"use strict";(self.webpackChunkandroid_playground=self.webpackChunkandroid_playground||[]).push([["199"],{96653(e,r,o){o.d(r,{v:()=>M,I:()=>U});var t=o(82378),n=o(39305),i=o(86840);function a(e,r,o){if(e)for(let t in e){let n=r[t.toLocaleLowerCase()];if(n){let r=e[t];"header"===t&&(r=r.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),o&&n.push(`//----${o}----//`),n.push(r)}else(0,i.R)(`${t} placement hook does not exist in shader`)}}let u=/\{\{(.*?)\}\}/g;function l(e){let r={};return(e.match(u)?.map(e=>e.replace(/[{()}]/g,""))??[]).forEach(e=>{r[e]=[]}),r}function s(e,r){let o,t=/@in\s+([^;]+);/g;for(;null!==(o=t.exec(e));)r.push(o[1])}function v(e,r,o=!1){let t=[];s(r,t),e.forEach(e=>{e.header&&s(e.header,t)}),o&&t.sort();let n=t.map((e,r)=>`       @location(${r}) ${e},`).join("\n"),i=r.replace(/@in\s+[^;]+;\s*/g,"");return i.replace("{{in}}",`
${n}
`)}function f(e,r){let o,t=/@out\s+([^;]+);/g;for(;null!==(o=t.exec(e));)r.push(o[1])}function c(e,r){let o=e;for(let e in r){let t=r[e];o=t.join("\n").length?o.replace(`{{${e}}}`,`//-----${e} START-----//
${t.join("\n")}
//----${e} FINISH----//`):o.replace(`{{${e}}}`,"")}return o}let d=Object.create(null),m=new Map,x=0;function p(e,r){return r.map(e=>(m.has(e)||m.set(e,x++),m.get(e))).sort((e,r)=>e-r).join("-")+e.vertex+e.fragment}function h(e,r,o){let t=l(e),n=l(r);return o.forEach(e=>{a(e.vertex,t,e.name),a(e.fragment,n,e.name)}),{vertex:c(e,t),fragment:c(r,n)}}let g=`
    @in aPosition: vec2<f32>;
    @in aUV: vec2<f32>;

    @out @builtin(position) vPosition: vec4<f32>;
    @out vUV : vec2<f32>;
    @out vColor : vec4<f32>;

    {{header}}

    struct VSOutput {
        {{struct}}
    };

    @vertex
    fn main( {{in}} ) -> VSOutput {

        var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
        var modelMatrix = mat3x3<f32>(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        var position = aPosition;
        var uv = aUV;

        {{start}}
        
        vColor = vec4<f32>(1., 1., 1., 1.);

        {{main}}

        vUV = uv;

        var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;

        vPosition =  vec4<f32>((modelViewProjectionMatrix *  vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
       
        vColor *= globalUniforms.uWorldColorAlpha;

        {{end}}

        {{return}}
    };
`,b=`
    @in vUV : vec2<f32>;
    @in vColor : vec4<f32>;
   
    {{header}}

    @fragment
    fn main(
        {{in}}
      ) -> @location(0) vec4<f32> {
        
        {{start}}

        var outColor:vec4<f32>;
      
        {{main}}
        
        return outColor * vColor;
      };
`,C=`
    in vec2 aPosition;
    in vec2 aUV;

    out vec4 vColor;
    out vec2 vUV;

    {{header}}

    void main(void){

        mat3 worldTransformMatrix = uWorldTransformMatrix;
        mat3 modelMatrix = mat3(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        vec2 position = aPosition;
        vec2 uv = aUV;
        
        {{start}}
        
        vColor = vec4(1.);
        
        {{main}}
        
        vUV = uv;
        
        mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;

        gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);

        vColor *= uWorldColorAlpha;

        {{end}}
    }
`,P=`
   
    in vec4 vColor;
    in vec2 vUV;

    out vec4 finalColor;

    {{header}}

    void main(void) {
        
        {{start}}

        vec4 outColor;
      
        {{main}}
        
        finalColor = outColor * vColor;
    }
`,T={name:"global-uniforms-bit",vertex:{header:`
        struct GlobalUniforms {
            uProjectionMatrix:mat3x3<f32>,
            uWorldTransformMatrix:mat3x3<f32>,
            uWorldColorAlpha: vec4<f32>,
            uResolution: vec2<f32>,
        }

        @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
        `}},$={name:"global-uniforms-bit",vertex:{header:`
          uniform mat3 uProjectionMatrix;
          uniform mat3 uWorldTransformMatrix;
          uniform vec4 uWorldColorAlpha;
          uniform vec2 uResolution;
        `}};function M({bits:e,name:r}){let o=function({template:e,bits:r}){let o=p(e,r);if(d[o])return d[o];let{vertex:t,fragment:n}=function(e,r){var o;let t,n,i,a,u,l=r.map(e=>e.vertex).filter(e=>!!e),s=r.map(e=>e.fragment).filter(e=>!!e),c=v(l,e.vertex,!0);return t=[],f(o=c,t),l.forEach(e=>{e.header&&f(e.header,t)}),n=0,i=t.sort().map(e=>e.indexOf("builtin")>-1?e:`@location(${n++}) ${e}`).join(",\n"),a=t.sort().map(e=>`       var ${e.replace(/@.*?\s+/g,"")};`).join("\n"),u=`return VSOutput(
                ${t.sort().map(e=>{let r;return` ${(r=/\b(\w+)\s*:/g.exec(e))?r[1]:""}`}).join(",\n")});`,{vertex:c=o.replace(/@out\s+[^;]+;\s*/g,"").replace("{{struct}}",`
${i}
`).replace("{{start}}",`
${a}
`).replace("{{return}}",`
${u}
`),fragment:v(s,e.fragment,!0)}}(e,r);return d[o]=h(t,n,r),d[o]}({template:{fragment:b,vertex:g},bits:[T,...e]});return n.B.from({name:r,vertex:{source:o.vertex,entryPoint:"main"},fragment:{source:o.fragment,entryPoint:"main"}})}function U({bits:e,name:r}){return new t.M({name:r,...function({template:e,bits:r}){let o=p(e,r);return d[o]||(d[o]=h(e.vertex,e.fragment,r)),d[o]}({template:{vertex:C,fragment:P},bits:[$,...e]})})}},89911(e,r,o){o.d(r,{F:()=>t,a:()=>n});let t={name:"color-bit",vertex:{header:`
            @in aColor: vec4<f32>;
        `,main:`
            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
        `}},n={name:"color-bit",vertex:{header:`
            in vec4 aColor;
        `,main:`
            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
        `}}},52844(e,r,o){o.d(r,{P:()=>a,_:()=>n});let t={};function n(e){return t[e]||(t[e]={name:"texture-batch-bit",vertex:{header:`
                @in aTextureIdAndRound: vec2<u32>;
                @out @interpolate(flat) vTextureId : u32;
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1)
                {
                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
                }
            `},fragment:{header:`
                @in @interpolate(flat) vTextureId: u32;
    
                ${function(e){let r=[];{let e=0;for(let o=0;o<16;o++)r.push(`@group(1) @binding(${e++}) var textureSource${o+1}: texture_2d<f32>;`),r.push(`@group(1) @binding(${e++}) var textureSampler${o+1}: sampler;`)}return r.join("\n")}(0)}
            `,main:`
                var uvDx = dpdx(vUV);
                var uvDy = dpdy(vUV);
    
                ${function(e){let r=[];r.push("switch vTextureId {");for(let e=0;e<16;e++)15===e?r.push("  default:{"):r.push(`  case ${e}:{`),r.push(`      outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),r.push("      break;}");return r.push("}"),r.join("\n")}(0)}
            `}}),t[e]}let i={};function a(e){return i[e]||(i[e]={name:"texture-batch-bit",vertex:{header:`
                in vec2 aTextureIdAndRound;
                out float vTextureId;
              
            `,main:`
                vTextureId = aTextureIdAndRound.y;
            `,end:`
                if(aTextureIdAndRound.x == 1.)
                {
                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
                }
            `},fragment:{header:`
                in float vTextureId;
    
                uniform sampler2D uTextures[${e}];
              
            `,main:`
    
                ${function(e){let r=[];for(let e=0;e<16;e++)e>0&&r.push("else"),e<15&&r.push(`if(vTextureId < ${e}.5)`),r.push("{"),r.push(`	outColor = texture(uTextures[${e}], vUV);`),r.push("}");return r.join("\n")}(0)}
            `}}),i[e]}},54447(e,r,o){o.d(r,{Ls:()=>t,_Q:()=>n,mA:()=>i});let t={name:"local-uniform-bit",vertex:{header:`

            struct LocalUniforms {
                uTransformMatrix:mat3x3<f32>,
                uColor:vec4<f32>,
                uRound:f32,
            }

            @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
        `,main:`
            vColor *= localUniforms.uColor;
            modelMatrix *= localUniforms.uTransformMatrix;
        `,end:`
            if(localUniforms.uRound == 1)
            {
                vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
            }
        `}},n={...t,vertex:{...t.vertex,header:t.vertex.header.replace("group(1)","group(2)")}},i={name:"local-uniform-bit",vertex:{header:`

            uniform mat3 uTransformMatrix;
            uniform vec4 uColor;
            uniform float uRound;
        `,main:`
            vColor *= uColor;
            modelMatrix = uTransformMatrix;
        `,end:`
            if(uRound == 1.)
            {
                gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
            }
        `}}},57261(e,r,o){o.d(r,{b:()=>t,m:()=>n});let t={name:"round-pixels-bit",vertex:{header:`
            fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32> 
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}},n={name:"round-pixels-bit",vertex:{header:`   
            vec2 roundPixels(vec2 position, vec2 targetSize)
            {       
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `}}},13372(e,r,o){o.d(r,{V:()=>t});function t(e,r,o){let t=(e>>24&255)/255;r[o++]=(255&e)/255*t,r[o++]=(e>>8&255)/255*t,r[o++]=(e>>16&255)/255*t,r[o++]=t}},59786(e,r,o){o.d(r,{K:()=>t});class t{constructor(){this.vertexSize=4,this.indexSize=6,this.location=0,this.batcher=null,this.batch=null,this.roundPixels=0}get blendMode(){return this.renderable.groupBlendMode}packAttributes(e,r,o,t){let n=this.renderable,i=this.texture,a=n.groupTransform,u=a.a,l=a.b,s=a.c,v=a.d,f=a.tx,c=a.ty,d=this.bounds,m=d.maxX,x=d.minX,p=d.maxY,h=d.minY,g=i.uvs,b=n.groupColorAlpha,C=t<<16|65535&this.roundPixels;e[o+0]=u*x+s*h+f,e[o+1]=v*h+l*x+c,e[o+2]=g.x0,e[o+3]=g.y0,r[o+4]=b,r[o+5]=C,e[o+6]=u*m+s*h+f,e[o+7]=v*h+l*m+c,e[o+8]=g.x1,e[o+9]=g.y1,r[o+10]=b,r[o+11]=C,e[o+12]=u*m+s*p+f,e[o+13]=v*p+l*m+c,e[o+14]=g.x2,e[o+15]=g.y2,r[o+16]=b,r[o+17]=C,e[o+18]=u*x+s*p+f,e[o+19]=v*p+l*x+c,e[o+20]=g.x3,e[o+21]=g.y3,r[o+22]=b,r[o+23]=C}packIndex(e,r,o){e[r]=o+0,e[r+1]=o+1,e[r+2]=o+2,e[r+3]=o+0,e[r+4]=o+2,e[r+5]=o+3}reset(){this.renderable=null,this.texture=null,this.batcher=null,this.batch=null,this.bounds=null}}}}]);
//# sourceMappingURL=199.de925865.js.map