@subiz/widget-v4 4.1.141 → 4.1.143
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/assets/img/stars_v2.png +0 -0
- package/assets/less/form-page.less +1 -1
- package/assets/less/form.less +79 -0
- package/compiled_src/chatbox/Widget.js +2 -2
- package/compiled_src/form/Form.js +19 -5
- package/compiled_src/form/rating-stars.js +129 -0
- package/dist/19680dc0775.278.js +1 -0
- package/dist/19680dc0775.app.js +1 -0
- package/dist/19680dc0775.form.html +1 -0
- package/dist/19680dc0775.form.js +1 -0
- package/dist/{1967c022bc1.index.html → 19680dc0775.index.html} +1 -1
- package/dist/{1967c022bc1.library.html → 19680dc0775.library.html} +1 -1
- package/dist/19680dc0775.library.js +1 -0
- package/dist/{1967c022bc1.preview.html → 19680dc0775.preview.html} +1 -1
- package/dist/19680dc0775.preview.js +1 -0
- package/dist/19680dc0775.webview.js +1 -0
- package/dist/278.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +79 -90
- package/package.json +1 -1
- package/src/chatbox/FormAttachment2.js +83 -0
- package/src/chatbox/Widget.js +2 -2
- package/src/form/Form.js +54 -36
- package/src/form/FormPage.js +81 -1
- package/src/form/rating-stars.js +89 -0
- package/dist/1967c022bc1.278.js +0 -1
- package/dist/1967c022bc1.app.js +0 -1
- package/dist/1967c022bc1.form.html +0 -1
- package/dist/1967c022bc1.form.js +0 -1
- package/dist/1967c022bc1.library.js +0 -1
- package/dist/1967c022bc1.preview.js +0 -1
- package/dist/1967c022bc1.webview.js +0 -1
- /package/dist/{1967c022bc1.127.js → 19680dc0775.127.js} +0 -0
- /package/dist/{1967c022bc1.132.js → 19680dc0775.132.js} +0 -0
- /package/dist/{1967c022bc1.185.js → 19680dc0775.185.js} +0 -0
- /package/dist/{1967c022bc1.27.js → 19680dc0775.27.js} +0 -0
- /package/dist/{1967c022bc1.459.js → 19680dc0775.459.js} +0 -0
- /package/dist/{1967c022bc1.490.js → 19680dc0775.490.js} +0 -0
- /package/dist/{1967c022bc1.74.js → 19680dc0775.74.js} +0 -0
- /package/dist/{1967c022bc1.997.js → 19680dc0775.997.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<html><head><meta name="viewport" content="width=device-width,initial-scale=1"/></head><body><div id="form"></div><script defer="defer" src="https://vcdn.subiz-cdn.com/widget-v4/public/1967c022bc1.form.js"></script></body></html>
|
package/dist/1967c022bc1.form.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var e,t,n={9:(e,t,i)=>{var n=i(9143);e.exports=function(e,t,i){var r=[],s="idle",o=function(e){var t=e.map((function(e){return e.payload})),n=i(t);n&&n.then||(n=Promise.resolve(n));var r=e.map((function(e){return e.rs}));return new Promise((function(e){n.then((function(t){r.map((function(e,i){e(t&&t[i])})),e()}))}))},a=function(){"executing"!==s&&(s="executing",n((function(){if(r.length<=e)return Promise.resolve(!1);var t=r.splice(0,e);return o(t).then((function(){return!0}))})).then((function(){if(0!==r.length){var e=t-(Date.now()-r[0].created);if(e>=1){if(s="idle",r[0].settedTimeout)return;return r[0].settedTimeout=!0,void setTimeout(a,e)}var i=r;r=[],o(i).then((function(){s="idle",a()}))}else s="idle"})))};return this.push=function(e,t){return new Promise((function(i){r.push({payload:e,priority:t,created:Date.now(),rs:i}),a()}))},this}},318:e=>{var t="Content-Type",i="application/x-www-form-urlencoded",n="application/json; charset=utf-8";function r(e,t){return Object.assign(e.clone(),t)}var s={code:"network_error,retry",number:"SBZ-EQNETWORK",message:{En_US:"Can not connect to the server. Please check your internet connection.",Vi_VN:"Không thể kết nối tới máy chủ. Vui lòng kiểm tra lại kết nối mạng."}},o={code:"invalid_response,retry",number:"SBZ-EQRESPONSE",message:{En_US:"Server error, please try again later",Vi_VN:"Lỗi máy chủ, vui lòng thử lại sau"}},a={code:"not_200,retry",number:"SBZ-EQCN200",message:{En_US:"Error while connecting to the server, please try again later",Vi_VN:"Lỗi kết nối với máy chủ, vui lòng thử lại sau"}};function c(e){return(e||"").trim()}function u(e){return e&&"[object Function]"==={}.toString.call(e)}function l(e,t,i){if(!e||0===e.length)return i(t);var n=e.shift();if(!u(n))return l(e,t,i);n(t,(function(n){return!1===n?i(t):l(e,t,i)}))}function h(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16)}))}function d(e){if(!e)return"";for(var t=Object.keys(e),i=[],n=0;n<t.length;n++){var r=t[n],s="",o=e[r];if(void 0!==o){if(null===o)s=h(r);else if(Array.isArray(o)){for(var a=[],c=0;c<o.length;c++)void 0!==o[c]&&(a.push(p(r,o[c],a.length)),a.push(i));s=a.join("&")}else s=h(r)+"="+h(o);s.length>0&&i.push(s)}}return i.join("&")}function p(e,t){return null===t?h(e):[h(e),"=",h(t)].join("")}var f,_=(f={parser:"",beforehooks:[],afterhooks:[],baseurl:"",query:{},clone:function(){return Object.assign({},this,{query:Object.assign({},this.query)})},addQuery:function(e,t){var i=this.clone();return i.query[e]=t,i},removeQuery:function(e){var t=this.clone();return void 0!==t.query[e]&&(t.query[e]=void 0),t},withCredentials:function(e){return r(this,{_withCredentials:e})},setQuery:function(e){return r(this,{query:e})},clearHooks:function(){return r(this,{beforehooks:[],afterhooks:[]})},beforeHook:function(e){var t=this.beforehooks.slice();return t.push(e),r(this,{beforehooks:t})},afterHook:function(e){var t=this.afterhooks.slice();return t.push(e),r(this,{afterhooks:t})},setHeader:function(e){return(e=Object.assign({},this.headers,e))[t]=void 0,r(this,{headers:e})}},["put","head","patch","delete","post","get"].map((function(e){f[e]=function(h,p,f){return function(e,r,c){c=c||function(){},u(r)&&(c=r,r=void 0);var h,p=new Promise((function(e){h=function(t){try{c(t.error,t.body,t.code)}catch(e){}e(t)}}));return r&&((e=e.clone()).body=r,e.content_type===n&&(e.body=m.Jsonify(r)),e.content_type===i&&(e.body=d(r))),l(e.beforehooks.slice(),{request:e},(function(i){if(i.error)return h({body:{error:bq.error},code:0,error:i.error});!function(e,i){let n=d(e.query);if(n&&(n="?"+n),!m.XMLHttpRequest)return function(e,i,n){var r=Object.assign({},e.headers);e.content_type&&(r[t]=e.content_type),fetch(e.baseurl+n,{method:e.method,headers:r,credentials:e._withCredentials,body:e.body}).then((function(e){return e.text()})).then((function(e){i(void 0,e,res.status)})).catch((function(e){i("network_error",e,-1)}))}(e,i,n);var r=new m.XMLHttpRequest;for(var s in r.onreadystatechange=function(e){4===r.readyState&&(0===r.status?i("network_error",r.responseText,r.status):i(void 0,r.responseText,r.status))},r.open(e.method,e.baseurl+n),r.withCredentials=e._withCredentials,e.headers)r.setRequestHeader(s,e.headers[s]);e.content_type&&r.setRequestHeader(t,e.content_type),r.send(e.body)}(i.request,(function(t,i,n){l(e.afterhooks.slice(),{request:e,code:n,body:i,err:t},(function(t){var i=t.body;if("network_error"==r)return h({body:{error:s},code:t.code,error:s});if("json"==e.parser&&t.body)try{i=m.ParseJson(t.body)}catch(e){return h({body:{error:o,origin_body:t.body},code:t.code,error:o})}var r=t.err;if("network_error"==r)return h({body:{error:s},code:t.code,error:s});!r&&(n<200||n>299)&&(r=i&&i.error?i.error:a),h({body:r?i||{error:r}:i,code:t.code,error:r})}))}))})),p}(r(this,{method:e,baseurl:(_=this.baseurl,g=h,_=c(_),(g=c(g))&&_?g.startsWith("http://")||g.startsWith("https://")||g.startsWith("//")?g:(_.endsWith("/")||(_+="/"),g.startsWith("/")&&(g=g.substring(1)),_+g):_+g)}),p,f);var _,g}})),f.setBaseUrl=function(e){return r(this,{baseurl:e})},f.contentTypeJson=function(){return r(this,{content_type:n})},f.contentTypeForm=function(){return r(this,{content_type:i})},f.setContentType=function(e){return r(this,{content_type:c(e)})},f.setParser=function(e){return r(this,{parser:c(e)})},f.setBody=function(e){return r(this,{body:e})},f),m={Jsonify:JSON.stringify,ParseJson:JSON.parse};_.env=m,_.waterfall=l,e.exports=_},450:e=>{var t={},i={};t.length=0,t.getItem=function(e){return e in i?i[e]:null},t.setItem=function(e,n){void 0===n?t.removeItem(e):(Object.prototype.hasOwnProperty.call(i,e)||t.length++,i[e]=n)},t.removeItem=function(e){Object.prototype.hasOwnProperty.call(i,e)&&(delete i[e],t.length--)},t.key=function(e){return Object.keys(i)[e]||null},t.clear=function(){i={},t.length=0},e.exports=t},1139:(e,t,i)=>{"use strict";i.d(t,{A:()=>n});class n{constructor(e){this.isOpen=!0===e,this.cbs=[]}open(){this.isOpen=!0;let e=[];this.cbs.forEach((t=>{this.isOpen?t():e.push(t)})),this.cbs=e}close(){this.isOpen=!1}entry(e,t){return this.isOpen?(t&&(this.isOpen=!1),e&&e(),Promise.resolve()):new Promise((i=>{this.cbs.push((()=>{t&&(this.isOpen=!1),e&&e(),i()}))}))}}},2839:(e,t,i)=>{var n=i(8193),{xhrsend:r,parseJSON:s,Pubsub:o}=i(7695);function a(e,t,i,o,a,h){a=a||r,t=t||{};var d="";h||(h="");var p=!1,f=!1,_=!1,m=function(t){p||a("get",e+"poll?token="+d+"&account-id="+h,void 0,(function(i,n){if(!p){if(c(n))return f=!0,setTimeout(m,function(e){if(!e||-1===e)return 0;var t=1e3*Math.pow(1.5,e);return Math.min(1e4,t)}(t),t+1);if(200!==n)return f=!0,y("poll");f=!1,(i=s(i)||{}).host&&(e=l(i.host));var r=i.sequential_token;return r?(d=r,o(i.events||[]),m(0)):y("poll")}}))},g=n.batch(50,100,(function(i){if(p)return Promise.resolve(u("dead",i.length));if(i.length<=0)return Promise.resolve([]);var r,o=new Promise((e=>{r=e})),f=!1;return setTimeout((function(){f||p||(_=!0)}),4e3),setTimeout((()=>{f||(f=!0,r(u("dead",i.length)),p||y("subs"))}),6e4),n.loop((function(){return new Promise((function(n){if(p)return r(u("dead",i.length)),n(!1);var o="?token="+d;t.getAccessToken().then((function(g){if(p)return r(u("dead",i.length)),n(!1);t.user_ref?o+="&user_ref="+encodeURIComponent(t.user_ref):t.user_mask?o+="&user-mask="+encodeURIComponent(t.user_mask):g&&(o+="&access-token="+g);var v=e+"subs"+o+"&account-id="+encodeURIComponent(h||t.account_id);a("post",v,JSON.stringify({events:i}),(function(t,o){if(!f){if(p)return r(u("dead",i.length)),n(!1);if(c(o))return _=!0,setTimeout(n,3e3,!0);if(200!==o)return y("subs"),r(u("dead",i.length)),n(!1);if(_=!1,f=!0,d)return r(i),n(!1);var a=(t=s(t)||{}).initial_token;return a?(t.host&&(e=l(t.host)),d=a,m(0),r(i),n(!1)):(y("subs"),r(u("dead",i.length)),n(!1))}}))}))}))})),o}));this.subscribe=g.push.bind(g),this.getStatus=function(){return p?"dead":_||f?"connecting":"active"};var y=function(e){p=!0,i(e)};this.kill=y}function c(e){return e>=500&&e<600||0===e||-1===e||429===e}function u(e,t){for(var i=[],n=0;n<t;n++)i.push(e);return i}function l(e){return(e=e||"").startsWith("//")?"https:"+e:e}e.exports=function(e,t,i,n,r){("string"==typeof e||e instanceof String)&&(e=[e]),(t=t||{}).getAccessToken||(t.getAccessToken=function(){return Promise.resolve("")}),n||(n=t.account_id||"");var s,c=new o,u={};this.stop=function(){s&&(s.kill(),s=void 0,c.emit("interrupted"))},this.onEvent=function(e){return c.on("event",e)},this.onInterrupted=function(e){return c.on("interrupted",e)},this.getStatus=function(){return s?s.getStatus():"dead"},this.subscribe=function(e){if(!s)return Promise.resolve({error:"dead"});if("string"==typeof e&&(e=[e]),!Array.isArray(e))return Promise.resolve({error:"param should be an array or string"});for(var t=[],i=0;i<e.length;i++){var n=e[i];n&&(u[n]||(u[n]=!0,t.push(s.subscribe(n))))}return 0===t.length?Promise.resolve({}):Promise.all(t).then((function(){return s&&"dead"!=s.getStatus()?{}:{error:"dead"}}))},this.reconnect=function(){var o=e[Math.floor(Math.random()*e.length)];s&&s.kill();let l=new a(o,t,(function(e,t,i){l==s&&(c.emit("interrupted",e,t,i),r||setTimeout(this.reconnect,2e3))}),(function(e){if(l==s)for(var t=0;t<e.length;t++)c.emit("event",e[t])}),i,n);s=l;var h=Object.keys(u);return u={},this.subscribe(h)},this.reconnect()}},3259:(e,t,i)=>{"use strict";i.r(t),i.d(t,{get:()=>a,set:()=>c});var n=Object.prototype.toString,r=Array.isArray||function(e){return"[object Array]"===n.call(e)};function s(e){var t=parseInt(e);return t.toString()===e?t:e}function o(e,t){if(function(e,t){return"number"==typeof t&&r(e)||function(e,t){return null!=e&&Object.prototype.hasOwnProperty.call(e,t)}(e,t)}(e,t))return e[t]}function a(e,t,i){if("number"==typeof t&&(t=[t]),!t||0===t.length)return e;if(null==e)return i;if("string"==typeof t)return a(e,t.split("."),i);var n=s(t[0]),r=o(e,n);return void 0===r?i:1===t.length?r:a(e[n],t.slice(1),i)}function c(e,t,i){if("number"==typeof t&&(t=[t]),!t||0===t.length)return e;if("string"==typeof t)return c(e,t.split(".").map(s),i);var n=t[0],r=o(e,n);return 1===t.length?(e[n]=i,r):(void 0===r&&(e[n]="number"==typeof t[1]?[]:{}),c(e[n],t.slice(1),i))}},5180:e=>{e.exports={ApiURL:"https://api.sbz.vn/4.0",RealtimeURL:"https://api.sbz.vn/rt/0/",FileURL:"https://vcdn.subiz-cdn.com/file/",BaseURL:"https://widget.sbz.vn"}},5219:(e,t,i)=>{var n=i(9096);e.exports=function(e,t,i){if("number"==typeof t){let e=i;i=t,t=e}t||(t=function(){}),("number"!=typeof i||i<=0)&&(i=1);var r={};if(n.map(e,(function(e,t){r[t]=e})),i<=0&&(i=1),0===Object.keys(r).length)return Promise.resolve([]);Object.keys(r).length<i&&(i=Object.keys(r).length);var s={};return new Promise((function(e){let o=Object.keys(r).length;for(var a=function(){var i=Object.keys(r);if(0!==i.length){var c=i.shift(),u=r[c];delete r[c];var l=t(u,c);l&&l.then||(l=Promise.resolve(l)),l.then((function(t){if(s[c]=t,Object.keys(s).length===o)return e(n.map(s));a()}))}},c=0;c<i;c++)setTimeout(a,1)}))}},5369:(e,t,i)=>{"use strict";i.d(t,{A:()=>n});class n{constructor(){this.isOpen=!0,this.cbs=[]}_check(){if(!this.isOpen)return;let e=this.cbs.pop();e&&(this.isOpen=!1,e())}lock(){return new Promise((e=>{this.cbs.push(e),this._check()}))}unlock(){this.isOpen||(this.isOpen=!0,this._check())}}},5672:function(e){e.exports=function(){"use strict";var e=function(){return e.get.apply(e,arguments)},t=e.utils={isArray:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},isPlainObject:function(e){return!!e&&"[object Object]"===Object.prototype.toString.call(e)},toArray:function(e){return Array.prototype.slice.call(e)},getKeys:Object.keys||function(e){var t=[],i="";for(i in e)e.hasOwnProperty(i)&&t.push(i);return t},encode:function(e){return String(e).replace(/[,;"\\=\s%]/g,(function(e){return encodeURIComponent(e)}))},decode:function(e){return decodeURIComponent(e)},retrieve:function(e,t){return null==e?t:e}};return e.defaults={},e.expiresMultiplier=86400,e.set=function(e,i,n){if(t.isPlainObject(e))for(var r in e)e.hasOwnProperty(r)&&this.set(r,e[r],i);else{var s=void 0!==(n=t.isPlainObject(n)?n:{expires:n}).expires?n.expires:this.defaults.expires||"",o=typeof s;"string"===o&&""!==s?s=new Date(s):"number"===o&&(s=new Date(+new Date+1e3*this.expiresMultiplier*s)),""!==s&&"toUTCString"in s&&(s=";expires="+s.toUTCString());var a=n.path||this.defaults.path;a=a?";path="+a:"";var c=n.domain||this.defaults.domain;c=c?";domain="+c:"";var u=n.secure||this.defaults.secure?";secure":"";!1===n.secure&&(u="");var l=n.sameSite||this.defaults.sameSite;l=l?";SameSite="+l:"",null===n.sameSite&&(l=""),document.cookie=t.encode(e)+"="+t.encode(i)+s+a+c+u+l}return this},e.setDefault=function(i,n,r){if(t.isPlainObject(i)){for(var s in i)void 0===this.get(s)&&this.set(s,i[s],n);return e}if(void 0===this.get(i))return this.set.apply(this,arguments)},e.remove=function(e){for(var i=0,n=(e=t.isArray(e)?e:t.toArray(arguments)).length;i<n;i++)this.set(e[i],"",-1);return this},e.removeSpecific=function(e,i){if(!i)return this.remove(e);e=t.isArray(e)?e:[e],i.expires=-1;for(var n=0,r=e.length;n<r;n++)this.set(e[n],"",i);return this},e.empty=function(){return this.remove(t.getKeys(this.all()))},e.get=function(e,i){var n=this.all();if(t.isArray(e)){for(var r={},s=0,o=e.length;s<o;s++){var a=e[s];r[a]=t.retrieve(n[a],i)}return r}return t.retrieve(n[e],i)},e.all=function(){if(""===document.cookie)return{};for(var e=document.cookie.split("; "),i={},n=0,r=e.length;n<r;n++){var s=e[n].split("="),o=t.decode(s.shift()),a=t.decode(s.join("="));i[o]=a}return i},e.enabled=function(){if(navigator.cookieEnabled)return!0;var t="_"===e.set("_","_").get("_");return e.remove("_"),t},e}()},6463:(e,t,i)=>{"use strict";i.d(t,{A:()=>s});var{filter:n,map:r}=i(9917);class s{constructor(){this.listeners={}}publish(e,t,i,s){this.listeners[e]=n(this.listeners[e],(e=>e.obj._isMounted)),r(this.listeners[e],(({cb:e})=>e(t,i,s)))}on2(e,t,i){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push({obj:e,cb:i})}}},7695:e=>{function t(e){return e<10?`0${e}`:`${e}`}var i=function(e,t,i,n){if("undefined"==typeof XMLHttpRequest)return function(e,t,i,n){let r={};i&&(r["content-type"]="text/plain"),fetch(t,{method:e,headers:r,body:i}).then((e=>e.text().then((t=>n&&n(t,e.status))))).catch((e=>n&&n(e,-1)))}(e,t,i,n);var r=new XMLHttpRequest;r.onreadystatechange=function(e){4===r.readyState&&(n&&n(r.responseText,r.status),n=void 0)},r.onerror=function(){n&&n(r.responseText,-1),n=void 0},r.open(e,t),i&&r.setRequestHeader("content-type","text/plain"),r.send(i)};e.exports={xhrsend:i,parseJSON:function(e){try{return JSON.parse(e)}catch(e){}},Pubsub:function(){var e={};this.emit=function(t){for(var i=[],n=1;n<arguments.length;n++)i.push(arguments[n]);var r=e[t];if(r)for(n=0;n<r.length;n++)r[n].apply(void 0,i)},this.on=function(t,i){e[t]||(e[t]=[]),e[t].push(i)}},randomString:function(e,t){var i,n="";(!e||e<1)&&(e=10);for(var r=0;r<e;r++)t?n+=t[Math.floor(Math.random()*t.length)]:(i=Math.floor(25*Math.random()+97),n+=String.fromCharCode(i));return n},logError:function(e,n,r,s){let o=function(e){let i=e.getUTCFullYear().toString().substr(2,2),n=e.getUTCMonth()+1,r=e.getUTCDate(),s=e.getUTCHours(),o=e.getUTCMinutes(),a=e.getUTCSeconds();return`${i}-${t(n)}-${t(r)} ${t(s)}:${t(o)}:${t(a)}`}(new Date),a=JSON.stringify({id:Date.now(),class:400,code:"frontend_error",number:s.split("").map((e=>e.charCodeAt(0).toString(16).padStart(2,"0"))).join(""),fields:{message:JSON.stringify(r),user_id:n,url:JSON.stringify(location.href)}});i("POST","https://track.subiz.net/collect",`${o} app ERROR dashboard ${e} ${s} ${a}`)}}},8193:(e,t,i)=>{var n=i(9798),r=i(9143),s=i(5219),o=i(9);e.exports={sleep:n,loop:r,map:s,batch:o}},9096:e=>{e.exports={map:function(e,t){if(!e)return[];t||(t=function(e){return e});var i=[];if(Array.isArray(e)){for(var n=0;n<e.length;n++)i.push(t(e[n],n));return i}if("object"==typeof e){var r=Object.keys(e);for(n=0;n<r.length;n++){var s=r[n];i.push(t(e[s],s))}return i}return i}}},9143:e=>{e.exports=function e(t){var i=t();if(!i||!i.then){var n=i;i={then:function(e){e(n)}}}return i.then((function(i){return i?e(t):Promise.resolve()}))}},9798:e=>{e.exports=function(e){return new Promise((function(t){setTimeout(t,e)}))}},9917:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DEFVAL:()=>de,DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL:()=>he,Date:()=>v,XMLHttpRequest:()=>C,agentsOfConvo:()=>q,blockToText:()=>Le,checkRunConditions:()=>_e,clearInterval:()=>x,clearTimeout:()=>S,cloneDeep:()=>P,convoOfEv:()=>O,convoToEv:()=>T,detectLang:()=>Te,diffDay:()=>we,diffYear:()=>ke,each:()=>U,extract:()=>h,extractEmails:()=>u,extractEmojis:()=>a,extractLinks:()=>c,extractPhones:()=>l,extractText:()=>p,filter:()=>E,find:()=>H,formatCurrency:()=>Pe,getAgentDisplayName:()=>ee,getDayName:()=>me,getMs:()=>Oe,getUrlParameter:()=>Ae,getUserAttr:()=>ne,hslToRgb:()=>o,includes:()=>I,isBlockEmpty:()=>Ue,isConvoSeen:()=>$,isEmail:()=>K,isNumber:()=>Z,isPhone:()=>J,isURL:()=>X,isUserBanned:()=>te,js2css:()=>pe,last:()=>Y,map:()=>L,merge:()=>z,noop:()=>se,norm:()=>re,offsetToMin:()=>be,orderBy:()=>G,orderByF:()=>Q,parseJSON:()=>f,pipeExtracts:()=>d,preloadImg:()=>ve,preloadWebfonts:()=>ye,randomString:()=>j,replaceAll:()=>F,replaceCssVariable:()=>ce,replaceCssVariablePlugin:()=>ae,requestAnimationFrame:()=>b,rgbToHsl:()=>s,sameDay:()=>xe,scrollIntoViewIfNeeded:()=>Ee,setCss:()=>le,setInterval:()=>k,setTimeout:()=>w,setUserAttr:()=>ie,shortTime:()=>Se,size:()=>R,sleep:()=>ze,startsWith:()=>D,stringify:()=>g,throttle:()=>V,tokenize:()=>ue,trim:()=>W,trimStart:()=>N,unicodeToAscii:()=>je,unixSec:()=>Ce,usersOfConvo:()=>M});var r=n(3259);function s(e,t,i){e/=255,t/=255,i/=255;var n,r,s=Math.max(e,t,i),o=Math.min(e,t,i),a=(s+o)/2;if(s==o)n=r=0;else{var c=s-o;switch(r=a>.5?c/(2-s-o):c/(s+o),s){case e:n=(t-i)/c+(t<i?6:0);break;case t:n=(i-e)/c+2;break;case i:n=(e-t)/c+4}n/=6}return[n,r,a]}function o(e,t,i){var n,r,s;if(0==t)n=r=s=i;else{function c(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}var o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;n=c(a,o,e+1/3),r=c(a,o,e),s=c(a,o,e-1/3)}return[255*n,255*r,255*s]}function a(e){for(var t=[],i=0;i<e.length;i++)for(var n=0;n<qe.length;n++)if(e.indexOf(qe[n],i)===i){t.push({index:i,length:qe[n].length}),i+=qe[n].length-1;break}return t}function c(e){e=e||"";for(var t,i=/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9@:%_\+.,~#?&//=]*)/gim,n=[];t=i.exec(e);)n.push({index:t.index,length:i.lastIndex-t.index});return n}function u(e){e=e||"";for(var t,i=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gim,n=[];t=i.exec(e);)n.push({index:t.index,length:i.lastIndex-t.index});return n}function l(e){e=e||"";for(var t="",i={},n=0;n<e.length;n++){var r=e.charAt(n);if("."===r||"-"===r||" "===r){var s=n>0?e.charAt(n-1):"-",o=n<e.length-1?e.charAt(n+1):"-";-1!=="0123456789".indexOf(s)&&-1!=="0123456789".indexOf(o)||(i[(t+=r).length-1]=n)}else i[(t+=r).length-1]=n}for(var a,c=/([0-9]{8,13})/gim,u=[];a=c.exec(t);)u.push({index:i[a.index],length:i[c.lastIndex-1]-i[a.index]+1});return u}function h(e,t,i){if(!e)return[];var n=[],r=0,s=t(e);if(0===R(s))return[{type:"text",text:e}];U(s,(t=>{n.push({type:"text",text:e.substr(r,t.index-r)}),n.push({type:i,text:e.substr(t.index,t.length)}),r=t.index+t.length}));var o=Y(s);return n.push({type:"text",text:e.substr(o.index+o.length,e.length-o.index+o.length)}),E(n,(e=>""!==e.text))}function d(e,t){var i=[];if(0===R(t))return[{type:"text",text:e}];var n=t.shift();return U(h(e,n,n.type),(e=>{if("text"!==e.type)return i.push(e);i=i.concat(d(e.text,t.slice()))})),i}function p(e){var t=c;t.type="link";var i=u;i.type="email";var n=l;n.type="phone";var r=a;return r.type="emoji",d(e,[t,i,n,r])}function f(e){try{return y(e)}catch(e){}}var _=document.createElement("iframe");_.style.display="none",document.documentElement.appendChild(_);const m=_.contentDocument.createElement("div");_.contentDocument.body.appendChild(m);var g=_.contentWindow.JSON.stringify,y=_.contentWindow.JSON.parse,v=_.contentWindow.Date,b=_.contentWindow.requestAnimationFrame,w=_.contentWindow.setTimeout.bind(_.contentWindow),k=_.contentWindow.setInterval.bind(_.contentWindow),x=_.contentWindow.clearInterval.bind(_.contentWindow),S=_.contentWindow.clearTimeout.bind(_.contentWindow),C=_.contentWindow.XMLHttpRequest;function O(e){return e?r.get(e,"data.conversation.id",r.get(e,"data.message.conversation_id")):""}function T(e,t){if(!t)return"";switch(t.type){case"message_sent":case"message_updated":case"message_pong":return r.set(t,"data.message.conversation_id",e);case"ticket_updated":return r.set(t,"data.ticket.conversation_id",e);default:return r.set(t,"data.conversation.id",e)}}function A(e){return e&&"object"==typeof e&&!Array.isArray(e)}function z(e,...t){if(!t.length)return e;const i=t.shift();if(A(e)&&A(i))for(const t in i)A(i[t])?(e[t]||Object.assign(e,{[t]:{}}),z(e[t],i[t])):Object.assign(e,{[t]:i[t]});return z(e,...t)}function P(e){if(e!==Object(e))return e;var t=g(e);return void 0!==t?y(t):void 0}function j(e){var t,i="";(!e||e<1)&&(e=10);for(var n=0;n<e;n++)t=Math.floor(25*Math.random()+97),i+=String.fromCharCode(t);return i}function E(e,t){if(!e)return[];if(!t)return e;var i=[];if(Array.isArray(e)){for(let n=0;n<e.length;n++)t(e[n],n)&&i.push(e[n]);return i}if("object"==typeof e){var n=Object.keys(e);for(let s=0;s<n.length;s++){var r=n[s];t(e[r],r)&&i.push(e[r])}return i}return i}function I(e,t){if(!e)return!1;var i="string"==typeof e||e instanceof String;return!(!Array.isArray(e)&&!i)&&e.includes(t)}function L(e,t){if(!e)return[];t||(t=e=>e);var i=[];if(Array.isArray(e)){for(let n=0;n<e.length;n++)i.push(t(e[n],n));return i}if("object"==typeof e){var n=Object.keys(e);for(let s=0;s<n.length;s++){var r=n[s];i.push(t(e[r],r))}return i}return i}function U(e,t){return L(e,t)}function M(e){return e?L(E(e.members,(e=>"user"===e.type)),(e=>e.id)):[]}function $(e,t){if("ended"===e.state)return!0;let i=e.last_message_sent;if(!i)return!0;if(r.get(i,"by.id")===t)return!0;let n=H(e.members,(e=>e.id===t));return!n||Oe(i.created)<Oe(n.seen_at)}function q(e,t){return e?L(E(e.members,(e=>t?"agent"===e.type||"bot"===e.type:"agent"===e.type)),(e=>e.id)):[]}function D(e,t){return((e||"")+"").startsWith(t)}function R(e){return e?void 0!==e.length?e.length:Object.keys(e).length:0}function F(e,t,i){return(e||"").split(t).join(i)}function W(e,t){return((e||"")+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function N(e,t){for(e=(e||"")+"";e.charAt(0)===t;)e=e.substr(1);return e}function V(e,t,i){var n,r,s,o=null,a=0;i||(i={});var c=function(){a=!1===i.leading?0:(new v).getTime(),o=null,s=e.apply(n,r),o||(n=r=null)};return function(){var u=(new v).getTime();a||!1!==i.leading||(a=u);var l=t-(u-a);return n=this,r=arguments,l<=0||l>t?(o&&(S(o),o=null),a=u,s=e.apply(n,r),o||(n=r=null)):o||!1===i.trailing||(o=w(c,l)),s}}function H(e,t){if(e)return e[B(e,t)]}function B(e,t){if(!e)return-1;if(!t)return-1;if(Array.isArray(e)){for(let i=0;i<e.length;i++)if(t(e[i],i))return i;return-1}if("object"==typeof e){var i=Object.keys(e);for(let r=0;r<i.length;r++){var n=i[r];if(t(e[n],n))return n}}return-1}function G(e,t,i){var n=[];return U(e,(e=>n.push(e))),n.sort(((e,n)=>{if(e[t]===n[t])return 0;var r=e[t]<n[t]?-1:1;return"desc"===i?-r:r})),n}function Q(e,t,i){var n=[];return U(e,(e=>n.push(e))),n.sort(((e,n)=>{let r=t(e),s=t(n);if(r===s)return 0;var o=r<s?-1:1;return"desc"===i?-o:o})),n}function J(e){return/^[\+]?[(]?[0-9]{2,3}[)]?[-\s\.]?[0-9]{3,4}[-\s\.]?[0-9]{4,6}$/im.test(String(e))}function X(e){return/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi.test(String(e).toLowerCase())}function Z(e){return/^\d+$/.test(String(e))}function K(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}function Y(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function ee(e,t){return r.get(t,"fullname")||r.get(t,"email")||r.get(e,"name")||"Agent"}function te(e){return ne(e,"is_ban","boolean")}function ie(e,t){if(e&&r.get(t,"key")){e.attributes=e.attributes||[];var i=B(e.attributes,(e=>e&&e.key===t.key));-1!==i?e.attributes[i]=t:e.attributes.push(t)}}function ne(e,t,i){if(!e||!e.attributes)return;let n;return U(e.attributes,(e=>{e&&e.key===t&&("datetime"===i&&(n=e.datetime),"boolean"===i&&(n=e.boolean),"number"===i&&(n=e.number),"text"===i&&(n=e.text),"list"===i&&(n=[e.text].concat(e.other_values)))})),n}function re(e){return(e=e||"").trim().toLowerCase()}function se(){}function oe(e){return("string"==typeof e||e instanceof String)&&(e=e.trim().replace(/;+$/,"")),e}function ae(e,t){var i=[e];let n=t.spacer||10;t=Object.assign({},t,{spacer:n+"px",spacer0:n/2+"px",spacer2:2*n+"px",spacer3:3*n+"px"}),i=ue(i,"'@font_family'"),i=ue(i,"'@font_size'"),i=ue(i,"'@text_color'"),i=ue(i,"'@faded_text_color'"),i=ue(i,"'@primary_color'"),i=ue(i,"'@background'"),i=ue(i,"'@spacer'"),i=ue(i,"'@spacer0'"),i=ue(i,"'@spacer2'"),i=ue(i,"'@spacer3'");let a=$e(r.get(t,"primary_color")||r.get(de,"primary_color"));a||(a={red:238,blue:238,green:238});let c=s(a.red,a.green,a.blue)[0],[u,l,h]=o(c,.25,.95);de.primary_color_faded=`rgb(${u},${l},${h})`;for(var d=[],p=0;p<i.length;p++){var f=i[p];if("string"!=typeof f){var _=f.type.substr(2,f.type.length-3),m=r.get(t,_)||r.get(de,_)||"";d.push(m)}else d.push(f)}return d.join("")}function ce(e,t){var i=[e];i=ue(i,"'@primary_color'"),i=ue(i,"'@primary_color_faded'"),i=ue(i,"@esc-primary-color-esc"),i=ue(i,"'@secondary_color'"),i=ue(i,"'@background'"),i=ue(i,"'@text_color'"),i=ue(i,"'@width'"),i=ue(i,"'@height'"),i=ue(i,"'@desktop_button.width'"),i=ue(i,"'@desktop_button.height'"),i=ue(i,"'@desktop_button.background'"),i=ue(i,"'@desktop_button.border_radius'"),i=ue(i,"'@desktop_button.margin_x'"),i=ue(i,"'@desktop_button.margin_y'"),i=ue(i,"'@mobile_button.width'"),i=ue(i,"'@mobile_button.height'"),i=ue(i,"'@mobile_button.background'"),i=ue(i,"'@mobile_button.border_radius'"),i=ue(i,"'@mobile_button.margin_x'"),i=ue(i,"'@mobile_button.margin_y'"),i=ue(i,"'@widget_position'"),i=ue(i,"'@z_index'"),i=ue(i,"'@z_index_2'"),i=ue(i,"'@z_index_3'"),i=ue(i,"'@z_index_4'"),i=ue(i,"'@z_index_5'");let n=$e(r.get(t,"primary_color")||r.get(de,"primary_color"));n||(n={red:238,blue:238,green:238});let a=s(n.red,n.green,n.blue)[0],[c,u,l]=o(a,.25,.95);de.primary_color_faded=`rgb(${c},${u},${l})`;for(var h=[],d=0;d<i.length;d++){var p=i[d];if("string"!=typeof p)if("@esc-primary-color-esc"!==p.type)if("'@z_index_2'"!==p.type)if("'@z_index_3'"!==p.type)if("'@z_index_4'"!==p.type)if("'@z_index_5'"!==p.type){var f=p.type.substr(2,p.type.length-3);_=oe(_=r.get(t,f)||r.get(de,f)||""),["mobile_button.width","mobile_button.height","mobile_button.margin_x","mobile_button.margin_y","desktop_button.width","desktop_button.height","desktop_button.margin_x","desktop_button.margin_y","width","height"].includes(f)&&(_+="px"),"height"!==f||"full"!==r.get(t,"window_mode")?h.push(_):h.push("100%")}else _=r.get(t,"z_index")||r.get(de,"z_index"),h.push(_+5);else _=r.get(t,"z_index")||r.get(de,"z_index"),h.push(_+4);else{var _=r.get(t,"z_index")||r.get(de,"z_index");h.push(_+3)}else{_=r.get(t,"z_index")||r.get(de,"z_index");h.push(_+2)}else{_=r.get(t,"primary_color")||r.get(de,"primary_color");h.push(encodeURIComponent(oe(_)))}else h.push(p)}return h.join("")}function ue(e,t){if(!e||!e.length)return[];var i=[];for(let s=0;s<e.length;s++){var n=e[s];if("string"==typeof n){var r=n.split(t);for(let e=0;e<r.length;e++)i.push(r[e]),i.push({type:t});i.pop()}else i.push(n)}return i}function le(e,t,i){i=F(i,"#sbz92","#"+e),t.styleSheet?t.styleSheet.cssText=i:(t.innerHTML="",t.appendChild(document.createTextNode(i)))}const he="https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5",de={primary_color:"#0265FF",secondary_color:"#555555",background:"linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)",text_color:"white",width:375,height:705,window_mode:"mini",desktop_button:{width:.3,height:.3,border_radius:"100%",background_mask_url:he,margin_x:.3,margin_y:.3},mobile_button:{width:.3,height:.3,border_radius:"100%",background_mask_url:he,margin_x:.3,margin_y:.3},widget_position:"fixed",z_index:2e9};function pe(e,t,i){var n={};for(var r in e)e.hasOwnProperty(r)&&(t&&t.length>0&&-1===t.indexOf(r)||("string"==typeof e[r]?n[r]=W(e[r]):n[r]=e[r]));e=n;let s="";for(var r in e)if(e.hasOwnProperty(r)){var o="";if(e.blur&&(o+="blur("+e.blur+") "),e.grayscale&&(o+="grayscale("+e+") "),o&&(s+="filter: "+o+"!important;"),void 0!==e.rotate&&(s+="transform:rotate("+e.rotate+") !important;"),void 0!==e[r]){let t=e[r]+"";L(i,((e,i)=>{-1!==t.indexOf(i)&&(t=F(t,i,e))})),s+=F(r,"_","-")+":"+t+" !important;","color"===r&&(s+="-webkit-text-fill-color: "+t+" !important;")}}return s}function fe(){var e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,i=(/constructor/i.test(window.HTMLElement)||(!window.safari||"undefined"!=typeof safari&&window.safari.pushNotification).toString(),!!document.documentMode),n=!i&&!!window.StyleMedia,r=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime);r||(r=navigator.userAgent.indexOf("Chrome"));var s=r&&-1!=navigator.userAgent.indexOf("Edg"),o=(r||e)&&!!window.CSS;return e?"opera":t?"firefox":i?"ie":n||s?"edge":r?"chrome":o?"blink":"unknown"}function _e(e,t,i,n){var s=n.matchAccount()||{},o=n.matchLocation()||{};if(!function(e,t){return!(t&&(r.get(e,"once_per_user")||r.get(e,"once_per_session")&&xe(t.created,v.now())||r.get(e,"interval_sec")&&r.get(e,"interval_sec")>(v.now()-t.created)/1e3))}(e,i))return!1;for(let e=0;e<R(t);e++){var a=t[e];switch(a.key){case"url":let e=E(a.exclude_urls,(e=>re(e)));if(R(e)>0&&H(e,(e=>re(window.location.href).indexOf(re(e))>-1)))return!1;let t=E(a.urls,(e=>re(e)));if(R(t)>0&&!H(t,(e=>re(window.location.href).indexOf(re(e))>-1)))return!1;break;case"url_path":let i=E(a.exclude_url_paths,(e=>re(e)));if(R(i)>0){let e=new URL(window.location.href).pathname||"";if("string"==typeof e&&e.endsWith("/")&&(e=e.substring(0,e.length-1)),H(i,(t=>("string"==typeof t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),e===t))))return!1}let h=E(a.url_paths,(e=>re(e)));if(R(h)>0){let e=new URL(window.location.href).pathname||"";if("string"==typeof e&&e.endsWith("/")&&(e=e.substring(0,e.length-1)),!H(h,(t=>("string"==typeof t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),e===t))))return!1}break;case"browser":if(R(a.browsers)>0){var c=fe();if(!H(a.browsers,(e=>re(e)===re(c))))return!1}break;case"location":if(R(a.exclude_locations)>0&&H(a.exclude_locations,(e=>!(!e.city_name||!e.country_code||e.city_name!==o.city_name||e.country_code!==o.country_code)||!(!e.city_name||e.country_code||e.city_name!==o.city_name)||!(e.city_name||!e.country_code||e.country_code!==o.country_code)||void 0)))return!1;if(R(a.locations)>0&&!H(a.locations,(e=>!(!e.city_name||!e.country_code||e.city_name!==o.city_name||e.country_code!==o.country_code)||!(!e.city_name||e.country_code||e.city_name!==o.city_name)||!(e.city_name||!e.country_code||e.country_code!==o.country_code)||void 0)))return!1;break;case"returning_visitor":if(a.returning_visitor&&n.new_visitor)return!1;if(!a.returning_visitor&&!n.new_visitor)return!1;break;case"user_is_a_contact":let d=r.get(n.matchUser(),"attributes",[]),p=H(d,(e=>"emails"===e.key&&attr.text&&"related_email"===e.key&&attr.text)),_=H(d,(e=>"phones"===e.key&&attr.text&&"related_phone"===e.key&&attr.text)),m=p||_;if(a.user_is_a_contact&&!m)return!1;if(!a.user_is_a_contact&&m)return!1;break;case"device_type":if(R(a.device_types)>0){let e="desktop";if(n.isMobile()&&(e="mobile"),n.isTablet()&&(e="tablet"),!H(a.device_types,(t=>re(t)===re(e))))return!1}break;case"referer":if(R(a.exclude_referers)>0&&H(a.exclude_referers,(e=>re(document.referrer).indexOf(re(e))>-1)))return!1;if(R(a.urls)>0&&!H(a.referers,(e=>re(document.referrer).indexOf(re(e))>-1)))return!1;break;case"source":if(R(a.sources)>0){let e=n.matchTrafficSource()||"direct";if(!H(a.sources,(t=>re(t)===re(e))))return!1}break;case"user_attribute":case"user":let g,y=r.get(n.matchUser(),"attributes",[]),b=r.get(a,"user.operator");U(y,(e=>{e&&e.key===r.get(a,"user.key")&&(g=e.datetime||e.boolean||e.number||e.text||e.list)}));let w=!0;switch(b){case"cons":let e=f(a.value)||[];if(0===R(e))return!1;w=!!H(e,(e=>re(g).indexOf(re(e))>-1));break;case"notEmpty":w=!!g;break;case"empty":w=!g;break;case"true":w=!0===g||"true"===g;break;case"false":w=!g||!1===g||"false"===g}if(!w)return!1;break;case"timming":if("in"===a.business_hour&&!s.is_in_business_hour)return!1;if("notIn"===a.business_hour&&s.is_in_business_hour)return!1;if(R(a.days_of_week)>0&&!H(a.days_of_week,(e=>re(me((new v).getDay()))===re(e))))return!1;if(R(a.minutes_of_day)>0&&R(a.minutes_of_day)%2==0){var u=new v,l=u.getMinutes()+60*u.getHours();let e=!1;for(let t=0;t<a.minutes_of_day.length;t+=2){if(a.minutes_of_day[t]<=l&&l<=a.minutes_of_day[t+1]){e=!0;break}if(a.minutes_of_day[t]>a.minutes_of_day[t+1]&&(l>=a.minutes_of_day[t]||l<=a.minutes_of_day[t+1])){e=!0;break}}if(!e)return!1}break;case"offline":if(!s.is_online!=!!a.offline)return!1}}return!0}function me(e){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]}let ge={};function ye(e,t){for(var i=0;i<e.length;i++){let t=e[i];if(t&&!ge[t]){ge[t]=!0;for(var n=0;n<2;n++){let e=[400,500][n],i=document.createElement("div");i.innerHTML="@!-/#Chào mỪng1",i.style.position="absolute",i.style.display="block",i.style.opacity="0.1",i.style.color="transparent",i.style.fontSize="20px",i.style.height="0px",i.style.top="0px",i.style.width="0px",i.style.fontWeight=e,i.setAttribute("subiz-preload",t+":"+e),document.body.appendChild(i),i.style.fontFamily=t,w((()=>i.remove()),3e3)}}}}function ve(e,t){if(t||(t=()=>{}),!e)return t(),Promise.resolve(!0);let i=new Image;return e=function(e){let t="https://vcdn.subiz-cdn.com/file/";return e?D(e,"/")||D(e,"data:")?e:(D(e,"http://")||D(e,"https://")||D(e,"//")||(e=W(t)+"/"+N(e,"/")),e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace("https://file-subiz.com/",t)).replace("http://file-subiz.com/",t)).replace("https://file-v4.subiz.com/",t)).replace("http://file-v4.subiz.com/",t)).replace("https://filev4.subiz.com/",t)).replace("http://filev4.subiz.com/",t)).replace("https://filev4-1.subiz.com/",t)).replace("http://filev4-1.subiz.com/",t)).replace("https://file.subiz.com/",t)).replace("http://file.subiz.com/",t)).replace("https://file.mysubiz.com/",t)).replace("http://file.mysubiz.com/",t)):""}(e),i.src=e,new Promise((e=>{i.onload=()=>{t(),e()}}))}function be(e){if(!e)return 0;e.length<=2&&(e+=":00");let t=e.split(":");if(2!==t.length)return 0;let i=parseInt(t[0]);if(i<0||i>23)return 0;let n=parseInt(t[1]);return n<0||n>59?0:60*i+n}function we(e,t,i){var n=-(new v).getTimezoneOffset();i&&(n=be(i));var r=new v(e).getTime(),s=new v(t).getTime(),o=Math.ceil((r/60/1e3+n)/60/24),a=Math.ceil((s/60/1e3+n)/60/24);return Math.abs(o-a)}function ke(e,t,i){var n=-(new v).getTimezoneOffset(),r=-(new v).getTimezoneOffset();i&&(r=be(i));var s=new v(e).getTime()+60*(r-n)*1e3,o=new v(t).getTime()+60*(r-n)*1e3;return Math.abs(new v(s).getYear()-new v(o).getYear())}function xe(e,t,i){return 0===we(e,t,i)}function Se(e,t,i,n){var s=-(new v).getTimezoneOffset(),o=s;t&&(o=be(t));var a=new v(Oe(e));let c=new v(a);c.setMinutes(a.getMinutes()+o-s),i||(i=new v);let u=c.getHours(),l=c.getMinutes(),h=r.get(navigator,"languages.0","en-US");n&&(h=n);let d=c.toLocaleDateString(h,{weekday:"long"}),p=c.getFullYear(),f=c.getMonth()+1,_=c.toLocaleDateString(h,{month:"long"}),m=c.getDate();return u<10&&(u="0"+u),l<10&&(l="0"+l),xe(a,i,t)?u+":"+l:we(a,i,t)<=5?d+", "+u+":"+l:0===ke(a,i,t)?"vi-VN"===h?m+" "+_+", "+u+":"+l:_+" "+m+", "+u+":"+l:"vi-VN"===h?m+"/"+f+"/"+p+", "+u+":"+l:p+"/"+f+"/"+m+", "+u+":"+l}function Ce(e){return Math.floor(Oe(e)/1e3)}function Oe(e){return e?"number"!=typeof e&&(e=new v(e).getTime()):e=0,e>1e18?Math.floor(e/1e6):e>1e15?Math.floor(e/1e3):e>1e12?e:1e3*e}function Te(){let e=Ae("sbz_locale"),t=document.getElementsByTagName("html")[0].getAttribute("xml:lang")||document.getElementsByTagName("html")[0].getAttribute("lang"),i=navigator.language;return e||t||i}function Ae(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))}var ze=e=>new Promise((t=>w(t,e)));function Pe(e,t="VND"){let i=Ie.find((e=>e.code===t))||{name:"Dong",code:"VND",symbol:"₫"},n="",r="";return"VND"===t?(n="",r=" "+i.symbol):(n=i.symbol+" ",r=""),e?n+(e=Math.round(e)).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")+r:`${n}0${r}`}function je(e){return(e=(e+="").replaceAll("đ","d").replaceAll("Đ","D")).normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Ee(e){centerIfNeeded=0===arguments.length||!!centerIfNeeded;var t=e.parentNode,i=window.getComputedStyle(t,null),n=parseInt(i.getPropertyValue("border-top-width")),r=parseInt(i.getPropertyValue("border-left-width")),s=e.offsetTop-t.offsetTop<t.scrollTop,o=e.offsetTop-t.offsetTop+e.clientHeight-n>t.scrollTop+t.clientHeight,a=e.offsetLeft-t.offsetLeft<t.scrollLeft,c=e.offsetLeft-t.offsetLeft+e.clientWidth-r>t.scrollLeft+t.clientWidth,u=s&&!o;(s||o)&¢erIfNeeded&&(t.scrollTop=e.offsetTop-t.offsetTop-t.clientHeight/2-n+e.clientHeight/2),(a||c)&¢erIfNeeded&&(t.scrollLeft=e.offsetLeft-t.offsetLeft-t.clientWidth/2-r+e.clientWidth/2),(s||o||a||c)&&!centerIfNeeded&&e.scrollIntoView(u)}const Ie=[{code:"USD",symbol:"$"},{code:"VND",symbol:"₫"}];function Le(e){return function(e){if(!e||!e.type)return"";let t="";if("bullet_list"==e.type||"ordered_list"==e.type)return L(e.content,(n=>{preifx="\n* ","ordered_list"==e.type&&(prefix=i+"\n. "),t+=prefix+Le(n).trim()})),t;if("heading"!=e.type&&"paragraph"!=e.type||(t+="\n"),""==e.type||"text"==e.type||"link"==e.type||"mention-agent"==e.type||"dynamic-field"==e.type)return t+e.text;if("horizontal_rule"==e.type)return t+"\n---\n";if("emoji"==e.type){let i;if(R(e.attrs)>0&&(i=e.attrs.code),""==i&&(i=e.text),""!=i){let e=H(LEXICAL_EMOJI_LIST,(e=>e.code===i));r.get(e,"text",i)}return t}return L(e.content,(e=>{t+=Le(e)})),t}(e).trim()}function Ue(e){return Me(e)}function Me(e={}){if(!R(e.content))return!(e.text||"").trim();let t=!0;return L(e.content,(e=>{t=t&&Me(e)})),t}function $e(e){if(!e||!e.split)return"";m.style.color=e;const t=_.contentWindow.getComputedStyle(m).color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{red:parseInt(t[1]),green:parseInt(t[2]),blue:parseInt(t[3])}:null}let qe=["like","unlike","wink","tongue-out","tired","surprised","smiling","sleepy","sad","neutral","heart-eyes","grinning","crying","confused","angry","cry","heart_eyes","neutral_face","emoji--disappointed","smile","open_mouth","tired_face","stuck_out_tongue","moyai","thumbsdown","dislike","thumbsup","ok_hand","octopus","pig2","wave","mouse","mouse2","rat"];qe=L(qe,(e=>":"+e+":"))}},r={};function s(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={id:e,exports:{}};return n[e].call(i.exports,i,i.exports,s),i.exports}s.m=n,s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,i)=>(s.f[i](e,t),t)),[])),s.u=e=>"1967c022bc1."+e+".js",s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="@subiz/widget-v4:",s.l=(i,n,r,o)=>{if(e[i])e[i].push(n);else{var a,c;if(void 0!==r)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var h=u[l];if(h.getAttribute("src")==i||h.getAttribute("data-webpack")==t+r){a=h;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",t+r),a.src=i),e[i]=[n];var d=(t,n)=>{a.onerror=a.onload=null,clearTimeout(p);var r=e[i];if(delete e[i],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),c&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.p="https://vcdn.subiz-cdn.com/widget-v4/public/",(()=>{var e={325:0};s.f.j=(t,i)=>{var n=s.o(e,t)?e[t]:void 0;if(0!==n)if(n)i.push(n[2]);else{var r=new Promise(((i,r)=>n=e[t]=[i,r]));i.push(n[2]=r);var o=s.p+s.u(t),a=new Error;s.l(o,(i=>{if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var r=i&&("load"===i.type?"missing":i.type),o=i&&i.target&&i.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+o+")",a.name="ChunkLoadError",a.type=r,a.request=o,n[1](a)}}),"chunk-"+t,t)}};var t=(t,i)=>{var n,r,[o,a,c]=i,u=0;if(o.some((t=>0!==e[t]))){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);c&&c(s)}for(t&&t(i);u<o.length;u++)r=o[u],s.o(e,r)&&e[r]&&e[r][0](),e[r]=0},i=self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})(),(()=>{"use strict";var e={};s.r(e),s.d(e,{trackAreaClicked:()=>o,trackExitIntent:()=>n,trackInactivity:()=>a,trackScrollingPercentage:()=>r,trackTimeOnPage:()=>u});var t=s(9917),i=s(9917);function n(e){let t=i=>{i.clientY>10||(e&&e(),document.removeEventListener("mouseout",t))};document.addEventListener("mouseout",t)}function r(e,t){let i=n=>{let r=n.srcElement.scrollingElement?n.srcElement.scrollingElement.scrollTop:n.srcElement.scrollTop,s=n.srcElement.scrollingElement?n.srcElement.scrollingElement.scrollHeight:n.srcElement.scrollHeight;r>0&&s>0&&(r+window.innerHeight)/s>=e&&(t&&t(),window.removeEventListener("scroll",i,!1))};window.addEventListener("scroll",i,!1)}function o(e,t){e&&(e=e||"",i.map(e.split("\n"),(e=>{(e=i.trim(e))&&function(e,t,i){document.addEventListener("click",(function(e){let n=document.querySelectorAll(t),r=e.target;for(let t=0,s=n.length;t<s;t++){let s=r,o=n[t];for(;s&&s!==document;){if(s===o)return i.call(o,e);s=s.parentNode}}}))}(0,e,t)})))}function a(e=0,t){let n=["scroll","keyup","keydown","mousemove","mousewheel","mouseenter","mouseover","mousedown","touchstart","touchmove","touchenter"],r=0,s=()=>{r=0},o=i.setInterval((()=>{if(r++,!(r<e)){t&&t();for(let e of n)document.removeEventListener(e,s,!1);i.clearInterval(o)}}),1e3);for(let e of n)document.addEventListener(e,s,!1)}let c=i.Date.now();function u(e=0,t){if(e<1)return i.setTimeout((function(){t(e)}),100);let n=i.setInterval((()=>{let r=(i.Date.now()-c)/1e3;r<e||(t&&t(r),i.clearInterval(n))}),200)}var l={};(l=Object.assign(l,t)).Gate=s(1139).A,l.Mutex=s(5369).A;var h=s(3259);l.get=h.get,l.set=h.set,l.Pubsub=s(6463).A;const d=l=Object.assign(l,e);function p(e,t,i){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const f=s(318);function _(e,t){let i=e.request;"text/plain"===i.content_type&&void 0!==i.body&&(i.body=d.stringify(i.body)),t(!0)}f.env.XMLHttpRequest=d.XMLHttpRequest;const m=class{constructor(e,t){p(this,"listConversations",(e=>this.apireq.addQuery("user_id",this.uid).addQuery("integration_id",`${this.accid}.subizv4.subikon`).get(`/accounts/${this.accid}/conversations`))),p(this,"listMessages",((e,t,i)=>this.apireq.addQuery("limit",t).addQuery("start_id",i).get(`/accounts/${this.accid}/conversations/${e}/messages`))),p(this,"ajax",f),p(this,"start",(e=>{let t={touchpoint:{channel:"subiz",source:"web"}};return d.each(e,((e,i)=>{t[i]=e})),this.apireq.post(`/accounts/${this.accid}/conversations`,t)})),p(this,"sendConvoEvent",((e,t)=>this.apireq.addQuery("x-referer",d.get(location,"origin","")).post(`/accounts/${this.accid}/conversations/${e}/events`,t))),p(this,"createPostback",((e,t)=>this.apireq.post(`/accounts/${this.accid}/conversations/${e}/postbacks`,t))),p(this,"markAsReceived",((e,t)=>this.apireq.post(`/accounts/${this.accid}/conversations/${e}/messages/${t}/receive`))),p(this,"markAsSeen",((e,t)=>this.apireq.post(`/accounts/${this.accid}/conversations/${e}/messages/${t}/seen`))),p(this,"getConversation",(e=>this.apireq.get(`/accounts/${this.accid}/conversations/${e}`))),p(this,"getLocaleContent",(e=>this.apireq.get(`/accounts/${this.accid}/locales/${e}`))),p(this,"sendEvent",(e=>this.apireq.addQuery("shorten",!0).addQuery("x-referer",d.get(location,"origin","")).post(`/accounts/${this.accid}/users/${this.uid}/events`,e))),p(this,"submitForm",((e,t,i,n,r)=>this.apireq.addQuery("x-referer",d.get(location,"origin","")).post(`/accounts/${this.accid}/users/${this.uid}/events`,{by:{id:this.uid,device:i},type:"form_submitted",data:{user:r,form_submission:{user_id:this.uid,form_id:e,page_url:t,submitted_at:d.Date.now(),values:n}}}))),p(this,"sendTyping",(e=>this.apireq.post(`/accounts/${this.accid}/conversations/${e}/typing`))),p(this,"sendLostFocus",(()=>this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`))),p(this,"uploadToS3",(async e=>{let{body:t,error:i}=await this.apireq.post(`/accounts/${this.accid}/files`,{account_id:this.accid,description:"upload\n user-client: web-widget",name:e.name.replace(/\s+/g,"_"),size:e.size,type:e.type});if(i)return{body:t,error:i};let n,r=e.type||"application/octet-stream";return({error:i}=await f.setContentType(r).put(t.signed_url,e)),i?{error:i}:(({body:n,error:i}=await this.apireq.post(`/accounts/${this.accid}/files/${t.id}`,{account_id:this.accid})),i?{body:n,error:i}:{url:n.url})})),p(this,"time",(e=>f.setBaseUrl(this.ApiURL).withCredentials(!0).setParser("json").get("/time"))),p(this,"updateUser",(e=>this.apireq.post(`/accounts/${this.accid}/users/${this.uid}`,e))),p(this,"getUser",(e=>this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`))),p(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),p(this,"sendImpression",(e=>this.apireq.post(`/accounts/${this.accid}/campaigns/${e.campaign_id}/impressions`,e))),p(this,"sendConversion",(e=>this.apireq.post(`/accounts/${this.accid}/campaigns/${e.campaign_id}/conversions`,e))),p(this,"lookupOrder",(e=>f.setBaseUrl(this.ApiURL).setContentType("text/plain").beforeHook(_).setParser("json").addQuery("x-signed-key",e).get("/orders/123"))),p(this,"getOrder",(e=>this.apireq.get(`/accounts/${this.accid}/orders/`+e))),p(this,"updateOrder",(e=>this.apireq.post(`/accounts/${this.accid}/orders/`+e.id,e))),p(this,"fetchShippingAddresses",(()=>this.apireq.get(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`))),p(this,"createShippingAddress",(e=>this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`,e))),p(this,"list_provinces",(()=>this.apireq.get(`/accounts/${this.accid}/provinces`))),p(this,"list_districts",(e=>this.apireq.setQuery(e).get(`/accounts/${this.accid}/districts`))),p(this,"list_wards",(e=>this.apireq.setQuery(e).get(`/accounts/${this.accid}/wards`))),p(this,"checkFormToken",(e=>this.api41.get(`/submissions/${e}`))),p(this,"submitForm2",((e,t)=>this.api41.post(`/submissions/${e}`,t))),p(this,"suggest_address",(e=>this.apireq.setQuery({keyword:e}).get(`/accounts/${this.accid}/addresses`))),p(this,"create_ticket",(e=>this.apireq.post(`/accounts/${this.accid}/tickets`,e))),this.refreshLock=new d.Mutex,this.FileURL=t,this.ApiURL=e,this.api41=f.setBaseUrl("https://api5.subiz.com.vn/4.1").withCredentials(!0).setContentType("text/plain").beforeHook(_).setParser("json"),this.apireq=f.setBaseUrl(e).withCredentials(!0).addQuery("v","6").setContentType("text/plain").beforeHook(_).setParser("json").beforeHook(((e,t)=>{if(!this.token_generator)return this.ref?e.request=e.request.addQuery("x-user-ref",this.ref):this.mask&&(e.request=e.request.addQuery("x-user-mask",this.mask)),t(!0);{let i=this.profile_id;this.token_generator().then((n=>i!=this.profile_id?t(!0):n?"error"==n?t(!1):(e.request=e.request.addQuery("x-access-token",n),t(!0)):t(!1)))}}))}setAgentId(e){this.agentid=e}async setAuth(e){if(e.accid&&(this.accid=e.accid),e.ref&&(this.ref=e.ref),this.mask=e.mask,this.profile_id=e.profile_id,e.ref){let e;for(let t=0;e=await f.setBaseUrl(this.ApiURL).withCredentials(!0).addQuery("v","6").addQuery("x-user-ref",this.ref).setParser("json").get(`/accounts/${this.accid}/users/${this.ref}`),-1==d.get(e,"body.error.code","").indexOf("locked_account");t++)if(-1==d.get(e,"body.error.code","").indexOf("user_is_banned")){if(d.get(e,"body.id"))break;{let e=Math.min(2e3+400*t,6e4);await d.sleep(e)}}else await d.sleep(12e4);return e.error?d.get(e.body.code)?{error:e.body.code}:e:(this.uid=e.body.id,e.body)}if(e.tokenGenerator){let t=e.tokenGenerator;this.tokensession=this.tokensession||0,this.tokensession++;let i=this.tokensession;if(!this.accid||!d.startsWith(this.accid,"ac"))return{error:"invalid_account_id"};if(!this.profile_id)return{error:"invalid_profile_id"};if("function"!=typeof t)return{error:"invalid_token_generator"};let n,r=this.profile_id;this.token_generator=async e=>{if(await this.refreshLock.lock(),i!=this.tokensession)return void this.refreshLock.unlock();let n,s,o=(d.Date.now()-(this.last_token_at||0))/1e3;if(!e&&this.last_token&&o<1800)return this.refreshLock.unlock(),this.last_token;if(!e&&this.last_token&&o<3e3)return this.token_generator&&d.setTimeout((async()=>{let e,n;try{e=await t(r)}catch(e){n=e}i==this.tokensession?(this.last_token=n?"error":e,this.last_token_at=d.Date.now(),this.refreshLock.unlock()):this.refreshLock.unlock()})),this.last_token;try{n=await t(r)}catch(e){s=e}if(i==this.tokensession)return this.last_token=s?"error":n,this.last_token_at=d.Date.now(),this.refreshLock.unlock(),this.last_token;this.refreshLock.unlock()};for(let e=0;await this.token_generator(!0),i==this.tokensession&&(n=await f.setBaseUrl(this.ApiURL).withCredentials(!0).addQuery("v","6").addQuery("x-access-token",this.last_token).setParser("json").get(`/accounts/${this.accid}/users/${r}`),!d.get(n,"body.id"));e++){let t=Math.min(2e3+100*e,12e4);await d.sleep(t)}return n.error?d.get(n.body.code)?{error:n.body.code}:n:(this.uid=n.body.id,n.body)}if(this.mask){let e=this.mask.split("@");return this.uid=e[1],{id:this.uid}}return{error:"invalid_auth"}}sendContentView(e,t,i,n,r,s){return n||(n=void 0),r||(r=void 0),this.sendEvent({by:{id:this.uid,device:e},type:"content_viewed",data:{product:{id:n,source_id:r,url:t,name:i,title:i,sku:s}}})}};let g=s(450),y="undefined"!=typeof window?window.requestIdleCallback:null;y||(y=e=>e());const v=class{constructor(e,t){if(this.localStorage=g,this.inmem=t,this.allkeys={},!t)try{window.localStorage.setItem("sbzstore1029","?"),window.localStorage.removeItem("sbzstore1029"),this.localStorage=window.localStorage}catch(e){}this.schema=e}all(e){let t=[];for(var i=0;i<this.localStorage.length;i++){let n=this.localStorage.key(i);n.startsWith(this.schema+"#"+e+"#")&&(this.allkeys[n]=!0,this.inmem?t.push(this.localStorage.getItem(n)):t.push(d.parseJSON(this.localStorage.getItem(n))))}return t}removes(e,t){for(var i=0;i<t.length;i++)delete this.allkeys[this.schema+"#"+e+"#"+t[i]],this.localStorage.removeItem(this.schema+"#"+e+"#"+t[i])}clear(e){for(var t=0;t<this.localStorage.length;t++){let i=this.localStorage.key(t);i.startsWith(this.schema+"#"+e+"#")&&this.localStorage.removeItem(i)}this.allkeys={}}put(e,t,i){if(this.allkeys[this.schema+"#"+e+"#"+t]=!0,this.inmem)return this.localStorage.setItem(this.schema+"#"+e+"#"+t,i);Object.keys(this.allkeys).length>80&&this.clear(e),y((()=>{try{this.localStorage.setItem(this.schema+"#"+e+"#"+t,void 0===(n=i)?"null":JSON.stringify(n))}catch(t){this.clear(e)}var n}))}};class b{constructor(e,t,i){this.schema=t+"_chain",this.dead=!1,this.db=e,this.anchorCache={},this.cache={},this.init()}init(){let e={};this.db.all("items").map((t=>{e[t.chain]=e[t.chain]||{},e[t.chain][t.id]={id:t.id,chain:t.chain,full_id:t.full_id,index:t.index,value:t.value}})),k(e,((t,i)=>{if(x(t)<50)return;let n=function(e,t){var i=[];return k(e,(e=>i.push(e))),i.sort(((e,i)=>{if(e[t]===i[t])return 0;var n=e[t]<i[t]?-1:1;return-n})),i}(k(t),["index"]),r=[];for(var s=50;s<n.length;s++)r.push(n[s].full_id),delete t[n[s].id];this.db.removes("items",r),e[i]=t})),this.cache=e}destroy(){this.db.clear("items"),this.dead=!0,this.cache={},this.anchorCache={},this.db=void 0}put(e,t,i,n){if(this.dead)return;let r=this.cache[e]||{},s=(w(r)||{}).index||"z";0==x(r)&&(s="");let o={id:t,index:i,value:n,chain:e,full_id:e+":"+t};delete r[o.id],s>o.index+""||(r[o.id]=o,this.cache[e]=r,this.db.put("items",o.full_id,o))}listM(e){if(this.dead)return{};let t=this.cache[e]||{},i={};return k(t,((e,t)=>{i[t]=e.value})),i}async fetchMore(e,t=20,i){if(this.dead)return{error:"dead"};if(!i)return{error:"no api"};let n=this.anchorCache[e]||"";var[r,s,o]=await i(e,n,t);if(o)return{error:o};if(this.dead)return{error:"dead"};let a=this.cache[e]||{};return 0===r.length?{end:!0}:(r.forEach((t=>{t.chain=e,t.full_id=e+":"+t.id,a[t.id]=t,this.db.put("items",t.full_id,t)})),this.anchorCache[e]=s,this.cache[e]=a,{})}del(e,t){if(this.dead)return;let i=e+":"+t;delete(this.cache[e]||{})[t],this.db.removes("items",[i])}match(e,t){return this.listM(e)[t]}async reload(e,t){if(this.dead)return;let i=function(e){if(!e)return;let t=Object.keys(e);if(!t.length)return;let i=-1/0,n=Object.keys(e)[0];for(var r=0;r<t.length;r++){let s=e[t[r]]&&e[t[r]].index||-1/0;s>i&&(i=s,n=t[r])}return e[t[n]]}(this.listM(e))||{},n=i.index;n||(n=Date.now());for(var r="",s={};;){if(this.dead)return;let[i,o,a]=await t(e,r,50);if(a)return;if(this.dead)return;if(i.map((t=>{s[t.id]=Object.assign({},t,{chain:e,full_id:e+":"+t.id})})),0===i.length||o===r)break;if(s.length>=200){let t=this.cache[e]||{},i=[];k(t,(t=>{t.chain===e&&i.push(t.full_id)})),this.db.removes("items",i),this.cache[e]={};break}if((w(s)||{}).index<=n){r=this.anchorCache[e]||o;break}r=o}for(var o=0;o<Object.keys(s).length;o++){let e=s[Object.keys(s)[o]];this.db.put("items",e.full_id,e),this.cache[e.chain]=this.cache[e.chain]||{},this.cache[e.chain][e.id]=e}this.anchorCache[e]=r}}function w(e){if(!e)return;let t=Object.keys(e);if(!t.length)return;let i=1/0,n=Object.keys(e)[0];for(var r=0;r<t.length;r++){let s=e[t[r]]&&e[t[r]].index||1/0;s<i&&(i=s,n=t[r])}return e[n]}function k(e,t){if(!e)return[];if(!t)return e;var i=[];if(Array.isArray(e)){for(let n=0;n<e.length;n++)i.push(t(e[n],n));return i}if("object"==typeof e){var n=Object.keys(e);for(let s=0;s<n.length;s++){var r=n[s];i.push(t(e[r],r))}return i}return i}function x(e){return e?void 0!==e.length?e.length:Object.keys(e).length:0}const S=class{constructor(e,t){this.name=t,t+="_kv",this.dead=!1,this.db=e,this.cache={},this.initialized=!1,this.init()}refreshCache(){if(this.dead)return;let e={};this.db.all("items").forEach((function(t){e[t.key]=t.value})),this.cache=e}init(){if(this.initialized)return;let e={};console.time("KV"+this.name),this.db.all("items").forEach((function(t){e[t.key]=t.value})),this.cache=e;let t=Object.keys(this.cache);if(t.length>500){let e=250/t.lenth,n=[];for(var i=0;i<500;i++){if(Math.random()<=e)continue;let r=t[i];delete this.cache[r],n.push(r)}this.db.removes("items",[n])}this.initialized=!0,console.timeEnd("KV"+this.name)}all(){return this.dead?[]:this.initialized?this.cache:[]}match(e){if(!this.dead&&this.initialized&&e)return this.cache[e]}put(e,t){if(e){if(this.dead)return[];if(!this.initialized)throw new Error("uninitialized");this.cache[e]=t,this.db.put("items",e,{key:e,value:t})}}del(e){if(!this.dead){if(!this.initialized)throw new Error("uninitialized");delete this.cache[e],this.db.removes("items",[e])}}destroy(){this.db.clear("items"),this.dead=!0,this.db=void 0,this.cache=void 0,this.initialized=!1}};function C(e,t,i){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const O=s(318);function T(e,t){let i=e.request;"text/plain"===i.content_type&&void 0!==i.body&&(i.body=d.stringify(i.body)),t(!0)}O.env.XMLHttpRequest=window.XMLHttpRequest;const A=Promise.resolve({code:200}),z=class{constructor(e,t){C(this,"listConversations",(e=>{let t=P(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid);return Promise.resolve({body:{anchor:"",conversations:[t]},code:200})})),C(this,"listMessages",((e,t,i)=>{let n=function(e,t,i,n){let r=e+".subizv4.subikon",s={type:"user",id:i,last_page_view_url:"https://subiz.com.vn/",conversation_id:t,membership:"active",invited_by:{id:i,type:"user"}},o={type:"agent",conversation_id:t,id:n,membership:"active",invited_by:{id:i,type:"user"}};return[{id:"evqyiyjmxrjsylftvnrghrfmq",account_id:e,created:1616213202264,type:"conversation_invited",by:{id:i,type:"user"},data:{conversation:{id:t,account_id:e,members:[s],state:"pending"}}},{id:"evqyiyjmyqdgrouswczzawuzp",account_id:e,created:1616213202559,type:"conversation_invited",by:{id:i,type:"user"},data:{conversation:{id:t,account_id:e,members:[o],state:"pending",source:"https://subiz.com.vn/vi/"}}},{id:"evqyiyjmyzjpyehnngvmcyauf",account_id:e,created:1616213202668,type:"conversation_state_updated",by:{id:i,type:"user"},data:{conversation:{id:t,account_id:e,state:"active"}}},{id:"evqyiyjmzaozvqgbkljbwywdl",account_id:e,created:1616213202683,type:"conversation_joined",by:{id:i,type:"user"},data:{conversation:{id:t,members:[s]}}},{id:"evqyiyjmzatvtgpdmmpzwnwgn",account_id:e,created:1616213202685,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:t,text:"Xin chào",format:"plaintext",idempotency_key:"wrueysyjbhqrkiwhsejpqrwqrdkkyaibajdw",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213203068}]}}},{id:"evqyiyjrhsfyuxtetszmvkkke",account_id:e,created:1616213237491,type:"conversation_joined",by:{id:i,type:"user"},data:{conversation:{id:t,members:[o]}}},{id:"evqyiyjrhtroknjyakrlrwhgr",account_id:e,created:1616213237508,type:"message_sent",by:{id:n,client_id:"dashboard",type:"agent"},data:{message:{conversation_id:t,text:"chào bạn, mình có thể giúp gì được cho bạn :grinning:",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"receive",created:1616213237742},{member_id:i,type:"seen",created:1616213240057}]}}},{id:"evqyiyjuvjinmclneroerxmrl",account_id:e,created:1616213265805,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:t,text:"mình muốn hỏi giá sản phẩm IPhone X",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213267090}]}}},{id:"evqyiyjzjxzfcsexshcjbbnnf",account_id:e,created:1616213302432,type:"message_sent",by:{id:n,client_id:"dashboard",type:"agent"},data:{message:{conversation_id:t,text:"IPhone X hiện đang được bán tại cửa hàng với giá 12tr đồng nha bạn",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"receive",created:1616213302698},{member_id:i,type:"seen",created:1616213305071}]}}},{id:"evqyiykaoizbwnkaecwphttwk",account_id:e,created:1616213311830,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:t,text:"ok cám ơn!",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213312110}]}}}]}(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid);return Promise.resolve({body:n,code:200})})),C(this,"ajax",O),C(this,"start",(e=>A)),C(this,"sendConvoEvent",((e,t)=>A)),C(this,"createPostback",((e,t)=>A)),C(this,"markAsReceived",((e,t)=>A)),C(this,"markAsSeen",((e,t)=>A)),C(this,"getConversation",(e=>Promise.resolve({body:P(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid),code:200}))),C(this,"getLocaleContent",(e=>this.apireq.get(`/accounts/${this.accid}/locales/${e}`))),C(this,"sendEvent",(e=>A)),C(this,"submitForm",((e,t,i,n,r)=>A)),C(this,"sendTyping",(e=>A)),C(this,"sendPresence",(e=>A)),C(this,"sendContent",(e=>A)),C(this,"sendLostFocus",(e=>A)),C(this,"sendContentView",(e=>A)),C(this,"uploadToS3",(async e=>A)),C(this,"time",(e=>Promise.resolve({code:200,body:(new d.Date).toISOString()}))),C(this,"updateUser",(e=>A)),C(this,"getUser",(e=>Promise.resolve({code:200,body:{id:"usqzgtgfake",attributes:[{key:"fullname",text:"Kiều Thanh"}]}}))),C(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),C(this,"sendImpression",(e=>A)),C(this,"sendConversion",(e=>A)),this.FileURL=t,this.apireq=O.setBaseUrl(e).setContentType("text/plain").beforeHook(T).setParser("json")}setAgentId(e){this.agentid=e}setAuth(e){return this.accid=e.accid,this.mask=e.mask,this.uid=e.uid,{account_id:this.accid,id:"usqzgtgfake",attributes:[{key:"fullname",text:"Kiều Thanh"}]}}};function P(e,t,i,n){return{id:t,account_id:e,created:1610452894916,members:[{type:"user",id:i,membership:"active",invited_by:{id:i,type:"user"}},{type:"agent",id:n,conversation_id:t,membership:"active",invited_by:{id:i,type:"user"}}],ended:1610454875505,state:"ended",actived:1610453070259,last_message_sent:{id:"evqyiykaoizbwnkaecwphttwk",account_id:e,created:1616213311830,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:t,text:"ok cám ơn!",format:"plaintext",integration_id:e+".subizv4.subikon",pongs:[{member_id:i,type:"seen",created:1616213312110}]}}},assigned_to:{},first_message:"Xin chào",subject:"Chúc một ngày tốt lành",source:"https://subiz.com.vn/"}}const j=class{onEvent(){}onInterrupted(){}subscribe(){}stop(){}getStatus(){return"active"}reconnect(){}};function E(e,t,i){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var I=s(8193),L=s(2839),U=s(5672);U.defaults.path="/",U.expiresMultiplier=86400,U.defaults.expires=3650;const M=d.Date.now();class ${constructor(e,t,i,n,r){if(E(this,"inmem",!1),E(this,"cookie",U),E(this,"getConnectionStatus",(()=>this.connectionStatus)),E(this,"_currentViewingProduct",{}),E(this,"new_visitor",!0),E(this,"matchUser",(()=>(this._touchAcc(),this.cache.match("user")))),E(this,"suggest_addresses",(e=>this.api.suggest_address(e))),E(this,"matchAccount",(()=>this.cache.match("account"))),E(this,"matchPaymentMethods",(()=>this.cache.match("payment_methods"))),E(this,"matchUnread",(()=>{let e=this.matchUser(),t=this.matchConvo("*"),i=0;return d.map(t,(t=>{d.isConvoSeen(t,e.id)||i++})),i})),E(this,"matchPlugin",(()=>d.size(this.forcePlugins)>0?d.cloneDeep(this.forcePlugins):d.cloneDeep(this.cache.match("plugin"))||{})),E(this,"device",{}),E(this,"browserVisibility","visible"),E(this,"matchAgent",(e=>{let t=this.cache.match("agent")||{};return"*"===e?t:t[e]})),E(this,"matchConvo",(e=>{if(e)return"*"===e?(this._touchAcc(),d.filter(this.cache.all(),((e,t)=>t.startsWith("convo_")))):(this.isInsync(e)||this.fetchConvo(e),this.cache.match("convo_"+e))})),E(this,"fetchConvo",(async e=>{if(this._die)return V;if(await this.readyGate.entry(),await this.reconnectGate.entry(void 0,!0),this.isInsync(e))return this.reconnectGate.open();this.markSync(e);let{body:t,error:i}=await this.api.getConversation(e);return t&&!i&&this._setConvo(t),this.reconnectGate.open()})),E(this,"list_provinces",(()=>this.api.list_provinces())),E(this,"list_districts",(e=>this.api.list_districts(e))),E(this,"list_wards",(e=>this.api.list_wards(e))),E(this,"outofmsgM",{}),E(this,"listEvents",(e=>{if(e&&"*"!==e&&"string"==typeof e)return this.chain.listM(e)})),E(this,"fetchMoreEvents",(async e=>{if(!this.isInsync("events"+e)){if(await this.readyGate.entry(),await this.reconnectGate.entry(void 0,!0),this.isInsync("events"+e))return this.reconnectGate.open(),{};this.markSync("events"+e),await this.chain.reload(e,(()=>[[],""]));let t=await this._doFetchMsg(e);return this.reconnectGate.open(),t}return this._doFetchMsg(e)})),E(this,"_doFetchMsg",(async e=>{let{error:t}=await this.chain.fetchMore(e,150,(async(t,i,n)=>{if(this.outofmsgM[e])return[[],""];let[r,s,o,a]=await this.listmessageapi(t,i,n);return a&&(this.outofmsgM[e]=!0),[r,s,o]}));return this.pubsub.publish("account"),{error:t}})),E(this,"matchLocation",(()=>this.cache.match("location")||{})),E(this,"matchBot",(()=>this.cache.match("bot")||{})),E(this,"readyGate",new d.Gate),E(this,"convoGate",new d.Gate(!0)),E(this,"reconnectGate",new d.Gate(!0)),E(this,"wsGate",new d.Gate(!0)),E(this,"matchLastview",(()=>{let e=this.kv.match("lastview")||{},t=this.cache.match("user")||{};return t.id?e.user_id!=t.id?{}:e:{}})),E(this,"matchIsOpen",(()=>!!this.kv.match("isopen"))),E(this,"matchHasManuallyClosed",(()=>!!this.kv.match("hasManuallyClosed"))),E(this,"matchClosePreviewAt",(()=>this.kv.match("close_preview_at")||0)),E(this,"checkFormToken",(e=>this.api.checkFormToken(e))),E(this,"submitForm2",((e,t)=>this.api.submitForm2(e,t))),E(this,"sendPresence",d.throttle((async()=>this._die?V:(await this.readyGate.entry(),d.get(this.cache.match("user"),"id")&&!d.isUserBanned(this.cache.match("user"))&&this._track_page_view?"visible"===this.browserVisibility&&document.hasFocus()?void this.api.sendContentView(this.device,location.href,document.title,this._currentViewingProduct.id,this._currentViewingProduct.source_id,this._currentViewingProduct.sku):this.api.sendLostFocus():void 0)),1e3,{leading:!1})),E(this,"now",(()=>d.Date.now()+this.timeDiff)),E(this,"seenQueue",[]),E(this,"matchTrafficSource",(()=>this.kv.match("traffic_source"))),E(this,"_alreadyReceived",{}),E(this,"_typing",d.throttle((e=>this.api.sendTyping(e)),3e3,{trailing:!1})),E(this,"onConvoEvent",((e,t)=>this.pubsub.on2(e,"events",t))),E(this,"onWidgetClose",((e,t)=>this.pubsub.on2(e,"sbz_close_widget",t))),E(this,"seenConvo",(e=>{e&&"create"!==e&&this.seenQueue.push(e)})),E(this,"onUpdate",((e,t)=>this.pubsub.on2(e,"account",t))),E(this,"onConnection",((e,t)=>this.pubsub.on2(e,"connection",t))),E(this,"onResetCSS",((e,t)=>this.pubsub.on2(e,"resetCSS",t))),E(this,"onHighlight",((e,t)=>this.pubsub.on2(e,"highlight",t))),E(this,"setHasManuallyClosed",(()=>this.kv.put("hasManuallyClosed",!0))),E(this,"setIsOpen",(e=>{let t=this.kv.match("isopen");this.kv.put("isopen",e),!t&&e&&R("SUBIZ Chat","Opened","Subiz Windows")})),E(this,"closePreview",(()=>this.kv.put("close_preview_at",(new d.Date).getTime()))),E(this,"setLastview",((e,t)=>{let i=this.cache.match("user")||{};i.id&&this.kv.put("lastview",{user_id:i.id,view:e,opts:t})})),E(this,"timeDiff",0),this.connectionStatus="active",this.CONNECTION_CHECK_INTERVAL=3e3,this.reconnectTimestamp=0,this.g_sync={},this._die=!1,this.forceDevice=null,this.forcePlugins={},this.forceAcc={},this.forceChatbox={},this.RealtimeURL=i,this.fake=r,this.FileURL=t,this._track_page_view=!0,this.device_type="desktop",this.fake?this.api=new z(e,t):this.api=new m(e,t),!n)try{document.cookie,localStorage}catch(e){n=!0}n&&(this.inmem=n,this.cookie=D),F(),this.pubsub=new d.Pubsub,this.kv=new S(new v("sbz2023",this.inmem),"kv"),this.cache=new S(new v("sbz2023",!0),"kv"),this.chain=new b(new v("cbz2023",!0),"ch"),this.getLocaleContent=this.api.getLocaleContent,this.g_haveSentSeenM={},this.last_focused=d.Date.now(),window.addEventListener("blur",(()=>{this.last_focused=d.Date.now(),this.sendPresence()})),window.addEventListener("focus",(()=>{this.last_focused=0,this.sendPresence()})),window.addEventListener("beforeunload",(()=>this.api.sendLostFocus())),this.doNotStartBot=()=>{this._donotstartbot=!0},this.autoStartBot=()=>{this._donotstartbot=!1},this.matchAutoStartBot=()=>!this._donotstartbot,this._presenceInterval1=d.setInterval((()=>{if(this._die)return d.clearInterval(this._presenceInterval1);"visible"===this.browserVisibility&&document.hasFocus()&&this.sendPresence()}),2e4),this._presenceInterval2=d.setInterval((()=>{if(this._die)return d.clearInterval(this._presenceInterval2);"visible"===this.browserVisibility&&document.hasFocus()||this.last_focused&&d.Date.now()-this.last_focused>18e5||this.sendPresence()}),6e4),function(e){var t="hidden";function i(i){var n="visible",r="hidden",s={focus:n,focusin:n,pageshow:n,blur:r,focusout:r,pagehide:r};(i=i||window.event).type in s?e(s[i.type]):e(this[t]?"hidden":"visible")}t in document?document.addEventListener("visibilitychange",i):(t="mozHidden")in document?document.addEventListener("mozvisibilitychange",i):(t="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",i):(t="msHidden")in document?document.addEventListener("msvisibilitychange",i):"onfocusin"in document?document.onfocusin=document.onfocusout=i:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=i,void 0!==document[t]&&i({type:document[t]?"blur":"focus"})}((e=>{this._die||(this.browserVisibility=e,this.sendPresence())})),this.loopTime(),this.device=this.getDeviceInfo();const s=d.setInterval((()=>{let e=this.cache.match("user")||{};if(!e.id)return;var t=this.getDeviceInfo();if(!t.ga_tracking_ids||!t.ga_client_id)return;d.clearInterval(s),this.device=t;let i=t.ga_client_id;i!==d.getUserAttr(e,"ga_client_id","text")&&this.setUser({attributes:[{type:"text",text:i,key:"ga_client_id"}]})}),2e3)}async loopCheckConnectionStatus(){for(;!this._die;){if(await d.sleep(this.CONNECTION_CHECK_INTERVAL),!this.realtime)continue;if(!this.realtime.getStatus||!this.realtime.reconnect)continue;"dead"===this.connectionStatus&&await this.realtime.reconnect();let e=this.connectionStatus;this.connectionStatus=this.realtime.getStatus(),e!==this.connectionStatus&&(console.log("publish connectionStatus",this.connectionStatus),this.pubsub.publish("connection"))}}linkProduct(e){e?(e.id&&(this._currentViewingProduct.id=(e.id+"").trim()),e.source_id&&(this._currentViewingProduct.source_id=(e.source_id+"").trim()),e.sku&&(this._currentViewingProduct.sku=(e.sku+"").trim())):this._currentViewingProduct={}}getTrackPageview(){return this._track_page_view}setTrackPageview(e){this._track_page_view=!!e}getLinkedProduct(){return d.cloneDeep(this._currentViewingProduct)}isInsync(e){return d.Date.now()-(this.g_sync[e]||0)<6e5}async fetchShippingAddresses(){let e=await this.api.fetchShippingAddresses();if(e.error)return null;this.cache.put("shipping_address",e.body.shipping_addresses)}matchShippingAddresses(){return this.cache.match("shipping_address")}updateOrder(e){return this.api.updateOrder(e)}createShippingAddress(e){return this.api.createShippingAddress(e)}createTicket(e){return this.api.create_ticket(e)}async overrideAcc(e){this.forceAcc=d.cloneDeep(e),await this.readyGate.entry(),this.reconnect()}async overrideChatbox(e){this.forceChatbox=e,await this.readyGate.entry(),await this.reconnect(),d.setTimeout(this.pubsub.publish("resetCSS"),10)}getDeviceInfo(){let e={screen_resolution:window.screen.width+"x"+window.screen.height,source_referrer:document.referrer,platform:window.navigator.platform,language:navigator.language,page_url:document.URL,page_title:document.title},t=function(){if(!window.ga)return;if(!window.ga.getAll)return;var e=window.ga.getAll()||[];let t="";return e.forEach((function(e){t=e.get("clientId")})),t}();t&&(e.ga_client_id=t);let i=(n=[],window.ga&&window.ga.getAll?window.ga&&window.ga.getAll?((window.ga.getAll()||[]).forEach((function(e){var t=e.get("trackingId");t&&n.push(t)})),n):[]:n);var n;return i.length>0&&(e.ga_tracking_ids=i),e}highlight(e,t){this.pubsub.publish("highlight",e,t)}emitConvoEvent(e){this.pubsub.publish("events",e)}setAIDevMode(e){this.ai_dev_mode=e}isAIDevMode(){return this.ai_dev_mode}overrideDeviceType(e){this.forceDevice=e,this.pubsub.publish("account")}isMobile(){return this.forceDevice?"mobile"===this.forceDevice:"mobile"==this.device_type||d.get(window,"screen.width",1e3)<576}isTablet(){return this.forceDevice?"tablet"===this.forceDevice:"tablet"==this.device_type}isDesktop(){return this.forceDevice?"desktop"===this.forceDevice:!this.isMobile()&&!this.isTable()}disconnect(e){this.g_sync[e]=0}pageLoaded(){return M}overridePlugin(e){if(this._die)return V;if(!Array.isArray(e))throw"plugins must be be an array";let t={};d.map(e,(function(e){t[e.id]=e})),this.forcePlugins=t,this.pubsub.publish("account"),this.pubsub.publish("resetCSS")}markSync(e){this.g_sync[e]=d.Date.now()}async _touchAcc(){this.isInsync("account")||(await this.readyGate.entry(),this.isInsync("account")||this.reconnect())}async init(e,t,i,n){if(this.readyGate.close(),e=(e||"").trim(),this.g_sync={},n&&n.use_subdomain_cookie||window&&window.location&&window.location.hostname&&(U.defaults.domain="."+window.location.hostname),!i){try{i=this.cookie.get("__sbref","")}catch(e){}if(!i){if(!t)try{t=this.cookie.get("__sbmask","")}catch(e){}t?(t.split("@")[0]!=e&&(i=d.randomString(40),this.new_visitor=!0),this.new_visitor=!1,this.cookie.set("__sbmask",t)):(i=d.randomString(40),this.new_visitor=!0)}}this.cookie.get("__sbref",i)!=i&&W(),this.api.setAuth({accid:e}),i&&this.cookie.set("__sbref",i);let r=await this.api.setAuth({accid:e,mask:t,ref:i});return r.error?console.error(r):(this.realtime&&this.realtime.stop(),this.fake?this.realtime=new j:this.realtime=new L(this.RealtimeURL,{account_id:e,user_ref:i,user_mask:t},N),this.realtime.onEvent(this.onWs.bind(this)),this.realtime.onInterrupted((async()=>{await this.reconnectWs(e,r.id),this.reconnect()})),this.seenLoop(),await this.reconnect({user:r}),this.readyGate.open(),this.reconnectWs(e,r.id),this.loopCheckConnectionStatus(),r)}async login(e,t,i){if(this._die)return V;let n=await this.api.setAuth({accid:e,profile_id:t,tokenGenerator:i});return n.error||(this.clearBrowserData(),this.readyGate.close(),e=(e||"").trim(),this.g_sync={},this.new_visitor=!1,this.realtime&&this.realtime.stop(),this.fake?this.realtime=new j:this.realtime=new L(this.RealtimeURL,{getAccessToken:()=>this.api.token_generator()}),this.realtime.onEvent(this.onWs.bind(this)),this.realtime.onInterrupted((async()=>{await this.reconnectWs(e,n.id),this.reconnect()})),this.seenLoop(),await this.reconnect(),this.readyGate.open(),this.reconnectWs(e,n.id)),n}logout(e){return this.api.setAuth({ref:e})}seenLoop(){this.seenQueue=[],d.clearInterval(this._seenInterval),this._seenInterval=d.setInterval((()=>{if(this._die)return d.clearInterval(this._seenInterval);this.seenQueue=[...new Set(this.seenQueue)];let e=this.cache.match("user")||{};d.map(this.seenQueue,(t=>{var i=this.listEvents(t);if(!i)return;if(0===d.size(i))return;var n=(i=d.filter(i,(e=>"message_sent"===e.type)))[d.size(i)-1];if(!n)return;if(this.g_haveSentSeenM[n.id])return;if(n.id===n.data.message.idempotency_key)return;this.api.markAsSeen(t,n.id),this.pubsub.publish("events",{created:d.Date.now(),type:"message_pong",by:{type:"user"},data:{message:{conversation_id:t,id:"*",pongs:[{type:"seen",created:d.Date.now()}]}}});let r=this.cache.match("convo_"+t)||{},s=d.find(r.members,(t=>t.id===e.id));s&&(s.seen_at=d.Date.now()),this._setConvo(r),this.g_haveSentSeenM[n.id]=!0})),this.seenQueue=[]}),1e3)}async reconnectWs(e,t){await this.realtime.subscribe([`conversation_state_updated.account.${e}.user.${t}`,`conversation_joined.account.${e}.user.${t}`,`conversation_typing.account.${e}.user.${t}`,`message_sent.account.${e}.user.${t}`,`message_pong.account.${e}.user.${t}`,`conversation_rating_requested.account.${e}.user.${t}`,`conversation_rated.account.${e}.user.${t}`]),await this.readyGate.entry()}async reconnect(e){if(this._die)return;await this.reconnectGate.entry(void 0,!0),this.markSync("account");let t=e&&e.user?Promise.resolve({body:e.user}):this.api.getUser(),i=await Promise.all([t,this.api.getAccountSetting()]),n=d.find(i,(e=>e.error));if(n)return console.error(n);let r=i[1].body;r.user=i[0].body,await this._setSetting(r);let s=await this.api.listConversations();n=s.error;let o=s.body;if(!n){let e=d.get(o,"conversations",[]);d.map(this.cache.all(),((e,t)=>{t.startsWith("convo_")&&this.now()-d.getMs(d.get(e,"actived"))>12096e5&&this.cache.del(t)})),d.map(e,(e=>this._setConvo(e)))}return this.reconnectGate.open()}async submitForm(e,t,i){return await this.readyGate.entry(),i&&await this.setUser(i),this.api.submitForm(e,document.URL,this.device,t,i)}async setUser(e){if(e)return await this.readyGate.entry(),this._setUser(e),this.api.updateUser(e)}async setUserDiff(e){if(!e)return;await this.readyGate.entry();let t=await this.api.updateUser(e);t&&200==t.code&&t.body.id&&this._setUser(t.body)}_setUser(e){e=d.cloneDeep(e);let t=this.cache.match("user")||{};var i=t.account_id||e.account_id,n=t.id||e.id;d.each(e.attributes,(e=>{e&&(t.attributes=d.filter(t.attributes,(t=>!!t&&t.key!==e.key)))})),t.attributes=t.attributes||[],t.attributes=t.attributes.concat(e.attributes),t.account_id=i,t.id=n,this.cache.put("user",t),this.pubsub.publish("account")}async setSetting(e){if(e)return await this.readyGate.entry(),this._setSetting(e)}async _setSetting(e){(e=d.cloneDeep(e)||{}).account=Object.assign({},e.account,this.forceAcc),e.account.logo_url||(e.account.logo_url="https://vcdn.subiz-cdn.com/file/fiqpezhkmeyesdscyetk-default_logo.jpg"),e.user&&(e.user.account_id=e.account.id,delete e.user.session,this._setUser(e.user)),e.account&&(e.account.is_online=e.is_online,e.account.is_in_business_hour=e.is_in_business_hour,this.cache.put("account",e.account),delete e.account);let t=d.get(e,"location",[]);this.cache.put("location",t);let i=d.get(e,"bots",[]),n={};d.map(i,(e=>{n[e.id]=e})),this.cache.put("bot",n),this.device_type=e.device_type||"desktop";let r=d.get(e,"plugins",[]),s={};d.map(r,(e=>{"chatbox"===e.type&&(e=d.merge(e,this.forceChatbox)),s[e.id]=e})),this.cache.put("plugin",s);var o=d.get(e,"agents",[]);if(d.size(o)>0){let e={};this.api.setAgentId(o[0].id),d.map(o,(t=>{e[t.id]=t})),this.cache.put("agent",e)}let a=d.get(e,"payment_methods",[]);this.cache.put("payment_methods",a),this.pubsub.publish("account")}async track(){let e=await this.api.sendContentView(this.device,location.href,document.title,this._currentViewingProduct.id,this._currentViewingProduct.source_id,this._currentViewingProduct.sku),t=d.get(e,"body.by.device.source","");t&&this.kv.put("traffic_source",t)}async onWs(e){await this.wsGate.entry(),this.wsGate.close(),await this._onWs(e),this.wsGate.open()}async _onWs(e){if(this._die)return;if(!e||!e.type)return;if(e.created=d.getMs(e.created),"user_info_updated"===e.type)return;let t,i=this.cache.match("user")||{},n=d.convoOfEv(e),r=!1;if(n&&(t=this.cache.match("convo_"+n),!t||!t.id)){let{body:e,error:i}=await this.api.getConversation(n);if(!e)return;t=e,r=!0,this._setConvo(t)}if(t){if(this.pubsub.publish("events",e),"conversation_joined"===e.type){let i=d.get(e,"data.conversation.members",[]),s=d.find(i,(e=>e.id===this.cache.match("user").id));if(s&&!r){let{body:e}=await this.api.getConversation(n);e&&(t=e,this._setConvo(t)),this.pubsub.publish("account")}}return"message_sent"===e.type&&d.get(e,"by.id")!==i.id&&(this._alreadyReceived[e.id]||(this._alreadyReceived[e.id]=!0,this.api.markAsReceived(n,e.id))),d.startsWith(e.type,"message_")||d.startsWith(e.type,"conversation_")?(this.restConvoEvent(e),void("message_sent"===e.type&&d.get(e,"by.id")!==i.id&&R("SUBIZ Chat","Received","User"))):void 0}}async restConvoEvent(e){let t=this.cache.match("user"),i=d.convoOfEv(e),n=this.cache.match("convo_"+i)||{};if("conversation_state_updated"===e.type){if(!d.get(n,"id")){let{body:e,error:t}=await this.api.getConversation(i);if(t)return}n=Object.assign(n,d.get(e,"data.conversation"))}if("message_pong"===e.type){var r=d.get(e,"data.message.id"),s=this.chain.match(i,r);if(!d.get(s,"data.message"))return;var o=d.get(s,"data.message.pongs",[]);let a=d.get(e,"data.message.pongs",[])||[];if(o=o.concat(a),1===a.length){let e=a[0].type;"like"!==e&&"remove_dislike"!==e||(o=o.filter((e=>"dislike"!==e.type))),"dislike"!==e&&"remove_like"!==e||(o=o.filter((e=>"like"!==e.type)))}s.data.message.pongs=o,d.map(o,(e=>{if(e.member_id==t.id&&"seen"===e.type){let i=d.find(n.members,(e=>e.id===t.id));i&&(i.seen_at=e.created)}})),this.chain.put(i,s.id,d.getMs(s.created),s),this.pubsub.publish("events",s)}if("message_sent"===e.type){let t=d.get(e,"data.message.idempotency_key"),r=d.find(this.listEvents(i),(e=>e.id===t));r&&(this.chain.del(i,r.id),e.created=r.created),n.last_message_sent=e}"message_pong"!==e.type&&"conversation_typing"!==e.type&&this.chain.put(i,e.id,d.getMs(e.created),e),this._setConvo(n),this.pubsub.publish("account")}emitCloseWidgetEvent(){this.pubsub.publish("sbz_close_widget",{type:"chatbox_closed"})}typing(e){e&&this._typing(e)}async startConvo(e){e||(e={}),await this.readyGate.entry(),this.convoGate.close(),e.source||(e.source=document.location.href);let{body:t,error:i}=await this.api.start(e);return this.convoGate.open(),i?{error:i}:(this._setConvo(t),{convo:t})}fetchOrder(e){return this.api.getOrder(e)}lookupOrder(e){return this.api.lookupOrder(e)}createPostback(e,t){return this.api.createPostback(e,t)}sendReaction(e,t){return this.api.sendConvoEvent(e,t)}async sendConvoEvent(e,t,i){await this.readyGate.entry();var n=d.randomString(36),r={id:n,by:{id:(this.cache.match("user")||{}).id,type:"user",device:this.device},data:i,type:t,created:this.now()};d.convoToEv(e,r);let s=[];if("message_sent"===t&&(r.data.message.idempotency_key=n,r.data.message.conversation_id=e,await I.map(r.data.message.attachments,2,(async(e,t)=>{var i;if("file"===e.type&&e._file&&(s.push(e),q.includes(e._file.type))){let{width:t,height:n,url:r}=await(i=e._file,new Promise((e=>{var t=new window.FileReader;t.onload=t=>{let i=t.target.result,n=new Image;n.onload=()=>{e({url:i,width:n.width,height:n.height})},n.src=i},t.readAsDataURL(i)})));e.url=r,e.width=t,e.height=n}}))),this.onWs(r),await this.convoGate.entry(),await I.map(s,1,(async e=>{const{body:t,url:i,error:n}=await this.api.uploadToS3(e._file);"invalid_field_size"==d.get(t,"code")&&(r._error_message="cannot_send_too_big_file"),r._error=n,e.url=i})),r._error)return this.onWs(r);let{body:o,error:a}=await this.api.sendConvoEvent(e,r);return a?(r._error=a,void this.onWs(r)):(this.onWs(o),R("SUBIZ Chat","Sent","User"),this.kv.match("last_msg_sent")||(window.dataLayer||[]).push({event:"SUBIZ Chat",event_action:"Sent",event_label:"User",first_interaction:1}),this.kv.put("last_msg_sent",d.Date.now()),o)}_setConvo(e){this.cache.match("user");let t=d.get(e,"touchpoint.channel","");if(t&&"subiz"!=t)return;let i={};if(d.map(this.cache.all(),((e,t)=>{t.startsWith("convo_")&&(i[t]=e)})),d.size(i)>18){i=d.orderBy(d.map(i),"created","desc");for(var n=18;n<d.size(i);n++){let e=i[n];this.cache.del("convo_"+e.id)}}this.markSync(e.id),this.pubsub.publish("account"),this.cache.put("convo_"+e.id,e)}matchLastPluginRun(e){return(this.kv.match("plugin_run_logs")||{})[e]}matchLastBotRun(e){return(this.kv.match("bot_run_logs")||{})[e]}logBotRun(e){let t=this.kv.match("bot_run_logs")||{};t[e]={bot_id:e,created:this.now()},this.kv.put("bot_run_logs",t)}sendImpression(e){let t=this.cache.match("user")||{},i=this.kv.match("plugin_run_logs")||{};return i[e]={web_plugin_id:e,created:this.now()},this.kv.put("plugin_run_logs",i),this.api.sendImpression({account_id:t.account_id,campaign_id:e,web_plugin_id:e,user_id:t.id,url:window.location.href,device:this.device})}sendConversion(e,t,i){let n=this.cache.match("user")||{},r={account_id:n.account_id,user_id:n.id,fields:t},s=this.kv.match("conversions")||{};return s[e]=!0,this.kv.put("conversions",s),this.api.sendConversion({account_id:n.account_id,web_plugin_id:e,campaign_id:e,user_id:d.get(n,"id"),url:window.location.href,device:this.device,submission:r,impression_token:i})}isConverted(e){return(this.kv.match("conversions")||{})[e]}async listmessageapi(e,t,i){let n=e,{body:r,code:s,error:o}=await this.api.listMessages(n,-i,t);if(o||200!==s)return[[],t,o];t=d.get(d.last(r),"id"),r=d.map(r,(e=>(e.created=d.getMs(e.created),{id:e.id,index:e.created,value:e})));let a=this.cache.match("user")||{};for(let e=0;e<r.length;e++){let t=r[e].value;if("message_sent"!==t.type)continue;if(d.get(t,"by.id")===a.id)continue;let i=d.find(d.get(t,"data.message.pongs"),(e=>e.member_id===a.id));if(i)break;this._alreadyReceived[t.id]||(this._alreadyReceived[t.id]=!0,this.api.markAsReceived(n,t.id));break}return[r,t,void 0,d.size(r)<i]}async loopTime(){if(this._die)return;let e=d.Date.now();if(!d.get(this.cache.match("user"),"id"))return d.setTimeout((()=>this.loopTime()),24e4);let{body:t,error:i}=await this.api.time();if(i)return d.setTimeout((()=>this.loopTime()),3e4);var n=Math.abs(d.Date.now()-e)/2,r=new d.Date(t).getTime()+n,s=d.Date.now();this.timeDiff=Math.floor(r-s),d.setTimeout((()=>this.loopTime()),24e4)}replaceFileUrl(e){return e?d.startsWith(e,"/")||d.startsWith(e,"data:")?e:(d.startsWith(e,"http://")||d.startsWith(e,"https://")||d.startsWith(e,"//")||(e=d.trim(this.FileURL,"/")+"/"+d.trimStart(e,"/")),e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace("https://file-subiz.com/",this.FileURL)).replace("http://file-subiz.com/",this.FileURL)).replace("https://file-v4.subiz.com/",this.FileURL)).replace("http://file-v4.subiz.com/",this.FileURL)).replace("https://filev4.subiz.com/",this.FileURL)).replace("http://filev4.subiz.com/",this.FileURL)).replace("https://filev4-1.subiz.com/",this.FileURL)).replace("http://filev4-1.subiz.com/",this.FileURL)).replace("https://file.subiz.com/",this.FileURL)).replace("http://file.subiz.com/",this.FileURL)).replace("https://file.mysubiz.com/",this.FileURL)).replace("http://file.mysubiz.com/",this.FileURL)):""}clearBrowserData(){d.each(this.cookie.all(),((e,t)=>{(t||"").startsWith("__sb")&&this.cookie.remove(t)})),this.kv.destroy(),this.kv=new S(new v("sbz2023",this.inmem),"kv"),this.chain.destroy(),this.chain=new b(new v("cbz2023",!0),"ch")}destroy(){this._die=!0,this.kv&&this.kv.destroy(),this.chain&&this.chain.destroy(),d.clearInterval(this._seenInterval),this.realtime&&this.realtime.stop(),this.readyGate.close(),window.removeEventListener("blur",this.sendPresence),window.removeEventListener("focus",this.sendPresence)}}const q=["image/gif","image/jpeg","image/png","image/svg+xml"],D={data:{},get(e,t){return this.data[e]||t},set(e,t){return this.data[e]=e},all(){return this.data},remove(e){delete this.data[e]}};function R(e,t,i){document.dispatchEvent(new CustomEvent("subiz",{detail:{category:e,action:t,label:i}})),function(e,t,i){window.sbz_no_gtag?console.log("SKIPSENT.",e,t,i):((window.dataLayer||[]).push({event:e,event_action:t,event_label:i}),window.gtag&&window.gtag("event",e,{Action:t,Label:i}),window.ga&&window.ga.getAll&&(window.ga.getAll()||[]).forEach((function(n){const r=n.get("name");window.ga(r+".send","event",e,t,i)})))}(e,t,i),function(e,t,i){window.fbq&&window.fbq("trackCustom",e,{action:t,label:i})}(e,t,i)}let F=()=>{try{localStorage}catch(e){return}d.setTimeout((()=>{for(var e in localStorage)e&&(e.startsWith("cbz2020")||e.startsWith("sbz2020"))&&localStorage.removeItem(e)}))},W=()=>{try{localStorage}catch(e){return}d.setTimeout((()=>{for(var e in localStorage)e&&(e.startsWith("cbz2020")||e.startsWith("sbz2020")||e.startsWith("sbz2022")||e.startsWith("sbz2023"))&&localStorage.removeItem(e)}))};var N=function(e,t,i,n){if(void 0===d.XMLHttpRequest)return function(e,t,i,n){let r={};i&&(r["content-type"]="text/plain"),fetch(t,{method:e,headers:r,body:i}).then((e=>e.text().then((t=>n&&n(t,e.status))))).catch((e=>n&&n(e,-1)))}(e,t,i,n);var r=new d.XMLHttpRequest;r.onreadystatechange=function(e){4===r.readyState&&(n&&n(r.responseText,r.status),n=void 0)},r.onerror=function(){n&&n(r.responseText,-1),n=void 0},r.open(e,t),i&&r.setRequestHeader("content-type","text/plain"),r.send(i)};const V=new Error("sdk unloaded");var H,B,G,Q,J,X,Z,K={},Y=[],ee=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,te=Array.isArray;function ie(e,t){for(var i in t)e[i]=t[i];return e}function ne(e){var t=e.parentNode;t&&t.removeChild(e)}function re(e,t,i){var n,r,s,o={};for(s in t)"key"==s?n=t[s]:"ref"==s?r=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?H.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===o[s]&&(o[s]=e.defaultProps[s]);return se(e,o,n,r,null)}function se(e,t,i,n,r){var s={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++G:r,__i:-1,__u:0};return null==r&&null!=B.vnode&&B.vnode(s),s}function oe(e){return e.children}function ae(e,t){this.props=e,this.context=t}function ce(e,t){if(null==t)return e.__?ce(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?ce(e):null}function ue(e){var t,i;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e){e.__e=e.__c.base=i.__e;break}return ue(e)}}function le(e){(!e.__d&&(e.__d=!0)&&Q.push(e)&&!he.__r++||J!==B.debounceRendering)&&((J=B.debounceRendering)||X)(he)}function he(){var e,t,i,n,r,s,o,a,c;for(Q.sort(Z);e=Q.shift();)e.__d&&(t=Q.length,n=void 0,s=(r=(i=e).__v).__e,a=[],c=[],(o=i.__P)&&((n=ie({},r)).__v=r.__v+1,B.vnode&&B.vnode(n),be(o,n,r,i.__n,void 0!==o.ownerSVGElement,32&r.__u?[s]:null,a,null==s?ce(r):s,!!(32&r.__u),c),n.__.__k[n.__i]=n,we(a,n,c),n.__e!=s&&ue(n)),Q.length>t&&Q.sort(Z));he.__r=0}function de(e,t,i,n,r,s,o,a,c,u,l){var h,d,p,f,_,m=n&&n.__k||Y,g=t.length;for(i.__d=c,pe(i,t,m),c=i.__d,h=0;h<g;h++)null!=(p=i.__k[h])&&"boolean"!=typeof p&&"function"!=typeof p&&(d=-1===p.__i?K:m[p.__i]||K,p.__i=h,be(e,p,d,r,s,o,a,c,u,l),f=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&xe(d.ref,null,p),l.push(p.ref,p.__c||f,p)),null==_&&null!=f&&(_=f),65536&p.__u||d.__k===p.__k?c=fe(p,c,e):"function"==typeof p.type&&void 0!==p.__d?c=p.__d:f&&(c=f.nextSibling),p.__d=void 0,p.__u&=-196609);i.__d=c,i.__e=_}function pe(e,t,i){var n,r,s,o,a,c=t.length,u=i.length,l=u,h=0;for(e.__k=[],n=0;n<c;n++)null!=(r=e.__k[n]=null==(r=t[n])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?se(null,r,null,null,r):te(r)?se(oe,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?se(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=_e(r,i,o=n+h,l),r.__i=a,s=null,-1!==a&&(l--,(s=i[a])&&(s.__u|=131072)),null==s||null===s.__v?(-1==a&&h--,"function"!=typeof r.type&&(r.__u|=65536)):a!==o&&(a===o+1?h++:a>o?l>c-o?h+=a-o:h--:h=a<o&&a==o-1?a-o:0,a!==n+h&&(r.__u|=65536))):(s=i[n])&&null==s.key&&s.__e&&(s.__e==e.__d&&(e.__d=ce(s)),Se(s,s,!1),i[n]=null,l--);if(l)for(n=0;n<u;n++)null!=(s=i[n])&&!(131072&s.__u)&&(s.__e==e.__d&&(e.__d=ce(s)),Se(s,s))}function fe(e,t,i){var n,r;if("function"==typeof e.type){for(n=e.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=e,t=fe(n[r],t,i));return t}return e.__e!=t&&(i.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function _e(e,t,i,n){var r=e.key,s=e.type,o=i-1,a=i+1,c=t[i];if(null===c||c&&r==c.key&&s===c.type)return i;if(n>(null==c||131072&c.__u?0:1))for(;o>=0||a<t.length;){if(o>=0){if((c=t[o])&&!(131072&c.__u)&&r==c.key&&s===c.type)return o;o--}if(a<t.length){if((c=t[a])&&!(131072&c.__u)&&r==c.key&&s===c.type)return a;a++}}return-1}function me(e,t,i){"-"===t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||ee.test(t)?i:i+"px"}function ge(e,t,i,n,r){var s;e:if("style"===t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof n&&(e.style.cssText=n=""),n)for(t in n)i&&t in i||me(e.style,t,"");if(i)for(t in i)n&&i[t]===n[t]||me(e.style,t,i[t])}else if("o"===t[0]&&"n"===t[1])s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=i,i?n?i.u=n.u:(i.u=Date.now(),e.addEventListener(t,s?ve:ye,s)):e.removeEventListener(t,s?ve:ye,s);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,i))}}function ye(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(B.event?B.event(e):e)}function ve(e){return this.l[e.type+!0](B.event?B.event(e):e)}function be(e,t,i,n,r,s,o,a,c,u){var l,h,d,p,f,_,m,g,y,v,b,w,k,x,S,C=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(c=!!(32&i.__u),s=[a=t.__e=i.__e]),(l=B.__b)&&l(t);e:if("function"==typeof C)try{if(g=t.props,y=(l=C.contextType)&&n[l.__c],v=l?y?y.props.value:l.__:n,i.__c?m=(h=t.__c=i.__c).__=h.__E:("prototype"in C&&C.prototype.render?t.__c=h=new C(g,v):(t.__c=h=new ae(g,v),h.constructor=C,h.render=Ce),y&&y.sub(h),h.props=g,h.state||(h.state={}),h.context=v,h.__n=n,d=h.__d=!0,h.__h=[],h._sb=[]),null==h.__s&&(h.__s=h.state),null!=C.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=ie({},h.__s)),ie(h.__s,C.getDerivedStateFromProps(g,h.__s))),p=h.props,f=h.state,h.__v=t,d)null==C.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==C.getDerivedStateFromProps&&g!==p&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(g,v),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(g,h.__s,v)||t.__v===i.__v)){for(t.__v!==i.__v&&(h.props=g,h.state=h.__s,h.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.forEach((function(e){e&&(e.__=t)})),b=0;b<h._sb.length;b++)h.__h.push(h._sb[b]);h._sb=[],h.__h.length&&o.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(g,h.__s,v),null!=h.componentDidUpdate&&h.__h.push((function(){h.componentDidUpdate(p,f,_)}))}if(h.context=v,h.props=g,h.__P=e,h.__e=!1,w=B.__r,k=0,"prototype"in C&&C.prototype.render){for(h.state=h.__s,h.__d=!1,w&&w(t),l=h.render(h.props,h.state,h.context),x=0;x<h._sb.length;x++)h.__h.push(h._sb[x]);h._sb=[]}else do{h.__d=!1,w&&w(t),l=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++k<25);h.state=h.__s,null!=h.getChildContext&&(n=ie(ie({},n),h.getChildContext())),d||null==h.getSnapshotBeforeUpdate||(_=h.getSnapshotBeforeUpdate(p,f)),de(e,te(S=null!=l&&l.type===oe&&null==l.key?l.props.children:l)?S:[S],t,i,n,r,s,o,a,c,u),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),m&&(h.__E=h.__=null)}catch(e){t.__v=null,c||null!=s?(t.__e=a,t.__u|=c?160:32,s[s.indexOf(a)]=null):(t.__e=i.__e,t.__k=i.__k),B.__e(e,t,i)}else null==s&&t.__v===i.__v?(t.__k=i.__k,t.__e=i.__e):t.__e=ke(i.__e,t,i,n,r,s,o,c,u);(l=B.diffed)&&l(t)}function we(e,t,i){t.__d=void 0;for(var n=0;n<i.length;n++)xe(i[n],i[++n],i[++n]);B.__c&&B.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){B.__e(e,t.__v)}}))}function ke(e,t,i,n,r,s,o,a,c){var u,l,h,d,p,f,_,m=i.props,g=t.props,y=t.type;if("svg"===y&&(r=!0),null!=s)for(u=0;u<s.length;u++)if((p=s[u])&&"setAttribute"in p==!!y&&(y?p.localName===y:3===p.nodeType)){e=p,s[u]=null;break}if(null==e){if(null===y)return document.createTextNode(g);e=r?document.createElementNS("http://www.w3.org/2000/svg",y):document.createElement(y,g.is&&g),s=null,a=!1}if(null===y)m===g||a&&e.data===g||(e.data=g);else{if(s=s&&H.call(e.childNodes),m=i.props||K,!a&&null!=s)for(m={},u=0;u<e.attributes.length;u++)m[(p=e.attributes[u]).name]=p.value;for(u in m)p=m[u],"children"==u||("dangerouslySetInnerHTML"==u?h=p:"key"===u||u in g||ge(e,u,null,p,r));for(u in g)p=g[u],"children"==u?d=p:"dangerouslySetInnerHTML"==u?l=p:"value"==u?f=p:"checked"==u?_=p:"key"===u||a&&"function"!=typeof p||m[u]===p||ge(e,u,p,m[u],r);if(l)a||h&&(l.__html===h.__html||l.__html===e.innerHTML)||(e.innerHTML=l.__html),t.__k=[];else if(h&&(e.innerHTML=""),de(e,te(d)?d:[d],t,i,n,r&&"foreignObject"!==y,s,o,s?s[0]:i.__k&&ce(i,0),a,c),null!=s)for(u=s.length;u--;)null!=s[u]&&ne(s[u]);a||(u="value",void 0!==f&&(f!==e[u]||"progress"===y&&!f||"option"===y&&f!==m[u])&&ge(e,u,f,m[u],!1),u="checked",void 0!==_&&_!==e[u]&&ge(e,u,_,m[u],!1))}return e}function xe(e,t,i){try{"function"==typeof e?e(t):e.current=t}catch(e){B.__e(e,i)}}function Se(e,t,i){var n,r;if(B.unmount&&B.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||xe(n,null,t)),null!=(n=e.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(e){B.__e(e,t)}n.base=n.__P=null,e.__c=void 0}if(n=e.__k)for(r=0;r<n.length;r++)n[r]&&Se(n[r],t,i||"function"!=typeof e.type);i||null==e.__e||ne(e.__e),e.__=e.__e=e.__d=void 0}function Ce(e,t,i){return this.constructor(e,i)}H=Y.slice,B={__e:function(e,t,i,n){for(var r,s,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((s=r.constructor)&&null!=s.getDerivedStateFromError&&(r.setState(s.getDerivedStateFromError(e)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,n||{}),o=r.__d),o)return r.__E=r}catch(t){e=t}throw e}},G=0,ae.prototype.setState=function(e,t){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=ie({},this.state),"function"==typeof e&&(e=e(ie({},i),this.props)),e&&ie(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),le(this))},ae.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),le(this))},ae.prototype.render=oe,Q=[],X="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Z=function(e,t){return e.__v.__b-t.__v.__b},he.__r=0;class Oe extends ae{constructor(e){super(e),this._isMounted=!0,d.setTimeout((()=>{if(this.componentWillUnmount){let e=this.componentWillUnmount.bind(this);this.componentWillUnmount=()=>{e(),this._isMounted=!1}}}),10)}}let Te={},Ae=!1;function ze(e,t,i){if(Ae)return new Promise((n=>d.setTimeout((()=>ze(e,t,i).then(n)),100)));let n;return Ae=!0,"debug"===t||Te[t]&&!i?(Ae=!1,Promise.resolve()):e.getLocaleContent(t).then((e=>{Ae=!1,n=d.get(e,"body.messages",[]),Te[t]=n}))}class Pe extends Oe{render(){var e=this.props.emojiCode;if(d.size(e)<3)return null;var t=e.replace(/:/g,"");return re("i",{"data-tooltip":e,class:`emoji emoji--${t}`})}}class je extends Oe{constructor(e){super(e)}renderBlock(e){if(0==d.size(e))return null;let t={style:""};if(e.style&&d.map(e.style,((e,i)=>{t.style+=i+": "+e+";"})),t.attrs={},""!=e.title&&(t.attrs.title=e.title),""!=e.href&&(t.attrs.href=e.href),t.class=e.class,d.map(e.attrs,((e,i)=>{t.attrs[i]=e})),"bullet_list"!=e.type&&"ordered_list"!=e.type||("bullet_list"==e.type?t.tag="ol":t.tag="ul"),"list_item"==e.type&&(t.tag="li"),"heading"==e.type&&(e.level<1&&(e.level=1),e.level>6&&(e.level=6),t.tag="h"+e.level),"paragraph"!=e.type&&"section"!=e.type&&"div"!=e.type||(t.tag="div"),t.text=e.text,""!=e.type&&"text"!=e.type&&"dynamic-field"!=e.type||(t.tag="span",e.bold&&(t.tag="b"),e.italic&&("b"==t.tag?t.style+="font-style: italic;":t.tag="em"),e.underline&&(t.Style+="text-decoration:underline;"),e.strike_through&&(t.Style+="text-decoration: line-through;")),"dynamic-field"==e.type){let i=d.get(e.attrs,"key");t.text=d.get(this.props.data,[i],t.text)}if("link"==e.type&&(t.tag="a",t.attrs.href=e.href,t.attrs.target=e.target,t.attrs.title=e.title),"mention-agent"==e.type||"mention"==e.type){t.tag="span",t.class="mention";let i=e.attrs.id="";if("*"!=e.attrs.id&&"all"!=e.attrs.id||(t.text="@"+this.$t("all")),i.startsWith("ag")){let e=store.matchAgent(i),n=d.getAgentDisplayName(e,insert.mention.fullname);t.text="@"+n}}if("horizontal_rule"==e.type&&(t.tag="hr"),"emoji"==e.type){let i="";d.size(e.attrs)>0&&(i=e.attrs.code),""==i&&(i=e.Text),""!=i&&(t.tag="Emoji",t.attrs.emojiCode=i)}if("table"==e.type)return null;let i=null;if(d.size(e.content))i=d.map(e.content,(e=>this.renderBlock(e)));else if("text"===e.type){i=d.extractText(t.text).map((e=>{if("link"===e.type){let t=e.text||"";return t.startsWith("//")||t.startsWith("https://")||t.startsWith("http://")||t.startsWith("data:")||(t="//"+t),re("a",{href:t,target:"_blank",onClick:e=>this.props.onLink(e,t)},e.text)}return"phone"===e.type?re("a",{href:"tel:"+e.text},e.text):"email"===e.type?re("a",{href:"mailto:"+e.text},e.text):e.text}))}else i=t.text;switch(t.tag){case"div":return re("div",null,i);case"h1":return re("h1",null,i);case"h2":return re("h2",null,i);case"h3":return re("h3",null,i);case"h4":return re("h4",null,i);case"h5":return re("h5",null,i);case"h6":return re("h6",null,i);case"ol":return re("ol",null,i);case"ul":return re("ul",null,i);case"span":return re("span",null,i);case"em":return re("em",null,i);case"b":return re("b",null,i);case"hr":return re("hr",null);case"a":return re("a",{href:t.attrs.href,target:t.attrs.target,title:t.attrs.title},i);case"Emoji":return re(Pe,{emojiCode:t.attrs.emojiCode})}return null}render(){return this.renderBlock(this.props.block)}}function Ee(e,t,i){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Ie extends Oe{constructor(e){super(e),Ee(this,"state",{errorFields:{},submiting:!1}),Ee(this,"renderFormComponent",((e,t)=>"input"===e.type?this.renderField(e,t):"submit_button"===e.type?this.renderSubmitButton(e,t):this.props.isSubmited?void 0:re("div",{class:"form-component form-component-block"},re(je,{block:e})))),Ee(this,"renderSubmitButton",((e,t)=>{if(!this.props.isSubmited)return re("div",{class:"form-component form-component-submit-button"},re("div",{class:"form-control--valid-input--error"},this.props.errorMessage),re("div",null,re("button",{class:"btn--start-convo",disabled:this.props.submiting},e.label)))})),Ee(this,"renderField",((e,t)=>{let i=this.state.errorFields[e.key];if(this.props.isSubmited){let t=d.find(this.props.formValues,(t=>t.key===e.key))||{};return t=t.value||'""',t=d.parseJSON(t),Array.isArray(t)&&(t=t.join(", ")),re("div",{class:"form-component submitted",key:e.key},re("label",{class:"label"},e.label),re("div",null,t||re("span",{class:"text-muted text-italic"},this.props.t("no_info_input"))))}return re("div",{class:"form-component",key:e.key},re("label",{class:"label"},e.label," ",e.is_required&&re("span",{class:"red"},"*")),"text"===e.input_type&&this.renderFieldTextInput(e,t),"multiple"===e.input_type&&this.renderFieldTextareaInput(e,t),"date"===e.input_type&&this.renderFieldDateInput(e,t),"radio"===e.input_type&&this.renderFieldRadioInput(e,t),"checkbox"===e.input_type&&this.renderFieldCheckboxInput(e,t),"dropdown"===e.input_type&&this.renderFieldDropdownInput(e,t),i&&re("div",{class:"form-control--valid-input--error"},i))})),Ee(this,"renderFieldTextInput",((e,t)=>{let i="form-control";this.state.errorFields[e.key]&&(i="form-control input--error");let n=d.find(this.props.formValues,(t=>t.key===e.key))||{};return n=n.value||'""',n=d.parseJSON(n),re("input",{ref:this[`${e.key}_input`],type:"text",class:i,placeholder:e.placeholder,value:n,onInput:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)}})})),Ee(this,"renderFieldDateInput",((e,t)=>{let i=d.find(this.props.formValues,(t=>t.key===e.key))||{};return i=i.value||'""',i=d.parseJSON(i),re("input",{ref:this[`${e.key}_input`],class:"form-control",type:"date",value:i,onInput:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)}})})),Ee(this,"renderFieldRadioInput",((e,t)=>{let i=d.find(this.props.formValues,(t=>t.key===e.key))||{};return i=i.value||'""',i=d.parseJSON(i),d.map(e.input_options,((t,n)=>{let r=e.key+"_"+n;return re("div",{class:"radio"},re("input",{type:"radio",name:e.key,id:r,checked:t.value===i,onChange:()=>this.toggleRadioField(e.key,t.value)}),re("label",{class:"radio--label",for:r},t.label),re("div",{class:"radio--check"}))}))})),Ee(this,"renderFieldCheckboxInput",((e,t)=>{let i=d.find(this.props.formValues,(t=>t.key===e.key))||{};return i=i.value||"[]",i=d.parseJSON(i),d.map(e.input_options,((t,n)=>{let r=e.key+"_"+n;return re("div",{class:"checkbox"},re("input",{type:"checkbox",name:e.key,id:r,checked:i.includes(t.value),onChange:()=>this.toggleCheckboxField(e.key,t.value)}),re("label",{class:"checkbox--label",for:r},t.label),re("div",{class:"checkbox--check"}))}))})),Ee(this,"renderFieldDropdownInput",((e,t)=>{let i=d.find(this.props.formValues,(t=>t.key===e.key))||{};return i=i.value||'""',i=d.parseJSON(i),re("select",{class:"form-control",ref:this[`${e.key}_input`],onChange:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)}},d.map(e.input_options,(e=>re("option",{value:e.value},e.label))))})),Ee(this,"renderFieldTextareaInput",((e,t)=>{let i=d.find(this.props.formValues,(t=>t.key===e.key))||{};return i=i.value||'""',i=d.parseJSON(i),re("textarea",{onInput:t=>{this.onChangeValue(e.key,t.target.value),this.clearError(e.key)},ref:this[`${e.key}_input`],rows:"3",class:"form-control",placeholder:e.placeholder})})),Ee(this,"onSubmit",(e=>{e.preventDefault(),this.validateForm()&&this.props.onSubmit()})),Ee(this,"validateForm",(()=>{let e=!0,t="",i={},n=d.get(this.props.formSetting,"components")||[];return d.each(n,(n=>{if("input"===n.type&&n.is_required){let r=d.find(this.props.formValues,(e=>e.key===n.key))||{};r=r.value||'""',r=d.parseJSON(r),"string"!=typeof r||r.trim()||(e=!1,i[n.key]=this.props.t("cannot_be_empty"),t||"checkbox"===n.input_type||"radio"===n.input_type||(t=`${n.key}_input`)),Array.isArray(r)&&0===r.length&&(e=!1,i[n.key]=this.props.t("cannot_be_empty"))}})),t&&this[t]&&this[t].current&&this[t].current.focus(),this.setState({errorFields:i}),e})),Ee(this,"onChangeValue",((e,t)=>{let i=this.props.formValues,n=d.find(i,(t=>t.key===e));n?n.value=JSON.stringify(t):i.push({key:e,value:JSON.stringify(t)}),this.props.onChangeFormValues(i)})),Ee(this,"clearError",(e=>{let t=this.state.errorFields;t[e]="",this.setState({errorFields:t})}));let t=d.get(this.props.formSetting,"components")||[];d.each(t,(e=>{"input"===e.type&&"checkbox"!==e.input_type&&"radio"!==e.input_type&&(this[`${e.key}_input`]={current:null})}))}toggleRadioField(e,t){this.clearError(e),this.onChangeValue(e,t)}toggleCheckboxField(e,t){let i=d.find(this.props.formValues,(t=>t.key===e))||{};i=i.value||"[]",i=d.parseJSON(i),i.includes(t)?i=i.filter((e=>e!==t)):i.push(t),this.clearError(e),this.onChangeValue(e,i)}render(){let e=d.get(this.props.formSetting,"components")||[],t="form-wrapper form";return"attachment"===this.props.mode&&(t+=" form-wrapper-attachment"),re("div",{class:t},this.props.isSubmited&&re("div",{class:"form-component"},this.props.t("you_have_submitted_info_successfully")),re("form",{onSubmit:this.onSubmit},d.map(e,this.renderFormComponent)))}}function Le(e,t,i){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Ue extends Oe{constructor(e){super(e),Le(this,"onChangeFormValues",(e=>{this.setState({formValues:e})})),Le(this,"onSubmit",(async()=>{console.log("submittttttt",this.state.formValues),this.setState({errorMessage:""}),this.state.submiting||(this.setState({submiting:!0}),await d.sleep(2e3),this.setState({submiting:!1,isSubmited:!0}))})),this.state={formValues:[],submiting:!1,errorMessage:"",isSubmited:!1}}async componentDidMount(){let e=await this.props.store.checkFormToken(this.props.token);console.log("componentDidMountttt",e)}render(){return re("div",{class:"form-page"},re("div",{class:"form-page-header"},"LoGOOOOOOOOOOOOO"),re(Ie,{store:this.props.store,formSetting:{components:[{type:"text",text:"Đặt lịch khám"},{type:"input",key:"fullname",default_value:"234",link_attribute:"email",placeholder:"Nguyen Van A",label:"Họ và tên",input_type:"text",is_required:!0},{type:"input",key:"phone",validation:"phone",label:"SĐT",input_type:"text",is_required:!0},{type:"input",label:"Chọn ca",input_type:"radio",key:"shift",input_options:[{value:"Buổi sáng",label:"Buổi sáng"},{value:"Buổi chiều",label:"Buổi chiều"}]},{type:"input",label:"Chọn ca 2",input_type:"checkbox",key:"shift_2",input_options:[{value:"Buổi sáng",label:"Buổi sáng"},{value:"Buổi chiều",label:"Buổi chiều"}]},{type:"input",key:"schedule",label:"Chọn ngày",is_required:!0,input_type:"date"},{type:"submit_button",label:"Submit"}]},t:this.props.t,formValues:this.state.formValues,errorMessage:this.state.errorMessage,isSubmited:this.state.isSubmited,submiting:this.state.submiting,onChangeFormValues:this.onChangeFormValues,onSubmit:this.onSubmit}))}}let Me=s.e(278).then(s.bind(s,9278));const $e=s(5180);function qe(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))}var De=document.createElement("link");De.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap",De.rel="stylesheet",document.head.append(De),d.preloadWebfonts(["Inter"],[400,500]),async function(){let e=new $($e.ApiURL,$e.FileURL,$e.RealtimeURL,!0);window.store=e;let t=qe("id")||qe("acc_id")||qe("account_id")||"acqsulrowbxiugvginhw",i=t+"@abcd",n=qe("token");await e.init(t,i);let r=e.matchAccount()||{},s=function(e){let t=e.matchPlugin(),i=d.filter(t,(e=>"chatbox"===e.type));if(0!==d.size(i))return i[0];console.error("no chatbox found.")}(e)||{},o=(await Me).default.default.toString();var a=d.replaceCssVariable(o,s.chatbox);let c=document.createElement("style");document.head.appendChild(c),c.type="text/css",c.id="subiz-style-for-order",d.setCss("form",c,a);let u=e=>{if("debug"===l)return`{{${e}}}`;let t=d.get(Te,l,[]),i=d.find(t,(t=>t.key===e));return d.get(i,"message",e)},l=s.locale||r.locale||"vi-VN";u.i18n=e=>{if(!e)return"";let t=s.locale||r.locale||"vi-VN";return t=t.replace("-","_"),e[l.replace("-","_")]||e[t]},u.locale=()=>l,ze(e,l).then((()=>{!function(e,t,i){var n,r,s,o;B.__&&B.__(e,t),r=(n="function"==typeof i)?null:i&&i.__k||t.__k,s=[],o=[],be(t,e=(!n&&i||t).__k=re(oe,null,[e]),r||K,K,void 0!==t.ownerSVGElement,!n&&i?[i]:r?null:t.firstChild?H.call(t.childNodes):null,s,!n&&i?i:r?r.__e:t.firstChild,n,o),we(s,e,o)}(re(Ue,{store:e,t:u,token:n}),document.getElementById("form"))}))}()})()})();
|