"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";










var _chunkUUARMJJEcjs = require('./chunk-UUARMJJE.cjs');


var _chunkDAAFVOTLcjs = require('./chunk-DAAFVOTL.cjs');


var _chunkMEAR2WHScjs = require('./chunk-MEAR2WHS.cjs');


var _chunkXL4V2PYGcjs = require('./chunk-XL4V2PYG.cjs');


var _chunkG7UE6RKVcjs = require('./chunk-G7UE6RKV.cjs');



var _chunkWBR7H6E3cjs = require('./chunk-WBR7H6E3.cjs');



var _chunkFIG2RKZFcjs = require('./chunk-FIG2RKZF.cjs');

// src/components/shared/doc-search/format-relative-path.ts
function formatRelativePath(fullPath) {
  if (!fullPath) return "";
  const segments = fullPath.replace(/\.md$/, "").split("/");
  const parentSegments = segments.length > 1 ? segments.slice(0, -1) : segments;
  return parentSegments.map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1).replace(/-/g, " ")).join(" / ");
}

// src/components/shared/doc-search/doc-search-result-row.tsx
var _jsxruntime = require('react/jsx-runtime');
function DocSearchResultRow({
  result,
  isHighlighted
}) {
  const docType = _optionalChain([result, 'access', _2 => _2.metadata, 'optionalAccess', _3 => _3.documentType]) || void 0;
  const sourceRepo = _optionalChain([result, 'access', _4 => _4.metadata, 'optionalAccess', _5 => _5.sourceRepo]) || void 0;
  const { Icon: SourceIcon, label: iconLabel } = _chunkUUARMJJEcjs.resolveSourceIcon.call(void 0, {
    sourceRepo,
    documentType: docType
  });
  const isGroup = _optionalChain([result, 'access', _6 => _6.metadata, 'optionalAccess', _7 => _7.isGroup]);
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-3 w-full min-w-0", children: [
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      "span",
      {
        className: "flex-shrink-0 text-ods-text-secondary",
        title: iconLabel,
        children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SourceIcon, { className: "size-4" })
      }
    ),
    /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "min-w-0 flex-1", children: [
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
        "div",
        {
          className: `text-sm font-medium leading-5 truncate ${isHighlighted ? "text-ods-accent" : "text-ods-text-primary"}`,
          children: result.title || result.path
        }
      ),
      !isGroup && _optionalChain([result, 'access', _8 => _8.path, 'optionalAccess', _9 => _9.includes, 'call', _10 => _10("/")]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-xs leading-4 text-ods-text-secondary truncate mt-0.5", children: formatRelativePath(result.path) })
    ] })
  ] });
}

// src/components/shared/doc-search/doc-search-bar.tsx

function DocSearchBar({
  placeholder,
  query,
  onQueryChange,
  results,
  isLoading,
  onResultSelect,
  showDropdown,
  minQueryLength = 2,
  debounceMs = 0,
  className = "w-full",
  renderResult
}) {
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    _chunkUUARMJJEcjs.SearchInput,
    {
      placeholder,
      value: query,
      onChange: onQueryChange,
      results,
      isLoading,
      onResultSelect,
      showDropdown: showDropdown || void 0,
      debounceMs,
      minQueryLength,
      className,
      renderResult: _nullishCoalesce(renderResult, () => ( ((result, isHighlighted) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocSearchResultRow, { result, isHighlighted }))))
    }
  );
}

