@subiz/widget-v4 4.0.91 → 4.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/compiled_src/bot.js +0 -11
  2. package/compiled_src/call/call.js +0 -61
  3. package/compiled_src/call/css.js +0 -2
  4. package/compiled_src/chatbox/AgentsAvatar.js +0 -16
  5. package/compiled_src/chatbox/AudioAttachments.js +0 -14
  6. package/compiled_src/chatbox/ButtonAttachments.js +1 -14
  7. package/compiled_src/chatbox/Buttons.js +0 -13
  8. package/compiled_src/chatbox/ChatButton.js +1 -78
  9. package/compiled_src/chatbox/DropdownSelect.js +3 -44
  10. package/compiled_src/chatbox/Emoji.js +0 -7
  11. package/compiled_src/chatbox/Event.js +0 -59
  12. package/compiled_src/chatbox/Events.js +4 -44
  13. package/compiled_src/chatbox/FileAttachments.js +0 -14
  14. package/compiled_src/chatbox/FormAttachment.js +1 -52
  15. package/compiled_src/chatbox/FormAttachments.js +0 -14
  16. package/compiled_src/chatbox/FormSubmitAttachments.js +0 -11
  17. package/compiled_src/chatbox/GenericTemplateAttachments.js +1 -20
  18. package/compiled_src/chatbox/Header.js +1 -46
  19. package/compiled_src/chatbox/ImageAttachments.js +0 -16
  20. package/compiled_src/chatbox/InfoMessage.js +0 -13
  21. package/compiled_src/chatbox/ListField.js +0 -16
  22. package/compiled_src/chatbox/MessageInput.js +1 -47
  23. package/compiled_src/chatbox/Order.js +0 -35
  24. package/compiled_src/chatbox/OrderAttachments.js +1 -23
  25. package/compiled_src/chatbox/PoweredBy.js +0 -7
  26. package/compiled_src/chatbox/ProductAttachments.js +0 -19
  27. package/compiled_src/chatbox/QuickReplies.js +0 -18
  28. package/compiled_src/chatbox/Rating.js +0 -37
  29. package/compiled_src/chatbox/ShadowDomRoot.js +0 -9
  30. package/compiled_src/chatbox/TextMessage.js +0 -64
  31. package/compiled_src/chatbox/Typing.js +0 -15
  32. package/compiled_src/chatbox/VideoAttachments.js +0 -14
  33. package/compiled_src/chatbox/Widget.js +6 -167
  34. package/compiled_src/chatbox/css.js +0 -2
  35. package/compiled_src/chatbox/dragscroll.js +1 -5
  36. package/compiled_src/chatbox/main.js +3 -43
  37. package/compiled_src/chatbox/releaseAnimation.js +0 -11
  38. package/compiled_src/chatbox/spinner.js +0 -10
  39. package/compiled_src/chatbox/time.js +0 -22
  40. package/compiled_src/chatbox/touchscroll.js +0 -7
  41. package/compiled_src/common.js +0 -22
  42. package/compiled_src/contact/contact.js +2 -52
  43. package/compiled_src/contact/css.js +0 -2
  44. package/compiled_src/lib.js +19 -46
  45. package/compiled_src/notif/css.js +0 -2
  46. package/compiled_src/notif/notif.js +0 -63
  47. package/compiled_src/order/address_picker.js +4 -38
  48. package/compiled_src/order/icon.js +0 -16
  49. package/compiled_src/order/index.js +1 -34
  50. package/compiled_src/order/order.js +2 -156
  51. package/compiled_src/plugin.js +1 -77
  52. package/compiled_src/popup/countdown.js +2 -33
  53. package/compiled_src/popup/css.js +0 -2
  54. package/compiled_src/popup/popup.js +2 -165
  55. package/compiled_src/popup/tick.core.commonjs.js +72 -222
  56. package/compiled_src/popup/tick.view.flip.commonjs.js +23 -31
  57. package/compiled_src/store/api.js +103 -66
  58. package/compiled_src/store/api_fake.js +3 -39
  59. package/compiled_src/store/realtime_fake.js +0 -6
  60. package/compiled_src/store/store.js +46 -257
  61. package/compiled_src/util/campaign.js +0 -13
  62. package/compiled_src/util/common.js +15 -190
  63. package/compiled_src/util/common.test.js +0 -4
  64. package/compiled_src/util/extractor.js +1 -21
  65. package/compiled_src/util/extractor.test.js +0 -3
  66. package/compiled_src/util/gate.js +0 -7
  67. package/compiled_src/util/gate.test.js +1 -2
  68. package/compiled_src/util/index.js +1 -7
  69. package/compiled_src/util/mutex.js +31 -0
  70. package/compiled_src/util/op.js +1 -14
  71. package/compiled_src/util/pubsub.js +0 -6
  72. package/compiled_src/util/pubsub.test.js +0 -2
  73. package/package.json +12 -12
  74. package/src/chatbox/main.js +3 -3
  75. package/src/lib.js +24 -2
  76. package/src/store/api.js +111 -22
  77. package/src/store/api_fake.js +5 -6
  78. package/src/store/store.js +38 -14
  79. package/src/util/common.js +0 -4
  80. package/src/util/index.js +1 -0
  81. package/src/util/mutex.js +27 -0
  82. package/dist/0b82fa7e5c3b07b40a44.png +0 -1
  83. package/dist/0f4af006e38ee8b93633.png +0 -1
  84. package/dist/132.js +0 -6777
  85. package/dist/178.js +0 -573
  86. package/dist/17f00e48d38.132.js +0 -1
  87. package/dist/17f00e48d38.178.js +0 -1
  88. package/dist/17f00e48d38.213.js +0 -1
  89. package/dist/17f00e48d38.335.js +0 -1
  90. package/dist/17f00e48d38.362.js +0 -1
  91. package/dist/17f00e48d38.441.js +0 -1
  92. package/dist/17f00e48d38.605.js +0 -1
  93. package/dist/17f00e48d38.678.js +0 -1
  94. package/dist/17f00e48d38.782.js +0 -1
  95. package/dist/17f00e48d38.app.js +0 -1
  96. package/dist/17f00e48d38.index.html +0 -22
  97. package/dist/17f00e48d38.library.html +0 -22
  98. package/dist/17f00e48d38.library.js +0 -1
  99. package/dist/17f00e48d38.preview.html +0 -759
  100. package/dist/17f00e48d38.preview.js +0 -1
  101. package/dist/17f00e48d38.screenshoot.js +0 -1
  102. package/dist/1ea1c6cd21d25176810c.png +0 -1
  103. package/dist/213.js +0 -3188
  104. package/dist/292d42404e1b03398f61.png +0 -1
  105. package/dist/312d376370831b7bea83.png +0 -1
  106. package/dist/313d1bfc1cf776d1aefe.png +0 -1
  107. package/dist/335.js +0 -411
  108. package/dist/362.js +0 -157
  109. package/dist/441.js +0 -2732
  110. package/dist/4aa58bb7a66bb44975aa.png +0 -1
  111. package/dist/56ce063bc6c81adb7322.png +0 -1
  112. package/dist/605.js +0 -328
  113. package/dist/678.js +0 -157
  114. package/dist/6a411166ef5cc79e0714.png +0 -1
  115. package/dist/6faf403782fefacc1649.png +0 -1
  116. package/dist/782.js +0 -204
  117. package/dist/79dca33c68fab79c067f.png +0 -1
  118. package/dist/82da1578fa84f9debaeb.png +0 -1
  119. package/dist/8b8e0f0824743974b282.png +0 -1
  120. package/dist/8d551390d81e39130a3c.png +0 -1
  121. package/dist/9fc61b9479877ebdb6c7.png +0 -1
  122. package/dist/HASH +0 -1
  123. package/dist/a165d31dcb3dc90f1057.png +0 -1
  124. package/dist/a98d4a5698812c4426b3.png +0 -1
  125. package/dist/assets/img/Facebook.64607ec.png +0 -0
  126. package/dist/assets/img/Zalo.6845707.png +0 -0
  127. package/dist/assets/img/award1a.1a58e10.png +0 -0
  128. package/dist/assets/img/award3a.3b74423.png +0 -0
  129. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  130. package/dist/assets/img/award5.39eb7ae.png +0 -0
  131. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  132. package/dist/assets/img/caret.998eb8f.svg +0 -1
  133. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  134. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  135. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  136. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  137. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  138. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  139. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  140. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  141. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  142. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  143. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  144. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  145. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  146. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  147. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  148. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  149. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  150. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  151. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  152. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  153. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  154. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  155. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  156. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  157. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  158. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  159. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  160. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  161. package/dist/assets/img/empty.29bed2d.svg +0 -23
  162. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  163. package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
  164. package/dist/assets/img/external-link.90577cc.svg +0 -1
  165. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  166. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  167. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  168. package/dist/assets/img/image_default.be0698b.png +0 -0
  169. package/dist/assets/img/info.ebce7ea.svg +0 -1
  170. package/dist/assets/img/loader.37000a7.svg +0 -1
  171. package/dist/assets/img/loading_static.8f403ae.svg +0 -10
  172. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  173. package/dist/assets/img/main-service2.9b99549.png +0 -0
  174. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  175. package/dist/assets/img/package.8d37d0f.svg +0 -5
  176. package/dist/assets/img/package_fade.763c001.svg +0 -1
  177. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  178. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  179. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  180. package/dist/assets/img/search.f9705ff.svg +0 -1
  181. package/dist/assets/img/send.6db52a9.svg +0 -3
  182. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  183. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  184. package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
  185. package/dist/assets/img/x.26fdfa3.svg +0 -5
  186. package/dist/c41606bf9d1b604e46d5.png +0 -1
  187. package/dist/ce1f7450ce6c1aacd330.png +0 -1
  188. package/dist/cf8c01e88f4770a6e3e5.png +0 -1
  189. package/dist/dfbcfeab1d5622a737e2.png +0 -1
  190. package/dist/e4893ed8c2f7b8329919.png +0 -1
  191. package/dist/ec2ab4eb4ef73d186186.png +0 -1
  192. package/dist/malicious-app.js +0 -13
  193. package/dist/screenshoot.html +0 -7
  194. package/dist/screenshoot.js +0 -5919
