"use strict";var core=require("@gem-sdk/core"),common=require("./common.js");const appendPixelUnitIfNeed=e=>e?.includes("px")?e:`${e}px`,convertAutoToZero=e=>["auto","Auto",void 0].includes(e)?"0px":appendPixelUnitIfNeed(`${e}`),getGapWhenOnlyFeature=e=>{let{device:t,position:o,leftGap:a,rightGap:c}=e,n=common.getDeviceSpecificStyle(e?.imageShape,t)?.width||"100%",i=common.getDeviceSpecificStyle(e?.imageAlign,t);switch(o){case"left":return"flex-end"===i?`calc((100% - ${n}) + ${a})`:"center"===i?`calc((100% - ${n}) / 2 + ${a})`:a;case"center":return"flex-end"===i?`calc((200% - ${n}) / 2 + ${a})`:"center"===i?"50%":`calc(${n} / 2 + ${a})`;case"right":return"flex-start"===i?`calc((100% - ${n}) + ${c})`:"center"===i?`calc((100% - ${n}) / 2 + ${c})`:c}},getGapWhenNotOnlyFeature=e=>{let{position:t,leftGap:o,rightGap:a}=e;switch(t){case"left":return o;case"center":return"50%";case"right":return a}},getGapCompareProductImage=e=>{let{device:t,imageLayout:o}=e,a=common.getDeviceSpecificStyle(o,t);return"only-feature"===a?getGapWhenOnlyFeature(e):getGapWhenNotOnlyFeature(e)},getValuePositon=(e,t,o)=>t?o:getGapCompareProductImage(e),getGapBottom=e=>{let{device:t,bottomGap:o,dotSize:a,dotGapToCarousel:c,key:n,dotStyle:i,imageLayout:r,isLiquid:l}=e,s=common.getDeviceSpecificStyle(i,t),g=common.getDeviceSpecificStyle(r,t);return l&&"outside"===s?{[`--bottom${n}`]:o}:"none"!==s&&"only-feature"===g?{[`--bottom${n}`]:`calc(${a?.[t]||a?.desktop||0}px + ${c?.[e.device]||c?.desktop||0}px + ${o})`}:{[`--bottom${n}`]:o}},getShapePosition=e=>{let{positionType:t,isLiquid:o,navigationPosition:a,dataImage:c}=e;return core.DEVICES.reduce((e,n)=>{let i="desktop"===n?"":`-${n}`,r=common.getDeviceSpecificStyle(t,n)?.placement||"",l=convertAutoToZero(common.getDeviceSpecificStyle(t,n)?.topGap),s=convertAutoToZero(common.getDeviceSpecificStyle(t,n)?.rightGap),g=convertAutoToZero(common.getDeviceSpecificStyle(t,n)?.bottomGap),p=convertAutoToZero(common.getDeviceSpecificStyle(t,n)?.leftGap);a?.[n]!=="outside"||["bottom","top"].includes(r)||(s=`calc(${s} + 56px)`,p=`calc(${p} + 56px)`);let u=e=>({position:e,device:n,imageLayout:c?.imageLayout,imageAlign:c?.imageAlign,imageShape:c?.imageShape,leftGap:p,rightGap:s}),m={device:n,bottomGap:g,key:i,dotSize:c?.dotSize,dotGapToCarousel:c?.dotGapToCarousel,dotStyle:c?.dotStyle,imageLayout:c?.imageLayout,isLiquid:o},$={};switch(r){case"top-left":$={[`--top${i}`]:l,[`--left${i}`]:getValuePositon(u("left"),o,p),[`--right${i}`]:"unset",[`--bottom${i}`]:"unset",[`--t${i}`]:"unset"};break;case"top":$={[`--top${i}`]:l,[`--left${i}`]:getValuePositon(u("center"),o,"50%"),[`--right${i}`]:"unset",[`--bottom${i}`]:"unset",[`--t${i}`]:"translateX(-50%)"};break;case"top-right":$={[`--top${i}`]:l,[`--right${i}`]:getValuePositon(u("right"),o,s),[`--left${i}`]:"unset",[`--bottom${i}`]:"unset",[`--t${i}`]:"unset"};break;case"left":$={[`--top${i}`]:"50%",[`--left${i}`]:getValuePositon(u("left"),o,p),[`--right${i}`]:"unset",[`--bottom${i}`]:"unset",[`--t${i}`]:"translateY(-50%)"};break;case"right":$={[`--top${i}`]:"50%",[`--right${i}`]:getValuePositon(u("right"),o,s),[`--left${i}`]:"unset",[`--bottom${i}`]:"unset",[`--t${i}`]:"translateY(-50%)"};break;case"bottom-left":$={...getGapBottom(m),[`--left${i}`]:getValuePositon(u("left"),o,p),[`--right${i}`]:"unset",[`--top${i}`]:"unset",[`--t${i}`]:"unset"};break;case"bottom":$={...getGapBottom(m),[`--left${i}`]:getValuePositon(u("center"),o,"50%"),[`--top${i}`]:"unset",[`--right${i}`]:"unset",[`--t${i}`]:"translateX(-50%)"};break;case"bottom-right":$={...getGapBottom(m),[`--right${i}`]:getValuePositon(u("right"),o,s),[`--left${i}`]:"unset",[`--top${i}`]:"unset",[`--t${i}`]:"unset"}}return{...e,...$}},{})};exports.getGapBottom=getGapBottom,exports.getGapCompareProductImage=getGapCompareProductImage,exports.getShapePosition=getShapePosition;