// src/components/shared/doc-search/map-doc-search-results.ts
var SEARCH_GROUP_REPOS = /* @__PURE__ */ new Set([
  "financial-cap-table",
  "financial-kpis",
  "financial-pnl",
  "financial-balance-sheet",
  "financial-cash-flow"
]);
var ENTITY_LABELS = {
  "financial-cap-table": "Cap Table",
  "financial-kpis": "Financial KPIs",
  "financial-pnl": "Profit & Loss",
  "financial-balance-sheet": "Balance Sheets",
  "financial-cash-flow": "Cash Flow",
  "blog-posts": "Blog Posts",
  "product-releases": "Product Releases",
  "case-studies": "Case Studies",
  webinars: "Webinars",
  events: "Events",
  podcasts: "Podcasts"
};
function mapDocSearchResults(docs) {
  const entityGroups = /* @__PURE__ */ new Map();
  const order = [];
  const seenRepos = /* @__PURE__ */ new Set();
  for (const doc of docs) {
    if (doc.sourceRepo && SEARCH_GROUP_REPOS.has(doc.sourceRepo)) {
      const group = entityGroups.get(doc.sourceRepo) || [];
      group.push(doc);
      entityGroups.set(doc.sourceRepo, group);
      if (!seenRepos.has(doc.sourceRepo)) {
        seenRepos.add(doc.sourceRepo);
        order.push({ type: "entity", repo: doc.sourceRepo });
      }
    } else {
      order.push({ type: "doc", doc });
    }
  }
  const results = [];
  for (const entry of order) {
    if (entry.type === "entity") {
      const rows = entityGroups.get(entry.repo);
      const label = ENTITY_LABELS[entry.repo] || entry.repo;
      results.push({
        id: `group-${entry.repo}`,
        title: `${label} (${rows.length} ${rows.length === 1 ? "record" : "records"})`,
        path: rows[0].path,
        type: "file",
        metadata: {
          documentType: rows[0].documentType,
          externalUrl: rows[0].externalUrl,
          sourceRepo: entry.repo,
          id: rows[0].entityId,
          isGroup: true,
          items: rows.map((r) => ({
            name: r.name,
            externalUrl: r.externalUrl,
            id: r.entityId,
            sourceRepo: r.sourceRepo,
            documentType: r.documentType
          }))
        }
      });
    } else {
      const doc = entry.doc;
      const isNonMarkdown = doc.documentType && doc.documentType !== "markdown";
      results.push({
        id: doc.path,
        title: doc.name,
        description: isNonMarkdown ? doc.name : doc.snippet,
        path: doc.path,
        type: doc.type,
        metadata: {
          matchType: doc.matchType,
          ...doc.documentType ? { documentType: doc.documentType } : {},
          ...doc.externalUrl ? { externalUrl: doc.externalUrl } : {},
          ...doc.targetPlatform != null ? { targetPlatform: doc.targetPlatform } : {},
          ...doc.sourceRepo ? { sourceRepo: doc.sourceRepo } : {},
          ...doc.entityId ? { id: doc.entityId } : {}
        }
      });
    }
  }
  return results;
}

// src/components/shared/doc-search/resolve-search-result-action.ts
function resolveSearchResultAction(result, source, runtimeMode) {
  const meta = _nullishCoalesce(result.metadata, () => ( {}));
  const externalUrl = meta.externalUrl;
  if (externalUrl) {
    const targetPlatform = meta.targetPlatform;
    const isNewTab = _chunkUUARMJJEcjs.decideNewTab.call(void 0, {
      href: externalUrl,
      targetPlatform,
      surface: "useUnifiedNav",
      runtimeMode,
      currentSource: source
    });
    return isNewTab ? { kind: "navigate-new-tab", href: externalUrl } : { kind: "navigate-same-tab", href: externalUrl };
  }
  const rowId = meta.id;
  const sourceRepo = meta.sourceRepo;
  const documentType = meta.documentType;
  if (rowId && sourceRepo && documentType) {
    return {
      kind: "ask-ai",
      detail: {
        source,
        ref: { type: documentType, id: rowId, title: result.title, url: null }
      }
    };
  }
  if (result.path) {
    return { kind: "route", path: result.path };
  }
  return { kind: "noop" };
}

