/* ===========================================================
   App root: route switch + footer
   =========================================================== */

function Footer() {
  const cats = window.DATA.categories;
  return React.createElement("footer", { className: "footer" },
    React.createElement("div", { className: "wrap" },
      React.createElement("div", { className: "footer-grid" },
        React.createElement("div", null,
          React.createElement(Logo, { light: true }),
          React.createElement("p", { style: { marginTop: 14, maxWidth: 280, fontSize: 14 } }, "Heavy-duty clutch, brake, flywheel and kingpin specialists. Manufacturing & reman since 1980."),
          React.createElement("div", { style: { marginTop: 16, display: "flex", flexDirection: "column", gap: 6, fontSize: 14 } },
            React.createElement("a", { href: "tel:4102358829" }, "410-235-8829"),
            React.createElement("a", { href: "mailto:kevin@dwt.solutions" }, "kevin@dwt.solutions"),
            React.createElement("span", { style: { color: "#8a8a93" } }, "2601 Sisson St, Baltimore MD 21211"))),
        React.createElement("div", null,
          React.createElement("h5", null, "Catalog"),
          cats.slice(0, 6).map(c => React.createElement(Link, { key: c.id, to: "/c/" + c.slug }, c.name))),
        React.createElement("div", null,
          React.createElement("h5", null, "Company"),
          React.createElement(Link, { to: "/about" }, "About"),
          React.createElement(Link, { to: "/videos" }, "Videos"),
          React.createElement(Link, { to: "/info/diamond-brakes" }, "Diamond Brakes"),
          React.createElement(Link, { to: "/contact" }, "Contact")),
        React.createElement("div", null,
          React.createElement("h5", null, "Support"),
          React.createElement(Link, { to: "/policies" }, "Policies"),
          React.createElement(Link, { to: "/warranties" }, "Warranties"),
          React.createElement(Link, { to: "/b2b" }, "B2B accounts"),
          React.createElement(Link, { to: "/quote" }, "Quote Builder"))),
      React.createElement("div", { className: "footer-bot" },
        React.createElement("span", null, "© " + new Date().getFullYear() + " DWTruck Solutions · dwt.solutions · Shift to quality."),
        React.createElement("span", null, "Prototype — representative data, mirrors the /api/v1 contract"))
    )
  );
}

function Routes() {
  const { path, params } = useRouter();
  const seg = path.split("/").filter(Boolean);
  let page;
  if (path === "/" || path === "") page = React.createElement(HomePage, null);
  else if (seg[0] === "c") page = React.createElement(CategoryPage, { slug: seg[1] });
  else if (seg[0] === "p") page = React.createElement(ProductPage, { slug: seg[1] });
  else if (seg[0] === "search") page = React.createElement(SearchPage, { q: params.q });
  else if (seg[0] === "quote" && seg[1]) page = React.createElement(QuoteView, { number: seg[1] });
  else if (seg[0] === "quote") page = React.createElement(QuotePage, null);
  else if (seg[0] === "quote-request") page = React.createElement(QuoteRequestPage, null);
  else if (seg[0] === "cart") page = React.createElement(CartPage, null);
  else if (seg[0] === "checkout") page = React.createElement(CheckoutPage, null);
  else if (seg[0] === "order") page = React.createElement(OrderPage, { number: seg[1] });
  else if (seg[0] === "account") page = React.createElement(AccountPage, null);
  else if (seg[0] === "b2b") page = React.createElement(B2BPage, null);
  else if (seg[0] === "about") page = React.createElement(AboutPage, null);
  else if (seg[0] === "contact") page = React.createElement(ContactPage, null);
  else if (seg[0] === "videos") page = React.createElement(VideosPage, null);
  else if (seg[0] === "policies") page = React.createElement(PoliciesPage, null);
  else if (seg[0] === "warranties") page = React.createElement(WarrantiesPage, null);
  else if (seg[0] === "info" && seg[1] === "diamond-brakes") page = React.createElement(DiamondBrakesPage, null);
  else page = React.createElement(NotFound, null);

  // hide footer on quote builder for cleaner tool feel? keep it but not on builder/cart/checkout
  const noFooter = ["quote", "cart", "checkout"].includes(seg[0]) && !seg[1];
  return React.createElement(React.Fragment, null, page, noFooter ? null : React.createElement(Footer, null));
}

