var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __esm = (fn, res) => function() {
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: !0 });
};

// src/utils/jsonld.ts
import memoized from "nano-memoize";
var parse, getObject, jsonld_default, init_jsonld = __esm({
  "src/utils/jsonld.ts"() {
    "use strict";
    parse = memoized((document) => {
      let json = document.querySelector(
        'script[type="application/ld+json"]'
      )?.textContent;
      if (json)
        return JSON.parse(json);
    }), getObject = memoized(
      (graph, name, predicate = (thing) => !0) => {
        if (!graph || !name)
          return [];
        let { "@graph": innerGraph, ...properties } = graph, result = properties[name] ? [properties[name]] : [];
        if (innerGraph)
          for (let element of innerGraph)
            predicate(element) && typeof element == "object" && name in element && result.push(element[name]);
        return result;
      }
    ), jsonld_default = Object.assign(parse, { getObject });
  }
});

// src/utils/elements.ts
function attribute(name, elements) {
  return Array.from(elements).map((it) => it.getAttribute(name)).filter((it) => it !== null);
}
var textContent, elements_default, init_elements = __esm({
  "src/utils/elements.ts"() {
    "use strict";
    textContent = (elements) => Array.from(elements).map(
      (it) => it.textContent ?? it.innerText
    );
    elements_default = {
      textContent,
      attribute
    };
  }
});

// src/utils/memoized-functions.ts
import memoized2 from "nano-memoize";
import { default as _condenseWhitespace } from "condense-whitespace";
import { distance } from "fastest-levenshtein";
import { interopImportCJSDefault } from "node-cjs-interop";
import _deepMerge from "ts-deepmerge";
import _dedupe from "dedupe";
import { crush } from "html-crush";
var condenseWhitespace, closest, deepMerge, dedupe, minifyHtml, init_memoized_functions = __esm({
  "src/utils/memoized-functions.ts"() {
    "use strict";
    condenseWhitespace = memoized2(_condenseWhitespace), closest = memoized2((source, ...targets) => {
      let distribution = Number.POSITIVE_INFINITY, result;
      for (let target of targets) {
        let current = distance(source, target);
        distribution < current && (result = target, distribution = current);
      }
      return { source, result, distance: distribution };
    }), deepMerge = memoized2(interopImportCJSDefault(_deepMerge)), dedupe = memoized2(_dedupe), minifyHtml = memoized2(
      (html, options) => crush(html, {
        removeLineBreaks: !0,
        removeHTMLComments: !0,
        removeCSSComments: !0,
        ...options
      }).result
    );
  }
});

// src/utils/extractors.ts
import memoized3 from "nano-memoize";
var ExtractOperators, init_extractors = __esm({
  "src/utils/extractors.ts"() {
    "use strict";
    ExtractOperators = class extends Array {
      constructor(items = {}) {
        super(
          ...Object.entries(items).map(
            (it) => [it[0], memoized3(it[1])]
          )
        );
      }
      push(...items) {
        let keys = /* @__PURE__ */ new Set(), index = this.length;
        for (; index--; ) {
          let current = items[index][0];
          keys.has(current) ? items.splice(index, 1) : keys.add(current);
        }
        return this.removeIf(([it]) => keys.has(it)), super.push(...items);
      }
      set(key, extractor, index = this.findIndex(([it]) => it === key)) {
        return this.removeIf(([it]) => it === key), index === -1 ? this.push([key, memoized3(extractor)]) : this.splice(index, 0, [key, memoized3(extractor)]), this;
      }
      get = (key) => this.find(([it]) => it === key);
      removeIf(callback) {
        let index = this.length;
        for (; index--; )
          callback(this[index], index) && this.splice(index, 1);
      }
    };
  }
});

