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