{"version":3,"file":"ProcessImage.CnIWJg4J.mjs","names":["useState","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","_e","p","ce","addPropertyControls","init_framer_CKT6jEEQ","ControlType","fullRes","url","u","ProcessImage","props","open","setOpen","nat","setNat","image","alt","sourceWidth","im","onKey","style","radius","rows","splitRows","iw","ih","sourceHeight","split","cw","cropX","ch","cropY","segRatio","segments","zoom","y0","r","__FramerMetadata__","init_ProcessImage","init_jsx_runtime","\"exports\"","\"default\"","\"type\"","\"name\"","\"slots\"","\"annotations\"","\"framerContractVersion\"","\"framerSupportedLayoutHeight\"","\"framerSupportedLayoutWidth\"","\"__FramerMetadata__\""],"sources":["https:/framerusercontent.com/modules/a5VCc8slCAWVh3Jd5EPN/UdjOH9M6jOwTIV9jHkIV/ProcessImage.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function fullRes(url){if(!url)return url;try{const u=new URL(url);u.searchParams.delete(\"scale-down-to\");u.searchParams.delete(\"width\");u.searchParams.delete(\"height\");return u.toString();}catch(e){return url;}}/**\n * Process image: smaller in-flow image that opens full resolution on click.\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ProcessImage(props){const{image,maxWidth,radius,zoom,splitRows=1,cropX=0,cropY=0,sourceWidth=0,sourceHeight=0,style}=props;const[open,setOpen]=useState(false);const[nat,setNat]=useState(null);const url=fullRes(image?.src);const alt=image?.alt||\"\";useEffect(()=>{if(!url||sourceWidth||typeof window===\"undefined\")return;const im=new window.Image;im.onload=()=>setNat({w:im.naturalWidth,h:im.naturalHeight});im.src=url;},[url,sourceWidth]);useEffect(()=>{if(!open)return;const onKey=e=>e.key===\"Escape\"&&setOpen(false);window.addEventListener(\"keydown\",onKey);return()=>window.removeEventListener(\"keydown\",onKey);},[open]);if(!url){return /*#__PURE__*/_jsx(\"div\",{style:{...style,width:\"100%\",maxWidth,aspectRatio:\"16 / 10\",borderRadius:radius,background:\"#EDEDF0\",margin:\"8px auto\"}});}const rows=Math.max(1,Math.round(splitRows||1));const iw=sourceWidth||nat?.w;const ih=sourceHeight||nat?.h;const split=rows>1&&iw&&ih;const cw=1-2*cropX/100;const ch=(1-2*cropY/100)/rows;const segRatio=split?cw*iw/(ch*ih):1;const segments=split?/*#__PURE__*/_jsx(\"div\",{onClick:()=>zoom&&setOpen(true),style:{display:\"flex\",width:\"100%\",maxWidth,borderRadius:radius,overflow:\"hidden\",border:\"1px solid rgba(0,0,0,0.06)\",cursor:zoom?\"zoom-in\":\"default\"},children:Array.from({length:rows}).map((_,r)=>{const y0=cropY/100+r*ch;return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",flex:1,aspectRatio:String(segRatio),overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"img\",{src:url,alt:r===0?alt:\"\",loading:\"lazy\",decoding:\"async\",style:{position:\"absolute\",display:\"block\",maxWidth:\"none\",width:100/cw+\"%\",height:\"auto\",left:-(cropX/100/cw)*100+\"%\",top:-(y0/ch)*100+\"%\"}})},r);})}):null;return /*#__PURE__*/_jsxs(\"div\",{style:{...style,width:\"100%\",display:\"flex\",justifyContent:\"center\",padding:\"8px 0\"},children:[split?segments:/*#__PURE__*/_jsx(\"img\",{src:url,alt:alt,loading:\"lazy\",decoding:\"async\",onClick:()=>zoom&&setOpen(true),style:{display:\"block\",width:\"100%\",maxWidth,height:\"auto\",borderRadius:radius,border:\"1px solid rgba(0,0,0,0.06)\",cursor:zoom?\"zoom-in\":\"default\"}}),open&&/*#__PURE__*/_jsx(\"div\",{onClick:()=>setOpen(false),role:\"dialog\",\"aria-label\":\"Image preview\",style:{position:\"fixed\",inset:0,zIndex:1e3,background:\"rgba(10,10,12,0.86)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:32,cursor:\"zoom-out\"},children:/*#__PURE__*/_jsx(\"img\",{src:url,alt:alt,style:{maxWidth:\"100%\",maxHeight:\"100%\",objectFit:\"contain\",borderRadius:8}})})]});}ProcessImage.defaultProps={maxWidth:520,radius:12,zoom:true,splitRows:1,cropX:0,cropY:0,sourceWidth:0,sourceHeight:0};addPropertyControls(ProcessImage,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},maxWidth:{type:ControlType.Number,title:\"Max Width\",min:200,max:1200,step:10,unit:\"px\"},radius:{type:ControlType.Number,title:\"Radius\",min:0,max:40,unit:\"px\"},zoom:{type:ControlType.Boolean,title:\"Click to Zoom\"},splitRows:{type:ControlType.Number,title:\"Rows → 1 Line\",min:1,max:4,step:1,displayStepper:true},cropX:{type:ControlType.Number,title:\"Crop Sides\",min:0,max:20,step:.5,unit:\"%\",hidden:p=>(p.splitRows||1)<2},sourceWidth:{type:ControlType.Number,title:\"Source W\",min:0,max:1e4,unit:\"px\",hidden:p=>(p.splitRows||1)<2},sourceHeight:{type:ControlType.Number,title:\"Source H\",min:0,max:1e4,unit:\"px\",hidden:p=>(p.splitRows||1)<2},cropY:{type:ControlType.Number,title:\"Crop Top/Bottom\",min:0,max:20,step:.5,unit:\"%\",hidden:p=>(p.splitRows||1)<2}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProcessImage\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProcessImage.map"],"mappings":"A,4LAAmJ,SAASW,EAAQ,EAAI,CAAC,GAAG,CAACC,EAAI,OAAOA,EAAI,GAAG,CAAC,IAAMC,EAAE,IAAI,IAAID,CAAG,EAAwG,OAAtGC,EAAE,aAAa,OAAO,eAAe,EAAEA,EAAE,aAAa,OAAO,OAAO,EAAEA,EAAE,aAAa,OAAO,QAAQ,EAASA,EAAE,SAAS,CAAE,MAAS,CAAC,OAAOD,CAAI,CAAC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