var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __commonJS = (cb, mod) => function __require() {
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));

// ../../node_modules/is-url-superb/index.js
var require_is_url_superb = __commonJS({
  "../../node_modules/is-url-superb/index.js"(exports, module) {
    "use strict";
    module.exports = (string) => {
      if (typeof string !== "string") {
        throw new TypeError("Expected a string");
      }
      try {
        new URL(string);
        return true;
      } catch (e) {
        return false;
      }
    };
  }
});

// src/third-party/equation.tsx
import React15 from "react";
import Katex from "@matejmazur/react-katex";
import { getBlockTitle as getBlockTitle2 } from "notion-utils";

// src/context.tsx
import React14 from "react";

// src/components/asset-wrapper.tsx
import React11 from "react";

// src/components/asset.tsx
import React3 from "react";
import { getTextContent } from "notion-utils";

// src/components/lazy-image.tsx
import React from "react";
import { LazyImageFull, ImageState } from "react-lazy-images";
import { normalizeUrl } from "notion-utils";

// src/utils.ts
var import_is_url_superb = __toESM(require_is_url_superb(), 1);
var defaultMapImageUrl = (url, block) => {
  if (!url) {
    return null;
  }
  if (url.startsWith("data:")) {
    return url;
  }
  if (url.startsWith("https://images.unsplash.com")) {
    return url;
  }
  try {
    const u = new URL(url);
    if (u.pathname.startsWith("/secure.notion-static.com") && u.hostname.endsWith(".amazonaws.com")) {
      if (u.searchParams.has("X-Amz-Credential") && u.searchParams.has("X-Amz-Signature") && u.searchParams.has("X-Amz-Algorithm")) {
        return url;
      }
    }
  } catch (e) {
  }
  if (url.startsWith("/images")) {
    url = `https://www.notion.so${url}`;
  }
  url = `https://www.notion.so${url.startsWith("/image") ? url : `/image/${encodeURIComponent(url)}`}`;
  const notionImageUrlV2 = new URL(url);
  let table = block.parent_table === "space" ? "block" : block.parent_table;
  if (table === "collection") {
    table = "block";
  }
  notionImageUrlV2.searchParams.set("table", table);
  notionImageUrlV2.searchParams.set("id", block.id);
  notionImageUrlV2.searchParams.set("cache", "v2");
  url = notionImageUrlV2.toString();
  return url;
};
var defaultMapPageUrl = (rootPageId) => (pageId) => {
  pageId = (pageId || "").replace(/-/g, "");
  if (rootPageId && pageId === rootPageId) {
    return "/";
  } else {
    return `/${pageId}`;
  }
};
var cs = (...classes) => classes.filter((a) => !!a).join(" ");
var getHashFragmentValue = (url) => {
  return url.includes("#") ? url.replace(/^.+(#.+)$/, "$1") : "";
};
var months = [
  "Jan",
  "Feb",
  "Mar",
  "Apr",
  "May",
  "Jun",
  "Jul",
  "Aug",
  "Sep",
  "Oct",
  "Nov",
  "Dec"
];
var formatDate = (input) => {
  const date = new Date(input);
  const month = date.getMonth();
  return `${months[month]} ${date.getUTCDate()}, ${date.getUTCFullYear()}`;
};
var isBrowser = typeof window !== "undefined";
var youtubeDomains = /* @__PURE__ */ new Set([
  "youtu.be",
  "youtube.com",
  "www.youtube.com",
  "youtube-nocookie.com",
  "www.youtube-nocookie.com"
]);
var getYoutubeId = (url) => {
  try {
    const { hostname } = new URL(url);
    if (!youtubeDomains.has(hostname)) {
      return null;
    }
    const regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/i;
    const match = url.match(regExp);
    if (match && match[2].length == 11) {
      return match[2];
    }
  } catch (e) {
  }
  return null;
};

// src/components/lazy-image.tsx
var LazyImage = (_a) => {
  var _b = _a, {
    src,
    alt,
    className,
    style,
    zoomable = false,
    priority = false,
    height
  } = _b, rest = __objRest(_b, [
    "src",
    "alt",
    "className",
    "style",
    "zoomable",
    "priority",
    "height"
  ]);
  var _a2, _b2, _c;
  const { recordMap, zoom, previewImages, forceCustomImages, components } = useNotionContext();
  const zoomRef = React.useRef(zoom ? zoom.clone() : null);
  const previewImage = previewImages ? (_c = (_a2 = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _a2[src]) != null ? _c : (_b2 = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _b2[normalizeUrl(src)] : null;
  const onLoad = React.useCallback((e) => {
    if (zoomable && (e.target.src || e.target.srcset)) {
      if (zoomRef.current) {
        ;
        zoomRef.current.attach(e.target);
      }
    }
  }, [zoomRef, zoomable]);
  const attachZoom = React.useCallback((image) => {
    if (zoomRef.current && image) {
      ;
      zoomRef.current.attach(image);
    }
  }, [zoomRef]);
  const attachZoomRef = React.useMemo(() => zoomable ? attachZoom : void 0, [zoomable, attachZoom]);
  if (previewImage) {
    const aspectRatio = previewImage.originalHeight / previewImage.originalWidth;
    if (components.Image) {
      return /* @__PURE__ */ React.createElement(components.Image, {
        src,
        alt,
        style,
        className,
        width: previewImage.originalWidth,
        height: previewImage.originalHeight,
        blurDataURL: previewImage.dataURIBase64,
        placeholder: "blur",
        priority,
        onLoad
      });
    }
    return /* @__PURE__ */ React.createElement(LazyImageFull, __spreadProps(__spreadValues({
      src
    }, rest), {
      experimentalDecode: true
    }), ({ imageState, ref }) => {
      const isLoaded = imageState === ImageState.LoadSuccess;
      const wrapperStyle = {
        width: "100%"
      };
      const imgStyle = {};
      if (height) {
        wrapperStyle.height = height;
      } else {
        imgStyle.position = "absolute";
        wrapperStyle.paddingBottom = `${aspectRatio * 100}%`;
      }
      return /* @__PURE__ */ React.createElement("div", {
        className: cs("lazy-image-wrapper", isLoaded && "lazy-image-loaded", className),
        style: wrapperStyle
      }, /* @__PURE__ */ React.createElement("img", {
        className: "lazy-image-preview",
        src: previewImage.dataURIBase64,
        alt,
        ref,
        style,
        decoding: "async"
      }), /* @__PURE__ */ React.createElement("img", {
        className: "lazy-image-real",
        src,
        alt,
        ref: attachZoomRef,
        style: __spreadValues(__spreadValues({}, style), imgStyle),
        width: previewImage.originalWidth,
        height: previewImage.originalHeight,
        decoding: "async",
        loading: "lazy"
      }));
    });
  } else {
    if (components.Image && forceCustomImages) {
      return /* @__PURE__ */ React.createElement(components.Image, {
        src,
        alt,
        className,
        style,
        width: null,
        height: height || null,
        priority,
        onLoad
      });
    }
    return /* @__PURE__ */ React.createElement("img", __spreadValues({
      className,
      style,
      src,
      alt,
      ref: attachZoomRef,
      loading: "lazy",
      decoding: "async"
    }, rest));
  }
};

// src/components/lite-youtube-embed.tsx
import React2 from "react";
var qs = (params) => {
  return Object.keys(params).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join("&");
};
var LiteYouTubeEmbed = ({
  id,
  defaultPlay = false,
  mute = false,
  lazyImage = false,
  iframeTitle = "YouTube video",
  alt = "Video preview",
  params = {},
  adLinksPreconnect = true,
  style,
  className
}) => {
  const muteParam = mute || defaultPlay ? "1" : "0";
  const queryString = React2.useMemo(() => qs(__spreadValues({ autoplay: "1", mute: muteParam }, params)), [muteParam, params]);
  const resolution = "hqdefault";
  const posterUrl = `https://i.ytimg.com/vi/${id}/${resolution}.jpg`;
  const ytUrl = "https://www.youtube-nocookie.com";
  const iframeSrc = `${ytUrl}/embed/${id}?${queryString}`;
  const [isPreconnected, setIsPreconnected] = React2.useState(false);
  const [iframeInitialized, setIframeInitialized] = React2.useState(defaultPlay);
  const [isIframeLoaded, setIsIframeLoaded] = React2.useState(false);
  const warmConnections = React2.useCallback(() => {
    if (isPreconnected)
      return;
    setIsPreconnected(true);
  }, [isPreconnected]);
  const onLoadIframe = React2.useCallback(() => {
    if (iframeInitialized)
      return;
    setIframeInitialized(true);
  }, [iframeInitialized]);
  const onIframeLoaded = React2.useCallback(() => {
    setIsIframeLoaded(true);
  }, []);
  return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("link", {
    rel: "preload",
    href: posterUrl,
    as: "image"
  }), isPreconnected && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("link", {
    rel: "preconnect",
    href: ytUrl
  }), /* @__PURE__ */ React2.createElement("link", {
    rel: "preconnect",
    href: "https://www.google.com"
  })), isPreconnected && adLinksPreconnect && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("link", {
    rel: "preconnect",
    href: "https://static.doubleclick.net"
  }), /* @__PURE__ */ React2.createElement("link", {
    rel: "preconnect",
    href: "https://googleads.g.doubleclick.net"
  })), /* @__PURE__ */ React2.createElement("div", {
    onClick: onLoadIframe,
    onPointerOver: warmConnections,
    className: cs("notion-yt-lite", isIframeLoaded && "notion-yt-loaded", iframeInitialized && "notion-yt-initialized", className),
    style
  }, /* @__PURE__ */ React2.createElement("img", {
    src: posterUrl,
    className: "notion-yt-thumbnail",
    loading: lazyImage ? "lazy" : void 0,
    alt
  }), /* @__PURE__ */ React2.createElement("div", {
    className: "notion-yt-playbtn"
  }), iframeInitialized && /* @__PURE__ */ React2.createElement("iframe", {
    width: "560",
    height: "315",
    frameBorder: "0",
    allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
    allowFullScreen: true,
    title: iframeTitle,
    src: iframeSrc,
    onLoad: onIframeLoaded
  })));
};

// src/components/asset.tsx
var isServer = typeof window === "undefined";
var supportedAssetTypes = [
  "video",
  "image",
  "embed",
  "figma",
  "typeform",
  "excalidraw",
  "maps",
  "tweet",
  "pdf",
  "gist",
  "codepen",
  "drive"
];
var Asset = ({ block, children }) => {
  var _a, _b, _c, _d, _e, _f;
  const { recordMap, mapImageUrl, components } = useNotionContext();
  if (!block || !supportedAssetTypes.includes(block.type)) {
    return null;
  }
  const style = {
    position: "relative",
    display: "flex",
    justifyContent: "center",
    alignSelf: "center",
    width: "100%",
    maxWidth: "100%",
    flexDirection: "column"
  };
  const assetStyle = {};
  if (block.format) {
    const {
      block_aspect_ratio,
      block_height,
      block_width,
      block_full_width,
      block_page_width,
      block_preserve_scale
    } = block.format;
    if (block_full_width || block_page_width) {
      if (block_full_width) {
        style.width = "100vw";
      } else {
        style.width = "100%";
      }
      if (block.type === "video") {
        if (block_height) {
          style.height = block_height;
        } else if (block_aspect_ratio) {
          style.paddingBottom = `${block_aspect_ratio * 100}%`;
        } else if (block_preserve_scale) {
          style.objectFit = "contain";
        }
      } else if (block_aspect_ratio && block.type !== "image") {
        style.paddingBottom = `${block_aspect_ratio * 100}%`;
      } else if (block_height) {
        style.height = block_height;
      } else if (block_preserve_scale) {
        if (block.type === "image") {
          style.height = "100%";
        } else {
          style.paddingBottom = "75%";
          style.minHeight = 100;
        }
      }
    } else {
      if (block_width) {
        style.width = block_width;
      }
      if (block_preserve_scale && block.type !== "image") {
        style.paddingBottom = "50%";
        style.minHeight = 100;
      } else {
        if (block_height && block.type !== "image") {
          style.height = block_height;
        }
      }
    }
    if (block.type === "image") {
      assetStyle.objectFit = "cover";
    } else if (block_preserve_scale) {
      assetStyle.objectFit = "contain";
    }
  }
  const source = ((_a = recordMap.signed_urls) == null ? void 0 : _a[block.id]) || ((_d = (_c = (_b = block.properties) == null ? void 0 : _b.source) == null ? void 0 : _c[0]) == null ? void 0 : _d[0]);
  let content = null;
  if (!source) {
    return null;
  }
  if (block.type === "tweet") {
    const src = source;
    if (!src)
      return null;
    const id = src.split("?")[0].split("/").pop();
    if (!id)
      return null;
    content = /* @__PURE__ */ React3.createElement("div", {
      style: __spreadProps(__spreadValues({}, assetStyle), {
        maxWidth: 420,
        width: "100%",
        marginLeft: "auto",
        marginRight: "auto"
      })
    }, /* @__PURE__ */ React3.createElement(components.Tweet, {
      id
    }));
  } else if (block.type === "pdf") {
    style.overflow = "auto";
    style.background = "rgb(226, 226, 226)";
    if (!style.padding) {
      style.padding = "8px 16px";
    }
    if (!isServer) {
      content = /* @__PURE__ */ React3.createElement(components.Pdf, {
        file: source
      });
    }
  } else if (block.type === "embed" || block.type === "video" || block.type === "figma" || block.type === "typeform" || block.type === "gist" || block.type === "maps" || block.type === "excalidraw" || block.type === "codepen" || block.type === "drive") {
    if (block.type === "video" && source && source.indexOf("youtube") < 0 && source.indexOf("youtu.be") < 0 && source.indexOf("vimeo") < 0 && source.indexOf("wistia") < 0 && source.indexOf("loom") < 0 && source.indexOf("videoask") < 0 && source.indexOf("getcloudapp") < 0) {
      style.paddingBottom = void 0;
      content = /* @__PURE__ */ React3.createElement("video", {
        playsInline: true,
        controls: true,
        preload: "metadata",
        style: assetStyle,
        src: source,
        title: block.type
      });
    } else {
      let src = ((_e = block.format) == null ? void 0 : _e.display_source) || source;
      if (src) {
        const youtubeVideoId = block.type === "video" ? getYoutubeId(src) : null;
        if (youtubeVideoId) {
          content = /* @__PURE__ */ React3.createElement(LiteYouTubeEmbed, {
            id: youtubeVideoId,
            style: assetStyle,
            className: "notion-asset-object-fit"
          });
        } else if (block.type === "gist") {
          if (!src.endsWith(".pibb")) {
            src = `${src}.pibb`;
          }
          assetStyle.width = "100%";
          style.paddingBottom = "50%";
          content = /* @__PURE__ */ React3.createElement("iframe", {
            style: assetStyle,
            className: "notion-asset-object-fit",
            src,
            title: "GitHub Gist",
            frameBorder: "0",
            loading: "lazy",
            scrolling: "auto"
          });
        } else {
          content = /* @__PURE__ */ React3.createElement("iframe", {
            className: "notion-asset-object-fit",
            style: assetStyle,
            src,
            title: `iframe ${block.type}`,
            frameBorder: "0",
            allowFullScreen: true,
            loading: "lazy",
            scrolling: "auto"
          });
        }
      }
    }
  } else if (block.type === "image") {
    const src = mapImageUrl(source, block);
    const caption = getTextContent((_f = block.properties) == null ? void 0 : _f.caption);
    const alt = caption || "notion image";
    content = /* @__PURE__ */ React3.createElement(LazyImage, {
      src,
      alt,
      zoomable: true,
      height: style.height,
      style: assetStyle
    });
  }
  return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("div", {
    style
  }, content, block.type === "image" && children), block.type !== "image" && children);
};

