@subiz/widget-v4 4.0.63 → 4.0.64

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 (55) hide show
  1. package/babel.config.js +2 -4
  2. package/compiled_src/bot.js +7 -1
  3. package/compiled_src/call/call.js +15 -12
  4. package/compiled_src/chatbox/DropdownSelect.js +75 -66
  5. package/compiled_src/chatbox/MessageInput.js +7 -4
  6. package/compiled_src/chatbox/Order.js +94 -90
  7. package/compiled_src/chatbox/Rating.js +10 -7
  8. package/compiled_src/chatbox/Widget.js +27 -23
  9. package/compiled_src/contact/contact.js +9 -6
  10. package/compiled_src/lib.js +14 -9
  11. package/compiled_src/notif/notif.js +15 -12
  12. package/compiled_src/order/address_picker.js +71 -63
  13. package/compiled_src/order/order.js +330 -316
  14. package/compiled_src/popup/countdown.js +7 -4
  15. package/compiled_src/popup/popup.js +12 -9
  16. package/compiled_src/store/api.js +110 -80
  17. package/compiled_src/store/api_fake.js +82 -55
  18. package/compiled_src/store/store.js +170 -133
  19. package/dist/132.js +633 -588
  20. package/dist/17ee31b89ac.132.js +1 -0
  21. package/dist/{17e757ccadd.178.js → 17ee31b89ac.178.js} +0 -0
  22. package/dist/17ee31b89ac.213.js +1 -0
  23. package/dist/17ee31b89ac.335.js +1 -0
  24. package/dist/{17e757ccadd.362.js → 17ee31b89ac.362.js} +1 -1
  25. package/dist/17ee31b89ac.441.js +1 -0
  26. package/dist/17ee31b89ac.605.js +1 -0
  27. package/dist/{17e757ccadd.678.js → 17ee31b89ac.678.js} +0 -0
  28. package/dist/{17e757ccadd.782.js → 17ee31b89ac.782.js} +1 -1
  29. package/dist/17ee31b89ac.app.js +1 -0
  30. package/dist/{17e757ccadd.index.html → 17ee31b89ac.index.html} +1 -1
  31. package/dist/{17e757ccadd.library.html → 17ee31b89ac.library.html} +1 -1
  32. package/dist/17ee31b89ac.library.js +1 -0
  33. package/dist/{17e757ccadd.preview.html → 17ee31b89ac.preview.html} +1 -1
  34. package/dist/17ee31b89ac.preview.js +1 -0
  35. package/dist/17ee31b89ac.screenshoot.js +1 -0
  36. package/dist/213.js +19 -13
  37. package/dist/335.js +9 -6
  38. package/dist/362.js +1 -1
  39. package/dist/441.js +2 -2
  40. package/dist/605.js +15 -12
  41. package/dist/782.js +1 -1
  42. package/dist/HASH +1 -1
  43. package/dist/screenshoot.html +1 -1
  44. package/dist/screenshoot.js +372 -273
  45. package/package.json +12 -12
  46. package/src/bot.js +2 -1
  47. package/dist/17e757ccadd.132.js +0 -1
  48. package/dist/17e757ccadd.213.js +0 -1
  49. package/dist/17e757ccadd.335.js +0 -1
  50. package/dist/17e757ccadd.441.js +0 -1
  51. package/dist/17e757ccadd.605.js +0 -1
  52. package/dist/17e757ccadd.app.js +0 -1
  53. package/dist/17e757ccadd.library.js +0 -1
  54. package/dist/17e757ccadd.preview.js +0 -1
  55. package/dist/17e757ccadd.screenshoot.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.0.63",
3
+ "version": "4.0.64",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -14,27 +14,27 @@
14
14
  "@subiz/storage": "0.0.8",
15
15
  "@subiz/wsclient": "^3.1.7",
16
16
  "cookie_js": "1.4.2",
17
- "core-js": "^3.20.3",
18
- "css-loader": "^6.5.1",
17
+ "core-js": "^3.21.0",
18
+ "css-loader": "^6.6.0",
19
19
  "file-loader": "^6.2.0",
20
20
  "less": "^4.1.2",
21
21
  "less-loader": "^10.2.0",
22
- "marked": "^4.0.10",
23
- "preact": "^10.6.4"
22
+ "marked": "^4.0.12",
23
+ "preact": "^10.6.5"
24
24
  },
25
25
  "devDependencies": {
26
- "@babel/cli": "^7.16.8",
27
- "@babel/core": "^7.16.7",
26
+ "@babel/cli": "^7.17.0",
27
+ "@babel/core": "^7.17.0",
28
28
  "@babel/plugin-proposal-class-properties": "^7.16.7",
29
29
  "@babel/plugin-transform-react-jsx": "^7.16.7",
30
- "@babel/preset-env": "^7.16.8",
30
+ "@babel/preset-env": "^7.16.11",
31
31
  "babel-loader": "^8.2.3",
32
32
  "babel-plugin-syntax-jsx": "^6.18.0",
33
33
  "html-webpack-plugin": "^5.5.0",
34
- "puppeteer": "^13.0.1",
35
- "webpack": "^5.66.0",
34
+ "puppeteer": "^13.3.0",
35
+ "webpack": "^5.68.0",
36
36
  "webpack-bundle-analyzer": "^4.5.0",
37
- "webpack-cli": "^4.9.1",
38
- "webpack-dev-server": "^4.7.3"
37
+ "webpack-cli": "^4.9.2",
38
+ "webpack-dev-server": "^4.7.4"
39
39
  }
40
40
  }
package/src/bot.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import sb from './util/index.js'
2
+ import * as common from './common.js'
2
3
 
