"use strict";var F=Object.create;var u=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var M=(e,s)=>{for(var r in s)u(e,r,{get:s[r],enumerable:!0})},T=(e,s,r,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of q(s))!k.call(e,i)&&i!==r&&u(e,i,{get:()=>s[i],enumerable:!(t=R(s,i))||t.enumerable});return e};var d=(e,s,r)=>(r=e!=null?F(N(e)):{},T(s||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)),A=e=>T(u({},"__esModule",{value:!0}),e);var X={};M(X,{default:()=>V});module.exports=A(X);var h=d(require("node:fs/promises"),1),S=d(require("node:path"),1);var P=d(require("google-closure-compiler"),1);var J=/(?<=\.{3}\s*|(?e.replace(J,'globalThis["__reserved__"]["%dymamic_import%"]'),b=e=>e.replace(/\bglobalThis\s*\.\s*__reserved__\s*\[\s*"%dymamic_import%"\s*\]/g,"import");var v=e=>e.replace(/export\s+default\b/g,'/** @nocollapse */globalThis["__reserved__"]["%export"]["default"]=').replace(/export\s*{([^}]+)}/g,(s,r)=>r.split(",").map(t=>'/** @nocollapse */globalThis["__reserved__"]["%export"]'+(/\sas\s/.test(t)?t.replace(/(.+)\sas\s(.+)/,(i,o,n)=>`[${JSON.stringify(n.trim())}]=${o}`):`[${JSON.stringify(t.trim())}]=${t}`)).join(";")),O=e=>{let s=e.replace(/globalThis\s*\.\s*__reserved__\s*\[\s*"%export"\s*\]\s*\[\s*"default"\s*\]\s*=/g,"export default ").replace(/globalThis\s*\.\s*__reserved__\s*\[\s*"%export"\s*\]\s*\.\s*([^=]+)=/g,"export const $1=");if(s.indexOf('globalThis.__reserved__["%export"]')!==-1)throw new Error("File has unsupported exports");return s};var L=/\bimport\s*(?:|(?:((?<=\s)(?:(?=[^{*]*,\s*[*{])[^,]+\s*(?=,)|[^,{*]*?(?=\s*from))),?)?\s*(?:(?:[*]\s*as\s+([^{},]*)(?=\s))|\{\s*([^}]*?)\s*\})?\s*(from))\s*((["'])(?:[^\\6\\]|\\.)*?\6)/g,$=e=>e.replace(L,(s,r,t,i,o,n)=>`/** @nocollapse */ globalThis["__reserved__"]["%import_start"]();${o?`const {${[r?`default:${r}`:"",i?.replace(/as\s/g,":"),t?`...${t}`:""].filter(Boolean).join(",")}}=`:""}globalThis["__reserved__"]["%import"](${n});/** @nocollapse */ globalThis["__reserved__"]["%import_end"]()`).replace(/export\s*{([^}]+)}/g,(s,r)=>r.split(",").map(t=>'/** @nocollapse */globalThis["__reserved__"]["%export"]'+(/\sas\s/.test(t)?t.replace(/(.+)\sas\s(.+)/,(i,o,n)=>`[${JSON.stringify(n.trim())}]=${o}`):`[${JSON.stringify(t.trim())}]=${t}`)).join(";")),E=e=>{let s=e.replace(/\bglobalThis\s*\.\s*__reserved__\s*\[\s*"%import_start"\s*\]\s*\(\s*\)[^}]*(\{.*?)\s*=\s*globalThis\s*\.\s*__reserved__\s*\[\s*"%import"\s*\]\s*\(\s*(.*?)\s*\)(?:\s*;|[\r\n])\s*globalThis\s*.__reserved__\s*\[\s*"%import_end"\s*\]\s*\(\s*\)/g,(r,t,i)=>`import ${t.replace(/:/g," as ")} from ${i}`);if(s.indexOf('globalThis.__reserved__["%import_start"]')!==-1)throw new Error("File has unsupported imports");return s};var C=e=>` (function(fallbackPkgName){(function (global, factory) { if (typeof define === "function" && define["amd"]) { define(["require", "exports", "module"], factory); } else { const isCjsMod = (typeof module === "object" && typeof module["exports"] === "object"); const req = (typeof require === "function") ? require : function(n) {throw new Error("Cannot find module '" + n + "'");}; const mod = isCjsMod ? module : Object.create(null, { "exports": { ["configurable"]: true, ["enumerable"]: true, ["writable"]: true, ["value"]: Object.create(null), }, }); const result = factory(req, mod["exports"], mod); if (typeof result !== "undefined") { mod["exports"] = result; } if (!isCjsMod) { global[fallbackPkgName] = mod["exports"]; } } })(this, function (require, exports, module) { ${e} });}).call( typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof global === "object" ? global : this, ${JSON.stringify("index")} );`,j=e=>e;var x=e=>e.replace(/(__reserved__)/g,"_$1_"),y=e=>e.replace(/_(__reserved__)_/g,"$1"),z={preprocess:e=>[x,f,v,$].reduce((s,r)=>r(s),e),postprocess:e=>[b,O,E,y].reduce((s,r)=>r(s),e)},G={preprocess:e=>[x,f,C].reduce((s,r)=>r(s),e),postprocess:e=>[b,j,y].reduce((s,r)=>r(s),e)},H={preprocess:x,postprocess:e=>"~function(){"+y(e)+"}();"},K=(e,s)=>{let r=e.format==="esm",t=e.format==="esm"?z:e.format==="cjs"?G:H,i=()=>new P.default.compiler({language_in:"ECMASCRIPT_2020",language_out:"ECMASCRIPT_2015",env:"BROWSER",...s,rewrite_polyfills:!1,process_closure_primitives:!1,apply_input_source_maps:!1,warning_level:"QUIET",isolate_polyfills:!0,assume_function_wrapper:r});return o=>(o=t.preprocess(o),new Promise((n,m)=>{let c=i().run((a,l,p)=>{if(a===0)l=t.postprocess(l),n(l);else return m(new Error(p))});if(!c.stdin){c.kill(),m(new Error("No stdin"));return}c.stdin.write(o),c.stdin.end()}))},I=K;var V=e=>{let s="@apeleghq/esbuild-plugin-closure-compiler",r=new TextEncoder,t=new TextDecoder;return{name:s,setup(o){let n=o.initialOptions.write,m={...o.initialOptions};o.initialOptions.write=!1,o.initialOptions.metafile=!0;let c=I(m,e);o.onEnd(async a=>{let l=a.outputFiles;!Array.isArray(l)||!a.metafile||(await Promise.all(Object.entries(a.metafile?.outputs||{}).map(async([p,w])=>{if(!w.entryPoint)return;let _=l.find(D=>D.path.endsWith(p));if(!_)return;let g=r.encode(await c(_.text));Object.defineProperty(w,"bytes",{get:()=>g.byteLength}),Object.defineProperties(_,{contents:{get:()=>g},text:{get:()=>t.decode(g)}})})),n!==!1&&(await Promise.all(Array.from(new Set(l.map(p=>S.default.dirname(p.path)))).map(p=>h.default.mkdir(p,{recursive:!0}))),await Promise.all(l.map(p=>h.default.writeFile(p.path,p.contents))),a.outputFiles=void 0))})}}};