// src/utils/urls.ts
import _normalizeUrl from "normalize-url";
import { relativeToAbsolute } from "@availity/resolve-url";
import memoized5 from "nano-memoize";
var normalizeUrl, absolutifyUrl, absolutifyDocument, init_urls = __esm({
  "src/utils/urls.ts"() {
    "use strict";
    normalizeUrl = memoized5(
      (url) => _normalizeUrl(url, {
        stripWWW: !1,
        sortQueryParameters: !1,
        removeSingleSlash: !1,
        removeTrailingSlash: !1
      })
    ), absolutifyUrl = memoized5(
      (base = "", relative = "") => relativeToAbsolute(relative, base)
    ), absolutifyDocument = memoized5(
      (document, baseUrl = document.baseURI) => {
        if (!baseUrl)
          return document;
        for (let element of Array.from(document.querySelectorAll("a"))) {
          let href = element.getAttribute("href");
          href && element.setAttribute("href", absolutifyUrl(baseUrl, href));
        }
        for (let element of Array.from(document.querySelectorAll("img"))) {
          let source = element.dataset.src ?? element.getAttribute("src");
          source && element.setAttribute("src", absolutifyUrl(baseUrl, source));
        }
        return document;
      }
    );
  }
});

// src/author-extractor.ts
var author_extractor_exports = {};
__export(author_extractor_exports, {
  default: () => author_extractor_default
});
import isStringBlank2 from "is-string-blank";
import memoized7 from "nano-memoize";
var author_extractor_default, init_author_extractor = __esm({
  "src/author-extractor.ts"() {
    "use strict";
    init_jsonld();
    init_memoized_functions();
    init_elements();
    init_extractors();
    author_extractor_default = {
      operators: new ExtractOperators({
        jsonld: (document) => {
          let json = jsonld_default(document);
          return jsonld_default.getObject(
            json,
            "author",
            (it) => typeof it != "string" && !["EndorsementRating", "AggregateRating", "Rating"].includes(
              it["@type"]
            )
          ).flatMap((author) => author === void 0 ? [] : typeof author == "string" ? [author] : Array.isArray(author) ? author.flatMap((it) => {
            if (typeof it == "string")
              return [it];
            if ("name" in it) {
              let name = it.name;
              if (typeof name == "string")
                return [name];
              if (typeof it == "object" && "textValue" in it)
                return [it.textValue];
            } else if ("@id" in it) {
              let id = it["@id"];
              if (typeof id == "string")
                return [id];
            }
            return [];
          }) : author && "name" in author ? [author.name?.toString()] : author && "@id" in author ? [author["@id"]] : []);
        },
        meta: (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[name="author" i]')
        ),
        "itemprop name": (document) => elements_default.textContent(
          document.querySelectorAll('[itemprop*="author" i] [itemprop="name"]')
        ),
        itemprop: (document) => elements_default.textContent(document.querySelectorAll('[itemprop*="author" i]')),
        rel: (document) => elements_default.textContent(document.querySelectorAll('[rel="author"]')),
        "a class": (document) => elements_default.textContent(document.querySelectorAll('a[class*="author" i]')),
        "class a": (document) => elements_default.textContent(document.querySelectorAll('[class*="author" i] a')),
        href: (document) => elements_default.textContent(document.querySelectorAll('a[href*="/author/" i]')),
        class: (document) => elements_default.textContent(document.querySelectorAll('[class*="author" i]'))
      }),
      processor: memoized7(
        (value) => value.filter((it) => !isStringBlank2(it)).map((it) => condenseWhitespace(it))
      ),
      selector: (source) => ({ author: { name: source[0] } })
    };
  }
});

