@subiz/widget-v4 4.1.198 → 4.1.200

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 (70) hide show
  1. package/assets/img/default_avatar.png +0 -0
  2. package/assets/img/default_logo.png +0 -0
  3. package/assets/img/default_logo.svg +5 -0
  4. package/assets/less/avatar.less +2 -2
  5. package/assets/less/message.less +6 -1
  6. package/assets/less/widget.less +1 -1
  7. package/assets/less/widget_header.less +2 -1
  8. package/compiled_src/bot.js +3 -18
  9. package/compiled_src/chatbox/Event.js +1 -1
  10. package/compiled_src/chatbox/Events.js +3 -1
  11. package/compiled_src/chatbox/Header.js +2 -2
  12. package/compiled_src/chatbox/QuickReplies.js +2 -1
  13. package/compiled_src/chatbox/Widget.js +2 -1
  14. package/compiled_src/lib.js +2 -1
  15. package/compiled_src/plugin.js +1 -0
  16. package/compiled_src/store/store.js +26 -18
  17. package/compiled_src/util/common.js +27 -14
  18. package/compiled_src/util/common.test.js +43 -133
  19. package/dist/132.js +21 -21
  20. package/dist/185.js +49 -49
  21. package/dist/{19bbfd5aa77.132.js → 19c2dd58182.132.js} +1 -1
  22. package/dist/19c2dd58182.185.js +1 -0
  23. package/dist/19c2dd58182.278.js +1 -0
  24. package/dist/19c2dd58182.339.js +1 -0
  25. package/dist/19c2dd58182.459.js +1 -0
  26. package/dist/19c2dd58182.app.js +1 -0
  27. package/dist/{19bbfd5aa77.chat.html → 19c2dd58182.chat.html} +1 -1
  28. package/dist/19c2dd58182.chat.js +1 -0
  29. package/dist/{19bbfd5aa77.form.html → 19c2dd58182.form.html} +1 -1
  30. package/dist/19c2dd58182.form.js +1 -0
  31. package/dist/{19bbfd5aa77.index.html → 19c2dd58182.index.html} +1 -1
  32. package/dist/{19bbfd5aa77.library.html → 19c2dd58182.library.html} +1 -1
  33. package/dist/19c2dd58182.library.js +1 -0
  34. package/dist/{19bbfd5aa77.preview.html → 19c2dd58182.preview.html} +1 -1
  35. package/dist/19c2dd58182.preview.js +1 -0
  36. package/dist/19c2dd58182.webview.js +1 -0
  37. package/dist/459.js +11 -11
  38. package/dist/74.js +1 -0
  39. package/dist/HASH +1 -1
  40. package/dist/assets/img/default_avatar.e449b04.png +0 -0
  41. package/dist/assets/img/default_logo.dd13a2b.svg +5 -0
  42. package/dist/screenshoot.js +3053 -3038
  43. package/package.json +13 -12
  44. package/src/bot.js +4 -14
  45. package/src/chatbox/Event.js +1 -1
  46. package/src/chatbox/Events.js +3 -2
  47. package/src/chatbox/Header.js +2 -2
  48. package/src/chatbox/QuickReplies.js +10 -10
  49. package/src/chatbox/Widget.js +3 -2
  50. package/src/lib.js +3 -1
  51. package/src/plugin.js +1 -0
  52. package/src/store/store.js +23 -13
  53. package/src/util/common.js +31 -16
  54. package/src/util/common.test.js +108 -193
  55. package/dist/19bbfd5aa77.185.js +0 -1
  56. package/dist/19bbfd5aa77.278.js +0 -1
  57. package/dist/19bbfd5aa77.339.js +0 -1
  58. package/dist/19bbfd5aa77.459.js +0 -1
  59. package/dist/19bbfd5aa77.app.js +0 -1
  60. package/dist/19bbfd5aa77.chat.js +0 -1
  61. package/dist/19bbfd5aa77.form.js +0 -1
  62. package/dist/19bbfd5aa77.library.js +0 -1
  63. package/dist/19bbfd5aa77.preview.js +0 -1
  64. package/dist/19bbfd5aa77.webview.js +0 -1
  65. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  66. /package/dist/{19bbfd5aa77.127.js → 19c2dd58182.127.js} +0 -0
  67. /package/dist/{19bbfd5aa77.27.js → 19c2dd58182.27.js} +0 -0
  68. /package/dist/{19bbfd5aa77.490.js → 19c2dd58182.490.js} +0 -0
  69. /package/dist/{19bbfd5aa77.74.js → 19c2dd58182.74.js} +0 -0
  70. /package/dist/{19bbfd5aa77.997.js → 19c2dd58182.997.js} +0 -0
@@ -1,157 +1,72 @@
1
+ import {createRequire} from 'module'
2
+ const require = createRequire(import.meta.url)
3
+ global.require = require
4
+ global.XMLHttpRequest = {
5
+ prototype: {
6
+ open: function () {},
7
+ },
8
+ }
9
+ global.document = {
10
+ JSON: JSON,
11
+ // document.documentElement.appendChild
12
+ // f.contentDocument.createElement
13
+ body: {
14
+ appendChild: function () {},
15
+ },
16
+ documentElement: {
17
+ appendChild: function () {},
18
+ },
19
+ createElement: function () {
20
+ return {
21
+ contentWindow: global,
22
+ contentDocument: global.document,
23
+ style: {display: false},
24
+ }
25
+ },
26
+ }
1
27
  const test = require('tape')
2
28
  const util = require('./common.js')
3
29
 