// src/components/text.tsx
import React10 from "react";
import { parsePageId } from "notion-utils";

// src/components/page-title.tsx
import React6 from "react";

// src/components/page-icon.tsx
import React5 from "react";
import { getBlockIcon, getBlockTitle } from "notion-utils";

// src/icons/default-page-icon.tsx
import React4 from "react";
var DefaultPageIcon = (props) => {
  const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
  return /* @__PURE__ */ React4.createElement("svg", __spreadProps(__spreadValues({
    className
  }, rest), {
    viewBox: "0 0 30 30",
    width: "16"
  }), /* @__PURE__ */ React4.createElement("path", {
    d: "M16,1H4v28h22V11L16,1z M16,3.828L23.172,11H16V3.828z M24,27H6V3h8v10h10V27z M8,17h14v-2H8V17z M8,21h14v-2H8V21z M8,25h14v-2H8V25z"
  }));
};

// src/components/page-icon.tsx
var isIconBlock = (value) => {
  return value.type === "page" || value.type === "callout" || value.type === "collection_view" || value.type === "collection_view_page";
};
var PageIcon = ({
  block,
  className,
  inline = true,
  hideDefaultIcon = false,
  defaultIcon
}) => {
  var _a;
  const { mapImageUrl, recordMap } = useNotionContext();
  let isImage = false;
  let content = null;
  if (isIconBlock(block)) {
    const icon = ((_a = getBlockIcon(block, recordMap)) == null ? void 0 : _a.trim()) || defaultIcon;
    const title = getBlockTitle(block, recordMap);
    if (icon && (0, import_is_url_superb.default)(icon)) {
      const url = mapImageUrl(icon, block);
      isImage = true;
      content = /* @__PURE__ */ React5.createElement(LazyImage, {
        src: url,
        alt: title || "page icon",
        className: cs(className, "notion-page-icon")
      });
    } else if (!icon) {
      if (!hideDefaultIcon) {
        isImage = true;
        content = /* @__PURE__ */ React5.createElement(DefaultPageIcon, {
          className: cs(className, "notion-page-icon"),
          alt: title ? title : "page icon"
        });
      }
    } else {
      isImage = false;
      content = /* @__PURE__ */ React5.createElement("span", {
        className: cs(className, "notion-page-icon"),
        role: "img",
        "aria-label": icon
      }, icon);
    }
  }
  if (!content) {
    return null;
  }
  return /* @__PURE__ */ React5.createElement("div", {
    className: cs(inline ? "notion-page-icon-inline" : "notion-page-icon-hero", isImage ? "notion-page-icon-image" : "notion-page-icon-span")
  }, content);
};

