/*! For license information please see forum.js.LICENSE.txt */
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};(()=>{"use strict";const e=flarum.reg.get("core","forum/app");var o=t.n(e);const r=flarum.reg.get("core","common/app");var i=t.n(r);const n=flarum.reg.get("core","common/extend"),a=flarum.reg.get("core","common/utils/BasicEditorDriver");var l=t.n(a);const c=flarum.reg.get("core","common/utils/styleSelectedText");var s=t.n(c);const d=flarum.reg.get("core","common/Component");var f=t.n(d);class u extends(f()){view(t){return m("div",{className:"MarkdownToolbar"},t.children)}}flarum.reg.add("flarum-markdown","common/components/MarkdownToolbar",u);const p=flarum.reg.get("core","common/components/Icon");var k=t.n(p);const h=flarum.reg.get("core","common/components/Tooltip");var g=t.n(h);class x extends(f()){oncreate(t){super.oncreate(t)}view(){const t=m("button",{className:"Button Button--icon Button--link",type:"button","data-hotkey":this.attrs.hotkey,onkeydown:this.keydown.bind(this),onclick:this.attrs.onclick},m(k(),{name:this.attrs.icon}));return this.attrs.title?m(g(),{text:this.attrs.title},t):t}keydown(t){" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.element.click())}}flarum.reg.add("flarum-markdown","common/components/MarkdownButton",x);const b=flarum.reg.get("core","common/utils/ItemList");var v=t.n(b);const w=navigator.userAgent.match(/Macintosh/)?"⌘":"ctrl",y={header:{prefix:"### "},bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},strikethrough:{prefix:"~~",suffix:"~~",trimFirst:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},image:{prefix:"![",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},unordered_list:{prefix:"- ",multiline:!0,surroundWithNewlines:!0},ordered_list:{prefix:"1. ",multiline:!0,orderedList:!0},spoiler:{prefix:">!",suffix:"!<",blockPrefix:">! ",multiline:!0,trimFirst:!0}},_=(t,e)=>{s()(e.el,y[t])};function T(t,e,o){return function(r){r.key===e&&(r.metaKey&&"⌘"===w||r.ctrlKey&&"ctrl"===w)&&(r.preventDefault(),_(t,o))}}function F(t){const e="function"==typeof t?t():new(v());function o(t,e){return i().translator.trans(`flarum-markdown.lib.composer.${t}_tooltip`)+(e?` <${w}-${e}>`:"")}const r=t=>()=>_(t,this.attrs.composer.editor);return e.add("header",m(x,{title:o("header"),icon:"fas fa-heading",onclick:r("header")}),1e3),e.add("bold",m(x,{title:o("bold","b"),icon:"fas fa-bold",onclick:r("bold")}),900),e.add("italic",m(x,{title:o("italic","i"),icon:"fas fa-italic",onclick:r("italic")}),800),e.add("strikethrough",m(x,{title:o("strikethrough"),icon:"fas fa-strikethrough",onclick:r("strikethrough")}),700),e.add("quote",m(x,{title:o("quote"),icon:"fas fa-quote-left",onclick:r("quote")}),600),e.add("spoiler",m(x,{title:o("spoiler"),icon:"fas fa-exclamation-triangle",onclick:r("spoiler")}),500),e.add("code",m(x,{title:o("code"),icon:"fas fa-code",onclick:r("code")}),400),e.add("link",m(x,{title:o("link"),icon:"fas fa-link",onclick:r("link")}),300),e.add("image",m(x,{title:o("image"),icon:"fas fa-image",onclick:r("image")}),200),e.add("unordered_list",m(x,{title:o("unordered_list"),icon:"fas fa-list-ul",onclick:r("unordered_list")}),100),e.add("ordered_list",m(x,{title:o("ordered_list"),icon:"fas fa-list-ol",onclick:r("ordered_list")}),0),e}o().initializers.add("flarum-markdown",(function(t){(0,n.extend)(l().prototype,"keyHandlers",(function(t){t.add("bold",T("bold","b",this)),t.add("italic",T("italic","i",this))})),(0,n.override)("flarum/common/components/TextEditor","markdownToolbarItems",F),(0,n.extend)("flarum/common/components/TextEditor","toolbarItems",(function(t){t.add("markdown",m(u,{for:this.textareaId,setShortcutHandler:t=>shortcutHandler=t},this.markdownToolbarItems().toArray()),100)}))}))})(),module.exports={}})();
//# sourceMappingURL=forum.js.map