/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../assets","../../Color","../../request","../../core/ItemCache","../../core/screenUtils","./cimSymbolUtils"],(function(e,t,n,r,i,l,o){"use strict";const s="picture-fill",a="simple-fill",c="simple-line",u="simple-marker",p="text",d="cim",g={left:"start",center:"middle",right:"end",justify:"start"},m={top:"text-before-edge",middle:"central",baseline:"alphabetic",bottom:"text-after-edge"},f=new i(1e3);function h(e){let t=e.horizontalAlignment;return t=t&&g[t.toLowerCase()]||"middle",t}function y(e){const t=e.verticalAlignment;return t&&m[t.toLowerCase()]||"alphabetic"}function b(e){return"bottom"===e.verticalAlignment?"super":null}function x(e){const n=e.style;let r=null;if(e)switch(e.type){case u:"cross"!==n&&"x"!==n&&(r=e.color);break;case a:"solid"===n?r=e.color:"none"!==n&&(r={type:"pattern",x:0,y:0,src:t.getAssetUrl(`esri/symbols/patterns/${n}.png`),width:5,height:5});break;case s:r={type:"pattern",src:e.url,width:l.pt2px(e.width)*e.xscale,height:l.pt2px(e.height)*e.yscale,x:l.pt2px(e.xoffset),y:l.pt2px(e.yoffset)};break;case p:r=e.color;break;case d:r=o.getCIMSymbolColor(e)}return r}function w(e,t){const n=e+"-"+t;return void 0!==f.get(n)?Promise.resolve(f.get(n)):r(e,{responseType:"image"}).then((e=>{const r=e.data,i=r.naturalWidth,l=r.naturalHeight,o=document.createElement("canvas");o.width=i,o.height=l;const s=o.getContext("2d");s.fillStyle=t,s.fillRect(0,0,i,l),s.globalCompositeOperation="destination-in",s.drawImage(r,0,0);const a=o.toDataURL();return f.put(n,a),a}))}function S(e){if(!e)return null;let t;switch(e.type){case a:case s:case u:t=S(e.outline);break;case c:{const n=l.pt2px(e.width);"none"!==e.style&&0!==n&&(t={color:e.color,style:C(e.style),width:n,cap:e.cap,join:"miter"===e.join?l.pt2px(e.miterLimit):e.join});break}default:t=null}return t}const C=(()=>{const e={};return t=>{if(e[t])return e[t];const n=t.replace(/-/g,"");return e[t]=n,n}})(),k=new n([128,128,128]);e.defaultThematicColor=k,e.dekebabifyLineStyle=C,e.getFill=x,e.getPatternUrlWithColor=w,e.getSVGAlign=h,e.getSVGBaseline=y,e.getSVGBaselineShift=b,e.getStroke=S,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