// src/components/page-title.tsx
import { getBlockCollectionId } from "notion-utils";
var PageTitle = (_a) => {
  var _b = _a, { block, className, defaultIcon } = _b, rest = __objRest(_b, ["block", "className", "defaultIcon"]);
  var _a2, _b2, _c;
  const { recordMap } = useNotionContext();
  if (!block)
    return null;
  if (block.type === "collection_view_page" || block.type === "collection_view") {
    const collection = (_a2 = recordMap.collection[getBlockCollectionId(block)]) == null ? void 0 : _a2.value;
    if (collection) {
      block.properties = __spreadProps(__spreadValues({}, block.properties), {
        title: collection.name
      });
      block.format = __spreadProps(__spreadValues({}, block.format), {
        page_icon: collection.icon
      });
    }
  }
  if (!((_b2 = block.properties) == null ? void 0 : _b2.title)) {
    return null;
  }
  return /* @__PURE__ */ React6.createElement("span", __spreadValues({
    className: cs("notion-page-title", className)
  }, rest), /* @__PURE__ */ React6.createElement(PageIcon, {
    block,
    defaultIcon,
    className: "notion-page-title-icon"
  }), /* @__PURE__ */ React6.createElement("span", {
    className: "notion-page-title-text"
  }, /* @__PURE__ */ React6.createElement(Text, {
    value: (_c = block.properties) == null ? void 0 : _c.title,
    block
  })));
};

