{"version":3,"file":"AspectLogo_Prod.NMvTeY1C.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/exixtAlsKOrVXmqj9VvS/g0G8s15ZrJqtXysHroX4/AspectLogo_Prod.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Logo Uploader with Aspect Ratio\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function AspectRatioLogo(props){const{logoFile=\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",fixedHeight=80,invertColors=false,style}=props;const[aspectRatio,setAspectRatio]=useState(1);const[isSVG,setIsSVG]=useState(false);const[svgSize,setSvgSize]=useState({width:1,height:1});const imgRef=useRef(null);const[isLoading,setIsLoading]=useState(true)// New state for loading\n;useEffect(()=>{if(!logoFile){startTransition(()=>{setAspectRatio(1);setIsSVG(false);setIsLoading(false);});return;}const isSvgFile=logoFile.endsWith(\".svg\");startTransition(()=>{setIsLoading(true);setIsSVG(isSvgFile);});if(isSvgFile){fetch(logoFile).then(res=>res.text()).then(svgText=>{const parser=new DOMParser;const doc=parser.parseFromString(svgText,\"image/svg+xml\");const svg=doc.querySelector(\"svg\");let newAspectRatio=1// Default aspect ratio\n;if(svg){let width=parseFloat(svg.getAttribute(\"width\")||\"0\");let height=parseFloat(svg.getAttribute(\"height\")||\"0\");if(!width||!height){const viewBox=svg.getAttribute(\"viewBox\");if(viewBox){const parts=viewBox.split(\" \").map(Number);if(parts.length===4){width=parts[2];height=parts[3];}}}if(width&&height){setSvgSize({width,height})// Kept as in original\n;newAspectRatio=width/height;}}startTransition(()=>{setAspectRatio(newAspectRatio);setIsLoading(false);});}).catch(()=>{startTransition(()=>{setAspectRatio(1)// Fallback on error\n;setIsLoading(false);});});}else{// For raster images, isLoading is true. The other useEffect will handle setting it to false.\n}},[logoFile]);// For raster images, get natural size\nuseEffect(()=>{if(isSVG||!logoFile){// If it's an SVG, or no logo file, this effect should not run or interfere.\n// isLoading state is managed by the primary effect for these cases.\nreturn;}const img=imgRef.current;if(img){const handleLoad=()=>{if(img.naturalWidth&&img.naturalHeight){startTransition(()=>{setAspectRatio(img.naturalWidth/img.naturalHeight);setIsLoading(false);});}else{// Image loaded but has no dimensions (e.g. broken but onload fired)\nstartTransition(()=>{setAspectRatio(1)// Fallback\n;setIsLoading(false);});}};const handleError=()=>{startTransition(()=>{setAspectRatio(1)// Fallback aspect ratio\n;setIsLoading(false);});};// Add event listeners\nimg.addEventListener(\"load\",handleLoad);img.addEventListener(\"error\",handleError);// Check if the image is already complete (e.g., from cache)\nif(img.complete){// If already complete, remove listeners and call handler to avoid double execution\nimg.removeEventListener(\"load\",handleLoad);img.removeEventListener(\"error\",handleError);if(img.naturalWidth&&img.naturalHeight){handleLoad()// Manually call if valid and complete\n;}else{handleError()// Manually call if broken and complete\n;}}return()=>{img.removeEventListener(\"load\",handleLoad);img.removeEventListener(\"error\",handleError);};}},[isSVG,logoFile])// Depends on isSVG and logoFile to re-run for new raster images\n;// Calculate width from aspect ratio and fixed height\nconst width=Math.round(fixedHeight*aspectRatio);const height=fixedHeight;// Container style\nconst containerStyle={...style,width:style&&style.width===\"100%\"?\"100%\":width,height:style&&style.height===\"100%\"?\"100%\":height,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",overflow:\"hidden\",background:\"transparent\",position:\"relative\",userSelect:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",pointerEvents:\"auto\",opacity:isLoading?0:1,visibility:isLoading?\"hidden\":\"visible\",transition:\"opacity 0.2s ease-in-out\"};// Image style\nconst imageStyle={width:\"100%\",height:\"100%\",objectFit:\"contain\",pointerEvents:\"none\",userSelect:\"none\",WebkitUserDrag:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",display:\"block\"};// Invert filter\nconst filterStyle=invertColors?{filter:\"invert(1) hue-rotate(180deg)\"}:{};return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,\"aria-label\":\"Logo Container\",children:isSVG?/*#__PURE__*/_jsx(\"img\",{src:logoFile,alt:\"Logo\",style:{...imageStyle,...filterStyle},draggable:false,\"aria-label\":\"Logo\"}):/*#__PURE__*/_jsx(\"img\",{ref:imgRef,src:logoFile,alt:\"Logo\",style:{...imageStyle,...filterStyle},draggable:false,\"aria-label\":\"Logo\"})});}addPropertyControls(AspectRatioLogo,{logoFile:{type:ControlType.File,allowedFileTypes:[\"svg\",\"jpg\",\"jpeg\",\"png\",\"gif\",\"webp\"],title:\"Logo\"},fixedHeight:{type:ControlType.Number,title:\"Height\",defaultValue:80,min:1,max:512,step:1,unit:\"px\",displayStepper:true},invertColors:{type:ControlType.Boolean,title:\"Invert\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});AspectRatioLogo.displayName=\"Aspect Ratio Logo\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AspectRatioLogo\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AspectLogo_Prod.map"],"mappings":"0LAOG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,WAAS,sEAAsE,cAAY,GAAG,eAAa,GAAM,SAAO,EAAW,CAAC,EAAY,GAAgBA,EAAS,CAAC,EAAO,CAAC,EAAM,GAAUA,EAAS,EAAK,EAAO,CAAC,EAAQ,GAAYA,EAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAQ,EAAOC,EAAO,IAAI,EAAO,CAAC,EAAU,GAAcD,EAAS,EAAI,EACrY,MAAc,CAAC,GAAG,CAAC,EAAS,CAAC,MAAoB,CAAC,EAAe,CAAC,EAAE,EAAS,EAAK,EAAE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