"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 _chunkQXRXIHY6cjs = require('../../chunk-QXRXIHY6.cjs');


var _chunkT7AJBKZPcjs = require('../../chunk-T7AJBKZP.cjs');
require('../../chunk-VFKQMAUF.cjs');













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


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



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


var _chunkJMU4RU5Jcjs = require('../../chunk-JMU4RU5J.cjs');
require('../../chunk-N5UOJC3V.cjs');


var _chunkWBR7H6E3cjs = require('../../chunk-WBR7H6E3.cjs');
require('../../chunk-LGLPNWS6.cjs');
require('../../chunk-FIG2RKZF.cjs');
require('../../chunk-C6ASEPZL.cjs');
require('../../chunk-WZW7C7TF.cjs');
require('../../chunk-XQFFGR6U.cjs');
require('../../chunk-VRHGVLSL.cjs');

// src/components/onboarding-guides/onboarding-guides-catalog-view.tsx
var _react = require('react');
var _lucidereact = require('lucide-react');

// src/components/onboarding-guides/onboarding-guides-catalog-skeleton.tsx
var _jsxruntime = require('react/jsx-runtime');
function OnboardingGuidesCatalogSkeleton() {
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "w-full flex flex-col gap-10 animate-pulse", children: [
    /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-12 w-full bg-ods-card border border-ods-border rounded-md" }),
      /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-wrap items-center gap-3 p-4 bg-ods-card border border-ods-border rounded-lg", children: [
        /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-4 w-14 bg-ods-border/60 rounded" }),
        [0, 1, 2, 3].map((i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
          "div",
          {
            className: "h-10 w-24 bg-ods-card border border-ods-border rounded-md"
          },
          i
        ))
      ] })
    ] }),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-10", children: [4, 3, 3].map((cardCount, sectionIdx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { className: "space-y-4", children: [
      /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "h2", { className: "text-h3 tracking-[-0.36px] text-ods-text-primary flex items-center gap-2", children: [
        /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "h-6 w-40 bg-ods-border/70 rounded" }),
        /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "h-5 w-8 bg-ods-text-secondary/20 rounded-full" })
      ] }),
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "flex flex-col gap-4", children: Array.from({ length: cardCount }).map((_, cardIdx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkUUARMJJEcjs.OnboardingGuideCardSkeleton, { size: "catalog" }) }, cardIdx)) })
    ] }, sectionIdx)) })
  ] });
}

// src/components/onboarding-guides/onboarding-guides-catalog-view.tsx