@@ -18,7 +18,6 @@ exports.find = find;
18
18
  exports.formatCurrency = formatCurrency;
19
19
  exports.getAgentDisplayName = getAgentDisplayName;
20
20
  exports.getDayName = getDayName;
21
- exports.getIntegrationId = getIntegrationId;
22
21
  exports.getMs = getMs;
23
22
  exports.getMsgField = getMsgField;
24
23
  exports.getUrlParameter = getUrlParameter;
@@ -65,15 +64,12 @@ exports.trimStart = trimStart;
65
64
  exports.unicodeToAscii = unicodeToAscii;
66
65
  exports.unixSec = unixSec;
67
66
  exports.usersOfConvo = usersOfConvo;
68
-
69
67
  var op = require('./op.js');
70
-
71
68
  function parseJSON(str) {
72
69
  try {
73
70
  return parse(str);
74
71
  } catch (e) {}
75
72
  }
76
-
77
73
  var f = document.createElement('iframe');
78
74
  f.style.display = 'none';
79
75
  document.documentElement.appendChild(f);
@@ -87,11 +83,10 @@ exports.requestAnimationFrame = requestAnimationFrame;
87
83
  var setTimeout = f.contentWindow.setTimeout;
88
84
  exports.setTimeout = setTimeout;
89
85
  var setInterval = f.contentWindow.setInterval;
90
- exports.setInterval = setInterval;
91
86
 
