cloudcommerce 0.2.1 → 0.2.3

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 (141) hide show
  1. package/.eslintrc.cjs +1 -93
  2. package/CHANGELOG.md +37 -0
  3. package/ecomplus-stores/monocard/functions/ssr/package.json +2 -1
  4. package/ecomplus-stores/tia-sonia/functions/ssr/package.json +2 -1
  5. package/package.json +7 -7
  6. package/packages/api/package.json +1 -1
  7. package/packages/apps/correios/package.json +2 -2
  8. package/packages/apps/custom-payment/package.json +1 -1
  9. package/packages/apps/custom-shipping/package.json +1 -1
  10. package/packages/apps/datafrete/package.json +4 -4
  11. package/packages/apps/discounts/package.json +1 -1
  12. package/packages/apps/emails/package.json +2 -2
  13. package/packages/apps/fb-conversions/lib/fb-conversions-events.js +131 -111
  14. package/packages/apps/fb-conversions/lib/fb-conversions-events.js.map +1 -1
  15. package/packages/apps/fb-conversions/lib/functions-lib/create-fb-objects.js +69 -0
  16. package/packages/apps/fb-conversions/lib/functions-lib/create-fb-objects.js.map +1 -0
  17. package/packages/apps/fb-conversions/package.json +4 -4
  18. package/packages/apps/fb-conversions/src/fb-conversions-events.ts +173 -125
  19. package/packages/apps/fb-conversions/src/functions-lib/create-fb-objects.ts +104 -0
  20. package/packages/apps/frenet/package.json +4 -4
  21. package/packages/apps/galaxpay/lib/galaxpay-list-payments.d.ts +2 -2
  22. package/packages/apps/galaxpay/lib/galaxpay.d.ts +2 -2
  23. package/packages/apps/galaxpay/package.json +4 -4
  24. package/packages/apps/google-analytics/package.json +4 -4
  25. package/packages/apps/infinitepay/package.json +4 -4
  26. package/packages/apps/jadlog/package.json +2 -2
  27. package/packages/apps/loyalty-points/package.json +1 -1
  28. package/packages/apps/mercadopago/package.json +4 -4
  29. package/packages/apps/pagarme/package.json +4 -4
  30. package/packages/apps/paghiper/CHANGELOG.md +1 -0
  31. package/packages/apps/paghiper/README.md +1 -0
  32. package/packages/apps/paghiper/lib/functions-lib/create-axios.d.ts +2 -0
  33. package/packages/apps/paghiper/lib/functions-lib/create-axios.js +22 -0
  34. package/packages/apps/paghiper/lib/functions-lib/create-axios.js.map +1 -0
  35. package/packages/apps/paghiper/lib/functions-lib/handle-webhook.d.ts +3 -0
  36. package/packages/apps/paghiper/lib/functions-lib/handle-webhook.js +154 -0
  37. package/packages/apps/paghiper/lib/functions-lib/handle-webhook.js.map +1 -0
  38. package/packages/apps/paghiper/lib/index.d.ts +1 -0
  39. package/packages/apps/paghiper/lib/index.js +2 -0
  40. package/packages/apps/paghiper/lib/index.js.map +1 -0
  41. package/packages/apps/paghiper/lib/paghiper-create-transaction.d.ts +71 -0
  42. package/packages/apps/paghiper/lib/paghiper-create-transaction.js +199 -0
  43. package/packages/apps/paghiper/lib/paghiper-create-transaction.js.map +1 -0
  44. package/packages/apps/paghiper/lib/paghiper-list-payments.d.ts +7 -0
  45. package/packages/apps/paghiper/lib/paghiper-list-payments.js +97 -0
  46. package/packages/apps/paghiper/lib/paghiper-list-payments.js.map +1 -0
  47. package/packages/apps/paghiper/lib/paghiper-webhook.d.ts +5 -0
  48. package/packages/apps/paghiper/lib/paghiper-webhook.js +18 -0
  49. package/packages/apps/paghiper/lib/paghiper-webhook.js.map +1 -0
  50. package/packages/apps/paghiper/lib/paghiper.d.ts +76 -0
  51. package/packages/apps/paghiper/lib/paghiper.js +12 -0
  52. package/packages/apps/paghiper/lib/paghiper.js.map +1 -0
  53. package/packages/apps/paghiper/package.json +36 -0
  54. package/packages/apps/paghiper/src/functions-lib/create-axios.ts +21 -0
  55. package/packages/apps/paghiper/src/functions-lib/handle-webhook.ts +176 -0
  56. package/packages/apps/paghiper/src/index.ts +1 -0
  57. package/packages/apps/paghiper/src/paghiper-create-transaction.ts +242 -0
  58. package/packages/apps/paghiper/src/paghiper-list-payments.ts +127 -0
  59. package/packages/apps/paghiper/src/paghiper-webhook.ts +17 -0
  60. package/packages/apps/paghiper/src/paghiper.ts +12 -0
  61. package/packages/apps/paghiper/tsconfig.json +6 -0
  62. package/packages/apps/paghiper/types/config-app.d.ts +34 -0
  63. package/packages/apps/paghiper/webhook.js +1 -0
  64. package/packages/apps/pix/package.json +4 -4
  65. package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js.map +1 -1
  66. package/packages/apps/tiny-erp/package.json +4 -4
  67. package/packages/apps/tiny-erp/src/integration/post-tiny-erp.ts +1 -1
  68. package/packages/cli/package.json +1 -1
  69. package/packages/config/package.json +1 -1
  70. package/packages/emails/package.json +2 -2
  71. package/packages/events/lib/firebase.js +2 -0
  72. package/packages/events/lib/firebase.js.map +1 -1
  73. package/packages/events/package.json +4 -3
  74. package/packages/events/src/firebase.ts +2 -0
  75. package/packages/firebase/lib/config.d.ts +3 -0
  76. package/packages/firebase/lib/config.js +4 -0
  77. package/packages/firebase/lib/config.js.map +1 -1
  78. package/packages/firebase/package.json +3 -3
  79. package/packages/firebase/src/config.ts +4 -0
  80. package/packages/i18n/package.json +1 -1
  81. package/packages/modules/lib/firebase/call-app-module.js +12 -0
  82. package/packages/modules/lib/firebase/call-app-module.js.map +1 -1
  83. package/packages/modules/package.json +6 -5
  84. package/packages/modules/src/firebase/call-app-module.ts +12 -0
  85. package/packages/passport/package.json +3 -3
  86. package/packages/ssr/package.json +7 -7
  87. package/packages/storefront/.base.eslintrc.cjs +93 -0
  88. package/packages/storefront/.eslintrc.cjs +1 -1
  89. package/packages/storefront/astro.config.mjs +2 -0
  90. package/packages/storefront/client.d.ts +1 -1
  91. package/packages/storefront/config/storefront.cms.mjs +2 -2
  92. package/packages/storefront/dist/client/_astro/PitchBar.f3579a5b.js +1 -0
  93. package/packages/storefront/dist/client/_astro/Prices.8e5cead5.js +1 -0
  94. package/packages/storefront/dist/client/_astro/Prices.vue_vue_type_script_setup_true_lang.b8cbeb54.js +1 -0
  95. package/packages/storefront/dist/client/_astro/ProductCard.6d8b6d86.js +1 -0
  96. package/packages/storefront/dist/client/_astro/StickyHeader.7b0f3963.js +1 -0
  97. package/packages/storefront/dist/client/{assets/_...slug_.fea84512.css → _astro/_...slug_.97285eba.css} +1 -1
  98. package/packages/storefront/dist/client/_astro/client.3e777d4c.js +1 -0
  99. package/packages/storefront/dist/client/_astro/ecom-utils.92f137f6.js +1 -0
  100. package/packages/storefront/dist/client/_astro/hoisted.6edd7364.js +1 -0
  101. package/packages/storefront/dist/client/{assets → _astro}/index.90df622b.css +0 -0
  102. package/packages/storefront/dist/client/_astro/modules-info.dde776b4.js +1 -0
  103. package/packages/storefront/dist/client/_astro/runtime-core.esm-bundler.7cf33881.js +1 -0
  104. package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.1a4c7407.js +1 -0
  105. package/packages/storefront/dist/client/{assets → _astro}/server.4d9646d8.css +0 -0
  106. package/packages/storefront/dist/client/_astro/session-utm.72684b84.js +1 -0
  107. package/packages/storefront/dist/client/{chunks/workbox-window.prod.es5.10f2e5ac.js → _astro/workbox-window.prod.es5.295a6886.js} +0 -0
  108. package/packages/storefront/dist/client/fallback/index.html +73 -0
  109. package/packages/storefront/dist/client/sw.js +1 -1
  110. package/packages/storefront/dist/server/chunks/astro.89bd9221.mjs +3378 -0
  111. package/packages/storefront/dist/server/chunks/pages/all.c27193d6.mjs +2195 -0
  112. package/packages/storefront/dist/server/chunks/prerender.89f63027.mjs +2 -0
  113. package/packages/storefront/dist/server/entry.mjs +516 -5742
  114. package/packages/storefront/package.json +9 -9
  115. package/packages/storefront/src/lib/components/Carousel.vue +1 -0
  116. package/packages/storefront/src/lib/components/CarouselControl.vue +1 -1
  117. package/packages/storefront/src/lib/components/PitchBar.vue +27 -10
  118. package/packages/storefront/src/lib/components/Prices.vue +24 -24
  119. package/packages/storefront/src/lib/components/StickyHeader.vue +56 -0
  120. package/packages/storefront/src/lib/layouts/Base.astro +6 -0
  121. package/packages/storefront/src/lib/layouts/BaseBody.astro +0 -1
  122. package/packages/storefront/src/lib/layouts/PagesHeader.astro +24 -3
  123. package/packages/storefront/src/lib/scripts/modules-info-preset.ts +60 -0
  124. package/packages/storefront/src/lib/ssr/Picture.astro +18 -0
  125. package/packages/storefront/src/lib/ssr/image.ts +12 -2
  126. package/packages/storefront/src/lib/ssr-context.ts +18 -4
  127. package/packages/storefront/src/lib/state/modules-info.ts +44 -14
  128. package/packages/storefront/src/lib/types/cms-settings.d.ts +2 -1
  129. package/packages/storefront/storefront.config.mjs +20 -8
  130. package/packages/storefront/tailwind.config.cjs +1 -1
  131. package/packages/types/index.ts +17 -0
  132. package/packages/types/package.json +1 -1
  133. package/packages/storefront/dist/client/PitchBar.afe7ff5c.js +0 -1
  134. package/packages/storefront/dist/client/Prices.eaf8a32c.js +0 -1
  135. package/packages/storefront/dist/client/ProductCard.1106b153.js +0 -1
  136. package/packages/storefront/dist/client/chunks/Prices.vue_vue_type_script_setup_true_lang.781b6501.js +0 -1
  137. package/packages/storefront/dist/client/chunks/ecom-utils.63984324.js +0 -1
  138. package/packages/storefront/dist/client/chunks/runtime-core.esm-bundler.fa6cdb60.js +0 -1
  139. package/packages/storefront/dist/client/chunks/session-utm.2de8b604.js +0 -1
  140. package/packages/storefront/dist/client/client.367a6497.js +0 -1
  141. package/packages/storefront/dist/client/hoisted.4671ed15.js +0 -1
