import{__decorate}from"tslib";import{validation}from"../../Validation.js";import{MapProvider}from"./MapProvider.js";import{activate}from"../../Hooks.js";import{inline,featuresToArray}from"./tools.js";import{isArcGisApiVersion3x}from"./ArcGisApiVersion.js";let AddGraphics=class{execute(r,e,i){const a=validation.id("layerId",r.layerId,void 0),s=featuresToArray(validation.exists("features",r.features)),t=validation.boolean("removeAllFeatures",r.removeAllFeatures,!1),o=i.create();return inline(o.load(),function(){if(a){const r=o.findLayer(a);return inline(r&&r.load(),function(){return t&&r&&r.clearFeatures(),{features:(r||o).addFeatures(s,a)}})}if(isArcGisApiVersion3x){t&&o.map.graphics.clear();const e=[];return s.forEach(r=>{e.push(o.map.graphics.add(r))}),{features:e}}return t&&o.view.graphics.removeAll(),o.view.graphics.addMany(s),{features:s}})}};AddGraphics.action="gcx:wf:arcgis::AddGraphicsLayerFeatures",AddGraphics.suite="gcx:wf:builtin",AddGraphics=__decorate([activate(MapProvider)],AddGraphics);export{AddGraphics};