zuma-ui
Version:
A JavaScript powered embeddable chatbot for business - customer interaction
2 lines • 22.8 kB
JavaScript
/*! For license information please see 149.bundle.js.LICENSE.txt */
(self.webpackChunkZuma=self.webpackChunkZuma||[]).push([[149],{1235:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),s=new O(n||[]);return i(a,"_invoke",{value:k(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function d(){}function y(){}function v(){}var m={};l(m,s,(function(){return this}));var g=Object.getPrototypeOf,b=g&&g(g(S([])));b&&b!==e&&r.call(b,s)&&(m=b);var w=v.prototype=d.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function o(i,a,s,c){var u=h(t[i],t,a);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,s,c)}),(function(t){o("throw",t,s,c)})):e.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return o("throw",t,s,c)}))}c(u.arg)}var a;i(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function k(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function S(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return y.prototype=v,i(w,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:y,configurable:!0}),y.displayName=l(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},x(L.prototype),l(L.prototype,c,(function(){return this})),t.AsyncIterator=L,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new L(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),l(w,u,"Generator"),l(w,s,(function(){return this})),l(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=S,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function i(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}var a=r(7379),s=a.Configuration,c=new(0,a.OpenAIApi)(new s({apiKey:"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"}));function u(){var t;return t=o().mark((function t(e){var r;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.createChatCompletion({model:"gpt-3.5-turbo",messages:[{role:"system",content:"You are a helpful assistant. your name is Zuma UI. Provide at most five keywords relevant to your response at thr bottom with enough space. your responsibility is to provide realtime frequently asked questions support for users. keep your response very simple and short. Generate your response from \"This company is accelerated towards providing a quick solution for live chats services for websites to enhance quick and straight to the point solution to frequently asked questions. A very easy and simple way to embed our app into your website is using our CDN links; unpkg: 'https://unpkg.com/zuma-ui@latest', jsdelivr: 'https://cdn.jsdelivr.net/npm/zuma-ui@latest'. Our official documentation website is 'https://zumabot.vercel.app'. To get started, create a div element with id attribute set to 'zuma', this is to concent that you're aware of this integration. then create a script and paste the following code `js Zuma.auth(document.getElementById('zuma')).startApp()`. Sit back and await a floating button on your app. This is just the beginning. head on to our documentation website to learn more. Suggest that they exit the chat by clicking on the 'exit chat' button if no further action is required.\""},{role:"user",content:e||"Hello"}]});case 2:return r=t.sent,t.abrupt("return",r.data);case 4:case"end":return t.stop()}}),t)})),u=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function s(t){i(a,n,o,s,c,"next",t)}function c(t){i(a,n,o,s,c,"throw",t)}s(void 0)}))},u.apply(this,arguments)}t.exports=function(t){return u.apply(this,arguments)}},1542:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>b});var n=r(2076),o=(r(4031),[{label:"",name:"ticket",use:"button"},{label:"",name:"message",placeholder:"How are you?"}]),i=r(1235),a=r.n(i);r.p;var s=r(5105),c=(r(4108),r(412)),u=r(3692);function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function f(){f=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,o){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),s=new O(o||[]);return n(a,"_invoke",{value:k(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p={};function d(){}function y(){}function v(){}var m={};c(m,i,(function(){return this}));var g=Object.getPrototypeOf,b=g&&g(g(S([])));b&&b!==e&&r.call(b,i)&&(m=b);var w=v.prototype=d.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function o(n,i,a,s){var c=h(t[n],t,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==l(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,a,s)}),(function(t){o("throw",t,a,s)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return o("throw",t,a,s)}))}s(c.arg)}var i;n(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}})}function k(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function S(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return y.prototype=v,n(w,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:y,configurable:!0}),y.displayName=c(v,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,s,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},x(L.prototype),c(L.prototype,a,(function(){return this})),t.AsyncIterator=L,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new L(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),c(w,s,"Generator"),c(w,i,(function(){return this})),c(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=S,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return p(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function d(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}var y=(0,n.Z)(Date.now(),"p"),v=function(){var t,e=(t=f().mark((function t(e,r){var n,i,a,l,p,d,y,v,b,w,x,L,k,E,_,j,O,S,C,N,A,T,I;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return I=function(t){var e,n,o,i,s=t.message,c=void 0===s?"Hi <b>".concat(null==r?void 0:r.get("fullname").ucfirst(),"</b>! My name is ").concat(null==a?void 0:a.config.appName,". What's up with you?"):s,l=t.type,f=void 0===l?"bot":l,h=t.msgArea,p=(t.suggestionArea,"text-base/7 py-1 px-2 break-words bg-transparent"),v="".concat("bot"===f?"text-slate-500":"text-slate-300"," text-xs font-bold");switch(f){case"bot":y(d.RECEIVED),(e=h.nextNode()).setCss("mb-5 max-w-full bg-white text-white inline-block"),m({node:o=e.nextNode(c,"p"),style:v}),o.setCss("".concat(p," bg-white text-black whitespace-break-spaces")),e.scrollIntoView();break;case"client":y(d.SENT),(n=h.nextNode()).setCss("mb-5 max-w-full bg-blue-500 inline-block"),m({node:i=n.nextNode(c,"p"),style:v}),i.setCss("".concat(p," text-white")),u.Z.emit("post_message_to_ai",{message:c,ai:k});break;case"suggest":(n=h.nextNode(c,"span")).setCss("bg-white !text-black py-1 px-2 text-black rounded-lg text-smaller m-1 inline-block shadow-sm"),n.addEventListener("click",(function(){return A(new Map([["message",c]]))}));break;case"notice":(n=h.nextNode(c)).setCss("bg-transparent !text-black text-xs my-5 min-w-full border border-t-white text-center border-b-white"),n.scrollIntoView()}},T=function(){var t=(0,s.dS)("input",{attributes:[{key:"type",value:"file"},{key:"name",value:"attachment"}]});t.click(),t.addEventListener("change",(function(t){var e=new FileReader;e.readAsDataURL(t.target.files[0]);var r=new Map;e.onload=function(){r.set("message",e.result),A(r)}}))},A=function(t){var e,r,n=null==t?void 0:t.get("message");if(!((null==n||null===(e=n.trim())||void 0===e?void 0:e.length)<1)){if(L.clearChildren(),n.toLowerCase().includes("copy:"))return I({msgArea:L,message:"<i class='text-xs text-green-500'>COPIED!</i>",type:"suggest"}),k.doneTyping(),(0,s.vQ)((0,s.Su)(n));if(null!=n&&null!==(r=n.toLowerCase())&&void 0!==r&&r.includes("goto:"))return(0,s.gB)((0,s.Su)(n));if(n.startsWith("data:")){var o=w.nextNode(null,"img",{src:n,width:200,height:200,alt:"attachment"});return o.setCss("mb-5"),o.scrollIntoView(),void setTimeout((function(){return I({msgArea:w,message:"Working on it...",type:"bot"})}),2500)}I({msgArea:w,message:n,type:"client"}),w.scrollIntoView()}},i=e.frame,a=e.context,t.next=6,(0,c.cT)();case 6:l=t.sent,p=h(l,2),d=p[0],y=p[1],v=i.nextNode(),b=v.nextNode(),w=b.nextNode(),x=b.nextNode(),L=x.nextNode(),k=(0,s.nM)(L),E=(0,c.cI)(x,{url:"/api/message/",children:o}),_=E.form,j=h(E.inputs,2),O=j[0],S=j[1],C=E.submitButton,N=E.onSubmit,I({msgArea:w,suggestionArea:L}),i.setCss("user-select-none bg-gray-300 p-0"),v.setCss("h-full w-full flex flex-col justify-around items-center bg-transparent-"),b.setCss("flex flex-col justify-center items-center w-full h-full flex flex-col justify-between bg-transparent-"),w.setCss("max-h-[90%] w-[100%] bg-transparent- overflow-y-auto scrollbar-none p-5"),L.setCss("bg-transparent- py-2"),x.setCss("sticky bottom-0 mx-auto inset-x-0 bg-white w-full px-3 py-1"),_.setCss("flex justify-between items-center"),O.inputEl.setCss("fa fa-plus p-3 text-slate-500 font-bold rounded-full"),S.inputEl.setCss("outline-none ".concat(null!=a&&null!==(n=a.config)&&void 0!==n&&n.isDarkTheme?"!text-white placeholder:text-white/40":"!text-black placeholder:text-black/40"," text-shadow-white rounded-2xl border border-slate-200 p-3 shadow-sm mx-1")),C.textContent="",C.setCss("disabled:opacity-25 fa fa-paper-plane text-gray-400 p-3"),O.inputEl.addEventListener("click",T),N((function(t){return A(t)})),u.Z.on("received_message_from_ai",(function(t){var e=t.text,r=t.ai,n=t.error;if(r.doneTyping(),n)return I({msgArea:w,message:e,type:"notice"});I({msgArea:w,message:(0,s.iV)(e),type:"bot"});var o=g(e);L.clearChildren(),(null==o?void 0:o.length)<1||o.forEach((function(t){I({msgArea:L,message:t,type:"suggest"})}))})),a.removeFooter();case 33:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){d(i,n,o,a,s,"next",t)}function s(t){d(i,n,o,a,s,"throw",t)}a(void 0)}))});return function(t,r){return e.apply(this,arguments)}}();function m(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.node,r=t.time,n=void 0===r?y:r,o=t.status,i=void 0===o?"fa fa-check":o,a=t.style,s=e.nextNode();s.setCss("flex justify-between items-center pt-2 text-sm bg-transparent"),s.nextNode(n,"span").setCss("bg-transparent mr-3 text-inherit ".concat(a)),s.nextNode(null,"span").setCss("".concat(i," bg-transparent ").concat(a))}function g(t){var e=t.match(/\[(.*?)\]/);if(e)return e[1].split(",").map((function(t){return t.trim()}));var r=t.match(/Keywords: (.*)/i);if(r)return r[1].split(",").map((function(t){return t.trim()}));var n=t.match(/#(.*)/);return n?n[1].split(",").map((function(t){var e;return null===(e=t.trim())||void 0===e?void 0:e.replace("#","")})):[]}u.Z.on("post_message_to_ai",(function(t){var e=t.message,r=t.ai;r.isTyping(),a()(e).then((function(t){var e=t.choices[0].message.content;u.Z.emit("received_message_from_ai",{text:e,ai:r})})).catch((function(t,e,n){console.log(t,e,n),u.Z.emit("received_message_from_ai",{text:t.message,ai:r,error:!0})}))})),u.Z.on("retry",(function(t){var e=t.text,r=t.ai;u.Z.emit("post_message_to_ai",{text:e,ai:r})}));const b=v}}]);