/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{PixelType as r}from"../../../webgl/enums.js";import{getDataTypeBytes as n}from"../../../webgl/getDataTypeBytes.js";import{VertexElementDescriptor as a}from"../../../webgl/VertexElementDescriptor.js";const s=()=>t.getLogger("esri.views.2d.engine.webgl.Utils");function o(t){switch(t){case r.UNSIGNED_BYTE:return 1;case r.UNSIGNED_SHORT_4_4_4_4:return 2;case r.FLOAT:return 4;default:return void s().error(new e("webgl-utils",`Unable to handle type ${t}`))}}function i(t){switch(t){case r.UNSIGNED_BYTE:return Uint8Array;case r.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case r.FLOAT:return Float32Array;default:return void s().error(new e("webgl-utils",`Unable to handle type ${t}`))}}function c(e){let t=0;const r=e.map(e=>{const r=new a(e.name,e.count,e.type,t,0,e.normalized||!1);return t+=e.count*n(e.type),r});return r.forEach(e=>e.stride=t),r}const l=e=>{const t=new Map;for(const r of e)t.set(r.name,r.location);return t};function u(e){return e[0]?.stride??0}const m=new Map,$=(e,t)=>{if(!m.has(e)){const r={bufferLayout:c(t),attributes:l(t)};m.set(e,r)}return m.get(e)},f=e=>e.includes("data:image/svg+xml");function d(e){const t=[];for(let r=0;r<e.length;r++)t.push(e.charCodeAt(r));return t}const g=e=>!!e&&(e=e.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(e)&&/[\dz]$/i.test(e)&&e.length>4));function p(e){if(null==e)return"";const{type:t}=e;switch(t){case"CIMMarkerPlacementAlongLineRandomSize":return`${t}-${e.seed}-${e.randomization}`;case"CIMMarkerPlacementAlongLineVariableSize":return`${t}-${e.maxRandomOffset}-${e.numberOfSizes}-${e.seed}-${e.variationMethod}`;case"CIMMarkerPlacementAtExtremities":return`${t}-${e.extremityPlacement}-${e.offsetAlongLine}`;case"CIMMarkerPlacementAtRatioPositions":return`${t}-${e.beginPosition}-${e.endPosition}-${e.flipFirst}-${JSON.stringify(e.positionArray)}`;case"CIMMarkerPlacementAtMeasuredUnits":return`${t}-${e.interval}-${e.skipMarkerRate}-${e.placeAtExtremities}`;case"CIMMarkerPlacementInsidePolygon":return`${t}-${e.stepX}-${e.stepY}-${e.randomness}-${e.gridType}-${e.seed}-${e.shiftOddRows}`;case"CIMMarkerPlacementOnLine":return`${t}-${e.relativeTo}-${e.startPointOffset}`;case"CIMMarkerPlacementOnVertices":return`${t}-${e.placeOnControlPoints}-${e.placeOnEndPoints}-${e.placeOnRegularVertices}`;case"CIMMarkerPlacementPolygonCenter":return`${t}-${e.method}`;default:return`${t}`}}export{d as charCodes,c as createAttributeLayout,$ as createProgramDescriptor,p as getCIMMarkerPlacementHash,i as getPixelArrayCtor,o as getPixelBytes,u as getStrideFromLayout,f as isSVGImage,g as isValidSVG};
