cloudcommerce 2.10.2 → 2.10.4

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 (156) hide show
  1. package/.vscode/settings.json +3 -3
  2. package/CHANGELOG.md +15 -0
  3. package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
  4. package/ecomplus-stores/barradoce/functions/ssr/content/pages/products.json +1 -4
  5. package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
  6. package/ecomplus-stores/barradoce/functions/ssr/{tailwind.config.cjs → tailwind.config.js} +3 -3
  7. package/ecomplus-stores/barradoce/functions/ssr/uno.config.js +4 -0
  8. package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
  9. package/ecomplus-stores/barradoce/package.json +2 -2
  10. package/ecomplus-stores/barradoce/tailwind.config.js +8 -0
  11. package/package.json +4 -4
  12. package/packages/api/package.json +1 -1
  13. package/packages/apps/affiliate-program/package.json +2 -2
  14. package/packages/apps/correios/package.json +2 -2
  15. package/packages/apps/custom-payment/package.json +1 -1
  16. package/packages/apps/custom-shipping/package.json +1 -1
  17. package/packages/apps/datafrete/package.json +3 -3
  18. package/packages/apps/discounts/package.json +1 -1
  19. package/packages/apps/emails/package.json +3 -3
  20. package/packages/apps/fb-conversions/package.json +3 -3
  21. package/packages/apps/flash-courier/package.json +2 -2
  22. package/packages/apps/frenet/package.json +3 -3
  23. package/packages/apps/galaxpay/package.json +3 -3
  24. package/packages/apps/google-analytics/package.json +3 -3
  25. package/packages/apps/jadlog/package.json +1 -1
  26. package/packages/apps/loyalty-points/package.json +1 -1
  27. package/packages/apps/mandae/package.json +2 -2
  28. package/packages/apps/melhor-envio/package.json +3 -3
  29. package/packages/apps/mercadopago/package.json +3 -3
  30. package/packages/apps/pagarme/package.json +3 -3
  31. package/packages/apps/pagarme-v5/package.json +2 -2
  32. package/packages/apps/paghiper/package.json +3 -3
  33. package/packages/apps/pix/package.json +3 -3
  34. package/packages/apps/tiny-erp/package.json +3 -3
  35. package/packages/apps/webhooks/package.json +3 -3
  36. package/packages/cli/package.json +1 -1
  37. package/packages/config/package.json +1 -1
  38. package/packages/emails/package.json +1 -1
  39. package/packages/eslint/base.eslintrc.cjs +1 -0
  40. package/packages/eslint/package.json +4 -4
  41. package/packages/events/package.json +3 -3
  42. package/packages/feeds/package.json +2 -2
  43. package/packages/firebase/package.json +3 -3
  44. package/packages/i18n/package.json +1 -1
  45. package/packages/modules/package.json +3 -3
  46. package/packages/passport/package.json +3 -3
  47. package/packages/ssr/package.json +3 -3
  48. package/packages/storefront/config/{storefront.tailwind.cjs → storefront.tailwind.mjs} +19 -19
  49. package/packages/storefront/config/{storefront.unocss.cjs → storefront.unocss.mjs} +9 -9
  50. package/packages/storefront/dist/client/_astro/AccountPage.Cf0WE6GF.js +1 -0
  51. package/packages/storefront/dist/client/_astro/CartSidebar.DAvJKL2c.js +1 -0
  52. package/packages/storefront/dist/client/_astro/HeroSlider.DyjSOy4Q.js +1 -0
  53. package/packages/storefront/dist/client/_astro/PitchBar.CEGsee2q.js +1 -0
  54. package/packages/storefront/dist/client/_astro/Prices.9RhV7hCY.js +1 -0
  55. package/packages/storefront/dist/client/_astro/ProductDetails.BpZtnS8j.js +7 -0
  56. package/packages/storefront/dist/client/_astro/ProductShelf.C0TU_sRb.js +1 -0
  57. package/packages/storefront/dist/client/_astro/SearchModal.DWNSfxML.js +1 -0
  58. package/packages/storefront/dist/client/_astro/SearchShowcase.CUkbXIRk.js +1 -0
  59. package/packages/storefront/dist/client/_astro/ShippingCalculator.DZSCK4xv.js +1 -0
  60. package/packages/storefront/dist/client/_astro/ShopHeader.D7qqQxFD.js +7 -0
  61. package/packages/storefront/dist/client/_astro/{_plugin-vue_export-helper.3R8ooc_r.js → _plugin-vue_export-helper.6K9uDcVo.js} +1 -1
  62. package/packages/storefront/dist/client/_astro/_slug_.HhgCFKHv.css +1 -0
  63. package/packages/storefront/dist/client/_astro/client.D_V8TfA5.js +1 -0
  64. package/packages/storefront/dist/client/_astro/customer-session.Cctko5_9.js +7 -0
  65. package/packages/storefront/dist/client/_astro/{firebase-app.CBckq0Sj.js → firebase-app.CmI1zl7o.js} +1 -1
  66. package/packages/storefront/dist/client/_astro/{format-money.vLicYTv9.js → format-money.D19_eJVX.js} +1 -1
  67. package/packages/storefront/dist/client/_astro/{grid-title.CxNZApGL.js → grid-title.CZdq2sDS.js} +1 -1
  68. package/packages/storefront/dist/client/_astro/hoisted.BeKMioW4.js +1 -0
  69. package/packages/storefront/dist/client/_astro/hoisted.Bf1gCkSN.js +1 -0
  70. package/packages/storefront/dist/client/_astro/hoisted.CSjieYcR.js +8 -0
  71. package/packages/storefront/dist/client/_astro/{i18n.BE5r_SIU.js → i18n.DPcLqMFO.js} +1 -1
  72. package/packages/storefront/dist/client/_astro/{img.CB-F9VLo.js → img.Be85e5da.js} +1 -1
  73. package/packages/storefront/dist/client/_astro/{index-bea2a320.CHELEM8n.js → index-a8cf6c8f.k99a-gIB.js} +99 -99
  74. package/packages/storefront/dist/client/_astro/index.BCNoXz_Z.js +1 -0
  75. package/packages/storefront/dist/client/_astro/index.BgtOIB20.js +1 -0
  76. package/packages/storefront/dist/client/_astro/index.DlxZwqDP.js +1 -0
  77. package/packages/storefront/dist/client/_astro/modules-info.BswYf_-7.js +1 -0
  78. package/packages/storefront/dist/client/_astro/name.Dll7Wwmg.js +1 -0
  79. package/packages/storefront/dist/client/_astro/page.FdSlRisw.js +1 -0
  80. package/packages/storefront/dist/client/_astro/sf-utils.C9ygvYIB.js +13 -0
  81. package/packages/storefront/dist/client/_astro/shopping-cart.Cqc6p5UR.js +1 -0
  82. package/packages/storefront/dist/client/_astro/use-analytics.bP3a5cR0.js +1 -0
  83. package/packages/storefront/dist/client/_astro/{use-cms-preview.CPGTKut8.js → use-cms-preview.BxKK4a1X.js} +1 -1
  84. package/packages/storefront/dist/client/_astro/use-product-card.Cj9Q-Y1A.js +1 -0
  85. package/packages/storefront/dist/client/_astro/{use-text-value.D4Rw7N4D.js → use-text-value.DT0v9Yj_.js} +2 -2
  86. package/packages/storefront/dist/server/_astro-internal_middleware.mjs +4 -0
  87. package/packages/storefront/dist/server/chunks/404_jTV5wvby.mjs +5 -0
  88. package/packages/storefront/dist/server/chunks/{CartSidebar_lUckG0fs.mjs → CartSidebar_CV9qwGNE.mjs} +2 -1
  89. package/packages/storefront/dist/server/chunks/{SearchModal_B2f22Mff.mjs → SearchModal_Cw1ECnXI.mjs} +37 -15
  90. package/packages/storefront/dist/server/chunks/_.._k1NruPDv.mjs +5 -0
  91. package/packages/storefront/dist/server/chunks/_astro-internal_middleware_DIG56BhA.mjs +40 -0
  92. package/packages/storefront/dist/server/chunks/{_page__Ex4FhYrc.mjs → _page__BKNX3RH7.mjs} +1 -1
  93. package/packages/storefront/dist/server/chunks/{account_B7sLjsXD.mjs → account_BZOa6Kmc.mjs} +1 -1
  94. package/packages/storefront/dist/server/chunks/astro/{assets-service_BOyOfKDQ.mjs → assets-service_MW85B416.mjs} +5 -2
  95. package/packages/storefront/dist/server/chunks/{astro_B5LBy7PI.mjs → astro_8KdHu_Gf.mjs} +83 -113
  96. package/packages/storefront/dist/server/chunks/{index_C2hkTn-w.mjs → index_CZ6FSUEb.mjs} +1 -1
  97. package/packages/storefront/dist/server/chunks/{index_BOh755yP.mjs → index_D1o9pXka.mjs} +1 -1
  98. package/packages/storefront/dist/server/chunks/{node_DavlI8UF.mjs → node_Khrf-0bH.mjs} +1 -1
  99. package/packages/storefront/dist/server/chunks/pages/{__RXg_hYeF.mjs → 404_BPSxJtl3.mjs} +675 -4955
  100. package/packages/storefront/dist/server/chunks/pages/__ByRpsTnC.mjs +4630 -0
  101. package/packages/storefront/dist/server/chunks/pages/{_page__Dyte93f2.mjs → _page__BasreLue.mjs} +32 -9
  102. package/packages/storefront/dist/server/chunks/pages/{account_C66y6_Y9.mjs → account_MZBvNAyZ.mjs} +2 -2
  103. package/packages/storefront/dist/server/chunks/pages/{index_EO1hhrt8.mjs → index_CV2ET14h.mjs} +24 -9
  104. package/packages/storefront/dist/server/chunks/pages/{node_hc25rqYt.mjs → node_1tKTIKG-.mjs} +145 -11
  105. package/packages/storefront/dist/server/chunks/pages/{~fallback_-K3esUV3.mjs → ~fallback_BVYzgZ5p.mjs} +2 -28
  106. package/packages/storefront/dist/server/chunks/{~fallback_DQ6yB81s.mjs → ~fallback_xH9bJF7E.mjs} +1 -1
  107. package/packages/storefront/dist/server/entry.mjs +469 -507
  108. package/packages/storefront/dist/server/manifest_S9lE9v48.mjs +206 -0
  109. package/packages/storefront/dist/server/middleware.mjs +4 -0
  110. package/packages/storefront/dist/server/renderers.mjs +39 -50
  111. package/packages/storefront/package.json +7 -7
  112. package/packages/storefront/src/decap-cms/get-cms-config.ts +0 -1
  113. package/packages/storefront/src/images/picture-base.ts +1 -1
  114. package/packages/storefront/src/lib/assets/decap-cms.css +13 -3
  115. package/packages/storefront/src/lib/components/Picture.astro +1 -1
  116. package/packages/storefront/src/lib/composables/use-product-shelf.ts +1 -1
  117. package/packages/storefront/tailwind.config.js +3 -0
  118. package/packages/storefront/uno.config.js +3 -0
  119. package/packages/test-base/package.json +1 -1
  120. package/packages/types/package.json +1 -1
  121. package/tailwind.config.js +6 -0
  122. package/ecomplus-stores/barradoce/functions/ssr/uno.config.cjs +0 -5
  123. package/ecomplus-stores/barradoce/tailwind.config.cjs +0 -7
  124. package/packages/storefront/dist/client/_astro/AccountPage.Cq0jrJE5.js +0 -1
  125. package/packages/storefront/dist/client/_astro/CartSidebar.DkX2BE1w.js +0 -1
  126. package/packages/storefront/dist/client/_astro/HeroSlider.CZujn8cU.js +0 -1
  127. package/packages/storefront/dist/client/_astro/PitchBar.DhcSEQPV.js +0 -1
  128. package/packages/storefront/dist/client/_astro/Prices.D1uItqV5.js +0 -1
  129. package/packages/storefront/dist/client/_astro/ProductDetails.DDNMc2oj.js +0 -7
  130. package/packages/storefront/dist/client/_astro/ProductShelf.BwRDTU-V.js +0 -1
  131. package/packages/storefront/dist/client/_astro/SearchModal.DgrtGsIu.js +0 -1
  132. package/packages/storefront/dist/client/_astro/SearchShowcase.DggdcmcI.js +0 -1
  133. package/packages/storefront/dist/client/_astro/ShippingCalculator.B5JIh5xw.js +0 -1
  134. package/packages/storefront/dist/client/_astro/ShopHeader.CIsQLhMR.js +0 -7
  135. package/packages/storefront/dist/client/_astro/_slug_.CnXAH2gj.css +0 -1
  136. package/packages/storefront/dist/client/_astro/client.mwowSQrH.js +0 -1
  137. package/packages/storefront/dist/client/_astro/customer-session.BAjMMoBA.js +0 -7
  138. package/packages/storefront/dist/client/_astro/hoisted.B8Lw6O9a.js +0 -1
  139. package/packages/storefront/dist/client/_astro/hoisted.D4m7OTKi.js +0 -8
  140. package/packages/storefront/dist/client/_astro/hoisted.DSAg3dYh.js +0 -1
  141. package/packages/storefront/dist/client/_astro/hoisted.D_dlmSy5.js +0 -1
  142. package/packages/storefront/dist/client/_astro/index.BAyyMfaO.js +0 -1
  143. package/packages/storefront/dist/client/_astro/index.CTTHpJlV.js +0 -1
  144. package/packages/storefront/dist/client/_astro/modules-info.C6KJuGeB.js +0 -1
  145. package/packages/storefront/dist/client/_astro/name.CIPngEFN.js +0 -1
  146. package/packages/storefront/dist/client/_astro/server-data.CUHTES8a.js +0 -1
  147. package/packages/storefront/dist/client/_astro/sf-utils.xmJHVMAX.js +0 -13
  148. package/packages/storefront/dist/client/_astro/shopping-cart.DGvCZWRZ.js +0 -1
  149. package/packages/storefront/dist/client/_astro/use-analytics.BWhF_fCv.js +0 -1
  150. package/packages/storefront/dist/client/_astro/use-product-card.C-RbCwna.js +0 -1
  151. package/packages/storefront/dist/server/_noop-middleware.mjs +0 -3
  152. package/packages/storefront/dist/server/chunks/_.._CvgSOb3Z.mjs +0 -5
  153. package/packages/storefront/dist/server/manifest_bZVxjk3o.mjs +0 -201
  154. package/packages/storefront/tailwind.config.cjs +0 -3
  155. package/packages/storefront/uno.config.cjs +0 -3
  156. package/tailwind.config.cjs +0 -5
