/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../geometry","../../../core/Error","../../../geometry/Multipoint","../../../geometry/Point","../../../geometry/Polygon","../../../geometry/Polyline","../../../geometry/Geometry"],(function(e,t,r,o,n,a,s,i){"use strict";function y(e,t){if(e instanceof o)return f(e,t);if(e instanceof n)return g(e,t);if(e instanceof s||e instanceof a)return m(e,t);throw new r("knowledge-graph:unsupported-geometry","Only Point, Multipoint, Polyline, and Polygon geometry are supported by ArcGIS Knowledge",{geometry:e})}function c(e,t){const r=new t.ArrayValue;return e.forEach((e=>{r.add_value(u(e,t))})),r}function l(e,t){const r=new t.ObjectValue;for(const[o,n]of Object.entries(e))r.set_key_value(o,u(n,t));return r}function u(e,t){if(null==e)return"";if("object"!=typeof e)return e;if(e instanceof Date)return e;if(e instanceof i)return y(e,t);if(Array.isArray(e)){const r=new t.ArrayValue;return e.forEach((e=>{r.add_value(u(e,t))})),r}return l(e,t)}function m(e,t){const r=new t.GeometryValue;r.has_z=e.hasZ,r.has_m=e.hasM;const o=[],n=[];let i=[];e instanceof s?(r.geometry_type=t.esriGeometryType.esriGeometryPolyline,i=e.paths):e instanceof a&&(r.geometry_type=t.esriGeometryType.esriGeometryPolygon,i=e.rings);let y=0,c=0;return i.forEach((e=>{let t=0;e.forEach((e=>{t++,e.forEach((e=>{o[c]=e,c++}))})),n[y]=t,y++})),r.coords=new Float64Array(o),r.lengths=new Uint32Array(n),r}function f(e,t){const r=new t.GeometryValue;r.geometry_type=r.geometry_type=t.esriGeometryType.esriGeometryMultipoint,r.has_z=e.hasZ,r.has_m=e.hasM;const o=[],n=[];n[0]=e.points.length;let a=0;return e.points.forEach((e=>{e.forEach((e=>{o[a]=e,a++}))})),r.coords=new Float64Array(o),r.lengths=new Uint32Array(n),r}function g(e,t){const r=new t.GeometryValue;r.geometry_type=t.esriGeometryType.esriGeometryPoint,r.has_z=e.hasZ,r.has_m=e.hasM;const o=[],n=[];n[0]=1,o[0]=e.x,o[1]=e.y;let a=2;return e.hasZ&&(o[a]=e.z,a++),e.hasM&&(o[a]=e.m,a++),r.coords=new Float64Array(o),r.lengths=new Uint32Array(n),r}e.bindParamArrayToWasm=c,e.bindParamObjectToWasm=l,e.geometryToWasm=y,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