// src/author-url-extractor.ts
var author_url_extractor_exports = {};
__export(author_url_extractor_exports, {
  default: () => author_url_extractor_default
});
import isURI2 from "@stdlib/assert-is-uri";
import memoized8 from "nano-memoize";
var author_url_extractor_default, init_author_url_extractor = __esm({
  "src/author-url-extractor.ts"() {
    "use strict";
    init_jsonld();
    init_elements();
    init_urls();
    init_extractors();
    author_url_extractor_default = {
      operators: new ExtractOperators({
        jsonld: (document) => {
          let json = jsonld_default(document);
          return jsonld_default.getObject(
            json,
            "author",
            (it) => typeof it != "string" && !["EndorsementRating", "AggregateRating", "Rating"].includes(
              it["@type"]
            )
          ).flatMap((author) => author === void 0 ? [] : typeof author == "string" ? [author] : Array.isArray(author) ? author.flatMap((it) => {
            if (typeof it == "string")
              return [it];
            if ("name" in it) {
              let url = it.url;
              if (typeof url == "string")
                return [url];
            } else if ("@id" in it)
              return [it["@id"]];
            return [];
          }) : author && "url" in author ? [author.url?.toString()] : author && "@id" in author ? [author["@id"]] : []);
        },
        "meta article": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[property="article:author"]')
        ),
        "itemprop url": (document) => elements_default.attribute(
          "href",
          document.querySelectorAll(
            '[itemprop*="author" i] [itemprop="url"][href]'
          )
        ),
        itemprop: (document) => elements_default.attribute(
          "href",
          document.querySelectorAll('[itemprop*="author" i][href]')
        ),
        rel: (document) => elements_default.attribute(
          "href",
          document.querySelectorAll('[rel="author"][href]')
        ),
        "a class": (document) => elements_default.attribute(
          "href",
          document.querySelectorAll('a[class*="author" i][href]')
        ),
        "class a": (document) => elements_default.attribute(
          "href",
          document.querySelectorAll('[class*="author" i] a[href]')
        ),
        href: (document) => elements_default.attribute(
          "href",
          document.querySelectorAll('a[href*="/author/" i]')
        )
      }),
      processor: memoized8(
        (value, context) => value.map((it) => normalizeUrl(absolutifyUrl(context?.url, it))).filter((it) => isURI2(it))
      ),
      selector: (source) => ({ author: { url: source[0] } })
    };
  }
});

// src/utils/parse-date.ts
import {
  Constants,
  Culture,
  recognizeDateTime
} from "@microsoft/recognizers-text-date-time";
import isDigitString from "@stdlib/assert-is-digit-string";
import dedupe2 from "dedupe";
import containsChinese from "contains-chinese";
import memoized9 from "nano-memoize";
var parse2, toDate, resultToDate, guessLocale, parse_date_default, init_parse_date = __esm({
  "src/utils/parse-date.ts"() {
    "use strict";
    parse2 = memoized9(
      (input, lang) => {
        lang && (lang = Culture.mapToNearestLanguage(lang)), isDigitString(input) && (input = Number.parseInt(input));
        let date = new Date(input);
        if (Number.isNaN(date.getTime()) && typeof input == "string") {
          let results = recognizeDateTime(
            input,
            lang ?? Culture.mapToNearestLanguage(guessLocale(input))
          );
          return resultToDate(results);
        }
        return Number.isNaN(date.getTime()) ? void 0 : date;
      }
    ), toDate = ({ typeName, resolution }) => new Date(
      typeName.endsWith("range") ? resolution.values[0].end : resolution.values[0].value
    ), resultToDate = memoized9((results) => {
      results = dedupe2(results, (it) => it.typeName);
      let accumulator = new Date(), success = !1;
      for (let result of results) {
        let date = toDate(result);
        result.typeName.includes(`.${Constants.SYS_DATETIME_DATETIME}`) ? (accumulator = date, success = !0) : result.typeName.includes(`.${Constants.SYS_DATETIME_DATE}`) ? (accumulator.setFullYear(
          date.getFullYear(),
          date.getMonth(),
          date.getDate()
        ), success = !0) : result.typeName.includes(`.${Constants.SYS_DATETIME_TIME}`) && (accumulator.setHours(
          date.getHours(),
          date.getMinutes(),
          date.getSeconds(),
          date.getMilliseconds()
        ), success = !0);
      }
      if (success)
        return Number.isNaN(accumulator.getTime()) ? void 0 : accumulator;
    }), guessLocale = (input) => containsChinese(input) ? Culture.Chinese : Culture.English, parse_date_default = parse2;
  }
});

