/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/Collection","../../core/JSONSupport","../../core/Warning","../../core/Logger","../../core/accessorSupport/ensureType","../../core/arrayUtils","../../core/has","../../core/accessorSupport/set","../../core/accessorSupport/decorators/subclass","../../geometry/Polygon","../../geometry/projection"],(function(e,t,r,o,n,s,i,c,a,l,u,p,f){"use strict";var h;let y=h=function(t){function r(e){return t.call(this,e)||this}e._inheritsLoose(r,t);var o=r.prototype;return o.clone=function(){return new h(this.items.map((e=>e.clone())))},o.write=function(e,t){return this.toJSON(t)},o.toJSON=function(e){var t;const r=null==e||null==(t=e.layer)?void 0:t.spatialReference;return r?this.toArray().map((t=>{if(!r.equals(t.spatialReference)){if(!f.canProjectWithoutEngine(t.spatialReference,r))return e&&e.messages&&e.messages.push(new n("scenefilter:unsupported","Scene filters with incompatible spatial references are not supported",{modification:this,spatialReference:e.layer.spatialReference,context:e})),null;const o=new p;f.projectPolygon(t,o,r),t=o}const o=t.toJSON(e);return delete o.spatialReference,o})).filter((e=>null!=e)):(null!=e&&e.messages&&e.messages.push(new n("scenefilter:unsupported","Writing Scene filters without context layer is not supported",{modification:this,spatialReference:e.layer.spatialReference,context:e})),this.toArray().map((t=>t.toJSON(e))))},r.fromJSON=function(e,t){const r=new h;return e.forEach((e=>r.add(p.fromJSON(e,t)))),r},r}(o.JSONSupportMixin(r.ofType(p)));y=h=t.__decorate([u.subclass("esri.layers.support.PolygonCollection")],y);return y}));
