@subiz/widget-v4 4.0.57 → 4.0.61

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.
Files changed (45) hide show
  1. package/assets/less/chatbox.less +2 -0
  2. package/compiled_src/chatbox/Header.js +2 -0
  3. package/compiled_src/chatbox/main.js +2 -1
  4. package/compiled_src/lib.js +9 -2
  5. package/compiled_src/popup/popup.js +33 -3
  6. package/compiled_src/store/store.js +7 -5
  7. package/compiled_src/util/common.js +4 -2
  8. package/dist/{17d83c40640.178.js → 17db8166252.178.js} +0 -0
  9. package/dist/17db8166252.213.js +1 -0
  10. package/dist/{17d83c40640.362.js → 17db8166252.362.js} +0 -0
  11. package/dist/{17d83c40640.441.js → 17db8166252.441.js} +0 -0
  12. package/dist/{17d83c40640.605.js → 17db8166252.605.js} +0 -0
  13. package/dist/{17d83c40640.619.js → 17db8166252.619.js} +0 -0
  14. package/dist/{17d83c40640.678.js → 17db8166252.678.js} +0 -0
  15. package/dist/17db8166252.74.js +1 -0
  16. package/dist/{17d83c40640.782.js → 17db8166252.782.js} +0 -0
  17. package/dist/17db8166252.app.js +1 -0
  18. package/dist/{17d83c40640.index.html → 17db8166252.index.html} +2 -1
  19. package/dist/{17d83c40640.library.html → 17db8166252.library.html} +2 -1
  20. package/dist/17db8166252.library.js +1 -0
  21. package/dist/{17d83c40640.preview.html → 17db8166252.preview.html} +1 -1
  22. package/dist/17db8166252.preview.js +1 -0
  23. package/dist/17db8166252.screenshoot.js +1 -0
  24. package/dist/213.js +30 -1
  25. package/dist/74.js +4 -1
  26. package/dist/HASH +1 -1
  27. package/dist/screenshoot.html +1 -1
  28. package/dist/screenshoot.js +20 -9
  29. package/index.html +1 -0
  30. package/order.html +784 -0
  31. package/order.js +0 -0
  32. package/package.json +10 -10
  33. package/src/chatbox/Header.js +42 -34
  34. package/src/chatbox/main.js +2 -2
  35. package/src/lib.js +8 -3
  36. package/src/popup/popup.js +27 -2
  37. package/src/store/store.js +9 -5
  38. package/src/util/common.js +4 -2
  39. package/test.js +1 -0
  40. package/dist/17d83c40640.213.js +0 -1
  41. package/dist/17d83c40640.74.js +0 -1
  42. package/dist/17d83c40640.app.js +0 -1
  43. package/dist/17d83c40640.library.js +0 -1
  44. package/dist/17d83c40640.preview.js +0 -1
  45. package/dist/17d83c40640.screenshoot.js +0 -1
@@ -133,9 +133,11 @@ body div#sbz92 {
133
133
  .d-none {
134
134
  display: none;
135
135
  }
136
+
136
137
  .d-flex {
137
138
  display: flex;
138
139
  }
140
+
139
141
  .d-inline-block {
140
142
  display: inline-block;
141
143
  }
@@ -219,6 +219,8 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
219
219
  }
220
220
 
221
221
  renderCloseButton() {
222
+ let accSetting = this.props.plugin.chatbox || {};
223
+ if (accSetting.hide_close_button) return null;
222
224
  return (0, _preact.h)("div", {
223
225
  class: "widget-header--button widget-header--button-close",
224
226
  "data-tooltip": this.props.t('close'),
@@ -77,7 +77,8 @@ class Main extends _common.Com {
77
77
  view: this.props.store.matchLastview().view
78
78
  }));
79
79
  } else {
80
- this.hideWidget();
80
+ restoreViewport();
81
+ if (!this.state.isShowWidget) this.hideWidget();
81
82
  }
82
83
  }
83
84
 
@@ -57,8 +57,13 @@ class Widget {
57
57
  xhttp.send();
58
58
  }
59
59
 
60
- async setAccount(id, $container) {
61
- await this.store.init(id);
60
+ async waitReady(cb) {
61
+ await this.store.readyGate.entry();
62
+ cb();
63
+ }
64
+
65
+ async setAccount(id, $container, mask, cb) {
66
+ let outmask = await this.store.init(id, mask);
62
67
  if (!$container) $container = document.body;
63
68
  this.pluginMgr = new _plugin.default(this, $container);
64
69
  let clean = setInterval(() => {
@@ -67,6 +72,8 @@ class Widget {
67
72
  clearInterval(clean);
68
73
  }, 1000);
69
74
  this.domGate.open();
75
+ cb && cb(outmask);
76
+ return outmask;
70
77
  }
71
78
 
72
79
  _setAccount(id, $con) {
@@ -32,7 +32,8 @@ class Popup extends _common.Com {
32
32
  cssready: false,
33
33
  closeAnimation: true,
34
34
  pressedSubmit: false,
35
- imageReady: false
35
+ imageReady: false,
36
+ fontReady: false
36
37
  });
37
38
 
38
39
  this._formRef = (0, _preact.createRef)();
@@ -61,6 +62,9 @@ class Popup extends _common.Com {
61
62
  });
62
63
  });
63
64
 
65
+ delete fonts.undefined;
66
+ delete fonts.null;
67
+ delete fonts[''];
64
68
  if (_index.default.size(images) == 0) this.setState({
65
69
  imageReady: true
66
70
  });
@@ -70,9 +74,34 @@ class Popup extends _common.Com {
70
74
  })));
71
75
 
72
76
  _index.default.preloadWebfonts(Object.keys(fonts));
77
+
78
+ setTimeout(async () => {
79
+ await this.waitForFont(Object.keys(fonts));
80
+ this.setState({
81
+ fontReady: true
82
+ });
83
+ });
73
84
  });
74
85
  }
75
86
 
