/*
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","../../Color","../../renderers/ClassBreaksRenderer","../../renderers/DictionaryRenderer","../../renderers/DotDensityRenderer","../../renderers/HeatmapRenderer","../../renderers/PieChartRenderer","../../renderers/Renderer","../../renderers/SimpleRenderer","../../renderers/UniqueValueRenderer","../../renderers/support/jsonUtils","../../core/Error","../../core/maybe","../../renderers/support/HeatmapColorStop","../../renderers/support/heatmapUtils","./support/utils","../statistics/heatmapStatistics","../support/utils","../support/adapters/support/layerUtils","../symbology/heatmap"],(function(e,r,a,s,t,n,i,l,o,p,u,d,m,c,y,f,h,b,T,w,g){"use strict";const R=.01;function S(e){return L.apply(this,arguments)}function L(){return(L=r._asyncToGenerator((function*(e){if(!(e&&e.layer&&e.view))throw new m("heatmap-renderer:missing-parameters","'layer' and 'view' parameters are required");const{blurRadius:r,radius:a,minRatio:s,maxRatio:t,fadeToTransparent:n}=e,i={...e};i.radius=null==a?null==r?18:f.gaussianBlurRadiusPxToKernelDensityRadiusPt(r):a,i.minRatio=null==s?.01:s,i.maxRatio=null==t?1:t,i.fadeToTransparent=null==n||n;const l=[w.LayerType.CSVLayer,w.LayerType.FeatureLayer,w.LayerType.OGCFeatureLayer,w.LayerType.GeoJSONLayer,w.LayerType.WFSLayer],o=w.createLayerAdapter(i.layer,l);if(i.layer=o,!o)throw new m("heatmap-renderer:invalid-parameters","'layer' must be one of these types: "+w.getLayerTypeLabels(l).join(", "));const p=c.isSome(i.signal)?{signal:i.signal}:null;yield o.load(p);const u=yield T.getFieldsList({field:i.field}),d=h.verifyBasicFieldValidity(o,u,"heatmap-renderer:invalid-parameters");if(d)throw d;return i}))).apply(this,arguments)}function v(e){return I.apply(this,arguments)}function I(){return(I=r._asyncToGenerator((function*(e){let r=e.scheme,a=null,s=null;const t=yield h.getBasemapInfo(e.basemap,e.view);if(a=c.isSome(t.basemapId)?t.basemapId:null,s=c.isSome(t.basemapTheme)?t.basemapTheme:null,r)return{scheme:g.cloneScheme(r),basemapId:a,basemapTheme:s};const n=g.getSchemes({basemap:a,basemapTheme:s});return n&&(r=n.primaryScheme,a=n.basemapId,s=n.basemapTheme),{scheme:r,basemapId:a,basemapTheme:s}}))).apply(this,arguments)}function x(e,r){return C.apply(this,arguments)}function C(){return(C=r._asyncToGenerator((function*(e,r){const{fieldOffset:s}=e,{field:t,basemap:n,radius:l,minRatio:o,maxRatio:p,fadeToTransparent:u,heatmapScheme:d,view:m}=r,{scheme:c,basemapId:f,basemapTheme:b}=yield v({basemap:n,scheme:d,view:m}),T=c.colors,w=T.length,S=!e.count,L=S?[0,.04]:[e.min,e.max],I=(p-o)/(w-1),x=T[0],C=[new y({ratio:0,color:new a([x.r,x.g,x.b,0])}),new y({ratio:R,color:new a([x.r,x.g,x.b,0])}),new y({ratio:u?o:R,color:x})];h.createColors(T,w).forEach(((e,r)=>{C.push(new y({ratio:o+I*r,color:e}))}));const O=new i({radius:l,colorStops:C,field:t,minDensity:L[0],maxDensity:L[1]});return null!=s&&(O.fieldOffset=s),{renderer:O,statistics:e,defaultValuesUsed:S,scheme:g.cloneScheme(c),basemapId:f,basemapTheme:b}}))).apply(this,arguments)}function O(e){return _.apply(this,arguments)}function _(){return(_=r._asyncToGenerator((function*(e){const r=yield S(e);return x(r.statistics?r.statistics:yield b({layer:r.layer,field:r.field,fieldOffset:r.fieldOffset,radius:r.radius,view:r.view,signal:r.signal}),r)}))).apply(this,arguments)}e.createRenderer=O,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
