@agrada_digital/pbm 0.0.112 → 0.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,43 @@
1
+ // src/schema/validation-schema.ts
2
+ import { z } from "zod";
3
+ var validationSchema = z.object({
4
+ securityNumber: z.string({
5
+ required_error: "CPF \xE9 obrigat\xF3rio."
6
+ }).refine((doc) => {
7
+ const replacedDoc = doc.replace(/\D/g, "");
8
+ return replacedDoc.length >= 11;
9
+ }, "CPF deve conter no m\xEDnimo 11 caracteres.").refine((doc) => {
10
+ const replacedDoc = doc.replace(/\D/g, "");
11
+ return !!Number(replacedDoc);
12
+ }, "CPF deve conter apenas n\xFAmeros."),
13
+ coupon: z.string({ required_error: "Cupom / ID do Cart\xE3o obrigat\xF3rio." }).optional()
14
+ });
15
+
16
+ // src/components/UI/Button/index.tsx
17
+ import classNames from "classnames";
18
+ import { jsx } from "react/jsx-runtime";
19
+ function Button(props) {
20
+ return /* @__PURE__ */ jsx(
21
+ "button",
22
+ {
23
+ ...props,
24
+ className: classNames(
25
+ "w-3xs cursor-pointer h-10 rounded-lg text-white text-sm font-semibold transition-colors",
26
+ props.className
27
+ ),
28
+ style: { ...props.style },
29
+ children: props.children
30
+ }
31
+ );
32
+ }
33
+ var Button_default = Button;
34
+
1
35
  // src/libs/zustand/usePBM.tsx
2
36
  import { createStore } from "zustand";
3
37
  import { useStore } from "zustand/react";