// src/components/graceful-image.tsx
import React7 from "react";
import { Img } from "react-image";
var GracefulImage = (props) => {
  if (isBrowser) {
    return /* @__PURE__ */ React7.createElement(Img, __spreadValues({}, props));
  } else {
    return /* @__PURE__ */ React7.createElement("img", __spreadValues({}, props));
  }
};

// src/components/external-component-github.tsx
import React9, { useEffect, useState } from "react";

// src/icons/type-github.tsx
import React8 from "react";
function SvgTypeGitHub(props) {
  return /* @__PURE__ */ React8.createElement("svg", __spreadValues({
    viewBox: "0 0 260 260"
  }, props), /* @__PURE__ */ React8.createElement("g", null, /* @__PURE__ */ React8.createElement("path", {
    d: "M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z",
    fill: "#161614"
  })));
}
var type_github_default = SvgTypeGitHub;

// src/components/external-component-github.tsx
var ExternalComponentGithub = ({ original_url, block, className }) => {
  const { components } = useNotionContext();
  const url = new URL(original_url);
  const [name, setName] = useState(url.pathname.substring(1));
  const [githubRepo, setGithubRepo] = useState();
  useEffect(() => {
    fetch(`https://api.github.com/repos/${name}`).then((response) => {
      if (!response.ok) {
        throw Error(response.statusText);
      }
      return response.json();
    }).then((data) => {
      setGithubRepo(data);
      setName(data.name);
    }).catch((err) => console.error(err));
  }, [name]);
  return /* @__PURE__ */ React9.createElement(components.Link, {
    target: "_blank",
    rel: "noopener noreferrer",
    href: original_url,
    className: cs("notion-external", block ? "notion-external-block notion-row" : "notion-external-mention", className)
  }, /* @__PURE__ */ React9.createElement("div", {
    className: "notion-external-image"
  }, /* @__PURE__ */ React9.createElement(type_github_default, null)), /* @__PURE__ */ React9.createElement("div", {
    className: "notion-external-description"
  }, /* @__PURE__ */ React9.createElement("div", {
    className: "notion-external-title"
  }, name), githubRepo && /* @__PURE__ */ React9.createElement("div", {
    className: "notion-external-subtitle"
  }, `${githubRepo.owner.login} \u2022 Updated on ${githubRepo.updated_at.substring(0, 10)}`)));
};

