const { useState } = React; const SpecComponents = window.SpecComponents || {}; const SpecHooks = window.SpecHooks || {}; const { SpecHeader, CardGrid, SplitView, Accordion, FunctionalitiesTabs } = SpecComponents; const useSpecMetadataSafe = SpecHooks.useSpecMetadata || (() => ({ specMeta: null, navLinks: [], specError: "Spec hooks not loaded" })); const useFunctionalitiesSafe = SpecHooks.useFunctionalities || (() => ({ functionalities: [], loading: false, error: "Spec hooks not loaded" })); const useCfrSafe = SpecHooks.useCfr || (() => ({ items: [], loading: false, error: "CFR hooks not loaded" })); const VIEW_TABS = [ { id: "cards", label: "Option 1 — Card Grid + Drawer" }, { id: "split", label: "Option 2 — Split Panel" }, { id: "accordion", label: "Option 4 — Accordion" }, ]; function App() { const [tab, setTab] = useState("cards"); const [activeNav, setActiveNav] = useState("functionalities"); const { specMeta, navLinks, specError } = useSpecMetadataSafe(); const { functionalities, loading, error } = useFunctionalitiesSafe(specMeta?.functionalities?.path); const { items: cfrItems, loading: cfrLoading, error: cfrError } = useCfrSafe(specMeta?.["cross-functional-requirements"]?.path); if (!SpecHeader || !FunctionalitiesTabs || !CardGrid || !SplitView || !Accordion) { return (
Loading app assets…
); } return (
{specError && (
Metadata warning: {specError}
)} {activeNav === "functionalities" && loading && (
Loading functionality data…
)} {activeNav === "functionalities" && !loading && error && (
Failed to load data: {error}
)} {activeNav === "functionalities" && !loading && !error && !functionalities.length && (
No functionality data found.
)} {activeNav === "functionalities" && !loading && !error && functionalities.length > 0 && ( <> {tab === "cards" && } {tab === "split" && } {tab === "accordion" && } )} {activeNav === "cfr" && cfrLoading && (
Loading cross-functional requirements…
)} {activeNav === "cfr" && !cfrLoading && cfrError && (
Failed to load data: {cfrError}
)} {activeNav === "cfr" && !cfrLoading && !cfrError && !cfrItems.length && (
No cross-functional requirements found.
)} {activeNav === "cfr" && !cfrLoading && !cfrError && cfrItems.length > 0 && ( <> {tab === "cards" && } {tab === "split" && } {tab === "accordion" && } )}
); } window.SpecApp = App;