@subiz/widget-v4 4.0.61 → 4.0.63

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 (154) hide show
  1. package/assets/img/caret.svg +1 -0
  2. package/assets/img/done_green.svg +4 -0
  3. package/assets/img/empty_1.svg +11 -0
  4. package/assets/img/ghn.svg +17 -0
  5. package/assets/img/ghtk.svg +18 -0
  6. package/assets/img/home.svg +1 -0
  7. package/assets/img/info.svg +1 -0
  8. package/assets/img/loader.svg +1 -0
  9. package/assets/img/map-pin.svg +1 -0
  10. package/assets/img/not_found_search.png +0 -0
  11. package/assets/img/package.svg +5 -0
  12. package/assets/img/package_fade.svg +1 -0
  13. package/assets/img/phone.svg +1 -0
  14. package/assets/img/search.svg +1 -0
  15. package/assets/img/shop.svg +1 -0
  16. package/assets/img/shop_faded.svg +1 -0
  17. package/assets/img/user.svg +1 -0
  18. package/assets/img/x.svg +5 -0
  19. package/assets/less/chatbox.less +33 -0
  20. package/assets/less/dropdown_select.less +130 -0
  21. package/assets/less/form.less +7 -20
  22. package/assets/less/order.less +489 -0
  23. package/assets/less/rating.less +3 -8
  24. package/compiled_src/call/call.js +12 -15
  25. package/compiled_src/chatbox/DropdownSelect.js +239 -0
  26. package/compiled_src/chatbox/Event.js +4 -2
  27. package/compiled_src/chatbox/Events.js +1 -0
  28. package/compiled_src/chatbox/MessageInput.js +4 -7
  29. package/compiled_src/chatbox/Order.js +281 -0
  30. package/compiled_src/chatbox/OrderAttachments.js +2 -1
  31. package/compiled_src/chatbox/Rating.js +7 -10
  32. package/compiled_src/chatbox/TextMessage.js +9 -2
  33. package/compiled_src/chatbox/Widget.js +40 -3
  34. package/compiled_src/chatbox/spinner.js +1 -1
  35. package/compiled_src/chatbox/time.js +3 -1
  36. package/compiled_src/common.js +40 -1
  37. package/compiled_src/contact/contact.js +7 -12
  38. package/compiled_src/lib.js +9 -14
  39. package/compiled_src/notif/notif.js +12 -15
  40. package/compiled_src/order/address_picker.js +241 -0
  41. package/compiled_src/order/icon.js +62 -0
  42. package/compiled_src/order/index.js +113 -0
  43. package/compiled_src/order/order.js +1220 -0
  44. package/compiled_src/plugin.js +9 -42
  45. package/compiled_src/popup/countdown.js +4 -7
  46. package/compiled_src/popup/popup.js +9 -12
  47. package/compiled_src/store/api.js +80 -90
  48. package/compiled_src/store/api_fake.js +55 -82
  49. package/compiled_src/store/store.js +163 -158
  50. package/compiled_src/util/common.js +36 -2
  51. package/dist/0b82fa7e5c3b07b40a44.png +1 -0
  52. package/dist/0f4af006e38ee8b93633.png +1 -0
  53. package/dist/{74.js → 132.js} +2232 -235
  54. package/dist/178.js +341 -174
  55. package/dist/17e757ccadd.132.js +1 -0
  56. package/dist/17e757ccadd.178.js +1 -0
  57. package/dist/17e757ccadd.213.js +1 -0
  58. package/dist/17e757ccadd.335.js +1 -0
  59. package/dist/17e757ccadd.362.js +1 -0
  60. package/dist/17e757ccadd.441.js +1 -0
  61. package/dist/17e757ccadd.605.js +1 -0
  62. package/dist/17e757ccadd.678.js +1 -0
  63. package/dist/17e757ccadd.782.js +1 -0
  64. package/dist/17e757ccadd.app.js +1 -0
  65. package/dist/{17db8166252.index.html → 17e757ccadd.index.html} +1 -1
  66. package/dist/{17db8166252.library.html → 17e757ccadd.library.html} +1 -1
  67. package/dist/17e757ccadd.library.js +1 -0
  68. package/dist/{17db8166252.preview.html → 17e757ccadd.preview.html} +1 -1
  69. package/dist/17e757ccadd.preview.js +1 -0
  70. package/dist/17e757ccadd.screenshoot.js +1 -0
  71. package/dist/1ea1c6cd21d25176810c.png +1 -0
  72. package/dist/213.js +18 -88
  73. package/dist/292d42404e1b03398f61.png +1 -0
  74. package/dist/312d376370831b7bea83.png +1 -0
  75. package/dist/313d1bfc1cf776d1aefe.png +1 -0
  76. package/dist/335.js +408 -0
  77. package/dist/362.js +71 -21
  78. package/dist/441.js +69 -43
  79. package/dist/4aa58bb7a66bb44975aa.png +1 -0
  80. package/dist/56ce063bc6c81adb7322.png +1 -0
  81. package/dist/605.js +13 -79
  82. package/dist/678.js +70 -20
  83. package/dist/6a411166ef5cc79e0714.png +1 -0
  84. package/dist/6faf403782fefacc1649.png +1 -0
  85. package/dist/782.js +118 -21
  86. package/dist/79dca33c68fab79c067f.png +1 -0
  87. package/dist/82da1578fa84f9debaeb.png +1 -0
  88. package/dist/8b8e0f0824743974b282.png +1 -0
  89. package/dist/8d551390d81e39130a3c.png +1 -0
  90. package/dist/9fc61b9479877ebdb6c7.png +1 -0
  91. package/dist/HASH +1 -1
  92. package/dist/a165d31dcb3dc90f1057.png +1 -0
  93. package/dist/a98d4a5698812c4426b3.png +1 -0
  94. package/dist/assets/img/caret.998eb8f.svg +1 -0
  95. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  96. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  97. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  98. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  99. package/dist/assets/img/info.ebce7ea.svg +1 -0
  100. package/dist/assets/img/loader.37000a7.svg +1 -0
  101. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  102. package/dist/assets/img/package.8d37d0f.svg +5 -0
  103. package/dist/assets/img/package_fade.763c001.svg +1 -0
  104. package/dist/assets/img/search.f9705ff.svg +1 -0
  105. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  106. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  107. package/dist/assets/img/x.26fdfa3.svg +5 -0
  108. package/dist/c41606bf9d1b604e46d5.png +1 -0
  109. package/dist/ce1f7450ce6c1aacd330.png +1 -0
  110. package/dist/cf8c01e88f4770a6e3e5.png +1 -0
  111. package/dist/dfbcfeab1d5622a737e2.png +1 -0
  112. package/dist/e4893ed8c2f7b8329919.png +1 -0
  113. package/dist/ec2ab4eb4ef73d186186.png +1 -0
  114. package/dist/screenshoot.html +1 -1
  115. package/dist/screenshoot.js +448 -386
  116. package/order.html +19 -771
  117. package/package.json +12 -13
  118. package/src/chatbox/DropdownSelect.js +229 -0
  119. package/src/chatbox/Event.js +2 -2
  120. package/src/chatbox/Events.js +43 -42
  121. package/src/chatbox/Order.js +232 -0
  122. package/src/chatbox/OrderAttachments.js +2 -1
  123. package/src/chatbox/TextMessage.js +21 -12
  124. package/src/chatbox/Widget.js +34 -4
  125. package/src/chatbox/spinner.js +1 -1
  126. package/src/chatbox/time.js +1 -1
  127. package/src/common.js +52 -8
  128. package/src/contact/contact.js +1 -1
  129. package/src/order/address_picker.js +235 -0
  130. package/src/order/icon.js +32 -0
  131. package/src/order/index.js +86 -0
  132. package/src/order/order.js +1157 -0
  133. package/src/order/scratch +211 -0
  134. package/src/plugin.js +7 -52
  135. package/src/store/api.js +26 -1
  136. package/src/store/store.js +46 -9
  137. package/src/util/common.js +48 -2
  138. package/webpack.dev.js +2 -0
  139. package/dist/17db8166252.178.js +0 -1
  140. package/dist/17db8166252.213.js +0 -1
  141. package/dist/17db8166252.362.js +0 -1
  142. package/dist/17db8166252.441.js +0 -1
  143. package/dist/17db8166252.605.js +0 -1
  144. package/dist/17db8166252.619.js +0 -1
  145. package/dist/17db8166252.678.js +0 -1
  146. package/dist/17db8166252.74.js +0 -1
  147. package/dist/17db8166252.782.js +0 -1
  148. package/dist/17db8166252.app.js +0 -1
  149. package/dist/17db8166252.library.js +0 -1
  150. package/dist/17db8166252.preview.js +0 -1
  151. package/dist/17db8166252.screenshoot.js +0 -1
  152. package/dist/619.js +0 -777
  153. package/order.js +0 -0
  154. package/test.js +0 -1