// src/components/text.tsx
var Text = ({ value, block, linkProps, linkProtocol }) => {
  const { components, recordMap, mapPageUrl, mapImageUrl, rootDomain } = useNotionContext();
  return /* @__PURE__ */ React10.createElement(React10.Fragment, null, value == null ? void 0 : value.map(([text, decorations], index) => {
    if (!decorations) {
      if (text === ",") {
        return /* @__PURE__ */ React10.createElement("span", {
          key: index,
          style: { padding: "0.5em" }
        });
      } else {
        return /* @__PURE__ */ React10.createElement(React10.Fragment, {
          key: index
        }, text);
      }
    }
    const formatted = decorations.reduce((element, decorator) => {
      var _a, _b, _c, _d, _e, _f, _g, _h;
      switch (decorator[0]) {
        case "p": {
          const blockId = decorator[1];
          const linkedBlock = (_a = recordMap.block[blockId]) == null ? void 0 : _a.value;
          if (!linkedBlock) {
            console.log('"p" missing block', blockId);
            return null;
          }
          return /* @__PURE__ */ React10.createElement(components.PageLink, {
            className: "notion-link",
            href: mapPageUrl(blockId)
          }, /* @__PURE__ */ React10.createElement(PageTitle, {
            block: linkedBlock
          }));
        }
        case "\u2023": {
          const linkType = decorator[1][0];
          const id = decorator[1][1];
          switch (linkType) {
            case "u": {
              const user = (_b = recordMap.notion_user[id]) == null ? void 0 : _b.value;
              if (!user) {
                console.log('"\u2023" missing user', id);
                return null;
              }
              const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
              return /* @__PURE__ */ React10.createElement(GracefulImage, {
                className: "notion-user",
                src: mapImageUrl(user.profile_photo, block),
                alt: name
              });
            }
            default: {
              const linkedBlock = (_c = recordMap.block[id]) == null ? void 0 : _c.value;
              if (!linkedBlock) {
                console.log('"\u2023" missing block', linkType, id);
                return null;
              }
              return /* @__PURE__ */ React10.createElement(components.PageLink, __spreadProps(__spreadValues({
                className: "notion-link",
                href: mapPageUrl(id)
              }, linkProps), {
                target: "_blank",
                rel: "noopener noreferrer"
              }), /* @__PURE__ */ React10.createElement(PageTitle, {
                block: linkedBlock
              }));
            }
          }
        }
        case "h":
          return /* @__PURE__ */ React10.createElement("span", {
            className: `notion-${decorator[1]}`
          }, element);
        case "c":
          return /* @__PURE__ */ React10.createElement("code", {
            className: "notion-inline-code"
          }, element);
        case "b":
          return /* @__PURE__ */ React10.createElement("b", null, element);
        case "i":
          return /* @__PURE__ */ React10.createElement("em", null, element);
        case "s":
          return /* @__PURE__ */ React10.createElement("s", null, element);
        case "_":
          return /* @__PURE__ */ React10.createElement("span", {
            className: "notion-inline-underscore"
          }, element);
        case "e":
          return /* @__PURE__ */ React10.createElement(components.Equation, {
            math: decorator[1],
            inline: true
          });
        case "m":
          return element;
        case "a": {
          const v = decorator[1];
          const pathname = v.substr(1);
          const id = parsePageId(pathname, { uuid: true });
          if ((v[0] === "/" || v.includes(rootDomain)) && id) {
            const href = v.includes(rootDomain) ? v : `${mapPageUrl(id)}${getHashFragmentValue(v)}`;
            return /* @__PURE__ */ React10.createElement(components.PageLink, __spreadValues({
              className: "notion-link",
              href
            }, linkProps), element);
          } else {
            return /* @__PURE__ */ React10.createElement(components.Link, __spreadValues({
              className: "notion-link",
              href: linkProtocol ? `${linkProtocol}:${decorator[1]}` : decorator[1]
            }, linkProps), element);
          }
        }
        case "d": {
          const v = decorator[1];
          const type = v == null ? void 0 : v.type;
          if (type === "date") {
            const startDate = v.start_date;
            return formatDate(startDate);
          } else if (type === "daterange") {
            const startDate = v.start_date;
            const endDate = v.end_date;
            return `${formatDate(startDate)} \u2192 ${formatDate(endDate)}`;
          } else {
            return element;
          }
        }
        case "u": {
          const userId = decorator[1];
          const user = (_d = recordMap.notion_user[userId]) == null ? void 0 : _d.value;
          if (!user) {
            console.log("missing user", userId);
            return null;
          }
          const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
          return /* @__PURE__ */ React10.createElement(GracefulImage, {
            className: "notion-user",
            src: mapImageUrl(user.profile_photo, block),
            alt: name
          });
        }
        case "eoi": {
          const blockId = decorator[1];
          const externalObjectInstance = (_e = recordMap.block[blockId]) == null ? void 0 : _e.value;
          switch ((_f = externalObjectInstance == null ? void 0 : externalObjectInstance.format) == null ? void 0 : _f.domain) {
            case "github.com":
              return /* @__PURE__ */ React10.createElement(ExternalComponentGithub, {
                original_url: (_g = externalObjectInstance.format) == null ? void 0 : _g.original_url,
                className: blockId
              });
            default:
              if (true) {
                console.log(`Unsupported external_object_instance domain ${(_h = externalObjectInstance == null ? void 0 : externalObjectInstance.format) == null ? void 0 : _h.domain}: ` + block.type, JSON.stringify(block, null, 2));
              }
              return /* @__PURE__ */ React10.createElement("div", null);
          }
        }
        default:
          if (true) {
            console.log("unsupported text format", decorator);
          }
          return element;
      }
    }, /* @__PURE__ */ React10.createElement(React10.Fragment, null, text));
    return /* @__PURE__ */ React10.createElement(React10.Fragment, {
      key: index
    }, formatted);
  }));
};