3
4
  export default function(store) {
4
5
  let botM = store.matchBot()
@@ -12,7 +13,7 @@ export default function(store) {
12
13
 
13
14
  let {error} = await store.startConvo({
14
15
  initial_by: bot.id,
15
- locale: sb.detectLang(),
16
+ locale: common.getLocale(bot, sb.detectLang()),
16
17
  state: 'active',
17
18
  members: [{type: 'bot', id: bot.id}],
18
19
  })
@@ -1 +0,0 @@
1
- (self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[132],{8132:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>vt});var i=s(819),r=s(2493),o=s(6400);class a extends r.up{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 h=s(4761);class l extends r.up{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()<p)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||h;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 l=this.renderMessagePreview(this.state.previewEvent,this.props.t("sent_you_a_message"));return 0===i.Z.size(l)&&(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"},l)),(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")||c,r=i.Z.get(t,"desktop_button.position")||"right",a=i.Z.get(t,"desktop_button.background_image_url"),h=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,h=o)}let l="chat-button--white-bg";!a&&h&&(l+=" chat-button--white-bg--mask-only");let p="";a=this.props.store.replaceFileUrl(a),e=this.props.store.replaceFileUrl(e),h=this.props.store.replaceFileUrl(h),a||h||(l+=" chat-button--white-bg--mask-only",p=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(d)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(d)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(d)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(d)}") !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&&h&&(p=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(h)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(h)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(h)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(h)}") !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&&!h&&(p=`\n\t\t\t\tbackground-image: url("${encodeURI(a)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n\t\t\t`),!a&&h&&(p=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(h)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(h)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(h)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(h)}") !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:l}),(0,o.h)("div",{class:"chat-button--img-container",style:p},(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=h,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 p=18e5,d="https://file-subiz.com/bubble_11.svg",c="linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)";var u=s(8430);class m extends r.up{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.up{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 h=this.props.tooltipPos||"bottom",l=this.props.mode||"primary";if(0===r.length)return(0,o.h)("div",{class:`group-avatar group-avatar--${l}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":n.name,"data-tooltip-position":h},(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 p=r[0],d="primary"===l?"group-avatar--agent-middle":"group-avatar--agent-left";return(0,o.h)("div",{class:`group-avatar group-avatar--${l}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":p.fullname||n.name,"data-tooltip-position":h},(0,o.h)("img",{width:35,height:35,class:`avatar ${d}`,alt:"agent avatar",src:this.props.store.replaceFileUrl(p.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--${l}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":t.fullname||n.name,"data-tooltip-position":h},(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":h},(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 c=r[0],u=r[1],m=r[2];return(0,o.h)("div",{class:`group-avatar group-avatar--${l}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":c.fullname||n.name,"data-tooltip-position":h},(0,o.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:this.props.store.replaceFileUrl(c.avatar_url)||s(4761)})),(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":u.fullname||n.name,"data-tooltip-position":h},(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":h},(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.up{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)),h="widget-header--inner widget-header--inner--collapsed";return t||(h+=" widget-header--inner--hidden"),(0,o.h)("div",{class:h},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)),h=i.Z.get(e,"tagline",{});var l=this.props.t.i18n(h)||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",p=i.Z.extractText(l).map((t=>"emoji"===t.type?(0,o.h)(a,{emojiCode:t.text}):t.text));let d="widget-header--inner widget-header--inner--expanded";return t||(d+=" widget-header--inner--hidden"),(0,o.h)("div",{class:d},(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"},p),(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 h="widget-header--inner widget-header--inner--expanded";return t||(h+=" widget-header--inner--hidden"),(0,o.h)("div",{class:h},(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 _ extends r.up{constructor(t){super(t),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()}onEnter=i.Z.throttle((function(){this.submitMessage()}),50);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 y extends r.up{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 b extends r.up{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.up{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 k extends r.up{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 Z extends r.up{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)(k,{store:this.props.store,buttons:t})}}class x extends r.up{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 h=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"},h)}}class S extends r.up{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 C extends r.up{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."+D(this.state.formData[s].name)]}else{var r=this.firstUnfilledField();if(!r)return;t=this["field."+D(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."+D(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."+D(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."+D(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."+D(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."+D(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)(S,{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."+D(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 D(t){return btoa(t).split("=").join("")}class M extends r.up{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)(C,{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 E extends r.up{constructor(t){super(t)}render(){return null}}function U(t){return t.touches&&t.touches.length?t.touches[0]:{}}class I extends r.up{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)(k,{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",h="generic-attachment-navigator generic-attachment-navigator--right";return 0===this.state.focusing&&(n+=" generic-attachment-navigator--disabled"),this.state.focusing===a.length-1&&(h+=" 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:h,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=U(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=U(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 R extends r.up{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,h=null,l=n.url||n.mobile_url;this.props.store.isMobile()&&(l=n.mobile_url||n.url),l&&(h=(0,o.h)("a",{class:"product_attachment__btn",href:l,target:"_blank"},this.props.t("detail"),(0,o.h)("img",{src:s(8453),class:"product_attachment__btn_external_link"})));let p=(0,o.h)("a",{href:l,class:"product_attachment__title",target:"_blank"},n.name),d=null,c=n.description||n.long_description;c&&(d=(0,o.h)("div",{class:"product_attachment__subtitle"},c));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)}))),p,d,u,(0,o.h)("div",{class:"product_attachment__btns"},h))}))}}class P extends r.up{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",alt:""+i.Z.get(e,"id"),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 h=(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)))),l=i.Z.get(e,"shipping.address",{}),p=[l.street,l.ward,l.district,l.region,l.country].filter((t=>t)).join(", "),d=i.Z.find(i.Z.get(e,"user.attributes",[]),(t=>"phones"===t.key))||{key:"phones",text:""},c=i.Z.get(e,"shipping.address.phone","").trim();c=c||i.Z.trim(d.text),c&&(c=this.props.t("phn")+": "+c);let u=null;return(p||c)&&(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"},p),(0,o.h)("div",{class:"order_attachment__text_truncate"},c))),(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,h)}))}}class j extends r.up{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 F extends r.up{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 L=[],A=(t,e)=>(L.push(t),"");(async()=>{let t=(await s.e(441).then(s.bind(s,7441))).marked;A=(e,s)=>t(s),i.Z.map(L,(t=>t.forceUpdate())),L=[]})();class $ extends r.up{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=>{if("emoji"===t.type)return(0,o.h)(a,{emojiCode:t.text,byType:e});if("link"===t.type){let e=t.text||"";return e.startsWith("//")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:")||(e="//"+e),(0,o.h)("a",{href:e,target:"_blank",onClick:t=>this.props.onLink(t,e)},t.text)}return"phone"===t.type?(0,o.h)("a",{href:"tel:"+t.text},t.text):"email"===t.type?(0,o.h)("a",{href:"mailto:"+t.text},t.text):t.text}));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)(F,{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)(F,{html:A(this,t)})))}}var z=new i.Z.Pubsub;setInterval((()=>z.publish("time")),2e4);class O extends r.up{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 h=Math.round(Math.abs(o));if(h<=r.r||!r.r){h<=1&&n>0&&(r=i[n-1]),a=s[r.l].replace("%d",h);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",{style:this.props.style},this.state.t)}}class T extends r.up{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)(O,{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 B extends r.up{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 h=n.logo_url||s(9895);let l=this.props.store.matchAgent("*");return"system"===r&&"dummy"===e||(h=i.Z.get(l[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(h)}),(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)(O,{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)($,{store:this.props.store,ev:t,onLink:this.props.onLink}),(0,o.h)(y,{store:this.props.store,ev:t}),(0,o.h)(b,{store:this.props.store,ev:t}),(0,o.h)(j,{store:this.props.store,ev:t}),(0,o.h)(w,{store:this.props.store,ev:t}),(0,o.h)(Z,{store:this.props.store,ev:t}),(0,o.h)(M,{store:this.props.store,onSubmit:this.props.onFormSubmit,ref:this.refForm,ev:t,t:this.props.t}),(0,o.h)(E,{store:this.props.store,ev:t,t:this.props.t}),(0,o.h)(I,{store:this.props.store,ev:t,onSelect:t=>this.choosePostbackBtn(t)}),(0,o.h)(R,{t:this.props.t,store:this.props.store,ev:t}),(0,o.h)(P,{t:this.props.t,store:this.props.store,ev:t}),(0,o.h)(x,{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)($,{store:this.props.store,ev:t,refresh:this.state.refresh,onLink:this.props.onLink}),(0,o.h)(y,{store:this.props.store,ev:t}),(0,o.h)(b,{store:this.props.store,ev:t}),(0,o.h)(j,{store:this.props.store,ev:t}),(0,o.h)(w,{store:this.props.store,ev:t}),(0,o.h)(Z,{store:this.props.store,ev:t}),(0,o.h)(M,{store:this.props.store,onSubmit:this.props.onFormSubmit,ref:this.refForm,ev:t}),(0,o.h)(R,{t:this.props.t,store:this.props.store,ev:t}),(0,o.h)(E,{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 q=s(6484);class V extends r.up{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 !important;height: ${i}px !important;`;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:q})):(0,o.h)("img",{alt:"loading",style:t,src:q})}return(0,o.h)("div",{class:"spinner1",style:r})}}const W=s(6188);class H extends r.up{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=>Y(t.ev)))).length<1)){for(var s=1;s<e.length;s++){let t=e[s],r=e[s-1];Y(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)(B,{onLink:this.props.onLink,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)(V,{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)(V,{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:W}),(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 Y(t){let e=i.Z.get(t,"type");return"message_sent"===e||"conversation_state_updated"===e}class G extends r.up{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"))}}const N=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,[h,l]=this.calcY(t,e,n);if(s(h),l)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)}};function J(t,e){return Math.abs(t-e)<=.001}class K extends r.up{constructor(t){super(t),this.refComment=(0,o.Vf)(),this.refRating=(0,o.Vf)(),this.refHandle=(0,o.Vf)()}state={hide:!0,ratingHeight:0,overlayOpacity:.3,comment:""};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 N({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)})}}}class Q extends r.up{state={show:!1,searchValue:""};filterRef=(0,o.Vf)();overlayRef=(0,o.Vf)();constructor(t){super(t),document.addEventListener("touchmove",(function(t){}))}onTouchMove=t=>{t.target===this.overlayRef.current&&(t.preventDefault(),t.stopPropagation())};hideDropdown=()=>{this.setState({show:!1,searchValue:""})};onKeydown=t=>{if("Escape"===t.key){if(!this.state.show)return;this.state.searchValue?this.setState({searchValue:""}):this.hideDropdown(),t.preventDefault(),t.stopPropagation()}};hasSearch=()=>!!this.props.has_search||i.Z.size(this.props.items)>=10;getFilteredOptions=()=>{let t=this.props.items;return this.state.searchValue&&this.hasSearch()&&(t=i.Z.filter(t,(t=>{let e=i.Z.unicodeToAscii(t.name).toLowerCase().replace(/ /g,""),s=i.Z.unicodeToAscii(t.desc).toLowerCase().replace(/ /g,""),r=i.Z.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g,"");return-1!=e.indexOf(r)||-1!=s.indexOf(r)}))),t};componentDidMount(){window.addEventListener("keydown",this.onKeydown)}componentWillUnmount(){window.removeEventListener("keydown",this.onKeydown)}onChangeSearchValue=t=>{this.setState({searchValue:t.target.value})};renderEmpty(){return(0,o.h)("div",{class:"dropdown_select_filter__empty"},(0,o.h)("img",{class:"dropdown_select_filter__empty_img",src:s(6071)}),(0,o.h)("div",{class:"muted",style:"text-align: center !important;"},"Không có kết quả"))}renderLoading(){return(0,o.h)("div",{class:"dropdown_select_filter__empty pt-3"},(0,o.h)(V,{size:"40",static:!0}),(0,o.h)("div",{class:"muted mt-2",style:"text-align: center !important;"},"Đang tải dữ liệu"))}toogleDropdown=async()=>{await this.setState({show:!0,searchValue:""}),this.focusFilter()};focusFilter(){this.filterRef.current&&(this.filterRef.current.focus(),setTimeout((()=>{this.filterRef.current&&this.filterRef.current.focus()}),100))}onSelect=t=>{this.props.onSelect(t),this.hideDropdown()};renderDropdown(){if(!this.state.show)return null;let t=this.getFilteredOptions(),e=i.Z.map(t,(t=>(0,o.h)("div",{class:"dropdown_select__item",onClick:e=>this.onSelect(t)},t.name))),r=null;if(this.hasSearch()){let t=(0,o.h)("img",{class:"dropdown_select_filter__icon",src:s(636)});this.props.loading&&(t=(0,o.h)("img",{class:"dropdown_select_filter__icon",src:s(5770)})),r=(0,o.h)("div",{class:"dropdown_select_filter"},t,(0,o.h)("input",{ref:this.filterRef,value:this.state.searchValue,onInput:this.onChangeSearchValue,type:"text",class:"dropdown_select_filter_input "}))}0==e.length&&(e=this.renderEmpty()),this.props.loading&&(e=this.renderLoading());let a=`width: ${this.props.width||"150px"} !important;`;return this.props.full?(a=" top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; ",(0,o.h)("div",{class:"dropdown_select__overlay",ref:this.overlayRef,onClick:this.hideDropdown,onTouchMove:this.onTouchMove},(0,o.h)("div",{class:"dropdown_select",style:a,onClick:t=>{t.preventDefault(),t.stopPropagation()}},r,(0,o.h)("div",{class:"dropdown_select__items"},e)))):(0,o.h)("div",{class:"dropdown_select",style:a},r,(0,o.h)("div",{class:"dropdown_select__items"},e))}onBackgroundScroll=t=>{console.log("EEEEEEE",t),alert("y")};render(){let t=(0,o.h)("div",{class:"muted text-truncate",style:"flex: 1 !important;"},"Chọn một phần tử");i.Z.get(this.props,"selected.name")&&(t=(0,o.h)("div",{class:"text-truncate",style:"flex: 1 !important;"},i.Z.get(this.props,"selected.name")));let e="position: relative !important;";return this.props.full&&(e=""),(0,o.h)("div",{style:e},(0,o.h)(r.u$,{onClickaway:this.hideDropdown},(0,o.h)("div",{type:"text",class:"dropdown_select_input "+this.props.extra_cls,onClick:this.toogleDropdown},t," ",(0,o.h)("img",{class:"dropdown_select__caret",src:s(8712)})),this.renderDropdown()))}}class X extends r.up{state={show:!1,searchValue:"",addresses:[]};filterRef=(0,o.Vf)();overlayRef=(0,o.Vf)();constructor(t){super(t),document.addEventListener("touchmove",(function(t){}))}onTouchMove=t=>{t.target===this.overlayRef.current&&(t.preventDefault(),t.stopPropagation())};hideDropdown=()=>{this.setState({show:!1,searchValue:""})};onKeydown=t=>{if("Escape"===t.key){if(!this.state.show)return;this.state.searchValue?this.setState({searchValue:""}):this.hideDropdown(),t.preventDefault(),t.stopPropagation()}t.key};doSearch=i.Z.throttle((async()=>{let t=Date.now();this.requestId=t;let e=await this.props.store.suggest_addresses(this.state.searchValue);this.requestId===t&&this.setState({addresses:i.Z.get(e,"body.addresses",[])})}),100);componentDidMount(){window.addEventListener("keydown",this.onKeydown)}componentWillUnmount(){window.removeEventListener("keydown",this.onKeydown)}onChangeSearchValue=t=>{this.setState({searchValue:t.target.value}),this.props.onChangeAddress(t.target.value),this.doSearch()};renderEmpty(){return(0,o.h)("div",{class:"dropdown_select_filter__empty"},(0,o.h)("img",{class:"dropdown_select_filter__empty_img",src:s(6071)}),(0,o.h)("div",{class:"muted",style:"text-align: center !important;"},"Không có kết quả"))}renderLoading(){return(0,o.h)("div",{class:"dropdown_select_filter__empty pt-3"},(0,o.h)(V,{size:"40",static:!0}),(0,o.h)("div",{class:"muted mt-2",style:"text-align: center !important;"},"Đang tải dữ liệu"))}toogleDropdown=async()=>{await this.setState({show:!0,searchValue:this.props.initAddress||""}),this.focusFilter()};focusFilter(){this.filterRef.current&&(this.filterRef.current.focus(),setTimeout((()=>{this.filterRef.current&&this.filterRef.current.focus()}),100))}onSelect=t=>{this.props.onSelect(t),this.hideDropdown()};renderDropdown(){if(!this.state.show)return null;let t=i.Z.map(this.state.addresses,((t,e)=>{let s=[((t.address||"")+" "+tt(t.street)).trim()].join(", "),i=[tt(t.ward),tt(t.district),tt(t.province)].join(", ");return(0,o.h)("div",{class:"dropdown_select__item",onClick:e=>this.onSelect(t),key:e},(0,o.h)("div",null,(0,o.h)("b",null,s)),(0,o.h)("div",{style:"opacity: 0.7 !important;"},i))})),e=null,r=(0,o.h)("img",{class:"dropdown_select_filter__icon",src:s(636)});this.props.loading&&(r=(0,o.h)("img",{class:"dropdown_select_filter__icon",src:s(5770)})),e=(0,o.h)("div",{class:"dropdown_select_filter"},r,(0,o.h)("input",{ref:this.filterRef,value:this.state.searchValue,onInput:this.onChangeSearchValue,type:"text",class:"dropdown_select_filter_input "})),0==t.length&&(t=this.renderEmpty()),this.props.loading&&(t=this.renderLoading());let a=`width: ${this.props.width||"150px"} !important;`;return this.props.full?(a=" top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; ",(0,o.h)("div",{class:"dropdown_select__overlay",ref:this.overlayRef,onClick:this.hideDropdown,onTouchMove:this.onTouchMove},(0,o.h)("div",{class:"dropdown_select",style:a,onClick:t=>{t.preventDefault(),t.stopPropagation()}},e,(0,o.h)("div",{class:"dropdown_select__items"},t)))):(0,o.h)("div",{class:"dropdown_select",style:a},e,(0,o.h)("div",{class:"dropdown_select__items"},t))}onBackgroundScroll=t=>{console.log("EEEEEEE",t)};render(){let t=(0,o.h)("div",{class:"text-truncate",style:"flex: 1 !important;"},this.props.initAddress),e="position: relative !important;";return this.props.full&&(e=""),(0,o.h)("div",{style:e},(0,o.h)(r.u$,{onClickaway:this.hideDropdown},(0,o.h)("div",{type:"text",class:"dropdown_select_input "+this.props.extra_cls,onClick:this.toogleDropdown},t),this.renderDropdown()))}}function tt(t){let e=(t+"").toLowerCase();return e.startsWith("tp ")?t.substr(3):e.startsWith("thanh pho ")?t.substr("thanh pho ".length):e.startsWith("thành phố ")?t.substr("thành phố ".length):e.startsWith("tỉnh ")?t.substr("tỉnh ".length):e.startsWith("huyện ")?t.substr("huyện ".length):e.startsWith("tỉnh ")?t.substr("tỉnh ".length):e.startsWith("xã ")?t.substr("xã ".length):e.startsWith("thị trấn ")?t.substr("thị trấn ".length):e.startsWith("thị xã ")?t.substr("thị xã ".length):e.startsWith("đường ")&&(t[7]<"0"||t[7]>"9")?t.substr("đường ".length):e.startsWith("phường ")&&(t[7]<"0"||t[7]>"9")?t.substr("phường ".length):e.startsWith("quận ")&&(t[7]<"0"||t[7]>"9")?t.substr("quận ".length):t}s.e(178).then(s.bind(s,178));var et=document.createElement("link");et.href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap",et.rel="stylesheet",document.head.append(et),i.Z.preloadWebfonts(["Roboto"],[400,500]),s(4761);class st extends r.up{render(){return"package"==this.props.name?this.props.active?(0,o.h)("img",{style:"width: 18px !important;",src:s(25)}):(0,o.h)("img",{style:"width: 18px !important;",src:s(1216)}):"shop"===this.props.name?this.props.active?(0,o.h)("img",{style:"width: 18px !important;",src:s(6180)}):(0,o.h)("img",{style:"width: 18px !important;",src:s(750)}):void 0}}var it=s(763),rt=s(2514);class ot extends r.up{state={loadProvince:!0,g_err:"",fullname:"",email:"",phone:"",loading:!0,order:{},err:{},selectedProvince:null,selectedDistrict:null,selectedWard:null,street:"",address:"",sending:!1,step:""};constructor(t){super(t),this.load()}async load(){if(!this.props.order_id)return;let t=await this.props.store.fetchOrder(this.props.order_id);this.setState({loading:!1}),t.error?this.setState({error:t.error}):this.setState({order:t.body}),this.props.store.matchUser();let e=i.Z.get(this.props.store.matchUser(),"attributes",[]),s=i.Z.get(i.Z.find(e,(t=>"fullname"===t.key)),"text"),r=i.Z.get(i.Z.find(e,(t=>"emails"===t.key)),"text"),o=i.Z.get(i.Z.find(e,(t=>"phones"===t.key)),"text");this.setState({fullname:s,email:r,phone:o}),await this.props.store.fetchShippingAddresses();let a=await this.props.store.list_provinces();this.setState({loadProvince:!1}),a.error||this.setState({provinces:i.Z.get(a,"body.addresses")})}isMobile(){return!!this.props.cid||!!this.props.isMobile||this.props.store.isMobile()}onChangeShippingAddress(t){this.setState({shipping_address:t,err:{},g_err:""})}renderMobileSuccess=t=>(0,o.h)("div",{class:"order",style:"height: 100% !important"},(0,o.h)("div",{style:"display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"},(0,o.h)("img",{style:"width: 60px !important; height: 60px !important;",width:"60",height:"60",src:it}),(0,o.h)("div",{style:"margin-top: 20px !important; margin-bottom: 10px !important"},(0,o.h)("b",{style:"font-size: 18px !important;"},"Đơn hàng của bạn đã được ghi nhận")),(0,o.h)("div",{class:"muted"},"Tôi sẽ liên hệ lại với bạn khi đơn hàng được xử lý"),(0,o.h)("div",{style:"flex:1 !important"}),(0,o.h)("div",{style:"margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"},(0,o.h)("div",{class:"order_btn order__btn__light",onClick:this.close},this.props.t("close")))));onChangeShipping(t){this.setState({shipping:t,err:{},g_err:""})}onSelectProvince=async t=>{this.setState({selectedProvince:t,err:{},g_err:""}),this.setState({loadDistrict:!0});let e=await this.props.store.list_districts({id:t.id});this.setState({loadDistrict:!1}),e.error||this.setState({districts:i.Z.get(e,"body.addresses")})};onSelectDistrict=async t=>{this.setState({selectedDistrict:t,err:{},g_err:""}),this.setState({loadWard:!0});let e=await this.props.store.list_wards({id:t.id});this.setState({loadWard:!1}),e.error||this.setState({wards:i.Z.get(e,"body.addresses")})};onSelectWard=t=>this.setState({selectedWard:t,err:{},g_err:""});onChangeFullname=t=>this.setState({fullname:t.target.value,err:{},g_err:""});onChangeAddress=t=>this.setState({address:t,err:{},g_err:""});onSelectAddress=t=>{t&&(this.setState({address:[i.Z.trim(t.address),i.Z.trim(t.street)].join(" ").trim(),street:t.street,err:{},g_err:""}),this.onSelectWard({id:t.ward_id,name:t.ward}),this.onSelectDistrict({id:t.district_id,name:t.district}),this.onSelectProvince({id:t.province_id,name:t.province}))};onChangeEmail=t=>this.setState({email:t.target.value,err:{},g_err:""});onChangePhone=t=>this.setState({phone:t.target.value,err:{},g_err:""});onChangePaymentMethod=t=>this.setState({pm:t});renderDesktopPaymentMethod(t){return null}renderDesktopShipping(t){let e=!1;if(t.status&&"new"!=t.status||(e=!t.user_confirmation),this.props.store.matchUser(),e){let t=this.props.store.matchShippingAddresses(),e=i.Z.map(this.state.provinces,(t=>({id:t.id,name:t.province}))),s=i.Z.map(this.state.districts,(t=>({id:t.id,name:t.district}))),r=i.Z.map(this.state.wards,(t=>({id:t.id,name:t.ward}))),a="ship_card",n=null,h=!1;if("ship"===this.state.shipping){h=!0;let l=i.Z.map(t,(t=>{let e=[t.street,t.ward,t.district,t.region,t.country].filter((t=>t)).join(", "),s=null;return t.phone&&(s=(0,o.h)(o.HY,null," · ",this.props.t("phn")," ",t.phone)),(0,o.h)("div",{style:"margin-bottom: 15px !important"},(0,o.h)("div",{class:"radio d-flex "},(0,o.h)("input",{type:"radio",id:"shipping_addr."+t.id,onInput:e=>this.onChangeShippingAddress(t.id),name:"shipping_address",checked:this.state.shipping_address===t.id}),(0,o.h)("label",{class:"radio--label",for:"shipping_addr."+t.id,style:`font-weight: ${this.state.shipping_address===t.id?500:400} !important`},t.fullname,s,(0,o.h)("div",{class:"mt-1 muted"},"DC ",e)),(0,o.h)("div",{class:"radio--check"},(0,o.h)("div",{class:"inside"}))))}));l.push((0,o.h)("div",{style:""},(0,o.h)("div",{class:"radio d-flex "},(0,o.h)("input",{type:"radio",id:"shipping_addr.new",onInput:t=>this.onChangeShippingAddress("new"),name:"shipping_address",checked:"new"===this.state.shipping_address}),(0,o.h)("label",{class:"radio--label",for:"shipping_addr.new"},"new"===this.state.shipping_address?(0,o.h)("b",null,"Tới địa chỉ khác"):"Tới địa chỉ khác"),(0,o.h)("div",{class:"radio--check"},(0,o.h)("div",{class:"inside"})))));let p=(0,o.h)("div",{style:"padding-left: 22px !important;"},(0,o.h)("div",{class:"d-flex"},(0,o.h)("div",{class:"mr-2",style:"flex: 1 !important;"},(0,o.h)("div",{class:"order_form_label"},this.props.t("fullname")),(0,o.h)("input",{type:"text",class:"form-control "+(this.state.err.name&&"err"),onInput:this.onChangeFullname,value:this.state.fullname})),(0,o.h)("div",{class:"ml-2",style:"flex: 1 !important;"},(0,o.h)("div",{class:"order_form_label"},this.props.t("phones")),(0,o.h)("input",{type:"text",class:"form-control "+(this.state.err.phone&&"err"),onInput:this.onChangePhone,value:this.state.phone}))),(0,o.h)("div",{class:"",style:"width: 100% !important"},(0,o.h)("div",{class:"order_form_label"},this.props.t("address")),(0,o.h)(X,{initAddress:this.state.address,store:this.props.store,width:"100%",onChangeAddress:this.onChangeAddress,full:this.isMobile(),onSelect:this.onSelectAddress,extra_cls:this.state.err.address&&"err"})),(0,o.h)("div",{class:"d-flex",style:"justify-content: space-between !important;"},(0,o.h)("div",{style:"flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"},(0,o.h)("div",{class:"order_form_label"},this.props.t("province")),(0,o.h)(Q,{width:"194",full:this.isMobile(),has_search:!0,loading:this.state.loadProvince,items:e,selected:this.state.selectedProvince,onSelect:this.onSelectProvince,extra_cls:this.state.err.province&&"err"})),(0,o.h)("div",{style:"flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"},(0,o.h)("div",{class:"order_form_label"},this.props.t("district")),(0,o.h)(Q,{width:"194",full:this.isMobile(),selected:this.state.selectedDistrict,has_search:!0,onSelect:this.onSelectDistrict,loading:this.state.loadDistrict,extra_cls:this.state.err.district&&"err",items:s}))),(0,o.h)("div",{class:"d-flex",style:"justify-content: space-between !important;"},(0,o.h)("div",{style:"flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"},(0,o.h)("div",{class:"order_form_label"},this.props.t("ward")),(0,o.h)(Q,{width:"194",selected:this.state.selectedWard,full:this.isMobile(),has_search:!0,onSelect:this.onSelectWard,extra_cls:this.state.err.ward&&"err",loading:this.state.loadWard,items:r})),(0,o.h)("div",{style:"flex: 1 !important; margin-left: 7px !important;"})));a+=" ship_card__active",0==i.Z.size(t)?n=(0,o.h)("div",null,(0,o.h)("div",{class:"mt-3 mb-2 "},this.props.t("input_shipping_info")),p):("new"!==this.state.shipping_address&&(p=null),n=(0,o.h)("div",null,(0,o.h)("div",{class:"mt-3 mb-2",style:"margin-bottom: 10px !important;"},"Vui lòng chọn địa chỉ giao hàng"),(0,o.h)("div",{class:"form"},l),p))}let l="ship_card",p=!1;"shop"===this.state.shipping&&(p=!0,l+=" ship_card__active",n=(0,o.h)("div",null,(0,o.h)("div",{class:"d-flex"},(0,o.h)("div",{class:"mr-2",style:"flex: 3 !important;"},(0,o.h)("div",{class:"order_form_label"},this.props.t("fullname")),(0,o.h)("input",{type:"text",class:"form-control "+(this.state.err.name&&"err"),onInput:this.onChangeFullname,value:this.state.fullname})),(0,o.h)("div",{class:"ml-2",style:"flex: 2 !important;"},(0,o.h)("div",{class:"order_form_label"},this.props.t("phones")),(0,o.h)("input",{type:"text",class:"form-control "+(this.state.err.phone&&"err"),onInput:this.onChangePhone,value:this.state.phone}))),(0,o.h)("div",null,(0,o.h)("div",{class:"order_form_label"},this.props.t("email")),(0,o.h)("input",{type:"text",class:"form-control "+(this.state.err.email&&"err"),onInput:this.onChangeEmail,value:this.state.email}))));let d="card_section";return this.isMobile()&&(d="order_section"),(0,o.h)(o.HY,null,(0,o.h)("div",{class:"order_section__line"}),(0,o.h)("div",{class:d},(0,o.h)("div",{class:"order_label"},this.props.t("ship_to")),(0,o.h)("div",{class:"d-flex"},(0,o.h)("div",{class:l+" mr-3",onClick:t=>this.onChangeShipping("shop")},(0,o.h)(st,{name:"shop",active:p})," ",(0,o.h)("b",{class:"ml-2"},"Nhận hàng tại shop")),(0,o.h)("div",{class:a,onClick:t=>this.onChangeShipping("ship")},(0,o.h)(st,{name:"package",active:h})," ",(0,o.h)("b",{class:"ml-2"},"Giao hàng cho tôi"))),n))}let s=i.Z.get(t,"shipping.address")||{},r=[s.address,s.ward,s.district,s.region,s.country].filter((t=>t)).join(", "),a=null;s.phone&&(a=(0,o.h)("div",{class:"mt-1 muted"},this.props.t("phn"),": ",s.phone)),i.Z.get(t,"shipping.pickup_at_shop")&&(r="Nhận hàng tại cửa hàng");let n=r?(0,o.h)("div",null,r):(0,o.h)("i",{class:"i muted"},"Chưa có địa chỉ giao hàng"),h="card_section";return this.isMobile()&&(h="order_section"),(0,o.h)("div",{class:h},(0,o.h)("div",{class:"order_label "},this.props.t("ship_to")),n,a)}renderDesktopSummary(t){let e=null;t.deposit>0&&(e=(0,o.h)("span",{class:"muted"},"(cọc ",i.Z.formatCurrency(t.deposit),")"));let r=null;t.total_discount>0&&(r=(0,o.h)("div",{class:"order_summary_line"},(0,o.h)("div",null,"Giảm giá"),(0,o.h)("div",null,i.Z.formatCurrency(t.total_discount))));let a=null;(e||t.payment_made)&&(a=(0,o.h)(o.HY,null,(0,o.h)("div",{class:"order_summary_line"},(0,o.h)("div",null,"Bạn đã trả"),(0,o.h)("div",null,e," ",i.Z.formatCurrency(t.payment_made))),(0,o.h)("div",{class:"order_summary_line"},(0,o.h)("div",null,"Bạn chưa trả"),(0,o.h)("div",null,i.Z.formatCurrency((t.total||0)-(t.payment_made||0))))));let n=(0,o.h)("div",{class:"order_summary_line"},(0,o.h)("div",null,"Tiền thuế"),(0,o.h)("div",null,i.Z.formatCurrency(t.total_tax))),h=(0,o.h)("div",{class:"order_summary_line"},(0,o.h)("div",null,"Phí vận chuyển"),(0,o.h)("div",null,i.Z.get(t,"shipping.fee",0)," d")),l=!1;t.status&&"new"!=t.status||(l=!t.user_confirmation);let p=null;l&&(h=null,n=null,p=(0,o.h)("div",{class:"muted"},(0,o.h)("img",{class:"order_ship_icon",src:s(9256)}),"  Chưa bao gồm thuế và phí vận chuyển"));let d="";return this.isMobile()&&(d="order_section"),(0,o.h)(o.HY,null,(0,o.h)("div",{class:"order_section__line"}),(0,o.h)("div",{class:d},(0,o.h)("div",{class:"order_label"},"Tóm tắt"),(0,o.h)("div",{class:"order_summary_line"},(0,o.h)("div",null,"Tổng tiền hàng"),(0,o.h)("div",null,i.Z.formatCurrency(t.subtotal))),n,r,h,p,(0,o.h)("div",{class:"order_summary_line",style:"margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"},(0,o.h)("div",null,"Bạn phải trả"),(0,o.h)("div",{class:"order__total"},i.Z.formatCurrency(t.total))),a))}renderStatusBadge(t){let e=t.status||"new";return(0,o.h)("div",{style:"float: right !important;",class:"order_status order_status__"+e},e)}renderShippingInfo(t){"new"!=t.status||t.user_confirmation;let e=i.Z.get(t,"shipping.shipping_provider");if(!e)return null;let r=i.Z.get(t,"shipping.shipping_code"),a=null;return r&&(a=(0,o.h)("div",{class:"muted",style:"margin-top: 3px !important"},"Vận đơn ",(0,o.h)("a",{class:"order_tracking_link",target:"_blank",href:"https://giaohangtietkiem.vn/tra-cuu-van-don/"+r},r," ",(0,o.h)("img",{class:"order_tracking_link_icon",src:s(8453)})))),"ghtk"==e?(0,o.h)("div",{class:"order_section"},(0,o.h)("div",{class:"order_section_label"},"Đơn vị vận chuyển"),(0,o.h)("div",{class:"d-flex align-items-center"},(0,o.h)("img",{class:"order_shipping_provider_logo",src:at.ghtk.logo}),(0,o.h)("div",null,at.ghtk.name,a))):null}renderDesktopShippingInfo(t){let e=i.Z.get(t,"shipping.shipping_provider");if(!e)return null;let r=i.Z.get(t,"shipping.shipping_code"),a=null;return r&&(a=(0,o.h)("div",{class:"muted",style:"margin-top: 3px !important"},"Vận đơn ",(0,o.h)("a",{class:"order_tracking_link",target:"_blank",href:"https://giaohangtietkiem.vn/tra-cuu-van-don/"+r},r," ",(0,o.h)("img",{class:"order_tracking_link_icon",src:s(8453)})))),"ghtk"==e?(0,o.h)(o.HY,null,(0,o.h)("div",{class:"order_label"},"Đơn vị vận chuyển"),(0,o.h)("div",{class:"d-flex align-items-center"},(0,o.h)("img",{class:"order_shipping_provider_logo",src:at.ghtk.logo}),(0,o.h)("div",null,at.ghtk.name,a))):null}renderProducts(t){let e=null;return e=i.Z.map(t.items,(t=>{if(!t||!t.product)return null;let e=t.product;return(0,o.h)("div",{class:"order_attachment__product"},(0,o.h)("img",{class:"order_attachment__product_img",alt:""+e.id,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))))})),this.isMobile()?(0,o.h)("div",{class:"order_section"},(0,o.h)("div",{class:"order_section_label"},this.props.t("product")),e):(0,o.h)("div",null,(0,o.h)("div",{class:"order_label"},this.props.t("product")),e)}onChangeQuantity=(t,e)=>{let s=parseInt(e)||1;t.quantity=s,this.forceUpdate()};renderDesktopProducts(t){let e=null,r=!1;return t.status&&"new"!=t.status||(r=!t.user_confirmation),e=r?i.Z.map(t.items,(t=>{if(!t||!t.product)return null;let e=t.product;return(0,o.h)("div",{class:"order_attachment__product"},(0,o.h)("img",{class:"order_attachment__product_img",alt:""+e.id,src:i.Z.get(e,"images.0")||s(9270)}),(0,o.h)("div",{style:"overflow: hidden !important; flex: 1 !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"},i.Z.formatCurrency(e.price))),(0,o.h)("input",{class:"form-control",style:"text-align: center !important; font-weight: 400 !important; width: 50px !important",value:t.quantity,onInput:e=>this.onChangeQuantity(t,e.target.value),type:"text"}),(0,o.h)("div",{style:"width: 80px !important; text-align: right !important; "},(0,o.h)("b",null,i.Z.formatCurrency(t.quantity*e.price))))})):i.Z.map(t.items,(t=>{if(!t||!t.product)return null;let e=t.product;return(0,o.h)("div",{class:"order_attachment__product"},(0,o.h)("img",{class:"order_attachment__product_img",alt:""+e.id,src:i.Z.get(e,"images.0")||s(9270)}),(0,o.h)("div",{style:"overflow: hidden !important; flex: 1 !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"},i.Z.formatCurrency(e.price))),(0,o.h)("div",{style:"text-align: center !important; font-weight: 400 !important; width: 50px !important"},t.quantity),(0,o.h)("div",{style:"width: 80px !important; text-align: right !important; "},(0,o.h)("b",null,i.Z.formatCurrency(t.total))))})),(0,o.h)("div",{class:"card_section"},(0,o.h)("div",{class:"desktop_order__heading"},this.renderStatusBadge(t),(0,o.h)("b",{style:"font-size: 18px !important;"},this.props.t("order")," #",t.order_number||t.id),(0,o.h)("div",{class:"muted"},(0,o.h)(O,{style:"font-size: 13px !important;",time:t.issue_date||t.created}))),(0,o.h)("div",{class:"order_label d-flex",style:"margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"},(0,o.h)("div",{style:"flex: 1 !important;"},this.props.t("product")),(0,o.h)("div",{style:"font-weight: 400 !important; text-align:center !important; width: 50px !important"},this.props.t("qty")),(0,o.h)("div",{style:"font-weight: 400 !important; text-align: right !important; width: 80px !important;"},this.props.t("total"))),e)}renderMobile(t){if("success"===this.state.step)return this.renderMobileSuccess(t);let e=null;this.state.g_err&&(e=(0,o.h)("div",{class:"mb-2 text__danger"},(0,o.h)("img",{style:"margin-top: -4px !important; height: 15px !important;",src:rt})," ",(0,o.h)("b",null,this.state.g_err)));let s=(0,o.h)("div",null,e,(0,o.h)("div",{class:"btn-confirm-order",style:"margin-top: 0 !important;",onClick:this.confirm},this.props.t("confirm_order"))),i=(0,o.h)("div",{class:"order_btn order__btn__light mt-3",onClick:this.onCancel},this.props.t("cancel_order"));return(t.user_confirmation||"new"!=t.status)&&(s=null,this.props.cid&&(i=(0,o.h)("div",{class:"order_btn order__btn__light mt-3",onClick:this.close},this.props.t("close")))),(0,o.h)("div",{class:"order",style:"height: 100% !important"},(0,o.h)("div",{class:"order--content"},(0,o.h)("div",{class:"order--heading"},this.renderStatusBadge(t),(0,o.h)("b",{style:"font-size: 16px !important;"},this.props.t("order")," #",t.order_number||t.id),(0,o.h)("div",{class:"muted"},(0,o.h)(O,{style:"font-size: 13px !important;",time:t.issue_date||t.created}))),this.renderProducts(t),this.renderDesktopShipping(t),this.renderShippingInfo(t),this.renderDesktopPaymentMethod(t),this.renderDesktopSummary(t),(0,o.h)("div",{class:"order_section pb-3",style:"padding-top: 0 !important;"},s,i)))}renderActions(t){let e=null,s=!1;if(t.status&&"new"!=t.status||(s=!t.user_confirmation),"success"===this.state.step)return(0,o.h)("div",{class:"d-flex",style:"align-items: center !important; justify-content: flex-end !important"},(0,o.h)("div",null,"Ghi nhận thành công")," ",(0,o.h)("img",{style:"width: 16px !important; height: 16px !important;",width:"16",height:"16",src:it}));if(s){let t=null;this.state.g_err&&(t=(0,o.h)("div",{class:"mb-2 text__danger"},(0,o.h)("img",{style:"margin-top: -4px !important; height: 15px !important;",src:rt})," ",(0,o.h)("b",null,this.state.g_err))),e=(0,o.h)("div",null,t,(0,o.h)("div",{class:"btn-confirm-order",onClick:this.confirm},this.props.t("confirm_order")),(0,o.h)("div",{class:"btn-cancel-order",onClick:this.onCancel},this.props.t("cancel_order")))}return e}renderDesktop(t){let e=this.props.store.matchAccount();var i=e.logo_url||s(9895);return(0,o.h)("div",{class:"desktop order"},(0,o.h)("div",{class:"order_acc_header"},(0,o.h)("img",{class:"order_acc_logo",src:i}),(0,o.h)("div",{class:"order_acc_name"},e.name)),(0,o.h)("div",{class:"desktop_order__content"},(0,o.h)("div",{style:"flex: 1 !important; padding-right: 20px !important;"},this.renderDesktopProducts(t),this.renderDesktopShipping(t),this.renderDesktopShippingInfo(t),this.renderDesktopPaymentMethod(t),(0,o.h)("div",{class:"order__footer"},(0,o.h)("a",{target:"_blank",href:"https://subiz.com.vn",class:"order__footer_link"},"Cung cấp bởi ",(0,o.h)("b",null,"Subiz")),(0,o.h)("div",{class:"order__footer_delimiter"}),(0,o.h)("a",{target:"_blank",href:"https://subiz.com.vn/vi/terms-of-service.html",class:"order__footer_link"},"Điều khoản"),(0,o.h)("a",{target:"_blank",href:"https://subiz.com.vn/vi/privacy-policy.html",class:"order__footer_link"},"Quyền riêng tư"))),(0,o.h)("div",null,(0,o.h)("div",{class:"order_recap"},this.renderDesktopSummary(t),this.renderActions(t)))))}render(){if(this.state.loading)return(0,o.h)("div",{class:"order_error"},(0,o.h)(V,{class:"mt-4",size:"60",static:!0}));if(this.state.error)return(0,o.h)("div",{class:"order_error"},(0,o.h)("img",{class:"mt-3",src:s(6825)}),(0,o.h)("div",{class:"mt-3"},this.props.t("order_load_error")));let t=this.state.order;return this.isMobile()?this.renderMobile(t):this.renderDesktop(t)}confirm=async()=>{this.setState({g_err:""});let t={};if(this.state.shipping||this.setState({g_err:"Mời bạn chọn địa chỉ giao hàng trước khi xác nhận"}),"shop"===this.state.shipping?(i.Z.isPhone(this.state.phone)||(t.phone=!0),i.Z.trim(this.state.fullname)||(t.name=!0),i.Z.trim(this.state.email)||(t.email=!0)):"new"==this.state.shipping_address&&(i.Z.isPhone(this.state.phone)||(t.phone=!0),i.Z.trim(this.state.fullname)||(t.name=!0),i.Z.trim(this.state.address)||(t.address=!0),0==i.Z.size(this.state.selectedWard)&&(t.ward=!0),0==i.Z.size(this.state.selectedDistrict)&&(t.district=!0),0==i.Z.size(this.state.selectedProvince)&&(t.province=!0)),i.Z.size(t)>0)return void this.setState({err:t,g_err:this.props.t("input_shipping_info_err")});let e=this.props.store.matchUser(),s=i.Z.getUserAttr(e,"fullname","text"),r=i.Z.getUserAttr(e,"emails","text"),o=i.Z.getUserAttr(e,"phones","text"),a=i.Z.cloneDeep(this.state.order);if("shop"===this.state.shipping)i.Z.set(a,"shipping.pickup_at_shop",!0),i.Z.set(a,"shipping.address.phone",this.state.phone),i.Z.set(a,"shipping.address.fullname",this.state.fullname),i.Z.set(a,"shipping.address.email",this.state.email);else if("new"==this.state.shipping_address){let t=await this.props.store.createShippingAddress({address:this.state.address,country:"Việt Nam",fullname:this.state.fullname,email:this.state.email,phone:this.state.phone,district:this.state.selectedDistrict.name,district_id:this.state.selectedDistrict.id,province:this.state.selectedProvince.name,province_id:this.state.selectedProvince.id,ward:this.state.selectedWard.name,street:this.state.street,ward_id:this.state.selectedWard.id});if(t.error)return this.setState({g_err:this.props.t("update_failed")});i.Z.set(a,"shipping.address",t.body)}else{let e=this.props.store.matchShippingAddresses(),s=i.Z.find(e,(t=>t.id===this.state.shipping_address));if(!s)return this.setState({err:t,g_err:this.props.t("input_shipping_info_err")});i.Z.set(a,"shipping.address",s)}let n=!1;!s&&this.state.fullname&&(n=!0,i.Z.setUserAttr(e,{key:"fullname",text:this.state.fullname})),!r&&this.state.email&&(n=!0,i.Z.setUserAttr(e,{key:"emails",text:this.state.email})),!o&&this.state.phone&&(n=!0,i.Z.setUserAttr(e,{key:"phones",text:this.state.phone})),n&&this.props.store.setUser(e),this.setState({sending:!0}),a.user_confirmation="confirmed";let h=await this.props.store.updateOrder(a);if(this.setState({sending:!1}),h.error)return this.setState({g_err:this.props.t("update_failed")});this.setState({step:"success"}),this.props.onResponse&&this.props.onResponse("confirmed")};onCancel=()=>{this.props.onResponse&&this.props.onResponse("rejected"),this.close()};close=()=>{if(this.props.cid&&!this.state.order.user_confirmation){let t=i.Z.cloneDeep(this.state.order);t.user_confirmation="rejected",this.props.store.updateOrder(t)}this.props.onClose&&this.props.onClose()}}let at={ghtk:{name:"Giao hàng tiết kiệm",logo:s(6890)},ghn:{name:"Giao hàng nhanh",logo:s(1473)}};s(4761);class nt extends r.up{constructor(t){super(t),this.refRating=(0,o.Vf)(),this.refHandle=(0,o.Vf)()}state={hide:!0,ratingHeight:0,overlayOpacity:.3};componentDidMount(){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 N({maxY:400,minY:0,duration:150}),this.close()}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(){this._show!=this.props.show&&(this._show=this.props.show,setTimeout((()=>{this._show?this.open():this.close()})));let t=this.state.hide?"d-none":"";return(0,o.h)("div",{class:t},(0,o.h)("div",{class:"extension--overlay",style:`opacity: ${.5*this.state.overlayOpacity} !important;`}),(0,o.h)("div",{class:"extension",ref:this.refRating,style:`height: ${this.state.ratingHeight}px !important;`},(0,o.h)("div",{class:"extension--close-btn",onClick:this.close},this.props.t("close")),(0,o.h)("div",{class:"extension--handle",ref:this.refHandle},(0,o.h)("div",{class:"extension--thumb"})),(0,o.h)("div",{style:"overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"},(0,o.h)(ot,{key:this.props.order_id,store:this.props.store,onResponse:this.onResponse,onClose:this.close,t:this.props.t,order_id:this.props.order_id,cid:this.props.cid}))))}onResponse=t=>{this.setState({response:t})};open(){if(this.state.hide&&this.props.order_id&&(this.setState({hide:!1}),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)})}))}}confirm=()=>{this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{format:"plaintext",text:"confirm",attachments:[{type:"postback",postback:{payload:JSON.stringify({type:"order_confirmation",status:"confirmed"})}}]}})};close=async()=>{if(await i.Z.sleep(100),"confirmed"===this.state.response?this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{format:"plaintext",text:this.props.t("confirm_order"),attachments:[{type:"postback",postback:{payload:JSON.stringify({type:"order_confirmation",status:"confirmed"})}}]}}):"rejected"===this.state.response&&this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{format:"plaintext",text:this.props.t("cancel_order"),attachments:[{type:"postback",postback:{payload:JSON.stringify({type:"order_confirmation",status:"cancelled"})}}]}}),this.setState({response:""}),!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}))})),this.props.onClose()}};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 ht=s(9737),lt=s(8909),pt=s(29);const dt="https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png";class ct extends r.up{constructor(t){super(t),this.userSent={},this.setState({creating:!1,clickedJoin:!1,formData:{},showOrder:!1,order_id:""}),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.closeOrder(),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(){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 h=null;h="list"===this.props.view?this.renderConvoList():e?this.renderForm(t,a):this.renderChat();let l=i.Z.get(s,"desktop_button.position")||"right";this.props.store.isMobile()&&(l=i.Z.get(s,"mobile_button.position",l));let p="widget-container widget-container--"+l;return this.props.isShow||(p+=" widget-container--hide"),(0,o.h)("div",{class:p},(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"})}),h)}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"},h={group_id:a,message:o,locale:this.props.t.locale(),initial_by:r.id};this.setState({creatingError:null});const{error:l,convo:p}=await this.props.store.startConvo(h);if(this.props.store.setUser(r),l)return void this.setState({creating:!1,creatingError:l});let d=p.id;this.userSent[d]=!0,this.props.onGo({view:"chat",cid:d}),this.props.store.sendConvoEvent(d,"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_"+mt(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_"+mt(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_"+mt(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"+mt(e),onInput:t=>this.onBooleanChange(e,t),checked:t.value}),(0,o.h)("label",{class:"checkbox--label",for:"form-checkbox"+mt(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"+mt(e)+mt(s.value),checked:t.value===s.value,onInput:t=>this.onInputChange(e,s.value)}),(0,o.h)("label",{class:"radio--label",for:"form-radio"+mt(e)+mt(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)(S,{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)(V,{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)(ut,{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:pt}),(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:ht,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_"+mt(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)(_,{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,onLink:this.onLink,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)(K,{forceView:this.props.view,plugin:this.props.plugin,store:this.props.store,onRate:t=>this.onRate(t),cid:this.props.cid,t:this.props.t}),(0,o.h)(nt,{forceView:this.props.view,plugin:this.props.plugin,show:this.state.showOrder,order_id:this.state.order_id,store:this.props.store,onClose:this.closeOrder,cid:this.props.cid,t:this.props.t}),t)}onLink=(t,e)=>{if(!e)return t.preventDefault();let s=e.replace(/(^\w+:|^)\/\//,"");if(s.startsWith("widget.subiz.com.vn/orders/")){let e=s.substr("widget.subiz.com.vn/orders/".length);return e=e.split("/")[0],this.setState({showOrder:!0,order_id:e}),void t.preventDefault()}};closeOrder=t=>{this.setState({showOrder:!1,order_id:""}),this.focusInput()};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:dt,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 h=null;"user"===t.lastSenderType&&(h=(0,o.h)("span",{class:"yourmessage"},this.props.t("you"),":"));let l=i.Z.isConvoSeen(t,this.props.store.matchUser().id);var p=this.renderMessagePreview(t.last_message_sent||{data:{message:i.Z.get(t,"last_message")}}),d=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),c=(0,o.h)(O,{ago:!0,time:d,key:d,short:!0});let u=l?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:lt,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"},c)),(0,o.h)("div",{class:"d-flex flex-row"},(0,o.h)("div",{class:"convo-list--convo-last-message"},h,p),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:dt,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 ut extends r.up{componentDidMount(){this.props.onMount(this.props.form)}}function mt(t){return encodeURIComponent(t)}let gt=s.e(178).then(s.bind(s,178));class vt extends r.up{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 gt).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 ft(),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)(l,{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)(ct,{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(){ft(),this.props.store.setIsOpen(!1),this.setState({isShowWidget:!1})}onWidgetClose(){this.refButton.current&&this.refButton.current.ClearPreview(),this.props.store.setHasManuallyClosed(),this.hideWidget()}}function ft(){let t=document.getElementById("subiz-meta-viewport");t&&t.remove()}},6755:(t,e,s)=>{t.exports=s.p+"assets/img/bubble_default.7d5e4ab.svg"},8712:(t,e,s)=>{t.exports=s.p+"assets/img/caret.998eb8f.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"},763:(t,e,s)=>{t.exports=s.p+"assets/img/done_green.b817fd4.svg"},29:(t,e,s)=>{t.exports=s.p+"assets/img/empty.29bed2d.svg"},6825:(t,e,s)=>{t.exports=s.p+"assets/img/empty_1.0b98af0.svg"},8453:(t,e,s)=>{t.exports=s.p+"assets/img/external-link.90577cc.svg"},1473:(t,e,s)=>{t.exports=s.p+"assets/img/ghn.070f8e3.svg"},6890:(t,e,s)=>{t.exports=s.p+"assets/img/ghtk.326eac1.svg"},9895:(t,e,s)=>{t.exports=s.p+"assets/img/image_default.be0698b.png"},9256:(t,e,s)=>{t.exports=s.p+"assets/img/info.ebce7ea.svg"},5770:(t,e,s)=>{t.exports=s.p+"assets/img/loader.37000a7.svg"},6484:(t,e,s)=>{t.exports=s.p+"assets/img/loading_static.8f403ae.svg"},6071:(t,e,s)=>{t.exports=s.p+"assets/img/not_found_search.2ddb8d1.png"},25:(t,e,s)=>{t.exports=s.p+"assets/img/package.8d37d0f.svg"},1216:(t,e,s)=>{t.exports=s.p+"assets/img/package_fade.763c001.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"},636:(t,e,s)=>{t.exports=s.p+"assets/img/search.f9705ff.svg"},9737:(t,e,s)=>{t.exports=s.p+"assets/img/send.6db52a9.svg"},6180:(t,e,s)=>{t.exports=s.p+"assets/img/shop.f7dc7d8.svg"},750:(t,e,s)=>{t.exports=s.p+"assets/img/shop_faded.df7845a.svg"},8430:(t,e,s)=>{t.exports=s.p+"assets/img/subiz-mono.877e9f5.svg"},2514:(t,e,s)=>{t.exports=s.p+"assets/img/x.26fdfa3.svg"}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[213],{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: '+Ut(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: '+Ut(n);if(!n[t][e])throw"Can't get extension with name \""+e+'", "'+e+'" is not available. The following extensions are available: '+Ut(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){Rt(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=Nt(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"),N=new RegExp("shadow"),P=new RegExp("^(follow-gradient|horizontal-gradient|vertical-gradient)"),R=new RegExp("^[.0-9]+(?:ms|s){1}$"),T=new RegExp("^transition-?(?:in|out)?$"),M=new RegExp("^url\\("),B=function(t){return t?parseFloat(t)*(/ms$/.test(t)?1:1e3):0},U=function(t){return t.match(/[a-z]+(?:\(.*?\))?\s?(?:origin\(.*?\))?\s?(?:[a-z]+\(.*?\))?[ .a-z-0-9]*/g).map(V)},V=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){R.test(t)?void 0===o?o=B(t):s=B(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}},$=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(q)}},W=/\s([\d]{1,3})%?$/,q=function(t){var e=t.match(W);return{offset:e?parseFloat(e[1])/100:null,value:L(t.replace(W,""))}},L="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):M.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,$):F(t,L):N.test(e)?F(t,H):T.test(e)?"none"===t?t:F(t,U):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},Nt=function(t){return t.slice()},Pt=function(){return window.performance.now()},Rt=function(t,e){return Tt(t)?Mt(t,e):Array.isArray(t)?Bt(t,e):t===e},Tt=function(t){return t===Object(t)},Mt=function(t,e){for(var n in t)if(!e.hasOwnProperty(n)||t[n]!==e[n])return!1;return!0},Bt=function(t,e){return t.length==e.length&&t.every((function(t,n){return t===e[n]}))},Ut=function(t){return Object.keys(t).map((function(t){return'"'+t+'"'})).join(", ")},Vt=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}(),$t=[],Wt={value:jt,didInit:It,didUpdate:It,didDestroy:It,willDestroy:It},qt=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},Lt=function(t){var e=$t.filter((function(e){return e.isRootElement(t)}));return e?e[0]:null},Ht=function(){return _({},Vt.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||!Lt(t)){e&&e.view&&(e.view=ft([e.view])[0]),!e&&t&&(e=qt(t,Wt,Ht())),t&&(e||(e={}),e.view||(e.view=dt([t])[0]));var n=new Vt(e,t);return $t.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}($t,t);return!(e<0||($t[e].destroy(),$t.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:Lt},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.up{state={flipKey:"43"};constructor(t){super(t),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.up{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.up{state={close:!1,cssready:!1,closeAnimation:!0,pressedSubmit:!1,imageReady:!1,fontReady:!1};constructor(t){super(t),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!0;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=this._formRef.current?new FormData(this._formRef.current):new FormData,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"}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[335],{2335:(t,e,s)=>{s.r(e),s.d(e,{default:()=>l,replaceCssVariable:()=>r,DEFVAL:()=>p});var a=s(819),i=s(6400),o=s(2493);let n=s.e(678).then(s.bind(s,2678));class l extends o.up{state={map:!1,map_loading:!1,map_initialized:!1};constructor(t){super(t),this.showMap=this.showMap.bind(this),this.hideMap=this.hideMap.bind(this)}async initMap(){this.map_initialized||(this.setState({map_initialized:!0,map_loading:!0}),await new Loader({apiKey:"YOUR_API_KEY",version:"weekly"}).load(),this.gmap=new google.maps.Map(document.getElementById("map")),this.setState({map_loading:!1}))}js2css(t,e){return a.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,"@primary_color":this.props.plugin.popup.primary_color,"@background":this.props.plugin.popup.background,"@spacer0":spacer/2+"px","@spacer":spacer+"px","@spacer2":2*spacer+"px","@spacer3":3*spacer+"px"})}renderMapButton(t){let e=(0,i.h)("svg",{width:"20px","aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"map-marker-alt",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",class:"svg-inline--fa fa-map-marker-alt fa-w-12 fa-3x"},(0,i.h)("path",{fill:"red",d:"M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z",class:""}));return(0,i.h)("div",{class:"contact_button",onClick:this.showMap},this.renderMapModal(t),e)}async setMap(t,e){console.log("HEE"),await this.initMap(),console.log("HEE22"),window.gmap=this.gmap,this.gmap.map.setCenter(new google.maps.LatLng(t,e))}renderMapModal(t){let e="map_modal";this.state.map?e+=" map_modal__show":e+=" map_modal__hide";let s="overlay";this.state.map||(s+=" overlay__hidden");let o=a.Z.map(t.map.locations,(t=>(0,i.h)("div",{class:"map_location",onClick:e=>this.setMap(t.latitude,t.longitude)},(0,i.h)("div",null,t.name),(0,i.h)("div",null,t.latitude),(0,i.h)("div",null,t.longitude))));o.unshift((0,i.h)("div",{class:"map_title"},t.map.title));let n=(0,i.h)("div",{id:"map",style:"height: 100%; width: 100%"}," ");return(0,i.h)("div",{class:s,onClick:this.hideMap},(0,i.h)("div",{class:e,onClick:t=>t.stopPropagation()},(0,i.h)("div",{class:"map_body"},(0,i.h)("div",{class:"map_locations"},o),n,(0,i.h)("div",{class:"mapouter"},(0,i.h)("div",{class:"gmap_canvas"},(0,i.h)("iframe",{width:"300",height:"400",id:"gmap_canvas",src:"https://maps.google.com/maps?q=2880%20Broadway,%20New%20York&t=&z=13&ie=UTF8&iwloc=&output=embed",frameborder:"0",scrolling:"no",marginheight:"0",marginwidth:"0"}))))))}hideMap(t){t.stopPropagation(),this.setState({map:!1})}showMap(){this.setState({map:!0})}renderZaloButton(t){let e=(0,i.h)("svg",{width:"20px ","aria-hidden":"true",focusable:"false","data-prefix":"fab","data-icon":"facebook-f",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",class:"svg-inline--fa fa-facebook-f fa-w-10 fa-5x"},(0,i.h)("path",{fill:"currentColor",d:"M279.14 288l14.22-92.66h-88.91v-60.13c0-25.35 12.42-50.06 52.24-50.06h40.42V6.26S260.43 0 225.36 0c-73.22 0-121.08 44.38-121.08 124.72v70.62H22.89V288h81.39v224h100.17V288z",class:""}));return(0,i.h)("div",{class:"contact_button"},e)}renderFacebookButton(t){let e=(0,i.h)("svg",{width:"20px ","aria-hidden":"true",focusable:"false","data-prefix":"fab","data-icon":"facebook-f",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",class:"svg-inline--fa fa-facebook-f fa-w-10 fa-5x"},(0,i.h)("path",{fill:"currentColor",d:"M279.14 288l14.22-92.66h-88.91v-60.13c0-25.35 12.42-50.06 52.24-50.06h40.42V6.26S260.43 0 225.36 0c-73.22 0-121.08 44.38-121.08 124.72v70.62H22.89V288h81.39v224h100.17V288z",class:""}));return(0,i.h)("div",{class:"contact_button"},e)}renderChatButton(){return(0,i.h)("div",null,"Chat")}renderCallButton(){let t=(0,i.h)("svg",{width:"20px","aria-hidden":"true",focusable:"false","data-prefix":"fas","data-icon":"phone",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",class:"svg-inline--fa fa-phone fa-w-16 fa-7x"},(0,i.h)("path",{fill:"currentColor",d:"M493.4 24.6l-104-24c-11.3-2.6-22.9 3.3-27.5 13.9l-48 112c-4.2 9.8-1.4 21.3 6.9 28l60.6 49.6c-36 76.7-98.9 140.5-177.2 177.2l-49.6-60.6c-6.8-8.3-18.2-11.1-28-6.9l-112 48C3.9 366.5-2 378.1.6 389.4l24 104C27.1 504.2 36.7 512 48 512c256.1 0 464-207.5 464-464 0-11.2-7.7-20.9-18.6-23.4z",class:""}));return(0,i.h)("div",null,t)}renderButtons(t){return 0===a.Z.size(t)?null:a.Z.map(t,(t=>"map"===t.type?this.renderMapButton(t):"zalo"===t.type?this.renderZaloButton(t):"facebook"===t.type?this.renderFacebookButton(t):"call"===t.type?this.renderCallButton(t):"chat"===t.type?this.renderChatButton(t):null))}renderByLayoutSideByStandard(){let t=this.renderButtons(this.props.plugin.contact.buttons);return(0,i.h)("div",null,t)}renderLineComponent(t){let e=Object.assign({},t.style,this.props.mobile?t.mobile_style:{});return(0,i.h)("div",{style:this.js2css(e)})}renderTextComponent(t){let e=Object.assign({},t.style,this.props.mobile?t.mobile_style:{});return(0,i.h)("div",{class:"text",style:this.js2css(e),dangerouslySetInnerHTML:{__html:a.Z.get(t,"text.html")}})}async refreshCSS(){var t=r((await n).default.default.toString(),this.props.plugin.popup);a.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,t),this.setState({cssready:!0})}componentDidMount(){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.refreshCSS();let t=JSON.stringify(this.props.plugin);this.setState({pluginjson:t})}render(){if(!this.state.cssready)return null;let t=JSON.stringify(this.props.plugin);if(this.state.pluginjson!==t&&(this.refreshCSS(),setTimeout((()=>this.setState({pluginjson:t})))),this.state.close)return null;let e,s,o,n,l,r=a.Z.get(this.props.plugin,"contact.layout","standard"),p=null;"standard"!==r&&r||(p=this.renderByLayoutSideByStandard()),"footer"===r&&(p=this.renderByLayoutFooter(a.Z.get(this.props.plugin,`popup.pages.${this.state.pageIndex}`))),"mini"===r&&(p=this.renderByLayoutMini(a.Z.get(this.props.plugin,`popup.pages.${this.state.pageIndex}`))),"docked"===r&&(p=this.renderByLayoutDocked(a.Z.get(this.props.plugin,`popup.pages.${this.state.pageIndex}`)));let h=a.Z.get(this.props.plugin,"contact.position","bottom-left");return"center-left"===h?(e="0",n="50%",l="translateY(-50%)"):"top-left"===h?(e="0",n="20px"):"bottom-right"===h?(s="0",o="20px"):"center-right"===h?(s="0",n="50%",l="translateY(-50%)"):"top-right"===h?(s="0",n="20px"):(e="0",o="20px"),(0,i.h)("div",{style:a.Z.js2css({position:"absolute",left:e,right:s,bottom:o,top:n,transform:l,display:"flex",align_items:"center",justify_content:"center",overflow:"hidden"}),onClick:t=>t.stopPropagation()},p)}}function r(t,e){var s=[t];s=a.Z.tokenize(s,"'@font_family'"),s=a.Z.tokenize(s,"'@font_size'"),s=a.Z.tokenize(s,"'@text_color'"),s=a.Z.tokenize(s,"'@primary_color'"),s=a.Z.tokenize(s,"'@background'"),s=a.Z.tokenize(s,"'@spacer'"),s=a.Z.tokenize(s,"'@spacer0'"),s=a.Z.tokenize(s,"'@spacer2'"),s=a.Z.tokenize(s,"'@spacer3'");for(var i=[],o=0;o<s.length;o++){var n=s[o];if("string"!=typeof n){var l=n.type.substr(2,n.type.length-3),r=a.Z.get(e,l)||a.Z.get(p,l)||"";i.push(r)}else i.push(n)}return i.join("")}const p={font_size:"16px",font_family:"roboto",text_color:"#333",primary_color:"#333"}}}]);