"use strict";var U=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var C=(m,t)=>{for(var f in t)U(m,f,{get:t[f],enumerable:!0})},I=(m,t,f,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let x of g(t))!b.call(m,x)&&x!==f&&U(m,x,{get:()=>t[x],enumerable:!(p=B(t,x))||p.enumerable});return m};var P=m=>I(U({},"__esModule",{value:!0}),m);var R={};C(R,{buildPaintColorMapImage:()=>T});module.exports=P(R);var s=require("@shopify/react-native-skia");function k(m,t,f,p){const x=Math.max(1,Math.min(16,Math.round(p))),r=new Uint8Array(t*f*4),l=new Uint8Array(t*f*4);for(let u=0;u<f;u++)for(let y=0;y<t;y++){let c=0,h=0,M=0,e=0,n=0;const o=u*t*4;for(let a=-x;a<=x;a++){const d=y+a;if(d>=0&&d<t){const A=o+d*4;c+=m[A],h+=m[A+1],M+=m[A+2],e+=m[A+3],n++}}const i=o+y*4;r[i]=Math.round(c/n),r[i+1]=Math.round(h/n),r[i+2]=Math.round(M/n),r[i+3]=Math.round(e/n)}for(let u=0;u<t;u++)for(let y=0;y<f;y++){let c=0,h=0,M=0,e=0,n=0;for(let i=-x;i<=x;i++){const a=y+i;if(a>=0&&a<f){const d=a*t*4+u*4;c+=r[d],h+=r[d+1],M+=r[d+2],e+=r[d+3],n++}}const o=y*t*4+u*4;l[o]=Math.round(c/n),l[o+1]=Math.round(h/n),l[o+2]=Math.round(M/n),l[o+3]=Math.round(e/n)}return l}function G(m,t,f,p){const x=Math.max(1,Math.min(8,Math.round(p))),r=new Uint8Array(t*f*4),l=new Uint8Array(t*f*4);for(let u=0;u<f;u++)for(let y=0;y<t;y++){let c=0,h=0,M=0,e=0;const n=u*t*4;for(let i=-x;i<=x;i++){const a=y+i;if(a>=0&&a<t){const d=n+a*4;m[d+3]>e?(c=m[d],h=m[d+1],M=m[d+2],e=m[d+3]):m[d+3]===e&&e>0&&(c=Math.max(c,m[d]),h=Math.max(h,m[d+1]),M=Math.max(M,m[d+2]))}}const o=n+y*4;r[o]=c,r[o+1]=h,r[o+2]=M,r[o+3]=e}for(let u=0;u<t;u++)for(let y=0;y<f;y++){let c=0,h=0,M=0,e=0;for(let o=-x;o<=x;o++){const i=y+o;if(i>=0&&i<f){const a=i*t*4+u*4;r[a+3]>e?(c=r[a],h=r[a+1],M=r[a+2],e=r[a+3]):r[a+3]===e&&e>0&&(c=Math.max(c,r[a]),h=Math.max(h,r[a+1]),M=Math.max(M,r[a+2]))}}const n=y*t*4+u*4;l[n]=c,l[n+1]=h,l[n+2]=M,l[n+3]=e}return l}function T(m,t,f,p,x=0){const r=t*f,l=new Map;for(const[e,n]of p)l.set(e+1,n);if(x<=.1&&x>=-.1){const e=new Uint8Array(r*4);for(let o=0;o<r;o++){const i=m[o],a=i>0?l.get(i):void 0,d=o*4;a&&(e[d]=a.r,e[d+1]=a.g,e[d+2]=a.b,e[d+3]=255)}const n=s.Skia.Data.fromBytes(e);return s.Skia.Image.MakeImage({width:t,height:f,alphaType:s.AlphaType.Unpremul,colorType:s.ColorType.RGBA_8888},n,t*4)}const u=new Uint8Array(r*4);for(let e=0;e<r;e++){const n=m[e],o=n>0?l.get(n):void 0,i=e*4;o&&(u[i]=o.r,u[i+1]=o.g,u[i+2]=o.b,u[i+3]=255)}const y=k(u,t,f,x),c=G(y,t,f,x),h=new Uint8Array(r*4);for(let e=0;e<r;e++){const n=e*4,o=c[n+3];o>0&&(h[n]=Math.min(255,Math.round(c[n]*255/o)),h[n+1]=Math.min(255,Math.round(c[n+1]*255/o)),h[n+2]=Math.min(255,Math.round(c[n+2]*255/o)),h[n+3]=o)}const M=s.Skia.Data.fromBytes(h);return s.Skia.Image.MakeImage({width:t,height:f,alphaType:s.AlphaType.Unpremul,colorType:s.ColorType.RGBA_8888},M,t*4)}