@@ -0,0 +1,2195 @@
1
+ import mime from 'mime';
2
+ import sharp$1 from 'sharp';
3
+ import 'kleur/colors';
4
+ import 'node:fs/promises';
5
+ import { resolve, join } from 'node:path';
6
+ import 'node:url';
7
+ import 'http-cache-semantics';
8
+ import 'node:os';
9
+ import sizeOf from 'image-size';
10
+ import 'magic-string';
11
+ import 'node:stream';
12
+ import 'slash';
13
+ import { c as createAstro, a as createComponent, r as renderTemplate, b as addAttribute, d as renderComponent, u as unescapeHTML, F as Fragment, m as maybeRenderHead, e as renderSlot, f as renderHead, s as spreadAttributes } from '../astro.89bd9221.mjs';
14
+ import api from '@cloudcommerce/api';
15
+ import { reactive, computed, defineComponent, inject, mergeProps, useSSRContext, ref, watch, toRef, onMounted, onBeforeUnmount, provide, createVNode, resolveDynamicComponent, withCtx, renderSlot as renderSlot$1, unref, withDirectives, vShow, openBlock, createBlock, createCommentVNode, Fragment as Fragment$1, renderList, toRefs, resolveComponent, toDisplayString, createTextVNode } from 'vue';
16
+ import { ssrRenderAttrs, ssrRenderSlot, ssrRenderClass, ssrRenderVNode, ssrRenderComponent, ssrRenderStyle, ssrRenderList, ssrInterpolate, ssrRenderAttr } from 'vue/server-renderer';
17
+ import { img, price, formatMoney, onPromotion } from '@ecomplus/utils';
18
+ /* empty css */import { EventEmitter } from 'node:events';
19
+ import fs, { readFileSync } from 'node:fs';
20
+ import config from '@cloudcommerce/config';
21
+ import { resolve as resolve$1 } from 'path';
22
+ /* empty css */import 'lodash/debounce.js';
23
+ import { useElementHover } from '@vueuse/core';
24
+
25
+ function isOutputFormat(value) {
26
+ return ["avif", "jpeg", "jpg", "png", "webp"].includes(value);
27
+ }
28
+ function isOutputFormatSupportsAlpha(value) {
29
+ return ["avif", "png", "webp"].includes(value);
30
+ }
31
+ function isAspectRatioString(value) {
32
+ return /^\d*:\d*$/.test(value);
33
+ }
34
+ function parseAspectRatio(aspectRatio) {
35
+ if (!aspectRatio) {
36
+ return void 0;
37
+ }
38
+ if (typeof aspectRatio === "number") {
39
+ return aspectRatio;
40
+ } else {
41
+ const [width, height] = aspectRatio.split(":");
42
+ return parseInt(width) / parseInt(height);
43
+ }
44
+ }
45
+ function isSSRService(service) {
46
+ return "transform" in service;
47
+ }
48
+ class BaseSSRService {
49
+ async getImageAttributes(transform) {
50
+ const { width, height, src, format, quality, aspectRatio, ...rest } = transform;
51
+ return {
52
+ ...rest,
53
+ width,
54
+ height
55
+ };
56
+ }
57
+ serializeTransform(transform) {
58
+ const searchParams = new URLSearchParams();
59
+ if (transform.quality) {
60
+ searchParams.append("q", transform.quality.toString());
61
+ }
62
+ if (transform.format) {
63
+ searchParams.append("f", transform.format);
64
+ }
65
+ if (transform.width) {
66
+ searchParams.append("w", transform.width.toString());
67
+ }
68
+ if (transform.height) {
69
+ searchParams.append("h", transform.height.toString());
70
+ }
71
+ if (transform.aspectRatio) {
72
+ searchParams.append("ar", transform.aspectRatio.toString());
73
+ }
74
+ if (transform.fit) {
75
+ searchParams.append("fit", transform.fit);
76
+ }
77
+ if (transform.background) {
78
+ searchParams.append("bg", transform.background);
79
+ }
80
+ if (transform.position) {
81
+ searchParams.append("p", encodeURI(transform.position));
82
+ }
83
+ searchParams.append("href", transform.src);
84
+ return { searchParams };
85
+ }
86
+ parseTransform(searchParams) {
87
+ if (!searchParams.has("href")) {
88
+ return void 0;
89
+ }
90
+ let transform = { src: searchParams.get("href") };
91
+ if (searchParams.has("q")) {
92
+ transform.quality = parseInt(searchParams.get("q"));
93
+ }
94
+ if (searchParams.has("f")) {
95
+ const format = searchParams.get("f");
96
+ if (isOutputFormat(format)) {
97
+ transform.format = format;
98
+ }
99
+ }
100
+ if (searchParams.has("w")) {
101
+ transform.width = parseInt(searchParams.get("w"));
102
+ }
103
+ if (searchParams.has("h")) {
104
+ transform.height = parseInt(searchParams.get("h"));
105
+ }
106
+ if (searchParams.has("ar")) {
107
+ const ratio = searchParams.get("ar");
108
+ if (isAspectRatioString(ratio)) {
109
+ transform.aspectRatio = ratio;
110
+ } else {
111
+ transform.aspectRatio = parseFloat(ratio);
112
+ }
113
+ }
114
+ if (searchParams.has("fit")) {
115
+ transform.fit = searchParams.get("fit");
116
+ }
117
+ if (searchParams.has("p")) {
118
+ transform.position = decodeURI(searchParams.get("p"));
119
+ }
120
+ if (searchParams.has("bg")) {
121
+ transform.background = searchParams.get("bg");
122
+ }
123
+ return transform;
124
+ }
125
+ }
126
+
127
+ class SharpService extends BaseSSRService {
128
+ async transform(inputBuffer, transform) {
129
+ const sharpImage = sharp$1(inputBuffer, { failOnError: false, pages: -1 });
130
+ sharpImage.rotate();
131
+ if (transform.width || transform.height) {
132
+ const width = transform.width && Math.round(transform.width);
133
+ const height = transform.height && Math.round(transform.height);
134
+ sharpImage.resize({
135
+ width,
136
+ height,
137
+ fit: transform.fit,
138
+ position: transform.position,
139
+ background: transform.background
140
+ });
141
+ }
142
+ if (transform.format) {
143
+ sharpImage.toFormat(transform.format, { quality: transform.quality });
144
+ if (transform.background && !isOutputFormatSupportsAlpha(transform.format)) {
145
+ sharpImage.flatten({ background: transform.background });
146
+ }
147
+ }
148
+ const { data, info } = await sharpImage.toBuffer({ resolveWithObject: true });
149
+ return {
150
+ data,
151
+ format: info.format
152
+ };
153
+ }
154
+ }
155
+ const service = new SharpService();
156
+ var sharp_default = service;
157
+
158
+ const sharp = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
159
+ __proto__: null,
160
+ default: sharp_default
161
+ }, Symbol.toStringTag, { value: 'Module' }));
162
+
163
+ const fnv1a52 = (str) => {
164
+ const len = str.length;
165
+ let i = 0, t0 = 0, v0 = 8997, t1 = 0, v1 = 33826, t2 = 0, v2 = 40164, t3 = 0, v3 = 52210;
166
+ while (i < len) {
167
+ v0 ^= str.charCodeAt(i++);
168
+ t0 = v0 * 435;
169
+ t1 = v1 * 435;
170
+ t2 = v2 * 435;
171
+ t3 = v3 * 435;
172
+ t2 += v0 << 8;
173
+ t3 += v1 << 8;
174
+ t1 += t0 >>> 16;
175
+ v0 = t0 & 65535;
176
+ t2 += t1 >>> 16;
177
+ v1 = t1 & 65535;
178
+ v3 = t3 + (t2 >>> 16) & 65535;
179
+ v2 = t2 & 65535;
180
+ }
181
+ return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
182
+ };
183
+ const etag = (payload, weak = false) => {
184
+ const prefix = weak ? 'W/"' : '"';
185
+ return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
186
+ };
187
+
188
+ function isRemoteImage$1(src) {
189
+ return /^(https?:)?\/\//.test(src);
190
+ }
191
+
192
+ async function loadRemoteImage(src) {
193
+ try {
194
+ const res = await fetch(src);
195
+ if (!res.ok) {
196
+ return void 0;
197
+ }
198
+ return Buffer.from(await res.arrayBuffer());
199
+ } catch (err) {
200
+ console.error(err);
201
+ return void 0;
202
+ }
203
+ }
204
+ const get = async ({ request }) => {
205
+ try {
206
+ const url = new URL(request.url);
207
+ const transform = sharp_default.parseTransform(url.searchParams);
208
+ let inputBuffer = void 0;
209
+ const sourceUrl = isRemoteImage$1(transform.src) ? new URL(transform.src) : new URL(transform.src, url.origin);
210
+ inputBuffer = await loadRemoteImage(sourceUrl);
211
+ if (!inputBuffer) {
212
+ return new Response("Not Found", { status: 404 });
213
+ }
214
+ const { data, format } = await sharp_default.transform(inputBuffer, transform);
215
+ return new Response(data, {
216
+ status: 200,
217
+ headers: {
218
+ "Content-Type": mime.getType(format) || "",
219
+ "Cache-Control": "public, max-age=31536000",
220
+ ETag: etag(data.toString()),
221
+ Date: new Date().toUTCString()
222
+ }
223
+ });
224
+ } catch (err) {
225
+ console.error(err);
226
+ return new Response(`Server Error: ${err}`, { status: 500 });
227
+ }
228
+ };
229
+
230
+ const _page0 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
231
+ __proto__: null,
232
+ get
233
+ }, Symbol.toStringTag, { value: 'Module' }));
234
+
235
+ const getCMS = () => {
236
+ const { STOREFRONT_BASE_DIR } = process.env;
237
+ let baseDir;
238
+ if (STOREFRONT_BASE_DIR) {
239
+ baseDir = resolve(process.cwd(), STOREFRONT_BASE_DIR);
240
+ } else {
241
+ baseDir = process.cwd();
242
+ }
243
+ process.env.STOREFRONT_BASE_DIR = baseDir;
244
+ const dirContent = resolve(baseDir, 'content');
245
+
246
+ const cms = (filename) => {
247
+ if (filename.endsWith('/')) {
248
+ const dirColl = resolve(dirContent, filename);
249
+ return fs.readdirSync(dirColl).map((_filename) => _filename.replace('.json', ''));
250
+ }
251
+ const filepath = resolve(dirContent, `${filename}.json`);
252
+ return JSON.parse(fs.readFileSync(filepath, 'utf8'));
253
+ };
254
+
255
+ let settings;
256
+ try {
257
+ settings = cms('settings');
258
+ } catch (e) {
259
+ settings = {};
260
+ }
261
+ const { domain } = settings;
262
+ const primaryColor = settings.primary_color || '#137c5c';
263
+ const secondaryColor = settings.secondary_color || primaryColor;
264
+
265
+ return {
266
+ domain,
267
+ primaryColor,
268
+ secondaryColor,
269
+ settings,
270
+ cms,
271
+ };
272
+ };
273
+
274
+ const _getConfig = () => {
275
+ const { VITE_ECOM_STORE_ID } = (Object.assign({"BASE_URL":"/","MODE":"production","DEV":false,"PROD":true},{ECOM_STORE_ID:process.env.ECOM_STORE_ID,})) || process.env;
276
+ if (VITE_ECOM_STORE_ID) {
277
+ config.set({ storeId: Number(VITE_ECOM_STORE_ID) });
278
+ }
279
+
280
+ const {
281
+ domain,
282
+ primaryColor,
283
+ secondaryColor,
284
+ settings,
285
+ cms,
286
+ } = getCMS();
287
+ config.set({ cmsSettings: settings });
288
+
289
+ let { storeId } = config.get();
290
+ if (!storeId) {
291
+ const configFilepath = join(process.cwd(), 'config.json');
292
+ try {
293
+ const mergeConfig = JSON.parse(readFileSync(configFilepath), 'utf8');
294
+ if (mergeConfig.storeId) {
295
+ storeId = mergeConfig.storeId;
296
+ config.set({ storeId });
297
+ }
298
+ } catch { /* */ }
299
+ }
300
+ const {
301
+ lang,
302
+ countryCode,
303
+ currency,
304
+ currencySymbol,
305
+ } = config.get();
306
+
307
+ return {
308
+ storeId,
309
+ lang,
310
+ countryCode,
311
+ currency,
312
+ currencySymbol,
313
+ domain,
314
+ primaryColor,
315
+ secondaryColor,
316
+ settings,
317
+ cms,
318
+ };
319
+ };
320
+
321
+ const emitter = new EventEmitter();
322
+ const getConfig = _getConfig;
323
+ if (!globalThis.api_prefetch_endpoints) {
324
+ globalThis.api_prefetch_endpoints = ["categories"];
325
+ }
326
+ if (!globalThis.storefront) {
327
+ globalThis.storefront = {
328
+ settings: {},
329
+ onLoad(callback) {
330
+ emitter.on("load", callback);
331
+ }
332
+ };
333
+ }
334
+ const setResponseCache = (Astro, maxAge, sMaxAge) => {
335
+ const headerName = "Cache-Control" ;
336
+ let cacheControl = `public, max-age=${maxAge}, must-revalidate`;
337
+ if (sMaxAge) {
338
+ cacheControl += `, s-maxage=${sMaxAge}, stale-while-revalidate=604800`;
339
+ }
340
+ Astro.response.headers.set(headerName, cacheControl);
341
+ };
342
+ const loadPageContext = async (Astro, {
343
+ cmsCollection,
344
+ apiPrefetchEndpoints = globalThis.api_prefetch_endpoints
345
+ } = {}) => {
346
+ const startedAt = Date.now();
347
+ const urlPath = Astro.url.pathname;
348
+ const isHomepage = urlPath === "/";
349
+ const { slug } = Astro.params;
350
+ const config = getConfig();
351
+ globalThis.storefront.settings = config.settings;
352
+ let cmsContent;
353
+ let apiResource;
354
+ let apiDoc;
355
+ const apiState = {};
356
+ const apiOptions = {
357
+ fetch,
358
+ isNoAuth: true
359
+ };
360
+ const apiFetchings = [
361
+ null,
362
+ // fetch by slug
363
+ ...apiPrefetchEndpoints.map((endpoint) => api.get(endpoint, apiOptions))
364
+ ];
365
+ if (slug) {
366
+ if (cmsCollection) {
367
+ cmsContent = config.cms(`${cmsCollection}/${slug}`);
368
+ } else {
369
+ apiFetchings[0] = api.get(`slugs/${slug}`, apiOptions);
370
+ }
371
+ }
372
+ try {
373
+ const [slugResponse, ...prefetchResponses] = await Promise.all(apiFetchings);
374
+ if (slugResponse) {
375
+ apiResource = slugResponse.data.resource;
376
+ apiDoc = slugResponse.data.doc;
377
+ apiState[`${apiResource}/${apiDoc._id}`] = apiDoc;
378
+ }
379
+ prefetchResponses.forEach(({ config: { endpoint }, data }) => {
380
+ apiState[endpoint] = data.result || data;
381
+ });
382
+ } catch (err) {
383
+ const error = err;
384
+ const status = error.statusCode || 500;
385
+ if (status === 404) {
386
+ if (urlPath.endsWith("/")) {
387
+ err.redirectUrl = urlPath.slice(0, -1);
388
+ err.astroResponse = Astro.redirect(err.redirectUrl);
389
+ throw err;
390
+ }
391
+ setResponseCache(Astro, 120, 300);
392
+ } else {
393
+ console.error(error);
394
+ setResponseCache(Astro, 30);
395
+ Astro.response.headers.set("X-SSR-Error", error.message);
396
+ }
397
+ Astro.response.status = status;
398
+ err.responseHTML = `<head>
399
+ <meta http-equiv="refresh" content="0;
400
+ url=/fallback?status=${status}&url=${encodeURIComponent(urlPath)}"/>
401
+ </head>
402
+ <body></body>`;
403
+ throw err;
404
+ }
405
+ Astro.response.headers.set("X-Load-Took", String(Date.now() - startedAt));
406
+ if (urlPath === "/fallback") {
407
+ setResponseCache(Astro, 3600, 86400);
408
+ } else if (isHomepage) {
409
+ setResponseCache(Astro, 180, 300);
410
+ } else {
411
+ setResponseCache(Astro, 120, 300);
412
+ }
413
+ const pageContext = {
414
+ ...config,
415
+ isHomepage,
416
+ cmsContent,
417
+ apiResource,
418
+ apiDoc,
419
+ apiState
420
+ };
421
+ emitter.emit("load", pageContext);
422
+ return pageContext;
423
+ };
424
+
425
+ const pwaInfo = {"pwaInDevEnvironment":false,"webManifest":{"href":"/manifest.webmanifest","useCredentials":false,"linkTag":"<link rel=\"manifest\" href=\"/manifest.webmanifest\">"}};
426
+
427
+ function isRemoteImage(src) {
428
+ return /^(https?:)?\/\//.test(src);
429
+ }
430
+ function removeQueryString(src) {
431
+ const index = src.lastIndexOf("?");
432
+ return index > 0 ? src.substring(0, index) : src;
433
+ }
434
+ function extname(src) {
435
+ const base = basename(src);
436
+ const index = base.lastIndexOf(".");
437
+ if (index <= 0) {
438
+ return "";
439
+ }
440
+ return base.substring(index);
441
+ }
442
+ function basename(src) {
443
+ return removeQueryString(src.replace(/^.*[\\\/]/, ""));
444
+ }
445
+
446
+ function resolveSize(transform) {
447
+ if (transform.width && transform.height) {
448
+ return transform;
449
+ }
450
+ if (!transform.width && !transform.height) {
451
+ throw new Error(`"width" and "height" cannot both be undefined`);
452
+ }
453
+ if (!transform.aspectRatio) {
454
+ throw new Error(
455
+ `"aspectRatio" must be included if only "${transform.width ? "width" : "height"}" is provided`
456
+ );
457
+ }
458
+ let aspectRatio;
459
+ if (typeof transform.aspectRatio === "number") {
460
+ aspectRatio = transform.aspectRatio;
461
+ } else {
462
+ const [width, height] = transform.aspectRatio.split(":");
463
+ aspectRatio = Number.parseInt(width) / Number.parseInt(height);
464
+ }
465
+ if (transform.width) {
466
+ return {
467
+ ...transform,
468
+ width: transform.width,
469
+ height: Math.round(transform.width / aspectRatio)
470
+ };
471
+ } else if (transform.height) {
472
+ return {
473
+ ...transform,
474
+ width: Math.round(transform.height * aspectRatio),
475
+ height: transform.height
476
+ };
477
+ }
478
+ return transform;
479
+ }
480
+ async function resolveTransform(input) {
481
+ if (typeof input.src === "string") {
482
+ return resolveSize(input);
483
+ }
484
+ const metadata = "then" in input.src ? (await input.src).default : input.src;
485
+ let { width, height, aspectRatio, background, format = metadata.format, ...rest } = input;
486
+ if (!width && !height) {
487
+ width = metadata.width;
488
+ height = metadata.height;
489
+ } else if (width) {
490
+ let ratio = parseAspectRatio(aspectRatio) || metadata.width / metadata.height;
491
+ height = height || Math.round(width / ratio);
492
+ } else if (height) {
493
+ let ratio = parseAspectRatio(aspectRatio) || metadata.width / metadata.height;
494
+ width = width || Math.round(height * ratio);
495
+ }
496
+ return {
497
+ ...rest,
498
+ src: metadata.src,
499
+ width,
500
+ height,
501
+ aspectRatio,
502
+ format,
503
+ background
504
+ };
505
+ }
506
+ async function getImage$1(transform) {
507
+ var _a, _b, _c;
508
+ if (!transform.src) {
509
+ throw new Error("[@astrojs/image] `src` is required");
510
+ }
511
+ let loader = (_a = globalThis.astroImage) == null ? void 0 : _a.loader;
512
+ if (!loader) {
513
+ const { default: mod } = await Promise.resolve().then(() => sharp).catch(() => {
514
+ throw new Error(
515
+ "[@astrojs/image] Builtin image loader not found. (Did you remember to add the integration to your Astro config?)"
516
+ );
517
+ });
518
+ loader = mod;
519
+ globalThis.astroImage = globalThis.astroImage || {};
520
+ globalThis.astroImage.loader = loader;
521
+ }
522
+ const resolved = await resolveTransform(transform);
523
+ const attributes = await loader.getImageAttributes(resolved);
524
+ const isDev = (_b = (Object.assign({"BASE_URL":"/","MODE":"production","DEV":false,"PROD":true},{SSR:true,}))) == null ? void 0 : _b.DEV;
525
+ const isLocalImage = !isRemoteImage(resolved.src);
526
+ const _loader = isDev && isLocalImage ? globalThis.astroImage.defaultLoader : loader;
527
+ if (!_loader) {
528
+ throw new Error("@astrojs/image: loader not found!");
529
+ }
530
+ const { searchParams } = isSSRService(_loader) ? _loader.serializeTransform(resolved) : globalThis.astroImage.defaultLoader.serializeTransform(resolved);
531
+ const imgSrc = !isLocalImage && resolved.src.startsWith("//") ? `https:${resolved.src}` : resolved.src;
532
+ let src;
533
+ if (/^[\/\\]?@astroimage/.test(imgSrc)) {
534
+ src = `${imgSrc}?${searchParams.toString()}`;
535
+ } else {
536
+ searchParams.set("href", imgSrc);
537
+ src = `/_image?${searchParams.toString()}`;
538
+ }
539
+ if ((_c = globalThis.astroImage) == null ? void 0 : _c.addStaticImage) {
540
+ src = globalThis.astroImage.addStaticImage(resolved);
541
+ }
542
+ return {
543
+ ...attributes,
544
+ src
545
+ };
546
+ }
547
+
548
+ async function resolveAspectRatio({ src, aspectRatio }) {
549
+ if (typeof src === "string") {
550
+ return parseAspectRatio(aspectRatio);
551
+ } else {
552
+ const metadata = "then" in src ? (await src).default : src;
553
+ return parseAspectRatio(aspectRatio) || metadata.width / metadata.height;
554
+ }
555
+ }
556
+ async function resolveFormats({ src, formats }) {
557
+ const unique = new Set(formats);
558
+ if (typeof src === "string") {
559
+ unique.add(extname(src).replace(".", ""));
560
+ } else {
561
+ const metadata = "then" in src ? (await src).default : src;
562
+ unique.add(extname(metadata.src).replace(".", ""));
563
+ }
564
+ return Array.from(unique).filter(Boolean);
565
+ }
566
+ async function getPicture(params) {
567
+ const { src, alt, widths, fit, position, background } = params;
568
+ if (!src) {
569
+ throw new Error("[@astrojs/image] `src` is required");
570
+ }
571
+ if (!widths || !Array.isArray(widths)) {
572
+ throw new Error("[@astrojs/image] at least one `width` is required");
573
+ }
574
+ const aspectRatio = await resolveAspectRatio(params);
575
+ if (!aspectRatio) {
576
+ throw new Error("`aspectRatio` must be provided for remote images");
577
+ }
578
+ const allFormats = await resolveFormats(params);
579
+ const lastFormat = allFormats[allFormats.length - 1];
580
+ const maxWidth = Math.max(...widths);
581
+ let image;
582
+ async function getSource(format) {
583
+ const imgs = await Promise.all(
584
+ widths.map(async (width) => {
585
+ const img = await getImage$1({
586
+ src,
587
+ alt,
588
+ format,
589
+ width,
590
+ fit,
591
+ position,
592
+ background,
593
+ aspectRatio
594
+ });
595
+ if (format === lastFormat && width === maxWidth) {
596
+ image = img;
597
+ }
598
+ return `${img.src} ${width}w`;
599
+ })
600
+ );
601
+ return {
602
+ type: mime.getType(format) || format,
603
+ srcset: imgs.join(",")
604
+ };
605
+ }
606
+ const sources = await Promise.all(allFormats.map((format) => getSource(format)));
607
+ return {
608
+ sources,
609
+ image
610
+ };
611
+ }
612
+
613
+ const tryImageSize = (src) => {
614
+ let dimensions = {};
615
+ if (typeof src === "string" && src.startsWith("/")) {
616
+ const { STOREFRONT_BASE_DIR } = Object.assign({"BASE_URL":"/","MODE":"production","DEV":false,"PROD":true}, { STOREFRONT_BASE_DIR: process.env.STOREFRONT_BASE_DIR });
617
+ try {
618
+ dimensions = sizeOf(resolve$1(STOREFRONT_BASE_DIR, `public${src}`));
619
+ } catch (e) {
620
+ dimensions = {};
621
+ }
622
+ }
623
+ return dimensions;
624
+ };
625
+ const getAspectRatio = (src) => {
626
+ if (typeof src === "string") {
627
+ src = tryImageSize(src);
628
+ }
629
+ if (src.width) {
630
+ return src.height ? src.width / src.height : 1;
631
+ }
632
+ return 0;
633
+ };
634
+ const getImage = async (options) => {
635
+ if (!options.isLowResolution) {
636
+ if (options.width) {
637
+ options.width *= 2;
638
+ }
639
+ if (options.height) {
640
+ options.height *= 2;
641
+ }
642
+ }
643
+ if (typeof options.src === "string" && !options.aspectRatio && (!options.width || !options.height)) {
644
+ const { width, height } = tryImageSize(options.src);
645
+ if (width) {
646
+ if (!options.width) {
647
+ options.width = width;
648
+ }
649
+ options.aspectRatio = getAspectRatio({ width, height });
650
+ }
651
+ }
652
+ const imgAttrs = await getImage$1({ alt: "", ...options });
653
+ imgAttrs.src += imgAttrs.src.includes("?") ? "&" : "?";
654
+ imgAttrs.src += `V=${({}).DEPLOY_RAND || "_"}`;
655
+ if (typeof imgAttrs.width === "number") {
656
+ imgAttrs.width /= 2;
657
+ }
658
+ if (typeof imgAttrs.height === "number") {
659
+ imgAttrs.height /= 2;
660
+ }
661
+ return imgAttrs;
662
+ };
663
+
664
+ const $$Astro$g = createAstro("https://ecom2-002.web.app");
665
+ const $$BaseHead = createComponent(async ($$result, $$props, $$slots) => {
666
+ const Astro2 = $$result.createAstro($$Astro$g, $$props, $$slots);
667
+ Astro2.self = $$BaseHead;
668
+ const {
669
+ storeId,
670
+ cmsContent,
671
+ apiDoc,
672
+ lang,
673
+ domain,
674
+ primaryColor,
675
+ settings,
676
+ cms
677
+ } = Astro2.props.pageContext;
678
+ const state = apiDoc || cmsContent || {};
679
+ const title = state.meta_title || state.name || state.title || Astro2.props.title || settings.name;
680
+ const description = state.meta_description || state.short_description || settings.description;
681
+ const favicon = settings.icon ? (await getImage({
682
+ src: settings.icon,
683
+ width: 32,
684
+ height: 32,
685
+ format: "png",
686
+ isLowResolution: true
687
+ })).src : "/favicon.ico";
688
+ const canonicalUrl = new URL(Astro2.url.pathname, Astro2.site || `https://${domain}`);
689
+ const cmsSocial = cms("social");
690
+ const ogLocale = lang.length === 2 ? lang : lang.substring(0, 2) + lang.slice(3).toUpperCase();
691
+ let ogImage;
692
+ if (apiDoc) {
693
+ const picture = img(state, null, "zoom");
694
+ ogImage = picture && picture.url;
695
+ }
696
+ if (!ogImage) {
697
+ if (cmsSocial.og_image) {
698
+ ogImage = cmsSocial.og_image.charAt(0) === "/" ? `https://${domain}${cmsSocial.og_image}` : cmsSocial.og_image;
699
+ }
700
+ } else {
701
+ ogImage = ogImage.replace(/(\w+\.)?(ecoms\d)\.com/i, "$2-nyc3.nyc3.cdn.digitaloceanspaces.com");
702
+ }
703
+ return renderTemplate`<meta charset="UTF-8">
704
+ <meta name="viewport" content="width=device-width">
705
+ <meta name="theme-color"${addAttribute(primaryColor, "content")}>
706
+ <link rel="icon"${addAttribute(favicon, "href")}>
707
+ <title>${title}</title>
708
+ <meta name="description"${addAttribute(description, "content")}>
709
+ <meta name="author"${addAttribute(settings.name, "content")}>
710
+ <meta name="generator"${addAttribute(Astro2.generator, "content")}>
711
+ <link rel="canonical"${addAttribute(canonicalUrl, "href")}>
712
+ <link rel="apple-touch-icon"${addAttribute(settings.icon, "href")}>
713
+ <meta name="apple-mobile-web-app-capable" content="yes">
714
+ <meta name="apple-mobile-web-app-status-bar-style" content="default">
715
+ <meta property="og:site_name"${addAttribute(settings.name, "content")}>
716
+ <meta property="og:url"${addAttribute(canonicalUrl, "content")}>
717
+ <meta property="og:title"${addAttribute(title, "content")}>
718
+ <meta property="og:description"${addAttribute(description, "content")}>
719
+ <meta property="og:type" content="website">
720
+ <meta property="og:locale"${addAttribute(ogLocale, "content")}>
721
+ ${ogImage && renderTemplate`<meta property="og:image"${addAttribute(ogImage, "content")}>`}
722
+ ${cmsSocial.fb_app_id && renderTemplate`<meta property="fb:app_id"${addAttribute(cmsSocial.fb_app_id, "content")}>`}
723
+ <meta name="twitter:card" content="summary">
724
+ ${cmsSocial.twitter_username && renderTemplate`<meta name="twitter:site"${addAttribute(cmsSocial.twitter_username, "content")}>`}
725
+ <meta name="ecom-store-id"${addAttribute(String(storeId), "content")}>
726
+ ${pwaInfo && renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": () => renderTemplate`${unescapeHTML(pwaInfo.webManifest.linkTag)}` })}`}
727
+ `;
728
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/layouts/BaseHead.astro");
729
+
730
+ var __freeze$1 = Object.freeze;
731
+ var __defProp$1 = Object.defineProperty;
732
+ var __template$1 = (cooked, raw) => __freeze$1(__defProp$1(cooked, "raw", { value: __freeze$1(raw || cooked.slice()) }));
733
+ var _a$1;
734
+ const $$Astro$f = createAstro("https://ecom2-002.web.app");
735
+ const $$BaseStateJson = createComponent(async ($$result, $$props, $$slots) => {
736
+ const Astro2 = $$result.createAstro($$Astro$f, $$props, $$slots);
737
+ Astro2.self = $$BaseStateJson;
738
+ const {
739
+ pageContext: {
740
+ storeId,
741
+ apiResource,
742
+ apiDoc,
743
+ lang,
744
+ countryCode,
745
+ currency,
746
+ currencySymbol,
747
+ domain,
748
+ settings
749
+ }
750
+ } = Astro2.props;
751
+ let inlineClientJS = `
752
+ window.ECOM_STORE_ID = ${storeId};
753
+ window.ECOM_LANG = '${lang}';
754
+ window.ECOM_CURRENCY = '${currency}';
755
+ window.ECOM_CURRENCY_SYMBOL = '${currencySymbol}';
756
+ window.ECOM_COUNTRY_CODE = '${countryCode}';
757
+ window.storefront = ${JSON.stringify({ settings })};`;
758
+ if (apiDoc) {
759
+ if (typeof apiDoc.price === "number") {
760
+ apiDoc.price = price(apiDoc);
761
+ }
762
+ const slimDocRegex = globalThis.storefront_slim_doc_regex || /body|meta|records|description|i18n/;
763
+ const minifyApiDoc = (nestedDoc) => {
764
+ if (typeof nestedDoc === "object" && nestedDoc) {
765
+ if (Array.isArray(nestedDoc)) {
766
+ nestedDoc.forEach((item) => minifyApiDoc(item));
767
+ } else {
768
+ Object.keys(nestedDoc).forEach((field) => {
769
+ if (slimDocRegex.test(field)) {
770
+ delete nestedDoc[field];
771
+ } else {
772
+ minifyApiDoc(nestedDoc[field]);
773
+ }
774
+ });
775
+ }
776
+ }
777
+ return nestedDoc;
778
+ };
779
+ inlineClientJS += `
780
+ window.storefront.context = ${JSON.stringify({
781
+ resource: apiResource,
782
+ doc: minifyApiDoc({ ...apiDoc }),
783
+ timestamp: Date.now()
784
+ })};`;
785
+ }
786
+ const inlineJSONLd = JSON.stringify({
787
+ "@context": "http://schema.org",
788
+ "@type": "Organization",
789
+ name: settings.name,
790
+ url: `https://${domain}/`,
791
+ logo: `https://${domain}${settings.logo}`
792
+ });
793
+ return renderTemplate(_a$1 || (_a$1 = __template$1(["<script>", '<\/script>\n<script type="application/ld+json">', "<\/script>"])), unescapeHTML(inlineClientJS), unescapeHTML(inlineJSONLd));
794
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/layouts/BaseStateJson.astro");
795
+
796
+ const $$Astro$e = createAstro("https://ecom2-002.web.app");
797
+ const $$BaseBody = createComponent(async ($$result, $$props, $$slots) => {
798
+ const Astro2 = $$result.createAstro($$Astro$e, $$props, $$slots);
799
+ Astro2.self = $$BaseBody;
800
+ return renderTemplate`${maybeRenderHead($$result)}<body>
801
+ ${renderSlot($$result, $$slots["default"])}
802
+ ${renderSlot($$result, $$slots["before-body-end"])}
803
+ </body>`;
804
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/layouts/BaseBody.astro");
805
+
806
+ const $$Astro$d = createAstro("https://ecom2-002.web.app");
807
+ const $$Base$1 = createComponent(async ($$result, $$props, $$slots) => {
808
+ const Astro2 = $$result.createAstro($$Astro$d, $$props, $$slots);
809
+ Astro2.self = $$Base$1;
810
+ const { pageContext, title } = Astro2.props;
811
+ const { cms } = pageContext;
812
+ const cmsCustomCode = cms("code");
813
+ return renderTemplate`<head>
814
+ ${renderComponent($$result, "BaseHead", $$BaseHead, { "pageContext": pageContext, "title": title })}
815
+ ${renderComponent($$result, "BaseStateJson", $$BaseStateJson, { "pageContext": pageContext })}
816
+ ${cmsCustomCode.css && renderTemplate`<style>{cmsCustomCode.css}</style>`}
817
+ ${cmsCustomCode.html_head && renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": () => renderTemplate`${unescapeHTML(cmsCustomCode.html_head)}` })}`}
818
+ ${renderSlot($$result, $$slots["base-head-scripts"])}
819
+ ${renderSlot($$result, $$slots["before-head-end"])}
820
+ ${renderHead($$result)}</head>
821
+ ${renderComponent($$result, "BaseBody", $$BaseBody, { "pageContext": pageContext }, { "default": () => renderTemplate`${renderSlot($$result, $$slots["default"])}${cmsCustomCode.html_body && renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": () => renderTemplate`${unescapeHTML(cmsCustomCode.html_body)}` })}`}${renderSlot($$result, $$slots["base-body-scripts"])}${renderSlot($$result, $$slots["before-body-end"])}` })}`;
822
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/layouts/Base.astro");
823
+
824
+ var __freeze = Object.freeze;
825
+ var __defProp = Object.defineProperty;
826
+ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
827
+ var _a;
828
+ const $$Astro$c = createAstro("https://ecom2-002.web.app");
829
+ const $$InlineScripts = createComponent(async ($$result, $$props, $$slots) => {
830
+ const Astro2 = $$result.createAstro($$Astro$c, $$props, $$slots);
831
+ Astro2.self = $$InlineScripts;
832
+ return renderTemplate(_a || (_a = __template(["<script>\n window.firebaseConfig = {\n apiKey: 'AIzaSyCrVzemDgpyp9i6ni7Yc5ZuEVfXYwl-4J0',\n authDomain: 'ecom2-002.firebaseapp.com',\n projectId: 'ecom2-002',\n storageBucket: 'ecom2-002.appspot.com',\n messagingSenderId: '402807248219',\n appId: '1:402807248219:web:cf7d57759751e74776367e',\n measurementId: 'G-SC592CE0GB',\n };\n<\/script>"])));
833
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/scripts/InlineScripts.astro");
834
+
835
+ const $$Astro$b = createAstro("https://ecom2-002.web.app");
836
+ const $$Base = createComponent(async ($$result, $$props, $$slots) => {
837
+ const Astro2 = $$result.createAstro($$Astro$b, $$props, $$slots);
838
+ Astro2.self = $$Base;
839
+ const { pageContext, title } = Astro2.props;
840
+ return renderTemplate`${renderComponent($$result, "Base", $$Base$1, { "pageContext": pageContext, "title": title }, { "before-head-end": () => renderTemplate`${renderComponent($$result, "InlineScripts", $$InlineScripts, { "slot": "before-head-end" })}`, "default": () => renderTemplate`${renderSlot($$result, $$slots["default"])}` })}`;
841
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/layouts/Base.astro");
842
+
843
+ const $$Astro$a = createAstro("https://ecom2-002.web.app");
844
+ const $$Image = createComponent(async ($$result, $$props, $$slots) => {
845
+ const Astro2 = $$result.createAstro($$Astro$a, $$props, $$slots);
846
+ Astro2.self = $$Image;
847
+ const { loading = "lazy", decoding = "async", ...props } = Astro2.props;
848
+ if (props.alt === void 0 || props.alt === null) {
849
+ warnForMissingAlt();
850
+ }
851
+ const attrs = await getImage$1(props);
852
+ return renderTemplate`${maybeRenderHead($$result)}<img${spreadAttributes(attrs)}${addAttribute(loading, "loading")}${addAttribute(decoding, "decoding")}>`;
853
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/node_modules/@astrojs/image/components/Image.astro");
854
+
855
+ const $$Astro$9 = createAstro("https://ecom2-002.web.app");
856
+ const $$Picture$1 = createComponent(async ($$result, $$props, $$slots) => {
857
+ const Astro2 = $$result.createAstro($$Astro$9, $$props, $$slots);
858
+ Astro2.self = $$Picture$1;
859
+ const {
860
+ src,
861
+ alt,
862
+ sizes,
863
+ widths,
864
+ aspectRatio,
865
+ fit,
866
+ background,
867
+ position,
868
+ formats = ["avif", "webp"],
869
+ loading = "lazy",
870
+ decoding = "async",
871
+ ...attrs
872
+ } = Astro2.props;
873
+ if (alt === void 0 || alt === null) {
874
+ warnForMissingAlt();
875
+ }
876
+ const { image, sources } = await getPicture({
877
+ src,
878
+ widths,
879
+ formats,
880
+ aspectRatio,
881
+ fit,
882
+ background,
883
+ position,
884
+ alt
885
+ });
886
+ delete image.width;
887
+ delete image.height;
888
+ return renderTemplate`${maybeRenderHead($$result)}<picture>
889
+ ${sources.map((attrs2) => renderTemplate`<source${spreadAttributes(attrs2)}${addAttribute(sizes, "sizes")}>`)}
890
+ <img${spreadAttributes(image)}${addAttribute(loading, "loading")}${addAttribute(decoding, "decoding")}${addAttribute(alt, "alt")}${spreadAttributes(attrs)}>
891
+ </picture>`;
892
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/node_modules/@astrojs/image/components/Picture.astro");
893
+
894
+ let altWarningShown = false;
895
+ function warnForMissingAlt() {
896
+ if (altWarningShown === true) {
897
+ return;
898
+ }
899
+ altWarningShown = true;
900
+ console.warn(`
901
+ [@astrojs/image] "alt" text was not provided for an <Image> or <Picture> component.
902
+
903
+ A future release of @astrojs/image may throw a build error when "alt" text is missing.
904
+
905
+ The "alt" attribute holds a text description of the image, which isn't mandatory but is incredibly useful for accessibility. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel).
906
+ `);
907
+ }
908
+
909
+ const $$Astro$8 = createAstro("https://ecom2-002.web.app");
910
+ const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
911
+ const Astro2 = $$result.createAstro($$Astro$8, $$props, $$slots);
912
+ Astro2.self = $$Picture;
913
+ const props = Astro2.props;
914
+ if (!props.aspectRatio && typeof props.src === "string") {
915
+ props.aspectRatio = getAspectRatio(props.src);
916
+ }
917
+ return renderTemplate`${renderComponent($$result, "Picture", $$Picture$1, { ...props })}`;
918
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/ssr/Picture.astro");
919
+
920
+ const checkObjNotNull = (obj) => {
921
+ return Object.values(obj).filter((val) => val).length;
922
+ };
923
+ const getModulesInfoPreset = (settingsModules = globalThis.storefront.settings.modules) => {
924
+ const modulesInfoPreset = {};
925
+ if (settingsModules) {
926
+ const settingsPayments = settingsModules.list_payments;
927
+ if (settingsPayments) {
928
+ const settingsDiscount = settingsPayments.discount_option;
929
+ if (settingsDiscount && checkObjNotNull(settingsDiscount)) {
930
+ modulesInfoPreset.list_payments = { discount_option: settingsDiscount };
931
+ }
932
+ const settingsInstallments = settingsPayments.installments_option;
933
+ if (settingsInstallments?.max_number) {
934
+ if (!modulesInfoPreset.list_payments)
935
+ modulesInfoPreset.list_payments = {};
936
+ modulesInfoPreset.list_payments.installments_option = settingsInstallments;
937
+ }
938
+ const settingsPointsPrograms = settingsPayments.loyalty_points_programs || {};
939
+ if (!Object.keys(settingsPointsPrograms).length) {
940
+ const pointsProgram = { ...settingsPayments.loyalty_points_program };
941
+ if (pointsProgram?.id && pointsProgram.ratio) {
942
+ const { id } = pointsProgram;
943
+ delete pointsProgram.id;
944
+ settingsPointsPrograms[id] = pointsProgram;
945
+ }
946
+ }
947
+ if (Object.keys(settingsPointsPrograms).length) {
948
+ if (!modulesInfoPreset.list_payments)
949
+ modulesInfoPreset.list_payments = {};
950
+ modulesInfoPreset.list_payments.loyalty_points_programs = settingsPointsPrograms;
951
+ }
952
+ }
953
+ const settingsShipping = settingsModules.calculate_shipping;
954
+ if (settingsShipping && settingsShipping.free_shipping_from_value) {
955
+ modulesInfoPreset.calculate_shipping = settingsShipping;
956
+ }
957
+ }
958
+ return modulesInfoPreset;
959
+ };
960
+ const loadingGlobalInfoPreset = new Promise((resolve) => {
961
+ {
962
+ global.storefront.onLoad(() => {
963
+ resolve(getModulesInfoPreset());
964
+ });
965
+ }
966
+ });
967
+
968
+ const emptyInfo = {
969
+ list_payments: {},
970
+ calculate_shipping: {},
971
+ apply_discount: {}
972
+ };
973
+ const modulesInfo = reactive(emptyInfo);
974
+ loadingGlobalInfoPreset.then((modulesInfoPreset) => {
975
+ Object.assign(modulesInfo, modulesInfoPreset);
976
+ });
977
+ const parsePhrase = (phrase, modName, varName, formatValue = formatMoney) => {
978
+ return computed(() => {
979
+ const searchString = `{{${varName}}}`;
980
+ const index = phrase.indexOf(searchString);
981
+ if (index > -1) {
982
+ const fieldValue = modulesInfo[modName][varName];
983
+ if (fieldValue) {
984
+ const replacement = formatValue(fieldValue);
985
+ return phrase.substring(0, index) + replacement + phrase.substring(index + searchString.length);
986
+ }
987
+ return "";
988
+ }
989
+ return phrase;
990
+ });
991
+ };
992
+ const parseShippingPhrase = (phrase) => {
993
+ return parsePhrase(phrase, "calculate_shipping", "free_shipping_from_value");
994
+ };
995
+
996
+ const carouselKey = Symbol("carousel");
997
+
998
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
999
+ __name: "CarouselControl",
1000
+ __ssrInlineRender: true,
1001
+ props: {
1002
+ direction: { default: 1 }
1003
+ },
1004
+ setup(__props) {
1005
+ inject(carouselKey);
1006
+ return (_ctx, _push, _parent, _attrs) => {
1007
+ _push(`<button${ssrRenderAttrs(mergeProps({
1008
+ type: "button",
1009
+ "aria-label": __props.direction > 0 ? "Próximo" : "Anterior",
1010
+ "data-carousel-control": __props.direction > 0 ? "next" : "previous"
1011
+ }, _attrs))}>`);
1012
+ ssrRenderSlot(_ctx.$slots, "default", {}, () => {
1013
+ _push(`<i class="${ssrRenderClass([__props.direction > 0 ? "i-chevron-right" : "i-chevron-left", "m-0"])}"></i>`);
1014
+ }, _push, _parent);
1015
+ _push(`</button>`);
1016
+ };
1017
+ }
1018
+ });
1019
+
1020
+ const _sfc_setup$5 = _sfc_main$5.setup;
1021
+ _sfc_main$5.setup = (props, ctx) => {
1022
+ const ssrContext = useSSRContext();
1023
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/CarouselControl.vue");
1024
+ return _sfc_setup$5 ? _sfc_setup$5(props, ctx) : void 0;
1025
+ };
1026
+
1027
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1028
+ __name: "Carousel",
1029
+ __ssrInlineRender: true,
1030
+ props: {
1031
+ as: { default: "ul" },
1032
+ modelValue: { default: 1 },
1033
+ autoplay: null
1034
+ },
1035
+ emits: [
1036
+ "update:modelValue",
1037
+ "bound-left",
1038
+ "bound-right"
1039
+ ],
1040
+ setup(__props, { emit }) {
1041
+ const props = __props;
1042
+ const approximatelyEqual = (v1, v2, epsilon) => {
1043
+ return Math.abs(v1 - v2) <= epsilon;
1044
+ };
1045
+ const currentPage = ref(props.modelValue - 1);
1046
+ watch(toRef(props, "modelValue"), (modelValue) => {
1047
+ currentPage.value = modelValue - 1;
1048
+ });
1049
+ watch(currentPage, (current, previous) => {
1050
+ if (current !== previous) {
1051
+ emit("update:modelValue", current + 1);
1052
+ }
1053
+ });
1054
+ const wrapper = ref(null);
1055
+ const isBoundLeft = ref(true);
1056
+ const isBoundRight = ref(false);
1057
+ const slidesWidth = ref([]);
1058
+ const wrapperScrollWidth = ref(0);
1059
+ const wrapperVisibleWidth = ref(0);
1060
+ const currentPos = ref(0);
1061
+ const maxPages = ref(0);
1062
+ ref(null);
1063
+ ref(null);
1064
+ const calcBounds = () => {
1065
+ const _isBoundLeft = approximatelyEqual(currentPos.value, 0, 5);
1066
+ const _isBoundRight = approximatelyEqual(
1067
+ wrapperScrollWidth.value - wrapperVisibleWidth.value,
1068
+ currentPos.value,
1069
+ 5
1070
+ );
1071
+ if (_isBoundLeft) {
1072
+ emit("bound-left", true);
1073
+ }
1074
+ isBoundLeft.value = _isBoundLeft;
1075
+ if (_isBoundRight) {
1076
+ emit("bound-right", true);
1077
+ }
1078
+ isBoundRight.value = _isBoundRight;
1079
+ };
1080
+ const calcWrapperWidth = () => {
1081
+ wrapperScrollWidth.value = wrapper.value.scrollWidth;
1082
+ wrapperVisibleWidth.value = wrapper.value.offsetWidth;
1083
+ };
1084
+ const calcSlidesWidth = () => {
1085
+ const childNodes = [...wrapper.value.children];
1086
+ slidesWidth.value = childNodes.map((node) => ({
1087
+ offsetLeft: node.offsetLeft,
1088
+ width: node.offsetWidth
1089
+ }));
1090
+ };
1091
+ const calcNextWidth = (direction) => {
1092
+ const nextSlideIndex = direction > 0 ? currentPage.value : currentPage.value + direction;
1093
+ const width = slidesWidth.value[nextSlideIndex].width || 0;
1094
+ if (!width) {
1095
+ return 0;
1096
+ }
1097
+ return width * direction;
1098
+ };
1099
+ const calcCurrentPage = () => {
1100
+ const getCurrentPage = slidesWidth.value.findIndex((slide) => {
1101
+ return approximatelyEqual(slide.offsetLeft, currentPos.value, 5);
1102
+ });
1103
+ if (getCurrentPage !== -1 && getCurrentPage !== -2) {
1104
+ currentPage.value = getCurrentPage || 0;
1105
+ }
1106
+ };
1107
+ const calcCurrentPosition = () => {
1108
+ currentPos.value = wrapper.value.scrollLeft || 0;
1109
+ };
1110
+ const calcMaxPages = () => {
1111
+ const maxPos = wrapperScrollWidth.value - wrapperVisibleWidth.value;
1112
+ maxPages.value = slidesWidth.value.findIndex(({ offsetLeft }) => offsetLeft >= maxPos);
1113
+ };
1114
+ const calcOnInit = () => {
1115
+ if (!wrapper.value) {
1116
+ return;
1117
+ }
1118
+ calcWrapperWidth();
1119
+ calcSlidesWidth();
1120
+ calcCurrentPosition();
1121
+ calcCurrentPage();
1122
+ calcBounds();
1123
+ calcMaxPages();
1124
+ };
1125
+ let autoplayTimer = null;
1126
+ const restartAutoplay = () => {
1127
+ if (props.autoplay) {
1128
+ clearTimeout(autoplayTimer);
1129
+ autoplayTimer = setTimeout(() => {
1130
+ changeSlide(1);
1131
+ }, props.autoplay);
1132
+ }
1133
+ };
1134
+ const changeSlide = (direction) => {
1135
+ if (direction < 0) {
1136
+ if (isBoundLeft.value) {
1137
+ calcMaxPages();
1138
+ currentPage.value = maxPages.value - 1;
1139
+ changeSlide(1);
1140
+ return;
1141
+ }
1142
+ } else if (isBoundRight.value) {
1143
+ currentPage.value = 1;
1144
+ changeSlide(-1);
1145
+ return;
1146
+ }
1147
+ const nextSlideWidth = calcNextWidth(direction);
1148
+ if (nextSlideWidth) {
1149
+ wrapper.value.scrollBy({ left: nextSlideWidth, behavior: "smooth" });
1150
+ restartAutoplay();
1151
+ }
1152
+ };
1153
+ const carousel = ref(null);
1154
+ const isHovered = useElementHover(carousel);
1155
+ watch(isHovered, (_isHovered) => {
1156
+ if (_isHovered) {
1157
+ clearTimeout(autoplayTimer);
1158
+ } else {
1159
+ restartAutoplay();
1160
+ }
1161
+ });
1162
+ onMounted(() => {
1163
+ calcOnInit();
1164
+ });
1165
+ onBeforeUnmount(() => {
1166
+ });
1167
+ provide(carouselKey, {
1168
+ autoplay: toRef(props, "autoplay"),
1169
+ changeSlide,
1170
+ isBoundLeft,
1171
+ isBoundRight
1172
+ });
1173
+ return (_ctx, _push, _parent, _attrs) => {
1174
+ _push(`<div${ssrRenderAttrs(mergeProps({
1175
+ ref_key: "carousel",
1176
+ ref: carousel,
1177
+ "data-carousel": ""
1178
+ }, _attrs))}>`);
1179
+ ssrRenderVNode(_push, createVNode(resolveDynamicComponent(__props.as), {
1180
+ ref_key: "wrapper",
1181
+ ref: wrapper,
1182
+ "data-carousel-wrapper": ""
1183
+ }, {
1184
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1185
+ if (_push2) {
1186
+ ssrRenderSlot(_ctx.$slots, "default", {}, null, _push2, _parent2, _scopeId);
1187
+ } else {
1188
+ return [
1189
+ renderSlot$1(_ctx.$slots, "default")
1190
+ ];
1191
+ }
1192
+ }),
1193
+ _: 3
1194
+ }), _parent);
1195
+ ssrRenderSlot(_ctx.$slots, "controls", { changeSlide, isBoundLeft: isBoundLeft.value, isBoundRight: isBoundRight.value }, () => {
1196
+ _push(ssrRenderComponent(_sfc_main$5, { direction: -1 }, {
1197
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1198
+ if (_push2) {
1199
+ ssrRenderSlot(_ctx.$slots, "previous", {}, null, _push2, _parent2, _scopeId);
1200
+ } else {
1201
+ return [
1202
+ renderSlot$1(_ctx.$slots, "previous")
1203
+ ];
1204
+ }
1205
+ }),
1206
+ _: 3
1207
+ }, _parent));
1208
+ _push(ssrRenderComponent(_sfc_main$5, null, {
1209
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1210
+ if (_push2) {
1211
+ ssrRenderSlot(_ctx.$slots, "next", {}, null, _push2, _parent2, _scopeId);
1212
+ } else {
1213
+ return [
1214
+ renderSlot$1(_ctx.$slots, "next")
1215
+ ];
1216
+ }
1217
+ }),
1218
+ _: 3
1219
+ }, _parent));
1220
+ }, _push, _parent);
1221
+ _push(`</div>`);
1222
+ };
1223
+ }
1224
+ });
1225
+
1226
+ const _sfc_setup$4 = _sfc_main$4.setup;
1227
+ _sfc_main$4.setup = (props, ctx) => {
1228
+ const ssrContext = useSSRContext();
1229
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/Carousel.vue");
1230
+ return _sfc_setup$4 ? _sfc_setup$4(props, ctx) : void 0;
1231
+ };
1232
+
1233
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1234
+ __name: "PitchBar",
1235
+ __ssrInlineRender: true,
1236
+ props: {
1237
+ slides: null
1238
+ },
1239
+ setup(__props) {
1240
+ const props = __props;
1241
+ const parsedContents = computed(() => {
1242
+ return props.slides.map(({ html }) => {
1243
+ return parseShippingPhrase(html).value;
1244
+ });
1245
+ });
1246
+ const countValidSlides = computed(() => {
1247
+ return parsedContents.value.filter((html) => html).length;
1248
+ });
1249
+ return (_ctx, _push, _parent, _attrs) => {
1250
+ _push(`<div${ssrRenderAttrs(mergeProps({
1251
+ "data-pitch-bar": "",
1252
+ class: "bg-base-100"
1253
+ }, _attrs))}><div class="container md:w-2/3 mx-auto px-3 py-1">`);
1254
+ _push(ssrRenderComponent(_sfc_main$4, {
1255
+ autoplay: unref(countValidSlides) > 1 ? 7e3 : null
1256
+ }, {
1257
+ controls: withCtx((_, _push2, _parent2, _scopeId) => {
1258
+ if (_push2) {
1259
+ _push2(`<div style="${ssrRenderStyle(unref(countValidSlides) > 1 ? null : { display: "none" })}" class="text-xl leading-none text-base-400"${_scopeId}>`);
1260
+ _push2(ssrRenderComponent(_sfc_main$5, {
1261
+ direction: -1,
1262
+ class: "pr-2 bg-base-100 hover:text-base-700"
1263
+ }, null, _parent2, _scopeId));
1264
+ _push2(ssrRenderComponent(_sfc_main$5, { class: "pl-2 bg-base-100 hover:text-base-700" }, null, _parent2, _scopeId));
1265
+ _push2(`</div>`);
1266
+ } else {
1267
+ return [
1268
+ withDirectives(createVNode("div", { class: "text-xl leading-none text-base-400" }, [
1269
+ createVNode(_sfc_main$5, {
1270
+ direction: -1,
1271
+ class: "pr-2 bg-base-100 hover:text-base-700"
1272
+ }),
1273
+ createVNode(_sfc_main$5, { class: "pl-2 bg-base-100 hover:text-base-700" })
1274
+ ], 512), [
1275
+ [vShow, unref(countValidSlides) > 1]
1276
+ ])
1277
+ ];
1278
+ }
1279
+ }),
1280
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1281
+ if (_push2) {
1282
+ _push2(`<!--[-->`);
1283
+ ssrRenderList(__props.slides, (slide, i) => {
1284
+ _push2(`<li${_scopeId}>`);
1285
+ ssrRenderVNode(_push2, createVNode(resolveDynamicComponent(slide.href ? "ALink" : "span"), {
1286
+ href: slide.href,
1287
+ target: slide.target,
1288
+ class: slide.href ? "hover:underline" : null
1289
+ }, {
1290
+ default: withCtx((_2, _push3, _parent3, _scopeId2) => {
1291
+ if (_push3) {
1292
+ ssrRenderSlot(_ctx.$slots, "slide", { slide, i, parsedContents: unref(parsedContents) }, () => {
1293
+ if (unref(parsedContents)[i]) {
1294
+ _push3(`<span class="prose text-sm text-base-800"${_scopeId2}>${unref(parsedContents)[i]}</span>`);
1295
+ } else {
1296
+ _push3(`<!---->`);
1297
+ }
1298
+ }, _push3, _parent3, _scopeId2);
1299
+ } else {
1300
+ return [
1301
+ renderSlot$1(_ctx.$slots, "slide", { slide, i, parsedContents: unref(parsedContents) }, () => [
1302
+ unref(parsedContents)[i] ? (openBlock(), createBlock("span", {
1303
+ key: 0,
1304
+ innerHTML: unref(parsedContents)[i],
1305
+ class: "prose text-sm text-base-800"
1306
+ }, null, 8, ["innerHTML"])) : createCommentVNode("", true)
1307
+ ])
1308
+ ];
1309
+ }
1310
+ }),
1311
+ _: 2
1312
+ }), _parent2, _scopeId);
1313
+ _push2(`</li>`);
1314
+ });
1315
+ _push2(`<!--]-->`);
1316
+ } else {
1317
+ return [
1318
+ (openBlock(true), createBlock(Fragment$1, null, renderList(__props.slides, (slide, i) => {
1319
+ return openBlock(), createBlock("li", { key: i }, [
1320
+ (openBlock(), createBlock(resolveDynamicComponent(slide.href ? "ALink" : "span"), {
1321
+ href: slide.href,
1322
+ target: slide.target,
1323
+ class: slide.href ? "hover:underline" : null
1324
+ }, {
1325
+ default: withCtx(() => [
1326
+ renderSlot$1(_ctx.$slots, "slide", { slide, i, parsedContents: unref(parsedContents) }, () => [
1327
+ unref(parsedContents)[i] ? (openBlock(), createBlock("span", {
1328
+ key: 0,
1329
+ innerHTML: unref(parsedContents)[i],
1330
+ class: "prose text-sm text-base-800"
1331
+ }, null, 8, ["innerHTML"])) : createCommentVNode("", true)
1332
+ ])
1333
+ ]),
1334
+ _: 2
1335
+ }, 1032, ["href", "target", "class"]))
1336
+ ]);
1337
+ }), 128))
1338
+ ];
1339
+ }
1340
+ }),
1341
+ _: 3
1342
+ }, _parent));
1343
+ _push(`</div></div>`);
1344
+ };
1345
+ }
1346
+ });
1347
+
1348
+ const _sfc_setup$3 = _sfc_main$3.setup;
1349
+ _sfc_main$3.setup = (props, ctx) => {
1350
+ const ssrContext = useSSRContext();
1351
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/PitchBar.vue");
1352
+ return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
1353
+ };
1354
+
1355
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1356
+ __name: "StickyHeader",
1357
+ __ssrInlineRender: true,
1358
+ props: {
1359
+ logo: null,
1360
+ logoAltHeading: { default: "h2" }
1361
+ },
1362
+ setup(__props) {
1363
+ const props = __props;
1364
+ const { logo } = toRefs(props);
1365
+ const fade = ref(false);
1366
+ setTimeout(() => {
1367
+ fade.value = true;
1368
+ }, 2e3);
1369
+ return (_ctx, _push, _parent, _attrs) => {
1370
+ const _component_Fade = resolveComponent("Fade");
1371
+ _push(`<header${ssrRenderAttrs(mergeProps({
1372
+ class: "header bg-opacity-90 backdrop-blur-md sticky top-0 z-50 py-1 sm:py-2",
1373
+ "data-sticky-header": ""
1374
+ }, _attrs))}><div class="container"><div class="grid grid-flow-col auto-cols-max justify-between items-center">`);
1375
+ ssrRenderSlot(_ctx.$slots, "aside", {}, () => {
1376
+ _push(`<div class="header__aside md:hidden"><div class="i-bars-3-bottom-left"></div></div>`);
1377
+ }, _push, _parent);
1378
+ ssrRenderSlot(_ctx.$slots, "logo", { logo: unref(logo) }, () => {
1379
+ if (unref(logo)) {
1380
+ _push(`<a href="/">`);
1381
+ ssrRenderVNode(_push, createVNode(resolveDynamicComponent(unref(logo).alt && __props.logoAltHeading || "span"), { class: "m-0" }, {
1382
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1383
+ if (_push2) {
1384
+ _push2(`<img${ssrRenderAttrs(unref(logo))}${_scopeId}>`);
1385
+ } else {
1386
+ return [
1387
+ createVNode("img", unref(logo), null, 16)
1388
+ ];
1389
+ }
1390
+ }),
1391
+ _: 1
1392
+ }), _parent);
1393
+ _push(`</a>`);
1394
+ } else {
1395
+ _push(`<!---->`);
1396
+ }
1397
+ }, _push, _parent);
1398
+ _push(`<div class="flex items-center">`);
1399
+ ssrRenderSlot(_ctx.$slots, "actions", {}, () => {
1400
+ ssrRenderSlot(_ctx.$slots, "nav", {}, () => {
1401
+ _push(ssrRenderComponent(_component_Fade, {
1402
+ speed: "slow",
1403
+ slide: "down"
1404
+ }, {
1405
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1406
+ if (_push2) {
1407
+ if (fade.value) {
1408
+ _push2(`<div class="h-20 bg-primary w-20"${_scopeId}> Fadiiing </div>`);
1409
+ } else {
1410
+ _push2(`<!---->`);
1411
+ }
1412
+ } else {
1413
+ return [
1414
+ fade.value ? (openBlock(), createBlock("div", {
1415
+ key: 0,
1416
+ class: "h-20 bg-primary w-20"
1417
+ }, " Fadiiing ")) : createCommentVNode("", true)
1418
+ ];
1419
+ }
1420
+ }),
1421
+ _: 1
1422
+ }, _parent));
1423
+ }, _push, _parent);
1424
+ ssrRenderSlot(_ctx.$slots, "search", {}, null, _push, _parent);
1425
+ ssrRenderSlot(_ctx.$slots, "buttons", {}, null, _push, _parent);
1426
+ }, _push, _parent);
1427
+ _push(`</div></div></div></header>`);
1428
+ };
1429
+ }
1430
+ });
1431
+
1432
+ const _sfc_setup$2 = _sfc_main$2.setup;
1433
+ _sfc_main$2.setup = (props, ctx) => {
1434
+ const ssrContext = useSSRContext();
1435
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/StickyHeader.vue");
1436
+ return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
1437
+ };
1438
+
1439
+ const $$Astro$7 = createAstro("https://ecom2-002.web.app");
1440
+ const $$PagesHeader = createComponent(async ($$result, $$props, $$slots) => {
1441
+ const Astro2 = $$result.createAstro($$Astro$7, $$props, $$slots);
1442
+ Astro2.self = $$PagesHeader;
1443
+ const {
1444
+ pageContext: {
1445
+ isHomepage,
1446
+ apiState,
1447
+ settings,
1448
+ cms
1449
+ }
1450
+ } = Astro2.props;
1451
+ const header = cms("header");
1452
+ const pitchBar = { slides: [] };
1453
+ if (header.pitch_bar) {
1454
+ pitchBar.slides = header.pitch_bar;
1455
+ } else if (header.marketing_stripe) {
1456
+ pitchBar.slides = [{
1457
+ href: header.marketing_stripe.link,
1458
+ html: header.marketing_stripe.text
1459
+ }];
1460
+ }
1461
+ const logoSrc = header.logo || settings.logo;
1462
+ const LogoHeading = Astro2.props.logoHeading || (isHomepage ? "h1" : "h2");
1463
+ return renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": () => renderTemplate`${renderSlot($$result, $$slots["pitch-bar"], renderTemplate`
1464
+ ${pitchBar.slides.length && renderTemplate`${renderComponent($$result, "PitchBar", _sfc_main$3, { ...pitchBar, "client:idle": true, "client:component-hydration": "idle", "client:component-path": "@@sf/components/PitchBar.vue", "client:component-export": "default" })}`}
1465
+ `)}${renderSlot($$result, $$slots["sticky-header"], renderTemplate`
1466
+ ${renderComponent($$result, "StickyHeader", _sfc_main$2, { "client:load": true, "client:component-hydration": "load", "client:component-path": "@@sf/components/StickyHeader.vue", "client:component-export": "default" }, { "logo": () => renderTemplate`${renderComponent($$result, "Fragment", Fragment, { "slot": "logo" }, { "default": () => renderTemplate`${renderSlot($$result, $$slots["logo"], renderTemplate`
1467
+ ${renderComponent($$result, "LogoHeading", LogoHeading, {}, { "default": () => renderTemplate`${renderComponent($$result, "Picture", $$Picture, { "src": logoSrc, "alt": settings.name, "widths": [300], "sizes": "150px", "fetchpriority": "high" })}` })}
1468
+ `)}` })}` })}
1469
+ `)}` })}`;
1470
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/layouts/PagesHeader.astro");
1471
+
1472
+ const $$Astro$6 = createAstro("https://ecom2-002.web.app");
1473
+ const $$Pages = createComponent(async ($$result, $$props, $$slots) => {
1474
+ const Astro2 = $$result.createAstro($$Astro$6, $$props, $$slots);
1475
+ Astro2.self = $$Pages;
1476
+ const { pageContext, title } = Astro2.props;
1477
+ return renderTemplate`${renderComponent($$result, "Base", $$Base, { "pageContext": pageContext, "title": title }, { "default": () => renderTemplate`${renderSlot($$result, $$slots["header"], renderTemplate`
1478
+ ${renderComponent($$result, "Header", $$PagesHeader, { "pageContext": pageContext })}
1479
+ `)}${renderSlot($$result, $$slots["default"])}` })}`;
1480
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/layouts/Pages.astro");
1481
+
1482
+ const getPriceWithDiscount = (price, discount) => {
1483
+ const { type, value } = discount;
1484
+ let priceWithDiscount;
1485
+ if (value) {
1486
+ if (type === "percentage") {
1487
+ priceWithDiscount = price * ((100 - value) / 100);
1488
+ } else {
1489
+ priceWithDiscount = price - value;
1490
+ }
1491
+ return priceWithDiscount > 0 ? priceWithDiscount : 0;
1492
+ }
1493
+ return price;
1494
+ };
1495
+ const usePrices = (props) => {
1496
+ const _product = computed(() => {
1497
+ return props.product || {
1498
+ price: props.price || 0,
1499
+ base_price: props.basePrice
1500
+ };
1501
+ });
1502
+ const hasVariedPrices = computed(() => {
1503
+ const { variations } = _product.value;
1504
+ if (variations) {
1505
+ const productPrice = price(_product.value);
1506
+ for (let i = 0; i < variations.length; i++) {
1507
+ const price$1 = price({
1508
+ ..._product.value,
1509
+ ...variations[i]
1510
+ });
1511
+ if (price$1 > productPrice) {
1512
+ return true;
1513
+ }
1514
+ }
1515
+ }
1516
+ return false;
1517
+ });
1518
+ const extraDiscount = computed(() => {
1519
+ return modulesInfo.apply_discount.available_extra_discount;
1520
+ });
1521
+ const salePrice = computed(() => {
1522
+ const price$1 = price(_product.value);
1523
+ const discount = extraDiscount.value;
1524
+ if (discount && (!discount.min_amount || price$1 > discount.min_amount)) {
1525
+ return getPriceWithDiscount(price$1, discount);
1526
+ }
1527
+ return price$1;
1528
+ });
1529
+ const comparePrice = computed(() => {
1530
+ if (onPromotion(_product.value)) {
1531
+ return _product.value.base_price;
1532
+ }
1533
+ const price$1 = price(_product.value);
1534
+ if (price$1 > salePrice.value) {
1535
+ return price$1;
1536
+ }
1537
+ return 0;
1538
+ });
1539
+ const installmentsObject = computed(() => {
1540
+ return props.installmentsOption || modulesInfo.list_payments.installments_option || { max_number: 1 };
1541
+ });
1542
+ const installmentsNumber = computed(() => {
1543
+ if (installmentsObject.value.max_number <= 1) {
1544
+ return 1;
1545
+ }
1546
+ const minInstallment = installmentsObject.value.min_installment || 5;
1547
+ const maxInstallmentsNumber = Math.round(salePrice.value / minInstallment);
1548
+ return Math.min(maxInstallmentsNumber, installmentsObject.value.max_number);
1549
+ });
1550
+ const monthlyInterest = computed(() => {
1551
+ return installmentsObject.value.monthly_interest || 0;
1552
+ });
1553
+ const installmentValue = computed(() => {
1554
+ if (installmentsNumber.value >= 2) {
1555
+ if (!monthlyInterest.value) {
1556
+ return salePrice.value / installmentsNumber.value;
1557
+ }
1558
+ const interest = monthlyInterest.value / 100;
1559
+ return salePrice.value * interest / (1 - (1 + interest) ** -installmentsNumber.value);
1560
+ }
1561
+ return 0;
1562
+ });
1563
+ const discountObject = computed(() => {
1564
+ const discount = props.discountOption || modulesInfo.list_payments.discount_option;
1565
+ if (discount && (!discount.min_amount || discount.min_amount <= salePrice.value) && (!props.isAmountTotal || discount.apply_at === "total")) {
1566
+ return discount;
1567
+ }
1568
+ return {};
1569
+ });
1570
+ const discountLabel = computed(() => {
1571
+ const { label } = discountObject.value;
1572
+ if (label) {
1573
+ if (label.includes(" ")) {
1574
+ return label;
1575
+ }
1576
+ return `via ${label}`;
1577
+ }
1578
+ return "";
1579
+ });
1580
+ const priceWithDiscount = computed(() => {
1581
+ return getPriceWithDiscount(salePrice.value, discountObject.value);
1582
+ });
1583
+ const pointsProgramObject = computed(() => {
1584
+ if (props.loyaltyPointsProgram) {
1585
+ return props.loyaltyPointsProgram;
1586
+ }
1587
+ const pointsPrograms = modulesInfo.list_payments.loyalty_points_programs;
1588
+ if (pointsPrograms) {
1589
+ const programIds = Object.keys(pointsPrograms);
1590
+ for (let i = 0; i < programIds.length; i++) {
1591
+ const program = pointsPrograms[programIds[i]];
1592
+ if (program && program.earn_percentage > 0) {
1593
+ return program;
1594
+ }
1595
+ }
1596
+ }
1597
+ return { ratio: 0 };
1598
+ });
1599
+ const pointsMinPrice = computed(() => {
1600
+ return pointsProgramObject.value.min_subtotal_to_earn || 0;
1601
+ });
1602
+ const pointsProgramName = computed(() => {
1603
+ return pointsProgramObject.value.name || "";
1604
+ });
1605
+ const earnPointsPercentage = computed(() => {
1606
+ return pointsProgramObject.value.earn_percentage || 0;
1607
+ });
1608
+ const cashbackPercentage = computed(() => {
1609
+ return earnPointsPercentage.value * pointsProgramObject.value.ratio;
1610
+ });
1611
+ const cashbackValue = computed(() => {
1612
+ return cashbackPercentage.value >= 1 ? salePrice.value * (cashbackPercentage.value / 100) : 0;
1613
+ });
1614
+ return {
1615
+ hasVariedPrices,
1616
+ salePrice,
1617
+ comparePrice,
1618
+ installmentsObject,
1619
+ installmentsNumber,
1620
+ monthlyInterest,
1621
+ installmentValue,
1622
+ discountObject,
1623
+ discountLabel,
1624
+ priceWithDiscount,
1625
+ pointsProgramObject,
1626
+ pointsMinPrice,
1627
+ pointsProgramName,
1628
+ earnPointsPercentage,
1629
+ cashbackPercentage,
1630
+ cashbackValue
1631
+ };
1632
+ };
1633
+
1634
+ const useComponentVariant = (props) => {
1635
+ return computed(() => {
1636
+ let variantName = "";
1637
+ Object.keys(props).forEach((prop) => {
1638
+ if (props[prop] === true) {
1639
+ variantName += ` ${prop.replace(/^(is|has)/, "")}`;
1640
+ }
1641
+ });
1642
+ return variantName.slice(1);
1643
+ });
1644
+ };
1645
+
1646
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1647
+ __name: "Prices",
1648
+ __ssrInlineRender: true,
1649
+ props: {
1650
+ product: null,
1651
+ price: null,
1652
+ basePrice: null,
1653
+ isAmountTotal: { type: Boolean },
1654
+ installmentsOption: null,
1655
+ discountOption: null,
1656
+ isBig: { type: Boolean },
1657
+ isLiteral: { type: Boolean },
1658
+ hasCashback: { type: Boolean, default: true },
1659
+ hasPriceOptions: { type: Boolean, default: true }
1660
+ },
1661
+ setup(__props) {
1662
+ const props = __props;
1663
+ const prices = usePrices(props);
1664
+ const {
1665
+ hasVariedPrices,
1666
+ salePrice,
1667
+ comparePrice,
1668
+ cashbackPercentage,
1669
+ cashbackValue,
1670
+ installmentsNumber,
1671
+ monthlyInterest,
1672
+ installmentValue,
1673
+ priceWithDiscount,
1674
+ discountLabel
1675
+ } = prices;
1676
+ const componentVariant = useComponentVariant(props);
1677
+ return (_ctx, _push, _parent, _attrs) => {
1678
+ const _component_Fade = resolveComponent("Fade");
1679
+ _push(`<div${ssrRenderAttrs(mergeProps({
1680
+ "data-prices": unref(componentVariant),
1681
+ class: "text-base-600"
1682
+ }, _attrs))}>`);
1683
+ if (unref(comparePrice)) {
1684
+ ssrRenderSlot(_ctx.$slots, "compare", { salePrice: unref(salePrice), comparePrice: unref(comparePrice) }, () => {
1685
+ _push(`<span data-prices-compare class="text-base-500 mr-1">`);
1686
+ ssrRenderSlot(_ctx.$slots, "compare-pre", {}, () => {
1687
+ if (__props.isLiteral) {
1688
+ _push(`<small>${ssrInterpolate(`${"De"} `)}</small>`);
1689
+ } else {
1690
+ _push(`<!---->`);
1691
+ }
1692
+ }, _push, _parent);
1693
+ ssrRenderSlot(_ctx.$slots, "compare-value", { salePrice: unref(salePrice), comparePrice: unref(comparePrice) }, () => {
1694
+ _push(`<s>${ssrInterpolate(_ctx.$money(unref(comparePrice)))}</s>`);
1695
+ }, _push, _parent);
1696
+ ssrRenderSlot(_ctx.$slots, "compare-post", {}, () => {
1697
+ if (__props.isLiteral) {
1698
+ _push(`<small>${ssrInterpolate(` ${"Por"}`)}</small>`);
1699
+ } else {
1700
+ _push(`<!---->`);
1701
+ }
1702
+ }, _push, _parent);
1703
+ _push(`</span>`);
1704
+ }, _push, _parent);
1705
+ } else {
1706
+ _push(`<!---->`);
1707
+ }
1708
+ ssrRenderSlot(_ctx.$slots, "sale", { salePrice: unref(salePrice) }, () => {
1709
+ _push(`<strong data-prices-sale class="inline-block text-base-800">`);
1710
+ ssrRenderSlot(_ctx.$slots, "sale-pre", {}, () => {
1711
+ if (unref(hasVariedPrices)) {
1712
+ _push(`<small>${ssrInterpolate(`${"A partir de"} `)}</small>`);
1713
+ } else {
1714
+ _push(`<!---->`);
1715
+ }
1716
+ }, _push, _parent);
1717
+ ssrRenderSlot(_ctx.$slots, "sale-value", { salePrice: unref(salePrice) }, () => {
1718
+ _push(`${ssrInterpolate(_ctx.$money(unref(salePrice)))}`);
1719
+ }, _push, _parent);
1720
+ ssrRenderSlot(_ctx.$slots, "sale-post", {}, null, _push, _parent);
1721
+ _push(`</strong>`);
1722
+ }, _push, _parent);
1723
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
1724
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1725
+ if (_push2) {
1726
+ if (unref(cashbackValue)) {
1727
+ ssrRenderSlot(_ctx.$slots, "cashback", { salePrice: unref(salePrice), cashbackValue: unref(cashbackValue), cashbackPercentage: unref(cashbackPercentage) }, () => {
1728
+ if (__props.hasCashback) {
1729
+ _push2(`<div data-prices-cashback class="relative z-10"${_scopeId}><span${ssrRenderAttr("data-tooltip", "Receba $1 de volta".replace("$1", _ctx.$percentage(unref(cashbackPercentage))))}${_scopeId}>`);
1730
+ ssrRenderSlot(_ctx.$slots, "cashback-pre", {}, () => {
1731
+ _push2(`<i class="i-cashback mr-1"${_scopeId}></i>`);
1732
+ }, _push2, _parent2, _scopeId);
1733
+ ssrRenderSlot(_ctx.$slots, "cashback-value", { salePrice: unref(salePrice), cashbackValue: unref(cashbackValue), cashbackPercentage: unref(cashbackPercentage) }, () => {
1734
+ _push2(`<span class="font-medium"${_scopeId}>${ssrInterpolate(_ctx.$money(unref(cashbackValue)))}</span>`);
1735
+ }, _push2, _parent2, _scopeId);
1736
+ ssrRenderSlot(_ctx.$slots, "cashback-post", {}, () => {
1737
+ _push2(`<small${_scopeId}> cashback</small>`);
1738
+ }, _push2, _parent2, _scopeId);
1739
+ _push2(`</span></div>`);
1740
+ } else {
1741
+ _push2(`<!---->`);
1742
+ }
1743
+ }, _push2, _parent2, _scopeId);
1744
+ } else {
1745
+ _push2(`<!---->`);
1746
+ }
1747
+ } else {
1748
+ return [
1749
+ unref(cashbackValue) ? renderSlot$1(_ctx.$slots, "cashback", mergeProps({ key: 0 }, { salePrice: unref(salePrice), cashbackValue: unref(cashbackValue), cashbackPercentage: unref(cashbackPercentage) }), () => [
1750
+ __props.hasCashback ? (openBlock(), createBlock("div", {
1751
+ key: 0,
1752
+ "data-prices-cashback": "",
1753
+ class: "relative z-10"
1754
+ }, [
1755
+ createVNode("span", {
1756
+ "data-tooltip": "Receba $1 de volta".replace("$1", _ctx.$percentage(unref(cashbackPercentage)))
1757
+ }, [
1758
+ renderSlot$1(_ctx.$slots, "cashback-pre", {}, () => [
1759
+ createVNode("i", { class: "i-cashback mr-1" })
1760
+ ]),
1761
+ renderSlot$1(_ctx.$slots, "cashback-value", { salePrice: unref(salePrice), cashbackValue: unref(cashbackValue), cashbackPercentage: unref(cashbackPercentage) }, () => [
1762
+ createVNode("span", { class: "font-medium" }, toDisplayString(_ctx.$money(unref(cashbackValue))), 1)
1763
+ ]),
1764
+ renderSlot$1(_ctx.$slots, "cashback-post", {}, () => [
1765
+ createVNode("small", null, " cashback")
1766
+ ])
1767
+ ], 8, ["data-tooltip"])
1768
+ ])) : createCommentVNode("", true)
1769
+ ]) : createCommentVNode("", true)
1770
+ ];
1771
+ }
1772
+ }),
1773
+ _: 3
1774
+ }, _parent));
1775
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
1776
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1777
+ if (_push2) {
1778
+ if (unref(installmentValue)) {
1779
+ ssrRenderSlot(_ctx.$slots, "installment", { salePrice: unref(salePrice), installmentValue: unref(installmentValue), installmentsNumber: unref(installmentsNumber), monthlyInterest: unref(monthlyInterest) }, () => {
1780
+ if (__props.hasPriceOptions) {
1781
+ _push2(`<div data-prices-installment${_scopeId}>`);
1782
+ ssrRenderSlot(_ctx.$slots, "installment-pre", {}, () => {
1783
+ if (__props.isLiteral) {
1784
+ _push2(`<small${_scopeId}>${ssrInterpolate(`${"Até"} `)}</small>`);
1785
+ } else {
1786
+ _push2(`<!---->`);
1787
+ }
1788
+ }, _push2, _parent2, _scopeId);
1789
+ ssrRenderSlot(_ctx.$slots, "installment-value", { salePrice: unref(salePrice), installmentValue: unref(installmentValue), installmentsNumber: unref(installmentsNumber), monthlyInterest: unref(monthlyInterest) }, () => {
1790
+ _push2(`${ssrInterpolate(unref(installmentsNumber))}x `);
1791
+ if (__props.isLiteral) {
1792
+ _push2(`<small${_scopeId}>${ssrInterpolate(` ${"De"} `)}</small>`);
1793
+ } else {
1794
+ _push2(`<!---->`);
1795
+ }
1796
+ _push2(`<span${_scopeId}>${ssrInterpolate(_ctx.$money(unref(installmentValue)))}</span>`);
1797
+ }, _push2, _parent2, _scopeId);
1798
+ ssrRenderSlot(_ctx.$slots, "installment-post", {}, () => {
1799
+ if (!unref(monthlyInterest) && __props.isLiteral) {
1800
+ _push2(`<small${_scopeId}>${ssrInterpolate("Sem juros")}</small>`);
1801
+ } else {
1802
+ _push2(`<!---->`);
1803
+ }
1804
+ }, _push2, _parent2, _scopeId);
1805
+ _push2(`</div>`);
1806
+ } else {
1807
+ _push2(`<!---->`);
1808
+ }
1809
+ }, _push2, _parent2, _scopeId);
1810
+ } else {
1811
+ _push2(`<!---->`);
1812
+ }
1813
+ } else {
1814
+ return [
1815
+ unref(installmentValue) ? renderSlot$1(_ctx.$slots, "installment", mergeProps({ key: 0 }, { salePrice: unref(salePrice), installmentValue: unref(installmentValue), installmentsNumber: unref(installmentsNumber), monthlyInterest: unref(monthlyInterest) }), () => [
1816
+ __props.hasPriceOptions ? (openBlock(), createBlock("div", {
1817
+ key: 0,
1818
+ "data-prices-installment": ""
1819
+ }, [
1820
+ renderSlot$1(_ctx.$slots, "installment-pre", {}, () => [
1821
+ __props.isLiteral ? (openBlock(), createBlock("small", { key: 0 }, toDisplayString(`${"Até"} `))) : createCommentVNode("", true)
1822
+ ]),
1823
+ renderSlot$1(_ctx.$slots, "installment-value", { salePrice: unref(salePrice), installmentValue: unref(installmentValue), installmentsNumber: unref(installmentsNumber), monthlyInterest: unref(monthlyInterest) }, () => [
1824
+ createTextVNode(toDisplayString(unref(installmentsNumber)) + "x ", 1),
1825
+ __props.isLiteral ? (openBlock(), createBlock("small", { key: 0 }, toDisplayString(` ${"De"} `))) : createCommentVNode("", true),
1826
+ createVNode("span", null, toDisplayString(_ctx.$money(unref(installmentValue))), 1)
1827
+ ]),
1828
+ renderSlot$1(_ctx.$slots, "installment-post", {}, () => [
1829
+ !unref(monthlyInterest) && __props.isLiteral ? (openBlock(), createBlock("small", { key: 0 }, toDisplayString("Sem juros"))) : createCommentVNode("", true)
1830
+ ])
1831
+ ])) : createCommentVNode("", true)
1832
+ ]) : createCommentVNode("", true)
1833
+ ];
1834
+ }
1835
+ }),
1836
+ _: 3
1837
+ }, _parent));
1838
+ _push(ssrRenderComponent(_component_Fade, { slide: "down" }, {
1839
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1840
+ if (_push2) {
1841
+ if (unref(priceWithDiscount) < unref(salePrice)) {
1842
+ ssrRenderSlot(_ctx.$slots, "discount", { salePrice: unref(salePrice), priceWithDiscount: unref(priceWithDiscount), discountLabel: unref(discountLabel) }, () => {
1843
+ if (__props.hasPriceOptions) {
1844
+ _push2(`<div data-prices-discount${_scopeId}>`);
1845
+ ssrRenderSlot(_ctx.$slots, "discount-pre", {}, () => {
1846
+ if (!unref(discountLabel)) {
1847
+ _push2(`<small${_scopeId}>${ssrInterpolate(`${"A partir de"} `)}</small>`);
1848
+ } else {
1849
+ _push2(`<!---->`);
1850
+ }
1851
+ }, _push2, _parent2, _scopeId);
1852
+ ssrRenderSlot(_ctx.$slots, "discount-value", { salePrice: unref(salePrice), priceWithDiscount: unref(priceWithDiscount), discountLabel: unref(discountLabel) }, () => {
1853
+ _push2(`<span${_scopeId}>${ssrInterpolate(_ctx.$money(unref(priceWithDiscount)))}</span>`);
1854
+ }, _push2, _parent2, _scopeId);
1855
+ ssrRenderSlot(_ctx.$slots, "discount-post", {}, () => {
1856
+ if (unref(discountLabel)) {
1857
+ _push2(`<small${_scopeId}>${ssrInterpolate(` ${unref(discountLabel)}`)}</small>`);
1858
+ } else {
1859
+ _push2(`<!---->`);
1860
+ }
1861
+ }, _push2, _parent2, _scopeId);
1862
+ _push2(`</div>`);
1863
+ } else {
1864
+ _push2(`<!---->`);
1865
+ }
1866
+ }, _push2, _parent2, _scopeId);
1867
+ } else {
1868
+ _push2(`<!---->`);
1869
+ }
1870
+ } else {
1871
+ return [
1872
+ unref(priceWithDiscount) < unref(salePrice) ? renderSlot$1(_ctx.$slots, "discount", mergeProps({ key: 0 }, { salePrice: unref(salePrice), priceWithDiscount: unref(priceWithDiscount), discountLabel: unref(discountLabel) }), () => [
1873
+ __props.hasPriceOptions ? (openBlock(), createBlock("div", {
1874
+ key: 0,
1875
+ "data-prices-discount": ""
1876
+ }, [
1877
+ renderSlot$1(_ctx.$slots, "discount-pre", {}, () => [
1878
+ !unref(discountLabel) ? (openBlock(), createBlock("small", { key: 0 }, toDisplayString(`${"A partir de"} `))) : createCommentVNode("", true)
1879
+ ]),
1880
+ renderSlot$1(_ctx.$slots, "discount-value", { salePrice: unref(salePrice), priceWithDiscount: unref(priceWithDiscount), discountLabel: unref(discountLabel) }, () => [
1881
+ createVNode("span", null, toDisplayString(_ctx.$money(unref(priceWithDiscount))), 1)
1882
+ ]),
1883
+ renderSlot$1(_ctx.$slots, "discount-post", {}, () => [
1884
+ unref(discountLabel) ? (openBlock(), createBlock("small", { key: 0 }, toDisplayString(` ${unref(discountLabel)}`), 1)) : createCommentVNode("", true)
1885
+ ])
1886
+ ])) : createCommentVNode("", true)
1887
+ ]) : createCommentVNode("", true)
1888
+ ];
1889
+ }
1890
+ }),
1891
+ _: 3
1892
+ }, _parent));
1893
+ _push(`</div>`);
1894
+ };
1895
+ }
1896
+ });
1897
+
1898
+ const _sfc_setup$1 = _sfc_main$1.setup;
1899
+ _sfc_main$1.setup = (props, ctx) => {
1900
+ const ssrContext = useSSRContext();
1901
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/Prices.vue");
1902
+ return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
1903
+ };
1904
+
1905
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1906
+ __name: "ProductCard",
1907
+ __ssrInlineRender: true,
1908
+ props: {
1909
+ as: { default: "div" }
1910
+ },
1911
+ setup(__props) {
1912
+ const price = ref(12);
1913
+ const isBig = ref(false);
1914
+ setTimeout(() => {
1915
+ price.value = 8;
1916
+ isBig.value = true;
1917
+ }, 5e3);
1918
+ return (_ctx, _push, _parent, _attrs) => {
1919
+ ssrRenderVNode(_push, createVNode(resolveDynamicComponent(__props.as), _attrs, {
1920
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
1921
+ if (_push2) {
1922
+ _push2(ssrRenderComponent(_sfc_main$1, null, {
1923
+ default: withCtx(({ salePrice }, _push3, _parent3, _scopeId2) => {
1924
+ if (_push3) {
1925
+ _push3(` ProductCard ${ssrInterpolate(salePrice)}`);
1926
+ } else {
1927
+ return [
1928
+ createTextVNode(" ProductCard " + toDisplayString(salePrice), 1)
1929
+ ];
1930
+ }
1931
+ }),
1932
+ _: 1
1933
+ }, _parent2, _scopeId));
1934
+ _push2(ssrRenderComponent(_sfc_main$1, {
1935
+ product: { price: price.value }
1936
+ }, null, _parent2, _scopeId));
1937
+ _push2(ssrRenderComponent(_sfc_main$1, {
1938
+ price: 12,
1939
+ "base-price": 17
1940
+ }, null, _parent2, _scopeId));
1941
+ _push2(ssrRenderComponent(_sfc_main$1, {
1942
+ price: 12,
1943
+ "base-price": 16,
1944
+ "is-literal": true
1945
+ }, null, _parent2, _scopeId));
1946
+ _push2(ssrRenderComponent(_sfc_main$1, {
1947
+ price: 12,
1948
+ "is-big": isBig.value
1949
+ }, null, _parent2, _scopeId));
1950
+ _push2(ssrRenderComponent(_sfc_main$1, {
1951
+ price: 14,
1952
+ "base-price": 18,
1953
+ "is-big": isBig.value,
1954
+ "is-literal": true
1955
+ }, null, _parent2, _scopeId));
1956
+ _push2(ssrRenderComponent(_sfc_main$1, {
1957
+ price: 12,
1958
+ "base-price": 16
1959
+ }, {
1960
+ "compare-value": withCtx(({ comparePrice }, _push3, _parent3, _scopeId2) => {
1961
+ if (_push3) {
1962
+ _push3(` x${ssrInterpolate(comparePrice)}`);
1963
+ } else {
1964
+ return [
1965
+ createTextVNode(" x" + toDisplayString(comparePrice), 1)
1966
+ ];
1967
+ }
1968
+ }),
1969
+ _: 1
1970
+ }, _parent2, _scopeId));
1971
+ } else {
1972
+ return [
1973
+ createVNode(_sfc_main$1, null, {
1974
+ default: withCtx(({ salePrice }) => [
1975
+ createTextVNode(" ProductCard " + toDisplayString(salePrice), 1)
1976
+ ]),
1977
+ _: 1
1978
+ }),
1979
+ createVNode(_sfc_main$1, {
1980
+ product: { price: price.value }
1981
+ }, null, 8, ["product"]),
1982
+ createVNode(_sfc_main$1, {
1983
+ price: 12,
1984
+ "base-price": 17
1985
+ }),
1986
+ createVNode(_sfc_main$1, {
1987
+ price: 12,
1988
+ "base-price": 16,
1989
+ "is-literal": true
1990
+ }),
1991
+ createVNode(_sfc_main$1, {
1992
+ price: 12,
1993
+ "is-big": isBig.value
1994
+ }, null, 8, ["is-big"]),
1995
+ createVNode(_sfc_main$1, {
1996
+ price: 14,
1997
+ "base-price": 18,
1998
+ "is-big": isBig.value,
1999
+ "is-literal": true
2000
+ }, null, 8, ["is-big"]),
2001
+ createVNode(_sfc_main$1, {
2002
+ price: 12,
2003
+ "base-price": 16
2004
+ }, {
2005
+ "compare-value": withCtx(({ comparePrice }) => [
2006
+ createTextVNode(" x" + toDisplayString(comparePrice), 1)
2007
+ ]),
2008
+ _: 1
2009
+ })
2010
+ ];
2011
+ }
2012
+ }),
2013
+ _: 1
2014
+ }), _parent);
2015
+ };
2016
+ }
2017
+ });
2018
+
2019
+ const _sfc_setup = _sfc_main.setup;
2020
+ _sfc_main.setup = (props, ctx) => {
2021
+ const ssrContext = useSSRContext();
2022
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/lib/components/ProductCard.vue");
2023
+ return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
2024
+ };
2025
+
2026
+ const $$Astro$5 = createAstro("https://ecom2-002.web.app");
2027
+ const $$Home = createComponent(async ($$result, $$props, $$slots) => {
2028
+ const Astro2 = $$result.createAstro($$Astro$5, $$props, $$slots);
2029
+ Astro2.self = $$Home;
2030
+ const products = (await api.get("products")).data.result;
2031
+ return renderTemplate`${maybeRenderHead($$result)}<main>
2032
+ <h1>Welcome to <span class="text-primary">Astro</span></h1>
2033
+ <ul role="list" class="mt-3 fs-20">
2034
+ ${products.map((product) => renderTemplate`<li>
2035
+ <a${addAttribute(`/${product.slug}`, "href")}>${product.sku}</a>
2036
+ </li>`)}
2037
+ </ul>
2038
+ <div class="prose">
2039
+ <h1>Oi</h1>
2040
+ <p>Olá <a href="/">link</a></p>
2041
+ <ul>
2042
+ <li>So here is the first item in this list.</li>
2043
+ <li>In this example we're keeping the items short.</li>
2044
+ <li>Later, we'll use longer, more complex list items.</li>
2045
+ </ul>
2046
+ <details>
2047
+ <summary role="button">Accordion 1</summary>
2048
+ <p>…</p>
2049
+ </details>
2050
+ </div>
2051
+ <div>
2052
+ <h1>Oi</h1>
2053
+ <p>Olá <a href="/">link</a></p>
2054
+ <details>
2055
+ <summary role="button">Accordion 1</summary>
2056
+ <p>…</p>
2057
+ </details>
2058
+ </div>
2059
+ <div class="mt-2">
2060
+ <div>
2061
+ <label class="block">
2062
+ <span class="text-gray-700">Email address</span>
2063
+ <input type="email" class="mt-1 block w-full" placeholder="john@example.com">
2064
+ </label>
2065
+ <label class="inline-flex items-center">
2066
+ <input type="checkbox" checked>
2067
+ <span class="ml-2 font-brand">Email me news and special offers</span>
2068
+ </label>
2069
+ </div>
2070
+ </div>
2071
+ ${renderComponent($$result, "Prices", _sfc_main$1, { "price": 10, "client:load": true, "client:component-hydration": "load", "client:component-path": "@@sf/components/Prices.vue", "client:component-export": "default" })}
2072
+ ${renderComponent($$result, "ProductCard", _sfc_main, { "client:load": true, "client:component-hydration": "load", "client:component-path": "@@sf/components/ProductCard.vue", "client:component-export": "default" })}
2073
+ </main>`;
2074
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/main/Home.astro");
2075
+
2076
+ const $$Astro$4 = createAstro("https://ecom2-002.web.app");
2077
+ const $$Index$1 = createComponent(async ($$result, $$props, $$slots) => {
2078
+ const Astro2 = $$result.createAstro($$Astro$4, $$props, $$slots);
2079
+ Astro2.self = $$Index$1;
2080
+ let pageContext;
2081
+ let loadError;
2082
+ try {
2083
+ pageContext = await loadPageContext(Astro2);
2084
+ } catch (err) {
2085
+ if (err.astroResponse) {
2086
+ return err.astroResponse;
2087
+ }
2088
+ loadError = err;
2089
+ }
2090
+ return renderTemplate`<html${addAttribute(pageContext?.lang.replace("_", "-"), "lang")}>
2091
+ ${pageContext && renderTemplate`${renderComponent($$result, "PagesLayout", $$Pages, { "pageContext": pageContext }, { "default": () => renderTemplate`${renderComponent($$result, "HomeMain", $$Home, { "pageContext": pageContext })}` })}`}
2092
+ ${loadError && renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": () => renderTemplate`${unescapeHTML(loadError.responseHTML)}` })}`}
2093
+ </html>`;
2094
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/index.astro");
2095
+
2096
+ const $$file$3 = "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/index.astro";
2097
+ const $$url$3 = "";
2098
+
2099
+ const _page1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2100
+ __proto__: null,
2101
+ default: $$Index$1,
2102
+ file: $$file$3,
2103
+ url: $$url$3
2104
+ }, Symbol.toStringTag, { value: 'Module' }));
2105
+
2106
+ const $$Astro$3 = createAstro("https://ecom2-002.web.app");
2107
+ const $$Index = createComponent(async ($$result, $$props, $$slots) => {
2108
+ const Astro2 = $$result.createAstro($$Astro$3, $$props, $$slots);
2109
+ Astro2.self = $$Index;
2110
+ return renderTemplate``;
2111
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/app/index.astro");
2112
+
2113
+ const $$file$2 = "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/app/index.astro";
2114
+ const $$url$2 = "/app";
2115
+
2116
+ const _page3 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2117
+ __proto__: null,
2118
+ default: $$Index,
2119
+ file: $$file$2,
2120
+ url: $$url$2
2121
+ }, Symbol.toStringTag, { value: 'Module' }));
2122
+
2123
+ const $$Astro$2 = createAstro("https://ecom2-002.web.app");
2124
+ const $$Account = createComponent(async ($$result, $$props, $$slots) => {
2125
+ const Astro2 = $$result.createAstro($$Astro$2, $$props, $$slots);
2126
+ Astro2.self = $$Account;
2127
+ return renderTemplate``;
2128
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/app/account.astro");
2129
+
2130
+ const $$file$1 = "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/app/account.astro";
2131
+ const $$url$1 = "/app/account";
2132
+
2133
+ const _page4 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2134
+ __proto__: null,
2135
+ default: $$Account,
2136
+ file: $$file$1,
2137
+ url: $$url$1
2138
+ }, Symbol.toStringTag, { value: 'Module' }));
2139
+
2140
+ const $$Astro$1 = createAstro("https://ecom2-002.web.app");
2141
+ const $$Wildcard = createComponent(async ($$result, $$props, $$slots) => {
2142
+ const Astro2 = $$result.createAstro($$Astro$1, $$props, $$slots);
2143
+ Astro2.self = $$Wildcard;
2144
+ const {
2145
+ pageContext: { apiResource, apiDoc }
2146
+ } = Astro2.props;
2147
+ return renderTemplate`${maybeRenderHead($$result)}<main>
2148
+ <h1>Hello <span class="text-gradient">${apiDoc.name}</span></h1>
2149
+ <hr>
2150
+ <div class="mt-3">
2151
+ <mark>${apiDoc._id}</mark> from <i>${apiResource}</i>
2152
+ <p>${Math.random()}</p>
2153
+ <em>Lorem ipsum dolor sit amet</em>
2154
+ </div>
2155
+ </main>`;
2156
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/main/Wildcard.astro");
2157
+
2158
+ const $$Astro = createAstro("https://ecom2-002.web.app");
2159
+ async function getStaticPaths() {
2160
+ return (await api.get("products?sort=-sales&limit=4&fields=slug")).data.result.map(({ slug }) => ({ params: { slug } }));
2161
+ }
2162
+ const $$ = createComponent(async ($$result, $$props, $$slots) => {
2163
+ const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
2164
+ Astro2.self = $$;
2165
+ if (String(Astro2.params.slug).endsWith(".css.map")) {
2166
+ return new Response(null, { status: 404 });
2167
+ }
2168
+ let pageContext;
2169
+ let loadError;
2170
+ try {
2171
+ pageContext = await loadPageContext(Astro2);
2172
+ } catch (err) {
2173
+ if (err.astroResponse) {
2174
+ return err.astroResponse;
2175
+ }
2176
+ loadError = err;
2177
+ }
2178
+ return renderTemplate`<html${addAttribute(pageContext?.lang.replace("_", "-"), "lang")}>
2179
+ ${pageContext && renderTemplate`${renderComponent($$result, "PagesLayout", $$Pages, { "pageContext": pageContext }, { "default": () => renderTemplate`${renderComponent($$result, "WildcardMain", $$Wildcard, { "pageContext": pageContext })}` })}`}
2180
+ ${loadError && renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": () => renderTemplate`${unescapeHTML(loadError.responseHTML)}` })}`}
2181
+ </html>`;
2182
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/[...slug].astro");
2183
+
2184
+ const $$file = "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/[...slug].astro";
2185
+ const $$url = "/[...slug]";
2186
+
2187
+ const _page5 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2188
+ __proto__: null,
2189
+ default: $$,
2190
+ file: $$file,
2191
+ getStaticPaths,
2192
+ url: $$url
2193
+ }, Symbol.toStringTag, { value: 'Module' }));
2194
+
2195
+ export { $$Pages as $, _page0 as _, _page1 as a, _page3 as b, _page4 as c, _page5 as d, loadPageContext as l };