// src/published-date-extractor.ts
var published_date_extractor_exports = {};
__export(published_date_extractor_exports, {
  default: () => published_date_extractor_default
});
import isStringBlank3 from "is-string-blank";
import memoized10 from "nano-memoize";
var published_date_extractor_default, init_published_date_extractor = __esm({
  "src/published-date-extractor.ts"() {
    "use strict";
    init_jsonld();
    init_parse_date();
    init_elements();
    init_extractors();
    published_date_extractor_default = {
      operators: new ExtractOperators({
        jsonld: (document) => {
          let json = jsonld_default(document);
          return [
            ...jsonld_default.getObject(
              json,
              "datePublished"
            ),
            ...jsonld_default.getObject(
              json,
              "dateCreated"
            )
          ];
        },
        "meta published": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[property*="published_time" i]')
        ),
        "meta release": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[property*="release_date" i]')
        ),
        "itemprop published": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('[itemprop="datepublished" i]')
        ),
        "time pubdate": (document) => elements_default.attribute(
          "datetime",
          document.querySelectorAll("time[datetime][pubdate]")
        ),
        "meta dc date issued": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[name*="dc.date.issued" i]')
        ),
        "meta dc date created": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[name*="dc.date.created" i]')
        ),
        "property dc date created": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('[property*="dc:created" i]')
        ),
        "jsonld upload": (document) => {
          let json = jsonld_default(document);
          return jsonld_default.getObject(json, "uploadDate");
        },
        "meta date": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[property="date" i]')
        ),
        "time itemprop": (document) => elements_default.attribute(
          "datetime",
          document.querySelectorAll('time[itemprop*="date" i]')
        ),
        time: (document) => elements_default.attribute(
          "datetime",
          document.querySelectorAll("time[datetime]")
        ),
        itemprop: (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('[itemprop*="date" i]')
        ),
        "meta dc date": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[name*="dc.date" i]')
        ),
        "property dc date": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('[property*="dc:date" i]')
        ),
        "id publish": (document) => elements_default.textContent(document.querySelectorAll('[id*="publish" i]')),
        "id post timestamp": (document) => elements_default.textContent(
          document.querySelectorAll('[id*="post-timestamp" i]')
        ),
        "class publish": (document) => elements_default.textContent(document.querySelectorAll('[class*="publish" i]')),
        "class post timestamp": (document) => elements_default.textContent(
          document.querySelectorAll('[class*="post-timestamp" i]')
        ),
        "class byline": (document) => elements_default.textContent(document.querySelectorAll('[class*="byline" i]')),
        "class dateline": (document) => elements_default.textContent(document.querySelectorAll('[class*="dateline" i]')),
        "id metadata": (document) => elements_default.textContent(document.querySelectorAll('[id*="metadata" i]')),
        "class metadata": (document) => elements_default.textContent(document.querySelectorAll('[class*="metadata" i]')),
        "id date": (document) => elements_default.textContent(document.querySelectorAll('[id*="date" i]')),
        "class date": (document) => elements_default.textContent(document.querySelectorAll('[class*="date" i]')),
        "id post meta": (document) => elements_default.textContent(document.querySelectorAll('[id*="post-meta" i]')),
        "class post meta": (document) => elements_default.textContent(document.querySelectorAll('[class*="post-meta" i]')),
        "id time": (document) => elements_default.textContent(document.querySelectorAll('[id*="time" i]')),
        "class time": (document) => elements_default.textContent(document.querySelectorAll('[class*="time" i]'))
      }),
      processor: memoized10((value) => value.filter((it) => !isStringBlank3(it))),
      selector: (source) => {
        let date;
        for (let string of source)
          if (date = parse_date_default(string), date)
            break;
        return {
          date: { published: date }
        };
      }
    };
  }
});

