crmbonus-component-wake 2.1.34 → 2.1.36-homolog

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 (196) hide show
  1. package/dist/cjs/app-modal.cjs.entry.js +1 -1
  2. package/dist/cjs/{cart.helper-701ea6b2.js → cart.helper-abdd9916.js} +3 -3
  3. package/dist/cjs/{cart.helper-701ea6b2.js.map → cart.helper-abdd9916.js.map} +1 -1
  4. package/dist/cjs/container-empty.cjs.entry.js +19 -0
  5. package/dist/cjs/container-empty.cjs.entry.js.map +1 -0
  6. package/dist/cjs/countdown-timer_11.cjs.entry.js +979 -0
  7. package/dist/cjs/countdown-timer_11.cjs.entry.js.map +1 -0
  8. package/dist/cjs/crm-bonus-note.cjs.entry.js +44 -69
  9. package/dist/cjs/crm-bonus-note.cjs.entry.js.map +1 -1
  10. package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
  11. package/dist/cjs/{i18n-1ce6cb94.js → info.config.helper-d4b1291b.js} +14 -1
  12. package/dist/cjs/info.config.helper-d4b1291b.js.map +1 -0
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/pedido-finalizado.cjs.entry.js +2 -2
  15. package/dist/collection/collection-manifest.json +2 -3
  16. package/dist/collection/components/crm-bonus/crm-bonus.js +13 -15
  17. package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
  18. package/dist/collection/components/giftback-form/giftback-form.js +10 -12
  19. package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
  20. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js +5 -5
  21. package/dist/collection/components/giftback-form/subcomponents/phone-form/phone-form.js +1 -1
  22. package/dist/collection/components/giftback-form/subcomponents/pin-form/pin-form.js +1 -1
  23. package/dist/collection/components/loading-container/container-empty.js +9 -0
  24. package/dist/collection/components/loading-container/container-empty.js.map +1 -0
  25. package/dist/collection/components/loading-container/loading-container.css +9 -2
  26. package/dist/collection/components/loading-container/loading-container.js +20 -1
  27. package/dist/collection/components/loading-container/loading-container.js.map +1 -1
  28. package/dist/collection/components/loading-spinner/loading-spinner.js +1 -1
  29. package/dist/collection/components/modal/app-modal.js +1 -1
  30. package/dist/collection/components/note/crm-bonus-note.js +26 -64
  31. package/dist/collection/components/note/crm-bonus-note.js.map +1 -1
  32. package/dist/collection/components/pedido/pedido.js +1 -1
  33. package/dist/collection/components/phone/phone-input-mask.js +1 -1
  34. package/dist/collection/components/tooltip/tooltip.js +1 -1
  35. package/dist/collection/utils/retry.utils.js +13 -0
  36. package/dist/collection/utils/retry.utils.js.map +1 -0
  37. package/dist/components/app-modal.js +1 -1
  38. package/dist/components/{crm-bonus-2.d.ts → container-empty.d.ts} +4 -4
  39. package/dist/components/container-empty.js +33 -0
  40. package/dist/components/container-empty.js.map +1 -0
  41. package/dist/components/crm-bonus-note.js +40 -64
  42. package/dist/components/crm-bonus-note.js.map +1 -1
  43. package/dist/components/crm-bonus.js +72 -26
  44. package/dist/components/crm-bonus.js.map +1 -1
  45. package/dist/components/crm-button.js +1 -1
  46. package/dist/components/crm-giftback-form.js +1 -1
  47. package/dist/components/crm-tooltip.js +1 -1
  48. package/dist/components/giftback-info.js +1 -1
  49. package/dist/components/loading-container.js +1 -1
  50. package/dist/components/loading-spinner.js +1 -1
  51. package/dist/components/{p-8fda6382.js → p-0a7ccd8c.js} +4 -4
  52. package/dist/components/{p-8fda6382.js.map → p-0a7ccd8c.js.map} +1 -1
  53. package/dist/components/{p-c5be72a0.js → p-2cece106.js} +6 -4
  54. package/dist/components/p-2cece106.js.map +1 -0
  55. package/dist/components/{p-f1823a52.js → p-786485b2.js} +2 -2
  56. package/dist/components/{p-f1823a52.js.map → p-786485b2.js.map} +1 -1
  57. package/dist/components/{p-890dc5d5.js → p-8274e2c4.js} +2 -2
  58. package/dist/components/{p-890dc5d5.js.map → p-8274e2c4.js.map} +1 -1
  59. package/dist/components/{p-ce77a841.js → p-9b5c07d8.js} +2 -2
  60. package/dist/components/{p-ce77a841.js.map → p-9b5c07d8.js.map} +1 -1
  61. package/dist/components/{p-e2a6a4cf.js → p-a7d4e578.js} +19 -21
  62. package/dist/components/p-a7d4e578.js.map +1 -0
  63. package/dist/components/{p-417b4f7f.js → p-bea5a5c2.js} +3 -3
  64. package/dist/components/{p-417b4f7f.js.map → p-bea5a5c2.js.map} +1 -1
  65. package/dist/components/{p-bc930dfe.js → p-c250687d.js} +2 -2
  66. package/dist/components/{p-bc930dfe.js.map → p-c250687d.js.map} +1 -1
  67. package/dist/components/{p-488a119c.js → p-d49313cb.js} +8 -8
  68. package/dist/components/{p-488a119c.js.map → p-d49313cb.js.map} +1 -1
  69. package/dist/components/{p-ee1c025b.js → p-e6863cf5.js} +5 -5
  70. package/dist/components/{p-ee1c025b.js.map → p-e6863cf5.js.map} +1 -1
  71. package/dist/components/pedido-finalizado.js +2 -2
  72. package/dist/components/phone-form.js +1 -1
  73. package/dist/components/phone-input-mask.js +1 -1
  74. package/dist/components/pin-form.js +1 -1
  75. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
  76. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
  77. package/dist/crmbonus-component-wake/p-1644deef.entry.js +2 -0
  78. package/dist/crmbonus-component-wake/p-1644deef.entry.js.map +1 -0
  79. package/dist/crmbonus-component-wake/p-4bfd518e.entry.js +2 -0
  80. package/dist/crmbonus-component-wake/p-4bfd518e.entry.js.map +1 -0
  81. package/dist/crmbonus-component-wake/p-5d014ac9.entry.js +2 -0
  82. package/dist/crmbonus-component-wake/p-5d014ac9.entry.js.map +1 -0
  83. package/dist/crmbonus-component-wake/p-622d5644.entry.js +2 -0
  84. package/dist/crmbonus-component-wake/p-7e52727e.entry.js +2 -0
  85. package/dist/crmbonus-component-wake/{p-702d5a6f.js → p-b4f52f79.js} +2 -2
  86. package/dist/crmbonus-component-wake/p-b4f52f79.js.map +1 -0
  87. package/dist/crmbonus-component-wake/{p-b5da6ce1.js → p-bea5a5c2.js} +2 -2
  88. package/dist/crmbonus-component-wake/{p-b5da6ce1.js.map → p-bea5a5c2.js.map} +1 -1
  89. package/dist/env.js +2 -2
  90. package/dist/env.js.map +1 -1
  91. package/dist/esm/app-modal.entry.js +1 -1
  92. package/dist/esm/{cart.helper-4f1913ce.js → cart.helper-89391005.js} +4 -4
  93. package/dist/esm/{cart.helper-4f1913ce.js.map → cart.helper-89391005.js.map} +1 -1
  94. package/dist/esm/container-empty.entry.js +15 -0
  95. package/dist/esm/container-empty.entry.js.map +1 -0
  96. package/dist/esm/countdown-timer_11.entry.js +965 -0
  97. package/dist/esm/countdown-timer_11.entry.js.map +1 -0
  98. package/dist/esm/crm-bonus-note.entry.js +40 -65
  99. package/dist/esm/crm-bonus-note.entry.js.map +1 -1
  100. package/dist/esm/crmbonus-component-wake.js +1 -1
  101. package/dist/esm/{i18n-7938fb86.js → info.config.helper-e4b8c478.js} +14 -2
  102. package/dist/esm/info.config.helper-e4b8c478.js.map +1 -0
  103. package/dist/esm/loader.js +1 -1
  104. package/dist/esm/pedido-finalizado.entry.js +2 -2
  105. package/dist/types/Users/Darlison/Projects/Bycoders/crmbonus/crmbonus-component/.stencil/env.d.ts +1 -1
  106. package/dist/types/components/giftback-form/giftback-form.d.ts +0 -1
  107. package/dist/types/components/loading-container/container-empty.d.ts +3 -0
  108. package/dist/types/components/loading-container/loading-container.d.ts +1 -0
  109. package/dist/types/components/note/crm-bonus-note.d.ts +1 -3
  110. package/dist/types/components.d.ts +15 -26
  111. package/dist/types/utils/retry.utils.d.ts +1 -0
  112. package/package.json +1 -1
  113. package/dist/cjs/build.payload.helper-cfd3173e.js +0 -54
  114. package/dist/cjs/build.payload.helper-cfd3173e.js.map +0 -1
  115. package/dist/cjs/countdown-timer_2.cjs.entry.js +0 -74
  116. package/dist/cjs/countdown-timer_2.cjs.entry.js.map +0 -1
  117. package/dist/cjs/crm-bonus-2.cjs.entry.js +0 -33
  118. package/dist/cjs/crm-bonus-2.cjs.entry.js.map +0 -1
  119. package/dist/cjs/crm-bonus-tray.cjs.entry.js +0 -18
  120. package/dist/cjs/crm-bonus-tray.cjs.entry.js.map +0 -1
  121. package/dist/cjs/crm-bonus.cjs.entry.js +0 -284
  122. package/dist/cjs/crm-bonus.cjs.entry.js.map +0 -1
  123. package/dist/cjs/crm-giftback-form.cjs.entry.js +0 -282
  124. package/dist/cjs/crm-giftback-form.cjs.entry.js.map +0 -1
  125. package/dist/cjs/crm-tooltip_5.cjs.entry.js +0 -292
  126. package/dist/cjs/crm-tooltip_5.cjs.entry.js.map +0 -1
  127. package/dist/cjs/i18n-1ce6cb94.js.map +0 -1
  128. package/dist/cjs/info.config.helper-e35e6e20.js +0 -17
  129. package/dist/cjs/info.config.helper-e35e6e20.js.map +0 -1
  130. package/dist/cjs/loading-container.cjs.entry.js +0 -23
  131. package/dist/cjs/loading-container.cjs.entry.js.map +0 -1
  132. package/dist/cjs/loading-spinner.cjs.entry.js +0 -24
  133. package/dist/cjs/loading-spinner.cjs.entry.js.map +0 -1
  134. package/dist/collection/components/crm-bonus/crmbonus.js +0 -38
  135. package/dist/collection/components/crm-bonus/crmbonus.js.map +0 -1
  136. package/dist/collection/tray-ecommerce/crm-bonus-tray.js +0 -8
  137. package/dist/collection/tray-ecommerce/crm-bonus-tray.js.map +0 -1
  138. package/dist/components/crm-bonus-2.js +0 -57
  139. package/dist/components/crm-bonus-2.js.map +0 -1
  140. package/dist/components/crm-bonus-tray.d.ts +0 -11
  141. package/dist/components/crm-bonus-tray.js +0 -32
  142. package/dist/components/crm-bonus-tray.js.map +0 -1
  143. package/dist/components/p-b0ef2c0b.js +0 -52
  144. package/dist/components/p-b0ef2c0b.js.map +0 -1
  145. package/dist/components/p-c5be72a0.js.map +0 -1
  146. package/dist/components/p-e2a6a4cf.js.map +0 -1
  147. package/dist/crmbonus-component-wake/p-17b97fd2.entry.js +0 -2
  148. package/dist/crmbonus-component-wake/p-1b441909.js +0 -2
  149. package/dist/crmbonus-component-wake/p-1b441909.js.map +0 -1
  150. package/dist/crmbonus-component-wake/p-3a4d7622.entry.js +0 -2
  151. package/dist/crmbonus-component-wake/p-3a4d7622.entry.js.map +0 -1
  152. package/dist/crmbonus-component-wake/p-54b8f32b.entry.js +0 -2
  153. package/dist/crmbonus-component-wake/p-54b8f32b.entry.js.map +0 -1
  154. package/dist/crmbonus-component-wake/p-59033825.entry.js +0 -2
  155. package/dist/crmbonus-component-wake/p-59033825.entry.js.map +0 -1
  156. package/dist/crmbonus-component-wake/p-61ea41c9.entry.js +0 -2
  157. package/dist/crmbonus-component-wake/p-6532623f.entry.js +0 -2
  158. package/dist/crmbonus-component-wake/p-6532623f.entry.js.map +0 -1
  159. package/dist/crmbonus-component-wake/p-702d5a6f.js.map +0 -1
  160. package/dist/crmbonus-component-wake/p-87cb8341.entry.js +0 -2
  161. package/dist/crmbonus-component-wake/p-87cb8341.entry.js.map +0 -1
  162. package/dist/crmbonus-component-wake/p-9d926857.entry.js +0 -2
  163. package/dist/crmbonus-component-wake/p-9d926857.entry.js.map +0 -1
  164. package/dist/crmbonus-component-wake/p-b0ef2c0b.js +0 -2
  165. package/dist/crmbonus-component-wake/p-b0ef2c0b.js.map +0 -1
  166. package/dist/crmbonus-component-wake/p-ce2819cc.entry.js +0 -2
  167. package/dist/crmbonus-component-wake/p-ce2819cc.entry.js.map +0 -1
  168. package/dist/crmbonus-component-wake/p-e992d997.entry.js +0 -2
  169. package/dist/crmbonus-component-wake/p-e992d997.entry.js.map +0 -1
  170. package/dist/crmbonus-component-wake/p-eace8d0e.entry.js +0 -2
  171. package/dist/crmbonus-component-wake/p-eace8d0e.entry.js.map +0 -1
  172. package/dist/esm/build.payload.helper-699a48ca.js +0 -52
  173. package/dist/esm/build.payload.helper-699a48ca.js.map +0 -1
  174. package/dist/esm/countdown-timer_2.entry.js +0 -69
  175. package/dist/esm/countdown-timer_2.entry.js.map +0 -1
  176. package/dist/esm/crm-bonus-2.entry.js +0 -29
  177. package/dist/esm/crm-bonus-2.entry.js.map +0 -1
  178. package/dist/esm/crm-bonus-tray.entry.js +0 -14
  179. package/dist/esm/crm-bonus-tray.entry.js.map +0 -1
  180. package/dist/esm/crm-bonus.entry.js +0 -280
  181. package/dist/esm/crm-bonus.entry.js.map +0 -1
  182. package/dist/esm/crm-giftback-form.entry.js +0 -278
  183. package/dist/esm/crm-giftback-form.entry.js.map +0 -1
  184. package/dist/esm/crm-tooltip_5.entry.js +0 -284
  185. package/dist/esm/crm-tooltip_5.entry.js.map +0 -1
  186. package/dist/esm/i18n-7938fb86.js.map +0 -1
  187. package/dist/esm/info.config.helper-7cad7a9c.js +0 -15
  188. package/dist/esm/info.config.helper-7cad7a9c.js.map +0 -1
  189. package/dist/esm/loading-container.entry.js +0 -19
  190. package/dist/esm/loading-container.entry.js.map +0 -1
  191. package/dist/esm/loading-spinner.entry.js +0 -20
  192. package/dist/esm/loading-spinner.entry.js.map +0 -1
  193. package/dist/types/components/crm-bonus/crmbonus.d.ts +0 -8
  194. package/dist/types/tray-ecommerce/crm-bonus-tray.d.ts +0 -3
  195. /package/dist/crmbonus-component-wake/{p-17b97fd2.entry.js.map → p-622d5644.entry.js.map} +0 -0
  196. /package/dist/crmbonus-component-wake/{p-61ea41c9.entry.js.map → p-7e52727e.entry.js.map} +0 -0
