1import{a as G}from"./chunk-OULBKL7V.js";import{d as f,e as F}from"./chunk-EDLENBQR.js";import{Ba as $,Ca as K,Da as X}from"./chunk-ROAQJP46.js";import{Ca as P,Hb as I,Ia as O,Ib as C,Ja as S,Jb as b,Ka as _,Na as R,Nb as j,Qb as B,Qc as D,Sb as u,Wc as q,Xc as z,Yc as J,_a as k,ab as H,eb as M,fb as v,oc as U,oh as V,rb as L,sa as E,tb as y,ub as w,vb as m,yc as A,zc as N}from"./chunk-ADQO3XXX.js";import{a as W,b as T}from"./chunk-3JMZ37NM.js";var Q=(()=>{let r=class r extends K{constructor(){super(...arguments),this.mediaSourceComparator=(e,t)=>{let i=t.width-e.width;return i===0&&e.mime!==t.mime&&(i=e.mime===F?-1:1),i}}get loadingStrategy(){return this.config?.imageLoadingStrategy??$.EAGER}get reversedWebpFormats(){return this._reversedWebpFormats||(this._reversedWebpFormats=this.reversedFormats.filter(e=>e.code.endsWith(f))),this._reversedWebpFormats}get reversedJpgFormats(){return this._reversedJpgFormats||(this._reversedJpgFormats=this.reversedFormats.filter(e=>!e.code.endsWith(f))),this._reversedJpgFormats}getMedia(e,t,i,a,s){if(!e)return;let d=e.url?e:this.resolveMedia(e,t),{sources:o,srcset:l}=this.resolveSources(e,t,d?.mime);return this.shiftSourceWidths({src:this.resolveAbsoluteUrl(d?.url),alt:i||d?.altText,role:a??d?.role,srcset:l,mime:d?.mime,sources:o},s)}mergeMediaSources(e,t){return T(W({},t?.src?t:e),{sources:[...e?.sources,...t?.sources].sort(this.mediaSourceComparator)})}resolveSources(e,t,i){if(!e)return;let a=this.sortedFormats.sort((h,g)=>h.size.width>g.size.width?1:-1),s=a.findIndex(h=>h.code===t);s>-1&&(a=a.slice(0,s+1));let d=[],o=-1,l="";return a.forEach(h=>{let g=e[h.code];if(g&&i===g.mime){let p=h.size.width;if(!o||o!==p){let x=this.resolveAbsoluteUrl(g.url);d.unshift({url:x,width:p,mime:i}),l.length>0&&(l+=", "),l+=`${x} ${p}w`,o=p}}}),{sources:d,srcset:l===""?void 0:l}}resolveFormat(e,t){return t&&e[t]?t:this.resolveClosestFormat(e,t)||this.resolveBestFormat(e)||Object.keys(e)[0]}resolveClosestFormat(e,t){if(t){let i=t.endsWith(f)?this.reversedWebpFormats:this.reversedJpgFormats,a=i.findIndex(s=>s.code===t);if(a>=0)return i.slice(a).find(s=>Object.prototype.hasOwnProperty.call(e,s.code))?.code}return null}
1shiftSourceWidths(e,t=0){if(t!==0){let i=Math.abs(t),a=e?.sources;if(a?.length>i){let s=[...a].sort((o,l)=>t>0?l.width-o.width:o.width-l.width);for(let o=0;o<s.length-i;o++)s[o].width=s[o+i].width;let d=0;for(let o=s.length-i;o<s.length;o++)s[o].width=--d}}return e}};r.\u0275fac=(()=>{let e;return function(i){return(e||(e=R(r)))(i||r)}})(),r.\u0275prov=E({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var ee=()=>[];function te(n,r){if(n&1&&b(0,"source"),n&2){let c=r.$implicit,e=r.count,t=u();w("srcset",c.url)("media",e<=(t.hasWebp?2:1)?void 0:"(min-width: "+c.width+"px)")("type",c.mime)}}function ie(n,r){if(n&1){let c=j();I(0,"img",3),A(1,"cxTranslate"),B("load",function(){S(c);let t=u();return _(t.loadHandler())})("error",function(){S(c);let t=u();return _(t.errorHandler())}),C()}if(n&2){let c,e=u();m("ngClass",(c=e.imageClass)!==null&&c!==void 0?c:""),w("src",(e.mergedMedia==null?null:e.mergedMedia.src)||N(1,9,e.missingImgKey),H)("alt",e.title)("title",e.title)("loading",e.loading)("width",e.imageRatio==null?null:e.imageRatio.width)("height",e.imageRatio==null?null:e.imageRatio.height)("fetchpriority",e.fetchPriority)("onerror",e.forceOnErrorHandler?e.errorHandlerFunction:null)}}function re(n,r){if(n&1&&b(0,"div",4),n&2){let c=u();m("innerHTML",c.title,k)}}var ue=(()=>{let r=class r extends X{constructor(e,t,i){super(e),this.mediaService=e,this.docRef=t,this.req=i,this.sourceShift=0,this.errorHandlerFunction=` 2 const sources = Array.from(this.parentNode.getElementsByTagName('source')); 3 if (sources && sources.length > 0) { 4 const failedUrl = this.currentSrc; 5 const failedSource = sources.find(source => failedUrl.endsWith(source.getAttribute('srcset'))); 6 if (failedSource) { 7 this.closest('sip-media').classList.add('has-error'); 8 } 9 }`}ngOnChanges(){this.ssrFormat&&this.req&&(this.format=this.ssrFormat);let e=this.format?this.format+f:void 0,t=this.req?this.sourceShift:void 0;this.hasWebp=!1;let i=this.mediaService.getMedia(this.container,e,this.alt,this.role,t),a=this.mediaService.getMedia(this.container,this.format,this.alt,this.role,t);if(i?.mime===F?(this.mergedMedia=this.mediaService.mergeMediaSources(i,a),this.hasWebp=!0):this.mergedMedia=a,this.media=this.mergedMedia,this.format?this.missingImgKey=`img.missingProductImage.${this.format}`:this.missingImgKey=void 0,this.title=this.alt||this.mergedMedia?.alt,this.req&&this.fetchPriority==="high"&&this.mergedMedia.sources[0]?.url&&!this.docRef.querySelector(`link[rel='preload'][href='${this.mergedMedia.sources[0]?.url}']`)){let s=this.createPreloadLink(this.mergedMedia.sources[0].url,this.fetchPriority);this.docRef.head.appendChild(s),this.hasWebp&&this.mergedMedia.sources[1]?.url&&(s=this.createPreloadLink(this.mergedMedia.sources[1].url,this.fetchPriority),this.docRef.head.appendChild(s))}}createPreloadLink(e,t){let i=this.docRef.createElement("link");return i.rel="preload",i.setAttribute("as","image"),i.setAttribute("fetchPriority",t),i.href=e,i}trackSource(e,t){return t.width+"-"+(t.mime||"")}};r.\u0275fac=function(t){return new(t||r)(v(Q),v(D),v(G,8))},r.\u0275cmp=P({type:r,selectors:[["sip-media"]],inputs:{container:"container",imageRatio:"imageRatio",fetchPriority:"fetchPriority",sourceShift:"sourceShift",ssrFormat:"ssrFormat",forceOnErrorHandler:"forceOnErrorHandler",showTitle:"showTitle",imageClass:"imageClass"},features:[L,O],decls:4,vars:5,consts:[[4,"ngFor","ngForOf","ngForTrackBy"],[3,"ngClass","load","error",4,"ngIf"],["class","img-desc",3,"innerHTML",4,"ngIf"],[3,"load","error","ngClass"],[1,"img-desc",3,"innerHTML"]],template:function(t,i){t&1&&(I(0,"picture"),y(1,te,1,3,"source",0)(2,ie,2,11,"img",1),C(),y(3,re,1,1,"div",2)),t&2&&(M(),m("ngForOf",(i.mergedMedia==null?null:i.mergedMedia.sources)||U(4,ee))("ngForTrackBy",i.trackSource),M(),m("ngIf",(i.mergedMedia==null?null:i.mergedMedia.src)||i.missingImgKey),M(),m("ngIf",i.showTitle&&i.title))},dependencies:[q,z,J,V],encapsulation:2,changeDetection:0});let n=r;return n})();export{Q as a,ue as b};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.