/* ===========================================================
   Tweaks — accent, trust bar, hero eyebrow, motion
   =========================================================== */
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "accent": ["#1583D1", "#1069ab", "#0E5C9C"],
  "showTrustBar": true,
  "heroEyebrow": "Baltimore, MD · Since 1980",
  "motion": true
}/*EDITMODE-END*/;

const ACCENT_OPTS = [
  ["#1583D1", "#1069ab", "#0E5C9C"],
  ["#2563EB", "#1D4ED8", "#1E40AF"],
  ["#0EA5B5", "#0C8797", "#0A6470"],
  ["#4F6BD8", "#3F55B0", "#2E3F86"]
];

function TweaksUI({ t, setTweak }) {
  return React.createElement(TweaksPanel, { title: "Tweaks" },
    React.createElement(TweakSection, { label: "Brand" }),
    React.createElement(TweakColor, {
      label: "Accent", value: t.accent, options: ACCENT_OPTS,
      onChange: (v) => setTweak("accent", v)
    }),
    React.createElement(TweakSection, { label: "Trust bar" }),
    React.createElement(TweakToggle, {
      label: "Show trust bar", value: t.showTrustBar !== false,
      onChange: (v) => setTweak("showTrustBar", v)
    }),
    React.createElement(TweakSection, { label: "Hero" }),
    React.createElement(TweakText, {
      label: "Eyebrow", value: t.heroEyebrow || "",
      placeholder: "Baltimore, MD · Since 1980",
      onChange: (v) => setTweak("heroEyebrow", v)
    }),
    React.createElement(TweakSection, { label: "Motion" }),
    React.createElement(TweakToggle, {
      label: "Scroll animations", value: t.motion !== false,
      onChange: (v) => setTweak("motion", v)
    })
  );
}

function TweaksProvider({ children }) {
  const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);
  useEffect(() => {
    const r = document.documentElement.style;
    const a = Array.isArray(t.accent) ? t.accent : [t.accent];
    if (a[0]) r.setProperty("--blue", a[0]);
    if (a[1]) r.setProperty("--blue-700", a[1]);
    if (a[2]) { r.setProperty("--purple", a[2]); r.setProperty("--purple-700", a[2]); }
  }, [t.accent]);
  useEffect(() => {
    document.body.classList.toggle("motion-off", t.motion === false);
  }, [t.motion]);
  return React.createElement(TweaksCtx.Provider, { value: { t, setTweak } },
    children,
    React.createElement(TweaksUI, { t, setTweak })
  );
}

function App() {
  return React.createElement(RouterProvider, null,
    React.createElement(TweaksProvider, null,
      React.createElement(ToastProvider, null,
        React.createElement(CartProvider, null,
          React.createElement(QuoteProvider, null,
            React.createElement("div", { className: "app-scroll" },
              React.createElement(Header, null),
              React.createElement("main", { id: "main" }, React.createElement(Routes, null))
            )
          )
        )
      )
    )
  );
}

function boot() {
  ReactDOM.createRoot(document.getElementById("root")).render(React.createElement(App));
}
function showSplash(msg) {
  const r = document.getElementById("root");
  if (r) r.innerHTML = '<div style="min-height:100vh;display:grid;place-items:center;font-family:Barlow,system-ui,sans-serif;background:#fff">'
    + '<div style="text-align:center"><div style="font-family:\'Barlow Semi Condensed\',sans-serif;font-weight:700;font-size:24px;color:#0F1A2A;letter-spacing:.02em">D&amp;W TRUCK</div>'
    + '<div style="margin-top:8px;font-size:14px;color:#8a94a3">' + msg + '</div></div></div>';
}
if (window.DATA && window.DATA.ready && typeof window.DATA.ready.then === "function") {
  showSplash("Loading catalog…");
  window.DATA.ready.then(boot).catch(function () { showSplash("Couldn't reach the catalog — please refresh."); });
} else {
  boot();
}
