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