{"version":3,"file":"Remote_image.CeFqrm-0.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/aFxgcRN1U8OOQcaOyEIy/nb2Blop9j35UMf0g4UdQ/Remote_image.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Remote_image(props){const[attempt,setAttempt]=useState(0);const[imageError,setImageError]=useState(false);const[loading,setLoading]=useState(true);// Determine slug: original or with underscores\nconst currentSlug=(()=>{const original=props.slug||\"\";if(attempt===0)return original;if(original.includes(\"-\"))return original.replace(/-/g,\"_\");if(original.includes(\"_\"))return original.replace(/_/g,\"-\");return original// if neither, just repeat (won’t help, but harmless)\n;})();const imgSource=prepare(props.image,currentSlug,props.routeSlugs,props.folder,props.useThumbnail);const handleImageError=()=>{const original=props.slug||\"\";const canRetry=attempt===0&&(original.includes(\"-\")||original.includes(\"_\"));if(canRetry){setAttempt(1);}else{setImageError(true);}};const onLoaded=()=>setLoading(false);const spinnerStyle={border:\"3px solid transparent\",borderTop:\"3px solid #BBBBBB\",borderRadius:\"50%\",width:\"40px\",height:\"40px\",animation:loading?\"spin 1s linear infinite\":\"none\",position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\"};const spinnerAnimation=`\n    @keyframes spin {\n      0% { transform: rotate(0deg); }\n      100% { transform: rotate(360deg); }\n    }`;return /*#__PURE__*/_jsxs(\"div\",{style:{width:props.width||\"auto\",height:props.height||\"auto\",borderRadius:props.roundCorners?props.cornerRadius||\"25px\":\"0px\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",overflow:\"hidden\",position:\"relative\"},children:[/*#__PURE__*/_jsx(\"style\",{children:spinnerAnimation}),loading&&/*#__PURE__*/_jsx(\"div\",{style:spinnerStyle}),/*#__PURE__*/_jsx(\"img\",{src:imgSource,onError:handleImageError,onLoad:onLoaded,style:{width:props.needsWidth?\"100%\":undefined,height:\"100%\",objectFit:\"contain\",borderRadius:props.roundCorners?props.cornerRadius||\"25px\":\"0px\",opacity:imageError?0:1}})]});}function prepare(link,slug,routeSlugs,folder,useThumbnail){if(!slug){slug=routeSlugs.slice(1,-1).split(\",\")[0].trim();}if(slug.startsWith(\"ru/\")){slug=slug.substring(3);}// Clean up trailing slashes (like iOS logic)\nconst cleanUrl=(()=>{try{const trimmed=link.trim();if(trimmed.endsWith(\"/\")&&!trimmed.includes(\"selcdn\")){return trimmed.slice(0,-1);}return trimmed;}catch{return link;}})();const filename=(()=>{try{let base=\"\";if(cleanUrl.startsWith(\"http\")){const url=new URL(cleanUrl);const lastComponent=url.pathname.split(\"/\").pop()||\"\";base=lastComponent.replace(/\\.[^/.]+$/,\"\");}else{const lastComponent=cleanUrl.split(\"/\").pop()||\"\";base=lastComponent.replace(/\\.[^/.]+$/,\"\");}// Drop everything after the FIRST extension (jpg/jpeg/png)\nconst firstExtMatch=base.match(/\\.(jpe?g|png)/i);if(firstExtMatch){const cutIndex=base.indexOf(firstExtMatch[0])// index of `.jpg`, `.jpeg`, `.png`\n;base=base.slice(0,cutIndex);}// Now keep only part before first dot\nbase=base.split(\".\")[0]||base;// Remove existing suffix if present\nif(base.endsWith(\"_thumbnail\")){base=base.slice(0,-10)// remove \"_thumbnail\"\n;}if(base.endsWith(\"_regular\")){base=base.slice(0,-8)// remove \"_regular\"\n;}// Then add correct suffix\nbase+=useThumbnail?\"_thumbnail\":\"_regular\";return base;}catch{return\"image\"+(useThumbnail?\"_thumbnail\":\"_regular\");}})();const folderPath=folder?`${folder}/`:\"\";return`https://d2v34uqyvfxwo4.cloudfront.net/${folderPath}${slug}/${filename}.jpg`;}function encodeFilename(name){return name.replace(/ /g,\"+\").split(\"\").map(char=>{const safe=/[a-zA-Z0-9()_\\-+]/.test(char);return safe?char:encodeURIComponent(char);}).join(\"\");}addPropertyControls(Remote_image,{image:{type:ControlType.String},height:{type:ControlType.String},width:{type:ControlType.String},slug:{type:ControlType.String},routeSlugs:{type:ControlType.String},folder:{type:ControlType.String},useThumbnail:{type:ControlType.Boolean},roundCorners:{type:ControlType.Boolean},cornerRadius:{type:ControlType.String},needsWidth:{type:ControlType.Boolean}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Remote_image\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Remote_image.map"],"mappings":"iLAGG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,EAAQ,GAAYA,EAAS,EAAE,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAK,CACvK,OAAiB,CAAC,IAAM,EAAS,EAAM,MAAM,GAA0J,OAApJ,IAAU,EAAS,EAAY,EAAS,SAAS,IAAI,CAAQ,EAAS,QAAQ,KAAK,IAAI,CAAI,EAAS,SAAS,IAAI,CAAQ,EAAS,QAAQ,KAAK,IAAI,CAAQ,KAC/M,CAAO,EAAU,EAAQ,EAAM,MAAM,EAAY,EAAM,WAAW,EAAM,OAAO,EAAM,aAAa,CAAO,MAAqB,CAAC,IAAM,EAAS,EAAM,MAAM,GAAkB,IAAU,IAAI,EAAS,SAAS,IAAI,EAAE,EAAS,SAAS,IAAI,EAAe,EAAW,EAAE,CAAO,EAAc,GAAK,EAAU,MAAa,EAAW,GAAM,CAAO,EAAa,CAAC,OAAO,wBAAwB,UAAU,oBAAoB,aAAa,MAAM,MAAM,OAAO,OAAO,OAAO,UAAU,EAAQ,0BAA0B,OAAO,SAAS,WAAW,IAAI,MAAM,KAAK,MAAM,UAAU,wBAAwB,CAIlkB,OAAoB,EAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAM,OAAO,OAAO,OAAO,EAAM,QAAQ,OAAO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