import e from"@arcgis/core/core/Collection";import o from"@arcgis/core/layers/FeatureLayer";import{toFeature as r}from"../data/Feature.js";import{FeatureSet as t}from"../data/FeatureSet.js";import{toCsv as a,csvToFeatureSet as s,toXLSX as i,xlsxToFeatureSet as n,toShapefile as c,shapefileToFeatureSet as l}from"../data/convert.js";import{checkArg as u}from"../utilities/checkArg.js";import{FeatureCollectionLayerExtension as f}from"./FeatureCollectionLayerExtension.js";export{GeometryFormat}from"../data/convert.js";export async function toCsv(o,s){u("featureCollection",o).isNotMissing(),u("featureCollection.layer",o.layer).isNotMissing(),u("featureCollection.layer.source",o.layer.source).satisfies((o=>e.isCollection(o)));const i=o.layer.source.map((e=>r(e,void 0))).toArray(),n=new t({features:i});return a(n,s)}export async function csvToFeatureCollection(e,r){u("csvData",e).isNotMissing();const t=await s(e,r),a=Array.from(t).map((e=>e.toGraphic())),i=new o({source:a});return new f({layer:i})}export async function toXLSX(o,a){u("featureCollection",o).isNotMissing(),u("featureCollection.layer",o.layer).isNotMissing(),u("featureCollection.layer.source",o.layer.source).satisfies((o=>e.isCollection(o)));const s=o.layer.source.map((e=>r(e,void 0))).toArray(),n=new t({features:s});return i(n,a)}export async function xlsxToFeatureCollection(e,r){u("xlsxData",e).isNotMissing();const t=await n(e,r),a=Array.from(t).map((e=>e.toGraphic())),s=new o({source:a});return new f({layer:s})}export async function toShapefile(o,a){u("featureCollection",o).isNotMissing(),u("featureCollection.layer",o.layer).isNotMissing(),u("featureCollection.layer.source",o.layer.source).satisfies((o=>e.isCollection(o)));const s=o.layer.source.map((e=>r(e,void 0))).toArray(),i=new t({features:s});return c(i,a)}export async function shapefileToFeatureCollection(e,r){u("shapefileData",e).isNotMissing();const t=await l(e,r),a=Array.from(t).map((e=>e.toGraphic())),s=new o({source:a});return new f({layer:s})}