4
38
  var initialPBMState = {
5
39
  securityNumber: "",
40
+ requestId: "",
6
41
  cardID: "",
7
42
  state: "isEmpty",
8
43
  availableDiscountSelected: {
@@ -14,6 +49,7 @@ var initialPBMState = {
14
49
  totalPrice: 0,
15
50
  grossPrice: 0
16
51
  },
52
+ benefitsEnabled: true,
17
53
  targetProduct: null,
18
54
  campaign: "pbm_campaign",
19
55
  isAuthenticatedShopper: false,
@@ -22,6 +58,7 @@ var initialPBMState = {
22
58
  var createPBMStore = (set) => ({
23
59
  ...initialPBMState,
24
60
  setSecurityNumber: (securityNumber) => set({ securityNumber }),
61
+ setRequestId: (requestId) => set({ requestId }),
25
62
  setState: (state) => set({ state }),
26
63
  setTargetProduct: (targetProduct) => set({ targetProduct }),
27
64
  setAvailableDiscountSelected: (availableDiscount) => set({ availableDiscountSelected: availableDiscount }),
@@ -29,187 +66,25 @@ var createPBMStore = (set) => ({
29
66
  setUrlRegisterIndustry: (urlRegisterIndustry) => set({ urlRegisterIndustry }),
30
67
  setIsAuthenticatedShopper: (isAuthenticatedShopper) => set({ isAuthenticatedShopper }),
31
68
  setCustomLoginUrl: (customLoginUrl) => set({ customLoginUrl }),
32
- setCardID: (cardID) => set({ cardID })
69
+ setCardID: (cardID) => set({ cardID }),
70
+ setBenefitsEnabled: (benefitsEnabled) => set({ benefitsEnabled })
33
71
  });
34
72
  var pbmStore = createStore(createPBMStore);
35
73
  function usePBMStore(selector) {
36
- if (selector) {
37
- return useStore(pbmStore, selector);
38
- }
39
- return useStore(pbmStore, (state) => state);
40
- }
41
-
42
- // src/components/Header/index.tsx
43
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
44
- function Header({ originalProductPrice }) {
45
- const { targetProduct } = usePBMStore();
46
- const Price = targetProduct?.listPrice || originalProductPrice;
47
- const Discount = Price * ((targetProduct?.discountMax || 0) / 100);
48
- return /* @__PURE__ */ jsxs(Fragment, { children: [
49
- targetProduct?.informativeMessage && /* @__PURE__ */ jsx("span", { className: "absolute w-11/12 -top-6 bg-emerald-500 px-4 py-1 rounded-lg text-sm text-center font-medium text-white", style: { backgroundColor: "var(--pbm-primary)" }, children: targetProduct?.informativeMessage }),
50
- /* @__PURE__ */ jsxs(
51
- "header",
52
- {
53
- className: "flex items-center justify-between w-full p-0.5 rounded-xl mt-5",
54
- style: { backgroundColor: "color-mix(in srgb, var(--pbm-primary), transparent 70%)" },
55
- id: "header_pbm",
56
- children: [
57
- /* @__PURE__ */ jsx(
58
- "span",
59
- {
60
- className: "py-1 px-6 rounded-xl shrink-0 text-white text-xl font-bold flex items-center justify-start gap-2 relative",
61
- style: { backgroundColor: "var(--pbm-primary)" },
62
- "data-testid": "test_id_header_price",
63
- id: "header_price",
64
- children: /* @__PURE__ */ jsxs("section", { className: "flex items-center gap-2 justify-center-safe", children: [
65
- /* @__PURE__ */ jsx("span", { className: "line-through text-sm font-light", children: Number(Price)?.toLocaleString("pt-BR", {
66
- currency: "BRL",
67
- currencyDisplay: "symbol",
68
- currencySign: "standard",
69
- style: "currency"
70
- }) }),
71
- Number(Price - Discount)?.toLocaleString("pt-BR", {
72
- currency: "BRL",
73
- currencyDisplay: "symbol",
74
- currencySign: "standard",
75
- style: "currency"
76
- })
77
- ] })
78
- }
79
- ),
80
- /* @__PURE__ */ jsx("h1", { id: "header_title", className: "text-center w-full font-bold text-xs px-4 md:text-sm", style: { color: "var(--pbm-secondary)" }, children: "Desconto de Laborat\xF3rio" })
81
- ]
82
- }
83
- )
84
- ] });
85
- }
86
- var Header_default = Header;
87
-
88
- // src/components/UI/Container/index.tsx
89
- import classNames from "classnames";
90
- import { jsx as jsx2 } from "react/jsx-runtime";
91
- function Container({
92
- children,
93
- variant
94
- }) {
95
- return /* @__PURE__ */ jsx2(
96
- "main",
97
- {
98
- className: classNames({
99
- "border-3 border-(--pbm-border) flex flex-col items-center justify-center min-w-(--min-container) max-w-(--max-container) w-full h-auto rounded-xl p-4 bg-white gap-4 relative": variant === "main",
100
- "w-full h-auto relative": variant === "simple"
101
- }),
102
- "data-testid": "test_id_container",
103
- "data-variant": variant,
104
- id: "container_pbm",
105
- children
106
- }
74
+ return useStore(
75
+ pbmStore,
76
+ selector ?? ((state) => state)
107
77
  );
108
78
  }
109
- var Container_default = Container;
110
79
 
111
- // src/components/Footer/index.tsx
112
- import classNames4 from "classnames";
113
-
114
- // src/components/UI/Title/index.tsx
80
+ // src/components/Form/index.tsx
81
+ import { zodResolver } from "@hookform/resolvers/zod";
82
+ import { useForm } from "react-hook-form";
83
+ import { ArrowRight } from "lucide-react";
115
84
  import classNames2 from "classnames";
116
- import { jsx as jsx3 } from "react/jsx-runtime";
117
- function Title(props) {
118
- return /* @__PURE__ */ jsx3(
119
- "h2",
120
- {
121
- className: classNames2(
122
- "text-start font-semibold text-sm",
123
- props.className
124
- ),
125
- style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
126
- "data-testid": "test_id_title",
127
- id: "title_pbm",
128
- children: props.children
129
- }
130
- );
131
- }
132
- var Title_default = Title;
133
-
134
- // src/components/UI/Text/index.tsx
135
- import classNames3 from "classnames";
136
- import { jsx as jsx4 } from "react/jsx-runtime";
137
- function Text(props) {
138
- return /* @__PURE__ */ jsx4(
139
- "p",
140
- {
141
- className: classNames3(
142
- "font-normal text-sm",
143
- props.textAlign && `text-${props.textAlign}`,
144
- props.className
145
- ),
146
- style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
147
- "data-testid": "test_id_text",
148
- id: "text_pbm",
149
- children: props.children
150
- }
151
- );
152
- }
153
- var Text_default = Text;
154
-
155
- // src/components/Footer/index.tsx
156
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
157
- function Footer() {
158
- const { targetProduct } = usePBMStore();
159
- return /* @__PURE__ */ jsx5("footer", { className: "w-full h-auto relative", id: "footer_pbm", children: /* @__PURE__ */ jsxs2("section", { className: classNames4("flex items-center w-full h-auto gap-4", { "justify-center": targetProduct?.industryLogo, "justify-start": !targetProduct?.industryLogo }), children: [
160
- /* @__PURE__ */ jsxs2("section", { className: "w-4/5 h-auto", children: [
161
- /* @__PURE__ */ jsx5(Title_default, { children: "Economize com o benef\xEDcio do laborat\xF3rio." }),
162
- /* @__PURE__ */ jsx5(Text_default, { children: "Este produto tem pre\xE7o exclusivo para clientes cadastrados no programa." })
163
- ] }),
164
- targetProduct?.industryLogo && /* @__PURE__ */ jsx5(
165
- "img",
166
- {
167
- src: targetProduct.industryLogo,
168
- alt: "parceiro",
169
- className: "w-1/5 min-w-20 h-auto aspect-auto rounded-xl",
170
- loading: "eager",
171
- id: "footer_industry_logo_pbm",
172
- "data-testid": "footer_industry_logo_pbm"
173
- }
174
- )
175
- ] }) });
176
- }
177
- var Footer_default = Footer;
178
-
179
- // src/schema/validation-schema.ts
180
- import { z } from "zod";
181
- var validationSchema = z.object({
182
- securityNumber: z.string({
183
- required_error: "CPF \xE9 obrigat\xF3rio."
184
- }).refine((doc) => {
185
- const replacedDoc = doc.replace(/\D/g, "");
186
- return replacedDoc.length >= 11;
187
- }, "CPF deve conter no m\xEDnimo 11 caracteres.").refine((doc) => {
188
- const replacedDoc = doc.replace(/\D/g, "");
189
- return !!Number(replacedDoc);
190
- }, "CPF deve conter apenas n\xFAmeros."),
191
- coupon: z.string({ required_error: "Cupom / ID do Cart\xE3o obrigat\xF3rio." }).optional()
192
- });
193
-
194
- // src/utils/format-security-number.ts
195
- var toFormat = (value) => {
196
- const cleanedValue = value.replace(/\D/g, "");
197
- if (cleanedValue.length <= 11) {
198
- return cleanedValue.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})/, "$1-$2").replace(/(-\d{2})\d+?$/, "$1");
199
- }
200
- };
201
-
202
- // src/utils/mapping-internal-states.ts
203
- var mappingInternalStates = (outContextState) => {
204
- const status = {
205
- "acceptance": "isInvalid",
206
- "industry registration": "isRegistered",
207
- "active": "isActivated"
208
- };
209
- return status[outContextState];
210
- };
85
+ import { Activity, useState } from "react";
211
86
 
212
- // src/services/benefits-with-document.ts
87
+ // src/services/lookup-customer.ts
213
88
  import Cookies from "js-cookie";
214
89
 
215
90
  // src/services/helper.ts
@@ -223,75 +98,113 @@ var getEnv = (key) => {
223
98
  return void 0;
224
99
  };
225
100
 
226
- // src/services/benefits-with-document.ts
227
- var BenefitsWithDocument = async ({ document, products }) => {
101
+ // src/services/lookup-customer.ts
102
+ var LookupCustomer = async ({ DOCUMENT }) => {
228
103
  const API_URL = getEnv("VITE_API_URL");
229
- if (!API_URL) {
230
- throw new Error("API URL is not defined in environment variables");
231
- }
232
104
  const AUTH_TOKEN = Cookies.get("pbm-token");
233
105
  if (!AUTH_TOKEN) {
234
106
  throw new Error("Token is not defined in cookies or is expired");
235
107
  }
236
- const response = await fetch(`${API_URL}/products/benefitByDocument`, {
237
- method: "POST",
108
+ const response = await fetch(`${API_URL}/programregistration/${DOCUMENT}`, {
109
+ method: "GET",
238
110
  headers: {
239
111
  Authorization: `Bearer ${AUTH_TOKEN}`,
240
112
  "Content-Type": "application/json"
241
- },
242
- body: JSON.stringify({ consumer: { document }, products })
113
+ }
243
114
  });
244
- const dataResponse = await response.json();
245
- if (!dataResponse.success) {
246
- throw new Error(dataResponse.message || "Failed to fetch document validation");
115
+ if (response.status === 404) {
116
+ return {
117
+ ...await response.json(),
118
+ success: false
119
+ };
247
120
  }
121
+ const dataResponse = await response.json();
248
122
  return dataResponse;
249
123
  };
250
124
 
251
- // src/components/UI/Button/index.tsx
252
- import classNames5 from "classnames";
253
- import { jsx as jsx6 } from "react/jsx-runtime";
254
- function Button(props) {
255
- return /* @__PURE__ */ jsx6(
256
- "button",
257
- {
258
- ...props,
259
- className: classNames5(
260
- "w-3xs cursor-pointer h-10 rounded-lg text-white text-sm font-semibold transition-colors",
261
- props.className
262
- ),
263
- style: { ...props.style },
264
- children: props.children
265
- }
266
- );
267
- }
268
- var Button_default = Button;
269
-
270
- // src/components/Form/index.tsx
271
- import { zodResolver } from "@hookform/resolvers/zod";
272
- import { useForm } from "react-hook-form";
273
- import { ArrowRight } from "lucide-react";
274
- import classNames6 from "classnames";
275
- import { Activity, useState } from "react";
276
-
277
- // src/libs/zustand/useError.tsx
125
+ // src/libs/zustand/useModal.tsx
278
126
  import { create } from "zustand";
279
- var initialErrorState = {
280
- ErrorMessage: "Erro ao aplicar o benef\xEDcio"
127
+ var initialModalState = {
128
+ modal: {
129
+ id: "",
130
+ open: false,
131
+ label: "",
132
+ url: ""
133
+ }
281
134
  };
282
- var createErrorStore = (set) => ({
283
- ...initialErrorState,
284
- setErrorMessage: (ErrorMessage) => set({ ErrorMessage }),
285
- resetErrorMessage: () => set({ ErrorMessage: initialErrorState.ErrorMessage })
135
+ var createModalStore = (set) => ({
136
+ ...initialModalState,
137
+ setModal: (modal) => set({ modal }),
138
+ resetModal: () => set({ modal: initialModalState.modal })
286
139
  });
287
- var useError = create(createErrorStore);
140
+ var useModal = create(createModalStore);
141
+
142
+ // src/utils/formaters.ts
143
+ var formatPhone = (value) => value.replace(/\D/g, "").slice(0, 11).replace(/^(\d{2})(\d{5})(\d{0,4})/, "($1) $2-$3").trim();
144
+ var formatCEP = (value) => value.replace(/\D/g, "").slice(0, 8).replace(/^(\d{5})(\d{0,3})/, "$1-$2");
145
+ var maskCPF = (value) => value.replace(/\D/g, "").replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, "$1.$2.$3-$4");
146
+ var formatPrice = (price) => Number(String(price).replace(",", "."));
147
+ var formaters = {
148
+ phone: (value) => formatPhone(value),
149
+ cep: (value) => formatCEP(value),
150
+ cpf: (value) => maskCPF(value),
151
+ price: (price) => formatPrice(price)
152
+ };
153
+
154
+ // src/libs/zustand/usePBMForm.tsx
155
+ import { create as create2 } from "zustand";
156
+ var initialPBMFormState = {
157
+ personalData: { name: "", phone: "", birthday: "", email: "" },
158
+ address: {
159
+ postalcode: "",
160
+ number: "",
161
+ complement: "",
162
+ street: "",
163
+ neighborhood: "",
164
+ city: "",
165
+ stateAddress: ""
166
+ },
167
+ genderResponsibility: { gender: "", patient: null },
168
+ doctor: { typeCredential: "CRM", register: "", state: "", doctorName: "" },
169
+ acceptances: {
170
+ acceptPhone: false,
171
+ acceptsSms: false,
172
+ acceptsEmail: false,
173
+ acceptsMail: false,
174
+ acceptsPrivacyTermsLGPD: false
175
+ },
176
+ step: 0
177
+ };
178
+ var usePBMFormStore = create2((set) => ({
179
+ ...initialPBMFormState,
180
+ setPersonalData: (data) => set((s) => ({ personalData: { ...s.personalData, ...data } })),
181
+ setAddress: (data) => set((s) => ({ address: { ...s.address, ...data } })),
182
+ setGenderResponsibility: (data) => set((s) => ({
183
+ genderResponsibility: { ...s.genderResponsibility, ...data }
184
+ })),
185
+ setDoctor: (data) => set((s) => ({ doctor: { ...s.doctor, ...data } })),
186
+ setAcceptances: (data) => set((s) => ({ acceptances: { ...s.acceptances, ...data } })),
187
+ setStep: (step) => set({ step }),
188
+ resetForm: () => set(initialPBMFormState)
189
+ }));
190
+ var usePBMForm = usePBMFormStore;
191
+
192
+ // src/utils/mappingFormStep.ts
193
+ var mappingFormStep = {
194
+ "PersonalData": 0,
195
+ "Address": 1,
196
+ "GenderResponsibility": 2,
197
+ "Doctor": 3,
198
+ "Acceptances": 4
199
+ };
288
200
 
289
201
  // src/components/Form/index.tsx
290
- import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
202
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
291
203
  function Form({ startTransition }) {
292
204
  const store = usePBMStore();
293
205
  const [showCardIDField, setShowCardIDField] = useState(false);
294
- const { setErrorMessage } = useError();
206
+ const { setModal } = useModal();
207
+ const { setStep } = usePBMForm();
295
208
  const {
296
209
  handleSubmit,
297
210
  register,
@@ -307,54 +220,100 @@ function Form({ startTransition }) {
307
220
  coupon: ""
308
221
  }
309
222
  });
223
+ const CheckCustomerRegisterSteps = ({
224
+ customer
225
+ }) => {
226
+ const data = customer.data;
227
+ if (data.registration?.personal_data === null) {
228
+ setStep(mappingFormStep["PersonalData"]);
229
+ setModal({
230
+ id: "CustomerNotRegistered",
231
+ open: true
232
+ });
233
+ return;
234
+ }
235
+ if (data.registration?.address === null) {
236
+ setStep(mappingFormStep["Address"]);
237
+ setModal({
238
+ id: "CustomerNotRegistered",
239
+ open: true
240
+ });
241
+ return;
242
+ }
243
+ if (data.registration?.identity_responsibility === null) {
244
+ setStep(mappingFormStep["GenderResponsibility"]);
245
+ setModal({
246
+ id: "CustomerNotRegistered",
247
+ open: true
248
+ });
249
+ return;
250
+ }
251
+ if (data.registration?.medical_data === null) {
252
+ setStep(mappingFormStep["Doctor"]);
253
+ setModal({
254
+ id: "CustomerNotRegistered",
255
+ open: true
256
+ });
257
+ return;
258
+ }
259
+ if (data.registration?.lgpd === null) {
260
+ setStep(mappingFormStep["Acceptances"]);
261
+ setModal({
262
+ id: "CustomerNotRegistered",
263
+ open: true
264
+ });
265
+ return;
266
+ }
267
+ store.setState("isActivated");
268
+ };
310
269
  const checkSecurityNumberBenefits = async (values) => {
311
- try {
312
- if (store.targetProduct === null) {
313
- console.error("PBMLOG: Product is not defined!");
314
- return;
315
- }
316
- if (!store.targetProduct.productId) {
317
- console.error("PBMLOG: Product ID is not defined!");
270
+ if (store.targetProduct === null) {
271
+ console.error("PBMLOG: Product is not defined!");
272
+ return;
273
+ }
274
+ if (!store.targetProduct.productId) {
275
+ console.error("PBMLOG: Product ID is not defined!");
276
+ return;
277
+ }
278
+ if (!store.targetProduct.listPrice) {
279
+ console.error("PBMLOG: List Price is not defined!");
280
+ return;
281
+ }
282
+ store.setSecurityNumber(values.securityNumber.replace(/\D/g, ""));
283
+ const customerIsRegistered = await LookupCustomer({
284
+ DOCUMENT: values.securityNumber.replace(/\D/g, "")
285
+ });
286
+ if (customerIsRegistered.success) {
287
+ if (!customerIsRegistered.data.requestId) {
288
+ console.error(
289
+ "PBMLOG: Request ID is not defined in lookup customer response"
290
+ );
318
291
  return;
319
292
  }
320
- if (!store.targetProduct.listPrice) {
321
- console.error("PBMLOG: List Price is not defined!");
293
+ store.setRequestId(customerIsRegistered.data.requestId || "");
294
+ CheckCustomerRegisterSteps({ customer: customerIsRegistered });
295
+ return;
296
+ }
297
+ if (!customerIsRegistered.success) {
298
+ if (!customerIsRegistered.requestId) {
299
+ console.error(
300
+ "PBMLOG: Request ID is not defined in lookup customer response for non registered customer"
301
+ );
322
302
  return;
323
303
  }
324
- const product = {
325
- productId: store.targetProduct.productId,
326
- ean: store.targetProduct.ean,
327
- requestedQuantity: 1,
328
- listPrice: store.targetProduct.listPrice,
329
- netPrice: store.targetProduct.netPrice ?? store.targetProduct.listPrice
330
- };
331
- const response = await BenefitsWithDocument({
332
- document: values.securityNumber.replace(/\D/g, ""),
333
- products: [product]
334
- });
335
- if (response.success) {
336
- const status = mappingInternalStates(response.data.product[0].statusCustomer);
337
- store.setSecurityNumber(values.securityNumber);
338
- store.setState(status);
339
- if (status === "isInvalid") {
340
- store.setUrlAcceptTerms(response.data.product[0].urlAcceptTerm || void 0);
341
- return;
342
- }
343
- if (status === "isRegistered") {
344
- store.setUrlRegisterIndustry(response.data.product[0].informativeLink);
345
- return;
346
- }
347
- if (!status) {
348
- setErrorMessage(response.data.product[0].informativeText);
349
- store.setState("isError");
350
- return;
351
- }
352
- }
353
- } catch (error) {
354
- console.error("PBMLOG: Error validating document -", error);
304
+ store.setRequestId(customerIsRegistered.requestId || "");
305
+ setModal({
306
+ id: "CustomerNotRegistered",
307
+ open: true
308
+ });
309
+ return;
355
310
  }
356
311
  };
357
312
  const onSubmitDefault = async (values) => {
313
+ if (!store.isAuthenticatedShopper) {
314
+ setModal({ id: "ShopperIsNotAuthenticated", open: true });
315
+ return;
316
+ }
358
317
  if (!showCardIDField) {
359
318
  setValue("coupon", void 0, { shouldValidate: false });
360
319
  }
@@ -365,31 +324,38 @@ function Form({ startTransition }) {
365
324
  await checkSecurityNumberBenefits(values);
366
325
  });
367
326
  };
368
- return /* @__PURE__ */ jsxs3(Fragment2, { children: [
369
- /* @__PURE__ */ jsxs3(
327
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
328
+ /* @__PURE__ */ jsxs(
370
329
  "form",
371
330
  {
372
331
  onSubmit: handleSubmit(onSubmitDefault),
373
- className: classNames6(
374
- "w-full h-auto flex items-center justify-center mb-0 transition-all duration-150",
375
- { "mb-4": errors.securityNumber || errors.coupon && showCardIDField, "gap-2": showCardIDField }
332
+ className: classNames2(
333
+ "w-full h-auto flex items-start justify-center flex-col mb-2 transition-all duration-150"
376
334
  ),
377
335
  id: "form_security_number_pbm",
378
336
  children: [
379
- /* @__PURE__ */ jsxs3(
337
+ /* @__PURE__ */ jsxs(
380
338
  "label",
381
339
  {
382
340
  htmlFor: "cpf",
383
- className: "w-4/5 h-auto flex items-start flex-col justify-center relative py-2",
341
+ className: classNames2(
342
+ "w-full h-auto flex items-start flex-col justify-center relative py-2 transition-all duration-100",
343
+ {
344
+ "mb-4": errors.securityNumber && !showCardIDField
345
+ }
346
+ ),
384
347
  id: "label_security_number_pbm",
385
348
  children: [
386
- /* @__PURE__ */ jsx7(
349
+ /* @__PURE__ */ jsx2(
387
350
  "input",
388
351
  {
389
352
  type: "text",
390
- className: classNames6(
391
- "w-full h-10 bg-gray-100 rounded-s-lg text-sm font-semibold focus:outline focus:bg-white text-zinc-600 placeholder:text-zinc-600 px-4 placeholder:text-sm placeholder:font-semibold",
392
- { "outline outline-red-600": errors.securityNumber, "rounded-lg": showCardIDField }
353
+ className: classNames2(
354
+ "w-full h-10 bg-(--pbm-input-background) rounded-lg text-sm font-semibold outline-(--pbm-outline-color) focus:outline focus:bg-(--pbm-input-focus) focus:outline-(--pbm-outline-focus-color) text-zinc-600 placeholder:text-zinc-600 px-4 placeholder:text-sm placeholder:font-semibold",
355
+ {
356
+ "outline outline-red-600": errors.securityNumber,
357
+ "rounded-lg": showCardIDField
358
+ }
393
359
  ),
394
360
  style: {
395
361
  "--tw-outline-color": !errors.securityNumber ? "var(--pbm-secondary)" : void 0
@@ -399,7 +365,7 @@ function Form({ startTransition }) {
399
365
  maxLength: 14,
400
366
  ...register("securityNumber", {
401
367
  onChange: (e) => {
402
- const formatted = toFormat(e.target.value);
368
+ const formatted = formaters.cpf(e.target.value);
403
369
  setValue("securityNumber", formatted, {
404
370
  shouldValidate: true
405
371
  });
@@ -409,24 +375,39 @@ function Form({ startTransition }) {
409
375
  id: "input_security_number_pbm"
410
376
  }
411
377
  ),
412
- errors.securityNumber && /* @__PURE__ */ jsx7("span", { className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap", id: "security_number_form_error", children: errors.securityNumber.message })
378
+ errors.securityNumber && /* @__PURE__ */ jsx2(
379
+ "span",
380
+ {
381
+ className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap",
382
+ id: "security_number_form_error",
383
+ children: errors.securityNumber.message
384
+ }
385
+ )
413
386
  ]
414
387
  }
415
388
  ),
416
- /* @__PURE__ */ jsx7(Activity, { mode: showCardIDField ? "visible" : "hidden", children: /* @__PURE__ */ jsxs3(
389
+ /* @__PURE__ */ jsx2(Activity, { mode: showCardIDField ? "visible" : "hidden", children: /* @__PURE__ */ jsxs(
417
390
  "label",
418
391
  {
419
392
  htmlFor: "coupon",
420
- className: "w-4/5 h-auto flex items-start flex-col justify-center relative py-2",
393
+ className: classNames2(
394
+ "w-full h-auto flex items-start flex-col justify-center relative py-2",
395
+ {
396
+ "mt-2": errors.securityNumber
397
+ }
398
+ ),
421
399
  id: "label_coupon_pbm",
422
400
  children: [
423
- /* @__PURE__ */ jsx7(
401
+ /* @__PURE__ */ jsx2(
424
402
  "input",
425
403
  {
426
404
  type: "text",
427
- className: classNames6(
405
+ className: classNames2(
428
406
  "w-full h-10 bg-gray-100 rounded-s-lg text-sm font-semibold focus:outline focus:bg-white text-zinc-600 placeholder:text-zinc-600 px-4 placeholder:text-sm placeholder:font-semibold",
429
- { "outline outline-red-600": errors.coupon, "rounded-lg": showCardIDField }
407
+ {
408
+ "outline outline-red-600": errors.coupon,
409
+ "rounded-lg": showCardIDField
410
+ }
430
411
  ),
431
412
  style: {
432
413
  "--tw-outline-color": !errors.coupon ? "var(--pbm-secondary)" : void 0
@@ -444,28 +425,37 @@ function Form({ startTransition }) {
444
425
  id: "input_coupon_pbm"
445
426
  }
446
427
  ),
447
- errors.coupon && /* @__PURE__ */ jsx7("span", { className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap", id: "coupon_form_error", children: errors.coupon.message })
428
+ errors.coupon && /* @__PURE__ */ jsx2(
429
+ "span",
430
+ {
431
+ className: "text-red-400 text-xs font-semibold absolute -bottom-3 left-2 text-nowrap",
432
+ id: "coupon_form_error",
433
+ children: errors.coupon.message
434
+ }
435
+ )
448
436
  ]
449
437
  }
450
438
  ) }),
451
- /* @__PURE__ */ jsx7(
439
+ /* @__PURE__ */ jsx2(
452
440
  "button",
453
441
  {
454
442
  type: "submit",
455
- className: classNames6(
456
- "w-1/5 h-10 rounded-e-lg flex items-center justify-center cursor-pointer",
457
- { "rounded-lg": showCardIDField }
443
+ className: classNames2(
444
+ "w-full h-10 rounded-lg flex items-center justify-center cursor-pointer text-sm text-white font-semibold transition-all duration-150",
445
+ {
446
+ "rounded-lg": showCardIDField
447
+ }
458
448
  ),
459
449
  style: { backgroundColor: "var(--pbm-primary)" },
460
450
  id: "button_submit_security_number_pbm",
461
- children: /* @__PURE__ */ jsx7(ArrowRight, { size: 24, color: "white", strokeWidth: 2 })
451
+ children: "Comprar com desconto"
462
452
  }
463
453
  )
464
454
  ]
465
455
  }
466
456
  ),
467
- /* @__PURE__ */ jsxs3("section", { className: "flex items-center-safe justify-between", children: [
468
- /* @__PURE__ */ jsxs3(
457
+ /* @__PURE__ */ jsxs("section", { className: "flex items-start flex-col gap-2", children: [
458
+ /* @__PURE__ */ jsxs(
469
459
  Button_default,
470
460
  {
471
461
  className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
@@ -482,12 +472,21 @@ function Form({ startTransition }) {
482
472
  },
483
473
  id: "check_benefits_button",
484
474
  children: [
485
- /* @__PURE__ */ jsx7("span", { children: !showCardIDField ? "Possui Cupom / ID do Cart\xE3o?" : "N\xE3o possui Cupom / ID do Cart\xE3o??" }),
486
- /* @__PURE__ */ jsx7(ArrowRight, { size: 16, className: classNames6({ "rotate-0": !showCardIDField, "rotate-180": showCardIDField }) })
475
+ /* @__PURE__ */ jsx2("span", { className: "text-start", children: !showCardIDField ? "Possui Cupom / ID do Cart\xE3o?" : "N\xE3o possui Cupom / ID do Cart\xE3o?" }),
476
+ /* @__PURE__ */ jsx2(
477
+ ArrowRight,
478
+ {
479
+ size: 16,
480
+ className: classNames2({
481
+ "rotate-0": !showCardIDField,
482
+ "rotate-180": showCardIDField
483
+ })
484
+ }
485
+ )
487
486
  ]
488
487
  }
489
488
  ),
490
- /* @__PURE__ */ jsxs3(
489
+ /* @__PURE__ */ jsxs(
491
490
  Button_default,
492
491
  {
493
492
  className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
@@ -497,8 +496,8 @@ function Form({ startTransition }) {
497
496
  onClick: () => store.setState("isPreview"),
498
497
  id: "check_benefits_button",
499
498
  children: [
500
- /* @__PURE__ */ jsx7("span", { children: "Consultar Benef\xEDcios" }),
501
- /* @__PURE__ */ jsx7(ArrowRight, { size: 16 })
499
+ /* @__PURE__ */ jsx2("span", { children: "Consultar Benef\xEDcios" }),
500
+ /* @__PURE__ */ jsx2(ArrowRight, { size: 16 })
502
501
  ]
503
502
  }
504
503
  )
@@ -507,86 +506,10 @@ function Form({ startTransition }) {
507
506
  }
508
507
  var Form_default = Form;
509
508
 
510
- // src/components/UI/Loading/index.tsx
511
- import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
512
- function Loading({ textColor }) {
513
- return /* @__PURE__ */ jsxs4("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: [
514
- /* @__PURE__ */ jsx8(
515
- "div",
516
- {
517
- "data-testid": "test_id_spin",
518
- className: "w-8 h-8 border-4 border-gray-300 rounded-full animate-spin",
519
- style: { borderTopColor: "var(--pbm-secondary)" },
520
- id: "loading_spin"
521
- }
522
- ),
523
- /* @__PURE__ */ jsx8(
524
- "p",
525
- {
526
- className: "text-sm font-semibold text-start",
527
- style: { color: textColor || "var(--pbm-text)" },
528
- id: "loading_label",
529
- children: "Um momento... estamos verificando seus dados."
530
- }
531
- )
532
- ] });
533
- }
534
- var Loading_default = Loading;
535
-
536
- // src/services/benefits-without-document.ts
537
- import Cookies2 from "js-cookie";
538
- var CheckBenefistWithoutDocument = async ({ products }) => {
539
- const API_URL = getEnv("VITE_API_URL");
540
- if (!API_URL) {
541
- throw new Error("API URL is not defined in environment variables");
542
- }
543
- const AUTH_TOKEN = Cookies2.get("pbm-token");
544
- if (!AUTH_TOKEN) {
545
- throw new Error("Token is not defined in cookies or is expired");
546
- }
547
- const response = await fetch(`${API_URL}/products/genericBenefit`, {
548
- method: "POST",
549
- headers: {
550
- Authorization: `Bearer ${AUTH_TOKEN}`,
551
- "Content-Type": "application/json"
552
- },
553
- body: JSON.stringify({ products })
554
- });
555
- const dataResponse = await response.json();
556
- if (!dataResponse.success) {
557
- throw new Error(dataResponse.message || "Failed to fetch benefits without document");
558
- }
559
- return dataResponse;
560
- };
561
-
562
- // src/components/BenefitsTable/index.tsx
563
- import { useEffect as useEffect2, useState as useState2, useTransition } from "react";
564
-
565
- // src/libs/zustand/useModal.tsx
566
- import { create as create2 } from "zustand";
567
- var initialModalState = {
568
- modal: {
569
- id: "",
570
- open: false,
571
- label: "",
572
- url: ""
573
- }
574
- };
575
- var createModalStore = (set) => ({
576
- ...initialModalState,
577
- setModal: (modal) => set({ modal }),
578
- resetModal: () => set({ modal: initialModalState.modal })
579
- });
580
- var useModal = create2(createModalStore);
581
-
582
- // src/components/BenefitsTable/Item.tsx
583
- import { useCallback, useEffect } from "react";
584
- import classNames7 from "classnames";
585
-
586
509
  // src/components/UI/Icons/index.tsx
587
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
510
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
588
511
  function CheckON({ size }) {
589
- return /* @__PURE__ */ jsx9(
512
+ return /* @__PURE__ */ jsx3(
590
513
  "svg",
591
514
  {
592
515
  xmlns: "http://www.w3.org/2000/svg",
@@ -594,7 +517,7 @@ function CheckON({ size }) {
594
517
  viewBox: "0 0 500 500",
595
518
  width: size,
596
519
  height: size,
597
- children: /* @__PURE__ */ jsx9(
520
+ children: /* @__PURE__ */ jsx3(
598
521
  "path",
599
522
  {
600
523
  d: "M421.44 78.56C375.64 32.77 314.76 7.55 250 7.55S124.36 32.77 78.56 78.56C32.77 124.36 7.55 185.24 7.55 250s25.22 125.64 71.01 171.44c45.8 45.79 106.68 71.01 171.44 71.01s125.64-25.22 171.44-71.01c45.79-45.8 71.01-106.68 71.01-171.44s-25.22-125.64-71.01-171.44zm-49.17 121.7L242.88 334.63c-8.98 9.29-23.57 10.17-33.59 2.02l-79.63-64.7c-10.69-8.67-12.33-24.38-3.66-35.07 8.67-10.69 24.38-12.33 35.07-3.65l61.9 50.39L336.5 165.74c4.4-4.75 10.48-7.59 16.95-7.93a24.88 24.88 0 0118.83 7.26c9.72 9.72 9.71 25.48 0 35.19z",
@@ -605,7 +528,7 @@ function CheckON({ size }) {
605
528
  );
606
529
  }
607
530
  function CheckOFF({ size }) {
608
- return /* @__PURE__ */ jsxs5(
531
+ return /* @__PURE__ */ jsxs2(
609
532
  "svg",
610
533
  {
611
534
  xmlns: "http://www.w3.org/2000/svg",
@@ -614,8 +537,8 @@ function CheckOFF({ size }) {
614
537
  width: size,
615
538
  height: size,
616
539
  children: [
617
- /* @__PURE__ */ jsx9("circle", { cx: 250, cy: 250, r: 237.45, fill: "#fff" }),
618
- /* @__PURE__ */ jsx9(
540
+ /* @__PURE__ */ jsx3("circle", { cx: 250, cy: 250, r: 237.45, fill: "#fff" }),
541
+ /* @__PURE__ */ jsx3(
619
542
  "path",
620
543
  {
621
544
  d: "M250 492.45c-64.76 0-125.64-25.22-171.44-71.01C32.77 375.64 7.55 314.76 7.55 250S32.77 124.36 78.56 78.56C124.36 32.77 185.24 7.55 250 7.55s125.64 25.22 171.44 71.01c45.79 45.79 71.01 106.68 71.01 171.44s-25.22 125.64-71.01 171.44c-45.79 45.79-106.68 71.01-171.44 71.01zm0-474.9C121.83 17.55 17.55 121.83 17.55 250S121.83 482.45 250 482.45 482.45 378.17 482.45 250 378.17 17.55 250 17.55z",
@@ -626,351 +549,2090 @@ function CheckOFF({ size }) {
626
549
  }
627
550
  );
628
551
  }
629
- var Icons = {
630
- CheckON,
631
- CheckOFF
632
- };
633
-
634
- // src/components/BenefitsTable/Item.tsx
635
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
636
- function Item({ data, onChange, checked }) {
637
- const { setAvailableDiscountSelected, state, isAuthenticatedShopper } = usePBMStore();
638
- const { setModal } = useModal();
639
- const ID_INPUT = "unity_quantity_" + data.authorizedQuantity;
640
- const decimalDiscount = data.discountPercentual / 100;
641
- const unitDiscountValue = data.grossPrice * decimalDiscount;
642
- const discountValue = unitDiscountValue * data.authorizedQuantity;
643
- const totalPriceProductWithDiscountBenefit = data.grossPrice * data.authorizedQuantity - discountValue;
644
- const updateStorageData = useCallback(() => {
645
- if (checked) {
646
- const roundToTwoDecimals = (value) => Math.round(value * 100) / 100;
647
- setAvailableDiscountSelected({
648
- discount: {
649
- total: roundToTwoDecimals(discountValue),
650
- unit: roundToTwoDecimals(unitDiscountValue)
651
- },
652
- quantity: data.authorizedQuantity,
653
- totalPrice: roundToTwoDecimals(totalPriceProductWithDiscountBenefit),
654
- grossPrice: data.grossPrice
655
- });
656
- }
657
- }, [
658
- checked,
659
- data.authorizedQuantity,
660
- setAvailableDiscountSelected,
661
- discountValue,
662
- totalPriceProductWithDiscountBenefit,
663
- unitDiscountValue
664
- ]);
665
- useEffect(() => {
666
- updateStorageData();
667
- }, [updateStorageData]);
668
- const handleChange = () => {
669
- if (!isAuthenticatedShopper && state === "isActivated") {
670
- setModal({
671
- id: "ShopperIsNotAuthenticated",
672
- open: true
673
- });
674
- return;
552
+ function Pills({ size, color }) {
553
+ return /* @__PURE__ */ jsxs2(
554
+ "svg",
555
+ {
556
+ viewBox: "-0.003 0 99.979 99.979",
557
+ xmlns: "http://www.w3.org/2000/svg",
558
+ fill: "#000000",
559
+ width: size,
560
+ height: size,
561
+ children: [
562
+ /* @__PURE__ */ jsx3("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
563
+ /* @__PURE__ */ jsx3(
564
+ "g",
565
+ {
566
+ id: "SVGRepo_tracerCarrier",
567
+ strokeLinecap: "round",
568
+ strokeLinejoin: "round"
569
+ }
570
+ ),
571
+ /* @__PURE__ */ jsxs2("g", { id: "SVGRepo_iconCarrier", children: [
572
+ /* @__PURE__ */ jsx3(
573
+ "path",
574
+ {
575
+ fill: "#ffe700",
576
+ d: "M92.869 7.105c9.478 9.476 9.478 24.832 0 34.308L41.411 92.869c-9.475 9.474-24.833 9.474-34.307 0-9.476-9.475-9.476-24.832 0-34.308L58.562 7.105c9.475-9.473 24.834-9.473 34.307 0z"
577
+ }
578
+ ),
579
+ /* @__PURE__ */ jsx3(
580
+ "path",
581
+ {
582
+ fill: color,
583
+ d: "M32.548 33.122L7.105 58.563c-9.476 9.476-9.476 24.833 0 34.308 9.474 9.475 24.832 9.475 34.307 0L66.85 67.43 32.548 33.122z"
584
+ }
585
+ ),
586
+ /* @__PURE__ */ jsx3(
587
+ "path",
588
+ {
589
+ fill: color,
590
+ d: "M65.43 68.862L31.134 34.568l1.414-1.414 34.294 34.294z"
591
+ }
592
+ ),
593
+ /* @__PURE__ */ jsx3(
594
+ "path",
595
+ {
596
+ fill: color,
597
+ d: "M38.096 41.51L12.7 66.906a5.894 5.894 0 0 0 0 8.339 5.896 5.896 0 0 0 8.339 0l25.396-25.396-8.339-8.339z"
598
+ }
599
+ ),
600
+ /* @__PURE__ */ jsx3(
601
+ "path",
602
+ {
603
+ fill: "#ffe700",
604
+ d: "M75.244 12.7a5.897 5.897 0 0 0-8.343 0L39.51 40.096l8.339 8.339 27.396-27.396a5.899 5.899 0 0 0-.001-8.339z"
605
+ }
606
+ ),
607
+ /* @__PURE__ */ jsx3(
608
+ "path",
609
+ {
610
+ fill: color,
611
+ d: "M47.862 48.444l-1.414 1.414-8.335-8.336 1.414-1.414z"
612
+ }
613
+ )
614
+ ] })
615
+ ]
675
616
  }
676
- onChange();
677
- };
678
- return /* @__PURE__ */ jsxs6(
679
- "label",
617
+ );
618
+ }
619
+ function ArrowDown({ size, color }) {
620
+ return /* @__PURE__ */ jsxs2(
621
+ "svg",
680
622
  {
681
- htmlFor: ID_INPUT,
682
- className: classNames7(
683
- "label_benefits w-full flex items-center justify-start bg-zinc-300/60 border border-zinc-400/50 px-4 py-2 transition-colors rounded-lg gap-1",
684
- { "cursor-not-allowed": state === "isPreview", "cursor-pointer": state === "isActivated", "opacity-80": !checked && state === "isActivated" }
685
- ),
686
- style: {
687
- borderColor: checked ? "var(--pbm-primary)" : void 0,
688
- backgroundColor: checked ? "color-mix(in srgb, var(--pbm-primary), transparent 90%)" : void 0
689
- },
690
- id: "label_benefits_" + ID_INPUT,
623
+ viewBox: "0 0 24 24",
624
+ fill: "none",
625
+ xmlns: "http://www.w3.org/2000/svg",
626
+ width: size,
627
+ height: size,
691
628
  children: [
692
- /* @__PURE__ */ jsx10(
693
- "input",
629
+ /* @__PURE__ */ jsx3("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
630
+ /* @__PURE__ */ jsx3(
631
+ "g",
694
632
  {
695
- type: "radio",
696
- name: "benefits_discount",
697
- id: ID_INPUT,
698
- className: "hidden",
699
- checked,
700
- onChange: handleChange,
701
- disabled: state === "isPreview"
633
+ id: "SVGRepo_tracerCarrier",
634
+ strokeLinecap: "round",
635
+ strokeLinejoin: "round"
702
636
  }
703
637
  ),
704
- /* @__PURE__ */ jsx10("span", { style: { color: "var(--pbm-primary)" }, children: !checked ? /* @__PURE__ */ jsx10(Icons.CheckOFF, { size: 20 }) : /* @__PURE__ */ jsx10(Icons.CheckON, { size: 20 }) }),
705
- /* @__PURE__ */ jsxs6("span", { className: "font-semibold text-sm", style: { color: "var(--pbm-text)" }, children: [
706
- data.authorizedQuantity,
707
- "un"
708
- ] }),
709
- /* @__PURE__ */ jsxs6("section", { className: "ml-auto relative gap-2 flex items-center-safe justify-end-safe", children: [
710
- /* @__PURE__ */ jsxs6(
711
- "span",
638
+ /* @__PURE__ */ jsx3("g", { id: "SVGRepo_iconCarrier", children: /* @__PURE__ */ jsx3(
639
+ "path",
640
+ {
641
+ d: "M7.33199 16.3154C6.94146 15.9248 6.3083 15.9248 5.91777 16.3154C5.52725 16.7059 5.52725 17.339 5.91777 17.7296L10.5834 22.3952C11.3644 23.1762 12.6308 23.1762 13.4118 22.3952L18.0802 17.7267C18.4707 17.3362 18.4707 16.703 18.0802 16.3125C17.6897 15.922 17.0565 15.922 16.666 16.3125L13 19.9786V2.0001C13 1.44781 12.5523 1.0001 12 1.0001C11.4477 1.0001 11 1.44781 11 2.0001V19.9833L7.33199 16.3154Z",
642
+ fill: color
643
+ }
644
+ ) })
645
+ ]
646
+ }
647
+ );
648
+ }
649
+ var Icons = {
650
+ CheckON,
651
+ CheckOFF,
652
+ Pills,
653
+ ArrowDown
654
+ };
655
+
656
+ // src/components/Header/index.tsx
657
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
658
+ function Header({ originalProductPrice }) {
659
+ const { targetProduct, benefitsEnabled, setBenefitsEnabled } = usePBMStore();
660
+ const Price = targetProduct?.listPrice || originalProductPrice;
661
+ const Discount = Price * ((targetProduct?.discountMax || 0) / 100);
662
+ return /* @__PURE__ */ jsxs3(
663
+ "header",
664
+ {
665
+ className: "flex items-start justify-start flex-col gap-4 w-full p-0.5 rounded-xl mt-5",
666
+ id: "header_pbm",
667
+ children: [
668
+ /* @__PURE__ */ jsxs3("label", { className: "flex items-center gap-2 cursor-pointer", children: [
669
+ /* @__PURE__ */ jsx4(
670
+ "input",
712
671
  {
713
- className: "text-white -top-4 py-0.5 font-semibold text-xs px-2 w-auto text-nowrap rounded-2xl -right-3",
714
- style: { backgroundColor: "var(--pbm-primary)" },
715
- children: [
716
- discountValue.toLocaleString("pt-BR", {
672
+ type: "checkbox",
673
+ name: "option",
674
+ className: "peer hidden",
675
+ checked: benefitsEnabled,
676
+ onChange: (e) => setBenefitsEnabled(e.target.checked)
677
+ }
678
+ ),
679
+ /* @__PURE__ */ jsx4("div", { className: "w-5 h-5 border border-(--pbm-primary) rounded-full flex items-center justify-center transition-all duration-300 after:content-[''] after:w-2 after:h-2 after:rounded-full after:bg-(--pbm-primary) after:scale-0 after:transition-transform after:duration-200 peer-checked:after:scale-100" }),
680
+ /* @__PURE__ */ jsx4("p", { className: "font-medium text-(--pbm-primary) select-none text-sm", children: "Desconto de Laborat\xF3rio" }),
681
+ /* @__PURE__ */ jsx4(Icons.Pills, { size: 16, color: "var(--pbm-primary)" })
682
+ ] }),
683
+ /* @__PURE__ */ jsx4(
684
+ "span",
685
+ {
686
+ className: "py-1 rounded-xl shrink-0 text-white text-xl font-bold flex items-center justify-start gap-2 relative",
687
+ "data-testid": "test_id_header_price",
688
+ id: "header_price",
689
+ children: /* @__PURE__ */ jsxs3("section", { className: "flex items-start gap-2 justify-center-safe flex-col", children: [
690
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center-safe justify-start gap-1", children: [
691
+ /* @__PURE__ */ jsx4("span", { className: "line-through text-sm font-light text-zinc-600", children: Number(Price)?.toLocaleString("pt-BR", {
717
692
  currency: "BRL",
718
693
  currencyDisplay: "symbol",
719
694
  currencySign: "standard",
720
695
  style: "currency"
721
- }),
722
- " ",
723
- "OFF"
724
- ]
725
- }
726
- ),
727
- /* @__PURE__ */ jsx10("strong", { className: "font-semibold text-sm text-center", style: { color: "var(--pbm-text)" }, children: totalPriceProductWithDiscountBenefit.toLocaleString("pt-BR", {
728
- currency: "BRL",
729
- currencyDisplay: "symbol",
730
- currencySign: "standard",
731
- style: "currency"
732
- }) })
733
- ] })
696
+ }) }),
697
+ /* @__PURE__ */ jsx4(Icons.ArrowDown, { size: 14, color: "var(--pbm-primary)" }),
698
+ /* @__PURE__ */ jsxs3("span", { className: "font-semibold text-sm text-(--pbm-primary)", children: [
699
+ (targetProduct?.discountMax || 0).toFixed(2),
700
+ "%"
701
+ ] })
702
+ ] }),
703
+ /* @__PURE__ */ jsx4("span", { className: "text-lg text-zinc-700 font-bold", children: Number(Price - Discount)?.toLocaleString("pt-BR", {
704
+ currency: "BRL",
705
+ currencyDisplay: "symbol",
706
+ currencySign: "standard",
707
+ style: "currency"
708
+ }) }),
709
+ targetProduct?.informativeMessage && /* @__PURE__ */ jsx4("span", { className: "text-xs text-zinc-600 font-medium", children: targetProduct?.informativeMessage })
710
+ ] })
711
+ }
712
+ )
734
713
  ]
735
714
  }
736
715
  );
737
716
  }
738
- var Item_default = Item;
717
+ var Header_default = Header;
739
718
 
740
- // src/components/BenefitsTable/index.tsx
741
- import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
742
- function BenefitsTable() {
743
- const [isPending, startTransition] = useTransition();
744
- const { securityNumber, setState, state, targetProduct, customLoginUrl, isAuthenticatedShopper } = usePBMStore();
745
- const [selectedDiscout, setSelectedDiscount] = useState2(null);
746
- const [benefitsItems, setBenefitsItems] = useState2();
747
- useEffect2(() => {
748
- if (!targetProduct?.productId) {
749
- console.error("PBMLOG: Product ID is not defined on targetProduct");
750
- return;
751
- }
752
- if (!targetProduct.ean) {
753
- console.error("PBMLOG: EAN is not defined on targetProduct");
719
+ // src/components/Iframe/index.tsx
720
+ import classNames5 from "classnames";
721
+ import { TriangleAlert, ExternalLink } from "lucide-react";
722
+ import { useState as useState2, useEffect } from "react";
723
+
724
+ // src/components/UI/Title/index.tsx
725
+ import classNames3 from "classnames";
726
+ import { jsx as jsx5 } from "react/jsx-runtime";
727
+ function Title(props) {
728
+ return /* @__PURE__ */ jsx5(
729
+ "h2",
730
+ {
731
+ className: classNames3(
732
+ "text-start font-semibold text-sm",
733
+ props.className
734
+ ),
735
+ style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
736
+ "data-testid": "test_id_title",
737
+ id: "title_pbm",
738
+ children: props.children
739
+ }
740
+ );
741
+ }
742
+ var Title_default = Title;
743
+
744
+ // src/components/UI/Text/index.tsx
745
+ import classNames4 from "classnames";
746
+ import { jsx as jsx6 } from "react/jsx-runtime";
747
+ function Text(props) {
748
+ return /* @__PURE__ */ jsx6(
749
+ "p",
750
+ {
751
+ className: classNames4(
752
+ "font-normal text-sm",
753
+ props.textAlign && `text-${props.textAlign}`,
754
+ props.className
755
+ ),
756
+ style: { color: props.textColor || "var(--pbm-text)", fontSize: props.textSize, textAlign: props.textAlign },
757
+ "data-testid": "test_id_text",
758
+ id: "text_pbm",
759
+ children: props.children
760
+ }
761
+ );
762
+ }
763
+ var Text_default = Text;
764
+
765
+ // src/components/Iframe/index.tsx
766
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
767
+ function Iframe() {
768
+ const [showFallback, setShowFallback] = useState2(false);
769
+ const { setState } = usePBMStore();
770
+ const { resetModal, modal } = useModal();
771
+ const isOpen = modal.open && modal.id === "iframe_pbm";
772
+ useEffect(() => {
773
+ if (isOpen) {
774
+ setShowFallback(false);
775
+ }
776
+ }, [isOpen, modal.url]);
777
+ const handleOpenInNewWindow = () => {
778
+ if (modal.url) {
779
+ window.open(modal.url, "_blank", "noopener,noreferrer");
780
+ }
781
+ };
782
+ const handleClose = () => {
783
+ setState("isEmpty");
784
+ resetModal();
785
+ };
786
+ if (!modal.url) return;
787
+ return /* @__PURE__ */ jsxs4(
788
+ "main",
789
+ {
790
+ className: classNames5(
791
+ "fixed inset-0 flex items-center justify-center z-50 flex-col transition-all duration-300 pt-[10%]",
792
+ isOpen ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
793
+ ),
794
+ id: "iframe_pbm",
795
+ children: [
796
+ /* @__PURE__ */ jsx7(
797
+ "div",
798
+ {
799
+ className: "bg-black/40 inset-0 absolute backdrop-blur-sm",
800
+ onClick: handleClose
801
+ }
802
+ ),
803
+ /* @__PURE__ */ jsxs4("section", { className: "w-[90%] md:w-4/5 gap-4 h-auto bg-zinc-900 py-3 px-6 flex items-center justify-end rounded-t-2xl border-b border-white/10 z-10 shadow-2xl", children: [
804
+ /* @__PURE__ */ jsx7(
805
+ Button_default,
806
+ {
807
+ onClick: handleClose,
808
+ className: "bg-red-500 hover:bg-red-400 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
809
+ children: "Cancelar"
810
+ }
811
+ ),
812
+ /* @__PURE__ */ jsx7(
813
+ Button_default,
814
+ {
815
+ onClick: handleClose,
816
+ className: "bg-blue-600 hover:bg-blue-500 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
817
+ children: "Finalizei o formul\xE1rio"
818
+ }
819
+ )
820
+ ] }),
821
+ /* @__PURE__ */ jsx7("div", { className: "w-[90%] md:w-4/5 h-[60vh] bg-zinc-900 z-10 overflow-hidden relative shadow-2xl", children: showFallback ? /* @__PURE__ */ jsxs4("div", { className: "absolute inset-0 flex flex-col items-center justify-center p-8 text-center bg-zinc-900", children: [
822
+ /* @__PURE__ */ jsx7("div", { className: "bg-yellow-500/10 p-4 rounded-full mb-4 animate-pulse", children: /* @__PURE__ */ jsx7(TriangleAlert, { size: 48, className: "text-yellow-500" }) }),
823
+ /* @__PURE__ */ jsx7(Title_default, { textColor: "white", textSize: "20px", textAlign: "center", className: "mb-2", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
824
+ /* @__PURE__ */ jsx7(Text_default, { textColor: "#a1a1aa", textAlign: "center", className: "mb-8 max-w-md", children: "Este conte\xFAdo n\xE3o permite exibi\xE7\xE3o integrada por seguran\xE7a. Clique no bot\xE3o abaixo para concluir em uma nova aba." }),
825
+ /* @__PURE__ */ jsxs4(
826
+ Button_default,
827
+ {
828
+ onClick: handleOpenInNewWindow,
829
+ className: "flex items-center gap-2 w-auto px-8 h-12 shadow-xl shadow-emerald-500/20",
830
+ children: [
831
+ /* @__PURE__ */ jsx7(ExternalLink, { size: 18 }),
832
+ "Abrir em nova janela"
833
+ ]
834
+ }
835
+ )
836
+ ] }) : /* @__PURE__ */ jsx7(
837
+ "iframe",
838
+ {
839
+ src: modal.url,
840
+ title: modal.label ?? "Conte\xFAdo PBM",
841
+ className: "w-full h-full border-none bg-white animate-fade-in",
842
+ allowFullScreen: true,
843
+ onError: () => setShowFallback(true)
844
+ }
845
+ ) }),
846
+ /* @__PURE__ */ jsxs4("section", { className: "w-[90%] md:w-4/5 flex flex-col md:flex-row items-center justify-between gap-3 bg-zinc-900 py-4 px-6 rounded-b-2xl border-t border-white/5 z-10 shadow-2xl", children: [
847
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
848
+ /* @__PURE__ */ jsx7(TriangleAlert, { size: 18, className: "text-yellow-500 shrink-0" }),
849
+ /* @__PURE__ */ jsxs4(Text_default, { textColor: "white", className: "text-[10px] md:text-xs", children: [
850
+ /* @__PURE__ */ jsx7("span", { className: "text-yellow-500 font-bold mr-1", children: "Importante:" }),
851
+ "Se a p\xE1gina n\xE3o carregar, tente abrir em tela cheia usando o bot\xE3o ao lado."
852
+ ] })
853
+ ] }),
854
+ /* @__PURE__ */ jsxs4(
855
+ "button",
856
+ {
857
+ onClick: handleOpenInNewWindow,
858
+ className: "text-white/60 hover:text-white text-[11px] underline flex items-center gap-1 transition-colors cursor-pointer",
859
+ children: [
860
+ /* @__PURE__ */ jsx7(ExternalLink, { size: 14 }),
861
+ " Abrir em nova aba"
862
+ ]
863
+ }
864
+ )
865
+ ] })
866
+ ]
867
+ }
868
+ );
869
+ }
870
+ var Iframe_default = Iframe;
871
+
872
+ // src/components/UI/Loading/index.tsx
873
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
874
+ function Loading({ textColor }) {
875
+ return /* @__PURE__ */ jsxs5("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: [
876
+ /* @__PURE__ */ jsx8(
877
+ "div",
878
+ {
879
+ "data-testid": "test_id_spin",
880
+ className: "w-8 h-8 border-4 border-gray-300 rounded-full animate-spin",
881
+ style: { borderTopColor: "var(--pbm-secondary)" },
882
+ id: "loading_spin"
883
+ }
884
+ ),
885
+ /* @__PURE__ */ jsx8(
886
+ "p",
887
+ {
888
+ className: "text-sm font-semibold text-start",
889
+ style: { color: textColor || "var(--pbm-text)" },
890
+ id: "loading_label",
891
+ children: "Um momento... estamos verificando seus dados."
892
+ }
893
+ )
894
+ ] });
895
+ }
896
+ var Loading_default = Loading;
897
+
898
+ // src/components/UI/Container/index.tsx
899
+ import classNames6 from "classnames";
900
+ import { jsx as jsx9 } from "react/jsx-runtime";
901
+ function Container({
902
+ children,
903
+ variant
904
+ }) {
905
+ const { benefitsEnabled } = usePBMStore();
906
+ return /* @__PURE__ */ jsx9(
907
+ "main",
908
+ {
909
+ className: classNames6({
910
+ "border-3 border-(--pbm-border) overflow-hidden flex flex-col items-center justify-center min-w-(--min-container) max-w-(--max-container) w-full h-auto rounded-xl p-4 bg-white gap-4 relative": variant === "main",
911
+ "w-full relative": variant === "simple",
912
+ "h-0 overflow-hidden": !benefitsEnabled && variant === "simple"
913
+ }),
914
+ "data-testid": "test_id_container",
915
+ "data-variant": variant,
916
+ id: "container_pbm",
917
+ children
918
+ }
919
+ );
920
+ }
921
+ var Container_default = Container;
922
+
923
+ // src/services/activate-customer.ts
924
+ import Cookies2 from "js-cookie";
925
+ var ActivateCustomer = async ({ document, requestId, products }) => {
926
+ const API_URL = getEnv("VITE_API_URL");
927
+ if (!API_URL) {
928
+ throw new Error("API URL is not defined in environment variables");
929
+ }
930
+ const AUTH_TOKEN = Cookies2.get("pbm-token");
931
+ if (!AUTH_TOKEN) {
932
+ throw new Error("Token is not defined in cookies or is expired");
933
+ }
934
+ const response = await fetch(`${API_URL}/programregistration/activate`, {
935
+ method: "POST",
936
+ headers: {
937
+ Authorization: `Bearer ${AUTH_TOKEN}`,
938
+ "Content-Type": "application/json"
939
+ },
940
+ body: JSON.stringify({ document, requestId, products })
941
+ });
942
+ const dataResponse = await response.json();
943
+ if (!dataResponse.success) {
944
+ throw new Error(dataResponse.message || "Failed to fetch document validation");
945
+ }
946
+ return dataResponse;
947
+ };
948
+
949
+ // src/services/benefits-without-document.ts
950
+ import Cookies3 from "js-cookie";
951
+ var CheckBenefistWithoutDocument = async ({ products }) => {
952
+ const API_URL = getEnv("VITE_API_URL");
953
+ if (!API_URL) {
954
+ throw new Error("API URL is not defined in environment variables");
955
+ }
956
+ const AUTH_TOKEN = Cookies3.get("pbm-token");
957
+ if (!AUTH_TOKEN) {
958
+ throw new Error("Token is not defined in cookies or is expired");
959
+ }
960
+ const response = await fetch(`${API_URL}/products/genericBenefit`, {
961
+ method: "POST",
962
+ headers: {
963
+ Authorization: `Bearer ${AUTH_TOKEN}`,
964
+ "Content-Type": "application/json"
965
+ },
966
+ body: JSON.stringify({ products })
967
+ });
968
+ const dataResponse = await response.json();
969
+ if (!dataResponse.success) {
970
+ throw new Error(dataResponse.message || "Failed to fetch benefits without document");
971
+ }
972
+ return dataResponse;
973
+ };
974
+
975
+ // src/components/BenefitsTable/index.tsx
976
+ import { useEffect as useEffect3, useState as useState3, useTransition } from "react";
977
+
978
+ // src/components/BenefitsTable/Item.tsx
979
+ import { useCallback, useEffect as useEffect2 } from "react";
980
+ import classNames7 from "classnames";
981
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
982
+ function Item({ data, onChange, checked }) {
983
+ const { setAvailableDiscountSelected, state, isAuthenticatedShopper } = usePBMStore();
984
+ const { setModal } = useModal();
985
+ const ID_INPUT = "unity_quantity_" + data.authorizedQuantity;
986
+ const decimalDiscount = data.discountPercentual / 100;
987
+ const unitDiscountValue = data.grossPrice * decimalDiscount;
988
+ const discountValue = unitDiscountValue * data.authorizedQuantity;
989
+ const totalPriceProductWithDiscountBenefit = data.grossPrice * data.authorizedQuantity - discountValue;
990
+ const updateStorageData = useCallback(() => {
991
+ if (checked) {
992
+ const roundToTwoDecimals = (value) => Math.round(value * 100) / 100;
993
+ setAvailableDiscountSelected({
994
+ discount: {
995
+ total: roundToTwoDecimals(discountValue),
996
+ unit: roundToTwoDecimals(unitDiscountValue)
997
+ },
998
+ quantity: data.authorizedQuantity,
999
+ totalPrice: roundToTwoDecimals(totalPriceProductWithDiscountBenefit),
1000
+ grossPrice: data.grossPrice
1001
+ });
1002
+ }
1003
+ }, [
1004
+ checked,
1005
+ data.authorizedQuantity,
1006
+ data.grossPrice,
1007
+ setAvailableDiscountSelected,
1008
+ discountValue,
1009
+ totalPriceProductWithDiscountBenefit,
1010
+ unitDiscountValue
1011
+ ]);
1012
+ useEffect2(() => {
1013
+ updateStorageData();
1014
+ }, [updateStorageData]);
1015
+ const handleChange = () => {
1016
+ if (!isAuthenticatedShopper && state === "isActivated") {
1017
+ setModal({
1018
+ id: "ShopperIsNotAuthenticated",
1019
+ open: true
1020
+ });
1021
+ return;
1022
+ }
1023
+ onChange();
1024
+ };
1025
+ return /* @__PURE__ */ jsxs6(
1026
+ "label",
1027
+ {
1028
+ htmlFor: ID_INPUT,
1029
+ className: classNames7(
1030
+ "label_benefits w-full flex items-center justify-start bg-zinc-300/60 border border-zinc-400/50 px-4 py-2 transition-colors rounded-lg gap-1",
1031
+ {
1032
+ "cursor-not-allowed": state === "isPreview",
1033
+ "cursor-pointer": state === "isActivated",
1034
+ "opacity-80": !checked && state === "isActivated"
1035
+ }
1036
+ ),
1037
+ style: {
1038
+ borderColor: checked ? "var(--pbm-primary)" : void 0,
1039
+ backgroundColor: checked ? "color-mix(in srgb, var(--pbm-primary), transparent 90%)" : void 0
1040
+ },
1041
+ id: "label_benefits_" + ID_INPUT,
1042
+ children: [
1043
+ /* @__PURE__ */ jsx10(
1044
+ "input",
1045
+ {
1046
+ type: "radio",
1047
+ name: "benefits_discount",
1048
+ id: ID_INPUT,
1049
+ className: "hidden",
1050
+ checked,
1051
+ onChange: handleChange,
1052
+ disabled: state === "isPreview"
1053
+ }
1054
+ ),
1055
+ /* @__PURE__ */ jsx10("span", { style: { color: "var(--pbm-primary)" }, children: !checked ? /* @__PURE__ */ jsx10(Icons.CheckOFF, { size: 20 }) : /* @__PURE__ */ jsx10(Icons.CheckON, { size: 20 }) }),
1056
+ /* @__PURE__ */ jsxs6(
1057
+ "span",
1058
+ {
1059
+ className: "font-semibold text-sm",
1060
+ style: { color: "var(--pbm-text)" },
1061
+ children: [
1062
+ data.authorizedQuantity,
1063
+ "un"
1064
+ ]
1065
+ }
1066
+ ),
1067
+ /* @__PURE__ */ jsxs6("section", { className: "ml-auto relative gap-2 flex items-center-safe justify-end-safe", children: [
1068
+ /* @__PURE__ */ jsxs6(
1069
+ "span",
1070
+ {
1071
+ className: "text-white -top-4 py-0.5 font-semibold text-xs px-2 w-auto text-nowrap rounded-2xl -right-3",
1072
+ style: { backgroundColor: "var(--pbm-primary)" },
1073
+ children: [
1074
+ discountValue.toLocaleString("pt-BR", {
1075
+ currency: "BRL",
1076
+ currencyDisplay: "symbol",
1077
+ currencySign: "standard",
1078
+ style: "currency"
1079
+ }),
1080
+ " ",
1081
+ "OFF"
1082
+ ]
1083
+ }
1084
+ ),
1085
+ /* @__PURE__ */ jsx10(
1086
+ "strong",
1087
+ {
1088
+ className: "font-semibold text-sm text-center",
1089
+ style: { color: "var(--pbm-text)" },
1090
+ children: totalPriceProductWithDiscountBenefit.toLocaleString("pt-BR", {
1091
+ currency: "BRL",
1092
+ currencyDisplay: "symbol",
1093
+ currencySign: "standard",
1094
+ style: "currency"
1095
+ })
1096
+ }
1097
+ )
1098
+ ] })
1099
+ ]
1100
+ }
1101
+ );
1102
+ }
1103
+ var Item_default = Item;
1104
+
1105
+ // src/components/BenefitsTable/index.tsx
1106
+ import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
1107
+ function BenefitsTable() {
1108
+ const [isPending, startTransition] = useTransition();
1109
+ const {
1110
+ securityNumber,
1111
+ setState,
1112
+ state,
1113
+ targetProduct,
1114
+ customLoginUrl,
1115
+ isAuthenticatedShopper,
1116
+ requestId
1117
+ } = usePBMStore();
1118
+ const [selectedDiscout, setSelectedDiscount] = useState3(null);
1119
+ const [benefitsItems, setBenefitsItems] = useState3();
1120
+ useEffect3(() => {
1121
+ if (!targetProduct?.productId) {
1122
+ console.error("PBMLOG: Product ID is not defined on targetProduct");
754
1123
  return;
755
1124
  }
756
- if (!targetProduct.listPrice) {
757
- console.error("PBMLOG: List Price is not defined on targetProduct");
758
- return;
1125
+ if (!targetProduct.ean) {
1126
+ console.error("PBMLOG: EAN is not defined on targetProduct");
1127
+ return;
1128
+ }
1129
+ if (!targetProduct.listPrice) {
1130
+ console.error("PBMLOG: List Price is not defined on targetProduct");
1131
+ return;
1132
+ }
1133
+ if (!targetProduct.price) {
1134
+ console.error("PBMLOG: Price is not defined on targetProduct");
1135
+ return;
1136
+ }
1137
+ const fetchDicountsWithoutDocument = async () => {
1138
+ try {
1139
+ const data = {
1140
+ productId: Number(targetProduct.productId),
1141
+ ean: targetProduct.ean,
1142
+ requestedQuantity: 1,
1143
+ listPrice: targetProduct.listPrice,
1144
+ netPrice: targetProduct.price
1145
+ };
1146
+ const response = await CheckBenefistWithoutDocument({
1147
+ products: [data]
1148
+ });
1149
+ if (response.success && response.data) {
1150
+ setBenefitsItems(response.data);
1151
+ } else {
1152
+ setBenefitsItems(void 0);
1153
+ }
1154
+ } catch (error) {
1155
+ setBenefitsItems(void 0);
1156
+ console.error(error);
1157
+ }
1158
+ };
1159
+ const fetchDiscountWithDocument = async () => {
1160
+ if (!securityNumber) {
1161
+ console.error("PBMLOG: Document is not defined");
1162
+ return;
1163
+ }
1164
+ if (!requestId) {
1165
+ console.error("PBMLOG: Request ID is not defined");
1166
+ return;
1167
+ }
1168
+ try {
1169
+ const data = {
1170
+ productId: Number(targetProduct.productId),
1171
+ ean: targetProduct.ean,
1172
+ quantity: 1,
1173
+ listPrice: targetProduct.listPrice
1174
+ };
1175
+ const response = await ActivateCustomer({
1176
+ document: securityNumber,
1177
+ requestId,
1178
+ products: [data]
1179
+ });
1180
+ if (response.success && response.data) {
1181
+ setBenefitsItems(response.data.product);
1182
+ } else {
1183
+ setBenefitsItems(void 0);
1184
+ }
1185
+ } catch (error) {
1186
+ setBenefitsItems(void 0);
1187
+ console.error(error);
1188
+ }
1189
+ };
1190
+ startTransition(async () => {
1191
+ if (state === "isActivated") {
1192
+ await fetchDiscountWithDocument();
1193
+ } else {
1194
+ await fetchDicountsWithoutDocument();
1195
+ }
1196
+ });
1197
+ }, []);
1198
+ if (isPending) {
1199
+ return /* @__PURE__ */ jsx11(Loading_default, { textColor: "var(--pbm-text)" });
1200
+ }
1201
+ if (benefitsItems?.length && benefitsItems[0]?.statusCode == null && state === "isActivated") {
1202
+ return /* @__PURE__ */ jsx11("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: /* @__PURE__ */ jsx11(
1203
+ "p",
1204
+ {
1205
+ className: "text-sm font-semibold text-start",
1206
+ style: { color: "var(--pbm-text)" },
1207
+ id: "benefits_error_handle",
1208
+ children: benefitsItems[0].informativeText
1209
+ }
1210
+ ) });
1211
+ }
1212
+ return /* @__PURE__ */ jsxs7(
1213
+ "section",
1214
+ {
1215
+ className: "flex items-start justify-center gap-4 w-full h-auto flex-col",
1216
+ id: "benefits_table_pbm",
1217
+ children: [
1218
+ /* @__PURE__ */ jsx11(Title_default, { children: "Descontos dispon\xEDveis:" }),
1219
+ /* @__PURE__ */ jsxs7(
1220
+ "form",
1221
+ {
1222
+ className: "flex flex-col items-center justify-start w-full gap-4.5",
1223
+ id: "form_benefits_table_pbm",
1224
+ onSubmit: (e) => e.preventDefault(),
1225
+ children: [
1226
+ !benefitsItems && /* @__PURE__ */ jsx11(
1227
+ "p",
1228
+ {
1229
+ className: "text-sm font-semibold text-start text-zinc-900",
1230
+ id: "benefits_empty_pbm",
1231
+ children: "N\xE3o foi poss\xEDvel encontrar benef\xEDcios para esse produto."
1232
+ }
1233
+ ),
1234
+ benefitsItems && benefitsItems.map((item, index) => {
1235
+ const ID_INPUT = "unity_quantity_" + item.authorizedQuantity;
1236
+ return /* @__PURE__ */ jsx11(
1237
+ Item_default,
1238
+ {
1239
+ data: item,
1240
+ checked: selectedDiscout === ID_INPUT,
1241
+ onChange: () => setSelectedDiscount(ID_INPUT)
1242
+ },
1243
+ index
1244
+ );
1245
+ })
1246
+ ]
1247
+ }
1248
+ ),
1249
+ state === "isPreview" && /* @__PURE__ */ jsxs7(
1250
+ Button_default,
1251
+ {
1252
+ onClick: () => setState("isEmpty"),
1253
+ className: "bg-transparent p-0 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
1254
+ id: "unauthorized_benefits_button",
1255
+ children: [
1256
+ "Aten\xE7\xE3o: N\xE3o \xE9 poss\xEDvel utilizar os benef\xEDcos sem realizar a consulta do CPF e o Login, por favor",
1257
+ " ",
1258
+ /* @__PURE__ */ jsx11("span", { className: "underline", children: "insira seu cpf para utilizar os benef\xEDcios" })
1259
+ ]
1260
+ }
1261
+ ),
1262
+ state === "isActivated" && /* @__PURE__ */ jsxs7(Fragment2, { children: [
1263
+ !isAuthenticatedShopper && /* @__PURE__ */ jsx11(
1264
+ Button_default,
1265
+ {
1266
+ type: "button",
1267
+ onClick: () => window.location.assign(customLoginUrl || "/login"),
1268
+ className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
1269
+ id: "login",
1270
+ children: /* @__PURE__ */ jsx11("span", { className: "underline", children: "Por favor, fa\xE7a o Login para aproveitar os benef\xEDcios!" })
1271
+ }
1272
+ ),
1273
+ /* @__PURE__ */ jsx11(
1274
+ Button_default,
1275
+ {
1276
+ onClick: () => setState("isEmpty"),
1277
+ className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
1278
+ id: "change_security_number",
1279
+ children: /* @__PURE__ */ jsx11("span", { className: "underline", children: "Deseja editar o cpf digitado?" })
1280
+ }
1281
+ )
1282
+ ] })
1283
+ ]
1284
+ }
1285
+ );
1286
+ }
1287
+ var BenefitsTable_default = BenefitsTable;
1288
+
1289
+ // src/components/SecurityNumberInvalid/index.tsx
1290
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
1291
+ function SecurityNumberInvalid({ textColor }) {
1292
+ const { urlAcceptTerms } = usePBMStore();
1293
+ const { setModal } = useModal();
1294
+ const handleOpenModal = () => {
1295
+ if (!urlAcceptTerms) return;
1296
+ setModal({ open: true, id: "iframe_pbm", label: "Aceitar os termos", url: urlAcceptTerms });
1297
+ };
1298
+ return /* @__PURE__ */ jsxs8(
1299
+ "section",
1300
+ {
1301
+ "data-testid": "test_id_invalid",
1302
+ className: "flex items-end justify-center gap-2 w-full h-auto flex-col border-y py-6",
1303
+ style: { borderColor: "color-mix(in srgb, var(--pbm-text), transparent 80%)" },
1304
+ id: "security_number_invalid_container_pbm",
1305
+ children: [
1306
+ /* @__PURE__ */ jsx12(Title_default, { className: "w-full", textColor, children: "CPF n\xE3o cadastrado." }),
1307
+ /* @__PURE__ */ jsxs8(Text_default, { className: "w-full", textColor, children: [
1308
+ "Conclua seu cadastro para habilitar o benef\xEDcio. ",
1309
+ /* @__PURE__ */ jsx12("br", {}),
1310
+ "Ao clicar em \u201CAceitar os termos\u201D, voc\xEA ir\xE1 para uma p\xE1gina externa. Aceite os termos e volte para continuar."
1311
+ ] }),
1312
+ /* @__PURE__ */ jsx12(Button_default, { onClick: () => handleOpenModal(), style: { backgroundColor: "var(--pbm-primary)" }, children: "Aceitar os termos" })
1313
+ ]
1314
+ }
1315
+ );
1316
+ }
1317
+ var SecurityNumberInvalid_default = SecurityNumberInvalid;
1318
+
1319
+ // src/components/SecurityNumberRegitered/index.tsx
1320
+ import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
1321
+ function SecurityNumberRegitered({ textColor }) {
1322
+ const { urlRegisterIndustry } = usePBMStore();
1323
+ const { setModal } = useModal();
1324
+ const handleOpenModal = () => {
1325
+ if (!urlRegisterIndustry) return;
1326
+ setModal({ open: true, id: "iframe_pbm", label: "Ativar CPF", url: urlRegisterIndustry });
1327
+ };
1328
+ return /* @__PURE__ */ jsxs9(
1329
+ "section",
1330
+ {
1331
+ "data-testid": "test_id_registered",
1332
+ className: "flex items-end justify-center gap-2 w-full h-auto flex-col border-y py-6",
1333
+ style: { borderColor: "color-mix(in srgb, var(--pbm-text), transparent 80%)" },
1334
+ id: "security_number_registered_container_pbm",
1335
+ children: [
1336
+ /* @__PURE__ */ jsx13(Title_default, { className: "w-full", textColor, children: "Ops, seu CPF ainda n\xE3o est\xE1 habilitado para este produto." }),
1337
+ /* @__PURE__ */ jsx13(Text_default, { className: "w-full", textColor, children: "Para ativar o benef\xEDcio, clique em \u201CAtivar CPF\u201D e conclua a etapa na p\xE1gina externa. Depois, \xE9 s\xF3 voltar para continuar \u2014 vamos aguardar voc\xEA aqui." }),
1338
+ /* @__PURE__ */ jsx13(Button_default, { onClick: () => handleOpenModal(), style: { backgroundColor: "var(--pbm-primary)" }, children: "Ativar CPF" })
1339
+ ]
1340
+ }
1341
+ );
1342
+ }
1343
+ var SecurityNumberRegitered_default = SecurityNumberRegitered;
1344
+
1345
+ // src/components/Errors/ErrorToApplyBenefits.tsx
1346
+ import { RefreshCw } from "lucide-react";
1347
+
1348
+ // src/libs/zustand/useError.tsx
1349
+ import { create as create3 } from "zustand";
1350
+ var initialErrorState = {
1351
+ ErrorMessage: "Erro ao aplicar o benef\xEDcio"
1352
+ };
1353
+ var createErrorStore = (set) => ({
1354
+ ...initialErrorState,
1355
+ setErrorMessage: (ErrorMessage) => set({ ErrorMessage }),
1356
+ resetErrorMessage: () => set({ ErrorMessage: initialErrorState.ErrorMessage })
1357
+ });
1358
+ var useError = create3(createErrorStore);
1359
+
1360
+ // src/components/Errors/ErrorToApplyBenefits.tsx
1361
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
1362
+ var ErrorToApplyBenefits = () => {
1363
+ const { ErrorMessage } = useError();
1364
+ const { setState } = usePBMStore();
1365
+ return /* @__PURE__ */ jsxs10(Container_default, { variant: "main", children: [
1366
+ /* @__PURE__ */ jsx14(Title_default, { children: "Erro ao Aplicar o Benef\xEDcio" }),
1367
+ /* @__PURE__ */ jsx14(Text_default, { textAlign: "center", children: ErrorMessage }),
1368
+ /* @__PURE__ */ jsxs10(
1369
+ Button_default,
1370
+ {
1371
+ className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
1372
+ style: { color: "var(--pbm-text)" },
1373
+ onMouseOver: (e) => e.currentTarget.style.filter = "brightness(0.8)",
1374
+ onMouseOut: (e) => e.currentTarget.style.filter = "none",
1375
+ onClick: () => setState("isEmpty"),
1376
+ id: "check_benefits_button",
1377
+ children: [
1378
+ /* @__PURE__ */ jsx14("span", { children: "Tentar novamente" }),
1379
+ /* @__PURE__ */ jsx14(RefreshCw, { size: 16 })
1380
+ ]
1381
+ }
1382
+ )
1383
+ ] });
1384
+ };
1385
+ var ErrorToApplyBenefits_default = ErrorToApplyBenefits;
1386
+
1387
+ // src/components/Modals/CustomerNotRegistered/index.tsx
1388
+ import { useState as useState9 } from "react";
1389
+ import classNames13 from "classnames";
1390
+
1391
+ // src/components/Modals/CustomerNotRegistered/StepPersonalDataForm.tsx
1392
+ import { useState as useState4 } from "react";
1393
+
1394
+ // src/components/Modals/CustomerNotRegistered/Shared/FieldWrapper.tsx
1395
+ import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
1396
+ var FieldWrapper = ({
1397
+ label,
1398
+ error,
1399
+ children
1400
+ }) => /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1", children: [
1401
+ /* @__PURE__ */ jsx15("label", { className: "text-xs font-medium text-zinc-500 uppercase tracking-wide", children: label }),
1402
+ children,
1403
+ error && /* @__PURE__ */ jsx15("span", { className: "text-xs text-red-500 mt-0.5", children: error })
1404
+ ] });
1405
+ var FieldWrapper_default = FieldWrapper;
1406
+
1407
+ // src/components/Modals/CustomerNotRegistered/Shared/DisabledInputClass.ts
1408
+ var disabledInputClass = "w-full rounded-lg border border-gray-200 bg-gray-100 px-3 py-2.5 text-sm text-gray-400 cursor-not-allowed";
1409
+ var DisabledInputClass_default = disabledInputClass;
1410
+
1411
+ // src/components/Modals/CustomerNotRegistered/Shared/InputClass.ts
1412
+ import classNames8 from "classnames";
1413
+ var inputClass = (error) => classNames8(
1414
+ "w-full rounded-lg border px-3 py-2.5 text-sm text-gray-800 outline-none transition-all",
1415
+ "focus:ring-2 focus:ring-blue-500/30 focus:border-blue-500",
1416
+ error ? "border-red-400 bg-red-50" : "border-gray-200 bg-gray-50 hover:border-gray-300"
1417
+ );
1418
+ var InputClass_default = inputClass;
1419
+
1420
+ // src/components/Modals/CustomerNotRegistered/Shared/StepActions.tsx
1421
+ import classNames9 from "classnames";
1422
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
1423
+ var StepActions = ({
1424
+ onNext,
1425
+ onBack,
1426
+ loading,
1427
+ nextLabel = "Continuar",
1428
+ isLast = false
1429
+ }) => /* @__PURE__ */ jsxs12("div", { className: "flex gap-2 mt-2 pt-4 border-t border-gray-100", children: [
1430
+ onBack && /* @__PURE__ */ jsx16(
1431
+ "button",
1432
+ {
1433
+ type: "button",
1434
+ onClick: onBack,
1435
+ className: "flex-1 rounded-lg border border-gray-200 py-2.5 text-sm font-medium text-zinc-600 hover:bg-zinc-600/10 transition-all cursor-pointer",
1436
+ children: "Voltar"
1437
+ }
1438
+ ),
1439
+ /* @__PURE__ */ jsx16(
1440
+ "button",
1441
+ {
1442
+ type: "button",
1443
+ onClick: onNext,
1444
+ disabled: loading,
1445
+ className: classNames9(
1446
+ "flex-2 rounded-lg py-2.5 text-sm font-semibold text-white transition-all cursor-pointer",
1447
+ isLast ? "bg-emerald-600 hover:bg-emerald-500" : "bg-(--pbm-primary) hover:bg-(--pbm-primary)/60",
1448
+ loading && "opacity-60 cursor-not-allowed"
1449
+ ),
1450
+ children: loading ? /* @__PURE__ */ jsxs12("span", { className: "flex items-center justify-center gap-2", children: [
1451
+ /* @__PURE__ */ jsxs12("svg", { className: "h-4 w-4 animate-spin", viewBox: "0 0 24 24", fill: "none", children: [
1452
+ /* @__PURE__ */ jsx16(
1453
+ "circle",
1454
+ {
1455
+ className: "opacity-25",
1456
+ cx: "12",
1457
+ cy: "12",
1458
+ r: "10",
1459
+ stroke: "currentColor",
1460
+ strokeWidth: "4"
1461
+ }
1462
+ ),
1463
+ /* @__PURE__ */ jsx16(
1464
+ "path",
1465
+ {
1466
+ className: "opacity-75",
1467
+ fill: "currentColor",
1468
+ d: "M4 12a8 8 0 018-8v8z"
1469
+ }
1470
+ )
1471
+ ] }),
1472
+ "Enviando..."
1473
+ ] }) : nextLabel
1474
+ }
1475
+ )
1476
+ ] });
1477
+ var StepActions_default = StepActions;
1478
+
1479
+ // src/services/set-personal-data-form.ts
1480
+ import Cookies4 from "js-cookie";
1481
+ var SetPersonalDataForm = async ({ document, requestId, personalData }) => {
1482
+ const API_URL = getEnv("VITE_API_URL");
1483
+ const AUTH_TOKEN = Cookies4.get("pbm-token");
1484
+ if (!AUTH_TOKEN) {
1485
+ throw new Error("Token is not defined in cookies or is expired");
1486
+ }
1487
+ const response = await fetch(`${API_URL}/programregistration/personalData`, {
1488
+ method: "PUT",
1489
+ headers: {
1490
+ Authorization: `Bearer ${AUTH_TOKEN}`,
1491
+ "Content-Type": "application/json"
1492
+ },
1493
+ body: JSON.stringify({ document, requestId, ...personalData })
1494
+ });
1495
+ const dataResponse = await response.json();
1496
+ if (!dataResponse.success) {
1497
+ throw new Error(dataResponse.message || "Failed to fetch authorization");
1498
+ }
1499
+ return dataResponse;
1500
+ };
1501
+
1502
+ // src/components/Modals/CustomerNotRegistered/StepPersonalDataForm.tsx
1503
+ import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
1504
+ var StepPersonalDataForm = ({
1505
+ securityNumber,
1506
+ onNext
1507
+ }) => {
1508
+ const { personalData, setPersonalData, setStep } = usePBMForm();
1509
+ const { setModal } = useModal();
1510
+ const store = usePBMStore();
1511
+ const [errors, setErrors] = useState4({});
1512
+ const [loading, setLoading] = useState4(false);
1513
+ const validate = () => {
1514
+ const e = {};
1515
+ if (!personalData.name.trim() || personalData.name.trim().split(" ").length < 2)
1516
+ e.name = "Informe o nome completo.";
1517
+ if (!/^\(\d{2}\) \d{5}-\d{4}$/.test(personalData.phone))
1518
+ e.phone = "Telefone inv\xE1lido.";
1519
+ if (!personalData.birthday) e.birthday = "Data de nascimento obrigat\xF3ria.";
1520
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(personalData.email))
1521
+ e.email = "E-mail inv\xE1lido.";
1522
+ setErrors(e);
1523
+ return Object.keys(e).length === 0;
1524
+ };
1525
+ const handleSubmit = async () => {
1526
+ if (!validate()) return;
1527
+ setLoading(true);
1528
+ try {
1529
+ const response = await SetPersonalDataForm({
1530
+ document: securityNumber,
1531
+ requestId: store.requestId,
1532
+ personalData
1533
+ });
1534
+ if (!response.success) {
1535
+ console.error("Failed to set personal data form:", response.message);
1536
+ return;
1537
+ }
1538
+ setStep(mappingFormStep["Address"]);
1539
+ onNext();
1540
+ } catch {
1541
+ console.error("An error occurred while setting personal data form.");
1542
+ } finally {
1543
+ setLoading(false);
1544
+ }
1545
+ };
1546
+ return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-4", children: [
1547
+ /* @__PURE__ */ jsxs13(FieldWrapper_default, { label: "CPF", children: [
1548
+ /* @__PURE__ */ jsx17(
1549
+ "input",
1550
+ {
1551
+ className: DisabledInputClass_default,
1552
+ value: formaters.cpf(securityNumber),
1553
+ disabled: true,
1554
+ readOnly: true
1555
+ }
1556
+ ),
1557
+ /* @__PURE__ */ jsx17("p", { className: "text-xs text-gray-400 mt-1", children: /* @__PURE__ */ jsx17(
1558
+ "button",
1559
+ {
1560
+ type: "button",
1561
+ className: "text-(--pbm-primary) hover:text-(--pbm-primary)/60 cursor-pointer underline underline-offset-2 transition-colors",
1562
+ onClick: () => setModal({ id: "", open: false }),
1563
+ children: "Deseja alterar o CPF? Clique aqui."
1564
+ }
1565
+ ) })
1566
+ ] }),
1567
+ /* @__PURE__ */ jsx17(FieldWrapper_default, { label: "Nome completo", error: errors.name, children: /* @__PURE__ */ jsx17(
1568
+ "input",
1569
+ {
1570
+ className: InputClass_default(errors.name),
1571
+ placeholder: "Ex: Jo\xE3o da Silva",
1572
+ value: personalData.name,
1573
+ onChange: (e) => {
1574
+ setPersonalData({ name: e.target.value });
1575
+ setErrors((p) => ({ ...p, name: void 0 }));
1576
+ }
1577
+ }
1578
+ ) }),
1579
+ /* @__PURE__ */ jsxs13("div", { className: "grid grid-cols-2 gap-3", children: [
1580
+ /* @__PURE__ */ jsx17(FieldWrapper_default, { label: "Telefone", error: errors.phone, children: /* @__PURE__ */ jsx17(
1581
+ "input",
1582
+ {
1583
+ className: InputClass_default(errors.phone),
1584
+ placeholder: "(11) 99999-8888",
1585
+ value: personalData.phone,
1586
+ onChange: (e) => {
1587
+ setPersonalData({ phone: formaters.phone(e.target.value) });
1588
+ setErrors((p) => ({ ...p, phone: void 0 }));
1589
+ }
1590
+ }
1591
+ ) }),
1592
+ /* @__PURE__ */ jsx17(FieldWrapper_default, { label: "Data de nascimento", error: errors.birthday, children: /* @__PURE__ */ jsx17(
1593
+ "input",
1594
+ {
1595
+ type: "date",
1596
+ className: InputClass_default(errors.birthday),
1597
+ value: personalData.birthday,
1598
+ onChange: (e) => {
1599
+ setPersonalData({ birthday: e.target.value });
1600
+ setErrors((p) => ({ ...p, birthday: void 0 }));
1601
+ }
1602
+ }
1603
+ ) })
1604
+ ] }),
1605
+ /* @__PURE__ */ jsx17(FieldWrapper_default, { label: "E-mail", error: errors.email, children: /* @__PURE__ */ jsx17(
1606
+ "input",
1607
+ {
1608
+ type: "email",
1609
+ className: InputClass_default(errors.email),
1610
+ placeholder: "joao@email.com",
1611
+ value: personalData.email,
1612
+ onChange: (e) => {
1613
+ setPersonalData({ email: e.target.value });
1614
+ setErrors((p) => ({ ...p, email: void 0 }));
1615
+ }
1616
+ }
1617
+ ) }),
1618
+ /* @__PURE__ */ jsx17(StepActions_default, { onNext: handleSubmit, loading })
1619
+ ] });
1620
+ };
1621
+ var StepPersonalDataForm_default = StepPersonalDataForm;
1622
+
1623
+ // src/components/Modals/CustomerNotRegistered/StepAddressForm.tsx
1624
+ import { useCallback as useCallback2, useState as useState5 } from "react";
1625
+
1626
+ // src/services/lookup-postal-code.ts
1627
+ import Cookies5 from "js-cookie";
1628
+ var LookupPostalCode = async ({ POSTAL_CODE }) => {
1629
+ const API_URL = getEnv("VITE_API_URL");
1630
+ const AUTH_TOKEN = Cookies5.get("pbm-token");
1631
+ if (!AUTH_TOKEN) {
1632
+ throw new Error("Token is not defined in cookies or is expired");
1633
+ }
1634
+ const response = await fetch(`${API_URL}/programregistration/consulta-cep/${POSTAL_CODE}`, {
1635
+ method: "GET",
1636
+ headers: {
1637
+ Authorization: `Bearer ${AUTH_TOKEN}`,
1638
+ "Content-Type": "application/json"
1639
+ }
1640
+ });
1641
+ const dataResponse = await response.json();
1642
+ if (!dataResponse.success) {
1643
+ throw new Error(dataResponse.message || "Failed to fetch authorization");
1644
+ }
1645
+ return dataResponse;
1646
+ };
1647
+
1648
+ // src/services/set-address-data-form.ts
1649
+ import Cookies6 from "js-cookie";
1650
+ var SetAddressDataForm = async ({ document, requestId, address }) => {
1651
+ const API_URL = getEnv("VITE_API_URL");
1652
+ const AUTH_TOKEN = Cookies6.get("pbm-token");
1653
+ if (!AUTH_TOKEN) {
1654
+ throw new Error("Token is not defined in cookies or is expired");
1655
+ }
1656
+ const response = await fetch(`${API_URL}/programregistration/address`, {
1657
+ method: "PUT",
1658
+ headers: {
1659
+ Authorization: `Bearer ${AUTH_TOKEN}`,
1660
+ "Content-Type": "application/json"
1661
+ },
1662
+ body: JSON.stringify({ document, requestId, ...address })
1663
+ });
1664
+ const dataResponse = await response.json();
1665
+ if (!dataResponse.success) {
1666
+ throw new Error(dataResponse.message || "Failed to fetch authorization");
1667
+ }
1668
+ return dataResponse;
1669
+ };
1670
+
1671
+ // src/components/Modals/CustomerNotRegistered/StepAddressForm.tsx
1672
+ import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
1673
+ var StepAddressForm = ({
1674
+ securityNumber,
1675
+ onNext,
1676
+ onBack
1677
+ }) => {
1678
+ const { address, setAddress, setStep } = usePBMForm();
1679
+ const store = usePBMStore();
1680
+ const [errors, setErrors] = useState5({});
1681
+ const [loadingCep, setLoadingCep] = useState5(false);
1682
+ const [loading, setLoading] = useState5(false);
1683
+ const fetchCEP = useCallback2(
1684
+ async (cep) => {
1685
+ const raw = cep.replace(/\D/g, "");
1686
+ if (raw.length !== 8) return;
1687
+ setLoadingCep(true);
1688
+ try {
1689
+ const response = await LookupPostalCode({ POSTAL_CODE: raw });
1690
+ if (!response.success) {
1691
+ console.error("Failed to lookup postal code");
1692
+ return;
1693
+ }
1694
+ setAddress({
1695
+ street: response.data.endereco,
1696
+ neighborhood: response.data.bairro,
1697
+ city: response.data.cidade,
1698
+ stateAddress: response.data.estado,
1699
+ postalcode: cep,
1700
+ complement: response.data.complementoSugeridoViaCep || ""
1701
+ });
1702
+ } catch {
1703
+ console.error("Failed to fetch address for CEP:", cep);
1704
+ } finally {
1705
+ setLoadingCep(false);
1706
+ }
1707
+ },
1708
+ [setAddress]
1709
+ );
1710
+ const validate = () => {
1711
+ const e = {};
1712
+ if (!/^\d{5}-\d{3}$/.test(address.postalcode))
1713
+ e.postalcode = "CEP inv\xE1lido.";
1714
+ if (!address.number.trim()) e.number = "N\xFAmero obrigat\xF3rio.";
1715
+ setErrors(e);
1716
+ return Object.keys(e).length === 0;
1717
+ };
1718
+ const handleSubmit = async () => {
1719
+ if (!validate()) return;
1720
+ setLoading(true);
1721
+ try {
1722
+ const response = await SetAddressDataForm({
1723
+ document: securityNumber,
1724
+ requestId: store.requestId,
1725
+ address: {
1726
+ postalcode: address.postalcode.replace(/\D/g, ""),
1727
+ number: address.number,
1728
+ complement: address.complement
1729
+ }
1730
+ });
1731
+ if (!response.success) {
1732
+ console.log("Failed to set address data form:", response.message);
1733
+ return;
1734
+ }
1735
+ setStep(mappingFormStep["GenderResponsibility"]);
1736
+ onNext();
1737
+ } catch {
1738
+ console.log("An error occurred while submitting address form.");
1739
+ } finally {
1740
+ setLoading(false);
1741
+ }
1742
+ };
1743
+ return /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-4", children: [
1744
+ /* @__PURE__ */ jsx18(FieldWrapper_default, { label: "CEP", error: errors.postalcode, children: /* @__PURE__ */ jsxs14("div", { className: "relative", children: [
1745
+ /* @__PURE__ */ jsx18(
1746
+ "input",
1747
+ {
1748
+ className: InputClass_default(errors.postalcode),
1749
+ placeholder: "00000-000",
1750
+ value: address.postalcode,
1751
+ onChange: (e) => {
1752
+ const formatted = formaters.cep(e.target.value);
1753
+ setAddress({ postalcode: formatted });
1754
+ setErrors((p) => ({
1755
+ ...p,
1756
+ postalcode: void 0
1757
+ }));
1758
+ if (formatted.replace(/\D/g, "").length === 8)
1759
+ fetchCEP(formatted);
1760
+ }
1761
+ }
1762
+ ),
1763
+ loadingCep && /* @__PURE__ */ jsx18("div", { className: "absolute right-3 top-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxs14(
1764
+ "svg",
1765
+ {
1766
+ className: "h-4 w-4 animate-spin text-blue-500",
1767
+ viewBox: "0 0 24 24",
1768
+ fill: "none",
1769
+ children: [
1770
+ /* @__PURE__ */ jsx18(
1771
+ "circle",
1772
+ {
1773
+ className: "opacity-25",
1774
+ cx: "12",
1775
+ cy: "12",
1776
+ r: "10",
1777
+ stroke: "currentColor",
1778
+ strokeWidth: "4"
1779
+ }
1780
+ ),
1781
+ /* @__PURE__ */ jsx18(
1782
+ "path",
1783
+ {
1784
+ className: "opacity-75",
1785
+ fill: "currentColor",
1786
+ d: "M4 12a8 8 0 018-8v8z"
1787
+ }
1788
+ )
1789
+ ]
1790
+ }
1791
+ ) })
1792
+ ] }) }),
1793
+ /* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-2 gap-3", children: [
1794
+ /* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Rua", children: /* @__PURE__ */ jsx18(
1795
+ "input",
1796
+ {
1797
+ className: DisabledInputClass_default,
1798
+ value: address.street || "",
1799
+ disabled: true,
1800
+ readOnly: true,
1801
+ placeholder: "Preenchido pelo CEP"
1802
+ }
1803
+ ) }),
1804
+ /* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Bairro", children: /* @__PURE__ */ jsx18(
1805
+ "input",
1806
+ {
1807
+ className: DisabledInputClass_default,
1808
+ value: address.neighborhood || "",
1809
+ disabled: true,
1810
+ readOnly: true,
1811
+ placeholder: "Preenchido pelo CEP"
1812
+ }
1813
+ ) })
1814
+ ] }),
1815
+ /* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-2 gap-3", children: [
1816
+ /* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Cidade", children: /* @__PURE__ */ jsx18(
1817
+ "input",
1818
+ {
1819
+ className: DisabledInputClass_default,
1820
+ value: address.city || "",
1821
+ disabled: true,
1822
+ readOnly: true,
1823
+ placeholder: "Preenchido pelo CEP"
1824
+ }
1825
+ ) }),
1826
+ /* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Estado", children: /* @__PURE__ */ jsx18(
1827
+ "input",
1828
+ {
1829
+ className: DisabledInputClass_default,
1830
+ value: address.stateAddress || "",
1831
+ disabled: true,
1832
+ readOnly: true,
1833
+ placeholder: "UF"
1834
+ }
1835
+ ) })
1836
+ ] }),
1837
+ /* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-2 gap-3", children: [
1838
+ /* @__PURE__ */ jsx18(FieldWrapper_default, { label: "N\xFAmero", error: errors.number, children: /* @__PURE__ */ jsx18(
1839
+ "input",
1840
+ {
1841
+ className: InputClass_default(errors.number),
1842
+ placeholder: "Ex: 100",
1843
+ value: address.number,
1844
+ onChange: (e) => {
1845
+ setAddress({ number: e.target.value });
1846
+ setErrors((p) => ({ ...p, number: void 0 }));
1847
+ }
1848
+ }
1849
+ ) }),
1850
+ /* @__PURE__ */ jsx18(FieldWrapper_default, { label: "Complemento", children: /* @__PURE__ */ jsx18(
1851
+ "input",
1852
+ {
1853
+ className: InputClass_default(),
1854
+ placeholder: "Apto, bloco...",
1855
+ value: address.complement,
1856
+ onChange: (e) => setAddress({ complement: e.target.value })
1857
+ }
1858
+ ) })
1859
+ ] }),
1860
+ /* @__PURE__ */ jsx18(StepActions_default, { onNext: handleSubmit, onBack, loading })
1861
+ ] });
1862
+ };
1863
+ var StepAddressForm_default = StepAddressForm;
1864
+
1865
+ // src/components/Modals/CustomerNotRegistered/StepGenderForm.tsx
1866
+ import classNames10 from "classnames";
1867
+ import { useState as useState6 } from "react";
1868
+
1869
+ // src/services/set-gender-responsability-data-form.ts
1870
+ import Cookies7 from "js-cookie";
1871
+ var SetGenderResponsabilityDataForm = async ({ document, requestId, identity_responsibility }) => {
1872
+ const API_URL = getEnv("VITE_API_URL");
1873
+ const AUTH_TOKEN = Cookies7.get("pbm-token");
1874
+ if (!AUTH_TOKEN) {
1875
+ throw new Error("Token is not defined in cookies or is expired");
1876
+ }
1877
+ const response = await fetch(`${API_URL}/programregistration/genderResponsibility`, {
1878
+ method: "PUT",
1879
+ headers: {
1880
+ Authorization: `Bearer ${AUTH_TOKEN}`,
1881
+ "Content-Type": "application/json"
1882
+ },
1883
+ body: JSON.stringify({ document, requestId, ...identity_responsibility })
1884
+ });
1885
+ const dataResponse = await response.json();
1886
+ if (!dataResponse.success) {
1887
+ throw new Error(dataResponse.message || "Failed to fetch authorization");
1888
+ }
1889
+ return dataResponse;
1890
+ };
1891
+
1892
+ // src/components/Modals/CustomerNotRegistered/StepGenderForm.tsx
1893
+ import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
1894
+ var StepGenderForm = ({
1895
+ securityNumber,
1896
+ onNext,
1897
+ onBack
1898
+ }) => {
1899
+ const { genderResponsibility, setGenderResponsibility, setStep } = usePBMForm();
1900
+ const store = usePBMStore();
1901
+ const [errors, setErrors] = useState6(
1902
+ {}
1903
+ );
1904
+ const [loading, setLoading] = useState6(false);
1905
+ const validate = () => {
1906
+ const e = {};
1907
+ if (!genderResponsibility.gender) e.gender = "Selecione o g\xEAnero.";
1908
+ if (genderResponsibility.patient === null)
1909
+ e.patient = "Informe se \xE9 o paciente.";
1910
+ setErrors(e);
1911
+ return Object.keys(e).length === 0;
1912
+ };
1913
+ const handleSubmit = async () => {
1914
+ if (!validate()) return;
1915
+ setLoading(true);
1916
+ try {
1917
+ const response = await SetGenderResponsabilityDataForm({
1918
+ document: securityNumber,
1919
+ requestId: store.requestId,
1920
+ identity_responsibility: {
1921
+ gender: genderResponsibility.gender,
1922
+ patient: genderResponsibility.patient
1923
+ }
1924
+ });
1925
+ if (!response.success) {
1926
+ console.error(
1927
+ "Failed to submit gender responsibility data:",
1928
+ response.message
1929
+ );
1930
+ return;
1931
+ }
1932
+ setStep(mappingFormStep["Doctor"]);
1933
+ onNext();
1934
+ } catch {
1935
+ console.error(
1936
+ "An error occurred while submitting gender responsibility data."
1937
+ );
1938
+ } finally {
1939
+ setLoading(false);
1940
+ }
1941
+ };
1942
+ const genderOptions = [
1943
+ { value: "M", label: "Masculino" },
1944
+ { value: "F", label: "Feminino" },
1945
+ { value: "O", label: "Outro" }
1946
+ ];
1947
+ return /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-5", children: [
1948
+ /* @__PURE__ */ jsxs15("div", { children: [
1949
+ /* @__PURE__ */ jsx19("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide block mb-2", children: "G\xEAnero" }),
1950
+ /* @__PURE__ */ jsx19("div", { className: "flex gap-2", children: genderOptions.map((opt) => /* @__PURE__ */ jsx19(
1951
+ "button",
1952
+ {
1953
+ type: "button",
1954
+ onClick: () => {
1955
+ setGenderResponsibility({ gender: opt.value });
1956
+ setErrors((p) => ({ ...p, gender: void 0 }));
1957
+ },
1958
+ className: classNames10(
1959
+ "flex-1 py-2.5 rounded-lg border text-sm font-medium transition-all",
1960
+ genderResponsibility.gender === opt.value ? "border-blue-500 bg-blue-500 text-white" : "border-gray-200 bg-gray-50 text-gray-600 hover:border-blue-300"
1961
+ ),
1962
+ children: opt.label
1963
+ },
1964
+ opt.value
1965
+ )) }),
1966
+ errors.gender && /* @__PURE__ */ jsx19("span", { className: "text-xs text-red-500 mt-1 block", children: errors.gender })
1967
+ ] }),
1968
+ /* @__PURE__ */ jsxs15("div", { children: [
1969
+ /* @__PURE__ */ jsx19("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide block mb-2", children: "Voc\xEA \xE9 o paciente?" }),
1970
+ /* @__PURE__ */ jsx19("div", { className: "flex gap-2", children: [
1971
+ { label: "Sim, sou o paciente", value: true },
1972
+ { label: "N\xE3o, sou respons\xE1vel", value: false }
1973
+ ].map((opt) => /* @__PURE__ */ jsx19(
1974
+ "button",
1975
+ {
1976
+ type: "button",
1977
+ onClick: () => {
1978
+ setGenderResponsibility({ patient: opt.value });
1979
+ setErrors((p) => ({ ...p, patient: void 0 }));
1980
+ },
1981
+ className: classNames10(
1982
+ "flex-1 py-2.5 rounded-lg border text-sm font-medium transition-all",
1983
+ genderResponsibility.patient === opt.value ? "border-blue-500 bg-blue-500 text-white" : "border-gray-200 bg-gray-50 text-gray-600 hover:border-blue-300"
1984
+ ),
1985
+ children: opt.label
1986
+ },
1987
+ String(opt.value)
1988
+ )) }),
1989
+ errors.patient && /* @__PURE__ */ jsx19("span", { className: "text-xs text-red-500 mt-1 block", children: errors.patient })
1990
+ ] }),
1991
+ /* @__PURE__ */ jsx19(StepActions_default, { onNext: handleSubmit, onBack, loading })
1992
+ ] });
1993
+ };
1994
+ var StepGenderForm_default = StepGenderForm;
1995
+
1996
+ // src/components/Modals/CustomerNotRegistered/StepDoctorForm.tsx
1997
+ import { useCallback as useCallback3, useState as useState7 } from "react";
1998
+
1999
+ // src/utils/ufMapping.ts
2000
+ var BRAZILIAN_STATES = [
2001
+ "AC",
2002
+ "AL",
2003
+ "AP",
2004
+ "AM",
2005
+ "BA",
2006
+ "CE",
2007
+ "DF",
2008
+ "ES",
2009
+ "GO",
2010
+ "MA",
2011
+ "MT",
2012
+ "MS",
2013
+ "MG",
2014
+ "PA",
2015
+ "PB",
2016
+ "PR",
2017
+ "PE",
2018
+ "PI",
2019
+ "RJ",
2020
+ "RN",
2021
+ "RS",
2022
+ "RO",
2023
+ "RR",
2024
+ "SC",
2025
+ "SP",
2026
+ "SE",
2027
+ "TO"
2028
+ ];
2029
+
2030
+ // src/services/set-doctor-data-form.ts
2031
+ import Cookies8 from "js-cookie";
2032
+ var SetDoctorDataForm = async ({ document, requestId, doctor }) => {
2033
+ const API_URL = getEnv("VITE_API_URL");
2034
+ const AUTH_TOKEN = Cookies8.get("pbm-token");
2035
+ if (!AUTH_TOKEN) {
2036
+ throw new Error("Token is not defined in cookies or is expired");
2037
+ }
2038
+ const response = await fetch(`${API_URL}/programregistration/doctorName`, {
2039
+ method: "PUT",
2040
+ headers: {
2041
+ Authorization: `Bearer ${AUTH_TOKEN}`,
2042
+ "Content-Type": "application/json"
2043
+ },
2044
+ body: JSON.stringify({ document, requestId, ...doctor })
2045
+ });
2046
+ const dataResponse = await response.json();
2047
+ if (!dataResponse.success) {
2048
+ throw new Error(dataResponse.message || "Failed to fetch authorization");
2049
+ }
2050
+ return dataResponse;
2051
+ };
2052
+
2053
+ // src/services/lookup-doctor.ts
2054
+ import Cookies9 from "js-cookie";
2055
+ var LookupDoctor = async ({ typeCredential, register, uf }) => {
2056
+ const API_URL = getEnv("VITE_API_URL");
2057
+ const AUTH_TOKEN = Cookies9.get("pbm-token");
2058
+ if (!AUTH_TOKEN) {
2059
+ throw new Error("Token is not defined in cookies or is expired");
2060
+ }
2061
+ const queryParams = new URLSearchParams({
2062
+ tipoCredencial: typeCredential,
2063
+ registro: register,
2064
+ uf
2065
+ });
2066
+ const response = await fetch(`${API_URL}/doctors/consulta-profissional?${queryParams.toString()}`, {
2067
+ method: "GET",
2068
+ headers: {
2069
+ Authorization: `Bearer ${AUTH_TOKEN}`,
2070
+ "Content-Type": "application/json"
759
2071
  }
760
- if (!targetProduct.price) {
761
- console.error("PBMLOG: Price is not defined on targetProduct");
762
- return;
2072
+ });
2073
+ const dataResponse = await response.json();
2074
+ if (!dataResponse.success) {
2075
+ throw new Error(dataResponse.message || "Failed to fetch authorization");
2076
+ }
2077
+ return dataResponse;
2078
+ };
2079
+
2080
+ // src/components/Modals/CustomerNotRegistered/StepDoctorForm.tsx
2081
+ import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
2082
+ var StepDoctorForm = ({
2083
+ securityNumber,
2084
+ onNext,
2085
+ onBack
2086
+ }) => {
2087
+ const { doctor, setDoctor, setStep } = usePBMForm();
2088
+ const store = usePBMStore();
2089
+ const [errors, setErrors] = useState7({});
2090
+ const [loadingDoctor, setLoadingDoctor] = useState7(false);
2091
+ const [loading, setLoading] = useState7(false);
2092
+ const fetchDoctor = useCallback3(async () => {
2093
+ if (!doctor.register || !doctor.state || !doctor.typeCredential) return;
2094
+ setLoadingDoctor(true);
2095
+ try {
2096
+ const response = await LookupDoctor({
2097
+ typeCredential: doctor.typeCredential,
2098
+ register: doctor.register,
2099
+ uf: doctor.state
2100
+ });
2101
+ if (!response.success) {
2102
+ console.error("Failed to fetch doctor data:", response.message);
2103
+ return;
2104
+ }
2105
+ const data = response.data;
2106
+ if (data?.nomeProfissional) {
2107
+ setDoctor({ doctorName: data.nomeProfissional });
2108
+ }
2109
+ } catch {
2110
+ console.error("An error occurred while fetching doctor data.");
2111
+ } finally {
2112
+ setLoadingDoctor(false);
763
2113
  }
764
- const fetchDicountsWithoutDocument = async () => {
765
- try {
766
- const data = {
767
- productId: Number(targetProduct.productId),
768
- ean: targetProduct.ean,
769
- requestedQuantity: 1,
770
- listPrice: targetProduct.listPrice,
771
- netPrice: targetProduct.price
772
- };
773
- const response = await CheckBenefistWithoutDocument({ products: [data] });
774
- if (response.success && response.data) {
775
- setBenefitsItems(response.data);
776
- } else {
777
- setBenefitsItems(void 0);
2114
+ }, [doctor.register, doctor.state, doctor.typeCredential, setDoctor]);
2115
+ const validate = () => {
2116
+ const e = {};
2117
+ if (!doctor.typeCredential)
2118
+ e.typeCredential = "Tipo de credencial obrigat\xF3rio.";
2119
+ if (!doctor.register.trim()) e.register = "N\xFAmero do registro obrigat\xF3rio.";
2120
+ if (!doctor.state) e.state = "Estado obrigat\xF3rio.";
2121
+ if (!doctor.doctorName.trim()) e.doctorName = "Nome do m\xE9dico obrigat\xF3rio.";
2122
+ setErrors(e);
2123
+ return Object.keys(e).length === 0;
2124
+ };
2125
+ const handleSubmit = async () => {
2126
+ if (!validate()) return;
2127
+ setLoading(true);
2128
+ try {
2129
+ const response = await SetDoctorDataForm({
2130
+ document: securityNumber,
2131
+ requestId: store.requestId,
2132
+ doctor: {
2133
+ typeCredential: doctor.typeCredential,
2134
+ register: doctor.register,
2135
+ state: doctor.state,
2136
+ doctorName: doctor.doctorName
778
2137
  }
779
- } catch (error) {
780
- setBenefitsItems(void 0);
781
- console.error(error);
782
- }
783
- };
784
- const fetchDiscountWithDocument = async () => {
785
- if (!securityNumber) {
786
- console.error("PBMLOG: Document is not defined");
2138
+ });
2139
+ if (!response.success) {
2140
+ console.error("Failed to submit doctor data:", response.message);
787
2141
  return;
788
2142
  }
789
- try {
790
- const data = {
791
- productId: Number(targetProduct.productId),
792
- ean: targetProduct.ean,
793
- requestedQuantity: 1,
794
- listPrice: targetProduct.listPrice,
795
- netPrice: targetProduct.price
796
- };
797
- const response = await BenefitsWithDocument({ document: securityNumber, products: [data] });
798
- if (response.success && response.data) {
799
- setBenefitsItems(response.data.product);
800
- } else {
801
- setBenefitsItems(void 0);
2143
+ setStep(mappingFormStep["Acceptances"]);
2144
+ onNext();
2145
+ } catch {
2146
+ console.error("An error occurred while submitting doctor data.");
2147
+ } finally {
2148
+ setLoading(false);
2149
+ }
2150
+ };
2151
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-4", children: [
2152
+ /* @__PURE__ */ jsxs16("div", { className: "grid grid-cols-3 gap-3", children: [
2153
+ /* @__PURE__ */ jsx20(FieldWrapper_default, { label: "Tipo credencial", error: errors.typeCredential, children: /* @__PURE__ */ jsxs16(
2154
+ "select",
2155
+ {
2156
+ className: InputClass_default(errors.typeCredential),
2157
+ value: doctor.typeCredential,
2158
+ onChange: (e) => {
2159
+ setDoctor({ typeCredential: e.target.value });
2160
+ setErrors((p) => ({
2161
+ ...p,
2162
+ typeCredential: void 0
2163
+ }));
2164
+ },
2165
+ children: [
2166
+ /* @__PURE__ */ jsx20("option", { value: "CRM", children: "CRM" }),
2167
+ /* @__PURE__ */ jsx20("option", { value: "CRO", children: "CRO" }),
2168
+ /* @__PURE__ */ jsx20("option", { value: "CRF", children: "CRF" })
2169
+ ]
802
2170
  }
803
- } catch (error) {
804
- setBenefitsItems(void 0);
805
- console.error(error);
806
- }
807
- };
808
- startTransition(async () => {
809
- state === "isActivated" ? await fetchDiscountWithDocument() : await fetchDicountsWithoutDocument();
810
- });
811
- }, []);
812
- if (isPending) {
813
- return /* @__PURE__ */ jsx11(Loading_default, { textColor: "var(--pbm-text)" });
814
- }
815
- if (benefitsItems?.length && benefitsItems[0]?.statusCode == null && state === "isActivated") {
816
- return /* @__PURE__ */ jsx11("main", { className: "flex items-center justify-center gap-4", id: "loading_pbm", children: /* @__PURE__ */ jsx11("p", { className: "text-sm font-semibold text-start", style: { color: "var(--pbm-text)" }, id: "benefits_error_handle", children: benefitsItems[0].informativeText }) });
817
- }
818
- return /* @__PURE__ */ jsxs7(
819
- "section",
820
- {
821
- className: "flex items-start justify-center gap-4 w-full h-auto flex-col",
822
- id: "benefits_table_pbm",
823
- children: [
824
- /* @__PURE__ */ jsx11(Title_default, { children: "Descontos dispon\xEDveis:" }),
825
- /* @__PURE__ */ jsxs7(
826
- "form",
2171
+ ) }),
2172
+ /* @__PURE__ */ jsx20(FieldWrapper_default, { label: "Estado (UF)", error: errors.state, children: /* @__PURE__ */ jsxs16(
2173
+ "select",
2174
+ {
2175
+ className: InputClass_default(errors.state),
2176
+ value: doctor.state,
2177
+ onChange: (e) => {
2178
+ setDoctor({ state: e.target.value });
2179
+ setErrors((p) => ({ ...p, state: void 0 }));
2180
+ },
2181
+ children: [
2182
+ /* @__PURE__ */ jsx20("option", { value: "", children: "UF" }),
2183
+ BRAZILIAN_STATES.map((state) => /* @__PURE__ */ jsx20("option", { value: state, children: state }, state))
2184
+ ]
2185
+ }
2186
+ ) }),
2187
+ /* @__PURE__ */ jsx20(FieldWrapper_default, { label: "N\xBA registro", error: errors.register, children: /* @__PURE__ */ jsx20("div", { className: "relative", children: /* @__PURE__ */ jsx20(
2188
+ "input",
2189
+ {
2190
+ className: InputClass_default(errors.register),
2191
+ placeholder: "Ex: 123456",
2192
+ value: doctor.register,
2193
+ onChange: (e) => {
2194
+ setDoctor({ register: e.target.value.replace(/\D/g, "") });
2195
+ setErrors((p) => ({
2196
+ ...p,
2197
+ register: void 0
2198
+ }));
2199
+ },
2200
+ onBlur: fetchDoctor
2201
+ }
2202
+ ) }) })
2203
+ ] }),
2204
+ /* @__PURE__ */ jsxs16(FieldWrapper_default, { label: "Nome do m\xE9dico", error: errors.doctorName, children: [
2205
+ /* @__PURE__ */ jsxs16("div", { className: "relative", children: [
2206
+ /* @__PURE__ */ jsx20(
2207
+ "input",
827
2208
  {
828
- className: "flex flex-col items-center justify-start w-full gap-4.5",
829
- id: "form_benefits_table_pbm",
830
- onSubmit: (e) => e.preventDefault(),
831
- children: [
832
- !benefitsItems && /* @__PURE__ */ jsx11("p", { className: "text-sm font-semibold text-start text-zinc-900", id: "benefits_empty_pbm", children: "N\xE3o foi poss\xEDvel encontrar benef\xEDcios para esse produto." }),
833
- benefitsItems && benefitsItems.map((item, index) => {
834
- const ID_INPUT = "unity_quantity_" + item.authorizedQuantity;
835
- return /* @__PURE__ */ jsx11(
836
- Item_default,
837
- {
838
- data: item,
839
- checked: selectedDiscout === ID_INPUT,
840
- onChange: () => setSelectedDiscount(ID_INPUT)
841
- },
842
- index
843
- );
844
- })
845
- ]
2209
+ className: InputClass_default(errors.doctorName),
2210
+ placeholder: loadingDoctor ? "Buscando m\xE9dico..." : "Dr. Nome Completo",
2211
+ value: doctor.doctorName,
2212
+ onChange: (e) => {
2213
+ setDoctor({ doctorName: e.target.value });
2214
+ setErrors((p) => ({
2215
+ ...p,
2216
+ doctorName: void 0
2217
+ }));
2218
+ }
846
2219
  }
847
2220
  ),
848
- state === "isPreview" && /* @__PURE__ */ jsxs7(
849
- Button_default,
2221
+ loadingDoctor && /* @__PURE__ */ jsx20("div", { className: "absolute right-3 top-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxs16(
2222
+ "svg",
850
2223
  {
851
- onClick: () => setState("isEmpty"),
852
- className: "bg-transparent p-0 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
853
- id: "unauthorized_benefits_button",
2224
+ className: "h-4 w-4 animate-spin text-blue-500",
2225
+ viewBox: "0 0 24 24",
2226
+ fill: "none",
854
2227
  children: [
855
- "Aten\xE7\xE3o: N\xE3o \xE9 poss\xEDvel utilizar os benef\xEDcos sem realizar a consulta do CPF e o Login, por favor",
856
- " ",
857
- /* @__PURE__ */ jsx11("span", { className: "underline", children: "insira seu cpf para utilizar os benef\xEDcios" })
2228
+ /* @__PURE__ */ jsx20(
2229
+ "circle",
2230
+ {
2231
+ className: "opacity-25",
2232
+ cx: "12",
2233
+ cy: "12",
2234
+ r: "10",
2235
+ stroke: "currentColor",
2236
+ strokeWidth: "4"
2237
+ }
2238
+ ),
2239
+ /* @__PURE__ */ jsx20(
2240
+ "path",
2241
+ {
2242
+ className: "opacity-75",
2243
+ fill: "currentColor",
2244
+ d: "M4 12a8 8 0 018-8v8z"
2245
+ }
2246
+ )
858
2247
  ]
859
2248
  }
860
- ),
861
- state === "isActivated" && /* @__PURE__ */ jsxs7(Fragment3, { children: [
862
- !isAuthenticatedShopper && /* @__PURE__ */ jsx11(
863
- Button_default,
2249
+ ) })
2250
+ ] }),
2251
+ /* @__PURE__ */ jsx20("p", { className: "text-xs text-gray-400 mt-0.5", children: "Preenchido automaticamente ao informar registro + UF." })
2252
+ ] }),
2253
+ /* @__PURE__ */ jsx20(StepActions_default, { onNext: handleSubmit, onBack, loading })
2254
+ ] });
2255
+ };
2256
+ var StepDoctorForm_default = StepDoctorForm;
2257
+
2258
+ // src/components/Modals/CustomerNotRegistered/StepAcceptancesForm.tsx
2259
+ import { useState as useState8 } from "react";
2260
+
2261
+ // src/components/Modals/CustomerNotRegistered/Shared/CheckRow.tsx
2262
+ import classNames11 from "classnames";
2263
+ import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
2264
+ var CheckRow = ({
2265
+ label,
2266
+ checked,
2267
+ onChange,
2268
+ required,
2269
+ error
2270
+ }) => /* @__PURE__ */ jsxs17(
2271
+ "label",
2272
+ {
2273
+ className: classNames11(
2274
+ "flex items-start gap-3 cursor-pointer group p-3 rounded-lg border transition-all",
2275
+ checked ? "border-emerald-200 bg-emerald-50/60" : "border-zinc-100 hover:border-zinc-200 bg-zinc-50/40",
2276
+ error ? "border-red-300 bg-red-50/40" : ""
2277
+ ),
2278
+ children: [
2279
+ /* @__PURE__ */ jsx21(
2280
+ "div",
2281
+ {
2282
+ className: classNames11(
2283
+ "mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-all",
2284
+ checked ? "border-(--pbm-primary) bg-(--pbm-primary)" : "border-zinc-300 bg-white"
2285
+ ),
2286
+ children: checked && /* @__PURE__ */ jsx21("svg", { className: "h-2.5 w-2.5 text-white", viewBox: "0 0 10 8", fill: "none", children: /* @__PURE__ */ jsx21(
2287
+ "path",
2288
+ {
2289
+ d: "M1 4l3 3 5-6",
2290
+ stroke: "currentColor",
2291
+ strokeWidth: "1.8",
2292
+ strokeLinecap: "round",
2293
+ strokeLinejoin: "round"
2294
+ }
2295
+ ) })
2296
+ }
2297
+ ),
2298
+ /* @__PURE__ */ jsxs17("span", { className: "text-sm text-zinc-700 leading-snug", children: [
2299
+ label,
2300
+ required && /* @__PURE__ */ jsx21("span", { className: "text-red-400 ml-1", children: "*" })
2301
+ ] }),
2302
+ /* @__PURE__ */ jsx21(
2303
+ "input",
2304
+ {
2305
+ type: "checkbox",
2306
+ className: "sr-only",
2307
+ checked,
2308
+ onChange: (e) => onChange(e.target.checked)
2309
+ }
2310
+ )
2311
+ ]
2312
+ }
2313
+ );
2314
+ var CheckRow_default = CheckRow;
2315
+
2316
+ // src/services/set-acceptances-data-form.ts
2317
+ import Cookies10 from "js-cookie";
2318
+ var SetAcceptancesDataForm = async ({ document, requestId, lgpd }) => {
2319
+ const API_URL = getEnv("VITE_API_URL");
2320
+ const AUTH_TOKEN = Cookies10.get("pbm-token");
2321
+ if (!AUTH_TOKEN) {
2322
+ throw new Error("Token is not defined in cookies or is expired");
2323
+ }
2324
+ const response = await fetch(`${API_URL}/programregistration/acceptances`, {
2325
+ method: "PUT",
2326
+ headers: {
2327
+ Authorization: `Bearer ${AUTH_TOKEN}`,
2328
+ "Content-Type": "application/json"
2329
+ },
2330
+ body: JSON.stringify({ document, requestId, ...lgpd })
2331
+ });
2332
+ const dataResponse = await response.json();
2333
+ if (!dataResponse.success) {
2334
+ throw new Error(dataResponse.message || "Failed to fetch authorization");
2335
+ }
2336
+ return dataResponse;
2337
+ };
2338
+
2339
+ // src/components/Modals/CustomerNotRegistered/StepAcceptancesForm.tsx
2340
+ import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
2341
+ var StepAcceptancesForm = ({
2342
+ securityNumber,
2343
+ onBack,
2344
+ onDone
2345
+ }) => {
2346
+ const { acceptances, setAcceptances } = usePBMForm();
2347
+ const store = usePBMStore();
2348
+ const [errors, setErrors] = useState8({});
2349
+ const [loading, setLoading] = useState8(false);
2350
+ const validate = () => {
2351
+ const e = {};
2352
+ if (!acceptances.acceptsPrivacyTermsLGPD)
2353
+ e.lgpd = "\xC9 obrigat\xF3rio aceitar os termos de privacidade (LGPD).";
2354
+ setErrors(e);
2355
+ return Object.keys(e).length === 0;
2356
+ };
2357
+ const handleSubmit = async () => {
2358
+ if (!validate()) return;
2359
+ setLoading(true);
2360
+ try {
2361
+ const response = await SetAcceptancesDataForm({
2362
+ document: securityNumber,
2363
+ requestId: store.requestId,
2364
+ lgpd: {
2365
+ acceptPhone: acceptances.acceptPhone,
2366
+ acceptsSms: acceptances.acceptsSms,
2367
+ acceptsEmail: acceptances.acceptsEmail,
2368
+ acceptsMail: acceptances.acceptsMail,
2369
+ acceptsPrivacyTermsLGPD: acceptances.acceptsPrivacyTermsLGPD
2370
+ }
2371
+ });
2372
+ if (!response.success) {
2373
+ console.error("Failed to submit acceptances data:", response.message);
2374
+ return;
2375
+ }
2376
+ onDone();
2377
+ } catch {
2378
+ console.error("An error occurred while submitting acceptances data.");
2379
+ } finally {
2380
+ setLoading(false);
2381
+ }
2382
+ };
2383
+ return /* @__PURE__ */ jsxs18("div", { className: "flex flex-col gap-3", children: [
2384
+ /* @__PURE__ */ jsx22("p", { className: "text-xs text-gray-500 mb-1", children: "Selecione como deseja receber comunica\xE7\xF5es:" }),
2385
+ /* @__PURE__ */ jsx22(
2386
+ CheckRow_default,
2387
+ {
2388
+ label: "Aceito receber contato por telefone",
2389
+ checked: acceptances.acceptPhone,
2390
+ onChange: (v) => setAcceptances({ acceptPhone: v })
2391
+ }
2392
+ ),
2393
+ /* @__PURE__ */ jsx22(
2394
+ CheckRow_default,
2395
+ {
2396
+ label: "Aceito receber SMS",
2397
+ checked: acceptances.acceptsSms,
2398
+ onChange: (v) => setAcceptances({ acceptsSms: v })
2399
+ }
2400
+ ),
2401
+ /* @__PURE__ */ jsx22(
2402
+ CheckRow_default,
2403
+ {
2404
+ label: "Aceito receber e-mails",
2405
+ checked: acceptances.acceptsEmail,
2406
+ onChange: (v) => setAcceptances({ acceptsEmail: v })
2407
+ }
2408
+ ),
2409
+ /* @__PURE__ */ jsx22(
2410
+ CheckRow_default,
2411
+ {
2412
+ label: "Aceito receber correspond\xEAncias por correio",
2413
+ checked: acceptances.acceptsMail,
2414
+ onChange: (v) => setAcceptances({ acceptsMail: v })
2415
+ }
2416
+ ),
2417
+ /* @__PURE__ */ jsxs18("div", { className: "mt-1", children: [
2418
+ /* @__PURE__ */ jsx22(
2419
+ CheckRow_default,
2420
+ {
2421
+ label: "Li e aceito os Termos de Privacidade (LGPD)",
2422
+ checked: acceptances.acceptsPrivacyTermsLGPD,
2423
+ onChange: (v) => {
2424
+ setAcceptances({ acceptsPrivacyTermsLGPD: v });
2425
+ setErrors({});
2426
+ },
2427
+ required: true,
2428
+ error: errors.lgpd
2429
+ }
2430
+ ),
2431
+ errors.lgpd && /* @__PURE__ */ jsx22("span", { className: "text-xs text-red-500 mt-1 block pl-1", children: errors.lgpd })
2432
+ ] }),
2433
+ /* @__PURE__ */ jsx22(
2434
+ StepActions_default,
2435
+ {
2436
+ onNext: handleSubmit,
2437
+ onBack,
2438
+ loading,
2439
+ nextLabel: "Concluir cadastro",
2440
+ isLast: true
2441
+ }
2442
+ )
2443
+ ] });
2444
+ };
2445
+ var StepAcceptancesForm_default = StepAcceptancesForm;
2446
+
2447
+ // src/components/Modals/CustomerNotRegistered/Shared/StepProgress.tsx
2448
+ import classNames12 from "classnames";
2449
+ import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
2450
+ var STEP_LABELS = [
2451
+ "Dados Pessoais",
2452
+ "Endere\xE7o",
2453
+ "Perfil",
2454
+ "M\xE9dico",
2455
+ "Aceites"
2456
+ ];
2457
+ var StepProgress = ({ current }) => /* @__PURE__ */ jsx23("div", { className: "flex items-center w-full justify-center mb-6", children: STEP_LABELS.map((label, i) => {
2458
+ const done = i < current;
2459
+ const active = i === current;
2460
+ return /* @__PURE__ */ jsxs19(
2461
+ "div",
2462
+ {
2463
+ className: "flex items-center w-full min-w-0 justify-center relative",
2464
+ children: [
2465
+ /* @__PURE__ */ jsxs19("div", { className: "flex flex-col items-center justify-center gap-1 shrink-0", children: [
2466
+ /* @__PURE__ */ jsx23(
2467
+ "div",
864
2468
  {
865
- type: "button",
866
- onClick: () => window.location.assign(customLoginUrl || "/login"),
867
- className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
868
- id: "login",
869
- children: /* @__PURE__ */ jsx11("span", { className: "underline", children: "Por favor, fa\xE7a o Login para aproveitar os benef\xEDcios!" })
2469
+ className: classNames12(
2470
+ "flex h-7 w-7 items-center justify-center rounded-full text-xs font-semibold transition-all",
2471
+ done ? "bg-emerald-600 text-white" : active ? "bg-(--pbm-primary) text-white ring-4 ring-(--pbm-primary)/15" : "bg-zinc-100 text-zinc-400"
2472
+ ),
2473
+ children: done ? /* @__PURE__ */ jsx23("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 12 10", fill: "none", children: /* @__PURE__ */ jsx23(
2474
+ "path",
2475
+ {
2476
+ d: "M1 5l4 4 6-8",
2477
+ stroke: "currentColor",
2478
+ strokeWidth: "2",
2479
+ strokeLinecap: "round",
2480
+ strokeLinejoin: "round"
2481
+ }
2482
+ ) }) : i + 1
870
2483
  }
871
2484
  ),
872
- /* @__PURE__ */ jsx11(
873
- Button_default,
2485
+ /* @__PURE__ */ jsx23(
2486
+ "span",
874
2487
  {
875
- onClick: () => setState("isEmpty"),
876
- className: "bg-transparent p-0 pl-2 w-auto h-auto text-zinc-600 cursor-pointer hover:text-zinc-900 hover:bg-transparent text-start",
877
- id: "change_security_number",
878
- children: /* @__PURE__ */ jsx11("span", { className: "underline", children: "Deseja editar o cpf digitado?" })
2488
+ className: classNames12(
2489
+ "text-[10px] font-medium whitespace-nowrap hidden sm:block",
2490
+ active ? "text-(--pbm-primary)" : done ? "text-emerald-600" : "text-zinc-400"
2491
+ ),
2492
+ children: label
879
2493
  }
880
2494
  )
881
- ] })
2495
+ ] }),
2496
+ i < STEP_LABELS.length - 1 && /* @__PURE__ */ jsx23(
2497
+ "div",
2498
+ {
2499
+ className: classNames12(
2500
+ "h-0.5 w-10 rounded transition-all absolute top-3.5 left-17",
2501
+ "bg-zinc-200"
2502
+ )
2503
+ }
2504
+ )
882
2505
  ]
883
- }
2506
+ },
2507
+ i
884
2508
  );
885
- }
886
- var BenefitsTable_default = BenefitsTable;
2509
+ }) });
2510
+ var StepProgress_default = StepProgress;
887
2511
 
888
- // src/components/SecurityNumberInvalid/index.tsx
889
- import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
890
- function SecurityNumberInvalid({ textColor }) {
891
- const { urlAcceptTerms } = usePBMStore();
892
- const { setModal } = useModal();
893
- const handleOpenModal = () => {
894
- if (!urlAcceptTerms) return;
895
- setModal({ open: true, id: "iframe_pbm", label: "Aceitar os termos", url: urlAcceptTerms });
896
- };
897
- return /* @__PURE__ */ jsxs8(
898
- "section",
2512
+ // src/components/Modals/CustomerNotRegistered/Shared/SuccessScreen.tsx
2513
+ import { jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
2514
+ var SuccessScreen = ({ onClose }) => /* @__PURE__ */ jsxs20("div", { className: "flex flex-col items-center gap-4 py-4 text-center", children: [
2515
+ /* @__PURE__ */ jsx24("div", { className: "flex h-16 w-16 items-center justify-center rounded-full bg-green-100", children: /* @__PURE__ */ jsx24("svg", { className: "h-8 w-8 text-green-500", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx24(
2516
+ "path",
899
2517
  {
900
- "data-testid": "test_id_invalid",
901
- className: "flex items-end justify-center gap-2 w-full h-auto flex-col border-y py-6",
902
- style: { borderColor: "color-mix(in srgb, var(--pbm-text), transparent 80%)" },
903
- id: "security_number_invalid_container_pbm",
904
- children: [
905
- /* @__PURE__ */ jsx12(Title_default, { className: "w-full", textColor, children: "CPF n\xE3o cadastrado." }),
906
- /* @__PURE__ */ jsxs8(Text_default, { className: "w-full", textColor, children: [
907
- "Conclua seu cadastro para habilitar o benef\xEDcio. ",
908
- /* @__PURE__ */ jsx12("br", {}),
909
- "Ao clicar em \u201CAceitar os termos\u201D, voc\xEA ir\xE1 para uma p\xE1gina externa. Aceite os termos e volte para continuar."
910
- ] }),
911
- /* @__PURE__ */ jsx12(Button_default, { onClick: () => handleOpenModal(), style: { backgroundColor: "var(--pbm-primary)" }, children: "Aceitar os termos" })
912
- ]
2518
+ d: "M5 13l4 4L19 7",
2519
+ stroke: "currentColor",
2520
+ strokeWidth: "2.5",
2521
+ strokeLinecap: "round",
2522
+ strokeLinejoin: "round"
913
2523
  }
914
- );
915
- }
916
- var SecurityNumberInvalid_default = SecurityNumberInvalid;
2524
+ ) }) }),
2525
+ /* @__PURE__ */ jsxs20("div", { children: [
2526
+ /* @__PURE__ */ jsx24("h3", { className: "text-base font-semibold text-gray-800", children: "Cadastro conclu\xEDdo!" }),
2527
+ /* @__PURE__ */ jsx24("p", { className: "text-sm text-zinc-500 mt-1", children: "Voc\xEA j\xE1 pode aproveitar os benef\xEDcios de farm\xE1cia." })
2528
+ ] }),
2529
+ /* @__PURE__ */ jsx24(
2530
+ "button",
2531
+ {
2532
+ onClick: onClose,
2533
+ className: "cursor-pointer mt-2 rounded-lg bg-(--primary-color) px-6 py-2.5 text-sm font-semibold text-white hover:bg-(--primary-color)/80 transition-all",
2534
+ children: "Fechar"
2535
+ }
2536
+ )
2537
+ ] });
2538
+ var SuccessScreen_default = SuccessScreen;
917
2539
 
918
- // src/components/SecurityNumberRegitered/index.tsx
919
- import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
920
- function SecurityNumberRegitered({ textColor }) {
921
- const { urlRegisterIndustry } = usePBMStore();
922
- const { setModal } = useModal();
923
- const handleOpenModal = () => {
924
- if (!urlRegisterIndustry) return;
925
- setModal({ open: true, id: "iframe_pbm", label: "Ativar CPF", url: urlRegisterIndustry });
2540
+ // src/components/Modals/CustomerNotRegistered/index.tsx
2541
+ import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
2542
+ var CustomerNotRegistered = ({ ID }) => {
2543
+ const { modal, setModal } = useModal();
2544
+ const { securityNumber } = usePBMStore();
2545
+ const { resetForm, step, setStep } = usePBMForm();
2546
+ const [done, setDone] = useState9(false);
2547
+ const closeModal = () => {
2548
+ setModal({ id: "", open: false });
2549
+ setTimeout(() => {
2550
+ setStep(0);
2551
+ setDone(false);
2552
+ resetForm();
2553
+ }, 300);
926
2554
  };
927
- return /* @__PURE__ */ jsxs9(
928
- "section",
2555
+ const next = () => setStep(step + 1);
2556
+ const back = () => setStep(step - 1);
2557
+ const rawSecurityNumber = securityNumber.replace(/\D/g, "");
2558
+ const stepComponents = [
2559
+ /* @__PURE__ */ jsx25(StepPersonalDataForm_default, { securityNumber: rawSecurityNumber, onNext: next }),
2560
+ /* @__PURE__ */ jsx25(
2561
+ StepAddressForm_default,
2562
+ {
2563
+ securityNumber: rawSecurityNumber,
2564
+ onNext: next,
2565
+ onBack: back
2566
+ }
2567
+ ),
2568
+ /* @__PURE__ */ jsx25(
2569
+ StepGenderForm_default,
2570
+ {
2571
+ securityNumber: rawSecurityNumber,
2572
+ onNext: next,
2573
+ onBack: back
2574
+ }
2575
+ ),
2576
+ /* @__PURE__ */ jsx25(
2577
+ StepDoctorForm_default,
2578
+ {
2579
+ securityNumber: rawSecurityNumber,
2580
+ onNext: next,
2581
+ onBack: back
2582
+ }
2583
+ ),
2584
+ /* @__PURE__ */ jsx25(
2585
+ StepAcceptancesForm_default,
2586
+ {
2587
+ securityNumber: rawSecurityNumber,
2588
+ onBack: back,
2589
+ onDone: () => setDone(true)
2590
+ }
2591
+ )
2592
+ ];
2593
+ return /* @__PURE__ */ jsxs21(
2594
+ "main",
929
2595
  {
930
- "data-testid": "test_id_registered",
931
- className: "flex items-end justify-center gap-2 w-full h-auto flex-col border-y py-6",
932
- style: { borderColor: "color-mix(in srgb, var(--pbm-text), transparent 80%)" },
933
- id: "security_number_registered_container_pbm",
2596
+ className: classNames13(
2597
+ "fixed inset-0 flex items-center justify-end z-50 flex-col transition-all shadow bg-black/40",
2598
+ {
2599
+ "opacity-100 pointer-events-auto": modal.id === ID && modal.open,
2600
+ "opacity-0 pointer-events-none": modal.id !== ID || !modal.open
2601
+ }
2602
+ ),
934
2603
  children: [
935
- /* @__PURE__ */ jsx13(Title_default, { className: "w-full", textColor, children: "Ops, seu CPF ainda n\xE3o est\xE1 habilitado para este produto." }),
936
- /* @__PURE__ */ jsx13(Text_default, { className: "w-full", textColor, children: "Para ativar o benef\xEDcio, clique em \u201CAtivar CPF\u201D e conclua a etapa na p\xE1gina externa. Depois, \xE9 s\xF3 voltar para continuar \u2014 vamos aguardar voc\xEA aqui." }),
937
- /* @__PURE__ */ jsx13(Button_default, { onClick: () => handleOpenModal(), style: { backgroundColor: "var(--pbm-primary)" }, children: "Ativar CPF" })
2604
+ /* @__PURE__ */ jsx25("div", { className: "absolute inset-0", onClick: closeModal }),
2605
+ /* @__PURE__ */ jsxs21("section", { className: "z-10 bg-white flex flex-col p-6 rounded-2xl w-full max-w-max mx-4 shadow-xl max-h-[90vh] overflow-y-auto", children: [
2606
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between mb-4", children: [
2607
+ /* @__PURE__ */ jsx25(Title_default, { textSize: "18px", textAlign: "start", children: done ? "Tudo pronto!" : "Benef\xEDcio de Farm\xE1cia" }),
2608
+ /* @__PURE__ */ jsx25(
2609
+ "button",
2610
+ {
2611
+ onClick: closeModal,
2612
+ className: "flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-gray-400 hover:bg-gray-100 hover:text-gray-600 transition-all",
2613
+ children: /* @__PURE__ */ jsx25("svg", { className: "h-4 w-4", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx25(
2614
+ "path",
2615
+ {
2616
+ d: "M1 1l12 12M13 1L1 13",
2617
+ stroke: "currentColor",
2618
+ strokeWidth: "2",
2619
+ strokeLinecap: "round"
2620
+ }
2621
+ ) })
2622
+ }
2623
+ )
2624
+ ] }),
2625
+ !done && /* @__PURE__ */ jsx25(StepProgress_default, { current: step }),
2626
+ done ? /* @__PURE__ */ jsx25(SuccessScreen_default, { onClose: closeModal }) : stepComponents[step]
2627
+ ] })
938
2628
  ]
939
2629
  }
940
2630
  );
941
- }
942
- var SecurityNumberRegitered_default = SecurityNumberRegitered;
943
-
944
- // src/components/Errors/ErrorToApplyBenefits.tsx
945
- import { RefreshCw } from "lucide-react";
946
- import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
947
- var ErrorToApplyBenefits = () => {
948
- const { ErrorMessage } = useError();
949
- const { setState } = usePBMStore();
950
- return /* @__PURE__ */ jsxs10(Container_default, { variant: "main", children: [
951
- /* @__PURE__ */ jsx14(Title_default, { children: "Erro ao Aplicar o Benef\xEDcio" }),
952
- /* @__PURE__ */ jsx14(Text_default, { textAlign: "center", children: ErrorMessage }),
953
- /* @__PURE__ */ jsxs10(
954
- Button_default,
955
- {
956
- className: "bg-transparent p-0 pl-2 w-auto h-auto underline cursor-pointer hover:bg-transparent flex items-center justify-start gap-1",
957
- style: { color: "var(--pbm-text)" },
958
- onMouseOver: (e) => e.currentTarget.style.filter = "brightness(0.8)",
959
- onMouseOut: (e) => e.currentTarget.style.filter = "none",
960
- onClick: () => setState("isEmpty"),
961
- id: "check_benefits_button",
962
- children: [
963
- /* @__PURE__ */ jsx14("span", { children: "Tentar novamente" }),
964
- /* @__PURE__ */ jsx14(RefreshCw, { size: 16 })
965
- ]
966
- }
967
- )
968
- ] });
969
2631
  };
970
- var ErrorToApplyBenefits_default = ErrorToApplyBenefits;
2632
+ var CustomerNotRegistered_default = CustomerNotRegistered;
971
2633
 
972
2634
  // src/components/UI/Link/index.tsx
973
- import classNames8 from "classnames";
2635
+ import classNames14 from "classnames";
974
2636
 
975
2637
  // src/utils/getParams.ts
976
2638
  var getParams = (params) => {
@@ -979,16 +2641,16 @@ var getParams = (params) => {
979
2641
  };
980
2642
 
981
2643
  // src/components/UI/Link/index.tsx
982
- import { jsx as jsx15 } from "react/jsx-runtime";
2644
+ import { jsx as jsx26 } from "react/jsx-runtime";
983
2645
  function Link(props) {
984
2646
  const { setState } = usePBMStore();
985
- return /* @__PURE__ */ jsx15(
2647
+ return /* @__PURE__ */ jsx26(
986
2648
  "a",
987
2649
  {
988
2650
  ...props,
989
2651
  target: props.target || "_self",
990
2652
  href: typeof props.href === "string" ? props.href : props.href.pathname + getParams(props.href.param),
991
- className: classNames8(
2653
+ className: classNames14(
992
2654
  "w-3xs cursor-pointer h-10 rounded-lg text-white text-sm font-semibold transition-colors flex items-center justify-center",
993
2655
  props.className
994
2656
  ),
@@ -1004,55 +2666,75 @@ function Link(props) {
1004
2666
  }
1005
2667
  var Link_default = Link;
1006
2668
 
1007
- // src/components/Modal/index.tsx
1008
- import classNames9 from "classnames";
1009
- import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
1010
- var Modal = ({ ID }) => {
2669
+ // src/components/Modals/ShopperIsNotAuthenticated.tsx
2670
+ import classNames15 from "classnames";
2671
+ import { jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
2672
+ var ShopperIsNotAuthenticated = ({ ID }) => {
1011
2673
  const { customLoginUrl } = usePBMStore();
1012
2674
  const { modal, setModal } = useModal();
1013
- return /* @__PURE__ */ jsxs11("main", { className: classNames9(
1014
- "fixed inset-0 flex items-center justify-center z-50 flex-col transition-all shadow bg-black/40",
2675
+ return /* @__PURE__ */ jsxs22(
2676
+ "main",
1015
2677
  {
1016
- "opacity-100 pointer-events-auto": modal.id === ID && modal.open,
1017
- "opacity-0 pointer-events-none": modal.id != ID || !modal.open
2678
+ className: classNames15(
2679
+ "fixed inset-0 flex items-center justify-center z-50 flex-col transition-all shadow bg-black/40",
2680
+ {
2681
+ "opacity-100 pointer-events-auto": modal.id === ID && modal.open,
2682
+ "opacity-0 pointer-events-none": modal.id != ID || !modal.open
2683
+ }
2684
+ ),
2685
+ children: [
2686
+ /* @__PURE__ */ jsx27(
2687
+ "div",
2688
+ {
2689
+ className: "absolute inset-0",
2690
+ onClick: () => setModal({ id: "", open: false })
2691
+ }
2692
+ ),
2693
+ /* @__PURE__ */ jsxs22("section", { className: "z-10 bg-white gap-2 flex-col items-center-safe justify-center-safe p-8 rounded-xl", children: [
2694
+ /* @__PURE__ */ jsx27(
2695
+ Title_default,
2696
+ {
2697
+ textColor: "tomato",
2698
+ textSize: "18px",
2699
+ textAlign: "center",
2700
+ className: "mb-2",
2701
+ children: "Opa! Parece que voc\xEA n\xE3o est\xE1 Logado"
2702
+ }
2703
+ ),
2704
+ /* @__PURE__ */ jsxs22(Text_default, { className: "mb-2", textAlign: "center", children: [
2705
+ "Para aproveitar os benef\xEDcios \xE9 necess\xE1rio realizar o",
2706
+ " ",
2707
+ /* @__PURE__ */ jsx27("strong", { children: "Login" }),
2708
+ " ou ",
2709
+ /* @__PURE__ */ jsx27("strong", { children: "Cadastro" }),
2710
+ " no site!"
2711
+ ] }),
2712
+ /* @__PURE__ */ jsxs22("section", { className: "flex items-center-safe justify-center-safe gap-4", children: [
2713
+ /* @__PURE__ */ jsx27(
2714
+ Button_default,
2715
+ {
2716
+ className: "bg-gray-600 hover:bg-gray-500",
2717
+ onClick: () => setModal({ id: "", open: false }),
2718
+ children: "Seguir sem Benef\xEDcios"
2719
+ }
2720
+ ),
2721
+ /* @__PURE__ */ jsx27(Link_default, { href: customLoginUrl || "/login", children: "Aproveitar Benef\xEDcios" })
2722
+ ] })
2723
+ ] })
2724
+ ]
1018
2725
  }
1019
- ), children: [
1020
- /* @__PURE__ */ jsx16("div", { className: "absolute inset-0", onClick: () => setModal({ id: "", open: false }) }),
1021
- /* @__PURE__ */ jsxs11("section", { className: "z-10 bg-white gap-2 flex-col items-center-safe justify-center-safe p-8 rounded-xl", children: [
1022
- /* @__PURE__ */ jsx16(Title_default, { textColor: "tomato", textSize: "18px", textAlign: "center", className: "mb-2", children: "Opa! Parece que voc\xEA n\xE3o est\xE1 Logado" }),
1023
- /* @__PURE__ */ jsxs11(Text_default, { className: "mb-2", textAlign: "center", children: [
1024
- "Para aproveitar os benef\xEDcios \xE9 necess\xE1rio realizar o ",
1025
- /* @__PURE__ */ jsx16("strong", { children: "Login" }),
1026
- " ou ",
1027
- /* @__PURE__ */ jsx16("strong", { children: "Cadastro" }),
1028
- " no site!"
1029
- ] }),
1030
- /* @__PURE__ */ jsxs11("section", { className: "flex items-center-safe justify-center-safe gap-4", children: [
1031
- /* @__PURE__ */ jsx16(Button_default, { className: "bg-gray-600 hover:bg-gray-500", onClick: () => setModal({ id: "", open: false }), children: "Seguir sem Benef\xEDcios" }),
1032
- /* @__PURE__ */ jsx16(Link_default, { href: customLoginUrl || "/login", children: "Aproveitar Benef\xEDcios" })
1033
- ] })
1034
- ] })
1035
- ] });
2726
+ );
1036
2727
  };
1037
- var Modal_default = Modal;
2728
+ var ShopperIsNotAuthenticated_default = ShopperIsNotAuthenticated;
1038
2729
 
1039
2730
  // src/PBM.tsx
1040
2731
  import Skeleton from "@mui/material/Skeleton";
1041
2732
 
1042
- // src/utils/format-price.ts
1043
- var formatedPrice = (price) => {
1044
- const result = Number(String(price).replace(",", "."));
1045
- return result;
1046
- };
1047
-
1048
- // src/PBM.tsx
1049
- import { useTransition as useTransition2 } from "react";
1050
-
1051
2733
  // src/hooks/useAppStartup.tsx
1052
- import { useEffect as useEffect3, useState as useState3 } from "react";
2734
+ import { useEffect as useEffect4, useState as useState10 } from "react";
1053
2735
 
1054
2736
  // src/services/authorization.ts
1055
- import Cookies3 from "js-cookie";
2737
+ import Cookies11 from "js-cookie";
1056
2738
 
1057
2739
  // src/services/clients-config.ts
1058
2740
  var CLIENTS_CONFIG = {
@@ -1087,7 +2769,7 @@ var GetAuthorization = async ({ tenant_id }) => {
1087
2769
  throw new Error("Authorization failed");
1088
2770
  }
1089
2771
  const SECONDS_IN_A_DAY = 86400;
1090
- Cookies3.set("pbm-token", data.data.access_token, {
2772
+ Cookies11.set("pbm-token", data.data.access_token, {
1091
2773
  secure: true,
1092
2774
  sameSite: "Strict",
1093
2775
  expires: data.data.expires_in / SECONDS_IN_A_DAY
@@ -1096,10 +2778,10 @@ var GetAuthorization = async ({ tenant_id }) => {
1096
2778
  };
1097
2779
 
1098
2780
  // src/services/get-product-by-ean.ts
1099
- import Cookies4 from "js-cookie";
2781
+ import Cookies12 from "js-cookie";
1100
2782
  var GetProductByEAN = async ({ PRODUCT_EAN }) => {
1101
2783
  const API_URL = getEnv("VITE_API_URL");
1102
- const AUTH_TOKEN = Cookies4.get("pbm-token");
2784
+ const AUTH_TOKEN = Cookies12.get("pbm-token");
1103
2785
  if (!AUTH_TOKEN) {
1104
2786
  throw new Error("Token is not defined in cookies or is expired");
1105
2787
  }
@@ -1118,10 +2800,10 @@ var GetProductByEAN = async ({ PRODUCT_EAN }) => {
1118
2800
  };
1119
2801
 
1120
2802
  // src/services/get-list-products.ts
1121
- import Cookies5 from "js-cookie";
2803
+ import Cookies13 from "js-cookie";
1122
2804
  var GetProductsWithBenefits = async (eanProduct) => {
1123
2805
  const API_URL = getEnv("VITE_API_URL");
1124
- const AUTH_TOKEN = Cookies5.get("pbm-token");
2806
+ const AUTH_TOKEN = Cookies13.get("pbm-token");
1125
2807
  if (!AUTH_TOKEN) {
1126
2808
  throw new Error("Token is not defined in cookies or is expired");
1127
2809
  }
@@ -1147,9 +2829,11 @@ var initialThemeState = {
1147
2829
  secondaryColor: "#339c9b",
1148
2830
  backgroundColor: "#ffffff",
1149
2831
  textColor: "#52525b",
1150
- // zinc-600
1151
- borderColor: "#44c2c0"
1152
- // zinc-600
2832
+ borderColor: "#44c2c0",
2833
+ inputOutlineColor: "transparent",
2834
+ inputOutlineFocusColor: "#323232",
2835
+ inputBackgroundColor: "#EDEDED",
2836
+ inputFocusBackgroundColor: "#EDEDED"
1153
2837
  };
1154
2838
  var themeStore = createStore2(
1155
2839
  (set) => ({
@@ -1173,9 +2857,9 @@ var useAppStartup = (props) => {
1173
2857
  setCustomLoginUrl
1174
2858
  } = usePBMStore();
1175
2859
  const { setTheme } = useTheme();
1176
- const [IsReady, setIsReady] = useState3(false);
1177
- const [IsValid, setIsValid] = useState3(false);
1178
- const [EanProductExist, setEanProductExist] = useState3(true);
2860
+ const [IsReady, setIsReady] = useState10(false);
2861
+ const [IsValid, setIsValid] = useState10(false);
2862
+ const [EanProductExist, setEanProductExist] = useState10(true);
1179
2863
  const fetchAuthorizationRequest = async () => {
1180
2864
  try {
1181
2865
  const response = await GetAuthorization({ tenant_id: props.tenant_id });
@@ -1239,7 +2923,7 @@ var useAppStartup = (props) => {
1239
2923
  setEanProductExist(false);
1240
2924
  }
1241
2925
  };
1242
- useEffect3(() => {
2926
+ useEffect4(() => {
1243
2927
  let isMounted = true;
1244
2928
  const startup = async () => {
1245
2929
  if (props.theme) {
@@ -1263,128 +2947,19 @@ var useAppStartup = (props) => {
1263
2947
  };
1264
2948
  var useAppStartup_default = useAppStartup;
1265
2949
 
1266
- // src/components/Iframe/index.tsx
1267
- import classNames10 from "classnames";
1268
- import { TriangleAlert, ExternalLink } from "lucide-react";
1269
- import { useState as useState4, useEffect as useEffect4 } from "react";
1270
- import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
1271
- function Iframe() {
1272
- const [showFallback, setShowFallback] = useState4(false);
1273
- const { setState } = usePBMStore();
1274
- const { resetModal, modal } = useModal();
1275
- const isOpen = modal.open && modal.id === "iframe_pbm";
1276
- useEffect4(() => {
1277
- if (isOpen) {
1278
- setShowFallback(false);
1279
- }
1280
- }, [isOpen, modal.url]);
1281
- const handleOpenInNewWindow = () => {
1282
- if (modal.url) {
1283
- window.open(modal.url, "_blank", "noopener,noreferrer");
1284
- }
1285
- };
1286
- const handleClose = () => {
1287
- setState("isEmpty");
1288
- resetModal();
1289
- };
1290
- if (!modal.url) return;
1291
- return /* @__PURE__ */ jsxs12(
1292
- "main",
1293
- {
1294
- className: classNames10(
1295
- "fixed inset-0 flex items-center justify-center z-50 flex-col transition-all duration-300 pt-[10%]",
1296
- isOpen ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
1297
- ),
1298
- id: "iframe_pbm",
1299
- children: [
1300
- /* @__PURE__ */ jsx17(
1301
- "div",
1302
- {
1303
- className: "bg-black/40 inset-0 absolute backdrop-blur-sm",
1304
- onClick: handleClose
1305
- }
1306
- ),
1307
- /* @__PURE__ */ jsxs12("section", { className: "w-[90%] md:w-4/5 gap-4 h-auto bg-zinc-900 py-3 px-6 flex items-center justify-end rounded-t-2xl border-b border-white/10 z-10 shadow-2xl", children: [
1308
- /* @__PURE__ */ jsx17(
1309
- Button_default,
1310
- {
1311
- onClick: handleClose,
1312
- className: "bg-red-500 hover:bg-red-400 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
1313
- children: "Cancelar"
1314
- }
1315
- ),
1316
- /* @__PURE__ */ jsx17(
1317
- Button_default,
1318
- {
1319
- onClick: handleClose,
1320
- className: "bg-blue-600 hover:bg-blue-500 w-auto px-6 h-9 transition-all active:scale-95 shadow-lg text-xs md:text-sm",
1321
- children: "Finalizei o formul\xE1rio"
1322
- }
1323
- )
1324
- ] }),
1325
- /* @__PURE__ */ jsx17("div", { className: "w-[90%] md:w-4/5 h-[60vh] bg-zinc-900 z-10 overflow-hidden relative shadow-2xl", children: showFallback ? /* @__PURE__ */ jsxs12("div", { className: "absolute inset-0 flex flex-col items-center justify-center p-8 text-center bg-zinc-900", children: [
1326
- /* @__PURE__ */ jsx17("div", { className: "bg-yellow-500/10 p-4 rounded-full mb-4 animate-pulse", children: /* @__PURE__ */ jsx17(TriangleAlert, { size: 48, className: "text-yellow-500" }) }),
1327
- /* @__PURE__ */ jsx17(Title_default, { textColor: "white", textSize: "20px", textAlign: "center", className: "mb-2", children: "N\xE3o foi poss\xEDvel carregar o conte\xFAdo" }),
1328
- /* @__PURE__ */ jsx17(Text_default, { textColor: "#a1a1aa", textAlign: "center", className: "mb-8 max-w-md", children: "Este conte\xFAdo n\xE3o permite exibi\xE7\xE3o integrada por seguran\xE7a. Clique no bot\xE3o abaixo para concluir em uma nova aba." }),
1329
- /* @__PURE__ */ jsxs12(
1330
- Button_default,
1331
- {
1332
- onClick: handleOpenInNewWindow,
1333
- className: "flex items-center gap-2 w-auto px-8 h-12 shadow-xl shadow-emerald-500/20",
1334
- children: [
1335
- /* @__PURE__ */ jsx17(ExternalLink, { size: 18 }),
1336
- "Abrir em nova janela"
1337
- ]
1338
- }
1339
- )
1340
- ] }) : /* @__PURE__ */ jsx17(
1341
- "iframe",
1342
- {
1343
- src: modal.url,
1344
- title: modal.label ?? "Conte\xFAdo PBM",
1345
- className: "w-full h-full border-none bg-white animate-fade-in",
1346
- allowFullScreen: true,
1347
- onError: () => setShowFallback(true)
1348
- }
1349
- ) }),
1350
- /* @__PURE__ */ jsxs12("section", { className: "w-[90%] md:w-4/5 flex flex-col md:flex-row items-center justify-between gap-3 bg-zinc-900 py-4 px-6 rounded-b-2xl border-t border-white/5 z-10 shadow-2xl", children: [
1351
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
1352
- /* @__PURE__ */ jsx17(TriangleAlert, { size: 18, className: "text-yellow-500 shrink-0" }),
1353
- /* @__PURE__ */ jsxs12(Text_default, { textColor: "white", className: "text-[10px] md:text-xs", children: [
1354
- /* @__PURE__ */ jsx17("span", { className: "text-yellow-500 font-bold mr-1", children: "Importante:" }),
1355
- "Se a p\xE1gina n\xE3o carregar, tente abrir em tela cheia usando o bot\xE3o ao lado."
1356
- ] })
1357
- ] }),
1358
- /* @__PURE__ */ jsxs12(
1359
- "button",
1360
- {
1361
- onClick: handleOpenInNewWindow,
1362
- className: "text-white/60 hover:text-white text-[11px] underline flex items-center gap-1 transition-colors cursor-pointer",
1363
- children: [
1364
- /* @__PURE__ */ jsx17(ExternalLink, { size: 14 }),
1365
- " Abrir em nova aba"
1366
- ]
1367
- }
1368
- )
1369
- ] })
1370
- ]
1371
- }
1372
- );
1373
- }
1374
- var Iframe_default = Iframe;
1375
-
1376
2950
  // src/PBM.tsx
1377
- import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
2951
+ import { useTransition as useTransition2 } from "react";
2952
+ import { Fragment as Fragment3, jsx as jsx28, jsxs as jsxs23 } from "react/jsx-runtime";
1378
2953
  function PBM(props) {
1379
2954
  const { state } = usePBMStore();
1380
2955
  const { IsReady, EanProductExist, IsValid } = useAppStartup_default(props);
1381
2956
  const { setErrorMessage } = useError();
1382
2957
  const theme = useTheme();
1383
2958
  const [isPending, startTransition] = useTransition2();
1384
- const formatedProductPrice = formatedPrice(props.original_product_price);
2959
+ const formatedProductPrice = formaters.price(props.original_product_price);
1385
2960
  if (!IsValid) return;
1386
2961
  if (!IsReady) {
1387
- return /* @__PURE__ */ jsx18(
2962
+ return /* @__PURE__ */ jsx28(
1388
2963
  Skeleton,
1389
2964
  {
1390
2965
  variant: "rectangular",
@@ -1398,9 +2973,9 @@ function PBM(props) {
1398
2973
  setErrorMessage(
1399
2974
  "O produto n\xE3o foi encontrado no sistema. Por favor, tente novamente mais tarde ou contate o suporte."
1400
2975
  );
1401
- return /* @__PURE__ */ jsx18("div", { id: "pbm-library-root", children: /* @__PURE__ */ jsx18(ErrorToApplyBenefits_default, {}) });
2976
+ return /* @__PURE__ */ jsx28("div", { id: "pbm-library-root", children: /* @__PURE__ */ jsx28(ErrorToApplyBenefits_default, {}) });
1402
2977
  }
1403
- return /* @__PURE__ */ jsxs13(
2978
+ return /* @__PURE__ */ jsxs23(
1404
2979
  "div",
1405
2980
  {
1406
2981
  id: "pbm-library-root",
@@ -1409,22 +2984,26 @@ function PBM(props) {
1409
2984
  "--pbm-secondary": theme.secondaryColor,
1410
2985
  "--pbm-bg": theme.backgroundColor,
1411
2986
  "--pbm-text": theme.textColor,
1412
- "--pbm-border": theme.borderColor
2987
+ "--pbm-border": theme.borderColor,
2988
+ "--pbm-outline-color": theme.inputOutlineColor,
2989
+ "--pbm-outline-focus-color": theme.inputOutlineFocusColor,
2990
+ "--pbm-input-focus-background": theme.inputFocusBackgroundColor,
2991
+ "--pbm-input-background": theme.inputBackgroundColor
1413
2992
  },
1414
2993
  children: [
1415
- /* @__PURE__ */ jsxs13(Container_default, { variant: "main", children: [
1416
- /* @__PURE__ */ jsx18(Header_default, { originalProductPrice: formatedProductPrice || 0 }),
1417
- /* @__PURE__ */ jsx18(Container_default, { variant: "simple", children: isPending ? /* @__PURE__ */ jsx18(Loading_default, {}) : /* @__PURE__ */ jsxs13(Fragment4, { children: [
1418
- state === "isEmpty" && /* @__PURE__ */ jsx18(Form_default, { startTransition }),
1419
- state === "isInvalid" && /* @__PURE__ */ jsx18(SecurityNumberInvalid_default, {}),
1420
- state === "isRegistered" && /* @__PURE__ */ jsx18(SecurityNumberRegitered_default, {}),
1421
- (state === "isActivated" || state === "isPreview") && /* @__PURE__ */ jsx18(BenefitsTable_default, {}),
1422
- state === "isError" && /* @__PURE__ */ jsx18(ErrorToApplyBenefits_default, {})
1423
- ] }) }),
1424
- /* @__PURE__ */ jsx18(Footer_default, {})
2994
+ /* @__PURE__ */ jsxs23(Container_default, { variant: "main", children: [
2995
+ /* @__PURE__ */ jsx28(Header_default, { originalProductPrice: formatedProductPrice || 0 }),
2996
+ /* @__PURE__ */ jsx28(Container_default, { variant: "simple", children: isPending ? /* @__PURE__ */ jsx28(Loading_default, {}) : /* @__PURE__ */ jsxs23(Fragment3, { children: [
2997
+ state === "isEmpty" && /* @__PURE__ */ jsx28(Form_default, { startTransition }),
2998
+ state === "isInvalid" && /* @__PURE__ */ jsx28(SecurityNumberInvalid_default, {}),
2999
+ state === "isRegistered" && /* @__PURE__ */ jsx28(SecurityNumberRegitered_default, {}),
3000
+ (state === "isActivated" || state === "isPreview") && /* @__PURE__ */ jsx28(BenefitsTable_default, {}),
3001
+ state === "isError" && /* @__PURE__ */ jsx28(ErrorToApplyBenefits_default, {})
3002
+ ] }) })
1425
3003
  ] }),
1426
- /* @__PURE__ */ jsx18(Modal_default, { ID: "ShopperIsNotAuthenticated" }),
1427
- /* @__PURE__ */ jsx18(Iframe_default, {})
3004
+ /* @__PURE__ */ jsx28(ShopperIsNotAuthenticated_default, { ID: "ShopperIsNotAuthenticated" }),
3005
+ /* @__PURE__ */ jsx28(CustomerNotRegistered_default, { ID: "CustomerNotRegistered" }),
3006
+ /* @__PURE__ */ jsx28(Iframe_default, {})
1428
3007
  ]
1429
3008
  }
1430
3009
  );