"use strict";var core=require("@gem-sdk/core"),helpers=require("../../image/common/helpers.js");const getAspectRatioData=({styles:t,leftImage:e,rightImage:o})=>{let i=(e?.width??0)/(e?.height??1),a=(o?.width??0)/(o?.height??1),s=i<=a?`${e?.width??0}/${e?.height??1}`:`${o?.width??0}/${o?.height??1}`,r=i<=a?e:o,l=composeResponsiveAspectRatio({aspect:t?.aspectRatio,auto:r,custom:t?.customAspectRadio,defaultRatio:s});return{defaultRatio:s,responsiveAspectRatio:l}},composeResponsiveAspectRatio=({aspect:t,auto:e,custom:o,defaultRatio:i})=>({desktop:helpers.composeAspectRatio({device:"desktop",aspect:t,auto:e,custom:o})??i,tablet:helpers.composeAspectRatio({device:"tablet",aspect:t,auto:e,custom:o}),mobile:helpers.composeAspectRatio({device:"mobile",aspect:t,auto:e,custom:o})}),composeLabelPosition=({input:t,isHorizontal:e})=>{let{device:o,positionHoz:i,positionVer:a}=t,s=e?core.getResponsiveValueByScreen(i,o,"hoz-center"):core.getResponsiveValueByScreen(a,o,"ver-center"),r={topLeft:"50%",bottomRight:"auto"};return({"hoz-center":{topLeft:"50%",bottomRight:"auto"},top:{topLeft:"8px",bottomRight:"auto"},bottom:{topLeft:"auto",bottomRight:"8px"},"ver-center":{topLeft:"50%",bottomRight:"auto"},left:{topLeft:"8px",bottomRight:"auto"},right:{topLeft:"auto",bottomRight:"8px"}})[s]??r},getLabelPosition=({position:t,labelPositionHoz:e,labelPositionVer:o,isHorizontal:i})=>({desktop:composeLabelPosition({input:{device:"desktop",positionHoz:e,positionVer:o},isHorizontal:i})?.[t??"topLeft"],tablet:composeLabelPosition({input:{device:"tablet",positionHoz:e,positionVer:o},isHorizontal:i})?.[t??"topLeft"],mobile:composeLabelPosition({input:{device:"mobile",positionHoz:e,positionVer:o},isHorizontal:i})?.[t??"topLeft"]}),generateTranslateByDevices=({isHorizontal:t,labelPositionHoz:e,labelPositionVer:o})=>{let i=t?e:o,a={desktop:i?.desktop??"hoz-center",tablet:i?.tablet??i?.desktop??"hoz-center",mobile:i?.mobile??i?.tablet??i?.desktop??"hoz-center"},s={desktop:"translateX(0) translateY(0)",tablet:"translateX(0) translateY(0)",mobile:"translateX(0) translateY(0)"};for(let e in a){let o=a?.[e];o.includes("center")?s[e]=t?"translateX(0) translateY(-50%)":"translateX(-50%) translateY(0)":s[e]="translateX(0) translateY(0)"}return s},getSliderPositionPercentage=t=>{let e="string"==typeof t?parseInt(t??0):t;return(e??50)/100},FLEX_ALIGN={left:"start",center:"center",right:"end",justify:"start"},getData=t=>{let{handle:e=null,hover:o=!1,handleSize:i=40,leftImageAlt:a="",leftImageTitle:s="",leftImageCss:r={},leftImageLabel:l=null,rightImageAlt:p="",rightImageTitle:n="",rightImageCss:c={},rightImageLabel:g=null,sliderLineWidth:u=2,sliderLineColor:m="#ffffff",sliderPositionPercentage:b=.5,vertical:h=!1,componentUid:d="",styles:L={},leftImage:R,rightImage:f,enableLabel:y=!1,qualityType:S,qualityPercent:x}=t,P=!h,v=y&&!!l,A=y&&!!g,C=(R?.width??0)<(f?.width??0)?{...R}:{...f},I=t=>{let{isLiquid:e}=t??{};return e?helpers.getImageSrc(R):R?.src??""},k=t=>{let{isLiquid:e}=t??{};return e?helpers.getImageSrc(f):f?.src??""},{responsiveAspectRatio:D,defaultRatio:X}=getAspectRatioData({leftImage:R,rightImage:f,styles:L});return{styles:L,handle:e,hover:o,handleSize:i,leftImageAlt:a,leftImageTitle:s,leftImageCss:r,leftImageLabel:l,rightImageAlt:p,rightImageTitle:n,rightImageCss:c,rightImageLabel:g,sliderLineWidth:u,sliderLineColor:m,sliderPositionPercentage:b,vertical:h,componentUid:d,tempImage:C,aspectRatio:D,defaultRatio:X,isHorizontal:P,hasLeftLabel:v,hasRightLabel:A,qualityType:S,qualityPercent:x,getLeftImageSrc:I,getRightImageSrc:k}},getImageClipStyle=t=>{let{isHorizontal:e,containerWidth:o,containerHeight:i,sliderPosition:a,type:s}=t,r=e?o*a:i*a;return"left"===s?{clip:e?`rect(auto, ${r}px, auto, auto)`:`rect(auto, auto, ${r}px, auto)`}:{clip:e?`rect(auto, auto, auto, ${r}px)`:`rect(${r}px, auto, auto, auto)`}},getSliderPositionStyle=t=>{let{isHorizontal:e,containerWidth:o,containerHeight:i,sliderPosition:a,handleSize:s}=t,r=e?o*a:i*a,l=s/2;return{[e?"top":"left"]:0,[e?"left":"top"]:`${r-l}px`}},getLabelContainerStyles=t=>({...getImageClipStyle(t)}),getReactStyles=t=>({sliderPosition:getSliderPositionStyle(t),leftImageClip:getImageClipStyle({...t,type:"left"}),rightImageClip:getImageClipStyle({...t,type:"right"}),leftLabelContainer:getLabelContainerStyles({...t,type:"left"}),rightLabelContainer:getLabelContainerStyles({...t,type:"right"})});exports.FLEX_ALIGN=FLEX_ALIGN,exports.composeLabelPosition=composeLabelPosition,exports.composeResponsiveAspectRatio=composeResponsiveAspectRatio,exports.generateTranslateByDevices=generateTranslateByDevices,exports.getAspectRatioData=getAspectRatioData,exports.getData=getData,exports.getImageClipStyle=getImageClipStyle,exports.getLabelContainerStyles=getLabelContainerStyles,exports.getLabelPosition=getLabelPosition,exports.getReactStyles=getReactStyles,exports.getSliderPositionPercentage=getSliderPositionPercentage,exports.getSliderPositionStyle=getSliderPositionStyle;
