{"version":3,"file":"Create_PriceFrom.GbhAXqVC.mjs","names":["useState","priceFromText","salePriceFromText"],"sources":["https:/framerusercontent.com/modules/vff7OHgjTEdEwS7A4HNF/iKxfqJIvfGmqHDOSO3qs/useDiscountBannerUtils.js","https:/framerusercontent.com/modules/gj53OHS8Kkjda7Vpd49J/6wI4hxH0SNDwgZJyPZ1r/Create_PriceFrom.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";const STORAGE_KEY=\"BG_Landing\";const STORAGE_DAYS=7;export function bestGiftActiveNotGiftJoy(){let showBestGift=false;try{// Check URL:\nconst isBestGiftPage=(window?.location?.href||\"\").toLowerCase().indexOf(\"bestgift\")>=0;if(isBestGiftPage){showBestGift=true;const nowTs=new Date().getTime();sessionStorage.setItem(STORAGE_KEY,`${nowTs}`);// localStorage.setItem(STORAGE_KEY, `${nowTs}`)\n}else{// Check Session:\nconst sessionValue=sessionStorage.getItem(STORAGE_KEY);if(sessionValue){showBestGift=true;}else{// Check Longer Term local storage\nconst localValue=localStorage.getItem(STORAGE_KEY);if(localValue){const localValueTs=Number.parseInt(localValue,10);const nowTs=new Date().getTime();const xDaysAgo=nowTs-STORAGE_DAYS*24*60*60*1e3;if(localValueTs>xDaysAgo){showBestGift=true;sessionStorage.setItem(STORAGE_KEY,localValue);}else{// Tidy Up\nlocalStorage.removeItem(STORAGE_KEY);}}}}}catch(e){console.error(`ERROR: Discount`,e);}return showBestGift;}export function showIfBestGift(Component){return props=>{let show=bestGiftActiveNotGiftJoy();return show?/*#__PURE__*/_jsx(Component,{...props}):null;// return show ? <Component {...props} /> : <Component {...props} style={{ ...props.style, display: \"none\" }} />\n};}export function showIfGiftJoy(Component){return props=>{let show=bestGiftActiveNotGiftJoy();return show?null:/*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"showIfGiftJoy\":{\"type\":\"reactHoc\",\"name\":\"showIfGiftJoy\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showIfBestGift\":{\"type\":\"reactHoc\",\"name\":\"showIfBestGift\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"bestGiftActiveNotGiftJoy\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./useDiscountBannerUtils.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{getStarMapJewelrySku}from\"https://framerusercontent.com/modules/KYsdNQQbOOPfSKUhrJi1/dGQMzt7E45c5ph0pOn44/utils_JewelrySku.js\";import{store_ProductPropsStore}from\"https://framerusercontent.com/modules/XlGHH84z4WYiDTmjfihj/H9dDHPYLn0I2rSxRNRXf/store_ProductPropsStore.js\";import{store_ProductPrices}from\"https://framerusercontent.com/modules/sntb8dU0GIjuRMyT5z3F/l8SNYDLAxhtHuWMwKNqY/store_ProductPrices.js\";import{getPriceText,getSalePriceText}from\"https://framerusercontent.com/modules/P71mmonnzSYySBCAYaxg/zUuT9PXtfk0abnyLm8Fz/utils_ProductPrices.js\";import{getTnsProps}from\"https://framerusercontent.com/modules/f5MemFRu7KXGzetUeQ0m/qPO7O3BJtMJXx5q2CSra/utils_TnsProps.js\";import{bestGiftActiveNotGiftJoy}from\"https://framerusercontent.com/modules/vff7OHgjTEdEwS7A4HNF/iKxfqJIvfGmqHDOSO3qs/useDiscountBannerUtils.js\";export default function Create_PriceFrom({jewelryOverrideSku,showDiscountedPrice}){const[priceFromText,setPriceFromText]=useState(\"\");const[salePriceFromText,setSalePriceFromText]=useState(\"\");const[pricesObj,setPricesObj]=store_ProductPrices();const[store,setStore]=store_ProductPropsStore();useEffect(()=>{if(!pricesObj||!pricesObj.pricing||!pricesObj.countryCode||pricesObj.countryCode===\"\"){return;}const{pricing}=pricesObj;// Get sale price\nlet discountPercent=0;if(showDiscountedPrice===true){discountPercent=15;if(store.productFormat===\"Jewelry\"){if(bestGiftActiveNotGiftJoy()&&[\"Black Onyx\",\"Green Onyx\"].includes(store.jewelryMaterial)){discountPercent=30;}else{discountPercent=20;}}}/**\n         * If we have an override SKU for jewelry, use that not props\n         */if(jewelryOverrideSku){let priceFromText=\"\";let salePriceFromText=\"\";let price=Object.values(pricing.jewelry.NIGHT_SKY).find(x=>x.sku===jewelryOverrideSku);if(!price){price=Object.values(pricing.jewelry.MOMENTS).find(x=>x.sku===jewelryOverrideSku);}if(price?.customer){if(price.customer.gross>0){priceFromText=getPriceText(price);salePriceFromText=getSalePriceText(price,discountPercent);}}setPriceFromText(priceFromText);setSalePriceFromText(salePriceFromText);return;}// ////////////\n// GET PRICE \"FROM\"...\nlet priceFrom=\"\";let salePriceFrom=\"\";let lowestPrice=-1;if(store.productFormat===\"Jewelry\"){if(pricing.jewelry&&pricing.jewelry.NIGHT_SKY){const priceObj=pricing.jewelry.NIGHT_SKY;// Format, Piece, Material and Bezel Mount are locked in... but we can iterate on jewelrySize\n// and jewelryChain\nlet availableSizes=[\"25mm\",\"20mm\",\"15mm\"];let jewelryChains=[\"Black Cord\",\"Sterling Silver\",\"18k Gold Vermeil\",\"9k Solid Gold\",\"No Mount\"];// We can filter out some options here:\nif(store.jewelryPiece===\"Locket\"){availableSizes=[\"25mm\",\"20mm\"];jewelryChains=[\"Sterling Silver\",\"18k Gold Vermeil\"];}Object.values(availableSizes).forEach(size=>{Object.values(jewelryChains).forEach(chain=>{const tnsSku=getStarMapJewelrySku(store.productFormat,store.jewelryPiece,store.jewelryMaterial,size,store.jewelryBezelMount,chain);let price=Object.values(pricing.jewelry.NIGHT_SKY).find(x=>x.sku===tnsSku);if(!price){price=Object.values(pricing.jewelry.MOMENTS).find(x=>x.sku===tnsSku);}if(price?.customer){if(lowestPrice===-1||price.customer.gross>0&&price.customer.gross<lowestPrice){lowestPrice=price.customer.gross;priceFrom=getPriceText(price);salePriceFrom=getSalePriceText(price,discountPercent);}}});});}}else if(store.productFormat===\"Print\"){let availableSizesLayouts=[{printLayout:\"Square\",printSize:\"12x12\"},{printLayout:\"Square\",printSize:\"16x16\"},// don't bother with largest\n// { printLayout: \"Square\", printSize: \"20x20\" },\n{printLayout:\"Portrait\",printSize:\"12x16\"},{printLayout:\"Portrait\",printSize:\"18x24\"}];Object.values(availableSizesLayouts).forEach(item=>{const tnsProps=getTnsProps({...store,printLayout:item.printLayout,printSize:item.printSize,printFrame:\"None\"});const{orientation,productFormat}=tnsProps;if(pricing[orientation]&&pricing[orientation][tnsProps.sizeId]){const itemPrice=pricing[orientation][tnsProps.sizeId];if(itemPrice&&itemPrice[productFormat]){const price=itemPrice[productFormat];if(price?.customer){if(lowestPrice===-1||price.customer.gross>0&&price.customer.gross<lowestPrice){lowestPrice=price.customer.gross;priceFrom=getPriceText(price);salePriceFrom=getSalePriceText(price,discountPercent);}}}}});}if(lowestPrice>-1&&priceFrom){setPriceFromText(priceFrom);setSalePriceFromText(salePriceFrom);}},[pricesObj,store,pricesObj.pricing,pricesObj.countryCode,jewelryOverrideSku]);if(showDiscountedPrice&&salePriceFromText){return /*#__PURE__*/_jsxs(\"p\",{style:{...styleText},children:[\"From \",/*#__PURE__*/_jsx(\"span\",{style:strikeThroughPrice,children:priceFromText}),\"\\xa0\",salePriceFromText]});}else{return /*#__PURE__*/_jsxs(\"p\",{style:{...styleText},children:[\"From \",priceFromText]});}}// /////////////////////////////////////////////////////////////////\n// STYLES\n// /////////////\nCreate_PriceFrom.defaultProps={jewelryOverrideSku:\"\",showDiscountedPrice:true};addPropertyControls(Create_PriceFrom,{jewelryOverrideSku:{type:ControlType.String,defaultValue:\"\"},showDiscountedPrice:{type:ControlType.Boolean,defaultValue:true}});// /////////////////////////////////////////////////////////////////\n// STYLES\n// /////////////\nconst styleText={width:\"auto\",height:\"auto\",boxSizing:\"border-box\",outline:\"none\",flex:\"none\",display:\"inline\",// display: \"flex\",\n// flexDirection: \"column\",\n// justifyContent: \"flex-start\",\n// flexShrink: 0,\nfontFamily:'\"Inter\", \"Inter Placeholder\", sans-serif',fontSize:\"14px\",fontWeight:400,// color: \"rgb(10, 14, 21)\",\ncolor:\"#121824\",textAlign:\"left\",userSelect:\"none\",whiteSpace:\"pre\",WebkitFontSmoothing:\"inherit\",margin:\"0px\",padding:\"0px\",letterSpacing:\"0px\",textDecoration:\"none\",lineHeight:\"1.4em\"};const strikeThroughPrice={textDecoration:\"line-through\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Create_PriceFrom\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Create_PriceFrom.map"],"mappings":"ktBAA+F,SAAgB,GAA0B,CAAC,IAAI,EAAa,GAAM,GAAG,CAC7E,IAAjE,GAAQ,UAAU,MAAM,IAAI,aAAa,CAAC,QAAQ,WAAW,EAAE,EAAoB,CAAC,EAAa,GAAK,IAAM,EAAM,IAAI,MAAM,CAAC,SAAS,CAAC,eAAe,QAAQ,EAAY,GAAG,IAAQ,SAExL,eAAe,QAAQ,EAAY,CAAkB,EAAa,OAAU,CAC/F,IAAM,EAAW,aAAa,QAAQ,EAAY,CAAC,GAAG,EAAW,CAAC,IAAM,EAAa,OAAO,SAAS,EAAW,GAAG,CAAwC,EAA3B,IAAI,MAAM,CAAC,SAAS,CAAsB,EAAa,GAAG,GAAG,GAAG,IAAO,EAAa,GAAU,EAAa,GAAK,eAAe,QAAQ,EAAY,EAAW,EAC9R,aAAa,WAAW,EAAY,SAAY,EAAE,CAAC,QAAQ,MAAM,kBAAkB,EAAE,CAAE,OAAO,2BALnD,CAAM,EAAY,aAAmB,EAAa,KCAi3B,SAAwB,EAAiB,CAAC,qBAAmB,uBAAqB,CAAC,GAAK,CAAC,EAAc,GAAkBA,EAAS,GAAG,CAAM,CAAC,EAAkB,GAAsBA,EAAS,GAAG,CAAM,CAAC,EAAU,GAAc,GAAqB,CAAM,CAAC,EAAM,GAAU,GAAyB,CAU7J,O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