import{getResponsiveValueByScreen as e,cloneDeep as t}from"@gem-sdk/core";import{getDynamicSourceLocales as o,createSettingId as i}from"../../helpers.js";import{Video as l}from"../settings/configs/translate.js";let s=(t,o)=>{let i={desktop:t?.desktop?.width,tablet:t?.tablet?.width,mobile:t?.mobile?.width},l={desktop:t?.desktop?.height,tablet:t?.tablet?.height,mobile:t?.mobile?.height},s={desktop:o?.desktop==="custom"?`${e(i,"desktop")}/${e(l,"desktop")}`:o?.desktop==="cover"?"unset":o?.desktop,tablet:o?.tablet==="custom"?`${e(i,"tablet")}/${e(l,"tablet")}`:o?.tablet==="cover"?"unset":o?.tablet,mobile:o?.mobile==="custom"?`${e(i,"mobile")}/${e(l,"mobile")}`:o?.mobile==="cover"?"unset":o?.mobile};return s},r=({setting:e,uid:s,pageContext:r})=>{if(!e||!s)return{};if(r?.isPreviewing)return e;let m=t(e);if(m.youtubeUrl&&"youtube"===m.type){let e=o({val:m.youtubeUrl,uid:s,settingId:i({id:l?.youtubeUrl?.id}),pageContext:r});m.youtubeUrlTranslated=String(e)}if(m.vimeoUrl&&"vimeo"===m.type){let e=o({val:m.vimeoUrl,uid:s,settingId:i({id:l?.vimeoUrl?.id}),pageContext:r});m.vimeoUrlTranslated=String(e)}if(m.html5Url&&"html5"===m.type){let e=o({val:m.html5Url,uid:s,settingId:i({id:l?.html5Url?.id}),pageContext:r});m.html5Url=String(e)}if(m.poster){let e=o({val:m.poster?.src,uid:s,settingId:l?.poster?.id?`${l.poster.id}_src`:"",pageContext:r});m.poster.src=String(e)}return m},m=e=>{let{id:t,params:o,muted:i,webp:l,controls:s,adNetwork:r,autoplay:m,lazy:a,thumbnail:d}=e,p=encodeURIComponent(t),n="hqdefault",u=`${o}`||"",b=i?"&mute=1":"",g=l?"webp":"jpg",h=l?"vi_webp":"vi",c=e.thumbnail||`https://i.ytimg.com/${h}/${p}/${n}.${g}`,$=e.noCookie?"https://www.youtube-nocookie.com":"https://www.youtube.com",v=`${$}/embed/${p}?autoplay=${!!a||!!d&&!m||m}&state=1${b}${u}&controls=${s?1:0}`;return{videoId:p,posterImp:n,paramsImp:u,mutedImp:b,format:g,vi:h,posterUrl:c,ytUrl:$,iframeSrc:v,adNetworkImp:r||!1}},a=e=>{let{id:t,autoplay:o,muted:i,controls:l,loop:s,lazy:r}=e,m=encodeURIComponent(t),a=`?&autoplay=${r?1:o?1:0}&muted=${i?1:0}&loop=${s?1:0}&controls=${l}&autopause=false`,d=`https://player.vimeo.com/video/${m}${a}`;return{videoId:m,params:a,iframeSrc:d}},d=(e,t)=>({[`--${e}`]:t?.desktop,[`--${e}-tablet`]:t?.tablet,[`--${e}-mobile`]:t?.mobile}),p="https://cdn.shopify.com/s/files/1/0703/5214/2562/files/gempages_518090459516502570-3d3a4631-1d7d-4a2f-9ef0-9bbe7220e02d.jpg",n=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=|shorts\/)|youtu\.be\/)([^"&?/\s]{11})/i,u=/^(?:http:\/\/|https:\/\/)vimeo\.com\/[\w/]+(?:\?.*)?$/im,b=e=>{let t=e.match(n);return t?.[1]??void 0},g=e=>e.match(/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/)?(\d+)(?:$|\/|\?)/)?.[3],h=e=>{let t=e.split(":",2);return t.length<=1?parseInt(t[0]||"0"):60*parseInt(t[0]||"0")+parseInt(t[1]||"0")},c=e=>{let t=e.split("&");return t.shift(),t.reduce((e,t)=>{let[o,i]=t.split("=");return"loop"!==o&&(e[o]=i),e},{})},$=e=>e.includes("loop=1");export{c as covertStrParamsToObj,p as fallbackImageVideoUrl,s as getAspectRatioSettings,r as getSettingTranslatedVideoAndThumbnail,a as getVimeoParams,g as getVimeoVideoId,m as getYoutubeParams,b as getYoutubeVideoId,$ as isSettingLoop,d as makeStyleResponsiveRatio,h as parseTimeVideo,u as vimeoVideoRegex,n as youtubeVideoRegex};
