{"version":3,"file":"virtual_main.js","sources":["theme-13/virtual:init-settings","theme-13/virtual:theme","theme-13/discourse/components/category-banner.hbs","theme-13/discourse/components/category-banner.js","theme-13/discourse/initializers/discourse-category-banners.js","theme-13/discourse/services/category-banner-presence.js","theme-13/virtual:main"],"sourcesContent":["import { registerSettings } from \"discourse/lib/theme-settings-store\";\n\nregisterSettings(13, {\n  \"show_description\": false,\n  \"show_mobile\": true,\n  \"show_subcategory\": true,\n  \"hide_if_no_description\": true,\n  \"show_category_logo\": false,\n  \"align_text\": \"left\",\n  \"exceptions\": \"\",\n  \"categories\": [],\n  \"plugin_outlet\": \"above-main-container\",\n  \"show_category_icon\": false,\n  \"override_category_icon_color\": false\n});\n","import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(13);\n\nexport function themePrefix(key) {\n  return `theme_translations.13.${key}`;\n}\n","{{#if this.shouldRender}}\n  <div\n    {{did-insert this.getCategory}}\n    {{did-update this.getCategory this.isVisible}}\n    {{will-destroy this.teardownComponent}}\n    class=\"category-title-header\n      {{if this.category (concat 'category-banner-' this.category.slug)}}\"\n    style={{if this.category this.safeStyle}}\n  >\n    {{#if this.category}}\n      <div class=\"category-title-contents\">\n        {{#if (theme-setting \"show_category_logo\")}}\n          <CategoryLogo @category={{this.category}} />\n        {{/if}}\n        <h1 class=\"category-title\">\n          {{#if (and (theme-setting \"show_category_icon\") this.category)}}\n            {{#if this.hasIconComponent}}\n              {{! For compatibility with https://meta.discourse.org/t/category-icons/104683}}\n              <CategoryIcon @category={{this.category}} />\n            {{else}}\n              {{this.consoleWarn}}\n            {{/if}}\n          {{/if}}\n          {{#if this.category.read_restricted}}\n            {{d-icon \"lock\"}}\n          {{/if}}\n          {{this.category.name}}\n          <PluginOutlet @name=\"category-banners-after-title\" />\n        </h1>\n\n        {{#if this.displayCategoryDescription}}\n          <div class=\"category-title-description\">\n            <div class=\"cooked\">\n              {{html-safe this.category.description}}\n            </div>\n          </div>\n        {{/if}}\n      </div>\n    {{/if}}\n  </div>\n{{/if}}","import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { getOwner } from \"@ember/application\";\nimport { action } from \"@ember/object\";\nimport { service } from \"@ember/service\";\nimport { htmlSafe } from \"@ember/template\";\nimport Category from \"discourse/models/category\";\n\nexport default class DiscourseCategoryBanners extends Component {\n  @service router;\n  @service site;\n  @service categoryBannerPresence;\n  @tracked category = null;\n  @tracked keepDuringLoadingRoute = false;\n\n  get hasIconComponent() {\n    return getOwner(this).hasRegistration(\"component:category-icon\");\n  }\n\n  get categorySlugPathWithID() {\n    return this.router?.currentRoute?.params?.category_slug_path_with_id;\n  }\n\n  get shouldRender() {\n    return (\n      this.categorySlugPathWithID ||\n      (this.keepDuringLoadingRoute &&\n        this.router.currentRoute.name.includes(\"loading\"))\n    );\n  }\n\n  get isVisible() {\n    if (this.categorySlugPathWithID) {\n      return true;\n    } else if (this.router.currentRoute.name.includes(\"loading\")) {\n      return this.keepDuringLoadingRoute;\n    }\n    return false;\n  }\n\n  get safeStyle() {\n    return htmlSafe(\n      `background-color: #${this.category.color}; color: #${this.category.text_color};`\n    );\n  }\n\n  get consoleWarn() {\n    // eslint-disable-next-line no-console\n    return console.warn(\n      \"The category banners component is trying to use the category icons component, but it is not available. https://meta.discourse.org/t/category-icons/104683\"\n    );\n  }\n\n  get displayCategoryDescription() {\n    return settings.show_description && this.category.description?.length > 0;\n  }\n\n  #parseExceptions(exceptionsStr) {\n    return exceptionsStr\n      .split(\"|\")\n      .filter(Boolean)\n      .map((value) => value.toLowerCase());\n  }\n\n  #checkTargetCategory() {\n    if (settings.categories.length === 0) {\n      return true;\n    }\n\n    const currentCategoryId = this.category?.id;\n\n    const activeCategory = settings.categories.find((category) => {\n      return category.category_id[0] === currentCategoryId;\n    });\n\n    if (\n      activeCategory &&\n      (activeCategory.target === \"all\" || activeCategory.target === \"no_sub\")\n    ) {\n      return true;\n    }\n\n    const parentCategoryId = this.category?.parentCategory?.id;\n\n    if (parentCategoryId) {\n      const activeParentCategory = settings.categories.find((category) => {\n        return category.category_id[0] === parentCategoryId;\n      });\n\n      if (\n        activeParentCategory &&\n        (activeParentCategory.target === \"all\" ||\n          activeParentCategory.target === \"only_sub\")\n      ) {\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  @action\n  teardownComponent() {\n    document.body.classList.remove(\"category-header\");\n    this.category = null;\n    this.categoryBannerPresence.setTo(false);\n  }\n\n  @action\n  getCategory() {\n    if (!this.isVisible) {\n      return;\n    }\n\n    if (this.categorySlugPathWithID) {\n      this.category = Category.findBySlugPathWithID(\n        this.categorySlugPathWithID\n      );\n      this.categoryBannerPresence.setTo(true);\n      this.keepDuringLoadingRoute = true;\n    } else {\n      if (!this.router.currentRoute.name.includes(\"loading\")) {\n        return (this.keepDuringLoadingRoute = false);\n      }\n    }\n\n    const exceptions = this.#parseExceptions(settings.exceptions);\n    const isException = exceptions.includes(this.category?.name.toLowerCase());\n    const isTarget = this.#checkTargetCategory();\n    const hideMobile = this.site.mobileView && !settings.show_mobile;\n    const hideSubCategory =\n      this.category?.parentCategory && !settings.show_subcategory;\n    const hasNoCategoryDescription =\n      settings.hide_if_no_description && !this.category?.description_text;\n\n    if (\n      isTarget &&\n      !isException &&\n      !hasNoCategoryDescription &&\n      !hideSubCategory &&\n      !hideMobile\n    ) {\n      document.body.classList.add(\"category-header\");\n    } else {\n      document.body.classList.remove(\"category-header\");\n      this.categoryBannerPresence.setTo(false);\n    }\n  }\n}\n","import { apiInitializer } from \"discourse/lib/api\";\nimport CategoryBanner from \"../components/category-banner\";\n\nexport default apiInitializer(\"1.13.0\", (api) => {\n  api.renderInOutlet(settings.plugin_outlet, CategoryBanner);\n});\n","import { tracked } from \"@glimmer/tracking\";\nimport Service from \"@ember/service\";\n\nexport default class CategoryBannerPresence extends Service {\n  @tracked isPresent = false;\n\n  setTo(value) {\n    this.isPresent = value;\n  }\n}\n","import \"virtual:init-settings\";\n\nconst themeCompatModules = {};\nimport * as Mod1 from \"./discourse/components/category-banner\";\nthemeCompatModules[\"discourse/components/category-banner\"] = Mod1;\n\nimport * as Mod2 from \"./discourse/components/category-banner\";\nthemeCompatModules[\"discourse/components/category-banner\"] = Mod2;\n\nimport * as Mod3 from \"./discourse/initializers/discourse-category-banners\";\nthemeCompatModules[\"discourse/initializers/discourse-category-banners\"] = Mod3;\n\nimport * as Mod4 from \"./discourse/services/category-banner-presence\";\nthemeCompatModules[\"discourse/services/category-banner-presence\"] = Mod4;\n\nexport default themeCompatModules;\n"],"names":["registerSettings","show_description","show_mobile","show_subcategory","hide_if_no_description","show_category_logo","align_text","exceptions","categories","plugin_outlet","show_category_icon","override_category_icon_color","settings","getObjectForTheme","createTemplateFactory","id","block","moduleName","isStrictMode","DiscourseCategoryBanners","Component","static","dt7948","g","this","prototype","service","router","i","site","categoryBannerPresence","tracked","category","keepDuringLoadingRoute","hasIconComponent","getOwner","hasRegistration","categorySlugPathWithID","currentRoute","params","category_slug_path_with_id","shouldRender","name","includes","isVisible","safeStyle","htmlSafe","color","text_color","consoleWarn","console","warn","displayCategoryDescription","description","length","parseExceptions","exceptionsStr","split","filter","Boolean","map","value","toLowerCase","checkTargetCategory","currentCategoryId","activeCategory","find","category_id","target","parentCategoryId","parentCategory","activeParentCategory","teardownComponent","document","body","classList","remove","setTo","n","action","getCategory","Category","findBySlugPathWithID","isException","isTarget","hideMobile","mobileView","hideSubCategory","hasNoCategoryDescription","description_text","add","_setComponentTemplate","__COLOCATED_TEMPLATE__","discourseCategoryBanners","apiInitializer","api","renderInOutlet","CategoryBanner","CategoryBannerPresence","Service","isPresent","themeCompatModules","Mod1","Mod2","Mod3","Mod4"],"mappings":";AAEAA,EAAiB,GAAI,CACnBC,kBAAoB,EACpBC,aAAe,EACfC,kBAAoB,EACpBC,wBAA0B,EAC1BC,oBAAsB,EACtBC,WAAc,OACdC,WAAc,GACdC,WAAc,GACdC,cAAiB,uBACjBC,oBAAsB,EACtBC,8BAAgC;ACX3B,MAAM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