// src/components/asset-wrapper.tsx
import { parsePageId as parsePageId2 } from "notion-utils";
var AssetWrapper = ({ blockId, block }) => {
  var _a, _b, _c, _d, _e, _f;
  const value = block;
  const { components, mapPageUrl, rootDomain } = useNotionContext();
  let isURL = false;
  if (((_b = (_a = value == null ? void 0 : value.properties) == null ? void 0 : _a.caption) == null ? void 0 : _b.length) > 0) {
    const caption = (_c = value == null ? void 0 : value.properties) == null ? void 0 : _c.caption[0][0];
    const id = parsePageId2(caption, { uuid: true });
    const isPage = caption.charAt(0) === "/" && id;
    if (block.type == "image" && isValidURL(caption) || isPage) {
      isURL = true;
    }
  }
  const figure = /* @__PURE__ */ React11.createElement("figure", {
    className: cs("notion-asset-wrapper", `notion-asset-wrapper-${block.type}`, ((_d = value.format) == null ? void 0 : _d.block_full_width) && "notion-asset-wrapper-full", blockId)
  }, /* @__PURE__ */ React11.createElement(Asset, {
    block: value
  }, ((_e = value == null ? void 0 : value.properties) == null ? void 0 : _e.caption) && !isURL && /* @__PURE__ */ React11.createElement("figcaption", {
    className: "notion-asset-caption"
  }, /* @__PURE__ */ React11.createElement(Text, {
    value: value.properties.caption,
    block
  }))));
  if (isURL) {
    const caption = (_f = value == null ? void 0 : value.properties) == null ? void 0 : _f.caption[0][0];
    const id = parsePageId2(caption, { uuid: true });
    const isPage = caption.charAt(0) === "/" && id;
    const captionHostname = extractHostname(caption);
    return /* @__PURE__ */ React11.createElement(components.PageLink, {
      style: { width: "100%" },
      href: isPage ? mapPageUrl(id) : caption,
      target: captionHostname && captionHostname !== rootDomain && !caption.startsWith("/") ? "blank_" : null
    }, figure);
  }
  return figure;
};
function isValidURL(str) {
  const pattern = new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$", "i");
  return !!pattern.test(str);
}
function extractHostname(url) {
  try {
    const hostname = new URL(url).hostname;
    return hostname;
  } catch (err) {
    return "";
  }
}

