/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as t}from"tslib";import{subclass as e}from"../../../../core/accessorSupport/decorators.js";import{createFlowFieldFromData as s,traceFlowPaths as a}from"../../../2d/engine/flow/dataUtils.js";import{createFlowFieldFromDataTiled as i,valuesPerFlowVertex as r}from"./loadUtils.js";let o=class{constructor(){this._tileData=new Map}async generateStreamlines(t){const{flowData:e,flowExtentInfo:a,needsMagnitude:i,simulationSettings:r,startPositions:o}=t,n=l(s(r,e),r,a.modelSize,i,o);return{result:{streamlines:n},transferList:n?.map(t=>t.vertices.buffer)}}async generateTiledStreamlines(t){const{flowDataTiles:e,flowExtentInfo:s,needsMagnitude:a,reset:r,simulationSettings:o,startPositions:n}=t;this._updateTileData(e,r);const f=l(i(o,this._tileData,s),o,s.modelSize,a,n);return{result:{streamlines:f},transferList:f?.map(t=>t.vertices.buffer)??[]}}_updateTileData(t,e){if(e)for(const s of this._tileData.keys())t.has(s)||this._tileData.delete(s);t.forEach((t,e)=>{"delete"===t.type?this._tileData.delete(e):"on-worker"!==t.type&&"invalid"!==t.type&&this._tileData.set(e,t.data)})}};o=t([e("esri.views.3d.support.flow.FlowWorker")],o);const n=o;function l(t,e,s,i,o){if(null==t)return;const n=a(e,t,s[0],s[1],{positions:o}),l=[],f=r(i);for(const{vertices:a,stage:r}of n){const t=new Float32Array(a.length*f);for(let e=0;e<a.length;e++)t[e*f]=a[e].x,t[e*f+1]=a[e].y,t[e*f+2]=a[e].time,i&&(t[e*f+3]=a[e].speed);l.push({vertices:t,stage:r,hasMagnitude:i})}return l}export{n as default};
