/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as t,__param as e}from"tslib";import{location as o,uniform as i,input as r}from"../../GraphShaderModule.js";import{Float as l,equal as s,float as p,Vec4 as n,ifElse as a,mat3 as d,negate as m,vec2 as u,Vec2 as f,sin as y,cos as c,Vec3 as v,mod as x,mix as h,texture2D as g,greaterThan as b}from"../../graph/glsl.js";import{BaseHittestVertexInput as w,FeatureFragmentInput as j}from"./AFeatureShader.js";import{c256ToRad as O,bitsetGenericConsiderAlphaOnly as T,bitsetFillRandomPatternOffset as C}from"./constants.js";import{FillShader as F,FillVertexInput as A}from"./FillShader.js";import{LocalTileOffset as I}from"./LocalTileOffset.js";import{MosaicInfo as S}from"./MosaicInfo.js";import{getBit as z,rgba2float as M,rand as V,isNan as q}from"./utils.js";class G extends A{}t([o(5,n)],G.prototype,"tlbr",void 0),t([o(6,l)],G.prototype,"width",void 0),t([o(7,l)],G.prototype,"height",void 0),t([o(8,f)],G.prototype,"offset",void 0),t([o(9,f)],G.prototype,"scale",void 0),t([o(10,l)],G.prototype,"angle",void 0);class L extends j{}function P(t,e,o,i,r){const l=s(z(r,C),p(1)),f=M(new n(t,0));return a(l,d(i.divide(e.x),o.divide(e.y),0,m(o.divide(e.x)),i.divide(e.y),0,V(u(f,0)),V(u(0,f)),1),d(i.divide(e.x),o.divide(e.y),0,m(o.divide(e.x)),i.divide(e.y),0,0,0,1))}function Z(t,e){const o=t.view.requiredZoomFactor,i=new f(e.width,e.height),r=i.multiply(e.scale).multiply(o),s=e.angle.multiply(O),p=y(s),n=c(s),d=P(e.id,r,p,n,e.bitset),m=t.localTileOffset.getPatternOffsetAtTileOrigin(i,p,n),u=o.multiply(e.scale).multiply(e.offset.subtract(m)).divide(r),x=new v(e.pos,1),h=d.multiply(x).xy.subtract(u),g=e.tlbr.divide(t.mosaicInfo.size.xyxy);let b=z(e.bitset,T);return null!=t.visualVariableColor&&(b=a(q(t.storage.getColorValue(e.id)),new l(0),b)),{tileTextureCoord:h,tlbr:g,sampleAlphaOnly:b}}function k(t,e){const o=x(e.tileTextureCoord,new l(1)),i=h(e.tlbr.xy,e.tlbr.zw,o);let r=g(t.mosaicInfo.texture,i);return r=a(b(e.sampleAlphaOnly,new l(.5)),r.aaaa,r),e.color.multiply(r)}class B extends F{constructor(){super(...arguments),this.type="ComplexFillShader"}vertex(t,e){return{...super.vertex(t,e),...Z(this,t)}}fragment(t){const e=k(this,t);return this.getFragmentOutput(e,t,new l(0))}}t([i(S)],B.prototype,"mosaicInfo",void 0),t([i(I)],B.prototype,"localTileOffset",void 0),t([e(0,r(G)),e(1,r(w))],B.prototype,"vertex",null),t([e(0,r(L))],B.prototype,"fragment",null);export{L as ComplexFillFragmentInput,B as ComplexFillShader,G as ComplexFillVertexInput,k as getComplexFillFragmentColor,Z as getComplexFillVertexData,P as getPatternMatrix};