// src/components/checkbox.tsx
import React13 from "react";

// src/icons/check.tsx
import React12 from "react";
function SvgCheck(props) {
  return /* @__PURE__ */ React12.createElement("svg", __spreadValues({
    viewBox: "0 0 14 14"
  }, props), /* @__PURE__ */ React12.createElement("path", {
    d: "M5.5 12L14 3.5 12.5 2l-7 7-4-4.003L0 6.499z"
  }));
}
var check_default = SvgCheck;

// src/components/checkbox.tsx
var Checkbox = ({ isChecked }) => {
  let content = null;
  if (isChecked) {
    content = /* @__PURE__ */ React13.createElement("div", {
      className: "notion-property-checkbox-checked"
    }, /* @__PURE__ */ React13.createElement(check_default, null));
  } else {
    content = /* @__PURE__ */ React13.createElement("div", {
      className: "notion-property-checkbox-unchecked"
    });
  }
  return /* @__PURE__ */ React13.createElement("span", {
    className: "notion-property notion-property-checkbox"
  }, content);
};

// src/context.tsx
var DefaultLink = (props) => /* @__PURE__ */ React14.createElement("a", __spreadValues({
  target: "_blank",
  rel: "noopener noreferrer"
}, props));
var DefaultPageLink = (props) => /* @__PURE__ */ React14.createElement("a", __spreadValues({}, props));
var DefaultEmbed = AssetWrapper;
var dummyComponent = (name) => () => {
  console.warn(`Warning: using empty component "${name}" (you should override this in NotionRenderer.components)`);
  return null;
};
var dummyOverrideFn = (_, defaultValueFn) => defaultValueFn();
var defaultComponents = {
  Image: null,
  Link: DefaultLink,
  PageLink: DefaultPageLink,
  Checkbox,
  Callout: void 0,
  Code: dummyComponent("Code"),
  Equation: dummyComponent("Equation"),
  Collection: dummyComponent("Collection"),
  Property: void 0,
  propertySelectValue: dummyOverrideFn,
  Pdf: dummyComponent("Pdf"),
  Tweet: dummyComponent("Tweet"),
  Modal: dummyComponent("Modal"),
  Embed: DefaultEmbed
};
var defaultNotionContext = {
  recordMap: {
    block: {},
    collection: {},
    collection_view: {},
    collection_query: {},
    notion_user: {},
    signed_urls: {}
  },
  components: defaultComponents,
  mapPageUrl: defaultMapPageUrl(),
  mapImageUrl: defaultMapImageUrl,
  searchNotion: null,
  fullPage: false,
  darkMode: false,
  previewImages: false,
  forceCustomImages: false,
  showCollectionViewDropdown: true,
  linkTableTitleProperties: true,
  showTableOfContents: false,
  minTableOfContentsItems: 3,
  defaultPageIcon: null,
  defaultPageCover: null,
  defaultPageCoverPosition: 0.5,
  zoom: null
};
var ctx = React14.createContext(defaultNotionContext);
var NotionContextConsumer = ctx.Consumer;
var useNotionContext = () => {
  return React14.useContext(ctx);
};

// src/third-party/equation.tsx
var katexSettings = {
  throwOnError: false,
  strict: false
};
var Equation = (_a) => {
  var _b = _a, { block, math, inline = false, className } = _b, rest = __objRest(_b, ["block", "math", "inline", "className"]);
  const { recordMap } = useNotionContext();
  math = math || getBlockTitle2(block, recordMap);
  if (!math)
    return null;
  return /* @__PURE__ */ React15.createElement("span", {
    role: "button",
    tabIndex: 0,
    className: cs("notion-equation", inline ? "notion-equation-inline" : "notion-equation-block", className)
  }, /* @__PURE__ */ React15.createElement(Katex, __spreadValues({
    math,
    settings: katexSettings
  }, rest)));
};
export {
  Equation
};
//# sourceMappingURL=equation.js.map