/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import{JSONSupport as r}from"../../core/JSONSupport.js";import{clone as t}from"../../core/lang.js";import o from"../../core/Warning.js";import{property as s,subclass as i}from"../../core/accessorSupport/decorators.js";import{persistable as a}from"../../core/accessorSupport/decorators/persistable.js";import p from"../../geometry/Polygon.js";import{canProjectWithoutEngine as c,projectPolygon as n}from"../../geometry/projectionUtils.js";import{isInitialized as l,switchMeshModificationPolygonVCSSync as m}from"../../views/3d/layers/Lyr3DWorker.js";import{toWasmModification as f,fromWasmModificationInSave as y}from"../../views/3d/layers/SceneLayerWorkerHandle.js";import{writer as d}from"../../core/accessorSupport/decorators/writer.js";var u;let g=u=class extends r{constructor(e){super(e),this.geometry=null,this.type="clip"}writeGeometry(e,r,t,s){if(s.layer?.spatialReference&&115700===s.layer?.spatialReference.vcsWkid){let e=!0;if(l()){const o=f(null,[this],s.layer?.spatialReference),i=m({modifications:o,inVCS:5773});if(i.success&&i.modifications){const o=y(i.modifications,this);o&&(r[t]=o.toJSON(s),e=!1)}}if(e)return void(s?.messages&&s.messages.push(new o("scenemodification:unsupported","Scene modifications with incompatible spatial references are not supported",{modification:this,spatialReference:s.layer.spatialReference,context:s})))}else if(s.layer?.spatialReference&&!s.layer.spatialReference.equals(this.geometry.spatialReference)){if(!c(e.spatialReference,s.layer.spatialReference))return void(s?.messages&&s.messages.push(new o("scenemodification:unsupported","Scene modifications with incompatible spatial references are not supported",{modification:this,spatialReference:s.layer.spatialReference,context:s})));const i=new p;n(e,i,s.layer.spatialReference),r[t]=i.toJSON(s)}else r[t]=e.toJSON(s)}clone(){return new u({geometry:t(this.geometry),type:this.type})}};e([s({type:p}),a()],g.prototype,"geometry",void 0),e([d(["web-scene","portal-item"],"geometry")],g.prototype,"writeGeometry",null),e([s({type:["clip","mask","replace"],nonNullable:!0}),a()],g.prototype,"type",void 0),g=u=e([i("esri.layers.support.SceneModification")],g);export{g as default};
