@knapsack/app
Version:
Build Design Systems on top of knapsack, by Basalt
2 lines • 71.6 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([["vendors~App-7KZ9F~ae3dbdae"],{"../node_modules/@aws-amplify/interactions/lib-esm/index.js":function(e,t,n){var r,o=n("../node_modules/@aws-amplify/core/lib-esm/index.js"),__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},i=new o.c("AbstractInteractionsProvider"),s=function(){function AbstractInteractionsProvider(e){void 0===e&&(e={}),this._config=e}return AbstractInteractionsProvider.prototype.configure=function(e){return void 0===e&&(e={}),this._config=__assign(__assign({},this._config),e),i.debug("configure "+this.getProviderName(),this._config),this.options},AbstractInteractionsProvider.prototype.getCategory=function(){return"Interactions"},Object.defineProperty(AbstractInteractionsProvider.prototype,"options",{get:function(){return __assign({},this._config)},enumerable:!0,configurable:!0}),AbstractInteractionsProvider}(),c=n("../node_modules/aws-sdk/clients/lexruntime.js"),a=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),__awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},__generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},u=new o.c("AWSLexProvider"),l=function(e){function AWSLexProvider(t){void 0===t&&(t={});var n=e.call(this,t)||this;return n.aws_lex=new c({region:n._config.region}),n._botsCompleteCallback={},n}return a(AWSLexProvider,e),AWSLexProvider.prototype.getProviderName=function(){return"AWSLexProvider"},AWSLexProvider.prototype.responseCallback=function(e,t,n,r,o){var i=this;e?r(e):(u.debug("postContent state",t.dialogState),"ReadyForFulfillment"!==t.dialogState&&"Fulfilled"!==t.dialogState||("function"==typeof this._botsCompleteCallback[o]&&setTimeout((function(){return i._botsCompleteCallback[o](null,{slots:t.slots})}),0),this._config&&"function"==typeof this._config[o].onComplete&&setTimeout((function(){return i._config[o].onComplete(null,{slots:t.slots})}),0)),n(t),"Failed"===t.dialogState&&("function"==typeof this._botsCompleteCallback[o]&&setTimeout((function(){return i._botsCompleteCallback[o]("Bot conversation failed")}),0),this._config&&"function"==typeof this._config[o].onComplete&&setTimeout((function(){return i._config[o].onComplete("Bot conversation failed")}),0)))},AWSLexProvider.prototype.sendMessage=function(e,t){var n=this;return new Promise((function(r,i){return __awaiter(n,void 0,void 0,(function(){var n,s,a=this;return __generator(this,(function(l){switch(l.label){case 0:return this._config[e]?[4,o.e.get()]:[2,i("Bot "+e+" does not exist")];case 1:return(n=l.sent())?(o.a.config.update({credentials:n}),this.aws_lex=new c({region:this._config[e].region,credentials:n}),"string"==typeof t?(s={botAlias:this._config[e].alias,botName:e,inputText:t,userId:n.identityId},u.debug("postText to lex",t),this.aws_lex.postText(s,(function(t,n){a.responseCallback(t,n,r,i,e)}))):(s="voice"===t.options.messageType?{botAlias:this._config[e].alias,botName:e,contentType:"audio/x-l16; sample-rate=16000",inputStream:t.content,userId:n.identityId,accept:"audio/mpeg"}:{botAlias:this._config[e].alias,botName:e,contentType:"text/plain; charset=utf-8",inputStream:t.content,userId:n.identityId,accept:"audio/mpeg"},u.debug("postContent to lex",t),this.aws_lex.postContent(s,(function(t,n){a.responseCallback(t,n,r,i,e)}))),[2]):[2,i("No credentials")]}}))}))}))},AWSLexProvider.prototype.onComplete=function(e,t){if(!this._config[e])throw new ErrorEvent("Bot "+e+" does not exist");this._botsCompleteCallback[e]=t},AWSLexProvider}(s),Interactions_assign=function(){return(Interactions_assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Interactions_awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},Interactions_generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},d=new o.c("Interactions"),p=function(){function Interactions(e){this._options=e,d.debug("Interactions Options",this._options),this._pluggables={}}return Interactions.prototype.getModuleName=function(){return"Interactions"},Interactions.prototype.configure=function(e){var t=this,n=e?e.Interactions||e:{};d.debug("configure Interactions",{opt:n}),this._options=Interactions_assign(Interactions_assign({bots:{}},n),n.Interactions);var r=this._options.aws_bots_config,o=this._options.bots;return!Object.keys(o).length&&r&&Array.isArray(r)&&r.forEach((function(e){t._options.bots[e.name]=e})),!this._pluggables.AWSLexProvider&&o&&Object.keys(o).map((function(e){return o[e]})).find((function(e){return!e.providerName||"AWSLexProvider"===e.providerName}))&&(this._pluggables.AWSLexProvider=new l),Object.keys(this._pluggables).map((function(e){t._pluggables[e].configure(t._options.bots)})),this._options},Interactions.prototype.addPluggable=function(e){if(e&&"Interactions"===e.getCategory()){if(this._pluggables[e.getProviderName()])throw new Error("Bot "+e.getProviderName()+" already plugged");return e.configure(this._options.bots),void(this._pluggables[e.getProviderName()]=e)}},Interactions.prototype.send=function(e,t){return Interactions_awaiter(this,void 0,void 0,(function(){var n;return Interactions_generator(this,(function(r){switch(r.label){case 0:if(!this._options.bots||!this._options.bots[e])throw new Error("Bot "+e+" does not exist");if(n=this._options.bots[e].providerName||"AWSLexProvider",!this._pluggables[n])throw new Error("Bot "+n+" does not have valid pluggin did you try addPluggable first?");return[4,this._pluggables[n].sendMessage(e,t)];case 1:return[2,r.sent()]}}))}))},Interactions.prototype.onComplete=function(e,t){if(!this._options.bots||!this._options.bots[e])throw new Error("Bot "+e+" does not exist");var n=this._options.bots[e].providerName||"AWSLexProvider";if(!this._pluggables[n])throw new Error("Bot "+n+" does not have valid pluggin did you try addPluggable first?");this._pluggables[n].onComplete(e,t)},Interactions}(),f=new o.c("Interactions"),v=null;v||(f.debug("Create Interactions Instance"),v=new p(null));var b=v;o.o.register(b);t.a=b},"../node_modules/@aws-amplify/predictions/lib-esm/Providers/AmazonAIConvertPredictionsProvider.js":function(e,t,n){(function(e){var r,o=n("../node_modules/@aws-amplify/predictions/lib-esm/types/Providers/AbstractConvertPredictionsProvider.js"),i=n("../node_modules/aws-sdk/clients/translate.js"),s=n("../node_modules/aws-sdk/clients/polly.js"),c=n("../node_modules/@aws-amplify/predictions/lib-esm/types/index.js"),a=n("../node_modules/@aws-amplify/core/lib-esm/index.js"),u=n("../node_modules/@aws-sdk/eventstream-marshaller/build/index.js"),l=n("../node_modules/@aws-sdk/util-utf8-node/build/index.js"),d=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),__awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},__generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},p=new a.c("AmazonAIConvertPredictionsProvider"),f=new u.EventStreamMarshaller(l.toUtf8,l.fromUtf8),v=function(t){function AmazonAIConvertPredictionsProvider(){var e=t.call(this)||this;return e.inputSampleRate=44100,e.outputSampleRate=16e3,e}return d(AmazonAIConvertPredictionsProvider,t),AmazonAIConvertPredictionsProvider.prototype.getProviderName=function(){return"AmazonAIConvertPredictionsProvider"},AmazonAIConvertPredictionsProvider.prototype.translateText=function(e){var t=this;return p.debug("Starting translation"),new Promise((function(n,r){return __awaiter(t,void 0,void 0,(function(){var t,o,s,c,u,l,d,f,v,b,y,h,g;return __generator(this,(function(m){switch(m.label){case 0:return t=this._config.translateText,s=(o=void 0===t?{}:t).defaults,u=(c=void 0===s?{}:s).sourceLanguage,l=void 0===u?"":u,d=c.targetLanguage,f=void 0===d?"":d,v=o.region,(b=void 0===v?"":v)?[4,a.e.get()]:[2,r("region not configured for transcription")];case 1:return(y=m.sent())?(h=e.translateText.source.language||l,g=e.translateText.targetLanguage||f,h&&g?(this.translate=new i({region:b,credentials:y}),this.translate.translateText({SourceLanguageCode:h,TargetLanguageCode:g,Text:e.translateText.source.text},(function(e,t){return p.debug({err:e,data:t}),e?r(e):n({text:t.TranslatedText,language:t.TargetLanguageCode})})),[2]):[2,r("Please provide both source and target language")]):[2,r("No credentials")]}}))}))}))},AmazonAIConvertPredictionsProvider.prototype.convertTextToSpeech=function(e){var t=this;return new Promise((function(n,r){return __awaiter(t,void 0,void 0,(function(){var t,o,i,c,u,l,d,p,f;return __generator(this,(function(v){switch(v.label){case 0:return[4,a.e.get()];case 1:return(t=v.sent())?(o=this._config.speechGenerator,c=(i=void 0===o?{}:o).defaults,u=(void 0===c?{}:c).VoiceId,l=void 0===u?"":u,d=i.region,p=void 0===d?"":d,e.textToSpeech.source?(f=e.textToSpeech.voiceId||l,p?f?(this.textToSpeech=new s({region:p,credentials:t}),this.textToSpeech.synthesizeSpeech({OutputFormat:"mp3",Text:e.textToSpeech.source.text,VoiceId:f,TextType:"text",SampleRate:"24000"},(function(t,o){if(t)r(t);else{var i=new Blob([o.AudioStream],{type:o.ContentType}),s=URL.createObjectURL(i);n({speech:{url:s},audioStream:o.AudioStream.buffer,text:e.textToSpeech.source.text})}})),[2]):[2,r("VoiceId was undefined.")]:[2,r("Region was undefined. Did you enable speech generator using amplify CLI?")]):[2,r("Source needs to be provided in the input")]):[2,r("No credentials")]}}))}))}))},AmazonAIConvertPredictionsProvider.prototype.convertSpeechToText=function(e){var t=this;return new Promise((function(n,r){return __awaiter(t,void 0,void 0,(function(){var t,o,i,s,u,l,d,f,v,b,y,h,g,m,P,_;return __generator(this,(function(w){switch(w.label){case 0:return w.trys.push([0,7,,8]),p.debug("starting transcription.."),[4,a.e.get()];case 1:return(t=w.sent())?(o=this._config.transcription,s=(i=void 0===o?{}:o).defaults,u=(void 0===s?{}:s).language,l=void 0===u?"":u,d=i.region,(f=void 0===d?"":d)?l?(v=e.transcription,b=v.source,y=v.language,h=void 0===y?l:y,Object(c.b)(b)?[4,this.openConnectionWithTranscribe({credentials:t,region:f,languageCode:h})]:[3,6]):[2,r("languageCode not configured or provided for transcription")]:[2,r("region not configured for transcription")]):[2,r("No credentials")];case 2:g=w.sent(),w.label=3;case 3:return w.trys.push([3,5,,6]),[4,this.sendDataToTranscribe({connection:g,raw:b.bytes})];case 4:return m=w.sent(),[2,n({transcription:{fullText:m}})];case 5:return P=w.sent(),r(P),[3,6];case 6:return[2,r("Source types other than byte source are not supported.")];case 7:return _=w.sent(),[2,r(_.name+": "+_.message)];case 8:return[2]}}))}))}))},AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe=function(t){var n="",r=f.unmarshall(e.from(t.data)),o=JSON.parse(String.fromCharCode.apply(String,r.body));if("exception"===r.headers[":message-type"].value)throw p.debug("exception",JSON.stringify(o.Message,null,2)),new Error(o.Message);return"event"===r.headers[":message-type"].value&&o.Transcript.Results.length>0&&o.Transcript.Results[0].Alternatives.length>0&&o.Transcript.Results[0].Alternatives[0].Transcript.length>0&&(!1===o.Transcript.Results[0].IsPartial?(n=o.Transcript.Results[0].Alternatives[0].Transcript+"\n",p.debug({decodedMessage:n})):p.debug({transcript:o.Transcript.Results[0].Alternatives[0]})),n},AmazonAIConvertPredictionsProvider.prototype.sendDataToTranscribe=function(t){var n=this,r=t.connection,o=t.raw;return new Promise((function(t,i){var s="";if(r.onmessage=function(e){try{var t=AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe(e);t&&(s+=t+" ")}catch(e){p.debug(e),i(e.message)}},r.onerror=function(e){p.debug({errorEvent:e}),i("failed to transcribe, network error")},r.onclose=function(e){return p.debug({closeEvent:e}),t(s.trim())},p.debug({raw:o}),Array.isArray(o))for(var c=0;c<o.length-1023;c+=1024){var a=o.slice(c,c+1024);n.sendEncodedDataToTranscribe(r,a)}var u=n.getAudioEventMessage(e.from([])),l=f.marshall(u);r.send(l)}))},AmazonAIConvertPredictionsProvider.prototype.sendEncodedDataToTranscribe=function(t,n){var r=this.downsampleBuffer({buffer:n}),o=this.pcmEncode(r),i=this.getAudioEventMessage(e.from(o)),s=f.marshall(i);t.send(s)},AmazonAIConvertPredictionsProvider.prototype.getAudioEventMessage=function(e){return{body:e,headers:{":message-type":{type:"string",value:"event"},":event-type":{type:"string",value:"AudioEvent"}}}},AmazonAIConvertPredictionsProvider.prototype.pcmEncode=function(e){for(var t=0,n=new ArrayBuffer(2*e.length),r=new DataView(n),o=0;o<e.length;o++,t+=2){var i=Math.max(-1,Math.min(1,e[o]));r.setInt16(t,i<0?32768*i:32767*i,!0)}return n},AmazonAIConvertPredictionsProvider.prototype.downsampleBuffer=function(e){var t=e.buffer;if(this.outputSampleRate===this.inputSampleRate)return t;for(var n=this.inputSampleRate/this.outputSampleRate,r=Math.round(t.length/n),o=new Float32Array(r),i=0,s=0;i<o.length;){for(var c=Math.round((i+1)*n),a=0,u=0,l=s;l<c&&l<t.length;l++)a+=t[l],u++;o[i]=a/u,i++,s=c}return o},AmazonAIConvertPredictionsProvider.prototype.openConnectionWithTranscribe=function(e){var t=this,n=e.credentials,r=e.region,o=e.languageCode;return new Promise((function(e,i){return __awaiter(t,void 0,void 0,(function(){var t,i,s,c,a,u;return __generator(this,(function(l){return t=n.accessKeyId,i=n.secretAccessKey,s=n.sessionToken,c={access_key:t,secret_key:i,session_token:s},a=this.generateTranscribeUrl({credentials:c,region:r,languageCode:o}),p.debug("connecting..."),(u=new WebSocket(a)).binaryType="arraybuffer",u.onopen=function(){p.debug("connected"),e(u)},[2]}))}))}))},AmazonAIConvertPredictionsProvider.prototype.generateTranscribeUrl=function(e){var t=e.credentials,n=e.region,r=["wss://transcribestreaming."+n+".amazonaws.com:8443","/stream-transcription-websocket?","media-encoding=pcm&","sample-rate=16000&","language-code="+e.languageCode].join("");return a.m.signUrl(r,t,{region:n,service:"transcribe"},300)},AmazonAIConvertPredictionsProvider}(o.a);t.a=v}).call(this,n("../node_modules/node-libs-browser/node_modules/buffer/index.js").Buffer)},"../node_modules/@aws-amplify/predictions/lib-esm/index.js":function(e,t,n){var r=n("../node_modules/@aws-amplify/core/lib-esm/index.js"),__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},__spreadArrays=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,c=i.length;s<c;s++,o++)r[o]=i[s];return r},o=new r.c("Predictions"),i=function(){function Predictions(e){this._options=e,this._convertPluggables=[],this._identifyPluggables=[],this._interpretPluggables=[]}return Predictions.prototype.getModuleName=function(){return"Predictions"},Predictions.prototype.addPluggable=function(e){if(this.getPluggable(e.getProviderName()))throw new Error("Pluggable with name "+e.getProviderName()+" has already been added.");var t=!1;this.implementsConvertPluggable(e)&&(this._convertPluggables.push(e),t=!0),this.implementsIdentifyPluggable(e)&&(this._identifyPluggables.push(e),t=!0),this.implementsInterpretPluggable(e)&&(this._interpretPluggables.push(e),t=!0),t&&this.configurePluggable(e)},Predictions.prototype.getPluggable=function(e){var t=this.getAllProviders().find((function(t){return t.getProviderName()===e}));return void 0===t?(o.debug("No plugin found with providerName=>",e),null):t},Predictions.prototype.removePluggable=function(e){this._convertPluggables=this._convertPluggables.filter((function(t){return t.getProviderName()!==e})),this._identifyPluggables=this._identifyPluggables.filter((function(t){return t.getProviderName()!==e})),this._interpretPluggables=this._interpretPluggables.filter((function(t){return t.getProviderName()!==e}))},Predictions.prototype.configure=function(e){var t=this,n=e?e.predictions||e:{};n=__assign(__assign({},n),e),this._options=Object.assign({},this._options,n),o.debug("configure Predictions",this._options),this.getAllProviders().forEach((function(e){return t.configurePluggable(e)}))},Predictions.prototype.interpret=function(e,t){return this.getPluggableToExecute(this._interpretPluggables,t).interpret(e)},Predictions.prototype.convert=function(e,t){return this.getPluggableToExecute(this._convertPluggables,t).convert(e)},Predictions.prototype.identify=function(e,t){return this.getPluggableToExecute(this._identifyPluggables,t).identify(e)},Predictions.prototype.getPluggableToExecute=function(e,t){if(t&&t.providerName)return __spreadArrays(e).find((function(e){return e.getProviderName()===t.providerName}));if(1===e.length)return e[0];throw new Error("More than one or no providers are configured, Either specify a provider name or configure exactly one provider")},Predictions.prototype.getAllProviders=function(){return __spreadArrays(this._convertPluggables,this._identifyPluggables,this._interpretPluggables)},Predictions.prototype.configurePluggable=function(e){var t=Object.assign({},this._options.predictions,this._options[e.getCategory().toLowerCase()]);e.configure(t)},Predictions.prototype.implementsConvertPluggable=function(e){return e&&"function"==typeof e.convert},Predictions.prototype.implementsIdentifyPluggable=function(e){return e&&"function"==typeof e.identify},Predictions.prototype.implementsInterpretPluggable=function(e){return e&&"function"==typeof e.interpret},Predictions}(),s=n("../node_modules/@aws-amplify/predictions/lib-esm/Providers/AmazonAIConvertPredictionsProvider.js"),c=n("../node_modules/@aws-amplify/storage/lib-esm/index.js"),a=n("../node_modules/@aws-amplify/predictions/lib-esm/types/Providers/index.js"),u=n("../node_modules/aws-sdk/clients/rekognition.js"),l=n("../node_modules/@aws-amplify/predictions/lib-esm/types/index.js"),d=n("../node_modules/aws-sdk/clients/textract.js");function makeCamelCase(e,t){if(e){var n={};return(t||Object.keys(e)).forEach((function(t){var r;if(e.hasOwnProperty(t)){var o=t.charAt(0).toLowerCase()+t.substr(1);Object.assign(n,((r={})[o]=e[t],r))}})),n}}function makeCamelCaseArray(e,t){if(e)return e.map((function(e){return makeCamelCase(e,t)}))}function blobToArrayBuffer(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(e){t(r.result)},r.onerror=function(e){n(e)};try{r.readAsArrayBuffer(e)}catch(e){n(e)}}))}function getBoundingBox(e){if(e)return makeCamelCase(e.BoundingBox)}function getPolygon(e){if(e)return makeCamelCaseArray(e.Polygon)}function categorizeTextractBlocks(e){var t={text:{fullText:"",words:[],lines:[],linesDetailed:[]}};if(0===e.length)return t;var n=Array(),r=Array(),o={};if(e.forEach((function(e){switch(e.BlockType){case"LINE":t.text.lines.push(e.Text),t.text.linesDetailed.push({text:e.Text,polygon:getPolygon(e.Geometry),boundingBox:getBoundingBox(e.Geometry),page:e.Page});break;case"WORD":t.text.fullText+=e.Text+" ",t.text.words.push({text:e.Text,polygon:getPolygon(e.Geometry),boundingBox:getBoundingBox(e.Geometry)}),o[e.Id]=e;break;case"SELECTION_ELEMENT":var i="SELECTED"===e.SelectionStatus;t.text.selections||(t.text.selections=[]),t.text.selections.push({selected:i,polygon:getPolygon(e.Geometry),boundingBox:getBoundingBox(e.Geometry)}),o[e.Id]=e;break;case"TABLE":n.push(e);break;case"KEY_VALUE_SET":r.push(e),o[e.Id]=e;break;default:o[e.Id]=e}})),t.text.fullText=t.text.fullText.substr(0,t.text.fullText.length-1),0!==n.length){var i=Array();n.forEach((function(e){i.push(function constructTable(e,t){var n;n=[],e.Relationships.forEach((function(e){e.Ids.forEach((function(e){var r=t[e],o=r.RowIndex-1,i=r.ColumnIndex-1,s=extractContentsFromBlock(r,t),c={text:s.text,boundingBox:getBoundingBox(r.Geometry),polygon:getPolygon(r.Geometry),selected:s.selected,rowSpan:r.RowSpan,columnSpan:r.ColumnSpan};n[o]||(n[o]=[]),n[o][i]=c}))}));var r=n.length,o=n[0].length;return{size:{rows:r,columns:o},table:n,boundingBox:getBoundingBox(e.Geometry),polygon:getPolygon(e.Geometry)}}(e,o))})),t.text.tables=i}if(0!==r.length){var s=Array();r.forEach((function(e){-1!==e.EntityTypes.indexOf("KEY")&&s.push(function constructKeyValue(e,t){var n,r="",o="";return e.Relationships.forEach((function(i){if("CHILD"===i.Type){var s=extractContentsFromBlock(e,t);r=s.text}else"VALUE"===i.Type&&i.Ids.forEach((function(e){var r=extractContentsFromBlock(t[e],t);o=r.text,null!=r.selected&&(n=r.selected)}))})),{key:r,value:{text:o,selected:n},polygon:getPolygon(e.Geometry),boundingBox:getBoundingBox(e.Geometry)}}(e,o))})),t.text.keyValues=s}return t}function extractContentsFromBlock(e,t){var n,r="";return e.Relationships?(e.Relationships.forEach((function(e){e.Ids.forEach((function(e){var o=t[e];"WORD"===o.BlockType?r+=o.Text+" ":"SELECTION_ELEMENT"===o.BlockType&&(n="SELECTED"===o.SelectionStatus)}))})),{text:r=r.substr(0,r.length-1),selected:n}):{text:"",selected:void 0}}var p,f=(p=function(e,t){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function __(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),AmazonAIIdentifyPredictionsProvider_assign=function(){return(AmazonAIIdentifyPredictionsProvider_assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},__awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},__generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},v=function(e){function AmazonAIIdentifyPredictionsProvider(){return e.call(this)||this}return f(AmazonAIIdentifyPredictionsProvider,e),AmazonAIIdentifyPredictionsProvider.prototype.getProviderName=function(){return"AmazonAIIdentifyPredictionsProvider"},AmazonAIIdentifyPredictionsProvider.prototype.configureSource=function(e){return new Promise((function(t,n){if(Object(l.f)(e)){var r={level:e.level,identityId:e.identityId};c.a.get(e.key,r).then((function(e){var r=e.match(/https:\/\/([a-zA-Z0-9%-_.]+)\.s3\.[A-Za-z0-9%-._~]+\/([a-zA-Z0-9%-._~/]+)\?/);r.length<3&&n("Invalid S3 key was given."),t({S3Object:{Bucket:r[1],Name:r[2]}})})).catch((function(e){return n(e)}))}else if(Object(l.c)(e))blobToArrayBuffer(e.file).then((function(e){t({Bytes:e})})).catch((function(e){return n(e)}));else if(Object(l.b)(e)){var o=e.bytes;o instanceof Blob&&blobToArrayBuffer(o).then((function(e){t({Bytes:e})})).catch((function(e){return n(e)})),t({Bytes:o})}else n("Input source is not configured correctly.")}))},AmazonAIIdentifyPredictionsProvider.prototype.identifyText=function(e){var t=this;return new Promise((function(n,o){return __awaiter(t,void 0,void 0,(function(){var t,i,s,c,a,l,p,f,v,b,y,h,g,m,P=this;return __generator(this,(function(_){switch(_.label){case 0:return[4,r.e.get()];case 1:return(t=_.sent())?(i=this._config.identifyText,c=(s=void 0===i?{}:i).region,a=void 0===c?"":c,l=s.defaults,p=(void 0===l?{}:l).format,f=void 0===p?"PLAIN":p,this.rekognition=new u({region:a,credentials:t}),this.textract=new d({region:a,credentials:t}),[4,this.configureSource(e.text.source).then((function(e){return v=e})).catch((function(e){o(e)}))]):[2,o("No credentials")];case 2:return _.sent(),b=e.text.format||f,y=[],"FORM"!==b&&"ALL"!==b||y.push("FORMS"),"TABLE"!==b&&"ALL"!==b||y.push("TABLES"),0===y.length?(h={Document:v},g={Image:v},this.rekognition.detectText(g,(function(e,t){if(e)return o(e);var r=function categorizeRekognitionBlocks(e){var t={text:{fullText:"",words:[],lines:[],linesDetailed:[]}};return e.forEach((function(e){switch(e.Type){case"LINE":t.text.lines.push(e.DetectedText),t.text.linesDetailed.push({text:e.DetectedText,polygon:getPolygon(e.Geometry),boundingBox:getBoundingBox(e.Geometry),page:null});break;case"WORD":t.text.fullText+=e.DetectedText+" ",t.text.words.push({text:e.DetectedText,polygon:getPolygon(e.Geometry),boundingBox:getBoundingBox(e.Geometry)})}})),t.text.fullText=t.text.fullText.substr(0,t.text.fullText.length-1),t}(t.TextDetections);if(r.text.words.length<50)return n(r);P.textract.detectDocumentText(h,(function(e,i){return e?o(e):t.TextDetections.length>i.Blocks.length?n(r):n(categorizeTextractBlocks(i.Blocks))}))}))):(m={Document:v,FeatureTypes:y},this.textract.analyzeDocument(m,(function(e,t){if(e)return o(e);var r=t.Blocks;n(categorizeTextractBlocks(r))}))),[2]}}))}))}))},AmazonAIIdentifyPredictionsProvider.prototype.identifyLabels=function(e){var t=this;return new Promise((function(n,o){return __awaiter(t,void 0,void 0,(function(){var t,i,s,c,a,l,d,p,f,v,b,y;return __generator(this,(function(h){switch(h.label){case 0:return[4,r.e.get()];case 1:return(t=h.sent())?(i=this._config.identifyLabels,c=(s=void 0===i?{}:i).region,a=void 0===c?"":c,l=s.defaults,d=(void 0===l?{}:l).type,p=void 0===d?"LABELS":d,this.rekognition=new u({region:a,credentials:t}),[4,this.configureSource(e.labels.source).then((function(e){f=e})).catch((function(e){return o(e)}))]):[2,o("No credentials")];case 2:return h.sent(),v={Image:f},b=[],"LABELS"!==(y=e.labels.type||p)&&"ALL"!==y||b.push(this.detectLabels(v)),"UNSAFE"!==y&&"ALL"!==y||b.push(this.detectModerationLabels(v)),Promise.all(b).then((function(e){var t={};e.forEach((function(e){t=AmazonAIIdentifyPredictionsProvider_assign(AmazonAIIdentifyPredictionsProvider_assign({},t),e)})),n(t)})).catch((function(e){return o(e)})),[2]}}))}))}))},AmazonAIIdentifyPredictionsProvider.prototype.detectLabels=function(e){var t=this;return new Promise((function(n,r){t.rekognition.detectLabels(e,(function(e,t){if(e)return r(e);if(!t.Labels)return n({labels:null});var o=t.Labels.map((function(e){var t=e.Instances?e.Instances.map((function(e){return makeCamelCase(e.BoundingBox)})):void 0;return{name:e.Name,boundingBoxes:t,metadata:{confidence:e.Confidence,parents:makeCamelCaseArray(e.Parents)}}}));return n({labels:o})}))}))},AmazonAIIdentifyPredictionsProvider.prototype.detectModerationLabels=function(e){var t=this;return new Promise((function(n,r){t.rekognition.detectModerationLabels(e,(function(e,t){return e?r(e):0!==t.ModerationLabels.length?n({unsafe:"YES"}):n({unsafe:"NO"})}))}))},AmazonAIIdentifyPredictionsProvider.prototype.identifyEntities=function(e){var t=this;return new Promise((function(n,o){return __awaiter(t,void 0,void 0,(function(){var t,i,s,c,a,d,p,f,v,b,y,h,g,m,P,_,w,A,x,I,S,T=this;return __generator(this,(function(C){switch(C.label){case 0:return[4,r.e.get()];case 1:return(t=C.sent())?(i=this._config.identifyEntities,c=(s=void 0===i?{}:i).region,a=void 0===c?"":c,d=s.celebrityDetectionEnabled,p=void 0!==d&&d,f=s.defaults,b=(v=void 0===f?{}:f).collectionId,y=void 0===b?"":b,h=v.maxEntities,g=void 0===h?50:h,this.rekognition=new u({region:a,credentials:t}),[4,this.configureSource(e.entities.source).then((function(e){return m=e})).catch((function(e){return o(e)}))]):[2,o("No credentials")];case 2:if(C.sent(),P={Image:m},Object(l.d)(e.entities)&&e.entities.celebrityDetection){if(!p)return[2,o("Error: You have to enable celebrity detection first")];this.rekognition.recognizeCelebrities(P,(function(e,t){if(e)return o(e);var r=t.CelebrityFaces.map((function(e){return{boundingBox:makeCamelCase(e.Face.BoundingBox),landmarks:makeCamelCaseArray(e.Face.Landmarks),metadata:AmazonAIIdentifyPredictionsProvider_assign(AmazonAIIdentifyPredictionsProvider_assign({},makeCamelCase(e,["Id","Name","Urls"])),{pose:makeCamelCase(e.Face.Pose)})}}));n({entities:r})}))}else Object(l.e)(e.entities)&&e.entities.collection?(_=e.entities,w=_.collectionId,A=void 0===w?y:w,x=_.maxEntities,I=void 0===x?g:x,S=AmazonAIIdentifyPredictionsProvider_assign(AmazonAIIdentifyPredictionsProvider_assign({},P),{CollectionId:A,MaxFaces:I}),this.rekognition.searchFacesByImage(S,(function(e,t){if(e)return o(e);var r=t.FaceMatches.map((function(e){return{boundingBox:makeCamelCase(e.Face.BoundingBox),metadata:{externalImageId:T.decodeExternalImageId(e.Face.ExternalImageId),similarity:e.Similarity}}}));n({entities:r})}))):this.rekognition.detectFaces(P,(function(e,t){if(e)return o(e);var r=t.FaceDetails.map((function(e){var t=["Smile","Eyeglasses","Sunglasses","Gender","Beard","Mustache","EyesOpen","MouthOpen"],n=makeCamelCase(e,t);return e.Emotions&&(n.emotions=e.Emotions.map((function(e){return e.Type}))),{boundingBox:makeCamelCase(e.BoundingBox),landmarks:makeCamelCaseArray(e.Landmarks),ageRange:makeCamelCase(e.AgeRange),attributes:makeCamelCase(e,t),metadata:{confidence:e.Confidence,pose:makeCamelCase(e.Pose)}}}));n({entities:r})}));return[2]}}))}))}))},AmazonAIIdentifyPredictionsProvider.prototype.decodeExternalImageId=function(e){return(""+e).replace(/::/g,"/")},AmazonAIIdentifyPredictionsProvider}(a.a),b=n("../node_modules/aws-sdk/lib/browser.js"),y=function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};return function(e,t){function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),AmazonAIInterpretPredictionsProvider_awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},AmazonAIInterpretPredictionsProvider_generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},h=function(e){function AmazonAIInterpretPredictionsProvider(){return e.call(this)||this}return y(AmazonAIInterpretPredictionsProvider,e),AmazonAIInterpretPredictionsProvider.prototype.getProviderName=function(){return"AmazonAIInterpretPredictionsProvider"},AmazonAIInterpretPredictionsProvider.prototype.interpretText=function(e){var t=this;return new Promise((function(n,o){return AmazonAIInterpretPredictionsProvider_awaiter(t,void 0,void 0,(function(){var t,i,s,c,a,u,d,p,f,v,y,h,g,m,P,_,w,A,x,I,S,T,C,O,E,j,k,L,B,N,z,M,W,D,F,R,G,q;return AmazonAIInterpretPredictionsProvider_generator(this,(function(U){switch(U.label){case 0:return[4,r.e.get()];case 1:return(t=U.sent())?(i=this._config.interpretText,c=(s=void 0===i?{}:i).region,a=void 0===c?"":c,u=s.defaults,d=(void 0===u?{}:u).type,p=void 0===d?"":d,f=e.text,y=(v=void 0===f?{}:f).source,h=(void 0===y?{}:y).text,g=void 0===h?"":h,m=v.type,P=void 0===m?p:m,_=e.text,w=(void 0===_?{}:_).source,A=(void 0===w?{}:w).language,x=void 0===A?void 0:A,I=new b.Comprehend({credentials:t,region:a}),((S=P===l.a.ALL)||P===l.a.LANGUAGE)&&(C={Text:g},T=this.detectLanguage(C,I)),S||P===l.a.ENTITIES?(E=x)?[3,3]:[4,T]:[3,4]):[2,o("No credentials")];case 2:E=U.sent(),U.label=3;case 3:if(!(D=E))return[2,o("language code is required on source for this selection")];j={Text:g,LanguageCode:D},O=this.detectEntities(j,I),U.label=4;case 4:return S||P===l.a.SENTIMENT?(L=x)?[3,6]:[4,T]:[3,7];case 5:L=U.sent(),U.label=6;case 6:if(!(D=L))return[2,o("language code is required on source for this selection")];B={Text:g,LanguageCode:D},k=this.detectSentiment(B,I),U.label=7;case 7:return S||P===l.a.SYNTAX?(z=x)?[3,9]:[4,T]:[3,10];case 8:z=U.sent(),U.label=9;case 9:if(!(D=z))return[2,o("language code is required on source for this selection")];M={Text:g,LanguageCode:D},N=this.detectSyntax(M,I),U.label=10;case 10:return S||P===l.a.KEY_PHRASES?(F=x)?[3,12]:[4,T]:[3,13];case 11:F=U.sent(),U.label=12;case 12:if(!(D=F))return[2,o("language code is required on source for this selection")];R={Text:g,LanguageCode:D},W=this.detectKeyPhrases(R,I),U.label=13;case 13:return U.trys.push([13,15,,16]),[4,Promise.all([T,O,k,N,W])];case 14:return G=U.sent(),n({textInterpretation:{keyPhrases:G[4]||[],language:G[0]||"",sentiment:G[2],syntax:G[3]||[],textEntities:G[1]||[]}}),[3,16];case 15:return q=U.sent(),o(q),[3,16];case 16:return[2]}}))}))}))},AmazonAIInterpretPredictionsProvider.prototype.detectKeyPhrases=function(e,t){return new Promise((function(n,r){t.detectKeyPhrases(e,(function(e,t){var o=(t||{}).KeyPhrases,i=void 0===o?[]:o;e?"AccessDeniedException"===e.code?r("Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: amplify predictions add"):r(e.message):n(i.map((function(e){return{text:e.Text}})))}))}))},AmazonAIInterpretPredictionsProvider.prototype.detectSyntax=function(e,t){var n=this;return new Promise((function(r,o){t.detectSyntax(e,(function(e,t){var i=(t||{}).SyntaxTokens,s=void 0===i?[]:i;e?"AccessDeniedException"===e.code?o("Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: amplify predictions add"):o(e.message):r(n.serializeSyntaxFromComprehend(s))}))}))},AmazonAIInterpretPredictionsProvider.prototype.serializeSyntaxFromComprehend=function(e){var t=[];return e&&Array.isArray(e)&&(t=e.map((function(e){var t=e.Text,n=void 0===t?"":t,r=e.PartOfSpeech,o=(void 0===r?{}:r).Tag;return{text:n,syntax:void 0===o?"":o}}))),t},AmazonAIInterpretPredictionsProvider.prototype.detectSentiment=function(e,t){return new Promise((function(n,r){t.detectSentiment(e,(function(e,t){if(e)"AccessDeniedException"===e.code?r("Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: amplify predictions add"):r(e.message);else{var o=t,i=o.Sentiment,s=void 0===i?"":i,c=o.SentimentScore,a=void 0===c?{}:c,u=a.Positive,l=void 0===u?0:u,d=a.Negative,p=void 0===d?0:d,f=a.Neutral,v=void 0===f?0:f,b=a.Mixed;n({predominant:s,positive:l,negative:p,neutral:v,mixed:void 0===b?0:b})}}))}))},AmazonAIInterpretPredictionsProvider.prototype.detectEntities=function(e,t){var n=this;return new Promise((function(r,o){t.detectEntities(e,(function(e,t){var i=(t||{}).Entities,s=void 0===i?[]:i;e?"AccessDeniedException"===e.code?o("Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: amplify predictions add"):o(e.message):r(n.serializeEntitiesFromComprehend(s))}))}))},AmazonAIInterpretPredictionsProvider.prototype.serializeEntitiesFromComprehend=function(e){var t=[];return e&&Array.isArray(e)&&(t=e.map((function(e){return{type:e.Type,text:e.Text}}))),t},AmazonAIInterpretPredictionsProvider.prototype.detectLanguage=function(e,t){return new Promise((function(n,r){t.detectDominantLanguage(e,(function(e,t){if(e)"AccessDeniedException"===e.code?r("Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: amplify predictions add"):r(e.message);else{var o=(t||{}).Languages;(void 0===o?[""]:o)[0].LanguageCode||r("Language not detected"),n(t.Languages[0].LanguageCode)}}))}))},AmazonAIInterpretPredictionsProvider}(a.b),g=function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};return function(e,t){function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),m=(function(e){function AmazonAIPredictionsProvider(){var t=e.call(this)||this;return t.convertProvider=new s.a,t.identifyProvider=new v,t.interpretProvider=new h,t}g(AmazonAIPredictionsProvider,e),AmazonAIPredictionsProvider.prototype.getCategory=function(){return"Predictions"},AmazonAIPredictionsProvider.prototype.getProviderName=function(){return"AmazonAIPredictionsProvider"},AmazonAIPredictionsProvider.prototype.configure=function(e){return this.convertProvider.configure(e.convert),this.identifyProvider.configure(e.identify),this.interpretProvider.configure(e.interpret),e},AmazonAIPredictionsProvider.prototype.interpret=function(e){return this.interpretProvider.interpret(e)},AmazonAIPredictionsProvider.prototype.convert=function(e){return this.convertProvider.convert(e)},AmazonAIPredictionsProvider.prototype.identify=function(e){return this.identifyProvider.identify(e)}}(a.c),new r.c("Predictions")),P=null;P||(m.debug("Create Predictions Instance"),P=new i({}));var _=P;r.o.register(_);t.a=_},"../node_modules/@aws-amplify/predictions/lib-esm/types/Predictions.js":function(e,t,n){var r;function isIdentifyFromCollection(e){return e&&(e.hasOwnProperty("collection")||e.hasOwnProperty("collectionId"))}function isIdentifyCelebrities(e){return e&&e.hasOwnProperty("celebrityDetection")}function isTranslateTextInput(e){return e&&e.hasOwnProperty("translateText")}function isTextToSpeechInput(e){return e&&e.hasOwnProperty("textToSpeech")}function isSpeechToTextInput(e){return e&&e.hasOwnProperty("transcription")}function isStorageSource(e){return e&&e.hasOwnProperty("key")}function isFileSource(e){return e&&e.hasOwnProperty("file")}function isBytesSource(e){return e&&e.hasOwnProperty("bytes")}function isIdentifyTextInput(e){return e&&e.hasOwnProperty("text")}function isIdentifyLabelsInput(e){return e&&e.hasOwnProperty("labels")}function isIdentifyEntitiesInput(e){return e&&e.hasOwnProperty("entities")}function isInterpretTextInput(e){return e&&e.hasOwnProperty("text")}n.d(t,"a",(function(){return r})),n.d(t,"f",(function(){return isIdentifyFromCollection})),n.d(t,"d",(function(){return isIdentifyCelebrities})),n.d(t,"m",(function(){return isTranslateTextInput})),n.d(t,"l",(function(){return isTextToSpeechInput})),n.d(t,"j",(function(){return isSpeechToTextInput})),n.d(t,"k",(function(){return isStorageSource})),n.d(t,"c",(function(){return isFileSource})),n.d(t,"b",(function(){return isBytesSource})),n.d(t,"h",(function(){return isIdentifyTextInput})),n.d(t,"g",(function(){return isIdentifyLabelsInput})),n.d(t,"e",(function(){return isIdentifyEntitiesInput})),n.d(t,"i",(function(){return isInterpretTextInput})),function(e){e.ALL="ALL",e.LANGUAGE="LANGUAGE",e.ENTITIES="ENTITIES",e.SENTIMENT="SENTIMENT",e.SYNTAX="SYNTAX",e.KEY_PHRASES="KEY_PHRASES"}(r||(r={}))},"../node_modules/@aws-amplify/predictions/lib-esm/types/Providers/AbstractConvertPredictionsProvider.js":function(e,t,n){n.d(t,"a",(function(){return u}));var r,o=n("../node_modules/@aws-amplify/predictions/lib-esm/types/Predictions.js"),i=n("../node_modules/@aws-amplify/predictions/lib-esm/types/Providers/index.js"),s=n("../node_modules/@aws-amplify/core/lib-esm/index.js"),c=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=new s.c("AbstractConvertPredictionsProvider"),u=function(e){function AbstractConvertPredictionsProvider(){return null!==e&&e.apply(this,arguments)||this}return c(AbstractConvertPredictionsProvider,e),AbstractConvertPredictionsProvider.prototype.getCategory=function(){return"Convert"},AbstractConvertPredictionsProvider.prototype.convert=function(e){return Object(o.m)(e)?(a.debug("translateText"),this.translateText(e)):Object(o.l)(e)?(a.debug("textToSpeech"),this.convertTextToSpeech(e)):Object(o.j)(e)?(a.debug("textToSpeech"),this.convertSpeechToText(e)):void 0},AbstractConvertPredictionsProvider.prototype.translateText=function(e){throw new Error("convertText is not implemented by this provider")},AbstractConvertPredictionsProvider.prototype.convertTextToSpeech=function(e){throw new Error("convertTextToSpeech is not implemented by this provider")},AbstractConvertPredictionsProvider.prototype.convertSpeechToText=function(e){throw new Error("convertSpeechToText is not implemented by this provider")},AbstractConvertPredictionsProvider}(i.c)},"../node_modules/@aws-amplify/predictions/lib-esm/types/Providers/index.js":function(e,t,n){n.d(t,"c",(function(){return s})),n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return p}));var r,o=n("../node_modules/@aws-amplify/core/lib-esm/index.js"),i=new o.c("Amplify"),s=function(){function AbstractPredictionsProvider(){}return AbstractPredictionsProvider.prototype.configure=function(e){return i.debug("configure AbstractPredictionsProvider",{config:e}),this._config=e,e},AbstractPredictionsProvider}(),c=(n("../node_modules/@aws-amplify/predictions/lib-esm/types/Providers/AbstractConvertPredictionsProvider.js"),n("../node_modules/@aws-amplify/predictions/lib-esm/types/Predictions.js")),a=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),u=new o.i("AbstractIdentifyPredictionsProvider"),l=function(e){function AbstractIdentifyPredictionsProvider(){return null!==e&&e.apply(this,arguments)||this}return a(AbstractIdentifyPredictionsProvider,e),AbstractIdentifyPredictionsProvider.prototype.getCategory=function(){return"Identify"},AbstractIdentifyPredictionsProvider.prototype.identify=function(e){return Object(c.h)(e)?(u.debug("identifyText"),this.identifyText(e)):Object(c.g)(e)?(u.debug("identifyLabels"),this.identifyLabels(e)):Object(c.e)(e)?(u.debug("identifyEntities"),this.identifyEntities(e)):void 0},AbstractIdentifyPredictionsProvider.prototype.identifyText=function(e){throw new Error("identifyText is not implemented by this provider.")},AbstractIdentifyPredictionsProvider.prototype.identifyLabels=function(e){throw new Error("identifyLabels is not implemented by this provider")},AbstractIdentifyPredictionsProvider.prototype.identifyEntities=function(e){throw new Error("identifyEntities is not implemented by this provider")},AbstractIdentifyPredictionsProvider}(s),d=function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};return function(e,t){function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),p=function(e){function AbstractInterpretPredictionsProvider(){return null!==e&&e.apply(this,arguments)||this}return d(AbstractInterpretPredictionsProvider,e),AbstractInterpretPredictionsProvider.prototype.getCategory=function(){return"Interpret"},AbstractInterpretPredictionsProvider.prototype.interpret=function(e){if(Object(c.i)(e))return this.interpretText(e)},AbstractInterpretPredictionsProvider.prototype.interpretText=function(e){throw new Error("interpretText is not implement by this provider")},AbstractInterpretPredictionsProvider}(s)},"../node_modules/@aws-amplify/predictions/lib-esm/types/index.js":function(e,t,n){var r=n("../node_modules/@aws-amplify/predictions/lib-esm/types/Predictions.js");n.d(t,"a",(function(){return r.a})),n.d(t,"b",(function(){return r.b})),n.d(t,"c",(function(){return r.c})),n.d(t,"d",(function(){return r.d})),n.d(t,"e",(function(){return r.f})),n.d(t,"f",(function(){return r.k}))},"../node_modules/@aws-amplify/pubsub/lib-esm/index.js":function(e,t,n){var r,o=n("../node_modules/zen-observable/index.js"),i=n("../node_modules/@aws-amplify/core/lib-esm/index.js"),s=n("../node_modules/@aws-amplify/core/lib/constants.js"),__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},c=new i.c("AbstractPubSubProvider"),a=function(){function AbstractPubSubProvider(e){void 0===e&&(e={}),this._config=e}return AbstractPubSubProvider.prototype.configure=function(e){return void 0===e&&(e={}),this._config=__assign(__assign({},e),this._config),c.debug("configure "+this.getProviderName(),this._config),this.options},AbstractPubSubProvider.prototype.getCategory=function(){return"PubSub"},Object.defineProperty(AbstractPubSubProvider.prototype,"options",{get:function(){return __assign({},this._config)},enumerable:!0,configurable:!0}),AbstractPubSubProvider}(),u=n("../node_modules/paho-mqtt/paho-mqtt.js"),l=n("../node_modules/uuid/index.js"),d=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),MqttOverWSProvider_assign=function(){return(MqttOverWSProvider_assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},__awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},__generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},__rest=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},p=new i.c("MqttOverWSProvider");var f=function(){function ClientsQueue(){this.promises=new Map}return ClientsQueue.prototype.get=function(e,t){return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(r){return(n=this.promises.get(e))?[2,n]:(n=t(e),this.promises.set(e,n),[2,n])}))}))},Object.defineProperty(ClientsQueue.prototype,"allClients",{get:function(){return Array.from(this.promises.keys())},enumerable:!0,configurable:!0}),ClientsQueue.prototype.remove=function(e){this.promises.delete(e)},ClientsQueue}(),v="undefined"!=typeof Symbol?Symbol("topic"):"@@topic",b=function(e){function MqttOverWSProvider(t){void 0===t&&(t={});var n=e.call(this,MqttOverWSProvider_assign(MqttOverWSProvider_assign({},t),{clientId:t.clientId||Object(l.v4)()}))||this;return n._clientsQueue=new f,n._topicObservers=new Map,n._clientIdObservers=new Map,n}return d(MqttOverWSProvider,e),Object.defineProperty(MqttOverWSProvider.prototype,"clientId",{get:function(){return this.options.clientId},enumerable:!0,configurable:!0}),Object.defineProperty(MqttOverWSProvider.prototype,"endpoint",{get:function(){return this.options.aws_pubsub_endpoint},enumerable:!0,configurable:!0}),Object.defineProperty(MqttOverWSProvider.prototype,"clientsQueue",{get:function(){return this._clientsQueue},enumerable:!0,configurable:!0}),Object.defineProperty(MqttOverWSProvider.prototype,"isSSLEnabled",{get:function(){return!this.options.aws_appsync_dangerously_connect_to_http_endpoint_for_testing},enumerable:!0,configurable:!0}),MqttOverWSProvider.prototype.getTopicForValue=function(e){return"object"==typeof e&&e[v]},MqttOverWSProvider.prototype.getProviderName=function(){return"MqttOverWSProvider"},MqttOverWSProvider.prototype.onDisconnect=function(e){var t=e.clientId,n=e.errorCode,r=__rest(e,["clientId","errorCode"]);0!==n&&(p.warn(t,JSON.stringify(MqttOverWSProvider_assign({errorCode:n},r),null,2)),this._topicObservers.forEach((function(e,t){e.forEach((function(e){e.error("Disconnected, error code: "+n),e.complete()}))}))),this._topicObservers=new Map},MqttOverWSProvider.prototype.newClient=function(e){var t=e.url,n=e.clientId;return __awaiter(this,void 0,void 0,(function(){var e,r=this;return __generator(this,(function(o){switch(o.label){case 0:return p.debug("Creating new MQTT client",n),(e=new u.Client(t,n)).onMessageArrived=function(e){var t=e.destinationName,n=e.payloadString;r._onMessage(t,n)},e.onConnectionLost=function(e){var t=e.errorCode,o=__rest(e,["errorCode"]);r.onDisconnect(MqttOverWSProvider_assign({clientId:n,errorCode:t},o))},[4,new Promise((function(t,n){e.connect({useSSL:r.isSSLEnabled,mqttVersion:3,onSuccess:function(){return t(e)},onFailure:n})}))];case 1:return o.sent(),[2,e]}}))}))},MqttOverWSProvider.prototype.connect=function(e,t){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,(function(){var n=this;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.clientsQueue.get(e,(function(e){return n.newClient(MqttOverWSProvider_assign(MqttOverWSProvider_assign({},t),{clientId:e}))}))];case 1:return[2,r.sent()]}}))}))},MqttOverWSProvider.prototype.disconnect=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){switch(n.label){case 0:return[4,this.clientsQueue.get(e,(function(){return null}))];case 1:return(t=n.sent())&&t.isConnected()&&t.disconnect(),this.clientsQueue.remove(e),[2]}}))}))},MqttOverWSProvider.prototype.publish=function(e,t){return __awaiter(this,void 0,void 0,(function(){var n,r,o,i;return __generator(this,(function(s){switch(s.label){case 0:return n=[].concat(e),r=JSON.stringify(t),[4,this.endpoint];case 1:return o=s.sent(),[4,this.connect(this.clientId,{url:o})];case 2:return i=s.sent(),p.debug("Publishing to topic(s)",n.join(","),r),n.forEach((function(e){return i.send(e,r)})),[2]}}))}))},MqttOverWSProvider.prototype._onMessage=function(e,t){try{var n=[];this._topicObservers.forEach((function(t,r){(function mqttTopicMatch(e,t){for(var n=e.split("/"),r=n.length,o=t.split("/"),i=0;i<r;++i){var s=n[i],c=o[i];if("#"===s)return o.length>=r;if("+"!==s&&s!==c)return!1}return r===o.length})(r,e)&&n.push(t)}));var r=JSON.parse(t);"object"==typeof r&&(r[v]=e),n.forEach((function(e){e.forEach((function(e){return e.next(r)}))}))}catch(e){p.warn("Error handling message",e,t)}},MqttOverWSProvider.prototype.subscribe=function(e,t){var n=this;void 0===t&&(t={});var r=[].concat(e);return p.debug("Subscribing to topic(s)",r.join(",")),new o((function(e){var o;r.forEach((function(t){var r=n._topicObservers.get(t);r||(r=new Set,n._topicObservers.set(t,r)),r.add(e)}));var i=t.clientId,s=void 0===i?n.clientId:i,c=n._clientIdObservers.get(s);return c||(c=new Set),c.add(e),n._clientIdObservers.set(s,c),__awaiter(n,void 0,void 0,(function(){var n,i,c,a;return __generator(this,(function(u){switch(u.label){case 0:return void 0!==(n=t.url)?[3,2]:[4,this.endpoint];case 1:return c=u.sent(),[3,3];case 2:c=n,u.label=3;case 3:i=c,u.label=4;case 4:return u.trys.push([4,6,,7]),[4,this.connect(s,{url:i})];case 5:return o=u.sent(),r.forEach((function(e){o.subscribe(e)})),[3,7];case 6:return a=u.sent(),e.error(a),[3,7];case 7:return[2]}}))})),function(){return p.debug("Unsubscribing from topic(s)",r.join(",")),o&&(n._clientIdObservers.get(s).delete(e),r.forEach((function(e){o.isConnected()&&o.unsubscribe(e);var t=n._topicObservers.get(e)||new Set;t.forEach((function(e){return e.complete()})),t.clear()})),0===n._clientIdObservers.get(s).size&&(n.disconnect(s),n._clientIdObservers.delete(s))),null}}))},MqttOverWSProvider}(a),y=function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};return function(e,t){function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),AWSAppSyncProvider_awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},AWSAppSyncProvider_generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},AWSAppSyncProvider_rest=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},__spreadArrays=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,c=i.length;s<c;s++,o++)r[o]=i[s];return r},h=new i.c("AWSAppSyncProvider"),g=function(e){function AWSAppSyncProvider(){var t=null!==e&&e.apply(this,arguments)||this;return t._topicClient=new Map,t._topicAlias=new Map,t}return y(AWSAppSyncProvider,e),Object.defineProperty(AWSAppSyncProvider.prototype,"endpoint",{get:function(){throw new Error("Not supported")},enumerable:!0,configurable:!0}),AWSAppSyncProvider.prototype.getProviderName=function(){return"AWSAppSyncProvider"},AWSAppSyncProvider.prototype.publish=function(e,t,n){return AWSAppSyncProvider_awaiter(this,void 0,void 0,(function(){return AWSAppSyncProvider_generator(this,(function(e){throw new Error("Operation not supported")}))}))},AWSAppSyncProvider.prototype._cleanUp=function(e){var t=this;Array.from(this._topicClient.entries()).filter((function(t){return t[1].clientId===e})).map((function(e){return e[0]})).forEach((function(e){return t._cleanUpForTopic(e)}))},AWSAppSyncProvider.prototype._cleanUpForTopic=function(e){this._topicClient.delete(e),this._topicAlias.delete(e)},AWSAppSyncProvider.prototype.onDisconnect=function(e){var t=this,n=e.clientId,r=e.errorCode,o=AWSAppSyncProvider_rest(e,["clientId","errorCode"]);0!==r&&(Array.from(this._topicClient.entries()).filter((function(e){return e[1].clientId===n})).map((function(e){return e[0]})).forEach((function(e){t._topicObservers.has(e)&&(t._topicObservers.get(e).forEach((function(e){e.closed||e.error(o)})),t._topicObservers.delete(e))})),this._cleanUp(n))},AWSAppSyncProvider.prototype.disconnect=function(t){return AWSAppSyncProvider_awaiter(this,void 0,void 0,(function(){return AWSAppSyncProvider_generator(this,(function(n){switch(n.label){case 0:return[4,this.clientsQueue.get(t,(function(){return null}))];case 1:return n.sent(),[4,e.prototype.disconnect.call(this,t)];case 2:return n.sent(),this._cleanUp(t),[2]}}))}))},AWSAppSyncProvider.prototype.subscribe=function(e,t){var n=this;void 0===t&&(t={});var r=new o((function(r){var o=[].concat(e);return h.debug("Subscribing to topic(s)",o.join(",")),AWSAppSyncProvider_awaiter(n,void 0,void 0,(function(){var e,n,i,s,c,a=this;return AWSAppSyncProvider_generator(this,(function(u){switch(u.label){case 0:return o.forEach((function(e){a._topicObservers.has(e)||a._topicObservers.set(e,new Set),a._topicObservers.get(e).add(r)})),e=t.mqttConnections,n=void 0===e?[]:e,i=t.newSubscriptions,s=Object.entries(i).map((function(e){var t=e[0];return[e[1].topic,t]})),this._topicAlias=new Map(__spreadArrays(Array.from(this._topicAlias.entries()),s)),c=Object.entries(o.reduce((function(e,t){var r=n.find((function(e){return e.topics.indexOf(t)>-1}));if(r){var o=r.client,i=r.url;e[o]||(e[o]={url:i,topics:new Set}),e[o].topics.add(t)}return e}),{})),[4,Promise.all(c.map((function(e){var t=e[0],n=e[1],o=n.url,i=n.topics;return AWSAppSyncProvider_awaiter(a,void 0,void 0,(function(){var e,n,s=this;return AWSAppSyncProvider_generator(this,(function(c){switch(c.label){case 0:e=null,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.connect(t,{clientId:t,url:o})];case 2:return e=c.sent(),[3,4];case 3:return n=c.sent(),r.error({message:"Failed to connect",error:n}),r.complete(),[2,void 0];case 4:return i.forEach((function(t){e.isConnected()&&(e.subscribe(t),s._topicClient.set(t,e))})),[2,e]}}))}))})))];case 1:return u.sent(),[2]}}))})),function(){h.debug("Unsubscribing from topic(s)",o.join(",")),o.forEach((function(e){var t=n._topicClient.get(e);t&&t.isConnected()&&(t.unsubscribe(e),n._topicClient.delete(e),Array.from(n._topicClient.values()).some((function(e){return e===t}))||n.disconnect(t.clientId)),n._topicObservers.delete(e)}))}}));return o.from(r).map((function(e){var t=n.getTopicForValue(e),r=n._topicAlias.get(t);return e.data=Object.entries(e.data).reduce((function(e,t){var n=t[0],o=t[1];return e[r||n]=o,e}),{}),e}))},AWSAppSyncProvider}(b),m=function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};return function(e,t){function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),AWSIotProvider_awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},AWSIotProvider_generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},P=(function(e){function AWSIoTProvider(){return null!==e&&e.apply(this,arguments)||this}m(AWSIoTProvider,e),Object.defineProperty(AWSIoTProvider.prototype,"region",{get:function(){return this.options.aws_pubsub_region},enumerable:!0,configurable:!0}),AWSIoTProvider.prototype.getProviderName=function(){return"AWSIoTProvider"},Object.defineProperty(AWSIoTProvider.prototype,"endpoint",{get:function(){return AWSIotProvider_awaiter(this,void 0,void 0,(function(){var e,t,n,r,o,s;return AWSIotProvider_generator(this,(function(c){switch(c.label){case 0:return e=this.options.aws_pubsub_endpoint,t={service:"iotdevicegateway",region:this.region},[4,i.e.get()];case 1:return n=c.sent(),r=n.accessKeyId,o=n.secretAccessKey,s=n.sessionToken,[2,i.m.signUrl(e,{access_key:r,secret_key:o,session_token:s},t)]}}))}))},enumerable:!0,configurable:!0})}(b),function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))}),PubSub_generator=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(c){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},_=new i.c("PubSub"),w=function(){function PubSub(e){this._options=e,_.debug("PubSub Options",this._options),this._pluggables=[],this.subscribe=this.subscribe.bind(this)}return Object.defineProperty(PubSub.prototype,"awsAppSyncProvider",{get:function(){return this._awsAppSyncProvider||(this._awsAppSyncProvider=new g(this._options)),this._awsAppSyncProvider},enumerable:!0,configurable:!0}),PubSub.prototype.getModuleName=function(){return"PubSub"},PubSub.prototype.configure=function(e){var t=this,n=e?e.PubSub||e:{};return _.debug("configure PubSub",{opt:n}),this._options=Object.assign({},this._options,n),this._pluggables.map((function(e){return e.configure(t._options)})),this._options},PubSub.prototype.addPluggable=function(e){return P(this,void 0,void 0,(function(){return PubSub_generator(this,(function(t){return e&&"PubSub"===e.getCategory()?(this._pluggables.push(e),[2,e.configure(this._options)]):[2]}))}))},PubSub.prototype.getProviderByName=function(e){return e===s.INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER?this.awsAppSyncProvider:this._pluggables.find((function(t){return t.getProviderName()===e}))},PubSub.prototype.getProviders=function(e){void 0===e&&(e={});var t=e.provider;if(!t)return this._pluggables;var n=this.getProviderByName(t);if(!n)throw new Error("Could not find provider named "+t);return[n]},PubSub.prototype.publish=function(e,t,n){return P(this,void 0,void 0,(function(){return PubSub_generator(this,(function(r){return[2,Promise.all(this.getProviders(n).map((function(r){return r.publish(e,t,n)})))]}))}))},PubSub.prototype.subscribe=function(e,t){_.debug("subscribe options",t);var n=this.getProviders(t);return new o((function(r){var o=n.map((function(n){return{provider:n,observable:n.subscribe(e,t)}})).map((function(e){var t=e.provider;return e.observable.subscribe({start:console.error,next:function(e){return r.next({provider:t,value:e})},error:function(e){return r.error({provider:t,error:e})}})}));return function(){return o.forEach((function(e){return e.unsubscribe()}))}}))},PubSub}(),A=new i.c("PubSub"),x=null;x||(A.debug("Create PubSub Instance"),x=new w(null));var I=x;i.o.register(I);t.a=I}}]);
//# sourceMappingURL=vendors~App-7KZ9F~ae3dbdae.chunk.eaa5497fb7f7db0479e3.js.map