/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{packInterleavedBuffer as e}from"../../../support/buffer/workerHelper.js";import{EdgeInputBufferLayout as t}from"./bufferLayouts.js";import{extractEdges as n}from"./edgePreprocessing.js";import{extract as s,extractEdgeInformation as r,extractComponentsEdgeLocationsLayout as i,extractEdgeLocationsLayout as a}from"./edgeProcessing.js";class o{async extract(e){const t=c(e),n=s(t),r=[t.data.buffer];return{result:u(n,r),transferList:r}}async extractComponentsEdgeLocations(t){const s=c(t),i=r(s.data,s.skipDeduplicate,s.indices,s.indicesLength),a=n(i,p),o=[];return{result:e(a.regular.instancesData,o),transferList:o}}async extractEdgeLocations(t){const s=c(t),i=r(s.data,s.skipDeduplicate,s.indices,s.indicesLength),a=n(i,f),o=[];return{result:e(a.regular.instancesData,o),transferList:o}}}function c(e){return{data:t.createView(e.dataBuffer),indices:"Uint32Array"===e.indicesType?new Uint32Array(e.indices):"Uint16Array"===e.indicesType?new Uint16Array(e.indices):"Uint8Array"===e.indicesType?new Uint8Array(e.indices):e.indices,indicesLength:e.indicesLength,writerSettings:e.writerSettings,skipDeduplicate:e.skipDeduplicate}}function u(t,n){n.push(t.regular.lodInfo.lengths.buffer),n.push(t.silhouette.lodInfo.lengths.buffer);return{regular:{instancesData:e(t.regular.instancesData,n),lodInfo:{lengths:t.regular.lodInfo.lengths.buffer}},silhouette:{instancesData:e(t.silhouette.instancesData,n),lodInfo:{lengths:t.silhouette.lodInfo.lengths.buffer}},averageEdgeLength:t.averageEdgeLength}}class l{allocate(e){return a.createBuffer(e)}trim(e,t){return e.slice(0,t)}write(e,t,n){e.position0.setVec(t,n.position0),e.position1.setVec(t,n.position1)}}class d{allocate(e){return i.createBuffer(e)}trim(e,t){return e.slice(0,t)}write(e,t,n){e.position0.setVec(t,n.position0),e.position1.setVec(t,n.position1),e.componentIndex.set(t,n.componentIndex)}}const f=new l,p=new d;export{o as default};
