{"version":3,"file":"markdown-note.js","names":["define","_exports","Object","defineProperty","value","setup","helper","markdownIt","allowList","registerPlugin","md","block","bbcode","ruler","push","tag","replace","state","tagInfo","content","notificationClass","attrs","includes","type","toLowerCase","attrSet","status","parse","forEach","element","tokens"],"sources":["discourse/plugins/markdown-note/discourse-markdown/notifications.js"],"sourcesContent":["define(\"discourse/plugins/markdown-note/discourse-markdown/notifications\", [\"exports\"], function (_exports) {\n  \"use strict\";\n\n  Object.defineProperty(_exports, \"__esModule\", {\n    value: true\n  });\n  _exports.setup = setup;\n  function setup(helper) {\n    if (!helper.markdownIt) {\n      return;\n    }\n    helper.allowList(['div.p-notification', 'div.p-notification--caution', 'div.p-notification--positive', 'div.p-notification--negative', 'div.p-notification--important', 'div.p-notification__response', 'span.p-notification__status']);\n    helper.registerPlugin(md => {\n      md.block.bbcode.ruler.push('note', {\n        tag: 'note',\n        replace: function (state, tagInfo, content) {\n          // Build up the notification class from the specified \"type\"\n          // \"p-notification--{type}\"\n          let notificationClass = 'p-notification';\n          if ('type' in tagInfo.attrs && ['caution', 'positive', 'negative', 'important'].includes(tagInfo.attrs.type.toLowerCase())) {\n            notificationClass += '--' + tagInfo.attrs.type.toLowerCase();\n          }\n\n          // Start wrapper elements:\n          // <div class=\"p-notification\"><p class=\"p-notification__render\">\n          state.push('div_open', 'div', 1).attrSet('class', notificationClass);\n          state.push('div_open', 'div', 1).attrSet('class', 'p-notification__response');\n          // Add status:\n          // <span class=\"p-notification__status\">{status}</span>\n          if ('status' in tagInfo.attrs) {\n            state.push('span_open', 'span', 1).attrSet('class', 'p-notification__status');\n            state.push('text', '', 0).content = tagInfo.attrs.status + ': ';\n            state.push('span_close', 'span', -1);\n          }\n\n          // Add the [note] content\n          const tokens = state.md.parse(content, state.md);\n          tokens.forEach(element => {\n            // For some reason, \"inline\" elements contain their text twice,\n            // which duplicates the text on the page.\n            // This is because the text appears both inside the \"content\" of the inline block,\n            // and in a \"text\" child node of the block.\n            // We therefore strip the \"content\", so the text only appears once.\n            if (element.type == \"inline\") {\n              element.content = \"\";\n            }\n            state.tokens.push(element);\n          });\n\n          // Close the wrapper elements\n          state.push('div_close', 'div', -1);\n          state.push('div_close', 'div', -1);\n          return true;\n        }\n      });\n    });\n  }\n});"],"mappings":"AAAAA,OAAA,wFAAAC,GACA;AAEAC,OAAAC,eAAAF,EAAA,cACAG,OAAA,IAEAH,EAAAI,MACA,SAAAC,GACA,IAAAA,EAAAC,WACA;AAEAD,EAAAE,UAAA,iNACAF,EAAAG,eAAAC,IACAA,EAAAC,MAAAC,OAAAC,MAAAC,KAAA,QACAC,IAAA,OACAC,QAAA,SAAAC,EAAAC,EAAAC,GAGA,IAAAC,EAAA;AACA,SAAAF,EAAAG,OAAA,8CAAAC,SAAAJ,EAAAG,MAAAE,KAAAC,iBACAJ,GAAA,KAAAF,EAAAG,MAAAE,KAAAC,eAKAP,EAAAH,KAAA,oBAAAW,QAAA,QAAAL,GACAH,EAAAH,KAAA,oBAAAW,QAAA,oCAGA,WAAAP,EAAAG,QACAJ,EAAAH,KAAA,sBAAAW,QAAA,kCACAR,EAAAH,KAAA,aAAAK,QAAAD,EAAAG,MAAAK,OAAA,KACAT,EAAAH,KAAA;AAoBA,OAhBAG,EAAAP,GAAAiB,MAAAR,EAAAF,EAAAP,IACAkB,QAAAC,IAMA,UAAAA,EAAAN,OACAM,EAAAV,QAAA,IAEAF,EAAAa,OAAAhB,KAAAe,KAIAZ,EAAAH,KAAA,sBACAG,EAAAH,KAAA,uBACA,CACA,KAGA,C","ignoreList":[]}