@@ -0,0 +1,979 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-a7537457.js');
6
+ const cart_helper = require('./cart.helper-abdd9916.js');
7
+ const info_config_helper = require('./info.config.helper-d4b1291b.js');
8
+ const utils = require('./utils-5d59acb1.js');
9
+
10
+ const CountdownTimer = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ this.downtime = undefined;
14
+ this.dataCriacao = undefined;
15
+ this.minutos = 6;
16
+ this.segundos = 60;
17
+ this.tempoRestante = undefined;
18
+ }
19
+ componentWillLoad() {
20
+ const tempoTotal = this.minutos * this.segundos * 1000;
21
+ const data = new Date(this.dataCriacao);
22
+ const agora = new Date();
23
+ const tempoPassado = agora.getTime() - data.getTime();
24
+ if (tempoPassado >= tempoTotal) {
25
+ this.tempoRestante = 0;
26
+ this.onTempoEsgotado();
27
+ }
28
+ else {
29
+ this.tempoRestante = tempoTotal - tempoPassado;
30
+ this.startCountdown();
31
+ }
32
+ }
33
+ disconnectedCallback() {
34
+ clearInterval(this.intervalId);
35
+ }
36
+ startCountdown() {
37
+ this.intervalId = setInterval(() => {
38
+ this.tempoRestante -= 1000;
39
+ if (this.tempoRestante <= 0) {
40
+ this.tempoRestante = 0;
41
+ clearInterval(this.intervalId);
42
+ this.onTempoEsgotado();
43
+ }
44
+ }, 1000);
45
+ }
46
+ onTempoEsgotado() {
47
+ console.log('Tempo esgotado! Executando ação...');
48
+ this.downtime();
49
+ }
50
+ render() {
51
+ const minutos = Math.floor(this.tempoRestante / 60000);
52
+ const segundos = Math.floor((this.tempoRestante % 60000) / 1000);
53
+ const tempoFormatado = `${String(minutos).padStart(2, '0')}:${String(segundos).padStart(2, '0')}`;
54
+ return (index.h("label", { key: 'ed1e0654cba5b152adcadb10cf9dfd6909c07a1f' }, " ", tempoFormatado));
55
+ }
56
+ };
57
+
58
+ var AjustesTipoEnum;
59
+ (function (AjustesTipoEnum) {
60
+ AjustesTipoEnum["P"] = "Promocao";
61
+ AjustesTipoEnum["CC"] = "ContaCorrente";
62
+ AjustesTipoEnum["PP"] = "PromocaoProduto";
63
+ AjustesTipoEnum["F"] = "Formula";
64
+ })(AjustesTipoEnum || (AjustesTipoEnum = {}));
65
+
66
+ function buildProductsByWake(productsWake = []) {
67
+ const products = [];
68
+ for (const pw of productsWake) {
69
+ let discounts = getDiscount(pw.Ajustes);
70
+ // let discounts_formula = getDiscountFormula(pw.Ajustes);
71
+ var value = (pw.PrecoDe * pw.Quantidade);
72
+ var originalValue = (pw.PrecoDe * pw.Quantidade);
73
+ var discounts_value = (discounts * -1);
74
+ const existsPromotionProduct = pw.Ajustes.filter(adj => [AjustesTipoEnum.PP].includes(adj.Tipo));
75
+ const promotion_product = (existsPromotionProduct.length > 0);
76
+ products.push({
77
+ sku: pw.SKU,
78
+ value: value,
79
+ originalValue: originalValue,
80
+ productVariantId: pw.ProdutoVarianteId.toString(),
81
+ quantity: pw.Quantidade,
82
+ discount: value < discounts_value ? value : discounts_value,
83
+ promotion_product
84
+ });
85
+ }
86
+ return products;
87
+ }
88
+ function getDiscount(ajustes = []) {
89
+ let discounts = 0;
90
+ for (const discount of ajustes) {
91
+ if ([AjustesTipoEnum.P, AjustesTipoEnum.CC, AjustesTipoEnum.PP].includes(discount.Tipo)) {
92
+ discounts += discount.Valor;
93
+ }
94
+ }
95
+ return discounts;
96
+ }
97
+ // function getDiscountFormula(ajustes: IAjustes[] = []) {
98
+ // let discounts = 0;
99
+ // for(const discount of ajustes) {
100
+ // if([AjustesTipoEnum.F].includes(discount.Tipo)) {
101
+ // discounts += (discount.Valor * -1);
102
+ // }
103
+ // }
104
+ // return discounts;
105
+ // }
106
+
107
+ const crmBonusCss = ".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";
108
+ const CrmBonusStyle0 = crmBonusCss;
109
+
110
+ const CrmBonus$1 = class {
111
+ constructor(hostRef) {
112
+ index.registerInstance(this, hostRef);
113
+ this.crmBonusService = cart_helper.CrmBonusService.getInstance();
114
+ this.cart = undefined;
115
+ this.canhidden = false;
116
+ this.showModal = false;
117
+ this.cartWake = undefined;
118
+ this.customer = {
119
+ birthDate: "",
120
+ document: "",
121
+ name: "",
122
+ phone: ""
123
+ };
124
+ this.loading = false;
125
+ this.message = undefined;
126
+ this.phone = undefined;
127
+ this.canCancel = false;
128
+ this.amountCancel = undefined;
129
+ this.sent = undefined;
130
+ this.session = undefined;
131
+ this.loading_reprocess = false;
132
+ this.styles = info_config_helper.defaultStyles;
133
+ this.reservedInfo = undefined;
134
+ }
135
+ async resetBonus() {
136
+ console.log('[CRMBONUS] - reset bonus');
137
+ try {
138
+ await this.crmBonusRef.processBonus(this.buildProducts(), true);
139
+ console.log('[BONUS RESETADO]!!!!!');
140
+ }
141
+ catch (err) {
142
+ this.loading = false;
143
+ console.log('[error ao reprocessar bonous]');
144
+ await this.crmBonusRef.setStep(info_config_helper.StepFormEnum.STEP_PHONE);
145
+ }
146
+ finally {
147
+ this.loading = false;
148
+ }
149
+ }
150
+ async setloading() {
151
+ this.loading_reprocess = !this.loading_reprocess;
152
+ }
153
+ async reprocess() {
154
+ console.log("[CRMBONUS] - reprocess");
155
+ this.loading_reprocess = true;
156
+ try {
157
+ const isUse = localStorage.getItem(cart_helper.USED_KEY);
158
+ if (!isUse)
159
+ return;
160
+ this.cartWake = await cart_helper.getCart();
161
+ await this.resetBonus();
162
+ }
163
+ catch (err) {
164
+ console.debug('[watchProducts]', err.message);
165
+ }
166
+ finally {
167
+ this.loading_reprocess = false;
168
+ }
169
+ }
170
+ async componentWillLoad() {
171
+ this.loading_reprocess = true;
172
+ window.addEventListener('productRemovedFromCart', async () => {
173
+ console.log('[CRMBONUS] - productRemovedFromCart');
174
+ await this.reprocess();
175
+ });
176
+ window.addEventListener('productAddedToCart', async () => {
177
+ console.log('[CRMBONUS] - productAddedToCart');
178
+ await this.reprocess();
179
+ });
180
+ document.querySelectorAll('form').forEach((el) => {
181
+ el.addEventListener("submit", async () => {
182
+ console.log("[CRMBONUS] - Formulário está sendo submetido!");
183
+ await this.reprocess();
184
+ });
185
+ });
186
+ await this.observerHandle();
187
+ info_config_helper.instance.changeLanguage(info_config_helper.instance.language);
188
+ }
189
+ async componentDidLoad() {
190
+ try {
191
+ await this.loadSession();
192
+ this.handleLoad();
193
+ await this.loadConfigStore();
194
+ }
195
+ catch (error) {
196
+ this.loading_reprocess = false;
197
+ }
198
+ }
199
+ async observerHandle() {
200
+ const elements = document.getElementsByTagName('a');
201
+ //@ts-ignore
202
+ for (let el of elements) {
203
+ console.log('[el.href]', el.href);
204
+ if (el.href.includes('Produto/Delete')) {
205
+ el.addEventListener('click', async () => {
206
+ console.log('[CRMBONUS] - Produto removido do carrinho');
207
+ setTimeout(async () => {
208
+ await this.reprocess();
209
+ this.observerHandle();
210
+ }, 2000);
211
+ });
212
+ }
213
+ if (el.href.includes('Produto/Add')) {
214
+ el.addEventListener('click', async () => {
215
+ console.log('[CRMBONUS] - Produto adicionado ao carrinho');
216
+ setTimeout(async () => {
217
+ await this.reprocess();
218
+ this.observerHandle();
219
+ }, 2000);
220
+ });
221
+ }
222
+ }
223
+ }
224
+ async loadConfigStore() {
225
+ const [customization, infoBonus] = await Promise.all([
226
+ this.crmBonusService.getCustomization(this.cartWake.store.name),
227
+ cart_helper.getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)
228
+ ]);
229
+ this.reservedInfo = infoBonus;
230
+ if (customization.keepStoreFrontStyle) {
231
+ this.styles = null;
232
+ }
233
+ }
234
+ async fetchCustomer(userId, storeName) {
235
+ try {
236
+ return await this.crmBonusService.getCustomer(userId, storeName);
237
+ }
238
+ catch (error) {
239
+ console.error('[fetchCustomer] Error fetching customer:', error);
240
+ return null;
241
+ }
242
+ }
243
+ async handleLoad() {
244
+ try {
245
+ if (this.cartWake.user.id) {
246
+ this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {
247
+ if (customer) {
248
+ this.customer = customer;
249
+ }
250
+ });
251
+ }
252
+ const amount = localStorage.getItem(this.cartWake.id);
253
+ if (amount) {
254
+ this.canCancel = true;
255
+ this.amountCancel = amount;
256
+ }
257
+ await this.buildAndGetProducts(this.cartWake.products);
258
+ }
259
+ catch (error) {
260
+ console.log('info customer');
261
+ }
262
+ }
263
+ async loadSession() {
264
+ this.cartWake = this.cart ? new cart_helper.CartWake(JSON.parse(this.cart)) : await cart_helper.getCart();
265
+ console.log('[bc:carregou carrinho]');
266
+ this.session = await this.crmBonusService.getToken(this.cartWake.store.name);
267
+ console.log('[bc:carregou session]');
268
+ setTimeout(() => {
269
+ this.loadSession();
270
+ }, 1500000);
271
+ }
272
+ async buildAndGetProducts(productsWake) {
273
+ console.log();
274
+ const key = `bc-products:${this.cartWake.id}`;
275
+ const productsString = JSON.stringify(productsWake);
276
+ localStorage.setItem(key, productsString);
277
+ const products_in_cache = JSON.parse(localStorage.getItem(key));
278
+ const products = [];
279
+ for (const product_cart of productsWake) {
280
+ const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId);
281
+ //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === "Formula")
282
+ if (pro) {
283
+ products.push(Object.assign(Object.assign({}, product_cart), { PrecoPor: pro.PrecoPor, PrecoDe: pro.PrecoDe, Quantidade: pro.Quantidade, Ajustes: pro.Ajustes }));
284
+ }
285
+ else {
286
+ products.push(product_cart);
287
+ }
288
+ }
289
+ this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);
290
+ }
291
+ async sendPin(phone) {
292
+ var _a, _b;
293
+ this.loading = true;
294
+ this.message = "";
295
+ try {
296
+ const _phone = phone.replace(/\D/g, '');
297
+ this.phone = Number(_phone);
298
+ this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
299
+ await this.crmBonusRef.setStep(info_config_helper.StepFormEnum.STEP_PIN);
300
+ this.showModal = true;
301
+ }
302
+ catch (error) {
303
+ this.message = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
304
+ }
305
+ finally {
306
+ this.loading = false;
307
+ }
308
+ }
309
+ async sendPinName(customerName) {
310
+ var _a, _b;
311
+ this.loading = true;
312
+ this.message = "";
313
+ try {
314
+ this.customer.name = customerName;
315
+ this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
316
+ await this.crmBonusRef.setStep(info_config_helper.StepFormEnum.STEP_PIN);
317
+ this.showModal = true;
318
+ }
319
+ catch (error) {
320
+ this.message = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
321
+ }
322
+ finally {
323
+ this.loading = false;
324
+ }
325
+ }
326
+ buildProducts() {
327
+ return buildProductsByWake(this.cartWake.products);
328
+ }
329
+ handleCloseModal() {
330
+ this.showModal = false;
331
+ }
332
+ save(amount) {
333
+ localStorage.setItem(this.cartWake.id, amount.toString());
334
+ this.canCancel = true;
335
+ this.amountCancel = amount.toString();
336
+ }
337
+ async cancel() {
338
+ this.message = "";
339
+ this.loading = true;
340
+ try {
341
+ await this.crmBonusService.cancel(this.cartWake.id);
342
+ this.canCancel = false;
343
+ localStorage.removeItem(this.cartWake.id);
344
+ }
345
+ catch (error) {
346
+ this.message = "Não consegui cancelar o bônus, tente novamente!";
347
+ }
348
+ finally {
349
+ this.loading = false;
350
+ }
351
+ }
352
+ async handleSendPin(phone) {
353
+ this.message = "";
354
+ if (!phone) {
355
+ this.message = "Informe seu telefone";
356
+ return;
357
+ }
358
+ this.customer.phone = phone;
359
+ const _phone = phone.replace(/\D/g, '');
360
+ this.phone = Number(_phone);
361
+ if (this.customer.name) {
362
+ return this.sendPin(phone);
363
+ }
364
+ await this.crmBonusRef.setStep(info_config_helper.StepFormEnum.STEP_NAME);
365
+ this.showModal = true;
366
+ }
367
+ render() {
368
+ if (this.canhidden) {
369
+ return null;
370
+ }
371
+ return (index.h("loading-container", { loading: this.loading_reprocess, text: 'carregando...' }, !this.loading_reprocess && (index.h("crm-giftback-form", { customStyles: this.styles, style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts(), loadAll: () => this.handleLoad(), reservedInfo: this.reservedInfo }))));
372
+ }
373
+ static get assetsDirs() { return ["assets"]; }
374
+ };
375
+ CrmBonus$1.style = CrmBonusStyle0;
376
+
377
+ const crmButtonCss = "input,button{margin:0;padding:10px;}.crm-contaner-button{height:auto;width:auto}.crm-button{height:48px;width:100%;border:1px solid #000;padding:14px 20px;background-color:#000;color:#fff;line-height:20px;font-weight:500;cursor:pointer}";
378
+ const CrmButtonStyle0 = crmButtonCss;
379
+
380
+ const Button = class {
381
+ constructor(hostRef) {
382
+ index.registerInstance(this, hostRef);
383
+ this.txtBtn = undefined;
384
+ this.loading = undefined;
385
+ this.handleClick = undefined;
386
+ }
387
+ render() {
388
+ return (index.h("div", { key: '785b4975fb6538dbe2cdb7b99d5801abc72c534a', class: "crm-contaner-button" }, index.h("button", { key: '1e41951aa024e9f3b9b1836e8386bd369d022f76', class: "crm-button", onClick: () => this.handleClick() }, !this.loading ? this.txtBtn : index.h("loading-spinner", { size: "15px", color: "#fff" }))));
389
+ }
390
+ };
391
+ Button.style = CrmButtonStyle0;
392
+
393
+ const giftbackFormCss$2 = "*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";
394
+ const CrmGiftbackFormStyle0 = giftbackFormCss$2;
395
+
396
+ const CrmBonus = class {
397
+ constructor(hostRef) {
398
+ index.registerInstance(this, hostRef);
399
+ // private phoneInputMask: HTMLPhoneFormElement;
400
+ this.crmBonusService = cart_helper.CrmBonusService.getInstance();
401
+ this.storeName = undefined;
402
+ this.cartId = undefined;
403
+ this.products = undefined;
404
+ this.customer = undefined;
405
+ this.loadProducts = undefined;
406
+ this.loadAll = undefined;
407
+ this.customStyles = undefined;
408
+ this.reservedInfo = undefined;
409
+ this.value = undefined;
410
+ this.loading = false;
411
+ this.message = undefined;
412
+ this.phone = undefined;
413
+ this.pinInfo = undefined;
414
+ this.step = info_config_helper.StepFormEnum.STEP_RESERVE;
415
+ this.bonus = undefined;
416
+ this.sucess = "";
417
+ this.error = "";
418
+ this.config = undefined;
419
+ this.hasApplyBonus = false;
420
+ this.loadingAllComponent = false;
421
+ }
422
+ async setStep(step) {
423
+ this.step = step;
424
+ }
425
+ async processBonus(products = [], hasNewProduct = false) {
426
+ await this.loadProducts();
427
+ this.sucess = "";
428
+ if (hasNewProduct) {
429
+ this.products = products;
430
+ }
431
+ const _bonus = localStorage.getItem(cart_helper.getKeyReserveByCartId(this.cartId));
432
+ if (_bonus) {
433
+ const bonus = JSON.parse(_bonus);
434
+ this.bonus = bonus;
435
+ this.phone = bonus.phone;
436
+ this.pinInfo = {
437
+ storeId: bonus.storeId,
438
+ userId: bonus.userId
439
+ };
440
+ await this.validateBonus("2018");
441
+ //this.step = StepFormEnum.STEP_RESERVE;
442
+ }
443
+ }
444
+ async handleSendPin(phone) {
445
+ await this.loadAll();
446
+ this.message = "";
447
+ if (!phone) {
448
+ this.message = "Informe seu telefone";
449
+ return;
450
+ }
451
+ this.phone = phone;
452
+ this.sendPin();
453
+ }
454
+ async componentWillLoad() {
455
+ this.sucess = "";
456
+ this.error = "";
457
+ this.config = info_config_helper.getInfoCustomization(this.storeName);
458
+ const phoneAgain = this.getPhoneNumberAgain();
459
+ if (phoneAgain) {
460
+ this.step = info_config_helper.StepFormEnum.STEP_PHONE;
461
+ return;
462
+ }
463
+ await this.processBonus();
464
+ }
465
+ getPhoneNumberAgain() {
466
+ const consulta_bonus = localStorage.getItem(cart_helper.getKeyReserveByCartId(this.cartId));
467
+ if (!consulta_bonus)
468
+ return true;
469
+ const bonus = JSON.parse(consulta_bonus);
470
+ return !bonus.hasBonus;
471
+ }
472
+ convertStringToNumber() {
473
+ var _a;
474
+ const _phone = (_a = this.phone) === null || _a === void 0 ? void 0 : _a.replace(/\D/g, '');
475
+ return Number(_phone);
476
+ }
477
+ async sendPin() {
478
+ var _a, _b, _c;
479
+ this.loading = true;
480
+ this.message = "";
481
+ this.sucess = "";
482
+ this.error = "";
483
+ try {
484
+ const _phone = this.convertStringToNumber();
485
+ const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);
486
+ if (!pinInfoCache) {
487
+ this.pinInfo = await this.crmBonusService.sendPin(_phone, (_a = this.customer) === null || _a === void 0 ? void 0 : _a.name, this.storeName);
488
+ }
489
+ if (pinInfoCache) {
490
+ const bonus = JSON.parse(pinInfoCache);
491
+ this.pinInfo = {
492
+ storeId: bonus.storeId,
493
+ userId: bonus.userId
494
+ };
495
+ await this.validateBonus("2018");
496
+ // this.step = StepFormEnum.STEP_RESERVE;
497
+ }
498
+ else {
499
+ this.step = info_config_helper.StepFormEnum.STEP_PIN;
500
+ }
501
+ }
502
+ catch (error) {
503
+ this.message = (_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message;
504
+ }
505
+ finally {
506
+ this.loading = false;
507
+ }
508
+ }
509
+ changePhone() {
510
+ this.sucess = "";
511
+ this.error = "";
512
+ this.step = info_config_helper.StepFormEnum.STEP_PHONE;
513
+ }
514
+ async validateBonus(pin) {
515
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
516
+ this.loadingAllComponent = true;
517
+ await this.loadProducts();
518
+ const used_or_no = localStorage.getItem(cart_helper.USED_KEY);
519
+ if (used_or_no == "dontUse") {
520
+ this.step = info_config_helper.StepFormEnum.STEP_RESERVE;
521
+ return;
522
+ }
523
+ this.loading = true;
524
+ this.sucess = "";
525
+ this.error = "";
526
+ const storeId = ((_a = this.pinInfo) === null || _a === void 0 ? void 0 : _a.storeId) || ((_c = (_b = this.reservedInfo) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.storeId);
527
+ const userId = ((_d = this.pinInfo) === null || _d === void 0 ? void 0 : _d.userId) || ((_f = (_e = this.reservedInfo) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.userId);
528
+ const cellphone = (_h = (_g = this.reservedInfo) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.cellphone;
529
+ const payload = {
530
+ pin: pin,
531
+ cellphone: cellphone || this.convertStringToNumber(),
532
+ storeId: storeId.toString(),
533
+ userId: userId.toString(),
534
+ checkoutId: this.cartId,
535
+ checkoutProducts: this.products,
536
+ name: (_j = this.customer) === null || _j === void 0 ? void 0 : _j.name,
537
+ storeName: this.storeName
538
+ };
539
+ try {
540
+ this.bonus = await this.crmBonusService.validatePinBonus(payload);
541
+ if (!this.bonus.hasBonus) {
542
+ localStorage.setItem(cart_helper.getKeyReserveByCartId(this.cartId), JSON.stringify(Object.assign(Object.assign({}, this.bonus), { phone: this.phone })));
543
+ this.loading = false;
544
+ this.step = info_config_helper.StepFormEnum.STEP_NO_BONUS;
545
+ return;
546
+ }
547
+ this.sucess = "Código validado com sucesso!";
548
+ localStorage.setItem(cart_helper.getKeyReserveByCartId(this.cartId), JSON.stringify(Object.assign(Object.assign({}, this.bonus), { phone: this.phone })));
549
+ localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));
550
+ localStorage.setItem(cart_helper.USED_KEY, "use");
551
+ localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());
552
+ this.updateMetadata({ storeId: Number(storeId), userId: Number(userId) }, payload.cellphone);
553
+ console.log('RESERVE', this.bonus);
554
+ this.step = info_config_helper.StepFormEnum.STEP_RESERVE;
555
+ }
556
+ catch (error) {
557
+ const _error = (_l = (_k = error === null || error === void 0 ? void 0 : error.response) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.response;
558
+ const response = (_m = error === null || error === void 0 ? void 0 : error.response) === null || _m === void 0 ? void 0 : _m.data;
559
+ if (_error && _error.includes("Pin")) {
560
+ this.error = "Código inválido!";
561
+ }
562
+ else if ([403, 500].includes(response.statusCode)) {
563
+ this.error = "ocorreu um error, atualize a pagina e tente novamente!";
564
+ }
565
+ else {
566
+ this.error = _error;
567
+ this.step = info_config_helper.StepFormEnum.STEP_NO_BONUS;
568
+ }
569
+ }
570
+ finally {
571
+ this.loading = false;
572
+ this.loadingAllComponent = false;
573
+ }
574
+ }
575
+ async updateMetadata(pinInfo, cellphone) {
576
+ try {
577
+ if (this.reservedInfo.isExpired()) {
578
+ console.log('[CRM:updateMetadata]');
579
+ await cart_helper.persisteMetadata(this.storeName, this.cartId, {
580
+ createdAt: Date.now(),
581
+ url: window.location.href,
582
+ storeId: pinInfo.storeId,
583
+ userId: pinInfo.userId,
584
+ cellphone: cellphone,
585
+ });
586
+ localStorage.removeItem("bc:time");
587
+ }
588
+ else {
589
+ await cart_helper.persisteMetadata(this.storeName, this.cartId, {
590
+ url: window.location.href,
591
+ storeId: pinInfo.storeId,
592
+ userId: pinInfo.userId,
593
+ cellphone: cellphone,
594
+ });
595
+ }
596
+ }
597
+ catch (error) {
598
+ console.error('[CRMBONUS:updateMetadata]: ', error);
599
+ }
600
+ }
601
+ handleCancel() {
602
+ // this.step = StepFormEnum.STEP_PHONE;
603
+ this.cancel();
604
+ }
605
+ async cancel() {
606
+ this.message = "";
607
+ this.loading = true;
608
+ try {
609
+ await this.crmBonusService.cancel(this.cartId);
610
+ localStorage.setItem(cart_helper.USED_KEY, "dontUse");
611
+ // this.save(0)
612
+ await this.updateMetadata({ storeId: null, userId: null }, null);
613
+ }
614
+ catch (error) {
615
+ this.message = "Não consegui cancelar o bônus, tente novamente!";
616
+ }
617
+ finally {
618
+ this.loading = false;
619
+ }
620
+ }
621
+ async reserveApply(amount) {
622
+ this.loading = true;
623
+ this.message = "";
624
+ try {
625
+ await this.reserve(amount);
626
+ // this.save(amount);
627
+ }
628
+ catch (error) {
629
+ this.message = "ocorreu um error ao solicitar a aplicação do bonus! tente novamente";
630
+ this.step = info_config_helper.StepFormEnum.STEP_NO_BONUS;
631
+ localStorage.removeItem(this.cartId);
632
+ }
633
+ finally {
634
+ this.loading = false;
635
+ }
636
+ }
637
+ // save(amount: number) {
638
+ // localStorage.setItem(this.cartId, amount.toString());
639
+ // }
640
+ async reserve(amount) {
641
+ await this.crmBonusService.reserve({
642
+ redeemedBonus: amount,
643
+ cartId: this.cartId,
644
+ ticket: this.cartId,
645
+ grossValue: Number(this.bonus.totalValue),
646
+ storeName: this.storeName,
647
+ storeId: this.bonus.storeId.toString(),
648
+ userId: this.bonus.userId
649
+ });
650
+ }
651
+ render() {
652
+ return (index.h("div", { key: '939a74f8d91ab9c880ffb2486967a7800a6d2ce6', class: "crm-container-form fbits-responsive-carrinho-desconto", style: this.customStyles }, index.h("label", { key: 'b51c241a72ae22911293ad3dd28190f22982c8cb', class: "crm-title" }, this.config.giftbackTitle), this.error && (index.h("label", { key: '9ca50e050603ad594b3086c82f2a31e08d8dec12', class: "crm-message-error" }, this.error)), this.step === info_config_helper.StepFormEnum.STEP_PHONE &&
653
+ index.h("phone-form", { key: 'ab8cd8263aaf2729f9af29937a40e029bf17193d', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === info_config_helper.StepFormEnum.STEP_PIN &&
654
+ index.h("pin-form", { key: 'da1680e62073ae2a3656fcef4ec85ec8b8d862cf', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && index.h("p", { key: '72486a002bbcb2cfad2f8ab32fbdda1e8dff143e', class: "crm-message-info" }, this.sucess), this.error && index.h("p", { key: 'dcddaee2dd0e7b6d50ef0377ae7a721ba5c8256c', class: "crm-message-error" }, this.error)), this.step === info_config_helper.StepFormEnum.STEP_RESERVE &&
655
+ index.h("giftback-info", { key: 'b237add0b03aa26f20bdf42264b01ad890670145', storeName: this.storeName, infoBonus: this.reservedInfo, config: this.config, loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: () => this.processBonus(), cartId: this.cartId }), this.step === info_config_helper.StepFormEnum.STEP_NO_BONUS &&
656
+ (index.h("div", { key: '6583e51ae1988bd5c797665e3119eed3aeb7a354', class: "container-message" }, info_config_helper.instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
657
+ }
658
+ };
659
+ CrmBonus.style = CrmGiftbackFormStyle0;
660
+
661
+ const infoCircleSvgrepoComSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xMiAxNy43NUMxMi40MTQyIDE3Ljc1IDEyLjc1IDE3LjQxNDIgMTIuNzUgMTdWMTFDMTIuNzUgMTAuNTg1OCAxMi40MTQyIDEwLjI1IDEyIDEwLjI1QzExLjU4NTggMTAuMjUgMTEuMjUgMTAuNTg1OCAxMS4yNSAxMVYxN0MxMS4yNSAxNy40MTQyIDExLjU4NTggMTcuNzUgMTIgMTcuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8cGF0aCBkPSJNMTIgN0MxMi41NTIzIDcgMTMgNy40NDc3MiAxMyA4QzEzIDguNTUyMjggMTIuNTUyMyA5IDEyIDlDMTEuNDQ3NyA5IDExIDguNTUyMjggMTEgOEMxMSA3LjQ0NzcyIDExLjQ0NzcgNyAxMiA3WiIgZmlsbD0iIzFDMjc0QyIvPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjI1IDEyQzEuMjUgNi4wNjI5NCA2LjA2Mjk0IDEuMjUgMTIgMS4yNUMxNy45MzcxIDEuMjUgMjIuNzUgNi4wNjI5NCAyMi43NSAxMkMyMi43NSAxNy45MzcxIDE3LjkzNzEgMjIuNzUgMTIgMjIuNzVDNi4wNjI5NCAyMi43NSAxLjI1IDE3LjkzNzEgMS4yNSAxMlpNMTIgMi43NUM2Ljg5MTM3IDIuNzUgMi43NSA2Ljg5MTM3IDIuNzUgMTJDMi43NSAxNy4xMDg2IDYuODkxMzcgMjEuMjUgMTIgMjEuMjVDMTcuMTA4NiAyMS4yNSAyMS4yNSAxNy4xMDg2IDIxLjI1IDEyQzIxLjI1IDYuODkxMzcgMTcuMTA4NiAyLjc1IDEyIDIuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8L3N2Zz4=';
662
+
663
+ const crmTooltipCss = ".crm-tooltip-container {\r\n display: flex;\r\n\r\n & img {\r\n width: 16px;\r\n margin-left: 3px;\r\n position: relative;\r\n }\r\n}\r\n\r\n.crm-tooltip {\r\n position: relative;\r\n display: inline-block;\r\n}\r\n\r\n.crm-tooltip .tooltiptext {\r\n visibility: hidden;\r\n background-color: black;\r\n color: #fff;\r\n text-align: center;\r\n padding: 8px 12px;\r\n border-radius: 0px;\r\n position: absolute;\r\n z-index: 1;\r\n min-width: 271px;\r\n top: 100%;\r\n left: 50%;\r\n margin-left: -238px;\r\n}\r\n\r\n@container (max-width: 410px) {\r\n .crm-tooltip .tooltiptext {\r\n margin-left: -14px;\r\n }\r\n\r\n .crm-tooltip #crm-role-description {\r\n margin-left: -151px;\r\n }\r\n}\r\n\r\n@container (max-width: 250px) {\r\n .crm-tooltip .tooltiptext {\r\n margin-left: -201px;\r\n }\r\n}\r\n\r\n.crm-tooltip:hover .tooltiptext {\r\n visibility: visible;\r\n}";
664
+ const CrmTooltipStyle0 = crmTooltipCss;
665
+
666
+ const Tooltip = class {
667
+ constructor(hostRef) {
668
+ index.registerInstance(this, hostRef);
669
+ this.text = undefined;
670
+ this.identity = undefined;
671
+ }
672
+ render() {
673
+ return (index.h("div", { key: '01d82d0172ca5f0dbb0b8ea278b4a5d438c13dd5', class: "crm-tooltip-container crm-tooltip" }, index.h("img", { key: '3b632cc38e8ff206402a2bfaadba9f9d2d747095', src: infoCircleSvgrepoComSvg }), index.h("span", { key: '08310e35ac945bda0e9356ecad8742698016f262', id: this.identity, class: "tooltiptext" }, this.text)));
674
+ }
675
+ };
676
+ Tooltip.style = CrmTooltipStyle0;
677
+
678
+ const giftbackInfoCss = ":host{--text-color:#6D6D5F}.giftback-container{display:flex;flex-direction:column;gap:14px}h3{margin-bottom:8px;color:#333}.container-description{display:flex;align-items:center;gap:5px;margin:0 0 10px 0}.container-description p{font-weight:400;margin:0px}p{color:#000}.value-display h2{color:#6D6D5F;margin:16px 0}input[type='range']{width:100%;margin:12px 0;-webkit-appearance:none;background:#ddd;height:4px;border-radius:4px;outline:none;padding:3px 0px 3px 3px}input[type=\"range\"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;background:rgb(109, 109, 95);border-radius:50%;cursor:pointer}.options{margin:0px 0;display:flex;gap:10px;flex-direction:column}.options label{display:flex;margin:0px 0;color:#333;align-items:center}.options input[type='radio']{margin-right:8px;height:16px;width:16px}.options input[type='radio']{appearance:none;-webkit-appearance:none;margin-right:8px;width:16px;height:16px;border:2px solid #ddd;border-radius:50%;background-color:#fff;cursor:pointer;transition:all 0.3s;padding:0px}.options input[type='radio']:checked{border-color:#000;background-color:#FAFAFA;border:4px solid #000}.info-box{background-color:#f9f9f9;border:1px solid #e0e0e0;border-radius:4px;padding:8px;color:#262626;line-height:20px}.info-icon{cursor:pointer;color:#888}h3{margin-bottom:8px;color:#333}.slider-wrapper{position:relative;margin:21px 0px 0px 0px}.slider{width:100%;-webkit-appearance:none;background:#ddd;height:4px;border-radius:2px;outline:none}.slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--text-color);border-radius:50%;cursor:pointer}.slider-value{position:absolute;top:-30px;font-weight:700;color:var(--text-color);transform:translateX(-50%);white-space:nowrap;}.options-option{display:flex}";
679
+ const GiftbackInfoStyle0 = giftbackInfoCss;
680
+
681
+ const GiftbackInfo = class {
682
+ constructor(hostRef) {
683
+ index.registerInstance(this, hostRef);
684
+ this.usedValue = 0;
685
+ this.selectedOption = 'none';
686
+ this.cartId = undefined;
687
+ this.loading = false;
688
+ this.bonus = {
689
+ totalBonus: 0,
690
+ cartId: "",
691
+ minimumPurchase: 0,
692
+ bonusBalance: 0,
693
+ calculatedValue: 0,
694
+ firstValidityDate: "",
695
+ totalValue: 0
696
+ };
697
+ this.reserve = undefined;
698
+ this.cancel = undefined;
699
+ this.config = undefined;
700
+ this.infoBonus = undefined;
701
+ this.storeName = undefined;
702
+ this.sliderPosition = 0;
703
+ this.sliderValuePosition = 0;
704
+ this.loadingTime = false;
705
+ }
706
+ changedBonus() {
707
+ this.updateBonus();
708
+ }
709
+ updateBonus() {
710
+ this.usedValue = this.bonus.bonusBalance;
711
+ this.buildPositionSlider(0, this.bonus.totalBonus);
712
+ }
713
+ componentWillLoad() {
714
+ this.updateBonus();
715
+ this.selectedOption = localStorage.getItem(cart_helper.USED_KEY);
716
+ }
717
+ handleSliderChange(event) {
718
+ const input = event.target;
719
+ this.usedValue = parseFloat(input.value);
720
+ // Calculando a posição do texto com base no valor do slider
721
+ // const percentage = ((this.usedValue - parseInt(input.min)) / (parseInt(input.max) - parseInt(input.min))) * 100;
722
+ // this.sliderPosition = percentage;
723
+ this.buildPositionSlider(parseFloat(input.min), parseFloat(input.max));
724
+ }
725
+ componentDidLoad() {
726
+ var _a;
727
+ if (this.bonus) {
728
+ this._refIinputRange.value = (_a = this.bonus) === null || _a === void 0 ? void 0 : _a.bonusBalance.toString();
729
+ }
730
+ }
731
+ buildPositionSlider(min, max) {
732
+ const percentage_init = max * 0.1;
733
+ // Calculando a posição do texto com base no valor do slider
734
+ const percentage = ((this.usedValue - min) / (max - min)) * 100;
735
+ this.sliderPosition = percentage;
736
+ this.sliderValuePosition = percentage + (this.usedValue <= percentage_init ? 10 : 0);
737
+ }
738
+ async handleOptionChange(option) {
739
+ this.selectedOption = option;
740
+ localStorage.setItem(cart_helper.USED_KEY, option);
741
+ await cart_helper.persisteMetadata(this.storeName, this.cartId, Object.assign(Object.assign({}, this.infoBonus.metadata), { createdAt: null }));
742
+ switch (this.selectedOption) {
743
+ case 'use':
744
+ await this.reserve(this.usedValue);
745
+ break;
746
+ case 'dontUse':
747
+ await this.cancel();
748
+ break;
749
+ }
750
+ }
751
+ showTime() {
752
+ if (!this.infoBonus)
753
+ return false;
754
+ return !this.infoBonus.isExpired();
755
+ // return this.infoBonus.isBonusProcessed
756
+ }
757
+ getTime() {
758
+ var _a, _b;
759
+ const createdAt = new Date((_b = (_a = this.infoBonus) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.createdAt);
760
+ const expiration = new Date(createdAt);
761
+ expiration.setMinutes(expiration.getMinutes() + 6);
762
+ return {
763
+ createdAt,
764
+ expiration
765
+ };
766
+ }
767
+ async downtime() {
768
+ await cart_helper.persisteMetadata(this.storeName, this.bonus.cartId, {
769
+ createdAt: null,
770
+ });
771
+ }
772
+ render() {
773
+ var _a, _b, _c, _d, _e, _f, _g;
774
+ console.log('this.bonus', this.bonus);
775
+ const remainingGiftback = this.bonus.minimumPurchase - this.bonus.totalValue;
776
+ const translateDescription = info_config_helper.instance.t("giftDescription", { amount: `${(_b = (_a = this.bonus) === null || _a === void 0 ? void 0 : _a.totalBonus) === null || _b === void 0 ? void 0 : _b.toFixed(2).replace(".", ",")}`, custom_name: "Giftback" });
777
+ const limit = utils.defineLimit(remainingGiftback);
778
+ return (index.h("div", { key: 'baf90a1de29b3275c1c3cfd31f9d004ca3187a84', class: "giftback-container" }, index.h("div", { key: '57af5fe5b40b3292a275065f577a9444470f8bf0', class: "container-description" }, index.h("p", { key: 'fff28c85077c36854f37d5f23f2908fa47197dac', innerHTML: translateDescription }), index.h("crm-tooltip", { key: 'b66b1914dfa5e0806f85a9695840fdd4bd52d21e', identity: "crm-role-description", text: info_config_helper.instance.t("labelUseGiftback", { minimumPurchase: this.bonus.minimumPurchase, expírationDate: utils.formatDateToBr(this.bonus.firstValidityDate) }) })), index.h("div", { key: 'e13afe9428744084443697df22048ac05b41ffd0', class: "slider-wrapper" }, index.h("div", { key: '1826a50e4e1b474322dbb0020db0154fe9ed5b80', class: "slider-value", style: {
779
+ left: `calc(${this.sliderValuePosition}% - 20px)`, // Ajuste para centralizar o texto
780
+ } }, "R$ ", this.usedValue.toFixed(2).replace(".", ",")), index.h("input", { key: '73b42919b8e4e0223dc8490a6190697d1975e96d', ref: ref => this._refIinputRange = ref, id: "position_value_id", disabled: true, type: "range", min: "0", max: this.bonus.totalBonus, value: this.usedValue, class: "slider", step: "0.01", onInput: (event) => this.handleSliderChange(event), style: {
781
+ background: `linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`,
782
+ } })), limit.isComplete && (index.h("p", { key: 'b9b853490c112bf3e98d14c2ceee25d0b7604983' }, info_config_helper.instance.t("maxAmount"))), !limit.isComplete && (index.h("div", { key: '50b23f6c4bde42ca12b077a33f0ffbde25601e3d', class: "container-description" }, index.h("p", { key: '73bfbcc779b8775aecc63050816909ba9120af3e' }, "Adicione ", index.h("strong", { key: '6d5a2ea943a1d3eee80b0f4d0cdda159a300bb25' }, "R$ ", remainingGiftback < 0 ? "0,00" : remainingGiftback.toFixed(2).replace(".", ",")), " ao carrinho para atingir o valor m\u00E1ximo!"), index.h("crm-tooltip", { key: '5a5bbbeb32abd51fbfb84c63d3e7a06f8d459ea0', identity: "crm-max-description", text: info_config_helper.instance.t("labelamountPartial") }))), index.h("div", { key: 'ea3f6aa8f4668b759b912bac36d9780e183a6180', class: "options" }, index.h("div", { key: '6f7f70930c8cd97f1215301d823f8631d071b472', class: "options-option" }, index.h("input", { key: '35b4f8380f34becd4dc94c1bcb1572c2b3401db8', disabled: this.showTime(), type: "radio", name: "giftbackOption", value: "use", checked: this.selectedOption === 'use', onChange: () => this.handleOptionChange('use') }), index.h("p", { key: '228beeb474e10a67811925bee00e5c1d0f5d64b6' }, "Usar o meu ", (_c = this.config) === null || _c === void 0 ? void 0 :
783
+ _c.giftbackTitle)), index.h("div", { key: '2a9ad1052f869057d5e36c3eba0cf1a24af88e1b', class: "options-option" }, index.h("input", { key: '3cc3fae293fda510873f9c5f4d906308affca8e1', disabled: this.showTime(), type: "radio", name: "giftbackOption", value: "dontUse", checked: this.selectedOption === 'dontUse', onChange: () => this.handleOptionChange('dontUse') }), index.h("p", { key: '364f7de414a6f536680f849fe3efdee803d9a596' }, "N\u00E3o usar o meu ", (_d = this.config) === null || _d === void 0 ? void 0 :
784
+ _d.giftbackTitle))), this.showTime() &&
785
+ (index.h("div", { key: '8fe525904208e2fc13ebd80615bbe7856cc2dc2c', class: "info-box" }, "Ap\u00F3s ", index.h("countdown-timer", { key: '3913bc9060980620654f03a987f62f628d6ee440', dataCriacao: new Date((_f = (_e = this.infoBonus) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.createdAt).toString(), downtime: () => { window.location.reload(); } }), ", voc\u00EA poder\u00E1 alterar sua escolha de usar ou n\u00E3o o Giftback.")), !((_g = this === null || this === void 0 ? void 0 : this.infoBonus) === null || _g === void 0 ? void 0 : _g.isBonusProcessed) && (index.h("div", { key: 'aecd80b9920c8b483d38a1c24a6b38ce03d52b64', class: "info-box" }, "O Giftback ser\u00E1 aplicado na pr\u00F3xima etapa."))));
786
+ }
787
+ static get watchers() { return {
788
+ "bonus": ["changedBonus"]
789
+ }; }
790
+ };
791
+ GiftbackInfo.style = GiftbackInfoStyle0;
792
+
793
+ const loadingContainerCss = ".loading-container{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000;flex-direction:column;}.loading-container p{margin:6px 0px;color:white;font-size:large}.loading-spinner{width:40px;height:40px;border:5px solid rgba(255, 255, 255, 0.3);border-top:5px solid white;border-radius:50%;animation:spin 1s linear infinite;}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.relative-xy{position:relative}";
794
+ const LoadingContainerStyle0 = loadingContainerCss;
795
+
796
+ const LoadingContainer = class {
797
+ constructor(hostRef) {
798
+ index.registerInstance(this, hostRef);
799
+ this.loading = true;
800
+ this.text = null;
801
+ }
802
+ render() {
803
+ return (index.h("div", { key: '5e323e6b562ee4d770bb2c9f786a23d6b47ce06e', class: "relative-xy" }, this.loading && (index.h("div", { key: '31183c82285ec32c7de0348885d0fd30e4a82502', class: "loading-container" }, index.h("div", { key: '1de235c7594a15e822d044364de0700d3c9e1fa4', class: "loading-spinner" }), this.text && index.h("p", { key: '82daa6b96a1e14d83be2fc22fd879b3a41896d0e' }, this.text))), index.h("slot", { key: '09c654783fde15f7b34c4a0804fcec07cfa28b30' })));
804
+ }
805
+ };
806
+ LoadingContainer.style = LoadingContainerStyle0;
807
+
808
+ const loadingSpinnerCss = ".spinner{display:inline-block;border:4px solid transparent;border-radius:50%;border-top-color:var(--color, #0078d7);animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
809
+ const LoadingSpinnerStyle0 = loadingSpinnerCss;
810
+
811
+ const LoadingSpinner = class {
812
+ constructor(hostRef) {
813
+ index.registerInstance(this, hostRef);
814
+ this.size = '50px';
815
+ this.color = '#0078d7';
816
+ }
817
+ render() {
818
+ return (index.h("div", { key: 'e1916d264937b0470cd5b1581c87184061b40c3a', class: "spinner", style: { width: this.size, height: this.size, borderColor: `${this.color} transparent transparent transparent` } }));
819
+ }
820
+ };
821
+ LoadingSpinner.style = LoadingSpinnerStyle0;
822
+
823
+ const giftbackFormCss$1 = "*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";
824
+ const PhoneFormStyle0 = giftbackFormCss$1;
825
+
826
+ const PhoneForm = class {
827
+ constructor(hostRef) {
828
+ index.registerInstance(this, hostRef);
829
+ this.value = undefined;
830
+ this.loading = undefined;
831
+ this.handlerSubmit = undefined;
832
+ this.config = undefined;
833
+ }
834
+ async handlePhone() {
835
+ const phone = await this.phoneInputMask.getPhone();
836
+ await this.handlerSubmit(phone);
837
+ }
838
+ render() {
839
+ var _a;
840
+ return (index.h(index.Host, { key: 'b27f64d8464d4c6b259d2d5f0113f55a6f809afb', class: "crm-phone-form" }, index.h("p", { key: '6f279841f43cd7f70f7a1b5340288b9c2d11c551', class: "crm-subtitle" }, "Digite o seu celular para verificar se h\u00E1 desconto dispon\u00EDvel nessa compra:"), index.h("phone-input-mask", { key: '7e86f63998a4f35d134b8f4e867a5e5c0b9df20a', initialValue: this.value, ref: ref => this.phoneInputMask = ref }), index.h("crm-button", { key: '462b7cc91f166c8fc588a5c922ba943a6715dca5', txtBtn: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.btnApplyBonusLabel) || "Avançar", loading: this.loading, handleClick: () => this.handlePhone() })));
841
+ }
842
+ };
843
+ PhoneForm.style = PhoneFormStyle0;
844
+
845
+ const phoneInputMaskCss = "*{margin:0;padding:0;box-sizing:border-box}.phone{display:block;width:100%;height:24px;padding:6px 12px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:0px;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, .075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, .075);-webkit-transition:border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s}.phone-input-form{width:100%;height:48px;padding:13px 16px 13px 16px;border:1px solid #CCCCCC;}.crm-erro-msg{color:#E11D48;font-weight:500;margin-top:11px}";
846
+ const PhoneInputMaskStyle0 = phoneInputMaskCss;
847
+
848
+ const PhoneInputMask = class {
849
+ constructor(hostRef) {
850
+ index.registerInstance(this, hostRef);
851
+ this.phone = '';
852
+ this.message = "";
853
+ this.initialValue = undefined;
854
+ this.disabled = undefined;
855
+ }
856
+ componentWillLoad() {
857
+ this.phone = this.initialValue;
858
+ }
859
+ formatPhone(value) {
860
+ const cleaned = value.replace(/\D/g, ''); // Remove tudo que não for número
861
+ const match = cleaned.match(/^(\d{0,2})(\d{0,5})(\d{0,4})$/);
862
+ if (!match)
863
+ return value;
864
+ const part1 = match[1] ? `(${match[1]}` : '';
865
+ const part2 = match[2] ? `) ${match[2]}` : '';
866
+ const part3 = match[3] ? ` ${match[3]}` : '';
867
+ return `${part1}${part2}${part3}`;
868
+ }
869
+ handleInput(event) {
870
+ const input = event.target;
871
+ this.phone = this.formatPhone(input.value);
872
+ if (!this.validatePhoneNumber(input.value)) {
873
+ this.message = info_config_helper.MESSAGE_ERROR_INVALID_NUMBER;
874
+ }
875
+ else {
876
+ this.message = "";
877
+ }
878
+ console.log('phone', this.phone);
879
+ }
880
+ validatePhoneNumber(phone) {
881
+ if (phone.length < 15) {
882
+ return true;
883
+ }
884
+ const phoneRegex = /^\(\d{2}\) \d{5} \d{4}$/; // Valida formato (99) 99999-9999
885
+ return phoneRegex.test(phone);
886
+ }
887
+ async getPhone() {
888
+ return this.phone;
889
+ }
890
+ render() {
891
+ return (index.h("div", { key: 'bbb0389d0a7ccb8651b8ee20e92dd4cdc94e3617' }, index.h("input", { key: 'b36cc9e65314cb786c7f94fee6b4992ba30a82e6', disabled: this.disabled, id: "phone", type: "text", class: "phone-input-form", value: this.phone, onInput: (event) => this.handleInput(event), placeholder: "(99) 99999 9999" }), index.h("p", { key: '81e48cda38cd9a8fc7d753d269425bd4288c57b1', class: "crm-erro-msg" }, this.message)));
892
+ }
893
+ };
894
+ PhoneInputMask.style = PhoneInputMaskStyle0;
895
+
896
+ const pinFormCss = ":host{display:block}.form-container-pin{display:flex;flex-direction:column;align-items:center}.pin-container{display:flex;justify-content:start;gap:10px}.pin-container input{width:100%;height:48px;text-align:center;border:1px solid #ccc;border-radius:5px}button{padding:10px 20px;background-color:#ddd;border:none;border-radius:5px;cursor:pointer}.success{color:green;margin-top:10px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;border-radius:10px;padding:15px;min-height:30px;min-width:120px;cursor:pointer}.button-cancel{top:50%;background-color:#ffffff;color:#1e1c1c;border:1px solid gray;border-radius:10px;padding:10px;min-height:30px;min-width:120px;cursor:pointer}.crm-description{width:100%;display:flex;gap:9px;flex-wrap:wrap}.crm-description a{font-weight:bold;cursor:pointer;text-decoration:underline}.crm-description div{display:flex;gap:5px}";
897
+ const PinFormStyle0 = pinFormCss;
898
+
899
+ const giftbackFormCss = "*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";
900
+ const PinFormStyle1 = giftbackFormCss;
901
+
902
+ const GiftbackPin = class {
903
+ constructor(hostRef) {
904
+ index.registerInstance(this, hostRef);
905
+ this.validate = undefined;
906
+ this.cancel = undefined;
907
+ this.resend = undefined;
908
+ this.sent = undefined;
909
+ this.loading = false;
910
+ this.phone = undefined;
911
+ this.config = undefined;
912
+ this.pin = ['', '', '', ''];
913
+ this.isVerified = false;
914
+ this.canResend = false;
915
+ }
916
+ componentWillLoad() {
917
+ this.canResend = false;
918
+ }
919
+ handleInput(event, index) {
920
+ const input = event.target;
921
+ const value = input.value.slice(0, 1); // Limitar a um único dígito
922
+ this.pin[index] = value;
923
+ // Focar no próximo campo, se possível
924
+ if (value && index < this.pin.length - 1) {
925
+ const nextInput = input.nextElementSibling;
926
+ nextInput === null || nextInput === void 0 ? void 0 : nextInput.focus();
927
+ }
928
+ this.pin = [...this.pin];
929
+ }
930
+ validatePin() {
931
+ localStorage.removeItem("bc:resend");
932
+ this.validate(this.pin.join(""));
933
+ }
934
+ verifyPin() {
935
+ const pinCode = this.pin.join('');
936
+ if (pinCode === '9999') {
937
+ this.isVerified = true;
938
+ }
939
+ }
940
+ handleTimeout() {
941
+ localStorage.removeItem("bc:resend");
942
+ this.canResend = true;
943
+ }
944
+ async handleResend() {
945
+ await this.resend();
946
+ this.canResend = false;
947
+ this.pin = ['', '', '', ''];
948
+ localStorage.removeItem("bc:resend");
949
+ }
950
+ buildTime() {
951
+ const resendDate = localStorage.getItem("bc:resend");
952
+ if (resendDate) {
953
+ return resendDate;
954
+ }
955
+ const date = new Date();
956
+ date.setSeconds(date.getSeconds() + 30);
957
+ localStorage.setItem("bc:resend", date.toString());
958
+ return date.toString();
959
+ }
960
+ render() {
961
+ var _a;
962
+ return (index.h("div", { key: '3f60e4c74c925daf656092812f40ae0d1f3b5a99', class: "crm-phone-form" }, index.h("label", { key: 'd0c023e22ff7eb8978ee6cc0ca4ced8192c53c20', class: "crm-subtitle" }, info_config_helper.instance.t('pin-sutitle'), " ", index.h("strong", { key: '05bb0e2493c99abaa29031a7cc787260266bb417' }, "+55 ", this.phone)), index.h("div", { key: '24c8eb55625f3b880741086c66decd96ecf40044', class: "pin-container" }, this.pin.map((_, index$1) => (index.h("input", { type: "text", maxLength: 1, value: this.pin[index$1], onInput: (event) => this.handleInput(event, index$1) })))), index.h("slot", { key: '02276aa80396d16f779a92a381e75506fa37d56d' }), index.h("p", { key: '27af068858b3ead8a70b8ec961d367c7beb04d94', class: "crm-description" }, " N\u00E3o recebeu?", !this.canResend && index.h("label", { key: '8ef93baf6f92142292078e5e4bcc125ff12b80d7' }, " Reenviar em", index.h("countdown-timer", { key: 'f3a0c60c7a88229e37add445886c44b00c60913f', minutos: 0, segundos: 30, dataCriacao: this.buildTime(), downtime: () => this.handleTimeout() }), " "), this.canResend && (index.h("div", { key: '2d1b5b028a7085d912acb0d0c696436e8aa75a29' }, index.h("a", { key: 'ad9aea2c6f167f1270c75b8dbd2ee79879f7567d', onClick: () => this.handleResend() }, "Reenviar"), index.h("a", { key: 'b0734ab0e472c5cf24fa083c0a712e4f29cf8d79', onClick: () => this.cancel() }, "Trocar n\u00FAmero")))), index.h("crm-button", { key: '39095211d007c871f48971509c3ff52b0f257c29', txtBtn: ((_a = this.config) === null || _a === void 0 ? void 0 : _a.btnApplyBonusLabel) || "Avançar", loading: this.loading, handleClick: () => this.validatePin() })));
963
+ }
964
+ };
965
+ GiftbackPin.style = PinFormStyle0 + PinFormStyle1;
966
+
967
+ exports.countdown_timer = CountdownTimer;
968
+ exports.crm_bonus = CrmBonus$1;
969
+ exports.crm_button = Button;
970
+ exports.crm_giftback_form = CrmBonus;
971
+ exports.crm_tooltip = Tooltip;
972
+ exports.giftback_info = GiftbackInfo;
973
+ exports.loading_container = LoadingContainer;
974
+ exports.loading_spinner = LoadingSpinner;
975
+ exports.phone_form = PhoneForm;
976
+ exports.phone_input_mask = PhoneInputMask;
977
+ exports.pin_form = GiftbackPin;
978
+
979
+ //# sourceMappingURL=countdown-timer_11.cjs.entry.js.map