@@ -17,8 +17,6 @@ var _realtime_fake = _interopRequireDefault(require("./realtime_fake.js"));
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
20
  var flow = require('@subiz/flow');
23
21
 
24
22
  var Realtime = require('@subiz/wsclient/index.js');
@@ -34,162 +32,6 @@ const page_loaded = _index.default.Date.now();
34
32
 
35
33
  class Store {
36
34
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fakeapi, agenttoken) {
37
- _defineProperty(this, "inmem", false);
38
-
39
- _defineProperty(this, "cookie", cookie);
40
-
41
- _defineProperty(this, "new_visitor", true);
42
-
43
- _defineProperty(this, "matchUser", () => {
44
- this._touchAcc();
45
-
46
- return this.kv.match('user');
47
- });
48
-
49
- _defineProperty(this, "matchSession", () => this.kv.match('session') || {});
50
-
51
- _defineProperty(this, "matchAccount", () => this.cache.match('account'));
52
-
53
- _defineProperty(this, "matchUnread", () => {
54
- let user = this.matchUser();
55
- let allconvos = this.matchConvo('*');
56
- let unreadcount = 0;
57
-
58
- _index.default.map(allconvos, convo => {
59
- if (!_index.default.isConvoSeen(convo, user.id)) unreadcount++;
60
- });
61
-
62
- return unreadcount;
63
- });
64
-
65
- _defineProperty(this, "matchPlugin", () => {
66
- if (_index.default.size(this.forcePlugins) > 0) return _index.default.cloneDeep(this.forcePlugins);
67
- return _index.default.cloneDeep(this.cache.match('plugin')) || {};
68
- });
69
-
70
- _defineProperty(this, "device", {});
71
-
72
- _defineProperty(this, "browserVisibility", 'visible');
73
-
74
- _defineProperty(this, "matchAgent", id => {
75
- let agentM = this.cache.match('agent') || {};
76
- if (id === '*') return agentM;
77
- return agentM[id];
78
- });
79
-
80
- _defineProperty(this, "matchConvo", id => {
81
- if (!id) return;
82
-
83
- if (id === '*') {
84
- this._touchAcc();
85
-
86
- return _index.default.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
87
- }
88
-
89
- if (!this.isInsync(id)) this.fetchConvo(id);
90
- return this.cache.match('convo_' + id);
91
- });
92
-
93
- _defineProperty(this, "fetchConvo", async cid => {
94
- await this.readyGate.entry();
95
- await this.reconnectGate.entry(undefined, true);
96
- if (this.isInsync(cid)) return this.reconnectGate.open();
97
- this.markSync(cid);
98
- let {
99
- body: convo,
100
- error
101
- } = await this.api.getConversation(cid);
102
- if (convo && !error) this._setConvo(convo);
103
- return this.reconnectGate.open();
104
- });
105
-
106
- _defineProperty(this, "listEvents", id => {
107
- if (!id || id === '*' || typeof id !== 'string') return;
108
-
109
- if (!this.isInsync('events' + id)) {
110
- setTimeout(async () => {
111
- await this.readyGate.entry();
112
- await this.reconnectGate.entry(undefined, true);
113
- if (this.isInsync('events' + id)) return this.reconnectGate.open();
114
- this.markSync('events' + id);
115
- await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
116
- this.pubsub.publish('account');
117
- return this.reconnectGate.open();
118
- }, 10);
119
- }
120
-
121
- return this.chain.listM(id);
122
- });
123
-
124
- _defineProperty(this, "fetchMoreEvents", async convoid => {
125
- let {
126
- error
127
- } = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
128
- this.pubsub.publish('account');
129
- return {
130
- error
131
- };
132
- });
133
-
134
- _defineProperty(this, "matchBot", () => this.cache.match('bot') || {});
135
-
136
- _defineProperty(this, "readyGate", new _index.default.Gate());
137
-
138
- _defineProperty(this, "convoGate", new _index.default.Gate(true));
139
-
140
- _defineProperty(this, "reconnectGate", new _index.default.Gate(true));
141
-
142
- _defineProperty(this, "matchLastview", () => this.kv.match('lastview') || {});
143
-
144
- _defineProperty(this, "matchIsOpen", () => !!this.kv.match('isopen'));
145
-
146
- _defineProperty(this, "matchHasManuallyClosed", () => !!this.kv.match('hasManuallyClosed'));
147
-
148
- _defineProperty(this, "matchClosePreviewAt", () => this.kv.match('close_preview_at') || 0);
149
-
150
- _defineProperty(this, "sendPresence", _index.default.throttle(async () => {
151
- await this.readyGate.entry();
152
- if (!_index.default.get(this.kv.match('user'), 'id')) return;
153
- if (_index.default.isUserBanned(this.kv.match('user'))) return;
154
- return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
155
- }, 1000));
156
-
157
- _defineProperty(this, "now", () => _index.default.Date.now() + this.timeDiff);
158
-
159
- _defineProperty(this, "seenQueue", []);
160
-
161
- _defineProperty(this, "_typing", _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000));
162
-
163
- _defineProperty(this, "onConvoEvent", (o, cb) => this.pubsub.on2(o, 'events', cb));
164
-
165
- _defineProperty(this, "seenConvo", id => {
166
- if (!id || id === 'create') return;
167
- this.seenQueue.push(id);
168
- });
169
-
170
- _defineProperty(this, "onUpdate", (o, cb) => this.pubsub.on2(o, 'account', cb));
171
-
172
- _defineProperty(this, "onResetCSS", (o, cb) => this.pubsub.on2(o, 'resetCSS', cb));
173
-
174
- _defineProperty(this, "onHighlight", (o, cb) => this.pubsub.on2(o, 'highlight', cb));
175
-
176
- _defineProperty(this, "setHasManuallyClosed", () => this.kv.put('hasManuallyClosed', true));
177
-
178
- _defineProperty(this, "setIsOpen", isopen => {
179
- let lastisopen = this.kv.match('isopen');
180
- this.kv.put('isopen', isopen);
181
- if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
182
- });
183
-
184
- _defineProperty(this, "closePreview", () => this.kv.put('close_preview_at', new _index.default.Date().getTime()));
185
-
186
- _defineProperty(this, "setLastview", (view, opts) => this.kv.put('lastview', {
187
- view,
188
- opts
189
- }));
190
-
191
- _defineProperty(this, "timeDiff", 0);
192
-
193
35
  this.agent_token = agenttoken;
