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