text: /* pytesNET/tail.writer v.0.4.1 | @bundle tail.writer + textile | @author SamBrishes, pytesNET <sam@pytes.net> | @license MIT */
  !function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):"object"==typeof module&&module.exports?module.exports=e(t):(void 0===t.tail&&(t.tail={}),t.tail.writer=e(t),"undefined"!=typeof jQuery&&(jQuery.fn.tailwriter=function(t){var e,i=[];return this.each(function(){!1!==(e=tail.writer(this,t))&&i.push(e)}),1===i.length?i[0]:0!==i.length&&i}),"undefined"!=typeof MooTools&&Element.implement({tailwriter:function(t){return new tail.writer(this,t)}}))}(this,function(t){"use strict";var o=t,l=t.document,h={},c=h.cHAS=function(t,e){return!!t.classList&&t.classList.contains(e)},u=h.cADD=function(t,e){return!!t.classList&&(t.classList.add(e),t)},d=h.cREM=function(t,e){return!!t.classList&&(t.classList.remove(e),t)},p=h.trigger=function(t,e,i){if(CustomEvent&&CustomEvent.name)var n=new CustomEvent(e,i);else(n=l.createEvent("CustomEvent")).initCustomEvent(e,!!i.bubbles,!!i.cancelable,i.detail);return t.dispatchEvent(n)},a=h.clone=function(t,e){return Object.assign({},t,e||{})},f=h.position=function(t,e){var i={top:t.offsetTop||0,left:t.offsetLeft||0,width:t.offsetWidth||0,height:t.offsetHeight||0};if(e)for(;t=t.offsetParent;)i.top+=t.offsetTop,i.left+=t.offsetLeft;return i},m=h.create=function(t,e){var i=l.createElement(t);return i.className=e&&e.join?e.join(" "):e||"",i},v=function(t,e){if((t="string"==typeof t?l.querySelectorAll(t):t)instanceof NodeList||t instanceof HTMLCollection||t instanceof Array){for(var i=[],n=t.length,r=0;r<n;r++)i.push(new v(t[r],a(e,{})));return 1===i.length?i[0]:0!==i.length&&i}if("TEXTAREA"!=(t.tagName||""))return!1;if(!(this instanceof v))return new v(t,e);if(v.inst[t.getAttribute("data-tail-writer")])return v.inst[t.getAttribute("data-tail-writer")];if(t.getAttribute("data-writer")){var s=JSON.parse(t.getAttribute("data-writer").replace(/\'/g,'"'));s instanceof Object&&(e=a(e,s))}return(e="object"==typeof e?e:{}).width=!0===e.width?t.offsetWidth:e.width,e.disabled="disabled"in e?e.disabled:t.disabled,e.readonly="readonly"in e?e.readonly:t.readOnly,e.classNames="classes"in e?e.classes:e.classNames||null,this.e={main:null,editor:t,tools:null,status:null},this.id=++v.count,this.con=a(v.defaults,e),this.keys={},this.events={},(v.inst["tail-"+this.id]=this).init()};v.__helper=h,v.version="0.4.1",v.status="beta",v.count=0,v.inst={},v.defaults={classNames:null,debug:!0,disabled:!1,doubleLineBreak:!1,fullscreenParent:l.body,height:[200,500],indentTab:!1,indentSize:4,locale:"en",markup:"textile",previewConverter:null,preventBindings:!1,readonly:!1,resize:!0,statusbar:!0,toolbar:"default",toolbarMultiLine:!1,toolbarScrollable:!0,tooltip:"top",width:"100%"};var r=v.markups=function(t,e){return null==typeof this?new r(t):(e in r.markups?(this.actions=r.markups[e].actions,this.walkers=r.markups[e].walkers,this.toolbars=r.markups[e].toolbars,this.renderer=r.markups[e].renderer):(this.actions={},this.walkers={},this.toolbars={},this.renderer=function(t){return t}),this.self=t,this.markup=e,this.toolbar=[],this.walkers.indent="\t",this)};v.markups.markups={},v.markups.globals={indent:{syntax:"\t$1",action:function(t,e,i){var n=this.selection(),r=1;if(!1!==this.walker&&!1!==this.previousLine()&&(r=this.indentation("count",this.previousLine())),r="\t".repeat(r),n.start===n.end)this.setContent(this.indentation("convert",r,!0),"prepend",n.start,null);else{var s={start:0,end:0},a={start:0,end:0},o=this.splitContent(n);o[0]=o[0].split("\n"),o[2]=o[2].split("\n");var l=o[0].pop()+o[1]+o[2].shift();s.start=a.start=o[0].join("\n").length,s.start=a.start+=0<o[0].length?1:0,s.end=s.start+l.length,l=this.indentation("indent",l),a.end=a.start+l.length,this.setContent(l,"replace",s,null)}return!0},walker:!0},outdent:{syntax:!1,action:function(t,e,i){var n=this.selection();if(n.start===n.end){var r=new RegExp("(\\t|"+new Array(this.con.indentSize+1).join(" ")+")$"),s=this.splitContent(n);s[0]=s[0].split("\n"),s[2]=s[2].split("\n");var a=s[0].pop()+s[1]+s[2].shift(),o=n.start-(s[0].join("\n").length+(s[0].length?1:0)),l=a.substr(o),h=a.substr(0,o);this.currentLine(h.replace(r,"")+l)}else{var u={start:0,end:0},d={start:0,end:0},c=this.splitContent(n);c[0]=c[0].split("\n"),c[2]=c[2].split("\n");var p=c[0].pop()+c[1]+c[2].shift();u.start=d.start=c[0].join("\n").length,u.start=d.start+=0<c[0].length?1:0,u.end=u.start+p.length,p=this.indentation("outdent",p),d.end=d.start+p.length,this.setContent(p,"replace",u,null)}return!0}},preview:{syntax:!1,toolbar:function(t){return t.setAttribute("data-write",this.translate("modeWrite")),t.setAttribute("data-preview",this.translate("modePreview")),t},action:function(t,e,i){e=this.e.tools.querySelector(".action-preview");var n,r,s,a=this.con.previewConverter;if("function"!=typeof a&&(a=this.markup.renderer||function(t){return t}),this.hideElement("dialog"),this.hideElement("dropdown"),h.cHAS(this.e.main,"preview")){d(this.e.main,"preview"),e.setAttribute("data-writer-title",this.translate("preview")),this.e.main.removeChild(this.e.main.querySelector(".tail-writer-preview")),this.e.editor.style.display="block",s=this.e.tools.querySelectorAll("button.disabled");for(l=0;l<s.length;l++)d(s[l],"disabled");d(this.e.tools.querySelector(".action-preview"),"active")}else{n=(n=this.e.editor.value).length?n:this.translate("previewEmpty"),(r=h.create("DIV","tail-writer-preview")).innerHTML=a.call(this,n,this.con.markup),r.style.width=this.e.editor.outerWidth+"px",r.style.height=this.e.editor.style.height,r.style.minHeight=this.e.editor.style.minHeight,r.style.maxHeight=this.e.editor.style.maxHeight,e.setAttribute("data-writer-title",this.translate("previewExit")),this.e.editor.style.display="none",this.e.main.insertBefore(r,this.e.editor),u(this.e.main,"preview");for(var o=(s=this.e.tools.querySelectorAll("button:not(.action-preview)")).length,l=0;l<o;l++)u(s[l],"disabled");u(this.e.tools.querySelector(".action-preview"),"active")}}},fullscreen:{syntax:!1,action:function(t,e,i){null===this.con.fullscreenParent&&(this.con.fullscreenParent=l.body),c(this.e.main,"fullscreen")?(d(this.e.main,"fullscreen"),l.body.style.removeProperty("overflow"),this.placeholder.parentElement.replaceChild(this.e.main,this.placeholder),this.placeholder=!1):(u(this.e.main,"fullscreen"),l.body.style.cssText="overflow:hidden;",this.placeholder=m("DIV"),this.placeholder.id=this.e.main.id+"-placeholder",this.e.main.parentElement.replaceChild(this.placeholder,this.e.main),this.con.fullscreenParent.appendChild(this.e.main))}},markup:{type:"select",values:function(){var t={};for(var e in r.markups)t[e]=e;return t},selected:function(){return this.con.markup},syntax:!1,action:function(t,e,i,n){return n[0]in r.markups?(this.config("markup",n[0],!0),!0):(this.error("errorMarkup"),!1)}},about:{syntax:!1,action:function(t,e,i){var n=v.status.split("")[0].toUpperCase()+v.status.slice(1),r='<div class="about">    <div class="about-top">        <div class="about-logo">tail.<span>writer</span> '+("v."+v.version+" ("+n+")")+'</div>        <div class="about-desc">'+this.translate("aboutDesc1")+'</div>        <div class="about-desc">'+this.translate("aboutDesc2")+'</div>        <a href="https://www.pytes.net" target="_blank" class="pytesnet-logo">        <svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.41421"><path d="M17.344 6.354c.123-1.212.239-2.305.342-3.399.052-.556.228-.661.712-.376 1.042.613 2.081 1.233 3.119 1.852 1.235.737 2.465 1.483 3.705 2.21.242.142.346.301.324.582-.032.401-.005.808-.053 1.206-.035.279.087.417.285.562 1.63 1.187 3.258 2.378 4.879 3.578.107.079.237.252.216.352-.026.117-.189.237-.319.293-.405.172-.822.314-1.278.484.577.878 1.129 1.719 1.683 2.559.296.449.609.889.888 1.349.186.306-.034.437-.292.513-.512.151-1.027.295-1.59.456.658 1.17 1.297 2.295 1.917 3.43.084.154.071.36.103.542-.173.013-.353.062-.519.032-.593-.105-1.181-.237-1.82-.369.258 1.412.503 2.76.749 4.108.068.371.151.74.197 1.114.015.123-.024.313-.109.372-.085.059-.282.036-.388-.024-.902-.512-1.791-1.046-2.695-1.556-.164-.093-.377-.155-.563-.145-3.571.195-7.142.384-10.709.63-.54.037-1.069.336-1.59.546-1.834.739-3.663 1.491-5.492 2.241-.295.121-.559.102-.845-.058-1.94-1.084-3.881-2.166-5.835-3.224-.508-.275-.641-.783-.883-1.218-.477-.858-.899-1.748-1.347-2.623-.218-.426-.197-.529.232-.768 2.839-1.578 5.669-3.169 8.527-4.712.528-.285.602-.765.786-1.199.63-1.484 1.227-2.983 1.816-4.484.184-.471.601-.626.984-.834.319-.174.646-.338.982-.473.293-.117.387-.291.381-.609-.028-1.49-.03-2.98-.032-4.47 0-.131.045-.345.122-.373.125-.046.321-.011.44.064.821.513 1.628 1.048 2.444 1.569.148.095.315.163.526.27zM5.116 27.227c1.115.618 2.166 1.211 3.23 1.779.145.078.372.085.531.034.445-.144.874-.337 1.311-.508 3.055-1.197 6.111-2.392 9.165-3.593.309-.121.632-.238.9-.426 1.055-.739 2.087-1.512 3.142-2.253.113-.079.314-.031.475-.042-.074.136-.115.315-.227.402-.585.453-1.175.899-1.787 1.315-.718.489-1.344 1.12-2.207 1.393-.698.22-1.378.494-2.066.744.12.077.223.073.325.067 2.947-.166 5.894-.34 8.843-.486.301-.015.638.086.91.227.655.34 1.28.738 1.92 1.107.14.081.293.138.494.231-.028-.218-.039-.351-.063-.482-.269-1.468-.542-2.936-.81-4.405-.101-.551.028-.672.573-.551.519.116 1.04.226 1.63.354-.062-.137-.085-.196-.115-.251-.568-1.026-1.14-2.05-1.704-3.078-.211-.385-.134-.547.288-.673.473-.14.947-.281 1.529-.455-.116-.14-.202-.227-.269-.328-.737-1.11-1.469-2.224-2.208-3.333-.271-.406-.211-.606.258-.78.336-.125.67-.255 1.075-.409-.171-.133-.282-.223-.398-.308-1.238-.909-2.431-1.894-3.733-2.701-.942-.584-1.29-1.275-1.049-2.317.072-.307-.068-.485-.335-.641-1.465-.858-2.919-1.735-4.377-2.603-.722-.431-1.447-.859-2.204-1.308-.026.145-.049.234-.058.325-.145 1.527-.291 3.054-.431 4.582-.031.348-.165.571-.509.736-1.627.781-3.24 1.592-4.851 2.407-.148.075-.291.236-.356.39-.729 1.739-1.434 3.488-2.169 5.224-.091.214-.284.431-.486.545-1.808 1.024-3.635 2.012-5.437 3.043-.322.185-.567.511-.829.79-.146.154-.252.346-.379.519-.432.583-.872 1.162-1.293 1.754-.063.089-.094.266-.049.357.32.653.657 1.298 1.005 1.937.066.121.19.228.311.298.535.309 1.087.589 1.617.907.28.168.509.151.776-.018.933-.59 1.875-1.166 2.815-1.744 1.077-.664 2.148-1.337 3.239-1.977.228-.134.532-.202.798-.194 1.171.038 2.341.114 3.511.179.12.007.249.011.355.058.064.027.132.14.125.205-.008.067-.099.158-.169.174-.114.026-.24 0-.36-.006-1.168-.058-2.336-.121-3.504-.167-.162-.006-.349.041-.488.124-1.097.659-2.186 1.331-3.276 2.002-.963.592-1.923 1.189-2.955 1.828zm9.138-22.272c.014 1.558.028 3.016.042 4.527.813-.398 1.512-.779 2.242-1.086.509-.213.754-.51.72-1.075-.014-.221.029-.417-.19-.557-.907-.58-1.812-1.164-2.814-1.809zM11.403 16.02c.309-.543.585-1.037.868-1.526.594-1.024 1.199-2.04 1.781-3.07.18-.32.367-.335.646-.145.691.468 1.391.922 2.083 1.388.321.215.315.439-.018.641-1.609.981-3.218 1.962-4.836 2.929-.109.065-.291.043-.428.011-.052-.012-.072-.165-.096-.228zm3.059-4.343c-.698 1.217-1.362 2.376-2.026 3.535.039.031.079.061.118.092 1.263-.764 2.527-1.528 3.859-2.334-.695-.461-1.296-.859-1.951-1.293z"/></svg>         </a>    </div>    <div class="about-bottom">        <div class="about-desc">'+this.translate("aboutDevelop",'<a href="https://www.github.com/pytesNET" target="_blank">pytesNET</a>')+'</div>        <div class="about-desc">'+this.translate("aboutDesign",'<a href="https://octicons.github.com" target="_blank">Octicon Font 8.1.0</a>')+'</div>        <div class="about-desc about-links">            <a href="https://www.github.com/pytesNET/tail.writer" target="_blank">'+this.translate("aboutLink1")+'</a>            <a href="https://www.github.com/pytesNET/tail.writer/wiki" target="_blank">'+this.translate("aboutLink2")+'</a>            <a href="https://github.pytes.net/tail.writer" target="_blank">'+this.translate("aboutLink3")+'</a>            <a href="https://www.github.com/pytesNET/tail.writer/issues/new" target="_blank">'+this.translate("aboutLink4")+"</a>        </div>    </div></div>";this.showElement("dialog","about",r)}}},v.markups.register=function(t,e,i,n){e="function"==typeof e?e.call(this):e,t in this.markups||(this.markups[t]={actions:{},walkers:{},toolbars:i,renderer:n||function(t){return t}});var r=this.markups[t];for(var s in e)void 0!==e[s].walker&&e[s].walker&&("function"==typeof e[s].walker?r.walkers[s]=e[s].walker:!0===e[s].walker&&e[s].syntax.substr&&(r.walkers[s]=e[s].syntax.substr(0,e[s].syntax.indexOf("$1")))),r.actions[s]=e[s];return null==v.defaults.markup&&(v.defaults.markup=t),!0};var e={acronym:{syntax:"$1()",action:"inline",filter:function(t,e,i,n){return 2<e.length&&(n.start=n.end=n.end-1),e.toUpperCase()}},codeblock:{syntax:"bc. $1",action:"block"},definition:{syntax:"- $1",action:"block",filter:function(t,e,i,n){var r=this.previousLine();return r&&"-"==r.substr(0,1)?(n.start+=1,n.end+=1,":="+e.substr(1)):e},walker:function(t,e){if(/^(- |:= )/.test(t)){if(/^(- |:= )(\s+)?\S+/.test(t))return"definition";this.currentLine("")}return!1}},headers:{syntax:function(t){return"h"+t+". $1"},action:function(t,e,i,n){if(1==n.length&&"x3"!==n[0])return this.do_block(e.markup,e,i,n);var r='<div class="dropdown-form"><ul class="form-list">\n'+new Array(1==n.length&&"x3"==n[0]?3:6).fill(0).map(function(t,e){return'<li data-value="'+ ++e+'">Header '+e+"</li>"}).join("\n")+"\n</ul></div>";this.showElement("dropdown",e.id,r,function(t){return this.perform("headers",[parseInt(t.target.getAttribute("data-value"))]),this.hideElement("dropdown")})}},image:{syntax:"!$1($2)!",action:function(i,s,t,e){if(0==e.length){var n=this;return this.do_inline(i,s,t,function(t,e){return 0===t.length?(e=n.translate("imageURL"),t=n.translate("imageTitle")):/^(file|http|https)\:/i.test(t)?(e=t,t=n.translate("imageTitle")):e=n.translate("imageURL"),i.replace("$1",t).replace("$2",e)})}var r='<div class="form-row">    <input type="text" name="title" value="" style="width:100%;" placeholder="'+this.translate("imageTitle")+'" /></div><div class="form-row">    <input type="text" name="url" value="" style="width:100%;" placeholder="'+this.translate("imageURL")+'" /></div><div class="form-row">    <button data-value="submit">'+this.translate("imageButton")+"</button></div>",a=h.create("DIV","dialog-form");a.innerHTML=r,this.showElement("dialog",s.id,a,function(t,e){var i=e.querySelector("input[name=title]").value,n=e.querySelector("input[name=url]").value,r=s.syntax.replace("$1",i).replace("$2",n);return this.hideElement("dialog"),this.writeContent(r,null),!0})},filter:function(t,e,i,n){var r=this.translate("imageURL"),s=this.translate("imageTitle"),a=e.indexOf(r)<0||e.indexOf(s)<e.indexOf(r);return 0<e.indexOf(s)&&a?(n.start=t.length+e.indexOf(s),n.end=n.start+s.length):0<e.indexOf(r)&&(n.start=t.length+e.indexOf(r),n.end=n.start+r.length),e}},link:{syntax:'"$1":$2',action:function(i,a,t,e){if(0==e.length){var n=this;return this.do_inline(i,a,t,function(t,e){return 0===t.length?(e=n.translate("linkURL"),t=n.translate("linkTitle")):/^(file|ftp|http|https|mailto|news|telnet)\:/i.test(t)?(e=t,t=n.translate("linkTitle")):e=n.translate("linkURL"),i.replace("$1",t).replace("$2",e)})}var r='<div class="form-row">    <input type="text" name="title" value="" style="width:100%;" placeholder="'+this.translate("linkTitle")+'" /></div><div class="form-row">    <select name="scheme">        <option value="http">http://</option>        <option value="https">https://</option>        <option value="mailto">mailto:</option>        <option value="file">file://</option>        <option value="ftp">ftp://</option>    </select>    <input type="text" name="uri" value="" placeholder="'+this.translate("linkURL")+'" /></div><div class="form-row">    <button data-value="submit">'+this.translate("linkButton")+"</button></div>",s=h.create("DIV","dialog-form");s.innerHTML=r,s.querySelector("input[name='uri']").addEventListener("input",function(t){var e=new RegExp("^((file|ftp|http|https|telnet):\\/\\/|(mailto|news):)","i");if(!e.test(this.value))return!0;var i=this.value.substr(0,this.value.indexOf(":"));this.parentElement.querySelector("select").querySelector("option[value="+i+"]").selected=!0,this.value=this.value.replace(e,"")}),this.showElement("dialog",a.id,s,function(t,e){var i=e.querySelector("input[name=title]").value,n=e.querySelector("select[name=scheme] option:checked").innerText,r=e.querySelector("input[name=uri]").value,s=a.syntax.replace("$1",i).replace("$2",n+r);return this.hideElement("dialog"),this.writeContent(s,null),!0})},filter:function(t,e,i,n){var r=this.translate("linkURL"),s=this.translate("linkTitle"),a=e.indexOf(r)<0||e.indexOf(s)<e.indexOf(r);return 0<e.indexOf(s)&&a?(n.start=t.length+e.indexOf(s),n.end=n.start+s.length):0<e.indexOf(r)&&(n.start=t.length+e.indexOf(r),n.end=n.start+r.length),e}},list:{title:function(t){return"list"+(t=void 0===t?"unordered":t)[0].toUpperCase()+t.slice(1).toLowerCase()},syntax:function(t){return"ordered"==t?"# $1":"* $1"},action:"block",filter:function(t,e,i,n){var r=this.previousLine();if(r.substr&&"#"===r.substr(0,1))r=r.replace(/[^\#]/g,"").split("").length,r=new Array(r).join("#");else{if(!r.substr||"*"!==r.substr(0,1))return e;r=r.replace(/[^\*]/g,"").split("").length,r=new Array(r).join("*")}return n.start+=r.length,n.end+=r.length,r+e},walker:function(t,e){var i={"list:ordered":"\\#","list:unordered":"\\*"};for(var n in i)if(new RegExp("^["+i[n]+"]+\\s+").test(t)){if(new RegExp("^["+i[n]+"]+\\s+\\S+","g").test(t))return n;this.currentLine("");break}return!1}},pre:{syntax:"pre. $1",action:"block"},quote:{syntax:"bq. $1",action:"block"},table:{syntax:!(v.markups.unregister=function(t){return t in this.markups&&(delete this.markups[t],!0)}),action:function(t,e,i,n){var r="writer-"+this.id+"-"+e.id+"-",s='<div class="form-row">    <label for="'+r+'rows">'+this.translate("tableRows")+'</label>    <input id="'+r+'rows" type="number" name="rows" value="3" min="1" step="1" /></div><div class="form-row">    <label for="'+r+'cols">'+this.translate("tableCols")+'</label>    <input id="'+r+'cols" type="number" name="cols" value="3" min="1" step="1" /></div><div class="form-row">    <input id="'+r+'header" type="checkbox" name="header" value="1" />    <label for="'+r+'header">'+this.translate("tableHeader")+'</label></div><div class="form-row">    <input id="'+r+'footer" type="checkbox" name="footer" value="1" />    <label for="'+r+'footer">'+this.translate("tableFooter")+'</label></div><div class="form-row">    <button data-value="submit">'+this.translate("tableButton")+"</button></div>",a=h.create("DIV","dialog-form");a.innerHTML=s,this.showElement("dialog",e.id,a,function(t,e){for(var i,n=e.querySelector("input[name=header]").checked,r=e.querySelector("input[name=footer]").checked,s=parseInt(e.querySelector("input[name=rows]").value)||3,a=parseInt(e.querySelector("input[name=cols]").value)||3,o="",l=0;l<s+n+r;l++){n&0===l&&(o+="|^. \n"),r&l===0+n&&(o+="|~. \n");for(var h=1;h<=a;h++){i=n&0===l||r&l===0+n?(o+="|_. ",10):(o+="| ",12);for(var u=0;u<i;u++)o+=" ";o+=" "}o+="|\n",(n&0===l||r&l===0+n)&&(o+="|-. \n")}return this.hideElement("dialog"),this.writeContent(o,null),!0})}}},i={bold:"**$1**",cite:"??$1??",code:"@$1@",emphasize:"_$1_",italic:"__$1__",strikethrough:"-$1-",span:"%$1%",strong:"*$1*",sub:"~$1~",sup:"^$1^",underline:"+$1+"};for(var n in i)e[n]={syntax:i[n],action:"inline"};var s={left:"p<. $1",center:"p=. $1",right:"p>. $1",justify:"p<>. $1"};for(var n in s)e[n]={id:"align-"+n,syntax:s[n],action:"block",filter:function(t,e,i,n){var r=(this.previousLine()||"").trim(),s=(this.nextLine()||"").trim();return 0!==r.length&&(n.start++,n.end++,e="\n"+e),0!==s.length?e+"\n":e}};return v.markups.register("textile",e,{minimal:["headers:x3","|","bold","italic","underline","strikethrough","indent","outdent","|","link","image","table","list:unordered","list:ordered","|","preview"],default:["headers","|","bold","italic","underline","strikethrough","|","code","codeblock","quote","indent","outdent","|","left","center","right","justify","|","link","image","list:unordered","list:ordered","table","|","preview","fullscreen","abut"],full:["headers","|","bold","italic","underline","strikethrough","|","cite","code","span","sub","sup","|","pre","codeblock","quote","indent","outdent","|","left","center","right","justify","|","link:dialog","image:dialog","acronym","|","list:unordered","list:ordered","definition","table","hr","|","preview","fullscreen","about"]},function(t){return"function"==typeof textile&&(t=textile(t)),t}),v.markups.prototype={get:function(t,e){if(!1===e&&(t=(e=t.split(":")).shift()),e=e instanceof Array?e:[],t in this.actions)var i=this.actions[t];else{if(!(t in r.globals))return!1;i=r.globals[t]}return i.id=t,i.type=i.type?i.type:"button",i.params=e,i.classes="action-"+t+(e.length?" action-"+t+"-"+e.join("-"):""),"function"==typeof i.syntax?i.markup=i.syntax.apply(this.self,e.join?e:[e]):i.markup=i.syntax,"function"==typeof i.title?i.string=i.title.apply(this.self,e):i.string=t,i},set:function(t,e){return"function"==typeof e.walker?this.walker[t]=e.walker:!0===e.walker&&e.syntax.substr?this.walker[t]=e.syntax.substr(0,e.syntax.indexOf("$1")):type in this.walker&&delete this.walker[t],this.actions[t]=e,!0},setToolbar:function(t){return this.toolbar="string"==typeof t?(t in this.toolbars||(t="default"),this.toolbars[t]):"function"==typeof t?t.call(this.self,this.self.con.markup,this):t instanceof Array?t:[],!0},loopToolbar:function(){return this.toolbar instanceof Array&&(void 0===this._toolbarItem&&(this._toolbarItem=0),this._toolbarItem<this.toolbar.length?this.toolbar[this._toolbarItem++]:this._toolbarItem=!1)},filter:function(t,e,i,n,r){var s=this.get(t,!1);return"function"==typeof s.filter?s.filter.call(this.self,e,i,n,r):i}},v.strings={en:{chars:"Characters",lines:"Lines",words:"Words",bbcode:"BBCode",markdown:"Markdown",textile:"Textile",about:"About",aboutDevelop:"Developed by $1",aboutDesc1:"written in pure vanilla JavaScript",aboutDesc2:"published under the MIT License",aboutDesign:"Designed with $1",aboutLink1:"GitHub Repository",aboutLink2:"Documentation",aboutLink3:"Demonstration",aboutLink4:"Report a Bug",fullscreen:"Toggle Fullscreen",indent:"Indent",markup:"Change Markup",modeWrite:"Write",modePreview:"Preview",outdent:"Outdent",preview:"Toggle Preview",previewEmpty:"There is nothing to Preview yet!",errorAction:"The passed action is unknown!",errorMarkup:"The passed markup doesn't exist!",acronym:"Acronym",big:"Big",bold:"Bold",center:"Center Paragraph",cite:"Citation",code:"Code (Inline)",codeblock:"Code (Block)",color:"Text Color",definition:"Definition List",emphasize:"Emphasize",email:"eMail",emailAddress:"eMail Address",emailButton:"Embed eMail Link",emailTitle:"eMail Title",font:"Font Family",header:"Heading",headers:"Headings",hr:"Horizontal Rule",image:"Image",imageButton:"Embed Image",imageTitle:"Image Title",imageURL:"Image URL",italic:"Italic",justify:"Justify Paragraph",left:"Left Paragraph",link:"Hyperlink",linkNewTab:"Open Link in a new Tab",linkButton:"Embed Link",linkTitle:"Link Title",linkURL:"Link URL",listOrdered:"Ordered List",listUnordered:"Unordered List",listChecked:"Checked List",listUnchecked:"Unchecked List",pre:"Pre-Formatted Text",quote:"Blockquote",right:"Right Paragraph",size:"Text Size",small:"Small",span:"Span",strikethrough:"Strikethrough",strong:"Strong",sub:"Subscript",sup:"Superscript",table:"Table",tableButton:"Embed Table",tableHeader:"Add Table Header",tableFooter:"Add Table Footer",tableCols:"Columns",tableRows:"Rows",underline:"Underline"},register:function(t,e){return"string"==typeof t&&e instanceof Object&&(this[t]=e,!0)},unregister:function(t){return t in this&&(delete this[t],!0)},get:function(t,e){return e in(this[t]||{})?this[t][e]:e},set:function(t,e,i){if(!(t in this))return!1;if(e instanceof Object)for(var n in e)this.set(t,n,e[n]);else this[t][e]="string"==typeof i?i:this[t][e];return!0}},v.hook=function(t,e,i){return"string"==typeof t&&"string"==typeof e&&(t in this.hooks||(this.hooks[t]={}),!(e in this.hooks[t]||"function"!=typeof i)&&(this.hooks[t][e]=i,!0))},v.load=function(t,e){if(e instanceof Array||(e=[null]),!(t in v.hooks))return e[0];for(var i in v.hooks[t])e[0]=v.hooks[t][i].apply(this,e);return e[0]},v.hooks={},v.prototype={init:function(){var e=this;if(this.__=a(v.strings.en,v.strings[this.con.locale]||{}),this.val=this.e.editor.value,this.markup=new r(this,this.con.markup),this.markup.setToolbar(this.con.toolbar),this.build(),!0!==this.firstInit&&!this.con.preventBindings){for(var t in{click:1,input:1,keydown:1,keypress:1,keyup:1})this.e.editor.addEventListener(t,function(t){e.handle.call(e,t),e.resize.call(e,!0),e.update.call(e)});l.body.onresize=function(){e.toolbarResize.call(e)},this.bind(112,function(t){return t.preventDefault(),this.perform("about",[])},0,0,0,"keydown"),this.bind(122,function(t){return t.preventDefault(),this.perform("fullscreen",[]),this.e.editor.focus(),this},0,0,0,"keydown"),this.bind(13,function(t){if((this.walker=!1)===(this.walker=this.walkable(this.currentLine())))return this.con.doubleLineBreak&&this.writeContent("\n"),!0;t.preventDefault();var e=this.walker.split(":");return this.setContent("\n","append",null,null),this.perform(e[0],(e[1]||"").split(","))},0,0,0,"keydown"),this.bind(9,function(t){return t.preventDefault(),this.perform("indent",[])},0,0,0,"keydown"),this.bind(9,function(t){return t.preventDefault(),this.perform("outdent",[])},1,0,0,"keydown"),this.bind(68,function(t){t.preventDefault();var e=this.selection();if(e.start===e.end)return this.writeContent("\n"+this.currentLine());var i=this.getContent(e);return this.selection(e.end,e.end),this.writeContent(i,{start:e.end,end:e.end+i.length})},0,1,0,"keydown"),this.bind(88,function(t){t.preventDefault();var e=this.selection();if(e.start!==e.end)this.getContent(e);else{var i=this.val.slice(0,e.start).split("\n"),n=this.val.slice(e.start).split("\n"),r=i.pop()+n.shift();e.start=i.join("\n").length,e.end=e.start+r.length+1,this.selection(e.start,e.end)}return l.execCommand&&l.execCommand("copy"),this.writeContent("",{start:e.start,end:e.start})},0,1,0,"keydown")}return this.e.editor.disabled=!0===this.con.disabled,this.e.editor.readOnly=!0===this.con.readonly,v.load.call(this,"init"),this.resize(!1),this.firstInit=!0,this},build:function(){var t=["tail-writer"],e=this.con,i=/^[0-9.]+(?:cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|\%)$/i,n=!0===e.classNames?this.e.editor.className:e.classNames;t.push(n&&n.push?n.join(" "):n&&n.split?n:""),e.disabled&&t.push("disabled"),e.readonly&&t.push("readonly"),this.e.main=m("DIV",t),e.width&&i.test(e.width)?this.e.main.style.width=e.width:e.width&&!isNaN(parseFloat(e.width,10))?this.e.main.style.width=e.width+"px":this.e.main.style.width="100%",this.e.editor.setAttribute("data-tail-writer","tail-"+this.id),this.e.editor.parentElement.replaceChild(this.e.main,this.e.editor),this.e.main.appendChild(this.e.editor),this.toolbar(),this.statusbar(),e.height instanceof Array||(e.height=[e.height,e.height]),i.test(e.height[0])?this.e.editor.style.height=e.height[0]:isNaN(parseFloat(e.height[0],10))?this.e.editor.style.height="250px":this.e.editor.style.height=e.height[0]+"px";var r=o.getComputedStyle(this.e.tools);r=this.e.tools.offsetHeight+Math.max(parseInt(r.marginTop),0)+Math.max(parseInt(r.marginBottom),0);var s=o.getComputedStyle(this.e.status);s="object"!=typeof s?0:this.e.status.offsetHeight+Math.max(parseInt(s.marginTop),0)+Math.max(parseInt(s.marginBottom),0);var a=this.e.editor.offsetHeight-(r+s+2);return this.e.editor.className+=" tail-writer-editor",this.e.editor.style.height=a+"px",this.e.editor.style.minHeight=a+"px",e.height[0]!==e.height[1]&&e.height[1]?i.test(e.height[1])?this.e.editor.style.maxHeight=e.height[1]:isNaN(parseFloat(e.height[1],10))||(this.e.editor.style.maxHeight=e.height[1]+"px"):this.e.editor.style.maxHeight=a+"px",e.indentTab&&(this.e.editor.style.tabSize=e.indentSize),this},toolbar:function(){var t=m("DIV","toolbar-inner");this.e.tools=m("DIV","tail-writer-toolbar"),this.e.tools.appendChild(t);for(var e,i,n,r,s,a,o,l,h,u=this;e=this.markup.loopToolbar();)if("$"===e&&this.con.multiLineBreak)t.appendChild(m("DIV","toolbar-linebreak"));else if("|"!==e){if(n=this.markup.get(e,!1)){if("button"===n.type)(i=m("BUTTON","toolbar-action "+n.classes)).addEventListener("click",function(t){return t.preventDefault(),!u.con.disabled&&!c(t.target,"disabled")&&u.perform.call(u,this.getAttribute("data-writer-action"),!1)});else{if("select"!==n.type)continue;if((i=m("SELECT","toolbar-action "+n.classes)).addEventListener("change",function(t){if(u.con.disabled||c(t.target,"disabled"))return!1;var e=this.getAttribute("data-writer-action")+":"+this.value;return u.perform.call(u,e,!1)}),sel=n.selected.call?n.selected.call(this):n.selected,"object"!=typeof(a=n.values.call?n.values.call(this):n.values))continue;for(r in a)(s=m("OPTION")).value=r,s.selected=s.value===sel,s.innerText=this.translate(a[r]),i.appendChild(s)}for(o in{mouseover:1,mouseout:1,click:1})i.addEventListener(o,function(t){u.tooltip.call(u,t,this)});i.setAttribute("data-writer-action",e),i.setAttribute("data-writer-tooltip",this.translate(n.string)),n.toolbar&&"function"==typeof n.toolbar&&(i=n.toolbar.call(this,i)),t.appendChild(i)}}else t.appendChild(m("SPAN","toolbar-separator"));if(!this.con.toolbarMultiLine&&(t.style.overflow="hidden",t.style.whiteSpace="nowrap",this.con.toolbarScrollable))for(var d in{left:1,right:1})(l=m("BUTTON","toolbar-scroll action-scroll-"+d)).setAttribute("tail-writer-action","scroll-"+d),l.addEventListener("click",function(t){t.preventDefault();var e=this.parentElement.querySelector(".toolbar-inner"),i=this.getAttribute("tail-writer-action"),n=e.scrollLeft+("scroll-right"==i?105:-105);e.scrollTo?e.scrollTo({top:0,left:n,behavior:"smooth"}):e.scrollLeft=n}),this.e.tools.insertBefore(l,this.e.tools.children[0]);return null!==(h=this.e.main.querySelector(".tail-writer-toolbar"))?this.e.main.replaceChild(this.e.tools,h):this.e.main.insertBefore(this.e.tools,this.e.main.children[0]),this.toolbarResize()},toolbarResize:function(){if(this.con.toolbarMultiLine||!this.con.toolbarScrollable)return this;var t=this.e.tools.querySelector(".toolbar-inner");return t.scrollWidth>t.offsetWidth?u(this.e.tools,"scrollable"):d(this.e.tools,"scrollable"),this},statusbar:function(){if(this.e.status=m("DIV","tail-writer-statusbar"),"function"==typeof this.con.statusbar){if("object"!=typeof(t=this.con.statusbar.call(this)))return!1}else{if(!1===this.con.statusbar)return!1;var t={},e=this.count();t[this.translate("lines")]=e.lines,t[this.translate("chars")]=e.chars,t[this.translate("words")]=e.words}var i="";for(var n in t)i+='<div class="statusbar-field">    <span class="field-title">'+n+':</span>    <span class="field-value">'+t[n]+"</span></div>";this.e.status.innerHTML=i,this.e.main.appendChild(this.e.status);var r=this.e.main.querySelector(".tail-writer-statusbar");return null!==r?this.e.main.replaceChild(this.e.status,r):this.e.main.insertBefore(this.e.status,this.e.main.children[0]),this},count:function(){var t={lines:(this.val.match(/^|\n/g)||[""]).length.toString(),chars:this.val.length.toString(),words:"0"},e=this.val.trim().replace(/[\:\-\.\?\!]/g,"").trim();return(e=e.replace(/[\n\t\s]+/g," ").replace(/[^\w\s]+/g,"").split(" ")).length<=1&&0==e[0].length?t.words="0":t.words=e.length.toString(),t},handle:function(t){p(this.e.main,"tail.writer::"+t.type,{bubbles:!1,cancelable:!0,detail:{args:arguments,self:this}});for(var e=(this.events[t.type]||[]).length,i=0;i<e;i++)this.events[t.type][i].cb.apply(this,function(t,e,i){for(var n=e.length,r=0;r<n;++r)t[r-1]=e[r];return t[r]=i,t}(new Array(arguments.length),arguments,this.events[t.type][i].args));if("click"==t.type){for(var n=t.target;!1!==n;){if(c(n,"tail-writer-dropdown")||c(n,"tail-writer-dialog")){n=!0;break}if(c(n,"tail-writer")){n=!1;break}n=n.parentElement}return n||(this.hideElement("dialog"),this.hideElement("dropdown")),!0}if("input"==t.type&&(this.val=this.e.editor.value),0<=["keydown","keyup","keypress"].indexOf(t.type)){var r=t.altKey,s=t.ctrlKey,a=t.shiftKey,o=t.which||t.keyCode,l=0+(a?16:0)+(s?17:0)+(r?18:0);if(!(t.type+"-"+o in this.keys))return!1;var h=this.keys[t.type+"-"+o];return l in h&&h[l].call(this,t)}return!1},walkable:function(t){if(0==t.length)return!1;var e=!1,i=(v.markups[this.con.markup],this.markup.walkers),n=this.markup.actions;for(var r in i)if("function"==typeof i[r]){if(!1!==(e=i[r].call(this,t,n[r])))break}else{var s=this.indentation("convert",i[r],!0);if(0<=t.indexOf(s)){t.length>s.length?e=r:this.currentLine("");break}}return e},error:function(t){this.con.debug&&console.error("tail.writer Error: "+this.translate(t))},translate:function(){if(0==arguments.lengt)return"";var t=arguments[0];t=t in this.__?this.__[t]:t;for(var e=1;e<arguments.length;e++)t=t.replace("$"+e,arguments[e]);return t},selection:function(t,e){if(void 0!==t)return"object"==typeof t&&"start"in t&&(e=t.end||e||void 0,t=t.start),t=(t=isNaN(t)?this.val.length:t)<0?this.val.length+t:t,e=(e=isNaN(e)||null===e?t:e)<0?this.val.length+e+1:e,this.e.editor.focus(),this.e.editor.selectionStart=t,this.e.editor.selectionEnd=e,this.selection();var i={start:this.e.editor.selectionStart,end:this.e.editor.selectionEnd};return i.lines=this.getContent(i).split("\n").length-1,i},indentation:function(t,e,r){void 0===e&&(e=this.val);this.con.indentTab,this.con.indentTab;var i=this.con.indentSize%2==1?this.con.indentSize++:this.con.indentSize,s={tab:"\\t",space:new Array(i+1).join(" ")},n=function(t,e,i){var n=r?new RegExp(s[e],"gm"):new RegExp("^"+s[e],"gm");return t.replace(n,"tab"==i?"\t":s[i])};switch(t){case"indent":e=e.split("\n").map(function(t){return"\t"+t}).join("\n");break;case"outdent":e=e.split("\n").map(function(t){return t.replace(new RegExp("^(\\t|"+s.space+")"),"")}).join("\n");break;case"convert":case"revert":e="convert"==t&&this.con.indentTab||"revert"==t&&!this.con.indentTab?n(e,"space","tab"):n(e,"tab","space");break;case"count":r=!0,e=((e=n(e,"space","tab")).match(/\t/g)||[]).length}return e},indenter:function(t,e){return this.error("The `indent()` function is deprecated, please use `indentation()` instead!",!0),"count"===e?this.indentation("count",t):"create"===e?this.indentation("indent",t):this.indentation("convert",t)},getContent:function(t){return this.val=this.e.editor.value,void 0===t?this.val:isNaN(t)?(null===t&&(t=this.selection()),t.length&&2==t.length||"start"in t&&"end"in t?this.val.substring("start"in t?t.start:t[0],"end"in t?t.end:t[1]):""):this.val.substr(t<0?this.val.length+t:t)},readContent:function(t,e){if(void 0===t||0===t&&void 0===e)return this.getContent();var i=this.getContent().split("\n");return t<0&&(t=i.length+t),(void 0===e||e<t)&&(e=i.length),i.slice(t,e).join("\n")},read:function(){return this.error("The `read()` function is deprecated, please use `getContent()` or `readContent()` instead!",!0),this.getContent()},splitContent:function(t){var e=this.getContent();return null===t&&(t=this.selection()),void 0===t?["",e,""]:isNaN(t)?"start"in t&&"end"in t?[e.slice(0,t.start),e.slice(t.start,t.end),e.slice(t.end)]:!(!t.length||2!=t.length)&&[e.slice(0,t[0]),e.slice(t[0],t[1]),e.slice(t[1])]:[e.slice(0,t),e.slice(t),""]},setContent:function(t,e,i,n){var r=this.splitContent(i),s=this.selection();if(!r)return!1;r.join("").length;switch(e){case"append":t=this.indentation("convert",t),null===n&&(s.start+=t.length,s.end+=t.length),r[1]=r[1]+t;break;case"prepend":t=this.indentation("convert",t),null===n&&(s.start+=t.length,s.end+=t.length),r[1]=t+r[1];break;default:t=this.indentation("convert",t),null===n&&(s.end=s.end-r[1].length+t.length),r[1]=t}return this.e.editor.value=this.val=this.indentation("convert",r.join("")),void 0!==n&&(null===n&&(n=s),this.selection(n)),this.resize(!1),this.val},writeContent:function(t,e){var i=this.selection();return i.start!==i.end?this.setContent(t,"replace",i,e):this.setContent(t,"append",i,e)},write:function(t,e){return this.error("The `write()` function is deprecated, please use `setContent()` or `writeContent()` instead!",!0),this.setContent(t,"replace",void 0,e)},previousLine:function(t){var e=this.selection(),i=this.val.slice(0,e.start).split("\n");if(i.pop(),"string"!=typeof t)return 0<i.length&&i.pop();if(0<i.length){var n=i.pop().length,r=i.join("\n").length;this.setContent(t,"replace",[r,n+r],null)}else this.setContent(t+"\n","prepend",null);return t},currentLine:function(t){var e=this.selection(),i=this.val.slice(0,e.start).split("\n"),n=this.val.slice(e.start).split("\n"),r=i.pop()+n.shift();if("string"!=typeof t)return r;var s=i.join("\n").length+(i.length?1:0);return this.setContent(t,"replace",[s,s+r.length],null),t},nextLine:function(t){var e=this.selection(),i=this.val.slice(e.start).split("\n"),n=e.start-i.shift().length+1;return"string"==typeof t?(0<i.length?this.setContent(t,"replace",[n,n+i.shift().length],null):this.setContent("\n"+t,"append",null),t):0<i.length&&i.shift()},resize:function(t){if(!this.con.resize)return!1;var e=this.e.editor.cloneNode();e.style.cssText="height:auto;min-height:none;max-height:none;opacity:0;position:absolute;",this.e.main.insertBefore(e,this.e.editor);var i=e.scrollHeight+"px";return parseInt(this.e.editor.style.minHeight,10)>e.scrollHeight?i=this.e.editor.style.minHeight:parseInt(this.e.editor.style.maxHeight,10)<e.scrollHeight&&(i=this.e.editor.style.maxHeight),this.e.editor.style.height=parseInt(i,10)+2+"px",this.e.main.removeChild(e),this},tooltip:function(t,e){if(c(this.e.main,"disabled")||c(this.e.main,"readonly"))return!1;if(c(t.target,"disabled")||!1===this.con.tooltip)return!1;if("function"==typeof this.con.tooltip)return this.con.tooltip.call(this,t,e);var i,n,r=e.getAttribute("data-writer-action").replace(/[^a-z_-]/g,"-");if("mouseover"!==t.type)return!!(s=this.e.main.querySelector("#tooltip-"+r))&&(c(s,"show")?(d(s,"show"),n=s,void setTimeout(function(){n&&n.parentElement&&n.parentElement.removeChild(n)},200)):s&&s.parentElement?s.parentElement.removeChild(s):void 0);var s=l.createElement("DIV"),a=f(e);if(!this.e.main.querySelector("#tooltip-"+r)){switch(s.id="tooltip-"+r,s.innerHTML=e.getAttribute("data-writer-tooltip"),s.className="tail-writer-tooltip tooltip-position-"+this.con.tooltip,this.e.main.appendChild(s),this.con.tooltip){case"left":s.style.top=a.top+a.height/2-s.offsetHeight/2+"px",s.style.left=a.left-s.offsetWidth-10+"px";break;case"right":s.style.top=a.top+a.height/2-s.offsetHeight/2+"px",s.style.left=a.left+a.width+10+"px";break;case"bottom":s.style.top=a.top+a.height+10+"px",s.style.left=a.left+a.width/2-s.offsetWidth/2+"px";break;default:s.style.top=a.top-s.offsetHeight-10+"px",s.style.left=a.left+a.width/2-s.offsetWidth/2+"px"}1<this.e.tools.offsetLeft&&(s.style.top=parseInt(s.style.top)+this.e.tools.offsetTop+"px",s.style.left=parseInt(s.style.left)+this.e.tools.offsetLeft+"px");var o=this.e.tools.querySelector(".toolbar-inner");o&&0<o.scrollLeft&&(s.style.left=parseInt(s.style.left)-o.scrollLeft+"px")}return i="tooltip-"+r,setTimeout(function(){l.querySelector("#"+i)&&u(l.querySelector("#"+i),"show")},350),!0},update:function(){return v.load.call(this,"update"),this.statusbar()},perform:function(t,e){if(!c(this.e.main,"disabled")&&!c(this.e.main,"readonly")){var i=this.markup.get(t,e);return!1===i?this.error("errorAction"):("string"==typeof i.markup&&(i.markup=this.indentation("convert",i.markup,!0)),"function"==typeof i.action?i.action.call(this,i.markup,i,i.id,i.params):0<=["inline","block"].indexOf(i.action)&&this["do_"+i.action].call(this,i.markup,i,i.params),!(this.walker=!1))}this.walker=!1},do_inline:function(e,t,i,n){var r=this.selection(),s=this.splitContent(r);s[1]=s[1].split("\n").map(n||function(t){return e.replace("$1",t)}).join("\n"),r.start===r.end?r.end=r.start+=e.indexOf("$1"):r.end=r.start+s[1].length;var a=this.markup.filter(t.id,s[0],s[1],s[2],r);return this.writeContent(a,r)},do_block:function(e,t,i,n){var r=this.selection(),s=this.splitContent(r);t.walker?s[1]=s[1].split("\n").map(n||function(t){return e.replace("$1",t)}).join("\n"):s[1]=e.replace("$1",s[1]),r.start===r.end?r.start=r.end=r.start+e.indexOf("$1"):(r.end=r.start=s[0].length+s[1].length,r.end=r.start+=t.walker?0:-e.indexOf("$1"));var a=this.markup.filter(t.id,s[0],s[1],s[2],r);return this.writeContent(a,r)},showElement:function(t,e,i,n){if(!c(this.e.main,"disabled")&&!c(this.e.main,"readonly")){if(this.e.main.querySelector("#"+t+"-"+e))return this.hideElement(t,e);this.hideElement(t);var r=m("DIV","tail-writer-"+t+" tail-writer-"+t+"-"+e);if(r.id=t+"-"+e,i instanceof Element?r.appendChild(i):r.innerHTML=i,this.e.main.appendChild(r),"dropdown"==t){var s=this.e.tools.querySelector(".action-"+e);r.style.top=s.offsetTop+s.offsetHeight+"px",r.style.left=s.offsetLeft+"px"}else"dialog"==t&&(r.style.top="50%",r.style.left="50%",r.style.marginTop="-"+r.offsetHeight/2+"px",r.style.marginLeft="-"+r.offsetWidth/2+"px");return(r=v.load.call(this,"showElement",[r,t,e,i,n]))instanceof Element&&(function(e,i){if(!r.querySelector(".dropdown-form,.dialog-form"))return;var n=r.querySelector(".dropdown-form,.dialog-form");n.addEventListener("click",function(t){t.target.hasAttribute("data-value")&&(t.preventDefault(),e.call(i,t,n))})}(n,this),u(r,"show"),!0)}},showDialog:function(t,e,i){return this.error("The `showDialog()` function is deprecated, please use `showElement()` instead!",!0),this.showElement("dialog",t,e,i)},showDropdown:function(t,e,i){return this.error("The `showDropdown()` function is deprecated, please use `showElement()` instead!",!0),this.showElement("dropdown",t,e,i)},hideElement:function(t,e){if(void 0===e)var i=this.e.main.querySelectorAll(".tail-writer-"+t);else i=this.e.main.querySelectorAll(".tail-writer-"+t+"-"+e);if(!(i=v.load.call(this,"hideElement",[i,t,e])).length||i.length&&0==i.length)return!1;for(var n=i.length,r=0;r<n;r++)d(i[r],"show"),function(t){setTimeout(function(){t&&t.parentElement&&t.parentElement.removeChild(t)},200)}(i[r]);return!0},hideDialog:function(){return this.error("The `hideDialog()` function is deprecated, please use `hideElement()` instead!",!0),this.hideElement("dialog")},hideDropdown:function(){return this.error("The `hideDropdown()` function is deprecated, please use `hideElement()` instead!",!0),this.hideElement("dropdown")},on:function(t,e,i){return"string"==typeof t&&"function"==typeof e&&(t in this.events||(this.events[t]=[]),this.events[t].push({cb:e,args:i instanceof Array?i:[]}),!0)},bind:function(t,e,i,n,r,s){if(["keydown","keypress","keyup"].indexOf(s="string"!=typeof s?"keydown":s)<0)return!1;if("number"!=typeof t||"function"!=typeof e)return!1;var a=0+(i?16:0)+(n?17:0)+(r?18:0);return s+"-"+t in this.keys||(this.keys[s+"-"+t]={}),this.keys[s+"-"+t][a.toString()]=e,!1},config:function(t,e,i){if(void 0===t)return this.con;if(t instanceof Object){for(var n in t)this.con[n]=t[n];return i?this.reload:this}return void 0===e?t in this.con?this.con[t]:void 0:(this.con[t]=e,i?this.reload():this)},disable:function(){return this.e.editor.disabled=!!state,this.config("disabled",!0,!0)},enable:function(){return this.e.editor.disabled=!1,this.config("disabled",!1,!0)},readonly:function(t){return this.e.editor.readOnly=!!t,this.config("readonly",!!t,!0)},remove:function(){this.e.main.removeChild(this.e.tools),this.e.main.removeChild(this.e.status);var t=this.e.main.querySelector("textarea");return t.removeAttribute("data-tail-writer"),d(t,"tail-writer-editor"),this.e.main.parentElement.replaceChild(t,this.e.main),v.load.call(this,"remove"),this},reload:function(){return this.remove().init()}},v});
  