@subiz/widget-v4 4.1.43 → 4.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled_src/chatbox/PoweredBy.js +1 -1
- package/compiled_src/chatbox/TextMessage.js +0 -56
- package/dist/18b1ceaf2e0.841.js +1 -0
- package/dist/18b1ceaf2e0.app.js +1 -0
- package/dist/{18afb30d167.index.html → 18b1ceaf2e0.index.html} +1 -1
- package/dist/{18afb30d167.library.html → 18b1ceaf2e0.library.html} +1 -1
- package/dist/18b1ceaf2e0.library.js +1 -0
- package/dist/{18afb30d167.preview.html → 18b1ceaf2e0.preview.html} +1 -1
- package/dist/18b1ceaf2e0.preview.js +1 -0
- package/dist/18b1ceaf2e0.screenshoot.js +1 -0
- package/dist/18b1ceaf2e0.webview.js +1 -0
- package/dist/{132.js → 841.js} +3 -93
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +2 -4
- package/package.json +1 -2
- package/src/chatbox/PoweredBy.js +3 -1
- package/src/chatbox/TextMessage.js +0 -68
- package/dist/18afb30d167.132.js +0 -1
- package/dist/18afb30d167.441.js +0 -1
- package/dist/18afb30d167.app.js +0 -1
- package/dist/18afb30d167.library.js +0 -1
- package/dist/18afb30d167.preview.js +0 -1
- package/dist/18afb30d167.screenshoot.js +0 -1
- package/dist/18afb30d167.webview.js +0 -1
- package/dist/441.js +0 -2420
- /package/dist/{18afb30d167.178.js → 18b1ceaf2e0.178.js} +0 -0
- /package/dist/{18afb30d167.213.js → 18b1ceaf2e0.213.js} +0 -0
- /package/dist/{18afb30d167.335.js → 18b1ceaf2e0.335.js} +0 -0
- /package/dist/{18afb30d167.362.js → 18b1ceaf2e0.362.js} +0 -0
- /package/dist/{18afb30d167.605.js → 18b1ceaf2e0.605.js} +0 -0
- /package/dist/{18afb30d167.678.js → 18b1ceaf2e0.678.js} +0 -0
- /package/dist/{18afb30d167.782.js → 18b1ceaf2e0.782.js} +0 -0
package/dist/18afb30d167.132.js
DELETED
|
@@ -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:()=>Zt});var i=s(4494),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 l=s(4761);class h 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",{});(this.props.t.i18n(i.Z.get(e,"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,r=i.Z.get(this.state.previewEvent,"by.display_id",i.Z.get(this.state.previewEvent,"by.id")),a=i.Z.cloneDeep(this.props.store.matchAgent(r))||{};a.fullname=a.fullname||i.Z.get(t,"name")||this.props.t("agent"),a.avatar_url=a.avatar_url||l;let n=i.Z.get(e,"desktop_button.position")||"right";this.props.store.isMobile()&&(n=i.Z.get(e,"mobile_button.position")||n),e&&e.hide_agent_profile&&(a=Object.assign({},t,{avatar_url:t.logo_url||s(9895),fullname:t.name||this.props.t("agent")}));let h="widget-preview widget-preview--"+n;this.state.displayPreview||(h+=" widget-preview--hidden");var p=this.renderMessagePreview(this.state.previewEvent,this.props.t("sent_you_a_message"));return 0===i.Z.size(p)&&(h+=" widget-preview--hidden"),(0,o.h)("div",{class:h},(0,o.h)("div",{class:"widget-preview--body"},(0,o.h)("img",{alt:"widget avatar",class:"widget-preview--avatar",src:this.props.store.replaceFileUrl(a.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"},a.fullname),(0,o.h)("p",{class:"widget-preview--message"},p)),(0,o.h)("div",{class:"widget-preview--btn-close",onClick:t=>this.closePreview(t)})),(0,o.h)("div",{class:"widget-preview--action",onClick:t=>this.onPreviewClick(t)},(0,o.h)("div",{class:"widget-preview--action-text"},this.props.t("chat_now"))))}onProfileReady(){this._buttonLoaded&&this.setState({opacity:1}),this._profileLoaded=!0}onButtonReady(){this._profileLoaded&&this.setState({opacity:1}),this._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"),l=i.Z.get(t,"desktop_button.background_mask_url");if(this.props.store.isMobile()){e=i.Z.get(t,"mobile_button.background_image_url")||i.Z.get(t,"mobile_button.background_mask_url")||e,r=i.Z.get(t,"mobile_button.position")||r;let s=i.Z.get(t,"mobile_button.background_image_url"),o=i.Z.get(t,"mobile_button.background_mask_url");(s||o)&&(a=s,l=o)}let h="chat-button--white-bg";!a&&l&&(h+=" chat-button--white-bg--mask-only");let p="";a=this.props.store.replaceFileUrl(a),e=this.props.store.replaceFileUrl(e),l=this.props.store.replaceFileUrl(l),a||l||(h+=" 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 mask-size: cover !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`),a&&l&&(p=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(l)}") !important;\n\t\t\t\tbackground-image: url("${encodeURI(a)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`),a&&!l&&(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&&l&&(p=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(l)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(l)}") !important;\n\t\t\t\theight: 70px !important;\n\t\t\t\twidth: 70px !important;\n\t\t\t\tbackground: ${s} !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`);let u="chat-button chat-button--"+r;return(0,o.h)("div",{class:u,onClick:t=>this.onClick(t)},(0,o.h)("div",{class:h}),(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=l,this.onProfileReady()}onChatButtonError(t){this._onChatButtonErrorExecuted||(this._onChatButtonErrorExecuted=!0,t.target.src=n)}renderMessagePreview(t,e){e=e||"Sent you a message";let s=i.Z.get(t,"data.message.text");var r=i.Z.get(t,"data.message.format");if("delta"===r)return this.renderDeltaMessagePreview(t,e);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))}renderDeltaMessagePreview(t,e){e=e||"Sent you a message";let s=i.Z.get(t,"data.message.quill_delta");if(!s&&i.Z.size(i.Z.get(t,"data.message.attachments"))>0&&(s=e),!s)return;let r=i.Z.parseJSON(s)||{};return r&&0!==i.Z.size(r.ops)?i.Z.map(r.ops,(t=>{let e=t.insert;return t.attributes,e.dynamicField?i.Z.get(e,"dynamicField.text",""):e.emoji?(0,o.h)(a,{emojiCode:`:${e.emoji}:`}):"string"==typeof e?e:null})):null}closePreview(t){t&&(t.preventDefault(),t.stopPropagation()),this.setState({displayPreview:!1}),this.props.store.closePreview(),this.forceUpdate()}}const p=18e5,d="https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5",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.matchAccount()||{};var r=this.props.tooltipPos||"bottom",a=this.props.mode||"primary";if(t&&t.hide_agent_profile)return(0,o.h)("div",{class:`group-avatar group-avatar--${a}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":e.name,"data-tooltip-position":r},(0,o.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:this.props.store.replaceFileUrl(e.logo_url)||s(9895)})));let n=this.props.store.matchAgent("*");var l=i.Z.map(this.props.agent_ids,(t=>n[t]));if(void 0===this.props.agent_ids||0===i.Z.size(this.props.agent_ids)){var h=i.Z.get(t,"header.agent_ids",[]);l=0!==(h=i.Z.filter(h,(t=>!!n[t]))).length?i.Z.map(h,(t=>n[t])):i.Z.filter(n,(t=>"agent"===t.type))}if(0===(l=i.Z.filter(l,(t=>!!t))).length)return(0,o.h)("div",{class:`group-avatar group-avatar--${a}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":e.name,"data-tooltip-position":r},(0,o.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:this.props.store.replaceFileUrl(e.logo_url)||s(9895)})));if(1===l.length){var p=l[0],d="primary"===a?"group-avatar--agent-middle":"group-avatar--agent-left";return(0,o.h)("div",{class:`group-avatar group-avatar--${a}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":p.fullname||e.name,"data-tooltip-position":r},(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===l.length){let t=l[0],i=l[1];return(0,o.h)("div",{class:`group-avatar group-avatar--${a}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":t.fullname||e.name,"data-tooltip-position":r},(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":i.fullname||e.name,"data-tooltip-position":r},(0,o.h)("img",{alt:"agent avatar right",width:35,height:35,class:"avatar group-avatar--agent-right",src:this.props.store.replaceFileUrl(i.avatar_url)||s(4761)})))}let c=l[0],u=l[1],m=l[2];return(0,o.h)("div",{class:`group-avatar group-avatar--${a}`},(0,o.h)("div",{class:"d-inline-block pos-relative","data-tooltip":c.fullname||e.name,"data-tooltip-position":r},(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||e.name,"data-tooltip-position":r},(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||e.name,"data-tooltip-position":r},(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=this.props.plugin.chatbox||{},a=i.Z.get(r,"header.layout"),n="list"!==this.props.view&&!0,l=!n&&"classic"===a;return n||"classic"==a?t+=" widget-header--collapsed":(t+=" widget-header--convo-expanded",e="social"===a,s=!(e||l)),(0,o.h)("div",{class:t},this.renderCollapsedHeader(n||l,l),this.renderSocial(e),this.renderTeam(s))}renderCollapsedHeader(t,e){let s=this.props.plugin.chatbox||{},r=(this.props.store.matchAccount()||{}).is_online?this.props.t("agent_online"):this.props.t("agent_offline"),a=i.Z.get(s,"tagline",{}),n=this.props.t.i18n(a)||s.introduction||r,l=i.Z.map(this.getAgentJoined(this.props.cid),(t=>t.id)),h="widget-header--inner widget-header--inner--collapsed";t||(h+=" widget-header--inner--hidden");let p=null,d="";return e?d="padding-bottom: 75px !important;":p=this.renderBackButton(),(0,o.h)("div",{class:h,style:d},p,(0,o.h)(g,{plugin:this.props.plugin,store:this.props.store,mode:"secondary",agent_ids:l}),(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:n},n)),this.renderCloseButton())}renderSocial(t){let e=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{},r=i.Z.get(e,"header.links")||[],n=i.Z.map(r,(t=>t.url&&t.type&&"subiz"!==t.type?"email"===t.type?(0,o.h)("div",null,(0,o.h)("a",{href:`mailto:${t.url}`,title:t.url},(0,o.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):(0,o.h)("div",null,(0,o.h)("a",{href:t.url,target:"_blank",title:t.url,rel:"noreferrer"},(0,o.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):null)),l=i.Z.get(e,"tagline",{});var h=this.props.t.i18n(l)||e.introduction||this.props.t("team_intro")||"Chúng tôi sẵn sàng trợ giúp :wave:.\nVui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn",p=i.Z.extractText(h).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 l="widget-header--inner widget-header--inner--expanded";return t||(l+=" widget-header--inner--hidden"),(0,o.h)("div",{class:l},(0,o.h)("div",{class:"widget-header-expand-container"},(0,o.h)("div",{class:"widget-header--top-wrapper"},(0,o.h)("div",{class:"widget-header--title"},this.getTitle()),this.renderCloseButton()),(0,o.h)("div",{class:"widget_header__body"},(0,o.h)("div",{class:"widget-header--avatar-wrapper"},(0,o.h)(g,{plugin:this.props.plugin,store:this.props.store,mode:"primary"})),(0,o.h)("div",{class:"widget-header--title-container"},(0,o.h)("div",{class:"widget-header--description"},n)))))}getTitle(){let t=this.props.plugin.chatbox||{},e=this.props.store.matchAccount()||{},s=this.getAgentJoined(this.props.cid),r=i.Z.get(this.props.plugin,"chatbox.caption",{}),o=this.props.t.i18n(r)||t.title;return f(s)||o||e.name||this.props.t("widget_title")}renderBackButton(){let t=this.props.store.matchConvo("*");if(0===i.Z.size(t))return null;var e=null;let s=this.props.store.matchUser(),r=0;return i.Z.map(t,(t=>{t.id!=this.props.cid&&(i.Z.isConvoSeen(t,s.id)||r++)})),0!==r&&(e=(0,o.h)("span",{class:"widget-header--total-unread-convo"},r)),(0,o.h)("div",{class:"widget-header--wrap-button-back "+(r?"widget-header--has-convo-unred":""),onClick:t=>this.onBackClick(t)},(0,o.h)("div",{class:"widget-header--button-back","data-tooltip":this.props.t("menu_back")}),e)}renderCloseButton(){return(this.props.plugin.chatbox||{}).hide_close_button?null:(0,o.h)("div",{class:"widget-header--button widget-header--button-close","data-tooltip":this.props.t("close"),"data-tooltip-position":"bottom",onClick:t=>this.onCloseClick(t)},(0,o.h)("span",{class:"widget-header--button-close-icon"}))}onBackClick(t){t.stopPropagation(),t.preventDefault(),this.props.onGotoList&&this.props.onGotoList()}onCloseClick(t){t.stopPropagation(),t.preventDefault(),this.props.onClose&&this.props.onClose()}getAgentJoined(t){var e=this.props.store.matchConvo(t)||{};return i.Z.filter(e.members,(t=>"agent"===t.type&&"active"===t.membership))}}let f=t=>(t=i.Z.filter(t,(t=>i.Z.trim(t.fullname)))).length?i.Z.map(t,(t=>t.fullname)).join(", "):null;class _ extends r.up{constructor(t){var e,s,r;super(t),e=this,s="onEnter",r=i.Z.throttle((function(){this.submitMessage()}),50),(s=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,this.refFileInput=(0,o.Vf)(),this.refMessageInput=(0,o.Vf)(),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(t=>{i.Z.convoOfEv(t)===this.props.cid&&this.forceUpdate()})),this.focus(),this._forceUpdate=i.Z.throttle((()=>{this.forceUpdate()}),500),this.resizeInput=i.Z.throttle((function(){const t=this.refMessageInput.current;t.style.setProperty("height","1em","important");const e=Math.min(200,t.scrollHeight);t.style.setProperty("height",`${e}px`,"important")}),5)}blur(){const t=this.refMessageInput.current;t&&t.blur()}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(),i.Z.setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()})),i.Z.setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()}),100))}renderEmoji(){return(0,o.h)("div",null,this.renderEmojiPopup(),(0,o.h)("div",{class:"message-input--button message-input--emoji-button",onClick:t=>this.toggleEmoji(t)}))}toggleEmoji(t){t.stopPropagation(),this.focus(),this.props.disabled||this.setState({openEmoji:!this.state.openEmoji})}emojiPick(t){const e=this.refMessageInput.current,s=e.selectionStart,i=this.refMessageInput.current.value;this.setState({openEmoji:!1}),this.refMessageInput.current.value=[i.slice(0,s),t,i.slice(s)].join(""),this.resizeInput(),e.focus()}onKeydown(t){if(13===t.keyCode&&!1===t.shiftKey)return this.onEnter(),t.preventDefault();this._forceUpdate(),this.sendTyping()}onChange(){this.resizeInput()}selectFile(){this.props.disabled||this.refFileInput.current.click()}sendFile(){let t=this.refFileInput.current;this._sendFile(t.files),t.value=""}_sendFile(t){if(0===i.Z.size(t))return;if(this.props.disabled)return;let e=i.Z.map(t,(t=>({type:"file",mimetype:t.type,name:t.name,_file:t,size:t.size})));this.props.onSend&&this.props.onSend({attachments:e})}async submitMessage(t){(t=t||i.Z.trim(this.refMessageInput.current.value)||"")&&(this.props.disabled||(this.refMessageInput.current.value="",this.resizeInput(),this.setState({openEmoji:!1}),this.props.onSend&&this.props.onSend({text:t,format:"plaintext"})))}sendTyping(){if(this.props.cid)return this.props.store.typing(this.props.cid)}pasteImage(t){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return;let e=new i.Z.Date;const s=`Paste-image-${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}-${e.getHours()}-${e.getMinutes()}-${e.getSeconds()}`;let r=null;const o=t.clipboardData.items[0];if(0===o.type.indexOf("image")&&(r=o.getAsFile()),!r)return;const a=[r,new ArrayBuffer],n=new File(a,`${s}.png`,{type:"image/png"});this._sendFile([n])}}class 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} message-${t}-audio`},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 Z 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},this.props.t.i18n(t.i18n_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},this.props.t.i18n(t.i18n_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)},this.props.t.i18n(t.i18n_title)||t.title):("widget_ask_desktop_notify_button"===t.type||t.type,null)));return(0,o.h)("div",{class:"button-attachments"},t)}}class k extends r.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)(Z,{store:this.props.store,buttons:t,t:this.props.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 l=i.Z.map(t,(t=>(0,o.h)("div",{class:"message_quick_reply",onClick:e=>this.props.onSelect(t)},t.title)));return(0,o.h)("div",{class:"message_quick_replies"},l)}}class 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 j extends r.up{constructor(t){super(t)}render(){return null}}function E(t){return t.touches&&t.touches.length?t.touches[0]:{}}class P 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.scrollTo({left:220*t,behavior:"smooth"})}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,r)=>{var a=i.Z.map(e.elements,(t=>{let e=this.props.t.i18n(t.i18n_title)||t.title,i=this.props.t.i18n(t.i18n_subtitle)||t.subtitle,r=e?(0,o.h)("div",{class:"generic-attachment--element-title"},e):null,a=i?(0,o.h)("div",{class:"generic-attachment--element-subtitle"},i):null,n=this.props.store.replaceFileUrl(t.image_url);return t.image_url||(n=s(9270)),(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:n})),(0,o.h)("div",{class:"generic-attachment--element-content"},r,a),(0,o.h)(Z,{buttons:t.buttons,onSelect:t=>this.props.onSelect(t),t:this.props.t}))}));let n=i.Z.get(t,"0.elements",[]),l="generic-attachment-navigator generic-attachment-navigator--left",h="generic-attachment-navigator generic-attachment-navigator--right";return 0===this.state.focusing&&(l+=" generic-attachment-navigator--disabled"),this.state.focusing===n.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},a),!this.props.store.isMobile()&&(0,o.h)(o.HY,null,(0,o.h)("div",{class:l,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=E(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=E(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 I 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,l=[],h=n.url||n.mobile_url;this.props.store.isMobile()&&(h=n.mobile_url||n.url),h&&0==i.Z.size(n.buttons)&&l.push((0,o.h)("a",{class:"product_attachment__btn",href:h,target:"_blank"},this.props.t("detail"),(0,o.h)("img",{src:s(8453),class:"product_attachment__btn_external_link"}))),console.log("P",n),i.Z.size(n.buttons)>0&&(l=l.concat(i.Z.map(n.buttons,((t,e)=>"call_button"===t.type?(0,o.h)("a",{class:"product_attachment__btn",href:"tel:"+t.phone_number,key:e,title:t.title},this.props.t.i18n(t.i18n_title)||t.title):"url_button"===t.type?(0,o.h)("a",{class:"product_attachment__btn",href:t.url,target:"_blank",key:e,title:t.title},this.props.t.i18n(t.i18n_title)||t.title||this.props.t("detail")," ",(0,o.h)("img",{src:s(8453),class:"product_attachment__btn_external_link"})):"postback_button"===t.type?(0,o.h)("a",{class:"product_attachment__btn",href:"javascript:;",onClick:e=>this.props.onPostback(t)},this.props.t.i18n(t.i18n_title)||t.title):void 0))));let p=(0,o.h)("a",{href:h,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=n.currency||i.Z.get(a,"currency","VND"),m=null;n.price&&(m=(0,o.h)("div",{class:"product_attachment__price"},i.Z.formatCurrency(n.price,u)));let g=this.props.store.replaceFileUrl(n.image);return n.image||(g=s(9270)),(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:g}))),p,d,m,(0,o.h)("div",{class:"product_attachment__btns"},l))}))}}class F 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)=>{i.Z.calcOrderTotal(e);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__note",title:e.note},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,"image",s(9270))}),(0,o.h)("div",{style:"overflow: hidden !important;"},(0,o.h)("div",{class:"order_attachment__product_name",title:this.props.t.i18n(e.i18n_name)||e.name},this.props.t.i18n(e.i18n_name)||e.name),(0,o.h)("div",{class:"order_attachment__product_desc"},i.Z.getProductPropName(e," / ")),(0,o.h)("div",{class:"order_attachment__product_desc"},this.props.t("qty")," ",t.quantity," · ",i.Z.formatCurrency(e.price))))}))));let l=(0,o.h)("div",{class:"order_attachment__footer"},(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",null,this.props.t("total"))," ",(0,o.h)("div",null,(0,o.h)("b",{class:"order_attachment__total"},i.Z.formatCurrency(e.total))))),h=i.Z.find(i.Z.get(e,"user.attributes",[]),(t=>"phones"===t.key))||{key:"phones",text:""},p=i.Z.get(e,"shipping.address.phone","").trim();p=p||i.Z.trim(h.text),p&&(p=this.props.t("phn")+": "+p);let d=null;(i.Z.displayOrderShippingAddress(e)||p)&&(d=(0,o.h)("div",null,(0,o.h)("div",{class:"order_attachment__label"},this.props.t("ship_to")),(0,o.h)("div",null,i.Z.displayOrderShippingAddress(e)),(0,o.h)("div",{class:"order_attachment__text_truncate"},p)));let c=null;e._discount_before_tax&&(c=(0,o.h)("div",{class:"order_attachment__footer"},(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},this.props.t("subtotal_before_tax"))," ",(0,o.h)("div",null,i.Z.formatCurrency(e._order_value))),(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_before_tax"))," ",(0,o.h)("div",null,"-",i.Z.formatCurrency(e._discount_before_tax)))));let u=(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},this.props.t("subtotal"))," ",(0,o.h)("div",{style:""},i.Z.formatCurrency(e.subtotal))),m=null;if(e.total_tax){let t="";if(1===i.Z.size(e._taxM)){let s=i.Z.get(e._taxM,"0.tax",{});s.name&&s.percentage&&(t=`(${s.name} ${Math.round(s.percentage||0)/100}%)`)}m=(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},this.props.t("tax")," ",t),(0,o.h)("div",{style:""},i.Z.formatCurrency(e.total_tax)))}let g=null;"percentage"===e.discount_type&&e.discount_percentage&&(g=(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_after_tax")," (",Math.round(e.discount_percentage/100),"%)")," ",(0,o.h)("div",{style:""},"-",i.Z.formatCurrency(e._computed_discount)))),"amount"===e.discount_type&&e.discount_amount&&(g=(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_after_tax"))," ",(0,o.h)("div",{class:"no-shrink"},"-",i.Z.formatCurrency(e._computed_discount))));let v=null;i.Z.get(e,"shipping.nominal_fee")&&(v=(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},this.props.t("shipping_fee"))," ",(0,o.h)("div",{style:""},i.Z.formatCurrency(i.Z.get(e,"shipping.nominal_fee",0)))));let f=null;return e.adjustment&&(f=(0,o.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,o.h)("div",{class:"order_attachment__label no_margin"},e.adjustment_description)," ",(0,o.h)("div",{class:"no-shrink"},i.Z.formatCurrency(e.adjustment)))),u=(0,o.h)("div",{class:"order_attachment__footer"},u,m,v,g,f),v||f||g||m||(u=null),(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"},i.Z.getOrderDisplayName(e))),n,d,a,c,u,l)}))}}class R 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 U 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: 'Inter', 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 { margin-bottom: 0; margin-top: 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 z=[],A=(t,e)=>(z.push(t),"");(async()=>{let t=(await s.e(441).then(s.bind(s,7441))).marked;A=(e,s)=>t(s),i.Z.map(z,(t=>t.forceUpdate())),z=[]})();class L extends r.up{render(){var t=i.Z.get(this.props.ev,"data.message.format","plaintext");return"markdown"===t?this.renderMarkdown():"delta"===t?this.renderDelta():this.renderPlainText()}renderPlainText(){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)}renderDelta(){let t=i.Z.get(this.props.ev,"data.message.quill_delta")||i.Z.get(this.props.ev,"data.message.text"),e=i.Z.parseJSON(t)||{};if(e=O(e),!e||0===i.Z.size(e.ops))return null;let s=i.Z.map(e.ops,(t=>{let e=t.insert,s=t.attributes;if(e.dynamicField)return i.Z.get(e,"dynamicField.text","");if(e.mention){if("*"==e.mention.id||"all"==e.mention.id)return(0,o.h)("span",{class:"mention"},"@",this.$t("all"));let t=store.matchAgent(e.mention.id),s=i.Z.getAgentDisplayName(t,e.mention.fullname);return(0,o.h)("span",{class:"mention","data-agent-id":t.id,"data-agent-fullname":s},"@",s)}if(e.emoji)return(0,o.h)(a,{emojiCode:`:${e.emoji}:`});if("string"==typeof e){let t=i.Z.extractText(e).map(((t,e)=>{return"link"===t.type?(0,o.h)("a",{href:(s=t.text,s.startsWith("http://")||s.startsWith("https://")||s.startsWith("//")?s:"http://"+s),target:"_blank"},t.text):t.text;var s}));if(s){if(s.italic&&s.bold)return(0,o.h)("span",{style:"font-weight: bold !important; font-style: italic !important"},t);if(s.italic)return(0,o.h)("span",{style:"font-style: italic !important"},t);if(s.bold)return(0,o.h)("span",{style:"font-weight: bold !important"},t)}return(0,o.h)("span",null,t)}return null})),r=i.Z.get(this.ev,"by.type");return"user"!==r&&(r="agent"),0===i.Z.size(s)?null:"agent"===r?(0,o.h)("div",{class:"message-agent message-text--agent"},s):(0,o.h)("div",{class:"message-user message-text--user"},s)}renderMarkdown(t){if(t||(t=i.Z.get(this.props.ev,"data.message.text")),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)(U,{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)(U,{html:A(this,t)})))}}function O(t){if(!t)return t;if(!t.ops||!t.ops.length)return t;let e=t.ops[t.ops.length-1];if("string"!=typeof e.insert)return t;let s=e.insert.trim();if(s){if(e.insert!=s){let e=t.ops.slice(),i=e.pop();return i.insert=s,e.push(i),{ops:e}}return t}let i=t.ops.slice();return i.pop(),O({ops:i})}var T=new i.Z.Pubsub;i.Z.setInterval((()=>T.publish("time")),2e4);class $ 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 l=Math.round(Math.abs(o));if(l<=r.r||!r.r){l<=1&&n>0&&(r=i[n-1]),a=s[r.l].replace("%d",l);break}}return a}(this.props.time,(new i.Z.Date).getTime()))}else t=i.Z.shortTime(this.props.time,this.props.tzoffset);this.props.uppercase&&(t=t.toUpperCase()),t!==this.state.t&&this.setState({t})}componentDidMount(){T.on2(this,"time",(()=>this.updateTime())),this.updateTime()}render(){return(0,o.h)("span",{style:this.props.style},this.state.t)}}class q 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)($,{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)(q,{t:this.props.t,store:this.props.store,ev:this.props.event}):null}return null}focus(){this.refForm.current&&this.refForm.current.focus()}chooseQuickReply(t){let e=i.Z.get(this.props.event,"ev",{}),s={text:t.title,format:"plaintext"};t.payload&&(s.attachments=[{type:"postback",postback:{event_id:e.id,payload:t.payload}}]),this.props.onSend(s)}choosePostbackBtn(t){let e=i.Z.get(this.props.event,"ev",{}),s={text:t.title,format:"plaintext"};t.payload&&(s.attachments=[{type:"postback",postback:{event_id:e.id,payload:t.payload}}]),this.props.onSend(s)}renderAgentAvatar(t){let e=i.Z.get(t,"by.type"),r=i.Z.get(t,"by.display_id",i.Z.get(t,"by.id"));if("user"===e)return null;var a=this.getSenderName(t);let n=this.props.store.matchAccount();var l=n.logo_url||s(9895);if(i.Z.get(this.props,"chatbox.hide_agent_profile"))return(0,o.h)("div",{class:"message-sender"},(0,o.h)("img",{alt:"sender",class:"message-sender-avatar",src:this.props.store.replaceFileUrl(l)}),(0,o.h)("p",{class:"message-sender-name"},n.name));let h=this.props.store.matchAgent("*");return"system"!==r&&"dummy"!==e&&"workflow"!==e&&(l=i.Z.get(h[r],"avatar_url")||n.logo_url||s(4761)),(0,o.h)("div",{class:"message-sender"},(0,o.h)("img",{alt:"sender",class:"message-sender-avatar",src:this.props.store.replaceFileUrl(l)}),(0,o.h)("p",{class:"message-sender-name"},a))}renderMessageSent(){let t=this.props.event.ev;var e=null;this.props.event.show_time&&(e=(0,o.h)("div",{class:"convo-event-time"},(0,o.h)($,{time:t.created})));let s=new i.Z.Date(t.created).toLocaleString();if("user"!==i.Z.get(t,"by.type")){let i=null;return"lead"===this.props.event.mode&&(i=this.renderAgentAvatar(t)),(0,o.h)("div",{class:"convo-event agent-message",title:s},e,i,(0,o.h)(L,{store:this.props.store,ev:t,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)(R,{store:this.props.store,ev:t}),(0,o.h)(w,{store:this.props.store,ev:t}),(0,o.h)(k,{store:this.props.store,ev:t,t:this.props.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)(j,{store:this.props.store,ev:t,t:this.props.t}),(0,o.h)(P,{store:this.props.store,ev:t,onSelect:t=>this.choosePostbackBtn(t),t:this.props.t}),(0,o.h)(I,{t:this.props.t,onPostback:t=>this.choosePostbackBtn(t),store:this.props.store,ev:t}),(0,o.h)(F,{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&&i.Z.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;if(t._error&&"message_sent"===t.type){let e=this.props.t("error_send_message");t._error_message&&(e=this.props.t(t._error_message)),n=(0,o.h)("a",{class:"message_error",src:"javascript:;",onClick:t=>this.resendMessage()},(0,o.h)("div",{class:"message_error__text"},e),(0,o.h)("div",{class:"message_error__icon"}))}return(0,o.h)("div",{class:"convo-event user-message",title:s},e,a,(0,o.h)("div",{class:"message-user__container"},r,(0,o.h)(L,{store:this.props.store,ev:t,refresh:this.state.refresh,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)(R,{store:this.props.store,ev:t}),(0,o.h)(w,{store:this.props.store,ev:t}),(0,o.h)(k,{store:this.props.store,ev:t,t:this.props.t}),(0,o.h)(M,{store:this.props.store,onSubmit:this.props.onFormSubmit,ref:this.refForm,ev:t}),(0,o.h)(I,{t:this.props.t,store:this.props.store,ev:t}),(0,o.h)(j,{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("user"===e)return i.Z.getUserDisplayName(this.props.store.matchUser());let r=this.props.store.matchAccount();return"agent"===e?i.Z.getAgentDisplayName(r,this.props.store.matchAgent(s)):"system"===s||"dummy"===e||"workflow"===e?r.name||"system":""}}const W=s(6484);class V extends r.up{render(){(this.props.mode+"").toLowerCase();let t=this.props.size||14,e=(Math.ceil(t/14),`width: ${t}px !important;height: ${t}px !important;`);return this.props.center?(0,o.h)("div",{class:"loading"},(0,o.h)("img",{alt:"loading",style:e,src:W})):(0,o.h)("img",{alt:"loading",style:e,src:W})}}const H=s(6188);class Y 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=>G(t.ev)))).length<1)){for(var s=1;s<e.length;s++){let t=e[s],r=e[s-1];G(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,{chatbox:this.props.chatbox,onLink:this.props.onLink,store:this.props.store,onFormSubmit:this.props.onFormSubmit,onSend:this.props.onSend,onPostback:this.props.onPostback,event: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:i.Z.get(this.props.chatbox,"primary_color","dark"),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:H}),(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(),i.Z.setTimeout((()=>this.setState({loading:!1})),50)}isBottom(){let t=this.refBody;return!!t&&t.scrollHeight<t.scrollTop+t.offsetHeight+50}scrollToBottom(){i.Z.setTimeout((()=>{const t=this.refBody;t&&(t.scrollTop=t.scrollHeight)})),i.Z.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 G(t){let e=i.Z.get(t,"type");return"message_sent"===e||"conversation_state_updated"===e}class N 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&&i.Z.clearTimeout(this.timer),this.timer=null,void this.setState({isShow:!1})):void("conversation_typing"===i.Z.get(t,"type")&&"agent"!=(this.props.store.matchAgent(i.Z.get(t,"by.id"))||{}).type&&(this.setState({ev:t,isShow:!0}),this.timer&&i.Z.clearTimeout(this.timer),this.timer=i.Z.setTimeout((()=>{i.Z.convoOfEv(t)===this.props.cid&&(this.timer=null,this.setState({isShow:!1}))}),5e3)))}))}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 J=class{constructor(t){this.duration=t.duration||100,this.breakingV=t.breakingV||7,this.maxY=t.maxY||500,this.minY=t.minY||0}play(t,e,s){var r;this.stop();var o=a=>{a||(a=(new i.Z.Date).getTime());var n=a-r,[l,h]=this.calcY(t,e,n);if(s(l),h)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(K(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,K(r,i)]}stop(){window.cancelAnimationFrame(this.animationframe)}};function K(t,e){return Math.abs(t-e)<=.001}class Q extends r.up{constructor(t){var e,s,i;super(t),e=this,i={hide:!0,ratingHeight:0,overlayOpacity:.3,comment:""},(s=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(s="state"))in e?Object.defineProperty(e,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[s]=i,this.refComment=(0,o.Vf)(),this.refRating=(0,o.Vf)(),this.refHandle=(0,o.Vf)()}componentDidMount(){this.props.store.onUpdate(this,(()=>{this.shoudDisplay()&&this.open()})),this.props.store.onConvoEvent(this,(t=>{i.Z.convoOfEv(t)===this.props.cid&&this.shoudDisplay()&&this.open()})),this.mouseUp=t=>this.onMouseUp(t),this.mouseMove=t=>this.onMouseMove(t),this.mouseDown=t=>this.onMouseDown(t);var t=this.refHandle.current;t.addEventListener("mousedown",this.mouseDown,{passive:!0}),t.addEventListener("touchstart",this.mouseDown,{passive:!0}),window.addEventListener("mouseup",this.mouseUp,{passive:!0}),window.addEventListener("touchend",this.mouseUp,{passive:!0}),window.addEventListener("mousemove",this.mouseMove,{passive:!0}),window.addEventListener("touchmove",this.mouseMove,{passive:!0}),this.animation=new J({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)){i.Z.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)})}}}function X(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class tt extends r.up{constructor(t){super(t),X(this,"state",{show:!1,searchValue:""}),X(this,"filterRef",(0,o.Vf)()),X(this,"overlayRef",(0,o.Vf)()),X(this,"onTouchMove",(t=>{t.target===this.overlayRef.current&&(t.preventDefault(),t.stopPropagation())})),X(this,"hideDropdown",(()=>{this.setState({show:!1,searchValue:""})})),X(this,"onKeydown",(t=>{if("Escape"===t.key){if(!this.state.show)return;this.state.searchValue?this.setState({searchValue:""}):this.hideDropdown(),t.preventDefault(),t.stopPropagation()}})),X(this,"hasSearch",(()=>!!this.props.has_search||i.Z.size(this.props.items)>=10)),X(this,"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})),X(this,"onChangeSearchValue",(t=>{this.setState({searchValue:t.target.value})})),X(this,"toogleDropdown",(async()=>{await this.setState({show:!0,searchValue:""}),this.focusFilter()})),X(this,"onSelect",(t=>{this.props.onSelect(t),this.hideDropdown()})),X(this,"onBackgroundScroll",(t=>{console.log("EEEEEEE",t),alert("y")})),document.addEventListener("touchmove",(function(t){}))}componentDidMount(){window.addEventListener("keydown",this.onKeydown)}componentWillUnmount(){window.removeEventListener("keydown",this.onKeydown)}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"))}focusFilter(){this.filterRef.current&&(this.filterRef.current.focus(),i.Z.setTimeout((()=>{this.filterRef.current&&this.filterRef.current.focus()}),100))}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))}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()))}}function et(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class st extends r.up{constructor(t){super(t),et(this,"state",{show:!1,searchValue:"",addresses:[]}),et(this,"filterRef",(0,o.Vf)()),et(this,"overlayRef",(0,o.Vf)()),et(this,"onTouchMove",(t=>{t.target===this.overlayRef.current&&(t.preventDefault(),t.stopPropagation())})),et(this,"hideDropdown",(()=>{this.setState({show:!1,searchValue:""})})),et(this,"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})),et(this,"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)),et(this,"onChangeSearchValue",(t=>{this.setState({searchValue:t.target.value}),this.props.onChangeAddress(t.target.value),this.doSearch()})),et(this,"toogleDropdown",(async()=>{await this.setState({show:!0,searchValue:this.props.initAddress||""}),this.focusFilter()})),et(this,"onSelect",(t=>{this.props.onSelect(t),this.hideDropdown()})),et(this,"onBackgroundScroll",(t=>{console.log("EEEEEEE",t)})),document.addEventListener("touchmove",(function(t){}))}componentDidMount(){window.addEventListener("keydown",this.onKeydown)}componentWillUnmount(){window.removeEventListener("keydown",this.onKeydown)}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"))}focusFilter(){this.filterRef.current&&(this.filterRef.current.focus(),i.Z.setTimeout((()=>{this.filterRef.current&&this.filterRef.current.focus()}),100))}renderDropdown(){if(!this.state.show)return null;let t=i.Z.map(this.state.addresses,((t,e)=>{let s=[((t.address||"")+" "+it(t.street)).trim()].join(", "),i=[it(t.ward),it(t.district),it(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))}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 it(t){let e=(t+"").toLowerCase();return e.startsWith("tp ")?t.substr(3):e.startsWith("thanh pho ")||e.startsWith("thành phố ")?t.substr(10):e.startsWith("tỉnh ")?t.substr(5):e.startsWith("huyện ")?t.substr(6):e.startsWith("tỉnh ")?t.substr(5):e.startsWith("xã ")?t.substr(3):e.startsWith("thị trấn ")?t.substr(9):e.startsWith("thị xã ")?t.substr(7):e.startsWith("đường ")&&(t[7]<"0"||t[7]>"9")?t.substr(6):e.startsWith("phường ")&&(t[7]<"0"||t[7]>"9")?t.substr(7):e.startsWith("quận ")&&(t[7]<"0"||t[7]>"9")?t.substr(5):t}s.e(178).then(s.bind(s,178));var rt=document.createElement("link");rt.href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap",rt.rel="stylesheet",document.head.append(rt),i.Z.preloadWebfonts(["Roboto"],[400,500]),s(4761);class ot 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}}function at(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var nt=s(763),lt=s(2514);class ht extends r.up{constructor(t){super(t),at(this,"state",{loadProvince:!0,g_err:"",fullname:"",email:"",phone:"",loading:!0,order:{},err:{},shipping_address:"new",selectedProvince:null,selectedDistrict:null,selectedWard:null,street:"",address:"",sending:!1,step:""}),at(this,"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:nt}),(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"))))))),at(this,"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")})})),at(this,"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")})})),at(this,"onSelectWard",(t=>this.setState({selectedWard:t,err:{},g_err:""}))),at(this,"onChangeFullname",(t=>this.setState({fullname:t.target.value,err:{},g_err:""}))),at(this,"onChangeAddress",(t=>this.setState({address:t,err:{},g_err:""}))),at(this,"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}))})),at(this,"onChangeEmail",(t=>this.setState({email:t.target.value,err:{},g_err:""}))),at(this,"onChangePhone",(t=>this.setState({phone:t.target.value,err:{},g_err:""}))),at(this,"onChangePaymentMethod",(t=>this.setState({pm:t}))),at(this,"onChangeQuantity",((t,e)=>{let s=parseInt(e)||1;t.quantity=s,this.forceUpdate()})),at(this,"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 l=await this.props.store.updateOrder(a);if(this.setState({sending:!1}),l.error)return this.setState({g_err:this.props.t("update_failed")});this.setState({step:"success"}),this.props.onResponse&&this.props.onResponse("confirmed")})),at(this,"onCancel",(()=>{if(this.props.onResponse&&this.props.onResponse("rejected"),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.close()})),at(this,"close",(()=>{this.props.onClose&&this.props.onClose()})),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:""})}onChangeShipping(t){this.setState({shipping:t,err:{},g_err:""})}renderDesktopPaymentMethod(t){return null}renderDesktopShipping(t){let e=!1;if(t.status&&"open"!=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,l=!1;if("ship"===this.state.shipping){l=!0;let h=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"}))))}));h.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)(st,{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)(tt,{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)(tt,{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)(tt,{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"},h),p))}let h="ship_card",p=!1;"shop"===this.state.shipping&&(p=!0,h+=" 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:h+" mr-3",onClick:t=>this.onChangeShipping("shop")},(0,o.h)(ot,{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)(ot,{name:"package",active:l})," ",(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"),l="card_section";return this.isMobile()&&(l="order_section"),(0,o.h)("div",{class:l},(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))),l=(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")),h=!1;t.status&&"open"!=t.status||(h=!t.user_confirmation);let p=null;h&&(l=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,l,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||"open";return(0,o.h)("div",{style:"float: right !important;",class:"order_status order_status__"+e},e)}renderShippingInfo(t){"open"!=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:pt.ghtk.logo}),(0,o.h)("div",null,pt.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:pt.ghtk.logo}),(0,o.h)("div",null,pt.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)}renderDesktopProducts(t){let e=null,r=!1;return t.status&&"open"!=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)($,{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:lt})," ",(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||"open"!=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)($,{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&&"open"!=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:nt}));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:lt})," ",(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)}}let pt={ghtk:{name:"Giao hàng tiết kiệm",logo:s(6890)},ghn:{name:"Giao hàng nhanh",logo:s(1473)}};function dt(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}s(4761);class ct extends r.up{constructor(t){super(t),dt(this,"state",{hide:!0,ratingHeight:0,overlayOpacity:.3}),dt(this,"onResponse",(t=>{this.setState({response:t})})),dt(this,"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"})}}]}})})),dt(this,"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()}})),this.refRating=(0,o.Vf)(),this.refHandle=(0,o.Vf)()}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 J({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,i.Z.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)(ht,{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}))))}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)})}))}}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)})}}}function ut(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var mt=s(9737),gt=s(8909),vt=s(29);const ft="https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png";class _t extends r.up{constructor(t){super(t),ut(this,"msgInput",(0,o.Vf)()),ut(this,"sendMessage",(async t=>{let e=i.Z.find(t.attachments,(t=>"postback"===t.type));if(this.isFormRequired()&&e)return this.onStartConvoClick(),void this.fillQuickReplyToQuestion(t);let s=t.text;if(!this.props.cid){this.creating=!0;const{convo:e,error:i}=await this.props.store.startConvo({locale:this.props.t.locale(),message:s,initial_by:this.props.store.matchUser().id});return this.creating=!1,this.props.store.sendConvoEvent(e.id,"message_sent",{message:t}),void this.props.onGo({view:"chat",cid:e.id})}this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:t})})),ut(this,"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(27);return e=e.split("/")[0],this.setState({showOrder:!0,order_id:e}),void t.preventDefault()}})),ut(this,"closeOrder",(t=>{this.setState({showOrder:!1,order_id:""}),this.focusInput()})),this.userSent={},this.wasFormInputed=!1,this.setState({creating:!1,clickedJoin:!1,formData:{},showOrder:!1,order_id:"",quickReplyMessage:{}}),this.props.store.onUpdate(this,(t=>this.forceUpdate()))}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,quickReplyMessage:{}}),i.Z.setTimeout((()=>{this.events&&this.events.focus(),this.props.store.isMobile()||this.focusInput()}),100)),this.updateFormDataFields()}shouldShowForm(){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),!this.hasSentMessage(this.props.cid)&&t&&(i.Z.size(t.groups)||t.group_required))return!0;let o=this.isFormRequired();return o&&!this.props.cid||o&&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 l=null;l="list"===this.props.view?this.renderConvoList():e?this.renderForm(t,a):this.renderChat();let h=i.Z.get(s,"desktop_button.position")||"right";this.props.store.isMobile()&&(h=i.Z.get(s,"mobile_button.position",h));let p="widget-container widget-container--"+h;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"})}),l)}async submitPrechatForm(t){var e=!1;if(i.Z.map(this.state.formData,((t,s)=>{t.is_required&&(void 0===t.value||""===t.value||0===i.Z.size(t.value)&&Array.isArray(t.value))?(t.error=this.props.t("error_empty"),e=!0):t.error="","emails"===s.substr(5)&&!i.Z.isEmail(t.value)&&t.is_required&&(t.error=this.props.t("error_email_invalid"),e=!0),"phones"===s.substr(5)&&!i.Z.isPhone(t.value)&&t.is_required&&(t.error=this.props.t("error_phone_invalid"),e=!0)})),e)return this.forceUpdate();let s=i.Z.cloneDeep(this.state.formData),r=i.Z.cloneDeep(this.props.store.matchUser()),o=!1;i.Z.map(s,((t,e)=>{if(e.startsWith("attr:")){var s={key:e.substr(5)};o=o||"emails"==e||"phones"==e,"number"===t.type&&(s.number=parseInt(t.value)),"datetime"===t.type&&(s.datetime=new i.Z.Date(t.value).toISOString()),"list"===t.type&&(s.text=t.value),"text"!==t.type&&"boolean"!==t.type||(s[t.type]=t.value),i.Z.setUserAttr(r,s)}})),o&&i.Z.setUserAttr(r,{key:"lead_source",text:"widget"});let a=i.Z.get(s,"question.value"),n=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:a,format:"plaintext",fields:[{key:"to_agent_group",value:i.Z.stringify(n)}],attachments:this.state.quickReplyMessage.attachments}}),this.setState({quickReplyMessage:{}}),void(t.end_conversation_after_submit&&await this.props.store.endConvo(this.props.cid));this.setState({creating:!0});let l={text:a,format:"plaintext"},h={group_id:n,message:a,locale:this.props.t.locale(),initial_by:r.id};this.setState({creatingError:null}),await this.props.store.setUser(r);const{error:p,convo:d}=await this.props.store.startConvo(h);if(p)return void this.setState({creating:!1,creatingError:p});let c=d.id;this.userSent[c]=!0,this.props.onGo({view:"chat",cid:c}),this.props.store.sendConvoEvent(c,"message_sent",{message:l}),this.setState({creating:!1,clickedJoin:!1,quickReplyMessage:{}}),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",value:this.state.quickReplyMessage.text},this.setState({formData:e}),this.props.store.isMobile()||this.focusInput()}onBooleanChange(t,e){this.wasFormInputed=!0;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){this.wasFormInputed=!0;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){this.wasFormInputed=!0;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){this.wasFormInputed=!0;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}))}renderCheckboxField(t){let e=i.Z.get(t,"def.items",[]),s=[],r=t.value||"";return r&&(s=r.split(",")),(0,o.h)("div",null,i.Z.map(e,(e=>(0,o.h)("div",{class:"checkbox"},(0,o.h)("input",{type:"checkbox",id:"form-checkbox"+bt(t.key)+e.value,onChange:s=>this.toggleCheckboxField(t.key,e.value),checked:s.includes(e.value)}),(0,o.h)("label",{class:"checkbox--label",for:"form-checkbox"+bt(t.key)+e.value},this.props.t.i18n(e.i18n_label)||e.label||e.value),(0,o.h)("div",{class:"checkbox--check"},(0,o.h)("div",null))))))}toggleCheckboxField(t,e){this.wasFormInputed=!0;let s=i.Z.cloneDeep(this.state.formData),r=i.Z.find(s,((e,s)=>e.key===t));if(!r)return;let o=r.value||"",a=[];o&&(a=o.split(",")),a.includes(e)?a=i.Z.filter(a,(t=>t!==e)):a.push(e),r.value=a.join(","),this.setState({formData:s})}renderRadioField(t){let e=i.Z.get(t,"def.items",[]),s=t.value||"";return(0,o.h)("div",null,i.Z.map(e,(e=>(0,o.h)("div",{class:"radio"},(0,o.h)("input",{type:"radio",name:"form-radio"+bt(t.key),id:"form-radio"+bt(t.key)+e.value,onChange:s=>this.toggleRadioField(t.key,e.value),checked:s===e.value}),(0,o.h)("label",{class:"radio--label",for:"form-radio"+bt(t.key)+e.value},this.props.t.i18n(e.i18n_label)||e.label||e.value),(0,o.h)("div",{class:"radio--check"},(0,o.h)("div",null))))))}toggleRadioField(t,e){this.wasFormInputed=!0;let s=i.Z.cloneDeep(this.state.formData),r=i.Z.find(s,((e,s)=>e.key===t));r&&(r.value=e,this.setState({formData:s}))}selectDropdownField(t,e){this.wasFormInputed=!0;let s=i.Z.cloneDeep(this.state.formData),r=i.Z.find(s,((e,s)=>e.key===t));r&&(r.value=e,this.setState({formData:s}))}renderDropdownField(t){let e=i.Z.get(t,"def.items",[]);return(0,o.h)("select",{class:"form-control",value:t.value,onChange:e=>this.selectDropdownField(t.key,e.target.value)},(0,o.h)("option",{value:""},"-- ",this.props.t("no_select")," --"),i.Z.map(e,(t=>(0,o.h)("option",{value:t.value},this.props.t.i18n(t.i18n_label)||t.label||t.value))))}renderFields(){if(0===i.Z.size(this.state.formData))return null;let t=i.Z.map(this.state.formData,((t,e)=>{if(this.state.quickReplyMessage.text&&"question"===e)return null;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_"+bt(e)]=t},value:t.value||"",onInput:t=>this.onInputChange(e,t.target.value),row:"4",class:"form-control"}):"checkbox"===i.Z.get(t,"def.select")?this.renderCheckboxField(t):"radio"===i.Z.get(t,"def.select")?this.renderRadioField(t):"dropdown"===i.Z.get(t,"def.select")?this.renderDropdownField(t):i.Z.get(t,"def.multiple_line")?(0,o.h)("textarea",{class:"form-control",ref:t=>{this["form_"+bt(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_"+bt(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_"+bt(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"+bt(e),onInput:t=>this.onBooleanChange(e,t),checked:t.value}),(0,o.h)("label",{class:"checkbox--label",for:"form-checkbox"+bt(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"+bt(e)+bt(s.value),checked:t.value===s.value,onInput:t=>this.onInputChange(e,s.value)}),(0,o.h)("label",{class:"radio--label",for:"form-radio"+bt(e)+bt(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)}),s=this.renderDropdownField(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)(yt,{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.orderByF(e,(t=>i.Z.get(t,"last_message_sent.created",t.actived)),"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:vt}),(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:mt,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.current;t&&(i.Z.setTimeout((()=>t&&t.blur())),i.Z.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 i.Z.setTimeout((()=>{var e=this["form_"+bt(t)];e&&e.focus()}),300)}var t=this.msgInput.current;t&&(i.Z.setTimeout((()=>t.focus())),i.Z.setTimeout((()=>t.focus()),300))}}onRate(t){this.props.cid&&(this.props.store.sendConvoEvent(this.props.cid,"conversation_rated",{conversation:{ratings:[t]}}),this.focusInput())}fillQuickReplyToQuestion(t){let e=this.state.formData;e&&i.Z.set(e,"question.value",t.text),this.setState({formData:e,quickReplyMessage:t})}createPostback(t){this.props.store.createPostback(this.props.cid,t)}onChangeMessageInput(){this.wasFormInputed=!0}renderChat(){let t=(0,o.h)(_,{store:this.props.store,ref:this.msgInput,cid:this.props.cid,onChange:this.onChangeMessageInput,onSend:this.sendMessage,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)(Y,{isShow:this.props.isShow,onLink:this.onLink,store:this.props.store,chatbox:this.props.plugin.chatbox||{},onFormSubmit:t=>this.onEventFormSubmit(t),ref:t=>this.events=t,cid:this.props.cid,creating:this.creating,onSend:t=>this.sendMessage(t),onPostback:t=>this.createPostback(t),t:this.props.t}),(0,o.h)(N,{store:this.props.store,cid:this.props.cid,t:this.props.t})),(0,o.h)(Q,{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)(ct,{forceView:this.props.view,plugin:this.props.plugin,show:this.state.showOrder,order_id:this.state.order_id,store:this.props.store,onClose:this.closeOrder,cid:this.props.cid,t:this.props.t}),t)}async onStartConvoClick(){if("ended"===(this.props.store.matchConvo(this.props.cid)||{}).state)return this.props.onGo({view:"chat",cid:""});this.setState({clickedJoin:!0,quickReplyMessage:{}})}onEventFormSubmit(){this.focusInput()}onContainerClick(){window.getSelection().toString().length>0||this.props.store.isMobile()||this.focusInput()}isFormRequired(){let 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)||{};if("ended"===a.state)return!0;a.state&&"pending"!==a.state&&delete o.group;let n=!0;return i.Z.each(o,(t=>{t.value&&(n=!1)})),!(!n||this.userHasSent(this.props.cid))||!!i.Z.find(o,(t=>t.is_required&&(null==t.value||""===t.value)))}renderConvoSummary(t){let e=this.props.plugin.chatbox||{},s=this.props.store.matchAgent("*"),r=i.Z.filter(t.members,(t=>("agent"===t.type||"bot"===t.type)&&"active"===t.membership)),a=i.Z.map(r,(t=>t.id));a=a||i.Z.agentsOfConvo(t)[0];let n=i.Z.map(a,(t=>s[t]||{avatar_url:ft,fullname:"Offline Agent"}));var l=i.Z.each(n,(t=>t.fullname)).join(", ");!e.hide_agent_profile&&l||(l=this.props.store.matchAccount().name),l||(l=this.props.t("agent"));var h=null;"user"===t.lastSenderType&&(h=(0,o.h)("span",null,this.props.t("you"),":"));let p=i.Z.isConvoSeen(t,this.props.store.matchUser().id);var d=this.renderMessagePreview(t.last_message_sent),c=i.Z.getMs(i.Z.get(t,"last_message_sent.created"))||i.Z.getMs(t.created);let u=p?null:(0,o.h)("div",{class:"convo-list--item-unread"});return"ended"===t.state&&(u=(0,o.h)("img",{alt:"conversation ended",class:"convo-list--convo-completed",src:gt,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"},l),(0,o.h)("div",{class:"convo-list--convo-time"},(0,o.h)($,{ago:!0,time:c,key:c,short:!0}))),(0,o.h)("div",{class:"d-flex flex-row"},(0,o.h)("div",{class:"convo-list--convo-last-message"},h,d),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:ft,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)))}hasSentMessage(t){let e=this.props.store.matchConvo(t)||{};return i.Z.find(e.members,(t=>"bot"===t.type||t.last_sent))}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),"emails"!=r.key||r.value||(r.value=i.Z.getUserAttr(s,"related_email","text")),"phones"!=r.key||r.value||(r.value=i.Z.getUserAttr(s,"related_phone","text")),"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 yt extends r.up{componentDidMount(){this.props.onMount(this.props.form)}}function bt(t){return encodeURIComponent(t)}let wt=s.e(178).then(s.bind(s,178));class Zt extends r.up{constructor(t){super(t),this.refButton=(0,o.Vf)(),this.refWidget=(0,o.Vf)()}async refreshCSS(){let t=this.props.store.matchPlugin(),e=i.Z.find(t,(t=>t.id===this.props.plugin.id));if(!e)return;let s=(await wt).default.default.toString();var r=i.Z.replaceCssVariable(s,e.chatbox);i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,r)}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.onConvoEvent(t))),this.props.store.onUpdate(this,(t=>this.checkExpand())),await this.refreshCSS(),this.setState({cssready:!0}),this.props.store.matchIsOpen()&&this.props.store.matchLastview().view){if(this.props.store.isMobile())return;this.showWidget(Object.assign({},this.props.store.matchLastview().opts,{view:this.props.store.matchLastview().view}))}else kt(),this.state.isShowWidget||this.hideWidget()}render(){return this.state.cssready?i.Z.isUserBanned(this.props.store.matchUser())?null:this.props.t?(0,o.h)("div",{class:this.props.store.isMobile()?"mobile":"desktop"},(0,o.h)(h,{plugin:this.props.plugin,store:this.props.store,key:"chat_button",ref:this.refButton,isShow:!this.state.isShowWidget,onClick:t=>this.showWidget(t),t:this.props.t}),(0,o.h)(_t,{plugin:this.props.plugin,store:this.props.store,view:this.state.widgetView,cid:this.state.widgetConvoId,isShow:this.state.isShowWidget,onClose:t=>this.onWidgetClose(t),onGo:t=>this.showWidget(t),t:this.props.t,ref:this.refWidget})):null:null}onConvoEvent(t){this.checkExpand(),this.checkShowBotConvo(t)}checkShowBotConvo(t){let e=this.refWidget.current;if(!e)return;if(e.wasFormInputed)return;if("message_sent"!==t.type)return;if(!this.state.isShowWidget)return;let s=i.Z.get(t,"by.type");if(!(i.Z.get(t,"by.id")||"").startsWith("bb")||"agent"!==s)return;let r=i.Z.get(t,"data.message.conversation_id");r&&this.showWidget({cid:r,view:"chat"})}checkExpand(){if(this.props.store.isMobile())return;if(this.props.plugin._no_auto_expand)return;if(this.props.store.matchHasManuallyClosed())return;let 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")}if(!(t=t||{}).view&&!t.cid){let e=this.props.store.matchConvo("*"),s=i.Z.find(e,(t=>!i.Z.isConvoSeen(t,this.props.store.matchUser().id)));t.cid=i.Z.get(s,"id",i.Z.get(e,"0.id")),t.view="chat"}this.props.store.isMobile()&&function(){document.body&&document.body.classList&&document.body.classList.add("sbz_no_scroll");let t=document.createElement("meta");t.httpEquiv="X-UA-Compatible",t.name="viewport",t.id="subiz-meta-viewport",t.content="maximum-scale=1.0, user-scalable=no, width=device-width, initial-scale=1.0",document.getElementsByTagName("head")[0].appendChild(t)}(),this.setState({widgetConvoId: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(){kt(),this.props.store.setIsOpen(!1),this.setState({isShowWidget:!1})}onWidgetClose(){this.refButton.current&&this.refButton.current.ClearPreview(),this.props.store.setHasManuallyClosed(),this.hideWidget()}}function kt(){document.body&&document.body.classList&&document.body.classList.remove("sbz_no_scroll");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.a27f0ac.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"}}]);
|
package/dist/18afb30d167.441.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[441],{7441:(e,t,n)=>{function s(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}n.r(t),n.d(t,{Hooks:()=>A,Lexer:()=>z,Marked:()=>I,Parser:()=>T,Renderer:()=>R,TextRenderer:()=>S,Tokenizer:()=>_,defaults:()=>r,getDefaults:()=>s,lexer:()=>C,marked:()=>Z,options:()=>q,parse:()=>B,parseInline:()=>P,parser:()=>Q,setOptions:()=>L,use:()=>v,walkTokens:()=>D});let r={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function i(e){r=e}const l=/[&<>"']/,o=new RegExp(l.source,"g"),a=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,c=new RegExp(a.source,"g"),h={"&":"&","<":"<",">":">",'"':""","'":"'"},p=e=>h[e];function u(e,t){if(t){if(l.test(e))return e.replace(o,p)}else if(a.test(e))return e.replace(c,p);return e}const g=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,k=/(^|[^\[])\^/g;function f(e,t){e="string"==typeof e?e:e.source,t=t||"";const n={replace:(t,s)=>(s=(s="object"==typeof s&&"source"in s?s.source:s).replace(k,"$1"),e=e.replace(t,s),n),getRegex:()=>new RegExp(e,t)};return n}function d(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const x={exec:()=>null};function b(e,t){const n=e.replace(/\|/g,((e,t,n)=>{let s=!1,r=t;for(;--r>=0&&"\\"===n[r];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function m(e,t,n){const s=e.length;if(0===s)return"";let r=0;for(;r<s;){const i=e.charAt(s-r-1);if(i!==t||n){if(i===t||!n)break;r++}else r++}return e.slice(0,s-r)}function w(e,t,n,s){const r=t.href,i=t.title?u(t.title):null,l=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:n,href:r,title:i,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,e}return{type:"image",raw:n,href:r,title:i,text:u(l)}}class _{options;rules;lexer;constructor(e){this.options=e||r}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:m(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const s=n[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=m(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=t[0].replace(/^ *>[ \t]?/gm,""),n=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");const i=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let l="",o="",a=!1;for(;e;){let n=!1;if(!(t=i.exec(e)))break;if(this.rules.block.hr.test(e))break;l=t[0],e=e.substring(l.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,o=s.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,o=s.slice(h),h+=t[1].length);let p=!1;if(!s&&/^ *$/.test(c)&&(l+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const a=e.split("\n",1)[0];if(c=a,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),r.test(c))break;if(i.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=h||!c.trim())o+="\n"+c.slice(h);else{if(p)break;if(s.search(/[^ ]/)>=4)break;if(r.test(s))break;if(i.test(s))break;if(n.test(s))break;o+="\n"+c}p||c.trim()||(p=!0),l+=a+"\n",e=e.substring(a.length+1),s=c.slice(h)}}r.loose||(a?r.loose=!0:/\n *\n *$/.test(l)&&(a=!0));let u,g=null;this.options.gfm&&(g=/^\[[ xX]\] /.exec(o),g&&(u="[ ] "!==g[0],o=o.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:l,task:!!g,checked:u,loose:!1,text:o,tokens:[]}),r.raw+=l}r.items[r.items.length-1].raw=l.trimEnd(),r.items[r.items.length-1].text=o.trimEnd(),r.raw=r.raw.trimEnd();for(let e=0;e<r.items.length;e++)if(this.lexer.state.top=!1,r.items[e].tokens=this.lexer.blockTokens(r.items[e].text,[]),!r.loose){const t=r.items[e].tokens.filter((e=>"space"===e.type)),n=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));r.loose=n}if(r.loose)for(let e=0;e<r.items.length;e++)r.items[e].loose=!0;return r}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(t){if(!/[:|]/.test(t[2]))return;const e={type:"table",raw:t[0],header:b(t[1]).map((e=>({text:e,tokens:[]}))),align:t[2].replace(/^\||\| *$/g,"").split("|"),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(e.header.length===e.align.length){let t,n,s,r,i=e.align.length;for(t=0;t<i;t++){const n=e.align[t];n&&(/^ *-+: *$/.test(n)?e.align[t]="right":/^ *:-+: *$/.test(n)?e.align[t]="center":/^ *:-+ *$/.test(n)?e.align[t]="left":e.align[t]=null)}for(i=e.rows.length,t=0;t<i;t++)e.rows[t]=b(e.rows[t],e.header.length).map((e=>({text:e,tokens:[]})));for(i=e.header.length,n=0;n<i;n++)e.header[n].tokens=this.lexer.inline(e.header[n].text);for(i=e.rows.length,n=0;n<i;n++)for(r=e.rows[n],s=0;s<r.length;s++)r[s].tokens=this.lexer.inline(r[s].text);return e}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:u(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=m(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),w(t,{href:n?n.replace(this.rules.inline._escapes,"$1"):n,title:s?s.replace(this.rules.inline._escapes,"$1"):s},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(/\s+/g," ");if(e=t[e.toLowerCase()],!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return w(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrong.lDelim.exec(e);if(s&&(!s[3]||!n.match(/[\p{L}\p{N}]/u))&&(!s[1]&&!s[2]||!n||this.rules.inline.punctuation.exec(n))){const n=[...s[0]].length-1;let r,i,l=n,o=0;const a="*"===s[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+s[0].length-1);null!=(s=a.exec(t));){if(r=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!r)continue;if(i=[...r].length,s[3]||s[4]){l+=i;continue}if((s[5]||s[6])&&n%3&&!((n+i)%3)){o+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+o);const t=[...e].slice(0,n+s.index+i+1).join("");if(Math.min(n,i)%2){const e=t.slice(1,-1);return{type:"em",raw:t,text:e,tokens:this.lexer.inlineTokens(e)}}const a=t.slice(2,-2);return{type:"strong",raw:t,text:a,tokens:this.lexer.inlineTokens(a)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return n&&s&&(e=e.substring(1,e.length-1)),e=u(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=u(t[1]),n="mailto:"+e):(e=u(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=u(t[0]),n="mailto:"+e;else{let s;do{s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])[0]}while(s!==t[0]);e=u(t[0]),n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:u(t[0]),{type:"text",raw:t[0],text:e}}}}const y={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:x,lheading:/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\.|[^\[\]\\])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};y.def=f(y.def).replace("label",y._label).replace("title",y._title).getRegex(),y.bullet=/(?:[*+-]|\d{1,9}[.)])/,y.listItemStart=f(/^( *)(bull) */).replace("bull",y.bullet).getRegex(),y.list=f(y.list).replace(/bull/g,y.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+y.def.source+")").getRegex(),y._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",y._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,y.html=f(y.html,"i").replace("comment",y._comment).replace("tag",y._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),y.lheading=f(y.lheading).replace(/bull/g,y.bullet).getRegex(),y.paragraph=f(y._paragraph).replace("hr",y.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",y._tag).getRegex(),y.blockquote=f(y.blockquote).replace("paragraph",y.paragraph).getRegex(),y.normal={...y},y.gfm={...y.normal,table:"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},y.gfm.table=f(y.gfm.table).replace("hr",y.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",y._tag).getRegex(),y.gfm.paragraph=f(y._paragraph).replace("hr",y.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",y.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",y._tag).getRegex(),y.pedantic={...y.normal,html:f("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",y._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:x,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:f(y.normal._paragraph).replace("hr",y.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",y.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const $={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:x,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,rDelimAst:/^[^_*]*?__[^_*]*?\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\*)[punct](\*+)(?=[\s]|$)|[^punct\s](\*+)(?!\*)(?=[punct\s]|$)|(?!\*)[punct\s](\*+)(?=[^punct\s])|[\s](\*+)(?!\*)(?=[punct])|(?!\*)[punct](\*+)(?!\*)(?=[punct])|[^punct\s](\*+)(?=[^punct\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\s]|$)|[^punct\s](_+)(?!_)(?=[punct\s]|$)|(?!_)[punct\s](_+)(?=[^punct\s])|[\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:x,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^((?![*_])[\spunctuation])/,_punctuation:"\\p{P}$+<=>`^|~"};$.punctuation=f($.punctuation,"u").replace(/punctuation/g,$._punctuation).getRegex(),$.blockSkip=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,$.anyPunctuation=/\\[punct]/g,$._escapes=/\\([punct])/g,$._comment=f(y._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),$.emStrong.lDelim=f($.emStrong.lDelim,"u").replace(/punct/g,$._punctuation).getRegex(),$.emStrong.rDelimAst=f($.emStrong.rDelimAst,"gu").replace(/punct/g,$._punctuation).getRegex(),$.emStrong.rDelimUnd=f($.emStrong.rDelimUnd,"gu").replace(/punct/g,$._punctuation).getRegex(),$.anyPunctuation=f($.anyPunctuation,"gu").replace(/punct/g,$._punctuation).getRegex(),$._escapes=f($._escapes,"gu").replace(/punct/g,$._punctuation).getRegex(),$._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,$._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,$.autolink=f($.autolink).replace("scheme",$._scheme).replace("email",$._email).getRegex(),$._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,$.tag=f($.tag).replace("comment",$._comment).replace("attribute",$._attribute).getRegex(),$._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,$._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,$._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,$.link=f($.link).replace("label",$._label).replace("href",$._href).replace("title",$._title).getRegex(),$.reflink=f($.reflink).replace("label",$._label).replace("ref",y._label).getRegex(),$.nolink=f($.nolink).replace("ref",y._label).getRegex(),$.reflinkSearch=f($.reflinkSearch,"g").replace("reflink",$.reflink).replace("nolink",$.nolink).getRegex(),$.normal={...$},$.pedantic={...$.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:f(/^!?\[(label)\]\((.*?)\)/).replace("label",$._label).getRegex(),reflink:f(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",$._label).getRegex()},$.gfm={...$.normal,escape:f($.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},$.gfm.url=f($.gfm.url,"i").replace("email",$.gfm._extended_email).getRegex(),$.breaks={...$.gfm,br:f($.br).replace("{2,}","*").getRegex(),text:f($.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};class z{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||r,this.options.tokenizer=this.options.tokenizer||new _,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:y.normal,inline:$.normal};this.options.pedantic?(t.block=y.pedantic,t.inline=$.pedantic):this.options.gfm&&(t.block=y.gfm,this.options.breaks?t.inline=$.breaks:t.inline=$.gfm),this.tokenizer.rules=t}static get rules(){return{block:y,inline:$}}static lex(e,t){return new z(t).lex(e)}static lexInline(e,t){return new z(t).inlineTokens(e)}lex(e){let t;for(e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){let n,s,r,i;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,n)=>t+" ".repeat(n.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(n):(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(s.raw+="\n"+n.raw,s.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(r=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r)))s=t[t.length-1],i&&"paragraph"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n),i=r.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+n.raw,s.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,s,r,i,l,o,a=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(a));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(a));)a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(a));)a=a.slice(0,i.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(l||(o=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(n=s.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),s=t[t.length-1],s&&"text"===n.type&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,a,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(r=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},n),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(r))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),l=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=n.raw,s.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class R{options;constructor(e){this.options=e||r}code(e,t,n){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+u(s)+'">'+(n?e:u(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:u(e,!0))+"</code></pre>\n"}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,n){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}list(e,t,n){const s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+s+">\n"}listitem(e,t,n){return`<li>${e}</li>\n`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>\n`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){const s=d(e);if(null===s)return n;let r='<a href="'+(e=s)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>",r}image(e,t,n){const s=d(e);if(null===s)return n;let r=`<img src="${e=s}" alt="${n}"`;return t&&(r+=` title="${t}"`),r+=">",r}text(e){return e}}class S{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class T{options;renderer;textRenderer;constructor(e){this.options=e||r,this.options.renderer=this.options.renderer||new R,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new S}static parse(e,t){return new T(t).parse(e)}static parseInline(e,t){return new T(t).parseInline(e)}parse(e,t=!0){let n="";for(let s=0;s<e.length;s++){const r=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const e=r,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){n+=t||"";continue}}switch(r.type){case"space":continue;case"hr":n+=this.renderer.hr();continue;case"heading":{const e=r;n+=this.renderer.heading(this.parseInline(e.tokens),e.depth,this.parseInline(e.tokens,this.textRenderer).replace(g,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")));continue}case"code":{const e=r;n+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=r;let t="",s="";for(let t=0;t<e.header.length;t++)s+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(s);let i="";for(let t=0;t<e.rows.length;t++){const n=e.rows[t];s="";for(let t=0;t<n.length;t++)s+=this.renderer.tablecell(this.parseInline(n[t].tokens),{header:!1,align:e.align[t]});i+=this.renderer.tablerow(s)}n+=this.renderer.table(t,i);continue}case"blockquote":{const e=r,t=this.parse(e.tokens);n+=this.renderer.blockquote(t);continue}case"list":{const e=r,t=e.ordered,s=e.start,i=e.loose;let l="";for(let t=0;t<e.items.length;t++){const n=e.items[t],s=n.checked,r=n.task;let o="";if(n.task){const e=this.renderer.checkbox(!!s);i?n.tokens.length>0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):o+=e+" "}o+=this.parse(n.tokens,i),l+=this.renderer.listitem(o,r,!!s)}n+=this.renderer.list(l,t,s);continue}case"html":{const e=r;n+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=r;n+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let i=r,l=i.tokens?this.parseInline(i.tokens):i.text;for(;s+1<e.length&&"text"===e[s+1].type;)i=e[++s],l+="\n"+(i.tokens?this.parseInline(i.tokens):i.text);n+=t?this.renderer.paragraph(l):l;continue}default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let s=0;s<e.length;s++){const r=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}switch(r.type){case"escape":{const e=r;n+=t.text(e.text);break}case"html":{const e=r;n+=t.html(e.text);break}case"link":{const e=r;n+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=r;n+=t.image(e.href,e.title,e.text);break}case"strong":{const e=r;n+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=r;n+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=r;n+=t.codespan(e.text);break}case"br":n+=t.br();break;case"del":{const e=r;n+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=r;n+=t.text(e.text);break}default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}}class A{options;constructor(e){this.options=e||r}static passThroughHooks=new Set(["preprocess","postprocess"]);preprocess(e){return e}postprocess(e){return e}}class I{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(z.lex,T.parse);parseInline=this.#e(z.lexInline,T.parseInline);Parser=T;parser=T.parse;Renderer=R;TextRenderer=S;Lexer=z;lexer=z.lex;Tokenizer=_;Hooks=A;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(const s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{const e=s;for(const s of e.header)n=n.concat(this.walkTokens(s.tokens,t));for(const s of e.rows)for(const e of s)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=s;n=n.concat(this.walkTokens(e.items,t));break}default:{const e=s;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((s=>{n=n.concat(this.walkTokens(e[s],t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=n.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new R(this.defaults);for(const n in e.renderer){const s=e.renderer[n],r=n,i=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new _(this.defaults);for(const n in e.tokenizer){const s=e.tokenizer[n],r=n,i=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new A;for(const n in e.hooks){const s=e.hooks[n],r=n,i=t[r];A.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(s.call(t,e)).then((e=>i.call(t,e)));const n=s.call(t,e);return i.call(t,n)}:t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(s.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}#e(e,t){return(n,s)=>{const r={...s},i={...this.defaults,...r};!0===this.defaults.async&&!1===r.async&&(i.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),i.async=!0);const l=this.#t(!!i.silent,!!i.async);if(null==n)return l(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(i.hooks&&(i.hooks.options=i),i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then((t=>e(t,i))).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>t(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(l);try{i.hooks&&(n=i.hooks.preprocess(n));const s=e(n,i);i.walkTokens&&this.walkTokens(s,i.walkTokens);let r=t(s,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return l(e)}}}#t(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+u(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}}const E=new I;function Z(e,t){return E.parse(e,t)}Z.options=Z.setOptions=function(e){return E.setOptions(e),Z.defaults=E.defaults,i(Z.defaults),Z},Z.getDefaults=s,Z.defaults=r,Z.use=function(...e){return E.use(...e),Z.defaults=E.defaults,i(Z.defaults),Z},Z.walkTokens=function(e,t){return E.walkTokens(e,t)},Z.parseInline=E.parseInline,Z.Parser=T,Z.parser=T.parse,Z.Renderer=R,Z.TextRenderer=S,Z.Lexer=z,Z.lexer=z.lex,Z.Tokenizer=_,Z.Hooks=A,Z.parse=Z;const q=Z.options,L=Z.setOptions,v=Z.use,D=Z.walkTokens,P=Z.parseInline,B=Z,Q=T.parse,C=z.lex}}]);
|