{"version":3,"file":"LazyImage.BoBNQ9YV.mjs","names":["React.useState","React.useRef","u"],"sources":["https:/framerusercontent.com/modules/wpD64Ge7LqIVOei3a6Bf/BMI9eb8qI4whX55wIhMB/LazyImage.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function LazyImage({src,alt,width=\"100%\",height=\"100%\",style,eager=false,fetchPriority=\"auto\",showOverlay=false,fallbackToSrc=true}){const[isLoaded,setIsLoaded]=React.useState(false);const[finalSrc,setFinalSrc]=React.useState(\"\");const containerRef=React.useRef(null);// Match Framer CDN-ish steps; DPR-aware to avoid a second fetch\nconst steps=[28,42,64,94,120,140,180,220,280,320,350,380,420,450,500,580,640,720,768,860,930,1024,1100,1200,1280,1420,1600,1720,1840,1920];const pickStep=n=>{for(let i=0;i<steps.length;i++)if(steps[i]>=n)return steps[i];return steps[steps.length-1];};// Safely set/replace the `scale-down-to` param while preserving ALL other params\nconst withScaleParam=(url,px)=>{try{// Some images can be relative; base with current origin\nconst u=new URL(url,typeof window!==\"undefined\"?window.location.origin:\"http://localhost\");u.searchParams.set(\"scale-down-to\",String(px));return u.toString();}catch{// Fallback if URL constructor fails (data: URIs etc.)\nconst hasQ=url.includes(\"?\");const hasScale=/(?:^|[?&])scale-down-to=\\d+/.test(url);if(hasScale)return url.replace(/(scale-down-to=)\\d+/,`$1${px}`);return`${url}${hasQ?\"&\":\"?\"}scale-down-to=${px}`;}};// Compute the optimized URL once the element is laid out\nReact.useLayoutEffect(()=>{if(!src)return;// immediate fallback so something shows even if optimization fails\nif(fallbackToSrc)setFinalSrc(src);const el=containerRef.current;const w=el?.offsetWidth??520;const h=el?.offsetHeight??520;const dpr=typeof window!==\"undefined\"?Math.max(1,window.devicePixelRatio||1):1;const target=pickStep(Math.ceil(Math.max(w,h)*dpr));const optimized=withScaleParam(src,target);// If we produced a different URL, switch to it (will typically be smaller)\nif(optimized&&optimized!==finalSrc)setFinalSrc(optimized);// eslint-disable-next-line react-hooks/exhaustive-deps\n},[src]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width,height,...style},children:[showOverlay&&!isLoaded&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:\"transparent\",pointerEvents:\"none\"},children:/*#__PURE__*/_jsx(\"svg\",{width:\"28\",height:\"28\",viewBox:\"0 0 38 38\",xmlns:\"http://www.w3.org/2000/svg\",stroke:\"#999\",\"aria-hidden\":true,children:/*#__PURE__*/_jsx(\"g\",{fill:\"none\",fillRule:\"evenodd\",children:/*#__PURE__*/_jsxs(\"g\",{transform:\"translate(1 1)\",strokeWidth:\"2\",children:[/*#__PURE__*/_jsx(\"circle\",{strokeOpacity:\".25\",cx:\"18\",cy:\"18\",r:\"18\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M36 18c0-9.94-8.06-18-18-18\",children:/*#__PURE__*/_jsx(\"animateTransform\",{attributeName:\"transform\",type:\"rotate\",from:\"0 18 18\",to:\"360 18 18\",dur:\"1s\",repeatCount:\"indefinite\"})})]})})})}),finalSrc?/*#__PURE__*/_jsx(\"img\",{alt:alt,src:finalSrc,loading:eager?\"eager\":\"lazy\",fetchPriority:fetchPriority,decoding:\"async\",onLoad:()=>setIsLoaded(true),style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\",opacity:isLoaded?1:0,transition:\"opacity .35s ease\",willChange:\"opacity\"}}):null]});}addPropertyControls(LazyImage,{src:{type:ControlType.Image,title:\"Image\"},alt:{type:ControlType.String,title:\"Alt Text\",defaultValue:\"\"},width:{type:ControlType.String,title:\"Width\",defaultValue:\"100%\"},height:{type:ControlType.String,title:\"Height\",defaultValue:\"100%\"},style:{type:ControlType.Object,title:\"Style\"},eager:{type:ControlType.Boolean,title:\"Eager Load\",defaultValue:false},fetchPriority:{type:ControlType.Enum,title:\"Fetch Priority\",options:[\"high\",\"low\",\"auto\"],optionTitles:[\"High\",\"Low\",\"Auto\"],defaultValue:\"auto\"},showOverlay:{type:ControlType.Boolean,title:\"Show Overlay\",defaultValue:true},fallbackToSrc:{type:ControlType.Boolean,title:\"Fallback to Src\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LazyImage\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LazyImage.map"],"mappings":"wMAAyI,SAAwB,EAAU,CAAC,MAAI,MAAI,QAAM,OAAO,SAAO,OAAO,QAAM,QAAM,GAAM,gBAAc,OAAO,cAAY,GAAM,gBAAc,IAAM,CAAC,GAAK,CAAC,EAAS,GAAaA,EAAe,GAAM,CAAM,CAAC,EAAS,GAAaA,EAAe,GAAG,CAAO,EAAaC,EAAa,KAAK,CAC7Z,EAAM,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,CAAO,EAAS,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,EAAM,OAAO,IAAI,GAAG,EAAM,IAAI,EAAE,OAAO,EAAM,GAAG,OAAO,EAAM,EAAM,OAAO,IAChP,GAAgB,EAAI,IAAK,CAAC,GAAG,CACnC,IAAMC,EAAE,IAAI,IAAI,EAAW,IAAS,OAAmC,mBAAvB,EAAO,SAAS,OAA0B,CAAgD,OAA/C,EAAE,aAAa,IAAI,gBAAgB,OAAO,EAAG,CAAC,CAAQA,EAAE,UAAU,MAAO,CACpK,IAAM,EAAK,EAAI,SAAS,IAAI,CAAwH,MAAxG,8BAA8B,KAAK,EAAI,CAAoB,EAAI,QAAQ,sBAAsB,KAAK,IAAK,CAAO,GAAG,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