import{getCornerCSSFromGlobal as e,getAspectRatioGlobalSize as t,hasTranslatedLiquid as i,makeStyleResponsive as r,DEVICES as l,getResponsiveValueByScreen as a,cloneDeep as s}from"@gem-sdk/core";import{getDynamicSourceLocales as o,createSettingId as n}from"../../helpers.js";import{Image as g}from"../settings/configs/translate.js";import{REGEX_IS_NON_RESIZABLE_IMAGE as c}from"./const.js";let d=t=>{let i={...t},r=!0;return i&&Object.keys(i??{}).forEach(e=>{if("bblr"===e||"bbrr"===e||"btlr"===e||"btrr"===e){let t=i[e]??{};"0px"!==t&&(r=!1)}}),r?e(i):{}},u=({styles:e,setting:i})=>{let{srcSet:r,image:l}=i??{},{customAspectRadio:a,shape:s}=e??{},o={desktop:m({device:"desktop",aspect:e?.aspectRatio,auto:i?.isAdaptive?r?.desktop:l,custom:a}),tablet:m({device:"tablet",aspect:e?.aspectRatio,auto:i?.isAdaptive?r?.tablet:l,custom:a}),mobile:m({device:"mobile",aspect:e?.aspectRatio,auto:i?.isAdaptive?r?.mobile:l,custom:a})};return s?t(s):o},m=({device:e,aspect:t,custom:i,auto:r})=>{let l=t?.[e];return"auto"===l?r?.height?`${r.width}/${r.height}`:void 0:"custom"===l?i?.[e]?.height?`${i?.[e]?.width}/${i?.[e]?.height}`:void 0:l},f=({layout:e,isDisableObjectFit:t})=>t?{}:r("objf",e),p=({isDisableAspectStyle:e,aspectRatio:t,objectFits:i,width:r,height:a})=>{if(e)return{};let s={};return l.forEach(e=>{let l=`--objf${"desktop"!==e?`-${e}`:""}`,o=i?.[l]||i?.["--objf"];if(t?.[e]==="auto"&&"contain"===o){s[e]="auto";return}s[e]=t?.[e]!=="auto"&&t?.[e]?t[e]:`${r}/${a}`}),s},h=e=>JSON.stringify(e||{}).replace(/"/g,"&quot;"),b=(e,t)=>`<svg width="${e}" height="${t}" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
      <linearGradient id="g-${e}-${t}">
        <stop stop-color="rgba(51, 51, 51, 0)" offset="20%" />
        <stop stop-color="rgba(51, 51, 51, 0)" offset="50%" />
        <stop stop-color="rgba(51, 51, 51, 0)" offset="70%" />
      </linearGradient>
    </defs>
    <rect width="${e}" height="${t}" fill="rgba(51, 51, 51, 0)" />
    <rect id="r" width="${e}" height="${t}" fill="url(#g-${e}-${t})" />
    <animate xlink:href="#r" attributeName="x" from="-${e}" to="${e}" dur="1s" repeatCount="indefinite"  />
  </svg>`,A=e=>"undefined"==typeof window?Buffer.from(e).toString("base64"):window.btoa(e),w=(e,t)=>`data:image/svg+xml;base64,${A(b(e,t))}`,$="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",_="https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif",S={DEFAULT_SIZES:"100vw",DEFAULT_ALT:"Alt image",DEFAULT_SRC:"https://cdn.shopify.com/s/files/1/2005/9307/files/placeholder-1.png?v=1751355990",DEFAULT_WIDTH_PROPS:800,DEFAULT_HEIGHT_PROPS:533},E=e=>{let{srcSet:t,fallbackImg:i}=e;return{getDeviceSource:e=>{let{isLiquid:r}=e??{},l=C(t?.desktop,"desktop",!r)||i||_,a=C(t?.tablet,"tablet",!r)||C(t?.desktop,"tablet",!r)||i||_,s=C(t?.mobile,"mobile",!r)||C(t?.tablet,"mobile",!r)||C(t?.desktop,"mobile",!r)||i||_;return{srcTablet:a,srcMobile:s,srcDesktop:l}}}},x=({setting:e,uid:t,pageContext:i})=>{if(!e||!g)return{};let r=s(e);for(let e in r.srcSet){let l=r.srcSet[e];if(l&&l.src){let r=o({val:l.src,uid:t,settingId:g?.srcSet?.id?`${g.srcSet.id}_${e}_src`:"",pageContext:i??{}});l.src=String(r)}}let l=o({val:r.alt,uid:t,settingId:n({id:g?.alt?.id}),pageContext:i??{}});r.alt=String(l);let a=o({val:r.title,uid:t,settingId:n({id:g?.title?.id}),pageContext:i??{}});return r.title=String(a),r},I=(e,t,i)=>e?v(e,t):y(i),k=e=>c.test(e),v=(e,t)=>{let i=N(e);return k(e)?"FILE_CONTENT"==t?`{{ '${i}' | file_url }} 768w, {{ '${i}' | file_url }} 1024w, {{ '${i}' | file_url }} 1440w`:`{{ '${e}' | asset_url }} 768w, {{ '${e}' | asset_url }} 1024w, {{ '${e}' | asset_url }} 1440w`:"FILE_CONTENT"==t?`{{ '${i}' | file_img_url: '768x' }} 768w, {{ '${i}' | file_img_url: '1024x' }} 1024w, {{ '${i}' | file_img_url: 'master' }} 1440w`:`{{ '${e}' | asset_img_url: '768x' }} 768w, {{ '${e}' | asset_img_url: '1024x' }} 1024w, {{ '${e}' | asset_img_url: 'master' }} 1440w`},y=e=>e,C=(e,t,r)=>{if(e?.metafieldDefinitionKey)return F(e?.metafieldDefinitionKey);let l=e?.backupFilePath??e?.src??"";if(r)l=e?.src||"";else{let t=e?.src??"";if(i(t))return t;if(e?.backupFileKey){let t=R(e.backupFileKey,e?.src??"");"THEME"!==e.storage&&e.storage?"FILE_CONTENT"===e.storage&&(l=`{{ "${N(t)}" | file_url }}`):l=`{{ "${t}" | asset_url }}`}}if(t&&l?.includes("cdn.shopify")&&!k(l))switch(t){case"tablet":l=l?.includes("?")?`${l}&width=1024`:`${l}?width=1024`;break;case"mobile":l=l?.includes("?")?`${l}&width=768`:`${l}?width=768`}return l},F=e=>`{{${e} | file_url}}`,N=e=>e.replace(/\.jpeg|\.jfif/g,".jpg"),R=(e,t)=>{let i=t?.match(/\/files\/([^\/]+\.(jpg|jpeg|gif|png|webp|svg))/)?.[1];return i&&i!=e?i:e};function T(e,t){let i=j({str:e,reg:/_(pico|icon|thumb|small|compact|medium|large|grande|original|1024x1024|2048x2048|master)+\./g,newString:"."});if(k(i))return i;let r=j({str:i,reg:/\.jpg|\.png|\.jpeg/g,newString:t,isAdd:!0});return r}let j=e=>{let t=e.str,i=e.str.match(e.reg)?.length;if(i){let r,l=1;for(;null!==(r=e.reg.exec(e.str));){if(l===i){let i=e.reg.lastIndex,l=i-r[0].length;e.isAdd&&(e.newString="_"+e.newString+r),t=t.slice(0,l)+e.newString+t.slice(i,t.length)}l++}}return t},L=(e,t)=>{let i=H(),r=t?.[i]||"auto";if("auto"===r||r.includes("%"))return e;let l=Number(r.replace("px",""));return l>e?e:Number(r.replace("px",""))},D=e=>{let{itemWidthParam:t,imageWidthSetting:i,qualityType:r,qualityPercent:l}=e,s=H(),o=L(t,i),n=a(r,s,"finest"),g=a(l,s,100);switch(n){case"finest":default:return"auto";case"high":return Math.round(1.5*o)||1;case"medium":return Math.round(o)||1;case"custom":return Math.round(o*(Number(g)/100))||1}},W=e=>{let t={desktop:"100%",tablet:"100%",mobile:"100%"};return l.forEach(i=>{let r=a(e,i)?.width||"100%";t[i]=r}),t},O=e=>{let t={desktop:"100%",tablet:"100%",mobile:"100%"};return l.forEach(i=>{let r=a(e,i)?.width||"100%";t[i]=r}),t},B=e=>{let t=document.querySelectorAll(`.gem-slider-item-${e}.gp-gallery-image-item`),i=0;return t.forEach(e=>{e.offsetWidth>i&&(i=e.offsetWidth)}),i},K=e=>{let t=document.querySelectorAll(`.gem-slider-item-${e}.gp-ft-image-item`),i=0;return t.forEach(e=>{e.offsetWidth>i&&(i=e.offsetWidth)}),i},P=e=>{let{shapeByLayout:t,qualityType:i,qualityPercent:r,builderPropUID:l}=e,a=document.querySelectorAll(`.gem-slider-item-${l}.gp-gallery-image-item`),s=O(t),o=B(l);a.forEach(e=>{G({item:e,settingWidth:s,width:o,qualityType:i,qualityPercent:r})})},U=e=>{let{ftShape:t,qualityType:i,qualityPercent:r,builderPropUID:l}=e,a=document.querySelectorAll(`.gem-slider-item-${l}.gp-ft-image-item`),s=W(t),o=K(l);a.forEach(e=>{G({item:e,settingWidth:s,width:o,qualityType:i,qualityPercent:r})})},G=e=>{let{item:t,settingWidth:i,width:r,qualityType:l,qualityPercent:a}=e,s=H(),o=t.querySelector("img");if(o){let e=D({itemWidthParam:r,imageWidthSetting:i,qualityType:l,qualityPercent:a}),t=o.getAttribute("base-src");if(!t)return;let n=M(e,t),g=q(t,n,s);o.setAttribute("srcset",g)}},M=(e,t)=>"auto"===e?t:T(t,`${e}x`),q=(e,t,i)=>`${"mobile"===i&&e!==t?t:T(e,"768x")} 767w, ${"tablet"===i&&e!==t?t:T(e,"1024x")} 1023w, ${"desktop"===i&&e!==t?t:T(e,"1920x")} 1440w`,H=()=>window.innerWidth<768?"mobile":window.innerWidth>=768&&window.innerWidth<1025?"tablet":"desktop";export{_ as FALLBACK_IMAGE,$ as IMAGE_PLACEHOLDER,S as NEXT_IMAGE_CONFIG,m as composeAspectRatio,w as createBlurDataURL,E as getAdaptiveImageData,u as getAspectRatio,p as getAspectRatioNextImage,H as getCurrentDevice,C as getImageSrc,D as getImageWidthFollowByQuality,R as getNewBackupFileKey,f as getResponsiveObjectFit,x as getSettingTranslatedImageAndSeo,I as getSrcSet,U as handleSetSrcForFeatureProductImage,P as handleSetSrcForProductImageList,k as isCannotResizeImage,d as overwriteDefaultRadius,N as replaceBackupFileKeyFileContent,T as resizeImage,h as safeStringify,b as shimmer,A as toBase64};
