{"version":3,"file":"main.CMwDsL.js","sources":["theme-4/virtual:theme","theme-4/discourse/components/big-logo.gjs","theme-4/discourse/api-initializers/big-header.js","theme-4/virtual:entrypoint:main"],"sourcesContent":["import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(4);\n\nexport function themePrefix(key) {\n  return `theme_translations.4.${key}`;\n}\n","import Component from \"@glimmer/component\";\nimport { on } from \"@ember/modifier\";\nimport { action } from \"@ember/object\";\nimport { service } from \"@ember/service\";\nimport { wantsNewWindow } from \"discourse/lib/intercept-click\";\nimport DiscourseURL from \"discourse/lib/url\";\n\nexport default class BigLogo extends Component {\n  @service site;\n  @service session;\n\n  get showLogo() {\n    return this.site.desktopView && this.logoUrl;\n  }\n\n  get logoUrl() {\n    const darkModeConfigured =\n      this.session.darkModeAvailable ||\n      this.session.defaultColorSchemeIsDark;\n    const prefersDark = window.matchMedia(\n      \"(prefers-color-scheme: dark)\"\n    ).matches;\n\n    if (darkModeConfigured && prefersDark && settings.logo_url_dark) {\n      return settings.logo_url_dark;\n    }\n    return settings.logo_url;\n  }\n\n  @action\n  click(event) {\n    if (wantsNewWindow(event)) {\n      return;\n    }\n    event.preventDefault();\n    DiscourseURL.routeTo(\"/\");\n  }\n\n  <template>\n    {{#if this.showLogo}}\n      <div id=\"logo-container\" class=\"wrap\">\n        <a id=\"logo-link\" href=\"/\" {{on \"click\" this.click}}>\n          <img\n            class=\"logo-really-big\"\n            src={{this.logoUrl}}\n            alt={{settings.logo_alt}}\n          />\n        </a>\n      </div>\n    {{/if}}\n  </template>\n}\n","import { apiInitializer } from \"discourse/lib/api\";\nimport BigLogo from \"../components/big-logo\";\n\nexport default apiInitializer((api) => {\n  // Render the large logo into the header. `header-contents__before` is a\n  // pure-injection outlet, so this adds to the header without replacing the\n  // core home logo (which we still need for the scrolled-down state).\n  api.renderInOutlet(\"header-contents__before\", BigLogo);\n\n  const site = api.container.lookup(\"service:site\");\n  const body = document.body;\n  const root = document.documentElement.style;\n  let headerWrap;\n  let mainOutletWrapper;\n  let collapsed = false;\n\n  // Core recomputes `--header-offset` / `--main-outlet-offset` (which the\n  // sidebar and content position off of) only on scroll, debounced to fire\n  // ~10ms after scrolling stops. When we change the header height mid-scroll\n  // those offsets go stale until then, so the sidebar lags. Recompute them\n  // ourselves the moment the header state flips. Mirrors core's calculation\n  // in glimmer-site-header.gjs.\n  const syncOffsets = () => {\n    headerWrap ||= document.querySelector(\".d-header-wrap\");\n    mainOutletWrapper ||= document.querySelector(\"#main-outlet-wrapper\");\n    if (!headerWrap) {\n      return;\n    }\n    // Reading getBoundingClientRect forces the pending reflow, so we measure\n    // the header at its new height.\n    const headerWrapBottom = Math.max(\n      0,\n      headerWrap.getBoundingClientRect().bottom\n    );\n    const mainOutletOffsetTop = mainOutletWrapper\n      ? Math.max(0, mainOutletWrapper.getBoundingClientRect().top - headerWrapBottom)\n      : 0;\n    root.setProperty(\"--header-offset\", `${Math.floor(headerWrapBottom)}px`);\n    root.setProperty(\n      \"--main-outlet-offset\",\n      `${Math.floor(headerWrapBottom + mainOutletOffsetTop)}px`\n    );\n  };\n\n  // Toggle the `scrolled-down` body class as the big header scrolls out of\n  // view. Replaces the old jQuery scroll handler; jQuery was removed from core.\n  //\n  // Uses two thresholds with a deadzone (hysteresis) rather than a single\n  // direction-based threshold. Collapsing to the compact header changes the\n  // header height by ~100px, so a single threshold flip-flops as momentum/\n  // subpixel scroll wobbles `scrollY` across it — that's the jitter. With a\n  // deadzone the state can only flip once per crossing.\n  const onScroll = () => {\n    // Desktop-only pattern. On mobile, do nothing and make sure the class\n    // isn't left applied (e.g. after a resize across the breakpoint).\n    if (!site.desktopView) {\n      if (collapsed) {\n        collapsed = false;\n        body.classList.remove(\"scrolled-down\");\n      }\n      return;\n    }\n\n    const collapseAt = settings.logo_height + 30; // collapse to compact header\n    const expandAt = 20; // back near the top: restore the big header\n    const scroll = window.scrollY;\n\n    let next = collapsed;\n    if (scroll >= collapseAt) {\n      next = true;\n    } else if (scroll <= expandAt) {\n      next = false;\n    }\n    // Between the two thresholds the current state is kept.\n\n    if (next !== collapsed) {\n      collapsed = next;\n      body.classList.toggle(\"scrolled-down\", collapsed);\n      requestAnimationFrame(syncOffsets);\n    }\n  };\n\n  window.addEventListener(\"scroll\", onScroll, { passive: true });\n\n  // Set the initial state from a page-render callback rather than calling\n  // onScroll() during initialization. Reading `site.desktopView` before the\n  // app has booted is deprecated (discourse.static-viewport-initialization).\n  api.onPageChange(onScroll);\n});\n","import * as Mod1 from \"./discourse/api-initializers/big-header\";\nimport * as Mod2 from \"./discourse/components/big-logo\";\nconst compatModules = {\n  \"discourse/api-initializers/big-header\": Mod1,\n  \"discourse/components/big-logo\": Mod2,\n};\nexport { compatModules };\nexport default compatModules;\n"],"names":["settings","getObjectForTheme","BigLogo","Component","dt7948","g","this","prototype","service","site","i","session","showLogo","desktopView","logoUrl","darkModeConfigured","darkModeAvailable","defaultColorSchemeIsDark","prefersDark","window","matchMedia","matches","logo_url_dark","logo_url","click","event","wantsNewWindow","preventDefault","DiscourseURL","routeTo","n","action","setComponentTemplate","createTemplateFactory","id","block","moduleName","scope","on","isStrictMode","bigHeader","apiInitializer","api","renderInOutlet","container","lookup","body","document","root","documentElement","style","headerWrap","mainOutletWrapper","collapsed","syncOffsets","querySelector","headerWrapBottom","Math","max","getBoundingClientRect","bottom","mainOutletOffsetTop","top","setProperty","floor","onScroll","classList","remove","collapseAt","logo_height","scroll","scrollY","next","toggle","requestAnimationFrame","addEventListener","passive","onPageChange","compatModules","Mod2"],"mappings":"qyBAEaA,EAAWC,EAAkB;ACK3B,MAAMC,UAAgBC,SAAAC,OAAAC,EAAAC,KAAAC,kBAClCC,GAAA,CAAAC,QAAAL,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,qBACAC,GAAA,CAAAG,QAAAP,OAAAM,EAAAJ,KAAA;AAED,YAAIM,GACF,OAAON,KAAKG,KAAKI,aAAeP,KAAKQ,OACvC,CAEA,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