// 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/arcade/arcadeCompiler","require exports ../geometry/Polygon ../geometry/Polyline ../geometry/Point ../geometry/Extent ../geometry/Multipoint ../SpatialReference ./languageUtils ./treeAnalysis ./Dictionary ./Feature ./functions/date ./functions/string ./functions/maths ./functions/geometry ./functions/geomsync ./functions/stats ./ImmutablePathArray ./ImmutablePointArray ../geometry/Geometry".split(" "),function(la,n,Q,R,S,T,U,V,d,h,t,x,W,X,Y,Z,aa,ba,D,ca,da){function m(b,a,c){try{return c(b,
null,a)}catch(e){throw e;}}function g(b,a){try{switch(a.type){case "EmptyStatement":return"lc.voidOperation";case "VariableDeclarator":return ea(b,a);case "VariableDeclaration":for(var c=[],e=0;e<a.declarations.length;e++)c.push(g(b,a.declarations[e]));return c.join("\n")+" \n lastStatement\x3d  lc.voidOperation; \n";case "BlockStatement":return K(b,a);case "FunctionDeclaration":var e=a.id.name.toLowerCase(),f={applicationCache:void 0===b.applicationCache?null:b.applicationCache,spatialReference:b.spatialReference,
console:b.console,symbols:b.symbols,localScope:{_SymbolsMap:{}},depthCounter:b.depthCounter+1,globalScope:b.globalScope};if(64<f.depthCounter)throw Error("Exceeded maximum function depth");for(var d="new lc.SizzleFunction( lang.functionDepthchecker(function() { var lastStatement \x3d lc.voidOperation; var lscope \x3d [];\n ",y=0;y<a.params.length;y++){var l=a.params[y].name.toLowerCase(),E=G(l,b);f.localScope._SymbolsMap[l]=E;d+="lscope['"+E+"']\x3darguments["+y.toString()+"];\n"}d+=K(f,a.body)+"\n return lastStatement; }, runtimeCtx))";
d+="\n lastStatement \x3d lc.voidOperation; \n";void 0!==b.globalScope[e]?c="gscope['"+e+"']\x3d"+d:void 0!==b.globalScope._SymbolsMap[e]?c="gscope['"+b.globalScope._SymbolsMap[e]+"']\x3d"+d:(E=G(e,b),b.globalScope._SymbolsMap[e]=E,c="gscope['"+E+"']\x3d"+d);return c;case "ReturnStatement":var L;L=null===a.argument?"return lc.voidOperation;":"return "+g(b,a.argument)+";";return L;case "IfStatement":if("AssignmentExpression"===a.test.type||"UpdateExpression"===a.test.type)throw Error(h.nodeErrorMessage(a.test,
"RUNTIME","CANNOT_USE_ASSIGNMENT_IN_CONDITION"));var fa=g(b,a.test),m=B(b),n="var "+m+" \x3d "+fa+";\n if ("+m+" \x3d\x3d\x3d true) {\n"+M(b,a.consequent)+"\n }\n",n=null!==a.alternate?n+("else if ("+m+"\x3d\x3d\x3dfalse)   { \n"+M(b,a.alternate)+"}\n"):n+("else if ("+m+"\x3d\x3d\x3dfalse) { \n lastStatement \x3d lc.voidOperation;\n }\n");return n+="else { lang.error({type: '"+a.type+"'},'RUNTIME','CANNOT_USE_NONBOOLEAN_IN_CONDITION'); \n}\n";case "ExpressionStatement":var t;t="AssignmentExpression"===
a.expression.type?"lastStatement \x3d lc.voidOperation; "+g(b,a.expression)+" \n ":"lastStatement \x3d "+g(b,a.expression)+";";return t;case "AssignmentExpression":return ga(b,a);case "UpdateExpression":return ha(b,a);case "BreakStatement":return"break;";case "ContinueStatement":return"continue;";case "ForStatement":c="lastStatement \x3d lc.voidOperation; \n";null!==a.init&&(c+=g(b,a.init));var q=B(b),u=B(b),c=c+("var "+q+" \x3d true;")+"\n do { ";null!==a.update&&(c+=" if ("+q+"\x3d\x3d\x3dfalse) {\n "+
g(b,a.update)+"  \n}\n "+q+"\x3dfalse; \n");null!==a.test&&(c+="var "+u+" \x3d "+g(b,a.test)+";",c+="if ("+u+"\x3d\x3d\x3dfalse) { break; } else if ("+u+"!\x3d\x3dtrue) { lang.error({type: '"+a.type+"'},'RUNTIME','CANNOT_USE_NONBOOLEAN_IN_CONDITION');   }\n");c+=g(b,a.body);null!==a.update&&(c+="\n "+g(b,a.update));return c+("\n"+q+" \x3d true; \n} while(true);  lastStatement \x3d lc.voidOperation;");case "ForInStatement":var v=B(b),A=B(b),r=B(b),k="var "+v+" \x3d "+g(b,a.right)+";\n";"VariableDeclaration"===
a.left.type&&(k+=g(b,a.left));var w="VariableDeclaration"===a.left.type?a.left.declarations[0].id.name:a.left.name,w=w.toLowerCase(),c="";null!==b.localScope&&(void 0!==b.localScope[w]?c="lscope['"+w+"']":void 0!==b.localScope._SymbolsMap[w]&&(c="lscope['"+b.localScope._SymbolsMap[w]+"']"));""===c&&(void 0!==b.globalScope[w]?c="gscope['"+w+"']":void 0!==b.globalScope._SymbolsMap[w]&&(c="gscope['"+b.globalScope._SymbolsMap[w]+"']"));k=k+("if ("+v+"\x3d\x3d\x3dnull) {  lastStatement \x3d lc.voidOperation; }\n ")+
("else if (lc.isArray("+v+") || lc.isString("+v+")) {")+("var "+A+"\x3d"+v+".length; \n")+("for(var "+r+"\x3d0; "+r+"\x3c"+A+"; "+r+"++) {\n");k+=c+"\x3d"+r+";\n";k+=g(b,a.body);k+="\n}\n";k+=" lastStatement \x3d lc.voidOperation; \n";k+=" \n}\n";k+="else if (lc.isImmutableArray("+v+")) {";k=k+("var "+A+"\x3d"+v+".length(); \n")+("for(var "+r+"\x3d0; "+r+"\x3c"+A+"; "+r+"++) {\n");k+=c+"\x3d"+r+";\n";k+=g(b,a.body);k+="\n}\n";k+=" lastStatement \x3d lc.voidOperation; \n";k+=" \n}\n";k+="else if (( "+
v+" instanceof lang.Dictionary) || ( "+v+" instanceof lang.Feature)) {";k=k+("var "+A+"\x3d"+v+".keys(); \n")+("for(var "+r+"\x3d0; "+r+"\x3c"+A+".length; "+r+"++) {\n");k+=c+"\x3d"+A+"["+r+"];\n";k+=g(b,a.body);k+="\n}\n";k+=" lastStatement \x3d lc.voidOperation; \n";k+=" \n}\n";return k+"else { lastStatement \x3d lc.voidOperation; } \n";case "Identifier":return ia(b,a);case "MemberExpression":var x;try{c=void 0,c=!0===a.computed?g(b,a.property):"'"+a.property.name+"'",x="lang.member("+g(b,a.object)+
","+c+")"}catch(p){throw p;}return x;case "Literal":return null===a.value||void 0===a.value?"null":JSON.stringify(a.value);case "ThisExpression":throw Error(h.nodeErrorMessage(a,"RUNTIME","NOTSUPPORTED"));case "CallExpression":try{if("Identifier"!==a.callee.type)throw Error(h.nodeErrorMessage(a,"RUNTIME","ONLYNODESSUPPORTED"));var z=a.callee.name.toLowerCase(),c="";null!==b.localScope&&(void 0!==b.localScope[z]?c="lscope['"+z+"']":void 0!==b.localScope._SymbolsMap[z]&&(c="lscope['"+b.localScope._SymbolsMap[z]+
"']"));""===c&&(void 0!==b.globalScope[z]?c="gscope['"+z+"']":void 0!==b.globalScope._SymbolsMap[z]&&(c="gscope['"+b.globalScope._SymbolsMap[z]+"']"));if(""!==c)for(e="[",f=0;f<a.arguments.length;f++)0<f&&(e+=", "),e+=g(b,a.arguments[f]);else throw Error(h.nodeErrorMessage(a,"RUNTIME","NOTFOUND"));}catch(p){throw p;}return"lang.callfunc("+c+","+(e+"]")+",runtimeCtx)";case "UnaryExpression":var C;try{C="lang.unary("+g(b,a.argument)+",'"+a.operator+"')"}catch(p){throw p;}return C;case "BinaryExpression":var D;
try{D="lang.binary("+g(b,a.left)+","+g(b,a.right)+",'"+a.operator+"')"}catch(p){throw p;}return D;case "LogicalExpression":var F;try{if("AssignmentExpression"===a.left.type||"UpdateExpression"===a.left.type)throw Error(h.nodeErrorMessage(a.left,"RUNTIME","CANNOT_USE_ASSIGNMENT_IN_CONDITION"));if("AssignmentExpression"===a.right.type||"UpdateExpression"===a.right.type)throw Error(h.nodeErrorMessage(a.right,"RUNTIME","CANNOT_USE_ASSIGNMENT_IN_CONDITION"));if("\x26\x26"===a.operator||"||"===a.operator)F=
"(lang.logicalCheck("+g(b,a.left)+") "+a.operator+" lang.logicalCheck("+g(b,a.right)+"))";else throw Error(h.nodeErrorMessage("LogicalExpression","RUNTIME","ONLYORORAND"));}catch(p){throw p;}return F;case "ConditionalExpression":throw Error(h.nodeErrorMessage(a,"RUNTIME","NOTSUPPORTED"));case "ArrayExpression":try{c=[];for(e=0;e<a.elements.length;e++)"Literal"===a.elements[e].type?c.push(g(b,a.elements[e])):c.push("lang.aCheck("+g(b,a.elements[e])+",'ArrayExpression')");d="["+c.join(",")+"]"}catch(p){throw p;
}return d;case "ObjectExpression":c="lang.dictionary([";for(e=0;e<a.properties.length;e++){var y=a.properties[e],H="Identifier"===y.key.type?"'"+y.key.name+"'":g(b,y.key),I=g(b,y.value);0<e&&(c+=",");c+="lang.strCheck("+H+",'ObjectExpression'),lang.aCheck("+I+", 'ObjectExpression')"}return c+"])";case "Property":throw Error("Should not get here");case "Array":throw Error(h.nodeErrorMessage(a,"RUNTIME","NOTSUPPORTED"));default:throw Error(h.nodeErrorMessage(a,"RUNTIME","UNREOGNISED"));}}catch(p){throw p;
}}function ha(b,a){var c=null,e="";if("MemberExpression"===a.argument.type)return c=g(b,a.argument.object),e=!0===a.argument.computed?g(b,a.argument.property):"'"+a.argument.property.name+"'","lang.memberupdate("+c+","+e+",'"+a.operator+"',"+a.prefix+")";c=a.argument.name.toLowerCase();if(null!==b.localScope){if(void 0!==b.localScope[c])return"lang.update(lscope, '"+c+"','"+a.operator+"',"+a.prefix+")";if(void 0!==b.localScope._SymbolsMap[c])return"lang.update(lscope, '"+b.localScope._SymbolsMap[c]+
"','"+a.operator+"',"+a.prefix+")"}if(void 0!==b.globalScope[c])return"lang.update(gscope, '"+c+"','"+a.operator+"',"+a.prefix+")";if(void 0!==b.globalScope._SymbolsMap[c])return"lang.update(gscope, '"+b.globalScope._SymbolsMap[c]+"','"+a.operator+"',"+a.prefix+")";throw Error("Variable not recognised");}function ga(b,a){var c=g(b,a.right),e=null,d="";if("MemberExpression"===a.left.type)return e=g(b,a.left.object),d=!0===a.left.computed?g(b,a.left.property):"'"+a.left.property.name+"'","lang.assignmember("+
e+","+d+",'"+a.operator+"',"+c+");";e=a.left.name.toLowerCase();if(null!==b.localScope){if(void 0!==b.localScope[e])return"lscope['"+e+"']\x3dlang.assign("+c+",'"+a.operator+"', lscope['"+e+"']); ";if(void 0!==b.localScope._SymbolsMap[e])return"lscope['"+b.localScope._SymbolsMap[e]+"']\x3dlang.assign("+c+",'"+a.operator+"', lscope['"+b.localScope._SymbolsMap[e]+"']); "}if(void 0!==b.globalScope[e])return"gscope['"+e+"']\x3dlang.assign("+c+",'"+a.operator+"', gscope['"+e+"']); ";if(void 0!==b.globalScope._SymbolsMap[e])return"gscope['"+
b.globalScope._SymbolsMap[e]+"']\x3dlang.assign("+c+",'"+a.operator+"', gscope['"+b.globalScope._SymbolsMap[e]+"']); ";throw Error("Variable not recognised");}function M(b,a){return"BlockStatement"===a.type?g(b,a):"ReturnStatement"===a.type?g(b,a):"BreakStatement"===a.type?g(b,a):"ContinueStatement"===a.type?g(b,a):"UpdateExpression"===a.type?"lastStatement \x3d "+g(b,a)+";":"ExpressionStatement"===a.type?g(b,a):"ObjectExpression"===a.type?"lastStatement \x3d "+g(b,a)+";":g(b,a)}function K(b,a){for(var c=
"",e=0;e<a.body.length;e++)c="ReturnStatement"===a.body[e].type?c+(g(b,a.body[e])+" \n"):"BreakStatement"===a.body[e].type?c+(g(b,a.body[e])+" \n"):"ContinueStatement"===a.body[e].type?c+(g(b,a.body[e])+" \n"):"UpdateExpression"===a.body[e].type?c+("lastStatement \x3d "+g(b,a.body[e])+"; \n"):"ObjectExpression"===a.body[e].type?c+("lastStatement \x3d "+g(b,a.body[e])+"; \n"):c+(g(b,a.body[e])+" \n");return c}function ea(b,a){var c=null===a.init?null:g(b,a.init);c===d.voidOperation&&(c=null);var e=
a.id.name.toLowerCase();if(null!==b.localScope){if(void 0!==b.localScope[e])return"lscope['"+e+"']\x3d"+c+";";if(void 0!==b.localScope._SymbolsMap[e])return"lscope['"+b.localScope._SymbolsMap[e]+"']\x3d"+c+";";var f=G(e,b);b.localScope._SymbolsMap[e]=f;return"lscope['"+f+"']\x3d"+c+";"}if(void 0!==b.globalScope[e])return"gscope['"+e+"']\x3d"+c+";";if(void 0!==b.globalScope._SymbolsMap[e])return"gscope['"+b.globalScope._SymbolsMap[e]+"']\x3d"+c+";";f=G(e,b);b.globalScope._SymbolsMap[e]=f;return"gscope['"+
f+"']\x3d"+c+";"}function ja(b,a,c){a=a.toLowerCase();switch(a){case "hasz":return b=b.hasZ,void 0===b?!1:b;case "hasm":return b=b.hasM,void 0===b?!1:b;case "spatialreference":return a=b.spatialReference._arcadeCacheId,void 0===a&&(c=!0,Object.freeze&&Object.isFrozen(b.spatialReference)&&(c=!1),c&&(q++,a=b.spatialReference._arcadeCacheId=q)),b=new t({wkt:b.spatialReference.wkt,wkid:b.spatialReference.wkid}),void 0!==a&&(b._arcadeCacheId="SPREF"+a.toString()),b}switch(b.type){case "extent":switch(a){case "xmin":case "xmax":case "ymin":case "ymax":case "zmin":case "zmax":case "mmin":case "mmax":return b=
b[a],void 0!==b?b:null;case "type":return"Extent"}break;case "polygon":switch(a){case "rings":return a=d.isVersion4?b.cache._arcadeCacheId:b.getCacheValue("_arcadeCacheId"),void 0===a&&(q++,a=q,d.isVersion4?b.cache._arcadeCacheId=a:b.setCacheValue("_arcadeCacheId",a)),b=new D(b.rings,b.spatialReference,!0===b.hasZ,!0===b.hasM,a);case "type":return"Polygon"}break;case "point":switch(a){case "x":case "y":case "z":case "m":return void 0!==b[a]?b[a]:null;case "type":return"Point"}break;case "polyline":switch(a){case "paths":return a=
d.isVersion4?b.cache._arcadeCacheId:b.getCacheValue("_arcadeCacheId"),void 0===a&&(q++,a=q,d.isVersion4?b.cache._arcadeCacheId=a:b.setCacheValue("_arcadeCacheId",a)),b=new D(b.paths,b.spatialReference,!0===b.hasZ,!0===b.hasM,a);case "type":return"Polyline"}break;case "multipoint":switch(a){case "points":return a=d.isVersion4?b.cache._arcadeCacheId:b.getCacheValue("_arcadeCacheId"),void 0===a&&(q++,a=q,d.isVersion4?b.cache._arcadeCacheId=a:b.setCacheValue("_arcadeCacheId",a)),b=new ca(b.points,b.spatialReference,
!0===b.hasZ,!0===b.hasM,a,1);case "type":return"Multipoint"}}throw Error(h.nodeErrorMessage(c,"RUNTIME","PROPERTYNOTFOUND"));}function ia(b,a){try{var c=a.name.toLowerCase();if(null!==b.localScope){if(void 0!==b.localScope[c])return"lscope['"+c+"']";if(void 0!==b.localScope._SymbolsMap[c])return"lscope['"+b.localScope._SymbolsMap[c]+"']"}if(void 0!==b.globalScope[c])return"gscope['"+c+"']";if(void 0!==b.globalScope._SymbolsMap[c])return"gscope['"+b.globalScope._SymbolsMap[c]+"']";throw Error(h.nodeErrorMessage(a,
"RUNTIME","VARIABLENOTFOUND"));}catch(e){throw e;}}function F(b){return null===b?"":d.isArray(b)||d.isImmutableArray(b)?"Array":d.isDate(b)?"Date":d.isString(b)?"String":d.isBoolean(b)?"Boolean":d.isNumber(b)?"Number":b instanceof t?"Dictionary":b instanceof x?"Feature":b instanceof S?"Point":b instanceof Q?"Polygon":b instanceof R?"Polyline":b instanceof U?"Multipoint":b instanceof T?"Extent":d.isFunctionParameter(b)?"Function":b===d.voidOperation?"":"number"===typeof b&&isNaN(b)?"Number":"Unrecognised Type"}
function H(b,a,c,e){try{if(d.equalityTest(a[c],e))return a[c+1];var f=a.length-c;return 1===f?a[c]:2===f?null:3===f?a[c+2]:H(b,a,c+2,e)}catch(J){throw J;}}function I(b,a,c,e){try{if(!0===e)return a[c+1];if(3===a.length-c)return a[c+2];var f=a[c+2];if(!1===d.isBoolean(f))throw Error("WHEN needs boolean test conditions");return I(b,a,c+2,f)}catch(J){throw J;}}function u(b,a){var c=b.length,e=Math.floor(c/2);if(0===c)return[];if(1===c)return[b[0]];for(var d=u(b.slice(0,e),a),c=u(b.slice(e,c),a),e=[];0<
d.length||0<c.length;)if(0<d.length&&0<c.length){var g=a(d[0],c[0]);isNaN(g)&&(g=0);0>=g?(e.push(d[0]),d=d.slice(1)):(e.push(c[0]),c=c.slice(1))}else 0<d.length?(e.push(d[0]),d=d.slice(1)):0<c.length&&(e.push(c[0]),c=c.slice(1));return e}function G(b,a){a.symbols.symbolCounter++;return"_T"+a.symbols.symbolCounter.toString()}function B(b){b.symbols.symbolCounter++;return"_Tvar"+b.symbols.symbolCounter.toString()}function ka(b,a,c){var d={};b||(b={});c||(c={});d._SymbolsMap={};d.textformatting=1;d.infinity=
1;d.pi=1;for(var f in a)d[f]=1;for(f in c)d[f]=1;for(f in b)d[f]=1;return d}function N(b){console.log(b)}Object.defineProperty(n,"__esModule",{value:!0});var q=0,l={};W.registerFunctions(l,m);X.registerFunctions(l,m);Y.registerFunctions(l,m);Z.registerFunctions(l,m);ba.registerFunctions(l,m);aa.registerFunctions(l,m);l["typeof"]=function(b,a){return m(b,a,function(b,a,f){d.pcCheck(f,1,1);b=F(f[0]);if("Unrecognised Type"===b)throw Error("Unrecognised Type");return b})};l.iif=function(b,a){try{return m(b,
a,function(b,a,f){d.pcCheck(f,3,3);if(!1===d.isBoolean(f[0]))throw Error("IF Function must have a boolean test condition");return f[0]?f[1]:f[2]})}catch(c){throw c;}};l.decode=function(b,a){try{return m(b,a,function(a,d,f){if(2>f.length)throw Error("Missing Parameters");if(2===f.length)return f[1];if(0===(f.length-1)%2)throw Error("Must have a default value result.");return H(b,f,1,f[0])})}catch(c){throw c;}};l.when=function(b,a){try{return m(b,a,function(a,e,f){if(3>f.length)throw Error("Missing Parameters");
if(0===f.length%2)throw Error("Must have a default value result.");a=f[0];if(!1===d.isBoolean(a))throw Error("WHEN needs boolean test conditions");return I(b,f,0,a)})}catch(c){throw c;}};l.top=function(b,a){return m(b,a,function(b,a,f){d.pcCheck(f,2,2);if(d.isArray(f[0]))return d.toNumber(f[1])>=f[0].length?f[0].slice(0):f[0].slice(0,d.toNumber(f[1]));if(d.isImmutableArray(f[0]))return d.toNumber(f[1])>=f[0].length()?f[0].slice(0):f[0].slice(0,d.toNumber(f[1]));throw Error("Top cannot accept this parameter type");
})};l.first=function(b,a){return m(b,a,function(b,a,f){d.pcCheck(f,1,1);return d.isArray(f[0])?0===f[0].length?null:f[0][0]:d.isImmutableArray(f[0])?0===f[0].length()?null:f[0].get(0):null})};l.sort=function(b,a){return m(b,a,function(b,a,f){d.pcCheck(f,1,2);a=f[0];d.isImmutableArray(a)&&(a=a.toArray());if(!1===d.isArray(a))throw Error("Illegal Argument");if(1<f.length){if(!1===d.isFunctionParameter(f[1]))throw Error("Illegal Argument");a=u(a,function(a,c){return O.callfunc(f[1],[a,c],b)})}else{if(0===
a.length)return[];for(var c={},e=0;e<a.length;e++){var g=F(a[e]);""!==g&&(c[g]=!0)}if(!0===c.Array||!0===c.Dictionary||!0===c.Feature||!0===c.Point||!0===c.Polygon||!0===c.Polyline||!0===c.Multipoint||!0===c.Extent||!0===c.Function)return a.slice(0);var e=0,g="",h;for(h in c)e++,g=h;a=1<e||"String"===g?u(a,function(a,b){if(null===a||void 0===a||a===d.voidOperation)return null===b||void 0===b||b===d.voidOperation?0:1;if(null===b||void 0===b||b===d.voidOperation)return-1;var c=d.toString(a),e=d.toString(b);
return c<e?-1:c===e?0:1}):"Number"===g?u(a,function(a,b){return a-b}):"Boolean"===g?u(a,function(a,b){return a===b?0:b?-1:1}):"Date"===g?u(a,function(a,b){return b-a}):a.slice(0)}return a})};for(var P in l)l[P]=new d.NativeFunction(l[P]);var C=function(){};C.prototype=l;n.functionHelper={fixSpatialReference:d.fixSpatialReference,parseArguments:function(b,a){for(var c=[],d=0;d<a.arguments.length;d++)c.push(g(b,a.arguments[d]));return c},standardFunction:m};n.extend=function(b){for(var a={mode:"sync",
compiled:!0,functions:{},signatures:[],standardFunction:m},c=0;c<b.length;c++)b[c].registerFunctions(a);for(var e in a.functions)l[e]=new d.NativeFunction(a.functions[e]),C.prototype[e]=l[e];for(c=0;c<a.signatures.length;c++)h.addFunctionDeclaration(a.signatures[c],"f")};n.executeScript=function(b,a,c){return b(a,c)};n.extractFieldLiterals=function(b,a){void 0===a&&(a=!1);return h.findFieldLiterals(b,a)};n.validateScript=function(b,a){return h.validateScript(b,a,"simple")};n.referencesMember=function(b,
a){return h.referencesMember(b,a)};n.referencesFunction=function(b,a){return h.referencesFunction(b,a)};var O={error:function(b,a,c){throw Error(h.nodeErrorMessage(b,a,c));},functionDepthchecker:function(b,a){return function(){a.depthCounte++;if(64<a.depthCounter)throw Error("Exceeded maximum function depth");var c=b.apply(this,arguments);a.depthCounte--;return c}},aCheck:function(b,a){if(d.isFunctionParameter(b))throw Error(h.nodeErrorMessage({type:a},"RUNTIME","FUNCTIONCONTEXTILLEGAL"));return b===
d.voidOperation?null:b},Dictionary:t,Feature:x,dictionary:function(b){for(var a={},c=0;c<b.length;c+=2){if(d.isFunctionParameter(b[c+1]))throw Error("Illegal Argument");if(!1===d.isString(b[c]))throw Error("Illegal Argument");a[b[c].toString()]=b[c+1]===d.voidOperation?null:b[c+1]}b=new t(a);b.immutable=!1;return b},strCheck:function(b,a){if(!1===d.isString(b))throw Error("Illegal Argument");return b},unary:function(b,a){if(d.isBoolean(b)){if("!"===a)return!b;if("-"===a)return-1*d.toNumber(b);if("+"===
a)return 1*d.toNumber(b);throw Error(h.nodeErrorMessage({type:"UnaryExpression"},"RUNTIME","NOTSUPPORTEDUNARYOPERATOR"));}if("-"===a)return-1*d.toNumber(b);if("+"===a)return 1*d.toNumber(b);throw Error(h.nodeErrorMessage({type:"UnaryExpression"},"RUNTIME","NOTSUPPORTEDUNARYOPERATOR"));},logicalCheck:function(b){if(!1===d.isBoolean(b))throw Error(h.nodeErrorMessage("LogicalExpression","RUNTIME","ONLYORORAND"));return b},logical:function(b,a,c){if(d.isBoolean(b)&&d.isBoolean(a))switch(c){case "||":return b||
a;case "\x26\x26":return b&&a;default:throw Error(h.nodeErrorMessage("LogicalExpression","RUNTIME","ONLYORORAND"));}else throw Error(h.nodeErrorMessage("LogicalExpression","RUNTIME","ONLYORORAND"));},binary:function(b,a,c){switch(c){case "\x3d\x3d":return d.equalityTest(b,a);case "\x3d":return d.equalityTest(b,a);case "!\x3d":return!d.equalityTest(b,a);case "\x3c":return d.greaterThanLessThan(b,a,c);case "\x3e":return d.greaterThanLessThan(b,a,c);case "\x3c\x3d":return d.greaterThanLessThan(b,a,c);
case "\x3e\x3d":return d.greaterThanLessThan(b,a,c);case "+":return d.isString(b)||d.isString(a)?d.toString(b)+d.toString(a):d.toNumber(b)+d.toNumber(a);case "-":return d.toNumber(b)-d.toNumber(a);case "*":return d.toNumber(b)*d.toNumber(a);case "/":return d.toNumber(b)/d.toNumber(a);case "%":return d.toNumber(b)%d.toNumber(a);default:throw Error(h.nodeErrorMessage({type:"BinaryExpression"},"RUNTIME","OPERATORNOTRECOGNISED"));}},assign:function(b,a,c){switch(a){case "\x3d":return b===d.voidOperation?
null:b;case "/\x3d":return d.toNumber(c)/d.toNumber(b);case "*\x3d":return d.toNumber(c)*d.toNumber(b);case "-\x3d":return d.toNumber(c)-d.toNumber(b);case "+\x3d":return d.isString(c)||d.isString(b)?d.toString(c)+d.toString(b):d.toNumber(c)+d.toNumber(b);case "%\x3d":return d.toNumber(c)%d.toNumber(b);default:throw Error(h.nodeErrorMessage("AssignmentExpression","RUNTIME","OPERATORNOTRECOGNISED"));}},update:function(b,a,c,e){var f=d.toNumber(b[a]);b[a]="++"===c?f+1:f-1;return!1===e?f:"++"===c?f+
1:f-1},memberupdate:function(b,a,c,e){var f;if(d.isArray(b))if(d.isNumber(a)){0>a&&(a=b.length+a);if(0>a||a>=b.length)throw Error("Assignment outside of array bounds");f=d.toNumber(b[a]);b[a]="++"===c?f+1:f-1}else throw Error("Invalid Parameter");else if(b instanceof t){if(!1===d.isString(a))throw Error("Dictionary accessor must be a string");if(!0===b.hasField(a))f=d.toNumber(b.field(a)),b.setField(a,"++"===c?f+1:f-1);else throw Error("Invalid Parameter");}else if(b instanceof x){if(!1===d.isString(a))throw Error("Feature accessor must be a string");
if(!0===b.hasField(a))f=d.toNumber(b.field(a)),b.setField(a,"++"===c?f+1:f-1);else throw Error("Invalid Parameter");}else{if(d.isImmutableArray(b))throw Error("Array is Immutable");throw Error("Invalid Parameter");}return!1===e?f:"++"===c?f+1:f-1},assignmember:function(b,a,c,e){if(d.isArray(b))if(d.isNumber(a)){0>a&&(a=b.length+a);if(0>a||a>b.length)throw Error("Assignment outside of array bounds");if(a===b.length&&"\x3d"!==c)throw Error("Invalid Parameter");b[a]=this.assign(e,c,b[a])}else throw Error("Invalid Parameter");
else if(b instanceof t){if(!1===d.isString(a))throw Error("Dictionary accessor must be a string");if(!0===b.hasField(a))b.setField(a,this.assign(e,c,b.field(a)));else{if("\x3d"!==c)throw Error("Invalid Parameter");b.setField(a,this.assign(e,c,null))}}else if(b instanceof x){if(!1===d.isString(a))throw Error("Feature accessor must be a string");if(!0===b.hasField(a))b.setField(a,this.assign(e,c,b.field(a)));else{if("\x3d"!==c)throw Error("Invalid Parameter");b.setField(a,this.assign(e,c,null))}}else{if(d.isImmutableArray(b))throw Error("Array is Immutable");
throw Error("Invalid Parameter");}},member:function(b,a){if(null===b)throw Error(h.nodeErrorMessage("MemberExpression","RUNTIME","NOTFOUND"));if(b instanceof t||b instanceof x){if(d.isString(a))return b.field(a)}else if(b instanceof da){if(d.isString(a))return ja(b,a,"MemberExpression")}else if(d.isArray(b)){if(d.isNumber(a)&&isFinite(a)&&Math.floor(a)===a){0>a&&(a=b.length+a);if(a>=b.length||0>a)throw Error(h.nodeErrorMessage("MemberExpression","RUNTIME","OUTOFBOUNDS"));return b[a]}}else if(d.isString(b)){if(d.isNumber(a)&&
isFinite(a)&&Math.floor(a)===a){0>a&&(a=b.length+a);if(a>=b.length||0>a)throw Error(h.nodeErrorMessage("MemberExpression","RUNTIME","OUTOFBOUNDS"));return b[a]}}else if(d.isImmutableArray(b)&&d.isNumber(a)&&isFinite(a)&&Math.floor(a)===a){0>a&&(a=b.length()+a);if(a>=b.length()||0>a)throw Error(h.nodeErrorMessage("MemberExpression","RUNTIME","OUTOFBOUNDS"));return b.get(a)}throw Error(h.nodeErrorMessage("MemberExpression","RUNTIME","INVALIDTYPE"));},callfunc:function(b,a,c){return b instanceof d.NativeFunction?
b.fn(c,a):b instanceof d.SizzleFunction?b.fn.apply(this,a):b.apply(this,a)}};n.compileScript=function(b,a){void 0===a&&(a=null);null===a&&(a={vars:{},customfunctions:{}});var c={globalScope:ka(a.vars,l,a.customfunctions),localScope:null,console:N,symbols:{symbolCounter:0}},c=g(c,b.body[0].body);""===c&&(c="lc.voidOperation;");var e={lc:d,lang:O,postProcess:function(a){a instanceof d.ReturnResult&&(a=a.value);a instanceof d.ImplicitResult&&(a=a.value);a===d.voidOperation&&(a=null);if(a===d.breakResult)throw Error("Cannot return BREAK");
if(a===d.continueResult)throw Error("Cannot return CONTINUE");if(d.isFunctionParameter(a))throw Error("Cannot return FUNCTION");return a},prepare:function(a,b){b||(b=new V({wkid:102100}));var c=a.vars,d=a.customfunctions,e=new C;c||(c={});d||(d={});var f=new t({newline:"\n",tab:"\t",singlequote:"'",doublequote:'"',forwardslash:"/",backwardslash:"\\"});f.immutable=!1;e._SymbolsMap={textformatting:1,infinity:1,pi:1};e.textformatting=f;e.infinity=Number.POSITIVE_INFINITY;e.pi=Math.PI;for(var g in d)e[g]=
d[g],e._SymbolsMap[g]=1;for(g in c)e._SymbolsMap[g]=1,e[g]=c[g]&&"esri.Graphic"===c[g].declaredClass?new x(c[g]):c[g];return{spatialReference:b,globalScope:e,localScope:null,console:a.console?a.console:N,symbols:{symbolCounter:0},depthCounter:1,applicationCache:void 0===a.applicationCache?null:a.applicationCache}}};return(new Function("context","spatialReference","var runtimeCtx\x3dthis.prepare(context, spatialReference);\n var lc \x3d this.lc;  var lang \x3d this.lang; var gscope\x3druntimeCtx.globalScope; \n function mainBody() {\n var lastStatement\x3dlc.voidOperation;\n "+
c+"\n return lastStatement; } \n return this.postProcess(mainBody());")).bind(e)}});