/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import e from"../../../../../geometry/Point.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{project as n}from"../../../../../layers/graphics/data/projectionSupport.js";import{parseAnnotationGraphic as r}from"./annotationGraphic.js";function o({scale:e,translate:t},n){return(n-t[0])/e[0]}function i({scale:e,translate:t},n){return(n-t[1])/e[1]}function s(r,p,c,f){if("custom-point"===r.type||"point"===r.type){const{x:s,y:u}=r,a=n(new e({x:s,y:u,spatialReference:p}),p,c);return new t([1],[o(f,a.x),i(f,a.y)])}if("custom-two-point"===r.type){const[s,u]=r.from,a=n(new e({x:s,y:u,spatialReference:p}),p,c),[y,l]=r.to,m=n(new e({x:y,y:l,spatialReference:p}),p,c);return new t([2],[o(f,a.x),i(f,a.y),o(f,m.x),i(f,m.y)])}if("custom-multipoint"===r.type){const s=r.points.map(([t,r])=>n(new e({x:t,y:r,spatialReference:p}),p,c)),u=s.map(({x:e,y:t})=>[o(f,e),i(f,t)]).flat();return new t([s.length],u)}if("geometry-bag"===r.type){let e=[],n=[],o=!0;for(const t of r.geometries){o||(e.push(2),n.push(0,0,1,1)),o=!1;const r=s(t,p,c,f);r&&(e=[...e,...r.lengths],n=[...n,...r.coords])}if(0===e.length||0===n.length)return;return new t(e,n)}if("polyline"===r.type){const[s,u]=r.paths[0][0],a=n(new e({x:s,y:u,spatialReference:p}),p,c),[y,l]=r.paths[0][1],m=n(new e({x:y,y:l,spatialReference:p}),p,c);return new t([2],[o(f,a.x),i(f,a.y),o(f,m.x),i(f,m.y)])}throw new Error("Unsupported geometry type!")}function p(e){return r(e)}function c(e,...t){const n={};for(const r of t)n[r]=e[r];return n}function f(e,t){const n=e.indexOf(t);if(-1===n)return null;return e[n+1]}function u(e){const{propertySetItems:t}=e.extensionProperties,n=f(t,"ReferenceScale");return parseInt(n,10)}function a(e){const{propertySetItems:t}=e.extensionProperties,n=f(t,"SymbolCollection");if(!n)return[];return JSON.parse(n)}function y(e){const{propertySetItems:t}=e.extensionProperties,n=f(t,"StyleCollection");if(!n)return[];return JSON.parse(n)}function l(e,t){const n=e.toLowerCase();for(const r in t){if(n===r.toLowerCase())return r}return e}function m(e,t){return t[l(e,t)]}function x(e,t,n){n[l(e,n)]=t}export{m as getAttributeValue,u as getReferenceScale,y as getStyleCollection,a as getSymbolCollection,p as parseElement,c as pick,o as quantizeXf,i as quantizeYf,s as reprojectAndQuantize,x as setAttributeValue};
