cloudcommerce 2.13.0 → 2.14.0

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 (168) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/ecomplus-stores/barradoce/conf/firebase.json +1 -0
  3. package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
  4. package/ecomplus-stores/barradoce/functions/ssr/content/extra-pages/promocoes.md +1 -1
  5. package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
  6. package/ecomplus-stores/barradoce/functions/ssr/src/components/AccountMenu.vue +18 -15
  7. package/ecomplus-stores/barradoce/functions/ssr/src/components/AccountPage.vue +5 -5
  8. package/ecomplus-stores/barradoce/functions/ssr/src/components/LoginForm.vue +16 -10
  9. package/ecomplus-stores/barradoce/functions/ssr/src/components/ShopFooter.vue +1 -1
  10. package/ecomplus-stores/barradoce/functions/ssr/src/pages/sitemap-[index].xml.astro +75 -0
  11. package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
  12. package/ecomplus-stores/barradoce/package.json +2 -2
  13. package/package.json +2 -2
  14. package/packages/api/package.json +1 -1
  15. package/packages/apps/affiliate-program/package.json +1 -1
  16. package/packages/apps/correios/package.json +1 -1
  17. package/packages/apps/custom-payment/package.json +1 -1
  18. package/packages/apps/custom-shipping/package.json +1 -1
  19. package/packages/apps/datafrete/package.json +1 -1
  20. package/packages/apps/discounts/package.json +1 -1
  21. package/packages/apps/emails/package.json +1 -1
  22. package/packages/apps/fb-conversions/package.json +1 -1
  23. package/packages/apps/flash-courier/package.json +1 -1
  24. package/packages/apps/frenet/package.json +1 -1
  25. package/packages/apps/galaxpay/package.json +1 -1
  26. package/packages/apps/google-analytics/package.json +1 -1
  27. package/packages/apps/jadlog/package.json +1 -1
  28. package/packages/apps/loyalty-points/package.json +1 -1
  29. package/packages/apps/mandae/package.json +1 -1
  30. package/packages/apps/melhor-envio/package.json +1 -1
  31. package/packages/apps/mercadopago/package.json +1 -1
  32. package/packages/apps/pagaleve/package.json +1 -1
  33. package/packages/apps/pagarme/package.json +1 -1
  34. package/packages/apps/pagarme-v5/package.json +1 -1
  35. package/packages/apps/paghiper/package.json +1 -1
  36. package/packages/apps/pix/package.json +1 -1
  37. package/packages/apps/tiny-erp/package.json +1 -1
  38. package/packages/apps/webhooks/package.json +1 -1
  39. package/packages/cli/ci/bunny-config-base.sh +4 -6
  40. package/packages/cli/config/firebase.json +1 -1
  41. package/packages/cli/package.json +1 -1
  42. package/packages/config/package.json +1 -1
  43. package/packages/emails/package.json +1 -1
  44. package/packages/eslint/package.json +1 -1
  45. package/packages/events/package.json +1 -1
  46. package/packages/feeds/lib/firebase/render-catalog.js +272 -0
  47. package/packages/feeds/lib/firebase/render-catalog.js.map +1 -0
  48. package/packages/feeds/lib/firebase/render-sitemap.js +42 -0
  49. package/packages/feeds/lib/firebase/render-sitemap.js.map +1 -0
  50. package/packages/feeds/lib/firebase/serve-feeds.js +22 -270
  51. package/packages/feeds/lib/firebase/serve-feeds.js.map +1 -1
  52. package/packages/feeds/package.json +1 -1
  53. package/packages/feeds/src/firebase/render-catalog.ts +286 -0
  54. package/packages/feeds/src/firebase/render-sitemap.ts +46 -0
  55. package/packages/feeds/src/firebase/serve-feeds.ts +22 -283
  56. package/packages/firebase/package.json +1 -1
  57. package/packages/i18n/package.json +1 -1
  58. package/packages/modules/package.json +1 -1
  59. package/packages/passport/package.json +1 -1
  60. package/packages/ssr/package.json +1 -1
  61. package/packages/storefront/dist/client/_astro/{AccountPage.Cf0WE6GF.js → AccountPage.CKu0oakN.js} +1 -1
  62. package/packages/storefront/dist/client/_astro/{CartSidebar.DAvJKL2c.js → CartSidebar.Bxz7ZD9N.js} +1 -1
  63. package/packages/storefront/dist/client/_astro/{ProductDetails.BpZtnS8j.js → ProductDetails.PkZr50hA.js} +1 -1
  64. package/packages/storefront/dist/client/_astro/{ProductShelf.C0TU_sRb.js → ProductShelf.BKz6WXbp.js} +1 -1
  65. package/packages/storefront/dist/client/_astro/{SearchModal.DWNSfxML.js → SearchModal.BIrixnFb.js} +1 -1
  66. package/packages/storefront/dist/client/_astro/SearchShowcase.YMZqG8rj.js +1 -0
  67. package/packages/storefront/dist/client/_astro/ShopHeader.BOLegIRO.js +7 -0
  68. package/packages/storefront/dist/client/_astro/{_slug_.HhgCFKHv.css → _slug_.oAbCb631.css} +1 -1
  69. package/packages/storefront/dist/client/_astro/customer-session.B9MvrBAQ.js +7 -0
  70. package/packages/storefront/dist/client/_astro/ecom-icon.png +0 -0
  71. package/packages/storefront/dist/client/_astro/ecom-icon_12falx.png +0 -0
  72. package/packages/storefront/dist/client/_astro/ecom-icon_15pqnO.png +0 -0
  73. package/packages/storefront/dist/client/_astro/ecom-icon_t3guw.png +0 -0
  74. package/packages/storefront/dist/client/_astro/{firebase-app.CmI1zl7o.js → firebase-app.DPioxxma.js} +1 -1
  75. package/packages/storefront/dist/client/_astro/headphone.webp +0 -0
  76. package/packages/storefront/dist/client/_astro/headphone_T2Jjc.avif +0 -0
  77. package/packages/storefront/dist/client/_astro/headphone_Z1CG18r.webp +0 -0
  78. package/packages/storefront/dist/client/_astro/{hoisted.BeKMioW4.js → hoisted.8Sq2YuJM.js} +1 -1
  79. package/packages/storefront/dist/client/_astro/{hoisted.Bf1gCkSN.js → hoisted.BzVcl7We.js} +1 -1
  80. package/packages/storefront/dist/client/_astro/{hoisted.-C0vLMXT.js → hoisted.CPcG9RpX.js} +1 -1
  81. package/packages/storefront/dist/client/_astro/{index-a8cf6c8f.k99a-gIB.js → index-219c3cac.78peI8kt.js} +3 -3
  82. package/packages/storefront/dist/client/_astro/logo.png +0 -0
  83. package/packages/storefront/dist/client/_astro/logo_1UBsBq.webp +0 -0
  84. package/packages/storefront/dist/client/_astro/logo_Z1K5PE9.png +0 -0
  85. package/packages/storefront/dist/client/_astro/logo_Z1KIIl1.avif +0 -0
  86. package/packages/storefront/dist/client/_astro/passion.webp +0 -0
  87. package/packages/storefront/dist/client/_astro/passion_LHbe9.webp +0 -0
  88. package/packages/storefront/dist/client/_astro/passion_Z23MeUb.avif +0 -0
  89. package/packages/storefront/dist/client/_astro/rect8589.png +0 -0
  90. package/packages/storefront/dist/client/_astro/rect8589_1TtOHY.png +0 -0
  91. package/packages/storefront/dist/client/_astro/rect8589_1f5opX.webp +0 -0
  92. package/packages/storefront/dist/client/_astro/rect8589_IUskt.webp +0 -0
  93. package/packages/storefront/dist/client/_astro/rect8589_Uxfdf.png +0 -0
  94. package/packages/storefront/dist/client/_astro/rect8589_Z15uApA.png +0 -0
  95. package/packages/storefront/dist/client/_astro/rect8589_Z1Ap1Im.avif +0 -0
  96. package/packages/storefront/dist/client/_astro/rect8589_Z1JT1HB.webp +0 -0
  97. package/packages/storefront/dist/client/_astro/rect8589_ZY9mtN.avif +0 -0
  98. package/packages/storefront/dist/client/_astro/rect8589_tMFW0.avif +0 -0
  99. package/packages/storefront/dist/client/_astro/rect859.png +0 -0
  100. package/packages/storefront/dist/client/_astro/rect859_1TgQXS.avif +0 -0
  101. package/packages/storefront/dist/client/_astro/rect859_2Nm1z.avif +0 -0
  102. package/packages/storefront/dist/client/_astro/rect859_DIqwR.png +0 -0
  103. package/packages/storefront/dist/client/_astro/rect859_Z1IKDb2.png +0 -0
  104. package/packages/storefront/dist/client/_astro/rect859_Z29FI4V.webp +0 -0
  105. package/packages/storefront/dist/client/_astro/rect859_Z2kFHGk.avif +0 -0
  106. package/packages/storefront/dist/client/_astro/rect859_ZkpPFI.webp +0 -0
  107. package/packages/storefront/dist/client/_astro/rect859_jXzBi.png +0 -0
  108. package/packages/storefront/dist/client/_astro/rect859_x1l16.webp +0 -0
  109. package/packages/storefront/dist/client/_astro/rect89.webp +0 -0
  110. package/packages/storefront/dist/client/_astro/rect89_1TSfW7.avif +0 -0
  111. package/packages/storefront/dist/client/_astro/rect89_Z1re32x.webp +0 -0
  112. package/packages/storefront/dist/client/_astro/{shopping-cart.Cqc6p5UR.js → shopping-cart.D8fbm2Dv.js} +1 -1
  113. package/packages/storefront/dist/client/_astro/{use-analytics.bP3a5cR0.js → use-analytics.D_peWG3X.js} +1 -1
  114. package/packages/storefront/dist/client/_astro/{use-product-card.Cj9Q-Y1A.js → use-product-card.BCGHZKB5.js} +1 -1
  115. package/packages/storefront/dist/client/_astro/{use-text-value.DT0v9Yj_.js → use-text-value.BFLvKnYE.js} +1 -1
  116. package/packages/storefront/dist/client/assets/cvv.png +0 -0
  117. package/packages/storefront/dist/client/assets/payments.png +0 -0
  118. package/packages/storefront/dist/client/robots.txt +2 -0
  119. package/packages/storefront/dist/client/~fallback.html +112 -0
  120. package/packages/storefront/dist/client/~index.html +137 -0
  121. package/packages/storefront/dist/server/_astro-internal_middleware.mjs +2 -2
  122. package/packages/storefront/dist/server/chunks/404_BUZm2bP1.mjs +5 -0
  123. package/packages/storefront/dist/server/chunks/{CartSidebar_tmly-0ip.mjs → CartSidebar_kQSDOTj2.mjs} +2 -2
  124. package/packages/storefront/dist/server/chunks/{SearchModal_CGNQss2j.mjs → SearchModal_O1xTrm-9.mjs} +2 -2
  125. package/packages/storefront/dist/server/chunks/{_.._Bt6Uzpk2.mjs → _.._6Bd7O3FD.mjs} +1 -1
  126. package/packages/storefront/dist/server/chunks/{_astro-internal_middleware_CqUpziyW.mjs → _astro-internal_middleware_BnKXd-Ev.mjs} +1 -1
  127. package/packages/storefront/dist/server/chunks/{_page__Dz-iZHMh.mjs → _page__CXnal5Rn.mjs} +1 -1
  128. package/packages/storefront/dist/server/chunks/{account_tfs9KFTy.mjs → account_C6XTKIP9.mjs} +1 -1
  129. package/packages/storefront/dist/server/chunks/astro/{assets-service_DSoC_W52.mjs → assets-service_146xb0vN.mjs} +11 -67
  130. package/packages/storefront/dist/server/chunks/{astro_Cu3MZ9xv.mjs → astro_DIU6qHCh.mjs} +34 -79
  131. package/packages/storefront/dist/server/chunks/{index_CGzMgZTN.mjs → index_EbDDnIXs.mjs} +1 -1
  132. package/packages/storefront/dist/server/chunks/{index_BKS_40rA.mjs → index_STpvD2cy.mjs} +1 -1
  133. package/packages/storefront/dist/server/chunks/{node_lZaNT3E1.mjs → node_DHQVZgH_.mjs} +1 -1
  134. package/packages/storefront/dist/server/chunks/pages/{404_CMwuVMu1.mjs → 404_n3mvoSWv.mjs} +94 -1140
  135. package/packages/storefront/dist/server/chunks/pages/{__Dz53F-0T.mjs → __C9Nd4c7_.mjs} +11 -42
  136. package/packages/storefront/dist/server/chunks/pages/{_page__C1x19nYF.mjs → _page__BnXBvVvn.mjs} +4 -20
  137. package/packages/storefront/dist/server/chunks/pages/account_Dk-8R3rY.mjs +22 -0
  138. package/packages/storefront/dist/server/chunks/pages/{index_CqvjdvSg.mjs → index_us3QX6kE.mjs} +5 -22
  139. package/packages/storefront/dist/server/chunks/pages/node_BGdGQ52C.mjs +1864 -0
  140. package/packages/storefront/dist/server/chunks/pages/sitemap-_index__rcX10oKd.mjs +32 -0
  141. package/packages/storefront/dist/server/chunks/pages/~fallback_BNfV6ECv.mjs +22 -0
  142. package/packages/storefront/dist/server/chunks/sitemap-_index__e6mToVZH.mjs +5 -0
  143. package/packages/storefront/dist/server/chunks/{~fallback_CrFe__-f.mjs → ~fallback_Cg1Pbe1d.mjs} +1 -1
  144. package/packages/storefront/dist/server/entry.mjs +18 -17
  145. package/packages/storefront/dist/server/images.dist.csv +37 -0
  146. package/packages/storefront/dist/server/images.src.csv +13 -0
  147. package/packages/storefront/dist/server/manifest_xBcEm6Np.mjs +206 -0
  148. package/packages/storefront/dist/server/middleware.mjs +2 -2
  149. package/packages/storefront/dist/server/renderers.mjs +1 -1
  150. package/packages/storefront/dist/server/static-builds.csv +80 -0
  151. package/packages/storefront/package.json +1 -1
  152. package/packages/storefront/scripts/build-prod.sh +17 -0
  153. package/packages/storefront/src/lib/components/AccountLink.vue +16 -11
  154. package/packages/storefront/src/lib/components/globals/Skeleton.vue +6 -4
  155. package/packages/storefront/src/lib/composables/use-login-form.ts +6 -1
  156. package/packages/storefront/src/lib/scripts/vbeta-app.ts +11 -2
  157. package/packages/storefront/src/lib/state/customer-session.ts +8 -1
  158. package/packages/test-base/package.json +1 -1
  159. package/packages/types/package.json +1 -1
  160. package/packages/storefront/dist/client/_astro/SearchShowcase.CUkbXIRk.js +0 -1
  161. package/packages/storefront/dist/client/_astro/ShopHeader.D7qqQxFD.js +0 -7
  162. package/packages/storefront/dist/client/_astro/customer-session.Cctko5_9.js +0 -7
  163. package/packages/storefront/dist/client/assets/.gitkeep +0 -2
  164. package/packages/storefront/dist/server/chunks/404_BcY_5eJJ.mjs +0 -5
  165. package/packages/storefront/dist/server/chunks/pages/account_B5Z6wDBy.mjs +0 -32
  166. package/packages/storefront/dist/server/chunks/pages/node_mvX6Tssv.mjs +0 -879
  167. package/packages/storefront/dist/server/chunks/pages/~fallback_D2ugBVgc.mjs +0 -32
  168. package/packages/storefront/dist/server/manifest_D4v8KX-D.mjs +0 -206
