import{makeStyleResponsive,filterHoverVariables,getStyleShadowState,composeRadius,makeGlobalSize,composeTypographyStyle,getColor,getStyleShadow,getStyleBackgroundImage,getGlobalColorStateStyle,makeStyleState,composeBorderCss,composeCornerCss,GRADIENT_BGR_KEY}from"@gem-sdk/core";let getButtonWrapperStyles=(e,t)=>({...e,...makeStyleResponsive("ta",t?.align)}),getButtonStyles=(e,t)=>{let o={...getSizeStyles(e),...getRadiusStyles(e),...getShadowStyles(e),...getBackgroundStyles(e),...getTypographyStyles(e).textColorStyle,...getTypographyStyles(e).withoutTextColorStyles};return t?o:filterHoverVariables(o)},getButtonIconStyles=(e,t)=>({...getIconSpacingStyle(e,t),"--height-desktop":`${e?.size?.desktop}`,"--height-tablet":`${e?.size?.desktop||e?.size?.tablet}`,"--height-mobile":`${e?.size?.mobile||e?.size?.tablet||e?.size?.desktop}`}),ignoreStateNoneValue=(obj,condition)=>Object.entries(obj).reduce((acc,[key,value])=>((!["hover","focus","normal","active"].includes(key)||eval(condition))&&(acc[key]=value),acc),{}),getShadowStyles=e=>{let{boxShadowBtn:t,hasBoxShadowBtn:o}=e||{},r=ignoreStateNoneValue(t||{},"value?.type !== undefined ");return{...getStyleShadowState(r,"box-shadow",o)}},getRadiusStyles=e=>{let t=ignoreStateNoneValue(e?.roundedBtnV2||{},"value?.radiusType !== undefined");return composeRadius(t,["normal","hover"])},getIconSpacingStyle=(e,t)=>{let o=e?.iconSpacing||{desktop:"8px"};return t?.iconAlign==="left"?makeStyleResponsive("mr",o):makeStyleResponsive("ml",o)},getSizeStyles=e=>{let t=makeGlobalSize(e?.globalSize);return{...t.width,...t.height,...t.padding}},getTypographyStyles=e=>{let t=composeTypographyStyle(e?.typo,e?.typography),o={"--c":t?.["--c"]},r={...t};return delete r["--c"],{textColorStyle:{"--hvr-c":getColor(e?.textColor?.hover),...o},withoutTextColorStyles:r}},getTypoStyles=e=>({...getTypographyStyles(e).withoutTextColorStyles,...getStyleShadow({styleAppliedFor:"text-shadow",value:e?.typo?.custom?.textShadow,isEnableShadow:e?.typo?.custom?.hasShadowText}),"word-break":"break-word"}),getBgImageUrl=(e,t)=>{let{backgroundImage:o,backgroundColorV2:r}=e||{},a=o?.[t],n=r?.[t];if(!a&&!n)return"";let l=`url(${a?.image?.src})`,s=n?`, ${n}`:"";return n?.includes?.(GRADIENT_BGR_KEY)&&a?.image?.src?`${l}${s}`:n?.includes?.(GRADIENT_BGR_KEY)&&!a?.image?.src?n:a?.image?.src?l:""},getBackgroundImageSource=e=>{let t={normal:getBgImageUrl(e,"normal"),hover:getBgImageUrl(e,"hover")};return makeStyleState("bgi",t)},getBackgroundStyles=e=>{let{backgroundColorV2:t,backgroundImage:o}=e||{},r={...o,hover:o?.hover?.image?o?.hover:o?.normal},a={...t,hover:t?.hover||t?.normal};return{...getStyleBackgroundImage(r,{ignoreBackgroundImage:!0}),...getBackgroundImageSource({backgroundImage:r,backgroundColorV2:a}),...getGlobalColorStateStyle("bg",a)}},getCustomCssStyles=({styles:e,uid:t,builderAttrs:o,enableHoverEffect:r})=>{if(!t)return"";let{borderBtnV2:a,roundedBtnV2:n}=e??{},l=ignoreStateNoneValue(a||{},"value?.border !== undefined"),s=ignoreStateNoneValue(n||{},"value?.radiusType !== undefined"),g=generateBorderCornerStyles({uid:t,borderBtn:l,roundedBtn:s,builderAttrs:o,enableHoverEffect:r});return`
      ${g.normalStyles}
      ${g.hoverStyles}
    `.trim()},generateBorderCornerStyles=({uid:e,borderBtn:t,roundedBtn:o,builderAttrs:r,enableHoverEffect:a})=>{let n=r?.["data-component-tag"],l=({styleObj:e,state:t})=>{if(e)return e?.[t]},s=l({styleObj:t,state:"normal"}),g=l({styleObj:a?t:void 0,state:"hover"}),d=l({styleObj:o,state:"normal"}),i=l({styleObj:o,state:"hover"}),u=`
    content: "";
    height: 100%;
    width: 100%;
    position: absolute;
    pointer-events: none;
    top: 0;
    left: 0;
    ${composeBorderCss(s)}
    ${composeCornerCss(d)}
  `,y=`
    [data-id="${e}"].gp-button-base::before, [data-id="${e}-interaction"].gp-button-base::before {
      ${u}
    }
  `,S=`
  [data-id="${e}"]:hover::before, [data-id="${e}-interaction"]:hover::before {
    ${composeBorderCss(g)}
    ${composeCornerCss(i)}
  }
`;if("ProductButton"===n){let t=r?.["data-is-in-stock"]??!1;y=`
      [data-is-in-stock="${t}"]>.${e}.gp-button-base::before {
        ${u}
      }
    `,S=`
    [data-is-in-stock="${t}"]>.${e}.gp-button-base:hover::before {
      ${composeBorderCss(g)}
      ${composeCornerCss(i)}
    }
  `}return{normalStyles:y,hoverStyles:S}};export{generateBorderCornerStyles,getButtonIconStyles,getButtonStyles,getButtonWrapperStyles,getCustomCssStyles,getRadiusStyles,getShadowStyles,getTypoStyles};
