/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.25/esri/copyright.txt for details. */ import{_ as o}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import{ClonableMixin as r}from"../../core/Clonable.js";import e from"../../core/Collection.js";import{referenceSetter as s}from"../../core/collectionUtils.js";import{JSONSupport as i}from"../../core/JSONSupport.js";import{clamp as p,lerp as n}from"../../core/mathUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import a from"./VoxelColorStop.js";import h from"./VoxelOpacityStop.js";import f from"./VoxelRangeFilter.js";var u;!function(o){o[o.Color=1]="Color",o[o.Alpha=2]="Alpha",o[o.Both=3]="Both"}(u||(u={}));let y=class extends(r(i)){constructor(o){super(o),this.interpolation=null,this.stretchRange=null,this.rangeFilter=null,this._colorMapSize=256,this.colorStops=new(e.ofType(a)),this.opacityStops=new(e.ofType(h))}set colorStops(o){this._set("colorStops",s(o,this._get("colorStops"),e.ofType(a)))}set opacityStops(o){this._set("opacityStops",s(o,this._get("opacityStops"),e.ofType(h)))}getPreviousNext(o,t,r){let e=o;for(;--e>0&&t[e].type!==r&&t[e].type!==u.Both;);let s=o;const i=t.length;for(;++so.position{r.color[e]=Math.round(n(t[e],p[e],o))}))}else["r","g","b"].forEach(-1!==s?o=>{r.color[o]=e[s][o]}:o=>{r.color[o]=e[i][o]})}}for(const t of e)r.push({color:t.color,position:t.position})}r[0].position=0,r[r.length-1].position=1;let i=0,l=1;for(let c=0;cr[l].position;)i=l++;const s=(e-r[i].position)/(r[l].position-r[i].position),a=r[i].color,h=r[l].color,f=new t;["r","g","b"].forEach((o=>{f[o]=Math.round(n(a[o],h[o],s))})),f.a=p(1-n(a.a,h.a,s)/255,0,1),o.push(f)}return o}getColorForContinuousDataValue(o,t){const r=this.rasterizedTransferFunction;if(this.colorStops.length<2||!Array.isArray(this.stretchRange)||this.stretchRange.length<2||r.length<256)return null;let e=this.stretchRange[0],s=this.stretchRange[1];if(e>s){const o=e;e=s,s=o}o=p(o,e,s);const i=r[Math.round((o-e)/(s-e)*(this._colorMapSize-1))].clone();return t||(i.a=1),i}};o([l({type:["linear","nearest"],json:{write:!0}})],y.prototype,"interpolation",void 0),o([l({type:[Number],json:{write:{enabled:!0,isRequired:!0}}})],y.prototype,"stretchRange",void 0),o([l({type:e.ofType(a),json:{write:{enabled:!0,overridePolicy(){return{enabled:!!this.colorStops&&this.colorStops.length>0}}}}})],y.prototype,"colorStops",null),o([l({type:e.ofType(h),json:{read:{source:"alphaStops"},write:{enabled:!0,target:"alphaStops",overridePolicy(){return{enabled:!!this.opacityStops&&this.opacityStops.length>0}}}}})],y.prototype,"opacityStops",null),o([l({type:f,json:{write:!0}})],y.prototype,"rangeFilter",void 0),o([l({type:[t],clonable:!1,json:{read:!1}})],y.prototype,"rasterizedTransferFunction",null),y=o([c("esri.layers.voxel.VoxelTransferFunctionStyle")],y);const g=y;export{g as default};