@@ -0,0 +1,1864 @@
1
+ import { isRemotePath } from '@astrojs/internal-helpers/path';
2
+ import { isAbsolute } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { readFile } from 'fs/promises';
5
+ import mime from 'mime/lite.js';
6
+ import { A as AstroError, I as InvalidImageService, r as resolveSrc, i as isRemoteImage, a as isESMImportedImage, b as isLocalService, D as DEFAULT_HASH_PROPS, c as isRemoteAllowed } from '../astro/assets-service_146xb0vN.mjs';
7
+ import { A as AstroError$1, i as ExpectedImageOptions, E as ExpectedImage, j as FailedToFetchRemoteImageDimensions, k as InvalidImageService$1, c as createAstro, b as createComponent, l as ImageMissingAlt, r as renderTemplate, m as maybeRenderHead, d as addAttribute, s as spreadAttributes } from '../astro_DIU6qHCh.mjs';
8
+ import 'clsx';
9
+
10
+ const decoder$1 = new TextDecoder();
11
+ const toUTF8String$1 = (input, start = 0, end = input.length) => decoder$1.decode(input.slice(start, end));
12
+ const toHexString$1 = (input, start = 0, end = input.length) => input.slice(start, end).reduce((memo, i) => memo + ("0" + i.toString(16)).slice(-2), "");
13
+ const readInt16LE$1 = (input, offset = 0) => {
14
+ const val = input[offset] + input[offset + 1] * 2 ** 8;
15
+ return val | (val & 2 ** 15) * 131070;
16
+ };
17
+ const readUInt16BE$1 = (input, offset = 0) => input[offset] * 2 ** 8 + input[offset + 1];
18
+ const readUInt16LE$1 = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8;
19
+ const readUInt24LE$1 = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16;
20
+ const readInt32LE$1 = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + (input[offset + 3] << 24);
21
+ const readUInt32BE$1 = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] * 2 ** 8 + input[offset + 3];
22
+ const readUInt32LE$1 = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + input[offset + 3] * 2 ** 24;
23
+ const methods$1 = {
24
+ readUInt16BE: readUInt16BE$1,
25
+ readUInt16LE: readUInt16LE$1,
26
+ readUInt32BE: readUInt32BE$1,
27
+ readUInt32LE: readUInt32LE$1
28
+ };
29
+ function readUInt$1(input, bits, offset, isBigEndian) {
30
+ offset = offset || 0;
31
+ const endian = isBigEndian ? "BE" : "LE";
32
+ const methodName = "readUInt" + bits + endian;
33
+ return methods$1[methodName](input, offset);
34
+ }
35
+ function readBox$1(buffer, offset) {
36
+ if (buffer.length - offset < 4)
37
+ return;
38
+ const boxSize = readUInt32BE$1(buffer, offset);
39
+ if (buffer.length - offset < boxSize)
40
+ return;
41
+ return {
42
+ name: toUTF8String$1(buffer, 4 + offset, 8 + offset),
43
+ offset,
44
+ size: boxSize
45
+ };
46
+ }
47
+ function findBox$1(buffer, boxName, offset) {
48
+ while (offset < buffer.length) {
49
+ const box = readBox$1(buffer, offset);
50
+ if (!box)
51
+ break;
52
+ if (box.name === boxName)
53
+ return box;
54
+ offset += box.size;
55
+ }
56
+ }
57
+
58
+ const BMP$1 = {
59
+ validate: (input) => toUTF8String$1(input, 0, 2) === "BM",
60
+ calculate: (input) => ({
61
+ height: Math.abs(readInt32LE$1(input, 22)),
62
+ width: readUInt32LE$1(input, 18)
63
+ })
64
+ };
65
+
66
+ const TYPE_ICON$1 = 1;
67
+ const SIZE_HEADER$3 = 2 + 2 + 2;
68
+ const SIZE_IMAGE_ENTRY$1 = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4;
69
+ function getSizeFromOffset$1(input, offset) {
70
+ const value = input[offset];
71
+ return value === 0 ? 256 : value;
72
+ }
73
+ function getImageSize$3(input, imageIndex) {
74
+ const offset = SIZE_HEADER$3 + imageIndex * SIZE_IMAGE_ENTRY$1;
75
+ return {
76
+ height: getSizeFromOffset$1(input, offset + 1),
77
+ width: getSizeFromOffset$1(input, offset)
78
+ };
79
+ }
80
+ const ICO$1 = {
81
+ validate(input) {
82
+ const reserved = readUInt16LE$1(input, 0);
83
+ const imageCount = readUInt16LE$1(input, 4);
84
+ if (reserved !== 0 || imageCount === 0)
85
+ return false;
86
+ const imageType = readUInt16LE$1(input, 2);
87
+ return imageType === TYPE_ICON$1;
88
+ },
89
+ calculate(input) {
90
+ const nbImages = readUInt16LE$1(input, 4);
91
+ const imageSize = getImageSize$3(input, 0);
92
+ if (nbImages === 1)
93
+ return imageSize;
94
+ const imgs = [imageSize];
95
+ for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) {
96
+ imgs.push(getImageSize$3(input, imageIndex));
97
+ }
98
+ return {
99
+ height: imageSize.height,
100
+ images: imgs,
101
+ width: imageSize.width
102
+ };
103
+ }
104
+ };
105
+
106
+ const TYPE_CURSOR$1 = 2;
107
+ const CUR$1 = {
108
+ validate(input) {
109
+ const reserved = readUInt16LE$1(input, 0);
110
+ const imageCount = readUInt16LE$1(input, 4);
111
+ if (reserved !== 0 || imageCount === 0)
112
+ return false;
113
+ const imageType = readUInt16LE$1(input, 2);
114
+ return imageType === TYPE_CURSOR$1;
115
+ },
116
+ calculate: (input) => ICO$1.calculate(input)
117
+ };
118
+
119
+ const DDS$1 = {
120
+ validate: (input) => readUInt32LE$1(input, 0) === 542327876,
121
+ calculate: (input) => ({
122
+ height: readUInt32LE$1(input, 12),
123
+ width: readUInt32LE$1(input, 16)
124
+ })
125
+ };
126
+
127
+ const gifRegexp$1 = /^GIF8[79]a/;
128
+ const GIF$1 = {
129
+ validate: (input) => gifRegexp$1.test(toUTF8String$1(input, 0, 6)),
130
+ calculate: (input) => ({
131
+ height: readUInt16LE$1(input, 8),
132
+ width: readUInt16LE$1(input, 6)
133
+ })
134
+ };
135
+
136
+ const brandMap$1 = {
137
+ avif: "avif",
138
+ mif1: "heif",
139
+ msf1: "heif",
140
+ // hief-sequence
141
+ heic: "heic",
142
+ heix: "heic",
143
+ hevc: "heic",
144
+ // heic-sequence
145
+ hevx: "heic"
146
+ // heic-sequence
147
+ };
148
+ function detectBrands$1(buffer, start, end) {
149
+ let brandsDetected = {};
150
+ for (let i = start; i <= end; i += 4) {
151
+ const brand = toUTF8String$1(buffer, i, i + 4);
152
+ if (brand in brandMap$1) {
153
+ brandsDetected[brand] = 1;
154
+ }
155
+ }
156
+ if ("avif" in brandsDetected) {
157
+ return "avif";
158
+ } else if ("heic" in brandsDetected || "heix" in brandsDetected || "hevc" in brandsDetected || "hevx" in brandsDetected) {
159
+ return "heic";
160
+ } else if ("mif1" in brandsDetected || "msf1" in brandsDetected) {
161
+ return "heif";
162
+ }
163
+ }
164
+ const HEIF$1 = {
165
+ validate(buffer) {
166
+ const ftype = toUTF8String$1(buffer, 4, 8);
167
+ const brand = toUTF8String$1(buffer, 8, 12);
168
+ return "ftyp" === ftype && brand in brandMap$1;
169
+ },
170
+ calculate(buffer) {
171
+ const metaBox = findBox$1(buffer, "meta", 0);
172
+ const iprpBox = metaBox && findBox$1(buffer, "iprp", metaBox.offset + 12);
173
+ const ipcoBox = iprpBox && findBox$1(buffer, "ipco", iprpBox.offset + 8);
174
+ const ispeBox = ipcoBox && findBox$1(buffer, "ispe", ipcoBox.offset + 8);
175
+ if (ispeBox) {
176
+ return {
177
+ height: readUInt32BE$1(buffer, ispeBox.offset + 16),
178
+ width: readUInt32BE$1(buffer, ispeBox.offset + 12),
179
+ type: detectBrands$1(buffer, 8, metaBox.offset)
180
+ };
181
+ }
182
+ throw new TypeError("Invalid HEIF, no size found");
183
+ }
184
+ };
185
+
186
+ const SIZE_HEADER$2 = 4 + 4;
187
+ const FILE_LENGTH_OFFSET$1 = 4;
188
+ const ENTRY_LENGTH_OFFSET$1 = 4;
189
+ const ICON_TYPE_SIZE$1 = {
190
+ ICON: 32,
191
+ "ICN#": 32,
192
+ // m => 16 x 16
193
+ "icm#": 16,
194
+ icm4: 16,
195
+ icm8: 16,
196
+ // s => 16 x 16
197
+ "ics#": 16,
198
+ ics4: 16,
199
+ ics8: 16,
200
+ is32: 16,
201
+ s8mk: 16,
202
+ icp4: 16,
203
+ // l => 32 x 32
204
+ icl4: 32,
205
+ icl8: 32,
206
+ il32: 32,
207
+ l8mk: 32,
208
+ icp5: 32,
209
+ ic11: 32,
210
+ // h => 48 x 48
211
+ ich4: 48,
212
+ ich8: 48,
213
+ ih32: 48,
214
+ h8mk: 48,
215
+ // . => 64 x 64
216
+ icp6: 64,
217
+ ic12: 32,
218
+ // t => 128 x 128
219
+ it32: 128,
220
+ t8mk: 128,
221
+ ic07: 128,
222
+ // . => 256 x 256
223
+ ic08: 256,
224
+ ic13: 256,
225
+ // . => 512 x 512
226
+ ic09: 512,
227
+ ic14: 512,
228
+ // . => 1024 x 1024
229
+ ic10: 1024
230
+ };
231
+ function readImageHeader$1(input, imageOffset) {
232
+ const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET$1;
233
+ return [
234
+ toUTF8String$1(input, imageOffset, imageLengthOffset),
235
+ readUInt32BE$1(input, imageLengthOffset)
236
+ ];
237
+ }
238
+ function getImageSize$2(type) {
239
+ const size = ICON_TYPE_SIZE$1[type];
240
+ return { width: size, height: size, type };
241
+ }
242
+ const ICNS$1 = {
243
+ validate: (input) => toUTF8String$1(input, 0, 4) === "icns",
244
+ calculate(input) {
245
+ const inputLength = input.length;
246
+ const fileLength = readUInt32BE$1(input, FILE_LENGTH_OFFSET$1);
247
+ let imageOffset = SIZE_HEADER$2;
248
+ let imageHeader = readImageHeader$1(input, imageOffset);
249
+ let imageSize = getImageSize$2(imageHeader[0]);
250
+ imageOffset += imageHeader[1];
251
+ if (imageOffset === fileLength)
252
+ return imageSize;
253
+ const result = {
254
+ height: imageSize.height,
255
+ images: [imageSize],
256
+ width: imageSize.width
257
+ };
258
+ while (imageOffset < fileLength && imageOffset < inputLength) {
259
+ imageHeader = readImageHeader$1(input, imageOffset);
260
+ imageSize = getImageSize$2(imageHeader[0]);
261
+ imageOffset += imageHeader[1];
262
+ result.images.push(imageSize);
263
+ }
264
+ return result;
265
+ }
266
+ };
267
+
268
+ const J2C$1 = {
269
+ // TODO: this doesn't seem right. SIZ marker doesn't have to be right after the SOC
270
+ validate: (input) => toHexString$1(input, 0, 4) === "ff4fff51",
271
+ calculate: (input) => ({
272
+ height: readUInt32BE$1(input, 12),
273
+ width: readUInt32BE$1(input, 8)
274
+ })
275
+ };
276
+
277
+ const JP2$1 = {
278
+ validate(input) {
279
+ if (readUInt32BE$1(input, 4) !== 1783636e3 || readUInt32BE$1(input, 0) < 1)
280
+ return false;
281
+ const ftypBox = findBox$1(input, "ftyp", 0);
282
+ if (!ftypBox)
283
+ return false;
284
+ return readUInt32BE$1(input, ftypBox.offset + 4) === 1718909296;
285
+ },
286
+ calculate(input) {
287
+ const jp2hBox = findBox$1(input, "jp2h", 0);
288
+ const ihdrBox = jp2hBox && findBox$1(input, "ihdr", jp2hBox.offset + 8);
289
+ if (ihdrBox) {
290
+ return {
291
+ height: readUInt32BE$1(input, ihdrBox.offset + 8),
292
+ width: readUInt32BE$1(input, ihdrBox.offset + 12)
293
+ };
294
+ }
295
+ throw new TypeError("Unsupported JPEG 2000 format");
296
+ }
297
+ };
298
+
299
+ const EXIF_MARKER$1 = "45786966";
300
+ const APP1_DATA_SIZE_BYTES$1 = 2;
301
+ const EXIF_HEADER_BYTES$1 = 6;
302
+ const TIFF_BYTE_ALIGN_BYTES$1 = 2;
303
+ const BIG_ENDIAN_BYTE_ALIGN$1 = "4d4d";
304
+ const LITTLE_ENDIAN_BYTE_ALIGN$1 = "4949";
305
+ const IDF_ENTRY_BYTES$1 = 12;
306
+ const NUM_DIRECTORY_ENTRIES_BYTES$1 = 2;
307
+ function isEXIF$1(input) {
308
+ return toHexString$1(input, 2, 6) === EXIF_MARKER$1;
309
+ }
310
+ function extractSize$1(input, index) {
311
+ return {
312
+ height: readUInt16BE$1(input, index),
313
+ width: readUInt16BE$1(input, index + 2)
314
+ };
315
+ }
316
+ function extractOrientation$1(exifBlock, isBigEndian) {
317
+ const idfOffset = 8;
318
+ const offset = EXIF_HEADER_BYTES$1 + idfOffset;
319
+ const idfDirectoryEntries = readUInt$1(exifBlock, 16, offset, isBigEndian);
320
+ for (let directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) {
321
+ const start = offset + NUM_DIRECTORY_ENTRIES_BYTES$1 + directoryEntryNumber * IDF_ENTRY_BYTES$1;
322
+ const end = start + IDF_ENTRY_BYTES$1;
323
+ if (start > exifBlock.length) {
324
+ return;
325
+ }
326
+ const block = exifBlock.slice(start, end);
327
+ const tagNumber = readUInt$1(block, 16, 0, isBigEndian);
328
+ if (tagNumber === 274) {
329
+ const dataFormat = readUInt$1(block, 16, 2, isBigEndian);
330
+ if (dataFormat !== 3) {
331
+ return;
332
+ }
333
+ const numberOfComponents = readUInt$1(block, 32, 4, isBigEndian);
334
+ if (numberOfComponents !== 1) {
335
+ return;
336
+ }
337
+ return readUInt$1(block, 16, 8, isBigEndian);
338
+ }
339
+ }
340
+ }
341
+ function validateExifBlock$1(input, index) {
342
+ const exifBlock = input.slice(APP1_DATA_SIZE_BYTES$1, index);
343
+ const byteAlign = toHexString$1(
344
+ exifBlock,
345
+ EXIF_HEADER_BYTES$1,
346
+ EXIF_HEADER_BYTES$1 + TIFF_BYTE_ALIGN_BYTES$1
347
+ );
348
+ const isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN$1;
349
+ const isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN$1;
350
+ if (isBigEndian || isLittleEndian) {
351
+ return extractOrientation$1(exifBlock, isBigEndian);
352
+ }
353
+ }
354
+ function validateInput$1(input, index) {
355
+ if (index > input.length) {
356
+ throw new TypeError("Corrupt JPG, exceeded buffer limits");
357
+ }
358
+ }
359
+ const JPG$1 = {
360
+ validate: (input) => toHexString$1(input, 0, 2) === "ffd8",
361
+ calculate(input) {
362
+ input = input.slice(4);
363
+ let orientation;
364
+ let next;
365
+ while (input.length) {
366
+ const i = readUInt16BE$1(input, 0);
367
+ if (input[i] !== 255) {
368
+ input = input.slice(1);
369
+ continue;
370
+ }
371
+ if (isEXIF$1(input)) {
372
+ orientation = validateExifBlock$1(input, i);
373
+ }
374
+ validateInput$1(input, i);
375
+ next = input[i + 1];
376
+ if (next === 192 || next === 193 || next === 194) {
377
+ const size = extractSize$1(input, i + 5);
378
+ if (!orientation) {
379
+ return size;
380
+ }
381
+ return {
382
+ height: size.height,
383
+ orientation,
384
+ width: size.width
385
+ };
386
+ }
387
+ input = input.slice(i + 2);
388
+ }
389
+ throw new TypeError("Invalid JPG, no size found");
390
+ }
391
+ };
392
+
393
+ const KTX$1 = {
394
+ validate: (input) => {
395
+ const signature = toUTF8String$1(input, 1, 7);
396
+ return ["KTX 11", "KTX 20"].includes(signature);
397
+ },
398
+ calculate: (input) => {
399
+ const type = input[5] === 49 ? "ktx" : "ktx2";
400
+ const offset = type === "ktx" ? 36 : 20;
401
+ return {
402
+ height: readUInt32LE$1(input, offset + 4),
403
+ width: readUInt32LE$1(input, offset),
404
+ type
405
+ };
406
+ }
407
+ };
408
+
409
+ const pngSignature$1 = "PNG\r\n\n";
410
+ const pngImageHeaderChunkName$1 = "IHDR";
411
+ const pngFriedChunkName$1 = "CgBI";
412
+ const PNG$1 = {
413
+ validate(input) {
414
+ if (pngSignature$1 === toUTF8String$1(input, 1, 8)) {
415
+ let chunkName = toUTF8String$1(input, 12, 16);
416
+ if (chunkName === pngFriedChunkName$1) {
417
+ chunkName = toUTF8String$1(input, 28, 32);
418
+ }
419
+ if (chunkName !== pngImageHeaderChunkName$1) {
420
+ throw new TypeError("Invalid PNG");
421
+ }
422
+ return true;
423
+ }
424
+ return false;
425
+ },
426
+ calculate(input) {
427
+ if (toUTF8String$1(input, 12, 16) === pngFriedChunkName$1) {
428
+ return {
429
+ height: readUInt32BE$1(input, 36),
430
+ width: readUInt32BE$1(input, 32)
431
+ };
432
+ }
433
+ return {
434
+ height: readUInt32BE$1(input, 20),
435
+ width: readUInt32BE$1(input, 16)
436
+ };
437
+ }
438
+ };
439
+
440
+ const PNMTypes$1 = {
441
+ P1: "pbm/ascii",
442
+ P2: "pgm/ascii",
443
+ P3: "ppm/ascii",
444
+ P4: "pbm",
445
+ P5: "pgm",
446
+ P6: "ppm",
447
+ P7: "pam",
448
+ PF: "pfm"
449
+ };
450
+ const handlers$1 = {
451
+ default: (lines) => {
452
+ let dimensions = [];
453
+ while (lines.length > 0) {
454
+ const line = lines.shift();
455
+ if (line[0] === "#") {
456
+ continue;
457
+ }
458
+ dimensions = line.split(" ");
459
+ break;
460
+ }
461
+ if (dimensions.length === 2) {
462
+ return {
463
+ height: parseInt(dimensions[1], 10),
464
+ width: parseInt(dimensions[0], 10)
465
+ };
466
+ } else {
467
+ throw new TypeError("Invalid PNM");
468
+ }
469
+ },
470
+ pam: (lines) => {
471
+ const size = {};
472
+ while (lines.length > 0) {
473
+ const line = lines.shift();
474
+ if (line.length > 16 || line.charCodeAt(0) > 128) {
475
+ continue;
476
+ }
477
+ const [key, value] = line.split(" ");
478
+ if (key && value) {
479
+ size[key.toLowerCase()] = parseInt(value, 10);
480
+ }
481
+ if (size.height && size.width) {
482
+ break;
483
+ }
484
+ }
485
+ if (size.height && size.width) {
486
+ return {
487
+ height: size.height,
488
+ width: size.width
489
+ };
490
+ } else {
491
+ throw new TypeError("Invalid PAM");
492
+ }
493
+ }
494
+ };
495
+ const PNM$1 = {
496
+ validate: (input) => toUTF8String$1(input, 0, 2) in PNMTypes$1,
497
+ calculate(input) {
498
+ const signature = toUTF8String$1(input, 0, 2);
499
+ const type = PNMTypes$1[signature];
500
+ const lines = toUTF8String$1(input, 3).split(/[\r\n]+/);
501
+ const handler = handlers$1[type] || handlers$1.default;
502
+ return handler(lines);
503
+ }
504
+ };
505
+
506
+ const PSD$1 = {
507
+ validate: (input) => toUTF8String$1(input, 0, 4) === "8BPS",
508
+ calculate: (input) => ({
509
+ height: readUInt32BE$1(input, 14),
510
+ width: readUInt32BE$1(input, 18)
511
+ })
512
+ };
513
+
514
+ const svgReg$1 = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
515
+ const extractorRegExps$1 = {
516
+ height: /\sheight=(['"])([^%]+?)\1/,
517
+ root: svgReg$1,
518
+ viewbox: /\sviewBox=(['"])(.+?)\1/i,
519
+ width: /\swidth=(['"])([^%]+?)\1/
520
+ };
521
+ const INCH_CM$1 = 2.54;
522
+ const units$1 = {
523
+ in: 96,
524
+ cm: 96 / INCH_CM$1,
525
+ em: 16,
526
+ ex: 8,
527
+ m: 96 / INCH_CM$1 * 100,
528
+ mm: 96 / INCH_CM$1 / 10,
529
+ pc: 96 / 72 / 12,
530
+ pt: 96 / 72,
531
+ px: 1
532
+ };
533
+ const unitsReg$1 = new RegExp(
534
+ // eslint-disable-next-line regexp/prefer-d
535
+ `^([0-9.]+(?:e\\d+)?)(${Object.keys(units$1).join("|")})?$`
536
+ );
537
+ function parseLength$1(len) {
538
+ const m = unitsReg$1.exec(len);
539
+ if (!m) {
540
+ return void 0;
541
+ }
542
+ return Math.round(Number(m[1]) * (units$1[m[2]] || 1));
543
+ }
544
+ function parseViewbox$1(viewbox) {
545
+ const bounds = viewbox.split(" ");
546
+ return {
547
+ height: parseLength$1(bounds[3]),
548
+ width: parseLength$1(bounds[2])
549
+ };
550
+ }
551
+ function parseAttributes$1(root) {
552
+ const width = root.match(extractorRegExps$1.width);
553
+ const height = root.match(extractorRegExps$1.height);
554
+ const viewbox = root.match(extractorRegExps$1.viewbox);
555
+ return {
556
+ height: height && parseLength$1(height[2]),
557
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
558
+ viewbox: viewbox && parseViewbox$1(viewbox[2]),
559
+ width: width && parseLength$1(width[2])
560
+ };
561
+ }
562
+ function calculateByDimensions$1(attrs) {
563
+ return {
564
+ height: attrs.height,
565
+ width: attrs.width
566
+ };
567
+ }
568
+ function calculateByViewbox$1(attrs, viewbox) {
569
+ const ratio = viewbox.width / viewbox.height;
570
+ if (attrs.width) {
571
+ return {
572
+ height: Math.floor(attrs.width / ratio),
573
+ width: attrs.width
574
+ };
575
+ }
576
+ if (attrs.height) {
577
+ return {
578
+ height: attrs.height,
579
+ width: Math.floor(attrs.height * ratio)
580
+ };
581
+ }
582
+ return {
583
+ height: viewbox.height,
584
+ width: viewbox.width
585
+ };
586
+ }
587
+ const SVG$1 = {
588
+ // Scan only the first kilo-byte to speed up the check on larger files
589
+ validate: (input) => svgReg$1.test(toUTF8String$1(input, 0, 1e3)),
590
+ calculate(input) {
591
+ const root = toUTF8String$1(input).match(extractorRegExps$1.root);
592
+ if (root) {
593
+ const attrs = parseAttributes$1(root[0]);
594
+ if (attrs.width && attrs.height) {
595
+ return calculateByDimensions$1(attrs);
596
+ }
597
+ if (attrs.viewbox) {
598
+ return calculateByViewbox$1(attrs, attrs.viewbox);
599
+ }
600
+ }
601
+ throw new TypeError("Invalid SVG");
602
+ }
603
+ };
604
+
605
+ const TGA$1 = {
606
+ validate(input) {
607
+ return readUInt16LE$1(input, 0) === 0 && readUInt16LE$1(input, 4) === 0;
608
+ },
609
+ calculate(input) {
610
+ return {
611
+ height: readUInt16LE$1(input, 14),
612
+ width: readUInt16LE$1(input, 12)
613
+ };
614
+ }
615
+ };
616
+
617
+ function readIFD$1(input, isBigEndian) {
618
+ const ifdOffset = readUInt$1(input, 32, 4, isBigEndian);
619
+ return input.slice(ifdOffset + 2);
620
+ }
621
+ function readValue$1(input, isBigEndian) {
622
+ const low = readUInt$1(input, 16, 8, isBigEndian);
623
+ const high = readUInt$1(input, 16, 10, isBigEndian);
624
+ return (high << 16) + low;
625
+ }
626
+ function nextTag$1(input) {
627
+ if (input.length > 24) {
628
+ return input.slice(12);
629
+ }
630
+ }
631
+ function extractTags$1(input, isBigEndian) {
632
+ const tags = {};
633
+ let temp = input;
634
+ while (temp && temp.length) {
635
+ const code = readUInt$1(temp, 16, 0, isBigEndian);
636
+ const type = readUInt$1(temp, 16, 2, isBigEndian);
637
+ const length = readUInt$1(temp, 32, 4, isBigEndian);
638
+ if (code === 0) {
639
+ break;
640
+ } else {
641
+ if (length === 1 && (type === 3 || type === 4)) {
642
+ tags[code] = readValue$1(temp, isBigEndian);
643
+ }
644
+ temp = nextTag$1(temp);
645
+ }
646
+ }
647
+ return tags;
648
+ }
649
+ function determineEndianness$1(input) {
650
+ const signature = toUTF8String$1(input, 0, 2);
651
+ if ("II" === signature) {
652
+ return "LE";
653
+ } else if ("MM" === signature) {
654
+ return "BE";
655
+ }
656
+ }
657
+ const signatures$1 = [
658
+ // '492049', // currently not supported
659
+ "49492a00",
660
+ // Little endian
661
+ "4d4d002a"
662
+ // Big Endian
663
+ // '4d4d002a', // BigTIFF > 4GB. currently not supported
664
+ ];
665
+ const TIFF$1 = {
666
+ validate: (input) => signatures$1.includes(toHexString$1(input, 0, 4)),
667
+ calculate(input) {
668
+ const isBigEndian = determineEndianness$1(input) === "BE";
669
+ const ifdBuffer = readIFD$1(input, isBigEndian);
670
+ const tags = extractTags$1(ifdBuffer, isBigEndian);
671
+ const width = tags[256];
672
+ const height = tags[257];
673
+ if (!width || !height) {
674
+ throw new TypeError("Invalid Tiff. Missing tags");
675
+ }
676
+ return { height, width };
677
+ }
678
+ };
679
+
680
+ function calculateExtended$1(input) {
681
+ return {
682
+ height: 1 + readUInt24LE$1(input, 7),
683
+ width: 1 + readUInt24LE$1(input, 4)
684
+ };
685
+ }
686
+ function calculateLossless$1(input) {
687
+ return {
688
+ height: 1 + ((input[4] & 15) << 10 | input[3] << 2 | (input[2] & 192) >> 6),
689
+ width: 1 + ((input[2] & 63) << 8 | input[1])
690
+ };
691
+ }
692
+ function calculateLossy$1(input) {
693
+ return {
694
+ height: readInt16LE$1(input, 8) & 16383,
695
+ width: readInt16LE$1(input, 6) & 16383
696
+ };
697
+ }
698
+ const WEBP$1 = {
699
+ validate(input) {
700
+ const riffHeader = "RIFF" === toUTF8String$1(input, 0, 4);
701
+ const webpHeader = "WEBP" === toUTF8String$1(input, 8, 12);
702
+ const vp8Header = "VP8" === toUTF8String$1(input, 12, 15);
703
+ return riffHeader && webpHeader && vp8Header;
704
+ },
705
+ calculate(input) {
706
+ const chunkHeader = toUTF8String$1(input, 12, 16);
707
+ input = input.slice(20, 30);
708
+ if (chunkHeader === "VP8X") {
709
+ const extendedHeader = input[0];
710
+ const validStart = (extendedHeader & 192) === 0;
711
+ const validEnd = (extendedHeader & 1) === 0;
712
+ if (validStart && validEnd) {
713
+ return calculateExtended$1(input);
714
+ } else {
715
+ throw new TypeError("Invalid WebP");
716
+ }
717
+ }
718
+ if (chunkHeader === "VP8 " && input[0] !== 47) {
719
+ return calculateLossy$1(input);
720
+ }
721
+ const signature = toHexString$1(input, 3, 6);
722
+ if (chunkHeader === "VP8L" && signature !== "9d012a") {
723
+ return calculateLossless$1(input);
724
+ }
725
+ throw new TypeError("Invalid WebP");
726
+ }
727
+ };
728
+
729
+ const typeHandlers$1 = /* @__PURE__ */ new Map([
730
+ ["bmp", BMP$1],
731
+ ["cur", CUR$1],
732
+ ["dds", DDS$1],
733
+ ["gif", GIF$1],
734
+ ["heif", HEIF$1],
735
+ ["icns", ICNS$1],
736
+ ["ico", ICO$1],
737
+ ["j2c", J2C$1],
738
+ ["jp2", JP2$1],
739
+ ["jpg", JPG$1],
740
+ ["ktx", KTX$1],
741
+ ["png", PNG$1],
742
+ ["pnm", PNM$1],
743
+ ["psd", PSD$1],
744
+ ["svg", SVG$1],
745
+ ["tga", TGA$1],
746
+ ["tiff", TIFF$1],
747
+ ["webp", WEBP$1]
748
+ ]);
749
+ Array.from(typeHandlers$1.keys());
750
+
751
+ async function getConfiguredImageService$1() {
752
+ if (!globalThis?.astroAsset?.imageService) {
753
+ const { default: service } = await import(
754
+ // @ts-expect-error
755
+ '../astro/assets-service_146xb0vN.mjs'
756
+ ).then(n => n.n).catch((e) => {
757
+ const error = new AstroError(InvalidImageService);
758
+ error.cause = e;
759
+ throw error;
760
+ });
761
+ if (!globalThis.astroAsset)
762
+ globalThis.astroAsset = {};
763
+ globalThis.astroAsset.imageService = service;
764
+ return service;
765
+ }
766
+ return globalThis.astroAsset.imageService;
767
+ }
768
+
769
+ const fnv1a52 = (str) => {
770
+ const len = str.length;
771
+ let i = 0, t0 = 0, v0 = 8997, t1 = 0, v1 = 33826, t2 = 0, v2 = 40164, t3 = 0, v3 = 52210;
772
+ while (i < len) {
773
+ v0 ^= str.charCodeAt(i++);
774
+ t0 = v0 * 435;
775
+ t1 = v1 * 435;
776
+ t2 = v2 * 435;
777
+ t3 = v3 * 435;
778
+ t2 += v0 << 8;
779
+ t3 += v1 << 8;
780
+ t1 += t0 >>> 16;
781
+ v0 = t0 & 65535;
782
+ t2 += t1 >>> 16;
783
+ v1 = t1 & 65535;
784
+ v3 = t3 + (t2 >>> 16) & 65535;
785
+ v2 = t2 & 65535;
786
+ }
787
+ return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
788
+ };
789
+ const etag = (payload, weak = false) => {
790
+ const prefix = weak ? 'W/"' : '"';
791
+ return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
792
+ };
793
+
794
+ const decoder = new TextDecoder();
795
+ const toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
796
+ const toHexString = (input, start = 0, end = input.length) => input.slice(start, end).reduce((memo, i) => memo + ("0" + i.toString(16)).slice(-2), "");
797
+ const readInt16LE = (input, offset = 0) => {
798
+ const val = input[offset] + input[offset + 1] * 2 ** 8;
799
+ return val | (val & 2 ** 15) * 131070;
800
+ };
801
+ const readUInt16BE = (input, offset = 0) => input[offset] * 2 ** 8 + input[offset + 1];
802
+ const readUInt16LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8;
803
+ const readUInt24LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16;
804
+ const readInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + (input[offset + 3] << 24);
805
+ const readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] * 2 ** 8 + input[offset + 3];
806
+ const readUInt32LE = (input, offset = 0) => input[offset] + input[offset + 1] * 2 ** 8 + input[offset + 2] * 2 ** 16 + input[offset + 3] * 2 ** 24;
807
+ const methods = {
808
+ readUInt16BE,
809
+ readUInt16LE,
810
+ readUInt32BE,
811
+ readUInt32LE
812
+ };
813
+ function readUInt(input, bits, offset, isBigEndian) {
814
+ offset = offset || 0;
815
+ const endian = isBigEndian ? "BE" : "LE";
816
+ const methodName = "readUInt" + bits + endian;
817
+ return methods[methodName](input, offset);
818
+ }
819
+ function readBox(buffer, offset) {
820
+ if (buffer.length - offset < 4)
821
+ return;
822
+ const boxSize = readUInt32BE(buffer, offset);
823
+ if (buffer.length - offset < boxSize)
824
+ return;
825
+ return {
826
+ name: toUTF8String(buffer, 4 + offset, 8 + offset),
827
+ offset,
828
+ size: boxSize
829
+ };
830
+ }
831
+ function findBox(buffer, boxName, offset) {
832
+ while (offset < buffer.length) {
833
+ const box = readBox(buffer, offset);
834
+ if (!box)
835
+ break;
836
+ if (box.name === boxName)
837
+ return box;
838
+ offset += box.size;
839
+ }
840
+ }
841
+
842
+ const BMP = {
843
+ validate: (input) => toUTF8String(input, 0, 2) === "BM",
844
+ calculate: (input) => ({
845
+ height: Math.abs(readInt32LE(input, 22)),
846
+ width: readUInt32LE(input, 18)
847
+ })
848
+ };
849
+
850
+ const TYPE_ICON = 1;
851
+ const SIZE_HEADER$1 = 2 + 2 + 2;
852
+ const SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4;
853
+ function getSizeFromOffset(input, offset) {
854
+ const value = input[offset];
855
+ return value === 0 ? 256 : value;
856
+ }
857
+ function getImageSize$1(input, imageIndex) {
858
+ const offset = SIZE_HEADER$1 + imageIndex * SIZE_IMAGE_ENTRY;
859
+ return {
860
+ height: getSizeFromOffset(input, offset + 1),
861
+ width: getSizeFromOffset(input, offset)
862
+ };
863
+ }
864
+ const ICO = {
865
+ validate(input) {
866
+ const reserved = readUInt16LE(input, 0);
867
+ const imageCount = readUInt16LE(input, 4);
868
+ if (reserved !== 0 || imageCount === 0)
869
+ return false;
870
+ const imageType = readUInt16LE(input, 2);
871
+ return imageType === TYPE_ICON;
872
+ },
873
+ calculate(input) {
874
+ const nbImages = readUInt16LE(input, 4);
875
+ const imageSize = getImageSize$1(input, 0);
876
+ if (nbImages === 1)
877
+ return imageSize;
878
+ const imgs = [imageSize];
879
+ for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) {
880
+ imgs.push(getImageSize$1(input, imageIndex));
881
+ }
882
+ return {
883
+ height: imageSize.height,
884
+ images: imgs,
885
+ width: imageSize.width
886
+ };
887
+ }
888
+ };
889
+
890
+ const TYPE_CURSOR = 2;
891
+ const CUR = {
892
+ validate(input) {
893
+ const reserved = readUInt16LE(input, 0);
894
+ const imageCount = readUInt16LE(input, 4);
895
+ if (reserved !== 0 || imageCount === 0)
896
+ return false;
897
+ const imageType = readUInt16LE(input, 2);
898
+ return imageType === TYPE_CURSOR;
899
+ },
900
+ calculate: (input) => ICO.calculate(input)
901
+ };
902
+
903
+ const DDS = {
904
+ validate: (input) => readUInt32LE(input, 0) === 542327876,
905
+ calculate: (input) => ({
906
+ height: readUInt32LE(input, 12),
907
+ width: readUInt32LE(input, 16)
908
+ })
909
+ };
910
+
911
+ const gifRegexp = /^GIF8[79]a/;
912
+ const GIF = {
913
+ validate: (input) => gifRegexp.test(toUTF8String(input, 0, 6)),
914
+ calculate: (input) => ({
915
+ height: readUInt16LE(input, 8),
916
+ width: readUInt16LE(input, 6)
917
+ })
918
+ };
919
+
920
+ const brandMap = {
921
+ avif: "avif",
922
+ mif1: "heif",
923
+ msf1: "heif",
924
+ // hief-sequence
925
+ heic: "heic",
926
+ heix: "heic",
927
+ hevc: "heic",
928
+ // heic-sequence
929
+ hevx: "heic"
930
+ // heic-sequence
931
+ };
932
+ function detectBrands(buffer, start, end) {
933
+ let brandsDetected = {};
934
+ for (let i = start; i <= end; i += 4) {
935
+ const brand = toUTF8String(buffer, i, i + 4);
936
+ if (brand in brandMap) {
937
+ brandsDetected[brand] = 1;
938
+ }
939
+ }
940
+ if ("avif" in brandsDetected) {
941
+ return "avif";
942
+ } else if ("heic" in brandsDetected || "heix" in brandsDetected || "hevc" in brandsDetected || "hevx" in brandsDetected) {
943
+ return "heic";
944
+ } else if ("mif1" in brandsDetected || "msf1" in brandsDetected) {
945
+ return "heif";
946
+ }
947
+ }
948
+ const HEIF = {
949
+ validate(buffer) {
950
+ const ftype = toUTF8String(buffer, 4, 8);
951
+ const brand = toUTF8String(buffer, 8, 12);
952
+ return "ftyp" === ftype && brand in brandMap;
953
+ },
954
+ calculate(buffer) {
955
+ const metaBox = findBox(buffer, "meta", 0);
956
+ const iprpBox = metaBox && findBox(buffer, "iprp", metaBox.offset + 12);
957
+ const ipcoBox = iprpBox && findBox(buffer, "ipco", iprpBox.offset + 8);
958
+ const ispeBox = ipcoBox && findBox(buffer, "ispe", ipcoBox.offset + 8);
959
+ if (ispeBox) {
960
+ return {
961
+ height: readUInt32BE(buffer, ispeBox.offset + 16),
962
+ width: readUInt32BE(buffer, ispeBox.offset + 12),
963
+ type: detectBrands(buffer, 8, metaBox.offset)
964
+ };
965
+ }
966
+ throw new TypeError("Invalid HEIF, no size found");
967
+ }
968
+ };
969
+
970
+ const SIZE_HEADER = 4 + 4;
971
+ const FILE_LENGTH_OFFSET = 4;
972
+ const ENTRY_LENGTH_OFFSET = 4;
973
+ const ICON_TYPE_SIZE = {
974
+ ICON: 32,
975
+ "ICN#": 32,
976
+ // m => 16 x 16
977
+ "icm#": 16,
978
+ icm4: 16,
979
+ icm8: 16,
980
+ // s => 16 x 16
981
+ "ics#": 16,
982
+ ics4: 16,
983
+ ics8: 16,
984
+ is32: 16,
985
+ s8mk: 16,
986
+ icp4: 16,
987
+ // l => 32 x 32
988
+ icl4: 32,
989
+ icl8: 32,
990
+ il32: 32,
991
+ l8mk: 32,
992
+ icp5: 32,
993
+ ic11: 32,
994
+ // h => 48 x 48
995
+ ich4: 48,
996
+ ich8: 48,
997
+ ih32: 48,
998
+ h8mk: 48,
999
+ // . => 64 x 64
1000
+ icp6: 64,
1001
+ ic12: 32,
1002
+ // t => 128 x 128
1003
+ it32: 128,
1004
+ t8mk: 128,
1005
+ ic07: 128,
1006
+ // . => 256 x 256
1007
+ ic08: 256,
1008
+ ic13: 256,
1009
+ // . => 512 x 512
1010
+ ic09: 512,
1011
+ ic14: 512,
1012
+ // . => 1024 x 1024
1013
+ ic10: 1024
1014
+ };
1015
+ function readImageHeader(input, imageOffset) {
1016
+ const imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET;
1017
+ return [
1018
+ toUTF8String(input, imageOffset, imageLengthOffset),
1019
+ readUInt32BE(input, imageLengthOffset)
1020
+ ];
1021
+ }
1022
+ function getImageSize(type) {
1023
+ const size = ICON_TYPE_SIZE[type];
1024
+ return { width: size, height: size, type };
1025
+ }
1026
+ const ICNS = {
1027
+ validate: (input) => toUTF8String(input, 0, 4) === "icns",
1028
+ calculate(input) {
1029
+ const inputLength = input.length;
1030
+ const fileLength = readUInt32BE(input, FILE_LENGTH_OFFSET);
1031
+ let imageOffset = SIZE_HEADER;
1032
+ let imageHeader = readImageHeader(input, imageOffset);
1033
+ let imageSize = getImageSize(imageHeader[0]);
1034
+ imageOffset += imageHeader[1];
1035
+ if (imageOffset === fileLength)
1036
+ return imageSize;
1037
+ const result = {
1038
+ height: imageSize.height,
1039
+ images: [imageSize],
1040
+ width: imageSize.width
1041
+ };
1042
+ while (imageOffset < fileLength && imageOffset < inputLength) {
1043
+ imageHeader = readImageHeader(input, imageOffset);
1044
+ imageSize = getImageSize(imageHeader[0]);
1045
+ imageOffset += imageHeader[1];
1046
+ result.images.push(imageSize);
1047
+ }
1048
+ return result;
1049
+ }
1050
+ };
1051
+
1052
+ const J2C = {
1053
+ // TODO: this doesn't seem right. SIZ marker doesn't have to be right after the SOC
1054
+ validate: (input) => toHexString(input, 0, 4) === "ff4fff51",
1055
+ calculate: (input) => ({
1056
+ height: readUInt32BE(input, 12),
1057
+ width: readUInt32BE(input, 8)
1058
+ })
1059
+ };
1060
+
1061
+ const JP2 = {
1062
+ validate(input) {
1063
+ if (readUInt32BE(input, 4) !== 1783636e3 || readUInt32BE(input, 0) < 1)
1064
+ return false;
1065
+ const ftypBox = findBox(input, "ftyp", 0);
1066
+ if (!ftypBox)
1067
+ return false;
1068
+ return readUInt32BE(input, ftypBox.offset + 4) === 1718909296;
1069
+ },
1070
+ calculate(input) {
1071
+ const jp2hBox = findBox(input, "jp2h", 0);
1072
+ const ihdrBox = jp2hBox && findBox(input, "ihdr", jp2hBox.offset + 8);
1073
+ if (ihdrBox) {
1074
+ return {
1075
+ height: readUInt32BE(input, ihdrBox.offset + 8),
1076
+ width: readUInt32BE(input, ihdrBox.offset + 12)
1077
+ };
1078
+ }
1079
+ throw new TypeError("Unsupported JPEG 2000 format");
1080
+ }
1081
+ };
1082
+
1083
+ const EXIF_MARKER = "45786966";
1084
+ const APP1_DATA_SIZE_BYTES = 2;
1085
+ const EXIF_HEADER_BYTES = 6;
1086
+ const TIFF_BYTE_ALIGN_BYTES = 2;
1087
+ const BIG_ENDIAN_BYTE_ALIGN = "4d4d";
1088
+ const LITTLE_ENDIAN_BYTE_ALIGN = "4949";
1089
+ const IDF_ENTRY_BYTES = 12;
1090
+ const NUM_DIRECTORY_ENTRIES_BYTES = 2;
1091
+ function isEXIF(input) {
1092
+ return toHexString(input, 2, 6) === EXIF_MARKER;
1093
+ }
1094
+ function extractSize(input, index) {
1095
+ return {
1096
+ height: readUInt16BE(input, index),
1097
+ width: readUInt16BE(input, index + 2)
1098
+ };
1099
+ }
1100
+ function extractOrientation(exifBlock, isBigEndian) {
1101
+ const idfOffset = 8;
1102
+ const offset = EXIF_HEADER_BYTES + idfOffset;
1103
+ const idfDirectoryEntries = readUInt(exifBlock, 16, offset, isBigEndian);
1104
+ for (let directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) {
1105
+ const start = offset + NUM_DIRECTORY_ENTRIES_BYTES + directoryEntryNumber * IDF_ENTRY_BYTES;
1106
+ const end = start + IDF_ENTRY_BYTES;
1107
+ if (start > exifBlock.length) {
1108
+ return;
1109
+ }
1110
+ const block = exifBlock.slice(start, end);
1111
+ const tagNumber = readUInt(block, 16, 0, isBigEndian);
1112
+ if (tagNumber === 274) {
1113
+ const dataFormat = readUInt(block, 16, 2, isBigEndian);
1114
+ if (dataFormat !== 3) {
1115
+ return;
1116
+ }
1117
+ const numberOfComponents = readUInt(block, 32, 4, isBigEndian);
1118
+ if (numberOfComponents !== 1) {
1119
+ return;
1120
+ }
1121
+ return readUInt(block, 16, 8, isBigEndian);
1122
+ }
1123
+ }
1124
+ }
1125
+ function validateExifBlock(input, index) {
1126
+ const exifBlock = input.slice(APP1_DATA_SIZE_BYTES, index);
1127
+ const byteAlign = toHexString(
1128
+ exifBlock,
1129
+ EXIF_HEADER_BYTES,
1130
+ EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES
1131
+ );
1132
+ const isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN;
1133
+ const isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN;
1134
+ if (isBigEndian || isLittleEndian) {
1135
+ return extractOrientation(exifBlock, isBigEndian);
1136
+ }
1137
+ }
1138
+ function validateInput(input, index) {
1139
+ if (index > input.length) {
1140
+ throw new TypeError("Corrupt JPG, exceeded buffer limits");
1141
+ }
1142
+ }
1143
+ const JPG = {
1144
+ validate: (input) => toHexString(input, 0, 2) === "ffd8",
1145
+ calculate(input) {
1146
+ input = input.slice(4);
1147
+ let orientation;
1148
+ let next;
1149
+ while (input.length) {
1150
+ const i = readUInt16BE(input, 0);
1151
+ if (input[i] !== 255) {
1152
+ input = input.slice(1);
1153
+ continue;
1154
+ }
1155
+ if (isEXIF(input)) {
1156
+ orientation = validateExifBlock(input, i);
1157
+ }
1158
+ validateInput(input, i);
1159
+ next = input[i + 1];
1160
+ if (next === 192 || next === 193 || next === 194) {
1161
+ const size = extractSize(input, i + 5);
1162
+ if (!orientation) {
1163
+ return size;
1164
+ }
1165
+ return {
1166
+ height: size.height,
1167
+ orientation,
1168
+ width: size.width
1169
+ };
1170
+ }
1171
+ input = input.slice(i + 2);
1172
+ }
1173
+ throw new TypeError("Invalid JPG, no size found");
1174
+ }
1175
+ };
1176
+
1177
+ const KTX = {
1178
+ validate: (input) => {
1179
+ const signature = toUTF8String(input, 1, 7);
1180
+ return ["KTX 11", "KTX 20"].includes(signature);
1181
+ },
1182
+ calculate: (input) => {
1183
+ const type = input[5] === 49 ? "ktx" : "ktx2";
1184
+ const offset = type === "ktx" ? 36 : 20;
1185
+ return {
1186
+ height: readUInt32LE(input, offset + 4),
1187
+ width: readUInt32LE(input, offset),
1188
+ type
1189
+ };
1190
+ }
1191
+ };
1192
+
1193
+ const pngSignature = "PNG\r\n\n";
1194
+ const pngImageHeaderChunkName = "IHDR";
1195
+ const pngFriedChunkName = "CgBI";
1196
+ const PNG = {
1197
+ validate(input) {
1198
+ if (pngSignature === toUTF8String(input, 1, 8)) {
1199
+ let chunkName = toUTF8String(input, 12, 16);
1200
+ if (chunkName === pngFriedChunkName) {
1201
+ chunkName = toUTF8String(input, 28, 32);
1202
+ }
1203
+ if (chunkName !== pngImageHeaderChunkName) {
1204
+ throw new TypeError("Invalid PNG");
1205
+ }
1206
+ return true;
1207
+ }
1208
+ return false;
1209
+ },
1210
+ calculate(input) {
1211
+ if (toUTF8String(input, 12, 16) === pngFriedChunkName) {
1212
+ return {
1213
+ height: readUInt32BE(input, 36),
1214
+ width: readUInt32BE(input, 32)
1215
+ };
1216
+ }
1217
+ return {
1218
+ height: readUInt32BE(input, 20),
1219
+ width: readUInt32BE(input, 16)
1220
+ };
1221
+ }
1222
+ };
1223
+
1224
+ const PNMTypes = {
1225
+ P1: "pbm/ascii",
1226
+ P2: "pgm/ascii",
1227
+ P3: "ppm/ascii",
1228
+ P4: "pbm",
1229
+ P5: "pgm",
1230
+ P6: "ppm",
1231
+ P7: "pam",
1232
+ PF: "pfm"
1233
+ };
1234
+ const handlers = {
1235
+ default: (lines) => {
1236
+ let dimensions = [];
1237
+ while (lines.length > 0) {
1238
+ const line = lines.shift();
1239
+ if (line[0] === "#") {
1240
+ continue;
1241
+ }
1242
+ dimensions = line.split(" ");
1243
+ break;
1244
+ }
1245
+ if (dimensions.length === 2) {
1246
+ return {
1247
+ height: parseInt(dimensions[1], 10),
1248
+ width: parseInt(dimensions[0], 10)
1249
+ };
1250
+ } else {
1251
+ throw new TypeError("Invalid PNM");
1252
+ }
1253
+ },
1254
+ pam: (lines) => {
1255
+ const size = {};
1256
+ while (lines.length > 0) {
1257
+ const line = lines.shift();
1258
+ if (line.length > 16 || line.charCodeAt(0) > 128) {
1259
+ continue;
1260
+ }
1261
+ const [key, value] = line.split(" ");
1262
+ if (key && value) {
1263
+ size[key.toLowerCase()] = parseInt(value, 10);
1264
+ }
1265
+ if (size.height && size.width) {
1266
+ break;
1267
+ }
1268
+ }
1269
+ if (size.height && size.width) {
1270
+ return {
1271
+ height: size.height,
1272
+ width: size.width
1273
+ };
1274
+ } else {
1275
+ throw new TypeError("Invalid PAM");
1276
+ }
1277
+ }
1278
+ };
1279
+ const PNM = {
1280
+ validate: (input) => toUTF8String(input, 0, 2) in PNMTypes,
1281
+ calculate(input) {
1282
+ const signature = toUTF8String(input, 0, 2);
1283
+ const type = PNMTypes[signature];
1284
+ const lines = toUTF8String(input, 3).split(/[\r\n]+/);
1285
+ const handler = handlers[type] || handlers.default;
1286
+ return handler(lines);
1287
+ }
1288
+ };
1289
+
1290
+ const PSD = {
1291
+ validate: (input) => toUTF8String(input, 0, 4) === "8BPS",
1292
+ calculate: (input) => ({
1293
+ height: readUInt32BE(input, 14),
1294
+ width: readUInt32BE(input, 18)
1295
+ })
1296
+ };
1297
+
1298
+ const svgReg = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/;
1299
+ const extractorRegExps = {
1300
+ height: /\sheight=(['"])([^%]+?)\1/,
1301
+ root: svgReg,
1302
+ viewbox: /\sviewBox=(['"])(.+?)\1/i,
1303
+ width: /\swidth=(['"])([^%]+?)\1/
1304
+ };
1305
+ const INCH_CM = 2.54;
1306
+ const units = {
1307
+ in: 96,
1308
+ cm: 96 / INCH_CM,
1309
+ em: 16,
1310
+ ex: 8,
1311
+ m: 96 / INCH_CM * 100,
1312
+ mm: 96 / INCH_CM / 10,
1313
+ pc: 96 / 72 / 12,
1314
+ pt: 96 / 72,
1315
+ px: 1
1316
+ };
1317
+ const unitsReg = new RegExp(
1318
+ // eslint-disable-next-line regexp/prefer-d
1319
+ `^([0-9.]+(?:e\\d+)?)(${Object.keys(units).join("|")})?$`
1320
+ );
1321
+ function parseLength(len) {
1322
+ const m = unitsReg.exec(len);
1323
+ if (!m) {
1324
+ return void 0;
1325
+ }
1326
+ return Math.round(Number(m[1]) * (units[m[2]] || 1));
1327
+ }
1328
+ function parseViewbox(viewbox) {
1329
+ const bounds = viewbox.split(" ");
1330
+ return {
1331
+ height: parseLength(bounds[3]),
1332
+ width: parseLength(bounds[2])
1333
+ };
1334
+ }
1335
+ function parseAttributes(root) {
1336
+ const width = root.match(extractorRegExps.width);
1337
+ const height = root.match(extractorRegExps.height);
1338
+ const viewbox = root.match(extractorRegExps.viewbox);
1339
+ return {
1340
+ height: height && parseLength(height[2]),
1341
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
1342
+ viewbox: viewbox && parseViewbox(viewbox[2]),
1343
+ width: width && parseLength(width[2])
1344
+ };
1345
+ }
1346
+ function calculateByDimensions(attrs) {
1347
+ return {
1348
+ height: attrs.height,
1349
+ width: attrs.width
1350
+ };
1351
+ }
1352
+ function calculateByViewbox(attrs, viewbox) {
1353
+ const ratio = viewbox.width / viewbox.height;
1354
+ if (attrs.width) {
1355
+ return {
1356
+ height: Math.floor(attrs.width / ratio),
1357
+ width: attrs.width
1358
+ };
1359
+ }
1360
+ if (attrs.height) {
1361
+ return {
1362
+ height: attrs.height,
1363
+ width: Math.floor(attrs.height * ratio)
1364
+ };
1365
+ }
1366
+ return {
1367
+ height: viewbox.height,
1368
+ width: viewbox.width
1369
+ };
1370
+ }
1371
+ const SVG = {
1372
+ // Scan only the first kilo-byte to speed up the check on larger files
1373
+ validate: (input) => svgReg.test(toUTF8String(input, 0, 1e3)),
1374
+ calculate(input) {
1375
+ const root = toUTF8String(input).match(extractorRegExps.root);
1376
+ if (root) {
1377
+ const attrs = parseAttributes(root[0]);
1378
+ if (attrs.width && attrs.height) {
1379
+ return calculateByDimensions(attrs);
1380
+ }
1381
+ if (attrs.viewbox) {
1382
+ return calculateByViewbox(attrs, attrs.viewbox);
1383
+ }
1384
+ }
1385
+ throw new TypeError("Invalid SVG");
1386
+ }
1387
+ };
1388
+
1389
+ const TGA = {
1390
+ validate(input) {
1391
+ return readUInt16LE(input, 0) === 0 && readUInt16LE(input, 4) === 0;
1392
+ },
1393
+ calculate(input) {
1394
+ return {
1395
+ height: readUInt16LE(input, 14),
1396
+ width: readUInt16LE(input, 12)
1397
+ };
1398
+ }
1399
+ };
1400
+
1401
+ function readIFD(input, isBigEndian) {
1402
+ const ifdOffset = readUInt(input, 32, 4, isBigEndian);
1403
+ return input.slice(ifdOffset + 2);
1404
+ }
1405
+ function readValue(input, isBigEndian) {
1406
+ const low = readUInt(input, 16, 8, isBigEndian);
1407
+ const high = readUInt(input, 16, 10, isBigEndian);
1408
+ return (high << 16) + low;
1409
+ }
1410
+ function nextTag(input) {
1411
+ if (input.length > 24) {
1412
+ return input.slice(12);
1413
+ }
1414
+ }
1415
+ function extractTags(input, isBigEndian) {
1416
+ const tags = {};
1417
+ let temp = input;
1418
+ while (temp && temp.length) {
1419
+ const code = readUInt(temp, 16, 0, isBigEndian);
1420
+ const type = readUInt(temp, 16, 2, isBigEndian);
1421
+ const length = readUInt(temp, 32, 4, isBigEndian);
1422
+ if (code === 0) {
1423
+ break;
1424
+ } else {
1425
+ if (length === 1 && (type === 3 || type === 4)) {
1426
+ tags[code] = readValue(temp, isBigEndian);
1427
+ }
1428
+ temp = nextTag(temp);
1429
+ }
1430
+ }
1431
+ return tags;
1432
+ }
1433
+ function determineEndianness(input) {
1434
+ const signature = toUTF8String(input, 0, 2);
1435
+ if ("II" === signature) {
1436
+ return "LE";
1437
+ } else if ("MM" === signature) {
1438
+ return "BE";
1439
+ }
1440
+ }
1441
+ const signatures = [
1442
+ // '492049', // currently not supported
1443
+ "49492a00",
1444
+ // Little endian
1445
+ "4d4d002a"
1446
+ // Big Endian
1447
+ // '4d4d002a', // BigTIFF > 4GB. currently not supported
1448
+ ];
1449
+ const TIFF = {
1450
+ validate: (input) => signatures.includes(toHexString(input, 0, 4)),
1451
+ calculate(input) {
1452
+ const isBigEndian = determineEndianness(input) === "BE";
1453
+ const ifdBuffer = readIFD(input, isBigEndian);
1454
+ const tags = extractTags(ifdBuffer, isBigEndian);
1455
+ const width = tags[256];
1456
+ const height = tags[257];
1457
+ if (!width || !height) {
1458
+ throw new TypeError("Invalid Tiff. Missing tags");
1459
+ }
1460
+ return { height, width };
1461
+ }
1462
+ };
1463
+
1464
+ function calculateExtended(input) {
1465
+ return {
1466
+ height: 1 + readUInt24LE(input, 7),
1467
+ width: 1 + readUInt24LE(input, 4)
1468
+ };
1469
+ }
1470
+ function calculateLossless(input) {
1471
+ return {
1472
+ height: 1 + ((input[4] & 15) << 10 | input[3] << 2 | (input[2] & 192) >> 6),
1473
+ width: 1 + ((input[2] & 63) << 8 | input[1])
1474
+ };
1475
+ }
1476
+ function calculateLossy(input) {
1477
+ return {
1478
+ height: readInt16LE(input, 8) & 16383,
1479
+ width: readInt16LE(input, 6) & 16383
1480
+ };
1481
+ }
1482
+ const WEBP = {
1483
+ validate(input) {
1484
+ const riffHeader = "RIFF" === toUTF8String(input, 0, 4);
1485
+ const webpHeader = "WEBP" === toUTF8String(input, 8, 12);
1486
+ const vp8Header = "VP8" === toUTF8String(input, 12, 15);
1487
+ return riffHeader && webpHeader && vp8Header;
1488
+ },
1489
+ calculate(input) {
1490
+ const chunkHeader = toUTF8String(input, 12, 16);
1491
+ input = input.slice(20, 30);
1492
+ if (chunkHeader === "VP8X") {
1493
+ const extendedHeader = input[0];
1494
+ const validStart = (extendedHeader & 192) === 0;
1495
+ const validEnd = (extendedHeader & 1) === 0;
1496
+ if (validStart && validEnd) {
1497
+ return calculateExtended(input);
1498
+ } else {
1499
+ throw new TypeError("Invalid WebP");
1500
+ }
1501
+ }
1502
+ if (chunkHeader === "VP8 " && input[0] !== 47) {
1503
+ return calculateLossy(input);
1504
+ }
1505
+ const signature = toHexString(input, 3, 6);
1506
+ if (chunkHeader === "VP8L" && signature !== "9d012a") {
1507
+ return calculateLossless(input);
1508
+ }
1509
+ throw new TypeError("Invalid WebP");
1510
+ }
1511
+ };
1512
+
1513
+ const typeHandlers = /* @__PURE__ */ new Map([
1514
+ ["bmp", BMP],
1515
+ ["cur", CUR],
1516
+ ["dds", DDS],
1517
+ ["gif", GIF],
1518
+ ["heif", HEIF],
1519
+ ["icns", ICNS],
1520
+ ["ico", ICO],
1521
+ ["j2c", J2C],
1522
+ ["jp2", JP2],
1523
+ ["jpg", JPG],
1524
+ ["ktx", KTX],
1525
+ ["png", PNG],
1526
+ ["pnm", PNM],
1527
+ ["psd", PSD],
1528
+ ["svg", SVG],
1529
+ ["tga", TGA],
1530
+ ["tiff", TIFF],
1531
+ ["webp", WEBP]
1532
+ ]);
1533
+ const types = Array.from(typeHandlers.keys());
1534
+
1535
+ const firstBytes = /* @__PURE__ */ new Map([
1536
+ [56, "psd"],
1537
+ [66, "bmp"],
1538
+ [68, "dds"],
1539
+ [71, "gif"],
1540
+ [73, "tiff"],
1541
+ [77, "tiff"],
1542
+ [82, "webp"],
1543
+ [105, "icns"],
1544
+ [137, "png"],
1545
+ [255, "jpg"]
1546
+ ]);
1547
+ function detector(input) {
1548
+ const byte = input[0];
1549
+ const type = firstBytes.get(byte);
1550
+ if (type && typeHandlers.get(type).validate(input)) {
1551
+ return type;
1552
+ }
1553
+ return types.find((fileType) => typeHandlers.get(fileType).validate(input));
1554
+ }
1555
+
1556
+ const globalOptions = {
1557
+ disabledTypes: []
1558
+ };
1559
+ function lookup(input) {
1560
+ const type = detector(input);
1561
+ if (typeof type !== "undefined") {
1562
+ if (globalOptions.disabledTypes.indexOf(type) > -1) {
1563
+ throw new TypeError("disabled file type: " + type);
1564
+ }
1565
+ const size = typeHandlers.get(type).calculate(input);
1566
+ if (size !== void 0) {
1567
+ size.type = size.type ?? type;
1568
+ return size;
1569
+ }
1570
+ }
1571
+ throw new TypeError("unsupported file type: " + type);
1572
+ }
1573
+
1574
+ async function probe(url) {
1575
+ const response = await fetch(url);
1576
+ if (!response.body || !response.ok) {
1577
+ throw new Error("Failed to fetch image");
1578
+ }
1579
+ const reader = response.body.getReader();
1580
+ let done, value;
1581
+ let accumulatedChunks = new Uint8Array();
1582
+ while (!done) {
1583
+ const readResult = await reader.read();
1584
+ done = readResult.done;
1585
+ if (done)
1586
+ break;
1587
+ if (readResult.value) {
1588
+ value = readResult.value;
1589
+ let tmp = new Uint8Array(accumulatedChunks.length + value.length);
1590
+ tmp.set(accumulatedChunks, 0);
1591
+ tmp.set(value, accumulatedChunks.length);
1592
+ accumulatedChunks = tmp;
1593
+ try {
1594
+ const dimensions = lookup(accumulatedChunks);
1595
+ if (dimensions) {
1596
+ await reader.cancel();
1597
+ return dimensions;
1598
+ }
1599
+ } catch (error) {
1600
+ }
1601
+ }
1602
+ }
1603
+ throw new Error("Failed to parse the size");
1604
+ }
1605
+
1606
+ async function getConfiguredImageService() {
1607
+ if (!globalThis?.astroAsset?.imageService) {
1608
+ const { default: service } = await import(
1609
+ // @ts-expect-error
1610
+ '../astro/assets-service_146xb0vN.mjs'
1611
+ ).then(n => n.n).catch((e) => {
1612
+ const error = new AstroError$1(InvalidImageService$1);
1613
+ error.cause = e;
1614
+ throw error;
1615
+ });
1616
+ if (!globalThis.astroAsset)
1617
+ globalThis.astroAsset = {};
1618
+ globalThis.astroAsset.imageService = service;
1619
+ return service;
1620
+ }
1621
+ return globalThis.astroAsset.imageService;
1622
+ }
1623
+ async function getImage$1(options, imageConfig) {
1624
+ if (!options || typeof options !== "object") {
1625
+ throw new AstroError$1({
1626
+ ...ExpectedImageOptions,
1627
+ message: ExpectedImageOptions.message(JSON.stringify(options))
1628
+ });
1629
+ }
1630
+ if (typeof options.src === "undefined") {
1631
+ throw new AstroError$1({
1632
+ ...ExpectedImage,
1633
+ message: ExpectedImage.message(
1634
+ options.src,
1635
+ "undefined",
1636
+ JSON.stringify(options)
1637
+ )
1638
+ });
1639
+ }
1640
+ const service = await getConfiguredImageService();
1641
+ const resolvedOptions = {
1642
+ ...options,
1643
+ src: await resolveSrc(options.src)
1644
+ };
1645
+ if (options.inferSize && isRemoteImage(resolvedOptions.src)) {
1646
+ try {
1647
+ const result = await probe(resolvedOptions.src);
1648
+ resolvedOptions.width ??= result.width;
1649
+ resolvedOptions.height ??= result.height;
1650
+ delete resolvedOptions.inferSize;
1651
+ } catch {
1652
+ throw new AstroError$1({
1653
+ ...FailedToFetchRemoteImageDimensions,
1654
+ message: FailedToFetchRemoteImageDimensions.message(resolvedOptions.src)
1655
+ });
1656
+ }
1657
+ }
1658
+ const originalPath = isESMImportedImage(resolvedOptions.src) ? resolvedOptions.src.fsPath : resolvedOptions.src;
1659
+ const clonedSrc = isESMImportedImage(resolvedOptions.src) ? (
1660
+ // @ts-expect-error - clone is a private, hidden prop
1661
+ resolvedOptions.src.clone ?? resolvedOptions.src
1662
+ ) : resolvedOptions.src;
1663
+ resolvedOptions.src = clonedSrc;
1664
+ const validatedOptions = service.validateOptions ? await service.validateOptions(resolvedOptions, imageConfig) : resolvedOptions;
1665
+ const srcSetTransforms = service.getSrcSet ? await service.getSrcSet(validatedOptions, imageConfig) : [];
1666
+ let imageURL = await service.getURL(validatedOptions, imageConfig);
1667
+ let srcSets = await Promise.all(
1668
+ srcSetTransforms.map(async (srcSet) => ({
1669
+ transform: srcSet.transform,
1670
+ url: await service.getURL(srcSet.transform, imageConfig),
1671
+ descriptor: srcSet.descriptor,
1672
+ attributes: srcSet.attributes
1673
+ }))
1674
+ );
1675
+ if (isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && imageURL === validatedOptions.src)) {
1676
+ const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS;
1677
+ imageURL = globalThis.astroAsset.addStaticImage(validatedOptions, propsToHash, originalPath);
1678
+ srcSets = srcSetTransforms.map((srcSet) => ({
1679
+ transform: srcSet.transform,
1680
+ url: globalThis.astroAsset.addStaticImage(srcSet.transform, propsToHash, originalPath),
1681
+ descriptor: srcSet.descriptor,
1682
+ attributes: srcSet.attributes
1683
+ }));
1684
+ }
1685
+ return {
1686
+ rawOptions: resolvedOptions,
1687
+ options: validatedOptions,
1688
+ src: imageURL,
1689
+ srcSet: {
1690
+ values: srcSets,
1691
+ attribute: srcSets.map((srcSet) => `${srcSet.url} ${srcSet.descriptor}`).join(", ")
1692
+ },
1693
+ attributes: service.getHTMLAttributes !== void 0 ? await service.getHTMLAttributes(validatedOptions, imageConfig) : {}
1694
+ };
1695
+ }
1696
+
1697
+ const $$Astro$1 = createAstro("https://demo.ecomplus.app");
1698
+ const $$Image = createComponent(async ($$result, $$props, $$slots) => {
1699
+ const Astro2 = $$result.createAstro($$Astro$1, $$props, $$slots);
1700
+ Astro2.self = $$Image;
1701
+ const props = Astro2.props;
1702
+ if (props.alt === void 0 || props.alt === null) {
1703
+ throw new AstroError$1(ImageMissingAlt);
1704
+ }
1705
+ if (typeof props.width === "string") {
1706
+ props.width = parseInt(props.width);
1707
+ }
1708
+ if (typeof props.height === "string") {
1709
+ props.height = parseInt(props.height);
1710
+ }
1711
+ const image = await getImage(props);
1712
+ const additionalAttributes = {};
1713
+ if (image.srcSet.values.length > 0) {
1714
+ additionalAttributes.srcset = image.srcSet.attribute;
1715
+ }
1716
+ return renderTemplate`${maybeRenderHead()}<img${addAttribute(image.src, "src")}${spreadAttributes(additionalAttributes)}${spreadAttributes(image.attributes)}>`;
1717
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/node_modules/astro/components/Image.astro", void 0);
1718
+
1719
+ const $$Astro = createAstro("https://demo.ecomplus.app");
1720
+ const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
1721
+ const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
1722
+ Astro2.self = $$Picture;
1723
+ const defaultFormats = ["webp"];
1724
+ const defaultFallbackFormat = "png";
1725
+ const specialFormatsFallback = ["gif", "svg", "jpg", "jpeg"];
1726
+ const { formats = defaultFormats, pictureAttributes = {}, fallbackFormat, ...props } = Astro2.props;
1727
+ if (props.alt === void 0 || props.alt === null) {
1728
+ throw new AstroError$1(ImageMissingAlt);
1729
+ }
1730
+ const originalSrc = await resolveSrc(props.src);
1731
+ const optimizedImages = await Promise.all(
1732
+ formats.map(
1733
+ async (format) => await getImage({
1734
+ ...props,
1735
+ src: originalSrc,
1736
+ format,
1737
+ widths: props.widths,
1738
+ densities: props.densities
1739
+ })
1740
+ )
1741
+ );
1742
+ let resultFallbackFormat = fallbackFormat ?? defaultFallbackFormat;
1743
+ if (!fallbackFormat && isESMImportedImage(originalSrc) && originalSrc.format in specialFormatsFallback) {
1744
+ resultFallbackFormat = originalSrc.format;
1745
+ }
1746
+ const fallbackImage = await getImage({
1747
+ ...props,
1748
+ format: resultFallbackFormat,
1749
+ widths: props.widths,
1750
+ densities: props.densities
1751
+ });
1752
+ const imgAdditionalAttributes = {};
1753
+ const sourceAdditionalAttributes = {};
1754
+ if (props.sizes) {
1755
+ sourceAdditionalAttributes.sizes = props.sizes;
1756
+ }
1757
+ if (fallbackImage.srcSet.values.length > 0) {
1758
+ imgAdditionalAttributes.srcset = fallbackImage.srcSet.attribute;
1759
+ }
1760
+ return renderTemplate`${maybeRenderHead()}<picture${spreadAttributes(pictureAttributes)}> ${Object.entries(optimizedImages).map(([_, image]) => {
1761
+ const srcsetAttribute = props.densities || !props.densities && !props.widths ? `${image.src}${image.srcSet.values.length > 0 ? ", " + image.srcSet.attribute : ""}` : image.srcSet.attribute;
1762
+ return renderTemplate`<source${addAttribute(srcsetAttribute, "srcset")}${addAttribute("image/" + image.options.format, "type")}${spreadAttributes(sourceAdditionalAttributes)}>`;
1763
+ })} <img${addAttribute(fallbackImage.src, "src")}${spreadAttributes(imgAdditionalAttributes)}${spreadAttributes(fallbackImage.attributes)}> </picture>`;
1764
+ }, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/node_modules/astro/components/Picture.astro", void 0);
1765
+
1766
+ const imageConfig = {"service":{"entrypoint":"astro/assets/services/noop","config":{}},"domains":[],"remotePatterns":[],"endpoint":"astro/assets/endpoint/node"};
1767
+ // This is used by the @astrojs/node integration to locate images.
1768
+ // It's unused on other platforms, but on some platforms like Netlify (and presumably also Vercel)
1769
+ // new URL("dist/...") is interpreted by the bundler as a signal to include that directory
1770
+ // in the Lambda bundle, which would bloat the bundle with images.
1771
+ // To prevent this, we mark the URL construction as pure,
1772
+ // so that it's tree-shaken away for all platforms that don't need it.
1773
+ const outDir = /* #__PURE__ */ new URL("file:///home/leo/code/ecomplus/cloud-commerce/packages/storefront/dist/client/");
1774
+ const assetsDir = /* #__PURE__ */ new URL("_astro", outDir);
1775
+ const getImage = async (options) => await getImage$1(options, imageConfig);
1776
+
1777
+ async function loadLocalImage(src, url) {
1778
+ const assetsDirPath = fileURLToPath(assetsDir);
1779
+ let fileUrl;
1780
+ {
1781
+ try {
1782
+ fileUrl = new URL("." + src, outDir);
1783
+ const filePath = fileURLToPath(fileUrl);
1784
+ if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
1785
+ return void 0;
1786
+ }
1787
+ } catch (err) {
1788
+ return void 0;
1789
+ }
1790
+ }
1791
+ let buffer = void 0;
1792
+ try {
1793
+ buffer = await readFile(fileUrl);
1794
+ } catch (e) {
1795
+ try {
1796
+ const sourceUrl = new URL(src, url.origin);
1797
+ buffer = await loadRemoteImage(sourceUrl);
1798
+ } catch (err) {
1799
+ console.error("Could not process image request:", err);
1800
+ return void 0;
1801
+ }
1802
+ }
1803
+ return buffer;
1804
+ }
1805
+ async function loadRemoteImage(src) {
1806
+ try {
1807
+ const res = await fetch(src);
1808
+ if (!res.ok) {
1809
+ return void 0;
1810
+ }
1811
+ return Buffer.from(await res.arrayBuffer());
1812
+ } catch (err) {
1813
+ return void 0;
1814
+ }
1815
+ }
1816
+ const GET = async ({ request }) => {
1817
+ try {
1818
+ const imageService = await getConfiguredImageService$1();
1819
+ if (!("transform" in imageService)) {
1820
+ throw new Error("Configured image service is not a local service");
1821
+ }
1822
+ const url = new URL(request.url);
1823
+ const transform = await imageService.parseURL(url, imageConfig);
1824
+ if (!transform?.src) {
1825
+ const err = new Error(
1826
+ "Incorrect transform returned by `parseURL`. Expected a transform with a `src` property."
1827
+ );
1828
+ console.error("Could not parse image transform from URL:", err);
1829
+ return new Response("Internal Server Error", { status: 500 });
1830
+ }
1831
+ let inputBuffer = void 0;
1832
+ if (isRemotePath(transform.src)) {
1833
+ if (isRemoteAllowed(transform.src, imageConfig) === false) {
1834
+ return new Response("Forbidden", { status: 403 });
1835
+ }
1836
+ inputBuffer = await loadRemoteImage(new URL(transform.src));
1837
+ } else {
1838
+ inputBuffer = await loadLocalImage(transform.src, url);
1839
+ }
1840
+ if (!inputBuffer) {
1841
+ return new Response("Internal Server Error", { status: 500 });
1842
+ }
1843
+ const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig);
1844
+ return new Response(data, {
1845
+ status: 200,
1846
+ headers: {
1847
+ "Content-Type": mime.getType(format) ?? `image/${format}`,
1848
+ "Cache-Control": "public, max-age=31536000",
1849
+ ETag: etag(data.toString()),
1850
+ Date: (/* @__PURE__ */ new Date()).toUTCString()
1851
+ }
1852
+ });
1853
+ } catch (err) {
1854
+ console.error("Could not process image request:", err);
1855
+ return new Response(
1856
+ `Internal Server Error`,
1857
+ {
1858
+ status: 500
1859
+ }
1860
+ );
1861
+ }
1862
+ };
1863
+
1864
+ export { GET };