{"version":3,"file":"QuoteAddButton.CUzc0-ey.mjs","names":["useState","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","_e","init_jsx_runtime","c","p","ce","window","addPropertyControls","init_framer_DymZktPS","ControlType","Link","readCart","parsed","CART_KEY","writeCart","items","CART_EVENT","useCart","setItems","sync","slugFromPartNumber","partNumber","cutCorners","px","AddToQuote","props","id","inCart","i","qty","setQty","draft","setDraft","added","setAdded","hover","setHover","t","large","size","height","cut","setQuantity","clamped","MAX_QTY","next","add","amount","cart","existing","title","spec","slug","stepButton","darkColor","MONO","dark","buttonStyle","accentColor","DISPLAY","style","borderColor","addedLabel","label","mutedColor","QUOTE_PAGE_ID","init_QuoteAddButton"],"sources":["https:/framerusercontent.com/modules/IzKcWjc2vNBvUrnvLRyO/ksa11fz6kwjl1PpDr8xk/QuoteAddButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType,Link}from\"framer\";// Framer page id of /quote. Linking by page id keeps navigation inside the\n// Framer router, so it works in preview as well as on the published site.\nconst QUOTE_PAGE_ID=\"cjXH2sOwj\";// Quote cart storage contract. Shared by QuoteAddButton, QuoteCartButton,\n// QuoteCartList, QuoteCartFields and QuoteConfigurator: keep the key, the\n// event name and the CartItem shape identical in every file.\nconst CART_KEY=\"igp-quote-cart-v1\";const CART_EVENT=\"igp-quote-cart\";function readCart(){if(typeof window===\"undefined\")return[];try{const parsed=JSON.parse(window.localStorage.getItem(CART_KEY)||\"[]\");return Array.isArray(parsed)?parsed:[];}catch{return[];}}function writeCart(items){try{window.localStorage.setItem(CART_KEY,JSON.stringify(items));}catch{// Private mode or full storage: the event still updates open views.\n}window.dispatchEvent(new Event(CART_EVENT));}function useCart(){const[items,setItems]=useState([]);useEffect(()=>{const sync=()=>setItems(readCart());sync();window.addEventListener(CART_EVENT,sync);window.addEventListener(\"storage\",sync);return()=>{window.removeEventListener(CART_EVENT,sync);window.removeEventListener(\"storage\",sync);};},[]);return items;}const MONO='\"IBM Plex Mono\", ui-monospace, monospace';const DISPLAY='\"Bebas Neue\", \"Arial Narrow\", sans-serif';const MAX_QTY=9999;/** CMS slugs are the part number without the PRT- prefix, lowercased, dots as dashes. */function slugFromPartNumber(partNumber){return partNumber.toLowerCase().replace(/^prt-/,\"\").replace(/\\./g,\"-\");}function cutCorners(px){return`polygon(${px}px 0, 100% 0, 100% calc(100% - ${px}px), calc(100% - ${px}px) 100%, 0 100%, 0 ${px}px)`;}/**\n * Quantity stepper and \"Add to quote\" button for one catalog part.\n * Adds to the shared quote cart; adding a part that is already there\n * raises its quantity.\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 72\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function AddToQuote(props){const{partNumber=\"\",title=\"\",spec=\"\",slug=\"\",size=\"compact\",label=\"Add to quote\",addedLabel=\"Added\",accentColor=\"rgb(250, 183, 2)\",darkColor=\"rgb(7, 8, 8)\",borderColor=\"rgba(7, 8, 8, 0.15)\",mutedColor=\"rgba(7, 8, 8, 0.6)\",style}=props;const items=useCart();const id=partNumber.trim();const inCart=id?items.find(i=>i.id===id):undefined;const[qty,setQty]=useState(1);const[draft,setDraft]=useState(\"1\");const[added,setAdded]=useState(false);const[hover,setHover]=useState(false);useEffect(()=>{if(!added)return;const t=window.setTimeout(()=>setAdded(false),1800);return()=>window.clearTimeout(t);},[added]);const large=size===\"large\";const height=large?52:44;const cut=large?16:14;function setQuantity(next){const clamped=Math.min(MAX_QTY,Math.max(1,Math.round(next)||1));setQty(clamped);setDraft(String(clamped));}function add(){if(!id)return;// Read the typed value directly: the input's blur commit may not have rendered yet.\nconst amount=Math.min(MAX_QTY,Math.max(1,Math.round(Number(draft))||qty));const cart=readCart();const existing=cart.find(i=>i.id===id);if(existing){existing.qty=Math.min(MAX_QTY,existing.qty+amount);}else{cart.push({id,partNumber:id,title:title||id,spec:spec||undefined,slug:slug||slugFromPartNumber(id),qty:amount});}writeCart(cart);setAdded(true);setQuantity(1);}const stepButton={width:large?44:38,height:\"100%\",border:\"none\",background:\"transparent\",color:darkColor,cursor:\"pointer\",fontFamily:MONO,fontSize:18,lineHeight:1,padding:0};const dark=added||hover;const buttonStyle={flex:\"1 1 auto\",minWidth:large?200:140,height,border:\"none\",padding:`0 ${cut+10}px`,clipPath:cutCorners(cut),background:dark?darkColor:accentColor,color:dark?accentColor:darkColor,cursor:id?\"pointer\":\"not-allowed\",opacity:id?1:.5,fontFamily:DISPLAY,fontSize:large?24:20,lineHeight:1,letterSpacing:\"0.01em\",textTransform:\"uppercase\",whiteSpace:\"nowrap\",transition:\"background 0.2s ease, color 0.2s ease\"};return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"stretch\",gap:8,width:\"100%\",...style},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",gap:8,width:\"100%\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",flex:\"0 0 auto\",height,boxSizing:\"border-box\",border:`1px solid ${borderColor}`,background:\"#ffffff\"},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Decrease quantity\",onClick:()=>setQuantity(qty-1),style:stepButton,children:\"−\"}),/*#__PURE__*/_jsx(\"input\",{type:\"text\",inputMode:\"numeric\",\"aria-label\":`Quantity for ${id||\"part\"}`,value:draft,onChange:e=>setDraft(e.target.value.replace(/[^0-9]/g,\"\")),onBlur:()=>setQuantity(Number(draft)),onKeyDown:e=>{if(e.key===\"Enter\"){e.preventDefault();setQuantity(Number(draft));}},style:{width:large?56:44,height:\"100%\",border:\"none\",borderLeft:`1px solid ${borderColor}`,borderRight:`1px solid ${borderColor}`,background:\"transparent\",color:darkColor,textAlign:\"center\",fontFamily:MONO,fontSize:14,fontWeight:500,padding:0,outline:\"none\"}}),/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":\"Increase quantity\",onClick:()=>setQuantity(qty+1),style:stepButton,children:\"+\"})]}),/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:add,onMouseEnter:()=>setHover(true),onMouseLeave:()=>setHover(false),disabled:!id,style:buttonStyle,children:added?`${addedLabel} ✓`:label})]}),inCart&&/*#__PURE__*/_jsxs(\"div\",{\"aria-live\":\"polite\",style:{display:\"flex\",alignItems:\"center\",gap:8,fontFamily:MONO,fontSize:12,fontWeight:500,letterSpacing:\"0.04em\",textTransform:\"uppercase\",lineHeight:1.4,color:mutedColor},children:[/*#__PURE__*/_jsx(\"span\",{style:{width:8,height:8,flex:\"0 0 auto\",background:accentColor}}),/*#__PURE__*/_jsxs(\"span\",{children:[\"In your quote: \",inCart.qty,\" pcs\"]}),large&&/*#__PURE__*/_jsx(Link,{href:{webPageId:QUOTE_PAGE_ID},openInNewTab:false,children:/*#__PURE__*/_jsx(\"a\",{style:{marginLeft:\"auto\",color:darkColor,textDecoration:\"underline\",textUnderlineOffset:3},children:\"Review quote →\"})})]})]});}addPropertyControls(AddToQuote,{partNumber:{type:ControlType.String,title:\"Part #\",defaultValue:\"\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"\"},spec:{type:ControlType.String,title:\"Spec\",defaultValue:\"\"},slug:{type:ControlType.String,title:\"Slug\",defaultValue:\"\"},size:{type:ControlType.Enum,title:\"Size\",options:[\"compact\",\"large\"],optionTitles:[\"Compact\",\"Large\"],defaultValue:\"compact\",displaySegmentedControl:true},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Add to quote\"},addedLabel:{type:ControlType.String,title:\"Added\",defaultValue:\"Added\"},accentColor:{type:ControlType.Color,title:\"Accent\",defaultValue:\"rgb(250, 183, 2)\"},darkColor:{type:ControlType.Color,title:\"Dark\",defaultValue:\"rgb(7, 8, 8)\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"rgba(7, 8, 8, 0.15)\"},mutedColor:{type:ControlType.Color,title:\"Muted\",defaultValue:\"rgba(7, 8, 8, 0.6)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AddToQuote\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"72\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./QuoteAddButton.map"],"mappings":"A,6MAKqE,SAASc,GAAU,CAAC,GAAUL,IAAS,OAAY,MAAM,CAAC,EAAE,GAAG,CAAC,IAAMM,EAAO,KAAK,MAAMN,EAAO,aAAa,QAAQO,CAAQ,GAAG,IAAI,EAAE,OAAO,MAAM,QAAQD,CAAM,EAAEA,EAAO,CAAC,CAAE,MAAM,CAAC,MAAM,CAAC,CAAE,CAAC,CAAC,SAASE,EAAU,EAAM,CAAC,GAAG,CAACR,EAAO,aAAa,QAAQO,EAAS,KAAK,UAAUE,CAAK,CAAC,CAAE,MAAM,CACnW,CAACT,EAAO,cAAc,IAAI,MAAMU,CAAU,CAAC,CAAE,CAAC,SAASC,GAAS,CAAC,GAAK,CAACF,EAAMG,GAAUrB,EAAS,CAAC,CAAC,EAAuP,OAArPQ,MAAc,CAAC,IAAMc,MAASD,EAASP,EAAS,CAAC,EAA0F,OAAxFQ,EAAK,EAAEb,EAAO,iBAAiBU,EAAWG,CAAI,EAAEb,EAAO,iBAAiB,UAAUa,CAAI,MAAY,CAACb,EAAO,oBAAoBU,EAAWG,CAAI,EAAEb,EAAO,oBAAoB,UAAUa,CAAI,CAAE,CAAE,EAAE,CAAC,CAAC,EAASJ,CAAM,CAA4N,SAASK,EAAmB,EAAW,CAAC,OAAOC,EAAW,YAAY,CAAC,CAAC,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,MAAM,GAAG,CAAE,CAAC,SAASC,EAAW,EAAG,CAAC,MAAM,WAAWC,EAA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