{"version":3,"file":"DynamicBackground.B4Ec0dNA.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/K7DXOWpW4xgKKewRb5Ts/RDje1KcDpcqso4i1AvDk/DynamicBackground.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * An image background element that changes colors based on the colors of the image inside it.\n * \n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function DynamicBackground(props){const{image={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Gradient 1 - Blue\"},blurAmount=20,brightness=100,saturation=100,opacity=.8,borderRadius=0,imageRadius,padding=20,style}=props;const[dominantColor,setDominantColor]=useState(\"rgba(0,0,0,0.1)\");const[shadowColor,setShadowColor]=useState(\"rgba(0,0,0,0.2)\");const canvasRef=useRef(null);const imgRef=useRef(null);useEffect(()=>{if(typeof window===\"undefined\")return;const img=new Image;img.crossOrigin=\"Anonymous\";img.src=image.src;img.onload=()=>{if(!canvasRef.current)return;const canvas=canvasRef.current;const ctx=canvas.getContext(\"2d\");// Set canvas dimensions to match image\ncanvas.width=img.width;canvas.height=img.height;// Draw image to canvas\nctx.drawImage(img,0,0);try{// Get image data\nconst imageData=ctx.getImageData(0,0,canvas.width,canvas.height);const data=imageData.data;// Simple color averaging\nlet r=0,g=0,b=0,count=0;// Sample pixels (every 5th pixel for performance)\nfor(let i=0;i<data.length;i+=20){r+=data[i];g+=data[i+1];b+=data[i+2];count++;}// Calculate average\nr=Math.floor(r/count);g=Math.floor(g/count);b=Math.floor(b/count);// Create muted/darker version for background\nconst darkenFactor=.7// Reduce brightness by 30%\n;const mutedR=Math.floor(r*darkenFactor);const mutedG=Math.floor(g*darkenFactor);const mutedB=Math.floor(b*darkenFactor);startTransition(()=>{setDominantColor(`rgba(${mutedR}, ${mutedG}, ${mutedB}, ${opacity})`);setShadowColor(`rgba(${Math.floor(r/3)}, ${Math.floor(g/3)}, ${Math.floor(b/3)}, 0.5)`);});}catch(e){console.error(\"Error analyzing image colors:\",e);}};img.onerror=()=>{console.error(\"Error loading image\");};return()=>{img.onload=null;img.onerror=null;};},[image.src,opacity,blurAmount]);return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",borderRadius,overflow:\"hidden\",...style},children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,right:0,bottom:0,backgroundColor:dominantColor,filter:`blur(${blurAmount}px) brightness(${brightness}%) saturate(${saturation}%)`,transform:\"scale(1.1)\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",padding,boxSizing:\"border-box\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsx(\"img\",{ref:imgRef,src:image.src,alt:image.alt||\"Image\",style:{maxWidth:\"100%\",maxHeight:\"100%\",objectFit:\"contain\",borderRadius:imageRadius!==undefined?imageRadius:Math.max(0,borderRadius-padding),boxShadow:`0 4px 12px ${shadowColor}`}})}),/*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{display:\"none\"},\"aria-hidden\":\"true\"})]});}addPropertyControls(DynamicBackground,{image:{type:ControlType.ResponsiveImage,title:\"Image\"},blurAmount:{type:ControlType.Number,title:\"Blur\",defaultValue:30,min:0,max:100,step:1,displayStepper:true},brightness:{type:ControlType.Number,title:\"Brightness\",defaultValue:80,min:0,max:200,step:1,displayStepper:true},saturation:{type:ControlType.Number,title:\"Saturation\",defaultValue:70,min:0,max:200,step:1,displayStepper:true},opacity:{type:ControlType.Number,title:\"Opacity\",defaultValue:.8,min:0,max:1,step:.05,displayStepper:true},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:12,min:0,max:100,step:1,displayStepper:true},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:20,min:0,max:100,step:1,displayStepper:true},imageRadius:{type:ControlType.Number,title:\"Image Radius\",defaultValue:8,min:0,max:100,step:1,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DynamicBackground\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DynamicBackground.map"],"mappings":"wUAKG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,IAAI,sEAAsE,IAAI,oBAAoB,CAAC,aAAW,GAAG,aAAW,IAAI,aAAW,IAAI,UAAQ,GAAG,eAAa,EAAE,cAAY,UAAQ,GAAG,SAAO,EAAW,CAAC,EAAc,GAAkBA,EAAS,kBAAkB,CAAM,CAAC,EAAY,GAAgBA,EAAS,kBAAkB,CAAO,EAAUC,EAAO,KAAK,CAAO,EAAOA,EAAO,KAAK,CAQiD,OARhD,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAI,IAAI,MAQnG,MARyG,GAAI,YAAY,YAAY,EAAI,IAAI,EAAM,IAAI,EAAI,WAAW,CAAC,GAAG,CAAC,EAAU,QAAQ,OAAO,IAAM,EAAO,EAAU,QAAc,EAAI,EAAO,WAAW,KAAK,CACzqB,EAAO,MAAM,EAAI,MAAM,EAAO,OAAO,EAAI,OACzC,EAAI,UAAU,EAAI,EAAE,EAAE,CAAC,GAAG,CACuC,IAAM,EAAvD,EAAI,aAAa,EAAE,EAAE,EAAO,MAAM,EAAO,OAAO,CAAsB,KAClF,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAM,EACtB,IAAI,IAAI,EAAE,EAAE,EAAE,EAAK,OAAO,GAAG,GAAI,GAAG,EAAK,GAAG,GAAG,EAAK,EAAE,GAAG,GAAG,EAAK,EAAE,GAAG,IACtE,EAAE,KAAK,MAAM,EAAE,EAAM,CAAC,E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