/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../Graphic","../../core/has","../../core/lang","../../core/maybe","../../core/typedArrayUtil","../../geometry/support/jsonUtils","./dehydratedFeatures"],(function(e,n,t,r,a,s,i,o){"use strict";function l(e){return"declaredClass"in e}function c(e){return"declaredClass"in e}function u(e){return"declaredClass"in e}function m(e,t){if(!e)return null;if(u(e))return e;const a=new n({layer:t,sourceLayer:t});return a.visible=e.visible,a.symbol=r.clone(e.symbol),a.attributes=r.clone(e.attributes),a.geometry=h(e.geometry),a}function h(e){return a.isNone(e)?null:l(e)?e:i.fromJSON(y(e))}function y(e){const n=e.spatialReference.toJSON();switch(e.type){case"point":{const{x:t,y:r,z:a,m:s}=e;return{x:t,y:r,z:a,m:s,spatialReference:n}}case"polygon":{const{rings:t,hasZ:r,hasM:a}=e;return{rings:f(t),hasZ:r,hasM:a,spatialReference:n}}case"polyline":{const{paths:t,hasZ:r,hasM:a}=e;return{paths:f(t),hasZ:r,hasM:a,spatialReference:n}}case"extent":{const{xmin:t,xmax:r,ymin:a,ymax:s,zmin:i,zmax:o,mmin:l,mmax:c,hasZ:u,hasM:m}=e;return{xmin:t,xmax:r,ymin:a,ymax:s,zmin:i,zmax:o,mmin:l,mmax:c,hasZ:u,hasM:m,spatialReference:n}}case"multipoint":{const{points:t,hasZ:r,hasM:a}=e;return{points:x(t)?p(t):t,hasZ:r,hasM:a,spatialReference:n}}default:return}}function f(e){return d(e)?e.map((e=>p(e))):e}function p(e){return e.map((e=>s.toArray(e)))}function d(e){for(const n of e)if(0!==n.length)return x(n);return!1}function x(e){return e.length&&(s.isFloat32Array(e[0])||s.isFloat64Array(e[0]))}function M(e,n){if(!e)return null;let t;if(c(e)){if(null==n)return e.clone();if(c(n))return n.copy(e)}return null!=n?(t=n,t.x=e.x,t.y=e.y,t.spatialReference=e.spatialReference,e.hasZ?(t.z=e.z,t.hasZ=e.hasZ):(t.z=null,t.hasZ=!1),e.hasM?(t.m=e.m,t.hasM=!0):(t.m=null,t.hasM=!1)):(t=o.makeDehydratedPoint(e.x,e.y,e.z,e.spatialReference),e.hasM&&(t.m=e.m,t.hasM=!0)),t}e.clonePoint=M,e.hydrateGeometry=h,e.hydrateGraphic=m,e.isHydratedGeometry=l,e.isHydratedGraphic=u,e.isHydratedPoint=c,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
