{"version":3,"file":"virtual_main.js","sources":["theme-22/virtual:init-settings","theme-22/virtual:theme","theme-22/discourse/components/advertisement-bar.gjs","theme-22/discourse/initializers/advertisement-bar.js","theme-22/virtual:main"],"sourcesContent":["import { registerSettings } from \"discourse/lib/theme-settings-store\";\n\nregisterSettings(22, {\n  \"bar_text\": \"\",\n  \"background_image\": \"//community-ccleaner-uploads-production.s3.dualstack.us-east-1.amazonaws.com/original/2X/c/ccb875e276c909e306492ce9adea90713518703f.png\",\n  \"button_text\": \"\",\n  \"button_link\": \"https://community.ccleaner.com/index.php?app=core&module=system&controller=redirect&do=advertisement&ad=1&key=e54ba96ec6743ae48396d23c6d0d61c5762f6b25e73d4eea75a8f9c21682d3ec\",\n  \"update_version\": \"20231116\",\n  \"show_on\": \"everywhere\",\n  \"plugin_outlet\": \"above-footer\",\n  \"hide_on_mobile\": false\n});\n","import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(22);\n\nexport function themePrefix(key) {\n  return `theme_translations.22.${key}`;\n}\n","import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport { action } from '@ember/object';\nimport { inject as service } from '@ember/service';\nimport { htmlSafe } from '@ember/template';\nimport cookie, { removeCookie } from 'discourse/lib/cookie';\nimport { defaultHomepage } from 'discourse/lib/utilities';\nimport icon from 'discourse-common/helpers/d-icon';\nimport and from 'truth-helpers/helpers/and';\n\nexport default class advertisementBar extends Component {\n  @service site;\n  @service siteSettings;\n  @service router;\n  @tracked closed = false;\n\n  <template>\n    {{#if (and this.showOnRoute this.showOnMobile this.cookieState)}}\n      <div class='advertisement-bar__wrapper {{settings.plugin_outlet}}'>\n        <div class='advertisement-bar__container'>\n          <div class='advertisement-bar__content'>\n            <span>{{htmlSafe settings.bar_text}}</span>\n            <a\n              class='advertisement-bar_text'\n              href='{{settings.button_link}}'\n            >{{settings.button_text}}</a>\n          </div>\n          <div class='advertisement-bar__close'>\n            <a {{on 'click' this.closeBanner}}>\n              {{icon 'times'}}\n            </a>\n          </div>\n        </div>\n      </div>\n    {{/if}}\n  </template>\n\n  get showOnRoute() {\n    const currentRoute = this.router.currentRouteName;\n    switch (settings.show_on) {\n      case 'everywhere':\n        return !currentRoute.includes('admin');\n      case 'homepage':\n        return currentRoute === `discovery.${defaultHomepage()}`;\n      case 'latest/top/new/categories':\n        const topMenu = this.siteSettings.top_menu;\n        const targets = topMenu.split('|').map((opt) => `discovery.${opt}`);\n        return targets.includes(currentRoute);\n      default:\n        return false;\n    }\n  }\n\n  get showOnMobile() {\n    if (settings.hide_on_mobile && this.site.mobileView) {\n      return false;\n    } else {\n      return true;\n    }\n  }\n\n  get cookieExpirationDate() {\n    return moment().add(1, 'year').toDate();\n  }\n\n  get cookieState() {\n    const closed_cookie = cookie('discourse_advertisement_bar_closed');\n    if (closed_cookie) {\n      const cookieValue = JSON.parse(closed_cookie);\n      if (cookieValue.name !== settings.update_version) {\n        removeCookie('discourse_advertisement_bar_closed', { path: '/' });\n      } else {\n        this.closed = true;\n      }\n    }\n    return !this.closed;\n  }\n\n  @action\n  closeBanner() {\n    this.closed = true;\n    const bannerState = { name: settings.update_version, closed: 'true' };\n    cookie('discourse_advertisement_bar_closed', JSON.stringify(bannerState), {\n      expires: this.cookieExpirationDate,\n      path: '/',\n    });\n  }\n}\n","import { apiInitializer } from 'discourse/lib/api';\nimport advertisementBar from '../components/advertisement-bar';\n\nexport default apiInitializer('1.14.0', (api) => {\n  api.renderInOutlet(settings.plugin_outlet.trim(), advertisementBar);\n});\n","import \"virtual:init-settings\";\n\nconst themeCompatModules = {};\nimport * as Mod1 from \"./discourse/components/advertisement-bar\";\nthemeCompatModules[\"discourse/components/advertisement-bar\"] = Mod1;\n\nimport * as Mod2 from \"./discourse/initializers/advertisement-bar\";\nthemeCompatModules[\"discourse/initializers/advertisement-bar\"] = Mod2;\n\nexport default themeCompatModules;\n"],"names":["registerSettings","bar_text","background_image","button_text","button_link","update_version","show_on","plugin_outlet","hide_on_mobile","settings","getObjectForTheme","Component","static","dt7948","g","this","prototype","service","site","i","siteSettings","router","tracked","closed","setComponentTemplate","createTemplateFactory","id","block","moduleName","scope","and","htmlSafe","on","icon","isStrictMode","showOnRoute","currentRoute","currentRouteName","includes","defaultHomepage","top_menu","split","map","opt","showOnMobile","mobileView","cookieExpirationDate","moment","add","toDate","cookieState","closed_cookie","cookie","JSON","parse","name","removeCookie","path","closeBanner","bannerState","stringify","expires","n","action","advertisementBar","apiInitializer","api","renderInOutlet","trim","themeCompatModules","Mod1","Mod2"],"mappings":";AAEAA,EAAiB,GAAI,CACnBC,SAAY,GACZC,iBAAoB,0IACpBC,YAAe,GACfC,YAAe,iLACfC,eAAkB,WAClBC,QAAW,aACXC,cAAiB,eACjBC,gBAAkB;ACRb,MAAMC,EAAWC,EAAkB;MCS3B,cAA+BC,EAAAC,cAAAC,OAAAC,EAAAC,KAAAC,kBAC3CC;AAAAC,GAAA,MAAAL,OAAAM,cAAA,EAAA;AAAAP,cAAAC,OAAAC,EAAAC,KAAAC,0BACAC;AAAAG,GAAA,MAAAP,OAAAM,sBAAA,EAAA;AAAAP,cAAAC,OAAAC,EAAAC,KAAAC,oBACAC;AAAAI,GAAA,MAAAR,OAAAM,gBAAA,EAAA;AAAAP,cAAAC,OAAAC,EAAAC,KAAAC,oBACAM,GAAA,WAAA,OAAiB,CAAA;AAAAC,GAAA,MAAAV,OAAAM,gBAAA,EAAA;AAAAP,SAAA,KAAAY,EAAAC,EAAA,CAAAC,GAAA,KAAAC,MAAA,i6BAAAC,WAAA,uDAAAC,MAAAA,IAAA,CAAAC,EAAArB,EAAAsB,EAAAC,EAAAC,GAAAC,cAAA,IAqBlBnB,MArBkB;AAuBlB,eAAIoB,GACF,MAAMC,EAAerB,KAAKM,OAAOgB;AACjC,OAAQ5B,EAASH,SACf,IAAK,aACH,OAAQ8B,EAAaE,SAAS;AAChC,IAAK,WACH,OAAOF,IAAiB,aAAaG;AACvC,IAAK,4BAG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