@subiz/widget-v4 4.0.50 → 4.0.51
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/default.jpg +0 -0
- package/assets/less/message.less +101 -10
- package/compiled_src/chatbox/Event.js +6 -0
- package/compiled_src/chatbox/OrderAttachments.js +113 -0
- package/compiled_src/chatbox/ProductAttachments.js +6 -4
- package/compiled_src/store/store.js +150 -0
- package/compiled_src/util/common.js +7 -0
- package/dist/{17cbc0a3e5f.178.js → 17d02a15859.178.js} +0 -0
- package/dist/{17cbc0a3e5f.213.js → 17d02a15859.213.js} +0 -0
- package/dist/{17cbc0a3e5f.362.js → 17d02a15859.362.js} +0 -0
- package/dist/17d02a15859.441.js +1 -0
- package/dist/{17cbc0a3e5f.605.js → 17d02a15859.605.js} +0 -0
- package/dist/{17cbc0a3e5f.619.js → 17d02a15859.619.js} +0 -0
- package/dist/{17cbc0a3e5f.678.js → 17d02a15859.678.js} +0 -0
- package/dist/{17cbc0a3e5f.712.js → 17d02a15859.712.js} +1 -1
- package/dist/{17cbc0a3e5f.782.js → 17d02a15859.782.js} +0 -0
- package/dist/17d02a15859.app.js +1 -0
- package/dist/{17cbc0a3e5f.index.html → 17d02a15859.index.html} +1 -1
- package/dist/{17cbc0a3e5f.library.html → 17d02a15859.library.html} +1 -1
- package/dist/17d02a15859.library.js +1 -0
- package/dist/{17cbc0a3e5f.preview.html → 17d02a15859.preview.html} +1 -1
- package/dist/17d02a15859.preview.js +1 -0
- package/dist/HASH +1 -1
- package/package.json +6 -6
- package/src/chatbox/Event.js +2 -0
- package/src/chatbox/OrderAttachments.js +112 -0
- package/src/chatbox/ProductAttachments.js +11 -5
- package/src/store/store.js +146 -8
- package/src/util/common.js +6 -0
- package/dist/17cbc0a3e5f.84.js +0 -1
- package/dist/17cbc0a3e5f.app.js +0 -1
- package/dist/17cbc0a3e5f.library.js +0 -1
- package/dist/17cbc0a3e5f.preview.js +0 -1
package/src/store/store.js
CHANGED
|
@@ -149,7 +149,7 @@ export default class Store {
|
|
|
149
149
|
overridePlugin(plugins) {
|
|
150
150
|
if (!Array.isArray(plugins)) throw 'plugins must be be an array'
|
|
151
151
|
let pluginM = {}
|
|
152
|
-
sb.map(plugins, function(plugin) {
|
|
152
|
+
sb.map(plugins, function (plugin) {
|
|
153
153
|
pluginM[plugin.id] = plugin
|
|
154
154
|
})
|
|
155
155
|
this.forcePlugins = pluginM
|
|
@@ -930,6 +930,143 @@ export default class Store {
|
|
|
930
930
|
setTimeout(() => this.loopTime(), 60000)
|
|
931
931
|
}
|
|
932
932
|
|
|
933
|
+
getPrice(obj, field, currency) {
|
|
934
|
+
if (!obj) return 0
|
|
935
|
+
if (!currency) return obj[field] || 0
|
|
936
|
+
let defcur = sb.get(this.matchAccount(), 'currency')
|
|
937
|
+
if (currency != defcur) return sb.get(obj, [field + '_locale', currency], 0)
|
|
938
|
+
return obj[field] || 0
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
getOrderTotal(order) {
|
|
942
|
+
let subtotal = 0
|
|
943
|
+
sb.map(order.items, (item) => {
|
|
944
|
+
if (!item.product) return 0
|
|
945
|
+
let price = this.getPrice(item.product, 'price', order.currency) * item.quantity
|
|
946
|
+
|
|
947
|
+
if (item.discount_type) {
|
|
948
|
+
if (item.discount_type == 'percentage') {
|
|
949
|
+
if (item.discount_before_tax && item.discount_percentage > 0) {
|
|
950
|
+
price = price * (1 - item.discount_percentage / 10000)
|
|
951
|
+
}
|
|
952
|
+
} else if (item.discount_type == 'amount') {
|
|
953
|
+
let computed_discount = this.getPrice(item, 'discount', order.currency)
|
|
954
|
+
if (item.discount_before_tax && computed_discount > 0) {
|
|
955
|
+
price = price - computed_discount
|
|
956
|
+
if (price <= 0) price = 0
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
subtotal += price
|
|
961
|
+
})
|
|
962
|
+
|
|
963
|
+
let computed_discount = 0
|
|
964
|
+
// add specific item discount after tax to computed_discount
|
|
965
|
+
sb.map(order.items, (item) => {
|
|
966
|
+
if (!item.discount_type) return
|
|
967
|
+
if (!item.product) return 0
|
|
968
|
+
let price = this.getPrice(item.product, 'price', order.currency) * item.quantity
|
|
969
|
+
|
|
970
|
+
let tax = item.product.tax
|
|
971
|
+
let taxprice = 0
|
|
972
|
+
if (tax && tax.id) taxprice = (price * tax.percentage) / 10000
|
|
973
|
+
|
|
974
|
+
if (item.discount_type == 'percentage' && !item.discount_before_tax && item.discount_percentage > 0) {
|
|
975
|
+
computed_discount += ((price + taxprice) * item.discount_percentage) / 10000
|
|
976
|
+
} else if (item.discount_type == 'amount') {
|
|
977
|
+
let itemdiscount = this.getPrice(item, 'discount', order.currency)
|
|
978
|
+
if (!item.discount_before_tax && itemdiscount > 0) {
|
|
979
|
+
// CAUTION: easy to miss condition
|
|
980
|
+
if (itemdiscount > price + taxprice) itemdiscount = price + taxprice
|
|
981
|
+
computed_discount += itemdiscount
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
})
|
|
985
|
+
|
|
986
|
+
// TAX
|
|
987
|
+
let totaltax = 0
|
|
988
|
+
let taxM = {}
|
|
989
|
+
sb.map(order.items, (item, i) => {
|
|
990
|
+
if (!item.product) return
|
|
991
|
+
let tax = item.product.tax
|
|
992
|
+
if (!tax) return
|
|
993
|
+
if (!tax.id) return
|
|
994
|
+
let price = this.getPrice(item.product, 'price', order.currency) * item.quantity
|
|
995
|
+
|
|
996
|
+
if (item.discount_type) {
|
|
997
|
+
if (item.discount_type == 'percentage') {
|
|
998
|
+
if (item.discount_before_tax && item.discount_percentage > 0) {
|
|
999
|
+
price = price * (1 - item.discount_percentage / 10000)
|
|
1000
|
+
}
|
|
1001
|
+
} else if (item.discount_type == 'amount') {
|
|
1002
|
+
let computed_discount = this.getPrice(item, 'discount', order.currency)
|
|
1003
|
+
if (item.discount_before_tax && computed_discount > 0) {
|
|
1004
|
+
price = price - computed_discount
|
|
1005
|
+
if (price <= 0) price = 0
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
let taxprice = (price * tax.percentage) / 10000
|
|
1010
|
+
|
|
1011
|
+
taxM[i] = {
|
|
1012
|
+
tax: tax,
|
|
1013
|
+
taxprice: taxprice,
|
|
1014
|
+
}
|
|
1015
|
+
})
|
|
1016
|
+
|
|
1017
|
+
// have discount before tax
|
|
1018
|
+
if (order.discount_before_tax) {
|
|
1019
|
+
// decrease tax by discount percentage
|
|
1020
|
+
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
1021
|
+
sb.map(taxM, (t) => {
|
|
1022
|
+
t.taxprice = t.taxprice * (1 - order.discount_percentage / 10000)
|
|
1023
|
+
})
|
|
1024
|
+
computed_discount += (subtotal * order.discount_percentage) / 10000
|
|
1025
|
+
} else if (order.discount_type == 'amount') {
|
|
1026
|
+
let discount = this.getPrice(order, 'discount', order.currency)
|
|
1027
|
+
if (subtotal > 0) {
|
|
1028
|
+
sb.map(taxM, (t) => {
|
|
1029
|
+
// CAUTION: easy to miss
|
|
1030
|
+
if (discount > subtotal) discount = subtotal
|
|
1031
|
+
|
|
1032
|
+
t.taxprice = t.taxprice * (1 - discount / subtotal)
|
|
1033
|
+
})
|
|
1034
|
+
}
|
|
1035
|
+
computed_discount += discount
|
|
1036
|
+
}
|
|
1037
|
+
} else {
|
|
1038
|
+
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
1039
|
+
let taxprice = 0
|
|
1040
|
+
sb.map(taxM, (t) => (taxprice += t.taxprice))
|
|
1041
|
+
computed_discount += ((subtotal + taxprice) * order.discount_percentage) / 10000
|
|
1042
|
+
} else if (order.discount_type == 'amount') {
|
|
1043
|
+
let discount = this.getPrice(order, 'discount', order.currency)
|
|
1044
|
+
computed_discount += discount
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// SHIP
|
|
1049
|
+
let shippingfee = this.getPrice(order.shipping, 'fee', order.currency)
|
|
1050
|
+
if (shippingfee > 0) {
|
|
1051
|
+
if (sb.get(order, 'shipping.tax.id')) {
|
|
1052
|
+
let tax = order.shipping.tax
|
|
1053
|
+
let taxprice = (shippingfee * tax.percentage) / 10000
|
|
1054
|
+
taxM['ship'] = {tax: tax, taxprice: taxprice}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
let taxprice = 0
|
|
1059
|
+
sb.map(taxM, (t) => (taxprice += t.taxprice))
|
|
1060
|
+
let total = subtotal + taxprice - computed_discount + shippingfee
|
|
1061
|
+
|
|
1062
|
+
// add adjustment
|
|
1063
|
+
let adj = this.getPrice(order, 'adjustment', order.currency)
|
|
1064
|
+
total += adj
|
|
1065
|
+
|
|
1066
|
+
if (total < 0) total = 0
|
|
1067
|
+
return {subtotal, computed_discount, taxM, total}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
933
1070
|
replaceFileUrl(src) {
|
|
934
1071
|
if (!src) return ''
|
|
935
1072
|
|
|
@@ -1042,7 +1179,7 @@ function getGaClientId() {
|
|
|
1042
1179
|
if (!hasGA()) return clientId
|
|
1043
1180
|
|
|
1044
1181
|
var allTrackers = window.ga.getAll() || []
|
|
1045
|
-
allTrackers.forEach(function(tracker) {
|
|
1182
|
+
allTrackers.forEach(function (tracker) {
|
|
1046
1183
|
clientId = tracker.get('clientId')
|
|
1047
1184
|
})
|
|
1048
1185
|
|
|
@@ -1059,7 +1196,7 @@ function getGaTrackingIds() {
|
|
|
1059
1196
|
if (!hasGA()) return trackingIds
|
|
1060
1197
|
|
|
1061
1198
|
const allTrackers = window.ga.getAll() || []
|
|
1062
|
-
allTrackers.forEach(function(tracker) {
|
|
1199
|
+
allTrackers.forEach(function (tracker) {
|
|
1063
1200
|
var trackingId = tracker.get('trackingId')
|
|
1064
1201
|
if (trackingId) trackingIds.push(trackingId)
|
|
1065
1202
|
})
|
|
@@ -1077,7 +1214,7 @@ function sendToGA(category, action, label) {
|
|
|
1077
1214
|
if (!hasGA()) return
|
|
1078
1215
|
|
|
1079
1216
|
const allTrackers = window.ga.getAll() || []
|
|
1080
|
-
allTrackers.forEach(function(tracker) {
|
|
1217
|
+
allTrackers.forEach(function (tracker) {
|
|
1081
1218
|
const name = tracker.get('name')
|
|
1082
1219
|
window.ga(name + '.send', 'event', category, action, label)
|
|
1083
1220
|
})
|
|
@@ -1090,7 +1227,7 @@ function sendEventToThirdParty(category, action, label) {
|
|
|
1090
1227
|
}
|
|
1091
1228
|
|
|
1092
1229
|
// from http://detectmobilebrowsers.com/
|
|
1093
|
-
let mobileCheck = (function(a) {
|
|
1230
|
+
let mobileCheck = (function (a) {
|
|
1094
1231
|
return (
|
|
1095
1232
|
/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(
|
|
1096
1233
|
a,
|
|
@@ -1101,6 +1238,7 @@ let mobileCheck = (function(a) {
|
|
|
1101
1238
|
)
|
|
1102
1239
|
})(navigator.userAgent || navigator.vendor || window.opera)
|
|
1103
1240
|
|
|
1104
|
-
let tabletCheck =
|
|
1105
|
-
|
|
1106
|
-
|
|
1241
|
+
let tabletCheck =
|
|
1242
|
+
/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
|
|
1243
|
+
navigator.userAgent,
|
|
1244
|
+
)
|
package/src/util/common.js
CHANGED
|
@@ -1071,6 +1071,12 @@ export function getUrlParameter() {
|
|
|
1071
1071
|
|
|
1072
1072
|
export var sleep = (ms) => new Promise((res) => setTimeout(res, ms))
|
|
1073
1073
|
|
|
1074
|
+
export function formatCurrency(val) {
|
|
1075
|
+
if (!val) return 0
|
|
1076
|
+
val = Math.round(val)
|
|
1077
|
+
return val.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1074
1080
|
function replaceFileUrl(src) {
|
|
1075
1081
|
let fileurl = 'https://vcdn.subiz-cdn.com/file/'
|
|
1076
1082
|
if (!src) return ''
|
package/dist/17cbc0a3e5f.84.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[84],{7084:function(e){e.exports=function(){"use strict";function e(e,t){for(var u=0;u<t.length;u++){var n=t[u];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var u=0,n=new Array(t);u<t;u++)n[u]=e[u];return n}function u(e,u){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,u){if(e){if("string"==typeof e)return t(e,u);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,u):void 0}}(e))||u&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n={exports:{}};function r(){return{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}n.exports={defaults:{baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1},getDefaults:r,changeDefaults:function(e){n.exports.defaults=e}};var i=/[&<>"']/,s=/[&<>"']/g,l=/[<>"']|&(?!#?\w+;)/,a=/[<>"']|&(?!#?\w+;)/g,o={"&":"&","<":"<",">":">",'"':""","'":"'"},D=function(e){return o[e]};var c=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function h(e){return e.replace(c,(function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""}))}var p=/(^|[^\[])\^/g;var f=/[^\w:]/g,g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;var F={},A=/^[^:]+:\/*[^/]*$/,C=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function k(e,t){F[" "+e]||(A.test(e)?F[" "+e]=e+"/":F[" "+e]=E(e,"/",!0));var u=-1===(e=F[" "+e]).indexOf(":");return"//"===t.substring(0,2)?u?t:e.replace(C,"$1")+t:"/"===t.charAt(0)?u?t:e.replace(d,"$1")+t:e+t}function E(e,t,u){var n=e.length;if(0===n)return"";for(var r=0;r<n;){var i=e.charAt(n-r-1);if(i!==t||u){if(i===t||!u)break;r++}else r++}return e.substr(0,n-r)}var x=function(e,t){if(t){if(i.test(e))return e.replace(s,D)}else if(l.test(e))return e.replace(a,D);return e},m=h,b=function(e,t){e=e.source||e,t=t||"";var u={replace:function(t,n){return n=(n=n.source||n).replace(p,"$1"),e=e.replace(t,n),u},getRegex:function(){return new RegExp(e,t)}};return u},B=function(e,t,u){if(e){var n;try{n=decodeURIComponent(h(u)).replace(f,"").toLowerCase()}catch(e){return null}if(0===n.indexOf("javascript:")||0===n.indexOf("vbscript:")||0===n.indexOf("data:"))return null}t&&!g.test(u)&&(u=k(t,u));try{u=encodeURI(u).replace(/%25/g,"%")}catch(e){return null}return u},w={exec:function(){}},v=function(e){for(var t,u,n=1;n<arguments.length;n++)for(u in t=arguments[n])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e},y=function(e,t){var u=e.replace(/\|/g,(function(e,t,u){for(var n=!1,r=t;--r>=0&&"\\"===u[r];)n=!n;return n?"|":" |"})).split(/ \|/),n=0;if(u[0].trim()||u.shift(),u[u.length-1].trim()||u.pop(),u.length>t)u.splice(t);else for(;u.length<t;)u.push("");for(;n<u.length;n++)u[n]=u[n].trim().replace(/\\\|/g,"|");return u},_=E,z=function(e,t){if(-1===e.indexOf(t[1]))return-1;for(var u=e.length,n=0,r=0;r<u;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&--n<0)return r;return-1},$=function(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")},S=function(e,t){if(t<1)return"";for(var u="";t>1;)1&t&&(u+=e),t>>=1,e+=e;return u+e},T=n.exports.defaults,R=_,I=y,Z=x,q=z;function O(e,t,u,n){var r=t.href,i=t.title?Z(t.title):null,s=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){n.state.inLink=!0;var l={type:"link",raw:u,href:r,title:i,text:s,tokens:n.inlineTokens(s,[])};return n.state.inLink=!1,l}return{type:"image",raw:u,href:r,title:i,text:Z(s)}}var L=function(){function e(e){this.options=e||T}var t=e.prototype;return t.space=function(e){var t=this.rules.block.newline.exec(e);if(t)return t[0].length>1?{type:"space",raw:t[0]}:{raw:"\n"}},t.code=function(e){var t=this.rules.block.code.exec(e);if(t){var u=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?u:R(u,"\n")}}},t.fences=function(e){var t=this.rules.block.fences.exec(e);if(t){var u=t[0],n=function(e,t){var u=e.match(/^(\s+)(?:```)/);if(null===u)return t;var n=u[1];return t.split("\n").map((function(e){var t=e.match(/^\s+/);return null===t?e:t[0].length>=n.length?e.slice(n.length):e})).join("\n")}(u,t[3]||"");return{type:"code",raw:u,lang:t[2]?t[2].trim():t[2],text:n}}},t.heading=function(e){var t=this.rules.block.heading.exec(e);if(t){var u=t[2].trim();if(/#$/.test(u)){var n=R(u,"#");this.options.pedantic?u=n.trim():n&&!/ $/.test(n)||(u=n.trim())}var r={type:"heading",raw:t[0],depth:t[1].length,text:u,tokens:[]};return this.lexer.inline(r.text,r.tokens),r}},t.hr=function(e){var t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}},t.blockquote=function(e){var t=this.rules.block.blockquote.exec(e);if(t){var u=t[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:t[0],tokens:this.lexer.blockTokens(u,[]),text:u}}},t.list=function(e){var t=this.rules.block.list.exec(e);if(t){var u,n,r,i,s,l,a,o,D,c,h=t[1].trim(),p=h.length>1,f={type:"list",raw:"",ordered:p,start:p?+h.slice(0,-1):"",loose:!1,items:[]};h=p?"\\d{1,9}\\"+h.slice(-1):"\\"+h,this.options.pedantic&&(h=p?h:"[*+-]");for(var g=new RegExp("^( {0,3}"+h+")((?: [^\\n]*| *)(?:\\n[^\\n]*)*(?:\\n|$))");e&&!this.rules.block.hr.test(e)&&(t=g.exec(e));){D=t[2].split("\n"),this.options.pedantic?(i=2,c=D[0].trimLeft()):(i=t[2].search(/[^ ]/),i=t[1].length+(i>4?1:i),c=D[0].slice(i-t[1].length)),l=!1,u=t[0],!D[0]&&/^ *$/.test(D[1])&&(u=t[1]+D.slice(0,2).join("\n")+"\n",f.loose=!0,D=[]);var F=new RegExp("^ {0,"+Math.min(3,i-1)+"}(?:[*+-]|\\d{1,9}[.)])");for(s=1;s<D.length;s++){if(o=D[s],this.options.pedantic&&(o=o.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),F.test(o)){u=t[1]+D.slice(0,s).join("\n")+"\n";break}if(l){if(!(o.search(/[^ ]/)>=i)&&o.trim()){u=t[1]+D.slice(0,s).join("\n")+"\n";break}c+="\n"+o.slice(i)}else o.trim()||(l=!0),o.search(/[^ ]/)>=i?c+="\n"+o.slice(i):c+="\n"+o}f.loose||(a?f.loose=!0:/\n *\n *$/.test(u)&&(a=!0)),this.options.gfm&&(n=/^\[[ xX]\] /.exec(c))&&(r="[ ] "!==n[0],c=c.replace(/^\[[ xX]\] +/,"")),f.items.push({type:"list_item",raw:u,task:!!n,checked:r,loose:!1,text:c}),f.raw+=u,e=e.slice(u.length)}f.items[f.items.length-1].raw=u.trimRight(),f.items[f.items.length-1].text=c.trimRight(),f.raw=f.raw.trimRight();var A=f.items.length;for(s=0;s<A;s++)this.lexer.state.top=!1,f.items[s].tokens=this.lexer.blockTokens(f.items[s].text,[]),f.items[s].tokens.some((function(e){return"space"===e.type}))&&(f.loose=!0,f.items[s].loose=!0);return f}},t.html=function(e){var t=this.rules.block.html.exec(e);if(t){var u={type:"html",raw:t[0],pre:!this.options.sanitizer&&("pre"===t[1]||"script"===t[1]||"style"===t[1]),text:t[0]};return this.options.sanitize&&(u.type="paragraph",u.text=this.options.sanitizer?this.options.sanitizer(t[0]):Z(t[0]),u.tokens=[],this.lexer.inline(u.text,u.tokens)),u}},t.def=function(e){var t=this.rules.block.def.exec(e);if(t)return t[3]&&(t[3]=t[3].substring(1,t[3].length-1)),{type:"def",tag:t[1].toLowerCase().replace(/\s+/g," "),raw:t[0],href:t[2],title:t[3]}},t.table=function(e){var t=this.rules.block.table.exec(e);if(t){var u={type:"table",header:I(t[1]).map((function(e){return{text:e}})),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]?t[3].replace(/\n$/,"").split("\n"):[]};if(u.header.length===u.align.length){u.raw=t[0];var n,r,i,s,l=u.align.length;for(n=0;n<l;n++)/^ *-+: *$/.test(u.align[n])?u.align[n]="right":/^ *:-+: *$/.test(u.align[n])?u.align[n]="center":/^ *:-+ *$/.test(u.align[n])?u.align[n]="left":u.align[n]=null;for(l=u.rows.length,n=0;n<l;n++)u.rows[n]=I(u.rows[n],u.header.length).map((function(e){return{text:e}}));for(l=u.header.length,r=0;r<l;r++)u.header[r].tokens=[],this.lexer.inlineTokens(u.header[r].text,u.header[r].tokens);for(l=u.rows.length,r=0;r<l;r++)for(s=u.rows[r],i=0;i<s.length;i++)s[i].tokens=[],this.lexer.inlineTokens(s[i].text,s[i].tokens);return u}}},t.lheading=function(e){var t=this.rules.block.lheading.exec(e);if(t){var u={type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:[]};return this.lexer.inline(u.text,u.tokens),u}},t.paragraph=function(e){var t=this.rules.block.paragraph.exec(e);if(t){var u={type:"paragraph",raw:t[0],text:"\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1],tokens:[]};return this.lexer.inline(u.text,u.tokens),u}},t.text=function(e){var t=this.rules.block.text.exec(e);if(t){var u={type:"text",raw:t[0],text:t[0],tokens:[]};return this.lexer.inline(u.text,u.tokens),u}},t.escape=function(e){var t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:Z(t[1])}},t.tag=function(e){var t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):Z(t[0]):t[0]}},t.link=function(e){var t=this.rules.inline.link.exec(e);if(t){var u=t[2].trim();if(!this.options.pedantic&&/^</.test(u)){if(!/>$/.test(u))return;var n=R(u.slice(0,-1),"\\");if((u.length-n.length)%2==0)return}else{var r=q(t[2],"()");if(r>-1){var i=(0===t[0].indexOf("!")?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,i).trim(),t[3]=""}}var s=t[2],l="";if(this.options.pedantic){var a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);a&&(s=a[1],l=a[3])}else l=t[3]?t[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(s=this.options.pedantic&&!/>$/.test(u)?s.slice(1):s.slice(1,-1)),O(t,{href:s?s.replace(this.rules.inline._escapes,"$1"):s,title:l?l.replace(this.rules.inline._escapes,"$1"):l},t[0],this.lexer)}},t.reflink=function(e,t){var u;if((u=this.rules.inline.reflink.exec(e))||(u=this.rules.inline.nolink.exec(e))){var n=(u[2]||u[1]).replace(/\s+/g," ");if(!(n=t[n.toLowerCase()])||!n.href){var r=u[0].charAt(0);return{type:"text",raw:r,text:r}}return O(u,n,u[0],this.lexer)}},t.emStrong=function(e,t,u){void 0===u&&(u="");var n=this.rules.inline.emStrong.lDelim.exec(e);if(n&&(!n[3]||!u.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/))){var r=n[1]||n[2]||"";if(!r||r&&(""===u||this.rules.inline.punctuation.exec(u))){var i,s,l=n[0].length-1,a=l,o=0,D="*"===n[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(D.lastIndex=0,t=t.slice(-1*e.length+l);null!=(n=D.exec(t));)if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6])if(s=i.length,n[3]||n[4])a+=s;else if(!((n[5]||n[6])&&l%3)||(l+s)%3){if(!((a-=s)>0)){if(s=Math.min(s,s+a+o),Math.min(l,s)%2){var c=e.slice(1,l+n.index+s);return{type:"em",raw:e.slice(0,l+n.index+s+1),text:c,tokens:this.lexer.inlineTokens(c,[])}}var h=e.slice(2,l+n.index+s-1);return{type:"strong",raw:e.slice(0,l+n.index+s+1),text:h,tokens:this.lexer.inlineTokens(h,[])}}}else o+=s}}},t.codespan=function(e){var t=this.rules.inline.code.exec(e);if(t){var u=t[2].replace(/\n/g," "),n=/[^ ]/.test(u),r=/^ /.test(u)&&/ $/.test(u);return n&&r&&(u=u.substring(1,u.length-1)),u=Z(u,!0),{type:"codespan",raw:t[0],text:u}}},t.br=function(e){var t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}},t.del=function(e){var t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2],[])}},t.autolink=function(e,t){var u,n,r=this.rules.inline.autolink.exec(e);if(r)return n="@"===r[2]?"mailto:"+(u=Z(this.options.mangle?t(r[1]):r[1])):u=Z(r[1]),{type:"link",raw:r[0],text:u,href:n,tokens:[{type:"text",raw:u,text:u}]}},t.url=function(e,t){var u;if(u=this.rules.inline.url.exec(e)){var n,r;if("@"===u[2])r="mailto:"+(n=Z(this.options.mangle?t(u[0]):u[0]));else{var i;do{i=u[0],u[0]=this.rules.inline._backpedal.exec(u[0])[0]}while(i!==u[0]);n=Z(u[0]),r="www."===u[1]?"http://"+n:n}return{type:"link",raw:u[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}},t.inlineText=function(e,t){var u,n=this.rules.inline.text.exec(e);if(n)return u=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Z(n[0]):n[0]:Z(this.options.smartypants?t(n[0]):n[0]),{type:"text",raw:n[0],text:u}},e}(),j=w,U=b,P=v,Q={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:j,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};Q.def=U(Q.def).replace("label",Q._label).replace("title",Q._title).getRegex(),Q.bullet=/(?:[*+-]|\d{1,9}[.)])/,Q.listItemStart=U(/^( *)(bull) */).replace("bull",Q.bullet).getRegex(),Q.list=U(Q.list).replace(/bull/g,Q.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Q.def.source+")").getRegex(),Q._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Q._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Q.html=U(Q.html,"i").replace("comment",Q._comment).replace("tag",Q._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Q.paragraph=U(Q._paragraph).replace("hr",Q.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Q._tag).getRegex(),Q.blockquote=U(Q.blockquote).replace("paragraph",Q.paragraph).getRegex(),Q.normal=P({},Q),Q.gfm=P({},Q.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),Q.gfm.table=U(Q.gfm.table).replace("hr",Q.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Q._tag).getRegex(),Q.pedantic=P({},Q.normal,{html:U("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Q._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:j,paragraph:U(Q.normal._paragraph).replace("hr",Q.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Q.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var M={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:j,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:j,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/,_punctuation:"!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~"};M.punctuation=U(M.punctuation).replace(/punctuation/g,M._punctuation).getRegex(),M.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,M.escapedEmSt=/\\\*|\\_/g,M._comment=U(Q._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),M.emStrong.lDelim=U(M.emStrong.lDelim).replace(/punct/g,M._punctuation).getRegex(),M.emStrong.rDelimAst=U(M.emStrong.rDelimAst,"g").replace(/punct/g,M._punctuation).getRegex(),M.emStrong.rDelimUnd=U(M.emStrong.rDelimUnd,"g").replace(/punct/g,M._punctuation).getRegex(),M._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,M._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,M._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,M.autolink=U(M.autolink).replace("scheme",M._scheme).replace("email",M._email).getRegex(),M._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,M.tag=U(M.tag).replace("comment",M._comment).replace("attribute",M._attribute).getRegex(),M._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,M._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,M._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,M.link=U(M.link).replace("label",M._label).replace("href",M._href).replace("title",M._title).getRegex(),M.reflink=U(M.reflink).replace("label",M._label).getRegex(),M.reflinkSearch=U(M.reflinkSearch,"g").replace("reflink",M.reflink).replace("nolink",M.nolink).getRegex(),M.normal=P({},M),M.pedantic=P({},M.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:U(/^!?\[(label)\]\((.*?)\)/).replace("label",M._label).getRegex(),reflink:U(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",M._label).getRegex()}),M.gfm=P({},M.normal,{escape:U(M.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),M.gfm.url=U(M.gfm.url,"i").replace("email",M.gfm._extended_email).getRegex(),M.breaks=P({},M.gfm,{br:U(M.br).replace("{2,}","*").getRegex(),text:U(M.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var N={block:Q,inline:M},X=L,G=n.exports.defaults,V=N.block,H=N.inline,J=S;function K(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function W(e){var t,u,n="",r=e.length;for(t=0;t<r;t++)u=e.charCodeAt(t),Math.random()>.5&&(u="x"+u.toString(16)),n+="&#"+u+";";return n}var Y=function(){function t(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||G,this.options.tokenizer=this.options.tokenizer||new X,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};var t={block:V.normal,inline:H.normal};this.options.pedantic?(t.block=V.pedantic,t.inline=H.pedantic):this.options.gfm&&(t.block=V.gfm,this.options.breaks?t.inline=H.breaks:t.inline=H.gfm),this.tokenizer.rules=t}t.lex=function(e,u){return new t(u).lex(e)},t.lexInline=function(e,u){return new t(u).inlineTokens(e)};var u,n,r,i=t.prototype;return i.lex=function(e){var t;for(e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens);t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens},i.blockTokens=function(e,t){var u,n,r,i,s=this;for(void 0===t&&(t=[]),this.options.pedantic&&(e=e.replace(/^ +$/gm,""));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((function(n){return!!(u=n.call({lexer:s},e,t))&&(e=e.substring(u.raw.length),t.push(u),!0)}))))if(u=this.tokenizer.space(e))e=e.substring(u.raw.length),u.type&&t.push(u);else if(u=this.tokenizer.code(e))e=e.substring(u.raw.length),!(n=t[t.length-1])||"paragraph"!==n.type&&"text"!==n.type?t.push(u):(n.raw+="\n"+u.raw,n.text+="\n"+u.text,this.inlineQueue[this.inlineQueue.length-1].src=n.text);else if(u=this.tokenizer.fences(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.heading(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.hr(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.blockquote(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.list(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.html(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.def(e))e=e.substring(u.raw.length),!(n=t[t.length-1])||"paragraph"!==n.type&&"text"!==n.type?this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title}):(n.raw+="\n"+u.raw,n.text+="\n"+u.raw,this.inlineQueue[this.inlineQueue.length-1].src=n.text);else if(u=this.tokenizer.table(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.lheading(e))e=e.substring(u.raw.length),t.push(u);else if(r=e,this.options.extensions&&this.options.extensions.startBlock&&function(){var t=1/0,u=e.slice(1),n=void 0;s.options.extensions.startBlock.forEach((function(e){"number"==typeof(n=e.call({lexer:this},u))&&n>=0&&(t=Math.min(t,n))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}(),this.state.top&&(u=this.tokenizer.paragraph(r)))n=t[t.length-1],i&&"paragraph"===n.type?(n.raw+="\n"+u.raw,n.text+="\n"+u.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(u),i=r.length!==e.length,e=e.substring(u.raw.length);else if(u=this.tokenizer.text(e))e=e.substring(u.raw.length),(n=t[t.length-1])&&"text"===n.type?(n.raw+="\n"+u.raw,n.text+="\n"+u.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=n.text):t.push(u);else if(e){var l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}throw new Error(l)}return this.state.top=!0,t},i.inline=function(e,t){this.inlineQueue.push({src:e,tokens:t})},i.inlineTokens=function(e,t){var u,n,r,i=this;void 0===t&&(t=[]);var s,l,a,o=e;if(this.tokens.links){var D=Object.keys(this.tokens.links);if(D.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(o));)D.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,s.index)+"["+J("a",s[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(o));)o=o.slice(0,s.index)+"["+J("a",s[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.escapedEmSt.exec(o));)o=o.slice(0,s.index)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;e;)if(l||(a=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((function(n){return!!(u=n.call({lexer:i},e,t))&&(e=e.substring(u.raw.length),t.push(u),!0)}))))if(u=this.tokenizer.escape(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.tag(e))e=e.substring(u.raw.length),(n=t[t.length-1])&&"text"===u.type&&"text"===n.type?(n.raw+=u.raw,n.text+=u.text):t.push(u);else if(u=this.tokenizer.link(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(u.raw.length),(n=t[t.length-1])&&"text"===u.type&&"text"===n.type?(n.raw+=u.raw,n.text+=u.text):t.push(u);else if(u=this.tokenizer.emStrong(e,o,a))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.codespan(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.br(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.del(e))e=e.substring(u.raw.length),t.push(u);else if(u=this.tokenizer.autolink(e,W))e=e.substring(u.raw.length),t.push(u);else if(this.state.inLink||!(u=this.tokenizer.url(e,W))){if(r=e,this.options.extensions&&this.options.extensions.startInline&&function(){var t=1/0,u=e.slice(1),n=void 0;i.options.extensions.startInline.forEach((function(e){"number"==typeof(n=e.call({lexer:this},u))&&n>=0&&(t=Math.min(t,n))})),t<1/0&&t>=0&&(r=e.substring(0,t+1))}(),u=this.tokenizer.inlineText(r,K))e=e.substring(u.raw.length),"_"!==u.raw.slice(-1)&&(a=u.raw.slice(-1)),l=!0,(n=t[t.length-1])&&"text"===n.type?(n.raw+=u.raw,n.text+=u.text):t.push(u);else if(e){var c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}throw new Error(c)}}else e=e.substring(u.raw.length),t.push(u);return t},u=t,r=[{key:"rules",get:function(){return{block:V,inline:H}}}],(n=null)&&e(u.prototype,n),r&&e(u,r),t}(),ee=n.exports.defaults,te=B,ue=x,ne=function(){function e(e){this.options=e||ee}var t=e.prototype;return t.code=function(e,t,u){var n=(t||"").match(/\S*/)[0];if(this.options.highlight){var r=this.options.highlight(e,n);null!=r&&r!==e&&(u=!0,e=r)}return e=e.replace(/\n$/,"")+"\n",n?'<pre><code class="'+this.options.langPrefix+ue(n,!0)+'">'+(u?e:ue(e,!0))+"</code></pre>\n":"<pre><code>"+(u?e:ue(e,!0))+"</code></pre>\n"},t.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},t.html=function(e){return e},t.heading=function(e,t,u,n){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+n.slug(u)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"},t.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},t.list=function(e,t,u){var n=t?"ol":"ul";return"<"+n+(t&&1!==u?' start="'+u+'"':"")+">\n"+e+"</"+n+">\n"},t.listitem=function(e){return"<li>"+e+"</li>\n"},t.checkbox=function(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},t.paragraph=function(e){return"<p>"+e+"</p>\n"},t.table=function(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"},t.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},t.tablecell=function(e,t){var u=t.header?"th":"td";return(t.align?"<"+u+' align="'+t.align+'">':"<"+u+">")+e+"</"+u+">\n"},t.strong=function(e){return"<strong>"+e+"</strong>"},t.em=function(e){return"<em>"+e+"</em>"},t.codespan=function(e){return"<code>"+e+"</code>"},t.br=function(){return this.options.xhtml?"<br/>":"<br>"},t.del=function(e){return"<del>"+e+"</del>"},t.link=function(e,t,u){if(null===(e=te(this.options.sanitize,this.options.baseUrl,e)))return u;var n='<a href="'+ue(e)+'"';return t&&(n+=' title="'+t+'"'),n+">"+u+"</a>"},t.image=function(e,t,u){if(null===(e=te(this.options.sanitize,this.options.baseUrl,e)))return u;var n='<img src="'+e+'" alt="'+u+'"';return t&&(n+=' title="'+t+'"'),n+(this.options.xhtml?"/>":">")},t.text=function(e){return e},e}(),re=function(){function e(){}var t=e.prototype;return t.strong=function(e){return e},t.em=function(e){return e},t.codespan=function(e){return e},t.del=function(e){return e},t.html=function(e){return e},t.text=function(e){return e},t.link=function(e,t,u){return""+u},t.image=function(e,t,u){return""+u},t.br=function(){return""},e}(),ie=function(){function e(){this.seen={}}var t=e.prototype;return t.serialize=function(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")},t.getNextSafeSlug=function(e,t){var u=e,n=0;if(this.seen.hasOwnProperty(u)){n=this.seen[e];do{u=e+"-"+ ++n}while(this.seen.hasOwnProperty(u))}return t||(this.seen[e]=n,this.seen[u]=0),u},t.slug=function(e,t){void 0===t&&(t={});var u=this.serialize(e);return this.getNextSafeSlug(u,t.dryrun)},e}(),se=ne,le=re,ae=ie,oe=n.exports.defaults,De=m,ce=function(){function e(e){this.options=e||oe,this.options.renderer=this.options.renderer||new se,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new le,this.slugger=new ae}e.parse=function(t,u){return new e(u).parse(t)},e.parseInline=function(t,u){return new e(u).parseInline(t)};var t=e.prototype;return t.parse=function(e,t){void 0===t&&(t=!0);var u,n,r,i,s,l,a,o,D,c,h,p,f,g,F,A,C,d,k,E="",x=e.length;for(u=0;u<x;u++)if(c=e[u],!(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[c.type])||!1===(k=this.options.extensions.renderers[c.type].call({parser:this},c))&&["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(c.type))switch(c.type){case"space":continue;case"hr":E+=this.renderer.hr();continue;case"heading":E+=this.renderer.heading(this.parseInline(c.tokens),c.depth,De(this.parseInline(c.tokens,this.textRenderer)),this.slugger);continue;case"code":E+=this.renderer.code(c.text,c.lang,c.escaped);continue;case"table":for(o="",a="",i=c.header.length,n=0;n<i;n++)a+=this.renderer.tablecell(this.parseInline(c.header[n].tokens),{header:!0,align:c.align[n]});for(o+=this.renderer.tablerow(a),D="",i=c.rows.length,n=0;n<i;n++){for(a="",s=(l=c.rows[n]).length,r=0;r<s;r++)a+=this.renderer.tablecell(this.parseInline(l[r].tokens),{header:!1,align:c.align[r]});D+=this.renderer.tablerow(a)}E+=this.renderer.table(o,D);continue;case"blockquote":D=this.parse(c.tokens),E+=this.renderer.blockquote(D);continue;case"list":for(h=c.ordered,p=c.start,f=c.loose,i=c.items.length,D="",n=0;n<i;n++)A=(F=c.items[n]).checked,C=F.task,g="",F.task&&(d=this.renderer.checkbox(A),f?F.tokens.length>0&&"paragraph"===F.tokens[0].type?(F.tokens[0].text=d+" "+F.tokens[0].text,F.tokens[0].tokens&&F.tokens[0].tokens.length>0&&"text"===F.tokens[0].tokens[0].type&&(F.tokens[0].tokens[0].text=d+" "+F.tokens[0].tokens[0].text)):F.tokens.unshift({type:"text",text:d}):g+=d),g+=this.parse(F.tokens,f),D+=this.renderer.listitem(g,C,A);E+=this.renderer.list(D,h,p);continue;case"html":E+=this.renderer.html(c.text);continue;case"paragraph":E+=this.renderer.paragraph(this.parseInline(c.tokens));continue;case"text":for(D=c.tokens?this.parseInline(c.tokens):c.text;u+1<x&&"text"===e[u+1].type;)D+="\n"+((c=e[++u]).tokens?this.parseInline(c.tokens):c.text);E+=t?this.renderer.paragraph(D):D;continue;default:var m='Token with "'+c.type+'" type was not found.';if(this.options.silent)return void console.error(m);throw new Error(m)}else E+=k||"";return E},t.parseInline=function(e,t){t=t||this.renderer;var u,n,r,i="",s=e.length;for(u=0;u<s;u++)if(n=e[u],!(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type])||!1===(r=this.options.extensions.renderers[n.type].call({parser:this},n))&&["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type))switch(n.type){case"escape":case"text":i+=t.text(n.text);break;case"html":i+=t.html(n.text);break;case"link":i+=t.link(n.href,n.title,this.parseInline(n.tokens,t));break;case"image":i+=t.image(n.href,n.title,n.text);break;case"strong":i+=t.strong(this.parseInline(n.tokens,t));break;case"em":i+=t.em(this.parseInline(n.tokens,t));break;case"codespan":i+=t.codespan(n.text);break;case"br":i+=t.br();break;case"del":i+=t.del(this.parseInline(n.tokens,t));break;default:var l='Token with "'+n.type+'" type was not found.';if(this.options.silent)return void console.error(l);throw new Error(l)}else i+=r||"";return i},e}(),he=Y,pe=ce,fe=L,ge=ne,Fe=re,Ae=ie,Ce=v,de=$,ke=x,Ee=n.exports.getDefaults,xe=n.exports.changeDefaults,me=n.exports.defaults;function be(e,t,u){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if("function"==typeof t&&(u=t,t=null),t=Ce({},be.defaults,t||{}),de(t),u){var n,r=t.highlight;try{n=he.lex(e,t)}catch(e){return u(e)}var i=function(e){var i;if(!e)try{t.walkTokens&&be.walkTokens(n,t.walkTokens),i=pe.parse(n,t)}catch(t){e=t}return t.highlight=r,e?u(e):u(null,i)};if(!r||r.length<3)return i();if(delete t.highlight,!n.length)return i();var s=0;return be.walkTokens(n,(function(e){"code"===e.type&&(s++,setTimeout((function(){r(e.text,e.lang,(function(t,u){if(t)return i(t);null!=u&&u!==e.text&&(e.text=u,e.escaped=!0),0==--s&&i()}))}),0))})),void(0===s&&i())}try{var l=he.lex(e,t);return t.walkTokens&&be.walkTokens(l,t.walkTokens),pe.parse(l,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+ke(e.message+"",!0)+"</pre>";throw e}}return be.options=be.setOptions=function(e){return Ce(be.defaults,e),xe(be.defaults),be},be.getDefaults=Ee,be.defaults=me,be.use=function(){for(var e=arguments.length,t=new Array(e),u=0;u<e;u++)t[u]=arguments[u];var n,r=Ce.apply(void 0,[{}].concat(t)),i=be.defaults.extensions||{renderers:{},childTokens:{}};t.forEach((function(e){if(e.extensions&&(n=!0,e.extensions.forEach((function(e){if(!e.name)throw new Error("extension name required");if(e.renderer){var t=i.renderers?i.renderers[e.name]:null;i.renderers[e.name]=t?function(){for(var u=arguments.length,n=new Array(u),r=0;r<u;r++)n[r]=arguments[r];var i=e.renderer.apply(this,n);return!1===i&&(i=t.apply(this,n)),i}:e.renderer}if(e.tokenizer){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");i[e.level]?i[e.level].unshift(e.tokenizer):i[e.level]=[e.tokenizer],e.start&&("block"===e.level?i.startBlock?i.startBlock.push(e.start):i.startBlock=[e.start]:"inline"===e.level&&(i.startInline?i.startInline.push(e.start):i.startInline=[e.start]))}e.childTokens&&(i.childTokens[e.name]=e.childTokens)}))),e.renderer&&function(){var t=be.defaults.renderer||new ge,u=function(u){var n=t[u];t[u]=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];var l=e.renderer[u].apply(t,i);return!1===l&&(l=n.apply(t,i)),l}};for(var n in e.renderer)u(n);r.renderer=t}(),e.tokenizer&&function(){var t=be.defaults.tokenizer||new fe,u=function(u){var n=t[u];t[u]=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];var l=e.tokenizer[u].apply(t,i);return!1===l&&(l=n.apply(t,i)),l}};for(var n in e.tokenizer)u(n);r.tokenizer=t}(),e.walkTokens){var t=be.defaults.walkTokens;r.walkTokens=function(u){e.walkTokens.call(this,u),t&&t.call(this,u)}}n&&(r.extensions=i),be.setOptions(r)}))},be.walkTokens=function(e,t){for(var n,r=function(){var e=n.value;switch(t.call(be,e),e.type){case"table":for(var r,i=u(e.header);!(r=i()).done;){var s=r.value;be.walkTokens(s.tokens,t)}for(var l,a=u(e.rows);!(l=a()).done;)for(var o,D=u(l.value);!(o=D()).done;){var c=o.value;be.walkTokens(c.tokens,t)}break;case"list":be.walkTokens(e.items,t);break;default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[e.type]?be.defaults.extensions.childTokens[e.type].forEach((function(u){be.walkTokens(e[u],t)})):e.tokens&&be.walkTokens(e.tokens,t)}},i=u(e);!(n=i()).done;)r()},be.parseInline=function(e,t){if(null==e)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");t=Ce({},be.defaults,t||{}),de(t);try{var u=he.lexInline(e,t);return t.walkTokens&&be.walkTokens(u,t.walkTokens),pe.parseInline(u,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+ke(e.message+"",!0)+"</pre>";throw e}},be.Parser=pe,be.parser=pe.parse,be.Renderer=ge,be.TextRenderer=Fe,be.Lexer=he,be.lexer=he.lex,be.Tokenizer=fe,be.Slugger=Ae,be.parse=be,be}()}}]);
|
package/dist/17cbc0a3e5f.app.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var e,t,i,n,r={7460: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)}function s(e){return(e||"").trim()}function o(e){return e&&"[object Function]"==={}.toString.call(e)}function a(e,t,i){if(!e||0===e.length)return i(t);var n=e.shift();if(!o(n))return a(e,t,i);n(t,(function(n){return!1===n?i(t):a(e,t,i)}))}function c(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%"+e.charCodeAt(0).toString(16)}))}function u(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=c(r);else if(Array.isArray(o)){for(var a=[],u=0;u<o.length;u++)void 0!==o[u]&&(a.push(l(r,o[u],a.length)),a.push(i));s=a.join("&")}else s=c(r)+"="+c(o);s.length>0&&i.push(s)}}return i.join("&")}function l(e,t){return null===t?c(e):[c(e),"=",c(t)].join("")}var h,d=(h={parser:"",beforehooks:[],afterhooks:[],baseurl:"",query:{},meta:{},clone:function(){return Object.assign({},this,{query:Object.assign({},this.query),meta:Object.assign({},this.meta)})},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){h[e]=function(c,l,h){return function(e,r,s){s=s||function(){},o(r)&&(s=r,r=void 0);var c,l=new Promise((function(e){c=function(t){try{s(t.error,t.body,t.code)}catch(e){}e(t)}}));return r&&((e=e.clone()).body=r,e.content_type===n&&(e.body=p.Jsonify(r)),e.content_type===i&&(e.body=u(r))),a(e.beforehooks.slice(),{request:e},(function(i){if(i.error)return c({body:void 0,code:0,error:i.error});!function(e,i){let n=u(e.query);if(n&&(n="?"+n),!p.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((e=>e.text().then((t=>i(void 0,t,e.status))))).catch((e=>i("network_error",e,-1)))}(e,i,n);var r=new p.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){a(e.afterhooks.slice(),{request:e,code:n,body:i,err:t},(function(t){var i=t.body;if("json"==e.parser&&t.body)try{i=p.ParseJson(t.body)}catch(e){t.err=t.err||"invalid json"}var r=t.err;(n<200||n>299)&&(r="not 200"),c({body:i,code:t.code,error:r})}))}))})),l}(r(this,{method:e,baseurl:(d=this.baseurl,f=c,d=s(d),(f=s(f))&&d?f.startsWith("http://")||f.startsWith("https://")||f.startsWith("//")?f:(d.endsWith("/")||(d+="/"),f.startsWith("/")&&(f=f.substring(1)),d+f):d+f)}),l,h);var d,f}})),h.setBaseUrl=function(e){return r(this,{baseurl:e})},h.contentTypeJson=function(){return r(this,{content_type:n})},h.contentTypeForm=function(){return r(this,{content_type:i})},h.setContentType=function(e){return r(this,{content_type:s(e)})},h.setParser=function(e){return r(this,{parser:s(e)})},h.setBody=function(e){return r(this,{body:e})},h.setMeta=function(e,t){var i=this.clone();return i.meta[e]=t,i},h),p={Jsonify:JSON.stringify,ParseJson:JSON.parse};d.env=p,d.waterfall=a,e.exports=d},5530:(e,t,i)=>{var n=i(8368);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}},3538: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}}},3165:(e,t,i)=>{var n=i(2349),r=i(8368),s=i(8874),o=i(5530);e.exports={sleep:n,loop:r,map:s,batch:o}},8368: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()}))}},8874:(e,t,i)=>{var n=i(3538);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.pop(),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)}))}},2349:e=>{e.exports=function(e){return new Promise((function(t){setTimeout(t,e)}))}},8454:(e,t,i)=>{e.exports=i(608)},608:(e,t,i)=>{var n=i(3165);function r(e,t,i,r,a){a=a||s,t=t||{};var d=!1,p="";this.kill=function(){d=!0};var f=function(t){d||a("get",e+"poll?token="+p,void 0,(function(n,s){if(!d){if(u(s))return setTimeout(f,c(t),t+1);if(200!==s)return d=!0,i("poll");(n=o(n)||{}).host&&(e=h(n.host));var a=n.sequential_token;return a?(p=a,r(n.events||[]),f(0)):setTimeout(f,c(t),t+1)}}))},g=n.batch(50,100,(function(r){if(d)return["dead"];if(r.length<=0)return[];var s=[];return n.loop((function(){return new Promise((function(n){var c="?token="+p;t.getAccessToken().then((function(g){t.user_mask?c+="&user-mask="+encodeURIComponent(t.user_mask):g&&(c+="&access-token="+g),a("post",e+"subs"+c,JSON.stringify({events:r}),(function(t,a){if(d)return s=l("dead",r.length),n(!1);if(u(a))return setTimeout(n,3e3,!0);if(200!==a)return d=!0,i("subscribe",t,a),s=l("dead",r.length),n(!1);if(p)return n(!1);var c=(t=o(t)||{}).initial_token;return c?(t.host&&(e=h(t.host)),p=c,f(0),n(!1)):setTimeout(n,3e3,!0)}))}))}))})).then((function(){return s}))}));this.subscribe=g.push.bind(g)}var s=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)};function o(e){try{return JSON.parse(e)}catch(e){}}function a(){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)}}function c(e){if(!e||-1===e)return 0;var t=1e3*Math.pow(1.5,e);return Math.min(1e4,t)}function u(e){return e>=500&&e<600||0===e||-1===e||429===e}function l(e,t){for(var i=[],n=0;n<t;n++)i.push(e);return i}function h(e){return(e=e||"").startsWith("//")?"https:"+e:e}e.exports=function(e,t,i){("string"==typeof e||e instanceof String)&&(e=[e]),(t=t||{}).getAccessToken||(t.getAccessToken=function(){return Promise.resolve("")});var n,s=new a,o={},c=!1;this.stop=function(){c||(c=!0,n.kill())},this.onEvent=function(e){return s.on("event",e)},this.onInterrupted=function(e){return s.on("interrupted",e)},this.subscribe=function(e){if(c)return Promise.resolve({});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 r=e[i];r&&(o[r]||t.push(n.subscribe(r)))}return 0===t.length?Promise.resolve({}):Promise.all(t).then((function(t){for(var i=0;i<t.length;i++)if(t[i])return{error:t[i]};for(var n=0;n<e.length;n++)o[e[n]]=!0;return{}}))};var u=function(){if(!c){for(var a=Object.keys(o),l=0;l<a.length;l++)o[a[l]]=!1;var h=e[Math.floor(Math.random()*e.length)];n=new r(h,t,(function(e,t,i){c||(s.emit("interrupted",e,t,i),setTimeout(u,2e3))}),(function(e){if(!c)for(var t=0;t<e.length;t++)s.emit("event",e[t])}),i);var d=Object.keys(o);for(l=0;l<d.length;l++)n.subscribe(d[l])}};u()}},4636: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"}},4878:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});class n{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}})),s(e,((t,i)=>{if(((n=t)?void 0!==n.length?n.length:Object.keys(n).length:0)<50)return;var n;let r=(o=s(t),a=["index"],"desc",c=[],s(o,(e=>c.push(e))),c.sort(((e,t)=>{if(e[a]===t[a])return 0;var i=e[a]<t[a]?-1:1;return-i})),c);var o,a,c;let u=[];for(var l=50;l<r.length;l++)u.push(r[l].full_id),delete t[r[l].id];this.db.removes("items",u),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 s=this.cache[e]||{},o=(r(s)||{}).index||"z",a={id:t,index:i,value:n,chain:e,full_id:e+":"+t};delete s[a.id],o>a.index+""||(s[a.id]=a,this.cache[e]=s,this.db.put("items",a.full_id,a))}listM(e){if(this.dead)return{};let t=this.cache[e]||{},i={};return s(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 o="",a={};;){if(this.dead)return;let[i,c,u]=await t(e,o,50);if(u)return;if(this.dead)return;if(i.map((t=>{a[t.id]=Object.assign({},t,{chain:e,full_id:e+":"+t.id})})),0===i.length||c===o)break;if(a.length>=200){let t=this.cache[e]||{},i=[];s(t,(t=>{t.chain===e&&i.push(t.full_id)})),this.db.removes("items",i),this.cache[e]={};break}if((r(a)||{}).index<=n){o=this.anchorCache[e]||c;break}o=c}for(var c=0;c<Object.keys(a).length;c++){let e=a[Object.keys(a)[c]];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]=o}}function r(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 s(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}},9489:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n={},r={};n.length=0,n.getItem=function(e){return e in r?r[e]:null},n.setItem=function(e,t){void 0===t?n.removeItem(e):r[e]=""+t,n.length=Object.keys(r).length},n.removeItem=function(e){Object.prototype.hasOwnProperty.call(r,e)&&(delete r[e],n.length=Object.keys(r).length)},n.key=function(e){return Object.keys(r)[e]||null},n.clear=function(){r={},n.length=0};const s=n},1606:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=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}}},6929:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});let n=i(9489).Z,r=window.requestIdleCallback||(e=>e());const s=class{constructor(e,t){if(this.localStorage=n,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,t.push(JSON.parse(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){let t=[];for(var i=0;i<this.localStorage.length;i++){let n=this.localStorage.key(i);n.startsWith(this.schema+"#"+e+"#")&&t.push(n)}for(i=0;i<t.length;i++)this.localStorage.removeItem(t[i]);this.allkeys={}}put(e,t,i){this.allkeys[this.schema+"#"+e+"#"+t]=!0,Object.keys(this.allkeys).length>80&&this.clear(e),r((()=>{try{this.localStorage.setItem(this.schema+"#"+e+"#"+t,void 0===(n=i)?"null":JSON.stringify(n))}catch(t){this.clear(e)}var n}))}}},8733:(e,t,i)=>{"use strict";i.r(t),i.d(t,{parseJSON:()=>r,stringify:()=>o,Date:()=>c,requestAnimationFrame:()=>u,setTimeout:()=>l,setInterval:()=>h,convoOfEv:()=>d,convoToEv:()=>p,setMsgField:()=>f,getMsgField:()=>g,merge:()=>m,cloneDeep:()=>v,randomString:()=>y,filter:()=>b,includes:()=>w,map:()=>k,each:()=>x,usersOfConvo:()=>Z,isConvoSeen:()=>C,agentsOfConvo:()=>z,startsWith:()=>S,size:()=>A,replaceAll:()=>O,trim:()=>j,trimStart:()=>P,throttle:()=>M,find:()=>E,orderBy:()=>U,getIntegrationId:()=>L,isPhone:()=>q,isURL:()=>I,isNumber:()=>R,isEmail:()=>D,last:()=>W,getAgentDisplayName:()=>$,isUserBanned:()=>G,setUserAttr:()=>F,getUserAttr:()=>H,norm:()=>B,noop:()=>N,replaceCssVariablePlugin:()=>Q,replaceCssVariable:()=>J,tokenize:()=>X,setCss:()=>Y,DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL:()=>K,DEFVAL:()=>ee,js2css:()=>te,checkRunConditions:()=>ne,getDayName:()=>se,preloadWebfonts:()=>ae,preloadImg:()=>ce,offsetToMin:()=>ue,diffDay:()=>le,diffYear:()=>he,sameDay:()=>de,shortTime:()=>pe,unixSec:()=>fe,getMs:()=>ge,detectLang:()=>_e,getUrlParameter:()=>me,sleep:()=>ve});var n=i(6877);function r(e){try{return a(e)}catch(e){}}var s=document.createElement("iframe");s.style.display="none",document.documentElement.appendChild(s);var o=s.contentWindow.JSON.stringify,a=s.contentWindow.JSON.parse,c=s.contentWindow.Date,u=s.contentWindow.requestAnimationFrame,l=s.contentWindow.setTimeout,h=s.contentWindow.setInterval;function d(e){if(!e)return"";switch(e.type){case"conversation_state_updated":case"conversation_joined":case"conversation_invited":case"conversation_left":case"conversation_tagged":case"conversation_untagged":case"conversation_typing":case"conversation_rating_requested":case"conversation_rated":return n.get(e,"data.conversation.id");case"message_sent":case"message_updated":case"message_pong":return n.get(e,"data.message.conversation_id");case"ticket_updated":return n.get(e,"data.ticket.conversation_id");default:return""}}function p(e,t){if(!t)return"";switch(t.type){case"conversation_state_updated":case"conversation_joined":case"conversation_invited":case"conversation_left":case"conversation_tagged":case"conversation_untagged":case"conversation_typing":case"conversation_rating_requested":case"conversation_rated":return n.set(t,"data.conversation.id",e);case"message_sent":case"message_updated":case"message_pong":return n.set(t,"data.message.conversation_id",e);case"ticket_updated":return n.set(t,"data.ticket.conversation_id",e);default:return""}}function f(e,t,i){var r=n.get(e,"data.message.fields")||[];(r=b(r,(e=>e.key!==t))).push({key:t,value:o(i)}),n.set(e,"data.message.fields",r)}function g(e,t){var i=n.get(e,"data.message.fields");if(0===A(i))return;let r=i.find((e=>e.key===t));try{return r?a(r.value):void 0}catch(e){}}function _(e){return e&&"object"==typeof e&&!Array.isArray(e)}function m(e,...t){if(!t.length)return e;const i=t.shift();if(_(e)&&_(i))for(const t in i)_(i[t])?(e[t]||Object.assign(e,{[t]:{}}),m(e[t],i[t])):Object.assign(e,{[t]:i[t]});return m(e,...t)}function v(e){if(e!==Object(e))return e;var t=o(e);return void 0!==t?a(t):void 0}function y(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 b(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 w(e,t){if(!e)return!1;var i="string"==typeof e||e instanceof String;return!(!Array.isArray(e)&&!i)&&e.includes(t)}function k(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 x(e,t){return k(e,t)}function Z(e){return e?k(b(e.members,(e=>"user"===e.type)),(e=>e.id)):[]}function C(e,t){if("ended"===e.state)return!0;let i=e.last_message_sent;if(!i)return!0;if(n.get(i,"by.id")===t)return!0;let r=E(e.members,(e=>e.id===t));return!r||ge(i.created)<ge(r.seen_at)}function z(e,t){return e?k(b(e.members,(e=>t?"agent"===e.type||"bot"===e.type:"agent"===e.type)),(e=>e.id)):[]}function S(e,t){return((e||"")+"").startsWith(t)}function A(e){return e?void 0!==e.length?e.length:Object.keys(e).length:0}function O(e,t,i){return(e||"").split(t).join(i)}function j(e,t){return((e||"")+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function P(e,t){for(e=(e||"")+"";e.charAt(0)===t;)e=e.substr(1);return e}function M(e,t,i){var n,r,s,o=null,a=0;i||(i={});var u=function(){a=!1===i.leading?0:(new c).getTime(),o=null,s=e.apply(n,r),o||(n=r=null)};return function(){var h=(new c).getTime();a||!1!==i.leading||(a=h);var d=t-(h-a);return n=this,r=arguments,d<=0||d>t?(o&&(clearTimeout(o),o=null),a=h,s=e.apply(n,r),o||(n=r=null)):o||!1===i.trailing||(o=l(u,d)),s}}function E(e,t){if(e)return e[T(e,t)]}function T(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 U(e,t,i){var n=[];return x(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 L(e){return`${e}.subizv4.subikon`}function q(e){return/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im.test(String(e))}function I(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 R(e){return re.test(String(e))}function D(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 W(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function $(e,t){return n.get(t,"fullname")||n.get(t,"email")||n.get(e,"name")||"Agent"}function G(e){return H(e,"is_ban","boolean")}function F(e,t){if(e&&n.get(t,"key")){e.attributes=e.attributes||[];var i=T(e.attributes,(e=>e.key===t.key));-1!==i?e.attributes[i]=t:e.attributes.push(t)}}function H(e,t,i){if(!e||!e.attributes)return;let n;return x(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.list))})),n}function B(e){return(e=e||"").trim().toLowerCase()}function N(){}function V(e){return("string"==typeof e||e instanceof String)&&(e=e.trim().replace(/;+$/,"")),e}function Q(e,t){var i=[e];let r=t.spacer||10;t=Object.assign({},t,{spacer:r+"px",spacer0:r/2+"px",spacer2:2*r+"px",spacer3:3*r+"px"}),i=X(i,"'@font_family'"),i=X(i,"'@font_size'"),i=X(i,"'@text_color'"),i=X(i,"'@faded_text_color'"),i=X(i,"'@primary_color'"),i=X(i,"'@background'"),i=X(i,"'@spacer'"),i=X(i,"'@spacer0'"),i=X(i,"'@spacer2'"),i=X(i,"'@spacer3'");for(var s=[],o=0;o<i.length;o++){var a=i[o];if("string"!=typeof a){var c=a.type.substr(2,a.type.length-3),u=n.get(t,c)||n.get(ee,c)||"";s.push(u)}else s.push(a)}return s.join("")}function J(e,t){var i=[e];i=X(i,"'@primary_color'"),i=X(i,"@esc-primary-color-esc"),i=X(i,"'@secondary_color'"),i=X(i,"'@background'"),i=X(i,"'@text_color'"),i=X(i,"'@width'"),i=X(i,"'@height'"),i=X(i,"'@desktop_button.width'"),i=X(i,"'@desktop_button.height'"),i=X(i,"'@desktop_button.background'"),i=X(i,"'@desktop_button.border_radius'"),i=X(i,"'@desktop_button.margin_x'"),i=X(i,"'@desktop_button.margin_y'"),i=X(i,"'@mobile_button.width'"),i=X(i,"'@mobile_button.height'"),i=X(i,"'@mobile_button.background'"),i=X(i,"'@mobile_button.border_radius'"),i=X(i,"'@mobile_button.margin_x'"),i=X(i,"'@mobile_button.margin_y'"),i=X(i,"'@widget_position'"),i=X(i,"'@z_index'"),i=X(i,"'@z_index_2'"),i=X(i,"'@z_index_3'"),i=X(i,"'@z_index_4'"),i=X(i,"'@z_index_5'");for(var r=[],s=0;s<i.length;s++){var o=i[s];if("string"!=typeof o)if("@esc-primary-color-esc"!==o.type)if("'@z_index_2'"!==o.type)if("'@z_index_3'"!==o.type)if("'@z_index_4'"!==o.type)if("'@z_index_5'"!==o.type){var a=o.type.substr(2,o.type.length-3);c=V(c=n.get(t,a)||n.get(ee,a)||""),["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(a)&&(c+="px"),"height"!==a||"full"!==n.get(t,"window_mode")?r.push(c):r.push("100%")}else c=n.get(t,"z_index")||n.get(ee,"z_index"),r.push(c+5);else c=n.get(t,"z_index")||n.get(ee,"z_index"),r.push(c+4);else{var c=n.get(t,"z_index")||n.get(ee,"z_index");r.push(c+3)}else{c=n.get(t,"z_index")||n.get(ee,"z_index");r.push(c+2)}else{c=n.get(t,"primary_color")||n.get(ee,"primary_color");r.push(encodeURIComponent(V(c)))}else r.push(o)}return r.join("")}function X(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 Y(e,t,i){i=O(i,"#sbz92","#"+e),t.styleSheet?t.styleSheet.cssText=i:(t.innerHTML="",t.appendChild(document.createTextNode(i)))}const K="https://file-subiz.com/bubble_11.svg",ee={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:K,margin_x:.3,margin_y:.3},mobile_button:{width:.3,height:.3,border_radius:"100%",background_mask_url:K,margin_x:.3,margin_y:.3},widget_position:"fixed",z_index:2e9};function te(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]=j(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]+"";k(i,((e,i)=>{-1!==t.indexOf(i)&&(t=O(t,i,e))})),s+=O(r,"_","-")+":"+t+" !important;","color"===r&&(s+="-webkit-text-fill-color: "+t+" !important;")}}return s}function ie(){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 ne(e,t,i,s){var o=s.matchAccount()||{},a=s.matchSession()||{};if(!function(e,t,i){if(!t)return!0;if(n.get(e,"once_per_user"))return!1;var r=i.matchSession()||{};return!(n.get(e,"once_per_session")&&t.session_id===r.id||n.get(e,"interval_sec")&&n.get(e,"interval_sec")>(c.now()-t.created)/1e3)}(e,i,s))return!1;for(var u=0;u<A(t);u++){var l=t[u];switch(l.key){case"url":let e=b(l.exclude_urls,(e=>B(e)));if(A(e)>0&&E(e,(e=>B(window.location.href).indexOf(B(e))>-1)))return!1;let t=b(l.urls,(e=>B(e)));if(A(t)>0&&!E(t,(e=>B(window.location.href).indexOf(B(e))>-1)))return!1;break;case"browser":if(A(l.browsers)>0){var h=ie();if(!E(l.browsers,(e=>B(e)===B(h))))return!1}break;case"location":if(A(l.exclude_locations)>0&&E(l.exclude_locations,(e=>!(!e.city_name||!e.country_code||e.city_name!==a.city_name||e.country_code!==a.country_code)||!(!e.city_name||e.country_code||e.city_name!==a.city_name)||!(e.city_name||!e.country_code||e.country_code!==a.country_code)||void 0)))return!1;if(A(l.locations)>0&&!E(l.locations,(e=>!(!e.city_name||!e.country_code||e.city_name!==a.city_name||e.country_code!==a.country_code)||!(!e.city_name||e.country_code||e.city_name!==a.city_name)||!(e.city_name||!e.country_code||e.country_code!==a.country_code)||void 0)))return!1;break;case"returning_visitor":if(l.returning_visitor&&s.new_visitor)return!1;if(!l.returning_visitor&&!s.new_visitor)return!1;break;case"user_is_a_contact":let i=n.get(s.matchUser(),"attributes",[]),f=E(i,(e=>"emails"===e.key)),g=E(i,(e=>"phones"===e.key)),_=f||g;if(l.user_is_a_contact&&!_)return!1;if(!l.user_is_a_contact&&_)return!1;break;case"device_type":if(A(l.device_types)>0){let e="desktop";if(s.isMobile()&&(e="mobile"),s.isTablet()&&(e="tablet"),!E(l.device_types,(t=>B(t)===B(e))))return!1}break;case"referer":if(A(l.exclude_referers)>0&&E(l.exclude_referers,(e=>B(document.referrer).indexOf(B(e))>-1)))return!1;if(A(l.urls)>0&&!E(l.referers,(e=>B(document.referrer).indexOf(B(e))>-1)))return!1;break;case"source":if(A(l.sources)>0&&!E(l.sources,(e=>B(e)===B(a.source))))return!1;break;case"user_attribute":let m,v=n.get(s.matchUser(),"attributes",[]),y=n.get(l,"user.operator");x(v,(e=>{e&&e.key===n.get(l,"user.key")&&(m=e.datetime||e.boolean||e.number||e.text||e.list)}));let w=!0;switch(y){case"cons":let e=r(l.value)||[];if(0===A(e))return!1;w=!!E(e,(e=>B(m).indexOf(B(e))>-1));break;case"notEmpty":w=!!m;break;case"empty":w=!m;break;case"true":w=!0===m||"true"===m;break;case"false":w=!m||!1===m||"false"===m}if(!w)return!1;break;case"timming":if("in"===l.business_hour&&!o.is_in_business_hour)return!1;if("notIn"===l.business_hour&&o.is_in_business_hour)return!1;if(A(l.days_of_week)>0&&!E(l.days_of_week,(e=>B(se((new c).getDay()))===B(e))))return!1;if(A(l.minute_of_days)>0&&A(l.minute_of_days)%2==0){var d=new c,p=d.getMinutes()+60*d.getHours();let e=!1;for(u=0;u<l.minute_of_days.length;u+=2)if(l.minute_of_days[u]<=p&&p<=l.minute_of_days[u+1]){e=!0;break}if(!e)return!1}break;case"offline":if(!o.is_online!=!!l.offline)return!1}}return!0}function se(e){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]}let oe={};function ae(e){for(var t=0;t<e.length;t++){let n=e[t];if(n&&!oe[n]){oe[n]=!0;for(var i=0;i<2;i++){let e=[400,500][i],t=document.createElement("div");t.innerHTML="@!-/#Chào mỪng1",t.style.position="absolute",t.style.display="block",t.style.fontSize="1px",t.style.height="0px",t.style.width="0px",t.style.fontWeight=e,t.setAttribute("subiz-preload",n+":"+e),document.body.appendChild(t),t.style.fontFamily=n,l((()=>t.remove()),3e3)}}}}function ce(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?S(e,"/")||S(e,"data:")?e:(S(e,"http://")||S(e,"https://")||S(e,"//")||(e=j(t)+"/"+P(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 ue(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 le(e,t,i){var n=-(new c).getTimezoneOffset();i&&(n=ue(i));var r=new c(e).getTime(),s=new c(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 he(e,t,i){var n=-(new c).getTimezoneOffset(),r=-(new c).getTimezoneOffset();i&&(r=ue(i));var s=new c(e).getTime()+60*(r-n)*1e3,o=new c(t).getTime()+60*(r-n)*1e3;return Math.abs(new c(s).getYear()-new c(o).getYear())}function de(e,t,i){return 0===le(e,t,i)}function pe(e,t,i){var r=-(new c).getTimezoneOffset(),s=r;t&&(s=ue(t));var o=new c(ge(e));let a=new c(o);a.setMinutes(o.getMinutes()+s-r),i||(i=new c);let u=a.getHours(),l=a.getMinutes(),h=n.get(navigator,"languages.0","en-US"),d=a.toLocaleDateString(h,{weekday:"long"}),p=a.getFullYear(),f=a.getMonth()+1,g=a.toLocaleDateString(h,{month:"long"}),_=a.getDate();return u<10&&(u="0"+u),l<10&&(l="0"+l),de(o,i,t)?u+":"+l:le(o,i,t)<=5?d+", "+u+":"+l:0===he(o,i,t)?g+" "+_+", "+u+":"+l:p+"/"+f+"/"+_+", "+u+":"+l}function fe(e){return Math.floor(ge(e)/1e3)}function ge(e){return e?"number"!=typeof e&&(e=new c(e).getTime()):e=0,e>1e18?Math.floor(e/1e6):e>1e15?Math.floor(e/1e3):e>1e12?e:1e3*e}function _e(){let e=me(),t=document.getElementsByTagName("html")[0].getAttribute("xml:lang")||document.getElementsByTagName("html")[0].getAttribute("lang"),i=navigator.language;return e||t||i}function me(){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var e=new RegExp("[\\?&]"+name+"=([^&#]*)").exec(location.search);return null===e?"":decodeURIComponent(e[1].replace(/\+/g," "))}var ve=e=>new Promise((t=>l(t,e)))},2302:(e,t,i)=>{"use strict";i.d(t,{Z:()=>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()}))}))}}},819:(e,t,i)=>{"use strict";i.d(t,{Z:()=>Z});var n={};i.r(n),i.d(n,{extract:()=>d,extractEmails:()=>l,extractEmojis:()=>c,extractLinks:()=>u,extractPhones:()=>h,extractText:()=>f,pipeExtracts:()=>p});var r={};i.r(r),i.d(r,{trackAreaClicked:()=>v,trackExitIntent:()=>_,trackInactivity:()=>y,trackScrollingPercentage:()=>m,trackTimeOnPage:()=>w});var s=i(8733),o=i(8733);let a=["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"];function c(e){for(var t=[],i=0;i<e.length;i++)for(var n=0;n<a.length;n++)if(e.indexOf(a[n],i)===i){t.push({index:i,length:a[n].length}),i+=a[n].length-1;break}return t}function u(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 l(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 h(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 d(e,t,i){if(!e)return[];var n=[],r=0,s=t(e);if(0===o.size(s))return[{type:"text",text:e}];o.each(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 a=o.last(s);return n.push({type:"text",text:e.substr(a.index+a.length,e.length-a.index+a.length)}),o.filter(n,(e=>""!==e.text))}function p(e,t){var i=[];if(0===o.size(t))return[{type:"text",text:e}];var n=t.shift(),r=d(e,n,n.type);return o.each(r,(e=>{if("text"!==e.type)return i.push(e);i=i.concat(p(e.text,t.slice()))})),i}function f(e){var t=u;t.type="link";var i=l;i.type="email";var n=h;n.type="phone";var r=c;return r.type="emoji",p(e,[i,t,n,r])}a=o.map(a,(e=>":"+e+":"));var g=i(8733);function _(e){let t=i=>{i.clientY>10||(e&&e(),document.removeEventListener("mouseout",t))};document.addEventListener("mouseout",t)}function m(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/s>=e&&(t&&t(),window.removeEventListener("scroll",i,!1))};window.addEventListener("scroll",i,!1)}function v(e,t){e&&(e=e||"",g.map(e.split("\n"),(e=>{if(!(e=g.trim(e)))return;let i=document.querySelectorAll(e);g.map(i,(e=>{e&&e.addEventListener("click",t,!1)}))})))}function y(e,t){let i=["scroll","keyup","keydown","mousemove","mousewheel","mouseenter","mouseover","mousedown","touchstart","touchmove","touchenter"],n=0,r=()=>{n=0},s=setInterval((()=>{if(n++,!(n<e)){t&&t();for(let e of i)document.removeEventListener(e,r,!1);clearInterval(s)}}),1e3);for(let e of i)document.addEventListener(e,r,!1)}let b=0;function w(e,t){if(e<1)return setTimeout((function(){t(e)}),100);let i=setInterval((()=>{b<e||(t&&t(b),clearInterval(i))}),1e3)}setInterval((()=>b++),1e3);var k={};(k=Object.assign(k,s)).Gate=i(2302).Z;var x=i(6877);k.get=x.get,k.set=x.set,k.Pubsub=i(2851).Z,k=Object.assign(k,n);const Z=k=Object.assign(k,r)},6877:(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))}},2851:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var{filter:n,map:r}=i(8733);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})}}},9554: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}()},6400:(e,t,i)=>{"use strict";i.d(t,{sY:()=>L,h:()=>f,HY:()=>m,Vf:()=>_,wA:()=>v});var n,r,s,o,a,c,u={},l=[],h=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function d(e,t){for(var i in t)e[i]=t[i];return e}function p(e){var t=e.parentNode;t&&t.removeChild(e)}function f(e,t,i){var r,s,o,a={};for(o in t)"key"==o?r=t[o]:"ref"==o?s=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===a[o]&&(a[o]=e.defaultProps[o]);return g(e,a,r,s,null)}function g(e,t,i,n,o){var a={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++s:o};return null==o&&null!=r.vnode&&r.vnode(a),a}function _(){return{current:null}}function m(e){return e.children}function v(e,t){this.props=e,this.context=t}function y(e,t){if(null==t)return e.__?y(e.__,e.__.__k.indexOf(e)+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?y(e):null}function b(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 b(e)}}function w(e){(!e.__d&&(e.__d=!0)&&o.push(e)&&!k.__r++||c!==r.debounceRendering)&&((c=r.debounceRendering)||a)(k)}function k(){for(var e;k.__r=o.length;)e=o.sort((function(e,t){return e.__v.__b-t.__v.__b})),o=[],e.some((function(e){var t,i,n,r,s,o;e.__d&&(s=(r=(t=e).__v).__e,(o=t.__P)&&(i=[],(n=d({},r)).__v=r.__v+1,j(o,r,n,t.__n,void 0!==o.ownerSVGElement,null!=r.__h?[s]:null,i,null==s?y(r):s,r.__h),P(i,r),r.__e!=s&&b(r)))}))}function x(e,t,i,n,r,s,o,a,c,h){var d,p,f,_,v,b,w,k=n&&n.__k||l,x=k.length;for(i.__k=[],d=0;d<t.length;d++)if(null!=(_=i.__k[d]=null==(_=t[d])||"boolean"==typeof _?null:"string"==typeof _||"number"==typeof _||"bigint"==typeof _?g(null,_,null,null,_):Array.isArray(_)?g(m,{children:_},null,null,null):_.__b>0?g(_.type,_.props,_.key,null,_.__v):_)){if(_.__=i,_.__b=i.__b+1,null===(f=k[d])||f&&_.key==f.key&&_.type===f.type)k[d]=void 0;else for(p=0;p<x;p++){if((f=k[p])&&_.key==f.key&&_.type===f.type){k[p]=void 0;break}f=null}j(e,_,f=f||u,r,s,o,a,c,h),v=_.__e,(p=_.ref)&&f.ref!=p&&(w||(w=[]),f.ref&&w.push(f.ref,null,_),w.push(p,_.__c||v,_)),null!=v?(null==b&&(b=v),"function"==typeof _.type&&_.__k===f.__k?_.__d=c=Z(_,c,e):c=C(e,_,f,k,v,c),"function"==typeof i.type&&(i.__d=c)):c&&f.__e==c&&c.parentNode!=e&&(c=y(f))}for(i.__e=b,d=x;d--;)null!=k[d]&&("function"==typeof i.type&&null!=k[d].__e&&k[d].__e==i.__d&&(i.__d=y(n,d+1)),T(k[d],k[d]));if(w)for(d=0;d<w.length;d++)E(w[d],w[++d],w[++d])}function Z(e,t,i){for(var n,r=e.__k,s=0;r&&s<r.length;s++)(n=r[s])&&(n.__=e,t="function"==typeof n.type?Z(n,t,i):C(i,n,n,r,n.__e,t));return t}function C(e,t,i,n,r,s){var o,a,c;if(void 0!==t.__d)o=t.__d,t.__d=void 0;else if(null==i||r!=s||null==r.parentNode)e:if(null==s||s.parentNode!==e)e.appendChild(r),o=null;else{for(a=s,c=0;(a=a.nextSibling)&&c<n.length;c+=2)if(a==r)break e;e.insertBefore(r,s),o=s}return void 0!==o?o:r.nextSibling}function z(e,t,i){"-"===t[0]?e.setProperty(t,i):e[t]=null==i?"":"number"!=typeof i||h.test(t)?i:i+"px"}function S(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||z(e.style,t,"");if(i)for(t in i)n&&i[t]===n[t]||z(e.style,t,i[t])}else if("o"===t[0]&&"n"===t[1])s=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=i,i?n||e.addEventListener(t,s?O:A,s):e.removeEventListener(t,s?O:A,s);else if("dangerouslySetInnerHTML"!==t){if(r)t=t.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null!=i&&(!1!==i||"a"===t[0]&&"r"===t[1])?e.setAttribute(t,i):e.removeAttribute(t))}}function A(e){this.l[e.type+!1](r.event?r.event(e):e)}function O(e){this.l[e.type+!0](r.event?r.event(e):e)}function j(e,t,i,n,s,o,a,c,u){var l,h,p,f,g,_,y,b,w,k,Z,C=t.type;if(void 0!==t.constructor)return null;null!=i.__h&&(u=i.__h,c=t.__e=i.__e,t.__h=null,o=[c]),(l=r.__b)&&l(t);try{e:if("function"==typeof C){if(b=t.props,w=(l=C.contextType)&&n[l.__c],k=l?w?w.props.value:l.__:n,i.__c?y=(h=t.__c=i.__c).__=h.__E:("prototype"in C&&C.prototype.render?t.__c=h=new C(b,k):(t.__c=h=new v(b,k),h.constructor=C,h.render=U),w&&w.sub(h),h.props=b,h.state||(h.state={}),h.context=k,h.__n=n,p=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=C.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=d({},h.__s)),d(h.__s,C.getDerivedStateFromProps(b,h.__s))),f=h.props,g=h.state,p)null==C.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==C.getDerivedStateFromProps&&b!==f&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(b,k),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(b,h.__s,k)||t.__v===i.__v){h.props=b,h.state=h.__s,t.__v!==i.__v&&(h.__d=!1),h.__v=t,t.__e=i.__e,t.__k=i.__k,t.__k.forEach((function(e){e&&(e.__=t)})),h.__h.length&&a.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(b,h.__s,k),null!=h.componentDidUpdate&&h.__h.push((function(){h.componentDidUpdate(f,g,_)}))}h.context=k,h.props=b,h.state=h.__s,(l=r.__r)&&l(t),h.__d=!1,h.__v=t,h.__P=e,l=h.render(h.props,h.state,h.context),h.state=h.__s,null!=h.getChildContext&&(n=d(d({},n),h.getChildContext())),p||null==h.getSnapshotBeforeUpdate||(_=h.getSnapshotBeforeUpdate(f,g)),Z=null!=l&&l.type===m&&null==l.key?l.props.children:l,x(e,Array.isArray(Z)?Z:[Z],t,i,n,s,o,a,c,u),h.base=t.__e,t.__h=null,h.__h.length&&a.push(h),y&&(h.__E=h.__=null),h.__e=!1}else null==o&&t.__v===i.__v?(t.__k=i.__k,t.__e=i.__e):t.__e=M(i.__e,t,i,n,s,o,a,u);(l=r.diffed)&&l(t)}catch(e){t.__v=null,(u||null!=o)&&(t.__e=c,t.__h=!!u,o[o.indexOf(c)]=null),r.__e(e,t,i)}}function P(e,t){r.__c&&r.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){r.__e(e,t.__v)}}))}function M(e,t,i,r,s,o,a,c){var l,h,d,f=i.props,g=t.props,_=t.type,m=0;if("svg"===_&&(s=!0),null!=o)for(;m<o.length;m++)if((l=o[m])&&(l===e||(_?l.localName==_:3==l.nodeType))){e=l,o[m]=null;break}if(null==e){if(null===_)return document.createTextNode(g);e=s?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,g.is&&g),o=null,c=!1}if(null===_)f===g||c&&e.data===g||(e.data=g);else{if(o=o&&n.call(e.childNodes),h=(f=i.props||u).dangerouslySetInnerHTML,d=g.dangerouslySetInnerHTML,!c){if(null!=o)for(f={},m=0;m<e.attributes.length;m++)f[e.attributes[m].name]=e.attributes[m].value;(d||h)&&(d&&(h&&d.__html==h.__html||d.__html===e.innerHTML)||(e.innerHTML=d&&d.__html||""))}if(function(e,t,i,n,r){var s;for(s in i)"children"===s||"key"===s||s in t||S(e,s,null,i[s],n);for(s in t)r&&"function"!=typeof t[s]||"children"===s||"key"===s||"value"===s||"checked"===s||i[s]===t[s]||S(e,s,t[s],i[s],n)}(e,g,f,s,c),d)t.__k=[];else if(m=t.props.children,x(e,Array.isArray(m)?m:[m],t,i,r,s&&"foreignObject"!==_,o,a,o?o[0]:i.__k&&y(i,0),c),null!=o)for(m=o.length;m--;)null!=o[m]&&p(o[m]);c||("value"in g&&void 0!==(m=g.value)&&(m!==e.value||"progress"===_&&!m)&&S(e,"value",m,f.value,!1),"checked"in g&&void 0!==(m=g.checked)&&m!==e.checked&&S(e,"checked",m,f.checked,!1))}return e}function E(e,t,i){try{"function"==typeof e?e(t):e.current=t}catch(e){r.__e(e,i)}}function T(e,t,i){var n,s;if(r.unmount&&r.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||E(n,null,t)),null!=(n=e.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(e){r.__e(e,t)}n.base=n.__P=null}if(n=e.__k)for(s=0;s<n.length;s++)n[s]&&T(n[s],t,"function"!=typeof e.type);i||null==e.__e||p(e.__e),e.__e=e.__d=void 0}function U(e,t,i){return this.constructor(e,i)}function L(e,t,i){var s,o,a;r.__&&r.__(e,t),o=(s="function"==typeof i)?null:i&&i.__k||t.__k,a=[],j(t,e=(!s&&i||t).__k=f(m,null,[e]),o||u,u,void 0!==t.ownerSVGElement,!s&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,a,!s&&i?i:o?o.__e:t.firstChild,s),P(a,e)}n=l.slice,r={__e:function(e,t){for(var i,n,r;t=t.__;)if((i=t.__c)&&!i.__)try{if((n=i.constructor)&&null!=n.getDerivedStateFromError&&(i.setState(n.getDerivedStateFromError(e)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e),r=i.__d),r)return i.__E=i}catch(t){e=t}throw e}},s=0,v.prototype.setState=function(e,t){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=d({},this.state),"function"==typeof e&&(e=e(d({},i),this.props)),e&&d(i,e),null!=e&&this.__v&&(t&&this.__h.push(t),w(this))},v.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),w(this))},v.prototype.render=m,o=[],a="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,k.__r=0}},s={};function o(e){var t=s[e];if(void 0!==t)return t.exports;var i=s[e]={id:e,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.exports}o.m=r,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(i,n){if(1&n&&(i=this(i)),8&n)return i;if("object"==typeof i&&i){if(4&n&&i.__esModule)return i;if(16&n&&"function"==typeof i.then)return i}var r=Object.create(null);o.r(r);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&i;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>s[e]=()=>i[e]));return s.default=()=>i,o.d(r,s),r},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,i)=>(o.f[i](e,t),t)),[])),o.u=e=>"17cbc0a3e5f."+e+".js",o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i={},n="@subiz/widget-v4:",o.l=(e,t,r,s)=>{if(i[e])i[e].push(t);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")==e||h.getAttribute("data-webpack")==n+r){a=h;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",n+r),a.src=e),i[e]=[t];var d=(t,n)=>{a.onerror=a.onload=null,clearTimeout(p);var r=i[e];if(delete i[e],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)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="https://vcdn.subiz-cdn.com/widget-v4/public/",(()=>{var e={143:0};o.f.j=(t,i)=>{var n=o.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 s=o.p+o.u(t),a=new Error;o.l(s,(i=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var r=i&&("load"===i.type?"missing":i.type),s=i&&i.target&&i.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+s+")",a.name="ChunkLoadError",a.type=r,a.request=s,n[1](a)}}),"chunk-"+t,t)}};var t=(t,i)=>{var n,r,[s,a,c]=i,u=0;if(s.some((t=>0!==e[t]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(t&&t(i);u<s.length;u++)r=s[u],o.o(e,r)&&e[r]&&e[r][0](),e[s[u]]=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=o(819),t=o(1606).Z,i=o(4878).Z,n=o(9489).Z;const r={kv:t,lsdb:o(6929).Z,chain:i,inmem_localstorage:n};function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const a=o(7460);a.env.XMLHttpRequest=window.XMLHttpRequest;const c=e=>e.answer;function u(t,i){let n=t.request;"text/plain"===n.content_type&&void 0!==n.body&&(n.body=e.Z.stringify(n.body)),i(!0)}function l(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const h=o(7460);function d(t,i){let n=t.request;"text/plain"===n.content_type&&void 0!==n.body&&(n.body=e.Z.stringify(n.body)),i(!0)}h.env.XMLHttpRequest=window.XMLHttpRequest;const p=Promise.resolve({code:200});function f(e,t,i,n){let r=e+".subizv4.subikon";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",integration:{account_id:e,connector_id:"subikon",name:"Subiz Widget",connector_type:"subiz",state:"activated",id:r},actived:1610453070259,last_event:{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}]}}},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:r,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/"}}function g(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var _=o(3165),m=o(8454),v=o(9554);v.defaults.path="/",v.expiresMultiplier=86400,v.defaults.expires=3650;const y=e.Z.Date.now();class b{constructor(t,i,n,o,_,m){g(this,"inmem",!1),g(this,"cookie",v),g(this,"new_visitor",!0),g(this,"matchUser",(()=>(this._touchAcc(),this.kv.match("user")))),g(this,"matchSession",(()=>this.kv.match("session")||{})),g(this,"matchAccount",(()=>this.cache.match("account"))),g(this,"matchUnread",(()=>{let t=this.matchUser(),i=this.matchConvo("*"),n=0;return e.Z.map(i,(i=>{e.Z.isConvoSeen(i,t.id)||n++})),n})),g(this,"matchPlugin",(()=>e.Z.size(this.forcePlugins)>0?e.Z.cloneDeep(this.forcePlugins):e.Z.cloneDeep(this.cache.match("plugin"))||{})),g(this,"device",{}),g(this,"browserVisibility","visible"),g(this,"matchAgent",(e=>{let t=this.cache.match("agent")||{};return"*"===e?t:t[e]})),g(this,"matchConvo",(t=>{if(t)return"*"===t?(this._touchAcc(),e.Z.filter(this.cache.all(),((e,t)=>t.startsWith("convo_")))):(this.isInsync(t)||this.fetchConvo(t),this.cache.match("convo_"+t))})),g(this,"fetchConvo",(async e=>{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()})),g(this,"listEvents",(e=>{if(e&&"*"!==e&&"string"==typeof e)return this.isInsync("events"+e)||setTimeout((async()=>(await this.readyGate.entry(),await this.reconnectGate.entry(void 0,!0),this.isInsync("events"+e)||(this.markSync("events"+e),await this.chain.reload(e,((e,t,i)=>this.listmessageapi(e,t,i))),this.pubsub.publish("account")),this.reconnectGate.open())),10),this.chain.listM(e)})),g(this,"fetchMoreEvents",(async e=>{let{error:t}=await this.chain.fetchMore(e,50,((e,t,i)=>this.listmessageapi(e,t,i)));return this.pubsub.publish("account"),{error:t}})),g(this,"matchBot",(()=>this.cache.match("bot")||{})),g(this,"readyGate",new e.Z.Gate),g(this,"convoGate",new e.Z.Gate(!0)),g(this,"reconnectGate",new e.Z.Gate(!0)),g(this,"matchLastview",(()=>this.kv.match("lastview")||{})),g(this,"matchIsOpen",(()=>!!this.kv.match("isopen"))),g(this,"matchHasManuallyClosed",(()=>!!this.kv.match("hasManuallyClosed"))),g(this,"matchClosePreviewAt",(()=>this.kv.match("close_preview_at")||0)),g(this,"sendPresence",e.Z.throttle((async()=>{if(await this.readyGate.entry(),e.Z.get(this.kv.match("user"),"id")&&!e.Z.isUserBanned(this.kv.match("user")))return this.api.sendPresence(this.device,"visible"===this.browserVisibility&&document.hasFocus())}),1e3)),g(this,"now",(()=>e.Z.Date.now()+this.timeDiff)),g(this,"seenQueue",[]),g(this,"_typing",e.Z.throttle((e=>this.api.sendTyping(e)),3e3)),g(this,"onConvoEvent",((e,t)=>this.pubsub.on2(e,"events",t))),g(this,"seenConvo",(e=>{e&&"create"!==e&&this.seenQueue.push(e)})),g(this,"onUpdate",((e,t)=>this.pubsub.on2(e,"account",t))),g(this,"onResetCSS",((e,t)=>this.pubsub.on2(e,"resetCSS",t))),g(this,"onHighlight",((e,t)=>this.pubsub.on2(e,"highlight",t))),g(this,"setHasManuallyClosed",(()=>this.kv.put("hasManuallyClosed",!0))),g(this,"setIsOpen",(e=>{let t=this.kv.match("isopen");this.kv.put("isopen",e),!t&&e&&Z("SUBIZ Chat","Opened","Subiz Windows")})),g(this,"closePreview",(()=>this.kv.put("close_preview_at",(new e.Z.Date).getTime()))),g(this,"setLastview",((e,t)=>this.kv.put("lastview",{view:e,opts:t}))),g(this,"timeDiff",0),this.agent_token=m,this.g_sync={},this.forceDevice=null,this.forcePlugins={},this.forceAcc={},this.forceChatbox={},this.RealtimeURL=n,this.fake=_,this.FileURL=i,this.fake?this.api=new class{constructor(t,i){l(this,"listConversations",(e=>{let t=f(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid);return Promise.resolve({body:{anchor:"",conversations:[t]},code:200})})),l(this,"listMessages",((e,t,i)=>{let n=function(e,t,i,n){let r=e+".subizv4.subikon";return[{id:"evqyiyjmxrjsylftvnrghrfmq",account_id:e,created:1616213202264,type:"conversation_invited",by:{id:i,type:"user"},data:{conversation:{id:t,account_id:e,members:[{type:"user",id:i,last_page_view_url:"https://subiz.com.vn/",membership:"observer",invited_by:{id:i,type:"user"}}],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:[{type:"agent",id:n,conversation_id:t,membership:"observer",invited_by:{id:i,type:"user"}}],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:[{type:"user",id:i,last_page_view_url:"https://subiz.com.vn/",membership:"active",invited_by:{id:i,type:"user"}}]}}},{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",fields:[{key:"idempotency",value:'"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:[{type:"agent",id:n,conversation_id:t,membership:"active",invited_by:{id:i,type:"user"}}]}}},{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})})),l(this,"ajax",h),l(this,"start",(e=>p)),l(this,"sendConvoEvent",((e,t)=>p)),l(this,"createPostback",((e,t)=>p)),l(this,"markAsReceived",((e,t)=>p)),l(this,"markAsSeen",((e,t)=>p)),l(this,"getConversation",(e=>Promise.resolve({body:f(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid),code:200}))),l(this,"getLocaleContent",(e=>this.apireq.get(`/accounts/${this.accid}/locales/${e}`))),l(this,"sendEvent",(e=>p)),l(this,"sendTyping",(e=>p)),l(this,"sendPresence",(e=>p)),l(this,"sendContent",(e=>p)),l(this,"uploadToS3",(async e=>p)),l(this,"getChallenge",(e=>p)),l(this,"createUser",(e=>Promise.resolve({account_id:e,id:"usqzgtgfake",mask:"fakemask"}))),l(this,"createAgentUser",(e=>Promise.resolve("fakemask"))),l(this,"time",(t=>Promise.resolve({code:200,body:(new e.Z.Date).toISOString()}))),l(this,"updateUser",(e=>p)),l(this,"getUser",(e=>Promise.resolve({code:200,body:{id:"-"}}))),l(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),l(this,"getIsOnline",(()=>this.apireq.get(`/accounts/${this.accid}/is_online`))),l(this,"sendImpression",(e=>p)),l(this,"sendConversion",(e=>p)),this.FileURL=i,this.apireq=h.setBaseUrl(t).setContentType("text/plain").beforeHook(d).setParser("json")}setAgentId(e){this.agentid=e}setAuth(e){this.accid=e.accid,this.mask=e.mask,this.uid=e.uid}}(t,i):this.api=new class{constructor(t,i){s(this,"listConversations",(e=>this.apireq.addQuery("user_id",this.uid).addQuery("integration_id",`${this.accid}.subizv4.subikon`).get("/conversations"))),s(this,"listMessages",((e,t,i)=>this.apireq.addQuery("limit",t).addQuery("start_id",i).get(`/conversations/${e}/messages`))),s(this,"ajax",a),s(this,"start",(t=>{let i={starter_id:this.uid,starter_type:"user",integration_id:`${this.accid}.subizv4.subikon`};return e.Z.each(t,((e,t)=>{i[t]=e})),this.apireq.post("/conversations",i)})),s(this,"sendConvoEvent",((e,t)=>this.apireq.post(`/accounts/${this.accid}/conversations/${e}/events`,t))),s(this,"createPostback",((e,t)=>this.apireq.post(`/accounts/${this.accid}/conversations/${e}/postbacks`,t))),s(this,"markAsReceived",((e,t)=>this.apireq.post(`/conversations/${e}/messages/${t}/receive`))),s(this,"markAsSeen",((e,t)=>this.apireq.post(`/conversations/${e}/messages/${t}/seen`))),s(this,"getConversation",(e=>this.apireq.get(`/conversations/${e}`))),s(this,"getLocaleContent",(e=>this.apireq.get(`/accounts/${this.accid}/locales/${e}`))),s(this,"sendEvent",(e=>this.apireq.post(`/users/${this.uid}/events`,e))),s(this,"sendTyping",(e=>this.apireq.post(`/conversations/${e}/typing`))),s(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{error:i};let n,r=e.type||"application/octet-stream";return({error:i}=await a.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?{error:i}:{url:this.FileURL+n.url})})),s(this,"getChallenge",(e=>this.apireq.post(`/accounts/${e}/scrypt-challenges`))),s(this,"time",(e=>this.apireq.get("/time"))),s(this,"updateUser",(e=>this.apireq.post(`/users/${this.uid}`,e))),s(this,"getUser",(e=>this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`))),s(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),s(this,"getIsOnline",(()=>this.apireq.get(`/accounts/${this.accid}/is_online`))),s(this,"sendImpression",(e=>this.apireq.post(`/accounts/${this.accid}/campaigns/${e.campaign_id}/impressions`,e))),s(this,"sendConversion",(e=>this.apireq.post(`/accounts/${this.accid}/campaigns/${e.campaign_id}/conversions`,e))),this.FileURL=i,this.ApiURL=t,this.apireq=a.setBaseUrl(t).withCredentials(!0).addQuery("v","6").setContentType("text/plain").beforeHook(u).setParser("json").beforeHook(((e,t)=>(this.mask&&(e.request=e.request.addQuery("x-user-mask",this.mask)),t(!0))))}setAgentId(e){this.agentid=e}setAuth(e){this.accid=e.accid,this.mask=e.mask,this.uid=e.uid}sendPresence(t,i){return this.sendEvent({by:{id:this.uid,device:t},type:"presence_updated",data:{presence:{pinged:e.Z.Date.now(),is_focused:i}}})}sendContent(e,t,i){return this.sendEvent({by:{id:this.uid,device:e},type:"content_viewed",data:{product:{url:t,title:i}}})}async createAgentUser(t){for(var i=0;i<10;i++){let{body:i,error:n}=await a.setBaseUrl(this.ApiURL).setContentType("text/plain").beforeHook(u).setParser("json").addQuery("x-access-token",t).post("/agent-users");if(n){await e.Z.sleep(1e3);continue}let r=i&&i.id||"";return r?i.account_id+"@"+r:""}}async createUser(t){for(var i=0;i<10;i++){const{body:i}=await this.getChallenge(t),n=c(i),r={challenge_id:i.id,answer:""+n};let{body:s,error:o}=await this.apireq.post(`/accounts/${t}/scrypt-challenges/users`,r);if(!o)return s;await e.Z.sleep(1e3)}}}(t,i),o&&(this.inmem=o,this.cookie=k),this.pubsub=new e.Z.Pubsub,this.kv=new r.kv(new r.lsdb("sbz2020",this.inmem),"kv"),this.cache=new r.kv(new r.lsdb("sbz2020",!0),"kv"),this.chain=new r.chain(new r.lsdb("cbz2020",!0),"ch"),this.getLocaleContent=this.api.getLocaleContent,this.g_haveSentSeenM={},window.addEventListener("blur",(()=>this.sendPresence())),window.addEventListener("focus",(()=>this.sendPresence())),setInterval((()=>this.sendPresence()),3e4),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.browserVisibility=e,this.sendPresence()})),this.loopTime(),this.device=this.getDeviceInfo();const y=setInterval((()=>{let t=this.kv.match("user")||{};if(!t.id)return;var i=this.getDeviceInfo();if(!i.ga_tracking_ids||!i.ga_client_id)return;clearInterval(y),this.device=i;let n=i.ga_client_id;n!==e.Z.getUserAttr(t,"ga_client_id","text")&&this.setUser({attributes:[{type:"text",text:n,key:"ga_client_id"}]})}),2e3)}isInsync(t){return e.Z.Date.now()-(this.g_sync[t]||0)<3e5}async overrideAcc(t){this.forceAcc=e.Z.cloneDeep(t),await this.readyGate.entry(),this.disconnect("account"),this.reconnect()}async overrideChatbox(e){this.forceChatbox=e,await this.readyGate.entry(),this.disconnect("account"),await this.reconnect(),setTimeout(this.pubsub.publish("resetCSS"),10)}getDeviceInfo(){let e={user_agent:window.navigator.userAgent,screen_resolution:window.screen.width+"x"+window.screen.height,source_referrer:document.referrer,platform:window.navigator.platform,referrer:document.URL,type:this.isMobile()?"mobile":"desktop",language:navigator.language},t=(i="",x()?((window.ga.getAll()||[]).forEach((function(e){i=e.get("clientId")})),i):i);var i;t&&(e.ga_client_id=t);let n=(r=[],x()?((window.ga.getAll()||[]).forEach((function(e){var t=e.get("trackingId");t&&r.push(t)})),r):r);var r;return n.length>0&&(e.ga_tracking_ids=n),e}highlight(e,t){this.pubsub.publish("highlight",e,t)}overrideDeviceType(e){this.forceDevice=e,this.pubsub.publish("account")}isMobile(){return"mobile"===this.forceDevice||C}isTablet(){return"tablet"===this.forceDevice||S}isDesktop(){return"desktop"===this.forceDevice||!this.isMobile()&&!this.isTable()}disconnect(e){this.g_sync[e]=0}pageLoaded(){return y}overridePlugin(t){if(!Array.isArray(t))throw"plugins must be be an array";let i={};e.Z.map(t,(function(e){i[e.id]=e})),this.forcePlugins=i,this.pubsub.publish("account"),this.pubsub.publish("resetCSS")}markSync(t){this.g_sync[t]=e.Z.Date.now()}async _touchAcc(){this.isInsync("account")||(await this.readyGate.entry(),this.isInsync("account")||this.reconnect())}async init(e){this.readyGate.close(),e=(e||"").trim(),this.api.setAuth({accid:e}),this.g_sync={};let t="";try{t=this.cookie.get("__sbmask","")}catch(e){}let i=this.kv.match("mask");!t&&i&&(t=i),t&&i&&t!==i&&this.clearBrowserData(),this.agent_token&&(t=await this.api.createAgentUser(this.agent_token));var n="";if(t){let i=t.split("@");i[0]!=e?(t="",this.clearBrowserData()):n=i[1]}if(t)this.new_visitor=!1;else{let i=await this.api.createUser(e);this.new_visitor=!0,t=i.mask,n=i.id}this.cookie.set("__sbmask",t),this.kv.put("mask",t),this.realtime&&this.realtime.stop(),this.fake?this.realtime=new class{onEvent(){}onInterrupted(){}subscribe(){}stop(){}}:this.realtime=new m(this.RealtimeURL,{user_mask:t}),this.realtime.onEvent(this.onWs.bind(this)),this.realtime.onInterrupted((()=>this.reconnectWs(e,n))),this.api.setAuth({accid:e,uid:n,mask:t}),this.seenLoop(),await this.reconnect(),this.readyGate.open(),this.reconnectWs(e,n)}seenLoop(){this.seenQueue=[],clearInterval(this._seenInterval),this._seenInterval=setInterval((()=>{this.seenQueue=[...new Set(this.seenQueue)];let t=this.kv.match("user")||{};e.Z.map(this.seenQueue,(i=>{var n=this.listEvents(i);if(!n)return;if(0===e.Z.size(n))return;var r=(n=e.Z.filter(n,(e=>"message_sent"===e.type)))[e.Z.size(n)-1];if(!r)return;if(this.g_haveSentSeenM[r.id])return;if(r.id===e.Z.getMsgField(r,"idempotency"))return;this.api.markAsSeen(i,r.id);let s=this.cache.match("convo_"+i)||{};e.Z.find(s.members,(e=>e.id===t.id)).seen_at=Date.now(),this._setConvo(s),this.g_haveSentSeenM[r.id]=!0})),this.seenQueue=[]}),1e3)}async reconnectWs(e,t){return 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}`,`conversation_pending.account.${e}.user.${t}`,`user_info_updated.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(),this.disconnect("account"),this.reconnect()}async reconnect(){if(this._die)return;if(await this.reconnectGate.entry(void 0,!0),this.isInsync("account"))return this.reconnectGate.open();this.markSync("account");let t=await Promise.all([this.api.getUser(),this.api.getAccountSetting(),this.api.getIsOnline()]),i=e.Z.find(t,(e=>e.error));if(i)return console.error(i);let n=Object.assign(t[1].body,t[2].body);n.user=t[0].body,await this._setSetting(n);let r=await this.api.listConversations();i=r.error;let s=r.body;if(!i){let t=e.Z.get(s,"conversations",[]);e.Z.map(this.cache.all(),((t,i)=>{i.startsWith("convo_")&&this.now()-e.Z.getMs(e.Z.get(t,"actived"))>12096e5&&this.cache.del(i)})),e.Z.map(t,(e=>this._setConvo(e)))}return this.reconnectGate.open()}async setUser(e){if(e)return await this.readyGate.entry(),this._setUser(e),this.api.updateUser(e)}_setUser(t){let i=this.kv.match("user")||{};var n=i.account_id||t.account_id,r=i.id||t.id;e.Z.each(t.attributes,(t=>{t&&(i.attributes=e.Z.filter(i.attributes,(e=>!!e&&e.key!==t.key)))})),i.attributes=i.attributes||[],i.attributes=i.attributes.concat(t.attributes),i.account_id=n,i.id=r,this.kv.put("user",i),this.pubsub.publish("account")}async setSetting(e){if(e)return await this.readyGate.entry(),this._setSetting(e)}async _setSetting(t){if((t=e.Z.cloneDeep(t)||{}).account=Object.assign({},t.account,this.forceAcc),t.account.logo_url||(t.account.logo_url="https://file-subiz.com/fiqpezhkmeyesdscyetk-default_logo.jpg"),t.user){t.user.account_id=t.account.id;let e=this.matchSession(),i=t.user.session;for(i?i.id===e.id&&(i._urls=e._urls):i=e,i._urls=i._urls||[],i._urls.push(location.href);i._urls.length>1e3;)i._urls.shift();this.kv.put("session",i),delete t.user.session,this._setUser(t.user)}t.account&&(t.account.is_online=t.is_online,t.account.is_in_business_hour=t.is_in_business_hour,this.cache.put("account",t.account),delete t.account);let i=e.Z.get(t,"bots",[]),n={};e.Z.map(i,(e=>{n[e.id]=e})),this.cache.put("bot",n);let r=e.Z.get(t,"plugins",[]),s={};e.Z.map(r,(t=>{"chatbox"===t.type&&(t=e.Z.merge(t,this.forceChatbox)),s[t.id]=t})),this.cache.put("plugin",s);var o=e.Z.get(t,"agents",[]);if(e.Z.size(o)>0){let t={};this.api.setAgentId(o[0].id),e.Z.map(o,(e=>{t[e.id]=e})),this.cache.put("agent",t)}this.pubsub.publish("account")}async track(){this.kv.match("user"),await this.api.sendContent(this.device,location.href,document.title),this.sendPresence()}async onWs(t){if(!t||!t.type)return;if(t.created=e.Z.getMs(t.created),"user_info_updated"===t.type){let i=e.Z.cloneDeep(this.kv.match("user")),n=e.Z.get(t,"data.user.attributes")||[];return e.Z.map(n,(t=>e.Z.setUserAttr(i,t))),void this._setUser(i)}let i=this.kv.match("user")||{};const n=e.Z.getIntegrationId(i.account_id);let r,s=e.Z.convoOfEv(t);if(s&&(r=this.matchConvo(s),!r||!r.id)){let{body:e,error:t}=await this.api.getConversation(s);if(!e)return;r=e}if(!r)return;let o=e.Z.get(r,"integration.id","");if(o||(o=e.Z.get(t,"data.message.integration_id","")),o&&o===n){if(this.pubsub.publish("events",t),"conversation_joined"===t.type){let i=e.Z.get(t,"data.conversation.members",[]);if(e.Z.find(i,(e=>e.id===this.kv.match("user").id))){await this.chain.reload(s,((e,t,i)=>this.listmessageapi(e,t,i))),this.markSync("events"+s);let{body:e}=await this.api.getConversation(s);e&&(r=e,this._setConvo(r)),this.pubsub.publish("account")}}return"message_sent"===t.type&&e.Z.get(t,"by.id")!==i.id&&this.api.markAsReceived(s,t.id),e.Z.startsWith(t.type,"message_")||e.Z.startsWith(t.type,"conversation_")?(this.restConvoEvent(t),void("message_sent"===t.type&&e.Z.get(t,"by.id")!==i.id&&Z("SUBIZ Chat","Received","User"))):void 0}}async restConvoEvent(t){let i=this.kv.match("user"),n=e.Z.convoOfEv(t),r=this.cache.match("convo_"+n)||{};if("conversation_state_updated"===t.type){if(!e.Z.get(r,"id")){let{body:e,error:t}=await this.api.getConversation(n);if(t)return}r=Object.assign(r,e.Z.get(t,"data.conversation"))}if("message_pong"===t.type){var s=e.Z.get(t,"data.message.id"),o=this.chain.match(n,s);if(!e.Z.get(o,"data.message"))return;var a=e.Z.get(o,"data.message.pongs",[]);a=a.concat(e.Z.get(t,"data.message.pongs",[])),o.data.message.pongs=a,e.Z.map(a,(t=>{t.member_id==i.id&&"seen"===t.type&&(e.Z.find(r.members,(e=>e.id===i.id)).seen_at=t.created)})),this.chain.put(n,o.id,e.Z.getMs(o.created),o)}if("message_sent"===t.type){let i=e.Z.getMsgField(t,"idempotency"),s=e.Z.find(this.listEvents(n),(e=>e.id===i));s&&(this.chain.del(n,s.id),t.created=s.created),r.last_message_sent=t}"message_pong"!==t.type&&"conversation_typing"!==t.type&&this.chain.put(n,t.id,e.Z.getMs(t.created),t),r.last_event=t,this._setConvo(r),this.pubsub.publish("account")}handleFormSubmit(t,i){if("message_sent"!==i.type)return;let n=[],r=e.Z.get(i,"data.message.attachments")||[];e.Z.each(r,(e=>{e&&"form_submit"===e.type&&n.push(e.form_submit)})),e.Z.each(n,(i=>{let n=e.Z.get(this.convoEventM,t+"."+i.form_message_id);if(!n)return;let r=e.Z.filter(e.Z.get(n,"data.message.attachments"),(e=>!!e&&("form"===e.type||"ask_info_form"===e.type)));e.Z.each(r,(t=>{t=t.form,e.Z.each(t.fields,(t=>{e.Z.each(i.fields,(e=>{t.name===e.name&&(t.default_answer||(t.default_answer=e.value))}))}))})),e.Z.size(r)>0&&this.pubsub.publish("state.convoEventM",this.convoEventM,t)}))}typing(e){e&&this._typing(e)}async startConvo(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})}createPostback(e,t){return this.api.createPostback(e,t)}async sendConvoEvent(t,i,n){await this.readyGate.entry();var r=e.Z.randomString(36),s={id:r,by:{id:(this.kv.match("user")||{}).id,type:"user",device:{referrer:document.URL}},data:n,type:i,created:this.now()};e.Z.convoToEv(t,s);let o=[];if("message_sent"===i&&(e.Z.setMsgField(s,"idempotency",r),s.data.message.conversation_id=t,await _.map(s.data.message.attachments,2,(async(e,t)=>{var i;"file"===e.type&&e._file&&(o.push(e),w.includes(e._file.type)&&(e.url=await(i=e._file,new Promise((e=>{var t=new window.FileReader;t.onload=t=>{e(t.target.result)},t.readAsDataURL(i)})))))}))),this.onWs(s),await this.convoGate.entry(),await _.map(o,1,(async e=>{const{url:t,error:i}=await this.api.uploadToS3(e._file);s._error=i,e.url=t})),s._error)return this.onWs(s);let{body:a,error:c}=await this.api.sendConvoEvent(t,s);if(c)return s._error=c,void this.onWs(s);this.onWs(a),Z("SUBIZ Chat","Sent","User")}_setConvo(t){let i=this.kv.match("user");const n=e.Z.getIntegrationId(i.account_id);let r=e.Z.get(t,"integration.id","");if(!r||r!==n)return;let s={};if(e.Z.map(this.cache.all(),((e,t)=>{t.startsWith("convo_")&&(s[t]=e)})),e.Z.size(s)>18){s=e.Z.orderBy(e.Z.map(s),"created","desc");for(var o=18;o<e.Z.size(s);o++){let e=s[o];this.cache.del("convo_"+e.id)}}this.markSync(t.id),this.pubsub.publish("account"),this.cache.put("convo_"+t.id,t)}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.matchSession(),i=this.kv.match("bot_run_logs")||{};i[e]={bot_id:e,created:this.now(),session_id:t.id},this.kv.put("bot_run_logs",i)}sendImpression(e){let t=this.kv.match("user")||{},i=this.kv.match("plugin_run_logs")||{},n=this.matchSession();return i[e]={web_plugin_id:e,created:this.now(),session_id:n.id},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,session_id:n.id})}sendConversion(t,i,n){let r=this.kv.match("user")||{},s={account_id:r.account_id,user_id:r.id,fields:i},o=this.kv.match("conversions")||{};return o[t]=!0,this.kv.put("conversions",o),this.api.sendConversion({account_id:r.account_id,web_plugin_id:t,campaign_id:t,user_id:e.Z.get(r,"id"),url:window.location.href,device:this.device,submission:s,impression_token:n,session_id:this.matchSession().id})}isConverted(e){return(this.kv.match("conversions")||{})[e]}async listmessageapi(t,i,n){let r=t,{body:s,code:o,error:a}=await this.api.listMessages(r,-n,i);if(a||200!==o)return[[],i,a];i=e.Z.get(e.Z.last(s),"id"),s=e.Z.map(s,(t=>(t.created=e.Z.getMs(t.created),{id:t.id,index:t.created,value:t})));let c=this.kv.match("user")||{};for(let t=0;t<s.length;t++){let i=s[t].value;if("message_sent"===i.type&&e.Z.get(i,"by.id")!==c.id){if(e.Z.find(e.Z.get(i,"data.message.pongs"),(e=>e.member_id===c.id)))break;this.api.markAsReceived(r,i.id);break}}return[s,i]}async loopTime(){let t=e.Z.Date.now();if(!e.Z.get(this.kv.match("user"),"id"))return setTimeout((()=>this.loopTime()),3e4);let{body:i,error:n}=await this.api.time();if(n)return setTimeout((()=>this.loopTime()),3e4);var r=Math.abs(e.Z.Date.now()-t)/2,s=new e.Z.Date(i).getTime()+r,o=e.Z.Date.now();this.timeDiff=Math.floor(s-o),setTimeout((()=>this.loopTime()),6e4)}replaceFileUrl(t){return t?e.Z.startsWith(t,"/")||e.Z.startsWith(t,"data:")?t:(e.Z.startsWith(t,"http://")||e.Z.startsWith(t,"https://")||e.Z.startsWith(t,"//")||(t=e.Z.trim(this.FileURL,"/")+"/"+e.Z.trimStart(t,"/")),t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.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(){e.Z.each(this.cookie.all(),((e,t)=>{(t||"").startsWith("__sb")&&this.cookie.remove(t)})),this.kv.destroy(),this.kv=new r.kv(new r.lsdb("sbz2020",this.inmem),"kv"),this.chain.destroy(),this.chain=new r.chain(new r.lsdb("cbz2020",!0),"ch")}destroy(){this._die=!0,this.clearBrowserData(),this.realtime&&this.realtime.stop(),this.readyGate.close()}}const w=["image/gif","image/jpeg","image/png","image/svg+xml"],k={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]}},x=()=>!(!window.ga||!window.ga.getAll);function Z(e,t,i){document.dispatchEvent(new CustomEvent("subiz",{detail:{category:e,action:t,label:i}})),function(e,t,i){x()&&(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 C=(z=navigator.userAgent||navigator.vendor||window.opera,/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(z)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(z.substr(0,4)));var z;let S=/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(navigator.userAgent);var A=o(6400);let O={},j=!1;function P(t,i,n,r){if(!n)throw"$div must is a valid html node";var s=document.createElement("div");s.id=t.id,n.appendChild(s);let a=T(t,e.Z.detectLang());var c,u=new e.Z.Gate,l=0,h="hold",d=this;this.getState=()=>h;var p=async function(){if(k)return;if("hold"!==h)return;if("popup"===t.type&&i.isConverted(t.id))return;let n=i.matchLastPluginRun(t.id);"chatbox"!==t.type&&"notification"!==t.type||(n=void 0),e.Z.checkRunConditions(t.initiative_frequency,t.conditions,n,i)&&(h="running",await d.update(t))};this.forceRunPopup=async()=>{e.Z.get(f,"current")?f.current.openPopup():w()};var f=(0,A.Vf)();let g=null,_=null,m=null,v=null;var y=e=>r.showWidget(e),b=()=>{l++,w()},w=async()=>{k||s&&("chatbox"===t.type&&(g||(g=(await o.e(712).then(o.bind(o,5712))).default),(0,A.sY)((0,A.h)(g,{destroy:k,plugin:t,store:i,ref:f,t:this.t}),s)),"popup"===t.type&&(_||(_=(await o.e(213).then(o.bind(o,8213))).default),(0,A.sY)((0,A.h)(_,{destroy:k,t:this.t,highlight:c,mobile:i.isMobile(),plugin:t,store:i,ref:f,pageIndex:l,nextPage:b,showWidget:y}),s)),"notification"===t.type&&(v||(v=(await o.e(605).then(o.bind(o,9605))).default),(0,A.sY)((0,A.h)(v,{destroy:k,t:this.t,mobile:i.isMobile(),plugin:t,store:i,ref:f}),s)),"contact"===t.type&&(m||(m=(await o.e(619).then(o.bind(o,9619))).default),(0,A.sY)((0,A.h)(m,{destroy:k,t:this.t,plugin:t,store:i,ref:f}),s)),u.open())};this.call=(e,t)=>u.entry().then((()=>f.current[e](t)));var k=!1;this.destroy=()=>{k=!0,(0,A.sY)(null,s),s.parentNode.removeChild(s)},this.highlight=e=>{c=e,w()},this.update=e=>{k||(t=e,"hold"!==h&&"finished"!==h&&w())};let x=t=>{if("debug"===a)return`{{${t}}}`;let i=e.Z.get(O,a,[]),n=e.Z.find(i,(e=>e.key===t));return e.Z.get(n,"message",t)},Z=i.matchAccount();x.i18n=e=>{if(!e)return"";let i=t.locale||Z.locale||"vi-VN";return i=i.replace("-","_"),e[a.replace("-","_")]||e[i]},x.locale=()=>a,this.forceDownloadLanguage=async()=>{await E(i,a,!0),this.update(t)},this.setLocale=async e=>a===e?e:(this.t=null,w(),a=T(t,e),await E(i,a),this.t=x,w(),a);let C={};e.Z.map(e.Z.get(t,"popup.pages"),(t=>{t&&e.Z.map(t.components,(e=>{"image"===e.type&&e.image&&e.image.url&&e.image.url.startsWith("http")&&(C[e.image.url]=!0)}))})),e.Z.size(C)>=0&&e.Z.map(C,((t,i)=>e.Z.preloadImg(i)));let z=e.Z.get(t,"triggers")||[{type:"after_pageview",after_pageview_sec:0,disabled:!1}];for(var S=0;S<e.Z.size(z);S++){var j=z[S];j&&(j.disabled||("exit_intent"===j.type&&e.Z.trackExitIntent(p),"area_clicked"===j.type&&e.Z.trackAreaClicked(j.area_clicked_css_selector,p),"scrolling_percentage"===j.type&&e.Z.trackScrollingPercentage(j.scrolling_percentage,p),"inactivity_duration"===j.type&&e.Z.trackInactivity(j.inactivity_sec,p),"after_pageview"===j.type&&e.Z.trackTimeOnPage(j.after_pageview_sec,p)))}this.update(t),E(i,a).then((()=>{this.t=x,this.update(t)}))}class M{constructor(t,i){this.refM={},this.lib=t,this.$div=i,this.pluginM={},this._destroy=!1,t.store.onHighlight({_isMounted:!0},((e,t)=>{let i=this.pluginM[e];i&&i.highlight(t)})),t.store.onUpdate({_isMounted:!0},(()=>{if(this._destroy)return;let n=this.lib.store.matchPlugin(),r=!1;e.Z.each(n,(e=>{if("chatbox"===e.type){if(r)return;r=!0}this.pluginM[e.id]?this.pluginM[e.id].update(e):this.pluginM[e.id]=new P(e,this.lib.store,i,t)})),e.Z.each(this.pluginM,((e,t)=>{n[t]||(this.pluginM[t].destroy(),delete this.pluginM[t])}))}));let n=this.lib.store.matchPlugin(),r=!1;e.Z.each(n,(e=>{if("chatbox"===e.type){if(r)return;r=!0}this.pluginM[e.id]||(this.pluginM[e.id]=new P(e,this.lib.store,i,t))}))}findChatbox(){var t=this.lib.store.matchPlugin();let i=e.Z.filter(this.pluginM,((e,i)=>"chatbox"===t[i].type));if(0===e.Z.size(i))return void console.error("no chatbox found.");let n=e.Z.find(i,(e=>"running"===e.getState()));if(n||(n=i[0]),n)return n;console.error("found no suitable chatbox to run.")}getCurrentView(){let e=this.findChatbox();if(e)return e.call("getCurrentView")}showCurrentChatbox(e){let t=this.findChatbox();t&&t.call("showWidget",e)}showCurrentGreeting(){let e=this.findChatbox();e&&e.call("showGreeting")}hideCurrentGreeting(){let e=this.findChatbox();e&&e.call("hideGreeting")}hideCurrentChatbox(){let e=this.findChatbox();e&&e.call("hideWidget")}forceUpdateLang(e){let t=this.pluginM[e];t&&t.forceDownloadLanguage()}forceRunPopup(e){let t=this.pluginM[e];t&&t.forceRunPopup(e)}setPluginLocale(e,t){let i=this.pluginM[e];if(i)return i.setLocale(t)}setCurrentChatboxLocale(e){let t=this.findChatbox();t&&t.setLocale(e)}destroy(){e.Z.map(this.pluginM,((e,t)=>{this.pluginM[t]||(this.pluginM[t].destroy(),delete this.pluginM[t])})),this._destroy=!0}}function E(t,i,n){if(j)return new Promise((e=>setTimeout((()=>E(t,i,n).then(e)),100)));let r;return j=!0,"debug"===i||O[i]&&!n?(j=!1,Promise.resolve()):t.getLocaleContent(i).then((t=>{j=!1,r=e.Z.get(t,"body.messages",[]),O[i]=r}))}const T=(t,i)=>{let n=e.Z.find(t.locales,(e=>e===i));return n?i:(n=e.Z.find(t.locales,(e=>(e||"").toLowerCase().includes(i.toLowerCase()))),n||t.locale||"en-US")};function U(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var L=document.createElement("link");L.href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap",L.rel="stylesheet",document.head.append(L),e.Z.preloadWebfonts(["Roboto"],[400,500]);class q{constructor(t,i,n,r,s,o){U(this,"version",(()=>"4.4")),U(this,"setSetting",(e=>this.store.setSetting({account_setting:e}))),U(this,"getSetting",(t=>({account_setting:e.Z.cloneDeep(this.store.matchAccountSetting())}))),U(this,"getUser",(()=>e.Z.parseJSON(e.Z.stringify(this.store.matchUser())))),this.domGate=new e.Z.Gate,this.store=new b(t,i,n,r,s,o),window.sbz_store=this.store,this.subs=[],this.store.onConvoEvent({_isMounted:!0},(t=>e.Z.map(this.subs,(e=>e(t)))))}setLang(e){var t=new XMLHttpRequest;t.open("GET","https://api.sbz.vn/4.0/oldlang",!0),t.send()}toggleLangDebugMode(){var e=new XMLHttpRequest;e.open("GET","https://api.sbz.vn/4.0/oldlangdebug",!0),e.send()}async setAccount(e,t){await this.store.init(e),t||(t=document.body),this.pluginMgr=new M(this,t);let i=setInterval((()=>{t&&t.isConnected||(this.pluginMgr.destroy(),clearInterval(i))}),1e3);this.domGate.open()}_setAccount(e,t){return this.setAccount(e,t)}async updateUserAttributes(t){await this.store.setUser({attributes:t});var i=this.store.matchUser();return e.Z.cloneDeep(i.attributes)}async getUserAttributes(){await this.store.readyGate.entry();var t=this.store.matchUser();return e.Z.cloneDeep(e.Z.get(t,"attributes",[]))}async getWidgetCurrentView(){return await this.domGate.entry(),this.pluginMgr.getCurrentView()}expandWidget(e,t){return this.showWidget(e,t)}shrinkWidget(){return this.hideWidget()}async sendMessage(e,t){this.store.sendConvoEvent(e,"message_sent",{message:t})}startConvo(e){return this.store.startConvo(e)}async showGreeting(){await this.domGate.entry(),this.pluginMgr.showCurrentGreeting()}async hideGreeting(){await this.domGate.entry(),this.pluginMgr.hideCurrentGreeting()}async showWidget(e,t){await this.domGate.entry(),this.pluginMgr.showCurrentChatbox({view:e,cid:t})}async hideWidget(){await this.domGate.entry(),this.pluginMgr.hideCurrentChatbox()}async setLocale(e){return await this.domGate.entry(),this.pluginMgr.setCurrentChatboxLocale(e)}async setPluginLocale(e,t){return await this.domGate.entry(),this.pluginMgr.setPluginLocale(e,t)}_overrideDeviceType(e){this.store.overrideDeviceType(e)}_overridePlugin(e){this.store.overridePlugin(e)}_forceUpdateLang(e){this.pluginMgr.forceUpdateLang(e)}_highlight(e,t){this.store.highlight(e,t)}openPopup(e){this.pluginMgr.forceRunPopup(e)}unEvent(t){this.subs=e.Z.filter(this.subs,(e=>e!==t))}async countUnreadMessages(){return await this.domGate.entry(),this.store.matchUnread()}onEvent(t){this.subs=e.Z.filter(this.subs,(e=>e!==t)),this.subs.push(t)}overrideAccount(e){this.store.overrideAcc(e)}async overrideChatbox(t){await this.store.overrideChatbox(t),e.Z.get(t,"chatbox.greeting.greeting")&&this.pluginMgr.showCurrentGreeting()}}window.__sbz_WIDGET=q;const I=q;if(window._subiz_init_2094850928430&&!window._subiz_init_2094850928430_keep_loading)throw new Error("subiz have already initialized");window._subiz_init_2094850928430=!0,window._subiz_init_2094850928430_keep_loading=!1,o(7460);var R=o(4636),D=window._sbzaccid?"4.3":function(){if(window.sbz_v4)return!0;var e=document.getElementsByTagName("script");if("function"!=typeof window.subiz)return!1;for(var t of e)if(t&&t.src){if(-1!==t.src.indexOf(R.BaseURL))return!0;if(-1!==t.src.indexOf("https://widgetv4.subiz.com"))return!0;if(-1!==t.src.indexOf("https://widget.mysubiz.com"))return!0;if(-1!==t.src.indexOf("https://storage.googleapis.com/sbz"))return!0}return!1}()?"4.2":window.subiz_account_id&&window.subiz_account_id>0?"1":function(){var e=document.getElementsByTagName("script");if(!(window._sbzq instanceof Array))return!1;for(var t of e)if(t&&t.src){if(-1!==t.src.indexOf(R.BaseURL))return!0;if(-1!==t.src.indexOf("https://widgetv4.subiz.com"))return!0}return!1}()?"4.1":function(){if(!window._sbzq)return!1;var e=document.getElementsByTagName("script");for(var t of e)if(t&&t.src&&-1!==t.src.indexOf("static.subiz.com"))return!0;return!1}()?"2":void 0;if(!D)throw new Error("subiz cannot detect version");var W=new I(R.ApiURL,R.FileURL,R.RealtimeURL);function $(e){e=e||[];var t=[];if(Array.isArray(e))t=e;else{if("object"!=typeof e)return;for(var i=Object.keys(e),n=0;n<i.length;n++)t.push(e[i[n]])}if(!((e=t).length<1)){var r=e.shift();if("function"==typeof W[r])return W[r](...e)}}window.addEventListener("keydown",(function(e){"Escape"===e.key&&W.hideWidget()}));let G=window.document.title;!function e(t){let i;if(W.store&&W.store.matchUser()&&(i=W.store.matchUser().account_id),"acqnarufdnsdtthffcnh"==i)return;if("visible"===W.store.browserVisibility)return"dirty invisible"===t&&G===window.document.title&&(window.document.title=window.document.title.substr(4)),setTimeout(e,1e3,"visible");let n=W.store.matchUnread();return n?"dirty invisible"===t?(G===window.document.title&&(window.document.title=window.document.title.substr(4)),setTimeout(e,1e3,"dirty invisible blink")):(n>9&&(n="*"),window.document.title="("+n+") "+window.document.title,G=window.document.title,setTimeout(e,2e3,"dirty invisible")):("dirty invisible"===t&&G===window.document.title&&(window.document.title=window.document.title.substr(4)),setTimeout(e,1e3,"clean invisible"))}(),function(){if("1"!==D&&"2"!==D){if("1"===D&&W._setAccount(window.subiz_account_id),"2"===D||"4.1"===D){let e=window._sbzq||[];Array.isArray(e)||(e=[]),window._sbzq={push:$},e.forEach($)}if("4.2"===D||"4.3"===D){let e=window.subiz&&window.subiz.q||[];window.subiz=function(){return $(arguments)},e.forEach($)}W.store.readyGate.entry().then((function(){W.store.track(),function(t){let i=t.matchBot();0!==Object.keys(i).length&&e.Z.each(i,(i=>{let n=async()=>{if(n=()=>!0,!e.Z.checkRunConditions(i.initiative_frequency,i.conditions,t.matchLastBotRun(i.id),t))return;let{error:r}=await t.startConvo({initial_by:i.id,locale:e.Z.detectLang(),state:"active",members:[{type:"bot",id:i.id}]});if(r)return console.error(r);t.logBotRun(i.id)},r=e.Z.get(i,"triggers")||[];for(let t of r){if(!t)continue;if(t.disabled)continue;let i=n;"area_clicked"===t.type&&e.Z.trackAreaClicked(t.area_clicked_css_selector,i),"scrolling_percentage"===t.type&&e.Z.trackScrollingPercentage(t.scrolling_percentage,i),"inactivity_duration"===t.type&&e.Z.trackInactivity(t.inactivity_sec,i),"after_pageview"===t.type&&e.Z.trackTimeOnPage(t.after_pageview_sec,i)}}))}(W.store)}))}else console.error("DETECTED SUBIZ OUTDATED V3 EMBEDED CODE",v3accid,". Please visit https://subiz.com.vn for support")}()})()})();
|