"use strict";var e=require("parse5");const t=(e,t)=>e.attrs.find((e=>e.name===t)),r=(e,r)=>{var i;return null===(i=t(e,r))||void 0===i?void 0:i.value},i=(e,t)=>{var i;const o=(null===(i=r(e,"class"))||void 0===i?void 0:i.split(" "))||[];return t?o.filter((e=>"string"==typeof t?e.startsWith(t):e.match(t))):o},o=(e,t)=>i(e).filter((e=>t.includes(e))),n=(e,t)=>i(e).some((e=>t.includes(e))),a=(e,t,i)=>t.includes(e.tagName)?r(e,i):void 0,l=(e,t)=>{var i;return Boolean(null===(i=r(e,"rel"))||void 0===i?void 0:i.split(" ").some((e=>t.includes(e))))},s=(e,t)=>[...e,...t],u={adr:{type:["h-adr"],properties:{"country-name":"p-country-name",locality:"p-locality",region:"p-region","street-address":"p-street-address","postal-code":"p-postal-code","extended-address":"p-extended-address"}},geo:{type:["h-geo"],properties:{latitude:"p-latitude",longitude:"p-longitude"}},hentry:{type:["h-entry"],properties:{author:"p-author","entry-content":"e-content","entry-summary":"p-summary","entry-title":"p-name",updated:"dt-updated"},rels:{bookmark:"u-url",tag:"p-category"}},hfeed:{type:["h-feed"],properties:{author:"p-author",photo:"u-photo",url:"u-url"},rels:{tag:"p-category"}},hnews:{type:["h-news"],properties:{entry:"p-entry","source-org":"p-source-org",dateline:"p-dateline",geo:"p-geo"},rels:{principles:"u-principles"}},hproduct:{type:["h-product"],properties:{price:"p-price",description:"p-description",fn:"p-name",review:"p-review",brand:"p-brand",url:"u-url",photo:"u-photo"},rels:{tag:"p-category"}},hreview:{type:["h-review"],properties:{item:"p-item",rating:"p-rating",reviewer:"p-author",summary:"p-name",url:"u-url",description:"e-content"},rels:{bookmark:"u-url",tag:"p-category"}},vcard:{type:["h-card"],properties:{fn:"p-name",url:"u-url",org:"p-org",adr:"p-adr",tel:"p-tel",title:"p-job-title",email:"u-email",photo:"u-photo",agent:"p-agent","family-name":"p-family-name","given-name":"p-given-name","additional-name":"p-additional-name","honorific-prefix":"p-honorific-prefix","honorific-suffix":"p-honorific-suffix",key:"p-key",label:"p-label",logo:"u-logo",mailer:"p-mailer",nickname:"p-nickname",note:"p-note",sound:"u-sound",geo:"p-geo",bday:"dt-bday",class:"p-class",rev:"p-rev",role:"p-role","sort-string":"p-sort-string",tz:"p-tz",uid:"u-uid"},rels:{tag:"p-category"}},hresume:{type:["h-resume"],properties:{contact:"p-contact",experience:"p-experience",summary:"p-summary",skill:"p-skill",education:"p-education",affiliation:"p-affiliation"}},vevent:{type:["h-event"],properties:{summary:"p-name",dtstart:"dt-start",dtend:"dt-end",duration:"dt-duration",description:"p-description",attendee:"p-attendee",location:"p-location",url:"u-url"}},item:{type:["h-item"],properties:{fn:"p-name",photo:"u-photo",url:"u-url"}},"hreview-aggregate":{type:["h-review-aggregate"],properties:{rating:"p-rating",average:"p-average",best:"p-best",count:"p-count",item:"p-item",url:"u-url",fn:"p-name"}}},d=Object.keys(u),p=e=>o(e,d),c=e=>new RegExp(`^${e}-([a-z0-9]+-)?([a-z]+-)*[a-z]+$`),m=c("h"),h=c("(p|e|u|dt)"),g=e=>"tagName"in e&&"childNodes"in e,f=e=>t=>g(t)&&t.tagName===e,v=e=>"value"in e,y=e=>i(e).some((e=>e.match(m))),N=e=>y(e)||(e=>n(e,d))(e),b=(e,t)=>((e,t)=>t.some((t=>{const{properties:r,rels:i}=u[t];return n(e,Object.keys(r))||i&&l(e,Object.keys(i))})))(e,t),w=e=>i(e,h).length>0,$=(e,t)=>!w(e)&&!b(e,t)&&N(e),x=e=>Boolean(g(e)&&"base"===e.tagName&&t(e,"href")),k=e=>g(e)&&n(e,["value","value-title"]),j=e=>Boolean(g(e)&&e.attrs.some((e=>"rel"===e.name))&&e.attrs.some((e=>"href"===e.name))),E=e=>e.childNodes.filter(Boolean).filter(g),T=(e,t,r)=>{const{matcher:i,roots:o}=r,n=i(t,o)&&t;if(n&&N(t))return[...e,t];if(N(t))return e;const a=E(t).reduce(((e,t)=>T(e,t,r)),n?[n]:[]);return[...e,...a]},U=(e,t)=>{const r={roots:g(e)?p(e):[],stopAtRoot:!0,matcher:t};return E(e).reduce(((e,t)=>T(e,t,r)),[])},M=(e,t)=>e&&e.experimental&&e.experimental[t]||!1,C=e=>{var t,i,o;return null!==(i=null===(t=r(e,"alt"))||void 0===t?void 0:t.trim())&&void 0!==i?i:null===(o=r(e,"src"))||void 0===o?void 0:o.trim()},R=(e,t)=>{if(g(t)){if(["style","script"].includes(t.tagName))return e;if("img"===t.tagName){const r=C(t);if(r)return`${e} ${r} `}return t.childNodes.reduce(R,e)}return v(t)?`${e}${t.value}`:e},O=(e,t)=>g(t)?["style","script"].includes(t.tagName)?e:"img"===t.tagName?`${e}${r(t,"alt")||""}`:t.childNodes.reduce(O,e):v(t)?`${e}${t.value}`:e,z=(e,t)=>{if(g(t)){if(["style","script"].includes(t.tagName))return e;if("img"===t.tagName){const r=C(t);if(r)return`${e} ${r} `}return"br"===t.tagName?`${e}\n`:"p"===t.tagName?t.childNodes.reduce(z,`${e}\n`):t.childNodes.reduce(z,e)}if(v(t)){const r=t.value.replace(/[\t\n\r]/g," ");if(r)return`${e}${r}`}return e},B=e=>e.childNodes.reduce(z,"").replace(/ +/g," ").replace(/ ?\n ?/g,"\n").trim(),W=(e,t)=>M(t,"textContent")?B(e):e.childNodes.reduce(R,"").trim(),_=e=>{var t;return null!==(t=a(e,["img","area"],"alt"))&&void 0!==t?t:a(e,["abbr"],"title")},A=e=>{const t=e.childNodes.filter(g);return t.length?_(t[0]):void 0},L=(e,t,r)=>{var o,n,a;if(!t.some((e=>i(e,/^(p|e|h)-/).length)))return null!==(a=null!==(n=null!==(o=_(e))&&void 0!==o?o:A(e))&&void 0!==n?n:(e=>{const t=e.childNodes.filter(g);return 1===t.length?A(t[0]):void 0})(e))&&void 0!==a?a:((e,t)=>M(t,"textContent")?B(e):e.childNodes.reduce(O,"").trim())(e,r)},K=e=>a(e,["a","area"],"href"),S=e=>{const t=e.childNodes.filter(g),r=t.filter((e=>"a"===e.tagName)),i=t.filter((e=>"area"===e.tagName));for(const e of[r,i])if(1===e.length&&!y(e[0]))return K(e[0])},q=(e,t)=>{var r,o;if(!t.some((e=>i(e,"u-").length)))return null!==(o=null!==(r=K(e))&&void 0!==r?r:S(e))&&void 0!==o?o:(e=>{const t=e.childNodes.filter(g);return 1===t.length?S(t[0]):void 0})(e)},H=(e,{inherited:t}={})=>{if("img"!==e.tagName)return;const i=(!t||!t.roots||!t.roots.length)&&r(e,"alt"),o=r(e,"src");return i?{alt:i,value:o}:o},P=e=>"img"===e.tagName?H(e):"object"===e.tagName?r(e,"data"):void 0,I=e=>{const t=e.childNodes.filter(g),r=t.filter((e=>"img"===e.tagName)),i=t.filter((e=>"object"===e.tagName));for(const e of[r,i])if(1===e.length&&!y(e[0]))return P(e[0])},D=(e,t)=>{var r,o;if(!t.some((e=>i(e,"u-").length)))return null!==(o=null!==(r=P(e))&&void 0!==r?r:I(e))&&void 0!==o?o:(e=>{const t=e.childNodes.filter(g);return 1===t.length?I(t[0]):void 0})(e)},F=e=>{if(((e,t)=>i(e).some((e=>"value-title"===e)))(e))return r(e,"title")},G=(e,t)=>{const i=U(e,k);if(i.length){if(t.datetime){const e=i.map((e=>{var i,o;return null!==(o=null!==(i=(e=>r(e,"datetime"))(e))&&void 0!==i?i:F(e))&&void 0!==o?o:W(e,t)}));return e.sort((e=>e.match(/^[0-9]{4}/)?-1:1)).join(" ").trim().replace(/((\+|-)[0-2][0-9]):([0-5][0-9])$/,(e=>e.replace(":",""))).replace(/([0-2]?[0-9])(:[0-5][0-9])?(:[0-5][0-9])?(a\.?m\.?|p\.?m\.?)/i,((e,t,r,i,o)=>`${/a/i.test(o)?t.padStart(2,"0"):`${parseInt(t,10)+12}`}${r||":00"}${i||""}`)).toUpperCase()}return i.map((e=>{var r;return null!==(r=F(e))&&void 0!==r?r:W(e,t)})).join("").trim()}},J=e=>!e.includes("://")&&!e.startsWith("#"),Q=(e,t)=>new URL(e,t).toString(),V=/^(p|u|e|dt)-/,X=(e,t)=>{var r,i,o,n,l;return null!==(l=null!==(n=null!==(o=null!==(i=null!==(r=G(e,{...t,datetime:!0}))&&void 0!==r?r:a(e,["time","ins","del"],"datetime"))&&void 0!==i?i:a(e,["abbr"],"title"))&&void 0!==o?o:a(e,["data","input"],"value"))&&void 0!==n?n:a(e,["meta"],"content"))&&void 0!==l?l:W(e,t)},Y=(t,i)=>{const o={value:W(t,i),html:e.serialize(t).trim()},n=M(i,"lang")&&(r(t,"lang")||i.inherited.lang);return n?{...o,lang:n}:o},Z=(e,t,r)=>"p"===t?((e,t)=>{var r,i,o,n,l;return null!==(l=null!==(n=null!==(o=null!==(i=null!==(r=G(e,t))&&void 0!==r?r:a(e,["abbr","link"],"title"))&&void 0!==i?i:a(e,["data"],"value"))&&void 0!==o?o:a(e,["img","area"],"alt"))&&void 0!==n?n:a(e,["meta"],"content"))&&void 0!==l?l:W(e,t)})(e,r):"e"===t?Y(e,r):"u"===t?((e,t)=>{var r,i,o,n,l,s,u,d,p;const c=null!==(p=null!==(d=null!==(u=null!==(s=null!==(l=null!==(n=null!==(o=null!==(i=null!==(r=a(e,["a","area","link"],"href"))&&void 0!==r?r:H(e,t))&&void 0!==i?i:a(e,["audio","source","iframe","video"],"src"))&&void 0!==o?o:a(e,["video"],"poster"))&&void 0!==n?n:a(e,["object"],"data"))&&void 0!==l?l:G(e,t))&&void 0!==s?s:a(e,["abbr"],"title"))&&void 0!==u?u:a(e,["data","input"],"value"))&&void 0!==d?d:a(e,["meta"],"content"))&&void 0!==p?p:W(e,t);return"string"==typeof c&&J(c)?Q(c,t.baseUrl):"string"==typeof c?c.trim():c})(e,r):X(e,r),ee=(e,t)=>((e,{inherited:t})=>t.roots.length?((e,t)=>[...new Set(t.map((t=>{const{properties:i,rels:n}=u[t],a=o(e,Object.keys(i)).map((e=>i[e])),l=n&&((e,t)=>{var i;return(null===(i=r(e,"rel"))||void 0===i?void 0:i.split(" ").filter((e=>t.includes(e))))||[]})(e,Object.keys(n)).map((e=>n[e]))||[];return[...a,...l]})).reduce(s))])(e,t.roots):i(e,/^(p|u|e|dt)-/))(e,t).map((r=>{const i=(e=>(e.startsWith("p-")?"p":e.startsWith("u-")&&"u")||e.startsWith("e-")&&"e"||"dt")(r),o=r.replace(V,"");return{type:i,key:o,value:["u","p","e","dt"].includes(i)&&N(e)?ae(e,{...t,valueType:i,valueKey:o}):Z(e,i,t)}})).filter((e=>Boolean(e))),te=(e,t,r)=>{var i;if("dt"===e.type&&"end"===e.key&&"string"==typeof e.value&&!e.value.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}/)&&e.value.match(/^[0-9]{2}:[0-9]{2}/)){const t=null===(i=r.find((t=>"dt"===t.type&&"start"===t.key&&"string"==typeof e.value)))||void 0===i?void 0:i.value;if(t){const r=t.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}/);return{...e,value:`${r} ${e.value}`}}}return e},re=(e,{key:t,value:r})=>{void 0!==r&&(e[t]||Array.isArray(e[t])?e[t].push(r):e[t]=[r])},ie=(e,t)=>{const r={},i=((e,t)=>t.inherited.roots.length?U(e,b):U(e,w))(e,t);return i.map((e=>ee(e,t))).reduce(s,[]).map(te).forEach((e=>re(r,e))),t.implyProperties&&!t.inherited.roots.length&&(void 0===r.name&&re(r,{key:"name",value:L(e,i,t)}),void 0===r.url&&re(r,{key:"url",value:q(e,i)}),void 0===r.photo&&re(r,{key:"photo",value:D(e,i)})),r},oe=(e,t)=>{const o=(e=>{const t=r(e,"itemref");if(t)return t.split(" ");if(i(e).includes("include")){const t="object"===e.tagName?"data":"href",i=r(e,t);if(i&&i.startsWith("#"))return[i.substring(1)]}const o="td"===e.tagName&&r(e,"headers");return o?[o]:[]})(e);o.forEach((r=>{const i=t.idRefs[r];i&&e.childNodes.push(i)})),e.childNodes.forEach((e=>g(e)&&!N(e)&&oe(e,t)))},ne=e=>{const t=i(e,"h-");return t.length?t:(e=>{const t=p(e).map((e=>u[e].type)).reduce(s);return t.length>1?t.filter((e=>"h-item"!==e)):t})(e)},ae=(e,t)=>{var i,o,n;((e,t)=>{y(e)||oe(e,t)})(e,t);const a=(e=>y(e)?[]:p(e))(e),l=(e=>y(e)?r(e,"id"):void 0)(e),s=r(e,"lang")||t.inherited.lang,u=U(e,$),d={lang:s,roots:a},c={type:ne(e).sort(),properties:ie(e,{...t,implyProperties:!u.length,inherited:d})};if(l&&(c.id=l),M(t,"lang")&&s&&(c.lang=s),u.length&&(c.children=u.map((e=>ae(e,{...t,inherited:d})))),"p"===t.valueType&&(c.value=null!==(o=null!==(i=c.properties.name&&c.properties.name[0])&&void 0!==i?i:r(e,"title"))&&void 0!==o?o:W(e,t)),"u"===t.valueType&&(c.value=null!==(n=c.properties.url&&c.properties.url[0])&&void 0!==n?n:W(e,t)),"dt"===t.valueType&&(c.value=X(e,t)),"e"===t.valueType)return{...Y(e,t),...c};if(t.valueKey&&!c.value){const e=c.properties[t.valueKey]&&c.properties[t.valueKey][0];e&&(c.value="string"==typeof e?e:e.value)}return c},le=(e,t)=>{if(void 0===e)throw new TypeError(`Microformats parser: ${t} not provided`);if("string"!=typeof e)throw new TypeError(`Microformats parser: ${t} is not a string`);if(""===e)throw new TypeError(`Microformats parser: ${t} cannot be empty`);return e},se=(e,t)=>{if("boolean"!=typeof e)throw new TypeError(`Microformats parser: ${t} is not a boolean`);return e},ue=(e,t,r)=>{if(void 0===e)throw new TypeError(`Microformats parser: ${r} is not provided`);if("object"!=typeof e)throw new TypeError(`Microformats parser: ${r} is not an object`);if(Array.isArray(e))throw new TypeError(`Microformats parser: ${r} is not an object`);if(null===e)throw new TypeError(`Microformats parser: ${r} cannot be null`);const i=Object.keys(e).filter((e=>!t.includes(e)));if(i.length)throw new TypeError(`Microformats parser: ${r} contains unknown properties: ${i.join(", ")}`);return e},de=(e,{rels:t,relUrls:i},o)=>{var n;const a=((e,t)=>M(t,"textContent")?B(e):e.childNodes.reduce(O,""))(e,o),l=r(e,"rel"),s=null===(n=r(e,"href"))||void 0===n?void 0:n.trim(),u=r(e,"title"),d=r(e,"media"),p=r(e,"hreflang"),c=r(e,"type");l&&s&&l.split(" ").forEach((e=>{t[e]||(t[e]=[]),t[e].includes(s)||t[e].push(s),i[s]?i[s].rels.includes(e)||(i[s].rels.push(e),i[s].rels.sort()):i[s]={rels:[e],text:a},a&&!i[s].text&&(i[s].text=a),u&&!i[s].title&&(i[s].title=u),d&&!i[s].media&&(i[s].media=d),p&&!i[s].hreflang&&(i[s].hreflang=p),c&&!i[s].type&&(i[s].type=c)}))},pe=e=>{for(const t of e.childNodes){if(!g(t))continue;if(x(t))return r(t,"href");const e=pe(t);if(e)return e}},ce=(e,i,o)=>{for(const n in e.childNodes){const a=e.childNodes[n];if(!g(a))continue;"template"===a.tagName&&delete e.childNodes[n],i.lang||("html"===a.tagName&&(i.lang=r(a,"lang")),"meta"===a.tagName&&"Content-Language"===r(a,"http-equiv")&&(i.lang=r(a,"content"))),("object"===a.tagName?["data"]:["href","src"]).forEach((e=>{const r=t(a,e);r&&J(r.value)?r.value=Q(r.value,i.baseUrl):r&&(r.value=r.value.trim())}));const l=r(a,"id");l&&!i.idRefs[l]&&(i.idRefs[l]=a),j(a)&&de(a,i,o),ce(a,i,o)}},me="