// WoltLabButton.js
$.Redactor.prototype.WoltLabButton=function(){"use strict";var t;return{init:function(){this.button.buildButtonTooltip=function(){};var t=this.button.clickCallback;this.button.clickCallback=function(e,o,n,i){"function"==typeof e.preventDefault&&e.preventDefault(),t.call(this,e,o,n,i)}.bind(this);var e,o,n,i;for(n=0,i=this.opts.woltlab.customButtons.length;i>n;n++)o=this.opts.woltlab.customButtons[n],e=this.button.add(o,""),this.button.addCallback(e,this.WoltLabButton._handleCustomButton);var s,a,l;for(n=0,i=this.opts.buttons.length;i>n;n++)if(o=this.opts.buttons[n],"wcfSeparator"!==o){if(!this.opts.woltlab.buttons.hasOwnProperty(o))throw new Error("Missing button definition for '"+o+"'.");switch(s=this.opts.woltlab.buttons[o],"underline"===o&&(this.opts.activeButtonsStates.u="underline"),o){case"subscript":case"superscript":e=this.button.addAfter(this.opts.buttons[n-1],o,""),this.button.setEvent(e,o,{func:"inline.format"}),this.opts.activeButtonsStates["subscript"===o?"sub":"sup"]=o;break;case"redo":case"undo":e=this.button.addAfter(this.opts.buttons[n-1],o,""),this.button.addCallback(e,this.buffer[o]);break;default:e=this.button.get(o)}if(a=s.icon,l=!1,!a.match(/^fa-/)&&a.match(/\.(gif|jpe?g|png|svg)$/)&&(l=!0),this.button.setIcon(e,'<span class="icon icon16 '+(l?"redactorButtonImage":a)+'"'+(l?" style=\"background-image: url('"+WCF_PATH+"icon/"+a+"')\"":"")+"></span>"),!e[0])throw new Error("Missing button element for '"+o+"'.");if(elAttr(e[0],"title",s.title),e[0].classList.add("jsTooltip"),"lists"===o){var r=e.data("dropdown");elBySel(".redactor-dropdown-outdent span",r[0]).textContent=WCF.Language.get("wcf.editor.list.outdent"),elBySel(".redactor-dropdown-indent span",r[0]).textContent=WCF.Language.get("wcf.editor.list.indent")}}var c=this.core.toolbar()[0];elBySelAll(".re-button-tooltip",c.parentNode,elRemove);for(var d,u={},h=[];c.childElementCount;)d=c.removeChild(c.children[0]),o=elAttr(d.children[0],"rel"),u[o]=d,h.push(o);var b=!1;for(n=0,i=this.opts.buttons.length;i>n;n++)o=this.opts.buttons[n],"wcfSeparator"!==o?(d=u[o],c.appendChild(d),h.splice(h.indexOf(o),1),b&&(d.classList.add("redactor-toolbar-separator"),b=!1)):b=!0;for(n=0,i=c.childElementCount;i>n;n++)d=c.children[n],e=d.children[0],elData(d,"show-on-mobile",-1!==this.opts.woltlab.buttonMobile.indexOf(e.rel));h.forEach(function(t){c.appendChild(u[t])}),WCF.DOMNodeInsertedHandler.execute(),require(["Ui/Screen"],function(t){t.on("screen-xs",{match:this.WoltLabButton._enableToggleButton.bind(this),unmatch:this.WoltLabButton._disableToggleButton.bind(this),setup:this.WoltLabButton._setupToggleButton.bind(this)})}.bind(this)),this.$toolbar[0].addEventListener("dragstart",function(t){t.preventDefault()})},_handleCustomButton:function(t){var e={cancel:!1};if(WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","bbcode_"+t+"_"+this.$element[0].id,e),e.cancel!==!0){this.buffer.set();var o="["+t+"]"+this.selection.html()+(this.selection.is()?"":this.marker.html())+"[/"+t+"]";this.insert.html(o),this.selection.restore()}window.setTimeout(function(){document.activeElement!==this.$editor[0]&&this.$editor[0].focus()}.bind(this),10)},_enableToggleButton:function(){null===t.parentNode&&this.$toolbar[0].appendChild(t)},_disableToggleButton:function(){null!==t.parentNode&&this.$toolbar[0].removeChild(t)},_setupToggleButton:function(){t=elCreate("li"),t.className="redactorToolbarToggle",t.innerHTML='<a href="#"><span class="icon icon16 fa-caret-down"></span></a>',elData(t,"show-on-mobile",!0);var e=t.children[0].children[0],o=function(t){t instanceof Event&&t.preventDefault(),this.$toolbar[0].classList.toggle("redactorToolbarOverride")&&document.activeElement&&document.activeElement!==this.$editor[0]&&document.activeElement.blur(),e.classList.toggle("fa-caret-down"),e.classList.toggle("fa-caret-up")}.bind(this);t.children[0].addEventListener("mousedown",o),this.$toolbar[0].appendChild(t),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","reset_"+this.$element[0].id,function(){this.$toolbar[0].classList.contains("redactorToolbarOverride")&&o()}.bind(this))}}};
// WoltLabCaret.js
-$.Redactor.prototype.WoltLabCaret=function(){"use strict";return{init:function(){var e=this.caret.after;this.caret.after=function(t){t=this.caret.prepare(t),this.utils.isBlockTag(t.tagName)&&this.WoltLabCaret._addParagraphAfterBlock(t),e.call(this,t)}.bind(this);var t=!1;require(["Environment"],function(e){t="ios"===e.platform()});var n=this.caret.end;this.caret.end=function(e){e=this.caret.prepare(e);var i=!1;if(e.nodeType===Node.ELEMENT_NODE&&e.lastChild&&"P"===e.lastChild.nodeName)i=!0;else if(t){var r=this.core.editor()[0];e.parentNode===r&&"<p><br></p>"===r.innerHTML&&(i=!0)}if(i){var a=window.getSelection(),o=document.createRange();return o.selectNodeContents(e.lastChild),o.collapse(!1),a.removeAllRanges(),void a.addRange(o)}return n.call(this,e)}.bind(this);var i=this.selection.nodes;this.selection.nodes=function(e){var t=i.call(this,e);if(1===t.length&&t[0]===this.$editor[0]){var n=this.selection.range(this.selection.get());if(n.startContainer===n.endContainer)return[n.startContainer]}return t}.bind(this),this.$editor[0].addEventListener(WCF_CLICK_EVENT,this.WoltLabCaret._handleEditorClick.bind(this)),this.WoltLabCaret._initInternalRange();var r=this.selection.saveInstant;this.selection.saveInstant=function(){r.call(this),this.saved.isAtNodeStart=!1;var e=window.getSelection();if(e.rangeCount&&!e.isCollapsed){var t=e.getRangeAt(0);t.startContainer.nodeType===Node.TEXT_NODE&&0===t.startOffset&&(this.saved.isAtNodeStart=!0)}}.bind(this);var a=this.selection.restoreInstant;this.selection.restoreInstant=function(e){if("undefined"!=typeof e||this.saved){var t="undefined"!=typeof e?e:this.saved;if(a.call(this,e),t.isAtNodeStart===!0){var n=window.getSelection();if(n.rangeCount&&!n.isCollapsed){var i=n.getRangeAt(0),r=i.startContainer;if(t.node===r)return;for(;null!==r&&"P"!==r.nodeName;)r=r.parentNode;if(null!==r&&(r=r.nextElementSibling,null!==r&&"P"===r.nodeName&&0===r.textContent.replace(/\u200B/g,"").length)){r=r.nextElementSibling;for(var o=t.node;null!==o&&o!==r;)o=o.parentNode;o===r&&(i=i.cloneRange(),i.setStart(t.node,0),n.removeAllRanges(),n.addRange(i))}}}}}.bind(this)},paragraphAfterBlock:function(e){var t=e.nextElementSibling;t&&"P"!==t.nodeName&&(t=elCreate("p"),t.textContent="",e.parentNode.insertBefore(t,e.nextSibling)),this.caret.after(e)},endOfEditor:function(){var e=this.core.editor()[0];document.activeElement!==e&&e.focus();var t=e.lastElementChild;"P"===t.nodeName?this.caret.end(t):this.caret.after(t)},_initInternalRange:function(){var e=this.core.editor()[0],t=null,n=window.getSelection(),i=function(){t=n.rangeCount?n.getRangeAt(0).cloneRange():null},r=function(){if(null!==t){if(document.activeElement===e){var i=n.getRangeAt(0);if(0!==i.startOffset)return;for(var r=i.startContainer;r;){if(r.parentNode===e){if(r.previousSibling)return;break}if(r.previousSibling)return;r=r.parentNode}if(!r)return}e.focus(),n.removeAllRanges(),n.addRange(t),t=null}};e.addEventListener("keyup",i),e.addEventListener("mouseup",function(){n.rangeCount&&i()});var a=this.selection.save;this.selection.save=function(){t=null,a.call(this)}.bind(this);var o=this.selection.restore;this.selection.restore=function(){t&&null===elBySel(".redactor-selection-marker",this.$editor[0])&&(r(),n.rangeCount&&this.utils.isRedactorParent(n.getRangeAt(0).commonAncestorContainer))||o.call(this)}.bind(this);var s=this.buffer.set;this.buffer.set=function(t){if(document.activeElement!==e){var n=window.getSelection();n.rangeCount&&this.utils.isRedactorParent(n.anchorNode)!==!1?e.focus():r()}s.call(this,t),i()}.bind(this);var l=this.insert.html;this.insert.html=function(e,t){var n=elBySel(".redactor-selection-marker",this.$editor[0]);l.call(this,e,t),(n||null===elBySel(".redactor-selection-marker",this.$editor[0]))&&i()}.bind(this),require(["Environment"],function(t){"ios"===t.platform()&&(e.addEventListener("focus",function(){document.addEventListener("selectionchange",i)}),e.addEventListener("blur",function(){document.removeEventListener("selectionchange",i)}))}.bind(this))},_handleEditorClick:function(e){if(this.selection.get().isCollapsed){var t=this.selection.block();if(t===!1){if(this.selection.current()===this.$editor[0]){var n=this.$editor[0].childNodes[this.selection.get().anchorOffset];n.nodeType===Node.ELEMENT_NODE&&"TABLE"===n.nodeName&&(t=n)}if(t===!1)return}for(var i=e.target;i&&!this.utils.isBlockTag(i.nodeName);)i=i.parentNode;if(i&&i!==t&&("P"!==t.nodeName||(t=t.parentNode,t!==this.$editor[0]&&this.utils.isBlockTag(t.nodeName)))){if("TD"===t.nodeName)for(;"TABLE"!==t.nodeName;)t=t.parentNode;if(!t.nodeName.match(/^H\d$/)&&!$(t).closest("ol, ul",this.$editor[0]).length){for(var r,a,o=t;o;){if(a=o.getBoundingClientRect(),e.clientY<a.top)r=!0,t=o;else{if(!(e.clientY>a.bottom))break;r=!1,t=o}if(!o.parentNode||o.parentNode===this.$editor[0])break;o=o.parentNode}if(void 0!==r){var s=t[(r?"previous":"next")+"ElementSibling"];if(s&&"P"===s.nodeName)return void this.caret.end(s);this.buffer.set();var l=elCreate("p");l.textContent="",t.parentNode.insertBefore(l,r?t:t.nextSibling),this.caret.end(l)}}}}},_addParagraphAfterBlock:function(e){var t=e.nextElementSibling;(!t||"P"!==t.nodeName&&!this.utils.isBlockTag(t.nodeName))&&(t=elCreate("p"),t.textContent="",e.parentNode.insertBefore(t,e.nextSibling))}}};
+$.Redactor.prototype.WoltLabCaret=function(){"use strict";return{init:function(){var e=this.caret.after;this.caret.after=function(t){t=this.caret.prepare(t),this.utils.isBlockTag(t.tagName)&&this.WoltLabCaret._addParagraphAfterBlock(t),e.call(this,t)}.bind(this);var t=!1;require(["Environment"],function(e){t="ios"===e.platform()});var n=this.caret.end;this.caret.end=function(e){e=this.caret.prepare(e);var i=!1;if(e.nodeType===Node.ELEMENT_NODE&&e.lastChild&&"P"===e.lastChild.nodeName)i=!0;else if(t){var r=this.core.editor()[0];e.parentNode===r&&"<p><br></p>"===r.innerHTML&&(i=!0)}if(i){var a=window.getSelection(),o=document.createRange();return o.selectNodeContents(e.lastChild),o.collapse(!1),a.removeAllRanges(),void a.addRange(o)}return n.call(this,e)}.bind(this);var i=this.selection.nodes;this.selection.nodes=function(e){var t=i.call(this,e);if(1===t.length&&t[0]===this.$editor[0]){var n=this.selection.range(this.selection.get());if(n.startContainer===n.endContainer)return[n.startContainer]}return t}.bind(this),this.$editor[0].addEventListener(WCF_CLICK_EVENT,this.WoltLabCaret._handleEditorClick.bind(this)),this.WoltLabCaret._initInternalRange();var r=this.selection.saveInstant;this.selection.saveInstant=function(){if(r.call(this),this.saved){this.saved.isAtNodeStart=!1;var e=window.getSelection();if(e.rangeCount&&!e.isCollapsed){var t=e.getRangeAt(0);t.startContainer.nodeType===Node.TEXT_NODE&&0===t.startOffset&&(this.saved.isAtNodeStart=!0)}}}.bind(this);var a=this.selection.restoreInstant;this.selection.restoreInstant=function(e){if("undefined"!=typeof e||this.saved){var t="undefined"!=typeof e?e:this.saved;if(a.call(this,e),t.isAtNodeStart===!0){var n=window.getSelection();if(n.rangeCount&&!n.isCollapsed){var i=n.getRangeAt(0),r=i.startContainer;if(t.node===r)return;for(;null!==r&&"P"!==r.nodeName;)r=r.parentNode;if(null!==r&&(r=r.nextElementSibling,null!==r&&"P"===r.nodeName&&0===r.textContent.replace(/\u200B/g,"").length)){r=r.nextElementSibling;for(var o=t.node;null!==o&&o!==r;)o=o.parentNode;o===r&&(i=i.cloneRange(),i.setStart(t.node,0),n.removeAllRanges(),n.addRange(i))}}}}}.bind(this)},paragraphAfterBlock:function(e){var t=e.nextElementSibling;t&&"P"!==t.nodeName&&(t=elCreate("p"),t.textContent="",e.parentNode.insertBefore(t,e.nextSibling)),this.caret.after(e)},endOfEditor:function(){var e=this.core.editor()[0];document.activeElement!==e&&e.focus();var t=e.lastElementChild;"P"===t.nodeName?this.caret.end(t):this.caret.after(t)},_initInternalRange:function(){var e=this.core.editor()[0],t=null,n=window.getSelection(),i=function(){t=n.rangeCount?n.getRangeAt(0).cloneRange():null},r=function(){if(null!==t){if(document.activeElement===e){var i=n.getRangeAt(0);if(0!==i.startOffset)return;for(var r=i.startContainer;r;){if(r.parentNode===e){if(r.previousSibling)return;break}if(r.previousSibling)return;r=r.parentNode}if(!r)return}e.focus(),n.removeAllRanges(),n.addRange(t),t=null}};e.addEventListener("keyup",i),e.addEventListener("mouseup",function(){n.rangeCount&&i()});var a=this.selection.save;this.selection.save=function(){t=null,a.call(this)}.bind(this);var o=this.selection.restore;this.selection.restore=function(){t&&null===elBySel(".redactor-selection-marker",this.$editor[0])&&(r(),n.rangeCount&&this.utils.isRedactorParent(n.getRangeAt(0).commonAncestorContainer))||o.call(this)}.bind(this);var s=this.buffer.set;this.buffer.set=function(t){if(document.activeElement!==e){var n=window.getSelection();n.rangeCount&&this.utils.isRedactorParent(n.anchorNode)!==!1?e.focus():r()}s.call(this,t),i()}.bind(this);var l=this.insert.html;this.insert.html=function(e,t){var n=elBySel(".redactor-selection-marker",this.$editor[0]);l.call(this,e,t),(n||null===elBySel(".redactor-selection-marker",this.$editor[0]))&&i()}.bind(this),require(["Environment"],function(t){"ios"===t.platform()&&(e.addEventListener("focus",function(){document.addEventListener("selectionchange",i)}),e.addEventListener("blur",function(){document.removeEventListener("selectionchange",i)}))}.bind(this))},_handleEditorClick:function(e){if(this.selection.get().isCollapsed){var t=this.selection.block();if(t===!1){if(this.selection.current()===this.$editor[0]){var n=this.$editor[0].childNodes[this.selection.get().anchorOffset];n.nodeType===Node.ELEMENT_NODE&&"TABLE"===n.nodeName&&(t=n)}if(t===!1)return}for(var i=e.target;i&&!this.utils.isBlockTag(i.nodeName);)i=i.parentNode;if(i&&i!==t&&("P"!==t.nodeName||(t=t.parentNode,t!==this.$editor[0]&&this.utils.isBlockTag(t.nodeName)))){if("TD"===t.nodeName)for(;"TABLE"!==t.nodeName;)t=t.parentNode;if(!t.nodeName.match(/^H\d$/)&&!$(t).closest("ol, ul",this.$editor[0]).length){for(var r,a,o=t;o;){if(a=o.getBoundingClientRect(),e.clientY<a.top)r=!0,t=o;else{if(!(e.clientY>a.bottom))break;r=!1,t=o}if(!o.parentNode||o.parentNode===this.$editor[0])break;o=o.parentNode}if(void 0!==r){var s=t[(r?"previous":"next")+"ElementSibling"];if(s&&"P"===s.nodeName)return void this.caret.end(s);this.buffer.set();var l=elCreate("p");l.textContent="",t.parentNode.insertBefore(l,r?t:t.nextSibling),this.caret.end(l)}}}}},_addParagraphAfterBlock:function(e){var t=e.nextElementSibling;(!t||"P"!==t.nodeName&&!this.utils.isBlockTag(t.nodeName))&&(t=elCreate("p"),t.textContent="",e.parentNode.insertBefore(t,e.nextSibling))}}};
// WoltLabClean.js
$.Redactor.prototype.WoltLabClean=function(){"use strict";return{init:function(){var e=this.clean.onSet;this.clean.onSet=function(t){t=t.replace(/\u200B/g,""),t=t.replace(/&amp;/g,"@@@WCF_LITERAL_AMP@@@"),t=t.replace(/&/g,"&WCF_AMPERSAND&"),t=e.call(this,t),t=t.replace(/&WCF_AMPERSAND&(amp;)?/g,"&"),t=t.replace(/@@@WCF_LITERAL_AMP@@@/,"&amp;");var n=elCreate("div");return n.innerHTML=t,elBySelAll("iframe",n,elRemove),elBySelAll("pre",n,function(e){e.classList.contains("redactor-script-tag")&&elRemove(e)}),elBySelAll("td",n,function(e){0===e.childNodes.length&&(e.innerHTML="")}),t=n.innerHTML}.bind(this);var t=this.clean.onSync;this.clean.onSync=function(e){var n=elCreate("div");n.innerHTML=e;var r={};return elBySelAll("pre",n,function(e){var t=WCF.getUUID();r[t]=e.textContent,e.textContent=t}),elBySelAll("p",n,function(e){var t=e.lastElementChild;if(t&&"BR"===t.nodeName&&t.nextSibling&&t.nextSibling.textContent.replace(/[\r\n\t]/g,"").match(/^\u200B+$/)){var n=elCreate("p");n.innerHTML="<br>",e.parentNode.insertBefore(n,e.nextSibling),e.removeChild(t.nextSibling),e.removeChild(t)}}),e=n.innerHTML,e=e.replace(/<p>\u200B<\/p>/g,"<p><br></p>"),e=e.replace(/&/g,"&WCF_AMPERSAND&"),e=t.call(this,e),e=e.replace(/&WCF_AMPERSAND&/g,"&"),n.innerHTML=e,elBySelAll("pre",n,function(e){r.hasOwnProperty(e.textContent)&&(e.textContent=r[e.textContent])}),e=n.innerHTML}.bind(this);var n=this.clean.savePreFormatting;this.clean.savePreFormatting=function(e){var t=this.clean.encodeEntities;return this.clean.encodeEntities=function(e){return WCF.String.escapeHTML(e)},e=n.call(this,e),this.clean.encodeEntities=t,e}.bind(this);var r=this.clean.onPaste;this.clean.onPaste=function(e,t,n){if(t.pre||this.utils.isCurrentOrParent("kbd")){var l=this.clean.removeEmptyInlineTags;return this.clean.removeEmptyInlineTags=function(e){return e},e=r.call(this,e,t,n),this.clean.removeEmptyInlineTags=l,e}var i=elCreate("div");i.innerHTML=e.replace(/@@@WOLTLAB-P-ALIGN-(?:left|right|center|justify)@@@/g,"");var a,o,s,c=!0;for(o=0,s=i.childElementCount;s>o;o++){if(a=i.children[o],"DIV"!==a.nodeName||0===a.childNodes.length){c=!1;break}if(1===a.childNodes.length&&1===a.childElementCount){var h=a.children[0];if(0===h.childNodes.length&&"BR"!==h.nodeName){c=!1;break}}}if(c){var d=[];for(o=0,s=i.childElementCount;s>o;o++)d.push(i.children[o]);d.forEach(function(e){var t=elCreate("p");for(i.insertBefore(t,e);e.childNodes.length>0;)t.appendChild(e.childNodes[0]);i.removeChild(e)})}var f,p,u,m,g=null!==elBySel(".MsoNormal",i),v=elBySelAll("[style]",i);for(o=0,s=v.length;s>o;o++){a=v[o],p=[];for(var b=0,y=a.style.length;y>b;b++)if(f=a.style[b],-1===this.opts.woltlab.allowedInlineStyles.indexOf(f)){if("font-weight"===f)m=a.style.getPropertyValue(f),("bold"===m||"bolder"===m)&&(m=600),m=~~m,m>500&&(u=elCreate("strong"),a.parentNode.insertBefore(u,a),u.appendChild(a));else if(g&&"margin-bottom"===f&&"P"===a.nodeName&&(m=a.style.getPropertyValue(f),m.match(/^12(?:\.0)?pt$/))){var C=elCreate("p");C.innerHTML="<br>",a.parentNode.insertBefore(C,a.nextSibling)}p.push(f)}p.forEach(function(e){a.style.removeProperty(e)})}return elBySelAll("span",i,function(e){if(!e.hasAttribute("style")||!e.style.length){for(;e.childNodes.length;)e.parentNode.insertBefore(e.childNodes[0],e);elRemove(e)}}),elBySelAll("p",i,function(e){e.classList.contains("MsoNormal")?1===e.childElementCount&&"O:P"===e.children[0].nodeName&&" "===e.textContent&&(e.innerHTML="<br>"):e.className.match(/\btext-(left|right|center|justify)\b/)&&e.insertBefore(document.createTextNode("@@@WOLTLAB-P-ALIGN-"+RegExp.$1+"@@@"),e.firstChild),e.removeAttribute("class"),e.removeAttribute("style")}),elBySelAll("img",i,function(e){e.removeAttribute("style")}),elBySelAll("br",i,function(e){e.parentNode.insertBefore(document.createTextNode("@@@WOLTLAB-BR-MARKER@@@"),e.nextSibling)}),e=r.call(this,i.innerHTML,t,n),e=e.replace(/\n*@@@WOLTLAB-BR-MARKER@@@\n*/g,"<woltlab-br-marker></woltlab-br-marker>"),e=e.replace(/(<p>)?\s*@@@WOLTLAB-P-ALIGN-(left|right|center|justify)@@@/g,function(e,t,n){return t?'<p class="text-'+n+'">':""}),i.innerHTML=e.replace(/&quot;/g,"""),elBySelAll("woltlab-br-marker",i,function(e){var t=e.parentNode;if(null!==t){if("P"===t.nodeName){var n=elCreate("p");n.innerHTML="<br>";var r=!1,l=e.nextSibling;l&&"WOLTLAB-BR-MARKER"===l.nodeName&&(r=!0);for(var i=!r;e.nextSibling;)i&&0!==e.nextSibling.textContent.replace(/\u200B/g,"").trim().length&&(i=!1),n.appendChild(e.nextSibling);i||elRemove(n.firstElementChild);var a=e.previousSibling;a&&"BR"===a.nodeName&&elRemove(a),t.parentNode.insertBefore(n,t.nextSibling),r&&(n=elCreate("p"),n.innerHTML="<br>",t.parentNode.insertBefore(n,t.nextSibling))}else t.insertBefore(elCreate("br"),e);elRemove(e)}}),elBySelAll("p",i,function(e){var t=!1;0===e.childNodes.length?t=!0:""===e.textContent?(t=!0,elBySelAll("*",e,function(e){"SPAN"!==e.nodeName&&(t=!1)})):0===e.textContent.trim().length&&(elBySelAll("span",e,function(e){if(!e.hasAttribute("style")||!e.style.length){for(;e.childNodes.length;)e.parentNode.insertBefore(e.childNodes[0],e);elRemove(e)}}),0===e.children.length&&(e.innerHTML="<br>")),t&&elRemove(e)}),i.innerHTML}.bind(this);var l=[],i=function(e,t){for(var n,r,i={},a=0,o=t.length;o>a;a++)n=t[a],r=elAttr(e,n),"style"===n&&0===e.style.length&&0===r.indexOf("font-family")&&(r=r.replace(/"/g,"")),i[n]=r;l.push({element:e,attributes:i})},a=this.clean.convertTags;this.clean.convertTags=function(e,t){var n=elCreate("div");n.innerHTML=e,l=[],WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","convertTags_"+this.$element[0].id,{addToStorage:i,div:n}),elBySelAll("span",n,function(e){i(e,["style"])}),l.forEach(function(e,t){var n=e.element,r=n.parentNode;for(r.insertBefore(document.createTextNode("###custom"+t+"###"),n),r.insertBefore(document.createTextNode("###/custom"+t+"###"),n.nextSibling);n.childNodes.length;)r.insertBefore(n.childNodes[0],n);r.removeChild(n)});var r=!1;t.links&&this.opts.pasteLinks&&(elBySelAll("a",n,function(e){e.href&&(e.outerHTML='#####[a href="'+e.href+'"]#####'+e.innerHTML+"#####[/a]#####")}),r=!0,t.links=!1);var o=!1;return t.images&&this.opts.pasteImages&&(elBySelAll("img",n,function(e){if(e.src){for(var t,n='#####[img src="'+e.src+'"',r=0,l=e.attributes.length;l>r;r++)t=e.attributes.item(r),"src"!==t.name&&(n+=" "+t.name+'="'+t.value+'"');e.outerHTML=n+"]#####"}}),o=!0,t.images=!1),e=a.call(this,n.innerHTML,t),o&&(t.images=!0),r&&(t.links=!0),e}.bind(this);var o=this.clean.reconvertTags;this.clean.reconvertTags=function(e,t){if(l.length){e=e.replace(/###(\/?)custom(\d+)###/g,'<$1woltlab-custom-tag data-index="$2">');var n=elCreate("div");n.innerHTML=e,elBySelAll("woltlab-custom-tag",n,function(e){var t=~~elData(e,"index");if(l[t]){var n=l[t],r=elCreate(n.element.nodeName);for(var i in n.attributes)n.attributes.hasOwnProperty(i)&&elAttr(r,i,n.attributes[i]);for(e.parentNode.insertBefore(r,e);e.childNodes.length;)r.appendChild(e.childNodes[0])}elRemove(e)}),e=n.innerHTML}return o.call(this,e,t)}.bind(this),this.clean.removeSpans=function(e){return e};var s=this.clean.getCurrentType;this.clean.getCurrentType=function(e,t){var n=s.call(this,e,t);return this.utils.isCurrentOrParent(["kbd"])&&(n.inline=!1,n.block=!1,n.encode=!0,n.pre=!0,n.paragraphize=!1,n.images=!1,n.links=!1),n}.bind(this)}}};
// WoltLabCode.js
// WoltLabImage.js
$.Redactor.prototype.WoltLabImage=function(){"use strict";return{init:function(){if(this.opts.woltlab.allowImages){var t=this.button.add("woltlabImage","");this.button.addCallback(t,this.WoltLabImage.add)}var e=this.image.showEdit;this.image.showEdit=function(t){var a=t[0];if(!a.classList.contains("smiley")){e(t),this.modal.setTitle(WCF.Language.get("wcf.editor.image.edit")),this.modal.getActionButton().text(WCF.Language.get("wcf.global.button.save")),this.modal.getDeleteButton().text(WCF.Language.get("wcf.global.button.delete")),elById("redactor-image-source").value=a.src;var i=elById("redactor-image-float");a.classList.contains("messageFloatObjectLeft")?i.value="left":a.classList.contains("messageFloatObjectRight")&&(i.value="right"),a.classList.contains("woltlabAttachment")&&elRemove(elById("redactor-image-source-container"))}}.bind(this);var a=this.image.update;this.image.update=function(){var t=this.observe.image[0],e=elById("redactor-image-source"),i=function(t,e){$('<small class="innerError" />').text(e).insertAfter(t)};if(!t.classList.contains("woltlabAttachment")){var o=e.value.trim();if(""===o)return i(e,WCF.Language.get("wcf.global.form.error.empty"));if(!o.match(this.opts.regexps.url))return i(e,WCF.Language.get("wcf.editor.image.source.error.invalid"));t.src=o}t.classList.remove("messageFloatObjectLeft"),t.classList.remove("messageFloatObjectRight");var r=elById("redactor-image-float").value;("left"===r||"right"===r)&&t.classList.add("messageFloatObject"+WCF.String.ucfirst(r)),a.call(this),t.removeAttribute("alt"),t.removeAttribute("title"),this.caret.after(t)}.bind(this),this.opts.modal["image-edit"]='<div class="section"><dl id="redactor-image-source-container"><dt><label for="redactor-image-source">'+WCF.Language.get("wcf.editor.image.source")+'</label></dt><dd><input type="text" id="redactor-image-source" class="long"></dd></dl><dl><dt><label for="redactor-image-link">'+WCF.Language.get("wcf.editor.image.link")+'</label></dt><dd><input type="text" id="redactor-image-link" class="long"></dd></dl><dl><dt><label for="redactor-image-float">'+WCF.Language.get("wcf.editor.image.float")+'</label></dt><dd><select id="redactor-image-float"><option value="none">'+WCF.Language.get("wcf.global.noSelection")+'</option><option value="left">'+WCF.Language.get("wcf.editor.image.float.left")+'</option><option value="right">'+WCF.Language.get("wcf.editor.image.float.right")+'</option></select></dd></dl><input id="redactor-image-title" style="display: none"><input id="redactor-image-caption" style="display: none"><div class="formSubmit"><button id="redactor-modal-button-action" class="buttonPrimary">Insert</button><button id="redactor-modal-button-delete" class="redactor-modal-button-offset">Delete</button></div></div>'},add:function(){this.modal.load("image-edit",WCF.Language.get("wcf.editor.image.insert")),this.modal.show(),this.modal.getDeleteButton().hide();var t=this.modal.getActionButton()[0];t.addEventListener(WCF_CLICK_EVENT,this.WoltLabImage.insert),t.textContent=WCF.Language.get("wcf.global.button.insert"),this.WoltLabModal.rebuild()},insert:function(t){t.preventDefault(),this.modal.getModal().find(".innerError").remove();var e=elById("redactor-image-source"),a=function(t,e){$('<small class="innerError" />').text(e).insertAfter(t)},i=e.value.trim();if(""===i)return a(e,WCF.Language.get("wcf.global.form.error.empty"));if(!i.match(this.opts.regexps.url))return a(e,WCF.Language.get("wcf.editor.image.source.error.invalid"));var o=elById("redactor-image-link"),r=o.value.trim();if(""!==r&&!r.match(this.opts.regexps.url))return a(o,WCF.Language.get("wcf.editor.image.link.error.invalid"));var l=elById("redactor-image-float").value,s="";("left"===l||"right"===l)&&(s="messageFloatObject"+WCF.String.ucfirst(l));var n='<img src="'+WCF.String.escapeHTML(i)+'"'+(s?' class="'+s+'"':"")+">";r&&(n='<a href="'+WCF.String.escapeHTML(r)+'">'+n+"</a>"),this.modal.close(),this.buffer.set(),this.insert.html(n)}}};
// WoltLabIndent.js
-$.Redactor.prototype.WoltLabIndent=function(){"use strict";return{init:function(){if(this.detect.isFirefox()){var e,t,i=this.indent.decrease;this.indent.decrease=function(){if(this.list.get()){var n=$(this.selection.current()).closest("li",this.core.editor()[0]),r=n.closest("ul, ol",this.core.editor()[0]);if(0===r.parent().closest("ul, ol",this.core.editor()[0]).length){var l=n[0];if(null!==elBySel("ul, ol",l)){this.buffer.set(),this.selection.save();var o,s,a=l.previousElementSibling;if(null!==a){for(o=elCreate(l.parentNode.nodeName.toLowerCase());a.nextSibling;)o.appendChild(a.nextSibling);s=a.parentNode,s.parentNode.insertBefore(o,s.nextSibling)}if(null!==l.nextElementSibling){for(o=elCreate(l.parentNode.nodeName.toLowerCase());l.nextSibling;)o.appendChild(l.nextSibling);s=l.parentNode,s.parentNode.insertBefore(o,s.nextSibling)}for(s=l.parentNode;l.childNodes.length;)s.parentNode.insertBefore(l.childNodes[0],s);return elRemove(s),void this.selection.restore()}}else elBySelAll("woltlab-list-marker",this.core.editor()[0],elRemove),this.selection.save(),e=elCreate("woltlab-list-marker"),n[0].insertBefore(e,n[0].firstChild),t=elCreate("woltlab-list-marker"),n[0].appendChild(t),this.selection.restore();i.call(this)}}.bind(this);var n=this.indent.removeEmpty;this.indent.removeEmpty=function(){if(e&&e.parentNode){for(var i,r=elCreate("li");(i=e.nextSibling)&&i!==t;)r.appendChild(i);e.parentNode.insertBefore(r,e),elBySelAll("woltlab-list-marker",this.core.editor()[0],elRemove),e=void 0,t=void 0}n.call(this)}.bind(this)}this.indent.normalize=function(){if(this.detect.isFirefox()){var e=this.selection.block();if(e&&"P"===e.nodeName){var t=e.previousElementSibling;t&&"BR"===t.nodeName&&elRemove(t)}}this.core.editor().find("li").each($.proxy(function(e,t){var i=$(t),n="";0!==this.opts.keepStyleAttr.length&&(n=","+this.opts.keepStyleAttr.join(",")),i.find(this.opts.inlineTags.join(",")).not("img"+n).not("span").removeAttr("style");var r=i.parent();if(0!==r.length&&"LI"===r[0].tagName){for(;t.nextSibling;)t.appendChild(t.nextSibling);return void r.after(i)}var l=i.next();0===l.length||"UL"!==l[0].tagName&&"OL"!==l[0].tagName||i.append(l)},this))}.bind(this)}}};
+$.Redactor.prototype.WoltLabIndent=function(){"use strict";return{init:function(){if(this.detect.isFirefox()){var e,t,i=this.indent.decrease;this.indent.decrease=function(){if(this.list.get()){var n=$(this.selection.current()).closest("li",this.core.editor()[0]),r=n.closest("ul, ol",this.core.editor()[0]);if(0===r.parent().closest("ul, ol",this.core.editor()[0]).length){var l=n[0];if(null!==elBySel("ul, ol",l)){this.buffer.set(),this.selection.save();var o,s,a=l.previousElementSibling;if(null!==a){for(o=elCreate(l.parentNode.nodeName.toLowerCase());a.nextSibling;)o.appendChild(a.nextSibling);s=a.parentNode,s.parentNode.insertBefore(o,s.nextSibling)}if(null!==l.nextElementSibling){for(o=elCreate(l.parentNode.nodeName.toLowerCase());l.nextSibling;)o.appendChild(l.nextSibling);s=l.parentNode,s.parentNode.insertBefore(o,s.nextSibling)}for(s=l.parentNode;l.childNodes.length;)s.parentNode.insertBefore(l.childNodes[0],s);return elRemove(s),void this.selection.restore()}}else{elBySelAll("woltlab-list-marker",this.core.editor()[0],elRemove),this.selection.save(),e=elCreate("woltlab-list-marker"),n[0].insertBefore(e,n[0].firstChild);var d=n[0].lastElementChild;if("BR"===d.nodeName){for(var h="",a=d;a.nextSibling;)h+=a.textContent;""===h.replace(/\u200B/g,"").trim()&&elRemove(d)}t=elCreate("woltlab-list-marker"),n[0].appendChild(t),this.selection.restore()}i.call(this)}}.bind(this);var n=this.indent.removeEmpty;this.indent.removeEmpty=function(){if(e&&e.parentNode){for(var i,r=elCreate("li");(i=e.nextSibling)&&i!==t;)r.appendChild(i);e.parentNode.insertBefore(r,e),elBySelAll("woltlab-list-marker",this.core.editor()[0],elRemove),e=void 0,t=void 0}n.call(this)}.bind(this)}this.indent.repositionItem=function(e){var t=e.next();0===t.length||"UL"===t[0].tagName&&"OL"===t[0].tagName||e.append(t);var i=e.prev();if(0!==i.length&&"LI"!==i[0].tagName){this.selection.save();var n=e.closest("li",this.core.editor()[0]);n.after(e),this.selection.restore()}}.bind(this),this.indent.normalize=function(){if(this.detect.isFirefox()){var e=this.selection.block();if(e&&"P"===e.nodeName){var t=e.previousElementSibling;t&&"BR"===t.nodeName&&elRemove(t)}}this.core.editor().find("li").each($.proxy(function(e,t){var i=$(t),n="";0!==this.opts.keepStyleAttr.length&&(n=","+this.opts.keepStyleAttr.join(",")),i.find(this.opts.inlineTags.join(",")).not("img"+n).not("span").removeAttr("style");var r=i.parent();if(0!==r.length&&"LI"===r[0].tagName){for(;t.nextSibling;)t.appendChild(t.nextSibling);return void r.after(i)}var l=i.next();0===l.length||"UL"!==l[0].tagName&&"OL"!==l[0].tagName||i.append(l)},this))}.bind(this)}}};
// WoltLabInlineCode.js
$.Redactor.prototype.WoltLabInlineCode=function(){"use strict";var e;return{init:function(){this.opts.activeButtonsStates.kbd="tt",require(["Environment","EventHandler"],function(t,n){e=t,n.add("com.woltlab.wcf.redactor2","bbcode_tt_"+this.$element[0].id,this.WoltLabInlineCode._toggle.bind(this))}.bind(this))},_toggle:function(t){t.cancel=!0,this.button.toggle({},"kbd","func","inline.format");var n=window.getSelection(),o=n.anchorNode;if(o.nodeType===Node.TEXT_NODE&&(o=o.parentNode),"KBD"===o.nodeName){var i=o.nextSibling;if("ios"===e.platform()&&"safari"===e.browser())return void(i&&"BR"===i.nodeName&&o.parentNode.insertBefore(document.createTextNode(""),i));for(;i;){if(i.nodeType!==Node.TEXT_NODE||i.textContent.length)return;i=i.nextSibling}i?i.textContent="":o.parentNode.appendChild(document.createTextNode(""))}}}};
// WoltLabInsert.js