// 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/ReportPlayer/core/supportClasses/templateJsonUtils/fieldInfo/RichTextJsonUtil",["./utils","../countryConfig"],function(k,m){var d={},n={_reCache:{},getRegExp:function(){var a=m.getCurrencySymbol();this._reCache[a]||(this._reCache[a]=new RegExp("[\\"+a+"%]*\\[[^\\[]*\\]%*","g"));return this._reCache[a]}};d.collectFieldInfosFromRenderedXMLString=function(a,b){var e={},c={};b&&b.fieldInfos.forEach(function(a){e[k.renderer.renderFieldInfoInTableCell(a)]=a});b&&b.specialFieldInfos.forEach(function(a){c[k.renderer.renderFieldInfoInTableCell(a)]=
a});var g=[],d=[],h=a.match(n.getRegExp());h&&h.forEach(function(b){var f=e[b]||c[b]||k.builder.createFieldInfoFromSpecialFieldName(b.replace(/\[|\]/g,""))||k.builder.createFieldInfoFromLabel(b);f&&(f.hasVariable||f.script?(g.push(f),a=a.replace(b,"\x3cd/\x3e")):(d.push(f),a=a.replace(b,"\x3ctext/\x3e")))});return{xmlString:a,fieldInfos:g,specialFieldInfos:d}};var p=/<d[^\/]*\/>/,q=/<text[^\/]*\/>/,h=/<reportname\s*\/\>/i,l=/<reporttitle2\s*\/\>/i;d.createFieldInfoFromRichText=function(a,b,e){a=a||
"";b=b||[];e=e||[];for(var c=0;c<b.length;c++)a=a.replace(p,d._wrapFieldInfoInRichText(b[c]));for(c=0;c<e.length;c++){var g=e[c],f;f="Title"===g.name&&h.test(a)?h:"Subtitle"===g.name&&l.test(a)?l:q;a=a.replace(f,d._wrapFieldInfoInRichText(g))}return{isRichText:!0,richTextJson:{fieldInfos:b,specialFieldInfos:e,xmlString:a}}};d.createRichTextFromFieldInfo=function(a,b,e){a=a.richTextJson;var c=a.xmlString;a.fieldInfos.forEach(function(a){var e=b(a);c=c.replace(d._wrapFieldInfoInRichText(a),e||"")});
a.specialFieldInfos.forEach(function(a){var b=e(a);c=c.replace(d._wrapFieldInfoInRichText(a),b||"")});return c};d.addFieldInfosToRichTextFieldInfo=function(a,b,e){var c=a.richTextJson;c.xmlString+=(e&&e.addSpaces&&c.xmlString?" ":"")+b.map(function(a){a.hasVariable?c.fieldInfos.push(a):c.specialFieldInfos.push(a);return d._wrapFieldInfoInRichText(a)}).join(", ")};d._wrapFieldInfoInRichText=function(a){return"["+a.name+"]"};d.updateXMLString=function(a,b){b.forEach(function(b){a=a.replace(new RegExp("\\["+
b.nameBefore+"\\]","g"),"["+b.name+"]")});return a};return d});