function OnboardingGuidesCatalogView({
  initialGuides,
  initialSections,
  initialSection = "",
  guidesEndpoint,
  sectionsEndpoint,
  renderCard,
  basePath = "/onboarding-guides"
}) {
  const router = _chunkG7UE6RKVcjs.useRouter.call(void 0, );
  const searchParams = _chunkG7UE6RKVcjs.useSearchParams.call(void 0, );
  const [isPending, startTransition] = _react.useTransition.call(void 0, );
  const runtime = _chunkMEAR2WHScjs.useChatRuntime.call(void 0, );
  const selfFetch = initialGuides === void 0 && guidesEndpoint !== void 0;
  const sectionValue = selfFetch ? _nullishCoalesce(searchParams.get("section"), () => ( "")) : initialSection;
  const activeSection = sectionValue || "all";
  const guidesQs = sectionValue ? `?section=${encodeURIComponent(sectionValue)}` : "";
  const guidesRes = _chunkT7AJBKZPcjs.useSelfFetch.call(void 0, 
    selfFetch && guidesEndpoint ? `${guidesEndpoint}${guidesQs}` : null
  );
  const sectionsRes = _chunkT7AJBKZPcjs.useSelfFetch.call(void 0, 
    selfFetch && sectionsEndpoint ? sectionsEndpoint : null
  );
  const guides = _nullishCoalesce(_nullishCoalesce(initialGuides, () => ( _optionalChain([guidesRes, 'access', _2 => _2.data, 'optionalAccess', _3 => _3.data]))), () => ( []));
  const sections = _nullishCoalesce(initialSections, () => ( (Array.isArray(sectionsRes.data) ? sectionsRes.data : [])));
  const isLoading = selfFetch ? guidesRes.isLoading : false;
  const grouped = _react.useMemo.call(void 0, () => {
    const map = /* @__PURE__ */ new Map();
    for (const g of guides) {
      const existing = map.get(g.section);
      if (existing) {
        if (g.section_order < existing.section_order) existing.section_order = g.section_order;
        existing.guides.push(g);
      } else {
        map.set(g.section, { section_order: g.section_order, guides: [g] });
      }
    }
    for (const entry of map.values()) {
      entry.guides.sort((a, b) => a.step_order - b.step_order || a.title.localeCompare(b.title));
    }
    return Array.from(map.entries()).map(([section, info]) => ({ section, ...info })).sort((a, b) => a.section_order - b.section_order || a.section.localeCompare(b.section));
  }, [guides]);
  const sectionFilterOptions = _react.useMemo.call(void 0, 
    () => [
      { value: "all", label: `All (${guides.length})` },
      ...sections.map((s) => ({ value: s.section, label: `${s.section} (${s.count})` }))
    ],
    [guides.length, sections]
  );
  const setSection = (value) => {
    const params = new URLSearchParams(searchParams.toString());
    if (value === "all") {
      params.delete("section");
    } else {
      params.set("section", value);
    }
    const qs = params.toString();
    startTransition(() => {
      router.push(qs ? `${basePath}?${qs}` : basePath);
    });
  };
  const source = _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _4 => _4.source]), () => ( "openframe"));
  const docSearch = _chunkQXRXIHY6cjs.useDocSearch.call(void 0, {
    source,
    baseRoute: basePath,
    onNavigate: (path) => router.push(path),
    tableIds: ["onboarding-guides"]
  });
  const defaultRenderCard = (guide) => {
    const cta = _chunkUUARMJJEcjs.resolveContentHref.call(void 0, _optionalChain([runtime, 'optionalAccess', _5 => _5.composeContentUrl]), {
      type: "onboarding_guide",
      slug: guide.slug,
      basePath,
      platforms: guide.onboarding_guide_platforms
    });
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkUUARMJJEcjs.OnboardingGuideCard,
      {
        guide,
        href: cta.href,
        targetPlatform: cta.targetPlatform,
        size: "catalog"
      }
    );
  };
  const renderCardFn = _nullishCoalesce(renderCard, () => ( defaultRenderCard));
  const preControls = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4", children: [
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkQXRXIHY6cjs.DocSearchBar,
      {
        placeholder: "Search onboarding guides, releases, case studies\u2026",
        query: docSearch.query,
        onQueryChange: docSearch.setQuery,
        results: docSearch.results,
        isLoading: docSearch.isLoading,
        onResultSelect: docSearch.handleResultSelect,
        showDropdown: docSearch.keepDropdownOpen
      }
    ),
    sections.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkUUARMJJEcjs.FilterPillRow,
      {
        label: "Section",
        selectedValue: activeSection,
        onValueChange: setSection,
        options: sectionFilterOptions
      }
    )
  ] });
  if (selfFetch && guidesRes.error) {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkUUARMJJEcjs.LoadError, { message: "Failed to load onboarding guides.", onRetry: guidesRes.reload });
  }
  if (selfFetch && guidesRes.data == null && isLoading) {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, OnboardingGuidesCatalogSkeleton, {});
  }
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "w-full flex flex-col gap-10", children: [
    preControls,
    guides.length === 0 ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "text-center py-16", children: [
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.GraduationCap, { className: "h-12 w-12 text-ods-text-secondary mx-auto mb-4" }),
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "text-ods-text-primary font-['DM_Sans'] text-[20px] font-semibold mb-2", children: "No onboarding guides found" }),
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-ods-text-secondary font-['DM_Sans'] text-[14px]", children: activeSection !== "all" ? "No guides in this section yet." : "We're working on the onboarding library. Check back soon." })
    ] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: isPending || isLoading ? "opacity-60 transition-opacity space-y-10" : "space-y-10", children: grouped.map((sec) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { className: "space-y-4", children: [
      /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "h2", { className: "text-h3 tracking-[-0.36px] text-ods-text-primary flex items-center gap-2", children: [
        sec.section,
        /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "inline-flex items-center justify-center rounded-full bg-ods-text-secondary/20 text-ods-text-secondary text-xs font-medium px-2 py-0.5", children: sec.guides.length })
      ] }),
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "flex flex-col gap-4", children: sec.guides.map((guide) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: renderCardFn(guide) }, guide.id)) })
    ] }, sec.section)) })
  ] });
}

