{"version":3,"file":"ProductTileSearchResults.B1lFw13i.min.js","sources":["../frontend/src/stories/client/ProductTileSearch/ProductTileSearchResults.tsx"],"sourcesContent":["import React, {useEffect, useState} from \"react\";\nimport helpers from \"../../../../js/helpers\";\nimport useMobileBreakpoint from \"@mindarc/arctheme-components/frontend/src/hooks/useMobileBreakpoint\";\n\nexport const ProductTileSearchResults = ({\n product,\n swatches = [],\n siblings,\n show_add = false,\n show_price_inline = false,\n settings,\n enableWishlist,\n type = ''\n }) => {\n const isMobile = useMobileBreakpoint(\"1024px\");\n const currencyCode = window.Alpine?.store('currency').getCurrencyCode();\n const currencySymbol = window.Alpine?.store('currency').getCurrencySymbol();\n\n // Helper function to get price by currency code\n const getPriceByCurrency = (priceRanges, currency) => {\n const priceEntry = priceRanges?.find((item) => item.currency_code === currency);\n return priceEntry?.amount || 0; // Convert to proper price format\n };\n\n // Default prices from compare_at_price and price\n let minPrice = product?.price > 0 ? product?.price / 100 : 0;\n let maxPrice = product?.compare_at_price > 0 ? product?.compare_at_price / 100 : 0;\n\n // If presentment_price_ranges exist, extract prices for the current currency\n if (product?.presentment_price_ranges) {\n const presentmentMinPrice = getPriceByCurrency(product?.presentment_price_ranges?.min_variant_price, currencyCode);\n const presentmentMaxPrice = getPriceByCurrency(product?.presentment_price_ranges?.max_variant_price, currencyCode);\n\n // Use presentment prices only if they are available\n minPrice = presentmentMinPrice ?? minPrice;\n maxPrice = presentmentMaxPrice ?? maxPrice;\n }\n // Ensure that compare_at_price is treated as a \"strike-through price\" if higher\n const isOnSale = minPrice > 0 && minPrice < maxPrice;\n\n return (\n <>\n \n
\n
\n \n
\n
\n
\n \n {product.title}\n
\n
\n
\n {isOnSale ? (\n <>\n Special Price\n
\n {currencyCode} {currencySymbol}{minPrice.toFixed(0)}\n
\n \n ) : (\n <>\n Regular Price\n
\n {currencyCode} {currencySymbol}{minPrice.toFixed(0)}\n
\n \n )}\n
\n
\n
\n {swatches.map((swatch) => (\n \n ))}\n
\n
\n {show_add && (\n {\n }}\n >\n Add to Cart\n \n )}\n {enableWishlist && (\n {\n }}\n >\n Add to Wishlist\n \n )}\n
\n
\n
\n \n
\n \n );\n};\n"],"names":["ProductTileSearchResults","product","swatches","siblings","show_add","show_price_inline","settings","enableWishlist","type","useMobileBreakpoint","currencyCode","_a","currencySymbol","_b","getPriceByCurrency","priceRanges","currency","priceEntry","item","minPrice","maxPrice","presentmentMinPrice","_c","presentmentMaxPrice","_d","isOnSale","jsx","Fragment","jsxs","swatch"],"mappings":"0QAIO,MAAMA,EAA2B,CAAC,CACT,QAAAC,EACA,SAAAC,EAAW,CAAC,EACZ,SAAAC,EACA,SAAAC,EAAW,GACX,kBAAAC,EAAoB,GACpB,SAAAC,EACA,eAAAC,EACA,KAAAC,EAAO,EACX,IAAM,aACbC,EAAoB,QAAQ,EAC7C,MAAMC,GAAgBC,EAAA,OAAO,SAAP,YAAAA,EAAe,MAAM,YAAY,kBACjDC,GAAkBC,EAAA,OAAO,SAAP,YAAAA,EAAe,MAAM,YAAY,oBAGnDC,EAAqB,CAACC,EAAaC,IAAa,CAClD,MAAMC,EAAaF,GAAA,YAAAA,EAAa,KAAMG,GAASA,EAAK,gBAAkBF,GACtE,OAAOC,GAAA,YAAAA,EAAY,SAAU,CAAA,EAIjC,IAAIE,GAAWlB,GAAA,YAAAA,EAAS,OAAQ,GAAIA,GAAA,YAAAA,EAAS,OAAQ,IAAM,EACvDmB,GAAWnB,GAAA,YAAAA,EAAS,kBAAmB,GAAIA,GAAA,YAAAA,EAAS,kBAAmB,IAAM,EAGjF,GAAIA,GAAA,MAAAA,EAAS,yBAA0B,CACnC,MAAMoB,EAAsBP,GAAmBQ,EAAArB,GAAA,YAAAA,EAAS,2BAAT,YAAAqB,EAAmC,kBAAmBZ,CAAY,EAC3Ga,EAAsBT,GAAmBU,EAAAvB,GAAA,YAAAA,EAAS,2BAAT,YAAAuB,EAAmC,kBAAmBd,CAAY,EAGjHS,EAAWE,GAAuBF,EAClCC,EAAWG,GAAu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