/*
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/workers/workers","../../../chunks/vec3f64","../ray","../triangle","./ElevationSamplerWorker","../../../layers/support/ElevationSampler"],(function(e,n,t,r,o,a,l,i,u){"use strict";function s(e,n){return c.apply(this,arguments)}function c(){return(c=n._asyncToGenerator((function*(e,n){const t=yield p(),r=yield y.createIndex(e,t);return f(t),new m(e,r,n)}))).apply(this,arguments)}let m=function(e){function r(n,r,o){var a;return(a=e.call(this)||this).rindex=r,a.demResolution={min:0,max:0},a.spatialReference=n.spatialReference.clone(),a.extent=n.extent.clone(),a.noDataValue=t.isSome(o)&&o.noDataValue||0,a}return n._inheritsLoose(r,e),r.prototype.elevationAt=function(e,n){let t=Number.NEGATIVE_INFINITY;return a.fromValues([e,n,0],[0,0,-1],E),this.rindex.search({minX:e,maxX:e,minY:n,maxY:n},(e=>{l.intersectRay(e,E,N)&&N[2]>t&&(t=N[2])})),t===Number.NEGATIVE_INFINITY?this.noDataValue:t},r}(u.ElevationSamplerBase);function p(){return++d,h(),v||(v=r.open("ElevationSamplerWorker").catch((()=>null)),v)}function f(e){--d,t.isSome(e)&&0===d&&(x=setTimeout((()=>{e.close(),v=null,x=0}),I))}function h(){x&&(clearTimeout(x),x=0)}const y=new i;let d=0,v=null,x=0;const I=1e4,E=a.fromValues([0,0,0],[0,0,-1]),N=o.create();e.create=s,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
