@subiz/widget-v4 4.1.143 → 4.1.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/compiled_src/bot.js +1 -2
- package/compiled_src/call/call.js +1 -2
- package/compiled_src/chatbox/Event.js +1 -2
- package/compiled_src/chatbox/Widget.js +1 -2
- package/compiled_src/chatbox/main.js +1 -2
- package/compiled_src/contact/contact.js +1 -2
- package/compiled_src/form/FormPage.js +1 -2
- package/compiled_src/form/index.js +1 -2
- package/compiled_src/form.js +1 -2
- package/compiled_src/notif/notif.js +1 -2
- package/compiled_src/order/icon.js +1 -2
- package/compiled_src/order/index.js +1 -2
- package/compiled_src/order/order.js +1 -2
- package/compiled_src/plugin.js +1 -2
- package/compiled_src/popup/popup.js +1 -2
- package/compiled_src/store/store.js +1 -3
- package/compiled_src/util/index.js +1 -2
- package/dist/196d3465f26.278.js +1 -0
- package/dist/196d3465f26.339.js +1 -0
- package/dist/196d3465f26.app.js +1 -0
- package/dist/{19680dc0775.form.html → 196d3465f26.form.html} +1 -1
- package/dist/196d3465f26.form.js +1 -0
- package/dist/{19680dc0775.index.html → 196d3465f26.index.html} +15 -1
- package/dist/{19680dc0775.library.html → 196d3465f26.library.html} +15 -1
- package/dist/196d3465f26.library.js +1 -0
- package/dist/{19680dc0775.preview.html → 196d3465f26.preview.html} +1 -1
- package/dist/196d3465f26.preview.js +1 -0
- package/dist/196d3465f26.webview.js +1 -0
- package/dist/278.js +81 -70
- package/dist/HASH +1 -1
- package/dist/assets/img/stars_v2.79cf728.png +0 -0
- package/dist/screenshoot.js +242 -32
- package/index.html +14 -0
- package/package.json +10 -10
- package/src/store/store.js +1 -1
- package/dist/19680dc0775.278.js +0 -1
- package/dist/19680dc0775.app.js +0 -1
- package/dist/19680dc0775.form.js +0 -1
- package/dist/19680dc0775.library.js +0 -1
- package/dist/19680dc0775.preview.js +0 -1
- package/dist/19680dc0775.webview.js +0 -1
- /package/dist/{19680dc0775.127.js → 196d3465f26.127.js} +0 -0
- /package/dist/{19680dc0775.132.js → 196d3465f26.132.js} +0 -0
- /package/dist/{19680dc0775.185.js → 196d3465f26.185.js} +0 -0
- /package/dist/{19680dc0775.27.js → 196d3465f26.27.js} +0 -0
- /package/dist/{19680dc0775.459.js → 196d3465f26.459.js} +0 -0
- /package/dist/{19680dc0775.490.js → 196d3465f26.490.js} +0 -0
- /package/dist/{19680dc0775.74.js → 196d3465f26.74.js} +0 -0
- /package/dist/{19680dc0775.997.js → 196d3465f26.997.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var t,e,s={9:(t,e,i)=>{var s=i(9143);t.exports=function(t,e,i){var r=[],n="idle",o=function(t){var e=t.map((function(t){return t.payload})),s=i(e);s&&s.then||(s=Promise.resolve(s));var r=t.map((function(t){return t.rs}));return new Promise((function(t){s.then((function(e){r.map((function(t,i){t(e&&e[i])})),t()}))}))},a=function(){"executing"!==n&&(n="executing",s((function(){if(r.length<=t)return Promise.resolve(!1);var e=r.splice(0,t);return o(e).then((function(){return!0}))})).then((function(){if(0!==r.length){var t=e-(Date.now()-r[0].created);if(t>=1){if(n="idle",r[0].settedTimeout)return;return r[0].settedTimeout=!0,void setTimeout(a,t)}var i=r;r=[],o(i).then((function(){n="idle",a()}))}else n="idle"})))};return this.push=function(t,e){return new Promise((function(i){r.push({payload:t,priority:e,created:Date.now(),rs:i}),a()}))},this}},172:(t,e,i)=>{"use strict";i.d(e,{FK:()=>y,XX:()=>O,_3:()=>_,h:()=>f,uA:()=>b});var s,r,n,o,a,l,c,h={},u=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,p=Array.isArray;function m(t,e){for(var i in e)t[i]=e[i];return t}function g(t){var e=t.parentNode;e&&e.removeChild(t)}function f(t,e,i){var r,n,o,a={};for(o in e)"key"==o?r=e[o]:"ref"==o?n=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?s.call(arguments,2):i),"function"==typeof t&&null!=t.defaultProps)for(o in t.defaultProps)void 0===a[o]&&(a[o]=t.defaultProps[o]);return v(t,a,r,n,null)}function v(t,e,i,s,o){var a={type:t,props:e,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==o?++n:o,__i:-1,__u:0};return null==o&&null!=r.vnode&&r.vnode(a),a}function _(){return{current:null}}function y(t){return t.children}function b(t,e){this.props=t,this.context=e}function w(t,e){if(null==e)return t.__?w(t.__,t.__i+1):null;for(var i;e<t.__k.length;e++)if(null!=(i=t.__k[e])&&null!=i.__e)return i.__e;return"function"==typeof t.type?w(t):null}function k(t){var e,i;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(i=t.__k[e])&&null!=i.__e){t.__e=t.__c.base=i.__e;break}return k(t)}}function A(t){(!t.__d&&(t.__d=!0)&&o.push(t)&&!x.__r++||a!==r.debounceRendering)&&((a=r.debounceRendering)||l)(x)}function x(){var t,e,i,s,n,a,l,h,u;for(o.sort(c);t=o.shift();)t.__d&&(e=o.length,s=void 0,a=(n=(i=t).__v).__e,h=[],u=[],(l=i.__P)&&((s=m({},n)).__v=n.__v+1,r.vnode&&r.vnode(s),D(l,s,n,i.__n,void 0!==l.ownerSVGElement,32&n.__u?[a]:null,h,null==a?w(n):a,!!(32&n.__u),u),s.__.__k[s.__i]=s,L(h,s,u),s.__e!=a&&k(s)),o.length>e&&o.sort(c));x.__r=0}function C(t,e,i,s,r,n,o,a,l,c,d){var p,m,g,f,v,_=s&&s.__k||u,y=e.length;for(i.__d=l,S(i,e,_),l=i.__d,p=0;p<y;p++)null!=(g=i.__k[p])&&"boolean"!=typeof g&&"function"!=typeof g&&(m=-1===g.__i?h:_[g.__i]||h,g.__i=p,D(t,g,m,r,n,o,a,l,c,d),f=g.__e,g.ref&&m.ref!=g.ref&&(m.ref&&U(m.ref,null,g),d.push(g.ref,g.__c||f,g)),null==v&&null!=f&&(v=f),65536&g.__u||m.__k===g.__k?l=M(g,l,t):"function"==typeof g.type&&void 0!==g.__d?l=g.__d:f&&(l=f.nextSibling),g.__d=void 0,g.__u&=-196609);i.__d=l,i.__e=v}function S(t,e,i){var s,r,n,o,a,l=e.length,c=i.length,h=c,u=0;for(t.__k=[],s=0;s<l;s++)null!=(r=t.__k[s]=null==(r=e[s])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?v(null,r,null,null,r):p(r)?v(y,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?v(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=t,r.__b=t.__b+1,a=P(r,i,o=s+u,h),r.__i=a,n=null,-1!==a&&(h--,(n=i[a])&&(n.__u|=131072)),null==n||null===n.__v?(-1==a&&u--,"function"!=typeof r.type&&(r.__u|=65536)):a!==o&&(a===o+1?u++:a>o?h>l-o?u+=a-o:u--:u=a<o&&a==o-1?a-o:0,a!==s+u&&(r.__u|=65536))):(n=i[s])&&null==n.key&&n.__e&&(n.__e==t.__d&&(t.__d=w(n)),F(n,n,!1),i[s]=null,h--);if(h)for(s=0;s<c;s++)null!=(n=i[s])&&!(131072&n.__u)&&(n.__e==t.__d&&(t.__d=w(n)),F(n,n))}function M(t,e,i){var s,r;if("function"==typeof t.type){for(s=t.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=t,e=M(s[r],e,i));return e}return t.__e!=e&&(i.insertBefore(t.__e,e||null),e=t.__e),e&&e.nextSibling}function P(t,e,i,s){var r=t.key,n=t.type,o=i-1,a=i+1,l=e[i];if(null===l||l&&r==l.key&&n===l.type)return i;if(s>(null==l||131072&l.__u?0:1))for(;o>=0||a<e.length;){if(o>=0){if((l=e[o])&&!(131072&l.__u)&&r==l.key&&n===l.type)return o;o--}if(a<e.length){if((l=e[a])&&!(131072&l.__u)&&r==l.key&&n===l.type)return a;a++}}return-1}function E(t,e,i){"-"===e[0]?t.setProperty(e,null==i?"":i):t[e]=null==i?"":"number"!=typeof i||d.test(e)?i:i+"px"}function j(t,e,i,s,r){var n;t:if("style"===e)if("string"==typeof i)t.style.cssText=i;else{if("string"==typeof s&&(t.style.cssText=s=""),s)for(e in s)i&&e in i||E(t.style,e,"");if(i)for(e in i)s&&i[e]===s[e]||E(t.style,e,i[e])}else if("o"===e[0]&&"n"===e[1])n=e!==(e=e.replace(/(PointerCapture)$|Capture$/,"$1")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+n]=i,i?s?i.u=s.u:(i.u=Date.now(),t.addEventListener(e,n?T:I,n)):t.removeEventListener(e,n?T:I,n);else{if(r)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==e&&"height"!==e&&"href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&"rowSpan"!==e&&"colSpan"!==e&&"role"!==e&&e in t)try{t[e]=null==i?"":i;break t}catch(t){}"function"==typeof i||(null==i||!1===i&&"-"!==e[4]?t.removeAttribute(e):t.setAttribute(e,i))}}function I(t){var e=this.l[t.type+!1];if(t.t){if(t.t<=e.u)return}else t.t=Date.now();return e(r.event?r.event(t):t)}function T(t){return this.l[t.type+!0](r.event?r.event(t):t)}function D(t,e,i,s,n,o,a,l,c,h){var u,d,g,f,v,_,w,k,A,x,S,M,P,E,j,I=e.type;if(void 0!==e.constructor)return null;128&i.__u&&(c=!!(32&i.__u),o=[l=e.__e=i.__e]),(u=r.__b)&&u(e);t:if("function"==typeof I)try{if(k=e.props,A=(u=I.contextType)&&s[u.__c],x=u?A?A.props.value:u.__:s,i.__c?w=(d=e.__c=i.__c).__=d.__E:("prototype"in I&&I.prototype.render?e.__c=d=new I(k,x):(e.__c=d=new b(k,x),d.constructor=I,d.render=R),A&&A.sub(d),d.props=k,d.state||(d.state={}),d.context=x,d.__n=s,g=d.__d=!0,d.__h=[],d._sb=[]),null==d.__s&&(d.__s=d.state),null!=I.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=m({},d.__s)),m(d.__s,I.getDerivedStateFromProps(k,d.__s))),f=d.props,v=d.state,d.__v=e,g)null==I.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(null==I.getDerivedStateFromProps&&k!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(k,x),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(k,d.__s,x)||e.__v===i.__v)){for(e.__v!==i.__v&&(d.props=k,d.state=d.__s,d.__d=!1),e.__e=i.__e,e.__k=i.__k,e.__k.forEach((function(t){t&&(t.__=e)})),S=0;S<d._sb.length;S++)d.__h.push(d._sb[S]);d._sb=[],d.__h.length&&a.push(d);break t}null!=d.componentWillUpdate&&d.componentWillUpdate(k,d.__s,x),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(f,v,_)}))}if(d.context=x,d.props=k,d.__P=t,d.__e=!1,M=r.__r,P=0,"prototype"in I&&I.prototype.render){for(d.state=d.__s,d.__d=!1,M&&M(e),u=d.render(d.props,d.state,d.context),E=0;E<d._sb.length;E++)d.__h.push(d._sb[E]);d._sb=[]}else do{d.__d=!1,M&&M(e),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++P<25);d.state=d.__s,null!=d.getChildContext&&(s=m(m({},s),d.getChildContext())),g||null==d.getSnapshotBeforeUpdate||(_=d.getSnapshotBeforeUpdate(f,v)),C(t,p(j=null!=u&&u.type===y&&null==u.key?u.props.children:u)?j:[j],e,i,s,n,o,a,l,c,h),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),w&&(d.__E=d.__=null)}catch(t){e.__v=null,c||null!=o?(e.__e=l,e.__u|=c?160:32,o[o.indexOf(l)]=null):(e.__e=i.__e,e.__k=i.__k),r.__e(t,e,i)}else null==o&&e.__v===i.__v?(e.__k=i.__k,e.__e=i.__e):e.__e=z(i.__e,e,i,s,n,o,a,c,h);(u=r.diffed)&&u(e)}function L(t,e,i){e.__d=void 0;for(var s=0;s<i.length;s++)U(i[s],i[++s],i[++s]);r.__c&&r.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){r.__e(t,e.__v)}}))}function z(t,e,i,r,n,o,a,l,c){var u,d,m,f,v,_,y,b=i.props,k=e.props,A=e.type;if("svg"===A&&(n=!0),null!=o)for(u=0;u<o.length;u++)if((v=o[u])&&"setAttribute"in v==!!A&&(A?v.localName===A:3===v.nodeType)){t=v,o[u]=null;break}if(null==t){if(null===A)return document.createTextNode(k);t=n?document.createElementNS("http://www.w3.org/2000/svg",A):document.createElement(A,k.is&&k),o=null,l=!1}if(null===A)b===k||l&&t.data===k||(t.data=k);else{if(o=o&&s.call(t.childNodes),b=i.props||h,!l&&null!=o)for(b={},u=0;u<t.attributes.length;u++)b[(v=t.attributes[u]).name]=v.value;for(u in b)v=b[u],"children"==u||("dangerouslySetInnerHTML"==u?m=v:"key"===u||u in k||j(t,u,null,v,n));for(u in k)v=k[u],"children"==u?f=v:"dangerouslySetInnerHTML"==u?d=v:"value"==u?_=v:"checked"==u?y=v:"key"===u||l&&"function"!=typeof v||b[u]===v||j(t,u,v,b[u],n);if(d)l||m&&(d.__html===m.__html||d.__html===t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(m&&(t.innerHTML=""),C(t,p(f)?f:[f],e,i,r,n&&"foreignObject"!==A,o,a,o?o[0]:i.__k&&w(i,0),l,c),null!=o)for(u=o.length;u--;)null!=o[u]&&g(o[u]);l||(u="value",void 0!==_&&(_!==t[u]||"progress"===A&&!_||"option"===A&&_!==b[u])&&j(t,u,_,b[u],!1),u="checked",void 0!==y&&y!==t[u]&&j(t,u,y,b[u],!1))}return t}function U(t,e,i){try{"function"==typeof t?t(e):t.current=e}catch(t){r.__e(t,i)}}function F(t,e,i){var s,n;if(r.unmount&&r.unmount(t),(s=t.ref)&&(s.current&&s.current!==t.__e||U(s,null,e)),null!=(s=t.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(t){r.__e(t,e)}s.base=s.__P=null,t.__c=void 0}if(s=t.__k)for(n=0;n<s.length;n++)s[n]&&F(s[n],e,i||"function"!=typeof t.type);i||null==t.__e||g(t.__e),t.__=t.__e=t.__d=void 0}function R(t,e,i){return this.constructor(t,i)}function O(t,e,i){var n,o,a,l;r.__&&r.__(t,e),o=(n="function"==typeof i)?null:i&&i.__k||e.__k,a=[],l=[],D(e,t=(!n&&i||e).__k=f(y,null,[t]),o||h,h,void 0!==e.ownerSVGElement,!n&&i?[i]:o?null:e.firstChild?s.call(e.childNodes):null,a,!n&&i?i:o?o.__e:e.firstChild,n,l),L(a,t,l)}s=u.slice,r={__e:function(t,e,i,s){for(var r,n,o;e=e.__;)if((r=e.__c)&&!r.__)try{if((n=r.constructor)&&null!=n.getDerivedStateFromError&&(r.setState(n.getDerivedStateFromError(t)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(t,s||{}),o=r.__d),o)return r.__E=r}catch(e){t=e}throw t}},n=0,b.prototype.setState=function(t,e){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=m({},this.state),"function"==typeof t&&(t=t(m({},i),this.props)),t&&m(i,t),null!=t&&this.__v&&(e&&this._sb.push(e),A(this))},b.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),A(this))},b.prototype.render=y,o=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(t,e){return t.__v.__b-e.__v.__b},x.__r=0},318:t=>{var e="Content-Type",i="application/x-www-form-urlencoded",s="application/json; charset=utf-8";function r(t,e){return Object.assign(t.clone(),e)}var n={code:"network_error,retry",number:"SBZ-EQNETWORK",message:{En_US:"Can not connect to the server. Please check your internet connection.",Vi_VN:"Không thể kết nối tới máy chủ. Vui lòng kiểm tra lại kết nối mạng."}},o={code:"invalid_response,retry",number:"SBZ-EQRESPONSE",message:{En_US:"Server error, please try again later",Vi_VN:"Lỗi máy chủ, vui lòng thử lại sau"}},a={code:"not_200,retry",number:"SBZ-EQCN200",message:{En_US:"Error while connecting to the server, please try again later",Vi_VN:"Lỗi kết nối với máy chủ, vui lòng thử lại sau"}};function l(t){return(t||"").trim()}function c(t){return t&&"[object Function]"==={}.toString.call(t)}function h(t,e,i){if(!t||0===t.length)return i(e);var s=t.shift();if(!c(s))return h(t,e,i);s(e,(function(s){return!1===s?i(e):h(t,e,i)}))}function u(t){return encodeURIComponent(t).replace(/[!'()*]/g,(function(t){return"%"+t.charCodeAt(0).toString(16)}))}function d(t){if(!t)return"";for(var e=Object.keys(t),i=[],s=0;s<e.length;s++){var r=e[s],n="",o=t[r];if(void 0!==o){if(null===o)n=u(r);else if(Array.isArray(o)){for(var a=[],l=0;l<o.length;l++)void 0!==o[l]&&(a.push(p(r,o[l],a.length)),a.push(i));n=a.join("&")}else n=u(r)+"="+u(o);n.length>0&&i.push(n)}}return i.join("&")}function p(t,e){return null===e?u(t):[u(t),"=",u(e)].join("")}var m,g=(m={parser:"",beforehooks:[],afterhooks:[],baseurl:"",query:{},clone:function(){return Object.assign({},this,{query:Object.assign({},this.query)})},addQuery:function(t,e){var i=this.clone();return i.query[t]=e,i},removeQuery:function(t){var e=this.clone();return void 0!==e.query[t]&&(e.query[t]=void 0),e},withCredentials:function(t){return r(this,{_withCredentials:t})},setQuery:function(t){return r(this,{query:t})},clearHooks:function(){return r(this,{beforehooks:[],afterhooks:[]})},beforeHook:function(t){var e=this.beforehooks.slice();return e.push(t),r(this,{beforehooks:e})},afterHook:function(t){var e=this.afterhooks.slice();return e.push(t),r(this,{afterhooks:e})},setHeader:function(t){return(t=Object.assign({},this.headers,t))[e]=void 0,r(this,{headers:t})}},["put","head","patch","delete","post","get"].map((function(t){m[t]=function(u,p,m){return function(t,r,l){l=l||function(){},c(r)&&(l=r,r=void 0);var u,p=new Promise((function(t){u=function(e){try{l(e.error,e.body,e.code)}catch(t){}t(e)}}));return r&&((t=t.clone()).body=r,t.content_type===s&&(t.body=f.Jsonify(r)),t.content_type===i&&(t.body=d(r))),h(t.beforehooks.slice(),{request:t},(function(i){if(i.error)return u({body:{error:bq.error},code:0,error:i.error});!function(t,i){let s=d(t.query);if(s&&(s="?"+s),!f.XMLHttpRequest)return function(t,i,s){var r=Object.assign({},t.headers);t.content_type&&(r[e]=t.content_type),fetch(t.baseurl+s,{method:t.method,headers:r,credentials:t._withCredentials,body:t.body}).then((function(t){return t.text()})).then((function(t){i(void 0,t,res.status)})).catch((function(t){i("network_error",t,-1)}))}(t,i,s);var r=new f.XMLHttpRequest;for(var n in r.onreadystatechange=function(t){4===r.readyState&&(0===r.status?i("network_error",r.responseText,r.status):i(void 0,r.responseText,r.status))},r.open(t.method,t.baseurl+s),r.withCredentials=t._withCredentials,t.headers)r.setRequestHeader(n,t.headers[n]);t.content_type&&r.setRequestHeader(e,t.content_type),r.send(t.body)}(i.request,(function(e,i,s){h(t.afterhooks.slice(),{request:t,code:s,body:i,err:e},(function(e){var i=e.body;if("network_error"==r)return u({body:{error:n},code:e.code,error:n});if("json"==t.parser&&e.body)try{i=f.ParseJson(e.body)}catch(t){return u({body:{error:o,origin_body:e.body},code:e.code,error:o})}var r=e.err;if("network_error"==r)return u({body:{error:n},code:e.code,error:n});!r&&(s<200||s>299)&&(r=i&&i.error?i.error:a),u({body:r?i||{error:r}:i,code:e.code,error:r})}))}))})),p}(r(this,{method:t,baseurl:(g=this.baseurl,v=u,g=l(g),(v=l(v))&&g?v.startsWith("http://")||v.startsWith("https://")||v.startsWith("//")?v:(g.endsWith("/")||(g+="/"),v.startsWith("/")&&(v=v.substring(1)),g+v):g+v)}),p,m);var g,v}})),m.setBaseUrl=function(t){return r(this,{baseurl:t})},m.contentTypeJson=function(){return r(this,{content_type:s})},m.contentTypeForm=function(){return r(this,{content_type:i})},m.setContentType=function(t){return r(this,{content_type:l(t)})},m.setParser=function(t){return r(this,{parser:l(t)})},m.setBody=function(t){return r(this,{body:t})},m),f={Jsonify:JSON.stringify,ParseJson:JSON.parse};g.env=f,g.waterfall=h,t.exports=g},450:t=>{var e={},i={};e.length=0,e.getItem=function(t){return t in i?i[t]:null},e.setItem=function(t,s){void 0===s?e.removeItem(t):(Object.prototype.hasOwnProperty.call(i,t)||e.length++,i[t]=s)},e.removeItem=function(t){Object.prototype.hasOwnProperty.call(i,t)&&(delete i[t],e.length--)},e.key=function(t){return Object.keys(i)[t]||null},e.clear=function(){i={},e.length=0},t.exports=e},940:(t,e,i)=>{t.exports=i.p+"assets/img/rating--great.e3d712e.svg"},1108:(t,e,i)=>{t.exports=i.p+"assets/img/bubble_default.7d5e4ab.svg"},1139:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});class s{constructor(t){this.isOpen=!0===t,this.cbs=[]}open(){this.isOpen=!0;let t=[];this.cbs.forEach((e=>{this.isOpen?e():t.push(e)})),this.cbs=t}close(){this.isOpen=!1}entry(t,e){return this.isOpen?(e&&(this.isOpen=!1),t&&t(),Promise.resolve()):new Promise((i=>{this.cbs.push((()=>{e&&(this.isOpen=!1),t&&t(),i()}))}))}}},1370:(t,e,i)=>{t.exports=i.p+"assets/img/convos_empty.2353007.svg"},1620:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(5922),r=i(2840),n=i(172),o=new s.A.Pubsub;s.A.setInterval((()=>o.publish("time")),2e4);class a extends r.Mw{constructor(t){super(t),this.setState({t:"",langCode:"en_US"})}updateTime(){var t="";let e="";this.props.t&&this.props.t.locale&&"function"==typeof this.props.t.locale&&(e=this.props.t.locale()),this.props.ago?(this.props.short,!t&&this.props.time>0&&(t=function(t,e,i){let s={s:"%d sec",m:"1 min",mm:"%d mins",h:"1 hour",hh:"%d hours",d:"1 day",dd:"%d days",M:"1 month",MM:"%d months",y:"1 year",yy:"%d years"};i&&(s={s:`%d ${i("second_short")}`,m:`1 ${i("minute_short")}`,mm:`%d ${i("minutes_short")}`,h:`1 ${i("hour_short")}`,hh:`%d ${i("hours_short")}`,d:`1 ${i("day_short")}`,dd:`%d ${i("days_short")}`,M:`1 ${i("month_short")}`,MM:`%d ${i("months_short")}`,y:`1 ${i("year_short")}`,yy:`%d ${i("years_short")}`});const r=s,n=[{l:"s",r:44,d:1e3},{l:"m",r:89},{l:"mm",r:44,d:6e4},{l:"h",r:89},{l:"hh",r:21,d:36e5},{l:"d",r:35},{l:"dd",r:25,d:864e5},{l:"M",r:45},{l:"MM",r:10,d:2592e6},{l:"y",r:17},{l:"yy",d:31536e6}],o=n.length;let a,l;for(let i=0;i<o;i+=1){let s=n[i];s.d&&(a=(t-e)/s.d);let o=Math.round(Math.abs(a));if(o<=s.r||!s.r){o<=1&&i>0&&(s=n[i-1]),l=r[s.l].replace("%d",o);break}}return l}(this.props.time,(new s.A.Date).getTime(),this.props.t))):t=s.A.shortTime(this.props.time,this.props.tzoffset,s.A.Date.now(),e),this.props.uppercase&&(t=t.toUpperCase()),t!==this.state.t&&this.setState({t})}componentDidMount(){o.on2(this,"time",(()=>this.updateTime())),this.updateTime()}render(){let t=s.A.get(navigator,"languages.0","en-US");this.props.t&&this.props.t.locale&&"function"==typeof this.props.t.locale&&(t=this.props.t.locale());let e=new Date(this.props.time).toLocaleString(t);return(0,n.h)("span",{class:this.props.class,style:this.props.style,title:e},this.state.t)}}},2538:(t,e,i)=>{t.exports=i.p+"assets/img/default_avatar.5b74dc1.png"},2839:(t,e,i)=>{var s=i(8193),{xhrsend:r,parseJSON:n,Pubsub:o}=i(7695);function a(t,e,i,o,a,u){a=a||r,e=e||{};var d="";u||(u="");var p=!1,m=!1,g=!1,f=function(e){p||a("get",t+"poll?token="+d+"&account-id="+u,void 0,(function(i,s){if(!p){if(l(s))return m=!0,setTimeout(f,function(t){if(!t||-1===t)return 0;var e=1e3*Math.pow(1.5,t);return Math.min(1e4,e)}(e),e+1);if(200!==s)return m=!0,_("poll");m=!1,(i=n(i)||{}).host&&(t=h(i.host));var r=i.sequential_token;return r?(d=r,o(i.events||[]),f(0)):_("poll")}}))},v=s.batch(50,100,(function(i){if(p)return Promise.resolve(c("dead",i.length));if(i.length<=0)return Promise.resolve([]);var r,o=new Promise((t=>{r=t})),m=!1;return setTimeout((function(){m||p||(g=!0)}),4e3),setTimeout((()=>{m||(m=!0,r(c("dead",i.length)),p||_("subs"))}),6e4),s.loop((function(){return new Promise((function(s){if(p)return r(c("dead",i.length)),s(!1);var o="?token="+d;e.getAccessToken().then((function(v){if(p)return r(c("dead",i.length)),s(!1);e.user_ref?o+="&user_ref="+encodeURIComponent(e.user_ref):e.user_mask?o+="&user-mask="+encodeURIComponent(e.user_mask):v&&(o+="&access-token="+v);var y=t+"subs"+o+"&account-id="+encodeURIComponent(u||e.account_id);a("post",y,JSON.stringify({events:i}),(function(e,o){if(!m){if(p)return r(c("dead",i.length)),s(!1);if(l(o))return g=!0,setTimeout(s,3e3,!0);if(200!==o)return _("subs"),r(c("dead",i.length)),s(!1);if(g=!1,m=!0,d)return r(i),s(!1);var a=(e=n(e)||{}).initial_token;return a?(e.host&&(t=h(e.host)),d=a,f(0),r(i),s(!1)):(_("subs"),r(c("dead",i.length)),s(!1))}}))}))}))})),o}));this.subscribe=v.push.bind(v),this.getStatus=function(){return p?"dead":g||m?"connecting":"active"};var _=function(t){p=!0,i(t)};this.kill=_}function l(t){return t>=500&&t<600||0===t||-1===t||429===t}function c(t,e){for(var i=[],s=0;s<e;s++)i.push(t);return i}function h(t){return(t=t||"").startsWith("//")?"https:"+t:t}t.exports=function(t,e,i,s,r){("string"==typeof t||t instanceof String)&&(t=[t]),(e=e||{}).getAccessToken||(e.getAccessToken=function(){return Promise.resolve("")}),s||(s=e.account_id||"");var n,l=new o,c={};this.stop=function(){n&&(n.kill(),n=void 0,l.emit("interrupted"))},this.onEvent=function(t){return l.on("event",t)},this.onInterrupted=function(t){return l.on("interrupted",t)},this.getStatus=function(){return n?n.getStatus():"dead"},this.subscribe=function(t){if(!n)return Promise.resolve({error:"dead"});if("string"==typeof t&&(t=[t]),!Array.isArray(t))return Promise.resolve({error:"param should be an array or string"});for(var e=[],i=0;i<t.length;i++){var s=t[i];s&&(c[s]||(c[s]=!0,e.push(n.subscribe(s))))}return 0===e.length?Promise.resolve({}):Promise.all(e).then((function(){return n&&"dead"!=n.getStatus()?{}:{error:"dead"}}))},this.reconnect=function(){var o=t[Math.floor(Math.random()*t.length)];n&&n.kill();let h=new a(o,e,(function(t,e,i){h==n&&(l.emit("interrupted",t,e,i),r||setTimeout(this.reconnect,2e3))}),(function(t){if(h==n)for(var e=0;e<t.length;e++)l.emit("event",t[e])}),i,s);n=h;var u=Object.keys(c);return c={},this.subscribe(u)},this.reconnect()}},2840:(t,e,i)=>{"use strict";i.d(e,{Dy:()=>h,JK:()=>a,Mw:()=>n,r9:()=>l,tW:()=>o});var s=i(172),r=i(5922);class n extends s.uA{constructor(t){super(t),this._isMounted=!0,r.A.setTimeout((()=>{if(this.componentWillUnmount){let t=this.componentWillUnmount.bind(this);this.componentWillUnmount=()=>{t(),this._isMounted=!1}}}),10)}}class o extends n{constructor(t){super(t),this.setWrapperRef=this.setWrapperRef.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){document.addEventListener("mousedown",this.onClick)}componentWillUnmount(){document.removeEventListener("mousedown",this.onClick)}setWrapperRef(t){this.wrapperRef=t}onClick(t){this.wrapperRef&&!this.wrapperRef.contains(t.target)&&this.props.onClickaway&&this.props.onClickaway()}render(){return(0,s.h)("div",{ref:this.setWrapperRef},this.props.children)}}const a=(t,e)=>{e||(e="");let i=r.A.find(t.locales,(t=>t.toLowerCase().trim()===e.toLowerCase().trim()));return i||(i=r.A.find(t.locales,(t=>(t=t.replace("-","_").split("_")[0].trim().toLowerCase())==e.replace("-","_").split("_")[0].trim().toLowerCase())),i||t.locale||"en-US")};let l={},c=!1;function h(t,e,i){if(c)return new Promise((s=>r.A.setTimeout((()=>h(t,e,i).then(s)),100)));let s;return c=!0,"debug"===e||l[e]&&!i?(c=!1,Promise.resolve()):t.getLocaleContent(e).then((t=>{c=!1,s=r.A.get(t,"body.messages",[]),l[e]=s}))}},2876:(t,e,i)=>{t.exports=i.p+"assets/img/default.06e6ee0.jpg"},2959:(t,e,i)=>{"use strict";i.d(e,{A:()=>o});var s=i(5922),r=i(2840),n=i(172);class o extends r.Mw{render(){var t=this.props.emojiCode;if(s.A.size(t)<3)return null;var e=t.replace(/:/g,"");return(0,n.h)("i",{"data-tooltip":t,class:`emoji emoji--${e}`})}}},2988:(t,e,i)=>{"use strict";i.d(e,{A:()=>r});var s=i(5922);const r=class{constructor(t){this.duration=t.duration||100,this.breakingV=t.breakingV||7,this.maxY=t.maxY||500,this.minY=t.minY||0}play(t,e,i){var r;this.stop();var n=o=>{o||(o=(new s.A.Date).getTime());var a=o-r,[l,c]=this.calcY(t,e,a);if(i(l),c)return this.stop();this.animationframe=window.requestAnimationFrame(n)};this.animationframe=window.requestAnimationFrame((t=>{r=t||(new s.A.Date).getTime(),n(r)}))}calcY(t,e,i){var s,r=function(t,e,i,s){if(n(t,e))return t;var r=t+(e-t)/s*i;return(t<e&&r>e||e<t&&r<e)&&(r=e),r}(e,s=e>this.maxY?this.maxY:e<this.minY?this.minY:Math.abs(t)<this.breakingV?Math.abs(this.maxY-e)<Math.abs(this.minY-e)?this.maxY:this.minY:t<0?this.maxY:this.minY,i,this.duration);return[r,n(r,s)]}stop(){window.cancelAnimationFrame(this.animationframe)}};function n(t,e){return Math.abs(t-e)<=.001}},3078:(t,e,i)=>{"use strict";i.r(e),i.d(e,{trackAreaClicked:()=>o,trackExitIntent:()=>r,trackInactivity:()=>a,trackScrollingPercentage:()=>n,trackTimeOnPage:()=>c});var s=i(9917);function r(t){let e=i=>{i.clientY>10||(t&&t(),document.removeEventListener("mouseout",e))};document.addEventListener("mouseout",e)}function n(t,e){let i=s=>{let r=s.srcElement.scrollingElement?s.srcElement.scrollingElement.scrollTop:s.srcElement.scrollTop,n=s.srcElement.scrollingElement?s.srcElement.scrollingElement.scrollHeight:s.srcElement.scrollHeight;r>0&&n>0&&(r+window.innerHeight)/n>=t&&(e&&e(),window.removeEventListener("scroll",i,!1))};window.addEventListener("scroll",i,!1)}function o(t,e){t&&(t=t||"",s.map(t.split("\n"),(t=>{(t=s.trim(t))&&function(t,e,i){document.addEventListener("click",(function(t){let s=document.querySelectorAll(e),r=t.target;for(let e=0,n=s.length;e<n;e++){let n=r,o=s[e];for(;n&&n!==document;){if(n===o)return i.call(o,t);n=n.parentNode}}}))}(0,t,e)})))}function a(t=0,e){let i=["scroll","keyup","keydown","mousemove","mousewheel","mouseenter","mouseover","mousedown","touchstart","touchmove","touchenter"],r=0,n=()=>{r=0},o=s.setInterval((()=>{if(r++,!(r<t)){e&&e();for(let t of i)document.removeEventListener(t,n,!1);s.clearInterval(o)}}),1e3);for(let t of i)document.addEventListener(t,n,!1)}let l=s.Date.now();function c(t=0,e){if(t<1)return s.setTimeout((function(){e(t)}),100);let i=s.setInterval((()=>{let r=(s.Date.now()-l)/1e3;r<t||(e&&e(r),s.clearInterval(i))}),200)}},3259:(t,e,i)=>{"use strict";i.r(e),i.d(e,{get:()=>a,set:()=>l});var s=Object.prototype.toString,r=Array.isArray||function(t){return"[object Array]"===s.call(t)};function n(t){var e=parseInt(t);return e.toString()===t?e:t}function o(t,e){if(function(t,e){return"number"==typeof e&&r(t)||function(t,e){return null!=t&&Object.prototype.hasOwnProperty.call(t,e)}(t,e)}(t,e))return t[e]}function a(t,e,i){if("number"==typeof e&&(e=[e]),!e||0===e.length)return t;if(null==t)return i;if("string"==typeof e)return a(t,e.split("."),i);var s=n(e[0]),r=o(t,s);return void 0===r?i:1===e.length?r:a(t[s],e.slice(1),i)}function l(t,e,i){if("number"==typeof e&&(e=[e]),!e||0===e.length)return t;if("string"==typeof e)return l(t,e.split(".").map(n),i);var s=e[0],r=o(t,s);return 1===e.length?(t[s]=i,r):(void 0===r&&(t[s]="number"==typeof e[1]?[]:{}),l(t[s],e.slice(1),i))}},3266:(t,e,i)=>{t.exports=i.p+"assets/img/external-link.90577cc.svg"},3582:(t,e,i)=>{t.exports=i.p+"assets/img/image_default.be0698b.png"},4188:(t,e,i)=>{"use strict";i.d(e,{A:()=>o});var s=i(2840),r=i(172);const n=i(6973);class o extends s.Mw{render(){(this.props.mode+"").toLowerCase();let t=this.props.size||14,e=(Math.ceil(t/14),`width: ${t}px !important;height: ${t}px !important;`);return this.props.center?(0,r.h)("div",{class:"loading"},(0,r.h)("img",{alt:"loading",style:e,src:n})):(0,r.h)("img",{alt:"loading",style:e,src:n})}}},5180:t=>{t.exports={ApiURL:"https://api.sbz.vn/4.0",RealtimeURL:"https://api.sbz.vn/rt/0/",FileURL:"https://vcdn.subiz-cdn.com/file/",BaseURL:"https://widget.sbz.vn"}},5219:(t,e,i)=>{var s=i(9096);t.exports=function(t,e,i){if("number"==typeof e){let t=i;i=e,e=t}e||(e=function(){}),("number"!=typeof i||i<=0)&&(i=1);var r={};if(s.map(t,(function(t,e){r[e]=t})),i<=0&&(i=1),0===Object.keys(r).length)return Promise.resolve([]);Object.keys(r).length<i&&(i=Object.keys(r).length);var n={};return new Promise((function(t){let o=Object.keys(r).length;for(var a=function(){var i=Object.keys(r);if(0!==i.length){var l=i.shift(),c=r[l];delete r[l];var h=e(c,l);h&&h.then||(h=Promise.resolve(h)),h.then((function(e){if(n[l]=e,Object.keys(n).length===o)return t(s.map(n));a()}))}},l=0;l<i;l++)setTimeout(a,1)}))}},5369:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});class s{constructor(){this.isOpen=!0,this.cbs=[]}_check(){if(!this.isOpen)return;let t=this.cbs.pop();t&&(this.isOpen=!1,t())}lock(){return new Promise((t=>{this.cbs.push(t),this._check()}))}unlock(){this.isOpen||(this.isOpen=!0,this._check())}}},5672:function(t){t.exports=function(){"use strict";var t=function(){return t.get.apply(t,arguments)},e=t.utils={isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},isPlainObject:function(t){return!!t&&"[object Object]"===Object.prototype.toString.call(t)},toArray:function(t){return Array.prototype.slice.call(t)},getKeys:Object.keys||function(t){var e=[],i="";for(i in t)t.hasOwnProperty(i)&&e.push(i);return e},encode:function(t){return String(t).replace(/[,;"\\=\s%]/g,(function(t){return encodeURIComponent(t)}))},decode:function(t){return decodeURIComponent(t)},retrieve:function(t,e){return null==t?e:t}};return t.defaults={},t.expiresMultiplier=86400,t.set=function(t,i,s){if(e.isPlainObject(t))for(var r in t)t.hasOwnProperty(r)&&this.set(r,t[r],i);else{var n=void 0!==(s=e.isPlainObject(s)?s:{expires:s}).expires?s.expires:this.defaults.expires||"",o=typeof n;"string"===o&&""!==n?n=new Date(n):"number"===o&&(n=new Date(+new Date+1e3*this.expiresMultiplier*n)),""!==n&&"toUTCString"in n&&(n=";expires="+n.toUTCString());var a=s.path||this.defaults.path;a=a?";path="+a:"";var l=s.domain||this.defaults.domain;l=l?";domain="+l:"";var c=s.secure||this.defaults.secure?";secure":"";!1===s.secure&&(c="");var h=s.sameSite||this.defaults.sameSite;h=h?";SameSite="+h:"",null===s.sameSite&&(h=""),document.cookie=e.encode(t)+"="+e.encode(i)+n+a+l+c+h}return this},t.setDefault=function(i,s,r){if(e.isPlainObject(i)){for(var n in i)void 0===this.get(n)&&this.set(n,i[n],s);return t}if(void 0===this.get(i))return this.set.apply(this,arguments)},t.remove=function(t){for(var i=0,s=(t=e.isArray(t)?t:e.toArray(arguments)).length;i<s;i++)this.set(t[i],"",-1);return this},t.removeSpecific=function(t,i){if(!i)return this.remove(t);t=e.isArray(t)?t:[t],i.expires=-1;for(var s=0,r=t.length;s<r;s++)this.set(t[s],"",i);return this},t.empty=function(){return this.remove(e.getKeys(this.all()))},t.get=function(t,i){var s=this.all();if(e.isArray(t)){for(var r={},n=0,o=t.length;n<o;n++){var a=t[n];r[a]=e.retrieve(s[a],i)}return r}return e.retrieve(s[t],i)},t.all=function(){if(""===document.cookie)return{};for(var t=document.cookie.split("; "),i={},s=0,r=t.length;s<r;s++){var n=t[s].split("="),o=e.decode(n.shift()),a=e.decode(n.join("="));i[o]=a}return i},t.enabled=function(){if(navigator.cookieEnabled)return!0;var e="_"===t.set("_","_").get("_");return t.remove("_"),e},t}()},5922:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(9917),r=i(3078),n={};(n=Object.assign(n,s)).Gate=i(1139).A,n.Mutex=i(5369).A;var o=i(3259);n.get=o.get,n.set=o.set,n.Pubsub=i(6463).A;const a=n=Object.assign(n,r)},6463:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var{filter:s,map:r}=i(9917);class n{constructor(){this.listeners={}}publish(t,e,i,n){this.listeners[t]=s(this.listeners[t],(t=>t.obj._isMounted)),r(this.listeners[t],(({cb:t})=>t(e,i,n)))}on2(t,e,i){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({obj:t,cb:i})}}},6973:(t,e,i)=>{t.exports=i.p+"assets/img/loading_static.a27f0ac.svg"},7072:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(5922),r=i(2959),n=i(2840),o=i(172);class a extends n.Mw{constructor(t){super(t)}renderBlock(t){if(0==s.A.size(t))return null;let e={style:""};if(t.style&&s.A.map(t.style,((t,i)=>{e.style+=i+": "+t+";"})),e.attrs={},""!=t.title&&(e.attrs.title=t.title),""!=t.href&&(e.attrs.href=t.href),e.class=t.class,s.A.map(t.attrs,((t,i)=>{e.attrs[i]=t})),"bullet_list"!=t.type&&"ordered_list"!=t.type||("bullet_list"==t.type?e.tag="ol":e.tag="ul"),"list_item"==t.type&&(e.tag="li"),"heading"==t.type&&(t.level<1&&(t.level=1),t.level>6&&(t.level=6),e.tag="h"+t.level),"paragraph"!=t.type&&"section"!=t.type&&"div"!=t.type||(e.tag="div"),e.text=t.text,""!=t.type&&"text"!=t.type&&"dynamic-field"!=t.type||(e.tag="span",t.bold&&(e.tag="b"),t.italic&&("b"==e.tag?e.style+="font-style: italic;":e.tag="em"),t.underline&&(e.Style+="text-decoration:underline;"),t.strike_through&&(e.Style+="text-decoration: line-through;")),"dynamic-field"==t.type){let i=s.A.get(t.attrs,"key");e.text=s.A.get(this.props.data,[i],e.text)}if("link"==t.type&&(e.tag="a",e.attrs.href=t.href,e.attrs.target=t.target,e.attrs.title=t.title),"mention-agent"==t.type||"mention"==t.type){e.tag="span",e.class="mention";let i=t.attrs.id="";if("*"!=t.attrs.id&&"all"!=t.attrs.id||(e.text="@"+this.$t("all")),i.startsWith("ag")){let t=store.matchAgent(i),r=s.A.getAgentDisplayName(t,insert.mention.fullname);e.text="@"+r}}if("horizontal_rule"==t.type&&(e.tag="hr"),"emoji"==t.type){let i="";s.A.size(t.attrs)>0&&(i=t.attrs.code),""==i&&(i=t.Text),""!=i&&(e.tag="Emoji",e.attrs.emojiCode=i)}if("table"==t.type)return null;let i=null;switch(i=s.A.size(t.content)?s.A.map(t.content,(t=>this.renderBlock(t))):"text"===t.type?s.A.extractText(e.text).map((t=>{if("link"===t.type){let e=t.text||"";return e.startsWith("//")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:")||(e="//"+e),(0,o.h)("a",{href:e,target:"_blank",onClick:t=>this.props.onLink(t,e)},t.text)}return"phone"===t.type?(0,o.h)("a",{href:"tel:"+t.text},t.text):"email"===t.type?(0,o.h)("a",{href:"mailto:"+t.text},t.text):t.text})):e.text,e.tag){case"div":return(0,o.h)("div",null,i);case"h1":return(0,o.h)("h1",null,i);case"h2":return(0,o.h)("h2",null,i);case"h3":return(0,o.h)("h3",null,i);case"h4":return(0,o.h)("h4",null,i);case"h5":return(0,o.h)("h5",null,i);case"h6":return(0,o.h)("h6",null,i);case"ol":return(0,o.h)("ol",null,i);case"ul":return(0,o.h)("ul",null,i);case"span":return(0,o.h)("span",null,i);case"em":return(0,o.h)("em",null,i);case"b":return(0,o.h)("b",null,i);case"hr":return(0,o.h)("hr",null);case"a":return(0,o.h)("a",{href:e.attrs.href,target:e.attrs.target,title:e.attrs.title},i);case"Emoji":return(0,o.h)(r.A,{emojiCode:e.attrs.emojiCode})}return null}render(){return this.renderBlock(this.props.block)}}},7134:(t,e,i)=>{t.exports=i.p+"assets/img/rating--average.1ea492c.svg"},7695:t=>{function e(t){return t<10?`0${t}`:`${t}`}var i=function(t,e,i,s){if("undefined"==typeof XMLHttpRequest)return function(t,e,i,s){let r={};i&&(r["content-type"]="text/plain"),fetch(e,{method:t,headers:r,body:i}).then((t=>t.text().then((e=>s&&s(e,t.status))))).catch((t=>s&&s(t,-1)))}(t,e,i,s);var r=new XMLHttpRequest;r.onreadystatechange=function(t){4===r.readyState&&(s&&s(r.responseText,r.status),s=void 0)},r.onerror=function(){s&&s(r.responseText,-1),s=void 0},r.open(t,e),i&&r.setRequestHeader("content-type","text/plain"),r.send(i)};t.exports={xhrsend:i,parseJSON:function(t){try{return JSON.parse(t)}catch(t){}},Pubsub:function(){var t={};this.emit=function(e){for(var i=[],s=1;s<arguments.length;s++)i.push(arguments[s]);var r=t[e];if(r)for(s=0;s<r.length;s++)r[s].apply(void 0,i)},this.on=function(e,i){t[e]||(t[e]=[]),t[e].push(i)}},randomString:function(t,e){var i,s="";(!t||t<1)&&(t=10);for(var r=0;r<t;r++)e?s+=e[Math.floor(Math.random()*e.length)]:(i=Math.floor(25*Math.random()+97),s+=String.fromCharCode(i));return s},logError:function(t,s,r,n){let o=function(t){let i=t.getUTCFullYear().toString().substr(2,2),s=t.getUTCMonth()+1,r=t.getUTCDate(),n=t.getUTCHours(),o=t.getUTCMinutes(),a=t.getUTCSeconds();return`${i}-${e(s)}-${e(r)} ${e(n)}:${e(o)}:${e(a)}`}(new Date),a=JSON.stringify({id:Date.now(),class:400,code:"frontend_error",number:n.split("").map((t=>t.charCodeAt(0).toString(16).padStart(2,"0"))).join(""),fields:{message:JSON.stringify(r),user_id:s,url:JSON.stringify(location.href)}});i("POST","https://track.subiz.net/collect",`${o} app ERROR dashboard ${t} ${n} ${a}`)}}},8193:(t,e,i)=>{var s=i(9798),r=i(9143),n=i(5219),o=i(9);t.exports={sleep:s,loop:r,map:n,batch:o}},8506:(t,e,i)=>{t.exports=i.p+"assets/img/send.6db52a9.svg"},9096:t=>{t.exports={map:function(t,e){if(!t)return[];e||(e=function(t){return t});var i=[];if(Array.isArray(t)){for(var s=0;s<t.length;s++)i.push(e(t[s],s));return i}if("object"==typeof t){var r=Object.keys(t);for(s=0;s<r.length;s++){var n=r[s];i.push(e(t[n],n))}return i}return i}}},9143:t=>{t.exports=function t(e){var i=e();if(!i||!i.then){var s=i;i={then:function(t){t(s)}}}return i.then((function(i){return i?t(e):Promise.resolve()}))}},9150:(t,e,i)=>{t.exports=i.p+"assets/img/done_gray.d7e8203.svg"},9419:(t,e,i)=>{t.exports=i.p+"assets/img/empty.29bed2d.svg"},9529:(t,e,i)=>{t.exports=i.p+"assets/img/subiz-mono.8fbc067.svg"},9798:t=>{t.exports=function(t){return new Promise((function(e){setTimeout(e,t)}))}},9801:(t,e,i)=>{t.exports=i.p+"assets/img/rating--poor.2938a25.svg"},9917:(t,e,s)=>{"use strict";s.r(e),s.d(e,{DEFVAL:()=>dt,DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL:()=>ut,Date:()=>y,XMLHttpRequest:()=>C,agentsOfConvo:()=>R,blockToText:()=>Lt,checkRunConditions:()=>gt,clearInterval:()=>A,clearTimeout:()=>x,cloneDeep:()=>j,convoOfEv:()=>S,convoToEv:()=>M,detectLang:()=>Mt,diffDay:()=>wt,diffYear:()=>kt,each:()=>z,extract:()=>u,extractEmails:()=>c,extractEmojis:()=>a,extractLinks:()=>l,extractPhones:()=>h,extractText:()=>p,filter:()=>T,find:()=>V,formatCurrency:()=>jt,getAgentDisplayName:()=>tt,getDayName:()=>ft,getMs:()=>St,getUrlParameter:()=>Pt,getUserAttr:()=>st,hslToRgb:()=>o,includes:()=>D,isBlockEmpty:()=>zt,isConvoSeen:()=>F,isEmail:()=>K,isNumber:()=>Y,isPhone:()=>Q,isURL:()=>X,isUserBanned:()=>et,js2css:()=>pt,last:()=>Z,map:()=>L,merge:()=>E,noop:()=>nt,norm:()=>rt,offsetToMin:()=>bt,orderBy:()=>H,orderByF:()=>J,parseJSON:()=>m,pipeExtracts:()=>d,preloadImg:()=>yt,preloadWebfonts:()=>_t,randomString:()=>I,replaceAll:()=>q,replaceCssVariable:()=>lt,replaceCssVariablePlugin:()=>at,requestAnimationFrame:()=>b,rgbToHsl:()=>n,sameDay:()=>At,scrollIntoViewIfNeeded:()=>Tt,setCss:()=>ht,setInterval:()=>k,setTimeout:()=>w,setUserAttr:()=>it,shortTime:()=>xt,size:()=>$,sleep:()=>Et,startsWith:()=>O,stringify:()=>v,throttle:()=>G,tokenize:()=>ct,trim:()=>W,trimStart:()=>B,unicodeToAscii:()=>It,unixSec:()=>Ct,usersOfConvo:()=>U});var r=s(3259);function n(t,e,i){t/=255,e/=255,i/=255;var s,r,n=Math.max(t,e,i),o=Math.min(t,e,i),a=(n+o)/2;if(n==o)s=r=0;else{var l=n-o;switch(r=a>.5?l/(2-n-o):l/(n+o),n){case t:s=(e-i)/l+(e<i?6:0);break;case e:s=(i-t)/l+2;break;case i:s=(t-e)/l+4}s/=6}return[s,r,a]}function o(t,e,i){var s,r,n;if(0==e)s=r=n=i;else{function l(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}var o=i<.5?i*(1+e):i+e-i*e,a=2*i-o;s=l(a,o,t+1/3),r=l(a,o,t),n=l(a,o,t-1/3)}return[255*s,255*r,255*n]}function a(t){for(var e=[],i=0;i<t.length;i++)for(var s=0;s<Rt.length;s++)if(t.indexOf(Rt[s],i)===i){e.push({index:i,length:Rt[s].length}),i+=Rt[s].length-1;break}return e}function l(t){t=t||"";for(var e,i=/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9@:%_\+.,~#?&//=]*)/gim,s=[];e=i.exec(t);)s.push({index:e.index,length:i.lastIndex-e.index});return s}function c(t){t=t||"";for(var e,i=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gim,s=[];e=i.exec(t);)s.push({index:e.index,length:i.lastIndex-e.index});return s}function h(t){t=t||"";for(var e="",i={},s=0;s<t.length;s++){var r=t.charAt(s);if("."===r||"-"===r||" "===r){var n=s>0?t.charAt(s-1):"-",o=s<t.length-1?t.charAt(s+1):"-";-1!=="0123456789".indexOf(n)&&-1!=="0123456789".indexOf(o)||(i[(e+=r).length-1]=s)}else i[(e+=r).length-1]=s}for(var a,l=/([0-9]{8,13})/gim,c=[];a=l.exec(e);)c.push({index:i[a.index],length:i[l.lastIndex-1]-i[a.index]+1});return c}function u(t,e,i){if(!t)return[];var s=[],r=0,n=e(t);if(0===$(n))return[{type:"text",text:t}];z(n,(e=>{s.push({type:"text",text:t.substr(r,e.index-r)}),s.push({type:i,text:t.substr(e.index,e.length)}),r=e.index+e.length}));var o=Z(n);return s.push({type:"text",text:t.substr(o.index+o.length,t.length-o.index+o.length)}),T(s,(t=>""!==t.text))}function d(t,e){var i=[];if(0===$(e))return[{type:"text",text:t}];var s=e.shift();return z(u(t,s,s.type),(t=>{if("text"!==t.type)return i.push(t);i=i.concat(d(t.text,e.slice()))})),i}function p(t){var e=l;e.type="link";var i=c;i.type="email";var s=h;s.type="phone";var r=a;return r.type="emoji",d(t,[e,i,s,r])}function m(t){try{return _(t)}catch(t){}}var g=document.createElement("iframe");g.style.display="none",document.documentElement.appendChild(g);const f=g.contentDocument.createElement("div");g.contentDocument.body.appendChild(f);var v=g.contentWindow.JSON.stringify,_=g.contentWindow.JSON.parse,y=g.contentWindow.Date,b=g.contentWindow.requestAnimationFrame,w=g.contentWindow.setTimeout.bind(g.contentWindow),k=g.contentWindow.setInterval.bind(g.contentWindow),A=g.contentWindow.clearInterval.bind(g.contentWindow),x=g.contentWindow.clearTimeout.bind(g.contentWindow),C=g.contentWindow.XMLHttpRequest;function S(t){return t?r.get(t,"data.conversation.id",r.get(t,"data.message.conversation_id")):""}function M(t,e){if(!e)return"";switch(e.type){case"message_sent":case"message_updated":case"message_pong":return r.set(e,"data.message.conversation_id",t);case"ticket_updated":return r.set(e,"data.ticket.conversation_id",t);default:return r.set(e,"data.conversation.id",t)}}function P(t){return t&&"object"==typeof t&&!Array.isArray(t)}function E(t,...e){if(!e.length)return t;const i=e.shift();if(P(t)&&P(i))for(const e in i)P(i[e])?(t[e]||Object.assign(t,{[e]:{}}),E(t[e],i[e])):Object.assign(t,{[e]:i[e]});return E(t,...e)}function j(t){if(t!==Object(t))return t;var e=v(t);return void 0!==e?_(e):void 0}function I(t){var e,i="";(!t||t<1)&&(t=10);for(var s=0;s<t;s++)e=Math.floor(25*Math.random()+97),i+=String.fromCharCode(e);return i}function T(t,e){if(!t)return[];if(!e)return t;var i=[];if(Array.isArray(t)){for(let s=0;s<t.length;s++)e(t[s],s)&&i.push(t[s]);return i}if("object"==typeof t){var s=Object.keys(t);for(let n=0;n<s.length;n++){var r=s[n];e(t[r],r)&&i.push(t[r])}return i}return i}function D(t,e){if(!t)return!1;var i="string"==typeof t||t instanceof String;return!(!Array.isArray(t)&&!i)&&t.includes(e)}function L(t,e){if(!t)return[];e||(e=t=>t);var i=[];if(Array.isArray(t)){for(let s=0;s<t.length;s++)i.push(e(t[s],s));return i}if("object"==typeof t){var s=Object.keys(t);for(let n=0;n<s.length;n++){var r=s[n];i.push(e(t[r],r))}return i}return i}function z(t,e){return L(t,e)}function U(t){return t?L(T(t.members,(t=>"user"===t.type)),(t=>t.id)):[]}function F(t,e){if("ended"===t.state)return!0;let i=t.last_message_sent;if(!i)return!0;if(r.get(i,"by.id")===e)return!0;let s=V(t.members,(t=>t.id===e));return!s||St(i.created)<St(s.seen_at)}function R(t,e){return t?L(T(t.members,(t=>e?"agent"===t.type||"bot"===t.type:"agent"===t.type)),(t=>t.id)):[]}function O(t,e){return((t||"")+"").startsWith(e)}function $(t){return t?void 0!==t.length?t.length:Object.keys(t).length:0}function q(t,e,i){return(t||"").split(e).join(i)}function W(t,e){return((t||"")+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function B(t,e){for(t=(t||"")+"";t.charAt(0)===e;)t=t.substr(1);return t}function G(t,e,i){var s,r,n,o=null,a=0;i||(i={});var l=function(){a=!1===i.leading?0:(new y).getTime(),o=null,n=t.apply(s,r),o||(s=r=null)};return function(){var c=(new y).getTime();a||!1!==i.leading||(a=c);var h=e-(c-a);return s=this,r=arguments,h<=0||h>e?(o&&(x(o),o=null),a=c,n=t.apply(s,r),o||(s=r=null)):o||!1===i.trailing||(o=w(l,h)),n}}function V(t,e){if(t)return t[N(t,e)]}function N(t,e){if(!t)return-1;if(!e)return-1;if(Array.isArray(t)){for(let i=0;i<t.length;i++)if(e(t[i],i))return i;return-1}if("object"==typeof t){var i=Object.keys(t);for(let r=0;r<i.length;r++){var s=i[r];if(e(t[s],s))return s}}return-1}function H(t,e,i){var s=[];return z(t,(t=>s.push(t))),s.sort(((t,s)=>{if(t[e]===s[e])return 0;var r=t[e]<s[e]?-1:1;return"desc"===i?-r:r})),s}function J(t,e,i){var s=[];return z(t,(t=>s.push(t))),s.sort(((t,s)=>{let r=e(t),n=e(s);if(r===n)return 0;var o=r<n?-1:1;return"desc"===i?-o:o})),s}function Q(t){return/^[\+]?[(]?[0-9]{2,3}[)]?[-\s\.]?[0-9]{3,4}[-\s\.]?[0-9]{4,6}$/im.test(String(t))}function X(t){return/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi.test(String(t).toLowerCase())}function Y(t){return/^\d+$/.test(String(t))}function K(t){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(t).toLowerCase())}function Z(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}function tt(t,e){return r.get(e,"fullname")||r.get(e,"email")||r.get(t,"name")||"Agent"}function et(t){return st(t,"is_ban","boolean")}function it(t,e){if(t&&r.get(e,"key")){t.attributes=t.attributes||[];var i=N(t.attributes,(t=>t&&t.key===e.key));-1!==i?t.attributes[i]=e:t.attributes.push(e)}}function st(t,e,i){if(!t||!t.attributes)return;let s;return z(t.attributes,(t=>{t&&t.key===e&&("datetime"===i&&(s=t.datetime),"boolean"===i&&(s=t.boolean),"number"===i&&(s=t.number),"text"===i&&(s=t.text),"list"===i&&(s=[t.text].concat(t.other_values)))})),s}function rt(t){return(t=t||"").trim().toLowerCase()}function nt(){}function ot(t){return("string"==typeof t||t instanceof String)&&(t=t.trim().replace(/;+$/,"")),t}function at(t,e){var i=[t];let s=e.spacer||10;e=Object.assign({},e,{spacer:s+"px",spacer0:s/2+"px",spacer2:2*s+"px",spacer3:3*s+"px"}),i=ct(i,"'@font_family'"),i=ct(i,"'@font_size'"),i=ct(i,"'@text_color'"),i=ct(i,"'@faded_text_color'"),i=ct(i,"'@primary_color'"),i=ct(i,"'@background'"),i=ct(i,"'@spacer'"),i=ct(i,"'@spacer0'"),i=ct(i,"'@spacer2'"),i=ct(i,"'@spacer3'");let a=Ft(r.get(e,"primary_color")||r.get(dt,"primary_color"));a||(a={red:238,blue:238,green:238});let l=n(a.red,a.green,a.blue)[0],[c,h,u]=o(l,.25,.95);dt.primary_color_faded=`rgb(${c},${h},${u})`;for(var d=[],p=0;p<i.length;p++){var m=i[p];if("string"!=typeof m){var g=m.type.substr(2,m.type.length-3),f=r.get(e,g)||r.get(dt,g)||"";d.push(f)}else d.push(m)}return d.join("")}function lt(t,e){var i=[t];i=ct(i,"'@primary_color'"),i=ct(i,"'@primary_color_faded'"),i=ct(i,"@esc-primary-color-esc"),i=ct(i,"'@secondary_color'"),i=ct(i,"'@background'"),i=ct(i,"'@text_color'"),i=ct(i,"'@width'"),i=ct(i,"'@height'"),i=ct(i,"'@desktop_button.width'"),i=ct(i,"'@desktop_button.height'"),i=ct(i,"'@desktop_button.background'"),i=ct(i,"'@desktop_button.border_radius'"),i=ct(i,"'@desktop_button.margin_x'"),i=ct(i,"'@desktop_button.margin_y'"),i=ct(i,"'@mobile_button.width'"),i=ct(i,"'@mobile_button.height'"),i=ct(i,"'@mobile_button.background'"),i=ct(i,"'@mobile_button.border_radius'"),i=ct(i,"'@mobile_button.margin_x'"),i=ct(i,"'@mobile_button.margin_y'"),i=ct(i,"'@widget_position'"),i=ct(i,"'@z_index'"),i=ct(i,"'@z_index_2'"),i=ct(i,"'@z_index_3'"),i=ct(i,"'@z_index_4'"),i=ct(i,"'@z_index_5'");let s=Ft(r.get(e,"primary_color")||r.get(dt,"primary_color"));s||(s={red:238,blue:238,green:238});let a=n(s.red,s.green,s.blue)[0],[l,c,h]=o(a,.25,.95);dt.primary_color_faded=`rgb(${l},${c},${h})`;for(var u=[],d=0;d<i.length;d++){var p=i[d];if("string"!=typeof p)if("@esc-primary-color-esc"!==p.type)if("'@z_index_2'"!==p.type)if("'@z_index_3'"!==p.type)if("'@z_index_4'"!==p.type)if("'@z_index_5'"!==p.type){var m=p.type.substr(2,p.type.length-3);g=ot(g=r.get(e,m)||r.get(dt,m)||""),["mobile_button.width","mobile_button.height","mobile_button.margin_x","mobile_button.margin_y","desktop_button.width","desktop_button.height","desktop_button.margin_x","desktop_button.margin_y","width","height"].includes(m)&&(g+="px"),"height"!==m||"full"!==r.get(e,"window_mode")?u.push(g):u.push("100%")}else g=r.get(e,"z_index")||r.get(dt,"z_index"),u.push(g+5);else g=r.get(e,"z_index")||r.get(dt,"z_index"),u.push(g+4);else{var g=r.get(e,"z_index")||r.get(dt,"z_index");u.push(g+3)}else{g=r.get(e,"z_index")||r.get(dt,"z_index");u.push(g+2)}else{g=r.get(e,"primary_color")||r.get(dt,"primary_color");u.push(encodeURIComponent(ot(g)))}else u.push(p)}return u.join("")}function ct(t,e){if(!t||!t.length)return[];var i=[];for(let n=0;n<t.length;n++){var s=t[n];if("string"==typeof s){var r=s.split(e);for(let t=0;t<r.length;t++)i.push(r[t]),i.push({type:e});i.pop()}else i.push(s)}return i}function ht(t,e,i){i=q(i,"#sbz92","#"+t),e.styleSheet?e.styleSheet.cssText=i:(e.innerHTML="",e.appendChild(document.createTextNode(i)))}const ut="https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5",dt={primary_color:"#0265FF",secondary_color:"#555555",background:"linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)",text_color:"white",width:375,height:705,window_mode:"mini",desktop_button:{width:.3,height:.3,border_radius:"100%",background_mask_url:ut,margin_x:.3,margin_y:.3},mobile_button:{width:.3,height:.3,border_radius:"100%",background_mask_url:ut,margin_x:.3,margin_y:.3},widget_position:"fixed",z_index:2e9};function pt(t,e,i){var s={};for(var r in t)t.hasOwnProperty(r)&&(e&&e.length>0&&-1===e.indexOf(r)||("string"==typeof t[r]?s[r]=W(t[r]):s[r]=t[r]));t=s;let n="";for(var r in t)if(t.hasOwnProperty(r)){var o="";if(t.blur&&(o+="blur("+t.blur+") "),t.grayscale&&(o+="grayscale("+t+") "),o&&(n+="filter: "+o+"!important;"),void 0!==t.rotate&&(n+="transform:rotate("+t.rotate+") !important;"),void 0!==t[r]){let e=t[r]+"";L(i,((t,i)=>{-1!==e.indexOf(i)&&(e=q(e,i,t))})),n+=q(r,"_","-")+":"+e+" !important;","color"===r&&(n+="-webkit-text-fill-color: "+e+" !important;")}}return n}function mt(){var t=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,e="undefined"!=typeof InstallTrigger,i=(/constructor/i.test(window.HTMLElement)||(!window.safari||"undefined"!=typeof safari&&window.safari.pushNotification).toString(),!!document.documentMode),s=!i&&!!window.StyleMedia,r=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime);r||(r=navigator.userAgent.indexOf("Chrome"));var n=r&&-1!=navigator.userAgent.indexOf("Edg"),o=(r||t)&&!!window.CSS;return t?"opera":e?"firefox":i?"ie":s||n?"edge":r?"chrome":o?"blink":"unknown"}function gt(t,e,i,s){var n=s.matchAccount()||{},o=s.matchLocation()||{};if(!function(t,e){return!(e&&(r.get(t,"once_per_user")||r.get(t,"once_per_session")&&At(e.created,y.now())||r.get(t,"interval_sec")&&r.get(t,"interval_sec")>(y.now()-e.created)/1e3))}(t,i))return!1;for(let t=0;t<$(e);t++){var a=e[t];switch(a.key){case"url":let t=T(a.exclude_urls,(t=>rt(t)));if($(t)>0&&V(t,(t=>rt(window.location.href).indexOf(rt(t))>-1)))return!1;let e=T(a.urls,(t=>rt(t)));if($(e)>0&&!V(e,(t=>rt(window.location.href).indexOf(rt(t))>-1)))return!1;break;case"url_path":let i=T(a.exclude_url_paths,(t=>rt(t)));if($(i)>0){let t=new URL(window.location.href).pathname||"";if("string"==typeof t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),V(i,(e=>("string"==typeof e&&e.endsWith("/")&&(e=e.substring(0,e.length-1)),t===e))))return!1}let u=T(a.url_paths,(t=>rt(t)));if($(u)>0){let t=new URL(window.location.href).pathname||"";if("string"==typeof t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),!V(u,(e=>("string"==typeof e&&e.endsWith("/")&&(e=e.substring(0,e.length-1)),t===e))))return!1}break;case"browser":if($(a.browsers)>0){var l=mt();if(!V(a.browsers,(t=>rt(t)===rt(l))))return!1}break;case"location":if($(a.exclude_locations)>0&&V(a.exclude_locations,(t=>!(!t.city_name||!t.country_code||t.city_name!==o.city_name||t.country_code!==o.country_code)||!(!t.city_name||t.country_code||t.city_name!==o.city_name)||!(t.city_name||!t.country_code||t.country_code!==o.country_code)||void 0)))return!1;if($(a.locations)>0&&!V(a.locations,(t=>!(!t.city_name||!t.country_code||t.city_name!==o.city_name||t.country_code!==o.country_code)||!(!t.city_name||t.country_code||t.city_name!==o.city_name)||!(t.city_name||!t.country_code||t.country_code!==o.country_code)||void 0)))return!1;break;case"returning_visitor":if(a.returning_visitor&&s.new_visitor)return!1;if(!a.returning_visitor&&!s.new_visitor)return!1;break;case"user_is_a_contact":let d=r.get(s.matchUser(),"attributes",[]),p=V(d,(t=>"emails"===t.key&&attr.text&&"related_email"===t.key&&attr.text)),g=V(d,(t=>"phones"===t.key&&attr.text&&"related_phone"===t.key&&attr.text)),f=p||g;if(a.user_is_a_contact&&!f)return!1;if(!a.user_is_a_contact&&f)return!1;break;case"device_type":if($(a.device_types)>0){let t="desktop";if(s.isMobile()&&(t="mobile"),s.isTablet()&&(t="tablet"),!V(a.device_types,(e=>rt(e)===rt(t))))return!1}break;case"referer":if($(a.exclude_referers)>0&&V(a.exclude_referers,(t=>rt(document.referrer).indexOf(rt(t))>-1)))return!1;if($(a.urls)>0&&!V(a.referers,(t=>rt(document.referrer).indexOf(rt(t))>-1)))return!1;break;case"source":if($(a.sources)>0){let t=s.matchTrafficSource()||"direct";if(!V(a.sources,(e=>rt(e)===rt(t))))return!1}break;case"user_attribute":case"user":let v,_=r.get(s.matchUser(),"attributes",[]),b=r.get(a,"user.operator");z(_,(t=>{t&&t.key===r.get(a,"user.key")&&(v=t.datetime||t.boolean||t.number||t.text||t.list)}));let w=!0;switch(b){case"cons":let t=m(a.value)||[];if(0===$(t))return!1;w=!!V(t,(t=>rt(v).indexOf(rt(t))>-1));break;case"notEmpty":w=!!v;break;case"empty":w=!v;break;case"true":w=!0===v||"true"===v;break;case"false":w=!v||!1===v||"false"===v}if(!w)return!1;break;case"timming":if("in"===a.business_hour&&!n.is_in_business_hour)return!1;if("notIn"===a.business_hour&&n.is_in_business_hour)return!1;if($(a.days_of_week)>0&&!V(a.days_of_week,(t=>rt(ft((new y).getDay()))===rt(t))))return!1;if($(a.minutes_of_day)>0&&$(a.minutes_of_day)%2==0){var c=new y,h=c.getMinutes()+60*c.getHours();let t=!1;for(let e=0;e<a.minutes_of_day.length;e+=2){if(a.minutes_of_day[e]<=h&&h<=a.minutes_of_day[e+1]){t=!0;break}if(a.minutes_of_day[e]>a.minutes_of_day[e+1]&&(h>=a.minutes_of_day[e]||h<=a.minutes_of_day[e+1])){t=!0;break}}if(!t)return!1}break;case"offline":if(!n.is_online!=!!a.offline)return!1}}return!0}function ft(t){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t]}let vt={};function _t(t,e){for(var i=0;i<t.length;i++){let e=t[i];if(e&&!vt[e]){vt[e]=!0;for(var s=0;s<2;s++){let t=[400,500][s],i=document.createElement("div");i.innerHTML="@!-/#Chào mỪng1",i.style.position="absolute",i.style.display="block",i.style.opacity="0.1",i.style.color="transparent",i.style.fontSize="20px",i.style.height="0px",i.style.top="0px",i.style.width="0px",i.style.fontWeight=t,i.setAttribute("subiz-preload",e+":"+t),document.body.appendChild(i),i.style.fontFamily=e,w((()=>i.remove()),3e3)}}}}function yt(t,e){if(e||(e=()=>{}),!t)return e(),Promise.resolve(!0);let i=new Image;return t=function(t){let e="https://vcdn.subiz-cdn.com/file/";return t?O(t,"/")||O(t,"data:")?t:(O(t,"http://")||O(t,"https://")||O(t,"//")||(t=W(e)+"/"+B(t,"/")),t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("https://file-subiz.com/",e)).replace("http://file-subiz.com/",e)).replace("https://file-v4.subiz.com/",e)).replace("http://file-v4.subiz.com/",e)).replace("https://filev4.subiz.com/",e)).replace("http://filev4.subiz.com/",e)).replace("https://filev4-1.subiz.com/",e)).replace("http://filev4-1.subiz.com/",e)).replace("https://file.subiz.com/",e)).replace("http://file.subiz.com/",e)).replace("https://file.mysubiz.com/",e)).replace("http://file.mysubiz.com/",e)):""}(t),i.src=t,new Promise((t=>{i.onload=()=>{e(),t()}}))}function bt(t){if(!t)return 0;t.length<=2&&(t+=":00");let e=t.split(":");if(2!==e.length)return 0;let i=parseInt(e[0]);if(i<0||i>23)return 0;let s=parseInt(e[1]);return s<0||s>59?0:60*i+s}function wt(t,e,i){var s=-(new y).getTimezoneOffset();i&&(s=bt(i));var r=new y(t).getTime(),n=new y(e).getTime(),o=Math.ceil((r/60/1e3+s)/60/24),a=Math.ceil((n/60/1e3+s)/60/24);return Math.abs(o-a)}function kt(t,e,i){var s=-(new y).getTimezoneOffset(),r=-(new y).getTimezoneOffset();i&&(r=bt(i));var n=new y(t).getTime()+60*(r-s)*1e3,o=new y(e).getTime()+60*(r-s)*1e3;return Math.abs(new y(n).getYear()-new y(o).getYear())}function At(t,e,i){return 0===wt(t,e,i)}function xt(t,e,i,s){var n=-(new y).getTimezoneOffset(),o=n;e&&(o=bt(e));var a=new y(St(t));let l=new y(a);l.setMinutes(a.getMinutes()+o-n),i||(i=new y);let c=l.getHours(),h=l.getMinutes(),u=r.get(navigator,"languages.0","en-US");s&&(u=s);let d=l.toLocaleDateString(u,{weekday:"long"}),p=l.getFullYear(),m=l.getMonth()+1,g=l.toLocaleDateString(u,{month:"long"}),f=l.getDate();return c<10&&(c="0"+c),h<10&&(h="0"+h),At(a,i,e)?c+":"+h:wt(a,i,e)<=5?d+", "+c+":"+h:0===kt(a,i,e)?"vi-VN"===u?f+" "+g+", "+c+":"+h:g+" "+f+", "+c+":"+h:"vi-VN"===u?f+"/"+m+"/"+p+", "+c+":"+h:p+"/"+m+"/"+f+", "+c+":"+h}function Ct(t){return Math.floor(St(t)/1e3)}function St(t){return t?"number"!=typeof t&&(t=new y(t).getTime()):t=0,t>1e18?Math.floor(t/1e6):t>1e15?Math.floor(t/1e3):t>1e12?t:1e3*t}function Mt(){let t=Pt("sbz_locale"),e=document.getElementsByTagName("html")[0].getAttribute("xml:lang")||document.getElementsByTagName("html")[0].getAttribute("lang"),i=navigator.language;return t||e||i}function Pt(t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var e=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(location.search);return null===e?"":decodeURIComponent(e[1].replace(/\+/g," "))}var Et=t=>new Promise((e=>w(e,t)));function jt(t,e="VND"){let i=Dt.find((t=>t.code===e))||{name:"Dong",code:"VND",symbol:"₫"},s="",r="";return"VND"===e?(s="",r=" "+i.symbol):(s=i.symbol+" ",r=""),t?s+(t=Math.round(t)).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")+r:`${s}0${r}`}function It(t){return(t=(t+="").replaceAll("đ","d").replaceAll("Đ","D")).normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Tt(t){centerIfNeeded=0===arguments.length||!!centerIfNeeded;var e=t.parentNode,i=window.getComputedStyle(e,null),s=parseInt(i.getPropertyValue("border-top-width")),r=parseInt(i.getPropertyValue("border-left-width")),n=t.offsetTop-e.offsetTop<e.scrollTop,o=t.offsetTop-e.offsetTop+t.clientHeight-s>e.scrollTop+e.clientHeight,a=t.offsetLeft-e.offsetLeft<e.scrollLeft,l=t.offsetLeft-e.offsetLeft+t.clientWidth-r>e.scrollLeft+e.clientWidth,c=n&&!o;(n||o)&¢erIfNeeded&&(e.scrollTop=t.offsetTop-e.offsetTop-e.clientHeight/2-s+t.clientHeight/2),(a||l)&¢erIfNeeded&&(e.scrollLeft=t.offsetLeft-e.offsetLeft-e.clientWidth/2-r+t.clientWidth/2),(n||o||a||l)&&!centerIfNeeded&&t.scrollIntoView(c)}const Dt=[{code:"USD",symbol:"$"},{code:"VND",symbol:"₫"}];function Lt(t){return function(t){if(!t||!t.type)return"";let e="";if("bullet_list"==t.type||"ordered_list"==t.type)return L(t.content,(s=>{preifx="\n* ","ordered_list"==t.type&&(prefix=i+"\n. "),e+=prefix+Lt(s).trim()})),e;if("heading"!=t.type&&"paragraph"!=t.type||(e+="\n"),""==t.type||"text"==t.type||"link"==t.type||"mention-agent"==t.type||"dynamic-field"==t.type)return e+t.text;if("horizontal_rule"==t.type)return e+"\n---\n";if("emoji"==t.type){let i;if($(t.attrs)>0&&(i=t.attrs.code),""==i&&(i=t.text),""!=i){let t=V(LEXICAL_EMOJI_LIST,(t=>t.code===i));r.get(t,"text",i)}return e}return L(t.content,(t=>{e+=Lt(t)})),e}(t).trim()}function zt(t){return Ut(t)}function Ut(t={}){if(!$(t.content))return!(t.text||"").trim();let e=!0;return L(t.content,(t=>{e=e&&Ut(t)})),e}function Ft(t){if(!t||!t.split)return"";f.style.color=t;const e=g.contentWindow.getComputedStyle(f).color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)/);return e?{red:parseInt(e[1]),green:parseInt(e[2]),blue:parseInt(e[3])}:null}let Rt=["like","unlike","wink","tongue-out","tired","surprised","smiling","sleepy","sad","neutral","heart-eyes","grinning","crying","confused","angry","cry","heart_eyes","neutral_face","emoji--disappointed","smile","open_mouth","tired_face","stuck_out_tongue","moyai","thumbsdown","dislike","thumbsup","ok_hand","octopus","pig2","wave","mouse","mouse2","rat"];Rt=L(Rt,(t=>":"+t+":"))}},r={};function n(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={id:t,exports:{}};return s[t].call(i.exports,i,i.exports,n),i.exports}n.m=s,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.f={},n.e=t=>Promise.all(Object.keys(n.f).reduce(((e,i)=>(n.f[i](t,e),e)),[])),n.u=t=>"19680dc0775."+t+".js",n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t={},e="@subiz/widget-v4:",n.l=(i,s,r,o)=>{if(t[i])t[i].push(s);else{var a,l;if(void 0!==r)for(var c=document.getElementsByTagName("script"),h=0;h<c.length;h++){var u=c[h];if(u.getAttribute("src")==i||u.getAttribute("data-webpack")==e+r){a=u;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,n.nc&&a.setAttribute("nonce",n.nc),a.setAttribute("data-webpack",e+r),a.src=i),t[i]=[s];var d=(e,s)=>{a.onerror=a.onload=null,clearTimeout(p);var r=t[i];if(delete t[i],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((t=>t(s))),e)return e(s)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),l&&document.head.appendChild(a)}},n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.p="https://vcdn.subiz-cdn.com/widget-v4/public/",(()=>{var t={60:0};n.f.j=(e,i)=>{var s=n.o(t,e)?t[e]:void 0;if(0!==s)if(s)i.push(s[2]);else{var r=new Promise(((i,r)=>s=t[e]=[i,r]));i.push(s[2]=r);var o=n.p+n.u(e),a=new Error;n.l(o,(i=>{if(n.o(t,e)&&(0!==(s=t[e])&&(t[e]=void 0),s)){var r=i&&("load"===i.type?"missing":i.type),o=i&&i.target&&i.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",a.name="ChunkLoadError",a.type=r,a.request=o,s[1](a)}}),"chunk-"+e,e)}};var e=(e,i)=>{var s,r,[o,a,l]=i,c=0;if(o.some((e=>0!==t[e]))){for(s in a)n.o(a,s)&&(n.m[s]=a[s]);l&&l(n)}for(e&&e(i);c<o.length;c++)r=o[c],n.o(t,r)&&t[r]&&t[r][0](),t[r]=0},i=self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[];i.forEach(e.bind(null,0)),i.push=e.bind(null,i.push.bind(i))})(),(()=>{"use strict";var t=n(5922);function e(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const i=n(318);function s(e,i){let s=e.request;"text/plain"===s.content_type&&void 0!==s.body&&(s.body=t.A.stringify(s.body)),i(!0)}i.env.XMLHttpRequest=t.A.XMLHttpRequest;const r=class{constructor(r,n){e(this,"listConversations",(t=>this.apireq.addQuery("user_id",this.uid).addQuery("integration_id",`${this.accid}.subizv4.subikon`).get(`/accounts/${this.accid}/conversations`))),e(this,"listMessages",((t,e,i)=>this.apireq.addQuery("limit",e).addQuery("start_id",i).get(`/accounts/${this.accid}/conversations/${t}/messages`))),e(this,"ajax",i),e(this,"start",(e=>{let i={touchpoint:{channel:"subiz",source:"web"}};return t.A.each(e,((t,e)=>{i[e]=t})),this.apireq.post(`/accounts/${this.accid}/conversations`,i)})),e(this,"sendConvoEvent",((e,i)=>this.apireq.addQuery("x-referer",t.A.get(location,"origin","")).post(`/accounts/${this.accid}/conversations/${e}/events`,i))),e(this,"createPostback",((t,e)=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/postbacks`,e))),e(this,"markAsReceived",((t,e)=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/messages/${e}/receive`))),e(this,"markAsSeen",((t,e)=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/messages/${e}/seen`))),e(this,"getConversation",(t=>this.apireq.get(`/accounts/${this.accid}/conversations/${t}`))),e(this,"getLocaleContent",(t=>this.apireq.get(`/accounts/${this.accid}/locales/${t}`))),e(this,"sendEvent",(e=>this.apireq.addQuery("shorten",!0).addQuery("x-referer",t.A.get(location,"origin","")).post(`/accounts/${this.accid}/users/${this.uid}/events`,e))),e(this,"submitForm",((e,i,s,r,n)=>this.apireq.addQuery("x-referer",t.A.get(location,"origin","")).post(`/accounts/${this.accid}/users/${this.uid}/events`,{by:{id:this.uid,device:s},type:"form_submitted",data:{user:n,form_submission:{user_id:this.uid,form_id:e,page_url:i,submitted_at:t.A.Date.now(),values:r}}}))),e(this,"sendTyping",(t=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/typing`))),e(this,"sendLostFocus",(()=>this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`))),e(this,"uploadToS3",(async t=>{let{body:e,error:s}=await this.apireq.post(`/accounts/${this.accid}/files`,{account_id:this.accid,description:"upload\n user-client: web-widget",name:t.name.replace(/\s+/g,"_"),size:t.size,type:t.type});if(s)return{body:e,error:s};let r,n=t.type||"application/octet-stream";return({error:s}=await i.setContentType(n).put(e.signed_url,t)),s?{error:s}:(({body:r,error:s}=await this.apireq.post(`/accounts/${this.accid}/files/${e.id}`,{account_id:this.accid})),s?{body:r,error:s}:{url:r.url})})),e(this,"time",(t=>i.setBaseUrl(this.ApiURL).withCredentials(!0).setParser("json").get("/time"))),e(this,"updateUser",(t=>this.apireq.post(`/accounts/${this.accid}/users/${this.uid}`,t))),e(this,"getUser",(t=>this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`))),e(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),e(this,"sendImpression",(t=>this.apireq.post(`/accounts/${this.accid}/campaigns/${t.campaign_id}/impressions`,t))),e(this,"sendConversion",(t=>this.apireq.post(`/accounts/${this.accid}/campaigns/${t.campaign_id}/conversions`,t))),e(this,"lookupOrder",(t=>i.setBaseUrl(this.ApiURL).setContentType("text/plain").beforeHook(s).setParser("json").addQuery("x-signed-key",t).get("/orders/123"))),e(this,"getOrder",(t=>this.apireq.get(`/accounts/${this.accid}/orders/`+t))),e(this,"updateOrder",(t=>this.apireq.post(`/accounts/${this.accid}/orders/`+t.id,t))),e(this,"fetchShippingAddresses",(()=>this.apireq.get(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`))),e(this,"createShippingAddress",(t=>this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`,t))),e(this,"list_provinces",(()=>this.apireq.get(`/accounts/${this.accid}/provinces`))),e(this,"list_districts",(t=>this.apireq.setQuery(t).get(`/accounts/${this.accid}/districts`))),e(this,"list_wards",(t=>this.apireq.setQuery(t).get(`/accounts/${this.accid}/wards`))),e(this,"checkFormToken",((t,e)=>this.api41.addQuery("account-id",t).get(`/submissions/${e}`))),e(this,"submitForm2",((t,e,i)=>this.api41.addQuery("account-id",t).post(`/submissions/${e}`,i))),e(this,"suggest_address",(t=>this.apireq.setQuery({keyword:t}).get(`/accounts/${this.accid}/addresses`))),e(this,"create_ticket",(t=>this.apireq.post(`/accounts/${this.accid}/tickets`,t))),this.refreshLock=new t.A.Mutex,this.FileURL=n,this.ApiURL=r,this.api41=i.setBaseUrl("https://api5.subiz.com.vn/4.1").withCredentials(!0).setContentType("text/plain").beforeHook(s).setParser("json"),this.apireq=i.setBaseUrl(r).withCredentials(!0).addQuery("v","6").setContentType("text/plain").beforeHook(s).setParser("json").beforeHook(((t,e)=>{if(!this.token_generator)return this.ref?t.request=t.request.addQuery("x-user-ref",this.ref):this.mask&&(t.request=t.request.addQuery("x-user-mask",this.mask)),e(!0);{let i=this.profile_id;this.token_generator().then((s=>i!=this.profile_id?e(!0):s?"error"==s?e(!1):(t.request=t.request.addQuery("x-access-token",s),e(!0)):e(!1)))}}))}setAgentId(t){this.agentid=t}async setAuth(e){if(e.accid&&(this.accid=e.accid),e.ref&&(this.ref=e.ref),this.mask=e.mask,this.profile_id=e.profile_id,e.ref){let e;for(let s=0;e=await i.setBaseUrl(this.ApiURL).withCredentials(!0).addQuery("v","6").addQuery("x-user-ref",this.ref).setParser("json").get(`/accounts/${this.accid}/users/${this.ref}`),-1==t.A.get(e,"body.error.code","").indexOf("locked_account");s++)if(-1==t.A.get(e,"body.error.code","").indexOf("user_is_banned")){if(t.A.get(e,"body.id"))break;{let e=Math.min(2e3+400*s,6e4);await t.A.sleep(e)}}else await t.A.sleep(12e4);return e.error?t.A.get(e.body.code)?{error:e.body.code}:e:(this.uid=e.body.id,e.body)}if(e.tokenGenerator){let s=e.tokenGenerator;this.tokensession=this.tokensession||0,this.tokensession++;let r=this.tokensession;if(!this.accid||!t.A.startsWith(this.accid,"ac"))return{error:"invalid_account_id"};if(!this.profile_id)return{error:"invalid_profile_id"};if("function"!=typeof s)return{error:"invalid_token_generator"};let n,o=this.profile_id;this.token_generator=async e=>{if(await this.refreshLock.lock(),r!=this.tokensession)return void this.refreshLock.unlock();let i,n,a=(t.A.Date.now()-(this.last_token_at||0))/1e3;if(!e&&this.last_token&&a<1800)return this.refreshLock.unlock(),this.last_token;if(!e&&this.last_token&&a<3e3)return this.token_generator&&t.A.setTimeout((async()=>{let e,i;try{e=await s(o)}catch(t){i=t}r==this.tokensession?(this.last_token=i?"error":e,this.last_token_at=t.A.Date.now(),this.refreshLock.unlock()):this.refreshLock.unlock()})),this.last_token;try{i=await s(o)}catch(t){n=t}if(r==this.tokensession)return this.last_token=n?"error":i,this.last_token_at=t.A.Date.now(),this.refreshLock.unlock(),this.last_token;this.refreshLock.unlock()};for(let e=0;await this.token_generator(!0),r==this.tokensession&&(n=await i.setBaseUrl(this.ApiURL).withCredentials(!0).addQuery("v","6").addQuery("x-access-token",this.last_token).setParser("json").get(`/accounts/${this.accid}/users/${o}`),!t.A.get(n,"body.id"));e++){let i=Math.min(2e3+100*e,12e4);await t.A.sleep(i)}return n.error?t.A.get(n.body.code)?{error:n.body.code}:n:(this.uid=n.body.id,n.body)}if(this.mask){let t=this.mask.split("@");return this.uid=t[1],{id:this.uid}}return{error:"invalid_auth"}}sendContentView(t,e,i,s,r,n){return s||(s=void 0),r||(r=void 0),this.sendEvent({by:{id:this.uid,device:t},type:"content_viewed",data:{product:{id:s,source_id:r,url:e,name:i,title:i,sku:n}}})}};let o=n(450),a="undefined"!=typeof window?window.requestIdleCallback:null;a||(a=t=>t());const l=class{constructor(t,e){if(this.localStorage=o,this.inmem=e,this.allkeys={},!e)try{window.localStorage.setItem("sbzstore1029","?"),window.localStorage.removeItem("sbzstore1029"),this.localStorage=window.localStorage}catch(t){}this.schema=t}all(e){let i=[];for(var s=0;s<this.localStorage.length;s++){let r=this.localStorage.key(s);r.startsWith(this.schema+"#"+e+"#")&&(this.allkeys[r]=!0,this.inmem?i.push(this.localStorage.getItem(r)):i.push(t.A.parseJSON(this.localStorage.getItem(r))))}return i}removes(t,e){for(var i=0;i<e.length;i++)delete this.allkeys[this.schema+"#"+t+"#"+e[i]],this.localStorage.removeItem(this.schema+"#"+t+"#"+e[i])}clear(t){for(var e=0;e<this.localStorage.length;e++){let i=this.localStorage.key(e);i.startsWith(this.schema+"#"+t+"#")&&this.localStorage.removeItem(i)}this.allkeys={}}put(t,e,i){if(this.allkeys[this.schema+"#"+t+"#"+e]=!0,this.inmem)return this.localStorage.setItem(this.schema+"#"+t+"#"+e,i);Object.keys(this.allkeys).length>80&&this.clear(t),a((()=>{try{this.localStorage.setItem(this.schema+"#"+t+"#"+e,void 0===(s=i)?"null":JSON.stringify(s))}catch(e){this.clear(t)}var s}))}};class c{constructor(t,e,i){this.schema=e+"_chain",this.dead=!1,this.db=t,this.anchorCache={},this.cache={},this.init()}init(){let t={};this.db.all("items").map((e=>{t[e.chain]=t[e.chain]||{},t[e.chain][e.id]={id:e.id,chain:e.chain,full_id:e.full_id,index:e.index,value:e.value}})),u(t,((e,i)=>{if(d(e)<50)return;let s=(r=u(e),n=["index"],o=[],u(r,(t=>o.push(t))),o.sort(((t,e)=>{if(t[n]===e[n])return 0;var i=t[n]<e[n]?-1:1;return-i})),o);var r,n,o;let a=[];for(var l=50;l<s.length;l++)a.push(s[l].full_id),delete e[s[l].id];this.db.removes("items",a),t[i]=e})),this.cache=t}destroy(){this.db.clear("items"),this.dead=!0,this.cache={},this.anchorCache={},this.db=void 0}put(t,e,i,s){if(this.dead)return;let r=this.cache[t]||{},n=(h(r)||{}).index||"z";0==d(r)&&(n="");let o={id:e,index:i,value:s,chain:t,full_id:t+":"+e};delete r[o.id],n>o.index+""||(r[o.id]=o,this.cache[t]=r,this.db.put("items",o.full_id,o))}listM(t){if(this.dead)return{};let e=this.cache[t]||{},i={};return u(e,((t,e)=>{i[e]=t.value})),i}async fetchMore(t,e=20,i){if(this.dead)return{error:"dead"};if(!i)return{error:"no api"};let s=this.anchorCache[t]||"";var[r,n,o]=await i(t,s,e);if(o)return{error:o};if(this.dead)return{error:"dead"};let a=this.cache[t]||{};return 0===r.length?{end:!0}:(r.forEach((e=>{e.chain=t,e.full_id=t+":"+e.id,a[e.id]=e,this.db.put("items",e.full_id,e)})),this.anchorCache[t]=n,this.cache[t]=a,{})}del(t,e){if(this.dead)return;let i=t+":"+e;delete(this.cache[t]||{})[e],this.db.removes("items",[i])}match(t,e){return this.listM(t)[e]}async reload(t,e){if(this.dead)return;let i=function(t){if(!t)return;let e=Object.keys(t);if(!e.length)return;let i=-1/0,s=Object.keys(t)[0];for(var r=0;r<e.length;r++){let n=t[e[r]]&&t[e[r]].index||-1/0;n>i&&(i=n,s=e[r])}return t[e[s]]}(this.listM(t))||{},s=i.index;s||(s=Date.now());for(var r="",n={};;){if(this.dead)return;let[i,o,a]=await e(t,r,50);if(a)return;if(this.dead)return;if(i.map((e=>{n[e.id]=Object.assign({},e,{chain:t,full_id:t+":"+e.id})})),0===i.length||o===r)break;if(n.length>=200){let e=this.cache[t]||{},i=[];u(e,(e=>{e.chain===t&&i.push(e.full_id)})),this.db.removes("items",i),this.cache[t]={};break}if((h(n)||{}).index<=s){r=this.anchorCache[t]||o;break}r=o}for(var o=0;o<Object.keys(n).length;o++){let t=n[Object.keys(n)[o]];this.db.put("items",t.full_id,t),this.cache[t.chain]=this.cache[t.chain]||{},this.cache[t.chain][t.id]=t}this.anchorCache[t]=r}}function h(t){if(!t)return;let e=Object.keys(t);if(!e.length)return;let i=1/0,s=Object.keys(t)[0];for(var r=0;r<e.length;r++){let n=t[e[r]]&&t[e[r]].index||1/0;n<i&&(i=n,s=e[r])}return t[s]}function u(t,e){if(!t)return[];if(!e)return t;var i=[];if(Array.isArray(t)){for(let s=0;s<t.length;s++)i.push(e(t[s],s));return i}if("object"==typeof t){var s=Object.keys(t);for(let n=0;n<s.length;n++){var r=s[n];i.push(e(t[r],r))}return i}return i}function d(t){return t?void 0!==t.length?t.length:Object.keys(t).length:0}const p=class{constructor(t,e){this.name=e,e+="_kv",this.dead=!1,this.db=t,this.cache={},this.initialized=!1,this.init()}refreshCache(){if(this.dead)return;let t={};this.db.all("items").forEach((function(e){t[e.key]=e.value})),this.cache=t}init(){if(this.initialized)return;let t={};console.time("KV"+this.name),this.db.all("items").forEach((function(e){t[e.key]=e.value})),this.cache=t;let e=Object.keys(this.cache);if(e.length>500){let t=250/e.lenth,s=[];for(var i=0;i<500;i++){if(Math.random()<=t)continue;let r=e[i];delete this.cache[r],s.push(r)}this.db.removes("items",[s])}this.initialized=!0,console.timeEnd("KV"+this.name)}all(){return this.dead?[]:this.initialized?this.cache:[]}match(t){if(!this.dead&&this.initialized&&t)return this.cache[t]}put(t,e){if(t){if(this.dead)return[];if(!this.initialized)throw new Error("uninitialized");this.cache[t]=e,this.db.put("items",t,{key:t,value:e})}}del(t){if(!this.dead){if(!this.initialized)throw new Error("uninitialized");delete this.cache[t],this.db.removes("items",[t])}}destroy(){this.db.clear("items"),this.dead=!0,this.db=void 0,this.cache=void 0,this.initialized=!1}};function m(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const g=n(318);function f(e,i){let s=e.request;"text/plain"===s.content_type&&void 0!==s.body&&(s.body=t.A.stringify(s.body)),i(!0)}g.env.XMLHttpRequest=window.XMLHttpRequest;const v=Promise.resolve({code:200}),_=class{constructor(e,i){m(this,"listConversations",(t=>{let e=y(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid);return Promise.resolve({body:{anchor:"",conversations:[e]},code:200})})),m(this,"listMessages",((t,e,i)=>{let s=function(t,e,i,s){let r=t+".subizv4.subikon",n={type:"user",id:i,last_page_view_url:"https://subiz.com.vn/",conversation_id:e,membership:"active",invited_by:{id:i,type:"user"}},o={type:"agent",conversation_id:e,id:s,membership:"active",invited_by:{id:i,type:"user"}};return[{id:"evqyiyjmxrjsylftvnrghrfmq",account_id:t,created:1616213202264,type:"conversation_invited",by:{id:i,type:"user"},data:{conversation:{id:e,account_id:t,members:[n],state:"pending"}}},{id:"evqyiyjmyqdgrouswczzawuzp",account_id:t,created:1616213202559,type:"conversation_invited",by:{id:i,type:"user"},data:{conversation:{id:e,account_id:t,members:[o],state:"pending",source:"https://subiz.com.vn/vi/"}}},{id:"evqyiyjmyzjpyehnngvmcyauf",account_id:t,created:1616213202668,type:"conversation_state_updated",by:{id:i,type:"user"},data:{conversation:{id:e,account_id:t,state:"active"}}},{id:"evqyiyjmzaozvqgbkljbwywdl",account_id:t,created:1616213202683,type:"conversation_joined",by:{id:i,type:"user"},data:{conversation:{id:e,members:[n]}}},{id:"evqyiyjmzatvtgpdmmpzwnwgn",account_id:t,created:1616213202685,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"Xin chào",format:"plaintext",idempotency_key:"wrueysyjbhqrkiwhsejpqrwqrdkkyaibajdw",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213203068}]}}},{id:"evqyiyjrhsfyuxtetszmvkkke",account_id:t,created:1616213237491,type:"conversation_joined",by:{id:i,type:"user"},data:{conversation:{id:e,members:[o]}}},{id:"evqyiyjrhtroknjyakrlrwhgr",account_id:t,created:1616213237508,type:"message_sent",by:{id:s,client_id:"dashboard",type:"agent"},data:{message:{conversation_id:e,text:"chào bạn, mình có thể giúp gì được cho bạn :grinning:",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"receive",created:1616213237742},{member_id:i,type:"seen",created:1616213240057}]}}},{id:"evqyiyjuvjinmclneroerxmrl",account_id:t,created:1616213265805,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"mình muốn hỏi giá sản phẩm IPhone X",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213267090}]}}},{id:"evqyiyjzjxzfcsexshcjbbnnf",account_id:t,created:1616213302432,type:"message_sent",by:{id:s,client_id:"dashboard",type:"agent"},data:{message:{conversation_id:e,text:"IPhone X hiện đang được bán tại cửa hàng với giá 12tr đồng nha bạn",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"receive",created:1616213302698},{member_id:i,type:"seen",created:1616213305071}]}}},{id:"evqyiykaoizbwnkaecwphttwk",account_id:t,created:1616213311830,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"ok cám ơn!",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213312110}]}}}]}(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid);return Promise.resolve({body:s,code:200})})),m(this,"ajax",g),m(this,"start",(t=>v)),m(this,"sendConvoEvent",((t,e)=>v)),m(this,"createPostback",((t,e)=>v)),m(this,"markAsReceived",((t,e)=>v)),m(this,"markAsSeen",((t,e)=>v)),m(this,"getConversation",(t=>Promise.resolve({body:y(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid),code:200}))),m(this,"getLocaleContent",(t=>this.apireq.get(`/accounts/${this.accid}/locales/${t}`))),m(this,"sendEvent",(t=>v)),m(this,"submitForm",((t,e,i,s,r)=>v)),m(this,"sendTyping",(t=>v)),m(this,"sendPresence",(t=>v)),m(this,"sendContent",(t=>v)),m(this,"sendLostFocus",(t=>v)),m(this,"sendContentView",(t=>v)),m(this,"uploadToS3",(async t=>v)),m(this,"time",(e=>Promise.resolve({code:200,body:(new t.A.Date).toISOString()}))),m(this,"updateUser",(t=>v)),m(this,"getUser",(t=>Promise.resolve({code:200,body:{id:"usqzgtgfake",attributes:[{key:"fullname",text:"Kiều Thanh"}]}}))),m(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),m(this,"sendImpression",(t=>v)),m(this,"sendConversion",(t=>v)),this.FileURL=i,this.apireq=g.setBaseUrl(e).setContentType("text/plain").beforeHook(f).setParser("json")}setAgentId(t){this.agentid=t}setAuth(t){return this.accid=t.accid,this.mask=t.mask,this.uid=t.uid,{account_id:this.accid,id:"usqzgtgfake",attributes:[{key:"fullname",text:"Kiều Thanh"}]}}};function y(t,e,i,s){return{id:e,account_id:t,created:1610452894916,members:[{type:"user",id:i,membership:"active",invited_by:{id:i,type:"user"}},{type:"agent",id:s,conversation_id:e,membership:"active",invited_by:{id:i,type:"user"}}],ended:1610454875505,state:"ended",actived:1610453070259,last_message_sent:{id:"evqyiykaoizbwnkaecwphttwk",account_id:t,created:1616213311830,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"ok cám ơn!",format:"plaintext",integration_id:t+".subizv4.subikon",pongs:[{member_id:i,type:"seen",created:1616213312110}]}}},assigned_to:{},first_message:"Xin chào",subject:"Chúc một ngày tốt lành",source:"https://subiz.com.vn/"}}const b=class{onEvent(){}onInterrupted(){}subscribe(){}stop(){}getStatus(){return"active"}reconnect(){}};function w(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var k=n(8193),A=n(2839),x=n(5672);x.defaults.path="/",x.expiresMultiplier=86400,x.defaults.expires=3650;const C=t.A.Date.now();class S{constructor(e,i,s,n,o){if(w(this,"inmem",!1),w(this,"cookie",x),w(this,"getConnectionStatus",(()=>this.connectionStatus)),w(this,"_currentViewingProduct",{}),w(this,"new_visitor",!0),w(this,"matchUser",(()=>(this._touchAcc(),this.cache.match("user")))),w(this,"suggest_addresses",(t=>this.api.suggest_address(t))),w(this,"matchAccount",(()=>this.cache.match("account"))),w(this,"matchPaymentMethods",(()=>this.cache.match("payment_methods"))),w(this,"matchUnread",(()=>{let e=this.matchUser(),i=this.matchConvo("*"),s=0;return t.A.map(i,(i=>{t.A.isConvoSeen(i,e.id)||s++})),s})),w(this,"matchPlugin",(()=>t.A.size(this.forcePlugins)>0?t.A.cloneDeep(this.forcePlugins):t.A.cloneDeep(this.cache.match("plugin"))||{})),w(this,"device",{}),w(this,"browserVisibility","visible"),w(this,"matchAgent",(t=>{let e=this.cache.match("agent")||{};return"*"===t?e:e[t]})),w(this,"matchConvo",(e=>{if(e)return"*"===e?(this._touchAcc(),t.A.filter(this.cache.all(),((t,e)=>e.startsWith("convo_")))):(this.isInsync(e)||this.fetchConvo(e),this.cache.match("convo_"+e))})),w(this,"fetchConvo",(async t=>{if(this._die)return D;if(await this.readyGate.entry(),await this.reconnectGate.entry(void 0,!0),this.isInsync(t))return this.reconnectGate.open();this.markSync(t);let{body:e,error:i}=await this.api.getConversation(t);return e&&!i&&this._setConvo(e),this.reconnectGate.open()})),w(this,"list_provinces",(()=>this.api.list_provinces())),w(this,"list_districts",(t=>this.api.list_districts(t))),w(this,"list_wards",(t=>this.api.list_wards(t))),w(this,"outofmsgM",{}),w(this,"listEvents",(t=>{if(t&&"*"!==t&&"string"==typeof t)return this.chain.listM(t)})),w(this,"fetchMoreEvents",(async t=>{if(!this.isInsync("events"+t)){if(await this.readyGate.entry(),await this.reconnectGate.entry(void 0,!0),this.isInsync("events"+t))return this.reconnectGate.open(),{};this.markSync("events"+t),await this.chain.reload(t,(()=>[[],""]));let e=await this._doFetchMsg(t);return this.reconnectGate.open(),e}return this._doFetchMsg(t)})),w(this,"_doFetchMsg",(async t=>{let{error:e}=await this.chain.fetchMore(t,150,(async(e,i,s)=>{if(this.outofmsgM[t])return[[],""];let[r,n,o,a]=await this.listmessageapi(e,i,s);return a&&(this.outofmsgM[t]=!0),[r,n,o]}));return this.pubsub.publish("account"),{error:e}})),w(this,"matchLocation",(()=>this.cache.match("location")||{})),w(this,"matchBot",(()=>this.cache.match("bot")||{})),w(this,"readyGate",new t.A.Gate),w(this,"convoGate",new t.A.Gate(!0)),w(this,"reconnectGate",new t.A.Gate(!0)),w(this,"wsGate",new t.A.Gate(!0)),w(this,"matchLastview",(()=>{let t=this.kv.match("lastview")||{},e=this.cache.match("user")||{};return e.id?t.user_id!=e.id?{}:t:{}})),w(this,"matchIsOpen",(()=>!!this.kv.match("isopen"))),w(this,"matchHasManuallyClosed",(()=>!!this.kv.match("hasManuallyClosed"))),w(this,"matchClosePreviewAt",(()=>this.kv.match("close_preview_at")||0)),w(this,"checkFormToken",((t,e)=>this.api.checkFormToken(t,e))),w(this,"submitForm2",((t,e,i)=>this.api.submitForm2(t,e,i))),w(this,"sendPresence",t.A.throttle((async()=>this._die?D:(await this.readyGate.entry(),t.A.get(this.cache.match("user"),"id")&&!t.A.isUserBanned(this.cache.match("user"))&&this._track_page_view?"visible"===this.browserVisibility&&document.hasFocus()?void this.api.sendContentView(this.device,location.href,document.title,this._currentViewingProduct.id,this._currentViewingProduct.source_id,this._currentViewingProduct.sku):this.api.sendLostFocus():void 0)),1e3,{leading:!1})),w(this,"now",(()=>t.A.Date.now()+this.timeDiff)),w(this,"seenQueue",[]),w(this,"matchTrafficSource",(()=>this.kv.match("traffic_source"))),w(this,"_alreadyReceived",{}),w(this,"_typing",t.A.throttle((t=>this.api.sendTyping(t)),3e3,{trailing:!1})),w(this,"onConvoEvent",((t,e)=>this.pubsub.on2(t,"events",e))),w(this,"onWidgetClose",((t,e)=>this.pubsub.on2(t,"sbz_close_widget",e))),w(this,"seenConvo",(t=>{t&&"create"!==t&&this.seenQueue.push(t)})),w(this,"onUpdate",((t,e)=>this.pubsub.on2(t,"account",e))),w(this,"onConnection",((t,e)=>this.pubsub.on2(t,"connection",e))),w(this,"onResetCSS",((t,e)=>this.pubsub.on2(t,"resetCSS",e))),w(this,"onHighlight",((t,e)=>this.pubsub.on2(t,"highlight",e))),w(this,"setHasManuallyClosed",(()=>this.kv.put("hasManuallyClosed",!0))),w(this,"setIsOpen",(t=>{let e=this.kv.match("isopen");this.kv.put("isopen",t),!e&&t&&E("SUBIZ Chat","Opened","Subiz Windows")})),w(this,"closePreview",(()=>this.kv.put("close_preview_at",(new t.A.Date).getTime()))),w(this,"setLastview",((t,e)=>{let i=this.cache.match("user")||{};i.id&&this.kv.put("lastview",{user_id:i.id,view:t,opts:e})})),w(this,"timeDiff",0),this.connectionStatus="active",this.CONNECTION_CHECK_INTERVAL=3e3,this.reconnectTimestamp=0,this.g_sync={},this._die=!1,this.forceDevice=null,this.forcePlugins={},this.forceAcc={},this.forceChatbox={},this.RealtimeURL=s,this.fake=o,this.FileURL=i,this._track_page_view=!0,this.device_type="desktop",this.fake?this.api=new _(e,i):this.api=new r(e,i),!n)try{document.cookie,localStorage}catch(t){n=!0}n&&(this.inmem=n,this.cookie=P),j(),this.pubsub=new t.A.Pubsub,this.kv=new p(new l("sbz2023",this.inmem),"kv"),this.cache=new p(new l("sbz2023",!0),"kv"),this.chain=new c(new l("cbz2023",!0),"ch"),this.getLocaleContent=this.api.getLocaleContent,this.g_haveSentSeenM={},this.last_focused=t.A.Date.now(),window.addEventListener("blur",(()=>{this.last_focused=t.A.Date.now(),this.sendPresence()})),window.addEventListener("focus",(()=>{this.last_focused=0,this.sendPresence()})),window.addEventListener("beforeunload",(()=>this.api.sendLostFocus())),this.doNotStartBot=()=>{this._donotstartbot=!0},this.autoStartBot=()=>{this._donotstartbot=!1},this.matchAutoStartBot=()=>!this._donotstartbot,this._presenceInterval1=t.A.setInterval((()=>{if(this._die)return t.A.clearInterval(this._presenceInterval1);"visible"===this.browserVisibility&&document.hasFocus()&&this.sendPresence()}),2e4),this._presenceInterval2=t.A.setInterval((()=>{if(this._die)return t.A.clearInterval(this._presenceInterval2);"visible"===this.browserVisibility&&document.hasFocus()||this.last_focused&&t.A.Date.now()-this.last_focused>18e5||this.sendPresence()}),6e4),function(t){var e="hidden";function i(i){var s="visible",r="hidden",n={focus:s,focusin:s,pageshow:s,blur:r,focusout:r,pagehide:r};(i=i||window.event).type in n?t(n[i.type]):t(this[e]?"hidden":"visible")}e in document?document.addEventListener("visibilitychange",i):(e="mozHidden")in document?document.addEventListener("mozvisibilitychange",i):(e="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",i):(e="msHidden")in document?document.addEventListener("msvisibilitychange",i):"onfocusin"in document?document.onfocusin=document.onfocusout=i:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=i,void 0!==document[e]&&i({type:document[e]?"blur":"focus"})}((t=>{this._die||(this.browserVisibility=t,this.sendPresence())})),this.loopTime(),this.device=this.getDeviceInfo();const a=t.A.setInterval((()=>{let e=this.cache.match("user")||{};if(!e.id)return;var i=this.getDeviceInfo();if(!i.ga_tracking_ids||!i.ga_client_id)return;t.A.clearInterval(a),this.device=i;let s=i.ga_client_id;s!==t.A.getUserAttr(e,"ga_client_id","text")&&this.setUser({attributes:[{type:"text",text:s,key:"ga_client_id"}]})}),2e3)}async loopCheckConnectionStatus(){for(;!this._die;){if(await t.A.sleep(this.CONNECTION_CHECK_INTERVAL),!this.realtime)continue;if(!this.realtime.getStatus||!this.realtime.reconnect)continue;"dead"===this.connectionStatus&&await this.realtime.reconnect();let e=this.connectionStatus;this.connectionStatus=this.realtime.getStatus(),e!==this.connectionStatus&&(console.log("publish connectionStatus",this.connectionStatus),this.pubsub.publish("connection"))}}linkProduct(t){t?(t.id&&(this._currentViewingProduct.id=(t.id+"").trim()),t.source_id&&(this._currentViewingProduct.source_id=(t.source_id+"").trim()),t.sku&&(this._currentViewingProduct.sku=(t.sku+"").trim())):this._currentViewingProduct={}}getTrackPageview(){return this._track_page_view}setTrackPageview(t){this._track_page_view=!!t}getLinkedProduct(){return t.A.cloneDeep(this._currentViewingProduct)}isInsync(e){return t.A.Date.now()-(this.g_sync[e]||0)<6e5}async fetchShippingAddresses(){let t=await this.api.fetchShippingAddresses();if(t.error)return null;this.cache.put("shipping_address",t.body.shipping_addresses)}matchShippingAddresses(){return this.cache.match("shipping_address")}updateOrder(t){return this.api.updateOrder(t)}createShippingAddress(t){return this.api.createShippingAddress(t)}createTicket(t){return this.api.create_ticket(t)}async overrideAcc(e){this.forceAcc=t.A.cloneDeep(e),await this.readyGate.entry(),this.reconnect()}async overrideChatbox(e){this.forceChatbox=e,await this.readyGate.entry(),await this.reconnect(),t.A.setTimeout(this.pubsub.publish("resetCSS"),10)}getDeviceInfo(){let t={screen_resolution:window.screen.width+"x"+window.screen.height,source_referrer:document.referrer,platform:window.navigator.platform,language:navigator.language,page_url:document.URL,page_title:document.title},e=function(){if(!window.ga)return;if(!window.ga.getAll)return;var t=window.ga.getAll()||[];let e="";return t.forEach((function(t){e=t.get("clientId")})),e}();e&&(t.ga_client_id=e);let i=(s=[],window.ga&&window.ga.getAll?window.ga&&window.ga.getAll?((window.ga.getAll()||[]).forEach((function(t){var e=t.get("trackingId");e&&s.push(e)})),s):[]:s);var s;return i.length>0&&(t.ga_tracking_ids=i),t}highlight(t,e){this.pubsub.publish("highlight",t,e)}emitConvoEvent(t){this.pubsub.publish("events",t)}setAIDevMode(t){this.ai_dev_mode=t}isAIDevMode(){return this.ai_dev_mode}overrideDeviceType(t){this.forceDevice=t,this.pubsub.publish("account")}isMobile(){return this.forceDevice?"mobile"===this.forceDevice:"mobile"==this.device_type||t.A.get(window,"screen.width",1e3)<576}isTablet(){return this.forceDevice?"tablet"===this.forceDevice:"tablet"==this.device_type}isDesktop(){return this.forceDevice?"desktop"===this.forceDevice:!this.isMobile()&&!this.isTable()}disconnect(t){this.g_sync[t]=0}pageLoaded(){return C}overridePlugin(e){if(this._die)return D;if(!Array.isArray(e))throw"plugins must be be an array";let i={};t.A.map(e,(function(t){i[t.id]=t})),this.forcePlugins=i,this.pubsub.publish("account"),this.pubsub.publish("resetCSS")}markSync(e){this.g_sync[e]=t.A.Date.now()}async _touchAcc(){this.isInsync("account")||(await this.readyGate.entry(),this.isInsync("account")||this.reconnect())}async init(e,i,s,r){if(this.readyGate.close(),e=(e||"").trim(),this.g_sync={},r&&r.use_subdomain_cookie||window&&window.location&&window.location.hostname&&(x.defaults.domain="."+window.location.hostname),!s){try{s=this.cookie.get("__sbref","")}catch(t){}if(!s){if(!i)try{i=this.cookie.get("__sbmask","")}catch(t){}i?(i.split("@")[0]!=e&&(s=t.A.randomString(40),this.new_visitor=!0),this.new_visitor=!1,this.cookie.set("__sbmask",i)):(s=t.A.randomString(40),this.new_visitor=!0)}}this.cookie.get("__sbref",s)!=s&&I(),this.api.setAuth({accid:e}),s&&this.cookie.set("__sbref",s);let n=await this.api.setAuth({accid:e,mask:i,ref:s});return n.error?console.error(n):(this.realtime&&this.realtime.stop(),this.fake?this.realtime=new b:this.realtime=new A(this.RealtimeURL,{account_id:e,user_ref:s,user_mask:i},T),this.realtime.onEvent(this.onWs.bind(this)),this.realtime.onInterrupted((async()=>{await this.reconnectWs(e,n.id),this.reconnect()})),this.seenLoop(),await this.reconnect({user:n}),this.readyGate.open(),this.reconnectWs(e,n.id),this.loopCheckConnectionStatus(),n)}async login(t,e,i){if(this._die)return D;let s=await this.api.setAuth({accid:t,profile_id:e,tokenGenerator:i});return s.error||(this.clearBrowserData(),this.readyGate.close(),t=(t||"").trim(),this.g_sync={},this.new_visitor=!1,this.realtime&&this.realtime.stop(),this.fake?this.realtime=new b:this.realtime=new A(this.RealtimeURL,{getAccessToken:()=>this.api.token_generator()}),this.realtime.onEvent(this.onWs.bind(this)),this.realtime.onInterrupted((async()=>{await this.reconnectWs(t,s.id),this.reconnect()})),this.seenLoop(),await this.reconnect(),this.readyGate.open(),this.reconnectWs(t,s.id)),s}logout(t){return this.api.setAuth({ref:t})}seenLoop(){this.seenQueue=[],t.A.clearInterval(this._seenInterval),this._seenInterval=t.A.setInterval((()=>{if(this._die)return t.A.clearInterval(this._seenInterval);this.seenQueue=[...new Set(this.seenQueue)];let e=this.cache.match("user")||{};t.A.map(this.seenQueue,(i=>{var s=this.listEvents(i);if(!s)return;if(0===t.A.size(s))return;var r=(s=t.A.filter(s,(t=>"message_sent"===t.type)))[t.A.size(s)-1];if(!r)return;if(this.g_haveSentSeenM[r.id])return;if(r.id===r.data.message.idempotency_key)return;this.api.markAsSeen(i,r.id),this.pubsub.publish("events",{created:t.A.Date.now(),type:"message_pong",by:{type:"user"},data:{message:{conversation_id:i,id:"*",pongs:[{type:"seen",created:t.A.Date.now()}]}}});let n=this.cache.match("convo_"+i)||{},o=t.A.find(n.members,(t=>t.id===e.id));o&&(o.seen_at=t.A.Date.now()),this._setConvo(n),this.g_haveSentSeenM[r.id]=!0})),this.seenQueue=[]}),1e3)}async reconnectWs(t,e){await this.realtime.subscribe([`conversation_state_updated.account.${t}.user.${e}`,`conversation_joined.account.${t}.user.${e}`,`conversation_typing.account.${t}.user.${e}`,`message_sent.account.${t}.user.${e}`,`message_pong.account.${t}.user.${e}`,`conversation_rating_requested.account.${t}.user.${e}`,`conversation_rated.account.${t}.user.${e}`]),await this.readyGate.entry()}async reconnect(e){if(this._die)return;await this.reconnectGate.entry(void 0,!0),this.markSync("account");let i=e&&e.user?Promise.resolve({body:e.user}):this.api.getUser(),s=await Promise.all([i,this.api.getAccountSetting()]),r=t.A.find(s,(t=>t.error));if(r)return console.error(r);let n=s[1].body;n.user=s[0].body,await this._setSetting(n);let o=await this.api.listConversations();r=o.error;let a=o.body;if(!r){let e=t.A.get(a,"conversations",[]);t.A.map(this.cache.all(),((e,i)=>{i.startsWith("convo_")&&this.now()-t.A.getMs(t.A.get(e,"actived"))>12096e5&&this.cache.del(i)})),t.A.map(e,(t=>this._setConvo(t)))}return this.reconnectGate.open()}async submitForm(t,e,i){return await this.readyGate.entry(),i&&await this.setUser(i),this.api.submitForm(t,document.URL,this.device,e,i)}async setUser(t){if(t)return await this.readyGate.entry(),this._setUser(t),this.api.updateUser(t)}async setUserDiff(t){if(!t)return;await this.readyGate.entry();let e=await this.api.updateUser(t);e&&200==e.code&&e.body.id&&this._setUser(e.body)}_setUser(e){e=t.A.cloneDeep(e);let i=this.cache.match("user")||{};var s=i.account_id||e.account_id,r=i.id||e.id;t.A.each(e.attributes,(e=>{e&&(i.attributes=t.A.filter(i.attributes,(t=>!!t&&t.key!==e.key)))})),i.attributes=i.attributes||[],i.attributes=i.attributes.concat(e.attributes),i.account_id=s,i.id=r,this.cache.put("user",i),this.pubsub.publish("account")}async setSetting(t){if(t)return await this.readyGate.entry(),this._setSetting(t)}async _setSetting(e){(e=t.A.cloneDeep(e)||{}).account=Object.assign({},e.account,this.forceAcc),e.account.logo_url||(e.account.logo_url="https://vcdn.subiz-cdn.com/file/fiqpezhkmeyesdscyetk-default_logo.jpg"),e.user&&(e.user.account_id=e.account.id,delete e.user.session,this._setUser(e.user)),e.account&&(e.account.is_online=e.is_online,e.account.is_in_business_hour=e.is_in_business_hour,this.cache.put("account",e.account),delete e.account);let i=t.A.get(e,"location",[]);this.cache.put("location",i);let s=t.A.get(e,"bots",[]),r={};t.A.map(s,(t=>{r[t.id]=t})),this.cache.put("bot",r),this.device_type=e.device_type||"desktop";let n=t.A.get(e,"plugins",[]),o={};t.A.map(n,(e=>{"chatbox"===e.type&&(e=t.A.merge(e,this.forceChatbox)),o[e.id]=e})),this.cache.put("plugin",o);var a=t.A.get(e,"agents",[]);if(t.A.size(a)>0){let e={};this.api.setAgentId(a[0].id),t.A.map(a,(t=>{e[t.id]=t})),this.cache.put("agent",e)}let l=t.A.get(e,"payment_methods",[]);this.cache.put("payment_methods",l),this.pubsub.publish("account")}async track(){let e=await this.api.sendContentView(this.device,location.href,document.title,this._currentViewingProduct.id,this._currentViewingProduct.source_id,this._currentViewingProduct.sku),i=t.A.get(e,"body.by.device.source","");i&&this.kv.put("traffic_source",i)}async onWs(t){await this.wsGate.entry(),this.wsGate.close(),await this._onWs(t),this.wsGate.open()}async _onWs(e){if(this._die)return;if(!e||!e.type)return;if(e.created=t.A.getMs(e.created),"user_info_updated"===e.type)return;let i,s=this.cache.match("user")||{},r=t.A.convoOfEv(e),n=!1;if(r&&(i=this.cache.match("convo_"+r),!i||!i.id)){let{body:t,error:e}=await this.api.getConversation(r);if(!t)return;i=t,n=!0,this._setConvo(i)}if(i){if(this.pubsub.publish("events",e),"conversation_joined"===e.type){let s=t.A.get(e,"data.conversation.members",[]);if(t.A.find(s,(t=>t.id===this.cache.match("user").id))&&!n){let{body:t}=await this.api.getConversation(r);t&&(i=t,this._setConvo(i)),this.pubsub.publish("account")}}return"message_sent"===e.type&&t.A.get(e,"by.id")!==s.id&&(this._alreadyReceived[e.id]||(this._alreadyReceived[e.id]=!0,this.api.markAsReceived(r,e.id))),t.A.startsWith(e.type,"message_")||t.A.startsWith(e.type,"conversation_")?(this.restConvoEvent(e),void("message_sent"===e.type&&t.A.get(e,"by.id")!==s.id&&E("SUBIZ Chat","Received","User"))):void 0}}async restConvoEvent(e){let i=this.cache.match("user"),s=t.A.convoOfEv(e),r=this.cache.match("convo_"+s)||{};if("conversation_state_updated"===e.type){if(!t.A.get(r,"id")){let{body:t,error:e}=await this.api.getConversation(s);if(e)return}r=Object.assign(r,t.A.get(e,"data.conversation"))}if("message_pong"===e.type){var n=t.A.get(e,"data.message.id"),o=this.chain.match(s,n);if(!t.A.get(o,"data.message"))return;var a=t.A.get(o,"data.message.pongs",[]);let l=t.A.get(e,"data.message.pongs",[])||[];if(a=a.concat(l),1===l.length){let t=l[0].type;"like"!==t&&"remove_dislike"!==t||(a=a.filter((t=>"dislike"!==t.type))),"dislike"!==t&&"remove_like"!==t||(a=a.filter((t=>"like"!==t.type)))}o.data.message.pongs=a,t.A.map(a,(e=>{if(e.member_id==i.id&&"seen"===e.type){let s=t.A.find(r.members,(t=>t.id===i.id));s&&(s.seen_at=e.created)}})),this.chain.put(s,o.id,t.A.getMs(o.created),o),this.pubsub.publish("events",o)}if("message_sent"===e.type){let i=t.A.get(e,"data.message.idempotency_key"),n=t.A.find(this.listEvents(s),(t=>t.id===i));n&&(this.chain.del(s,n.id),e.created=n.created),r.last_message_sent=e}"message_pong"!==e.type&&"conversation_typing"!==e.type&&this.chain.put(s,e.id,t.A.getMs(e.created),e),this._setConvo(r),this.pubsub.publish("account")}emitCloseWidgetEvent(){this.pubsub.publish("sbz_close_widget",{type:"chatbox_closed"})}typing(t){t&&this._typing(t)}async startConvo(t){t||(t={}),await this.readyGate.entry(),this.convoGate.close(),t.source||(t.source=document.location.href);let{body:e,error:i}=await this.api.start(t);return this.convoGate.open(),i?{error:i}:(this._setConvo(e),{convo:e})}fetchOrder(t){return this.api.getOrder(t)}lookupOrder(t){return this.api.lookupOrder(t)}createPostback(t,e){return this.api.createPostback(t,e)}sendReaction(t,e){return this.api.sendConvoEvent(t,e)}async sendConvoEvent(e,i,s){await this.readyGate.entry();var r=t.A.randomString(36),n={id:r,by:{id:(this.cache.match("user")||{}).id,type:"user",device:this.device},data:s,type:i,created:this.now()};t.A.convoToEv(e,n);let o=[];if("message_sent"===i&&(n.data.message.idempotency_key=r,n.data.message.conversation_id=e,await k.map(n.data.message.attachments,2,(async(t,e)=>{var i;if("file"===t.type&&t._file&&(o.push(t),M.includes(t._file.type))){let{width:e,height:s,url:r}=await(i=t._file,new Promise((t=>{var e=new window.FileReader;e.onload=e=>{let i=e.target.result,s=new Image;s.onload=()=>{t({url:i,width:s.width,height:s.height})},s.src=i},e.readAsDataURL(i)})));t.url=r,t.width=e,t.height=s}}))),this.onWs(n),await this.convoGate.entry(),await k.map(o,1,(async e=>{const{body:i,url:s,error:r}=await this.api.uploadToS3(e._file);"invalid_field_size"==t.A.get(i,"code")&&(n._error_message="cannot_send_too_big_file"),n._error=r,e.url=s})),n._error)return this.onWs(n);let{body:a,error:l}=await this.api.sendConvoEvent(e,n);return l?(n._error=l,void this.onWs(n)):(this.onWs(a),E("SUBIZ Chat","Sent","User"),this.kv.match("last_msg_sent")||(window.dataLayer||[]).push({event:"SUBIZ Chat",event_action:"Sent",event_label:"User",first_interaction:1}),this.kv.put("last_msg_sent",t.A.Date.now()),a)}_setConvo(e){this.cache.match("user");let i=t.A.get(e,"touchpoint.channel","");if(i&&"subiz"!=i)return;let s={};if(t.A.map(this.cache.all(),((t,e)=>{e.startsWith("convo_")&&(s[e]=t)})),t.A.size(s)>18){s=t.A.orderBy(t.A.map(s),"created","desc");for(var r=18;r<t.A.size(s);r++){let t=s[r];this.cache.del("convo_"+t.id)}}this.markSync(e.id),this.pubsub.publish("account"),this.cache.put("convo_"+e.id,e)}matchLastPluginRun(t){return(this.kv.match("plugin_run_logs")||{})[t]}matchLastBotRun(t){return(this.kv.match("bot_run_logs")||{})[t]}logBotRun(t){let e=this.kv.match("bot_run_logs")||{};e[t]={bot_id:t,created:this.now()},this.kv.put("bot_run_logs",e)}sendImpression(t){let e=this.cache.match("user")||{},i=this.kv.match("plugin_run_logs")||{};return i[t]={web_plugin_id:t,created:this.now()},this.kv.put("plugin_run_logs",i),this.api.sendImpression({account_id:e.account_id,campaign_id:t,web_plugin_id:t,user_id:e.id,url:window.location.href,device:this.device})}sendConversion(e,i,s){let r=this.cache.match("user")||{},n={account_id:r.account_id,user_id:r.id,fields:i},o=this.kv.match("conversions")||{};return o[e]=!0,this.kv.put("conversions",o),this.api.sendConversion({account_id:r.account_id,web_plugin_id:e,campaign_id:e,user_id:t.A.get(r,"id"),url:window.location.href,device:this.device,submission:n,impression_token:s})}isConverted(t){return(this.kv.match("conversions")||{})[t]}async listmessageapi(e,i,s){let r=e,{body:n,code:o,error:a}=await this.api.listMessages(r,-s,i);if(a||200!==o)return[[],i,a];i=t.A.get(t.A.last(n),"id"),n=t.A.map(n,(e=>(e.created=t.A.getMs(e.created),{id:e.id,index:e.created,value:e})));let l=this.cache.match("user")||{};for(let e=0;e<n.length;e++){let i=n[e].value;if("message_sent"===i.type&&t.A.get(i,"by.id")!==l.id){if(t.A.find(t.A.get(i,"data.message.pongs"),(t=>t.member_id===l.id)))break;this._alreadyReceived[i.id]||(this._alreadyReceived[i.id]=!0,this.api.markAsReceived(r,i.id));break}}return[n,i,void 0,t.A.size(n)<s]}async loopTime(){if(this._die)return;let e=t.A.Date.now();if(!t.A.get(this.cache.match("user"),"id"))return t.A.setTimeout((()=>this.loopTime()),24e4);let{body:i,error:s}=await this.api.time();if(s)return t.A.setTimeout((()=>this.loopTime()),3e4);var r=Math.abs(t.A.Date.now()-e)/2,n=new t.A.Date(i).getTime()+r,o=t.A.Date.now();this.timeDiff=Math.floor(n-o),t.A.setTimeout((()=>this.loopTime()),24e4)}replaceFileUrl(e){return e?t.A.startsWith(e,"/")||t.A.startsWith(e,"data:")?e:(t.A.startsWith(e,"http://")||t.A.startsWith(e,"https://")||t.A.startsWith(e,"//")||(e=t.A.trim(this.FileURL,"/")+"/"+t.A.trimStart(e,"/")),e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace("https://file-subiz.com/",this.FileURL)).replace("http://file-subiz.com/",this.FileURL)).replace("https://file-v4.subiz.com/",this.FileURL)).replace("http://file-v4.subiz.com/",this.FileURL)).replace("https://filev4.subiz.com/",this.FileURL)).replace("http://filev4.subiz.com/",this.FileURL)).replace("https://filev4-1.subiz.com/",this.FileURL)).replace("http://filev4-1.subiz.com/",this.FileURL)).replace("https://file.subiz.com/",this.FileURL)).replace("http://file.subiz.com/",this.FileURL)).replace("https://file.mysubiz.com/",this.FileURL)).replace("http://file.mysubiz.com/",this.FileURL)):""}clearBrowserData(){t.A.each(this.cookie.all(),((t,e)=>{(e||"").startsWith("__sb")&&this.cookie.remove(e)})),this.kv.destroy(),this.kv=new p(new l("sbz2023",this.inmem),"kv"),this.chain.destroy(),this.chain=new c(new l("cbz2023",!0),"ch")}destroy(){this._die=!0,this.kv&&this.kv.destroy(),this.chain&&this.chain.destroy(),t.A.clearInterval(this._seenInterval),this.realtime&&this.realtime.stop(),this.readyGate.close(),window.removeEventListener("blur",this.sendPresence),window.removeEventListener("focus",this.sendPresence)}}const M=["image/gif","image/jpeg","image/png","image/svg+xml"],P={data:{},get(t,e){return this.data[t]||e},set(t,e){return this.data[t]=t},all(){return this.data},remove(t){delete this.data[t]}};function E(t,e,i){document.dispatchEvent(new CustomEvent("subiz",{detail:{category:t,action:e,label:i}})),function(t,e,i){window.sbz_no_gtag?console.log("SKIPSENT.",t,e,i):((window.dataLayer||[]).push({event:t,event_action:e,event_label:i}),window.gtag&&window.gtag("event",t,{Action:e,Label:i}),window.ga&&window.ga.getAll&&(window.ga.getAll()||[]).forEach((function(s){const r=s.get("name");window.ga(r+".send","event",t,e,i)})))}(t,e,i),function(t,e,i){window.fbq&&window.fbq("trackCustom",t,{action:e,label:i})}(t,e,i)}let j=()=>{try{localStorage}catch(t){return}t.A.setTimeout((()=>{for(var t in localStorage)t&&(t.startsWith("cbz2020")||t.startsWith("sbz2020"))&&localStorage.removeItem(t)}))},I=()=>{try{localStorage}catch(t){return}t.A.setTimeout((()=>{for(var t in localStorage)t&&(t.startsWith("cbz2020")||t.startsWith("sbz2020")||t.startsWith("sbz2022")||t.startsWith("sbz2023"))&&localStorage.removeItem(t)}))};var T=function(e,i,s,r){if(void 0===t.A.XMLHttpRequest)return function(t,e,i,s){let r={};i&&(r["content-type"]="text/plain"),fetch(e,{method:t,headers:r,body:i}).then((t=>t.text().then((e=>s&&s(e,t.status))))).catch((t=>s&&s(t,-1)))}(e,i,s,r);var n=new t.A.XMLHttpRequest;n.onreadystatechange=function(t){4===n.readyState&&(r&&r(n.responseText,n.status),r=void 0)},n.onerror=function(){r&&r(n.responseText,-1),r=void 0},n.open(e,i),s&&n.setRequestHeader("content-type","text/plain"),n.send(s)};const D=new Error("sdk unloaded");var L=n(2840),z=n(172),U=n(2959),F=n(7072),R=n(1108);let O=n(2538);class $ extends L.Mw{constructor(e){super(e),this.setState({opacity:0,previewEvent:{},displayPreview:!1}),this.loadGreeting(),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(e=>{if("message_sent"!==t.A.get(e,"type"))return;let i=t.A.get(e,"by.type");if("system"!==i&&"agent"!==i)return;let s=!1;t.A.map(t.A.get(e,"data.message.attachments",[]),(t=>{t&&"quick_replies"===t.type&&(s=!0)}));let r=t.A.get(e,"data.message.format"),n=t.A.get(e,"data.message.block");if(n||"block"==r){if(t.A.isBlockEmpty(n)&&s)return}else if(!t.A.get(e,"data.message.text")&&s)return;this.setState({displayPreview:!0,previewEvent:e})}))}fixMissingSetting(e){return e=t.A.cloneDeep(e),t.A.get(e,"desktop_button.background_image_url")&&(e.desktop_button.background_image_url=this.props.store.replaceFileUrl(e.desktop_button.background_image_url)),t.A.get(e,"desktop_button.background_mask_url")&&(e.desktop_button.background_mask_url=this.props.store.replaceFileUrl(e.desktop_button.background_mask_url)),t.A.get(e,"mobile_button.background_image_url")&&(e.mobile_button.background_image_url=this.props.store.replaceFileUrl(e.mobile_button.background_image_url)),t.A.get(e,"mobile_button.background_mask_url")&&(e.mobile_button.background_mask_url=this.props.store.replaceFileUrl(e.mobile_button.background_mask_url)),e}render(){let e=this.props.plugin.chatbox,i=t.A.get(e,"desktop_button.position")||"right";if(this.props.store.isMobile()&&(i=t.A.get(e,"mobile_button.position")||i,t.A.get(e,"mobile_button.hidden")))return null;if(t.A.get(e,"desktop_button.hidden"))return null;let s="widget-layout widget-layout--"+i,r=this.state.opacity;return this.props.isShow||(s+=" widget-layout--hidden",r=0),(0,z.h)("div",{class:s,style:"opacity: "+r+" !important"},this.renderPreview(),this.renderButton())}ClearPreview(){this.setState({previewEvent:{}})}ClosePreview(){this.setState({displayPreview:!1})}ShowGreeting(){if(this.props.store.isMobile()&&"acqjeefqeaoiagyfprap"===t.A.get(this.props.plugin,"chatbox.account_id",{}))return;let e=t.A.get(this.props.plugin,"chatbox.greeting",{}),i=this.props.store.matchAgent("*"),s=e.agent_id;s||(s=function(e){var i=t.A.filter(e,(t=>"agent"===t.type));return i[Math.floor(Math.random()*t.A.size(i))]||{}}(i).id);let r=this.props.t.i18n(t.A.get(e,"greeting",{}))||e.message;this.setState({previewEvent:{by:{id:s,type:"agent"},data:{message:{text:r,format:"plaintext"}}},displayPreview:!0})}HideGreeting(){this.setState({previewEvent:{}})}loadGreeting(){let e=this.props.plugin.chatbox;if((new t.A.Date).getTime()-this.props.store.matchClosePreviewAt()<q)return;let i=t.A.get(e,"greeting",{}),s=this.props.t.i18n(t.A.get(i,"greeting",{}))||i.message,r=i.enabled;this.props.store.isMobile()&&(r=r&&!t.A.get(i,"mobile_disabled")),s&&r?this.ShowGreeting():this.setState({previewEvent:{}})}onClick(){let e=this.props.store.matchLastview();return t.A.get(e,"view")&&("list"!==e.view||t.A.size(this.props.store.matchConvo("*"))>0)?this.props.onClick&&this.props.onClick(Object.assign({},e.opts,{view:e.view})):this.onPreviewClick()}onPreviewClick(e){let i=t.A.convoOfEv(this.state.previewEvent);if(!i){let e=t.A.map(this.props.store.matchConvo("*")),s=t.A.find(e,(e=>!t.A.isConvoSeen(e,this.props.store.matchUser().id)));s||(s=e[0]||{}),i=s.id}this.closePreview(e),this.props.onClick&&this.props.onClick({view:"chat",cid:i})}renderUnread(){let t=this.props.store.matchUnread();return 0===t?null:(0,z.h)("div",{class:"chat-button--unread"},t)}renderPreview(){let e=this.props.store.matchAccount(),i=this.props.plugin.chatbox,s=t.A.get(this.state.previewEvent,"by.display_id",t.A.get(this.state.previewEvent,"by.id")),r=this.props.store.matchAgent(s);r||(r=this.props.store.matchAgent("*")[s]||{}),r=t.A.cloneDeep(r),r.fullname=r.fullname||t.A.get(e,"name")||this.props.t("agent"),r.avatar_url=r.avatar_url||O;let o=t.A.get(i,"desktop_button.position")||"right";this.props.store.isMobile()&&(o=t.A.get(i,"mobile_button.position")||o),i&&i.hide_agent_profile&&(r=Object.assign({},e,{avatar_url:e.logo_url||n(3582),fullname:e.name||this.props.t("agent")}));let a="widget-preview widget-preview--"+o;this.state.displayPreview||(a+=" widget-preview--hidden");var l=this.renderMessagePreview(this.state.previewEvent);return 0===t.A.size(l)&&(a+=" widget-preview--hidden"),(0,z.h)("div",{class:a},(0,z.h)("div",{class:"widget-preview--body"},(0,z.h)("img",{alt:"widget avatar",class:"widget-preview--avatar",src:this.props.store.replaceFileUrl(r.avatar_url),onError:t=>this.onProfileError(t),onload:t=>this.onProfileReady()}),(0,z.h)("div",{class:"widget-preview--content",onClick:t=>this.onPreviewClick(t)},(0,z.h)("div",{class:"widget-preview--title"},r.fullname),(0,z.h)("p",{class:"widget-preview--message"},l)),(0,z.h)("div",{class:"widget-preview--btn-close",onClick:t=>this.closePreview(t)})),(0,z.h)("div",{class:"widget-preview--action",onClick:t=>this.onPreviewClick(t)},(0,z.h)("div",{class:"widget-preview--action-text"},this.props.t("chat_now"))))}onProfileReady(){this._buttonLoaded&&this.setState({opacity:1}),this._profileLoaded=!0}onButtonReady(){this._profileLoaded&&this.setState({opacity:1}),this._buttonLoaded=!0}renderButton(){let e=this.props.plugin.chatbox;e=this.fixMissingSetting(e);let i=t.A.get(e,"desktop_button.background_image_url")||t.A.get(e,"desktop_button.background_mask_url")||R,s=t.A.get(e,"background")||B,r=t.A.get(e,"desktop_button.position")||"right",n=t.A.get(e,"desktop_button.background_image_url"),o=t.A.get(e,"desktop_button.background_mask_url"),a=t.A.get(e,"desktop_button.width")||70,l=t.A.get(e,"desktop_button.height")||70;if(this.props.store.isMobile()){i=t.A.get(e,"mobile_button.background_image_url")||t.A.get(e,"mobile_button.background_mask_url")||i,r=t.A.get(e,"mobile_button.position")||r;let s=t.A.get(e,"mobile_button.background_image_url"),c=t.A.get(e,"mobile_button.background_mask_url");a=t.A.get(e,"mobile_button.width")||70,l=t.A.get(e,"mobile_button.height")||70,(s||c)&&(n=s,o=c)}let c="chat-button--white-bg";!n&&o&&(c+=" chat-button--white-bg--mask-only");let h="";n=this.props.store.replaceFileUrl(n),i=this.props.store.replaceFileUrl(i),o=this.props.store.replaceFileUrl(o),n||o||(c+=" chat-button--white-bg--mask-only",h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(W)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(W)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(W)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(W)}") !important;\n\t\t\t\theight: ${l}px !important;\n\t\t\t\twidth: ${a}px !important;\n\t\t\t\tbackground: ${s} !important;\n\t\t\t\tbackground: ${s} !important;\n mask-size: cover !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`),n&&o&&(h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(o)}") !important;\n\t\t\t\tbackground-image: url("${encodeURI(n)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`),n&&!o&&(h=`\n\t\t\t\tbackground-image: url("${encodeURI(n)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n\t\t\t`),!n&&o&&(h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(o)}") !important;\n\t\t\t\theight: ${l}px !important;\n\t\t\t\twidth: ${a}px !important;\n\t\t\t\tbackground: ${s} !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`);let u="chat-button chat-button--"+r,d=`\n\t\t\twidth: ${a-4}px !important;\n\t\t\theight: ${l-4}px !important;\n\n `;return(0,z.h)("div",{class:u,onClick:t=>this.onClick(t)},(0,z.h)("div",{class:c,style:d}),(0,z.h)("div",{class:"chat-button--img-container",style:h},(0,z.h)("img",{width:"70",height:"70",alt:"chat button",class:"chat-button--img",onload:()=>this.onButtonReady(),src:i,onError:(t,e)=>this.onChatButtonError(t,e)})),this.renderUnread())}onProfileError(t){t.target.src=O,this.onProfileReady()}onChatButtonError(t){this._onChatButtonErrorExecuted||(this._onChatButtonErrorExecuted=!0,t.target.src=R)}renderMessagePreview(e,i){i=i||this.props.t("sent_you_a_message");let s=t.A.get(e,"data.message.format"),r=t.A.get(e,"data.message.block");if(r||"block"==s){if(t.A.isBlockEmpty(r)){let s=t.A.get(e,"data.message.attachments");return t.A.size(s)>0?(0,z.h)("div",null,`${this.props.t("send")} ${t.A.size(s)} ${t.A.size(s)>1?this.props.t("attachments"):this.props.t("attachment")}`):i}return(0,z.h)(F.A,{block:r})}let n=t.A.get(e,"data.message.text",i);return!n&&t.A.size(t.A.get(e,"data.message.attachments"))>0&&(n=i),n?(t.A.get(e,"by.type"),t.A.extractText(n).map((t=>"emoji"===t.type?(0,z.h)(U.A,{emojiCode:t.text}):t.text))):null}closePreview(t){t&&(t.preventDefault(),t.stopPropagation()),this.setState({displayPreview:!1}),this.props.store.closePreview(),this.forceUpdate()}}const q=18e5,W="https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5",B="linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)";var G=n(9529);function V(t){if(t.store.isMobile())return null;if(t.store.isAIDevMode())return null;let e=t.store.matchUser()||{};var i=`https://subiz.com.vn/?utm_source=${window.location.host||`id-${e.account_id}`}&utm_medium=widget&utm_campaign=widget_referral`;return(0,z.h)("div",{class:"poweredby"},(0,z.h)("a",{href:i,class:"poweredby--text",target:"_blank",title:"Subiz"},(0,z.h)("img",{width:"17",height:"12",class:"poweredby--subiz-logo",src:G,alt:"powerred by subiz"})," Subiz"))}function N(e){let i=e.plugin.chatbox,s=e.store.matchAccount()||{};var r=e.tooltipPos||"bottom",o=e.mode||"primary";if(i&&i.hide_agent_profile)return(0,z.h)("div",{class:`group-avatar group-avatar--${o}`},(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":s.name,"data-tooltip-position":r},(0,z.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(s.logo_url)||n(3582)})));let a=e.store.matchAgent("*");var l=t.A.map(e.agent_ids,(t=>a[t]));if(void 0!==e.agent_ids&&0==t.A.size(e.agent_ids)){var c=t.A.get(i,"header.agent_ids",[]);l=0!==(c=t.A.filter(c,(t=>!!a[t]))).length?t.A.map(c,(t=>a[t])):t.A.filter(a,(t=>"agent"===t.type))}if(l=t.A.filter(l,(t=>!!t)),0===t.A.size(l))return(0,z.h)("div",{class:`group-avatar group-avatar--${o}`},(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":s.name,"data-tooltip-position":r},(0,z.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(s.logo_url)||n(3582)})));if(1===l.length){var h=l[0],u="primary"===o?"group-avatar--agent-middle":"group-avatar--agent-left";return(0,z.h)("div",{class:`group-avatar group-avatar--${o}`},(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":h.fullname||s.name,"data-tooltip-position":r},(0,z.h)("img",{width:35,height:35,class:`avatar ${u}`,alt:"agent avatar",src:e.store.replaceFileUrl(h.avatar_url)||n(2538)})))}if(2===l.length){let t=l[0],i=l[1];return(0,z.h)("div",{class:`group-avatar group-avatar--${o}`},(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":t.fullname||s.name,"data-tooltip-position":r},(0,z.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(t.avatar_url)||n(2538)})),(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":i.fullname||s.name,"data-tooltip-position":r},(0,z.h)("img",{alt:"agent avatar right",width:35,height:35,class:"avatar group-avatar--agent-right",src:e.store.replaceFileUrl(i.avatar_url)||n(2538)})))}let d=l[0],p=l[1],m=l[2];return(0,z.h)("div",{class:`group-avatar group-avatar--${o}`},(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":d.fullname||s.name,"data-tooltip-position":r},(0,z.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(d.avatar_url)||n(2538)})),(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":p.fullname||s.name,"data-tooltip-position":r},(0,z.h)("img",{alt:"agent avatar middle",width:35,height:35,class:"avatar group-avatar--agent-middle",src:e.store.replaceFileUrl(p.avatar_url)||n(2538)})),(0,z.h)("div",{class:"d-inline-block pos-relative","data-tooltip":m.fullname||s.name,"data-tooltip-position":r},(0,z.h)("img",{width:35,height:35,alt:"agent avatar right",class:"avatar group-avatar--agent-right",src:e.store.replaceFileUrl(m.avatar_url)||n(2538)})))}class H extends L.Mw{constructor(t){super(t)}renderAccountAvatar(){let t=this.props.store.matchAccount()||{};return t.logo_url?(0,z.h)("img",{width:38,height:38,alt:t.name,class:"avatar avatar__account",src:this.props.store.replaceFileUrl(t.logo_url)||n(3582)}):null}render(){let e="widget-header",i=!1,s=!1,r=this.props.plugin.chatbox||{},n=t.A.get(r,"header.layout"),o="list"!==this.props.view&&!0,a=!o&&"classic"===n;return o||"classic"==n?e+=" widget-header--collapsed":(e+=" widget-header--convo-expanded",i="social"===n,s=!(i||a)),(0,z.h)("div",{class:e},this.renderCollapsedHeader(o||a,a),this.renderSocial(i),this.renderTeam(s))}renderCollapsedHeader(e,i){let s=this.props.plugin.chatbox||{},r=(this.props.store.matchAccount()||{}).is_online?this.props.t("agent_online"):this.props.t("agent_offline"),n=t.A.get(s,"tagline",{}),o=this.props.t.i18n(n)||s.introduction||r,a=(t.A.map(this.getAgentJoined(this.props.cid),(t=>t.id)),"widget-header--inner widget-header--inner--collapsed");e||(a+=" widget-header--inner--hidden");let l=null,c="";return i?c="padding-bottom: 75px !important;":l=this.renderBackButton(),(0,z.h)("div",{class:a,style:c},l,this.renderAccountAvatar(),(0,z.h)("div",{class:"widget-header--title-container"},(0,z.h)("div",{class:"widget-header--title"},this.getTitle()),(0,z.h)("div",{class:"widget-header--description",title:o},o)),this.renderCloseButton())}renderSocial(e){let i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{},r=t.A.get(i,"header.links")||[],n=t.A.map(r,(t=>t.url&&t.type&&"subiz"!==t.type?"email"===t.type?(0,z.h)("div",null,(0,z.h)("a",{href:`mailto:${t.url}`,title:t.url},(0,z.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):(0,z.h)("div",null,(0,z.h)("a",{href:t.url,target:"_blank",title:t.url},(0,z.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):null)),o=t.A.get(i,"tagline",{});var a=this.props.t.i18n(o)||i.introduction||this.props.t("team_intro")||"Chúng tôi sẵn sàng trợ giúp :wave:.\nVui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn",l=t.A.extractText(a).map((t=>"emoji"===t.type?(0,z.h)(U.A,{emojiCode:t.text}):t.text));let c="widget-header--inner widget-header--inner--expanded";return e||(c+=" widget-header--inner--hidden"),(0,z.h)("div",{class:c},(0,z.h)("div",{class:"widget-header-expand-container"},(0,z.h)("div",{class:"widget-header--top-wrapper"},(0,z.h)("div",{class:"widget-header--title"},this.getTitle()),this.renderCloseButton()),(0,z.h)("div",{class:"widget_header__body widget_header__body__social"},(0,z.h)("img",{alt:"logo",class:"social__account_logo",src:this.props.store.replaceFileUrl(t.A.get(s,"logo_url"))}),(0,z.h)("div",null,(0,z.h)("div",{class:"social__introduction"},l),(0,z.h)("div",{class:"social__links"},n)))))}renderTeam(e){let i=this.props.plugin.chatbox||{},s=t.A.get(i,"tagline",{});var r=this.props.t.i18n(s)||i.introduction||this.props.t("team_intro")||"Chúng tôi sẵn sàng trợ giúp :wave:.\nVui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn",n=t.A.extractText(r).map((t=>"emoji"===t.type?(0,z.h)(U.A,{emojiCode:t.text}):t.text));let o="widget-header--inner widget-header--inner--expanded";return e||(o+=" widget-header--inner--hidden"),(0,z.h)("div",{class:o},(0,z.h)("div",{class:"widget-header-expand-container"},(0,z.h)("div",{class:"widget-header--top-wrapper"},(0,z.h)("div",{class:"widget-header--title"},this.getTitle()),this.renderCloseButton()),(0,z.h)("div",{class:"widget_header__body"},(0,z.h)("div",{class:"widget-header--avatar-wrapper"},(0,z.h)(N,{plugin:this.props.plugin,store:this.props.store,mode:"primary",agent_ids:[]})),(0,z.h)("div",{class:"widget-header--title-container"},(0,z.h)("div",{class:"widget-header--description"},n)))))}getTitle(){let e=this.props.plugin.chatbox||{},i=this.props.store.matchAccount()||{},s=this.getAgentJoined(this.props.cid),r=t.A.get(this.props.plugin,"chatbox.caption",{}),n=this.props.t.i18n(r)||e.title;return J(s)||n||i.name||this.props.t("widget_title")}renderBackButton(){let e=this.props.store.matchConvo("*");if(0===t.A.size(e))return null;var i=null;let s=this.props.store.matchUser(),r=0;return t.A.map(e,(e=>{e.id!=this.props.cid&&(t.A.isConvoSeen(e,s.id)||r++)})),0!==r&&(i=(0,z.h)("span",{class:"widget-header--total-unread-convo"},r)),(0,z.h)("div",{class:"widget-header--wrap-button-back "+(r?"widget-header--has-convo-unred":""),onClick:t=>this.onBackClick(t)},(0,z.h)("div",{class:"widget-header--button-back","data-tooltip":this.props.t("menu_back")}),i)}renderCloseButton(){return(this.props.plugin.chatbox||{}).hide_close_button?null:(0,z.h)("div",{class:"widget-header--button-close","data-tooltip":this.props.t("close"),"data-tooltip-position":"bottom",onClick:t=>this.onCloseClick(t)},(0,z.h)("span",{class:"widget-header--button-close-icon"}))}onBackClick(t){t.stopPropagation(),t.preventDefault(),this.props.onGotoList&&this.props.onGotoList()}onCloseClick(t){t.stopPropagation(),t.preventDefault(),this.props.onClose&&this.props.onClose()}getAgentJoined(e){var i=this.props.store.matchConvo(e)||{};return t.A.filter(i.members,(t=>"agent"===t.type&&"active"===t.membership))}}let J=e=>(e=t.A.filter(e,(e=>t.A.trim(e.fullname)))).length?t.A.map(e,(t=>t.fullname)).join(", "):null;var Q=n(4188);class X extends L.Mw{constructor(e){var i,s,r;super(e),i=this,s="onEnter",r=t.A.throttle((function(){this.submitMessage()}),50),(s=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(s))in i?Object.defineProperty(i,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[s]=r,this.refFileInput=(0,z._3)(),this.refMessageInput=(0,z._3)(),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(e=>{t.A.convoOfEv(e)===this.props.cid&&this.forceUpdate()})),this.focus(),this._forceUpdate=t.A.throttle((()=>{this.forceUpdate()}),500),this.resizeInput=t.A.throttle((function(){const t=this.refMessageInput.current;t.style.setProperty("height","1em","important");const e=Math.min(200,t.scrollHeight);t.style.setProperty("height",`${e}px`,"important")}),5)}blur(){const t=this.refMessageInput.current;t&&t.blur()}render(){var e=(0,z.h)("div",{class:"d-flex flex-row align-self-end"},this.renderEmoji(),(0,z.h)("div",{"data-tooltip-poasition":"top-left",class:"message-input--button message-input--attachment-button",onClick:t=>this.selectFile(t)}));t.A.trim(this.state.msgValue).length>0&&(e=(0,z.h)("div",{class:"d-flex flex-row align-self-end"},this.renderEmoji(),(0,z.h)("div",{"data-tooltip-position":"top-left",class:"message-input--button message-input--send-button",onClick:()=>this.submitMessage()}))),this.props.is_loading&&(e=(0,z.h)("div",{class:"d-flex flex-row align-self-end"},(0,z.h)(Q.A,{size:"32"})));var i="",s=this.hasUnfinishRequiredFormOrLock()||this.props.disabled;return(s||this.props.is_loading)&&(i="message-input--disabled"),(0,z.h)("div",{class:`message-input ${i}`,onClick:t=>{this.refMessageInput.current&&this.refMessageInput.current.focus()}},(0,z.h)("input",{class:"d-none",ref:this.refFileInput,type:"file",onChange:t=>this.sendFile(t),multiple:!0}),(0,z.h)("textarea",{disabled:s,class:"message-input--input",maxlength:"1024",placeholder:this.props.t("message_input_help").substr(0,25),ref:this.refMessageInput,rows:"1",value:this.state.msgValue,onInput:t=>this.onChange(t),onPaste:t=>this.pasteImage(t),"data-emojiable":"true",onKeydown:t=>this.onKeydown(t)}),e)}hasUnfinishRequiredFormOrLock(){let e=this.props.store.matchConvo(this.props.cid);if("ended"===t.A.get(e,"state"))return!1;let i=this.props.store.listEvents(this.props.cid);i=t.A.orderBy(i,"created","desc").filter((t=>"message_sent"===t.type));let s=t.A.get(i[0],"data.message.attachments",[]);if(t.A.find(s,(e=>t.A.get(e,"lock_input"))))return!0;var r;for(let e of i)if("user"!==t.A.get(e,"by.type")){r=e;break}s=t.A.get(r,"data.message.attachments",[]);let n=t.A.filter(s,(e=>{if(!e)return!1;if("form"!==e.type&&"ask_info_form"!==e.type)return!1;var i=e.form;return!(!i||!(t.A.parseJSON(i.state)||{}).require_finished&&"ask_info_form"!==e.type||function(e){let i=t.A.get(e,"fields")||[];return t.A.find(i,(t=>!!t.answered))}(e.form))}));return t.A.size(n)>0}renderEmojiPopup(){return this.state.openEmoji?(0,z.h)("div",{class:"emoji-picker","v-clickaway":t=>this.setState({openEmoji:!1})},(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":like:"),"data-tooltip":":like:",class:"emoji-picker--item emoji--like"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":unlike:"),"data-tooltip":":unlike:",class:"emoji-picker--item emoji--unlike"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":angry:"),"data-tooltip":":angry:",class:"emoji-picker--item emoji--angry"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":confused:"),"data-tooltip":":confused:",class:"emoji-picker--item emoji--confused"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":crying:"),"data-tooltip":":crying:",class:"emoji-picker--item emoji--crying"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":grinning:"),"data-tooltip":":grinning:",class:"emoji-picker--item emoji--grinning"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":heart-eyes:"),"data-tooltip":":heart-eyes:",class:"emoji-picker--item emoji--heart-eyes"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":neutral:"),"data-tooltip":":neutral:",class:"emoji-picker--item emoji--neutral"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":sad:"),"data-tooltip":":sad:",class:"emoji-picker--item emoji--sad"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":sleepy:"),"data-tooltip":":sleepy:",class:"emoji-picker--item emoji--sleepy"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":smiling:"),"data-tooltip":":smiling:",class:"emoji-picker--item emoji--smiling"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":surprised:"),"data-tooltip":":surprised:",class:"emoji-picker--item emoji--surprised"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":tired:"),"data-tooltip":":tired:",class:"emoji-picker--item emoji--tired"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":tongue-out:"),"data-tooltip":":tongue-out:",class:"emoji-picker--item emoji--tongue-out"})),(0,z.h)("div",{class:"emoji-picker-background-item"},(0,z.h)("div",{onClick:()=>this.emojiPick(":wink:"),"data-tooltip":":wink:",class:"emoji-picker--item emoji--wink"}))):null}applyMessage(t){this.setState({msgValue:t}),this.resizeInput()}focus(){this.props.disabled||(this.refMessageInput.current&&this.refMessageInput.current.focus(),t.A.setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()})),t.A.setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()}),100))}renderEmoji(){return(0,z.h)("div",null,this.renderEmojiPopup(),(0,z.h)("div",{class:"message-input--button message-input--emoji-button",onClick:t=>this.toggleEmoji(t)}))}toggleEmoji(t){t.stopPropagation(),this.focus(),this.props.disabled||this.setState({openEmoji:!this.state.openEmoji})}emojiPick(t){const e=this.refMessageInput.current,i=e.selectionStart,s=this.state.msgValue||"";this.setState({openEmoji:!1,msgValue:[s.slice(0,i),t,s.slice(i)].join("")}),this.resizeInput(),e.focus()}onKeydown(t){if(13===t.keyCode&&!1===t.shiftKey)return this.onEnter(),t.preventDefault();this._forceUpdate(),this.sendTyping()}onChange(t){this.setState({msgValue:t.target.value}),this.resizeInput()}selectFile(){this.props.disabled||this.refFileInput.current.click()}sendFile(){let t=this.refFileInput.current;this._sendFile(t.files),t.value=""}_sendFile(e){if(0===t.A.size(e))return;if(this.props.disabled)return;let i=t.A.map(e,(t=>({type:"file",mimetype:t.type,name:t.name,_file:t,size:t.size})));this.props.onSend&&this.props.onSend({attachments:i})}async submitMessage(e){(e=e||t.A.trim(this.state.msgValue)||"")&&(this.props.disabled||(this.props.onSend&&await this.props.onSend({text:e,format:"plaintext"}),this.setState({openEmoji:!1,msgValue:""}),this.resizeInput()))}sendTyping(){if(this.props.cid)return this.props.store.typing(this.props.cid)}pasteImage(e){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return;let i=new t.A.Date;const s=`Paste-image-${i.getFullYear()}-${i.getMonth()+1}-${i.getDate()}-${i.getHours()}-${i.getMinutes()}-${i.getSeconds()}`;let r=null;const n=e.clipboardData.items[0];if(0===n.type.indexOf("image")&&(r=n.getAsFile()),!r)return;const o=[r,new ArrayBuffer],a=new File(o,`${s}.png`,{type:"image/png"});this._sendFile([a])}}class Y extends L.Mw{constructor(t){var e,i,s;super(t),e=this,i="containerRef",s=(0,z._3)(),(i=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(i))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,this.setState({ready:!1,errorIndecies:[]})}componentDidMount(){this.setImageFrameDimension()}setImageFrameDimension(){let t=this.containerRef.current;this.frameWidth=t?t.parentNode.parentNode.offsetWidth:267,this.frameHeight=240,this.setState({ready:!0})}onErrorImage(t){let e=this.state.errorIndecies||[];e.push(t),e=[...e],this.setState({errorIndecies:e})}calculateImageDimension(t){if(!t.width||!t.height)return{width:this.frameWidth,height:this.frameHeight};if(t.width/t.height-this.frameWidth/this.frameHeight>=0){let e=this.frameWidth,i=t.height*this.frameWidth/t.width;return i=Math.round(i),{width:e,height:i}}{let e=this.frameHeight,i=t.width*this.frameHeight/t.height;return i=Math.round(i),{width:i,height:e}}}renderImage(e,i){if(!this.state.ready)return;let s=t.A.get(this.props.ev,"by.type");if(!e.width||!e.height)return(0,z.h)("div",{class:`image-attachment image-attachment--${s}`},(0,z.h)("a",{href:this.props.store.replaceFileUrl(e.url),target:"_blank"},(0,z.h)("img",{alt:!0,class:"image-attachment__img",src:this.props.store.replaceFileUrl(e.thumbnail_url||e.url),onload:t=>this.props.onLoad&&this.props.onLoad()})));let{width:r,height:o}=this.calculateImageDimension(e),a=this.props.store.replaceFileUrl(e.thumbnail_url||e.url),l=this.props.store.replaceFileUrl(e.url);return this.state.errorIndecies.includes(i)&&(a=n(2876),l=a),(0,z.h)("div",{class:`image-attachment image-attachment--${s}`},(0,z.h)("a",{href:l,target:"_blank"},(0,z.h)("img",{alt:!0,ref:t=>{t&&(t.style.setProperty("width",`${r}px`,"important"),t.style.setProperty("height",`${o}px`,"important"))},class:"image-attachment__img",src:a,onload:t=>this.props.onLoad&&this.props.onLoad(),onerror:t=>this.onErrorImage(i)})))}render(){var e=t.A.get(this.props.ev,"data.message.attachments",[]),i=[];let s=t.A.get(this.props.ev,"by.type");if(t.A.each(e,((e,s)=>{if(e&&t.A.includes(e.mimetype,"image")&&e.url){var r=e.url;r.startsWith("https://")||r.startsWith("http://")||r.startsWith("content://")||r.startsWith("data:")||(e.url=this.props.store.FileURL+r),i.push(e)}})),0===i.length)return null;let r=t.A.map(i,((t,e)=>this.renderImage(t,e)));return"agent"===s?(0,z.h)("div",{class:"message-agent",ref:this.containerRef},r):(0,z.h)("div",{class:"message-user message-user-images-container",ref:this.containerRef},r)}}function K(e){let i=t.A.get(e.ev,"by.type");var s=t.A.get(e.ev,"data.message.attachments",[]),r=[];if(t.A.each(s,((e,i)=>{e&&t.A.includes(e.mimetype,"audio")&&r.push(e)})),0===r.length)return null;var n=t.A.map(r,((t,s)=>(0,z.h)("div",{key:s,class:`audio-attachment audio-attachment--${i}`},(0,z.h)("audio",{class:"audio-attachment__audio",controls:!0},(0,z.h)("source",{src:e.store.replaceFileUrl(t.url),type:t.mimetype})))));return(0,z.h)("div",{class:`message-${i} message-${i}-audio`},n)}class Z extends L.Mw{render(){var e=t.A.get(this.props.ev,"by.type","agent"),i=t.A.get(this.props.ev,"data.message.attachments",[]),s=[];if(t.A.each(i,(e=>{e&&(e.url||e._file)&&(t.A.includes(e.mimetype,"video")||t.A.includes(e.mimetype,"audio")||t.A.includes(e.mimetype,"image")||"button"===e.type||"quick_replies"===e.type||"form"===e.type||"form_submit"===e.type||s.push(e))})),0===s.length)return null;var r=t.A.map(s,((t,i)=>(0,z.h)("div",{key:i,class:`file-attachment file-attachment--${e}`},(0,z.h)("a",{class:"file-attachment--link",href:this.props.store.replaceFileUrl(t.url),target:"_blank"},(0,z.h)("span",{class:"file-attachment--download mr-2"}),(0,z.h)("span",{class:"file-attachment--filename"},t.name)))));return(0,z.h)("div",{class:`message-${e}`},r)}}function tt(e){if(0===t.A.size(e.buttons))return null;var i=t.A.map(e.buttons,((t,i)=>"call_button"===t.type?(0,z.h)("a",{class:"url-button-attachment",href:"tel:"+t.phone_number,key:i,title:t.title},e.t.i18n(t.i18n_title)||t.title):"url_button"===t.type?(0,z.h)("a",{class:"url-button-attachment",href:t.url,target:"_blank",key:i,title:t.title},e.t.i18n(t.i18n_title)||t.title||t.url):"postback_button"===t.type?(0,z.h)("a",{class:"url-button-attachment",href:"javascript:;",onClick:i=>e.onSelect(t)},e.t.i18n(t.i18n_title)||t.title):("widget_ask_desktop_notify_button"===t.type||t.type,null)));return(0,z.h)("div",{class:"button-attachments"},i)}function et(e){if("user"===t.A.get(e.ev,"by.type"))return null;let i=[],s=t.A.get(e.ev,"data.message.attachments",[]);return t.A.each(s,((e,s)=>{e&&"button"===t.A.get(e,"type")&&t.A.each(t.A.get(e,"buttons")||[],(t=>i.push(t)))})),(0,z.h)(tt,{store:e.store,buttons:i,t:e.t})}class it extends L.Mw{constructor(t){super(t)}render(){if("user"===t.A.get(this.props.ev,"by.type"))return null;let e=[];if(t.A.map(t.A.get(this.props.ev,"data.message.attachments",[]),(i=>{i&&"quick_replies"===i.type&&(e=t.A.get(i,"quick_replies",[]))})),e=t.A.filter(e,(t=>t.title)),0===e.length)return null;let i=t.A.convoOfEv(this.props.ev),s=this.props.store.matchConvo(i);if("ended"===t.A.get(s,"state"))return null;let r=t.A.map(this.props.store.listEvents(i));r=t.A.orderBy(r,"created","asc").filter((t=>"message_sent"===t.type));let n=0;for(var o=0;o<r.length;o++)if(r[o].id===this.props.ev.id){n=o;break}for(o=n+1;o<r.length;o++)if("user"===t.A.get(r[o],"by.type"))return null;let a=t.A.map(e,(t=>(0,z.h)("div",{class:"message_quick_reply",onClick:e=>this.props.onSelect(t)},t.title)));return(0,z.h)("div",{class:"message_quick_replies"},a)}}function st(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class rt extends L.Mw{constructor(e){super(e),st(this,"state",{errorFields:{},submiting:!1}),st(this,"renderFormComponent",((t,e)=>"input"===t.type?this.renderField(t,e):"button"===t.type?this.renderSubmitButton(t,e):this.props.isSubmited?void 0:(0,z.h)("div",{class:"form-component form-component-block"},(0,z.h)(F.A,{block:t})))),st(this,"renderSubmitButton",((t,e)=>{if(!this.props.isSubmited)return(0,z.h)("div",{class:"form-component form-component-submit-button"},this.props.errorMessage&&(0,z.h)("div",{class:"form-control--valid-input--error mb-1"},this.props.errorMessage),(0,z.h)("div",null,(0,z.h)("button",{class:"btn--start-convo",disabled:this.props.submiting},t.label)))})),st(this,"renderField",((e,i)=>{let s=this.state.errorFields[e.key];if(this.props.isSubmited){let i=t.A.find(this.props.submission.values,(t=>t.key===e.key))||{};return i=i.value||'""',i=t.A.parseJSON(i),Array.isArray(i)&&(i=i.join(", ")),(0,z.h)("div",{class:"form-component submitted",key:e.key},(0,z.h)("label",{class:"label"},e.label),(0,z.h)("div",null,i||(0,z.h)("span",{class:"text-muted text-italic"},this.props.t("no_info_input"))))}return(0,z.h)("div",{class:"form-component",key:e.key},(0,z.h)("label",{class:"label"},e.label," ",e.is_required&&(0,z.h)("span",{class:"red"},"*")),"text"===e.input_type&&this.renderFieldTextInput(e,i),"multiple"===e.input_type&&this.renderFieldTextareaInput(e,i),"date"===e.input_type&&this.renderFieldDateInput(e,i),"radio"===e.input_type&&this.renderFieldRadioInput(e,i),"checkbox"===e.input_type&&this.renderFieldCheckboxInput(e,i),"dropdown"===e.input_type&&this.renderFieldDropdownInput(e,i),s&&(0,z.h)("div",{class:"form-control--valid-input--error"},s))})),st(this,"renderFieldTextInput",((e,i)=>{let s="form-control";this.state.errorFields[e.key]&&(s="form-control input--error");let r=t.A.find(this.props.submission.values,(t=>t.key===e.key))||{};return r=r.value||'""',r=t.A.parseJSON(r),(0,z.h)("input",{ref:this[`${e.key}_input`],type:"text",class:s,placeholder:e.placeholder,value:r,onInput:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)}})})),st(this,"renderFieldDateInput",((e,i)=>{let s=t.A.find(this.props.submission.values,(t=>t.key===e.key))||{};s=s.value||'""',s=t.A.parseJSON(s);let r="form-control";return this.state.errorFields[e.key]&&(r="form-control input--error"),(0,z.h)("input",{ref:this[`${e.key}_input`],class:r,type:"date",value:s,onInput:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)}})})),st(this,"renderFieldRadioInput",((e,i)=>{let s=t.A.find(this.props.submission.values,(t=>t.key===e.key))||{};return s=s.value||'""',s=t.A.parseJSON(s),t.A.map(e.input_options,((t,i)=>{let r=e.key+"_"+i;return(0,z.h)("div",{class:"radio"},(0,z.h)("input",{type:"radio",name:e.key,id:r,checked:t.value===s,onChange:()=>this.toggleRadioField(e.key,t.value)}),(0,z.h)("label",{class:"radio--label",for:r},t.label),(0,z.h)("div",{class:"radio--check"}))}))})),st(this,"renderFieldCheckboxInput",((e,i)=>{let s=t.A.find(this.props.submission.values,(t=>t.key===e.key))||{};return s=s.value||"[]",s=t.A.parseJSON(s),t.A.map(e.input_options,((t,i)=>{let r=e.key+"_"+i;return(0,z.h)("div",{class:"checkbox"},(0,z.h)("input",{type:"checkbox",name:e.key,id:r,checked:s.includes(t.value),onChange:()=>this.toggleCheckboxField(e.key,t.value)}),(0,z.h)("label",{class:"checkbox--label",for:r},t.label),(0,z.h)("div",{class:"checkbox--check"}))}))})),st(this,"renderFieldDropdownInput",((e,i)=>{let s=t.A.find(this.props.submission.values,(t=>t.key===e.key))||{};return s=s.value||'""',s=t.A.parseJSON(s),(0,z.h)("select",{class:"form-control",ref:this[`${e.key}_input`],onChange:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)}},t.A.map(e.input_options,(t=>(0,z.h)("option",{value:t.value},t.label))))})),st(this,"renderFieldTextareaInput",((e,i)=>{let s=t.A.find(this.props.submission.values,(t=>t.key===e.key))||{};return s=s.value||'""',s=t.A.parseJSON(s),(0,z.h)("textarea",{onInput:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)},ref:this[`${e.key}_input`],rows:"3",class:"form-control",placeholder:e.placeholder})})),st(this,"onSubmit",(t=>{t.preventDefault(),this.validateForm()&&this.props.onSubmit()})),st(this,"validateForm",(()=>{let e=!0,i="",s={},r=t.A.get(this.props.formSetting,"components")||[];return t.A.each(r,(r=>{if("input"===r.type&&r.is_required){let n=t.A.find(this.props.submission.values,(t=>t.key===r.key))||{};n=n.value||'""',n=t.A.parseJSON(n),"string"!=typeof n||n.trim()||(e=!1,s[r.key]=this.props.t("cannot_be_empty"),i||"checkbox"===r.input_type||"radio"===r.input_type||(i=`${r.key}_input`)),Array.isArray(n)&&0===n.length&&(e=!1,s[r.key]=this.props.t("cannot_be_empty"))}})),i&&this[i]&&this[i].current&&this[i].current.focus(),this.setState({errorFields:s}),e})),st(this,"onChangeValue",((e,i)=>{let s=t.A.get(this.props.submission,"values")||[],r=t.A.find(s,(t=>t.key===e));r?r.value=JSON.stringify(i):s.push({key:e,value:JSON.stringify(i)}),this.props.onChangeFormValues(s)})),st(this,"clearError",(t=>{let e=this.state.errorFields;e[t]="",this.setState({errorFields:e})}));let i=t.A.get(this.props.formSetting,"components")||[];t.A.each(i,(t=>{"input"===t.type&&"checkbox"!==t.input_type&&"radio"!==t.input_type&&(this[`${t.key}_input`]=(0,z._3)())}))}toggleRadioField(t,e){this.clearError(t),this.onChangeValue(t,e)}toggleCheckboxField(e,i){let s=t.A.find(this.props.submission.values,(t=>t.key===e))||{};s=s.value||"[]",s=t.A.parseJSON(s),s.includes(i)?s=s.filter((t=>t!==i)):s.push(i),this.clearError(e),this.onChangeValue(e,s)}render(){let e=t.A.get(this.props.formSetting,"components")||[],i=t.A.get(this.props.formSetting,"title")||"",s="form-wrapper form";return"attachment"===this.props.mode&&(s+=" form-wrapper-attachment"),(0,z.h)("div",{class:s},this.props.isSubmited&&(0,z.h)("div",{class:"form-component"},this.props.t("you_have_submitted_info_successfully")),(0,z.h)("form",{onSubmit:this.onSubmit},(0,z.h)("div",{class:"form-component form-component-block"},i),t.A.map(e,this.renderFormComponent)))}}function nt(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ot extends L.Mw{constructor(e){super(e),nt(this,"fetchFormSetting",(()=>{let e=t.A.get(this.props.ev,"data.message.attachments")||[],i=t.A.find(e,(t=>"form"===t.type));if(!i)return;let s=i.url;this.token=function(t,e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var i=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===i?"":decodeURIComponent(i[1].replace(/\+/g," "))}(s,"token");let r=i.form||{},n=i.form_submission||{},o=t.A.size(n)>0;this.setState({formSetting:r,submission:n,isSubmited:o})})),nt(this,"onChangeFormValues",(t=>{this.setState({submission:{values:t}})})),nt(this,"onSubmit",(async()=>{if(this.setState({errorMessage:""}),this.state.submiting)return;this.setState({submiting:!0});let e=await this.props.store.submitForm2(this.props.store.matchAccount().id,this.token,this.state.submission);e.error?this.setState({submiting:!1,errorMessage:t.A.get(e,"error.code")}):this.setState({submiting:!1,isSubmited:!0})})),this.state={submission:{},formSetting:{},submiting:!1,errorMessage:"",isSubmited:!1}}componentDidMount(){this.fetchFormSetting()}render(){let e=t.A.get(this.props.ev,"data.message.attachments")||[];if(!t.A.find(e,(t=>"form"===t.type)))return;const{submission:i,formSetting:s,errorMessage:r,isSubmited:n,submiting:o}=this.state;return(0,z.h)("div",{onClick:t=>t.stopPropagation()},(0,z.h)(rt,{store:this.props.store,formSetting:s,mode:"attachment",t:this.props.t,submission:i,errorMessage:r,isSubmited:n,submiting:o,onChangeFormValues:this.onChangeFormValues,onSubmit:this.onSubmit}))}}class at extends L.Mw{constructor(t){super(t)}render(){return null}}function lt(t){return t.touches&&t.touches.length?t.touches[0]:{}}class ct extends L.Mw{constructor(t){super(t),this.state={focusing:0},this.galleryRef=(0,z._3)()}componentDidMount(){this.bindDrag()}focus(t){this.setState({focusing:t}),this.galleryRef.current.scrollTo({left:220*t,behavior:"smooth"})}render(){if("user"===t.A.get(this.props.ev,"by.type"))return null;let e=t.A.get(this.props.ev,"data.message.attachments",[]),i=t.A.filter(e,(e=>"generic"===t.A.get(e,"type")));return 0===i.length?null:t.A.map(i,((i,s)=>{var r=t.A.map(i.elements,(t=>{let e=this.props.t.i18n(t.i18n_title)||t.title,i=this.props.t.i18n(t.i18n_subtitle)||t.subtitle,s=e?(0,z.h)("div",{class:"generic-attachment--element-title"},e):null,r=i?(0,z.h)("div",{class:"generic-attachment--element-subtitle"},i):null,o=this.props.store.replaceFileUrl(t.image_url);return t.image_url||(o=n(2876)),(0,z.h)("div",{class:"generic-attachment--element swiper-slide"},(0,z.h)("div",null,(0,z.h)("img",{alt:"generic attachment element",class:"generic-attachment--element-img",src:o})),(0,z.h)("div",{class:"generic-attachment--element-content"},s,r),(0,z.h)(tt,{buttons:t.buttons,onSelect:t=>this.props.onSelect(t),t:this.props.t}))}));let o=t.A.get(e,"0.elements",[]),a="generic-attachment-navigator generic-attachment-navigator--left",l="generic-attachment-navigator generic-attachment-navigator--right";return 0===this.state.focusing&&(a+=" generic-attachment-navigator--disabled"),this.state.focusing===o.length-1&&(l+=" generic-attachment-navigator--disabled"),(0,z.h)("div",{class:"generic-attachment-container"},(0,z.h)("div",{class:"generic-attachment",ref:this.galleryRef},r),!this.props.store.isMobile()&&(0,z.h)(z.FK,null,(0,z.h)("div",{class:a,onClick:t=>this.focus(this.state.focusing-1)},(0,z.h)("span",{class:"generic-attachment-navigator-icon"},"‹")),(0,z.h)("div",{class:l,onClick:t=>this.focus(this.state.focusing+1)},(0,z.h)("span",{class:"generic-attachment-navigator-icon"},"›"))))}))}bindDrag(){if(!this.props.store.isMobile())return;let e=document.getElementsByClassName("generic-attachment");t.A.map(e,(t=>{var e,i,s;(e=t)&&(e.removeEventListener("touchstart",e.md,0),window.removeEventListener("touchend",e.mu,0),window.removeEventListener("touchmove",e.mm,0),e.md=function(t){let r=lt(t);e.hasAttribute("nochilddrag")&&document.elementFromPoint(r.pageX,r.pageY)||(s=1,i=r.clientX,t.preventDefault())},e.mu=()=>{s=0},e.mm=function(t){if(!s)return;let r=lt(t);e.scrollLeft-=-i+r.clientX,i=r.clientX},e.addEventListener("touchstart",e.md,{passive:!0}),window.addEventListener("touchend",e.mu,{passive:!0}),window.addEventListener("touchmove",e.mm,{passive:!0}))}))}}class ht extends L.Mw{render(){let e=t.A.get(this.props.ev,"by.type");if("user"===e)return null;let i=t.A.get(this.props.ev,"data.message.attachments",[]),s=t.A.filter(i,(e=>"product"===t.A.get(e,"type")||"product_preview"===t.A.get(e,"type")));if(s=s.filter((t=>t.product&&t.product.name)),0===s.length)return null;let r=this.props.store.matchAccount();return t.A.map(s,((i,s)=>{let o=i.product,a=[],l=o.url||o.mobile_url;this.props.store.isMobile()&&(l=o.mobile_url||o.url),l&&0==t.A.size(o.buttons)&&a.push((0,z.h)("a",{class:"product_attachment__btn",href:l,target:"_blank"},this.props.t("detail"),(0,z.h)("img",{src:n(3266),class:"product_attachment__btn_external_link"}))),console.log("P",o),t.A.size(o.buttons)>0&&(a=a.concat(t.A.map(o.buttons,((t,e)=>"call_button"===t.type?(0,z.h)("a",{class:"product_attachment__btn",href:"tel:"+t.phone_number,key:e,title:t.title},this.props.t.i18n(t.i18n_title)||t.title):"url_button"===t.type?(0,z.h)("a",{class:"product_attachment__btn",href:t.url,target:"_blank",key:e,title:t.title},this.props.t.i18n(t.i18n_title)||t.title||this.props.t("detail")," ",(0,z.h)("img",{src:n(3266),class:"product_attachment__btn_external_link"})):"postback_button"===t.type?(0,z.h)("a",{class:"product_attachment__btn",href:"javascript:;",onClick:e=>this.props.onPostback(t)},this.props.t.i18n(t.i18n_title)||t.title):void 0))));let c=(0,z.h)("a",{href:l,class:"product_attachment__title",target:"_blank"},o.name),h=null,u=o.description||o.long_description;u&&(h=(0,z.h)("div",{class:"product_attachment__subtitle"},u));let d=o.currency||t.A.get(r,"currency","VND"),p=null;o.price&&(p=(0,z.h)("div",{class:"product_attachment__price"},t.A.formatCurrency(o.price,d)));let m=this.props.store.replaceFileUrl(o.image);return o.image||(m=n(2876)),(0,z.h)("div",{class:"product_attachment product_attachment__"+e},(0,z.h)("div",null,(0,z.h)("a",{href:this.props.store.replaceFileUrl(o.image),target:"_blank"},(0,z.h)("img",{class:"product_attachment__img",src:m}))),c,h,p,(0,z.h)("div",{class:"product_attachment__btns"},a))}))}}class ut extends L.Mw{constructor(t){super(t)}render(){let e=t.A.get(this.props.ev,"by.type");var i=t.A.get(this.props.ev,"data.message.attachments",[]),s=[];if(t.A.each(i,((e,i)=>{e&&t.A.includes(e.mimetype,"video")&&s.push(e)})),0===s.length)return null;var r=t.A.map(s,((t,i)=>(0,z.h)("div",{key:i,class:`video-attachment video-attachment--${e}`},(0,z.h)("video",{class:"video-attachment__video",src:this.props.store.replaceFileUrl(t.url),width:"100%",height:"",poster:this.props.store.replaceFileUrl(t.thumbnail_url),controls:"controls",preload:"metadata"}))));return(0,z.h)("div",{class:`message-${e}`},r)}}var dt=n(1620);class pt extends L.Mw{renderTime(){return null}render(){t.A.get(this.props.ev,"data.message.format","plaintext");let e=t.A.get(this.props.ev,"data.message.block");return e?this.renderBlock(e):this.renderPlainText()}renderPlainText(){var e=t.A.get(this.props.ev,"data.message.text");if(e=t.A.trim(e),0===t.A.size(e))return null;let i=new t.A.Date(t.A.get(this.props.ev,"created")).toLocaleString(),s=t.A.get(this.props.ev,"by.type");"user"!==s&&(s="agent");var r=t.A.extractText(e).map((t=>{if("emoji"===t.type)return(0,z.h)(U.A,{emojiCode:t.text,byType:s});if("link"===t.type){let e=t.text||"";return e.startsWith("//")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:")||(e="//"+e),(0,z.h)("a",{href:e,target:"_blank",onClick:t=>this.props.onLink(t,e)},t.text)}return"phone"===t.type?(0,z.h)("a",{href:"tel:"+t.text},t.text):"email"===t.type?(0,z.h)("a",{href:"mailto:"+t.text},t.text):t.text}));if(0===t.A.size(r))return null;if("agent"===s)return(0,z.h)("div",{class:"message-agent message-text--agent",title:i},r,this.renderTime());let n="message-user message-text--user";return this.props.ev._error&&(n+=" message-user--error"),(0,z.h)("div",{class:n,title:i},r)}renderBlock(e){if(mt(e))return null;let i=new t.A.Date(t.A.get(this.props.ev,"created")).toLocaleString(),s=t.A.get(this.props.ev,"by.type");if("user"!==s&&(s="agent"),"agent"===s)return(0,z.h)("div",{class:"message-agent message-text--agent",title:i},(0,z.h)(F.A,{block:e,onLink:this.props.onLink}),this.renderTime());let r="message-user message-text--user";return this.props.ev._error&&(r+=" message-user--error"),(0,z.h)("div",{class:r,title:i},(0,z.h)(F.A,{block:e,onLink:this.props.onLink}))}}function mt(e){if(!e||!e.type)return!0;let i=t.A.size(t.A.filter(t.A.map(e.content,(t=>mt(t))),(t=>!t)))>0;return!t.A.trim(e.text)&&!i}class gt extends L.Mw{render(){let e=this.props.ev.ev;if("conversation_rated"===e.type){var i=t.A.get(e,"data.conversation.ratings.0",{no_rating:!0,rating:0});return i.no_rating?null:(0,z.h)("div",{class:"convo-event"},(0,z.h)("div",{class:"info-message"},this.props.t("rated_as")+" "+this.props.t(function(t){return t?t<2?"poor":t<4?"average":"great":"poor"}(i.rating)).toLowerCase()))}return"conversation_state_updated"===e.type&&"ended"===t.A.get(e,"data.conversation.state")?(0,z.h)("div",{class:"convo-event"},(0,z.h)("div",{class:"info-message"},this.props.t("conversation_ended"))):null}}let ft=!1;class vt extends L.Mw{constructor(e){var i,s,r;super(e),i=this,r=()=>{let e=t.A.convoOfEv(this.props.event.ev);const i=t.A.get(this.props.event,"ev.data.message");this.props.store.sendConvoEvent(e,"message_sent",{message:i})},(s=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(s="resendMessage"))in i?Object.defineProperty(i,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[s]=r,this.props.store.onConvoEvent(this,(t=>this.onEvent(t))),this.refForm=(0,z._3)(),this.state={pongs:t.A.get(this.props.event,"ev.data.message.pongs")||[]}}render(){var e=t.A.get(this.props.event,"ev",{});switch(e.type){case"conversation_typing":return this.renderTyping();case"conversation_joined":break;case"message_sent":return this.props.event.is_typing?this.renderTyping():this.renderMessageSent();case"conversation_state_updated":case"conversation_rating_requested":case"conversation_rated":return t.A.startsWith(e.id,"ev")?(0,z.h)(gt,{t:this.props.t,store:this.props.store,ev:this.props.event}):null}return null}focus(){this.refForm.current&&this.refForm.current.focus()}onEvent(e){e.id===t.A.get(this.props.event,"ev.id")&&this.setState({pongs:t.A.get(e,"data.message.pongs")||[]})}hasLike(){let{pongs:e}=this.state;return!!t.A.find(e,(t=>"like"===t.type))}hasDislike(){let{pongs:e}=this.state;return!!t.A.find(e,(t=>"dislike"===t.type))}chooseQuickReply(e){let i=t.A.get(this.props.event,"ev",{}),s={text:e.title,format:"plaintext"};e.payload&&(s.attachments=[{type:"postback",postback:{event_id:i.id,payload:e.payload}}]),this.props.onSend(s)}choosePostbackBtn(e){let i=t.A.get(this.props.event,"ev",{}),s={text:e.title,format:"plaintext"};e.payload&&(s.attachments=[{type:"postback",postback:{event_id:i.id,payload:e.payload}}]),this.props.onSend(s)}renderAgentAvatar(e){let i=t.A.get(e,"by.type"),s=t.A.get(e,"by.display_id",t.A.get(e,"by.id"));if("user"===i)return null;var r=this.getSenderName(e);let o=this.props.store.matchAccount();var a=o.logo_url||n(3582);if(t.A.get(this.props,"chatbox.hide_agent_profile"))return(0,z.h)("div",{class:"message-sender"},(0,z.h)("img",{alt:"sender",class:"message-sender-avatar",src:this.props.store.replaceFileUrl(a)}),(0,z.h)("p",{class:"message-sender-name"},o.name));let l=this.props.store.matchAgent("*");return"system"!==s&&"dummy"!==i&&"workflow"!==i&&(a=t.A.get(l[s],"avatar_url")||o.logo_url||n(2538)),(0,z.h)("div",{class:"message-sender"},(0,z.h)("img",{alt:"sender",class:"message-sender-avatar",src:this.props.store.replaceFileUrl(a)}),(0,z.h)("p",{class:"message-sender-name"},r))}tryLoadOrder(e){if("user"!==t.A.get(e,"by.type")){this.props.store.matchAccount();var i=t.A.get(e,"data.message.attachments",[]);0!==t.A.filter(i,(t=>"order"===t.type&&t.order)).map((t=>t.order)).length&&(ft||t.A.setTimeout((async()=>{ft=(await n.e(127).then(n.bind(n,6127))).default})))}}renderTyping(){if(!this.props.event.is_show)return(0,z.h)("div",{key:"container",class:"convo-event agent-message",style:"opacity: 0 !important"},(0,z.h)("div",{class:"agent-convo-event-wrapper"},(0,z.h)("div",{class:"agent-convo-event-inner"},(0,z.h)("div",{class:"message-agent message-text--agent",style:"opacity: 0.6 !important"},(0,z.h)("div",{style:"height: 20px !important; width: 35px !important"})))));let t="data:text/html,"+encodeURIComponent('\n<html>\n <head>\n <style>\n .typing-container {\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n gap: 4px;\n justify-content: center;\n }\n .typing-dot {\n display: inline-block;\n vertical-align: middle;\n width: 8px;\n height: 8px;\n background: black;\n border-radius: 50%;\n animation: typing 0.5s infinite alternate;\n }\n .typing-dot:nth-of-type(2) {\n animation-delay: 0.2s;\n }\n .typing-dot:nth-of-type(3) {\n animation-delay: 0.6s;\n }\n @keyframes typing {\n 0% {\n opacity: 0.9;\n }\n 100% {\n opacity: 0.4;\n }\n }\n </style>\n </head>\n <body style="padding: 0; margin: 0">\n <div class="typing-container">\n <span class="typing-dot"></span>\n <span class="typing-dot"></span>\n <span class="typing-dot"></span>\n </div>\n </body>\n</html>\n');return(0,z.h)("div",{key:"container",class:"convo-event agent-message",style:"opacity: 0.6 !important"},(0,z.h)("div",{class:"agent-convo-event-wrapper"},(0,z.h)("div",{class:"agent-convo-event-inner"},(0,z.h)("div",{class:"message-agent message-text--agent"},(0,z.h)("iframe",{src:t,style:"width: 35px !important; height: 20px !important; display: block !important; overflow: hidden !important; padding: 0 !important "})))))}renderMessageSent(){let e=this.props.event.ev,i=t.A.get(e,"data.message.attachments"),s=t.A.find(i,(t=>"form"===t.type));if("evshpgaeetsplfqprzmynrvrl"===e.id&&(s=!0),this.tryLoadOrder(e),new t.A.Date(e.created).toLocaleString(),"user"!==t.A.get(e,"by.type")){let t=null;"lead"===this.props.event.mode&&(t=this.renderAgentAvatar(e));let i="agent-convo-event-inner";this.props.isLast&&(i+=" last");let r="agent-convo-event-wrapper";return s&&(r+=" full"),(0,z.h)("div",{class:"convo-event agent-message"},t,(0,z.h)("div",{class:r},(0,z.h)("div",{class:i},(0,z.h)(pt,{showTime:this.props.event.show_time,isLast:this.props.isLast,store:this.props.store,ev:e,onLink:this.props.onLink}),(0,z.h)(Y,{store:this.props.store,ev:e}),(0,z.h)(K,{store:this.props.store,ev:e}),(0,z.h)(ut,{store:this.props.store,ev:e}),(0,z.h)(Z,{store:this.props.store,ev:e}),(0,z.h)(et,{store:this.props.store,ev:e,t:this.props.t}),(0,z.h)(ot,{store:this.props.store,ev:e,t:this.props.t}),(0,z.h)(at,{store:this.props.store,ev:e,t:this.props.t}),(0,z.h)(ct,{store:this.props.store,ev:e,onSelect:t=>this.choosePostbackBtn(t),t:this.props.t}),(0,z.h)(ht,{t:this.props.t,onPostback:t=>this.choosePostbackBtn(t),store:this.props.store,ev:e}),(0,z.h)(ft,{t:this.props.t,store:this.props.store,ev:e}),(0,z.h)(it,{store:this.props.store,ev:e,onSelect:t=>this.chooseQuickReply(t)}),this.renderReactions(),this.renderAIDevNote())))}t.A.get(e,"data.message.idempotency_key")===e.id&&this.props.store.now()-e.created<900&&t.A.setTimeout((()=>this.setState({refresh:this.state.refresh})),1e3);let r=(0,z.h)("div",{class:"sending_dot"});(this.props.store.now()-e.created<900||t.A.get(e,"data.message.idempotency_key")!==e.id)&&(r=(0,z.h)("div",{class:"sending_dot sending_dot__hide"}));let n=null;"lead"===this.props.event.mode&&(n=(0,z.h)("div",{class:"pt-3"}));let o=null;if(e._error&&(r=null),e._error&&"message_sent"===e.type){let t=this.props.t("error_send_message");e._error_message&&(t=this.props.t(e._error_message)),o=(0,z.h)("a",{class:"message_error",src:"javascript:;",onClick:this.resendMessage},(0,z.h)("div",{class:"message_error__icon"})," ",(0,z.h)("div",{class:"message_error__text"},t))}return(0,z.h)("div",{class:"convo-event user-message"},n,(0,z.h)("div",{class:"message-user__container"},r,(0,z.h)(pt,{store:this.props.store,ev:e,refresh:this.state.refresh,onLink:this.props.onLink}),(0,z.h)(Y,{store:this.props.store,ev:e}),(0,z.h)(K,{store:this.props.store,ev:e}),(0,z.h)(ut,{store:this.props.store,ev:e}),(0,z.h)(Z,{store:this.props.store,ev:e}),(0,z.h)(et,{store:this.props.store,ev:e,t:this.props.t}),(0,z.h)(ot,{store:this.props.store,t:this.props.t,ev:e}),(0,z.h)(ht,{t:this.props.t,store:this.props.store,ev:e}),(0,z.h)(at,{store:this.props.store,ev:e})),o)}async onSendReaction(e){if(this._reacting)return;let i=this.props.event.ev,s=t.A.get(i,"data.message.conversation_id");i={type:"message_pong",data:{message:{id:i.id,pongs:[{type:e}],conversion_id:s}}},"dislike"==e&&this.props.store.isAIDevMode()&&this.props.store.emitConvoEvent({type:"bad_feedbacked",data:{event:i,id:i.id,conversion_id:s}});let{pongs:r}=this.state;"like"===e?(r=r.filter((t=>"dislike"!==t.type)),r.push({type:"like"})):"dislike"===e?(r=r.filter((t=>"like"!==t.type)),r.push({type:"dislike"})):"remove_like"===e?r=r.filter((t=>"like"!==t.type)):"remove_dislike"===e&&(r=r.filter((t=>"dislike"!==t.type))),this.setState({pongs:r}),this._reacting=!0,await this.props.store.sendReaction(s,i),this._reacting=!1}renderReactions(){if(this.props.store.isAIDevMode())return null;let e=t.A.get(this.props.event,"ev")||{},i=(t.A.get(e,"data.message.pongs"),this.hasLike()),s=this.hasDislike(),r="message-event-action-btn";i&&(r+=" active");let n="message-event-action-btn";return s&&(n+=" active"),(0,z.h)("div",{class:"message-event-actions"},(0,z.h)("div",{class:r,onClick:()=>this.onSendReaction(i?"remove_like":"like")},(0,z.h)("div",{class:"message-event-action-btn-svg like"})),(0,z.h)("div",{class:n,onClick:()=>this.onSendReaction(s?"remove_dislike":"dislike")},(0,z.h)("div",{class:"message-event-action-btn-svg dislike"})))}renderAIDevNote(){if(!this.props.isLast)return null;if(!this.props.store.isAIDevMode())return null;let e=t.A.get(this.props.event,"ev")||{},i=(t.A.get(e,"data.message.pongs"),this.hasLike()),s=this.hasDislike(),r="message-event-action-btn message-event-action-btn__dev message-event-action-btn_like";i&&(r+=" active");let n="message-event-action-btn message-event-action-btn__dev message-event-action-btn_dislike";return s&&(n+=" active"),(0,z.h)("div",{class:"message-event-actions"},(0,z.h)("div",{class:r,onClick:()=>this.onSendReaction(i?"remove_like":"like")},(0,z.h)("div",{class:"message-event-action-btn-svg like"})," Good"),(0,z.h)("div",{class:n,onClick:()=>this.onSendReaction(s?"remove_dislike":"dislike")},(0,z.h)("div",{class:"message-event-action-btn-svg dislike"})," Bad"))}renderUpdateConvo(e){var i=t.A.get(e,"data.conversation.state");return"active"===i||"pending"===i?null:(0,z.h)("div",{class:"message-system"},this.props.t("conversation_state_updated",{state:i}))}getSenderName(e){let i=t.A.get(e,"by.type"),s=t.A.get(e,"by.display_id",t.A.get(e,"by.id"));if("user"===i)return t.A.getUserDisplayName(this.props.store.matchUser());let r=this.props.store.matchAccount();if("agent"===i)return t.A.getAgentDisplayName(r,this.props.store.matchAgent(s));if("bot"===i){let t=this.props.store.matchBot()[s];return t&&t.fullname||"Bot"}return"system"===s||"dummy"===i||"workflow"===i?r.name||"system":r.name}}const _t=n(1370);class yt extends L.Mw{constructor(e){super(e),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(t=>this.onEvent(t))),this.loadConvo(),this.refBody=null,this.checkAndSeen=t.A.throttle((()=>{this.props.isShow&&this.isBottom()&&"visible"===this.props.store.browserVisibility&&document.hasFocus()&&this.props.store.seenConvo(this.props.cid)}),500),this.checkAndSeen()}componentDidMount(){this.setState({isShowTyping:!1,typing_event:{}}),this.props.store.onConvoEvent(this,(e=>{if(t.A.convoOfEv(e)!==this.props.cid)return;if("user"===t.A.get(e,"by.type"))return;let i=t.A.get(this.state.typing_event,"by.id");return i&&t.A.get(e,"by.id")!==i?void 0:"message_sent"===t.A.get(e,"type")?(this.timer&&t.A.clearTimeout(this.timer),this.timer=null,void this.setState({isShowTyping:!1})):void("conversation_typing"===t.A.get(e,"type")&&("agent"!=(this.props.store.matchAgent(t.A.get(e,"by.id"))||{}).type||t.A.get(this.props.plugin,"chatbox.show_agent_typing"))&&(this.setState({typing_event:e,isShowTyping:!0}),this.timer&&t.A.clearTimeout(this.timer),this.timer=t.A.setTimeout((()=>{t.A.convoOfEv(e)===this.props.cid&&(this.timer=null,this.setState({isShowTyping:!1}))}),5e3)))}))}componentDidUpdate(t){t.cid!==this.props.cid&&this.loadConvo()}ShowTyping(){this.setState({isShowTyping:!0,typing_event:{id:"evzz"+t.A.Date.now(),created:t.A.Date.now(),by:{type:"agent"},type:"conversation_typing"}}),this.timer&&t.A.clearTimeout(this.timer),this.timer=t.A.setTimeout((()=>{this.timer=null,this.setState({isShowTyping:!1})}),5e3)}render(){if(this.state.error)return this.renderError();let e=t.A.map(this.props.store.listEvents(this.props.cid));if(!this.state.loading&&0===t.A.size(e)&&!this.props.cid)return(0,z.h)("div",{ref:t=>this.refBody=t,class:"widget-body--events-container"},(0,z.h)("div",{class:"widget-body--empty"},(0,z.h)("div",{class:"widget-body--empty-icon"}),(0,z.h)("div",{class:"widget-body--empty-text"},this.props.t("empty_convo_text"))),(0,z.h)(V,{store:this.props.store}));e=t.A.orderBy(e,"created","asc");let i=this.props.store.matchConvo(this.props.cid);e=t.A.map(e,(t=>({ev:t})));let s=this.state.typing_event||{id:"evzz"+t.A.Date.now(),created:t.A.Date.now(),by:{type:"agent"}},r={is_typing:!0,is_show:this.state.isShowTyping,id:s.id,ev:{id:s.id,created:s.created,by:s.by,type:"message_sent",data:{message:{text:"...",conversation_id:this.props.cid}}}};e.push(r),function(e,i){if(!((i=i.filter((t=>bt(t.ev)))).length<1)){for(var s,r=1;r<i.length;r++){let e=i[r],n=i[r-1];"user"==t.A.get(e,"ev.by.type")||e.is_typing||(s=e),bt(e.ev)&&t.A.unixSec(e.ev.created)-t.A.unixSec(n.ev.created)>300&&(e.show_time=!0)}for(s&&(s.show_time=!0),r=0;r<i.length;r++){let e=i[r];if("message_sent"===t.A.get(e,"ev.type")){e.show_time=!0;break}}for(r=0;r<i.length;r++){let e=i[r],s=i[r-1];"message_sent"!==e.ev.type||(e.mode="lead","message_sent"===t.A.get(s,"ev.type")&&t.A.get(s,"ev.by.id")===t.A.get(e,"ev.by.id")&&(e.mode="follow"))}}}(0,e);let n=t.A.map(e,(e=>{let s=e.ev.id===t.A.get(i,"last_message_sent.id");return(0,z.h)(vt,{isLast:s,chatbox:this.props.chatbox,onLink:this.props.onLink,store:this.props.store,onFormSubmit:this.props.onFormSubmit,onSend:this.props.onSend,onPostback:this.props.onPostback,event:e,t:this.props.t,key:e.ev.id})})),o=null,a="opacity: 1 !important";return this.props.creating&&(o=(0,z.h)(Q.A,{static:!0,mode:t.A.get(this.props.chatbox,"primary_color","dark"),size:"120",center:!0}),a="opacity: 0 !important"),this.state.loading&&t.A.Date.now()-this.state.loading>500&&(o=(0,z.h)(Q.A,{static:!0,mode:t.A.get(this.props.chatbox,"primary_color","dark"),size:"120",center:!0}),a="opacity: 0 !important"),(0,z.h)(z.FK,null,o,(0,z.h)("div",{style:a,ref:t=>this.refBody=t,class:"widget-body--events-container",onMouseOver:this.checkAndSeen},(0,z.h)("div",{class:"widget-body--events"},n),(0,z.h)(V,{store:this.props.store})))}renderError(){let t=(0,z.h)("a",{href:"#",onclick:t=>this.loadConvo()},this.props.t("try_again"));return this.state.loading&&(t=(0,z.h)(Q.A,{size:"16",mode:"blue"})),(0,z.h)("div",{class:"widget-body--events-container widget-body--events-container__error"},(0,z.h)("img",{alt:"empty",src:_t}),(0,z.h)("div",{class:"widget_body__events__error_msg"},this.props.t("load_convo_error")),(0,z.h)("div",{class:"widget_body__events__error_retry"},t))}focus(){let e=this.props.store.listEvents(this.props.cid);var i;e=t.A.orderBy(t.A.map(e),"created","desc");for(let s of e)if("message_sent"===t.A.get(s,"type")&&"user"!==t.A.get(s,"by.type")){i=s;break}"user"===t.A.get(i,"by.type")&&(i=null);let s=t.A.get(i,"data.message.attachments",[]),r=this.props.store.matchConvo(this.props.cid);t.A.filter(s,(e=>{if(!e)return!1;if("form"!==e.type&&"ask_info_form"!==e.type)return!1;var i=e.form;return!(!i||!(t.A.parseJSON(i.state)||{}).require_finished&&"ask_info_form"!==e.type||function(e){let i=t.A.get(e,"fields")||[];return t.A.find(i,(t=>!!t.answered))}(e.form)||"ended"===r.state)}))}onEvent(e){if(t.A.convoOfEv(e)!==this.props.cid)return;let i=this.isBottom();var s=!1;"message_sent"===t.A.get(e,"type")&&e.id===t.A.get(e,"data.message.idempotency_key")&&(s=!0),(s||i)&&this.scrollToBottom()}async loadConvo(){if(!this.props.cid)return;this.lastContentOffsetY=0,this.setState({loading:!1});let e=this.props.store.listEvents(this.props.cid);if(0===t.A.size(e)){this.setState({loading:t.A.Date.now()}),t.A.setTimeout((()=>{this.forceUpdate()}),800);let e=this.props.cid,{error:i}=await this.props.store.fetchMoreEvents(e);if(this.setState({loading:!1}),e!==this.props.cid)return;if(i)return void this.setState({error:!0})}this.props.store.fetchMoreEvents(this.props.cid),this.setState({error:!1}),this.scrollToBottom()}isBottom(){let t=this.refBody;return!!t&&t.scrollHeight<t.scrollTop+t.offsetHeight+50}scrollToBottom(){t.A.setTimeout((()=>{const t=this.refBody;t&&(t.scrollTop=t.scrollHeight)})),t.A.setTimeout((()=>{const t=this.refBody;t&&(t.scrollTop=t.scrollHeight)}),100),this.props.isShow&&"visible"===this.props.store.browserVisibility&&document.hasFocus()&&this.props.store.seenConvo(this.props.cid)}}function bt(e){let i=t.A.get(e,"type");return"message_sent"===i||("conversation_state_updated"===i?"ended"==t.A.get(e,"data.conversation.state"):void 0)}var wt=n(2988);class kt extends L.Mw{constructor(t){var e,i,s;super(t),e=this,s={hide:!0,ratingHeight:0,overlayOpacity:.3,comment:""},(i=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(i="state"))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,this.refComment=(0,z._3)(),this.refRating=(0,z._3)(),this.refHandle=(0,z._3)()}componentDidMount(){this.props.store.onUpdate(this,(()=>{this.shoudDisplay()&&this.open()})),this.props.store.onConvoEvent(this,(e=>{t.A.convoOfEv(e)===this.props.cid&&this.shoudDisplay()&&this.open()})),this.mouseUp=t=>this.onMouseUp(t),this.mouseMove=t=>this.onMouseMove(t),this.mouseDown=t=>this.onMouseDown(t);var e=this.refHandle.current;e.addEventListener("mousedown",this.mouseDown,{passive:!0}),e.addEventListener("touchstart",this.mouseDown,{passive:!0}),window.addEventListener("mouseup",this.mouseUp,{passive:!0}),window.addEventListener("touchend",this.mouseUp,{passive:!0}),window.addEventListener("mousemove",this.mouseMove,{passive:!0}),window.addEventListener("touchmove",this.mouseMove,{passive:!0}),this.animation=new wt.A({maxY:400,minY:0,duration:150}),this.close(),(this.shoudDisplay()||"rating"===this.props.forceView)&&this.open()}componentWillUnmount(){var t=this.refHandle.current;t.removeEventListener("mousedown",this.mouseDown,0),t.removeEventListener("touchstart",this.mouseDown,0),window.removeEventListener("mouseup",this.mouseUp,0),window.removeEventListener("touchend",this.mouseUp,0),window.removeEventListener("mousemove",this.mouseMove,0),window.removeEventListener("touchmove",this.mouseMove,0)}render(){let t=this.state.hide?"d-none":"";return(0,z.h)("div",{class:t},(0,z.h)("div",{class:"rating--overlay",style:`opacity: ${.5*this.state.overlayOpacity} !important;`}),(0,z.h)("div",{class:"rating",ref:this.refRating,style:`color:red; height: ${this.state.ratingHeight}px !important;`},(0,z.h)("div",{class:"rating--handle",ref:this.refHandle},(0,z.h)("div",{class:"rating--thumb"})),(0,z.h)("div",{class:"rating--content"},(0,z.h)("div",{class:"rating--heading"},this.props.t("rating_title"),(0,z.h)("div",{class:"rating--close-btn",onClick:t=>this.onCloseRating(t)})),(0,z.h)("div",{class:"rating--description"},this.props.t("rating_description")),(0,z.h)("textarea",{ref:this.refComment,type:"text",class:"rating--comment"}),(0,z.h)("div",{class:"rating-faces-container"},(0,z.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingPoor(t)},(0,z.h)("img",{alt:"poor",src:n(9801)}),(0,z.h)("p",{class:"rating-face--text"},this.props.t("poor"))),(0,z.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingAverage(t)},(0,z.h)("img",{alt:"average",src:n(7134)}),(0,z.h)("p",{class:"rating-face--text"},this.props.t("average"))),(0,z.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingGreat(t)},(0,z.h)("img",{alt:"great",src:n(940)}),(0,z.h)("p",{class:"rating-face--text"},this.props.t("great")))),(0,z.h)("div",{class:"rating-no-thanks",onClick:t=>this.onCloseRating(t)},this.props.t("no_thanks")))))}shoudDisplay(){if(!this.props.cid)return!1;let e,i,s,r=0,n=this.props.store.matchUser(),o=!1;if(t.A.map(this.props.store.listEvents(this.props.cid),(a=>{a&&a.by&&("message_sent"===a.type&&("user"===t.A.get(a,"by.type")&&(o=!0),a.created>r&&(r=a.created)),"conversation_state_updated"===a.type&&"ended"===t.A.get(a,"data.conversation.state")&&(s=a),"conversation_rating_requested"===a.type&&(e=a),"conversation_rated"===a.type&&a.by.id===n.id&&(i=a))})),!o)return!1;if(i)return!1;let a=this.props.plugin.chatbox.auto_request_rating&&s;return a&&(a=!!r&&a&&Date.now()-r<9e5),e||a}onCloseRating(){this.props.onRate&&this.props.onRate({no_rating:!0,comment:this.refComment.current.value}),this.close()}onRatingPoor(){this.props.onRate&&this.props.onRate({rating:1,comment:this.refComment.current.value}),this.close()}onRatingAverage(){this.props.onRate&&this.props.onRate({rating:3,comment:this.refComment.current.value}),this.close()}onRatingGreat(){this.props.onRate&&this.props.onRate({rating:5,comment:this.refComment.current.value}),this.close()}open(){if(this.state.hide&&(this.setState({hide:!1}),this.refRating.current)){t.A.setTimeout((()=>{this.refComment.current&&this.refComment.current.focus()}),400),this.refComment.current.value="";var e=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),i=parseFloat(e.height);this.animation.play(-20,i,(t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)})}))}}close(){if(!this.state.hide&&this.refRating.current){var t=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),e=parseFloat(t.height);this.animation.play(20,e,(t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)}),t<10&&(this.state.hide||this.setState({hide:!0}))}))}}onMouseDown(t){this.mousePushed=!0,this.animation.stop(),t.preventDefault(),t.touches&&t.touches[0]&&(t=t.touches[0]),this.mousePushedDy=t.pageY-window.pageYOffset-this.refRating.current.getBoundingClientRect().y}onMouseUp(t){if(this.mousePushed){t.touches&&t.touches[0]&&(t=t.touches[0]),this.mousePushed=!1;var e=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),i=parseFloat(e.height);this.animation.play(this.mouseVelocity,i,(t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)}),t<10&&(this.state.hide||(this.setState({hide:!0}),this.props.onRate&&this.props.onRate({no_rating:!0})))}))}}onMouseMove(t){if(this.mousePushed){t.touches&&t.touches[0]&&(t=t.touches[0]);var e=t.pageY;this.mouseVelocity=e-this.lastMouseY,this.lastMouseY=e,e-=this.mousePushedDy;var i=this.refRating.current.getBoundingClientRect().bottom-e;i>400&&(i=500-1e4/(i+-300)),this.setState({ratingHeight:i,overlayOpacity:Math.min(1,(i-0)/500)})}}}function At(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class xt extends L.Mw{constructor(t){super(t),At(this,"onChangeConnectionStatus",(()=>{let t=this.props.store.getConnectionStatus(),e=this.state.status;this.setState({status:t}),"active"!==e&&"active"===t&&this.changeStatusFailedToSuccess()})),At(this,"changeStatusFailedToSuccess",(()=>{this.setState({status:"just_active"}),this.props.cid&&this.props.store.fetchMoreEvents(this.props.cid),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((()=>{this.setState({status:"active"})}),2e3)})),this.props.store.onConnection(this,this.onChangeConnectionStatus),this.state={status:this.props.store.getConnectionStatus()}}render(){if("active"===this.state.status)return;let t="widget-internet-status",e="";return"just_active"!==this.state.status?(t+=" negative",e=`${this.props.t("network_error")}. ${this.props.t("try_reconnecting")}...`):(t+=" positive",e=this.props.t("reconnect_successfully")),(0,z.h)("div",{class:t},e)}}class Ct extends L.Mw{constructor(t){super(t),this.setState({search:"",isShow:!1})}render(){let e=t.A.filter(this.props.items,(t=>{let e=this.state.search.toLowerCase();return(t||"").toLowerCase().indexOf(e)>-1})),i=t.A.map(e,(t=>(0,z.h)("li",{class:"custom-select--item-options",onClick:()=>this.add(t)},t))),s=t.A.map(this.props.selected,((t,e)=>(0,z.h)("div",{class:"custom-select--selected-item",onClick:t=>this.remove(t,e)},t,(0,z.h)("i",{class:"icn-delete delete-tag"})))),r=(0,z.h)("div",{class:"custom-select--wrap-options"},(0,z.h)("input",{onClick:t=>{t.preventDefault(),t.stopPropagation(),this.setState({isShow:!0})},type:"text",onInput:t=>this.setState({search:t.target.value}),value:this.state.search,placeholder:"Tìm kiếm",class:"custom-select--input-search"}),(0,z.h)("ul",{class:"custom-select--items-options"},i));return this.state.isShow||(r=null),(0,z.h)("div",{class:"form-control custom-select"},(0,z.h)(L.tW,{onClickaway:t=>this.clickaway()},(0,z.h)("div",{class:"custom-select--wrap-selected",onClick:()=>this.setState({isShow:!this.state.isShow})},(0,z.h)("div",{class:"custom-select--selected-items"},s),r,(0,z.h)("div",{class:"custom-select--icon-dropdown"},(0,z.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,z.h)("g",{opacity:"0.6"},(0,z.h)("path",{d:"M7 9.5L12 14.5L17 9.5H7Z",fill:"black"})))))))}clickaway(){this.setState({isShow:!1})}add(t){this.props.onAddItem&&this.props.onAddItem(t)}remove(t,e){t.preventDefault(),t.stopPropagation(),this.props.onRemoveItem&&this.props.onRemoveItem(e)}}function St(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var Mt=n(8506),Pt=n(9150),Et=n(9419);let jt=!1;const It="https://vcdn.subiz-cdn.com/file/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png";class Tt extends L.Mw{constructor(e){super(e),St(this,"msgInput",(0,z._3)()),St(this,"formMounted",(e=>{let i=this.fillForm(e);(e.question_required||this.state.quickReplyMessage.text)&&(i.question={key:"question",is_required:!0,label:this.props.t.i18n(t.A.get(e,"i18n_question_label",{}))||e.question_label,type:"text",value:this.state.quickReplyMessage.text}),this.setState({formData:i}),this.props.store.isMobile()||e._updated||this.focusInput()})),St(this,"sendMessage",(async e=>{let i=t.A.find(e.attachments,(t=>"postback"===t.type));if(this.isFormRequired()&&i)return this.onStartConvoClick(),void this.fillQuickReplyToQuestion(e);let s=e.text;if(!this.props.cid){this._creating=(this._creating||0)+1;let t=this._creating;this.setState({creating:!0});const{convo:i,error:r}=await this.props.store.startConvo({locale:this.props.t.locale(),message:s,initial_by:this.props.store.matchUser().id});if(t!=this._creating)return;if(r)return void this.setState({creating:!1});if(await this.props.store.sendConvoEvent(i.id,"message_sent",{message:e}),t!=this._creating)return;return this.props.onGo({view:"chat",cid:i.id}),void this.setState({creating:!1})}t.A.setTimeout((async()=>{await this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:e}),this.setState({creating:!1})}),1)})),St(this,"onLink",((e,i)=>{if(!i)return e.preventDefault();let s=i.replace(/(^\w+:|^)\/\//,"");if(s.startsWith("widget.subiz.com.vn/orders/")){let i=s.substr(27);return i=i.split("/")[0],t.A.setTimeout((async()=>{jt||(jt=(await n.e(185).then(n.bind(n,4185))).default),this.setState({showOrder:!0,order_id:i})})),void e.preventDefault()}})),St(this,"closeOrder",(t=>{this.setState({showOrder:!1,order_id:""}),this.focusInput()})),this.userSent={},this.wasFormInputed=!1,this.setState({creating:!1,clickedJoin:!1,formData:{},showOrder:!1,order_id:"",quickReplyMessage:{}}),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.refTyping=(0,z._3)()}componentDidMount(){this.props.store.isMobile()||this.focusInput(),this.updateFormDataFields()}applyMessage(t){this.focusInput(t)}componentDidUpdate(e){e.isShow!==this.props.isShow&&(this.props.isShow&&!this.props.store.isMobile()&&this.focusInput(),this.props.isShow&&this.props.store.isMobile()&&this.blur(),this.updateFormDataFields()),e.cid!==this.props.cid&&(this.closeOrder(),this.setState({clickedJoin:!1,quickReplyMessage:{}}),t.A.setTimeout((()=>{this.$events&&this.$events.focus(),this.props.store.isMobile()||this.focusInput()}),100),this.updateFormDataFields())}ShowTyping(){this.$events&&this.$events.ShowTyping()}shouldShowForm(){let e,i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};t.A.get(i,"prechat_form.enabled")&&(e=i.prechat_form);let r=t.A.get(i,"offline_form.enabled");if(this.isOffline(s,i)&&r&&(e=i.offline_form),!this.hasSentMessage(this.props.cid)&&e&&(t.A.size(e.groups)||e.group_required))return!0;let n=this.isFormRequired();return n&&!this.props.cid||n&&this.props.cid&&this.state.clickedJoin}render(){let e,i=this.shouldShowForm(),s="",r=this.props.plugin.chatbox||{},n=this.props.store.matchAccount()||{},o=this.props.t("prechat_form_btn");t.A.get(r,"prechat_form.enabled")&&(e=r.prechat_form);let a=t.A.get(r,"offline_form.enabled");this.isOffline(n,r)&&a&&(e=r.offline_form,o=this.props.t("offline_form_btn"),s="offline"),"offline_form"===this.props.view&&(i=!0,e=r.offline_form,s="offline",o=this.props.t("offline_form_btn")),"prechat_form"===this.props.view&&(i=!0,e=r.prechat_form,o=this.props.t("prechat_form_btn"),s="prechat");let l=null;l="list"===this.props.view?this.renderConvoList():i?this.renderForm(e,o,s):this.renderChat();let c=t.A.get(r,"desktop_button.position")||"right";this.props.store.isMobile()&&(c=t.A.get(r,"mobile_button.position",c));let h="widget-container widget-container--"+c;var u;return this.props.store.isMobile()||"full"!==t.A.get(r,"window_mode")||(h+=" widget-container--full"),this.props.isShow||(h+=" widget-container--hide"),t.A.get(r,"header.hidden",!1)||(u=(0,z.h)(H,{t:this.props.t,plugin:this.props.plugin,store:this.props.store,cid:this.props.cid,view:this.props.view,onClose:this.props.onClose,onGotoList:()=>this.props.onGo({view:"list"})})),(0,z.h)("div",{class:h},u,l)}validateForm(e){let i={};return t.A.map(e,((e,s)=>{if((e=Object.assign({},e)).is_empty_error=!1,e.is_required&&(void 0===e.value||""===e.value||0===t.A.size(e.value)&&Array.isArray(e.value))?(e.is_empty_error=!0,e.error=this.props.t("error_empty")):e.error="","emails"===s.substr(5))if(e.is_required)t.A.isEmail(e.value)||(e.error=this.props.t("error_email_invalid"));else{let i=e.value||"";"string"!=typeof i&&(i+=""),i.trim()&&!t.A.isEmail(e.value)&&(e.error=this.props.t("error_email_invalid"))}if("phones"===s.substr(5))if(e.is_required)t.A.isPhone(e.value)||(e.error=this.props.t("error_phone_invalid"));else{let i=e.value||"";"string"!=typeof i&&(i+=""),i.trim()&&!t.A.isPhone(e.value)&&(e.error=this.props.t("error_phone_invalid"))}i[s]=e})),i}async submitPrechatForm(e,i){if(this.state.submiting)return;let s=this.validateForm(this.state.formData);if(t.A.find(s,(t=>!!t.error)))return this.setState({formData:s}),void this.focusInput();let r=t.A.cloneDeep(this.state.formData),n=t.A.cloneDeep(this.props.store.matchUser()),o=!1;t.A.map(r,((e,i)=>{if(i.startsWith("attr:")){var s={key:i.substr(5)};o=o||"emails"==i||"phones"==i,"number"===e.type&&(s.number=parseInt(e.value)),"datetime"===e.type&&(s.datetime=new t.A.Date(e.value).toISOString()),"list"===e.type&&(s.text=e.value),"text"!==e.type&&"boolean"!==e.type||(s[e.type]=e.value),t.A.setUserAttr(n,s)}})),o&&t.A.setUserAttr(n,{key:"lead_source",text:"widget"});let a=t.A.get(r,"question.value",this.props.t("get_started")),l=t.A.get(r,"group.value","");this._creating=(this._creating||0)+1;let c=this._creating;this.setState({creating:!0});let h=t.A.map(r,((e,i)=>({key:i,type:e.type,value:t.A.stringify(e.value)})));if(await this.props.store.submitForm("chatbox_"+i,h,n),await t.A.sleep(500),c!=this._creating)return;if(this.props.cid){if(this.setState({clickedJoin:!1}),await this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{text:a,format:"plaintext",fields:[{key:"to_agent_group",value:t.A.stringify(l)}],attachments:this.state.quickReplyMessage.attachments}}),c!=this._creating)return;return this.setState({creating:!1,quickReplyMessage:{}}),e.end_conversation_after_submit&&await this.props.store.endConvo(this.props.cid),void this._creating}let u={text:a,format:"plaintext"},d={group_id:l,message:a,locale:this.props.t.locale(),initial_by:n.id};this.setState({creatingError:null});const{error:p,convo:m}=await this.props.store.startConvo(d);if(c!=this._creating)return;if(p)return void this.setState({creating:!1,creatingError:p});let g=m.id;this.userSent[g]=!0,await this.props.store.sendConvoEvent(g,"message_sent",{message:u}),c==this._creating&&(this.setState({creating:!1,clickedJoin:!1,quickReplyMessage:{}}),this.props.onGo({view:"chat",cid:g}),this.props.store.isMobile()||this.focusInput())}onBooleanChange(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=i.target.checked,this.setState({formData:s}))}onKeywordField(t,e,i,s){"Enter"==t.code&&this.submitPrechatForm(e,i)}onInputChange(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=i,r.error=void 0,this.setState({formData:s}))}onListAddItem(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=r.value||[],r.value.push(i),this.setState({formData:s}))}onListRemoveItem(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=r.value||[],r.value.splice(i,1),this.setState({formData:s}))}renderCheckboxField(e){let i=t.A.get(e,"def.items",[]),s=[],r=e.value||"";return r&&(s=r.split(",")),(0,z.h)("div",null,t.A.map(i,(t=>(0,z.h)("div",{class:"checkbox"},(0,z.h)("input",{type:"checkbox",id:"form-checkbox"+Lt(e.key)+t.value,onChange:i=>this.toggleCheckboxField(e.key,t.value),checked:s.includes(t.value)}),(0,z.h)("label",{class:"checkbox--label",for:"form-checkbox"+Lt(e.key)+t.value},this.props.t.i18n(t.i18n_label)||t.label||t.value),(0,z.h)("div",{class:"checkbox--check"},(0,z.h)("div",null))))))}toggleCheckboxField(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>t.key===e));if(!r)return;let n=r.value||"",o=[];n&&(o=n.split(",")),o.includes(i)?o=t.A.filter(o,(t=>t!==i)):o.push(i),r.value=o.join(","),this.setState({formData:s})}renderRadioField(e){let i=t.A.get(e,"def.items",[]),s=e.value||"";return(0,z.h)("div",null,t.A.map(i,(t=>(0,z.h)("div",{class:"radio"},(0,z.h)("input",{type:"radio",name:"form-radio"+Lt(e.key),id:"form-radio"+Lt(e.key)+t.value,onChange:i=>this.toggleRadioField(e.key,t.value),checked:s===t.value}),(0,z.h)("label",{class:"radio--label",for:"form-radio"+Lt(e.key)+t.value},this.props.t.i18n(t.i18n_label)||t.label||t.value),(0,z.h)("div",{class:"radio--check"},(0,z.h)("div",null))))))}toggleRadioField(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>t.key===e));r&&(r.value=i,this.setState({formData:s}))}selectDropdownField(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>t.key===e));r&&(r.value=i,this.setState({formData:s}))}renderDropdownField(e){let i=t.A.get(e,"def.items",[]);return(0,z.h)("select",{class:"form-control",value:e.value,onChange:t=>this.selectDropdownField(e.key,t.target.value)},(0,z.h)("option",{value:""},"-- ",this.props.t("no_select")," --"),t.A.map(i,(t=>(0,z.h)("option",{value:t.value},this.props.t.i18n(t.i18n_label)||t.label||t.value))))}renderFields(e,i){if(0===t.A.size(this.state.formData))return null;let s=t.A.map(this.state.formData,((s,r)=>{if(this.state.quickReplyMessage.text&&"question"===r)return null;let n=null;var o=s.error?"input--error":"";if("text"===s.type)n="question"==r||t.A.get(s,"def.multiple_line")?(0,z.h)("textarea",{class:`form-control ${o}`,ref:t=>{this["form_"+Lt(r)]=t},id:"form_"+Lt(r),value:s.value||"",onInput:t=>this.onInputChange(r,t.target.value),onChange:t=>this.onInputChange(r,t.target.value),row:"4"}):"checkbox"===t.A.get(s,"def.select")?this.renderCheckboxField(s):"radio"===t.A.get(s,"def.select")?this.renderRadioField(s):"dropdown"===t.A.get(s,"def.select")?this.renderDropdownField(s):(0,z.h)("input",{id:"form_"+Lt(r),value:s.value||"",onInput:t=>this.onInputChange(r,t.target.value),onChange:t=>this.onInputChange(r,t.target.value),onKeyDown:t=>this.onKeywordField(t,e,i,r),ref:t=>{this["form_"+Lt(r)]=t},class:`form-control ${o}`,type:"text"});else if("number"===s.type)n=(0,z.h)("input",{id:"form_"+Lt(r),value:s.value,onInput:t=>this.onInputChange(r,t.target.value),ref:t=>{this["form_"+Lt(r)]=t},class:`form-control ${o}`,type:"number"});else if("boolean"===s.type)n=(0,z.h)("div",{class:"checkbox"},(0,z.h)("input",{type:"checkbox",id:"form-checkbox"+Lt(r),onInput:t=>this.onBooleanChange(r,t),checked:s.value}),(0,z.h)("label",{class:"checkbox--label",for:"form-checkbox"+Lt(r)},s.label),(0,z.h)("div",{class:"checkbox--check"},(0,z.h)("div",null)));else if("group"===s.type)n=t.A.map(s.list,(t=>(0,z.h)("div",{class:"radio"},(0,z.h)("input",{type:"radio",id:"form-radio"+Lt(r)+Lt(t.value),checked:s.value===t.value,onInput:e=>this.onInputChange(r,t.value)}),(0,z.h)("label",{class:"radio--label",for:"form-radio"+Lt(r)+Lt(t.value)},this.props.t.i18n(t.i18n_label)||t.label||t.value),(0,z.h)("div",{class:"radio--check"},(0,z.h)("div",{class:"inside"})))));else if("list"===s.type){let e=this.state.formData[r].value||[],i=t.A.filter(t.A.get(s,"list",[]),(i=>!t.A.includes(e,i)));n=(0,z.h)(Ct,{selected:e,items:i,onAddItem:t=>this.onListAddItem(r,t),onRemoveItem:t=>this.onListRemoveItem(r,t)}),n=this.renderDropdownField(s)}else"datetime"===s.type&&(n=(0,z.h)("input",{id:"form_"+Lt(r),value:s.value,onInput:t=>this.onInputChange(r,t.target.value),class:`form-control ${o}`,type:"date"}));let a="";return"fullname"===s.key?a=this.props.t("fullname"):"emails"===s.key?a=this.props.t("email"):"phones"===s.key?a=this.props.t("phones"):"question"===s.key&&(a=s.label||this.props.t("your_question")),s.label&&(a=s.label),(0,z.h)("div",{key:"form_"+Lt(r)},(0,z.h)("label",{class:"label",for:"form_"+Lt(r)},a,s.is_required?(0,z.h)("span",{class:"red"},"*"):""),n,s.error?(0,z.h)("div",{class:"form-control--valid-input--error"},s.error):"")}));return(0,z.h)("div",{class:"pt-2"},s)}renderForm(e,i,s){let r=this.props.t.i18n(t.A.get(e,"i18n_title",{}));r||(r=t.A.get(e,"title",this.props.t("capture_lead_title"))),r=r.replace("↵","");let n=t.A.find(this.state.formData,(t=>!!t.error)),o=this.validateForm(this.state.formData),a=t.A.find(o,(t=>!!t.is_empty_error));return(0,z.h)("div",{class:"widget-body"},(0,z.h)(Dt,{key:e._updated,form:e,onMount:this.formMounted}),(0,z.h)("div",{class:"widget-body--content flex-grow-1 pl-3 pr-3 pb-2 d-flex flex-column"},(0,z.h)("div",{class:"mt-2 d-flex flex-column"},(0,z.h)("div",null,r),this.renderFields(e,s)),(0,z.h)("div",{style:"min-height: 15px !important; flex: 1 !important; flex-shrink: 0 !important"}),(0,z.h)("button",{class:"btn--start-convo ",onClick:t=>this.submitPrechatForm(e,s),disabled:!!a||!!n||this.state.creating},i)))}goToConvo(t){this.props.onGo({view:"chat",cid:t})}renderConvoList(){let e=this.props.store.matchConvo("*");var i=t.A.map(e,(t=>this.props.store.matchConvo(t.id)));i=t.A.filter(i,(t=>!!t)),i=t.A.orderByF(i,(e=>t.A.get(e,"last_message_sent.created",e.actived)),"desc");var s=t.A.map(i,(e=>{let i=t.A.filter(e.members,(t=>"agent"===t.type&&"active"===t.membership||"bot"===t.type)),s=t.A.map(i,(t=>t.id));return s=s||t.A.agentsOfConvo(e)[0],(0,z.h)("div",{class:"convo-list--item",onClick:()=>this.goToConvo(e.id),key:e.id},(0,z.h)(N,{plugin:this.props.plugin,store:this.props.store,mode:"secondary",class:"d-flex flex-row",tooltipPos:"right",agent_ids:[s[0]]}),this.renderConvoSummary(e))}));let r=(0,z.h)("div",{class:"convo-list--list"},s);return 0===t.A.size(i)&&(r=(0,z.h)("div",{class:"convo-list--list"},(0,z.h)("div",{class:"empty-container"},(0,z.h)("img",{alt:"empty",src:Et}),(0,z.h)("div",{class:"empty-desc"},this.props.t("empty_convo"))))),(0,z.h)("div",{class:"convo-list"},(0,z.h)("div",{class:"convo-list--container"},(0,z.h)("div",{class:"convo-list--title"},this.props.t("conversations")),r),(0,z.h)("div",{class:"convo-list--footer"},(0,z.h)(V,{store:this.props.store}),(0,z.h)("button",{class:"btn--start-convo",onClick:t=>this.goToConvo("")},(0,z.h)("span",null,this.props.t("start_conversation")),(0,z.h)("img",{src:Mt,alt:"send button",width:"26",height:"26"})),(0,z.h)("div",{class:"mt-2"})))}blur(){if(!this.props.store.isPreview){var e=this.msgInput.current;e&&(t.A.setTimeout((()=>e&&e.blur())),t.A.setTimeout((()=>e&&e.blur()),300))}}focusInput(e){if(!this.props.store.isPreview){if(this.shouldShowForm()){let e="";return t.A.map(this.state.formData,((t,i)=>{e||"text"!==t.type||t.value&&!t.error||(e=i)})),(i=this["form_"+Lt(e)])&&i.focus(),void t.A.setTimeout((()=>{t.A.map(this.state.formData,((t,i)=>{e||"text"!==t.type||t.value&&!t.error||(e=i)}));var i=this["form_"+Lt(e)];i&&i.focus()}),200)}var i;(i=this.msgInput.current)&&(null!=e&&"string"==typeof e&&i.applyMessage(e),t.A.setTimeout((()=>i.focus())),t.A.setTimeout((()=>i.focus()),300))}}onRate(t){this.props.cid&&(this.props.store.sendConvoEvent(this.props.cid,"conversation_rated",{conversation:{ratings:[t]}}),this.focusInput())}fillQuickReplyToQuestion(e){let i=this.state.formData;i&&t.A.set(i,"question.value",e.text||this.props.t("get_started")),this.setState({formData:i,quickReplyMessage:e})}createPostback(t){this.props.store.createPostback(this.props.cid,t)}onChangeMessageInput(){this.wasFormInputed=!0}renderChat(){let t=(0,z.h)(X,{store:this.props.store,ref:this.msgInput,cid:this.props.cid,onChange:this.onChangeMessageInput,is_loading:this.state.creating,onSend:this.sendMessage,t:this.props.t}),e=this.props.store.matchConvo(this.props.cid)||{};return(this.isFormRequired()||"ended"===e.state)&&(t=(0,z.h)("div",{class:"message-input message-input--preform"},(0,z.h)("button",{class:"btn--start-convo",onClick:t=>this.onStartConvoClick(t)},this.props.t("offline_preform_btn")))),(0,z.h)("div",{class:"widget-body"},(0,z.h)("div",{class:"widget-body--content",onClick:t=>this.onContainerClick(t)},(0,z.h)(yt,{isShow:this.props.isShow,onLink:this.onLink,store:this.props.store,chatbox:this.props.plugin.chatbox||{},onFormSubmit:t=>this.onEventFormSubmit(t),ref:t=>this.$events=t,cid:this.props.cid,creating:this.creating,onSend:t=>this.sendMessage(t),onPostback:t=>this.createPostback(t),t:this.props.t,plugin:this.props.plugin}),(0,z.h)(xt,{cid:this.props.cid,store:this.props.store,t:this.props.t})),(0,z.h)(kt,{forceView:this.props.view,plugin:this.props.plugin,store:this.props.store,onRate:t=>this.onRate(t),cid:this.props.cid,t:this.props.t}),(0,z.h)(jt,{forceView:this.props.view,plugin:this.props.plugin,show:this.state.showOrder,order_id:this.state.order_id,store:this.props.store,onClose:this.closeOrder,cid:this.props.cid,t:this.props.t}),t)}async onStartConvoClick(){if("ended"===(this.props.store.matchConvo(this.props.cid)||{}).state)return this.props.onGo({view:"chat",cid:""});this.setState({clickedJoin:!0,quickReplyMessage:{}})}onEventFormSubmit(){this.focusInput()}onContainerClick(){window.getSelection().toString().length>0||this.props.store.isMobile()||this.focusInput()}isFormRequired(){let e,i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};t.A.get(i,"prechat_form.enabled")&&(e=i.prechat_form);let r=t.A.get(i,"offline_form.enabled");if(this.isOffline(s,i)&&r&&(e=i.offline_form),!e)return!1;let n=this.fillForm(e),o=this.props.store.matchConvo(this.props.cid)||{};if("ended"===o.state)return!0;o.state&&"pending"!==o.state&&delete n.group;let a=!0;return t.A.each(n,(t=>{t.value&&(a=!1)})),!(!a||this.userHasSent(this.props.cid))||!!t.A.find(n,(t=>t.is_required&&(null==t.value||""===t.value)))}renderConvoSummary(e){let i=this.props.plugin.chatbox||{},s=this.props.store.matchAgent("*"),r=t.A.filter(e.members,(t=>"agent"===t.type||"bot"===t.type)),n=t.A.map(r,(t=>t.id));n=n||t.A.agentsOfConvo(e)[0];let o=t.A.map(n,(t=>s[t]||{avatar_url:It,fullname:"Offline Agent"}));var a=t.A.each(o,(t=>t.fullname)).join(", ");!i.hide_agent_profile&&a||(a=this.props.store.matchAccount().name),a||(a=this.props.t("agent"));var l=null;"user"===e.lastSenderType&&(l=(0,z.h)("span",null,this.props.t("you"),":"));let c=t.A.isConvoSeen(e,this.props.store.matchUser().id);var h=this.renderMessagePreview(e.last_message_sent),u=t.A.getMs(t.A.get(e,"last_message_sent.created"))||t.A.getMs(e.created);let d=c?null:(0,z.h)("div",{class:"convo-list--item-unread"});return"ended"===e.state&&(d=(0,z.h)("img",{alt:"conversation ended",class:"convo-list--convo-completed",src:Pt,title:this.props.t("conversation_ended")})),(0,z.h)("div",{class:"convo-list--convo-last-info"},(0,z.h)("div",{class:"d-flex flex-row"},(0,z.h)("div",{class:"convo-list--convo-name"},a),(0,z.h)("div",{class:"convo-list--convo-time"},(0,z.h)(dt.A,{ago:!0,time:u,t:this.props.t,short:!0}))),(0,z.h)("div",{class:"d-flex flex-row"},(0,z.h)("div",{class:"convo-list--convo-last-message"},l,h),d))}agentsOfConvo(e){let i=this.props.store.matchAgent("*");var s=t.A.agentsOfConvo(e,!0);return t.A.map(s,(t=>i[t]||{avatar_url:It,fullname:"Offline Agent"}))}renderMessagePreview(e){let i=this.props.t("sent_you_a_message"),s=t.A.get(e,"data.message.text");if("plaintext"!==t.A.get(e,"data.message.format")&&(s=i),!s&&t.A.size(t.A.get(e,"data.message.attachments"))>0&&(s=i),!s)return null;let r=t.A.get(e,"by.type");return(0,z.h)("div",{class:"convo-list--convo-last-mes"},t.A.map(t.A.extractText(s),(t=>"emoji"===t.type?(0,z.h)(U.A,{emojiCode:t.text,byType:r}):t.text)))}userHasSent(e){var i=this.props.store.matchConvo(e)||{};let s=this.props.store.matchUser();return!!this.userSent[e]||t.A.find(i.members,(t=>t.id===s.id&&("active"===t.membership||t.last_sent>0)))}hasSentMessage(e){if(this.userSent[e])return!0;let i=this.props.store.matchConvo(e)||{};return t.A.find(i.members,(t=>"bot"===t.type||t.last_sent))}isOffline(e,i){let s=t.A.get(i,"offline_form.enable_when"),r=!0;return"all_agents_offline"===s&&(r=e.is_online),"out_of_bussiness_hour"===s&&(r=e.is_in_business_hour),!r}updateFormDataFields(){let e,i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};t.A.get(i,"prechat_form.enabled")&&(e=i.prechat_form);let r=t.A.get(i,"offline_form.enabled");if(this.isOffline(s,i)&&r&&(e=i.offline_form),"offline_form"===this.props.view&&(e=i.offline_form),"prechat_form"===this.props.view&&(e=i.prechat_form),0===t.A.size(e))return[];var n={};t.A.each(e.fields,(e=>{var i=Object.assign({},e);"list"===e.type&&(i.list=e.list),i.label=this.props.t.i18n(t.A.get(e,"i18n_label",{}))||e.label,n["attr:"+e.key]=i})),e.group_required&&t.A.size(e.groups)>0&&(n.group={key:"group",is_required:!!e.group_required,label:this.props.t.i18n(t.A.get(e,"i18n_group_label",{}))||e.group_label,type:"group",list:t.A.map(e.groups,(t=>({value:t.id,label:t.name,i18n_label:t.i18n_name})))}),e.question_required&&(n.question={key:"question",is_required:!0,label:this.props.t.i18n(t.A.get(e,"i18n_question_label",{}))||e.question_label,type:"text"}),this.isFormChanged(this.state.formData,n)&&this.setState({formData:n})}isFormChanged(e,i){let s=Object.keys(e),r=Object.keys(i);if(s.length!==r.length)return!0;for(let n=0;n<s.length;n++){if(t.A.get(e,`${s[n]}.label`)!==t.A.get(i,`${r[n]}.label`))return!0;if(t.A.get(e,`${s[n]}.is_required`)!==t.A.get(i,`${r[n]}.is_required`))return!0;if(t.A.stringify(t.A.get(e,`${s[n]}.list`))!==t.A.stringify(t.A.get(i,`${r[n]}.list`)))return!0}return!1}fillForm(e){if(0===t.A.size(e))return[];var i={};let s=this.props.store.matchUser();return t.A.each(e.fields,(e=>{var r=Object.assign({},e);r.value=t.A.getUserAttr(s,e.key,e.type),"emails"!=r.key||r.value||(r.value=t.A.getUserAttr(s,"related_email","text")),"phones"!=r.key||r.value||(r.value=t.A.getUserAttr(s,"related_phone","text")),"boolean"!==e.type||r.value||(r.value=!1),"datetime"===e.type&&r.value&&(r.value=new t.A.Date(i.value).toLocaleDateString("en-CA")),"list"===e.type&&(r.list=e.list),r.label=this.props.t.i18n(t.A.get(e,"i18n_label",{}))||e.label,i["attr:"+e.key]=r})),e.group_required&&t.A.size(e.groups)>0&&(i.group={key:"group",is_required:!!e.group_required,label:this.props.t.i18n(t.A.get(e,"i18n_group_label",{}))||e.group_label,type:"group",list:t.A.map(e.groups,(t=>({value:t.id,label:t.name})))}),i}}class Dt extends L.Mw{componentDidMount(){this.props.onMount(this.props.form)}}function Lt(t){return encodeURIComponent(t)}let zt=n.e(278).then(n.bind(n,9278));class Ut extends L.Mw{constructor(t){super(t),this.refButton=(0,z._3)(),this.refWidget=(0,z._3)()}async refreshCSS(){let e=this.props.store.matchPlugin(),i=t.A.find(e,(t=>t.id===this.props.plugin.id));if(!i)return;let s=(await zt).default.default.toString();var r=t.A.replaceCssVariable(s,i.chatbox);t.A.setCss(this.props.plugin.id,this.$cssStyleDiv,r)}componentWillUnmount(){t.A.setCss(this.props.plugin.id,this.$cssStyleDiv,"")}async componentDidMount(){if(this.$cssStyleDiv=document.getElementById("subiz-style-for-"+this.props.plugin.id),this.$cssStyleDiv||(this.$cssStyleDiv=document.createElement("style"),document.head.appendChild(this.$cssStyleDiv),this.$cssStyleDiv.type="text/css",this.$cssStyleDiv.id="subiz-style-for-"+this.props.plugin.id),this.setState({cssready:!1,isShowWidget:!1,widgetView:"",widgetConvoId:""}),this.checkExpand(),this.props.store.onResetCSS(this,(()=>this.refreshCSS())),this.props.store.onConvoEvent(this,(t=>this.onConvoEvent(t))),this.props.store.onUpdate(this,(t=>this.checkExpand())),await this.refreshCSS(),this.setState({cssready:!0}),this.props.store.matchIsOpen()&&this.props.store.matchLastview().view){if(this.props.store.isMobile())return;this.showWidget(Object.assign({},this.props.store.matchLastview().opts,{view:this.props.store.matchLastview().view}))}else Ft(),this.state.isShowWidget||this.hideWidget()}render(){return this.state.cssready?t.A.isUserBanned(this.props.store.matchUser())?null:this.props.t?(0,z.h)("div",{class:this.props.store.isMobile()?"mobile":"desktop"},(0,z.h)($,{plugin:this.props.plugin,store:this.props.store,key:"chat_button",ref:this.refButton,isShow:!this.state.isShowWidget,onClick:t=>this.showWidget(t),t:this.props.t}),(0,z.h)(Tt,{plugin:this.props.plugin,store:this.props.store,view:this.state.widgetView,cid:this.state.widgetConvoId,isShow:this.state.isShowWidget,onClose:t=>this.onWidgetClose(t),onGo:t=>this.showWidget(t),t:this.props.t,ref:this.refWidget})):null:null}onConvoEvent(t){this.checkExpand(),this.checkShowBotConvo(t)}checkShowBotConvo(e){let i=this.refWidget.current;if(!i)return;if(i.wasFormInputed)return;if("message_sent"!==e.type)return;if(!this.state.isShowWidget)return;let s=t.A.get(e,"by.type");if(!(t.A.get(e,"by.id")||"").startsWith("bb")||"agent"!==s)return;let r=t.A.get(e,"data.message.conversation_id");r&&this.showWidget({cid:r,view:"chat"})}checkExpand(){if(this.props.store.isMobile())return;if(this.props.plugin._no_auto_expand)return;if(this.props.store.matchHasManuallyClosed())return;let e=this.props.store.matchConvo("*"),i=t.A.find(e,(e=>!t.A.isConvoSeen(e,this.props.store.matchUser().id)));i&&i.id&&(this.state.isShowWidget||this.showWidget({view:"chat",cid:i.id}))}getCurrentView(){return{is_show_widget:this.state.isShowWidget,conversation_id:this.state.widgetConvoId,view:this.state.widgetView}}async showWidget(e){if(this.refButton.current&&this.refButton.current.ClearPreview(),!e.view){let i=this.props.store.matchLastview()||{};e.view=t.A.get(i,"view"),e.cid=t.A.get(i,"opts.cid")}if(!(e=e||{}).view&&!e.cid){let i=this.props.store.matchConvo("*"),s=t.A.find(i,(e=>!t.A.isConvoSeen(e,this.props.store.matchUser().id)));e.cid=t.A.get(s,"id",t.A.get(i,"0.id")),e.view="chat"}this.props.store.isMobile()&&function(){document.body&&document.body.classList&&document.body.classList.add("sbz_no_scroll"),document.documentElement&&document.documentElement.classList&&document.documentElement.classList.add("sbz_no_scroll");let t=document.createElement("meta");t.httpEquiv="X-UA-Compatible",t.name="viewport",t.id="subiz-meta-viewport",t.content="maximum-scale=1.0, user-scalable=no, width=device-width, initial-scale=1.0",document.getElementsByTagName("head")[0].appendChild(t)}(),this.setState({widgetConvoId:e.cid,widgetView:e.view}),this.props.store.setIsOpen(!0),this.forceUpdate(),this.setState({isShowWidget:!0}),this.props.store.setLastview(e.view,{cid:e.cid})}applyMessage(t){this.refWidget.current&&this.refWidget.current.applyMessage(t)}showGreeting(){this.refButton.current&&this.refButton.current.ShowGreeting()}hideGreeting(){this.refButton.current&&this.refButton.current.HideGreeting()}showTyping(){this.refWidget.current&&this.refWidget.current.ShowTyping()}hideWidget(){Ft(),this.props.store.setIsOpen(!1),this.setState({isShowWidget:!1})}onWidgetClose(){this.refButton.current&&this.refButton.current.ClearPreview(),this.refButton.current&&this.refButton.current.ClosePreview(),this.props.store.setHasManuallyClosed(),this.hideWidget(),this.props.store.emitCloseWidgetEvent()}}function Ft(){document.body&&document.body.classList&&document.body.classList.remove("sbz_no_scroll"),document.documentElement&&document.documentElement.classList&&document.documentElement.classList.remove("sbz_no_scroll");let t=document.getElementById("subiz-meta-viewport");t&&t.remove()}function Rt(e,i,s,r){if(!s)throw"$div must is a valid html node";var o=document.createElement("div");o.id=e.id;let a=i.matchAccount();o.setAttribute("sbz-plugin-type",e.type),o.setAttribute("sbz-plugin-account-id",a.id),s.appendChild(o);let l=L.JK(e,t.A.detectLang());var c,h=new t.A.Gate,u=0,d="hold",p=this;this.getState=()=>d;var m=async function(){if(k)return;if("hold"!==d)return;if("popup"===e.type&&i.isConverted(e.id))return;let s=i.matchLastPluginRun(e.id);"chatbox"!==e.type&&"notification"!==e.type||(s=void 0),e.enabled&&t.A.checkRunConditions(e.initiative_frequency,e.conditions,s,i)&&(d="running",await p.update(e))};this.forceRunPopup=async()=>{t.A.get(g,"current")?g.current.openPopup():w()};var g=(0,z._3)();let f=null,v=null,_=null;var y=t=>r.showWidget(t),b=()=>{u++,w()},w=async()=>{k||o&&this.t&&("chatbox"===e.type&&(0,z.XX)((0,z.h)(Ut,{destroy:k,plugin:e,store:i,ref:g,t:this.t}),o),"popup"===e.type&&(f||(f=(await n.e(132).then(n.bind(n,132))).default),(0,z.XX)((0,z.h)(f,{destroy:k,t:this.t,highlight:c,mobile:i.isMobile(),plugin:e,store:i,ref:g,pageIndex:u,nextPage:b,showWidget:y}),o)),"notification"===e.type&&(_||(_=(await n.e(490).then(n.bind(n,1490))).default),(0,z.XX)((0,z.h)(_,{destroy:k,t:this.t,mobile:i.isMobile(),plugin:e,store:i,ref:g}),o)),"contact"===e.type&&(v||(v=(await n.e(74).then(n.bind(n,9074))).default),(0,z.XX)((0,z.h)(v,{destroy:k,t:this.t,plugin:e,store:i,ref:g}),o)),h.open())};this.call=(t,e)=>h.entry().then((()=>g.current[t](e)));var k=!1;this.destroy=()=>{k=!0,(0,z.XX)(null,o),o.parentNode.removeChild(o)},this.highlight=t=>{c=t,w()},this.update=t=>{k||(e=t,"hold"!==d&&"finished"!==d&&w())};let A=e=>{if("debug"===l)return`{{${e}}}`;let i=t.A.get(L.r9,l,[]),s=t.A.find(i,(t=>t.key===e));return t.A.get(s,"message",e)};A.i18n=t=>{if(!t)return"";let i=e.locale||a.locale||"vi-VN";return i=i.replace("-","_"),t[l.replace("-","_")]||t[i]},A.locale=()=>l,this.forceDownloadLanguage=async()=>{await L.Dy(i,l,!0),this.update(e)},this.setLocale=async t=>l===t?t:(this.t=null,w(),l=L.JK(e,t),await L.Dy(i,l),this.t=A,w(),l);let x={};t.A.map(t.A.get(e,"popup.pages"),(e=>{e&&t.A.map(e.components,(t=>{"image"===t.type&&t.image&&t.image.url&&t.image.url.startsWith("http")&&(x[t.image.url]=!0)}))})),t.A.size(x)>=0&&t.A.map(x,((e,i)=>t.A.preloadImg(i)));let C=t.A.get(e,"triggers")||[{type:"after_pageview",after_pageview_sec:0,disabled:!1}];for(var S=0;S<t.A.size(C);S++){var M=C[S];M&&(M.disabled||("exit_intent"===M.type&&t.A.trackExitIntent(m),"area_clicked"===M.type&&t.A.trackAreaClicked(M.area_clicked_css_selector,m),"scrolling_percentage"===M.type&&t.A.trackScrollingPercentage(M.scrolling_percentage,m),"inactivity_duration"===M.type&&t.A.trackInactivity(M.inactivity_sec,m),"after_pageview"===M.type&&t.A.trackTimeOnPage(M.after_pageview_sec,m)))}this.update(e),L.Dy(i,l).then((()=>{this.t=A,this.update(e)}))}class Ot{constructor(e,i){this.refM={},this.lib=e,this.$div=i,this.pluginM={},this._destroy=!1,e.store.onHighlight({_isMounted:!0},((t,e)=>{let i=this.pluginM[t];i&&i.highlight(e)})),e.store.onUpdate({_isMounted:!0},(()=>{if(this._destroy)return;let s=this.lib.store.matchPlugin(),r=!1;t.A.each(s,(t=>{if("chatbox"===t.type){if(r)return;r=!0}this.pluginM[t.id]?this.pluginM[t.id].update(t):this.pluginM[t.id]=new Rt(t,this.lib.store,i,e)})),t.A.each(this.pluginM,((t,e)=>{s[e]||(this.pluginM[e].destroy(),delete this.pluginM[e])}))}));let s=this.lib.store.matchPlugin(),r=!1;t.A.each(s,(t=>{if("chatbox"===t.type){if(r)return;r=!0}this.pluginM[t.id]||(this.pluginM[t.id]=new Rt(t,this.lib.store,i,e))}))}findChatbox(){var e=this.lib.store.matchPlugin();let i=t.A.filter(this.pluginM,((t,i)=>"chatbox"===e[i].type));if(0===t.A.size(i))return void console.error("no chatbox found.");let s=t.A.find(i,(t=>"running"===t.getState()));if(s||(s=i[0]),s)return s;console.error("found no suitable chatbox to run.")}getCurrentView(){let t=this.findChatbox();if(t)return t.call("getCurrentView")}showCurrentChatbox(t){let e=this.findChatbox();if(e)return e.call("showWidget",t)}showCurrentChatboxTyping(){let t=this.findChatbox();if(t)return t.call("showTyping")}showCurrentGreeting(){let t=this.findChatbox();if(t)return t.call("showGreeting")}applyTextToCurrentChatbox(t){let e=this.findChatbox();if(e)return e.call("applyMessage",t)}hideCurrentGreeting(){let t=this.findChatbox();if(t)return t.call("hideGreeting")}hideCurrentChatbox(){let t=this.findChatbox();if(t)return t.call("hideWidget")}forceUpdateLang(t){let e=this.pluginM[t];if(e)return e.forceDownloadLanguage()}forceRunPopup(t){let e=this.pluginM[t];if(e)return e.forceRunPopup(t)}setPluginLocale(t,e){let i=this.pluginM[t];if(i)return i.setLocale(e)}setCurrentChatboxLocale(t){let e=this.findChatbox();if(e)return e.setLocale(t)}destroy(){t.A.map(this.pluginM,((t,e)=>{t.destroy(),delete this.pluginM[e]})),this._destroy=!0}}function $t(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class qt{constructor(e,i,s,r,n){$t(this,"version",(()=>"4.5")),$t(this,"setSetting",(t=>this.store.setSetting({account_setting:t}))),$t(this,"getUser",(()=>t.A.parseJSON(t.A.stringify(this.store.matchUser())))),$t(this,"setViewingProduct",(t=>this.store.linkProduct(t))),$t(this,"getViewingProduct",(()=>this.store.getLinkedProduct())),$t(this,"track",(()=>this.store.track())),this.impressionTokens={},this.domGate=new t.A.Gate,this.store=new S(e,i,s,r,n),window.sbz_store=this.store,this.subs=[],this.store.onConvoEvent({_isMounted:!0},(e=>t.A.map(this.subs,(t=>{t&&"function"==typeof t&&t(e)})))),this.store.onWidgetClose({_isMounted:!0},(e=>t.A.map(this.subs,(t=>{t&&"function"==typeof t&&t(e)}))))}async waitReady(t){await this.store.readyGate.entry(),t()}setAIDevMode(t){this.store.setAIDevMode(t)}setTrackPageView(t){this.store.setTrackPageview(t)}getTrackPageView(){return this.store.getTrackPageview()}async cleanLogin(t,e){}async login(e,i,s,r){let n=await this.store.login(e,i,s);r||(r=document.body),this.pluginMgr=new Ot(this,r);let o=t.A.setInterval((()=>{r&&r.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(o))}),1e3);return this.domGate.open(),n}logout(t){return this.store.logout(t)}async init(e,i){let s=(e=e||{}).account_id,r=e.ref,n=await this.store.init(s,void 0,r,e);t.A.setTimeout((()=>window.postMessage({type:"widget_loaded",account_id:s},"*")),0),i||(i=document.body||document),this.pluginMgr=new Ot(this,i);let o=t.A.setInterval((()=>{i&&i.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(o))}),1e3);return this.domGate.open(),n}async start(e,i,s,r){let n=(e=e||{}).account_id,o=await this.store.init(n,s,e.ref,e);t.A.setTimeout((()=>window.postMessage({type:"widget_loaded",account_id:n},"*")),0),i||(i=document.body||document),this.pluginMgr=new Ot(this,i);let a=t.A.setInterval((()=>{i&&i.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(a))}),1e3);return this.domGate.open(),r&&r(o),o}async setAccount(e,i,s,r){let n=await this.store.init(e,s);t.A.setTimeout((()=>window.postMessage({type:"widget_loaded",account_id:e},"*")),0),i||(i=document.body||document),this.pluginMgr=new Ot(this,i);let o=t.A.setInterval((()=>{i&&i.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(o))}),1e3);return this.domGate.open(),r&&r(n),n}_setAccount(t,e){return this.setAccount(t,e)}async updateUserAttributes(e){await this.store.setUser({attributes:e});var i=this.store.matchUser();return t.A.cloneDeep(i.attributes)}async getUserAttributes(){await this.store.readyGate.entry();var e=this.store.matchUser();return t.A.cloneDeep(t.A.get(e,"attributes",[]))}async getWidgetCurrentView(){return await this.domGate.entry(),this.pluginMgr.getCurrentView()}async createTicket(t){return await this.domGate.entry(),this.createTicket(t)}expandWidget(t,e){return this.showWidget(t,e)}shrinkWidget(){return this.hideWidget()}async sendMessage(t,e){if(!t){const{convo:i,error:s}=await this.store.startConvo({message:e.text,initial_by:this.store.matchUser().id});if(s)return{error:s};t=i.id}return this.store.sendConvoEvent(t,"message_sent",{message:e})}async viewForm(e){if(!e||!t.A.startsWith(e,"cp"))return;let i=this.impressionTokens[e];if(i)return i;let{body:s}=await this.store.sendImpression(e);return i=t.A.get(s,"impression_token")||"",this.impressionTokens[e]=i,i}async submitForm(e,i){if(!e||!t.A.startsWith(e,"cp"))return;let s=t.A.cloneDeep(this.store.matchUser()),r={id:s.id,account_id:s.account_id},n=!1;i=t.A.map(i,(e=>{let i=e.key;return"email"===i&&(i="emails"),"phone"===i&&(i="phones"),n=n||"emails"==i||"phones"==i,t.A.setUserAttr(r,{key:i,[e.type||"text"]:e.value}),{key:i,type:e.type||"text",value:t.A.stringify(e.value)}})),n&&t.A.setUserAttr(r,{key:"lead_source",text:"plugin."+e});let o=await this.viewForm(e);return this.store.setUserDiff(r),this.store.sendConversion(e,i,o)}startConvo(t){return this.store.startConvo(t)}async showGreeting(){await this.domGate.entry(),this.pluginMgr.showCurrentGreeting()}async hideGreeting(){await this.domGate.entry(),this.pluginMgr.hideCurrentGreeting()}async showWidget(t,e){await this.domGate.entry(),this.pluginMgr.showCurrentChatbox({view:t,cid:e})}async showTyping(){await this.domGate.entry(),this.pluginMgr.showCurrentChatboxTyping()}async hideWidget(){await this.domGate.entry(),this.pluginMgr.hideCurrentChatbox()}async setLocale(t){return await this.domGate.entry(),this.pluginMgr.setCurrentChatboxLocale(t)}async setLanguage(t){return await this.domGate.entry(),this.pluginMgr.setCurrentChatboxLocale(t)}async setPluginLocale(t,e){return await this.domGate.entry(),this.pluginMgr.setPluginLocale(t,e)}_overrideDeviceType(t){this.store.overrideDeviceType(t)}unload(){this.pluginMgr&&this.pluginMgr.destroy(),this.store.destroy()}async applyMessage(t){await this.domGate.entry(),this.pluginMgr.applyTextToCurrentChatbox(t)}_overridePlugin(t){this.store.overridePlugin(t)}_forceUpdateLang(t){this.pluginMgr.forceUpdateLang(t)}_highlight(t,e){this.store.highlight(t,e)}openPopup(t){this.pluginMgr.forceRunPopup(t)}unEvent(e){this.subs=t.A.filter(this.subs,(t=>t!==e))}async countUnreadMessages(){return await this.domGate.entry(),this.store.matchUnread()}onEvent(e){this.subs=t.A.filter(this.subs,(t=>t!==e)),this.subs.push(e)}overrideAccount(t){this.store.overrideAcc(t)}async overrideChatbox(e){await this.store.overrideChatbox(e),t.A.get(e,"chatbox.greeting.greeting")&&this.pluginMgr.showCurrentGreeting()}stopAutobot(){this.store.doNotStartBot()}}window.__sbz_WIDGET=qt;const Wt=qt;n(318);var Bt=n(5180),Gt=new Wt(Bt.ApiURL,Bt.FileURL,Bt.RealtimeURL);function Vt(t){t=t||[];var e=[];if(Array.isArray(t))e=t;else{if("object"!=typeof t)return;for(var i=Object.keys(t),s=0;s<i.length;s++)e.push(t[i[s]])}if(!((t=e).length<1)){var r=t.shift();if("function"==typeof Gt[r])return Gt[r](...t)}}!function(){let e=window.subiz&&window.subiz.q||[];window.subiz=function(){return Vt(arguments)},e.forEach(Vt),Gt.store.readyGate.entry().then((function(){Gt.store.track(),function(e){if(!e.matchAutoStartBot())return;let i=e.matchBot();0!==Object.keys(i).length&&t.A.each(i,(i=>{let s=async()=>{if(s=()=>!0,!t.A.checkRunConditions(i.initiative_frequency,i.conditions,e.matchLastBotRun(i.id),e))return;let{error:r}=await e.startConvo({initial_by:i.id,locale:L.JK(i,t.A.detectLang()),state:"active",members:[{type:"bot",id:i.id}]});if(r)return console.error(r);e.logBotRun(i.id)},r=t.A.get(i,"triggers")||[];for(let e of r){if(!e)continue;if(e.disabled)continue;let i=s;"area_clicked"===e.type&&t.A.trackAreaClicked(e.area_clicked_css_selector,i),"scrolling_percentage"===e.type&&t.A.trackScrollingPercentage(e.scrolling_percentage,i),"inactivity_duration"===e.type&&t.A.trackInactivity(e.inactivity_sec,i),"after_pageview"===e.type&&t.A.trackTimeOnPage(e.after_pageview_sec,i)}}))}(Gt.store)}))}()})()})();
|