{"version":3,"file":"Create_PriceFrom.RKy1FFtV.mjs","names":["priceFromText","salePriceFromText"],"sources":["https:/framerusercontent.com/modules/vff7OHgjTEdEwS7A4HNF/avPE5PZDVQgJioFxA0kR/UseDiscountBannerUtils.js","https:/framerusercontent.com/modules/gj53OHS8Kkjda7Vpd49J/im2aThE6TwM17wYKKHmb/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{var _window_location,_window;// Check URL:\nconst isBestGiftPage=(((_window=window)===null||_window===void 0?void 0:(_window_location=_window.location)===null||_window_location===void 0?void 0:_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\"}},\"bestGiftActiveNotGiftJoy\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showIfBestGift\":{\"type\":\"reactHoc\",\"name\":\"showIfBestGift\",\"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/mfxQaC31OTaxgWKW3Yph/utils_JewelrySku.js\";import{store_ProductPropsStore}from\"https://framerusercontent.com/modules/XlGHH84z4WYiDTmjfihj/4VVkelJuPMA6zxPlnEsO/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/lkqLkMbQ8U9agsNRbEOG/utils_ProductPrices.js\";import{getTnsProps}from\"https://framerusercontent.com/modules/f5MemFRu7KXGzetUeQ0m/pgAdXPHqp1CXuCKllwDM/utils_TnsProps.js\";import{bestGiftActiveNotGiftJoy}from\"https://framerusercontent.com/modules/vff7OHgjTEdEwS7A4HNF/avPE5PZDVQgJioFxA0kR/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\"}}}"],"mappings":"ktBAA+F,SAAgB,GAA0B,CAAC,IAAI,GAAa,EAAM,GAAG,CAAC,IAAI,EAAiB,EAC1L,IAAM,EAAe,GAAG,EAAQ,IAAU,SAA4B,IAAG,EAAiB,EAAQ,WAAoE,OAAO,IAAI,aAAa,CAAC,QAAQ,WAAW,EAAE,EAAE,GAAG,EAAe,CAAC,GAAa,EAAK,IAAM,EAAM,IAAI,OAAO,SAAS,CAAC,eAAe,QAAQ,KAAe,IAAQ,AACzU,KAAI,CACL,IAAM,EAAa,eAAe,QAAQ,EAAY,CAAC,GAAG,EAAc,GAAa,MAAU,CAC/F,IAAM,EAAW,aAAa,QAAQ,EAAY,CAAC,GAAG,EAAW,CAAC,IAAM,EAAa,OAAO,SAAS,EAAW,GAAG,CAAO,EAAM,IAAI,OAAO,SAAS,CAAO,EAAS,EAAM,EAAa,GAAG,GAAG,GAAG,IAAI,AAAG,EAAa,GAAU,GAAa,EAAK,eAAe,QAAQ,EAAY,EAAW,EAC9R,aAAa,WAAW,EAAY,AAAG,CAAC,CAAC,CAAC,OAAM,EAAE,CAAC,QAAQ,MAAA,kBAAwB,EAAE,AAAE,QAAO,CAAc,kBAL5B,IAAhF,GAA2C,CAAM,EAAY,aAAmB,EAAa,ICAi3B,SAAwB,EAAiB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