194
36
  this.g_sync = {};
195
37
  this.forceDevice = null;
@@ -243,10 +85,31 @@ class Store {
243
85
  }, 2000);
244
86
  }
245
87
 
88
+ inmem = false;
89
+ cookie = cookie;
90
+
246
91
  isInsync(key) {
247
92
  return _index.default.Date.now() - (this.g_sync[key] || 0) < 300000;
248
93
  }
249
94
 
95
+ async fetchShippingAddresses() {
96
+ let out = await this.api.fetchShippingAddresses();
97
+ if (out.error) return null;
98
+ this.cache.put('shipping_address', out.body.shipping_addresses);
99
+ }
100
+
101
+ matchShippingAddresses() {
102
+ return this.cache.match('shipping_address');
103
+ }
104
+
105
+ updateOrder(order) {
106
+ return this.api.updateOrder(order);
107
+ }
108
+
109
+ createShippingAddress(addr) {
110
+ return this.api.createShippingAddress(addr);
111
+ }
112
+
250
113
  async overrideAcc(acc) {
251
114
  this.forceAcc = _index.default.cloneDeep(acc);
252
115
  await this.readyGate.entry();
@@ -325,12 +188,115 @@ class Store {
325
188
  this.g_sync[key] = _index.default.Date.now();
326
189
  }
327
190
 
191
+ new_visitor = true;
192
+
328
193
  async _touchAcc() {
329
194
  if (this.isInsync('account')) return;
330
195
  await this.readyGate.entry();
331
196
  if (!this.isInsync('account')) this.reconnect();
332
197
  }
333
198
 
199
+ matchUser = () => {
200
+ this._touchAcc();
201
+
202
+ return this.kv.match('user');
203
+ };
204
+ suggest_addresses = keyword => this.api.suggest_address(keyword);
205
+ matchSession = () => this.kv.match('session') || {};
206
+ matchAccount = () => this.cache.match('account');
207
+ matchPaymentMethods = () => this.cache.match('payment_methods');
208
+ matchUnread = () => {
209
+ let user = this.matchUser();
210
+ let allconvos = this.matchConvo('*');
211
+ let unreadcount = 0;
212
+
213
+ _index.default.map(allconvos, convo => {
214
+ if (!_index.default.isConvoSeen(convo, user.id)) unreadcount++;
215
+ });
216
+
217
+ return unreadcount;
218
+ };
219
+ matchPlugin = () => {
220
+ if (_index.default.size(this.forcePlugins) > 0) return _index.default.cloneDeep(this.forcePlugins);
221
+ return _index.default.cloneDeep(this.cache.match('plugin')) || {};
222
+ };
223
+ device = {};
224
+ browserVisibility = 'visible';
225
+ matchAgent = id => {
226
+ let agentM = this.cache.match('agent') || {};
227
+ if (id === '*') return agentM;
228
+ return agentM[id];
229
+ };
230
+ matchConvo = id => {
231
+ if (!id) return;
232
+
233
+ if (id === '*') {
234
+ this._touchAcc();
235
+
236
+ return _index.default.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
237
+ }
238
+
239
+ if (!this.isInsync(id)) this.fetchConvo(id);
240
+ return this.cache.match('convo_' + id);
241
+ };
242
+ fetchConvo = async cid => {
243
+ await this.readyGate.entry();
244
+ await this.reconnectGate.entry(undefined, true);
245
+ if (this.isInsync(cid)) return this.reconnectGate.open();
246
+ this.markSync(cid);
247
+ let {
248
+ body: convo,
249
+ error
250
+ } = await this.api.getConversation(cid);
251
+ if (convo && !error) this._setConvo(convo);
252
+ return this.reconnectGate.open();
253
+ };
254
+ list_provinces = () => this.api.list_provinces();
255
+ list_districts = p => this.api.list_districts(p);
256
+ list_wards = p => this.api.list_wards(p);
257
+ list_provices;
258
+ listEvents = id => {
259
+ if (!id || id === '*' || typeof id !== 'string') return;
260
+
261
+ if (!this.isInsync('events' + id)) {
262
+ setTimeout(async () => {
263
+ await this.readyGate.entry();
264
+ await this.reconnectGate.entry(undefined, true);
265
+ if (this.isInsync('events' + id)) return this.reconnectGate.open();
266
+ this.markSync('events' + id);
267
+ await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
268
+ this.pubsub.publish('account');
269
+ return this.reconnectGate.open();
270
+ }, 10);
271
+ }
272
+
273
+ return this.chain.listM(id);
274
+ };
275
+ fetchMoreEvents = async convoid => {
276
+ let {
277
+ error
278
+ } = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
279
+ this.pubsub.publish('account');
280
+ return {
281
+ error
282
+ };
283
+ };
284
+ matchBot = () => this.cache.match('bot') || {};
285
+ readyGate = new _index.default.Gate();
286
+ convoGate = new _index.default.Gate(true);
287
+ reconnectGate = new _index.default.Gate(true);
288
+ matchLastview = () => this.kv.match('lastview') || {};
289
+ matchIsOpen = () => !!this.kv.match('isopen');
290
+ matchHasManuallyClosed = () => !!this.kv.match('hasManuallyClosed');
291
+ matchClosePreviewAt = () => this.kv.match('close_preview_at') || 0;
292
+ sendPresence = _index.default.throttle(async () => {
293
+ await this.readyGate.entry();
294
+ if (!_index.default.get(this.kv.match('user'), 'id')) return;
295
+ if (_index.default.isUserBanned(this.kv.match('user'))) return;
296
+ return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
297
+ }, 1000);
298
+ now = () => _index.default.Date.now() + this.timeDiff;
299
+
334
300
  async init(accid, mask) {
335
301
  this.readyGate.close();
336
302
  accid = (accid || '').trim();
@@ -389,6 +355,8 @@ class Store {
389
355
  return mask;
390
356
  }
391
357
 
358
+ seenQueue = [];
359
+
392
360
  seenLoop() {
393
361
  this.seenQueue = [];
394
362
  clearInterval(this._seenInterval);
@@ -470,6 +438,7 @@ class Store {
470
438
  }
471
439
 
472
440
  _setUser(user) {
441
+ user = _index.default.cloneDeep(user);
473
442
  let olduser = this.kv.match('user') || {};
474
443
  var accid = olduser.account_id || user.account_id;
475
444
  var id = olduser.id || user.id;
@@ -573,6 +542,9 @@ class Store {
573
542
  this.cache.put('agent', agentM);
574
543
  }
575
544
 
545
+ let pms = _index.default.get(setting, 'payment_methods', []);
546
+
547
+ this.cache.put('payment_methods', pms);
576
548
  this.pubsub.publish('account');
577
549
  }
578
550
 
@@ -775,6 +747,8 @@ class Store {
775
747
  this._typing(cid);
776
748
  }
777
749
 
750
+ _typing = _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000);
751
+
778
752
  async startConvo(req) {
779
753
  await this.readyGate.entry();
780
754
  this.convoGate.close();
@@ -795,6 +769,14 @@ class Store {
795
769
  };
796
770
  }
797
771
 
772
+ fetchOrder(id) {
773
+ return this.api.getOrder(id);
774
+ }
775
+
776
+ lookupOrder(key) {
777
+ return this.api.lookupOrder(key);
778
+ }
779
+
798
780
  createPostback(cid, postback) {
799
781
  return this.api.createPostback(cid, postback);
800
782
  }
@@ -864,6 +846,12 @@ class Store {
864
846
  sendEventToThirdParty('SUBIZ Chat', 'Sent', 'User');
865
847
  }
866
848
 
849
+ onConvoEvent = (o, cb) => this.pubsub.on2(o, 'events', cb);
850
+ seenConvo = id => {
851
+ if (!id || id === 'create') return;
852
+ this.seenQueue.push(id);
853
+ };
854
+
867
855
  _setConvo(convo) {
868
856
  let count = 0;
869
857
  let user = this.kv.match('user');
@@ -895,6 +883,21 @@ class Store {
895
883
  this.cache.put('convo_' + convo.id, convo);
896
884
  }
897
885
 
886
+ onUpdate = (o, cb) => this.pubsub.on2(o, 'account', cb);
887
+ onResetCSS = (o, cb) => this.pubsub.on2(o, 'resetCSS', cb);
888
+ onHighlight = (o, cb) => this.pubsub.on2(o, 'highlight', cb);
889
+ setHasManuallyClosed = () => this.kv.put('hasManuallyClosed', true);
890
+ setIsOpen = isopen => {
891
+ let lastisopen = this.kv.match('isopen');
892
+ this.kv.put('isopen', isopen);
893
+ if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
894
+ };
895
+ closePreview = () => this.kv.put('close_preview_at', new _index.default.Date().getTime());
896
+ setLastview = (view, opts) => this.kv.put('lastview', {
897
+ view,
898
+ opts
899
+ });
900
+
898
901
  matchLastPluginRun(pluginid) {
899
902
  let log = this.kv.match('plugin_run_logs') || {};
900
903
  return log[pluginid];
@@ -999,6 +1002,8 @@ class Store {
999
1002
  return [events, anchor];
1000
1003
  }
1001
1004
 
1005
+ timeDiff = 0;
1006
+
1002
1007
  async loopTime() {
1003
1008
  let startms = _index.default.Date.now();
1004
1009
 
@@ -47,6 +47,7 @@ exports.replaceCssVariable = replaceCssVariable;
47
47
  exports.replaceCssVariablePlugin = replaceCssVariablePlugin;
48
48
  exports.requestAnimationFrame = void 0;
49
49
  exports.sameDay = sameDay;
50
+ exports.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
50
51
  exports.setCss = setCss;
51
52
  exports.setInterval = void 0;
52
53
  exports.setMsgField = setMsgField;
@@ -61,6 +62,7 @@ exports.throttle = throttle;
61
62
  exports.tokenize = tokenize;
62
63
  exports.trim = trim;
63
64
  exports.trimStart = trimStart;
65
+ exports.unicodeToAscii = unicodeToAscii;
64
66
  exports.unixSec = unixSec;
65
67
  exports.usersOfConvo = usersOfConvo;
66
68
 
@@ -998,6 +1000,7 @@ function preloadWebfonts(fonts, done) {
998
1000
  node.style.color = 'transparent';
999
1001
  node.style.fontSize = '20px';
1000
1002
  node.style.height = '0px';
1003
+ node.style.top = '0px';
1001
1004
  node.style.width = '0px';
1002
1005
  node.style.fontWeight = weight;
1003
1006
  node.setAttribute('subiz-preload', font + ':' + weight);
@@ -1133,9 +1136,9 @@ var sleep = ms => new Promise(res => setTimeout(res, ms));
1133
1136
  exports.sleep = sleep;
1134
1137
 
1135
1138
  function formatCurrency(val) {
1136
- if (!val) return 0;
1139
+ if (!val) return '0 đ';
1137
1140
  val = Math.round(val);
1138
- return val.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
1141
+ return val.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') + ' đ';
1139
1142
  }
1140
1143
 
1141
1144
  function replaceFileUrl(src) {
@@ -1161,4 +1164,35 @@ function replaceFileUrl(src) {
1161
1164
  src = src.replace('https://file.mysubiz.com/', fileurl);
1162
1165
  src = src.replace('http://file.mysubiz.com/', fileurl);
1163
1166
  return src;
1167
+ }
1168
+
1169
+ function unicodeToAscii(str) {
1170
+ str = str + '';
1171
+ str = str.replace('đ', 'd').replace('Đ', 'D');
1172
+ return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
1173
+ }
1174
+
1175
+ function scrollIntoViewIfNeeded($ele) {
1176
+ centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
1177
+ var parent = $ele.parentNode;
1178
+ var parentComputedStyle = window.getComputedStyle(parent, null);
1179
+ var parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'));
1180
+ var parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width'));
1181
+ var overTop = $ele.offsetTop - parent.offsetTop < parent.scrollTop;
1182
+ var overBottom = $ele.offsetTop - parent.offsetTop + $ele.clientHeight - parentBorderTopWidth > parent.scrollTop + parent.clientHeight;
1183
+ var overLeft = $ele.offsetLeft - parent.offsetLeft < parent.scrollLeft;
1184
+ var overRight = $ele.offsetLeft - parent.offsetLeft + $ele.clientWidth - parentBorderLeftWidth > parent.scrollLeft + parent.clientWidth;
1185
+ var alignWithTop = overTop && !overBottom;
1186
+
1187
+ if ((overTop || overBottom) && centerIfNeeded) {
1188
+ parent.scrollTop = $ele.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + $ele.clientHeight / 2;
1189
+ }
1190
+
1191
+ if ((overLeft || overRight) && centerIfNeeded) {
1192
+ parent.scrollLeft = $ele.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + $ele.clientWidth / 2;
1193
+ }
1194
+
1195
+ if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
1196
+ $ele.scrollIntoView(alignWithTop);
1197
+ }
1164
1198
  }
@@ -0,0 +1 @@
1
+ module.exports = __webpack_public_path__ + "assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png";
@@ -0,0 +1 @@
1
+ module.exports = __webpack_public_path__ + "assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png";