//>>built
define("dojox/editor/plugins/NormalizeStyle","dojo dijit dojox dijit/_editor/_Plugin dijit/_editor/html dojo/_base/connect dojo/_base/declare".split(" "),function(e,z,C,A,B){var y=e.declare("dojox.editor.plugins.NormalizeStyle",A,{mode:"semantic",condenseSpans:!0,setEditor:function(f){this.editor=f;f.customUndo=!0;"semantic"===this.mode?this.editor.contentDomPostFilters.push(e.hitch(this,this._convertToSemantic)):"css"===this.mode&&this.editor.contentDomPostFilters.push(e.hitch(this,this._convertToCss));
e.isIE?(this.editor.contentDomPreFilters.push(e.hitch(this,this._convertToSemantic)),this._browserFilter=this._convertToSemantic):e.isWebKit?(this.editor.contentDomPreFilters.push(e.hitch(this,this._convertToCss)),this._browserFilter=this._convertToCss):(this.editor.contentDomPreFilters.push(e.hitch(this,this._convertToSemantic)),this._browserFilter=this._convertToSemantic);this.editor._inserthtmlImpl&&(this.editor._oldInsertHtmlImpl=this.editor._inserthtmlImpl);this.editor._inserthtmlImpl=e.hitch(this,
this._inserthtmlImpl)},_convertToSemantic:function(f){if(f){var k=this.editor.document,g=this,d=function(a){if(1==a.nodeType){if("dijitEditorBody"!==a.id){var c=a.style,l=a.tagName?a.tagName.toLowerCase():"";if(c&&"table"!=l&&"ul"!=l&&"ol"!=l){var n=c.fontWeight?c.fontWeight.toLowerCase():"",m=c.fontStyle?c.fontStyle.toLowerCase():"",u=c.textDecoration?c.textDecoration.toLowerCase():"",b=c.fontSize?c.fontSize.toLowerCase():"",q=c.backgroundColor?c.backgroundColor.toLowerCase():"";c=c.color?c.color.toLowerCase():
"";var p=function(r,t){if(r){for(;t.firstChild;)r.appendChild(t.firstChild);"span"!=l||t.style.cssText?t.appendChild(r):(e.place(r,t,"before"),t.parentNode.removeChild(t),t=r)}return t};switch(n){case "bold":case "bolder":case "700":case "800":case "900":var h=k.createElement("b");a.style.fontWeight=""}a=p(h,a);h=null;"italic"==m&&(h=k.createElement("i"),a.style.fontStyle="");a=p(h,a);h=null;if(u){var w=u.split(" "),v=0;e.forEach(w,function(r){switch(r){case "underline":h=k.createElement("u");break;
case "line-through":h=k.createElement("strike")}v++;v==w.length&&(a.style.textDecoration="");a=p(h,a);h=null})}b&&(0<b.indexOf("pt")?(b=b.substring(0,b.indexOf("pt")),b=parseInt(b),5>b?b="xx-small":10>b?b="x-small":15>b?b="small":20>b?b="medium":25>b?b="large":30>b?b="x-large":30<b&&(b="xx-large")):0<b.indexOf("px")&&(b=b.substring(0,b.indexOf("px")),b=parseInt(b),5>b?b="xx-small":10>b?b="x-small":15>b?b="small":20>b?b="medium":25>b?b="large":30>b?b="x-large":30<b&&(b="xx-large")),(n={"xx-small":1,
"x-small":2,small:3,medium:4,large:5,"x-large":6,"xx-large":7,"-webkit-xxx-large":7}[b])||(n=3),h=k.createElement("font"),h.setAttribute("size",n),a.style.fontSize="");a=p(h,a);h=null;q&&"font"!==l&&g._isInline(l)&&(q=(new e.Color(q)).toHex(),h=k.createElement("font"),h.style.backgroundColor=q,a.style.backgroundColor="");c&&"font"!==l&&(c=(new e.Color(c)).toHex(),h=k.createElement("font"),h.setAttribute("color",c),a.style.color="");a=p(h,a);h=null}}if(a.childNodes){var x=[];e.forEach(a.childNodes,
function(r){x.push(r)});e.forEach(x,d)}}return a};return this._normalizeTags(d(f))}return f},_normalizeTags:function(f){var k=this.editor.document;e.query("em,s,strong",f).forEach(function(g){switch(g.tagName?g.tagName.toLowerCase():""){case "s":var d="strike";break;case "em":d="i";break;case "strong":d="b"}if(d){var a=k.createElement(d);for(e.place("\x3c"+d+"\x3e",g,"before");g.firstChild;)a.appendChild(g.firstChild);g.parentNode.removeChild(g)}});return f},_convertToCss:function(f){if(f){var k=
this.editor.document,g=function(d){if(1==d.nodeType){if("dijitEditorBody"!==d.id){var a=d.tagName?d.tagName.toLowerCase():"";if(a){switch(a){case "b":case "strong":var c=k.createElement("span");c.style.fontWeight="bold";break;case "i":case "em":c=k.createElement("span");c.style.fontStyle="italic";break;case "u":c=k.createElement("span");c.style.textDecoration="underline";break;case "strike":case "s":c=k.createElement("span");c.style.textDecoration="line-through";break;case "font":a={},e.attr(d,"color")&&
(a.color=e.attr(d,"color")),e.attr(d,"face")&&(a.fontFace=e.attr(d,"face")),d.style&&d.style.backgroundColor&&(a.backgroundColor=d.style.backgroundColor),d.style&&d.style.color&&(a.color=d.style.color),c={1:"xx-small",2:"x-small",3:"small",4:"medium",5:"large",6:"x-large",7:"xx-large"},e.attr(d,"size")&&(a.fontSize=c[e.attr(d,"size")]),c=k.createElement("span"),e.style(c,a)}if(c){for(;d.firstChild;)c.appendChild(d.firstChild);e.place(c,d,"before");d.parentNode.removeChild(d);d=c}}}if(d.childNodes){var l=
[];e.forEach(d.childNodes,function(n){l.push(n)});e.forEach(l,g)}}return d};f=g(f);this.condenseSpans&&this._condenseSpans(f)}return f},_condenseSpans:function(f){var k=function(g){var d=function(u){if(u){var b={};u=u.toLowerCase().split(";");e.forEach(u,function(q){if(q){var p=q.split(":");q=p[0]?e.trim(p[0]):"";p=p[1]?e.trim(p[1]):"";if(q&&p){var h,w="";for(h=0;h<q.length;h++){var v=q.charAt(h);"-"==v?(h++,v=q.charAt(h),w+=v.toUpperCase()):w+=v}b[w]=p}}})}return b};if(g&&1==g.nodeType&&"span"===
(g.tagName?g.tagName.toLowerCase():"")&&g.childNodes&&1===g.childNodes.length)for(var a=g.firstChild;a&&1==a.nodeType&&a.tagName&&"span"==a.tagName.toLowerCase();)if(e.attr(a,"class")||e.attr(a,"id")||!a.style)a=a.nextSibling;else{var c=d(g.style.cssText),l=d(a.style.cssText);if(c&&l){var n={},m;for(m in c)if(c[m]&&l[m]&&c[m]!=l[m]){c[m]!=l[m]?"textDecoration"==m?(n[m]=c[m]+" "+l[m],delete l[m]):n=null:n=null;break}else n[m]=c[m],delete l[m];if(n){for(m in l)n[m]=l[m];for(e.style(g,n);a.firstChild;)g.appendChild(a.firstChild);
c=a.nextSibling;a.parentNode.removeChild(a);a=c}else a=a.nextSibling}else a=a.nextSibling}g.childNodes&&g.childNodes.length&&e.forEach(g.childNodes,k)};k(f)},_isInline:function(f){switch(f){case "a":case "b":case "strong":case "s":case "strike":case "i":case "u":case "em":case "sup":case "sub":case "span":case "font":case "big":case "cite":case "q":case "img":case "small":return!0;default:return!1}},_inserthtmlImpl:function(f){if(f){var k=this.editor.document.createElement("div");k.innerHTML=f;k=
this._browserFilter(k);f=B.getChildrenHtml(k);k.innerHTML="";return this.editor._oldInsertHtmlImpl?this.editor._oldInsertHtmlImpl(f):this.editor.execCommand("inserthtml",f)}return!1}});e.subscribe(z._scopeName+".Editor.getPlugin",null,function(f){f.plugin||"normalizestyle"!==f.args.name.toLowerCase()||(f.plugin=new y({mode:"mode"in f.args?f.args.mode:"semantic",condenseSpans:"condenseSpans"in f.args?f.args.condenseSpans:!0}))});return y});