/** * esbuild-plugin-glsl v1.2.2 build Sat Sep 30 2023 * https://github.com/vanruesc/esbuild-plugin-glsl * Copyright 2020 Raoul van RĂ¼schen * @license Zlib */ "use strict";var F=Object.create;var h=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},O=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!M.call(t,o)&&o!==r&&h(t,o,{get:()=>e[o],enumerable:!(s=P(e,o))||s.enumerable});return t};var x=(t,e,r)=>(r=t!=null?F($(t)):{},O(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),I=t=>O(h({},"__esModule",{value:!0}),t);var A={};B(A,{default:()=>k,glsl:()=>k});module.exports=I(A);function S(t){let e=/[ \t]*(?:(?:\/\*[\s\S]*?\*\/)|(?:\/\/.*\n))/g,r=/\s*([{}=*,+/><&|[\]()\\!?:;-])\s*/g,s=/(\w<\w+>)\s*(\w)/g,o=t.replace(/\r/g,"").replace(e,""),c=!0,a=!1;return o=o.split(/\n+/).reduce((i,n)=>(n=n.trim().replace(/\s{2,}|\t/," "),n[0]==="#"?(a&&i.push(` `),i.push(n,` `),a=!1):n.length>0&&(n=n.replace(r,"$1"),!c&&/\w/.test(n[0])&&(n=" "+n),n=n.replace(s,"$1 $2"),i.push(n),c=!/\w/.test(n[n.length-1]),a=!0),i),[]).join(""),o.replace(/\n{2,}/g,` `)}var R=x(require("fs"),1),b=x(require("util"),1),w=x(require("path"),1),j=b.promisify(R.readFile);async function L(t,e,r){let s=await j(t,"utf8");if(!r)return{contents:s};let o=[],c=[],a=new Set,i=/#include +["']([.\\/\w-]+)["']/g,n=/\r|\n|\r\n/g,l=i.exec(s);for(;l!==null;){let d=l[0],m=l[1],g=w.join(w.dirname(t),m);try{let p=e.get(g);if(p===void 0){let u=await L(g,e,r);u.warnings?.forEach(f=>c.push(f)),u.watchFiles?.forEach(f=>a.add(f)),p=u.contents,e.set(g,p)}o.push({file:g,contents:p,target:d}),a.add(g),l=i.exec(s)}catch{if(l===null)break;let u=s.split(n),f=u.indexOf(l[0]),y=u[f];c.push({text:`File from <${l[0]}> not found`,location:{file:m,line:f+1,length:m.length,column:y.indexOf(m),lineText:y}}),o.push({file:g,contents:"",target:l[0]}),l=i.exec(s)}}for(let d of o)s=s.replace(d.target,d.contents);return e.set(t,s),{contents:s,warnings:c,watchFiles:[...a]}}function k({minify:t=!1,resolveIncludes:e=!0}={}){let r=new Map;return{name:"glsl",setup(s){async function o(c){let{contents:a,warnings:i,watchFiles:n}=await L(c.path,r,e);return{contents:t?S(a):a,warnings:i,watchFiles:n,loader:"text"}}s.onLoad({filter:/\.(?:frag|vert|glsl|wgsl)$/},o)}}}0&&(module.exports={glsl});