{"version":3,"names":["window","define","_exports","_pluginApi","Object","defineProperty","value","default","require","getObjectForTheme","name","after","initialize","withPluginApi","api","metaMap","title","description","desired","applyTitle","document","titleEl","querySelector","MutationObserver","observe","childList","onPageChange","url","id","pathname","m","match","getTopicId","location","split","text","tag","createElement","setAttribute","head","appendChild","setDescription"],"sourceRoot":"theme-30/","sources":["discourse/initializers/theme-field-541-common-html-script-1.js"],"sourcesContent":["if ('define' in window) {\ndefine(\"discourse/theme-30/discourse/initializers/theme-field-541-common-html-script-1\", [\"exports\", \"discourse/lib/plugin-api\"], function (_exports, _pluginApi) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.default = void 0;\n  const settings = require(\"discourse/lib/theme-settings-store\").getObjectForTheme(30);\n  const themePrefix = key => `theme_translations.30.${key}`;\n  var _default = _exports.default = {\n    name: \"theme-field-541-common-html-script-1\",\n    after: \"inject-objects\",\n    initialize() {\n      (0, _pluginApi.withPluginApi)(\"1.8.0\", api => {\n        const metaMap = {\n          \"40212\": {\n            title: \"ไข้เลือดออก รู้จักโรคร้ายจากยุงลายที่ทุกบ้านต้องระวัง!\",\n            description: \"ไข้เลือดออกเป็นโรคติดเชื้อจากยุงลายที่พบได้บ่อยในไทย อาการเริ่มต้นคล้ายไข้หวัดทั่วไปแต่อาจเสี่ยงอาการรุนแรงได้ จึงควรสังเกตอาการและรู้วิธีป้องกันเพื่อลดความเสี่ยง\"\n          }\n        };\n        let desired = null; // override for the current page, or null\n\n        function getTopicId(pathname) {\n          const m = pathname.match(/\\/t\\/[^/]+\\/(\\d+)/);\n          return m ? m[1] : null;\n        }\n        function setDescription(text) {\n          let tag = document.querySelector('meta[name=\"description\"]');\n          if (!tag) {\n            tag = document.createElement(\"meta\");\n            tag.setAttribute(\"name\", \"description\");\n            document.head.appendChild(tag);\n          }\n          tag.setAttribute(\"content\", text);\n        }\n        function applyTitle() {\n          if (desired && desired.title && document.title !== desired.title) {\n            document.title = desired.title;\n          }\n        }\n\n        // Whenever Discourse rewrites <title>, put ours back (only while on a matching page).\n        const titleEl = document.querySelector(\"title\");\n        if (titleEl) {\n          new MutationObserver(applyTitle).observe(titleEl, {\n            childList: true\n          });\n        }\n        api.onPageChange(url => {\n          const pathname = (url || window.location.pathname).split(\"?\")[0].split(\"#\")[0];\n          const id = getTopicId(pathname);\n          desired = id && metaMap[id] || null;\n          if (desired) {\n            applyTitle();\n            if (desired.description) {\n              setDescription(desired.description);\n            }\n          }\n        });\n      });\n    }\n  };\n});\n}\n"],"mappings":"AAAI,WAAYA,QAChBC,OAAO,iFAAkF,CAAC,UAAW,6BAA6B,SAAUC,EAAUC,GACpJ;AAEAC,OAAOC,eAAeH,EAAU,aAAc,CAC5CI,OAAO,IAETJ,EAASK,aAAU;AACFC,QAAQ,sCAAsCC,kBAAkB;AAElEP,EAASK,QAAU,CAChCG,KAAM,uCACNC,MAAO,iBACP,UAAAC,IACE,EAAIT,EAAWU,eAAe,SAASC,IACrC,MAAMC,EAAU,CACd,MAAS,CACPC,MAAO,yDACPC,YAAa;AAGjB,IAAIC,EAAU;AAed,SAASC,IACHD,GAAWA,EAAQF,OAASI,SAASJ,QAAUE,EAAQF,QACzDI,SAASJ,MAAQE,EAAQF,MAE7B,CAGA,MAAMK,EAAUD,SAASE,cAAc;AACnCD,GACF,IAAIE,iBAAiBJ,GAAYK,QAAQH,EAAS,CAChDI,WAAW,IAGfX,EAAIY,cAAaC,IACf,MACMC,EA5BR,SAAoBC,GAClB,MAAMC,EAAID,EAASE,MAAM;AACzB,OAAOD,EAAIA,EAAE,GAAK,IACpB,CAyBaE,EADOL,GAAO3B,OAAOiC,SAASJ,UAAUK,MAAM,KAAK,GAAGA,MAAM,KAAK;AAE5EhB,EAAUU,GAAMb,EAAQa,IAAO,KAC3BV,IACFC,IACID,EAAQD,aA5BhB,SAAwBkB,GACtB,IAAIC,EAAMhB,SAASE,cAAc;AAC5Bc,IACHA,EAAMhB,SAASiB,cAAc,QAC7BD,EAAIE,aAAa,OAAQ,eACzBlB,SAASmB,KAAKC,YAAYJ,IAE5BA,EAAIE,aAAa,UAAWH,EAC9B,CAqBMM,CAAevB,EAAQD,aAE3B,GACA,GAEN,EAEJ","ignoreList":[]}