// src/components/shared/doc-search/use-doc-search.ts
var _react = require('react');
function useDocSearch(config) {
  const {
    source,
    baseRoute,
    onNavigate,
    tableIds,
    onInPageSwap,
    searchEndpoint = "/api/docs/search"
  } = config;
  const tableIdsKey = tableIds && tableIds.length > 0 ? tableIds.join(",") : "";
  const router = _chunkG7UE6RKVcjs.useRouter.call(void 0, );
  const runtime = _chunkMEAR2WHScjs.useChatRuntime.call(void 0, );
  const [query, setQuery] = _react.useState.call(void 0, "");
  const [results, setResults] = _react.useState.call(void 0, []);
  const [isFetching, setIsFetching] = _react.useState.call(void 0, false);
  const debouncedQuery = _chunkDAAFVOTLcjs.useDebounce.call(void 0, query, 300);
  _react.useEffect.call(void 0, () => {
    if (!debouncedQuery || debouncedQuery.trim().length < 2) {
      setResults([]);
      setIsFetching(false);
      return;
    }
    let cancelled = false;
    async function fetchResults() {
      setIsFetching(true);
      try {
        const params = new URLSearchParams({
          q: debouncedQuery,
          source,
          limit: "10"
        });
        if (tableIdsKey) params.set("tableIds", tableIdsKey);
        const response = await fetch(`${searchEndpoint}?${params.toString()}`);
        if (!response.ok) {
          throw new Error(`Search request failed: ${response.status}`);
        }
        const json = await response.json();
        if (!cancelled && json.success && Array.isArray(json.data)) {
          const mapped = mapDocSearchResults(json.data);
          setResults(mapped);
        }
      } catch (error) {
        console.error("Doc search error:", error);
        if (!cancelled) {
          setResults([]);
        }
      } finally {
        if (!cancelled) {
          setIsFetching(false);
        }
      }
    }
    fetchResults();
    return () => {
      cancelled = true;
    };
  }, [debouncedQuery, source, tableIdsKey, searchEndpoint]);
  const isLoading = query.trim().length >= 2 && (query !== debouncedQuery || isFetching);
  const [keepOpen, setKeepOpen] = _react.useState.call(void 0, false);
  const handleResultSelect = _react.useCallback.call(void 0, 
    (result, modifiers) => {
      const action = resolveSearchResultAction(
        result,
        source,
        _optionalChain([runtime, 'optionalAccess', _11 => _11.navigation, 'access', _12 => _12.mode])
      );
      const wantsNewTab = modifiers && (modifiers.metaKey || modifiers.ctrlKey || modifiers.shiftKey || modifiers.altKey || typeof modifiers.button === "number" && modifiers.button !== 0);
      switch (action.kind) {
        case "navigate-same-tab": {
          if (_optionalChain([runtime, 'optionalAccess', _13 => _13.navigation, 'access', _14 => _14.mode]) === "embed") {
            setKeepOpen(true);
            const targetPlatform = _nullishCoalesce(_optionalChain([result, 'access', _15 => _15.metadata, 'optionalAccess', _16 => _16.targetPlatform]), () => ( null));
            _chunkUUARMJJEcjs.resolveExternalNavigation.call(void 0, {
              href: action.href,
              targetPlatform,
              runtime
            }).open();
            return;
          }
          if (wantsNewTab) {
            setKeepOpen(true);
            window.open(action.href, "_blank", _chunkUUARMJJEcjs.NEW_TAB_FEATURES);
            return;
          }
          setKeepOpen(false);
          const path = baseRoute && action.href.startsWith(`${baseRoute}/`) ? action.href.slice(baseRoute.length + 1) : null;
          if (path && _optionalChain([onInPageSwap, 'optionalCall', _17 => _17(path)])) return;
          router.push(_chunkUUARMJJEcjs.stripSameOriginToPath.call(void 0, action.href));
          return;
        }
        case "navigate-new-tab":
          setKeepOpen(true);
          window.open(action.href, "_blank", _chunkUUARMJJEcjs.NEW_TAB_FEATURES);
          return;
        case "ask-ai":
          setKeepOpen(false);
          window.dispatchEvent(
            new CustomEvent("ask-ai:open-with-ref", { detail: action.detail })
          );
          return;
        case "route":
          setKeepOpen(false);
          onNavigate(action.path);
          return;
        case "noop":
          return;
      }
    },
    [onNavigate, source, baseRoute, router, onInPageSwap, runtime]
  );
  _react.useEffect.call(void 0, () => {
    setKeepOpen(false);
  }, [query]);
  return {
    query,
    setQuery,
    results,
    isLoading,
    handleResultSelect,
    keepDropdownOpen: keepOpen
  };
}

// src/components/shared/detail-page-skeleton.tsx

function DetailPageSkeleton({
  metadataColumns = 4,
  showImageGallery = true
} = {}) {
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    _chunkUUARMJJEcjs.PageContainer,
    {
      as: "article",
      backgroundClassName: "bg-ods-bg",
      contentPadding: "py-6 md:py-10 px-6 md:px-20",
      maxWidth: "max-w-[1280px]",
      children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6 md:space-y-10 animate-pulse", children: [
        /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-6 w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-16 md:h-20 w-full max-w-3xl bg-ods-card rounded" }) }),
        /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap gap-2 w-full", children: [
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-8 w-32 bg-ods-card rounded" }),
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-8 w-28 bg-ods-card rounded" }),
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-8 w-36 bg-ods-card rounded" })
        ] }),
        /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: `grid grid-cols-1 md:grid-cols-${metadataColumns} border border-ods-border rounded-md overflow-hidden w-full`, children: Array.from({ length: metadataColumns }).map((_, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "bg-ods-card border-b md:border-b-0 md:border-r last:border-r-0 border-ods-border p-4", children: [
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-6 w-24 bg-ods-border rounded mb-2" }),
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-5 w-20 bg-ods-border rounded" })
        ] }, i)) }),
        showImageGallery && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex gap-6 overflow-x-auto w-full", children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "shrink-0 w-[240px] h-[200px] bg-ods-card rounded-md border border-ods-border" }, i)) }),
        !showImageGallery && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aspect-[2560/1366] w-full bg-ods-card rounded-md" }),
        [1, 2, 3].map((section) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6", children: [
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-16 w-64 bg-ods-card rounded" }),
          /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
            /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-6 w-full bg-ods-card rounded" }),
            /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-6 w-full bg-ods-card rounded" }),
            /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-6 w-4/5 bg-ods-card rounded" })
          ] })
        ] }, section))
      ] })
    }
  );
}