@@ -0,0 +1,4630 @@
1
+ import { e as createAstro, f as createComponent, r as renderTemplate, u as unescapeHTML, l as renderComponent, n as Fragment$1, m as maybeRenderHead, h as addAttribute } from '../astro_8KdHu_Gf.mjs';
2
+ import 'kleur/colors';
3
+ import api from '@cloudcommerce/api';
4
+ import { _ as _export_sfc, u as useSharedData, a as useSectionPreview, i as i19relatedProducts, b as useStorage, c as i19brands, d as i19categories, e as i19upTo, f as i19aboveOf, s as scrollToEl, g as i19relevance, h as i19sales, j as i19lowestPrice, k as i19highestPrice, l as i19discount, m as i19releases, n as i19name, o as isScreenLg, $ as $$Picture, p as parseShippingPhrase, q as slugify, r as availableExtraDiscount, t as installmentsOption, v as discountOption, w as loyaltyPointsPrograms, x as addProductToCart, y as isMobile, z as useId, A as fetchModule, B as i19workingDays, C as i19days, D as i19untilTomorrow, E as i19pickUpToday, F as i19receiveToday, G as i19free, H as i19freeShipping, I as Drawer, J as getConfig, K as loadRouteContext, L as $$Base, M as $$BaseHead, N as $$PageHeader, O as $$PageFooter } from './404_BPSxJtl3.mjs';
5
+ import 'clsx';
6
+ import { computed, ref, watch, toRef, useSSRContext, defineComponent, mergeModels, useModel, resolveComponent, mergeProps, withCtx, createVNode, toDisplayString, createTextVNode, shallowReactive, reactive, renderSlot, resolveDynamicComponent, onMounted, withDirectives, vShow, openBlock, createBlock, Fragment, renderList, withAsyncContext, createCommentVNode, withModifiers, createSlots, inject, provide, vModelRadio } from 'vue';
7
+ import { inStock, gridTitle, formatMoney, categoriesList, name, price, img, onPromotion, imgSizes, variationsGrids, specTextValue, specValueByText } from '@ecomplus/utils';
8
+ import { useDebounceFn, useUrlSearchParams, useElementHover, createReusableTemplate } from '@vueuse/core';
9
+ import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate, ssrRenderList, ssrRenderSlot, ssrRenderVNode, ssrRenderStyle, ssrRenderClass, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseEqual } from 'vue/server-renderer';
10
+ import config from '@cloudcommerce/config';
11
+ import { Listbox, ListboxButton, ListboxOptions, ListboxOption } from '@headlessui/vue';
12
+ import { micromark } from 'micromark';
13
+
14
+ const usePagination = (props) => {
15
+ const totalPages = computed(() => {
16
+ if (props.totalPages)
17
+ return props.totalPages;
18
+ if (props.totalItems && props.pageSize) {
19
+ return Math.ceil(props.totalItems / props.pageSize);
20
+ }
21
+ return 1;
22
+ });
23
+ const pageNumber = computed(() => {
24
+ const currentPage = props.page || 1;
25
+ if (currentPage < 1)
26
+ return 1;
27
+ if (currentPage > totalPages.value)
28
+ return totalPages.value;
29
+ return currentPage;
30
+ });
31
+ const maxPages = computed(() => props.maxPages || 10);
32
+ const startPage = computed(() => {
33
+ if (totalPages.value <= maxPages.value)
34
+ return 1;
35
+ const maxPagesBeforeCurrent = Math.floor(maxPages.value / 2);
36
+ const maxPagesAfterCurrent = Math.ceil(maxPages.value / 2) - 1;
37
+ if (pageNumber.value <= maxPagesBeforeCurrent)
38
+ return 1;
39
+ if (pageNumber.value + maxPagesAfterCurrent >= totalPages.value) {
40
+ return totalPages.value - maxPages.value + 1;
41
+ }
42
+ return pageNumber.value - maxPagesBeforeCurrent;
43
+ });
44
+ const endPage = computed(() => {
45
+ if (totalPages.value <= maxPages.value)
46
+ return totalPages.value;
47
+ const maxPagesBeforeCurrent = Math.floor(maxPages.value / 2);
48
+ const maxPagesAfterCurrent = Math.ceil(maxPages.value / 2) - 1;
49
+ if (pageNumber.value <= maxPagesBeforeCurrent)
50
+ return maxPages.value;
51
+ if (pageNumber.value + maxPagesAfterCurrent >= totalPages.value) {
52
+ return totalPages.value;
53
+ }
54
+ return pageNumber.value + maxPagesAfterCurrent;
55
+ });
56
+ const pages = computed(() => {
57
+ return Array.from(Array(endPage.value + 1 - startPage.value).keys()).map((i) => startPage.value + i);
58
+ });
59
+ const baseUrl = ref("");
60
+ watch(toRef(props, "isUrlPath"), () => {
61
+ const { url } = globalThis.$storefront;
62
+ if (props.isUrlPath && !url.pathname.endsWith("/")) {
63
+ url.pathname += "/";
64
+ } else {
65
+ url.searchParams.delete("p");
66
+ }
67
+ baseUrl.value = `${url.pathname}${url.search}`;
68
+ }, {
69
+ immediate: true
70
+ });
71
+ const getPageLink = (pageN) => {
72
+ if (props.isUrlPath)
73
+ return `../${pageN}`;
74
+ return `?p=${pageN}`;
75
+ };
76
+ const pageLinks = computed(() => {
77
+ return pages.value.map((pageN) => baseUrl.value + getPageLink(pageN));
78
+ });
79
+ const prevPageLink = computed(() => {
80
+ if (pageNumber.value <= 1)
81
+ return null;
82
+ return baseUrl.value + getPageLink(pageNumber.value - 1);
83
+ });
84
+ const nextPageLink = computed(() => {
85
+ if (pageNumber.value >= totalPages.value)
86
+ return null;
87
+ return baseUrl.value + getPageLink(pageNumber.value + 1);
88
+ });
89
+ return {
90
+ totalPages,
91
+ startPage,
92
+ endPage,
93
+ pages,
94
+ pageLinks,
95
+ prevPageLink,
96
+ nextPageLink
97
+ };
98
+ };
99
+
100
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
101
+ __name: "Pagination",
102
+ props: /* @__PURE__ */ mergeModels({
103
+ totalItems: {},
104
+ totalPages: {},
105
+ page: {},
106
+ pageSize: {},
107
+ maxPages: { default: 7 },
108
+ isUrlPath: { type: Boolean, default: false }
109
+ }, {
110
+ "page": { default: 1 },
111
+ "pageModifiers": {}
112
+ }),
113
+ emits: ["update:page"],
114
+ setup(__props, { expose: __expose }) {
115
+ __expose();
116
+ const props = __props;
117
+ const page = useModel(__props, "page");
118
+ const {
119
+ pages,
120
+ pageLinks,
121
+ prevPageLink,
122
+ nextPageLink
123
+ } = usePagination(props);
124
+ const __returned__ = { props, page, pages, pageLinks, prevPageLink, nextPageLink };
125
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
126
+ return __returned__;
127
+ }
128
+ });
129
+ function _sfc_ssrRender$n(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
130
+ const _component_ALink = resolveComponent("ALink");
131
+ _push(`<ol${ssrRenderAttrs(mergeProps({ class: "text-base-900 flex justify-center gap-1.5 text-center text-sm font-medium leading-9" }, _attrs))}><li>`);
132
+ _push(ssrRenderComponent(_component_ALink, {
133
+ href: $setup.prevPageLink,
134
+ onClick: ($event) => $setup.prevPageLink && ($setup.page = $setup.page - 1),
135
+ class: ["mr-1 block min-w-9 rounded border px-3", $setup.prevPageLink ? "border-base-100 hover:bg-base-100" : "border-transparent text-base-500"]
136
+ }, {
137
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
138
+ if (_push2) {
139
+ _push2(`<i class="i-arrow-right rotate-180"${_scopeId}></i><span class="ml-1.5 hidden md:inline"${_scopeId}>${ssrInterpolate("Anterior")}</span>`);
140
+ } else {
141
+ return [
142
+ createVNode("i", { class: "i-arrow-right rotate-180" }),
143
+ createVNode("span", { class: "ml-1.5 hidden md:inline" }, toDisplayString("Anterior"))
144
+ ];
145
+ }
146
+ }),
147
+ _: 1
148
+ }, _parent));
149
+ _push(`</li><!--[-->`);
150
+ ssrRenderList($setup.pages, (pageN, i) => {
151
+ _push(`<li>`);
152
+ _push(ssrRenderComponent(_component_ALink, {
153
+ href: pageN !== $setup.page ? $setup.pageLinks[i] : null,
154
+ onClick: ($event) => $setup.page = pageN,
155
+ class: ["block w-9 rounded border ring-black/10", pageN === $setup.page ? "bg-base-50 border-base-100 ring text-base-700" : "border-transparent hover:bg-base-100"]
156
+ }, {
157
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
158
+ if (_push2) {
159
+ _push2(`${ssrInterpolate(pageN)}`);
160
+ } else {
161
+ return [
162
+ createTextVNode(toDisplayString(pageN), 1)
163
+ ];
164
+ }
165
+ }),
166
+ _: 2
167
+ }, _parent));
168
+ _push(`</li>`);
169
+ });
170
+ _push(`<!--]--><li>`);
171
+ _push(ssrRenderComponent(_component_ALink, {
172
+ href: $setup.nextPageLink,
173
+ onClick: ($event) => $setup.nextPageLink && ($setup.page = $setup.page + 1),
174
+ class: ["ml-1 block min-w-9 rounded border px-3", $setup.nextPageLink ? "border-base-100 hover:bg-base-100" : "border-transparent text-base-500"]
175
+ }, {
176
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
177
+ if (_push2) {
178
+ _push2(`<span class="mr-1.5 hidden md:inline"${_scopeId}>${ssrInterpolate("Pr\xF3ximo")}</span><i class="i-arrow-right"${_scopeId}></i>`);
179
+ } else {
180
+ return [
181
+ createVNode("span", { class: "mr-1.5 hidden md:inline" }, toDisplayString("Pr\xF3ximo")),
182
+ createVNode("i", { class: "i-arrow-right" })
183
+ ];
184
+ }
185
+ }),
186
+ _: 1
187
+ }, _parent));
188
+ _push(`</li></ol>`);
189
+ }
190
+ const _sfc_setup$n = _sfc_main$n.setup;
191
+ _sfc_main$n.setup = (props, ctx) => {
192
+ const ssrContext = useSSRContext();
193
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Pagination.vue");
194
+ return _sfc_setup$n ? _sfc_setup$n(props, ctx) : void 0;
195
+ };
196
+ const Pagination = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["ssrRender", _sfc_ssrRender$n]]);
197
+
198
+ var __freeze = Object.freeze;
199
+ var __defProp = Object.defineProperty;
200
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
201
+ var _a;
202
+ const $$Astro$6 = createAstro("https://demo.ecomplus.app");
203
+ const $$SharedData = createComponent(async ($$result, $$props, $$slots) => {
204
+ const Astro2 = $$result.createAstro($$Astro$6, $$props, $$slots);
205
+ Astro2.self = $$SharedData;
206
+ const { getInlineClientJS } = await useSharedData(Astro2.props);
207
+ return renderTemplate(_a || (_a = __template(["<script async>", "<\/script>"])), unescapeHTML(getInlineClientJS()));
208
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/components/SharedData.astro", void 0);
209
+
210
+ const useProductShelf = (props) => {
211
+ const title = ref(props.title || "");
212
+ const titleLink = ref(props.titleLink || "");
213
+ const isFetching = ref(false);
214
+ let fetching = null;
215
+ const fetchError = ref(null);
216
+ const products = shallowReactive(props.products || []);
217
+ useSectionPreview(props, { title, titleLink, products });
218
+ if (!props.products) {
219
+ isFetching.value = true;
220
+ fetching = (async () => {
221
+ const limit = props.limit || 12;
222
+ const offset = props.page ? (props.page - 1) * limit : 0;
223
+ let endpointQuery = `offset=${offset}&limit=${limit}`;
224
+ if (props.sort) {
225
+ endpointQuery += `&sort=${props.sort}`;
226
+ }
227
+ if (props.isRelatedProducts) {
228
+ const { apiContext } = globalThis.$storefront;
229
+ if (apiContext?.resource === "products") {
230
+ endpointQuery += `&like=${apiContext.doc._id}`;
231
+ if (!title.value && title.value !== null) {
232
+ title.value = i19relatedProducts;
233
+ }
234
+ }
235
+ } else {
236
+ let searchQuery = props.searchQuery || "";
237
+ let collection;
238
+ let productIds;
239
+ if (props.collectionId) {
240
+ try {
241
+ const { data } = await api.get(`collections/${props.collectionId}`);
242
+ collection = data;
243
+ } catch (err) {
244
+ console.error(err);
245
+ fetchError.value = err;
246
+ }
247
+ productIds = collection?.products;
248
+ if (!title.value && title.value !== null && collection?.name) {
249
+ title.value = collection?.name;
250
+ }
251
+ } else if (!searchQuery && props.orderedProductIds) {
252
+ productIds = props.orderedProductIds;
253
+ }
254
+ if (productIds?.length) {
255
+ searchQuery += `&_id=${productIds.slice(0, 60).join(",")}`;
256
+ }
257
+ endpointQuery += searchQuery;
258
+ }
259
+ try {
260
+ const { data } = await api.get(`search/v1?${endpointQuery}`);
261
+ if (props.isShuffle) {
262
+ let m = data.result.filter((item) => {
263
+ return item.available && inStock(item);
264
+ }).length;
265
+ let t;
266
+ let i;
267
+ while (m) {
268
+ i = Math.floor(Math.random() * m--);
269
+ t = data.result[m];
270
+ data.result[m] = data.result[i];
271
+ data.result[i] = t;
272
+ }
273
+ }
274
+ const { orderedProductIds } = props;
275
+ if (orderedProductIds) {
276
+ data.result.sort((a, b) => {
277
+ if (b.available && inStock(b)) {
278
+ if (!a.available || !inStock(a))
279
+ return 1;
280
+ const indexA = orderedProductIds.indexOf(a._id);
281
+ const indexB = orderedProductIds.indexOf(b._id);
282
+ if (indexA === -1 && indexB > -1)
283
+ return 1;
284
+ if (indexB === -1 && indexA > -1)
285
+ return -1;
286
+ return indexA - indexB;
287
+ }
288
+ if (a.available && inStock(a))
289
+ return -1;
290
+ return 0;
291
+ });
292
+ }
293
+ data.result.forEach((item) => products.push(item));
294
+ } catch (err) {
295
+ console.error(err);
296
+ fetchError.value = err;
297
+ }
298
+ isFetching.value = false;
299
+ })();
300
+ }
301
+ return {
302
+ title,
303
+ titleLink,
304
+ isFetching,
305
+ fetching,
306
+ fetchError,
307
+ products
308
+ };
309
+ };
310
+
311
+ const storageKey = "ecomSeachHistory";
312
+ const searchHistory = useStorage(storageKey, []);
313
+ for (let i = 0; i < searchHistory.length; i++) {
314
+ if (typeof searchHistory[i] !== "string") {
315
+ searchHistory.splice(i, 1);
316
+ i -= 1;
317
+ }
318
+ }
319
+ const search = async ({
320
+ term,
321
+ params,
322
+ fields,
323
+ url = "search/v1"
324
+ }) => {
325
+ if (typeof term === "string") {
326
+ term = term.trim();
327
+ if (term.length < 2) {
328
+ return { data: { result: [], meta: null } };
329
+ }
330
+ }
331
+ const response = await api.get(url, {
332
+ fields,
333
+ params: !term ? params : {
334
+ ...params,
335
+ term
336
+ }
337
+ });
338
+ if (term && response.data.result.length) {
339
+ const termStr = term;
340
+ const completeTermIndex = searchHistory.findIndex((_term) => {
341
+ return _term.includes(termStr) && !_term.replace(termStr, "").includes(" ");
342
+ });
343
+ if (completeTermIndex > -1) {
344
+ const completeTerm = searchHistory[completeTermIndex];
345
+ searchHistory.splice(completeTermIndex, 1);
346
+ searchHistory.unshift(completeTerm);
347
+ } else {
348
+ const termIndex = searchHistory.findIndex((_term) => termStr.startsWith(_term));
349
+ if (termIndex > -1) {
350
+ searchHistory.splice(termIndex, 1);
351
+ }
352
+ searchHistory.unshift(term);
353
+ }
354
+ while (searchHistory.length > 20) {
355
+ searchHistory.pop();
356
+ }
357
+ }
358
+ return response;
359
+ };
360
+ class SearchEngine {
361
+ fields;
362
+ term = ref(null);
363
+ isWithCount = ref(true);
364
+ isWithBuckets = ref(true);
365
+ params = reactive({});
366
+ pageSize = ref(24);
367
+ pageNumber = ref(1);
368
+ #middlewares = [];
369
+ #isFetching = ref(false);
370
+ isFetching = computed(() => this.#isFetching.value);
371
+ #wasFetched = ref(false);
372
+ wasFetched = computed(() => this.#wasFetched.value);
373
+ #fetching = ref(null);
374
+ #fulfillFetching;
375
+ fetching = computed(() => this.#fetching.value);
376
+ #fetchError = ref(null);
377
+ fetchError = computed(() => this.#fetchError.value);
378
+ products = shallowReactive([]);
379
+ meta = shallowReactive({
380
+ offset: 0,
381
+ limit: 0,
382
+ fields: [],
383
+ sort: [],
384
+ query: {}
385
+ });
386
+ #search;
387
+ constructor({
388
+ fields,
389
+ debounce = 150
390
+ } = {}) {
391
+ this.fields = fields;
392
+ this.#search = useDebounceFn((opts) => {
393
+ this.#isFetching.value = true;
394
+ return search(opts);
395
+ }, debounce);
396
+ watch([this.term, this.params, this.pageSize], () => {
397
+ if (this.wasFetched.value) {
398
+ this.pageNumber.value = 1;
399
+ this.#wasFetched.value = false;
400
+ }
401
+ });
402
+ watch(this.pageNumber, () => {
403
+ this.#wasFetched.value = false;
404
+ });
405
+ }
406
+ async fetch(term) {
407
+ if (term !== void 0 && term !== this.term.value) {
408
+ this.term.value = term;
409
+ this.pageNumber.value = 1;
410
+ }
411
+ const limit = this.pageSize.value;
412
+ const offset = limit * (this.pageNumber.value - 1);
413
+ if (!this.#fetching.value) {
414
+ this.#fetching.value = new Promise((resolve) => {
415
+ this.#fulfillFetching = resolve;
416
+ });
417
+ }
418
+ let response;
419
+ const searchOptions = {
420
+ term: this.term.value,
421
+ params: {
422
+ ...this.params,
423
+ limit,
424
+ offset,
425
+ count: this.isWithCount.value || void 0,
426
+ buckets: this.isWithBuckets.value || void 0
427
+ },
428
+ fields: this.fields
429
+ };
430
+ try {
431
+ for (let i = 0; i < this.#middlewares.length; i++) {
432
+ this.#middlewares[i](searchOptions);
433
+ }
434
+ response = await this.#search(searchOptions);
435
+ } catch (err) {
436
+ if (this.#fulfillFetching) {
437
+ this.#fetchError.value = err;
438
+ this.#fulfillFetching();
439
+ }
440
+ throw err;
441
+ }
442
+ if (response) {
443
+ this.#isFetching.value = false;
444
+ this.#wasFetched.value = true;
445
+ const { data } = response;
446
+ if (data.meta) {
447
+ this.setResult(data);
448
+ }
449
+ if (this.#fulfillFetching) {
450
+ this.#fulfillFetching();
451
+ }
452
+ }
453
+ }
454
+ addMiddleware(cb) {
455
+ this.#middlewares.push(cb);
456
+ }
457
+ setResult(data) {
458
+ if (data.meta) {
459
+ Object.assign(this.meta, data.meta);
460
+ }
461
+ if (data.result) {
462
+ this.products.splice(0);
463
+ data.result.forEach((item) => this.products.push(item));
464
+ }
465
+ if (data.meta && data.result) {
466
+ setTimeout(() => {
467
+ this.#wasFetched.value = true;
468
+ }, 9);
469
+ }
470
+ }
471
+ }
472
+
473
+ const useSearchActiveFilters = ({ searchEngine, fixedParams }) => {
474
+ const activeFilters = computed(() => {
475
+ const filters = {};
476
+ Object.keys(searchEngine.params).forEach((param) => {
477
+ if (fixedParams?.[param])
478
+ return;
479
+ const val = searchEngine.params[param];
480
+ if (val === void 0)
481
+ return;
482
+ switch (param) {
483
+ case "sort":
484
+ case "term":
485
+ case "limit":
486
+ case "offset":
487
+ case "count":
488
+ case "buckets":
489
+ case "fields":
490
+ return;
491
+ }
492
+ filters[param] = val;
493
+ });
494
+ return filters;
495
+ });
496
+ const filtersCount = computed(() => {
497
+ const paramKeys = Object.keys(activeFilters.value);
498
+ const fields = [];
499
+ paramKeys.forEach((key) => {
500
+ const field = key.replace(/[^\w.]/g, "");
501
+ if (field === "specs" && Array.isArray(activeFilters.value[key])) {
502
+ activeFilters.value[key].forEach((specAndVal) => {
503
+ const [spec] = specAndVal.split(":");
504
+ const specField = `specs.${spec}`;
505
+ if (!fields.includes(specField)) {
506
+ fields.push(specField);
507
+ }
508
+ });
509
+ return;
510
+ }
511
+ if (!fields.includes(field)) {
512
+ fields.push(field);
513
+ }
514
+ });
515
+ return fields.length;
516
+ });
517
+ return { activeFilters, filtersCount };
518
+ };
519
+ const useSearchFilters = (props) => {
520
+ const { searchEngine, fixedParams } = props;
521
+ const resultMeta = computed(() => searchEngine.meta);
522
+ const resultBuckets = computed(() => searchEngine.meta.buckets);
523
+ const { activeFilters, filtersCount } = useSearchActiveFilters(props);
524
+ watch(searchEngine.params, () => {
525
+ searchEngine.fetch();
526
+ });
527
+ let _lastParamChanged = null;
528
+ const clearFilters = () => {
529
+ Object.keys(searchEngine.params).forEach((param) => {
530
+ if (fixedParams?.[param])
531
+ return;
532
+ delete searchEngine.params[param];
533
+ });
534
+ _lastParamChanged = null;
535
+ };
536
+ const getPriceRangeKey = ({ min, max }) => {
537
+ return `${min || null}/${max || null}`;
538
+ };
539
+ const currentPriceRange = computed(() => {
540
+ const { params } = searchEngine;
541
+ return {
542
+ min: Number(params["price>"]),
543
+ max: Number(params["price<"])
544
+ };
545
+ });
546
+ const priceRanges = ref([]);
547
+ const _updatePriceRanges = useDebounceFn(() => {
548
+ priceRanges.value.splice(0);
549
+ resultBuckets.value?.prices?.forEach((priceRange) => {
550
+ if (priceRange.min)
551
+ priceRange.min = Math.round(priceRange.min * 100) / 100;
552
+ if (priceRange.max)
553
+ priceRange.max = Math.round(priceRange.max * 100) / 100;
554
+ priceRanges.value.push({
555
+ range: priceRange,
556
+ key: getPriceRangeKey(priceRange)
557
+ });
558
+ });
559
+ if (!Number.isNaN(currentPriceRange.value.min)) {
560
+ const checkedPriceRange = priceRanges.value.find(({ range }) => {
561
+ return range.min === currentPriceRange.value.min && range.max === currentPriceRange.value.max;
562
+ });
563
+ if (!checkedPriceRange) {
564
+ priceRanges.value.unshift({
565
+ range: {
566
+ ...currentPriceRange.value,
567
+ count: resultMeta.value.count || 0,
568
+ avg: null
569
+ },
570
+ key: getPriceRangeKey(currentPriceRange.value)
571
+ });
572
+ }
573
+ }
574
+ }, 50);
575
+ _updatePriceRanges();
576
+ const priceRangeKey = ref(getPriceRangeKey(currentPriceRange.value));
577
+ watch(priceRangeKey, () => {
578
+ _lastParamChanged = "price";
579
+ const priceRange = priceRanges.value.find(({ range }) => {
580
+ return getPriceRangeKey(range) === priceRangeKey.value;
581
+ });
582
+ if (priceRange) {
583
+ const { min, max } = priceRange.range;
584
+ if (min) {
585
+ searchEngine.params["price>"] = min;
586
+ } else {
587
+ delete searchEngine.params["price>"];
588
+ }
589
+ if (max) {
590
+ searchEngine.params["price<"] = max;
591
+ } else {
592
+ delete searchEngine.params["price<"];
593
+ }
594
+ return;
595
+ }
596
+ delete searchEngine.params["price>"];
597
+ delete searchEngine.params["price<"];
598
+ });
599
+ const getPriceRangeLabel = ({ min, max }) => {
600
+ if (min && max) {
601
+ if (max === min) {
602
+ return formatMoney(max);
603
+ }
604
+ return `${formatMoney(min)} ${i19upTo.toLowerCase()} ${formatMoney(max)}`;
605
+ }
606
+ if (!min && max) {
607
+ return `${i19upTo} ${formatMoney(max)}`;
608
+ }
609
+ return `${i19aboveOf} ${formatMoney(min || 0)}`;
610
+ };
611
+ const filterOptions = ref([]);
612
+ const _updateFilterOptions = useDebounceFn(() => {
613
+ for (let i = 0; i < filterOptions.value.length; i++) {
614
+ const { field } = filterOptions.value[i];
615
+ if (field !== _lastParamChanged) {
616
+ filterOptions.value.splice(i, 1);
617
+ i -= 1;
618
+ }
619
+ }
620
+ const buckets = resultBuckets.value;
621
+ if (buckets) {
622
+ [["brands", i19brands], ["categories", i19categories]].forEach(([resource, title]) => {
623
+ const field = `${resource}.name`;
624
+ if (buckets[field] && _lastParamChanged !== field) {
625
+ filterOptions.value.push({
626
+ title,
627
+ options: buckets[field],
628
+ field
629
+ });
630
+ }
631
+ });
632
+ if (buckets.specs) {
633
+ const { grids } = globalThis.$storefront.data;
634
+ Object.keys(buckets.specs).forEach((specAndVal) => {
635
+ const [spec, value] = specAndVal.split(":");
636
+ if (value) {
637
+ const field = `specs.${spec}`;
638
+ if (_lastParamChanged === field)
639
+ return;
640
+ const title = gridTitle(spec, grids || []);
641
+ let filterOption = filterOptions.value.find((_filterOption) => {
642
+ return _filterOption.field === field;
643
+ });
644
+ if (!filterOption) {
645
+ filterOption = { title, options: {}, field };
646
+ filterOptions.value.push(filterOption);
647
+ }
648
+ filterOption.options[value] = buckets.specs[specAndVal];
649
+ }
650
+ });
651
+ }
652
+ }
653
+ }, 50);
654
+ _updateFilterOptions();
655
+ const parseSpecsField = (field, value) => {
656
+ const [, spec] = field.split(".");
657
+ return ["specs,", `${spec}:${value}`];
658
+ };
659
+ const checkFilterOption = (field, value) => {
660
+ if (field.startsWith("specs.")) {
661
+ [field, value] = parseSpecsField(field, value);
662
+ }
663
+ const fieldParams = activeFilters.value[field];
664
+ if (fieldParams === value)
665
+ return true;
666
+ if (Array.isArray(fieldParams) && fieldParams.includes(value))
667
+ return true;
668
+ return false;
669
+ };
670
+ const toggleFilterOption = (field, value) => {
671
+ _lastParamChanged = field;
672
+ console.log({ _lastParamChanged });
673
+ if (field.startsWith("specs.")) {
674
+ [field, value] = parseSpecsField(field, value);
675
+ }
676
+ const isToActivate = !checkFilterOption(field, value);
677
+ let fieldParams = searchEngine.params[field];
678
+ if (!Array.isArray(fieldParams)) {
679
+ fieldParams = [];
680
+ searchEngine.params[field] = fieldParams;
681
+ }
682
+ if (isToActivate) {
683
+ fieldParams.push(value);
684
+ } else {
685
+ for (let i = 0; i < fieldParams.length; i++) {
686
+ if (fieldParams[i] === value) {
687
+ fieldParams.splice(i, 1);
688
+ break;
689
+ }
690
+ }
691
+ }
692
+ };
693
+ watch(resultBuckets, () => {
694
+ if (_lastParamChanged !== "price") {
695
+ _updatePriceRanges();
696
+ }
697
+ _updateFilterOptions();
698
+ });
699
+ return {
700
+ resultMeta,
701
+ resultBuckets,
702
+ activeFilters,
703
+ filtersCount,
704
+ clearFilters,
705
+ getPriceRangeKey,
706
+ priceRanges,
707
+ priceRangeKey,
708
+ getPriceRangeLabel,
709
+ filterOptions,
710
+ checkFilterOption,
711
+ toggleFilterOption
712
+ };
713
+ };
714
+
715
+ const useSearchShowcase = (props) => {
716
+ let { term } = props;
717
+ const canUseUrlParams = props.canUseUrlParams !== false;
718
+ const urlParams = canUseUrlParams ? useUrlSearchParams("history") : null;
719
+ if (props.ssrError && false) {
720
+ console.error(new Error(`SSR search error: ${props.ssrError}`));
721
+ if (window.location.pathname.startsWith("/s/")) {
722
+ window.location.href = `/s?q=${encodeURIComponent(term || "")}`;
723
+ }
724
+ }
725
+ const products = shallowReactive(props.products || []);
726
+ const searchEngine = props.searchEngine || new SearchEngine({ debounce: 50 });
727
+ if (term === void 0 && false) {
728
+ term = new URLSearchParams(window.location.search).get("q") || null;
729
+ }
730
+ if (term !== void 0) {
731
+ searchEngine.term.value = term;
732
+ }
733
+ if (props.pageSize) {
734
+ searchEngine.pageSize.value = props.pageSize;
735
+ }
736
+ Object.assign(searchEngine.params, props.fixedParams);
737
+ let hasChangedInitParams = false;
738
+ if (urlParams) {
739
+ Object.keys(urlParams).forEach((param) => {
740
+ if (!urlParams[param])
741
+ return;
742
+ if (param.startsWith("f\\")) {
743
+ const field = param.substring(2);
744
+ searchEngine.params[field] = urlParams[param];
745
+ if (props.fixedParams?.[field] !== urlParams[param]) {
746
+ hasChangedInitParams = true;
747
+ }
748
+ return;
749
+ }
750
+ if (param === "sort") {
751
+ searchEngine.params.sort = urlParams.sort;
752
+ if (typeof urlParams.sort === "string" && props.resultMeta?.sort?.length === 1) {
753
+ const { field, order } = props.resultMeta.sort[0];
754
+ const fetchedSort = order ? field : `-${field}`;
755
+ if (fetchedSort === urlParams.sort)
756
+ return;
757
+ }
758
+ hasChangedInitParams = true;
759
+ return;
760
+ }
761
+ if (param === "p") {
762
+ const pageNumber = parseInt(String(urlParams.p), 10);
763
+ if (pageNumber >= 1) {
764
+ searchEngine.pageNumber.value = pageNumber;
765
+ if (props.resultMeta?.limit) {
766
+ const { offset, limit } = props.resultMeta;
767
+ const fetchedPage = offset ? Math.ceil(offset / limit) : 1;
768
+ if (fetchedPage === pageNumber)
769
+ return;
770
+ }
771
+ hasChangedInitParams = true;
772
+ }
773
+ }
774
+ });
775
+ }
776
+ if (!searchEngine.wasFetched.value) {
777
+ if ((props.products || props.resultMeta) && !hasChangedInitParams) {
778
+ searchEngine.setResult({
779
+ result: props.products,
780
+ meta: props.resultMeta
781
+ });
782
+ }
783
+ if (!props.products || hasChangedInitParams) {
784
+ searchEngine.fetch().catch(console.error);
785
+ }
786
+ }
787
+ searchEngine.isWithCount.value = true;
788
+ searchEngine.isWithBuckets.value = true;
789
+ const resultMeta = ref({
790
+ count: 0,
791
+ ...props.resultMeta || searchEngine.meta
792
+ });
793
+ watch(searchEngine.products, () => {
794
+ products.splice(0);
795
+ searchEngine.products.forEach((item) => products.push(item));
796
+ resultMeta.value = {
797
+ count: 0,
798
+ ...searchEngine.meta
799
+ };
800
+ });
801
+ const totalPages = computed(() => {
802
+ const { count } = searchEngine.meta;
803
+ if (!count || products.length < 2)
804
+ return 1;
805
+ return Math.ceil(count / searchEngine.pageSize.value);
806
+ });
807
+ watch(searchEngine.pageNumber, (pageNumber) => {
808
+ if (urlParams) {
809
+ urlParams.p = `${pageNumber}`;
810
+ }
811
+ searchEngine.fetch();
812
+ });
813
+ const startWatchingFetch = () => {
814
+ watch(searchEngine.isFetching, (isFetching) => {
815
+ const el = props.showcase?.value;
816
+ if (!isFetching && el) {
817
+ setTimeout(() => {
818
+ scrollToEl(el, isScreenLg ? -25 : 0);
819
+ }, 50);
820
+ }
821
+ });
822
+ };
823
+ if (searchEngine.wasFetched.value) {
824
+ startWatchingFetch();
825
+ } else {
826
+ watch(searchEngine.wasFetched, startWatchingFetch, { once: true });
827
+ }
828
+ const { activeFilters, filtersCount } = useSearchActiveFilters({
829
+ searchEngine,
830
+ fixedParams: props.fixedParams
831
+ });
832
+ if (urlParams) {
833
+ watch(activeFilters, (params) => {
834
+ if (urlParams) {
835
+ Object.keys(urlParams).forEach((param) => {
836
+ if (param.startsWith("f\\"))
837
+ delete urlParams[param];
838
+ });
839
+ }
840
+ Object.keys(params).forEach((param) => {
841
+ const val = params[param];
842
+ if (typeof val === "string" || typeof val === "number") {
843
+ urlParams[`f\\${param}`] = `${val}`;
844
+ return;
845
+ }
846
+ if (Array.isArray(val) && typeof val[0] === "string") {
847
+ urlParams[`f\\${param}`] = val;
848
+ }
849
+ });
850
+ });
851
+ }
852
+ const sortOptions = [
853
+ {
854
+ value: null,
855
+ label: i19relevance
856
+ },
857
+ {
858
+ value: "-sales",
859
+ label: i19sales
860
+ },
861
+ {
862
+ value: "price",
863
+ label: i19lowestPrice
864
+ },
865
+ {
866
+ value: "-price",
867
+ label: i19highestPrice
868
+ },
869
+ {
870
+ value: "-price_discount",
871
+ label: i19discount
872
+ },
873
+ {
874
+ value: "-created_at",
875
+ label: i19releases
876
+ },
877
+ {
878
+ value: "name",
879
+ label: i19name
880
+ }
881
+ ];
882
+ const sortOption = ref(null);
883
+ watch(sortOption, () => {
884
+ searchEngine.params.sort = sortOption.value || void 0;
885
+ searchEngine.fetch();
886
+ });
887
+ if (urlParams) {
888
+ if (typeof urlParams.sort === "string" && urlParams.sort) {
889
+ sortOption.value = urlParams.sort;
890
+ }
891
+ watch(searchEngine.params, (params) => {
892
+ delete urlParams.sort;
893
+ if (params.sort)
894
+ urlParams.sort = String(params.sort);
895
+ });
896
+ }
897
+ return {
898
+ searchEngine,
899
+ fetching: searchEngine.fetching.value,
900
+ isFetching: searchEngine.isFetching,
901
+ products,
902
+ resultMeta,
903
+ totalPages,
904
+ activeFilters,
905
+ filtersCount,
906
+ sortOptions,
907
+ sortOption
908
+ };
909
+ };
910
+
911
+ const now = Date.now();
912
+ const parseBanners = (banners) => {
913
+ const validBanners = [];
914
+ banners.forEach(({
915
+ startsAt,
916
+ endsAt,
917
+ ...bannerProps
918
+ }) => {
919
+ if (startsAt && new Date(startsAt).getTime() < now)
920
+ return;
921
+ if (endsAt && new Date(endsAt).getTime() > now)
922
+ return;
923
+ validBanners.push(bannerProps);
924
+ });
925
+ return validBanners;
926
+ };
927
+ const usePageHero = async ({ routeContext }) => {
928
+ const { cmsContent } = routeContext;
929
+ const heroSlider = { slides: [] };
930
+ const heroContent = cmsContent?.hero;
931
+ if (heroContent) {
932
+ heroSlider.autoplay = heroContent.autoplay;
933
+ if (heroContent.slides) {
934
+ heroSlider.slides = parseBanners(heroContent.slides);
935
+ }
936
+ }
937
+ return { heroSlider };
938
+ };
939
+ const usePageSections = async ({ routeContext, handleCustomSection, searchEngine }) => {
940
+ const { cmsContent } = routeContext;
941
+ let sectionsContent = cmsContent?.sections;
942
+ if (cmsContent?.markdown && !sectionsContent?.find(({ type }) => type === "content-entry")) {
943
+ if (!sectionsContent)
944
+ sectionsContent = [];
945
+ sectionsContent.push({ type: "content-entry" });
946
+ }
947
+ const sections = [];
948
+ if (sectionsContent) {
949
+ await Promise.all(sectionsContent.map(async ({ type, ...sectionContent }, index) => {
950
+ if (type === "product-shelf" || type === "related-products") {
951
+ const {
952
+ collectionIdAndInfo,
953
+ isHeadless,
954
+ isShuffle,
955
+ ...rest
956
+ } = sectionContent;
957
+ let { sort, title } = sectionContent;
958
+ switch (sort) {
959
+ case "offers":
960
+ sort = "-price_discount";
961
+ break;
962
+ case "news":
963
+ sort = "-_id";
964
+ break;
965
+ case "lowest_price":
966
+ sort = "price";
967
+ break;
968
+ case "highest_price":
969
+ sort = "-price";
970
+ break;
971
+ }
972
+ let collectionId = null;
973
+ let searchQuery;
974
+ let titleLink = sectionContent.titleLink;
975
+ if (collectionIdAndInfo) {
976
+ const [_id, resource, name, path] = collectionIdAndInfo.split(":");
977
+ if (!resource || resource === "collection") {
978
+ collectionId = _id;
979
+ } else if (resource === "categories") {
980
+ searchQuery = `&categories._id=${_id}`;
981
+ } else if (resource === "brands") {
982
+ searchQuery = `&brands._id=${_id}`;
983
+ }
984
+ if (!title && title !== null && name)
985
+ title = name;
986
+ if (!titleLink)
987
+ titleLink = path;
988
+ }
989
+ const props = {
990
+ ...rest,
991
+ collectionId,
992
+ searchQuery,
993
+ sort,
994
+ title: isHeadless ? null : title,
995
+ titleLink,
996
+ isShuffle,
997
+ isRelatedProducts: type === "related-products"
998
+ };
999
+ const {
1000
+ fetching,
1001
+ products,
1002
+ title: { value: finalTitle },
1003
+ titleLink: { value: finalTitleLink }
1004
+ } = useProductShelf(props);
1005
+ await fetching;
1006
+ sections[index] = {
1007
+ type,
1008
+ props: {
1009
+ ...props,
1010
+ title: finalTitle,
1011
+ titleLink: finalTitleLink,
1012
+ products
1013
+ }
1014
+ };
1015
+ return;
1016
+ }
1017
+ if (type === "search-showcase" || type === "context-showcase") {
1018
+ const props = { ...sectionContent };
1019
+ if (type === "context-showcase") {
1020
+ if (routeContext.fetchingApiContext) {
1021
+ await routeContext.fetchingApiContext;
1022
+ }
1023
+ const { resource, doc } = routeContext.apiContext;
1024
+ if (resource === "categories" || resource === "brands") {
1025
+ const params = { [`${resource}.name`]: [doc.name] };
1026
+ if (resource === "categories") {
1027
+ const { value: categories } = await useSharedData({ field: "categories" });
1028
+ categories?.forEach(({ name, parent }) => {
1029
+ if (name && parent && (parent._id === doc._id || parent.slug === doc.slug)) {
1030
+ params[`categories.name`].push(name);
1031
+ }
1032
+ });
1033
+ }
1034
+ props.fixedParams = params;
1035
+ } else if (resource === "collections") {
1036
+ const { products } = doc;
1037
+ if (products?.length) {
1038
+ props.fixedParams = { _id: products };
1039
+ }
1040
+ }
1041
+ } else if (routeContext.searchPageTerm !== void 0) {
1042
+ props.term = routeContext.searchPageTerm || null;
1043
+ }
1044
+ if (props.term !== void 0 || props.fixedParams) {
1045
+ const {
1046
+ searchEngine: resultSearchEngine,
1047
+ fetching
1048
+ } = useSearchShowcase({ ...props, searchEngine });
1049
+ await fetching;
1050
+ props.products = resultSearchEngine.products;
1051
+ props.resultMeta = resultSearchEngine.meta;
1052
+ props.ssrError = resultSearchEngine.fetchError.value?.message;
1053
+ }
1054
+ sections[index] = { type, props };
1055
+ return;
1056
+ }
1057
+ switch (type) {
1058
+ case "banners-grid":
1059
+ sections[index] = {
1060
+ type,
1061
+ props: {
1062
+ banners: parseBanners(sectionContent.banners || [])
1063
+ }
1064
+ };
1065
+ return;
1066
+ case "custom-html":
1067
+ sections[index] = {
1068
+ type,
1069
+ props: { html: sectionContent.html || "" }
1070
+ };
1071
+ return;
1072
+ case "content-entry":
1073
+ sections[index] = {
1074
+ type,
1075
+ props: {
1076
+ title: sectionContent.title || cmsContent?.title || "",
1077
+ markdown: sectionContent.markdown || cmsContent?.markdown || ""
1078
+ }
1079
+ };
1080
+ return;
1081
+ case "breadcrumbs":
1082
+ case "product-details":
1083
+ case "doc-description":
1084
+ case "doc-banners":
1085
+ case "product-specifications":
1086
+ case "page-title":
1087
+ sections[index] = {
1088
+ type,
1089
+ props: sectionContent
1090
+ };
1091
+ return;
1092
+ }
1093
+ if (typeof handleCustomSection === "function") {
1094
+ const { props } = await handleCustomSection(
1095
+ type,
1096
+ sectionContent
1097
+ );
1098
+ sections[index] = { type, props };
1099
+ }
1100
+ }));
1101
+ }
1102
+ return {
1103
+ sections
1104
+ };
1105
+ };
1106
+
1107
+ const $$Astro$5 = createAstro("https://demo.ecomplus.app");
1108
+ const $$BannerPictures = createComponent(async ($$result, $$props, $$slots) => {
1109
+ const Astro2 = $$result.createAstro($$Astro$5, $$props, $$slots);
1110
+ Astro2.self = $$BannerPictures;
1111
+ const {
1112
+ img,
1113
+ alt,
1114
+ mobileImg,
1115
+ title,
1116
+ subtitle,
1117
+ buttonText,
1118
+ index,
1119
+ class: className = "max-w-screen-sm sm:max-w-[828px] md:max-w-screen-2xl",
1120
+ mobileClass = "max-w-screen-sm sm:max-w-screen-lg"
1121
+ } = Astro2.props;
1122
+ const hasHeader = title || subtitle || buttonText;
1123
+ let { widths, mobileWidths } = Astro2.props;
1124
+ if (!widths?.length) {
1125
+ if (mobileImg) {
1126
+ widths = [1536, 2048];
1127
+ } else {
1128
+ widths = [640, 828, 1536, 2048];
1129
+ if (hasHeader) {
1130
+ widths = widths.map((w) => w / 2);
1131
+ }
1132
+ }
1133
+ }
1134
+ if (!mobileWidths?.length) {
1135
+ mobileWidths = [640, 1024];
1136
+ }
1137
+ return renderTemplate`${img && renderTemplate`${renderComponent($$result, "Picture", $$Picture, { "src": img, "alt": alt || "", "widths": widths, "fetchpriority": index === 0 ? "high" : "low", "loading": index === 0 ? "eager" : "lazy", "class": `${mobileImg ? "hidden md:block " : ""}mx-auto
1138
+ text-sm text-opacity-70 ${className}` })}`}
1139
+ ${mobileImg && renderTemplate`${renderComponent($$result, "Picture", $$Picture, { "src": mobileImg, "alt": alt || "", "widths": mobileWidths, "fetchpriority": index === 0 ? "high" : "low", "loading": index === 0 ? "eager" : "lazy", "class": `mx-auto text-sm text-opacity-70 md:hidden ${mobileClass}` })}`}`;
1140
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/components/BannerPictures.astro", void 0);
1141
+
1142
+ const useBanner = (props) => {
1143
+ const parsedTitle = computed(() => {
1144
+ return props.title ? parseShippingPhrase(props.title).value : "";
1145
+ });
1146
+ const parsedSubtitle = computed(() => {
1147
+ return props.subtitle ? parseShippingPhrase(props.subtitle).value : "";
1148
+ });
1149
+ const parsedButtonText = computed(() => {
1150
+ return props.buttonText ? parseShippingPhrase(props.buttonText).value : "";
1151
+ });
1152
+ const hasHeader = computed(() => {
1153
+ return Boolean(parsedTitle.value || parsedSubtitle.value || parsedButtonText.value);
1154
+ });
1155
+ return {
1156
+ parsedTitle,
1157
+ parsedSubtitle,
1158
+ parsedButtonText,
1159
+ hasHeader
1160
+ };
1161
+ };
1162
+
1163
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
1164
+ __name: "Banner",
1165
+ props: {
1166
+ img: {},
1167
+ alt: {},
1168
+ mobileImg: {},
1169
+ href: {},
1170
+ title: {},
1171
+ subtitle: {},
1172
+ buttonLink: {},
1173
+ buttonText: {},
1174
+ headingTag: { default: "h3" }
1175
+ },
1176
+ setup(__props, { expose: __expose }) {
1177
+ __expose();
1178
+ const props = __props;
1179
+ const {
1180
+ hasHeader,
1181
+ parsedTitle,
1182
+ parsedSubtitle,
1183
+ parsedButtonText
1184
+ } = useBanner(props);
1185
+ const __returned__ = { props, hasHeader, parsedTitle, parsedSubtitle, parsedButtonText };
1186
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
1187
+ return __returned__;
1188
+ }
1189
+ });
1190
+ function _sfc_ssrRender$m(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
1191
+ const _component_ALink = resolveComponent("ALink");
1192
+ _push(`<div${ssrRenderAttrs(mergeProps({
1193
+ class: ["mx-auto overflow-x-hidden", $setup.hasHeader ? "grid grid-cols-1 sm:grid-cols-2 items-center" : null]
1194
+ }, _attrs))}>`);
1195
+ _push(ssrRenderComponent(_component_ALink, {
1196
+ href: $props.href,
1197
+ prefetch: "visible",
1198
+ class: $setup.hasHeader ? "sm:order-last [&_img]:max-w-full sm:[&_img]:max-w-none [&_img]:aspect-video sm:[&_img]:aspect-[2.5] [&_img]:object-cover" : "[&_img]:max-w-full"
1199
+ }, {
1200
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1201
+ if (_push2) {
1202
+ ssrRenderSlot(_ctx.$slots, "picture", {}, null, _push2, _parent2, _scopeId);
1203
+ } else {
1204
+ return [
1205
+ renderSlot(_ctx.$slots, "picture")
1206
+ ];
1207
+ }
1208
+ }),
1209
+ _: 3
1210
+ }, _parent));
1211
+ if ($setup.hasHeader) {
1212
+ _push(`<div class="mb-3 p-12 sm:mb-0 xl:ps-32">`);
1213
+ if ($setup.parsedTitle) {
1214
+ ssrRenderVNode(_push, createVNode(resolveDynamicComponent($props.headingTag), { class: "mt-1 ui-title" }, {
1215
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1216
+ if (_push2) {
1217
+ _push2(`${ssrInterpolate($setup.parsedTitle)}`);
1218
+ } else {
1219
+ return [
1220
+ createTextVNode(toDisplayString($setup.parsedTitle), 1)
1221
+ ];
1222
+ }
1223
+ }),
1224
+ _: 1
1225
+ }), _parent);
1226
+ } else {
1227
+ _push(`<!---->`);
1228
+ }
1229
+ if ($setup.parsedSubtitle) {
1230
+ _push(`<p class="mt-4 text-lg md:mt-6">${ssrInterpolate($setup.parsedSubtitle)}</p>`);
1231
+ } else {
1232
+ _push(`<!---->`);
1233
+ }
1234
+ if ($setup.parsedButtonText) {
1235
+ _push(ssrRenderComponent(_component_ALink, {
1236
+ href: $props.buttonLink,
1237
+ prefetch: $props.href ? "hover" : "visible",
1238
+ class: "mt-7 min-w-[150px] ui-btn-lg ui-btn-contrast md:mt-10"
1239
+ }, {
1240
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1241
+ if (_push2) {
1242
+ _push2(`${ssrInterpolate($setup.parsedButtonText)}`);
1243
+ } else {
1244
+ return [
1245
+ createTextVNode(toDisplayString($setup.parsedButtonText), 1)
1246
+ ];
1247
+ }
1248
+ }),
1249
+ _: 1
1250
+ }, _parent));
1251
+ } else {
1252
+ _push(`<!---->`);
1253
+ }
1254
+ _push(`</div>`);
1255
+ } else {
1256
+ _push(`<!---->`);
1257
+ }
1258
+ _push(`</div>`);
1259
+ }
1260
+ const _sfc_setup$m = _sfc_main$m.setup;
1261
+ _sfc_main$m.setup = (props, ctx) => {
1262
+ const ssrContext = useSSRContext();
1263
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Banner.vue");
1264
+ return _sfc_setup$m ? _sfc_setup$m(props, ctx) : void 0;
1265
+ };
1266
+ const Banner = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["ssrRender", _sfc_ssrRender$m]]);
1267
+
1268
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
1269
+ __name: "HeroSlider",
1270
+ props: {
1271
+ autoplay: {},
1272
+ slides: {}
1273
+ },
1274
+ setup(__props, { expose: __expose }) {
1275
+ __expose();
1276
+ const isMounted = ref(false);
1277
+ onMounted(() => {
1278
+ isMounted.value = true;
1279
+ });
1280
+ const __returned__ = { isMounted, Banner };
1281
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
1282
+ return __returned__;
1283
+ }
1284
+ });
1285
+ function _sfc_ssrRender$l(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
1286
+ const _component_Carousel = resolveComponent("Carousel");
1287
+ const _component_CarouselControl = resolveComponent("CarouselControl");
1288
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "relative mx-auto mb-9 md:mb-12" }, _attrs))}>`);
1289
+ _push(ssrRenderComponent(_component_Carousel, {
1290
+ autoplay: $props.autoplay,
1291
+ class: "secondary [&>*]:items-center"
1292
+ }, {
1293
+ controls: withCtx((_, _push2, _parent2, _scopeId) => {
1294
+ if (_push2) {
1295
+ _push2(`<div style="${ssrRenderStyle($props.slides.length > 1 ? null : { display: "none" })}" class="absolute bottom-5 right-5 z-10 flex w-screen items-center justify-end xl:left-1/2 xl:right-auto xl:-ms-[640px] xl:max-w-screen-xl"${_scopeId}><div class="${ssrRenderClass([$setup.isMounted ? "opacity-100" : "opacity-20 [&>*]:cursor-wait", "text-primary relative h-10 w-20 rounded-full bg-white/50 shadow-sm ring-1 ring-black/5 transition-opacity"])}"${_scopeId}>`);
1296
+ _push2(ssrRenderComponent(_component_CarouselControl, {
1297
+ class: "hover:bg-primary/10 size-10 rounded-full",
1298
+ "is-prev": ""
1299
+ }, {
1300
+ default: withCtx((_2, _push3, _parent3, _scopeId2) => {
1301
+ if (_push3) {
1302
+ _push3(`<i class="i-arrow-right rotate-180"${_scopeId2}></i>`);
1303
+ } else {
1304
+ return [
1305
+ createVNode("i", { class: "i-arrow-right rotate-180" })
1306
+ ];
1307
+ }
1308
+ }),
1309
+ _: 1
1310
+ }, _parent2, _scopeId));
1311
+ _push2(ssrRenderComponent(_component_CarouselControl, { class: "hover:bg-primary/10 size-10 rounded-full" }, {
1312
+ default: withCtx((_2, _push3, _parent3, _scopeId2) => {
1313
+ if (_push3) {
1314
+ _push3(`<i class="i-arrow-right"${_scopeId2}></i>`);
1315
+ } else {
1316
+ return [
1317
+ createVNode("i", { class: "i-arrow-right" })
1318
+ ];
1319
+ }
1320
+ }),
1321
+ _: 1
1322
+ }, _parent2, _scopeId));
1323
+ _push2(`</div></div>`);
1324
+ } else {
1325
+ return [
1326
+ withDirectives(createVNode("div", { class: "absolute bottom-5 right-5 z-10 flex w-screen items-center justify-end xl:left-1/2 xl:right-auto xl:-ms-[640px] xl:max-w-screen-xl" }, [
1327
+ createVNode("div", {
1328
+ class: ["text-primary relative h-10 w-20 rounded-full bg-white/50 shadow-sm ring-1 ring-black/5 transition-opacity", $setup.isMounted ? "opacity-100" : "opacity-20 [&>*]:cursor-wait"]
1329
+ }, [
1330
+ createVNode(_component_CarouselControl, {
1331
+ class: "hover:bg-primary/10 size-10 rounded-full",
1332
+ "is-prev": ""
1333
+ }, {
1334
+ default: withCtx(() => [
1335
+ createVNode("i", { class: "i-arrow-right rotate-180" })
1336
+ ]),
1337
+ _: 1
1338
+ }),
1339
+ createVNode(_component_CarouselControl, { class: "hover:bg-primary/10 size-10 rounded-full" }, {
1340
+ default: withCtx(() => [
1341
+ createVNode("i", { class: "i-arrow-right" })
1342
+ ]),
1343
+ _: 1
1344
+ })
1345
+ ], 2)
1346
+ ], 512), [
1347
+ [vShow, $props.slides.length > 1]
1348
+ ])
1349
+ ];
1350
+ }
1351
+ }),
1352
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1353
+ if (_push2) {
1354
+ _push2(`<!--[-->`);
1355
+ ssrRenderList($props.slides, (slide, i) => {
1356
+ _push2(`<li class="shrink-0 basis-full"${_scopeId}>`);
1357
+ _push2(ssrRenderComponent($setup["Banner"], mergeProps({ ...slide, headingTag: i === 0 ? "h2" : "h3" }, { class: "w-screen max-w-screen-2xl" }), {
1358
+ picture: withCtx((_2, _push3, _parent3, _scopeId2) => {
1359
+ if (_push3) {
1360
+ ssrRenderSlot(_ctx.$slots, `picture-${i}`, {}, null, _push3, _parent3, _scopeId2);
1361
+ } else {
1362
+ return [
1363
+ renderSlot(_ctx.$slots, `picture-${i}`)
1364
+ ];
1365
+ }
1366
+ }),
1367
+ _: 2
1368
+ }, _parent2, _scopeId));
1369
+ _push2(`</li>`);
1370
+ });
1371
+ _push2(`<!--]-->`);
1372
+ } else {
1373
+ return [
1374
+ (openBlock(true), createBlock(Fragment, null, renderList($props.slides, (slide, i) => {
1375
+ return openBlock(), createBlock("li", {
1376
+ key: i,
1377
+ class: "shrink-0 basis-full"
1378
+ }, [
1379
+ createVNode($setup["Banner"], mergeProps({ ...slide, headingTag: i === 0 ? "h2" : "h3" }, { class: "w-screen max-w-screen-2xl" }), {
1380
+ picture: withCtx(() => [
1381
+ renderSlot(_ctx.$slots, `picture-${i}`)
1382
+ ]),
1383
+ _: 2
1384
+ }, 1040)
1385
+ ]);
1386
+ }), 128))
1387
+ ];
1388
+ }
1389
+ }),
1390
+ _: 3
1391
+ }, _parent));
1392
+ _push(`</section>`);
1393
+ }
1394
+ const _sfc_setup$l = _sfc_main$l.setup;
1395
+ _sfc_main$l.setup = (props, ctx) => {
1396
+ const ssrContext = useSSRContext();
1397
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/HeroSlider.vue");
1398
+ return _sfc_setup$l ? _sfc_setup$l(props, ctx) : void 0;
1399
+ };
1400
+ const HeroSlider = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["ssrRender", _sfc_ssrRender$l]]);
1401
+
1402
+ const $$Astro$4 = createAstro("https://demo.ecomplus.app");
1403
+ const $$Hero = createComponent(async ($$result, $$props, $$slots) => {
1404
+ const Astro2 = $$result.createAstro($$Astro$4, $$props, $$slots);
1405
+ Astro2.self = $$Hero;
1406
+ const { routeContext } = Astro2.locals;
1407
+ const { heroSlider } = await usePageHero({ routeContext });
1408
+ const heroSlides = heroSlider.slides;
1409
+ return renderTemplate`${heroSlider.slides.length > 0 && renderTemplate`${renderComponent($$result, "Fragment", Fragment$1, {}, { "default": ($$result2) => renderTemplate`
1410
+ ${renderComponent($$result2, "HeroSlider", HeroSlider, { ...heroSlider, "client:sf": "lazy", "client:component-hydration": "sf", "client:component-path": "~/components/HeroSlider.vue", "client:component-export": "default" }, { "picture-0": ($$result3) => renderTemplate`${heroSlides[0] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-0", ...heroSlides[0], "index": 0 })}`}`, "picture-1": ($$result3) => renderTemplate`${heroSlides[1] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-1", ...heroSlides[1], "index": 1 })}`}`, "picture-2": ($$result3) => renderTemplate`${heroSlides[2] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-2", ...heroSlides[2], "index": 2 })}`}`, "picture-3": ($$result3) => renderTemplate`${heroSlides[3] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-3", ...heroSlides[3], "index": 3 })}`}`, "picture-4": ($$result3) => renderTemplate`${heroSlides[4] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-4", ...heroSlides[4], "index": 4 })}`}`, "picture-5": ($$result3) => renderTemplate`${heroSlides[5] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-5", ...heroSlides[5], "index": 5 })}`}`, "picture-6": ($$result3) => renderTemplate`${heroSlides[6] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-6", ...heroSlides[6], "index": 6 })}`}`, "picture-7": ($$result3) => renderTemplate`${heroSlides[7] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-7", ...heroSlides[7], "index": 7 })}`}`, "picture-8": ($$result3) => renderTemplate`${heroSlides[8] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-8", ...heroSlides[8], "index": 8 })}`}`, "picture-9": ($$result3) => renderTemplate`${heroSlides[9] && renderTemplate`${renderComponent($$result3, "BannerPictures", $$BannerPictures, { "slot": "picture-9", ...heroSlides[9], "index": 9 })}`}` })}
1411
+ ` })}`}`;
1412
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/main/content/Hero.astro", void 0);
1413
+
1414
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
1415
+ __name: "ContentClearfix",
1416
+ props: {
1417
+ html: {}
1418
+ },
1419
+ setup(__props, { expose: __expose }) {
1420
+ __expose();
1421
+ const { html } = __props;
1422
+ const parsedHTML = html.replace(/<(img|iframe) /g, '<$1 loading="lazy" ');
1423
+ const __returned__ = { parsedHTML };
1424
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
1425
+ return __returned__;
1426
+ }
1427
+ });
1428
+ function _sfc_ssrRender$k(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
1429
+ _push(`<article${ssrRenderAttrs(mergeProps({ class: "!max-w-full overflow-x-auto prose" }, _attrs))}><div class="[&amp;_iframe]:max-w-full [&amp;_img]:max-w-full [&amp;_table]:max-w-full">${$setup.parsedHTML}</div></article>`);
1430
+ }
1431
+ const _sfc_setup$k = _sfc_main$k.setup;
1432
+ _sfc_main$k.setup = (props, ctx) => {
1433
+ const ssrContext = useSSRContext();
1434
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/ContentClearfix.vue");
1435
+ return _sfc_setup$k ? _sfc_setup$k(props, ctx) : void 0;
1436
+ };
1437
+ const ContentClearfix = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["ssrRender", _sfc_ssrRender$k]]);
1438
+
1439
+ const $$Astro$3 = createAstro("https://demo.ecomplus.app");
1440
+ const $$BannersGrid = createComponent(async ($$result, $$props, $$slots) => {
1441
+ const Astro2 = $$result.createAstro($$Astro$3, $$props, $$slots);
1442
+ Astro2.self = $$BannersGrid;
1443
+ const { banners } = Astro2.props;
1444
+ return renderTemplate`${maybeRenderHead()}<section class="ui-section">
1445
+ <ul class="flex flex-wrap gap-4 lg:flex-nowrap">
1446
+ ${banners.map((banner) => renderTemplate`<li class="lg:flex-1 [&_img]:w-full [&_img]:object-cover">
1447
+ ${renderComponent($$result, "Banner", Banner, { ...banner }, { "picture": ($$result2) => renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { ...banner, "slot": "picture" })}` })}
1448
+ </li>`)}
1449
+ </ul>
1450
+ </section>`;
1451
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/components/BannersGrid.astro", void 0);
1452
+
1453
+ const useBreadcrumbs = async (props = {}) => {
1454
+ const { settings, apiContext, data } = globalThis.$storefront;
1455
+ const {
1456
+ apiDoc = apiContext?.doc,
1457
+ domain = settings.domain
1458
+ } = props;
1459
+ let categories = props.categories || data.categories;
1460
+ if (!categories) {
1461
+ categories = (await useSharedData({ field: "categories" })).value;
1462
+ }
1463
+ const breadcrumbs = [];
1464
+ if (apiDoc) {
1465
+ const productCategories = apiDoc.categories;
1466
+ if (productCategories) {
1467
+ categoriesList(apiDoc).forEach((categoryName) => {
1468
+ const findCategory = (category2) => {
1469
+ return category2.name === categoryName;
1470
+ };
1471
+ const category = productCategories && productCategories.find(findCategory) || categories?.find(findCategory);
1472
+ if (category) {
1473
+ breadcrumbs.push({
1474
+ name: name(category),
1475
+ link: `/${category.slug}`
1476
+ });
1477
+ }
1478
+ });
1479
+ }
1480
+ breadcrumbs.push({
1481
+ name: name(apiDoc),
1482
+ link: `/${apiDoc.slug}`
1483
+ });
1484
+ }
1485
+ return {
1486
+ breadcrumbs,
1487
+ inlineJSONLd: domain ? JSON.stringify({
1488
+ "@context": "https://schema.org",
1489
+ "@type": "BreadcrumbList",
1490
+ itemListElement: [
1491
+ {
1492
+ "@type": "ListItem",
1493
+ position: 1,
1494
+ item: {
1495
+ "@id": `https://${domain}/`,
1496
+ name: "Homepage"
1497
+ }
1498
+ }
1499
+ ].concat(breadcrumbs.map(({ name, link }, index) => {
1500
+ return {
1501
+ "@type": "ListItem",
1502
+ position: index + 2,
1503
+ item: {
1504
+ "@id": `https://${domain}${link}`,
1505
+ name
1506
+ }
1507
+ };
1508
+ }))
1509
+ }) : null
1510
+ };
1511
+ };
1512
+
1513
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
1514
+ __name: "Breadcrumbs",
1515
+ props: {
1516
+ apiDoc: {},
1517
+ categories: {},
1518
+ domain: {},
1519
+ cmsPreview: {}
1520
+ },
1521
+ async setup(__props, { expose: __expose }) {
1522
+ __expose();
1523
+ let __temp, __restore;
1524
+ const props = __props;
1525
+ const { breadcrumbs, inlineJSONLd } = ([__temp, __restore] = withAsyncContext(() => useBreadcrumbs(props)), __temp = await __temp, __restore(), __temp);
1526
+ const __returned__ = { props, breadcrumbs, inlineJSONLd };
1527
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
1528
+ return __returned__;
1529
+ }
1530
+ });
1531
+ function _sfc_ssrRender$j(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
1532
+ _push(`<!--[-->`);
1533
+ if ($setup.breadcrumbs.length > 1) {
1534
+ _push(`<section class="ui-section-slim"><nav aria-label="Breadcrumb" class="w-full overflow-hidden text-lg md:text-sm"><ol class="text-base-600 flex items-center gap-1"><li><a href="/" class="hover:text-primary"><span class="sr-only">${ssrInterpolate("In\xEDcio")}</span><i class="i-home"></i></a></li><!--[-->`);
1535
+ ssrRenderList($setup.breadcrumbs, ({ name, link }, i) => {
1536
+ _push(`<!--[-->`);
1537
+ if (i + 1 < $setup.breadcrumbs.length) {
1538
+ _push(`<!--[--><li class="text-base-300"><i class="i-chevron-right"></i></li><li class="whitespace-nowrap"><a${ssrRenderAttr("href", link)} class="hover:text-primary">${ssrInterpolate(name)}</a></li><!--]-->`);
1539
+ } else {
1540
+ _push(`<!--[--><li class="text-base-300 hidden lg:block"><i class="i-chevron-right"></i></li><li class="hidden truncate lg:block"><span class="text-base-500">${ssrInterpolate(name)}</span></li><!--]-->`);
1541
+ }
1542
+ _push(`<!--]-->`);
1543
+ });
1544
+ _push(`<!--]--></ol></nav></section>`);
1545
+ } else {
1546
+ _push(`<!---->`);
1547
+ }
1548
+ if ($setup.inlineJSONLd) {
1549
+ _push(`<script type="application/ld+json">${$setup.inlineJSONLd}<\/script>`);
1550
+ } else {
1551
+ _push(`<!---->`);
1552
+ }
1553
+ _push(`<!--]-->`);
1554
+ }
1555
+ const _sfc_setup$j = _sfc_main$j.setup;
1556
+ _sfc_main$j.setup = (props, ctx) => {
1557
+ const ssrContext = useSSRContext();
1558
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Breadcrumbs.vue");
1559
+ return _sfc_setup$j ? _sfc_setup$j(props, ctx) : void 0;
1560
+ };
1561
+ const Breadcrumbs = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["ssrRender", _sfc_ssrRender$j]]);
1562
+
1563
+ const emitGtagEvent = async (name, _params) => {
1564
+ return;
1565
+ };
1566
+ const getGtagItem = (product) => {
1567
+ const [name$1, ...variants] = name(product).split(" / ");
1568
+ const item = {
1569
+ item_name: name$1,
1570
+ item_id: product.sku,
1571
+ price: Math.round(price(product) * 100) / 100,
1572
+ // https://developers.google.com/analytics/devguides/collection/ga4/item-scoped-ecommerce#add_an_item-scoped_custom_parameter
1573
+ // @ts-ignore
1574
+ object_id: product._id
1575
+ };
1576
+ if (variants && variants.length) {
1577
+ item.item_variant = variants.join(" / ");
1578
+ } else if (product.variation_id) {
1579
+ item.item_name = name$1.replace(
1580
+ window.__customGTMVariantRegex || /\s[^\s]+$/,
1581
+ ""
1582
+ );
1583
+ item.item_variant = name$1.replace(item.item_name, "").trim();
1584
+ }
1585
+ if (product.quantity === 0 || product.quantity && product.product_id) {
1586
+ item.quantity = product.quantity;
1587
+ }
1588
+ const { brands, categories } = product;
1589
+ if (brands?.length) {
1590
+ item.item_brand = brands[0].name;
1591
+ }
1592
+ if (categories?.length) {
1593
+ for (let i = 0; i < categories.length; i++) {
1594
+ const { name: categoryName } = categories[i];
1595
+ if (i === 0) {
1596
+ item.item_category = categoryName;
1597
+ } else {
1598
+ item[`item_category${i + 1}`] = categoryName;
1599
+ if (i === 4)
1600
+ break;
1601
+ }
1602
+ }
1603
+ }
1604
+ return item;
1605
+ };
1606
+
1607
+ const useProductCard = (props) => {
1608
+ const isFetching = ref(false);
1609
+ let fetching = null;
1610
+ const fetchError = ref(null);
1611
+ const { productId } = props;
1612
+ const product = shallowReactive({
1613
+ ...props.product,
1614
+ _id: props.product?._id || productId,
1615
+ price: price(props.product || {})
1616
+ });
1617
+ if (!props.product && productId) {
1618
+ isFetching.value = true;
1619
+ fetching = (async () => {
1620
+ try {
1621
+ const { data } = await api.get(`products/${productId}`);
1622
+ Object.assign(product, data);
1623
+ } catch (err) {
1624
+ console.error(err);
1625
+ fetchError.value = err;
1626
+ }
1627
+ isFetching.value = false;
1628
+ })();
1629
+ }
1630
+ const title = computed(() => {
1631
+ return name(product);
1632
+ });
1633
+ const link = computed(() => {
1634
+ const { slug } = product;
1635
+ if (typeof slug === "string") {
1636
+ return `/${slug}`;
1637
+ }
1638
+ return null;
1639
+ });
1640
+ const images = computed(() => {
1641
+ const { pictures } = product;
1642
+ const _images = [];
1643
+ if (pictures) {
1644
+ pictures.forEach((picture) => {
1645
+ const img$1 = img(picture);
1646
+ if (img$1)
1647
+ _images.push(img$1);
1648
+ });
1649
+ }
1650
+ return _images;
1651
+ });
1652
+ const isInStock = computed(() => {
1653
+ return inStock(product);
1654
+ });
1655
+ const isActive = computed(() => {
1656
+ return isInStock.value && product.available && product.visible;
1657
+ });
1658
+ const discountPercentage = computed(() => {
1659
+ if (onPromotion(product)) {
1660
+ const basePrice = product.base_price;
1661
+ return Math.round((basePrice - price(product)) * 100 / basePrice);
1662
+ }
1663
+ return 0;
1664
+ });
1665
+ const hasVariations = computed(() => {
1666
+ if (product.has_variations)
1667
+ return true;
1668
+ return Boolean(product.variations?.length);
1669
+ });
1670
+ emitGtagEvent("view_item", {
1671
+ value: isActive.value ? product.price : 0,
1672
+ items: [{
1673
+ ...getGtagItem(product),
1674
+ item_list_name: props.listName,
1675
+ item_list_id: props.listId || props.listName && slugify(props.listName)
1676
+ }]
1677
+ });
1678
+ return {
1679
+ isFetching,
1680
+ fetching,
1681
+ fetchError,
1682
+ product,
1683
+ title,
1684
+ link,
1685
+ images,
1686
+ isInStock,
1687
+ isActive,
1688
+ discountPercentage,
1689
+ hasVariations
1690
+ };
1691
+ };
1692
+
1693
+ const getPriceWithDiscount = (price, discount) => {
1694
+ const { type, value } = discount;
1695
+ let priceWithDiscount;
1696
+ if (value) {
1697
+ if (type === "percentage") {
1698
+ priceWithDiscount = price * ((100 - value) / 100);
1699
+ } else {
1700
+ priceWithDiscount = price - value;
1701
+ }
1702
+ return priceWithDiscount > 0 ? priceWithDiscount : 0;
1703
+ }
1704
+ return price;
1705
+ };
1706
+ const usePrices = (props) => {
1707
+ const _product = computed(() => {
1708
+ return props.product || {
1709
+ price: props.price || 0,
1710
+ base_price: props.basePrice
1711
+ };
1712
+ });
1713
+ const hasVariedPrices = computed(() => {
1714
+ const { variations } = _product.value;
1715
+ if (variations) {
1716
+ const productPrice = price(_product.value);
1717
+ for (let i = 0; i < variations.length; i++) {
1718
+ const price$1 = price({
1719
+ ..._product.value,
1720
+ ...variations[i]
1721
+ });
1722
+ if (price$1 > productPrice) {
1723
+ return true;
1724
+ }
1725
+ }
1726
+ }
1727
+ return false;
1728
+ });
1729
+ const salePrice = computed(() => {
1730
+ const price$1 = price(_product.value);
1731
+ const discount = availableExtraDiscount.value;
1732
+ if (discount && (!discount.min_amount || price$1 > discount.min_amount)) {
1733
+ return getPriceWithDiscount(price$1, discount);
1734
+ }
1735
+ return price$1;
1736
+ });
1737
+ const comparePrice = computed(() => {
1738
+ if (onPromotion(_product.value)) {
1739
+ return _product.value.base_price;
1740
+ }
1741
+ const price$1 = price(_product.value);
1742
+ if (price$1 > salePrice.value) {
1743
+ return price$1;
1744
+ }
1745
+ return 0;
1746
+ });
1747
+ const installmentsObject = computed(() => {
1748
+ return props.installmentsOption || installmentsOption.value || { max_number: 1 };
1749
+ });
1750
+ const installmentsNumber = computed(() => {
1751
+ if (installmentsObject.value.max_number <= 1) {
1752
+ return 1;
1753
+ }
1754
+ const minInstallment = installmentsObject.value.min_installment || 5;
1755
+ const maxInstallmentsNumber = Math.floor(salePrice.value / minInstallment);
1756
+ return Math.min(maxInstallmentsNumber, installmentsObject.value.max_number);
1757
+ });
1758
+ const monthlyInterest = computed(() => {
1759
+ return installmentsObject.value.monthly_interest || 0;
1760
+ });
1761
+ const installmentValue = computed(() => {
1762
+ if (installmentsNumber.value >= 2) {
1763
+ if (!monthlyInterest.value) {
1764
+ return salePrice.value / installmentsNumber.value;
1765
+ }
1766
+ const interest = monthlyInterest.value / 100;
1767
+ return salePrice.value * interest / (1 - (1 + interest) ** -installmentsNumber.value);
1768
+ }
1769
+ return 0;
1770
+ });
1771
+ const discountObject = computed(() => {
1772
+ const discount = props.discountOption || discountOption.value;
1773
+ if (discount && (!discount.min_amount || discount.min_amount <= salePrice.value) && (!props.isAmountTotal || discount.apply_at === "total")) {
1774
+ return discount;
1775
+ }
1776
+ return {};
1777
+ });
1778
+ const discountLabel = computed(() => {
1779
+ const { label } = discountObject.value;
1780
+ if (label) {
1781
+ if (label.includes(" ")) {
1782
+ return label;
1783
+ }
1784
+ return `via ${label}`;
1785
+ }
1786
+ return "";
1787
+ });
1788
+ const priceWithDiscount = computed(() => {
1789
+ return getPriceWithDiscount(salePrice.value, discountObject.value);
1790
+ });
1791
+ const pointsProgramObject = computed(() => {
1792
+ if (props.loyaltyPointsProgram) {
1793
+ return props.loyaltyPointsProgram;
1794
+ }
1795
+ const pointsPrograms = loyaltyPointsPrograms.value;
1796
+ if (pointsPrograms) {
1797
+ const programIds = Object.keys(pointsPrograms);
1798
+ for (let i = 0; i < programIds.length; i++) {
1799
+ const program = pointsPrograms[programIds[i]];
1800
+ if (program?.earn_percentage && program.earn_percentage > 0) {
1801
+ return program;
1802
+ }
1803
+ }
1804
+ }
1805
+ return { ratio: 0 };
1806
+ });
1807
+ const pointsMinPrice = computed(() => {
1808
+ return pointsProgramObject.value.min_subtotal_to_earn || 0;
1809
+ });
1810
+ const pointsProgramName = computed(() => {
1811
+ return pointsProgramObject.value.name || "";
1812
+ });
1813
+ const earnPointsPercentage = computed(() => {
1814
+ return pointsProgramObject.value.earn_percentage || 0;
1815
+ });
1816
+ const cashbackPercentage = computed(() => {
1817
+ return earnPointsPercentage.value * pointsProgramObject.value.ratio;
1818
+ });
1819
+ const cashbackValue = computed(() => {
1820
+ return cashbackPercentage.value >= 1 ? salePrice.value * (cashbackPercentage.value / 100) : 0;
1821
+ });
1822
+ return {
1823
+ hasVariedPrices,
1824
+ salePrice,
1825
+ comparePrice,
1826
+ installmentsObject,
1827
+ installmentsNumber,
1828
+ monthlyInterest,
1829
+ installmentValue,
1830
+ discountObject,
1831
+ discountLabel,
1832
+ priceWithDiscount,
1833
+ pointsProgramObject,
1834
+ pointsMinPrice,
1835
+ pointsProgramName,
1836
+ earnPointsPercentage,
1837
+ cashbackPercentage,
1838
+ cashbackValue
1839
+ };
1840
+ };
1841
+
1842
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
1843
+ __name: "Prices",
1844
+ props: {
1845
+ isBig: { type: Boolean },
1846
+ isLiteral: { type: Boolean },
1847
+ hasCashback: { type: Boolean, default: true },
1848
+ hasPriceOptions: { type: Boolean, default: true },
1849
+ product: {},
1850
+ price: {},
1851
+ basePrice: {},
1852
+ isAmountTotal: { type: Boolean },
1853
+ installmentsOption: {},
1854
+ discountOption: {},
1855
+ loyaltyPointsProgram: {}
1856
+ },
1857
+ setup(__props, { expose: __expose }) {
1858
+ __expose();
1859
+ const props = __props;
1860
+ const {
1861
+ hasVariedPrices,
1862
+ salePrice,
1863
+ comparePrice,
1864
+ cashbackPercentage,
1865
+ cashbackValue,
1866
+ installmentsNumber,
1867
+ monthlyInterest,
1868
+ installmentValue,
1869
+ priceWithDiscount,
1870
+ discountLabel
1871
+ } = usePrices(props);
1872
+ const __returned__ = { props, hasVariedPrices, salePrice, comparePrice, cashbackPercentage, cashbackValue, installmentsNumber, monthlyInterest, installmentValue, priceWithDiscount, discountLabel };
1873
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
1874
+ return __returned__;
1875
+ }
1876
+ });
1877
+ function _sfc_ssrRender$i(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
1878
+ const _component_Fade = resolveComponent("Fade");
1879
+ _push(`<div${ssrRenderAttrs(mergeProps({
1880
+ class: ["text-base-600 [&>div]:[font-size:90%] [&_small]:lowercase [&_small]:[font-size:92%]", $props.isBig ? "text-lg" : null]
1881
+ }, _attrs))}>`);
1882
+ if ($setup.comparePrice) {
1883
+ _push(`<span class="text-base-500 mr-1 text-[87%]">`);
1884
+ if ($props.isLiteral) {
1885
+ _push(`<small>${ssrInterpolate(`${"De"} `)}</small>`);
1886
+ } else {
1887
+ _push(`<!---->`);
1888
+ }
1889
+ _push(`<s>${ssrInterpolate(_ctx.$money($setup.comparePrice))}</s>`);
1890
+ if ($props.isLiteral) {
1891
+ _push(`<small>${ssrInterpolate(` ${"Por"}`)}</small>`);
1892
+ } else {
1893
+ _push(`<!---->`);
1894
+ }
1895
+ _push(`</span>`);
1896
+ } else {
1897
+ _push(`<!---->`);
1898
+ }
1899
+ _push(`<strong class="${ssrRenderClass([$props.isBig ? "text-4xl block" : "inline-block", "text-base-800"])}">`);
1900
+ if ($setup.hasVariedPrices) {
1901
+ _push(`<small>${ssrInterpolate(`${"A partir de"} `)}</small>`);
1902
+ } else {
1903
+ _push(`<!---->`);
1904
+ }
1905
+ _push(` ${ssrInterpolate(_ctx.$money($setup.salePrice))}</strong>`);
1906
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
1907
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1908
+ if (_push2) {
1909
+ if ($setup.cashbackValue && $props.hasCashback) {
1910
+ _push2(`<div class="relative z-10"${_scopeId}><span${ssrRenderAttr("data-tooltip", "Receba $1 de volta".replace("$1", _ctx.$percentage($setup.cashbackPercentage)))}${_scopeId}><i class="i-arrow-uturn-left mr-1"${_scopeId}></i><span class="font-medium"${_scopeId}>${ssrInterpolate(_ctx.$money($setup.cashbackValue))}</span><small${_scopeId}> cashback</small></span></div>`);
1911
+ } else {
1912
+ _push2(`<!---->`);
1913
+ }
1914
+ } else {
1915
+ return [
1916
+ $setup.cashbackValue && $props.hasCashback ? (openBlock(), createBlock("div", {
1917
+ key: 0,
1918
+ class: "relative z-10"
1919
+ }, [
1920
+ createVNode("span", {
1921
+ "data-tooltip": "Receba $1 de volta".replace("$1", _ctx.$percentage($setup.cashbackPercentage))
1922
+ }, [
1923
+ createVNode("i", { class: "i-arrow-uturn-left mr-1" }),
1924
+ createVNode("span", { class: "font-medium" }, toDisplayString(_ctx.$money($setup.cashbackValue)), 1),
1925
+ createVNode("small", null, " cashback")
1926
+ ], 8, ["data-tooltip"])
1927
+ ])) : createCommentVNode("", true)
1928
+ ];
1929
+ }
1930
+ }),
1931
+ _: 1
1932
+ }, _parent));
1933
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
1934
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1935
+ if (_push2) {
1936
+ if ($setup.installmentValue && $props.hasPriceOptions) {
1937
+ _push2(`<div${_scopeId}>`);
1938
+ if ($props.isLiteral) {
1939
+ _push2(`<small${_scopeId}>${ssrInterpolate(`${"At\xE9"} `)}</small>`);
1940
+ } else {
1941
+ _push2(`<!---->`);
1942
+ }
1943
+ _push2(` ${ssrInterpolate($setup.installmentsNumber)}x `);
1944
+ if ($props.isLiteral) {
1945
+ _push2(`<small${_scopeId}>${ssrInterpolate(` ${"De"} `)}</small>`);
1946
+ } else {
1947
+ _push2(`<!---->`);
1948
+ }
1949
+ _push2(`<span${_scopeId}>${ssrInterpolate(_ctx.$money($setup.installmentValue))}</span>`);
1950
+ if (!$setup.monthlyInterest && $props.isLiteral) {
1951
+ _push2(`<small${_scopeId}>${ssrInterpolate(` ${"Sem juros"}`)}</small>`);
1952
+ } else {
1953
+ _push2(`<!---->`);
1954
+ }
1955
+ _push2(`</div>`);
1956
+ } else {
1957
+ _push2(`<!---->`);
1958
+ }
1959
+ } else {
1960
+ return [
1961
+ $setup.installmentValue && $props.hasPriceOptions ? (openBlock(), createBlock("div", { key: 0 }, [
1962
+ $props.isLiteral ? (openBlock(), createBlock("small", { key: 0 }, toDisplayString(`${"At\xE9"} `))) : createCommentVNode("", true),
1963
+ createTextVNode(" " + toDisplayString($setup.installmentsNumber) + "x ", 1),
1964
+ $props.isLiteral ? (openBlock(), createBlock("small", { key: 1 }, toDisplayString(` ${"De"} `))) : createCommentVNode("", true),
1965
+ createVNode("span", null, toDisplayString(_ctx.$money($setup.installmentValue)), 1),
1966
+ !$setup.monthlyInterest && $props.isLiteral ? (openBlock(), createBlock("small", { key: 2 }, toDisplayString(` ${"Sem juros"}`))) : createCommentVNode("", true)
1967
+ ])) : createCommentVNode("", true)
1968
+ ];
1969
+ }
1970
+ }),
1971
+ _: 1
1972
+ }, _parent));
1973
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
1974
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1975
+ if (_push2) {
1976
+ if ($setup.priceWithDiscount < $setup.salePrice && $props.hasPriceOptions) {
1977
+ _push2(`<div${_scopeId}>`);
1978
+ if (!$setup.discountLabel) {
1979
+ _push2(`<small${_scopeId}>${ssrInterpolate(`${"A partir de"} `)}</small>`);
1980
+ } else {
1981
+ _push2(`<!---->`);
1982
+ }
1983
+ _push2(`<span${_scopeId}>${ssrInterpolate(_ctx.$money($setup.priceWithDiscount))}</span>`);
1984
+ if ($setup.discountLabel) {
1985
+ _push2(`<small${_scopeId}>${ssrInterpolate(` ${$setup.discountLabel}`)}</small>`);
1986
+ } else {
1987
+ _push2(`<!---->`);
1988
+ }
1989
+ _push2(`</div>`);
1990
+ } else {
1991
+ _push2(`<!---->`);
1992
+ }
1993
+ } else {
1994
+ return [
1995
+ $setup.priceWithDiscount < $setup.salePrice && $props.hasPriceOptions ? (openBlock(), createBlock("div", { key: 0 }, [
1996
+ !$setup.discountLabel ? (openBlock(), createBlock("small", { key: 0 }, toDisplayString(`${"A partir de"} `))) : createCommentVNode("", true),
1997
+ createVNode("span", null, toDisplayString(_ctx.$money($setup.priceWithDiscount)), 1),
1998
+ $setup.discountLabel ? (openBlock(), createBlock("small", { key: 1 }, toDisplayString(` ${$setup.discountLabel}`), 1)) : createCommentVNode("", true)
1999
+ ])) : createCommentVNode("", true)
2000
+ ];
2001
+ }
2002
+ }),
2003
+ _: 1
2004
+ }, _parent));
2005
+ _push(`</div>`);
2006
+ }
2007
+ const _sfc_setup$i = _sfc_main$i.setup;
2008
+ _sfc_main$i.setup = (props, ctx) => {
2009
+ const ssrContext = useSSRContext();
2010
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Prices.vue");
2011
+ return _sfc_setup$i ? _sfc_setup$i(props, ctx) : void 0;
2012
+ };
2013
+ const Prices = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["ssrRender", _sfc_ssrRender$i]]);
2014
+
2015
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2016
+ __name: "ProductCard",
2017
+ props: {
2018
+ product: {},
2019
+ productId: {},
2020
+ listName: {},
2021
+ listId: {},
2022
+ headingTag: { default: "h3" }
2023
+ },
2024
+ setup(__props, { expose: __expose }) {
2025
+ __expose();
2026
+ const props = __props;
2027
+ const {
2028
+ product,
2029
+ title,
2030
+ link,
2031
+ images,
2032
+ isInStock,
2033
+ isActive,
2034
+ discountPercentage,
2035
+ hasVariations
2036
+ } = useProductCard(props);
2037
+ const card = ref(null);
2038
+ const isHovered = useElementHover(card);
2039
+ const wasHoveredOnce = ref(false);
2040
+ const unwatch = watch(isHovered, () => {
2041
+ wasHoveredOnce.value = true;
2042
+ unwatch();
2043
+ });
2044
+ const __returned__ = { props, product, title, link, images, isInStock, isActive, discountPercentage, hasVariations, card, isHovered, wasHoveredOnce, unwatch, get addProductToCart() {
2045
+ return addProductToCart;
2046
+ }, get isMobile() {
2047
+ return isMobile;
2048
+ }, Prices };
2049
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2050
+ return __returned__;
2051
+ }
2052
+ });
2053
+ function _sfc_ssrRender$h(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2054
+ const _component_ALink = resolveComponent("ALink");
2055
+ const _component_AImg = resolveComponent("AImg");
2056
+ _push(`<article${ssrRenderAttrs(mergeProps({
2057
+ ref: "card",
2058
+ "data-sku": $setup.product.sku,
2059
+ class: "group relative mx-auto h-full max-w-[350px] px-0.5 py-3 hover:z-[1]"
2060
+ }, _attrs))}>`);
2061
+ _push(ssrRenderComponent(_component_ALink, {
2062
+ href: $setup.link,
2063
+ prefetch: "visible",
2064
+ class: "flex h-full flex-col overflow-hidden rounded bg-white ring-black/5 group-hover:shadow group-hover:ring-1"
2065
+ }, {
2066
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2067
+ if (_push2) {
2068
+ _push2(`<div class="aspect-square p-2 transition-transform motion-safe:group-hover:scale-110"${_scopeId}><div class="relative size-full overflow-hidden rounded bg-white group-hover:rounded-none"${_scopeId}>`);
2069
+ if ($setup.images?.length) {
2070
+ _push2(`<span class="text-xs text-opacity-70"${_scopeId}>`);
2071
+ _push2(ssrRenderComponent(_component_AImg, {
2072
+ picture: $setup.images[0],
2073
+ alt: $setup.title,
2074
+ class: "absolute left-0 top-0 block size-full object-cover"
2075
+ }, null, _parent2, _scopeId));
2076
+ if (!$setup.isMobile && $setup.images[1] && $setup.wasHoveredOnce) {
2077
+ _push2(ssrRenderComponent(_component_AImg, {
2078
+ picture: $setup.images[1],
2079
+ alt: $setup.title,
2080
+ class: "absolute left-0 top-0 z-10 block size-full object-cover text-transparent opacity-0 transition-opacity group-hover:opacity-100 motion-safe:duration-300"
2081
+ }, null, _parent2, _scopeId));
2082
+ } else {
2083
+ _push2(`<!---->`);
2084
+ }
2085
+ _push2(`</span>`);
2086
+ } else {
2087
+ _push2(`<div class="size-full bg-gradient-to-br from-base-50/20 to-base-100"${_scopeId}></div>`);
2088
+ }
2089
+ _push2(`</div></div>`);
2090
+ if ($setup.discountPercentage) {
2091
+ _push2(`<span class="uno-bm03rg"${_scopeId}> -<strong${_scopeId}>${ssrInterpolate($setup.discountPercentage)}</strong>% </span>`);
2092
+ } else {
2093
+ _push2(`<!---->`);
2094
+ }
2095
+ _push2(`<div class="relative z-10 flex grow flex-col justify-between p-4"${_scopeId}>`);
2096
+ ssrRenderVNode(_push2, createVNode(resolveDynamicComponent($props.headingTag), {
2097
+ class: ["line-clamp-2 no-underline ui-link", [
2098
+ $setup.isActive ? "text-base-700" : "text-base-500",
2099
+ $setup.link ? "group-hover:text-primary group-hover:underline" : null
2100
+ ]]
2101
+ }, {
2102
+ default: withCtx((_2, _push3, _parent3, _scopeId2) => {
2103
+ if (_push3) {
2104
+ _push3(`${ssrInterpolate($setup.title)}`);
2105
+ } else {
2106
+ return [
2107
+ createTextVNode(toDisplayString($setup.title), 1)
2108
+ ];
2109
+ }
2110
+ }),
2111
+ _: 1
2112
+ }), _parent2, _scopeId);
2113
+ _push2(`<div class="pt-2"${_scopeId}>`);
2114
+ if ($setup.isActive) {
2115
+ _push2(`<div${_scopeId}>`);
2116
+ _push2(ssrRenderComponent($setup["Prices"], { product: $setup.product }, null, _parent2, _scopeId));
2117
+ _push2(`</div>`);
2118
+ } else {
2119
+ _push2(`<span class="bg-warning-100 text-warning-700 ui-badge"${_scopeId}>${ssrInterpolate(!$setup.isInStock ? "Sem estoque" : "Inativo")}</span>`);
2120
+ }
2121
+ _push2(`</div>`);
2122
+ if ($setup.isActive && !$setup.hasVariations) {
2123
+ _push2(`<button class="uno-3suct9 ui-btn-sm ui-btn-primary"${_scopeId}><span class="mr-1 inline-block size-4 rounded-full bg-on-primary text-center text-base leading-none text-primary opacity-80"${_scopeId}> + </span> ${ssrInterpolate("Adicionar ao carrinho")}</button>`);
2124
+ } else {
2125
+ _push2(`<!---->`);
2126
+ }
2127
+ _push2(`</div>`);
2128
+ } else {
2129
+ return [
2130
+ createVNode("div", { class: "aspect-square p-2 transition-transform motion-safe:group-hover:scale-110" }, [
2131
+ createVNode("div", { class: "relative size-full overflow-hidden rounded bg-white group-hover:rounded-none" }, [
2132
+ $setup.images?.length ? (openBlock(), createBlock("span", {
2133
+ key: 0,
2134
+ class: "text-xs text-opacity-70"
2135
+ }, [
2136
+ createVNode(_component_AImg, {
2137
+ picture: $setup.images[0],
2138
+ alt: $setup.title,
2139
+ class: "absolute left-0 top-0 block size-full object-cover"
2140
+ }, null, 8, ["picture", "alt"]),
2141
+ !$setup.isMobile && $setup.images[1] && $setup.wasHoveredOnce ? (openBlock(), createBlock(_component_AImg, {
2142
+ key: 0,
2143
+ picture: $setup.images[1],
2144
+ alt: $setup.title,
2145
+ class: "absolute left-0 top-0 z-10 block size-full object-cover text-transparent opacity-0 transition-opacity group-hover:opacity-100 motion-safe:duration-300"
2146
+ }, null, 8, ["picture", "alt"])) : createCommentVNode("", true)
2147
+ ])) : (openBlock(), createBlock("div", {
2148
+ key: 1,
2149
+ class: "size-full bg-gradient-to-br from-base-50/20 to-base-100"
2150
+ }))
2151
+ ])
2152
+ ]),
2153
+ $setup.discountPercentage ? (openBlock(), createBlock("span", {
2154
+ key: 0,
2155
+ class: "uno-bm03rg"
2156
+ }, [
2157
+ createTextVNode(" -"),
2158
+ createVNode("strong", null, toDisplayString($setup.discountPercentage), 1),
2159
+ createTextVNode("% ")
2160
+ ])) : createCommentVNode("", true),
2161
+ createVNode("div", { class: "relative z-10 flex grow flex-col justify-between p-4" }, [
2162
+ (openBlock(), createBlock(resolveDynamicComponent($props.headingTag), {
2163
+ class: ["line-clamp-2 no-underline ui-link", [
2164
+ $setup.isActive ? "text-base-700" : "text-base-500",
2165
+ $setup.link ? "group-hover:text-primary group-hover:underline" : null
2166
+ ]]
2167
+ }, {
2168
+ default: withCtx(() => [
2169
+ createTextVNode(toDisplayString($setup.title), 1)
2170
+ ]),
2171
+ _: 1
2172
+ }, 8, ["class"])),
2173
+ createVNode("div", { class: "pt-2" }, [
2174
+ $setup.isActive ? (openBlock(), createBlock("div", { key: 0 }, [
2175
+ createVNode($setup["Prices"], { product: $setup.product }, null, 8, ["product"])
2176
+ ])) : (openBlock(), createBlock("span", {
2177
+ key: 1,
2178
+ class: "bg-warning-100 text-warning-700 ui-badge"
2179
+ }, toDisplayString(!$setup.isInStock ? "Sem estoque" : "Inativo"), 1))
2180
+ ]),
2181
+ $setup.isActive && !$setup.hasVariations ? (openBlock(), createBlock("button", {
2182
+ key: 0,
2183
+ class: "uno-3suct9 ui-btn-sm ui-btn-primary",
2184
+ onClick: withModifiers(($event) => $setup.addProductToCart($setup.product), ["stop", "prevent"])
2185
+ }, [
2186
+ createVNode("span", { class: "mr-1 inline-block size-4 rounded-full bg-on-primary text-center text-base leading-none text-primary opacity-80" }, " + "),
2187
+ createTextVNode(" " + toDisplayString("Adicionar ao carrinho"))
2188
+ ], 8, ["onClick"])) : createCommentVNode("", true)
2189
+ ])
2190
+ ];
2191
+ }
2192
+ }),
2193
+ _: 1
2194
+ }, _parent));
2195
+ _push(`</article>`);
2196
+ }
2197
+ const _sfc_setup$h = _sfc_main$h.setup;
2198
+ _sfc_main$h.setup = (props, ctx) => {
2199
+ const ssrContext = useSSRContext();
2200
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/ProductCard.vue");
2201
+ return _sfc_setup$h ? _sfc_setup$h(props, ctx) : void 0;
2202
+ };
2203
+ const ProductCard = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["ssrRender", _sfc_ssrRender$h]]);
2204
+
2205
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2206
+ __name: "ProductShelf",
2207
+ props: {
2208
+ isGrid: { type: Boolean },
2209
+ collectionId: {},
2210
+ searchQuery: {},
2211
+ sort: {},
2212
+ title: {},
2213
+ titleLink: {},
2214
+ isShuffle: { type: Boolean },
2215
+ limit: {},
2216
+ page: {},
2217
+ products: {},
2218
+ orderedProductIds: {},
2219
+ isRelatedProducts: { type: Boolean },
2220
+ cmsPreview: {}
2221
+ },
2222
+ async setup(__props, { expose: __expose }) {
2223
+ __expose();
2224
+ let __temp, __restore;
2225
+ const props = __props;
2226
+ const [
2227
+ DefineCarouselControl,
2228
+ ReuseCarouselControl
2229
+ ] = createReusableTemplate();
2230
+ const {
2231
+ title,
2232
+ titleLink,
2233
+ fetching,
2234
+ products
2235
+ } = useProductShelf(props);
2236
+ {
2237
+ [__temp, __restore] = withAsyncContext(() => fetching), await __temp, __restore();
2238
+ }
2239
+ const listName = title.value || `Shelf ${useId()}`;
2240
+ const __returned__ = { props, DefineCarouselControl, ReuseCarouselControl, title, titleLink, fetching, products, listName, ProductCard };
2241
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2242
+ return __returned__;
2243
+ }
2244
+ });
2245
+ function _sfc_ssrRender$g(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2246
+ const _component_ALink = resolveComponent("ALink");
2247
+ const _component_CarouselControl = resolveComponent("CarouselControl");
2248
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "ui-section" }, _attrs))}>`);
2249
+ if ($setup.title) {
2250
+ _push(`<div class="mx-auto mb-4 max-w-prose text-center"><h3>`);
2251
+ _push(ssrRenderComponent(_component_ALink, {
2252
+ href: $setup.titleLink,
2253
+ class: ["text-3xl text-base-700 ui-text-brand", $setup.titleLink && "ui-link decoration-primary/60"]
2254
+ }, {
2255
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2256
+ if (_push2) {
2257
+ _push2(`${ssrInterpolate($setup.title)}`);
2258
+ } else {
2259
+ return [
2260
+ createTextVNode(toDisplayString($setup.title), 1)
2261
+ ];
2262
+ }
2263
+ }),
2264
+ _: 1
2265
+ }, _parent));
2266
+ _push(`</h3></div>`);
2267
+ } else {
2268
+ _push(`<!---->`);
2269
+ }
2270
+ ssrRenderVNode(_push, createVNode(resolveDynamicComponent($props.isGrid ? "ul" : "Carousel"), {
2271
+ class: ["group/shelf", $props.isGrid && "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4"]
2272
+ }, createSlots({
2273
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2274
+ if (_push2) {
2275
+ _push2(`<!--[-->`);
2276
+ ssrRenderList($setup.products, (product) => {
2277
+ _push2(`<li class="shrink-0 basis-1/2 md:basis-1/3 lg:basis-1/4"${_scopeId}>`);
2278
+ _push2(ssrRenderComponent($setup["ProductCard"], {
2279
+ product,
2280
+ "list-name": $setup.listName
2281
+ }, null, _parent2, _scopeId));
2282
+ _push2(`</li>`);
2283
+ });
2284
+ _push2(`<!--]-->`);
2285
+ } else {
2286
+ return [
2287
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.products, (product) => {
2288
+ return openBlock(), createBlock("li", {
2289
+ key: product._id,
2290
+ class: "shrink-0 basis-1/2 md:basis-1/3 lg:basis-1/4"
2291
+ }, [
2292
+ createVNode($setup["ProductCard"], {
2293
+ product,
2294
+ "list-name": $setup.listName
2295
+ }, null, 8, ["product", "list-name"])
2296
+ ]);
2297
+ }), 128))
2298
+ ];
2299
+ }
2300
+ }),
2301
+ _: 2
2302
+ }, [
2303
+ !$props.isGrid ? {
2304
+ name: "controls",
2305
+ fn: withCtx((_, _push2, _parent2, _scopeId) => {
2306
+ if (_push2) {
2307
+ _push2(ssrRenderComponent($setup["DefineCarouselControl"], null, {
2308
+ default: withCtx(({ isPrev }, _push3, _parent3, _scopeId2) => {
2309
+ if (_push3) {
2310
+ _push3(ssrRenderComponent(_component_CarouselControl, {
2311
+ style: $setup.products.length > 2 ? null : { display: "none" },
2312
+ class: ["uno-t0rdy7", isPrev ? "!-left-4" : "!-right-4"],
2313
+ "is-prev": isPrev
2314
+ }, null, _parent3, _scopeId2));
2315
+ } else {
2316
+ return [
2317
+ withDirectives(createVNode(_component_CarouselControl, {
2318
+ class: ["uno-t0rdy7", isPrev ? "!-left-4" : "!-right-4"],
2319
+ "is-prev": isPrev
2320
+ }, null, 8, ["class", "is-prev"]), [
2321
+ [vShow, $setup.products.length > 2]
2322
+ ])
2323
+ ];
2324
+ }
2325
+ }),
2326
+ _: 1
2327
+ }, _parent2, _scopeId));
2328
+ _push2(ssrRenderComponent($setup["ReuseCarouselControl"], { "is-prev": true }, null, _parent2, _scopeId));
2329
+ _push2(ssrRenderComponent($setup["ReuseCarouselControl"], null, null, _parent2, _scopeId));
2330
+ } else {
2331
+ return [
2332
+ createVNode($setup["DefineCarouselControl"], null, {
2333
+ default: withCtx(({ isPrev }) => [
2334
+ withDirectives(createVNode(_component_CarouselControl, {
2335
+ class: ["uno-t0rdy7", isPrev ? "!-left-4" : "!-right-4"],
2336
+ "is-prev": isPrev
2337
+ }, null, 8, ["class", "is-prev"]), [
2338
+ [vShow, $setup.products.length > 2]
2339
+ ])
2340
+ ]),
2341
+ _: 1
2342
+ }),
2343
+ createVNode($setup["ReuseCarouselControl"], { "is-prev": true }),
2344
+ createVNode($setup["ReuseCarouselControl"])
2345
+ ];
2346
+ }
2347
+ }),
2348
+ key: "0"
2349
+ } : void 0
2350
+ ])), _parent);
2351
+ ssrRenderSlot(_ctx.$slots, "append", {}, null, _push, _parent);
2352
+ _push(`</section>`);
2353
+ }
2354
+ const _sfc_setup$g = _sfc_main$g.setup;
2355
+ _sfc_main$g.setup = (props, ctx) => {
2356
+ const ssrContext = useSSRContext();
2357
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/ProductShelf.vue");
2358
+ return _sfc_setup$g ? _sfc_setup$g(props, ctx) : void 0;
2359
+ };
2360
+ const ProductShelf = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["ssrRender", _sfc_ssrRender$g]]);
2361
+
2362
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2363
+ __name: "Collapse",
2364
+ props: {
2365
+ title: {}
2366
+ },
2367
+ setup(__props, { expose: __expose }) {
2368
+ __expose();
2369
+ const __returned__ = {};
2370
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2371
+ return __returned__;
2372
+ }
2373
+ });
2374
+ function _sfc_ssrRender$f(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2375
+ _push(`<details${ssrRenderAttrs(mergeProps({ class: "group my-4 md:my-5 [&_i]:open:-rotate-90" }, _attrs))}><summary role="button" class="text-base-700 hover:text-base-800 [&amp;&gt;i]:hover:text-primary list-none text-2xl font-medium lowercase group-open:mb-3"><i class="i-chevron-right mr-1 rotate-90"></i><span>${ssrInterpolate($props.title)}</span></summary>`);
2376
+ ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent);
2377
+ _push(`</details>`);
2378
+ }
2379
+ const _sfc_setup$f = _sfc_main$f.setup;
2380
+ _sfc_main$f.setup = (props, ctx) => {
2381
+ const ssrContext = useSSRContext();
2382
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Collapse.vue");
2383
+ return _sfc_setup$f ? _sfc_setup$f(props, ctx) : void 0;
2384
+ };
2385
+ const Collapse = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["ssrRender", _sfc_ssrRender$f]]);
2386
+
2387
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2388
+ __name: "DocDescription",
2389
+ props: {
2390
+ apiDoc: { default: () => globalThis.$storefront.apiContext?.doc },
2391
+ title: {}
2392
+ },
2393
+ setup(__props, { expose: __expose }) {
2394
+ __expose();
2395
+ const props = __props;
2396
+ const html = computed(() => props.apiDoc.body_html);
2397
+ const __returned__ = { props, html, ContentClearfix, Collapse };
2398
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2399
+ return __returned__;
2400
+ }
2401
+ });
2402
+ function _sfc_ssrRender$e(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2403
+ if ($setup.html) {
2404
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "ui-section" }, _attrs))}>`);
2405
+ _push(ssrRenderComponent($setup["Collapse"], {
2406
+ title: $props.title || "Descri\xE7\xE3o",
2407
+ open: ""
2408
+ }, {
2409
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2410
+ if (_push2) {
2411
+ _push2(ssrRenderComponent($setup["ContentClearfix"], { html: $setup.html }, null, _parent2, _scopeId));
2412
+ } else {
2413
+ return [
2414
+ createVNode($setup["ContentClearfix"], { html: $setup.html }, null, 8, ["html"])
2415
+ ];
2416
+ }
2417
+ }),
2418
+ _: 1
2419
+ }, _parent));
2420
+ _push(`</section>`);
2421
+ } else {
2422
+ _push(`<!---->`);
2423
+ }
2424
+ }
2425
+ const _sfc_setup$e = _sfc_main$e.setup;
2426
+ _sfc_main$e.setup = (props, ctx) => {
2427
+ const ssrContext = useSSRContext();
2428
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/DocDescription.vue");
2429
+ return _sfc_setup$e ? _sfc_setup$e(props, ctx) : void 0;
2430
+ };
2431
+ const DocDescription = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["ssrRender", _sfc_ssrRender$e]]);
2432
+
2433
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2434
+ __name: "DocBanners",
2435
+ props: {
2436
+ apiDoc: { default: () => globalThis.$storefront.apiContext?.doc },
2437
+ title: {}
2438
+ },
2439
+ setup(__props, { expose: __expose }) {
2440
+ __expose();
2441
+ const props = __props;
2442
+ const pictures = computed(() => props.apiDoc.pictures || []);
2443
+ const __returned__ = { props, pictures };
2444
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2445
+ return __returned__;
2446
+ }
2447
+ });
2448
+ function _sfc_ssrRender$d(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2449
+ const _component_AImg = resolveComponent("AImg");
2450
+ if ($setup.pictures.length) {
2451
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "ui-section" }, _attrs))}><ul class="flex flex-wrap gap-4 lg:flex-nowrap"><!--[-->`);
2452
+ ssrRenderList($setup.pictures, (picture, i) => {
2453
+ _push(`<li class="lg:flex-1 [&amp;_img]:w-full [&amp;_img]:object-cover">`);
2454
+ _push(ssrRenderComponent(_component_AImg, { picture }, null, _parent));
2455
+ _push(`</li>`);
2456
+ });
2457
+ _push(`<!--]--></ul></section>`);
2458
+ } else {
2459
+ _push(`<!---->`);
2460
+ }
2461
+ }
2462
+ const _sfc_setup$d = _sfc_main$d.setup;
2463
+ _sfc_main$d.setup = (props, ctx) => {
2464
+ const ssrContext = useSSRContext();
2465
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/DocBanners.vue");
2466
+ return _sfc_setup$d ? _sfc_setup$d(props, ctx) : void 0;
2467
+ };
2468
+ const DocBanners = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["ssrRender", _sfc_ssrRender$d]]);
2469
+
2470
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
2471
+ __name: "CheckoutLink",
2472
+ props: {
2473
+ to: { default: "cart" },
2474
+ cartUrl: { default: globalThis.$storefront?.settings.cartUrl || "/app/#/cart" },
2475
+ checkoutUrl: { default: globalThis.$storefront?.settings.checkoutUrl || "/app/#/checkout" },
2476
+ cartId: {},
2477
+ cartItem: {}
2478
+ },
2479
+ setup(__props, { expose: __expose }) {
2480
+ __expose();
2481
+ const props = __props;
2482
+ const href = computed(() => {
2483
+ let url = props.to === "cart" ? props.cartUrl : props.checkoutUrl;
2484
+ if (props.cartId) {
2485
+ url += `/${props.cartId}`;
2486
+ } else if (props.cartItem) {
2487
+ const params = {
2488
+ product_id: props.cartItem.product_id
2489
+ };
2490
+ const {
2491
+ variation_id: variationId,
2492
+ quantity,
2493
+ sku,
2494
+ customizations
2495
+ } = props.cartItem;
2496
+ if (variationId)
2497
+ params.variation_id = variationId;
2498
+ if (quantity)
2499
+ params.quantity = String(quantity);
2500
+ if (sku)
2501
+ params.sku = sku;
2502
+ if (customizations) {
2503
+ customizations.forEach(({ label, option, attachment }, i) => {
2504
+ const prefix = `customizations.${i}.`;
2505
+ if (label)
2506
+ params[prefix + "label"] = label;
2507
+ if (option) {
2508
+ if (option._id)
2509
+ params[prefix + "option._id"] = option._id;
2510
+ params[prefix + "option.text"] = option.text;
2511
+ }
2512
+ if (attachment)
2513
+ params[prefix + "attachment"] = attachment;
2514
+ });
2515
+ }
2516
+ url += "?" + new URLSearchParams(params).toString();
2517
+ }
2518
+ return url;
2519
+ });
2520
+ const __returned__ = { props, href };
2521
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2522
+ return __returned__;
2523
+ }
2524
+ });
2525
+ function _sfc_ssrRender$c(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2526
+ _push(`<a${ssrRenderAttrs(mergeProps({ href: $setup.href }, _attrs))}>`);
2527
+ ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent);
2528
+ _push(`</a>`);
2529
+ }
2530
+ const _sfc_setup$c = _sfc_main$c.setup;
2531
+ _sfc_main$c.setup = (props, ctx) => {
2532
+ const ssrContext = useSSRContext();
2533
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/CheckoutLink.vue");
2534
+ return _sfc_setup$c ? _sfc_setup$c(props, ctx) : void 0;
2535
+ };
2536
+ const CheckoutLink = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["ssrRender", _sfc_ssrRender$c]]);
2537
+
2538
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2539
+ __name: "QuantitySelectorControl",
2540
+ props: {
2541
+ isMinus: { type: Boolean }
2542
+ },
2543
+ setup(__props, { expose: __expose }) {
2544
+ __expose();
2545
+ const {
2546
+ value,
2547
+ isBoundMin,
2548
+ isBoundMax
2549
+ } = inject(quantitySelectorKey);
2550
+ const __returned__ = { value, isBoundMin, isBoundMax };
2551
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2552
+ return __returned__;
2553
+ }
2554
+ });
2555
+ function _sfc_ssrRender$b(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2556
+ _push(`<button${ssrRenderAttrs(mergeProps({
2557
+ type: "button",
2558
+ class: "leading-12 h-12 w-10 text-xl enabled:text-primary enabled:hover:bg-primary-100/70 disabled:opacity-40",
2559
+ "data-quantity-selector-control": $props.isMinus ? "minus" : "plus",
2560
+ "aria-label": $props.isMinus ? "Menos" : "Mais",
2561
+ disabled: $props.isMinus ? $setup.isBoundMin : $setup.isBoundMax
2562
+ }, _attrs))}>`);
2563
+ ssrRenderSlot(_ctx.$slots, "default", {}, () => {
2564
+ if ($props.isMinus) {
2565
+ _push(`<!--[-->\u2212<!--]-->`);
2566
+ } else {
2567
+ _push(`<!--[-->+<!--]-->`);
2568
+ }
2569
+ }, _push, _parent);
2570
+ _push(`</button>`);
2571
+ }
2572
+ const _sfc_setup$b = _sfc_main$b.setup;
2573
+ _sfc_main$b.setup = (props, ctx) => {
2574
+ const ssrContext = useSSRContext();
2575
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/QuantitySelectorControl.vue");
2576
+ return _sfc_setup$b ? _sfc_setup$b(props, ctx) : void 0;
2577
+ };
2578
+ const QuantitySelectorControl = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["ssrRender", _sfc_ssrRender$b]]);
2579
+
2580
+ const quantitySelectorKey = Symbol("quantitySelector");
2581
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2582
+ __name: "QuantitySelector",
2583
+ props: /* @__PURE__ */ mergeModels({
2584
+ min: { default: 1 },
2585
+ max: {},
2586
+ step: {},
2587
+ disabled: { type: Boolean },
2588
+ readonly: { type: Boolean }
2589
+ }, {
2590
+ "modelValue": { default: 1 },
2591
+ "modelModifiers": {}
2592
+ }),
2593
+ emits: ["update:modelValue"],
2594
+ setup(__props, { expose: __expose }) {
2595
+ __expose();
2596
+ const props = __props;
2597
+ const model = useModel(__props, "modelValue");
2598
+ const input = ref(null);
2599
+ const inputId = useId("NInput");
2600
+ const value = computed({
2601
+ get() {
2602
+ return model.value;
2603
+ },
2604
+ set(_value) {
2605
+ if (_value < props.min) {
2606
+ _value = props.min;
2607
+ input.value.value = `${_value}`;
2608
+ } else if (props.max && _value > props.max) {
2609
+ _value = props.max;
2610
+ input.value.value = `${_value}`;
2611
+ }
2612
+ model.value = _value;
2613
+ }
2614
+ });
2615
+ const isBoundMin = computed(() => {
2616
+ return props.min >= value.value;
2617
+ });
2618
+ const isBoundMax = computed(() => {
2619
+ return props.max <= value.value;
2620
+ });
2621
+ provide(quantitySelectorKey, {
2622
+ value,
2623
+ isBoundMin,
2624
+ isBoundMax
2625
+ });
2626
+ const __returned__ = { quantitySelectorKey, props, model, input, inputId, value, isBoundMin, isBoundMax, QuantitySelectorControl };
2627
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2628
+ return __returned__;
2629
+ }
2630
+ });
2631
+ function _sfc_ssrRender$a(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2632
+ _push(`<div${ssrRenderAttrs(mergeProps({ "data-quantity-selector": "" }, _attrs))}>`);
2633
+ ssrRenderSlot(_ctx.$slots, "label", { inputId: $setup.inputId, value: $setup.value }, () => {
2634
+ _push(`<label${ssrRenderAttr("for", $setup.inputId)} class="sr-only">${ssrInterpolate("Quantidade")}</label>`);
2635
+ }, _push, _parent);
2636
+ _push(`<div class="flex items-center"><input type="number"${ssrRenderAttr("id", $setup.inputId)}${ssrRenderAttr("value", $setup.value)}${ssrRenderAttr("min", $props.min)}${ssrRenderAttr("max", $props.max)}${ssrRenderAttr("step", $props.step)}${ssrIncludeBooleanAttr($props.disabled) ? " disabled" : ""}${ssrIncludeBooleanAttr($props.readonly) ? " readonly" : ""} class="h-12 w-14 border-transparent px-2 text-center text-lg [-moz-appearance:_textfield] [&amp;::-webkit-inner-spin-button]:m-0 [&amp;::-webkit-inner-spin-button]:appearance-none [&amp;::-webkit-outer-spin-button]:m-0 [&amp;::-webkit-outer-spin-button]:appearance-none">`);
2637
+ ssrRenderSlot(_ctx.$slots, "controls", { value: $setup.value, isBoundMin: $setup.isBoundMin, isBoundMax: $setup.isBoundMax }, () => {
2638
+ _push(ssrRenderComponent($setup["QuantitySelectorControl"], {
2639
+ "is-minus": "",
2640
+ class: "order-first"
2641
+ }, {
2642
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2643
+ if (_push2) {
2644
+ ssrRenderSlot(_ctx.$slots, "minus", {}, null, _push2, _parent2, _scopeId);
2645
+ } else {
2646
+ return [
2647
+ renderSlot(_ctx.$slots, "minus")
2648
+ ];
2649
+ }
2650
+ }),
2651
+ _: 3
2652
+ }, _parent));
2653
+ _push(ssrRenderComponent($setup["QuantitySelectorControl"], { class: "order-last" }, {
2654
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2655
+ if (_push2) {
2656
+ ssrRenderSlot(_ctx.$slots, "plus", {}, null, _push2, _parent2, _scopeId);
2657
+ } else {
2658
+ return [
2659
+ renderSlot(_ctx.$slots, "plus")
2660
+ ];
2661
+ }
2662
+ }),
2663
+ _: 3
2664
+ }, _parent));
2665
+ }, _push, _parent);
2666
+ _push(`</div></div>`);
2667
+ }
2668
+ const _sfc_setup$a = _sfc_main$a.setup;
2669
+ _sfc_main$a.setup = (props, ctx) => {
2670
+ const ssrContext = useSSRContext();
2671
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/QuantitySelector.vue");
2672
+ return _sfc_setup$a ? _sfc_setup$a(props, ctx) : void 0;
2673
+ };
2674
+ const QuantitySelector = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["ssrRender", _sfc_ssrRender$a]]);
2675
+
2676
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
2677
+ __name: "ImagesGallery",
2678
+ props: {
2679
+ pictures: {}
2680
+ },
2681
+ setup(__props, { expose: __expose }) {
2682
+ __expose();
2683
+ const activeIndex = ref(0);
2684
+ const psId = ref("");
2685
+ let lightbox;
2686
+ const isLoadingLightbox = ref(false);
2687
+ const zoom = (index) => {
2688
+ psId.value = `ps-${useId()}`;
2689
+ if (!lightbox && !isLoadingLightbox.value) {
2690
+ isLoadingLightbox.value = true;
2691
+ const styleId = "photoswipe-style";
2692
+ Promise.all([
2693
+ // @ts-ignore
2694
+ import('photoswipe/lightbox'),
2695
+ import('photoswipe'),
2696
+ !document.getElementById(styleId) && import('../photoswipe_wusPJBJF.mjs')
2697
+ ]).then(([
2698
+ { default: PhotoSwipeLightbox },
2699
+ { default: pswpModule },
2700
+ cssImport
2701
+ ]) => {
2702
+ if (cssImport) {
2703
+ const { default: css } = cssImport;
2704
+ const style = document.createElement("style");
2705
+ style.id = styleId;
2706
+ style.textContent = css;
2707
+ document.head.appendChild(style);
2708
+ }
2709
+ lightbox = new PhotoSwipeLightbox({
2710
+ gallery: `#${psId.value} > div`,
2711
+ children: "a",
2712
+ pswpModule,
2713
+ showAnimationDuration: 300,
2714
+ hideAnimationDuration: 300
2715
+ });
2716
+ lightbox.init();
2717
+ lightbox.loadAndOpen(index);
2718
+ isLoadingLightbox.value = false;
2719
+ });
2720
+ }
2721
+ };
2722
+ const __returned__ = { activeIndex, psId, get lightbox() {
2723
+ return lightbox;
2724
+ }, set lightbox(v) {
2725
+ lightbox = v;
2726
+ }, isLoadingLightbox, zoom, get getImgSizes() {
2727
+ return imgSizes;
2728
+ } };
2729
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2730
+ return __returned__;
2731
+ }
2732
+ });
2733
+ function _sfc_ssrRender$9(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
2734
+ const _component_Carousel = resolveComponent("Carousel");
2735
+ const _component_AImg = resolveComponent("AImg");
2736
+ const _component_CarouselControl = resolveComponent("CarouselControl");
2737
+ const _component_ALink = resolveComponent("ALink");
2738
+ _push(`<div${ssrRenderAttrs(mergeProps({ class: "-mx-4 flex w-screen gap-3 sm:mx-0 sm:w-full md:h-[525px] 2xl:gap-5" }, _attrs))}>`);
2739
+ if ($props.pictures.length > 1) {
2740
+ _push(ssrRenderComponent(_component_Carousel, {
2741
+ axis: "y",
2742
+ class: "group hidden w-[300px] shrink-0 md:block"
2743
+ }, {
2744
+ controls: withCtx((_, _push2, _parent2, _scopeId) => {
2745
+ if (_push2) {
2746
+ _push2(`<span${_scopeId}>`);
2747
+ if ($props.pictures.length > 6) {
2748
+ _push2(ssrRenderComponent(_component_CarouselControl, { class: "text-primary hover:bg-primary-300/60 !bottom-3 !left-1/2 -ml-5 size-10 rounded-full bg-white/60 text-xl opacity-0 shadow-sm ring-1 ring-black/5 group-hover:opacity-90" }, null, _parent2, _scopeId));
2749
+ } else {
2750
+ _push2(`<!---->`);
2751
+ }
2752
+ _push2(`<span class="absolute bottom-0 block h-2 w-full bg-gradient-to-b from-transparent to-white"${_scopeId}></span></span>`);
2753
+ } else {
2754
+ return [
2755
+ createVNode("span", null, [
2756
+ $props.pictures.length > 6 ? (openBlock(), createBlock(_component_CarouselControl, {
2757
+ key: 0,
2758
+ class: "text-primary hover:bg-primary-300/60 !bottom-3 !left-1/2 -ml-5 size-10 rounded-full bg-white/60 text-xl opacity-0 shadow-sm ring-1 ring-black/5 group-hover:opacity-90"
2759
+ })) : createCommentVNode("", true),
2760
+ createVNode("span", { class: "absolute bottom-0 block h-2 w-full bg-gradient-to-b from-transparent to-white" })
2761
+ ])
2762
+ ];
2763
+ }
2764
+ }),
2765
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2766
+ if (_push2) {
2767
+ _push2(`<!--[-->`);
2768
+ ssrRenderList(Math.ceil($props.pictures.length / 2), (i) => {
2769
+ _push2(`<li class="${ssrRenderClass([i === 1 && "pt-1", "grid w-full grid-cols-2 gap-3 px-1 pb-3"])}"${_scopeId}><!--[-->`);
2770
+ ssrRenderList([1, 2].map((ii) => (i - 1) * 2 + (ii - 1)), (index) => {
2771
+ _push2(`<!--[-->`);
2772
+ if (index < $props.pictures.length) {
2773
+ _push2(`<button class="bg-secondary-100 block rounded md:h-[175px]"${_scopeId}>`);
2774
+ _push2(ssrRenderComponent(_component_AImg, {
2775
+ picture: $props.pictures[index],
2776
+ class: ["ring-secondary/10 size-full rounded border-2 object-cover opacity-90 transition-colors", index === $setup.activeIndex ? "border-secondary/50 ring-4 cursor-auto" : "border-transparent hover:border-primary hover:ring-4 hover:ring-primary/20"]
2777
+ }, null, _parent2, _scopeId));
2778
+ _push2(`</button>`);
2779
+ } else {
2780
+ _push2(`<!---->`);
2781
+ }
2782
+ _push2(`<!--]-->`);
2783
+ });
2784
+ _push2(`<!--]--></li>`);
2785
+ });
2786
+ _push2(`<!--]-->`);
2787
+ } else {
2788
+ return [
2789
+ (openBlock(true), createBlock(Fragment, null, renderList(Math.ceil($props.pictures.length / 2), (i) => {
2790
+ return openBlock(), createBlock("li", {
2791
+ key: i,
2792
+ class: ["grid w-full grid-cols-2 gap-3 px-1 pb-3", i === 1 && "pt-1"]
2793
+ }, [
2794
+ (openBlock(true), createBlock(Fragment, null, renderList([1, 2].map((ii) => (i - 1) * 2 + (ii - 1)), (index) => {
2795
+ return openBlock(), createBlock(Fragment, {
2796
+ key: `${i}-${index}`
2797
+ }, [
2798
+ index < $props.pictures.length ? (openBlock(), createBlock("button", {
2799
+ key: 0,
2800
+ class: "bg-secondary-100 block rounded md:h-[175px]",
2801
+ onClick: ($event) => $setup.activeIndex = index
2802
+ }, [
2803
+ createVNode(_component_AImg, {
2804
+ picture: $props.pictures[index],
2805
+ class: ["ring-secondary/10 size-full rounded border-2 object-cover opacity-90 transition-colors", index === $setup.activeIndex ? "border-secondary/50 ring-4 cursor-auto" : "border-transparent hover:border-primary hover:ring-4 hover:ring-primary/20"]
2806
+ }, null, 8, ["picture", "class"])
2807
+ ], 8, ["onClick"])) : createCommentVNode("", true)
2808
+ ], 64);
2809
+ }), 128))
2810
+ ], 2);
2811
+ }), 128))
2812
+ ];
2813
+ }
2814
+ }),
2815
+ _: 1
2816
+ }, _parent));
2817
+ } else {
2818
+ _push(`<!---->`);
2819
+ }
2820
+ _push(`<div class="relative aspect-square h-full grow md:aspect-auto">`);
2821
+ _push(ssrRenderComponent(_component_Carousel, {
2822
+ as: "div",
2823
+ index: $setup.activeIndex,
2824
+ "onUpdate:index": ($event) => $setup.activeIndex = $event,
2825
+ class: ["text-base-600 [&_i]:i-arrow-right mx-auto size-full max-w-[525px] [&>*]:h-full [&_i]:mx-2 [&_i]:text-2xl", $setup.isLoadingLightbox && "opacity-80"],
2826
+ id: $setup.psId
2827
+ }, {
2828
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
2829
+ if (_push2) {
2830
+ _push2(`<!--[-->`);
2831
+ ssrRenderList($props.pictures, (picture, i) => {
2832
+ _push2(ssrRenderComponent(_component_ALink, {
2833
+ key: `big-${i}`,
2834
+ href: picture.zoom?.size && picture.zoom.url,
2835
+ "data-pswp-width": $setup.getImgSizes(picture.zoom || "").width,
2836
+ "data-pswp-height": $setup.getImgSizes(picture.zoom || "").height,
2837
+ target: "_blank",
2838
+ rel: "noreferrer",
2839
+ class: ["shrink-0 basis-full", picture.zoom?.size && "cursor-zoom-in"],
2840
+ onClick: () => picture.zoom?.size && $setup.zoom(i)
2841
+ }, {
2842
+ default: withCtx((_2, _push3, _parent3, _scopeId2) => {
2843
+ if (_push3) {
2844
+ _push3(ssrRenderComponent(_component_AImg, {
2845
+ picture,
2846
+ "preferred-size": "big",
2847
+ class: "size-full rounded object-cover",
2848
+ fetchpriority: i === 0 ? "high" : "low",
2849
+ loading: i === 0 ? "eager" : "lazy"
2850
+ }, null, _parent3, _scopeId2));
2851
+ } else {
2852
+ return [
2853
+ createVNode(_component_AImg, {
2854
+ picture,
2855
+ "preferred-size": "big",
2856
+ class: "size-full rounded object-cover",
2857
+ fetchpriority: i === 0 ? "high" : "low",
2858
+ loading: i === 0 ? "eager" : "lazy"
2859
+ }, null, 8, ["picture", "fetchpriority", "loading"])
2860
+ ];
2861
+ }
2862
+ }),
2863
+ _: 2
2864
+ }, _parent2, _scopeId));
2865
+ });
2866
+ _push2(`<!--]-->`);
2867
+ } else {
2868
+ return [
2869
+ (openBlock(true), createBlock(Fragment, null, renderList($props.pictures, (picture, i) => {
2870
+ return openBlock(), createBlock(_component_ALink, {
2871
+ key: `big-${i}`,
2872
+ href: picture.zoom?.size && picture.zoom.url,
2873
+ "data-pswp-width": $setup.getImgSizes(picture.zoom || "").width,
2874
+ "data-pswp-height": $setup.getImgSizes(picture.zoom || "").height,
2875
+ target: "_blank",
2876
+ rel: "noreferrer",
2877
+ class: ["shrink-0 basis-full", picture.zoom?.size && "cursor-zoom-in"],
2878
+ onClick: withModifiers(() => picture.zoom?.size && $setup.zoom(i), ["prevent"])
2879
+ }, {
2880
+ default: withCtx(() => [
2881
+ createVNode(_component_AImg, {
2882
+ picture,
2883
+ "preferred-size": "big",
2884
+ class: "size-full rounded object-cover",
2885
+ fetchpriority: i === 0 ? "high" : "low",
2886
+ loading: i === 0 ? "eager" : "lazy"
2887
+ }, null, 8, ["picture", "fetchpriority", "loading"])
2888
+ ]),
2889
+ _: 2
2890
+ }, 1032, ["href", "data-pswp-width", "data-pswp-height", "class", "onClick"]);
2891
+ }), 128))
2892
+ ];
2893
+ }
2894
+ }),
2895
+ _: 1
2896
+ }, _parent));
2897
+ if ($setup.isLoadingLightbox) {
2898
+ _push(`<i class="bg-base-200 i-arrow-path absolute left-1/2 top-1/2 -ml-7 -mt-7 size-14 animate-spin"${ssrRenderAttr("aria-label", "Carregando")}></i>`);
2899
+ } else {
2900
+ _push(`<!---->`);
2901
+ }
2902
+ if ($props.pictures.length > 1) {
2903
+ _push(`<ul class="mt-2 flex justify-center gap-1.5 md:hidden"><!--[-->`);
2904
+ ssrRenderList($props.pictures.length, (i) => {
2905
+ _push(`<li><button class="${ssrRenderClass([$setup.activeIndex !== i - 1 && "opacity-40", "bg-base-700 block h-1.5 w-3 rounded-full"])}"${ssrRenderAttr("aria-label", `${"Imagem"} ${i}`)}></button></li>`);
2906
+ });
2907
+ _push(`<!--]--></ul>`);
2908
+ } else {
2909
+ _push(`<!---->`);
2910
+ }
2911
+ _push(`</div></div>`);
2912
+ }
2913
+ const _sfc_setup$9 = _sfc_main$9.setup;
2914
+ _sfc_main$9.setup = (props, ctx) => {
2915
+ const ssrContext = useSSRContext();
2916
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/ImagesGallery.vue");
2917
+ return _sfc_setup$9 ? _sfc_setup$9(props, ctx) : void 0;
2918
+ };
2919
+ const ImagesGallery = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["ssrRender", _sfc_ssrRender$9]]);
2920
+
2921
+ const useSkuSelector = (props) => {
2922
+ const grids = shallowReactive(
2923
+ props.grids || globalThis.$storefront.data.grids || []
2924
+ );
2925
+ if (!grids.length && false) {
2926
+ window.addEventListener("storefront:data:grids", () => {
2927
+ globalThis.$storefront.data.grids?.forEach((grid) => grids.push(grid));
2928
+ }, { once: true });
2929
+ }
2930
+ const variationsGrids$1 = reactive({});
2931
+ const activeVariationsGrids = reactive({});
2932
+ watch(toRef(props, "variations"), () => {
2933
+ Object.assign(activeVariationsGrids, variationsGrids(props, void 0, true));
2934
+ const allVariationsGrids = variationsGrids(props);
2935
+ Object.keys(allVariationsGrids).forEach((gridId) => {
2936
+ if (activeVariationsGrids[gridId]) {
2937
+ variationsGrids$1[gridId] = activeVariationsGrids[gridId];
2938
+ } else {
2939
+ delete variationsGrids$1[gridId];
2940
+ }
2941
+ });
2942
+ }, { immediate: true });
2943
+ const orderedGridIds = computed(() => Object.keys(variationsGrids$1));
2944
+ const selectedOptions = reactive({});
2945
+ const variationId = ref();
2946
+ const selectOption = ({ optionText, gridId, gridIndex }) => {
2947
+ selectedOptions[gridId] = optionText;
2948
+ const filteredGrids = {};
2949
+ for (let i = 0; i <= gridIndex; i++) {
2950
+ const _gridId = orderedGridIds[i];
2951
+ if (selectedOptions[_gridId]) {
2952
+ filteredGrids[_gridId] = selectedOptions[_gridId];
2953
+ }
2954
+ }
2955
+ const nextFilteredGrids = variationsGrids(props, filteredGrids, true);
2956
+ for (let i = gridIndex + 1; i < orderedGridIds.value.length; i++) {
2957
+ const _gridId = orderedGridIds[i];
2958
+ const options = nextFilteredGrids[_gridId];
2959
+ activeVariationsGrids[_gridId] = options;
2960
+ if (selectedOptions[_gridId] && !options.includes(selectedOptions[_gridId])) {
2961
+ delete selectedOptions[_gridId];
2962
+ }
2963
+ }
2964
+ const variations = props.variations.slice(0);
2965
+ for (let i = 0; i < variations.length; i++) {
2966
+ const variation = variations[i];
2967
+ const { specifications } = variation;
2968
+ const gridIds = Object.keys(specifications);
2969
+ for (let ii = 0; ii < gridIds.length; ii++) {
2970
+ const _gridId = gridIds[ii];
2971
+ if (selectedOptions[_gridId] !== specTextValue(variation, _gridId)) {
2972
+ variations.splice(i, 1);
2973
+ i -= 1;
2974
+ break;
2975
+ }
2976
+ }
2977
+ }
2978
+ variationId.value = variations[0]?._id || null;
2979
+ };
2980
+ watch(toRef(props, "variationId"), (_variationId) => {
2981
+ if (!_variationId || _variationId === variationId.value) {
2982
+ return;
2983
+ }
2984
+ const selectedVariation = props.variations.find((variation) => {
2985
+ return variation._id === _variationId;
2986
+ });
2987
+ if (!selectedVariation) {
2988
+ variationId.value = null;
2989
+ return;
2990
+ }
2991
+ const { specifications } = selectedVariation;
2992
+ const specs = Object.keys(specifications);
2993
+ const nextSpec = (specIndex = 0) => {
2994
+ const gridId = specs[specIndex];
2995
+ if (specs[specIndex] && specifications[gridId] && specifications[gridId].length === 1) {
2996
+ const optionText = specifications[gridId][0].text;
2997
+ if (variationsGrids$1[gridId].find((option) => option === optionText)) {
2998
+ selectOption({
2999
+ optionText,
3000
+ gridId,
3001
+ gridIndex: orderedGridIds.value.indexOf(gridId)
3002
+ });
3003
+ nextSpec(specIndex + 1);
3004
+ }
3005
+ }
3006
+ };
3007
+ nextSpec();
3008
+ }, { immediate: true });
3009
+ const getGridTitle = (gridId) => {
3010
+ return gridTitle(gridId, grids);
3011
+ };
3012
+ const getColorOptionBg = (optionText) => {
3013
+ const rgbs = optionText.split(",").map((colorName) => {
3014
+ return specValueByText(props.variations, colorName.trim(), "colors");
3015
+ });
3016
+ return rgbs.length > 1 ? `background:linear-gradient(to right bottom, ${rgbs[0]} 50%, ${rgbs[1]} 50%)` : `background:${rgbs[0]}`;
3017
+ };
3018
+ return {
3019
+ grids,
3020
+ variationsGrids: variationsGrids$1,
3021
+ activeVariationsGrids,
3022
+ selectOption,
3023
+ selectedOptions,
3024
+ variationId,
3025
+ getGridTitle,
3026
+ getColorOptionBg
3027
+ };
3028
+ };
3029
+
3030
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
3031
+ __name: "SkuSelector",
3032
+ props: {
3033
+ variations: {},
3034
+ variationId: {},
3035
+ grids: {}
3036
+ },
3037
+ emits: ["update:variationId"],
3038
+ setup(__props, { expose: __expose, emit: __emit }) {
3039
+ __expose();
3040
+ const props = __props;
3041
+ const emit = __emit;
3042
+ const {
3043
+ variationsGrids,
3044
+ activeVariationsGrids,
3045
+ selectOption,
3046
+ selectedOptions,
3047
+ variationId,
3048
+ getGridTitle,
3049
+ getColorOptionBg
3050
+ } = useSkuSelector(props);
3051
+ watch(variationId, (_id) => {
3052
+ emit("update:variationId", _id);
3053
+ });
3054
+ const __returned__ = { props, emit, variationsGrids, activeVariationsGrids, selectOption, selectedOptions, variationId, getGridTitle, getColorOptionBg };
3055
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
3056
+ return __returned__;
3057
+ }
3058
+ });
3059
+ function _sfc_ssrRender$8(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
3060
+ _push(`<div${ssrRenderAttrs(_attrs)}><!--[-->`);
3061
+ ssrRenderList($setup.variationsGrids, (options, gridId) => {
3062
+ _push(`<div class="mt-3"><span class="text-base-700 text-sm font-medium">${ssrInterpolate($setup.getGridTitle(gridId))}: `);
3063
+ if ($setup.selectedOptions[gridId]) {
3064
+ _push(`<strong class="text-base-800">${ssrInterpolate($setup.selectedOptions[gridId])}</strong>`);
3065
+ } else {
3066
+ _push(`<!---->`);
3067
+ }
3068
+ _push(`</span>`);
3069
+ if (options.length < 7) {
3070
+ _push(`<ul class="mt-2 flex gap-2"><!--[-->`);
3071
+ ssrRenderList(options, (optionText, i) => {
3072
+ _push(`<li><button class="${ssrRenderClass([[
3073
+ $setup.selectedOptions[gridId] === optionText ? "border-primary ring-2" : null,
3074
+ gridId === "colors" ? "size-9 text-[0px]" : "px-2.5 py-2 leading-none",
3075
+ $setup.activeVariationsGrids[gridId].includes(optionText) ? "border-primary-400 bg-primary-100 text-primary-950" : "border-primary-300 bg-primary-200 text-primary-600"
3076
+ ], "ring-primary/60 rounded border"])}" style="${ssrRenderStyle(gridId === "colors" && $setup.getColorOptionBg(optionText))}">${ssrInterpolate(optionText)}</button></li>`);
3077
+ });
3078
+ _push(`<!--]--></ul>`);
3079
+ } else {
3080
+ _push(`<!---->`);
3081
+ }
3082
+ _push(`</div>`);
3083
+ });
3084
+ _push(`<!--]--></div>`);
3085
+ }
3086
+ const _sfc_setup$8 = _sfc_main$8.setup;
3087
+ _sfc_main$8.setup = (props, ctx) => {
3088
+ const ssrContext = useSSRContext();
3089
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/SkuSelector.vue");
3090
+ return _sfc_setup$8 ? _sfc_setup$8(props, ctx) : void 0;
3091
+ };
3092
+ const SkuSelector = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["ssrRender", _sfc_ssrRender$8]]);
3093
+
3094
+ const localStorage$1 = typeof window === "object" && window.localStorage;
3095
+ const ZIP_STORAGE_KEY = "shipping-to-zip";
3096
+ const sortApps = (results, order) => {
3097
+ return results.sort((a, b) => {
3098
+ if (a.app_id === b.app_id) {
3099
+ return 0;
3100
+ }
3101
+ const indexA = order.indexOf(a.app_id);
3102
+ const indexB = order.indexOf(b.app_id);
3103
+ if (indexA > -1) {
3104
+ if (indexB > -1) {
3105
+ return indexA < indexB ? -1 : 1;
3106
+ }
3107
+ return -1;
3108
+ }
3109
+ if (indexB > -1)
3110
+ return 1;
3111
+ return 0;
3112
+ });
3113
+ };
3114
+ const reduceItemBody = (itemOrProduct) => {
3115
+ if (!itemOrProduct.product_id) {
3116
+ itemOrProduct.product_id = itemOrProduct._id;
3117
+ }
3118
+ const shippedItem = {};
3119
+ const fields = [
3120
+ "product_id",
3121
+ "variation_id",
3122
+ "sku",
3123
+ "name",
3124
+ "quantity",
3125
+ "inventory",
3126
+ "currency_id",
3127
+ "currency_symbol",
3128
+ "price",
3129
+ "final_price",
3130
+ "dimensions",
3131
+ "weight"
3132
+ ];
3133
+ fields.forEach((field) => {
3134
+ if (itemOrProduct[field] !== void 0) {
3135
+ shippedItem[field] = itemOrProduct[field];
3136
+ }
3137
+ });
3138
+ return shippedItem;
3139
+ };
3140
+ const useShippingCalculator = (props) => {
3141
+ const zipCode = props.zipCode || ref("");
3142
+ if (!zipCode.value && localStorage$1) {
3143
+ const storedZip = localStorage$1.getItem(ZIP_STORAGE_KEY);
3144
+ if (storedZip) {
3145
+ zipCode.value = storedZip;
3146
+ }
3147
+ }
3148
+ const countryCode = props.countryCode || config.get().countryCode;
3149
+ const _shippedItems = toRef(props, "shippedItems");
3150
+ const shippedItems = computed(() => {
3151
+ return _shippedItems.value?.map(reduceItemBody) || [];
3152
+ });
3153
+ const amountSubtotal = computed(() => {
3154
+ return shippedItems.value.reduce((subtotal, item) => {
3155
+ return subtotal + price(item) * item.quantity;
3156
+ }, 0);
3157
+ });
3158
+ const isFetching = ref(false);
3159
+ const fetchShippingServices = useDebounceFn((isRetry) => {
3160
+ if (isFetching.value) {
3161
+ const unwatch = watch(isFetching, (_isFetching) => {
3162
+ if (!_isFetching) {
3163
+ fetchShippingServices();
3164
+ unwatch();
3165
+ }
3166
+ });
3167
+ return;
3168
+ }
3169
+ const body = {
3170
+ ...props.baseParams,
3171
+ to: {
3172
+ ...props.baseParams?.to,
3173
+ zip: zipCode.value
3174
+ }
3175
+ };
3176
+ if (shippedItems.value.length) {
3177
+ body.items = shippedItems.value;
3178
+ body.subtotal = amountSubtotal.value;
3179
+ }
3180
+ isFetching.value = true;
3181
+ fetchModule("calculate_shipping", {
3182
+ method: "POST",
3183
+ params: {
3184
+ skip_ids: props.skippedAppIds
3185
+ },
3186
+ body
3187
+ }).then(async (response) => {
3188
+ if (response.status === 501)
3189
+ return;
3190
+ const data = await response.json();
3191
+ parseShippingResult(data.result, isRetry);
3192
+ }).catch((err) => {
3193
+ if (!isRetry) {
3194
+ scheduleRetry(4e3);
3195
+ }
3196
+ console.error(err);
3197
+ }).finally(() => {
3198
+ isFetching.value = false;
3199
+ });
3200
+ }, 100);
3201
+ let retryTimer = null;
3202
+ const scheduleRetry = (timeout = 1e4) => {
3203
+ if (retryTimer)
3204
+ clearTimeout(retryTimer);
3205
+ retryTimer = setTimeout(() => {
3206
+ fetchShippingServices(true);
3207
+ }, timeout);
3208
+ };
3209
+ const shippingServices = shallowReactive([]);
3210
+ const freeFromValue = ref(null);
3211
+ const hasPaidOption = ref();
3212
+ const parseShippingResult = (shippingResult = [], isRetry = false) => {
3213
+ freeFromValue.value = null;
3214
+ shippingServices.splice(0);
3215
+ if (shippingResult.length) {
3216
+ let hasSomeFailedApp = false;
3217
+ shippingResult.forEach((appResult) => {
3218
+ const { validated, error, response } = appResult;
3219
+ if (!validated || error) {
3220
+ hasSomeFailedApp = true;
3221
+ return;
3222
+ }
3223
+ if (props.skippedAppIds?.includes(appResult.app_id)) {
3224
+ return;
3225
+ }
3226
+ response.shipping_services.forEach((service) => {
3227
+ shippingServices.push({
3228
+ app_id: appResult.app_id,
3229
+ ...service
3230
+ });
3231
+ });
3232
+ const freeShippingFromValue = response.free_shipping_from_value;
3233
+ if (freeShippingFromValue && (!freeFromValue.value || freeFromValue.value > freeShippingFromValue)) {
3234
+ freeFromValue.value = freeShippingFromValue;
3235
+ }
3236
+ });
3237
+ if (!shippingServices.length) {
3238
+ if (hasSomeFailedApp) {
3239
+ if (!isRetry) {
3240
+ fetchShippingServices(true);
3241
+ } else {
3242
+ scheduleRetry();
3243
+ }
3244
+ }
3245
+ return;
3246
+ }
3247
+ shippingServices.sort((a, b) => {
3248
+ const lineA = a.shipping_line;
3249
+ const lineB = b.shipping_line;
3250
+ const priceDiff = lineA.total_price - lineB.total_price;
3251
+ if (priceDiff < 0)
3252
+ return -1;
3253
+ if (priceDiff > 0)
3254
+ return 1;
3255
+ return lineA.delivery_time?.days < lineB.delivery_time?.days ? -1 : 1;
3256
+ });
3257
+ hasPaidOption.value = Boolean(shippingServices.find((service) => {
3258
+ return service.shipping_line.total_price || service.shipping_line.price;
3259
+ }));
3260
+ const appIdsOrder = props.appIdsOrder || globalThis.ecomShippingApps || [];
3261
+ if (Array.isArray(appIdsOrder) && appIdsOrder.length) {
3262
+ sortApps(shippingServices, appIdsOrder);
3263
+ }
3264
+ }
3265
+ };
3266
+ const submitZipCode = () => {
3267
+ const _zipCode = zipCode.value;
3268
+ if (countryCode === "BR") {
3269
+ if (_zipCode?.replace(/\D/g, "").length !== 8)
3270
+ return;
3271
+ } else if (!_zipCode) {
3272
+ return;
3273
+ }
3274
+ if (localStorage$1) {
3275
+ localStorage$1.setItem(ZIP_STORAGE_KEY, _zipCode);
3276
+ }
3277
+ fetchShippingServices();
3278
+ };
3279
+ watch(zipCode, (value) => {
3280
+ if (value.length) {
3281
+ if (countryCode === "BR") {
3282
+ const fmt = value.replace(/\D/g, "");
3283
+ if (fmt.length > 5) {
3284
+ zipCode.value = fmt.substring(0, 5) + "-" + fmt.substring(5, 8);
3285
+ if (props.canAutoSubmit)
3286
+ submitZipCode();
3287
+ }
3288
+ } else {
3289
+ zipCode.value = value.substring(0, 30);
3290
+ }
3291
+ }
3292
+ }, {
3293
+ immediate: !props.shippingResult
3294
+ });
3295
+ watch(toRef(props, "shippingResult"), (shippingResult) => {
3296
+ if (!shippingResult?.length)
3297
+ return;
3298
+ parseShippingResult(shippingResult);
3299
+ }, {
3300
+ immediate: true
3301
+ });
3302
+ const productionDeadline = computed(() => {
3303
+ let maxDeadline = 0;
3304
+ _shippedItems.value?.forEach((item) => {
3305
+ if (item.quantity && item.production_time) {
3306
+ const { days, cumulative } = item.production_time;
3307
+ const itemDeadline = cumulative ? days * item.quantity : days;
3308
+ if (itemDeadline > maxDeadline) {
3309
+ maxDeadline = itemDeadline;
3310
+ }
3311
+ }
3312
+ });
3313
+ return maxDeadline;
3314
+ });
3315
+ const getShippingDeadline = (shipping) => {
3316
+ const isWorkingDays = Boolean(shipping.posting_deadline?.working_days || shipping.delivery_time?.working_days);
3317
+ let days = shipping.posting_deadline?.days || 0;
3318
+ if (shipping.delivery_time) {
3319
+ days += shipping.delivery_time.days;
3320
+ }
3321
+ days += productionDeadline.value;
3322
+ if (days > 1) {
3323
+ return `${i19upTo} ${days} ` + (isWorkingDays ? i19workingDays : i19days).toLowerCase();
3324
+ }
3325
+ if (days === 1)
3326
+ return i19untilTomorrow;
3327
+ return shipping.pick_up ? i19pickUpToday : i19receiveToday;
3328
+ };
3329
+ const getShippingPrice = (shipping) => {
3330
+ const freight = typeof shipping.total_price === "number" ? shipping.total_price : shipping.price;
3331
+ if (freight)
3332
+ return formatMoney(freight);
3333
+ return shipping.pick_up ? i19free : i19freeShipping;
3334
+ };
3335
+ return {
3336
+ zipCode,
3337
+ shippedItems,
3338
+ amountSubtotal,
3339
+ submitZipCode,
3340
+ fetchShippingServices,
3341
+ isFetching,
3342
+ freeFromValue,
3343
+ shippingServices,
3344
+ parseShippingResult,
3345
+ productionDeadline,
3346
+ getShippingDeadline,
3347
+ getShippingPrice
3348
+ };
3349
+ };
3350
+
3351
+ const _sfc_main$7 = {};
3352
+
3353
+ function _sfc_ssrRender$7(_ctx, _push, _parent, _attrs) {
3354
+ _push(`<div${ssrRenderAttrs(mergeProps({ role: "status" }, _attrs))}><svg aria-hidden="true" class="size-8 max-h-full max-w-full animate-spin fill-secondary text-base-300" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"></path><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"></path></svg><span class="sr-only">Loading...</span></div>`);
3355
+ }
3356
+ const _sfc_setup$7 = _sfc_main$7.setup;
3357
+ _sfc_main$7.setup = (props, ctx) => {
3358
+ const ssrContext = useSSRContext()
3359
+ ;(ssrContext.modules || (ssrContext.modules = new Set())).add("src/lib/components/Spinner.vue");
3360
+ return _sfc_setup$7 ? _sfc_setup$7(props, ctx) : undefined
3361
+ };
3362
+ const Spinner = /*#__PURE__*/_export_sfc(_sfc_main$7, [['ssrRender',_sfc_ssrRender$7]]);
3363
+
3364
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3365
+ __name: "ShippingCalculator",
3366
+ props: {
3367
+ hasLabel: { type: Boolean },
3368
+ zipCode: {},
3369
+ canAutoSubmit: { type: Boolean },
3370
+ countryCode: {},
3371
+ shippedItems: {},
3372
+ shippingResult: {},
3373
+ baseParams: {},
3374
+ skippedAppIds: {},
3375
+ appIdsOrder: {}
3376
+ },
3377
+ setup(__props, { expose: __expose }) {
3378
+ __expose();
3379
+ const props = __props;
3380
+ const zipCode = ref("");
3381
+ const zipInputId = useId("ZipInput");
3382
+ const {
3383
+ isFetching,
3384
+ fetchShippingServices,
3385
+ shippingServices,
3386
+ getShippingDeadline,
3387
+ getShippingPrice
3388
+ } = useShippingCalculator({ ...props, zipCode });
3389
+ const isMounted = ref(false);
3390
+ onMounted(() => {
3391
+ isMounted.value = true;
3392
+ });
3393
+ const __returned__ = { props, zipCode, zipInputId, isFetching, fetchShippingServices, shippingServices, getShippingDeadline, getShippingPrice, isMounted, Spinner };
3394
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
3395
+ return __returned__;
3396
+ }
3397
+ });
3398
+ function _sfc_ssrRender$6(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
3399
+ const _component_ALink = resolveComponent("ALink");
3400
+ const _component_Fade = resolveComponent("Fade");
3401
+ _push(`<div${ssrRenderAttrs(mergeProps({ class: "max-w-sm" }, _attrs))}><form class="group"><label${ssrRenderAttr("for", $setup.zipInputId)} class="${ssrRenderClass($props.hasLabel ? "lg:text-sm text-base-700 flex flex-wrap gap-x-5 items-center mb-1.5" : "sr-only")}"><span>${ssrInterpolate("Calcular frete")}</span>`);
3402
+ if ($props.hasLabel && _ctx.$settings.countryCode === "BR") {
3403
+ _push(ssrRenderComponent(_component_ALink, {
3404
+ href: "https://buscacepinter.correios.com.br/app/endereco/index.php",
3405
+ class: "ui-link text-base-500 text-xs font-normal"
3406
+ }, {
3407
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3408
+ if (_push2) {
3409
+ _push2(` N\xE3o sei meu CEP <i class="i-arrow-top-right-on-square mr-1 opacity-50"${_scopeId}></i>`);
3410
+ } else {
3411
+ return [
3412
+ createTextVNode(" N\xE3o sei meu CEP "),
3413
+ createVNode("i", { class: "i-arrow-top-right-on-square mr-1 opacity-50" })
3414
+ ];
3415
+ }
3416
+ }),
3417
+ _: 1
3418
+ }, _parent));
3419
+ } else {
3420
+ _push(`<!---->`);
3421
+ }
3422
+ _push(`</label><div class="relative max-w-52"><input${ssrRenderAttr("id", $setup.zipInputId)} type="tel"${ssrIncludeBooleanAttr($setup.isFetching) ? " readonly" : ""}${ssrRenderAttr("value", $setup.zipCode)} placeholder="12345-123" class="${ssrRenderClass([$setup.isFetching && "bg-base-50", "w-full"])}"><button class="${ssrRenderClass([$setup.isMounted && !$setup.shippingServices.length && $setup.zipCode.length > 1 ? "text-primary" : `${$props.hasLabel ? "text-base-400" : "text-base-600"}`, "hover:text-primary group-focus-within:text-primary absolute inset-y-0 end-0 grid w-12 place-content-center text-xl"])}"${ssrRenderAttr("aria-label", "Calcular frete")}>`);
3423
+ if ($setup.isFetching) {
3424
+ _push(ssrRenderComponent($setup["Spinner"], { class: "size-5" }, null, _parent));
3425
+ } else {
3426
+ _push(`<i class="i-truck"></i>`);
3427
+ }
3428
+ _push(`</button></div></form>`);
3429
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
3430
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3431
+ if (_push2) {
3432
+ if (!$setup.isFetching && $setup.shippingServices.length) {
3433
+ _push2(`<ul class="divide-base-200 bg-base-50/50 border-base-100 mt-2 grow divide-y rounded border px-3 py-1"${_scopeId}><!--[-->`);
3434
+ ssrRenderList($setup.shippingServices, ({ label, shipping_line: shipping }, i) => {
3435
+ _push2(`<li class="text-base-800 py-2.5 md:text-sm"${_scopeId}><div class="flex flex-wrap items-center"${_scopeId}><div class="grow"${_scopeId}><strong class="mr-2 font-semibold"${_scopeId}>${ssrInterpolate($setup.getShippingDeadline(shipping))}</strong><span class="mr-2"${_scopeId}>${ssrInterpolate($setup.getShippingPrice(shipping))}</span></div><small class="text-base-600"${_scopeId}>${ssrInterpolate(label)}</small></div>`);
3436
+ if (shipping.delivery_instructions) {
3437
+ _push2(`<small class="text-base-700"${_scopeId}>${ssrInterpolate(shipping.delivery_instructions)}</small>`);
3438
+ } else {
3439
+ _push2(`<!---->`);
3440
+ }
3441
+ _push2(`</li>`);
3442
+ });
3443
+ _push2(`<!--]--></ul>`);
3444
+ } else {
3445
+ _push2(`<!---->`);
3446
+ }
3447
+ } else {
3448
+ return [
3449
+ !$setup.isFetching && $setup.shippingServices.length ? (openBlock(), createBlock("ul", {
3450
+ key: 0,
3451
+ class: "divide-base-200 bg-base-50/50 border-base-100 mt-2 grow divide-y rounded border px-3 py-1"
3452
+ }, [
3453
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.shippingServices, ({ label, shipping_line: shipping }, i) => {
3454
+ return openBlock(), createBlock("li", {
3455
+ key: `${$setup.zipCode}-${i}`,
3456
+ class: "text-base-800 py-2.5 md:text-sm"
3457
+ }, [
3458
+ createVNode("div", { class: "flex flex-wrap items-center" }, [
3459
+ createVNode("div", { class: "grow" }, [
3460
+ createVNode("strong", { class: "mr-2 font-semibold" }, toDisplayString($setup.getShippingDeadline(shipping)), 1),
3461
+ createVNode("span", { class: "mr-2" }, toDisplayString($setup.getShippingPrice(shipping)), 1)
3462
+ ]),
3463
+ createVNode("small", { class: "text-base-600" }, toDisplayString(label), 1)
3464
+ ]),
3465
+ shipping.delivery_instructions ? (openBlock(), createBlock("small", {
3466
+ key: 0,
3467
+ class: "text-base-700"
3468
+ }, toDisplayString(shipping.delivery_instructions), 1)) : createCommentVNode("", true)
3469
+ ]);
3470
+ }), 128))
3471
+ ])) : createCommentVNode("", true)
3472
+ ];
3473
+ }
3474
+ }),
3475
+ _: 1
3476
+ }, _parent));
3477
+ _push(`</div>`);
3478
+ }
3479
+ const _sfc_setup$6 = _sfc_main$6.setup;
3480
+ _sfc_main$6.setup = (props, ctx) => {
3481
+ const ssrContext = useSSRContext();
3482
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/ShippingCalculator.vue");
3483
+ return _sfc_setup$6 ? _sfc_setup$6(props, ctx) : void 0;
3484
+ };
3485
+ const ShippingCalculator = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["ssrRender", _sfc_ssrRender$6]]);
3486
+
3487
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3488
+ __name: "ProductDetails",
3489
+ props: {
3490
+ product: { default: () => globalThis.$storefront.apiContext?.doc },
3491
+ cmsPreview: {}
3492
+ },
3493
+ setup(__props, { expose: __expose }) {
3494
+ __expose();
3495
+ const props = __props;
3496
+ const {
3497
+ product,
3498
+ title,
3499
+ isActive
3500
+ } = useProductCard(props);
3501
+ const quantity = ref(product.min_quantity || 1);
3502
+ const params = useUrlSearchParams("history");
3503
+ const hasSkuSelectionAlert = ref(false);
3504
+ const variationId = ref(null);
3505
+ watch(variationId, (_variationId) => {
3506
+ if (_variationId) {
3507
+ params.var = _variationId;
3508
+ hasSkuSelectionAlert.value = false;
3509
+ }
3510
+ });
3511
+ onMounted(() => {
3512
+ watch(params, ({ var: variation }) => {
3513
+ if (typeof variation === "string" && variation) {
3514
+ variationId.value = variation;
3515
+ }
3516
+ }, { immediate: true });
3517
+ });
3518
+ const isSkuSelected = computed(() => {
3519
+ return Boolean(!product.variations?.length || variationId.value);
3520
+ });
3521
+ const checkVariation = (ev) => {
3522
+ if (!isSkuSelected.value) {
3523
+ if (ev)
3524
+ ev.preventDefault();
3525
+ hasSkuSelectionAlert.value = true;
3526
+ } else {
3527
+ hasSkuSelectionAlert.value = false;
3528
+ }
3529
+ return !hasSkuSelectionAlert.value;
3530
+ };
3531
+ const addToCart = () => {
3532
+ if (!checkVariation())
3533
+ return;
3534
+ addProductToCart(product, variationId.value || void 0, quantity.value);
3535
+ };
3536
+ const __returned__ = { props, product, title, isActive, quantity, params, hasSkuSelectionAlert, variationId, isSkuSelected, checkVariation, addToCart, CheckoutLink, QuantitySelector, Prices, ImagesGallery, SkuSelector, ShippingCalculator };
3537
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
3538
+ return __returned__;
3539
+ }
3540
+ });
3541
+ function _sfc_ssrRender$5(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
3542
+ const _component_Fade = resolveComponent("Fade");
3543
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "relative grid grid-cols-1 items-start gap-x-5 ui-section lg:grid-cols-4 lg:gap-x-4 2xl:gap-x-6" }, _attrs))}><div class="w-full lg:col-span-3">`);
3544
+ if ($setup.product.pictures?.length) {
3545
+ _push(ssrRenderComponent($setup["ImagesGallery"], {
3546
+ pictures: $setup.product.pictures,
3547
+ class: "mb-5"
3548
+ }, null, _parent));
3549
+ } else {
3550
+ _push(`<!---->`);
3551
+ }
3552
+ _push(`</div><div class="top-0 pt-4 transition-transform lg:sticky lg:pb-4 lg:sticky-header:translate-y-14"><h1 class="text-lg text-secondary-900 ui-text-brand">${ssrInterpolate($setup.title)}</h1>`);
3553
+ if ($setup.isActive) {
3554
+ _push(`<div class="mt-5">`);
3555
+ _push(ssrRenderComponent($setup["Prices"], {
3556
+ product: $setup.product,
3557
+ "is-big": "",
3558
+ "is-literal": ""
3559
+ }, null, _parent));
3560
+ if ($setup.product.variations) {
3561
+ _push(ssrRenderComponent($setup["SkuSelector"], {
3562
+ variations: $setup.product.variations,
3563
+ "variation-id": $setup.variationId,
3564
+ "onUpdate:variationId": ($event) => $setup.variationId = $event,
3565
+ class: "my-4"
3566
+ }, null, _parent));
3567
+ } else {
3568
+ _push(`<!---->`);
3569
+ }
3570
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
3571
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3572
+ if (_push2) {
3573
+ if ($setup.hasSkuSelectionAlert) {
3574
+ _push2(`<div class="inline-block ui-alert"${_scopeId}>${ssrInterpolate("Por favor selecione uma op\xE7\xE3o em cada campo acima")} <i class="ml-1 -rotate-90 i-arrow-right"${_scopeId}></i></div>`);
3575
+ } else {
3576
+ _push2(`<!---->`);
3577
+ }
3578
+ } else {
3579
+ return [
3580
+ $setup.hasSkuSelectionAlert ? (openBlock(), createBlock("div", {
3581
+ key: 0,
3582
+ class: "inline-block ui-alert"
3583
+ }, [
3584
+ createTextVNode(toDisplayString("Por favor selecione uma op\xE7\xE3o em cada campo acima") + " "),
3585
+ createVNode("i", { class: "ml-1 -rotate-90 i-arrow-right" })
3586
+ ])) : createCommentVNode("", true)
3587
+ ];
3588
+ }
3589
+ }),
3590
+ _: 1
3591
+ }, _parent));
3592
+ _push(`<div class="mt-5 flex flex-wrap items-center gap-x-4 gap-y-2 md:flex-nowrap lg:mt-4 lg:flex-wrap">`);
3593
+ _push(ssrRenderComponent($setup["QuantitySelector"], {
3594
+ modelValue: $setup.quantity,
3595
+ "onUpdate:modelValue": ($event) => $setup.quantity = $event,
3596
+ min: $setup.product.min_quantity,
3597
+ max: $setup.product.quantity,
3598
+ class: "rounded border-base-100 md:mr-5 lg:mb-2 lg:mr-auto lg:border-2"
3599
+ }, null, _parent));
3600
+ _push(ssrRenderComponent($setup["CheckoutLink"], {
3601
+ class: "grow text-center ui-btn-lg ui-btn-primary",
3602
+ to: "checkout",
3603
+ "cart-item": {
3604
+ product_id: $setup.product._id,
3605
+ quantity: $setup.quantity,
3606
+ variation_id: $setup.variationId || void 0
3607
+ },
3608
+ "data-tooltip": !$setup.isSkuSelected ? "Escolha os detalhes do produto para comprar" : null,
3609
+ onClick: $setup.checkVariation
3610
+ }, {
3611
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3612
+ if (_push2) {
3613
+ _push2(`<i class="mr-1 i-chevron-double-right"${_scopeId}></i> ${ssrInterpolate("Comprar")}`);
3614
+ } else {
3615
+ return [
3616
+ createVNode("i", { class: "mr-1 i-chevron-double-right" }),
3617
+ createTextVNode(" " + toDisplayString("Comprar"))
3618
+ ];
3619
+ }
3620
+ }),
3621
+ _: 1
3622
+ }, _parent));
3623
+ _push(`<button class="grow ui-btn-lg ui-btn-contrast"${ssrRenderAttr("data-tooltip", !$setup.isSkuSelected ? "Escolha os detalhes do produto para comprar" : null)}>${ssrInterpolate("Adicionar ao carrinho")}</button></div><div class="mt-6 rounded border-2 border-base-50 border-t-base-100 p-4 lg:mt-4">`);
3624
+ _push(ssrRenderComponent($setup["ShippingCalculator"], {
3625
+ "shipped-items": [{ ...$setup.product, quantity: $setup.quantity }],
3626
+ "has-label": ""
3627
+ }, null, _parent));
3628
+ _push(`</div></div>`);
3629
+ } else {
3630
+ _push(`<!---->`);
3631
+ }
3632
+ _push(`</div><div class="w-full lg:col-span-3">`);
3633
+ ssrRenderSlot(_ctx.$slots, "description", {}, null, _push, _parent);
3634
+ _push(`</div></section>`);
3635
+ }
3636
+ const _sfc_setup$5 = _sfc_main$5.setup;
3637
+ _sfc_main$5.setup = (props, ctx) => {
3638
+ const ssrContext = useSSRContext();
3639
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/ProductDetails.vue");
3640
+ return _sfc_setup$5 ? _sfc_setup$5(props, ctx) : void 0;
3641
+ };
3642
+ const ProductDetails = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["ssrRender", _sfc_ssrRender$5]]);
3643
+
3644
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3645
+ __name: "ProductSpecifications",
3646
+ props: {
3647
+ product: { default: () => globalThis.$storefront.apiContext?.doc },
3648
+ title: {}
3649
+ },
3650
+ setup(__props, { expose: __expose }) {
3651
+ __expose();
3652
+ const props = __props;
3653
+ const specifications = computed(() => props.product.specifications || {});
3654
+ const hasSpecs = computed(() => Object.keys(specifications.value).length);
3655
+ const { grids } = globalThis.$storefront.data;
3656
+ const __returned__ = { props, specifications, hasSpecs, grids, get getGridTitle() {
3657
+ return gridTitle;
3658
+ }, get getSpecTextValue() {
3659
+ return specTextValue;
3660
+ }, Collapse };
3661
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
3662
+ return __returned__;
3663
+ }
3664
+ });
3665
+ function _sfc_ssrRender$4(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
3666
+ if ($setup.hasSpecs) {
3667
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "ui-section" }, _attrs))}>`);
3668
+ _push(ssrRenderComponent($setup["Collapse"], {
3669
+ title: $props.title || "Especifica\xE7\xF5es"
3670
+ }, {
3671
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3672
+ if (_push2) {
3673
+ _push2(`<ul${_scopeId}><!--[-->`);
3674
+ ssrRenderList($setup.specifications, (grid, gridId) => {
3675
+ _push2(`<li class="border-base-200 grid grid-cols-2 border-dashed py-2 sm:grid-cols-3 [&amp;:not(:last-child)]:border-b"${_scopeId}><span class="text-base-700"${_scopeId}>${ssrInterpolate($setup.getGridTitle(`${gridId}`, $setup.grids || []))}</span><strong class="font-semibold sm:col-span-2"${_scopeId}>${ssrInterpolate($setup.getSpecTextValue($props.product, `${gridId}`, $setup.grids))}</strong></li>`);
3676
+ });
3677
+ _push2(`<!--]--></ul>`);
3678
+ } else {
3679
+ return [
3680
+ createVNode("ul", null, [
3681
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.specifications, (grid, gridId) => {
3682
+ return openBlock(), createBlock("li", {
3683
+ key: gridId,
3684
+ class: "border-base-200 grid grid-cols-2 border-dashed py-2 sm:grid-cols-3 [&:not(:last-child)]:border-b"
3685
+ }, [
3686
+ createVNode("span", { class: "text-base-700" }, toDisplayString($setup.getGridTitle(`${gridId}`, $setup.grids || [])), 1),
3687
+ createVNode("strong", { class: "font-semibold sm:col-span-2" }, toDisplayString($setup.getSpecTextValue($props.product, `${gridId}`, $setup.grids)), 1)
3688
+ ]);
3689
+ }), 128))
3690
+ ])
3691
+ ];
3692
+ }
3693
+ }),
3694
+ _: 1
3695
+ }, _parent));
3696
+ _push(`</section>`);
3697
+ } else {
3698
+ _push(`<!---->`);
3699
+ }
3700
+ }
3701
+ const _sfc_setup$4 = _sfc_main$4.setup;
3702
+ _sfc_main$4.setup = (props, ctx) => {
3703
+ const ssrContext = useSSRContext();
3704
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/ProductSpecifications.vue");
3705
+ return _sfc_setup$4 ? _sfc_setup$4(props, ctx) : void 0;
3706
+ };
3707
+ const ProductSpecifications = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["ssrRender", _sfc_ssrRender$4]]);
3708
+
3709
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3710
+ __name: "SearchFilters",
3711
+ props: {
3712
+ searchEngine: {},
3713
+ fixedParams: {}
3714
+ },
3715
+ setup(__props, { expose: __expose }) {
3716
+ __expose();
3717
+ const props = __props;
3718
+ const {
3719
+ resultBuckets,
3720
+ activeFilters,
3721
+ filtersCount,
3722
+ clearFilters,
3723
+ priceRanges,
3724
+ priceRangeKey,
3725
+ getPriceRangeLabel,
3726
+ filterOptions,
3727
+ checkFilterOption,
3728
+ toggleFilterOption
3729
+ } = useSearchFilters(props);
3730
+ const __returned__ = { props, resultBuckets, activeFilters, filtersCount, clearFilters, priceRanges, priceRangeKey, getPriceRangeLabel, filterOptions, checkFilterOption, toggleFilterOption, Collapse };
3731
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
3732
+ return __returned__;
3733
+ }
3734
+ });
3735
+ function _sfc_ssrRender$3(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
3736
+ _push(`<aside${ssrRenderAttrs(mergeProps({ class: "bg-base-50/40 h-screen overflow-y-auto" }, _attrs))}><header class="px-6 pb-3 pt-5 text-center">`);
3737
+ if ($setup.filtersCount) {
3738
+ _push(`<button class="ui-btn-sm ui-btn-danger py-1">${ssrInterpolate("Limpar filtros")} <i class="i-trash ml-0.5"></i></button>`);
3739
+ } else {
3740
+ _push(`<p class="text-base-500 border border-transparent pb-1 text-base font-semibold">${ssrInterpolate("Filtrar resultados")}</p>`);
3741
+ }
3742
+ _push(`</header>`);
3743
+ if ($setup.resultBuckets) {
3744
+ _push(`<article class="px-6 pb-3">`);
3745
+ if ($setup.priceRanges) {
3746
+ _push(ssrRenderComponent($setup["Collapse"], {
3747
+ title: "Pre\xE7o",
3748
+ class: "[&>summary]:text-xl",
3749
+ open: ""
3750
+ }, {
3751
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3752
+ if (_push2) {
3753
+ _push2(`<div class="space-y-1.5"${_scopeId}><!--[-->`);
3754
+ ssrRenderList($setup.priceRanges, ({ range, key }) => {
3755
+ _push2(`<div class="flex items-center"${_scopeId}><input type="radio"${ssrRenderAttr("id", `priceRange-${key}`)} name="priceRange"${ssrRenderAttr("value", key)}${ssrIncludeBooleanAttr(ssrLooseEqual($setup.priceRangeKey, key)) ? " checked" : ""}${_scopeId}><label${ssrRenderAttr("for", `priceRange-${key}`)} class="cursor-pointer px-3 text-sm"${_scopeId}>${ssrInterpolate($setup.getPriceRangeLabel(range))} <small class="text-base-500 font-medium"${_scopeId}> (${ssrInterpolate(range.count)}) </small></label></div>`);
3756
+ });
3757
+ _push2(`<!--]-->`);
3758
+ if ($setup.activeFilters["price<"] || $setup.activeFilters["price>"]) {
3759
+ _push2(`<div class="flex items-center"${_scopeId}><input type="radio" id="priceRange-null" name="priceRange"${ssrRenderAttr("value", null)}${ssrIncludeBooleanAttr(ssrLooseEqual($setup.priceRangeKey, null)) ? " checked" : ""}${_scopeId}><label for="priceRange-null" class="cursor-pointer px-3 text-sm"${_scopeId}>${ssrInterpolate("Qualquer pre\xE7o")}</label></div>`);
3760
+ } else {
3761
+ _push2(`<!---->`);
3762
+ }
3763
+ _push2(`</div>`);
3764
+ } else {
3765
+ return [
3766
+ createVNode("div", { class: "space-y-1.5" }, [
3767
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.priceRanges, ({ range, key }) => {
3768
+ return openBlock(), createBlock("div", {
3769
+ key: `prices-${key}`,
3770
+ class: "flex items-center"
3771
+ }, [
3772
+ withDirectives(createVNode("input", {
3773
+ type: "radio",
3774
+ id: `priceRange-${key}`,
3775
+ name: "priceRange",
3776
+ value: key,
3777
+ "onUpdate:modelValue": ($event) => $setup.priceRangeKey = $event
3778
+ }, null, 8, ["id", "value", "onUpdate:modelValue"]), [
3779
+ [vModelRadio, $setup.priceRangeKey]
3780
+ ]),
3781
+ createVNode("label", {
3782
+ for: `priceRange-${key}`,
3783
+ class: "cursor-pointer px-3 text-sm"
3784
+ }, [
3785
+ createTextVNode(toDisplayString($setup.getPriceRangeLabel(range)) + " ", 1),
3786
+ createVNode("small", { class: "text-base-500 font-medium" }, " (" + toDisplayString(range.count) + ") ", 1)
3787
+ ], 8, ["for"])
3788
+ ]);
3789
+ }), 128)),
3790
+ $setup.activeFilters["price<"] || $setup.activeFilters["price>"] ? (openBlock(), createBlock("div", {
3791
+ key: 0,
3792
+ class: "flex items-center"
3793
+ }, [
3794
+ withDirectives(createVNode("input", {
3795
+ type: "radio",
3796
+ id: "priceRange-null",
3797
+ name: "priceRange",
3798
+ value: null,
3799
+ "onUpdate:modelValue": ($event) => $setup.priceRangeKey = $event
3800
+ }, null, 8, ["onUpdate:modelValue"]), [
3801
+ [vModelRadio, $setup.priceRangeKey]
3802
+ ]),
3803
+ createVNode("label", {
3804
+ for: "priceRange-null",
3805
+ class: "cursor-pointer px-3 text-sm"
3806
+ }, toDisplayString("Qualquer pre\xE7o"))
3807
+ ])) : createCommentVNode("", true)
3808
+ ])
3809
+ ];
3810
+ }
3811
+ }),
3812
+ _: 1
3813
+ }, _parent));
3814
+ } else {
3815
+ _push(`<!---->`);
3816
+ }
3817
+ _push(`<!--[-->`);
3818
+ ssrRenderList($setup.filterOptions, ({ title, options, field }) => {
3819
+ _push(ssrRenderComponent($setup["Collapse"], {
3820
+ key: field,
3821
+ title,
3822
+ class: "[&>summary]:text-xl",
3823
+ open: !!$setup.activeFilters[field]
3824
+ }, {
3825
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3826
+ if (_push2) {
3827
+ _push2(`<div class="space-y-1.5"${_scopeId}><!--[-->`);
3828
+ ssrRenderList(options, (count, value, i) => {
3829
+ _push2(`<div class="flex items-center"${_scopeId}><input type="checkbox"${ssrRenderAttr("id", `${field}-${value}`)}${ssrRenderAttr("value", value)}${ssrIncludeBooleanAttr($setup.checkFilterOption(field, value)) ? " checked" : ""}${_scopeId}><label${ssrRenderAttr("for", `${field}-${value}`)} class="cursor-pointer px-3 text-sm"${_scopeId}>${ssrInterpolate(value)} <small class="text-base-500 font-medium"${_scopeId}> (${ssrInterpolate(count)}) </small></label></div>`);
3830
+ });
3831
+ _push2(`<!--]--></div>`);
3832
+ } else {
3833
+ return [
3834
+ createVNode("div", { class: "space-y-1.5" }, [
3835
+ (openBlock(true), createBlock(Fragment, null, renderList(options, (count, value, i) => {
3836
+ return openBlock(), createBlock("div", {
3837
+ key: `${field}-${i}`,
3838
+ class: "flex items-center"
3839
+ }, [
3840
+ createVNode("input", {
3841
+ type: "checkbox",
3842
+ id: `${field}-${value}`,
3843
+ value,
3844
+ checked: $setup.checkFilterOption(field, value),
3845
+ onChange: ($event) => $setup.toggleFilterOption(field, value)
3846
+ }, null, 40, ["id", "value", "checked", "onChange"]),
3847
+ createVNode("label", {
3848
+ for: `${field}-${value}`,
3849
+ class: "cursor-pointer px-3 text-sm"
3850
+ }, [
3851
+ createTextVNode(toDisplayString(value) + " ", 1),
3852
+ createVNode("small", { class: "text-base-500 font-medium" }, " (" + toDisplayString(count) + ") ", 1)
3853
+ ], 8, ["for"])
3854
+ ]);
3855
+ }), 128))
3856
+ ])
3857
+ ];
3858
+ }
3859
+ }),
3860
+ _: 2
3861
+ }, _parent));
3862
+ });
3863
+ _push(`<!--]--></article>`);
3864
+ } else {
3865
+ _push(`<!---->`);
3866
+ }
3867
+ _push(`</aside>`);
3868
+ }
3869
+ const _sfc_setup$3 = _sfc_main$3.setup;
3870
+ _sfc_main$3.setup = (props, ctx) => {
3871
+ const ssrContext = useSSRContext();
3872
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/SearchFilters.vue");
3873
+ return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
3874
+ };
3875
+ const SearchFilters = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["ssrRender", _sfc_ssrRender$3]]);
3876
+
3877
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3878
+ __name: "SearchShowcase",
3879
+ props: {
3880
+ term: {},
3881
+ pageSize: {},
3882
+ fixedParams: {},
3883
+ products: {},
3884
+ resultMeta: {},
3885
+ ssrError: {},
3886
+ canUseUrlParams: { type: Boolean, default: true },
3887
+ showcase: {},
3888
+ searchEngine: {},
3889
+ cmsPreview: {}
3890
+ },
3891
+ async setup(__props, { expose: __expose }) {
3892
+ __expose();
3893
+ let __temp, __restore;
3894
+ const props = __props;
3895
+ const showcase = ref(null);
3896
+ const {
3897
+ searchEngine,
3898
+ fetching,
3899
+ isFetching,
3900
+ products,
3901
+ resultMeta,
3902
+ totalPages,
3903
+ filtersCount,
3904
+ sortOptions,
3905
+ sortOption
3906
+ } = useSearchShowcase({ ...props, showcase });
3907
+ {
3908
+ [__temp, __restore] = withAsyncContext(() => fetching), await __temp, __restore();
3909
+ }
3910
+ const wasFetched = computed(() => searchEngine.wasFetched.value);
3911
+ const searchTerm = computed(() => searchEngine.term.value);
3912
+ const hasFiltersBar = computed(() => {
3913
+ return wasFetched && !!(resultMeta.value.count > 4 || filtersCount.value);
3914
+ });
3915
+ const isFiltersOpen = ref(false);
3916
+ const __returned__ = { props, showcase, searchEngine, fetching, isFetching, products, resultMeta, totalPages, filtersCount, sortOptions, sortOption, wasFetched, searchTerm, hasFiltersBar, isFiltersOpen, get Listbox() {
3917
+ return Listbox;
3918
+ }, get ListboxButton() {
3919
+ return ListboxButton;
3920
+ }, get ListboxOptions() {
3921
+ return ListboxOptions;
3922
+ }, get ListboxOption() {
3923
+ return ListboxOption;
3924
+ }, Drawer, Pagination, ProductShelf, SearchFilters };
3925
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
3926
+ return __returned__;
3927
+ }
3928
+ });
3929
+ function _sfc_ssrRender$2(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
3930
+ const _component_Skeleton = resolveComponent("Skeleton");
3931
+ const _component_Fade = resolveComponent("Fade");
3932
+ _push(`<!--[-->`);
3933
+ if ($setup.searchTerm) {
3934
+ _push(`<section class="${ssrRenderClass([$setup.hasFiltersBar ? "relative z-[14] -mb-4" : "mb-0", "px-6 text-center text-xl lowercase text-base-700 ui-section-slim"])}">${ssrInterpolate("Buscando por")} <h1 class="inline font-bold italic text-base-800">${ssrInterpolate($setup.searchTerm)}</h1></section>`);
3935
+ } else {
3936
+ _push(`<!---->`);
3937
+ }
3938
+ if ($setup.isFetching && !$setup.products.length) {
3939
+ _push(`<div class="relative min-h-[300px] ui-section">`);
3940
+ _push(ssrRenderComponent(_component_Skeleton, {
3941
+ class: "absolute top-0 w-full px-5",
3942
+ "is-bold": "",
3943
+ "is-large": ""
3944
+ }, null, _parent));
3945
+ _push(`</div>`);
3946
+ } else {
3947
+ _push(`<!---->`);
3948
+ }
3949
+ _push(`<article class="relative">`);
3950
+ _push(ssrRenderComponent(_component_Fade, null, {
3951
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
3952
+ if (_push2) {
3953
+ if ($setup.hasFiltersBar) {
3954
+ _push2(`<section class="sticky top-0 z-[12] flex items-center justify-between rounded-b bg-white/80 to-base-100 px-6 py-4 shadow-sm backdrop-blur-sm transition-transform ui-section-slim sticky-header:translate-y-16 lg:sticky-header:translate-y-14"${_scopeId}><strong class="font-medium lowercase text-base-700"${_scopeId}>`);
3955
+ if ($setup.resultMeta.count > 1) {
3956
+ _push2(`<!--[-->${ssrInterpolate($setup.resultMeta.count)} <span class="hidden lg:inline"${_scopeId}>${ssrInterpolate("Itens encontrados")}</span><span class="lg:hidden"${_scopeId}>${ssrInterpolate("Produtos")}</span><!--]-->`);
3957
+ } else {
3958
+ _push2(`<!---->`);
3959
+ }
3960
+ _push2(`</strong><div class="flex items-center gap-4"${_scopeId}><span class="hidden text-xl leading-none md:block"${_scopeId}><i class="m-0 text-base-600 i-adjustments-horizontal"${_scopeId}></i></span><button class="relative ui-btn-sm ui-btn-secondary"${_scopeId}><span class="hidden md:inline"${_scopeId}>${ssrInterpolate("Filtrar produtos")}</span><span class="md:hidden"${_scopeId}><i class="mr-1 i-adjustments-horizontal"${_scopeId}></i> ${ssrInterpolate("Filtrar")}</span>`);
3961
+ if ($setup.filtersCount) {
3962
+ _push2(`<span class="outline-3 absolute -right-1.5 -top-1 outline outline-secondary/80 ui-badge-pill-sm"${_scopeId}>${ssrInterpolate($setup.filtersCount)}</span>`);
3963
+ } else {
3964
+ _push2(`<!---->`);
3965
+ }
3966
+ _push2(`</button>`);
3967
+ if (!$props.fixedParams?.sort) {
3968
+ _push2(ssrRenderComponent($setup["Listbox"], {
3969
+ modelValue: $setup.sortOption,
3970
+ "onUpdate:modelValue": ($event) => $setup.sortOption = $event,
3971
+ as: "div",
3972
+ class: "relative text-sm text-base-800"
3973
+ }, {
3974
+ default: withCtx((_2, _push3, _parent3, _scopeId2) => {
3975
+ if (_push3) {
3976
+ _push3(ssrRenderComponent($setup["ListboxButton"], {
3977
+ id: _ctx.$useId("ss"),
3978
+ class: "ui-btn-sm ui-btn-secondary"
3979
+ }, {
3980
+ default: withCtx((_3, _push4, _parent4, _scopeId3) => {
3981
+ if (_push4) {
3982
+ _push4(`${ssrInterpolate("Ordenar")}`);
3983
+ } else {
3984
+ return [
3985
+ createTextVNode(toDisplayString("Ordenar"))
3986
+ ];
3987
+ }
3988
+ }),
3989
+ _: 1
3990
+ }, _parent3, _scopeId2));
3991
+ _push3(ssrRenderComponent(_component_Fade, null, {
3992
+ default: withCtx((_3, _push4, _parent4, _scopeId3) => {
3993
+ if (_push4) {
3994
+ _push4(ssrRenderComponent($setup["ListboxOptions"], { class: "absolute right-0 mt-2 divide-y divide-base-100 rounded bg-white shadow ring-1 ring-black/5 focus:outline-none" }, {
3995
+ default: withCtx((_4, _push5, _parent5, _scopeId4) => {
3996
+ if (_push5) {
3997
+ _push5(`<!--[-->`);
3998
+ ssrRenderList($setup.sortOptions, ({ label, value }) => {
3999
+ _push5(ssrRenderComponent($setup["ListboxOption"], {
4000
+ key: value || "sort",
4001
+ value,
4002
+ as: "template"
4003
+ }, {
4004
+ default: withCtx(({ selected, active }, _push6, _parent6, _scopeId5) => {
4005
+ if (_push6) {
4006
+ _push6(`<li${_scopeId5}>`);
4007
+ ssrRenderVNode(_push6, createVNode(resolveDynamicComponent(selected ? "div" : "button"), {
4008
+ class: ["flex w-full py-2 pl-3 pr-6", !selected && active && "bg-secondary-100 text-secondary"]
4009
+ }, {
4010
+ default: withCtx((_5, _push7, _parent7, _scopeId6) => {
4011
+ if (_push7) {
4012
+ _push7(`<div class="w-5"${_scopeId6}><i style="${ssrRenderStyle(selected ? null : { display: "none" })}" class="i-check"${_scopeId6}></i></div> ${ssrInterpolate(label)}`);
4013
+ } else {
4014
+ return [
4015
+ createVNode("div", { class: "w-5" }, [
4016
+ withDirectives(createVNode("i", { class: "i-check" }, null, 512), [
4017
+ [vShow, selected]
4018
+ ])
4019
+ ]),
4020
+ createTextVNode(" " + toDisplayString(label), 1)
4021
+ ];
4022
+ }
4023
+ }),
4024
+ _: 2
4025
+ }), _parent6, _scopeId5);
4026
+ _push6(`</li>`);
4027
+ } else {
4028
+ return [
4029
+ createVNode("li", null, [
4030
+ (openBlock(), createBlock(resolveDynamicComponent(selected ? "div" : "button"), {
4031
+ class: ["flex w-full py-2 pl-3 pr-6", !selected && active && "bg-secondary-100 text-secondary"]
4032
+ }, {
4033
+ default: withCtx(() => [
4034
+ createVNode("div", { class: "w-5" }, [
4035
+ withDirectives(createVNode("i", { class: "i-check" }, null, 512), [
4036
+ [vShow, selected]
4037
+ ])
4038
+ ]),
4039
+ createTextVNode(" " + toDisplayString(label), 1)
4040
+ ]),
4041
+ _: 2
4042
+ }, 1032, ["class"]))
4043
+ ])
4044
+ ];
4045
+ }
4046
+ }),
4047
+ _: 2
4048
+ }, _parent5, _scopeId4));
4049
+ });
4050
+ _push5(`<!--]-->`);
4051
+ } else {
4052
+ return [
4053
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.sortOptions, ({ label, value }) => {
4054
+ return openBlock(), createBlock($setup["ListboxOption"], {
4055
+ key: value || "sort",
4056
+ value,
4057
+ as: "template"
4058
+ }, {
4059
+ default: withCtx(({ selected, active }) => [
4060
+ createVNode("li", null, [
4061
+ (openBlock(), createBlock(resolveDynamicComponent(selected ? "div" : "button"), {
4062
+ class: ["flex w-full py-2 pl-3 pr-6", !selected && active && "bg-secondary-100 text-secondary"]
4063
+ }, {
4064
+ default: withCtx(() => [
4065
+ createVNode("div", { class: "w-5" }, [
4066
+ withDirectives(createVNode("i", { class: "i-check" }, null, 512), [
4067
+ [vShow, selected]
4068
+ ])
4069
+ ]),
4070
+ createTextVNode(" " + toDisplayString(label), 1)
4071
+ ]),
4072
+ _: 2
4073
+ }, 1032, ["class"]))
4074
+ ])
4075
+ ]),
4076
+ _: 2
4077
+ }, 1032, ["value"]);
4078
+ }), 128))
4079
+ ];
4080
+ }
4081
+ }),
4082
+ _: 1
4083
+ }, _parent4, _scopeId3));
4084
+ } else {
4085
+ return [
4086
+ createVNode($setup["ListboxOptions"], { class: "absolute right-0 mt-2 divide-y divide-base-100 rounded bg-white shadow ring-1 ring-black/5 focus:outline-none" }, {
4087
+ default: withCtx(() => [
4088
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.sortOptions, ({ label, value }) => {
4089
+ return openBlock(), createBlock($setup["ListboxOption"], {
4090
+ key: value || "sort",
4091
+ value,
4092
+ as: "template"
4093
+ }, {
4094
+ default: withCtx(({ selected, active }) => [
4095
+ createVNode("li", null, [
4096
+ (openBlock(), createBlock(resolveDynamicComponent(selected ? "div" : "button"), {
4097
+ class: ["flex w-full py-2 pl-3 pr-6", !selected && active && "bg-secondary-100 text-secondary"]
4098
+ }, {
4099
+ default: withCtx(() => [
4100
+ createVNode("div", { class: "w-5" }, [
4101
+ withDirectives(createVNode("i", { class: "i-check" }, null, 512), [
4102
+ [vShow, selected]
4103
+ ])
4104
+ ]),
4105
+ createTextVNode(" " + toDisplayString(label), 1)
4106
+ ]),
4107
+ _: 2
4108
+ }, 1032, ["class"]))
4109
+ ])
4110
+ ]),
4111
+ _: 2
4112
+ }, 1032, ["value"]);
4113
+ }), 128))
4114
+ ]),
4115
+ _: 1
4116
+ })
4117
+ ];
4118
+ }
4119
+ }),
4120
+ _: 1
4121
+ }, _parent3, _scopeId2));
4122
+ } else {
4123
+ return [
4124
+ createVNode($setup["ListboxButton"], {
4125
+ id: _ctx.$useId("ss"),
4126
+ class: "ui-btn-sm ui-btn-secondary"
4127
+ }, {
4128
+ default: withCtx(() => [
4129
+ createTextVNode(toDisplayString("Ordenar"))
4130
+ ]),
4131
+ _: 1
4132
+ }, 8, ["id"]),
4133
+ createVNode(_component_Fade, null, {
4134
+ default: withCtx(() => [
4135
+ createVNode($setup["ListboxOptions"], { class: "absolute right-0 mt-2 divide-y divide-base-100 rounded bg-white shadow ring-1 ring-black/5 focus:outline-none" }, {
4136
+ default: withCtx(() => [
4137
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.sortOptions, ({ label, value }) => {
4138
+ return openBlock(), createBlock($setup["ListboxOption"], {
4139
+ key: value || "sort",
4140
+ value,
4141
+ as: "template"
4142
+ }, {
4143
+ default: withCtx(({ selected, active }) => [
4144
+ createVNode("li", null, [
4145
+ (openBlock(), createBlock(resolveDynamicComponent(selected ? "div" : "button"), {
4146
+ class: ["flex w-full py-2 pl-3 pr-6", !selected && active && "bg-secondary-100 text-secondary"]
4147
+ }, {
4148
+ default: withCtx(() => [
4149
+ createVNode("div", { class: "w-5" }, [
4150
+ withDirectives(createVNode("i", { class: "i-check" }, null, 512), [
4151
+ [vShow, selected]
4152
+ ])
4153
+ ]),
4154
+ createTextVNode(" " + toDisplayString(label), 1)
4155
+ ]),
4156
+ _: 2
4157
+ }, 1032, ["class"]))
4158
+ ])
4159
+ ]),
4160
+ _: 2
4161
+ }, 1032, ["value"]);
4162
+ }), 128))
4163
+ ]),
4164
+ _: 1
4165
+ })
4166
+ ]),
4167
+ _: 1
4168
+ })
4169
+ ];
4170
+ }
4171
+ }),
4172
+ _: 1
4173
+ }, _parent2, _scopeId));
4174
+ } else {
4175
+ _push2(`<!---->`);
4176
+ }
4177
+ _push2(`</div></section>`);
4178
+ } else {
4179
+ _push2(`<!---->`);
4180
+ }
4181
+ } else {
4182
+ return [
4183
+ $setup.hasFiltersBar ? (openBlock(), createBlock("section", {
4184
+ key: 0,
4185
+ class: "sticky top-0 z-[12] flex items-center justify-between rounded-b bg-white/80 to-base-100 px-6 py-4 shadow-sm backdrop-blur-sm transition-transform ui-section-slim sticky-header:translate-y-16 lg:sticky-header:translate-y-14"
4186
+ }, [
4187
+ createVNode("strong", { class: "font-medium lowercase text-base-700" }, [
4188
+ $setup.resultMeta.count > 1 ? (openBlock(), createBlock(Fragment, { key: 0 }, [
4189
+ createTextVNode(toDisplayString($setup.resultMeta.count) + " ", 1),
4190
+ createVNode("span", { class: "hidden lg:inline" }, toDisplayString("Itens encontrados")),
4191
+ createVNode("span", { class: "lg:hidden" }, toDisplayString("Produtos"))
4192
+ ], 64)) : createCommentVNode("", true)
4193
+ ]),
4194
+ createVNode("div", { class: "flex items-center gap-4" }, [
4195
+ createVNode("span", { class: "hidden text-xl leading-none md:block" }, [
4196
+ createVNode("i", { class: "m-0 text-base-600 i-adjustments-horizontal" })
4197
+ ]),
4198
+ createVNode("button", {
4199
+ onClick: ($event) => $setup.isFiltersOpen = !$setup.isFiltersOpen,
4200
+ class: "relative ui-btn-sm ui-btn-secondary"
4201
+ }, [
4202
+ createVNode("span", { class: "hidden md:inline" }, toDisplayString("Filtrar produtos")),
4203
+ createVNode("span", { class: "md:hidden" }, [
4204
+ createVNode("i", { class: "mr-1 i-adjustments-horizontal" }),
4205
+ createTextVNode(" " + toDisplayString("Filtrar"))
4206
+ ]),
4207
+ $setup.filtersCount ? (openBlock(), createBlock("span", {
4208
+ key: 0,
4209
+ class: "outline-3 absolute -right-1.5 -top-1 outline outline-secondary/80 ui-badge-pill-sm"
4210
+ }, toDisplayString($setup.filtersCount), 1)) : createCommentVNode("", true)
4211
+ ], 8, ["onClick"]),
4212
+ !$props.fixedParams?.sort ? (openBlock(), createBlock($setup["Listbox"], {
4213
+ key: 0,
4214
+ modelValue: $setup.sortOption,
4215
+ "onUpdate:modelValue": ($event) => $setup.sortOption = $event,
4216
+ as: "div",
4217
+ class: "relative text-sm text-base-800"
4218
+ }, {
4219
+ default: withCtx(() => [
4220
+ createVNode($setup["ListboxButton"], {
4221
+ id: _ctx.$useId("ss"),
4222
+ class: "ui-btn-sm ui-btn-secondary"
4223
+ }, {
4224
+ default: withCtx(() => [
4225
+ createTextVNode(toDisplayString("Ordenar"))
4226
+ ]),
4227
+ _: 1
4228
+ }, 8, ["id"]),
4229
+ createVNode(_component_Fade, null, {
4230
+ default: withCtx(() => [
4231
+ createVNode($setup["ListboxOptions"], { class: "absolute right-0 mt-2 divide-y divide-base-100 rounded bg-white shadow ring-1 ring-black/5 focus:outline-none" }, {
4232
+ default: withCtx(() => [
4233
+ (openBlock(true), createBlock(Fragment, null, renderList($setup.sortOptions, ({ label, value }) => {
4234
+ return openBlock(), createBlock($setup["ListboxOption"], {
4235
+ key: value || "sort",
4236
+ value,
4237
+ as: "template"
4238
+ }, {
4239
+ default: withCtx(({ selected, active }) => [
4240
+ createVNode("li", null, [
4241
+ (openBlock(), createBlock(resolveDynamicComponent(selected ? "div" : "button"), {
4242
+ class: ["flex w-full py-2 pl-3 pr-6", !selected && active && "bg-secondary-100 text-secondary"]
4243
+ }, {
4244
+ default: withCtx(() => [
4245
+ createVNode("div", { class: "w-5" }, [
4246
+ withDirectives(createVNode("i", { class: "i-check" }, null, 512), [
4247
+ [vShow, selected]
4248
+ ])
4249
+ ]),
4250
+ createTextVNode(" " + toDisplayString(label), 1)
4251
+ ]),
4252
+ _: 2
4253
+ }, 1032, ["class"]))
4254
+ ])
4255
+ ]),
4256
+ _: 2
4257
+ }, 1032, ["value"]);
4258
+ }), 128))
4259
+ ]),
4260
+ _: 1
4261
+ })
4262
+ ]),
4263
+ _: 1
4264
+ })
4265
+ ]),
4266
+ _: 1
4267
+ }, 8, ["modelValue", "onUpdate:modelValue"])) : createCommentVNode("", true)
4268
+ ])
4269
+ ])) : createCommentVNode("", true)
4270
+ ];
4271
+ }
4272
+ }),
4273
+ _: 1
4274
+ }, _parent));
4275
+ _push(ssrRenderComponent($setup["ProductShelf"], {
4276
+ products: $setup.products,
4277
+ "is-grid": ""
4278
+ }, {
4279
+ append: withCtx((_, _push2, _parent2, _scopeId) => {
4280
+ if (_push2) {
4281
+ _push2(ssrRenderComponent(_component_Fade, { slide: "down" }, {
4282
+ default: withCtx((_2, _push3, _parent3, _scopeId2) => {
4283
+ if (_push3) {
4284
+ if (!$setup.isFetching && $setup.totalPages > 1) {
4285
+ _push3(`<nav class="mt-3 lg:mt-4"${_scopeId2}>`);
4286
+ _push3(ssrRenderComponent($setup["Pagination"], {
4287
+ page: $setup.searchEngine.pageNumber.value,
4288
+ "onUpdate:page": ($event) => $setup.searchEngine.pageNumber.value = $event,
4289
+ "total-pages": $setup.totalPages
4290
+ }, null, _parent3, _scopeId2));
4291
+ _push3(`</nav>`);
4292
+ } else {
4293
+ _push3(`<!---->`);
4294
+ }
4295
+ } else {
4296
+ return [
4297
+ !$setup.isFetching && $setup.totalPages > 1 ? (openBlock(), createBlock("nav", {
4298
+ key: 0,
4299
+ class: "mt-3 lg:mt-4"
4300
+ }, [
4301
+ createVNode($setup["Pagination"], {
4302
+ page: $setup.searchEngine.pageNumber.value,
4303
+ "onUpdate:page": ($event) => $setup.searchEngine.pageNumber.value = $event,
4304
+ "total-pages": $setup.totalPages
4305
+ }, null, 8, ["page", "onUpdate:page", "total-pages"])
4306
+ ])) : createCommentVNode("", true)
4307
+ ];
4308
+ }
4309
+ }),
4310
+ _: 1
4311
+ }, _parent2, _scopeId));
4312
+ } else {
4313
+ return [
4314
+ createVNode(_component_Fade, { slide: "down" }, {
4315
+ default: withCtx(() => [
4316
+ !$setup.isFetching && $setup.totalPages > 1 ? (openBlock(), createBlock("nav", {
4317
+ key: 0,
4318
+ class: "mt-3 lg:mt-4"
4319
+ }, [
4320
+ createVNode($setup["Pagination"], {
4321
+ page: $setup.searchEngine.pageNumber.value,
4322
+ "onUpdate:page": ($event) => $setup.searchEngine.pageNumber.value = $event,
4323
+ "total-pages": $setup.totalPages
4324
+ }, null, 8, ["page", "onUpdate:page", "total-pages"])
4325
+ ])) : createCommentVNode("", true)
4326
+ ]),
4327
+ _: 1
4328
+ })
4329
+ ];
4330
+ }
4331
+ }),
4332
+ _: 1
4333
+ }, _parent));
4334
+ _push(ssrRenderComponent(_component_Fade, null, {
4335
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
4336
+ if (_push2) {
4337
+ if ($setup.isFetching) {
4338
+ _push2(`<div class="absolute left-0 top-0 z-[14] size-full bg-white/40"${_scopeId}></div>`);
4339
+ } else {
4340
+ _push2(`<!---->`);
4341
+ }
4342
+ } else {
4343
+ return [
4344
+ $setup.isFetching ? (openBlock(), createBlock("div", {
4345
+ key: 0,
4346
+ class: "absolute left-0 top-0 z-[14] size-full bg-white/40"
4347
+ })) : createCommentVNode("", true)
4348
+ ];
4349
+ }
4350
+ }),
4351
+ _: 1
4352
+ }, _parent));
4353
+ _push(`</article>`);
4354
+ _push(ssrRenderComponent($setup["Drawer"], {
4355
+ modelValue: $setup.isFiltersOpen,
4356
+ "onUpdate:modelValue": ($event) => $setup.isFiltersOpen = $event,
4357
+ placement: "end",
4358
+ "backdrop-target": null,
4359
+ "can-lock-scroll": false,
4360
+ class: "!z-[80] bg-white shadow [&_[data-drawer-close]]:bg-white/80"
4361
+ }, {
4362
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
4363
+ if (_push2) {
4364
+ _push2(ssrRenderComponent($setup["SearchFilters"], { "search-engine": $setup.searchEngine }, null, _parent2, _scopeId));
4365
+ } else {
4366
+ return [
4367
+ createVNode($setup["SearchFilters"], { "search-engine": $setup.searchEngine }, null, 8, ["search-engine"])
4368
+ ];
4369
+ }
4370
+ }),
4371
+ _: 1
4372
+ }, _parent));
4373
+ _push(`<!--]-->`);
4374
+ }
4375
+ const _sfc_setup$2 = _sfc_main$2.setup;
4376
+ _sfc_main$2.setup = (props, ctx) => {
4377
+ const ssrContext = useSSRContext();
4378
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/SearchShowcase.vue");
4379
+ return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
4380
+ };
4381
+ const SearchShowcase = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["ssrRender", _sfc_ssrRender$2]]);
4382
+
4383
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
4384
+ __name: "PageTitle",
4385
+ props: {
4386
+ apiDoc: { default: () => globalThis.$storefront.apiContext?.doc },
4387
+ title: {},
4388
+ description: {}
4389
+ },
4390
+ setup(__props, { expose: __expose }) {
4391
+ __expose();
4392
+ const props = __props;
4393
+ const title = computed(() => {
4394
+ return props.title || props.apiDoc?.name;
4395
+ });
4396
+ const logo = computed(() => {
4397
+ return props.apiDoc?.logo;
4398
+ });
4399
+ const description = computed(() => {
4400
+ return props.description || props.apiDoc?.short_description;
4401
+ });
4402
+ const __returned__ = { props, title, logo, description };
4403
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
4404
+ return __returned__;
4405
+ }
4406
+ });
4407
+ function _sfc_ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
4408
+ const _component_AImg = resolveComponent("AImg");
4409
+ if ($setup.title) {
4410
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "bg-secondary-100 py-1" }, _attrs))}><article class="ui-section"><div class="prose mx-auto"><div class="not-prose flex items-center gap-4 md:justify-center">`);
4411
+ if ($setup.logo) {
4412
+ _push(ssrRenderComponent(_component_AImg, {
4413
+ picture: $setup.logo,
4414
+ alt: $setup.logo.alt || $setup.title,
4415
+ class: "h-auto max-w-[150px] xl:max-w-[200px]"
4416
+ }, null, _parent));
4417
+ } else {
4418
+ _push(`<!---->`);
4419
+ }
4420
+ _push(`<h1 class="ui-title text-secondary-800 text-center">${ssrInterpolate($setup.title)}</h1></div>`);
4421
+ if ($setup.description) {
4422
+ _push(`<p class="${ssrRenderClass($setup.description.length < 120 && "md:text-center")}">${ssrInterpolate($setup.description)}</p>`);
4423
+ } else {
4424
+ _push(`<!---->`);
4425
+ }
4426
+ _push(`</div></article></section>`);
4427
+ } else {
4428
+ _push(`<!---->`);
4429
+ }
4430
+ }
4431
+ const _sfc_setup$1 = _sfc_main$1.setup;
4432
+ _sfc_main$1.setup = (props, ctx) => {
4433
+ const ssrContext = useSSRContext();
4434
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/PageTitle.vue");
4435
+ return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
4436
+ };
4437
+ const PageTitle = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["ssrRender", _sfc_ssrRender$1]]);
4438
+
4439
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4440
+ __name: "ContentEntry",
4441
+ props: {
4442
+ title: {},
4443
+ markdown: {}
4444
+ },
4445
+ setup(__props, { expose: __expose }) {
4446
+ __expose();
4447
+ const props = __props;
4448
+ const html = computed(() => micromark(props.markdown, {
4449
+ allowDangerousHtml: true
4450
+ }));
4451
+ const __returned__ = { props, html, ContentClearfix };
4452
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
4453
+ return __returned__;
4454
+ }
4455
+ });
4456
+ function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
4457
+ _push(`<section${ssrRenderAttrs(mergeProps({ class: "ui-section" }, _attrs))}><article class="prose"><h1 class="not-prose ui-title my-4">${ssrInterpolate($props.title)}</h1>`);
4458
+ _push(ssrRenderComponent($setup["ContentClearfix"], { html: $setup.html }, null, _parent));
4459
+ _push(`</article></section>`);
4460
+ }
4461
+ const _sfc_setup = _sfc_main.setup;
4462
+ _sfc_main.setup = (props, ctx) => {
4463
+ const ssrContext = useSSRContext();
4464
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/ContentEntry.vue");
4465
+ return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
4466
+ };
4467
+ const ContentEntry = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
4468
+
4469
+ const $$Astro$2 = createAstro("https://demo.ecomplus.app");
4470
+ const $$Sections = createComponent(async ($$result, $$props, $$slots) => {
4471
+ const Astro2 = $$result.createAstro($$Astro$2, $$props, $$slots);
4472
+ Astro2.self = $$Sections;
4473
+ const { routeContext } = Astro2.locals;
4474
+ const { sections } = await usePageSections({
4475
+ routeContext,
4476
+ handleCustomSection: async (type, content) => {
4477
+ if (type === "c:foo")
4478
+ return { props: { ...content, foo: "bar" } };
4479
+ return { props: content };
4480
+ }
4481
+ });
4482
+ const { cmsContent } = routeContext;
4483
+ return renderTemplate`${maybeRenderHead()}<article class="mb-9 mt-6 md:mb-12 md:mt-8">
4484
+ ${sections.map(async ({ type, props }, index) => {
4485
+ if (cmsContent?.$filename) {
4486
+ props.cmsPreview = {
4487
+ contentFilename: cmsContent.$filename,
4488
+ sectionIndex: index
4489
+ };
4490
+ }
4491
+ switch (type) {
4492
+ case "product-shelf":
4493
+ case "related-products":
4494
+ props.isRelatedProducts = type === "related-products";
4495
+ return renderTemplate`${renderComponent($$result, "ProductShelf", ProductShelf, { ...props, "client:sf": "lazy,interaction", "client:component-hydration": "sf", "client:component-path": "~/components/ProductShelf.vue", "client:component-export": "default" })}`;
4496
+ case "banners-grid":
4497
+ return renderTemplate`${renderComponent($$result, "BannersGrid", $$BannersGrid, { ...props })}`;
4498
+ case "breadcrumbs":
4499
+ return renderTemplate`${renderComponent($$result, "Breadcrumbs", Breadcrumbs, {})}`;
4500
+ case "doc-description":
4501
+ return renderTemplate`${renderComponent($$result, "DocDescription", DocDescription, {})}`;
4502
+ case "doc-banners":
4503
+ return renderTemplate`${renderComponent($$result, "DocBanners", DocBanners, {})}`;
4504
+ case "product-details":
4505
+ const { hasDescription, hasSpecifications, ...detailsProps } = props;
4506
+ return renderTemplate`${renderComponent($$result, "Fragment", Fragment$1, {}, { "default": ($$result2) => renderTemplate`
4507
+ ${renderComponent($$result2, "ProductDetails", ProductDetails, { ...detailsProps, "client:sf": "load", "client:component-hydration": "sf", "client:component-path": "~/components/ProductDetails.vue", "client:component-export": "default" }, { "description": ($$result3) => renderTemplate`${renderComponent($$result3, "Fragment", Fragment$1, { "slot": "description" }, { "default": ($$result4) => renderTemplate`${hasDescription && renderTemplate`${renderComponent($$result4, "DocDescription", DocDescription, {})}`}${hasSpecifications && renderTemplate`${renderComponent($$result4, "ProductSpecifications", ProductSpecifications, {})}`}` })}` })}
4508
+ ` })}`;
4509
+ case "search-showcase":
4510
+ case "context-showcase":
4511
+ return renderTemplate`${renderComponent($$result, "Fragment", Fragment$1, {}, { "default": ($$result2) => renderTemplate`
4512
+ <article class="min-h-[500px]">
4513
+ ${renderComponent($$result2, "SearchShowcase", SearchShowcase, { ...props, "client:sf": "load", "client:component-hydration": "sf", "client:component-path": "~/components/SearchShowcase.vue", "client:component-export": "default" })}
4514
+ </article>
4515
+ ` })}`;
4516
+ case "page-title":
4517
+ return renderTemplate`${renderComponent($$result, "PageTitle", PageTitle, { ...props })}`;
4518
+ case "content-entry":
4519
+ return renderTemplate`${renderComponent($$result, "ContentEntry", ContentEntry, { ...props })}`;
4520
+ case "custom-html":
4521
+ return renderTemplate`${renderComponent($$result, "ContentClearfix", ContentClearfix, { "html": props.html })}`;
4522
+ case "c:foo":
4523
+ return renderTemplate`<div${addAttribute(props.foo, "data-foo")}></div>`;
4524
+ default:
4525
+ return renderTemplate`<div${addAttribute(type, "data-section")}></div>`;
4526
+ }
4527
+ })}
4528
+ </article>`;
4529
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/main/content/Sections.astro", void 0);
4530
+
4531
+ const $$Astro$1 = createAstro("https://demo.ecomplus.app");
4532
+ const $$Main = createComponent(async ($$result, $$props, $$slots) => {
4533
+ const Astro2 = $$result.createAstro($$Astro$1, $$props, $$slots);
4534
+ Astro2.self = $$Main;
4535
+ const { routeContext } = Astro2.locals;
4536
+ const { isSearchPage, fetchingApiContext } = routeContext;
4537
+ const sharedData = {};
4538
+ if (isSearchPage || fetchingApiContext) {
4539
+ const [
4540
+ { data: { result: grids } }
4541
+ ] = await Promise.all([
4542
+ api.get("grids"),
4543
+ fetchingApiContext
4544
+ ]);
4545
+ sharedData.grids = grids;
4546
+ }
4547
+ return renderTemplate`${maybeRenderHead()}<main>
4548
+ ${Object.entries(sharedData).map(([field, value]) => renderTemplate`${renderComponent($$result, "SharedData", $$SharedData, { "field": field, "value": value })}`)}
4549
+ ${renderComponent($$result, "Hero", $$Hero, {})}
4550
+ ${renderComponent($$result, "Sections", $$Sections, {})}
4551
+ </main>`;
4552
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/main/Main.astro", void 0);
4553
+
4554
+ const $$Astro = createAstro("https://demo.ecomplus.app");
4555
+ async function getStaticPaths() {
4556
+ const paths = [{
4557
+ params: { slug: void 0 }
4558
+ }];
4559
+ if (!{"BASE_URL": "/", "MODE": "production", "DEV": false, "PROD": true, "SSR": true, "SITE": "https://demo.ecomplus.app", "ASSETS_PREFIX": undefined}.BUILD_MINIMAL) {
4560
+ const {
4561
+ data: { result: products }
4562
+ } = await api.get("products?fields=slug&sort=-sales&limit=2");
4563
+ products.forEach(({ slug }) => {
4564
+ if (slug)
4565
+ paths.push({ params: { slug } });
4566
+ });
4567
+ const {
4568
+ data: { result: categories }
4569
+ } = await api.get("categories?fields=slug&sort=created_at&limit=1");
4570
+ categories.forEach(({ slug }) => {
4571
+ if (slug)
4572
+ paths.push({ params: { slug } });
4573
+ });
4574
+ const pageSlugs = await getConfig().getContent("extra-pages/");
4575
+ const postSlugs = await getConfig().getContent("blog/");
4576
+ pageSlugs.slice(0, 2).map((slug) => `p/${slug}`).concat(postSlugs.slice(0, 2).map((slug) => `posts/${slug}`)).forEach((slug) => {
4577
+ paths.push({ params: { slug } });
4578
+ });
4579
+ }
4580
+ return paths;
4581
+ }
4582
+ const $$ = createComponent(async ($$result, $$props, $$slots) => {
4583
+ const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
4584
+ Astro2.self = $$;
4585
+ const slug = Astro2.params.slug || "";
4586
+ if (slug.endsWith(".map")) {
4587
+ return new Response(null, { status: 404 });
4588
+ }
4589
+ let contentCollection;
4590
+ if (slug.startsWith("p/")) {
4591
+ contentCollection = "extra-pages";
4592
+ Astro2.params.slug = slug.replace(/^p\//, "");
4593
+ } else if (slug.startsWith("posts/")) {
4594
+ contentCollection = "blog";
4595
+ Astro2.params.slug = slug.replace(/^posts\//, "");
4596
+ }
4597
+ let routeContext;
4598
+ let loadError;
4599
+ try {
4600
+ routeContext = await loadRouteContext(Astro2, { contentCollection });
4601
+ } catch (err) {
4602
+ if (err.astroResponse) {
4603
+ return err.astroResponse;
4604
+ }
4605
+ loadError = err;
4606
+ }
4607
+ return renderTemplate`<html${addAttribute(routeContext?.lang.replace("_", "-"), "lang")}>
4608
+ ${routeContext && renderTemplate`${renderComponent($$result, "Fragment", Fragment$1, {}, { "default": ($$result2) => renderTemplate`
4609
+ ${renderComponent($$result2, "Base", $$Base, {}, { "base-head": ($$result3) => renderTemplate`${renderComponent($$result3, "BaseHead", $$BaseHead, { "slot": "base-head" })}`, "default": ($$result3) => renderTemplate`
4610
+
4611
+ ${renderComponent($$result3, "PageHeader", $$PageHeader, {})}
4612
+ ${renderComponent($$result3, "Main", $$Main, {})}
4613
+ ${renderComponent($$result3, "PageFooter", $$PageFooter, {})}
4614
+ ` })}
4615
+ ` })}`}
4616
+ ${loadError && renderTemplate`${renderComponent($$result, "Fragment", Fragment$1, {}, { "default": ($$result2) => renderTemplate`${unescapeHTML(loadError.responseHTML)}` })}`}
4617
+ </html>`;
4618
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/[...slug].astro", void 0);
4619
+ const $$file = "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/[...slug].astro";
4620
+ const $$url = "/[...slug]";
4621
+
4622
+ const ____slug_ = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4623
+ __proto__: null,
4624
+ default: $$,
4625
+ file: $$file,
4626
+ getStaticPaths,
4627
+ url: $$url
4628
+ }, Symbol.toStringTag, { value: 'Module' }));
4629
+
4630
+ export { CheckoutLink as C, Pagination as P, QuantitySelector as Q, SearchEngine as S, ____slug_ as _, ProductShelf as a, Prices as b, ShippingCalculator as c, searchHistory as s };