// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/utils/htmlToSvg/supportClasses/DomProcessor",["dojo/dom-construct","./text/ReplaceUtil"],function(e,m){var g=/^ /,h=/ $/,k={_tempNode:e.create("div",null,document.body),replaceTextWithSpans:function(b){function l(f,b){var a=function(){var a;f.parentNode?a=f.parentNode.innerHTML:(k._tempNode.appendChild(f),a=f.parentNode.innerHTML,k._tempNode.removeChild(f));return a||""}();return a.trim()?function(a){var b=!1;a=a.replace(/([^;])(&nbsp;)([^&])/g,"$1 $3");-1!==a.indexOf("\x26nbsp;")&&
(a=a.split("\x26nbsp;").map(function(a){return a?(b=!0,"\x3cspan\x3e"+a+"\x3c/span\x3e"):a}).join("\x26nbsp;"));b&&(a=a.replace(/((&nbsp;)+)/g,"\x3cspan\x3e$1\x3c/span\x3e"));return a}(a):b?m.removeReturns(a):null}if(2>b.childNodes.length&&"TD"!==b.nodeName){if(1===b.childNodes.length){var a=b.childNodes[0];"#text"===a.nodeName&&(a=l(a))&&b.innerHTML!==a&&(b.innerHTML=a)}}else{for(a=[];b.childNodes.length;)a.push(b.removeChild(b.childNodes[0]));a.forEach(function(a){if("#text"===a.nodeName){if(a=
l(a,"TR"!==b.nodeName))if(a=e.create("span",{innerHTML:a}),1===a.childNodes.length)e.place(a,b);else for(;a.childNodes.length;)b.appendChild(a.removeChild(a.childNodes[0]))}else e.place(a,b)});for(a=0;a<b.childNodes.length;a++){var c=b.childNodes[a-1],d=b.childNodes[a];c&&"SPAN"===c.nodeName&&"SPAN"===d.nodeName&&(c.innerHTML.trim()||d.innerHTML.trim())&&(!c.innerHTML.trim()&&g.test(d.innerHTML)?d.innerHTML=d.innerHTML.substr(1):h.test(c.innerHTML)&&!d.innerHTML.trim()?c.innerHTML=c.innerHTML.substr(0,
c.innerHTML.length-1):!h.test(c.innerHTML)&&g.test(d.innerHTML)?(d.innerHTML=d.innerHTML.substr(1),e.create("span",{innerHTML:" "},c,"after"),a++):h.test(c.innerHTML)&&!g.test(d.innerHTML)&&(c.innerHTML=c.innerHTML.substr(0,c.innerHTML.length-1),e.create("span",{innerHTML:" "},c,"after"),a++))}}}};return k});