// src/components/shared/article-author-byline.tsx
var _lucidereact = require('lucide-react');
_chunkWBR7H6E3cjs.init_next_link.call(void 0, );
_chunkFIG2RKZFcjs.init_cn.call(void 0, );

function formatDate(value) {
  const d = typeof value === "string" ? new Date(value) : value;
  if (Number.isNaN(d.getTime())) return "";
  return d.toLocaleDateString("en-US", {
    month: "long",
    day: "numeric",
    year: "numeric",
    timeZone: "UTC"
  });
}
function ArticleAuthorByline({
  author,
  avatar,
  bio,
  jobTitle,
  publishedAt,
  href,
  fallbackBio,
  size = "md",
  proxyImageUrl,
  className
}) {
  const runtime = _chunkMEAR2WHScjs.useChatRuntime.call(void 0, );
  if (!author) return null;
  const proxiedAvatar = avatar ? proxyImageUrl ? proxyImageUrl(avatar) : _nullishCoalesce(_chunkUUARMJJEcjs.getProxiedImageUrl.call(void 0, avatar, {
    proxyPrefix: _optionalChain([runtime, 'optionalAccess', _18 => _18.endpoints, 'access', _19 => _19.imageProxyUrlPrefix]),
    skipDomains: _optionalChain([runtime, 'optionalAccess', _20 => _20.endpoints, 'access', _21 => _21.imageProxySkipDomains]),
    directHttps: true
  }), () => ( avatar)) : "";
  const avatarSizeClass = size === "lg" ? "w-16 h-16" : "w-14 h-14";
  const avatarIconClass = size === "lg" ? "w-8 h-8" : "w-7 h-7";
  const avatarDim = size === "lg" ? 64 : 56;
  const formattedBio = _chunkUUARMJJEcjs.formatBioText.call(void 0, _nullishCoalesce(bio, () => ( null)));
  const dateLabel = publishedAt ? formatDate(publishedAt) : "";
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, 
    "div",
    {
      className: _chunkFIG2RKZFcjs.cn.call(void 0, 
        "bg-ods-card border border-ods-border rounded-lg p-6",
        "flex flex-col md:flex-row gap-4 items-start",
        className
      ),
      children: [
        /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-shrink-0", children: avatar ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
          _chunkXL4V2PYGcjs.next_image_default,
          {
            src: proxiedAvatar || avatar,
            alt: author,
            width: avatarDim,
            height: avatarDim,
            className: _chunkFIG2RKZFcjs.cn.call(void 0, "rounded-full border-2 border-ods-border object-cover", avatarSizeClass)
          }
        ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
          "div",
          {
            className: _chunkFIG2RKZFcjs.cn.call(void 0, 
              "rounded-full border-2 border-ods-border bg-ods-bg flex items-center justify-center",
              avatarSizeClass
            ),
            children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.User, { className: _chunkFIG2RKZFcjs.cn.call(void 0, "text-ods-text-secondary", avatarIconClass) })
          }
        ) }),
        /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1 min-w-0", children: [
          /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1", children: [
            /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-h5 text-ods-text-primary", children: href ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWBR7H6E3cjs.next_link_default, { href, className: "hover:text-ods-accent transition-colors", children: author }) : author }),
            dateLabel && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center gap-1 font-body text-body-sm text-ods-text-secondary", children: [
              /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Calendar, { className: "h-3 w-3" }),
              dateLabel
            ] })
          ] }),
          jobTitle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-body text-body-sm text-ods-text-secondary mt-0.5", children: jobTitle }),
          formattedBio ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-body text-body-md text-ods-text-secondary leading-relaxed mt-2", children: formattedBio }) : fallbackBio ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "font-body text-body-md text-ods-text-secondary italic mt-2", children: fallbackBio }) : null
        ] })
      ]
    }
  );
}










exports.formatRelativePath = formatRelativePath; exports.DocSearchResultRow = DocSearchResultRow; exports.DocSearchBar = DocSearchBar; exports.mapDocSearchResults = mapDocSearchResults; exports.resolveSearchResultAction = resolveSearchResultAction; exports.useDocSearch = useDocSearch; exports.DetailPageSkeleton = DetailPageSkeleton; exports.ArticleAuthorByline = ArticleAuthorByline;
//# sourceMappingURL=chunk-QXRXIHY6.cjs.map