var d=Object.defineProperty,m=(t,e)=>{for(var i in e)d(t,i,{get:e[i],enumerable:!0})},c={};m(c,{IN_NODE:()=>s,WASM_PREFIX:()=>y,getFsBundle:()=>h,instantiateWasm:()=>S,rmdirRecursive:()=>g,startArtifactDownload:()=>u,toPostgresName:()=>b,uuid:()=>E});var s=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",y="/pglite",a=new Map;async function u(t){s||a.has(t.toString())||a.set(t.toString(),fetch(t))}var o=new Map;async function S(t,e,i){if(i||o.has(e.toString())){let r=i||o.get(e.toString());return{instance:await WebAssembly.instantiate(r,t),module:r}}if(s){let r=await(await import("fs/promises")).readFile(e),{module:n,instance:l}=await WebAssembly.instantiate(r,t);return o.set(e.toString(),n),{instance:l,module:n}}else{a.has(e.toString())||u(e);let r=await a.get(e.toString()),{module:n,instance:l}=await WebAssembly.instantiateStreaming(r.clone(),t);return o.set(e.toString(),n),{instance:l,module:n}}}async function h(t){return s?(await(await import("fs/promises")).readFile(t)).buffer:(u(t),(await a.get(t.toString())).clone().arrayBuffer())}var E=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let t=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(t);else for(let i=0;i<t.length;i++)t[i]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let e=[];return t.forEach(i=>{e.push(i.toString(16).padStart(2,"0"))}),e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10).join("")};function b(t){let e;return t.startsWith('"')&&t.endsWith('"')?e=t.substring(1,t.length-1):e=t.toLowerCase(),e}function g(t,e){try{let i=t.readdir(e).filter(r=>r!=="."&&r!=="..");for(let r of i){let n=e+"/"+r;try{t.readdir(n),g(t,n)}catch{t.unlink(n)}}t.rmdir(e)}catch{try{t.unlink(e)}catch{}}}var w=async(t,e)=>(e.PGLITE_ENV.POSTGIS_GDAL_ENABLED_DRIVERS="ENABLE_ALL",e.PGLITE_ENV.POSTGIS_ENABLE_OUTDB_RASTERS=1,e.PGLITE_ENV.PROJ_DATA=`${c.WASM_PREFIX}/share/proj`,{emscriptenOpts:e,bundlePath:new URL("./postgis.tar.gz",import.meta.url)}),P={name:"postgis",setup:w};export{P as postgis};
//# sourceMappingURL=index.js.map