/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../../chunks/_rollupPluginBabelHelpers","../../../Color","./utils"],(function(e,l,o,n,t){"use strict";const r=new n([64,64,64]);function u(e,l){const o=[],n=e.length-1;return 5===e.length?o.push(0,2,4):o.push(0,n),e.map(((e,r)=>o.includes(r)?t.createStopLabel(e,r,n,l):null))}function a(e,l,o){return s.apply(this,arguments)}function s(){return s=o._asyncToGenerator((function*(l,n,t){let r=!1,a=[],s=[];if(l.stops){const e=l.stops;a=e.map((e=>e.value)),r=e.some((e=>!!e.label)),r&&(s=e.map((e=>e.label)))}const c=a[0],p=a[a.length-1];if(null==c&&null==p)return null;const m=r?null:u(a,t),h=yield Promise.all(a.map(function(){var t=o._asyncToGenerator((function*(o,t){return{value:o,color:"opacity"===l.type?yield i(o,l,n):(yield new Promise(((l,o)=>e(["../../../renderers/visualVariables/support/visualVariableUtils"],l,o)))).getColor(l,o),label:r?s[t]:m[t]}}));return function(e,l){return t.apply(this,arguments)}}()));return h.reverse()})),s.apply(this,arguments)}function i(e,l){return c.apply(this,arguments)}function c(){return(c=o._asyncToGenerator((function*(l,o,t=r){const u=new n(t),a=(yield new Promise(((l,o)=>e(["../../../renderers/visualVariables/support/visualVariableUtils"],l,o)))).getOpacity(o,l);return null!=a&&(u.a=a),u}))).apply(this,arguments)}function p(e){let l=!1,o=[],n=[];o=e.map((e=>e.value)),l=e.some((e=>!!e.label)),l&&(n=e.map((e=>e.label)));const t=o[0],r=o[o.length-1];if(null==t&&null==r)return null;const a=l?null:u(o,!1);return o.map(((o,t)=>({value:o,color:m(o,e),label:l?n[t]:a[t]}))).reverse()}function m(e,l){const{startIndex:o,endIndex:t,weight:r}=h(e,l);if(o===t)return l[o].color;const u=n.blendColors(l[o].color,l[t].color,r);return new n(u)}function h(e,l){let o=0,n=l.length-1;return l.some(((l,t)=>e<l.value?(n=t,!0):(o=t,!1))),{startIndex:o,endIndex:n,weight:(e-l[o].value)/(l[n].value-l[o].value)}}function f(e,l){let o=[];if(e&&"multipart"===e.type)e.colorRamps.reverse().forEach(((t,r)=>{0===r?o.push({value:l.max,color:new n(t.toColor),label:"high"}):o.push({value:null,color:new n(t.toColor),label:""}),r===e.colorRamps.length-1?o.push({value:l.min,color:new n(t.fromColor),label:"low"}):o.push({value:null,color:new n(t.fromColor),label:""})}));else{let t,r;e&&"algorithmic"===e.type?(t=e.fromColor,r=e.toColor):(t=[0,0,0,1],r=[255,255,255,1]),o=[{value:l.max,color:new n(r),label:"high"},{value:l.min,color:new n(t),label:"low"}]}return o}l.getColorFromPointCloudStops=m,l.getRampStops=a,l.getRampStopsForPointCloud=p,l.getStrectchRampStops=f,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
