{"version":3,"file":"AddToKitList.DC8_c7Ho.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/BUTnQTTsUYu4R0qzQzMz/nuoWvVGcRFaSM6yAZNu8/AddToKitList.js"],"sourcesContent":["// \"Add to Kit List\" — goes on tiles, the item page and Rate Card rows (spec §4.1, §6).\n//\n// Framer: Assets > Code > New file, paste. Drop it on the Equipment CMS page and bind the\n// four props to the collection fields. It writes localStorage; the header's <KitList /> picks\n// the change up immediately through the shared subscription.\n//\n// Verbs are fixed (§4.1): \"Add to Kit List\", never Cart / Basket / Checkout.\n// Brand system v2 §6 Buttons: Add (tile) = small secondary, 30px, \"Add\"; after click \"Added\"\n// for 1.2s. Button (item page) = primary, 48px, full width. Toast = Graphite, bottom-left.\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{createPortal}from\"react-dom\";import{addPropertyControls,ControlType}from\"framer\";import{addLine,loadLines,removeLine,subscribe}from\"https://framerusercontent.com/modules/63duGyOXCgUlaPENpqTR/obBhtuCWVBT4PIlkq67w/kit-list.js\";import{colour,focusRingLight,font,labelMono,motion,radius,showFocusRing}from\"https://framerusercontent.com/modules/yG9gp6meCLV2xzqACEat/lENFKffrvr2h5MKUW9vx/theme.js\";const TOAST_MS=4e3;const ADDED_MS=1200;export default function AddToKitList({rentmanId=0,name=\"\",slug=\"\",dayRate=0,image,imageUrl=\"\",label=\"Add to Kit List\",compact=false,variant=\"button\",width}){const[toastOpen,setToastOpen]=useState(false);const[inList,setInList]=useState(false);const[hover,setHover]=useState(false);const[justAdded,setJustAdded]=useState(false);// Reflect the list on mount and whenever it changes elsewhere (another card, the drawer,\n// another tab). Reading in an effect keeps the first server render stable.\nuseEffect(()=>{const sync=()=>setInList(loadLines().some(l=>l.rentmanId===rentmanId));sync();return subscribe(sync);},[rentmanId]);useEffect(()=>{if(!toastOpen)return;const timer=setTimeout(()=>setToastOpen(false),TOAST_MS);return()=>clearTimeout(timer);},[toastOpen]);useEffect(()=>{if(!justAdded)return;const timer=setTimeout(()=>setJustAdded(false),ADDED_MS);return()=>clearTimeout(timer);},[justAdded]);// A CMS row that hasn't loaded yet, or a badly bound prop, must not write a junk line.\nconst usable=Number.isInteger(rentmanId)&&rentmanId>0&&name.trim()!==\"\";// Tiles and Rate Card rows are links to the item page; the button must not follow them.\nconst handleAdd=event=>{event.preventDefault();event.stopPropagation();if(!usable)return;// A toggle: once the item is on the list, the button takes it back off.\nif(inList){removeLine(rentmanId);return;}const item={rentmanId,name,slug,dayRate,imageUrl:image?.src||imageUrl};addLine(item);setJustAdded(true);if(!compact)setToastOpen(true);};const reduced=typeof window!==\"undefined\"&&window.matchMedia?.(motion.reduced).matches;const fade=reduced?\"none\":`background ${motion.t}ms ${motion.ease}, color ${motion.t}ms ${motion.ease}, border-color ${motion.t}ms ${motion.ease}`;const lit=hover&&usable;const style=variant===\"icon\"?{width:44,height:44,padding:0,display:\"grid\",placeItems:\"center\",color:lit||inList?colour.recordBlack:colour.casetteWhite,background:lit||inList?colour.houseLimeGreen:colour.recordBlack,border:\"none\",borderRadius:radius,transition:fade}:variant===\"add\"?{height:30,padding:\"0 12px\",...labelMono,fontSize:11,letterSpacing:\"0.06em\",color:lit||inList?colour.casetteWhite:colour.recordBlack,background:lit||inList?colour.recordBlack:\"transparent\",border:`1px solid ${lit||inList?colour.recordBlack:colour.tornGray}`,borderRadius:radius,transition:fade}:{width:width??\"100%\",height:48,padding:\"0 16px\",...labelMono,color:lit?colour.recordBlack:inList?colour.casetteWhite:colour.casetteWhite,background:lit?colour.houseLimeGreen:inList?colour.houseDarkGreen:colour.recordBlack,border:`1px solid ${lit?colour.houseLimeGreen:inList?colour.houseDarkGreen:colour.recordBlack}`,borderRadius:radius,transition:fade};const text=variant===\"add\"?justAdded?\"Added\":inList?\"Remove\":\"Add\":inList?\"Added. Remove from Kit List\":label;return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:handleAdd,disabled:!usable,// The icon has no visible words, so the verb (§4.1) lives in the accessible name.\n\"aria-label\":variant===\"icon\"?inList?`Remove ${name} from Kit List`:`${label}: ${name}`:variant===\"add\"?`${text} ${name}`:undefined,onMouseEnter:()=>setHover(true),onMouseLeave:()=>setHover(false),style:{...style,cursor:usable?\"pointer\":\"default\",opacity:usable?1:.4,whiteSpace:\"nowrap\"},onFocus:e=>showFocusRing(e.currentTarget,focusRingLight),onBlur:e=>Object.assign(e.currentTarget.style,{outline:\"none\"}),children:variant===\"icon\"?/*#__PURE__*/_jsx(\"svg\",{width:\"14\",height:\"14\",viewBox:\"0 0 16 16\",\"aria-hidden\":\"true\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"1.4\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:inList?/*#__PURE__*/_jsx(\"path\",{d:\"M3 8.5l3.2 3L13 4.5\"}):/*#__PURE__*/_jsx(\"path\",{d:\"M8 3v10M3 8h10\"})}):text}),toastOpen&&typeof document!==\"undefined\"&&/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs(\"div\",{// Polite, not assertive: adding kit is not an interruption.\nrole:\"status\",\"aria-live\":\"polite\",className:\"fomo-toast\",style:{position:\"fixed\",bottom:24,left:24,zIndex:9e3,display:\"flex\",alignItems:\"center\",gap:16,padding:\"12px 16px\",fontFamily:font.body,fontSize:14,lineHeight:1.5,color:colour.casetteWhite,background:colour.graphite,borderRadius:radius,maxWidth:\"calc(100vw - 32px)\",animation:reduced?\"none\":`fomo-toast-in ${motion.t}ms ${motion.ease}`},children:[/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:`@keyframes fomo-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } } @media (max-width: 699px) { .fomo-toast { left: 16px !important; right: 16px; bottom: 80px !important; } }`}}),/*#__PURE__*/_jsx(\"span\",{children:\"Added to your Kit List.\"}),/*#__PURE__*/_jsx(\"a\",{href:\"/kit-list\",style:{color:colour.casetteWhite,textDecoration:\"underline\",textDecorationColor:colour.casetteWhite,textUnderlineOffset:3,whiteSpace:\"nowrap\"},children:\"View Kit List\"})]}),document.body)]});}addPropertyControls(AddToKitList,{rentmanId:{type:ControlType.Number,title:\"Rentman ID\",displayStepper:false},name:{type:ControlType.String,title:\"Name\"},slug:{type:ControlType.String,title:\"Slug\"},dayRate:{type:ControlType.Number,title:\"Day rate\",displayStepper:false},image:{type:ControlType.ResponsiveImage,title:\"Image\"},imageUrl:{type:ControlType.String,title:\"Image URL\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Add to Kit List\"},variant:{type:ControlType.Enum,title:\"Style\",options:[\"button\",\"add\",\"icon\"],optionTitles:[\"Button (item page)\",\"Add (tile)\",\"Icon (+)\"],defaultValue:\"button\"},compact:{type:ControlType.Boolean,title:\"Compact\",description:\"No toast. Use on Rate Card rows\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AddToKitList\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"iXAS2iB,SAAwB,EAAa,CAAC,YAAU,EAAE,OAAK,GAAG,OAAK,GAAG,UAAQ,EAAE,QAAM,WAAS,GAAG,QAAM,kBAAkB,UAAQ,GAAM,UAAQ,SAAS,SAAO,CAAC,GAAK,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAO,CAAC,EAAO,GAAWA,EAAS,EAAK,EAAO,CAAC,EAAM,GAAUA,EAAS,EAAK,EAAO,CAAC,EAAU,GAAcA,EAAS,EAAK,EAEh3B,MAAc,CAAC,IAAM,MAAS,EAAU,EAAU,CAAC,CAAC,KAAK,GAAG,EAAE,YAAY,CAAS,CAAC,EAAS,OAAP,EAAK,EAAS,EAAU,CAAI,CAAE,EAAE,CAAC,CAAS,CAAC,EAAE,MAAc,CAAC,GAAG,CAAC,EAAU,OAAO,IAAM,EAAM,eAA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