// src/components/onboarding-guides/onboarding-guide-detail-view.tsx


function OnboardingGuideDetailView({
  authorHref,
  authorBio,
  fallbackBio,
  initialData,
  slug,
  guideEndpoint,
  related = [],
  MarkdownRenderer = _chunkUUARMJJEcjs.SimpleMarkdownRenderer,
  renderRelatedCard,
  backHref,
  backLabel = "Back to Getting Started",
  basePath = "/onboarding-guides"
}) {
  const resolvedBackHref = _nullishCoalesce(backHref, () => ( basePath));
  const runtime = _chunkMEAR2WHScjs.useChatRuntime.call(void 0, );
  const url = initialData ? null : slug && guideEndpoint ? guideEndpoint(slug) : null;
  const { data: guide, isLoading, error, reload } = _chunkT7AJBKZPcjs.useSelfFetch.call(void 0, url, { initialData });
  const { ref: videoWarmupRef } = _chunkUUARMJJEcjs.useVideoWarmup.call(void 0, {
    videoUrl: _optionalChain([guide, 'optionalAccess', _6 => _6.main_video_url]),
    supabaseStorageOrigin: _optionalChain([runtime, 'optionalAccess', _7 => _7.endpoints, 'access', _8 => _8.supabaseStorageOrigin])
  });
  if (error || !guide && !isLoading) {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkUUARMJJEcjs.LoadError, { message: "Guide not found.", onRetry: reload });
  }
  if (!guide) {
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQXRXIHY6cjs.DetailPageSkeleton, { showImageGallery: false });
  }
  const captionsUrl = _chunkUUARMJJEcjs.getCaptionsUrl.call(void 0, "onboarding_guide", guide.id, guide.srt_content);
  const videoPoster = guide.main_video_thumbnail || guide.featured_image || guide.og_image_url || _optionalChain([runtime, 'optionalAccess', _9 => _9.resolvePlaceholderUrl, 'optionalCall', _10 => _10(guide.title, { aspect: "wide" })]) || void 0;
  const defaultRenderRelatedCard = (g) => {
    const cta = _chunkUUARMJJEcjs.resolveContentHref.call(void 0, _optionalChain([runtime, 'optionalAccess', _11 => _11.composeContentUrl]), {
      type: "onboarding_guide",
      slug: g.slug,
      basePath,
      platforms: g.onboarding_guide_platforms
    });
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkUUARMJJEcjs.OnboardingGuideCard, { guide: g, href: cta.href, targetPlatform: cta.targetPlatform });
  };
  const renderRelatedCardFn = _nullishCoalesce(renderRelatedCard, () => ( defaultRenderRelatedCard));
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkUUARMJJEcjs.PageShell, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-6 md:space-y-8", children: [
    /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, 
      _chunkWBR7H6E3cjs.next_link_default,
      {
        href: resolvedBackHref,
        className: "inline-flex items-center gap-2 text-ods-text-secondary hover:text-ods-accent transition-colors",
        children: [
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArrowLeft, { className: "h-4 w-4" }),
          /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-h5", children: backLabel })
        ]
      }
    ),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-h1 tracking-[-1.12px] text-ods-text-primary", children: guide.title }),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkJMU4RU5Jcjs.EntityTagBadges, { tags: guide.onboarding_guide_tags }),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkUUARMJJEcjs.EntityAuthorCard,
      {
        author: guide.author,
        authorHref,
        publishedAt: guide.published_at,
        extraCells: [
          {
            value: `${guide.section} \xB7 Step ${guide.step_order}`,
            label: "Section",
            uppercase: false
          }
        ]
      }
    ),
    (guide.main_video_url || guide.youtube_url) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: videoWarmupRef, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkUUARMJJEcjs.EntityVideoSection,
      {
        mainVideoUrl: guide.main_video_url,
        youtubeUrl: guide.youtube_url || void 0,
        highlightVideoUrl: guide.highlight_video_url,
        mainVideoPoster: videoPoster,
        highlightVideoThumbnail: guide.highlight_video_thumbnail || void 0,
        videoSummary: void 0,
        videoBites: void 0,
        title: guide.title,
        srtContent: guide.srt_content,
        captionsUrl,
        MarkdownRenderer
      }
    ) }),
    guide.content && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MarkdownRenderer, { content: guide.content }) }),
    guide.video_bites && guide.video_bites.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkUUARMJJEcjs.VideoBitesDisplay,
      {
        bites: guide.video_bites,
        filterPublished: true,
        showTitle: false
      }
    ),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      _chunkQXRXIHY6cjs.ArticleAuthorByline,
      {
        author: _nullishCoalesce(_optionalChain([guide, 'access', _12 => _12.author, 'optionalAccess', _13 => _13.full_name]), () => ( null)),
        avatar: _optionalChain([guide, 'access', _14 => _14.author, 'optionalAccess', _15 => _15.avatar_url]),
        jobTitle: _optionalChain([guide, 'access', _16 => _16.author, 'optionalAccess', _17 => _17.job_title]),
        bio: _nullishCoalesce(authorBio, () => ( _optionalChain([guide, 'access', _18 => _18.author, 'optionalAccess', _19 => _19.about]))),
        href: authorHref,
        fallbackBio
      }
    ),
    related.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-4 pt-8 border-t border-ods-border", children: [
      /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "h2", { className: "text-h3 tracking-[-0.36px] text-ods-text-primary", children: [
        "More in ",
        guide.section
      ] }),
      /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "flex flex-col gap-3", children: related.map((r) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: renderRelatedCardFn(r) }, r.id)) })
    ] })
  ] }) });
}

