import{makeGlobalSize as e,composeTypographyStyle as t,getStyleShadow as o,convertDecimalToNumber as r}from"@gem-sdk/core";import{convertToStyle as i,getSize as a,getWrapperStyle as n,getShapeWrapperPadding as s,checkDiscountContentProductBadge as p}from"../utils/common.js";import{getShapePosition as g}from"../utils/getShapePosition.js";import{composeTextStyleByPosition as l,composeShapeStyleByPosition as d}from"../utils/getRotateShape.js";import{getStyleAdvanced as u}from"../utils/getStyleAdvanced.js";import{getWhiteSpaceStyle as S}from"../utils/getWhiteSpace.js";import{getStyleBackground as y,generateShadowCSS as m,getStyleBorder as h,getStyleCornerRadius as x}from"../utils/stylesV2.js";import{getShape as c}from"../utils/shape.js";import{checkShowBadge as C}from"../utils/renderBadgeILP.js";let getSizeStyles=e=>{let{setting:t,styles:o}=e,r=c(t?.shape),i=t?.contentType==="text",n=i?o?.textSizeV2:o?.imageSizeV2;return i?a(r,n):a(void 0,n)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:i,navigationPosition:a,imageData:s,dotData:p}=e,l=o?.positionWithImage==="outside",d=n(t),S=g({positionType:r?.position,isLiquid:!1,navigationPosition:a,dataImage:{...s,...p}}),y=getSizeStyles(e),m=u(l?{}:{...S,...y},i);return{...!l&&{"--pos":"absolute"},...d,...m}},getTextContentStyle=({styles:r,setting:a})=>{let n=e(r?.textSizeV2).padding,s=c(a?.shape),p=a?.positionWithImage==="outside";return{...S(r?.textSizeV2),...i(s?.textStyle),...l(s,r?.position,p),...t(r?.typo),...o({value:r?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:r?.typo?.custom?.hasShadowText}),...y(!!s?.backgroundColorInText,r?.badgeColorV2),...n}},getBorderStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?h(e?.textBadgeBorder):h(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?x(e?.textBadgeCorner,o?.shapeRadius):x(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=getBorderStyles({setting:t,styles:e}),i=t?.positionWithImage==="outside",a=getCornerStyles({setting:t,styles:e}),n=s(o?.ratio);return{...r,...a,...d(o,e?.position,i),...y(!o?.backgroundColorInText,e?.badgeColorV2),...n,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:t,setting:o})=>{let r=getBorderStyles({setting:o,styles:t}),i=getCornerStyles({setting:o,styles:t}),a=e(t?.imageSizeV2).padding;return{...r,...i,...a}},getOpacityProductBadge=({props:e,currentVariant:t,product:o,isEditMode:i})=>{let{"bundle-item":a,setting:n}=e;if(a)return 1;let s=n?.contentType==="text",g=s&&!n?.displayContent?.trim(),l=p(n?.displayContent);if(g)return i?.2:0;let d=r(t?.price)??0,u=r(t?.salePrice)??0,S=u-d>0,y=C(n?.displayTrigger,o,t);return(S||!l)&&y?1:i?.2:0},getSubWrapperStyle=({props:e,product:t,currentVariant:o,isEditMode:r})=>{let{setting:i}=e,a=i?.positionWithImage==="outside",n=getSizeStyles(e),s=r&&o?getOpacityProductBadge({props:e,currentVariant:o,product:t,isEditMode:r}):1;return{...a?{...n,"--mb":0}:{},opacity:s}},getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,i=o?.contentType==="text";return m(`[id="${r?.uid}"] .product-badge-item`,i?t?.textBadgeShadow:t?.imageBadgeShadow)};export{getContainerStyle,getContentStyleInternal,getImageContainerStyles,getSubWrapperStyle,getTextBadgeWrapperStyles,getTextContentStyle};