// src/modified-date-extractor.ts
var modified_date_extractor_exports = {};
__export(modified_date_extractor_exports, {
  default: () => modified_date_extractor_default
});
import isStringBlank4 from "is-string-blank";
import memoized11 from "nano-memoize";
var modified_date_extractor_default, init_modified_date_extractor = __esm({
  "src/modified-date-extractor.ts"() {
    "use strict";
    init_parse_date();
    init_jsonld();
    init_elements();
    init_extractors();
    modified_date_extractor_default = {
      operators: new ExtractOperators({
        jsonld: (document) => {
          let json = jsonld_default(document);
          return [
            ...jsonld_default.getObject(
              json,
              "dateModified"
            ),
            ...jsonld_default.getObject(json, "uploadDate")
          ];
        },
        "meta updated": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[property*="updated_time" i]')
        ),
        "meta modified": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('meta[property*="modified_time" i]')
        ),
        "itemprop modified": (document) => elements_default.attribute(
          "content",
          document.querySelectorAll('[itemprop*="datemodified" i]')
        )
      }),
      processor: memoized11((value) => value.filter((it) => !isStringBlank4(it))),
      selector: (source) => {
        let date;
        for (let string of source)
          if (date = parse_date_default(string), date)
            break;
        return {
          date: { modified: date }
        };
      }
    };
  }
});

// src/content-extractor/selector-extractors.ts
var selectors, init_selector_extractors = __esm({
  async "src/content-extractor/selector-extractors.ts"() {
    "use strict";
    globalThis.URLPattern || await import("urlpattern-polyfill");
    selectors = /* @__PURE__ */ new Map();
  }
});

// src/utils/sanitize-html.ts
import memoized12 from "nano-memoize";
import sanitize from "sanitize-html";
var defaultSanitizeOptions, sanitizeHtml, sanitize_html_default, init_sanitize_html = __esm({
  "src/utils/sanitize-html.ts"() {
    "use strict";
    defaultSanitizeOptions = {
      allowVulnerableTags: !0,
      allowedTags: [
        "h1",
        "h2",
        "h3",
        "h4",
        "h5",
        "h6",
        "u",
        "b",
        "i",
        "em",
        "strong",
        "small",
        "sup",
        "sub",
        "div",
        "span",
        "p",
        "article",
        "blockquote",
        "section",
        "details",
        "summary",
        "pre",
        "code",
        "ul",
        "ol",
        "li",
        "dd",
        "dl",
        "table",
        "th",
        "tr",
        "td",
        "thead",
        "tbody",
        "tfood",
        "fieldset",
        "legend",
        "figure",
        "figcaption",
        "img",
        "picture",
        "video",
        "audio",
        "source",
        "iframe",
        "progress",
        "br",
        "p",
        "hr",
        "label",
        "abbr",
        "a",
        "svg",
        "meta",
        "head",
        "title",
        "link",
        "script",
        "html",
        "body"
      ],
      allowedAttributes: {
        h1: ["id"],
        h2: ["id"],
        h3: ["id"],
        h4: ["id"],
        h5: ["id"],
        h6: ["id"],
        a: ["href", "target", "title"],
        abbr: ["title"],
        progress: ["value", "max"],
        img: ["src", "srcset", "alt", "title"],
        picture: ["media", "srcset"],
        video: ["controls", "width", "height", "autoplay", "muted", "loop", "src"],
        audio: ["controls", "width", "height", "autoplay", "muted", "loop", "src"],
        source: ["src", "srcset", "data-srcset", "type", "media", "sizes"],
        iframe: ["src", "frameborder", "height", "width", "scrolling", "allow"],
        svg: ["width", "height"],
        meta: ["content", "property", "name"],
        link: ["href", "rel"],
        script: [
          {
            name: "type",
            values: ["application/ld+json"]
          }
        ]
      }
    }, sanitizeHtml = memoized12(sanitize), sanitize_html_default = sanitizeHtml;
  }
});

