{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/be4xrCsGjhEIXT4yd2DD/NSMXZnSdDZbYI4aTIjLO/FrameshopStock.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function FrameshopStock(props){const{shopId,frameshopArticleId,textColor,fontSize,fontFamily,fontWeight,errorText,spinnerColor,spinnerSize,outOfStockText}=props;const[stockQuantity,setStockQuantity]=React.useState(null);const[loading,setLoading]=React.useState(true);const[error,setError]=React.useState(false);// Fonction pour charger dynamiquement les polices Google Fonts\nconst loadGoogleFont=font=>{if(!font)return;const linkId=`google-font-${font.replace(/\\s+/g,\"-\")}`;if(!document.getElementById(linkId)){const link=document.createElement(\"link\");link.id=linkId;link.href=`https://fonts.googleapis.com/css2?family=${font.replace(/ /g,\"+\")}&display=swap`;link.rel=\"stylesheet\";document.head.appendChild(link);}};// Charger la police choisie\nReact.useEffect(()=>{if(fontFamily){loadGoogleFont(fontFamily);}},[fontFamily]);// Injection des keyframes pour l'animation du spinner\nReact.useEffect(()=>{const styleSheet=document.createElement(\"style\");styleSheet.type=\"text/css\";styleSheet.innerText=spinnerKeyframes;document.head.appendChild(styleSheet);// Nettoyage lors du d\u00E9montage du composant\nreturn()=>{document.head.removeChild(styleSheet);};},[]);// Fonction pour r\u00E9cup\u00E9rer le stock\nconst fetchStock=async()=>{if(!shopId||!frameshopArticleId){setError(true);setLoading(false);return;}try{setLoading(true);const response=await fetch(`https://frameshopv2.support-cd7.workers.dev/stock?shopId=${encodeURIComponent(shopId)}&frameshop_article_id=${encodeURIComponent(frameshopArticleId)}`,{method:\"GET\",headers:{\"Content-Type\":\"application/json\"}});if(response.ok){const data=await response.json();setStockQuantity(data.stock_quantity);setError(false);}else{console.error(\"Error fetching stock:\",response.statusText);setError(true);}}catch(err){console.error(\"Error fetching stock:\",err);setError(true);}finally{setLoading(false);}};// Appeler fetchStock lorsque le composant est mont\u00E9 ou lorsque shopId ou frameshopArticleId changent\nReact.useEffect(()=>{fetchStock();},[shopId,frameshopArticleId]);const textStyle={color:textColor,fontSize:`${fontSize}px`,fontFamily:fontFamily,fontWeight:fontWeight,textAlign:\"left\"};if(loading){// Afficher le spinner pendant le chargement\nreturn /*#__PURE__*/_jsx(\"div\",{style:spinnerContainerStyle,children:/*#__PURE__*/_jsx(\"div\",{style:{...spinnerStyle,borderTopColor:spinnerColor,width:`${spinnerSize}px`,height:`${spinnerSize}px`,borderWidth:`${spinnerSize/8}px`}})});}else if(error){return /*#__PURE__*/_jsx(\"div\",{style:textStyle,children:errorText||\"Error loading stock.\"});}else if(stockQuantity===0){// Afficher le message personnalis\u00E9 lorsque le stock est \u00E0 z\u00E9ro\nreturn /*#__PURE__*/_jsx(\"div\",{style:textStyle,children:outOfStockText});}else{return /*#__PURE__*/_jsx(\"div\",{style:textStyle,children:`${stockQuantity}`});}}// Styles pour le spinner\nconst spinnerContainerStyle={display:\"flex\",justifyContent:\"center\",alignItems:\"center\",width:\"100%\",height:\"100%\"};const spinnerStyle={borderStyle:\"solid\",borderColor:\"rgba(0, 0, 0, 0.1)\",borderTopStyle:\"solid\",borderTopColor:\"#000\",borderRadius:\"50%\",animation:\"spin 1s linear infinite\"};// Animation du spinner\nconst spinnerKeyframes=`\n    @keyframes spin {\n        0% { transform: rotate(0deg); }\n        100% { transform: rotate(360deg); }\n    }\n`;FrameshopStock.defaultProps={shopId:\"\",frameshopArticleId:\"\",textColor:\"#000000\",fontSize:16,fontFamily:\"Inter\",fontWeight:\"400\",errorText:\"Error loading stock.\",spinnerColor:\"#000000\",spinnerSize:24,outOfStockText:\"Out of Stock\"};addPropertyControls(FrameshopStock,{shopId:{title:\"Shop ID\",type:ControlType.String,defaultValue:\"\"},frameshopArticleId:{title:\"Frameshop Article ID\",type:ControlType.String,defaultValue:\"\"},textColor:{title:\"Text Color\",type:ControlType.Color},fontSize:{title:\"Font Size\",type:ControlType.Number,min:8,max:100,defaultValue:16},fontFamily:{title:\"Font Family\",type:ControlType.String},fontWeight:{title:\"Font Weight\",type:ControlType.Enum,options:[\"100\",\"200\",\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],optionTitles:[\"100 Thin\",\"200 Extra Light\",\"300 Light\",\"400 Normal\",\"500 Medium\",\"600 Semi Bold\",\"700 Bold\",\"800 Extra Bold\",\"900 Black\"],defaultValue:\"400\"},errorText:{title:\"Error Text\",type:ControlType.String,defaultValue:\"Error loading stock.\"},spinnerColor:{title:\"Spinner Color\",type:ControlType.Color,defaultValue:\"#000000\"},spinnerSize:{title:\"Spinner Size\",type:ControlType.Number,min:10,max:100,defaultValue:24,unit:\"px\"},outOfStockText:{title:\"Out of Stock Text\",type:ControlType.String,defaultValue:\"Out of Stock\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FrameshopStock\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FrameshopStock.map"],
  "mappings": "6DAKkB,SAARA,EAAgCC,EAAM,CAAC,GAAK,CAAC,OAAAC,EAAO,mBAAAC,EAAmB,UAAAC,EAAU,SAAAC,EAAS,WAAAC,EAAW,WAAAC,EAAW,UAAAC,EAAU,aAAAC,EAAa,YAAAC,EAAY,eAAAC,CAAc,EAAEV,EAAW,CAACW,EAAcC,CAAgB,EAAQC,EAAS,IAAI,EAAO,CAACC,EAAQC,CAAU,EAAQF,EAAS,EAAI,EAAO,CAACG,EAAMC,CAAQ,EAAQJ,EAAS,EAAK,EACjUK,EAAeC,GAAM,CAAC,GAAG,CAACA,EAAK,OAAO,IAAMC,EAAO,eAAeD,EAAK,QAAQ,OAAO,GAAG,CA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AY,MAAM,EAAE,WAAW,CAAC,MAAM,cAAc,KAAKA,EAAY,KAAK,QAAQ,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,KAAK,EAAE,aAAa,CAAC,WAAW,kBAAkB,YAAY,aAAa,aAAa,gBAAgB,WAAW,iBAAiB,WAAW,EAAE,aAAa,KAAK,EAAE,UAAU,CAAC,MAAM,aAAa,KAAKA,EAAY,OAAO,aAAa,sBAAsB,EAAE,aAAa,CAAC,MAAM,gBAAgB,KAAKA,EAAY,MAAM,aAAa,SAAS,EAAE,YAAY,CAAC,MAAM,eAAe,KAAKA,EAAY,OAAO,IAAI,GAAG,IAAI,IAAI,aAAa,GAAG,KAAK,IAAI,EAAE,eAAe,CAAC,MAAM,oBAAoB,KAAKA,EAAY,OAAO,aAAa,cAAc,CAAC,CAAC",
  "names": ["FrameshopStock", "props", "shopId", "frameshopArticleId", "textColor", "fontSize", "fontFamily", "fontWeight", "errorText", "spinnerColor", "spinnerSize", "outOfStockText", "stockQuantity", "setStockQuantity", "ye", "loading", "setLoading", "error", "setError", "loadGoogleFont", "font", "linkId", "link", "ue", "styleSheet", "spinnerKeyframes", "fetchStock", "response", "data", "err", "textStyle", "p", "spinnerContainerStyle", "spinnerStyle", "addPropertyControls", "ControlType"]
}