// src/components/onboarding-guides/hooks/use-onboarding-guides.ts
var _reactquery = require('@tanstack/react-query');
var onboardingGuideKeys = {
  all: ["onboarding-guides"],
  lists: () => [...onboardingGuideKeys.all, "list"],
  list: (filters) => [...onboardingGuideKeys.lists(), filters],
  details: () => [...onboardingGuideKeys.all, "detail"],
  detail: (slug) => [...onboardingGuideKeys.details(), slug],
  sections: () => [...onboardingGuideKeys.all, "sections"],
  admin: {
    all: ["admin", "onboarding-guides"],
    lists: () => ["admin", "onboarding-guides", "list"],
    detail: (slug) => ["admin", "onboarding-guide", slug],
    stats: () => ["admin", "onboarding-guides", "stats"]
  }
};
function useOnboardingGuides(filters) {
  return _reactquery.useQuery.call(void 0, {
    queryKey: onboardingGuideKeys.list(filters || {}),
    queryFn: async () => {
      const params = new URLSearchParams();
      if (_optionalChain([filters, 'optionalAccess', _20 => _20.search])) params.set("search", filters.search);
      if (_optionalChain([filters, 'optionalAccess', _21 => _21.section])) params.set("section", filters.section);
      if (_optionalChain([filters, 'optionalAccess', _22 => _22.limit])) params.set("limit", filters.limit.toString());
      if (_optionalChain([filters, 'optionalAccess', _23 => _23.offset])) params.set("offset", filters.offset.toString());
      const res = await fetch(`/api/onboarding-guides?${params}`);
      if (!res.ok) throw new Error("Failed to fetch onboarding guides");
      return res.json();
    }
  });
}
function useOnboardingGuide(slug) {
  return _reactquery.useQuery.call(void 0, {
    queryKey: onboardingGuideKeys.detail(slug || ""),
    queryFn: async () => {
      const res = await fetch(`/api/onboarding-guides/${slug}`);
      if (!res.ok) throw new Error("Failed to fetch onboarding guide");
      return res.json();
    },
    enabled: !!slug
  });
}
function useOnboardingGuideSections() {
  return _reactquery.useQuery.call(void 0, {
    queryKey: onboardingGuideKeys.sections(),
    queryFn: async () => {
      const res = await fetch("/api/onboarding-guides/sections");
      if (!res.ok)
        throw new Error("Failed to fetch onboarding-guide sections");
      return res.json();
    },
    staleTime: 0
  });
}








exports.OnboardingGuideDetailView = OnboardingGuideDetailView; exports.OnboardingGuidesCatalogSkeleton = OnboardingGuidesCatalogSkeleton; exports.OnboardingGuidesCatalogView = OnboardingGuidesCatalogView; exports.onboardingGuideKeys = onboardingGuideKeys; exports.useOnboardingGuide = useOnboardingGuide; exports.useOnboardingGuideSections = useOnboardingGuideSections; exports.useOnboardingGuides = useOnboardingGuides;
//# sourceMappingURL=index.cjs.map