/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../../../chunks/_rollupPluginBabelHelpers","../../../../../../core/screenUtils","../../color","../../definitions","../../GeometryUtils","../../number","../../materialKey/MaterialKey","./util","./WGLBaseFillTemplate","./WGLMeshTemplate"],(function(t,e,l,i,n,o,r,_,a,s){"use strict";const u=128;return function(a){function s(t,e,l,n,_,s,u,O,I,c,f,T,M,A,E,p){var h;(h=a.call(this)||this)._effects=A;const d=r.FillMaterialKey.load(t);return e&&(d.sdf=e.sdf,d.pattern=!0,d.textureBinding=e.textureBinding),h.fillColor=l,h.tl=n,h.br=_,h.aux2_1=o.i1616to32(s,u),h.aux2_2=o.i1616to32(O,I),h.aux3=o.i8888to32(c,f,T,0),h._bitset=M,h._minMaxZoom=o.i1616to32(Math.round(E*i.MIN_MAX_ZOOM_PRECISION_FACTOR),Math.round(p*i.MIN_MAX_ZOOM_PRECISION_FACTOR)),h._materialKey=d.data,h}return t._inheritsLoose(s,a),s.fromCIMFill=function(t,r,a){const O=t.color,I=O&&l.premultiplyAlphaRGBA(O)||0,c=t.materialKey,[f,T]=_.getMinMaxZoom(t.scaleInfo,a),M=(t.colorLocked?i.BITSET_GENERIC_LOCK_COLOR:0)|(t.applyRandomOffset?i.BITSET_FILL_RANDOM_PATTERN_OFFSET:0)|(t.sampleAlphaOnly?i.BITSET_GENERIC_CONSIDER_ALPHA_ONLY:0);if(!r)return new s(c,null,I,0,0,0,0,0,0,0,0,0,M,t.effects,f,T);const{rect:A,width:E,height:p}=r,h=t.scaleX||1,d=A.x+i.SPRITE_PADDING,L=A.y+i.SPRITE_PADDING,R=d+E,m=L+p,y=t.height,N=h*y;let D=Math.round(y);D<=0&&(D=m-L);let C=Math.round(N);C<=0&&(C=R-d);const P=e.pt2px(t.offsetX||0),x=e.pt2px(-t.offsetY||0);return new s(c,r,I,o.i1616to32(d,L),o.i1616to32(R,m),C,D,P,x,u,u,n.degToByte(t.angle),M,t.effects,f,T)},s.fromSimpleFill=function(t,e,n=!1){const{color:r}=t,a=r&&"esriSFSNull"!==t.style&&l.premultiplyAlphaRGBAArray(r)||0,O=n?i.BITSET_GENERIC_LOCK_COLOR:0,I=t.materialKey;let c;if(e){const{rect:t,width:l,height:n}=e,r=t.x+i.SPRITE_PADDING,f=t.y+i.SPRITE_PADDING,T=r+l,M=f+n;c=new s(I,e,a,o.i1616to32(r,f),o.i1616to32(T,M),l,n,0,0,u,u,0,O,null,_.DEFAULT_MIN_ZOOM,_.DEFAULT_MAX_ZOOM)}else c=new s(I,null,a,0,0,0,0,0,0,0,0,0,O,null,_.DEFAULT_MIN_ZOOM,_.DEFAULT_MAX_ZOOM);return c._maybeAddLineTemplate(t),c},s.fromPictureFill=function(t,l,n=!1){const r=i.PICTURE_FILL_COLOR,{rect:a,width:O,height:I}=l,c=a.x+i.SPRITE_PADDING,f=a.y+i.SPRITE_PADDING,T=c+O,M=f+I,A=o.i1616to32(c,f),E=o.i1616to32(T,M),p=Math.round(e.pt2px(t.width)),h=Math.round(e.pt2px(t.height)),d=e.pt2px(t.xoffset),L=e.pt2px(-t.yoffset),R=t.materialKey,m=n?i.BITSET_GENERIC_LOCK_COLOR:0,y=new s(R,l,r,A,E,p,h,d,L,u*t.xscale,u*t.yscale,0,m,null,_.DEFAULT_MIN_ZOOM,_.DEFAULT_MAX_ZOOM);return y._maybeAddLineTemplate(t),y},s}(a(s))}));