// src/content-extractor/index.ts
var content_extractor_exports = {};
__export(content_extractor_exports, {
  default: () => content_extractor_default
});
import { Readability } from "@mozilla/readability";
import isStringBlank5 from "is-string-blank";
var content_extractor_default, init_content_extractor = __esm({
  async "src/content-extractor/index.ts"() {
    "use strict";
    await init_selector_extractors();
    init_extractors();
    init_sanitize_html();
    init_memoized_functions();
    content_extractor_default = {
      operators: new ExtractOperators({
        readability: (document) => [new Readability(document).parse()?.content],
        selector: (document, url) => {
          let result = "";
          for (let [key, value] of selectors.entries())
            if (key.test(url)) {
              if (value.ignored)
                for (let ignored of value.ignored)
                  for (let it of Array.from(document.querySelectorAll(ignored)))
                    it.remove();
              for (let selector of value.selector)
                for (let it of Array.from(document.querySelectorAll(selector)))
                  result += it.outerHTML;
            }
          return [result];
        }
      }),
      processor: (value) => value.filter((it) => !isStringBlank5(it)),
      selector: (source, title, context) => ({
        content: minifyHtml(
          sanitize_html_default(source[0], context?.sanitizeHtml ?? defaultSanitizeOptions)
        )
      })
    };
  }
});

// src/title-extractor.ts
init_jsonld();
init_elements();
init_memoized_functions();
init_extractors();
import memoized4 from "nano-memoize";
import isStringBlank from "is-string-blank";
var SEPARATORS = ["|", "-", "\\", "/", ">", "\xBB", "\xB7", "\u2013"].map(
  (it) => ` ${it} `
), title_extractor_default = {
  operators: new ExtractOperators({
    jsonld: (document) => {
      let json = jsonld_default(document);
      return jsonld_default.getObject(json, "headline");
    },
    "meta og": (document) => elements_default.attribute(
      "content",
      document.querySelectorAll('meta[property="og:title"]')
    ),
    "meta twitter": (document) => elements_default.attribute(
      "content",
      document.querySelectorAll('meta[property="twitter:title"]')
    ),
    "meta twitter attr name": (document) => elements_default.attribute(
      "content",
      document.querySelectorAll('meta[name="twitter:title"]')
    ),
    "post title class": (document) => elements_default.textContent(document.querySelectorAll(".post-title")),
    "entry title class": (document) => elements_default.textContent(document.querySelectorAll(".entry-title")),
    "h1 h2 like title": (document) => elements_default.textContent(
      document.querySelectorAll(':is(h1, h2)[class*="title" i]')
    ),
    title: (document) => [document.title]
  }),
  processor: memoized4(
    (value) => value.filter((it) => !isStringBlank(it)).map((it) => splitTitle(condenseWhitespace(it)))
  ),
  selector: (source) => ({ title: source[0] })
}, splitTitle = memoized4((title) => {
  let separatorIndex = SEPARATORS.map((it) => title.lastIndexOf(it)).find(
    (it) => it !== -1
  );
  return separatorIndex !== void 0 ? title.slice(0, separatorIndex) : title;
});