87
+ async waitForFont(fonts) {
88
+ if (_index.default.size(fonts) == 0) return;
89
+ let ready = {};
90
+
91
+ for (var t = 0; t < 10; t++) {
92
+ for (var i = 0; i < fonts.length; i++) {
93
+ try {
94
+ if (document.fonts.check('normal 16px ' + fonts[i])) ready[fonts[i]] = true;
95
+ if (Object.keys(readycount) == fonts.length) return;
96
+ } catch (e) {}
97
+ }
98
+
99
+ await _index.default.sleep(200);
100
+ }
101
+
102
+ return;
103
+ }
104
+
76
105
  openPopup() {
77
106
  this.setState({
78
107
  close: false
@@ -89,7 +118,7 @@ class Popup extends _common.Com {
89
118
 
90
119
  let form = _index.default.find(page.components, com => com.type === 'form');
91
120
 
92
- if (!form || !form.form) return;
121
+ if (!form || !form.form) return true;
93
122
 
94
123
  let fields = _index.default.get(form, 'form.fields', []);
95
124
 
@@ -246,7 +275,7 @@ class Popup extends _common.Com {
246
275
  }
247
276
 
248
277
  if (hasConversion) {
249
- var formData = new FormData(this._formRef.current);
278
+ var formData = this._formRef.current ? new FormData(this._formRef.current) : new FormData();
250
279
  var summitFields = [];
251
280
 
252
281
  let user = _index.default.cloneDeep(this.props.store.matchUser());
@@ -917,6 +946,7 @@ class Popup extends _common.Com {
917
946
  if (!this.props.t) return null;
918
947
  if (!this.state.cssready) return null;
919
948
  if (!this.state.imageReady) return null;
949
+ if (!this.state.fontReady) return null;
920
950
  if (this.state.close) return null;
921
951
 
922
952
  let popup = _index.default.get(this.props.plugin, 'popup', {});
@@ -331,18 +331,19 @@ class Store {
331
331
  if (!this.isInsync('account')) this.reconnect();
332
332
  }
333
333
 
334
- async init(accid) {
334
+ async init(accid, mask) {
335
335
  this.readyGate.close();
336
336
  accid = (accid || '').trim();
337
337
  this.api.setAuth({
338
338
  accid: accid
339
339
  });
340
340
  this.g_sync = {};
341
- let mask = '';
342
341
 
343
- try {
344
- mask = this.cookie.get('__sbmask', '');
345
- } catch (e) {}
342
+ if (!mask) {
343
+ try {
344
+ mask = this.cookie.get('__sbmask', '');
345
+ } catch (e) {}
346
+ }
346
347
 
347
348
  let localstorageMask = this.kv.match('mask');
348
349
  if (!mask && localstorageMask) mask = localstorageMask;
@@ -385,6 +386,7 @@ class Store {
385
386
  await this.reconnect();
386
387
  this.readyGate.open();
387
388
  this.reconnectWs(accid, userId);
389
+ return mask;
388
390
  }
389
391
 
390
392
  seenLoop() {
@@ -981,7 +981,7 @@ function getDayName(dayOfWeek) {
981
981
 
982
982
  let loadedFonts = {};
983
983
 
984
- function preloadWebfonts(fonts) {
984
+ function preloadWebfonts(fonts, done) {
985
985
  for (var i = 0; i < fonts.length; i++) {
986
986
  let font = fonts[i];
987
987
  if (!font) continue;
@@ -994,7 +994,9 @@ function preloadWebfonts(fonts) {
994
994
  node.innerHTML = '@!-/#Chào mỪng1';
995
995
  node.style.position = 'absolute';
996
996
  node.style.display = 'block';
997
- node.style.fontSize = '1px';
997
+ node.style.opacity = '0.1';
998
+ node.style.color = 'transparent';
999
+ node.style.fontSize = '20px';
998
1000
  node.style.height = '0px';
999
1001
  node.style.width = '0px';
1000
1002
  node.style.fontWeight = weight;
File without changes
@@ -0,0 +1 @@
1
+ (self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[213],{2493:(t,e,n)=>{"use strict";n.d(e,{M:()=>o,u:()=>r});var i=n(6400);n(819);class o extends i.wA{constructor(t){super(t),this._isMounted=!0,setTimeout((()=>{if(this.componentWillUnmount){let t=this.componentWillUnmount.bind(this);this.componentWillUnmount=()=>{t(),this._isMounted=!1}}}),10)}}class r extends o{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,i.h)("div",{ref:this.setWrapperRef},this.props.children)}}},8213:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>f});var i=n(819),o=n(2493);const r=function(){var t={},e={VIEW:"view",EASING_FUNCTION:"easing-function"},n={};n[e.VIEW]={},n[e.EASING_FUNCTION]={};var o=function(t,e){if(!n[t])return null;for(var i in e)if(e.hasOwnProperty(i)){if(n[t][i])return null;n[t][i]=e[i]}},r=function(t){var e=t.getBoundingClientRect();return!(e.bottom<0||e.top>window.scrollY+window.innerHeight)},s=function(t,e,i){if(!n[t])throw"Can't add extension with type of \""+t+'", "'+t+'" is not a valid extension type. The following types are valid: '+Bt(n);if(!/^[-a-z]+$/.test(e))throw"Can't add extension with name \""+e+'", "'+e+'" is contains invalid characters. Only lowercase alphabetical characters and dashes are allowed.';if(n[t][e])throw"Can't add extension with name \""+e+'", "'+e+'" is already added.';n[t][e]=i},a=function(t,e){if(!n[t])throw"Can't get extension with type of \""+t+'", "'+t+'" is not a valid extension type. The following types are available: '+Bt(n);if(!n[t][e])throw"Can't get extension with name \""+e+'", "'+e+'" is not available. The following extensions are available: '+Bt(n[t]);return n[t][e]},l=function(t){return{destroy:function(){t.destroyed=!0,t.frame&&cancelAnimationFrame(t.frame),t.styleObserver&&t.styleObserver.disconnect(),t.didResizeWindow&&window.removeEventListener("resize",t.didResizeWindow),t.root&&t.root.parentNode&&t.root.parentNode.removeChild(t.root)}}},p=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.createElement("span"),n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return t.root=e,t.aligned=null,t.destroyed=!1,e&&n&&(t.root.classList.add("tick-"+n),t.root.setAttribute("data-view",n)),e&&e.dataset.layout&&(t.align=(e.dataset.layout.match(/left|right|center/)||[])[0]||"left"),{appendTo:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"last";!t.root||t.root&&t.root.parentNode||("last"!==n?("first"===n&&(0===e.childNodes.length?e.appendChild(t.root):0===e.children.length&&e.childNodes.length?e.insertBefore(t.root,e.childNodes[e.childNodes.length-1]):e.insertBefore(t.root,e.children[0])),"string"!=typeof n&&e.insertBefore(t.root,n)):e.childNodes.length&&e.childNodes[e.childNodes.length-1].nodeType===Node.TEXT_NODE?e.insertBefore(t.root,e.childNodes[e.childNodes.length-1]):e.appendChild(t.root))}}},u=function(t,e){return t.definition=e,{setDefinition:function(e){t.definition=e}}},c=function(t,e,n,i){return{draw:function(){return t.dirty?(e(t,i),d(t),t.dirty=!1,!0):(n&&n(t)&&d(t),!1)}}},d=function(t){if(!t.fit){if(!t.root||!(t.root.getAttribute("data-layout")||"").match(/fit/))return void(t.fit=!1);var e=window.getComputedStyle(t.root,null);t.fit=!0,t.fitInfo={currentFontSize:parseInt(e.getPropertyValue("font-size"),10)}}t.fitInfo.availableWidth=t.root.parentNode.clientWidth,t.fitInfo.currentWidth=t.root.scrollWidth;var n=Math.min(Math.max(4,t.fitInfo.availableWidth/t.fitInfo.currentWidth*t.fitInfo.currentFontSize),1024);Math.abs(n-t.fitInfo.currentFontSize)<=1||(t.fitInfo.currentFontSize=n,t.root.style.setProperties("fontSize",t.fitInfo.currentFontSize+"px","important"))},f=function(t){return t.dirty=!0,t.value=null,t.valueUpdateCount=0,t.isInitialValue=function(){return t.valueUpdateCount<=1},{reset:function(){t.dirty=!0,t.value=null,t.valueUpdateCount=0},update:function(e){Nt(t.value,e)||(t.value=e,t.valueUpdateCount++,t.dirty=!0)}}},h=function(t){t.didResizeWindow=function(){t.dirty=!0},window.addEventListener("resize",t.didResizeWindow)},m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},y=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),_=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},v=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)},b=function(t,e){var n=(t.definition||[]).concat();"right"===t.align&&n.reverse();var i=Array.isArray(t.value)?t.value.concat():"object"===m(t.value)?Ot(t.value):t.value;n.forEach((function(n){if(!n.presenter){if(t.update=e(n),!n.presenter)return;n.presenter.appendTo(t.root)}})),n.filter((function(t){return void 0!==t.presenter})).forEach((function(e){Array.isArray(i)&&t.valueMapping?t.update(e,"indexes"===t.valueMapping?"right"===t.align?i.pop():i.shift():i):e.key&&void 0!==i[e.key]?t.update(e,i[e.key]):t.update(e,i)})),t.views=n,w(t)},w=function(t){var e=!1;return t.views.filter((function(t){return void 0!==t.presenter})).forEach((function(t){t.presenter.draw()&&(e=!0)})),e},k=function(t,e,n){var i=Rt(Array.isArray(t.value)?t.value:(t.value+"").split(""));if("right"===t.align&&i.reverse(),t.definitions.length>i.length)for(;t.definitions.length>i.length;)t.definitions.pop().presenter.destroy();i.forEach((function(n,i){var o=t.definitions[i];o||(o=t.definitions[i]=ut(t.definition),t.update=e(o),o.presenter.appendTo(t.root,"right"===t.align?"first":"last"))})),i.forEach((function(e,n){return t.update(t.definitions[n],e)})),t.views=i,x(t)},x=function(t){var e=!1;return t.views.forEach((function(n,i){t.definitions[i].presenter.draw()&&(e=!0)})),e},C=function(t,e){var n=document.createElement(t);return e&&(n.className=e),n},Z=function(t,e,n){var i=new MutationObserver((function(i){e.forEach((function(o){i.filter((function(t){return e.includes(t.attributeName)})).length&&n(t.getAttribute(o))}))}));return i.observe(t,{attributes:!0}),i},z=function(t){return t instanceof HTMLElement},D=function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";t.transforms||(t.transforms=[]);var o=t.transforms.find((function(t){return t.name===e}));o?o.value=n:t.transforms.push({name:e,value:n,unit:i}),S(t,t.transforms)},S=function(t,e){t.style.setProperty("transform",e.map((function(t){return t.name+"("+t.value+t.unit+")"})).join(" "),"important")},E={},F=function(t,e){var n=e.toString();return E[n]||(E[n]={}),E[n][t]||(E[n][t]=e(t)),E[n][t]},I=new RegExp("^[0-9]+$"),j=new RegExp("^(true|false)$"),A=new RegExp("^[0-9.]+$"),O=new RegExp("color"),R=new RegExp("shadow"),P=new RegExp("^(follow-gradient|horizontal-gradient|vertical-gradient)"),N=new RegExp("^[.0-9]+(?:ms|s){1}$"),M=new RegExp("^transition-?(?:in|out)?$"),T=new RegExp("^url\\("),U=function(t){return t?parseFloat(t)*(/ms$/.test(t)?1:1e3):0},B=function(t){return t.match(/[a-z]+(?:\(.*?\))?\s?(?:origin\(.*?\))?\s?(?:[a-z]+\(.*?\))?[ .a-z-0-9]*/g).map(W)},W=function(t){var e=t.match(/([a-z]+(?:\(.*?\))?)\s?(?:origin\((.*?)\))?\s?([a-z]+(?:\(.*?\))?)?\s?(?:([.0-9ms]+)?\s?(?:(ease-[a-z-]+))?\s?([.0-9ms]+)?)?/),n=vt(e[1]),i=void 0,o=void 0,r=void 0,s=void 0,a=void 0;return e.slice(2).filter((function(t){return void 0!==t})).forEach((function(t){N.test(t)?void 0===o?o=U(t):s=U(t):/ /.test(t)?i=t:/^ease-[a-z-]+$/.test(t)?r=t:/^[a-z]+/.test(t)&&(a=vt(t))})),a&&(o=void 0,r=void 0),{name:n.name,parameters:n.parameters,duration:o,ease:r,delay:s,origin:i,resolver:a}},V=function(t){var e=t.match(/follow-gradient|horizontal-gradient|vertical-gradient/)[0];return{type:e,colors:t.substr(e.length).match(/(?:transparent|rgb\(.*?\)|hsl\(.*?\)|hsla\(.*?\)|rgba\(.*?\)|[a-z]+|#[abcdefABCDEF\d]+)\s?(?:[\d]{1,3}%?)?/g).map(L)}},$=/\s([\d]{1,3})%?$/,L=function(t){var e=t.match($);return{offset:e?parseFloat(e[1])/100:null,value:q(t.replace($,""))}},q="undefined"==typeof document?function(t){return t}:function(t){if("transparent"===t)return"rgba(0,0,0,0)";var e=document.createElement("span");return e.style.cssText="position:absolute !important;visibility:hidden !important;color:"+t+" !important",document.body.appendChild(e),requestAnimationFrame((function(){e.parentNode.removeChild(e)})),window.getComputedStyle(e).getPropertyValue("color")},H=function(t){return"string"!=typeof t?t:t.match(/([-.\d]+(?:%|ms|s|deg|cm|em|ch|ex|q|in|mm|pc|pt|px|vh|vw|vmin|vmax)?)|[%#A-Za-z0-9,.()]+/g)},K=function(t){var e=t.split(":").map(At),n=e[0].trim().split("-").map((function(t,e){return e>0?function(t){return t.charAt(0).toUpperCase()+t.slice(1)}(t):t})).join(""),i=function(t,e){return j.test(t)?"string"==typeof t?"true"===t:t:I.test(t)?parseInt(t,10):A.test(t)?parseFloat(t):T.test(t)?1===(n=t.match(/url\((.*?)\)/g).map((function(t){return t.substring(4,t.length-1)}))).length?n[0]:n:O.test(e)?P.test(t)?F(t,V):F(t,q):R.test(e)?F(t,H):M.test(e)?"none"===t?t:F(t,B):t;var n}(e[1],e[0]);return n&&null!=i?{property:n,value:i}:null},X={"ease-out-sine":function(t){return Math.sin(t*(Math.PI/2))},"ease-out-cubic":function(t){var e=t-1;return e*e*e+1},"ease-out-bounce":function(t){var e=t/1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){var n=e-1.5/2.75;return 7.5625*n*n+.75}if(e<2.5/2.75){var i=e-2.25/2.75;return 7.5625*i*i+.9375}var o=e-2.625/2.75;return 7.5625*o*o+.984375}};o(e.EASING_FUNCTION,X);var Y=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.lastAppliedStyles=null,G(t,e,t.root.dataset.style),t.styleObserver=Z(t.root,["data-style"],(function(n){G(t,e,n)})),{setStyle:function(n){G(t,e,n)}}},G=function(t,e,n){t.lastAppliedStyles!==n&&(t.lastAppliedStyles=n,t.style=n?Ft(e,function(t){return t.split(";").filter((function(t){return t.trim().length})).map(K).filter((function(t){return null!==t})).reduce((function(t,e){return t[e.property]=e.value,t}),{})}(n)):e,t.dirty=!0)},J={text:function(){return function(t){var e={};return Object.assign({},p(e,t,"text"),f(e),c(e,(function(t){t.root.setAttribute("data-value",t.value),function(t,e){var n=t.childNodes[0];n?e!==n.nodeValue&&(n.nodeValue=e):(n=document.createTextNode(e),t.appendChild(n))}(t.root,t.value)})),l(e))}}};o(e.VIEW,J);var Q=function(t,e,n){return function(t,e,n){var i={valueMapping:null};if(t&&t.dataset.valueMapping){var o=t.dataset.valueMapping;i.valueMapping=-1!==["none","indexes"].indexOf(o)?o:null}return Object.assign({},p(i,t),h(i),f(i),u(i,e),c(i,b,w,n),l(i))}(t,e,n)},tt=function(t,e){return"-"===t[e]&&">"===t[e+1]},et=function(t){return"'"===t||'"'===t},nt=function(t){return","===t},it=function(t){return"("===t},ot=function(t){return")"===t},rt=function(t){return 0!==t.trim().length},st=function(t,e){return t.push(e.trim())},at=function(t,e){return rt(e)?(st(t,e),""):e},lt=function(t,e){return t.length&&e.push(t.length>1?t.concat():t[0]),[]},pt=function t(e,n,i){for(var o="",r=[],s=null,a=!1;e<n.length;){var l=n[e];if(it(l)){a=!1;var p=[o.trim()];l=n[e=t(e+1,n,p)],r.push(p),o=""}else{if(ot(l))return a&&o.trim().length&&(r.push([o.trim()]),o="",a=!1),rt(o)&&st(r,o),r=lt(r,i),e+1;null!==s&&l!==s?o+=l:l===s?(r.push(o),o="",s=null):et(l)?(o="",s=l):tt(n,e)?(a=!0,o.trim().length&&(r.push([o.trim()]),o=""),e+=2):nt(l)?(a&&o.trim().length&&(r.push([o.trim()]),o="",a=!1),r=lt(r,i),o=at(i,o)):o+=l,e++}}return(a&&o.trim().length||!a&&o.trim().length&&!r.length)&&(r.push([o.trim()]),o=""),lt(r,i),at(i,o),e},ut=function t(e){var n={};for(var i in e)e.hasOwnProperty(i)&&(n[i]="root"!==i?"children"!==i?"repeat"!==i?e[i]:null===e[i]?null:t(e[i]):null===e[i]?null:e[i].map(t):e[i].cloneNode());return n.presenter=null,n},ct={root:null,key:null,view:null,overlay:null,presenter:null,transform:null,layout:null,style:null,repeat:null,children:null,className:null},dt=function t(e){return Array.from(e).map((function(e){var n=Ft(ct,{root:e});for(var i in e.dataset)e.dataset.hasOwnProperty(i)&&void 0!==n[i]&&(n[i]=e.dataset[i]);return n.repeat?(n.repeat=t(e.children).pop(),Array.from(e.children).forEach((function(t){t.parentNode.removeChild(t)}))):e.children.length&&(n.children=t(e.children)),n}))},ft=function t(e){return e.map((function(e){return"string"==typeof(e=Ft(ct,e)).root?e.root=document.createElement(e.root):e.root=document.createElement("span"),e.transform&&(e.root.dataset.transform=e.transform),e.className&&(e.root.className=e.className),e.overlay&&(e.root.dataset.overlay=e.overlay),e.view?(e.root.dataset.view=e.view,e.style&&(e.root.dataset.style=e.style),e.repeat=null):(e.layout&&(e.root.dataset.layout=e.layout),e.repeat?(e.root.dataset.repeat=!0,e.repeat=t(e.children).pop()):e.children&&(e.children=t(e.children),e.children.forEach((function(t){e.root.appendChild(t.root)})))),e}))},ht=function(t){var n=!1,i=function(e,i){e.transform(i,(function(t){e.presenter.update(t)}),t),n||(n=!0,o())},o=function e(){t.baseDefinition.presenter.draw(),requestAnimationFrame(e)};return function n(o){return o.presenter=function(t,n){var i,o,s,d,m=void 0;return t.repeat?m=function(t,e,n){return function(t,e,n){var i={definitions:[]};return Object.assign({},p(i,t),f(i),u(i,e),c(i,k,x,n),l(i))}(t,e,n)}(t.root,t.repeat,n):"string"==typeof t.view?(i=t.view,o=t.root,s=t.style,m=(d=a(e.VIEW,i))?d({Extension:{Type:e,getExtension:a},Utils:{},Canvas:{},DOM:{visible:r,create:C,transform:D},Animation:{},Date:{performance:Pt},View:{rooter:p,drawer:c,updater:f,styler:Y,grouper:u,resizer:h,destroyer:l}})(o,s):null):function(t){return t.children&&t.children.length}(t)&&(m=Q(t.root,t.children,n)),m}(o,n),o.transform=yt(o.transform,t),i}(t.baseDefinition)},mt=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return function(e,i){!function e(o,r){n.length<=o?i(r):n[o](r,gt(e,[o+1]),t)}(0,e)}},gt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments[2];return function(){var i=Array.from(e);return Array.prototype.push.apply(i,arguments),t.apply(n,i)}},yt=function(t,e){if(!t)return function(t,e){return e(t)};if("function"==typeof t)return t;var n=function(t){var e=[];return pt(0,t,e),e}("transform("+(/^[a-z]+$/.test(t)?t+"()":t)+")");return _t(n,e)},_t=function t(n,i){var o=n.map((function(n){var o=n.shift(),r=a(e.TRANSFORM,o)||function(t,e,n){e(t)},s=n.map((function(e){return Array.isArray(e)?"string"==typeof e[0]?t([e],i):t(e,i):Et(e)}));return r.apply(void 0,v(s))}));return mt.apply(void 0,[i].concat(v(o)))},vt=function(t){var e=t.match(/[a-z]+/)[0];return{name:e,parameters:bt(t.substring(e.length))}},bt=function(t){(t.match(/('.+?')|(".+?")|(\[.+?])|([.:\-\d\sa-zA-Z]+%?)/g)||[]).map(At).filter((function(t){return t.length})).map(Et)},wt=function(t){return t.substring(1,t.length-1)},kt=/^([\d]{4}-[\d]{1,2}-[\d]{1,2})/,xt=/^(true|false)$/,Ct=/^[\a-zA-Z]+$/,Zt=/^0[\d]+/,zt=/^('|")/,Dt=/^-?(?:\d+)?(?:\.|0\.)?[\d]+$/,St=/^(\[)/,Et=function(t){return xt.test(t)?"true"===t:St.test(t)?bt(wt(t)):kt.test(t)?dateFromISO(t):zt.test(t)?wt(t):Ct.test(t)||Zt.test(t)?t:Dt.test(t)?parseFloat(t):t},Ft=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=void 0,i={};for(n in t)t.hasOwnProperty(n)&&(i[n]=void 0===e[n]?t[n]:e[n]);return i},It=function(t){var e=window,n=t.split(".");return n.forEach((function(t,i){e[n[i]]&&(e=e[n[i]])})),e!==window?e:null},jt=function(t){return/^(?:[\w]+\s?:\s?[\w.]+,\s?)+(?:[\w]+\s?:\s?[\w.]+)$/g.test(t)?t.match(/(?:(\w+)\s?:\s?([\w.]+))/g).reduce((function(t,e){var n=e.split(":");return t[n[0]]=Et(n[1]),t}),{}):Et(t)},At=function(t){return t.trim()},Ot=function(t){return"object"===(void 0===t?"undefined":m(t))&&null!==t?i.Z.parseJSON(i.Z.stringify(t)):t},Rt=function(t){return t.slice()},Pt=function(){return window.performance.now()},Nt=function(t,e){return Mt(t)?Tt(t,e):Array.isArray(t)?Ut(t,e):t===e},Mt=function(t){return t===Object(t)},Tt=function(t,e){for(var n in t)if(!e.hasOwnProperty(n)||t[n]!==e[n])return!1;return!0},Ut=function(t,e){return t.length==e.length&&t.every((function(t,n){return t===e[n]}))},Bt=function(t){return Object.keys(t).map((function(t){return'"'+t+'"'})).join(", ")},Wt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.createElement("div");g(this,t),this._options=Ft(t.options(),e),this._element=n,this._value=null,this._observer=null,this._viewDefinition=null,this._updater=null,this._didInit=null,this._didDestroy=null,this._willDestroy=null,this._didUpdate=null,this._init()}return y(t,[{key:"isRootElement",value:function(t){return this._element===t}},{key:"destroy",value:function(){this._willDestroy(this),this._observer.disconnect(),this.baseDefinition.presenter.destroy(),this._didDestroy(this)}},{key:"redraw",value:function(){this.baseDefinition&&this.baseDefinition.presenter&&(this.baseDefinition.presenter.reset(),this.baseDefinition.presenter.draw(),this._updater(this.baseDefinition,this._value))}},{key:"_init",value:function(){var t=this;this._viewDefinition=this._options.view,this._willDestroy=this._options.willDestroy,this._didDestroy=this._options.didDestroy,this._didInit=this._options.didInit,this._didUpdate=this._options.didUpdate,this._value=this._options.value,this._element.classList.contains("tick")||this._element.classList.add("tick"),this._observer=Z(this._element,["data-value"],(function(e){t.value=e})),this._viewDefinition.root!==this._element&&(Array.from(this._viewDefinition.root.children).forEach((function(e){t._element.appendChild(e)})),this._viewDefinition.root=this._element),this._viewDefinition.view||this._viewDefinition.children||(this._viewDefinition.view="text"),this._updater=ht(this),null!==this.value&&this._update(this.value),this._element.dataset.state="initialised",this._didInit(this,this.value)}},{key:"_update",value:function(t){this._updater(this.baseDefinition,t),this._didUpdate(this,t)}},{key:"baseDefinition",get:function(){return this._viewDefinition}},{key:"root",get:function(){return this._element}},{key:"value",get:function(){return this._value},set:function(t){this._value="string"==typeof t?jt(t):t,this._update(t)}}],[{key:"options",value:function(){return{value:null,view:null,didInit:function(t){},didUpdate:function(t,e){},willDestroy:function(t){},didDestroy:function(t){}}}}]),t}(),Vt=[],$t={value:jt,didInit:It,didUpdate:It,didDestroy:It,willDestroy:It},Lt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.dataset,o={meta:{}};for(var r in i)if(i.hasOwnProperty(r)){var s=e[r],a=i[r];s&&(a=null===(a=s(a))?Ot(n[r]):a,o[r]=a)}return o},qt=function(t){var e=Vt.filter((function(e){return e.isRootElement(t)}));return e?e[0]:null},Ht=function(){return _({},Wt.options())},Kt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;if(t&&!z(t)&&(e=t,t=void 0),!t||!qt(t)){e&&e.view&&(e.view=ft([e.view])[0]),!e&&t&&(e=Lt(t,$t,Ht())),t&&(e||(e={}),e.view||(e.view=dt([t])[0]));var n=new Wt(e,t);return Vt.push(n),n}},Xt={supported:function(){var t=window;if(void 0===t)return!1;var e=t.CSS&&t.CSS.supports,n=!!t.MSInputMethodContext&&!!document.documentMode,i=e&&CSS.supports("transform","translateX(0)");return n||e&&i&&!!["MutationObserver","requestAnimationFrame"].filter((function(e){return e in t})).length}(),options:{},DOM:{create:Kt,destroy:function(t){var e=function(t,e){for(var n=0,i=t.length;n<i;n++)if(t[n].isRootElement(e))return n;return-1}(Vt,t);return!(e<0||(Vt[e].destroy(),Vt.splice(e,1),0))},parse:function(t){var e,n=void 0,i=void 0,o=[];for(i=(e=t.querySelectorAll(".tick:not([data-state])")).length;i--;)n=e[i],o.push(Kt(n));return o},find:qt},plugin:{add:function(t,e,n){if("function"==typeof t){var i=t;return s(i.identifier.type,i.identifier.name,i)}return s(t,e,n)}}},Yt=function(t){if(!e.hasOwnProperty(t))return"continue";Xt.plugin[function(t){return t.replace(/-./g,(function(t){return t.charAt(1).toUpperCase()}))}("add-"+e[t])]=function(n,i){s(e[t],n,i)}};for(var Gt in e)Yt(Gt);return t.exports=Xt,t.exports}();var s=n(9980),a=n.n(s),l=n(6400);r.plugin.add(a());class p extends o.M{constructor(t){var e,n,i;super(t),i={flipKey:"43"},(n="state")in(e=this)?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,this.timer=setInterval((()=>{if(this.props._destroy)return this.componentWillUnmount();let t=this.props.com.countdown||{},e="cd:"+t.skin+":"+t.size+":"+this.props.plugin.popup.font_family+":";this.state.flipKey!==e&&this.setState({flipKey:e}),this.forceUpdate()}),500)}componentWillUnmount(){clearInterval(this.timer)}getCountDownDeltaSec(t){let e;if("fixed_time"===t.expire_time_type&&(e=t.fixed_time),"visit_time"===t.expire_time_type&&(e=this.props.store.pageLoaded()+6e4*t.visit_time),"repeat_daily"===t.expire_time_type&&((n=new i.Z.Date).setHours(0,0,0,0),e=n.getTime()+6e4*t.repeat_daily),"repeat_weekly"===t.expire_time_type){let r=0,s=(new i.Z.Date).getDay();if(r=0===s?"sunday"===t.repeat_weekly_weekday?0:7-(new i.Z.Date).getDay():"sunday"===t.repeat_weekly_weekday?7-s:u[t.repeat_weekly_weekday]-s,r<0)o=0;else if(0==r)(n=new i.Z.Date).setHours(0,0,0,0),e=n.getTime()+6e4*t.repeat_weekly_min;else{var n;(n=new i.Z.Date).setHours(0,0,0,0),e=n.getTime()+6e4*t.repeat_weekly_min+864e5*r}}let o=e-i.Z.Date.now();return o<0&&(o=0),Math.floor(o/1e3)||0}renderElectricCountdown(t,e,n,o,r,s,a){let p="28px";return"sm"===this.props.com.countdown.size&&(p="20px"),"lg"===this.props.com.countdown.size&&(p="40px"),(0,l.h)("div",{class:"countdown_electric"},(0,l.h)("div",{class:"countdown_electric_group"},(0,l.h)("div",{class:"countdown_electric_label"},this.props.t("hour")),(0,l.h)("div",{class:"countdown_electric_numbers"},(0,l.h)("div",{class:"countdown_electric_number",style:i.Z.js2css({font_size:p,font_family:this.props.plugin.popup.font_family})},e),(0,l.h)("div",{class:"countdown_electric_number",style:i.Z.js2css({font_size:p,font_family:this.props.plugin.popup.font_family})},n))),(0,l.h)("div",{class:"countdown_electric_group"},(0,l.h)("div",{class:"countdown_electric_label"},this.props.t("min")),(0,l.h)("div",{class:"countdown_electric_numbers"},(0,l.h)("div",{class:"countdown_electric_number",style:i.Z.js2css({font_size:p,font_family:this.props.plugin.popup.font_family})},o),(0,l.h)("div",{class:"countdown_electric_number",style:i.Z.js2css({font_size:p,font_family:this.props.plugin.popup.font_family})},r))),(0,l.h)("div",{class:"countdown_electric_group"},(0,l.h)("div",{class:"countdown_electric_label"},this.props.t("sec")),(0,l.h)("div",{class:"countdown_electric_numbers"},(0,l.h)("div",{class:"countdown_electric_number",style:i.Z.js2css({font_size:p,font_family:this.props.plugin.popup.font_family})},s),(0,l.h)("div",{class:"countdown_electric_number",style:i.Z.js2css({font_size:p,font_family:this.props.plugin.popup.font_family})},a))))}renderFlipCountdown(t,e,n,i,o,r,s){let a=null;if(t>99&&(t=99),t>0){let e=Math.floor(t/10)+"",n=t%10+"";a=(0,l.h)("div",{class:"countdown_group"},(0,l.h)(c,{key:this.state.flipKey+4,value:e+""+n,plugin:this.props.plugin,com:this.props.com}),(0,l.h)("div",{class:"countdown_label"},this.props.t("day")))}return(0,l.h)("div",{class:"countdown"},a,(0,l.h)("div",{class:"countdown_group"},(0,l.h)(c,{key:this.state.flipKey+1,value:e+""+n,plugin:this.props.plugin,com:this.props.com}),(0,l.h)("div",{class:"countdown_label"},this.props.t("hour"))),(0,l.h)("div",{class:"countdown_group"},(0,l.h)(c,{key:this.state.flipKey+2,value:i+""+o,plugin:this.props.plugin,com:this.props.com}),(0,l.h)("div",{class:"countdown_label"},this.props.t("min"))),(0,l.h)("div",{class:"countdown_group"},(0,l.h)(c,{key:this.state.flipKey+3,value:r+""+s,plugin:this.props.plugin,com:this.props.com}),(0,l.h)("div",{class:"countdown_label"},this.props.t("sec"))))}render(){let t=this.getCountDownDeltaSec(this.props.com.countdown),e=Math.floor(t/86400),n=Math.floor((t-86400*e)/3600),i=Math.floor((t-86400*e-3600*n)/60),o=t-86400*e-3600*n-60*i,r=Math.floor(o/10)+"",s=o%10+"",a=Math.floor(i/10)+"",l=i%10+"",p=Math.floor(n/10)+"",u=n%10+"";return"electric"===this.props.com.countdown.skin?this.renderElectricCountdown(e,p,u,a,l,r,s):this.renderFlipCountdown(e,p,u,a,l,r,s)}}const u={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6};class c extends o.M{constructor(t){super(t),this._tickRef=(0,l.Vf)()}componentDidMount(){this._tickInstance=r.DOM.create(this._tickRef.current,{value:this.props.value})}componentDidUpdate(){this._tickInstance&&(this._tickInstance.value=this.props.value)}componentWillUnmount(){this._tickInstance&&r.DOM.destroy(this._tickRef.current)}render(){let t="28px";return"sm"===this.props.com.countdown.size&&(t="20px"),"lg"===this.props.com.countdown.size&&(t="40px"),(0,l.h)("div",{ref:this._tickRef,class:"tick"},(0,l.h)("div",{"data-repeat":"true","aria-hidden":"true"},(0,l.h)("span",{"data-view":"flip",style:i.Z.js2css({font_size:t,font_family:this.props.plugin.popup.font_family})})))}}let d=n.e(782).then(n.bind(n,9782));class f extends o.M{constructor(t){var e,n,o;super(t),o={close:!1,cssready:!1,closeAnimation:!0,pressedSubmit:!1,imageReady:!1,fontReady:!1},(n="state")in(e=this)?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,this._formRef=(0,l.Vf)(),setTimeout((()=>this.fillForm()),1e3),setTimeout((async()=>{let{body:t}=await this.props.store.sendImpression(this.props.plugin.id);this.impressionToken=i.Z.get(t,"impression_token")||""}),10),setTimeout((()=>{let t={};t[this.props.plugin.popup.font_family]=!0;let e={};i.Z.map(this.props.plugin.popup.pages,(n=>{n&&i.Z.map(n.components,(n=>{t[i.Z.get(n,"style.font_family")]=!0,t[i.Z.get(n,"mobile_style.font_family")]=!0,"image"===n.type&&n.image&&n.image.url&&n.image.url.startsWith("http")&&(e[n.image.url]=!0)}))})),delete t.undefined,delete t.null,delete t[""],0==i.Z.size(e)&&this.setState({imageReady:!0}),i.Z.map(e,((t,e)=>i.Z.preloadImg(e,(()=>this.setState({imageReady:!0}))))),i.Z.preloadWebfonts(Object.keys(t)),setTimeout((async()=>{await this.waitForFont(Object.keys(t)),this.setState({fontReady:!0})}))}))}async waitForFont(t){if(0==i.Z.size(t))return;let e={};for(var n=0;n<10;n++){for(var o=0;o<t.length;o++)try{if(document.fonts.check("normal 16px "+t[o])&&(e[t[o]]=!0),Object.keys(readycount)==t.length)return}catch(t){}await i.Z.sleep(200)}}openPopup(){this.setState({close:!1})}getPageIndex(){return void 0!==this.props.plugin._page_index?this.props.plugin._page_index:this.props.pageIndex}isFormFilled(){let t=i.Z.get(this.props.plugin.popup,`pages.${this.getPageIndex()}`),e=i.Z.find(t.components,(t=>"form"===t.type));if(!e||!e.form)return;let n=i.Z.get(e,"form.fields",[]);return!i.Z.find(n,(t=>!!t.is_required&&(!this.isFieldValid(t.key,t.validate)||this.isFieldEmpty(t.key))))}fillForm(){let t=i.Z.get(this.props.plugin.popup,`pages.${this.getPageIndex()}`),e=i.Z.find(t.components,(t=>"form"===t.type));if(!e)return;let n=this.props.store.matchUser(),o=i.Z.get(n,"attributes"),r=i.Z.get(e,"form.fields",[]);i.Z.each(r,(t=>{let e=t.key;"email"===e&&(e="emails"),"phone"===e&&(e="phones"),"emails"===e&&"phones"==e&&"fullname"===e&&i.Z.map(o,(n=>{if(e===n.key){var i=this._formRef.current.elements[t.key];i&&(i.value=n.text)}}))}))}isFieldValid(t,e){if(!e)return!0;if(!this._formRef||!this._formRef.current)return!1;var n=new FormData(this._formRef.current);for(var o of n.entries())if(o[0]===t)return"email"===e?i.Z.isEmail(o[1]):"phone"===e?i.Z.isPhone(o[1]):"url"===e?i.Z.isURL(o[1]):"number"!==e||i.Z.isNumber(o[1]);return!0}isFieldEmpty(t){if(!this._formRef||!this._formRef.current)return!1;var e=new FormData(this._formRef.current);for(var n of e.entries())if(n[0]===t)return""===n[1]||void 0===n[1];return!0}renderCloseButton(){return this.props.plugin.popup.show_close_button?(0,l.h)("div",{class:"btn_close default",onClick:t=>this.setClose(!0)},(0,l.h)("svg",{class:"btn_close__icon",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24","stroke-linecap":"round","stroke-linejoin":"round"},(0,l.h)("line",{x1:"17",y1:"7",x2:"7",y2:"17",style:"stroke-width: 3 !important;"}),(0,l.h)("line",{x1:"7",y1:"7",x2:"17",y2:"17",style:"stroke-width: 3 !important;"}))):null}setClose(t){t?(document.body.style.setProperty("overflow",this.lastoverflow),this.setState({closeAnimation:!0}),setTimeout((()=>this.setState({close:!0,closeAnimation:!1})),150),this.props.plugin._dont_close&&setTimeout((()=>{this.lastoverflow=window.getComputedStyle(document.body).getPropertyValue("overflow"),document.body.style.setProperty("overflow","hidden","important"),this.setState({closeAnimation:!1,close:!1})}),1500)):(this.lastoverflow=window.getComputedStyle(document.body).getPropertyValue("overflow"),document.body.style.setProperty("overflow","hidden","important"),this.setState({closeAnimation:!1}))}onButtonClick(t,e){t.stopPropagation(),i.Z.get(this.props.plugin,"popup",{});let n=i.Z.get(this.props.plugin.popup,`pages.${this.getPageIndex()}`),o=[],r=i.Z.find(n.components,(t=>"buttons"===t.type));"background"===e&&(o=i.Z.get(n,"background_click.actions")||[]),"primary"===e&&r.buttons.primary_enabled&&(o=r.buttons.primary_actions||[]),"secondary"===e&&r.buttons.secondary_enabled&&(o=r.buttons.secondary_actions||[]);let s=!1;for(let t of o)"conversion"!==t.action&&"submit"!==t.action||(s=!0,this.setState({pressedSubmit:!0}));if(!s||this.isFormFilled()){var a=!1;for(let t of o)"submit"!==t.action&&"conversion"!==t.action||(a=!0);if(a){var l=new FormData(this._formRef.current),p=[];let t=i.Z.cloneDeep(this.props.store.matchUser());for(var u of l.entries()){let e=i.Z.get(this.props.plugin.popup,`pages.${this.getPageIndex()}`),n=i.Z.find(e.components,(t=>"form"===t.type)),o=i.Z.get(n,"form.fields",[]),r=i.Z.find(o,(t=>t.key===u[0]));if(!r.type)return;p.push({key:u[0],type:r.type,value:i.Z.stringify(u[1])});let s=u[0];"email"===s&&(s="emails"),"phone"===s&&(s="phones"),i.Z.setUserAttr(t,{key:s,text:u[1]})}this.props.store.sendConversion(this.props.plugin.id,p,this.impressionToken),this.props.store.setUser(t)}for(let t of o)"open_widget"===t.action&&this.props.showWidget("list");for(let t of o)"close"===t.action&&setTimeout((()=>this.setClose(!0)),100),"next_page"===t.action&&this.props.nextPage();for(let t of o){if(!t.url)continue;let e=t.url;if(e.startsWith("http://")||e.startsWith("https://")||(e="//"+e),"open_url"===t.action&&t.new_tab)return window.open(e,"_blank");if("open_url"===t.action&&!t.new_tab)return void(window.location.href=e)}}}renderButtons(t,e){let n=i.Z.get(this.props.plugin,"popup",{}),o=t.style||{},r=Object.assign({},o);delete r.justify_content,delete r.align_items,delete r.flex_direction,delete r.display,r.color=r.color||"#fff",r.font_weight=r.font_weight||"500",r.font_size=r.font_size||n.font_size||"14px",r.background=r.background||n.text_color;let s=null;if(t.buttons.primary_enabled&&t.buttons.primary_text){let o=Object.assign({font_size:n.font_size||"14px"},e.primary_button);i.Z.get(t,"style.background")&&(o.background=t.style.background),i.Z.get(t,"style.color")&&(o.color=t.style.color),s=(0,l.h)("div",{class:"btn btn__primary ",style:this.js2css(r),onClick:t=>this.onButtonClick(t,"primary")},this.props.t.i18n(t.buttons.i18n_primary_text)||t.buttons.primary_text)}let a=null;if(t.buttons.secondary_enabled&&t.buttons.secondary_text){let i=Object.assign({font_size:n.font_size||"14px"},e.secondary_button);a=(0,l.h)("div",{class:"btn btn__secondary",style:this.js2css(i),onClick:t=>this.onButtonClick(t,"secondary")},this.props.t.i18n(t.buttons.i18n_secondary_text)||t.buttons.secondary_text)}return(0,l.h)("div",{class:"popup_component",style:this.js2css({display:"flex",flex_direction:o.flex_direction,align_items:o.align_items})},s,(0,l.h)("div",{style:this.js2css({width:"10px",height:"1px"})}),a)}js2css(t,e){let n=this.props.plugin.popup.spacer||10;return i.Z.js2css(t,e,{"@font_size":this.props.plugin.popup.font_size,"@font_family":this.props.plugin.popup.font_family,"@text_color":this.props.plugin.popup.text_color,"@faded_text_color":this.props.plugin.popup.faded_text_color,"@primary_color":this.props.plugin.popup.primary_color,"@spacer0":n/2+"px","@spacer":n+"px","@spacer2":2*n+"px","@spacer3":3*n+"px"})}renderSingleChoiceField(t){var e="form-control form-control__select "+this.props.plugin.popup.theme;let n=i.Z.map(t.options,(n=>(0,l.h)("label",{class:e},(0,l.h)("input",{type:"radio",name:t.key,value:n.value}),(0,l.h)("span",null,this.props.t.i18n(n.i18n_label)||n.label))));return(0,l.h)(l.HY,null,n)}renderDropdownField(t){let e=i.Z.map(t.options,(t=>(0,l.h)("option",{value:t.value},t.value))),n=i.Z.get(this.props.plugin,"popup.theme");var o="form-control form-control__select "+n;return"vintage"===n?(0,l.h)("div",{class:"form-control__text_container"},(0,l.h)("div",{class:"form-control_inside_label form-label vintage"},this.props.t.i18n(t.i18n_label)||t.label),(0,l.h)("select",{class:o,name:t.key},e)):(0,l.h)("select",{class:o,name:t.key},e)}renderMutiChoiceField(t){var e="form-control form-control__check "+this.props.plugin.popup.theme;let n=i.Z.map(t.options,(n=>(0,l.h)("label",{class:e},(0,l.h)("input",{required:t.is_required,type:"checkbox",name:t.key,value:n.value}),(0,l.h)("span",null,this.props.t.i18n(n.i18n_label)||n.label))));return(0,l.h)(l.HY,null,n)}renderTextField(t){let e=i.Z.get(this.props.plugin,"popup.theme");var n="form-control form-control__text "+e;return"simple"===e?(0,l.h)("input",{type:t.type,class:"form-control form-control__text simple",key:"form_field_"+t.key,name:t.key,placeholder:this.props.t.i18n(t.i18n_label)||t.label||this.props.t.i18n(t.i18n_placeholder)||t.placeholder}):"vintage"===e?(0,l.h)("div",{class:"form-control__text_container"},(0,l.h)("div",{class:"form-control_inside_label form-label vintage"},this.props.t.i18n(t.i18n_label)||t.label),(0,l.h)("input",{type:t.type,class:n,key:"form_field_"+t.key,name:t.key,placeholder:this.props.t.i18n(t.i18n_placeholder)||t.placeholder})):(0,l.h)("input",{type:t.type,class:n,key:"form_field_"+t.key,name:t.key,placeholder:this.props.t.i18n(t.i18n_placeholder)||t.placeholder})}renderMultilineTextField(t){let e=i.Z.get(this.props.plugin,"popup.theme");var n="form-control form-control__text "+e;return"simple"===e?(0,l.h)("textarea",{rows:"3",name:t.key,type:t.type,key:"form_field_"+t.key,class:"form-control form-control__text simple",style:this.js2css({overflow:"auto",resize:"none"}),placeholder:this.props.t.i18n(t.i18n_label)||t.label||this.props.t.i18n(t.i18n_placeholder)||t.placeholder}):"vintage"===e?(0,l.h)("div",{class:"form-control__text_container"},(0,l.h)("div",{class:"form-control_inside_label form-label vintage"},t.label),(0,l.h)("textarea",{rows:"3",name:t.key,type:t.type,key:"form_field_"+t.key,class:n,style:this.js2css({overflow:"auto",resize:"none"}),placeholder:this.props.t.i18n(t.i18n_label)||t.label||this.props.t.i18n(t.i18n_placeholder)||t.placeholder})):(0,l.h)("textarea",{rows:"3",name:t.key,type:t.type,key:"form_field_"+t.key,class:n,style:this.js2css({overflow:"auto",resize:"none"}),placeholder:this.props.t.i18n(t.i18n_placeholder)||t.placeholder})}renderFormComponent(t){let e=i.Z.get(this.props.plugin,"popup",{}),n=i.Z.map(t.form.fields,(t=>"email"===t.type?this.renderTextField(t):"single-choice"===t.type?this.renderSingleChoiceField(t):"multiple-choice"===t.type?this.renderMutiChoiceField(t):"multiline-text"===t.type?this.renderMultilineTextField(t):"text"===t.type?this.renderTextField(t):"dropdown"===t.type?this.renderDropdownField(t):void 0)),o=i.Z.get(e,"theme");return n=i.Z.map(n,((n,i)=>{let r=null,s=t.form.fields[i];r=(0,l.h)("div",{class:"form-label",style:this.js2css({color:e.text_color,font_family:e.font_family,font_size:e.font_size||"14px"})},this.props.t.i18n(s.i18n_label)||s.label),"vintage"===o&&"dropdown"===s.type&&(r=null),"vintage"!==o&&"simple"!==o||"email"!==s.type&&"text"!==s.type&&"multiline-text"!==s.type||(r=null);let a=null;return this.state.pressedSubmit&&!this.isFieldValid(s.key,s.validate)&&(a=(0,l.h)("div",{class:"text__danger ",style:this.js2css({margin_top:"5px",font_family:e.font_family,font_size:e.font_size})},this.props.t("invalid_field"))),this.state.pressedSubmit&&s.is_required&&this.isFieldEmpty(s.key)&&(a=(0,l.h)("div",{class:"text__danger ",style:this.js2css({margin_top:"5px",font_family:e.font_family,font_size:e.font_size})},this.props.t("required"))),(0,l.h)("div",{class:"field"},r,n,a)})),(0,l.h)("form",{style:this.js2css(t.style),class:"form popup_component",ref:this._formRef,onClick:t=>t.stopPropagation()},n)}renderComponents(t){let e=i.Z.find(t.components,(t=>"buttons"===t.type)),n=null;e&&(n=this.renderButtons(e,t));let o=0;return i.Z.map(t.components,((t,e)=>"image"===t.type?null:(o++,"buttons"===t.type?n:"follow_facebook"===t.type?this.renderFollowFacebook(t):"social_buttons"===t.type?this.renderSocialButtons(t):"line"===t.type?this.renderLineComponent(t):"text"===t.type?this.renderTextComponent(t,1===o):"form"===t.type?this.renderFormComponent(t):"countdown"===t.type?(0,l.h)("div",{class:"popup_component",onClick:t=>t.stopPropagation()},(0,l.h)(p,{destroy:this.props.destroy,t:this.props.t,com:t,store:this.props.store,plugin:this.props.plugin})):void 0)))}renderFollowFacebook(t){if(!i.Z.get(t,"follow_facebook.url"))return null;let e=this.props.mobile&&t.mobile_style||t.style,o={display:"flex",justify_content:e.justify_content},r={};return r.font_family=e.font_family||this.props.plugin.popup.font_family,r.font_size=e.font_size||this.props.plugin.popup.font_size||"14px",(0,l.h)("div",{class:"popup_component",style:this.js2css(o),onClick:t=>t.stopPropagation()},(0,l.h)("div",{class:"follow_fb_btn"},(0,l.h)("img",{alt:"follow",class:"follow_fb_btn__img",src:n(9639)}),(0,l.h)("span",{style:this.js2css(Object.assign({white_space:"nowrap",overflow:"hidden",text_overflow:"ellipsis"},r))},this.props.t("follow_us_on_facebook"))))}renderSocialButtons(t){let e=i.Z.get(t,"social_buttons.facebook"),o=null;e&&(o=(0,l.h)("a",{href:e,class:"social_button",target:"_blank"},(0,l.h)("img",{alt:"facebook",class:"social_button__img",src:n(7435)})));let r=i.Z.get(t,"social_buttons.zalo"),s=null;r&&(s=(0,l.h)("a",{href:r,class:"social_button",target:"_blank"},(0,l.h)("img",{alt:"zalo",class:"social_button__img",src:n(7298)})));let a=this.props.mobile&&t.mobile_style||t.style;return(0,l.h)("div",{class:"social_buttons popup_component",style:this.js2css(a),onClick:t=>t.stopPropagation()},o," ",s)}renderImageComponent(t,e){let n=Object.assign({pointer_events:"none"},this.props.mobile&&t.mobile_style||t.style,{position:"absolute"});return n.z_index||(n.z_index="-1"),(0,l.h)("div",{style:this.js2css(n)},(0,l.h)("div",{id:"image_component_"+this.props.plugin.id+"_"+this.getPageIndex()+"_"+e,style:this.js2css({width:"100%",height:"100%",background_image:`url("${encodeURI(i.Z.get(t,"image.url"))}")`,background_size:n.background_size||"cover",background_position:n.background_position||"auto"})}))}renderLineComponent(t){let e=this.props.mobile&&t.mobile_style||t.style;return(0,l.h)("div",{class:"popup_component",style:this.js2css(e)})}renderTextComponent(t,e){let n=i.Z.get(this.props.plugin,"popup",{}),o=Object.assign({color:n.text_color,font_family:n.font_family,font_size:n.font_size||"14px",white_space:"pre-wrap"},this.props.mobile&&t.mobile_style||t.style);return delete o.margin_top,delete o.margin_bottom,(0,l.h)("div",{class:"text popup_component",style:this.js2css(o),onClick:t=>t.stopPropagation()},this.props.t.i18n(i.Z.get(t,"text.i18n_html"))||i.Z.get(t,"text.html"))}async refreshCSS(){let t=this.props.store.matchPlugin();if(!i.Z.find(t,(t=>t.id===this.props.plugin.id)))return;let e=(await d).default.default.toString();var n=i.Z.replaceCssVariablePlugin(e,this.props.plugin.popup);let o=i.Z.get(this.props.plugin,"popup.pages.0.extra_css",[]),r=i.Z.map(o,(t=>`#sbz92 ${t.selector} { ${this.js2css(t.style)}}`)).join("\n");n+=r,i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,n)}componentWillUnmount(){i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,"")}async componentDidMount(){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.props.store.onResetCSS(this,(()=>this.refreshCSS())),await this.refreshCSS(),setTimeout((()=>{this.setState({cssready:!0}),this.setClose(!1)}),50)}calculateContainerCss(t,e){let n=t.position||"center",o=Object.assign({display:"flex"},this.props.mobile&&e.mobile_style||e.style,{max_width:"85%",max_height:"85%"}),r={};return i.Z.map(["left","top","right","bottom","box_shadow","transform"],(t=>{r[t]=o[t]})),r.position="absolute","center"!==n&&n||(r.top="50%",r.transform="translateY(-50%) translateX(-50%)",r.left="50%",delete r.right,delete r.bottom),"fullscreen"===n&&(r.top=0,r.left=0,r.right=0,r.bottom=0,r.display="flex",r.align_items="center",r.background=t.background,delete r.width,delete r.height,delete r.transform),"top-left"===n&&(r.top=r.top||"0px",r.left=r.left||"0px",delete r.transform,delete r.right,delete r.bottom),"top-right"===n&&(r.top=r.top||"0px",r.right=r.right||"0px",delete r.transform,delete r.left,delete r.bottom),"top-center"===n&&(r.transform="translateX(-50%)",r.left="50%",r.top=r.top||"0px",delete r.right,delete r.bottom),"middle-left"===n&&(r.top="50%",r.transform="translateY(-50%)",r.left=r.left||"0px",delete r.right,delete r.bottom),"middle-right"===n&&(r.top="50%",r.transform="translateY(-50%)",r.right=r.right||"0px",delete r.left,delete r.bottom),"bottom-left"===n&&(r.bottom=r.bottom||"0px",r.left=r.left||"0px",delete r.transform,delete r.top,delete r.right),"bottom-right"===n&&(r.bottom=r.bottom||"0px",r.right=r.right||"0px",delete r.transform,delete r.top,delete r.left),"bottom-center"===n&&(r.bottom=r.bottom||"0px",r.transform="translateX(-50%)",r.left="50%",delete r.top,delete r.right),r.width=o.width,r.height=o.height,r.max_width=o.max_width,r.max_height=o.max_height,r.display=o.display,r.border_radius=o.border_radius,r.overflow=o.overflow,r.box_shadow=o.box_shadow,t.type&&"modal"!==t.type||(r.max_width="80%",r.max_height="95%"),"fullscreen"===n&&(r.width="100%",r.height="100%",r.max_width="100%",r.max_height="100%"),"bar"===t.type&&(r.width=o.width||"100%",r.max_width="100%"),r}render(){if(!this.props.t)return null;if(!this.state.cssready)return null;if(!this.state.imageReady)return null;if(!this.state.fontReady)return null;if(this.state.close)return null;let t=i.Z.get(this.props.plugin,"popup",{}),e=i.Z.get(t,`pages.${this.getPageIndex()}`);if(!e)return null;let n=Object.assign({},this.props.mobile&&e.mobile_style||e.style),o=this.calculateContainerCss(t,e),r="",s=i.Z.get(this.props.plugin,"popup.position","center");"center"!==s&&s||(r="zoomInCenter",this.state.closeAnimation&&(r="zoomOutCenter")),"bottom-left"!==s&&"bottom-right"!==s||(r="fadeInUpBig"),"top-left"!==s&&"top-right"!==s||(r="fadeInDown"),"top-center"===s&&(r="fadeInDownCenter"),"middle-left"===s&&(r="fadeInLeftBig"),"middle-right"===s&&(r="fadeInRightBig"),"bottom-center"===s&&(r="fadeInUpCenter");let a=i.Z.get(e,"layout");this.props.mobile&&(a=i.Z.get(e,"mobile_layout"));let p={display:n.display,align_items:n.align_items,justify_content:n.justify_content,padding_top:n.padding_top,padding_left:n.padding_left,padding_right:n.padding_right,padding_bottom:n.padding_bottom,background:n.background||t.background||"#fff",border:n.border,overflow:"row"===a?"auto":"",max_height:"row"===a?"100%":""},u={overflow:"column"===a?"auto":"",max_height:"column"===a?"100%":"",width:"100%",position:"relative",padding_top:n.margin_top,padding_left:n.margin_left,padding_right:n.margin_right,padding_bottom:n.margin_bottom};"padding"===this.props.highlight&&(u.background="#bad14a87",p.background="#ff3d006e");let c="position: fixed !important;";this.props.plugin._preview&&(c="position: absolute !important;"),t.overlay&&(c+=" background: #000c !important;");let d=i.Z.map(e.components,((t,e)=>{if("image"===t.type)return this.renderImageComponent(t,e)}));return(0,l.h)("div",{class:"overlay",style:c},(0,l.h)("div",{class:r,style:this.js2css(o),onClick:t=>t.stopPropagation()},this.renderCloseButton(),(0,l.h)("div",{style:this.js2css(u),onClick:t=>this.onButtonClick(t,"background")},d,(0,l.h)("div",{style:this.js2css(p),form:!0},this.renderComponents(e)))))}}},9980:t=>{t.exports=function(){if(!t)var t={};var e=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();return t.exports=function(t){var n=t.DOM,i=(t.Animation.animate,t.Extension),o=t.Date.performance,r=t.View,s=r.rooter,a=r.destroyer,l=r.drawer,p=r.updater,u=r.styler,c=i.getExtension(i.Type.EASING_FUNCTION,"ease-out-cubic"),d=i.getExtension(i.Type.EASING_FUNCTION,"ease-out-sine"),f=function(t){if(t.isInitialValue()){t.root.textContent="",t.spacer=n.create("span","tick-flip-spacer"),t.root.appendChild(t.spacer);var e=n.create("span","tick-flip-shadow-top tick-flip-shadow tick-flip-front"),r=n.create("span","tick-flip-shadow-bottom tick-flip-shadow tick-flip-back");t.root.appendChild(e),t.root.appendChild(r),t.shadowCard=n.create("span","tick-flip-card-shadow"),t.root.appendChild(t.shadowCard)}if(t.spacer.textContent=t.value,t.isInitialValue()||n.visible(t.root)){var s=t.cards[t.cards.length-1];if(s&&(s.waiting=!1,s.offset=o(),s.back=t.value),t.isInitialValue()){var a=new h;a.back=t.value,a.offset=null,a.progress=1,t.root.insertBefore(a.root,t.root.firstChild),t.cards.push(a)}var l=new h;if(l.offset=null,l.progress=0,l.visual_progress=0,l.waiting=!0,l.front=t.value,l.rotate(0),t.root.insertBefore(l.root,t.root.firstChild),t.cards.push(l),!t.animating){t.animating=!0;var p=i.getExtension(i.Type.EASING_FUNCTION,t.style.flipEasing);!function e(){var i=t.cards.filter((function(t){return!t.done&&!t.waiting}));if(0!==i.length){i.forEach((function(e){null!==e.offset&&(e.progress=(o()-e.offset)/t.style.flipDuration),e.progress>=1&&(e.progress=1,e.done=!0),e.visual_progress=p(e.progress)})),i.reverse().forEach((function(t,e){var n=i[e-1];n&&t.visual_progress<=n.visual_progress&&(t.visual_progress=n.visual_progress+.01)})),i.reverse(),t.cards.forEach((function(e,n){var i=1-2*Math.abs(e.visual_progress-.5),o=1-(e.visual_progress-.5)/.5;e.shadowFront=i,e.highlightBack=o;var r=t.cards[n+1];r&&e.visual_progress>.5&&e.visual_progress>0&&(e.shadowBack=c(r.visual_progress))})),i.forEach((function(t,e){var n=t.visual_progress;n>.5&&!t.done?t.root.style.setProperty("z-index",10+e,"important"):t.root.style.removeProperty("z-index"),t.rotate(-180*n)}));var r=0,s=1;i.forEach((function(t){var e=Math.abs(t.visual_progress-.5);e<s&&(s=e,r=t.visual_progress)}));var a=d(r<.5?r/.5:(1-r)/.5);t.shadowCard.style.setProperty("opacity",a,"important"),n.transform(t.shadowCard,"scaleY",a),t.cards.filter((function(t){return t.done})).slice(0,-1).forEach((function(e){t.cards=t.cards.filter((function(t){return t!==e})),e.root.parentNode&&t.root.removeChild(e.root)})),requestAnimationFrame(e)}else t.animating=!1}()}}else t.cards.forEach((function(e){e.back=t.value,e.front=t.value}))},h=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._root=n.create("span","tick-flip-card");var e=n.create("span","tick-flip-panel-front tick-flip-front tick-flip-panel"),i=n.create("span","tick-flip-panel-front-text"),o=n.create("span","tick-flip-panel-text-wrapper");i.appendChild(o);var r=n.create("span","tick-flip-panel-front-shadow");e.appendChild(i),e.appendChild(r);var s=n.create("span","tick-flip-panel-back tick-flip-back tick-flip-panel"),a=n.create("span","tick-flip-panel-back-text"),l=n.create("span","tick-flip-panel-text-wrapper");a.appendChild(l);var p=n.create("span","tick-flip-panel-back-highlight"),u=n.create("span","tick-flip-panel-back-shadow");s.appendChild(a),s.appendChild(p),s.appendChild(u),this._root.appendChild(e),this._root.appendChild(s),this._front=e,this._back=s,this._shadowFront=r,this._shadowBack=u,this._highlightBack=p,this._textBack=l,this._textFront=o,this._frontValue=null,this._backValue=null}return e(t,[{key:"rotate",value:function(t){this._front.style.setProperty("transform","rotateX("+t+"deg)","important"),this._back.style.setProperty("transform","rotateX("+(-180+t)+"deg)","important")}},{key:"root",get:function(){return this._root}},{key:"front",set:function(t){this._frontValue=t,this._textFront.textContent=t},get:function(){return this._frontValue}},{key:"back",set:function(t){this._backValue=t,this._textBack.textContent=t},get:function(){return this._backValue}},{key:"highlightBack",set:function(t){this._highlightBack.style.setProperty("opacity",t,"important")}},{key:"shadowBack",set:function(t){this._shadowBack.style.setProperty("opacity",t,"important")}},{key:"shadowFront",set:function(t){this._shadowFront.style.setProperty("opacity",t,"important")}}]),t}();return function(t){var e={cards:[],lastCard:null,initialCard:null,shadowAbove:null,shadowBelow:null,shadowCard:null,currentValue:null,lastValue:null,front:null,back:null};return Object.assign({},s(e,t,"flip"),p(e),u(e,{flipDuration:800,flipEasing:"ease-out-bounce"}),l(e,f),a(e))}},t.exports.identifier={name:"flip",type:"view"},t.exports}()},7435:(t,e,n)=>{t.exports=n.p+"assets/img/Facebook.64607ec.png"},7298:(t,e,n)=>{t.exports=n.p+"assets/img/Zalo.6845707.png"},9639:(t,e,n)=>{t.exports=n.p+"assets/img/fb_inverse_circle.36c2cfc.png"}}]);
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ (self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[74],{1074:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>ot});var i=s(819),r=s(2493),o=s(6400);class a extends r.M{render(){var t=this.props.emojiCode;if(i.Z.size(t)<3)return null;var e=t.replace(/:/g,"");return(0,o.h)("i",{"data-tooltip":t,class:`emoji emoji--${e}`})}}var n=s(6755);let l=s(4761);class p extends r.M{constructor(t){super(t),this.setState({opacity:0,previewEvent:{},displayPreview:!1}),this.loadGreeting(),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(t=>{if("message_sent"!==i.Z.get(t,"type"))return;let e=i.Z.get(t,"by.type");if("system"!==e&&"agent"!==e)return;let s=!1;i.Z.map(i.Z.get(t,"data.message.attachments",[]),(t=>{t&&"quick_replies"===t.type&&(s=!0)})),s||this.setState({displayPreview:!0,previewEvent:t})}))}fixMissingSetting(t){return t=i.Z.cloneDeep(t),i.Z.get(t,"desktop_button.background_image_url")&&(t.desktop_button.background_image_url=this.props.store.replaceFileUrl(t.desktop_button.background_image_url)),i.Z.get(t,"desktop_button.background_mask_url")&&(t.desktop_button.background_mask_url=this.props.store.replaceFileUrl(t.desktop_button.background_mask_url)),i.Z.get(t,"mobile_button.background_image_url")&&(t.mobile_button.background_image_url=this.props.store.replaceFileUrl(t.mobile_button.background_image_url)),i.Z.get(t,"mobile_button.background_mask_url")&&(t.mobile_button.background_mask_url=this.props.store.replaceFileUrl(t.mobile_button.background_mask_url)),t}render(){let t=this.props.plugin.chatbox,e=i.Z.get(t,"desktop_button.position")||"right";if(this.props.store.isMobile()&&(e=i.Z.get(t,"mobile_button.position")||e,i.Z.get(t,"mobile_button.hidden")))return null;if(i.Z.get(t,"desktop_button.hidden"))return null;let s="widget-layout widget-layout--"+e,r=this.state.opacity;return this.props.isShow||(s+=" widget-layout--hidden",r=0),(0,o.h)("div",{class:s,style:"opacity: "+r+" !important"},this.renderPreview(),this.renderButton())}ClearPreview(){this.setState({previewEvent:{}})}ShowGreeting(){let t=i.Z.get(this.props.plugin,"chatbox.greeting",{}),e=this.props.store.matchAgent("*"),s=t.agent_id;s||(s=function(t){var e=i.Z.filter(t,(t=>"agent"===t.type));return e[Math.floor(Math.random()*i.Z.size(e))]||{}}(e).id);let r=this.props.t.i18n(i.Z.get(t,"greeting",{}))||t.message;this.setState({previewEvent:{by:{id:s,type:"agent"},data:{message:{text:r,format:"plaintext"}}},displayPreview:!0})}HideGreeting(){this.setState({previewEvent:{}})}loadGreeting(){let t=this.props.plugin.chatbox;if((new i.Z.Date).getTime()-this.props.store.matchClosePreviewAt()<h)return;let e=i.Z.get(t,"greeting",{});e.message&&e.enabled?this.ShowGreeting():this.setState({previewEvent:{}})}onClick(){let t=this.props.store.matchLastview();return i.Z.get(t,"view")&&("list"!==t.view||i.Z.size(this.props.store.matchConvo("*"))>0)?this.props.onClick&&this.props.onClick(Object.assign({},t.opts,{view:t.view})):this.onPreviewClick()}onPreviewClick(t){let e=i.Z.convoOfEv(this.state.previewEvent);if(!e){let t=i.Z.map(this.props.store.matchConvo("*")),s=i.Z.find(t,(t=>!i.Z.isConvoSeen(t,this.props.store.matchUser().id)));s||(s=t[0]||{}),e=s.id}this.closePreview(t),this.props.onClick&&this.props.onClick({view:"chat",cid:e})}renderUnread(){let t=this.props.store.matchUnread();return 0===t?null:(0,o.h)("div",{class:"chat-button--unread"},t)}renderPreview(){let t=this.props.store.matchAccount(),e=this.props.plugin.chatbox,s=i.Z.get(this.state.previewEvent,"by.display_id",i.Z.get(this.state.previewEvent,"by.id")),r=i.Z.cloneDeep(this.props.store.matchAgent(s))||{};r.fullname=r.fullname||i.Z.get(t,"name")||this.props.t("agent"),r.avatar_url=r.avatar_url||l;let a=i.Z.get(e,"desktop_button.position")||"right";this.props.store.isMobile()&&(a=i.Z.get(e,"mobile_button.position")||a);let n="widget-preview widget-preview--"+a;this.state.displayPreview||(n+=" widget-preview--hidden");var p=this.renderMessagePreview(this.state.previewEvent,this.props.t("sent_you_a_message"));return 0===i.Z.size(p)&&(n+=" widget-preview--hidden"),(0,o.h)("div",{class:n},(0,o.h)("div",{class:"widget-preview--body"},(0,o.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,o.h)("div",{class:"widget-preview--content",onClick:t=>this.onPreviewClick(t)},(0,o.h)("div",{class:"widget-preview--title"},r.fullname),(0,o.h)("p",{class:"widget-preview--message"},p)),(0,o.h)("div",{class:"widget-preview--btn-close",onClick:t=>this.closePreview(t)})),(0,o.h)("div",{class:"widget-preview--action",onClick:t=>this.onPreviewClick(t)},(0,o.h)("div",{class:"widget-preview--action-text"},this.props.t("chat_now"))))}onProfileReady(){this.state.buttonLoaded&&this.setState({opacity:1}),this.setState({profileLoaded:!0})}onButtonReady(){this.state.profileLoaded&&this.setState({opacity:1}),this.setState({buttonLoaded:!0})}renderButton(){let t=this.props.plugin.chatbox;t=this.fixMissingSetting(t);let e=i.Z.get(t,"desktop_button.background_image_url")||i.Z.get(t,"desktop_button.background_mask_url")||n,s=i.Z.get(t,"background")||d,r=i.Z.get(t,"desktop_button.position")||"right",a=i.Z.get(t,"desktop_button.background_image_url"),l=i.Z.get(t,"desktop_button.background_mask_url");if(this.props.store.isMobile()){e=i.Z.get(t,"mobile_button.background_image_url")||i.Z.get(t,"mobile_button.background_mask_url")||e,r=i.Z.get(t,"mobile_button.position")||r;let s=i.Z.get(t,"mobile_button.background_image_url"),o=i.Z.get(t,"mobile_button.background_mask_url");(s||o)&&(a=s,l=o)}let p="chat-button--white-bg";!a&&l&&(p+=" chat-button--white-bg--mask-only");let h="";a=this.props.store.replaceFileUrl(a),e=this.props.store.replaceFileUrl(e),l=this.props.store.replaceFileUrl(l),a||l||(p+=" chat-button--white-bg--mask-only",h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(c)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(c)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(c)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(c)}") !important;\n\t\t\t\theight: 70px !important;\n\t\t\t\twidth: 70px !important;\n\t\t\t\tbackground: ${s} !important;\n\t\t\t`),a&&l&&(h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(l)}") !important;\n\t\t\t\tbackground-image: url("${encodeURI(a)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n\t\t\t`),a&&!l&&(h=`\n\t\t\t\tbackground-image: url("${encodeURI(a)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n\t\t\t`),!a&&l&&(h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(l)}") !important;\n\t\t\t\theight: 70px !important;\n\t\t\t\twidth: 70px !important;\n\t\t\t\tbackground: ${s} !important;\n\t\t\t`);let u="chat-button chat-button--"+r;return(0,o.h)("div",{class:u,onClick:t=>this.onClick(t)},(0,o.h)("div",{class:p}),(0,o.h)("div",{class:"chat-button--img-container",style:h},(0,o.h)("img",{width:"70",height:"70",alt:"chat button",class:"chat-button--img",onload:()=>this.onButtonReady(),src:e,onError:(t,e)=>this.onChatButtonError(t,e)})),this.renderUnread())}onProfileError(t){t.target.src=l,this.onProfileReady()}onChatButtonError(t){this._onChatButtonErrorExecuted||(this._onChatButtonErrorExecuted=!0,t.target.src=n)}renderMessagePreview(t,e){e=e||"Sent you a message";let s=i.Z.get(t,"data.message.text");var r=i.Z.get(t,"data.message.format");if(r&&"plaintext"!==r&&(s=e),!s&&i.Z.size(i.Z.get(t,"data.message.attachments"))>0&&(s=e),!s)return null;let n=i.Z.get(t,"by.type");return i.Z.extractText(s).map((t=>"emoji"===t.type?(0,o.h)(a,{emojiCode:t.text,byType:n}):t.text))}closePreview(t){t&&(t.preventDefault(),t.stopPropagation()),this.setState({displayPreview:!1}),this.props.store.closePreview(),this.forceUpdate()}}const h=18e5,c="https://file-subiz.com/bubble_11.svg",d="linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)";var u=s(8430);class m extends r.M{constructor(t){super(t)}render(){if(this.props.store.isMobile())return null;var t=`https://subiz.com.vn/?utm_source=id-${this.props.store.matchUser().account_id}&utm_medium=widget&utm_campaign=widget_referral`;return(0,o.h)("div",{class:"poweredby"},(0,o.h)("a",{href:t,class:"poweredby--text",target:"_blank",rel:"noreferrer"},(0,o.h)("img",{width:"14",height:"10",class:"poweredby--subiz-logo",src:u,alt:"power by"})," Subiz"))}}class g extends r.M{constructor(t){super(t)}render(){let t=this.props.plugin.chatbox,e=this.props.store.matchAgent("*");var r=i.Z.map(this.props.agent_ids,(t=>e[t]));if(void 0===this.props.agent_ids||0===i.Z.size(this.props.agent_ids)){var a=i.Z.get(t,"header.agent_ids",[]);r=0!==(a=i.Z.filter(a,(t=>!!e[t]))).length?i.Z.map(a,(t=>e[t])):i.Z.filter(e,(t=>"agent"===t.type))}r=i.Z.filter(r,(t=>!!t));let n=this.props.store.matchAccount();var l=this.props.tooltipPos||"bottom",p=this.props.mode||"primary";if(0===r.length)return(0,o.h)("div",{class:`group-avatar group-avatar--${p}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":n.name,"data-tooltip-position":l},(0,o.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:this.props.store.replaceFileUrl(n.logo_url)||s(9895)})));if(1===r.length){var h=r[0],c="primary"===p?"group-avatar--agent-middle":"group-avatar--agent-left";return(0,o.h)("div",{class:`group-avatar group-avatar--${p}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":h.fullname||n.name,"data-tooltip-position":l},(0,o.h)("img",{width:35,height:35,class:`avatar ${c}`,alt:"agent avatar",src:this.props.store.replaceFileUrl(h.avatar_url)||s(4761)})))}if(2===r.length){let t=r[0],e=r[1];return(0,o.h)("div",{class:`group-avatar group-avatar--${p}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":t.fullname||n.name,"data-tooltip-position":l},(0,o.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:this.props.store.replaceFileUrl(t.avatar_url)||s(4761)})),(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":e.fullname||n.name,"data-tooltip-position":l},(0,o.h)("img",{alt:"agent avatar right",width:35,height:35,class:"avatar group-avatar--agent-right",src:this.props.store.replaceFileUrl(e.avatar_url)||s(4761)})))}let d=r[0],u=r[1],m=r[2];return(0,o.h)("div",{class:`group-avatar group-avatar--${p}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":d.fullname||n.name,"data-tooltip-position":l},(0,o.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:this.props.store.replaceFileUrl(d.avatar_url)||s(4761)})),(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":u.fullname||n.name,"data-tooltip-position":l},(0,o.h)("img",{alt:"agent avatar middle",width:35,height:35,class:"avatar group-avatar--agent-middle",src:this.props.store.replaceFileUrl(u.avatar_url)||s(4761)})),(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":m.fullname||n.name,"data-tooltip-position":l},(0,o.h)("img",{width:35,height:35,alt:"agent avatar right",class:"avatar group-avatar--agent-right",src:this.props.store.replaceFileUrl(m.avatar_url)||s(4761)})))}}class v extends r.M{constructor(t){super(t)}render(){let t="widget-header",e=!1,s=!1,r="list"!==this.props.view&&!0,a=this.props.plugin.chatbox||{},n=i.Z.get(a,"header.layout");return r?t+=" widget-header--collapsed":(t+=" widget-header--convo-expanded",e="social"===n,s=!e),(0,o.h)("div",{class:t},this.renderCollapsedHeader(r),this.renderSocial(e),this.renderTeam(s))}renderCollapsedHeader(t){let e=this.props.plugin.chatbox||{},s=this.props.store.matchAccount().is_online?this.props.t("agent_online"):this.props.t("agent_offline"),r=i.Z.get(e,"tagline",{}),a=this.props.t.i18n(r)||e.introduction||s,n=i.Z.map(this.getAgentJoined(this.props.cid),(t=>t.id)),l="widget-header--inner widget-header--inner--collapsed";return t||(l+=" widget-header--inner--hidden"),(0,o.h)("div",{class:l},this.renderBackButton(),(0,o.h)(g,{plugin:this.props.plugin,store:this.props.store,mode:"secondary",agent_ids:n}),(0,o.h)("div",{class:"widget-header--title-container"},(0,o.h)("div",{class:"widget-header--title"},this.getTitle()),(0,o.h)("div",{class:"widget-header--description",title:a},a)),this.renderCloseButton())}renderSocial(t){let e=this.props.plugin.chatbox||{},s=this.props.store.matchAccount(),r=i.Z.get(e,"header.links")||[],n=i.Z.map(r,(t=>t.url&&t.type&&"subiz"!==t.type?"email"===t.type?(0,o.h)("div",null,(0,o.h)("a",{href:`mailto:${t.url}`,title:t.url},(0,o.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):(0,o.h)("div",null,(0,o.h)("a",{href:t.url,target:"_blank",title:t.url,rel:"noreferrer"},(0,o.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):null)),l=i.Z.get(e,"tagline",{});var p=this.props.t.i18n(l)||e.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",h=i.Z.extractText(p).map((t=>"emoji"===t.type?(0,o.h)(a,{emojiCode:t.text}):t.text));let c="widget-header--inner widget-header--inner--expanded";return t||(c+=" widget-header--inner--hidden"),(0,o.h)("div",{class:c},(0,o.h)("div",{class:"widget-header-expand-container"},(0,o.h)("div",{class:"widget-header--top-wrapper"},(0,o.h)("div",{class:"widget-header--title"},this.getTitle()),this.renderCloseButton()),(0,o.h)("div",{class:"widget_header__body widget_header__body__social"},(0,o.h)("img",{alt:"logo",class:"social__account_logo",src:this.props.store.replaceFileUrl(i.Z.get(s,"logo_url"))}),(0,o.h)("div",null,(0,o.h)("div",{class:"social__introduction"},h),(0,o.h)("div",{class:"social__links"},n)))))}renderTeam(t){let e=this.props.plugin.chatbox||{},s=i.Z.get(e,"tagline",{});var r=this.props.t.i18n(s)||e.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=i.Z.extractText(r).map((t=>"emoji"===t.type?(0,o.h)(a,{emojiCode:t.text}):t.text));let l="widget-header--inner widget-header--inner--expanded";return t||(l+=" widget-header--inner--hidden"),(0,o.h)("div",{class:l},(0,o.h)("div",{class:"widget-header-expand-container"},(0,o.h)("div",{class:"widget-header--top-wrapper"},(0,o.h)("div",{class:"widget-header--title"},this.getTitle()),this.renderCloseButton()),(0,o.h)("div",{class:"widget_header__body"},(0,o.h)("div",{class:"widget-header--avatar-wrapper"},(0,o.h)(g,{plugin:this.props.plugin,store:this.props.store,mode:"primary"})),(0,o.h)("div",{class:"widget-header--title-container"},(0,o.h)("div",{class:"widget-header--description"},n)))))}getTitle(){let t=this.props.plugin.chatbox||{},e=this.props.store.matchAccount(),s=this.getAgentJoined(this.props.cid),r=i.Z.get(this.props.plugin,"chatbox.caption",{}),o=this.props.t.i18n(r)||t.title;return f(s)||o||e.name||this.props.t("widget_title")}renderBackButton(){let t=this.props.store.matchConvo("*");if(0===i.Z.size(t))return null;var e=null;let s=this.props.store.matchUser(),r=0;return i.Z.map(t,(t=>{t.id!=this.props.cid&&(i.Z.isConvoSeen(t,s.id)||r++)})),0!==r&&(e=(0,o.h)("span",{class:"widget-header--total-unread-convo"},r)),(0,o.h)("div",{class:"widget-header--wrap-button-back "+(r?"widget-header--has-convo-unred":""),onClick:t=>this.onBackClick(t)},(0,o.h)("div",{class:"widget-header--button-back","data-tooltip":this.props.t("menu_back")}),e)}renderCloseButton(){return(this.props.plugin.chatbox||{}).hide_close_button?null:(0,o.h)("div",{class:"widget-header--button widget-header--button-close","data-tooltip":this.props.t("close"),"data-tooltip-position":"bottom",onClick:t=>this.onCloseClick(t)},(0,o.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(t){var e=this.props.store.matchConvo(t)||{};return i.Z.filter(e.members,(t=>"agent"===t.type&&"active"===t.membership))}}let f=t=>i.Z.map(t,(t=>t.name)).join(", ");class b extends r.M{constructor(t){var e,s,r;super(t),e=this,s="onEnter",r=i.Z.throttle((function(){this.submitMessage()}),50),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,this.refFileInput=(0,o.Vf)(),this.refMessageInput=(0,o.Vf)(),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(t=>{i.Z.convoOfEv(t)===this.props.cid&&this.forceUpdate()})),this.focus(),this._forceUpdate=i.Z.throttle((()=>{this.forceUpdate()}),500),this.resizeInput=i.Z.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)}render(){var t=(0,o.h)("div",{class:"d-flex flex-row align-self-end"},this.renderEmoji(),(0,o.h)("div",{"data-tooltip-poasition":"top-left",class:"message-input--button message-input--attachment-button",onClick:t=>this.selectFile(t)}));i.Z.trim(this.refMessageInput.current&&this.refMessageInput.current.value).length>0&&(t=(0,o.h)("div",{class:"d-flex flex-row align-self-end"},this.renderEmoji(),(0,o.h)("div",{"data-tooltip-position":"top-left",class:"message-input--button message-input--send-button",onClick:()=>this.submitMessage()})));var e="",s=this.hasUnfinishRequiredFormOrLock()||this.props.disabled;return s&&(e="message-input--disabled"),(0,o.h)("div",{class:`message-input ${e}`,onClick:t=>{this.refMessageInput.current&&this.refMessageInput.current.focus()}},(0,o.h)("input",{class:"d-none",ref:this.refFileInput,type:"file",onChange:t=>this.sendFile(t),multiple:!0}),(0,o.h)("textarea",{disabled:s,class:"message-input--input",maxlength:"1024",placeholder:this.props.t("message_input_help"),ref:this.refMessageInput,rows:"1",onInput:t=>this.onChange(t),onPaste:t=>this.pasteImage(t),"data-emojiable":"true",onKeydown:t=>this.onKeydown(t)}),t)}hasUnfinishRequiredFormOrLock(){let t=this.props.store.matchConvo(this.props.cid);if("ended"===i.Z.get(t,"state"))return!1;let e=this.props.store.listEvents(this.props.cid);e=i.Z.orderBy(e,"created","desc").filter((t=>"message_sent"===t.type));let s=i.Z.get(e[0],"data.message.attachments",[]);if(i.Z.find(s,(t=>i.Z.get(t,"lock_input"))))return!0;var r;for(let t of e)if("user"!==i.Z.get(t,"by.type")){r=t;break}s=i.Z.get(r,"data.message.attachments",[]);let o=i.Z.filter(s,(t=>{if(!t)return!1;if("form"!==t.type&&"ask_info_form"!==t.type)return!1;var e=t.form;return!(!e||!(i.Z.parseJSON(e.state)||{}).require_finished&&"ask_info_form"!==t.type||function(t){let e=i.Z.get(t,"fields")||[];return i.Z.find(e,(t=>!!t.answered))}(t.form))}));return i.Z.size(o)>0}renderEmojiPopup(){return this.state.openEmoji?(0,o.h)("div",{class:"emoji-picker","v-clickaway":t=>this.setState({openEmoji:!1})},(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":like:"),"data-tooltip":":like:",class:"emoji-picker--item emoji--like"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":unlike:"),"data-tooltip":":unlike:",class:"emoji-picker--item emoji--unlike"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":angry:"),"data-tooltip":":angry:",class:"emoji-picker--item emoji--angry"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":confused:"),"data-tooltip":":confused:",class:"emoji-picker--item emoji--confused"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":crying:"),"data-tooltip":":crying:",class:"emoji-picker--item emoji--crying"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":grinning:"),"data-tooltip":":grinning:",class:"emoji-picker--item emoji--grinning"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":heart-eyes:"),"data-tooltip":":heart-eyes:",class:"emoji-picker--item emoji--heart-eyes"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":neutral:"),"data-tooltip":":neutral:",class:"emoji-picker--item emoji--neutral"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":sad:"),"data-tooltip":":sad:",class:"emoji-picker--item emoji--sad"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":sleepy:"),"data-tooltip":":sleepy:",class:"emoji-picker--item emoji--sleepy"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":smiling:"),"data-tooltip":":smiling:",class:"emoji-picker--item emoji--smiling"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":surprised:"),"data-tooltip":":surprised:",class:"emoji-picker--item emoji--surprised"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":tired:"),"data-tooltip":":tired:",class:"emoji-picker--item emoji--tired"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":tongue-out:"),"data-tooltip":":tongue-out:",class:"emoji-picker--item emoji--tongue-out"})),(0,o.h)("div",{class:"emoji-picker-background-item"},(0,o.h)("div",{onClick:()=>this.emojiPick(":wink:"),"data-tooltip":":wink:",class:"emoji-picker--item emoji--wink"}))):null}focus(){this.props.disabled||(this.refMessageInput.current&&this.refMessageInput.current.focus(),setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()})),setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()}),100))}renderEmoji(){return(0,o.h)("div",null,this.renderEmojiPopup(),(0,o.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,s=e.selectionStart,i=this.refMessageInput.current.value;this.setState({openEmoji:!1}),this.refMessageInput.current.value=[i.slice(0,s),t,i.slice(s)].join(""),this.resizeInput(),e.focus()}onKeydown(t){if(13===t.keyCode&&!1===t.shiftKey)return this.onEnter(),t.preventDefault();this._forceUpdate(),this.sendTyping()}onChange(){this.resizeInput()}selectFile(){this.props.disabled||this.refFileInput.current.click()}sendFile(){let t=this.refFileInput.current;this._sendFile(t.files),t.value=""}_sendFile(t){if(0===i.Z.size(t))return;if(this.props.disabled)return;let e=i.Z.map(t,(t=>({type:"file",mimetype:t.type,name:t.name,_file:t,size:t.size})));this.props.onSend&&this.props.onSend({attachments:e})}async submitMessage(t){(t=t||i.Z.trim(this.refMessageInput.current.value)||"")&&(this.props.disabled||(this.refMessageInput.current.value="",this.resizeInput(),this.setState({openEmoji:!1}),this.props.onSend&&this.props.onSend({text:t,format:"plaintext"})))}sendTyping(){if(this.props.cid)return this.props.store.typing(this.props.cid)}pasteImage(t){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return;let e=new i.Z.Date;const s=`Paste-image-${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}-${e.getHours()}-${e.getMinutes()}-${e.getSeconds()}`;let r=null;const o=t.clipboardData.items[0];if(0===o.type.indexOf("image")&&(r=o.getAsFile()),!r)return;const a=[r,new ArrayBuffer],n=new File(a,`${s}.png`,{type:"image/png"});this._sendFile([n])}}class _ extends r.M{constructor(t){super(t)}render(){var t=i.Z.get(this.props.ev,"data.message.attachments",[]),e=[];let s=i.Z.get(this.props.ev,"by.type");if(i.Z.each(t,((t,s)=>{if(t&&i.Z.includes(t.mimetype,"image")&&t.url){var r=t.url;r.startsWith("https://")||r.startsWith("http://")||r.startsWith("content://")||r.startsWith("data:")||(t.url=this.props.store.FileURL+r),e.push(t)}})),0===e.length)return null;var r=i.Z.map(e,((t,e)=>(0,o.h)("div",{class:`image-attachment image-attachment--${s}`},(0,o.h)("a",{href:this.props.store.replaceFileUrl(t.thumbnail_url||t.url),target:"_blank"},(0,o.h)("img",{alt:!0,class:"image-attachment__img",src:this.props.store.replaceFileUrl(t.thumbnail_url||t.url),onload:t=>this.props.onLoad&&this.props.onLoad()})))));return"agent"===s?(0,o.h)("div",{class:"message-agent"},r):(0,o.h)("div",{class:"message-user"},r)}}class y extends r.M{constructor(t){super(t)}render(){let t=i.Z.get(this.props.ev,"by.type");var e=i.Z.get(this.props.ev,"data.message.attachments",[]),s=[];if(i.Z.each(e,((t,e)=>{t&&i.Z.includes(t.mimetype,"audio")&&s.push(t)})),0===s.length)return null;var r=i.Z.map(s,((e,s)=>(0,o.h)("div",{key:s,class:`audio-attachment audio-attachment--${t}`},(0,o.h)("audio",{class:"audio-attachment__audio",controls:!0},(0,o.h)("source",{src:this.props.store.replaceFileUrl(e.url),type:e.mimetype})))));return(0,o.h)("div",{class:`message-${t}`},r)}}class w extends r.M{render(){var t=i.Z.get(this.props.ev,"by.type","agent"),e=i.Z.get(this.props.ev,"data.message.attachments",[]),s=[];if(i.Z.each(e,(t=>{t&&(t.url||t._file)&&(i.Z.includes(t.mimetype,"video")||i.Z.includes(t.mimetype,"audio")||i.Z.includes(t.mimetype,"image")||"button"===t.type||"quick_replies"===t.type||"form"===t.type||"form_submit"===t.type||s.push(t))})),0===s.length)return null;var r=i.Z.map(s,((e,s)=>(0,o.h)("div",{key:s,class:`file-attachment file-attachment--${t}`},(0,o.h)("a",{class:"file-attachment--link",href:this.props.store.replaceFileUrl(e.url),target:"_blank"},(0,o.h)("span",{class:"file-attachment--download mr-2"}),(0,o.h)("span",{class:"file-attachment--filename"},e.name)))));return(0,o.h)("div",{class:`message-${t}`},r)}}class Z extends r.M{constructor(t){super(t)}render(){if(0===i.Z.size(this.props.buttons))return null;var t=i.Z.map(this.props.buttons,((t,e)=>"call_button"===t.type?(0,o.h)("a",{class:"url-button-attachment",href:"tel:"+t.phone_number,key:e,title:t.title},t.title):"url_button"===t.type?(0,o.h)("a",{class:"url-button-attachment",href:t.url,target:"_blank",key:e,title:t.title},t.title||t.url):"postback_button"===t.type?(0,o.h)("a",{class:"url-button-attachment",href:"javascript:;",onClick:e=>this.props.onSelect(t)},t.title):("widget_ask_desktop_notify_button"===t.type||t.type,null)));return(0,o.h)("div",{class:"button-attachments"},t)}}class k extends r.M{constructor(t){super(t)}render(){if("user"===i.Z.get(this.props.ev,"by.type"))return null;let t=[],e=i.Z.get(this.props.ev,"data.message.attachments",[]);return i.Z.each(e,((e,s)=>{e&&"button"===i.Z.get(e,"type")&&i.Z.each(i.Z.get(e,"buttons")||[],(e=>t.push(e)))})),(0,o.h)(Z,{store:this.props.store,buttons:t})}}class C extends r.M{constructor(t){super(t)}render(){if("user"===i.Z.get(this.props.ev,"by.type"))return null;let t=[];if(i.Z.map(i.Z.get(this.props.ev,"data.message.attachments",[]),(e=>{e&&"quick_replies"===e.type&&(t=i.Z.get(e,"quick_replies",[]))})),t=i.Z.filter(t,(t=>t.title)),0===t.length)return null;let e=i.Z.convoOfEv(this.props.ev),s=this.props.store.matchConvo(e);if("ended"===i.Z.get(s,"state"))return null;let r=i.Z.map(this.props.store.listEvents(e));r=i.Z.orderBy(r,"created","asc").filter((t=>"message_sent"===t.type));let a=0;for(var n=0;n<r.length;n++)if(r[n].id===this.props.ev.id){a=n;break}for(n=a+1;n<r.length;n++)if("user"===i.Z.get(r[n],"by.type"))return null;let l=i.Z.map(t,(t=>(0,o.h)("div",{class:"message_quick_reply",onClick:e=>this.props.onSelect(t)},t.title)));return(0,o.h)("div",{class:"message_quick_replies"},l)}}class x extends r.M{constructor(t){super(t),this.setState({search:"",isShow:!1})}render(){let t=i.Z.filter(this.props.items,(t=>{let e=this.state.search.toLowerCase();return(t||"").toLowerCase().indexOf(e)>-1})),e=i.Z.map(t,(t=>(0,o.h)("li",{class:"custom-select--item-options",onClick:()=>this.add(t)},t))),s=i.Z.map(this.props.selected,((t,e)=>(0,o.h)("div",{class:"custom-select--selected-item",onClick:t=>this.remove(t,e)},t,(0,o.h)("i",{class:"icn-delete delete-tag"})))),a=(0,o.h)("div",{class:"custom-select--wrap-options"},(0,o.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,o.h)("ul",{class:"custom-select--items-options"},e));return this.state.isShow||(a=null),(0,o.h)("div",{class:"form-control custom-select"},(0,o.h)(r.u,{onClickaway:t=>this.clickaway()},(0,o.h)("div",{class:"custom-select--wrap-selected",onClick:()=>this.setState({isShow:!this.state.isShow})},(0,o.h)("div",{class:"custom-select--selected-items"},s),a,(0,o.h)("div",{class:"custom-select--icon-dropdown"},(0,o.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,o.h)("g",{opacity:"0.6"},(0,o.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)}}class S extends r.M{constructor(t){super(t),this.props.store.onUpdate(this,(t=>this.forceUpdate()));let e=this.props.store.matchUser(),s=i.Z.get(this.props.form,"fields")||[],r=i.Z.map(s,(t=>{let s=t.is_required||!1;var r=i.Z.parseJSON(t.state)||{};s||(s=r.require||!1);var o=i.Z.getUserAttr(e,t.name,r.type||"text");return{name:t.name,items:t.items,value:i.Z.parseJSON(t.answer)||i.Z.parseJSON(t.default_answer)||o,is_required:s,label:t.title,type:t.input_type}}));this.setState({formData:r})}isSummited(){return!!i.Z.find(this.state.formData,(t=>!!t.answered))||"ended"===this.props.store.matchConvo(i.Z.convoOfEv(this.props.ev)).state}render(){if(0===i.Z.size(this.state.formData))return null;let t=this.renderFields(),e=null;return this.isSummited()||(e=(0,o.h)("div",{class:"mt-2"},(0,o.h)("button",{onClick:t=>this.submit(),type:"button",class:"form-attachment--submit-btn"},this.props.t("btn_submit_form_attachment")))),(0,o.h)("div",{class:"form-attachment",onClick:t=>t.stopPropagation()},this.props.t(this.props.form.title)||this.props.t("capture_lead_title"),t,e)}focus(){if(this.props.store.isPreview)return;if(0===i.Z.size(this.state.formData))return;let t;if(this.isFormFilled()){var e=Object.keys(this.state.formData),s=e[i.Z.size(e)-1];t=this["field."+M(this.state.formData[s].name)]}else{var r=this.firstUnfilledField();if(!r)return;t=this["field."+M(r.name)]}t&&t.focus()}firstUnfilledField(){return i.Z.find(this.state.formData,(t=>null==t.value||""===t.value))}isFormFilled(){return!i.Z.find(this.state.formData,(t=>null==t.value||""===t.value))}onInputChange(t,e){let s=i.Z.cloneDeep(this.state.formData);s[t].value=e,this.setState({formData:s})}onListAddItem(t,e){let s=i.Z.cloneDeep(this.state.formData),r=s[t];r.value=r.value||[],r.value.push(e),this.setState({formData:s})}onListRemoveItem(t,e){let s=i.Z.cloneDeep(this.state.formData),r=s[t];r.value=r.value||[],r.value.splice(e,1),this.setState({formData:s})}renderFields(){if(0===i.Z.size(this.state.formData))return null;let t=null;return t=i.Z.map(this.state.formData,((t,e)=>{let s=null;var r=t.error?"input--error":"";if("text"===t.type)s=this.isSummited()?(0,o.h)("div",{class:"form-control--container"},(0,o.h)("input",{disabled:!0,ref:e=>{this["field."+M(t.name)]=e},value:t.value,onInput:t=>this.onInputChange(e,t.target.value),class:`form-control ${r}`,type:"text"}),(0,o.h)("i",{class:"form-control--check"})):(0,o.h)("input",{ref:e=>{this["field."+M(t.name)]=e},value:t.value,onInput:t=>this.onInputChange(e,t.target.value),class:`form-control ${r}`,type:"text"});else if("number"===t.type)s=this.isSummited()?(0,o.h)("div",{class:"form-control--container"},(0,o.h)("input",{disabled:!0,ref:e=>{this["field."+M(t.name)]=e},value:t.value,onInput:t=>this.onInputChange(e,t.target.value),class:`form-control ${r}`,type:"number"}),(0,o.h)("i",{class:"form-control--check"})):(0,o.h)("input",{ref:e=>{this["field."+M(t.name)]=e},value:t.value,onInput:t=>this.onInputChange(e,t.target.value),class:`form-control ${r}`,type:"number"});else if("boolean"===t.type)s=(0,o.h)("div",{class:"checkbox"},(0,o.h)("input",{ref:e=>{this["field."+M(t.name)]=e},type:"checkbox",id:"checkbox."+this.props.ev.id+"."+t.name,onChange:t=>this.onInputChange(e,ev.target.checked),checked:t.value}),(0,o.h)("label",{class:"checkbox--label",for:"checkbox."+this.props.ev.id+"."+t.name},t.label),(0,o.h)("div",{class:"checkbox--check"},(0,o.h)("div",null)));else if("list"===t.type){let r=t.value||[],a=i.Z.filter(i.Z.get(t,"items",[]),(t=>!r.includes(t)));s=(0,o.h)(x,{selected:r,items:a,onAddItem:t=>this.onListAddItem(e,t),onRemoveItem:t=>this.onListRemoveItem(e,t)})}else"datetime"===t.type&&(s=(0,o.h)("input",{ref:e=>{this["field."+M(t.name)]=e},value:t.value,onInput:t=>this.onInputChange(e,t.target.value),class:`form-control ${r}`,type:"date"}));let a=t.label;return"fullname"===t.name?a=this.props.t("fullname"):"emails"===t.name?a=this.props.t("email"):"phones"===t.name&&(a=this.props.t("phones")),(0,o.h)("div",null,(0,o.h)("p",{class:"label mt-3"},a,t.is_required?(0,o.h)("span",{class:"ml-1 red"},"*"):""),t.error?(0,o.h)("div",{class:"form-control--valid-input--error"},t.error):"",s)})),(0,o.h)("div",null,t)}async submit(){var t=!1;if(i.Z.map(this.state.formData,(e=>{e.is_required&&(void 0===e.value||""===e.value||0===i.Z.size(e.value)&&Array.isArray(e.value))?(e.error=this.props.t("error_empty"),t=!0):e.error="","emails"===e.name&&e.value&&(i.Z.isEmail(e.value)||(e.error=this.props.t("error_email_invalid"),t=!0))})),this.forceUpdate(),t)return;let e={},s=i.Z.cloneDeep(this.state.formData);i.Z.map(s,(t=>{var s={key:t.name};t.answered=(new i.Z.Date).getTime(),"number"===t.type&&(s.number=parseInt(t.value),t.answer=i.Z.stringify(s.number)),"datetime"===t.type&&(s.datetime=new i.Z.Date(t.value).toISOString(),t.answer=i.Z.stringify(s.datetime)),"list"===t.type&&(s.list=t.value,t.answer=i.Z.stringify(s.list)),"text"!==t.type&&"boolean"!==t.type||(s[t.type]=t.value,t.answer=i.Z.stringify(t.value)),i.Z.setUserAttr(e,s)})),i.Z.map(s,(t=>{let e=i.Z.find(this.props.form.fields,(e=>e.name===t.name));e&&(e.answered=t.answered)})),this.setState({formData:s}),this.props.store.setUser(e);let r={attachments:[{type:"form_submit",form_submit:{state:'{"user_id":"'+this.props.store.matchUser().id+'"}',form_message_id:i.Z.get(this.props.ev,"id"),fields:s}}]},o=i.Z.convoOfEv(this.props.ev);this.props.store.sendConvoEvent(o,"message_sent",{message:r}),this.props.onSubmit&&this.props.onSubmit()}}function M(t){return btoa(t).split("=").join("")}class D extends r.M{constructor(t){super(t)}render(){if("user"===i.Z.get(this.props.ev,"by.type"))return;let t=[],e=i.Z.get(this.props.ev,"data.message.attachments")||[];i.Z.each(e,(e=>{e&&("form"!==e.type&&"ask_info_form"!==e.type||(e.form._type=e.type,t.push(e.form)))}));let s=i.Z.map(t,((t,e)=>(0,o.h)(S,{store:this.props.store,onSubmit:this.props.onSubmit,ref:t=>{this["form."+e]=t},key:e,form:t,ev:this.props.ev,t:this.props.t})));return 0===s.length?null:(0,o.h)("div",{class:"message-agent"},s)}focus(){var t=this["form.0"];t&&t.focus()}}class U extends r.M{constructor(t){super(t)}render(){return null}}function I(t){return t.touches&&t.touches.length?t.touches[0]:{}}class j extends r.M{constructor(t){super(t),this.state={focusing:0},this.galleryRef=(0,o.Vf)()}componentDidMount(){this.bindDrag()}focus(t){this.setState({focusing:t}),this.galleryRef.current.scrollLeft=190*t-20}render(){if("user"===i.Z.get(this.props.ev,"by.type"))return null;let t=i.Z.get(this.props.ev,"data.message.attachments",[]),e=i.Z.filter(t,(t=>"generic"===i.Z.get(t,"type")));return 0===e.length?null:i.Z.map(e,((e,s)=>{var r=i.Z.map(e.elements,(t=>{let e=t.title?(0,o.h)("div",{class:"generic-attachment--element-title"},t.title):null,s=t.subtitle?(0,o.h)("div",{class:"generic-attachment--element-subtitle"},t.subtitle):null;return(0,o.h)("div",{class:"generic-attachment--element swiper-slide"},(0,o.h)("div",null,(0,o.h)("img",{alt:"generic attachment element",class:"generic-attachment--element-img",src:this.props.store.replaceFileUrl(t.image_url)})),e,s,(0,o.h)(Z,{buttons:t.buttons,onSelect:t=>this.props.onSelect(t)}))}));let a=i.Z.get(t,"0.elements",[]),n="generic-attachment-navigator generic-attachment-navigator--left",l="generic-attachment-navigator generic-attachment-navigator--right";return 0===this.state.focusing&&(n+=" generic-attachment-navigator--disabled"),this.state.focusing===a.length-1&&(l+=" generic-attachment-navigator--disabled"),(0,o.h)("div",{class:"generic-attachment-container"},(0,o.h)("div",{class:"generic-attachment",ref:this.galleryRef},r),!this.props.store.isMobile()&&(0,o.h)(o.HY,null,(0,o.h)("div",{class:n,onClick:t=>this.focus(this.state.focusing-1)},(0,o.h)("span",{class:"generic-attachment-navigator-icon"},"‹")),(0,o.h)("div",{class:l,onClick:t=>this.focus(this.state.focusing+1)},(0,o.h)("span",{class:"generic-attachment-navigator-icon"},"›"))))}))}bindDrag(){if(!this.props.store.isMobile())return;let t=document.getElementsByClassName("generic-attachment");i.Z.map(t,(t=>{var e,s,i;(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=I(t);e.hasAttribute("nochilddrag")&&document.elementFromPoint(r.pageX,r.pageY)||(i=1,s=r.clientX,t.preventDefault())},e.mu=()=>{i=0},e.mm=function(t){if(!i)return;let r=I(t);e.scrollLeft-=-s+r.clientX,s=r.clientX},e.addEventListener("touchstart",e.md,{passive:!0}),window.addEventListener("touchend",e.mu,{passive:!0}),window.addEventListener("touchmove",e.mm,{passive:!0}))}))}}class E extends r.M{render(){let t=i.Z.get(this.props.ev,"by.type");if("user"===t)return null;let e=i.Z.get(this.props.ev,"data.message.attachments",[]),r=i.Z.filter(e,(t=>"product"===i.Z.get(t,"type")||"product_preview"===i.Z.get(t,"type")));if(r=r.filter((t=>t.product&&t.product.name)),0===r.length)return null;let a=this.props.store.matchAccount();return i.Z.map(r,((e,r)=>{let n=e.product,l=null,p=n.url||n.mobile_url;this.props.store.isMobile()&&(p=n.mobile_url||n.url),p&&(l=(0,o.h)("a",{class:"product_attachment__btn",href:p,target:"_blank"},this.props.t("detail"),(0,o.h)("img",{src:s(8453),class:"product_attachment__btn_external_link"})));let h=(0,o.h)("a",{href:p,class:"product_attachment__title",target:"_blank"},n.name),c=null,d=n.description||n.long_description;d&&(c=(0,o.h)("div",{class:"product_attachment__subtitle"},d));let u=null;return n.price&&(u=(0,o.h)("div",{class:"product_attachment__price"},n.currency||i.Z.get(a,"currency","")," ",i.Z.formatCurrency(n.price))),(0,o.h)("div",{class:"product_attachment product_attachment__"+t},(0,o.h)("div",null,(0,o.h)("a",{href:this.props.store.replaceFileUrl(n.image),target:"_blank"},(0,o.h)("img",{class:"product_attachment__img",src:this.props.store.replaceFileUrl(n.image)}))),h,c,u,(0,o.h)("div",{class:"product_attachment__btns"},l))}))}}class F extends r.M{render(){let t=i.Z.get(this.props.ev,"by.type");if("user"===t)return null;this.props.store.matchAccount();var e=i.Z.get(this.props.ev,"data.message.attachments",[]);let r=i.Z.filter(e,(t=>"order"===t.type&&t.order)).map((t=>t.order));return 0===r.length?null:i.Z.map(r,((e,r)=>{let a=null;e.note&&(a=(0,o.h)("div",null,(0,o.h)("div",{class:"order_attachment__label"},this.props.t("note")),(0,o.h)("div",{class:"order_attachment__text_truncate"},e.note)));let n=null;i.Z.size(e.items)>0&&(n=(0,o.h)("div",null,(0,o.h)("div",{class:"order_attachment__label"},this.props.t("product")),i.Z.map(e.items,(t=>{let e=t.product||{};return(0,o.h)("div",{class:"order_attachment__product"},(0,o.h)("img",{class:"order_attachment__product_img",src:(i.Z.get(e,"images.0"),s(9270))}),(0,o.h)("div",{style:"overflow: hidden !important;"},(0,o.h)("div",{class:"order_attachment__product_name"},e.name),(0,o.h)("div",{class:"order_attachment__product_desc"},e.description||e.long_description),(0,o.h)("div",{class:"order_attachment__product_desc"},this.props.t("qty")," ",t.quantity," · ",i.Z.formatCurrency(e.price))))}))));let l=(0,o.h)("div",{class:"order_attachment__footer"},(0,o.h)("div",null,this.props.t("total"))," ",(0,o.h)("div",null,(0,o.h)("b",null,i.Z.formatCurrency(e.total)))),p=i.Z.get(e,"shipping.address",{}),h=[p.street,p.ward,p.district,p.region,p.country].filter((t=>t)).join(", "),c=i.Z.find(i.Z.get(e,"user.attributes",[]),(t=>"phones"===t.key))||{key:"phones",text:""},d=i.Z.get(e,"shipping.address.phone","").trim();d=d||i.Z.trim(c.text),d&&(d=this.props.t("phn")+": "+d);let u=null;return(h||d)&&(u=(0,o.h)("div",null,(0,o.h)("div",{class:"order_attachment__label"},this.props.t("ship_to")),(0,o.h)("div",{class:"order_attachment__text_truncate"},h),(0,o.h)("div",{class:"order_attachment__text_truncate"},d))),(0,o.h)("div",{class:`order_attachment order_attachment__${t}`},(0,o.h)("div",{class:"order_attachment__header"},this.props.t("order"),(0,o.h)("span",{class:"order_attachment__text_muted order_attachment__text_sm"},"#",e.id)),n,u,(0,o.h)("div",null,(0,o.h)("div",{class:"order_attachment__label"},this.props.t("payment")),(0,o.h)("div",null,"COD")),a,l)}))}}class R extends r.M{constructor(t){super(t)}render(){let t=i.Z.get(this.props.ev,"by.type");var e=i.Z.get(this.props.ev,"data.message.attachments",[]),s=[];if(i.Z.each(e,((t,e)=>{t&&i.Z.includes(t.mimetype,"video")&&s.push(t)})),0===s.length)return null;var r=i.Z.map(s,((e,s)=>(0,o.h)("div",{class:`video-attachment video-attachment--${t}`},(0,o.h)("video",{class:"video-attachment__video",src:this.props.store.replaceFileUrl(e.url),width:"100%",height:"",poster:this.props.store.replaceFileUrl(e.thumbnail_url),controls:"controls",preload:"metadata",onclick:"this.play()"}))));return(0,o.h)("div",{class:`message-${t}`},r)}}class P extends r.M{constructor(t){super(t),this.ref=(0,o.Vf)()}componentDidMount(){this.shadowRoot=this.ref.current.attachShadow({mode:"open"}),this.update(this.props.html)}update(t){this.shadowRoot.innerHTML=`<style type="text/css">\nbody { font-family: 'Roboto', sans-serif!important; font-size: 14px!important; line-height: 20px; overflow-y: hidden; margin:0 }\nh{ font-size: 14/18px!important; }\na { text-decoration: none;}\nimg { max-width: 100%; display: block; margin: 10px auto; }\n* { white-space: normal }\nul > li { margin-bottom: 5px }\nul:last-child { margin-bottom: 0 }\np:first-child { margin-top: 0;}\np:last-child { margin-bottom: 0;}\n</style>\n<div>${t}</div>`;let e=this.shadowRoot.querySelectorAll("a");for(var s=0;s<e.length;s++)e[s].target="_blank"}render(){return(0,o.h)("div",{ref:this.ref,style:"white-space: normal !important"})}}let $=[],A=(t,e)=>($.push(t),"");(async()=>{let t=(await s.e(441).then(s.bind(s,7441))).marked;A=(e,s)=>t(s),i.Z.map($,(t=>t.forceUpdate())),$=[]})();class L extends r.M{render(){if("markdown"===i.Z.get(this.props.ev,"data.message.format","plaintext"))return this.renderMarkdown();var t=i.Z.get(this.props.ev,"data.message.text");if(t=i.Z.trim(t),0===i.Z.size(t))return null;let e=i.Z.get(this.props.ev,"by.type");var s=i.Z.extractText(t).map((t=>"emoji"===t.type?(0,o.h)(a,{emojiCode:t.text,byType:e}):"link"===t.type?(0,o.h)("a",{href:t.text,target:"_blank"},t.text):"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));return 0===i.Z.size(s)?null:"agent"===e?(0,o.h)("div",{class:"message-agent message-text--agent"},s):(0,o.h)("div",{class:"message-user message-text--user"},s)}renderMarkdown(){var t=i.Z.get(this.props.ev,"data.message.text");if(0===i.Z.size(t))return null;let e=i.Z.get(this.props.ev,"by.type");return t=i.Z.trim(t),0===i.Z.size(t)?null:"agent"===e?(0,o.h)("div",{class:"markdown-message message-agent message-text--agent"},(0,o.h)(P,{html:A(this,t)})):(0,o.h)("div",{class:"d-flex flex-column align-items-end"},(0,o.h)("div",{class:"markdown-message message-user message-text--user"},(0,o.h)(P,{html:A(this,t)})))}}var z=new i.Z.Pubsub;setInterval((()=>z.publish("time")),2e4);class B extends r.M{constructor(t){super(t),this.setState({t:"",langCode:"en_US"})}updateTime(){var t="";if(this.props.ago){if(this.props.short&&Math.abs(this.props.time-(new i.Z.Date).getTime())>864e6){let e=new i.Z.Date(this.props.time),s=e.getFullYear(),r=i.Z.get(navigator,"languages.0","en-US"),o=e.toLocaleDateString(r,{month:"short"});t=e.getDate()+" "+o+" "+s}!t&&this.props.time>0&&(t=function(t,e){const s={s:"%d s",m:"1m",mm:"%dm",h:"1h",hh:"%dh",d:"1d",dd:"%dd",M:"1M",MM:"%M",y:"1y",yy:"%dy"},i=[{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}],r=i.length;let o,a;for(let n=0;n<r;n+=1){let r=i[n];r.d&&(o=(t-e)/r.d);let l=Math.round(Math.abs(o));if(l<=r.r||!r.r){l<=1&&n>0&&(r=i[n-1]),a=s[r.l].replace("%d",l);break}}return a}(this.props.time,(new i.Z.Date).getTime()))}else t=i.Z.shortTime(this.props.time,this.props.tzoffset);this.props.uppercase&&(t=t.toUpperCase()),t!==this.state.t&&this.setState({t})}componentDidMount(){z.on2(this,"time",(()=>this.updateTime())),this.updateTime()}render(){return(0,o.h)("span",null,this.state.t)}}class T extends r.M{render(){let t=this.props.ev.ev;var e=null;if(this.props.ev.show_time&&(e=(0,o.h)("div",{class:"convo-event-time"},(0,o.h)(B,{time:t.created}))),"conversation_rated"===t.type){var s=i.Z.get(t,"data.conversation.ratings.0",{no_rating:!0,rating:0});return s.no_rating?null:(0,o.h)("div",{class:"convo-event"},e,(0,o.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"}(s.rating)).toLowerCase()))}return"conversation_state_updated"===t.type&&"ended"===i.Z.get(t,"data.conversation.state")?(0,o.h)("div",{class:"convo-event"},e,(0,o.h)("div",{class:"info-message"},this.props.t("conversation_ended"))):null}}class q extends r.M{constructor(t){super(t),this.refForm=(0,o.Vf)()}render(){var t=i.Z.get(this.props.event,"ev",{});switch(t.type){case"conversation_joined":break;case"message_sent":return this.renderMessageSent();case"conversation_state_updated":case"conversation_rating_requested":case"conversation_rated":return i.Z.startsWith(t.id,"ev")?(0,o.h)(T,{t:this.props.t,store:this.props.store,ev:this.props.event}):null}return null}focus(){this.refForm.current&&this.refForm.current.focus()}chooseQuickReply(t){let e=i.Z.get(this.props.event,"ev",{}),s={text:t.title,format:"plaintext"};t.payload&&(s.attachments=[{type:"postback",postback:{event_id:e.id,payload:t.payload}}]),this.props.onSend(s)}choosePostbackBtn(t){let e=i.Z.get(this.props.event,"ev",{}),s={text:t.title,format:"plaintext"};t.payload&&(s.attachments=[{type:"postback",postback:{event_id:e.id,payload:t.payload}}]),this.props.onSend(s)}renderAgentAvatar(t){let e=i.Z.get(t,"by.type"),r=i.Z.get(t,"by.display_id",i.Z.get(t,"by.id"));if("user"===e)return null;var a=this.getSenderName(t);let n=this.props.store.matchAccount();var l=n.logo_url||s(9895);let p=this.props.store.matchAgent("*");return"system"===r&&"dummy"===e||(l=i.Z.get(p[r],"avatar_url")||n.logo_url||s(4761)),(0,o.h)("div",{class:"message-sender"},(0,o.h)("img",{alt:"sender",class:"message-sender-avatar",src:this.props.store.replaceFileUrl(l)}),(0,o.h)("p",{class:"message-sender-name"},a))}renderMessageSent(){let t=this.props.event.ev;var e=null;this.props.event.show_time&&(e=(0,o.h)("div",{class:"convo-event-time"},(0,o.h)(B,{time:t.created})));let s=new i.Z.Date(t.created).toLocaleString();if("user"!==i.Z.get(t,"by.type")){let i=null;return"lead"===this.props.event.mode&&(i=this.renderAgentAvatar(t)),(0,o.h)("div",{class:"convo-event agent-message",title:s},e,i,(0,o.h)(L,{store:this.props.store,ev:t}),(0,o.h)(_,{store:this.props.store,ev:t}),(0,o.h)(y,{store:this.props.store,ev:t}),(0,o.h)(R,{store:this.props.store,ev:t}),(0,o.h)(w,{store:this.props.store,ev:t}),(0,o.h)(k,{store:this.props.store,ev:t}),(0,o.h)(D,{store:this.props.store,onSubmit:this.props.onFormSubmit,ref:this.refForm,ev:t,t:this.props.t}),(0,o.h)(U,{store:this.props.store,ev:t,t:this.props.t}),(0,o.h)(j,{store:this.props.store,ev:t,onSelect:t=>this.choosePostbackBtn(t)}),(0,o.h)(E,{t:this.props.t,store:this.props.store,ev:t}),(0,o.h)(F,{t:this.props.t,store:this.props.store,ev:t}),(0,o.h)(C,{store:this.props.store,ev:t,onSelect:t=>this.chooseQuickReply(t)}))}i.Z.getMsgField(t,"idempotency")===t.id&&this.props.store.now()-t.created<900&&setTimeout((()=>this.setState({refresh:this.state.refresh})),1e3);let r=(0,o.h)("div",{class:"sending_dot"});(this.props.store.now()-t.created<900||i.Z.getMsgField(t,"idempotency")!==t.id)&&(r=(0,o.h)("div",{class:"sending_dot sending_dot__hide"}));let a=null;"lead"===this.props.event.mode&&(a=(0,o.h)("div",{class:"pt-3"}));let n=null;return t._error&&"message_sent"===t.type&&(n=(0,o.h)("a",{class:"message_error",src:"javascript:;",onClick:t=>this.resendMessage()},(0,o.h)("div",{class:"message_error__text"},this.props.t("error_send_message")),(0,o.h)("div",{class:"message_error__icon"}))),(0,o.h)("div",{class:"convo-event user-message",title:s},e,a,(0,o.h)("div",{class:"message-user__container"},r,(0,o.h)(L,{store:this.props.store,ev:t,refresh:this.state.refresh}),(0,o.h)(_,{store:this.props.store,ev:t}),(0,o.h)(y,{store:this.props.store,ev:t}),(0,o.h)(R,{store:this.props.store,ev:t}),(0,o.h)(w,{store:this.props.store,ev:t}),(0,o.h)(k,{store:this.props.store,ev:t}),(0,o.h)(D,{store:this.props.store,onSubmit:this.props.onFormSubmit,ref:this.refForm,ev:t}),(0,o.h)(E,{t:this.props.t,store:this.props.store,ev:t}),(0,o.h)(U,{store:this.props.store,ev:t})),n)}renderUpdateConvo(t){var e=i.Z.get(t,"data.conversation.state");return"active"===e||"pending"===e?null:(0,o.h)("div",{class:"message-system"},this.props.t("conversation_state_updated",{state:e}))}resendMessage(){let t=i.Z.convoOfEv(this.props.event.ev);const e=i.Z.get(this.props.event,"ev.data.message");this.props.store.sendConvoEvent(t,"message_sent",{message:e})}getSenderName(t){let e=i.Z.get(t,"by.type"),s=i.Z.get(t,"by.display_id",i.Z.get(t,"by.id"));if("system"===s||"dummy"===e)return"system";let r=this.props.store.matchUser(),o=this.props.store.matchAccount();return"user"===e?i.Z.getUserDisplayName(r):"agent"===e?i.Z.getAgentDisplayName(o,this.props.store.matchAgent(s)):""}}const O=s(6484);class W extends r.M{render(){let t=(this.props.mode+"").toLowerCase(),e="dark"===t?"#000000dd":"blue"===t?"rgba(52, 152, 220, .8)":"#ffffffdd",s="dark"===t?"#00000055":"blue"===t?"rgba(52, 152, 220, .15)":"#ffffff55",i=this.props.size||14,r=`width: ${i}px !important;height: ${i}px!important;color: ${s} !important;border-width: ${Math.ceil(i/14)}px !important;\n border-left-color: ${s} !important;border-top-color: ${s} !important;\n border-bottom-color: ${s} !important;border-right-color: ${e} !important;`;if(this.props.static){let t=`width: ${i}px;height: ${i}px;`;return i<40?(0,o.h)(LoaderIcon,{size:i+"",style:`stroke:${e}`}):this.props.center?(0,o.h)("div",{class:"loading"},(0,o.h)("img",{alt:"loading",style:t,src:O})):(0,o.h)("img",{alt:"loading",style:t,src:O})}return(0,o.h)("div",{class:"spinner1",style:r})}}const Y=s(6188);class H extends r.M{constructor(t){super(t),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(t=>this.onEvent(t))),this.loadConvo(),this.refBody=null,this.checkAndSeen=i.Z.throttle((()=>{this.props.isShow&&this.isBottom()&&"visible"===this.props.store.browserVisibility&&document.hasFocus()&&this.props.store.seenConvo(this.props.cid)}),500),this.checkAndSeen()}componentDidUpdate(t){t.cid!==this.props.cid&&this.loadConvo()}render(){if(this.state.error)return this.renderError();let t=i.Z.map(this.props.store.listEvents(this.props.cid));if(!this.state.loading&&0===i.Z.size(t))return(0,o.h)("div",{ref:t=>this.refBody=t,class:"widget-body--events-container"},(0,o.h)("div",{class:"widget-body--empty"},(0,o.h)("div",{class:"widget-body--empty-icon"}),(0,o.h)("div",{class:"widget-body--empty-text"},this.props.t("empty_convo_text"))),(0,o.h)(m,{store:this.props.store}));t=i.Z.orderBy(t,"created","asc"),this.props.store.matchConvo(this.props.cid),t=i.Z.map(t,(t=>({ev:t}))),function(t,e){if(!((e=e.filter((t=>V(t.ev)))).length<1)){for(var s=1;s<e.length;s++){let t=e[s],r=e[s-1];V(t.ev)&&i.Z.unixSec(t.ev.created)-i.Z.unixSec(r.ev.created)>120&&(t.show_time=!0)}for(s=0;s<e.length;s++){let t=e[s];if("message_sent"===i.Z.get(t,"ev.type")){t.show_time=!0;break}}for(s=0;s<e.length;s++){let t=e[s],r=e[s-1];"message_sent"!==t.ev.type||(t.mode="lead","message_sent"===i.Z.get(r,"ev.type")&&i.Z.get(r,"ev.by.id")===i.Z.get(t,"ev.by.id")&&(t.mode="follow"))}}}(0,t);let e=i.Z.map(t,(t=>(0,o.h)(q,{store:this.props.store,onFormSubmit:this.props.onFormSubmit,onSend:this.props.onSend,onPostback:this.props.onPostback,event:t,t:this.props.t,key:t.ev.id}))),s=null,r="opacity: 1 !important";return(this.state.loading||this.props.creating)&&(s=(0,o.h)(W,{static:!0,mode:"blue",size:"120",center:!0}),r="opacity: 0 !important"),(0,o.h)(o.HY,null,s,(0,o.h)("div",{style:r,ref:t=>this.refBody=t,class:"widget-body--events-container",onMouseOver:this.checkAndSeen},(0,o.h)("div",{class:"widget-body--events"},e),(0,o.h)(m,{store:this.props.store})))}renderError(){let t=(0,o.h)("a",{href:"#",onclick:t=>this.loadConvo()},this.props.t("try_again"));return this.state.loading&&(t=(0,o.h)(W,{size:"16",mode:"blue"})),(0,o.h)("div",{class:"widget-body--events-container widget-body--events-container__error"},(0,o.h)("img",{alt:"empty",src:Y}),(0,o.h)("div",{class:"widget_body__events__error_msg"},this.props.t("load_convo_error")),(0,o.h)("div",{class:"widget_body__events__error_retry"},t))}focus(){let t=this.props.store.listEvents(this.props.cid);var e;t=i.Z.orderBy(i.Z.map(t),"created","desc");for(let s of t)if("message_sent"===i.Z.get(s,"type")&&"user"!==i.Z.get(s,"by.type")){e=s;break}"user"===i.Z.get(e,"by.type")&&(e=null);let s=i.Z.get(e,"data.message.attachments",[]),r=this.props.store.matchConvo(this.props.cid);i.Z.filter(s,(t=>{if(!t)return!1;if("form"!==t.type&&"ask_info_form"!==t.type)return!1;var e=t.form;return!(!e||!(i.Z.parseJSON(e.state)||{}).require_finished&&"ask_info_form"!==t.type||function(t){let e=i.Z.get(t,"fields")||[];return i.Z.find(e,(t=>!!t.answered))}(t.form)||"ended"===r.state)}))}onEvent(t){if(i.Z.convoOfEv(t)!==this.props.cid)return;let e=this.isBottom();var s=!1;"message_sent"===i.Z.get(t,"type")&&t.id===i.Z.getMsgField(t,"idempotency")&&(s=!0),(s||e)&&this.scrollToBottom()}async loadConvo(){if(!this.props.cid)return;this.lastContentOffsetY=0,this.setState({loading:!0});let t=this.props.store.listEvents(this.props.cid);if(0===i.Z.size(t)){let t=this.props.cid,{error:e}=await this.props.store.fetchMoreEvents(t);if(this.setState({loading:!1}),t!==this.props.cid)return;if(e)return void this.setState({error:!0})}this.setState({loading:!0}),this.props.store.fetchMoreEvents(this.props.cid),this.setState({error:!1}),this.scrollToBottom(),setTimeout((()=>this.setState({loading:!1})),50)}isBottom(){let t=this.refBody;return!!t&&t.scrollHeight<t.scrollTop+t.offsetHeight+50}scrollToBottom(){setTimeout((()=>{const t=this.refBody;t&&(t.scrollTop=t.scrollHeight)})),setTimeout((()=>{const t=this.refBody;t&&(t.scrollTop=t.scrollHeight)}),200),this.props.isShow&&"visible"===this.props.store.browserVisibility&&document.hasFocus()&&this.props.store.seenConvo(this.props.cid)}}function V(t){let e=i.Z.get(t,"type");return"message_sent"===e||"conversation_state_updated"===e}class G extends r.M{constructor(t){super(t)}componentDidMount(){this.setState({isShow:!1,ev:{}}),this.props.store.onConvoEvent(this,(t=>{if(i.Z.convoOfEv(t)!==this.props.cid)return;let e=this.props.store.matchUser();if(i.Z.get(t,"by.id")===e.id)return;let s=i.Z.get(this.state.ev,"by.id");return s&&i.Z.get(t,"by.id")!==s?void 0:"message_sent"===i.Z.get(t,"type")?(this.timer&&clearTimeout(this.timer),this.timer=null,void this.setState({isShow:!1})):void("conversation_typing"===i.Z.get(t,"type")&&(this.setState({ev:t,isShow:!0}),this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{i.Z.convoOfEv(t)===this.props.cid&&(this.timer=null,this.setState({isShow:!1}))}),1e4)))}))}render(){let t=this.props.store.matchAccount();var e=this.state.isShow?"":"typing--hidden";let s=i.Z.get(this.state.ev,"by.display_id",i.Z.get(this.state.ev,"by.id")),r=i.Z.getAgentDisplayName(t,this.props.store.matchAgent(s));return(0,o.h)("div",{class:`typing ${e}`},r," ",this.props.t("typing"))}}function J(t,e){return Math.abs(t-e)<=.001}class N extends r.M{constructor(t){var e,s;super(t),s={hide:!0,ratingHeight:0,overlayOpacity:.3,comment:""},(e="state")in this?Object.defineProperty(this,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):this[e]=s,this.refComment=(0,o.Vf)(),this.refRating=(0,o.Vf)(),this.refHandle=(0,o.Vf)()}componentDidMount(){this.props.store.onUpdate(this,(()=>{this.shoudDisplay()&&this.open()})),this.props.store.onConvoEvent(this,(t=>{i.Z.convoOfEv(t)===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 t=this.refHandle.current;t.addEventListener("mousedown",this.mouseDown,{passive:!0}),t.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 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,s){var r;this.stop();var o=a=>{a||(a=(new i.Z.Date).getTime());var n=a-r,[l,p]=this.calcY(t,e,n);if(s(l),p)return this.stop();this.animationframe=window.requestAnimationFrame(o)};this.animationframe=window.requestAnimationFrame((t=>{r=t||(new i.Z.Date).getTime(),o(r)}))}calcY(t,e,s){var i,r=function(t,e,s,i){if(J(t,e))return t;var r=t+(e-t)/i*s;return(t<e&&r>e||e<t&&r<e)&&(r=e),r}(e,i=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,s,this.duration);return[r,J(r,i)]}stop(){window.cancelAnimationFrame(this.animationframe)}}({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,o.h)("div",{class:t},(0,o.h)("div",{class:"rating--overlay",style:`opacity: ${.5*this.state.overlayOpacity} !important;`}),(0,o.h)("div",{class:"rating",ref:this.refRating,style:`color:red; height: ${this.state.ratingHeight}px !important;`},(0,o.h)("div",{class:"rating--handle",ref:this.refHandle},(0,o.h)("div",{class:"rating--thumb"})),(0,o.h)("div",{class:"rating--content"},(0,o.h)("div",{class:"rating--heading"},this.props.t("rating_title"),(0,o.h)("div",{class:"rating--close-btn",onClick:t=>this.onCloseRating(t)})),(0,o.h)("div",{class:"rating--description"},this.props.t("rating_description")),(0,o.h)("textarea",{ref:this.refComment,type:"text",class:"rating--comment"}),(0,o.h)("div",{class:"rating-faces-container"},(0,o.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingPoor(t)},(0,o.h)("img",{alt:"poor",src:s(8367)}),(0,o.h)("p",{class:"rating-face--text"},this.props.t("poor"))),(0,o.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingAverage(t)},(0,o.h)("img",{alt:"average",src:s(6535)}),(0,o.h)("p",{class:"rating-face--text"},this.props.t("average"))),(0,o.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingGreat(t)},(0,o.h)("img",{alt:"great",src:s(3824)}),(0,o.h)("p",{class:"rating-face--text"},this.props.t("great")))),(0,o.h)("div",{class:"rating-no-thanks",onClick:t=>this.onCloseRating(t)},this.props.t("no_thanks")))))}shoudDisplay(){if(!this.props.cid)return!1;var t,e,s;let r=this.props.store.matchUser();if(i.Z.map(this.props.store.listEvents(this.props.cid),(o=>{"conversation_state_updated"===i.Z.get(o,"type")&&"ended"===i.Z.get(o,"data.conversation.state")&&(s=o),"conversation_rating_requested"===i.Z.get(o,"type")&&(t=o),"conversation_rated"===i.Z.get(o,"type")&&i.Z.get(o,"by.id")===r.id&&(e=o)})),e)return!1;var o=this.props.plugin.chatbox.auto_request_rating&&s;return t||o}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)){setTimeout((()=>{this.refComment.current&&this.refComment.current.focus()}),400),this.refComment.current.value="";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)})}))}}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),s=parseFloat(e.height);this.animation.play(this.mouseVelocity,s,(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 s=this.refRating.current.getBoundingClientRect().bottom-e;s>400&&(s=500-1e4/(s+-300)),this.setState({ratingHeight:s,overlayOpacity:Math.min(1,(s-0)/500)})}}}var X=s(9737),K=s(8909),Q=s(29);const tt="https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png";class et extends r.M{constructor(t){super(t),this.userSent={},this.setState({creating:!1,clickedJoin:!1,formData:{}}),this.props.store.onUpdate(this,(t=>this.forceUpdate()))}componentDidMount(){this.props.store.isMobile()||this.focusInput()}componentDidUpdate(t){t.isShow!==this.props.isShow&&(this.props.isShow&&!this.props.store.isMobile()&&this.focusInput(),this.props.isShow&&this.props.store.isMobile()&&this.blur()),t.cid!==this.props.cid&&(this.setState({clickedJoin:!1}),setTimeout((()=>{this.events&&this.events.focus(),this.props.store.isMobile()||this.focusInput()}),100)),this.updateFormDataFields()}shouldShowForm(){let t=this.isFormRequired();return t&&!this.props.cid||t&&this.props.cid&&this.state.clickedJoin}render(){this.isFormRequired();let t,e=this.shouldShowForm(),s=this.props.plugin.chatbox||{},r=this.props.store.matchAccount()||{},a=this.props.t("prechat_form_btn");i.Z.get(s,"prechat_form.enabled")&&(t=s.prechat_form);let n=i.Z.get(s,"offline_form.enabled");this.isOffline(r,s)&&n&&(t=s.offline_form,a=this.props.t("offline_form_btn")),"offline_form"===this.props.view&&(e=!0,t=s.offline_form,a=this.props.t("offline_form_btn")),"prechat_form"===this.props.view&&(e=!0,t=s.prechat_form,a=this.props.t("prechat_form_btn"));let l=null;l="list"===this.props.view?this.renderConvoList():e?this.renderForm(t,a):this.renderChat();let p=i.Z.get(s,"desktop_button.position")||"right";this.props.store.isMobile()&&(p=i.Z.get(s,"mobile_button.position",p));let h="widget-container widget-container--"+p;return this.props.isShow||(h+=" widget-container--hide"),(0,o.h)("div",{class:h},(0,o.h)(v,{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"})}),l)}async submitPrechatForm(t){var e=!1;if(i.Z.map(this.state.formData,((t,s)=>{t.is_required&&(void 0===t.value||""===t.value||0===i.Z.size(t.value)&&Array.isArray(t.value))?(t.error=this.props.t("error_empty"),e=!0):t.error="","emails"===s.substr(5)&&!i.Z.isEmail(t.value)&&t.is_required&&(t.error=this.props.t("error_email_invalid"),e=!0),"phones"===s.substr(5)&&!i.Z.isPhone(t.value)&&t.is_required&&(t.error=this.props.t("error_phone_invalid"),e=!0)})),e)return this.forceUpdate();let s=i.Z.cloneDeep(this.state.formData),r=i.Z.cloneDeep(this.props.store.matchUser());i.Z.map(s,((t,e)=>{if(e.startsWith("attr:")){var s={key:e.substr(5)};"number"===t.type&&(s.number=parseInt(t.value)),"datetime"===t.type&&(s.datetime=new i.Z.Date(t.value).toISOString()),"list"===t.type&&(s.list=t.value),"text"!==t.type&&"boolean"!==t.type||(s[t.type]=t.value),i.Z.setUserAttr(r,s)}}));let o=i.Z.get(s,"question.value"),a=i.Z.get(s,"group.value","");if(this.props.cid)return this.props.store.setUser(r),this.setState({clickedJoin:!1}),await this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{text:o,format:"plaintext",fields:[{key:"to_agent_group",value:i.Z.stringify(a)}]}}),void(t.end_conversation_after_submit&&await this.props.store.endConvo(this.props.cid));this.setState({creating:!0});let n={text:o,format:"plaintext"},l={group_id:a,message:o,locale:this.props.t.locale(),initial_by:r.id};this.setState({creatingError:null});const{error:p,convo:h}=await this.props.store.startConvo(l);if(this.props.store.setUser(r),p)return void this.setState({creating:!1,creatingError:p});let c=h.id;this.userSent[c]=!0,this.props.onGo({view:"chat",cid:c}),this.props.store.sendConvoEvent(c,"message_sent",{message:n}),this.setState({creating:!1,clickedJoin:!1}),this.props.store.isMobile()||this.focusInput()}formMounted(t){let e=this.fillForm(t);e.question={key:"question",is_required:!0,label:this.props.t.i18n(i.Z.get(t,"i18n_question_label",{}))||t.question_label,type:"text"},this.setState({formData:e}),this.props.store.isMobile()||this.focusInput()}onBooleanChange(t,e){let s=i.Z.cloneDeep(this.state.formData),r=i.Z.find(s,((e,s)=>s===t));r&&(r.value=e.target.checked,this.setState({formData:s}))}onInputChange(t,e){let s=i.Z.cloneDeep(this.state.formData),r=i.Z.find(s,((e,s)=>s===t));r&&(r.value=e,this.setState({formData:s}))}onListAddItem(t,e){let s=i.Z.cloneDeep(this.state.formData),r=i.Z.find(s,((e,s)=>s===t));r&&(r.value=r.value||[],r.value.push(e),this.setState({formData:s}))}onListRemoveItem(t,e){let s=i.Z.cloneDeep(this.state.formData),r=i.Z.find(s,((e,s)=>s===t));r&&(r.value=r.value||[],r.value.splice(e,1),this.setState({formData:s}))}renderFields(){if(0===i.Z.size(this.state.formData))return null;let t=i.Z.map(this.state.formData,((t,e)=>{let s=null;var r=t.error?"input--error":"";if("text"===t.type)s="question"===e?(0,o.h)("textarea",{class:"form-control",ref:t=>{this["form_"+it(e)]=t},value:t.value||"",onInput:t=>this.onInputChange(e,t.target.value),row:"4",class:"form-control"}):(0,o.h)("input",{value:t.value||"",onInput:t=>this.onInputChange(e,t.target.value),ref:t=>{this["form_"+it(e)]=t},class:`form-control ${r}`,type:"text"});else if("number"===t.type)s=(0,o.h)("input",{value:t.value,onInput:t=>this.onInputChange(e,t.target.value),ref:t=>{this["form_"+it(e)]=t},class:`form-control ${r}`,type:"number"});else if("boolean"===t.type)s=(0,o.h)("div",{class:"checkbox"},(0,o.h)("input",{type:"checkbox",id:"form-checkbox"+it(e),onInput:t=>this.onBooleanChange(e,t),checked:t.value}),(0,o.h)("label",{class:"checkbox--label",for:"form-checkbox"+it(e)},t.label),(0,o.h)("div",{class:"checkbox--check"},(0,o.h)("div",null)));else if("group"===t.type)s=i.Z.map(t.list,(s=>(0,o.h)("div",{class:"radio"},(0,o.h)("input",{type:"radio",id:"form-radio"+it(e)+it(s.value),checked:t.value===s.value,onInput:t=>this.onInputChange(e,s.value)}),(0,o.h)("label",{class:"radio--label",for:"form-radio"+it(e)+it(s.value)},s.label),(0,o.h)("div",{class:"radio--check"},(0,o.h)("div",{class:"inside"})))));else if("list"===t.type){let r=this.state.formData[e].value||[],a=i.Z.filter(i.Z.get(t,"list",[]),(t=>!i.Z.includes(r,t)));s=(0,o.h)(x,{selected:r,items:a,onAddItem:t=>this.onListAddItem(e,t),onRemoveItem:t=>this.onListRemoveItem(e,t)})}else"datetime"===t.type&&(s=(0,o.h)("input",{value:t.value,onInput:t=>this.onInputChange(e,t.target.value),class:`form-control ${r}`,type:"date"}));let a="";return"fullname"===t.key?a=this.props.t("fullname"):"emails"===t.key?a=this.props.t("email"):"phones"===t.key?a=this.props.t("phones"):"question"===t.key&&(a=t.label||this.props.t("your_question")),t.label&&(a=t.label),(0,o.h)("div",null,(0,o.h)("div",{class:"label"},a,t.is_required?(0,o.h)("span",{class:"ml-1 red"},"*"):""),t.error?(0,o.h)("div",{class:"form-control--valid-input--error"},t.error):"",s)}));return(0,o.h)("div",{class:"pt-2"},t)}renderForm(t,e){let s=null;this.state.creating&&(s=(0,o.h)("span",{class:"ml-2"},(0,o.h)(W,{size:"16",mode:"white"})));let r=this.props.t.i18n(i.Z.get(t,"i18n_title",{}));return r||(r=i.Z.get(t,"title",this.props.t("capture_lead_title"))),r=r.replace("↵",""),(0,o.h)("div",{class:"widget-body"},(0,o.h)(st,{form:t,onMount:t=>this.formMounted(t)}),(0,o.h)("div",{class:"widget-body--content flex-grow-1 pl-3 pr-3 d-flex flex-column"},(0,o.h)("div",{class:"flex-grow-1"},(0,o.h)("div",{class:"form mt-3 pl-3 pr-3 pt-3 pb-3 d-flex flex-column"},(0,o.h)("div",null,r),this.renderFields())),(0,o.h)(m,{store:this.props.store,t:this.props.t})),(0,o.h)("div",{class:"message-input message-input--preform"},(0,o.h)("button",{class:"btn--start-convo",onClick:e=>this.submitPrechatForm(t)},e," ",s)))}goToConvo(t){this.props.onGo({view:"chat",cid:t})}renderConvoList(){let t=this.props.store.matchConvo("*");var e=i.Z.map(t,(t=>this.props.store.matchConvo(t.id)));e=i.Z.filter(e,(t=>!!t)),e=i.Z.orderBy(e,"created","desc");var s=i.Z.map(e,(t=>{let e=i.Z.filter(t.members,(t=>("agent"===t.type||"bot"===t.type)&&"active"===t.membership)),s=i.Z.map(e,(t=>t.id));return s=s||i.Z.agentsOfConvo(t)[0],(0,o.h)("div",{class:"convo-list--item",onClick:()=>this.goToConvo(t.id),key:t.id},(0,o.h)(g,{plugin:this.props.plugin,store:this.props.store,mode:"member",class:"d-flex flex-row",tooltipPos:"right",agent_ids:s}),this.renderConvoSummary(t))}));let r=(0,o.h)("div",{class:"convo-list--list"},s);return 0===i.Z.size(e)&&(r=(0,o.h)("div",{class:"convo-list--list"},(0,o.h)("div",{class:"empty-container"},(0,o.h)("img",{alt:"empty",src:Q}),(0,o.h)("div",{class:"empty-desc"},this.props.t("empty_convo"))))),(0,o.h)("div",{class:"convo-list"},(0,o.h)("div",{class:"convo-list--container"},(0,o.h)("div",{class:"convo-list--title"},this.props.t("conversations")),r),(0,o.h)("div",{class:"convo-list--footer"},(0,o.h)("button",{class:"btn--start-convo",onClick:t=>this.goToConvo("")},(0,o.h)("span",null,this.props.t("start_conversation")),(0,o.h)("img",{src:X,alt:"send button",width:"26",height:"26"})),(0,o.h)(m,{store:this.props.store})))}blur(){if(!this.props.store.isPreview){var t=this.msgInput;t&&(setTimeout((()=>t&&t.blur())),setTimeout((()=>t&&t.blur()),300))}}focusInput(){if(!this.props.store.isPreview){if(this.shouldShowForm()){let t="";return i.Z.map(this.state.formData,((e,s)=>{"text"===e.type&&(t||e.value||(t=s))})),void setTimeout((()=>{var e=this["form_"+it(t)];e&&e.focus()}),300)}var t=this.msgInput;t&&(setTimeout((()=>t.focus())),setTimeout((()=>t.focus()),300))}}onRate(t){this.props.cid&&(this.props.store.sendConvoEvent(this.props.cid,"conversation_rated",{conversation:{ratings:[t]}}),this.focusInput())}async sendMessage(t){let e=t.text;if(!this.props.cid){this.creating=!0;const{convo:s,error:i}=await this.props.store.startConvo({locale:this.props.t.locale(),message:e,initial_by:this.props.store.matchUser().id});return this.creating=!1,this.props.store.sendConvoEvent(s.id,"message_sent",{message:t}),void this.props.onGo({view:"chat",cid:s.id})}this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:t})}createPostback(t){this.props.store.createPostback(this.props.cid,t)}renderChat(){let t=(0,o.h)(b,{store:this.props.store,ref:t=>this.msgInput=t,cid:this.props.cid,onSend:t=>this.sendMessage(t),t:this.props.t}),e=this.props.store.matchConvo(this.props.cid)||{};return(this.isFormRequired()||"ended"===e.state)&&(t=(0,o.h)("div",{class:"message-input message-input--preform"},(0,o.h)("button",{class:"btn--start-convo",onClick:t=>this.onStartConvoClick(t)},this.props.t("offline_preform_btn")))),(0,o.h)("div",{class:"widget-body"},(0,o.h)("div",{class:"widget-body--content",onClick:t=>this.onContainerClick(t)},(0,o.h)(H,{isShow:this.props.isShow,store:this.props.store,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}),(0,o.h)(G,{store:this.props.store,cid:this.props.cid,t:this.props.t})),(0,o.h)(N,{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}),t)}async onStartConvoClick(){if("ended"===(this.props.store.matchConvo(this.props.cid)||{}).state)return this.props.onGo({view:"chat",cid:""});this.setState({clickedJoin:!0})}onEventFormSubmit(){this.focusInput()}onContainerClick(){window.getSelection().toString().length>0||this.props.store.isMobile()||this.focusInput()}isFormRequired(){let t,e=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};i.Z.get(e,"prechat_form.enabled")&&(t=e.prechat_form);let r=i.Z.get(e,"offline_form.enabled");if(this.isOffline(s,e)&&r&&(t=e.offline_form),!t)return!1;let o=this.fillForm(t),a=this.props.store.matchConvo(this.props.cid)||{};return"ended"===a.state||!this.userHasSent(this.props.cid)&&(a.state&&"pending"!==a.state&&delete o.group,!!i.Z.find(o,(t=>null==t.value||""===t.value)))}renderConvoSummary(t){let e=this.props.store.matchAgent("*"),s=i.Z.filter(t.members,(t=>("agent"===t.type||"bot"===t.type)&&"active"===t.membership)),r=i.Z.map(s,(t=>t.id));r=r||i.Z.agentsOfConvo(t)[0];let a=i.Z.map(r,(t=>e[t]||{avatar_url:tt,fullname:"Offline Agent"}));var n=i.Z.each(a,(t=>t.fullname)).join(", ");n||(n=this.props.store.matchAccount().name),n||(n=this.props.t("agent"));var l=null;"user"===t.lastSenderType&&(l=(0,o.h)("span",{class:"yourmessage"},this.props.t("you"),":"));let p=i.Z.isConvoSeen(t,this.props.store.matchUser().id);var h=this.renderMessagePreview(t.last_message_sent||{data:{message:i.Z.get(t,"last_message")}}),c=i.Z.getMs(i.Z.get(t,"last_message_sent.created"))||i.Z.getMs(i.Z.get(t,"last_sent.created"))||i.Z.getMs(t.created),d=(0,o.h)(B,{ago:!0,time:c,key:c,short:!0});let u=p?null:(0,o.h)("div",{class:"convo-list--item-unread"});return"ended"===t.state&&(u=(0,o.h)("img",{alt:"conversation ended",class:"convo-list--convo-completed",src:K,title:this.props.t("conversation_ended")})),(0,o.h)("div",{class:"convo-list--convo-last-info"},(0,o.h)("div",{class:"d-flex flex-row"},(0,o.h)("div",{class:"convo-list--convo-name"},n),(0,o.h)("div",{class:"convo-list--convo-time"},d)),(0,o.h)("div",{class:"d-flex flex-row"},(0,o.h)("div",{class:"convo-list--convo-last-message"},l,h),u))}agentsOfConvo(t){let e=this.props.store.matchAgent("*");var s=i.Z.agentsOfConvo(t,!0);return i.Z.map(s,(t=>e[t]||{avatar_url:tt,fullname:"Offline Agent"}))}renderMessagePreview(t){let e=this.props.t("sent_you_a_message"),s=i.Z.get(t,"data.message.text");if("plaintext"!==i.Z.get(t,"data.message.format")&&(s=e),!s&&i.Z.size(i.Z.get(t,"data.message.attachments"))>0&&(s=e),!s)return null;let r=i.Z.get(t,"by.type");return(0,o.h)("div",{class:"convo-list--convo-last-mes"},i.Z.map(i.Z.extractText(s),(t=>"emoji"===t.type?(0,o.h)(a,{emojiCode:t.text,byType:r}):t.text)))}userHasSent(t){var e=this.props.store.matchConvo(t)||{};let s=this.props.store.matchUser();return!!this.userSent[t]||i.Z.find(e.members,(t=>t.id===s.id&&("active"===t.membership||t.last_sent>0)))}isOffline(t,e){let s=i.Z.get(e,"offline_form.enable_when"),r=!0;return"all_agents_offline"===s&&(r=t.is_online),"out_of_bussiness_hour"===s&&(r=t.is_in_business_hour),!r}updateFormDataFields(){let t,e=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};i.Z.get(e,"prechat_form.enabled")&&(t=e.prechat_form);let r=i.Z.get(e,"offline_form.enabled");if(this.isOffline(s,e)&&r&&(t=e.offline_form),"offline_form"===this.props.view&&(t=e.offline_form),"prechat_form"===this.props.view&&(t=e.prechat_form),0===i.Z.size(t))return[];var o={};i.Z.each(t.fields,(t=>{var e=Object.assign({},t);"list"===t.type&&(e.list=t.list),e.label=this.props.t.i18n(i.Z.get(t,"i18n_label",{}))||t.label,o["attr:"+t.key]=e})),t.group_required&&i.Z.size(t.groups)>0&&(o.group={key:"group",is_required:!!t.group_required,label:this.props.t.i18n(i.Z.get(t,"i18n_group_label",{}))||t.group_label,type:"group",list:i.Z.map(t.groups,(t=>({value:t.id,label:t.name})))}),o.question={key:"question",is_required:!0,label:this.props.t.i18n(i.Z.get(t,"i18n_question_label",{}))||t.question_label,type:"text"},this.isFormChanged(this.state.formData,o)&&this.setState({formData:o})}isFormChanged(t,e){let s=Object.keys(t),r=Object.keys(e);if(s.length!==r.length)return!0;for(let o=0;o<s.length;o++){if(i.Z.get(t,`${s[o]}.label`)!==i.Z.get(e,`${r[o]}.label`))return!0;if(i.Z.get(t,`${s[o]}.is_required`)!==i.Z.get(e,`${r[o]}.is_required`))return!0;if(i.Z.stringify(i.Z.get(t,`${s[o]}.list`))!==i.Z.stringify(i.Z.get(e,`${r[o]}.list`)))return!0}return!1}fillForm(t){if(0===i.Z.size(t))return[];var e={};let s=this.props.store.matchUser();return i.Z.each(t.fields,(t=>{var r=Object.assign({},t);r.value=i.Z.getUserAttr(s,t.key,t.type),"boolean"!==t.type||r.value||(r.value=!1),"datetime"===t.type&&r.value&&(r.value=new i.Z.Date(e.value).toLocaleDateString("en-CA")),"list"===t.type&&(r.list=t.list),r.label=this.props.t.i18n(i.Z.get(t,"i18n_label",{}))||t.label,e["attr:"+t.key]=r})),t.group_required&&i.Z.size(t.groups)>0&&(e.group={key:"group",is_required:!!t.group_required,label:this.props.t.i18n(i.Z.get(t,"i18n_group_label",{}))||t.group_label,type:"group",list:i.Z.map(t.groups,(t=>({value:t.id,label:t.name})))}),e}}class st extends r.M{componentDidMount(){this.props.onMount(this.props.form)}}function it(t){return btoa(t).split("=").join("")}let rt=s.e(178).then(s.bind(s,178));class ot extends r.M{constructor(t){super(t),this.refButton=(0,o.Vf)()}async refreshCSS(){let t=this.props.store.matchPlugin();if(!i.Z.find(t,(t=>t.id===this.props.plugin.id)))return;let e=(await rt).default.default.toString();var s=i.Z.replaceCssVariable(e,this.props.plugin.chatbox);i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,s)}componentWillUnmount(){i.Z.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.checkExpand())),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 at(),this.state.isShowWidget||this.hideWidget()}render(){if(!this.state.cssready)return null;if(i.Z.isUserBanned(this.props.store.matchUser()))return null;if(!this.props.t)return null;var t=this.props.store.isMobile()?"mobile":"desktop";return(0,o.h)("div",{class:t},(0,o.h)(p,{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,o.h)(et,{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}))}checkExpand(){if(this.props.store.isMobile())return;if(this.props.plugin._no_auto_expand)return;if(this.props.store.matchHasManuallyClosed())return;let t=this.props.store.matchConvo("*"),e=i.Z.find(t,(t=>!i.Z.isConvoSeen(t,this.props.store.matchUser().id)));e&&e.id&&(this.state.isShowWidget||this.showWidget({view:"chat",cid:e.id}))}getCurrentView(){return{is_show_widget:this.state.isShowWidget,conversation_id:this.state.widgetConvoId,view:this.state.widgetView}}async showWidget(t){if(this.refButton.current&&this.refButton.current.ClearPreview(),!t.view){let e=this.props.store.matchLastview()||{};t.view=i.Z.get(e,"view"),t.cid=i.Z.get(e,"opts.cid")}t=t||{},this.props.store.isMobile()&&function(){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:t.cid,widgetView:t.view}),this.props.store.setIsOpen(!0),this.forceUpdate(),this.setState({isShowWidget:!0}),this.props.store.setLastview(t.view,{cid:t.cid})}showGreeting(){this.refButton.current&&this.refButton.current.ShowGreeting()}hideGreeting(){this.refButton.current&&this.refButton.current.HideGreeting()}hideWidget(){at(),this.props.store.setIsOpen(!1),this.setState({isShowWidget:!1})}onWidgetClose(){this.refButton.current&&this.refButton.current.ClearPreview(),this.props.store.setHasManuallyClosed(),this.hideWidget()}}function at(){let t=document.getElementById("subiz-meta-viewport");t&&t.remove()}},2493:(t,e,s)=>{"use strict";s.d(e,{M:()=>r,u:()=>o});var i=s(6400);s(819);class r extends i.wA{constructor(t){super(t),this._isMounted=!0,setTimeout((()=>{if(this.componentWillUnmount){let t=this.componentWillUnmount.bind(this);this.componentWillUnmount=()=>{t(),this._isMounted=!1}}}),10)}}class o extends r{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,i.h)("div",{ref:this.setWrapperRef},this.props.children)}}},6755:(t,e,s)=>{t.exports=s.p+"assets/img/bubble_default.7d5e4ab.svg"},6188:(t,e,s)=>{t.exports=s.p+"assets/img/convos_empty.2353007.svg"},9270:(t,e,s)=>{t.exports=s.p+"assets/img/default.06e6ee0.jpg"},4761:(t,e,s)=>{t.exports=s.p+"assets/img/default_avatar.5b74dc1.png"},8909:(t,e,s)=>{t.exports=s.p+"assets/img/done_gray.d7e8203.svg"},29:(t,e,s)=>{t.exports=s.p+"assets/img/empty.29bed2d.svg"},8453:(t,e,s)=>{t.exports=s.p+"assets/img/external-link.90577cc.svg"},9895:(t,e,s)=>{t.exports=s.p+"assets/img/image_default.be0698b.png"},6484:(t,e,s)=>{t.exports=s.p+"assets/img/loading_static.8f403ae.svg"},6535:(t,e,s)=>{t.exports=s.p+"assets/img/rating--average.1ea492c.svg"},3824:(t,e,s)=>{t.exports=s.p+"assets/img/rating--great.e3d712e.svg"},8367:(t,e,s)=>{t.exports=s.p+"assets/img/rating--poor.2938a25.svg"},9737:(t,e,s)=>{t.exports=s.p+"assets/img/send.6db52a9.svg"},8430:(t,e,s)=>{t.exports=s.p+"assets/img/subiz-mono.877e9f5.svg"}}]);
File without changes