@vtex/faststore 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/actions.json +181 -0
  3. package/dist/catalog.json +1595 -481
  4. package/dist/client.d.ts +2 -1
  5. package/dist/client.js +2 -1
  6. package/dist/components.d.ts +31 -7
  7. package/dist/components.js +35 -13
  8. package/dist/content-types.json +73 -0
  9. package/dist/docs/access-code-sign-in.md +1 -1
  10. package/dist/docs/account-access-gate.md +153 -0
  11. package/dist/docs/account-entry-point.md +1 -2
  12. package/dist/docs/account-menu.md +164 -0
  13. package/dist/docs/address-summary.md +24 -3
  14. package/dist/docs/alert-dialog.md +204 -0
  15. package/dist/docs/billing-address.md +284 -0
  16. package/dist/docs/buy-button.md +1 -1
  17. package/dist/docs/card-entry.md +250 -0
  18. package/dist/docs/cardholder-document.md +142 -0
  19. package/dist/docs/cart.md +1 -1
  20. package/dist/docs/client-preferences-fieldset.md +148 -0
  21. package/dist/docs/client-preferences.md +2 -1
  22. package/dist/docs/client-profile-fieldset.md +184 -0
  23. package/dist/docs/client-profile.md +1 -1
  24. package/dist/docs/document-field.md +58 -4
  25. package/dist/docs/field.md +317 -0
  26. package/dist/docs/form.md +307 -0
  27. package/dist/docs/identity-edit.md +6 -6
  28. package/dist/docs/identity-summary.md +5 -5
  29. package/dist/docs/installments.md +248 -0
  30. package/dist/docs/my-account-profile.md +1 -0
  31. package/dist/docs/order-placed-payment-summary.md +138 -0
  32. package/dist/docs/payment-method-badges.md +232 -0
  33. package/dist/docs/payment-methods.md +1 -0
  34. package/dist/docs/payment.md +218 -0
  35. package/dist/docs/phone-field.md +58 -4
  36. package/dist/docs/place-order.md +157 -0
  37. package/dist/docs/save-card.md +186 -0
  38. package/dist/docs/saved-cards.md +218 -0
  39. package/dist/docs/select.md +465 -0
  40. package/dist/docs/session.md +1 -1
  41. package/dist/docs/shipping-address.md +110 -258
  42. package/dist/docs/sign-in-redirect.md +1 -1
  43. package/dist/index.d.ts +4 -1
  44. package/dist/internal/client.d.ts +3 -1
  45. package/dist/internal/client.js +3 -1
  46. package/dist/matter/access-code-sign-in/access-code-sign-in.js +9 -8
  47. package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
  48. package/dist/matter/account-access-gate/account-access-gate.d.ts +86 -0
  49. package/dist/matter/account-access-gate/account-access-gate.js +283 -0
  50. package/dist/matter/account-access-gate/account-access-gate.js.map +1 -0
  51. package/dist/matter/account-access-gate/sign-out-intent.d.ts +17 -0
  52. package/dist/matter/account-access-gate/sign-out-intent.js +62 -0
  53. package/dist/matter/account-access-gate/sign-out-intent.js.map +1 -0
  54. package/dist/matter/account-entry-point/account-entry-point.js +2 -2
  55. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
  56. package/dist/matter/account-menu/account-menu.d.ts +88 -0
  57. package/dist/matter/account-menu/account-menu.js +246 -0
  58. package/dist/matter/account-menu/account-menu.js.map +1 -0
  59. package/dist/matter/billing-address/billing-address.d.ts +165 -0
  60. package/dist/matter/billing-address/billing-address.js +408 -0
  61. package/dist/matter/billing-address/billing-address.js.map +1 -0
  62. package/dist/matter/card-entry/card-capture.d.ts +25 -0
  63. package/dist/matter/card-entry/card-capture.js +25 -0
  64. package/dist/matter/card-entry/card-capture.js.map +1 -0
  65. package/dist/matter/card-entry/card-entry.d.ts +120 -0
  66. package/dist/matter/card-entry/card-entry.js +832 -0
  67. package/dist/matter/card-entry/card-entry.js.map +1 -0
  68. package/dist/matter/cardholder-document/cardholder-document.d.ts +45 -0
  69. package/dist/matter/cardholder-document/cardholder-document.js +70 -0
  70. package/dist/matter/cardholder-document/cardholder-document.js.map +1 -0
  71. package/dist/matter/cart/cart.d.ts +1 -1
  72. package/dist/matter/cart/cart.js +2 -2
  73. package/dist/matter/cart/cart.js.map +1 -1
  74. package/dist/matter/client-preferences/client-preferences-fieldset.d.ts +77 -0
  75. package/dist/matter/client-preferences/client-preferences-fieldset.js +299 -0
  76. package/dist/matter/client-preferences/client-preferences-fieldset.js.map +1 -0
  77. package/dist/matter/client-preferences/client-preferences.d.ts +3 -5
  78. package/dist/matter/client-preferences/client-preferences.js +6 -6
  79. package/dist/matter/client-preferences/client-preferences.js.map +1 -1
  80. package/dist/matter/client-profile/client-profile.d.ts +4 -6
  81. package/dist/matter/client-profile/client-profile.js +9 -6
  82. package/dist/matter/client-profile/client-profile.js.map +1 -1
  83. package/dist/matter/client-profile-form/client-profile-fieldset.d.ts +119 -0
  84. package/dist/matter/client-profile-form/client-profile-fieldset.js +488 -0
  85. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -0
  86. package/dist/matter/delivery-options/delivery-options.js.map +1 -1
  87. package/dist/matter/identity-edit/identity-edit.js +2 -2
  88. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  89. package/dist/matter/identity-summary/identity-summary.js +2 -2
  90. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  91. package/dist/matter/installments/installments-select.d.ts +42 -0
  92. package/dist/matter/installments/installments-select.js +167 -0
  93. package/dist/matter/installments/installments-select.js.map +1 -0
  94. package/dist/matter/installments/installments.d.ts +58 -0
  95. package/dist/matter/installments/installments.js +176 -0
  96. package/dist/matter/installments/installments.js.map +1 -0
  97. package/dist/matter/installments/use-installments-selection.d.ts +29 -0
  98. package/dist/matter/installments/use-installments-selection.js +95 -0
  99. package/dist/matter/installments/use-installments-selection.js.map +1 -0
  100. package/dist/matter/my-account-profile/my-account-profile.js +5 -5
  101. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  102. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +63 -0
  103. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +305 -0
  104. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -0
  105. package/dist/matter/payment/payment-card-capture.d.ts +19 -0
  106. package/dist/matter/payment/payment-card-capture.js +129 -0
  107. package/dist/matter/payment/payment-card-capture.js.map +1 -0
  108. package/dist/matter/payment/payment-controller.d.ts +24 -0
  109. package/dist/matter/payment/payment-controller.js +107 -0
  110. package/dist/matter/payment/payment-controller.js.map +1 -0
  111. package/dist/matter/payment/payment-method-badges.d.ts +57 -0
  112. package/dist/matter/payment/payment-method-badges.js +192 -0
  113. package/dist/matter/payment/payment-method-badges.js.map +1 -0
  114. package/dist/matter/payment/payment.d.ts +89 -0
  115. package/dist/matter/payment/payment.js +263 -0
  116. package/dist/matter/payment/payment.js.map +1 -0
  117. package/dist/matter/payment/use-payment-method-selection.d.ts +302 -0
  118. package/dist/matter/payment/use-payment-method-selection.js +458 -0
  119. package/dist/matter/payment/use-payment-method-selection.js.map +1 -0
  120. package/dist/matter/payment/use-payment-submit-gate.d.ts +111 -0
  121. package/dist/matter/payment/use-payment-submit-gate.js +144 -0
  122. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -0
  123. package/dist/matter/place-order/place-order.d.ts +74 -0
  124. package/dist/matter/place-order/place-order.js +379 -0
  125. package/dist/matter/place-order/place-order.js.map +1 -0
  126. package/dist/matter/product-list/product-list.d.ts +1 -0
  127. package/dist/matter/product-list/product-list.js.map +1 -1
  128. package/dist/matter/product-shelf/product-shelf.d.ts +1 -0
  129. package/dist/matter/product-shelf/product-shelf.js +2 -0
  130. package/dist/matter/product-shelf/product-shelf.js.map +1 -1
  131. package/dist/matter/region/region.js +1 -1
  132. package/dist/matter/region/region.js.map +1 -1
  133. package/dist/matter/save-card/save-card.d.ts +49 -0
  134. package/dist/matter/save-card/save-card.js +188 -0
  135. package/dist/matter/save-card/save-card.js.map +1 -0
  136. package/dist/matter/saved-cards/saved-cards.d.ts +79 -0
  137. package/dist/matter/saved-cards/saved-cards.js +387 -0
  138. package/dist/matter/saved-cards/saved-cards.js.map +1 -0
  139. package/dist/matter/shipping-address/country-descriptors.js +20 -10
  140. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  141. package/dist/matter/shipping-address/shipping-address.d.ts +113 -174
  142. package/dist/matter/shipping-address/shipping-address.js +481 -792
  143. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  144. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  145. package/dist/matter/variant-selector/variant-selector.js +1 -1
  146. package/dist/particles/address-summary/address-summary.d.ts +24 -0
  147. package/dist/particles/address-summary/address-summary.js +83 -2
  148. package/dist/particles/address-summary/address-summary.js.map +1 -1
  149. package/dist/particles/alert-dialog/alert-dialog.d.ts +68 -0
  150. package/dist/particles/alert-dialog/alert-dialog.js +187 -0
  151. package/dist/particles/alert-dialog/alert-dialog.js.map +1 -0
  152. package/dist/particles/checkbox/checkbox.d.ts +7 -3
  153. package/dist/particles/checkbox/checkbox.js +4 -1
  154. package/dist/particles/checkbox/checkbox.js.map +1 -1
  155. package/dist/particles/document-field/document-field.d.ts +48 -5
  156. package/dist/particles/document-field/document-field.js +189 -32
  157. package/dist/particles/document-field/document-field.js.map +1 -1
  158. package/dist/particles/field/bound-field-registry.js +52 -0
  159. package/dist/particles/field/bound-field-registry.js.map +1 -0
  160. package/dist/particles/field/field.d.ts +116 -0
  161. package/dist/particles/field/field.js +497 -6
  162. package/dist/particles/field/field.js.map +1 -1
  163. package/dist/particles/fieldset/fieldset.js +2 -2
  164. package/dist/particles/fieldset/fieldset.js.map +1 -1
  165. package/dist/particles/footer-social/footer-social.js +1 -1
  166. package/dist/particles/form/form.d.ts +104 -0
  167. package/dist/particles/form/form.js +485 -0
  168. package/dist/particles/form/form.js.map +1 -0
  169. package/dist/particles/incentives/incentives.js +1 -1
  170. package/dist/particles/phone-field/phone-field.d.ts +38 -10
  171. package/dist/particles/phone-field/phone-field.js +183 -39
  172. package/dist/particles/phone-field/phone-field.js.map +1 -1
  173. package/dist/particles/postal-code-field/postal-code-field.js +2 -2
  174. package/dist/particles/postal-code-field/postal-code-field.js.map +1 -1
  175. package/dist/particles/select/field-select.d.ts +43 -0
  176. package/dist/particles/select/field-select.js +150 -0
  177. package/dist/particles/select/field-select.js.map +1 -0
  178. package/dist/particles/select/select.d.ts +2 -0
  179. package/dist/particles/select/select.js.map +1 -1
  180. package/dist/particles/shared/compose-refs.js +21 -0
  181. package/dist/particles/shared/compose-refs.js.map +1 -0
  182. package/dist/schema.graphql +701 -2
  183. package/dist/sdk/actions/analytics-action-provider.d.ts +15 -0
  184. package/dist/sdk/actions/analytics-action-provider.js +19 -0
  185. package/dist/sdk/actions/analytics-action-provider.js.map +1 -0
  186. package/dist/sdk/actions/cart-action-provider.d.ts +1 -1
  187. package/dist/sdk/actions/cart-action-provider.js +1 -1
  188. package/dist/sdk/actions/cart-action-provider.js.map +1 -1
  189. package/dist/sdk/actions/index.d.ts +3 -1
  190. package/dist/sdk/actions/index.js +3 -1
  191. package/dist/sdk/actions/payment-action-provider.d.ts +22 -0
  192. package/dist/sdk/actions/payment-action-provider.js +26 -0
  193. package/dist/sdk/actions/payment-action-provider.js.map +1 -0
  194. package/dist/sdk/actions/session-action-provider.d.ts +1 -1
  195. package/dist/sdk/actions/session-action-provider.js +1 -1
  196. package/dist/sdk/actions/session-action-provider.js.map +1 -1
  197. package/dist/sdk/actions/shipping-action-provider.d.ts +1 -1
  198. package/dist/sdk/actions/shipping-action-provider.js +1 -1
  199. package/dist/sdk/actions/shipping-action-provider.js.map +1 -1
  200. package/dist/sdk/actions/types.d.ts +6 -2
  201. package/dist/sdk/analytics/analytics-destination.d.ts +43 -0
  202. package/dist/sdk/analytics/analytics-destination.js +90 -0
  203. package/dist/sdk/analytics/analytics-destination.js.map +1 -0
  204. package/dist/sdk/analytics/use-analytics-actions.d.ts +57 -0
  205. package/dist/sdk/analytics/use-analytics-actions.js +108 -0
  206. package/dist/sdk/analytics/use-analytics-actions.js.map +1 -0
  207. package/dist/sdk/cache/storefront-cache.js +1 -1
  208. package/dist/sdk/cache/storefront-cache.js.map +1 -1
  209. package/dist/sdk/cart/operations.d.ts +4 -4
  210. package/dist/sdk/cart/operations.js +1 -1
  211. package/dist/sdk/cart/operations.js.map +1 -1
  212. package/dist/sdk/cart/optimistic.js +1 -1
  213. package/dist/sdk/cart/optimistic.js.map +1 -1
  214. package/dist/sdk/cart/use-cart-actions.d.ts +1 -1
  215. package/dist/sdk/cart/use-cart-actions.js +4 -4
  216. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  217. package/dist/sdk/cart/use-cart-validate-on-open.js +1 -1
  218. package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -1
  219. package/dist/sdk/cart/write-gate.js +1 -1
  220. package/dist/sdk/cart/write-gate.js.map +1 -1
  221. package/dist/sdk/data/entity-resolution-context.js +31 -0
  222. package/dist/sdk/data/entity-resolution-context.js.map +1 -0
  223. package/dist/sdk/data/entity-subscriber.js +18 -8
  224. package/dist/sdk/data/entity-subscriber.js.map +1 -1
  225. package/dist/sdk/data/index.js +1 -0
  226. package/dist/sdk/data/page-reactive-data-root.d.ts +38 -2
  227. package/dist/sdk/data/page-reactive-data-root.js +4 -2
  228. package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
  229. package/dist/sdk/data/reactive-data-provider.d.ts +1 -1
  230. package/dist/sdk/data/reactive-data-provider.js +8 -4
  231. package/dist/sdk/data/reactive-data-provider.js.map +1 -1
  232. package/dist/sdk/data/reactive-list-item-data-provider.d.ts +1 -1
  233. package/dist/sdk/data/reactive-list-item-data-provider.js +13 -5
  234. package/dist/sdk/data/reactive-list-item-data-provider.js.map +1 -1
  235. package/dist/sdk/data/use-reactive-data-settled.js +39 -0
  236. package/dist/sdk/data/use-reactive-data-settled.js.map +1 -0
  237. package/dist/sdk/data/use-reactive-entity.js +6 -2
  238. package/dist/sdk/data/use-reactive-entity.js.map +1 -1
  239. package/dist/sdk/generated/fragment-types.js +2 -0
  240. package/dist/sdk/generated/fragment-types.js.map +1 -1
  241. package/dist/sdk/generated/gql.js +2 -1
  242. package/dist/sdk/generated/gql.js.map +1 -1
  243. package/dist/sdk/generated/graphql.js +85 -1
  244. package/dist/sdk/generated/graphql.js.map +1 -1
  245. package/dist/sdk/i18n/messages/en-US.js +3 -0
  246. package/dist/sdk/i18n/messages/en-US.json +3 -0
  247. package/dist/sdk/i18n/messages/en-US.json.d.ts +3 -0
  248. package/dist/sdk/i18n/messages/es-ES.js +3 -0
  249. package/dist/sdk/i18n/messages/es-ES.json +3 -0
  250. package/dist/sdk/i18n/messages/pt-BR.js +3 -0
  251. package/dist/sdk/i18n/messages/pt-BR.json +3 -0
  252. package/dist/sdk/identity/operations.js.map +1 -1
  253. package/dist/sdk/identity/use-identity-actions.d.ts +1 -1
  254. package/dist/sdk/identity/use-identity-actions.js +3 -2
  255. package/dist/sdk/identity/use-identity-actions.js.map +1 -1
  256. package/dist/sdk/payment/gateway-origin.js +35 -0
  257. package/dist/sdk/payment/gateway-origin.js.map +1 -0
  258. package/dist/sdk/payment/gateway.d.ts +85 -0
  259. package/dist/sdk/payment/gateway.js +183 -0
  260. package/dist/sdk/payment/gateway.js.map +1 -0
  261. package/dist/sdk/payment/operations.d.ts +52 -0
  262. package/dist/sdk/payment/operations.js +223 -0
  263. package/dist/sdk/payment/operations.js.map +1 -0
  264. package/dist/sdk/payment/security-code-mask.js +71 -0
  265. package/dist/sdk/payment/security-code-mask.js.map +1 -0
  266. package/dist/sdk/payment/submission-registry.d.ts +33 -0
  267. package/dist/sdk/payment/submission-registry.js +58 -0
  268. package/dist/sdk/payment/submission-registry.js.map +1 -0
  269. package/dist/sdk/payment/use-payment-actions.d.ts +78 -0
  270. package/dist/sdk/payment/use-payment-actions.js +276 -0
  271. package/dist/sdk/payment/use-payment-actions.js.map +1 -0
  272. package/dist/sdk/payment/use-place-order.d.ts +65 -0
  273. package/dist/sdk/payment/use-place-order.js +640 -0
  274. package/dist/sdk/payment/use-place-order.js.map +1 -0
  275. package/dist/sdk/session/auth-operations.d.ts +1 -1
  276. package/dist/sdk/session/auth-operations.js.map +1 -1
  277. package/dist/sdk/session/use-session-actions.d.ts +1 -1
  278. package/dist/sdk/session/use-session-actions.js.map +1 -1
  279. package/dist/sdk/session/use-session-revalidation.js +65 -0
  280. package/dist/sdk/session/use-session-revalidation.js.map +1 -0
  281. package/dist/sdk/shipping/option-select-operations.d.ts +1 -1
  282. package/dist/sdk/shipping/option-select-operations.js.map +1 -1
  283. package/dist/sdk/shipping/request-timeout.js +1 -1
  284. package/dist/sdk/shipping/request-timeout.js.map +1 -1
  285. package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
  286. package/dist/sdk/shipping/shipping-operations.js.map +1 -1
  287. package/dist/sdk/shipping/use-shipping-actions.d.ts +2 -2
  288. package/dist/sdk/shipping/use-shipping-actions.js +1 -1
  289. package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
  290. package/dist/sdk/state/cart.d.ts +3 -4
  291. package/dist/sdk/state/cart.js +6 -7
  292. package/dist/sdk/state/cart.js.map +1 -1
  293. package/dist/utils/loggable-error-name.js +49 -0
  294. package/dist/utils/loggable-error-name.js.map +1 -0
  295. package/dist/utils/resolve-authored-copy.js +18 -0
  296. package/dist/utils/resolve-authored-copy.js.map +1 -0
  297. package/dist/utils/safe-href.js +3 -3
  298. package/dist/utils/safe-href.js.map +1 -1
  299. package/dist/utils/substitute-template.js +33 -0
  300. package/dist/utils/substitute-template.js.map +1 -0
  301. package/package.json +2 -1
  302. package/src/styles/tailwind.css +34 -0
  303. package/dist/docs/client-profile-form.md +0 -192
  304. package/dist/matter/client-profile-form/client-profile-form.d.ts +0 -126
  305. package/dist/matter/client-profile-form/client-profile-form.js +0 -662
  306. package/dist/matter/client-profile-form/client-profile-form.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"shipping-address.js","names":[],"sources":["../../../src/matter/shipping-address/shipping-address.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AddressSummary, AddressSummaryRoot } from '../../particles/address-summary/address-summary.js';\nimport type { DrawerRootProps } from '../../particles/drawer/drawer.js';\nimport { Field } from '../../particles/field/field.js';\nimport { Select } from '../../particles/select/select.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport {\n SHIPPING_NETWORK_ERROR_CODE,\n type ShippingAddressInput,\n type ShippingAddressUpdateErrorEntity,\n} from '../../sdk/shipping/shipping-operations.js';\nimport type { CountryDescriptor } from './country-descriptors.js';\nimport { getAvailableCountries, getCountryDescriptor } from './country-descriptors.js';\n\n/**\n * Shipping address step (T2 — Enter and save the delivery address).\n * Single-file matter per ADR-0001; batches form state and writes once via shipping.setAddress.\n * Controls are thin context-bound components that read/write draft state (specs/shipping-address-step.md).\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingAddressData on Query {\n shipping {\n __typename\n id\n address {\n __typename\n id\n recipientName\n postalCode\n country\n street\n number\n complement\n neighborhood\n city\n state\n }\n savedAddresses {\n __typename\n id\n recipientName\n postalCode\n country\n street\n number\n complement\n neighborhood\n city\n state\n }\n }\n clientProfile {\n __typename\n firstName\n lastName\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The `$data` slice forwarded by the reactive runtime. `ShippingAddressData` selects two root\n * fields (`shipping`, `clientProfile`), so the compiler composes them via\n * `MultipleReactiveDataProvider`, which keys each entity's resolved slice by its own root field —\n * `$data` is `{ shipping: {...}, clientProfile: {...} }`, not a flat/unwrapped shape (that unwrapped\n * shape only applies to single-root-field fragments, e.g. CartTotalizerRoot's `$data.totalizers`).\n */\nexport type ShippingAddressData = {\n shipping?: {\n address?: {\n id?: string | null;\n recipientName?: string | null;\n postalCode?: string | null;\n country?: string | null;\n street?: string | null;\n number?: string | null;\n complement?: string | null;\n neighborhood?: string | null;\n city?: string | null;\n state?: string | null;\n } | null;\n savedAddresses?: Array<{\n id?: string | null;\n recipientName?: string | null;\n postalCode?: string | null;\n country?: string | null;\n street?: string | null;\n number?: string | null;\n complement?: string | null;\n neighborhood?: string | null;\n city?: string | null;\n state?: string | null;\n }>;\n } | null;\n clientProfile?: {\n firstName?: string | null;\n lastName?: string | null;\n } | null;\n} | null;\n\n/** The batched draft state, keyed by canonical field name (Decision 1). */\ntype AddressDraft = {\n recipientName: string;\n postalCode: string;\n country: string;\n street: string;\n number: string;\n complement: string;\n neighborhood: string;\n city: string;\n state: string;\n};\n\n/** Context value for child Controls to read/write the draft and access the descriptor. */\ntype ShippingAddressContextValue = {\n draft: AddressDraft;\n setDraftField: (field: keyof AddressDraft, value: string) => void;\n descriptor: CountryDescriptor | undefined;\n savedAddresses: Array<{ id: string; address: Partial<AddressDraft> }>;\n selectedSavedId: string | undefined;\n setSelectedSavedId: (id: string | undefined) => void;\n submitting: boolean;\n errors: readonly ShippingAddressUpdateErrorEntity[];\n upstreamError: boolean;\n handleSubmit: () => void;\n currentAddressId: string | undefined;\n /** Formatted current address fields; undefined when there is no current address yet. */\n currentAddress: Partial<AddressDraft> | undefined;\n /**\n * Increments once per successful `setAddress` call (main form submit or drawer submit).\n * Consumed by `ShippingAddressEditController` to switch back to view mode without\n * `ShippingAddressSubmit`/`ShippingAddressSavedAddressSubmit` needing to know about\n * view/edit mode — mirrors the `cartLastAddVar` pulse pattern in matter/cart/cart.tsx,\n * but scoped to this Root's own context since the signal originates and is consumed\n * entirely within this subtree (no cross-tree/global signal needed here).\n */\n submitSuccessSignal: number;\n isFormValid: boolean;\n /**\n * Throws away in-progress edits: re-seeds every field from the stored address and drops the touch marks.\n * Consumed by `ShippingAddressCancelButton`, which would otherwise leave the abandoned values in the\n * draft — the Root outlives the form, and touched fields are never re-seeded.\n */\n discardDraft: () => void;\n};\n\nconst SHIPPING_ADDRESS_CONTEXT_UNSET = Symbol('ShippingAddressContextUnset');\n\nconst ShippingAddressContext = createContext<ShippingAddressContextValue | typeof SHIPPING_ADDRESS_CONTEXT_UNSET>(\n SHIPPING_ADDRESS_CONTEXT_UNSET,\n);\n\nfunction useShippingAddressContext(): ShippingAddressContextValue {\n const ctx = useContext(ShippingAddressContext);\n if (ctx === SHIPPING_ADDRESS_CONTEXT_UNSET) {\n throw new Error('ShippingAddress components must be used inside ShippingAddressRoot.');\n }\n return ctx;\n}\n\n/**\n * Drawer flow state (US-8), kept in its own context separate from ShippingAddressContext so the\n * main data/actions context — read by every field Control — stays unaware of this one downstream\n * UI surface. Only ShippingAddressSavedAddressDrawerController and ShippingAddressSavedAddressSubmit\n * consume it.\n */\ntype ShippingAddressDrawerContextValue = {\n savedAddressDrawerOpen: boolean;\n setSavedAddressDrawerOpen: (open: boolean) => void;\n drawerSubmitting: boolean;\n handleDrawerSubmit: () => void;\n};\n\nconst SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET = Symbol('ShippingAddressDrawerContextUnset');\n\nconst ShippingAddressDrawerContext = createContext<\n ShippingAddressDrawerContextValue | typeof SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET\n>(SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET);\n\nfunction useShippingAddressDrawerContext(): ShippingAddressDrawerContextValue {\n const ctx = useContext(ShippingAddressDrawerContext);\n if (ctx === SHIPPING_ADDRESS_DRAWER_CONTEXT_UNSET) {\n throw new Error(\n 'ShippingAddressSavedAddressDrawerController and ShippingAddressSavedAddressSubmit must be used inside ShippingAddressRoot.',\n );\n }\n return ctx;\n}\n\n/**\n * View/edit mode state (view/edit toggle), kept in its own context — separate from\n * ShippingAddressContext and ShippingAddressDrawerContext — so neither of those needs to know\n * this UI surface exists. Consumed by ShippingAddressSummaryView, ShippingAddressEditForm,\n * ShippingAddressEditButton and ShippingAddressCancelButton; the last two are its only writers.\n */\n/** Internal: the section's two states never reach the schema, because each has its own component. */\ntype ShippingAddressSectionState = 'view' | 'edit';\n\ntype ShippingAddressSectionContextValue = {\n mode: ShippingAddressSectionState;\n setMode: (mode: ShippingAddressSectionState) => void;\n};\n\nconst SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET = Symbol('ShippingAddressSectionContextUnset');\n\nconst ShippingAddressSectionContext = createContext<\n ShippingAddressSectionContextValue | typeof SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET\n>(SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET);\n\nfunction useShippingAddressSectionContext(): ShippingAddressSectionContextValue {\n const ctx = useContext(ShippingAddressSectionContext);\n if (ctx === SHIPPING_ADDRESS_SECTION_CONTEXT_UNSET) {\n throw new Error(\n 'ShippingAddressSummaryView, ShippingAddressEditForm, ShippingAddressEditButton and ShippingAddressCancelButton must be used inside ShippingAddressEditController.',\n );\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Props Types\n// ---------------------------------------------------------------------------\n\nexport type ShippingAddressRootProps = {\n /** Default country (ISO alpha-3) when no address exists. */\n defaultCountry?: string;\n className?: string;\n children?: ReactNode;\n /** `ShippingAddressData` forwarded by the reactive runtime. */\n $data?: ShippingAddressData;\n /** Compiler-injected action surface; carries `shipping.setAddress`. */\n $actions?: ComponentActions;\n};\n\nexport type ShippingAddressStreetControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressNumberControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressCityControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressStateControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressPostalCodeControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressComplementControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressNeighborhoodControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressCountryControlProps = {\n className?: string;\n label?: string;\n};\n\nexport type ShippingAddressRecipientNameControlProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedListProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedOptionProps = {\n id: string;\n className?: string;\n};\n\nexport type ShippingAddressSubmitProps = {\n className?: string;\n label?: string;\n pendingLabel?: string;\n};\n\nexport type ShippingAddressErrorProps = {\n className?: string;\n};\n\nexport type ShippingAddressSavedAddressDrawerControllerProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressSavedAddressSubmitProps = {\n className?: string;\n label?: string;\n pendingLabel?: string;\n};\n\nexport type ShippingAddressSelectedSummaryProps = {\n className?: string;\n /**\n * The lines to render, in order — typically the `AddressSummaryRecipient` / `Street` / `Locality`\n * leaves. Defaults to recipient, street, locality when omitted.\n */\n children?: ReactNode;\n};\n\nexport type ShippingAddressEditControllerProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressSectionPanelProps = {\n children?: ReactNode;\n};\n\nexport type ShippingAddressEditButtonProps = {\n className?: string;\n label?: string;\n /** Compose custom button content (e.g. an Icon plus text); falls back to `label`. */\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Root Definition\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddressRootDefinition = defineComponent<ShippingAddressRootProps>({\n name: 'ShippingAddressRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'shipping-address',\n actions: { shipping: ['setAddress'] },\n editor: { label: 'Shipping Address Root', category: 'content' },\n schema: {\n defaultCountry: { type: 'string', default: 'BRA', label: 'Default country (ISO-3)' },\n },\n guideline:\n 'Country-adaptive single-address delivery form; batches all fields and writes once via shipping.setAddress. See shipping-address.md.',\n});\n\n// Control Definitions\nexport const ShippingAddressRecipientNameControlDefinition = defineComponent<ShippingAddressRecipientNameControlProps>({\n name: 'ShippingAddressRecipientNameControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressRecipientNameControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Recipient Name Control', category: 'action' },\n schema: {},\n guideline: 'Recipient-name input field; required for submit. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressStreetControlDefinition = defineComponent<ShippingAddressStreetControlProps>({\n name: 'ShippingAddressStreetControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStreetControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Street Control', category: 'action' },\n schema: {},\n guideline: 'Street name input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressNumberControlDefinition = defineComponent<ShippingAddressNumberControlProps>({\n name: 'ShippingAddressNumberControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNumberControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Number Control', category: 'action' },\n schema: {},\n guideline: 'Street number input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressCityControlDefinition = defineComponent<ShippingAddressCityControlProps>({\n name: 'ShippingAddressCityControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCityControl,\n requiresContext: 'shipping-address',\n editor: { label: 'City Control', category: 'action' },\n schema: {},\n guideline: 'City name input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressStateControlDefinition = defineComponent<ShippingAddressStateControlProps>({\n name: 'ShippingAddressStateControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStateControl,\n requiresContext: 'shipping-address',\n editor: { label: 'State Control', category: 'action' },\n schema: {},\n guideline: 'State/province input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressPostalCodeControlDefinition = defineComponent<ShippingAddressPostalCodeControlProps>({\n name: 'ShippingAddressPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressPostalCodeControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Postal Code Control', category: 'action' },\n schema: {},\n guideline: 'Postal code input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressComplementControlDefinition = defineComponent<ShippingAddressComplementControlProps>({\n name: 'ShippingAddressComplementControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressComplementControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Complement Control', category: 'action' },\n schema: {},\n guideline: 'Complement (apartment, suite, etc.) input field. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressNeighborhoodControlDefinition = defineComponent<ShippingAddressNeighborhoodControlProps>({\n name: 'ShippingAddressNeighborhoodControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNeighborhoodControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Neighborhood Control', category: 'action' },\n schema: {},\n guideline:\n 'Neighborhood (bairro) input field; shown only for countries that have this field (BR in v1). Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressCountryControlDefinition = defineComponent<ShippingAddressCountryControlProps>({\n name: 'ShippingAddressCountryControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCountryControl,\n requiresContext: 'shipping-address',\n editor: { label: 'Country Control', category: 'action' },\n schema: {\n label: { type: 'string', default: 'país', label: 'Field label' },\n },\n guideline:\n 'Country selector; lists only countries with an implemented descriptor. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedListDefinition = defineComponent<ShippingAddressSavedListProps>({\n name: 'ShippingAddressSavedList',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedList,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address List', category: 'commerce' },\n schema: {},\n guideline:\n 'List of saved addresses for logged-in shoppers; renders only if savedAddresses is non-empty. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedOptionDefinition = defineComponent<ShippingAddressSavedOptionProps>({\n name: 'ShippingAddressSavedOption',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedOption,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Option', category: 'commerce' },\n schema: { id: { type: 'string', label: 'Saved address ID' } },\n guideline:\n 'A single saved address option; renders its address via the same AddressSummary particle (through its own AddressSummaryRoot) used by ShippingAddressSelectedSummary, so both share one formatting implementation. Must be a descendant of ShippingAddressSavedList.',\n});\n\nexport const ShippingAddressSubmitDefinition = defineComponent<ShippingAddressSubmitProps>({\n name: 'ShippingAddressSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSubmit,\n requiresContext: 'shipping-address',\n editor: { label: 'Shipping Address Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'salvar endereço', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'salvando...', label: 'Pending label' },\n },\n guideline:\n 'Submit button; dispatches the batched address write. Disabled until recipient name is non-blank. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressErrorDefinition = defineComponent<ShippingAddressErrorProps>({\n name: 'ShippingAddressError',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressError,\n requiresContext: 'shipping-address',\n editor: { label: 'Shipping Address Error', category: 'commerce' },\n schema: {},\n guideline:\n 'Error banner; shows domain validation errors inline or a generic upstream-error state. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressSavedAddressDrawerControllerDefinition =\n defineComponent<ShippingAddressSavedAddressDrawerControllerProps>({\n name: 'ShippingAddressSavedAddressDrawerController',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedAddressDrawerController,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Drawer Controller', category: 'action' },\n schema: {},\n guideline:\n 'Wraps a single DrawerRoot child (the saved-address selection drawer) and makes it controlled by the shipping-address drawer state: open state and blocked-dismissal-while-submitting are handled here, so do not set raw open/onOpenChange on the wrapped DrawerRoot. Compose as the parent of DrawerRoot, with the drawer trigger and popup as DrawerRoot descendants, same pattern as CartOpenOnAdd wrapping the mini-cart DrawerRoot. Must be inside ShippingAddressRoot.',\n });\n\nexport const ShippingAddressSavedAddressSubmitDefinition = defineComponent<ShippingAddressSavedAddressSubmitProps>({\n name: 'ShippingAddressSavedAddressSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSavedAddressSubmit,\n requiresContext: 'shipping-address',\n editor: { label: 'Saved Address Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'selecionar', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'selecionando...', label: 'Pending label' },\n },\n guideline:\n \"The drawer's \\\"selecionar\\\" submit button; independent submitting state from the main form's Submit (Decision 7); no-ops when the selected saved address is already the current one (Decision 8). Must be inside the saved-address drawer's DrawerPopup and inside ShippingAddressRoot.\",\n});\n\nexport const ShippingAddressSelectedSummaryDefinition = defineComponent<ShippingAddressSelectedSummaryProps>({\n name: 'ShippingAddressSelectedSummary',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSelectedSummary,\n requiresContext: 'shipping-address',\n providesContext: 'address-summary',\n editor: { label: 'Selected Address Summary', category: 'commerce' },\n schema: {},\n guideline:\n 'Provides the current delivery address to the generic AddressSummary particle via AddressSummaryRoot context, and renders the default AddressSummary when composed with no children. Compose AddressSummaryRecipient / Street / Locality directly to choose the order or drop a line. Self-gates to null when there is no current address yet. Must be a descendant of ShippingAddressRoot.',\n});\n\nexport const ShippingAddressEditControllerDefinition = defineComponent<ShippingAddressEditControllerProps>({\n name: 'ShippingAddressEditController',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditController,\n requiresContext: 'shipping-address',\n providesContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Controller', category: 'commerce' },\n schema: {},\n guideline:\n \"Owns the view/edit toggle for the delivery address section: defaults to view when a current address exists, edit otherwise; switches back to view automatically whenever setAddress succeeds (main form submit or saved-address drawer submit), without ShippingAddressSubmit/ShippingAddressSavedAddressSubmit needing to know about this mode. Compose a ShippingAddressSummaryView holding SelectedSummary + EditButton and a ShippingAddressEditForm holding the form Controls/Submit/Error. Self-contained: it decides from its own data and the shopper's own presses, so no other section opens it and finishing it opens nothing. Must be inside ShippingAddressRoot.\",\n});\n\nexport const ShippingAddressSummaryViewDefinition = defineComponent<ShippingAddressSectionPanelProps>({\n name: 'ShippingAddressSummaryView',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressSummaryView,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Summary View', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the delivery section shows the saved-address summary, and nothing while it shows the form. Compose SelectedSummary and a ShippingAddressEditButton inside. Takes no props: which state it gates is which component it is. Must be inside a ShippingAddressEditController.',\n});\n\nexport const ShippingAddressEditFormDefinition = defineComponent<ShippingAddressSectionPanelProps>({\n name: 'ShippingAddressEditForm',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditForm,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Form', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the delivery section shows the address form, and nothing while it shows the summary. Compose the Controls, Submit and Error parts inside. Must be inside a ShippingAddressEditController.',\n});\n\nexport const ShippingAddressEditButtonDefinition = defineComponent<ShippingAddressEditButtonProps>({\n name: 'ShippingAddressEditButton',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressEditButton,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Edit Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'editar', label: 'Button label' },\n },\n guideline:\n 'CTA that switches the view/edit mode to edit. Typically placed inside a ShippingAddressSummaryView, next to SelectedSummary. Must be inside ShippingAddressEditController.',\n});\n\nexport const ShippingAddressCancelButtonDefinition = defineComponent<ShippingAddressEditButtonProps>({\n name: 'ShippingAddressCancelButton',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCancelButton,\n requiresContext: 'shipping-address-section',\n editor: { label: 'Shipping Address Cancel Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'cancelar', label: 'Button label' },\n },\n guideline:\n 'Returns the delivery section to its summary without saving. Place it inside a ShippingAddressEditForm so a shopper who opened the form has a way back that does not depend on a successful write. Must be inside ShippingAddressEditController.',\n});\n\n// ---------------------------------------------------------------------------\n// Root Component\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressRoot owns the batched form state, manages the current descriptor,\n * and provides context to child Controls. It handles submit dispatch and error tracking.\n */\nexport function ShippingAddressRoot({\n defaultCountry = 'BRA',\n className,\n children,\n $data: $dataProp,\n $actions: $actionsProp,\n}: Readonly<ShippingAddressRootProps>) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n\n // Current address and saved addresses from the fragment\n const currentAddress = $data?.shipping?.address;\n const savedAddresses = $data?.shipping?.savedAddresses ?? [];\n const clientProfile = $data?.clientProfile;\n\n // Joined shopper-profile name (US-4) — the single fallback for recipientName whenever an\n // address record (the current address, or a saved address picked from the drawer) has none.\n // Always applied as a real draft value, never just a placeholder hint, so the shopper never has\n // to retype a name the profile already has.\n const joinedProfileName = [clientProfile?.firstName, clientProfile?.lastName].filter(Boolean).join(' ');\n\n // Seeds the batched draft from the current address, falling back to empty. The recipient name defaults to\n // the joined profile name when the address has none (US-4): it must be a real pre-filled value, not just a\n // placeholder hint, so the shopper can submit without retyping it. Shared with `discardDraft` below so the\n // initial seed and the cancel path cannot drift apart.\n const seedDraft = useCallback(\n (): AddressDraft => ({\n recipientName: currentAddress?.recipientName ?? joinedProfileName,\n postalCode: currentAddress?.postalCode ?? '',\n country: currentAddress?.country ?? defaultCountry,\n street: currentAddress?.street ?? '',\n number: currentAddress?.number ?? '',\n complement: currentAddress?.complement ?? '',\n neighborhood: currentAddress?.neighborhood ?? '',\n city: currentAddress?.city ?? '',\n state: currentAddress?.state ?? '',\n }),\n [currentAddress, joinedProfileName, defaultCountry],\n );\n\n const [draft, setDraft] = useState<AddressDraft>(seedDraft);\n\n // Error tracking and submission state\n const [submitting, setSubmitting] = useState(false);\n const [errors, setErrors] = useState<readonly ShippingAddressUpdateErrorEntity[]>([]);\n const [upstreamError, setUpstreamError] = useState(false);\n const [selectedSavedId, setSelectedSavedId] = useState<string | undefined>();\n const [savedAddressDrawerOpen, setSavedAddressDrawerOpen] = useState(false);\n const [drawerSubmitting, setDrawerSubmitting] = useState(false);\n const [submitSuccessSignal, setSubmitSuccessSignal] = useState(0);\n\n // Per-field dirty tracking. `draft`'s initial state is set once (via useState's lazy\n // initializer) from whatever currentAddress holds on this component's first render — for a live\n // page, the reactive fragment often resolves asynchronously after that first render\n // (currentAddress starts undefined), so draft needs to catch up once it arrives. Tracked per\n // field, not as one global flag, so editing one field doesn't stop the others from picking up a\n // later currentAddress update (US-1, third criterion: \"untouched fields reflect the new values\").\n const [touchedFields, setTouchedFields] = useState<ReadonlySet<keyof AddressDraft>>(() => new Set());\n\n // Cancelling throws the edit away, and the marks have to go with the values. They are deliberately kept\n // after a successful write — a server that has not echoed the recipient back would otherwise re-seed the\n // profile name over what the shopper typed — but an abandoned edit has nothing worth preserving, and a\n // mark left behind would keep the stored value permanently out of reach of the re-seed effect below.\n const discardDraft = useCallback(() => {\n setTouchedFields(new Set());\n setDraft(seedDraft());\n setErrors([]);\n setUpstreamError(false);\n }, [seedDraft]);\n\n const currentAddressSnapshot = JSON.stringify(currentAddress ?? null);\n const clientProfileSnapshot = JSON.stringify(clientProfile ?? null);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the stringified snapshots (currentAddressSnapshot/clientProfileSnapshot), not object identity, so the effect doesn't refire on every render when Apollo returns a new-but-equal object reference.\n useEffect(() => {\n setDraft((prev) => {\n return {\n recipientName: touchedFields.has('recipientName')\n ? prev.recipientName\n : (currentAddress?.recipientName ?? (joinedProfileName || prev.recipientName)),\n postalCode: touchedFields.has('postalCode') ? prev.postalCode : (currentAddress?.postalCode ?? prev.postalCode),\n country: touchedFields.has('country') ? prev.country : (currentAddress?.country ?? prev.country),\n street: touchedFields.has('street') ? prev.street : (currentAddress?.street ?? prev.street),\n number: touchedFields.has('number') ? prev.number : (currentAddress?.number ?? prev.number),\n complement: touchedFields.has('complement') ? prev.complement : (currentAddress?.complement ?? prev.complement),\n neighborhood: touchedFields.has('neighborhood')\n ? prev.neighborhood\n : (currentAddress?.neighborhood ?? prev.neighborhood),\n city: touchedFields.has('city') ? prev.city : (currentAddress?.city ?? prev.city),\n state: touchedFields.has('state') ? prev.state : (currentAddress?.state ?? prev.state),\n };\n });\n }, [currentAddressSnapshot, clientProfileSnapshot, touchedFields]);\n\n // Compute current address ID for comparison with saved addresses (Decision 8)\n const currentAddressId = currentAddress?.id ?? undefined;\n\n // Formatted current address for read-only display (ShippingAddressSelectedSummary);\n // undefined when there is no current address yet, so the summary can self-gate on it.\n const formattedCurrentAddress = useMemo(() => {\n if (!currentAddress) return undefined;\n return {\n recipientName: currentAddress.recipientName ?? '',\n postalCode: currentAddress.postalCode ?? '',\n country: currentAddress.country ?? '',\n street: currentAddress.street ?? '',\n number: currentAddress.number ?? '',\n complement: currentAddress.complement ?? '',\n neighborhood: currentAddress.neighborhood ?? '',\n city: currentAddress.city ?? '',\n state: currentAddress.state ?? '',\n } satisfies Partial<AddressDraft>;\n }, [currentAddress]);\n\n // Get the current descriptor based on draft country\n const descriptor = getCountryDescriptor(draft.country);\n\n // Map saved addresses with extracted address data\n const mappedSavedAddresses = useMemo(\n () =>\n savedAddresses.map((saved) => ({\n id: saved.id ?? '',\n address: {\n recipientName: saved.recipientName ?? '',\n postalCode: saved.postalCode ?? '',\n country: saved.country ?? '',\n street: saved.street ?? '',\n number: saved.number ?? '',\n complement: saved.complement ?? '',\n neighborhood: saved.neighborhood ?? '',\n city: saved.city ?? '',\n state: saved.state ?? '',\n } as Partial<AddressDraft>,\n })),\n [savedAddresses],\n );\n\n // Update a single draft field\n const setDraftField = useCallback((field: keyof AddressDraft, value: string) => {\n setTouchedFields((prev) => (prev.has(field) ? prev : new Set(prev).add(field)));\n setDraft((prev) => ({ ...prev, [field]: value }));\n }, []);\n\n // Handle saved option selection\n const selectSavedAddress = useCallback(\n (id: string | undefined) => {\n setSelectedSavedId(id);\n if (id) {\n const saved = mappedSavedAddresses.find((s) => s.id === id);\n if (saved?.address) {\n // Selecting a saved address replaces the whole draft with its fields, so mark every\n // field touched — otherwise a later currentAddress sync could clobber this selection.\n setTouchedFields((prev) => new Set([...prev, ...(Object.keys(saved.address) as Array<keyof AddressDraft>)]));\n // A saved address can legitimately have a blank recipientName (Decision 9); fall back to\n // the joined profile name here too, same as the no-address case (US-4), so the field shows\n // a real pre-filled value instead of an empty string masquerading behind a placeholder.\n setDraft((prev) => ({\n ...prev,\n ...saved.address,\n recipientName: saved.address.recipientName || joinedProfileName,\n }));\n }\n }\n },\n [mappedSavedAddresses, joinedProfileName],\n );\n\n // Client-side validation: non-blank recipientName required\n const isFormValid = draft.recipientName.trim().length > 0;\n\n // Submit handler: dispatch setAddress action\n const handleSubmit = useCallback(async () => {\n if (!isFormValid || submitting) return;\n\n if (!$actions?.shipping?.setAddress) return;\n\n setSubmitting(true);\n setErrors([]);\n setUpstreamError(false);\n\n try {\n // Build input, including savedAddressId only if one was selected (US-3, third acceptance criterion).\n // Only include a field the active country's descriptor actually declares (US-2, third/fourth\n // criteria) — otherwise a stale value from a previously-selected country (e.g. `neighborhood`\n // retained in the draft after switching BR -> USA) would leak into the submitted payload.\n const isFieldActive = (field: keyof AddressDraft) => descriptor?.fields.some((f) => f.name === field) ?? false;\n\n const addressFields = {\n recipientName: draft.recipientName.trim(),\n postalCode: draft.postalCode,\n country: draft.country,\n ...(isFieldActive('street') ? { street: draft.street } : {}),\n ...(isFieldActive('number') ? { number: draft.number } : {}),\n ...(isFieldActive('complement') ? { complement: draft.complement } : {}),\n ...(isFieldActive('neighborhood') ? { neighborhood: draft.neighborhood } : {}),\n ...(isFieldActive('city') ? { city: draft.city } : {}),\n ...(isFieldActive('state') ? { state: draft.state } : {}),\n };\n\n const input: ShippingAddressInput = selectedSavedId\n ? { savedAddressId: selectedSavedId, ...addressFields }\n : addressFields;\n\n const userErrors = await $actions.shipping.setAddress(input);\n if (userErrors.length === 0) {\n // Success: cache merge will reactively update the form (US-5, second criterion). The touched\n // marks stay: dropping them re-arms the seeding effect, which would overwrite a recipient the\n // shopper typed with the profile-name fallback whenever the stored address still carries none.\n setErrors([]);\n setSubmitSuccessSignal((n) => n + 1);\n } else if (userErrors.some((e) => e.code === SHIPPING_NETWORK_ERROR_CODE)) {\n // The action resolves (never throws) the synthetic upstream/network failure as a userError;\n // route it to the generic error state, not the inline domain list (US-6 2nd criterion,\n // Decision 5). Draft retained (US-6, third criterion).\n setErrors([]);\n setUpstreamError(true);\n } else {\n // Domain userErrors render inline; retain draft on error (US-6, third criterion)\n setErrors(userErrors);\n }\n } catch (error) {\n // Network/upstream error: surface as generic state (US-6, second criterion)\n console.error('[ShippingAddress] setAddress failed:', error);\n setUpstreamError(true);\n setErrors([]);\n } finally {\n setSubmitting(false);\n }\n }, [isFormValid, submitting, $actions?.shipping?.setAddress, draft, selectedSavedId, descriptor]);\n\n // Drawer submit handler: dispatch setAddress for the selected saved address (US-8, Decision 7)\n const handleDrawerSubmit = useCallback(async () => {\n // Guard: if nothing picked in the drawer, return immediately\n if (!selectedSavedId) return;\n\n // No-op guard (Decision 8): if the selected address is already current, just close and return\n if (currentAddressId !== undefined && selectedSavedId === currentAddressId) {\n setSavedAddressDrawerOpen(false);\n return;\n }\n\n const selectedAddress = mappedSavedAddresses.find((s) => s.id === selectedSavedId);\n if (!selectedAddress) return;\n\n // Incomplete saved address (missing the one client-enforced field, recipientName): an\n // auto-submit would only fail server-side with MISSING_RECIPIENT_NAME. selectSavedAddress\n // already populated the draft from this record when it was picked, so just close the drawer\n // and let the shopper review/complete it via the main form's own submit (Decision 9).\n if (!selectedAddress.address.recipientName?.trim()) {\n setSavedAddressDrawerOpen(false);\n return;\n }\n\n if (!$actions?.shipping?.setAddress) return;\n\n setDrawerSubmitting(true);\n setErrors([]);\n setUpstreamError(false);\n\n try {\n // Build input from the saved address's stored fields (Decision 6)\n const input: ShippingAddressInput = {\n savedAddressId: selectedSavedId,\n recipientName: selectedAddress.address.recipientName || '',\n postalCode: selectedAddress.address.postalCode || '',\n country: selectedAddress.address.country || '',\n street: selectedAddress.address.street || '',\n number: selectedAddress.address.number || '',\n complement: selectedAddress.address.complement || '',\n neighborhood: selectedAddress.address.neighborhood || '',\n city: selectedAddress.address.city || '',\n state: selectedAddress.address.state || '',\n };\n\n const userErrors = await $actions.shipping.setAddress(input);\n if (userErrors.length === 0) {\n // Success: close the drawer (7th acceptance criterion)\n setErrors([]);\n setSavedAddressDrawerOpen(false);\n setSubmitSuccessSignal((n) => n + 1);\n } else if (userErrors.some((e) => e.code === SHIPPING_NETWORK_ERROR_CODE)) {\n // Resolved synthetic upstream/network failure: generic error state (Decision 5).\n setErrors([]);\n setUpstreamError(true);\n } else {\n // Domain userErrors render inline; leave drawer open for retry (7th acceptance criterion)\n setErrors(userErrors);\n }\n } catch (error) {\n // Network/upstream error: surface as generic state and leave drawer open\n console.error('[ShippingAddress] drawer submit failed:', error);\n setUpstreamError(true);\n setErrors([]);\n } finally {\n setDrawerSubmitting(false);\n }\n }, [selectedSavedId, currentAddressId, mappedSavedAddresses, $actions?.shipping?.setAddress]);\n\n // Provide context to all children\n const contextValue: ShippingAddressContextValue = {\n draft,\n setDraftField,\n descriptor,\n savedAddresses: mappedSavedAddresses,\n selectedSavedId,\n setSelectedSavedId: selectSavedAddress,\n submitting,\n errors,\n upstreamError,\n handleSubmit,\n currentAddressId,\n currentAddress: formattedCurrentAddress,\n submitSuccessSignal,\n isFormValid,\n discardDraft,\n };\n\n const drawerContextValue: ShippingAddressDrawerContextValue = {\n savedAddressDrawerOpen,\n setSavedAddressDrawerOpen,\n drawerSubmitting,\n handleDrawerSubmit,\n };\n\n return (\n <ShippingAddressContext.Provider value={contextValue}>\n <ShippingAddressDrawerContext.Provider value={drawerContextValue}>\n <div className={className} data-fs-shipping-address=\"\">\n {children}\n </div>\n </ShippingAddressDrawerContext.Provider>\n </ShippingAddressContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Control Components (thin, context-bound, reuse particles)\n// ---------------------------------------------------------------------------\n\n/**\n * RecipientNameControl — the only client-validated field (US-4, US-6).\n * Pre-filled from clientProfile, editable, required.\n */\nexport function ShippingAddressRecipientNameControl({ className }: ShippingAddressRecipientNameControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const isRendered = descriptor?.fields.some((f) => f.name === 'recipientName');\n if (!isRendered) return null;\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'recipientName');\n const label = fieldDescriptor?.label ?? 'nome do destinatário';\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"recipient-name\" disabled={submitting}>\n <Field.Label>{label}</Field.Label>\n <Field.Control\n value={draft.recipientName}\n onChange={(e) => setDraftField('recipientName', e.currentTarget.value)}\n />\n </Field.Root>\n );\n}\n\n/** StreetControl */\nexport function ShippingAddressStreetControl({ className }: ShippingAddressStreetControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'street');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"street\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.street} onChange={(e) => setDraftField('street', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** NumberControl */\nexport function ShippingAddressNumberControl({ className }: ShippingAddressNumberControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'number');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"number\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.number} onChange={(e) => setDraftField('number', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** CityControl */\nexport function ShippingAddressCityControl({ className }: ShippingAddressCityControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'city');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"city\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.city} onChange={(e) => setDraftField('city', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** StateControl */\nexport function ShippingAddressStateControl({ className }: ShippingAddressStateControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'state');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"state\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.state} onChange={(e) => setDraftField('state', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** PostalCodeControl */\nexport function ShippingAddressPostalCodeControl({ className }: ShippingAddressPostalCodeControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'postalCode');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"postal-code\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.postalCode} onChange={(e) => setDraftField('postalCode', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** ComplementControl */\nexport function ShippingAddressComplementControl({ className }: ShippingAddressComplementControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'complement');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"complement\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control value={draft.complement} onChange={(e) => setDraftField('complement', e.currentTarget.value)} />\n </Field.Root>\n );\n}\n\n/** NeighborhoodControl (BR-specific in v1) */\nexport function ShippingAddressNeighborhoodControl({ className }: ShippingAddressNeighborhoodControlProps) {\n const { draft, setDraftField, descriptor, submitting } = useShippingAddressContext();\n\n const fieldDescriptor = descriptor?.fields.find((f) => f.name === 'neighborhood');\n if (!fieldDescriptor) return null;\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"neighborhood\" disabled={submitting}>\n <Field.Label>{fieldDescriptor.label}</Field.Label>\n <Field.Control\n value={draft.neighborhood}\n onChange={(e) => setDraftField('neighborhood', e.currentTarget.value)}\n />\n </Field.Root>\n );\n}\n\n/** CountryControl — lists only countries with a descriptor (US-2, first criterion) */\nexport function ShippingAddressCountryControl({ className, label = 'país' }: ShippingAddressCountryControlProps) {\n const { draft, setDraftField, setSelectedSavedId, submitting } = useShippingAddressContext();\n\n const availableCountries = getAvailableCountries();\n const countryOptions = availableCountries.map((iso) => {\n const desc = getCountryDescriptor(iso);\n return { value: iso, label: desc?.label ?? iso };\n });\n\n const handleCountryChange = (value: string | null) => {\n if (!value) return;\n const newDesc = getCountryDescriptor(value);\n if (newDesc) {\n setDraftField('country', value);\n setSelectedSavedId(undefined);\n }\n };\n\n return (\n <Field.Root className={className} data-fs-shipping-address-field=\"country\" disabled={submitting}>\n <Field.Label>{label}</Field.Label>\n <Select.Root value={draft.country} onValueChange={handleCountryChange} disabled={submitting}>\n <Select.Trigger>\n {/* Resolves the label directly from the country descriptor rather than relying on Base\n UI's automatic item-label lookup, which only reflects a mounted Select.Item (i.e.\n after the popup has been opened at least once) — otherwise the trigger would show\n the raw ISO code (e.g. \"BRA\") before the shopper ever opens the dropdown. */}\n <Select.Value>{(value) => (value ? (getCountryDescriptor(value)?.label ?? value) : value)}</Select.Value>\n <Select.Icon>▾</Select.Icon>\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner>\n <Select.Popup>\n <Select.List>\n {countryOptions.map((option) => (\n <Select.Item key={option.value} value={option.value} label={option.label}>\n {option.label}\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </Field.Root>\n );\n}\n\n// ---------------------------------------------------------------------------\n// SavedAddresses List and Option (US-3)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedList — renders only when savedAddresses is non-empty (logged-in signal).\n */\nexport function ShippingAddressSavedList({ className }: ShippingAddressSavedListProps) {\n const { savedAddresses } = useShippingAddressContext();\n\n if (savedAddresses.length === 0) return null;\n\n return (\n <div className={className} data-fs-shipping-address-saved-list=\"\">\n {savedAddresses.map((saved) => (\n <ShippingAddressSavedOption key={saved.id} id={saved.id} />\n ))}\n </div>\n );\n}\n\n/**\n * ShippingAddressSavedOption — selectable saved address; populates draft on selection.\n * Includes isCurrent visual variant to mark the address matching the current cart address (Decision 8).\n */\nexport function ShippingAddressSavedOption({ id, className }: ShippingAddressSavedOptionProps) {\n const { savedAddresses, selectedSavedId, setSelectedSavedId, currentAddressId } = useShippingAddressContext();\n\n const saved = savedAddresses.find((s) => s.id === id);\n if (!saved) return null;\n\n const isSelected = selectedSavedId === id;\n const isCurrent = currentAddressId !== undefined && currentAddressId === id;\n const hasAddressContent = Boolean(\n saved.address.recipientName || saved.address.street || saved.address.city || saved.address.neighborhood,\n );\n const inputId = `saved-address-${id}`;\n\n return (\n <div\n className={className}\n data-fs-shipping-address-saved-option=\"\"\n {...(isSelected ? { 'data-fs-shipping-address-saved-option-selected': '' } : {})}\n {...(isCurrent ? { 'data-fs-shipping-address-saved-option-current': '' } : {})}\n >\n <input\n id={inputId}\n type=\"radio\"\n name=\"saved-address\"\n value={id}\n checked={isSelected}\n onChange={() => setSelectedSavedId(id)}\n />\n <label htmlFor={inputId}>\n {hasAddressContent ? (\n <AddressSummaryRoot address={saved.address}>\n <AddressSummary />\n </AddressSummaryRoot>\n ) : (\n `Endereço ${id}`\n )}\n </label>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Submit Button (US-5)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSubmit — dispatches the batched submit; reflects pending state.\n */\nexport function ShippingAddressSubmit({\n className,\n label = 'salvar endereço',\n pendingLabel = 'salvando...',\n}: ShippingAddressSubmitProps) {\n const { submitting, handleSubmit, isFormValid } = useShippingAddressContext();\n\n return (\n <button\n type=\"button\"\n onClick={handleSubmit}\n disabled={submitting || !isFormValid}\n className={className}\n data-fs-shipping-address-submit=\"\"\n {...(submitting ? { 'data-fs-shipping-address-submit-pending': '' } : {})}\n >\n {submitting ? pendingLabel : label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Saved-Address Drawer Controller (US-8)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedAddressDrawerController — makes the wrapped DrawerRoot controlled by the\n * shipping-address context's savedAddressDrawerOpen state, and blocks dismissal (Escape, backdrop\n * click, close button) while drawerSubmitting is true by simply not forwarding the close request\n * to the setter. Mirrors CartOpenOnAdd's cloneElement mechanism. Expects a single DrawerRoot child.\n */\nexport function ShippingAddressSavedAddressDrawerController({\n children,\n}: ShippingAddressSavedAddressDrawerControllerProps) {\n const { savedAddressDrawerOpen, setSavedAddressDrawerOpen, drawerSubmitting } = useShippingAddressDrawerContext();\n\n if (!isValidElement<Pick<DrawerRootProps, 'open' | 'onOpenChange'>>(children)) {\n return children;\n }\n\n return cloneElement(children, {\n open: savedAddressDrawerOpen,\n onOpenChange: (next: boolean) => {\n if (!next && drawerSubmitting) return;\n setSavedAddressDrawerOpen(next);\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Saved-Address Submit (US-8)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSavedAddressSubmit — the drawer's \"selecionar\" submit button; independent\n * submitting state from the main form's Submit (Decision 7); no-ops when the selected saved\n * address is already the current one (Decision 8).\n */\nexport function ShippingAddressSavedAddressSubmit({\n className,\n label = 'selecionar',\n pendingLabel = 'selecionando...',\n}: ShippingAddressSavedAddressSubmitProps) {\n const { selectedSavedId } = useShippingAddressContext();\n const { drawerSubmitting, handleDrawerSubmit } = useShippingAddressDrawerContext();\n\n return (\n <button\n type=\"button\"\n onClick={handleDrawerSubmit}\n disabled={drawerSubmitting || !selectedSavedId}\n className={className}\n data-fs-shipping-address-saved-address-submit=\"\"\n {...(drawerSubmitting ? { 'data-fs-shipping-address-saved-address-submit-pending': '' } : {})}\n >\n {drawerSubmitting ? pendingLabel : label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Selected Address Summary (read-only, self-gating)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressSelectedSummary — provides the current delivery address via AddressSummaryRoot's\n * context and renders it through AddressSummary. Composed lines go through that same wrapper rather\n * than replacing it, because AddressSummaryRoot renders no DOM and `className` would have nowhere to\n * land. Self-gating on currentAddress: renders null when there is none yet, rather than an empty\n * provider with nothing meaningful to show.\n */\nexport function ShippingAddressSelectedSummary({ className, children }: ShippingAddressSelectedSummaryProps) {\n const { currentAddress } = useShippingAddressContext();\n\n if (!currentAddress) return null;\n\n return (\n <AddressSummaryRoot address={currentAddress}>\n <AddressSummary className={className}>{children}</AddressSummary>\n </AddressSummaryRoot>\n );\n}\n\n// ---------------------------------------------------------------------------\n// View/Edit Mode Toggle (composable — Free Particle Model)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressEditController — owns the view/edit mode. Defaults to 'view' when a current\n * address exists, 'edit' otherwise (derived reactively from currentAddressId, so it self-corrects\n * if the address arrives asynchronously after mount, same issue as the draft-sync effect above).\n * Once the shopper explicitly toggles (via ShippingAddressEditButton) or a submit succeeds, the\n * explicit mode takes over. Does not render any DOM itself; provides ShippingAddressSectionContext\n * to ShippingAddressSummaryView/ShippingAddressEditForm/ShippingAddressEditButton descendants.\n */\nexport function ShippingAddressEditController({ children }: ShippingAddressEditControllerProps) {\n const { currentAddressId, submitSuccessSignal } = useShippingAddressContext();\n const [explicitMode, setExplicitMode] = useState<ShippingAddressSectionState | undefined>(undefined);\n const lastHandledSignal = useRef(submitSuccessSignal);\n\n useEffect(() => {\n if (submitSuccessSignal !== lastHandledSignal.current) {\n lastHandledSignal.current = submitSuccessSignal;\n setExplicitMode('view');\n }\n }, [submitSuccessSignal]);\n\n // This section decides alone: the form when there is no address to show, the summary when there is, and\n // whatever the shopper last chose once they have chosen. It reports nothing to anything else, so finishing\n // it opens no other section.\n const mode: ShippingAddressSectionState = explicitMode ?? (currentAddressId !== undefined ? 'view' : 'edit');\n\n const modeContextValue = useMemo<ShippingAddressSectionContextValue>(\n () => ({ mode, setMode: setExplicitMode }),\n [mode],\n );\n\n return (\n <ShippingAddressSectionContext.Provider value={modeContextValue}>{children}</ShippingAddressSectionContext.Provider>\n );\n}\n\n/** Renders its children only while the section shows the saved-address summary. */\nexport function ShippingAddressSummaryView({ children }: ShippingAddressSectionPanelProps) {\n const { mode } = useShippingAddressSectionContext();\n if (mode !== 'view') return null;\n return <>{children}</>;\n}\n\n/** Renders its children only while the section shows the address form. */\nexport function ShippingAddressEditForm({ children }: ShippingAddressSectionPanelProps) {\n const { mode } = useShippingAddressSectionContext();\n if (mode !== 'edit') return null;\n return <>{children}</>;\n}\n\n/**\n * ShippingAddressEditButton — CTA that switches the mode to 'edit'. Has no knowledge of why the\n * mode might currently be 'view' (a current address, or a just-completed submit) — it only writes\n * the mode forward.\n */\nexport function ShippingAddressEditButton({ className, label = 'editar', children }: ShippingAddressEditButtonProps) {\n const { setMode } = useShippingAddressSectionContext();\n return (\n <button type=\"button\" onClick={() => setMode('edit')} className={className} data-fs-shipping-address-edit-button=\"\">\n {children ?? label}\n </button>\n );\n}\n\n/**\n * ShippingAddressCancelButton — returns the section to its summary without writing. Without it a\n * shopper who opens the form can only leave through a successful `setAddress`, and blanking the\n * recipient disables Submit, which leaves the section stuck open over the summary it replaced.\n */\nexport function ShippingAddressCancelButton({\n className,\n label = 'cancelar',\n children,\n}: ShippingAddressEditButtonProps) {\n const { setMode } = useShippingAddressSectionContext();\n const { discardDraft } = useShippingAddressContext();\n return (\n <button\n type=\"button\"\n onClick={() => {\n discardDraft();\n setMode('view');\n }}\n className={className}\n data-fs-shipping-address-cancel-button=\"\"\n >\n {children ?? label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Error Component (US-6)\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressError — renders domain userErrors inline, or generic upstream error state.\n */\nexport function ShippingAddressError({ className }: ShippingAddressErrorProps) {\n const { errors, upstreamError } = useShippingAddressContext();\n\n if (errors.length === 0 && !upstreamError) return null;\n\n return (\n <div className={className} data-fs-shipping-address-error=\"\">\n {upstreamError ? (\n <div>Não foi possível salvar este endereço. Revise os dados e tente novamente.</div>\n ) : (\n <ul>\n {errors.map((error, idx) => (\n <li key={idx}>{error.message}</li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddress = {\n Root: ShippingAddressRoot,\n RootDefinition: ShippingAddressRootDefinition,\n RecipientNameControl: ShippingAddressRecipientNameControl,\n RecipientNameControlDefinition: ShippingAddressRecipientNameControlDefinition,\n StreetControl: ShippingAddressStreetControl,\n StreetControlDefinition: ShippingAddressStreetControlDefinition,\n NumberControl: ShippingAddressNumberControl,\n NumberControlDefinition: ShippingAddressNumberControlDefinition,\n CityControl: ShippingAddressCityControl,\n CityControlDefinition: ShippingAddressCityControlDefinition,\n StateControl: ShippingAddressStateControl,\n StateControlDefinition: ShippingAddressStateControlDefinition,\n PostalCodeControl: ShippingAddressPostalCodeControl,\n PostalCodeControlDefinition: ShippingAddressPostalCodeControlDefinition,\n ComplementControl: ShippingAddressComplementControl,\n ComplementControlDefinition: ShippingAddressComplementControlDefinition,\n NeighborhoodControl: ShippingAddressNeighborhoodControl,\n NeighborhoodControlDefinition: ShippingAddressNeighborhoodControlDefinition,\n CountryControl: ShippingAddressCountryControl,\n CountryControlDefinition: ShippingAddressCountryControlDefinition,\n SavedList: ShippingAddressSavedList,\n SavedListDefinition: ShippingAddressSavedListDefinition,\n SavedOption: ShippingAddressSavedOption,\n SavedOptionDefinition: ShippingAddressSavedOptionDefinition,\n Submit: ShippingAddressSubmit,\n SubmitDefinition: ShippingAddressSubmitDefinition,\n SavedAddressDrawerController: ShippingAddressSavedAddressDrawerController,\n SavedAddressDrawerControllerDefinition: ShippingAddressSavedAddressDrawerControllerDefinition,\n SavedAddressSubmit: ShippingAddressSavedAddressSubmit,\n SavedAddressSubmitDefinition: ShippingAddressSavedAddressSubmitDefinition,\n SelectedSummary: ShippingAddressSelectedSummary,\n SelectedSummaryDefinition: ShippingAddressSelectedSummaryDefinition,\n EditController: ShippingAddressEditController,\n EditControllerDefinition: ShippingAddressEditControllerDefinition,\n SummaryView: ShippingAddressSummaryView,\n SummaryViewDefinition: ShippingAddressSummaryViewDefinition,\n EditForm: ShippingAddressEditForm,\n EditFormDefinition: ShippingAddressEditFormDefinition,\n EditButton: ShippingAddressEditButton,\n EditButtonDefinition: ShippingAddressEditButtonDefinition,\n CancelButton: ShippingAddressCancelButton,\n CancelButtonDefinition: ShippingAddressCancelButtonDefinition,\n Error: ShippingAddressError,\n ErrorDefinition: ShippingAddressErrorDefinition,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkI/B,MAAM,iCAAiC,OAAO,6BAA6B;AAE3E,MAAM,yBAAyB,cAC7B,8BACF;AAEA,SAAS,4BAAyD;CAChE,MAAM,MAAM,WAAW,sBAAsB;CAC7C,IAAI,QAAQ,gCACV,MAAM,IAAI,MAAM,qEAAqE;CAEvF,OAAO;AACT;AAeA,MAAM,wCAAwC,OAAO,mCAAmC;AAExF,MAAM,+BAA+B,cAEnC,qCAAqC;AAEvC,SAAS,kCAAqE;CAC5E,MAAM,MAAM,WAAW,4BAA4B;CACnD,IAAI,QAAQ,uCACV,MAAM,IAAI,MACR,4HACF;CAEF,OAAO;AACT;AAgBA,MAAM,yCAAyC,OAAO,oCAAoC;AAE1F,MAAM,gCAAgC,cAEpC,sCAAsC;AAExC,SAAS,mCAAuE;CAC9E,MAAM,MAAM,WAAW,6BAA6B;CACpD,IAAI,QAAQ,wCACV,MAAM,IAAI,MACR,mKACF;CAEF,OAAO;AACT;AA+GA,MAAa,gCAAgC,gBAA0C;CACrF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,iBA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;CACxB,OAAO;CACP,iBAAiB;AACnB"}
1
+ {"version":3,"file":"shipping-address.js","names":[],"sources":["../../../src/matter/shipping-address/shipping-address.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { useWatch } from 'react-hook-form';\nimport {\n Field,\n FieldBinding,\n type FieldOption,\n type FieldRule,\n FieldsetFieldContext,\n useFieldsetField,\n useFieldsetFieldNames,\n useNoAncestorFieldset,\n} from '../../particles/field/field.js';\nimport { Fieldset } from '../../particles/fieldset/fieldset.js';\nimport { type FieldsetRegistration, type FormUserError, useFormRegistry } from '../../particles/form/form.js';\nimport { FieldSelect } from '../../particles/select/field-select.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { useEntityDataResolved } from '../../sdk/data/entity-resolution-context.js';\nimport { useReactiveDataSettled } from '../../sdk/data/use-reactive-data-settled.js';\nimport type { ShippingAddressInput } from '../../sdk/shipping/shipping-operations.js';\nimport type { CountryDescriptor, FieldDescriptor } from './country-descriptors.js';\nimport { getAvailableCountries, getCountryDescriptor } from './country-descriptors.js';\n\n/**\n * Shipping address step (T2 — Enter and save the delivery address).\n * Single-file matter per ADR-0001; batches form state and writes once via shipping.setAddress.\n * Controls are thin context-bound components that read/write draft state (docs/storefront-core/reference-cart.md § Delivery).\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\n/**\n * The fieldset's own fragment. Drops `savedAddresses` — the fieldset has no saved-address UI of\n * its own (Decision 1 of specs/shipping-address-fieldset.md).\n *\n * `clientProfile` selects `id` even though nothing renders it. The reactive runtime resolves each\n * root field to a cache reference through `cache.identify`, which needs `__typename` and `id`; with\n * no `id` in the composed page query the profile never normalises, `useReactiveEntity` keeps\n * returning the server's `fallbackData`, and a page composing this fieldset without\n * `ClientProfileFieldset` would show a logged-in shopper a blank recipient name instead of the one\n * US-4 fills in from their profile.\n */\nconst fieldsetFragment = /* GraphQL */ `\n fragment ShippingAddressFieldsetData on Query {\n shipping {\n __typename\n id\n address {\n __typename\n id\n recipientName\n postalCode\n country\n street\n number\n complement\n neighborhood\n city\n state\n }\n }\n clientProfile {\n __typename\n id\n firstName\n lastName\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The `$data` slice forwarded to `ShippingAddressFieldset` by the reactive runtime. Selects two\n * root fields (`shipping`, `clientProfile`), so the compiler composes them via\n * `MultipleReactiveDataProvider`, which keys each entity's resolved slice by its own root field —\n * `$data` is `{ shipping: {...}, clientProfile: {...} }`, not a flat/unwrapped shape (that unwrapped\n * shape only applies to single-root-field fragments, e.g. CartTotalizerRoot's `$data.totalizers`).\n * Carries no `savedAddresses` — the fieldset has no saved-address UI of its own (Decision 1).\n */\nexport type ShippingAddressFieldsetData = {\n shipping?: {\n address?: {\n id?: string | null;\n recipientName?: string | null;\n postalCode?: string | null;\n country?: string | null;\n street?: string | null;\n number?: string | null;\n complement?: string | null;\n neighborhood?: string | null;\n city?: string | null;\n state?: string | null;\n } | null;\n } | null;\n clientProfile?: {\n firstName?: string | null;\n lastName?: string | null;\n } | null;\n} | null;\n\n/** The batched draft state, keyed by canonical field name (Decision 1). */\ntype AddressDraft = {\n recipientName: string;\n postalCode: string;\n country: string;\n street: string;\n number: string;\n complement: string;\n neighborhood: string;\n city: string;\n state: string;\n};\n\n// ---------------------------------------------------------------------------\n// Fieldset context\n// ---------------------------------------------------------------------------\n\n/** The react-hook-form namespace every field of this entity registers under. */\nconst SHIPPING_ADDRESS_NAMESPACE = 'shippingAddress';\n\n/** Canonical field keys, matching AddressDraft's keys and the descriptors' `name` values. */\nexport type ShippingAddressFieldKey = keyof AddressDraft;\n\n/** What a bound Control needs from its fieldset. Carries no live value. */\ntype ShippingAddressFieldsetContextValue = Readonly<{\n namespace: string;\n /** The active country's descriptor, or undefined when the country has none. */\n descriptor: CountryDescriptor | undefined;\n /** The descriptor entry for a key, or undefined when this country does not have the field. */\n fieldFor: (key: ShippingAddressFieldKey) => FieldDescriptor | undefined;\n /** The value this field registers with as react-hook-form's field-level defaultValue. */\n seedFor: (key: ShippingAddressFieldKey) => string;\n /**\n * The rule for a rendered field. `label`, when given, overrides the descriptor's own label in\n * the generated required-message copy — an authored `label` renames the field in its own error\n * message, not just on screen. Never called for a field with no descriptor entry.\n */\n ruleFor: (key: ShippingAddressFieldKey, label?: string) => FieldRule | undefined;\n /** Only for `country`: the platform's option list, contract-shaped. */\n countryOptions: readonly FieldOption[];\n}>;\n\nconst ShippingAddressFieldsetContext = createContext<ShippingAddressFieldsetContextValue | null>(null);\n\n/**\n * Read before any field hook (Decision 4): a control calls this before looking up its own\n * descriptor entry, so a field the active descriptor does not declare never calls\n * `useFieldsetField`/`useController` and so never registers with react-hook-form at all. Throws\n * when rendered with no `ShippingAddressFieldset` above it (Decision 2), naming the required\n * composition.\n */\nfunction useShippingAddressFieldsetContext(): ShippingAddressFieldsetContextValue {\n const ctx = useContext(ShippingAddressFieldsetContext);\n if (!ctx) {\n throw new Error('ShippingAddress*Control components must be used inside ShippingAddressFieldset.');\n }\n return ctx;\n}\n\n/**\n * Rows `ShippingAddressFieldsetSkeleton` draws when nobody says otherwise: one per Control in the\n * full anatomy, the nine of them. It is a default and not a derivation — the skeleton renders before\n * any address has resolved, so it cannot read the live descriptor, and the composed Controls are\n * opaque children. A page that composes fewer than nine sets `skeletonCount` to what it composed,\n * or the form jumps by the difference when the Controls take the skeleton's place.\n */\nconst SHIPPING_ADDRESS_SKELETON_ROWS = 9;\n\n/** `autoComplete` tokens per field (US-3, WCAG 2.1 SC 1.3.5). `number` has no standard token. */\nconst FIELD_AUTOCOMPLETE: Readonly<Record<ShippingAddressFieldKey, string | undefined>> = {\n recipientName: 'name',\n postalCode: 'postal-code',\n country: 'country',\n street: 'address-line1',\n number: undefined,\n complement: 'address-line2',\n neighborhood: 'address-level3',\n city: 'address-level2',\n state: 'address-level1',\n};\n\n/**\n * Merges the descriptor's own `rule` under a generated `required`, which is this fieldset's whole\n * declaration of the baseline. The blank check it used to hand-write alongside lives in\n * `resolveRequiredness` now, installed for every bound control rather than only for this one.\n */\nfunction buildRule(field: FieldDescriptor, label: string): FieldRule | undefined {\n if (!field.required) return field.rule;\n return { ...field.rule, required: `${label} é obrigatório` };\n}\n\n/** Keeps only the AddressDraft keys `values` actually defines — a field no control composed is absent, not `undefined`. */\nfunction pickDefinedAddressFields(values: Record<string, unknown>): Partial<AddressDraft> {\n const result: Partial<AddressDraft> = {};\n for (const key of Object.keys(values) as ShippingAddressFieldKey[]) {\n const value = values[key];\n if (value !== undefined) result[key] = value as string;\n }\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Props Types\n// ---------------------------------------------------------------------------\n\nexport type ShippingAddressFieldsetProps = {\n /** Country used when the stored address has none. */\n defaultCountry?: string;\n /** Placeholder rows the loading skeleton draws. Set it to the number of Controls composed here. */\n skeletonCount?: number;\n /** Announced politely while the address resolves. Blank means no announcement. */\n loadingLabel?: string;\n /** Announced politely once the Controls mount. Blank means no announcement. */\n loadedLabel?: string;\n /** Accessible name of the `<fieldset>` group. Blank means no name is exposed. */\n groupLabel?: string;\n className?: string;\n children?: ReactNode;\n /** `ShippingAddressFieldsetData` forwarded by the reactive runtime. */\n $data?: ShippingAddressFieldsetData;\n /** Compiler-injected action surface; carries `shipping.setAddress`. */\n $actions?: ComponentActions;\n};\n\nexport type ShippingAddressStreetControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressNumberControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressCityControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressStateControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressPostalCodeControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressComplementControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressNeighborhoodControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressCountryControlProps = {\n className?: string;\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, FieldSelect.Root, Field.Error. */\n children?: ReactNode;\n};\n\nexport type ShippingAddressRecipientNameControlProps = {\n className?: string;\n /** Overrides the descriptor's label. Absence means the platform's value. */\n label?: string;\n placeholder?: string;\n /** Recomposes the anatomy. Absence renders Field.Label, Field.Control, Field.Error. */\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Root Definition\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddressFieldsetDefinition = defineComponent<ShippingAddressFieldsetProps>({\n name: 'ShippingAddressFieldset',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressFieldset,\n fragment: fieldsetFragment,\n fetchStrategy: 'reactive',\n skeleton: ShippingAddressFieldsetSkeleton,\n actions: { shipping: ['setAddress'] },\n requiresContext: 'form',\n providesContext: 'shipping-address',\n editor: { label: 'Shipping Address Fieldset', category: 'commerce' },\n schema: {\n defaultCountry: { type: 'string', default: 'BRA', label: 'Default country (ISO-3)' },\n skeletonCount: { type: 'number', default: 9, label: 'Skeleton rows' },\n loadingLabel: { type: 'string', default: 'Loading your delivery address', label: 'Loading announcement' },\n loadedLabel: { type: 'string', default: 'Your delivery address is ready', label: 'Loaded announcement' },\n groupLabel: { type: 'string', default: 'Your delivery address', label: 'Accessible group name' },\n },\n guideline:\n 'Composable delivery-address entity: registers under \"shippingAddress\" with the enclosing FormRoot and dispatches shipping.setAddress only when the shopper changed something. Compose the nine ShippingAddress*Control parts inside it; place FormSubmit/FormEnterSubmit/FormError as siblings of the fieldset, not inside it — this fieldset renders no submit or error part of its own. The Controls mount only once the address has resolved, with skeletonCount placeholder rows in their place until then — set it to the number of Controls composed, or the form jumps by the difference. Style the announcement sr-only. groupLabel names the group as its accessible name; blank emits no aria-label, and a composed FieldsetLegend wins over it. See shipping-address.md.',\n});\n\n// Control Definitions\n// Shared by all eight text Controls below (RFC:503): states the requiresContext and the\n// recomposable anatomy every one of them shares.\nconst ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX =\n 'Must be a descendant of ShippingAddressFieldset, which provides the shipping-address context this control requires. Recomposable: compose Field.Label, Field.Control and Field.Error as children, in any order, to reorder or extend the anatomy; a childless composition keeps the default label-control-error order.';\n\nexport const ShippingAddressRecipientNameControlDefinition = defineComponent<ShippingAddressRecipientNameControlProps>({\n name: 'ShippingAddressRecipientNameControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressRecipientNameControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'Recipient Name Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `Recipient-name input field; required for submit. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressStreetControlDefinition = defineComponent<ShippingAddressStreetControlProps>({\n name: 'ShippingAddressStreetControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStreetControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'Street Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `Street name input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressNumberControlDefinition = defineComponent<ShippingAddressNumberControlProps>({\n name: 'ShippingAddressNumberControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNumberControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'Number Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `Street number input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressCityControlDefinition = defineComponent<ShippingAddressCityControlProps>({\n name: 'ShippingAddressCityControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCityControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'City Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `City name input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressStateControlDefinition = defineComponent<ShippingAddressStateControlProps>({\n name: 'ShippingAddressStateControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressStateControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'State Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `State/province input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressPostalCodeControlDefinition = defineComponent<ShippingAddressPostalCodeControlProps>({\n name: 'ShippingAddressPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressPostalCodeControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'Postal Code Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `Postal code input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressComplementControlDefinition = defineComponent<ShippingAddressComplementControlProps>({\n name: 'ShippingAddressComplementControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressComplementControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'Complement Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `Complement (apartment, suite, etc.) input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressNeighborhoodControlDefinition = defineComponent<ShippingAddressNeighborhoodControlProps>({\n name: 'ShippingAddressNeighborhoodControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressNeighborhoodControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'Neighborhood Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value, applied at render time by\n // the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n },\n guideline: `Neighborhood (bairro) input field; shown only for countries that have this field (BR in v1). ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`,\n});\n\nexport const ShippingAddressCountryControlDefinition = defineComponent<ShippingAddressCountryControlProps>({\n name: 'ShippingAddressCountryControl',\n importPath: '@vtex/faststore/components',\n component: ShippingAddressCountryControl,\n requiresContext: 'shipping-address',\n providesContext: 'field',\n editor: { label: 'Country Control', category: 'action' },\n schema: {\n // No default (Decision 11): absence means the platform's value ('país'), applied at render time\n // by the control itself, not baked into the schema.\n label: { type: 'string', label: 'Field label' },\n },\n guideline:\n 'Country selector; lists only countries with an implemented descriptor. Must be a descendant of ShippingAddressFieldset, which provides the shipping-address context this control requires. Recomposable: compose Field.Label, FieldSelect.Root and Field.Error as children, in any order; a childless composition keeps the default label-select-error order.',\n});\n\n// ---------------------------------------------------------------------------\n// Fieldset Component\n// ---------------------------------------------------------------------------\n\n/**\n * ShippingAddressFieldset — this entity's root: same data, same action as a page-level submit\n * would use, dispatched at form-submit time instead of through a button of its own. Registers one\n * `FieldsetRegistration` with the enclosing `FormRoot` under the `shippingAddress` namespace,\n * derives the active country descriptor from react-hook-form (Decision 2), and publishes each\n * field's seed/rule/label through its own context so a bound Control never writes a validation\n * expression. Renders no button and holds no draft of its own.\n *\n * Its controls mount only once the entity has resolved; until then the `Fieldset.Root` carries\n * `-pending` and renders `ShippingAddressFieldsetSkeleton`. \"Resolved\" is two conditions, because\n * `$data` alone cannot answer it: under the reactive runtime the slice is defined from the first\n * render — `useReactiveEntity` hands down `fallbackData` while the cache read is incomplete — so an\n * empty server answer looks exactly like a resolved one, and every control would mount seeded `''`\n * before the shopper's stored address arrives. Each seed reaches react-hook-form as a field-level\n * `defaultValue`; `useSeedAdoption` re-seeds a clean field with it on every render, but once the\n * field turns dirty no later seed ever reaches it again (Decision 12). Mounting before the answer\n * arrives would seed `''`: a shopper who starts typing before the real value lands makes the field\n * dirty on that empty seed, permanently locking their saved address out of it, and even a shopper who\n * does not type sees the field flash from `''` to the real data. `useReactiveDataSettled` supplies\n * the missing half: the page query's own in-flight state, latched so it only ever goes pending →\n * settled. The `$data === undefined` half still carries\n * trees with no reactive root above them, where the slice arrives as a plain prop.\n *\n * Both ends of that wait are spoken: the fieldset carries `aria-busy` while it lasts and holds a\n * polite live region that announces `loadingLabel` and then `loadedLabel`. Style the region\n * `sr-only` — it is text meant for a screen reader, not for the page.\n */\nexport function ShippingAddressFieldset({\n defaultCountry = 'BRA',\n skeletonCount = SHIPPING_ADDRESS_SKELETON_ROWS,\n loadingLabel = 'Loading your delivery address',\n loadedLabel = 'Your delivery address is ready',\n groupLabel = 'Your delivery address',\n className,\n children,\n $data: $dataProp,\n $actions: $actionsProp,\n}: ShippingAddressFieldsetProps): ReactNode {\n // First hook called: throws the named registry error when no FormRoot is above (US-1, 5th\n // criterion), before any react-hook-form hook below has a chance to run against a missing context.\n const { registerFieldset } = useFormRegistry();\n\n // Guards runtime registry integrity the same way FormRoot's namespace-collision throw does:\n // useFieldsetField resolves the *nearest* FieldsetFieldContext, not the fieldset that owns a\n // given namespace, so a fieldset nested inside another one would register its controls' names\n // into the ancestor's name set instead of its own — FormClear, FormReset and post-dispatch\n // reconciliation would then act on the wrong fields. Nesting fieldsets has no legitimate use,\n // so this throws at mount rather than silently misrouting names.\n useNoAncestorFieldset('ShippingAddressFieldset');\n\n const $data = useDataOverride($dataProp);\n\n const $actions = useActionsOverride($actionsProp);\n // Three conditions, not two. `useReactiveDataSettled` latches one way and never re-arms, so on its\n // own it answers \"has this page ever resolved\", not \"is what I am holding right now the server's\n // answer\" — after the page query's entity ref moves to one this cache never stored, or its root is\n // skipped for want of a variable, the slice silently regresses to `fallbackData` while the latch\n // still reads settled. `useEntityDataResolved` is the per-entity half: unlatched, so it follows the\n // slice back down and returns this fieldset to its skeleton instead of leaving live controls seeded\n // from a placeholder.\n const settled = useReactiveDataSettled();\n const sliceResolved = useEntityDataResolved();\n const resolved = settled && sliceResolved && $data !== undefined;\n const currentAddress = $data?.shipping?.address;\n const clientProfile = $data?.clientProfile;\n const joinedProfileName = [clientProfile?.firstName, clientProfile?.lastName].filter(Boolean).join(' ');\n\n // The one seed record every field registers with as react-hook-form's own defaultValue (Decision\n // 12) — resolved fresh from $data on every render and re-applied to every already-mounted field\n // that is still clean; a field the shopper has started editing turns dirty and locks this out.\n const seed = useMemo<AddressDraft>(\n () => ({\n recipientName: currentAddress?.recipientName ?? joinedProfileName,\n postalCode: currentAddress?.postalCode ?? '',\n country: currentAddress?.country ?? defaultCountry,\n street: currentAddress?.street ?? '',\n number: currentAddress?.number ?? '',\n complement: currentAddress?.complement ?? '',\n neighborhood: currentAddress?.neighborhood ?? '',\n city: currentAddress?.city ?? '',\n state: currentAddress?.state ?? '',\n }),\n [currentAddress, joinedProfileName, defaultCountry],\n );\n\n // Decision 2: the descriptor is derived from react-hook-form, not from a draft of our own, so a\n // country change reshapes the form with one subscription and no re-seeding effect. `FormClear`\n // can drive the live value to '' (the select itself never offers an empty option); falling back\n // to the seeded country there keeps every field — including the required recipient name — mounted\n // and focusable instead of vanishing the moment the form is cleared.\n const watchedCountry = useWatch({ name: `${SHIPPING_ADDRESS_NAMESPACE}.country`, defaultValue: seed.country });\n const activeCountry = (typeof watchedCountry === 'string' && watchedCountry) || seed.country;\n const descriptor = getCountryDescriptor(activeCountry);\n\n const fieldFor = useCallback(\n (key: ShippingAddressFieldKey) => descriptor?.fields.find((f) => f.name === key),\n [descriptor],\n );\n const seedFor = useCallback((key: ShippingAddressFieldKey) => seed[key], [seed]);\n const ruleFor = useCallback(\n (key: ShippingAddressFieldKey, label?: string) => {\n const field = fieldFor(key);\n return field ? buildRule(field, label ?? field.label) : undefined;\n },\n [fieldFor],\n );\n const countryOptions = useMemo<readonly FieldOption[]>(\n () => getAvailableCountries().map((iso) => ({ value: iso, label: getCountryDescriptor(iso)?.label ?? iso })),\n [],\n );\n\n const fieldsetContextValue = useMemo<ShippingAddressFieldsetContextValue>(\n () => ({ namespace: SHIPPING_ADDRESS_NAMESPACE, descriptor, fieldFor, seedFor, ruleFor, countryOptions }),\n [descriptor, fieldFor, seedFor, ruleFor, countryOptions],\n );\n\n // Collects the field names this fieldset's own controls currently have mounted (FR 3), over the\n // seam `particles/field/field.tsx` exports for exactly this purpose.\n const { registry: fieldRegistryValue, getFieldNames } = useFieldsetFieldNames(SHIPPING_ADDRESS_NAMESPACE);\n\n // Deliberately NOT dirty-only (T21 Decision 4), unlike ClientProfileFieldset/ClientPreferencesFieldset:\n // `ShippingAddressUpdateInput` declares `recipientName`, `postalCode` and `country` non-null\n // (core.graphql:2446-2450), so a payload carrying only the changed keys is invalid by construction.\n // Sending the whole active-country address, seed-merged with the live values, is the correct shape\n // for this mutation's contract — not an oversight to \"fix\" into dirty-only.\n const toPayload = useCallback(\n (values: Record<string, unknown>): Record<string, unknown> => {\n const merged = { ...seed, ...pickDefinedAddressFields(values) } as AddressDraft;\n const country = String(merged.country || seed.country);\n const active = getCountryDescriptor(country);\n const isActive = (key: ShippingAddressFieldKey) => active?.fields.some((f) => f.name === key) ?? false;\n\n return {\n country,\n ...(isActive('recipientName') ? { recipientName: String(merged.recipientName ?? '').trim() } : {}),\n ...(isActive('postalCode') ? { postalCode: merged.postalCode } : {}),\n ...(isActive('street') ? { street: merged.street } : {}),\n ...(isActive('number') ? { number: merged.number } : {}),\n ...(isActive('complement') ? { complement: merged.complement } : {}),\n ...(isActive('neighborhood') ? { neighborhood: merged.neighborhood } : {}),\n ...(isActive('city') ? { city: merged.city } : {}),\n ...(isActive('state') ? { state: merged.state } : {}),\n };\n },\n [seed],\n );\n\n const dispatch = useCallback(\n async (payload: Record<string, unknown>): Promise<readonly FormUserError[]> => {\n if (!$actions?.shipping?.setAddress) {\n // The form reports a failure rather than silently succeeding (FR 13).\n throw new Error('ShippingAddressFieldset requires $actions.shipping.setAddress.');\n }\n return $actions.shipping.setAddress(payload as ShippingAddressInput);\n },\n [$actions],\n );\n\n const registration = useMemo<FieldsetRegistration>(\n () => ({\n namespace: SHIPPING_ADDRESS_NAMESPACE,\n getFieldNames,\n dispatch,\n toPayload,\n // Decision 1: the register is a machine identifier, the kebab-case ASCII rendering of this\n // registration's own `namespace` (`shippingAddress` → `shipping-address`) — not authored per\n // page (Decision 2).\n label: 'shipping-address',\n }),\n [getFieldNames, dispatch, toPayload],\n );\n\n // Registered from the mount commit, like the other two fieldsets, because `FormRoot` takes a\n // fieldset's dispatch slot from its first registration: deferring it until the entity resolves\n // would put this fieldset after every sibling that registered at mount, whatever their order in\n // the document.\n //\n // Registering early cannot send an unresolved seed. `toPayload` is whole-entity here\n // (`ShippingAddressUpdateInput` declares three fields non-null, so the payload is\n // `{ ...seed, ...liveValues }`), which makes a placeholder seed sendable, but the Controls mount only\n // once the entity has resolved. Until then `getFieldNames()` is empty and `FormRoot` finds nothing of\n // this fieldset that could be dirty — including a field the shopper edited before the slice regressed.\n useEffect(() => registerFieldset(registration), [registerFieldset, registration]);\n\n // Assistive technology only reports a change inside a region that was already in the tree, so a\n // region mounted together with its text announces nothing. The region therefore sits in both\n // branches and starts empty, with the wait written on the pass after mount and replaced — not\n // cleared — once the Controls are up: the skeleton is `aria-hidden`, so without this second\n // message the form would materialise in silence (WCAG 2.1 SC 4.1.3).\n const [announcement, setAnnouncement] = useState('');\n const announced = resolved ? loadedLabel : loadingLabel;\n useEffect(() => {\n setAnnouncement(announced);\n }, [announced]);\n\n return (\n <Fieldset.Root\n className={className}\n aria-busy={resolved ? undefined : true}\n // FR-12: blank (or whitespace-only) means no name is exposed, mirroring the loadingLabel/\n // loadedLabel convention. On the root itself (FR-13), so it is identical whether the fieldset\n // is pending or resolved; a page-composed FieldsetLegend still wins via aria-labelledby.\n {...(groupLabel?.trim() ? { 'aria-label': groupLabel } : {})}\n data-fs-shipping-address-fieldset=\"\"\n {...(resolved ? {} : { 'data-fs-shipping-address-fieldset-pending': '' })}\n >\n <ShippingAddressFieldsetContext.Provider value={fieldsetContextValue}>\n <FieldsetFieldContext.Provider value={fieldRegistryValue}>\n {resolved ? children : <ShippingAddressFieldsetSkeleton count={skeletonCount} />}\n </FieldsetFieldContext.Provider>\n </ShippingAddressFieldsetContext.Provider>\n <output aria-live=\"polite\" data-fs-shipping-address-fieldset-announcement=\"\">\n {announcement}\n </output>\n </Fieldset.Root>\n );\n}\n\n/**\n * The loading state of the fieldset, rendered in place of the Controls until the entity resolves and\n * declared as the definition's `skeleton`. Purely visual: the wait is spoken by the fieldset's own\n * live region, so this is hidden from assistive technology rather than announced twice.\n */\nexport function ShippingAddressFieldsetSkeleton({\n count = SHIPPING_ADDRESS_SKELETON_ROWS,\n className,\n ...props\n}: ComponentPropsWithRef<'div'> & { count?: number }) {\n return (\n <div {...props} className={className} data-fs-shipping-address-fieldset-skeleton=\"\" aria-hidden=\"true\">\n {Array.from({ length: count }, (_, i) => (\n <span key={i} data-fs-shipping-address-fieldset-skeleton-field=\"\" />\n ))}\n </div>\n );\n}\n\nShippingAddressFieldset.Skeleton = ShippingAddressFieldsetSkeleton;\n\n// ---------------------------------------------------------------------------\n// Control Components (thin, context-bound, reuse particles)\n//\n// Each control reads the fieldset context and finds its descriptor entry *before* calling any\n// field hook, so a field the active descriptor does not declare never calls\n// `useFieldsetField`/`useController` and so never registers with react-hook-form at all\n// (Decision 4).\n// ---------------------------------------------------------------------------\n\n/** The eight text fields' shared anatomy (Decision 6): `FieldBinding > Field.Root > (Field.Label, Field.Control, Field.Error)`. */\ntype BoundAddressTextFieldProps = {\n fieldKey: Exclude<ShippingAddressFieldKey, 'country'>;\n slug: string;\n className?: string;\n label?: string;\n placeholder?: string;\n children?: ReactNode;\n fieldsetCtx: ShippingAddressFieldsetContextValue;\n fieldDescriptor: FieldDescriptor;\n};\n\nfunction BoundAddressTextField({\n fieldKey,\n slug,\n className,\n label,\n placeholder,\n children,\n fieldsetCtx,\n fieldDescriptor,\n}: BoundAddressTextFieldProps) {\n const name = useFieldsetField(SHIPPING_ADDRESS_NAMESPACE, fieldKey);\n // Resolved once and threaded into both the visible label and the rule, so an authored `label`\n // renames the field in its own required-message copy too (spec 806-809), not just on screen.\n const resolvedLabel = label ?? fieldDescriptor.label;\n\n return (\n <FieldBinding\n name={name}\n label={resolvedLabel}\n placeholder={placeholder}\n defaultValue={fieldsetCtx.seedFor(fieldKey)}\n rule={fieldsetCtx.ruleFor(fieldKey, resolvedLabel)}\n autoComplete={FIELD_AUTOCOMPLETE[fieldKey]}\n >\n <Field.Root className={className} data-fs-shipping-address-field={slug}>\n {children ?? (\n <>\n <Field.Label />\n <Field.Control />\n <Field.Error />\n </>\n )}\n </Field.Root>\n </FieldBinding>\n );\n}\n\n/**\n * RecipientNameControl — the only required field (US-4, US-6); the postal code is client-validated\n * too, against the active country's format.\n * Pre-filled from clientProfile, editable, required.\n */\nexport function ShippingAddressRecipientNameControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressRecipientNameControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('recipientName');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"recipientName\"\n slug=\"recipient-name\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/** StreetControl */\nexport function ShippingAddressStreetControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressStreetControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('street');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"street\"\n slug=\"street\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/** NumberControl */\nexport function ShippingAddressNumberControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressNumberControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('number');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"number\"\n slug=\"number\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/** CityControl */\nexport function ShippingAddressCityControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressCityControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('city');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"city\"\n slug=\"city\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/** StateControl */\nexport function ShippingAddressStateControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressStateControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('state');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"state\"\n slug=\"state\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/** PostalCodeControl */\nexport function ShippingAddressPostalCodeControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressPostalCodeControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('postalCode');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"postalCode\"\n slug=\"postal-code\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/** ComplementControl */\nexport function ShippingAddressComplementControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressComplementControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('complement');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"complement\"\n slug=\"complement\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/** NeighborhoodControl (BR-specific in v1) */\nexport function ShippingAddressNeighborhoodControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressNeighborhoodControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n const fieldDescriptor = fieldsetCtx.fieldFor('neighborhood');\n if (!fieldDescriptor) return null;\n return (\n <BoundAddressTextField\n fieldKey=\"neighborhood\"\n slug=\"neighborhood\"\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n fieldDescriptor={fieldDescriptor}\n >\n {children}\n </BoundAddressTextField>\n );\n}\n\n/**\n * CountryControl — moves onto `FieldSelect` (Decision 8): the trigger resolves a country name from\n * the field contract's `options`. Gated on `descriptor`, not on a per-field entry (country has\n * none): a country with no descriptor renders no controls at all (Decision 3/4's \"no entry, no\n * control\" applied to the field that selects the entry itself).\n */\nexport function ShippingAddressCountryControl({\n className,\n label,\n placeholder,\n children,\n}: ShippingAddressCountryControlProps): ReactNode {\n const fieldsetCtx = useShippingAddressFieldsetContext();\n if (!fieldsetCtx.descriptor) return null;\n return (\n <BoundShippingAddressCountryControl\n className={className}\n label={label}\n placeholder={placeholder}\n fieldsetCtx={fieldsetCtx}\n >\n {children}\n </BoundShippingAddressCountryControl>\n );\n}\n\ntype BoundShippingAddressCountryControlProps = {\n className?: string;\n label?: string;\n placeholder?: string;\n children?: ReactNode;\n fieldsetCtx: ShippingAddressFieldsetContextValue;\n};\n\nfunction BoundShippingAddressCountryControl({\n className,\n label,\n placeholder,\n children,\n fieldsetCtx,\n}: BoundShippingAddressCountryControlProps) {\n const name = useFieldsetField(SHIPPING_ADDRESS_NAMESPACE, 'country');\n\n return (\n <FieldBinding\n name={name}\n label={label ?? 'país'}\n // Falls back to the active descriptor's label (already the FormClear-safe activeCountry,\n // not the raw watched value — Decision 2) so the trigger shows the country that will\n // actually be sent even when react-hook-form's own value is '' (e.g. right after\n // FormClear), instead of resolveOptionLabel('') rendering nothing at all.\n placeholder={placeholder ?? fieldsetCtx.descriptor?.label}\n defaultValue={fieldsetCtx.seedFor('country')}\n options={fieldsetCtx.countryOptions}\n autoComplete={FIELD_AUTOCOMPLETE.country}\n >\n <Field.Root className={className} data-fs-shipping-address-field=\"country\">\n {children ?? (\n <>\n <Field.Label />\n <FieldSelect.Root />\n <Field.Error />\n </>\n )}\n </Field.Root>\n </FieldBinding>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const ShippingAddress = {\n Fieldset: ShippingAddressFieldset,\n FieldsetDefinition: ShippingAddressFieldsetDefinition,\n FieldsetSkeleton: ShippingAddressFieldsetSkeleton,\n RecipientNameControl: ShippingAddressRecipientNameControl,\n RecipientNameControlDefinition: ShippingAddressRecipientNameControlDefinition,\n StreetControl: ShippingAddressStreetControl,\n StreetControlDefinition: ShippingAddressStreetControlDefinition,\n NumberControl: ShippingAddressNumberControl,\n NumberControlDefinition: ShippingAddressNumberControlDefinition,\n CityControl: ShippingAddressCityControl,\n CityControlDefinition: ShippingAddressCityControlDefinition,\n StateControl: ShippingAddressStateControl,\n StateControlDefinition: ShippingAddressStateControlDefinition,\n PostalCodeControl: ShippingAddressPostalCodeControl,\n PostalCodeControlDefinition: ShippingAddressPostalCodeControlDefinition,\n ComplementControl: ShippingAddressComplementControl,\n ComplementControlDefinition: ShippingAddressComplementControlDefinition,\n NeighborhoodControl: ShippingAddressNeighborhoodControl,\n NeighborhoodControlDefinition: ShippingAddressNeighborhoodControlDefinition,\n CountryControl: ShippingAddressCountryControl,\n CountryControlDefinition: ShippingAddressCountryControlDefinition,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAM,mBAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EvC,MAAM,6BAA6B;AAwBnC,MAAM,iCAAiC,cAA0D,IAAI;;;;;;;;AASrG,SAAS,oCAAyE;CAChF,MAAM,MAAM,WAAW,8BAA8B;CACrD,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,iFAAiF;CAEnG,OAAO;AACT;;;;;;;;AASA,MAAM,iCAAiC;;AAGvC,MAAM,qBAAoF;CACxF,eAAe;CACf,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,QAAQ,KAAA;CACR,YAAY;CACZ,cAAc;CACd,MAAM;CACN,OAAO;AACT;;;;;;AAOA,SAAS,UAAU,OAAwB,OAAsC;CAC/E,IAAI,CAAC,MAAM,UAAU,OAAO,MAAM;CAClC,OAAO;EAAE,GAAG,MAAM;EAAM,UAAU,GAAG,MAAM;CAAgB;AAC7D;;AAGA,SAAS,yBAAyB,QAAwD;CACxF,MAAM,SAAgC,CAAC;CACvC,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAgC;EAClE,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO;CACzC;CACA,OAAO;AACT;AA6GA,MAAa,oCAAoC,gBAA8C;CAC7F,MAAM;CACN,YAAY;CACZ,WAAW;CACX,UAAU;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AA,CAAA;EAEM,CAAA;CACA,CAAA;AAElB;AAMA,MAAa,kBAAkB;CAC7B,UAAU;CACV,oBAAoB;CACpB,kBAAkB;CAClB,sBAAsB;CACtB,gCAAgC;CAChC,eAAe;CACf,yBAAyB;CACzB,eAAe;CACf,yBAAyB;CACzB,aAAa;CACb,uBAAuB;CACvB,cAAc;CACd,wBAAwB;CACxB,mBAAmB;CACnB,6BAA6B;CAC7B,mBAAmB;CACnB,6BAA6B;CAC7B,qBAAqB;CACrB,+BAA+B;CAC/B,gBAAgB;CAChB,0BAA0B;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"shipping-simulator.js","names":[],"sources":["../../../src/matter/shipping-simulator/shipping-simulator.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { FormattedMessage, type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { CartShippingSimulateInput } from '../../sdk/shipping/cart-operations.js';\nimport type { ShippingSimulateInput } from '../../sdk/shipping/operations.js';\nimport { useCartShippingSimulation } from '../../sdk/shipping/use-cart-shipping-simulation.js';\nimport { useShippingSimulation } from '../../sdk/shipping/use-shipping-simulation.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingSimulatorData on Query {\n productBySlug(slug: $slug) {\n variants(first: 1) {\n edges {\n node {\n id\n sellers {\n id\n isDefault\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data types (shape of the fragment result)\n// ---------------------------------------------------------------------------\n\ntype RawShippingSimulatorData = {\n variants: {\n edges: Array<{\n node: {\n id: string;\n sellers: Array<{\n id: string;\n isDefault: boolean;\n }>;\n };\n }>;\n };\n};\n\n// ---------------------------------------------------------------------------\n// Domain types (mirror the shippingSimulation GraphQL contract)\n// ---------------------------------------------------------------------------\n\ntype MoneyValue = { amount: number; currencyCode: string };\n\ntype DeliveryChannel = 'DELIVERY' | 'PICKUP' | 'UNKNOWN';\n\ntype ShippingEstimateUnit = 'BUSINESS_DAYS' | 'DAYS' | 'HOURS' | 'MINUTES';\n\ntype ShippingEstimate = { value: number; unit: ShippingEstimateUnit };\n\n// Exported alongside `ShippingSimulatorContextValue` so `DeliveryOptionsRoot`\n// (matter/delivery-options) can type against the exact shape the reused leaves expect, with no\n// structural duplication (specs/delivery-options-step.md Decision 2).\nexport type ShippingOption = {\n id: string;\n name: string;\n channel: DeliveryChannel;\n shippingEstimate: ShippingEstimate;\n price: MoneyValue;\n listPrice: MoneyValue;\n};\n\ntype ShippingSimulateErrorCode = 'INVALID_POSTAL_CODE' | 'UNKNOWN';\n\n// Exported with `ShippingSimulationPayload` so the `./client` entry can name the simulate callback's\n// whole contract — the SDK hooks return it and a store writing its own `onSimulate` has to name it.\nexport type ShippingSimulateError = {\n code: ShippingSimulateErrorCode;\n message: string;\n};\n\nexport type ShippingSimulationPayload = {\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n};\n\ntype Status = 'idle' | 'loading' | 'success' | 'error';\n\nexport type ShippingSimulatorContextValue = {\n postalCode: string;\n setPostalCode: (value: string) => void;\n status: Status;\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n submit: () => void;\n};\n\nconst SHIPPING_SIMULATOR_CONTEXT_UNSET = Symbol('ShippingSimulatorContextUnset');\n\nexport type ShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n quantity?: number;\n variantId?: string;\n seller?: string;\n $data?: RawShippingSimulatorData | null;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: ShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type CartShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: CartShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type ShippingSimulatorFormProps = ComponentPropsWithRef<'form'>;\n\nexport type ShippingSimulatorInputProps = Omit<ComponentPropsWithRef<'input'>, 'value' | 'onChange'> & {\n format?: boolean;\n};\n\nexport type ShippingSimulatorSubmitProps = ComponentPropsWithRef<'button'>;\n\nexport type ShippingSimulatorLoadingProps = ComponentPropsWithRef<'output'>;\n\nexport type ShippingSimulatorErrorProps = ComponentPropsWithRef<'div'>;\n\nexport type ShippingSimulatorOptionsProps = ComponentPropsWithRef<'ul'> & {\n sortBy?: 'price' | 'estimate';\n maxOptions?: number;\n};\n\nexport type ShippingSimulatorOptionProps = ComponentPropsWithRef<'li'>;\n\nexport type ShippingSimulatorOptionNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionEstimateProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionFreeBadgeProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorEmptyProps = ComponentPropsWithRef<'output'>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n// Exported so `DeliveryOptionsRoot` can become a third provider by importing these same Context\n// objects directly (context matching is by identity, not shape). The two hooks below stay\n// module-private — providers need the objects, not the consumer API (Decision 2).\nexport const ShippingSimulatorContext = createContext<\n ShippingSimulatorContextValue | typeof SHIPPING_SIMULATOR_CONTEXT_UNSET\n>(SHIPPING_SIMULATOR_CONTEXT_UNSET);\n\nexport const OptionItemContext = createContext<ShippingOption | null>(null);\n\nfunction useShippingSimulator(): ShippingSimulatorContextValue {\n const ctx = useContext(ShippingSimulatorContext);\n if (ctx === SHIPPING_SIMULATOR_CONTEXT_UNSET) {\n throw new Error('ShippingSimulator components must be used inside ShippingSimulatorRoot.');\n }\n return ctx;\n}\n\nfunction useOptionItem(): ShippingOption {\n const ctx = useContext(OptionItemContext);\n if (!ctx) {\n throw new Error('ShippingSimulatorOption components must be used inside ShippingSimulatorOptions.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Each unit's whole sentence, and the variable that sentence names.\n//\n// Whole sentence, not a unit fragment interpolated into a wrapper: interpolating a translated\n// fragment into a translated wrapper freezes \"preposition + noun\" order into every language, and\n// hands the translator `em {estimate}` with no way to agree preposition, article or case with a noun\n// they cannot see. The variable is named after what it counts (`{days}`, `{hours}`) rather than a\n// generic `{count}`, for the same reason.\n//\n// A `Record` and not a `switch` with a default: a fifth unit arriving in the GraphQL schema is a\n// type error here, not a silent fallback to the wrong sentence.\n//\n// `variable` is the union of the names those sentences read, never `string`: widened, a typo passes\n// typecheck, lint and every test, and the shopper gets the raw ICU pattern because `onIntlError` is\n// silent in production. The parity assertion in the test file closes the other half of the gap — that\n// the name written here is the one the catalog's message actually names.\nexport const ESTIMATE_MESSAGE: Record<ShippingEstimateUnit, { id: MessageId; variable: 'days' | 'hours' | 'minutes' }> =\n {\n BUSINESS_DAYS: { id: 'fs/shipping.estimate.in-business-days', variable: 'days' },\n DAYS: { id: 'fs/shipping.estimate.in-days', variable: 'days' },\n HOURS: { id: 'fs/shipping.estimate.in-hours', variable: 'hours' },\n MINUTES: { id: 'fs/shipping.estimate.in-minutes', variable: 'minutes' },\n };\n\n// Business days weigh the same as calendar days: exact wall-clock conversion is unknowable and\n// the ranking only needs a consistent order.\nconst ESTIMATE_UNIT_MINUTES: Record<ShippingEstimateUnit, number> = {\n MINUTES: 1,\n HOURS: 60,\n DAYS: 1440,\n BUSINESS_DAYS: 1440,\n};\n\nfunction sortShippingOptions(options: readonly ShippingOption[], sortBy: 'price' | 'estimate'): ShippingOption[] {\n const rank =\n sortBy === 'price'\n ? (option: ShippingOption) => Number(option.price.amount)\n : (option: ShippingOption) => option.shippingEstimate.value * ESTIMATE_UNIT_MINUTES[option.shippingEstimate.unit];\n return [...options].sort((a, b) => rank(a) - rank(b));\n}\n\nfunction normalizePostalCode(value: string): string {\n return value.replace(/\\D/g, '').slice(0, 8);\n}\n\nfunction formatPostalCode(value: string): string {\n const digits = normalizePostalCode(value);\n return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;\n}\n\nfunction extractProductFromData(data: RawShippingSimulatorData | null | undefined): {\n variantId: string | null;\n seller: string | null;\n} {\n if (!data) return { variantId: null, seller: null };\n const edge = data.variants?.edges?.[0];\n if (!edge) return { variantId: null, seller: null };\n const { id, sellers } = edge.node;\n const defaultSeller = sellers?.find((s) => s.isDefault) ?? sellers?.[0];\n return { variantId: id ?? null, seller: defaultSeller?.id ?? null };\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulatorRootDefinition = defineComponent<ShippingSimulatorRootProps>({\n name: 'ShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n quantity: { type: 'number', default: 1, label: 'Quantity' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the PDP shipping simulator: a shopper types a postal code and sees a shipping preview for ONE product on a product detail page. Backed by shippingSimulation and a product fragment (productBySlug(slug: $slug)), so it must live on a page with a $slug variable. Use CartShippingSimulatorRoot instead for a whole-cart calculator in the cart/mini-cart. All other ShippingSimulator components must be descendants of this one.',\n});\n\nexport const CartShippingSimulatorRootDefinition = defineComponent<CartShippingSimulatorRootProps>({\n name: 'CartShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: CartShippingSimulatorRoot,\n editor: { label: 'Cart Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the cart/mini-cart shipping calculator: the shopper types a postal code and sees the shipping options for the WHOLE cart. Backed by cartShippingSimulation (cart sourced server-side via x-order-form-id); needs no CartRoot ancestor and no product fragment. Use ShippingSimulatorRoot instead for a single-product shipping preview on a PDP. All other CartShippingSimulator components must be descendants of this one.',\n});\n\nexport const ShippingSimulatorFormDefinition = defineComponent<ShippingSimulatorFormProps>({\n name: 'ShippingSimulatorForm',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorForm,\n editor: { label: 'Shipping Simulator Form', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Form wrapper that holds ShippingSimulatorInput and ShippingSimulatorSubmit; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorInputDefinition = defineComponent<ShippingSimulatorInputProps>({\n name: 'ShippingSimulatorInput',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorInput,\n editor: { label: 'Shipping Simulator Input', category: 'action' },\n schema: {\n format: { type: 'boolean', default: false, label: 'Auto-format CEP (00000-000)' },\n },\n requiresContext: 'shipping-simulator',\n guideline:\n 'Postal-code text input; enable `format` to auto-hyphenate the CEP as the user types (e.g. 01310-100). The placeholder comes from the message catalog. Must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorSubmitDefinition = defineComponent<ShippingSimulatorSubmitProps>({\n name: 'ShippingSimulatorSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorSubmit,\n editor: { label: 'Shipping Simulator Submit', category: 'action' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline: 'Submit button for the postal-code form; must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorLoadingDefinition = defineComponent<ShippingSimulatorLoadingProps>({\n name: 'ShippingSimulatorLoading',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorLoading,\n editor: { label: 'Shipping Simulator Loading', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Loading indicator shown while a simulation is in progress; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorErrorDefinition = defineComponent<ShippingSimulatorErrorProps>({\n name: 'ShippingSimulatorError',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorError,\n editor: { label: 'Shipping Simulator Error', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Error banner shown when the simulation returns validation errors; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorOptionsDefinition = defineComponent<ShippingSimulatorOptionsProps>({\n name: 'ShippingSimulatorOptions',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptions,\n editor: { label: 'Shipping Simulator Options', category: 'commerce' },\n schema: {\n sortBy: { type: ['price', 'estimate'] as const, label: 'Sort by' },\n maxOptions: { type: 'number', label: 'Max options' },\n },\n requiresContext: 'shipping-simulator',\n providesContext: 'shipping-simulator-option',\n guideline:\n 'List that renders one ShippingSimulatorOption per available shipping option; must be a descendant of a shipping-simulator Root (PDP or cart). Renders every option in API order by default; set sortBy (\"price\" = cheapest first, \"estimate\" = fastest first) and maxOptions to cap the list — sortBy=\"price\" with maxOptions=1 shows only the cheapest option. See shipping-simulator.md.',\n});\n\nexport const ShippingSimulatorOptionDefinition = defineComponent<ShippingSimulatorOptionProps>({\n name: 'ShippingSimulatorOption',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOption,\n editor: { label: 'Shipping Simulator Option', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Container for a single shipping option row; holds ShippingSimulatorOptionName, ShippingSimulatorOptionEstimate, and ShippingSimulatorOptionPrice. Must be a descendant of ShippingSimulatorOptions.',\n});\n\nexport const ShippingSimulatorOptionNameDefinition = defineComponent<ShippingSimulatorOptionNameProps>({\n name: 'ShippingSimulatorOptionName',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionName,\n editor: { label: 'Option Name', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping option name (e.g. \"Entrega Normal\"); must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionEstimateDefinition = defineComponent<ShippingSimulatorOptionEstimateProps>({\n name: 'ShippingSimulatorOptionEstimate',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionEstimate,\n editor: { label: 'Option Estimate', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the delivery estimate in the active locale, one whole sentence per unit from the message catalog; a zero-value estimate (any unit) reads as an arrival-today message instead, since \"chega em 0 dias úteis\" reads wrong. Must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionPriceDefinition = defineComponent<ShippingSimulatorOptionPriceProps>({\n name: 'ShippingSimulatorOptionPrice',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionPrice,\n editor: { label: 'Option Price', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping price, showing the free-shipping label from the message catalog when the amount is zero; must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionFreeBadgeDefinition = defineComponent<ShippingSimulatorOptionFreeBadgeProps>({\n name: 'ShippingSimulatorOptionFreeBadge',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionFreeBadge,\n editor: { label: 'Option Free Badge', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Badge shown only when the current option price is zero (free shipping); renders nothing otherwise. Must be a descendant of ShippingSimulatorOption. Orthogonal to the free-price replacement text owned by ShippingSimulatorOptionPrice.',\n});\n\nexport const ShippingSimulatorEmptyDefinition = defineComponent<ShippingSimulatorEmptyProps>({\n name: 'ShippingSimulatorEmpty',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorEmpty,\n editor: { label: 'Shipping Simulator Empty', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Message shown when a simulation ran and returned no shipping options (e.g. no carrier common to the whole cart). Renders nothing before the first submit and nothing when options or an error are present. The copy comes from the message catalog; pass children to override. Must be a descendant of a shipping-simulator Root.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ShippingSimulatorRoot({\n country = 'BRA',\n quantity = 1,\n variantId: variantIdProp,\n seller: sellerProp,\n $data: $dataProp,\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: ShippingSimulatorRootProps) {\n const defaultSimulate = useShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const $data = useDataOverride($dataProp);\n const extracted = extractProductFromData($data);\n const variantId = variantIdProp ?? extracted.variantId;\n const seller = sellerProp ?? extracted.seller;\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n if (!onSimulate || !variantId || !seller) return;\n\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country, variantId, quantity, seller })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode, quantity, seller, variantId]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function CartShippingSimulatorRoot({\n country = 'BRA',\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: CartShippingSimulatorRootProps) {\n const defaultSimulate = useCartShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function ShippingSimulatorForm({ className, children, ...props }: ShippingSimulatorFormProps) {\n const { submit } = useShippingSimulator();\n\n return (\n <form\n {...props}\n className={className}\n data-fs-shipping-simulator-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n );\n}\n\nexport function ShippingSimulatorInput({\n className,\n placeholder,\n 'aria-label': ariaLabel,\n format = false,\n ...props\n}: ShippingSimulatorInputProps) {\n const { postalCode, setPostalCode } = useShippingSimulator();\n const intl = useIntl();\n const displayValue = format ? formatPostalCode(postalCode) : postalCode;\n\n return (\n <input\n {...props}\n aria-label={ariaLabel ?? intl.formatMessage({ id: 'fs/shipping.postal-code.aria-label' })}\n className={className}\n data-fs-shipping-simulator-input=\"\"\n type=\"text\"\n value={displayValue}\n onChange={(event) => setPostalCode(normalizePostalCode(event.target.value))}\n placeholder={placeholder ?? intl.formatMessage({ id: 'fs/shipping.postal-code.placeholder' })}\n pattern=\"\\d{5}-?\\d{3}\"\n maxLength={9}\n inputMode=\"numeric\"\n required\n />\n );\n}\n\nexport function ShippingSimulatorSubmit({ className, children, disabled, ...props }: ShippingSimulatorSubmitProps) {\n const { status } = useShippingSimulator();\n const isLoading = status === 'loading';\n\n return (\n <button\n {...props}\n type=\"submit\"\n className={className}\n data-fs-shipping-simulator-submit=\"\"\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n >\n {children}\n </button>\n );\n}\n\nexport function ShippingSimulatorLoading({ className, children, ...props }: ShippingSimulatorLoadingProps) {\n const { status } = useShippingSimulator();\n if (status !== 'loading') return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-loading=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.calculating\" />}\n </output>\n );\n}\n\nexport function ShippingSimulatorError({ className, children, ...props }: ShippingSimulatorErrorProps) {\n const { userErrors } = useShippingSimulator();\n const [firstError] = userErrors;\n if (!firstError) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-shipping-simulator-error=\"\">\n {children ?? firstError.message}\n </div>\n );\n}\n\nexport function ShippingSimulatorOptions({\n sortBy,\n maxOptions,\n className,\n children,\n ...props\n}: ShippingSimulatorOptionsProps) {\n const { shippingOptions } = useShippingSimulator();\n\n const visibleOptions = useMemo(() => {\n if (!shippingOptions) return null;\n const sorted = sortBy ? sortShippingOptions(shippingOptions, sortBy) : shippingOptions;\n return maxOptions && maxOptions > 0 ? sorted.slice(0, maxOptions) : sorted;\n }, [shippingOptions, sortBy, maxOptions]);\n\n if (!visibleOptions || visibleOptions.length === 0) return null;\n\n return (\n <ul {...props} className={className} data-fs-shipping-simulator-options=\"\">\n {visibleOptions.map((option) => (\n <OptionItemContext key={option.id} value={option}>\n {children}\n </OptionItemContext>\n ))}\n </ul>\n );\n}\n\nexport function ShippingSimulatorOption({ className, children, ...props }: ShippingSimulatorOptionProps) {\n const option = useOptionItem();\n\n return (\n <li\n {...props}\n className={className}\n data-fs-shipping-simulator-option=\"\"\n data-fs-shipping-simulator-option-channel={option.channel}\n >\n {children}\n </li>\n );\n}\n\nexport function ShippingSimulatorOptionName({ className, children, ...props }: ShippingSimulatorOptionNameProps) {\n const option = useOptionItem();\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-name=\"\">\n {children ?? option.name}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionEstimate({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionEstimateProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { value, unit } = option.shippingEstimate;\n const { id, variable } = ESTIMATE_MESSAGE[unit];\n const text =\n value === 0\n ? intl.formatMessage({ id: 'fs/shipping.estimate.today' })\n : intl.formatMessage({ id }, { [variable]: value });\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-estimate=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionPrice({ className, children, ...props }: ShippingSimulatorOptionPriceProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { locale, currency } = useStorefrontContext();\n const text =\n option.price.amount === 0\n ? intl.formatMessage({ id: 'fs/shipping.free-price' })\n : formatPrice(option.price.amount, locale, currency);\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-price=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionFreeBadge({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionFreeBadgeProps) {\n const option = useOptionItem();\n if (option.price.amount !== 0) return null;\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-free-badge=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.free-badge\" />}\n </span>\n );\n}\n\nexport function ShippingSimulatorEmpty({ className, children, ...props }: ShippingSimulatorEmptyProps) {\n const { shippingOptions, userErrors } = useShippingSimulator();\n // Idle (null) → nothing; error → nothing (Error owns it); options present → nothing.\n const simulatedEmpty = Array.isArray(shippingOptions) && shippingOptions.length === 0 && userErrors.length === 0;\n if (!simulatedEmpty) return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-empty=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.no-options\" />}\n </output>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulator = {\n Root: ShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n\nexport const CartShippingSimulator = {\n Root: CartShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,WAAyB;;;;;;;;;;;;;;;;;AAqF/B,MAAM,mCAAmC,OAAO,+BAA+B;AA0D/E,MAAa,2BAA2B,cAEtC,gCAAgC;AAElC,MAAa,oBAAoB,cAAqC,IAAI;AAE1E,SAAS,uBAAsD;CAC7D,MAAM,MAAM,WAAW,wBAAwB;CAC/C,IAAI,QAAQ,kCACV,MAAM,IAAI,MAAM,yEAAyE;CAE3F,OAAO;AACT;AAEA,SAAS,gBAAgC;CACvC,MAAM,MAAM,WAAW,iBAAiB;CACxC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,kFAAkF;CAEpG,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C,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,gBAAgB;CAChB,aAAa;CACb,iBAAiB;CACjB,OAAO;AACT"}
1
+ {"version":3,"file":"shipping-simulator.js","names":[],"sources":["../../../src/matter/shipping-simulator/shipping-simulator.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { FormattedMessage, type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { CartShippingSimulateInput } from '../../sdk/shipping/cart-operations.js';\nimport type { ShippingSimulateInput } from '../../sdk/shipping/operations.js';\nimport { useCartShippingSimulation } from '../../sdk/shipping/use-cart-shipping-simulation.js';\nimport { useShippingSimulation } from '../../sdk/shipping/use-shipping-simulation.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingSimulatorData on Query {\n productBySlug(slug: $slug) {\n variants(first: 1) {\n edges {\n node {\n id\n sellers {\n id\n isDefault\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data types (shape of the fragment result)\n// ---------------------------------------------------------------------------\n\ntype RawShippingSimulatorData = {\n variants: {\n edges: Array<{\n node: {\n id: string;\n sellers: Array<{\n id: string;\n isDefault: boolean;\n }>;\n };\n }>;\n };\n};\n\n// ---------------------------------------------------------------------------\n// Domain types (mirror the shippingSimulation GraphQL contract)\n// ---------------------------------------------------------------------------\n\ntype MoneyValue = { amount: number; currencyCode: string };\n\ntype DeliveryChannel = 'DELIVERY' | 'PICKUP' | 'UNKNOWN';\n\ntype ShippingEstimateUnit = 'BUSINESS_DAYS' | 'DAYS' | 'HOURS' | 'MINUTES';\n\ntype ShippingEstimate = { value: number; unit: ShippingEstimateUnit };\n\n// Exported alongside `ShippingSimulatorContextValue` so `DeliveryOptionsRoot`\n// (matter/delivery-options) can type against the exact shape the reused leaves expect, with no\n// structural duplication (docs/storefront-core/reference-free-particle-model.md § Read side — state).\nexport type ShippingOption = {\n id: string;\n name: string;\n channel: DeliveryChannel;\n shippingEstimate: ShippingEstimate;\n price: MoneyValue;\n listPrice: MoneyValue;\n};\n\ntype ShippingSimulateErrorCode = 'INVALID_POSTAL_CODE' | 'UNKNOWN';\n\n// Exported with `ShippingSimulationPayload` so the `./client` entry can name the simulate callback's\n// whole contract — the SDK hooks return it and a store writing its own `onSimulate` has to name it.\nexport type ShippingSimulateError = {\n code: ShippingSimulateErrorCode;\n message: string;\n};\n\nexport type ShippingSimulationPayload = {\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n};\n\ntype Status = 'idle' | 'loading' | 'success' | 'error';\n\nexport type ShippingSimulatorContextValue = {\n postalCode: string;\n setPostalCode: (value: string) => void;\n status: Status;\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n submit: () => void;\n};\n\nconst SHIPPING_SIMULATOR_CONTEXT_UNSET = Symbol('ShippingSimulatorContextUnset');\n\nexport type ShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n quantity?: number;\n variantId?: string;\n seller?: string;\n $data?: RawShippingSimulatorData | null;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: ShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type CartShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: CartShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type ShippingSimulatorFormProps = ComponentPropsWithRef<'form'>;\n\nexport type ShippingSimulatorInputProps = Omit<ComponentPropsWithRef<'input'>, 'value' | 'onChange'> & {\n format?: boolean;\n};\n\nexport type ShippingSimulatorSubmitProps = ComponentPropsWithRef<'button'>;\n\nexport type ShippingSimulatorLoadingProps = ComponentPropsWithRef<'output'>;\n\nexport type ShippingSimulatorErrorProps = ComponentPropsWithRef<'div'>;\n\nexport type ShippingSimulatorOptionsProps = ComponentPropsWithRef<'ul'> & {\n sortBy?: 'price' | 'estimate';\n maxOptions?: number;\n};\n\nexport type ShippingSimulatorOptionProps = ComponentPropsWithRef<'li'>;\n\nexport type ShippingSimulatorOptionNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionEstimateProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionFreeBadgeProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorEmptyProps = ComponentPropsWithRef<'output'>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n// Exported so `DeliveryOptionsRoot` can become a third provider by importing these same Context\n// objects directly (context matching is by identity, not shape). The two hooks below stay\n// module-private — providers need the objects, not the consumer API (Decision 2).\nexport const ShippingSimulatorContext = createContext<\n ShippingSimulatorContextValue | typeof SHIPPING_SIMULATOR_CONTEXT_UNSET\n>(SHIPPING_SIMULATOR_CONTEXT_UNSET);\n\nexport const OptionItemContext = createContext<ShippingOption | null>(null);\n\nfunction useShippingSimulator(): ShippingSimulatorContextValue {\n const ctx = useContext(ShippingSimulatorContext);\n if (ctx === SHIPPING_SIMULATOR_CONTEXT_UNSET) {\n throw new Error('ShippingSimulator components must be used inside ShippingSimulatorRoot.');\n }\n return ctx;\n}\n\nfunction useOptionItem(): ShippingOption {\n const ctx = useContext(OptionItemContext);\n if (!ctx) {\n throw new Error('ShippingSimulatorOption components must be used inside ShippingSimulatorOptions.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Each unit's whole sentence, and the variable that sentence names.\n//\n// Whole sentence, not a unit fragment interpolated into a wrapper: interpolating a translated\n// fragment into a translated wrapper freezes \"preposition + noun\" order into every language, and\n// hands the translator `em {estimate}` with no way to agree preposition, article or case with a noun\n// they cannot see. The variable is named after what it counts (`{days}`, `{hours}`) rather than a\n// generic `{count}`, for the same reason.\n//\n// A `Record` and not a `switch` with a default: a fifth unit arriving in the GraphQL schema is a\n// type error here, not a silent fallback to the wrong sentence.\n//\n// `variable` is the union of the names those sentences read, never `string`: widened, a typo passes\n// typecheck, lint and every test, and the shopper gets the raw ICU pattern because `onIntlError` is\n// silent in production. The parity assertion in the test file closes the other half of the gap — that\n// the name written here is the one the catalog's message actually names.\nexport const ESTIMATE_MESSAGE: Record<ShippingEstimateUnit, { id: MessageId; variable: 'days' | 'hours' | 'minutes' }> =\n {\n BUSINESS_DAYS: { id: 'fs/shipping.estimate.in-business-days', variable: 'days' },\n DAYS: { id: 'fs/shipping.estimate.in-days', variable: 'days' },\n HOURS: { id: 'fs/shipping.estimate.in-hours', variable: 'hours' },\n MINUTES: { id: 'fs/shipping.estimate.in-minutes', variable: 'minutes' },\n };\n\n// Business days weigh the same as calendar days: exact wall-clock conversion is unknowable and\n// the ranking only needs a consistent order.\nconst ESTIMATE_UNIT_MINUTES: Record<ShippingEstimateUnit, number> = {\n MINUTES: 1,\n HOURS: 60,\n DAYS: 1440,\n BUSINESS_DAYS: 1440,\n};\n\nfunction sortShippingOptions(options: readonly ShippingOption[], sortBy: 'price' | 'estimate'): ShippingOption[] {\n const rank =\n sortBy === 'price'\n ? (option: ShippingOption) => Number(option.price.amount)\n : (option: ShippingOption) => option.shippingEstimate.value * ESTIMATE_UNIT_MINUTES[option.shippingEstimate.unit];\n return [...options].sort((a, b) => rank(a) - rank(b));\n}\n\nfunction normalizePostalCode(value: string): string {\n return value.replace(/\\D/g, '').slice(0, 8);\n}\n\nfunction formatPostalCode(value: string): string {\n const digits = normalizePostalCode(value);\n return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;\n}\n\nfunction extractProductFromData(data: RawShippingSimulatorData | null | undefined): {\n variantId: string | null;\n seller: string | null;\n} {\n if (!data) return { variantId: null, seller: null };\n const edge = data.variants?.edges?.[0];\n if (!edge) return { variantId: null, seller: null };\n const { id, sellers } = edge.node;\n const defaultSeller = sellers?.find((s) => s.isDefault) ?? sellers?.[0];\n return { variantId: id ?? null, seller: defaultSeller?.id ?? null };\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulatorRootDefinition = defineComponent<ShippingSimulatorRootProps>({\n name: 'ShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n quantity: { type: 'number', default: 1, label: 'Quantity' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the PDP shipping simulator: a shopper types a postal code and sees a shipping preview for ONE product on a product detail page. Backed by shippingSimulation and a product fragment (productBySlug(slug: $slug)), so it must live on a page with a $slug variable. Use CartShippingSimulatorRoot instead for a whole-cart calculator in the cart/mini-cart. All other ShippingSimulator components must be descendants of this one.',\n});\n\nexport const CartShippingSimulatorRootDefinition = defineComponent<CartShippingSimulatorRootProps>({\n name: 'CartShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: CartShippingSimulatorRoot,\n editor: { label: 'Cart Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the cart/mini-cart shipping calculator: the shopper types a postal code and sees the shipping options for the WHOLE cart. Backed by cartShippingSimulation (cart sourced server-side via x-order-form-id); needs no CartRoot ancestor and no product fragment. Use ShippingSimulatorRoot instead for a single-product shipping preview on a PDP. All other CartShippingSimulator components must be descendants of this one.',\n});\n\nexport const ShippingSimulatorFormDefinition = defineComponent<ShippingSimulatorFormProps>({\n name: 'ShippingSimulatorForm',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorForm,\n editor: { label: 'Shipping Simulator Form', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Form wrapper that holds ShippingSimulatorInput and ShippingSimulatorSubmit; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorInputDefinition = defineComponent<ShippingSimulatorInputProps>({\n name: 'ShippingSimulatorInput',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorInput,\n editor: { label: 'Shipping Simulator Input', category: 'action' },\n schema: {\n format: { type: 'boolean', default: false, label: 'Auto-format CEP (00000-000)' },\n },\n requiresContext: 'shipping-simulator',\n guideline:\n 'Postal-code text input; enable `format` to auto-hyphenate the CEP as the user types (e.g. 01310-100). The placeholder comes from the message catalog. Must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorSubmitDefinition = defineComponent<ShippingSimulatorSubmitProps>({\n name: 'ShippingSimulatorSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorSubmit,\n editor: { label: 'Shipping Simulator Submit', category: 'action' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline: 'Submit button for the postal-code form; must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorLoadingDefinition = defineComponent<ShippingSimulatorLoadingProps>({\n name: 'ShippingSimulatorLoading',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorLoading,\n editor: { label: 'Shipping Simulator Loading', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Loading indicator shown while a simulation is in progress; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorErrorDefinition = defineComponent<ShippingSimulatorErrorProps>({\n name: 'ShippingSimulatorError',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorError,\n editor: { label: 'Shipping Simulator Error', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Error banner shown when the simulation returns validation errors; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorOptionsDefinition = defineComponent<ShippingSimulatorOptionsProps>({\n name: 'ShippingSimulatorOptions',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptions,\n editor: { label: 'Shipping Simulator Options', category: 'commerce' },\n schema: {\n sortBy: { type: ['price', 'estimate'] as const, label: 'Sort by' },\n maxOptions: { type: 'number', label: 'Max options' },\n },\n requiresContext: 'shipping-simulator',\n providesContext: 'shipping-simulator-option',\n guideline:\n 'List that renders one ShippingSimulatorOption per available shipping option; must be a descendant of a shipping-simulator Root (PDP or cart). Renders every option in API order by default; set sortBy (\"price\" = cheapest first, \"estimate\" = fastest first) and maxOptions to cap the list — sortBy=\"price\" with maxOptions=1 shows only the cheapest option. See shipping-simulator.md.',\n});\n\nexport const ShippingSimulatorOptionDefinition = defineComponent<ShippingSimulatorOptionProps>({\n name: 'ShippingSimulatorOption',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOption,\n editor: { label: 'Shipping Simulator Option', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Container for a single shipping option row; holds ShippingSimulatorOptionName, ShippingSimulatorOptionEstimate, and ShippingSimulatorOptionPrice. Must be a descendant of ShippingSimulatorOptions.',\n});\n\nexport const ShippingSimulatorOptionNameDefinition = defineComponent<ShippingSimulatorOptionNameProps>({\n name: 'ShippingSimulatorOptionName',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionName,\n editor: { label: 'Option Name', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping option name (e.g. \"Entrega Normal\"); must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionEstimateDefinition = defineComponent<ShippingSimulatorOptionEstimateProps>({\n name: 'ShippingSimulatorOptionEstimate',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionEstimate,\n editor: { label: 'Option Estimate', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the delivery estimate in the active locale, one whole sentence per unit from the message catalog; a zero-value estimate (any unit) reads as an arrival-today message instead, since \"chega em 0 dias úteis\" reads wrong. Must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionPriceDefinition = defineComponent<ShippingSimulatorOptionPriceProps>({\n name: 'ShippingSimulatorOptionPrice',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionPrice,\n editor: { label: 'Option Price', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping price, showing the free-shipping label from the message catalog when the amount is zero; must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionFreeBadgeDefinition = defineComponent<ShippingSimulatorOptionFreeBadgeProps>({\n name: 'ShippingSimulatorOptionFreeBadge',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionFreeBadge,\n editor: { label: 'Option Free Badge', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Badge shown only when the current option price is zero (free shipping); renders nothing otherwise. Must be a descendant of ShippingSimulatorOption. Orthogonal to the free-price replacement text owned by ShippingSimulatorOptionPrice.',\n});\n\nexport const ShippingSimulatorEmptyDefinition = defineComponent<ShippingSimulatorEmptyProps>({\n name: 'ShippingSimulatorEmpty',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorEmpty,\n editor: { label: 'Shipping Simulator Empty', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Message shown when a simulation ran and returned no shipping options (e.g. no carrier common to the whole cart). Renders nothing before the first submit and nothing when options or an error are present. The copy comes from the message catalog; pass children to override. Must be a descendant of a shipping-simulator Root.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ShippingSimulatorRoot({\n country = 'BRA',\n quantity = 1,\n variantId: variantIdProp,\n seller: sellerProp,\n $data: $dataProp,\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: ShippingSimulatorRootProps) {\n const defaultSimulate = useShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const $data = useDataOverride($dataProp);\n const extracted = extractProductFromData($data);\n const variantId = variantIdProp ?? extracted.variantId;\n const seller = sellerProp ?? extracted.seller;\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n if (!onSimulate || !variantId || !seller) return;\n\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country, variantId, quantity, seller })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode, quantity, seller, variantId]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function CartShippingSimulatorRoot({\n country = 'BRA',\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: CartShippingSimulatorRootProps) {\n const defaultSimulate = useCartShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function ShippingSimulatorForm({ className, children, ...props }: ShippingSimulatorFormProps) {\n const { submit } = useShippingSimulator();\n\n return (\n <form\n {...props}\n className={className}\n data-fs-shipping-simulator-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n );\n}\n\nexport function ShippingSimulatorInput({\n className,\n placeholder,\n 'aria-label': ariaLabel,\n format = false,\n ...props\n}: ShippingSimulatorInputProps) {\n const { postalCode, setPostalCode } = useShippingSimulator();\n const intl = useIntl();\n const displayValue = format ? formatPostalCode(postalCode) : postalCode;\n\n return (\n <input\n {...props}\n aria-label={ariaLabel ?? intl.formatMessage({ id: 'fs/shipping.postal-code.aria-label' })}\n className={className}\n data-fs-shipping-simulator-input=\"\"\n type=\"text\"\n value={displayValue}\n onChange={(event) => setPostalCode(normalizePostalCode(event.target.value))}\n placeholder={placeholder ?? intl.formatMessage({ id: 'fs/shipping.postal-code.placeholder' })}\n pattern=\"\\d{5}-?\\d{3}\"\n maxLength={9}\n inputMode=\"numeric\"\n required\n />\n );\n}\n\nexport function ShippingSimulatorSubmit({ className, children, disabled, ...props }: ShippingSimulatorSubmitProps) {\n const { status } = useShippingSimulator();\n const isLoading = status === 'loading';\n\n return (\n <button\n {...props}\n type=\"submit\"\n className={className}\n data-fs-shipping-simulator-submit=\"\"\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n >\n {children}\n </button>\n );\n}\n\nexport function ShippingSimulatorLoading({ className, children, ...props }: ShippingSimulatorLoadingProps) {\n const { status } = useShippingSimulator();\n if (status !== 'loading') return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-loading=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.calculating\" />}\n </output>\n );\n}\n\nexport function ShippingSimulatorError({ className, children, ...props }: ShippingSimulatorErrorProps) {\n const { userErrors } = useShippingSimulator();\n const [firstError] = userErrors;\n if (!firstError) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-shipping-simulator-error=\"\">\n {children ?? firstError.message}\n </div>\n );\n}\n\nexport function ShippingSimulatorOptions({\n sortBy,\n maxOptions,\n className,\n children,\n ...props\n}: ShippingSimulatorOptionsProps) {\n const { shippingOptions } = useShippingSimulator();\n\n const visibleOptions = useMemo(() => {\n if (!shippingOptions) return null;\n const sorted = sortBy ? sortShippingOptions(shippingOptions, sortBy) : shippingOptions;\n return maxOptions && maxOptions > 0 ? sorted.slice(0, maxOptions) : sorted;\n }, [shippingOptions, sortBy, maxOptions]);\n\n if (!visibleOptions || visibleOptions.length === 0) return null;\n\n return (\n <ul {...props} className={className} data-fs-shipping-simulator-options=\"\">\n {visibleOptions.map((option) => (\n <OptionItemContext key={option.id} value={option}>\n {children}\n </OptionItemContext>\n ))}\n </ul>\n );\n}\n\nexport function ShippingSimulatorOption({ className, children, ...props }: ShippingSimulatorOptionProps) {\n const option = useOptionItem();\n\n return (\n <li\n {...props}\n className={className}\n data-fs-shipping-simulator-option=\"\"\n data-fs-shipping-simulator-option-channel={option.channel}\n >\n {children}\n </li>\n );\n}\n\nexport function ShippingSimulatorOptionName({ className, children, ...props }: ShippingSimulatorOptionNameProps) {\n const option = useOptionItem();\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-name=\"\">\n {children ?? option.name}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionEstimate({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionEstimateProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { value, unit } = option.shippingEstimate;\n const { id, variable } = ESTIMATE_MESSAGE[unit];\n const text =\n value === 0\n ? intl.formatMessage({ id: 'fs/shipping.estimate.today' })\n : intl.formatMessage({ id }, { [variable]: value });\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-estimate=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionPrice({ className, children, ...props }: ShippingSimulatorOptionPriceProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { locale, currency } = useStorefrontContext();\n const text =\n option.price.amount === 0\n ? intl.formatMessage({ id: 'fs/shipping.free-price' })\n : formatPrice(option.price.amount, locale, currency);\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-price=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionFreeBadge({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionFreeBadgeProps) {\n const option = useOptionItem();\n if (option.price.amount !== 0) return null;\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-free-badge=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.free-badge\" />}\n </span>\n );\n}\n\nexport function ShippingSimulatorEmpty({ className, children, ...props }: ShippingSimulatorEmptyProps) {\n const { shippingOptions, userErrors } = useShippingSimulator();\n // Idle (null) → nothing; error → nothing (Error owns it); options present → nothing.\n const simulatedEmpty = Array.isArray(shippingOptions) && shippingOptions.length === 0 && userErrors.length === 0;\n if (!simulatedEmpty) return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-empty=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.no-options\" />}\n </output>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulator = {\n Root: ShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n\nexport const CartShippingSimulator = {\n Root: CartShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,WAAyB;;;;;;;;;;;;;;;;;AAqF/B,MAAM,mCAAmC,OAAO,+BAA+B;AA0D/E,MAAa,2BAA2B,cAEtC,gCAAgC;AAElC,MAAa,oBAAoB,cAAqC,IAAI;AAE1E,SAAS,uBAAsD;CAC7D,MAAM,MAAM,WAAW,wBAAwB;CAC/C,IAAI,QAAQ,kCACV,MAAM,IAAI,MAAM,yEAAyE;CAE3F,OAAO;AACT;AAEA,SAAS,gBAAgC;CACvC,MAAM,MAAM,WAAW,iBAAiB;CACxC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,kFAAkF;CAEpG,OAAO;AACT;AAMA,SAAS,YAAY,OAAe,QAAgB,UAA0B;CAC5E,OAAO,IAAI,KAAK,aAAa,QAAQ;EAAE,OAAO;EAAY;CAAS,CAAC,CAAC,CAAC,OAAO,KAAK;AACpF;AAiBA,MAAa,mBACX;CACE,eAAe;EAAE,IAAI;EAAyC,UAAU;C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3
3
  import "../../core/dist/index.js";
4
4
  import { graphql } from "../../sdk/generated/gql.js";
5
5
  import { useDataOverride } from "../../sdk/data/data-override-context.js";
6
- import { publishedVariantIdFor, selectedVariantVar } from "../../sdk/state/variant-selector.js";
7
6
  import { RadioGroup } from "../../particles/radio/radio.js";
7
+ import { publishedVariantIdFor, selectedVariantVar } from "../../sdk/state/variant-selector.js";
8
8
  import { useReactiveVar } from "@apollo/client/react";
9
9
  import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";