/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import e from"../../../../../core/pbf.js";import{fromJSON as t}from"../../../../../geometry/support/jsonUtils.js";import{base64ToArrayBuffer as a}from"../../../../../support/base64Utils.js";function r(t){const r={leader:[],anchorPoint:[],fontVariations:[]},n=a(t.toString()),i=new e(new Uint8Array(n),new DataView(n));for(;i.next();)switch(i.tag()){case 1:r.version=o(i);break;case 2:r.bloated=i.getBool();break;case 3:r.graphic=s(o(i));break;case 4:r.geometryStorageType=i.getEnum();break;case 5:r.geometry=c(o(i),r.geometryStorageType);break;case 6:r.text=o(i);break;case 7:r.bloated?i.skip():r.symbolID=i.getUInt32();break;case 8:r.textAngle=i.getDouble();break;case 9:r.xOffset=i.getDouble();break;case 10:r.yOffset=i.getDouble();break;case 11:r.horizontalAlignment=i.getEnum();break;case 12:r.verticalAlignment=i.getEnum();break;case 13:r.flipAngle=i.getDouble();break;case 14:i.skip(),r.leader=[];break;case 15:i.skip(),r.anchorPoint=[];break;case 16:r.size=i.getDouble();break;case 17:r.color=o(i);break;case 18:r.characterSpacing=i.getDouble();break;case 19:r.characterWidth=i.getDouble();break;case 20:r.wordSpacing=i.getDouble();break;case 21:r.leading=i.getDouble();break;case 22:r.fontFamilyName=o(i);break;case 23:r.fontStyleName=o(i);break;case 24:r.underline=i.getBool();break;case 25:r.callout=o(i);break;case 26:i.skip(),r.fontVariations=[];break;default:i.skip()}return r}function o(e){return n(e.getString()||"")}function n(e){return e.replaceAll(/\p{Cc}/gu,"")}function s(e){return e?JSON.parse(e):null}function i(e){if(e?.ga){const t=e?.ga?.map(e=>i(e)).filter(e=>e);return{type:"geometry-bag",geometries:t}}const a=e?.g?.points;if(a)return{type:"custom-multipoint",points:a};const r=t(e);return r&&("point"===r.type||"polyline"===r.type)?r:void 0}function c(e,t){if(!e||null==t)return;if(1===t){const t=e.split(",").map(e=>parseFloat(e));return{type:"custom-point",x:t[0],y:t[1]}}if(2===t){const t=e.split(";").map(e=>e.split(",").map(e=>parseFloat(e)));return{type:"custom-two-point",from:[t[0][0],t[0][1]],to:[t[1][0],t[1][1]]}}if(3===t){return{type:"custom-multipoint",points:e.split(";").map(e=>e.split(",").map(e=>parseFloat(e)))}}return i(JSON.parse(e))}export{c as parseAnnotationGeometry,i as parseAnnotationGeometryJson,r as parseAnnotationGraphic,s as parseAnnotationInnerGraphic};
