// 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/conversion/ShapeConverter",["dojo/_base/lang","esri/dijit/geoenrichment/utils/JsonXmlConverter"],function(h,k){function b(a){return"string"===typeof a?Number(a.replace("px","")):Number(a)}var e={},l=/path|ellipse|circle|polygon|rect|line/,q=["fill","fill-opacity","stroke","storke-opacity"],r=["display"];e.svgJsonToShapeObject=function(a,g){function t(a){var d=a.attributes;if(!d)return!1;if(!g.ignoreHiddenElements)return!0;if("none"===d.display)return!1;
a=d.fill&&"none"!==d.fill&&(void 0===d["fill-opacity"]||0!==d["fill-opacity"]);d=d.stroke&&"none"!==d.stroke&&(void 0===d["stroke-opacity"]||0!==d["stroke-opacity"]);return void 0===a&&void 0===d?!0:a||d}g=g||{};if(g.ignoreHiddenElements){var f=function(a,b){b=h.mixin({},b);a.attributes=a.attributes||{};q.forEach(function(d){var c=a.attributes[d];void 0===c&&(c=a.attributes[d]=b[d]);b[d]=c});r.forEach(function(d){var c=b[d]||a.attributes[d];a.attributes[d]=c;b[d]=c});a.tags&&a.tags.forEach(function(a){f(a,
b)})};a=h.clone(a);f(a)}var c={name:g.name||"",g:[],style:{}};if(a.attributes.viewBox){var e=a.attributes.viewBox.split(" ");c.viewBox={xmin:b(e[0]),ymin:b(e[1]),width:b(e[2]),height:b(e[3])}}else if(a.attributes.width&&a.attributes.height)c.viewBox={xmin:0,ymin:0,width:b(a.attributes.width),height:b(a.attributes.height)};else return c;a.attributes.width&&(c.style.width=b(a.attributes.width));a.attributes.height&&(c.style.height=b(a.attributes.height));a.attributes.zoom&&(c.style.zoom=b(a.attributes.zoom));
c.preserveAspectRatio=a.attributes.preserveAspectRatio;c.showAsBar=a.attributes.showAsBar;c.showBarBackground=a.attributes.showBarBackground;k.queryJson(a,l).forEach(function(a){t(a)&&("path"===a.name?c.g.push({name:"path",d:a.attributes.d}):"ellipse"===a.name?c.g.push({name:"ellipse",cx:b(a.attributes.cx),cy:b(a.attributes.cy),rx:b(a.attributes.rx),ry:b(a.attributes.ry)}):"circle"===a.name?c.g.push({name:"circle",cx:b(a.attributes.cx),cy:b(a.attributes.cy),r:b(a.attributes.r)}):"polygon"===a.name?
c.g.push({name:"polygon",points:a.attributes.points}):"rect"===a.name?c.g.push({name:"rect",x:b(a.attributes.x),y:b(a.attributes.y),width:b(a.attributes.width),height:b(a.attributes.height)}):"line"===a.name&&c.g.push({name:"line",x1:b(a.attributes.x1),y1:b(a.attributes.y1),x2:b(a.attributes.x2),y2:b(a.attributes.y2)}))});return c};e.shapeJsonToSvgJson=function(a){return{name:"svg",attributes:{width:a.style.width||void 0,height:a.style.height||void 0,viewBox:a.viewBox.xmin+" "+a.viewBox.ymin+" "+
a.viewBox.width+" "+a.viewBox.height,preserveAspectRatio:a.preserveAspectRatio,showAsBar:a.showAsBar,showBarBackground:a.showBarBackground,zoom:a.style.zoom||void 0},tags:[{name:"g",tags:a.g.map(function(a){var b=h.mixin({},a);delete b.name;return{name:a.name,attributes:b}})}]}};var m={borderColor:"stroke",fillColor:"fill",borderAlpha:"stroke-opacity",fillAlpha:"fill-opacity",borderWidth:"stroke-width",borderDashArray:"stroke-dasharray",strokeMiterLimit:"stroke-miterlimit"},u={"stroke-opacity":1,
"fill-opacity":1,"stroke-width":1},n={},p;for(p in m)n[m[p]]=p;e.applyStylesToSvgJson=function(a,b){k.queryJson(a,l).forEach(function(a){a.attributes=a.attributes||{};for(var e in b){var c=m[e];c&&(a.attributes[c]=b[e])}})};e.getStylesFromSvgJson=function(a){var b={};a=k.queryJson(a,l)[0];if(!a||!a.attributes)return b;for(var e in n){var f=a.attributes[e];void 0!==f&&(b[n[e]]=u[e]?Number(f):f)}return b};return e});