-
Notifications
You must be signed in to change notification settings - Fork 0
/
490.54670fa5549b03faba89.js
1 lines (1 loc) · 168 KB
/
490.54670fa5549b03faba89.js
1
(self.webpackChunksparkworks_console=self.webpackChunksparkworks_console||[]).push([[490],{85831:function(we,ne,q){"use strict";q.d(ne,{b:function(){return xn}});var Y=q(33542),ce=q(96638),x={keyPrefix:"aws-amplify-cache",capacityInBytes:1048576,itemMaxSize:21e4,defaultTTL:2592e5,defaultPriority:5,warningThreshold:.8,storage:(new(q(70622).c4)).getStorage()};function ie(i){var t=0;t=i.length;for(var e=i.length;e>=0;e-=1){var n=i.charCodeAt(e);n>127&&n<=2047?t+=1:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&(e-=1)}return t}function G(){return(new Date).getTime()}function S(i){return Number.isInteger?Number.isInteger(i):function(i){return"number"==typeof i&&isFinite(i)&&Math.floor(i)===i}(i)}var i,I={},V=(function(){function i(){}i.clear=function(){I={}},i.getItem=function(t){return I[t]||null},i.setItem=function(t,e){I[t]=e},i.removeItem=function(t){delete I[t]}}(),q(45013)),M=new V.k("StorageCache"),Z=function(){function i(t){this.config=Object.assign({},t),this.cacheCurSizeKey=this.config.keyPrefix+"CurSize",this.checkConfig()}return i.prototype.getModuleName=function(){return"Cache"},i.prototype.checkConfig=function(){S(this.config.capacityInBytes)||(M.error("Invalid parameter: capacityInBytes. It should be an Integer. Setting back to default."),this.config.capacityInBytes=x.capacityInBytes),S(this.config.itemMaxSize)||(M.error("Invalid parameter: itemMaxSize. It should be an Integer. Setting back to default."),this.config.itemMaxSize=x.itemMaxSize),S(this.config.defaultTTL)||(M.error("Invalid parameter: defaultTTL. It should be an Integer. Setting back to default."),this.config.defaultTTL=x.defaultTTL),S(this.config.defaultPriority)||(M.error("Invalid parameter: defaultPriority. It should be an Integer. Setting back to default."),this.config.defaultPriority=x.defaultPriority),this.config.itemMaxSize>this.config.capacityInBytes&&(M.error("Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default."),this.config.itemMaxSize=x.itemMaxSize),(this.config.defaultPriority>5||this.config.defaultPriority<1)&&(M.error("Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default."),this.config.defaultPriority=x.defaultPriority),(Number(this.config.warningThreshold)>1||Number(this.config.warningThreshold)<0)&&(M.error("Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default."),this.config.warningThreshold=x.warningThreshold),this.config.capacityInBytes>5242880&&(M.error("Cache Capacity should be less than 5MB. Setting back to default. Setting back to default."),this.config.capacityInBytes=x.capacityInBytes)},i.prototype.fillCacheItem=function(t,e,n){var r={key:t,data:e,timestamp:G(),visitedTime:G(),priority:n.priority,expires:n.expires,type:typeof e,byteSize:0};return r.byteSize=ie(JSON.stringify(r)),r.byteSize=ie(JSON.stringify(r)),r},i.prototype.configure=function(t){return t?(t.keyPrefix&&M.warn("Don't try to configure keyPrefix!"),this.config=Object.assign({},this.config,t,t.Cache),this.checkConfig(),this.config):this.config},i}(),ee=(i=function(e,n){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a])})(e,n)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),W=new V.k("Cache"),he=new(function(i){function t(e){var n=this,r=e?Object.assign({},x,e):x;return(n=i.call(this,r)||this).config.storage=r.storage,n.getItem=n.getItem.bind(n),n.setItem=n.setItem.bind(n),n.removeItem=n.removeItem.bind(n),n}return ee(t,i),t.prototype._decreaseCurSizeInBytes=function(e){var n=this.getCacheCurSize();this.config.storage.setItem(this.cacheCurSizeKey,(n-e).toString())},t.prototype._increaseCurSizeInBytes=function(e){var n=this.getCacheCurSize();this.config.storage.setItem(this.cacheCurSizeKey,(n+e).toString())},t.prototype._refreshItem=function(e,n){return e.visitedTime=G(),this.config.storage.setItem(n,JSON.stringify(e)),e},t.prototype._isExpired=function(e){var n=this.config.storage.getItem(e),r=JSON.parse(n);return G()>=r.expires},t.prototype._removeItem=function(e,n){var r=n||JSON.parse(this.config.storage.getItem(e)).byteSize;this._decreaseCurSizeInBytes(r),this.config.storage.removeItem(e)},t.prototype._setItem=function(e,n){this._increaseCurSizeInBytes(n.byteSize);try{this.config.storage.setItem(e,JSON.stringify(n))}catch(r){this._decreaseCurSizeInBytes(n.byteSize),W.error("Failed to set item "+r)}},t.prototype._sizeToPop=function(e){var n=this.getCacheCurSize()+e-this.config.capacityInBytes,r=(1-this.config.warningThreshold)*this.config.capacityInBytes;return n>r?n:r},t.prototype._isCacheFull=function(e){return e+this.getCacheCurSize()>this.config.capacityInBytes},t.prototype._findValidKeys=function(){for(var e=[],n=[],r=0;r<this.config.storage.length;r+=1)n.push(this.config.storage.key(r));for(r=0;r<n.length;r+=1){var o=n[r];0===o.indexOf(this.config.keyPrefix)&&o!==this.cacheCurSizeKey&&(this._isExpired(o)?this._removeItem(o):e.push(o))}return e},t.prototype._popOutItems=function(e,n){for(var r=[],o=n,a=0;a<e.length;a+=1){var c=this.config.storage.getItem(e[a]);if(null!=c){var l=JSON.parse(c);r.push(l)}}for(r.sort(function(s,d){return s.priority>d.priority?-1:s.priority<d.priority?1:s.visitedTime<d.visitedTime?-1:1}),a=0;a<r.length;a+=1)if(this._removeItem(r[a].key,r[a].byteSize),(o-=r[a].byteSize)<=0)return},t.prototype.setItem=function(e,n,r){W.log("Set item: key is "+e+", value is "+n+" with options: "+r);var o=this.config.keyPrefix+e;if(o!==this.config.keyPrefix&&o!==this.cacheCurSizeKey)if(void 0!==n){var a={priority:r&&void 0!==r.priority?r.priority:this.config.defaultPriority,expires:r&&void 0!==r.expires?r.expires:this.config.defaultTTL+G()};if(a.priority<1||a.priority>5)W.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");else{var c=this.fillCacheItem(o,n,a);if(c.byteSize>this.config.itemMaxSize)W.warn("Item with key: "+e+" you are trying to put into is too big!");else try{var l=this.config.storage.getItem(o);if(l&&this._removeItem(o,JSON.parse(l).byteSize),this._isCacheFull(c.byteSize)){var s=this._findValidKeys();if(this._isCacheFull(c.byteSize)){var d=this._sizeToPop(c.byteSize);this._popOutItems(s,d)}}this._setItem(o,c)}catch(_){W.warn("setItem failed! "+_)}}}else W.warn("The value of item should not be undefined!");else W.warn("Invalid key: should not be empty or 'CurSize'")},t.prototype.getItem=function(e,n){W.log("Get item: key is "+e+" with options "+n);var r=null,o=this.config.keyPrefix+e;if(o===this.config.keyPrefix||o===this.cacheCurSizeKey)return W.warn("Invalid key: should not be empty or 'CurSize'"),null;try{if(null!=(r=this.config.storage.getItem(o))){if(!this._isExpired(o)){var a=JSON.parse(r);return(a=this._refreshItem(a,o)).data}this._removeItem(o,JSON.parse(r).byteSize),r=null}if(n&&void 0!==n.callback){var c=n.callback();return null!==c&&this.setItem(e,c,n),c}return null}catch(l){return W.warn("getItem failed! "+l),null}},t.prototype.removeItem=function(e){W.log("Remove item: key is "+e);var n=this.config.keyPrefix+e;if(n!==this.config.keyPrefix&&n!==this.cacheCurSizeKey)try{var r=this.config.storage.getItem(n);r&&this._removeItem(n,JSON.parse(r).byteSize)}catch(o){W.warn("removeItem failed! "+o)}},t.prototype.clear=function(){W.log("Clear Cache");for(var e=[],n=0;n<this.config.storage.length;n+=1){var r=this.config.storage.key(n);0===r.indexOf(this.config.keyPrefix)&&e.push(r)}try{for(n=0;n<e.length;n+=1)this.config.storage.removeItem(e[n])}catch(o){W.warn("clear failed! "+o)}},t.prototype.getAllKeys=function(){for(var e=[],n=0;n<this.config.storage.length;n+=1){var r=this.config.storage.key(n);0===r.indexOf(this.config.keyPrefix)&&r!==this.cacheCurSizeKey&&e.push(r.substring(this.config.keyPrefix.length))}return e},t.prototype.getCacheCurSize=function(){var e=this.config.storage.getItem(this.cacheCurSizeKey);return e||(this.config.storage.setItem(this.cacheCurSizeKey,"0"),e="0"),Number(e)},t.prototype.createInstance=function(e){return(!e.keyPrefix||e.keyPrefix===x.keyPrefix)&&(W.error("invalid keyPrefix, setting keyPrefix with timeStamp"),e.keyPrefix=G.toString()),new t(e)},t}(Z)),Te=he;ce.dQ.register(he);var be=q(57857),_e=q(44497),v={clockOffset:0,getDateWithClockOffset:function(){return v.clockOffset?new Date((new Date).getTime()+v.clockOffset):new Date},getClockOffset:function(){return v.clockOffset},getHeaderStringFromDate:function(t){return void 0===t&&(t=v.getDateWithClockOffset()),t.toISOString().replace(/[:\-]|\.\d{3}/g,"")},getDateFromHeaderString:function(t){var e=function(i,t){var e="function"==typeof Symbol&&i[Symbol.iterator];if(!e)return i;var r,a,n=e.call(i),o=[];try{for(;(void 0===t||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(c){a={error:c}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return o}(t.match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2}).+/),7),r=e[2],o=e[3],a=e[4],c=e[5],l=e[6];return new Date(Date.UTC(Number(e[1]),Number(r)-1,Number(o),Number(a),Number(c),Number(l)))},isClockSkewed:function(t){return Math.abs(t.getTime()-v.getDateWithClockOffset().getTime())>=3e5},isClockSkewError:function(t){if(!t.response||!t.response.headers)return!1;var e=t.response.headers;return Boolean(["BadRequestException","InvalidSignatureException"].includes(e["x-amzn-errortype"])&&(e.date||e.Date))},setClockOffset:function(t){v.clockOffset=t}},f=q(1093),u=q(14241),h=q(74476),p=function(){return(p=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},g=new V.k("Signer"),w="AWS4-HMAC-SHA256",m=function(t,e){var n=new f.Sha256(t);return n.update(e),n.digestSync()},A=function(t){var e=t||"",n=new f.Sha256;return n.update(e),(0,u.N)(n.digestSync())},B=function(t){return t&&0!==t.length?t.split("&").map(function(e){var n=e.split("=");if(1===n.length)return e;var r=function(t){return t.replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}(n[1]);return n[0]+"="+r}).sort(function(e,n){var r=e.split("=")[0],o=n.split("=")[0];return r===o?e<n?-1:1:r<o?-1:1}).join("&"):""},T=function(t){return t&&0!==Object.keys(t).length?Object.keys(t).map(function(e){return{key:e.toLowerCase(),value:t[e]?t[e].trim().replace(/\s+/g," "):""}}).sort(function(e,n){return e.key<n.key?-1:1}).map(function(e){return e.key+":"+e.value}).join("\n")+"\n":""},R=function(t){return Object.keys(t).map(function(e){return e.toLowerCase()}).sort().join(";")},$=function(t){var e=(0,h.Qc)(t.url);return[t.method||"/",encodeURIComponent(e.pathname).replace(/%2F/gi,"/"),B(e.query),T(t.headers),R(t.headers),A(t.data)].join("\n")},me=function(t){var o=((0,h.Qc)(t.url).host.match(/([^\.]+)\.(?:([^\.]*)\.)?amazonaws\.com$/)||[]).slice(1,3);return"es"===o[1]&&(o=o.reverse()),{service:t.service||o[0],region:t.region||o[1]}},se=function(t,e,n){return[t,e,n,"aws4_request"].join("/")},at=function(t,e,n,r){return[t,n,r,A(e)].join("\n")},Bt=function(t,e,n){g.debug(n);var o=m("AWS4"+t,e),a=m(o,n.region),c=m(a,n.service);return m(c,"aws4_request")},jt=function(t,e){return(0,u.N)(m(t,e))},Vt=function(){function i(){}return i.sign=function(t,e,n){if(void 0===n&&(n=null),t.headers=t.headers||{},t.body&&!t.data)throw new Error('The attribute "body" was found on the request object. Please use the attribute "data" instead.');var o=v.getDateWithClockOffset().toISOString().replace(/[:\-]|\.\d{3}/g,""),a=o.substr(0,8),c=(0,h.Qc)(t.url);t.headers.host=c.host,t.headers["x-amz-date"]=o,e.session_token&&(t.headers["X-Amz-Security-Token"]=e.session_token);var l=$(t);g.debug(l);var s=n||me(t),d=se(a,s.region,s.service),_=at(w,l,o,d),N=Bt(e.secret_key,a,s),O=jt(N,_),C=function(t,e,n,r,o){return["AWS4-HMAC-SHA256 Credential="+e+"/"+n,"SignedHeaders="+r,"Signature="+o].join(", ")}(0,e.access_key,d,R(t.headers),O);return t.headers.Authorization=C,t},i.signUrl=function(t,e,n,r){var o="object"==typeof t?t.url:t,a="object"==typeof t?t.method:"GET",c="object"==typeof t?t.body:void 0,l=v.getDateWithClockOffset().toISOString().replace(/[:\-]|\.\d{3}/g,""),s=l.substr(0,8),N=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(null!=i&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]])}return e}((0,h.Qc)(o,!0,!0),["search"]),C={host:N.host},P=n||me({url:(0,h.WU)(N)}),F=P.region,j=P.service,H=se(s,F,j),te=e.session_token&&"iotdevicegateway"!==j,re=p(p(p({"X-Amz-Algorithm":w,"X-Amz-Credential":[e.access_key,H].join("/"),"X-Amz-Date":l.substr(0,16)},te?{"X-Amz-Security-Token":""+e.session_token}:{}),r?{"X-Amz-Expires":""+r}:{}),{"X-Amz-SignedHeaders":Object.keys(C).join(",")}),J=$({method:a,url:(0,h.WU)(p(p({},N),{query:p(p({},N.query),re)})),headers:C,data:c}),oe=at(w,J,l,H),le=Bt(e.secret_key,s,{region:F,service:j}),ae=jt(le,oe),ve=p({"X-Amz-Signature":ae},e.session_token&&{"X-Amz-Security-Token":e.session_token});return(0,h.WU)({protocol:N.protocol,slashes:!0,hostname:N.hostname,port:N.port,pathname:N.pathname,query:p(p(p({},N.query),re),ve)})},i}(),Rn=q(9982),st=q.n(Rn),De=function(){return(De=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},qt=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(null!=i&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]])}return e},Je=new V.k("RestClient"),Kt=function(){function i(t){this._region="us-east-1",this._service="execute-api",this._custom_header=void 0,this._cancelTokenMap=null,this.Credentials=be.cN,this._options=t,Je.debug("API Options",this._options),null==this._cancelTokenMap&&(this._cancelTokenMap=new WeakMap)}return i.prototype.ajax=function(t,e,n){return function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})}(this,void 0,void 0,function(){var r,o,a,c,l,s,d,N,O,C,P,F,H,te=this;return function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}}(this,function(re){switch(re.label){case 0:return Je.debug(e,t),a="us-east-1",c="execute-api",l=void 0,"string"==typeof t?(r=this._parseUrl(t),o=t):(o=t.endpoint,l=t.custom_header,a=t.region,c=t.service,r=this._parseUrl(t.endpoint)),s={method:e,url:o,host:r.host,path:r.path,headers:{},data:null,responseType:"json",timeout:0,cancelToken:null},d={},_e.t4.isReactNative&&(d={"User-Agent":_e.t4.userAgent||"aws-amplify/0.1.x"}),N=Object.assign({},n),O=N.response,N.body&&("function"==typeof FormData&&N.body instanceof FormData?(d["Content-Type"]="multipart/form-data",s.data=N.body):(d["Content-Type"]="application/json; charset=UTF-8",s.data=JSON.stringify(N.body))),N.responseType&&(s.responseType=N.responseType),N.withCredentials&&(s.withCredentials=N.withCredentials),N.timeout&&(s.timeout=N.timeout),N.cancellableToken&&(s.cancelToken=N.cancellableToken.token),s.signerServiceInfo=N.signerServiceInfo,"function"!=typeof l?[3,2]:[4,l()];case 1:return P=re.sent(),[3,3];case 2:P=void 0,re.label=3;case 3:return C=P,s.headers=De(De(De({},d),C),N.headers),F=(0,h.Qc)(o,!0,!0),H=qt(F,["search"]),s.url=(0,h.WU)(De(De({},H),{query:De(De({},H.query),N.queryStringParameters||{})})),void 0!==s.headers.Authorization?(s.headers=Object.keys(s.headers).reduce(function(J,oe){return s.headers[oe]&&(J[oe]=s.headers[oe]),J},{}),[2,this._request(s,O)]):[2,this.Credentials.get().then(function(J){return te._signed(De({},s),J,O,{region:a,service:c}).catch(function(oe){if(v.isClockSkewError(oe)){var le=oe.response.headers,ve=new Date(le&&(le.date||le.Date)),ye=v.getDateFromHeaderString(s.headers["x-amz-date"]);if(v.isClockSkewed(ve))return v.setClockOffset(ve.getTime()-ye.getTime()),te.ajax(t,e,n)}throw oe})},function(J){return Je.debug("No credentials available, the request will be unsigned"),te._request(s,O)})]}})})},i.prototype.get=function(t,e){return this.ajax(t,"GET",e)},i.prototype.put=function(t,e){return this.ajax(t,"PUT",e)},i.prototype.patch=function(t,e){return this.ajax(t,"PATCH",e)},i.prototype.post=function(t,e){return this.ajax(t,"POST",e)},i.prototype.del=function(t,e){return this.ajax(t,"DELETE",e)},i.prototype.head=function(t,e){return this.ajax(t,"HEAD",e)},i.prototype.cancel=function(t,e){var n=this._cancelTokenMap.get(t);return!!n&&(n.cancel(e),!0)},i.prototype.hasCancelToken=function(t){return this._cancelTokenMap.has(t)},i.prototype.isCancel=function(t){return st().isCancel(t)},i.prototype.getCancellableToken=function(){return st().CancelToken.source()},i.prototype.updateRequestToBeCancellable=function(t,e){this._cancelTokenMap.set(t,e)},i.prototype.endpoint=function(t){var e=this,n=this._options.endpoints,r="";return Array.isArray(n)&&n.forEach(function(o){o.name===t&&(r=o.endpoint,"string"==typeof o.region?e._region=o.region:"string"==typeof e._options.region&&(e._region=e._options.region),e._service="string"==typeof o.service&&o.service||"execute-api",e._custom_header="function"==typeof o.custom_header?o.custom_header:void 0)}),r},i.prototype._signed=function(t,e,n,r){var o=r.service,a=r.region,c=t.signerServiceInfo,l=qt(t,["signerServiceInfo"]),_={secret_key:e.secretAccessKey,access_key:e.accessKeyId,session_token:e.sessionToken},O=Object.assign({region:a||this._region||this._options.region,service:o||this._service||this._options.service},c),C=Vt.sign(l,_,O);return C.data&&(C.body=C.data),Je.debug("Signed Request: ",C),delete C.headers.host,st()(C).then(function(P){return n?P:P.data}).catch(function(P){throw Je.debug(P),P})},i.prototype._request=function(t,e){return void 0===e&&(e=!1),st()(t).then(function(n){return e?n:n.data}).catch(function(n){throw Je.debug(n),n})},i.prototype._parseUrl=function(t){var e=t.split("/");return{host:e[2],path:"/"+e.slice(3).join("/")}},i}(),ct=function(){return(ct=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},ut=new V.k("RestAPI"),Gt=function(){function i(t){this._api=null,this.Credentials=be.cN,this._options=t,ut.debug("API Options",this._options)}return i.prototype.getModuleName=function(){return"RestAPI"},i.prototype.configure=function(t){var e=t||{},n=e.API,r=void 0===n?{}:n,o=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(null!=i&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]])}return e}(e,["API"]),a=ct(ct({},o),r);if(ut.debug("configure Rest API",{opt:a}),a.aws_project_region){if(a.aws_cloud_logic_custom){var c=a.aws_cloud_logic_custom;a.endpoints="string"==typeof c?JSON.parse(c):c}a=Object.assign({},a,{region:a.aws_project_region,header:{}})}return Array.isArray(a.endpoints)?a.endpoints.forEach(function(l){void 0!==l.custom_header&&"function"!=typeof l.custom_header&&(ut.warn("Rest API "+l.name+", custom_header should be a function"),l.custom_header=void 0)}):a.endpoints=this._options&&Array.isArray(this._options.endpoints)?this._options.endpoints:[],this._options=Object.assign({},this._options,a),this.createInstance(),this._options},i.prototype.createInstance=function(){return ut.debug("create Rest API instance"),this._api=new Kt(this._options),this._api.Credentials=this.Credentials,!0},i.prototype.get=function(t,e,n){try{var r=this.getEndpointInfo(t,e),o=this._api.getCancellableToken(),a=Object.assign({},n);a.cancellableToken=o;var c=this._api.get(r,a);return this._api.updateRequestToBeCancellable(c,o),c}catch(l){return Promise.reject(l.message)}},i.prototype.post=function(t,e,n){try{var r=this.getEndpointInfo(t,e),o=this._api.getCancellableToken(),a=Object.assign({},n);a.cancellableToken=o;var c=this._api.post(r,a);return this._api.updateRequestToBeCancellable(c,o),c}catch(l){return Promise.reject(l.message)}},i.prototype.put=function(t,e,n){try{var r=this.getEndpointInfo(t,e),o=this._api.getCancellableToken(),a=Object.assign({},n);a.cancellableToken=o;var c=this._api.put(r,a);return this._api.updateRequestToBeCancellable(c,o),c}catch(l){return Promise.reject(l.message)}},i.prototype.patch=function(t,e,n){try{var r=this.getEndpointInfo(t,e),o=this._api.getCancellableToken(),a=Object.assign({},n);a.cancellableToken=o;var c=this._api.patch(r,a);return this._api.updateRequestToBeCancellable(c,o),c}catch(l){return Promise.reject(l.message)}},i.prototype.del=function(t,e,n){try{var r=this.getEndpointInfo(t,e),o=this._api.getCancellableToken(),a=Object.assign({},n);a.cancellableToken=o;var c=this._api.del(r,a);return this._api.updateRequestToBeCancellable(c,o),c}catch(l){return Promise.reject(l.message)}},i.prototype.head=function(t,e,n){try{var r=this.getEndpointInfo(t,e),o=this._api.getCancellableToken(),a=Object.assign({},n);a.cancellableToken=o;var c=this._api.head(r,a);return this._api.updateRequestToBeCancellable(c,o),c}catch(l){return Promise.reject(l.message)}},i.prototype.isCancel=function(t){return this._api.isCancel(t)},i.prototype.cancel=function(t,e){return this._api.cancel(t,e)},i.prototype.hasCancelToken=function(t){return this._api.hasCancelToken(t)},i.prototype.endpoint=function(t){return function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})}(this,void 0,void 0,function(){return function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}}(this,function(e){return[2,this._api.endpoint(t)]})})},i.prototype.getEndpointInfo=function(t,e){var n=this._options.endpoints;if(!Array.isArray(n))throw new Error("API category not configured");var r=n.find(function(a){return a.name===t});if(!r)throw new Error("API "+t+" does not exist");var o={endpoint:r.endpoint+e};return"string"==typeof r.region?o.region=r.region:"string"==typeof this._options.region&&(o.region=this._options.region),o.service="string"==typeof r.service&&r.service||"execute-api",o.custom_header="function"==typeof r.custom_header?r.custom_header:void 0,o},i}(),jn=new Gt(null);function ft(i){return(ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(i)}ce.dQ.register(jn),"function"==typeof Symbol&&null!=Symbol.iterator&&Symbol,"function"==typeof Symbol&&null!=Symbol.asyncIterator&&Symbol;var zt="function"==typeof Symbol&&null!=Symbol.toStringTag?Symbol.toStringTag:"@@toStringTag";function Tt(i,t){for(var o,e=/\r\n|[\n\r]/g,n=1,r=t+1;(o=e.exec(i.body))&&o.index<t;)n+=1,r=t+1-(o.index+o[0].length);return{line:n,column:r}}function qn(i){return Qt(i.source,Tt(i.source,i.start))}function Qt(i,t){var e=i.locationOffset.column-1,n=lt(e)+i.body,r=t.line-1,a=t.line+(i.locationOffset.line-1),l=t.column+(1===t.line?e:0),s="".concat(i.name,":").concat(a,":").concat(l,"\n"),d=n.split(/\r\n|[\n\r]/g),_=d[r];if(_.length>120){for(var N=Math.floor(l/80),O=l%80,C=[],P=0;P<_.length;P+=80)C.push(_.slice(P,P+80));return s+Wt([["".concat(a),C[0]]].concat(C.slice(1,N+1).map(function(F){return["",F]}),[[" ",lt(O-1)+"^"],["",C[N+1]]]))}return s+Wt([["".concat(a-1),d[r-1]],["".concat(a),_],["",lt(l-1)+"^"],["".concat(a+1),d[r+1]]])}function Wt(i){var t=i.filter(function(n){return void 0!==n[1]}),e=Math.max.apply(Math,t.map(function(n){return n[0].length}));return t.map(function(n){var o=n[1];return function(i,t){return lt(i-t.length)+t}(e,n[0])+(o?" | "+o:" |")}).join("\n")}function lt(i){return Array(i+1).join(" ")}function ht(i){return(ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(i)}function Jt(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);t&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),e.push.apply(e,n)}return e}function zn(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function Ht(i,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,n.key,n)}}function Yt(i,t){return!t||"object"!==ht(t)&&"function"!=typeof t?et(i):t}function et(i){if(void 0===i)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function It(i){var t="function"==typeof Map?new Map:void 0;return(It=function(n){if(null===n||!function(i){return-1!==Function.toString.call(i).indexOf("[native code]")}(n))return n;if("function"!=typeof n)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(n))return t.get(n);t.set(n,r)}function r(){return dt(n,arguments,nt(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),tt(r,n)})(i)}function dt(i,t,e){return(dt=Xt()?Reflect.construct:function(r,o,a){var c=[null];c.push.apply(c,o);var s=new(Function.bind.apply(r,c));return a&&tt(s,a.prototype),s}).apply(null,arguments)}function Xt(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(i){return!1}}function tt(i,t){return(tt=Object.setPrototypeOf||function(n,r){return n.__proto__=r,n})(i,t)}function nt(i){return(nt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(i)}var Me=function(i){!function(i,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&tt(i,t)}(e,i);var t=function(i){var t=Xt();return function(){var r,n=nt(i);if(t){var o=nt(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Yt(this,r)}}(e);function e(n,r,o,a,c,l,s){var d,_,N,O;(function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),(O=t.call(this,n)).name="GraphQLError",O.originalError=null!=l?l:void 0,O.nodes=Zt(Array.isArray(r)?r:r?[r]:void 0);for(var C=[],P=0,F=null!==(j=O.nodes)&&void 0!==j?j:[];P<F.length;P++){var j,te=F[P].loc;null!=te&&C.push(te)}C=Zt(C),O.source=null!=o?o:null===(d=C)||void 0===d?void 0:d[0].source,O.positions=null!=a?a:null===(_=C)||void 0===_?void 0:_.map(function(J){return J.start}),O.locations=a&&o?a.map(function(J){return Tt(o,J)}):null===(N=C)||void 0===N?void 0:N.map(function(J){return Tt(J.source,J.start)}),O.path=null!=c?c:void 0;var re=null==l?void 0:l.extensions;return O.extensions=null==s&&function(i){return"object"==ft(i)&&null!==i}(re)?function(i){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?Jt(Object(e),!0).forEach(function(n){zn(i,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Jt(Object(e)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(e,n))})}return i}({},re):null!=s?s:{},Object.defineProperties(et(O),{message:{enumerable:!0},locations:{enumerable:null!=O.locations},path:{enumerable:null!=O.path},extensions:{enumerable:null!=O.extensions&&Object.keys(O.extensions).length>0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=l&&l.stack?(Object.defineProperty(et(O),"stack",{value:l.stack,writable:!0,configurable:!0}),Yt(O)):(Error.captureStackTrace?Error.captureStackTrace(et(O),e):Object.defineProperty(et(O),"stack",{value:Error().stack,writable:!0,configurable:!0}),O)}return function(i,t,e){t&&Ht(i.prototype,t)}(e,[{key:"toString",value:function(){return function(i){var t=i.message;if(i.nodes)for(var e=0,n=i.nodes;e<n.length;e++){var r=n[e];r.loc&&(t+="\n\n"+qn(r.loc))}else if(i.source&&i.locations)for(var o=0,a=i.locations;o<a.length;o++)t+="\n\n"+Qt(i.source,a[o]);return t}(this)}},{key:zt,get:function(){return"Object"}}]),e}(It(Error));function Zt(i){return void 0===i||0===i.length?void 0:i}function Ie(i,t,e){return new Me("Syntax Error: ".concat(e),void 0,i,[t])}var K=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"}),wt="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):void 0;function $t(i){var t=i.prototype.toJSON;"function"==typeof t||function(i,t){if(!Boolean(0))throw new Error("Unexpected invariant triggered.")}(),i.prototype.inspect=t,wt&&(i.prototype[wt]=t)}var en=function(){function i(e,n,r){this.start=e.start,this.end=n.end,this.startToken=e,this.endToken=n,this.source=r}return i.prototype.toJSON=function(){return{start:this.start,end:this.end}},i}();$t(en);var de=function(){function i(e,n,r,o,a,c,l){this.kind=e,this.start=n,this.end=r,this.line=o,this.column=a,this.value=l,this.prev=c,this.next=null}return i.prototype.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},i}();function tn(i){return null!=i&&"string"==typeof i.kind}$t(de);var E=Object.freeze({SOF:"<SOF>",EOF:"<EOF>",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function pt(i){return(pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(i)}function rn(i){return vt(i,[])}function vt(i,t){switch(pt(i)){case"string":return JSON.stringify(i);case"function":return i.name?"[function ".concat(i.name,"]"):"[function]";case"object":return null===i?"null":function(i,t){if(-1!==t.indexOf(i))return"[Circular]";var e=[].concat(t,[i]),n=function(i){var t=i[String(wt)];return"function"==typeof t?t:"function"==typeof i.inspect?i.inspect:void 0}(i);if(void 0!==n){var r=n.call(i);if(r!==i)return"string"==typeof r?r:vt(r,e)}else if(Array.isArray(i))return function(i,t){if(0===i.length)return"[]";if(t.length>2)return"[Array]";for(var e=Math.min(10,i.length),n=i.length-e,r=[],o=0;o<e;++o)r.push(vt(i[o],t));return 1===n?r.push("... 1 more item"):n>1&&r.push("... ".concat(n," more items")),"["+r.join(", ")+"]"}(i,e);return function(i,t){var e=Object.keys(i);return 0===e.length?"{}":t.length>2?"["+function(i){var t=Object.prototype.toString.call(i).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof i.constructor){var e=i.constructor.name;if("string"==typeof e&&""!==e)return e}return t}(i)+"]":"{ "+e.map(function(r){return r+": "+vt(i[r],t)}).join(", ")+" }"}(i,e)}(i,t);default:return String(i)}}function Nt(i,t){if(!Boolean(i))throw new Error(t)}function on(i,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,n.key,n)}}var an=function(){function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GraphQL request",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{line:1,column:1};"string"==typeof t||Nt(0,"Body must be a string. Received: ".concat(rn(t),".")),this.body=t,this.name=e,this.locationOffset=n,this.locationOffset.line>0||Nt(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Nt(0,"column in locationOffset is 1-indexed and must be positive.")}return function(i,t,e){t&&on(i.prototype,t)}(i,[{key:zt,get:function(){return"Source"}}]),i}(),ur=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function fr(i){var t=i.split(/\r\n|[\n\r]/g),e=function(i){for(var t,e=!0,n=!0,r=0,o=null,a=0;a<i.length;++a)switch(i.charCodeAt(a)){case 13:10===i.charCodeAt(a+1)&&++a;case 10:e=!1,n=!0,r=0;break;case 9:case 32:++r;break;default:n&&!e&&(null===o||r<o)&&(o=r),n=!1}return null!==(t=o)&&void 0!==t?t:0}(i);if(0!==e)for(var n=1;n<t.length;n++)t[n]=t[n].slice(e);for(var r=0;r<t.length&&sn(t[r]);)++r;for(var o=t.length;o>r&&sn(t[o-1]);)--o;return t.slice(r,o).join("\n")}function sn(i){for(var t=0;t<i.length;++t)if(" "!==i[t]&&"\t"!==i[t])return!1;return!0}var dr=function(){function i(e){var n=new de(E.SOF,0,0,0,0,null);this.source=e,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}var t=i.prototype;return t.advance=function(){return this.lastToken=this.token,this.token=this.lookahead()},t.lookahead=function(){var n=this.token;if(n.kind!==E.EOF)do{var r;n=null!==(r=n.next)&&void 0!==r?r:n.next=vr(this,n)}while(n.kind===E.COMMENT);return n},i}();function Ge(i){return isNaN(i)?E.EOF:i<127?JSON.stringify(String.fromCharCode(i)):'"\\u'.concat(("00"+i.toString(16).toUpperCase()).slice(-4),'"')}function vr(i,t){for(var e=i.source,n=e.body,r=n.length,o=t.end;o<r;){var a=n.charCodeAt(o),c=i.line,l=1+o-i.lineStart;switch(a){case 65279:case 9:case 32:case 44:++o;continue;case 10:++o,++i.line,i.lineStart=o;continue;case 13:10===n.charCodeAt(o+1)?o+=2:++o,++i.line,i.lineStart=o;continue;case 33:return new de(E.BANG,o,o+1,c,l,t);case 35:return gr(e,o,c,l,t);case 36:return new de(E.DOLLAR,o,o+1,c,l,t);case 38:return new de(E.AMP,o,o+1,c,l,t);case 40:return new de(E.PAREN_L,o,o+1,c,l,t);case 41:return new de(E.PAREN_R,o,o+1,c,l,t);case 46:if(46===n.charCodeAt(o+1)&&46===n.charCodeAt(o+2))return new de(E.SPREAD,o,o+3,c,l,t);break;case 58:return new de(E.COLON,o,o+1,c,l,t);case 61:return new de(E.EQUALS,o,o+1,c,l,t);case 64:return new de(E.AT,o,o+1,c,l,t);case 91:return new de(E.BRACKET_L,o,o+1,c,l,t);case 93:return new de(E.BRACKET_R,o,o+1,c,l,t);case 123:return new de(E.BRACE_L,o,o+1,c,l,t);case 124:return new de(E.PIPE,o,o+1,c,l,t);case 125:return new de(E.BRACE_R,o,o+1,c,l,t);case 34:return 34===n.charCodeAt(o+1)&&34===n.charCodeAt(o+2)?br(e,o,c,l,t,i):mr(e,o,c,l,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return _r(e,o,a,c,l,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return Er(e,o,c,l,t)}throw Ie(e,o,yr(a))}return new de(E.EOF,r,r,i.line,1+o-i.lineStart,t)}function yr(i){return i<32&&9!==i&&10!==i&&13!==i?"Cannot contain the invalid character ".concat(Ge(i),"."):39===i?"Unexpected single quote character ('), did you mean to use a double quote (\")?":"Cannot parse the unexpected character ".concat(Ge(i),".")}function gr(i,t,e,n,r){var a,o=i.body,c=t;do{a=o.charCodeAt(++c)}while(!isNaN(a)&&(a>31||9===a));return new de(E.COMMENT,t,c,e,n,r,o.slice(t+1,c))}function _r(i,t,e,n,r,o){var a=i.body,c=e,l=t,s=!1;if(45===c&&(c=a.charCodeAt(++l)),48===c){if((c=a.charCodeAt(++l))>=48&&c<=57)throw Ie(i,l,"Invalid number, unexpected digit after 0: ".concat(Ge(c),"."))}else l=At(i,l,c),c=a.charCodeAt(l);if(46===c&&(s=!0,c=a.charCodeAt(++l),l=At(i,l,c),c=a.charCodeAt(l)),(69===c||101===c)&&(s=!0,(43===(c=a.charCodeAt(++l))||45===c)&&(c=a.charCodeAt(++l)),l=At(i,l,c),c=a.charCodeAt(l)),46===c||function(i){return 95===i||i>=65&&i<=90||i>=97&&i<=122}(c))throw Ie(i,l,"Invalid number, expected digit but got: ".concat(Ge(c),"."));return new de(s?E.FLOAT:E.INT,t,l,n,r,o,a.slice(t,l))}function At(i,t,e){var n=i.body,r=t,o=e;if(o>=48&&o<=57){do{o=n.charCodeAt(++r)}while(o>=48&&o<=57);return r}throw Ie(i,r,"Invalid number, expected digit but got: ".concat(Ge(o),"."))}function mr(i,t,e,n,r){for(var o=i.body,a=t+1,c=a,l=0,s="";a<o.length&&!isNaN(l=o.charCodeAt(a))&&10!==l&&13!==l;){if(34===l)return s+=o.slice(c,a),new de(E.STRING,t,a+1,e,n,r,s);if(l<32&&9!==l)throw Ie(i,a,"Invalid character within String: ".concat(Ge(l),"."));if(++a,92===l){switch(s+=o.slice(c,a-1),l=o.charCodeAt(a)){case 34:s+='"';break;case 47:s+="/";break;case 92:s+="\\";break;case 98:s+="\b";break;case 102:s+="\f";break;case 110:s+="\n";break;case 114:s+="\r";break;case 116:s+="\t";break;case 117:var d=Sr(o.charCodeAt(a+1),o.charCodeAt(a+2),o.charCodeAt(a+3),o.charCodeAt(a+4));if(d<0){var _=o.slice(a+1,a+5);throw Ie(i,a,"Invalid character escape sequence: \\u".concat(_,"."))}s+=String.fromCharCode(d),a+=4;break;default:throw Ie(i,a,"Invalid character escape sequence: \\".concat(String.fromCharCode(l),"."))}c=++a}}throw Ie(i,a,"Unterminated string.")}function br(i,t,e,n,r,o){for(var a=i.body,c=t+3,l=c,s=0,d="";c<a.length&&!isNaN(s=a.charCodeAt(c));){if(34===s&&34===a.charCodeAt(c+1)&&34===a.charCodeAt(c+2))return d+=a.slice(l,c),new de(E.BLOCK_STRING,t,c+3,e,n,r,fr(d));if(s<32&&9!==s&&10!==s&&13!==s)throw Ie(i,c,"Invalid character within String: ".concat(Ge(s),"."));10===s?(++c,++o.line,o.lineStart=c):13===s?(10===a.charCodeAt(c+1)?c+=2:++c,++o.line,o.lineStart=c):92===s&&34===a.charCodeAt(c+1)&&34===a.charCodeAt(c+2)&&34===a.charCodeAt(c+3)?(d+=a.slice(l,c)+'"""',l=c+=4):++c}throw Ie(i,c,"Unterminated string.")}function Sr(i,t,e,n){return yt(i)<<12|yt(t)<<8|yt(e)<<4|yt(n)}function yt(i){return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:-1}function Er(i,t,e,n,r){for(var o=i.body,a=o.length,c=t+1,l=0;c!==a&&!isNaN(l=o.charCodeAt(c))&&(95===l||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122);)++c;return new de(E.NAME,t,c,e,n,r,o.slice(t,c))}function Ct(i,t){return new xt(i,t).parseDocument()}var xt=function(){function i(e,n){var r=function(i){return i instanceof an}(e)?e:new an(e);this._lexer=new dr(r),this._options=n}var t=i.prototype;return t.parseName=function(){var n=this.expectToken(E.NAME);return{kind:K.NAME,value:n.value,loc:this.loc(n)}},t.parseDocument=function(){var n=this._lexer.token;return{kind:K.DOCUMENT,definitions:this.many(E.SOF,this.parseDefinition,E.EOF),loc:this.loc(n)}},t.parseDefinition=function(){if(this.peek(E.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(E.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var n=this._lexer.token;if(this.peek(E.BRACE_L))return{kind:K.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(n)};var o,r=this.parseOperationType();return this.peek(E.NAME)&&(o=this.parseName()),{kind:K.OPERATION_DEFINITION,operation:r,name:o,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},t.parseOperationType=function(){var n=this.expectToken(E.NAME);switch(n.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(n)},t.parseVariableDefinitions=function(){return this.optionalMany(E.PAREN_L,this.parseVariableDefinition,E.PAREN_R)},t.parseVariableDefinition=function(){var n=this._lexer.token;return{kind:K.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(E.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(E.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(n)}},t.parseVariable=function(){var n=this._lexer.token;return this.expectToken(E.DOLLAR),{kind:K.VARIABLE,name:this.parseName(),loc:this.loc(n)}},t.parseSelectionSet=function(){var n=this._lexer.token;return{kind:K.SELECTION_SET,selections:this.many(E.BRACE_L,this.parseSelection,E.BRACE_R),loc:this.loc(n)}},t.parseSelection=function(){return this.peek(E.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var o,a,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(E.COLON)?(o=r,a=this.parseName()):a=r,{kind:K.FIELD,alias:o,name:a,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(E.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(n){return this.optionalMany(E.PAREN_L,n?this.parseConstArgument:this.parseArgument,E.PAREN_R)},t.parseArgument=function(){var n=this._lexer.token,r=this.parseName();return this.expectToken(E.COLON),{kind:K.ARGUMENT,name:r,value:this.parseValueLiteral(!1),loc:this.loc(n)}},t.parseConstArgument=function(){var n=this._lexer.token;return{kind:K.ARGUMENT,name:this.parseName(),value:(this.expectToken(E.COLON),this.parseValueLiteral(!0)),loc:this.loc(n)}},t.parseFragment=function(){var n=this._lexer.token;this.expectToken(E.SPREAD);var r=this.expectOptionalKeyword("on");return!r&&this.peek(E.NAME)?{kind:K.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(n)}:{kind:K.INLINE_FRAGMENT,typeCondition:r?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},t.parseFragmentDefinition=function(){var n,r=this._lexer.token;return this.expectKeyword("fragment"),!0===(null===(n=this._options)||void 0===n?void 0:n.experimentalFragmentVariables)?{kind:K.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(r)}:{kind:K.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(r)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(n){var r=this._lexer.token;switch(r.kind){case E.BRACKET_L:return this.parseList(n);case E.BRACE_L:return this.parseObject(n);case E.INT:return this._lexer.advance(),{kind:K.INT,value:r.value,loc:this.loc(r)};case E.FLOAT:return this._lexer.advance(),{kind:K.FLOAT,value:r.value,loc:this.loc(r)};case E.STRING:case E.BLOCK_STRING:return this.parseStringLiteral();case E.NAME:switch(this._lexer.advance(),r.value){case"true":return{kind:K.BOOLEAN,value:!0,loc:this.loc(r)};case"false":return{kind:K.BOOLEAN,value:!1,loc:this.loc(r)};case"null":return{kind:K.NULL,loc:this.loc(r)};default:return{kind:K.ENUM,value:r.value,loc:this.loc(r)}}case E.DOLLAR:if(!n)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var n=this._lexer.token;return this._lexer.advance(),{kind:K.STRING,value:n.value,block:n.kind===E.BLOCK_STRING,loc:this.loc(n)}},t.parseList=function(n){var r=this,o=this._lexer.token;return{kind:K.LIST,values:this.any(E.BRACKET_L,function(){return r.parseValueLiteral(n)},E.BRACKET_R),loc:this.loc(o)}},t.parseObject=function(n){var r=this,o=this._lexer.token;return{kind:K.OBJECT,fields:this.any(E.BRACE_L,function(){return r.parseObjectField(n)},E.BRACE_R),loc:this.loc(o)}},t.parseObjectField=function(n){var r=this._lexer.token,o=this.parseName();return this.expectToken(E.COLON),{kind:K.OBJECT_FIELD,name:o,value:this.parseValueLiteral(n),loc:this.loc(r)}},t.parseDirectives=function(n){for(var r=[];this.peek(E.AT);)r.push(this.parseDirective(n));return r},t.parseDirective=function(n){var r=this._lexer.token;return this.expectToken(E.AT),{kind:K.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(n),loc:this.loc(r)}},t.parseTypeReference=function(){var r,n=this._lexer.token;return this.expectOptionalToken(E.BRACKET_L)?(r=this.parseTypeReference(),this.expectToken(E.BRACKET_R),r={kind:K.LIST_TYPE,type:r,loc:this.loc(n)}):r=this.parseNamedType(),this.expectOptionalToken(E.BANG)?{kind:K.NON_NULL_TYPE,type:r,loc:this.loc(n)}:r},t.parseNamedType=function(){var n=this._lexer.token;return{kind:K.NAMED_TYPE,name:this.parseName(),loc:this.loc(n)}},t.parseTypeSystemDefinition=function(){var n=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(n.kind===E.NAME)switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(n)},t.peekDescription=function(){return this.peek(E.STRING)||this.peek(E.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("schema");var o=this.parseDirectives(!0),a=this.many(E.BRACE_L,this.parseOperationTypeDefinition,E.BRACE_R);return{kind:K.SCHEMA_DEFINITION,description:r,directives:o,operationTypes:a,loc:this.loc(n)}},t.parseOperationTypeDefinition=function(){var n=this._lexer.token,r=this.parseOperationType();this.expectToken(E.COLON);var o=this.parseNamedType();return{kind:K.OPERATION_TYPE_DEFINITION,operation:r,type:o,loc:this.loc(n)}},t.parseScalarTypeDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("scalar");var o=this.parseName(),a=this.parseDirectives(!0);return{kind:K.SCALAR_TYPE_DEFINITION,description:r,name:o,directives:a,loc:this.loc(n)}},t.parseObjectTypeDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("type");var o=this.parseName(),a=this.parseImplementsInterfaces(),c=this.parseDirectives(!0),l=this.parseFieldsDefinition();return{kind:K.OBJECT_TYPE_DEFINITION,description:r,name:o,interfaces:a,directives:c,fields:l,loc:this.loc(n)}},t.parseImplementsInterfaces=function(){var n;if(!this.expectOptionalKeyword("implements"))return[];if(!0===(null===(n=this._options)||void 0===n?void 0:n.allowLegacySDLImplementsInterfaces)){var r=[];this.expectOptionalToken(E.AMP);do{r.push(this.parseNamedType())}while(this.expectOptionalToken(E.AMP)||this.peek(E.NAME));return r}return this.delimitedMany(E.AMP,this.parseNamedType)},t.parseFieldsDefinition=function(){var n;return!0===(null===(n=this._options)||void 0===n?void 0:n.allowLegacySDLEmptyFields)&&this.peek(E.BRACE_L)&&this._lexer.lookahead().kind===E.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(E.BRACE_L,this.parseFieldDefinition,E.BRACE_R)},t.parseFieldDefinition=function(){var n=this._lexer.token,r=this.parseDescription(),o=this.parseName(),a=this.parseArgumentDefs();this.expectToken(E.COLON);var c=this.parseTypeReference(),l=this.parseDirectives(!0);return{kind:K.FIELD_DEFINITION,description:r,name:o,arguments:a,type:c,directives:l,loc:this.loc(n)}},t.parseArgumentDefs=function(){return this.optionalMany(E.PAREN_L,this.parseInputValueDef,E.PAREN_R)},t.parseInputValueDef=function(){var n=this._lexer.token,r=this.parseDescription(),o=this.parseName();this.expectToken(E.COLON);var c,a=this.parseTypeReference();this.expectOptionalToken(E.EQUALS)&&(c=this.parseValueLiteral(!0));var l=this.parseDirectives(!0);return{kind:K.INPUT_VALUE_DEFINITION,description:r,name:o,type:a,defaultValue:c,directives:l,loc:this.loc(n)}},t.parseInterfaceTypeDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("interface");var o=this.parseName(),a=this.parseImplementsInterfaces(),c=this.parseDirectives(!0),l=this.parseFieldsDefinition();return{kind:K.INTERFACE_TYPE_DEFINITION,description:r,name:o,interfaces:a,directives:c,fields:l,loc:this.loc(n)}},t.parseUnionTypeDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("union");var o=this.parseName(),a=this.parseDirectives(!0),c=this.parseUnionMemberTypes();return{kind:K.UNION_TYPE_DEFINITION,description:r,name:o,directives:a,types:c,loc:this.loc(n)}},t.parseUnionMemberTypes=function(){return this.expectOptionalToken(E.EQUALS)?this.delimitedMany(E.PIPE,this.parseNamedType):[]},t.parseEnumTypeDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("enum");var o=this.parseName(),a=this.parseDirectives(!0),c=this.parseEnumValuesDefinition();return{kind:K.ENUM_TYPE_DEFINITION,description:r,name:o,directives:a,values:c,loc:this.loc(n)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(E.BRACE_L,this.parseEnumValueDefinition,E.BRACE_R)},t.parseEnumValueDefinition=function(){var n=this._lexer.token,r=this.parseDescription(),o=this.parseName(),a=this.parseDirectives(!0);return{kind:K.ENUM_VALUE_DEFINITION,description:r,name:o,directives:a,loc:this.loc(n)}},t.parseInputObjectTypeDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("input");var o=this.parseName(),a=this.parseDirectives(!0),c=this.parseInputFieldsDefinition();return{kind:K.INPUT_OBJECT_TYPE_DEFINITION,description:r,name:o,directives:a,fields:c,loc:this.loc(n)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(E.BRACE_L,this.parseInputValueDef,E.BRACE_R)},t.parseTypeSystemExtension=function(){var n=this._lexer.lookahead();if(n.kind===E.NAME)switch(n.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(n)},t.parseSchemaExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var r=this.parseDirectives(!0),o=this.optionalMany(E.BRACE_L,this.parseOperationTypeDefinition,E.BRACE_R);if(0===r.length&&0===o.length)throw this.unexpected();return{kind:K.SCHEMA_EXTENSION,directives:r,operationTypes:o,loc:this.loc(n)}},t.parseScalarTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var r=this.parseName(),o=this.parseDirectives(!0);if(0===o.length)throw this.unexpected();return{kind:K.SCALAR_TYPE_EXTENSION,name:r,directives:o,loc:this.loc(n)}},t.parseObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var r=this.parseName(),o=this.parseImplementsInterfaces(),a=this.parseDirectives(!0),c=this.parseFieldsDefinition();if(0===o.length&&0===a.length&&0===c.length)throw this.unexpected();return{kind:K.OBJECT_TYPE_EXTENSION,name:r,interfaces:o,directives:a,fields:c,loc:this.loc(n)}},t.parseInterfaceTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var r=this.parseName(),o=this.parseImplementsInterfaces(),a=this.parseDirectives(!0),c=this.parseFieldsDefinition();if(0===o.length&&0===a.length&&0===c.length)throw this.unexpected();return{kind:K.INTERFACE_TYPE_EXTENSION,name:r,interfaces:o,directives:a,fields:c,loc:this.loc(n)}},t.parseUnionTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var r=this.parseName(),o=this.parseDirectives(!0),a=this.parseUnionMemberTypes();if(0===o.length&&0===a.length)throw this.unexpected();return{kind:K.UNION_TYPE_EXTENSION,name:r,directives:o,types:a,loc:this.loc(n)}},t.parseEnumTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var r=this.parseName(),o=this.parseDirectives(!0),a=this.parseEnumValuesDefinition();if(0===o.length&&0===a.length)throw this.unexpected();return{kind:K.ENUM_TYPE_EXTENSION,name:r,directives:o,values:a,loc:this.loc(n)}},t.parseInputObjectTypeExtension=function(){var n=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var r=this.parseName(),o=this.parseDirectives(!0),a=this.parseInputFieldsDefinition();if(0===o.length&&0===a.length)throw this.unexpected();return{kind:K.INPUT_OBJECT_TYPE_EXTENSION,name:r,directives:o,fields:a,loc:this.loc(n)}},t.parseDirectiveDefinition=function(){var n=this._lexer.token,r=this.parseDescription();this.expectKeyword("directive"),this.expectToken(E.AT);var o=this.parseName(),a=this.parseArgumentDefs(),c=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var l=this.parseDirectiveLocations();return{kind:K.DIRECTIVE_DEFINITION,description:r,name:o,arguments:a,repeatable:c,locations:l,loc:this.loc(n)}},t.parseDirectiveLocations=function(){return this.delimitedMany(E.PIPE,this.parseDirectiveLocation)},t.parseDirectiveLocation=function(){var n=this._lexer.token,r=this.parseName();if(void 0!==ur[r.value])return r;throw this.unexpected(n)},t.loc=function(n){var r;if(!0!==(null===(r=this._options)||void 0===r?void 0:r.noLocation))return new en(n,this._lexer.lastToken,this._lexer.source)},t.peek=function(n){return this._lexer.token.kind===n},t.expectToken=function(n){var r=this._lexer.token;if(r.kind===n)return this._lexer.advance(),r;throw Ie(this._lexer.source,r.start,"Expected ".concat(cn(n),", found ").concat(kt(r),"."))},t.expectOptionalToken=function(n){var r=this._lexer.token;if(r.kind===n)return this._lexer.advance(),r},t.expectKeyword=function(n){var r=this._lexer.token;if(r.kind!==E.NAME||r.value!==n)throw Ie(this._lexer.source,r.start,'Expected "'.concat(n,'", found ').concat(kt(r),"."));this._lexer.advance()},t.expectOptionalKeyword=function(n){var r=this._lexer.token;return r.kind===E.NAME&&r.value===n&&(this._lexer.advance(),!0)},t.unexpected=function(n){var r=null!=n?n:this._lexer.token;return Ie(this._lexer.source,r.start,"Unexpected ".concat(kt(r),"."))},t.any=function(n,r,o){this.expectToken(n);for(var a=[];!this.expectOptionalToken(o);)a.push(r.call(this));return a},t.optionalMany=function(n,r,o){if(this.expectOptionalToken(n)){var a=[];do{a.push(r.call(this))}while(!this.expectOptionalToken(o));return a}return[]},t.many=function(n,r,o){this.expectToken(n);var a=[];do{a.push(r.call(this))}while(!this.expectOptionalToken(o));return a},t.delimitedMany=function(n,r){this.expectOptionalToken(n);var o=[];do{o.push(r.call(this))}while(this.expectOptionalToken(n));return o},i}();function kt(i){var t=i.value;return cn(i.kind)+(null!=t?' "'.concat(t,'"'):"")}function cn(i){return function(i){return i===E.BANG||i===E.DOLLAR||i===E.AMP||i===E.PAREN_L||i===E.PAREN_R||i===E.SPREAD||i===E.COLON||i===E.EQUALS||i===E.AT||i===E.BRACKET_L||i===E.BRACKET_R||i===E.BRACE_L||i===E.PIPE||i===E.BRACE_R}(i)?'"'.concat(i,'"'):i}var Ir={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},rt=Object.freeze({});function Pt(i,t,e){var n=i[t];if(n){if(!e&&"function"==typeof n)return n;var r=e?n.leave:n.enter;if("function"==typeof r)return r}else{var o=e?i.leave:i.enter;if(o){if("function"==typeof o)return o;var a=o[t];if("function"==typeof a)return a}}}function Dt(i){return function(i,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ir,n=void 0,r=Array.isArray(i),o=[i],a=-1,c=[],l=void 0,s=void 0,d=void 0,_=[],N=[],O=i;do{var C=++a===o.length,P=C&&0!==c.length;if(C){if(s=0===N.length?void 0:_[_.length-1],l=d,d=N.pop(),P){if(r)l=l.slice();else{for(var F={},j=0,H=Object.keys(l);j<H.length;j++){var te=H[j];F[te]=l[te]}l=F}for(var re=0,J=0;J<c.length;J++){var oe=c[J][0],le=c[J][1];r&&(oe-=re),r&&null===le?(l.splice(oe,1),re++):l[oe]=le}}a=n.index,o=n.keys,c=n.edits,r=n.inArray,n=n.prev}else{if(s=d?r?a:o[a]:void 0,null==(l=d?d[s]:O))continue;d&&_.push(s)}var ye,ae=void 0;if(!Array.isArray(l)){if(!tn(l))throw new Error("Invalid AST Node: ".concat(rn(l),"."));var ve=Pt(t,l.kind,C);if(ve){if((ae=ve.call(t,l,s,d,_,N))===rt)break;if(!1===ae){if(!C){_.pop();continue}}else if(void 0!==ae&&(c.push([s,ae]),!C)){if(!tn(ae)){_.pop();continue}l=ae}}}void 0===ae&&P&&c.push([s,l]),C?_.pop():(n={inArray:r,index:a,keys:o,edits:c,prev:n},o=(r=Array.isArray(l))?l:null!==(ye=e[l.kind])&&void 0!==ye?ye:[],a=-1,c=[],d&&N.push(d),d=l)}while(void 0!==n);return 0!==c.length&&(O=c[c.length-1][1]),O}(i,{leave:Or})}var Or={Name:function(t){return t.value},Variable:function(t){return"$"+t.name},Document:function(t){return L(t.definitions,"\n\n")+"\n"},OperationDefinition:function(t){var e=t.operation,n=t.name,r=ue("(",L(t.variableDefinitions,", "),")"),o=L(t.directives," "),a=t.selectionSet;return n||o||r||"query"!==e?L([e,L([n,r]),o,a]," "):a},VariableDefinition:function(t){var o=t.directives;return t.variable+": "+t.type+ue(" = ",t.defaultValue)+ue(" ",L(o," "))},SelectionSet:function(t){return xe(t.selections)},Field:function(t){var n=t.name,r=t.arguments,o=t.directives,a=t.selectionSet,c=ue("",t.alias,": ")+n,l=c+ue("(",L(r,", "),")");return l.length>80&&(l=c+ue("(\n",gt(L(r,"\n")),"\n)")),L([l,L(o," "),a]," ")},Argument:function(t){return t.name+": "+t.value},FragmentSpread:function(t){return"..."+t.name+ue(" ",L(t.directives," "))},InlineFragment:function(t){var n=t.directives,r=t.selectionSet;return L(["...",ue("on ",t.typeCondition),L(n," "),r]," ")},FragmentDefinition:function(t){var n=t.typeCondition,r=t.variableDefinitions,o=t.directives,a=t.selectionSet;return"fragment ".concat(t.name).concat(ue("(",L(r,", "),")")," ")+"on ".concat(n," ").concat(ue("",L(o," ")," "))+a},IntValue:function(t){return t.value},FloatValue:function(t){return t.value},StringValue:function(t,e){var n=t.value;return t.block?function(i){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=-1===i.indexOf("\n"),r=" "===i[0]||"\t"===i[0],o='"'===i[i.length-1],a="\\"===i[i.length-1],c=!n||o||a||e,l="";return c&&!(n&&r)&&(l+="\n"+t),l+=t?i.replace(/\n/g,"\n"+t):i,c&&(l+="\n"),'"""'+l.replace(/"""/g,'\\"""')+'"""'}(n,"description"===e?"":" "):JSON.stringify(n)},BooleanValue:function(t){return t.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(t){return t.value},ListValue:function(t){return"["+L(t.values,", ")+"]"},ObjectValue:function(t){return"{"+L(t.fields,", ")+"}"},ObjectField:function(t){return t.name+": "+t.value},Directive:function(t){return"@"+t.name+ue("(",L(t.arguments,", "),")")},NamedType:function(t){return t.name},ListType:function(t){return"["+t.type+"]"},NonNullType:function(t){return t.type+"!"},SchemaDefinition:Ce(function(i){var e=i.operationTypes;return L(["schema",L(i.directives," "),xe(e)]," ")}),OperationTypeDefinition:function(t){return t.operation+": "+t.type},ScalarTypeDefinition:Ce(function(i){return L(["scalar",i.name,L(i.directives," ")]," ")}),ObjectTypeDefinition:Ce(function(i){var n=i.directives,r=i.fields;return L(["type",i.name,ue("implements ",L(i.interfaces," & ")),L(n," "),xe(r)]," ")}),FieldDefinition:Ce(function(i){var e=i.arguments,n=i.type,r=i.directives;return i.name+(un(e)?ue("(\n",gt(L(e,"\n")),"\n)"):ue("(",L(e,", "),")"))+": "+n+ue(" ",L(r," "))}),InputValueDefinition:Ce(function(i){var r=i.directives;return L([i.name+": "+i.type,ue("= ",i.defaultValue),L(r," ")]," ")}),InterfaceTypeDefinition:Ce(function(i){var n=i.directives,r=i.fields;return L(["interface",i.name,ue("implements ",L(i.interfaces," & ")),L(n," "),xe(r)]," ")}),UnionTypeDefinition:Ce(function(i){var n=i.types;return L(["union",i.name,L(i.directives," "),n&&0!==n.length?"= "+L(n," | "):""]," ")}),EnumTypeDefinition:Ce(function(i){var n=i.values;return L(["enum",i.name,L(i.directives," "),xe(n)]," ")}),EnumValueDefinition:Ce(function(i){return L([i.name,L(i.directives," ")]," ")}),InputObjectTypeDefinition:Ce(function(i){var n=i.fields;return L(["input",i.name,L(i.directives," "),xe(n)]," ")}),DirectiveDefinition:Ce(function(i){var e=i.arguments,n=i.repeatable,r=i.locations;return"directive @"+i.name+(un(e)?ue("(\n",gt(L(e,"\n")),"\n)"):ue("(",L(e,", "),")"))+(n?" repeatable":"")+" on "+L(r," | ")}),SchemaExtension:function(t){var n=t.operationTypes;return L(["extend schema",L(t.directives," "),xe(n)]," ")},ScalarTypeExtension:function(t){return L(["extend scalar",t.name,L(t.directives," ")]," ")},ObjectTypeExtension:function(t){var r=t.directives,o=t.fields;return L(["extend type",t.name,ue("implements ",L(t.interfaces," & ")),L(r," "),xe(o)]," ")},InterfaceTypeExtension:function(t){var r=t.directives,o=t.fields;return L(["extend interface",t.name,ue("implements ",L(t.interfaces," & ")),L(r," "),xe(o)]," ")},UnionTypeExtension:function(t){var r=t.types;return L(["extend union",t.name,L(t.directives," "),r&&0!==r.length?"= "+L(r," | "):""]," ")},EnumTypeExtension:function(t){var r=t.values;return L(["extend enum",t.name,L(t.directives," "),xe(r)]," ")},InputObjectTypeExtension:function(t){var r=t.fields;return L(["extend input",t.name,L(t.directives," "),xe(r)]," ")}};function Ce(i){return function(t){return L([t.description,i(t)],"\n")}}function L(i){var t,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return null!==(t=null==i?void 0:i.filter(function(n){return n}).join(e))&&void 0!==t?t:""}function xe(i){return ue("{\n",gt(L(i,"\n")),"\n}")}function ue(i,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return null!=t&&""!==t?i+t+e:""}function gt(i){return ue(" ",i.replace(/\n/g,"\n "))}function Ar(i){return-1!==i.indexOf("\n")}function un(i){return null!=i&&i.some(Ar)}var fn="undefined"!=typeof Symbol&&"function"==typeof Symbol.for,Cr=fn?Symbol.for("INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER"):"@@INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER",ln=fn?Symbol.for("INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER"):"@@INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER",kr=q(13880),je=q.n(kr)(),Rt=q(77),Rr=q(11178),hn=q(79031),it=function(){return(it=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},Lr=new V.k("AbstractPubSubProvider"),dn=function(){function i(t){void 0===t&&(t={}),this._config=t}return i.prototype.configure=function(t){return void 0===t&&(t={}),this._config=it(it({},t),this._config),Lr.debug("configure "+this.getProviderName(),this._config),this.options},i.prototype.getCategory=function(){return"PubSub"},Object.defineProperty(i.prototype,"options",{get:function(){return it({},this._config)},enumerable:!0,configurable:!0}),i}(),pn=q(54414),ze=function(i){return i.CONNECTION_CLOSED="Connection closed",i.CONNECTION_FAILED="Connection failed",i.REALTIME_SUBSCRIPTION_INIT_ERROR="AppSync Realtime subscription init error",i.SUBSCRIPTION_ACK="Subscription ack",i.TIMEOUT_DISCONNECT="Timeout disconnect",i}({}),Ve=function(i){return i.Connected="Connected",i.ConnectedPendingNetwork="ConnectedPendingNetwork",i.ConnectionDisrupted="ConnectionDisrupted",i.ConnectionDisruptedPendingNetwork="ConnectionDisruptedPendingNetwork",i.Connecting="Connecting",i.ConnectedPendingDisconnect="ConnectedPendingDisconnect",i.Disconnected="Disconnected",i.ConnectedPendingKeepAlive="ConnectedPendingKeepAlive",i}({}),Fr=function(){function i(){}return i.prototype.networkMonitor=function(t){if((0,Rt.lC)().isNode)return je.from([{online:!0}]);var e=(0,Rt.n2)()?self:window;return new je(function(n){n.next({online:e.navigator.onLine});var r=function(){return n.next({online:!0})},o=function(){return n.next({online:!1})};return e.addEventListener("online",r),e.addEventListener("offline",o),i._observers.push(n),function(){e.removeEventListener("online",r),e.removeEventListener("offline",o),i._observers=i._observers.filter(function(a){return a!==n})}})},i._observerOverride=function(t){var e,n,r=function(s){if(s.closed)return i._observers=i._observers.filter(function(d){return d!==s}),"continue";s.next(t)};try{for(var o=function(i){var t="function"==typeof Symbol&&Symbol.iterator,e=t&&i[t],n=0;if(e)return e.call(i);if(i&&"number"==typeof i.length)return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(i._observers),a=o.next();!a.done;a=o.next())r(a.value)}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}},i._observers=[],i}(),ot=function(){return(ot=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},pe={KEEP_ALIVE_MISSED:{keepAliveState:"unhealthy"},KEEP_ALIVE:{keepAliveState:"healthy"},CONNECTION_ESTABLISHED:{connectionState:"connected"},CONNECTION_FAILED:{intendedConnectionState:"disconnected",connectionState:"disconnected"},CLOSING_CONNECTION:{intendedConnectionState:"disconnected"},OPENING_CONNECTION:{intendedConnectionState:"connected",connectionState:"connecting"},CLOSED:{connectionState:"disconnected"},ONLINE:{networkState:"connected"},OFFLINE:{networkState:"disconnected"}},vn=function(){function i(){var t=this;this._networkMonitoringSubscription=void 0,this._linkedConnectionState={networkState:"connected",connectionState:"disconnected",intendedConnectionState:"disconnected",keepAliveState:"healthy"},this._linkedConnectionStateObservable=new je(function(e){e.next(t._linkedConnectionState),t._linkedConnectionStateObserver=e})}return i.prototype.enableNetworkMonitoring=function(){var t=this;void 0===this._networkMonitoringSubscription&&(this._networkMonitoringSubscription=(new Fr).networkMonitor().subscribe(function(e){t.record(e.online?pe.ONLINE:pe.OFFLINE)}))},i.prototype.disableNetworkMonitoring=function(){var t;null===(t=this._networkMonitoringSubscription)||void 0===t||t.unsubscribe(),this._networkMonitoringSubscription=void 0},Object.defineProperty(i.prototype,"connectionStateObservable",{get:function(){var n,e=this;return this._linkedConnectionStateObservable.map(function(r){return e.connectionStatesTranslator(r)}).filter(function(r){var o=r!==n;return n=r,o})},enumerable:!0,configurable:!0}),i.prototype.record=function(t){"connected"===t.intendedConnectionState?this.enableNetworkMonitoring():"disconnected"===t.intendedConnectionState&&this.disableNetworkMonitoring();var e=ot(ot({},this._linkedConnectionState),t);this._linkedConnectionState=ot({},e),this._linkedConnectionStateObserver.next(this._linkedConnectionState)},i.prototype.connectionStatesTranslator=function(t){var e=t.connectionState,n=t.networkState,r=t.intendedConnectionState;return"connected"===e&&"disconnected"===n?Ve.ConnectedPendingNetwork:"connected"===e&&"disconnected"===r?Ve.ConnectedPendingDisconnect:"disconnected"===e&&"connected"===r&&"disconnected"===n?Ve.ConnectionDisruptedPendingNetwork:"disconnected"===e&&"connected"===r?Ve.ConnectionDisrupted:"connected"===e&&"unhealthy"===t.keepAliveState?Ve.ConnectedPendingKeepAlive:"connecting"===e?Ve.Connecting:"disconnected"===e?Ve.Disconnected:Ve.Connected},i}(),Vr=[400,401,403],yn="ConnectionStateChange",Ue=function(i){return i.GQL_CONNECTION_INIT="connection_init",i.GQL_CONNECTION_ERROR="connection_error",i.GQL_CONNECTION_ACK="connection_ack",i.GQL_START="start",i.GQL_START_ACK="start_ack",i.GQL_DATA="data",i.GQL_CONNECTION_KEEP_ALIVE="ka",i.GQL_STOP="stop",i.GQL_COMPLETE="complete",i.GQL_ERROR="error",i}({}),He=function(i){return i[i.PENDING=0]="PENDING",i[i.CONNECTED=1]="CONNECTED",i[i.FAILED=2]="FAILED",i}({}),Re=function(i){return i[i.CLOSED=0]="CLOSED",i[i.READY=1]="READY",i[i.CONNECTING=2]="CONNECTING",i}({}),gn="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",qr={accept:"application/json, text/javascript","content-encoding":"amz-1.0","content-type":"application/json; charset=UTF-8"},zr=function(){var i=function(e,n){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a])})(e,n)};return function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),qe=function(){return(qe=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},Ye=function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})},Xe=function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}},bn=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(null!=i&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]])}return e},Ze=new V.k("MqttOverWSProvider"),Wr=function(){function i(){this.promises=new Map}return i.prototype.get=function(t,e){return Ye(this,void 0,void 0,function(){var n,r;return Xe(this,function(o){return(n=this.promises.get(t))?[2,n]:e?(r=e(t),this.promises.set(t,r),[2,r]):[2,void 0]})})},Object.defineProperty(i.prototype,"allClients",{get:function(){return Array.from(this.promises.keys())},enumerable:!0,configurable:!0}),i.prototype.remove=function(t){this.promises.delete(t)},i}(),Sn="undefined"!=typeof Symbol?Symbol("topic"):"@@topic",Hr=function(i){function t(e){void 0===e&&(e={});var n=i.call(this,qe(qe({},e),{clientId:e.clientId||(0,hn.v4)()}))||this;return n._clientsQueue=new Wr,n.connectionStateMonitor=new vn,n._topicObservers=new Map,n._clientIdObservers=new Map,n.connectionStateMonitor.connectionStateObservable.subscribe(function(r){!function(t,e,n){pn.Xb.dispatch("pubsub",{event:"ConnectionStateChange",data:e,message:n},"PubSub",gn)}(0,{provider:n,connectionState:r},"Connection state is "+r)}),n}return zr(t,i),Object.defineProperty(t.prototype,"clientId",{get:function(){return this.options.clientId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"endpoint",{get:function(){return this.options.aws_pubsub_endpoint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"clientsQueue",{get:function(){return this._clientsQueue},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSSLEnabled",{get:function(){return!this.options.aws_appsync_dangerously_connect_to_http_endpoint_for_testing},enumerable:!0,configurable:!0}),t.prototype.getTopicForValue=function(e){return"object"==typeof e&&e[Sn]},t.prototype.getProviderName=function(){return"MqttOverWSProvider"},t.prototype.onDisconnect=function(e){var n=this,r=e.clientId,o=e.errorCode,a=bn(e,["clientId","errorCode"]);if(0!==o){Ze.warn(r,JSON.stringify(qe({errorCode:o},a),null,2));var c=[];if(!r)return;var l=this._clientIdObservers.get(r);if(!l)return;l.forEach(function(s){s.error("Disconnected, error code: "+o),n._topicObservers.forEach(function(d,_){d.delete(s),0===d.size&&c.push(_)})}),this._clientIdObservers.delete(r),c.forEach(function(s){n._topicObservers.delete(s)})}},t.prototype.newClient=function(e){var n=e.url,r=e.clientId;return Ye(this,void 0,void 0,function(){var o,a=this;return Xe(this,function(c){switch(c.label){case 0:return Ze.debug("Creating new MQTT client",r),this.connectionStateMonitor.record(pe.OPENING_CONNECTION),(o=new Rr.Client(n,r)).onMessageArrived=function(l){a._onMessage(l.destinationName,l.payloadString)},o.onConnectionLost=function(l){var s=l.errorCode,d=bn(l,["errorCode"]);a.onDisconnect(qe({clientId:r,errorCode:s},d)),a.connectionStateMonitor.record(pe.CLOSED)},[4,new Promise(function(l,s){o.connect({useSSL:a.isSSLEnabled,mqttVersion:3,onSuccess:function(){return l(o)},onFailure:function(){s(),a.connectionStateMonitor.record(pe.CONNECTION_FAILED)}})})];case 1:return c.sent(),this.connectionStateMonitor.record(pe.CONNECTION_ESTABLISHED),[2,o]}})})},t.prototype.connect=function(e,n){return void 0===n&&(n={}),Ye(this,void 0,void 0,function(){var r=this;return Xe(this,function(o){switch(o.label){case 0:return[4,this.clientsQueue.get(e,function(a){return r.newClient(qe(qe({},n),{clientId:a}))})];case 1:return[2,o.sent()]}})})},t.prototype.disconnect=function(e){return Ye(this,void 0,void 0,function(){var n;return Xe(this,function(r){switch(r.label){case 0:return[4,this.clientsQueue.get(e)];case 1:return(n=r.sent())&&n.isConnected()&&(n.disconnect(),this.connectionStateMonitor.record(pe.CLOSED)),this.clientsQueue.remove(e),[2]}})})},t.prototype.publish=function(e,n){return Ye(this,void 0,void 0,function(){var r,o,a,c;return Xe(this,function(l){switch(l.label){case 0:return r=[].concat(e),o=JSON.stringify(n),[4,this.endpoint];case 1:return a=l.sent(),[4,this.connect(this.clientId,{url:a})];case 2:return c=l.sent(),Ze.debug("Publishing to topic(s)",r.join(","),o),r.forEach(function(s){return c.send(s,o)}),[2]}})})},t.prototype._onMessage=function(e,n){try{var r=[];this._topicObservers.forEach(function(a,c){(function(i,t){for(var e=i.split("/"),n=e.length,r=t.split("/"),o=0;o<n;++o){var a=e[o];if("#"===a)return r.length>=n;if("+"!==a&&a!==r[o])return!1}return n===r.length})(c,e)&&r.push(a)});var o=JSON.parse(n);"object"==typeof o&&(o[Sn]=e),r.forEach(function(a){a.forEach(function(c){return c.next(o)})})}catch(a){Ze.warn("Error handling message",a,n)}},t.prototype.subscribe=function(e,n){var r=this;void 0===n&&(n={});var o=[].concat(e);return Ze.debug("Subscribing to topic(s)",o.join(",")),new je(function(a){o.forEach(function(_){var N=r._topicObservers.get(_);N||(N=new Set,r._topicObservers.set(_,N)),N.add(a)});var c,l=n.clientId,s=void 0===l?r.clientId:l,d=r._clientIdObservers.get(s);return d||(d=new Set),d.add(a),r._clientIdObservers.set(s,d),Ye(r,void 0,void 0,function(){var _,N,O,C;return Xe(this,function(P){switch(P.label){case 0:return void 0!==(_=n.url)?[3,2]:[4,this.endpoint];case 1:return O=P.sent(),[3,3];case 2:O=_,P.label=3;case 3:N=O,P.label=4;case 4:return P.trys.push([4,6,,7]),[4,this.connect(s,{url:N})];case 5:return c=P.sent(),o.forEach(function(F){c.subscribe(F)}),[3,7];case 6:return C=P.sent(),a.error(C),[3,7];case 7:return[2]}})}),function(){var _,N;return Ze.debug("Unsubscribing from topic(s)",o.join(",")),c&&(null===(_=r._clientIdObservers.get(s))||void 0===_||_.delete(a),0===(null===(N=r._clientIdObservers.get(s))||void 0===N?void 0:N.size)&&(r.connectionStateMonitor.record(pe.CLOSING_CONNECTION),r.disconnect(s),r._clientIdObservers.delete(s)),o.forEach(function(O){var C=r._topicObservers.get(O)||new Set;C.delete(a),0===C.size&&(r._topicObservers.delete(O),c.isConnected()&&c.unsubscribe(O))})),null}})},t}(dn),Yr=function(){var i=function(e,n){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a])})(e,n)};return function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),_t=function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})},mt=function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}},Ke=function(i,t){var e="function"==typeof Symbol&&i[Symbol.iterator];if(!e)return i;var r,a,n=e.call(i),o=[];try{for(;(void 0===t||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(c){a={error:c}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return o},En=new V.k("AWSAppSyncProvider"),$r=function(i){function t(){var e=null!==i&&i.apply(this,arguments)||this;return e._topicClient=new Map,e._topicAlias=new Map,e}return Yr(t,i),Object.defineProperty(t.prototype,"endpoint",{get:function(){throw new Error("Not supported")},enumerable:!0,configurable:!0}),t.prototype.getProviderName=function(){return"AWSAppSyncProvider"},t.prototype.publish=function(e,n,r){return _t(this,void 0,void 0,function(){return mt(this,function(o){throw new Error("Operation not supported")})})},t.prototype._cleanUp=function(e){var n=this;Array.from(this._topicClient.entries()).filter(function(o){return Ke(o,2)[1].clientId===e}).map(function(o){return Ke(o,1)[0]}).forEach(function(o){return n._cleanUpForTopic(o)})},t.prototype._cleanUpForTopic=function(e){this._topicClient.delete(e),this._topicAlias.delete(e)},t.prototype.onDisconnect=function(e){var n=this,r=e.clientId,o=e.errorCode,a=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(null!=i&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]])}return e}(e,["clientId","errorCode"]);0!==o&&(Array.from(this._topicClient.entries()).filter(function(l){return Ke(l,2)[1].clientId===r}).map(function(l){return Ke(l,1)[0]}).forEach(function(l){n._topicObservers.has(l)&&(n._topicObservers.get(l).forEach(function(s){s.closed||s.error(a)}),n._topicObservers.delete(l))}),this._cleanUp(r))},t.prototype.disconnect=function(e){return _t(this,void 0,void 0,function(){return mt(this,function(r){switch(r.label){case 0:return[4,this.clientsQueue.get(e,function(){return null})];case 1:return r.sent(),[4,i.prototype.disconnect.call(this,e)];case 2:return r.sent(),this._cleanUp(e),[2]}})})},t.prototype.subscribe=function(e,n){var r=this;void 0===n&&(n={});var o=new je(function(a){var c=[].concat(e);return En.debug("Subscribing to topic(s)",c.join(",")),_t(r,void 0,void 0,function(){var l,s,_,N,O=this;return mt(this,function(C){switch(C.label){case 0:return c.forEach(function(P){O._topicObservers.has(P)||O._topicObservers.set(P,new Set),O._topicObservers.get(P).add(a)}),s=void 0===(l=n.mqttConnections)?[]:l,_=Object.entries(n.newSubscriptions).map(function(P){var F=Ke(P,2);return[F[1].topic,F[0]]}),this._topicAlias=new Map(function(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(Ke(arguments[t]));return i}(Array.from(this._topicAlias.entries()),_)),N=Object.entries(c.reduce(function(P,F){var j=s.find(function(re){return re.topics.indexOf(F)>-1});if(j){var H=j.client;P[H]||(P[H]={url:j.url,topics:new Set}),P[H].topics.add(F)}return P},{})),[4,Promise.all(N.map(function(P){var F=Ke(P,2),j=F[0],H=F[1],te=H.url,re=H.topics;return _t(O,void 0,void 0,function(){var J,oe,le=this;return mt(this,function(ae){switch(ae.label){case 0:J=null,ae.label=1;case 1:return ae.trys.push([1,3,,4]),[4,this.connect(j,{clientId:j,url:te})];case 2:return J=ae.sent(),[3,4];case 3:return oe=ae.sent(),a.error({message:"Failed to connect",error:oe}),a.complete(),[2,void 0];case 4:return re.forEach(function(ve){J.isConnected()&&(J.subscribe(ve),le._topicClient.set(ve,J))}),[2,J]}})})}))];case 1:return C.sent(),[2]}})}),function(){En.debug("Unsubscribing from topic(s)",c.join(",")),c.forEach(function(l){var s=r._topicClient.get(l);s&&s.isConnected()&&(s.unsubscribe(l),r._topicClient.delete(l),Array.from(r._topicClient.values()).some(function(d){return d===s})||r.disconnect(s.clientId)),r._topicObservers.delete(l)})}});return je.from(o).map(function(a){var c=r.getTopicForValue(a),l=r._topicAlias.get(c);return a.data=Object.entries(a.data).reduce(function(s,d){var _=Ke(d,2);return s[l||_[0]]=_[1],s},{}),a})},t}(Hr),Tn=q(23833),ei=(q(53799),{userAgent:_e.t4.userAgent}),In=q(91668),bt=q(43061),ti=function(){var i=function(e,n){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a])})(e,n)};return function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),Se=function(){return(Se=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},Oe=function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})},Ae=function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}},fe=new V.k("AWSAppSyncRealTimeProvider"),wn=function(t,e,n){pn.Xb.dispatch("api",{event:t,data:e,message:n},"PubSub",gn)},ri=/^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com\/graphql$/i,oi=function(i){function t(e){void 0===e&&(e={});var n=i.call(this,e)||this;return n.socketStatus=Re.CLOSED,n.keepAliveTimeout=3e5,n.subscriptionObserverMap=new Map,n.promiseArray=[],n.connectionStateMonitor=new vn,n.connectionStateMonitor.connectionStateObservable.subscribe(function(r){wn(yn,{provider:n,connectionState:r},"Connection state is "+r)}),n}return ti(t,i),t.prototype.getNewWebSocket=function(e,n){return new WebSocket(e,n)},t.prototype.getProviderName=function(){return"AWSAppSyncRealTimeProvider"},t.prototype.newClient=function(){throw new Error("Not used here")},t.prototype.publish=function(e,n,r){return Oe(this,void 0,void 0,function(){return Ae(this,function(o){throw new Error("Operation not supported")})})},t.prototype.isCustomDomain=function(e){return null===e.match(ri)},t.prototype.subscribe=function(e,n){var r=this,o=null==n?void 0:n.appSyncGraphqlEndpoint;return new je(function(a){if(n&&o){var c=(0,hn.v4)();return r._startSubscriptionWithAWSAppSyncRealTime({options:n,observer:a,subscriptionId:c}).catch(function(l){a.error({errors:[Se({},new Me(ze.REALTIME_SUBSCRIPTION_INIT_ERROR+": "+l))]}),r.connectionStateMonitor.record(pe.CLOSED),a.complete()}),function(){return Oe(r,void 0,void 0,function(){var l,s;return Ae(this,function(d){switch(d.label){case 0:return d.trys.push([0,2,3,4]),[4,this._waitForSubscriptionToBeConnected(c)];case 1:if(d.sent(),!(l=(this.subscriptionObserverMap.get(c)||{}).subscriptionState))return[2];if(l!==He.CONNECTED)throw new Error("Subscription never connected");return this._sendUnsubscriptionMessage(c),[3,4];case 2:return s=d.sent(),fe.debug("Error while unsubscribing "+s),[3,4];case 3:return this._removeSubscriptionObserver(c),[7];case 4:return[2]}})})}}a.error({errors:[Se({},new Me("Subscribe only available for AWS AppSync endpoint"))]}),a.complete()})},Object.defineProperty(t.prototype,"isSSLEnabled",{get:function(){return!this.options.aws_appsync_dangerously_connect_to_http_endpoint_for_testing},enumerable:!0,configurable:!0}),t.prototype._startSubscriptionWithAWSAppSyncRealTime=function(e){var a,c,n=e.options,r=e.observer,o=e.subscriptionId;return Oe(this,void 0,void 0,function(){var l,s,d,_,N,O,C,P,F,j,H,te,re,J,oe,le,ae,ve,ye,ke,Be,Pe,Ft,Pn=this;return Ae(this,function(We){switch(We.label){case 0:return l=n.appSyncGraphqlEndpoint,s=n.authenticationType,N=n.apiKey,O=n.region,P=void 0===(C=n.graphql_headers)?function(){return{}}:C,j=void 0===(F=n.additionalHeaders)?{}:F,te={query:d=n.query,variables:_=n.variables},this.subscriptionObserverMap.set(o,{observer:r,query:null!=d?d:"",variables:null!=_?_:{},subscriptionState:H=He.PENDING,startAckTimeoutId:void 0}),re=JSON.stringify(te),oe=[{}],[4,this._awsRealTimeHeaderBasedAuth({apiKey:N,appSyncGraphqlEndpoint:l,authenticationType:s,payload:re,canonicalUri:"",region:O,additionalHeaders:j})];case 1:return le=[Se.apply(void 0,oe.concat([We.sent()]))],[4,P()];case 2:J=Se.apply(void 0,[Se.apply(void 0,[Se.apply(void 0,le.concat([We.sent()])),j]),(Ft={},Ft["x-amz-user-agent"]=ei.userAgent,Ft)]),ae={id:o,payload:{data:re,extensions:{authorization:Se({},J)}},type:Ue.GQL_START},ve=JSON.stringify(ae),We.label=3;case 3:return We.trys.push([3,5,,6]),this.connectionStateMonitor.record(pe.OPENING_CONNECTION),[4,this._initializeWebSocketConnection({apiKey:N,appSyncGraphqlEndpoint:l,authenticationType:s,region:O,additionalHeaders:j})];case 4:return We.sent(),[3,6];case 5:return ye=We.sent(),fe.debug({err:ye}),ke=null!==(a=ye.message)&&void 0!==a?a:"",this.connectionStateMonitor.record(pe.CLOSED),r.error({errors:[Se({},new Me(ze.CONNECTION_FAILED+": "+ke))]}),r.complete(),"function"==typeof(Be=(this.subscriptionObserverMap.get(o)||{}).subscriptionFailedCallback)&&Be(),[2];case 6:return Pe=null!==(c=this.subscriptionObserverMap.get(o))&&void 0!==c?c:{},this.subscriptionObserverMap.set(o,{observer:r,subscriptionState:H,query:null!=d?d:"",variables:null!=_?_:{},subscriptionReadyCallback:Pe.subscriptionReadyCallback,subscriptionFailedCallback:Pe.subscriptionFailedCallback,startAckTimeoutId:setTimeout(function(){Pn._timeoutStartSubscriptionAck.call(Pn,o)},15e3)}),this.awsRealTimeSocket&&this.awsRealTimeSocket.send(ve),[2]}})})},t.prototype._waitForSubscriptionToBeConnected=function(e){return Oe(this,void 0,void 0,function(){var n,o=this;return Ae(this,function(a){return(n=this.subscriptionObserverMap.get(e))&&n.subscriptionState===He.PENDING?[2,new Promise(function(c,l){o.subscriptionObserverMap.set(e,{observer:n.observer,subscriptionState:n.subscriptionState,variables:n.variables,query:n.query,subscriptionReadyCallback:c,subscriptionFailedCallback:l})})]:[2]})})},t.prototype._sendUnsubscriptionMessage=function(e){try{if(this.awsRealTimeSocket&&this.awsRealTimeSocket.readyState===WebSocket.OPEN&&this.socketStatus===Re.READY){var r=JSON.stringify({id:e,type:Ue.GQL_STOP});this.awsRealTimeSocket.send(r)}}catch(o){fe.debug({err:o})}},t.prototype._removeSubscriptionObserver=function(e){this.subscriptionObserverMap.delete(e),setTimeout(this._closeSocketIfRequired.bind(this),1e3)},t.prototype._closeSocketIfRequired=function(){if(!(this.subscriptionObserverMap.size>0)){if(!this.awsRealTimeSocket)return void(this.socketStatus=Re.CLOSED);if(this.connectionStateMonitor.record(pe.CLOSING_CONNECTION),this.awsRealTimeSocket.bufferedAmount>0)setTimeout(this._closeSocketIfRequired.bind(this),1e3);else{fe.debug("closing WebSocket..."),this.keepAliveTimeoutId&&clearTimeout(this.keepAliveTimeoutId),this.keepAliveAlertTimeoutId&&clearTimeout(this.keepAliveAlertTimeoutId);var e=this.awsRealTimeSocket;e.onclose=null,e.onerror=null,e.close(1e3),this.awsRealTimeSocket=void 0,this.socketStatus=Re.CLOSED,this.connectionStateMonitor.record(pe.CLOSED)}}},t.prototype._handleIncomingSubscriptionMessage=function(e){var n=this;fe.debug("subscription message from AWS AppSync RealTime: "+e.data);var r=JSON.parse(e.data),o=r.id,a=void 0===o?"":o,c=r.payload,l=r.type,s=this.subscriptionObserverMap.get(a)||{},d=s.observer,_=void 0===d?null:d,N=s.query,O=void 0===N?"":N,C=s.variables,P=void 0===C?{}:C,F=s.startAckTimeoutId,j=s.subscriptionReadyCallback,H=s.subscriptionFailedCallback;if(fe.debug({id:a,observer:_,query:O,variables:P}),l===Ue.GQL_DATA&&c&&c.data)_?_.next(c):fe.debug("observer not found for id: "+a);else{if(l===Ue.GQL_START_ACK){fe.debug("subscription ready for "+JSON.stringify({query:O,variables:P})),"function"==typeof j&&j(),F&&clearTimeout(F),wn(ze.SUBSCRIPTION_ACK,{query:O,variables:P},"Connection established for subscription");var te=He.CONNECTED;return _&&this.subscriptionObserverMap.set(a,{observer:_,query:O,variables:P,startAckTimeoutId:void 0,subscriptionState:te,subscriptionReadyCallback:j,subscriptionFailedCallback:H}),void this.connectionStateMonitor.record(pe.CONNECTION_ESTABLISHED)}if(l===Ue.GQL_CONNECTION_KEEP_ALIVE)return this.keepAliveTimeoutId&&clearTimeout(this.keepAliveTimeoutId),this.keepAliveAlertTimeoutId&&clearTimeout(this.keepAliveAlertTimeoutId),this.keepAliveTimeoutId=setTimeout(function(){return n._errorDisconnect(ze.TIMEOUT_DISCONNECT)},this.keepAliveTimeout),this.keepAliveAlertTimeoutId=setTimeout(function(){n.connectionStateMonitor.record(pe.KEEP_ALIVE_MISSED)},65e3),void this.connectionStateMonitor.record(pe.KEEP_ALIVE);l===Ue.GQL_ERROR&&(te=He.FAILED,_&&(this.subscriptionObserverMap.set(a,{observer:_,query:O,variables:P,startAckTimeoutId:F,subscriptionReadyCallback:j,subscriptionFailedCallback:H,subscriptionState:te}),_.error({errors:[Se({},new Me(ze.CONNECTION_FAILED+": "+JSON.stringify(c)))]}),F&&clearTimeout(F),_.complete(),"function"==typeof H&&H()))}},t.prototype._errorDisconnect=function(e){fe.debug("Disconnect error: "+e),this.subscriptionObserverMap.forEach(function(n){var r=n.observer;r&&!r.closed&&r.error({errors:[Se({},new Me(e))]})}),this.subscriptionObserverMap.clear(),this.awsRealTimeSocket&&(this.connectionStateMonitor.record(pe.CLOSED),this.awsRealTimeSocket.close()),this.socketStatus=Re.CLOSED},t.prototype._timeoutStartSubscriptionAck=function(e){var n=this.subscriptionObserverMap.get(e);if(n){var r=n.observer,o=n.query,a=n.variables;if(!r)return;this.subscriptionObserverMap.set(e,{observer:r,query:o,variables:a,subscriptionState:He.FAILED}),r&&!r.closed&&(r.error({errors:[Se({},new Me("Subscription timeout "+JSON.stringify({query:o,variables:a})))]}),r.complete()),fe.debug("timeoutStartSubscription",JSON.stringify({query:o,variables:a}))}},t.prototype._initializeWebSocketConnection=function(e){var n=this,r=e.appSyncGraphqlEndpoint,o=e.authenticationType,a=e.apiKey,c=e.region,l=e.additionalHeaders;if(this.socketStatus!==Re.READY)return new Promise(function(s,d){return Oe(n,void 0,void 0,function(){var _,N,O,C,P,F,j,H,re;return Ae(this,function(J){switch(J.label){case 0:if(this.promiseArray.push({res:s,rej:d}),this.socketStatus!==Re.CLOSED)return[3,5];J.label=1;case 1:return J.trys.push([1,4,,5]),this.socketStatus=Re.CONNECTING,_="{}",C=(O=JSON).stringify,[4,this._awsRealTimeHeaderBasedAuth({authenticationType:o,payload:_,canonicalUri:"/connect",apiKey:a,appSyncGraphqlEndpoint:r,region:c,additionalHeaders:l})];case 2:return N=C.apply(O,[J.sent()]),P=Tn.lW.from(N).toString("base64"),F=Tn.lW.from(_).toString("base64"),j=(j=this.isCustomDomain(j=null!=r?r:"")?j.concat("/realtime"):j.replace("appsync-api","appsync-realtime-api").replace("gogi-beta","grt-beta")).replace("https://",H=this.isSSLEnabled?"wss://":"ws://").replace("http://",H),[4,this._initializeRetryableHandshake(j+"?header="+P+"&payload="+F)];case 3:return J.sent(),this.promiseArray.forEach(function(oe){var le=oe.res;fe.debug("Notifying connection successful"),le()}),this.socketStatus=Re.READY,this.promiseArray=[],[3,5];case 4:return re=J.sent(),this.promiseArray.forEach(function(oe){return(0,oe.rej)(re)}),this.promiseArray=[],this.awsRealTimeSocket&&this.awsRealTimeSocket.readyState===WebSocket.OPEN&&this.awsRealTimeSocket.close(3001),this.awsRealTimeSocket=void 0,this.socketStatus=Re.CLOSED,[3,5];case 5:return[2]}})})})},t.prototype._initializeRetryableHandshake=function(e){return Oe(this,void 0,void 0,function(){return Ae(this,function(n){switch(n.label){case 0:return fe.debug("Initializaling retryable Handshake"),[4,(0,In.Xm)(this._initializeHandshake.bind(this),[e],5e3)];case 1:return n.sent(),[2]}})})},t.prototype._initializeHandshake=function(e){return Oe(this,void 0,void 0,function(){var n,r,o,c=this;return Ae(this,function(l){switch(l.label){case 0:fe.debug("Initializing handshake "+e),l.label=1;case 1:return l.trys.push([1,4,,5]),[4,new Promise(function(s,d){var _=c.getNewWebSocket(e,"graphql-ws");_.onerror=function(){fe.debug("WebSocket connection error")},_.onclose=function(){c.connectionStateMonitor.record(pe.CONNECTION_FAILED),d(new Error("Connection handshake error"))},_.onopen=function(){return c.awsRealTimeSocket=_,s()}})];case 2:return l.sent(),[4,new Promise(function(s,d){if(c.awsRealTimeSocket){var _=!1;c.awsRealTimeSocket.onerror=function(C){fe.debug("WebSocket error "+JSON.stringify(C))},c.awsRealTimeSocket.onclose=function(C){fe.debug("WebSocket closed "+C.reason),d(new Error(JSON.stringify(C)))},c.awsRealTimeSocket.onmessage=function(C){fe.debug("subscription message from AWS AppSyncRealTime: "+C.data+" ");var P=JSON.parse(C.data),F=P.type,j=P.payload,H=(void 0===j?{}:j).connectionTimeoutMs;if(F===Ue.GQL_CONNECTION_ACK)return _=!0,c.awsRealTimeSocket&&(c.keepAliveTimeout=void 0===H?3e5:H,c.awsRealTimeSocket.onmessage=c._handleIncomingSubscriptionMessage.bind(c),c.awsRealTimeSocket.onerror=function(Pe){fe.debug(Pe),c._errorDisconnect(ze.CONNECTION_CLOSED)},c.awsRealTimeSocket.onclose=function(Pe){fe.debug("WebSocket closed "+Pe.reason),c._errorDisconnect(ze.CONNECTION_CLOSED)}),void s("Cool, connected to AWS AppSyncRealTime");if(F===Ue.GQL_CONNECTION_ERROR){var re=P.payload,J=(void 0===re?{}:re).errors,le=function(i,t){var e="function"==typeof Symbol&&i[Symbol.iterator];if(!e)return i;var r,a,n=e.call(i),o=[];try{for(;(void 0===t||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(c){a={error:c}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return o}(void 0===J?[]:J,1)[0],ae=void 0===le?{}:le,ve=ae.errorType,ke=ae.errorCode;d({errorType:void 0===ve?"":ve,errorCode:void 0===ke?0:ke})}},c.awsRealTimeSocket.send(JSON.stringify({type:Ue.GQL_CONNECTION_INIT})),setTimeout(function(){_||(c.connectionStateMonitor.record(pe.CONNECTION_FAILED),d(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after 15000 ms")))},15e3)}})];case 3:return l.sent(),[3,5];case 4:throw n=l.sent(),o=(r=n).errorType,Vr.includes(r.errorCode)?new In.V2(o):o?new Error(o):n;case 5:return[2]}})})},t.prototype._awsRealTimeHeaderBasedAuth=function(e){var n=e.authenticationType,r=e.payload,o=e.canonicalUri,a=e.appSyncGraphqlEndpoint,c=e.apiKey,l=e.region,s=e.additionalHeaders;return Oe(this,void 0,void 0,function(){var d,_,N;return Ae(this,function(C){switch(C.label){case 0:return d={API_KEY:this._awsRealTimeApiKeyHeader.bind(this),AWS_IAM:this._awsRealTimeIAMHeader.bind(this),OPENID_CONNECT:this._awsRealTimeOPENIDHeader.bind(this),AMAZON_COGNITO_USER_POOLS:this._awsRealTimeCUPHeader.bind(this),AWS_LAMBDA:this._customAuthHeader},n&&d[n]?[3,1]:(fe.debug("Authentication type "+n+" not supported"),[2,""]);case 1:return _=d[n],N=h.Qc(null!=a?a:"").host,fe.debug("Authenticating with "+n),[4,_({payload:r,canonicalUri:o,appSyncGraphqlEndpoint:a,apiKey:c,region:l,host:N,additionalHeaders:s})];case 2:return[2,C.sent()]}})})},t.prototype._awsRealTimeCUPHeader=function(e){var n=e.host;return Oe(this,void 0,void 0,function(){return Ae(this,function(o){switch(o.label){case 0:return[4,bt.ZP.currentSession()];case 1:return[2,{Authorization:o.sent().getAccessToken().getJwtToken(),host:n}]}})})},t.prototype._awsRealTimeOPENIDHeader=function(e){var n=e.host;return Oe(this,void 0,void 0,function(){var r,o,a;return Ae(this,function(c){switch(c.label){case 0:return[4,Te.getItem("federatedInfo")];case 1:return(o=c.sent())?(r=o.token,[3,4]):[3,2];case 2:return[4,bt.ZP.currentAuthenticatedUser()];case 3:(a=c.sent())&&(r=a.token),c.label=4;case 4:if(!r)throw new Error("No federated jwt");return[2,{Authorization:r,host:n}]}})})},t.prototype._awsRealTimeApiKeyHeader=function(e){var n=e.apiKey,r=e.host;return Oe(this,void 0,void 0,function(){var o,a;return Ae(this,function(c){return o=new Date,a=o.toISOString().replace(/[:\-]|\.\d{3}/g,""),[2,{host:r,"x-amz-date":a,"x-api-key":n}]})})},t.prototype._awsRealTimeIAMHeader=function(e){var n=e.payload,r=e.canonicalUri,o=e.appSyncGraphqlEndpoint,a=e.region;return Oe(this,void 0,void 0,function(){var c,s,d;return Ae(this,function(N){switch(N.label){case 0:return c={region:a,service:"appsync"},[4,this._ensureCredentials()];case 1:if(!N.sent())throw new Error("No credentials");return[4,be.cN.get().then(function(O){return{secret_key:O.secretAccessKey,access_key:O.accessKeyId,session_token:O.sessionToken}})];case 2:return s=N.sent(),d={url:""+o+r,data:n,method:"POST",headers:Se({},qr)},[2,Vt.sign(d,s,c).headers]}})})},t.prototype._customAuthHeader=function(e){var n=e.host,r=e.additionalHeaders;if(!r||!r.Authorization)throw new Error("No auth token specified");return{Authorization:r.Authorization,host:n}},t.prototype._ensureCredentials=function(){return be.cN.get().then(function(e){if(!e)return!1;var n=be.cN.shear(e);return fe.debug("set credentials for AWSAppSyncRealTimeProvider",n),!0}).catch(function(e){return fe.warn("ensure credentials error",e),!1})},t}(dn),Nn=function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})},On=function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}},ai=(0,Rt.lC)().isNode,Lt=new V.k("PubSub"),St=new(function(){function i(t){this._options=null!=t?t:{},Lt.debug("PubSub Options",this._options),this._pluggables=[],this.subscribe=this.subscribe.bind(this)}return Object.defineProperty(i.prototype,"awsAppSyncProvider",{get:function(){return this._awsAppSyncProvider||(this._awsAppSyncProvider=new $r(this._options)),this._awsAppSyncProvider},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"awsAppSyncRealTimeProvider",{get:function(){return this._awsAppSyncRealTimeProvider||(this._awsAppSyncRealTimeProvider=new oi(this._options)),this._awsAppSyncRealTimeProvider},enumerable:!0,configurable:!0}),i.prototype.getModuleName=function(){return"PubSub"},i.prototype.configure=function(t){var e=this,n=t?t.PubSub||t:{};return Lt.debug("configure PubSub",{opt:n}),this._options=Object.assign({},this._options,n),this._pluggables.map(function(r){return r.configure(e._options)}),this._options},i.prototype.addPluggable=function(t){return Nn(this,void 0,void 0,function(){return On(this,function(n){return t&&"PubSub"===t.getCategory()?(this._pluggables.push(t),[2,t.configure(this._options)]):[2]})})},i.prototype.removePluggable=function(t){this._pluggables=this._pluggables.filter(function(e){return e.getProviderName()!==t})},i.prototype.getProviderByName=function(t){return t===Cr?this.awsAppSyncProvider:t===ln?this.awsAppSyncRealTimeProvider:this._pluggables.find(function(e){return e.getProviderName()===t})},i.prototype.getProviders=function(t){void 0===t&&(t={});var e=t.provider;if(!e)return this._pluggables;var n=this.getProviderByName(e);if(!n)throw new Error("Could not find provider named "+e);return[n]},i.prototype.publish=function(t,e,n){return Nn(this,void 0,void 0,function(){return On(this,function(r){return[2,Promise.all(this.getProviders(n).map(function(o){return o.publish(t,e,n)}))]})})},i.prototype.subscribe=function(t,e){if(ai&&this._options&&this._options.ssr)throw new Error("Subscriptions are not supported for Server-Side Rendering (SSR)");Lt.debug("subscribe options",e);var n=this.getProviders(e);return new je(function(r){var a=n.map(function(c){return{provider:c,observable:c.subscribe(t,e)}}).map(function(c){var l=c.provider;return c.observable.subscribe({start:console.error,next:function(_){return r.next({provider:l,value:_})},error:function(_){return r.error({provider:l,error:_})}})});return function(){return a.forEach(function(c){return c.unsubscribe()})}})},i}());ce.dQ.register(St);var $e=function(i){return i.NO_API_KEY="No api-key configured",i.NO_CURRENT_USER="No current user",i.NO_CREDENTIALS="No credentials",i.NO_FEDERATED_JWT="No federated jwt",i.NO_AUTH_TOKEN="No auth token specified",i}({}),Fe=function(){return(Fe=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},Mt=function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})},Ut=function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}},An=function(i,t){var e="function"==typeof Symbol&&i[Symbol.iterator];if(!e)return i;var r,a,n=e.call(i),o=[];try{for(;(void 0===t||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(c){a={error:c}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return o},Qe=new V.k("GraphQLAPI"),Cn=function(){function i(t){this._api=null,this.Auth=bt.ZP,this.Cache=Te,this.Credentials=be.cN,this._options=t,Qe.debug("API Options",this._options)}return i.prototype.getModuleName=function(){return"GraphQLAPI"},i.prototype.configure=function(t){var e=t||{},n=e.API,r=void 0===n?{}:n,o=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(null!=i&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]])}return e}(e,["API"]),a=Fe(Fe({},o),r);return Qe.debug("configure GraphQL API",{opt:a}),a.aws_project_region&&(a=Object.assign({},a,{region:a.aws_project_region,header:{}})),void 0!==a.graphql_headers&&"function"!=typeof a.graphql_headers&&(Qe.warn("graphql_headers should be a function"),a.graphql_headers=void 0),this._options=Object.assign({},this._options,a),this.createInstance(),this._options},i.prototype.createInstance=function(){return Qe.debug("create Rest instance"),this._options?(this._api=new Kt(this._options),this._api.Credentials=this.Credentials,!0):Promise.reject("API not configured")},i.prototype._headerBasedAuth=function(t,e){return void 0===e&&(e={}),Mt(this,void 0,void 0,function(){var n,r,o,c,d,_,N,C;return Ut(this,function(F){switch(F.label){case 0:switch(r=(n=this._options).aws_appsync_authenticationType,o=n.aws_appsync_apiKey,c={},t||r||"AWS_IAM"){case"API_KEY":return[3,1];case"AWS_IAM":return[3,2];case"OPENID_CONNECT":return[3,4];case"AMAZON_COGNITO_USER_POOLS":return[3,11];case"AWS_LAMBDA":return[3,15]}return[3,16];case 1:if(!o)throw new Error($e.NO_API_KEY);return c={Authorization:null,"X-Api-Key":o},[3,17];case 2:return[4,this._ensureCredentials()];case 3:if(!F.sent())throw new Error($e.NO_CREDENTIALS);return[3,17];case 4:return F.trys.push([4,9,,10]),d=void 0,[4,Te.getItem("federatedInfo")];case 5:return(_=F.sent())?(d=_.token,[3,8]):[3,6];case 6:return[4,bt.ZP.currentAuthenticatedUser()];case 7:(N=F.sent())&&(d=N.token),F.label=8;case 8:if(!d)throw new Error($e.NO_FEDERATED_JWT);return c={Authorization:d},[3,10];case 9:throw F.sent(),new Error($e.NO_CURRENT_USER);case 10:return[3,17];case 11:return F.trys.push([11,13,,14]),[4,this.Auth.currentSession()];case 12:return C=F.sent(),c={Authorization:C.getAccessToken().getJwtToken()},[3,14];case 13:throw F.sent(),new Error($e.NO_CURRENT_USER);case 14:return[3,17];case 15:if(!e.Authorization)throw new Error($e.NO_AUTH_TOKEN);return c={Authorization:e.Authorization},[3,17];case 16:return c={Authorization:null},[3,17];case 17:return[2,c]}})})},i.prototype.getGraphqlOperationType=function(t){var e=Ct(t);return An(e.definitions,1)[0].operation},i.prototype.graphql=function(t,e){var n=t.query,r=t.variables,o=void 0===r?{}:r,a=t.authMode,c=t.authToken,l=t.userAgentSuffix,s=Ct("string"==typeof n?n:Dt(n)),_=An(s.definitions.filter(function(H){return"OperationDefinition"===H.kind}),1)[0],O=(void 0===_?{}:_).operation,C=e||{};switch(c&&(C.Authorization=c),O){case"query":case"mutation":this.createInstanceIfNotCreated();var P=this._api.getCancellableToken(),j=this._graphql({query:s,variables:o,authMode:a,userAgentSuffix:l},C,{cancellableToken:P});return this._api.updateRequestToBeCancellable(j,P),j;case"subscription":return this._graphqlSubscribe({query:s,variables:o,authMode:a},C);default:throw new Error("invalid operation type: "+O)}},i.prototype._graphql=function(t,e,n){var r=t.query,o=t.variables,a=t.authMode,c=t.userAgentSuffix;return void 0===e&&(e={}),void 0===n&&(n={}),Mt(this,void 0,void 0,function(){var l,s,d,_,N,O,C,P,F,j,H,te,re,J,oe,le,ae,ye,ke,Be,Pe;return Ut(this,function(Ee){switch(Ee.label){case 0:return this.createInstanceIfNotCreated(),s=(l=this._options).aws_appsync_region,d=l.aws_appsync_graphqlEndpoint,N=void 0===(_=l.graphql_headers)?function(){return{}}:_,C=l.graphql_endpoint_iam_region,F=[{}],(j=!(O=l.graphql_endpoint))?[4,this._headerBasedAuth(a,e)]:[3,2];case 1:j=Ee.sent(),Ee.label=2;case 2:return H=[Fe.apply(void 0,F.concat([j]))],(te=O)?C?[4,this._headerBasedAuth(a,e)]:[3,4]:[3,6];case 3:return re=Ee.sent(),[3,5];case 4:re={Authorization:null},Ee.label=5;case 5:te=re,Ee.label=6;case 6:return J=[Fe.apply(void 0,H.concat([te]))],[4,N({query:r,variables:o})];case 7:if(P=Fe.apply(void 0,[Fe.apply(void 0,[Fe.apply(void 0,J.concat([Ee.sent()])),e]),!O&&(Pe={},Pe["x-amz-user-agent"]=(0,_e.Zm)(c),Pe)]),oe={query:Dt(r),variables:o},le=Object.assign({headers:P,body:oe,signerServiceInfo:{service:O?"execute-api":"appsync",region:O?C:s}},n),!(ae=O||d))throw{data:{},errors:[new Me("No graphql endpoint provided.")]};Ee.label=8;case 8:return Ee.trys.push([8,10,,11]),[4,this._api.post(ae,le)];case 9:return ye=Ee.sent(),[3,11];case 10:if(ke=Ee.sent(),this._api.isCancel(ke))throw ke;return ye={data:{},errors:[new Me(ke.message,null,null,null,null,ke)]},[3,11];case 11:if((Be=ye.errors)&&Be.length)throw ye;return[2,ye]}})})},i.prototype.createInstanceIfNotCreated=function(){return Mt(this,void 0,void 0,function(){return Ut(this,function(t){switch(t.label){case 0:return this._api?[3,2]:[4,this.createInstance()];case 1:t.sent(),t.label=2;case 2:return[2]}})})},i.prototype.isCancel=function(t){return this._api.isCancel(t)},i.prototype.cancel=function(t,e){return this._api.cancel(t,e)},i.prototype.hasCancelToken=function(t){return this._api.hasCancelToken(t)},i.prototype._graphqlSubscribe=function(t,e){var r=t.variables,a=t.authToken;void 0===e&&(e={});var c=this._options,l=c.aws_appsync_region,N=c.graphql_headers,O=void 0===N?function(){return{}}:N;if(St&&"function"==typeof St.subscribe)return St.subscribe("",{provider:ln,appSyncGraphqlEndpoint:c.aws_appsync_graphqlEndpoint,authenticationType:t.authMode||c.aws_appsync_authenticationType||"AWS_IAM",apiKey:c.aws_appsync_apiKey,query:Dt(t.query),region:l,variables:r,graphql_headers:O,additionalHeaders:e,authToken:a});throw Qe.debug("No pubsub module applied for subscription"),new Error("No pubsub module applied for subscription")},i.prototype._ensureCredentials=function(){var t=this;return this.Credentials.get().then(function(e){if(!e)return!1;var n=t.Credentials.shear(e);return Qe.debug("set credentials for api",n),!0}).catch(function(e){return Qe.warn("ensure credentials error",e),!1})},i}(),fi=new Cn(null);ce.dQ.register(fi);var Et=function(){return(Et=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r]);return i}).apply(this,arguments)},di=new V.k("API"),xn=new(function(){function i(t){this.Auth=Y.g,this.Cache=Te,this.Credentials=be.cN,this._options=t,this._restApi=new Gt(t),this._graphqlApi=new Cn(t),di.debug("API Options",this._options)}return i.prototype.getModuleName=function(){return"API"},i.prototype.configure=function(t){this._options=Object.assign({},this._options,t),this._restApi.Credentials=this.Credentials,this._graphqlApi.Auth=this.Auth,this._graphqlApi.Cache=this.Cache,this._graphqlApi.Credentials=this.Credentials;var e=this._restApi.configure(this._options),n=this._graphqlApi.configure(this._options);return Et(Et({},e),n)},i.prototype.get=function(t,e,n){return this._restApi.get(t,e,n)},i.prototype.post=function(t,e,n){return this._restApi.post(t,e,n)},i.prototype.put=function(t,e,n){return this._restApi.put(t,e,n)},i.prototype.patch=function(t,e,n){return this._restApi.patch(t,e,n)},i.prototype.del=function(t,e,n){return this._restApi.del(t,e,n)},i.prototype.head=function(t,e,n){return this._restApi.head(t,e,n)},i.prototype.isCancel=function(t){return this._restApi.isCancel(t)},i.prototype.cancel=function(t,e){return this._restApi.hasCancelToken(t)?this._restApi.cancel(t,e):!!this._graphqlApi.hasCancelToken(t)&&this._graphqlApi.cancel(t,e)},i.prototype.endpoint=function(t){return function(i,t,e,n){return new(e||(e=Promise))(function(o,a){function c(d){try{s(n.next(d))}catch(_){a(_)}}function l(d){try{s(n.throw(d))}catch(_){a(_)}}function s(d){d.done?o(d.value):function(o){return o instanceof e?o:new e(function(a){a(o)})}(d.value).then(c,l)}s((n=n.apply(i,t||[])).next())})}(this,void 0,void 0,function(){return function(i,t){var n,r,o,a,e={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(d){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,r=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(!(o=(o=e.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){e=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){e.label=s[1];break}if(6===s[0]&&e.label<o[1]){e.label=o[1],o=s;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(s);break}o[2]&&e.ops.pop(),e.trys.pop();continue}s=t.call(i,e)}catch(d){s=[6,d],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,d])}}}(this,function(e){return[2,this._restApi.endpoint(t)]})})},i.prototype.getGraphqlOperationType=function(t){return this._graphqlApi.getGraphqlOperationType(t)},i.prototype.graphql=function(t,e){return this._graphqlApi.graphql(t,e)},i}())(null);ce.dQ.register(xn)},54642:function(we,ne,q){"use strict";Object.defineProperty(ne,"__esModule",{value:!0});var Y=q(77339),ce=function(){function X(){this.state=Int32Array.from(Y.INIT),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return X.prototype.update=function(x){if(this.finished)throw new Error("Attempted to update an already finished hash.");var ie=0,G=x.byteLength;if(this.bytesHashed+=G,8*this.bytesHashed>Y.MAX_HASHABLE_LENGTH)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;G>0;)this.buffer[this.bufferLength++]=x[ie++],G--,this.bufferLength===Y.BLOCK_SIZE&&(this.hashBuffer(),this.bufferLength=0)},X.prototype.digest=function(){if(!this.finished){var x=8*this.bytesHashed,ie=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),G=this.bufferLength;if(ie.setUint8(this.bufferLength++,128),G%Y.BLOCK_SIZE>=Y.BLOCK_SIZE-8){for(var S=this.bufferLength;S<Y.BLOCK_SIZE;S++)ie.setUint8(S,0);this.hashBuffer(),this.bufferLength=0}for(S=this.bufferLength;S<Y.BLOCK_SIZE-8;S++)ie.setUint8(S,0);ie.setUint32(Y.BLOCK_SIZE-8,Math.floor(x/4294967296),!0),ie.setUint32(Y.BLOCK_SIZE-4,x),this.hashBuffer(),this.finished=!0}var z=new Uint8Array(Y.DIGEST_LENGTH);for(S=0;S<8;S++)z[4*S]=this.state[S]>>>24&255,z[4*S+1]=this.state[S]>>>16&255,z[4*S+2]=this.state[S]>>>8&255,z[4*S+3]=this.state[S]>>>0&255;return z},X.prototype.hashBuffer=function(){for(var ie=this.buffer,G=this.state,S=G[0],z=G[1],I=G[2],Q=G[3],V=G[4],M=G[5],Z=G[6],ge=G[7],ee=0;ee<Y.BLOCK_SIZE;ee++){if(ee<16)this.temp[ee]=(255&ie[4*ee])<<24|(255&ie[4*ee+1])<<16|(255&ie[4*ee+2])<<8|255&ie[4*ee+3];else{var W=this.temp[ee-2];this.temp[ee]=(((W>>>17|W<<15)^(W>>>19|W<<13)^W>>>10)+this.temp[ee-7]|0)+((((W=this.temp[ee-15])>>>7|W<<25)^(W>>>18|W<<14)^W>>>3)+this.temp[ee-16]|0)}var Ne=(((V>>>6|V<<26)^(V>>>11|V<<21)^(V>>>25|V<<7))+(V&M^~V&Z)|0)+(ge+(Y.KEY[ee]+this.temp[ee]|0)|0)|0,Te=((S>>>2|S<<30)^(S>>>13|S<<19)^(S>>>22|S<<10))+(S&z^S&I^z&I)|0;ge=Z,Z=M,M=V,V=Q+Ne|0,Q=I,I=z,z=S,S=Ne+Te|0}G[0]+=S,G[1]+=z,G[2]+=I,G[3]+=Q,G[4]+=V,G[5]+=M,G[6]+=Z,G[7]+=ge},X}();ne.RawSha256=ce},77339:function(we,ne){"use strict";Object.defineProperty(ne,"__esModule",{value:!0}),ne.BLOCK_SIZE=64,ne.DIGEST_LENGTH=32,ne.KEY=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ne.INIT=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],ne.MAX_HASHABLE_LENGTH=Math.pow(2,53)-1},1093:function(we,ne,q){"use strict";Object.defineProperty(ne,"__esModule",{value:!0}),q(82754).__exportStar(q(48477),ne)},48477:function(we,ne,q){"use strict";Object.defineProperty(ne,"__esModule",{value:!0});var Y=q(82754),ce=q(77339),X=q(54642),x=q(58982),ie=function(){function I(Q){if(this.hash=new X.RawSha256,Q){this.outer=new X.RawSha256;var V=function(I){var Q=z(I);if(Q.byteLength>ce.BLOCK_SIZE){var V=new X.RawSha256;V.update(Q),Q=V.digest()}var M=new Uint8Array(ce.BLOCK_SIZE);return M.set(Q),M}(Q),M=new Uint8Array(ce.BLOCK_SIZE);M.set(V);for(var Z=0;Z<ce.BLOCK_SIZE;Z++)V[Z]^=54,M[Z]^=92;for(this.hash.update(V),this.outer.update(M),Z=0;Z<V.byteLength;Z++)V[Z]=0}}return I.prototype.update=function(Q){if(!function(I){return"string"==typeof I?0===I.length:0===I.byteLength}(Q)&&!this.error)try{this.hash.update(z(Q))}catch(V){this.error=V}},I.prototype.digestSync=function(){if(this.error)throw this.error;return this.outer?(this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest()):this.hash.digest()},I.prototype.digest=function(){return Y.__awaiter(this,void 0,void 0,function(){return Y.__generator(this,function(Q){return[2,this.digestSync()]})})},I}();function z(I){return"string"==typeof I?x.fromUtf8(I):ArrayBuffer.isView(I)?new Uint8Array(I.buffer,I.byteOffset,I.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(I)}ne.Sha256=ie},58982:function(we,ne,q){"use strict";q.r(ne),q.d(ne,{fromUtf8:function(){return ie},toUtf8:function(){return G}});var ie=function(z){return"function"==typeof TextEncoder?(S=z,(new TextEncoder).encode(S)):function(z){for(var I=[],Q=0,V=z.length;Q<V;Q++){var M=z.charCodeAt(Q);if(M<128)I.push(M);else if(M<2048)I.push(M>>6|192,63&M|128);else if(Q+1<z.length&&55296==(64512&M)&&56320==(64512&z.charCodeAt(Q+1))){var Z=65536+((1023&M)<<10)+(1023&z.charCodeAt(++Q));I.push(Z>>18|240,Z>>12&63|128,Z>>6&63|128,63&Z|128)}else I.push(M>>12|224,M>>6&63|128,63&M|128)}return Uint8Array.from(I)}(z);var S},G=function(z){return"function"==typeof TextDecoder?(S=z,new TextDecoder("utf-8").decode(S)):function(z){for(var I="",Q=0,V=z.length;Q<V;Q++){var M=z[Q];if(M<128)I+=String.fromCharCode(M);else if(192<=M&&M<224){var Z=z[++Q];I+=String.fromCharCode((31&M)<<6|63&Z)}else if(240<=M&&M<365){var ee="%"+[M,z[++Q],z[++Q],z[++Q]].map(function(W){return W.toString(16)}).join("%");I+=decodeURIComponent(ee)}else I+=String.fromCharCode((15&M)<<12|(63&z[++Q])<<6|63&z[++Q])}return I}(z);var S}},11178:function(we){we.exports=function(Y){var f,X=Y.localStorage||(f={},{setItem:function(h,p){f[h]=p},getItem:function(h){return f[h]},removeItem:function(h){delete f[h]}}),x_CONNECT=1,x_CONNACK=2,x_PUBLISH=3,x_PUBACK=4,x_PUBREC=5,x_PUBREL=6,x_PUBCOMP=7,x_SUBSCRIBE=8,x_SUBACK=9,x_UNSUBSCRIBE=10,x_UNSUBACK=11,x_PINGREQ=12,x_PINGRESP=13,x_DISCONNECT=14,ie=function(u,h){for(var p in u)if(u.hasOwnProperty(p)){if(!h.hasOwnProperty(p)){var y="Unknown property, "+p+". Valid properties are:";for(var g in h)h.hasOwnProperty(g)&&(y=y+" "+g);throw new Error(y)}if(typeof u[p]!==h[p])throw new Error(I(S.INVALID_TYPE,[typeof u[p],p]))}},G=function(u,h){return function(){return u.apply(h,arguments)}},S={OK:{code:0,text:"AMQJSC0000I OK."},CONNECT_TIMEOUT:{code:1,text:"AMQJSC0001E Connect timed out."},SUBSCRIBE_TIMEOUT:{code:2,text:"AMQJS0002E Subscribe timed out."},UNSUBSCRIBE_TIMEOUT:{code:3,text:"AMQJS0003E Unsubscribe timed out."},PING_TIMEOUT:{code:4,text:"AMQJS0004E Ping timed out."},INTERNAL_ERROR:{code:5,text:"AMQJS0005E Internal error. Error Message: {0}, Stack trace: {1}"},CONNACK_RETURNCODE:{code:6,text:"AMQJS0006E Bad Connack return code:{0} {1}."},SOCKET_ERROR:{code:7,text:"AMQJS0007E Socket error:{0}."},SOCKET_CLOSE:{code:8,text:"AMQJS0008I Socket closed."},MALFORMED_UTF:{code:9,text:"AMQJS0009E Malformed UTF data:{0} {1} {2}."},UNSUPPORTED:{code:10,text:"AMQJS0010E {0} is not supported by this browser."},INVALID_STATE:{code:11,text:"AMQJS0011E Invalid state {0}."},INVALID_TYPE:{code:12,text:"AMQJS0012E Invalid type {0} for {1}."},INVALID_ARGUMENT:{code:13,text:"AMQJS0013E Invalid argument {0} for {1}."},UNSUPPORTED_OPERATION:{code:14,text:"AMQJS0014E Unsupported operation."},INVALID_STORED_DATA:{code:15,text:"AMQJS0015E Invalid data in local storage key={0} value={1}."},INVALID_MQTT_MESSAGE_TYPE:{code:16,text:"AMQJS0016E Invalid MQTT message type {0}."},MALFORMED_UNICODE:{code:17,text:"AMQJS0017E Malformed Unicode string:{0} {1}."},BUFFER_FULL:{code:18,text:"AMQJS0018E Message buffer is full, maximum buffer size: {0}."}},z={0:"Connection Accepted",1:"Connection Refused: unacceptable protocol version",2:"Connection Refused: identifier rejected",3:"Connection Refused: server unavailable",4:"Connection Refused: bad user name or password",5:"Connection Refused: not authorized"},I=function(u,h){var p=u.text;if(h)for(var y,g,w=0;w<h.length;w++)if((g=p.indexOf(y="{"+w+"}"))>0){var D=p.substring(0,g),m=p.substring(g+y.length);p=D+h[w]+m}return p},Q=[0,6,77,81,73,115,100,112,3],V=[0,4,77,81,84,84,4],M=function(u,h){for(var p in this.type=u,h)h.hasOwnProperty(p)&&(this[p]=h[p])};function Z(f,u){var h=u,p=f[u],y=p>>4,g=p&=15;u+=1;var w,D=0,m=1;do{if(u==f.length)return[null,h];D+=(127&(w=f[u++]))*m,m*=128}while(0!=(128&w));var A=u+D;if(A>f.length)return[null,h];var U=new M(y);switch(y){case x_CONNACK:1&f[u++]&&(U.sessionPresent=!0),U.returnCode=f[u++];break;case x_PUBLISH:var T=g>>1&3,R=W(f,u),$=Te(f,u+=2,R);u+=R,T>0&&(U.messageIdentifier=W(f,u),u+=2);var me=new v(f.subarray(u,A));1==(1&g)&&(me.retained=!0),8==(8&g)&&(me.duplicate=!0),me.qos=T,me.destinationName=$,U.payloadMessage=me;break;case x_PUBACK:case x_PUBREC:case x_PUBREL:case x_PUBCOMP:case x_UNSUBACK:U.messageIdentifier=W(f,u);break;case x_SUBACK:U.messageIdentifier=W(f,u),U.returnCode=f.subarray(u+=2,A)}return[U,A]}function ge(f,u,h){return u[h++]=f>>8,u[h++]=f%256,h}function ee(f,u,h,p){return Ne(f,h,p=ge(u,h,p)),p+u}function W(f,u){return 256*f[u]+f[u+1]}function he(f){for(var u=0,h=0;h<f.length;h++){var p=f.charCodeAt(h);p>2047?(55296<=p&&p<=56319&&(h++,u++),u+=3):p>127?u+=2:u++}return u}function Ne(f,u,h){for(var p=h,y=0;y<f.length;y++){var g=f.charCodeAt(y);if(55296<=g&&g<=56319){var w=f.charCodeAt(++y);if(isNaN(w))throw new Error(I(S.MALFORMED_UNICODE,[g,w]));g=w-56320+(g-55296<<10)+65536}g<=127?u[p++]=g:g<=2047?(u[p++]=g>>6&31|192,u[p++]=63&g|128):g<=65535?(u[p++]=g>>12&15|224,u[p++]=g>>6&63|128,u[p++]=63&g|128):(u[p++]=g>>18&7|240,u[p++]=g>>12&63|128,u[p++]=g>>6&63|128,u[p++]=63&g|128)}return u}function Te(f,u,h){for(var y,p="",g=u;g<u+h;){var w=f[g++];if(w<128)y=w;else{var D=f[g++]-128;if(D<0)throw new Error(I(S.MALFORMED_UTF,[w.toString(16),D.toString(16),""]));if(w<224)y=64*(w-192)+D;else{var m=f[g++]-128;if(m<0)throw new Error(I(S.MALFORMED_UTF,[w.toString(16),D.toString(16),m.toString(16)]));if(w<240)y=4096*(w-224)+64*D+m;else{var A=f[g++]-128;if(A<0)throw new Error(I(S.MALFORMED_UTF,[w.toString(16),D.toString(16),m.toString(16),A.toString(16)]));if(!(w<248))throw new Error(I(S.MALFORMED_UTF,[w.toString(16),D.toString(16),m.toString(16),A.toString(16)]));y=262144*(w-240)+4096*D+64*m+A}}}y>65535&&(y-=65536,p+=String.fromCharCode(55296+(y>>10)),y=56320+(1023&y)),p+=String.fromCharCode(y)}return p}M.prototype.encode=function(){var y,f=(15&this.type)<<4,u=0,h=[],p=0;switch(void 0!==this.messageIdentifier&&(u+=2),this.type){case x_CONNECT:switch(this.mqttVersion){case 3:u+=Q.length+3;break;case 4:u+=V.length+3}u+=he(this.clientId)+2,void 0!==this.willMessage&&(u+=he(this.willMessage.destinationName)+2,(y=this.willMessage.payloadBytes)instanceof Uint8Array||(y=new Uint8Array(w)),u+=y.byteLength+2),void 0!==this.userName&&(u+=he(this.userName)+2),void 0!==this.password&&(u+=he(this.password)+2);break;case x_SUBSCRIBE:f|=2;for(var g=0;g<this.topics.length;g++)h[g]=he(this.topics[g]),u+=h[g]+2;u+=this.requestedQos.length;break;case x_UNSUBSCRIBE:for(f|=2,g=0;g<this.topics.length;g++)h[g]=he(this.topics[g]),u+=h[g]+2;break;case x_PUBREL:f|=2;break;case x_PUBLISH:this.payloadMessage.duplicate&&(f|=8),f=f|=this.payloadMessage.qos<<1,this.payloadMessage.retained&&(f|=1),u+=(p=he(this.payloadMessage.destinationName))+2;var w=this.payloadMessage.payloadBytes;u+=w.byteLength,w instanceof ArrayBuffer?w=new Uint8Array(w):w instanceof Uint8Array||(w=new Uint8Array(w.buffer))}var D=function(f){var u=new Array(1),h=0;do{var p=f%128;(f>>=7)>0&&(p|=128),u[h++]=p}while(f>0&&h<4);return u}(u),m=D.length+1,A=new ArrayBuffer(u+m),U=new Uint8Array(A);if(U[0]=f,U.set(D,1),this.type==x_PUBLISH)m=ee(this.payloadMessage.destinationName,p,U,m);else if(this.type==x_CONNECT){switch(this.mqttVersion){case 3:U.set(Q,m),m+=Q.length;break;case 4:U.set(V,m),m+=V.length}var B=0;this.cleanSession&&(B=2),void 0!==this.willMessage&&(B|=4,B|=this.willMessage.qos<<3,this.willMessage.retained&&(B|=32)),void 0!==this.userName&&(B|=128),void 0!==this.password&&(B|=64),U[m++]=B,m=ge(this.keepAliveInterval,U,m)}switch(void 0!==this.messageIdentifier&&(m=ge(this.messageIdentifier,U,m)),this.type){case x_CONNECT:m=ee(this.clientId,he(this.clientId),U,m),void 0!==this.willMessage&&(m=ee(this.willMessage.destinationName,he(this.willMessage.destinationName),U,m),m=ge(y.byteLength,U,m),U.set(y,m),m+=y.byteLength),void 0!==this.userName&&(m=ee(this.userName,he(this.userName),U,m)),void 0!==this.password&&(m=ee(this.password,he(this.password),U,m));break;case x_PUBLISH:U.set(w,m);break;case x_SUBSCRIBE:for(g=0;g<this.topics.length;g++)m=ee(this.topics[g],h[g],U,m),U[m++]=this.requestedQos[g];break;case x_UNSUBSCRIBE:for(g=0;g<this.topics.length;g++)m=ee(this.topics[g],h[g],U,m)}return A};var be=function(u,h){this._client=u,this._keepAliveInterval=1e3*h,this.isReset=!1;var p=new M(x_PINGREQ).encode(),y=function(D){return function(){return g.apply(D)}},g=function(){this.isReset?(this.isReset=!1,this._client._trace("Pinger.doPing","send PINGREQ"),this._client.socket.send(p),this.timeout=setTimeout(y(this),this._keepAliveInterval)):(this._client._trace("Pinger.doPing","Timed out"),this._client._disconnected(S.PING_TIMEOUT.code,I(S.PING_TIMEOUT)))};this.reset=function(){this.isReset=!0,clearTimeout(this.timeout),this._keepAliveInterval>0&&(this.timeout=setTimeout(y(this),this._keepAliveInterval))},this.cancel=function(){clearTimeout(this.timeout)}},_e=function(u,h,p,y){var D,m,A;h||(h=30),this.timeout=setTimeout((D=p,m=u,A=y,function(){return D.apply(m,A)}),1e3*h),this.cancel=function(){clearTimeout(this.timeout)}},b=function(u,h,p,y,g){if(!("WebSocket"in Y)||null===Y.WebSocket)throw new Error(I(S.UNSUPPORTED,["WebSocket"]));if(!("ArrayBuffer"in Y)||null===Y.ArrayBuffer)throw new Error(I(S.UNSUPPORTED,["ArrayBuffer"]));for(var w in this._trace("Paho.Client",u,h,p,y,g),this.host=h,this.port=p,this.path=y,this.uri=u,this.clientId=g,this._wsuri=null,this._localKey=h+":"+p+("/mqtt"!=y?":"+y:"")+":"+g+":",this._msg_queue=[],this._buffered_msg_queue=[],this._sentMessages={},this._receivedMessages={},this._notify_msg_sent={},this._message_identifier=1,this._sequence=0,X)(0===w.indexOf("Sent:"+this._localKey)||0===w.indexOf("Received:"+this._localKey))&&this.restore(w)};b.prototype.host=null,b.prototype.port=null,b.prototype.path=null,b.prototype.uri=null,b.prototype.clientId=null,b.prototype.socket=null,b.prototype.connected=!1,b.prototype.maxMessageIdentifier=65536,b.prototype.connectOptions=null,b.prototype.hostIndex=null,b.prototype.onConnected=null,b.prototype.onConnectionLost=null,b.prototype.onMessageDelivered=null,b.prototype.onMessageArrived=null,b.prototype.traceFunction=null,b.prototype._msg_queue=null,b.prototype._buffered_msg_queue=null,b.prototype._connectTimeout=null,b.prototype.sendPinger=null,b.prototype.receivePinger=null,b.prototype._reconnectInterval=1,b.prototype._reconnecting=!1,b.prototype._reconnectTimeout=null,b.prototype.disconnectedPublishing=!1,b.prototype.disconnectedBufferSize=5e3,b.prototype.receiveBuffer=null,b.prototype._traceBuffer=null,b.prototype._MAX_TRACE_ENTRIES=100,b.prototype.connect=function(f){var u=this._traceMask(f,"password");if(this._trace("Client.connect",u,this.socket,this.connected),this.connected)throw new Error(I(S.INVALID_STATE,["already connected"]));if(this.socket)throw new Error(I(S.INVALID_STATE,["already connected"]));this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),this.connectOptions=f,this._reconnectInterval=1,this._reconnecting=!1,f.uris?(this.hostIndex=0,this._doConnect(f.uris[0])):this._doConnect(this.uri)},b.prototype.subscribe=function(f,u){if(this._trace("Client.subscribe",f,u),!this.connected)throw new Error(I(S.INVALID_STATE,["not connected"]));var h=new M(x_SUBSCRIBE);h.topics=f.constructor===Array?f:[f],void 0===u.qos&&(u.qos=0),h.requestedQos=[];for(var p=0;p<h.topics.length;p++)h.requestedQos[p]=u.qos;u.onSuccess&&(h.onSuccess=function(y){u.onSuccess({invocationContext:u.invocationContext,grantedQos:y})}),u.onFailure&&(h.onFailure=function(y){u.onFailure({invocationContext:u.invocationContext,errorCode:y,errorMessage:I(y)})}),u.timeout&&(h.timeOut=new _e(this,u.timeout,u.onFailure,[{invocationContext:u.invocationContext,errorCode:S.SUBSCRIBE_TIMEOUT.code,errorMessage:I(S.SUBSCRIBE_TIMEOUT)}])),this._requires_ack(h),this._schedule_message(h)},b.prototype.unsubscribe=function(f,u){if(this._trace("Client.unsubscribe",f,u),!this.connected)throw new Error(I(S.INVALID_STATE,["not connected"]));var h=new M(x_UNSUBSCRIBE);h.topics=f.constructor===Array?f:[f],u.onSuccess&&(h.callback=function(){u.onSuccess({invocationContext:u.invocationContext})}),u.timeout&&(h.timeOut=new _e(this,u.timeout,u.onFailure,[{invocationContext:u.invocationContext,errorCode:S.UNSUBSCRIBE_TIMEOUT.code,errorMessage:I(S.UNSUBSCRIBE_TIMEOUT)}])),this._requires_ack(h),this._schedule_message(h)},b.prototype.send=function(f){this._trace("Client.send",f);var u=new M(x_PUBLISH);if(u.payloadMessage=f,this.connected)f.qos>0?this._requires_ack(u):this.onMessageDelivered&&(this._notify_msg_sent[u]=this.onMessageDelivered(u.payloadMessage)),this._schedule_message(u);else{if(!this._reconnecting||!this.disconnectedPublishing)throw new Error(I(S.INVALID_STATE,["not connected"]));if(Object.keys(this._sentMessages).length+this._buffered_msg_queue.length>this.disconnectedBufferSize)throw new Error(I(S.BUFFER_FULL,[this.disconnectedBufferSize]));f.qos>0?this._requires_ack(u):(u.sequence=++this._sequence,this._buffered_msg_queue.unshift(u))}},b.prototype.disconnect=function(){if(this._trace("Client.disconnect"),this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),!this.socket)throw new Error(I(S.INVALID_STATE,["not connecting or connected"]));var f=new M(x_DISCONNECT);this._notify_msg_sent[f]=G(this._disconnected,this),this._schedule_message(f)},b.prototype.getTraceLog=function(){if(null!==this._traceBuffer){for(var f in this._trace("Client.getTraceLog",new Date),this._trace("Client.getTraceLog in flight messages",this._sentMessages.length),this._sentMessages)this._trace("_sentMessages ",f,this._sentMessages[f]);for(var f in this._receivedMessages)this._trace("_receivedMessages ",f,this._receivedMessages[f]);return this._traceBuffer}},b.prototype.startTrace=function(){null===this._traceBuffer&&(this._traceBuffer=[]),this._trace("Client.startTrace",new Date,"@VERSION@-@BUILDLEVEL@")},b.prototype.stopTrace=function(){delete this._traceBuffer},b.prototype._doConnect=function(f){if(this.connectOptions.useSSL){var u=f.split(":");u[0]="wss",f=u.join(":")}this._wsuri=f,this.connected=!1,this.socket=this.connectOptions.mqttVersion<4?new WebSocket(f,["mqttv3.1"]):new WebSocket(f,["mqtt"]),this.socket.binaryType="arraybuffer",this.socket.onopen=G(this._on_socket_open,this),this.socket.onmessage=G(this._on_socket_message,this),this.socket.onerror=G(this._on_socket_error,this),this.socket.onclose=G(this._on_socket_close,this),this.sendPinger=new be(this,this.connectOptions.keepAliveInterval),this.receivePinger=new be(this,this.connectOptions.keepAliveInterval),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._connectTimeout=new _e(this,this.connectOptions.timeout,this._disconnected,[S.CONNECT_TIMEOUT.code,I(S.CONNECT_TIMEOUT)])},b.prototype._schedule_message=function(f){this._msg_queue.unshift(f),this.connected&&this._process_queue()},b.prototype.store=function(f,u){var h={type:u.type,messageIdentifier:u.messageIdentifier,version:1};switch(u.type){case x_PUBLISH:u.pubRecReceived&&(h.pubRecReceived=!0),h.payloadMessage={};for(var p="",y=u.payloadMessage.payloadBytes,g=0;g<y.length;g++)y[g]<=15?p=p+"0"+y[g].toString(16):p+=y[g].toString(16);h.payloadMessage.payloadHex=p,h.payloadMessage.qos=u.payloadMessage.qos,h.payloadMessage.destinationName=u.payloadMessage.destinationName,u.payloadMessage.duplicate&&(h.payloadMessage.duplicate=!0),u.payloadMessage.retained&&(h.payloadMessage.retained=!0),0===f.indexOf("Sent:")&&(void 0===u.sequence&&(u.sequence=++this._sequence),h.sequence=u.sequence);break;default:throw Error(I(S.INVALID_STORED_DATA,[f+this._localKey+u.messageIdentifier,h]))}X.setItem(f+this._localKey+u.messageIdentifier,JSON.stringify(h))},b.prototype.restore=function(f){var u=X.getItem(f),h=JSON.parse(u),p=new M(h.type,h);switch(h.type){case x_PUBLISH:for(var y=h.payloadMessage.payloadHex,g=new ArrayBuffer(y.length/2),w=new Uint8Array(g),D=0;y.length>=2;){var m=parseInt(y.substring(0,2),16);y=y.substring(2,y.length),w[D++]=m}var A=new v(w);A.qos=h.payloadMessage.qos,A.destinationName=h.payloadMessage.destinationName,h.payloadMessage.duplicate&&(A.duplicate=!0),h.payloadMessage.retained&&(A.retained=!0),p.payloadMessage=A;break;default:throw Error(I(S.INVALID_STORED_DATA,[f,u]))}0===f.indexOf("Sent:"+this._localKey)?(p.payloadMessage.duplicate=!0,this._sentMessages[p.messageIdentifier]=p):0===f.indexOf("Received:"+this._localKey)&&(this._receivedMessages[p.messageIdentifier]=p)},b.prototype._process_queue=function(){for(var f=null;f=this._msg_queue.pop();)this._socket_send(f),this._notify_msg_sent[f]&&(this._notify_msg_sent[f](),delete this._notify_msg_sent[f])},b.prototype._requires_ack=function(f){var u=Object.keys(this._sentMessages).length;if(u>this.maxMessageIdentifier)throw Error("Too many messages:"+u);for(;void 0!==this._sentMessages[this._message_identifier];)this._message_identifier++;f.messageIdentifier=this._message_identifier,this._sentMessages[f.messageIdentifier]=f,f.type===x_PUBLISH&&this.store("Sent:",f),this._message_identifier===this.maxMessageIdentifier&&(this._message_identifier=1)},b.prototype._on_socket_open=function(){var f=new M(x_CONNECT,this.connectOptions);f.clientId=this.clientId,this._socket_send(f)},b.prototype._on_socket_message=function(f){this._trace("Client._on_socket_message",f.data);for(var u=this._deframeMessages(f.data),h=0;h<u.length;h+=1)this._handleMessage(u[h])},b.prototype._deframeMessages=function(f){var u=new Uint8Array(f),h=[];if(this.receiveBuffer){var p=new Uint8Array(this.receiveBuffer.length+u.length);p.set(this.receiveBuffer),p.set(u,this.receiveBuffer.length),u=p,delete this.receiveBuffer}try{for(var y=0;y<u.length;){var g=Z(u,y),w=g[0];if(y=g[1],null===w)break;h.push(w)}y<u.length&&(this.receiveBuffer=u.subarray(y))}catch(m){var D="undefined"==m.hasOwnProperty("stack")?m.stack.toString():"No Error Stack Available";return void this._disconnected(S.INTERNAL_ERROR.code,I(S.INTERNAL_ERROR,[m.message,D]))}return h},b.prototype._handleMessage=function(f){this._trace("Client._handleMessage",f);try{switch(f.type){case x_CONNACK:if(this._connectTimeout.cancel(),this._reconnectTimeout&&this._reconnectTimeout.cancel(),this.connectOptions.cleanSession){for(var u in this._sentMessages)X.removeItem("Sent:"+this._localKey+(A=this._sentMessages[u]).messageIdentifier);for(var u in this._sentMessages={},this._receivedMessages)X.removeItem("Received:"+this._localKey+(U=this._receivedMessages[u]).messageIdentifier);this._receivedMessages={}}if(0!==f.returnCode){this._disconnected(S.CONNACK_RETURNCODE.code,I(S.CONNACK_RETURNCODE,[f.returnCode,z[f.returnCode]]));break}this.connected=!0,this.connectOptions.uris&&(this.hostIndex=this.connectOptions.uris.length);var h=[];for(var p in this._sentMessages)this._sentMessages.hasOwnProperty(p)&&h.push(this._sentMessages[p]);if(this._buffered_msg_queue.length>0)for(var y=null;y=this._buffered_msg_queue.pop();)h.push(y),this.onMessageDelivered&&(this._notify_msg_sent[y]=this.onMessageDelivered(y.payloadMessage));h=h.sort(function(R,$){return R.sequence-$.sequence});for(var g=0,w=h.length;g<w;g++)if((A=h[g]).type==x_PUBLISH&&A.pubRecReceived){var D=new M(x_PUBREL,{messageIdentifier:A.messageIdentifier});this._schedule_message(D)}else this._schedule_message(A);this.connectOptions.onSuccess&&this.connectOptions.onSuccess({invocationContext:this.connectOptions.invocationContext});var m=!1;this._reconnecting&&(m=!0,this._reconnectInterval=1,this._reconnecting=!1),this._connected(m,this._wsuri),this._process_queue();break;case x_PUBLISH:this._receivePublish(f);break;case x_PUBACK:(A=this._sentMessages[f.messageIdentifier])&&(delete this._sentMessages[f.messageIdentifier],X.removeItem("Sent:"+this._localKey+f.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(A.payloadMessage));break;case x_PUBREC:(A=this._sentMessages[f.messageIdentifier])&&(A.pubRecReceived=!0,D=new M(x_PUBREL,{messageIdentifier:f.messageIdentifier}),this.store("Sent:",A),this._schedule_message(D));break;case x_PUBREL:var U=this._receivedMessages[f.messageIdentifier];X.removeItem("Received:"+this._localKey+f.messageIdentifier),U&&(this._receiveMessage(U),delete this._receivedMessages[f.messageIdentifier]);var B=new M(x_PUBCOMP,{messageIdentifier:f.messageIdentifier});this._schedule_message(B);break;case x_PUBCOMP:var A=this._sentMessages[f.messageIdentifier];delete this._sentMessages[f.messageIdentifier],X.removeItem("Sent:"+this._localKey+f.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(A.payloadMessage);break;case x_SUBACK:(A=this._sentMessages[f.messageIdentifier])&&(A.timeOut&&A.timeOut.cancel(),128===f.returnCode[0]?A.onFailure&&A.onFailure(f.returnCode):A.onSuccess&&A.onSuccess(f.returnCode),delete this._sentMessages[f.messageIdentifier]);break;case x_UNSUBACK:(A=this._sentMessages[f.messageIdentifier])&&(A.timeOut&&A.timeOut.cancel(),A.callback&&A.callback(),delete this._sentMessages[f.messageIdentifier]);break;case x_PINGRESP:this.sendPinger.reset();break;case x_DISCONNECT:this._disconnected(S.INVALID_MQTT_MESSAGE_TYPE.code,I(S.INVALID_MQTT_MESSAGE_TYPE,[f.type]));break;default:this._disconnected(S.INVALID_MQTT_MESSAGE_TYPE.code,I(S.INVALID_MQTT_MESSAGE_TYPE,[f.type]))}}catch(R){var T="undefined"==R.hasOwnProperty("stack")?R.stack.toString():"No Error Stack Available";return void this._disconnected(S.INTERNAL_ERROR.code,I(S.INTERNAL_ERROR,[R.message,T]))}},b.prototype._on_socket_error=function(f){this._reconnecting||this._disconnected(S.SOCKET_ERROR.code,I(S.SOCKET_ERROR,[f.data]))},b.prototype._on_socket_close=function(){this._reconnecting||this._disconnected(S.SOCKET_CLOSE.code,I(S.SOCKET_CLOSE))},b.prototype._socket_send=function(f){if(1==f.type){var u=this._traceMask(f,"password");this._trace("Client._socket_send",u)}else this._trace("Client._socket_send",f);this.socket.send(f.encode()),this.sendPinger.reset()},b.prototype._receivePublish=function(f){switch(f.payloadMessage.qos){case"undefined":case 0:this._receiveMessage(f);break;case 1:var u=new M(x_PUBACK,{messageIdentifier:f.messageIdentifier});this._schedule_message(u),this._receiveMessage(f);break;case 2:this._receivedMessages[f.messageIdentifier]=f,this.store("Received:",f);var h=new M(x_PUBREC,{messageIdentifier:f.messageIdentifier});this._schedule_message(h);break;default:throw Error("Invaild qos="+f.payloadMessage.qos)}},b.prototype._receiveMessage=function(f){this.onMessageArrived&&this.onMessageArrived(f.payloadMessage)},b.prototype._connected=function(f,u){this.onConnected&&this.onConnected(f,u)},b.prototype._reconnect=function(){this._trace("Client._reconnect"),this.connected||(this._reconnecting=!0,this.sendPinger.cancel(),this.receivePinger.cancel(),this._reconnectInterval<128&&(this._reconnectInterval=2*this._reconnectInterval),this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri))},b.prototype._disconnected=function(f,u){if(this._trace("Client._disconnected",f,u),void 0!==f&&this._reconnecting)this._reconnectTimeout=new _e(this,this._reconnectInterval,this._reconnect);else if(this.sendPinger.cancel(),this.receivePinger.cancel(),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._msg_queue=[],this._buffered_msg_queue=[],this._notify_msg_sent={},this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,1===this.socket.readyState&&this.socket.close(),delete this.socket),this.connectOptions.uris&&this.hostIndex<this.connectOptions.uris.length-1)this.hostIndex++,this._doConnect(this.connectOptions.uris[this.hostIndex]);else if(void 0===f&&(f=S.OK.code,u=I(S.OK)),this.connected){if(this.connected=!1,this.onConnectionLost&&this.onConnectionLost({errorCode:f,errorMessage:u,reconnect:this.connectOptions.reconnect,uri:this._wsuri}),f!==S.OK.code&&this.connectOptions.reconnect)return this._reconnectInterval=1,void this._reconnect()}else 4===this.connectOptions.mqttVersion&&!1===this.connectOptions.mqttVersionExplicit?(this._trace("Failed to connect V4, dropping back to V3"),this.connectOptions.mqttVersion=3,this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri)):this.connectOptions.onFailure&&this.connectOptions.onFailure({invocationContext:this.connectOptions.invocationContext,errorCode:f,errorMessage:u})},b.prototype._trace=function(){if(this.traceFunction){var f=Array.prototype.slice.call(arguments);for(var u in f)void 0!==f[u]&&f.splice(u,1,JSON.stringify(f[u]));var h=f.join("");this.traceFunction({severity:"Debug",message:h})}if(null!==this._traceBuffer){u=0;for(var p=arguments.length;u<p;u++)this._traceBuffer.length==this._MAX_TRACE_ENTRIES&&this._traceBuffer.shift(),this._traceBuffer.push(0===u||void 0===arguments[u]?arguments[u]:" "+JSON.stringify(arguments[u]))}},b.prototype._traceMask=function(f,u){var h={};for(var p in f)f.hasOwnProperty(p)&&(h[p]=p==u?"******":f[p]);return h};var v=function(u){var h;if(!("string"==typeof u||u instanceof ArrayBuffer||ArrayBuffer.isView(u)&&!(u instanceof DataView)))throw I(S.INVALID_ARGUMENT,[u,"newPayload"]);h=u;var p,y=0,g=!1,w=!1;Object.defineProperties(this,{payloadString:{enumerable:!0,get:function(){return"string"==typeof h?h:Te(h,0,h.length)}},payloadBytes:{enumerable:!0,get:function(){if("string"==typeof h){var m=new ArrayBuffer(he(h)),A=new Uint8Array(m);return Ne(h,A,0),A}return h}},destinationName:{enumerable:!0,get:function(){return p},set:function(m){if("string"!=typeof m)throw new Error(I(S.INVALID_ARGUMENT,[m,"newDestinationName"]));p=m}},qos:{enumerable:!0,get:function(){return y},set:function(m){if(0!==m&&1!==m&&2!==m)throw new Error("Invalid argument:"+m);y=m}},retained:{enumerable:!0,get:function(){return g},set:function(m){if("boolean"!=typeof m)throw new Error(I(S.INVALID_ARGUMENT,[m,"newRetained"]));g=m}},topic:{enumerable:!0,get:function(){return p},set:function(m){p=m}},duplicate:{enumerable:!0,get:function(){return w},set:function(m){w=m}}})};return{Client:function(u,h,p,y){var g;if("string"!=typeof u)throw new Error(I(S.INVALID_TYPE,[typeof u,"host"]));if(2==arguments.length){y=h;var w=(g=u).match(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/);if(!w)throw new Error(I(S.INVALID_ARGUMENT,[u,"host"]));u=w[4]||w[2],h=parseInt(w[7]),p=w[8]}else{if(3==arguments.length&&(y=p,p="/mqtt"),"number"!=typeof h||h<0)throw new Error(I(S.INVALID_TYPE,[typeof h,"port"]));if("string"!=typeof p)throw new Error(I(S.INVALID_TYPE,[typeof p,"path"]));var D=-1!==u.indexOf(":")&&"["!==u.slice(0,1)&&"]"!==u.slice(-1);g="ws://"+(D?"["+u+"]":u)+":"+h+p}for(var m=0,A=0;A<y.length;A++){var U=y.charCodeAt(A);55296<=U&&U<=56319&&A++,m++}if("string"!=typeof y||m>65535)throw new Error(I(S.INVALID_ARGUMENT,[y,"clientId"]));var B=new b(g,u,h,p,y);Object.defineProperties(this,{host:{get:function(){return u},set:function(){throw new Error(I(S.UNSUPPORTED_OPERATION))}},port:{get:function(){return h},set:function(){throw new Error(I(S.UNSUPPORTED_OPERATION))}},path:{get:function(){return p},set:function(){throw new Error(I(S.UNSUPPORTED_OPERATION))}},uri:{get:function(){return g},set:function(){throw new Error(I(S.UNSUPPORTED_OPERATION))}},clientId:{get:function(){return B.clientId},set:function(){throw new Error(I(S.UNSUPPORTED_OPERATION))}},onConnected:{get:function(){return B.onConnected},set:function(R){if("function"!=typeof R)throw new Error(I(S.INVALID_TYPE,[typeof R,"onConnected"]));B.onConnected=R}},disconnectedPublishing:{get:function(){return B.disconnectedPublishing},set:function(R){B.disconnectedPublishing=R}},disconnectedBufferSize:{get:function(){return B.disconnectedBufferSize},set:function(R){B.disconnectedBufferSize=R}},onConnectionLost:{get:function(){return B.onConnectionLost},set:function(R){if("function"!=typeof R)throw new Error(I(S.INVALID_TYPE,[typeof R,"onConnectionLost"]));B.onConnectionLost=R}},onMessageDelivered:{get:function(){return B.onMessageDelivered},set:function(R){if("function"!=typeof R)throw new Error(I(S.INVALID_TYPE,[typeof R,"onMessageDelivered"]));B.onMessageDelivered=R}},onMessageArrived:{get:function(){return B.onMessageArrived},set:function(R){if("function"!=typeof R)throw new Error(I(S.INVALID_TYPE,[typeof R,"onMessageArrived"]));B.onMessageArrived=R}},trace:{get:function(){return B.traceFunction},set:function(R){if("function"!=typeof R)throw new Error(I(S.INVALID_TYPE,[typeof R,"onTrace"]));B.traceFunction=R}}}),this.connect=function(T){if(ie(T=T||{},{timeout:"number",userName:"string",password:"string",willMessage:"object",keepAliveInterval:"number",cleanSession:"boolean",useSSL:"boolean",invocationContext:"object",onSuccess:"function",onFailure:"function",hosts:"object",ports:"object",reconnect:"boolean",mqttVersion:"number",mqttVersionExplicit:"boolean",uris:"object"}),void 0===T.keepAliveInterval&&(T.keepAliveInterval=60),T.mqttVersion>4||T.mqttVersion<3)throw new Error(I(S.INVALID_ARGUMENT,[T.mqttVersion,"connectOptions.mqttVersion"]));if(void 0===T.mqttVersion?(T.mqttVersionExplicit=!1,T.mqttVersion=4):T.mqttVersionExplicit=!0,void 0!==T.password&&void 0===T.userName)throw new Error(I(S.INVALID_ARGUMENT,[T.password,"connectOptions.password"]));if(T.willMessage){if(!(T.willMessage instanceof v))throw new Error(I(S.INVALID_TYPE,[T.willMessage,"connectOptions.willMessage"]));if(T.willMessage.stringPayload=null,void 0===T.willMessage.destinationName)throw new Error(I(S.INVALID_TYPE,[typeof T.willMessage.destinationName,"connectOptions.willMessage.destinationName"]))}if(void 0===T.cleanSession&&(T.cleanSession=!0),T.hosts){if(!(T.hosts instanceof Array))throw new Error(I(S.INVALID_ARGUMENT,[T.hosts,"connectOptions.hosts"]));if(T.hosts.length<1)throw new Error(I(S.INVALID_ARGUMENT,[T.hosts,"connectOptions.hosts"]));for(var R=!1,$=0;$<T.hosts.length;$++){if("string"!=typeof T.hosts[$])throw new Error(I(S.INVALID_TYPE,[typeof T.hosts[$],"connectOptions.hosts["+$+"]"]));if(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/.test(T.hosts[$])){if(0===$)R=!0;else if(!R)throw new Error(I(S.INVALID_ARGUMENT,[T.hosts[$],"connectOptions.hosts["+$+"]"]))}else if(R)throw new Error(I(S.INVALID_ARGUMENT,[T.hosts[$],"connectOptions.hosts["+$+"]"]))}if(R)T.uris=T.hosts;else{if(!T.ports)throw new Error(I(S.INVALID_ARGUMENT,[T.ports,"connectOptions.ports"]));if(!(T.ports instanceof Array))throw new Error(I(S.INVALID_ARGUMENT,[T.ports,"connectOptions.ports"]));if(T.hosts.length!==T.ports.length)throw new Error(I(S.INVALID_ARGUMENT,[T.ports,"connectOptions.ports"]));for(T.uris=[],$=0;$<T.hosts.length;$++){if("number"!=typeof T.ports[$]||T.ports[$]<0)throw new Error(I(S.INVALID_TYPE,[typeof T.ports[$],"connectOptions.ports["+$+"]"]));var me=T.hosts[$],se=T.ports[$],at=-1!==me.indexOf(":");T.uris.push(g="ws://"+(at?"["+me+"]":me)+":"+se+p)}}}B.connect(T)},this.subscribe=function(T,R){if("string"!=typeof T&&T.constructor!==Array)throw new Error("Invalid argument:"+T);if(ie(R=R||{},{qos:"number",invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),R.timeout&&!R.onFailure)throw new Error("subscribeOptions.timeout specified with no onFailure callback.");if(void 0!==R.qos&&0!==R.qos&&1!==R.qos&&2!==R.qos)throw new Error(I(S.INVALID_ARGUMENT,[R.qos,"subscribeOptions.qos"]));B.subscribe(T,R)},this.unsubscribe=function(T,R){if("string"!=typeof T&&T.constructor!==Array)throw new Error("Invalid argument:"+T);if(ie(R=R||{},{invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),R.timeout&&!R.onFailure)throw new Error("unsubscribeOptions.timeout specified with no onFailure callback.");B.unsubscribe(T,R)},this.send=function(T,R,$,me){var se;if(0===arguments.length)throw new Error("Invalid argument.length");if(1==arguments.length){if(!(T instanceof v)&&"string"!=typeof T)throw new Error("Invalid argument:"+typeof T);if(void 0===(se=T).destinationName)throw new Error(I(S.INVALID_ARGUMENT,[se.destinationName,"Message.destinationName"]));B.send(se)}else(se=new v(R)).destinationName=T,arguments.length>=3&&(se.qos=$),arguments.length>=4&&(se.retained=me),B.send(se)},this.publish=function(T,R,$,me){var se;if(0===arguments.length)throw new Error("Invalid argument.length");if(1==arguments.length){if(!(T instanceof v)&&"string"!=typeof T)throw new Error("Invalid argument:"+typeof T);if(void 0===(se=T).destinationName)throw new Error(I(S.INVALID_ARGUMENT,[se.destinationName,"Message.destinationName"]));B.send(se)}else(se=new v(R)).destinationName=T,arguments.length>=3&&(se.qos=$),arguments.length>=4&&(se.retained=me),B.send(se)},this.disconnect=function(){B.disconnect()},this.getTraceLog=function(){return B.getTraceLog()},this.startTrace=function(){B.startTrace()},this.stopTrace=function(){B.stopTrace()},this.isConnected=function(){return B.connected}},Message:v}}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},13880:function(we,ne,q){we.exports=q(60626).Observable},60626:function(we,ne){"use strict";function Y(b,k){if(!(b instanceof k))throw new TypeError("Cannot call a class as a function")}function ce(b,k){for(var v=0;v<k.length;v++){var f=k[v];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(b,f.key,f)}}function X(b,k,v){return k&&ce(b.prototype,k),v&&ce(b,v),b}ne.Observable=void 0;var x=function(){return"function"==typeof Symbol},ie=function(k){return x()&&Boolean(Symbol[k])},G=function(k){return ie(k)?Symbol[k]:"@@"+k};x()&&!ie("observable")&&(Symbol.observable=Symbol("observable"));var S=G("iterator"),z=G("observable"),I=G("species");function Q(b,k){var v=b[k];if(null!=v){if("function"!=typeof v)throw new TypeError(v+" is not a function");return v}}function V(b){var k=b.constructor;return void 0!==k&&null===(k=k[I])&&(k=void 0),void 0!==k?k:_e}function Z(b){Z.log?Z.log(b):setTimeout(function(){throw b})}function ge(b){Promise.resolve().then(function(){try{b()}catch(k){Z(k)}})}function ee(b){var k=b._cleanup;if(void 0!==k&&(b._cleanup=void 0,k))try{if("function"==typeof k)k();else{var v=Q(k,"unsubscribe");v&&v.call(k)}}catch(f){Z(f)}}function W(b){b._observer=void 0,b._queue=void 0,b._state="closed"}function he(b,k,v){b._state="running";var f=b._observer;try{var u=Q(f,k);switch(k){case"next":u&&u.call(f,v);break;case"error":if(W(b),!u)throw v;u.call(f,v);break;case"complete":W(b),u&&u.call(f)}}catch(h){Z(h)}"closed"===b._state?ee(b):"running"===b._state&&(b._state="ready")}function Ne(b,k,v){if("closed"!==b._state){if("buffering"===b._state)return void b._queue.push({type:k,value:v});if("ready"!==b._state)return b._state="buffering",b._queue=[{type:k,value:v}],void ge(function(){return function(b){var k=b._queue;if(k){b._queue=void 0,b._state="ready";for(var v=0;v<k.length&&(he(b,k[v].type,k[v].value),"closed"!==b._state);++v);}}(b)});he(b,k,v)}}var Te=function(){function b(k,v){Y(this,b),this._cleanup=void 0,this._observer=k,this._queue=void 0,this._state="initializing";var f=new be(this);try{this._cleanup=v.call(void 0,f)}catch(u){f.error(u)}"initializing"===this._state&&(this._state="ready")}return X(b,[{key:"unsubscribe",value:function(){"closed"!==this._state&&(W(this),ee(this))}},{key:"closed",get:function(){return"closed"===this._state}}]),b}(),be=function(){function b(k){Y(this,b),this._subscription=k}return X(b,[{key:"next",value:function(v){Ne(this._subscription,"next",v)}},{key:"error",value:function(v){Ne(this._subscription,"error",v)}},{key:"complete",value:function(){Ne(this._subscription,"complete")}},{key:"closed",get:function(){return"closed"===this._subscription._state}}]),b}(),_e=function(){function b(k){if(Y(this,b),!(this instanceof b))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof k)throw new TypeError("Observable initializer must be a function");this._subscriber=k}return X(b,[{key:"subscribe",value:function(v){return("object"!=typeof v||null===v)&&(v={next:v,error:arguments[1],complete:arguments[2]}),new Te(v,this._subscriber)}},{key:"forEach",value:function(v){var f=this;return new Promise(function(u,h){if("function"==typeof v)var y=f.subscribe({next:function(w){try{v(w,p)}catch(D){h(D),y.unsubscribe()}},error:h,complete:u});else h(new TypeError(v+" is not a function"));function p(){y.unsubscribe(),u()}})}},{key:"map",value:function(v){var f=this;if("function"!=typeof v)throw new TypeError(v+" is not a function");return new(V(this))(function(h){return f.subscribe({next:function(y){try{y=v(y)}catch(g){return h.error(g)}h.next(y)},error:function(y){h.error(y)},complete:function(){h.complete()}})})}},{key:"filter",value:function(v){var f=this;if("function"!=typeof v)throw new TypeError(v+" is not a function");return new(V(this))(function(h){return f.subscribe({next:function(y){try{if(!v(y))return}catch(g){return h.error(g)}h.next(y)},error:function(y){h.error(y)},complete:function(){h.complete()}})})}},{key:"reduce",value:function(v){var f=this;if("function"!=typeof v)throw new TypeError(v+" is not a function");var u=V(this),h=arguments.length>1,p=!1,y=arguments[1],g=y;return new u(function(w){return f.subscribe({next:function(m){var A=!p;if(p=!0,!A||h)try{g=v(g,m)}catch(U){return w.error(U)}else g=m},error:function(m){w.error(m)},complete:function(){if(!p&&!h)return w.error(new TypeError("Cannot reduce an empty sequence"));w.next(g),w.complete()}})})}},{key:"concat",value:function(){for(var v=this,f=arguments.length,u=new Array(f),h=0;h<f;h++)u[h]=arguments[h];var p=V(this);return new p(function(y){var g,w=0;return function D(m){g=m.subscribe({next:function(U){y.next(U)},error:function(U){y.error(U)},complete:function(){w===u.length?(g=void 0,y.complete()):D(p.from(u[w++]))}})}(v),function(){g&&(g.unsubscribe(),g=void 0)}})}},{key:"flatMap",value:function(v){var f=this;if("function"!=typeof v)throw new TypeError(v+" is not a function");var u=V(this);return new u(function(h){var p=[],y=f.subscribe({next:function(D){if(v)try{D=v(D)}catch(A){return h.error(A)}var m=u.from(D).subscribe({next:function(U){h.next(U)},error:function(U){h.error(U)},complete:function(){var U=p.indexOf(m);U>=0&&p.splice(U,1),g()}});p.push(m)},error:function(D){h.error(D)},complete:function(){g()}});function g(){y.closed&&0===p.length&&h.complete()}return function(){p.forEach(function(w){return w.unsubscribe()}),y.unsubscribe()}})}},{key:z,value:function(){return this}}],[{key:"from",value:function(v){var f="function"==typeof this?this:b;if(null==v)throw new TypeError(v+" is not an object");var u=Q(v,z);if(u){var h=u.call(v);if(Object(h)!==h)throw new TypeError(h+" is not an object");return function(b){return b instanceof _e}(h)&&h.constructor===f?h:new f(function(p){return h.subscribe(p)})}if(ie("iterator")&&(u=Q(v,S)))return new f(function(p){ge(function(){if(!p.closed){var y=!0,g=!1,w=void 0;try{for(var m,D=u.call(v)[Symbol.iterator]();!(y=(m=D.next()).done);y=!0)if(p.next(m.value),p.closed)return}catch(U){g=!0,w=U}finally{try{!y&&null!=D.return&&D.return()}finally{if(g)throw w}}p.complete()}})});if(Array.isArray(v))return new f(function(p){ge(function(){if(!p.closed){for(var y=0;y<v.length;++y)if(p.next(v[y]),p.closed)return;p.complete()}})});throw new TypeError(v+" is not observable")}},{key:"of",value:function(){for(var v=arguments.length,f=new Array(v),u=0;u<v;u++)f[u]=arguments[u];var h="function"==typeof this?this:b;return new h(function(p){ge(function(){if(!p.closed){for(var y=0;y<f.length;++y)if(p.next(f[y]),p.closed)return;p.complete()}})})}},{key:I,get:function(){return this}}]),b}();ne.Observable=_e,x()&&Object.defineProperty(_e,Symbol("extensions"),{value:{symbol:z,hostReportError:Z},configurable:!0})},32821:function(we,ne,q){"use strict";q.d(ne,{x:function(){return ce}});var Y=q(529),ce=function(){function X(){}return X.apiName=Y.N.endpointName,X.paths={pathGroups:"/group",pathGroup:"/group/",pathThings:"/thing",pathSubscribeOffline:"/subscribe/offline",pathAttribute:"/attribute",pathThing:"/thing/",pathTypes:"/type",pathType:"/type/",pathMapper:"/mapper/"},X.params={response:!0,timeout:1e4},X}()},82754:function(we,ne,q){"use strict";q.r(ne),q.d(ne,{__extends:function(){return ce},__assign:function(){return X},__rest:function(){return x},__decorate:function(){return ie},__param:function(){return G},__metadata:function(){return S},__awaiter:function(){return z},__generator:function(){return I},__createBinding:function(){return Q},__exportStar:function(){return V},__values:function(){return M},__read:function(){return Z},__spread:function(){return ge},__spreadArrays:function(){return ee},__await:function(){return W},__asyncGenerator:function(){return Le},__asyncDelegator:function(){return he},__asyncValues:function(){return Ne},__makeTemplateObject:function(){return Te},__importStar:function(){return be},__importDefault:function(){return _e},__classPrivateFieldGet:function(){return b},__classPrivateFieldSet:function(){return k}});var Y=function(v,f){return(Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,h){u.__proto__=h}||function(u,h){for(var p in h)h.hasOwnProperty(p)&&(u[p]=h[p])})(v,f)};function ce(v,f){function u(){this.constructor=v}Y(v,f),v.prototype=null===f?Object.create(f):(u.prototype=f.prototype,new u)}var X=function(){return(X=Object.assign||function(f){for(var u,h=1,p=arguments.length;h<p;h++)for(var y in u=arguments[h])Object.prototype.hasOwnProperty.call(u,y)&&(f[y]=u[y]);return f}).apply(this,arguments)};function x(v,f){var u={};for(var h in v)Object.prototype.hasOwnProperty.call(v,h)&&f.indexOf(h)<0&&(u[h]=v[h]);if(null!=v&&"function"==typeof Object.getOwnPropertySymbols){var p=0;for(h=Object.getOwnPropertySymbols(v);p<h.length;p++)f.indexOf(h[p])<0&&Object.prototype.propertyIsEnumerable.call(v,h[p])&&(u[h[p]]=v[h[p]])}return u}function ie(v,f,u,h){var g,p=arguments.length,y=p<3?f:null===h?h=Object.getOwnPropertyDescriptor(f,u):h;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)y=Reflect.decorate(v,f,u,h);else for(var w=v.length-1;w>=0;w--)(g=v[w])&&(y=(p<3?g(y):p>3?g(f,u,y):g(f,u))||y);return p>3&&y&&Object.defineProperty(f,u,y),y}function G(v,f){return function(u,h){f(u,h,v)}}function S(v,f){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(v,f)}function z(v,f,u,h){return new(u||(u=Promise))(function(y,g){function w(A){try{m(h.next(A))}catch(U){g(U)}}function D(A){try{m(h.throw(A))}catch(U){g(U)}}function m(A){A.done?y(A.value):function(y){return y instanceof u?y:new u(function(g){g(y)})}(A.value).then(w,D)}m((h=h.apply(v,f||[])).next())})}function I(v,f){var h,p,y,g,u={label:0,sent:function(){if(1&y[0])throw y[1];return y[1]},trys:[],ops:[]};return g={next:w(0),throw:w(1),return:w(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function w(m){return function(A){return function(m){if(h)throw new TypeError("Generator is already executing.");for(;u;)try{if(h=1,p&&(y=2&m[0]?p.return:m[0]?p.throw||((y=p.return)&&y.call(p),0):p.next)&&!(y=y.call(p,m[1])).done)return y;switch(p=0,y&&(m=[2&m[0],y.value]),m[0]){case 0:case 1:y=m;break;case 4:return u.label++,{value:m[1],done:!1};case 5:u.label++,p=m[1],m=[0];continue;case 7:m=u.ops.pop(),u.trys.pop();continue;default:if(!(y=(y=u.trys).length>0&&y[y.length-1])&&(6===m[0]||2===m[0])){u=0;continue}if(3===m[0]&&(!y||m[1]>y[0]&&m[1]<y[3])){u.label=m[1];break}if(6===m[0]&&u.label<y[1]){u.label=y[1],y=m;break}if(y&&u.label<y[2]){u.label=y[2],u.ops.push(m);break}y[2]&&u.ops.pop(),u.trys.pop();continue}m=f.call(v,u)}catch(A){m=[6,A],p=0}finally{h=y=0}if(5&m[0])throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}([m,A])}}}function Q(v,f,u,h){void 0===h&&(h=u),v[h]=f[u]}function V(v,f){for(var u in v)"default"!==u&&!f.hasOwnProperty(u)&&(f[u]=v[u])}function M(v){var f="function"==typeof Symbol&&Symbol.iterator,u=f&&v[f],h=0;if(u)return u.call(v);if(v&&"number"==typeof v.length)return{next:function(){return v&&h>=v.length&&(v=void 0),{value:v&&v[h++],done:!v}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")}function Z(v,f){var u="function"==typeof Symbol&&v[Symbol.iterator];if(!u)return v;var p,g,h=u.call(v),y=[];try{for(;(void 0===f||f-- >0)&&!(p=h.next()).done;)y.push(p.value)}catch(w){g={error:w}}finally{try{p&&!p.done&&(u=h.return)&&u.call(h)}finally{if(g)throw g.error}}return y}function ge(){for(var v=[],f=0;f<arguments.length;f++)v=v.concat(Z(arguments[f]));return v}function ee(){for(var v=0,f=0,u=arguments.length;f<u;f++)v+=arguments[f].length;var h=Array(v),p=0;for(f=0;f<u;f++)for(var y=arguments[f],g=0,w=y.length;g<w;g++,p++)h[p]=y[g];return h}function W(v){return this instanceof W?(this.v=v,this):new W(v)}function Le(v,f,u){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var p,h=u.apply(v,f||[]),y=[];return p={},g("next"),g("throw"),g("return"),p[Symbol.asyncIterator]=function(){return this},p;function g(B){h[B]&&(p[B]=function(T){return new Promise(function(R,$){y.push([B,T,R,$])>1||w(B,T)})})}function w(B,T){try{!function(B){B.value instanceof W?Promise.resolve(B.value.v).then(m,A):U(y[0][2],B)}(h[B](T))}catch(R){U(y[0][3],R)}}function m(B){w("next",B)}function A(B){w("throw",B)}function U(B,T){B(T),y.shift(),y.length&&w(y[0][0],y[0][1])}}function he(v){var f,u;return f={},h("next"),h("throw",function(p){throw p}),h("return"),f[Symbol.iterator]=function(){return this},f;function h(p,y){f[p]=v[p]?function(g){return(u=!u)?{value:W(v[p](g)),done:"return"===p}:y?y(g):g}:y}}function Ne(v){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var u,f=v[Symbol.asyncIterator];return f?f.call(v):(v=M(v),u={},h("next"),h("throw"),h("return"),u[Symbol.asyncIterator]=function(){return this},u);function h(y){u[y]=v[y]&&function(g){return new Promise(function(w,D){!function(y,g,w,D){Promise.resolve(D).then(function(m){y({value:m,done:w})},g)}(w,D,(g=v[y](g)).done,g.value)})}}}function Te(v,f){return Object.defineProperty?Object.defineProperty(v,"raw",{value:f}):v.raw=f,v}function be(v){if(v&&v.__esModule)return v;var f={};if(null!=v)for(var u in v)Object.hasOwnProperty.call(v,u)&&(f[u]=v[u]);return f.default=v,f}function _e(v){return v&&v.__esModule?v:{default:v}}function b(v,f){if(!f.has(v))throw new TypeError("attempted to get private field on non-instance");return f.get(v)}function k(v,f,u){if(!f.has(v))throw new TypeError("attempted to set private field on non-instance");return f.set(v,u),u}}}]);