import{dataStringify as e,DEVICES as t,getValueByDevice as r}from"@gem-sdk/core";import{createStateOrContext as d}from"@gem-sdk/system";let getResponsiveSetting=e=>{let t=e.desktop,r=e.tablet?e.tablet:t,d=e.mobile?e.mobile:r;return{desktop:t,tablet:r,mobile:d}},defaultWidth={desktop:"1200px",tablet:"100%",mobile:"100%"},getStyleByDevice=(e,t)=>t?.[e]==="100%"?{contentWidth:"100%",wrapperWidth:"100%",wrapperPadding:"var(--g-ct-p)"}:t?.[e]==="default"?{contentWidth:`var(--g-ct-w, ${defaultWidth[e]})`,wrapperWidth:`calc(var(--g-ct-w, ${defaultWidth[e]}) + 2 * var(--g-ct-p, 15px))`,wrapperPadding:"var(--g-ct-p, 15px)"}:t?.[e]!==void 0?{contentWidth:t?.[e],wrapperWidth:`calc(${t?.[e]} + 2 * var(--g-ct-p, 15px))`,wrapperPadding:"var(--g-ct-p, 15px)"}:{contentWidth:void 0,wrapperWidth:`calc(var(--g-ct-w, ${defaultWidth[e]}) + 2 * var(--g-ct-p, 15px))`,wrapperPadding:"var(--g-ct-p, 15px)"},createStyleObject=e=>{let t=getStyleByDevice("desktop",e),r=getStyleByDevice("tablet",e),d=getStyleByDevice("mobile",e);return{content:{desktop:t.contentWidth,tablet:r.contentWidth,mobile:d.contentWidth},wrapper:{desktop:t.wrapperWidth,tablet:r.wrapperWidth,mobile:d.wrapperWidth},padding:{desktop:t.wrapperPadding,tablet:r.wrapperPadding,mobile:d.wrapperPadding}}},getData=t=>{let{styles:r,builderProps:i}=t,o=d({background:r?.background,uid:i?.uid});return{stateData:e(o).replaceAll("'","&#039;")}};function reduceRadiusForState(e,t){if(!e||!t)return{};let r=("string"==typeof e?e.split(" "):[]).map(e=>parseInt(e,10)||0),d=Object.fromEntries(["btrr","bblr","bbrr","btlr"].map((e,d)=>[e,Math.max(0,(parseInt(t[e]??"0",10)||0)-(r[d]||0))+"px"]));return{...d,radiusType:t.radiusType}}function reduceBorderRadiusForDevice(e,t){if(!e||!t)return{};let r={};return["normal","hover","active"].forEach(d=>{let i=e?.[d],o=t?.[d];i&&o&&(r[d]=reduceRadiusForState(i.width,o))}),r}function getInnerRadiusExcludeBorder(e,t){return{desktop:reduceBorderRadiusForDevice(e?.desktop,t?.desktop),tablet:reduceBorderRadiusForDevice(e?.tablet??e?.desktop,t?.tablet??t?.desktop),mobile:reduceBorderRadiusForDevice(e?.mobile??e?.tablet??e?.desktop,t?.mobile??t?.tablet??t?.desktop)}}let checkHasBackgroundVideo=e=>t.some(t=>{let d=r(e,t);return!!d&&(d?.videoType==="html5"&&d?.videoHtml5||d?.videoType==="youtube"&&d?.video)}),isRenderHtmlVideo=e=>{let t=getResponsiveSetting(e||{}),r=t.desktop?.videoType,d=t.tablet?.videoType,i=t.mobile?.videoType;return"html5"==r||"html5"==d||"html5"==i},isRenderYoutubeVideo=e=>{let t=getResponsiveSetting(e||{}),r=t.desktop?.videoType,d=t.tablet?.videoType,i=t.mobile?.videoType;return"youtube"==r||"youtube"==d||"youtube"==i};export{checkHasBackgroundVideo,createStyleObject,getData,getInnerRadiusExcludeBorder,isRenderHtmlVideo,isRenderYoutubeVideo};
