import{makeStyleResponsive as e,DEVICES as t,getSingleColorVariable as r,removeNullUndefined as o,parseValueWithUnit as a}from"@gem-sdk/core";let getStyleBackground=(t,r)=>{if(!t)return{};let o=createResponsiveStateMap(e=>getBackgroundByDevice(r,e));return{...e("bg",o)}},getBackgroundByDevice=(e,t)=>{let o=e?.[t];return r(o??e?.desktop)},getStyleBorder=t=>{if(!t)return{};let r=createResponsiveMap(e=>getBorderColorByDevice(t,e)),a=createResponsiveMap(e=>getBorderWidthByDevice(t,e)),l=createResponsiveMap(e=>getBorderStyleByDevice(t,e)),i=o({...e("bc",r),...e("bw",a),...e("bs",l)});return i},getBorderColorByDevice=(e,t)=>e?.[t]?.color,getBorderWidthByDevice=(e,t)=>e?.[t]?.width,getBorderStyleByDevice=(e,t)=>e?.[t]?.border,getStyleCornerRadius=(t,r)=>{if(!t)return{};let a=["btlr","btrr","bblr","bbrr"],l=a.reduce((a,l)=>({...a,...o(e(l,getCornerValueStyles(l,t,r)))}),{});return l},getCornerValueStyles=(e,t,r)=>createResponsiveMap(o=>getCornerByDevice({corner:e,cornerProps:t,device:o,shapeRadius:r})),getCornerByDevice=e=>{let{cornerProps:t,device:r,corner:o,shapeRadius:a}=e,l=t?.[r]?.[o],i=t?.desktop?.[o],n=a?.[o];return l??i??n},calculateShadow=e=>{let o={};for(let l of t){let t=e[l]||e.desktop;if(!t)continue;let{angle:i,distance:n,blur:d,color:s,enable:c}=t;if(!i||!n||!d||!s||!1===c)continue;let{unit:p}=a(`${n}`),g=`${Math.cos(parseFloat(`${i}`)*Math.PI/180)*parseFloat(`${n}`)}${p}`,u=`${Math.sin(parseFloat(`${i}`)*Math.PI/180)*parseFloat(`${n}`)}${p}`;o[l]=`drop-shadow(${g} ${u} ${d} ${r(s)})`}return o},createResponsiveMap=e=>t.reduce((t,r)=>({...t,[r]:e(r)}),{}),createResponsiveStateMap=e=>t.reduce((t,r)=>({...t,[r]:e(r)}),{}),generateShadowCSS=(e,t)=>{if(!t)return"";let r=calculateShadow(t);return`
     ${e} {
      filter: ${r.desktop};
      transition: filter 0.3s ease;
    }

    @media only screen and (max-width: 1024px) and (min-width: 768px) {
      ${e} {
        filter: ${r.tablet||r.desktop};
      }
    }

    @media only screen and (max-width: 767px) {
      ${e} {
        filter: ${r.mobile||r.tablet||r.desktop};
      }
    }
  `};export{generateShadowCSS,getStyleBackground,getStyleBorder,getStyleCornerRadius};
