1import{m as g}from"./chunk-ZHJ4UNAO.js";import{A as f}from"./chunk-67TKGUI5.js";import{Ma as y,ea as h,g as l,ia as c,ja as s,l as u,va as d}from"./chunk-AHHE3Q23.js";var o={article:{fields:["headline","image","author","publisher","datePublished","dateModified","mainEntityOfPage"],defaultType:"Article"},main:{fields:["name","url","email","address","contactPoint","image"],defaultType:"Organization"},single:{fields:[],defaultType:"json"},event:{fields:["name","description","image","startDate","endDate","eventStatus","eventAttendanceMode","location","performer","organizer","offers"],defaultType:"Event"}};var T=(()=>{class r{document;platformId;sanitizer=s(g);environmentService=s(f);defaultImg=this.environmentService.get("imageUrl")+"assets/images/logo.svg";site=this.environmentService.get("hostnameSEO");schemaSub=new l(null);constructor(e,t){this.document=e,this.platformId=t}setSchema(e){let t=o[e.type]?o[e.type]:null,n;return t&&t.fields.length&&(n=this.generateSchema(e,t)),e.entity&&e.entity.schemaJSON&&(n=e.entity.schemaJSON),n&&this.injectJsonLD(this.sanitizerHTML(n)),u(!0)}generateSchema(e,t){if(!e||!e.entity||!e.entity.schemaType&&!e.entity.schemaEventStatus)return null;let n={"@context":"https://schema.org","@type":e.entity.schemaType?e.entity.schemaType:t.defaultType};return t.fields.forEach(i=>{let a=this.getFieldValue(i,e);a&&(n[i]=a)}),n}getFieldValue(e,t){switch(e){case"image":case"logo":return this.getSchemaImage(t.entity);case"publisher":return this.getSchemaPublisher();case"name":return t.entity.schemaName||t.entity.name||"";default:return this.getFieldByTypes(e,t)}}getSchemaImage(e){return e.image&&e.image.url?e.image.url:this.defaultImg}getSchemaAuthor(e){return{"@type":"Person",name:e.author?typeof e.author=="string"?e.author:e.author.name:"@MGID"}}getFieldByTypes(e,t){switch(t.type){case"article":return this.getArticleSchemaField(e,t);case"single":return this.getSingleSchemaField(e,t);case"event":return this.getEventSchemaField(e,t);case"main":return this.getMainSchemaField(e,t);default:return""}}getSchemaPublisher(){return{"@type":"Organization",name:"@MGID",logo:{"@type":"ImageObject",url:this.defaultImg}}}getArticleSchemaField(e,t){switch(e){case"headline":return this.getValue(t.entity.schemaHeadline,t.entity.name,110);case"author":return this.getSchemaAuthor(t.entity);case"datePublished":return t.entity.publishDate||t.entity.createdAt;case"dateModified":return t.entity.updatedAt;default:return t.url?this.getUrl(t.url):this.site}}getSingleSchemaField(e,t){return t.url?this.getUrl(t.url):this.site}getEventSchemaField(e,t){let n="OnlineEventAttendanceMode";switch(e){case"description":return t.entity.schemaDescription||null;case"startDate":return t.entity.dateStart||t.entity.date;case"endDate":return t.entity.dateEnd||this.getEndDate(t);case"eventStatus":return`https://schema.org/${t.entity.schemaEventStatus}`;case"eventAttendanceMode":return`https://schema.org/${t.entity.schemaEventAttendanceMode||n}`;case"performer":return{type:t.entity.schemaPerformerType||"Organization",name:t.entity.schemaPerformerName||"@MGID"};case"organizer":return{type:t.entity.schemaOrganizerType||"Organization",name:t.entity.schemaOrganizerName||"@MGID",url:t.entity.schemaOrganizerUrl||null};case"offers":return this.getSchemaOffer(t);default:return this.getEventLocation(t)}}getEventLocation(e){let t={"@type":"VirtualLocation",url:e.entity.schemaLocationUrl||this.getUrl(e.url)},n={"@type":"Place",name:e.entity.schemaLocationName,address:e.entity.schemaLocationAddresses?e.entity.schemaLocationAddresses:e.entity.place+", "+e.entity.meetUs};switch(e.entity.schemaEventAttendanceMode){case"MixedEventAttendanceMode":return[t,n];case"OfflineEventAttendanceMode":return n;default:return t}}getSchemaOffer(e){return{type:e.entity.schemaOffersType||"Offer",url:e.entity.schemaOffersUrl||this.getUrl(e.url),price:e.entity.schemaOffersPrice||1,priceCurrency:e.entity.schemaOffersPriceCurrency||"USD",availability:`https://schema.org/${e.entity.schemaOffersAvailability||"InStock"}`,validFrom:e.entity.schemaOffersValidFrom||e.entity.dateStart||e.entity.date}}getEndDate(e){if(!e.entity.date||!e.entity.duration)return null;let t=new Date(e.entity.date);return t.setMinutes(e.entity.duration),t.toISOString()}getMainSchemaField(e,t){switch(e){case"email":return t.entity.email||null;case"address":return this.getAddresses(t.entity.headquarters);case"contactPoint":return this.getContactPoint(t.entity.headquarters);default:return t.url?this.getUrl(t.url):this.site}}getAddresses(e){if(!e)return null;let t;return e.forEach(n=>{(n.phone&&(n.phone.indexOf("380")===0||n.phone.indexOf("380")<2)||n.postalCode&&n.postalCode.indexOf("03680")!==-1)&&(t={"@type":"PostalAddress",streetAddress:n.street,addressLocality:n.city,postalCode:n.postalCode,addressCountry:{"@type":"Country",name:n.country}})}),t}getContactPoint(e){if(!e)return null;let t=[];return e.forEach(n=>{t.push({"@type":"ContactPoint",email:n.email||null,telephone:n.phone,contactType:n.name})}),t}getUrl(e){return this.site+e}getValue(e,t,n){let i=e||t||null;return i?i.length>n?i.substring(0,107)+"...":i:null}sanitizerHTML(e={}){let t=e?JSON.stringify(e,null,2).replace(/\//g,"\\/"):"";return this.sanitizer.bypassSecurityTrustHtml(`<script type="application/ld+json">${t}<\/script>`)}injectJsonLD(e){this.schemaSub.next(e)}removeJsonLd(){this.schemaSub.next(null)}getSchemaObservable(){return this.schemaSub.asObservable()}static \u0275fac=function(t){return new(t||r)(c(d,8),c(y))};static \u0275prov=h({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();export{T as a};
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.