4
- test('util.getNotiDescription', t => {
30
+ test('util.checkUrlCondition', (t) => {
5
31
  var tcs = [
6
32
  {
7
- desc: 'not a message sent',
8
- event: { type: 'conversation_updated' },
9
- text: '',
10
- },
11
- {
12
- desc: 'an email',
13
- event: {
14
- type: 'message_sent',
15
- data: {
16
- message: {
17
- fields: [
18
- { key: 'from', value: '"thanh"' },
19
- { key: 'to', value: '"van"' },
20
- ],
21
- },
22
- },
23
- },
24
- text: 'sent an email',
25
- },
26
- { desc: 'empty msg', event: {}, text: '' },
27
- {
28
- desc: 'markdown',
29
- event: {
30
- type: 'message_sent',
31
- data: {
32
- message: {
33
- format: 'markdown',
34
- text: 'xin chao',
35
- },
36
- },
37
- },
38
- text: 'sent a message',
39
- },
40
- {
41
- desc: 'html',
42
- event: {
43
- type: 'message_sent',
44
- data: {
45
- message: {
46
- format: 'html',
47
- text: '<b>xin chao</b>',
48
- },
49
- },
50
- },
51
- text: 'sent a message',
52
- },
53
- {
54
- desc: 'multiple attachemnts',
55
- event: {
56
- type: 'message_sent',
57
- data: {
58
- message: {
59
- attachments: [{}, {}, {}],
60
- },
61
- },
62
- },
63
- text: 'sent a message with 3 attachments',
64
- },
65
- {
66
- desc: 'text with attachment',
67
- event: {
68
- type: 'message_sent',
69
- data: {
70
- message: {
71
- type: 'text',
72
- text: 'xin chao',
73
- attachments: [{}],
74
- },
75
- },
76
- },
77
- text: 'sent a message with 1 attachments',
78
- },
79
- {
80
- desc: '1 attachment no type',
81
- event: {
82
- type: 'message_sent',
83
- data: {
84
- message: {
85
- attachments: [{}],
86
- },
87
- },
88
- },
89
- text: 'sent an attachment',
90
- },
91
- {
92
- desc: 'audio ',
93
- event: {
94
- type: 'message_sent',
95
- data: {
96
- message: {
97
- attachments: [{ mimetype: 'audio/mp3' }],
98
- },
99
- },
100
- },
101
- text: 'sent an audio',
102
- },
103
- {
104
- desc: 'video',
105
- event: {
106
- type: 'message_sent',
107
- data: {
108
- message: {
109
- attachments: [{ mimetype: 'video/ogg' }],
110
- },
111
- },
112
- },
113
- text: 'sent a video',
114
- },
115
- {
116
- desc: 'image',
117
- event: {
118
- type: 'message_sent',
119
- data: {
120
- message: {
121
- attachments: [{ mimetype: 'image/jpeg' }],
122
- },
123
- },
33
+ name: 'minvoice',
34
+ cond: {
35
+ key: 'url',
36
+ urls: ['qlhd.minvoice.com.vn'],
37
+ exclude_urls: ['minvoice.com.vn', 'minvoice.net', 'hdt.minvoice.com.vn'],
124
38
  },
125
- text: 'sent a picture',
39
+ href: 'https://qlhd.minvoice.com.vn/#/login',
40
+ pass: true,
126
41
  },
127
42
  ]
128
43
 
129
- tcs.map(tc => {
44
+ tcs.map((tc) => {
130
45
  // if (tc.desc !== 'multiple attachemnts') return
131
- var out = util.getNotiDescription(tc.event)
132
- t.equal(out, tc.text)
46
+ var out = util.checkUrlCondition(tc.cond, tc.href)
47
+ t.equal(out, tc.pass)
133
48
  })
134
49
  t.end()
135
50
  })
136
51
 
137
- test('util.randomString', t => {
52
+ test('util.randomString', (t) => {
138
53
  t.equal(10, util.randomString(10).length)
139
54
  t.equal(11, util.randomString(11).length)
140
55
  t.equal(12, util.randomString(12).length)
141
56
  t.end()
142
57
  })
143
58
 
144
- test('convert message event first msg send', t => {
59
+ test('convert message event first msg send', (t) => {
145
60
  var events = [
146
- { by: { id: 1 }, type: 'message_sent', created: 1100 },
147
- { by: { id: 1 }, type: 'message_sent', created: 1200 },
148
- { by: { id: 1 }, type: 'message_sent', created: 1300 },
61
+ {by: {id: 1}, type: 'message_sent', created: 1100},
62
+ {by: {id: 1}, type: 'message_sent', created: 1200},
63
+ {by: {id: 1}, type: 'message_sent', created: 1300},
149
64
  ]
150
65
 
151
66
  var expect = [
152
- { by: { id: 1 }, type: 'message_sent', created: 1100, mode: 'lead', show_time: true },
153
- { by: { id: 1 }, type: 'message_sent', created: 1200, mode: 'follow', show_time: false },
154
- { by: { id: 1 }, type: 'message_sent', created: 1300, mode: 'follow', show_time: false },
67
+ {by: {id: 1}, type: 'message_sent', created: 1100, mode: 'lead', show_time: true},
68
+ {by: {id: 1}, type: 'message_sent', created: 1200, mode: 'follow', show_time: false},
69
+ {by: {id: 1}, type: 'message_sent', created: 1300, mode: 'follow', show_time: false},
155
70
  ]
156
71
 
157
72
  util.convertMessageEvent(events, 0)
@@ -162,33 +77,33 @@ test('convert message event first msg send', t => {
162
77
  t.end()
163
78
  })
164
79
 
165
- test('convert message event message tag', t => {
80
+ test('convert message event message tag', (t) => {
166
81
  var events = [
167
- { type: 'conversation_state_updated' },
168
- { type: 'conversation_tagged' },
169
- { type: 'conversation_tagged' },
170
- { type: 'conversation_tagged' },
171
- { type: 'conversation_state_updated' },
82
+ {type: 'conversation_state_updated'},
83
+ {type: 'conversation_tagged'},
84
+ {type: 'conversation_tagged'},
85
+ {type: 'conversation_tagged'},
86
+ {type: 'conversation_state_updated'},
172
87
  ]
173
88
 
174
89
  var expect = [
175
- { type: 'conversation_state_updated' },
176
- { type: 'conversation_tagged', mode: 'hide' },
177
- { type: 'conversation_tagged', mode: 'hide' },
178
- { type: 'conversation_tagged', mode: 'combine' },
179
- { type: 'conversation_state_updated' },
90
+ {type: 'conversation_state_updated'},
91
+ {type: 'conversation_tagged', mode: 'hide'},
92
+ {type: 'conversation_tagged', mode: 'hide'},
93
+ {type: 'conversation_tagged', mode: 'combine'},
94
+ {type: 'conversation_state_updated'},
180
95
  ]
181
96
 
182
97
  events.map((_, i) => util.convertMessageEvent(events, i))
183
98
 
184
99
  t.equal(JSON.stringify(events), JSON.stringify(expect))
185
100
 
186
- var events = [{ type: 'conversation_tagged' }, { type: 'conversation_tagged' }, { type: 'conversation_tagged' }]
101
+ var events = [{type: 'conversation_tagged'}, {type: 'conversation_tagged'}, {type: 'conversation_tagged'}]
187
102
 
188
103
  var expect = [
189
- { type: 'conversation_tagged', mode: 'hide' },
190
- { type: 'conversation_tagged', mode: 'hide' },
191
- { type: 'conversation_tagged', mode: 'combine' },
104
+ {type: 'conversation_tagged', mode: 'hide'},
105
+ {type: 'conversation_tagged', mode: 'hide'},
106
+ {type: 'conversation_tagged', mode: 'combine'},
192
107
  ]
193
108
 
194
109
  events.map((_, i) => util.convertMessageEvent(events, i))
@@ -196,25 +111,25 @@ test('convert message event message tag', t => {
196
111
  t.end()
197
112
  })
198
113
 
199
- test('convert message event message tag, msg_sent mixup', t => {
114
+ test('convert message event message tag, msg_sent mixup', (t) => {
200
115
  var events = [
201
- { type: 'conversation_state_updated' },
202
- { type: 'conversation_tagged' },
203
- { by: { id: 1 }, type: 'message_sent' },
204
- { by: { id: 2 }, type: 'message_sent' },
205
- { type: 'conversation_tagged' },
206
- { type: 'conversation_tagged' },
207
- { type: 'conversation_state_updated' },
116
+ {type: 'conversation_state_updated'},
117
+ {type: 'conversation_tagged'},
118
+ {by: {id: 1}, type: 'message_sent'},
119
+ {by: {id: 2}, type: 'message_sent'},
120
+ {type: 'conversation_tagged'},
121
+ {type: 'conversation_tagged'},
122
+ {type: 'conversation_state_updated'},
208
123
  ]
209
124
 
210
125
  var expect = [
211
- { type: 'conversation_state_updated' },
212
- { type: 'conversation_tagged', mode: 'combine' },
213
- { by: { id: 1 }, type: 'message_sent', mode: 'lead', show_time: false },
214
- { by: { id: 2 }, type: 'message_sent', mode: 'lead', show_time: false },
215
- { type: 'conversation_tagged', mode: 'hide' },
216
- { type: 'conversation_tagged', mode: 'combine' },
217
- { type: 'conversation_state_updated' },
126
+ {type: 'conversation_state_updated'},
127
+ {type: 'conversation_tagged', mode: 'combine'},
128
+ {by: {id: 1}, type: 'message_sent', mode: 'lead', show_time: false},
129
+ {by: {id: 2}, type: 'message_sent', mode: 'lead', show_time: false},
130
+ {type: 'conversation_tagged', mode: 'hide'},
131
+ {type: 'conversation_tagged', mode: 'combine'},
132
+ {type: 'conversation_state_updated'},
218
133
  ]
219
134
 
220
135
  events.map((_, i) => util.convertMessageEvent(events, i))
@@ -223,49 +138,49 @@ test('convert message event message tag, msg_sent mixup', t => {
223
138
  t.end()
224
139
  })
225
140
 
226
- test('test insert message', t => {
141
+ test('test insert message', (t) => {
227
142
  var events = [
228
- { type: 'conversation_state_updated' },
229
- { id: 1, type: 'conversation_tagged' },
230
- { by: { id: 1 }, type: 'message_sent' },
231
- { by: { id: 2 }, type: 'message_sent' },
232
- { type: 'conversation_tagged' },
233
- { type: 'conversation_tagged' },
234
- { type: 'conversation_state_updated' },
143
+ {type: 'conversation_state_updated'},
144
+ {id: 1, type: 'conversation_tagged'},
145
+ {by: {id: 1}, type: 'message_sent'},
146
+ {by: {id: 2}, type: 'message_sent'},
147
+ {type: 'conversation_tagged'},
148
+ {type: 'conversation_tagged'},
149
+ {type: 'conversation_state_updated'},
235
150
  ]
236
151
 
237
152
  events.map((_, i) => util.convertMessageEvent(events, i))
238
153
 
239
- events.splice(2, 0, { id: 2, type: 'conversation_tagged' })
154
+ events.splice(2, 0, {id: 2, type: 'conversation_tagged'})
240
155
  util.convertUpdatedOrDeletedMessageEvent(events, 2)
241
156
  var expect = [
242
- { type: 'conversation_state_updated' },
243
- { id: 1, type: 'conversation_tagged', mode: 'hide' },
244
- { id: 2, type: 'conversation_tagged', mode: 'combine' },
245
- { by: { id: 1 }, type: 'message_sent', mode: 'lead', show_time: false },
246
- { by: { id: 2 }, type: 'message_sent', mode: 'lead', show_time: false },
247
- { type: 'conversation_tagged', mode: 'hide' },
248
- { type: 'conversation_tagged', mode: 'combine' },
249
- { type: 'conversation_state_updated' },
157
+ {type: 'conversation_state_updated'},
158
+ {id: 1, type: 'conversation_tagged', mode: 'hide'},
159
+ {id: 2, type: 'conversation_tagged', mode: 'combine'},
160
+ {by: {id: 1}, type: 'message_sent', mode: 'lead', show_time: false},
161
+ {by: {id: 2}, type: 'message_sent', mode: 'lead', show_time: false},
162
+ {type: 'conversation_tagged', mode: 'hide'},
163
+ {type: 'conversation_tagged', mode: 'combine'},
164
+ {type: 'conversation_state_updated'},
250
165
  ]
251
166
 
252
167
  t.equal(JSON.stringify(events), JSON.stringify(expect))
253
168
  t.end()
254
169
  })
255
170
 
256
- test('mapizeDeep a map', t => {
171
+ test('mapizeDeep a map', (t) => {
257
172
  var topicM = {
258
- '0': {
173
+ 0: {
259
174
  topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxnairroppcktrg',
260
175
  read: false,
261
176
  updated: 1570586074000,
262
177
  },
263
- '1': {
178
+ 1: {
264
179
  topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxmkozwryrgjvag',
265
180
  read: false,
266
181
  updated: 1570551305000,
267
182
  },
268
- '2': {
183
+ 2: {
269
184
  topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlvkqgspihkfzsnm',
270
185
  read: false,
271
186
  updated: 1570289320000,
@@ -294,24 +209,24 @@ test('mapizeDeep a map', t => {
294
209
  t.end()
295
210
  })
296
211
 
297
- test('mapize a map', t => {
212
+ test('mapize a map', (t) => {
298
213
  var topicM = {
299
- '0': { topic: 't1', updated: 157 },
300
- '1': { topic: 't2', updated: 158 },
214
+ 0: {topic: 't1', updated: 157},
215
+ 1: {topic: 't2', updated: 158},
301
216
  }
302
217
 
303
218
  var out = util.mapize(topicM, 'topic')
304
- t.deepEqual(out, { t1: { topic: 't1', updated: 157 }, t2: { topic: 't2', updated: 158 } })
219
+ t.deepEqual(out, {t1: {topic: 't1', updated: 157}, t2: {topic: 't2', updated: 158}})
305
220
  t.end()
306
221
  })
307
222
 
308
- test('mapize', t => {
223
+ test('mapize', (t) => {
309
224
  var arr = [
310
- { id: 0, value: 0 },
311
- { id: 1, value: 1 },
312
- { id: 2, value: 2 },
313
- { id: 3, value: 3 },
314
- { id: 4, value: 4 },
225
+ {id: 0, value: 0},
226
+ {id: 1, value: 1},
227
+ {id: 2, value: 2},
228
+ {id: 3, value: 3},
229
+ {id: 4, value: 4},
315
230
  ]
316
231
  var m = util.mapize(arr, 'id')
317
232
  for (var i = 0; i < arr.length; i++) {
@@ -320,12 +235,12 @@ test('mapize', t => {
320
235
  t.end()
321
236
  })
322
237
 
323
- test('convo id from topic', t => {
238
+ test('convo id from topic', (t) => {
324
239
  t.equal('csqldpucwamyuaetjf', util.convoIdFromTopic('account.acqcsmrppbftadjzxnvo.conversation.csqldpucwamyuaetjf'))
325
240
  t.end()
326
241
  })
327
242
 
328
- test('user of convo', t => {
243
+ test('user of convo', (t) => {
329
244
  var convo = {
330
245
  id: 'csqlmhetrpccwprnms',
331
246
  account_id: 'acqcsmrppbftadjzxnvo',
@@ -1 +0,0 @@
1
- (self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[185],{185(t,e,s){t.exports=s.p+"assets/img/loader.37000a7.svg"},1113(t,e,s){t.exports=s.p+"assets/img/ghn.070f8e3.svg"},2523(t,e,s){t.exports=s.p+"assets/img/shop_faded.df7845a.svg"},3080(t,e,s){t.exports=s.p+"assets/img/x.26fdfa3.svg"},3142(t,e,s){t.exports=s.p+"assets/img/not_found_search.2ddb8d1.png"},4185(t,e,s){"use strict";s.r(e),s.d(e,{default:()=>b});var i=s(5922),r=s(2988),o=s(1620),n=s(2840),a=s(172),h=s(4188);function l(t,e,s){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var s=e.call(t,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class d extends n.Mw{constructor(t){super(t),l(this,"state",{show:!1,searchValue:""}),l(this,"filterRef",(0,a._3)()),l(this,"overlayRef",(0,a._3)()),l(this,"onTouchMove",t=>{t.target===this.overlayRef.current&&(t.preventDefault(),t.stopPropagation())}),l(this,"hideDropdown",()=>{this.setState({show:!1,searchValue:""})}),l(this,"onKeydown",t=>{if("Escape"===t.key){if(!this.state.show)return;this.state.searchValue?this.setState({searchValue:""}):this.hideDropdown(),t.preventDefault(),t.stopPropagation()}}),l(this,"hasSearch",()=>!!this.props.has_search||i.A.size(this.props.items)>=10),l(this,"getFilteredOptions",()=>{let t=this.props.items;return this.state.searchValue&&this.hasSearch()&&(t=i.A.filter(t,t=>{let e=i.A.unicodeToAscii(t.name).toLowerCase().replace(/ /g,""),s=i.A.unicodeToAscii(t.desc).toLowerCase().replace(/ /g,""),r=i.A.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g,"");return-1!=e.indexOf(r)||-1!=s.indexOf(r)})),t}),l(this,"onChangeSearchValue",t=>{this.setState({searchValue:t.target.value})}),l(this,"toogleDropdown",async()=>{await this.setState({show:!0,searchValue:""}),this.focusFilter()}),l(this,"onSelect",t=>{this.props.onSelect(t),this.hideDropdown()}),l(this,"onBackgroundScroll",t=>{console.log("EEEEEEE",t),alert("y")}),document.addEventListener("touchmove",function(t){})}componentDidMount(){window.addEventListener("keydown",this.onKeydown)}componentWillUnmount(){window.removeEventListener("keydown",this.onKeydown)}renderEmpty(){return(0,a.h)("div",{class:"dropdown_select_filter__empty"},(0,a.h)("img",{class:"dropdown_select_filter__empty_img",src:s(3142)}),(0,a.h)("div",{class:"muted",style:"text-align: center !important;"},"Không có kết quả"))}renderLoading(){return(0,a.h)("div",{class:"dropdown_select_filter__empty pt-3"},(0,a.h)(h.A,{size:"40",static:!0}),(0,a.h)("div",{class:"muted mt-2",style:"text-align: center !important;"},"Đang tải dữ liệu"))}focusFilter(){this.filterRef.current&&(this.filterRef.current.focus(),i.A.setTimeout(()=>{this.filterRef.current&&this.filterRef.current.focus()},100))}renderDropdown(){if(!this.state.show)return null;let t=this.getFilteredOptions(),e=i.A.map(t,t=>(0,a.h)("div",{class:"dropdown_select__item",onClick:e=>this.onSelect(t)},t.name)),r=null;if(this.hasSearch()){let t=(0,a.h)("img",{class:"dropdown_select_filter__icon",src:s(5452)});this.props.loading&&(t=(0,a.h)("img",{class:"dropdown_select_filter__icon",src:s(185)})),r=(0,a.h)("div",{class:"dropdown_select_filter"},t,(0,a.h)("input",{ref:this.filterRef,value:this.state.searchValue,onInput:this.onChangeSearchValue,type:"text",class:"dropdown_select_filter_input "}))}0==e.length&&(e=this.renderEmpty()),this.props.loading&&(e=this.renderLoading());let o=`width: ${this.props.width||"150px"} !important;`;return this.props.full?(o=" top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; ",(0,a.h)("div",{class:"dropdown_select__overlay",ref:this.overlayRef,onClick:this.hideDropdown,onTouchMove:this.onTouchMove},(0,a.h)("div",{class:"dropdown_select",style:o,onClick:t=>{t.preventDefault(),t.stopPropagation()}},r,(0,a.h)("div",{class:"dropdown_select__items"},e)))):(0,a.h)("div",{class:"dropdown_select",style:o},r,(0,a.h)("div",{class:"dropdown_select__items"},e))}render(){let t=(0,a.h)("div",{class:"muted text-truncate",style:"flex: 1 !important;"},"Chọn một phần tử");i.A.get(this.props,"selected.name")&&(t=(0,a.h)("div",{class:"text-truncate",style:"flex: 1 !important;"},i.A.get(this.props,"selected.name")));let e="position: relative !important;";return this.props.full&&(e=""),(0,a.h)("div",{style:e},(0,a.h)(n.tW,{onClickaway:this.hideDropdown},(0,a.h)("div",{type:"text",class:"dropdown_select_input "+this.props.extra_cls,onClick:this.toogleDropdown},t," ",(0,a.h)("img",{class:"dropdown_select__caret",src:s(7741)})),this.renderDropdown()))}}function p(t,e,s){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var s=e.call(t,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class c extends n.Mw{constructor(t){super(t),p(this,"state",{show:!1,searchValue:"",addresses:[]}),p(this,"filterRef",(0,a._3)()),p(this,"overlayRef",(0,a._3)()),p(this,"onTouchMove",t=>{t.target===this.overlayRef.current&&(t.preventDefault(),t.stopPropagation())}),p(this,"hideDropdown",()=>{this.setState({show:!1,searchValue:""})}),p(this,"onKeydown",t=>{if("Escape"===t.key){if(!this.state.show)return;this.state.searchValue?this.setState({searchValue:""}):this.hideDropdown(),t.preventDefault(),t.stopPropagation()}t.key}),p(this,"doSearch",i.A.throttle(async()=>{let t=Date.now();this.requestId=t;let e=await this.props.store.suggest_addresses(this.state.searchValue);this.requestId===t&&this.setState({addresses:i.A.get(e,"body.addresses",[])})},100)),p(this,"onChangeSearchValue",t=>{this.setState({searchValue:t.target.value}),this.props.onChangeAddress(t.target.value),this.doSearch()}),p(this,"toogleDropdown",async()=>{await this.setState({show:!0,searchValue:this.props.initAddress||""}),this.focusFilter()}),p(this,"onSelect",t=>{this.props.onSelect(t),this.hideDropdown()}),p(this,"onBackgroundScroll",t=>{console.log("EEEEEEE",t)}),document.addEventListener("touchmove",function(t){})}componentDidMount(){window.addEventListener("keydown",this.onKeydown)}componentWillUnmount(){window.removeEventListener("keydown",this.onKeydown)}renderEmpty(){return(0,a.h)("div",{class:"dropdown_select_filter__empty"},(0,a.h)("img",{class:"dropdown_select_filter__empty_img",src:s(3142)}),(0,a.h)("div",{class:"muted",style:"text-align: center !important;"},"Không có kết quả"))}renderLoading(){return(0,a.h)("div",{class:"dropdown_select_filter__empty pt-3"},(0,a.h)(h.A,{size:"40",static:!0}),(0,a.h)("div",{class:"muted mt-2",style:"text-align: center !important;"},"Đang tải dữ liệu"))}focusFilter(){this.filterRef.current&&(this.filterRef.current.focus(),i.A.setTimeout(()=>{this.filterRef.current&&this.filterRef.current.focus()},100))}renderDropdown(){if(!this.state.show)return null;let t=i.A.map(this.state.addresses,(t,e)=>{let s=[((t.address||"")+" "+u(t.street)).trim()].join(", "),i=[u(t.ward),u(t.district),u(t.province)].join(", ");return(0,a.h)("div",{class:"dropdown_select__item",onClick:e=>this.onSelect(t),key:e},(0,a.h)("div",null,(0,a.h)("b",null,s)),(0,a.h)("div",{style:"opacity: 0.7 !important;"},i))}),e=null,r=(0,a.h)("img",{class:"dropdown_select_filter__icon",src:s(5452)});this.props.loading&&(r=(0,a.h)("img",{class:"dropdown_select_filter__icon",src:s(185)})),e=(0,a.h)("div",{class:"dropdown_select_filter"},r,(0,a.h)("input",{ref:this.filterRef,value:this.state.searchValue,onInput:this.onChangeSearchValue,type:"text",class:"dropdown_select_filter_input "})),0==t.length&&(t=this.renderEmpty()),this.props.loading&&(t=this.renderLoading());let o=`width: ${this.props.width||"150px"} !important;`;return this.props.full?(o=" top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; ",(0,a.h)("div",{class:"dropdown_select__overlay",ref:this.overlayRef,onClick:this.hideDropdown,onTouchMove:this.onTouchMove},(0,a.h)("div",{class:"dropdown_select",style:o,onClick:t=>{t.preventDefault(),t.stopPropagation()}},e,(0,a.h)("div",{class:"dropdown_select__items"},t)))):(0,a.h)("div",{class:"dropdown_select",style:o},e,(0,a.h)("div",{class:"dropdown_select__items"},t))}render(){let t=(0,a.h)("div",{class:"text-truncate",style:"flex: 1 !important;"},this.props.initAddress),e="position: relative !important;";return this.props.full&&(e=""),(0,a.h)("div",{style:e},(0,a.h)(n.tW,{onClickaway:this.hideDropdown},(0,a.h)("div",{type:"text",class:"dropdown_select_input "+this.props.extra_cls,onClick:this.toogleDropdown},t),this.renderDropdown()))}}function u(t){let e=(t+"").toLowerCase();return e.startsWith("tp ")?t.substr(3):e.startsWith("thanh pho ")||e.startsWith("thành phố ")?t.substr(10):e.startsWith("tỉnh ")?t.substr(5):e.startsWith("huyện ")?t.substr(6):e.startsWith("tỉnh ")?t.substr(5):e.startsWith("xã ")?t.substr(3):e.startsWith("thị trấn ")?t.substr(9):e.startsWith("thị xã ")?t.substr(7):e.startsWith("đường ")&&(t[7]<"0"||t[7]>"9")?t.substr(6):e.startsWith("phường ")&&(t[7]<"0"||t[7]>"9")?t.substr(7):e.startsWith("quận ")&&(t[7]<"0"||t[7]>"9")?t.substr(5):t}Promise.resolve().then(s.bind(s,9278));var m=document.createElement("link");m.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap",m.rel="stylesheet",document.head.append(m),i.A.preloadWebfonts(["Inter"],[400,500]),s(2538);class g extends n.Mw{render(){return"package"==this.props.name?this.props.active?(0,a.h)("img",{style:"width: 18px !important;",src:s(8512)}):(0,a.h)("img",{style:"width: 18px !important;",src:s(6857)}):"shop"===this.props.name?this.props.active?(0,a.h)("img",{style:"width: 18px !important;",src:s(5244)}):(0,a.h)("img",{style:"width: 18px !important;",src:s(2523)}):void 0}}function _(t,e,s){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var s=e.call(t,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var v=s(5860),f=s(3080);class y extends n.Mw{constructor(t){super(t),_(this,"state",{loadProvince:!0,g_err:"",fullname:"",email:"",phone:"",loading:!0,order:{},err:{},shipping_address:"new",selectedProvince:null,selectedDistrict:null,selectedWard:null,street:"",address:"",sending:!1,step:""}),_(this,"renderMobileSuccess",t=>(0,a.h)("div",{class:"order",style:"height: 100% !important"},(0,a.h)("div",{style:"display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"},(0,a.h)("img",{style:"width: 60px !important; height: 60px !important;",width:"60",height:"60",src:v}),(0,a.h)("div",{style:"margin-top: 20px !important; margin-bottom: 10px !important"},(0,a.h)("b",{style:"font-size: 18px !important;"},"Đơn hàng của bạn đã được ghi nhận")),(0,a.h)("div",{class:"muted"},"Tôi sẽ liên hệ lại với bạn khi đơn hàng được xử lý"),(0,a.h)("div",{style:"flex:1 !important"}),(0,a.h)("div",{style:"margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"},(0,a.h)("div",{class:"order_btn order__btn__light",onClick:this.close},this.props.t("close")))))),_(this,"onSelectProvince",async t=>{this.setState({selectedProvince:t,err:{},g_err:""}),this.setState({loadDistrict:!0});let e=await this.props.store.list_districts({id:t.id});this.setState({loadDistrict:!1}),e.error||this.setState({districts:i.A.get(e,"body.addresses")})}),_(this,"onSelectDistrict",async t=>{this.setState({selectedDistrict:t,err:{},g_err:""}),this.setState({loadWard:!0});let e=await this.props.store.list_wards({id:t.id});this.setState({loadWard:!1}),e.error||this.setState({wards:i.A.get(e,"body.addresses")})}),_(this,"onSelectWard",t=>this.setState({selectedWard:t,err:{},g_err:""})),_(this,"onChangeFullname",t=>this.setState({fullname:t.target.value,err:{},g_err:""})),_(this,"onChangeAddress",t=>this.setState({address:t,err:{},g_err:""})),_(this,"onSelectAddress",t=>{t&&(this.setState({address:[i.A.trim(t.address),i.A.trim(t.street)].join(" ").trim(),street:t.street,err:{},g_err:""}),this.onSelectWard({id:t.ward_id,name:t.ward}),this.onSelectDistrict({id:t.district_id,name:t.district}),this.onSelectProvince({id:t.province_id,name:t.province}))}),_(this,"onChangeEmail",t=>this.setState({email:t.target.value,err:{},g_err:""})),_(this,"onChangePhone",t=>this.setState({phone:t.target.value,err:{},g_err:""})),_(this,"onChangePaymentMethod",t=>this.setState({pm:t})),_(this,"onChangeQuantity",(t,e)=>{let s=parseInt(e)||1;t.quantity=s,this.forceUpdate()}),_(this,"confirm",async()=>{this.setState({g_err:""});let t={};if(this.state.shipping||this.setState({g_err:"Mời bạn chọn địa chỉ giao hàng trước khi xác nhận"}),"shop"===this.state.shipping?(i.A.isPhone(this.state.phone)||(t.phone=!0),i.A.trim(this.state.fullname)||(t.name=!0),i.A.trim(this.state.email)||(t.email=!0)):"new"==this.state.shipping_address&&(i.A.isPhone(this.state.phone)||(t.phone=!0),i.A.trim(this.state.fullname)||(t.name=!0),i.A.trim(this.state.address)||(t.address=!0),0==i.A.size(this.state.selectedWard)&&(t.ward=!0),0==i.A.size(this.state.selectedDistrict)&&(t.district=!0),0==i.A.size(this.state.selectedProvince)&&(t.province=!0)),i.A.size(t)>0)return void this.setState({err:t,g_err:this.props.t("input_shipping_info_err")});let e=this.props.store.matchUser(),s=i.A.getUserAttr(e,"fullname","text"),r=i.A.getUserAttr(e,"emails","text"),o=i.A.getUserAttr(e,"phones","text"),n=i.A.cloneDeep(this.state.order);if("shop"===this.state.shipping)i.A.set(n,"shipping.pickup_at_shop",!0),i.A.set(n,"shipping.address.phone",this.state.phone),i.A.set(n,"shipping.address.fullname",this.state.fullname),i.A.set(n,"shipping.address.email",this.state.email);else if("new"==this.state.shipping_address){let t=await this.props.store.createShippingAddress({address:this.state.address,country:"Việt Nam",fullname:this.state.fullname,email:this.state.email,phone:this.state.phone,district:this.state.selectedDistrict.name,district_id:this.state.selectedDistrict.id,province:this.state.selectedProvince.name,province_id:this.state.selectedProvince.id,ward:this.state.selectedWard.name,street:this.state.street,ward_id:this.state.selectedWard.id});if(t.error)return this.setState({g_err:this.props.t("update_failed")});i.A.set(n,"shipping.address",t.body)}else{let e=this.props.store.matchShippingAddresses(),s=i.A.find(e,t=>t.id===this.state.shipping_address);if(!s)return this.setState({err:t,g_err:this.props.t("input_shipping_info_err")});i.A.set(n,"shipping.address",s)}let a=!1;!s&&this.state.fullname&&(a=!0,i.A.setUserAttr(e,{key:"fullname",text:this.state.fullname})),!r&&this.state.email&&(a=!0,i.A.setUserAttr(e,{key:"emails",text:this.state.email})),!o&&this.state.phone&&(a=!0,i.A.setUserAttr(e,{key:"phones",text:this.state.phone})),a&&this.props.store.setUser(e),this.setState({sending:!0}),n.user_confirmation="confirmed";let h=await this.props.store.updateOrder(n);if(this.setState({sending:!1}),h.error)return this.setState({g_err:this.props.t("update_failed")});this.setState({step:"success"}),this.props.onResponse&&this.props.onResponse("confirmed")}),_(this,"onCancel",()=>{if(this.props.onResponse&&this.props.onResponse("rejected"),this.props.cid&&!this.state.order.user_confirmation){let t=i.A.cloneDeep(this.state.order);t.user_confirmation="rejected",this.props.store.updateOrder(t)}this.close()}),_(this,"close",()=>{this.props.onClose&&this.props.onClose()}),this.load()}async load(){if(!this.props.order_id)return;let t=await this.props.store.fetchOrder(this.props.order_id);this.setState({loading:!1}),t.error?this.setState({error:t.error}):this.setState({order:t.body}),this.props.store.matchUser();let e=i.A.get(this.props.store.matchUser(),"attributes",[]),s=i.A.get(i.A.find(e,t=>"fullname"===t.key),"text"),r=i.A.get(i.A.find(e,t=>"emails"===t.key),"text"),o=i.A.get(i.A.find(e,t=>"phones"===t.key),"text");this.setState({fullname:s,email:r,phone:o}),await this.props.store.fetchShippingAddresses();let n=await this.props.store.list_provinces();this.setState({loadProvince:!1}),n.error||this.setState({provinces:i.A.get(n,"body.addresses")})}isMobile(){return!!this.props.cid||!!this.props.isMobile||this.props.store.isMobile()}onChangeShippingAddress(t){this.setState({shipping_address:t,err:{},g_err:""})}onChangeShipping(t){this.setState({shipping:t,err:{},g_err:""})}renderDesktopPaymentMethod(t){return null}renderDesktopShipping(t){let e=!1;if(t.status&&"open"!=t.status||(e=!t.user_confirmation),this.props.store.matchUser(),e){let t=this.props.store.matchShippingAddresses(),e=i.A.map(this.state.provinces,t=>({id:t.id,name:t.province})),s=i.A.map(this.state.districts,t=>({id:t.id,name:t.district})),r=i.A.map(this.state.wards,t=>({id:t.id,name:t.ward})),o="ship_card",n=null,h=!1;if("ship"===this.state.shipping){h=!0;let l=i.A.map(t,t=>{let e=[t.street,t.ward,t.district,t.region,t.country].filter(t=>t).join(", "),s=null;return t.phone&&(s=(0,a.h)(a.FK,null," · ",this.props.t("phn")," ",t.phone)),(0,a.h)("div",{style:"margin-bottom: 15px !important"},(0,a.h)("div",{class:"radio d-flex "},(0,a.h)("input",{type:"radio",id:"shipping_addr."+t.id,onInput:e=>this.onChangeShippingAddress(t.id),name:"shipping_address",checked:this.state.shipping_address===t.id}),(0,a.h)("label",{class:"radio--label",for:"shipping_addr."+t.id,style:`font-weight: ${this.state.shipping_address===t.id?500:400} !important`},t.fullname,s,(0,a.h)("div",{class:"mt-1 muted"},"DC ",e)),(0,a.h)("div",{class:"radio--check"},(0,a.h)("div",{class:"inside"}))))});l.push((0,a.h)("div",{style:""},(0,a.h)("div",{class:"radio d-flex "},(0,a.h)("input",{type:"radio",id:"shipping_addr.new",onInput:t=>this.onChangeShippingAddress("new"),name:"shipping_address",checked:"new"===this.state.shipping_address}),(0,a.h)("label",{class:"radio--label",for:"shipping_addr.new"},"new"===this.state.shipping_address?(0,a.h)("b",null,"Tới địa chỉ khác"):"Tới địa chỉ khác"),(0,a.h)("div",{class:"radio--check"},(0,a.h)("div",{class:"inside"})))));let p=(0,a.h)("div",{style:"padding-left: 22px !important;"},(0,a.h)("div",{class:"d-flex"},(0,a.h)("div",{class:"mr-2",style:"flex: 1 !important;"},(0,a.h)("div",{class:"order_form_label"},this.props.t("fullname")),(0,a.h)("input",{type:"text",class:"form-control "+(this.state.err.name&&"err"),onInput:this.onChangeFullname,value:this.state.fullname})),(0,a.h)("div",{class:"ml-2",style:"flex: 1 !important;"},(0,a.h)("div",{class:"order_form_label"},this.props.t("phones")),(0,a.h)("input",{type:"text",class:"form-control "+(this.state.err.phone&&"err"),onInput:this.onChangePhone,value:this.state.phone}))),(0,a.h)("div",{class:"",style:"width: 100% !important"},(0,a.h)("div",{class:"order_form_label"},this.props.t("address")),(0,a.h)(c,{initAddress:this.state.address,store:this.props.store,width:"100%",onChangeAddress:this.onChangeAddress,full:this.isMobile(),onSelect:this.onSelectAddress,extra_cls:this.state.err.address&&"err"})),(0,a.h)("div",{class:"d-flex",style:"justify-content: space-between !important;"},(0,a.h)("div",{style:"flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"},(0,a.h)("div",{class:"order_form_label"},this.props.t("province")),(0,a.h)(d,{width:"194",full:this.isMobile(),has_search:!0,loading:this.state.loadProvince,items:e,selected:this.state.selectedProvince,onSelect:this.onSelectProvince,extra_cls:this.state.err.province&&"err"})),(0,a.h)("div",{style:"flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"},(0,a.h)("div",{class:"order_form_label"},this.props.t("district")),(0,a.h)(d,{width:"194",full:this.isMobile(),selected:this.state.selectedDistrict,has_search:!0,onSelect:this.onSelectDistrict,loading:this.state.loadDistrict,extra_cls:this.state.err.district&&"err",items:s}))),(0,a.h)("div",{class:"d-flex",style:"justify-content: space-between !important;"},(0,a.h)("div",{style:"flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"},(0,a.h)("div",{class:"order_form_label"},this.props.t("ward")),(0,a.h)(d,{width:"194",selected:this.state.selectedWard,full:this.isMobile(),has_search:!0,onSelect:this.onSelectWard,extra_cls:this.state.err.ward&&"err",loading:this.state.loadWard,items:r})),(0,a.h)("div",{style:"flex: 1 !important; margin-left: 7px !important;"})));o+=" ship_card__active",0==i.A.size(t)?n=(0,a.h)("div",null,(0,a.h)("div",{class:"mt-3 mb-2 "},this.props.t("input_shipping_info")),p):("new"!==this.state.shipping_address&&(p=null),n=(0,a.h)("div",null,(0,a.h)("div",{class:"mt-3 mb-2",style:"margin-bottom: 10px !important;"},"Vui lòng chọn địa chỉ giao hàng"),(0,a.h)("div",{class:"form"},l),p))}let l="ship_card",p=!1;"shop"===this.state.shipping&&(p=!0,l+=" ship_card__active",n=(0,a.h)("div",null,(0,a.h)("div",{class:"d-flex"},(0,a.h)("div",{class:"mr-2",style:"flex: 3 !important;"},(0,a.h)("div",{class:"order_form_label"},this.props.t("fullname")),(0,a.h)("input",{type:"text",class:"form-control "+(this.state.err.name&&"err"),onInput:this.onChangeFullname,value:this.state.fullname})),(0,a.h)("div",{class:"ml-2",style:"flex: 2 !important;"},(0,a.h)("div",{class:"order_form_label"},this.props.t("phones")),(0,a.h)("input",{type:"text",class:"form-control "+(this.state.err.phone&&"err"),onInput:this.onChangePhone,value:this.state.phone}))),(0,a.h)("div",null,(0,a.h)("div",{class:"order_form_label"},this.props.t("email")),(0,a.h)("input",{type:"text",class:"form-control "+(this.state.err.email&&"err"),onInput:this.onChangeEmail,value:this.state.email}))));let u="card_section";return this.isMobile()&&(u="order_section"),(0,a.h)(a.FK,null,(0,a.h)("div",{class:"order_section__line"}),(0,a.h)("div",{class:u},(0,a.h)("div",{class:"order_label"},this.props.t("ship_to")),(0,a.h)("div",{class:"d-flex"},(0,a.h)("div",{class:l+" mr-3",onClick:t=>this.onChangeShipping("shop")},(0,a.h)(g,{name:"shop",active:p})," ",(0,a.h)("b",{class:"ml-2"},"Nhận hàng tại shop")),(0,a.h)("div",{class:o,onClick:t=>this.onChangeShipping("ship")},(0,a.h)(g,{name:"package",active:h})," ",(0,a.h)("b",{class:"ml-2"},"Giao hàng cho tôi"))),n))}let s=i.A.get(t,"shipping.address")||{},r=[s.address,s.ward,s.district,s.region,s.country].filter(t=>t).join(", "),o=null;s.phone&&(o=(0,a.h)("div",{class:"mt-1 muted"},this.props.t("phn"),": ",s.phone)),i.A.get(t,"shipping.pickup_at_shop")&&(r="Nhận hàng tại cửa hàng");let n=r?(0,a.h)("div",null,r):(0,a.h)("i",{class:"i muted"},"Chưa có địa chỉ giao hàng"),h="card_section";return this.isMobile()&&(h="order_section"),(0,a.h)("div",{class:h},(0,a.h)("div",{class:"order_label "},this.props.t("ship_to")),n,o)}renderDesktopSummary(t){let e=null;t.deposit>0&&(e=(0,a.h)("span",{class:"muted"},"(cọc ",i.A.formatCurrency(t.deposit),")"));let r=null;t.total_discount>0&&(r=(0,a.h)("div",{class:"order_summary_line"},(0,a.h)("div",null,"Giảm giá"),(0,a.h)("div",null,i.A.formatCurrency(t.total_discount))));let o=null;(e||t.payment_made)&&(o=(0,a.h)(a.FK,null,(0,a.h)("div",{class:"order_summary_line"},(0,a.h)("div",null,"Bạn đã trả"),(0,a.h)("div",null,e," ",i.A.formatCurrency(t.payment_made))),(0,a.h)("div",{class:"order_summary_line"},(0,a.h)("div",null,"Bạn chưa trả"),(0,a.h)("div",null,i.A.formatCurrency((t.total||0)-(t.payment_made||0))))));let n=(0,a.h)("div",{class:"order_summary_line"},(0,a.h)("div",null,"Tiền thuế"),(0,a.h)("div",null,i.A.formatCurrency(t.total_tax))),h=(0,a.h)("div",{class:"order_summary_line"},(0,a.h)("div",null,"Phí vận chuyển"),(0,a.h)("div",null,i.A.get(t,"shipping.fee",0)," d")),l=!1;t.status&&"open"!=t.status||(l=!t.user_confirmation);let d=null;l&&(h=null,n=null,d=(0,a.h)("div",{class:"muted"},(0,a.h)("img",{class:"order_ship_icon",src:s(7324)}),"  Chưa bao gồm thuế và phí vận chuyển"));let p="";return this.isMobile()&&(p="order_section"),(0,a.h)(a.FK,null,(0,a.h)("div",{class:"order_section__line"}),(0,a.h)("div",{class:p},(0,a.h)("div",{class:"order_label"},"Tóm tắt"),(0,a.h)("div",{class:"order_summary_line"},(0,a.h)("div",null,"Tổng tiền hàng"),(0,a.h)("div",null,i.A.formatCurrency(t.subtotal))),n,r,h,d,(0,a.h)("div",{class:"order_summary_line",style:"margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"},(0,a.h)("div",null,"Bạn phải trả"),(0,a.h)("div",{class:"order__total"},i.A.formatCurrency(t.total))),o))}renderStatusBadge(t){let e=t.status||"open";return(0,a.h)("div",{style:"float: right !important;",class:"order_status order_status__"+e},e)}renderShippingInfo(t){"open"!=t.status||t.user_confirmation;let e=i.A.get(t,"shipping.shipping_provider");if(!e)return null;let r=i.A.get(t,"shipping.shipping_code"),o=null;return r&&(o=(0,a.h)("div",{class:"muted",style:"margin-top: 3px !important"},"Vận đơn ",(0,a.h)("a",{class:"order_tracking_link",target:"_blank",href:"https://giaohangtietkiem.vn/tra-cuu-van-don/"+r},r," ",(0,a.h)("img",{class:"order_tracking_link_icon",src:s(3266)})))),"ghtk"==e?(0,a.h)("div",{class:"order_section"},(0,a.h)("div",{class:"order_section_label"},"Đơn vị vận chuyển"),(0,a.h)("div",{class:"d-flex align-items-center"},(0,a.h)("img",{class:"order_shipping_provider_logo",src:w.ghtk.logo}),(0,a.h)("div",null,w.ghtk.name,o))):null}renderDesktopShippingInfo(t){let e=i.A.get(t,"shipping.shipping_provider");if(!e)return null;let r=i.A.get(t,"shipping.shipping_code"),o=null;return r&&(o=(0,a.h)("div",{class:"muted",style:"margin-top: 3px !important"},"Vận đơn ",(0,a.h)("a",{class:"order_tracking_link",target:"_blank",href:"https://giaohangtietkiem.vn/tra-cuu-van-don/"+r},r," ",(0,a.h)("img",{class:"order_tracking_link_icon",src:s(3266)})))),"ghtk"==e?(0,a.h)(a.FK,null,(0,a.h)("div",{class:"order_label"},"Đơn vị vận chuyển"),(0,a.h)("div",{class:"d-flex align-items-center"},(0,a.h)("img",{class:"order_shipping_provider_logo",src:w.ghtk.logo}),(0,a.h)("div",null,w.ghtk.name,o))):null}renderProducts(t){let e=null;return e=i.A.map(t.items,t=>{if(!t||!t.product)return null;let e=t.product;return(0,a.h)("div",{class:"order_attachment__product"},(0,a.h)("img",{class:"order_attachment__product_img",alt:""+e.id,src:i.A.get(e,"images.0")||s(2876)}),(0,a.h)("div",{style:"overflow: hidden !important;"},(0,a.h)("div",{class:"order_attachment__product_name"},e.name),(0,a.h)("div",{class:"order_attachment__product_desc"},e.description||e.long_description),(0,a.h)("div",{class:"order_attachment__product_desc"},this.props.t("qty")," ",t.quantity," · ",i.A.formatCurrency(e.price))))}),this.isMobile()?(0,a.h)("div",{class:"order_section"},(0,a.h)("div",{class:"order_section_label"},this.props.t("product")),e):(0,a.h)("div",null,(0,a.h)("div",{class:"order_label"},this.props.t("product")),e)}renderDesktopProducts(t){let e=null,r=!1;return t.status&&"open"!=t.status||(r=!t.user_confirmation),e=r?i.A.map(t.items,t=>{if(!t||!t.product)return null;let e=t.product;return(0,a.h)("div",{class:"order_attachment__product"},(0,a.h)("img",{class:"order_attachment__product_img",alt:""+e.id,src:i.A.get(e,"images.0")||s(2876)}),(0,a.h)("div",{style:"overflow: hidden !important; flex: 1 !important"},(0,a.h)("div",{class:"order_attachment__product_name"},e.name),(0,a.h)("div",{class:"order_attachment__product_desc"},e.description||e.long_description),(0,a.h)("div",{class:"order_attachment__product_desc"},i.A.formatCurrency(e.price))),(0,a.h)("input",{class:"form-control",style:"text-align: center !important; font-weight: 400 !important; width: 50px !important",value:t.quantity,onInput:e=>this.onChangeQuantity(t,e.target.value),type:"text"}),(0,a.h)("div",{style:"width: 80px !important; text-align: right !important; "},(0,a.h)("b",null,i.A.formatCurrency(t.quantity*e.price))))}):i.A.map(t.items,t=>{if(!t||!t.product)return null;let e=t.product;return(0,a.h)("div",{class:"order_attachment__product"},(0,a.h)("img",{class:"order_attachment__product_img",alt:""+e.id,src:i.A.get(e,"images.0")||s(2876)}),(0,a.h)("div",{style:"overflow: hidden !important; flex: 1 !important"},(0,a.h)("div",{class:"order_attachment__product_name"},e.name),(0,a.h)("div",{class:"order_attachment__product_desc"},e.description||e.long_description),(0,a.h)("div",{class:"order_attachment__product_desc"},i.A.formatCurrency(e.price))),(0,a.h)("div",{style:"text-align: center !important; font-weight: 400 !important; width: 50px !important"},t.quantity),(0,a.h)("div",{style:"width: 80px !important; text-align: right !important; "},(0,a.h)("b",null,i.A.formatCurrency(t.total))))}),(0,a.h)("div",{class:"card_section"},(0,a.h)("div",{class:"desktop_order__heading"},this.renderStatusBadge(t),(0,a.h)("b",{style:"font-size: 18px !important;"},this.props.t("order")," #",t.order_number||t.id),(0,a.h)("div",{class:"muted"},(0,a.h)(o.A,{style:"font-size: 13px !important;",time:t.issue_date||t.created}))),(0,a.h)("div",{class:"order_label d-flex",style:"margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"},(0,a.h)("div",{style:"flex: 1 !important;"},this.props.t("product")),(0,a.h)("div",{style:"font-weight: 400 !important; text-align:center !important; width: 50px !important"},this.props.t("qty")),(0,a.h)("div",{style:"font-weight: 400 !important; text-align: right !important; width: 80px !important;"},this.props.t("total"))),e)}renderMobile(t){if("success"===this.state.step)return this.renderMobileSuccess(t);let e=null;this.state.g_err&&(e=(0,a.h)("div",{class:"mb-2 text__danger"},(0,a.h)("img",{style:"margin-top: -4px !important; height: 15px !important;",src:f})," ",(0,a.h)("b",null,this.state.g_err)));let s=(0,a.h)("div",null,e,(0,a.h)("div",{class:"btn-confirm-order",style:"margin-top: 0 !important;",onClick:this.confirm},this.props.t("confirm_order"))),i=(0,a.h)("div",{class:"order_btn order__btn__light mt-3",onClick:this.onCancel},this.props.t("cancel_order"));return(t.user_confirmation||"open"!=t.status)&&(s=null,this.props.cid&&(i=(0,a.h)("div",{class:"order_btn order__btn__light mt-3",onClick:this.close},this.props.t("close")))),(0,a.h)("div",{class:"order",style:"height: 100% !important"},(0,a.h)("div",{class:"order--content"},(0,a.h)("div",{class:"order--heading"},this.renderStatusBadge(t),(0,a.h)("b",{style:"font-size: 16px !important;"},this.props.t("order")," #",t.order_number||t.id),(0,a.h)("div",{class:"muted"},(0,a.h)(o.A,{style:"font-size: 13px !important;",time:t.issue_date||t.created}))),this.renderProducts(t),this.renderDesktopShipping(t),this.renderShippingInfo(t),this.renderDesktopPaymentMethod(t),this.renderDesktopSummary(t),(0,a.h)("div",{class:"order_section pb-3",style:"padding-top: 0 !important;"},s,i)))}renderActions(t){let e=null,s=!1;if(t.status&&"open"!=t.status||(s=!t.user_confirmation),"success"===this.state.step)return(0,a.h)("div",{class:"d-flex",style:"align-items: center !important; justify-content: flex-end !important"},(0,a.h)("div",null,"Ghi nhận thành công")," ",(0,a.h)("img",{style:"width: 16px !important; height: 16px !important;",width:"16",height:"16",src:v}));if(s){let t=null;this.state.g_err&&(t=(0,a.h)("div",{class:"mb-2 text__danger"},(0,a.h)("img",{style:"margin-top: -4px !important; height: 15px !important;",src:f})," ",(0,a.h)("b",null,this.state.g_err))),e=(0,a.h)("div",null,t,(0,a.h)("div",{class:"btn-confirm-order",onClick:this.confirm},this.props.t("confirm_order")),(0,a.h)("div",{class:"btn-cancel-order",onClick:this.onCancel},this.props.t("cancel_order")))}return e}renderDesktop(t){let e=this.props.store.matchAccount();var i=e.logo_url||s(3582);return(0,a.h)("div",{class:"desktop order"},(0,a.h)("div",{class:"order_acc_header"},(0,a.h)("img",{class:"order_acc_logo",src:i}),(0,a.h)("div",{class:"order_acc_name"},e.name)),(0,a.h)("div",{class:"desktop_order__content"},(0,a.h)("div",{style:"flex: 1 !important; padding-right: 20px !important;"},this.renderDesktopProducts(t),this.renderDesktopShipping(t),this.renderDesktopShippingInfo(t),this.renderDesktopPaymentMethod(t),(0,a.h)("div",{class:"order__footer"},(0,a.h)("a",{target:"_blank",href:"https://subiz.com.vn",class:"order__footer_link"},"Cung cấp bởi ",(0,a.h)("b",null,"Subiz")),(0,a.h)("div",{class:"order__footer_delimiter"}),(0,a.h)("a",{target:"_blank",href:"https://subiz.com.vn/vi/terms-of-service.html",class:"order__footer_link"},"Điều khoản"),(0,a.h)("a",{target:"_blank",href:"https://subiz.com.vn/vi/privacy-policy.html",class:"order__footer_link"},"Quyền riêng tư"))),(0,a.h)("div",null,(0,a.h)("div",{class:"order_recap"},this.renderDesktopSummary(t),this.renderActions(t)))))}render(){if(this.state.loading)return(0,a.h)("div",{class:"order_error"},(0,a.h)(h.A,{class:"mt-4",size:"60",static:!0}));if(this.state.error)return(0,a.h)("div",{class:"order_error"},(0,a.h)("img",{class:"mt-3",src:s(6907)}),(0,a.h)("div",{class:"mt-3"},this.props.t("order_load_error")));let t=this.state.order;return this.isMobile()?this.renderMobile(t):this.renderDesktop(t)}}let w={ghtk:{name:"Giao hàng tiết kiệm",logo:s(7362)},ghn:{name:"Giao hàng nhanh",logo:s(1113)}};function x(t,e,s){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var s=e.call(t,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}s(2538);class b extends n.Mw{constructor(t){super(t),x(this,"state",{hide:!0,ratingHeight:0,overlayOpacity:.3}),x(this,"onResponse",t=>{this.setState({response:t})}),x(this,"confirm",()=>{this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{format:"plaintext",text:"confirm",attachments:[{type:"postback",postback:{payload:JSON.stringify({type:"order_confirmation",status:"confirmed"})}}]}})}),x(this,"close",async()=>{if(await i.A.sleep(100),"confirmed"===this.state.response?this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{format:"plaintext",text:this.props.t("confirm_order"),attachments:[{type:"postback",postback:{payload:JSON.stringify({type:"order_confirmation",status:"confirmed"})}}]}}):"rejected"===this.state.response&&this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{format:"plaintext",text:this.props.t("cancel_order"),attachments:[{type:"postback",postback:{payload:JSON.stringify({type:"order_confirmation",status:"cancelled"})}}]}}),this.setState({response:""}),!this.state.hide&&this.refRating.current){var t=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),e=parseFloat(t.height);this.animation.play(20,e,t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)}),t<10&&(this.state.hide||this.setState({hide:!0}))}),this.props.onClose()}}),this.refRating=(0,a._3)(),this.refHandle=(0,a._3)()}componentDidMount(){this.mouseUp=t=>this.onMouseUp(t),this.mouseMove=t=>this.onMouseMove(t),this.mouseDown=t=>this.onMouseDown(t);var t=this.refHandle.current;t.addEventListener("mousedown",this.mouseDown,{passive:!0}),t.addEventListener("touchstart",this.mouseDown,{passive:!0}),window.addEventListener("mouseup",this.mouseUp,{passive:!0}),window.addEventListener("touchend",this.mouseUp,{passive:!0}),window.addEventListener("mousemove",this.mouseMove,{passive:!0}),window.addEventListener("touchmove",this.mouseMove,{passive:!0}),this.animation=new r.A({maxY:400,minY:0,duration:150}),this.close()}componentWillUnmount(){var t=this.refHandle.current;t.removeEventListener("mousedown",this.mouseDown,0),t.removeEventListener("touchstart",this.mouseDown,0),window.removeEventListener("mouseup",this.mouseUp,0),window.removeEventListener("touchend",this.mouseUp,0),window.removeEventListener("mousemove",this.mouseMove,0),window.removeEventListener("touchmove",this.mouseMove,0)}render(){this._show!=this.props.show&&(this._show=this.props.show,i.A.setTimeout(()=>{this._show?this.open():this.close()}));let t=this.state.hide?"d-none":"";return(0,a.h)("div",{class:t},(0,a.h)("div",{class:"extension--overlay",style:`opacity: ${.5*this.state.overlayOpacity} !important;`}),(0,a.h)("div",{class:"extension",ref:this.refRating,style:`height: ${this.state.ratingHeight}px !important;`},(0,a.h)("div",{class:"extension--close-btn",onClick:this.close},this.props.t("close")),(0,a.h)("div",{class:"extension--handle",ref:this.refHandle},(0,a.h)("div",{class:"extension--thumb"})),(0,a.h)("div",{style:"overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"},(0,a.h)(y,{key:this.props.order_id,store:this.props.store,onResponse:this.onResponse,onClose:this.close,t:this.props.t,order_id:this.props.order_id,cid:this.props.cid}))))}open(){if(this.state.hide&&this.props.order_id&&(this.setState({hide:!1}),this.refRating.current)){var t=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),e=parseFloat(t.height);this.animation.play(-20,e,t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)})})}}onMouseDown(t){this.mousePushed=!0,this.animation.stop(),t.preventDefault(),t.touches&&t.touches[0]&&(t=t.touches[0]),this.mousePushedDy=t.pageY-window.pageYOffset-this.refRating.current.getBoundingClientRect().y}onMouseUp(t){if(this.mousePushed){t.touches&&t.touches[0]&&(t=t.touches[0]),this.mousePushed=!1;var e=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),s=parseFloat(e.height);this.animation.play(this.mouseVelocity,s,t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)}),t<10&&(this.state.hide||(this.setState({hide:!0}),this.props.onRate&&this.props.onRate({no_rating:!0})))})}}onMouseMove(t){if(this.mousePushed){t.touches&&t.touches[0]&&(t=t.touches[0]);var e=t.pageY;this.mouseVelocity=e-this.lastMouseY,this.lastMouseY=e,e-=this.mousePushedDy;var s=this.refRating.current.getBoundingClientRect().bottom-e;s>400&&(s=500-1e4/(s+-300)),this.setState({ratingHeight:s,overlayOpacity:Math.min(1,(s-0)/500)})}}}},5244(t,e,s){t.exports=s.p+"assets/img/shop.f7dc7d8.svg"},5452(t,e,s){t.exports=s.p+"assets/img/search.f9705ff.svg"},5860(t,e,s){t.exports=s.p+"assets/img/done_green.b817fd4.svg"},6857(t,e,s){t.exports=s.p+"assets/img/package_fade.763c001.svg"},6907(t,e,s){t.exports=s.p+"assets/img/empty_1.0b98af0.svg"},7324(t,e,s){t.exports=s.p+"assets/img/info.ebce7ea.svg"},7362(t,e,s){t.exports=s.p+"assets/img/ghtk.326eac1.svg"},7741(t,e,s){t.exports=s.p+"assets/img/caret.998eb8f.svg"},8512(t,e,s){t.exports=s.p+"assets/img/package.8d37d0f.svg"}}]);