/*
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/maybe","../../../../core/screenUtils","../../../../core/unitUtils","../../../../renderers/support/lengthUtils","./Utils","./techniques/Technique","./techniques/utils","../../../webgl/capabilities"],(function(e,t,i,s,a,n,r,l,o,u){"use strict";function v(e,t){const i=t.length;if(e<t[0].value||1===i)return t[0].size;for(let s=1;s<i;s++)if(e<t[s].value){const i=(e-t[s-1].value)/(t[s].value-t[s-1].value);return t[s-1].size+i*(t[s].size-t[s-1].size)}return t[i-1].size}let c=function(){function e(){this.symbolLevels=[],this.vvColorValues=new Float32Array(8),this.vvColors=new Float32Array(32),this.vvOpacityValues=new Float32Array(8),this.vvOpacities=new Float32Array(8),this.vvSizeMinMaxValue=new Float32Array(4),this._vvMaterialParameters={vvSizeEnabled:!1,vvColorEnabled:!1,vvRotationEnabled:!1,vvRotationType:"geographic",vvOpacityEnabled:!1},this._technique=l.Technique}var c=e.prototype;return c.getSizeVVFieldStops=function(e){const t=this._vvSizeFieldStops;switch(t.type){case"static":return t;case"level-dependent":return i.unwrapOr(t.levels[e],(()=>{let s=1/0,a=0;for(const i in t.levels){const t=parseFloat(i),n=Math.abs(e-t);n<s&&(s=n,a=t)}if(s===1/0)return{sizes:new Float32Array([0,0,0,0,0,0]),values:new Float32Array([0,0,0,0,0,0])};const n=2**((e-a)/2),r=i.unwrap(t.levels[a]),l=new Float32Array(r.values);return l[2]*=n,l[3]*=n,{sizes:i.unwrap(r.sizes),values:l}}))}},c.update=function(e){i.isSome(this._vvInfo)&&this._updateVisualVariables(this._vvInfo.vvRanges,e)},c.setInfo=function(e,t,i){this._updateEffects(i),this._vvInfo=t,this._technique=o.getTechniqueFromRenderer(e),this.rendererSchema=this._technique.createOrUpdateRendererSchema(this.rendererSchema,e)},c.getVariation=function(){return{...this._technique.getVariation(this.rendererSchema),outsideLabelsVisible:this.outsideLabelsVisible,supportsTextureFloat:u.getWebGLCapabilities("2d").supportsTextureFloat}},c.getVariationHash=function(){return this._technique.getVariationHash(this.rendererSchema)<<1|(this.outsideLabelsVisible?1:0)},c._updateEffects=function(e){i.isSome(e)?this.outsideLabelsVisible=e.excludedLabelsVisible:this.outsideLabelsVisible=!1},c._updateVisualVariables=function(e,t){const i=this._vvMaterialParameters;if(i.vvOpacityEnabled=!1,i.vvSizeEnabled=!1,i.vvColorEnabled=!1,i.vvRotationEnabled=!1,!e)return;const l=e.size;if(l){if(i.vvSizeEnabled=!0,l.minMaxValue){const e=l.minMaxValue;let i,a;if(r.isDefined(e.minSize)&&r.isDefined(e.maxSize))if(r.isNumber(e.minSize)&&r.isNumber(e.maxSize))i=s.pt2px(e.minSize),a=s.pt2px(e.maxSize);else{const n=t.scale;i=s.pt2px(v(n,e.minSize.stops)),a=s.pt2px(v(n,e.maxSize.stops))}this.vvSizeMinMaxValue.set([e.minDataValue,e.maxDataValue,i,a])}if(l.scaleStops&&(this.vvSizeScaleStopsValue=s.pt2px(v(t.scale,l.scaleStops.stops))),l.unitValue){const e=a.getMetersPerUnitForSR(t.spatialReference)/n.meterIn[l.unitValue.unit];this.vvSizeUnitValueToPixelsRatio=e/t.resolution}l.fieldStops&&(this._vvSizeFieldStops=l.fieldStops)}const o=e.color;o&&(i.vvColorEnabled=!0,this.vvColorValues.set(o.values),this.vvColors.set(o.colors));const u=e.opacity;u&&(i.vvOpacityEnabled=!0,this.vvOpacityValues.set(u.values),this.vvOpacities.set(u.opacities));const c=e.rotation;c&&(i.vvRotationEnabled=!0,i.vvRotationType=c.type)},t._createClass(e,[{key:"vvMaterialParameters",get:function(){return this._vvMaterialParameters}}]),e}();e.WGLRendererInfo=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
