import{HREF_TO_SALES_PAGE as t}from"../../constant.js";import{getAspectRatio as e,getNewBackupFileKey as r,getImageSrc as a,safeStringify as s,NEXT_IMAGE_CONFIG as i,getSrcSet as l,createBlurDataURL as o,IMAGE_PLACEHOLDER as g}from"./helpers.js";import{createAttr as p}from"@gem-sdk/system";import{handleClickLink as n}from"../../helpers.js";import{PRIORITY_LOAD_ATTRS as c}from"../constants.js";let getContainerAttrs=(t,e)=>({...t,...e&&{"data-id":e}}),getLinkWrapperAttrs=({urlData:e,imageLink:r,title:a,isLiquid:s=!1})=>{let i=s?{...e,...r?.noFollow&&{rel:"nofollow"},title:a}:{setting:e,title:a};return r?.type!=="go-to-sales-page"?r?.link?i:{}:s?{href:t,target:"_self"}:{setting:{href:t,target:"_self"}}},getImageLiquidAttrs=({pageContext:t,enableLazyLoadImage:e=!1})=>({...t&&{pageContext:t},...e&&{enableLazyLoadImage:e}}),getAdaptiveImageAttrs=({styles:t,setting:i,mode:l,isLiquid:o})=>{let{alt:g,srcSet:p,priority:u,qualityPercent:d,qualityType:m}=i??{},A=e({styles:t,setting:i}),y=()=>{n(i?.imageLink,l)},k=p?.desktop?.backupFileKey?r(p?.desktop?.backupFileKey??"",p?.desktop?.src??""):"",L=o?a({src:p?.desktop?.src,backupFileKey:k,backupFilePath:p?.desktop?.backupFilePath,storage:p?.desktop?.storage}):p?.desktop?.src??"",F=u?{}:{"base-src":L??"","quality-type":s(m),"quality-percent":s(d)};return{pictureClass:"gp-contents",...g&&{alt:g},...p&&{srcSet:p},...u&&c,...F,...t?.objectFit&&{layout:t.objectFit},onClick:y,aspectRatio:A}},getNextImageAttrs=({styles:t,setting:r})=>{let{objectFit:a}=t??{},{vw:s,alt:i,title:l,quality:o,priority:g,isNotLazyload:p,qualityType:n,qualityPercent:c}=r??{},u=e({styles:t,setting:r});return{...r?.image,...s&&{vw:s},...i&&{alt:i},...l&&{title:l},...o&&{quality:o},...g&&{priority:g},isNotLazyload:p,setting:{aspectRatio:u,layout:a,qualityType:n,qualityPercent:c}}},getNextImageLiquidAttrs=t=>{let{srcset:e,setting:g,storage:n,baseSrc:c,priority:u,customAttrs:d,width:m=2237,height:A=1678,isNotLazyload:y,backupFileKey:k,backupFilePath:L,srcIsLiquidCode:F,enableLazyLoadImage:b,alt:f,title:h,src:I=i.DEFAULT_SRC,sizes:q=i.DEFAULT_SIZES}=t,E=!y&&b&&!u,T=()=>{let t=k?r(k??"",I):"",s=F?c:a({src:I,backupFileKey:t,backupFilePath:L,storage:n}),i=F?I:l(t??"",n??"THEME",I),g={sizes:"100vw",src:o(m,A),...s&&!u?{"base-src":s}:{},...s?{"data-src":s}:{},...i?{"data-srcset":i}:{}},p={sizes:q,src:s??"",isNotLazyload:"true",srcset:e??"",...s&&!u?{"base-src":s}:{},...u?{loading:"eager",fetchpriority:"high"}:{loading:"lazy"}};return{"data-sizes":"auto",...E?g:p}},_=()=>{let{qualityPercent:t,qualityType:e}=g??{},r=!u&&e&&t?{"quality-type":s(e),"quality-percent":s(t)}:{"quality-type":"","quality-percent":""};return{...f&&{alt:f},...h&&{title:h},width:m,height:A,draggable:"false",...r}};return p({...d,..._(),...T()})},getNextImageReactAttrs=t=>{let{width:e=i.DEFAULT_WIDTH_PROPS,height:r=i.DEFAULT_HEIGHT_PROPS,quality:a,priority:s,isNotLazyload:l,enableLazyLoadImage:o,base64:n=g,alt:c=i.DEFAULT_ALT,title:u,src:d=i.DEFAULT_SRC}=t,m=!l&&o&&!s,A=()=>{let t={loading:"lazy",placeholder:"blur",...n&&{blurDataURL:n}},e={loading:"eager",fetchpriority:"high"};return{...m?t:e}},y=()=>({src:d,alt:c,title:u,width:e,height:r,quality:a}),k=y(),L=p(A());return{...k,...L}};export{getAdaptiveImageAttrs,getContainerAttrs,getImageLiquidAttrs,getLinkWrapperAttrs,getNextImageAttrs,getNextImageLiquidAttrs,getNextImageReactAttrs};