87
+ exports.setInterval = setInterval;
92
88
  function convoOfEv(ev) {
93
89
  if (!ev) return '';
94
-
95
90
  switch (ev.type) {
96
91
  case 'conversation_state_updated':
97
92
  case 'conversation_joined':
@@ -103,23 +98,18 @@ function convoOfEv(ev) {
103
98
  case 'conversation_rating_requested':
104
99
  case 'conversation_rated':
105
100
  return op.get(ev, 'data.conversation.id');
106
-
107
101
  case 'message_sent':
108
102
  case 'message_updated':
109
103
  case 'message_pong':
110
104
  return op.get(ev, 'data.message.conversation_id');
111
-
112
105
  case 'ticket_updated':
113
106
  return op.get(ev, 'data.ticket.conversation_id');
114
-
115
107
  default:
116
108
  return '';
117
109
  }
118
110
  }
119
-
120
111
  function convoToEv(convoid, ev) {
121
112
  if (!ev) return '';
122
-
123
113
  switch (ev.type) {
124
114
  case 'conversation_state_updated':
125
115
  case 'conversation_joined':
@@ -131,20 +121,16 @@ function convoToEv(convoid, ev) {
131
121
  case 'conversation_rating_requested':
132
122
  case 'conversation_rated':
133
123
  return op.set(ev, 'data.conversation.id', convoid);
134
-
135
124
  case 'message_sent':
136
125
  case 'message_updated':
137
126
  case 'message_pong':
138
127
  return op.set(ev, 'data.message.conversation_id', convoid);
139
-
140
128
  case 'ticket_updated':
141
129
  return op.set(ev, 'data.ticket.conversation_id', convoid);
142
-
143
130
  default:
144
131
  return '';
145
132
  }
146
133
  }
147
-
148
134
  function setMsgField(ev, key, value) {
149
135
  var fields = op.get(ev, 'data.message.fields') || [];
150
136
  fields = filter(fields, field => field.key !== key);
@@ -154,30 +140,24 @@ function setMsgField(ev, key, value) {
154
140
  });
155
141
  op.set(ev, 'data.message.fields', fields);
156
142
  }
157
-
158
143
  function getMsgField(ev, fieldName) {
159
144
  var fields = op.get(ev, 'data.message.fields');
160
145
  if (size(fields) === 0) return undefined;
161
146
  let f = fields.find(f => f.key === fieldName);
162
-
163
147
  try {
164
148
  if (f) return parse(f.value);
165
149
  return undefined;
166
150
  } catch (e) {}
167
151
  }
168
-
169
152
  function isObject(item) {
170
153
  return item && typeof item === 'object' && !Array.isArray(item);
171
154
  }
172
-
173
155
  function merge(target) {
174
156
  for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
175
157
  sources[_key - 1] = arguments[_key];
176
158
  }
177
-
178
159
  if (!sources.length) return target;
179
160
  const source = sources.shift();
180
-
181
161
  if (isObject(target) && isObject(source)) {
182
162
  for (const key in source) {
183
163
  if (isObject(source[key])) {
@@ -192,100 +172,77 @@ function merge(target) {
192
172
  }
193
173
  }
194
174
  }
195
-
196
175
  return merge(target, ...sources);
197
176
  }
198
-
199
177
  function cloneDeep(p) {
200
178
  if (p !== Object(p)) return p;
201
179
  var s = stringify(p);
202
180
  if (s === undefined) return;
203
181
  return parse(s);
204
182
  }
205
-
206
183
  function randomString(len) {
207
184
  var str = '';
208
185
  if (!len || len < 1) len = 10;
209
186
  var asciiKey;
210
-
211
187
  for (var i = 0; i < len; i++) {
212
188
  asciiKey = Math.floor(Math.random() * 25 + 97);
213
189
  str += String.fromCharCode(asciiKey);
214
190
  }
215
-
216
191
  return str;
217
192
  }
218
-
219
193
  function filter(collection, predicate) {
220
194
  if (!collection) return [];
221
195
  if (!predicate) return collection;
222
196
  var out = [];
223
-
224
197
  if (Array.isArray(collection)) {
225
198
  for (let i = 0; i < collection.length; i++) {
226
199
  if (predicate(collection[i], i)) out.push(collection[i]);
227
200
  }
228
-
229
201
  return out;
230
202
  }
231
-
232
203
  if (typeof collection === 'object') {
233
204
  var keys = Object.keys(collection);
234
-
235
205
  for (let i = 0; i < keys.length; i++) {
236
206
  var k = keys[i];
237
207
  if (predicate(collection[k], k)) out.push(collection[k]);
238
208
  }
239
-
240
209
  return out;
241
210
  }
242
-
243
211
  return out;
244
212
  }
245
-
246
213
  function includes(collection, value) {
247
214
  if (!collection) return false;
248
215
  var isString = typeof collection === 'string' || collection instanceof String;
249
216
  if (Array.isArray(collection) || isString) return collection.includes(value);
250
217
  return false;
251
218
  }
252
-
253
219
  function map(collection, predicate) {
254
220
  if (!collection) return [];
255
221
  if (!predicate) predicate = i => i;
256
222
  var out = [];
257
-
258
223
  if (Array.isArray(collection)) {
259
224
  for (let i = 0; i < collection.length; i++) {
260
225
  out.push(predicate(collection[i], i));
261
226
  }
262
-
263
227
  return out;
264
228
  }
265
-
266
229
  if (typeof collection === 'object') {
267
230
  var keys = Object.keys(collection);
268
-
269
231
  for (let i = 0; i < keys.length; i++) {
270
232
  var k = keys[i];
271
233
  out.push(predicate(collection[k], k));
272
234
  }
273
-
274
235
  return out;
275
236
  }
276
-
277
237
  return out;
278
238
  }
279
-
280
239
  function each(collection, predicate) {
281
240
  return map(collection, predicate);
282
241
  }
283
-
284
242
  function usersOfConvo(convo) {
285
243
  if (!convo) return [];
286
244
  return map(filter(convo.members, m => m.type === 'user'), m => m.id);
287
245
  }
288
-
289
246
  function isConvoSeen(convo, memberid) {
290
247
  if (convo.state === 'ended') return true;
291
248
  let lastmsgsent = convo.last_message_sent;
@@ -295,7 +252,6 @@ function isConvoSeen(convo, memberid) {
295
252
  if (!mem) return true;
296
253
  return getMs(lastmsgsent.created) < getMs(mem.seen_at);
297
254
  }
298
-
299
255
  function agentsOfConvo(convo, botIncluded) {
300
256
  if (!convo) return [];
301
257
  return map(filter(convo.members, m => {
@@ -303,30 +259,23 @@ function agentsOfConvo(convo, botIncluded) {
303
259
  return m.type === 'agent';
304
260
  }), m => m.id);
305
261
  }
306
-
307
262
  function startsWith(s, i) {
308
263
  return ((s || '') + '').startsWith(i);
309
264
  }
310
-
311
265
  function size(o) {
312
266
  if (!o) return 0;
313
267
  if (o.length !== undefined) return o.length;
314
268
  return Object.keys(o).length;
315
269
  }
316
-
317
270
  function replaceAll(str, a, b) {
318
271
  return (str || '').split(a).join(b);
319
272
  }
320
-
321
273
  function trim(s, suffix) {
322
274
  return ((s || '') + '').replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
323
275
  }
324
-
325
276
  function trimStart(s, prefix) {
326
277
  s = (s || '') + '';
327
-
328
278
  while (s.charAt(0) === prefix) s = s.substr(1);
329
-
330
279
  return s;
331
280
  }
332
281
 
@@ -335,67 +284,54 @@ function throttle(func, wait, options) {
335
284
  var timeout = null;
336
285
  var previous = 0;
337
286
  if (!options) options = {};
338
-
339
287
  var later = function () {
340
288
  previous = options.leading === false ? 0 : new Date().getTime();
341
289
  timeout = null;
342
290
  result = func.apply(context, args);
343
291
  if (!timeout) context = args = null;
344
292
  };
345
-
346
293
  return function () {
347
294
  var now = new Date().getTime();
348
295
  if (!previous && options.leading === false) previous = now;
349
296
  var remaining = wait - (now - previous);
350
297
  context = this;
351
298
  args = arguments;
352
-
353
299
  if (remaining <= 0 || remaining > wait) {
354
300
  if (timeout) {
355
301
  clearTimeout(timeout);
356
302
  timeout = null;
357
303
  }
358
-
359
304
  previous = now;
360
305
  result = func.apply(context, args);
361
306
  if (!timeout) context = args = null;
362
307
  } else if (!timeout && options.trailing !== false) {
363
308
  timeout = setTimeout(later, remaining);
364
309
  }
365
-
366
310
  return result;
367
311
  };
368
312
  }
369
-
370
313
  function find(collection, f) {
371
314
  if (!collection) return undefined;
372
315
  return collection[findIndex(collection, f)];
373
316
  }
374
-
375
317
  function findIndex(collection, f) {
376
318
  if (!collection) return -1;
377
319
  if (!f) return -1;
378
-
379
320
  if (Array.isArray(collection)) {
380
321
  for (let i = 0; i < collection.length; i++) {
381
322
  if (f(collection[i], i)) return i;
382
323
  }
383
-
384
324
  return -1;
385
325
  }
386
-
387
326
  if (typeof collection === 'object') {
388
327
  var keys = Object.keys(collection);
389
-
390
328
  for (let i = 0; i < keys.length; i++) {
391
329
  var k = keys[i];
392
330
  if (f(collection[k], k)) return k;
393
331
  }
394
332
  }
395
-
396
333
  return -1;
397
334
  }
398
-
399
335
  function orderBy(a, k, d) {
400
336
  var clone = [];
401
337
  each(a, v => clone.push(v));
@@ -406,58 +342,43 @@ function orderBy(a, k, d) {
406
342
  });
407
343
  return clone;
408
344
  }
409
-
410
- function getIntegrationId(accid) {
411
- return `${accid}.subizv4.subikon`;
412
- }
413
-
414
345
  function isPhone(phone) {
415
346
  var re = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im;
416
347
  return re.test(String(phone));
417
348
  }
418
-
419
349
  function isURL(url) {
420
350
  var re = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
421
351
  return re.test(String(url).toLowerCase());
422
352
  }
423
-
424
353
  function isNumber(num) {
425
354
  var re = /^\d+$/;
426
355
  return re.test(String(num));
427
356
  }
428
-
429
357
  function isEmail(email) {
430
358
  const re = /^(([^<>()[\]\\.,;:\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,}))$/;
431
359
  return re.test(String(email).toLowerCase());
432
360
  }
433
-
434
361
  function last(array) {
435
362
  var length = array == null ? 0 : array.length;
436
363
  return length ? array[length - 1] : undefined;
437
364
  }
438
-
439
365
  function getAgentDisplayName(account, agent) {
440
366
  return op.get(agent, 'fullname') || op.get(agent, 'email') || op.get(account, 'name') || 'Agent';
441
367
  }
442
-
443
368
  function isUserBanned(user) {
444
369
  return getUserAttr(user, 'is_ban', 'boolean');
445
370
  }
446
-
447
371
  function setUserAttr(user, attr) {
448
372
  if (!user) return;
449
373
  if (!op.get(attr, 'key')) return;
450
374
  user.attributes = user.attributes || [];
451
375
  var index = findIndex(user.attributes, a => a.key === attr.key);
452
-
453
376
  if (index === -1) {
454
377
  user.attributes.push(attr);
455
378
  return;
456
379
  }
457
-
458
380
  user.attributes[index] = attr;
459
381
  }
460
-
461
382
  function getUserAttr(user, key, type) {
462
383
  if (!user || !user.attributes) return;
463
384
  let value;
@@ -471,19 +392,15 @@ function getUserAttr(user, key, type) {
471
392
  });
472
393
  return value;
473
394
  }
474
-
475
395
  function norm(s) {
476
396
  s = s || '';
477
397
  return s.trim().toLowerCase();
478
398
  }
479
-
480
399
  function noop() {}
481
-
482
400
  function norm2(val) {
483
401
  if (typeof val === 'string' || val instanceof String) val = val.trim().replace(/;+$/, '');
484
402
  return val;
485
403
  }
486
-
487
404
  function replaceCssVariablePlugin(css, setting) {
488
405
  var tokens = [css];
489
406
  let spacer = setting.spacer || 10;
@@ -504,10 +421,8 @@ function replaceCssVariablePlugin(css, setting) {
504
421
  tokens = tokenize(tokens, "'@spacer2'");
505
422
  tokens = tokenize(tokens, "'@spacer3'");
506
423
  var ret = [];
507
-
508
424
  for (var i = 0; i < tokens.length; i++) {
509
425
  var item = tokens[i];
510
-
511
426
  if (typeof item === 'string') {
512
427
  ret.push(item);
513
428
  continue;
@@ -517,10 +432,8 @@ function replaceCssVariablePlugin(css, setting) {
517
432
  var val = op.get(setting, path) || op.get(DEFVAL, path) || '';
518
433
  ret.push(val);
519
434
  }
520
-
521
435
  return ret.join('');
522
436
  }
523
-
524
437
  function replaceCssVariable(css, setting) {
525
438
  var tokens = [css];
526
439
  tokens = tokenize(tokens, "'@primary_color'");
@@ -549,39 +462,32 @@ function replaceCssVariable(css, setting) {
549
462
  tokens = tokenize(tokens, "'@z_index_4'");
550
463
  tokens = tokenize(tokens, "'@z_index_5'");
551
464
  var ret = [];
552
-
553
465
  for (var i = 0; i < tokens.length; i++) {
554
466
  var item = tokens[i];
555
-
556
467
  if (typeof item === 'string') {
557
468
  ret.push(item);
558
469
  continue;
559
470
  }
560
-
561
471
  if (item.type === '@esc-primary-color-esc') {
562
472
  var val = op.get(setting, 'primary_color') || op.get(DEFVAL, 'primary_color');
563
473
  ret.push(encodeURIComponent(norm2(val)));
564
474
  continue;
565
475
  }
566
-
567
476
  if (item.type === "'@z_index_2'") {
568
477
  var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');
569
478
  ret.push(val + 2);
570
479
  continue;
571
480
  }
572
-
573
481
  if (item.type === "'@z_index_3'") {
574
482
  var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');
575
483
  ret.push(val + 3);
576
484
  continue;
577
485
  }
578
-
579
486
  if (item.type === "'@z_index_4'") {
580
487
  var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');
581
488
  ret.push(val + 4);
582
489
  continue;
583
490
  }
584
-
585
491
  if (item.type === "'@z_index_5'") {
586
492
  var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');
587
493
  ret.push(val + 5);
@@ -591,7 +497,6 @@ function replaceCssVariable(css, setting) {
591
497
  var path = item.type.substr(2, item.type.length - 3);
592
498
  var val = op.get(setting, path) || op.get(DEFVAL, path) || '';
593
499
  val = norm2(val);
594
-
595
500
  if (['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(path)) {
596
501
  val += 'px';
597
502
  }
@@ -600,43 +505,33 @@ function replaceCssVariable(css, setting) {
600
505
  ret.push('100%');
601
506
  continue;
602
507
  }
603
-
604
508
  ret.push(val);
605
509
  }
606
-
607
510
  return ret.join('');
608
511
  }
609
512
 
610
513
  function tokenize(arr, token) {
611
514
  if (!arr || !arr.length) return [];
612
515
  var out = [];
613
-
614
516
  for (let i = 0; i < arr.length; i++) {
615
517
  var item = arr[i];
616
-
617
518
  if (typeof item !== 'string') {
618
519
  out.push(item);
619
520
  continue;
620
521
  }
621
-
622
522
  var ts = item.split(token);
623
-
624
523
  for (let i = 0; i < ts.length; i++) {
625
524
  out.push(ts[i]);
626
525
  out.push({
627
526
  type: token
628
527
  });
629
528
  }
630
-
631
529
  out.pop();
632
530
  }
633
-
634
531
  return out;
635
532
  }
636
-
637
533
  function setCss(id, $css, css) {
638
534
  css = replaceAll(css, '#sbz92', '#' + id);
639
-
640
535
  if ($css.styleSheet) {
641
536
  $css.styleSheet.cssText = css;
642
537
  } else {
@@ -644,7 +539,6 @@ function setCss(id, $css, css) {
644
539
  $css.appendChild(document.createTextNode(css));
645
540
  }
646
541
  }
647
-
648
542
  const DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = 'https://file-subiz.com/bubble_11.svg';
649
543
  exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL;
650
544
  const DEFVAL = {
@@ -675,25 +569,25 @@ const DEFVAL = {
675
569
  z_index: 2000000000
676
570
  };
677
571
  exports.DEFVAL = DEFVAL;
678
-
679
572
  function js2css(js, onlyprops, variables) {
680
573
  var newjs = {};
681
-
682
574
  for (var prop in js) {
683
575
  if (!js.hasOwnProperty(prop)) continue;
576
+
684
577
  if (onlyprops && onlyprops.length > 0 && onlyprops.indexOf(prop) === -1) continue;
578
+
685
579
  if (typeof js[prop] === 'string') newjs[prop] = trim(js[prop]);else newjs[prop] = js[prop];
686
580
  }
687
-
688
581
  js = newjs;
689
582
  let style = '';
690
-
691
583
  for (var prop in js) {
692
584
  if (!js.hasOwnProperty(prop)) continue;
585
+
693
586
  var filter = '';
694
587
  if (js.blur) filter += 'blur(' + js.blur + ') ';
695
588
  if (js.grayscale) filter += 'grayscale(' + js + ') ';
696
589
  if (filter) style += 'filter: ' + filter + '!important;';
590
+
697
591
  if (js.rotate !== undefined) style += 'transform:rotate(' + js.rotate + ') !important;';
698
592
 
699
593
  if (js[prop] !== undefined) {
@@ -705,12 +599,11 @@ function js2css(js, onlyprops, variables) {
705
599
  if (prop === 'color') style += '-webkit-text-fill-color: ' + propval + ' !important;';
706
600
  }
707
601
  }
708
-
709
602
  return style;
710
603
  }
711
-
712
604
  function browserName() {
713
605
  var isOpera = !!window.opr && !!opr.addons || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
606
+
714
607
  var isFirefox = typeof InstallTrigger !== 'undefined';
715
608
 
716
609
  var isSafari = /constructor/i.test(window.HTMLElement) || function (p) {
@@ -718,10 +611,14 @@ function browserName() {
718
611
  }(!window['safari'] || typeof safari !== 'undefined' && window['safari'].pushNotification);
719
612
 
720
613
  var isIE = false || !!document.documentMode;
614
+
721
615
  var isEdge = !isIE && !!window.StyleMedia;
616
+
722
617
  var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);
723
618
  if (!isChrome) isChrome = navigator.userAgent.indexOf('Chrome');
619
+
724
620
  var isEdgeChromium = isChrome && navigator.userAgent.indexOf('Edg') != -1;
621
+
725
622
  var isBlink = (isChrome || isOpera) && !!window.CSS;
726
623
  if (isOpera) return 'opera';
727
624
  if (isFirefox) return 'firefox';
@@ -731,7 +628,6 @@ function browserName() {
731
628
  if (isBlink) return 'blink';
732
629
  return 'unknown';
733
630
  }
734
-
735
631
  function osName() {
736
632
  var OSName = 'Unknown';
737
633
  if (window.navigator.userAgent.indexOf('Windows NT 10.0') != -1) OSName = 'Windows 10';
@@ -750,31 +646,25 @@ function osName() {
750
646
  function check_frequently(freq, lastrun, store) {
751
647
  if (!lastrun) return true;
752
648
  if (op.get(freq, 'once_per_user')) return false;
753
-
754
649
  if (op.get(freq, 'once_per_session')) {
755
650
  if (sameDay(lastrun.created, Date.now())) return false;
756
651
  }
757
-
758
652
  if (op.get(freq, 'interval_sec')) {
759
653
  var sec = op.get(freq, 'interval_sec');
760
654
  if (sec > (Date.now() - lastrun.created) / 1000) return false;
761
655
  }
762
-
763
656
  return true;
764
657
  }
765
-
766
658
  function checkRunConditions(freq, conds, lastrun, store) {
767
659
  var acc = store.matchAccount() || {};
768
660
  var location = store.matchLocation() || {};
769
- if (!check_frequently(freq, lastrun, store)) return false;
770
661
 
662
+ if (!check_frequently(freq, lastrun, store)) return false;
771
663
  for (var i = 0; i < size(conds); i++) {
772
664
  var cond = conds[i];
773
-
774
665
  switch (cond.key) {
775
666
  case 'url':
776
667
  let exclude_urls = filter(cond.exclude_urls, url => norm(url));
777
-
778
668
  if (size(exclude_urls) > 0) {
779
669
  let found = find(exclude_urls, url => {
780
670
  return norm(window.location.href).indexOf(norm(url)) > -1;
@@ -783,88 +673,69 @@ function checkRunConditions(freq, conds, lastrun, store) {
783
673
  }
784
674
 
785
675
  let urls = filter(cond.urls, url => norm(url));
786
-
787
676
  if (size(urls) > 0) {
788
677
  let found = find(urls, url => {
789
678
  return norm(window.location.href).indexOf(norm(url)) > -1;
790
679
  });
791
680
  if (!found) return false;
792
681
  }
793
-
794
682
  break;
795
-
796
683
  case 'browser':
797
684
  if (size(cond.browsers) > 0) {
798
685
  var browsername = browserName();
799
686
  if (!find(cond.browsers, b => norm(b) === norm(browsername))) return false;
800
687
  }
801
-
802
688
  break;
803
-
804
689
  case 'location':
805
690
  if (size(cond.exclude_locations) > 0) {
806
691
  let found = find(cond.exclude_locations, loc => {
807
692
  if (loc.city_name && loc.country_code) {
808
693
  if (loc.city_name === location.city_name && loc.country_code === location.country_code) return true;
809
694
  }
810
-
811
695
  if (loc.city_name && !loc.country_code) {
812
696
  if (loc.city_name === location.city_name) return true;
813
697
  }
814
-
815
698
  if (!loc.city_name && loc.country_code) {
816
699
  if (loc.country_code === location.country_code) return true;
817
700
  }
818
701
  });
819
702
  if (found) return false;
820
703
  }
821
-
822
704
  if (size(cond.locations) > 0) {
823
705
  let found = find(cond.locations, loc => {
824
706
  if (loc.city_name && loc.country_code) {
825
707
  if (loc.city_name === location.city_name && loc.country_code === location.country_code) return true;
826
708
  }
827
-
828
709
  if (loc.city_name && !loc.country_code) {
829
710
  if (loc.city_name === location.city_name) return true;
830
711
  }
831
-
832
712
  if (!loc.city_name && loc.country_code) {
833
713
  if (loc.country_code === location.country_code) return true;
834
714
  }
835
715
  });
836
716
  if (!found) return false;
837
717
  }
838
-
839
718
  break;
840
-
841
719
  case 'returning_visitor':
842
720
  if (cond.returning_visitor) {
843
721
  if (store.new_visitor) return false;
844
722
  }
845
-
846
723
  if (!cond.returning_visitor) {
847
724
  if (!store.new_visitor) return false;
848
725
  }
849
-
850
726
  break;
851
-
852
727
  case 'user_is_a_contact':
853
728
  let attributes = op.get(store.matchUser(), 'attributes', []);
854
729
  let email = find(attributes, att => att.key === 'emails');
855
730
  let phone = find(attributes, att => att.key === 'phones');
856
731
  let hasContact = email || phone;
857
-
858
732
  if (cond.user_is_a_contact) {
859
733
  if (!hasContact) return false;
860
734
  }
861
-
862
735
  if (!cond.user_is_a_contact) {
863
736
  if (hasContact) return false;
864
737
  }
865
-
866
738
  break;
867
-
868
739
  case 'device_type':
869
740
  if (size(cond.device_types) > 0) {
870
741
  let type = 'desktop';
@@ -872,9 +743,7 @@ function checkRunConditions(freq, conds, lastrun, store) {
872
743
  if (store.isTablet()) type = 'tablet';
873
744
  if (!find(cond.device_types, t => norm(t) === norm(type))) return false;
874
745
  }
875
-
876
746
  break;
877
-
878
747
  case 'referer':
879
748
  if (size(cond.exclude_referers) > 0) {
880
749
  let found = find(cond.exclude_referers, ref => {
@@ -882,24 +751,19 @@ function checkRunConditions(freq, conds, lastrun, store) {
882
751
  });
883
752
  if (found) return false;
884
753
  }
885
-
886
754
  if (size(cond.urls) > 0) {
887
755
  let found = find(cond.referers, ref => {
888
756
  return norm(document.referrer).indexOf(norm(ref)) > -1;
889
757
  });
890
758
  if (!found) return false;
891
759
  }
892
-
893
760
  break;
894
-
895
761
  case 'source':
896
762
  if (size(cond.sources) > 0) {
897
763
  let source = store.matchTrafficSource() || 'direct';
898
764
  if (!find(cond.sources, src => norm(src) === norm(source))) return false;
899
765
  }
900
-
901
766
  break;
902
-
903
767
  case 'user_attribute':
904
768
  let userprop;
905
769
  let attrs = op.get(store.matchUser(), 'attributes', []);
@@ -909,7 +773,6 @@ function checkRunConditions(freq, conds, lastrun, store) {
909
773
  userprop = attr.datetime || attr.boolean || attr.number || attr.text || attr.list;
910
774
  });
911
775
  let valid = true;
912
-
913
776
  switch (operator) {
914
777
  case 'cons':
915
778
  let vals = parseJSON(cond.value) || [];
@@ -919,77 +782,60 @@ function checkRunConditions(freq, conds, lastrun, store) {
919
782
  });
920
783
  valid = !!found;
921
784
  break;
922
-
923
785
  case 'notEmpty':
924
786
  valid = !!userprop;
925
787
  break;
926
-
927
788
  case 'empty':
928
789
  valid = !userprop;
929
790
  break;
930
-
931
791
  case 'true':
932
792
  valid = userprop === true || userprop === 'true';
933
793
  break;
934
-
935
794
  case 'false':
936
795
  valid = !userprop || userprop === false || userprop === 'false';
937
796
  break;
938
797
  }
939
-
940
798
  if (!valid) return false;
941
799
  break;
942
-
943
800
  case 'timming':
944
801
  if (cond.business_hour === 'in' && !acc.is_in_business_hour) return false;
945
802
  if (cond.business_hour === 'notIn' && acc.is_in_business_hour) return false;
946
-
947
803
  if (size(cond.days_of_week) > 0) {
948
804
  let found = find(cond.days_of_week, day => {
949
805
  return norm(getDayName(new Date().getDay())) === norm(day);
950
806
  });
951
807
  if (!found) return false;
952
808
  }
953
-
954
809
  if (size(cond.minute_of_days) > 0 && size(cond.minute_of_days) % 2 === 0) {
955
810
  var now = new Date();
956
811
  var minuteofday = now.getMinutes() + now.getHours() * 60;
957
812
  let found = false;
958
-
959
813
  for (var i = 0; i < cond.minute_of_days.length; i += 2) {
960
814
  if (cond.minute_of_days[i] <= minuteofday && minuteofday <= cond.minute_of_days[i + 1]) {
961
815
  found = true;
962
816
  break;
963
817
  }
964
818
  }
965
-
966
819
  if (!found) return false;
967
820
  }
968
-
969
821
  break;
970
-
971
822
  case 'offline':
972
823
  if (!acc.is_online !== !!cond.offline) return false;
973
824
  }
974
825
  }
975
-
976
826
  return true;
977
827
  }
978
-
979
828
  function getDayName(dayOfWeek) {
980
829
  let days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
981
830
  return days[dayOfWeek];
982
831
  }
983
-
984
832
  let loadedFonts = {};
985
-
986
833
  function preloadWebfonts(fonts, done) {
987
834
  for (var i = 0; i < fonts.length; i++) {
988
835
  let font = fonts[i];
989
836
  if (!font) continue;
990
837
  if (loadedFonts[font]) continue;
991
838
  loadedFonts[font] = true;
992
-
993
839
  for (var w = 0; w < 2; w++) {
994
840
  let weight = [400, 500][w];
995
841
  let node = document.createElement('div');
@@ -1010,15 +856,12 @@ function preloadWebfonts(fonts, done) {
1010
856
  }
1011
857
  }
1012
858
  }
1013
-
1014
859
  function preloadImg(src, cb) {
1015
860
  if (!cb) cb = () => {};
1016
-
1017
861
  if (!src) {
1018
862
  cb();
1019
863
  return Promise.resolve(true);
1020
864
  }
1021
-
1022
865
  let image = new Image();
1023
866
  src = replaceFileUrl(src);
1024
867
  image.src = src;
@@ -1029,7 +872,6 @@ function preloadImg(src, cb) {
1029
872
  };
1030
873
  });
1031
874
  }
1032
-
1033
875
  function offsetToMin(offset) {
1034
876
  if (!offset) return 0;
1035
877
  if (offset.length <= 2) offset += ':00';
@@ -1041,7 +883,6 @@ function offsetToMin(offset) {
1041
883
  if (min < 0 || min > 59) return 0;
1042
884
  return hour * 60 + min;
1043
885
  }
1044
-
1045
886
  function diffDay(a, b, tzoffset) {
1046
887
  var offsetmin = -new Date().getTimezoneOffset();
1047
888
  if (tzoffset) offsetmin = offsetToMin(tzoffset);
@@ -1051,7 +892,6 @@ function diffDay(a, b, tzoffset) {
1051
892
  var bunixDay = Math.ceil((bms / 60 / 1000 + offsetmin) / 60 / 24);
1052
893
  return Math.abs(aunixDay - bunixDay);
1053
894
  }
1054
-
1055
895
  function diffYear(a, b, tzoffset) {
1056
896
  var machineoffsetmin = -new Date().getTimezoneOffset();
1057
897
  var offsetmin = -new Date().getTimezoneOffset();
@@ -1062,7 +902,6 @@ function diffYear(a, b, tzoffset) {
1062
902
  var bmsInZone = bms + (offsetmin - machineoffsetmin) * 60 * 1000;
1063
903
  return Math.abs(new Date(amsInZone).getYear() - new Date(bmsInZone).getYear());
1064
904
  }
1065
-
1066
905
  function sameDay(a, b, tzoffset) {
1067
906
  return diffDay(a, b, tzoffset) === 0;
1068
907
  }
@@ -1089,31 +928,29 @@ function shortTime(utcms, tzoffset, now) {
1089
928
  let tzdate = tztime.getDate();
1090
929
  if (tzhour < 10) tzhour = '0' + tzhour;
1091
930
  if (tzmin < 10) tzmin = '0' + tzmin;
931
+
1092
932
  if (sameDay(time, now, tzoffset)) return tzhour + ':' + tzmin;
933
+
1093
934
  if (diffDay(time, now, tzoffset) <= 5) return tzdddd + ', ' + tzhour + ':' + tzmin;
935
+
1094
936
  if (diffYear(time, now, tzoffset) === 0) return tzmonthname + ' ' + tzdate + ', ' + tzhour + ':' + tzmin;
937
+
1095
938
  return tzyear + '/' + tzmonth + '/' + tzdate + ', ' + tzhour + ':' + tzmin;
1096
939
  }
1097
-
1098
940
  function unixSec(t) {
1099
941
  return Math.floor(getMs(t) / 1000);
1100
942
  }
1101
-
1102
943
  function getMs(t) {
1103
944
  if (!t) t = 0;else if (typeof t !== 'number') t = new Date(t).getTime();
1104
-
1105
945
  if (t > 1e18) {
1106
946
  return Math.floor(t / 1e6);
1107
947
  }
1108
-
1109
948
  if (t > 1e15) {
1110
949
  return Math.floor(t / 1e3);
1111
950
  }
1112
-
1113
951
  if (t > 1e12) {
1114
952
  return t;
1115
953
  }
1116
-
1117
954
  return t * 1e3;
1118
955
  }
1119
956
 
@@ -1123,34 +960,27 @@ function detectLang() {
1123
960
  let browserlang = navigator.language;
1124
961
  return urllang || doclang || browserlang;
1125
962
  }
1126
-
1127
963
  function getUrlParameter() {
1128
964
  name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1129
965
  var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
1130
966
  var results = regex.exec(location.search);
1131
967
  return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
1132
968
  }
1133
-
1134
969
  var sleep = ms => new Promise(res => setTimeout(res, ms));
1135
-
1136
970
  exports.sleep = sleep;
1137
-
1138
971
  function formatCurrency(val) {
1139
972
  if (!val) return '0 đ';
1140
973
  val = Math.round(val);
1141
974
  return val.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') + ' đ';
1142
975
  }
1143
-
1144
976
  function replaceFileUrl(src) {
1145
977
  let fileurl = 'https://vcdn.subiz-cdn.com/file/';
1146
978
  if (!src) return '';
1147
979
  if (startsWith(src, '/')) return src;
1148
980
  if (startsWith(src, 'data:')) return src;
1149
-
1150
981
  if (!startsWith(src, 'http://') && !startsWith(src, 'https://') && !startsWith(src, '//')) {
1151
982
  src = trim(fileurl, '/') + '/' + trimStart(src, '/');
1152
983
  }
1153
-
1154
984
  src = src.replace('https://file-subiz.com/', fileurl);
1155
985
  src = src.replace('http://file-subiz.com/', fileurl);
1156
986
  src = src.replace('https://file-v4.subiz.com/', fileurl);
@@ -1165,13 +995,11 @@ function replaceFileUrl(src) {
1165
995
  src = src.replace('http://file.mysubiz.com/', fileurl);
1166
996
  return src;
1167
997
  }
1168
-
1169
998
  function unicodeToAscii(str) {
1170
999
  str = str + '';
1171
1000
  str = str.replace('đ', 'd').replace('Đ', 'D');
1172
1001
  return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
1173
1002
  }
1174
-
1175
1003
  function scrollIntoViewIfNeeded($ele) {
1176
1004
  centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
1177
1005
  var parent = $ele.parentNode;
@@ -1183,15 +1011,12 @@ function scrollIntoViewIfNeeded($ele) {
1183
1011
  var overLeft = $ele.offsetLeft - parent.offsetLeft < parent.scrollLeft;
1184
1012
  var overRight = $ele.offsetLeft - parent.offsetLeft + $ele.clientWidth - parentBorderLeftWidth > parent.scrollLeft + parent.clientWidth;
1185
1013
  var alignWithTop = overTop && !overBottom;
1186
-
1187
1014
  if ((overTop || overBottom) && centerIfNeeded) {
1188
1015
  parent.scrollTop = $ele.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + $ele.clientHeight / 2;
1189
1016
  }
1190
-
1191
1017
  if ((overLeft || overRight) && centerIfNeeded) {
1192
1018
  parent.scrollLeft = $ele.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + $ele.clientWidth / 2;
1193
1019
  }
1194
-
1195
1020
  if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
1196
1021
  $ele.scrollIntoView(alignWithTop);
1197
1022
  }