// src/url-extractor.ts
init_jsonld();
init_urls();
init_memoized_functions();
init_elements();
init_extractors();
import isURI from "@stdlib/assert-is-uri";
import memoized6 from "nano-memoize";
var url_extractor_default = {
  operators: new ExtractOperators({
    jsonld: (document) => {
      let json = jsonld_default(document);
      return jsonld_default.getObject(
        json,
        "url",
        (it) => typeof it != "string" && "headline" in it
      );
    },
    "meta og": (document) => elements_default.attribute(
      "content",
      document.querySelectorAll('meta[property="og:url"]')
    ),
    "meta twitter": (document) => elements_default.attribute(
      "content",
      document.querySelectorAll('meta[property="twitter:url"]')
    ),
    "meta twitter attr name": (document) => elements_default.attribute(
      "content",
      document.querySelectorAll('meta[name="twitter:url"]')
    ),
    "link canonical": (document) => elements_default.attribute(
      "href",
      document.querySelectorAll('link[rel="canonical"]')
    ),
    "link alternate": (document) => elements_default.attribute(
      "href",
      document.querySelectorAll('link[rel="alternate"]')
    ),
    "post title class": (document) => elements_default.attribute("href", document.querySelectorAll(".post-title a")),
    "entry title class": (document) => elements_default.attribute("href", document.querySelectorAll(".entry-title a")),
    "h1 h2 like title": (document) => elements_default.attribute(
      "href",
      document.querySelectorAll(':is(h1, h2)[class*="title" i] a')
    )
  }),
  processor: memoized6(
    (value, context) => value.map((it) => normalizeUrl(absolutifyUrl(context?.url, it))).filter((it) => isURI(it))
  ),
  selector: memoized6((value, title, context) => {
    if (context?.url && value.push(context?.url), !title)
      return { url: value[0] };
    let { distance: distance2, result } = closest(title, ...value);
    return distance2 > 0.7 * title.length ? { url: context?.url ?? value[0] } : { url: result };
  })
};

// src/browser/linkedom.ts
var DOMParser = globalThis.DOMParser;

// src/default-extractors.ts
var defaultExtractors = await Promise.all([
  Promise.resolve().then(() => (init_author_extractor(), author_extractor_exports)),
  Promise.resolve().then(() => (init_author_url_extractor(), author_url_extractor_exports)),
  Promise.resolve().then(() => (init_published_date_extractor(), published_date_extractor_exports)),
  Promise.resolve().then(() => (init_modified_date_extractor(), modified_date_extractor_exports)),
  init_content_extractor().then(() => content_extractor_exports)
]).then((it) => it.map((it2) => it2.default)), default_extractors_default = defaultExtractors;

// src/index.ts
init_memoized_functions();
init_sanitize_html();
init_urls();
await init_selector_extractors();
async function extract(html, options = {}) {
  let finalOptions = {
    extractors: default_extractors_default,
    sanitizeHtml: defaultSanitizeOptions,
    ...options
  }, document = typeof html == "string" ? new DOMParser().parseFromString(
    sanitize_html_default(html, finalOptions.sanitizeHtml),
    "text/html"
  ) : html;
  finalOptions.lang ??= document.documentElement.lang;
  let title = title_extractor_default.selector(
    title_extractor_default.processor(
      [
        ...title_extractor_default.operators.flatMap((it) => it[1](document)).filter((it) => !!it)
      ],
      finalOptions
    ),
    void 0,
    finalOptions
  ), url = url_extractor_default.selector(
    url_extractor_default.processor(
      [
        ...url_extractor_default.operators.flatMap((it) => it[1](document)).filter((it) => !!it)
      ],
      finalOptions
    ),
    title.title,
    finalOptions
  );
  if (!document.baseURI && url?.url) {
    let base = document.createElement("base");
    base.setAttribute("href", url.url), document.head.append(base);
  }
  document = absolutifyDocument(document);
  let context = {
    ...finalOptions,
    url: url?.url
  }, results = await Promise.all(finalOptions.extractors).then(
    (it) => it.map(({ operators, processor, selector }) => {
      let operated = operators.flatMap((it2) => it2[1](document, url.url)).filter((it2) => !!it2), processed = dedupe(processor([...operated], context), (it2) => it2);
      if (processed.length > 0)
        return selector(processed, title.title, context);
    }).filter((it2) => !!it2)
  );
  return deepMerge(title, url, ...results);
}
export {
  selectors as contentSelectors,
  extract
};
//# sourceMappingURL=article-extractor.node.browser.js.map
