/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../core/Logger","../../../../layers/graphics/hydratedFeatures","../../../../support/arcadeOnDemand"],(function(e,t,r,n,c){"use strict";const o=r.getLogger("esri.views.3d.layers.graphics.featureExpressionInfoUtils");function u(e){return{cachedResult:e.cachedResult,arcade:e.arcade?{func:e.arcade.func,context:e.arcade.modules.arcadeUtils.createExecContext(null,{sr:e.arcade.context.spatialReference}),modules:e.arcade.modules}:null}}function a(e){const t=e&&e.expression;if("string"==typeof t){const e=g(t);if(null!=e)return{cachedResult:e}}return null}function s(e,t,r){return l.apply(this,arguments)}function l(){return l=t._asyncToGenerator((function*(e,t,r){const n=e&&e.expression;if("string"!=typeof n)return null;const o=g(n);if(null!=o)return{cachedResult:o};const u=yield c.loadArcade(),a=u.arcadeUtils,s=a.createSyntaxTree(n);return a.dependsOnView(s)?(null!=r&&r.error("Expressions containing '$view' are not supported on ElevationInfo"),{cachedResult:0}):{arcade:{func:a.createFunction(s),context:a.createExecContext(null,{sr:t}),modules:u}}})),l.apply(this,arguments)}function i(e,t,r){return e.arcadeUtils.createFeature(t.attributes,t.geometry,r)}function d(e,t){if(null!=e&&!y(e)){if(!t||!e.arcade)return void o.errorOncePerTick("Arcade support required but not provided");const r=t;r._geometry&&(r._geometry=n.hydrateGeometry(r._geometry)),e.arcade.modules.arcadeUtils.updateExecContext(e.arcade.context,t)}}function f(e){if(null!=e){if(y(e))return e.cachedResult;const t=e.arcade;let r=e.arcade.modules.arcadeUtils.executeFunction(t.func,t.context);return"number"!=typeof r&&(e.cachedResult=0,r=0),r}return 0}function p(e,t=!1){let r=e&&e.featureExpressionInfo;const n=r&&r.expression;return t||"0"===n||(r=null),r}const x={cachedResult:0};function y(e){return null!=e.cachedResult}function g(e){return"0"===e?0:null}e.clone=u,e.createContext=s,e.createContextWithoutExpressionSupport=a,e.createFeature=i,e.execute=f,e.extractExpressionInfo=p,e.setContextFeature=d,e.zeroContext=x,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
