@ailog/cli 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +3 -26
  2. package/dist/bin/cli.js +1 -1
  3. package/dist/standalone/.next/BUILD_ID +1 -1
  4. package/dist/standalone/.next/build-manifest.json +2 -2
  5. package/dist/standalone/.next/server/app/_global-error.html +2 -2
  6. package/dist/standalone/.next/server/app/_global-error.rsc +1 -1
  7. package/dist/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/dist/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/dist/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/dist/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/dist/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/dist/standalone/.next/server/app/_not-found.html +1 -1
  13. package/dist/standalone/.next/server/app/_not-found.rsc +1 -1
  14. package/dist/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  15. package/dist/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/dist/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  17. package/dist/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/dist/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/dist/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  20. package/dist/standalone/.next/server/app/api/[[...route]]/route.js.nft.json +1 -1
  21. package/dist/standalone/.next/server/app/index.html +1 -1
  22. package/dist/standalone/.next/server/app/index.rsc +1 -1
  23. package/dist/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  24. package/dist/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  25. package/dist/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  26. package/dist/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  27. package/dist/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  28. package/dist/standalone/.next/server/chunks/[root-of-the-server]__a0f47697._.js +2 -2
  29. package/dist/standalone/.next/server/pages/404.html +1 -1
  30. package/dist/standalone/.next/server/pages/500.html +2 -2
  31. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +3 -0
  32. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +238 -0
  33. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +224 -0
  34. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +283 -0
  35. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +274 -0
  36. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +24 -0
  37. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/layout.tsx +3 -0
  38. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/page.tsx +238 -0
  39. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/settings/page.tsx +224 -0
  40. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/app/apps/[appId]/threads/[threadId]/page.tsx +283 -0
  41. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components/apps-table.tsx +274 -0
  42. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/components.json +24 -0
  43. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +65 -0
  44. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +34 -0
  45. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +65 -0
  46. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/tsconfig.json +34 -0
  47. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +6 -6
  48. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +7 -7
  49. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +7 -7
  50. package/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/dist/standalone/package.json +5 -5
  51. package/dist/standalone/dist/standalone/dist/standalone/package.json +1 -1
  52. package/dist/standalone/dist/standalone/package.json +2 -2
  53. package/dist/standalone/package.json +1 -1
  54. package/package.json +1 -1
  55. /package/dist/standalone/.next/static/{9y8i31xPiG_Qcw_BXVNIB → 8H5ZwnsPRw0PovUUXMbkb}/_buildManifest.js +0 -0
  56. /package/dist/standalone/.next/static/{9y8i31xPiG_Qcw_BXVNIB → 8H5ZwnsPRw0PovUUXMbkb}/_clientMiddlewareManifest.json +0 -0
  57. /package/dist/standalone/.next/static/{9y8i31xPiG_Qcw_BXVNIB → 8H5ZwnsPRw0PovUUXMbkb}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[80253,30314,e=>{"use strict";var t=class extends Error{res;status;constructor(e=500,t){super(t?.message,{cause:t?.cause}),this.res=t?.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};e.s(["HTTPException",()=>t],80253);var r=e=>{let t=e.split("/");return""===t[0]&&t.shift(),t},a=e=>{let{groups:t,path:a}=i(e);return s(r(a),t)},i=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,r)=>{let a=`@${r}`;return t.push([a,e]),a}),{groups:t,path:e}},s=(e,t)=>{for(let r=t.length-1;r>=0;r--){let[a]=t[r];for(let i=e.length-1;i>=0;i--)if(e[i].includes(a)){e[i]=e[i].replace(a,t[r][1]);break}}return e},n={},o=(e,t)=>{if("*"===e)return"*";let r=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let a=`${e}#${t}`;return n[a]||(r[2]?n[a]=t&&":"!==t[0]&&"*"!==t[0]?[a,r[1],RegExp(`^${r[2]}(?=/${t})`)]:[e,r[1],RegExp(`^${r[2]}$`)]:n[a]=[e,r[1],!0]),n[a]}return null},p=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},d=e=>p(e,decodeURI),l=e=>{let t=e.url,r=t.indexOf("/",t.indexOf(":")+4),a=r;for(;a<t.length;a++){let e=t.charCodeAt(a);if(37===e){let e=t.indexOf("?",a),i=t.slice(r,-1===e?void 0:e);return d(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}if(63===e)break}return t.slice(r,a)},c=e=>{let t=l(e);return t.length>1&&"/"===t.at(-1)?t.slice(0,-1):t},u=(e,t,...r)=>(r.length&&(t=u(t,...r)),`${e?.[0]==="/"?"":"/"}${e}${"/"===t?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),h=e=>{if(63!==e.charCodeAt(e.length-1)||!e.includes(":"))return null;let t=e.split("/"),r=[],a="";return t.forEach(e=>{if(""===e||/\:/.test(e)){if(/\:/.test(e))if(/\?/.test(e)){0===r.length&&""===a?r.push("/"):r.push(a);let t=e.replace("?","");a+="/"+t,r.push(a)}else a+="/"+e}else a+="/"+e}),r.filter((e,t,r)=>r.indexOf(e)===t)},m=e=>/[%+]/.test(e)?(-1!==e.indexOf("+")&&(e=e.replace(/\+/g," ")),-1!==e.indexOf("%")?p(e,v):e):e,f=(e,t,r)=>{let a;if(!r&&t&&!/[%+]/.test(t)){let r=e.indexOf("?",8);if(-1===r)return;for(e.startsWith(t,r+1)||(r=e.indexOf(`&${t}`,r+1));-1!==r;){let a=e.charCodeAt(r+t.length+1);if(61===a){let a=r+t.length+2,i=e.indexOf("&",a);return m(e.slice(a,-1===i?void 0:i))}if(38==a||isNaN(a))return"";r=e.indexOf(`&${t}`,r+1)}if(!(a=/[%+]/.test(e)))return}let i={};a??=/[%+]/.test(e);let s=e.indexOf("?",8);for(;-1!==s;){let t,n=e.indexOf("&",s+1),o=e.indexOf("=",s);o>n&&-1!==n&&(o=-1);let p=e.slice(s+1,-1===o?-1===n?void 0:n:o);a&&(p=m(p)),s=n,""!==p&&(-1===o?t="":(t=e.slice(o+1,-1===n?void 0:n),a&&(t=m(t))),r?(i[p]&&Array.isArray(i[p])||(i[p]=[]),i[p].push(t)):i[p]??=t)}return t?i[t]:i},g=(e,t)=>f(e,t,!0),v=decodeURIComponent;e.s(["checkOptionalParameter",()=>h,"decodeURIComponent_",()=>v,"getPath",()=>l,"getPathNoStrict",()=>c,"getPattern",()=>o,"getQueryParam",()=>f,"getQueryParams",()=>g,"mergePath",()=>u,"splitPath",()=>r,"splitRoutingPath",()=>a,"tryDecode",()=>p],30314)},26481,e=>{"use strict";var t=(e,t,r)=>(a,i)=>{let s=-1;return n(0);async function n(o){let p,d;if(o<=s)throw Error("next() called multiple times");s=o;let l=!1;if(e[o]?(d=e[o][0][0],a.req.routeIndex=o):d=o===e.length&&i||void 0,d)try{p=await d(a,()=>n(o+1))}catch(e){if(e instanceof Error&&t)a.error=e,p=await t(e,a),l=!0;else throw e}else!1===a.finalized&&r&&(p=await r(a));return p&&(!1===a.finalized||l)&&(a.res=p),a}};e.i(80253);var r=Symbol(),a=async(e,t=Object.create(null))=>{let{all:r=!1,dot:a=!1}=t,s=(e instanceof d?e.raw.headers:e.headers).get("Content-Type");return s?.startsWith("multipart/form-data")||s?.startsWith("application/x-www-form-urlencoded")?i(e,{all:r,dot:a}):{}};async function i(e,t){var r,a;let i,o=await e.formData();return o?(r=o,a=t,i=Object.create(null),r.forEach((e,t)=>{a.all||t.endsWith("[]")?s(i,t,e):i[t]=e}),a.dot&&Object.entries(i).forEach(([e,t])=>{e.includes(".")&&(n(i,e,t),delete i[e])}),i):{}}var s=(e,t,r)=>{void 0!==e[t]?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:t.endsWith("[]")?e[t]=[r]:e[t]=r},n=(e,t,r)=>{let a=e,i=t.split(".");i.forEach((e,t)=>{t===i.length-1?a[e]=r:((!a[e]||"object"!=typeof a[e]||Array.isArray(a[e])||a[e]instanceof File)&&(a[e]=Object.create(null)),a=a[e])})},o=e.i(30314),p=e=>(0,o.tryDecode)(e,o.decodeURIComponent_),d=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",r=[[]]){this.raw=e,this.path=t,this.#t=r,this.#e={}}param(e){return e?this.#r(e):this.#a()}#r(e){let t=this.#t[0][this.routeIndex][1][e],r=this.#i(t);return r&&/\%/.test(r)?p(r):r}#a(){let e={};for(let t of Object.keys(this.#t[0][this.routeIndex][1])){let r=this.#i(this.#t[0][this.routeIndex][1][t]);void 0!==r&&(e[t]=/\%/.test(r)?p(r):r)}return e}#i(e){return this.#t[1]?this.#t[1][e]:e}query(e){return(0,o.getQueryParam)(this.url,e)}queries(e){return(0,o.getQueryParams)(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((e,r)=>{t[r]=e}),t}async parseBody(e){return this.bodyCache.parsedBody??=await a(this,e)}#s=e=>{let{bodyCache:t,raw:r}=this,a=t[e];if(a)return a;let i=Object.keys(t)[0];return i?t[i].then(t=>("json"===i&&(t=JSON.stringify(t)),new Response(t)[e]())):t[e]=r[e]()};json(){return this.#s("text").then(e=>JSON.parse(e))}text(){return this.#s("text")}arrayBuffer(){return this.#s("arrayBuffer")}blob(){return this.#s("blob")}formData(){return this.#s("formData")}addValidatedData(e,t){this.#e[e]=t}valid(e){return this.#e[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[r](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},l=async(e,t,r,a,i)=>{var s;let n;"object"==typeof e&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let o=e.callbacks;if(!o?.length)return Promise.resolve(e);i?i[0]+=e:i=[e];let p=Promise.all(o.map(e=>e({phase:t,buffer:i,context:a}))).then(e=>Promise.all(e.filter(Boolean).map(e=>l(e,t,!1,a,i))).then(()=>i[0]));if(!r)return p;return s=await p,(n=new String(s)).isEscaped=!0,n.callbacks=o,n},c=(e,t)=>({"Content-Type":e,...t}),u=class{#n;#o;env={};#p;finalized=!1;error;#d;#l;#c;#u;#h;#m;#f;#t;#g;constructor(e,t){this.#n=e,t&&(this.#l=t.executionCtx,this.env=t.env,this.#m=t.notFoundHandler,this.#g=t.path,this.#t=t.matchResult)}get req(){return this.#o??=new d(this.#n,this.#g,this.#t),this.#o}get event(){if(this.#l&&"respondWith"in this.#l)return this.#l;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#l)return this.#l;throw Error("This context has no ExecutionContext")}get res(){return this.#c||=new Response(null,{headers:this.#f??=new Headers})}set res(e){if(this.#c&&e){for(let[t,r]of(e=new Response(e.body,e),this.#c.headers.entries()))if("content-type"!==t)if("set-cookie"===t){let t=this.#c.headers.getSetCookie();for(let r of(e.headers.delete("set-cookie"),t))e.headers.append("set-cookie",r)}else e.headers.set(t,r)}this.#c=e,this.finalized=!0}render=(...e)=>(this.#h??=e=>this.html(e),this.#h(...e));setLayout=e=>this.#u=e;getLayout=()=>this.#u;setRenderer=e=>{this.#h=e};header=(e,t,r)=>{this.finalized&&(this.#c=new Response(this.#c.body,this.#c));let a=this.#c?this.#c.headers:this.#f??=new Headers;void 0===t?a.delete(e):r?.append?a.append(e,t):a.set(e,t)};status=e=>{this.#d=e};set=(e,t)=>{this.#p??=new Map,this.#p.set(e,t)};get=e=>this.#p?this.#p.get(e):void 0;get var(){return this.#p?Object.fromEntries(this.#p):{}}#v(e,t,r){let a=this.#c?new Headers(this.#c.headers):this.#f??new Headers;if("object"==typeof t&&"headers"in t)for(let[e,r]of t.headers instanceof Headers?t.headers:new Headers(t.headers))"set-cookie"===e.toLowerCase()?a.append(e,r):a.set(e,r);if(r)for(let[e,t]of Object.entries(r))if("string"==typeof t)a.set(e,t);else for(let r of(a.delete(e),t))a.append(e,r);return new Response(e,{status:"number"==typeof t?t:t?.status??this.#d,headers:a})}newResponse=(...e)=>this.#v(...e);body=(e,t,r)=>this.#v(e,t,r);text=(e,t,r)=>this.#f||this.#d||t||r||this.finalized?this.#v(e,t,c("text/plain; charset=UTF-8",r)):new Response(e);json=(e,t,r)=>this.#v(JSON.stringify(e),t,c("application/json",r));html=(e,t,r)=>{let a=e=>this.#v(e,t,c("text/html; charset=UTF-8",r));return"object"==typeof e?l(e,1,!1,{}).then(a):a(e)};redirect=(e,t)=>{let r=String(e);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,t??302)};notFound=()=>(this.#m??=()=>new Response,this.#m(this))},h=["get","post","put","delete","options","patch"],m="Can not add a route since the matcher is already built.",f=class extends Error{},g=e=>e.text("404 Not Found",404),v=(e,t)=>{if("getResponse"in e){let r=e.getResponse();return t.newResponse(r.body,r)}return console.error(e),t.text("Internal Server Error",500)},y=class e{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#g="/";routes=[];constructor(e={}){[...h,"all"].forEach(e=>{this[e]=(t,...r)=>("string"==typeof t?this.#g=t:this.#y(e,this.#g,t),r.forEach(t=>{this.#y(e,this.#g,t)}),this)}),this.on=(e,t,...r)=>{for(let a of[t].flat())for(let t of(this.#g=a,[e].flat()))r.map(e=>{this.#y(t.toUpperCase(),this.#g,e)});return this},this.use=(e,...t)=>("string"==typeof e?this.#g=e:(this.#g="*",t.unshift(e)),t.forEach(e=>{this.#y("ALL",this.#g,e)}),this);const{strict:t,...r}=e;Object.assign(this,r),this.getPath=t??!0?e.getPath??o.getPath:o.getPathNoStrict}#w(){let t=new e({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#m=this.#m,t.routes=this.routes,t}#m=g;errorHandler=v;route(e,r){let a=this.basePath(e);return r.routes.map(e=>{let i;r.errorHandler===v?i=e.handler:(i=async(a,i)=>(await t([],r.errorHandler)(a,()=>e.handler(a,i))).res).__COMPOSED_HANDLER=e.handler,a.#y(e.method,e.path,i)}),this}basePath(e){let t=this.#w();return t._basePath=(0,o.mergePath)(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#m=e,this);mount(e,t,r){let a,i,s,n;r&&("function"==typeof r?i=r:(i=r.optionHandler,a=!1===r.replaceRequest?e=>e:r.replaceRequest));let p=i?e=>{let t=i(e);return Array.isArray(t)?t:[t]}:e=>{let t;try{t=e.executionCtx}catch{}return[e.env,t]};a||=(n="/"===(s=(0,o.mergePath)(this._basePath,e))?0:s.length,e=>{let t=new URL(e.url);return t.pathname=t.pathname.slice(n)||"/",new Request(t,e)});let d=async(e,r)=>{let i=await t(a(e.req.raw),...p(e));if(i)return i;await r()};return this.#y("ALL",(0,o.mergePath)(e,"*"),d),this}#y(e,t,r){e=e.toUpperCase(),t=(0,o.mergePath)(this._basePath,t);let a={basePath:this._basePath,path:t,method:e,handler:r};this.router.add(e,t,[r,a]),this.routes.push(a)}#b(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#_(e,r,a,i){if("HEAD"===i)return(async()=>new Response(null,await this.#_(e,r,a,"GET")))();let s=this.getPath(e,{env:a}),n=this.router.match(i,s),o=new u(e,{path:s,matchResult:n,env:a,executionCtx:r,notFoundHandler:this.#m});if(1===n[0].length){let e;try{e=n[0][0][0][0](o,async()=>{o.res=await this.#m(o)})}catch(e){return this.#b(e,o)}return e instanceof Promise?e.then(e=>e||(o.finalized?o.res:this.#m(o))).catch(e=>this.#b(e,o)):e??this.#m(o)}let p=t(n[0],this.errorHandler,this.#m);return(async()=>{try{let e=await p(o);if(!e.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return e.res}catch(e){return this.#b(e,o)}})()}fetch=(e,...t)=>this.#_(e,t[1],t[0],e.method);request=(e,t,r,a)=>e instanceof Request?this.fetch(t?new Request(e,t):e,r,a):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${(0,o.mergePath)("/",e)}`,t),r,a));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#_(e.request,e,void 0,e.request.method))})}},w=[];function b(e,t){let r=this.buildAllMatchers(),a=(e,t)=>{let a=r[e]||r.ALL,i=a[2][t];if(i)return i;let s=t.match(a[0]);if(!s)return[[],w];let n=s.indexOf("",1);return[a[1][n],s]};return this.match=a,a(e,t)}var _="[^/]+",x="(?:|/.*)",N=Symbol(),T=new Set(".\\+*[^]$()");function E(e,t){return 1===e.length?1===t.length?e<t?-1:1:-1:1===t.length||".*"===e||e===x?1:".*"===t||t===x?-1:e===_?1:t===_?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var A=class e{#x;#N;#T=Object.create(null);insert(t,r,a,i,s){let n;if(0===t.length){if(void 0!==this.#x)throw N;if(s)return;this.#x=r;return}let[o,...p]=t,d="*"===o?0===p.length?["","",".*"]:["","",_]:"/*"===o?["","",x]:o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(d){let t=d[1],r=d[2]||_;if(t&&d[2]&&(".*"===r||(r=r.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(r))))throw N;if(!(n=this.#T[r])){if(Object.keys(this.#T).some(e=>".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[r]=new e,""!==t&&(n.#N=i.varIndex++)}s||""===t||a.push([t,n.#N])}else if(!(n=this.#T[o])){if(Object.keys(this.#T).some(e=>e.length>1&&".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[o]=new e}n.insert(p,r,a,i,s)}buildRegExpStr(){let e=Object.keys(this.#T).sort(E).map(e=>{let t=this.#T[e];return("number"==typeof t.#N?`(${e})@${t.#N}`:T.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return("number"==typeof this.#x&&e.unshift(`#${this.#x}`),0===e.length)?"":1===e.length?e[0]:"(?:"+e.join("|")+")"}},S=class{#E={varIndex:0};#A=new A;insert(e,t,r){let a=[],i=[];for(let t=0;;){let r=!1;if(e=e.replace(/\{[^}]+\}/g,e=>{let a=`@\\${t}`;return i[t]=[a,e],t++,r=!0,a}),!r)break}let s=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let e=i.length-1;e>=0;e--){let[t]=i[e];for(let r=s.length-1;r>=0;r--)if(-1!==s[r].indexOf(t)){s[r]=s[r].replace(t,i[e][1]);break}}return this.#A.insert(s,t,a,this.#E,r),a}buildRegExp(){let e=this.#A.buildRegExpStr();if(""===e)return[/^$/,[],[]];let t=0,r=[],a=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(e,i,s)=>void 0!==i?(r[++t]=Number(i),"$()"):(void 0!==s&&(a[Number(s)]=++t),"")),[RegExp(`^${e}`),r,a]}},k=[/^$/,[],Object.create(null)],O=Object.create(null);function C(e){return O[e]??=new RegExp("*"===e?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`)}function I(e,t){if(e){for(let r of Object.keys(e).sort((e,t)=>t.length-e.length))if(C(r).test(t))return[...e[r]]}}var R=class{name="RegExpRouter";#S;#k;constructor(){this.#S={ALL:Object.create(null)},this.#k={ALL:Object.create(null)}}add(e,t,r){let a=this.#S,i=this.#k;if(!a||!i)throw Error(m);a[e]||[a,i].forEach(t=>{t[e]=Object.create(null),Object.keys(t.ALL).forEach(r=>{t[e][r]=[...t.ALL[r]]})}),"/*"===t&&(t="*");let s=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let n=C(t);"ALL"===e?Object.keys(a).forEach(e=>{a[e][t]||=I(a[e],t)||I(a.ALL,t)||[]}):a[e][t]||=I(a[e],t)||I(a.ALL,t)||[],Object.keys(a).forEach(t=>{("ALL"===e||e===t)&&Object.keys(a[t]).forEach(e=>{n.test(e)&&a[t][e].push([r,s])})}),Object.keys(i).forEach(t=>{("ALL"===e||e===t)&&Object.keys(i[t]).forEach(e=>n.test(e)&&i[t][e].push([r,s]))});return}let n=(0,o.checkOptionalParameter)(t)||[t];for(let t=0,o=n.length;t<o;t++){let p=n[t];Object.keys(i).forEach(n=>{("ALL"===e||e===n)&&(i[n][p]||=[...I(a[n],p)||I(a.ALL,p)||[]],i[n][p].push([r,s-o+t+1]))})}}match=b;buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#k).concat(Object.keys(this.#S)).forEach(t=>{e[t]||=this.#O(t)}),this.#S=this.#k=void 0,O=Object.create(null),e}#O(e){let t=[],r="ALL"===e;return([this.#S,this.#k].forEach(a=>{let i=a[e]?Object.keys(a[e]).map(t=>[t,a[e][t]]):[];0!==i.length?(r||=!0,t.push(...i)):"ALL"!==e&&t.push(...Object.keys(a.ALL).map(e=>[e,a.ALL[e]]))}),r)?function(e){let t=new S,r=[];if(0===e.length)return k;let a=e.map(e=>[!/\*|\/:/.test(e[0]),...e]).sort(([e,t],[r,a])=>e?1:r?-1:t.length-a.length),i=Object.create(null);for(let e=0,s=-1,n=a.length;e<n;e++){let n,[o,p,d]=a[e];o?i[p]=[d.map(([e])=>[e,Object.create(null)]),w]:s++;try{n=t.insert(p,s,o)}catch(e){throw e===N?new f(p):e}o||(r[s]=d.map(([e,t])=>{let r=Object.create(null);for(t-=1;t>=0;t--){let[e,a]=n[t];r[e]=a}return[e,r]}))}let[s,n,o]=t.buildRegExp();for(let e=0,t=r.length;e<t;e++)for(let t=0,a=r[e].length;t<a;t++){let a=r[e][t]?.[1];if(!a)continue;let i=Object.keys(a);for(let e=0,t=i.length;e<t;e++)a[i[e]]=o[a[i[e]]]}let p=[];for(let e in n)p[e]=r[n[e]];return[s,p,i]}(t):null}},D=class{name="SmartRouter";#C=[];#k=[];constructor(e){this.#C=e.routers}add(e,t,r){if(!this.#k)throw Error(m);this.#k.push([e,t,r])}match(e,t){let r;if(!this.#k)throw Error("Fatal error");let a=this.#C,i=this.#k,s=a.length,n=0;for(;n<s;n++){let s=a[n];try{for(let e=0,t=i.length;e<t;e++)s.add(...i[e]);r=s.match(e,t)}catch(e){if(e instanceof f)continue;throw e}this.match=s.match.bind(s),this.#C=[s],this.#k=void 0;break}if(n===s)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,r}get activeRouter(){if(this.#k||1!==this.#C.length)throw Error("No active router has been determined yet.");return this.#C[0]}},P=Object.create(null),j=class e{#I;#T;#R;#D=0;#P=P;constructor(e,t,r){if(this.#T=r||Object.create(null),this.#I=[],e&&t){const r=Object.create(null);r[e]={handler:t,possibleKeys:[],score:0},this.#I=[r]}this.#R=[]}insert(t,r,a){this.#D=++this.#D;let i=this,s=(0,o.splitRoutingPath)(r),n=[];for(let t=0,r=s.length;t<r;t++){let r=s[t],a=s[t+1],p=(0,o.getPattern)(r,a),d=Array.isArray(p)?p[0]:r;if(d in i.#T){i=i.#T[d],p&&n.push(p[1]);continue}i.#T[d]=new e,p&&(i.#R.push(p),n.push(p[1])),i=i.#T[d]}return i.#I.push({[t]:{handler:a,possibleKeys:n.filter((e,t,r)=>r.indexOf(e)===t),score:this.#D}}),i}#j(e,t,r,a){let i=[];for(let s=0,n=e.#I.length;s<n;s++){let n=e.#I[s],o=n[t]||n.ALL,p={};if(void 0!==o&&(o.params=Object.create(null),i.push(o),r!==P||a&&a!==P))for(let e=0,t=o.possibleKeys.length;e<t;e++){let t=o.possibleKeys[e],i=p[o.score];o.params[t]=a?.[t]&&!i?a[t]:r[t]??a?.[t],p[o.score]=!0}}return i}search(e,t){let r=[];this.#P=P;let a=[this],i=(0,o.splitPath)(t),s=[];for(let t=0,n=i.length;t<n;t++){let o=i[t],p=t===n-1,d=[];for(let n=0,l=a.length;n<l;n++){let l=a[n],c=l.#T[o];c&&(c.#P=l.#P,p?(c.#T["*"]&&r.push(...this.#j(c.#T["*"],e,l.#P)),r.push(...this.#j(c,e,l.#P))):d.push(c));for(let a=0,n=l.#R.length;a<n;a++){let n=l.#R[a],c=l.#P===P?{}:{...l.#P};if("*"===n){let t=l.#T["*"];t&&(r.push(...this.#j(t,e,l.#P)),t.#P=c,d.push(t));continue}let[u,h,m]=n;if(!o&&!(m instanceof RegExp))continue;let f=l.#T[u],g=i.slice(t).join("/");if(m instanceof RegExp){let t=m.exec(g);if(t){if(c[h]=t[0],r.push(...this.#j(f,e,l.#P,c)),Object.keys(f.#T).length){f.#P=c;let e=t[0].match(/\//)?.length??0;(s[e]||=[]).push(f)}continue}}(!0===m||m.test(o))&&(c[h]=o,p?(r.push(...this.#j(f,e,c,l.#P)),f.#T["*"]&&r.push(...this.#j(f.#T["*"],e,c,l.#P))):(f.#P=c,d.push(f)))}}a=d.concat(s.shift()??[])}return r.length>1&&r.sort((e,t)=>e.score-t.score),[r.map(({handler:e,params:t})=>[e,t])]}},q=class{name="TrieRouter";#q;constructor(){this.#q=new j}add(e,t,r){let a=(0,o.checkOptionalParameter)(t);if(a){for(let t=0,i=a.length;t<i;t++)this.#q.insert(e,a[t],r);return}this.#q.insert(e,t,r)}match(e,t){return this.#q.search(e,t)}},L=class extends y{constructor(e={}){super(e),this.router=e.router??new D({routers:[new R,new q]})}};e.s(["Hono",()=>L],26481)},19991,e=>{"use strict";e.i(26481),e.s([])},66349,e=>{"use strict";var t=e=>t=>e.fetch(t);e.s(["handle",()=>t])},66587,e=>{"use strict";e.i(66349),e.s([],66587)},7805,e=>{"use strict";var t=e=>{var t;let r={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[],...e},a=(e=>{if("string"==typeof e)if("*"===e)return()=>e;else return t=>e===t?t:null;return"function"==typeof e?e:t=>e.includes(t)?t:null})(r.origin),i="function"==typeof(t=r.allowMethods)?t:Array.isArray(t)?()=>t:()=>[];return async function(e,t){function s(t,r){e.res.headers.set(t,r)}let n=await a(e.req.header("origin")||"",e);if(n&&s("Access-Control-Allow-Origin",n),r.credentials&&s("Access-Control-Allow-Credentials","true"),r.exposeHeaders?.length&&s("Access-Control-Expose-Headers",r.exposeHeaders.join(",")),"OPTIONS"===e.req.method){"*"!==r.origin&&s("Vary","Origin"),null!=r.maxAge&&s("Access-Control-Max-Age",r.maxAge.toString());let t=await i(e.req.header("origin")||"",e);t.length&&s("Access-Control-Allow-Methods",t.join(","));let a=r.allowHeaders;if(!a?.length){let t=e.req.header("Access-Control-Request-Headers");t&&(a=t.split(/\s*,\s*/))}return a?.length&&(s("Access-Control-Allow-Headers",a.join(",")),e.res.headers.append("Vary","Access-Control-Request-Headers")),e.res.headers.delete("Content-Length"),e.res.headers.delete("Content-Type"),new Response(null,{headers:e.res.headers,status:204,statusText:"No Content"})}await t(),"*"!==r.origin&&e.header("Vary","Origin",{append:!0})}};e.s(["cors",()=>t])},39768,e=>{"use strict";async function t(){let{navigator:t}=globalThis,r="cloudflare:workers";return!(void 0!==t&&"Cloudflare-Workers"===t.userAgent?await (async()=>{try{return"NO_COLOR"in((await Promise.resolve().then(()=>e.x(r,()=>require(r),!0))).env??{})}catch{return!1}})():!function(){let{process:e,Deno:t}=globalThis;return!("boolean"==typeof t?.noColor?t.noColor:void 0!==e&&"NO_COLOR"in e?.env)}())}var r=async e=>{if(await t())switch(e/100|0){case 5:return`\x1b[31m${e}\x1b[0m`;case 4:return`\x1b[33m${e}\x1b[0m`;case 3:return`\x1b[36m${e}\x1b[0m`;case 2:return`\x1b[32m${e}\x1b[0m`}return`${e}`};async function a(e,t,i,s,n=0,o){e("<--"===t?`${t} ${i} ${s}`:`${t} ${i} ${s} ${await r(n)} ${o}`)}var i=(e=console.log)=>async function(t,r){let i,{method:s,url:n}=t.req,o=n.slice(n.indexOf("/",8));await a(e,"<--",s,o);let p=Date.now();await r(),await a(e,"-->",s,o,t.res.status,(e=>{let[t,r]=[",","."];return e.map(e=>e.replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+t)).join(r)})([(i=Date.now()-p)<1e3?i+"ms":Math.round(i/1e3)+"s"]))};e.s(["logger",()=>i],39768)},79296,e=>{"use strict";function t(e,t,r){function a(r,a){var i;for(let s in Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(i=r._zod).traits??(i.traits=new Set),r._zod.traits.add(e),t(r,a),n.prototype)s in r||Object.defineProperty(r,s,{value:n.prototype[s].bind(r)});r._zod.constr=n,r._zod.def=a}let i=r?.Parent??Object;class s extends i{}function n(e){var t;let i=r?.Parent?new s:this;for(let r of(a(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))r();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(n,"init",{value:a}),Object.defineProperty(n,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}function r(e,t){return"bigint"==typeof t?t.toString():t}Object.freeze({status:"aborted"}),Symbol("zod_brand"),Error.captureStackTrace||((...e)=>{}),()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}};let a=t("$ZodError",(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,r,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})}),i=t("ZodError",(e,t)=>{a.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>{let r,a,i;return r=t||function(e){return e.message},a={_errors:[]},(i=e=>{for(let t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>i({issues:e}));else if("invalid_key"===t.code)i({issues:t.issues});else if("invalid_element"===t.code)i({issues:t.issues});else if(0===t.path.length)a._errors.push(r(t));else{let e=a,i=0;for(;i<t.path.length;){let a=t.path[i];i===t.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(r(t))):e[a]=e[a]||{_errors:[]},e=e[a],i++}}})(e),a}},flatten:{value:t=>(function(e,t=e=>e.message){let r={},a=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}})(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})});e.s(["ZodError",0,i],79296)},16172,e=>{"use strict";let t;e.s([],44057),e.i(44057),(to=tl||(tl={})).assertEqual=e=>{},to.assertIs=function(e){},to.assertNever=function(e){throw Error()},to.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},to.getValidEnumValues=e=>{let t=to.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let a of t)r[a]=e[a];return to.objectValues(r)},to.objectValues=e=>to.objectKeys(e).map(function(t){return e[t]}),to.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},to.find=(e,t)=>{for(let r of e)if(t(r))return r},to.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,to.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},to.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(tc||(tc={})).mergeShapes=(e,t)=>({...e,...t});let r=tl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return r.undefined;case"string":return r.string;case"number":return Number.isNaN(e)?r.nan:r.number;case"boolean":return r.boolean;case"function":return r.function;case"bigint":return r.bigint;case"symbol":return r.symbol;case"object":if(Array.isArray(e))return r.array;if(null===e)return r.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return r.promise;if("undefined"!=typeof Map&&e instanceof Map)return r.map;if("undefined"!=typeof Set&&e instanceof Set)return r.set;if("undefined"!=typeof Date&&e instanceof Date)return r.date;return r.object;default:return r.unknown}};e.s(["ZodParsedType",0,r,"getParsedType",0,a,"objectUtil",()=>tc,"util",()=>tl],57500);let i=tl.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),s=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},a=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(a);else if("invalid_return_type"===i.code)a(i.returnTypeError);else if("invalid_arguments"===i.code)a(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,a=0;for(;a<i.path.length;){let r=i.path[a];a===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],a++}}};return a(this),r}static assert(e){if(!(e instanceof n))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tl.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];t[r]=t[r]||[],t[r].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}n.create=e=>new n(e),e.s(["ZodError",()=>n,"ZodIssueCode",0,i,"quotelessJson",0,s],21466);let o=(e,t)=>{let a;switch(e.code){case i.invalid_type:a=e.received===r.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,tl.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${tl.joinValues(e.keys,", ")}`;break;case i.invalid_union:a="Invalid input";break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${tl.joinValues(e.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${tl.joinValues(e.options)}, received '${e.received}'`;break;case i.invalid_arguments:a="Invalid function arguments";break;case i.invalid_return_type:a="Invalid function return type";break;case i.invalid_date:a="Invalid date";break;case i.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:tl.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case i.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case i.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case i.custom:a="Invalid input";break;case i.invalid_intersection_types:a="Intersection results could not be merged";break;case i.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case i.not_finite:a="Number must be finite";break;default:a=t.defaultError,tl.assertNever(e)}return{message:a}},p=o;function d(e){p=e}function l(){return p}e.s(["getErrorMap",()=>l,"setErrorMap",()=>d],13981),e.i(13981),e.s(["defaultErrorMap",0,o,"getErrorMap",()=>l,"setErrorMap",()=>d],87672),e.i(87672);let c=e=>{let{data:t,path:r,errorMaps:a,issueData:i}=e,s=[...r,...i.path||[]],n={...i,path:s};if(void 0!==i.message)return{...i,path:s,message:i.message};let o="";for(let e of a.filter(e=>!!e).slice().reverse())o=e(n,{data:t,defaultError:o}).message;return{...i,path:s,message:o}},u=[];function h(e,t){let r=p,a=c({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===o?void 0:o].filter(e=>!!e)});e.common.issues.push(a)}class m{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let a of t){if("aborted"===a.status)return f;"dirty"===a.status&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,a=await e.value;r.push({key:t,value:a})}return m.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let a of t){let{key:t,value:i}=a;if("aborted"===t.status||"aborted"===i.status)return f;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||a.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let f=Object.freeze({status:"aborted"}),g=e=>({status:"dirty",value:e}),v=e=>({status:"valid",value:e}),y=e=>"aborted"===e.status,w=e=>"dirty"===e.status,b=e=>"valid"===e.status,_=e=>"undefined"!=typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"OK",0,v,"ParseStatus",()=>m,"addIssueToContext",()=>h,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"makeIssue",0,c],58216),e.i(58216),e.s([],28032),e.i(28032),e.i(57500),(tp=tu||(tu={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},tp.toString=e=>"string"==typeof e?e:e?.message;class x{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let N=(e,t)=>{if(b(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new n(e.common.issues);return this._error=t,this._error}}};function T(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=e;if(t&&(r||a))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:s}=e;return"invalid_enum_value"===t.code?{message:s??i.defaultError}:void 0===i.data?{message:s??a??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:s??r??i.defaultError}},description:i}}class E{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new m,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(_(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parseSync({data:e,path:r.path,parent:r});return N(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return b(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>b(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parse({data:e,path:r.path,parent:r});return N(r,await (_(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,a)=>{let s=e(r),n=()=>a.addIssue({code:i.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(n(),!1)):!!s||(n(),!1)})}refinement(e,t){return this._refinement((r,a)=>!!e(r)||(a.addIssue("function"==typeof t?t(r,a):t),!1))}_refinement(e){return new ew({schema:this,typeName:th.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return eb.create(this,this._def)}nullable(){return e_.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this)}promise(){return ey.create(this,this._def)}or(e){return ei.create([this,e],this._def)}and(e){return eo.create(this,e,this._def)}transform(e){return new ew({...T(this._def),schema:this,typeName:th.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new ex({...T(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:th.ZodDefault})}brand(){return new eA({typeName:th.ZodBranded,type:this,...T(this._def)})}catch(e){return new eN({...T(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:th.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return eS.create(this,e)}readonly(){return ek.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let A=/^c[^\s-]{8,}$/i,S=/^[0-9a-z]+$/,k=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,R=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,D=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,P=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,j=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,q=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,F=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",B=RegExp(`^${U}$`);function V(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function z(e){let t=`${U}T${V(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class W extends E{_parse(e){var a,s,n,o;let p;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==r.string){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.string,received:t.parsedType}),f}let d=new m;for(let r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("max"===r.kind)e.data.length>r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("length"===r.kind){let t=e.data.length>r.value,a=e.data.length<r.value;(t||a)&&(p=this._getOrReturnCtx(e,p),t?h(p,{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&h(p,{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),d.dirty())}else if("email"===r.kind)D.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"email",code:i.invalid_string,message:r.message}),d.dirty());else if("emoji"===r.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"emoji",code:i.invalid_string,message:r.message}),d.dirty());else if("uuid"===r.kind)O.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"uuid",code:i.invalid_string,message:r.message}),d.dirty());else if("nanoid"===r.kind)C.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"nanoid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid"===r.kind)A.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid2"===r.kind)S.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid2",code:i.invalid_string,message:r.message}),d.dirty());else if("ulid"===r.kind)k.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"ulid",code:i.invalid_string,message:r.message}),d.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{h(p=this._getOrReturnCtx(e,p),{validation:"url",code:i.invalid_string,message:r.message}),d.dirty()}else"regex"===r.kind?(r.regex.lastIndex=0,r.regex.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"regex",code:i.invalid_string,message:r.message}),d.dirty())):"trim"===r.kind?e.data=e.data.trim():"includes"===r.kind?e.data.includes(r.value,r.position)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),d.dirty()):"toLowerCase"===r.kind?e.data=e.data.toLowerCase():"toUpperCase"===r.kind?e.data=e.data.toUpperCase():"startsWith"===r.kind?e.data.startsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{startsWith:r.value},message:r.message}),d.dirty()):"endsWith"===r.kind?e.data.endsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{endsWith:r.value},message:r.message}),d.dirty()):"datetime"===r.kind?z(r).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"datetime",message:r.message}),d.dirty()):"date"===r.kind?B.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"date",message:r.message}),d.dirty()):"time"===r.kind?RegExp(`^${V(r)}$`).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"time",message:r.message}),d.dirty()):"duration"===r.kind?R.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"duration",code:i.invalid_string,message:r.message}),d.dirty()):"ip"===r.kind?(a=e.data,!(("v4"===(s=r.version)||!s)&&P.test(a)||("v6"===s||!s)&&q.test(a))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"ip",code:i.invalid_string,message:r.message}),d.dirty())):"jwt"===r.kind?!function(e,t){if(!I.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));if("object"!=typeof i||null===i||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)return!1;return!0}catch{return!1}}(e.data,r.alg)&&(h(p=this._getOrReturnCtx(e,p),{validation:"jwt",code:i.invalid_string,message:r.message}),d.dirty()):"cidr"===r.kind?(n=e.data,!(("v4"===(o=r.version)||!o)&&j.test(n)||("v6"===o||!o)&&L.test(n))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"cidr",code:i.invalid_string,message:r.message}),d.dirty())):"base64"===r.kind?M.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64",code:i.invalid_string,message:r.message}),d.dirty()):"base64url"===r.kind?F.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64url",code:i.invalid_string,message:r.message}),d.dirty()):tl.assertNever(r);return{status:d.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...tu.errToObj(r)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...tu.errToObj(e)})}url(e){return this._addCheck({kind:"url",...tu.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...tu.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...tu.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...tu.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...tu.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...tu.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...tu.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...tu.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...tu.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...tu.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...tu.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...tu.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...tu.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...tu.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...tu.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...tu.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...tu.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...tu.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...tu.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...tu.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...tu.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...tu.errToObj(t)})}nonempty(e){return this.min(1,tu.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}W.create=e=>new W({checks:[],typeName:th.ZodString,coerce:e?.coerce??!1,...T(e)});class $ extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==r.number){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.number,received:t.parsedType}),f}let a=new m;for(let r of this._def.checks)"int"===r.kind?tl.isInteger(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"multipleOf"===r.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(e.data,r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.not_finite,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:tu.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:tu.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:tu.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:tu.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&tl.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}$.create=e=>new $({checks:[],typeName:th.ZodNumber,coerce:e?.coerce||!1,...T(e)});class G extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==r.bigint)return this._getInvalidInput(e);let a=new m;for(let r of this._def.checks)"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}G.create=e=>new G({checks:[],typeName:th.ZodBigInt,coerce:e?.coerce??!1,...T(e)});class H extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==r.boolean){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.boolean,received:t.parsedType}),f}return v(e.data)}}H.create=e=>new H({typeName:th.ZodBoolean,coerce:e?.coerce||!1,...T(e)});class K extends E{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==r.date){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.date,received:t.parsedType}),f}if(Number.isNaN(e.data.getTime()))return h(this._getOrReturnCtx(e),{code:i.invalid_date}),f;let a=new m;for(let r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),a.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),a.dirty()):tl.assertNever(r);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:tu.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:tu.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}K.create=e=>new K({checks:[],coerce:e?.coerce||!1,typeName:th.ZodDate,...T(e)});class J extends E{_parse(e){if(this._getType(e)!==r.symbol){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.symbol,received:t.parsedType}),f}return v(e.data)}}J.create=e=>new J({typeName:th.ZodSymbol,...T(e)});class Z extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.undefined,received:t.parsedType}),f}return v(e.data)}}Z.create=e=>new Z({typeName:th.ZodUndefined,...T(e)});class Q extends E{_parse(e){if(this._getType(e)!==r.null){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.null,received:t.parsedType}),f}return v(e.data)}}Q.create=e=>new Q({typeName:th.ZodNull,...T(e)});class Y extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return v(e.data)}}Y.create=e=>new Y({typeName:th.ZodAny,...T(e)});class X extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return v(e.data)}}X.create=e=>new X({typeName:th.ZodUnknown,...T(e)});class ee extends E{_parse(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.never,received:t.parsedType}),f}}ee.create=e=>new ee({typeName:th.ZodNever,...T(e)});class et extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.void,received:t.parsedType}),f}return v(e.data)}}et.create=e=>new et({typeName:th.ZodVoid,...T(e)});class er extends E{_parse(e){let{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==r.array)return h(t,{code:i.invalid_type,expected:r.array,received:t.parsedType}),f;if(null!==s.exactLength){let e=t.data.length>s.exactLength.value,r=t.data.length<s.exactLength.value;(e||r)&&(h(t,{code:e?i.too_big:i.too_small,minimum:r?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(h(t,{code:i.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(h(t,{code:i.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>s.type._parseAsync(new x(t,e,t.path,r)))).then(e=>m.mergeArray(a,e));let n=[...t.data].map((e,r)=>s.type._parseSync(new x(t,e,t.path,r)));return m.mergeArray(a,n)}get element(){return this._def.type}min(e,t){return new er({...this._def,minLength:{value:e,message:tu.toString(t)}})}max(e,t){return new er({...this._def,maxLength:{value:e,message:tu.toString(t)}})}length(e,t){return new er({...this._def,exactLength:{value:e,message:tu.toString(t)}})}nonempty(e){return this.min(1,e)}}er.create=(e,t)=>new er({type:e,minLength:null,maxLength:null,exactLength:null,typeName:th.ZodArray,...T(t)});class ea extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=tl.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==r.object){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f}let{status:t,ctx:a}=this._processInputParams(e),{shape:s,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof ee&&"strip"===this._def.unknownKeys))for(let e in a.data)n.includes(e)||o.push(e);let p=[];for(let e of n){let t=s[e],r=a.data[e];p.push({key:{status:"valid",value:e},value:t._parse(new x(a,r,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ee){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of o)p.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(h(a,{code:i.unrecognized_keys,keys:o}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of o){let r=a.data[t];p.push({key:{status:"valid",value:t},value:e._parse(new x(a,r,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of p){let r=await t.key,a=await t.value;e.push({key:r,value:a,alwaysSet:t.alwaysSet})}return e}).then(e=>m.mergeObjectSync(t,e)):m.mergeObjectSync(t,p)}get shape(){return this._def.shape()}strict(e){return tu.errToObj,new ea({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let a=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:tu.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ea({...this._def,unknownKeys:"strip"})}passthrough(){return new ea({...this._def,unknownKeys:"passthrough"})}extend(e){return new ea({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ea({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:th.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ea({...this._def,catchall:e})}pick(e){let t={};for(let r of tl.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}omit(e){let t={};for(let r of tl.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ea){let r={};for(let a in t.shape){let i=t.shape[a];r[a]=eb.create(e(i))}return new ea({...t._def,shape:()=>r})}if(t instanceof er)return new er({...t._def,type:e(t.element)});if(t instanceof eb)return eb.create(e(t.unwrap()));if(t instanceof e_)return e_.create(e(t.unwrap()));if(t instanceof ep)return ep.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of tl.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new ea({...this._def,shape:()=>t})}required(e){let t={};for(let r of tl.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof eb;)e=e._def.innerType;t[r]=e}return new ea({...this._def,shape:()=>t})}keyof(){return ef(tl.objectKeys(this.shape))}}ea.create=(e,t)=>new ea({shape:()=>e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.strictCreate=(e,t)=>new ea({shape:()=>e,unknownKeys:"strict",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.lazycreate=(e,t)=>new ea({shape:e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)});class ei extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new n(e.ctx.common.issues));return h(t,{code:i.invalid_union,unionErrors:r}),f});{let e,a=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},s=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===s.status)return s;"dirty"!==s.status||e||(e={result:s,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let s=a.map(e=>new n(e));return h(t,{code:i.invalid_union,unionErrors:s}),f}}get options(){return this._def.options}}ei.create=(e,t)=>new ei({options:e,typeName:th.ZodUnion,...T(t)});let es=e=>{if(e instanceof eh)return es(e.schema);if(e instanceof ew)return es(e.innerType());if(e instanceof em)return[e.value];if(e instanceof eg)return e.options;if(e instanceof ev)return tl.objectValues(e.enum);else if(e instanceof ex)return es(e._def.innerType);else if(e instanceof Z)return[void 0];else if(e instanceof Q)return[null];else if(e instanceof eb)return[void 0,...es(e.unwrap())];else if(e instanceof e_)return[null,...es(e.unwrap())];else if(e instanceof eA)return es(e.unwrap());else if(e instanceof ek)return es(e.unwrap());else if(e instanceof eN)return es(e._def.innerType);else return[]};class en extends E{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f;let a=this.discriminator,s=t.data[a],n=this.optionsMap.get(s);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let a=new Map;for(let r of t){let t=es(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(a.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);a.set(i,r)}}return new en({typeName:th.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...T(r)})}}class eo extends E{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(y(e)||y(n))return f;let o=function e(t,i){let s=a(t),n=a(i);if(t===i)return{valid:!0,data:t};if(s===r.object&&n===r.object){let r=tl.objectKeys(i),a=tl.objectKeys(t).filter(e=>-1!==r.indexOf(e)),s={...t,...i};for(let r of a){let a=e(t[r],i[r]);if(!a.valid)return{valid:!1};s[r]=a.data}return{valid:!0,data:s}}if(s===r.array&&n===r.array){if(t.length!==i.length)return{valid:!1};let r=[];for(let a=0;a<t.length;a++){let s=e(t[a],i[a]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}if(s===r.date&&n===r.date&&+t==+i)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return o.valid?((w(e)||w(n))&&t.dirty(),{status:t.value,value:o.data}):(h(s,{code:i.invalid_intersection_types}),f)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}eo.create=(e,t,r)=>new eo({left:e,right:t,typeName:th.ZodIntersection,...T(r)});class ep extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.array)return h(a,{code:i.invalid_type,expected:r.array,received:a.parsedType}),f;if(a.data.length<this._def.items.length)return h(a,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&a.data.length>this._def.items.length&&(h(a,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...a.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new x(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>m.mergeArray(t,e)):m.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ep({...this._def,rest:e})}}ep.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ep({items:e,typeName:th.ZodTuple,rest:null,...T(t)})};class ed extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.object)return h(a,{code:i.invalid_type,expected:r.object,received:a.parsedType}),f;let s=[],n=this._def.keyType,o=this._def.valueType;for(let e in a.data)s.push({key:n._parse(new x(a,e,a.path,e)),value:o._parse(new x(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?m.mergeObjectAsync(t,s):m.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return new ed(t instanceof E?{keyType:e,valueType:t,typeName:th.ZodRecord,...T(r)}:{keyType:W.create(),valueType:e,typeName:th.ZodRecord,...T(t)})}}class el extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.map)return h(a,{code:i.invalid_type,expected:r.map,received:a.parsedType}),f;let s=this._def.keyType,n=this._def.valueType,o=[...a.data.entries()].map(([e,t],r)=>({key:s._parse(new x(a,e,a.path,[r,"key"])),value:n._parse(new x(a,t,a.path,[r,"value"]))}));if(a.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of o){let a=await r.key,i=await r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of o){let a=r.key,i=r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}}}}el.create=(e,t,r)=>new el({valueType:t,keyType:e,typeName:th.ZodMap,...T(r)});class ec extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.set)return h(a,{code:i.invalid_type,expected:r.set,received:a.parsedType}),f;let s=this._def;null!==s.minSize&&a.data.size<s.minSize.value&&(h(a,{code:i.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&a.data.size>s.maxSize.value&&(h(a,{code:i.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let n=this._def.valueType;function o(e){let r=new Set;for(let a of e){if("aborted"===a.status)return f;"dirty"===a.status&&t.dirty(),r.add(a.value)}return{status:t.value,value:r}}let p=[...a.data.values()].map((e,t)=>n._parse(new x(a,e,a.path,t)));return a.common.async?Promise.all(p).then(e=>o(e)):o(p)}min(e,t){return new ec({...this._def,minSize:{value:e,message:tu.toString(t)}})}max(e,t){return new ec({...this._def,maxSize:{value:e,message:tu.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ec.create=(e,t)=>new ec({valueType:e,minSize:null,maxSize:null,typeName:th.ZodSet,...T(t)});class eu extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.function)return h(t,{code:i.invalid_type,expected:r.function,received:t.parsedType}),f;function a(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:r}})}function s(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:r}})}let d={errorMap:t.common.contextualErrorMap},l=t.data;if(this._def.returns instanceof ey){let e=this;return v(async function(...t){let r=new n([]),i=await e._def.args.parseAsync(t,d).catch(e=>{throw r.addIssue(a(t,e)),r}),o=await Reflect.apply(l,this,i);return await e._def.returns._def.type.parseAsync(o,d).catch(e=>{throw r.addIssue(s(o,e)),r})})}{let e=this;return v(function(...t){let r=e._def.args.safeParse(t,d);if(!r.success)throw new n([a(t,r.error)]);let i=Reflect.apply(l,this,r.data),o=e._def.returns.safeParse(i,d);if(!o.success)throw new n([s(i,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new eu({...this._def,args:ep.create(e).rest(X.create())})}returns(e){return new eu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new eu({args:e||ep.create([]).rest(X.create()),returns:t||X.create(),typeName:th.ZodFunction,...T(r)})}}class eh extends E{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}eh.create=(e,t)=>new eh({getter:e,typeName:th.ZodLazy,...T(t)});class em extends E{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ef(e,t){return new eg({values:e,typeName:th.ZodEnum,...T(t)})}em.create=(e,t)=>new em({value:e,typeName:th.ZodLiteral,...T(t)});class eg extends E{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:tl.joinValues(r),received:t.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:i.invalid_enum_value,options:r}),f}return v(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return eg.create(e,{...this._def,...t})}exclude(e,t=this._def){return eg.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eg.create=ef;class ev extends E{_parse(e){let t=tl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==r.string&&a.parsedType!==r.number){let e=tl.objectValues(t);return h(a,{expected:tl.joinValues(e),received:a.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(tl.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=tl.objectValues(t);return h(a,{received:a.data,code:i.invalid_enum_value,options:e}),f}return v(e.data)}get enum(){return this._def.values}}ev.create=(e,t)=>new ev({values:e,typeName:th.ZodNativeEnum,...T(t)});class ey extends E{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==r.promise&&!1===t.common.async?(h(t,{code:i.invalid_type,expected:r.promise,received:t.parsedType}),f):v((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ey.create=(e,t)=>new ey({type:e,typeName:th.ZodPromise,...T(t)});class ew extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===th.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:e=>{h(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===a.type){let e=a.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return f;let a=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a});{if("aborted"===t.value)return f;let a=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a}}if("refinement"===a.type){let e=e=>{let t=a.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?f:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===a.status?f:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}}if("transform"===a.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>b(e)?Promise.resolve(a.transform(e.value,i)).then(e=>({status:t.value,value:e})):f);else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!b(e))return f;let s=a.transform(e.value,i);if(s instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}tl.assertNever(a)}}ew.create=(e,t,r)=>new ew({schema:e,typeName:th.ZodEffects,effect:t,...T(r)}),ew.createWithPreprocess=(e,t,r)=>new ew({schema:t,effect:{type:"preprocess",transform:e},typeName:th.ZodEffects,...T(r)});class eb extends E{_parse(e){return this._getType(e)===r.undefined?v(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eb.create=(e,t)=>new eb({innerType:e,typeName:th.ZodOptional,...T(t)});class e_ extends E{_parse(e){return this._getType(e)===r.null?v(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}e_.create=(e,t)=>new e_({innerType:e,typeName:th.ZodNullable,...T(t)});class ex extends E{_parse(e){let{ctx:t}=this._processInputParams(e),a=t.data;return t.parsedType===r.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ex.create=(e,t)=>new ex({innerType:e,typeName:th.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...T(t)});class eN extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _(a)?a.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}eN.create=(e,t)=>new eN({innerType:e,typeName:th.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...T(t)});class eT extends E{_parse(e){if(this._getType(e)!==r.nan){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.nan,received:t.parsedType}),f}return{status:"valid",value:e.data}}}eT.create=e=>new eT({typeName:th.ZodNaN,...T(e)});let eE=Symbol("zod_brand");class eA extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class eS extends E{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),g(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new eS({in:e,out:t,typeName:th.ZodPipeline})}}class ek extends E{_parse(e){let t=this._def.innerType._parse(e),r=e=>(b(e)&&(e.value=Object.freeze(e.value)),e);return _(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}function eO(e,t){let r="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof r?{message:r}:r}function eC(e,t={},r){return e?Y.create().superRefine((a,i)=>{let s=e(a);if(s instanceof Promise)return s.then(e=>{if(!e){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}});if(!s){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}}):Y.create()}ek.create=(e,t)=>new ek({innerType:e,typeName:th.ZodReadonly,...T(t)});let eI={object:ea.lazycreate};(td=th||(th={})).ZodString="ZodString",td.ZodNumber="ZodNumber",td.ZodNaN="ZodNaN",td.ZodBigInt="ZodBigInt",td.ZodBoolean="ZodBoolean",td.ZodDate="ZodDate",td.ZodSymbol="ZodSymbol",td.ZodUndefined="ZodUndefined",td.ZodNull="ZodNull",td.ZodAny="ZodAny",td.ZodUnknown="ZodUnknown",td.ZodNever="ZodNever",td.ZodVoid="ZodVoid",td.ZodArray="ZodArray",td.ZodObject="ZodObject",td.ZodUnion="ZodUnion",td.ZodDiscriminatedUnion="ZodDiscriminatedUnion",td.ZodIntersection="ZodIntersection",td.ZodTuple="ZodTuple",td.ZodRecord="ZodRecord",td.ZodMap="ZodMap",td.ZodSet="ZodSet",td.ZodFunction="ZodFunction",td.ZodLazy="ZodLazy",td.ZodLiteral="ZodLiteral",td.ZodEnum="ZodEnum",td.ZodEffects="ZodEffects",td.ZodNativeEnum="ZodNativeEnum",td.ZodOptional="ZodOptional",td.ZodNullable="ZodNullable",td.ZodDefault="ZodDefault",td.ZodCatch="ZodCatch",td.ZodPromise="ZodPromise",td.ZodBranded="ZodBranded",td.ZodPipeline="ZodPipeline",td.ZodReadonly="ZodReadonly";let eR=(e,t={message:`Input not instance of ${e.name}`})=>eC(t=>t instanceof e,t),eD=W.create,eP=$.create,ej=eT.create,eq=G.create,eL=H.create,eM=K.create,eF=J.create,eU=Z.create,eB=Q.create,eV=Y.create,ez=X.create,eW=ee.create,e$=et.create,eG=er.create,eH=ea.create,eK=ea.strictCreate,eJ=ei.create,eZ=en.create,eQ=eo.create,eY=ep.create,eX=ed.create,e1=el.create,e0=ec.create,e2=eu.create,e6=eh.create,e4=em.create,e3=eg.create,e9=ev.create,e5=ey.create,e8=ew.create,e7=eb.create,te=e_.create,tt=ew.createWithPreprocess,tr=eS.create,ta=()=>eD().optional(),ti=()=>eP().optional(),ts=()=>eL().optional(),tn={string:e=>W.create({...e,coerce:!0}),number:e=>$.create({...e,coerce:!0}),boolean:e=>H.create({...e,coerce:!0}),bigint:e=>G.create({...e,coerce:!0}),date:e=>K.create({...e,coerce:!0})};e.s(["BRAND",0,eE,"NEVER",0,f,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"instanceof",()=>eR,"intersection",()=>eQ,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"record",()=>eX,"set",()=>e0,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"void",()=>e$],73023),e.i(73023),e.i(21466),e.s(["BRAND",0,eE,"DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"NEVER",0,f,"OK",0,v,"ParseStatus",()=>m,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodError",()=>n,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodIssueCode",0,i,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodParsedType",0,r,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"addIssueToContext",()=>h,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"defaultErrorMap",0,o,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"getErrorMap",()=>l,"getParsedType",0,a,"instanceof",()=>eR,"intersection",()=>eQ,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"makeIssue",0,c,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"objectUtil",()=>tc,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"quotelessJson",0,s,"record",()=>eX,"set",()=>e0,"setErrorMap",()=>d,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"util",()=>tl,"void",()=>e$],59063);var to,tp,td,tl,tc,tu,th,tm=e.i(59063);e.s(["z",0,tm],16172)},96401,e=>{"use strict";var t=e.i(16172);let r=t.z.enum(["local","postgres"]),a=t.z.enum(["local","gcs"]),i=t.z.object({serverPepper:t.z.string().min(1),standaloneMode:t.z.boolean().default(!1),storeTypes:t.z.object({global:r,log:r.optional(),app:r.optional(),blob:a}),paths:t.z.object({localStore:t.z.string().min(1),blobStore:t.z.string().min(1)}),gcs:t.z.object({bucketName:t.z.string().optional()})}),s={serverPepper:process.env.API_KEY_PEPPER||"default-pepper-change-in-production",standaloneMode:"false"!==process.env.AILOG_STANDALONE_MODE,storeTypes:{global:process.env.STORE_TYPE||"local",log:process.env.LOG_STORE_TYPE,app:process.env.APP_STORE_TYPE,blob:process.env.BLOB_STORE_TYPE||"local"},paths:{localStore:process.env.LOCAL_STORE_PATH||"./.ailog/data",blobStore:process.env.BLOB_STORE_LOCAL_PATH||"./data/blobs"},gcs:{bucketName:process.env.GCS_BUCKET_NAME}},n=i.parse(s),o={log:n.storeTypes.log??n.storeTypes.global,app:n.storeTypes.app??n.storeTypes.global,blob:n.storeTypes.blob};e.s(["config",0,n,"resolvedStoreTypes",0,o])},13558,e=>{"use strict";var t=e.i(30314),r=/^[\w!#$%&'*.^`|~+-]+$/,a=/^[ !#-:<-[\]-~]*$/,i=(e,i)=>{if(i&&-1===e.indexOf(i))return{};let s=e.trim().split(";"),n={};for(let e of s){let s=(e=e.trim()).indexOf("=");if(-1===s)continue;let o=e.substring(0,s).trim();if(i&&i!==o||!r.test(o))continue;let p=e.substring(s+1).trim();if(p.startsWith('"')&&p.endsWith('"')&&(p=p.slice(1,-1)),a.test(p)&&(n[o]=-1!==p.indexOf("%")?(0,t.tryDecode)(p,t.decodeURIComponent_):p,i))break}return n},s=e.i(80253),n=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,o=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,p=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;let d=function(e,t,r,a){let d;return d=async(i,s)=>{let n=i;if("header"===e&&"_def"in t||"header"===e&&"_zod"in t){let e=Object.fromEntries(Object.keys("in"in t?t.in.shape:t.shape).map(e=>[e.toLowerCase(),e]));n=Object.fromEntries(Object.entries(i).map(([t,r])=>[e[t]||t,r]))}let o=a&&a.validationFunction?await a.validationFunction(t,n):await t.safeParseAsync(n);if(r){let t=await r({data:n,...o,target:e},s);if(t){if(t instanceof Response)return t;if("response"in t)return t.response}}return o.success?o.data:s.json(o,400)},async(t,r)=>{let a={},l=t.req.header("Content-Type");switch(e){case"json":if(!l||!n.test(l))break;try{a=await t.req.json()}catch{throw new s.HTTPException(400,{message:"Malformed JSON in request body"})}break;case"form":{let e;if(!l||!(o.test(l)||p.test(l)))break;if(t.req.bodyCache.formData)e=await t.req.bodyCache.formData;else try{let r=await t.req.arrayBuffer();e=await new Response(r,{headers:{"Content-Type":l}}).formData(),t.req.bodyCache.formData=e}catch(t){let e="Malformed FormData request.";throw e+=t instanceof Error?` ${t.message}`:` ${String(t)}`,new s.HTTPException(400,{message:e})}let r={};e.forEach((e,t)=>{t.endsWith("[]")?(r[t]??=[]).push(e):Array.isArray(r[t])?r[t].push(e):t in r?r[t]=[r[t],e]:r[t]=e}),a=r;break}case"query":a=Object.fromEntries(Object.entries(t.req.queries()).map(([e,t])=>1===t.length?[e,t[0]]:[e,t]));break;case"param":a=t.req.param();break;case"header":a=t.req.header();break;case"cookie":a=((e,t,r)=>{let a=e.req.raw.headers.get("Cookie");if("string"==typeof t){if(!a)return;let e=t;return"secure"===r?e="__Secure-"+t:"host"===r&&(e="__Host-"+t),i(a,e)[e]}return a?i(a):{}})(t)}let c=await d(a,t);return c instanceof Response?c:(t.req.addValidatedData(e,c),await r())}};e.s(["zValidator",()=>d],13558)},84739,482,62212,79044,56967,6697,54199,6937,80864,90348,56900,22177,46220,40203,9581,83013,50430,72866,29986,27539,34939,2758,90640,46432,13424,82258,45393,86566,72515,21797,51014,67204,87799,e=>{"use strict";function t(e){return void 0===e||void 0===e}function r(e){return"string"==typeof e}function a(e){return"number"==typeof e}function i(e){return"boolean"==typeof e}function s(e){return null===e}function n(e){return e instanceof Date}function o(e){return"bigint"==typeof e}function p(e){return"function"==typeof e}function d(e){return"object"==typeof e&&null!==e}function l(e){return e[e.length-1]}function c(e){return Object.freeze(e)}function u(e){return h(e)?e:[e]}function h(e){return Array.isArray(e)}function m(e){return e}Object.prototype.toString,e.s(["asArray",()=>u,"freeze",()=>c,"getLast",()=>l,"isBigInt",()=>o,"isBoolean",()=>i,"isDate",()=>n,"isFunction",()=>p,"isNull",()=>s,"isNumber",()=>a,"isObject",()=>d,"isReadonlyArray",()=>h,"isString",()=>r,"isUndefined",()=>t,"noop",()=>m],84739);let f=c({is:e=>"IdentifierNode"===e.kind,create:e=>c({kind:"IdentifierNode",name:e})});e.s(["IdentifierNode",0,f],482);let g=c({is:e=>"SchemableIdentifierNode"===e.kind,create:e=>c({kind:"SchemableIdentifierNode",identifier:f.create(e)}),createWithSchema:(e,t)=>c({kind:"SchemableIdentifierNode",schema:f.create(e),identifier:f.create(t)})});e.s(["SchemableIdentifierNode",0,g],62212),e.s(["parseAliasedTable",()=>rt,"parseTable",()=>rr,"parseTableExpression",()=>re,"parseTableExpressionOrList",()=>t7],87799);let v=c({is:e=>"AliasNode"===e.kind,create:(e,t)=>c({kind:"AliasNode",node:e,alias:t})});e.s(["AliasNode",0,v],79044);let y=c({is:e=>"TableNode"===e.kind,create:e=>c({kind:"TableNode",table:g.create(e)}),createWithSchema:(e,t)=>c({kind:"TableNode",table:g.createWithSchema(e,t)})});function w(e){return d(e)&&p(e.toOperationNode)}e.s(["isExpressionOrFactory",()=>t8,"parseAliasedExpression",()=>t5,"parseExpression",()=>t9],67204),e.s(["isOperationNodeSource",()=>w],56967);let b=c({is:e=>"SelectModifierNode"===e.kind,create:(e,t)=>c({kind:"SelectModifierNode",modifier:e,of:t}),createWithExpression:e=>c({kind:"SelectModifierNode",rawModifier:e})}),_=c({is:e=>"AndNode"===e.kind,create:(e,t)=>c({kind:"AndNode",left:e,right:t})}),x=c({is:e=>"OrNode"===e.kind,create:(e,t)=>c({kind:"OrNode",left:e,right:t})}),N=c({is:e=>"OnNode"===e.kind,create:e=>c({kind:"OnNode",on:e}),cloneWithOperation:(e,t,r)=>c({...e,on:"And"===t?_.create(e.on,r):x.create(e.on,r)})}),T=c({is:e=>"JoinNode"===e.kind,create:(e,t)=>c({kind:"JoinNode",joinType:e,table:t,on:void 0}),createWithOn:(e,t,r)=>c({kind:"JoinNode",joinType:e,table:t,on:N.create(r)}),cloneWithOn:(e,t)=>c({...e,on:e.on?N.cloneWithOperation(e.on,"And",t):N.create(t)})});e.s(["parseFilterList",()=>ec,"parseFilterObject",()=>el,"parseReferentialBinaryOperation",()=>ed,"parseValueBinaryOperation",()=>ep,"parseValueBinaryOperationOrExpression",()=>eo],83013);let E=c({is:e=>"BinaryOperationNode"===e.kind,create:(e,t,r)=>c({kind:"BinaryOperationNode",leftOperand:e,operator:t,rightOperand:r})}),A=["->","->>"],S=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from","+","-","*","/","%","^","&","|","#","<<",">>","&&","||",...A,"not","-","exists","not exists","between","between symmetric"],k=c({is:e=>"OperatorNode"===e.kind,create:e=>c({kind:"OperatorNode",operator:e})});function O(e){return r(e)&&A.includes(e)}e.s(["OPERATORS",0,S,"OperatorNode",0,k,"isJSONOperator",()=>O],6697),e.s(["parseAliasedStringReference",()=>J,"parseColumnName",()=>Z,"parseJSONReference",()=>H,"parseOrderedColumnName",()=>Q,"parseReferenceExpression",()=>G,"parseReferenceExpressionOrList",()=>$,"parseSimpleReferenceExpression",()=>W,"parseStringReference",()=>K],56900);let C=c({is:e=>"ColumnNode"===e.kind,create:e=>c({kind:"ColumnNode",column:f.create(e)})});e.s(["ColumnNode",0,C],54199);let I=c({is:e=>"SelectAllNode"===e.kind,create:()=>c({kind:"SelectAllNode"})});e.s(["SelectAllNode",0,I],6937);let R=c({is:e=>"ReferenceNode"===e.kind,create:(e,t)=>c({kind:"ReferenceNode",table:t,column:e}),createSelectAll:e=>c({kind:"ReferenceNode",table:e,column:I.create()})});e.s(["DynamicReferenceBuilder",()=>D,"isDynamicReferenceBuilder",()=>P],80864);class D{#L;get dynamicReference(){return this.#L}get refType(){}constructor(e){this.#L=e}toOperationNode(){return W(this.#L)}}function P(e){return d(e)&&w(e)&&r(e.dynamicReference)}let j=c({is:e=>"OrderByItemNode"===e.kind,create:(e,t)=>c({kind:"OrderByItemNode",orderBy:e,direction:t})}),q=c({is:e=>"RawNode"===e.kind,create:(e,t)=>c({kind:"RawNode",sqlFragments:c(e),parameters:c(t)}),createWithSql:e=>q.create([e],[]),createWithChild:e=>q.create(["",""],[e]),createWithChildren:e=>q.create(Array(e.length+1).fill(""),e)});function L(e){return"asc"===e||"desc"===e}function M(e){if(2===e.length)return[F(e[0],e[1])];if(1===e.length){let[t]=e;return Array.isArray(t)?t.map(e=>F(e)):[F(t)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function F(e,t){let r=function(e){if(t8(e))return t9(e);if(P(e))return e.toOperationNode();let[t,r]=e.split(" ");if(r){if(!L(r))throw Error(`Invalid order by direction: ${r}`);return j.create(K(t),U(r))}return K(e)}(e);if(j.is(r)){if(t)throw Error("Cannot specify direction twice!");return r}return j.create(r,U(t))}function U(e){if(e)return"asc"===e||"desc"===e?q.createWithSql(e):e.toOperationNode()}e.s(["RawNode",0,q],90348);let B=c({is:e=>"JSONReferenceNode"===e.kind,create:(e,t)=>c({kind:"JSONReferenceNode",reference:e,traversal:t}),cloneWithTraversal:(e,t)=>c({...e,traversal:t})}),V=c({is:e=>"JSONOperatorChainNode"===e.kind,create:e=>c({kind:"JSONOperatorChainNode",operator:e,values:c([])}),cloneWithValue:(e,t)=>c({...e,values:c([...e.values,t])})}),z=c({is:e=>"JSONPathNode"===e.kind,create:e=>c({kind:"JSONPathNode",inOperator:e,pathLegs:c([])}),cloneWithLeg:(e,t)=>c({...e,pathLegs:c([...e.pathLegs,t])})});function W(e){return r(e)?K(e):e.toOperationNode()}function $(e){return h(e)?e.map(e=>G(e)):[G(e)]}function G(e){return t8(e)?t9(e):W(e)}function H(e,t){let r=K(e);if(O(t))return B.create(r,V.create(k.create(t)));let a=t.slice(0,-1);if(O(a))return B.create(r,z.create(k.create(a)));throw Error(`Invalid JSON operator: ${t}`)}function K(e){if(!e.includes("."))return R.create(C.create(e));let t=e.split(".").map(Y);if(3===t.length)return function(e){let[t,r,a]=e;return R.create(C.create(a),y.createWithSchema(t,r))}(t);if(2===t.length)return function(e){let[t,r]=e;return R.create(C.create(r),y.create(t))}(t);throw Error(`invalid column reference ${e}`)}function J(e){let t=" as ";if(!e.includes(t))return K(e);{let[r,a]=e.split(t).map(Y);return v.create(K(r),f.create(a))}}function Z(e){return C.create(e)}function Q(e){if(!e.includes(" "))return Z(e);{let[t,r]=e.split(" ").map(Y);if(!L(r))throw Error(`invalid order direction "${r}" next to "${t}"`);return M([t,r])[0]}}function Y(e){return e.trim()}e.s(["isSafeImmediateValue",()=>ei,"parseSafeImmediateValue",()=>es,"parseValueExpression",()=>ea,"parseValueExpressionOrList",()=>er],40203);let X=c({is:e=>"PrimitiveValueListNode"===e.kind,create:e=>c({kind:"PrimitiveValueListNode",values:c([...e])})}),ee=c({is:e=>"ValueListNode"===e.kind,create:e=>c({kind:"ValueListNode",values:c(e)})});e.s(["ValueListNode",0,ee],22177);let et=c({is:e=>"ValueNode"===e.kind,create:e=>c({kind:"ValueNode",value:e}),createImmediate:e=>c({kind:"ValueNode",value:e,immediate:!0})});function er(e){var t;return h(e)?(t=e).some(t8)?ee.create(t.map(e=>ea(e))):X.create(t):ea(e)}function ea(e){return t8(e)?t9(e):et.create(e)}function ei(e){return a(e)||i(e)||s(e)}function es(e){if(!ei(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return et.createImmediate(e)}e.s(["ValueNode",0,et],46220);let en=c({is:e=>"ParensNode"===e.kind,create:e=>c({kind:"ParensNode",node:e})});function eo(e){if(3===e.length)return ep(e[0],e[1],e[2]);if(1===e.length)return ea(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function ep(e,t,r){var a,n;return("is"===(a=t)||"is not"===a)&&(s(n=r)||i(n))?E.create(G(e),eu(t),et.createImmediate(r)):E.create(G(e),eu(t),er(r))}function ed(e,t,r){return E.create(G(e),eu(t),G(r))}function el(e,r){return ec(Object.entries(e).filter(([,e])=>!t(e)).map(([e,t])=>{var r;return ep(e,s(r=t)||i(r)?"is":"=",t)}),r)}function ec(e,t,r=!0){let a="and"===t?_.create:x.create;if(0===e.length)return E.create(et.createImmediate(1),k.create("="),et.createImmediate(+("and"===t)));let i=eh(e[0]);for(let t=1;t<e.length;++t)i=a(i,eh(e[t]));return e.length>1&&r?en.create(i):i}e.s(["ParensNode",0,en],9581);function eu(e){if(r(e)&&S.includes(e))return k.create(e);if(w(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function eh(e){return w(e)?e.toOperationNode():e}let em=c({is:e=>"OrderByNode"===e.kind,create:e=>c({kind:"OrderByNode",items:c([...e])}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ef=c({is:e=>"PartitionByNode"===e.kind,create:e=>c({kind:"PartitionByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),eg=c({is:e=>"OverNode"===e.kind,create:()=>c({kind:"OverNode"}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithPartitionByItems:(e,t)=>c({...e,partitionBy:e.partitionBy?ef.cloneWithItems(e.partitionBy,t):ef.create(t)})}),ev=c({is:e=>"FromNode"===e.kind,create:e=>c({kind:"FromNode",froms:c(e)}),cloneWithFroms:(e,t)=>c({...e,froms:c([...e.froms,...t])})}),ey=c({is:e=>"GroupByNode"===e.kind,create:e=>c({kind:"GroupByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ew=c({is:e=>"HavingNode"===e.kind,create:e=>c({kind:"HavingNode",having:e}),cloneWithOperation:(e,t,r)=>c({...e,having:"And"===t?_.create(e.having,r):x.create(e.having,r)})}),eb=c({is:e=>"SelectQueryNode"===e.kind,create:e=>c({kind:"SelectQueryNode",...e&&{with:e}}),createFrom:(e,t)=>c({kind:"SelectQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)}),cloneWithDistinctOn:(e,t)=>c({...e,distinctOn:e.distinctOn?c([...e.distinctOn,...t]):c(t)}),cloneWithFrontModifier:(e,t)=>c({...e,frontModifiers:e.frontModifiers?c([...e.frontModifiers,t]):c([t])}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithGroupByItems:(e,t)=>c({...e,groupBy:e.groupBy?ey.cloneWithItems(e.groupBy,t):ey.create(t)}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithOffset:(e,t)=>c({...e,offset:t}),cloneWithFetch:(e,t)=>c({...e,fetch:t}),cloneWithHaving:(e,t)=>c({...e,having:e.having?ew.cloneWithOperation(e.having,"And",t):ew.create(t)}),cloneWithSetOperations:(e,t)=>c({...e,setOperations:e.setOperations?c([...e.setOperations,...t]):c([...t])}),cloneWithoutSelections:e=>c({...e,selections:[]}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithoutOffset:e=>c({...e,offset:void 0}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithoutGroupBy:e=>c({...e,groupBy:void 0})});function e_(e,t){Object.defineProperties(e.prototype,{then:{enumerable:!1,value:()=>{throw Error(t)}}})}e.s(["preventAwait",()=>e_],50430);class ex{#M;constructor(e){this.#M=c(e)}on(...e){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,eo(e))})}onRef(e,t,r){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,ed(e,t,r))})}onTrue(){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,q.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#M.joinNode}}e_(ex,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");let eN=c({is:e=>"PartitionByItemNode"===e.kind,create:e=>c({kind:"PartitionByItemNode",partitionBy:e})});class eT{#M;constructor(e){this.#M=c(e)}orderBy(e,t){return new eT({overNode:eg.cloneWithOrderByItems(this.#M.overNode,M([e,t]))})}partitionBy(e){return new eT({overNode:eg.cloneWithPartitionByItems(this.#M.overNode,$(e).map(eN.create))})}$call(e){return e(this)}toOperationNode(){return this.#M.overNode}}e_(eT,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query."),e.s(["QueryCreator",()=>tA],82258);let eE=c({is:e=>"SelectionNode"===e.kind,create:e=>c({kind:"SelectionNode",selection:e}),createSelectAll:()=>c({kind:"SelectionNode",selection:I.create()}),createSelectAllFromTable:e=>c({kind:"SelectionNode",selection:R.createSelectAll(e)})});function eA(e){return p(e)?eA(e(t3())):h(e)?e.map(e=>eS(e)):[eS(e)]}function eS(e){return r(e)?eE.create(J(e)):P(e)?eE.create(e.toOperationNode()):eE.create(t5(e))}function ek(e){return e?Array.isArray(e)?e.map(eO):[eO(e)]:[eE.createSelectAll()]}function eO(e){if(r(e))return eE.createSelectAllFromTable(rr(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}let eC=c({is:e=>"ValuesNode"===e.kind,create:e=>c({kind:"ValuesNode",values:c(e)})}),eI=c({is:e=>"DefaultInsertValueNode"===e.kind,create:()=>c({kind:"DefaultInsertValueNode"})});function eR(e){var r;let a,i=p(e)?e(t3()):e;return a=function(e){let t=new Map;for(let r of e)for(let e of Object.keys(r))t.has(e)||void 0===r[e]||t.set(e,t.size);return t}(r=h(i)?i:c([i])),[c([...a.keys()].map(C.create)),eC.create(r.map(e=>(function(e,r){let a=Object.keys(e),i=Array.from({length:r.size}),s=!1,n=a.length;for(let o of a){let a=r.get(o);if(t(a)){n--;continue}let p=e[o];(t(p)||t8(p))&&(s=!0),i[a]=p}if(n<r.size||s){let e=eI.create();return ee.create(i.map(r=>t(r)?e:ea(r)))}return X.create(i)})(e,a)))]}let eD=c({is:e=>"InsertQueryNode"===e.kind,create:(e,t,r)=>c({kind:"InsertQueryNode",into:e,...t&&{with:t},replace:r}),createWithoutInto:()=>c({kind:"InsertQueryNode"}),cloneWith:(e,t)=>c({...e,...t})});e.s(["InsertQueryNode",0,eD],72866);let eP=c({is:e=>"UpdateQueryNode"===e.kind,create:(e,t)=>c({kind:"UpdateQueryNode",table:e,...t&&{with:t}}),createWithoutTable:()=>c({kind:"UpdateQueryNode"}),cloneWithFromItems:(e,t)=>c({...e,from:e.from?ev.cloneWithFroms(e.from,t):ev.create(t)}),cloneWithUpdates:(e,t)=>c({...e,updates:e.updates?c([...e.updates,...t]):t}),cloneWithLimit:(e,t)=>c({...e,limit:t})}),ej=c({is:e=>"UsingNode"===e.kind,create:e=>c({kind:"UsingNode",tables:c(e)}),cloneWithTables:(e,t)=>c({...e,tables:c([...e.tables,...t])})}),eq=c({is:e=>"DeleteQueryNode"===e.kind,create:(e,t)=>c({kind:"DeleteQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithUsing:(e,t)=>c({...e,using:void 0!==e.using?ej.cloneWithTables(e.using,t):ej.create(t)})}),eL=c({is:e=>"WhereNode"===e.kind,create:e=>c({kind:"WhereNode",where:e}),cloneWithOperation:(e,t,r)=>c({...e,where:"And"===t?_.create(e.where,r):x.create(e.where,r)})}),eM=c({is:e=>"ReturningNode"===e.kind,create:e=>c({kind:"ReturningNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),eF=c({is:e=>"ExplainNode"===e.kind,create:(e,t)=>c({kind:"ExplainNode",format:e,options:t})}),eU=c({is:e=>"WhenNode"===e.kind,create:e=>c({kind:"WhenNode",condition:e}),cloneWithResult:(e,t)=>c({...e,result:t})}),eB=c({is:e=>"MergeQueryNode"===e.kind,create:(e,t)=>c({kind:"MergeQueryNode",into:e,...t&&{with:t}}),cloneWithUsing:(e,t)=>c({...e,using:t}),cloneWithWhen:(e,t)=>c({...e,whens:e.whens?c([...e.whens,t]):c([t])}),cloneWithThen:(e,t)=>c({...e,whens:e.whens?c([...e.whens.slice(0,-1),eU.cloneWithResult(e.whens[e.whens.length-1],t)]):void 0})});e.s(["MergeQueryNode",0,eB],29986);let eV=c({is:e=>"OutputNode"===e.kind,create:e=>c({kind:"OutputNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),ez=c({is:e=>eb.is(e)||eD.is(e)||eP.is(e)||eq.is(e)||eB.is(e),cloneWithEndModifier:(e,t)=>c({...e,endModifiers:e.endModifiers?c([...e.endModifiers,t]):c([t])}),cloneWithWhere:(e,t)=>c({...e,where:e.where?eL.cloneWithOperation(e.where,"And",t):eL.create(t)}),cloneWithJoin:(e,t)=>c({...e,joins:e.joins?c([...e.joins,t]):c([t])}),cloneWithReturning:(e,t)=>c({...e,returning:e.returning?eM.cloneWithSelections(e.returning,t):eM.create(t)}),cloneWithoutReturning:e=>c({...e,returning:void 0}),cloneWithoutWhere:e=>c({...e,where:void 0}),cloneWithExplain:(e,t,r)=>c({...e,explain:eF.create(t,r?.toOperationNode())}),cloneWithTop:(e,t)=>c({...e,top:t}),cloneWithOutput:(e,t)=>c({...e,output:e.output?eV.cloneWithSelections(e.output,t):eV.create(t)})});e.s(["QueryNode",0,ez],27539);let eW=c({is:e=>"ColumnUpdateNode"===e.kind,create:(e,t)=>c({kind:"ColumnUpdateNode",column:e,value:t})});function e$(e){return Object.entries(p(e)?e(t3()):e).filter(([e,t])=>void 0!==t).map(([e,t])=>eW.create(C.create(e),ea(t)))}let eG=c({is:e=>"OnDuplicateKeyNode"===e.kind,create:e=>c({kind:"OnDuplicateKeyNode",updates:e})});class eH{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}}class eK extends Error{node;constructor(e){super("no result"),this.node=e}}function eJ(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}let eZ=c({is:e=>"OnConflictNode"===e.kind,create:()=>c({kind:"OnConflictNode"}),cloneWith:(e,t)=>c({...e,...t}),cloneWithIndexWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"And",t):eL.create(t)}),cloneWithIndexOrWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"Or",t):eL.create(t)}),cloneWithUpdateWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"And",t):eL.create(t)}),cloneWithUpdateOrWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"Or",t):eL.create(t)}),cloneWithoutIndexWhere:e=>c({...e,indexWhere:void 0}),cloneWithoutUpdateWhere:e=>c({...e,updateWhere:void 0})});class eQ{#M;constructor(e){this.#M=c(e)}column(e){let t=C.create(e);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,t]):c([t])})})}columns(e){let t=e.map(C.create);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,...t]):c(t)})})}constraint(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{constraint:f.create(e)})})}expression(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eQ({...this.#M,onConflictNode:eZ.cloneWithoutIndexWhere(this.#M.onConflictNode)})}doNothing(){return new eY({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new eX({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{updates:e$(e)})})}$call(e){return e(this)}}e_(eQ,"don't await OnConflictBuilder instances.");class eY{#M;constructor(e){this.#M=c(e)}toOperationNode(){return this.#M.onConflictNode}}e_(eY,"don't await OnConflictDoNothingBuilder instances.");class eX{#M;constructor(e){this.#M=c(e)}where(...e){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eX({...this.#M,onConflictNode:eZ.cloneWithoutUpdateWhere(this.#M.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#M.onConflictNode}}e_(eX,"don't await OnConflictUpdateBuilder instances.");let e1=c({is:e=>"TopNode"===e.kind,create:(e,t)=>c({kind:"TopNode",expression:e,modifiers:t})});function e0(e,r){var i;if(!a(e)&&!o(e))throw Error(`Invalid top expression: ${e}`);if(!t(r)&&"percent"!==(i=r)&&"with ties"!==i&&"percent with ties"!==i)throw Error(`Invalid top modifiers: ${r}`);return e1.create(e,r)}class e2{#M;constructor(e){this.#M=c(e)}values(e){let[t,r]=eR(e);return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:t,values:r})})}columns(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:c(e.map(C.create))})})}expression(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{values:t9(e)})})}defaultValues(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{defaultValues:!0})})}modifyEnd(e){return new e2({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}ignore(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{ignore:!0})})}top(e,t){return new e2({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}onConflict(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onConflict:e(new eQ({onConflictNode:eZ.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onDuplicateKey:eG.create(e$(e))})})}returning(e){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek())})}output(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e2({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e2({...this.#M})}$castTo(){return new e2(this.#M)}$narrowType(){return new e2(this.#M)}$assertType(){return new e2(this.#M)}withPlugin(e){return new e2({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new eH(t.insertId,t.numAffectedRows??t.numUpdatedOrDeletedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e2({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e2,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e6{numDeletedRows;constructor(e){this.numDeletedRows=e}}let e4=c({is:e=>"LimitNode"===e.kind,create:e=>c({kind:"LimitNode",limit:e})});class e3{#M;constructor(e){this.#M=c(e)}where(...e){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e3({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e3({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(e){return new e3({...this.#M,queryNode:eq.cloneWithUsing(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}returning(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e3({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}clearLimit(){return new e3({...this.#M,queryNode:eq.cloneWithoutLimit(this.#M.queryNode)})}clearOrderBy(){return new e3({...this.#M,queryNode:eq.cloneWithoutOrderBy(this.#M.queryNode)})}orderBy(e,t){return new e3({...this.#M,queryNode:eq.cloneWithOrderByItems(this.#M.queryNode,M([e,t]))})}limit(e){return new e3({...this.#M,queryNode:eq.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}modifyEnd(e){return new e3({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new e3({...this.#M})}$castTo(){return new e3(this.#M)}$narrowType(){return new e3(this.#M)}$assertType(){return new e3(this.#M)}withPlugin(e){return new e3({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e6(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e3({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e3,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e9{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}}class e5{#M;constructor(e){this.#M=c(e)}where(...e){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e5({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e5({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}from(e){return new e5({...this.#M,queryNode:eP.cloneWithFromItems(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}limit(e){return new e5({...this.#M,queryNode:eP.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}set(...e){return new e5({...this.#M,queryNode:eP.cloneWithUpdates(this.#M.queryNode,function(...e){return 2===e.length?[eW.create(G(e[0]),ea(e[1]))]:e$(e[0])}(...e))})}returning(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}modifyEnd(e){return new e5({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}clearReturning(){return new e5({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e5({...this.#M})}$castTo(){return new e5(this.#M)}$narrowType(){return new e5(this.#M)}$assertType(){return new e5(this.#M)}withPlugin(e){return new e5({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e9(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e5({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e5,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");let e8=c({is:e=>"CommonTableExpressionNameNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNameNode",table:y.create(e),columns:t?c(t.map(C.create)):void 0})}),e7=c({is:e=>"CommonTableExpressionNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNode",name:e,expression:t}),cloneWith:(e,t)=>c({...e,...t})});class te{#M;constructor(e){this.#M=c(e)}materialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!0})})}notMaterialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!1})})}toOperationNode(){return this.#M.node}}function tt(e,t){var r;let a=t(new tA({executor:tb})).toOperationNode();return p(e)?e((r=a,e=>new te({node:e7.create(tr(e),r)}))).toOperationNode():e7.create(tr(e),a)}function tr(e){if(!e.includes("("))return e8.create(e);{let t=e.split(/[\(\)]/),r=t[0],a=t[1].split(",").map(e=>e.trim());return e8.create(r,a)}}e_(te,"don't await CTEBuilder instances. They are never executed directly and are always just a part of a query.");let ta=c({is:e=>"WithNode"===e.kind,create:(e,t)=>c({kind:"WithNode",expressions:c([e]),...t}),cloneWithExpression:(e,t)=>c({...e,expressions:c([...e.expressions,t])})}),ti=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function ts(){return new tn}class tn{#F;get queryId(){return void 0===this.#F&&(this.#F=function(e){let t="";for(let e=0;e<8;++e)t+=ti[~~(Math.random()*ti.length)];return t}(0)),this.#F}}e.s(["createQueryId",()=>ts],34939);class to{nodeStack=[];#U=c({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this)});transformNode(e){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e);return this.nodeStack.pop(),c(t)}transformNodeImpl(e){return this.#U[e.kind](e)}transformNodeList(e){return e?c(e.map(e=>this.transformNode(e))):e}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations),fetch:this.transformNode(e.fetch),top:this.transformNode(e.top)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",column:this.transformNode(e.column),table:this.transformNode(e.table)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:c([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain),defaultValues:e.defaultValues,top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),selectQuery:this.transformNode(e.selectQuery)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),explain:this.transformNode(e.explain),limit:this.transformNode(e.limit),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where),nullsNotDistinct:e.nullsNotDistinct}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name),nullsNotDistinct:e.nullsNotDistinct}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),materialized:e.materialized,expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint),addIndex:this.transformNode(e.addIndex),dropIndex:this.transformNode(e.dropIndex)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier),of:this.transformNodeList(e.of)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,orderBy:this.transformNode(e.orderBy),filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}transformTuple(e){return{kind:"TupleNode",values:this.transformNodeList(e.values)}}transformMergeQuery(e){return{kind:"MergeQueryNode",into:this.transformNode(e.into),using:this.transformNode(e.using),whens:this.transformNodeList(e.whens),with:this.transformNode(e.with),top:this.transformNode(e.top),endModifiers:this.transformNodeList(e.endModifiers),output:this.transformNode(e.output)}}transformMatched(e){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e){return{kind:"AddIndexNode",name:this.transformNode(e.name),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists}}transformCast(e){return{kind:"CastNode",expression:this.transformNode(e.expression),dataType:this.transformNode(e.dataType)}}transformFetch(e){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount),modifier:e.modifier}}transformTop(e){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e){return{kind:"OutputNode",selections:this.transformNodeList(e.selections)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}e.s(["OperationNodeTransformer",()=>to],2758);let tp=c({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),td={json_agg:!0,to_json:!0};class tl extends to{#B;#V=new Set;#z=new Set;constructor(e){super(),this.#B=e}transformNodeImpl(e){if(!this.#W(e))return super.transformNodeImpl(e);let t=this.#$(e);for(let e of t)this.#z.add(e);let r=this.#G(e);for(let e of r)this.#V.add(e);let a=super.transformNodeImpl(e);for(let e of r)this.#V.delete(e);for(let e of t)this.#z.delete(e);return a}transformSchemableIdentifier(e){let t=super.transformSchemableIdentifier(e);return t.schema||!this.#V.has(e.identifier.name)?t:{...t,schema:f.create(this.#B)}}transformReferences(e){let t=super.transformReferences(e);return t.table.table.schema?t:{...t,table:y.createWithSchema(this.#B,t.table.table.identifier.name)}}transformAggregateFunction(e){return{...super.transformAggregateFunction({...e,aggregated:[]}),aggregated:this.#H(e,"aggregated")}}transformFunction(e){return{...super.transformFunction({...e,arguments:[]}),arguments:this.#H(e,"arguments")}}#H(e,t){return td[e.func]?e[t].map(e=>!y.is(e)||e.table.schema?this.transformNode(e):{...e,table:this.transformIdentifier(e.table.identifier)}):this.transformNodeList(e[t])}#W(e){return e.kind in tp}#G(e){let t=new Set;if("name"in e&&e.name&&g.is(e.name)&&this.#K(e.name,t),"from"in e&&e.from)for(let r of e.from.froms)this.#J(r,t);if("into"in e&&e.into&&this.#J(e.into,t),"table"in e&&e.table&&this.#J(e.table,t),"joins"in e&&e.joins)for(let r of e.joins)this.#J(r.table,t);return"using"in e&&e.using&&this.#J(e.using,t),t}#$(e){let t=new Set;return"with"in e&&e.with&&this.#Z(e.with,t),t}#J(e,t){let r=y.is(e)?e:v.is(e)&&y.is(e.node)?e.node:null;r&&this.#K(r.table,t)}#K(e,t){let r=e.identifier.name;this.#V.has(r)||this.#z.has(r)||t.add(r)}#Z(e,t){for(let r of e.expressions){let e=r.name.table.table.identifier.name;this.#z.has(e)||t.add(e)}}}class tc{#Q;constructor(e){this.#Q=new tl(e)}transformQuery(e){return this.#Q.transformNode(e.node)}async transformResult(e){return e.result}}e.s(["WithSchemaPlugin",()=>tc],90640);let tu=c({is:e=>"MatchedNode"===e.kind,create:(e,t=!1)=>c({kind:"MatchedNode",not:e,bySource:t})});function th(e,t,r){return eU.create(ec([tu.create(!e.isMatched,e.bySource),...t&&t.length>0?[3===t.length&&r?ed(t[0],t[1],t[2]):eo(t)]:[]],"and",!1))}function tm(e){return r(e)?q.create([e],[]):w(e)?e.toOperationNode():e}class tf{#Y;#X;#ee;constructor(){this.#Y=new Promise((e,t)=>{this.#ee=t,this.#X=e})}get promise(){return this.#Y}resolve=e=>{this.#X&&this.#X(e)};reject=e=>{this.#ee&&this.#ee(e)}}let tg=new Set,tv=c([]);class ty{#et;constructor(e=tv){this.#et=e}get plugins(){return this.#et}transformQuery(e,t){for(let r of this.#et){let a=r.transformQuery({node:e,queryId:t});if(a.kind===e.kind)e=a;else throw Error(`KyselyPlugin.transformQuery must return a node of the same kind that was given to it. The plugin was given a ${e.kind} but it returned a ${a.kind}`)}return e}async executeQuery(e,t){return await this.provideConnection(async r=>{let a=await r.executeQuery(e),i=await this.#er(a,t);return function(e,t){let{numAffectedRows:r}=e;if((void 0!==r||void 0!==e.numUpdatedOrDeletedRows)&&(void 0===r||void 0===t.numAffectedRows)){var a;a="kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.",tg.has(a)||(tg.add(a),console.log(a))}}(a,i),i})}async *stream(e,t,r){let a=new tf,i=new tf;this.provideConnection(async e=>(a.resolve(e),await i.promise)).catch(e=>a.reject(e));let s=await a.promise;try{for await(let a of s.streamQuery(e,t))yield await this.#er(a,r)}finally{i.resolve()}}async #er(e,t){for(let r of this.#et)e=await r.transformResult({result:e,queryId:t});return e}}e.s(["QueryExecutorBase",()=>ty],46432);class tw extends ty{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new tw([...this.plugins,e])}withPlugins(e){return new tw([...this.plugins,...e])}withPluginAtFront(e){return new tw([e,...this.plugins])}withoutPlugins(){return new tw([])}}let tb=new tw;e.s(["NOOP_QUERY_EXECUTOR",0,tb],13424);class t_{numChangedRows;constructor(e){this.numChangedRows=e}}class tx{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tx({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tx({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(...e){return new tN({...this.#M,queryNode:eB.cloneWithUsing(this.#M.queryNode,tS("Using",e))})}output(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}}e_(tx,"don't await MergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tN{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tN({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tN({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}whenMatched(){return this.#ea([])}whenMatchedAnd(...e){return this.#ea(e)}whenMatchedAndRef(e,t,r){return this.#ea([e,t,r],!0)}#ea(e,t){return new tT({...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!0},e,t))})}whenNotMatched(){return this.#ei([])}whenNotMatchedAnd(...e){return this.#ei(e)}whenNotMatchedAndRef(e,t,r){return this.#ei([e,t,r],!0)}whenNotMatchedBySource(){return this.#ei([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#ei(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,r){return this.#ei([e,t,r],!0,!0)}output(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}#ei(e,t=!1,r=!1){let a={...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!1,bySource:r},e,t))};return new(r?tT:tE)(a)}$call(e){return e(this)}$if(e,t){return e?t(this):new tN({...this.#M})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId);return e.query.output&&this.#M.executor.adapter.supportsOutput?t.rows:[new t_(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}}e_(tN,"don't await WheneableMergeQueryBuilder instances directly. To execute the query you need to call `execute`.");class tT{#M;constructor(e){this.#M=c(e)}thenDelete(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("delete"))})}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenUpdate(e){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(e(new e5({queryId:this.#M.queryId,executor:tb,queryNode:eP.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}}e_(tT,"don't await MatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tE{#M;constructor(e){this.#M=c(e)}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenInsertValues(e){let[t,r]=eR(e);return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(eD.cloneWith(eD.createWithoutInto(),{columns:t,values:r})))})}}e_(tE,"don't await NotMatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tA{#M;constructor(e){this.#M=c(e)}selectFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.createFrom(t7(e),this.#M.withNode)})}selectNoFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.cloneWithSelections(eb.create(this.#M.withNode),eA(e))})}insertInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode)})}replaceInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode,!0)})}deleteFrom(e){return new e3({queryId:ts(),executor:this.#M.executor,queryNode:eq.create(t7(e),this.#M.withNode)})}updateTable(e){return new e5({queryId:ts(),executor:this.#M.executor,queryNode:eP.create(re(e),this.#M.withNode)})}mergeInto(e){return new tx({queryId:ts(),executor:this.#M.executor,queryNode:eB.create(rt(e),this.#M.withNode)})}with(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r)})}withRecursive(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r,{recursive:!0})})}withPlugin(e){return new tA({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new tA({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new tA({...this.#M,executor:this.#M.executor.withPluginAtFront(new tc(e))})}}function tS(e,t){if(3===t.length){var r,a,i,s;return r=e,a=t[0],i=t[1],s=t[2],T.createWithOn(r,re(a),ed(i,"=",s))}if(2===t.length)return function(e,t,r){return r(new ex({joinNode:T.create(e,re(t))})).toOperationNode()}(e,t[0],t[1]);throw Error("not implemented")}let tk=c({is:e=>"OffsetNode"===e.kind,create:e=>c({kind:"OffsetNode",offset:e})}),tO=c({is:e=>"GroupByItemNode"===e.kind,create:e=>c({kind:"GroupByItemNode",groupBy:e})}),tC=c({is:e=>"SetOperationNode"===e.kind,create:(e,t,r)=>c({kind:"SetOperationNode",operator:e,expression:t,all:r})});function tI(e,t,r){return p(t)&&(t=t(t3())),h(t)||(t=[t]),t.map(t=>tC.create(e,t9(t),r))}e.s(["SetOperationNode",0,tC],45393);class tR{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tR(this.#q)}$notNull(){return new tR(this.#q)}toOperationNode(){return this.#q}}class tD{#es;#en;constructor(e,t){this.#es=e,this.#en=t}get expression(){return this.#es}get alias(){return this.#en}toOperationNode(){return v.create(this.#es.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}class tP{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}$castTo(){return new tP(this.#q)}toOperationNode(){return en.create(this.#q)}}class tj{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tj(this.#q)}toOperationNode(){return en.create(this.#q)}}class tq{#M;constructor(e){this.#M=c(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}having(...e){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,eo(e))})}havingRef(e,t,r){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,ed(e,t,r))})}select(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,eA(e))})}distinctOn(e){return new tq({...this.#M,queryNode:eb.cloneWithDistinctOn(this.#M.queryNode,$(e))})}modifyFront(e){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}distinct(){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.create("Distinct"))})}forUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForUpdate",e?u(e).map(rr):void 0))})}forShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForShare",e?u(e).map(rr):void 0))})}forKeyShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForKeyShare",e?u(e).map(rr):void 0))})}forNoKeyUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForNoKeyUpdate",e?u(e).map(rr):void 0))})}skipLocked(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("SkipLocked"))})}noWait(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("NoWait"))})}selectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,ek(e))})}innerJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}innerJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralInnerJoin",e))})}leftJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralLeftJoin",e))})}orderBy(...e){return new tq({...this.#M,queryNode:eb.cloneWithOrderByItems(this.#M.queryNode,M(e))})}groupBy(e){var t;return new tq({...this.#M,queryNode:eb.cloneWithGroupByItems(this.#M.queryNode,$(t=p(t=e)?t(t3()):t).map(tO.create))})}limit(e){return new tq({...this.#M,queryNode:eb.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}offset(e){return new tq({...this.#M,queryNode:eb.cloneWithOffset(this.#M.queryNode,tk.create(ea(e)))})}fetch(e,t="only"){return new tq({...this.#M,queryNode:eb.cloneWithFetch(this.#M.queryNode,function(e,t){var r;let i,s;if(!a(e)&&!o(e))throw Error(`Invalid fetch row count: ${e}`);if("only"!==(r=t)&&"with ties"!==r)throw Error(`Invalid fetch modifier: ${t}`);return i=e,s=t,{kind:"FetchNode",rowCount:et.create(i),modifier:s}}(e,t))})}top(e,t){return new tq({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}union(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!1))})}unionAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!0))})}intersect(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!1))})}intersectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!0))})}except(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!1))})}exceptAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!0))})}as(e){return new tL(this,e)}clearSelect(){return new tq({...this.#M,queryNode:eb.cloneWithoutSelections(this.#M.queryNode)})}clearWhere(){return new tq({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}clearLimit(){return new tq({...this.#M,queryNode:eb.cloneWithoutLimit(this.#M.queryNode)})}clearOffset(){return new tq({...this.#M,queryNode:eb.cloneWithoutOffset(this.#M.queryNode)})}clearOrderBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutOrderBy(this.#M.queryNode)})}clearGroupBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutGroupBy(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new tq({...this.#M})}$castTo(){return new tq(this.#M)}$narrowType(){return new tq(this.#M)}$assertType(){return new tq(this.#M)}$asTuple(){return new tR(this.toOperationNode())}withPlugin(e){return new tq({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile();return(await this.#M.executor.executeQuery(e,this.#M.queryId)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new tq({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(tq,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class tL{#eo;#en;constructor(e,t){this.#eo=e,this.#en=t}get expression(){return this.#eo}get alias(){return this.#en}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return v.create(this.#eo.toOperationNode(),f.create(this.#en))}}e_(tL,"don't await AliasedSelectQueryBuilder instances directly. AliasedSelectQueryBuilder should never be executed directly since it's always a part of another query."),e.s(["createFunctionModule",()=>tV],86566);let tM=c({is:e=>"AggregateFunctionNode"===e.kind,create:(e,t=[])=>c({kind:"AggregateFunctionNode",func:e,aggregated:t}),cloneWithDistinct:e=>c({...e,distinct:!0}),cloneWithOrderBy:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"And",t):eL.create(t)}),cloneWithOrFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"Or",t):eL.create(t)}),cloneWithOver:(e,t)=>c({...e,over:t})}),tF=c({is:e=>"FunctionNode"===e.kind,create:(e,t)=>c({kind:"FunctionNode",func:e,arguments:t})});class tU{#M;constructor(e){this.#M=c(e)}get expressionType(){}as(e){return new tB(this,e)}distinct(){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithDistinct(this.#M.aggregateFunctionNode)})}orderBy(e,t){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOrderBy(this.#M.aggregateFunctionNode,M([e,t]))})}filterWhere(...e){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,eo(e))})}filterWhereRef(e,t,r){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,ed(e,t,r))})}over(e){let t=new eT({overNode:eg.create()});return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOver(this.#M.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new tU(this.#M)}$notNull(){return new tU(this.#M)}toOperationNode(){return this.#M.aggregateFunctionNode}}e_(tU,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class tB{#ep;#en;constructor(e,t){this.#ep=e,this.#en=t}get expression(){return this.#ep}get alias(){return this.#en}toOperationNode(){return v.create(this.#ep.toOperationNode(),f.create(this.#en))}}function tV(){let e=(e,t)=>new tR(tF.create(e,$(t??[]))),t=(e,t)=>new tU({aggregateFunctionNode:tM.create(e,t?$(t):void 0)});return Object.assign(e,{agg:t,avg:e=>t("avg",[e]),coalesce:(...t)=>e("coalesce",t),count:e=>t("count",[e]),countAll:e=>new tU({aggregateFunctionNode:tM.create("count",ek(e))}),max:e=>t("max",[e]),min:e=>t("min",[e]),sum:e=>t("sum",[e]),any:t=>e("any",[t]),jsonAgg:e=>new tU({aggregateFunctionNode:tM.create("json_agg",[r(e)?rr(e):e.toOperationNode()])}),toJson:e=>new tR(tF.create("to_json",[r(e)?rr(e):e.toOperationNode()]))})}let tz=c({is:e=>"UnaryOperationNode"===e.kind,create:(e,t)=>c({kind:"UnaryOperationNode",operator:e,operand:t})});e.s(["CaseBuilder",()=>t$],21797);let tW=c({is:e=>"CaseNode"===e.kind,create:e=>c({kind:"CaseNode",value:e}),cloneWithWhen:(e,t)=>c({...e,when:c(e.when?[...e.when,t]:[t])}),cloneWithThen:(e,t)=>c({...e,when:e.when?c([...e.when.slice(0,-1),eU.cloneWithResult(e.when[e.when.length-1],t)]):void 0}),cloneWith:(e,t)=>c({...e,...t})});e.s(["CaseNode",0,tW],72515);class t${#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}}class tG{#M;constructor(e){this.#M=c(e)}then(e){return new tH({...this.#M,node:tW.cloneWithThen(this.#M.node,ei(e)?es(e):ea(e))})}}class tH{#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}else(e){return new tK({...this.#M,node:tW.cloneWith(this.#M.node,{else:ei(e)?es(e):ea(e)})})}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}class tK{#M;constructor(e){this.#M=c(e)}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}let tJ=c({is:e=>"JSONPathLegNode"===e.kind,create:(e,t)=>c({kind:"JSONPathLegNode",type:e,value:t})});class tZ{#q;constructor(e){this.#q=e}at(e){return this.#ed("ArrayLocation",e)}key(e){return this.#ed("Member",e)}#ed(e,t){return new tQ(B.is(this.#q)?B.cloneWithTraversal(this.#q,z.is(this.#q.traversal)?z.cloneWithLeg(this.#q.traversal,tJ.create(e,t)):V.cloneWithValue(this.#q.traversal,et.createImmediate(t))):z.cloneWithLeg(this.#q,tJ.create(e,t)))}}class tQ extends tZ{#q;constructor(e){super(e),this.#q=e}get expressionType(){}as(e){return new tY(this,e)}$castTo(){return new tQ(this.#q)}$notNull(){return new tQ(this.#q)}toOperationNode(){return this.#q}}class tY{#el;#en;constructor(e,t){this.#el=e,this.#en=t}get expression(){return this.#el}get alias(){return this.#en}toOperationNode(){return v.create(this.#el.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}let tX=c({is:e=>"TupleNode"===e.kind,create:e=>c({kind:"TupleNode",values:c(e)})}),t1=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],t0=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],t2=c({is:e=>"DataTypeNode"===e.kind,create:e=>c({kind:"DataTypeNode",dataType:e})});function t6(e){if(w(e))return e.toOperationNode();if(t1.includes(e)||t0.some(t=>t.test(e)))return t2.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}e.s(["parseDataTypeExpression",()=>t6],51014);let t4=c({is:e=>"CastNode"===e.kind,create:(e,t)=>c({kind:"CastNode",expression:e,dataType:t})});function t3(e=tb){function r(e,t){return new tR(tz.create(k.create(e),G(t)))}let a=Object.assign(function(e,t,r){return new tR(ep(e,t,r))},{fn:void 0,eb:void 0,selectFrom:t=>new tq({queryId:ts(),executor:e,queryNode:eb.createFrom(t7(t))}),case:e=>new t$({node:tW.create(t(e)?void 0:G(e))}),ref:(e,r)=>t(r)?new tR(K(e)):new tZ(H(e,r)),jsonPath:()=>new tZ(z.create()),table:e=>new tR(rr(e)),val:e=>new tR(ea(e)),refTuple:(...e)=>new tR(tX.create(e.map(G))),tuple:(...e)=>new tR(tX.create(e.map(ea))),lit:e=>new tR(es(e)),unary:r,not:e=>r("not",e),exists:e=>r("exists",e),neg:e=>r("-",e),between:(e,t,r)=>new tR(E.create(G(e),k.create("between"),_.create(ea(t),ea(r)))),betweenSymmetric:(e,t,r)=>new tR(E.create(G(e),k.create("between symmetric"),_.create(ea(t),ea(r)))),and:e=>new tR(h(e)?ec(e,"and"):el(e,"and")),or:e=>new tR(h(e)?ec(e,"or"):el(e,"or")),parens(...e){let t=eo(e);return new tR(en.is(t)?t:en.create(t))},cast:(e,t)=>new tR(t4.create(G(e),t6(t))),withSchema:t=>t3(e.withPluginAtFront(new tc(t)))});return a.fn=tV(),a.eb=a,a}function t9(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function t5(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function t8(e){return d(e)&&"expressionType"in e&&w(e)||d(e)&&"expression"in e&&r(e.alias)&&w(e)||p(e)}function t7(e){return h(e)?e.map(e=>re(e)):[re(e)]}function re(e){return r(e)?rt(e):t5(e)}function rt(e){let t=" as ";if(!e.includes(t))return rr(e);{let[r,a]=e.split(t).map(ra);return v.create(rr(r),f.create(a))}}function rr(e){if(!e.includes("."))return y.create(e);{let[t,r]=e.split(".").map(ra);return y.createWithSchema(t,r)}}function ra(e){return e.trim()}},58666,3888,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"CreateTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTableNode",table:e,columns:(0,t.freeze)([])}),cloneWithColumn:(e,r)=>(0,t.freeze)({...e,columns:(0,t.freeze)([...e.columns,r])}),cloneWithConstraint:(e,r)=>(0,t.freeze)({...e,constraints:e.constraints?(0,t.freeze)([...e.constraints,r]):(0,t.freeze)([r])}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):(0,t.freeze)([r])}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):(0,t.freeze)([r])}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateTableNode",0,r,"ON_COMMIT_ACTIONS",0,["preserve rows","delete rows","drop"]],58666);var a=e.i(62212);let i=(0,t.freeze)({is:e=>"CreateViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateViewNode",name:a.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateViewNode",0,i],3888)},24659,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"AlterTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"AlterTableNode",table:e}),cloneWithTableProps:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumnAlteration:(e,r)=>(0,t.freeze)({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,r]:[r]})});var a=e.i(482);let i=(0,t.freeze)({is:e=>"CreateIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})}),s=(0,t.freeze)({is:e=>"CreateSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CreateSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var n=e.i(58666),o=e.i(62212);let p=(0,t.freeze)({is:e=>"DropIndexNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropIndexNode",name:o.SchemableIdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),d=(0,t.freeze)({is:e=>"DropSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),l=(0,t.freeze)({is:e=>"DropTableNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropTableNode",table:e,...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var c=e.i(87799);let u=(0,t.freeze)({is:e=>"AddColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddColumnNode",column:e})});var h=e.i(54199);let m=(0,t.freeze)({is:e=>"ColumnDefinitionNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ColumnDefinitionNode",column:h.ColumnNode.create(e),dataType:r}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):[r]}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):[r]}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),f=(0,t.freeze)({is:e=>"DropColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropColumnNode",column:h.ColumnNode.create(e)})}),g=(0,t.freeze)({is:e=>"RenameColumnNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"RenameColumnNode",column:h.ColumnNode.create(e),renameTo:h.ColumnNode.create(r)})});var v=e.i(50430);let y=(0,t.freeze)({is:e=>"CheckConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CheckConstraintNode",expression:e,name:r?a.IdentifierNode.create(r):void 0})}),w=["no action","restrict","cascade","set null","set default"],b=(0,t.freeze)({is:e=>"ReferencesNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ReferencesNode",table:e,columns:(0,t.freeze)([...r])}),cloneWithOnDelete:(e,r)=>(0,t.freeze)({...e,onDelete:r}),cloneWithOnUpdate:(e,r)=>(0,t.freeze)({...e,onUpdate:r})});var _=e.i(6937),x=e.i(56900),N=e.i(56967),T=e.i(46220);function E(e){return(0,N.isOperationNodeSource)(e)?e.toOperationNode():T.ValueNode.createImmediate(e)}let A=(0,t.freeze)({is:e=>"GeneratedNode"===e.kind,create:e=>(0,t.freeze)({kind:"GeneratedNode",...e}),createWithExpression:e=>(0,t.freeze)({kind:"GeneratedNode",always:!0,expression:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),S=(0,t.freeze)({is:e=>"DefaultValueNode"===e.kind,create:e=>(0,t.freeze)({kind:"DefaultValueNode",defaultValue:e})});function k(e){if(w.includes(e))return e;throw Error(`invalid OnModifyForeignAction ${e}`)}class O{#q;constructor(e){this.#q=e}autoIncrement(){return new O(m.cloneWith(this.#q,{autoIncrement:!0}))}identity(){return new O(m.cloneWith(this.#q,{identity:!0}))}primaryKey(){return new O(m.cloneWith(this.#q,{primaryKey:!0}))}references(e){let t=(0,x.parseStringReference)(e);if(!t.table||_.SelectAllNode.is(t.column))throw Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new O(m.cloneWith(this.#q,{references:b.create(t.table,[t.column])}))}onDelete(e){if(!this.#q.references)throw Error("on delete constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnDelete(this.#q.references,k(e))}))}onUpdate(e){if(!this.#q.references)throw Error("on update constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnUpdate(this.#q.references,k(e))}))}unique(){return new O(m.cloneWith(this.#q,{unique:!0}))}notNull(){return new O(m.cloneWith(this.#q,{notNull:!0}))}unsigned(){return new O(m.cloneWith(this.#q,{unsigned:!0}))}defaultTo(e){return new O(m.cloneWith(this.#q,{defaultTo:S.create(E(e))}))}check(e){return new O(m.cloneWith(this.#q,{check:y.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new O(m.cloneWith(this.#q,{generated:A.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#q.generated)throw Error("stored() can only be called after generatedAlwaysAs");return new O(m.cloneWith(this.#q,{generated:A.cloneWith(this.#q.generated,{stored:!0})}))}modifyFront(e){return new O(m.cloneWithFrontModifier(this.#q,e.toOperationNode()))}nullsNotDistinct(){return new O(m.cloneWith(this.#q,{nullsNotDistinct:!0}))}ifNotExists(){return new O(m.cloneWith(this.#q,{ifNotExists:!0}))}modifyEnd(e){return new O(m.cloneWithEndModifier(this.#q,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(O,"don't await ColumnDefinitionBuilder instances directly.");let C=(0,t.freeze)({is:e=>"ModifyColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"ModifyColumnNode",column:e})});var I=e.i(51014);let R=(0,t.freeze)({is:e=>"ForeignKeyConstraintNode"===e.kind,create:(e,r,i,s)=>(0,t.freeze)({kind:"ForeignKeyConstraintNode",columns:e,references:b.create(r,i),name:s?a.IdentifierNode.create(s):void 0}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class D{#q;constructor(e){this.#q=e}onDelete(e){return new D(R.cloneWith(this.#q,{onDelete:k(e)}))}onUpdate(e){return new D(R.cloneWith(this.#q,{onUpdate:k(e)}))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(D,"don't await ForeignKeyConstraintBuilder instances directly.");let P=(0,t.freeze)({is:e=>"AddConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddConstraintNode",constraint:e})}),j=(0,t.freeze)({is:e=>"UniqueConstraintNode"===e.kind,create:(e,r,i)=>(0,t.freeze)({kind:"UniqueConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0,nullsNotDistinct:i}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),q=(0,t.freeze)({is:e=>"DropConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropConstraintNode",constraintName:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),L=(0,t.freeze)({is:e=>"AlterColumnNode"===e.kind,create:(e,r,a)=>(0,t.freeze)({kind:"AlterColumnNode",column:h.ColumnNode.create(e),[r]:a})});class M{#ec;constructor(e){this.#ec=e}setDataType(e){return new F(L.create(this.#ec,"dataType",(0,I.parseDataTypeExpression)(e)))}setDefault(e){return new F(L.create(this.#ec,"setDefault",E(e)))}dropDefault(){return new F(L.create(this.#ec,"dropDefault",!0))}setNotNull(){return new F(L.create(this.#ec,"setNotNull",!0))}dropNotNull(){return new F(L.create(this.#ec,"dropNotNull",!0))}$call(e){return e(this)}}(0,v.preventAwait)(M,"don't await AlterColumnBuilder instances");class F{#eu;constructor(e){this.#eu=e}toOperationNode(){return this.#eu}}(0,v.preventAwait)(F,"don't await AlteredColumnBuilder instances");class U{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(U,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");class B{#M;constructor(e){this.#M=(0,t.freeze)(e)}onDelete(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onDelete(e)})}onUpdate(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(this.#M.constraintBuilder.toOperationNode())}),this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(B,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");class V{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{ifExists:!0})})})}cascade(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(V,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");let z=(0,t.freeze)({is:e=>"PrimaryKeyConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"PrimaryKeyConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0})}),W=(0,t.freeze)({is:e=>"AddIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})});var $=e.i(90348);class G{#M;constructor(e){this.#M=(0,t.freeze)(e)}unique(){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{unique:!0})})})}column(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[(0,x.parseOrderedColumnName)(e)])})})}columns(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,e.map(x.parseOrderedColumnName))})})}expression(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[e.toOperationNode()])})})}using(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{using:$.RawNode.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(G,"don't await AlterTableAddIndexBuilder instances directly. To execute the query you need to call `execute`");class H{#q;constructor(e){this.#q=e}toOperationNode(){return this.#q}nullsNotDistinct(){return new H(j.cloneWith(this.#q,{nullsNotDistinct:!0}))}}(0,v.preventAwait)(H,"don't await UniqueConstraintNodeBuilder instances directly.");class K{#M;constructor(e){this.#M=(0,t.freeze)(e)}renameTo(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{renameTo:(0,c.parseTable)(e)})})}setSchema(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{setSchema:a.IdentifierNode.create(e)})})}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}addUniqueConstraint(e,a,i=t.noop){let s=i(new H(j.create(a,e)));return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(s.toOperationNode())})})}addCheckConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(y.create(t.toOperationNode(),e))})})}addForeignKeyConstraint(e,t,r,a){return new B({...this.#M,constraintBuilder:new D(R.create(t.map(h.ColumnNode.create),(0,c.parseTable)(r),a.map(h.ColumnNode.create),e))})}addPrimaryKeyConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(z.create(t,e))})})}dropConstraint(e){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.create(e)})})}addIndex(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.create(e)})})}dropIndex(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropIndex:p.create(e)})})}$call(e){return e(this)}}(0,v.preventAwait)(K,"don't await AlterTableBuilder instances");class J{#M;constructor(e){this.#M=(0,t.freeze)(e)}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(J,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");var Z=e.i(83013),Q=e.i(27539),Y=e.i(2758);class X extends Y.OperationNodeTransformer{transformValue(e){return{...super.transformValue(e),immediate:!0}}}class ee{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{ifNotExists:!0})})}unique(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{unique:!0})})}nullsNotDistinct(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{nullsNotDistinct:!0})})}on(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}column(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[(0,x.parseOrderedColumnName)(e)])})}columns(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,e.map(x.parseOrderedColumnName))})}expression(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[e.toOperationNode()])})}using(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{using:$.RawNode.createWithSql(e)})})}where(...e){let t=new X;return new ee({...this.#M,node:Q.QueryNode.cloneWithWhere(this.#M.node,t.transformNode((0,Z.parseValueBinaryOperationOrExpression)(e)))})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ee,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");class et{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new et({...this.#M,node:s.cloneWith(this.#M.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(et,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");var er=e.i(67204);class ea{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{temporary:!0})})}onCommit(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{onCommit:function(e){if(n.ON_COMMIT_ACTIONS.includes(e))return e;throw Error(`invalid OnCommitAction ${e}`)}(e)})})}ifNotExists(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{ifNotExists:!0})})}addColumn(e,r,a=t.noop){let i=a(new O(m.create(e,(0,I.parseDataTypeExpression)(r))));return new ea({...this.#M,node:n.CreateTableNode.cloneWithColumn(this.#M.node,i.toOperationNode())})}addPrimaryKeyConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,z.create(t,e))})}addUniqueConstraint(e,r,a=t.noop){let i=a(new H(j.create(r,e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,i.toOperationNode())})}addCheckConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,y.create(t.toOperationNode(),e))})}addForeignKeyConstraint(e,r,a,i,s=t.noop){let o=s(new D(R.create(r.map(h.ColumnNode.create),(0,c.parseTable)(a),i.map(h.ColumnNode.create),e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,o.toOperationNode())})}modifyFront(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithFrontModifier(this.#M.node,e.toOperationNode())})}modifyEnd(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithEndModifier(this.#M.node,e.toOperationNode())})}as(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{selectQuery:(0,er.parseExpression)(e)})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ea,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");class ei{#M;constructor(e){this.#M=(0,t.freeze)(e)}on(e){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}ifExists(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ei,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");class es{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(es,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");class en{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(en,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");var eo=e.i(34939),ep=e.i(90640),ed=e.i(3888);class el{#Q=new X;transformQuery(e){return this.#Q.transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}class ec{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{temporary:!0})})}materialized(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{materialized:!0})})}ifNotExists(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{ifNotExists:!0})})}orReplace(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{orReplace:!0})})}columns(e){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{columns:e.map(x.parseColumnName)})})}as(e){let t=e.withPlugin(new el).toOperationNode();return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{as:t})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ec,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");let eu=(0,t.freeze)({is:e=>"DropViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropViewNode",name:o.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class eh{#M;constructor(e){this.#M=(0,t.freeze)(e)}materialized(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{materialized:!0})})}ifExists(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eh,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");var em=e.i(22177);let ef=(0,t.freeze)({is:e=>"CreateTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTypeNode",name:e}),cloneWithEnum:(e,r)=>(0,t.freeze)({...e,enum:em.ValueListNode.create(r.map(e=>T.ValueNode.createImmediate(e)))})});class eg{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}asEnum(e){return new eg({...this.#M,node:ef.cloneWithEnum(this.#M.node,e)})}$call(e){return e(this)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eg,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");let ev=(0,t.freeze)({is:e=>"DropTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropTypeNode",name:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class ey{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new ey({...this.#M,node:ev.cloneWith(this.#M.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}function ew(e){if(!e.includes("."))return o.SchemableIdentifierNode.create(e);{let t=e.split(".").map(eb);if(2===t.length)return o.SchemableIdentifierNode.createWithSchema(t[0],t[1]);throw Error(`invalid schemable identifier ${e}`)}}function eb(e){return e.trim()}(0,v.preventAwait)(ey,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");class e_{#eh;constructor(e){this.#eh=e}createTable(e){return new ea({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:n.CreateTableNode.create((0,c.parseTable)(e))})}dropTable(e){return new en({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:l.create((0,c.parseTable)(e))})}createIndex(e){return new ee({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:i.create(e)})}dropIndex(e){return new ei({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:p.create(e)})}createSchema(e){return new et({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:s.create(e)})}dropSchema(e){return new es({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:d.create(e)})}alterTable(e){return new K({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:r.create((0,c.parseTable)(e))})}createView(e){return new ec({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ed.CreateViewNode.create(e)})}dropView(e){return new eh({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:eu.create(e)})}createType(e){return new eg({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ef.create(ew(e))})}dropType(e){return new ey({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ev.create(ew(e))})}withPlugin(e){return new e_(this.#eh.withPlugin(e))}withoutPlugins(){return new e_(this.#eh.withoutPlugins())}withSchema(e){return new e_(this.#eh.withPluginAtFront(new ep.WithSchemaPlugin(e)))}}var ex=e.i(80864);class eN{ref(e){return new ex.DynamicReferenceBuilder(e)}}class eT{#em;constructor(e){this.#em=e}async provideConnection(e){let t=await this.#em.acquireConnection();try{return await e(t)}finally{await this.#em.releaseConnection(t)}}}var eE=e.i(82258),eA=e.i(46432);class eS extends eA.QueryExecutorBase{#ef;#eg;#ev;constructor(e,t,r,a=[]){super(a),this.#ef=e,this.#eg=t,this.#ev=r}get adapter(){return this.#eg}compileQuery(e){return this.#ef.compileQuery(e)}provideConnection(e){return this.#ev.provideConnection(e)}withPlugins(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,...e])}withPlugin(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,e])}withPluginAtFront(e){return new eS(this.#ef,this.#eg,this.#ev,[e,...this.plugins])}withConnectionProvider(e){return new eS(this.#ef,this.#eg,e,[...this.plugins])}withoutPlugins(){return new eS(this.#ef,this.#eg,this.#ev,[])}}function ek(){return"undefined"!=typeof performance&&(0,t.isFunction)(performance.now)?performance.now():Date.now()}class eO{#em;#ey;#ew;#eb;#e_;#ex=new WeakSet;constructor(e,t){this.#eb=!1,this.#em=e,this.#ey=t}async init(){if(this.#e_)throw Error("driver has already been destroyed");this.#ew||(this.#ew=this.#em.init().then(()=>{this.#eb=!0}).catch(e=>(this.#ew=void 0,Promise.reject(e)))),await this.#ew}async acquireConnection(){if(this.#e_)throw Error("driver has already been destroyed");this.#eb||await this.init();let e=await this.#em.acquireConnection();return this.#ex.has(e)||(this.#eN()&&this.#eT(e),this.#ex.add(e)),e}async releaseConnection(e){await this.#em.releaseConnection(e)}beginTransaction(e,t){return this.#em.beginTransaction(e,t)}commitTransaction(e){return this.#em.commitTransaction(e)}rollbackTransaction(e){return this.#em.rollbackTransaction(e)}async destroy(){this.#ew&&(await this.#ew,this.#e_||(this.#e_=this.#em.destroy().catch(e=>(this.#e_=void 0,Promise.reject(e)))),await this.#e_)}#eN(){return this.#ey.isLevelEnabled("query")||this.#ey.isLevelEnabled("error")}#eT(e){let t=e.executeQuery;e.executeQuery=async r=>{let a,i=ek();try{return await t.call(e,r)}catch(e){throw a=e,await this.#eE(e,r,i),e}finally{a||await this.#eA(r,i)}}}async #eE(e,t,r){await this.#ey.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#eS(r)}))}async #eA(e,t){await this.#ey.query(()=>({level:"query",query:e,queryDurationMillis:this.#eS(t)}))}#eS(e){return ek()-e}}let eC=()=>{};class eI{#ek;#eO;constructor(e){this.#ek=e}async provideConnection(e){for(;this.#eO;)await this.#eO.catch(eC);return this.#eO=this.#eC(e).finally(()=>{this.#eO=void 0}),this.#eO}async #eC(e){return await e(this.#ek)}}let eR=["read uncommitted","read committed","repeatable read","serializable","snapshot"];var eD=e.i(86566);(0,t.freeze)(["query","error"]);class eP{#eI;#eR;constructor(e){(0,t.isFunction)(e)?(this.#eR=e,this.#eI=(0,t.freeze)({query:!0,error:!0})):(this.#eR=ej,this.#eI=(0,t.freeze)({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#eI[e]}async query(e){this.#eI.query&&await this.#eR(e())}async error(e){this.#eI.error&&await this.#eR(e())}}function ej(e){"query"===e.level?(console.log(`kysely:query: ${e.query.sql}`),console.log(`kysely:query: duration: ${e.queryDurationMillis.toFixed(1)}ms`)):"error"===e.level&&(e.error instanceof Error?console.error(`kysely:error: ${e.error.stack??e.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`))}var eq=e.i(21797),eL=e.i(72515);class eM extends eE.QueryCreator{#M;constructor(e){let r,a;if(function(e){return(0,t.isObject)(e)&&(0,t.isObject)(e.config)&&(0,t.isObject)(e.driver)&&(0,t.isObject)(e.executor)&&(0,t.isObject)(e.dialect)}(e))r={executor:e.executor},a={...e};else{const t=e.dialect,i=t.createDriver(),s=t.createQueryCompiler(),n=t.createAdapter(),o=new eO(i,new eP(e.log??[])),p=new eS(s,n,new eT(o),e.plugins??[]);r={executor:p},a={config:e,executor:p,dialect:t,driver:o}}super(r),this.#M=(0,t.freeze)(a)}get schema(){return new e_(this.#M.executor)}get dynamic(){return new eN}get introspection(){return this.#M.dialect.createIntrospector(this.withoutPlugins())}case(e){return new eq.CaseBuilder({node:eL.CaseNode.create((0,t.isUndefined)(e)?void 0:(0,er.parseExpression)(e))})}get fn(){return(0,eD.createFunctionModule)()}transaction(){return new eB({...this.#M})}connection(){return new eU({...this.#M})}withPlugin(e){return new eM({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eM({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eM({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eM({...this.#M})}async destroy(){await this.#M.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#M.executor}executeQuery(e,r=(0,eo.createQueryId)()){let a=(0,t.isObject)(e)&&(0,t.isFunction)(e.compile)?e.compile():e;return this.getExecutor().executeQuery(a,r)}}class eF extends eM{#M;constructor(e){super(e),this.#M=e}get isTransaction(){return!0}transaction(){throw Error("calling the transaction method for a Transaction is not supported")}connection(){throw Error("calling the connection method for a Transaction is not supported")}async destroy(){throw Error("calling the destroy method for a Transaction is not supported")}withPlugin(e){return new eF({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eF({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eF({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eF({...this.#M})}}class eU{#M;constructor(e){this.#M=(0,t.freeze)(e)}async execute(e){return this.#M.executor.provideConnection(async t=>{let r=this.#M.executor.withConnectionProvider(new eI(t)),a=new eM({...this.#M,executor:r});return await e(a)})}}(0,v.preventAwait)(eU,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");class eB{#M;constructor(e){this.#M=(0,t.freeze)(e)}setIsolationLevel(e){return new eB({...this.#M,isolationLevel:e})}async execute(e){let{isolationLevel:t,...r}=this.#M,a={isolationLevel:t};return function(e){if(e.isolationLevel&&!eR.includes(e.isolationLevel))throw Error(`invalid transaction isolation level ${e.isolationLevel}`)}(a),this.#M.executor.provideConnection(async t=>{let i=this.#M.executor.withConnectionProvider(new eI(t)),s=new eF({...r,executor:i});try{await this.#M.driver.beginTransaction(t,a);let r=await e(s);return await this.#M.driver.commitTransaction(t),r}catch(e){throw await this.#M.driver.rollbackTransaction(t),e}})}}(0,v.preventAwait)(eB,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method"),e.s(["Kysely",()=>eM],24659)},12995,e=>{"use strict";var t=e.i(482),r=e.i(56967),a=e.i(90348),i=e.i(46220),s=e.i(56900),n=e.i(87799),o=e.i(40203),p=e.i(34939),d=e.i(79044),l=e.i(50430),c=e.i(84739),u=e.i(13424);class h{#M;constructor(e){this.#M=(0,c.freeze)(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new f(this,e)}$castTo(){return new h({...this.#M})}$notNull(){return new h(this.#M)}withPlugin(e){return new h({...this.#M,plugins:void 0!==this.#M.plugins?(0,c.freeze)([...this.#M.plugins,e]):(0,c.freeze)([e])})}toOperationNode(){return this.#eD(this.#eP())}compile(e){return this.#ej(this.#eP(e))}async execute(e){let t=this.#eP(e);return t.executeQuery(this.#ej(t),this.#M.queryId)}#eP(e){let t=void 0!==e?e.getExecutor():u.NOOP_QUERY_EXECUTOR;return void 0!==this.#M.plugins?t.withPlugins(this.#M.plugins):t}#eD(e){return e.transformQuery(this.#M.rawNode,this.#M.queryId)}#ej(e){return e.compileQuery(this.#eD(e),this.#M.queryId)}}function m(e){return new h(e)}(0,l.preventAwait)(h,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class f{#eq;#en;constructor(e,t){this.#eq=e,this.#en=t}get expression(){return this.#eq}get alias(){return this.#en}get rawBuilder(){return this.#eq}toOperationNode(){return d.AliasNode.create(this.#eq.toOperationNode(),(0,r.isOperationNodeSource)(this.#en)?this.#en.toOperationNode():t.IdentifierNode.create(this.#en))}}(0,l.preventAwait)(f,"don't await AliasedRawBuilder instances directly. AliasedRawBuilder should never be executed directly since it's always a part of another query.");let g=Object.assign((e,...t)=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(e,t?.map(v)??[])}),{ref:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,s.parseStringReference)(e))}),val:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,o.parseValueExpression)(e))}),value(e){return this.val(e)},table:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,n.parseTable)(e))}),id(...e){let r=Array(e.length+1).fill(".");return r[0]="",r[r.length-1]="",m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(r,e.map(t.IdentifierNode.create))})},lit:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild(i.ValueNode.createImmediate(e))}),literal(e){return this.lit(e)},raw:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithSql(e)}),join(e,t=g`, `){let r=Array(2*e.length-1),i=t.toOperationNode();for(let t=0;t<e.length;++t)r[2*t]=v(e[t]),t!==e.length-1&&(r[2*t+1]=i);return m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChildren(r)})}});function v(e){return(0,r.isOperationNodeSource)(e)?e.toOperationNode():(0,o.parseValueExpression)(e)}e.s(["sql",0,g],12995)},78134,e=>{"use strict";var t=e.i(90348),r=e.i(84739);let a=(0,r.freeze)({raw:(e,a=[])=>(0,r.freeze)({sql:e,query:t.RawNode.createWithSql(e),parameters:(0,r.freeze)(a)})}),i=Symbol();class s{#eL;#ex=new WeakMap;#eM;constructor(e){this.#eL=(0,r.freeze)({...e})}async init(){this.#eM=(0,r.isFunction)(this.#eL.pool)?await this.#eL.pool():this.#eL.pool}async acquireConnection(){let e=await this.#eM.connect(),t=this.#ex.get(e);return!t&&(t=new n(e,{cursor:this.#eL.cursor??null}),this.#ex.set(e,t),this.#eL.onCreateConnection&&await this.#eL.onCreateConnection(t)),this.#eL.onReserveConnection&&await this.#eL.onReserveConnection(t),t}async beginTransaction(e,t){t.isolationLevel?await e.executeQuery(a.raw(`start transaction isolation level ${t.isolationLevel}`)):await e.executeQuery(a.raw("begin"))}async commitTransaction(e){await e.executeQuery(a.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(a.raw("rollback"))}async releaseConnection(e){e[i]()}async destroy(){if(this.#eM){let e=this.#eM;this.#eM=void 0,await e.end()}}}class n{#eF;#eU;constructor(e,t){this.#eF=e,this.#eU=t}async executeQuery(e){try{let t=await this.#eF.query(e.sql,[...e.parameters]);if("INSERT"===t.command||"UPDATE"===t.command||"DELETE"===t.command||"MERGE"===t.command){let e=BigInt(t.rowCount);return{numUpdatedOrDeletedRows:e,numAffectedRows:e,rows:t.rows??[]}}return{rows:t.rows??[]}}catch(e){throw function(e,t){var a;if(a=e,(0,r.isObject)(a)&&(0,r.isString)(a.stack)&&t.stack){let r=t.stack.split("\n").slice(1).join("\n");e.stack+=`
1
+ module.exports=[80253,30314,e=>{"use strict";var t=class extends Error{res;status;constructor(e=500,t){super(t?.message,{cause:t?.cause}),this.res=t?.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};e.s(["HTTPException",()=>t],80253);var r=e=>{let t=e.split("/");return""===t[0]&&t.shift(),t},a=e=>{let{groups:t,path:a}=i(e);return s(r(a),t)},i=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,r)=>{let a=`@${r}`;return t.push([a,e]),a}),{groups:t,path:e}},s=(e,t)=>{for(let r=t.length-1;r>=0;r--){let[a]=t[r];for(let i=e.length-1;i>=0;i--)if(e[i].includes(a)){e[i]=e[i].replace(a,t[r][1]);break}}return e},n={},o=(e,t)=>{if("*"===e)return"*";let r=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let a=`${e}#${t}`;return n[a]||(r[2]?n[a]=t&&":"!==t[0]&&"*"!==t[0]?[a,r[1],RegExp(`^${r[2]}(?=/${t})`)]:[e,r[1],RegExp(`^${r[2]}$`)]:n[a]=[e,r[1],!0]),n[a]}return null},p=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},d=e=>p(e,decodeURI),l=e=>{let t=e.url,r=t.indexOf("/",t.indexOf(":")+4),a=r;for(;a<t.length;a++){let e=t.charCodeAt(a);if(37===e){let e=t.indexOf("?",a),i=t.slice(r,-1===e?void 0:e);return d(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}if(63===e)break}return t.slice(r,a)},c=e=>{let t=l(e);return t.length>1&&"/"===t.at(-1)?t.slice(0,-1):t},u=(e,t,...r)=>(r.length&&(t=u(t,...r)),`${e?.[0]==="/"?"":"/"}${e}${"/"===t?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),h=e=>{if(63!==e.charCodeAt(e.length-1)||!e.includes(":"))return null;let t=e.split("/"),r=[],a="";return t.forEach(e=>{if(""===e||/\:/.test(e)){if(/\:/.test(e))if(/\?/.test(e)){0===r.length&&""===a?r.push("/"):r.push(a);let t=e.replace("?","");a+="/"+t,r.push(a)}else a+="/"+e}else a+="/"+e}),r.filter((e,t,r)=>r.indexOf(e)===t)},m=e=>/[%+]/.test(e)?(-1!==e.indexOf("+")&&(e=e.replace(/\+/g," ")),-1!==e.indexOf("%")?p(e,v):e):e,f=(e,t,r)=>{let a;if(!r&&t&&!/[%+]/.test(t)){let r=e.indexOf("?",8);if(-1===r)return;for(e.startsWith(t,r+1)||(r=e.indexOf(`&${t}`,r+1));-1!==r;){let a=e.charCodeAt(r+t.length+1);if(61===a){let a=r+t.length+2,i=e.indexOf("&",a);return m(e.slice(a,-1===i?void 0:i))}if(38==a||isNaN(a))return"";r=e.indexOf(`&${t}`,r+1)}if(!(a=/[%+]/.test(e)))return}let i={};a??=/[%+]/.test(e);let s=e.indexOf("?",8);for(;-1!==s;){let t,n=e.indexOf("&",s+1),o=e.indexOf("=",s);o>n&&-1!==n&&(o=-1);let p=e.slice(s+1,-1===o?-1===n?void 0:n:o);a&&(p=m(p)),s=n,""!==p&&(-1===o?t="":(t=e.slice(o+1,-1===n?void 0:n),a&&(t=m(t))),r?(i[p]&&Array.isArray(i[p])||(i[p]=[]),i[p].push(t)):i[p]??=t)}return t?i[t]:i},g=(e,t)=>f(e,t,!0),v=decodeURIComponent;e.s(["checkOptionalParameter",()=>h,"decodeURIComponent_",()=>v,"getPath",()=>l,"getPathNoStrict",()=>c,"getPattern",()=>o,"getQueryParam",()=>f,"getQueryParams",()=>g,"mergePath",()=>u,"splitPath",()=>r,"splitRoutingPath",()=>a,"tryDecode",()=>p],30314)},26481,e=>{"use strict";var t=(e,t,r)=>(a,i)=>{let s=-1;return n(0);async function n(o){let p,d;if(o<=s)throw Error("next() called multiple times");s=o;let l=!1;if(e[o]?(d=e[o][0][0],a.req.routeIndex=o):d=o===e.length&&i||void 0,d)try{p=await d(a,()=>n(o+1))}catch(e){if(e instanceof Error&&t)a.error=e,p=await t(e,a),l=!0;else throw e}else!1===a.finalized&&r&&(p=await r(a));return p&&(!1===a.finalized||l)&&(a.res=p),a}};e.i(80253);var r=Symbol(),a=async(e,t=Object.create(null))=>{let{all:r=!1,dot:a=!1}=t,s=(e instanceof d?e.raw.headers:e.headers).get("Content-Type");return s?.startsWith("multipart/form-data")||s?.startsWith("application/x-www-form-urlencoded")?i(e,{all:r,dot:a}):{}};async function i(e,t){var r,a;let i,o=await e.formData();return o?(r=o,a=t,i=Object.create(null),r.forEach((e,t)=>{a.all||t.endsWith("[]")?s(i,t,e):i[t]=e}),a.dot&&Object.entries(i).forEach(([e,t])=>{e.includes(".")&&(n(i,e,t),delete i[e])}),i):{}}var s=(e,t,r)=>{void 0!==e[t]?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:t.endsWith("[]")?e[t]=[r]:e[t]=r},n=(e,t,r)=>{let a=e,i=t.split(".");i.forEach((e,t)=>{t===i.length-1?a[e]=r:((!a[e]||"object"!=typeof a[e]||Array.isArray(a[e])||a[e]instanceof File)&&(a[e]=Object.create(null)),a=a[e])})},o=e.i(30314),p=e=>(0,o.tryDecode)(e,o.decodeURIComponent_),d=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",r=[[]]){this.raw=e,this.path=t,this.#t=r,this.#e={}}param(e){return e?this.#r(e):this.#a()}#r(e){let t=this.#t[0][this.routeIndex][1][e],r=this.#i(t);return r&&/\%/.test(r)?p(r):r}#a(){let e={};for(let t of Object.keys(this.#t[0][this.routeIndex][1])){let r=this.#i(this.#t[0][this.routeIndex][1][t]);void 0!==r&&(e[t]=/\%/.test(r)?p(r):r)}return e}#i(e){return this.#t[1]?this.#t[1][e]:e}query(e){return(0,o.getQueryParam)(this.url,e)}queries(e){return(0,o.getQueryParams)(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((e,r)=>{t[r]=e}),t}async parseBody(e){return this.bodyCache.parsedBody??=await a(this,e)}#s=e=>{let{bodyCache:t,raw:r}=this,a=t[e];if(a)return a;let i=Object.keys(t)[0];return i?t[i].then(t=>("json"===i&&(t=JSON.stringify(t)),new Response(t)[e]())):t[e]=r[e]()};json(){return this.#s("text").then(e=>JSON.parse(e))}text(){return this.#s("text")}arrayBuffer(){return this.#s("arrayBuffer")}blob(){return this.#s("blob")}formData(){return this.#s("formData")}addValidatedData(e,t){this.#e[e]=t}valid(e){return this.#e[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[r](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},l=async(e,t,r,a,i)=>{var s;let n;"object"==typeof e&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let o=e.callbacks;if(!o?.length)return Promise.resolve(e);i?i[0]+=e:i=[e];let p=Promise.all(o.map(e=>e({phase:t,buffer:i,context:a}))).then(e=>Promise.all(e.filter(Boolean).map(e=>l(e,t,!1,a,i))).then(()=>i[0]));if(!r)return p;return s=await p,(n=new String(s)).isEscaped=!0,n.callbacks=o,n},c=(e,t)=>({"Content-Type":e,...t}),u=class{#n;#o;env={};#p;finalized=!1;error;#d;#l;#c;#u;#h;#m;#f;#t;#g;constructor(e,t){this.#n=e,t&&(this.#l=t.executionCtx,this.env=t.env,this.#m=t.notFoundHandler,this.#g=t.path,this.#t=t.matchResult)}get req(){return this.#o??=new d(this.#n,this.#g,this.#t),this.#o}get event(){if(this.#l&&"respondWith"in this.#l)return this.#l;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#l)return this.#l;throw Error("This context has no ExecutionContext")}get res(){return this.#c||=new Response(null,{headers:this.#f??=new Headers})}set res(e){if(this.#c&&e){for(let[t,r]of(e=new Response(e.body,e),this.#c.headers.entries()))if("content-type"!==t)if("set-cookie"===t){let t=this.#c.headers.getSetCookie();for(let r of(e.headers.delete("set-cookie"),t))e.headers.append("set-cookie",r)}else e.headers.set(t,r)}this.#c=e,this.finalized=!0}render=(...e)=>(this.#h??=e=>this.html(e),this.#h(...e));setLayout=e=>this.#u=e;getLayout=()=>this.#u;setRenderer=e=>{this.#h=e};header=(e,t,r)=>{this.finalized&&(this.#c=new Response(this.#c.body,this.#c));let a=this.#c?this.#c.headers:this.#f??=new Headers;void 0===t?a.delete(e):r?.append?a.append(e,t):a.set(e,t)};status=e=>{this.#d=e};set=(e,t)=>{this.#p??=new Map,this.#p.set(e,t)};get=e=>this.#p?this.#p.get(e):void 0;get var(){return this.#p?Object.fromEntries(this.#p):{}}#v(e,t,r){let a=this.#c?new Headers(this.#c.headers):this.#f??new Headers;if("object"==typeof t&&"headers"in t)for(let[e,r]of t.headers instanceof Headers?t.headers:new Headers(t.headers))"set-cookie"===e.toLowerCase()?a.append(e,r):a.set(e,r);if(r)for(let[e,t]of Object.entries(r))if("string"==typeof t)a.set(e,t);else for(let r of(a.delete(e),t))a.append(e,r);return new Response(e,{status:"number"==typeof t?t:t?.status??this.#d,headers:a})}newResponse=(...e)=>this.#v(...e);body=(e,t,r)=>this.#v(e,t,r);text=(e,t,r)=>this.#f||this.#d||t||r||this.finalized?this.#v(e,t,c("text/plain; charset=UTF-8",r)):new Response(e);json=(e,t,r)=>this.#v(JSON.stringify(e),t,c("application/json",r));html=(e,t,r)=>{let a=e=>this.#v(e,t,c("text/html; charset=UTF-8",r));return"object"==typeof e?l(e,1,!1,{}).then(a):a(e)};redirect=(e,t)=>{let r=String(e);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,t??302)};notFound=()=>(this.#m??=()=>new Response,this.#m(this))},h=["get","post","put","delete","options","patch"],m="Can not add a route since the matcher is already built.",f=class extends Error{},g=e=>e.text("404 Not Found",404),v=(e,t)=>{if("getResponse"in e){let r=e.getResponse();return t.newResponse(r.body,r)}return console.error(e),t.text("Internal Server Error",500)},y=class e{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#g="/";routes=[];constructor(e={}){[...h,"all"].forEach(e=>{this[e]=(t,...r)=>("string"==typeof t?this.#g=t:this.#y(e,this.#g,t),r.forEach(t=>{this.#y(e,this.#g,t)}),this)}),this.on=(e,t,...r)=>{for(let a of[t].flat())for(let t of(this.#g=a,[e].flat()))r.map(e=>{this.#y(t.toUpperCase(),this.#g,e)});return this},this.use=(e,...t)=>("string"==typeof e?this.#g=e:(this.#g="*",t.unshift(e)),t.forEach(e=>{this.#y("ALL",this.#g,e)}),this);const{strict:t,...r}=e;Object.assign(this,r),this.getPath=t??!0?e.getPath??o.getPath:o.getPathNoStrict}#w(){let t=new e({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#m=this.#m,t.routes=this.routes,t}#m=g;errorHandler=v;route(e,r){let a=this.basePath(e);return r.routes.map(e=>{let i;r.errorHandler===v?i=e.handler:(i=async(a,i)=>(await t([],r.errorHandler)(a,()=>e.handler(a,i))).res).__COMPOSED_HANDLER=e.handler,a.#y(e.method,e.path,i)}),this}basePath(e){let t=this.#w();return t._basePath=(0,o.mergePath)(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#m=e,this);mount(e,t,r){let a,i,s,n;r&&("function"==typeof r?i=r:(i=r.optionHandler,a=!1===r.replaceRequest?e=>e:r.replaceRequest));let p=i?e=>{let t=i(e);return Array.isArray(t)?t:[t]}:e=>{let t;try{t=e.executionCtx}catch{}return[e.env,t]};a||=(n="/"===(s=(0,o.mergePath)(this._basePath,e))?0:s.length,e=>{let t=new URL(e.url);return t.pathname=t.pathname.slice(n)||"/",new Request(t,e)});let d=async(e,r)=>{let i=await t(a(e.req.raw),...p(e));if(i)return i;await r()};return this.#y("ALL",(0,o.mergePath)(e,"*"),d),this}#y(e,t,r){e=e.toUpperCase(),t=(0,o.mergePath)(this._basePath,t);let a={basePath:this._basePath,path:t,method:e,handler:r};this.router.add(e,t,[r,a]),this.routes.push(a)}#b(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#_(e,r,a,i){if("HEAD"===i)return(async()=>new Response(null,await this.#_(e,r,a,"GET")))();let s=this.getPath(e,{env:a}),n=this.router.match(i,s),o=new u(e,{path:s,matchResult:n,env:a,executionCtx:r,notFoundHandler:this.#m});if(1===n[0].length){let e;try{e=n[0][0][0][0](o,async()=>{o.res=await this.#m(o)})}catch(e){return this.#b(e,o)}return e instanceof Promise?e.then(e=>e||(o.finalized?o.res:this.#m(o))).catch(e=>this.#b(e,o)):e??this.#m(o)}let p=t(n[0],this.errorHandler,this.#m);return(async()=>{try{let e=await p(o);if(!e.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return e.res}catch(e){return this.#b(e,o)}})()}fetch=(e,...t)=>this.#_(e,t[1],t[0],e.method);request=(e,t,r,a)=>e instanceof Request?this.fetch(t?new Request(e,t):e,r,a):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${(0,o.mergePath)("/",e)}`,t),r,a));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#_(e.request,e,void 0,e.request.method))})}},w=[];function b(e,t){let r=this.buildAllMatchers(),a=(e,t)=>{let a=r[e]||r.ALL,i=a[2][t];if(i)return i;let s=t.match(a[0]);if(!s)return[[],w];let n=s.indexOf("",1);return[a[1][n],s]};return this.match=a,a(e,t)}var _="[^/]+",x="(?:|/.*)",N=Symbol(),T=new Set(".\\+*[^]$()");function E(e,t){return 1===e.length?1===t.length?e<t?-1:1:-1:1===t.length||".*"===e||e===x?1:".*"===t||t===x?-1:e===_?1:t===_?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var A=class e{#x;#N;#T=Object.create(null);insert(t,r,a,i,s){let n;if(0===t.length){if(void 0!==this.#x)throw N;if(s)return;this.#x=r;return}let[o,...p]=t,d="*"===o?0===p.length?["","",".*"]:["","",_]:"/*"===o?["","",x]:o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(d){let t=d[1],r=d[2]||_;if(t&&d[2]&&(".*"===r||(r=r.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(r))))throw N;if(!(n=this.#T[r])){if(Object.keys(this.#T).some(e=>".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[r]=new e,""!==t&&(n.#N=i.varIndex++)}s||""===t||a.push([t,n.#N])}else if(!(n=this.#T[o])){if(Object.keys(this.#T).some(e=>e.length>1&&".*"!==e&&e!==x))throw N;if(s)return;n=this.#T[o]=new e}n.insert(p,r,a,i,s)}buildRegExpStr(){let e=Object.keys(this.#T).sort(E).map(e=>{let t=this.#T[e];return("number"==typeof t.#N?`(${e})@${t.#N}`:T.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return("number"==typeof this.#x&&e.unshift(`#${this.#x}`),0===e.length)?"":1===e.length?e[0]:"(?:"+e.join("|")+")"}},S=class{#E={varIndex:0};#A=new A;insert(e,t,r){let a=[],i=[];for(let t=0;;){let r=!1;if(e=e.replace(/\{[^}]+\}/g,e=>{let a=`@\\${t}`;return i[t]=[a,e],t++,r=!0,a}),!r)break}let s=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let e=i.length-1;e>=0;e--){let[t]=i[e];for(let r=s.length-1;r>=0;r--)if(-1!==s[r].indexOf(t)){s[r]=s[r].replace(t,i[e][1]);break}}return this.#A.insert(s,t,a,this.#E,r),a}buildRegExp(){let e=this.#A.buildRegExpStr();if(""===e)return[/^$/,[],[]];let t=0,r=[],a=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(e,i,s)=>void 0!==i?(r[++t]=Number(i),"$()"):(void 0!==s&&(a[Number(s)]=++t),"")),[RegExp(`^${e}`),r,a]}},k=[/^$/,[],Object.create(null)],O=Object.create(null);function C(e){return O[e]??=new RegExp("*"===e?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`)}function I(e,t){if(e){for(let r of Object.keys(e).sort((e,t)=>t.length-e.length))if(C(r).test(t))return[...e[r]]}}var R=class{name="RegExpRouter";#S;#k;constructor(){this.#S={ALL:Object.create(null)},this.#k={ALL:Object.create(null)}}add(e,t,r){let a=this.#S,i=this.#k;if(!a||!i)throw Error(m);a[e]||[a,i].forEach(t=>{t[e]=Object.create(null),Object.keys(t.ALL).forEach(r=>{t[e][r]=[...t.ALL[r]]})}),"/*"===t&&(t="*");let s=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let n=C(t);"ALL"===e?Object.keys(a).forEach(e=>{a[e][t]||=I(a[e],t)||I(a.ALL,t)||[]}):a[e][t]||=I(a[e],t)||I(a.ALL,t)||[],Object.keys(a).forEach(t=>{("ALL"===e||e===t)&&Object.keys(a[t]).forEach(e=>{n.test(e)&&a[t][e].push([r,s])})}),Object.keys(i).forEach(t=>{("ALL"===e||e===t)&&Object.keys(i[t]).forEach(e=>n.test(e)&&i[t][e].push([r,s]))});return}let n=(0,o.checkOptionalParameter)(t)||[t];for(let t=0,o=n.length;t<o;t++){let p=n[t];Object.keys(i).forEach(n=>{("ALL"===e||e===n)&&(i[n][p]||=[...I(a[n],p)||I(a.ALL,p)||[]],i[n][p].push([r,s-o+t+1]))})}}match=b;buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#k).concat(Object.keys(this.#S)).forEach(t=>{e[t]||=this.#O(t)}),this.#S=this.#k=void 0,O=Object.create(null),e}#O(e){let t=[],r="ALL"===e;return([this.#S,this.#k].forEach(a=>{let i=a[e]?Object.keys(a[e]).map(t=>[t,a[e][t]]):[];0!==i.length?(r||=!0,t.push(...i)):"ALL"!==e&&t.push(...Object.keys(a.ALL).map(e=>[e,a.ALL[e]]))}),r)?function(e){let t=new S,r=[];if(0===e.length)return k;let a=e.map(e=>[!/\*|\/:/.test(e[0]),...e]).sort(([e,t],[r,a])=>e?1:r?-1:t.length-a.length),i=Object.create(null);for(let e=0,s=-1,n=a.length;e<n;e++){let n,[o,p,d]=a[e];o?i[p]=[d.map(([e])=>[e,Object.create(null)]),w]:s++;try{n=t.insert(p,s,o)}catch(e){throw e===N?new f(p):e}o||(r[s]=d.map(([e,t])=>{let r=Object.create(null);for(t-=1;t>=0;t--){let[e,a]=n[t];r[e]=a}return[e,r]}))}let[s,n,o]=t.buildRegExp();for(let e=0,t=r.length;e<t;e++)for(let t=0,a=r[e].length;t<a;t++){let a=r[e][t]?.[1];if(!a)continue;let i=Object.keys(a);for(let e=0,t=i.length;e<t;e++)a[i[e]]=o[a[i[e]]]}let p=[];for(let e in n)p[e]=r[n[e]];return[s,p,i]}(t):null}},D=class{name="SmartRouter";#C=[];#k=[];constructor(e){this.#C=e.routers}add(e,t,r){if(!this.#k)throw Error(m);this.#k.push([e,t,r])}match(e,t){let r;if(!this.#k)throw Error("Fatal error");let a=this.#C,i=this.#k,s=a.length,n=0;for(;n<s;n++){let s=a[n];try{for(let e=0,t=i.length;e<t;e++)s.add(...i[e]);r=s.match(e,t)}catch(e){if(e instanceof f)continue;throw e}this.match=s.match.bind(s),this.#C=[s],this.#k=void 0;break}if(n===s)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,r}get activeRouter(){if(this.#k||1!==this.#C.length)throw Error("No active router has been determined yet.");return this.#C[0]}},P=Object.create(null),j=class e{#I;#T;#R;#D=0;#P=P;constructor(e,t,r){if(this.#T=r||Object.create(null),this.#I=[],e&&t){const r=Object.create(null);r[e]={handler:t,possibleKeys:[],score:0},this.#I=[r]}this.#R=[]}insert(t,r,a){this.#D=++this.#D;let i=this,s=(0,o.splitRoutingPath)(r),n=[];for(let t=0,r=s.length;t<r;t++){let r=s[t],a=s[t+1],p=(0,o.getPattern)(r,a),d=Array.isArray(p)?p[0]:r;if(d in i.#T){i=i.#T[d],p&&n.push(p[1]);continue}i.#T[d]=new e,p&&(i.#R.push(p),n.push(p[1])),i=i.#T[d]}return i.#I.push({[t]:{handler:a,possibleKeys:n.filter((e,t,r)=>r.indexOf(e)===t),score:this.#D}}),i}#j(e,t,r,a){let i=[];for(let s=0,n=e.#I.length;s<n;s++){let n=e.#I[s],o=n[t]||n.ALL,p={};if(void 0!==o&&(o.params=Object.create(null),i.push(o),r!==P||a&&a!==P))for(let e=0,t=o.possibleKeys.length;e<t;e++){let t=o.possibleKeys[e],i=p[o.score];o.params[t]=a?.[t]&&!i?a[t]:r[t]??a?.[t],p[o.score]=!0}}return i}search(e,t){let r=[];this.#P=P;let a=[this],i=(0,o.splitPath)(t),s=[];for(let t=0,n=i.length;t<n;t++){let o=i[t],p=t===n-1,d=[];for(let n=0,l=a.length;n<l;n++){let l=a[n],c=l.#T[o];c&&(c.#P=l.#P,p?(c.#T["*"]&&r.push(...this.#j(c.#T["*"],e,l.#P)),r.push(...this.#j(c,e,l.#P))):d.push(c));for(let a=0,n=l.#R.length;a<n;a++){let n=l.#R[a],c=l.#P===P?{}:{...l.#P};if("*"===n){let t=l.#T["*"];t&&(r.push(...this.#j(t,e,l.#P)),t.#P=c,d.push(t));continue}let[u,h,m]=n;if(!o&&!(m instanceof RegExp))continue;let f=l.#T[u],g=i.slice(t).join("/");if(m instanceof RegExp){let t=m.exec(g);if(t){if(c[h]=t[0],r.push(...this.#j(f,e,l.#P,c)),Object.keys(f.#T).length){f.#P=c;let e=t[0].match(/\//)?.length??0;(s[e]||=[]).push(f)}continue}}(!0===m||m.test(o))&&(c[h]=o,p?(r.push(...this.#j(f,e,c,l.#P)),f.#T["*"]&&r.push(...this.#j(f.#T["*"],e,c,l.#P))):(f.#P=c,d.push(f)))}}a=d.concat(s.shift()??[])}return r.length>1&&r.sort((e,t)=>e.score-t.score),[r.map(({handler:e,params:t})=>[e,t])]}},q=class{name="TrieRouter";#q;constructor(){this.#q=new j}add(e,t,r){let a=(0,o.checkOptionalParameter)(t);if(a){for(let t=0,i=a.length;t<i;t++)this.#q.insert(e,a[t],r);return}this.#q.insert(e,t,r)}match(e,t){return this.#q.search(e,t)}},L=class extends y{constructor(e={}){super(e),this.router=e.router??new D({routers:[new R,new q]})}};e.s(["Hono",()=>L],26481)},19991,e=>{"use strict";e.i(26481),e.s([])},66349,e=>{"use strict";var t=e=>t=>e.fetch(t);e.s(["handle",()=>t])},66587,e=>{"use strict";e.i(66349),e.s([],66587)},7805,e=>{"use strict";var t=e=>{var t;let r={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[],...e},a=(e=>{if("string"==typeof e)if("*"===e)return()=>e;else return t=>e===t?t:null;return"function"==typeof e?e:t=>e.includes(t)?t:null})(r.origin),i="function"==typeof(t=r.allowMethods)?t:Array.isArray(t)?()=>t:()=>[];return async function(e,t){function s(t,r){e.res.headers.set(t,r)}let n=await a(e.req.header("origin")||"",e);if(n&&s("Access-Control-Allow-Origin",n),r.credentials&&s("Access-Control-Allow-Credentials","true"),r.exposeHeaders?.length&&s("Access-Control-Expose-Headers",r.exposeHeaders.join(",")),"OPTIONS"===e.req.method){"*"!==r.origin&&s("Vary","Origin"),null!=r.maxAge&&s("Access-Control-Max-Age",r.maxAge.toString());let t=await i(e.req.header("origin")||"",e);t.length&&s("Access-Control-Allow-Methods",t.join(","));let a=r.allowHeaders;if(!a?.length){let t=e.req.header("Access-Control-Request-Headers");t&&(a=t.split(/\s*,\s*/))}return a?.length&&(s("Access-Control-Allow-Headers",a.join(",")),e.res.headers.append("Vary","Access-Control-Request-Headers")),e.res.headers.delete("Content-Length"),e.res.headers.delete("Content-Type"),new Response(null,{headers:e.res.headers,status:204,statusText:"No Content"})}await t(),"*"!==r.origin&&e.header("Vary","Origin",{append:!0})}};e.s(["cors",()=>t])},39768,e=>{"use strict";e.s([],39768)},79296,e=>{"use strict";function t(e,t,r){function a(r,a){var i;for(let s in Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(i=r._zod).traits??(i.traits=new Set),r._zod.traits.add(e),t(r,a),n.prototype)s in r||Object.defineProperty(r,s,{value:n.prototype[s].bind(r)});r._zod.constr=n,r._zod.def=a}let i=r?.Parent??Object;class s extends i{}function n(e){var t;let i=r?.Parent?new s:this;for(let r of(a(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))r();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(n,"init",{value:a}),Object.defineProperty(n,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(n,"name",{value:e}),n}function r(e,t){return"bigint"==typeof t?t.toString():t}Object.freeze({status:"aborted"}),Symbol("zod_brand"),Error.captureStackTrace||((...e)=>{}),()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}};let a=t("$ZodError",(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,r,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})}),i=t("ZodError",(e,t)=>{a.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>{let r,a,i;return r=t||function(e){return e.message},a={_errors:[]},(i=e=>{for(let t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>i({issues:e}));else if("invalid_key"===t.code)i({issues:t.issues});else if("invalid_element"===t.code)i({issues:t.issues});else if(0===t.path.length)a._errors.push(r(t));else{let e=a,i=0;for(;i<t.path.length;){let a=t.path[i];i===t.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(r(t))):e[a]=e[a]||{_errors:[]},e=e[a],i++}}})(e),a}},flatten:{value:t=>(function(e,t=e=>e.message){let r={},a=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}})(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})});e.s(["ZodError",0,i],79296)},16172,e=>{"use strict";let t;e.s([],44057),e.i(44057),(to=tl||(tl={})).assertEqual=e=>{},to.assertIs=function(e){},to.assertNever=function(e){throw Error()},to.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},to.getValidEnumValues=e=>{let t=to.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let a of t)r[a]=e[a];return to.objectValues(r)},to.objectValues=e=>to.objectKeys(e).map(function(t){return e[t]}),to.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},to.find=(e,t)=>{for(let r of e)if(t(r))return r},to.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,to.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},to.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(tc||(tc={})).mergeShapes=(e,t)=>({...e,...t});let r=tl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return r.undefined;case"string":return r.string;case"number":return Number.isNaN(e)?r.nan:r.number;case"boolean":return r.boolean;case"function":return r.function;case"bigint":return r.bigint;case"symbol":return r.symbol;case"object":if(Array.isArray(e))return r.array;if(null===e)return r.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return r.promise;if("undefined"!=typeof Map&&e instanceof Map)return r.map;if("undefined"!=typeof Set&&e instanceof Set)return r.set;if("undefined"!=typeof Date&&e instanceof Date)return r.date;return r.object;default:return r.unknown}};e.s(["ZodParsedType",0,r,"getParsedType",0,a,"objectUtil",()=>tc,"util",()=>tl],57500);let i=tl.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),s=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},a=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(a);else if("invalid_return_type"===i.code)a(i.returnTypeError);else if("invalid_arguments"===i.code)a(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,a=0;for(;a<i.path.length;){let r=i.path[a];a===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],a++}}};return a(this),r}static assert(e){if(!(e instanceof n))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,tl.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];t[r]=t[r]||[],t[r].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}n.create=e=>new n(e),e.s(["ZodError",()=>n,"ZodIssueCode",0,i,"quotelessJson",0,s],21466);let o=(e,t)=>{let a;switch(e.code){case i.invalid_type:a=e.received===r.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,tl.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${tl.joinValues(e.keys,", ")}`;break;case i.invalid_union:a="Invalid input";break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${tl.joinValues(e.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${tl.joinValues(e.options)}, received '${e.received}'`;break;case i.invalid_arguments:a="Invalid function arguments";break;case i.invalid_return_type:a="Invalid function return type";break;case i.invalid_date:a="Invalid date";break;case i.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:tl.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case i.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case i.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case i.custom:a="Invalid input";break;case i.invalid_intersection_types:a="Intersection results could not be merged";break;case i.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case i.not_finite:a="Number must be finite";break;default:a=t.defaultError,tl.assertNever(e)}return{message:a}},p=o;function d(e){p=e}function l(){return p}e.s(["getErrorMap",()=>l,"setErrorMap",()=>d],13981),e.i(13981),e.s(["defaultErrorMap",0,o,"getErrorMap",()=>l,"setErrorMap",()=>d],87672),e.i(87672);let c=e=>{let{data:t,path:r,errorMaps:a,issueData:i}=e,s=[...r,...i.path||[]],n={...i,path:s};if(void 0!==i.message)return{...i,path:s,message:i.message};let o="";for(let e of a.filter(e=>!!e).slice().reverse())o=e(n,{data:t,defaultError:o}).message;return{...i,path:s,message:o}},u=[];function h(e,t){let r=p,a=c({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===o?void 0:o].filter(e=>!!e)});e.common.issues.push(a)}class m{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let a of t){if("aborted"===a.status)return f;"dirty"===a.status&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,a=await e.value;r.push({key:t,value:a})}return m.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let a of t){let{key:t,value:i}=a;if("aborted"===t.status||"aborted"===i.status)return f;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||a.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let f=Object.freeze({status:"aborted"}),g=e=>({status:"dirty",value:e}),v=e=>({status:"valid",value:e}),y=e=>"aborted"===e.status,w=e=>"dirty"===e.status,b=e=>"valid"===e.status,_=e=>"undefined"!=typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"OK",0,v,"ParseStatus",()=>m,"addIssueToContext",()=>h,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"makeIssue",0,c],58216),e.i(58216),e.s([],28032),e.i(28032),e.i(57500),(tp=tu||(tu={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},tp.toString=e=>"string"==typeof e?e:e?.message;class x{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let N=(e,t)=>{if(b(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new n(e.common.issues);return this._error=t,this._error}}};function T(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=e;if(t&&(r||a))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:s}=e;return"invalid_enum_value"===t.code?{message:s??i.defaultError}:void 0===i.data?{message:s??a??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:s??r??i.defaultError}},description:i}}class E{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new m,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(_(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parseSync({data:e,path:r.path,parent:r});return N(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return b(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>b(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},i=this._parse({data:e,path:r.path,parent:r});return N(r,await (_(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,a)=>{let s=e(r),n=()=>a.addIssue({code:i.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(n(),!1)):!!s||(n(),!1)})}refinement(e,t){return this._refinement((r,a)=>!!e(r)||(a.addIssue("function"==typeof t?t(r,a):t),!1))}_refinement(e){return new ew({schema:this,typeName:th.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return eb.create(this,this._def)}nullable(){return e_.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this)}promise(){return ey.create(this,this._def)}or(e){return ei.create([this,e],this._def)}and(e){return eo.create(this,e,this._def)}transform(e){return new ew({...T(this._def),schema:this,typeName:th.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new ex({...T(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:th.ZodDefault})}brand(){return new eA({typeName:th.ZodBranded,type:this,...T(this._def)})}catch(e){return new eN({...T(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:th.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return eS.create(this,e)}readonly(){return ek.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let A=/^c[^\s-]{8,}$/i,S=/^[0-9a-z]+$/,k=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,R=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,D=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,P=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,j=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,q=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,F=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",B=RegExp(`^${U}$`);function V(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function z(e){let t=`${U}T${V(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class W extends E{_parse(e){var a,s,n,o;let p;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==r.string){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.string,received:t.parsedType}),f}let d=new m;for(let r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("max"===r.kind)e.data.length>r.value&&(h(p=this._getOrReturnCtx(e,p),{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),d.dirty());else if("length"===r.kind){let t=e.data.length>r.value,a=e.data.length<r.value;(t||a)&&(p=this._getOrReturnCtx(e,p),t?h(p,{code:i.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&h(p,{code:i.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),d.dirty())}else if("email"===r.kind)D.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"email",code:i.invalid_string,message:r.message}),d.dirty());else if("emoji"===r.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"emoji",code:i.invalid_string,message:r.message}),d.dirty());else if("uuid"===r.kind)O.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"uuid",code:i.invalid_string,message:r.message}),d.dirty());else if("nanoid"===r.kind)C.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"nanoid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid"===r.kind)A.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid",code:i.invalid_string,message:r.message}),d.dirty());else if("cuid2"===r.kind)S.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"cuid2",code:i.invalid_string,message:r.message}),d.dirty());else if("ulid"===r.kind)k.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"ulid",code:i.invalid_string,message:r.message}),d.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{h(p=this._getOrReturnCtx(e,p),{validation:"url",code:i.invalid_string,message:r.message}),d.dirty()}else"regex"===r.kind?(r.regex.lastIndex=0,r.regex.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"regex",code:i.invalid_string,message:r.message}),d.dirty())):"trim"===r.kind?e.data=e.data.trim():"includes"===r.kind?e.data.includes(r.value,r.position)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),d.dirty()):"toLowerCase"===r.kind?e.data=e.data.toLowerCase():"toUpperCase"===r.kind?e.data=e.data.toUpperCase():"startsWith"===r.kind?e.data.startsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{startsWith:r.value},message:r.message}),d.dirty()):"endsWith"===r.kind?e.data.endsWith(r.value)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:{endsWith:r.value},message:r.message}),d.dirty()):"datetime"===r.kind?z(r).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"datetime",message:r.message}),d.dirty()):"date"===r.kind?B.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"date",message:r.message}),d.dirty()):"time"===r.kind?RegExp(`^${V(r)}$`).test(e.data)||(h(p=this._getOrReturnCtx(e,p),{code:i.invalid_string,validation:"time",message:r.message}),d.dirty()):"duration"===r.kind?R.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"duration",code:i.invalid_string,message:r.message}),d.dirty()):"ip"===r.kind?(a=e.data,!(("v4"===(s=r.version)||!s)&&P.test(a)||("v6"===s||!s)&&q.test(a))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"ip",code:i.invalid_string,message:r.message}),d.dirty())):"jwt"===r.kind?!function(e,t){if(!I.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));if("object"!=typeof i||null===i||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)return!1;return!0}catch{return!1}}(e.data,r.alg)&&(h(p=this._getOrReturnCtx(e,p),{validation:"jwt",code:i.invalid_string,message:r.message}),d.dirty()):"cidr"===r.kind?(n=e.data,!(("v4"===(o=r.version)||!o)&&j.test(n)||("v6"===o||!o)&&L.test(n))&&1&&(h(p=this._getOrReturnCtx(e,p),{validation:"cidr",code:i.invalid_string,message:r.message}),d.dirty())):"base64"===r.kind?M.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64",code:i.invalid_string,message:r.message}),d.dirty()):"base64url"===r.kind?F.test(e.data)||(h(p=this._getOrReturnCtx(e,p),{validation:"base64url",code:i.invalid_string,message:r.message}),d.dirty()):tl.assertNever(r);return{status:d.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...tu.errToObj(r)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...tu.errToObj(e)})}url(e){return this._addCheck({kind:"url",...tu.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...tu.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...tu.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...tu.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...tu.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...tu.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...tu.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...tu.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...tu.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...tu.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...tu.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...tu.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...tu.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...tu.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...tu.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...tu.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...tu.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...tu.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...tu.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...tu.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...tu.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...tu.errToObj(t)})}nonempty(e){return this.min(1,tu.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}W.create=e=>new W({checks:[],typeName:th.ZodString,coerce:e?.coerce??!1,...T(e)});class $ extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==r.number){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.number,received:t.parsedType}),f}let a=new m;for(let r of this._def.checks)"int"===r.kind?tl.isInteger(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):"multipleOf"===r.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(e.data,r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(h(t=this._getOrReturnCtx(e,t),{code:i.not_finite,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:tu.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:tu.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:tu.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:tu.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&tl.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}$.create=e=>new $({checks:[],typeName:th.ZodNumber,coerce:e?.coerce||!1,...T(e)});class G extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==r.bigint)return this._getInvalidInput(e);let a=new m;for(let r of this._def.checks)"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(h(t=this._getOrReturnCtx(e,t),{code:i.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):tl.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit("min",e,!0,tu.toString(t))}gt(e,t){return this.setLimit("min",e,!1,tu.toString(t))}lte(e,t){return this.setLimit("max",e,!0,tu.toString(t))}lt(e,t){return this.setLimit("max",e,!1,tu.toString(t))}setLimit(e,t,r,a){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:tu.toString(a)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:tu.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:tu.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:tu.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}G.create=e=>new G({checks:[],typeName:th.ZodBigInt,coerce:e?.coerce??!1,...T(e)});class H extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==r.boolean){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.boolean,received:t.parsedType}),f}return v(e.data)}}H.create=e=>new H({typeName:th.ZodBoolean,coerce:e?.coerce||!1,...T(e)});class K extends E{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==r.date){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.date,received:t.parsedType}),f}if(Number.isNaN(e.data.getTime()))return h(this._getOrReturnCtx(e),{code:i.invalid_date}),f;let a=new m;for(let r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),a.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(h(t=this._getOrReturnCtx(e,t),{code:i.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),a.dirty()):tl.assertNever(r);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:tu.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:tu.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}K.create=e=>new K({checks:[],coerce:e?.coerce||!1,typeName:th.ZodDate,...T(e)});class J extends E{_parse(e){if(this._getType(e)!==r.symbol){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.symbol,received:t.parsedType}),f}return v(e.data)}}J.create=e=>new J({typeName:th.ZodSymbol,...T(e)});class Z extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.undefined,received:t.parsedType}),f}return v(e.data)}}Z.create=e=>new Z({typeName:th.ZodUndefined,...T(e)});class Q extends E{_parse(e){if(this._getType(e)!==r.null){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.null,received:t.parsedType}),f}return v(e.data)}}Q.create=e=>new Q({typeName:th.ZodNull,...T(e)});class Y extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return v(e.data)}}Y.create=e=>new Y({typeName:th.ZodAny,...T(e)});class X extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return v(e.data)}}X.create=e=>new X({typeName:th.ZodUnknown,...T(e)});class ee extends E{_parse(e){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.never,received:t.parsedType}),f}}ee.create=e=>new ee({typeName:th.ZodNever,...T(e)});class et extends E{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.void,received:t.parsedType}),f}return v(e.data)}}et.create=e=>new et({typeName:th.ZodVoid,...T(e)});class er extends E{_parse(e){let{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==r.array)return h(t,{code:i.invalid_type,expected:r.array,received:t.parsedType}),f;if(null!==s.exactLength){let e=t.data.length>s.exactLength.value,r=t.data.length<s.exactLength.value;(e||r)&&(h(t,{code:e?i.too_big:i.too_small,minimum:r?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(h(t,{code:i.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(h(t,{code:i.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>s.type._parseAsync(new x(t,e,t.path,r)))).then(e=>m.mergeArray(a,e));let n=[...t.data].map((e,r)=>s.type._parseSync(new x(t,e,t.path,r)));return m.mergeArray(a,n)}get element(){return this._def.type}min(e,t){return new er({...this._def,minLength:{value:e,message:tu.toString(t)}})}max(e,t){return new er({...this._def,maxLength:{value:e,message:tu.toString(t)}})}length(e,t){return new er({...this._def,exactLength:{value:e,message:tu.toString(t)}})}nonempty(e){return this.min(1,e)}}er.create=(e,t)=>new er({type:e,minLength:null,maxLength:null,exactLength:null,typeName:th.ZodArray,...T(t)});class ea extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=tl.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==r.object){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f}let{status:t,ctx:a}=this._processInputParams(e),{shape:s,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof ee&&"strip"===this._def.unknownKeys))for(let e in a.data)n.includes(e)||o.push(e);let p=[];for(let e of n){let t=s[e],r=a.data[e];p.push({key:{status:"valid",value:e},value:t._parse(new x(a,r,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ee){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of o)p.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(h(a,{code:i.unrecognized_keys,keys:o}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of o){let r=a.data[t];p.push({key:{status:"valid",value:t},value:e._parse(new x(a,r,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of p){let r=await t.key,a=await t.value;e.push({key:r,value:a,alwaysSet:t.alwaysSet})}return e}).then(e=>m.mergeObjectSync(t,e)):m.mergeObjectSync(t,p)}get shape(){return this._def.shape()}strict(e){return tu.errToObj,new ea({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let a=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:tu.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ea({...this._def,unknownKeys:"strip"})}passthrough(){return new ea({...this._def,unknownKeys:"passthrough"})}extend(e){return new ea({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ea({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:th.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ea({...this._def,catchall:e})}pick(e){let t={};for(let r of tl.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}omit(e){let t={};for(let r of tl.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new ea({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ea){let r={};for(let a in t.shape){let i=t.shape[a];r[a]=eb.create(e(i))}return new ea({...t._def,shape:()=>r})}if(t instanceof er)return new er({...t._def,type:e(t.element)});if(t instanceof eb)return eb.create(e(t.unwrap()));if(t instanceof e_)return e_.create(e(t.unwrap()));if(t instanceof ep)return ep.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of tl.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new ea({...this._def,shape:()=>t})}required(e){let t={};for(let r of tl.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof eb;)e=e._def.innerType;t[r]=e}return new ea({...this._def,shape:()=>t})}keyof(){return ef(tl.objectKeys(this.shape))}}ea.create=(e,t)=>new ea({shape:()=>e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.strictCreate=(e,t)=>new ea({shape:()=>e,unknownKeys:"strict",catchall:ee.create(),typeName:th.ZodObject,...T(t)}),ea.lazycreate=(e,t)=>new ea({shape:e,unknownKeys:"strip",catchall:ee.create(),typeName:th.ZodObject,...T(t)});class ei extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new n(e.ctx.common.issues));return h(t,{code:i.invalid_union,unionErrors:r}),f});{let e,a=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},s=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===s.status)return s;"dirty"!==s.status||e||(e={result:s,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let s=a.map(e=>new n(e));return h(t,{code:i.invalid_union,unionErrors:s}),f}}get options(){return this._def.options}}ei.create=(e,t)=>new ei({options:e,typeName:th.ZodUnion,...T(t)});let es=e=>{if(e instanceof eh)return es(e.schema);if(e instanceof ew)return es(e.innerType());if(e instanceof em)return[e.value];if(e instanceof eg)return e.options;if(e instanceof ev)return tl.objectValues(e.enum);else if(e instanceof ex)return es(e._def.innerType);else if(e instanceof Z)return[void 0];else if(e instanceof Q)return[null];else if(e instanceof eb)return[void 0,...es(e.unwrap())];else if(e instanceof e_)return[null,...es(e.unwrap())];else if(e instanceof eA)return es(e.unwrap());else if(e instanceof ek)return es(e.unwrap());else if(e instanceof eN)return es(e._def.innerType);else return[]};class en extends E{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return h(t,{code:i.invalid_type,expected:r.object,received:t.parsedType}),f;let a=this.discriminator,s=t.data[a],n=this.optionsMap.get(s);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let a=new Map;for(let r of t){let t=es(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(a.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);a.set(i,r)}}return new en({typeName:th.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...T(r)})}}class eo extends E{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(e,n)=>{if(y(e)||y(n))return f;let o=function e(t,i){let s=a(t),n=a(i);if(t===i)return{valid:!0,data:t};if(s===r.object&&n===r.object){let r=tl.objectKeys(i),a=tl.objectKeys(t).filter(e=>-1!==r.indexOf(e)),s={...t,...i};for(let r of a){let a=e(t[r],i[r]);if(!a.valid)return{valid:!1};s[r]=a.data}return{valid:!0,data:s}}if(s===r.array&&n===r.array){if(t.length!==i.length)return{valid:!1};let r=[];for(let a=0;a<t.length;a++){let s=e(t[a],i[a]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}if(s===r.date&&n===r.date&&+t==+i)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return o.valid?((w(e)||w(n))&&t.dirty(),{status:t.value,value:o.data}):(h(s,{code:i.invalid_intersection_types}),f)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}eo.create=(e,t,r)=>new eo({left:e,right:t,typeName:th.ZodIntersection,...T(r)});class ep extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.array)return h(a,{code:i.invalid_type,expected:r.array,received:a.parsedType}),f;if(a.data.length<this._def.items.length)return h(a,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&a.data.length>this._def.items.length&&(h(a,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...a.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new x(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>m.mergeArray(t,e)):m.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ep({...this._def,rest:e})}}ep.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ep({items:e,typeName:th.ZodTuple,rest:null,...T(t)})};class ed extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.object)return h(a,{code:i.invalid_type,expected:r.object,received:a.parsedType}),f;let s=[],n=this._def.keyType,o=this._def.valueType;for(let e in a.data)s.push({key:n._parse(new x(a,e,a.path,e)),value:o._parse(new x(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?m.mergeObjectAsync(t,s):m.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return new ed(t instanceof E?{keyType:e,valueType:t,typeName:th.ZodRecord,...T(r)}:{keyType:W.create(),valueType:e,typeName:th.ZodRecord,...T(t)})}}class el extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.map)return h(a,{code:i.invalid_type,expected:r.map,received:a.parsedType}),f;let s=this._def.keyType,n=this._def.valueType,o=[...a.data.entries()].map(([e,t],r)=>({key:s._parse(new x(a,e,a.path,[r,"key"])),value:n._parse(new x(a,t,a.path,[r,"value"]))}));if(a.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of o){let a=await r.key,i=await r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of o){let a=r.key,i=r.value;if("aborted"===a.status||"aborted"===i.status)return f;("dirty"===a.status||"dirty"===i.status)&&t.dirty(),e.set(a.value,i.value)}return{status:t.value,value:e}}}}el.create=(e,t,r)=>new el({valueType:t,keyType:e,typeName:th.ZodMap,...T(r)});class ec extends E{_parse(e){let{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==r.set)return h(a,{code:i.invalid_type,expected:r.set,received:a.parsedType}),f;let s=this._def;null!==s.minSize&&a.data.size<s.minSize.value&&(h(a,{code:i.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&a.data.size>s.maxSize.value&&(h(a,{code:i.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let n=this._def.valueType;function o(e){let r=new Set;for(let a of e){if("aborted"===a.status)return f;"dirty"===a.status&&t.dirty(),r.add(a.value)}return{status:t.value,value:r}}let p=[...a.data.values()].map((e,t)=>n._parse(new x(a,e,a.path,t)));return a.common.async?Promise.all(p).then(e=>o(e)):o(p)}min(e,t){return new ec({...this._def,minSize:{value:e,message:tu.toString(t)}})}max(e,t){return new ec({...this._def,maxSize:{value:e,message:tu.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ec.create=(e,t)=>new ec({valueType:e,minSize:null,maxSize:null,typeName:th.ZodSet,...T(t)});class eu extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.function)return h(t,{code:i.invalid_type,expected:r.function,received:t.parsedType}),f;function a(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:r}})}function s(e,r){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,p,o].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:r}})}let d={errorMap:t.common.contextualErrorMap},l=t.data;if(this._def.returns instanceof ey){let e=this;return v(async function(...t){let r=new n([]),i=await e._def.args.parseAsync(t,d).catch(e=>{throw r.addIssue(a(t,e)),r}),o=await Reflect.apply(l,this,i);return await e._def.returns._def.type.parseAsync(o,d).catch(e=>{throw r.addIssue(s(o,e)),r})})}{let e=this;return v(function(...t){let r=e._def.args.safeParse(t,d);if(!r.success)throw new n([a(t,r.error)]);let i=Reflect.apply(l,this,r.data),o=e._def.returns.safeParse(i,d);if(!o.success)throw new n([s(i,o.error)]);return o.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new eu({...this._def,args:ep.create(e).rest(X.create())})}returns(e){return new eu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new eu({args:e||ep.create([]).rest(X.create()),returns:t||X.create(),typeName:th.ZodFunction,...T(r)})}}class eh extends E{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}eh.create=(e,t)=>new eh({getter:e,typeName:th.ZodLazy,...T(t)});class em extends E{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ef(e,t){return new eg({values:e,typeName:th.ZodEnum,...T(t)})}em.create=(e,t)=>new em({value:e,typeName:th.ZodLiteral,...T(t)});class eg extends E{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:tl.joinValues(r),received:t.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:i.invalid_enum_value,options:r}),f}return v(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return eg.create(e,{...this._def,...t})}exclude(e,t=this._def){return eg.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eg.create=ef;class ev extends E{_parse(e){let t=tl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==r.string&&a.parsedType!==r.number){let e=tl.objectValues(t);return h(a,{expected:tl.joinValues(e),received:a.parsedType,code:i.invalid_type}),f}if(this._cache||(this._cache=new Set(tl.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=tl.objectValues(t);return h(a,{received:a.data,code:i.invalid_enum_value,options:e}),f}return v(e.data)}get enum(){return this._def.values}}ev.create=(e,t)=>new ev({values:e,typeName:th.ZodNativeEnum,...T(t)});class ey extends E{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==r.promise&&!1===t.common.async?(h(t,{code:i.invalid_type,expected:r.promise,received:t.parsedType}),f):v((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ey.create=(e,t)=>new ey({type:e,typeName:th.ZodPromise,...T(t)});class ew extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===th.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:e=>{h(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===a.type){let e=a.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return f;let a=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a});{if("aborted"===t.value)return f;let a=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===a.status?f:"dirty"===a.status||"dirty"===t.value?g(a.value):a}}if("refinement"===a.type){let e=e=>{let t=a.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?f:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===a.status?f:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}}if("transform"===a.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>b(e)?Promise.resolve(a.transform(e.value,i)).then(e=>({status:t.value,value:e})):f);else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!b(e))return f;let s=a.transform(e.value,i);if(s instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}tl.assertNever(a)}}ew.create=(e,t,r)=>new ew({schema:e,typeName:th.ZodEffects,effect:t,...T(r)}),ew.createWithPreprocess=(e,t,r)=>new ew({schema:t,effect:{type:"preprocess",transform:e},typeName:th.ZodEffects,...T(r)});class eb extends E{_parse(e){return this._getType(e)===r.undefined?v(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}eb.create=(e,t)=>new eb({innerType:e,typeName:th.ZodOptional,...T(t)});class e_ extends E{_parse(e){return this._getType(e)===r.null?v(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}e_.create=(e,t)=>new e_({innerType:e,typeName:th.ZodNullable,...T(t)});class ex extends E{_parse(e){let{ctx:t}=this._processInputParams(e),a=t.data;return t.parsedType===r.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ex.create=(e,t)=>new ex({innerType:e,typeName:th.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...T(t)});class eN extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _(a)?a.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}eN.create=(e,t)=>new eN({innerType:e,typeName:th.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...T(t)});class eT extends E{_parse(e){if(this._getType(e)!==r.nan){let t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:r.nan,received:t.parsedType}),f}return{status:"valid",value:e.data}}}eT.create=e=>new eT({typeName:th.ZodNaN,...T(e)});let eE=Symbol("zod_brand");class eA extends E{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class eS extends E{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),g(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?f:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new eS({in:e,out:t,typeName:th.ZodPipeline})}}class ek extends E{_parse(e){let t=this._def.innerType._parse(e),r=e=>(b(e)&&(e.value=Object.freeze(e.value)),e);return _(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}function eO(e,t){let r="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof r?{message:r}:r}function eC(e,t={},r){return e?Y.create().superRefine((a,i)=>{let s=e(a);if(s instanceof Promise)return s.then(e=>{if(!e){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}});if(!s){let e=eO(t,a),s=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:s})}}):Y.create()}ek.create=(e,t)=>new ek({innerType:e,typeName:th.ZodReadonly,...T(t)});let eI={object:ea.lazycreate};(td=th||(th={})).ZodString="ZodString",td.ZodNumber="ZodNumber",td.ZodNaN="ZodNaN",td.ZodBigInt="ZodBigInt",td.ZodBoolean="ZodBoolean",td.ZodDate="ZodDate",td.ZodSymbol="ZodSymbol",td.ZodUndefined="ZodUndefined",td.ZodNull="ZodNull",td.ZodAny="ZodAny",td.ZodUnknown="ZodUnknown",td.ZodNever="ZodNever",td.ZodVoid="ZodVoid",td.ZodArray="ZodArray",td.ZodObject="ZodObject",td.ZodUnion="ZodUnion",td.ZodDiscriminatedUnion="ZodDiscriminatedUnion",td.ZodIntersection="ZodIntersection",td.ZodTuple="ZodTuple",td.ZodRecord="ZodRecord",td.ZodMap="ZodMap",td.ZodSet="ZodSet",td.ZodFunction="ZodFunction",td.ZodLazy="ZodLazy",td.ZodLiteral="ZodLiteral",td.ZodEnum="ZodEnum",td.ZodEffects="ZodEffects",td.ZodNativeEnum="ZodNativeEnum",td.ZodOptional="ZodOptional",td.ZodNullable="ZodNullable",td.ZodDefault="ZodDefault",td.ZodCatch="ZodCatch",td.ZodPromise="ZodPromise",td.ZodBranded="ZodBranded",td.ZodPipeline="ZodPipeline",td.ZodReadonly="ZodReadonly";let eR=(e,t={message:`Input not instance of ${e.name}`})=>eC(t=>t instanceof e,t),eD=W.create,eP=$.create,ej=eT.create,eq=G.create,eL=H.create,eM=K.create,eF=J.create,eU=Z.create,eB=Q.create,eV=Y.create,ez=X.create,eW=ee.create,e$=et.create,eG=er.create,eH=ea.create,eK=ea.strictCreate,eJ=ei.create,eZ=en.create,eQ=eo.create,eY=ep.create,eX=ed.create,e1=el.create,e0=ec.create,e2=eu.create,e6=eh.create,e4=em.create,e3=eg.create,e9=ev.create,e5=ey.create,e8=ew.create,e7=eb.create,te=e_.create,tt=ew.createWithPreprocess,tr=eS.create,ta=()=>eD().optional(),ti=()=>eP().optional(),ts=()=>eL().optional(),tn={string:e=>W.create({...e,coerce:!0}),number:e=>$.create({...e,coerce:!0}),boolean:e=>H.create({...e,coerce:!0}),bigint:e=>G.create({...e,coerce:!0}),date:e=>K.create({...e,coerce:!0})};e.s(["BRAND",0,eE,"NEVER",0,f,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"instanceof",()=>eR,"intersection",()=>eQ,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"record",()=>eX,"set",()=>e0,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"void",()=>e$],73023),e.i(73023),e.i(21466),e.s(["BRAND",0,eE,"DIRTY",0,g,"EMPTY_PATH",0,u,"INVALID",0,f,"NEVER",0,f,"OK",0,v,"ParseStatus",()=>m,"Schema",()=>E,"ZodAny",()=>Y,"ZodArray",()=>er,"ZodBigInt",()=>G,"ZodBoolean",()=>H,"ZodBranded",()=>eA,"ZodCatch",()=>eN,"ZodDate",()=>K,"ZodDefault",()=>ex,"ZodDiscriminatedUnion",()=>en,"ZodEffects",()=>ew,"ZodEnum",()=>eg,"ZodError",()=>n,"ZodFirstPartyTypeKind",()=>th,"ZodFunction",()=>eu,"ZodIntersection",()=>eo,"ZodIssueCode",0,i,"ZodLazy",()=>eh,"ZodLiteral",()=>em,"ZodMap",()=>el,"ZodNaN",()=>eT,"ZodNativeEnum",()=>ev,"ZodNever",()=>ee,"ZodNull",()=>Q,"ZodNullable",()=>e_,"ZodNumber",()=>$,"ZodObject",()=>ea,"ZodOptional",()=>eb,"ZodParsedType",0,r,"ZodPipeline",()=>eS,"ZodPromise",()=>ey,"ZodReadonly",()=>ek,"ZodRecord",()=>ed,"ZodSchema",()=>E,"ZodSet",()=>ec,"ZodString",()=>W,"ZodSymbol",()=>J,"ZodTransformer",()=>ew,"ZodTuple",()=>ep,"ZodType",()=>E,"ZodUndefined",()=>Z,"ZodUnion",()=>ei,"ZodUnknown",()=>X,"ZodVoid",()=>et,"addIssueToContext",()=>h,"any",()=>eV,"array",()=>eG,"bigint",()=>eq,"boolean",()=>eL,"coerce",0,tn,"custom",()=>eC,"date",()=>eM,"datetimeRegex",()=>z,"defaultErrorMap",0,o,"discriminatedUnion",()=>eZ,"effect",()=>e8,"enum",()=>e3,"function",()=>e2,"getErrorMap",()=>l,"getParsedType",0,a,"instanceof",()=>eR,"intersection",()=>eQ,"isAborted",0,y,"isAsync",0,_,"isDirty",0,w,"isValid",0,b,"late",0,eI,"lazy",()=>e6,"literal",()=>e4,"makeIssue",0,c,"map",()=>e1,"nan",()=>ej,"nativeEnum",()=>e9,"never",()=>eW,"null",()=>eB,"nullable",()=>te,"number",()=>eP,"object",()=>eH,"objectUtil",()=>tc,"oboolean",()=>ts,"onumber",()=>ti,"optional",()=>e7,"ostring",()=>ta,"pipeline",()=>tr,"preprocess",()=>tt,"promise",()=>e5,"quotelessJson",0,s,"record",()=>eX,"set",()=>e0,"setErrorMap",()=>d,"strictObject",()=>eK,"string",()=>eD,"symbol",()=>eF,"transformer",()=>e8,"tuple",()=>eY,"undefined",()=>eU,"union",()=>eJ,"unknown",()=>ez,"util",()=>tl,"void",()=>e$],59063);var to,tp,td,tl,tc,tu,th,tm=e.i(59063);e.s(["z",0,tm],16172)},96401,e=>{"use strict";var t=e.i(16172);let r=t.z.enum(["local","postgres"]),a=t.z.enum(["local","gcs"]),i=t.z.object({serverPepper:t.z.string().min(1),standaloneMode:t.z.boolean().default(!1),storeTypes:t.z.object({global:r,log:r.optional(),app:r.optional(),blob:a}),paths:t.z.object({localStore:t.z.string().min(1),blobStore:t.z.string().min(1)}),gcs:t.z.object({bucketName:t.z.string().optional()})}),s={serverPepper:process.env.API_KEY_PEPPER||"default-pepper-change-in-production",standaloneMode:"false"!==process.env.AILOG_STANDALONE_MODE,storeTypes:{global:process.env.STORE_TYPE||"local",log:process.env.LOG_STORE_TYPE,app:process.env.APP_STORE_TYPE,blob:process.env.BLOB_STORE_TYPE||"local"},paths:{localStore:process.env.LOCAL_STORE_PATH||"./.ailog/data",blobStore:process.env.BLOB_STORE_LOCAL_PATH||"./data/blobs"},gcs:{bucketName:process.env.GCS_BUCKET_NAME}},n=i.parse(s),o={log:n.storeTypes.log??n.storeTypes.global,app:n.storeTypes.app??n.storeTypes.global,blob:n.storeTypes.blob};e.s(["config",0,n,"resolvedStoreTypes",0,o])},13558,e=>{"use strict";var t=e.i(30314),r=/^[\w!#$%&'*.^`|~+-]+$/,a=/^[ !#-:<-[\]-~]*$/,i=(e,i)=>{if(i&&-1===e.indexOf(i))return{};let s=e.trim().split(";"),n={};for(let e of s){let s=(e=e.trim()).indexOf("=");if(-1===s)continue;let o=e.substring(0,s).trim();if(i&&i!==o||!r.test(o))continue;let p=e.substring(s+1).trim();if(p.startsWith('"')&&p.endsWith('"')&&(p=p.slice(1,-1)),a.test(p)&&(n[o]=-1!==p.indexOf("%")?(0,t.tryDecode)(p,t.decodeURIComponent_):p,i))break}return n},s=e.i(80253),n=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,o=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,p=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;let d=function(e,t,r,a){let d;return d=async(i,s)=>{let n=i;if("header"===e&&"_def"in t||"header"===e&&"_zod"in t){let e=Object.fromEntries(Object.keys("in"in t?t.in.shape:t.shape).map(e=>[e.toLowerCase(),e]));n=Object.fromEntries(Object.entries(i).map(([t,r])=>[e[t]||t,r]))}let o=a&&a.validationFunction?await a.validationFunction(t,n):await t.safeParseAsync(n);if(r){let t=await r({data:n,...o,target:e},s);if(t){if(t instanceof Response)return t;if("response"in t)return t.response}}return o.success?o.data:s.json(o,400)},async(t,r)=>{let a={},l=t.req.header("Content-Type");switch(e){case"json":if(!l||!n.test(l))break;try{a=await t.req.json()}catch{throw new s.HTTPException(400,{message:"Malformed JSON in request body"})}break;case"form":{let e;if(!l||!(o.test(l)||p.test(l)))break;if(t.req.bodyCache.formData)e=await t.req.bodyCache.formData;else try{let r=await t.req.arrayBuffer();e=await new Response(r,{headers:{"Content-Type":l}}).formData(),t.req.bodyCache.formData=e}catch(t){let e="Malformed FormData request.";throw e+=t instanceof Error?` ${t.message}`:` ${String(t)}`,new s.HTTPException(400,{message:e})}let r={};e.forEach((e,t)=>{t.endsWith("[]")?(r[t]??=[]).push(e):Array.isArray(r[t])?r[t].push(e):t in r?r[t]=[r[t],e]:r[t]=e}),a=r;break}case"query":a=Object.fromEntries(Object.entries(t.req.queries()).map(([e,t])=>1===t.length?[e,t[0]]:[e,t]));break;case"param":a=t.req.param();break;case"header":a=t.req.header();break;case"cookie":a=((e,t,r)=>{let a=e.req.raw.headers.get("Cookie");if("string"==typeof t){if(!a)return;let e=t;return"secure"===r?e="__Secure-"+t:"host"===r&&(e="__Host-"+t),i(a,e)[e]}return a?i(a):{}})(t)}let c=await d(a,t);return c instanceof Response?c:(t.req.addValidatedData(e,c),await r())}};e.s(["zValidator",()=>d],13558)},84739,482,62212,79044,56967,6697,54199,6937,80864,90348,56900,22177,46220,40203,9581,83013,50430,72866,29986,27539,34939,2758,90640,46432,13424,82258,45393,86566,72515,21797,51014,67204,87799,e=>{"use strict";function t(e){return void 0===e||void 0===e}function r(e){return"string"==typeof e}function a(e){return"number"==typeof e}function i(e){return"boolean"==typeof e}function s(e){return null===e}function n(e){return e instanceof Date}function o(e){return"bigint"==typeof e}function p(e){return"function"==typeof e}function d(e){return"object"==typeof e&&null!==e}function l(e){return e[e.length-1]}function c(e){return Object.freeze(e)}function u(e){return h(e)?e:[e]}function h(e){return Array.isArray(e)}function m(e){return e}Object.prototype.toString,e.s(["asArray",()=>u,"freeze",()=>c,"getLast",()=>l,"isBigInt",()=>o,"isBoolean",()=>i,"isDate",()=>n,"isFunction",()=>p,"isNull",()=>s,"isNumber",()=>a,"isObject",()=>d,"isReadonlyArray",()=>h,"isString",()=>r,"isUndefined",()=>t,"noop",()=>m],84739);let f=c({is:e=>"IdentifierNode"===e.kind,create:e=>c({kind:"IdentifierNode",name:e})});e.s(["IdentifierNode",0,f],482);let g=c({is:e=>"SchemableIdentifierNode"===e.kind,create:e=>c({kind:"SchemableIdentifierNode",identifier:f.create(e)}),createWithSchema:(e,t)=>c({kind:"SchemableIdentifierNode",schema:f.create(e),identifier:f.create(t)})});e.s(["SchemableIdentifierNode",0,g],62212),e.s(["parseAliasedTable",()=>rt,"parseTable",()=>rr,"parseTableExpression",()=>re,"parseTableExpressionOrList",()=>t7],87799);let v=c({is:e=>"AliasNode"===e.kind,create:(e,t)=>c({kind:"AliasNode",node:e,alias:t})});e.s(["AliasNode",0,v],79044);let y=c({is:e=>"TableNode"===e.kind,create:e=>c({kind:"TableNode",table:g.create(e)}),createWithSchema:(e,t)=>c({kind:"TableNode",table:g.createWithSchema(e,t)})});function w(e){return d(e)&&p(e.toOperationNode)}e.s(["isExpressionOrFactory",()=>t8,"parseAliasedExpression",()=>t5,"parseExpression",()=>t9],67204),e.s(["isOperationNodeSource",()=>w],56967);let b=c({is:e=>"SelectModifierNode"===e.kind,create:(e,t)=>c({kind:"SelectModifierNode",modifier:e,of:t}),createWithExpression:e=>c({kind:"SelectModifierNode",rawModifier:e})}),_=c({is:e=>"AndNode"===e.kind,create:(e,t)=>c({kind:"AndNode",left:e,right:t})}),x=c({is:e=>"OrNode"===e.kind,create:(e,t)=>c({kind:"OrNode",left:e,right:t})}),N=c({is:e=>"OnNode"===e.kind,create:e=>c({kind:"OnNode",on:e}),cloneWithOperation:(e,t,r)=>c({...e,on:"And"===t?_.create(e.on,r):x.create(e.on,r)})}),T=c({is:e=>"JoinNode"===e.kind,create:(e,t)=>c({kind:"JoinNode",joinType:e,table:t,on:void 0}),createWithOn:(e,t,r)=>c({kind:"JoinNode",joinType:e,table:t,on:N.create(r)}),cloneWithOn:(e,t)=>c({...e,on:e.on?N.cloneWithOperation(e.on,"And",t):N.create(t)})});e.s(["parseFilterList",()=>ec,"parseFilterObject",()=>el,"parseReferentialBinaryOperation",()=>ed,"parseValueBinaryOperation",()=>ep,"parseValueBinaryOperationOrExpression",()=>eo],83013);let E=c({is:e=>"BinaryOperationNode"===e.kind,create:(e,t,r)=>c({kind:"BinaryOperationNode",leftOperand:e,operator:t,rightOperand:r})}),A=["->","->>"],S=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from","+","-","*","/","%","^","&","|","#","<<",">>","&&","||",...A,"not","-","exists","not exists","between","between symmetric"],k=c({is:e=>"OperatorNode"===e.kind,create:e=>c({kind:"OperatorNode",operator:e})});function O(e){return r(e)&&A.includes(e)}e.s(["OPERATORS",0,S,"OperatorNode",0,k,"isJSONOperator",()=>O],6697),e.s(["parseAliasedStringReference",()=>J,"parseColumnName",()=>Z,"parseJSONReference",()=>H,"parseOrderedColumnName",()=>Q,"parseReferenceExpression",()=>G,"parseReferenceExpressionOrList",()=>$,"parseSimpleReferenceExpression",()=>W,"parseStringReference",()=>K],56900);let C=c({is:e=>"ColumnNode"===e.kind,create:e=>c({kind:"ColumnNode",column:f.create(e)})});e.s(["ColumnNode",0,C],54199);let I=c({is:e=>"SelectAllNode"===e.kind,create:()=>c({kind:"SelectAllNode"})});e.s(["SelectAllNode",0,I],6937);let R=c({is:e=>"ReferenceNode"===e.kind,create:(e,t)=>c({kind:"ReferenceNode",table:t,column:e}),createSelectAll:e=>c({kind:"ReferenceNode",table:e,column:I.create()})});e.s(["DynamicReferenceBuilder",()=>D,"isDynamicReferenceBuilder",()=>P],80864);class D{#L;get dynamicReference(){return this.#L}get refType(){}constructor(e){this.#L=e}toOperationNode(){return W(this.#L)}}function P(e){return d(e)&&w(e)&&r(e.dynamicReference)}let j=c({is:e=>"OrderByItemNode"===e.kind,create:(e,t)=>c({kind:"OrderByItemNode",orderBy:e,direction:t})}),q=c({is:e=>"RawNode"===e.kind,create:(e,t)=>c({kind:"RawNode",sqlFragments:c(e),parameters:c(t)}),createWithSql:e=>q.create([e],[]),createWithChild:e=>q.create(["",""],[e]),createWithChildren:e=>q.create(Array(e.length+1).fill(""),e)});function L(e){return"asc"===e||"desc"===e}function M(e){if(2===e.length)return[F(e[0],e[1])];if(1===e.length){let[t]=e;return Array.isArray(t)?t.map(e=>F(e)):[F(t)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function F(e,t){let r=function(e){if(t8(e))return t9(e);if(P(e))return e.toOperationNode();let[t,r]=e.split(" ");if(r){if(!L(r))throw Error(`Invalid order by direction: ${r}`);return j.create(K(t),U(r))}return K(e)}(e);if(j.is(r)){if(t)throw Error("Cannot specify direction twice!");return r}return j.create(r,U(t))}function U(e){if(e)return"asc"===e||"desc"===e?q.createWithSql(e):e.toOperationNode()}e.s(["RawNode",0,q],90348);let B=c({is:e=>"JSONReferenceNode"===e.kind,create:(e,t)=>c({kind:"JSONReferenceNode",reference:e,traversal:t}),cloneWithTraversal:(e,t)=>c({...e,traversal:t})}),V=c({is:e=>"JSONOperatorChainNode"===e.kind,create:e=>c({kind:"JSONOperatorChainNode",operator:e,values:c([])}),cloneWithValue:(e,t)=>c({...e,values:c([...e.values,t])})}),z=c({is:e=>"JSONPathNode"===e.kind,create:e=>c({kind:"JSONPathNode",inOperator:e,pathLegs:c([])}),cloneWithLeg:(e,t)=>c({...e,pathLegs:c([...e.pathLegs,t])})});function W(e){return r(e)?K(e):e.toOperationNode()}function $(e){return h(e)?e.map(e=>G(e)):[G(e)]}function G(e){return t8(e)?t9(e):W(e)}function H(e,t){let r=K(e);if(O(t))return B.create(r,V.create(k.create(t)));let a=t.slice(0,-1);if(O(a))return B.create(r,z.create(k.create(a)));throw Error(`Invalid JSON operator: ${t}`)}function K(e){if(!e.includes("."))return R.create(C.create(e));let t=e.split(".").map(Y);if(3===t.length)return function(e){let[t,r,a]=e;return R.create(C.create(a),y.createWithSchema(t,r))}(t);if(2===t.length)return function(e){let[t,r]=e;return R.create(C.create(r),y.create(t))}(t);throw Error(`invalid column reference ${e}`)}function J(e){let t=" as ";if(!e.includes(t))return K(e);{let[r,a]=e.split(t).map(Y);return v.create(K(r),f.create(a))}}function Z(e){return C.create(e)}function Q(e){if(!e.includes(" "))return Z(e);{let[t,r]=e.split(" ").map(Y);if(!L(r))throw Error(`invalid order direction "${r}" next to "${t}"`);return M([t,r])[0]}}function Y(e){return e.trim()}e.s(["isSafeImmediateValue",()=>ei,"parseSafeImmediateValue",()=>es,"parseValueExpression",()=>ea,"parseValueExpressionOrList",()=>er],40203);let X=c({is:e=>"PrimitiveValueListNode"===e.kind,create:e=>c({kind:"PrimitiveValueListNode",values:c([...e])})}),ee=c({is:e=>"ValueListNode"===e.kind,create:e=>c({kind:"ValueListNode",values:c(e)})});e.s(["ValueListNode",0,ee],22177);let et=c({is:e=>"ValueNode"===e.kind,create:e=>c({kind:"ValueNode",value:e}),createImmediate:e=>c({kind:"ValueNode",value:e,immediate:!0})});function er(e){var t;return h(e)?(t=e).some(t8)?ee.create(t.map(e=>ea(e))):X.create(t):ea(e)}function ea(e){return t8(e)?t9(e):et.create(e)}function ei(e){return a(e)||i(e)||s(e)}function es(e){if(!ei(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return et.createImmediate(e)}e.s(["ValueNode",0,et],46220);let en=c({is:e=>"ParensNode"===e.kind,create:e=>c({kind:"ParensNode",node:e})});function eo(e){if(3===e.length)return ep(e[0],e[1],e[2]);if(1===e.length)return ea(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function ep(e,t,r){var a,n;return("is"===(a=t)||"is not"===a)&&(s(n=r)||i(n))?E.create(G(e),eu(t),et.createImmediate(r)):E.create(G(e),eu(t),er(r))}function ed(e,t,r){return E.create(G(e),eu(t),G(r))}function el(e,r){return ec(Object.entries(e).filter(([,e])=>!t(e)).map(([e,t])=>{var r;return ep(e,s(r=t)||i(r)?"is":"=",t)}),r)}function ec(e,t,r=!0){let a="and"===t?_.create:x.create;if(0===e.length)return E.create(et.createImmediate(1),k.create("="),et.createImmediate(+("and"===t)));let i=eh(e[0]);for(let t=1;t<e.length;++t)i=a(i,eh(e[t]));return e.length>1&&r?en.create(i):i}e.s(["ParensNode",0,en],9581);function eu(e){if(r(e)&&S.includes(e))return k.create(e);if(w(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function eh(e){return w(e)?e.toOperationNode():e}let em=c({is:e=>"OrderByNode"===e.kind,create:e=>c({kind:"OrderByNode",items:c([...e])}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ef=c({is:e=>"PartitionByNode"===e.kind,create:e=>c({kind:"PartitionByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),eg=c({is:e=>"OverNode"===e.kind,create:()=>c({kind:"OverNode"}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithPartitionByItems:(e,t)=>c({...e,partitionBy:e.partitionBy?ef.cloneWithItems(e.partitionBy,t):ef.create(t)})}),ev=c({is:e=>"FromNode"===e.kind,create:e=>c({kind:"FromNode",froms:c(e)}),cloneWithFroms:(e,t)=>c({...e,froms:c([...e.froms,...t])})}),ey=c({is:e=>"GroupByNode"===e.kind,create:e=>c({kind:"GroupByNode",items:c(e)}),cloneWithItems:(e,t)=>c({...e,items:c([...e.items,...t])})}),ew=c({is:e=>"HavingNode"===e.kind,create:e=>c({kind:"HavingNode",having:e}),cloneWithOperation:(e,t,r)=>c({...e,having:"And"===t?_.create(e.having,r):x.create(e.having,r)})}),eb=c({is:e=>"SelectQueryNode"===e.kind,create:e=>c({kind:"SelectQueryNode",...e&&{with:e}}),createFrom:(e,t)=>c({kind:"SelectQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)}),cloneWithDistinctOn:(e,t)=>c({...e,distinctOn:e.distinctOn?c([...e.distinctOn,...t]):c(t)}),cloneWithFrontModifier:(e,t)=>c({...e,frontModifiers:e.frontModifiers?c([...e.frontModifiers,t]):c([t])}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithGroupByItems:(e,t)=>c({...e,groupBy:e.groupBy?ey.cloneWithItems(e.groupBy,t):ey.create(t)}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithOffset:(e,t)=>c({...e,offset:t}),cloneWithFetch:(e,t)=>c({...e,fetch:t}),cloneWithHaving:(e,t)=>c({...e,having:e.having?ew.cloneWithOperation(e.having,"And",t):ew.create(t)}),cloneWithSetOperations:(e,t)=>c({...e,setOperations:e.setOperations?c([...e.setOperations,...t]):c([...t])}),cloneWithoutSelections:e=>c({...e,selections:[]}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithoutOffset:e=>c({...e,offset:void 0}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithoutGroupBy:e=>c({...e,groupBy:void 0})});function e_(e,t){Object.defineProperties(e.prototype,{then:{enumerable:!1,value:()=>{throw Error(t)}}})}e.s(["preventAwait",()=>e_],50430);class ex{#M;constructor(e){this.#M=c(e)}on(...e){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,eo(e))})}onRef(e,t,r){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,ed(e,t,r))})}onTrue(){return new ex({...this.#M,joinNode:T.cloneWithOn(this.#M.joinNode,q.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#M.joinNode}}e_(ex,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");let eN=c({is:e=>"PartitionByItemNode"===e.kind,create:e=>c({kind:"PartitionByItemNode",partitionBy:e})});class eT{#M;constructor(e){this.#M=c(e)}orderBy(e,t){return new eT({overNode:eg.cloneWithOrderByItems(this.#M.overNode,M([e,t]))})}partitionBy(e){return new eT({overNode:eg.cloneWithPartitionByItems(this.#M.overNode,$(e).map(eN.create))})}$call(e){return e(this)}toOperationNode(){return this.#M.overNode}}e_(eT,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query."),e.s(["QueryCreator",()=>tA],82258);let eE=c({is:e=>"SelectionNode"===e.kind,create:e=>c({kind:"SelectionNode",selection:e}),createSelectAll:()=>c({kind:"SelectionNode",selection:I.create()}),createSelectAllFromTable:e=>c({kind:"SelectionNode",selection:R.createSelectAll(e)})});function eA(e){return p(e)?eA(e(t3())):h(e)?e.map(e=>eS(e)):[eS(e)]}function eS(e){return r(e)?eE.create(J(e)):P(e)?eE.create(e.toOperationNode()):eE.create(t5(e))}function ek(e){return e?Array.isArray(e)?e.map(eO):[eO(e)]:[eE.createSelectAll()]}function eO(e){if(r(e))return eE.createSelectAllFromTable(rr(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}let eC=c({is:e=>"ValuesNode"===e.kind,create:e=>c({kind:"ValuesNode",values:c(e)})}),eI=c({is:e=>"DefaultInsertValueNode"===e.kind,create:()=>c({kind:"DefaultInsertValueNode"})});function eR(e){var r;let a,i=p(e)?e(t3()):e;return a=function(e){let t=new Map;for(let r of e)for(let e of Object.keys(r))t.has(e)||void 0===r[e]||t.set(e,t.size);return t}(r=h(i)?i:c([i])),[c([...a.keys()].map(C.create)),eC.create(r.map(e=>(function(e,r){let a=Object.keys(e),i=Array.from({length:r.size}),s=!1,n=a.length;for(let o of a){let a=r.get(o);if(t(a)){n--;continue}let p=e[o];(t(p)||t8(p))&&(s=!0),i[a]=p}if(n<r.size||s){let e=eI.create();return ee.create(i.map(r=>t(r)?e:ea(r)))}return X.create(i)})(e,a)))]}let eD=c({is:e=>"InsertQueryNode"===e.kind,create:(e,t,r)=>c({kind:"InsertQueryNode",into:e,...t&&{with:t},replace:r}),createWithoutInto:()=>c({kind:"InsertQueryNode"}),cloneWith:(e,t)=>c({...e,...t})});e.s(["InsertQueryNode",0,eD],72866);let eP=c({is:e=>"UpdateQueryNode"===e.kind,create:(e,t)=>c({kind:"UpdateQueryNode",table:e,...t&&{with:t}}),createWithoutTable:()=>c({kind:"UpdateQueryNode"}),cloneWithFromItems:(e,t)=>c({...e,from:e.from?ev.cloneWithFroms(e.from,t):ev.create(t)}),cloneWithUpdates:(e,t)=>c({...e,updates:e.updates?c([...e.updates,...t]):t}),cloneWithLimit:(e,t)=>c({...e,limit:t})}),ej=c({is:e=>"UsingNode"===e.kind,create:e=>c({kind:"UsingNode",tables:c(e)}),cloneWithTables:(e,t)=>c({...e,tables:c([...e.tables,...t])})}),eq=c({is:e=>"DeleteQueryNode"===e.kind,create:(e,t)=>c({kind:"DeleteQueryNode",from:ev.create(e),...t&&{with:t}}),cloneWithOrderByItems:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithoutOrderBy:e=>c({...e,orderBy:void 0}),cloneWithLimit:(e,t)=>c({...e,limit:t}),cloneWithoutLimit:e=>c({...e,limit:void 0}),cloneWithUsing:(e,t)=>c({...e,using:void 0!==e.using?ej.cloneWithTables(e.using,t):ej.create(t)})}),eL=c({is:e=>"WhereNode"===e.kind,create:e=>c({kind:"WhereNode",where:e}),cloneWithOperation:(e,t,r)=>c({...e,where:"And"===t?_.create(e.where,r):x.create(e.where,r)})}),eM=c({is:e=>"ReturningNode"===e.kind,create:e=>c({kind:"ReturningNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),eF=c({is:e=>"ExplainNode"===e.kind,create:(e,t)=>c({kind:"ExplainNode",format:e,options:t})}),eU=c({is:e=>"WhenNode"===e.kind,create:e=>c({kind:"WhenNode",condition:e}),cloneWithResult:(e,t)=>c({...e,result:t})}),eB=c({is:e=>"MergeQueryNode"===e.kind,create:(e,t)=>c({kind:"MergeQueryNode",into:e,...t&&{with:t}}),cloneWithUsing:(e,t)=>c({...e,using:t}),cloneWithWhen:(e,t)=>c({...e,whens:e.whens?c([...e.whens,t]):c([t])}),cloneWithThen:(e,t)=>c({...e,whens:e.whens?c([...e.whens.slice(0,-1),eU.cloneWithResult(e.whens[e.whens.length-1],t)]):void 0})});e.s(["MergeQueryNode",0,eB],29986);let eV=c({is:e=>"OutputNode"===e.kind,create:e=>c({kind:"OutputNode",selections:c(e)}),cloneWithSelections:(e,t)=>c({...e,selections:e.selections?c([...e.selections,...t]):c(t)})}),ez=c({is:e=>eb.is(e)||eD.is(e)||eP.is(e)||eq.is(e)||eB.is(e),cloneWithEndModifier:(e,t)=>c({...e,endModifiers:e.endModifiers?c([...e.endModifiers,t]):c([t])}),cloneWithWhere:(e,t)=>c({...e,where:e.where?eL.cloneWithOperation(e.where,"And",t):eL.create(t)}),cloneWithJoin:(e,t)=>c({...e,joins:e.joins?c([...e.joins,t]):c([t])}),cloneWithReturning:(e,t)=>c({...e,returning:e.returning?eM.cloneWithSelections(e.returning,t):eM.create(t)}),cloneWithoutReturning:e=>c({...e,returning:void 0}),cloneWithoutWhere:e=>c({...e,where:void 0}),cloneWithExplain:(e,t,r)=>c({...e,explain:eF.create(t,r?.toOperationNode())}),cloneWithTop:(e,t)=>c({...e,top:t}),cloneWithOutput:(e,t)=>c({...e,output:e.output?eV.cloneWithSelections(e.output,t):eV.create(t)})});e.s(["QueryNode",0,ez],27539);let eW=c({is:e=>"ColumnUpdateNode"===e.kind,create:(e,t)=>c({kind:"ColumnUpdateNode",column:e,value:t})});function e$(e){return Object.entries(p(e)?e(t3()):e).filter(([e,t])=>void 0!==t).map(([e,t])=>eW.create(C.create(e),ea(t)))}let eG=c({is:e=>"OnDuplicateKeyNode"===e.kind,create:e=>c({kind:"OnDuplicateKeyNode",updates:e})});class eH{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}}class eK extends Error{node;constructor(e){super("no result"),this.node=e}}function eJ(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}let eZ=c({is:e=>"OnConflictNode"===e.kind,create:()=>c({kind:"OnConflictNode"}),cloneWith:(e,t)=>c({...e,...t}),cloneWithIndexWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"And",t):eL.create(t)}),cloneWithIndexOrWhere:(e,t)=>c({...e,indexWhere:e.indexWhere?eL.cloneWithOperation(e.indexWhere,"Or",t):eL.create(t)}),cloneWithUpdateWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"And",t):eL.create(t)}),cloneWithUpdateOrWhere:(e,t)=>c({...e,updateWhere:e.updateWhere?eL.cloneWithOperation(e.updateWhere,"Or",t):eL.create(t)}),cloneWithoutIndexWhere:e=>c({...e,indexWhere:void 0}),cloneWithoutUpdateWhere:e=>c({...e,updateWhere:void 0})});class eQ{#M;constructor(e){this.#M=c(e)}column(e){let t=C.create(e);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,t]):c([t])})})}columns(e){let t=e.map(C.create);return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{columns:this.#M.onConflictNode.columns?c([...this.#M.onConflictNode.columns,...t]):c(t)})})}constraint(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{constraint:f.create(e)})})}expression(e){return new eQ({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eQ({...this.#M,onConflictNode:eZ.cloneWithIndexWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eQ({...this.#M,onConflictNode:eZ.cloneWithoutIndexWhere(this.#M.onConflictNode)})}doNothing(){return new eY({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new eX({...this.#M,onConflictNode:eZ.cloneWith(this.#M.onConflictNode,{updates:e$(e)})})}$call(e){return e(this)}}e_(eQ,"don't await OnConflictBuilder instances.");class eY{#M;constructor(e){this.#M=c(e)}toOperationNode(){return this.#M.onConflictNode}}e_(eY,"don't await OnConflictDoNothingBuilder instances.");class eX{#M;constructor(e){this.#M=c(e)}where(...e){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,eo(e))})}whereRef(e,t,r){return new eX({...this.#M,onConflictNode:eZ.cloneWithUpdateWhere(this.#M.onConflictNode,ed(e,t,r))})}clearWhere(){return new eX({...this.#M,onConflictNode:eZ.cloneWithoutUpdateWhere(this.#M.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#M.onConflictNode}}e_(eX,"don't await OnConflictUpdateBuilder instances.");let e1=c({is:e=>"TopNode"===e.kind,create:(e,t)=>c({kind:"TopNode",expression:e,modifiers:t})});function e0(e,r){var i;if(!a(e)&&!o(e))throw Error(`Invalid top expression: ${e}`);if(!t(r)&&"percent"!==(i=r)&&"with ties"!==i&&"percent with ties"!==i)throw Error(`Invalid top modifiers: ${r}`);return e1.create(e,r)}class e2{#M;constructor(e){this.#M=c(e)}values(e){let[t,r]=eR(e);return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:t,values:r})})}columns(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{columns:c(e.map(C.create))})})}expression(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{values:t9(e)})})}defaultValues(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{defaultValues:!0})})}modifyEnd(e){return new e2({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}ignore(){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{ignore:!0})})}top(e,t){return new e2({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}onConflict(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onConflict:e(new eQ({onConflictNode:eZ.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new e2({...this.#M,queryNode:eD.cloneWith(this.#M.queryNode,{onDuplicateKey:eG.create(e$(e))})})}returning(e){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(){return new e2({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek())})}output(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e2({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e2({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e2({...this.#M})}$castTo(){return new e2(this.#M)}$narrowType(){return new e2(this.#M)}$assertType(){return new e2(this.#M)}withPlugin(e){return new e2({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new eH(t.insertId,t.numAffectedRows??t.numUpdatedOrDeletedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e2({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e2,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e6{numDeletedRows;constructor(e){this.numDeletedRows=e}}let e4=c({is:e=>"LimitNode"===e.kind,create:e=>c({kind:"LimitNode",limit:e})});class e3{#M;constructor(e){this.#M=c(e)}where(...e){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e3({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e3({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e3({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(e){return new e3({...this.#M,queryNode:eq.cloneWithUsing(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e3({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}returning(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e3({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e3({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}clearReturning(){return new e3({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}clearLimit(){return new e3({...this.#M,queryNode:eq.cloneWithoutLimit(this.#M.queryNode)})}clearOrderBy(){return new e3({...this.#M,queryNode:eq.cloneWithoutOrderBy(this.#M.queryNode)})}orderBy(e,t){return new e3({...this.#M,queryNode:eq.cloneWithOrderByItems(this.#M.queryNode,M([e,t]))})}limit(e){return new e3({...this.#M,queryNode:eq.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}modifyEnd(e){return new e3({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new e3({...this.#M})}$castTo(){return new e3(this.#M)}$narrowType(){return new e3(this.#M)}$assertType(){return new e3(this.#M)}withPlugin(e){return new e3({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e6(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e3({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e3,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class e9{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}}class e5{#M;constructor(e){this.#M=c(e)}where(...e){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new e5({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}clearWhere(){return new e5({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}top(e,t){return new e5({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}from(e){return new e5({...this.#M,queryNode:eP.cloneWithFromItems(this.#M.queryNode,t7(e))})}innerJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new e5({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}limit(e){return new e5({...this.#M,queryNode:eP.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}set(...e){return new e5({...this.#M,queryNode:eP.cloneWithUpdates(this.#M.queryNode,function(...e){return 2===e.length?[eW.create(G(e[0]),ea(e[1]))]:e$(e[0])}(...e))})}returning(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,eA(e))})}returningAll(e){return new e5({...this.#M,queryNode:ez.cloneWithReturning(this.#M.queryNode,ek(e))})}output(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new e5({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}modifyEnd(e){return new e5({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}clearReturning(){return new e5({...this.#M,queryNode:ez.cloneWithoutReturning(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new e5({...this.#M})}$castTo(){return new e5(this.#M)}$narrowType(){return new e5(this.#M)}$assertType(){return new e5(this.#M)}withPlugin(e){return new e5({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId),{adapter:r}=this.#M.executor,a=e.query;return a.returning&&r.supportsReturning||a.output&&r.supportsOutput?t.rows:[new e9(t.numAffectedRows??t.numUpdatedOrDeletedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new e5({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(e5,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");let e8=c({is:e=>"CommonTableExpressionNameNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNameNode",table:y.create(e),columns:t?c(t.map(C.create)):void 0})}),e7=c({is:e=>"CommonTableExpressionNode"===e.kind,create:(e,t)=>c({kind:"CommonTableExpressionNode",name:e,expression:t}),cloneWith:(e,t)=>c({...e,...t})});class te{#M;constructor(e){this.#M=c(e)}materialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!0})})}notMaterialized(){return new te({...this.#M,node:e7.cloneWith(this.#M.node,{materialized:!1})})}toOperationNode(){return this.#M.node}}function tt(e,t){var r;let a=t(new tA({executor:tb})).toOperationNode();return p(e)?e((r=a,e=>new te({node:e7.create(tr(e),r)}))).toOperationNode():e7.create(tr(e),a)}function tr(e){if(!e.includes("("))return e8.create(e);{let t=e.split(/[\(\)]/),r=t[0],a=t[1].split(",").map(e=>e.trim());return e8.create(r,a)}}e_(te,"don't await CTEBuilder instances. They are never executed directly and are always just a part of a query.");let ta=c({is:e=>"WithNode"===e.kind,create:(e,t)=>c({kind:"WithNode",expressions:c([e]),...t}),cloneWithExpression:(e,t)=>c({...e,expressions:c([...e.expressions,t])})}),ti=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function ts(){return new tn}class tn{#F;get queryId(){return void 0===this.#F&&(this.#F=function(e){let t="";for(let e=0;e<8;++e)t+=ti[~~(Math.random()*ti.length)];return t}(0)),this.#F}}e.s(["createQueryId",()=>ts],34939);class to{nodeStack=[];#U=c({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this)});transformNode(e){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e);return this.nodeStack.pop(),c(t)}transformNodeImpl(e){return this.#U[e.kind](e)}transformNodeList(e){return e?c(e.map(e=>this.transformNode(e))):e}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations),fetch:this.transformNode(e.fetch),top:this.transformNode(e.top)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",column:this.transformNode(e.column),table:this.transformNode(e.table)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:c([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain),defaultValues:e.defaultValues,top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),selectQuery:this.transformNode(e.selectQuery)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),endModifiers:this.transformNodeList(e.endModifiers),with:this.transformNode(e.with),explain:this.transformNode(e.explain),limit:this.transformNode(e.limit),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where),nullsNotDistinct:e.nullsNotDistinct}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name),nullsNotDistinct:e.nullsNotDistinct}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),materialized:e.materialized,expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint),addIndex:this.transformNode(e.addIndex),dropIndex:this.transformNode(e.dropIndex)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier),of:this.transformNodeList(e.of)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,orderBy:this.transformNode(e.orderBy),filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}transformTuple(e){return{kind:"TupleNode",values:this.transformNodeList(e.values)}}transformMergeQuery(e){return{kind:"MergeQueryNode",into:this.transformNode(e.into),using:this.transformNode(e.using),whens:this.transformNodeList(e.whens),with:this.transformNode(e.with),top:this.transformNode(e.top),endModifiers:this.transformNodeList(e.endModifiers),output:this.transformNode(e.output)}}transformMatched(e){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e){return{kind:"AddIndexNode",name:this.transformNode(e.name),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists}}transformCast(e){return{kind:"CastNode",expression:this.transformNode(e.expression),dataType:this.transformNode(e.dataType)}}transformFetch(e){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount),modifier:e.modifier}}transformTop(e){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e){return{kind:"OutputNode",selections:this.transformNodeList(e.selections)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}e.s(["OperationNodeTransformer",()=>to],2758);let tp=c({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),td={json_agg:!0,to_json:!0};class tl extends to{#B;#V=new Set;#z=new Set;constructor(e){super(),this.#B=e}transformNodeImpl(e){if(!this.#W(e))return super.transformNodeImpl(e);let t=this.#$(e);for(let e of t)this.#z.add(e);let r=this.#G(e);for(let e of r)this.#V.add(e);let a=super.transformNodeImpl(e);for(let e of r)this.#V.delete(e);for(let e of t)this.#z.delete(e);return a}transformSchemableIdentifier(e){let t=super.transformSchemableIdentifier(e);return t.schema||!this.#V.has(e.identifier.name)?t:{...t,schema:f.create(this.#B)}}transformReferences(e){let t=super.transformReferences(e);return t.table.table.schema?t:{...t,table:y.createWithSchema(this.#B,t.table.table.identifier.name)}}transformAggregateFunction(e){return{...super.transformAggregateFunction({...e,aggregated:[]}),aggregated:this.#H(e,"aggregated")}}transformFunction(e){return{...super.transformFunction({...e,arguments:[]}),arguments:this.#H(e,"arguments")}}#H(e,t){return td[e.func]?e[t].map(e=>!y.is(e)||e.table.schema?this.transformNode(e):{...e,table:this.transformIdentifier(e.table.identifier)}):this.transformNodeList(e[t])}#W(e){return e.kind in tp}#G(e){let t=new Set;if("name"in e&&e.name&&g.is(e.name)&&this.#K(e.name,t),"from"in e&&e.from)for(let r of e.from.froms)this.#J(r,t);if("into"in e&&e.into&&this.#J(e.into,t),"table"in e&&e.table&&this.#J(e.table,t),"joins"in e&&e.joins)for(let r of e.joins)this.#J(r.table,t);return"using"in e&&e.using&&this.#J(e.using,t),t}#$(e){let t=new Set;return"with"in e&&e.with&&this.#Z(e.with,t),t}#J(e,t){let r=y.is(e)?e:v.is(e)&&y.is(e.node)?e.node:null;r&&this.#K(r.table,t)}#K(e,t){let r=e.identifier.name;this.#V.has(r)||this.#z.has(r)||t.add(r)}#Z(e,t){for(let r of e.expressions){let e=r.name.table.table.identifier.name;this.#z.has(e)||t.add(e)}}}class tc{#Q;constructor(e){this.#Q=new tl(e)}transformQuery(e){return this.#Q.transformNode(e.node)}async transformResult(e){return e.result}}e.s(["WithSchemaPlugin",()=>tc],90640);let tu=c({is:e=>"MatchedNode"===e.kind,create:(e,t=!1)=>c({kind:"MatchedNode",not:e,bySource:t})});function th(e,t,r){return eU.create(ec([tu.create(!e.isMatched,e.bySource),...t&&t.length>0?[3===t.length&&r?ed(t[0],t[1],t[2]):eo(t)]:[]],"and",!1))}function tm(e){return r(e)?q.create([e],[]):w(e)?e.toOperationNode():e}class tf{#Y;#X;#ee;constructor(){this.#Y=new Promise((e,t)=>{this.#ee=t,this.#X=e})}get promise(){return this.#Y}resolve=e=>{this.#X&&this.#X(e)};reject=e=>{this.#ee&&this.#ee(e)}}let tg=new Set,tv=c([]);class ty{#et;constructor(e=tv){this.#et=e}get plugins(){return this.#et}transformQuery(e,t){for(let r of this.#et){let a=r.transformQuery({node:e,queryId:t});if(a.kind===e.kind)e=a;else throw Error(`KyselyPlugin.transformQuery must return a node of the same kind that was given to it. The plugin was given a ${e.kind} but it returned a ${a.kind}`)}return e}async executeQuery(e,t){return await this.provideConnection(async r=>{let a=await r.executeQuery(e),i=await this.#er(a,t);return function(e,t){let{numAffectedRows:r}=e;if((void 0!==r||void 0!==e.numUpdatedOrDeletedRows)&&(void 0===r||void 0===t.numAffectedRows)){var a;a="kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.",tg.has(a)||(tg.add(a),console.log(a))}}(a,i),i})}async *stream(e,t,r){let a=new tf,i=new tf;this.provideConnection(async e=>(a.resolve(e),await i.promise)).catch(e=>a.reject(e));let s=await a.promise;try{for await(let a of s.streamQuery(e,t))yield await this.#er(a,r)}finally{i.resolve()}}async #er(e,t){for(let r of this.#et)e=await r.transformResult({result:e,queryId:t});return e}}e.s(["QueryExecutorBase",()=>ty],46432);class tw extends ty{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new tw([...this.plugins,e])}withPlugins(e){return new tw([...this.plugins,...e])}withPluginAtFront(e){return new tw([e,...this.plugins])}withoutPlugins(){return new tw([])}}let tb=new tw;e.s(["NOOP_QUERY_EXECUTOR",0,tb],13424);class t_{numChangedRows;constructor(e){this.numChangedRows=e}}class tx{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tx({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tx({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}using(...e){return new tN({...this.#M,queryNode:eB.cloneWithUsing(this.#M.queryNode,tS("Using",e))})}output(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tx({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}}e_(tx,"don't await MergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tN{#M;constructor(e){this.#M=c(e)}modifyEnd(e){return new tN({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,e.toOperationNode())})}top(e,t){return new tN({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}whenMatched(){return this.#ea([])}whenMatchedAnd(...e){return this.#ea(e)}whenMatchedAndRef(e,t,r){return this.#ea([e,t,r],!0)}#ea(e,t){return new tT({...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!0},e,t))})}whenNotMatched(){return this.#ei([])}whenNotMatchedAnd(...e){return this.#ei(e)}whenNotMatchedAndRef(e,t,r){return this.#ei([e,t,r],!0)}whenNotMatchedBySource(){return this.#ei([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#ei(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,r){return this.#ei([e,t,r],!0,!0)}output(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,eA(e))})}outputAll(e){return new tN({...this.#M,queryNode:ez.cloneWithOutput(this.#M.queryNode,ek(e))})}#ei(e,t=!1,r=!1){let a={...this.#M,queryNode:eB.cloneWithWhen(this.#M.queryNode,th({isMatched:!1,bySource:r},e,t))};return new(r?tT:tE)(a)}$call(e){return e(this)}$if(e,t){return e?t(this):new tN({...this.#M})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile(),t=await this.#M.executor.executeQuery(e,this.#M.queryId);return e.query.output&&this.#M.executor.adapter.supportsOutput?t.rows:[new t_(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}}e_(tN,"don't await WheneableMergeQueryBuilder instances directly. To execute the query you need to call `execute`.");class tT{#M;constructor(e){this.#M=c(e)}thenDelete(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("delete"))})}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenUpdate(e){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(e(new e5({queryId:this.#M.queryId,executor:tb,queryNode:eP.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}}e_(tT,"don't await MatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tE{#M;constructor(e){this.#M=c(e)}thenDoNothing(){return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm("do nothing"))})}thenInsertValues(e){let[t,r]=eR(e);return new tN({...this.#M,queryNode:eB.cloneWithThen(this.#M.queryNode,tm(eD.cloneWith(eD.createWithoutInto(),{columns:t,values:r})))})}}e_(tE,"don't await NotMatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.");class tA{#M;constructor(e){this.#M=c(e)}selectFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.createFrom(t7(e),this.#M.withNode)})}selectNoFrom(e){return new tq({queryId:ts(),executor:this.#M.executor,queryNode:eb.cloneWithSelections(eb.create(this.#M.withNode),eA(e))})}insertInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode)})}replaceInto(e){return new e2({queryId:ts(),executor:this.#M.executor,queryNode:eD.create(rr(e),this.#M.withNode,!0)})}deleteFrom(e){return new e3({queryId:ts(),executor:this.#M.executor,queryNode:eq.create(t7(e),this.#M.withNode)})}updateTable(e){return new e5({queryId:ts(),executor:this.#M.executor,queryNode:eP.create(re(e),this.#M.withNode)})}mergeInto(e){return new tx({queryId:ts(),executor:this.#M.executor,queryNode:eB.create(rt(e),this.#M.withNode)})}with(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r)})}withRecursive(e,t){let r=tt(e,t);return new tA({...this.#M,withNode:this.#M.withNode?ta.cloneWithExpression(this.#M.withNode,r):ta.create(r,{recursive:!0})})}withPlugin(e){return new tA({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new tA({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new tA({...this.#M,executor:this.#M.executor.withPluginAtFront(new tc(e))})}}function tS(e,t){if(3===t.length){var r,a,i,s;return r=e,a=t[0],i=t[1],s=t[2],T.createWithOn(r,re(a),ed(i,"=",s))}if(2===t.length)return function(e,t,r){return r(new ex({joinNode:T.create(e,re(t))})).toOperationNode()}(e,t[0],t[1]);throw Error("not implemented")}let tk=c({is:e=>"OffsetNode"===e.kind,create:e=>c({kind:"OffsetNode",offset:e})}),tO=c({is:e=>"GroupByItemNode"===e.kind,create:e=>c({kind:"GroupByItemNode",groupBy:e})}),tC=c({is:e=>"SetOperationNode"===e.kind,create:(e,t,r)=>c({kind:"SetOperationNode",operator:e,expression:t,all:r})});function tI(e,t,r){return p(t)&&(t=t(t3())),h(t)||(t=[t]),t.map(t=>tC.create(e,t9(t),r))}e.s(["SetOperationNode",0,tC],45393);class tR{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tR(this.#q)}$notNull(){return new tR(this.#q)}toOperationNode(){return this.#q}}class tD{#es;#en;constructor(e,t){this.#es=e,this.#en=t}get expression(){return this.#es}get alias(){return this.#en}toOperationNode(){return v.create(this.#es.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}class tP{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}or(...e){return new tP(x.create(this.#q,eo(e)))}$castTo(){return new tP(this.#q)}toOperationNode(){return en.create(this.#q)}}class tj{#q;constructor(e){this.#q=e}get expressionType(){}as(e){return new tD(this,e)}and(...e){return new tj(_.create(this.#q,eo(e)))}$castTo(){return new tj(this.#q)}toOperationNode(){return en.create(this.#q)}}class tq{#M;constructor(e){this.#M=c(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,eo(e))})}whereRef(e,t,r){return new tq({...this.#M,queryNode:ez.cloneWithWhere(this.#M.queryNode,ed(e,t,r))})}having(...e){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,eo(e))})}havingRef(e,t,r){return new tq({...this.#M,queryNode:eb.cloneWithHaving(this.#M.queryNode,ed(e,t,r))})}select(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,eA(e))})}distinctOn(e){return new tq({...this.#M,queryNode:eb.cloneWithDistinctOn(this.#M.queryNode,$(e))})}modifyFront(e){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.createWithExpression(e.toOperationNode()))})}distinct(){return new tq({...this.#M,queryNode:eb.cloneWithFrontModifier(this.#M.queryNode,b.create("Distinct"))})}forUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForUpdate",e?u(e).map(rr):void 0))})}forShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForShare",e?u(e).map(rr):void 0))})}forKeyShare(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForKeyShare",e?u(e).map(rr):void 0))})}forNoKeyUpdate(e){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("ForNoKeyUpdate",e?u(e).map(rr):void 0))})}skipLocked(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("SkipLocked"))})}noWait(){return new tq({...this.#M,queryNode:ez.cloneWithEndModifier(this.#M.queryNode,b.create("NoWait"))})}selectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSelections(this.#M.queryNode,ek(e))})}innerJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("InnerJoin",e))})}leftJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LeftJoin",e))})}rightJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("RightJoin",e))})}fullJoin(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("FullJoin",e))})}innerJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralInnerJoin",e))})}leftJoinLateral(...e){return new tq({...this.#M,queryNode:ez.cloneWithJoin(this.#M.queryNode,tS("LateralLeftJoin",e))})}orderBy(...e){return new tq({...this.#M,queryNode:eb.cloneWithOrderByItems(this.#M.queryNode,M(e))})}groupBy(e){var t;return new tq({...this.#M,queryNode:eb.cloneWithGroupByItems(this.#M.queryNode,$(t=p(t=e)?t(t3()):t).map(tO.create))})}limit(e){return new tq({...this.#M,queryNode:eb.cloneWithLimit(this.#M.queryNode,e4.create(ea(e)))})}offset(e){return new tq({...this.#M,queryNode:eb.cloneWithOffset(this.#M.queryNode,tk.create(ea(e)))})}fetch(e,t="only"){return new tq({...this.#M,queryNode:eb.cloneWithFetch(this.#M.queryNode,function(e,t){var r;let i,s;if(!a(e)&&!o(e))throw Error(`Invalid fetch row count: ${e}`);if("only"!==(r=t)&&"with ties"!==r)throw Error(`Invalid fetch modifier: ${t}`);return i=e,s=t,{kind:"FetchNode",rowCount:et.create(i),modifier:s}}(e,t))})}top(e,t){return new tq({...this.#M,queryNode:ez.cloneWithTop(this.#M.queryNode,e0(e,t))})}union(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!1))})}unionAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("union",e,!0))})}intersect(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!1))})}intersectAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("intersect",e,!0))})}except(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!1))})}exceptAll(e){return new tq({...this.#M,queryNode:eb.cloneWithSetOperations(this.#M.queryNode,tI("except",e,!0))})}as(e){return new tL(this,e)}clearSelect(){return new tq({...this.#M,queryNode:eb.cloneWithoutSelections(this.#M.queryNode)})}clearWhere(){return new tq({...this.#M,queryNode:ez.cloneWithoutWhere(this.#M.queryNode)})}clearLimit(){return new tq({...this.#M,queryNode:eb.cloneWithoutLimit(this.#M.queryNode)})}clearOffset(){return new tq({...this.#M,queryNode:eb.cloneWithoutOffset(this.#M.queryNode)})}clearOrderBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutOrderBy(this.#M.queryNode)})}clearGroupBy(){return new tq({...this.#M,queryNode:eb.cloneWithoutGroupBy(this.#M.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new tq({...this.#M})}$castTo(){return new tq(this.#M)}$narrowType(){return new tq(this.#M)}$assertType(){return new tq(this.#M)}$asTuple(){return new tR(this.toOperationNode())}withPlugin(e){return new tq({...this.#M,executor:this.#M.executor.withPlugin(e)})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.queryNode,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){let e=this.compile();return(await this.#M.executor.executeQuery(e,this.#M.queryId)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=eK){let t=await this.executeTakeFirst();if(void 0===t)throw eJ(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async *stream(e=100){let t=this.compile();for await(let r of this.#M.executor.stream(t,e,this.#M.queryId))yield*r.rows}async explain(e,t){let r=new tq({...this.#M,queryNode:ez.cloneWithExplain(this.#M.queryNode,e,t)});return await r.execute()}}e_(tq,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class tL{#eo;#en;constructor(e,t){this.#eo=e,this.#en=t}get expression(){return this.#eo}get alias(){return this.#en}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return v.create(this.#eo.toOperationNode(),f.create(this.#en))}}e_(tL,"don't await AliasedSelectQueryBuilder instances directly. AliasedSelectQueryBuilder should never be executed directly since it's always a part of another query."),e.s(["createFunctionModule",()=>tV],86566);let tM=c({is:e=>"AggregateFunctionNode"===e.kind,create:(e,t=[])=>c({kind:"AggregateFunctionNode",func:e,aggregated:t}),cloneWithDistinct:e=>c({...e,distinct:!0}),cloneWithOrderBy:(e,t)=>c({...e,orderBy:e.orderBy?em.cloneWithItems(e.orderBy,t):em.create(t)}),cloneWithFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"And",t):eL.create(t)}),cloneWithOrFilter:(e,t)=>c({...e,filter:e.filter?eL.cloneWithOperation(e.filter,"Or",t):eL.create(t)}),cloneWithOver:(e,t)=>c({...e,over:t})}),tF=c({is:e=>"FunctionNode"===e.kind,create:(e,t)=>c({kind:"FunctionNode",func:e,arguments:t})});class tU{#M;constructor(e){this.#M=c(e)}get expressionType(){}as(e){return new tB(this,e)}distinct(){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithDistinct(this.#M.aggregateFunctionNode)})}orderBy(e,t){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOrderBy(this.#M.aggregateFunctionNode,M([e,t]))})}filterWhere(...e){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,eo(e))})}filterWhereRef(e,t,r){return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithFilter(this.#M.aggregateFunctionNode,ed(e,t,r))})}over(e){let t=new eT({overNode:eg.create()});return new tU({...this.#M,aggregateFunctionNode:tM.cloneWithOver(this.#M.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new tU(this.#M)}$notNull(){return new tU(this.#M)}toOperationNode(){return this.#M.aggregateFunctionNode}}e_(tU,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class tB{#ep;#en;constructor(e,t){this.#ep=e,this.#en=t}get expression(){return this.#ep}get alias(){return this.#en}toOperationNode(){return v.create(this.#ep.toOperationNode(),f.create(this.#en))}}function tV(){let e=(e,t)=>new tR(tF.create(e,$(t??[]))),t=(e,t)=>new tU({aggregateFunctionNode:tM.create(e,t?$(t):void 0)});return Object.assign(e,{agg:t,avg:e=>t("avg",[e]),coalesce:(...t)=>e("coalesce",t),count:e=>t("count",[e]),countAll:e=>new tU({aggregateFunctionNode:tM.create("count",ek(e))}),max:e=>t("max",[e]),min:e=>t("min",[e]),sum:e=>t("sum",[e]),any:t=>e("any",[t]),jsonAgg:e=>new tU({aggregateFunctionNode:tM.create("json_agg",[r(e)?rr(e):e.toOperationNode()])}),toJson:e=>new tR(tF.create("to_json",[r(e)?rr(e):e.toOperationNode()]))})}let tz=c({is:e=>"UnaryOperationNode"===e.kind,create:(e,t)=>c({kind:"UnaryOperationNode",operator:e,operand:t})});e.s(["CaseBuilder",()=>t$],21797);let tW=c({is:e=>"CaseNode"===e.kind,create:e=>c({kind:"CaseNode",value:e}),cloneWithWhen:(e,t)=>c({...e,when:c(e.when?[...e.when,t]:[t])}),cloneWithThen:(e,t)=>c({...e,when:e.when?c([...e.when.slice(0,-1),eU.cloneWithResult(e.when[e.when.length-1],t)]):void 0}),cloneWith:(e,t)=>c({...e,...t})});e.s(["CaseNode",0,tW],72515);class t${#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}}class tG{#M;constructor(e){this.#M=c(e)}then(e){return new tH({...this.#M,node:tW.cloneWithThen(this.#M.node,ei(e)?es(e):ea(e))})}}class tH{#M;constructor(e){this.#M=c(e)}when(...e){return new tG({...this.#M,node:tW.cloneWithWhen(this.#M.node,eU.create(eo(e)))})}else(e){return new tK({...this.#M,node:tW.cloneWith(this.#M.node,{else:ei(e)?es(e):ea(e)})})}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}class tK{#M;constructor(e){this.#M=c(e)}end(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!1}))}endCase(){return new tR(tW.cloneWith(this.#M.node,{isStatement:!0}))}}let tJ=c({is:e=>"JSONPathLegNode"===e.kind,create:(e,t)=>c({kind:"JSONPathLegNode",type:e,value:t})});class tZ{#q;constructor(e){this.#q=e}at(e){return this.#ed("ArrayLocation",e)}key(e){return this.#ed("Member",e)}#ed(e,t){return new tQ(B.is(this.#q)?B.cloneWithTraversal(this.#q,z.is(this.#q.traversal)?z.cloneWithLeg(this.#q.traversal,tJ.create(e,t)):V.cloneWithValue(this.#q.traversal,et.createImmediate(t))):z.cloneWithLeg(this.#q,tJ.create(e,t)))}}class tQ extends tZ{#q;constructor(e){super(e),this.#q=e}get expressionType(){}as(e){return new tY(this,e)}$castTo(){return new tQ(this.#q)}$notNull(){return new tQ(this.#q)}toOperationNode(){return this.#q}}class tY{#el;#en;constructor(e,t){this.#el=e,this.#en=t}get expression(){return this.#el}get alias(){return this.#en}toOperationNode(){return v.create(this.#el.toOperationNode(),w(this.#en)?this.#en.toOperationNode():f.create(this.#en))}}let tX=c({is:e=>"TupleNode"===e.kind,create:e=>c({kind:"TupleNode",values:c(e)})}),t1=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],t0=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],t2=c({is:e=>"DataTypeNode"===e.kind,create:e=>c({kind:"DataTypeNode",dataType:e})});function t6(e){if(w(e))return e.toOperationNode();if(t1.includes(e)||t0.some(t=>t.test(e)))return t2.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}e.s(["parseDataTypeExpression",()=>t6],51014);let t4=c({is:e=>"CastNode"===e.kind,create:(e,t)=>c({kind:"CastNode",expression:e,dataType:t})});function t3(e=tb){function r(e,t){return new tR(tz.create(k.create(e),G(t)))}let a=Object.assign(function(e,t,r){return new tR(ep(e,t,r))},{fn:void 0,eb:void 0,selectFrom:t=>new tq({queryId:ts(),executor:e,queryNode:eb.createFrom(t7(t))}),case:e=>new t$({node:tW.create(t(e)?void 0:G(e))}),ref:(e,r)=>t(r)?new tR(K(e)):new tZ(H(e,r)),jsonPath:()=>new tZ(z.create()),table:e=>new tR(rr(e)),val:e=>new tR(ea(e)),refTuple:(...e)=>new tR(tX.create(e.map(G))),tuple:(...e)=>new tR(tX.create(e.map(ea))),lit:e=>new tR(es(e)),unary:r,not:e=>r("not",e),exists:e=>r("exists",e),neg:e=>r("-",e),between:(e,t,r)=>new tR(E.create(G(e),k.create("between"),_.create(ea(t),ea(r)))),betweenSymmetric:(e,t,r)=>new tR(E.create(G(e),k.create("between symmetric"),_.create(ea(t),ea(r)))),and:e=>new tR(h(e)?ec(e,"and"):el(e,"and")),or:e=>new tR(h(e)?ec(e,"or"):el(e,"or")),parens(...e){let t=eo(e);return new tR(en.is(t)?t:en.create(t))},cast:(e,t)=>new tR(t4.create(G(e),t6(t))),withSchema:t=>t3(e.withPluginAtFront(new tc(t)))});return a.fn=tV(),a.eb=a,a}function t9(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function t5(e){if(w(e))return e.toOperationNode();if(p(e))return e(t3()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function t8(e){return d(e)&&"expressionType"in e&&w(e)||d(e)&&"expression"in e&&r(e.alias)&&w(e)||p(e)}function t7(e){return h(e)?e.map(e=>re(e)):[re(e)]}function re(e){return r(e)?rt(e):t5(e)}function rt(e){let t=" as ";if(!e.includes(t))return rr(e);{let[r,a]=e.split(t).map(ra);return v.create(rr(r),f.create(a))}}function rr(e){if(!e.includes("."))return y.create(e);{let[t,r]=e.split(".").map(ra);return y.createWithSchema(t,r)}}function ra(e){return e.trim()}},58666,3888,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"CreateTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTableNode",table:e,columns:(0,t.freeze)([])}),cloneWithColumn:(e,r)=>(0,t.freeze)({...e,columns:(0,t.freeze)([...e.columns,r])}),cloneWithConstraint:(e,r)=>(0,t.freeze)({...e,constraints:e.constraints?(0,t.freeze)([...e.constraints,r]):(0,t.freeze)([r])}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):(0,t.freeze)([r])}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):(0,t.freeze)([r])}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateTableNode",0,r,"ON_COMMIT_ACTIONS",0,["preserve rows","delete rows","drop"]],58666);var a=e.i(62212);let i=(0,t.freeze)({is:e=>"CreateViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateViewNode",name:a.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});e.s(["CreateViewNode",0,i],3888)},24659,e=>{"use strict";var t=e.i(84739);let r=(0,t.freeze)({is:e=>"AlterTableNode"===e.kind,create:e=>(0,t.freeze)({kind:"AlterTableNode",table:e}),cloneWithTableProps:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumnAlteration:(e,r)=>(0,t.freeze)({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,r]:[r]})});var a=e.i(482);let i=(0,t.freeze)({is:e=>"CreateIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})}),s=(0,t.freeze)({is:e=>"CreateSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CreateSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var n=e.i(58666),o=e.i(62212);let p=(0,t.freeze)({is:e=>"DropIndexNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropIndexNode",name:o.SchemableIdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),d=(0,t.freeze)({is:e=>"DropSchemaNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropSchemaNode",schema:a.IdentifierNode.create(e),...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),l=(0,t.freeze)({is:e=>"DropTableNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"DropTableNode",table:e,...r}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});var c=e.i(87799);let u=(0,t.freeze)({is:e=>"AddColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddColumnNode",column:e})});var h=e.i(54199);let m=(0,t.freeze)({is:e=>"ColumnDefinitionNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ColumnDefinitionNode",column:h.ColumnNode.create(e),dataType:r}),cloneWithFrontModifier:(e,r)=>(0,t.freeze)({...e,frontModifiers:e.frontModifiers?(0,t.freeze)([...e.frontModifiers,r]):[r]}),cloneWithEndModifier:(e,r)=>(0,t.freeze)({...e,endModifiers:e.endModifiers?(0,t.freeze)([...e.endModifiers,r]):[r]}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),f=(0,t.freeze)({is:e=>"DropColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropColumnNode",column:h.ColumnNode.create(e)})}),g=(0,t.freeze)({is:e=>"RenameColumnNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"RenameColumnNode",column:h.ColumnNode.create(e),renameTo:h.ColumnNode.create(r)})});var v=e.i(50430);let y=(0,t.freeze)({is:e=>"CheckConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"CheckConstraintNode",expression:e,name:r?a.IdentifierNode.create(r):void 0})}),w=["no action","restrict","cascade","set null","set default"],b=(0,t.freeze)({is:e=>"ReferencesNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"ReferencesNode",table:e,columns:(0,t.freeze)([...r])}),cloneWithOnDelete:(e,r)=>(0,t.freeze)({...e,onDelete:r}),cloneWithOnUpdate:(e,r)=>(0,t.freeze)({...e,onUpdate:r})});var _=e.i(6937),x=e.i(56900),N=e.i(56967),T=e.i(46220);function E(e){return(0,N.isOperationNodeSource)(e)?e.toOperationNode():T.ValueNode.createImmediate(e)}let A=(0,t.freeze)({is:e=>"GeneratedNode"===e.kind,create:e=>(0,t.freeze)({kind:"GeneratedNode",...e}),createWithExpression:e=>(0,t.freeze)({kind:"GeneratedNode",always:!0,expression:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),S=(0,t.freeze)({is:e=>"DefaultValueNode"===e.kind,create:e=>(0,t.freeze)({kind:"DefaultValueNode",defaultValue:e})});function k(e){if(w.includes(e))return e;throw Error(`invalid OnModifyForeignAction ${e}`)}class O{#q;constructor(e){this.#q=e}autoIncrement(){return new O(m.cloneWith(this.#q,{autoIncrement:!0}))}identity(){return new O(m.cloneWith(this.#q,{identity:!0}))}primaryKey(){return new O(m.cloneWith(this.#q,{primaryKey:!0}))}references(e){let t=(0,x.parseStringReference)(e);if(!t.table||_.SelectAllNode.is(t.column))throw Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new O(m.cloneWith(this.#q,{references:b.create(t.table,[t.column])}))}onDelete(e){if(!this.#q.references)throw Error("on delete constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnDelete(this.#q.references,k(e))}))}onUpdate(e){if(!this.#q.references)throw Error("on update constraint can only be added for foreign keys");return new O(m.cloneWith(this.#q,{references:b.cloneWithOnUpdate(this.#q.references,k(e))}))}unique(){return new O(m.cloneWith(this.#q,{unique:!0}))}notNull(){return new O(m.cloneWith(this.#q,{notNull:!0}))}unsigned(){return new O(m.cloneWith(this.#q,{unsigned:!0}))}defaultTo(e){return new O(m.cloneWith(this.#q,{defaultTo:S.create(E(e))}))}check(e){return new O(m.cloneWith(this.#q,{check:y.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new O(m.cloneWith(this.#q,{generated:A.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new O(m.cloneWith(this.#q,{generated:A.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#q.generated)throw Error("stored() can only be called after generatedAlwaysAs");return new O(m.cloneWith(this.#q,{generated:A.cloneWith(this.#q.generated,{stored:!0})}))}modifyFront(e){return new O(m.cloneWithFrontModifier(this.#q,e.toOperationNode()))}nullsNotDistinct(){return new O(m.cloneWith(this.#q,{nullsNotDistinct:!0}))}ifNotExists(){return new O(m.cloneWith(this.#q,{ifNotExists:!0}))}modifyEnd(e){return new O(m.cloneWithEndModifier(this.#q,e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(O,"don't await ColumnDefinitionBuilder instances directly.");let C=(0,t.freeze)({is:e=>"ModifyColumnNode"===e.kind,create:e=>(0,t.freeze)({kind:"ModifyColumnNode",column:e})});var I=e.i(51014);let R=(0,t.freeze)({is:e=>"ForeignKeyConstraintNode"===e.kind,create:(e,r,i,s)=>(0,t.freeze)({kind:"ForeignKeyConstraintNode",columns:e,references:b.create(r,i),name:s?a.IdentifierNode.create(s):void 0}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class D{#q;constructor(e){this.#q=e}onDelete(e){return new D(R.cloneWith(this.#q,{onDelete:k(e)}))}onUpdate(e){return new D(R.cloneWith(this.#q,{onUpdate:k(e)}))}$call(e){return e(this)}toOperationNode(){return this.#q}}(0,v.preventAwait)(D,"don't await ForeignKeyConstraintBuilder instances directly.");let P=(0,t.freeze)({is:e=>"AddConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddConstraintNode",constraint:e})}),j=(0,t.freeze)({is:e=>"UniqueConstraintNode"===e.kind,create:(e,r,i)=>(0,t.freeze)({kind:"UniqueConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0,nullsNotDistinct:i}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),q=(0,t.freeze)({is:e=>"DropConstraintNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropConstraintNode",constraintName:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})}),L=(0,t.freeze)({is:e=>"AlterColumnNode"===e.kind,create:(e,r,a)=>(0,t.freeze)({kind:"AlterColumnNode",column:h.ColumnNode.create(e),[r]:a})});class M{#ec;constructor(e){this.#ec=e}setDataType(e){return new F(L.create(this.#ec,"dataType",(0,I.parseDataTypeExpression)(e)))}setDefault(e){return new F(L.create(this.#ec,"setDefault",E(e)))}dropDefault(){return new F(L.create(this.#ec,"dropDefault",!0))}setNotNull(){return new F(L.create(this.#ec,"setNotNull",!0))}dropNotNull(){return new F(L.create(this.#ec,"dropNotNull",!0))}$call(e){return e(this)}}(0,v.preventAwait)(M,"don't await AlterColumnBuilder instances");class F{#eu;constructor(e){this.#eu=e}toOperationNode(){return this.#eu}}(0,v.preventAwait)(F,"don't await AlteredColumnBuilder instances");class U{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(U,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");class B{#M;constructor(e){this.#M=(0,t.freeze)(e)}onDelete(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onDelete(e)})}onUpdate(e){return new B({...this.#M,constraintBuilder:this.#M.constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(this.#M.constraintBuilder.toOperationNode())}),this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(B,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");class V{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{ifExists:!0})})})}cascade(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.cloneWith(this.#M.node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(V,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");let z=(0,t.freeze)({is:e=>"PrimaryKeyConstraintNode"===e.kind,create:(e,r)=>(0,t.freeze)({kind:"PrimaryKeyConstraintNode",columns:(0,t.freeze)(e.map(h.ColumnNode.create)),name:r?a.IdentifierNode.create(r):void 0})}),W=(0,t.freeze)({is:e=>"AddIndexNode"===e.kind,create:e=>(0,t.freeze)({kind:"AddIndexNode",name:a.IdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r}),cloneWithColumns:(e,r)=>(0,t.freeze)({...e,columns:[...e.columns||[],...r]})});var $=e.i(90348);class G{#M;constructor(e){this.#M=(0,t.freeze)(e)}unique(){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{unique:!0})})})}column(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[(0,x.parseOrderedColumnName)(e)])})})}columns(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,e.map(x.parseOrderedColumnName))})})}expression(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWithColumns(this.#M.node.addIndex,[e.toOperationNode()])})})}using(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.cloneWith(this.#M.node.addIndex,{using:$.RawNode.createWithSql(e)})})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(G,"don't await AlterTableAddIndexBuilder instances directly. To execute the query you need to call `execute`");class H{#q;constructor(e){this.#q=e}toOperationNode(){return this.#q}nullsNotDistinct(){return new H(j.cloneWith(this.#q,{nullsNotDistinct:!0}))}}(0,v.preventAwait)(H,"don't await UniqueConstraintNodeBuilder instances directly.");class K{#M;constructor(e){this.#M=(0,t.freeze)(e)}renameTo(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{renameTo:(0,c.parseTable)(e)})})}setSchema(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{setSchema:a.IdentifierNode.create(e)})})}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}addUniqueConstraint(e,a,i=t.noop){let s=i(new H(j.create(a,e)));return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(s.toOperationNode())})})}addCheckConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(y.create(t.toOperationNode(),e))})})}addForeignKeyConstraint(e,t,r,a){return new B({...this.#M,constraintBuilder:new D(R.create(t.map(h.ColumnNode.create),(0,c.parseTable)(r),a.map(h.ColumnNode.create),e))})}addPrimaryKeyConstraint(e,t){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addConstraint:P.create(z.create(t,e))})})}dropConstraint(e){return new V({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropConstraint:q.create(e)})})}addIndex(e){return new G({...this.#M,node:r.cloneWithTableProps(this.#M.node,{addIndex:W.create(e)})})}dropIndex(e){return new U({...this.#M,node:r.cloneWithTableProps(this.#M.node,{dropIndex:p.create(e)})})}$call(e){return e(this)}}(0,v.preventAwait)(K,"don't await AlterTableBuilder instances");class J{#M;constructor(e){this.#M=(0,t.freeze)(e)}alterColumn(e,t){let a=t(new M(e));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,a.toOperationNode())})}dropColumn(e){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,f.create(e))})}renameColumn(e,t){return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,g.create(e,t))})}addColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,u.create(s.toOperationNode()))})}modifyColumn(e,a,i=t.noop){let s=i(new O(m.create(e,(0,I.parseDataTypeExpression)(a))));return new J({...this.#M,node:r.cloneWithColumnAlteration(this.#M.node,C.create(s.toOperationNode()))})}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(J,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");var Z=e.i(83013),Q=e.i(27539),Y=e.i(2758);class X extends Y.OperationNodeTransformer{transformValue(e){return{...super.transformValue(e),immediate:!0}}}class ee{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{ifNotExists:!0})})}unique(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{unique:!0})})}nullsNotDistinct(){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{nullsNotDistinct:!0})})}on(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}column(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[(0,x.parseOrderedColumnName)(e)])})}columns(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,e.map(x.parseOrderedColumnName))})}expression(e){return new ee({...this.#M,node:i.cloneWithColumns(this.#M.node,[e.toOperationNode()])})}using(e){return new ee({...this.#M,node:i.cloneWith(this.#M.node,{using:$.RawNode.createWithSql(e)})})}where(...e){let t=new X;return new ee({...this.#M,node:Q.QueryNode.cloneWithWhere(this.#M.node,t.transformNode((0,Z.parseValueBinaryOperationOrExpression)(e)))})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ee,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");class et{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifNotExists(){return new et({...this.#M,node:s.cloneWith(this.#M.node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(et,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");var er=e.i(67204);class ea{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{temporary:!0})})}onCommit(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{onCommit:function(e){if(n.ON_COMMIT_ACTIONS.includes(e))return e;throw Error(`invalid OnCommitAction ${e}`)}(e)})})}ifNotExists(){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{ifNotExists:!0})})}addColumn(e,r,a=t.noop){let i=a(new O(m.create(e,(0,I.parseDataTypeExpression)(r))));return new ea({...this.#M,node:n.CreateTableNode.cloneWithColumn(this.#M.node,i.toOperationNode())})}addPrimaryKeyConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,z.create(t,e))})}addUniqueConstraint(e,r,a=t.noop){let i=a(new H(j.create(r,e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,i.toOperationNode())})}addCheckConstraint(e,t){return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,y.create(t.toOperationNode(),e))})}addForeignKeyConstraint(e,r,a,i,s=t.noop){let o=s(new D(R.create(r.map(h.ColumnNode.create),(0,c.parseTable)(a),i.map(h.ColumnNode.create),e)));return new ea({...this.#M,node:n.CreateTableNode.cloneWithConstraint(this.#M.node,o.toOperationNode())})}modifyFront(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithFrontModifier(this.#M.node,e.toOperationNode())})}modifyEnd(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWithEndModifier(this.#M.node,e.toOperationNode())})}as(e){return new ea({...this.#M,node:n.CreateTableNode.cloneWith(this.#M.node,{selectQuery:(0,er.parseExpression)(e)})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ea,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");class ei{#M;constructor(e){this.#M=(0,t.freeze)(e)}on(e){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{table:(0,c.parseTable)(e)})})}ifExists(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new ei({...this.#M,node:p.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ei,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");class es{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new es({...this.#M,node:d.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(es,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");class en{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new en({...this.#M,node:l.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(en,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");var eo=e.i(34939),ep=e.i(90640),ed=e.i(3888);class el{#Q=new X;transformQuery(e){return this.#Q.transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}class ec{#M;constructor(e){this.#M=(0,t.freeze)(e)}temporary(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{temporary:!0})})}materialized(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{materialized:!0})})}ifNotExists(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{ifNotExists:!0})})}orReplace(){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{orReplace:!0})})}columns(e){return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{columns:e.map(x.parseColumnName)})})}as(e){let t=e.withPlugin(new el).toOperationNode();return new ec({...this.#M,node:ed.CreateViewNode.cloneWith(this.#M.node,{as:t})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(ec,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");let eu=(0,t.freeze)({is:e=>"DropViewNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropViewNode",name:o.SchemableIdentifierNode.create(e)}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class eh{#M;constructor(e){this.#M=(0,t.freeze)(e)}materialized(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{materialized:!0})})}ifExists(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{ifExists:!0})})}cascade(){return new eh({...this.#M,node:eu.cloneWith(this.#M.node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eh,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");var em=e.i(22177);let ef=(0,t.freeze)({is:e=>"CreateTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"CreateTypeNode",name:e}),cloneWithEnum:(e,r)=>(0,t.freeze)({...e,enum:em.ValueListNode.create(r.map(e=>T.ValueNode.createImmediate(e)))})});class eg{#M;constructor(e){this.#M=(0,t.freeze)(e)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}asEnum(e){return new eg({...this.#M,node:ef.cloneWithEnum(this.#M.node,e)})}$call(e){return e(this)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}(0,v.preventAwait)(eg,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");let ev=(0,t.freeze)({is:e=>"DropTypeNode"===e.kind,create:e=>(0,t.freeze)({kind:"DropTypeNode",name:e}),cloneWith:(e,r)=>(0,t.freeze)({...e,...r})});class ey{#M;constructor(e){this.#M=(0,t.freeze)(e)}ifExists(){return new ey({...this.#M,node:ev.cloneWith(this.#M.node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return this.#M.executor.transformQuery(this.#M.node,this.#M.queryId)}compile(){return this.#M.executor.compileQuery(this.toOperationNode(),this.#M.queryId)}async execute(){await this.#M.executor.executeQuery(this.compile(),this.#M.queryId)}}function ew(e){if(!e.includes("."))return o.SchemableIdentifierNode.create(e);{let t=e.split(".").map(eb);if(2===t.length)return o.SchemableIdentifierNode.createWithSchema(t[0],t[1]);throw Error(`invalid schemable identifier ${e}`)}}function eb(e){return e.trim()}(0,v.preventAwait)(ey,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");class e_{#eh;constructor(e){this.#eh=e}createTable(e){return new ea({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:n.CreateTableNode.create((0,c.parseTable)(e))})}dropTable(e){return new en({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:l.create((0,c.parseTable)(e))})}createIndex(e){return new ee({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:i.create(e)})}dropIndex(e){return new ei({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:p.create(e)})}createSchema(e){return new et({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:s.create(e)})}dropSchema(e){return new es({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:d.create(e)})}alterTable(e){return new K({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:r.create((0,c.parseTable)(e))})}createView(e){return new ec({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ed.CreateViewNode.create(e)})}dropView(e){return new eh({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:eu.create(e)})}createType(e){return new eg({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ef.create(ew(e))})}dropType(e){return new ey({queryId:(0,eo.createQueryId)(),executor:this.#eh,node:ev.create(ew(e))})}withPlugin(e){return new e_(this.#eh.withPlugin(e))}withoutPlugins(){return new e_(this.#eh.withoutPlugins())}withSchema(e){return new e_(this.#eh.withPluginAtFront(new ep.WithSchemaPlugin(e)))}}var ex=e.i(80864);class eN{ref(e){return new ex.DynamicReferenceBuilder(e)}}class eT{#em;constructor(e){this.#em=e}async provideConnection(e){let t=await this.#em.acquireConnection();try{return await e(t)}finally{await this.#em.releaseConnection(t)}}}var eE=e.i(82258),eA=e.i(46432);class eS extends eA.QueryExecutorBase{#ef;#eg;#ev;constructor(e,t,r,a=[]){super(a),this.#ef=e,this.#eg=t,this.#ev=r}get adapter(){return this.#eg}compileQuery(e){return this.#ef.compileQuery(e)}provideConnection(e){return this.#ev.provideConnection(e)}withPlugins(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,...e])}withPlugin(e){return new eS(this.#ef,this.#eg,this.#ev,[...this.plugins,e])}withPluginAtFront(e){return new eS(this.#ef,this.#eg,this.#ev,[e,...this.plugins])}withConnectionProvider(e){return new eS(this.#ef,this.#eg,e,[...this.plugins])}withoutPlugins(){return new eS(this.#ef,this.#eg,this.#ev,[])}}function ek(){return"undefined"!=typeof performance&&(0,t.isFunction)(performance.now)?performance.now():Date.now()}class eO{#em;#ey;#ew;#eb;#e_;#ex=new WeakSet;constructor(e,t){this.#eb=!1,this.#em=e,this.#ey=t}async init(){if(this.#e_)throw Error("driver has already been destroyed");this.#ew||(this.#ew=this.#em.init().then(()=>{this.#eb=!0}).catch(e=>(this.#ew=void 0,Promise.reject(e)))),await this.#ew}async acquireConnection(){if(this.#e_)throw Error("driver has already been destroyed");this.#eb||await this.init();let e=await this.#em.acquireConnection();return this.#ex.has(e)||(this.#eN()&&this.#eT(e),this.#ex.add(e)),e}async releaseConnection(e){await this.#em.releaseConnection(e)}beginTransaction(e,t){return this.#em.beginTransaction(e,t)}commitTransaction(e){return this.#em.commitTransaction(e)}rollbackTransaction(e){return this.#em.rollbackTransaction(e)}async destroy(){this.#ew&&(await this.#ew,this.#e_||(this.#e_=this.#em.destroy().catch(e=>(this.#e_=void 0,Promise.reject(e)))),await this.#e_)}#eN(){return this.#ey.isLevelEnabled("query")||this.#ey.isLevelEnabled("error")}#eT(e){let t=e.executeQuery;e.executeQuery=async r=>{let a,i=ek();try{return await t.call(e,r)}catch(e){throw a=e,await this.#eE(e,r,i),e}finally{a||await this.#eA(r,i)}}}async #eE(e,t,r){await this.#ey.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#eS(r)}))}async #eA(e,t){await this.#ey.query(()=>({level:"query",query:e,queryDurationMillis:this.#eS(t)}))}#eS(e){return ek()-e}}let eC=()=>{};class eI{#ek;#eO;constructor(e){this.#ek=e}async provideConnection(e){for(;this.#eO;)await this.#eO.catch(eC);return this.#eO=this.#eC(e).finally(()=>{this.#eO=void 0}),this.#eO}async #eC(e){return await e(this.#ek)}}let eR=["read uncommitted","read committed","repeatable read","serializable","snapshot"];var eD=e.i(86566);(0,t.freeze)(["query","error"]);class eP{#eI;#eR;constructor(e){(0,t.isFunction)(e)?(this.#eR=e,this.#eI=(0,t.freeze)({query:!0,error:!0})):(this.#eR=ej,this.#eI=(0,t.freeze)({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#eI[e]}async query(e){this.#eI.query&&await this.#eR(e())}async error(e){this.#eI.error&&await this.#eR(e())}}function ej(e){"query"===e.level?(console.log(`kysely:query: ${e.query.sql}`),console.log(`kysely:query: duration: ${e.queryDurationMillis.toFixed(1)}ms`)):"error"===e.level&&(e.error instanceof Error?console.error(`kysely:error: ${e.error.stack??e.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`))}var eq=e.i(21797),eL=e.i(72515);class eM extends eE.QueryCreator{#M;constructor(e){let r,a;if(function(e){return(0,t.isObject)(e)&&(0,t.isObject)(e.config)&&(0,t.isObject)(e.driver)&&(0,t.isObject)(e.executor)&&(0,t.isObject)(e.dialect)}(e))r={executor:e.executor},a={...e};else{const t=e.dialect,i=t.createDriver(),s=t.createQueryCompiler(),n=t.createAdapter(),o=new eO(i,new eP(e.log??[])),p=new eS(s,n,new eT(o),e.plugins??[]);r={executor:p},a={config:e,executor:p,dialect:t,driver:o}}super(r),this.#M=(0,t.freeze)(a)}get schema(){return new e_(this.#M.executor)}get dynamic(){return new eN}get introspection(){return this.#M.dialect.createIntrospector(this.withoutPlugins())}case(e){return new eq.CaseBuilder({node:eL.CaseNode.create((0,t.isUndefined)(e)?void 0:(0,er.parseExpression)(e))})}get fn(){return(0,eD.createFunctionModule)()}transaction(){return new eB({...this.#M})}connection(){return new eU({...this.#M})}withPlugin(e){return new eM({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eM({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eM({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eM({...this.#M})}async destroy(){await this.#M.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#M.executor}executeQuery(e,r=(0,eo.createQueryId)()){let a=(0,t.isObject)(e)&&(0,t.isFunction)(e.compile)?e.compile():e;return this.getExecutor().executeQuery(a,r)}}class eF extends eM{#M;constructor(e){super(e),this.#M=e}get isTransaction(){return!0}transaction(){throw Error("calling the transaction method for a Transaction is not supported")}connection(){throw Error("calling the connection method for a Transaction is not supported")}async destroy(){throw Error("calling the destroy method for a Transaction is not supported")}withPlugin(e){return new eF({...this.#M,executor:this.#M.executor.withPlugin(e)})}withoutPlugins(){return new eF({...this.#M,executor:this.#M.executor.withoutPlugins()})}withSchema(e){return new eF({...this.#M,executor:this.#M.executor.withPluginAtFront(new ep.WithSchemaPlugin(e))})}withTables(){return new eF({...this.#M})}}class eU{#M;constructor(e){this.#M=(0,t.freeze)(e)}async execute(e){return this.#M.executor.provideConnection(async t=>{let r=this.#M.executor.withConnectionProvider(new eI(t)),a=new eM({...this.#M,executor:r});return await e(a)})}}(0,v.preventAwait)(eU,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");class eB{#M;constructor(e){this.#M=(0,t.freeze)(e)}setIsolationLevel(e){return new eB({...this.#M,isolationLevel:e})}async execute(e){let{isolationLevel:t,...r}=this.#M,a={isolationLevel:t};return function(e){if(e.isolationLevel&&!eR.includes(e.isolationLevel))throw Error(`invalid transaction isolation level ${e.isolationLevel}`)}(a),this.#M.executor.provideConnection(async t=>{let i=this.#M.executor.withConnectionProvider(new eI(t)),s=new eF({...r,executor:i});try{await this.#M.driver.beginTransaction(t,a);let r=await e(s);return await this.#M.driver.commitTransaction(t),r}catch(e){throw await this.#M.driver.rollbackTransaction(t),e}})}}(0,v.preventAwait)(eB,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method"),e.s(["Kysely",()=>eM],24659)},12995,e=>{"use strict";var t=e.i(482),r=e.i(56967),a=e.i(90348),i=e.i(46220),s=e.i(56900),n=e.i(87799),o=e.i(40203),p=e.i(34939),d=e.i(79044),l=e.i(50430),c=e.i(84739),u=e.i(13424);class h{#M;constructor(e){this.#M=(0,c.freeze)(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new f(this,e)}$castTo(){return new h({...this.#M})}$notNull(){return new h(this.#M)}withPlugin(e){return new h({...this.#M,plugins:void 0!==this.#M.plugins?(0,c.freeze)([...this.#M.plugins,e]):(0,c.freeze)([e])})}toOperationNode(){return this.#eD(this.#eP())}compile(e){return this.#ej(this.#eP(e))}async execute(e){let t=this.#eP(e);return t.executeQuery(this.#ej(t),this.#M.queryId)}#eP(e){let t=void 0!==e?e.getExecutor():u.NOOP_QUERY_EXECUTOR;return void 0!==this.#M.plugins?t.withPlugins(this.#M.plugins):t}#eD(e){return e.transformQuery(this.#M.rawNode,this.#M.queryId)}#ej(e){return e.compileQuery(this.#eD(e),this.#M.queryId)}}function m(e){return new h(e)}(0,l.preventAwait)(h,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class f{#eq;#en;constructor(e,t){this.#eq=e,this.#en=t}get expression(){return this.#eq}get alias(){return this.#en}get rawBuilder(){return this.#eq}toOperationNode(){return d.AliasNode.create(this.#eq.toOperationNode(),(0,r.isOperationNodeSource)(this.#en)?this.#en.toOperationNode():t.IdentifierNode.create(this.#en))}}(0,l.preventAwait)(f,"don't await AliasedRawBuilder instances directly. AliasedRawBuilder should never be executed directly since it's always a part of another query.");let g=Object.assign((e,...t)=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(e,t?.map(v)??[])}),{ref:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,s.parseStringReference)(e))}),val:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,o.parseValueExpression)(e))}),value(e){return this.val(e)},table:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild((0,n.parseTable)(e))}),id(...e){let r=Array(e.length+1).fill(".");return r[0]="",r[r.length-1]="",m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.create(r,e.map(t.IdentifierNode.create))})},lit:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChild(i.ValueNode.createImmediate(e))}),literal(e){return this.lit(e)},raw:e=>m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithSql(e)}),join(e,t=g`, `){let r=Array(2*e.length-1),i=t.toOperationNode();for(let t=0;t<e.length;++t)r[2*t]=v(e[t]),t!==e.length-1&&(r[2*t+1]=i);return m({queryId:(0,p.createQueryId)(),rawNode:a.RawNode.createWithChildren(r)})}});function v(e){return(0,r.isOperationNodeSource)(e)?e.toOperationNode():(0,o.parseValueExpression)(e)}e.s(["sql",0,g],12995)},78134,e=>{"use strict";var t=e.i(90348),r=e.i(84739);let a=(0,r.freeze)({raw:(e,a=[])=>(0,r.freeze)({sql:e,query:t.RawNode.createWithSql(e),parameters:(0,r.freeze)(a)})}),i=Symbol();class s{#eL;#ex=new WeakMap;#eM;constructor(e){this.#eL=(0,r.freeze)({...e})}async init(){this.#eM=(0,r.isFunction)(this.#eL.pool)?await this.#eL.pool():this.#eL.pool}async acquireConnection(){let e=await this.#eM.connect(),t=this.#ex.get(e);return!t&&(t=new n(e,{cursor:this.#eL.cursor??null}),this.#ex.set(e,t),this.#eL.onCreateConnection&&await this.#eL.onCreateConnection(t)),this.#eL.onReserveConnection&&await this.#eL.onReserveConnection(t),t}async beginTransaction(e,t){t.isolationLevel?await e.executeQuery(a.raw(`start transaction isolation level ${t.isolationLevel}`)):await e.executeQuery(a.raw("begin"))}async commitTransaction(e){await e.executeQuery(a.raw("commit"))}async rollbackTransaction(e){await e.executeQuery(a.raw("rollback"))}async releaseConnection(e){e[i]()}async destroy(){if(this.#eM){let e=this.#eM;this.#eM=void 0,await e.end()}}}class n{#eF;#eU;constructor(e,t){this.#eF=e,this.#eU=t}async executeQuery(e){try{let t=await this.#eF.query(e.sql,[...e.parameters]);if("INSERT"===t.command||"UPDATE"===t.command||"DELETE"===t.command||"MERGE"===t.command){let e=BigInt(t.rowCount);return{numUpdatedOrDeletedRows:e,numAffectedRows:e,rows:t.rows??[]}}return{rows:t.rows??[]}}catch(e){throw function(e,t){var a;if(a=e,(0,r.isObject)(a)&&(0,r.isString)(a.stack)&&t.stack){let r=t.stack.split("\n").slice(1).join("\n");e.stack+=`
2
2
  ${r}`}return e}(e,Error())}}async *streamQuery(e,t){if(!this.#eU.cursor)throw Error("'cursor' is not present in your postgres dialect config. It's required to make streaming work in postgres.");if(!Number.isInteger(t)||t<=0)throw Error("chunkSize must be a positive integer");let r=this.#eF.query(new this.#eU.cursor(e.sql,e.parameters.slice()));try{for(;;){let e=await r.read(t);if(0===e.length)break;yield{rows:e}}}finally{await r.close()}}[i](){this.#eF.release()}}e.i(90640),(0,r.freeze)({__noMigrations__:!0});var o=e.i(12995);class p{#eB;constructor(e){this.#eB=e}async getSchemas(){return(await this.#eB.selectFrom("pg_catalog.pg_namespace").select("nspname").$castTo().execute()).map(e=>({name:e.nspname}))}async getTables(e={withInternalKyselyTables:!1}){let t=this.#eB.selectFrom("pg_catalog.pg_attribute as a").innerJoin("pg_catalog.pg_class as c","a.attrelid","c.oid").innerJoin("pg_catalog.pg_namespace as ns","c.relnamespace","ns.oid").innerJoin("pg_catalog.pg_type as typ","a.atttypid","typ.oid").innerJoin("pg_catalog.pg_namespace as dtns","typ.typnamespace","dtns.oid").select(["a.attname as column","a.attnotnull as not_null","a.atthasdef as has_default","c.relname as table","c.relkind as table_type","ns.nspname as schema","typ.typname as type","dtns.nspname as type_schema",o.sql`col_description(a.attrelid, a.attnum)`.as("column_description"),this.#eB.selectFrom("pg_class").select(o.sql`true`.as("auto_incrementing")).whereRef("relnamespace","=","c.relnamespace").where("relkind","=","S").where("relname","=",o.sql`c.relname || '_' || a.attname || '_seq'`).as("auto_incrementing")]).where(e=>e.or([e("c.relkind","=","r"),e("c.relkind","=","v"),e("c.relkind","=","p")])).where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema").where("a.attnum",">=",0).where("a.attisdropped","!=",!0).orderBy("ns.nspname").orderBy("c.relname").orderBy("a.attnum").$castTo();e.withInternalKyselyTables||(t=t.where("c.relname","!=","kysely_migration").where("c.relname","!=","kysely_migration_lock"));let r=await t.execute();return this.#eV(r)}async getMetadata(e){return{tables:await this.getTables(e)}}#eV(e){return e.reduce((e,t)=>{let a=e.find(e=>e.name===t.table&&e.schema===t.schema);return a||(a=(0,r.freeze)({name:t.table,isView:"v"===t.table_type,schema:t.schema,columns:[]}),e.push(a)),a.columns.push((0,r.freeze)({name:t.column,dataType:t.type,dataTypeSchema:t.type_schema,isNullable:!t.not_null,isAutoIncrementing:!!t.auto_incrementing,hasDefaultValue:t.has_default,comment:t.column_description??void 0})),e},[])}}var d=e.i(58666),l=e.i(72866);class c{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#ez=(0,r.freeze)({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this)});visitNode=e=>{this.nodeStack.push(e),this.#ez[e.kind](e),this.nodeStack.pop()}}var u=e.i(6697),h=e.i(9581),m=e.i(27539),f=e.i(3888),g=e.i(45393),v=e.i(29986);class y extends c{#eW="";#e$=[];get numParameters(){return this.#e$.length}compileQuery(e){return this.#eW="",this.#e$=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(e),(0,r.freeze)({query:e,sql:this.getSql(),parameters:[...this.#e$]})}getSql(){return this.#eW}visitSelectQuery(e){let t=void 0!==this.parentNode&&!h.ParensNode.is(this.parentNode)&&!l.InsertQueryNode.is(this.parentNode)&&!d.CreateTableNode.is(this.parentNode)&&!f.CreateViewNode.is(this.parentNode)&&!g.SetOperationNode.is(this.parentNode);void 0===this.parentNode&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("select"),e.distinctOn&&(this.append(" "),this.compileDistinctOn(e.distinctOn)),e.frontModifiers?.length&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.top&&(this.append(" "),this.visitNode(e.top)),e.selections&&(this.append(" "),this.compileList(e.selections)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.groupBy&&(this.append(" "),this.visitNode(e.groupBy)),e.having&&(this.append(" "),this.visitNode(e.having)),e.setOperations&&(this.append(" "),this.compileList(e.setOperations," ")),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.offset&&(this.append(" "),this.visitNode(e.offset)),e.fetch&&(this.append(" "),this.visitNode(e.fetch)),e.endModifiers?.length&&(this.append(" "),this.compileList(this.sortSelectModifiers([...e.endModifiers])," ")),t&&this.append(")")}visitFrom(e){this.append("from "),this.compileList(e.froms)}visitSelection(e){this.visitNode(e.selection)}visitColumn(e){this.visitNode(e.column)}compileDistinctOn(e){this.append("distinct on ("),this.compileList(e),this.append(")")}compileList(e,t=", "){let r=e.length-1;for(let a=0;a<=r;a++)this.visitNode(e[a]),a<r&&this.append(t)}visitWhere(e){this.append("where "),this.visitNode(e.where)}visitHaving(e){this.append("having "),this.visitNode(e.having)}visitInsertQuery(e){let t=this.nodeStack.find(m.QueryNode.is),r=t!==e;!r&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&!v.MergeQueryNode.is(t)&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append(e.replace?"replace":"insert"),e.ignore&&this.append(" ignore"),e.top&&(this.append(" "),this.visitNode(e.top)),e.into&&(this.append(" into "),this.visitNode(e.into)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.output&&(this.append(" "),this.visitNode(e.output)),e.values&&(this.append(" "),this.visitNode(e.values)),e.defaultValues&&(this.append(" "),this.append("default values")),e.onConflict&&(this.append(" "),this.visitNode(e.onConflict)),e.onDuplicateKey&&(this.append(" "),this.visitNode(e.onDuplicateKey)),e.returning&&(this.append(" "),this.visitNode(e.returning)),r&&!v.MergeQueryNode.is(t)&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitValues(e){this.append("values "),this.compileList(e.values)}visitDeleteQuery(e){let t=this.nodeStack.find(m.QueryNode.is)!==e;!t&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("delete "),e.top&&(this.visitNode(e.top),this.append(" ")),this.visitNode(e.from),e.output&&(this.append(" "),this.visitNode(e.output)),e.using&&(this.append(" "),this.visitNode(e.using)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),t&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitReturning(e){this.append("returning "),this.compileList(e.selections)}visitAlias(e){this.visitNode(e.node),this.append(" as "),this.visitNode(e.alias)}visitReference(e){e.table&&(this.visitNode(e.table),this.append(".")),this.visitNode(e.column)}visitSelectAll(e){this.append("*")}visitIdentifier(e){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(e),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(e){if(!(0,r.isString)(e.name))throw Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(e.name))}visitAnd(e){this.visitNode(e.left),this.append(" and "),this.visitNode(e.right)}visitOr(e){this.visitNode(e.left),this.append(" or "),this.visitNode(e.right)}visitValue(e){e.immediate?this.appendImmediateValue(e.value):this.appendValue(e.value)}visitValueList(e){this.append("("),this.compileList(e.values),this.append(")")}visitTuple(e){this.append("("),this.compileList(e.values),this.append(")")}visitPrimitiveValueList(e){this.append("(");let{values:t}=e;for(let e=0;e<t.length;++e)this.appendValue(t[e]),e!==t.length-1&&this.append(", ");this.append(")")}visitParens(e){this.append("("),this.visitNode(e.node),this.append(")")}visitJoin(e){this.append(_[e.joinType]),this.append(" "),this.visitNode(e.table),e.on&&(this.append(" "),this.visitNode(e.on))}visitOn(e){this.append("on "),this.visitNode(e.on)}visitRaw(e){let{sqlFragments:t,parameters:r}=e;for(let e=0;e<t.length;++e)this.append(t[e]),r.length>e&&this.visitNode(r[e])}visitOperator(e){this.append(e.operator)}visitTable(e){this.visitNode(e.table)}visitSchemableIdentifier(e){e.schema&&(this.visitNode(e.schema),this.append(".")),this.visitNode(e.identifier)}visitCreateTable(e){this.append("create "),e.frontModifiers&&e.frontModifiers.length>0&&(this.compileList(e.frontModifiers," "),this.append(" ")),e.temporary&&this.append("temporary "),this.append("table "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.table),e.selectQuery?(this.append(" as "),this.visitNode(e.selectQuery)):(this.append(" ("),this.compileList([...e.columns,...e.constraints??[]]),this.append(")"),e.onCommit&&(this.append(" on commit "),this.append(e.onCommit)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," ")))}visitColumnDefinition(e){e.ifNotExists&&this.append("if not exists "),this.visitNode(e.column),this.append(" "),this.visitNode(e.dataType),e.unsigned&&this.append(" unsigned"),e.frontModifiers&&e.frontModifiers.length>0&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.generated&&(this.append(" "),this.visitNode(e.generated)),e.identity&&this.append(" identity"),e.defaultTo&&(this.append(" "),this.visitNode(e.defaultTo)),e.notNull&&this.append(" not null"),e.unique&&this.append(" unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.primaryKey&&this.append(" primary key"),e.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),e.references&&(this.append(" "),this.visitNode(e.references)),e.check&&(this.append(" "),this.visitNode(e.check)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(e){this.append("references "),this.visitNode(e.table),this.append(" ("),this.compileList(e.columns),this.append(")"),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitDropTable(e){this.append("drop table "),e.ifExists&&this.append("if exists "),this.visitNode(e.table),e.cascade&&this.append(" cascade")}visitDataType(e){this.append(e.dataType)}visitOrderBy(e){this.append("order by "),this.compileList(e.items)}visitOrderByItem(e){this.visitNode(e.orderBy),e.direction&&(this.append(" "),this.visitNode(e.direction))}visitGroupBy(e){this.append("group by "),this.compileList(e.items)}visitGroupByItem(e){this.visitNode(e.groupBy)}visitUpdateQuery(e){let t=this.nodeStack.find(m.QueryNode.is),r=t!==e;!r&&e.explain&&(this.visitNode(e.explain),this.append(" ")),r&&!v.MergeQueryNode.is(t)&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("update "),e.top&&(this.visitNode(e.top),this.append(" ")),e.table&&(this.visitNode(e.table),this.append(" ")),this.append("set "),e.updates&&this.compileList(e.updates),e.output&&(this.append(" "),this.visitNode(e.output)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),r&&!v.MergeQueryNode.is(t)&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitColumnUpdate(e){this.visitNode(e.column),this.append(" = "),this.visitNode(e.value)}visitLimit(e){this.append("limit "),this.visitNode(e.limit)}visitOffset(e){this.append("offset "),this.visitNode(e.offset)}visitOnConflict(e){this.append("on conflict"),e.columns?(this.append(" ("),this.compileList(e.columns),this.append(")")):e.constraint?(this.append(" on constraint "),this.visitNode(e.constraint)):e.indexExpression&&(this.append(" ("),this.visitNode(e.indexExpression),this.append(")")),e.indexWhere&&(this.append(" "),this.visitNode(e.indexWhere)),!0===e.doNothing?this.append(" do nothing"):e.updates&&(this.append(" do update set "),this.compileList(e.updates),e.updateWhere&&(this.append(" "),this.visitNode(e.updateWhere)))}visitOnDuplicateKey(e){this.append("on duplicate key update "),this.compileList(e.updates)}visitCreateIndex(e){this.append("create "),e.unique&&this.append("unique "),this.append("index "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.using&&(this.append(" using "),this.visitNode(e.using)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.where&&(this.append(" "),this.visitNode(e.where))}visitDropIndex(e){this.append("drop index "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.cascade&&this.append(" cascade")}visitCreateSchema(e){this.append("create schema "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.schema)}visitDropSchema(e){this.append("drop schema "),e.ifExists&&this.append("if exists "),this.visitNode(e.schema),e.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("primary key ("),this.compileList(e.columns),this.append(")")}visitUniqueConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),this.append(" ("),this.compileList(e.columns),this.append(")")}visitCheckConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("check ("),this.visitNode(e.expression),this.append(")")}visitForeignKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("foreign key ("),this.compileList(e.columns),this.append(") "),this.visitNode(e.references),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitList(e){this.compileList(e.items)}visitWith(e){this.append("with "),e.recursive&&this.append("recursive "),this.compileList(e.expressions)}visitCommonTableExpression(e){this.visitNode(e.name),this.append(" as "),(0,r.isBoolean)(e.materialized)&&(e.materialized||this.append("not "),this.append("materialized ")),this.visitNode(e.expression)}visitCommonTableExpressionName(e){this.visitNode(e.table),e.columns&&(this.append("("),this.compileList(e.columns),this.append(")"))}visitAlterTable(e){this.append("alter table "),this.visitNode(e.table),this.append(" "),e.renameTo&&(this.append("rename to "),this.visitNode(e.renameTo)),e.setSchema&&(this.append("set schema "),this.visitNode(e.setSchema)),e.addConstraint&&this.visitNode(e.addConstraint),e.dropConstraint&&this.visitNode(e.dropConstraint),e.columnAlterations&&this.compileColumnAlterations(e.columnAlterations),e.addIndex&&this.visitNode(e.addIndex),e.dropIndex&&this.visitNode(e.dropIndex)}visitAddColumn(e){this.append("add column "),this.visitNode(e.column)}visitRenameColumn(e){this.append("rename column "),this.visitNode(e.column),this.append(" to "),this.visitNode(e.renameTo)}visitDropColumn(e){this.append("drop column "),this.visitNode(e.column)}visitAlterColumn(e){this.append("alter column "),this.visitNode(e.column),this.append(" "),e.dataType&&(this.announcesNewColumnDataType()&&this.append("type "),this.visitNode(e.dataType),e.dataTypeExpression&&(this.append("using "),this.visitNode(e.dataTypeExpression))),e.setDefault&&(this.append("set default "),this.visitNode(e.setDefault)),e.dropDefault&&this.append("drop default"),e.setNotNull&&this.append("set not null"),e.dropNotNull&&this.append("drop not null")}visitModifyColumn(e){this.append("modify column "),this.visitNode(e.column)}visitAddConstraint(e){this.append("add "),this.visitNode(e.constraint)}visitDropConstraint(e){this.append("drop constraint "),e.ifExists&&this.append("if exists "),this.visitNode(e.constraintName),"cascade"===e.modifier?this.append(" cascade"):"restrict"===e.modifier&&this.append(" restrict")}visitSetOperation(e){this.append(e.operator),this.append(" "),e.all&&this.append("all "),this.visitNode(e.expression)}visitCreateView(e){this.append("create "),e.orReplace&&this.append("or replace "),e.materialized&&this.append("materialized "),e.temporary&&this.append("temporary "),this.append("view "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),this.append(" "),e.columns&&(this.append("("),this.compileList(e.columns),this.append(") ")),e.as&&(this.append("as "),this.visitNode(e.as))}visitDropView(e){this.append("drop "),e.materialized&&this.append("materialized "),this.append("view "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.cascade&&this.append(" cascade")}visitGenerated(e){this.append("generated "),e.always&&this.append("always "),e.byDefault&&this.append("by default "),this.append("as "),e.identity&&this.append("identity"),e.expression&&(this.append("("),this.visitNode(e.expression),this.append(")")),e.stored&&this.append(" stored")}visitDefaultValue(e){this.append("default "),this.visitNode(e.defaultValue)}visitSelectModifier(e){e.rawModifier?this.visitNode(e.rawModifier):this.append(w[e.modifier]),e.of&&(this.append(" of "),this.compileList(e.of,", "))}visitCreateType(e){this.append("create type "),this.visitNode(e.name),e.enum&&(this.append(" as enum "),this.visitNode(e.enum))}visitDropType(e){this.append("drop type "),e.ifExists&&this.append("if exists "),this.visitNode(e.name)}visitExplain(e){this.append("explain"),(e.options||e.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),e.options&&(this.visitNode(e.options),e.format&&this.append(this.getExplainOptionsDelimiter())),e.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(e.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(e){this.append("default")}visitAggregateFunction(e){this.append(e.func),this.append("("),e.distinct&&this.append("distinct "),this.compileList(e.aggregated),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),this.append(")"),e.filter&&(this.append(" filter("),this.visitNode(e.filter),this.append(")")),e.over&&(this.append(" "),this.visitNode(e.over))}visitOver(e){this.append("over("),e.partitionBy&&(this.visitNode(e.partitionBy),e.orderBy&&this.append(" ")),e.orderBy&&this.visitNode(e.orderBy),this.append(")")}visitPartitionBy(e){this.append("partition by "),this.compileList(e.items)}visitPartitionByItem(e){this.visitNode(e.partitionBy)}visitBinaryOperation(e){this.visitNode(e.leftOperand),this.append(" "),this.visitNode(e.operator),this.append(" "),this.visitNode(e.rightOperand)}visitUnaryOperation(e){this.visitNode(e.operator),this.isMinusOperator(e.operator)||this.append(" "),this.visitNode(e.operand)}isMinusOperator(e){return u.OperatorNode.is(e)&&"-"===e.operator}visitUsing(e){this.append("using "),this.compileList(e.tables)}visitFunction(e){this.append(e.func),this.append("("),this.compileList(e.arguments),this.append(")")}visitCase(e){this.append("case"),e.value&&(this.append(" "),this.visitNode(e.value)),e.when&&(this.append(" "),this.compileList(e.when," ")),e.else&&(this.append(" else "),this.visitNode(e.else)),this.append(" end"),e.isStatement&&this.append(" case")}visitWhen(e){this.append("when "),this.visitNode(e.condition),e.result&&(this.append(" then "),this.visitNode(e.result))}visitJSONReference(e){this.visitNode(e.reference),this.visitNode(e.traversal)}visitJSONPath(e){for(let t of(e.inOperator&&this.visitNode(e.inOperator),this.append("'$"),e.pathLegs))this.visitNode(t);this.append("'")}visitJSONPathLeg(e){let t="ArrayLocation"===e.type;this.append(t?"[":"."),this.append(String(e.value)),t&&this.append("]")}visitJSONOperatorChain(e){for(let t=0,r=e.values.length;t<r;t++)t===r-1?this.visitNode(e.operator):this.append("->"),this.visitNode(e.values[t])}visitMergeQuery(e){e.with&&(this.visitNode(e.with),this.append(" ")),this.append("merge "),e.top&&(this.visitNode(e.top),this.append(" ")),this.append("into "),this.visitNode(e.into),e.using&&(this.append(" "),this.visitNode(e.using)),e.whens&&(this.append(" "),this.compileList(e.whens," ")),e.output&&(this.append(" "),this.visitNode(e.output)),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitMatched(e){e.not&&this.append("not "),this.append("matched"),e.bySource&&this.append(" by source")}visitAddIndex(e){this.append("add "),e.unique&&this.append("unique "),this.append("index "),this.visitNode(e.name),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.using&&(this.append(" using "),this.visitNode(e.using))}visitCast(e){this.append("cast("),this.visitNode(e.expression),this.append(" as "),this.visitNode(e.dataType),this.append(")")}visitFetch(e){this.append("fetch next "),this.visitNode(e.rowCount),this.append(` rows ${e.modifier}`)}visitOutput(e){this.append("output "),this.compileList(e.selections)}visitTop(e){this.append(`top(${e.expression})`),e.modifiers&&this.append(` ${e.modifiers}`)}append(e){this.#eW+=e}appendValue(e){this.addParameter(e),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(e){let t=this.getLeftIdentifierWrapper(),r=this.getRightIdentifierWrapper(),a="";for(let i of e)a+=i,i===t?a+=t:i===r&&(a+=r);return a}addParameter(e){this.#e$.push(e)}appendImmediateValue(e){if((0,r.isString)(e))this.append(`'${e}'`);else if((0,r.isNumber)(e)||(0,r.isBoolean)(e))this.append(e.toString());else if((0,r.isNull)(e))this.append("null");else if((0,r.isDate)(e))this.appendImmediateValue(e.toISOString());else if((0,r.isBigInt)(e))this.appendImmediateValue(e.toString());else throw Error(`invalid immediate value ${e}`)}sortSelectModifiers(e){return e.sort((e,t)=>e.modifier&&t.modifier?b[e.modifier]-b[t.modifier]:1),(0,r.freeze)(e)}compileColumnAlterations(e){this.compileList(e)}announcesNewColumnDataType(){return!0}}let w=(0,r.freeze)({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),b=(0,r.freeze)({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),_=(0,r.freeze)({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",Using:"using"}),x=/"/g;class N extends y{sanitizeIdentifier(e){return e.replace(x,'""')}}class T{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}}let E=BigInt("3853314791062309107");class A extends T{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,t){await o.sql`select pg_advisory_xact_lock(${o.sql.lit(E)})`.execute(e)}async releaseMigrationLock(e,t){}}class S{#eL;constructor(e){this.#eL=e}createDriver(){return new s(this.#eL)}createQueryCompiler(){return new N}createAdapter(){return new A}createIntrospector(e){return new p(e)}}e.s(["PostgresDialect",()=>S],78134)},30056,e=>e.a(async(t,r)=>{try{let t=await e.y("pg");e.n(t),r()}catch(e){r(e)}},!0),14281,e=>e.a(async(t,r)=>{try{var a=e.i(24659),i=e.i(78134),s=e.i(30056),n=t([s]);[s]=n.then?(await n)():n;let o=new s.default.Pool({connectionString:process.env.DATABASE_URL}),p=new a.Kysely({dialect:new i.PostgresDialect({pool:o}),log:void 0}),d=async()=>{try{await p.destroy()}catch(e){throw console.error(e,"Failed to clean up resources"),e}};process.on("SIGTERM",d),process.on("SIGINT",d),e.s(["db",0,p]),r()}catch(e){r(e)}},!1),54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},66680,(e,t,r)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},7273,e=>{"use strict";let t,r;var a=e.i(66680);function i(e=21){var s;s=e|=0,!t||t.length<s?(t=Buffer.allocUnsafe(128*s),a.webcrypto.getRandomValues(t),r=0):r+s>t.length&&(a.webcrypto.getRandomValues(t),r=0),r+=s;let n="";for(let a=r-e;a<r;a++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[a]];return n}e.s(["nanoid",()=>i],7273)},69855,e=>{"use strict";var t=e.i(54799),r=e.i(12995),a=e.i(7273);class i{db;serverPepper;constructor(e,t){this.db=e,this.serverPepper=t}hashKey(e){return(0,t.createHash)("sha256").update(e+this.serverPepper).digest("hex")}generateApiKey(){let e=`sk_${(0,t.randomBytes)(32).toString("hex")}`,r=e.substring(0,12);return{apiKey:e,keyPrefix:r}}async createApp(e){let t=(0,a.nanoid)(),i=new Date,s=await this.db.insertInto("app").values({app_id:t,name:e.name,metadata:r.sql`cast(${JSON.stringify(e.metadata||{})} as jsonb)`,createdAt:i,updatedAt:i}).returningAll().executeTakeFirstOrThrow();return{appId:s.app_id,name:s.name,metadata:s.metadata,createdAt:s.createdAt,updatedAt:s.updatedAt}}async getApp(e){let t=await this.db.selectFrom("app").selectAll().where("app_id","=",e).executeTakeFirst();return t?{appId:t.app_id,name:t.name,metadata:t.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listApps(e){let t=e.limit||50,r=e.offset||0;return(await this.db.selectFrom("app").selectAll().orderBy("createdAt","desc").limit(t).offset(r).execute()).map(e=>({appId:e.app_id,name:e.name,metadata:e.metadata,createdAt:e.createdAt,updatedAt:e.updatedAt}))}async updateApp(e){let t={updatedAt:new Date};void 0!==e.name&&(t.name=e.name);let a=await this.db.updateTable("app").set(t).$if(void 0!==e.metadata,t=>t.set("metadata",r.sql`cast(${JSON.stringify(e.metadata||{})} as jsonb)`)).where("app_id","=",e.appId).returningAll().executeTakeFirst();return a?{appId:a.app_id,name:a.name,metadata:a.metadata,createdAt:a.createdAt,updatedAt:a.updatedAt}:null}async deleteApp(e){await this.db.deleteFrom("app").where("app_id","=",e).execute()}async createApiKey(e){let t=(0,a.nanoid)(),{apiKey:i,keyPrefix:s}=this.generateApiKey(),n=this.hashKey(i);return await this.db.insertInto("api_key").values({key_id:t,key_prefix:s,key_hash:n,app_id:e.appId,scopes:r.sql`cast(${JSON.stringify(e.scopes)} as jsonb)`,name:e.name,metadata:r.sql`cast(${JSON.stringify(e.metadata||{})} as jsonb)`,createdAt:new Date}).execute(),{apiKey:i,keyId:t,keyPrefix:s}}async verifyApiKey(e){let t=this.hashKey(e),r=await this.db.selectFrom("api_key").select(["key_id","app_id","scopes","revoked_at"]).where("key_hash","=",t).executeTakeFirst();return!r||r.revoked_at?null:(await this.db.updateTable("api_key").set({last_used_at:new Date}).where("key_id","=",r.key_id).execute(),{keyId:r.key_id,appId:r.app_id,scopes:r.scopes})}async revokeApiKey(e,t){await this.db.updateTable("api_key").set({revoked_at:new Date}).where("key_id","=",t).where("app_id","=",e).execute()}async listApiKeys(e){return(await this.db.selectFrom("api_key").select(["key_id","key_prefix","app_id","scopes","name","last_used_at","revoked_at","createdAt"]).where("app_id","=",e.appId).execute()).map(e=>({keyId:e.key_id,keyPrefix:e.key_prefix,appId:e.app_id,scopes:e.scopes,name:e.name,lastUsedAt:e.last_used_at,revokedAt:e.revoked_at,createdAt:e.createdAt}))}async getOrCreateAppByName(e){let t=await this.db.selectFrom("app").selectAll().where("name","=",e).executeTakeFirst();return t?{appId:t.app_id,name:t.name,metadata:t.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt}:this.createApp({name:e,metadata:{createdBy:"standalone-mode"}})}}e.s(["PostgresAppStore",()=>i])},24868,(e,t,r)=>{t.exports=e.x("fs/promises",()=>require("fs/promises"))},13932,e=>{"use strict";var t=e.i(54799),r=e.i(24868),a=e.i(14747),i=e.i(7273);async function s(e){try{let t=await (0,r.readFile)(e,"utf-8");return JSON.parse(t)}catch(e){if("ENOENT"===e.code)return null;throw e}}async function n(e,t){await (0,r.mkdir)((0,a.dirname)(e),{recursive:!0}),await (0,r.writeFile)(e,JSON.stringify(t,null,2),"utf-8")}async function o(e){try{let t=await (0,r.readFile)(e,"utf-8"),a=await (0,r.stat)(e);return{data:JSON.parse(t),createdAt:a.birthtime,updatedAt:a.mtime}}catch(e){if("ENOENT"===e.code)return null;throw e}}async function p(e){try{return(await (0,r.readdir)(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if("ENOENT"===e.code)return[];throw e}}class d{basePath;serverPepper;constructor(e,t){this.basePath=e,this.serverPepper=t}getAppsDir(){return(0,a.join)(this.basePath,"apps")}getAppDir(e){return(0,a.join)(this.getAppsDir(),e)}getAppDataPath(e){return(0,a.join)(this.getAppDir(e),"data.json")}getApiKeysPath(e){return(0,a.join)(this.getAppDir(e),"api-keys","data.json")}hashKey(e){return(0,t.createHash)("sha256").update(e+this.serverPepper).digest("hex")}generateApiKey(){let e=`sk_${(0,t.randomBytes)(32).toString("hex")}`,r=e.substring(0,12);return{apiKey:e,keyPrefix:r}}async loadApiKeys(e){return await s(this.getApiKeysPath(e))??{keys:[],hashIndex:{}}}async saveApiKeys(e,t){await n(this.getApiKeysPath(e),t)}async createApp(e){let t=(0,i.nanoid)(),a={appId:t,name:e.name,metadata:e.metadata||{}};await n(this.getAppDataPath(t),a);let s=await (0,r.stat)(this.getAppDataPath(t));return{appId:a.appId,name:a.name,metadata:a.metadata,createdAt:s.birthtime,updatedAt:s.mtime}}async getApp(e){let t=await o(this.getAppDataPath(e));return t?{appId:t.data.appId,name:t.data.name,metadata:t.data.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listApps(e){let t=e.limit||50,a=e.offset||0,i=await p(this.getAppsDir()),s=[];for(let e of i)try{let t=await (0,r.stat)(this.getAppDataPath(e));s.push({appId:e,createdAt:t.birthtime})}catch{}s.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime());let n=s.slice(a,a+t),d=[];for(let{appId:e}of n){let t=await o(this.getAppDataPath(e));t&&d.push({appId:t.data.appId,name:t.data.name,metadata:t.data.metadata,createdAt:t.createdAt,updatedAt:t.updatedAt})}return d}async updateApp(e){let t=await s(this.getAppDataPath(e.appId));if(!t)return null;let a={...t,name:void 0!==e.name?e.name:t.name,metadata:void 0!==e.metadata?e.metadata:t.metadata};await n(this.getAppDataPath(e.appId),a);let i=await (0,r.stat)(this.getAppDataPath(e.appId));return{appId:a.appId,name:a.name,metadata:a.metadata,createdAt:i.birthtime,updatedAt:i.mtime}}async deleteApp(e){try{await (0,r.rm)(this.getAppDir(e),{recursive:!0,force:!0})}catch(e){if("ENOENT"!==e.code)throw e}}async createApiKey(e){let t=(0,i.nanoid)(),{apiKey:r,keyPrefix:a}=this.generateApiKey(),s=this.hashKey(r),n=await this.loadApiKeys(e.appId),o={keyId:t,keyPrefix:a,keyHash:s,appId:e.appId,scopes:e.scopes,name:e.name,metadata:e.metadata||{},lastUsedAt:null,revokedAt:null,createdAt:new Date().toISOString()};return n.keys.push(o),n.hashIndex[s]=t,await this.saveApiKeys(e.appId,n),{apiKey:r,keyId:t,keyPrefix:a}}async verifyApiKey(e){let t=this.hashKey(e);for(let e of(await p(this.getAppsDir()))){let r=await this.loadApiKeys(e),a=r.hashIndex[t];if(!a)continue;let i=r.keys.find(e=>e.keyId===a);if(i){if(i.revokedAt)return null;return i.lastUsedAt=new Date().toISOString(),await this.saveApiKeys(e,r),{keyId:i.keyId,appId:i.appId,scopes:i.scopes}}}return null}async revokeApiKey(e,t){let r=await this.loadApiKeys(e),a=r.keys.find(e=>e.keyId===t);a&&(a.revokedAt=new Date().toISOString(),await this.saveApiKeys(e,r))}async listApiKeys(e){return(await this.loadApiKeys(e.appId)).keys.map(e=>({keyId:e.keyId,keyPrefix:e.keyPrefix,appId:e.appId,scopes:e.scopes,name:e.name,lastUsedAt:e.lastUsedAt?new Date(e.lastUsedAt):null,revokedAt:e.revokedAt?new Date(e.revokedAt):null,createdAt:new Date(e.createdAt)}))}async getOrCreateAppByName(e){for(let t of(await p(this.getAppsDir()))){let r=await o(this.getAppDataPath(t));if(r&&r.data.name===e)return{appId:r.data.appId,name:r.data.name,metadata:r.data.metadata,createdAt:r.createdAt,updatedAt:r.updatedAt}}return this.createApp({name:e,metadata:{createdBy:"standalone-mode"}})}}e.s(["LocalAppStore",()=>d])},54906,e=>{"use strict";e.i(69855),e.i(13932),e.s([])},36553,e=>{"use strict";var t=e.i(54799),r=e.i(24868),a=e.i(14747),i=e.i(7273);class s{blobPath;dataPath;constructor(e,t){this.blobPath=e,this.dataPath=t}getGenerationFilePath(e,t,r){return(0,a.join)(this.dataPath,"apps",e,"generations",t,"files",`${r}.json`)}getBlobPath(e,t,r,i){return(0,a.join)(this.blobPath,"apps",e,"generations",t,r,i)}async saveGenerationFile(e){let s=(0,i.nanoid)(),n=(0,t.createHash)("sha256").update(e.content).digest("hex"),o=`apps/${e.appId}/generations/${e.generationId}/${s}/${e.filename}`,p=(0,a.join)(this.blobPath,o);await (0,r.mkdir)((0,a.dirname)(p),{recursive:!0}),await (0,r.writeFile)(p,e.content);let d={fileId:s,generationId:e.generationId,filename:e.filename,contentType:e.contentType,sizeBytes:e.content.length.toString(),sha256Hex:n,gcsPath:o},l=this.getGenerationFilePath(e.appId,e.generationId,s);return await (0,r.mkdir)((0,a.dirname)(l),{recursive:!0}),await (0,r.writeFile)(l,JSON.stringify(d,null,2),"utf-8"),{fileId:s}}async downloadFile(e){let t=(0,a.join)(this.blobPath,e);return(0,r.readFile)(t)}}e.s(["LocalBlobStore",()=>s])},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},46786,(e,t,r)=>{t.exports=e.x("os",()=>require("os"))},91198,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GCE_LINUX_BIOS_PATHS=void 0,r.isGoogleCloudServerless=s,r.isGoogleComputeEngineLinux=n,r.isGoogleComputeEngineMACAddress=o,r.isGoogleComputeEngine=p,r.detectGCPResidency=function(){return s()||p()},e.r(22734);let a=e.r(46786);r.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};let i=/^42:01/;function s(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function n(){if("linux"!==(0,a.platform)())return!1}function o(){for(let e of Object.values((0,a.networkInterfaces)()))if(e){for(let{mac:t}of e)if(i.test(t))return!0}return!1}function p(){return n()||o()}},4446,(e,t,r)=>{t.exports=e.x("net",()=>require("net"))},55004,(e,t,r)=>{t.exports=e.x("tls",()=>require("tls"))},49719,(e,t,r)=>{t.exports=e.x("assert",()=>require("assert"))},57108,(e,t,r)=>{function a(e,t,r,a){return Math.round(e/r)+" "+a+(t>=1.5*r?"s":"")}t.exports=function(e,t){t=t||{};var r,i,s,n,o=typeof e;if("string"===o&&e.length>0){var p=e;if(!((p=String(p)).length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(d){var l=parseFloat(d[1]);switch((d[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*l;case"weeks":case"week":case"w":return 6048e5*l;case"days":case"day":case"d":return 864e5*l;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*l;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*l;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*l;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:break}}}return}if("number"===o&&isFinite(e)){return t.long?(i=Math.abs(r=e))>=864e5?a(r,i,864e5,"day"):i>=36e5?a(r,i,36e5,"hour"):i>=6e4?a(r,i,6e4,"minute"):i>=1e3?a(r,i,1e3,"second"):r+" ms":(n=Math.abs(s=e))>=864e5?Math.round(s/864e5)+"d":n>=36e5?Math.round(s/36e5)+"h":n>=6e4?Math.round(s/6e4)+"m":n>=1e3?Math.round(s/1e3)+"s":s+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},61086,(e,t,r)=>{t.exports=function(t){function r(e){let t,i,s,n=null;function o(...e){if(!o.enabled)return;let a=Number(new Date);o.diff=a-(t||a),o.prev=t,o.curr=a,t=a,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,a)=>{if("%%"===t)return"%";i++;let s=r.formatters[a];if("function"==typeof s){let r=e[i];t=s.call(o,r),e.splice(i,1),i--}return t}),r.formatArgs.call(o,e),(o.log||r.log).apply(o,e)}return o.namespace=e,o.useColors=r.useColors(),o.color=r.selectColor(e),o.extend=a,o.destroy=r.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==n?n:(i!==r.namespaces&&(i=r.namespaces,s=r.enabled(e)),s),set:e=>{n=e}}),"function"==typeof r.init&&r.init(o),o}function a(e,t){let a=r(this.namespace+(void 0===t?":":t)+e);return a.log=this.log,a}function i(e,t){let r=0,a=0,i=-1,s=0;for(;r<e.length;)if(a<t.length&&(t[a]===e[r]||"*"===t[a]))"*"===t[a]?(i=a,s=r):r++,a++;else{if(-1===i)return!1;a=i+1,r=++s}for(;a<t.length&&"*"===t[a];)a++;return a===t.length}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){let e=[...r.names,...r.skips.map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){for(let t of(r.save(e),r.namespaces=e,r.names=[],r.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean)))"-"===t[0]?r.skips.push(t.slice(1)):r.names.push(t)},r.enabled=function(e){for(let t of r.skips)if(i(e,t))return!1;for(let t of r.names)if(i(e,t))return!0;return!1},r.humanize=e.r(57108),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(e=>{r[e]=t[e]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}},70722,(e,t,r)=>{t.exports=e.x("tty",()=>require("tty"))},75606,(e,t,r)=>{"use strict";t.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":1===e.length?"-":"--",a=t.indexOf(r+e),i=t.indexOf("--");return -1!==a&&(-1===i||a<i)}},2854,(e,t,r)=>{"use strict";let a;e.r(46786);let i=e.r(70722),s=e.r(75606),{env:n}=process;function o(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function p(e,t){if(0===a)return 0;if(s("color=16m")||s("color=full")||s("color=truecolor"))return 3;if(s("color=256"))return 2;if(e&&!t&&void 0===a)return 0;let r=a||0;if("dumb"===n.TERM)return r;if("CI"in n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in n)||"codeship"===n.CI_NAME?1:r;if("TEAMCITY_VERSION"in n)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION);if("truecolor"===n.COLORTERM)return 3;if("TERM_PROGRAM"in n){let e=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:r}s("no-color")||s("no-colors")||s("color=false")||s("color=never")?a=0:(s("color")||s("colors")||s("color=true")||s("color=always"))&&(a=1),"FORCE_COLOR"in n&&(a="true"===n.FORCE_COLOR?1:"false"===n.FORCE_COLOR?0:0===n.FORCE_COLOR.length?1:Math.min(parseInt(n.FORCE_COLOR,10),3)),t.exports={supportsColor:function(e){return o(p(e,e&&e.isTTY))},stdout:o(p(!0,i.isatty(1))),stderr:o(p(!0,i.isatty(2)))}},89376,(e,t,r)=>{let a=e.r(70722),i=e.r(24361);r.init=function(e){e.inspectOpts={};let t=Object.keys(r.inspectOpts);for(let a=0;a<t.length;a++)e.inspectOpts[t[a]]=r.inspectOpts[t[a]]},r.log=function(...e){return process.stderr.write(i.formatWithOptions(r.inspectOpts,...e)+"\n")},r.formatArgs=function(e){let{namespace:a,useColors:i}=this;if(i){let r=this.color,i="\x1b[3"+(r<8?r:"8;5;"+r),s=` ${i};1m${a} \u001B[0m`;e[0]=s+e[0].split("\n").join("\n"+s),e.push(i+"m+"+t.exports.humanize(this.diff)+"\x1b[0m")}else e[0]=(r.inspectOpts.hideDate?"":new Date().toISOString()+" ")+a+" "+e[0]},r.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},r.load=function(){return process.env.DEBUG},r.useColors=function(){return"colors"in r.inspectOpts?!!r.inspectOpts.colors:a.isatty(process.stderr.fd)},r.destroy=i.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),r.colors=[6,2,3,4,5,1];try{let t=e.r(2854);t&&(t.stderr||t).level>=2&&(r.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}r.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),a=process.env[t];return a=!!/^(yes|on|true|enabled)$/i.test(a)||!/^(no|off|false|disabled)$/i.test(a)&&("null"===a?null:Number(a)),e[r]=a,e},{}),t.exports=e.r(61086)(r);let{formatters:s}=t.exports;s.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},s.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)}},38771,(e,t,r)=>{let a;r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;let r="color: "+this.color;e.splice(1,0,r,"color: inherit");let a=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(a++,"%c"===e&&(i=a))}),e.splice(i,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")||r.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},r.useColors=function(){let e;return!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},r.storage=function(){try{return localStorage}catch(e){}}(),a=!1,r.destroy=()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))},r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e.r(61086)(r);let{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},14682,(e,t,r)=>{"undefined"==typeof process||"renderer"===process.type||process.__nwjs?t.exports=e.r(38771):t.exports=e.r(89376)},21517,(e,t,r)=>{t.exports=e.x("http",()=>require("http"))},24836,(e,t,r)=>{t.exports=e.x("https",()=>require("https"))},62848,(e,t,r)=>{"use strict";var a=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return i(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.req=r.json=r.toBuffer=void 0;let n=s(e.r(21517)),o=s(e.r(24836));async function p(e){let t=0,r=[];for await(let a of e)t+=a.length,r.push(a);return Buffer.concat(r,t)}r.toBuffer=p,r.json=async function(e){let t=(await p(e)).toString("utf8");try{return JSON.parse(t)}catch(e){throw e.message+=` (input: ${t})`,e}},r.req=function(e,t={}){let r=(("string"==typeof e?e:e.href).startsWith("https:")?o:n).request(e,t),a=new Promise((e,t)=>{r.once("response",e).once("error",t).end()});return r.then=a.then.bind(a),r}},15303,(e,t,r)=>{"use strict";var a=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return i(t,e),t},n=e.e&&e.e.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.Agent=void 0;let o=s(e.r(4446)),p=s(e.r(21517)),d=e.r(24836);n(e.r(62848),r);let l=Symbol("AgentBaseInternalState");class c extends p.Agent{constructor(e){super(e),this[l]={}}isSecureEndpoint(e){if(e){if("boolean"==typeof e.secureEndpoint)return e.secureEndpoint;if("string"==typeof e.protocol)return"https:"===e.protocol}let{stack:t}=Error();return"string"==typeof t&&t.split("\n").some(e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:"))}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;this.sockets[e]||(this.sockets[e]=[]);let t=new o.Socket({writable:!1});return this.sockets[e].push(t),this.totalSocketCount++,t}decrementSockets(e,t){if(!this.sockets[e]||null===t)return;let r=this.sockets[e],a=r.indexOf(t);-1!==a&&(r.splice(a,1),this.totalSocketCount--,0===r.length&&delete this.sockets[e])}getName(e){return this.isSecureEndpoint(e)?d.Agent.prototype.getName.call(this,e):super.getName(e)}createSocket(e,t,r){let a={...t,secureEndpoint:this.isSecureEndpoint(t)},i=this.getName(a),s=this.incrementSockets(i);Promise.resolve().then(()=>this.connect(e,a)).then(n=>{if(this.decrementSockets(i,s),n instanceof p.Agent)try{return n.addRequest(e,a)}catch(e){return r(e)}this[l].currentSocket=n,super.createSocket(e,t,r)},e=>{this.decrementSockets(i,s),r(e)})}createConnection(){let e=this[l].currentSocket;if(this[l].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[l].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(e){this[l]&&(this[l].defaultPort=e)}get protocol(){return this[l].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(e){this[l]&&(this[l].protocol=e)}}r.Agent=c},92509,(e,t,r)=>{t.exports=e.x("url",()=>require("url"))},27842,(e,t,r)=>{"use strict";var a=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.parseProxyResponse=void 0;let i=(0,a(e.r(14682)).default)("https-proxy-agent:parse-proxy-response");r.parseProxyResponse=function(e){return new Promise((t,r)=>{let a=0,s=[];function n(){let p=e.read();p?function(p){s.push(p),a+=p.length;let d=Buffer.concat(s,a),l=d.indexOf("\r\n\r\n");if(-1===l){i("have not received end of HTTP headers yet..."),n();return}let c=d.slice(0,l).toString("ascii").split("\r\n"),u=c.shift();if(!u)return e.destroy(),r(Error("No header received from proxy CONNECT response"));let h=u.split(" "),m=+h[1],f=h.slice(2).join(" "),g={};for(let t of c){if(!t)continue;let a=t.indexOf(":");if(-1===a)return e.destroy(),r(Error(`Invalid header from proxy CONNECT response: "${t}"`));let i=t.slice(0,a).toLowerCase(),s=t.slice(a+1).trimStart(),n=g[i];"string"==typeof n?g[i]=[n,s]:Array.isArray(n)?n.push(s):g[i]=s}i("got proxy server response: %o %o",u,g),o(),t({connect:{statusCode:m,statusText:f,headers:g},buffered:d})}(p):e.once("readable",n)}function o(){e.removeListener("end",p),e.removeListener("error",d),e.removeListener("readable",n)}function p(){o(),i("onend"),r(Error("Proxy connection ended before receiving CONNECT response"))}function d(e){o(),i("onerror %o",e),r(e)}e.on("error",d),e.on("end",p),n()})}},63352,(e,t,r)=>{"use strict";var a=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&a(t,e,r);return i(t,e),t},n=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.HttpsProxyAgent=void 0;let o=s(e.r(4446)),p=s(e.r(55004)),d=n(e.r(49719)),l=n(e.r(14682)),c=e.r(15303),u=e.r(92509),h=e.r(27842),m=(0,l.default)("https-proxy-agent"),f=e=>void 0===e.servername&&e.host&&!o.isIP(e.host)?{...e,servername:e.host}:e;class g extends c.Agent{constructor(e,t){super(t),this.options={path:void 0},this.proxy="string"==typeof e?new u.URL(e):e,this.proxyHeaders=t?.headers??{},m("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const r=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),a=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...t?y(t,"headers"):null,host:r,port:a}}async connect(e,t){let r,{proxy:a}=this;if(!t.host)throw TypeError('No "host" provided');"https:"===a.protocol?(m("Creating `tls.Socket`: %o",this.connectOpts),r=p.connect(f(this.connectOpts))):(m("Creating `net.Socket`: %o",this.connectOpts),r=o.connect(this.connectOpts));let i="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},s=o.isIPv6(t.host)?`[${t.host}]`:t.host,n=`CONNECT ${s}:${t.port} HTTP/1.1\r
3
3
  `;if(a.username||a.password){let e=`${decodeURIComponent(a.username)}:${decodeURIComponent(a.password)}`;i["Proxy-Authorization"]=`Basic ${Buffer.from(e).toString("base64")}`}for(let e of(i.Host=`${s}:${t.port}`,i["Proxy-Connection"]||(i["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close"),Object.keys(i)))n+=`${e}: ${i[e]}\r
4
4
  `;let l=(0,h.parseProxyResponse)(r);r.write(`${n}\r
@@ -23,6 +23,6 @@ ${y}
23
23
  Content-Type: ${i["Content-Type"]}\r
24
24
  \r
25
25
  `;a.write(t),"string"==typeof i.body?(a.write(i.body),a.write("\r\n")):(i.body.pipe(a,{end:!1}),i.body.on("end",()=>{a.write("\r\n"),a.write(r),a.end()}))}return a}(e,u),l.stats.requestStarting(),(0,a.default)(o,c).then(e=>{l.stats.requestFinished();let t=e.headers.get("content-type"),a=d(c,e),i=a.body;"application/json"===t||"application/json; charset=utf-8"===t?e.json().then(e=>{a.body=e,r(null,a,e)},e=>{r(e,a,i)}):e.text().then(e=>{a.body=e,r(null,a,e)},e=>{r(e,a,i)})},e=>{l.stats.requestFinished(),r(e,null,null)});return}if(void 0===r){let e,t=p(new i.PassThrough);return t.once("reading",()=>{e?(0,i.pipeline)(e,t,()=>{}):t.once("response",()=>{(0,i.pipeline)(e,t,()=>{})})}),c.compress=!1,l.stats.requestStarting(),(0,a.default)(o,c).then(r=>{l.stats.requestFinished(),(e=r.body).on("error",e=>{t.emit("error",e)});let a=d(c,r);t.emit("response",a)},e=>{l.stats.requestFinished(),t.emit("error",e)}),t}l.stats.requestStarting(),(0,a.default)(o,c).then(e=>{l.stats.requestFinished();let t=e.headers.get("content-type"),a=d(c,e),i=a.body;"application/json"===t||"application/json; charset=utf-8"===t?204===a.statusCode?r(null,a,i):e.json().then(e=>{a.body=e,r(null,a,e)},e=>{r(e,a,i)}):e.text().then(t=>{let a=d(c,e);a.body=t,r(null,a,t)},e=>{r(e,a,i)})},e=>{l.stats.requestFinished(),r(e,null,null)})}r.RequestError=class extends Error{},r.teenyRequest=l,l.defaults=e=>(t,r)=>{let a={...e,...t};if(void 0===r)return l(a);l(a,r)},l.stats=new o.TeenyStatistics,l.resetStats=()=>{l.stats=new o.TeenyStatistics(l.stats.getOptions())}},89228,e=>{e.v({name:"@google-cloud/storage",description:"Cloud Storage Client Library for Node.js",version:"7.18.0",license:"Apache-2.0",author:"Google Inc.",engines:{node:">=14"},repository:"googleapis/nodejs-storage",main:"./build/cjs/src/index.js",types:"./build/cjs/src/index.d.ts",type:"module",exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},files:["build/cjs/src","build/cjs/package.json","!build/cjs/src/**/*.map","build/esm/src","!build/esm/src/**/*.map"],keywords:["google apis client","google api client","google apis","google api","google","google cloud platform","google cloud","cloud","google storage","storage"],scripts:{"all-test":"npm test && npm run system-test && npm run samples-test",benchwrapper:"node bin/benchwrapper.js",check:"gts check",clean:"rm -rf build/","compile:cjs":"tsc -p ./tsconfig.cjs.json","compile:esm":"tsc -p .",compile:"npm run compile:cjs && npm run compile:esm","conformance-test":"mocha --parallel build/cjs/conformance-test/ --require build/cjs/conformance-test/globalHooks.js","docs-test":"linkinator docs",docs:"jsdoc -c .jsdoc.json",fix:"gts fix",lint:"gts check",postcompile:"cp ./src/package-json-helper.cjs ./build/cjs/src && cp ./src/package-json-helper.cjs ./build/esm/src","postcompile:cjs":"babel --plugins gapic-tools/build/src/replaceImportMetaUrl,gapic-tools/build/src/toggleESMFlagVariable build/cjs/src/util.js -o build/cjs/src/util.js && cp internal-tooling/helpers/package.cjs.json build/cjs/package.json",precompile:"rm -rf build/","preconformance-test":"npm run compile:cjs -- --sourceMap","predocs-test":"npm run docs",predocs:"npm run compile:cjs -- --sourceMap",prelint:"cd samples; npm link ../; npm install",prepare:"npm run compile","presystem-test:esm":"npm run compile:esm","presystem-test":"npm run compile -- --sourceMap",pretest:"npm run compile -- --sourceMap","samples-test":"npm link && cd samples/ && npm link ../ && npm test && cd ../","system-test:esm":"mocha build/esm/system-test --timeout 600000 --exit","system-test":"mocha build/cjs/system-test --timeout 600000 --exit",test:"c8 mocha build/cjs/test"},dependencies:{"@google-cloud/paginator":"^5.0.0","@google-cloud/projectify":"^4.0.0","@google-cloud/promisify":"<4.1.0","abort-controller":"^3.0.0","async-retry":"^1.3.3",duplexify:"^4.1.3","fast-xml-parser":"^4.4.1",gaxios:"^6.0.2","google-auth-library":"^9.6.3","html-entities":"^2.5.2",mime:"^3.0.0","p-limit":"^3.0.1","retry-request":"^7.0.0","teeny-request":"^9.0.0",uuid:"^8.0.0"},devDependencies:{"@babel/cli":"^7.22.10","@babel/core":"^7.22.11","@google-cloud/pubsub":"^4.0.0","@grpc/grpc-js":"^1.0.3","@grpc/proto-loader":"^0.8.0","@types/async-retry":"^1.4.3","@types/duplexify":"^3.6.4","@types/mime":"^3.0.0","@types/mocha":"^9.1.1","@types/mockery":"^1.4.29","@types/node":"^24.0.0","@types/node-fetch":"^2.1.3","@types/proxyquire":"^1.3.28","@types/request":"^2.48.4","@types/sinon":"^17.0.0","@types/tmp":"0.2.6","@types/uuid":"^8.0.0","@types/yargs":"^17.0.10",c8:"^9.0.0","form-data":"^4.0.4","gapic-tools":"^0.4.0",gts:"^5.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",linkinator:"^3.0.0",mocha:"^9.2.2",mockery:"^2.1.0",nock:"~13.5.0","node-fetch":"^2.6.7","pack-n-play":"^2.0.0",proxyquire:"^2.1.3",sinon:"^18.0.0",nise:"6.0.0","path-to-regexp":"6.3.0",tmp:"^0.2.0",typescript:"^5.1.6",yargs:"^17.3.1"}})},13438,(e,t,r)=>{r.getPackageJSON=function(){return e.r(89228)}},89410,(e,t,r)=>{t.exports=e.r(88947)},51892,(e,t,r)=>{"use strict";function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){var a,i,n;a=e,i=t,n=r[t],(i=s(i))in a?Object.defineProperty(a,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):a[i]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=typeof a)return a;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var n=e.r(874).Buffer,o=e.r(24361).inspect,p=o&&o.custom||"inspect";t.exports=function(){var e;function t(){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");this.head=null,this.tail=null,this.length=0}return e=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return n.alloc(0);for(var t,r,a=n.allocUnsafe(e>>>0),i=this.head,s=0;i;)t=i.data,r=s,n.prototype.copy.call(t,a,r),s+=i.data.length,i=i.next;return a}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,a=t.data;for(e-=a.length;t=t.next;){var i=t.data,s=e>i.length?i.length:e;if(s===i.length?a+=i:a+=i.slice(0,e),0==(e-=s)){s===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(s));break}++r}return this.length-=r,a}},{key:"_getBuffer",value:function(e){var t=n.allocUnsafe(e),r=this.head,a=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,s=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,s),0==(e-=s)){s===i.length?(++a,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(s));break}++a}return this.length-=a,t}},{key:p,value:function(e,t){return o(this,i(i({},t),{},{depth:0,customInspect:!1}))}}],function(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,s(a.key),a)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}()},2500,(e,t,r)=>{"use strict";function a(e,t){s(e,t),i(e)}function i(e){e._writableState&&!e._writableState.emitClose||(!e._readableState||e._readableState.emitClose)&&e.emit("close")}function s(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return n||o?t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(s,this,e)):process.nextTick(s,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?r._writableState?r._writableState.errorEmitted?process.nextTick(i,r):(r._writableState.errorEmitted=!0,process.nextTick(a,r,e)):process.nextTick(a,r,e):t?(process.nextTick(i,r),t(e)):process.nextTick(i,r)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,a=e._writableState;r&&r.autoDestroy||a&&a.autoDestroy?e.destroy(t):e.emit("error",t)}}},52203,(e,t,r)=>{"use strict";let a={};function i(e,t,r){r||(r=Error);class i extends r{constructor(e,r,a){super("string"==typeof t?t:t(e,r,a))}}i.prototype.name=r.name,i.prototype.code=e,a[e]=i}function s(e,t){if(!Array.isArray(e))return`of ${t} ${String(e)}`;{let r=e.length;return(e=e.map(e=>String(e)),r>2)?`one of ${t} ${e.slice(0,r-1).join(", ")}, or `+e[r-1]:2===r?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}}i("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(e,t,r){var a,i,n,o;let p,d;if("string"==typeof t&&(a="not ",t.substr(0,a.length)===a)?(p="must not be",t=t.replace(/^not /,"")):p="must be",i=" argument",(void 0===n||n>e.length)&&(n=e.length),e.substring(n-i.length,n)===i)d=`The ${e} ${p} ${s(t,"type")}`;else{let r=("number"!=typeof o&&(o=0),o+1>e.length||-1===e.indexOf(".",o))?"argument":"property";d=`The "${e}" ${r} ${p} ${s(t,"type")}`}return d+`. Received type ${typeof r}`},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=a},24813,(e,t,r)=>{"use strict";var a=e.r(52203).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,r,i){var s=null!=t.highWaterMark?t.highWaterMark:i?t[r]:null;if(null!=s){if(!(isFinite(s)&&Math.floor(s)===s)||s<0)throw new a(i?r:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}}},64639,(e,t,r)=>{"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},48807,(e,t,r)=>{try{var a=e.r(24361);if("function"!=typeof a.inherits)throw"";t.exports=a.inherits}catch(r){t.exports=e.r(64639)}},71177,(e,t,r)=>{t.exports=e.r(24361).deprecate},27518,(e,t,r)=>{"use strict";function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){var r=t,a=e,i=r.entry;for(r.entry=null;i;){var s=i.callback;a.pendingcb--,s(void 0),i=i.next}a.corkedRequestsFree.next=r}}t.exports=T,T.WritableState=N;var i,s,n={deprecate:e.r(71177)},o=e.r(89410),p=e.r(874).Buffer,d=e.g.Uint8Array||function(){},l=e.r(2500),c=e.r(24813).getHighWaterMark,u=e.r(52203).codes,h=u.ERR_INVALID_ARG_TYPE,m=u.ERR_METHOD_NOT_IMPLEMENTED,f=u.ERR_MULTIPLE_CALLBACK,g=u.ERR_STREAM_CANNOT_PIPE,v=u.ERR_STREAM_DESTROYED,y=u.ERR_STREAM_NULL_VALUES,w=u.ERR_STREAM_WRITE_AFTER_END,b=u.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function x(){}function N(t,r,s){i=i||e.r(91566),t=t||{},"boolean"!=typeof s&&(s=r instanceof i),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=c(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=!1===t.decodeStrings;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,a=r.sync,i=r.writecb;if("function"!=typeof i)throw new f;if(r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,t)--r.pendingcb,a?(process.nextTick(i,t),process.nextTick(C,e,r),e._writableState.errorEmitted=!0,_(e,t)):(i(t),e._writableState.errorEmitted=!0,_(e,t),C(e,r));else{var s=k(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||S(e,r),a?process.nextTick(A,e,r,s,i):A(e,r,s,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}e.r(48807)(T,o),N.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t};try{Object.defineProperty(N.prototype,"buffer",{get:n.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}function T(t){var r=this instanceof(i=i||e.r(91566));if(!r&&!s.call(T,this))return new T(t);this._writableState=new N(t,this,r),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),o.call(this)}function E(e,t,r,a,i,s,n){t.writelen=a,t.writecb=n,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new v("write")):r?e._writev(i,t.onwrite):e._write(i,s,t.onwrite),t.sync=!1}function A(e,t,r,a){var i,s;r||(i=e,0===(s=t).length&&s.needDrain&&(s.needDrain=!1,i.emit("drain"))),t.pendingcb--,a(),C(e,t)}function S(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=Array(t.bufferedRequestCount),s=t.corkedRequestsFree;s.entry=r;for(var n=0,o=!0;r;)i[n]=r,r.isBuf||(o=!1),r=r.next,n+=1;i.allBuffers=o,E(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;r;){var p=r.chunk,d=r.encoding,l=r.callback,c=t.objectMode?1:p.length;if(E(e,t,!1,c,p,d,l),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function k(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function O(e,t){e._final(function(r){t.pendingcb--,r&&_(e,r),t.prefinished=!0,e.emit("prefinish"),C(e,t)})}function C(e,t){var r=k(t);if(r&&(t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,process.nextTick(O,e,t))),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var a=e._readableState;(!a||a.autoDestroy&&a.endEmitted)&&e.destroy()}return r}"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!s.call(this,e)||this===T&&e&&e._writableState instanceof N}})):s=function(e){return e instanceof this},T.prototype.pipe=function(){_(this,new g)},T.prototype.write=function(e,t,r){var a,i,s,n,o,l,c,u=this._writableState,m=!1,f=!u.objectMode&&(a=e,p.isBuffer(a)||a instanceof d);return(f&&!p.isBuffer(e)&&(i=e,e=p.from(i)),"function"==typeof t&&(r=t,t=null),f?t="buffer":t||(t=u.defaultEncoding),"function"!=typeof r&&(r=x),u.ending)?(s=r,_(this,n=new w),process.nextTick(s,n)):(f||(o=e,l=r,null===o?c=new y:"string"==typeof o||u.objectMode||(c=new h("chunk",["string","Buffer"],o)),!c||(_(this,c),process.nextTick(l,c),0)))&&(u.pendingcb++,m=function(e,t,r,a,i,s){if(!r){var n,o,d=(n=a,o=i,t.objectMode||!1===t.decodeStrings||"string"!=typeof n||(n=p.from(n,o)),n);a!==d&&(r=!0,i="buffer",a=d)}var l=t.objectMode?1:a.length;t.length+=l;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:a,encoding:i,isBuf:r,callback:s,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else E(e,t,!1,l,a,i,s);return c}(this,u,f,e,t,r)),m},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||S(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new b(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,r){r(new m("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,r){var a,i,s,n=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||(a=this,i=n,s=r,i.ending=!0,C(a,i),s&&(i.finished?process.nextTick(s):a.once("finish",s)),i.ended=!0,a.writable=!1),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(e,t){t(e)}},91566,(e,t,r)=>{"use strict";var a=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=d;var i=e.r(99070),s=e.r(27518);e.r(48807)(d,i);for(var n=a(s.prototype),o=0;o<n.length;o++){var p=n[o];d.prototype[p]||(d.prototype[p]=s.prototype[p])}function d(e){if(!(this instanceof d))return new d(e);i.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||process.nextTick(c,this)}function c(e){e.end()}Object.defineProperty(d.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(d.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(d.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(d.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})},87773,(e,t,r)=>{"use strict";var a=e.r(89915).Buffer,i=a.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){var t;if(!e)return"utf8";for(;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(a.isEncoding===i||!i(e)))throw Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=p,this.end=d,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=l,this.end=c,t=3;break;default:this.write=u,this.end=h;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=a.allocUnsafe(t)}function n(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if((192&t[0])!=128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((192&t[1])!=128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(192&t[2])!=128)return e.lastNeed=2,"�"}}(this,e,0);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length)}function p(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var a=r.charCodeAt(r.length-1);if(a>=55296&&a<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function d(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function u(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}r.StringDecoder=s,s.prototype.write=function(e){var t,r;if(0===e.length)return"";if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},s.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},s.prototype.text=function(e,t){var r=function(e,t,r){var a=t.length-1;if(a<r)return 0;var i=n(t[a]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--a<r||-2===i?0:(i=n(t[a]))>=0?(i>0&&(e.lastNeed=i-2),i):--a<r||-2===i?0:(i=n(t[a]))>=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var a=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,a),e.toString("utf8",t,a)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},63102,(e,t,r)=>{"use strict";var a=e.r(52203).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function e(t,r,s){if("function"==typeof r)return e(t,null,r);r||(r={}),n=s||i,o=!1,s=function(){if(!o){o=!0;for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];n.apply(this,t)}};var n,o,p=r.readable||!1!==r.readable&&t.readable,d=r.writable||!1!==r.writable&&t.writable,l=function(){t.writable||u()},c=t._writableState&&t._writableState.finished,u=function(){d=!1,c=!0,p||s.call(t)},h=t._readableState&&t._readableState.endEmitted,m=function(){p=!1,h=!0,d||s.call(t)},f=function(e){s.call(t,e)},g=function(){var e;return p&&!h?(t._readableState&&t._readableState.ended||(e=new a),s.call(t,e)):d&&!c?(t._writableState&&t._writableState.ended||(e=new a),s.call(t,e)):void 0},v=function(){t.req.on("finish",u)};return t.setHeader&&"function"==typeof t.abort?(t.on("complete",u),t.on("abort",g),t.req?v():t.on("request",v)):d&&!t._writableState&&(t.on("end",l),t.on("close",l)),t.on("end",m),t.on("finish",u),!1!==r.error&&t.on("error",f),t.on("close",g),function(){t.removeListener("complete",u),t.removeListener("abort",g),t.removeListener("request",v),t.req&&t.req.removeListener("finish",u),t.removeListener("end",l),t.removeListener("close",l),t.removeListener("finish",u),t.removeListener("end",m),t.removeListener("error",f),t.removeListener("close",g)}}},65941,(e,t,r)=>{"use strict";function a(e,t,r){var a;return(t="symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=typeof a)return a;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?a:String(a))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i,s=e.r(63102),n=Symbol("lastResolve"),o=Symbol("lastReject"),p=Symbol("error"),d=Symbol("ended"),l=Symbol("lastPromise"),c=Symbol("handlePromise"),u=Symbol("stream");function h(e,t){return{value:e,done:t}}function m(e){var t=e[n];if(null!==t){var r=e[u].read();null!==r&&(e[l]=null,e[n]=null,e[o]=null,t(h(r,!1)))}}function f(e){process.nextTick(m,e)}var g=Object.getPrototypeOf(function(){}),v=Object.setPrototypeOf((a(i={get stream(){return this[u]},next:function(){var e,t,r=this,a=this[p];if(null!==a)return Promise.reject(a);if(this[d])return Promise.resolve(h(void 0,!0));if(this[u].destroyed)return new Promise(function(e,t){process.nextTick(function(){r[p]?t(r[p]):e(h(void 0,!0))})});var i=this[l];if(i)t=new Promise((e=this,function(t,r){i.then(function(){e[d]?t(h(void 0,!0)):e[c](t,r)},r)}));else{var s=this[u].read();if(null!==s)return Promise.resolve(h(s,!1));t=new Promise(this[c])}return this[l]=t,t}},Symbol.asyncIterator,function(){return this}),a(i,"return",function(){var e=this;return new Promise(function(t,r){e[u].destroy(null,function(e){e?r(e):t(h(void 0,!0))})})}),i),g);t.exports=function(e){var t,r=Object.create(v,(a(t={},u,{value:e,writable:!0}),a(t,n,{value:null,writable:!0}),a(t,o,{value:null,writable:!0}),a(t,p,{value:null,writable:!0}),a(t,d,{value:e._readableState.endEmitted,writable:!0}),a(t,c,{value:function(e,t){var a=r[u].read();a?(r[l]=null,r[n]=null,r[o]=null,e(h(a,!1))):(r[n]=e,r[o]=t)},writable:!0}),t));return r[l]=null,s(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[o];null!==t&&(r[l]=null,r[n]=null,r[o]=null,t(e)),r[p]=e;return}var a=r[n];null!==a&&(r[l]=null,r[n]=null,r[o]=null,a(h(void 0,!0))),r[d]=!0}),e.on("readable",f.bind(null,r)),r}},74963,(e,t,r)=>{"use strict";function a(e,t,r,a,i,s,n){try{var o=e[s](n),p=o.value}catch(e){r(e);return}o.done?t(p):Promise.resolve(p).then(a,i)}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}var s=e.r(52203).codes.ERR_INVALID_ARG_TYPE;t.exports=function(e,t,r){if(t&&"function"==typeof t.next)n=t;else if(t&&t[Symbol.asyncIterator])n=t[Symbol.asyncIterator]();else if(t&&t[Symbol.iterator])n=t[Symbol.iterator]();else throw new s("iterable",["Iterable"],t);var n,o=new e(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach(function(t){var a,i,s;a=e,i=t,s=r[t],(i=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=typeof a)return a;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(i))in a?Object.defineProperty(a,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[i]=s}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({objectMode:!0},r)),p=!1;function d(){return l.apply(this,arguments)}function l(){var e;return e=function*(){try{var e=yield n.next(),t=e.value;e.done?o.push(null):o.push((yield t))?d():p=!1}catch(e){o.destroy(e)}},(l=function(){var t=this,r=arguments;return new Promise(function(i,s){var n=e.apply(t,r);function o(e){a(n,i,s,o,p,"next",e)}function p(e){a(n,i,s,o,p,"throw",e)}o(void 0)})}).apply(this,arguments)}return o._read=function(){p||(p=!0,d())},o}},99070,(e,t,r)=>{"use strict";t.exports=T,T.ReadableState=N,e.r(27699).EventEmitter;var a,i,s,n,o,p=function(e,t){return e.listeners(t).length},d=e.r(89410),l=e.r(874).Buffer,c=e.g.Uint8Array||function(){},u=e.r(24361);i=u&&u.debuglog?u.debuglog("stream"):function(){};var h=e.r(51892),m=e.r(2500),f=e.r(24813).getHighWaterMark,g=e.r(52203).codes,v=g.ERR_INVALID_ARG_TYPE,y=g.ERR_STREAM_PUSH_AFTER_EOF,w=g.ERR_METHOD_NOT_IMPLEMENTED,b=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e.r(48807)(T,d);var _=m.errorOrDestroy,x=["error","close","destroy","pause","resume"];function N(t,r,i){a=a||e.r(91566),t=t||{},"boolean"!=typeof i&&(i=r instanceof a),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=f(this,t,"readableHighWaterMark",i),this.buffer=new h,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(s||(s=e.f({string_decoder:{id:()=>87773,module:()=>e.r(87773)},"string_decoder/":{id:()=>87773,module:()=>e.r(87773)}})("string_decoder/").StringDecoder),this.decoder=new s(t.encoding),this.encoding=t.encoding)}function T(t){if(a=a||e.r(91566),!(this instanceof T))return new T(t);var r=this instanceof a;this._readableState=new N(t,this,r),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),d.call(this)}function E(e,t,r,a,s){i("readableAddChunk",t);var n,o,p=e._readableState;if(null===t)p.reading=!1,function(e,t){if(i("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?k(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,O(e)))}}(e,p);else if(s||(o=function(e,t){var r;return l.isBuffer(t)||t instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],t)),r}(p,t)),o)_(e,o);else if(p.objectMode||t&&t.length>0)if("string"==typeof t||p.objectMode||Object.getPrototypeOf(t)===l.prototype||(n=t,t=l.from(n)),a)p.endEmitted?_(e,new b):A(e,p,t,!0);else if(p.ended)_(e,new y);else{if(p.destroyed)return!1;p.reading=!1,p.decoder&&!r?(t=p.decoder.write(t),p.objectMode||0!==t.length?A(e,p,t,!1):C(e,p)):A(e,p,t,!1)}else a||(p.reading=!1,C(e,p));return!p.ended&&(p.length<p.highWaterMark||0===p.length)}function A(e,t,r,a){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,a?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&k(e)),C(e,t)}function S(e,t){var r;if(e<=0||0===t.length&&t.ended)return 0;if(t.objectMode)return 1;if(e!=e)if(t.flowing&&t.length)return t.buffer.head.data.length;else return t.length;return(e>t.highWaterMark&&((r=e)>=0x40000000?r=0x40000000:(r--,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r++),t.highWaterMark=r),e<=t.length)?e:t.ended?t.length:(t.needReadable=!0,0)}function k(e){var t=e._readableState;i("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(i("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(O,e))}function O(e){var t=e._readableState;i("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,j(e)}function C(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(I,e,t))}function I(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(i("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function R(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function D(e){i("readable nexttick read 0"),e.read(0)}function P(e,t){i("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),j(e),t.flowing&&!t.reading&&e.read(0)}function j(e){var t=e._readableState;for(i("flow",t.flowing);t.flowing&&null!==e.read(););}function q(e,t){var r;return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r)}function L(e){var t=e._readableState;i("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(M,t,e))}function M(e,t){if(i("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function F(e,t){for(var r=0,a=e.length;r<a;r++)if(e[r]===t)return r;return -1}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),T.prototype.destroy=m.destroy,T.prototype._undestroy=m.undestroy,T.prototype._destroy=function(e,t){t(e)},T.prototype.push=function(e,t){var r,a=this._readableState;return a.objectMode?r=!0:"string"==typeof e&&((t=t||a.defaultEncoding)!==a.encoding&&(e=l.from(e,t),t=""),r=!0),E(this,e,t,!1,r)},T.prototype.unshift=function(e){return E(this,e,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(t){s||(s=e.f({string_decoder:{id:()=>87773,module:()=>e.r(87773)},"string_decoder/":{id:()=>87773,module:()=>e.r(87773)}})("string_decoder/").StringDecoder);var r=new s(t);this._readableState.decoder=r,this._readableState.encoding=this._readableState.decoder.encoding;for(var a=this._readableState.buffer.head,i="";null!==a;)i+=r.write(a.data),a=a.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this},T.prototype.read=function(e){i("read",e),e=parseInt(e,10);var t,r=this._readableState,a=e;if(0!==e&&(r.emittedReadable=!1),0===e&&r.needReadable&&((0!==r.highWaterMark?r.length>=r.highWaterMark:r.length>0)||r.ended))return i("read: emitReadable",r.length,r.ended),0===r.length&&r.ended?L(this):k(this),null;if(0===(e=S(e,r))&&r.ended)return 0===r.length&&L(this),null;var s=r.needReadable;return i("need readable",s),(0===r.length||r.length-e<r.highWaterMark)&&i("length less than watermark",s=!0),r.ended||r.reading?i("reading or ended",s=!1):s&&(i("do read"),r.reading=!0,r.sync=!0,0===r.length&&(r.needReadable=!0),this._read(r.highWaterMark),r.sync=!1,r.reading||(e=S(a,r))),null===(t=e>0?q(e,r):null)?(r.needReadable=r.length<=r.highWaterMark,e=0):(r.length-=e,r.awaitDrain=0),0===r.length&&(r.ended||(r.needReadable=!0),a!==e&&r.ended&&L(this)),null!==t&&this.emit("data",t),t},T.prototype._read=function(e){_(this,new w("_read()"))},T.prototype.pipe=function(e,t){var r,a=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e)}s.pipesCount+=1,i("pipe count=%d opts=%j",s.pipesCount,t);var n=t&&!1===t.end||e===process.stdout||e===process.stderr?f:o;function o(){i("onend"),e.end()}s.endEmitted?process.nextTick(n):a.once("end",n),e.on("unpipe",function t(r,n){i("onunpipe"),r===a&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,i("cleanup"),e.removeListener("close",h),e.removeListener("finish",m),e.removeListener("drain",d),e.removeListener("error",u),e.removeListener("unpipe",t),a.removeListener("end",o),a.removeListener("end",f),a.removeListener("data",c),l=!0,s.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&d())});var d=(r=a,function(){var e=r._readableState;i("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&p(r,"data")&&(e.flowing=!0,j(r))});e.on("drain",d);var l=!1;function c(t){i("ondata");var r=e.write(t);i("dest.write",r),!1===r&&((1===s.pipesCount&&s.pipes===e||s.pipesCount>1&&-1!==F(s.pipes,e))&&!l&&(i("false write response, pause",s.awaitDrain),s.awaitDrain++),a.pause())}function u(t){i("onerror",t),f(),e.removeListener("error",u),0===p(e,"error")&&_(e,t)}function h(){e.removeListener("finish",m),f()}function m(){i("onfinish"),e.removeListener("close",h),f()}function f(){i("unpipe"),a.unpipe(e)}return a.on("data",c),!function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",u),e.once("close",h),e.once("finish",m),e.emit("pipe",a),s.flowing||(i("pipe resume"),a.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var a=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s<i;s++)a[s].emit("unpipe",this,{hasUnpiped:!1});return this}var n=F(t.pipes,e);return -1===n||(t.pipes.splice(n,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},T.prototype.on=function(e,t){var r=d.prototype.on.call(this,e,t),a=this._readableState;return"data"===e?(a.readableListening=this.listenerCount("readable")>0,!1!==a.flowing&&this.resume()):"readable"!==e||a.endEmitted||a.readableListening||(a.readableListening=a.needReadable=!0,a.flowing=!1,a.emittedReadable=!1,i("on readable",a.length,a.reading),a.length?k(this):a.reading||process.nextTick(D,this)),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var r=d.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(R,this),r},T.prototype.removeAllListeners=function(e){var t=d.prototype.removeAllListeners.apply(this,arguments);return("readable"===e||void 0===e)&&process.nextTick(R,this),t},T.prototype.resume=function(){var e,t,r=this._readableState;return r.flowing||(i("resume"),r.flowing=!r.readableListening,e=this,(t=r).resumeScheduled||(t.resumeScheduled=!0,process.nextTick(P,e,t))),r.paused=!1,this},T.prototype.pause=function(){return i("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(i("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,r=this._readableState,a=!1;for(var s in e.on("end",function(){if(i("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(s){i("wrapped data"),r.decoder&&(s=r.decoder.write(s)),r.objectMode&&null==s||(r.objectMode||s&&s.length)&&(t.push(s)||(a=!0,e.pause()))}),e)void 0===this[s]&&"function"==typeof e[s]&&(this[s]=function(t){return function(){return e[t].apply(e,arguments)}}(s));for(var n=0;n<x.length;n++)e.on(x[n],this.emit.bind(this,x[n]));return this._read=function(t){i("wrapped _read",t),a&&(a=!1,e.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===n&&(n=e.r(65941)),n(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),T._fromList=q,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(t,r){return void 0===o&&(o=e.r(74963)),o(T,t,r)})},28,(e,t,r)=>{"use strict";t.exports=l;var a=e.r(52203).codes,i=a.ERR_METHOD_NOT_IMPLEMENTED,s=a.ERR_MULTIPLE_CALLBACK,n=a.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=a.ERR_TRANSFORM_WITH_LENGTH_0,p=e.r(91566);function d(e,t){var r=this._transformState;r.transforming=!1;var a=r.writecb;if(null===a)return this.emit("error",new s);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),a(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);p.call(this,e),this._transformState={afterTransform:d.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",c)}function c(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?u(this,null,null):this._flush(function(t,r){u(e,t,r)})}function u(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new o;if(e._transformState.transforming)throw new n;return e.push(null)}e.r(48807)(l,p),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,p.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,r){r(new i("_transform()"))},l.prototype._write=function(e,t,r){var a=this._transformState;if(a.writecb=r,a.writechunk=e,a.writeencoding=t,!a.transforming){var i=this._readableState;(a.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){p.prototype._destroy.call(this,e,function(e){t(e)})}},93352,(e,t,r)=>{"use strict";t.exports=i;var a=e.r(28);function i(e){if(!(this instanceof i))return new i(e);a.call(this,e)}e.r(48807)(i,a),i.prototype._transform=function(e,t,r){r(null,e)}},36311,(e,t,r)=>{"use strict";var a,i=e.r(52203).codes,s=i.ERR_MISSING_ARGS,n=i.ERR_STREAM_DESTROYED;function o(e){if(e)throw e}function p(e){e()}function d(e,t){return e.pipe(t)}t.exports=function(){for(var t,r,i=arguments.length,l=Array(i),c=0;c<i;c++)l[c]=arguments[c];var u=(t=l).length&&"function"==typeof t[t.length-1]?t.pop():o;if(Array.isArray(l[0])&&(l=l[0]),l.length<2)throw new s("streams");var h=l.map(function(t,i){var s,o,d,c,m,f,g=i<l.length-1;return s=i>0,d=o=function(e){r||(r=e),e&&h.forEach(p),g||(h.forEach(p),u(r))},c=!1,o=function(){c||(c=!0,d.apply(void 0,arguments))},m=!1,t.on("close",function(){m=!0}),void 0===a&&(a=e.r(63102)),a(t,{readable:g,writable:s},function(e){if(e)return o(e);m=!0,o()}),f=!1,function(e){if(!m&&!f){if(f=!0,t.setHeader&&"function"==typeof t.abort)return t.abort();if("function"==typeof t.destroy)return t.destroy();o(e||new n("pipe"))}}});return l.reduce(d)}},60193,(e,t,r)=>{var a=e.r(88947);"disable"===process.env.READABLE_STREAM&&a?(t.exports=a.Readable,Object.assign(t.exports,a),t.exports.Stream=a):((r=t.exports=e.r(99070)).Stream=a||r,r.Readable=r,r.Writable=e.r(27518),r.Duplex=e.r(91566),r.Transform=e.r(28),r.PassThrough=e.r(93352),r.finished=e.r(63102),r.pipeline=e.r(36311))},28749,(e,t,r)=>{t.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw TypeError("need wrapper function");return Object.keys(t).forEach(function(e){a[e]=t[e]}),a;function a(){for(var e=Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var a=t.apply(this,e),i=e[e.length-1];return"function"==typeof a&&a!==i&&Object.keys(i).forEach(function(e){a[e]=i[e]}),a}}},78569,(e,t,r)=>{var a=e.r(28749);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function s(e){var t=function(){if(t.called)throw Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)};return t.onceError=(e.name||"Function wrapped with `once`")+" shouldn't be called more than once",t.called=!1,t}t.exports=a(i),t.exports.strict=a(s),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return s(this)},configurable:!0})})},23441,(e,t,r)=>{var a=e.r(78569),i=function(){},s=e.g.Bare?queueMicrotask:process.nextTick.bind(process),n=function(e,t,r){if("function"==typeof t)return n(e,null,t);t||(t={}),r=a(r||i);var o=e._writableState,p=e._readableState,d=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,c=!1,u=function(){e.writable||h()},h=function(){l=!1,d||r.call(e)},m=function(){d=!1,l||r.call(e)},f=function(t){r.call(e,t?Error("exited with error code: "+t):null)},g=function(t){r.call(e,t)},v=function(){s(y)},y=function(){if(!c&&(d&&!(p&&p.ended&&!p.destroyed)||l&&!(o&&o.ended&&!o.destroyed)))return r.call(e,Error("premature close"))},w=function(){e.req.on("finish",h)};return e.setHeader&&"function"==typeof e.abort?(e.on("complete",h),e.on("abort",v),e.req?w():e.on("request",w)):l&&!o&&(e.on("end",u),e.on("close",u)),e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length&&e.on("exit",f),e.on("end",m),e.on("finish",h),!1!==t.error&&e.on("error",g),e.on("close",v),function(){c=!0,e.removeListener("complete",h),e.removeListener("abort",v),e.removeListener("request",w),e.req&&e.req.removeListener("finish",h),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",h),e.removeListener("exit",f),e.removeListener("end",m),e.removeListener("error",g),e.removeListener("close",v)}};t.exports=n},37619,(e,t,r)=>{t.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}(t)):null}},48628,(e,t,r)=>{var a=e.r(60193),i=e.r(23441),s=e.r(48807),n=e.r(37619),o=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),p=function(e,t){e._corked?e.once("uncork",t):t()},d=function(e,t){e._autoDestroy&&e.destroy(t)},l=function(e,t){return function(r){r?d(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},c=function(){},u=function(e,t,r){if(!(this instanceof u))return new u(e,t,r);a.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(u,a.Duplex),u.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new u(e,t,r)},u.prototype.cork=function(){1==++this._corked&&this.emit("cork")},u.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},u.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(null===e||!1===e)return void this.end();var t=this,r=i(e,{writable:!0,readable:!1},l(this,this._forwardEnd)),a=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&process.nextTick(a),this._writable=e,this._writable.on("drain",a),this._unwrite=function(){t._writable.removeListener("drain",a),r()},this.uncork()},u.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(null===e||!1===e){this.push(null),this.resume();return}var t=this,r=i(e,{writable:!1,readable:!0},l(this)),s=function(){t._forward()},n=function(){t.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:new a.Readable({objectMode:!0,highWaterMark:16}).wrap(e),this._readable2.on("readable",s),this._readable2.on("end",n),this._unread=function(){t._readable2.removeListener("readable",s),t._readable2.removeListener("end",n),r()},this._forward()},u.prototype._read=function(){this._drained=!0,this._forward()},u.prototype._forward=function(){var e;if(!this._forwarding&&this._readable2&&this._drained){for(this._forwarding=!0;this._drained&&null!==(e=n(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},u.prototype.destroy=function(e,t){if(t||(t=c),this.destroyed)return t(null);this.destroyed=!0;var r=this;process.nextTick(function(){r._destroy(e),t(null)})},u.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},u.prototype._write=function(e,t,r){if(!this.destroyed){if(this._corked)return p(this,this._write.bind(this,e,t,r));if(e===o)return this._finish(r);if(!this._writable)return r();!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()}},u.prototype._finish=function(e){var t=this;this.emit("preend"),p(this,function(){var r,a;r=t._forwardEnd&&t._writable,a=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),p(t,e)},!r||r._writableState&&r._writableState.finished?a():r._writableState?r.end(a):(r.end(),a())})},u.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(o),a.Writable.prototype.end.call(this,r))},t.exports=u},6460,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.callbackifyAll=r.callbackify=r.promisifyAll=r.promisify=void 0,r.promisify=function(e,t){if(e.promisified_)return e;t=t||{};let r=Array.prototype.slice,a=function(){let a;for(a=arguments.length-1;a>=0;a--){let t=arguments[a];if(void 0!==t){if("function"!=typeof t)break;return e.apply(this,arguments)}}let i=r.call(arguments,0,a+1),s=Promise;return this&&this.Promise&&(s=this.Promise),new s((a,s)=>{i.push((...e)=>{let i=r.call(e),n=i.shift();if(n)return s(n);t.singular&&1===i.length?a(i[0]):a(i)}),e.apply(this,i)})};return a.promisified_=!0,a},r.promisifyAll=function(e,t){let a=t&&t.exclude||[];Object.getOwnPropertyNames(e.prototype).filter(t=>!a.includes(t)&&"function"==typeof e.prototype[t]&&!/(^_|(Stream|_)|promise$)|^constructor$/.test(t)).forEach(a=>{let i=e.prototype[a];i.promisified_||(e.prototype[a]=r.promisify(i,t))})},r.callbackify=function(e){if(e.callbackified_)return e;let t=function(){if("function"!=typeof arguments[arguments.length-1])return e.apply(this,arguments);let t=Array.prototype.pop.call(arguments);e.apply(this,arguments).then(e=>{t(null,...e=Array.isArray(e)?e:[e])},e=>t(e))};return t.callbackified_=!0,t},r.callbackifyAll=function(e,t){let a=t&&t.exclude||[];Object.getOwnPropertyNames(e.prototype).filter(t=>!a.includes(t)&&"function"==typeof e.prototype[t]&&!/^_|(Stream|_)|^constructor$/.test(t)).forEach(t=>{let a=e.prototype[t];a.callbackified_||(e.prototype[t]=r.callbackify(a))})}},79384,(e,t,r)=>{"use strict";t.exports=e=>null==e?[]:Array.isArray(e)?e:"string"==typeof e?[e]:"function"==typeof e[Symbol.iterator]?[...e]:[e]},70878,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ResourceStream=void 0;let a=e.r(88947);class i extends a.Transform{constructor(e,t){super(Object.assign({objectMode:!0},e.streamOptions)),this._ended=!1,this._maxApiCalls=-1===e.maxApiCalls?1/0:e.maxApiCalls,this._nextQuery=e.query,this._reading=!1,this._requestFn=t,this._requestsMade=0,this._resultsToSend=-1===e.maxResults?1/0:e.maxResults,this._otherArgs=[]}end(...e){return this._ended=!0,super.end(...e)}_read(){if(!this._reading){this._reading=!0;try{this._requestFn(this._nextQuery,(e,t,r,...a)=>{if(e)return void this.destroy(e);this._otherArgs=a,this._nextQuery=r,this._resultsToSend!==1/0&&(t=t.splice(0,this._resultsToSend),this._resultsToSend-=t.length);let i=!0;for(let e of t){if(this._ended)break;i=this.push(e)}let s=!this._nextQuery||this._resultsToSend<1,n=++this._requestsMade>=this._maxApiCalls;(s||n)&&this.end(),i&&!this._ended&&setImmediate(()=>this._read()),this._reading=!1})}catch(e){this.destroy(e)}}}}r.ResourceStream=i},28070,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ResourceStream=r.paginator=r.Paginator=void 0;let a=e.r(79384),i=e.r(64105),s=e.r(70878);Object.defineProperty(r,"ResourceStream",{enumerable:!0,get:function(){return s.ResourceStream}});class n{extend(e,t){(t=a(t)).forEach(t=>{let r=e.prototype[t];e.prototype[t+"_"]=r,e.prototype[t]=function(...e){let t=o.parseArguments_(e);return o.run_(t,r.bind(this))}})}streamify(e){return function(...t){let r=o.parseArguments_(t),a=this[e+"_"]||this[e];return o.runAsStream_(r,a.bind(this))}}parseArguments_(e){let t,r,a=!0,s=-1,n=-1,o=e[0],p=e[e.length-1];"function"==typeof o?r=o:t=o,"function"==typeof p&&(r=p),"object"==typeof t&&((t=i(!0,{},t)).maxResults&&"number"==typeof t.maxResults?n=t.maxResults:"number"==typeof t.pageSize&&(n=t.pageSize),t.maxApiCalls&&"number"==typeof t.maxApiCalls&&(s=t.maxApiCalls,delete t.maxApiCalls),(-1!==n||!1===t.autoPaginate)&&(a=!1));let d={query:t||{},autoPaginate:a,maxApiCalls:s,maxResults:n,callback:r};return d.streamOptions=i(!0,{},d.query),delete d.streamOptions.autoPaginate,delete d.streamOptions.maxResults,delete d.streamOptions.pageSize,d}run_(e,t){let r=e.query,a=e.callback;if(!e.autoPaginate)return t(r,a);let i=[],s=[],n=new Promise((r,a)=>{let n=o.runAsStream_(e,t);n.on("error",a).on("data",e=>i.push(e)).on("end",()=>{s=n._otherArgs||[],r(i)})});if(!a)return n.then(e=>[e,r,...s]);n.then(e=>a(null,e,r,...s),e=>a(e))}runAsStream_(e,t){return new s.ResourceStream(e,t)}}r.Paginator=n;let o=new n;r.paginator=o},7063,(e,t,r)=>{"use strict";function a(){this._types=Object.create(null),this._extensions=Object.create(null);for(let e=0;e<arguments.length;e++)this.define(arguments[e]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}a.prototype.define=function(e,t){for(let r in e){let a=e[r].map(function(e){return e.toLowerCase()});r=r.toLowerCase();for(let e=0;e<a.length;e++){let i=a[e];if("*"!==i[0]){if(!t&&i in this._types)throw Error('Attempt to change mapping for "'+i+'" extension from "'+this._types[i]+'" to "'+r+'". Pass `force=true` to allow this, otherwise remove "'+i+'" from the list of extensions for "'+r+'".');this._types[i]=r}}if(t||!this._extensions[r]){let e=a[0];this._extensions[r]="*"!==e[0]?e:e.substr(1)}}},a.prototype.getType=function(e){let t=(e=String(e)).replace(/^.*[/\\]/,"").toLowerCase(),r=t.replace(/^.*\./,"").toLowerCase(),a=t.length<e.length;return(r.length<t.length-1||!a)&&this._types[r]||null},a.prototype.getExtension=function(e){return(e=/^\s*([^;\s]*)/.test(e)&&RegExp.$1)&&this._extensions[e.toLowerCase()]||null},t.exports=a},28987,(e,t,r)=>{t.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}},45905,(e,t,r)=>{t.exports={"application/prs.cww":["cww"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mapbox-vector-tile":["mvt"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-iwork-keynote-sffkey":["*key"],"application/x-iwork-numbers-sffnumbers":["*numbers"],"application/x-iwork-pages-sffpages":["*pages"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.sap.vds":["vds"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},51452,(e,t,r)=>{"use strict";t.exports=new(e.r(7063))(e.r(28987),e.r(45905))},25569,(e,t,r)=>{class a{constructor(e){this.value=e,this.next=void 0}}class i{constructor(){this.clear()}enqueue(e){let t=new a(e);this._head?this._tail.next=t:this._head=t,this._tail=t,this._size++}dequeue(){let e=this._head;if(e)return this._head=this._head.next,this._size--,e.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let e=this._head;for(;e;)yield e.value,e=e.next}}t.exports=i},57427,(e,t,r)=>{"use strict";let a=e.r(25569);t.exports=e=>{if(!((Number.isInteger(e)||e===1/0)&&e>0))throw TypeError("Expected `concurrency` to be a number from 1 and up");let t=new a,r=0,i=async(e,a,...i)=>{r++;let s=(async()=>e(...i))();a(s);try{await s}catch{}r--,t.size>0&&t.dequeue()()},s=(a,...s)=>new Promise(n=>{((a,s,...n)=>{t.enqueue(i.bind(null,a,s,...n)),(async()=>{await Promise.resolve(),r<e&&t.size>0&&t.dequeue()()})()})(a,n,...s)});return Object.defineProperties(s,{activeCount:{get:()=>r},pendingCount:{get:()=>t.size},clearQueue:{value:()=>{t.clear()}}}),s}},30741,(e,t,r)=>{function a(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=a,a.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},a.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},a.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(void 0===r)if(!this._cachedTimeouts)return!1;else this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);var a=this;return this._timer=setTimeout(function(){a._attempts++,a._operationTimeoutCb&&(a._timeout=setTimeout(function(){a._operationTimeoutCb(a._attempts)},a._operationTimeout),a._options.unref&&a._timeout.unref()),a._fn(a._attempts)},r),this._options.unref&&this._timer.unref(),!0},a.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},a.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},a.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},a.prototype.start=a.prototype.try,a.prototype.errors=function(){return this._errors},a.prototype.attempts=function(){return this._attempts},a.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,r=0,a=0;a<this._errors.length;a++){var i=this._errors[a],s=i.message,n=(e[s]||0)+1;e[s]=n,n>=r&&(t=i,r=n)}return t}},46831,(e,t,r)=>{var a=e.r(30741);r.operation=function(e){return new a(r.timeouts(e),{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})},r.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");for(var a=[],i=0;i<t.retries;i++)a.push(this.createTimeout(i,t));return e&&e.forever&&!a.length&&a.push(this.createTimeout(i,t)),a.sort(function(e,t){return e-t}),a},r.createTimeout=function(e,t){var r=Math.round((t.randomize?Math.random()+1:1)*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return Math.min(r,t.maxTimeout)},r.wrap=function(e,t,a){if(t instanceof Array&&(a=t,t=null),!a)for(var i in a=[],e)"function"==typeof e[i]&&a.push(i);for(var s=0;s<a.length;s++){var n=a[s],o=e[n];e[n]=(function(a){var i=r.operation(t),s=Array.prototype.slice.call(arguments,1),n=s.pop();s.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),n.apply(this,arguments))}),i.attempt(function(){a.apply(e,s)})}).bind(e,o),e[n].options=t}}},3729,(e,t,r)=>{t.exports=e.r(46831)},77441,(e,t,r)=>{var a=e.r(3729);t.exports=function(e,t){return new Promise(function(r,i){var s,n=t||{};function o(e){i(e||Error("Aborted"))}function p(e,t){e.bail?o(e):s.retry(e)?n.onRetry&&n.onRetry(e,t):i(s.mainError())}"randomize"in n||(n.randomize=!0),(s=a.operation(n)).attempt(function(t){var a;try{a=e(o,t)}catch(e){p(e,t);return}Promise.resolve(a).then(r).catch(function(e){p(e,t)})})})}},92294,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});let a=new WeakMap,i=new WeakMap;function s(e){let t=a.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function n(e){if(null!=e.passiveListener){"undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",e.passiveListener);return}e.event.cancelable&&(e.canceled=!0,"function"==typeof e.event.preventDefault&&e.event.preventDefault())}function o(e,t){a.set(this,{eventTarget:e,event:t,eventPhase:2,currentTarget:e,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:t.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=Object.keys(t);for(let e=0;e<r.length;++e){let t=r[e];t in this||Object.defineProperty(this,t,p(t))}}function p(e){return{get(){return s(this).event[e]},set(t){s(this).event[e]=t},configurable:!0,enumerable:!0}}function d(e,t){s(e).passiveListener=t}o.prototype={get type(){return s(this).event.type},get target(){return s(this).eventTarget},get currentTarget(){return s(this).currentTarget},composedPath(){let e=s(this).currentTarget;return null==e?[]:[e]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return s(this).eventPhase},stopPropagation(){let e=s(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation(){let e=s(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return!!s(this).event.bubbles},get cancelable(){return!!s(this).event.cancelable},preventDefault(){n(s(this))},get defaultPrevented(){return s(this).canceled},get composed(){return!!s(this).event.composed},get timeStamp(){return s(this).timeStamp},get srcElement(){return s(this).eventTarget},get cancelBubble(){return s(this).stopped},set cancelBubble(value){if(!value)return;let e=s(this);e.stopped=!0,"boolean"==typeof e.event.cancelBubble&&(e.event.cancelBubble=!0)},get returnValue(){return!s(this).canceled},set returnValue(value){value||n(s(this))},initEvent(){}},Object.defineProperty(o.prototype,"constructor",{value:o,configurable:!0,writable:!0});let l=new WeakMap;function c(e){return null!==e&&"object"==typeof e}function u(e){let t=l.get(e);if(null==t)throw TypeError("'this' is expected an EventTarget object, but got another value.");return t}function h(e,t){Object.defineProperty(e,`on${t}`,{get(){let e=u(this).get(t);for(;null!=e;){if(3===e.listenerType)return e.listener;e=e.next}return null},set(e){"function"==typeof e||c(e)||(e=null);let r=u(this),a=null,i=r.get(t);for(;null!=i;)3===i.listenerType?null!==a?a.next=i.next:null!==i.next?r.set(t,i.next):r.delete(t):a=i,i=i.next;if(null!==e){let i={listener:e,listenerType:3,passive:!1,once:!1,next:null};null===a?r.set(t,i):a.next=i}},configurable:!0,enumerable:!0})}function m(e){function t(){f.call(this)}t.prototype=Object.create(f.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let r=0;r<e.length;++r)h(t.prototype,e[r]);return t}function f(){if(this instanceof f)return void l.set(this,new Map);if(1==arguments.length&&Array.isArray(arguments[0]))return m(arguments[0]);if(arguments.length>0){let e=Array(arguments.length);for(let t=0;t<arguments.length;++t)e[t]=arguments[t];return m(e)}throw TypeError("Cannot call a class as a function")}f.prototype={addEventListener(e,t,r){if(null==t)return;if("function"!=typeof t&&!c(t))throw TypeError("'listener' should be a function or an object.");let a=u(this),i=c(r),s=(i?r.capture:r)?1:2,n={listener:t,listenerType:s,passive:i&&!!r.passive,once:i&&!!r.once,next:null},o=a.get(e);if(void 0===o)return void a.set(e,n);let p=null;for(;null!=o;){if(o.listener===t&&o.listenerType===s)return;p=o,o=o.next}p.next=n},removeEventListener(e,t,r){if(null==t)return;let a=u(this),i=(c(r)?r.capture:r)?1:2,s=null,n=a.get(e);for(;null!=n;){if(n.listener===t&&n.listenerType===i)return void(null!==s?s.next=n.next:null!==n.next?a.set(e,n.next):a.delete(e));s=n,n=n.next}},dispatchEvent(e){if(null==e||"string"!=typeof e.type)throw TypeError('"event.type" should be a string.');let t=u(this),r=e.type,a=t.get(r);if(null==a)return!0;let n=new(function e(t){if(null==t||t===Object.prototype)return o;let r=i.get(t);return null==r&&(r=function(e,t){let r=Object.keys(t);if(0===r.length)return e;function a(t,r){e.call(this,t,r)}a.prototype=Object.create(e.prototype,{constructor:{value:a,configurable:!0,writable:!0}});for(let i=0;i<r.length;++i){let n=r[i];if(!(n in e.prototype)){let e="function"==typeof Object.getOwnPropertyDescriptor(t,n).value;Object.defineProperty(a.prototype,n,e?function(e){return{value(){let t=s(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}(n):p(n))}}return a}(e(Object.getPrototypeOf(t)),t),i.set(t,r)),r}(Object.getPrototypeOf(e)))(this,e),l=null;for(;null!=a;){if(a.once?null!==l?l.next=a.next:null!==a.next?t.set(r,a.next):t.delete(r):l=a,d(n,a.passive?a.listener:null),"function"==typeof a.listener)try{a.listener.call(this,n)}catch(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e)}else 3!==a.listenerType&&"function"==typeof a.listener.handleEvent&&a.listener.handleEvent(n);if(s(n).immediateStopped)break;a=a.next}return d(n,null),s(n).eventPhase=0,s(n).currentTarget=null,!n.defaultPrevented}},Object.defineProperty(f.prototype,"constructor",{value:f,configurable:!0,writable:!0}),r.defineEventAttribute=h,r.EventTarget=f,r.default=f,t.exports=f,t.exports.EventTarget=t.exports.default=f,t.exports.defineEventAttribute=h},87148,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var a=e.r(92294);class AbortSignal extends a.EventTarget{constructor(){throw super(),TypeError("AbortSignal cannot be constructed directly")}get aborted(){let e=i.get(this);if("boolean"!=typeof e)throw TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this===null?"null":typeof this}`);return e}}a.defineEventAttribute(AbortSignal.prototype,"abort");let i=new WeakMap;Object.defineProperties(AbortSignal.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(AbortSignal.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});class s{constructor(){n.set(this,function(){let e=Object.create(AbortSignal.prototype);return a.EventTarget.call(e),i.set(e,!1),e}())}get signal(){return o(this)}abort(){var e;e=o(this),!1===i.get(e)&&(i.set(e,!0),e.dispatchEvent({type:"abort"}))}}let n=new WeakMap;function o(e){let t=n.get(e);if(null==t)throw TypeError(`Expected 'this' to be an 'AbortController' object, but got ${null===e?"null":typeof e}`);return t}Object.defineProperties(s.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(s.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"}),r.AbortController=s,r.AbortSignal=AbortSignal,r.default=s,t.exports=s,t.exports.AbortController=t.exports.default=s,t.exports.AbortSignal=AbortSignal},10476,(e,t,r)=>{"use strict";let a=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",i="["+a+"]["+a+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*",s=RegExp("^"+i+"$");r.isExist=function(e){return void 0!==e},r.isEmptyObject=function(e){return 0===Object.keys(e).length},r.merge=function(e,t,r){if(t){let a=Object.keys(t),i=a.length;for(let s=0;s<i;s++)"strict"===r?e[a[s]]=[t[a[s]]]:e[a[s]]=t[a[s]]}},r.getValue=function(e){return r.isExist(e)?e:""},r.isName=function(e){return null!=s.exec(e)},r.getAllMatches=function(e,t){let r=[],a=t.exec(e);for(;a;){let i=[];i.startIndex=t.lastIndex-a[0].length;let s=a.length;for(let e=0;e<s;e++)i.push(a[e]);r.push(i),a=t.exec(e)}return r},r.nameRegexp=i},48418,(e,t,r)=>{"use strict";let a=e.r(10476),i={allowBooleanAttributes:!1,unpairedTags:[]};function s(e){return" "===e||" "===e||"\n"===e||"\r"===e}function n(e,t){let r=t;for(;t<e.length;t++)if("?"==e[t]||" "==e[t]){let a=e.substr(r,t-r);if(t>5&&"xml"===a)return l("InvalidXml","XML declaration allowed only at the start of the document.",c(e,t));if("?"!=e[t]||">"!=e[t+1])continue;t++;break}return t}function o(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let r=1;for(t+=8;t<e.length;t++)if("<"===e[t])r++;else if(">"===e[t]&&0==--r)break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7]){for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}}return t}r.validate=function(e,t){t=Object.assign({},i,t);let r=[],p=!1,u=!1;"\uFEFF"===e[0]&&(e=e.substr(1));for(let i=0;i<e.length;i++)if("<"===e[i]&&"?"===e[i+1]){if(i+=2,(i=n(e,i)).err)return i}else if("<"===e[i]){let m=i;if("!"===e[++i]){i=o(e,i);continue}{var h;let f=!1;"/"===e[i]&&(f=!0,i++);let g="";for(;i<e.length&&">"!==e[i]&&" "!==e[i]&&" "!==e[i]&&"\n"!==e[i]&&"\r"!==e[i];i++)g+=e[i];if("/"===(g=g.trim())[g.length-1]&&(g=g.substring(0,g.length-1),i--),h=g,!a.isName(h))return l("InvalidTag",0===g.trim().length?"Invalid space after '<'.":"Tag '"+g+"' is an invalid name.",c(e,i));let v=function(e,t){let r="",a="",i=!1;for(;t<e.length;t++){if('"'===e[t]||"'"===e[t])""===a?a=e[t]:a!==e[t]||(a="");else if(">"===e[t]&&""===a){i=!0;break}r+=e[t]}return""===a&&{value:r,index:t,tagClosed:i}}(e,i);if(!1===v)return l("InvalidAttr","Attributes for '"+g+"' have open quote.",c(e,i));let y=v.value;if(i=v.index,"/"===y[y.length-1]){let r=i-y.length,a=d(y=y.substring(0,y.length-1),t);if(!0!==a)return l(a.err.code,a.err.msg,c(e,r+a.err.line));p=!0}else if(f)if(!v.tagClosed)return l("InvalidTag","Closing tag '"+g+"' doesn't have proper closing.",c(e,i));else{if(y.trim().length>0)return l("InvalidTag","Closing tag '"+g+"' can't have attributes or invalid starting.",c(e,m));if(0===r.length)return l("InvalidTag","Closing tag '"+g+"' has not been opened.",c(e,m));let t=r.pop();if(g!==t.tagName){let r=c(e,t.tagStartPos);return l("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+r.line+", col "+r.col+") instead of closing tag '"+g+"'.",c(e,m))}0==r.length&&(u=!0)}else{let a=d(y,t);if(!0!==a)return l(a.err.code,a.err.msg,c(e,i-y.length+a.err.line));if(!0===u)return l("InvalidXml","Multiple possible root nodes found.",c(e,i));-1!==t.unpairedTags.indexOf(g)||r.push({tagName:g,tagStartPos:m}),p=!0}for(i++;i<e.length;i++)if("<"===e[i])if("!"===e[i+1]){i=o(e,++i);continue}else if("?"===e[i+1]){if((i=n(e,++i)).err)return i}else break;else if("&"===e[i]){let t=function(e,t){if(";"===e[++t])return -1;if("#"===e[t]){var r=++t;let a=/\d/;for("x"===e[r]&&(r++,a=/[\da-fA-F]/);r<e.length;r++){if(";"===e[r])return r;if(!e[r].match(a))break}return -1}let a=0;for(;t<e.length;t++,a++)if(!e[t].match(/\w/)||!(a<20)){if(";"===e[t])break;return -1}return t}(e,i);if(-1==t)return l("InvalidChar","char '&' is not expected.",c(e,i));i=t}else if(!0===u&&!s(e[i]))return l("InvalidXml","Extra text at the end",c(e,i));"<"===e[i]&&i--}}else{if(s(e[i]))continue;return l("InvalidChar","char '"+e[i]+"' is not expected.",c(e,i))}return p?1==r.length?l("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",c(e,r[0].tagStartPos)):!(r.length>0)||l("InvalidXml","Invalid '"+JSON.stringify(r.map(e=>e.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):l("InvalidXml","Start tag expected.",1)};let p=RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function d(e,t){let r=a.getAllMatches(e,p),i={};for(let e=0;e<r.length;e++){var s;if(0===r[e][1].length)return l("InvalidAttr","Attribute '"+r[e][2]+"' has no space in starting.",u(r[e]));if(void 0!==r[e][3]&&void 0===r[e][4])return l("InvalidAttr","Attribute '"+r[e][2]+"' is without value.",u(r[e]));if(void 0===r[e][3]&&!t.allowBooleanAttributes)return l("InvalidAttr","boolean attribute '"+r[e][2]+"' is not allowed.",u(r[e]));let n=r[e][2];if(s=n,!a.isName(s))return l("InvalidAttr","Attribute '"+n+"' is an invalid name.",u(r[e]));if(i.hasOwnProperty(n))return l("InvalidAttr","Attribute '"+n+"' is repeated.",u(r[e]));i[n]=1}return!0}function l(e,t,r){return{err:{code:e,msg:t,line:r.line||r,col:r.col}}}function c(e,t){let r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function u(e){return e.startIndex+e[1].length}},56979,(e,t,r)=>{let a={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,r){return e}};r.buildOptions=function(e){return Object.assign({},a,e)},r.defaultOptions=a},14374,(e,t,r)=>{"use strict";t.exports=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}},43353,(e,t,r)=>{let a=e.r(10476);t.exports=function(e,t){let r={};if("O"===e[t+3]&&"C"===e[t+4]&&"T"===e[t+5]&&"Y"===e[t+6]&&"P"===e[t+7]&&"E"===e[t+8]){t+=9;let u=1,h=!1,m=!1;for(;t<e.length;t++)if("<"!==e[t]||m)if(">"===e[t]){if(m?"-"===e[t-1]&&"-"===e[t-2]&&(m=!1,u--):u--,0===u)break}else"["===e[t]?h=!0:e[t];else{var i,s,n,o,p,d,l,c;if(h&&"!"===(i=e)[(s=t)+1]&&"E"===i[s+2]&&"N"===i[s+3]&&"T"===i[s+4]&&"I"===i[s+5]&&"T"===i[s+6]&&"Y"===i[s+7]){let i,s;t+=7,[i,s,t]=function(e,t){let r="";for(;t<e.length&&"'"!==e[t]&&'"'!==e[t];t++)r+=e[t];if(-1!==(r=r.trim()).indexOf(" "))throw Error("External entites are not supported");let a=e[t++],i="";for(;t<e.length&&e[t]!==a;t++)i+=e[t];return[r,i,t]}(e,t+1),-1===s.indexOf("&")&&(r[function(e){if(a.isName(e))return e;throw Error(`Invalid entity name ${e}`)}(i)]={regx:RegExp(`&${i};`,"g"),val:s})}else{h&&"!"===(n=e)[(o=t)+1]&&"E"===n[o+2]&&"L"===n[o+3]&&"E"===n[o+4]&&"M"===n[o+5]&&"E"===n[o+6]&&"N"===n[o+7]&&"T"===n[o+8]||h&&"!"===(p=e)[(d=t)+1]&&"A"===p[d+2]&&"T"===p[d+3]&&"T"===p[d+4]&&"L"===p[d+5]&&"I"===p[d+6]&&"S"===p[d+7]&&"T"===p[d+8]?t+=8:h&&"!"===(l=e)[(c=t)+1]&&"N"===l[c+2]&&"O"===l[c+3]&&"T"===l[c+4]&&"A"===l[c+5]&&"T"===l[c+6]&&"I"===l[c+7]&&"O"===l[c+8]&&"N"===l[c+9]?t+=9:m=!0}u++}if(0!==u)throw Error("Unclosed DOCTYPE")}else throw Error("Invalid Tag instead of DOCTYPE");return{entities:r,i:t}}},16646,(e,t,r)=>{let a=/^[-+]?0x[a-fA-F0-9]+$/,i=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,s={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};t.exports=function(e,t={}){if(t=Object.assign({},s,t),!e||"string"!=typeof e)return e;let r=e.trim();if(void 0!==t.skipLike&&t.skipLike.test(r))return e;if("0"===e)return 0;if(t.hex&&a.test(r)){var n,o=r;if(parseInt)return parseInt(o,16);if(Number.parseInt)return Number.parseInt(o,16);if(window&&window.parseInt)return window.parseInt(o,16);throw Error("parseInt, Number.parseInt, window.parseInt are not supported")}if(-1!==r.search(/[eE]/)){let a=r.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(!a)return e;if(t.leadingZeros)r=(a[1]||"")+a[3];else if("0"!==a[2]||"."!==a[3][0])return e;return t.eNotation?Number(r):e}{let a=i.exec(r);if(!a)return e;{let i=a[1],s=a[2],o=((n=a[3])&&-1!==n.indexOf(".")&&("."===(n=n.replace(/0+$/,""))?n="0":"."===n[0]?n="0"+n:"."===n[n.length-1]&&(n=n.substr(0,n.length-1))),n);if(!t.leadingZeros&&s.length>0&&i&&"."!==r[2])return e;{if(!t.leadingZeros&&s.length>0&&!i&&"."!==r[1])return e;if(t.leadingZeros&&s===e)return 0;let a=Number(r),n=""+a;if(-1!==n.search(/[eE]/))if(t.eNotation)return a;else return e;if(-1!==r.indexOf("."))if("0"===n&&""===o)return a;else if(n===o)return a;else if(i&&n==="-"+o)return a;else return e;return s?o===n||i+o===n?a:e:r===n||r===i+n?a:e}}}}},53129,(e,t,r)=>{t.exports=function(e){return"function"==typeof e?e:Array.isArray(e)?t=>{for(let r of e)if("string"==typeof r&&t===r||r instanceof RegExp&&r.test(t))return!0}:()=>!1}},62330,(e,t,r)=>{"use strict";let a=e.r(10476),i=e.r(14374),s=e.r(43353),n=e.r(16646),o=e.r(53129);function p(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let a=t[r];this.lastEntities[a]={regex:RegExp("&"+a+";","g"),val:e[a]}}}function d(e,t,r,a,i,s,n){if(void 0!==e&&(this.options.trimValues&&!a&&(e=e.trim()),e.length>0)){n||(e=this.replaceEntitiesValue(e));let a=this.options.tagValueProcessor(t,e,r,i,s);return null==a?e:typeof a!=typeof e||a!==e?a:this.options.trimValues||e.trim()===e?_(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function l(e){if(this.options.removeNSPrefix){let t=e.split(":"),r="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=r+t[1])}return e}let c=RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function u(e,t,r){if(!0!==this.options.ignoreAttributes&&"string"==typeof e){let r=a.getAllMatches(e,c),i=r.length,s={};for(let e=0;e<i;e++){let a=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(a,t))continue;let i=r[e][4],n=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(n=this.options.transformAttributeName(n)),"__proto__"===n&&(n="#__proto__"),void 0!==i){this.options.trimValues&&(i=i.trim()),i=this.replaceEntitiesValue(i);let e=this.options.attributeValueProcessor(a,i,t);null==e?s[n]=i:typeof e!=typeof i||e!==i?s[n]=e:s[n]=_(i,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[n]=!0)}if(Object.keys(s).length){if(this.options.attributesGroupName){let e={};return e[this.options.attributesGroupName]=s,e}return s}}}let h=function(e){e=e.replace(/\r\n?/g,"\n");let t=new i("!xml"),r=t,a="",n="";for(let o=0;o<e.length;o++)if("<"===e[o])if("/"===e[o+1]){let t=y(e,">",o,"Closing Tag is not closed."),i=e.substring(o+2,t).trim();if(this.options.removeNSPrefix){let e=i.indexOf(":");-1!==e&&(i=i.substr(e+1))}this.options.transformTagName&&(i=this.options.transformTagName(i)),r&&(a=this.saveTextToParentTag(a,r,n));let s=n.substring(n.lastIndexOf(".")+1);if(i&&-1!==this.options.unpairedTags.indexOf(i))throw Error(`Unpaired tag can not be used as closing tag: </${i}>`);let p=0;s&&-1!==this.options.unpairedTags.indexOf(s)?(p=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=n.lastIndexOf("."),n=n.substring(0,p),r=this.tagsNodeStack.pop(),a="",o=t}else if("?"===e[o+1]){let t=w(e,o,!1,"?>");if(!t)throw Error("Pi Tag is not closed.");if(a=this.saveTextToParentTag(a,r,n),this.options.ignoreDeclaration&&"?xml"===t.tagName||this.options.ignorePiTags);else{let e=new i(t.tagName);e.add(this.options.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[":@"]=this.buildAttributesMap(t.tagExp,n,t.tagName)),this.addChild(r,e,n)}o=t.closeIndex+1}else if("!--"===e.substr(o+1,3)){let t=y(e,"-->",o+4,"Comment is not closed.");if(this.options.commentPropName){let i=e.substring(o+4,t-2);a=this.saveTextToParentTag(a,r,n),r.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}o=t}else if("!D"===e.substr(o+1,2)){let t=s(e,o);this.docTypeEntities=t.entities,o=t.i}else if("!["===e.substr(o+1,2)){let t=y(e,"]]>",o,"CDATA is not closed.")-2,i=e.substring(o+9,t);a=this.saveTextToParentTag(a,r,n);let s=this.parseTextData(i,r.tagname,n,!0,!1,!0,!0);void 0==s&&(s=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]):r.add(this.options.textNodeName,s),o=t+2}else{let s=w(e,o,this.options.removeNSPrefix),p=s.tagName,d=s.rawTagName,l=s.tagExp,c=s.attrExpPresent,u=s.closeIndex;this.options.transformTagName&&(p=this.options.transformTagName(p)),r&&a&&"!xml"!==r.tagname&&(a=this.saveTextToParentTag(a,r,n,!1));let h=r;if(h&&-1!==this.options.unpairedTags.indexOf(h.tagname)&&(r=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),p!==t.tagname&&(n+=n?"."+p:p),this.isItStopNode(this.options.stopNodes,n,p)){let t="";if(l.length>0&&l.lastIndexOf("/")===l.length-1)"/"===p[p.length-1]?(p=p.substr(0,p.length-1),n=n.substr(0,n.length-1),l=p):l=l.substr(0,l.length-1),o=s.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(p))o=s.closeIndex;else{let r=this.readStopNodeData(e,d,u+1);if(!r)throw Error(`Unexpected end of ${d}`);o=r.i,t=r.tagContent}let a=new i(p);p!==l&&c&&(a[":@"]=this.buildAttributesMap(l,n,p)),t&&(t=this.parseTextData(t,p,n,!0,c,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),a.add(this.options.textNodeName,t),this.addChild(r,a,n)}else{if(l.length>0&&l.lastIndexOf("/")===l.length-1){"/"===p[p.length-1]?(p=p.substr(0,p.length-1),n=n.substr(0,n.length-1),l=p):l=l.substr(0,l.length-1),this.options.transformTagName&&(p=this.options.transformTagName(p));let e=new i(p);p!==l&&c&&(e[":@"]=this.buildAttributesMap(l,n,p)),this.addChild(r,e,n),n=n.substr(0,n.lastIndexOf("."))}else{let e=new i(p);this.tagsNodeStack.push(r),p!==l&&c&&(e[":@"]=this.buildAttributesMap(l,n,p)),this.addChild(r,e,n),r=e}a="",o=u}}else a+=e[o];return t.child};function m(e,t,r){let a=this.options.updateTag(t.tagname,r,t[":@"]);!1===a||("string"==typeof a&&(t.tagname=a),e.addChild(t))}let f=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let r=this.docTypeEntities[t];e=e.replace(r.regx,r.val)}for(let t in this.lastEntities){let r=this.lastEntities[t];e=e.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let r=this.htmlEntities[t];e=e.replace(r.regex,r.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function g(e,t,r,a){return e&&(void 0===a&&(a=0===t.child.length),void 0!==(e=this.parseTextData(e,t.tagname,r,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,a))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function v(e,t,r){let a="*."+r;for(let r in e){let i=e[r];if(a===i||t===i)return!0}return!1}function y(e,t,r,a){let i=e.indexOf(t,r);if(-1!==i)return i+t.length-1;throw Error(a)}function w(e,t,r,a=">"){let i=function(e,t,r=">"){let a,i="";for(let s=t;s<e.length;s++){let t=e[s];if(a)t===a&&(a="");else if('"'===t||"'"===t)a=t;else if(t===r[0]){if(!r[1])return{data:i,index:s};else if(e[s+1]===r[1])return{data:i,index:s}}else" "===t&&(t=" ");i+=t}}(e,t+1,a);if(!i)return;let s=i.data,n=i.index,o=s.search(/\s/),p=s,d=!0;-1!==o&&(p=s.substring(0,o),s=s.substring(o+1).trimStart());let l=p;if(r){let e=p.indexOf(":");-1!==e&&(d=(p=p.substr(e+1))!==i.data.substr(e+1))}return{tagName:p,tagExp:s,closeIndex:n,attrExpPresent:d,rawTagName:l}}function b(e,t,r){let a=r,i=1;for(;r<e.length;r++)if("<"===e[r])if("/"===e[r+1]){let s=y(e,">",r,`${t} is not closed`);if(e.substring(r+2,s).trim()===t&&0==--i)return{tagContent:e.substring(a,r),i:s};r=s}else if("?"===e[r+1])r=y(e,"?>",r+1,"StopNode is not closed.");else if("!--"===e.substr(r+1,3))r=y(e,"-->",r+3,"StopNode is not closed.");else if("!["===e.substr(r+1,2))r=y(e,"]]>",r,"StopNode is not closed.")-2;else{let a=w(e,r,">");a&&((a&&a.tagName)===t&&"/"!==a.tagExp[a.tagExp.length-1]&&i++,r=a.closeIndex)}}function _(e,t,r){if(t&&"string"==typeof e){let t=e.trim();return"true"===t||"false"!==t&&n(e,r)}return a.isExist(e)?e:""}t.exports=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,16))}},this.addExternalEntities=p,this.parseXml=h,this.parseTextData=d,this.resolveNameSpace=l,this.buildAttributesMap=u,this.isItStopNode=v,this.replaceEntitiesValue=f,this.readStopNodeData=b,this.saveTextToParentTag=g,this.addChild=m,this.ignoreAttributesFn=o(this.options.ignoreAttributes)}}},1252,(e,t,r)=>{"use strict";r.prettify=function(e,t){return function e(t,r,a){let i,s={};for(let n=0;n<t.length;n++){let o=t[n],p=function(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let r=t[e];if(":@"!==r)return r}}(o),d="";if(d=void 0===a?p:a+"."+p,p===r.textNodeName)void 0===i?i=o[p]:i+=""+o[p];else if(void 0===p)continue;else if(o[p]){let t=e(o[p],r,d),a=function(e,t){let{textNodeName:r}=t,a=Object.keys(e).length;return 0===a||1===a&&(!!e[r]||"boolean"==typeof e[r]||0===e[r])}(t,r);o[":@"]?function(e,t,r,a){if(t){let i=Object.keys(t),s=i.length;for(let n=0;n<s;n++){let s=i[n];a.isArray(s,r+"."+s,!0,!0)?e[s]=[t[s]]:e[s]=t[s]}}}(t,o[":@"],d,r):1!==Object.keys(t).length||void 0===t[r.textNodeName]||r.alwaysCreateTextNode?0===Object.keys(t).length&&(r.alwaysCreateTextNode?t[r.textNodeName]="":t=""):t=t[r.textNodeName],void 0!==s[p]&&s.hasOwnProperty(p)?(Array.isArray(s[p])||(s[p]=[s[p]]),s[p].push(t)):r.isArray(p,d,a)?s[p]=[t]:s[p]=t}}return"string"==typeof i?i.length>0&&(s[r.textNodeName]=i):void 0!==i&&(s[r.textNodeName]=i),s}(e,t)}},3838,(e,t,r)=>{let{buildOptions:a}=e.r(56979),i=e.r(62330),{prettify:s}=e.r(1252),n=e.r(48418);t.exports=class{constructor(e){this.externalEntities={},this.options=a(e)}parse(e,t){if("string"==typeof e);else if(e.toString)e=e.toString();else throw Error("XML data is accepted in String or Bytes[] form.");if(t){!0===t&&(t={});let r=n.validate(e,t);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}let r=new i(this.options);r.addExternalEntities(this.externalEntities);let a=r.parseXml(e);return this.options.preserveOrder||void 0===a?a:s(a,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===t)throw Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}}},96434,(e,t,r)=>{function a(e,t){let r="";if(e&&!t.ignoreAttributes)for(let a in e){if(!e.hasOwnProperty(a))continue;let s=t.attributeValueProcessor(a,e[a]);!0===(s=i(s,t))&&t.suppressBooleanAttributes?r+=` ${a.substr(t.attributeNamePrefix.length)}`:r+=` ${a.substr(t.attributeNamePrefix.length)}="${s}"`}return r}function i(e,t){if(e&&e.length>0&&t.processEntities)for(let r=0;r<t.entities.length;r++){let a=t.entities[r];e=e.replace(a.regex,a.val)}return e}t.exports=function(e,t){let r="";return t.format&&t.indentBy.length>0&&(r="\n"),function e(t,r,s,n){let o="",p=!1;for(let d=0;d<t.length;d++){let l=t[d],c=function(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let a=t[r];if(e.hasOwnProperty(a)&&":@"!==a)return a}}(l);if(void 0===c)continue;let u="";if(u=0===s.length?c:`${s}.${c}`,c===r.textNodeName){let e=l[c];!function(e,t){let r=(e=e.substr(0,e.length-t.textNodeName.length-1)).substr(e.lastIndexOf(".")+1);for(let a in t.stopNodes)if(t.stopNodes[a]===e||t.stopNodes[a]==="*."+r)return!0;return!1}(u,r)&&(e=i(e=r.tagValueProcessor(c,e),r)),p&&(o+=n),o+=e,p=!1;continue}if(c===r.cdataPropName){p&&(o+=n),o+=`<![CDATA[${l[c][0][r.textNodeName]}]]>`,p=!1;continue}if(c===r.commentPropName){o+=n+`<!--${l[c][0][r.textNodeName]}-->`,p=!0;continue}else if("?"===c[0]){let e=a(l[":@"],r),t="?xml"===c?"":n,i=l[c][0][r.textNodeName];i=0!==i.length?" "+i:"",o+=t+`<${c}${i}${e}?>`,p=!0;continue}let h=n;""!==h&&(h+=r.indentBy);let m=a(l[":@"],r),f=n+`<${c}${m}`,g=e(l[c],r,u,h);-1!==r.unpairedTags.indexOf(c)?r.suppressUnpairedNode?o+=f+">":o+=f+"/>":(!g||0===g.length)&&r.suppressEmptyNode?o+=f+"/>":g&&g.endsWith(">")?o+=f+`>${g}${n}</${c}>`:(o+=f+">",g&&""!==n&&(g.includes("/>")||g.includes("</"))?o+=n+r.indentBy+g+n:o+=g,o+=`</${c}>`),p=!0}return o}(e,t,"",r)}},51030,(e,t,r)=>{"use strict";let a=e.r(96434),i=e.r(53129),s={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:RegExp("&","g"),val:"&amp;"},{regex:RegExp(">","g"),val:"&gt;"},{regex:RegExp("<","g"),val:"&lt;"},{regex:RegExp("'","g"),val:"&apos;"},{regex:RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function n(e){this.options=Object.assign({},s,e),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=i(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=d),this.processTextOrObjNode=o,this.options.format?(this.indentate=p,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function o(e,t,r,a){let i=this.j2x(e,r+1,a.concat(t));return void 0!==e[this.options.textNodeName]&&1===Object.keys(e).length?this.buildTextValNode(e[this.options.textNodeName],t,i.attrStr,r):this.buildObjectNode(i.val,t,i.attrStr,r)}function p(e){return this.options.indentBy.repeat(e)}function d(e){return!!e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName&&e.substr(this.attrPrefixLen)}n.prototype.build=function(e){return this.options.preserveOrder?a(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)},n.prototype.j2x=function(e,t,r){let a="",i="",s=r.join(".");for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n))if(void 0===e[n])this.isAttribute(n)&&(i+="");else if(null===e[n])this.isAttribute(n)||n===this.options.cdataPropName?i+="":"?"===n[0]?i+=this.indentate(t)+"<"+n+"?"+this.tagEndChar:i+=this.indentate(t)+"<"+n+"/"+this.tagEndChar;else if(e[n]instanceof Date)i+=this.buildTextValNode(e[n],n,"",t);else if("object"!=typeof e[n]){let r=this.isAttribute(n);if(r&&!this.ignoreAttributesFn(r,s))a+=this.buildAttrPairStr(r,""+e[n]);else if(!r)if(n===this.options.textNodeName){let t=this.options.tagValueProcessor(n,""+e[n]);i+=this.replaceEntitiesValue(t)}else i+=this.buildTextValNode(e[n],n,"",t)}else if(Array.isArray(e[n])){let a=e[n].length,s="",o="";for(let p=0;p<a;p++){let a=e[n][p];if(void 0===a);else if(null===a)"?"===n[0]?i+=this.indentate(t)+"<"+n+"?"+this.tagEndChar:i+=this.indentate(t)+"<"+n+"/"+this.tagEndChar;else if("object"==typeof a)if(this.options.oneListGroup){let e=this.j2x(a,t+1,r.concat(n));s+=e.val,this.options.attributesGroupName&&a.hasOwnProperty(this.options.attributesGroupName)&&(o+=e.attrStr)}else s+=this.processTextOrObjNode(a,n,t,r);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(n,a);s+=e=this.replaceEntitiesValue(e)}else s+=this.buildTextValNode(a,n,"",t)}this.options.oneListGroup&&(s=this.buildObjectNode(s,n,o,t)),i+=s}else if(this.options.attributesGroupName&&n===this.options.attributesGroupName){let t=Object.keys(e[n]),r=t.length;for(let i=0;i<r;i++)a+=this.buildAttrPairStr(t[i],""+e[n][t[i]])}else i+=this.processTextOrObjNode(e[n],n,t,r);return{attrStr:a,val:i}},n.prototype.buildAttrPairStr=function(e,t){return(t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&"true"===t)?" "+e:" "+e+'="'+t+'"'},n.prototype.buildObjectNode=function(e,t,r,a){if(""===e)if("?"===t[0])return this.indentate(a)+"<"+t+r+"?"+this.tagEndChar;else return this.indentate(a)+"<"+t+r+this.closeTag(t)+this.tagEndChar;{let i="</"+t+this.tagEndChar,s="";return("?"===t[0]&&(s="?",i=""),(r||""===r)&&-1===e.indexOf("<"))?this.indentate(a)+"<"+t+r+s+">"+e+i:!1!==this.options.commentPropName&&t===this.options.commentPropName&&0===s.length?this.indentate(a)+`<!--${e}-->`+this.newLine:this.indentate(a)+"<"+t+r+s+this.tagEndChar+e+this.indentate(a)+i}},n.prototype.closeTag=function(e){let t="";return -1!==this.options.unpairedTags.indexOf(e)?this.options.suppressUnpairedNode||(t="/"):t=this.options.suppressEmptyNode?"/":`></${e}`,t},n.prototype.buildTextValNode=function(e,t,r,a){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName)return this.indentate(a)+`<![CDATA[${e}]]>`+this.newLine;{if(!1!==this.options.commentPropName&&t===this.options.commentPropName)return this.indentate(a)+`<!--${e}-->`+this.newLine;if("?"===t[0])return this.indentate(a)+"<"+t+r+"?"+this.tagEndChar;let i=this.options.tagValueProcessor(t,e);return""===(i=this.replaceEntitiesValue(i))?this.indentate(a)+"<"+t+r+this.closeTag(t)+this.tagEndChar:this.indentate(a)+"<"+t+r+">"+i+"</"+t+this.tagEndChar}},n.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let r=this.options.entities[t];e=e.replace(r.regex,r.val)}return e},t.exports=n},55101,(e,t,r)=>{"use strict";let a=e.r(48418);t.exports={XMLParser:e.r(3838),XMLValidator:a,XMLBuilder:e.r(51030)}},59613,e=>{"use strict";var t,r,a,i,s,n,o,p,d,l,c,u,h,m,f,g,v,y,w,b,_,x,N,T,E,A,S,k,O,C=e.i(21360),I=e.i(54799);let R=new Uint8Array(256),D=R.length,P=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,j=[];for(let e=0;e<256;++e)j.push((e+256).toString(16).substr(1));let q=function(e,t=0){let r=(j[e[t+0]]+j[e[t+1]]+j[e[t+2]]+j[e[t+3]]+"-"+j[e[t+4]]+j[e[t+5]]+"-"+j[e[t+6]]+j[e[t+7]]+"-"+j[e[t+8]]+j[e[t+9]]+"-"+j[e[t+10]]+j[e[t+11]]+j[e[t+12]]+j[e[t+13]]+j[e[t+14]]+j[e[t+15]]).toLowerCase();if(!("string"==typeof r&&P.test(r)))throw TypeError("Stringified UUID is invalid");return r},L=function(e,t,r){let a=(e=e||{}).random||(e.rng||function(){return D>R.length-16&&(I.default.randomFillSync(R),D=0),R.slice(D,D+=16)})();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=a[e];return t}return q(a)};var M=e.i(37554),F=function(){return(F=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function U(e,t){for(var r={},a={},i=e.split("~~"),s=!1,n=0;i.length>n;n++){for(var o=i[n].split("~"),p=0;p<o.length;p+=2){var d=o[p],l=o[p+1],c="&"+d+";";r[c]=l,s&&(r["&"+d]=l),a[l]=c}s=!0}return t?{entities:F(F({},r),t.entities),characters:F(F({},a),t.characters)}:{entities:r,characters:a}}var B={};B.xml=U("lt~<~gt~>~quot~\"~apos~'~amp~&"),B.html4=U("apos~'~OElig~Œ~oelig~œ~Scaron~Š~scaron~š~Yuml~Ÿ~circ~ˆ~tilde~˜~ensp~ ~emsp~ ~thinsp~ ~zwnj~‌~zwj~‍~lrm~‎~rlm~‏~ndash~–~mdash~—~lsquo~‘~rsquo~’~sbquo~‚~ldquo~“~rdquo~”~bdquo~„~dagger~†~Dagger~‡~permil~‰~lsaquo~‹~rsaquo~›~euro~€~fnof~ƒ~Alpha~Α~Beta~Β~Gamma~Γ~Delta~Δ~Epsilon~Ε~Zeta~Ζ~Eta~Η~Theta~Θ~Iota~Ι~Kappa~Κ~Lambda~Λ~Mu~Μ~Nu~Ν~Xi~Ξ~Omicron~Ο~Pi~Π~Rho~Ρ~Sigma~Σ~Tau~Τ~Upsilon~Υ~Phi~Φ~Chi~Χ~Psi~Ψ~Omega~Ω~alpha~α~beta~β~gamma~γ~delta~δ~epsilon~ε~zeta~ζ~eta~η~theta~θ~iota~ι~kappa~κ~lambda~λ~mu~μ~nu~ν~xi~ξ~omicron~ο~pi~π~rho~ρ~sigmaf~ς~sigma~σ~tau~τ~upsilon~υ~phi~φ~chi~χ~psi~ψ~omega~ω~thetasym~ϑ~upsih~ϒ~piv~ϖ~bull~•~hellip~…~prime~′~Prime~″~oline~‾~frasl~⁄~weierp~℘~image~ℑ~real~ℜ~trade~™~alefsym~ℵ~larr~←~uarr~↑~rarr~→~darr~↓~harr~↔~crarr~↵~lArr~⇐~uArr~⇑~rArr~⇒~dArr~⇓~hArr~⇔~forall~∀~part~∂~exist~∃~empty~∅~nabla~∇~isin~∈~notin~∉~ni~∋~prod~∏~sum~∑~minus~−~lowast~∗~radic~√~prop~∝~infin~∞~ang~∠~and~∧~or~∨~cap~∩~cup~∪~int~∫~there4~∴~sim~∼~cong~≅~asymp~≈~ne~≠~equiv~≡~le~≤~ge~≥~sub~⊂~sup~⊃~nsub~⊄~sube~⊆~supe~⊇~oplus~⊕~otimes~⊗~perp~⊥~sdot~⋅~lceil~⌈~rceil~⌉~lfloor~⌊~rfloor~⌋~lang~〈~rang~〉~loz~◊~spades~♠~clubs~♣~hearts~♥~diams~♦~~nbsp~ ~iexcl~¡~cent~¢~pound~£~curren~¤~yen~¥~brvbar~¦~sect~§~uml~¨~copy~©~ordf~ª~laquo~«~not~¬~shy~­~reg~®~macr~¯~deg~°~plusmn~±~sup2~²~sup3~³~acute~´~micro~µ~para~¶~middot~·~cedil~¸~sup1~¹~ordm~º~raquo~»~frac14~¼~frac12~½~frac34~¾~iquest~¿~Agrave~À~Aacute~Á~Acirc~Â~Atilde~Ã~Auml~Ä~Aring~Å~AElig~Æ~Ccedil~Ç~Egrave~È~Eacute~É~Ecirc~Ê~Euml~Ë~Igrave~Ì~Iacute~Í~Icirc~Î~Iuml~Ï~ETH~Ð~Ntilde~Ñ~Ograve~Ò~Oacute~Ó~Ocirc~Ô~Otilde~Õ~Ouml~Ö~times~×~Oslash~Ø~Ugrave~Ù~Uacute~Ú~Ucirc~Û~Uuml~Ü~Yacute~Ý~THORN~Þ~szlig~ß~agrave~à~aacute~á~acirc~â~atilde~ã~auml~ä~aring~å~aelig~æ~ccedil~ç~egrave~è~eacute~é~ecirc~ê~euml~ë~igrave~ì~iacute~í~icirc~î~iuml~ï~eth~ð~ntilde~ñ~ograve~ò~oacute~ó~ocirc~ô~otilde~õ~ouml~ö~divide~÷~oslash~ø~ugrave~ù~uacute~ú~ucirc~û~uuml~ü~yacute~ý~thorn~þ~yuml~ÿ~quot~\"~amp~&~lt~<~gt~>"),B.html5=U('Abreve~Ă~Acy~А~Afr~𝔄~Amacr~Ā~And~⩓~Aogon~Ą~Aopf~𝔸~ApplyFunction~⁡~Ascr~𝒜~Assign~≔~Backslash~∖~Barv~⫧~Barwed~⌆~Bcy~Б~Because~∵~Bernoullis~ℬ~Bfr~𝔅~Bopf~𝔹~Breve~˘~Bscr~ℬ~Bumpeq~≎~CHcy~Ч~Cacute~Ć~Cap~⋒~CapitalDifferentialD~ⅅ~Cayleys~ℭ~Ccaron~Č~Ccirc~Ĉ~Cconint~∰~Cdot~Ċ~Cedilla~¸~CenterDot~·~Cfr~ℭ~CircleDot~⊙~CircleMinus~⊖~CirclePlus~⊕~CircleTimes~⊗~ClockwiseContourIntegral~∲~CloseCurlyDoubleQuote~”~CloseCurlyQuote~’~Colon~∷~Colone~⩴~Congruent~≡~Conint~∯~ContourIntegral~∮~Copf~ℂ~Coproduct~∐~CounterClockwiseContourIntegral~∳~Cross~⨯~Cscr~𝒞~Cup~⋓~CupCap~≍~DD~ⅅ~DDotrahd~⤑~DJcy~Ђ~DScy~Ѕ~DZcy~Џ~Darr~↡~Dashv~⫤~Dcaron~Ď~Dcy~Д~Del~∇~Dfr~𝔇~DiacriticalAcute~´~DiacriticalDot~˙~DiacriticalDoubleAcute~˝~DiacriticalGrave~`~DiacriticalTilde~˜~Diamond~⋄~DifferentialD~ⅆ~Dopf~𝔻~Dot~¨~DotDot~⃜~DotEqual~≐~DoubleContourIntegral~∯~DoubleDot~¨~DoubleDownArrow~⇓~DoubleLeftArrow~⇐~DoubleLeftRightArrow~⇔~DoubleLeftTee~⫤~DoubleLongLeftArrow~⟸~DoubleLongLeftRightArrow~⟺~DoubleLongRightArrow~⟹~DoubleRightArrow~⇒~DoubleRightTee~⊨~DoubleUpArrow~⇑~DoubleUpDownArrow~⇕~DoubleVerticalBar~∥~DownArrow~↓~DownArrowBar~⤓~DownArrowUpArrow~⇵~DownBreve~̑~DownLeftRightVector~⥐~DownLeftTeeVector~⥞~DownLeftVector~↽~DownLeftVectorBar~⥖~DownRightTeeVector~⥟~DownRightVector~⇁~DownRightVectorBar~⥗~DownTee~⊤~DownTeeArrow~↧~Downarrow~⇓~Dscr~𝒟~Dstrok~Đ~ENG~Ŋ~Ecaron~Ě~Ecy~Э~Edot~Ė~Efr~𝔈~Element~∈~Emacr~Ē~EmptySmallSquare~◻~EmptyVerySmallSquare~▫~Eogon~Ę~Eopf~𝔼~Equal~⩵~EqualTilde~≂~Equilibrium~⇌~Escr~ℰ~Esim~⩳~Exists~∃~ExponentialE~ⅇ~Fcy~Ф~Ffr~𝔉~FilledSmallSquare~◼~FilledVerySmallSquare~▪~Fopf~𝔽~ForAll~∀~Fouriertrf~ℱ~Fscr~ℱ~GJcy~Ѓ~Gammad~Ϝ~Gbreve~Ğ~Gcedil~Ģ~Gcirc~Ĝ~Gcy~Г~Gdot~Ġ~Gfr~𝔊~Gg~⋙~Gopf~𝔾~GreaterEqual~≥~GreaterEqualLess~⋛~GreaterFullEqual~≧~GreaterGreater~⪢~GreaterLess~≷~GreaterSlantEqual~⩾~GreaterTilde~≳~Gscr~𝒢~Gt~≫~HARDcy~Ъ~Hacek~ˇ~Hat~^~Hcirc~Ĥ~Hfr~ℌ~HilbertSpace~ℋ~Hopf~ℍ~HorizontalLine~─~Hscr~ℋ~Hstrok~Ħ~HumpDownHump~≎~HumpEqual~≏~IEcy~Е~IJlig~IJ~IOcy~Ё~Icy~И~Idot~İ~Ifr~ℑ~Im~ℑ~Imacr~Ī~ImaginaryI~ⅈ~Implies~⇒~Int~∬~Integral~∫~Intersection~⋂~InvisibleComma~⁣~InvisibleTimes~⁢~Iogon~Į~Iopf~𝕀~Iscr~ℐ~Itilde~Ĩ~Iukcy~І~Jcirc~Ĵ~Jcy~Й~Jfr~𝔍~Jopf~𝕁~Jscr~𝒥~Jsercy~Ј~Jukcy~Є~KHcy~Х~KJcy~Ќ~Kcedil~Ķ~Kcy~К~Kfr~𝔎~Kopf~𝕂~Kscr~𝒦~LJcy~Љ~Lacute~Ĺ~Lang~⟪~Laplacetrf~ℒ~Larr~↞~Lcaron~Ľ~Lcedil~Ļ~Lcy~Л~LeftAngleBracket~⟨~LeftArrow~←~LeftArrowBar~⇤~LeftArrowRightArrow~⇆~LeftCeiling~⌈~LeftDoubleBracket~⟦~LeftDownTeeVector~⥡~LeftDownVector~⇃~LeftDownVectorBar~⥙~LeftFloor~⌊~LeftRightArrow~↔~LeftRightVector~⥎~LeftTee~⊣~LeftTeeArrow~↤~LeftTeeVector~⥚~LeftTriangle~⊲~LeftTriangleBar~⧏~LeftTriangleEqual~⊴~LeftUpDownVector~⥑~LeftUpTeeVector~⥠~LeftUpVector~↿~LeftUpVectorBar~⥘~LeftVector~↼~LeftVectorBar~⥒~Leftarrow~⇐~Leftrightarrow~⇔~LessEqualGreater~⋚~LessFullEqual~≦~LessGreater~≶~LessLess~⪡~LessSlantEqual~⩽~LessTilde~≲~Lfr~𝔏~Ll~⋘~Lleftarrow~⇚~Lmidot~Ŀ~LongLeftArrow~⟵~LongLeftRightArrow~⟷~LongRightArrow~⟶~Longleftarrow~⟸~Longleftrightarrow~⟺~Longrightarrow~⟹~Lopf~𝕃~LowerLeftArrow~↙~LowerRightArrow~↘~Lscr~ℒ~Lsh~↰~Lstrok~Ł~Lt~≪~Map~⤅~Mcy~М~MediumSpace~ ~Mellintrf~ℳ~Mfr~𝔐~MinusPlus~∓~Mopf~𝕄~Mscr~ℳ~NJcy~Њ~Nacute~Ń~Ncaron~Ň~Ncedil~Ņ~Ncy~Н~NegativeMediumSpace~​~NegativeThickSpace~​~NegativeThinSpace~​~NegativeVeryThinSpace~​~NestedGreaterGreater~≫~NestedLessLess~≪~NewLine~\n~Nfr~𝔑~NoBreak~⁠~NonBreakingSpace~ ~Nopf~ℕ~Not~⫬~NotCongruent~≢~NotCupCap~≭~NotDoubleVerticalBar~∦~NotElement~∉~NotEqual~≠~NotEqualTilde~≂̸~NotExists~∄~NotGreater~≯~NotGreaterEqual~≱~NotGreaterFullEqual~≧̸~NotGreaterGreater~≫̸~NotGreaterLess~≹~NotGreaterSlantEqual~⩾̸~NotGreaterTilde~≵~NotHumpDownHump~≎̸~NotHumpEqual~≏̸~NotLeftTriangle~⋪~NotLeftTriangleBar~⧏̸~NotLeftTriangleEqual~⋬~NotLess~≮~NotLessEqual~≰~NotLessGreater~≸~NotLessLess~≪̸~NotLessSlantEqual~⩽̸~NotLessTilde~≴~NotNestedGreaterGreater~⪢̸~NotNestedLessLess~⪡̸~NotPrecedes~⊀~NotPrecedesEqual~⪯̸~NotPrecedesSlantEqual~⋠~NotReverseElement~∌~NotRightTriangle~⋫~NotRightTriangleBar~⧐̸~NotRightTriangleEqual~⋭~NotSquareSubset~⊏̸~NotSquareSubsetEqual~⋢~NotSquareSuperset~⊐̸~NotSquareSupersetEqual~⋣~NotSubset~⊂⃒~NotSubsetEqual~⊈~NotSucceeds~⊁~NotSucceedsEqual~⪰̸~NotSucceedsSlantEqual~⋡~NotSucceedsTilde~≿̸~NotSuperset~⊃⃒~NotSupersetEqual~⊉~NotTilde~≁~NotTildeEqual~≄~NotTildeFullEqual~≇~NotTildeTilde~≉~NotVerticalBar~∤~Nscr~𝒩~Ocy~О~Odblac~Ő~Ofr~𝔒~Omacr~Ō~Oopf~𝕆~OpenCurlyDoubleQuote~“~OpenCurlyQuote~‘~Or~⩔~Oscr~𝒪~Otimes~⨷~OverBar~‾~OverBrace~⏞~OverBracket~⎴~OverParenthesis~⏜~PartialD~∂~Pcy~П~Pfr~𝔓~PlusMinus~±~Poincareplane~ℌ~Popf~ℙ~Pr~⪻~Precedes~≺~PrecedesEqual~⪯~PrecedesSlantEqual~≼~PrecedesTilde~≾~Product~∏~Proportion~∷~Proportional~∝~Pscr~𝒫~Qfr~𝔔~Qopf~ℚ~Qscr~𝒬~RBarr~⤐~Racute~Ŕ~Rang~⟫~Rarr~↠~Rarrtl~⤖~Rcaron~Ř~Rcedil~Ŗ~Rcy~Р~Re~ℜ~ReverseElement~∋~ReverseEquilibrium~⇋~ReverseUpEquilibrium~⥯~Rfr~ℜ~RightAngleBracket~⟩~RightArrow~→~RightArrowBar~⇥~RightArrowLeftArrow~⇄~RightCeiling~⌉~RightDoubleBracket~⟧~RightDownTeeVector~⥝~RightDownVector~⇂~RightDownVectorBar~⥕~RightFloor~⌋~RightTee~⊢~RightTeeArrow~↦~RightTeeVector~⥛~RightTriangle~⊳~RightTriangleBar~⧐~RightTriangleEqual~⊵~RightUpDownVector~⥏~RightUpTeeVector~⥜~RightUpVector~↾~RightUpVectorBar~⥔~RightVector~⇀~RightVectorBar~⥓~Rightarrow~⇒~Ropf~ℝ~RoundImplies~⥰~Rrightarrow~⇛~Rscr~ℛ~Rsh~↱~RuleDelayed~⧴~SHCHcy~Щ~SHcy~Ш~SOFTcy~Ь~Sacute~Ś~Sc~⪼~Scedil~Ş~Scirc~Ŝ~Scy~С~Sfr~𝔖~ShortDownArrow~↓~ShortLeftArrow~←~ShortRightArrow~→~ShortUpArrow~↑~SmallCircle~∘~Sopf~𝕊~Sqrt~√~Square~□~SquareIntersection~⊓~SquareSubset~⊏~SquareSubsetEqual~⊑~SquareSuperset~⊐~SquareSupersetEqual~⊒~SquareUnion~⊔~Sscr~𝒮~Star~⋆~Sub~⋐~Subset~⋐~SubsetEqual~⊆~Succeeds~≻~SucceedsEqual~⪰~SucceedsSlantEqual~≽~SucceedsTilde~≿~SuchThat~∋~Sum~∑~Sup~⋑~Superset~⊃~SupersetEqual~⊇~Supset~⋑~TRADE~™~TSHcy~Ћ~TScy~Ц~Tab~ ~Tcaron~Ť~Tcedil~Ţ~Tcy~Т~Tfr~𝔗~Therefore~∴~ThickSpace~  ~ThinSpace~ ~Tilde~∼~TildeEqual~≃~TildeFullEqual~≅~TildeTilde~≈~Topf~𝕋~TripleDot~⃛~Tscr~𝒯~Tstrok~Ŧ~Uarr~↟~Uarrocir~⥉~Ubrcy~Ў~Ubreve~Ŭ~Ucy~У~Udblac~Ű~Ufr~𝔘~Umacr~Ū~UnderBar~_~UnderBrace~⏟~UnderBracket~⎵~UnderParenthesis~⏝~Union~⋃~UnionPlus~⊎~Uogon~Ų~Uopf~𝕌~UpArrow~↑~UpArrowBar~⤒~UpArrowDownArrow~⇅~UpDownArrow~↕~UpEquilibrium~⥮~UpTee~⊥~UpTeeArrow~↥~Uparrow~⇑~Updownarrow~⇕~UpperLeftArrow~↖~UpperRightArrow~↗~Upsi~ϒ~Uring~Ů~Uscr~𝒰~Utilde~Ũ~VDash~⊫~Vbar~⫫~Vcy~В~Vdash~⊩~Vdashl~⫦~Vee~⋁~Verbar~‖~Vert~‖~VerticalBar~∣~VerticalLine~|~VerticalSeparator~❘~VerticalTilde~≀~VeryThinSpace~ ~Vfr~𝔙~Vopf~𝕍~Vscr~𝒱~Vvdash~⊪~Wcirc~Ŵ~Wedge~⋀~Wfr~𝔚~Wopf~𝕎~Wscr~𝒲~Xfr~𝔛~Xopf~𝕏~Xscr~𝒳~YAcy~Я~YIcy~Ї~YUcy~Ю~Ycirc~Ŷ~Ycy~Ы~Yfr~𝔜~Yopf~𝕐~Yscr~𝒴~ZHcy~Ж~Zacute~Ź~Zcaron~Ž~Zcy~З~Zdot~Ż~ZeroWidthSpace~​~Zfr~ℨ~Zopf~ℤ~Zscr~𝒵~abreve~ă~ac~∾~acE~∾̳~acd~∿~acy~а~af~⁡~afr~𝔞~aleph~ℵ~amacr~ā~amalg~⨿~andand~⩕~andd~⩜~andslope~⩘~andv~⩚~ange~⦤~angle~∠~angmsd~∡~angmsdaa~⦨~angmsdab~⦩~angmsdac~⦪~angmsdad~⦫~angmsdae~⦬~angmsdaf~⦭~angmsdag~⦮~angmsdah~⦯~angrt~∟~angrtvb~⊾~angrtvbd~⦝~angsph~∢~angst~Å~angzarr~⍼~aogon~ą~aopf~𝕒~ap~≈~apE~⩰~apacir~⩯~ape~≊~apid~≋~approx~≈~approxeq~≊~ascr~𝒶~ast~*~asympeq~≍~awconint~∳~awint~⨑~bNot~⫭~backcong~≌~backepsilon~϶~backprime~‵~backsim~∽~backsimeq~⋍~barvee~⊽~barwed~⌅~barwedge~⌅~bbrk~⎵~bbrktbrk~⎶~bcong~≌~bcy~б~becaus~∵~because~∵~bemptyv~⦰~bepsi~϶~bernou~ℬ~beth~ℶ~between~≬~bfr~𝔟~bigcap~⋂~bigcirc~◯~bigcup~⋃~bigodot~⨀~bigoplus~⨁~bigotimes~⨂~bigsqcup~⨆~bigstar~★~bigtriangledown~▽~bigtriangleup~△~biguplus~⨄~bigvee~⋁~bigwedge~⋀~bkarow~⤍~blacklozenge~⧫~blacksquare~▪~blacktriangle~▴~blacktriangledown~▾~blacktriangleleft~◂~blacktriangleright~▸~blank~␣~blk12~▒~blk14~░~blk34~▓~block~█~bne~=⃥~bnequiv~≡⃥~bnot~⌐~bopf~𝕓~bot~⊥~bottom~⊥~bowtie~⋈~boxDL~╗~boxDR~╔~boxDl~╖~boxDr~╓~boxH~═~boxHD~╦~boxHU~╩~boxHd~╤~boxHu~╧~boxUL~╝~boxUR~╚~boxUl~╜~boxUr~╙~boxV~║~boxVH~╬~boxVL~╣~boxVR~╠~boxVh~╫~boxVl~╢~boxVr~╟~boxbox~⧉~boxdL~╕~boxdR~╒~boxdl~┐~boxdr~┌~boxh~─~boxhD~╥~boxhU~╨~boxhd~┬~boxhu~┴~boxminus~⊟~boxplus~⊞~boxtimes~⊠~boxuL~╛~boxuR~╘~boxul~┘~boxur~└~boxv~│~boxvH~╪~boxvL~╡~boxvR~╞~boxvh~┼~boxvl~┤~boxvr~├~bprime~‵~breve~˘~bscr~𝒷~bsemi~⁏~bsim~∽~bsime~⋍~bsol~\\~bsolb~⧅~bsolhsub~⟈~bullet~•~bump~≎~bumpE~⪮~bumpe~≏~bumpeq~≏~cacute~ć~capand~⩄~capbrcup~⩉~capcap~⩋~capcup~⩇~capdot~⩀~caps~∩︀~caret~⁁~caron~ˇ~ccaps~⩍~ccaron~č~ccirc~ĉ~ccups~⩌~ccupssm~⩐~cdot~ċ~cemptyv~⦲~centerdot~·~cfr~𝔠~chcy~ч~check~✓~checkmark~✓~cir~○~cirE~⧃~circeq~≗~circlearrowleft~↺~circlearrowright~↻~circledR~®~circledS~Ⓢ~circledast~⊛~circledcirc~⊚~circleddash~⊝~cire~≗~cirfnint~⨐~cirmid~⫯~cirscir~⧂~clubsuit~♣~colon~:~colone~≔~coloneq~≔~comma~,~commat~@~comp~∁~compfn~∘~complement~∁~complexes~ℂ~congdot~⩭~conint~∮~copf~𝕔~coprod~∐~copysr~℗~cross~✗~cscr~𝒸~csub~⫏~csube~⫑~csup~⫐~csupe~⫒~ctdot~⋯~cudarrl~⤸~cudarrr~⤵~cuepr~⋞~cuesc~⋟~cularr~↶~cularrp~⤽~cupbrcap~⩈~cupcap~⩆~cupcup~⩊~cupdot~⊍~cupor~⩅~cups~∪︀~curarr~↷~curarrm~⤼~curlyeqprec~⋞~curlyeqsucc~⋟~curlyvee~⋎~curlywedge~⋏~curvearrowleft~↶~curvearrowright~↷~cuvee~⋎~cuwed~⋏~cwconint~∲~cwint~∱~cylcty~⌭~dHar~⥥~daleth~ℸ~dash~‐~dashv~⊣~dbkarow~⤏~dblac~˝~dcaron~ď~dcy~д~dd~ⅆ~ddagger~‡~ddarr~⇊~ddotseq~⩷~demptyv~⦱~dfisht~⥿~dfr~𝔡~dharl~⇃~dharr~⇂~diam~⋄~diamond~⋄~diamondsuit~♦~die~¨~digamma~ϝ~disin~⋲~div~÷~divideontimes~⋇~divonx~⋇~djcy~ђ~dlcorn~⌞~dlcrop~⌍~dollar~$~dopf~𝕕~dot~˙~doteq~≐~doteqdot~≑~dotminus~∸~dotplus~∔~dotsquare~⊡~doublebarwedge~⌆~downarrow~↓~downdownarrows~⇊~downharpoonleft~⇃~downharpoonright~⇂~drbkarow~⤐~drcorn~⌟~drcrop~⌌~dscr~𝒹~dscy~ѕ~dsol~⧶~dstrok~đ~dtdot~⋱~dtri~▿~dtrif~▾~duarr~⇵~duhar~⥯~dwangle~⦦~dzcy~џ~dzigrarr~⟿~eDDot~⩷~eDot~≑~easter~⩮~ecaron~ě~ecir~≖~ecolon~≕~ecy~э~edot~ė~ee~ⅇ~efDot~≒~efr~𝔢~eg~⪚~egs~⪖~egsdot~⪘~el~⪙~elinters~⏧~ell~ℓ~els~⪕~elsdot~⪗~emacr~ē~emptyset~∅~emptyv~∅~emsp13~ ~emsp14~ ~eng~ŋ~eogon~ę~eopf~𝕖~epar~⋕~eparsl~⧣~eplus~⩱~epsi~ε~epsiv~ϵ~eqcirc~≖~eqcolon~≕~eqsim~≂~eqslantgtr~⪖~eqslantless~⪕~equals~=~equest~≟~equivDD~⩸~eqvparsl~⧥~erDot~≓~erarr~⥱~escr~ℯ~esdot~≐~esim~≂~excl~!~expectation~ℰ~exponentiale~ⅇ~fallingdotseq~≒~fcy~ф~female~♀~ffilig~ffi~fflig~ff~ffllig~ffl~ffr~𝔣~filig~fi~fjlig~fj~flat~♭~fllig~fl~fltns~▱~fopf~𝕗~fork~⋔~forkv~⫙~fpartint~⨍~frac13~⅓~frac15~⅕~frac16~⅙~frac18~⅛~frac23~⅔~frac25~⅖~frac35~⅗~frac38~⅜~frac45~⅘~frac56~⅚~frac58~⅝~frac78~⅞~frown~⌢~fscr~𝒻~gE~≧~gEl~⪌~gacute~ǵ~gammad~ϝ~gap~⪆~gbreve~ğ~gcirc~ĝ~gcy~г~gdot~ġ~gel~⋛~geq~≥~geqq~≧~geqslant~⩾~ges~⩾~gescc~⪩~gesdot~⪀~gesdoto~⪂~gesdotol~⪄~gesl~⋛︀~gesles~⪔~gfr~𝔤~gg~≫~ggg~⋙~gimel~ℷ~gjcy~ѓ~gl~≷~glE~⪒~gla~⪥~glj~⪤~gnE~≩~gnap~⪊~gnapprox~⪊~gne~⪈~gneq~⪈~gneqq~≩~gnsim~⋧~gopf~𝕘~grave~`~gscr~ℊ~gsim~≳~gsime~⪎~gsiml~⪐~gtcc~⪧~gtcir~⩺~gtdot~⋗~gtlPar~⦕~gtquest~⩼~gtrapprox~⪆~gtrarr~⥸~gtrdot~⋗~gtreqless~⋛~gtreqqless~⪌~gtrless~≷~gtrsim~≳~gvertneqq~≩︀~gvnE~≩︀~hairsp~ ~half~½~hamilt~ℋ~hardcy~ъ~harrcir~⥈~harrw~↭~hbar~ℏ~hcirc~ĥ~heartsuit~♥~hercon~⊹~hfr~𝔥~hksearow~⤥~hkswarow~⤦~hoarr~⇿~homtht~∻~hookleftarrow~↩~hookrightarrow~↪~hopf~𝕙~horbar~―~hscr~𝒽~hslash~ℏ~hstrok~ħ~hybull~⁃~hyphen~‐~ic~⁣~icy~и~iecy~е~iff~⇔~ifr~𝔦~ii~ⅈ~iiiint~⨌~iiint~∭~iinfin~⧜~iiota~℩~ijlig~ij~imacr~ī~imagline~ℐ~imagpart~ℑ~imath~ı~imof~⊷~imped~Ƶ~in~∈~incare~℅~infintie~⧝~inodot~ı~intcal~⊺~integers~ℤ~intercal~⊺~intlarhk~⨗~intprod~⨼~iocy~ё~iogon~į~iopf~𝕚~iprod~⨼~iscr~𝒾~isinE~⋹~isindot~⋵~isins~⋴~isinsv~⋳~isinv~∈~it~⁢~itilde~ĩ~iukcy~і~jcirc~ĵ~jcy~й~jfr~𝔧~jmath~ȷ~jopf~𝕛~jscr~𝒿~jsercy~ј~jukcy~є~kappav~ϰ~kcedil~ķ~kcy~к~kfr~𝔨~kgreen~ĸ~khcy~х~kjcy~ќ~kopf~𝕜~kscr~𝓀~lAarr~⇚~lAtail~⤛~lBarr~⤎~lE~≦~lEg~⪋~lHar~⥢~lacute~ĺ~laemptyv~⦴~lagran~ℒ~langd~⦑~langle~⟨~lap~⪅~larrb~⇤~larrbfs~⤟~larrfs~⤝~larrhk~↩~larrlp~↫~larrpl~⤹~larrsim~⥳~larrtl~↢~lat~⪫~latail~⤙~late~⪭~lates~⪭︀~lbarr~⤌~lbbrk~❲~lbrace~{~lbrack~[~lbrke~⦋~lbrksld~⦏~lbrkslu~⦍~lcaron~ľ~lcedil~ļ~lcub~{~lcy~л~ldca~⤶~ldquor~„~ldrdhar~⥧~ldrushar~⥋~ldsh~↲~leftarrow~←~leftarrowtail~↢~leftharpoondown~↽~leftharpoonup~↼~leftleftarrows~⇇~leftrightarrow~↔~leftrightarrows~⇆~leftrightharpoons~⇋~leftrightsquigarrow~↭~leftthreetimes~⋋~leg~⋚~leq~≤~leqq~≦~leqslant~⩽~les~⩽~lescc~⪨~lesdot~⩿~lesdoto~⪁~lesdotor~⪃~lesg~⋚︀~lesges~⪓~lessapprox~⪅~lessdot~⋖~lesseqgtr~⋚~lesseqqgtr~⪋~lessgtr~≶~lesssim~≲~lfisht~⥼~lfr~𝔩~lg~≶~lgE~⪑~lhard~↽~lharu~↼~lharul~⥪~lhblk~▄~ljcy~љ~ll~≪~llarr~⇇~llcorner~⌞~llhard~⥫~lltri~◺~lmidot~ŀ~lmoust~⎰~lmoustache~⎰~lnE~≨~lnap~⪉~lnapprox~⪉~lne~⪇~lneq~⪇~lneqq~≨~lnsim~⋦~loang~⟬~loarr~⇽~lobrk~⟦~longleftarrow~⟵~longleftrightarrow~⟷~longmapsto~⟼~longrightarrow~⟶~looparrowleft~↫~looparrowright~↬~lopar~⦅~lopf~𝕝~loplus~⨭~lotimes~⨴~lowbar~_~lozenge~◊~lozf~⧫~lpar~(~lparlt~⦓~lrarr~⇆~lrcorner~⌟~lrhar~⇋~lrhard~⥭~lrtri~⊿~lscr~𝓁~lsh~↰~lsim~≲~lsime~⪍~lsimg~⪏~lsqb~[~lsquor~‚~lstrok~ł~ltcc~⪦~ltcir~⩹~ltdot~⋖~lthree~⋋~ltimes~⋉~ltlarr~⥶~ltquest~⩻~ltrPar~⦖~ltri~◃~ltrie~⊴~ltrif~◂~lurdshar~⥊~luruhar~⥦~lvertneqq~≨︀~lvnE~≨︀~mDDot~∺~male~♂~malt~✠~maltese~✠~map~↦~mapsto~↦~mapstodown~↧~mapstoleft~↤~mapstoup~↥~marker~▮~mcomma~⨩~mcy~м~measuredangle~∡~mfr~𝔪~mho~℧~mid~∣~midast~*~midcir~⫰~minusb~⊟~minusd~∸~minusdu~⨪~mlcp~⫛~mldr~…~mnplus~∓~models~⊧~mopf~𝕞~mp~∓~mscr~𝓂~mstpos~∾~multimap~⊸~mumap~⊸~nGg~⋙̸~nGt~≫⃒~nGtv~≫̸~nLeftarrow~⇍~nLeftrightarrow~⇎~nLl~⋘̸~nLt~≪⃒~nLtv~≪̸~nRightarrow~⇏~nVDash~⊯~nVdash~⊮~nacute~ń~nang~∠⃒~nap~≉~napE~⩰̸~napid~≋̸~napos~ʼn~napprox~≉~natur~♮~natural~♮~naturals~ℕ~nbump~≎̸~nbumpe~≏̸~ncap~⩃~ncaron~ň~ncedil~ņ~ncong~≇~ncongdot~⩭̸~ncup~⩂~ncy~н~neArr~⇗~nearhk~⤤~nearr~↗~nearrow~↗~nedot~≐̸~nequiv~≢~nesear~⤨~nesim~≂̸~nexist~∄~nexists~∄~nfr~𝔫~ngE~≧̸~nge~≱~ngeq~≱~ngeqq~≧̸~ngeqslant~⩾̸~nges~⩾̸~ngsim~≵~ngt~≯~ngtr~≯~nhArr~⇎~nharr~↮~nhpar~⫲~nis~⋼~nisd~⋺~niv~∋~njcy~њ~nlArr~⇍~nlE~≦̸~nlarr~↚~nldr~‥~nle~≰~nleftarrow~↚~nleftrightarrow~↮~nleq~≰~nleqq~≦̸~nleqslant~⩽̸~nles~⩽̸~nless~≮~nlsim~≴~nlt~≮~nltri~⋪~nltrie~⋬~nmid~∤~nopf~𝕟~notinE~⋹̸~notindot~⋵̸~notinva~∉~notinvb~⋷~notinvc~⋶~notni~∌~notniva~∌~notnivb~⋾~notnivc~⋽~npar~∦~nparallel~∦~nparsl~⫽⃥~npart~∂̸~npolint~⨔~npr~⊀~nprcue~⋠~npre~⪯̸~nprec~⊀~npreceq~⪯̸~nrArr~⇏~nrarr~↛~nrarrc~⤳̸~nrarrw~↝̸~nrightarrow~↛~nrtri~⋫~nrtrie~⋭~nsc~⊁~nsccue~⋡~nsce~⪰̸~nscr~𝓃~nshortmid~∤~nshortparallel~∦~nsim~≁~nsime~≄~nsimeq~≄~nsmid~∤~nspar~∦~nsqsube~⋢~nsqsupe~⋣~nsubE~⫅̸~nsube~⊈~nsubset~⊂⃒~nsubseteq~⊈~nsubseteqq~⫅̸~nsucc~⊁~nsucceq~⪰̸~nsup~⊅~nsupE~⫆̸~nsupe~⊉~nsupset~⊃⃒~nsupseteq~⊉~nsupseteqq~⫆̸~ntgl~≹~ntlg~≸~ntriangleleft~⋪~ntrianglelefteq~⋬~ntriangleright~⋫~ntrianglerighteq~⋭~num~#~numero~№~numsp~ ~nvDash~⊭~nvHarr~⤄~nvap~≍⃒~nvdash~⊬~nvge~≥⃒~nvgt~>⃒~nvinfin~⧞~nvlArr~⤂~nvle~≤⃒~nvlt~<⃒~nvltrie~⊴⃒~nvrArr~⤃~nvrtrie~⊵⃒~nvsim~∼⃒~nwArr~⇖~nwarhk~⤣~nwarr~↖~nwarrow~↖~nwnear~⤧~oS~Ⓢ~oast~⊛~ocir~⊚~ocy~о~odash~⊝~odblac~ő~odiv~⨸~odot~⊙~odsold~⦼~ofcir~⦿~ofr~𝔬~ogon~˛~ogt~⧁~ohbar~⦵~ohm~Ω~oint~∮~olarr~↺~olcir~⦾~olcross~⦻~olt~⧀~omacr~ō~omid~⦶~ominus~⊖~oopf~𝕠~opar~⦷~operp~⦹~orarr~↻~ord~⩝~order~ℴ~orderof~ℴ~origof~⊶~oror~⩖~orslope~⩗~orv~⩛~oscr~ℴ~osol~⊘~otimesas~⨶~ovbar~⌽~par~∥~parallel~∥~parsim~⫳~parsl~⫽~pcy~п~percnt~%~period~.~pertenk~‱~pfr~𝔭~phiv~ϕ~phmmat~ℳ~phone~☎~pitchfork~⋔~planck~ℏ~planckh~ℎ~plankv~ℏ~plus~+~plusacir~⨣~plusb~⊞~pluscir~⨢~plusdo~∔~plusdu~⨥~pluse~⩲~plussim~⨦~plustwo~⨧~pm~±~pointint~⨕~popf~𝕡~pr~≺~prE~⪳~prap~⪷~prcue~≼~pre~⪯~prec~≺~precapprox~⪷~preccurlyeq~≼~preceq~⪯~precnapprox~⪹~precneqq~⪵~precnsim~⋨~precsim~≾~primes~ℙ~prnE~⪵~prnap~⪹~prnsim~⋨~profalar~⌮~profline~⌒~profsurf~⌓~propto~∝~prsim~≾~prurel~⊰~pscr~𝓅~puncsp~ ~qfr~𝔮~qint~⨌~qopf~𝕢~qprime~⁗~qscr~𝓆~quaternions~ℍ~quatint~⨖~quest~?~questeq~≟~rAarr~⇛~rAtail~⤜~rBarr~⤏~rHar~⥤~race~∽̱~racute~ŕ~raemptyv~⦳~rangd~⦒~range~⦥~rangle~⟩~rarrap~⥵~rarrb~⇥~rarrbfs~⤠~rarrc~⤳~rarrfs~⤞~rarrhk~↪~rarrlp~↬~rarrpl~⥅~rarrsim~⥴~rarrtl~↣~rarrw~↝~ratail~⤚~ratio~∶~rationals~ℚ~rbarr~⤍~rbbrk~❳~rbrace~}~rbrack~]~rbrke~⦌~rbrksld~⦎~rbrkslu~⦐~rcaron~ř~rcedil~ŗ~rcub~}~rcy~р~rdca~⤷~rdldhar~⥩~rdquor~”~rdsh~↳~realine~ℛ~realpart~ℜ~reals~ℝ~rect~▭~rfisht~⥽~rfr~𝔯~rhard~⇁~rharu~⇀~rharul~⥬~rhov~ϱ~rightarrow~→~rightarrowtail~↣~rightharpoondown~⇁~rightharpoonup~⇀~rightleftarrows~⇄~rightleftharpoons~⇌~rightrightarrows~⇉~rightsquigarrow~↝~rightthreetimes~⋌~ring~˚~risingdotseq~≓~rlarr~⇄~rlhar~⇌~rmoust~⎱~rmoustache~⎱~rnmid~⫮~roang~⟭~roarr~⇾~robrk~⟧~ropar~⦆~ropf~𝕣~roplus~⨮~rotimes~⨵~rpar~)~rpargt~⦔~rppolint~⨒~rrarr~⇉~rscr~𝓇~rsh~↱~rsqb~]~rsquor~’~rthree~⋌~rtimes~⋊~rtri~▹~rtrie~⊵~rtrif~▸~rtriltri~⧎~ruluhar~⥨~rx~℞~sacute~ś~sc~≻~scE~⪴~scap~⪸~sccue~≽~sce~⪰~scedil~ş~scirc~ŝ~scnE~⪶~scnap~⪺~scnsim~⋩~scpolint~⨓~scsim~≿~scy~с~sdotb~⊡~sdote~⩦~seArr~⇘~searhk~⤥~searr~↘~searrow~↘~semi~;~seswar~⤩~setminus~∖~setmn~∖~sext~✶~sfr~𝔰~sfrown~⌢~sharp~♯~shchcy~щ~shcy~ш~shortmid~∣~shortparallel~∥~sigmav~ς~simdot~⩪~sime~≃~simeq~≃~simg~⪞~simgE~⪠~siml~⪝~simlE~⪟~simne~≆~simplus~⨤~simrarr~⥲~slarr~←~smallsetminus~∖~smashp~⨳~smeparsl~⧤~smid~∣~smile~⌣~smt~⪪~smte~⪬~smtes~⪬︀~softcy~ь~sol~/~solb~⧄~solbar~⌿~sopf~𝕤~spadesuit~♠~spar~∥~sqcap~⊓~sqcaps~⊓︀~sqcup~⊔~sqcups~⊔︀~sqsub~⊏~sqsube~⊑~sqsubset~⊏~sqsubseteq~⊑~sqsup~⊐~sqsupe~⊒~sqsupset~⊐~sqsupseteq~⊒~squ~□~square~□~squarf~▪~squf~▪~srarr~→~sscr~𝓈~ssetmn~∖~ssmile~⌣~sstarf~⋆~star~☆~starf~★~straightepsilon~ϵ~straightphi~ϕ~strns~¯~subE~⫅~subdot~⪽~subedot~⫃~submult~⫁~subnE~⫋~subne~⊊~subplus~⪿~subrarr~⥹~subset~⊂~subseteq~⊆~subseteqq~⫅~subsetneq~⊊~subsetneqq~⫋~subsim~⫇~subsub~⫕~subsup~⫓~succ~≻~succapprox~⪸~succcurlyeq~≽~succeq~⪰~succnapprox~⪺~succneqq~⪶~succnsim~⋩~succsim~≿~sung~♪~supE~⫆~supdot~⪾~supdsub~⫘~supedot~⫄~suphsol~⟉~suphsub~⫗~suplarr~⥻~supmult~⫂~supnE~⫌~supne~⊋~supplus~⫀~supset~⊃~supseteq~⊇~supseteqq~⫆~supsetneq~⊋~supsetneqq~⫌~supsim~⫈~supsub~⫔~supsup~⫖~swArr~⇙~swarhk~⤦~swarr~↙~swarrow~↙~swnwar~⤪~target~⌖~tbrk~⎴~tcaron~ť~tcedil~ţ~tcy~т~tdot~⃛~telrec~⌕~tfr~𝔱~therefore~∴~thetav~ϑ~thickapprox~≈~thicksim~∼~thkap~≈~thksim~∼~timesb~⊠~timesbar~⨱~timesd~⨰~tint~∭~toea~⤨~top~⊤~topbot~⌶~topcir~⫱~topf~𝕥~topfork~⫚~tosa~⤩~tprime~‴~triangle~▵~triangledown~▿~triangleleft~◃~trianglelefteq~⊴~triangleq~≜~triangleright~▹~trianglerighteq~⊵~tridot~◬~trie~≜~triminus~⨺~triplus~⨹~trisb~⧍~tritime~⨻~trpezium~⏢~tscr~𝓉~tscy~ц~tshcy~ћ~tstrok~ŧ~twixt~≬~twoheadleftarrow~↞~twoheadrightarrow~↠~uHar~⥣~ubrcy~ў~ubreve~ŭ~ucy~у~udarr~⇅~udblac~ű~udhar~⥮~ufisht~⥾~ufr~𝔲~uharl~↿~uharr~↾~uhblk~▀~ulcorn~⌜~ulcorner~⌜~ulcrop~⌏~ultri~◸~umacr~ū~uogon~ų~uopf~𝕦~uparrow~↑~updownarrow~↕~upharpoonleft~↿~upharpoonright~↾~uplus~⊎~upsi~υ~upuparrows~⇈~urcorn~⌝~urcorner~⌝~urcrop~⌎~uring~ů~urtri~◹~uscr~𝓊~utdot~⋰~utilde~ũ~utri~▵~utrif~▴~uuarr~⇈~uwangle~⦧~vArr~⇕~vBar~⫨~vBarv~⫩~vDash~⊨~vangrt~⦜~varepsilon~ϵ~varkappa~ϰ~varnothing~∅~varphi~ϕ~varpi~ϖ~varpropto~∝~varr~↕~varrho~ϱ~varsigma~ς~varsubsetneq~⊊︀~varsubsetneqq~⫋︀~varsupsetneq~⊋︀~varsupsetneqq~⫌︀~vartheta~ϑ~vartriangleleft~⊲~vartriangleright~⊳~vcy~в~vdash~⊢~vee~∨~veebar~⊻~veeeq~≚~vellip~⋮~verbar~|~vert~|~vfr~𝔳~vltri~⊲~vnsub~⊂⃒~vnsup~⊃⃒~vopf~𝕧~vprop~∝~vrtri~⊳~vscr~𝓋~vsubnE~⫋︀~vsubne~⊊︀~vsupnE~⫌︀~vsupne~⊋︀~vzigzag~⦚~wcirc~ŵ~wedbar~⩟~wedge~∧~wedgeq~≙~wfr~𝔴~wopf~𝕨~wp~℘~wr~≀~wreath~≀~wscr~𝓌~xcap~⋂~xcirc~◯~xcup~⋃~xdtri~▽~xfr~𝔵~xhArr~⟺~xharr~⟷~xlArr~⟸~xlarr~⟵~xmap~⟼~xnis~⋻~xodot~⨀~xopf~𝕩~xoplus~⨁~xotime~⨂~xrArr~⟹~xrarr~⟶~xscr~𝓍~xsqcup~⨆~xuplus~⨄~xutri~△~xvee~⋁~xwedge~⋀~yacy~я~ycirc~ŷ~ycy~ы~yfr~𝔶~yicy~ї~yopf~𝕪~yscr~𝓎~yucy~ю~zacute~ź~zcaron~ž~zcy~з~zdot~ż~zeetrf~ℨ~zfr~𝔷~zhcy~ж~zigrarr~⇝~zopf~𝕫~zscr~𝓏~~AMP~&~COPY~©~GT~>~LT~<~QUOT~"~REG~®',B.html4);var V={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376},z=String.fromCodePoint||function(e){return String.fromCharCode(Math.floor((e-65536)/1024)+55296,(e-65536)%1024+56320)};String.prototype.codePointAt;var W=function(){return(W=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},$=W(W({},B),{all:B.html5}),G={scope:"body",level:"all"},H=/&(?:#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);/g,K=/&(?:#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+)[;=]?/g,J={xml:{strict:H,attribute:K,body:/&(?:#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);?/g},html4:{strict:H,attribute:K,body:/&notin;|&(?:nbsp|iexcl|cent|pound|curren|yen|brvbar|sect|uml|copy|ordf|laquo|not|shy|reg|macr|deg|plusmn|sup2|sup3|acute|micro|para|middot|cedil|sup1|ordm|raquo|frac14|frac12|frac34|iquest|Agrave|Aacute|Acirc|Atilde|Auml|Aring|AElig|Ccedil|Egrave|Eacute|Ecirc|Euml|Igrave|Iacute|Icirc|Iuml|ETH|Ntilde|Ograve|Oacute|Ocirc|Otilde|Ouml|times|Oslash|Ugrave|Uacute|Ucirc|Uuml|Yacute|THORN|szlig|agrave|aacute|acirc|atilde|auml|aring|aelig|ccedil|egrave|eacute|ecirc|euml|igrave|iacute|icirc|iuml|eth|ntilde|ograve|oacute|ocirc|otilde|ouml|divide|oslash|ugrave|uacute|ucirc|uuml|yacute|thorn|yuml|quot|amp|lt|gt|#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);?/g},html5:{strict:H,attribute:K,body:/&centerdot;|&copysr;|&divideontimes;|&gtcc;|&gtcir;|&gtdot;|&gtlPar;|&gtquest;|&gtrapprox;|&gtrarr;|&gtrdot;|&gtreqless;|&gtreqqless;|&gtrless;|&gtrsim;|&ltcc;|&ltcir;|&ltdot;|&lthree;|&ltimes;|&ltlarr;|&ltquest;|&ltrPar;|&ltri;|&ltrie;|&ltrif;|&notin;|&notinE;|&notindot;|&notinva;|&notinvb;|&notinvc;|&notni;|&notniva;|&notnivb;|&notnivc;|&parallel;|&timesb;|&timesbar;|&timesd;|&(?:AElig|AMP|Aacute|Acirc|Agrave|Aring|Atilde|Auml|COPY|Ccedil|ETH|Eacute|Ecirc|Egrave|Euml|GT|Iacute|Icirc|Igrave|Iuml|LT|Ntilde|Oacute|Ocirc|Ograve|Oslash|Otilde|Ouml|QUOT|REG|THORN|Uacute|Ucirc|Ugrave|Uuml|Yacute|aacute|acirc|acute|aelig|agrave|amp|aring|atilde|auml|brvbar|ccedil|cedil|cent|copy|curren|deg|divide|eacute|ecirc|egrave|eth|euml|frac12|frac14|frac34|gt|iacute|icirc|iexcl|igrave|iquest|iuml|laquo|lt|macr|micro|middot|nbsp|not|ntilde|oacute|ocirc|ograve|ordf|ordm|oslash|otilde|ouml|para|plusmn|pound|quot|raquo|reg|sect|shy|sup1|sup2|sup3|szlig|thorn|times|uacute|ucirc|ugrave|uml|uuml|yacute|yen|yuml|#\d+|#[xX][\da-fA-F]+|[0-9a-zA-Z]+);?/g}},Z=W(W({},J),{all:J.html5}),Q=String.fromCharCode,Y=Q(65533),X=e.i(8737),ee=e.i(88947),et=e.i(11884),er=e.i(14747),ea=e.i(45706),ei=ee,es=e.i(92509),en=e.i(13438);function eo(e,t){return{options:"object"==typeof e?e:{},callback:"function"==typeof e?e:t}}function ep(e){return Object.keys(e).map(t=>[t,e[t]])}function ed(e){return encodeURIComponent(e).replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())}function el(e,t){return e.split("/").map(ed).join(t?"%2F":"/")}function ec(e,t=!1,r="",a=""){let i=e.getUTCFullYear(),s=e.getUTCMonth()+1,n=e.getUTCDate(),o=e.getUTCHours(),p=e.getUTCMinutes(),d=e.getUTCSeconds(),l=`${i.toString().padStart(4,"0")}${r}${s.toString().padStart(2,"0")}${r}${n.toString().padStart(2,"0")}`;return t&&(l=`${l}T${o.toString().padStart(2,"0")}${a}${p.toString().padStart(2,"0")}${a}${d.toString().padStart(2,"0")}Z`),l}function eu(){return globalThis.Deno&&globalThis.Deno.version&&globalThis.Deno.version.deno?`gl-deno/${globalThis.Deno.version.deno}`:`gl-node/${process.versions.node}`}function eh(){let e=(0,en.getPackageJSON)();return e.name.replace("@google-cloud","gcloud-node").replace("/","-")+"/"+e.version}function em(){return"ESM"}es.fileURLToPath;class ef extends ei.PassThrough{constructor(){super(...arguments),this.shouldEmitReading=!0,this.shouldEmitWriting=!0}_read(e){this.shouldEmitReading&&(this.emit("reading"),this.shouldEmitReading=!1),super._read(e)}_write(e,t,r){this.shouldEmitWriting&&(this.emit("writing"),this.shouldEmitWriting=!1),process.nextTick(()=>{super._write(e,t,r)})}_final(e){this.shouldEmitReading&&(this.emit("reading"),this.shouldEmitReading=!1),this.shouldEmitWriting&&(this.emit("writing"),this.shouldEmitWriting=!1),e(null)}}var eg=e.i(48628);let ev=(0,en.getPackageJSON)(),ey=Symbol.for("GCCL_GCS_CMD"),ew={timeout:6e4,gzip:!0,forever:!0,pool:{maxSockets:1/0}};class eb extends Error{constructor(e){if(super(),"object"!=typeof e){this.message=e||"";return}this.code=e.code,this.errors=e.errors,this.response=e.response;try{this.errors=JSON.parse(this.response.body).error.errors}catch(t){this.errors=e.errors}this.message=eb.createMultiErrorMessage(e,this.errors),Error.captureStackTrace(this)}static createMultiErrorMessage(e,t){let r=new Set;e.message&&r.add(e.message),t&&t.length?t.forEach(({message:e})=>r.add(e)):e.response&&e.response.body?r.add(function(e,t){var r=G.level,a=void 0===r?"all":r,i=G.scope,s=void 0===i?"xml"===a?"strict":"body":i;if(!e)return"";var n=Z[a][s],o=$[a].entities,p="attribute"===s,d="strict"===s;return e.replace(n,function(e){return function(e,t,r,a){var i=e,s=e[e.length-1];if(r&&"="===s)i=e;else if(a&&";"!==s)i=e;else{var n=t[e];if(n)i=n;else if("&"===e[0]&&"#"===e[1]){var o=e[2],p="x"==o||"X"==o?parseInt(e.substr(3),16):parseInt(e.substr(2));i=p>=1114111?Y:p>65535?z(p):Q(V[p]||p)}}return i}(e,o,p,d)})}(e.response.body.toString())):e.message||r.add("A failure occurred during this request.");let a=Array.from(r);return a.length>1&&((a=a.map((e,t)=>` ${t+1}. ${e}`)).unshift("Multiple errors occurred during the request. Please see the `errors` array for complete details.\n"),a.push("\n")),a.join("\n")}}class e_ extends Error{constructor(e){super(),this.errors=e.errors,this.name="PartialFailureError",this.response=e.response,this.message=eb.createMultiErrorMessage(e,this.errors)}}class ex extends ee.Transform{constructor(){super(...arguments),this.bytesRead=0}_transform(e,t,r){this.bytesRead+=e.length,this.emit("progress",{bytesWritten:this.bytesRead,contentLength:"*"}),this.push(e),r()}}let eN=new class{constructor(){this.ApiError=eb,this.PartialFailureError=e_}noop(){}handleResp(e,t,r,a){a=a||eN.noop;let i={err:e||null,...t&&eN.parseHttpRespMessage(t),...r&&eN.parseHttpRespBody(r)};!i.err&&t&&"object"==typeof i.body&&(i.resp.body=i.body),i.err&&t&&(i.err.response=t),a(i.err,i.body,i.resp)}parseHttpRespMessage(e){let t={resp:e};return(e.statusCode<200||e.statusCode>299)&&(t.err=new eb({errors:[],code:e.statusCode,message:e.statusMessage,response:e})),t}parseHttpRespBody(e){let t={body:e};if("string"==typeof e)try{t.body=JSON.parse(e)}catch(r){t.body=e}return t.body&&t.body.error&&(t.err=new eb(t.body.error)),t}makeWritableStream(e,t,r){var a;r=r||eN.noop;let i=new ex;i.on("progress",t=>e.emit("progress",t)),e.setWritable(i);let s={method:"POST",qs:{uploadType:"multipart"},timeout:0,maxRetries:0},n=t.metadata||{},o={...s,...t.request,qs:{...s.qs,...null==(a=t.request)?void 0:a.qs},multipart:[{"Content-Type":"application/json",body:JSON.stringify(n)},{"Content-Type":n.contentType||"application/octet-stream",body:i}]};t.makeAuthenticatedRequest(o,{onAuthenticated(t,a){t?e.destroy(t):(ew.headers=eN._getDefaultHeaders(o[ey]),et.teenyRequest.defaults(ew)(a,(t,a,i)=>{eN.handleResp(t,a,i,(t,i)=>{t?e.destroy(t):(e.emit("response",a),r(i))})}))}})}shouldRetryRequest(e){if(e){if(-1!==[408,429,500,502,503,504].indexOf(e.code))return!0;if(e.errors)for(let t of e.errors){let e=t.reason;if("rateLimitExceeded"===e||"userRateLimitExceeded"===e||e&&e.includes("EAI_AGAIN"))return!0}}return!1}makeAuthenticatedRequestFactory(e){let t,r={...e};r.projectId===eT&&delete r.projectId;let a=function(r,a){let i,s,n,o={...e};a||(o.stream=i=(0,eg.default)());let p="object"==typeof a?a:void 0,d="function"==typeof a?a:void 0;async function l(){s=await t.getProjectId()}let c=async(e,t)=>{let a=e,c=e&&"string"==typeof e.message&&e.message.indexOf("Could not load the default credentials")>-1;if(c&&(t=r),!e||c)try{t=eN.decorateRequest(t,s),e=null}catch(r){if(r instanceof M.MissingProjectIdError)try{await l(),t=eN.decorateRequest(t,s),e=null}catch(t){e=e||t}else e=e||r}e?i?i.destroy(e):(p&&p.onAuthenticated?p.onAuthenticated:d)(e):p&&p.onAuthenticated?p.onAuthenticated(null,t):n=eN.makeRequest(t,o,(e,...t)=>{e&&401===e.code&&a&&(e=a),d(e,...t)})};return((async()=>{try{let a=async()=>e.projectId&&e.projectId!==eT?e.projectId:!1===e.projectIdRequired?eT:l(),i=async()=>o.customEndpoint&&!o.useAuthWithCustomEndpoint?r:t.authorizeRequest(r),[n,p]=await Promise.all([a(),i()]);return n&&(s=n),c(null,p)}catch(e){return c(e)}})(),i)?i:{abort(){setImmediate(()=>{n&&(n.abort(),n=null)})}}};return a.getCredentials=(t=r.authClient instanceof C.GoogleAuth?r.authClient:new C.GoogleAuth({...r,authClient:r.authClient,clientOptions:r.clientOptions})).getCredentials.bind(t),a.authClient=t,a}makeRequest(e,t,r){var a,i,s,n,o;let p,d=!0;void 0!==t.autoRetry?d=t.autoRetry:(null==(a=t.retryOptions)?void 0:a.autoRetry)!==void 0&&(d=t.retryOptions.autoRetry);let l=3;void 0!==t.maxRetries?l=t.maxRetries:(null==(i=t.retryOptions)?void 0:i.maxRetries)!==void 0&&(l=t.retryOptions.maxRetries),ew.headers=this._getDefaultHeaders(e[ey]);let c={request:et.teenyRequest.defaults(ew),retries:!1!==d?l:0,noResponseRetries:!1!==d?l:0,shouldRetryFn(e){var r,a;let i=eN.parseHttpRespMessage(e).err;return(null==(r=t.retryOptions)?void 0:r.retryableErrorFn)?i&&(null==(a=t.retryOptions)?void 0:a.retryableErrorFn(i)):i&&eN.shouldRetryRequest(i)},maxRetryDelay:null==(s=t.retryOptions)?void 0:s.maxRetryDelay,retryDelayMultiplier:null==(n=t.retryOptions)?void 0:n.retryDelayMultiplier,totalTimeout:null==(o=t.retryOptions)?void 0:o.totalTimeout};if("number"==typeof e.maxRetries&&(c.retries=e.maxRetries,c.noResponseRetries=e.maxRetries),!t.stream)return(0,X.default)(e,c,(e,t,a)=>{eN.handleResp(e,t,a,r)});let u=t.stream;return"GET"===(e.method||"GET").toUpperCase()?(p=(0,X.default)(e,c),u.setReadable(p)):(p=c.request(e),u.setWritable(p)),p.on("error",u.destroy.bind(u)).on("response",u.emit.bind(u,"response")).on("complete",u.emit.bind(u,"complete")),u.abort=p.abort,u}decorateRequest(e,t){return delete e.autoPaginate,delete e.autoPaginateVal,delete e.objectMode,null!==e.qs&&"object"==typeof e.qs&&(delete e.qs.autoPaginate,delete e.qs.autoPaginateVal,e.qs=(0,M.replaceProjectIdToken)(e.qs,t)),Array.isArray(e.multipart)&&(e.multipart=e.multipart.map(e=>(0,M.replaceProjectIdToken)(e,t))),null!==e.json&&"object"==typeof e.json&&(delete e.json.autoPaginate,delete e.json.autoPaginateVal,e.json=(0,M.replaceProjectIdToken)(e.json,t)),e.uri=(0,M.replaceProjectIdToken)(e.uri,t),e}isCustomType(e,t){function r(e){return e.constructor&&e.constructor.name.toLowerCase()}let a=t.split("/"),i=a[0]&&a[0].toLowerCase(),s=a[1]&&a[1].toLowerCase();if(s&&r(e)!==s)return!1;let n=e;for(;;){if(r(n)===i)return!0;if(!(n=n.parent))return!1}}maybeOptionsOrCallback(e,t){return"function"==typeof e?[{},e]:[e,t]}_getDefaultHeaders(e){let t={"User-Agent":eh(),"x-goog-api-client":`${eu()} gccl/${ev.version}-${em()} gccl-invocation-id/${L()}`};return e&&(t["x-goog-api-client"]+=` gccl-gcs-cmd/${e}`),t}},eT="{{projectId}}";class eE{constructor(e,t={}){this.baseUrl=e.baseUrl,this.apiEndpoint=e.apiEndpoint,this.timeout=t.timeout,this.globalInterceptors=Array.isArray(t.interceptors_)?t.interceptors_:[],this.interceptors=[],this.packageJson=e.packageJson,this.projectId=t.projectId||eT,this.projectIdRequired=!1!==e.projectIdRequired,this.providedUserAgent=t.userAgent,this.universeDomain=t.universeDomain||C.DEFAULT_UNIVERSE,this.customEndpoint=e.customEndpoint||!1,this.useAuthWithCustomEndpoint=e.useAuthWithCustomEndpoint,this.makeAuthenticatedRequest=eN.makeAuthenticatedRequestFactory({...e,projectIdRequired:this.projectIdRequired,projectId:this.projectId,authClient:t.authClient||e.authClient,credentials:t.credentials,keyFile:t.keyFilename,email:t.email,clientOptions:{universeDomain:t.universeDomain,...t.clientOptions}}),this.authClient=this.makeAuthenticatedRequest.authClient,process.env.FUNCTION_NAME&&this.interceptors.push({request:e=>(e.forever=!1,e)})}getRequestInterceptors(){return[].slice.call(this.globalInterceptors).concat(this.interceptors).filter(e=>"function"==typeof e.request).map(e=>e.request)}getProjectId(e){if(!e)return this.getProjectIdAsync();this.getProjectIdAsync().then(t=>e(null,t),e)}async getProjectIdAsync(){let e=await this.authClient.getProjectId();return this.projectId===eT&&e&&(this.projectId=e),this.projectId}request_(e,t){let r=0===(e={...e,timeout:this.timeout}).uri.indexOf("http"),a=[this.baseUrl];this.projectIdRequired&&(e.projectId?(a.push("projects"),a.push(e.projectId)):(a.push("projects"),a.push(this.projectId))),a.push(e.uri),r&&a.splice(0,a.indexOf(e.uri)),e.uri=a.map(e=>e.replace(/^\/*|\/*$/g,"")).join("/").replace(/\/:/g,":");let i=this.getRequestInterceptors();(Array.isArray(e.interceptors_)?e.interceptors_:[]).forEach(e=>{"function"==typeof e.request&&i.push(e.request)}),i.forEach(t=>{e=t(e)}),delete e.interceptors_;let s=this.packageJson,n=eh();if(this.providedUserAgent&&(n=`${this.providedUserAgent} ${n}`),e.headers={...e.headers,"User-Agent":n,"x-goog-api-client":`${eu()} gccl/${s.version}-${em()} gccl-invocation-id/${L()}`},e[ey]&&(e.headers["x-goog-api-client"]+=` gccl-gcs-cmd/${e[ey]}`),e.shouldReturnStream)return this.makeAuthenticatedRequest(e);this.makeAuthenticatedRequest(e,t)}request(e,t){eE.prototype.request_.call(this,e,t)}requestStream(e){let t={...e,shouldReturnStream:!0};return eE.prototype.request_.call(this,t)}}var eA=e.i(6460),eS=e.i(27699);class ek extends eS.EventEmitter{constructor(e){super(),this.metadata={},this.baseUrl=e.baseUrl,this.parent=e.parent,this.id=e.id,this.createMethod=e.createMethod,this.methods=e.methods||{},this.interceptors=[],this.projectId=e.projectId,e.methods&&Object.getOwnPropertyNames(ek.prototype).filter(t=>!/^request/.test(t)&&!/^getRequestInterceptors/.test(t)&&this[t]===ek.prototype[t]&&!e.methods[t]).forEach(e=>{this[e]=void 0})}create(e,t){let r=this,a=[this.id];"function"==typeof e&&(t=e),"object"==typeof e&&a.push(e),a.push(function(...e){let[a,i]=e;a||(r.metadata=i.metadata,r.id&&i.metadata&&(r.id=i.metadata.id),e[1]=r),t(...e)}),this.createMethod.apply(null,a)}delete(e,t){var r;let[a,i]=eN.maybeOptionsOrCallback(e,t),s=a.ignoreNotFound;delete a.ignoreNotFound;let n="object"==typeof this.methods.delete&&this.methods.delete||{},o={method:"DELETE",uri:"",...n.reqOpts,qs:{...null==(r=n.reqOpts)?void 0:r.qs,...a}};ek.prototype.request.call(this,o,(e,t,r)=>{e&&404===e.code&&s&&(e=null),i(e,r)})}exists(e,t){let[r,a]=eN.maybeOptionsOrCallback(e,t);this.get(r,e=>{e?404===e.code?a(null,!1):a(e):a(null,!0)})}get(e,t){let r=this,[a,i]=eN.maybeOptionsOrCallback(e,t),s=Object.assign({},a),n=s.autoCreate&&"function"==typeof this.create;function o(e,t,a){e?409===e.code?r.get(s,i):i(e,null,a):i(null,t,a)}delete s.autoCreate,this.getMetadata(s,(e,t)=>{if(e){if(404===e.code&&n){let e=[];Object.keys(s).length>0&&e.push(s),e.push(o),r.create(...e);return}i(e,null,t);return}i(null,r,t)})}getMetadata(e,t){var r;let[a,i]=eN.maybeOptionsOrCallback(e,t),s="object"==typeof this.methods.getMetadata&&this.methods.getMetadata||{},n={uri:"",...s.reqOpts,qs:{...null==(r=s.reqOpts)?void 0:r.qs,...a}};ek.prototype.request.call(this,n,(e,t,r)=>{this.metadata=t,i(e,this.metadata,r)})}getRequestInterceptors(){let e=this.interceptors.filter(e=>"function"==typeof e.request).map(e=>e.request);return this.parent.getRequestInterceptors().concat(e)}setMetadata(e,t,r){var a,i;let[s,n]=eN.maybeOptionsOrCallback(t,r),o="object"==typeof this.methods.setMetadata&&this.methods.setMetadata||{},p={method:"PATCH",uri:"",...o.reqOpts,json:{...null==(a=o.reqOpts)?void 0:a.json,...e},qs:{...null==(i=o.reqOpts)?void 0:i.qs,...s}};ek.prototype.request.call(this,p,(e,t,r)=>{this.metadata=t,n(e,this.metadata,r)})}request_(e,t){e={...e},this.projectId&&(e.projectId=this.projectId);let r=0===e.uri.indexOf("http"),a=[this.baseUrl,this.id||"",e.uri];r&&a.splice(0,a.indexOf(e.uri)),e.uri=a.filter(e=>e.trim()).map(e=>e.replace(/^\/*|\/*$/g,"")).join("/");let i=Array.isArray(e.interceptors_)?e.interceptors_:[],s=[].slice.call(this.interceptors);if(e.interceptors_=i.concat(s),e.shouldReturnStream)return this.parent.requestStream(e);this.parent.request(e,t)}request(e,t){this.request_(e,t)}requestStream(e){let t={...e,shouldReturnStream:!0};return this.request_(t)}}(0,eA.promisifyAll)(ek,{exclude:["getRequestInterceptors"]});var eO=e.i(28070),eC=e.i(22734),eI=e.i(51452),eR=e.i(57427),eD=e.i(24361),eP=e.i(77441);class ej{constructor(){this.owners={},this.readers={},this.writers={},this.owners={},this.readers={},this.writers={},ej.roles.forEach(this._assignAccessMethods.bind(this))}_assignAccessMethods(e){let t=ej.accessMethods,r=ej.entities;this[e.toLowerCase()+"s"]=r.reduce((r,a)=>{let i="-"===a.charAt(a.length-1);return t.forEach(t=>{let s=t+a[0].toUpperCase()+a.substring(1);i&&(s=s.replace("-","")),r[s]=(r,s,n)=>{let o;"function"==typeof s&&(n=s,s={}),i?o=a+r:(o=a,n=r);let p=[s=Object.assign({entity:o,role:e},s)];return"function"==typeof n&&p.push(n),this[t].apply(this,p)}}),r},{})}}ej.accessMethods=["add","delete"],ej.entities=["allAuthenticatedUsers","allUsers","domain-","group-","project-","user-"],ej.roles=["OWNER","READER","WRITER"];class eq extends ej{constructor(e){super(),this.pathPrefix=e.pathPrefix,this.request_=e.request}add(e,t){let r={};e.generation&&(r.generation=e.generation),e.userProject&&(r.userProject=e.userProject),this.request({method:"POST",uri:"",qs:r,maxRetries:0,json:{entity:e.entity,role:e.role.toUpperCase()}},(e,r)=>{e?t(e,null,r):t(null,this.makeAclObject_(r),r)})}delete(e,t){let r={};e.generation&&(r.generation=e.generation),e.userProject&&(r.userProject=e.userProject),this.request({method:"DELETE",uri:"/"+encodeURIComponent(e.entity),qs:r},(e,r)=>{t(e,r)})}get(e,t){let r="object"==typeof e?e:null,a="function"==typeof e?e:t,i="",s={};r&&(i="/"+encodeURIComponent(r.entity),r.generation&&(s.generation=r.generation),r.userProject&&(s.userProject=r.userProject)),this.request({uri:i,qs:s},(e,t)=>{e?a(e,null,t):a(null,t.items?t.items.map(this.makeAclObject_):this.makeAclObject_(t),t)})}update(e,t){let r={};e.generation&&(r.generation=e.generation),e.userProject&&(r.userProject=e.userProject),this.request({method:"PUT",uri:"/"+encodeURIComponent(e.entity),qs:r,json:{role:e.role.toUpperCase()}},(e,r)=>{e?t(e,null,r):t(null,this.makeAclObject_(r),r)})}makeAclObject_(e){let t={entity:e.entity,role:e.role};return e.projectTeam&&(t.projectTeam=e.projectTeam),t}request(e,t){e.uri=this.pathPrefix+e.uri,this.request_(e,t)}}(0,eA.promisifyAll)(eq,{exclude:["request"]});var eL=e.i(87148),eM=e.i(62011),eF=ee,eU=function(e,t,r,a,i){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?i.call(e,r):i?i.value=r:t.set(e,r),r},eB=function(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)};let eV=(0,en.getPackageJSON)(),ez=/^(\w*):\/\//;class eW extends eF.Writable{constructor(e){var t;if(super(e),l.add(this),this.numBytesWritten=0,this.numRetries=0,this.currentInvocationId={checkUploadStatus:L(),chunk:L(),uri:L()},this.writeBuffers=[],this.numChunksReadInRequest=0,this.localWriteCache=[],this.localWriteCacheByteLength=0,this.upstreamEnded=!1,c.set(this,void 0),!(e=e||{}).bucket||!e.file)throw Error("A bucket and file name are required");if(e.offset&&!e.uri)throw RangeError("Cannot provide an `offset` without providing a `uri`");if(e.isPartialUpload&&!e.chunkSize)throw RangeError("Cannot set `isPartialUpload` without providing a `chunkSize`");e.authConfig=e.authConfig||{},e.authConfig.scopes=["https://www.googleapis.com/auth/devstorage.full_control"],this.authClient=e.authClient||new C.GoogleAuth(e.authConfig);const r=e.universeDomain||C.DEFAULT_UNIVERSE;if(this.apiEndpoint=`https://storage.${r}`,e.apiEndpoint&&e.apiEndpoint!==this.apiEndpoint){this.apiEndpoint=this.sanitizeEndpoint(e.apiEndpoint);const t=new URL(this.apiEndpoint).hostname,a=t===r,i=t===C.DEFAULT_UNIVERSE,s=t.slice(-(r.length+1))===`.${r}`,n=t.slice(-(C.DEFAULT_UNIVERSE.length+1))===`.${C.DEFAULT_UNIVERSE}`;a||i||s||n||!0===e.useAuthWithCustomEndpoint||(this.authClient=eM)}this.baseURI=`${this.apiEndpoint}/upload/storage/v1/b`,this.bucket=e.bucket;const a=[e.bucket,e.file];if("number"==typeof e.generation&&a.push(`${e.generation}`),this.cacheKey=a.join("/"),this.customRequestOptions=e.customRequestOptions||{},this.file=e.file,this.generation=e.generation,this.kmsKeyName=e.kmsKeyName,this.metadata=e.metadata||{},this.offset=e.offset,this.origin=e.origin,this.params=e.params||{},this.userProject=e.userProject,this.chunkSize=e.chunkSize,this.retryOptions=e.retryOptions,this.isPartialUpload=null!=(t=e.isPartialUpload)&&t,e.key)if("string"==typeof e.key){const t=Buffer.from(e.key).toString("base64");this.encryption={key:t,hash:(0,I.createHash)("sha256").update(e.key).digest("base64")}}else{const t=e.key.toString("base64");this.encryption={key:t,hash:(0,I.createHash)("sha256").update(e.key).digest("base64")}}this.predefinedAcl=e.predefinedAcl,e.private&&(this.predefinedAcl="private"),e.public&&(this.predefinedAcl="publicRead");const i=e.retryOptions.autoRetry;this.uriProvidedManually=!!e.uri,this.uri=e.uri,this.offset&&(this.numBytesWritten=this.offset),this.numRetries=0,i||(e.retryOptions.maxRetries=0),this.timeOfFirstRequest=Date.now();const s=e.metadata?Number(e.metadata.contentLength):NaN;this.contentLength=isNaN(s)?"*":s,eU(this,c,e[ey],"f"),this.once("writing",()=>{this.uri?this.continueUploading():this.createURI(e=>{if(e)return this.destroy(e);this.startUploading()})})}_final(e=()=>{}){this.upstreamEnded=!0,this.once("uploadFinished",e),process.nextTick(()=>{this.emit("upstreamFinished"),this.emit("writing")})}_write(e,t,r=()=>{}){this.emit("writing"),this.writeBuffers.push("string"==typeof e?Buffer.from(e,t):e),this.once("readFromChunkBuffer",r),process.nextTick(()=>this.emit("wroteToChunkBuffer"))}prependLocalBufferToUpstream(e){let t=[];if(e){let r=0;for(;e>r;){let a=this.localWriteCache.pop();if(!a)break;if((r+=a.byteLength)>e){let t=r-e;a=a.subarray(t),r-=t}t.unshift(a)}}else t=this.localWriteCache;let r=this.writeBuffers;for(let e of(this.writeBuffers=t,r))this.writeBuffers.push(e);eB(this,l,"m",u).call(this)}*pullFromChunkBuffer(e){for(;e;){let t=this.writeBuffers.shift();if(!t)break;let r=t;t.byteLength>e?(r=t.subarray(0,e),this.writeBuffers.unshift(t.subarray(e)),e=0):e-=t.byteLength,yield r,this.emit("readFromChunkBuffer")}}async waitForNextChunk(){return await new Promise(e=>{if(this.writeBuffers.length)return e(!0);if(this.upstreamEnded)return e(!1);let t=()=>(a(),e(!0)),r=()=>(a(),this.writeBuffers.length)?e(!0):e(!1),a=()=>{this.removeListener("wroteToChunkBuffer",t),this.removeListener("upstreamFinished",r)};this.once("wroteToChunkBuffer",t),this.once("upstreamFinished",r)})}async *upstreamIterator(e=1/0){for(;e&&await this.waitForNextChunk();)for(let t of this.pullFromChunkBuffer(e))e-=t.byteLength,yield t}createURI(e){if(!e)return this.createURIAsync();this.createURIAsync().then(t=>e(null,t),e)}async createURIAsync(){let e={...this.metadata},t={};e.contentLength&&(t["X-Upload-Content-Length"]=e.contentLength.toString(),delete e.contentLength),e.contentType&&(t["X-Upload-Content-Type"]=e.contentType,delete e.contentType);let r=`${eu()} gccl/${eV.version}-${em()} gccl-invocation-id/${this.currentInvocationId.uri}`;eB(this,c,"f")&&(r+=` gccl-gcs-cmd/${eB(this,c,"f")}`);let a={method:"POST",url:[this.baseURI,this.bucket,"o"].join("/"),params:Object.assign({name:this.file,uploadType:"resumable"},this.params),data:e,headers:{"User-Agent":eh(),"x-goog-api-client":r,...t}};e.contentLength&&(a.headers["X-Upload-Content-Length"]=e.contentLength.toString()),e.contentType&&(a.headers["X-Upload-Content-Type"]=e.contentType),void 0!==this.generation&&(a.params.ifGenerationMatch=this.generation),this.kmsKeyName&&(a.params.kmsKeyName=this.kmsKeyName),this.predefinedAcl&&(a.params.predefinedAcl=this.predefinedAcl),this.origin&&(a.headers.Origin=this.origin);let i=await (0,eP.default)(async e=>{var t,r,i;try{let e=await this.makeRequest(a);return this.currentInvocationId.uri=L(),e.headers.location}catch(s){let a={code:null==(t=s.response)?void 0:t.status,name:null==(r=s.response)?void 0:r.statusText,message:null==(i=s.response)?void 0:i.statusText,errors:[{reason:s.code}]};if(!(this.retryOptions.maxRetries>0&&this.retryOptions.retryableErrorFn(a)))return e(s);throw s}},{retries:this.retryOptions.maxRetries,factor:this.retryOptions.retryDelayMultiplier,maxTimeout:1e3*this.retryOptions.maxRetryDelay,maxRetryTime:1e3*this.retryOptions.totalTimeout});return this.uri=i,this.offset=0,this.emit("uri",i),i}async continueUploading(){return null!=this.offset||await this.getAndSetOffset(),this.startUploading()}async startUploading(){let e,t=!!this.chunkSize,r=!1;if(this.numChunksReadInRequest=0,this.offset||(this.offset=0),this.offset<this.numBytesWritten){let e=this.numBytesWritten-this.offset,t=`The offset is lower than the number of bytes written. The server has ${this.offset} bytes and while ${this.numBytesWritten} bytes has been uploaded - thus ${e} bytes are missing. Stopping as this could result in data loss. Initiate a new upload to continue.`;this.emit("error",RangeError(t));return}if(this.numBytesWritten<this.offset){let e=this.offset-this.numBytesWritten;for await(let t of this.upstreamIterator(e));this.numBytesWritten=this.offset}"number"==typeof this.contentLength&&(e=this.contentLength-this.numBytesWritten),this.chunkSize&&(e=e?Math.min(this.chunkSize,e):this.chunkSize);let a=this.upstreamIterator(e),i=new eF.Readable({read:async()=>{r&&i.push(null);let e=await a.next();e.value&&(this.numChunksReadInRequest++,t||eB(this,l,"m",u).call(this),eB(this,l,"m",h).call(this,e.value),this.numBytesWritten+=e.value.byteLength,this.emit("progress",{bytesWritten:this.numBytesWritten,contentLength:this.contentLength}),i.push(e.value)),e.done&&i.push(null)}}),s=`${eu()} gccl/${eV.version}-${em()} gccl-invocation-id/${this.currentInvocationId.chunk}`;eB(this,c,"f")&&(s+=` gccl-gcs-cmd/${eB(this,c,"f")}`);let n={"User-Agent":eh(),"x-goog-api-client":s};if(t){for await(let t of this.upstreamIterator(e))eB(this,l,"m",h).call(this,t);let t=this.localWriteCacheByteLength,r=!await this.waitForNextChunk();this.prependLocalBufferToUpstream();let a=this.contentLength;"number"!=typeof this.contentLength&&r&&!this.isPartialUpload&&(a=t+this.numBytesWritten);let i=t+this.numBytesWritten-1;n["Content-Length"]=t,n["Content-Range"]=`bytes ${this.offset}-${i}/${a}`}else n["Content-Range"]=`bytes ${this.offset}-*/${this.contentLength}`;let o={method:"PUT",url:this.uri,headers:n,body:i};try{let e=await this.makeRequestStream(o);e&&(r=!0,await this.responseHandler(e))}catch(e){if(this.retryOptions.retryableErrorFn(e))return void this.attemptDelayedRetry({status:NaN,data:e});this.destroy(e)}}async responseHandler(e){if(e.data.error)return void this.destroy(e.data.error);this.currentInvocationId.chunk=L();let t=await this.waitForNextChunk(),r=this.chunkSize&&308===e.status&&e.headers.range&&t,a=this.isPartialUpload&&308===e.status&&!t;if(r){let t=e.headers.range;this.offset=Number(t.split("-")[1])+1;let r=this.numBytesWritten-this.offset;r?(this.prependLocalBufferToUpstream(r),this.numBytesWritten-=r):eB(this,l,"m",u).call(this),this.continueUploading()}else if(this.isSuccessfulResponse(e.status)||a)eB(this,l,"m",u).call(this),e&&e.data&&(e.data.size=Number(e.data.size)),this.emit("metadata",e.data),this.emit("uploadFinished");else{let t=Error("Upload failed");t.code=e.status,t.name="Upload failed",(null==e?void 0:e.data)&&(t.errors=[null==e?void 0:e.data]),this.destroy(t)}}async checkUploadStatus(e={}){let t=`${eu()} gccl/${eV.version}-${em()} gccl-invocation-id/${this.currentInvocationId.checkUploadStatus}`;eB(this,c,"f")&&(t+=` gccl-gcs-cmd/${eB(this,c,"f")}`);let r={method:"PUT",url:this.uri,headers:{"Content-Length":0,"Content-Range":"bytes */*","User-Agent":eh(),"x-goog-api-client":t}};try{let e=await this.makeRequest(r);return this.currentInvocationId.checkUploadStatus=L(),e}catch(r){if(!1===e.retry||!(r instanceof Error)||!this.retryOptions.retryableErrorFn(r))throw r;let t=this.getRetryDelay();if(t<=0)throw r;return await new Promise(e=>setTimeout(e,t)),this.checkUploadStatus(e)}}async getAndSetOffset(){try{let e=await this.checkUploadStatus({retry:!1});if(308===e.status&&"string"==typeof e.headers.range){this.offset=Number(e.headers.range.split("-")[1])+1;return}this.offset=0}catch(e){if(this.retryOptions.retryableErrorFn(e))return void this.attemptDelayedRetry({status:NaN,data:e});this.destroy(e)}}async makeRequest(e){this.encryption&&(e.headers=e.headers||{},e.headers["x-goog-encryption-algorithm"]="AES256",e.headers["x-goog-encryption-key"]=this.encryption.key.toString(),e.headers["x-goog-encryption-key-sha256"]=this.encryption.hash.toString()),this.userProject&&(e.params=e.params||{},e.params.userProject=this.userProject),e.validateStatus=e=>this.isSuccessfulResponse(e)||308===e;let t={...this.customRequestOptions,...e,headers:{...this.customRequestOptions.headers,...e.headers}},r=await this.authClient.request(t);if(r.data&&r.data.error)throw r.data.error;return r}async makeRequestStream(e){let t=new eL.default,r=()=>t.abort();this.once("error",r),this.userProject&&(e.params=e.params||{},e.params.userProject=this.userProject),e.signal=t.signal,e.validateStatus=()=>!0;let a={...this.customRequestOptions,...e,headers:{...this.customRequestOptions.headers,...e.headers}},i=await this.authClient.request(a),s=this.onResponse(i);return this.removeListener("error",r),s?i:null}onResponse(e){return 200!==e.status&&this.retryOptions.retryableErrorFn({code:e.status,message:e.statusText,name:e.statusText})?(this.attemptDelayedRetry(e),!1):(this.emit("response",e),!0)}attemptDelayedRetry(e){if(this.numRetries<this.retryOptions.maxRetries){if(404===e.status&&0===this.numChunksReadInRequest)this.startUploading();else{let t=this.getRetryDelay();if(t<=0)return void this.destroy(Error(`Retry total time limit exceeded - ${JSON.stringify(e.data)}`));this.numBytesWritten-=this.localWriteCacheByteLength,this.prependLocalBufferToUpstream(),this.offset=void 0,setTimeout(this.continueUploading.bind(this),t)}this.numRetries++}else this.destroy(Error(`Retry limit exceeded - ${JSON.stringify(e.data)}`))}getRetryDelay(){let e=Math.round(1e3*Math.random()),t=1e3*Math.pow(this.retryOptions.retryDelayMultiplier,this.numRetries)+e,r=1e3*this.retryOptions.totalTimeout-(Date.now()-this.timeOfFirstRequest);return Math.min(t,1e3*this.retryOptions.maxRetryDelay,r)}sanitizeEndpoint(e){return ez.test(e)||(e=`https://${e}`),e.replace(/\/+$/,"")}isSuccessfulResponse(e){return e>=200&&e<300}}c=new WeakMap,l=new WeakSet,u=function(){this.localWriteCache=[],this.localWriteCacheByteLength=0},h=function(e){this.localWriteCache.push(e),this.localWriteCacheByteLength+=e.byteLength};var e$=e.i(6461);(t=m||(m={})).ACCESSIBLE_DATE_INVALID="The accessible at date provided was invalid.",t.EXPIRATION_BEFORE_ACCESSIBLE_DATE="An expiration date cannot be before accessible date.",t.X_GOOG_CONTENT_SHA256="The header X-Goog-Content-SHA256 must be a hexadecimal string.";class eG{constructor(e,t,r,a=new td){this.auth=e,this.bucket=t,this.file=r,this.storage=a}getSignedUrl(e){let t,r,a=this.parseExpires(e.expires),i=e.method,s=this.parseAccessibleAt(e.accessibleAt);if(a<s)throw Error(m.EXPIRATION_BEFORE_ACCESSIBLE_DATE);let n=e.virtualHostedStyle||!1;e.cname?t=e.cname:n&&(t=`https://${this.bucket.name}.storage.${this.storage.universeDomain}`);let o=Object.assign({},e,{method:i,expiration:a,accessibleAt:new Date(1e3*s),bucket:this.bucket.name,file:this.file?el(this.file.name,!1):void 0});t&&(o.cname=t);let p=e.version||"v2";if("v2"===p)r=this.getSignedUrlV2(o);else if("v4"===p)r=this.getSignedUrlV4(o);else throw Error(`Invalid signed URL version: ${p}. Supported versions are 'v2' and 'v4'.`);return r.then(t=>{var r,a;t=Object.assign(t,e.queryParams);let i=new es.URL((null==(r=e.host)?void 0:r.toString())||o.cname||this.storage.apiEndpoint);return i.pathname=this.getResourcePath(!!o.cname,this.bucket.name,o.file),a=t,i.search=ea.stringify(a,"&","=",{encodeURIComponent:e=>el(e,!0)}),i.href})}getSignedUrlV2(e){let t=this.getCanonicalHeaders(e.extensionHeaders||{}),r=this.getResourcePath(!1,e.bucket,e.file),a=[e.method,e.contentMd5||"",e.contentType||"",e.expiration,t+r].join("\n");return(async()=>{var t;let r=this.auth;try{let i=await r.sign(a,null==(t=e.signingEndpoint)?void 0:t.toString());return{GoogleAccessId:(await r.getCredentials()).client_email,Expires:e.expiration,Signature:i}}catch(t){let e=new eH(t.message);throw e.stack=t.stack,e}})()}getSignedUrlV4(e){var t;let r;e.accessibleAt=e.accessibleAt?e.accessibleAt:new Date;let a=e.expiration-.001*e.accessibleAt.valueOf();if(a>604800)throw Error("Max allowed expiration is seven days (604800 seconds).");let i=Object.assign({},e.extensionHeaders);i.host=new es.URL((null==(t=e.host)?void 0:t.toString())||e.cname||this.storage.apiEndpoint).hostname,e.contentMd5&&(i["content-md5"]=e.contentMd5),e.contentType&&(i["content-type"]=e.contentType);let s=i["x-goog-content-sha256"];if(s){if("string"!=typeof s||!/[A-Fa-f0-9]{40}/.test(s))throw Error(m.X_GOOG_CONTENT_SHA256);r=s}let n=Object.keys(i).map(e=>e.toLowerCase()).sort().join(";"),o=this.getCanonicalHeaders(i),p=ec(e.accessibleAt),d=`${p}/auto/storage/goog4_request`;return(async()=>{var t;let i=await this.auth.getCredentials(),s=`${i.client_email}/${d}`,p=ec(e.accessibleAt?e.accessibleAt:new Date,!0),l={"X-Goog-Algorithm":"GOOG4-RSA-SHA256","X-Goog-Credential":s,"X-Goog-Date":p,"X-Goog-Expires":a.toString(10),"X-Goog-SignedHeaders":n,...e.queryParams||{}},c=this.getCanonicalQueryParams(l),u=this.getCanonicalRequest(e.method,this.getResourcePath(!!e.cname,e.bucket,e.file),c,o,n,r),h=["GOOG4-RSA-SHA256",p,d,I.createHash("sha256").update(u).digest("hex")].join("\n");try{let r=await this.auth.sign(h,null==(t=e.signingEndpoint)?void 0:t.toString()),a=Buffer.from(r,"base64").toString("hex");return Object.assign({},l,{"X-Goog-Signature":a})}catch(t){let e=new eH(t.message);throw e.stack=t.stack,e}})()}getCanonicalHeaders(e){return ep(e).map(([e,t])=>[e.toLowerCase(),t]).sort((e,t)=>e[0].localeCompare(t[0])).filter(([,e])=>void 0!==e).map(([e,t])=>{let r=`${t}`.trim().replace(/\s{2,}/g," ");return`${e}:${r}
26
- `}).join("")}getCanonicalRequest(e,t,r,a,i,s){return[e,t,r,a,i,s||"UNSIGNED-PAYLOAD"].join("\n")}getCanonicalQueryParams(e){return ep(e).map(([e,t])=>[el(e,!0),el(t,!0)]).sort((e,t)=>e[0]<t[0]?-1:1).map(([e,t])=>`${e}=${t}`).join("&")}getResourcePath(e,t,r){return e?"/"+(r||""):r?`/${t}/${r}`:`/${t}`}parseExpires(e,t=new Date){let r=new Date(e).valueOf();if(isNaN(r))throw Error(k.EXPIRATION_DATE_INVALID);if(r<t.valueOf())throw Error(k.EXPIRATION_DATE_PAST);return Math.floor(r/1e3)}parseAccessibleAt(e){let t=new Date(e||new Date).valueOf();if(isNaN(t))throw Error(m.ACCESSIBLE_DATE_INVALID);return Math.floor(t/1e3)}}class eH extends Error{constructor(){super(...arguments),this.name="SigningError"}}var eK=function(e,t,r,a,i){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?i.call(e,r):i?i.value=r:t.set(e,r),r},eJ=function(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)};let eZ=[0,0xf26b8303,0xe13b70f7,0x1350f3f4,0xc79a971f,0x35f1141c,0x26a1e7e8,0xd4ca64eb,0x8ad958cf,0x78b2dbcc,0x6be22838,0x9989ab3b,0x4d43cfd0,0xbf284cd3,0xac78bf27,0x5e133c24,0x105ec76f,0xe235446c,0xf165b798,0x30e349b,0xd7c45070,0x25afd373,0x36ff2087,0xc494a384,0x9a879fa0,0x68ec1ca3,0x7bbcef57,0x89d76c54,0x5d1d08bf,0xaf768bbc,0xbc267848,0x4e4dfb4b,0x20bd8ede,0xd2d60ddd,0xc186fe29,0x33ed7d2a,0xe72719c1,0x154c9ac2,0x61c6936,0xf477ea35,0xaa64d611,0x580f5512,0x4b5fa6e6,0xb93425e5,0x6dfe410e,0x9f95c20d,0x8cc531f9,0x7eaeb2fa,0x30e349b1,0xc288cab2,0xd1d83946,0x23b3ba45,0xf779deae,0x5125dad,0x1642ae59,0xe4292d5a,0xba3a117e,0x4851927d,0x5b016189,0xa96ae28a,0x7da08661,0x8fcb0562,0x9c9bf696,0x6ef07595,0x417b1dbc,0xb3109ebf,0xa0406d4b,0x522bee48,0x86e18aa3,0x748a09a0,0x67dafa54,0x95b17957,0xcba24573,0x39c9c670,0x2a993584,0xd8f2b687,0xc38d26c,0xfe53516f,0xed03a29b,0x1f682198,0x5125dad3,0xa34e59d0,0xb01eaa24,0x42752927,0x96bf4dcc,0x64d4cecf,0x77843d3b,0x85efbe38,0xdbfc821c,0x2997011f,0x3ac7f2eb,0xc8ac71e8,0x1c661503,0xee0d9600,0xfd5d65f4,0xf36e6f7,0x61c69362,0x93ad1061,0x80fde395,0x72966096,0xa65c047d,0x5437877e,0x4767748a,0xb50cf789,0xeb1fcbad,0x197448ae,0xa24bb5a,0xf84f3859,0x2c855cb2,0xdeeedfb1,0xcdbe2c45,0x3fd5af46,0x7198540d,0x83f3d70e,0x90a324fa,0x62c8a7f9,0xb602c312,0x44694011,0x5739b3e5,0xa55230e6,0xfb410cc2,0x92a8fc1,0x1a7a7c35,0xe811ff36,0x3cdb9bdd,0xceb018de,0xdde0eb2a,0x2f8b6829,0x82f63b78,0x709db87b,0x63cd4b8f,0x91a6c88c,0x456cac67,0xb7072f64,0xa457dc90,0x563c5f93,0x82f63b7,0xfa44e0b4,0xe9141340,0x1b7f9043,0xcfb5f4a8,0x3dde77ab,0x2e8e845f,0xdce5075c,0x92a8fc17,0x60c37f14,0x73938ce0,0x81f80fe3,0x55326b08,0xa759e80b,0xb4091bff,0x466298fc,0x1871a4d8,0xea1a27db,0xf94ad42f,0xb21572c,0xdfeb33c7,0x2d80b0c4,0x3ed04330,0xccbbc033,0xa24bb5a6,0x502036a5,0x4370c551,0xb11b4652,0x65d122b9,0x97baa1ba,0x84ea524e,0x7681d14d,0x2892ed69,0xdaf96e6a,0xc9a99d9e,0x3bc21e9d,0xef087a76,0x1d63f975,0xe330a81,0xfc588982,0xb21572c9,0x407ef1ca,0x532e023e,0xa145813d,0x758fe5d6,0x87e466d5,0x94b49521,0x66df1622,0x38cc2a06,0xcaa7a905,0xd9f75af1,0x2b9cd9f2,0xff56bd19,0xd3d3e1a,0x1e6dcdee,0xec064eed,0xc38d26c4,0x31e6a5c7,0x22b65633,0xd0ddd530,0x417b1db,0xf67c32d8,0xe52cc12c,0x1747422f,0x49547e0b,0xbb3ffd08,0xa86f0efc,0x5a048dff,0x8ecee914,0x7ca56a17,0x6ff599e3,0x9d9e1ae0,0xd3d3e1ab,0x21b862a8,0x32e8915c,0xc083125f,0x144976b4,0xe622f5b7,0xf5720643,0x7198540,0x590ab964,0xab613a67,0xb831c993,0x4a5a4a90,0x9e902e7b,0x6cfbad78,0x7fab5e8c,0x8dc0dd8f,0xe330a81a,0x115b2b19,0x20bd8ed,0xf0605bee,0x24aa3f05,0xd6c1bc06,0xc5914ff2,0x37faccf1,0x69e9f0d5,0x9b8273d6,0x88d28022,0x7ab90321,0xae7367ca,0x5c18e4c9,0x4f48173d,0xbd23943e,0xf36e6f75,0x105ec76,0x12551f82,0xe03e9c81,0x34f4f86a,0xc69f7b69,0xd5cf889d,0x27a40b9e,0x79b737ba,0x8bdcb4b9,0x988c474d,0x6ae7c44e,0xbe2da0a5,0x4c4623a6,0x5f16d052,0xad7d5351],eQ=new Int32Array(eZ),eY=()=>new eX;class eX{constructor(e=0){f.set(this,0),eK(this,f,e,"f")}update(e){let t=0xffffffff^eJ(this,f,"f");for(let r of e)t=eX.CRC32C_EXTENSION_TABLE[(r^t)&255]^t>>>8;eK(this,f,0xffffffff^t,"f")}validate(e){return"number"==typeof e?e===eJ(this,f,"f"):"string"==typeof e?e===this.toString():Buffer.isBuffer(e)?0===Buffer.compare(e,this.toBuffer()):e.toString()===this.toString()}toBuffer(){let e=Buffer.alloc(4);return e.writeInt32BE(eJ(this,f,"f")),e}toJSON(){return this.toString()}toString(){return this.toBuffer().toString("base64")}valueOf(){return eJ(this,f,"f")}static fromBuffer(e){let t;if(4!==(t=Buffer.isBuffer(e)?e:"buffer"in e?Buffer.from(e.buffer):Buffer.from(e)).byteLength){let e;throw RangeError((e=t.byteLength,`Buffer expected to equal 4 bytes, not ${e}`))}return new eX(t.readInt32BE())}static async fromFile(e){let t=new eX;return await new Promise((r,a)=>{(0,eC.createReadStream)(e).on("data",e=>{"string"==typeof e?t.update(Buffer.from(e)):t.update(e)}).on("end",()=>r()).on("error",a)}),t}static fromString(e){let t=Buffer.from(e,"base64");if(4!==t.byteLength){let e;throw RangeError((e=t.byteLength,`base64-encoded data expected to equal 4 bytes, not ${e}`))}return this.fromBuffer(t)}static fromNumber(e){if(!Number.isSafeInteger(e)||e>0x100000000||e<-0x100000000){let t;throw RangeError((t=e,`Number expected to be a safe, unsigned 32-bit integer, not ${t}`))}return new eX(e)}static from(e){return"number"==typeof e?this.fromNumber(e):"string"==typeof e?this.fromString(e):"byteLength"in e?this.fromBuffer(e):this.fromString(e.toString())}}f=new WeakMap,eX.CRC32C_EXTENSIONS=eZ,eX.CRC32C_EXTENSION_TABLE=eQ;var e1=ee,e0=function(e,t,r,a,i){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?i.call(e,r):i?i.value=r:t.set(e,r),r},e2=function(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)};class e6 extends e1.Transform{constructor(e={}){if(super(),this.updateHashesOnly=!1,g.set(this,void 0),v.set(this,void 0),y.set(this,""),this.crc32cEnabled=!!e.crc32c,this.md5Enabled=!!e.md5,this.updateHashesOnly=!!e.updateHashesOnly,this.crc32cExpected=e.crc32cExpected,this.md5Expected=e.md5Expected,this.crc32cEnabled)if(e.crc32cInstance)e0(this,g,e.crc32cInstance,"f");else{const t=e.crc32cGenerator||eY;e0(this,g,t(),"f")}this.md5Enabled&&e0(this,v,(0,I.createHash)("md5"),"f")}get crc32c(){var e;return null==(e=e2(this,g,"f"))?void 0:e.toString()}_flush(e){if(e2(this,v,"f")&&e0(this,y,e2(this,v,"f").digest("base64"),"f"),this.updateHashesOnly)return void e();let t=this.crc32cEnabled||this.md5Enabled;if(this.crc32cEnabled&&this.crc32cExpected&&(t=!this.test("crc32c",this.crc32cExpected)),this.md5Enabled&&this.md5Expected&&(t=!this.test("md5",this.md5Expected)),t){let t=new e5(x.DOWNLOAD_MISMATCH);t.code="CONTENT_DOWNLOAD_MISMATCH",e(t)}else e()}_transform(e,t,r){this.push(e,t);try{e2(this,g,"f")&&e2(this,g,"f").update(e),e2(this,v,"f")&&e2(this,v,"f").update(e),r()}catch(e){r(e)}}test(e,t){let r=Buffer.isBuffer(t)?t.toString("base64"):t;return"crc32c"===e&&e2(this,g,"f")?e2(this,g,"f").validate(r):!!("md5"===e&&e2(this,v,"f"))&&e2(this,y,"f")===r}}g=new WeakMap,v=new WeakMap,y=new WeakMap;var e4=function(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)};(r=_||(_={})).read="GET",r.write="PUT",r.delete="DELETE",r.resumable="POST";let e3=/^gs:\/\/([a-z0-9_.-]+)\/(.+)$/,e9=RegExp([/^text\/|application\/ecmascript|application\/javascript|application\/json/,/|application\/postscript|application\/rtf|application\/toml|application\/vnd.dart/,/|application\/vnd.ms-fontobject|application\/wasm|application\/x-httpd-php|application\/x-ns-proxy-autoconfig/,/|application\/x-sh(?!ockwave-flash)|application\/x-tar|application\/x-virtualbox-hdd|application\/x-virtualbox-ova|application\/x-virtualbox-ovf/,/|^application\/x-virtualbox-vbox$|application\/x-virtualbox-vdi|application\/x-virtualbox-vhd|application\/x-virtualbox-vmdk/,/|application\/xml|application\/xml-dtd|font\/otf|font\/ttf|image\/bmp|image\/vnd.adobe.photoshop|image\/vnd.microsoft.icon/,/|image\/vnd.ms-dds|image\/x-icon|image\/x-ms-bmp|message\/rfc822|model\/gltf-binary|\+json|\+text|\+xml|\+yaml/].map(e=>e.source).join(""),"i");class e5 extends Error{}let e8=/(gs):\/\/([a-z0-9_.-]+)\/(.+)/g,e7=/(https):\/\/(storage\.googleapis\.com)\/([a-z0-9_.-]+)\/(.+)/g;(a=x||(x={})).EXPIRATION_TIME_NA="An expiration time is not available.",a.DESTINATION_NO_NAME="Destination file should have a name.",a.INVALID_VALIDATION_FILE_RANGE="Cannot use validation with file ranges (start/end).",a.MD5_NOT_AVAILABLE="MD5 verification was specified, but is not available for the requested object. MD5 is not available for composite objects.",a.EQUALS_CONDITION_TWO_ELEMENTS="Equals condition must be an array of 2 elements.",a.STARTS_WITH_TWO_ELEMENTS="StartsWith condition must be an array of 2 elements.",a.CONTENT_LENGTH_RANGE_MIN_MAX="ContentLengthRange must have numeric min & max fields.",a.DOWNLOAD_MISMATCH="The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again.",a.UPLOAD_MISMATCH_DELETE_FAIL="The uploaded data did not match the data from the server.\n As a precaution, we attempted to delete the file, but it was not successful.\n To be sure the content is the same, you should try removing the file manually,\n then uploading the file again.\n \n\nThe delete attempt failed with this message:\n\n ",a.UPLOAD_MISMATCH="The uploaded data did not match the data from the server.\n As a precaution, the file has been deleted.\n To be sure the content is the same, you should try uploading the file again.",a.MD5_RESUMED_UPLOAD="MD5 cannot be used with a continued resumable upload as MD5 cannot be extended from an existing value",a.MISSING_RESUME_CRC32C_FINAL_UPLOAD="The CRC32C is missing for the final portion of a resumed upload, which is required for validation. Please provide `resumeCRC32C` if validation is required, or disable `validation`.";class te extends ek{constructor(e,t,r={}){var a,i;let s;const n={};null!==r.generation&&(isNaN(s="string"==typeof r.generation?Number(r.generation):r.generation)||(n.generation=s)),Object.assign(n,r.preconditionOpts);const o=r.userProject||e.userProject;if("string"==typeof o&&(n.userProject=o),super({parent:e,baseUrl:"/o",id:encodeURIComponent(t),methods:{delete:{reqOpts:{qs:n}},exists:{reqOpts:{qs:n}},get:{reqOpts:{qs:n}},getMetadata:{reqOpts:{qs:n}},setMetadata:{reqOpts:{qs:n}}}}),w.add(this),this.bucket=e,this.storage=e.parent,null!==r.generation){let e;isNaN(e="string"==typeof r.generation?Number(r.generation):r.generation)||(this.generation=e)}this.kmsKeyName=r.kmsKeyName,this.userProject=o,this.name=t,r.encryptionKey&&this.setEncryptionKey(r.encryptionKey),this.acl=new eq({request:this.request.bind(this),pathPrefix:"/acl"}),this.crc32cGenerator=r.crc32cGenerator||this.bucket.crc32cGenerator,this.instanceRetryValue=null==(i=null==(a=this.storage)?void 0:a.retryOptions)?void 0:i.autoRetry,this.instancePreconditionOpts=null==r?void 0:r.preconditionOpts}get cloudStorageURI(){let e=this.bucket.cloudStorageURI;return e.pathname=this.name,e}shouldRetryBasedOnPreconditionAndIdempotencyStrat(e){var t;return((null==e?void 0:e.ifGenerationMatch)!==void 0||(null==(t=this.instancePreconditionOpts)?void 0:t.ifGenerationMatch)!==void 0||this.storage.retryOptions.idempotencyStrategy!==S.RetryConditional)&&this.storage.retryOptions.idempotencyStrategy!==S.RetryNever}copy(e,t,r){var a,i;let s,n,o,p=Error(x.DESTINATION_NO_NAME);if(!e)throw p;let d={};if("function"==typeof t?r=t:t&&(d={...t}),r=r||eN.noop,"string"==typeof e){let t=e3.exec(e);null!==t&&3===t.length?(s=this.storage.bucket(t[1]),n=t[2]):(s=this.bucket,n=e)}else if(e instanceof ta)s=e,n=this.name;else if(e instanceof te)s=e.bucket,n=e.name,o=e;else throw p;let l={};void 0!==this.generation&&(l.sourceGeneration=this.generation),void 0!==d.token&&(l.rewriteToken=d.token),void 0!==d.userProject&&(l.userProject=d.userProject,delete d.userProject),void 0!==d.predefinedAcl&&(l.destinationPredefinedAcl=d.predefinedAcl,delete d.predefinedAcl),o=o||s.file(n);let c={};if(void 0!==this.encryptionKey&&(c["x-goog-copy-source-encryption-algorithm"]="AES256",c["x-goog-copy-source-encryption-key"]=this.encryptionKeyBase64,c["x-goog-copy-source-encryption-key-sha256"]=this.encryptionKeyHash),void 0!==o.encryptionKey?this.setEncryptionKey(o.encryptionKey):void 0!==d.destinationKmsKeyName?(l.destinationKmsKeyName=d.destinationKmsKeyName,delete d.destinationKmsKeyName):void 0!==o.kmsKeyName&&(l.destinationKmsKeyName=o.kmsKeyName),l.destinationKmsKeyName){this.kmsKeyName=l.destinationKmsKeyName;let e=this.interceptors.indexOf(this.encryptionKeyInterceptor);e>-1&&this.interceptors.splice(e,1)}this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(null==d?void 0:d.preconditionOpts)||(this.storage.retryOptions.autoRetry=!1),(null==(a=d.preconditionOpts)?void 0:a.ifGenerationMatch)!==void 0&&(l.ifGenerationMatch=null==(i=d.preconditionOpts)?void 0:i.ifGenerationMatch,delete d.preconditionOpts),this.request({method:"POST",uri:`/rewriteTo/b/${s.name}/o/${encodeURIComponent(o.name)}`,qs:l,json:d,headers:c},(e,t)=>{if(this.storage.retryOptions.autoRetry=this.instanceRetryValue,e)return void r(e,null,t);if(t.rewriteToken){let e={token:t.rewriteToken};l.userProject&&(e.userProject=l.userProject),l.destinationKmsKeyName&&(e.destinationKmsKeyName=l.destinationKmsKeyName),this.copy(o,e,r);return}r(null,o,t)})}createReadStream(e={}){let t,r,a="number"==typeof(e=Object.assign({decompress:!0},e)).start||"number"==typeof e.end,i=e.end<0,s=new ef,n=!0,o=!1;if("string"==typeof e.validation){let t=e.validation.toLowerCase().trim();n="crc32c"===t,o="md5"===t}else!1===e.validation&&(n=!1);let p=!a&&(n||o);if(a){if("string"==typeof e.validation||!0===e.validation)throw Error(x.INVALID_VALIDATION_FILE_RANGE);n=!1,o=!1}let d=e=>{e&&((null==r?void 0:r.agent)&&r.agent.destroy(),s.destroy(e))},l=(a,i,l)=>{if(a)return void this.getBufferFromReadable(l).then(e=>{a.message=e.toString("utf8"),s.destroy(a)});r=l.request;let c=l.toJSON().headers,u="gzip"===c["content-encoding"],h={},m="gzip"===c["x-goog-stored-content-encoding"]&&u||"identity"===c["x-goog-stored-content-encoding"],f=[];if(p&&("string"==typeof c["x-goog-hash"]&&c["x-goog-hash"].split(",").forEach(e=>{let t=e.indexOf("="),r=e.substring(0,t),a=e.substring(t+1);h[r]=a}),t=new e6({crc32c:n,md5:o,crc32cGenerator:this.crc32cGenerator,crc32cExpected:h.crc32c,md5Expected:h.md5})),o&&!h.md5){let e=new e5(x.MD5_NOT_AVAILABLE);e.code="MD5_NOT_AVAILABLE",s.destroy(e);return}m&&p&&t&&f.push(t),u&&e.decompress&&f.push(e$.createGunzip()),(0,ee.pipeline)(l,...f,s,d)},c=()=>{let t={alt:"media"};this.generation&&(t.generation=this.generation),e.userProject&&(t.userProject=e.userProject);let r={"Accept-Encoding":"gzip","Cache-Control":"no-store"};if(a){let t="number"==typeof e.start?e.start:"0",a="number"==typeof e.end?e.end:"";r.Range=`bytes=${i?a:`${t}-${a}`}`}let n={uri:"",headers:r,qs:t};e[ey]&&(n[ey]=e[ey]),this.requestStream(n).on("error",e=>{s.destroy(e)}).on("response",e=>{s.emit("response",e),eN.handleResp(null,e,null,l)}).resume()};return s.on("reading",c),s}createResumableUpload(e,t){var r,a;let i="object"==typeof e?e:{};t="function"==typeof e?e:t;let s=this.storage.retryOptions;((null==(r=null==i?void 0:i.preconditionOpts)?void 0:r.ifGenerationMatch)===void 0&&(null==(a=this.instancePreconditionOpts)?void 0:a.ifGenerationMatch)===void 0&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(s.autoRetry=!1),function(e,t){let r=new eW(e);if(!t)return r.createURI();r.createURI().then(e=>t(null,e),t)}({authClient:this.storage.authClient,apiEndpoint:this.storage.apiEndpoint,bucket:this.bucket.name,customRequestOptions:this.getRequestInterceptors().reduce((e,t)=>t(e),{}),file:this.name,generation:this.generation,key:this.encryptionKey,kmsKeyName:this.kmsKeyName,metadata:i.metadata,offset:i.offset,origin:i.origin,predefinedAcl:i.predefinedAcl,private:i.private,public:i.public,userProject:i.userProject||this.userProject,retryOptions:s,params:(null==i?void 0:i.preconditionOpts)||this.instancePreconditionOpts,universeDomain:this.bucket.storage.universeDomain,useAuthWithCustomEndpoint:this.storage.useAuthWithCustomEndpoint,[ey]:i[ey]},t),this.storage.retryOptions.autoRetry=this.instanceRetryValue}createWriteStream(e={}){if(null!=e.metadata||(e.metadata={}),e.contentType&&(e.metadata.contentType=e.contentType),!e.metadata.contentType||"auto"===e.metadata.contentType){let t=eI.default.getType(this.name);t&&(e.metadata.contentType=t)}let t=e.gzip;"auto"===t&&(t=e9.test(e.metadata.contentType||"")),t&&(e.metadata.contentEncoding="gzip");let r=!0,a=!1;if("string"==typeof e.validation?(e.validation=e.validation.toLowerCase(),r="crc32c"===e.validation,a="md5"===e.validation):!1===e.validation&&(r=!1,a=!1),e.offset){if(a)throw RangeError(x.MD5_RESUMED_UPLOAD);if(r&&!e.isPartialUpload&&!e.resumeCRC32C)throw RangeError(x.MISSING_RESUME_CRC32C_FINAL_UPLOAD)}let i=e=>{s.destroy(e||void 0)},s=new ee.Writable({final(e){i=e,o.end()},write(e,t,r){o.write(e,t,r)}});s.once("error",e=>{o.destroy(e)}),s.once("close",()=>{o.destroy()});let n=[];t&&n.push(e$.createGzip());let o=new ef,p=()=>{};o.on("error",p);let d=null;if(r||a){let t=e.resumeCRC32C?eX.from(e.resumeCRC32C):void 0;d=new e6({crc32c:r,crc32cInstance:t,md5:a,crc32cGenerator:this.crc32cGenerator,updateHashesOnly:!0}),n.push(d)}let l=(0,eg.default)(),c=!1;return o.on("reading",()=>s.emit("reading")),o.on("writing",()=>s.emit("writing")),l.on("uri",e=>s.emit("uri",e)),l.on("progress",e=>s.emit("progress",e)),l.on("response",e=>s.emit("response",e)),l.once("metadata",()=>{c=!0}),s.once("writing",()=>{!1===e.resumable?this.startSimpleUpload_(l,e):this.startResumableUpload_(l,e),o.removeListener("error",p),(0,ee.pipeline)(o,...n,l,async t=>{if(t)return i(t);if(!c)try{await new Promise((e,t)=>{l.once("metadata",e),l.once("error",t)})}catch(e){return i(e)}(null==d?void 0:d.crc32c)&&s.emit("crc32c",d.crc32c);try{let t=e.isPartialUpload&&!this.metadata;d&&!t&&await e4(this,w,"m",b).call(this,d,{crc32c:r,md5:a}),i()}catch(e){i(e)}})}),s}delete(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t,this.disableAutoRetryConditionallyIdempotent_(this.methods.delete,E.delete,r),super.delete(r).then(e=>t(null,...e)).catch(t).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}download(e,t){let r;"function"==typeof e?(t=e,r={}):r=Object.assign({},e);let a=!1,i=(...e)=>{a||t(...e),a=!0},s=r.destination;delete r.destination,r.encryptionKey&&(this.setEncryptionKey(r.encryptionKey),delete r.encryptionKey);let n=this.createReadStream(r),o=!1;s?n.on("error",i).once("data",e=>{o=!0;let t=eC.createWriteStream(s);t.write(e),n.pipe(t).on("error",e=>{i(e,Buffer.from(""))}).on("finish",()=>{i(null,e)})}).on("end",()=>{if(!o){let e=Buffer.alloc(0);try{eC.writeFileSync(s,e),i(null,e)}catch(t){i(t,e)}}}):this.getBufferFromReadable(n).then(e=>null==i?void 0:i(null,e)).catch(i)}setEncryptionKey(e){return this.encryptionKey=e,this.encryptionKeyBase64=Buffer.from(e).toString("base64"),this.encryptionKeyHash=I.createHash("sha256").update(this.encryptionKeyBase64,"base64").digest("base64"),this.encryptionKeyInterceptor={request:e=>(e.headers=e.headers||{},e.headers["x-goog-encryption-algorithm"]="AES256",e.headers["x-goog-encryption-key"]=this.encryptionKeyBase64,e.headers["x-goog-encryption-key-sha256"]=this.encryptionKeyHash,e)},this.interceptors.push(this.encryptionKeyInterceptor),this}static from(e,t,r){let a=[...e.matchAll(e8)],i=[...e.matchAll(e7)];if(a.length>0)return new te(new ta(t,a[0][2]),a[0][3],r);if(i.length>0)return new te(new ta(t,i[0][3]),i[0][4],r);throw Error("URL string must be of format gs://bucket/file or https://storage.googleapis.com/bucket/file")}get(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t,super.get(r).then(e=>t(null,...e)).catch(t)}getExpirationDate(e){this.getMetadata((t,r,a)=>{t?e(t,null,a):r.retentionExpirationTime?e(null,new Date(r.retentionExpirationTime),a):e(Error(x.EXPIRATION_TIME_NA),null,a)})}generateSignedPostPolicyV2(e,t){let r=eo(e,t),a=r.options,i=r.callback,s=new Date(a.expires);if(isNaN(s.getTime()))throw Error(k.EXPIRATION_DATE_INVALID);if(s.valueOf()<Date.now())throw Error(k.EXPIRATION_DATE_PAST);a=Object.assign({},a);let n=[["eq","$key",this.name],{bucket:this.bucket.name}];if(Array.isArray(a.equals)&&(Array.isArray(a.equals[0])||(a.equals=[a.equals]),a.equals.forEach(e=>{if(!Array.isArray(e)||2!==e.length)throw Error(x.EQUALS_CONDITION_TWO_ELEMENTS);n.push(["eq",e[0],e[1]])})),Array.isArray(a.startsWith)&&(Array.isArray(a.startsWith[0])||(a.startsWith=[a.startsWith]),a.startsWith.forEach(e=>{if(!Array.isArray(e)||2!==e.length)throw Error(x.STARTS_WITH_TWO_ELEMENTS);n.push(["starts-with",e[0],e[1]])})),a.acl&&n.push({acl:a.acl}),a.successRedirect&&n.push({success_action_redirect:a.successRedirect}),a.successStatus&&n.push({success_action_status:a.successStatus}),a.contentLengthRange){let e=a.contentLengthRange.min,t=a.contentLengthRange.max;if("number"!=typeof e||"number"!=typeof t)throw Error(x.CONTENT_LENGTH_RANGE_MIN_MAX);n.push(["content-length-range",e,t])}let o=JSON.stringify({expiration:s.toISOString(),conditions:n}),p=Buffer.from(o).toString("base64");this.storage.authClient.sign(p,a.signingEndpoint).then(e=>{i(null,{string:o,base64:p,signature:e})},e=>{i(new eH(e.message))})}generateSignedPostPolicyV4(e,t){let r=eo(e,t),a=r.options,i=r.callback,s=new Date(a.expires);if(isNaN(s.getTime()))throw Error(k.EXPIRATION_DATE_INVALID);if(s.valueOf()<Date.now())throw Error(k.EXPIRATION_DATE_PAST);if(s.valueOf()-Date.now()>6048e5)throw Error("Max allowed expiration is seven days (604800 seconds).");let n=Object.assign({},(a=Object.assign({},a)).fields),o=new Date,p=ec(o,!0),d=ec(o);(async()=>{let{client_email:e}=await this.storage.authClient.getCredentials(),t=`${e}/${d}/auto/storage/goog4_request`;n={...n,bucket:this.bucket.name,key:this.name,"x-goog-date":p,"x-goog-credential":t,"x-goog-algorithm":"GOOG4-RSA-SHA256"};let r=a.conditions||[];Object.entries(n).forEach(([e,t])=>{e.startsWith("x-ignore-")||r.push({[e]:t})}),delete n.bucket;let i=JSON.stringify({conditions:r,expiration:ec(s,!0,"-",":")}).replace(/[\u0080-\uFFFF]/g,e=>"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)),o=Buffer.from(i).toString("base64");try{let e=await this.storage.authClient.sign(o,a.signingEndpoint),t=Buffer.from(e,"base64").toString("hex"),r=this.parent.storage.universeDomain;return n.policy=o,n["x-goog-signature"]=t,{url:this.storage.customEndpoint?this.storage.apiEndpoint:a.virtualHostedStyle?`https://${this.bucket.name}.storage.${r}/`:a.bucketBoundHostname?`${a.bucketBoundHostname}/`:`https://storage.${r}/${this.bucket.name}/`,fields:n}}catch(e){throw new eH(e.message)}})().then(e=>i(null,e),i)}getSignedUrl(e,t){let r=_[e.action],a=function(e){let t={};for(let r of Object.keys(e)){let a=e[r];t[r=r.toLowerCase()]=a}return t}(e.extensionHeaders||{});"resumable"===e.action&&(a["x-goog-resumable"]="start");let i=Object.assign({},e.queryParams);"string"==typeof e.responseType&&(i["response-content-type"]=e.responseType),"string"==typeof e.promptSaveAs&&(i["response-content-disposition"]='attachment; filename="'+e.promptSaveAs+'"'),"string"==typeof e.responseDisposition&&(i["response-content-disposition"]=e.responseDisposition),this.generation&&(i.generation=this.generation.toString());let s={method:r,expires:e.expires,accessibleAt:e.accessibleAt,extensionHeaders:a,queryParams:i,contentMd5:e.contentMd5,contentType:e.contentType,host:e.host};e.cname&&(s.cname=e.cname),e.version&&(s.version=e.version),e.virtualHostedStyle&&(s.virtualHostedStyle=e.virtualHostedStyle),this.signer||(this.signer=new eG(this.storage.authClient,this.bucket,this,this.storage)),this.signer.getSignedUrl(s).then(e=>t(null,e),t)}isPublic(e){var t;let r=(null==(t=this.storage)?void 0:t.interceptors)||[],a=this.interceptors||[],i=r.concat(a).reduce((e,t)=>(Object.assign(e,t.request({uri:`${this.storage.apiEndpoint}/${this.bucket.name}/${encodeURIComponent(this.name)}`}).headers),e),{});eN.makeRequest({method:"GET",uri:`${this.storage.apiEndpoint}/${this.bucket.name}/${encodeURIComponent(this.name)}`,headers:i},{retryOptions:this.storage.retryOptions},t=>{t?403===t.code?e(null,!1):e(t):e(null,!0)})}makePrivate(e,t){var r,a;let i="object"==typeof e?e:{};t="function"==typeof e?e:t;let s={predefinedAcl:i.strict?"private":"projectPrivate"};(null==(r=i.preconditionOpts)?void 0:r.ifMetagenerationMatch)!==void 0&&(s.ifMetagenerationMatch=null==(a=i.preconditionOpts)?void 0:a.ifMetagenerationMatch,delete i.preconditionOpts),i.userProject&&(s.userProject=i.userProject);let n={...i.metadata,acl:null};this.setMetadata(n,s,t)}makePublic(e){e=e||eN.noop,this.acl.add({entity:"allUsers",role:"READER"},(t,r,a)=>{e(t,a)})}publicUrl(){return`${this.storage.apiEndpoint}/${this.bucket.name}/${encodeURIComponent(this.name)}`}moveFileAtomic(e,t,r){var a,i;let s,n,o=Error(x.DESTINATION_NO_NAME);if(!e)throw o;let p={};if("function"==typeof t?r=t:t&&(p={...t}),r=r||eN.noop,"string"==typeof e){let t=e3.exec(e);s=null!==t&&3===t.length?t[2]:e}else if(e instanceof te)s=e.name,n=e;else throw o;n=n||this.bucket.file(s),this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(null==p?void 0:p.preconditionOpts)||(this.storage.retryOptions.autoRetry=!1);let d={};void 0!==p.userProject&&(d.userProject=p.userProject,delete p.userProject),(null==(a=p.preconditionOpts)?void 0:a.ifGenerationMatch)!==void 0&&(d.ifGenerationMatch=null==(i=p.preconditionOpts)?void 0:i.ifGenerationMatch,delete p.preconditionOpts),this.request({method:"POST",uri:`/moveTo/o/${encodeURIComponent(n.name)}`,qs:d,json:p},(e,t)=>{(this.storage.retryOptions.autoRetry=this.instanceRetryValue,e)?r(e,null,t):r(null,n,t)})}move(e,t,r){let a="object"==typeof t?t:{};r=(r="function"==typeof t?t:r)||eN.noop,this.copy(e,a,(e,t,i)=>{if(e){e.message="file#copy failed with an error - "+e.message,r(e,null,i);return}this.name!==t.name||this.bucket.name!==t.bucket.name?this.delete(a,(e,a)=>{if(e){e.message="file#delete failed with an error - "+e.message,r(e,t,a);return}r(null,t,i)}):r(null,t,i)})}rename(e,t,r){let a="object"==typeof t?t:{};r=(r="function"==typeof t?t:r)||eN.noop,this.move(e,a,r)}async restore(e){let[t]=await this.request({method:"POST",uri:"/restore",qs:e});return t}request(e,t){return this.parent.request.call(this,e,t)}rotateEncryptionKey(e,t){var r;t="function"==typeof e?e:t;let a={};"string"==typeof e||e instanceof Buffer?a={encryptionKey:e}:"object"==typeof e&&(a=e);let i=this.bucket.file(this.id,a),s=(null==(r=a.preconditionOpts)?void 0:r.ifGenerationMatch)!==void 0?{preconditionOpts:a.preconditionOpts}:{};this.copy(i,s,t)}save(e,t,r){r="function"==typeof t?t:r;let a="object"==typeof t?t:{},i=this.storage.retryOptions.maxRetries;this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(null==a?void 0:a.preconditionOpts)||(i=0);let s=(0,eP.default)(async t=>new Promise((r,s)=>{0===i&&(this.storage.retryOptions.autoRetry=!1);let n=this.createWriteStream(a);a.onUploadProgress&&n.on("progress",a.onUploadProgress);let o=e=>this.storage.retryOptions.autoRetry&&this.storage.retryOptions.retryableErrorFn(e)?s(e):t(e);"string"==typeof e||Buffer.isBuffer(e)||e instanceof Uint8Array?n.on("error",o).on("finish",()=>r()).end(e):(0,ee.pipeline)(e,n,a=>{if(a){if("function"!=typeof e)return t(a);o(a)}else r()})}),{retries:i,factor:this.storage.retryOptions.retryDelayMultiplier,maxTimeout:1e3*this.storage.retryOptions.maxRetryDelay,maxRetryTime:1e3*this.storage.retryOptions.totalTimeout});return r?s.then(()=>{if(r)return r()}).catch(r):s}setMetadata(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.disableAutoRetryConditionallyIdempotent_(this.methods.setMetadata,E.setMetadata,a),super.setMetadata(e,a).then(e=>r(null,...e)).catch(r).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}setStorageClass(e,t,r){r="function"==typeof t?t:r;let a={..."object"==typeof t?t:{},storageClass:e.replace(/-/g,"_").replace(/([a-z])([A-Z])/g,(e,t,r)=>t+"_"+r).toUpperCase()};this.copy(this,a,(e,t,a)=>{e?r(e,a):(this.metadata=t.metadata,r(null,a))})}setUserProject(e){this.bucket.setUserProject.call(this,e)}startResumableUpload_(e,t={}){let r;null!=t.metadata||(t.metadata={});let a=this.storage.retryOptions;this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(t.preconditionOpts)||(a.autoRetry=!1);let i={authClient:this.storage.authClient,apiEndpoint:this.storage.apiEndpoint,bucket:this.bucket.name,customRequestOptions:this.getRequestInterceptors().reduce((e,t)=>t(e),{}),file:this.name,generation:this.generation,isPartialUpload:t.isPartialUpload,key:this.encryptionKey,kmsKeyName:this.kmsKeyName,metadata:t.metadata,offset:t.offset,predefinedAcl:t.predefinedAcl,private:t.private,public:t.public,uri:t.uri,userProject:t.userProject||this.userProject,retryOptions:{...a},params:(null==t?void 0:t.preconditionOpts)||this.instancePreconditionOpts,chunkSize:null==t?void 0:t.chunkSize,highWaterMark:null==t?void 0:t.highWaterMark,universeDomain:this.bucket.storage.universeDomain,[ey]:t[ey]};try{r=new eW(i)}catch(t){e.destroy(t),this.storage.retryOptions.autoRetry=this.instanceRetryValue;return}r.on("response",t=>{e.emit("response",t)}).on("uri",t=>{e.emit("uri",t)}).on("metadata",t=>{this.metadata=t,e.emit("metadata")}).on("finish",()=>{e.emit("complete")}).on("progress",t=>e.emit("progress",t)),e.setWritable(r),this.storage.retryOptions.autoRetry=this.instanceRetryValue}startSimpleUpload_(e,t={}){null!=t.metadata||(t.metadata={});let r=this.storage.apiEndpoint,a=this.bucket.name,i=`${r}/upload/storage/v1/b/${a}/o`,s={qs:{name:this.name},uri:i,[ey]:t[ey]};void 0!==this.generation&&(s.qs.ifGenerationMatch=this.generation),void 0!==this.kmsKeyName&&(s.qs.kmsKeyName=this.kmsKeyName),"number"==typeof t.timeout&&(s.timeout=t.timeout),(t.userProject||this.userProject)&&(s.qs.userProject=t.userProject||this.userProject),t.predefinedAcl?s.qs.predefinedAcl=t.predefinedAcl:t.private?s.qs.predefinedAcl="private":t.public&&(s.qs.predefinedAcl="publicRead"),Object.assign(s.qs,this.instancePreconditionOpts,t.preconditionOpts),eN.makeWritableStream(e,{makeAuthenticatedRequest:t=>{this.request(t,(t,r,a)=>{t?e.destroy(t):(this.metadata=r,e.emit("metadata",r),e.emit("response",a),e.emit("complete"))})},metadata:t.metadata,request:s})}disableAutoRetryConditionallyIdempotent_(e,t,r){var a,i,s,n;("object"==typeof e&&(null==(i=null==(a=null==e?void 0:e.reqOpts)?void 0:a.qs)?void 0:i.ifGenerationMatch)===void 0&&(null==r?void 0:r.ifGenerationMatch)===void 0&&t===E.delete&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(this.storage.retryOptions.autoRetry=!1),("object"==typeof e&&(null==(n=null==(s=null==e?void 0:e.reqOpts)?void 0:s.qs)?void 0:n.ifMetagenerationMatch)===void 0&&(null==r?void 0:r.ifMetagenerationMatch)===void 0&&t===E.setMetadata&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(this.storage.retryOptions.autoRetry=!1)}async getBufferFromReadable(e){let t=[];for await(let r of e)t.push(r);return Buffer.concat(t)}}w=new WeakSet,b=async function(e,t={}){let r=this.metadata,a=!!(t.crc32c||t.md5);if(t.crc32c&&r.crc32c&&(a=!e.test("crc32c",r.crc32c)),t.md5&&r.md5Hash&&(a=!e.test("md5",r.md5Hash)),a){let e=[],a="",i="";try{await this.delete(),t.md5&&!r.md5Hash?(a="MD5_NOT_AVAILABLE",i=x.MD5_NOT_AVAILABLE):(a="FILE_NO_UPLOAD",i=x.UPLOAD_MISMATCH)}catch(t){a="FILE_NO_UPLOAD_DELETE",i=`${x.UPLOAD_MISMATCH_DELETE_FAIL}${t.message}`,e.push(t)}let s=new e5(i);throw s.code=a,s.errors=e,s}return!0},(0,eA.promisifyAll)(te,{exclude:["cloudStorageURI","publicUrl","request","save","setEncryptionKey","shouldRetryBasedOnPreconditionAndIdempotencyStrat","getBufferFromReadable","restore"]}),(i=N||(N={})).POLICY_OBJECT_REQUIRED="A policy object is required.",i.PERMISSIONS_REQUIRED="Permissions are required.";class tt{constructor(e){this.request_=e.request.bind(e),this.resourceId_="buckets/"+e.getId()}getPolicy(e,t){let{options:r,callback:a}=eo(e,t),i={};r.userProject&&(i.userProject=r.userProject),null!==r.requestedPolicyVersion&&void 0!==r.requestedPolicyVersion&&(i.optionsRequestedPolicyVersion=r.requestedPolicyVersion),this.request_({uri:"/iam",qs:i},a)}setPolicy(e,t,r){let a;if(null===e||"object"!=typeof e)throw Error(N.POLICY_OBJECT_REQUIRED);let{options:i,callback:s}=eo(t,r);void 0===e.etag&&(a=0),this.request_({method:"PUT",uri:"/iam",maxRetries:a,json:Object.assign({resourceId:this.resourceId_},e),qs:i},s)}testPermissions(e,t,r){if(!Array.isArray(e)&&"string"!=typeof e)throw Error(N.PERMISSIONS_REQUIRED);let{options:a,callback:i}=eo(t,r),s=Array.isArray(e)?e:[e],n=Object.assign({permissions:s},a);this.request_({uri:"/iam/testPermissions",qs:n,useQuerystring:!0},(e,t)=>{if(e)return void i(e,null,t);let r=Array.isArray(t.permissions)?t.permissions:[];i(null,s.reduce((e,t)=>(e[t]=r.indexOf(t)>-1,e),{}),t)})}}(0,eA.promisifyAll)(tt);class tr extends ek{constructor(e,t){const r={};super({parent:e,baseUrl:"/notificationConfigs",id:t.toString(),createMethod:e.createNotification.bind(e),methods:{create:!0,delete:{reqOpts:{qs:r}},get:{reqOpts:{qs:r}},getMetadata:{reqOpts:{qs:r}},exists:!0}})}}(0,eA.promisifyAll)(tr),(T||(T={})).list="GET",(s=E||(E={}))[s.setMetadata=0]="setMetadata",s[s.delete=1]="delete",(n=A||(A={})).PROVIDE_SOURCE_FILE="You must provide at least one source file.",n.DESTINATION_FILE_NOT_SPECIFIED="A destination file must be specified.",n.CHANNEL_ID_REQUIRED="An ID is required to create a channel.",n.TOPIC_NAME_REQUIRED="A valid topic name is required.",n.CONFIGURATION_OBJECT_PREFIX_REQUIRED="A configuration object with a prefix is required.",n.SPECIFY_FILE_NAME="A file name must be specified.",n.METAGENERATION_NOT_PROVIDED="A metageneration must be provided.",n.SUPPLY_NOTIFICATION_ID="You must supply a notification ID.";class ta extends ek{getFilesStream(e){return new ee.Readable}constructor(e,t,r){var a,i,s,n;r=r||{},t=t.replace(/^gs:\/\//,"").replace(/\/+$/,"");const o={};(null==(a=null==r?void 0:r.preconditionOpts)?void 0:a.ifGenerationMatch)&&(o.ifGenerationMatch=r.preconditionOpts.ifGenerationMatch),(null==(i=null==r?void 0:r.preconditionOpts)?void 0:i.ifGenerationNotMatch)&&(o.ifGenerationNotMatch=r.preconditionOpts.ifGenerationNotMatch),(null==(s=null==r?void 0:r.preconditionOpts)?void 0:s.ifMetagenerationMatch)&&(o.ifMetagenerationMatch=r.preconditionOpts.ifMetagenerationMatch),(null==(n=null==r?void 0:r.preconditionOpts)?void 0:n.ifMetagenerationNotMatch)&&(o.ifMetagenerationNotMatch=r.preconditionOpts.ifMetagenerationNotMatch);const p=r.userProject;"string"==typeof p&&(o.userProject=p),super({parent:e,baseUrl:"/b",id:t,createMethod:e.createBucket.bind(e),methods:{create:{reqOpts:{qs:o}},delete:{reqOpts:{qs:o}},exists:{reqOpts:{qs:o}},get:{reqOpts:{qs:o}},getMetadata:{reqOpts:{qs:o}},setMetadata:{reqOpts:{qs:o}}}}),this.unreachable=!1,this.name=t,this.storage=e,this.userProject=r.userProject,this.acl=new eq({request:this.request.bind(this),pathPrefix:"/acl"}),this.acl.default=new eq({request:this.request.bind(this),pathPrefix:"/defaultObjectAcl"}),this.crc32cGenerator=r.crc32cGenerator||this.storage.crc32cGenerator,this.iam=new tt(this),this.getFilesStream=eO.paginator.streamify("getFiles"),this.instanceRetryValue=e.retryOptions.autoRetry,this.instancePreconditionOpts=null==r?void 0:r.preconditionOpts}get cloudStorageURI(){let e=new es.URL("gs://");return e.host=this.name,e}addLifecycleRule(e,t,r){let a={};"function"==typeof t?r=t:t&&(a=t),a=a||{};let i=Array.isArray(e)?e:[e];for(let e of i)e.condition.createdBefore instanceof Date&&(e.condition.createdBefore=e.condition.createdBefore.toISOString().replace(/T.+$/,"")),e.condition.customTimeBefore instanceof Date&&(e.condition.customTimeBefore=e.condition.customTimeBefore.toISOString().replace(/T.+$/,"")),e.condition.noncurrentTimeBefore instanceof Date&&(e.condition.noncurrentTimeBefore=e.condition.noncurrentTimeBefore.toISOString().replace(/T.+$/,""));!1===a.append?this.setMetadata({lifecycle:{rule:i}},a,r):this.getMetadata((e,t)=>{var s,n;if(e)return void r(e);let o=Array.isArray(null==(s=t.lifecycle)?void 0:s.rule)?null==(n=t.lifecycle)?void 0:n.rule:[];this.setMetadata({lifecycle:{rule:o.concat(i)}},a,r)})}combine(e,t,r,a){var i;if(!Array.isArray(e)||0===e.length)throw Error(A.PROVIDE_SOURCE_FILE);if(!t)throw Error(A.DESTINATION_FILE_NOT_SPECIFIED);let s={};"function"==typeof r?a=r:r&&(s=r),this.disableAutoRetryConditionallyIdempotent_(this.methods.setMetadata,E.setMetadata,s);let n=e=>e instanceof te?e:this.file(e);e=e.map(n);let o=n(t);if(a=a||eN.noop,!o.metadata.contentType){let e=eI.default.getType(o.name)||void 0;e&&(o.metadata.contentType=e)}let p=this.storage.retryOptions.maxRetries;((null==(i=null==o?void 0:o.instancePreconditionOpts)?void 0:i.ifGenerationMatch)===void 0&&void 0===s.ifGenerationMatch&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(p=0),void 0===s.ifGenerationMatch&&Object.assign(s,o.instancePreconditionOpts,s),o.request({method:"POST",uri:"/compose",maxRetries:p,json:{destination:{contentType:o.metadata.contentType,contentEncoding:o.metadata.contentEncoding},sourceObjects:e.map(e=>{let t={name:e.name};return e.metadata&&e.metadata.generation&&(t.generation=parseInt(e.metadata.generation.toString())),t})},qs:s},(e,t)=>{(this.storage.retryOptions.autoRetry=this.instanceRetryValue,e)?a(e,null,t):a(null,o,t)})}createChannel(e,t,r,a){if("string"!=typeof e)throw Error(A.CHANNEL_ID_REQUIRED);let i={};"function"==typeof r?a=r:r&&(i=r),this.request({method:"POST",uri:"/o/watch",json:Object.assign({id:e,type:"web_hook"},t),qs:i},(t,r)=>{if(t)return void a(t,null,r);let i=r.resourceId,s=this.storage.channel(e,i);s.metadata=r,a(null,s,r)})}createNotification(e,t,r){let a={};if("function"==typeof t?r=t:t&&(a=t),null!==e&&"object"==typeof e&&eN.isCustomType(e,"pubsub/topic")&&(e=e.name),"string"!=typeof e)throw Error(A.TOPIC_NAME_REQUIRED);let i=Object.assign({topic:e},a);0!==i.topic.indexOf("projects")&&(i.topic="projects/{{projectId}}/topics/"+i.topic),i.topic=`//pubsub.${this.storage.universeDomain}/`+i.topic,i.payloadFormat||(i.payloadFormat="JSON_API_V1");let s={};i.userProject&&(s.userProject=i.userProject,delete i.userProject),this.request({method:"POST",uri:"/notificationConfigs",json:function e(t){return t instanceof Date||t instanceof RegExp?t:Array.isArray(t)?t.map(e):t instanceof Object?Object.keys(t).reduce((r,a)=>(r[a[0].toLocaleLowerCase()+a.slice(1).replace(/([A-Z]+)/g,(e,t)=>`_${t.toLowerCase()}`)]=e(t[a]),r),{}):t}(i),qs:s,maxRetries:0},(e,t)=>{if(e)return void r(e,null,t);let a=this.notification(t.id);a.metadata=t,r(null,a,t)})}deleteFiles(e,t){let r={};"function"==typeof e?t=e:e&&(r=e);let a=[],i=e=>e.delete(r).catch(e=>{if(!r.force)throw e;a.push(e)});(async()=>{try{let e=[],s=(0,eR.default)(10),n=this.getFilesStream(r);for await(let t of n)e.length>=1e3&&(await Promise.all(e),e=[]),e.push(s(()=>i(t)).catch(e=>{throw n.destroy(),e}));await Promise.all(e),t(a.length>0?a:null)}catch(e){t(e);return}})()}deleteLabels(e,t,r){let a=[],i={};"function"==typeof e?r=e:"string"==typeof e?a=[e]:Array.isArray(e)?a=e:e&&(i=e),"function"==typeof t?r=t:t&&(i=t);let s=e=>{let t=e.reduce((e,t)=>(e[t]=null,e),{});(null==i?void 0:i.ifMetagenerationMatch)!==void 0?this.setLabels(t,i,r):this.setLabels(t,r)};0===a.length?this.getLabels((e,t)=>{e?r(e):s(Object.keys(t))}):s(a)}disableRequesterPays(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.setMetadata({billing:{requesterPays:!1}},r,t)}enableLogging(e,t){if(!e||"function"==typeof e||void 0===e.prefix)throw Error(A.CONFIGURATION_OBJECT_PREFIX_REQUIRED);let r=this.id;e.bucket&&e.bucket instanceof ta?r=e.bucket.id:e.bucket&&"string"==typeof e.bucket&&(r=e.bucket);let a={};(null==e?void 0:e.ifMetagenerationMatch)&&(a.ifMetagenerationMatch=e.ifMetagenerationMatch),(null==e?void 0:e.ifMetagenerationNotMatch)&&(a.ifMetagenerationNotMatch=e.ifMetagenerationNotMatch),(async()=>{try{let[i]=await this.iam.getPolicy();i.bindings.push({members:["group:cloud-storage-analytics@google.com"],role:"roles/storage.objectCreator"}),await this.iam.setPolicy(i),this.setMetadata({logging:{logBucket:r,logObjectPrefix:e.prefix}},a,t)}catch(e){t(e);return}})()}enableRequesterPays(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.setMetadata({billing:{requesterPays:!0}},r,t)}file(e,t){if(!e)throw Error(A.SPECIFY_FILE_NAME);return new te(this,e,t)}getFiles(e,t){let r="object"==typeof e?e:{};t||(t=e),(r=Object.assign({},r)).fields&&r.autoPaginate&&!r.fields.includes("nextPageToken")&&(r.fields=`${r.fields},nextPageToken`),this.request({uri:"/o",qs:r},(e,a)=>{if(e)return void t(e,null,null,a);let i=(a.items?a.items:[]).map(e=>{let t={};if(r.fields)return e;r.versions&&(t.generation=e.generation),e.kmsKeyName&&(t.kmsKeyName=e.kmsKeyName);let a=this.file(e.name,t);return a.metadata=e,a}),s=null;a.nextPageToken&&(s=Object.assign({},r,{pageToken:a.nextPageToken})),t(null,i,s,a)})}getLabels(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.getMetadata(r,(e,r)=>{e?t(e,null):t(null,(null==r?void 0:r.labels)||{})})}getNotifications(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.request({uri:"/notificationConfigs",qs:r},(e,r)=>{if(e)return void t(e,null,r);let a=(r.items?r.items:[]).map(e=>{let t=this.notification(e.id);return t.metadata=e,t});t(null,a,r)})}getSignedUrl(e,t){let r={method:T[e.action],expires:e.expires,version:e.version,cname:e.cname,extensionHeaders:e.extensionHeaders||{},queryParams:e.queryParams||{},host:e.host,signingEndpoint:e.signingEndpoint};this.signer||(this.signer=new eG(this.storage.authClient,this,void 0,this.storage)),this.signer.getSignedUrl(r).then(e=>t(null,e),t)}lock(e,t){let r=typeof e;if("number"!==r&&"string"!==r)throw Error(A.METAGENERATION_NOT_PROVIDED);this.request({method:"POST",uri:"/lockRetentionPolicy",qs:{ifMetagenerationMatch:e}},t)}async restore(e){let[t]=await this.request({method:"POST",uri:"/restore",qs:e});return t}makePrivate(e,t){var r,a,i,s;let n="object"==typeof e?e:{};t="function"==typeof e?e:t,n.private=!0;let o={predefinedAcl:"projectPrivate"};n.userProject&&(o.userProject=n.userProject),(null==(r=n.preconditionOpts)?void 0:r.ifGenerationMatch)&&(o.ifGenerationMatch=n.preconditionOpts.ifGenerationMatch),(null==(a=n.preconditionOpts)?void 0:a.ifGenerationNotMatch)&&(o.ifGenerationNotMatch=n.preconditionOpts.ifGenerationNotMatch),(null==(i=n.preconditionOpts)?void 0:i.ifMetagenerationMatch)&&(o.ifMetagenerationMatch=n.preconditionOpts.ifMetagenerationMatch),(null==(s=n.preconditionOpts)?void 0:s.ifMetagenerationNotMatch)&&(o.ifMetagenerationNotMatch=n.preconditionOpts.ifMetagenerationNotMatch);let p={...n.metadata,acl:null};this.setMetadata(p,o,e=>{e&&t(e),(n.includeFiles?(0,eD.promisify)(this.makeAllFilesPublicPrivate_).call(this,n):Promise.resolve([])).then(e=>t(null,e)).catch(t)})}makePublic(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t;let a={public:!0,...r};this.acl.add({entity:"allUsers",role:"READER"}).then(()=>this.acl.default.add({entity:"allUsers",role:"READER"})).then(()=>a.includeFiles?(0,eD.promisify)(this.makeAllFilesPublicPrivate_).call(this,a):[]).then(e=>t(null,e),t)}notification(e){if(!e)throw Error(A.SUPPLY_NOTIFICATION_ID);return new tr(this,e)}removeRetentionPeriod(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t,this.setMetadata({retentionPolicy:null},r,t)}request(e,t){return!this.userProject||e.qs&&e.qs.userProject||(e.qs={...e.qs,userProject:this.userProject}),super.request(e,t)}setLabels(e,t,r){let a="object"==typeof t?t:{};r=(r="function"==typeof t?t:r)||eN.noop,this.setMetadata({labels:e},a,r)}setMetadata(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.disableAutoRetryConditionallyIdempotent_(this.methods.setMetadata,E.setMetadata,a),super.setMetadata(e,a).then(e=>r(null,...e)).catch(r).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}setRetentionPeriod(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.setMetadata({retentionPolicy:{retentionPeriod:e.toString()}},a,r)}setCorsConfiguration(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.setMetadata({cors:e},a,r)}setStorageClass(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,e=e.replace(/-/g,"_").replace(/([a-z])([A-Z])/g,(e,t,r)=>t+"_"+r).toUpperCase(),this.setMetadata({storageClass:e},a,r)}setUserProject(e){this.userProject=e,["create","delete","exists","get","getMetadata","setMetadata"].forEach(t=>{let r=this.methods[t];"object"==typeof r&&("object"==typeof r.reqOpts?Object.assign(r.reqOpts.qs,{userProject:e}):r.reqOpts={qs:{userProject:e}})})}upload(t,r,a){var i,s;let n,o=e=>{let r=(0,eP.default)(async r=>{await new Promise((a,i)=>{var s,o;0===e&&(null==(o=null==(s=null==n?void 0:n.storage)?void 0:s.retryOptions)?void 0:o.autoRetry)&&(n.storage.retryOptions.autoRetry=!1);let d=n.createWriteStream(p);p.onUploadProgress&&d.on("progress",p.onUploadProgress),eC.createReadStream(t).on("error",r).pipe(d).on("error",e=>this.storage.retryOptions.autoRetry&&this.storage.retryOptions.retryableErrorFn(e)?i(e):r(e)).on("finish",()=>a())})},{retries:e,factor:this.storage.retryOptions.retryDelayMultiplier,maxTimeout:1e3*this.storage.retryOptions.maxRetryDelay,maxRetryTime:1e3*this.storage.retryOptions.totalTimeout});return a?r.then(()=>{if(a)return a(null,n,n.metadata)}).catch(a):r};if(e.g.GCLOUD_SANDBOX_ENV)return;let p="object"==typeof r?r:{};a="function"==typeof r?r:a,p=Object.assign({metadata:{}},p);let d=this.storage.retryOptions.maxRetries;if(((null==(i=null==p?void 0:p.preconditionOpts)?void 0:i.ifGenerationMatch)===void 0&&(null==(s=this.instancePreconditionOpts)?void 0:s.ifGenerationMatch)===void 0&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(d=0),p.destination instanceof te)n=p.destination;else if(null!==p.destination&&"string"==typeof p.destination)n=this.file(p.destination,{encryptionKey:p.encryptionKey,kmsKeyName:p.kmsKeyName,preconditionOpts:this.instancePreconditionOpts});else{let e=er.basename(t);n=this.file(e,{encryptionKey:p.encryptionKey,kmsKeyName:p.kmsKeyName,preconditionOpts:this.instancePreconditionOpts})}o(d)}makeAllFilesPublicPrivate_(e,t){let r=[],a=[],i="object"==typeof e?e:{};t="function"==typeof e?e:t;let s=async e=>{try{await (i.public?e.makePublic():e.makePrivate(i)),a.push(e)}catch(e){if(!i.force)throw e;r.push(e)}};this.getFiles(i).then(([e])=>{let t=(0,eR.default)(10);return Promise.all(e.map(e=>t(()=>s(e))))}).then(()=>t(r.length>0?r:null,a),e=>t(e,a))}getId(){return this.id}disableAutoRetryConditionallyIdempotent_(e,t,r){var a,i;"object"==typeof e&&(null==(i=null==(a=null==e?void 0:e.reqOpts)?void 0:a.qs)?void 0:i.ifMetagenerationMatch)===void 0&&(null==r?void 0:r.ifMetagenerationMatch)===void 0&&(t===E.setMetadata||t===E.delete)&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional?this.storage.retryOptions.autoRetry=!1:this.storage.retryOptions.idempotencyStrategy===S.RetryNever&&(this.storage.retryOptions.autoRetry=!1)}}eO.paginator.extend(ta,"getFiles"),(0,eA.promisifyAll)(ta,{exclude:["cloudStorageURI","request","file","notification","restore"]});class ti extends ek{constructor(e,t,r){super({parent:e,baseUrl:"/channels",id:"",methods:{}}),this.metadata.id=t,this.metadata.resourceId=r}stop(e){e=e||eN.noop,this.request({method:"POST",uri:"/stop",json:this.metadata},(t,r)=>{e(t,r)})}}(0,eA.promisifyAll)(ti);class ts extends ek{constructor(e,t,r){super({parent:e,id:t,baseUrl:`/projects/${r&&r.projectId||e.projectId}/hmacKeys`,methods:{delete:!0,get:!0,getMetadata:!0,setMetadata:{reqOpts:{method:"PUT"}}}}),this.storage=e,this.instanceRetryValue=e.retryOptions.autoRetry}setMetadata(e,t,r){this.storage.retryOptions.idempotencyStrategy!==S.RetryAlways&&(this.storage.retryOptions.autoRetry=!1);let a="object"==typeof t?t:{};r="function"==typeof t?t:r,super.setMetadata(e,a).then(e=>r(null,...e)).catch(r).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}}(0,eA.promisifyAll)(ts),(o=S||(S={}))[o.RetryAlways=0]="RetryAlways",o[o.RetryConditional=1]="RetryConditional",o[o.RetryNever=2]="RetryNever",(p=k||(k={})).EXPIRATION_DATE_INVALID="The expiration date provided was invalid.",p.EXPIRATION_DATE_PAST="An expiration date cannot be in the past.",(d=O||(O={})).BUCKET_NAME_REQUIRED="A bucket name is needed to use Cloud Storage.",d.BUCKET_NAME_REQUIRED_CREATE="A name is required to create a bucket.",d.HMAC_SERVICE_ACCOUNT="The first argument must be a service account email to create an HMAC key.",d.HMAC_ACCESS_ID="An access ID is needed to create an HmacKey object.";let tn=/^(\w*):\/\//,to=S.RetryConditional,tp=function(e){var t;let r=e=>e.includes("eai_again")||"econnreset"===e||"unexpected connection closure"===e||"epipe"===e||"socket connection timeout"===e;if(e){if(-1!==[408,429,500,502,503,504].indexOf(e.code)||"string"==typeof e.code&&(-1!==["408","429","500","502","503","504"].indexOf(e.code)||r(e.code.toLowerCase())))return!0;if(e.errors)for(let a of e.errors){let e=null==(t=null==a?void 0:a.reason)?void 0:t.toString().toLowerCase();if(e&&r(e))return!0}}return!1};class td extends eE{getBucketsStream(){return new ee.Readable}getHmacKeysStream(){return new ee.Readable}constructor(e={}){var t,r,a,i,s,n,o,p,d,l,c,u,h,m;const f=e.universeDomain||C.DEFAULT_UNIVERSE;let g=`https://storage.${f}`,v=!1;const y=process.env.STORAGE_EMULATOR_HOST;"string"==typeof y&&(g=td.sanitizeEndpoint(y),v=!0),e.apiEndpoint&&e.apiEndpoint!==g&&(g=td.sanitizeEndpoint(e.apiEndpoint),v=!0),e=Object.assign({},e,{apiEndpoint:g});const w=y||`${e.apiEndpoint}/storage/v1`,b={apiEndpoint:e.apiEndpoint,retryOptions:{autoRetry:(null==(t=e.retryOptions)?void 0:t.autoRetry)===void 0||(null==(r=e.retryOptions)?void 0:r.autoRetry),maxRetries:(null==(a=e.retryOptions)?void 0:a.maxRetries)?null==(i=e.retryOptions)?void 0:i.maxRetries:3,retryDelayMultiplier:(null==(s=e.retryOptions)?void 0:s.retryDelayMultiplier)?null==(n=e.retryOptions)?void 0:n.retryDelayMultiplier:2,totalTimeout:(null==(o=e.retryOptions)?void 0:o.totalTimeout)?null==(p=e.retryOptions)?void 0:p.totalTimeout:600,maxRetryDelay:(null==(d=e.retryOptions)?void 0:d.maxRetryDelay)?null==(l=e.retryOptions)?void 0:l.maxRetryDelay:64,retryableErrorFn:(null==(c=e.retryOptions)?void 0:c.retryableErrorFn)?null==(u=e.retryOptions)?void 0:u.retryableErrorFn:tp,idempotencyStrategy:(null==(h=e.retryOptions)?void 0:h.idempotencyStrategy)!==void 0?null==(m=e.retryOptions)?void 0:m.idempotencyStrategy:to},baseUrl:w,customEndpoint:v,useAuthWithCustomEndpoint:null==e?void 0:e.useAuthWithCustomEndpoint,projectIdRequired:!1,scopes:["https://www.googleapis.com/auth/iam","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/devstorage.full_control"],packageJson:(0,en.getPackageJSON)()};super(b,e),this.acl=td.acl,this.crc32cGenerator=e.crc32cGenerator||eY,this.retryOptions=b.retryOptions,this.getBucketsStream=eO.paginator.streamify("getBuckets"),this.getHmacKeysStream=eO.paginator.streamify("getHmacKeys")}static sanitizeEndpoint(e){return tn.test(e)||(e=`https://${e}`),e.replace(/\/+$/,"")}bucket(e,t){if(!e)throw Error(O.BUCKET_NAME_REQUIRED);return new ta(this,e,t)}channel(e,t){return new ti(this,e,t)}createBucket(e,t,r){let a;if(!e)throw Error(O.BUCKET_NAME_REQUIRED_CREATE);r?a=t:(r=t,a={});let i={...a,name:e},s={archive:"ARCHIVE",coldline:"COLDLINE",dra:"DURABLE_REDUCED_AVAILABILITY",multiRegional:"MULTI_REGIONAL",nearline:"NEARLINE",regional:"REGIONAL",standard:"STANDARD"};for(let e of Object.keys(s))if(i[e]){if(a.storageClass&&a.storageClass!==e)throw Error(`Both \`${e}\` and \`storageClass\` were provided.`);i.storageClass=s[e],delete i[e]}i.requesterPays&&(i.billing={requesterPays:i.requesterPays},delete i.requesterPays);let n={project:this.projectId};i.userProject&&(n.userProject=i.userProject,delete i.userProject),i.enableObjectRetention&&(n.enableObjectRetention=i.enableObjectRetention,delete i.enableObjectRetention),i.predefinedAcl&&(n.predefinedAcl=i.predefinedAcl,delete i.predefinedAcl),i.predefinedDefaultObjectAcl&&(n.predefinedDefaultObjectAcl=i.predefinedDefaultObjectAcl,delete i.predefinedDefaultObjectAcl),i.projection&&(n.projection=i.projection,delete i.projection),this.request({method:"POST",uri:"/b",qs:n,json:i},(t,a)=>{if(t)return void r(t,null,a);let i=this.bucket(e);i.metadata=a,r(null,i,a)})}createHmacKey(e,t,r){if("string"!=typeof e)throw Error(O.HMAC_SERVICE_ACCOUNT);let{options:a,callback:i}=eo(t,r),s=Object.assign({},a,{serviceAccountEmail:e}),n=s.projectId||this.projectId;delete s.projectId,this.request({method:"POST",uri:`/projects/${n}/hmacKeys`,qs:s,maxRetries:0},(e,t)=>{if(e)return void i(e,null,null,t);let r=t.metadata,a=this.hmacKey(r.accessId,{projectId:r.projectId});a.metadata=t.metadata,i(null,a,t.secret,t)})}getBuckets(e,t){let{options:r,callback:a}=eo(e,t);r.project=r.project||this.projectId,this.request({uri:"/b",qs:r},(e,t)=>{if(e)return void a(e,null,null,t);let i=t.items?t.items:[],s=t.unreachable?t.unreachable:[],n=i.map(e=>{let t=this.bucket(e.id);return t.metadata=e,t});s.length>0&&s.forEach(e=>{let t=e.split("/").pop();if(t){let e=this.bucket(t);e.unreachable=!0,e.metadata={},n.push(e)}}),a(null,n,t.nextPageToken?Object.assign({},r,{pageToken:t.nextPageToken}):null,t)})}getHmacKeys(e,t){let{options:r,callback:a}=eo(e,t),i=Object.assign({},r),s=i.projectId||this.projectId;delete i.projectId,this.request({uri:`/projects/${s}/hmacKeys`,qs:i},(e,t)=>{e?a(e,null,null,t):a(null,(t.items?t.items:[]).map(e=>{let t=this.hmacKey(e.accessId,{projectId:e.projectId});return t.metadata=e,t}),t.nextPageToken?Object.assign({},r,{pageToken:t.nextPageToken}):null,t)})}getServiceAccount(e,t){let{options:r,callback:a}=eo(e,t);this.request({uri:`/projects/${this.projectId}/serviceAccount`,qs:r},(e,t)=>{if(e)return void a(e,null,t);let r={};for(let e in t)t.hasOwnProperty(e)&&(r[e.replace(/_(\w)/g,(e,t)=>t.toUpperCase())]=t[e]);a(null,r,t)})}hmacKey(e,t){if(!e)throw Error(O.HMAC_ACCESS_ID);return new ts(this,e,t)}}td.Bucket=ta,td.Channel=ti,td.File=te,td.HmacKey=ts,td.acl={OWNER_ROLE:"OWNER",READER_ROLE:"READER",WRITER_ROLE:"WRITER"},eO.paginator.extend(td,["getBuckets","getHmacKeys"]),(0,eA.promisifyAll)(td,{exclude:["bucket","channel","hmacKey"]}),e.i(55101),(0,en.getPackageJSON)(),new WeakSet;var tl=e.i(7273);class tc{storage;bucketName;db;constructor(e,t){this.db=e,this.bucketName=t,this.storage=new td}async saveGenerationFile(e){let t=(0,tl.nanoid)(),r=(0,I.createHash)("sha256").update(e.content).digest("hex"),a=`generations/${e.generationId}/${t}/${e.filename}`,i=this.storage.bucket(this.bucketName).file(a);return await i.save(e.content,{contentType:e.contentType,metadata:{sha256:r,generationId:e.generationId,fileId:t}}),await this.db.insertInto("generation_file").values({file_id:t,generation_id:e.generationId,filename:e.filename,content_type:e.contentType,size_bytes:e.content.length.toString(),sha256_hex:r,gcs_path:a,createdAt:new Date}).execute(),{fileId:t}}async downloadFile(e){let[t]=await this.storage.bucket(this.bucketName).file(e).download();return t}}e.s(["GCSBlobStore",()=>tc],59613)},37893,e=>{"use strict";e.i(36553),e.i(59613),e.s([])},55340,e=>{"use strict";var t=e.i(12995),r=e.i(7273);class a{db;constructor(e){this.db=e}async upsertThread(e){let t=new Date,r={user_id:e.userId,updatedAt:t};return void 0!==e.title&&(r.title=e.title),await this.db.insertInto("thread").values({thread_id:e.threadId,app_id:e.appId,tenant_id:e.tenantId||null,user_id:e.userId,title:e.title??null,createdAt:t,updatedAt:t}).onConflict(e=>e.column("thread_id").doUpdateSet(r)).execute(),{threadId:e.threadId}}async upsertThreadByGenerationId(e){let t=await this.db.selectFrom("generation").select(["app_id","thread_id","user_id","tenant_id"]).where("generation_id","=",e.generationId).executeTakeFirst();t&&await this.upsertThread({threadId:t.thread_id,appId:t.app_id,tenantId:t.tenant_id??void 0,userId:t.user_id,title:e.title})}async startGeneration(e){let r=new Date;return await this.db.insertInto("generation").values({generation_id:e.generationId,app_id:e.appId,tenant_id:e.tenantId||null,thread_id:e.threadId,request_id:e.requestId,user_id:e.userId,model:e.model,name:e.name||null,messages:t.sql`cast(${JSON.stringify(e.messages)} as jsonb)`,createdAt:r,updatedAt:r}).execute(),{generationId:e.generationId}}async endGeneration(e){let a=new Date;if(e.responseMessages&&e.responseMessages.length>0){let r=await this.db.selectFrom("generation").select("messages").where("generation_id","=",e.generationId).executeTakeFirst(),i=[...r?.messages||[],...e.responseMessages];await this.db.updateTable("generation").set({messages:t.sql`cast(${JSON.stringify(i)} as jsonb)`,updatedAt:a}).where("generation_id","=",e.generationId).execute()}else await this.db.updateTable("generation").set({updatedAt:a}).where("generation_id","=",e.generationId).execute();await this.db.insertInto("generation_metrics").values({metrics_id:(0,r.nanoid)(),generation_id:e.generationId,latency_ms:e.latencyMs||null,input_tokens:e.usage?.inputTokens||null,output_tokens:e.usage?.outputTokens||null,total_tokens:e.usage?.totalTokens||null,reasoning_tokens:e.usage?.reasoningTokens||null,cached_input_tokens:e.usage?.cachedInputTokens||null,input_cost_usd:e.cost?.inputCostUsd?.toString()||null,output_cost_usd:e.cost?.outputCostUsd?.toString()||null,total_cost_usd:e.cost?.totalCostUsd?.toString()||null,createdAt:a,updatedAt:a}).onConflict(t=>t.column("generation_id").doUpdateSet({latency_ms:e.latencyMs||null,input_tokens:e.usage?.inputTokens||null,output_tokens:e.usage?.outputTokens||null,total_tokens:e.usage?.totalTokens||null,reasoning_tokens:e.usage?.reasoningTokens||null,cached_input_tokens:e.usage?.cachedInputTokens||null,input_cost_usd:e.cost?.inputCostUsd?.toString()||null,output_cost_usd:e.cost?.outputCostUsd?.toString()||null,total_cost_usd:e.cost?.totalCostUsd?.toString()||null,updatedAt:a})).execute()}async appendGenerationError(e){let a=(0,r.nanoid)();return await this.db.insertInto("generation_error").values({error_id:a,generation_id:e.generationId,kind:e.kind||"error",message:e.message,code:e.code||null,stack:e.stack||null,data:t.sql`cast(${JSON.stringify(e.data||{})} as jsonb)`,createdAt:new Date}).execute(),{errorId:a}}async listThreads(e){let t=e.limit||50,r=e.offset||0,a=this.db.selectFrom("thread").selectAll().where("app_id","=",e.appId);return e.tenantId&&(a=a.where("tenant_id","=",e.tenantId)),(await a.orderBy("updatedAt","desc").limit(t).offset(r).execute()).map(e=>({threadId:e.thread_id,appId:e.app_id,tenantId:e.tenant_id,userId:e.user_id,title:e.title,createdAt:e.createdAt,updatedAt:e.updatedAt}))}async getThread(e){let t=await this.db.selectFrom("thread").selectAll().where("thread_id","=",e.threadId).where("app_id","=",e.appId).executeTakeFirst();return t?{threadId:t.thread_id,appId:t.app_id,tenantId:t.tenant_id,userId:t.user_id,title:t.title,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listGenerations(e){let r=e.limit||50,a=this.db.selectFrom("generation").leftJoin("generation_metrics","generation.generation_id","generation_metrics.generation_id").select(["generation.generation_id","generation.request_id","generation.user_id","generation.model","generation.name","generation.messages","generation.createdAt","generation.updatedAt","generation_metrics.latency_ms","generation_metrics.input_tokens","generation_metrics.output_tokens","generation_metrics.total_tokens","generation_metrics.reasoning_tokens","generation_metrics.cached_input_tokens","generation_metrics.input_cost_usd","generation_metrics.output_cost_usd","generation_metrics.total_cost_usd"]).where("generation.app_id","=",e.appId).$if(!!e.tenantId,t=>t.where("tenant_id","=",e.tenantId)).$if(!!e.threadId,t=>t.where("thread_id","=",e.threadId)).$if(!!e.requestId,t=>t.where("request_id","=",e.requestId));if(e.cursor)try{let r=Buffer.from(e.cursor,"base64").toString("utf-8"),i=r.lastIndexOf("|");if(i>0){let e=r.substring(0,i),s=r.substring(i+1);a=a.where(t.sql`("generation"."createdAt", generation_id) < (${new Date(e)}, ${s})`)}}catch{}let i=await a.orderBy("generation.createdAt","desc").orderBy("generation.generation_id","desc").limit(r+1).execute(),s=i.length>r,n=i.slice(0,r),o=null;if(s&&n.length>0){let e=n[n.length-1],t=`${e.createdAt.toISOString()}|${e.generation_id}`;o=Buffer.from(t).toString("base64")}let p=n.map(e=>e.generation_id),d=new Map;if(p.length>0)for(let e of(await this.db.selectFrom("generation_error").select(["generation_id","message"]).where("generation_id","in",p).where("kind","=","error").orderBy("createdAt","desc").execute()))d.has(e.generation_id)||d.set(e.generation_id,e.message);return{generations:n.map(e=>({generationId:e.generation_id,requestId:e.request_id,userId:e.user_id,model:e.model,name:e.name,messages:e.messages,error:d.get(e.generation_id)||null,latencyMs:e.latency_ms,inputTokens:e.input_tokens,outputTokens:e.output_tokens,totalTokens:e.total_tokens,reasoningTokens:e.reasoning_tokens,cachedInputTokens:e.cached_input_tokens,inputCostUsd:e.input_cost_usd,outputCostUsd:e.output_cost_usd,totalCostUsd:e.total_cost_usd,createdAt:e.createdAt,updatedAt:e.updatedAt})),nextCursor:o,hasMore:s}}async getGeneration(e){let t=await this.db.selectFrom("generation").leftJoin("generation_metrics","generation.generation_id","generation_metrics.generation_id").select(["generation.generation_id","generation.request_id","generation.user_id","generation.model","generation.name","generation.messages","generation.createdAt","generation.updatedAt","generation_metrics.latency_ms","generation_metrics.input_tokens","generation_metrics.output_tokens","generation_metrics.total_tokens","generation_metrics.reasoning_tokens","generation_metrics.cached_input_tokens","generation_metrics.input_cost_usd","generation_metrics.output_cost_usd","generation_metrics.total_cost_usd"]).where("generation.generation_id","=",e.generationId).where("generation.app_id","=",e.appId).executeTakeFirst();if(!t)return null;let r=await this.db.selectFrom("generation_error").select("message").where("generation_id","=",e.generationId).where("kind","=","error").orderBy("createdAt","desc").limit(1).executeTakeFirst();return{generationId:t.generation_id,requestId:t.request_id,userId:t.user_id,model:t.model,name:t.name,messages:t.messages,error:r?.message||null,latencyMs:t.latency_ms,inputTokens:t.input_tokens,outputTokens:t.output_tokens,totalTokens:t.total_tokens,reasoningTokens:t.reasoning_tokens,cachedInputTokens:t.cached_input_tokens,inputCostUsd:t.input_cost_usd,outputCostUsd:t.output_cost_usd,totalCostUsd:t.total_cost_usd,createdAt:t.createdAt,updatedAt:t.updatedAt}}async getGenerationErrors(e){return(await this.db.selectFrom("generation_error").selectAll().where("generation_id","=",e.generationId).orderBy("createdAt","asc").execute()).map(e=>({errorId:e.error_id,generationId:e.generation_id,kind:e.kind,message:e.message,code:e.code,stack:e.stack,data:e.data,createdAt:e.createdAt}))}async getGenerationErrorsByIds(e){if(0===e.generationIds.length)return new Map;let t=await this.db.selectFrom("generation_error").selectAll().where("generation_id","in",e.generationIds).orderBy("createdAt","asc").execute(),r=new Map;for(let e of t){let t={errorId:e.error_id,generationId:e.generation_id,kind:e.kind,message:e.message,code:e.code,stack:e.stack,data:e.data,createdAt:e.createdAt},a=r.get(e.generation_id)??[];a.push(t),r.set(e.generation_id,a)}return r}async getGenerationFiles(e){return(await this.db.selectFrom("generation_file").selectAll().where("generation_id","=",e.generationId).orderBy("createdAt","asc").execute()).map(e=>({fileId:e.file_id,generationId:e.generation_id,filename:e.filename,contentType:e.content_type,sizeBytes:e.size_bytes,sha256Hex:e.sha256_hex,gcsPath:e.gcs_path,createdAt:e.createdAt}))}async getGenerationFilesByIds(e){if(0===e.generationIds.length)return new Map;let t=await this.db.selectFrom("generation_file").selectAll().where("generation_id","in",e.generationIds).orderBy("createdAt","asc").execute(),r=new Map;for(let e of t){let t={fileId:e.file_id,generationId:e.generation_id,filename:e.filename,contentType:e.content_type,sizeBytes:e.size_bytes,sha256Hex:e.sha256_hex,gcsPath:e.gcs_path,createdAt:e.createdAt},a=r.get(e.generation_id)??[];a.push(t),r.set(e.generation_id,a)}return r}async getGenerationFile(e){let t=await this.db.selectFrom("generation_file").selectAll().where("file_id","=",e.fileId).where("generation_id","=",e.generationId).executeTakeFirst();return t?{fileId:t.file_id,generationId:t.generation_id,filename:t.filename,contentType:t.content_type,sizeBytes:t.size_bytes,sha256Hex:t.sha256_hex,gcsPath:t.gcs_path,createdAt:t.createdAt}:null}async listThreadsByApp(e){let r=e.limit||50,a=this.db.selectFrom("thread").selectAll().where("app_id","=",e.appId);if(e.cursor)try{let r=Buffer.from(e.cursor,"base64").toString("utf-8"),i=r.lastIndexOf("|");if(i>0){let e=r.substring(0,i),s=r.substring(i+1);a=a.where(t.sql`("updatedAt", thread_id) < (${new Date(e)}, ${s})`)}}catch{}e.filters?.tenantId&&(a=a.where("tenant_id","=",e.filters.tenantId)),e.filters?.userId&&(a=a.where("user_id","=",e.filters.userId)),e.filters?.fromDate&&(a=a.where("createdAt",">=",new Date(e.filters.fromDate))),e.filters?.toDate&&(a=a.where("createdAt","<=",new Date(e.filters.toDate)));let i=await a.orderBy("updatedAt","desc").orderBy("thread_id","desc").limit(r+1).execute(),s=i.length>r,n=i.slice(0,r),o=null;if(s&&n.length>0){let e=n[n.length-1],t=`${e.updatedAt.toISOString()}|${e.thread_id}`;o=Buffer.from(t).toString("base64")}return{threads:n.map(e=>({threadId:e.thread_id,appId:e.app_id,tenantId:e.tenant_id,userId:e.user_id,title:e.title,createdAt:e.createdAt,updatedAt:e.updatedAt})),nextCursor:o,hasMore:s}}}e.s(["PostgresLogStore",()=>a])},97836,e=>{"use strict";var t=e.i(24868),r=e.i(14747),a=e.i(7273);async function i(e){try{let r=await (0,t.readFile)(e,"utf-8");return JSON.parse(r)}catch(e){if("ENOENT"===e.code)return null;throw e}}async function s(e,i){await (0,t.mkdir)((0,r.dirname)(e),{recursive:!0});let s=`${e}.${(0,a.nanoid)()}.tmp`;await (0,t.writeFile)(s,JSON.stringify(i,null,2),"utf-8"),await (0,t.rename)(s,e)}async function n(e){try{let r=await (0,t.readFile)(e,"utf-8"),a=await (0,t.stat)(e);return{data:JSON.parse(r),createdAt:a.birthtime,updatedAt:a.mtime}}catch(e){if("ENOENT"===e.code)return null;throw e}}async function o(e){try{return(await (0,t.readdir)(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(".json")).map(e=>e.name.replace(".json",""))}catch(e){if("ENOENT"===e.code)return[];throw e}}async function p(e){try{let a=await (0,t.readdir)(e,{withFileTypes:!0}),i=[];for(let s of a){if(!s.isFile()||!s.name.endsWith(".json"))continue;let a=(0,r.join)(e,s.name),n=await (0,t.stat)(a);i.push({name:s.name.replace(".json",""),createdAt:n.birthtime})}return i}catch(e){if("ENOENT"===e.code)return[];throw e}}class d{basePath;constructor(e){this.basePath=e}getAppDir(e){return(0,r.join)(this.basePath,"apps",e)}getThreadsDir(e){return(0,r.join)(this.getAppDir(e),"threads")}getThreadPath(e,t){return(0,r.join)(this.getThreadsDir(e),`${t}.json`)}getGenerationsDir(e){return(0,r.join)(this.getAppDir(e),"generations")}getGenerationPath(e,t){return(0,r.join)(this.getGenerationsDir(e),`${t}.json`)}getGenerationsByThreadDir(e,t){return(0,r.join)(this.getAppDir(e),"generations-by-thread",t)}getGenerationByThreadPath(e,t,a){return(0,r.join)(this.getGenerationsByThreadDir(e,t),a)}getGenerationErrorsDir(e,t){return(0,r.join)(this.getAppDir(e),"generation-errors",t)}getGenerationErrorPath(e,t,a){return(0,r.join)(this.getGenerationErrorsDir(e,t),`${a}.json`)}getGenerationFilesDir(e,t){return(0,r.join)(this.getAppDir(e),"generation-files",t)}getGenerationFilePath(e,t,a){return(0,r.join)(this.getGenerationFilesDir(e,t),`${a}.json`)}async upsertThread(e){let t=this.getThreadPath(e.appId,e.threadId),r=await i(t),a={threadId:e.threadId,appId:e.appId,tenantId:e.tenantId||null,userId:e.userId,title:void 0!==e.title?e.title??null:r?.title??null};return await s(t,a),{threadId:e.threadId}}async upsertThreadByGenerationId(e){let t=await i(this.getGenerationPath(e.appId,e.generationId));t&&await this.upsertThread({threadId:t.threadId,appId:t.appId,tenantId:t.tenantId??void 0,userId:t.userId,title:e.title})}async startGeneration(e){let a={generationId:e.generationId,appId:e.appId,tenantId:e.tenantId||null,threadId:e.threadId,requestId:e.requestId,userId:e.userId,model:e.model,name:e.name||null,messages:e.messages,latencyMs:null,inputTokens:null,outputTokens:null,totalTokens:null,reasoningTokens:null,cachedInputTokens:null,inputCostUsd:null,outputCostUsd:null,totalCostUsd:null};await s(this.getGenerationPath(e.appId,e.generationId),a);let i=this.getGenerationByThreadPath(e.appId,e.threadId,e.generationId);return await (0,t.mkdir)((0,r.dirname)(i),{recursive:!0}),await (0,t.writeFile)(i,""),{generationId:e.generationId}}async endGeneration(e){let t=this.getGenerationPath(e.appId,e.generationId),r=await i(t);if(!r)return;let a=e.responseMessages&&e.responseMessages.length>0?[...r.messages,...e.responseMessages]:r.messages,n={...r,messages:a,latencyMs:e.latencyMs??r.latencyMs,inputTokens:e.usage?.inputTokens??r.inputTokens,outputTokens:e.usage?.outputTokens??r.outputTokens,totalTokens:e.usage?.totalTokens??r.totalTokens,reasoningTokens:e.usage?.reasoningTokens??r.reasoningTokens,cachedInputTokens:e.usage?.cachedInputTokens??r.cachedInputTokens,inputCostUsd:e.cost?.inputCostUsd?.toString()??r.inputCostUsd,outputCostUsd:e.cost?.outputCostUsd?.toString()??r.outputCostUsd,totalCostUsd:e.cost?.totalCostUsd?.toString()??r.totalCostUsd};await s(t,n)}async appendGenerationError(e){let t=(0,a.nanoid)(),r={errorId:t,generationId:e.generationId,kind:e.kind||"error",message:e.message,code:e.code||null,stack:e.stack||null,data:e.data||{}};return await s(this.getGenerationErrorPath(e.appId,e.generationId,t),r),{errorId:t}}async listThreads(e){let t=e.limit||50,r=e.offset||0,a=await p(this.getThreadsDir(e.appId));if(a.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),e.tenantId){let i=[],s=0;for(let o of a){let a=await n(this.getThreadPath(e.appId,o.name));if(a&&a.data.tenantId===e.tenantId){if(s<r){s++;continue}if(i.push({threadId:a.data.threadId,appId:a.data.appId,tenantId:a.data.tenantId,userId:a.data.userId,title:a.data.title,createdAt:a.createdAt,updatedAt:a.updatedAt}),i.length>=t)break}}return i}let i=a.slice(r,r+t),s=[];for(let t of i){let r=await n(this.getThreadPath(e.appId,t.name));r&&s.push({threadId:r.data.threadId,appId:r.data.appId,tenantId:r.data.tenantId,userId:r.data.userId,title:r.data.title,createdAt:r.createdAt,updatedAt:r.updatedAt})}return s}async getThread(e){let t=await n(this.getThreadPath(e.appId,e.threadId));return t?{threadId:t.data.threadId,appId:t.data.appId,tenantId:t.data.tenantId,userId:t.data.userId,title:t.data.title,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listGenerations(e){let r,a=e.limit||50,i=e.tenantId||e.requestId;if(e.threadId){let a,i=this.getGenerationsByThreadDir(e.appId,e.threadId);try{a=(await (0,t.readdir)(i,{withFileTypes:!0})).filter(e=>e.isFile()).map(e=>e.name)}catch(e){if("ENOENT"===e.code)a=[];else throw e}let s=[];for(let r of a){let a=this.getGenerationPath(e.appId,r);try{let e=await (0,t.stat)(a);s.push({name:r,createdAt:e.birthtime})}catch{}}r=s}else r=await p(this.getGenerationsDir(e.appId));if(r.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),e.cursor)try{let t=Buffer.from(e.cursor,"base64").toString("utf-8"),a=t.lastIndexOf("|");if(a>0){let e=new Date(t.substring(0,a)),i=t.substring(a+1);r=r.filter(t=>!!(t.createdAt<e)||t.createdAt.getTime()===e.getTime()&&!!(t.name<i))}}catch{}if(i){let t=[];for(let i of r){let r=await n(this.getGenerationPath(e.appId,i.name));if(r&&(!e.tenantId||r.data.tenantId===e.tenantId)&&(!e.requestId||r.data.requestId===e.requestId)&&(t.push({generationId:r.data.generationId,requestId:r.data.requestId,userId:r.data.userId,model:r.data.model,name:r.data.name,messages:r.data.messages,error:null,latencyMs:r.data.latencyMs,inputTokens:r.data.inputTokens,outputTokens:r.data.outputTokens,totalTokens:r.data.totalTokens,reasoningTokens:r.data.reasoningTokens,cachedInputTokens:r.data.cachedInputTokens,inputCostUsd:r.data.inputCostUsd,outputCostUsd:r.data.outputCostUsd,totalCostUsd:r.data.totalCostUsd,createdAt:r.createdAt,updatedAt:r.updatedAt}),t.length>a))break}let i=t.length>a,s=t.slice(0,a),o=null;if(i&&s.length>0){let e=s[s.length-1];o=Buffer.from(`${e.createdAt.toISOString()}|${e.generationId}`).toString("base64")}return{generations:s,nextCursor:o,hasMore:i}}let s=r.length>a,o=r.slice(0,a),d=[];for(let t of o){let r=await n(this.getGenerationPath(e.appId,t.name));r&&d.push({generationId:r.data.generationId,requestId:r.data.requestId,userId:r.data.userId,model:r.data.model,name:r.data.name,messages:r.data.messages,error:null,latencyMs:r.data.latencyMs,inputTokens:r.data.inputTokens,outputTokens:r.data.outputTokens,totalTokens:r.data.totalTokens,reasoningTokens:r.data.reasoningTokens,cachedInputTokens:r.data.cachedInputTokens,inputCostUsd:r.data.inputCostUsd,outputCostUsd:r.data.outputCostUsd,totalCostUsd:r.data.totalCostUsd,createdAt:r.createdAt,updatedAt:r.updatedAt})}let l=null;if(s&&d.length>0){let e=d[d.length-1];l=Buffer.from(`${e.createdAt.toISOString()}|${e.generationId}`).toString("base64")}return{generations:d,nextCursor:l,hasMore:s}}async getGeneration(e){let t=await n(this.getGenerationPath(e.appId,e.generationId));if(!t)return null;let r=(await this.getGenerationErrors({generationId:e.generationId,appId:e.appId})).filter(e=>"error"===e.kind).pop();return{generationId:t.data.generationId,requestId:t.data.requestId,userId:t.data.userId,model:t.data.model,name:t.data.name,messages:t.data.messages,error:r?.message||null,latencyMs:t.data.latencyMs,inputTokens:t.data.inputTokens,outputTokens:t.data.outputTokens,totalTokens:t.data.totalTokens,reasoningTokens:t.data.reasoningTokens,cachedInputTokens:t.data.cachedInputTokens,inputCostUsd:t.data.inputCostUsd,outputCostUsd:t.data.outputCostUsd,totalCostUsd:t.data.totalCostUsd,createdAt:t.createdAt,updatedAt:t.updatedAt}}async getGenerationErrors(e){let t=await o(this.getGenerationErrorsDir(e.appId,e.generationId)),r=[];for(let a of t){let t=await n(this.getGenerationErrorPath(e.appId,e.generationId,a));t&&r.push({errorId:t.data.errorId,generationId:t.data.generationId,kind:t.data.kind,message:t.data.message,code:t.data.code,stack:t.data.stack,data:t.data.data,createdAt:t.createdAt})}return r.sort((e,t)=>e.createdAt.getTime()-t.createdAt.getTime()),r}async getGenerationErrorsByIds(e){let t=new Map;for(let r of e.generationIds){let a=await this.getGenerationErrors({generationId:r,appId:e.appId});t.set(r,a)}return t}async getGenerationFiles(e){let t=await o(this.getGenerationFilesDir(e.appId,e.generationId)),r=[];for(let a of t){let t=await n(this.getGenerationFilePath(e.appId,e.generationId,a));t&&r.push({fileId:t.data.fileId,generationId:t.data.generationId,filename:t.data.filename,contentType:t.data.contentType,sizeBytes:t.data.sizeBytes,sha256Hex:t.data.sha256Hex,gcsPath:t.data.gcsPath,createdAt:t.createdAt})}return r.sort((e,t)=>e.createdAt.getTime()-t.createdAt.getTime()),r}async getGenerationFilesByIds(e){let t=new Map;for(let r of e.generationIds){let a=await this.getGenerationFiles({generationId:r,appId:e.appId});t.set(r,a)}return t}async getGenerationFile(e){let t=await n(this.getGenerationFilePath(e.appId,e.generationId,e.fileId));return t?{fileId:t.data.fileId,generationId:t.data.generationId,filename:t.data.filename,contentType:t.data.contentType,sizeBytes:t.data.sizeBytes,sha256Hex:t.data.sha256Hex,gcsPath:t.data.gcsPath,createdAt:t.createdAt}:null}async listThreadsByApp(e){let t=e.limit||50,r=e.filters?.tenantId||e.filters?.userId||e.filters?.fromDate||e.filters?.toDate,a=await p(this.getThreadsDir(e.appId));if(a.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),e.cursor)try{let t=Buffer.from(e.cursor,"base64").toString("utf-8"),r=t.lastIndexOf("|");if(r>0){let e=new Date(t.substring(0,r)),i=t.substring(r+1);a=a.filter(t=>!!(t.createdAt<e)||t.createdAt.getTime()===e.getTime()&&!!(t.name<i))}}catch{}if(r){let r=[];for(let i of a){let a=await n(this.getThreadPath(e.appId,i.name));if(!(!a||e.filters?.tenantId&&a.data.tenantId!==e.filters.tenantId||e.filters?.userId&&a.data.userId!==e.filters.userId||e.filters?.fromDate&&a.createdAt<new Date(e.filters.fromDate))&&!(e.filters?.toDate&&a.createdAt>new Date(e.filters.toDate))&&(r.push({threadId:a.data.threadId,appId:a.data.appId,tenantId:a.data.tenantId,userId:a.data.userId,title:a.data.title,createdAt:a.createdAt,updatedAt:a.updatedAt}),r.length>t))break}let i=r.length>t,s=r.slice(0,t),o=null;if(i&&s.length>0){let e=s[s.length-1];o=Buffer.from(`${e.createdAt.toISOString()}|${e.threadId}`).toString("base64")}return{threads:s,nextCursor:o,hasMore:i}}let i=a.length>t,s=a.slice(0,t),o=[];for(let t of s){let r=await n(this.getThreadPath(e.appId,t.name));r&&o.push({threadId:r.data.threadId,appId:r.data.appId,tenantId:r.data.tenantId,userId:r.data.userId,title:r.data.title,createdAt:r.createdAt,updatedAt:r.updatedAt})}let d=null;if(i&&o.length>0){let e=o[o.length-1];d=Buffer.from(`${e.createdAt.toISOString()}|${e.threadId}`).toString("base64")}return{threads:o,nextCursor:d,hasMore:i}}}e.s(["LocalLogStore",()=>d])},51e3,e=>{"use strict";e.i(55340),e.i(97836),e.s([])},95678,e=>e.a(async(t,r)=>{try{var a=e.i(14281),i=e.i(96401);e.i(54906);var s=e.i(13932),n=e.i(69855);e.i(37893);var o=e.i(59613),p=e.i(36553);e.i(51e3);var d=e.i(97836),l=e.i(55340),c=t([a]);[a]=c.then?(await c)():c;let u="local"===i.resolvedStoreTypes.log?new d.LocalLogStore(i.config.paths.localStore):new l.PostgresLogStore(a.db),h="local"===i.resolvedStoreTypes.app?new s.LocalAppStore(i.config.paths.localStore,i.config.serverPepper):new n.PostgresAppStore(a.db,i.config.serverPepper),m=function(){if("local"===i.resolvedStoreTypes.blob)return new p.LocalBlobStore(i.config.paths.blobStore,i.config.paths.localStore);let e=i.config.gcs.bucketName;if(!e)throw Error("GCS_BUCKET_NAME environment variable is required when BLOB_STORE_TYPE is gcs");return new o.GCSBlobStore(a.db,e)}();e.s(["appStore",0,h,"blobStore",0,m,"logStore",0,u]),r()}catch(e){r(e)}},!1),53163,e=>{"use strict";var t=e.i(16172);let r=t.z.union([t.z.string(),t.z.custom(e=>e instanceof Uint8Array),t.z.custom(e=>e instanceof ArrayBuffer),t.z.custom(e=>e instanceof URL)]),a=t.z.object({type:t.z.literal("text"),text:t.z.string()}),i=t.z.object({type:t.z.literal("image"),image:r,mediaType:t.z.string().optional()}),s=t.z.object({type:t.z.literal("file"),data:r,filename:t.z.string().optional(),mediaType:t.z.string()}),n=t.z.object({type:t.z.literal("reasoning"),text:t.z.string()}),o=t.z.object({type:t.z.literal("tool-call"),toolCallId:t.z.string(),toolName:t.z.string(),input:t.z.unknown()}),p=t.z.object({type:t.z.literal("tool-result"),toolCallId:t.z.string(),toolName:t.z.string(),output:t.z.unknown()}),d=t.z.object({role:t.z.literal("system"),content:t.z.string()}),l=t.z.object({role:t.z.literal("user"),content:t.z.union([t.z.string(),t.z.array(t.z.union([a,i,s]))])}),c=t.z.object({role:t.z.literal("assistant"),content:t.z.union([t.z.string(),t.z.array(t.z.union([a,s,n,o,p]))]).nullable()}),u=t.z.object({role:t.z.literal("tool"),content:t.z.array(p)}),h=t.z.discriminatedUnion("role",[d,l,c,u]);e.s(["ModelMessageSchema",0,h])},16516,e=>{"use strict";var t=e.i(16172),r=e.i(53163);let a=t.z.object({tenantId:t.z.string().optional(),threadId:t.z.string(),userId:t.z.string(),title:t.z.string().optional()});t.z.object({threadId:t.z.string()});let i=t.z.object({tenantId:t.z.string().optional(),threadId:t.z.string(),requestId:t.z.string(),generationId:t.z.string(),userId:t.z.string(),model:t.z.string(),name:t.z.string().optional(),messages:t.z.array(r.ModelMessageSchema),threadTitle:t.z.string().optional()});t.z.object({generationId:t.z.string()});let s=t.z.object({generationId:t.z.string(),responseMessages:t.z.array(r.ModelMessageSchema).optional(),latencyMs:t.z.number().optional(),usage:t.z.object({inputTokens:t.z.number().optional(),outputTokens:t.z.number().optional(),totalTokens:t.z.number().optional(),reasoningTokens:t.z.number().optional(),cachedInputTokens:t.z.number().optional()}).optional(),cost:t.z.object({inputCostUsd:t.z.number().optional(),outputCostUsd:t.z.number().optional(),totalCostUsd:t.z.number().optional()}).optional(),threadTitle:t.z.string().optional()});t.z.object({generationId:t.z.string()});let n=t.z.object({kind:t.z.enum(["error","warning","retry","tool_error"]).optional(),message:t.z.string(),code:t.z.string().optional(),stack:t.z.string().optional(),data:t.z.record(t.z.unknown()).optional()});t.z.object({errorId:t.z.string()}),t.z.object({fileId:t.z.string()});let o=t.z.object({generationId:t.z.string(),kind:t.z.enum(["error","warning","retry","tool_error"]).optional(),message:t.z.string(),code:t.z.string().optional(),stack:t.z.string().optional(),data:t.z.record(t.z.unknown()).optional()}),p=t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("generation_start"),data:i}),t.z.object({type:t.z.literal("generation_end"),data:s}),t.z.object({type:t.z.literal("generation_error"),data:o})]),d=t.z.object({operations:t.z.array(p)}),l=t.z.object({success:t.z.boolean(),generationId:t.z.string().optional(),errorId:t.z.string().optional(),error:t.z.string().optional()});t.z.object({results:t.z.array(l)}),e.s(["BatchRequestSchema",0,d,"GenerationEndRequestSchema",0,s,"GenerationErrorRequestSchema",0,n,"GenerationStartRequestSchema",0,i,"ThreadUpsertRequestSchema",0,a])},5941,e=>{"use strict";let t="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,r=new Set,a="object"==typeof process&&process?process:{},i=(e,t,r,i)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,r,i):console.error(`[${r}] ${t}: ${e}`)},s=globalThis.AbortController,n=globalThis.AbortSignal;if(void 0===s){n=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},s=class{constructor(){t()}signal=new n;abort(e){if(!this.signal.aborted){for(let t of(this.signal.reason=e,this.signal.aborted=!0,this.signal._onabort))t(e);this.signal.onabort?.(e)}}};let e=a.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,i("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");let o=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),p=e=>o(e)?e<=256?Uint8Array:e<=65536?Uint16Array:e<=0x100000000?Uint32Array:e<=Number.MAX_SAFE_INTEGER?d:null:null;class d extends Array{constructor(e){super(e),this.fill(0)}}class l{heap;length;static #eG=!1;static create(e){let t=p(e);if(!t)return[];l.#eG=!0;let r=new l(e,t);return l.#eG=!1,r}constructor(e,t){if(!l.#eG)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class c{#eH;#eK;#eJ;#eZ;#eQ;#eY;#eX;#e1;get perf(){return this.#e1}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#e0;#e2;#e6;#e4;#e3;#e9;#e5;#e8;#e7;#te;#tt;#tr;#ta;#ti;#ts;#tn;#to;#tp;#td;static unsafeExposeInternals(e){return{starts:e.#ta,ttls:e.#ti,autopurgeTimers:e.#ts,sizes:e.#tr,keyMap:e.#e6,keyList:e.#e4,valList:e.#e3,next:e.#e9,prev:e.#e5,get head(){return e.#e8},get tail(){return e.#e7},free:e.#te,isBackgroundFetch:t=>e.#tl(t),backgroundFetch:(t,r,a,i)=>e.#tc(t,r,a,i),moveToTail:t=>e.#tu(t),indexes:t=>e.#th(t),rindexes:t=>e.#tm(t),isStale:t=>e.#tf(t)}}get max(){return this.#eH}get maxSize(){return this.#eK}get calculatedSize(){return this.#e2}get size(){return this.#e0}get fetchMethod(){return this.#eY}get memoMethod(){return this.#eX}get dispose(){return this.#eJ}get onInsert(){return this.#eZ}get disposeAfter(){return this.#eQ}constructor(e){const{max:a=0,ttl:s,ttlResolution:n=1,ttlAutopurge:d,updateAgeOnGet:u,updateAgeOnHas:h,allowStale:m,dispose:f,onInsert:g,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:w,maxSize:b=0,maxEntrySize:_=0,sizeCalculation:x,fetchMethod:N,memoMethod:T,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:k,ignoreFetchAbort:O,perf:C}=e;if(void 0!==C&&"function"!=typeof C?.now)throw TypeError("perf option must have a now() method if specified");if(this.#e1=C??t,0!==a&&!o(a))throw TypeError("max option must be a nonnegative integer");const I=a?p(a):Array;if(!I)throw Error("invalid max value: "+a);if(this.#eH=a,this.#eK=b,this.maxEntrySize=_||this.#eK,this.sizeCalculation=x,this.sizeCalculation){if(!this.#eK&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw TypeError("sizeCalculation set to non-function")}if(void 0!==T&&"function"!=typeof T)throw TypeError("memoMethod must be a function if defined");if(this.#eX=T,void 0!==N&&"function"!=typeof N)throw TypeError("fetchMethod must be a function if specified");if(this.#eY=N,this.#to=!!N,this.#e6=new Map,this.#e4=Array(a).fill(void 0),this.#e3=Array(a).fill(void 0),this.#e9=new I(a),this.#e5=new I(a),this.#e8=0,this.#e7=0,this.#te=l.create(a),this.#e0=0,this.#e2=0,"function"==typeof f&&(this.#eJ=f),"function"==typeof g&&(this.#eZ=g),"function"==typeof v?(this.#eQ=v,this.#tt=[]):(this.#eQ=void 0,this.#tt=void 0),this.#tn=!!this.#eJ,this.#td=!!this.#eZ,this.#tp=!!this.#eQ,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!k,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#eK&&!o(this.#eK))throw TypeError("maxSize must be a positive integer if specified");if(!o(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#tg()}if(this.allowStale=!!m,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!u,this.updateAgeOnHas=!!h,this.ttlResolution=o(n)||0===n?n:1,this.ttlAutopurge=!!d,this.ttl=s||0,this.ttl){if(!o(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#tv()}if(0===this.#eH&&0===this.ttl&&0===this.#eK)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#eH&&!this.#eK){const e="LRU_CACHE_UNBOUNDED";r.has(e)||(r.add(e),i("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,c))}}getRemainingTTL(e){return this.#e6.has(e)?1/0:0}#tv(){let e=new d(this.#eH),t=new d(this.#eH);this.#ti=e,this.#ta=t;let r=this.ttlAutopurge?Array(this.#eH):void 0;this.#ts=r,this.#ty=(a,i,s=this.#e1.now())=>{if(t[a]=0!==i?s:0,e[a]=i,r?.[a]&&(clearTimeout(r[a]),r[a]=void 0),0!==i&&r){let e=setTimeout(()=>{this.#tf(a)&&this.#tw(this.#e4[a],"expire")},i+1);e.unref&&e.unref(),r[a]=e}},this.#tb=r=>{t[r]=0!==e[r]?this.#e1.now():0},this.#t_=(r,s)=>{if(e[s]){let n=e[s],o=t[s];if(!n||!o)return;r.ttl=n,r.start=o,r.now=a||i();let p=r.now-o;r.remainingTTL=n-p}};let a=0,i=()=>{let e=this.#e1.now();if(this.ttlResolution>0){a=e;let t=setTimeout(()=>a=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=r=>{let s=this.#e6.get(r);if(void 0===s)return 0;let n=e[s],o=t[s];return n&&o?n-((a||i())-o):1/0},this.#tf=r=>{let s=t[r],n=e[r];return!!n&&!!s&&(a||i())-s>n}}#tb=()=>{};#t_=()=>{};#ty=()=>{};#tf=()=>!1;#tg(){let e=new d(this.#eH);this.#e2=0,this.#tr=e,this.#tx=t=>{this.#e2-=e[t],e[t]=0},this.#tN=(e,t,r,a)=>{if(this.#tl(t))return 0;if(!o(r))if(a){if("function"!=typeof a)throw TypeError("sizeCalculation must be a function");if(!o(r=a(t,e)))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#tT=(t,r,a)=>{if(e[t]=r,this.#eK){let r=this.#eK-e[t];for(;this.#e2>r;)this.#tE(!0)}this.#e2+=e[t],a&&(a.entrySize=r,a.totalCalculatedSize=this.#e2)}}#tx=e=>{};#tT=(e,t,r)=>{};#tN=(e,t,r,a)=>{if(r||a)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#th({allowStale:e=this.allowStale}={}){if(this.#e0)for(let t=this.#e7;this.#tA(t)&&((e||!this.#tf(t))&&(yield t),t!==this.#e8);)t=this.#e5[t]}*#tm({allowStale:e=this.allowStale}={}){if(this.#e0)for(let t=this.#e8;this.#tA(t)&&((e||!this.#tf(t))&&(yield t),t!==this.#e7);)t=this.#e9[t]}#tA(e){return void 0!==e&&this.#e6.get(this.#e4[e])===e}*entries(){for(let e of this.#th())void 0===this.#e3[e]||void 0===this.#e4[e]||this.#tl(this.#e3[e])||(yield[this.#e4[e],this.#e3[e]])}*rentries(){for(let e of this.#tm())void 0===this.#e3[e]||void 0===this.#e4[e]||this.#tl(this.#e3[e])||(yield[this.#e4[e],this.#e3[e]])}*keys(){for(let e of this.#th()){let t=this.#e4[e];void 0===t||this.#tl(this.#e3[e])||(yield t)}}*rkeys(){for(let e of this.#tm()){let t=this.#e4[e];void 0===t||this.#tl(this.#e3[e])||(yield t)}}*values(){for(let e of this.#th())void 0===this.#e3[e]||this.#tl(this.#e3[e])||(yield this.#e3[e])}*rvalues(){for(let e of this.#tm())void 0===this.#e3[e]||this.#tl(this.#e3[e])||(yield this.#e3[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#th()){let a=this.#e3[r],i=this.#tl(a)?a.__staleWhileFetching:a;if(void 0!==i&&e(i,this.#e4[r],this))return this.get(this.#e4[r],t)}}forEach(e,t=this){for(let r of this.#th()){let a=this.#e3[r],i=this.#tl(a)?a.__staleWhileFetching:a;void 0!==i&&e.call(t,i,this.#e4[r],this)}}rforEach(e,t=this){for(let r of this.#tm()){let a=this.#e3[r],i=this.#tl(a)?a.__staleWhileFetching:a;void 0!==i&&e.call(t,i,this.#e4[r],this)}}purgeStale(){let e=!1;for(let t of this.#tm({allowStale:!0}))this.#tf(t)&&(this.#tw(this.#e4[t],"expire"),e=!0);return e}info(e){let t=this.#e6.get(e);if(void 0===t)return;let r=this.#e3[t],a=this.#tl(r)?r.__staleWhileFetching:r;if(void 0===a)return;let i={value:a};if(this.#ti&&this.#ta){let e=this.#ti[t],r=this.#ta[t];e&&r&&(i.ttl=e-(this.#e1.now()-r),i.start=Date.now())}return this.#tr&&(i.size=this.#tr[t]),i}dump(){let e=[];for(let t of this.#th({allowStale:!0})){let r=this.#e4[t],a=this.#e3[t],i=this.#tl(a)?a.__staleWhileFetching:a;if(void 0===i||void 0===r)continue;let s={value:i};if(this.#ti&&this.#ta){s.ttl=this.#ti[t];let e=this.#e1.now()-this.#ta[t];s.start=Math.floor(Date.now()-e)}this.#tr&&(s.size=this.#tr[t]),e.unshift([r,s])}return e}load(e){for(let[t,r]of(this.clear(),e)){if(r.start){let e=Date.now()-r.start;r.start=this.#e1.now()-e}this.set(t,r.value,r)}}set(e,t,r={}){if(void 0===t)return this.delete(e),this;let{ttl:a=this.ttl,start:i,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:n=this.sizeCalculation,status:o}=r,{noUpdateTTL:p=this.noUpdateTTL}=r,d=this.#tN(e,t,r.size||0,n);if(this.maxEntrySize&&d>this.maxEntrySize)return o&&(o.set="miss",o.maxEntrySizeExceeded=!0),this.#tw(e,"set"),this;let l=0===this.#e0?void 0:this.#e6.get(e);if(void 0===l)l=0===this.#e0?this.#e7:0!==this.#te.length?this.#te.pop():this.#e0===this.#eH?this.#tE(!1):this.#e0,this.#e4[l]=e,this.#e3[l]=t,this.#e6.set(e,l),this.#e9[this.#e7]=l,this.#e5[l]=this.#e7,this.#e7=l,this.#e0++,this.#tT(l,d,o),o&&(o.set="add"),p=!1,this.#td&&this.#eZ?.(t,e,"add");else{this.#tu(l);let r=this.#e3[l];if(t!==r){if(this.#to&&this.#tl(r)){r.__abortController.abort(Error("replaced"));let{__staleWhileFetching:t}=r;void 0!==t&&!s&&(this.#tn&&this.#eJ?.(t,e,"set"),this.#tp&&this.#tt?.push([t,e,"set"]))}else!s&&(this.#tn&&this.#eJ?.(r,e,"set"),this.#tp&&this.#tt?.push([r,e,"set"]));if(this.#tx(l),this.#tT(l,d,o),this.#e3[l]=t,o){o.set="replace";let e=r&&this.#tl(r)?r.__staleWhileFetching:r;void 0!==e&&(o.oldValue=e)}}else o&&(o.set="update");this.#td&&this.onInsert?.(t,e,t===r?"update":"replace")}if(0===a||this.#ti||this.#tv(),this.#ti&&(p||this.#ty(l,a,i),o&&this.#t_(o,l)),!s&&this.#tp&&this.#tt){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}return this}pop(){try{for(;this.#e0;){let e=this.#e3[this.#e8];if(this.#tE(!0),this.#tl(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#tp&&this.#tt){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}}}#tE(e){let t=this.#e8,r=this.#e4[t],a=this.#e3[t];return this.#to&&this.#tl(a)?a.__abortController.abort(Error("evicted")):(this.#tn||this.#tp)&&(this.#tn&&this.#eJ?.(a,r,"evict"),this.#tp&&this.#tt?.push([a,r,"evict"])),this.#tx(t),this.#ts?.[t]&&(clearTimeout(this.#ts[t]),this.#ts[t]=void 0),e&&(this.#e4[t]=void 0,this.#e3[t]=void 0,this.#te.push(t)),1===this.#e0?(this.#e8=this.#e7=0,this.#te.length=0):this.#e8=this.#e9[t],this.#e6.delete(r),this.#e0--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:a}=t,i=this.#e6.get(e);if(void 0!==i){let e=this.#e3[i];if(this.#tl(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#tf(i))return r&&this.#tb(i),a&&(a.has="hit",this.#t_(a,i)),!0;a&&(a.has="stale",this.#t_(a,i))}else a&&(a.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,a=this.#e6.get(e);if(void 0===a||!r&&this.#tf(a))return;let i=this.#e3[a];return this.#tl(i)?i.__staleWhileFetching:i}#tc(e,t,r,a){let i=void 0===t?void 0:this.#e3[t];if(this.#tl(i))return i;let n=new s,{signal:o}=r;o?.addEventListener("abort",()=>n.abort(o.reason),{signal:n.signal});let p={signal:n.signal,options:r,context:a},d=(a,i=!1)=>{let{aborted:s}=n.signal,o=r.ignoreFetchAbort&&void 0!==a;if(r.status&&(s&&!i?(r.status.fetchAborted=!0,r.status.fetchError=n.signal.reason,o&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),s&&!o&&!i)return l(n.signal.reason);let d=this.#e3[t];return(d===u||o&&i&&void 0===d)&&(void 0===a?void 0!==u.__staleWhileFetching?this.#e3[t]=u.__staleWhileFetching:this.#tw(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,a,p.options))),a},l=a=>{let{aborted:i}=n.signal,s=i&&r.allowStaleOnFetchAbort,o=s||r.allowStaleOnFetchRejection,p=o||r.noDeleteOnFetchRejection;if(this.#e3[t]===u&&(p&&void 0!==u.__staleWhileFetching?s||(this.#e3[t]=u.__staleWhileFetching):this.#tw(e,"fetch")),o)return r.status&&void 0!==u.__staleWhileFetching&&(r.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw a},c=(t,a)=>{let s=this.#eY?.(e,i,p);s&&s instanceof Promise&&s.then(e=>t(void 0===e?void 0:e),a),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>d(e,!0)))})};r.status&&(r.status.fetchDispatched=!0);let u=new Promise(c).then(d,e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),l(e))),h=Object.assign(u,{__abortController:n,__staleWhileFetching:i,__returned:void 0});return void 0===t?(this.set(e,h,{...p.options,status:void 0}),t=this.#e6.get(e)):this.#e3[t]=h,h}#tl(e){return!!this.#to&&!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof s}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:n=this.noDisposeOnSet,size:o=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:c=this.allowStaleOnFetchRejection,ignoreFetchAbort:u=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:v}=t;if(!this.#to)return g&&(g.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:i,status:g});let y={allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:i,ttl:s,noDisposeOnSet:n,size:o,sizeCalculation:p,noUpdateTTL:d,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:h,ignoreFetchAbort:u,status:g,signal:v},w=this.#e6.get(e);if(void 0===w){g&&(g.fetch="miss");let t=this.#tc(e,w,y,m);return t.__returned=t}{let t=this.#e3[w];if(this.#tl(t)){let e=r&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#tf(w);if(!f&&!i)return g&&(g.fetch="hit"),this.#tu(w),a&&this.#tb(w),g&&this.#t_(g,w),t;let s=this.#tc(e,w,y,m),n=void 0!==s.__staleWhileFetching&&r;return g&&(g.fetch=i?"stale":"refresh",n&&i&&(g.returnedStale=!0)),n?s.__staleWhileFetching:s.__returned=s}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(void 0===r)throw Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#eX;if(!r)throw Error("no memoMethod provided to constructor");let{context:a,forceRefresh:i,...s}=t,n=this.get(e,s);if(!i&&void 0!==n)return n;let o=r(e,n,{options:s,context:a});return this.set(e,o,s),o}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:s}=t,n=this.#e6.get(e);if(void 0!==n){let t=this.#e3[n],o=this.#tl(t);return(s&&this.#t_(s,n),this.#tf(n))?(s&&(s.get="stale"),o)?(s&&r&&void 0!==t.__staleWhileFetching&&(s.returnedStale=!0),r?t.__staleWhileFetching:void 0):(i||this.#tw(e,"expire"),s&&r&&(s.returnedStale=!0),r?t:void 0):(s&&(s.get="hit"),o)?t.__staleWhileFetching:(this.#tu(n),a&&this.#tb(n),t)}s&&(s.get="miss")}#tS(e,t){this.#e5[t]=e,this.#e9[e]=t}#tu(e){e!==this.#e7&&(e===this.#e8?this.#e8=this.#e9[e]:this.#tS(this.#e5[e],this.#e9[e]),this.#tS(this.#e7,e),this.#e7=e)}delete(e){return this.#tw(e,"delete")}#tw(e,t){let r=!1;if(0!==this.#e0){let a=this.#e6.get(e);if(void 0!==a)if(this.#ts?.[a]&&(clearTimeout(this.#ts?.[a]),this.#ts[a]=void 0),r=!0,1===this.#e0)this.#tk(t);else{this.#tx(a);let r=this.#e3[a];if(this.#tl(r)?r.__abortController.abort(Error("deleted")):(this.#tn||this.#tp)&&(this.#tn&&this.#eJ?.(r,e,t),this.#tp&&this.#tt?.push([r,e,t])),this.#e6.delete(e),this.#e4[a]=void 0,this.#e3[a]=void 0,a===this.#e7)this.#e7=this.#e5[a];else if(a===this.#e8)this.#e8=this.#e9[a];else{let e=this.#e5[a];this.#e9[e]=this.#e9[a];let t=this.#e9[a];this.#e5[t]=this.#e5[a]}this.#e0--,this.#te.push(a)}}if(this.#tp&&this.#tt?.length){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}return r}clear(){return this.#tk("delete")}#tk(e){for(let t of this.#tm({allowStale:!0})){let r=this.#e3[t];if(this.#tl(r))r.__abortController.abort(Error("deleted"));else{let a=this.#e4[t];this.#tn&&this.#eJ?.(r,a,e),this.#tp&&this.#tt?.push([r,a,e])}}if(this.#e6.clear(),this.#e3.fill(void 0),this.#e4.fill(void 0),this.#ti&&this.#ta){for(let e of(this.#ti.fill(0),this.#ta.fill(0),this.#ts??[]))void 0!==e&&clearTimeout(e);this.#ts?.fill(void 0)}if(this.#tr&&this.#tr.fill(0),this.#e8=0,this.#e7=0,this.#te.length=0,this.#e2=0,this.#e0=0,this.#tp&&this.#tt){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}}}let u=new c({max:1e3,ttl:3e5});function h(e){return async(t,r)=>{let a=t.req.header("Authorization"),i=t.req.header("X-API-Key"),s=null;if(a?.startsWith("Bearer ")?s=a.substring(7):i&&(s=i),!s)return t.json({error:"Missing API key"},401);let n=u.get(s);if(n){t.set("auth",n),await r();return}let o=await e.verifyApiKey(s);return o?o.scopes.includes("log:write")?void(u.set(s,o),t.set("auth",o),await r()):t.json({error:"Insufficient permissions"},403):t.json({error:"Invalid or revoked API key"},401)}}e.s(["createAuthMiddleware",()=>h],5941)},17016,e=>{"use strict";function t(e){return async(t,r)=>{let a=t.req.header("X-App")||"default",i={keyId:"standalone",appId:(await e.getOrCreateAppByName(a)).appId,scopes:["log:write"]};t.set("auth",i),await r()}}e.s(["createStandaloneAuthMiddleware",()=>t])},23802,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(96401),n=e.i(95678),o=e.i(16516),p=e.i(5941),d=e.i(17016),l=t([n]);[n]=l.then?(await l)():l;let c=s.config.standaloneMode?(0,d.createStandaloneAuthMiddleware)(n.appStore):(0,p.createAuthMiddleware)(n.appStore),u=new a.Hono().use(c).post("/thread",(0,i.zValidator)("json",o.ThreadUpsertRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth");await n.logStore.upsertThread({threadId:t.threadId,appId:r.appId,tenantId:t.tenantId,userId:t.userId,title:t.title});let a={threadId:t.threadId};return e.json(a)}).post("/generation/start",(0,i.zValidator)("json",o.GenerationStartRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth");await n.logStore.upsertThread({threadId:t.threadId,appId:r.appId,tenantId:t.tenantId,userId:t.userId,title:t.threadTitle});let{generationId:a}=await n.logStore.startGeneration({generationId:t.generationId,appId:r.appId,tenantId:t.tenantId,threadId:t.threadId,requestId:t.requestId,userId:t.userId,model:t.model,name:t.name,messages:t.messages});return e.json({generationId:a})}).post("/generation/end",(0,i.zValidator)("json",o.GenerationEndRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth");await n.logStore.endGeneration({appId:r.appId,generationId:t.generationId,responseMessages:t.responseMessages,latencyMs:t.latencyMs,usage:t.usage,cost:t.cost}),t.threadTitle&&await n.logStore.upsertThreadByGenerationId({appId:r.appId,generationId:t.generationId,title:t.threadTitle});let a={generationId:t.generationId};return e.json(a)}).post("/generation/:generationId/error",(0,i.zValidator)("json",o.GenerationErrorRequestSchema),async e=>{let t=e.req.param("generationId"),r=e.req.valid("json"),a=e.get("auth"),i={errorId:(await n.logStore.appendGenerationError({appId:a.appId,generationId:t,kind:r.kind,message:r.message,code:r.code,stack:r.stack,data:r.data})).errorId};return e.json(i)}).post("/generation/:generationId/file",async e=>{let t=e.req.param("generationId"),r=e.get("auth"),a=await e.req.formData(),i=a.get("file"),s=a.get("filename"),o=a.get("contentType");if(!i||!s||!o)return e.json({error:"Missing required fields: file, filename, contentType"},400);if(i.size>0xa00000)return e.json({error:"File too large. Maximum size is 10MB"},413);let p=await i.arrayBuffer(),d=Buffer.from(p),{fileId:l}=await n.blobStore.saveGenerationFile({appId:r.appId,generationId:t,filename:s,contentType:o,content:d});return e.json({fileId:l})}).post("/batch",(0,i.zValidator)("json",o.BatchRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth"),a=[];for(let e of t.operations)try{switch(e.type){case"generation_start":{let t=e.data;await n.logStore.upsertThread({threadId:t.threadId,appId:r.appId,tenantId:t.tenantId,userId:t.userId,title:t.threadTitle});let{generationId:i}=await n.logStore.startGeneration({generationId:t.generationId,appId:r.appId,tenantId:t.tenantId,threadId:t.threadId,requestId:t.requestId,userId:t.userId,model:t.model,name:t.name,messages:t.messages});a.push({success:!0,generationId:i});break}case"generation_end":{let t=e.data;await n.logStore.endGeneration({appId:r.appId,generationId:t.generationId,responseMessages:t.responseMessages,latencyMs:t.latencyMs,usage:t.usage,cost:t.cost}),t.threadTitle&&await n.logStore.upsertThreadByGenerationId({appId:r.appId,generationId:t.generationId,title:t.threadTitle}),a.push({success:!0,generationId:t.generationId});break}case"generation_error":{let t=e.data,i=await n.logStore.appendGenerationError({appId:r.appId,generationId:t.generationId,kind:t.kind,message:t.message,code:t.code,stack:t.stack,data:t.data});a.push({success:!0,errorId:i.errorId})}}}catch(e){a.push({success:!1,error:e instanceof Error?e.message:"Unknown error"})}return e.json({results:a})});e.s(["collectRoutes",0,u]),r()}catch(e){r(e)}},!1),99030,e=>{"use strict";var t=e.i(16172),r=e.i(53163);let a=t.z.object({name:t.z.string(),metadata:t.z.record(t.z.unknown()).optional()}),i=t.z.object({name:t.z.string().optional(),metadata:t.z.record(t.z.unknown()).optional()});t.z.object({appId:t.z.string(),name:t.z.string(),metadata:t.z.record(t.z.unknown()),createdAt:t.z.string(),updatedAt:t.z.string()});let s=t.z.object({threadId:t.z.string(),tenantId:t.z.string().nullable(),userId:t.z.string(),title:t.z.string().nullable(),createdAt:t.z.string(),updatedAt:t.z.string()});t.z.object({threads:t.z.array(s),nextCursor:t.z.string().nullable(),hasMore:t.z.boolean()});let n=t.z.object({generationId:t.z.string(),requestId:t.z.string(),userId:t.z.string(),model:t.z.string(),name:t.z.string().nullable(),messages:t.z.array(r.ModelMessageSchema),error:t.z.string().nullable(),latencyMs:t.z.number().nullable(),usage:t.z.object({inputTokens:t.z.number().nullable(),outputTokens:t.z.number().nullable(),totalTokens:t.z.number().nullable(),reasoningTokens:t.z.number().nullable(),cachedInputTokens:t.z.number().nullable()}).nullable(),cost:t.z.object({inputCostUsd:t.z.number().nullable(),outputCostUsd:t.z.number().nullable(),totalCostUsd:t.z.number().nullable()}).nullable(),metadata:t.z.record(t.z.unknown()),createdAt:t.z.string(),updatedAt:t.z.string()}),o=t.z.object({errorId:t.z.string(),generationId:t.z.string(),kind:t.z.string(),message:t.z.string(),code:t.z.string().nullable(),stack:t.z.string().nullable(),data:t.z.record(t.z.unknown()).nullable(),createdAt:t.z.string()}),p=t.z.object({fileId:t.z.string(),generationId:t.z.string(),filename:t.z.string(),contentType:t.z.string(),sizeBytes:t.z.string(),sha256Hex:t.z.string(),gcsPath:t.z.string(),createdAt:t.z.string()});n.extend({errors:t.z.array(o),files:t.z.array(p)});let d=t.z.object({name:t.z.string(),scopes:t.z.array(t.z.string()),metadata:t.z.record(t.z.unknown()).optional()});t.z.object({keyId:t.z.string(),keyPrefix:t.z.string(),appId:t.z.string(),name:t.z.string(),scopes:t.z.array(t.z.string()),lastUsedAt:t.z.string().nullable(),revokedAt:t.z.string().nullable(),createdAt:t.z.string()}),t.z.object({keyId:t.z.string(),keyPrefix:t.z.string(),apiKey:t.z.string()}),e.s(["CreateApiKeyRequestSchema",0,d,"CreateAppRequestSchema",0,a,"UpdateAppRequestSchema",0,i])},9253,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(95678),n=e.i(99030),o=t([s]);[s]=o.then?(await o)():o;let p=new a.Hono().post("/apps",(0,i.zValidator)("json",n.CreateAppRequestSchema),async e=>{let t=e.req.valid("json"),r=await s.appStore.createApp({name:t.name,metadata:t.metadata}),a={appId:r.appId,name:r.name,metadata:r.metadata,createdAt:r.createdAt.toISOString(),updatedAt:r.updatedAt.toISOString()};return e.json(a,201)}).get("/apps",async e=>{let t=e.req.query("limit")?parseInt(e.req.query("limit")):50,r=e.req.query("offset")?parseInt(e.req.query("offset")):0,a=(await s.appStore.listApps({limit:t,offset:r})).map(e=>({appId:e.appId,name:e.name,metadata:e.metadata,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()}));return e.json({apps:a})}).get("/apps/:appId",async e=>{let t=e.req.param("appId"),r=await s.appStore.getApp(t);if(!r)return e.json({error:"App not found"},404);let a={appId:r.appId,name:r.name,metadata:r.metadata,createdAt:r.createdAt.toISOString(),updatedAt:r.updatedAt.toISOString()};return e.json(a)}).put("/apps/:appId",(0,i.zValidator)("json",n.UpdateAppRequestSchema),async e=>{let t=e.req.param("appId"),r=e.req.valid("json"),a=await s.appStore.updateApp({appId:t,name:r.name,metadata:r.metadata});if(!a)return e.json({error:"App not found"},404);let i={appId:a.appId,name:a.name,metadata:a.metadata,createdAt:a.createdAt.toISOString(),updatedAt:a.updatedAt.toISOString()};return e.json(i)}).delete("/apps/:appId",async e=>{let t=e.req.param("appId");return await s.appStore.deleteApp(t),e.json({success:!0})}).get("/apps/:appId/api-keys",async e=>{let t=e.req.param("appId"),r=(await s.appStore.listApiKeys({appId:t})).map(e=>({keyId:e.keyId,keyPrefix:e.keyPrefix,appId:e.appId,name:e.name,scopes:e.scopes,lastUsedAt:e.lastUsedAt?.toISOString()??null,revokedAt:e.revokedAt?.toISOString()??null,createdAt:e.createdAt.toISOString()}));return e.json({keys:r})}).post("/apps/:appId/api-keys",(0,i.zValidator)("json",n.CreateApiKeyRequestSchema),async e=>{let t=e.req.param("appId"),r=e.req.valid("json"),a=await s.appStore.createApiKey({appId:t,name:r.name,scopes:r.scopes,metadata:r.metadata});return e.json({keyId:a.keyId,keyPrefix:a.keyPrefix,apiKey:a.apiKey},201)}).delete("/apps/:appId/api-keys/:keyId",async e=>{let t=e.req.param("appId"),r=e.req.param("keyId");return await s.appStore.revokeApiKey(t,r),e.json({success:!0})});e.s(["appsRoutes",0,p]),r()}catch(e){r(e)}},!1),49534,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(16172),n=e.i(95678),o=t([n]);[n]=o.then?(await o)():o;let p=s.z.object({tenantId:s.z.string().optional(),userId:s.z.string().optional(),from:s.z.string().optional(),to:s.z.string().optional(),limit:s.z.string().optional(),cursor:s.z.string().optional()}),d=new a.Hono().get("/apps/:appId/threads",(0,i.zValidator)("query",p),async e=>{let t=e.req.param("appId"),r=e.req.valid("query"),a=r.tenantId,i=r.userId,s=r.from,o=r.to,p=r.limit?parseInt(r.limit):50,d=r.cursor,l=await n.logStore.listThreadsByApp({appId:t,limit:p,cursor:d,filters:{tenantId:a||void 0,userId:i||void 0,fromDate:s||void 0,toDate:o||void 0}}),c={threads:l.threads.map(e=>({threadId:e.threadId,tenantId:e.tenantId,userId:e.userId,title:e.title,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})),nextCursor:l.nextCursor,hasMore:l.hasMore};return e.json(c)}).get("/apps/:appId/threads/:threadId",async e=>{let t=e.req.param("appId"),r=e.req.param("threadId"),a=await n.logStore.getThread({threadId:r,appId:t});if(!a)return e.json({error:"Thread not found"},404);let i={threadId:a.threadId,tenantId:a.tenantId,userId:a.userId,title:a.title,createdAt:a.createdAt.toISOString(),updatedAt:a.updatedAt.toISOString()};return e.json(i)});e.s(["threadsRoutes",0,d]),r()}catch(e){r(e)}},!1),54743,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(16172),n=e.i(95678),o=t([n]);function p(e){return{errorId:e.errorId,generationId:e.generationId,kind:e.kind,message:e.message,code:e.code,stack:e.stack,data:e.data,createdAt:e.createdAt.toISOString()}}function d(e){return{fileId:e.fileId,generationId:e.generationId,filename:e.filename,contentType:e.contentType,sizeBytes:e.sizeBytes,sha256Hex:e.sha256Hex,gcsPath:e.gcsPath,createdAt:e.createdAt.toISOString()}}function l(e,t,r){return{generationId:e.generationId,requestId:e.requestId,userId:e.userId,model:e.model,name:e.name,messages:e.messages,error:e.error,latencyMs:e.latencyMs,usage:{inputTokens:e.inputTokens,outputTokens:e.outputTokens,totalTokens:e.totalTokens,reasoningTokens:e.reasoningTokens,cachedInputTokens:e.cachedInputTokens},cost:{inputCostUsd:e.inputCostUsd?parseFloat(e.inputCostUsd):null,outputCostUsd:e.outputCostUsd?parseFloat(e.outputCostUsd):null,totalCostUsd:e.totalCostUsd?parseFloat(e.totalCostUsd):null},metadata:{},createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString(),errors:t.map(p),files:r.map(d)}}[n]=o.then?(await o)():o;let c=s.z.object({tenantId:s.z.string().optional(),threadId:s.z.string().optional(),requestId:s.z.string().optional(),limit:s.z.string().optional(),cursor:s.z.string().optional()}),u=new a.Hono().get("/",(0,i.zValidator)("query",c),async e=>{let t=e.req.param("appId"),r=e.req.valid("query"),a=r.tenantId,i=r.threadId,s=r.requestId,o=r.limit?parseInt(r.limit):50,p=r.cursor,{generations:d,nextCursor:c,hasMore:u}=await n.logStore.listGenerations({appId:t,tenantId:a,threadId:i,requestId:s,limit:o,cursor:p}),h=d.map(e=>e.generationId),[m,f]=await Promise.all([n.logStore.getGenerationErrorsByIds({generationIds:h,appId:t}),n.logStore.getGenerationFilesByIds({generationIds:h,appId:t})]),g=d.map(e=>l(e,m.get(e.generationId)??[],f.get(e.generationId)??[]));return e.json({generations:g,nextCursor:c,hasMore:u})}).get("/:generationId",async e=>{let t=e.req.param("appId"),r=e.req.param("generationId"),a=await n.logStore.getGeneration({generationId:r,appId:t});if(!a)return e.json({error:"Generation not found"},404);let[i,s]=await Promise.all([n.logStore.getGenerationErrors({generationId:r,appId:t}),n.logStore.getGenerationFiles({generationId:r,appId:t})]);return e.json(l(a,i,s))}).get("/:generationId/files/:fileId/download",async e=>{let t=e.req.param("appId"),r=e.req.param("generationId"),a=e.req.param("fileId"),i=await n.logStore.getGenerationFile({fileId:a,generationId:r,appId:t});if(!i)return e.json({error:"File not found"},404);let s=await n.blobStore.downloadFile(i.gcsPath);return new Response(new Uint8Array(s),{headers:{"Content-Type":i.contentType,"Content-Disposition":`attachment; filename="${encodeURIComponent(i.filename)}"`,"Content-Length":i.sizeBytes}})});e.s(["generationsRoutes",0,u]),r()}catch(e){r(e)}},!1),12303,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(7805),s=e.i(39768),n=e.i(79296),o=e.i(96401),p=e.i(23802),d=e.i(9253),l=e.i(49534),c=e.i(54743),u=t([p,d,l,c]);[p,d,l,c]=u.then?(await u)():u;let h=new a.Hono().use((0,i.cors)()).use((0,s.logger)()).onError((e,t)=>(console.error(e,`Error caught by global handler [${t.req.method} ${t.req.path}]`),e instanceof n.ZodError)?t.json({error:{issues:e.issues}},400):t.json({error:String(e)})).get("/health",e=>e.json({status:"ok"})).get("/api/health",e=>e.json({status:"ok"})).get("/api/config",e=>e.json({standaloneMode:o.config.standaloneMode})).route("/api/collect",p.collectRoutes).route("/api/admin",d.appsRoutes).route("/api/admin/",l.threadsRoutes).route("/api/admin/apps/:appId/generations",c.generationsRoutes);e.s(["routes",()=>h]),r()}catch(e){r(e)}},!1),80719,e=>e.a(async(t,r)=>{try{var a=e.i(12303),i=t([a]);[a]=i.then?(await i)():i,process.env.PORT&&parseInt(process.env.PORT),a.routes.fetch,e.s([]),r()}catch(e){r(e)}},!1),14608,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481);e.i(66587);var i=e.i(66349),s=e.i(80719),n=e.i(12303),o=t([s,n]);[s,n]=o.then?(await o)():o;let p=new a.Hono;p.route("/",n.routes);let d=(0,i.handle)(p),l=(0,i.handle)(p),c=(0,i.handle)(p),u=(0,i.handle)(p),h=(0,i.handle)(p);e.s(["DELETE",0,h,"GET",0,d,"PATCH",0,u,"POST",0,l,"PUT",0,c]),r()}catch(e){r(e)}},!1),41689,e=>e.a(async(t,r)=>{try{var a=e.i(71882),i=e.i(10915),s=e.i(54628),n=e.i(74462),o=e.i(12036),p=e.i(56971),d=e.i(61158),l=e.i(20794),c=e.i(73240),u=e.i(90993),h=e.i(38778),m=e.i(59155),f=e.i(77190),g=e.i(77366),v=e.i(97308),y=e.i(70941),w=e.i(93695);e.i(2260);var b=e.i(49590),_=e.i(14608),x=t([_]);[_]=x.then?(await x)():x;let E=new a.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/[[...route]]/route",pathname:"/api/[[...route]]",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/[[...route]]/route.ts",nextConfigOutput:"standalone",userland:_}),{workAsyncStorage:A,workUnitAsyncStorage:S,serverHooks:k}=E;function N(){return(0,s.patchFetch)({workAsyncStorage:A,workUnitAsyncStorage:S})}async function T(e,t,r){E.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let a="/api/[[...route]]/route";a=a.replace(/\/index$/,"")||"/";let s=await E.prepare(e,t,{srcPage:a,multiZoneDraftMode:!1});if(!s)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:_,params:x,nextConfig:N,parsedUrl:T,isDraftMode:A,prerenderManifest:S,routerServerContext:k,isOnDemandRevalidate:O,revalidateOnlyGenerated:C,resolvedPathname:I,clientReferenceManifest:R,serverActionsManifest:D}=s,P=(0,l.normalizeAppPath)(a),j=!!(S.dynamicRoutes[P]||S.routes[I]),q=async()=>((null==k?void 0:k.render404)?await k.render404(e,t,T,!1):t.end("This page could not be found"),null);if(j&&!A){let e=!!S.routes[I],t=S.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(N.experimental.adapterPath)return await q();throw new w.NoFallbackError}}let L=null;!j||E.isDev||A||(L=I,L="/index"===L?"/":L);let M=!0===E.isDev||!j,F=j&&!M;D&&R&&(0,p.setReferenceManifestsSingleton)({page:a,clientReferenceManifest:R,serverActionsManifest:D,serverModuleMap:(0,d.createServerModuleMap)({serverActionsManifest:D})});let U=e.method||"GET",B=(0,o.getTracer)(),V=B.getActiveScopeSpan(),z={params:x,prerenderManifest:S,renderOpts:{experimental:{authInterrupts:!!N.experimental.authInterrupts},cacheComponents:!!N.cacheComponents,supportsDynamicResponse:M,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:N.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a)=>E.onRequestError(e,t,a,k)},sharedContext:{buildId:_}},W=new c.NodeNextRequest(e),$=new c.NodeNextResponse(t),G=u.NextRequestAdapter.fromNodeNextRequest(W,(0,u.signalFromNodeResponse)(t));try{let s=async e=>E.handle(G,z).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=B.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==h.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let i=r.get("next.route");if(i){let t=`${U} ${i}`;e.setAttributes({"next.route":i,"http.route":i,"next.span_name":t}),e.updateName(t)}else e.updateName(`${U} ${a}`)}),p=!!(0,n.getRequestMeta)(e,"minimalMode"),d=async n=>{var o,d;let l=async({previousCacheEntry:i})=>{try{if(!p&&O&&C&&!i)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await s(n);e.fetchMetrics=z.renderOpts.fetchMetrics;let o=z.renderOpts.pendingWaitUntil;o&&r.waitUntil&&(r.waitUntil(o),o=void 0);let d=z.renderOpts.collectedTags;if(!j)return await (0,f.sendResponse)(W,$,a,z.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,g.toNodeOutgoingHttpHeaders)(a.headers);d&&(t[y.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==z.renderOpts.collectedRevalidate&&!(z.renderOpts.collectedRevalidate>=y.INFINITE_CACHE)&&z.renderOpts.collectedRevalidate,i=void 0===z.renderOpts.collectedExpire||z.renderOpts.collectedExpire>=y.INFINITE_CACHE?void 0:z.renderOpts.collectedExpire;return{value:{kind:b.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:i}}}}catch(t){throw(null==i?void 0:i.isStale)&&await E.onRequestError(e,t,{routerKind:"App Router",routePath:a,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:F,isOnDemandRevalidate:O})},k),t}},c=await E.handleResponse({req:e,nextConfig:N,cacheKey:L,routeKind:i.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:S,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:C,responseGenerator:l,waitUntil:r.waitUntil,isMinimalMode:p});if(!j)return null;if((null==c||null==(o=c.value)?void 0:o.kind)!==b.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(d=c.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});p||t.setHeader("x-nextjs-cache",O?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,g.fromNodeOutgoingHttpHeaders)(c.value.headers);return p&&j||u.delete(y.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,v.getCacheControlHeader)(c.cacheControl)),await (0,f.sendResponse)(W,$,new Response(c.value.body,{headers:u,status:c.value.status||200})),null};V?await d(V):await B.withPropagatedContext(e.headers,()=>B.trace(h.BaseServerSpan.handleRequest,{spanName:`${U} ${a}`,kind:o.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},d))}catch(t){if(t instanceof w.NoFallbackError||await E.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:F,isOnDemandRevalidate:O})}),j)throw t;return await (0,f.sendResponse)(W,$,new Response(null,{status:500})),null}}e.s(["handler",()=>T,"patchFetch",()=>N,"routeModule",()=>E,"serverHooks",()=>k,"workAsyncStorage",()=>A,"workUnitAsyncStorage",()=>S]),r()}catch(e){r(e)}},!1)];
26
+ `}).join("")}getCanonicalRequest(e,t,r,a,i,s){return[e,t,r,a,i,s||"UNSIGNED-PAYLOAD"].join("\n")}getCanonicalQueryParams(e){return ep(e).map(([e,t])=>[el(e,!0),el(t,!0)]).sort((e,t)=>e[0]<t[0]?-1:1).map(([e,t])=>`${e}=${t}`).join("&")}getResourcePath(e,t,r){return e?"/"+(r||""):r?`/${t}/${r}`:`/${t}`}parseExpires(e,t=new Date){let r=new Date(e).valueOf();if(isNaN(r))throw Error(k.EXPIRATION_DATE_INVALID);if(r<t.valueOf())throw Error(k.EXPIRATION_DATE_PAST);return Math.floor(r/1e3)}parseAccessibleAt(e){let t=new Date(e||new Date).valueOf();if(isNaN(t))throw Error(m.ACCESSIBLE_DATE_INVALID);return Math.floor(t/1e3)}}class eH extends Error{constructor(){super(...arguments),this.name="SigningError"}}var eK=function(e,t,r,a,i){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?i.call(e,r):i?i.value=r:t.set(e,r),r},eJ=function(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)};let eZ=[0,0xf26b8303,0xe13b70f7,0x1350f3f4,0xc79a971f,0x35f1141c,0x26a1e7e8,0xd4ca64eb,0x8ad958cf,0x78b2dbcc,0x6be22838,0x9989ab3b,0x4d43cfd0,0xbf284cd3,0xac78bf27,0x5e133c24,0x105ec76f,0xe235446c,0xf165b798,0x30e349b,0xd7c45070,0x25afd373,0x36ff2087,0xc494a384,0x9a879fa0,0x68ec1ca3,0x7bbcef57,0x89d76c54,0x5d1d08bf,0xaf768bbc,0xbc267848,0x4e4dfb4b,0x20bd8ede,0xd2d60ddd,0xc186fe29,0x33ed7d2a,0xe72719c1,0x154c9ac2,0x61c6936,0xf477ea35,0xaa64d611,0x580f5512,0x4b5fa6e6,0xb93425e5,0x6dfe410e,0x9f95c20d,0x8cc531f9,0x7eaeb2fa,0x30e349b1,0xc288cab2,0xd1d83946,0x23b3ba45,0xf779deae,0x5125dad,0x1642ae59,0xe4292d5a,0xba3a117e,0x4851927d,0x5b016189,0xa96ae28a,0x7da08661,0x8fcb0562,0x9c9bf696,0x6ef07595,0x417b1dbc,0xb3109ebf,0xa0406d4b,0x522bee48,0x86e18aa3,0x748a09a0,0x67dafa54,0x95b17957,0xcba24573,0x39c9c670,0x2a993584,0xd8f2b687,0xc38d26c,0xfe53516f,0xed03a29b,0x1f682198,0x5125dad3,0xa34e59d0,0xb01eaa24,0x42752927,0x96bf4dcc,0x64d4cecf,0x77843d3b,0x85efbe38,0xdbfc821c,0x2997011f,0x3ac7f2eb,0xc8ac71e8,0x1c661503,0xee0d9600,0xfd5d65f4,0xf36e6f7,0x61c69362,0x93ad1061,0x80fde395,0x72966096,0xa65c047d,0x5437877e,0x4767748a,0xb50cf789,0xeb1fcbad,0x197448ae,0xa24bb5a,0xf84f3859,0x2c855cb2,0xdeeedfb1,0xcdbe2c45,0x3fd5af46,0x7198540d,0x83f3d70e,0x90a324fa,0x62c8a7f9,0xb602c312,0x44694011,0x5739b3e5,0xa55230e6,0xfb410cc2,0x92a8fc1,0x1a7a7c35,0xe811ff36,0x3cdb9bdd,0xceb018de,0xdde0eb2a,0x2f8b6829,0x82f63b78,0x709db87b,0x63cd4b8f,0x91a6c88c,0x456cac67,0xb7072f64,0xa457dc90,0x563c5f93,0x82f63b7,0xfa44e0b4,0xe9141340,0x1b7f9043,0xcfb5f4a8,0x3dde77ab,0x2e8e845f,0xdce5075c,0x92a8fc17,0x60c37f14,0x73938ce0,0x81f80fe3,0x55326b08,0xa759e80b,0xb4091bff,0x466298fc,0x1871a4d8,0xea1a27db,0xf94ad42f,0xb21572c,0xdfeb33c7,0x2d80b0c4,0x3ed04330,0xccbbc033,0xa24bb5a6,0x502036a5,0x4370c551,0xb11b4652,0x65d122b9,0x97baa1ba,0x84ea524e,0x7681d14d,0x2892ed69,0xdaf96e6a,0xc9a99d9e,0x3bc21e9d,0xef087a76,0x1d63f975,0xe330a81,0xfc588982,0xb21572c9,0x407ef1ca,0x532e023e,0xa145813d,0x758fe5d6,0x87e466d5,0x94b49521,0x66df1622,0x38cc2a06,0xcaa7a905,0xd9f75af1,0x2b9cd9f2,0xff56bd19,0xd3d3e1a,0x1e6dcdee,0xec064eed,0xc38d26c4,0x31e6a5c7,0x22b65633,0xd0ddd530,0x417b1db,0xf67c32d8,0xe52cc12c,0x1747422f,0x49547e0b,0xbb3ffd08,0xa86f0efc,0x5a048dff,0x8ecee914,0x7ca56a17,0x6ff599e3,0x9d9e1ae0,0xd3d3e1ab,0x21b862a8,0x32e8915c,0xc083125f,0x144976b4,0xe622f5b7,0xf5720643,0x7198540,0x590ab964,0xab613a67,0xb831c993,0x4a5a4a90,0x9e902e7b,0x6cfbad78,0x7fab5e8c,0x8dc0dd8f,0xe330a81a,0x115b2b19,0x20bd8ed,0xf0605bee,0x24aa3f05,0xd6c1bc06,0xc5914ff2,0x37faccf1,0x69e9f0d5,0x9b8273d6,0x88d28022,0x7ab90321,0xae7367ca,0x5c18e4c9,0x4f48173d,0xbd23943e,0xf36e6f75,0x105ec76,0x12551f82,0xe03e9c81,0x34f4f86a,0xc69f7b69,0xd5cf889d,0x27a40b9e,0x79b737ba,0x8bdcb4b9,0x988c474d,0x6ae7c44e,0xbe2da0a5,0x4c4623a6,0x5f16d052,0xad7d5351],eQ=new Int32Array(eZ),eY=()=>new eX;class eX{constructor(e=0){f.set(this,0),eK(this,f,e,"f")}update(e){let t=0xffffffff^eJ(this,f,"f");for(let r of e)t=eX.CRC32C_EXTENSION_TABLE[(r^t)&255]^t>>>8;eK(this,f,0xffffffff^t,"f")}validate(e){return"number"==typeof e?e===eJ(this,f,"f"):"string"==typeof e?e===this.toString():Buffer.isBuffer(e)?0===Buffer.compare(e,this.toBuffer()):e.toString()===this.toString()}toBuffer(){let e=Buffer.alloc(4);return e.writeInt32BE(eJ(this,f,"f")),e}toJSON(){return this.toString()}toString(){return this.toBuffer().toString("base64")}valueOf(){return eJ(this,f,"f")}static fromBuffer(e){let t;if(4!==(t=Buffer.isBuffer(e)?e:"buffer"in e?Buffer.from(e.buffer):Buffer.from(e)).byteLength){let e;throw RangeError((e=t.byteLength,`Buffer expected to equal 4 bytes, not ${e}`))}return new eX(t.readInt32BE())}static async fromFile(e){let t=new eX;return await new Promise((r,a)=>{(0,eC.createReadStream)(e).on("data",e=>{"string"==typeof e?t.update(Buffer.from(e)):t.update(e)}).on("end",()=>r()).on("error",a)}),t}static fromString(e){let t=Buffer.from(e,"base64");if(4!==t.byteLength){let e;throw RangeError((e=t.byteLength,`base64-encoded data expected to equal 4 bytes, not ${e}`))}return this.fromBuffer(t)}static fromNumber(e){if(!Number.isSafeInteger(e)||e>0x100000000||e<-0x100000000){let t;throw RangeError((t=e,`Number expected to be a safe, unsigned 32-bit integer, not ${t}`))}return new eX(e)}static from(e){return"number"==typeof e?this.fromNumber(e):"string"==typeof e?this.fromString(e):"byteLength"in e?this.fromBuffer(e):this.fromString(e.toString())}}f=new WeakMap,eX.CRC32C_EXTENSIONS=eZ,eX.CRC32C_EXTENSION_TABLE=eQ;var e1=ee,e0=function(e,t,r,a,i){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?i.call(e,r):i?i.value=r:t.set(e,r),r},e2=function(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)};class e6 extends e1.Transform{constructor(e={}){if(super(),this.updateHashesOnly=!1,g.set(this,void 0),v.set(this,void 0),y.set(this,""),this.crc32cEnabled=!!e.crc32c,this.md5Enabled=!!e.md5,this.updateHashesOnly=!!e.updateHashesOnly,this.crc32cExpected=e.crc32cExpected,this.md5Expected=e.md5Expected,this.crc32cEnabled)if(e.crc32cInstance)e0(this,g,e.crc32cInstance,"f");else{const t=e.crc32cGenerator||eY;e0(this,g,t(),"f")}this.md5Enabled&&e0(this,v,(0,I.createHash)("md5"),"f")}get crc32c(){var e;return null==(e=e2(this,g,"f"))?void 0:e.toString()}_flush(e){if(e2(this,v,"f")&&e0(this,y,e2(this,v,"f").digest("base64"),"f"),this.updateHashesOnly)return void e();let t=this.crc32cEnabled||this.md5Enabled;if(this.crc32cEnabled&&this.crc32cExpected&&(t=!this.test("crc32c",this.crc32cExpected)),this.md5Enabled&&this.md5Expected&&(t=!this.test("md5",this.md5Expected)),t){let t=new e5(x.DOWNLOAD_MISMATCH);t.code="CONTENT_DOWNLOAD_MISMATCH",e(t)}else e()}_transform(e,t,r){this.push(e,t);try{e2(this,g,"f")&&e2(this,g,"f").update(e),e2(this,v,"f")&&e2(this,v,"f").update(e),r()}catch(e){r(e)}}test(e,t){let r=Buffer.isBuffer(t)?t.toString("base64"):t;return"crc32c"===e&&e2(this,g,"f")?e2(this,g,"f").validate(r):!!("md5"===e&&e2(this,v,"f"))&&e2(this,y,"f")===r}}g=new WeakMap,v=new WeakMap,y=new WeakMap;var e4=function(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)};(r=_||(_={})).read="GET",r.write="PUT",r.delete="DELETE",r.resumable="POST";let e3=/^gs:\/\/([a-z0-9_.-]+)\/(.+)$/,e9=RegExp([/^text\/|application\/ecmascript|application\/javascript|application\/json/,/|application\/postscript|application\/rtf|application\/toml|application\/vnd.dart/,/|application\/vnd.ms-fontobject|application\/wasm|application\/x-httpd-php|application\/x-ns-proxy-autoconfig/,/|application\/x-sh(?!ockwave-flash)|application\/x-tar|application\/x-virtualbox-hdd|application\/x-virtualbox-ova|application\/x-virtualbox-ovf/,/|^application\/x-virtualbox-vbox$|application\/x-virtualbox-vdi|application\/x-virtualbox-vhd|application\/x-virtualbox-vmdk/,/|application\/xml|application\/xml-dtd|font\/otf|font\/ttf|image\/bmp|image\/vnd.adobe.photoshop|image\/vnd.microsoft.icon/,/|image\/vnd.ms-dds|image\/x-icon|image\/x-ms-bmp|message\/rfc822|model\/gltf-binary|\+json|\+text|\+xml|\+yaml/].map(e=>e.source).join(""),"i");class e5 extends Error{}let e8=/(gs):\/\/([a-z0-9_.-]+)\/(.+)/g,e7=/(https):\/\/(storage\.googleapis\.com)\/([a-z0-9_.-]+)\/(.+)/g;(a=x||(x={})).EXPIRATION_TIME_NA="An expiration time is not available.",a.DESTINATION_NO_NAME="Destination file should have a name.",a.INVALID_VALIDATION_FILE_RANGE="Cannot use validation with file ranges (start/end).",a.MD5_NOT_AVAILABLE="MD5 verification was specified, but is not available for the requested object. MD5 is not available for composite objects.",a.EQUALS_CONDITION_TWO_ELEMENTS="Equals condition must be an array of 2 elements.",a.STARTS_WITH_TWO_ELEMENTS="StartsWith condition must be an array of 2 elements.",a.CONTENT_LENGTH_RANGE_MIN_MAX="ContentLengthRange must have numeric min & max fields.",a.DOWNLOAD_MISMATCH="The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again.",a.UPLOAD_MISMATCH_DELETE_FAIL="The uploaded data did not match the data from the server.\n As a precaution, we attempted to delete the file, but it was not successful.\n To be sure the content is the same, you should try removing the file manually,\n then uploading the file again.\n \n\nThe delete attempt failed with this message:\n\n ",a.UPLOAD_MISMATCH="The uploaded data did not match the data from the server.\n As a precaution, the file has been deleted.\n To be sure the content is the same, you should try uploading the file again.",a.MD5_RESUMED_UPLOAD="MD5 cannot be used with a continued resumable upload as MD5 cannot be extended from an existing value",a.MISSING_RESUME_CRC32C_FINAL_UPLOAD="The CRC32C is missing for the final portion of a resumed upload, which is required for validation. Please provide `resumeCRC32C` if validation is required, or disable `validation`.";class te extends ek{constructor(e,t,r={}){var a,i;let s;const n={};null!==r.generation&&(isNaN(s="string"==typeof r.generation?Number(r.generation):r.generation)||(n.generation=s)),Object.assign(n,r.preconditionOpts);const o=r.userProject||e.userProject;if("string"==typeof o&&(n.userProject=o),super({parent:e,baseUrl:"/o",id:encodeURIComponent(t),methods:{delete:{reqOpts:{qs:n}},exists:{reqOpts:{qs:n}},get:{reqOpts:{qs:n}},getMetadata:{reqOpts:{qs:n}},setMetadata:{reqOpts:{qs:n}}}}),w.add(this),this.bucket=e,this.storage=e.parent,null!==r.generation){let e;isNaN(e="string"==typeof r.generation?Number(r.generation):r.generation)||(this.generation=e)}this.kmsKeyName=r.kmsKeyName,this.userProject=o,this.name=t,r.encryptionKey&&this.setEncryptionKey(r.encryptionKey),this.acl=new eq({request:this.request.bind(this),pathPrefix:"/acl"}),this.crc32cGenerator=r.crc32cGenerator||this.bucket.crc32cGenerator,this.instanceRetryValue=null==(i=null==(a=this.storage)?void 0:a.retryOptions)?void 0:i.autoRetry,this.instancePreconditionOpts=null==r?void 0:r.preconditionOpts}get cloudStorageURI(){let e=this.bucket.cloudStorageURI;return e.pathname=this.name,e}shouldRetryBasedOnPreconditionAndIdempotencyStrat(e){var t;return((null==e?void 0:e.ifGenerationMatch)!==void 0||(null==(t=this.instancePreconditionOpts)?void 0:t.ifGenerationMatch)!==void 0||this.storage.retryOptions.idempotencyStrategy!==S.RetryConditional)&&this.storage.retryOptions.idempotencyStrategy!==S.RetryNever}copy(e,t,r){var a,i;let s,n,o,p=Error(x.DESTINATION_NO_NAME);if(!e)throw p;let d={};if("function"==typeof t?r=t:t&&(d={...t}),r=r||eN.noop,"string"==typeof e){let t=e3.exec(e);null!==t&&3===t.length?(s=this.storage.bucket(t[1]),n=t[2]):(s=this.bucket,n=e)}else if(e instanceof ta)s=e,n=this.name;else if(e instanceof te)s=e.bucket,n=e.name,o=e;else throw p;let l={};void 0!==this.generation&&(l.sourceGeneration=this.generation),void 0!==d.token&&(l.rewriteToken=d.token),void 0!==d.userProject&&(l.userProject=d.userProject,delete d.userProject),void 0!==d.predefinedAcl&&(l.destinationPredefinedAcl=d.predefinedAcl,delete d.predefinedAcl),o=o||s.file(n);let c={};if(void 0!==this.encryptionKey&&(c["x-goog-copy-source-encryption-algorithm"]="AES256",c["x-goog-copy-source-encryption-key"]=this.encryptionKeyBase64,c["x-goog-copy-source-encryption-key-sha256"]=this.encryptionKeyHash),void 0!==o.encryptionKey?this.setEncryptionKey(o.encryptionKey):void 0!==d.destinationKmsKeyName?(l.destinationKmsKeyName=d.destinationKmsKeyName,delete d.destinationKmsKeyName):void 0!==o.kmsKeyName&&(l.destinationKmsKeyName=o.kmsKeyName),l.destinationKmsKeyName){this.kmsKeyName=l.destinationKmsKeyName;let e=this.interceptors.indexOf(this.encryptionKeyInterceptor);e>-1&&this.interceptors.splice(e,1)}this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(null==d?void 0:d.preconditionOpts)||(this.storage.retryOptions.autoRetry=!1),(null==(a=d.preconditionOpts)?void 0:a.ifGenerationMatch)!==void 0&&(l.ifGenerationMatch=null==(i=d.preconditionOpts)?void 0:i.ifGenerationMatch,delete d.preconditionOpts),this.request({method:"POST",uri:`/rewriteTo/b/${s.name}/o/${encodeURIComponent(o.name)}`,qs:l,json:d,headers:c},(e,t)=>{if(this.storage.retryOptions.autoRetry=this.instanceRetryValue,e)return void r(e,null,t);if(t.rewriteToken){let e={token:t.rewriteToken};l.userProject&&(e.userProject=l.userProject),l.destinationKmsKeyName&&(e.destinationKmsKeyName=l.destinationKmsKeyName),this.copy(o,e,r);return}r(null,o,t)})}createReadStream(e={}){let t,r,a="number"==typeof(e=Object.assign({decompress:!0},e)).start||"number"==typeof e.end,i=e.end<0,s=new ef,n=!0,o=!1;if("string"==typeof e.validation){let t=e.validation.toLowerCase().trim();n="crc32c"===t,o="md5"===t}else!1===e.validation&&(n=!1);let p=!a&&(n||o);if(a){if("string"==typeof e.validation||!0===e.validation)throw Error(x.INVALID_VALIDATION_FILE_RANGE);n=!1,o=!1}let d=e=>{e&&((null==r?void 0:r.agent)&&r.agent.destroy(),s.destroy(e))},l=(a,i,l)=>{if(a)return void this.getBufferFromReadable(l).then(e=>{a.message=e.toString("utf8"),s.destroy(a)});r=l.request;let c=l.toJSON().headers,u="gzip"===c["content-encoding"],h={},m="gzip"===c["x-goog-stored-content-encoding"]&&u||"identity"===c["x-goog-stored-content-encoding"],f=[];if(p&&("string"==typeof c["x-goog-hash"]&&c["x-goog-hash"].split(",").forEach(e=>{let t=e.indexOf("="),r=e.substring(0,t),a=e.substring(t+1);h[r]=a}),t=new e6({crc32c:n,md5:o,crc32cGenerator:this.crc32cGenerator,crc32cExpected:h.crc32c,md5Expected:h.md5})),o&&!h.md5){let e=new e5(x.MD5_NOT_AVAILABLE);e.code="MD5_NOT_AVAILABLE",s.destroy(e);return}m&&p&&t&&f.push(t),u&&e.decompress&&f.push(e$.createGunzip()),(0,ee.pipeline)(l,...f,s,d)},c=()=>{let t={alt:"media"};this.generation&&(t.generation=this.generation),e.userProject&&(t.userProject=e.userProject);let r={"Accept-Encoding":"gzip","Cache-Control":"no-store"};if(a){let t="number"==typeof e.start?e.start:"0",a="number"==typeof e.end?e.end:"";r.Range=`bytes=${i?a:`${t}-${a}`}`}let n={uri:"",headers:r,qs:t};e[ey]&&(n[ey]=e[ey]),this.requestStream(n).on("error",e=>{s.destroy(e)}).on("response",e=>{s.emit("response",e),eN.handleResp(null,e,null,l)}).resume()};return s.on("reading",c),s}createResumableUpload(e,t){var r,a;let i="object"==typeof e?e:{};t="function"==typeof e?e:t;let s=this.storage.retryOptions;((null==(r=null==i?void 0:i.preconditionOpts)?void 0:r.ifGenerationMatch)===void 0&&(null==(a=this.instancePreconditionOpts)?void 0:a.ifGenerationMatch)===void 0&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(s.autoRetry=!1),function(e,t){let r=new eW(e);if(!t)return r.createURI();r.createURI().then(e=>t(null,e),t)}({authClient:this.storage.authClient,apiEndpoint:this.storage.apiEndpoint,bucket:this.bucket.name,customRequestOptions:this.getRequestInterceptors().reduce((e,t)=>t(e),{}),file:this.name,generation:this.generation,key:this.encryptionKey,kmsKeyName:this.kmsKeyName,metadata:i.metadata,offset:i.offset,origin:i.origin,predefinedAcl:i.predefinedAcl,private:i.private,public:i.public,userProject:i.userProject||this.userProject,retryOptions:s,params:(null==i?void 0:i.preconditionOpts)||this.instancePreconditionOpts,universeDomain:this.bucket.storage.universeDomain,useAuthWithCustomEndpoint:this.storage.useAuthWithCustomEndpoint,[ey]:i[ey]},t),this.storage.retryOptions.autoRetry=this.instanceRetryValue}createWriteStream(e={}){if(null!=e.metadata||(e.metadata={}),e.contentType&&(e.metadata.contentType=e.contentType),!e.metadata.contentType||"auto"===e.metadata.contentType){let t=eI.default.getType(this.name);t&&(e.metadata.contentType=t)}let t=e.gzip;"auto"===t&&(t=e9.test(e.metadata.contentType||"")),t&&(e.metadata.contentEncoding="gzip");let r=!0,a=!1;if("string"==typeof e.validation?(e.validation=e.validation.toLowerCase(),r="crc32c"===e.validation,a="md5"===e.validation):!1===e.validation&&(r=!1,a=!1),e.offset){if(a)throw RangeError(x.MD5_RESUMED_UPLOAD);if(r&&!e.isPartialUpload&&!e.resumeCRC32C)throw RangeError(x.MISSING_RESUME_CRC32C_FINAL_UPLOAD)}let i=e=>{s.destroy(e||void 0)},s=new ee.Writable({final(e){i=e,o.end()},write(e,t,r){o.write(e,t,r)}});s.once("error",e=>{o.destroy(e)}),s.once("close",()=>{o.destroy()});let n=[];t&&n.push(e$.createGzip());let o=new ef,p=()=>{};o.on("error",p);let d=null;if(r||a){let t=e.resumeCRC32C?eX.from(e.resumeCRC32C):void 0;d=new e6({crc32c:r,crc32cInstance:t,md5:a,crc32cGenerator:this.crc32cGenerator,updateHashesOnly:!0}),n.push(d)}let l=(0,eg.default)(),c=!1;return o.on("reading",()=>s.emit("reading")),o.on("writing",()=>s.emit("writing")),l.on("uri",e=>s.emit("uri",e)),l.on("progress",e=>s.emit("progress",e)),l.on("response",e=>s.emit("response",e)),l.once("metadata",()=>{c=!0}),s.once("writing",()=>{!1===e.resumable?this.startSimpleUpload_(l,e):this.startResumableUpload_(l,e),o.removeListener("error",p),(0,ee.pipeline)(o,...n,l,async t=>{if(t)return i(t);if(!c)try{await new Promise((e,t)=>{l.once("metadata",e),l.once("error",t)})}catch(e){return i(e)}(null==d?void 0:d.crc32c)&&s.emit("crc32c",d.crc32c);try{let t=e.isPartialUpload&&!this.metadata;d&&!t&&await e4(this,w,"m",b).call(this,d,{crc32c:r,md5:a}),i()}catch(e){i(e)}})}),s}delete(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t,this.disableAutoRetryConditionallyIdempotent_(this.methods.delete,E.delete,r),super.delete(r).then(e=>t(null,...e)).catch(t).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}download(e,t){let r;"function"==typeof e?(t=e,r={}):r=Object.assign({},e);let a=!1,i=(...e)=>{a||t(...e),a=!0},s=r.destination;delete r.destination,r.encryptionKey&&(this.setEncryptionKey(r.encryptionKey),delete r.encryptionKey);let n=this.createReadStream(r),o=!1;s?n.on("error",i).once("data",e=>{o=!0;let t=eC.createWriteStream(s);t.write(e),n.pipe(t).on("error",e=>{i(e,Buffer.from(""))}).on("finish",()=>{i(null,e)})}).on("end",()=>{if(!o){let e=Buffer.alloc(0);try{eC.writeFileSync(s,e),i(null,e)}catch(t){i(t,e)}}}):this.getBufferFromReadable(n).then(e=>null==i?void 0:i(null,e)).catch(i)}setEncryptionKey(e){return this.encryptionKey=e,this.encryptionKeyBase64=Buffer.from(e).toString("base64"),this.encryptionKeyHash=I.createHash("sha256").update(this.encryptionKeyBase64,"base64").digest("base64"),this.encryptionKeyInterceptor={request:e=>(e.headers=e.headers||{},e.headers["x-goog-encryption-algorithm"]="AES256",e.headers["x-goog-encryption-key"]=this.encryptionKeyBase64,e.headers["x-goog-encryption-key-sha256"]=this.encryptionKeyHash,e)},this.interceptors.push(this.encryptionKeyInterceptor),this}static from(e,t,r){let a=[...e.matchAll(e8)],i=[...e.matchAll(e7)];if(a.length>0)return new te(new ta(t,a[0][2]),a[0][3],r);if(i.length>0)return new te(new ta(t,i[0][3]),i[0][4],r);throw Error("URL string must be of format gs://bucket/file or https://storage.googleapis.com/bucket/file")}get(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t,super.get(r).then(e=>t(null,...e)).catch(t)}getExpirationDate(e){this.getMetadata((t,r,a)=>{t?e(t,null,a):r.retentionExpirationTime?e(null,new Date(r.retentionExpirationTime),a):e(Error(x.EXPIRATION_TIME_NA),null,a)})}generateSignedPostPolicyV2(e,t){let r=eo(e,t),a=r.options,i=r.callback,s=new Date(a.expires);if(isNaN(s.getTime()))throw Error(k.EXPIRATION_DATE_INVALID);if(s.valueOf()<Date.now())throw Error(k.EXPIRATION_DATE_PAST);a=Object.assign({},a);let n=[["eq","$key",this.name],{bucket:this.bucket.name}];if(Array.isArray(a.equals)&&(Array.isArray(a.equals[0])||(a.equals=[a.equals]),a.equals.forEach(e=>{if(!Array.isArray(e)||2!==e.length)throw Error(x.EQUALS_CONDITION_TWO_ELEMENTS);n.push(["eq",e[0],e[1]])})),Array.isArray(a.startsWith)&&(Array.isArray(a.startsWith[0])||(a.startsWith=[a.startsWith]),a.startsWith.forEach(e=>{if(!Array.isArray(e)||2!==e.length)throw Error(x.STARTS_WITH_TWO_ELEMENTS);n.push(["starts-with",e[0],e[1]])})),a.acl&&n.push({acl:a.acl}),a.successRedirect&&n.push({success_action_redirect:a.successRedirect}),a.successStatus&&n.push({success_action_status:a.successStatus}),a.contentLengthRange){let e=a.contentLengthRange.min,t=a.contentLengthRange.max;if("number"!=typeof e||"number"!=typeof t)throw Error(x.CONTENT_LENGTH_RANGE_MIN_MAX);n.push(["content-length-range",e,t])}let o=JSON.stringify({expiration:s.toISOString(),conditions:n}),p=Buffer.from(o).toString("base64");this.storage.authClient.sign(p,a.signingEndpoint).then(e=>{i(null,{string:o,base64:p,signature:e})},e=>{i(new eH(e.message))})}generateSignedPostPolicyV4(e,t){let r=eo(e,t),a=r.options,i=r.callback,s=new Date(a.expires);if(isNaN(s.getTime()))throw Error(k.EXPIRATION_DATE_INVALID);if(s.valueOf()<Date.now())throw Error(k.EXPIRATION_DATE_PAST);if(s.valueOf()-Date.now()>6048e5)throw Error("Max allowed expiration is seven days (604800 seconds).");let n=Object.assign({},(a=Object.assign({},a)).fields),o=new Date,p=ec(o,!0),d=ec(o);(async()=>{let{client_email:e}=await this.storage.authClient.getCredentials(),t=`${e}/${d}/auto/storage/goog4_request`;n={...n,bucket:this.bucket.name,key:this.name,"x-goog-date":p,"x-goog-credential":t,"x-goog-algorithm":"GOOG4-RSA-SHA256"};let r=a.conditions||[];Object.entries(n).forEach(([e,t])=>{e.startsWith("x-ignore-")||r.push({[e]:t})}),delete n.bucket;let i=JSON.stringify({conditions:r,expiration:ec(s,!0,"-",":")}).replace(/[\u0080-\uFFFF]/g,e=>"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)),o=Buffer.from(i).toString("base64");try{let e=await this.storage.authClient.sign(o,a.signingEndpoint),t=Buffer.from(e,"base64").toString("hex"),r=this.parent.storage.universeDomain;return n.policy=o,n["x-goog-signature"]=t,{url:this.storage.customEndpoint?this.storage.apiEndpoint:a.virtualHostedStyle?`https://${this.bucket.name}.storage.${r}/`:a.bucketBoundHostname?`${a.bucketBoundHostname}/`:`https://storage.${r}/${this.bucket.name}/`,fields:n}}catch(e){throw new eH(e.message)}})().then(e=>i(null,e),i)}getSignedUrl(e,t){let r=_[e.action],a=function(e){let t={};for(let r of Object.keys(e)){let a=e[r];t[r=r.toLowerCase()]=a}return t}(e.extensionHeaders||{});"resumable"===e.action&&(a["x-goog-resumable"]="start");let i=Object.assign({},e.queryParams);"string"==typeof e.responseType&&(i["response-content-type"]=e.responseType),"string"==typeof e.promptSaveAs&&(i["response-content-disposition"]='attachment; filename="'+e.promptSaveAs+'"'),"string"==typeof e.responseDisposition&&(i["response-content-disposition"]=e.responseDisposition),this.generation&&(i.generation=this.generation.toString());let s={method:r,expires:e.expires,accessibleAt:e.accessibleAt,extensionHeaders:a,queryParams:i,contentMd5:e.contentMd5,contentType:e.contentType,host:e.host};e.cname&&(s.cname=e.cname),e.version&&(s.version=e.version),e.virtualHostedStyle&&(s.virtualHostedStyle=e.virtualHostedStyle),this.signer||(this.signer=new eG(this.storage.authClient,this.bucket,this,this.storage)),this.signer.getSignedUrl(s).then(e=>t(null,e),t)}isPublic(e){var t;let r=(null==(t=this.storage)?void 0:t.interceptors)||[],a=this.interceptors||[],i=r.concat(a).reduce((e,t)=>(Object.assign(e,t.request({uri:`${this.storage.apiEndpoint}/${this.bucket.name}/${encodeURIComponent(this.name)}`}).headers),e),{});eN.makeRequest({method:"GET",uri:`${this.storage.apiEndpoint}/${this.bucket.name}/${encodeURIComponent(this.name)}`,headers:i},{retryOptions:this.storage.retryOptions},t=>{t?403===t.code?e(null,!1):e(t):e(null,!0)})}makePrivate(e,t){var r,a;let i="object"==typeof e?e:{};t="function"==typeof e?e:t;let s={predefinedAcl:i.strict?"private":"projectPrivate"};(null==(r=i.preconditionOpts)?void 0:r.ifMetagenerationMatch)!==void 0&&(s.ifMetagenerationMatch=null==(a=i.preconditionOpts)?void 0:a.ifMetagenerationMatch,delete i.preconditionOpts),i.userProject&&(s.userProject=i.userProject);let n={...i.metadata,acl:null};this.setMetadata(n,s,t)}makePublic(e){e=e||eN.noop,this.acl.add({entity:"allUsers",role:"READER"},(t,r,a)=>{e(t,a)})}publicUrl(){return`${this.storage.apiEndpoint}/${this.bucket.name}/${encodeURIComponent(this.name)}`}moveFileAtomic(e,t,r){var a,i;let s,n,o=Error(x.DESTINATION_NO_NAME);if(!e)throw o;let p={};if("function"==typeof t?r=t:t&&(p={...t}),r=r||eN.noop,"string"==typeof e){let t=e3.exec(e);s=null!==t&&3===t.length?t[2]:e}else if(e instanceof te)s=e.name,n=e;else throw o;n=n||this.bucket.file(s),this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(null==p?void 0:p.preconditionOpts)||(this.storage.retryOptions.autoRetry=!1);let d={};void 0!==p.userProject&&(d.userProject=p.userProject,delete p.userProject),(null==(a=p.preconditionOpts)?void 0:a.ifGenerationMatch)!==void 0&&(d.ifGenerationMatch=null==(i=p.preconditionOpts)?void 0:i.ifGenerationMatch,delete p.preconditionOpts),this.request({method:"POST",uri:`/moveTo/o/${encodeURIComponent(n.name)}`,qs:d,json:p},(e,t)=>{(this.storage.retryOptions.autoRetry=this.instanceRetryValue,e)?r(e,null,t):r(null,n,t)})}move(e,t,r){let a="object"==typeof t?t:{};r=(r="function"==typeof t?t:r)||eN.noop,this.copy(e,a,(e,t,i)=>{if(e){e.message="file#copy failed with an error - "+e.message,r(e,null,i);return}this.name!==t.name||this.bucket.name!==t.bucket.name?this.delete(a,(e,a)=>{if(e){e.message="file#delete failed with an error - "+e.message,r(e,t,a);return}r(null,t,i)}):r(null,t,i)})}rename(e,t,r){let a="object"==typeof t?t:{};r=(r="function"==typeof t?t:r)||eN.noop,this.move(e,a,r)}async restore(e){let[t]=await this.request({method:"POST",uri:"/restore",qs:e});return t}request(e,t){return this.parent.request.call(this,e,t)}rotateEncryptionKey(e,t){var r;t="function"==typeof e?e:t;let a={};"string"==typeof e||e instanceof Buffer?a={encryptionKey:e}:"object"==typeof e&&(a=e);let i=this.bucket.file(this.id,a),s=(null==(r=a.preconditionOpts)?void 0:r.ifGenerationMatch)!==void 0?{preconditionOpts:a.preconditionOpts}:{};this.copy(i,s,t)}save(e,t,r){r="function"==typeof t?t:r;let a="object"==typeof t?t:{},i=this.storage.retryOptions.maxRetries;this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(null==a?void 0:a.preconditionOpts)||(i=0);let s=(0,eP.default)(async t=>new Promise((r,s)=>{0===i&&(this.storage.retryOptions.autoRetry=!1);let n=this.createWriteStream(a);a.onUploadProgress&&n.on("progress",a.onUploadProgress);let o=e=>this.storage.retryOptions.autoRetry&&this.storage.retryOptions.retryableErrorFn(e)?s(e):t(e);"string"==typeof e||Buffer.isBuffer(e)||e instanceof Uint8Array?n.on("error",o).on("finish",()=>r()).end(e):(0,ee.pipeline)(e,n,a=>{if(a){if("function"!=typeof e)return t(a);o(a)}else r()})}),{retries:i,factor:this.storage.retryOptions.retryDelayMultiplier,maxTimeout:1e3*this.storage.retryOptions.maxRetryDelay,maxRetryTime:1e3*this.storage.retryOptions.totalTimeout});return r?s.then(()=>{if(r)return r()}).catch(r):s}setMetadata(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.disableAutoRetryConditionallyIdempotent_(this.methods.setMetadata,E.setMetadata,a),super.setMetadata(e,a).then(e=>r(null,...e)).catch(r).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}setStorageClass(e,t,r){r="function"==typeof t?t:r;let a={..."object"==typeof t?t:{},storageClass:e.replace(/-/g,"_").replace(/([a-z])([A-Z])/g,(e,t,r)=>t+"_"+r).toUpperCase()};this.copy(this,a,(e,t,a)=>{e?r(e,a):(this.metadata=t.metadata,r(null,a))})}setUserProject(e){this.bucket.setUserProject.call(this,e)}startResumableUpload_(e,t={}){let r;null!=t.metadata||(t.metadata={});let a=this.storage.retryOptions;this.shouldRetryBasedOnPreconditionAndIdempotencyStrat(t.preconditionOpts)||(a.autoRetry=!1);let i={authClient:this.storage.authClient,apiEndpoint:this.storage.apiEndpoint,bucket:this.bucket.name,customRequestOptions:this.getRequestInterceptors().reduce((e,t)=>t(e),{}),file:this.name,generation:this.generation,isPartialUpload:t.isPartialUpload,key:this.encryptionKey,kmsKeyName:this.kmsKeyName,metadata:t.metadata,offset:t.offset,predefinedAcl:t.predefinedAcl,private:t.private,public:t.public,uri:t.uri,userProject:t.userProject||this.userProject,retryOptions:{...a},params:(null==t?void 0:t.preconditionOpts)||this.instancePreconditionOpts,chunkSize:null==t?void 0:t.chunkSize,highWaterMark:null==t?void 0:t.highWaterMark,universeDomain:this.bucket.storage.universeDomain,[ey]:t[ey]};try{r=new eW(i)}catch(t){e.destroy(t),this.storage.retryOptions.autoRetry=this.instanceRetryValue;return}r.on("response",t=>{e.emit("response",t)}).on("uri",t=>{e.emit("uri",t)}).on("metadata",t=>{this.metadata=t,e.emit("metadata")}).on("finish",()=>{e.emit("complete")}).on("progress",t=>e.emit("progress",t)),e.setWritable(r),this.storage.retryOptions.autoRetry=this.instanceRetryValue}startSimpleUpload_(e,t={}){null!=t.metadata||(t.metadata={});let r=this.storage.apiEndpoint,a=this.bucket.name,i=`${r}/upload/storage/v1/b/${a}/o`,s={qs:{name:this.name},uri:i,[ey]:t[ey]};void 0!==this.generation&&(s.qs.ifGenerationMatch=this.generation),void 0!==this.kmsKeyName&&(s.qs.kmsKeyName=this.kmsKeyName),"number"==typeof t.timeout&&(s.timeout=t.timeout),(t.userProject||this.userProject)&&(s.qs.userProject=t.userProject||this.userProject),t.predefinedAcl?s.qs.predefinedAcl=t.predefinedAcl:t.private?s.qs.predefinedAcl="private":t.public&&(s.qs.predefinedAcl="publicRead"),Object.assign(s.qs,this.instancePreconditionOpts,t.preconditionOpts),eN.makeWritableStream(e,{makeAuthenticatedRequest:t=>{this.request(t,(t,r,a)=>{t?e.destroy(t):(this.metadata=r,e.emit("metadata",r),e.emit("response",a),e.emit("complete"))})},metadata:t.metadata,request:s})}disableAutoRetryConditionallyIdempotent_(e,t,r){var a,i,s,n;("object"==typeof e&&(null==(i=null==(a=null==e?void 0:e.reqOpts)?void 0:a.qs)?void 0:i.ifGenerationMatch)===void 0&&(null==r?void 0:r.ifGenerationMatch)===void 0&&t===E.delete&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(this.storage.retryOptions.autoRetry=!1),("object"==typeof e&&(null==(n=null==(s=null==e?void 0:e.reqOpts)?void 0:s.qs)?void 0:n.ifMetagenerationMatch)===void 0&&(null==r?void 0:r.ifMetagenerationMatch)===void 0&&t===E.setMetadata&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(this.storage.retryOptions.autoRetry=!1)}async getBufferFromReadable(e){let t=[];for await(let r of e)t.push(r);return Buffer.concat(t)}}w=new WeakSet,b=async function(e,t={}){let r=this.metadata,a=!!(t.crc32c||t.md5);if(t.crc32c&&r.crc32c&&(a=!e.test("crc32c",r.crc32c)),t.md5&&r.md5Hash&&(a=!e.test("md5",r.md5Hash)),a){let e=[],a="",i="";try{await this.delete(),t.md5&&!r.md5Hash?(a="MD5_NOT_AVAILABLE",i=x.MD5_NOT_AVAILABLE):(a="FILE_NO_UPLOAD",i=x.UPLOAD_MISMATCH)}catch(t){a="FILE_NO_UPLOAD_DELETE",i=`${x.UPLOAD_MISMATCH_DELETE_FAIL}${t.message}`,e.push(t)}let s=new e5(i);throw s.code=a,s.errors=e,s}return!0},(0,eA.promisifyAll)(te,{exclude:["cloudStorageURI","publicUrl","request","save","setEncryptionKey","shouldRetryBasedOnPreconditionAndIdempotencyStrat","getBufferFromReadable","restore"]}),(i=N||(N={})).POLICY_OBJECT_REQUIRED="A policy object is required.",i.PERMISSIONS_REQUIRED="Permissions are required.";class tt{constructor(e){this.request_=e.request.bind(e),this.resourceId_="buckets/"+e.getId()}getPolicy(e,t){let{options:r,callback:a}=eo(e,t),i={};r.userProject&&(i.userProject=r.userProject),null!==r.requestedPolicyVersion&&void 0!==r.requestedPolicyVersion&&(i.optionsRequestedPolicyVersion=r.requestedPolicyVersion),this.request_({uri:"/iam",qs:i},a)}setPolicy(e,t,r){let a;if(null===e||"object"!=typeof e)throw Error(N.POLICY_OBJECT_REQUIRED);let{options:i,callback:s}=eo(t,r);void 0===e.etag&&(a=0),this.request_({method:"PUT",uri:"/iam",maxRetries:a,json:Object.assign({resourceId:this.resourceId_},e),qs:i},s)}testPermissions(e,t,r){if(!Array.isArray(e)&&"string"!=typeof e)throw Error(N.PERMISSIONS_REQUIRED);let{options:a,callback:i}=eo(t,r),s=Array.isArray(e)?e:[e],n=Object.assign({permissions:s},a);this.request_({uri:"/iam/testPermissions",qs:n,useQuerystring:!0},(e,t)=>{if(e)return void i(e,null,t);let r=Array.isArray(t.permissions)?t.permissions:[];i(null,s.reduce((e,t)=>(e[t]=r.indexOf(t)>-1,e),{}),t)})}}(0,eA.promisifyAll)(tt);class tr extends ek{constructor(e,t){const r={};super({parent:e,baseUrl:"/notificationConfigs",id:t.toString(),createMethod:e.createNotification.bind(e),methods:{create:!0,delete:{reqOpts:{qs:r}},get:{reqOpts:{qs:r}},getMetadata:{reqOpts:{qs:r}},exists:!0}})}}(0,eA.promisifyAll)(tr),(T||(T={})).list="GET",(s=E||(E={}))[s.setMetadata=0]="setMetadata",s[s.delete=1]="delete",(n=A||(A={})).PROVIDE_SOURCE_FILE="You must provide at least one source file.",n.DESTINATION_FILE_NOT_SPECIFIED="A destination file must be specified.",n.CHANNEL_ID_REQUIRED="An ID is required to create a channel.",n.TOPIC_NAME_REQUIRED="A valid topic name is required.",n.CONFIGURATION_OBJECT_PREFIX_REQUIRED="A configuration object with a prefix is required.",n.SPECIFY_FILE_NAME="A file name must be specified.",n.METAGENERATION_NOT_PROVIDED="A metageneration must be provided.",n.SUPPLY_NOTIFICATION_ID="You must supply a notification ID.";class ta extends ek{getFilesStream(e){return new ee.Readable}constructor(e,t,r){var a,i,s,n;r=r||{},t=t.replace(/^gs:\/\//,"").replace(/\/+$/,"");const o={};(null==(a=null==r?void 0:r.preconditionOpts)?void 0:a.ifGenerationMatch)&&(o.ifGenerationMatch=r.preconditionOpts.ifGenerationMatch),(null==(i=null==r?void 0:r.preconditionOpts)?void 0:i.ifGenerationNotMatch)&&(o.ifGenerationNotMatch=r.preconditionOpts.ifGenerationNotMatch),(null==(s=null==r?void 0:r.preconditionOpts)?void 0:s.ifMetagenerationMatch)&&(o.ifMetagenerationMatch=r.preconditionOpts.ifMetagenerationMatch),(null==(n=null==r?void 0:r.preconditionOpts)?void 0:n.ifMetagenerationNotMatch)&&(o.ifMetagenerationNotMatch=r.preconditionOpts.ifMetagenerationNotMatch);const p=r.userProject;"string"==typeof p&&(o.userProject=p),super({parent:e,baseUrl:"/b",id:t,createMethod:e.createBucket.bind(e),methods:{create:{reqOpts:{qs:o}},delete:{reqOpts:{qs:o}},exists:{reqOpts:{qs:o}},get:{reqOpts:{qs:o}},getMetadata:{reqOpts:{qs:o}},setMetadata:{reqOpts:{qs:o}}}}),this.unreachable=!1,this.name=t,this.storage=e,this.userProject=r.userProject,this.acl=new eq({request:this.request.bind(this),pathPrefix:"/acl"}),this.acl.default=new eq({request:this.request.bind(this),pathPrefix:"/defaultObjectAcl"}),this.crc32cGenerator=r.crc32cGenerator||this.storage.crc32cGenerator,this.iam=new tt(this),this.getFilesStream=eO.paginator.streamify("getFiles"),this.instanceRetryValue=e.retryOptions.autoRetry,this.instancePreconditionOpts=null==r?void 0:r.preconditionOpts}get cloudStorageURI(){let e=new es.URL("gs://");return e.host=this.name,e}addLifecycleRule(e,t,r){let a={};"function"==typeof t?r=t:t&&(a=t),a=a||{};let i=Array.isArray(e)?e:[e];for(let e of i)e.condition.createdBefore instanceof Date&&(e.condition.createdBefore=e.condition.createdBefore.toISOString().replace(/T.+$/,"")),e.condition.customTimeBefore instanceof Date&&(e.condition.customTimeBefore=e.condition.customTimeBefore.toISOString().replace(/T.+$/,"")),e.condition.noncurrentTimeBefore instanceof Date&&(e.condition.noncurrentTimeBefore=e.condition.noncurrentTimeBefore.toISOString().replace(/T.+$/,""));!1===a.append?this.setMetadata({lifecycle:{rule:i}},a,r):this.getMetadata((e,t)=>{var s,n;if(e)return void r(e);let o=Array.isArray(null==(s=t.lifecycle)?void 0:s.rule)?null==(n=t.lifecycle)?void 0:n.rule:[];this.setMetadata({lifecycle:{rule:o.concat(i)}},a,r)})}combine(e,t,r,a){var i;if(!Array.isArray(e)||0===e.length)throw Error(A.PROVIDE_SOURCE_FILE);if(!t)throw Error(A.DESTINATION_FILE_NOT_SPECIFIED);let s={};"function"==typeof r?a=r:r&&(s=r),this.disableAutoRetryConditionallyIdempotent_(this.methods.setMetadata,E.setMetadata,s);let n=e=>e instanceof te?e:this.file(e);e=e.map(n);let o=n(t);if(a=a||eN.noop,!o.metadata.contentType){let e=eI.default.getType(o.name)||void 0;e&&(o.metadata.contentType=e)}let p=this.storage.retryOptions.maxRetries;((null==(i=null==o?void 0:o.instancePreconditionOpts)?void 0:i.ifGenerationMatch)===void 0&&void 0===s.ifGenerationMatch&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(p=0),void 0===s.ifGenerationMatch&&Object.assign(s,o.instancePreconditionOpts,s),o.request({method:"POST",uri:"/compose",maxRetries:p,json:{destination:{contentType:o.metadata.contentType,contentEncoding:o.metadata.contentEncoding},sourceObjects:e.map(e=>{let t={name:e.name};return e.metadata&&e.metadata.generation&&(t.generation=parseInt(e.metadata.generation.toString())),t})},qs:s},(e,t)=>{(this.storage.retryOptions.autoRetry=this.instanceRetryValue,e)?a(e,null,t):a(null,o,t)})}createChannel(e,t,r,a){if("string"!=typeof e)throw Error(A.CHANNEL_ID_REQUIRED);let i={};"function"==typeof r?a=r:r&&(i=r),this.request({method:"POST",uri:"/o/watch",json:Object.assign({id:e,type:"web_hook"},t),qs:i},(t,r)=>{if(t)return void a(t,null,r);let i=r.resourceId,s=this.storage.channel(e,i);s.metadata=r,a(null,s,r)})}createNotification(e,t,r){let a={};if("function"==typeof t?r=t:t&&(a=t),null!==e&&"object"==typeof e&&eN.isCustomType(e,"pubsub/topic")&&(e=e.name),"string"!=typeof e)throw Error(A.TOPIC_NAME_REQUIRED);let i=Object.assign({topic:e},a);0!==i.topic.indexOf("projects")&&(i.topic="projects/{{projectId}}/topics/"+i.topic),i.topic=`//pubsub.${this.storage.universeDomain}/`+i.topic,i.payloadFormat||(i.payloadFormat="JSON_API_V1");let s={};i.userProject&&(s.userProject=i.userProject,delete i.userProject),this.request({method:"POST",uri:"/notificationConfigs",json:function e(t){return t instanceof Date||t instanceof RegExp?t:Array.isArray(t)?t.map(e):t instanceof Object?Object.keys(t).reduce((r,a)=>(r[a[0].toLocaleLowerCase()+a.slice(1).replace(/([A-Z]+)/g,(e,t)=>`_${t.toLowerCase()}`)]=e(t[a]),r),{}):t}(i),qs:s,maxRetries:0},(e,t)=>{if(e)return void r(e,null,t);let a=this.notification(t.id);a.metadata=t,r(null,a,t)})}deleteFiles(e,t){let r={};"function"==typeof e?t=e:e&&(r=e);let a=[],i=e=>e.delete(r).catch(e=>{if(!r.force)throw e;a.push(e)});(async()=>{try{let e=[],s=(0,eR.default)(10),n=this.getFilesStream(r);for await(let t of n)e.length>=1e3&&(await Promise.all(e),e=[]),e.push(s(()=>i(t)).catch(e=>{throw n.destroy(),e}));await Promise.all(e),t(a.length>0?a:null)}catch(e){t(e);return}})()}deleteLabels(e,t,r){let a=[],i={};"function"==typeof e?r=e:"string"==typeof e?a=[e]:Array.isArray(e)?a=e:e&&(i=e),"function"==typeof t?r=t:t&&(i=t);let s=e=>{let t=e.reduce((e,t)=>(e[t]=null,e),{});(null==i?void 0:i.ifMetagenerationMatch)!==void 0?this.setLabels(t,i,r):this.setLabels(t,r)};0===a.length?this.getLabels((e,t)=>{e?r(e):s(Object.keys(t))}):s(a)}disableRequesterPays(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.setMetadata({billing:{requesterPays:!1}},r,t)}enableLogging(e,t){if(!e||"function"==typeof e||void 0===e.prefix)throw Error(A.CONFIGURATION_OBJECT_PREFIX_REQUIRED);let r=this.id;e.bucket&&e.bucket instanceof ta?r=e.bucket.id:e.bucket&&"string"==typeof e.bucket&&(r=e.bucket);let a={};(null==e?void 0:e.ifMetagenerationMatch)&&(a.ifMetagenerationMatch=e.ifMetagenerationMatch),(null==e?void 0:e.ifMetagenerationNotMatch)&&(a.ifMetagenerationNotMatch=e.ifMetagenerationNotMatch),(async()=>{try{let[i]=await this.iam.getPolicy();i.bindings.push({members:["group:cloud-storage-analytics@google.com"],role:"roles/storage.objectCreator"}),await this.iam.setPolicy(i),this.setMetadata({logging:{logBucket:r,logObjectPrefix:e.prefix}},a,t)}catch(e){t(e);return}})()}enableRequesterPays(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.setMetadata({billing:{requesterPays:!0}},r,t)}file(e,t){if(!e)throw Error(A.SPECIFY_FILE_NAME);return new te(this,e,t)}getFiles(e,t){let r="object"==typeof e?e:{};t||(t=e),(r=Object.assign({},r)).fields&&r.autoPaginate&&!r.fields.includes("nextPageToken")&&(r.fields=`${r.fields},nextPageToken`),this.request({uri:"/o",qs:r},(e,a)=>{if(e)return void t(e,null,null,a);let i=(a.items?a.items:[]).map(e=>{let t={};if(r.fields)return e;r.versions&&(t.generation=e.generation),e.kmsKeyName&&(t.kmsKeyName=e.kmsKeyName);let a=this.file(e.name,t);return a.metadata=e,a}),s=null;a.nextPageToken&&(s=Object.assign({},r,{pageToken:a.nextPageToken})),t(null,i,s,a)})}getLabels(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.getMetadata(r,(e,r)=>{e?t(e,null):t(null,(null==r?void 0:r.labels)||{})})}getNotifications(e,t){let r={};"function"==typeof e?t=e:e&&(r=e),this.request({uri:"/notificationConfigs",qs:r},(e,r)=>{if(e)return void t(e,null,r);let a=(r.items?r.items:[]).map(e=>{let t=this.notification(e.id);return t.metadata=e,t});t(null,a,r)})}getSignedUrl(e,t){let r={method:T[e.action],expires:e.expires,version:e.version,cname:e.cname,extensionHeaders:e.extensionHeaders||{},queryParams:e.queryParams||{},host:e.host,signingEndpoint:e.signingEndpoint};this.signer||(this.signer=new eG(this.storage.authClient,this,void 0,this.storage)),this.signer.getSignedUrl(r).then(e=>t(null,e),t)}lock(e,t){let r=typeof e;if("number"!==r&&"string"!==r)throw Error(A.METAGENERATION_NOT_PROVIDED);this.request({method:"POST",uri:"/lockRetentionPolicy",qs:{ifMetagenerationMatch:e}},t)}async restore(e){let[t]=await this.request({method:"POST",uri:"/restore",qs:e});return t}makePrivate(e,t){var r,a,i,s;let n="object"==typeof e?e:{};t="function"==typeof e?e:t,n.private=!0;let o={predefinedAcl:"projectPrivate"};n.userProject&&(o.userProject=n.userProject),(null==(r=n.preconditionOpts)?void 0:r.ifGenerationMatch)&&(o.ifGenerationMatch=n.preconditionOpts.ifGenerationMatch),(null==(a=n.preconditionOpts)?void 0:a.ifGenerationNotMatch)&&(o.ifGenerationNotMatch=n.preconditionOpts.ifGenerationNotMatch),(null==(i=n.preconditionOpts)?void 0:i.ifMetagenerationMatch)&&(o.ifMetagenerationMatch=n.preconditionOpts.ifMetagenerationMatch),(null==(s=n.preconditionOpts)?void 0:s.ifMetagenerationNotMatch)&&(o.ifMetagenerationNotMatch=n.preconditionOpts.ifMetagenerationNotMatch);let p={...n.metadata,acl:null};this.setMetadata(p,o,e=>{e&&t(e),(n.includeFiles?(0,eD.promisify)(this.makeAllFilesPublicPrivate_).call(this,n):Promise.resolve([])).then(e=>t(null,e)).catch(t)})}makePublic(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t;let a={public:!0,...r};this.acl.add({entity:"allUsers",role:"READER"}).then(()=>this.acl.default.add({entity:"allUsers",role:"READER"})).then(()=>a.includeFiles?(0,eD.promisify)(this.makeAllFilesPublicPrivate_).call(this,a):[]).then(e=>t(null,e),t)}notification(e){if(!e)throw Error(A.SUPPLY_NOTIFICATION_ID);return new tr(this,e)}removeRetentionPeriod(e,t){let r="object"==typeof e?e:{};t="function"==typeof e?e:t,this.setMetadata({retentionPolicy:null},r,t)}request(e,t){return!this.userProject||e.qs&&e.qs.userProject||(e.qs={...e.qs,userProject:this.userProject}),super.request(e,t)}setLabels(e,t,r){let a="object"==typeof t?t:{};r=(r="function"==typeof t?t:r)||eN.noop,this.setMetadata({labels:e},a,r)}setMetadata(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.disableAutoRetryConditionallyIdempotent_(this.methods.setMetadata,E.setMetadata,a),super.setMetadata(e,a).then(e=>r(null,...e)).catch(r).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}setRetentionPeriod(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.setMetadata({retentionPolicy:{retentionPeriod:e.toString()}},a,r)}setCorsConfiguration(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,this.setMetadata({cors:e},a,r)}setStorageClass(e,t,r){let a="object"==typeof t?t:{};r="function"==typeof t?t:r,e=e.replace(/-/g,"_").replace(/([a-z])([A-Z])/g,(e,t,r)=>t+"_"+r).toUpperCase(),this.setMetadata({storageClass:e},a,r)}setUserProject(e){this.userProject=e,["create","delete","exists","get","getMetadata","setMetadata"].forEach(t=>{let r=this.methods[t];"object"==typeof r&&("object"==typeof r.reqOpts?Object.assign(r.reqOpts.qs,{userProject:e}):r.reqOpts={qs:{userProject:e}})})}upload(t,r,a){var i,s;let n,o=e=>{let r=(0,eP.default)(async r=>{await new Promise((a,i)=>{var s,o;0===e&&(null==(o=null==(s=null==n?void 0:n.storage)?void 0:s.retryOptions)?void 0:o.autoRetry)&&(n.storage.retryOptions.autoRetry=!1);let d=n.createWriteStream(p);p.onUploadProgress&&d.on("progress",p.onUploadProgress),eC.createReadStream(t).on("error",r).pipe(d).on("error",e=>this.storage.retryOptions.autoRetry&&this.storage.retryOptions.retryableErrorFn(e)?i(e):r(e)).on("finish",()=>a())})},{retries:e,factor:this.storage.retryOptions.retryDelayMultiplier,maxTimeout:1e3*this.storage.retryOptions.maxRetryDelay,maxRetryTime:1e3*this.storage.retryOptions.totalTimeout});return a?r.then(()=>{if(a)return a(null,n,n.metadata)}).catch(a):r};if(e.g.GCLOUD_SANDBOX_ENV)return;let p="object"==typeof r?r:{};a="function"==typeof r?r:a,p=Object.assign({metadata:{}},p);let d=this.storage.retryOptions.maxRetries;if(((null==(i=null==p?void 0:p.preconditionOpts)?void 0:i.ifGenerationMatch)===void 0&&(null==(s=this.instancePreconditionOpts)?void 0:s.ifGenerationMatch)===void 0&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional||this.storage.retryOptions.idempotencyStrategy===S.RetryNever)&&(d=0),p.destination instanceof te)n=p.destination;else if(null!==p.destination&&"string"==typeof p.destination)n=this.file(p.destination,{encryptionKey:p.encryptionKey,kmsKeyName:p.kmsKeyName,preconditionOpts:this.instancePreconditionOpts});else{let e=er.basename(t);n=this.file(e,{encryptionKey:p.encryptionKey,kmsKeyName:p.kmsKeyName,preconditionOpts:this.instancePreconditionOpts})}o(d)}makeAllFilesPublicPrivate_(e,t){let r=[],a=[],i="object"==typeof e?e:{};t="function"==typeof e?e:t;let s=async e=>{try{await (i.public?e.makePublic():e.makePrivate(i)),a.push(e)}catch(e){if(!i.force)throw e;r.push(e)}};this.getFiles(i).then(([e])=>{let t=(0,eR.default)(10);return Promise.all(e.map(e=>t(()=>s(e))))}).then(()=>t(r.length>0?r:null,a),e=>t(e,a))}getId(){return this.id}disableAutoRetryConditionallyIdempotent_(e,t,r){var a,i;"object"==typeof e&&(null==(i=null==(a=null==e?void 0:e.reqOpts)?void 0:a.qs)?void 0:i.ifMetagenerationMatch)===void 0&&(null==r?void 0:r.ifMetagenerationMatch)===void 0&&(t===E.setMetadata||t===E.delete)&&this.storage.retryOptions.idempotencyStrategy===S.RetryConditional?this.storage.retryOptions.autoRetry=!1:this.storage.retryOptions.idempotencyStrategy===S.RetryNever&&(this.storage.retryOptions.autoRetry=!1)}}eO.paginator.extend(ta,"getFiles"),(0,eA.promisifyAll)(ta,{exclude:["cloudStorageURI","request","file","notification","restore"]});class ti extends ek{constructor(e,t,r){super({parent:e,baseUrl:"/channels",id:"",methods:{}}),this.metadata.id=t,this.metadata.resourceId=r}stop(e){e=e||eN.noop,this.request({method:"POST",uri:"/stop",json:this.metadata},(t,r)=>{e(t,r)})}}(0,eA.promisifyAll)(ti);class ts extends ek{constructor(e,t,r){super({parent:e,id:t,baseUrl:`/projects/${r&&r.projectId||e.projectId}/hmacKeys`,methods:{delete:!0,get:!0,getMetadata:!0,setMetadata:{reqOpts:{method:"PUT"}}}}),this.storage=e,this.instanceRetryValue=e.retryOptions.autoRetry}setMetadata(e,t,r){this.storage.retryOptions.idempotencyStrategy!==S.RetryAlways&&(this.storage.retryOptions.autoRetry=!1);let a="object"==typeof t?t:{};r="function"==typeof t?t:r,super.setMetadata(e,a).then(e=>r(null,...e)).catch(r).finally(()=>{this.storage.retryOptions.autoRetry=this.instanceRetryValue})}}(0,eA.promisifyAll)(ts),(o=S||(S={}))[o.RetryAlways=0]="RetryAlways",o[o.RetryConditional=1]="RetryConditional",o[o.RetryNever=2]="RetryNever",(p=k||(k={})).EXPIRATION_DATE_INVALID="The expiration date provided was invalid.",p.EXPIRATION_DATE_PAST="An expiration date cannot be in the past.",(d=O||(O={})).BUCKET_NAME_REQUIRED="A bucket name is needed to use Cloud Storage.",d.BUCKET_NAME_REQUIRED_CREATE="A name is required to create a bucket.",d.HMAC_SERVICE_ACCOUNT="The first argument must be a service account email to create an HMAC key.",d.HMAC_ACCESS_ID="An access ID is needed to create an HmacKey object.";let tn=/^(\w*):\/\//,to=S.RetryConditional,tp=function(e){var t;let r=e=>e.includes("eai_again")||"econnreset"===e||"unexpected connection closure"===e||"epipe"===e||"socket connection timeout"===e;if(e){if(-1!==[408,429,500,502,503,504].indexOf(e.code)||"string"==typeof e.code&&(-1!==["408","429","500","502","503","504"].indexOf(e.code)||r(e.code.toLowerCase())))return!0;if(e.errors)for(let a of e.errors){let e=null==(t=null==a?void 0:a.reason)?void 0:t.toString().toLowerCase();if(e&&r(e))return!0}}return!1};class td extends eE{getBucketsStream(){return new ee.Readable}getHmacKeysStream(){return new ee.Readable}constructor(e={}){var t,r,a,i,s,n,o,p,d,l,c,u,h,m;const f=e.universeDomain||C.DEFAULT_UNIVERSE;let g=`https://storage.${f}`,v=!1;const y=process.env.STORAGE_EMULATOR_HOST;"string"==typeof y&&(g=td.sanitizeEndpoint(y),v=!0),e.apiEndpoint&&e.apiEndpoint!==g&&(g=td.sanitizeEndpoint(e.apiEndpoint),v=!0),e=Object.assign({},e,{apiEndpoint:g});const w=y||`${e.apiEndpoint}/storage/v1`,b={apiEndpoint:e.apiEndpoint,retryOptions:{autoRetry:(null==(t=e.retryOptions)?void 0:t.autoRetry)===void 0||(null==(r=e.retryOptions)?void 0:r.autoRetry),maxRetries:(null==(a=e.retryOptions)?void 0:a.maxRetries)?null==(i=e.retryOptions)?void 0:i.maxRetries:3,retryDelayMultiplier:(null==(s=e.retryOptions)?void 0:s.retryDelayMultiplier)?null==(n=e.retryOptions)?void 0:n.retryDelayMultiplier:2,totalTimeout:(null==(o=e.retryOptions)?void 0:o.totalTimeout)?null==(p=e.retryOptions)?void 0:p.totalTimeout:600,maxRetryDelay:(null==(d=e.retryOptions)?void 0:d.maxRetryDelay)?null==(l=e.retryOptions)?void 0:l.maxRetryDelay:64,retryableErrorFn:(null==(c=e.retryOptions)?void 0:c.retryableErrorFn)?null==(u=e.retryOptions)?void 0:u.retryableErrorFn:tp,idempotencyStrategy:(null==(h=e.retryOptions)?void 0:h.idempotencyStrategy)!==void 0?null==(m=e.retryOptions)?void 0:m.idempotencyStrategy:to},baseUrl:w,customEndpoint:v,useAuthWithCustomEndpoint:null==e?void 0:e.useAuthWithCustomEndpoint,projectIdRequired:!1,scopes:["https://www.googleapis.com/auth/iam","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/devstorage.full_control"],packageJson:(0,en.getPackageJSON)()};super(b,e),this.acl=td.acl,this.crc32cGenerator=e.crc32cGenerator||eY,this.retryOptions=b.retryOptions,this.getBucketsStream=eO.paginator.streamify("getBuckets"),this.getHmacKeysStream=eO.paginator.streamify("getHmacKeys")}static sanitizeEndpoint(e){return tn.test(e)||(e=`https://${e}`),e.replace(/\/+$/,"")}bucket(e,t){if(!e)throw Error(O.BUCKET_NAME_REQUIRED);return new ta(this,e,t)}channel(e,t){return new ti(this,e,t)}createBucket(e,t,r){let a;if(!e)throw Error(O.BUCKET_NAME_REQUIRED_CREATE);r?a=t:(r=t,a={});let i={...a,name:e},s={archive:"ARCHIVE",coldline:"COLDLINE",dra:"DURABLE_REDUCED_AVAILABILITY",multiRegional:"MULTI_REGIONAL",nearline:"NEARLINE",regional:"REGIONAL",standard:"STANDARD"};for(let e of Object.keys(s))if(i[e]){if(a.storageClass&&a.storageClass!==e)throw Error(`Both \`${e}\` and \`storageClass\` were provided.`);i.storageClass=s[e],delete i[e]}i.requesterPays&&(i.billing={requesterPays:i.requesterPays},delete i.requesterPays);let n={project:this.projectId};i.userProject&&(n.userProject=i.userProject,delete i.userProject),i.enableObjectRetention&&(n.enableObjectRetention=i.enableObjectRetention,delete i.enableObjectRetention),i.predefinedAcl&&(n.predefinedAcl=i.predefinedAcl,delete i.predefinedAcl),i.predefinedDefaultObjectAcl&&(n.predefinedDefaultObjectAcl=i.predefinedDefaultObjectAcl,delete i.predefinedDefaultObjectAcl),i.projection&&(n.projection=i.projection,delete i.projection),this.request({method:"POST",uri:"/b",qs:n,json:i},(t,a)=>{if(t)return void r(t,null,a);let i=this.bucket(e);i.metadata=a,r(null,i,a)})}createHmacKey(e,t,r){if("string"!=typeof e)throw Error(O.HMAC_SERVICE_ACCOUNT);let{options:a,callback:i}=eo(t,r),s=Object.assign({},a,{serviceAccountEmail:e}),n=s.projectId||this.projectId;delete s.projectId,this.request({method:"POST",uri:`/projects/${n}/hmacKeys`,qs:s,maxRetries:0},(e,t)=>{if(e)return void i(e,null,null,t);let r=t.metadata,a=this.hmacKey(r.accessId,{projectId:r.projectId});a.metadata=t.metadata,i(null,a,t.secret,t)})}getBuckets(e,t){let{options:r,callback:a}=eo(e,t);r.project=r.project||this.projectId,this.request({uri:"/b",qs:r},(e,t)=>{if(e)return void a(e,null,null,t);let i=t.items?t.items:[],s=t.unreachable?t.unreachable:[],n=i.map(e=>{let t=this.bucket(e.id);return t.metadata=e,t});s.length>0&&s.forEach(e=>{let t=e.split("/").pop();if(t){let e=this.bucket(t);e.unreachable=!0,e.metadata={},n.push(e)}}),a(null,n,t.nextPageToken?Object.assign({},r,{pageToken:t.nextPageToken}):null,t)})}getHmacKeys(e,t){let{options:r,callback:a}=eo(e,t),i=Object.assign({},r),s=i.projectId||this.projectId;delete i.projectId,this.request({uri:`/projects/${s}/hmacKeys`,qs:i},(e,t)=>{e?a(e,null,null,t):a(null,(t.items?t.items:[]).map(e=>{let t=this.hmacKey(e.accessId,{projectId:e.projectId});return t.metadata=e,t}),t.nextPageToken?Object.assign({},r,{pageToken:t.nextPageToken}):null,t)})}getServiceAccount(e,t){let{options:r,callback:a}=eo(e,t);this.request({uri:`/projects/${this.projectId}/serviceAccount`,qs:r},(e,t)=>{if(e)return void a(e,null,t);let r={};for(let e in t)t.hasOwnProperty(e)&&(r[e.replace(/_(\w)/g,(e,t)=>t.toUpperCase())]=t[e]);a(null,r,t)})}hmacKey(e,t){if(!e)throw Error(O.HMAC_ACCESS_ID);return new ts(this,e,t)}}td.Bucket=ta,td.Channel=ti,td.File=te,td.HmacKey=ts,td.acl={OWNER_ROLE:"OWNER",READER_ROLE:"READER",WRITER_ROLE:"WRITER"},eO.paginator.extend(td,["getBuckets","getHmacKeys"]),(0,eA.promisifyAll)(td,{exclude:["bucket","channel","hmacKey"]}),e.i(55101),(0,en.getPackageJSON)(),new WeakSet;var tl=e.i(7273);class tc{storage;bucketName;db;constructor(e,t){this.db=e,this.bucketName=t,this.storage=new td}async saveGenerationFile(e){let t=(0,tl.nanoid)(),r=(0,I.createHash)("sha256").update(e.content).digest("hex"),a=`generations/${e.generationId}/${t}/${e.filename}`,i=this.storage.bucket(this.bucketName).file(a);return await i.save(e.content,{contentType:e.contentType,metadata:{sha256:r,generationId:e.generationId,fileId:t}}),await this.db.insertInto("generation_file").values({file_id:t,generation_id:e.generationId,filename:e.filename,content_type:e.contentType,size_bytes:e.content.length.toString(),sha256_hex:r,gcs_path:a,createdAt:new Date}).execute(),{fileId:t}}async downloadFile(e){let[t]=await this.storage.bucket(this.bucketName).file(e).download();return t}}e.s(["GCSBlobStore",()=>tc],59613)},37893,e=>{"use strict";e.i(36553),e.i(59613),e.s([])},55340,e=>{"use strict";var t=e.i(12995),r=e.i(7273);class a{db;constructor(e){this.db=e}async upsertThread(e){let t=new Date,r={user_id:e.userId,updatedAt:t};return void 0!==e.title&&(r.title=e.title),await this.db.insertInto("thread").values({thread_id:e.threadId,app_id:e.appId,tenant_id:e.tenantId||null,user_id:e.userId,title:e.title??null,createdAt:t,updatedAt:t}).onConflict(e=>e.column("thread_id").doUpdateSet(r)).execute(),{threadId:e.threadId}}async upsertThreadByGenerationId(e){let t=await this.db.selectFrom("generation").select(["app_id","thread_id","user_id","tenant_id"]).where("generation_id","=",e.generationId).executeTakeFirst();t&&await this.upsertThread({threadId:t.thread_id,appId:t.app_id,tenantId:t.tenant_id??void 0,userId:t.user_id,title:e.title})}async startGeneration(e){let r=new Date;return await this.db.insertInto("generation").values({generation_id:e.generationId,app_id:e.appId,tenant_id:e.tenantId||null,thread_id:e.threadId,request_id:e.requestId,user_id:e.userId,model:e.model,name:e.name||null,messages:t.sql`cast(${JSON.stringify(e.messages)} as jsonb)`,createdAt:r,updatedAt:r}).execute(),{generationId:e.generationId}}async endGeneration(e){let a=new Date;if(e.responseMessages&&e.responseMessages.length>0){let r=await this.db.selectFrom("generation").select("messages").where("generation_id","=",e.generationId).executeTakeFirst(),i=[...r?.messages||[],...e.responseMessages];await this.db.updateTable("generation").set({messages:t.sql`cast(${JSON.stringify(i)} as jsonb)`,updatedAt:a}).where("generation_id","=",e.generationId).execute()}else await this.db.updateTable("generation").set({updatedAt:a}).where("generation_id","=",e.generationId).execute();await this.db.insertInto("generation_metrics").values({metrics_id:(0,r.nanoid)(),generation_id:e.generationId,latency_ms:e.latencyMs||null,input_tokens:e.usage?.inputTokens||null,output_tokens:e.usage?.outputTokens||null,total_tokens:e.usage?.totalTokens||null,reasoning_tokens:e.usage?.reasoningTokens||null,cached_input_tokens:e.usage?.cachedInputTokens||null,input_cost_usd:e.cost?.inputCostUsd?.toString()||null,output_cost_usd:e.cost?.outputCostUsd?.toString()||null,total_cost_usd:e.cost?.totalCostUsd?.toString()||null,createdAt:a,updatedAt:a}).onConflict(t=>t.column("generation_id").doUpdateSet({latency_ms:e.latencyMs||null,input_tokens:e.usage?.inputTokens||null,output_tokens:e.usage?.outputTokens||null,total_tokens:e.usage?.totalTokens||null,reasoning_tokens:e.usage?.reasoningTokens||null,cached_input_tokens:e.usage?.cachedInputTokens||null,input_cost_usd:e.cost?.inputCostUsd?.toString()||null,output_cost_usd:e.cost?.outputCostUsd?.toString()||null,total_cost_usd:e.cost?.totalCostUsd?.toString()||null,updatedAt:a})).execute()}async appendGenerationError(e){let a=(0,r.nanoid)();return await this.db.insertInto("generation_error").values({error_id:a,generation_id:e.generationId,kind:e.kind||"error",message:e.message,code:e.code||null,stack:e.stack||null,data:t.sql`cast(${JSON.stringify(e.data||{})} as jsonb)`,createdAt:new Date}).execute(),{errorId:a}}async listThreads(e){let t=e.limit||50,r=e.offset||0,a=this.db.selectFrom("thread").selectAll().where("app_id","=",e.appId);return e.tenantId&&(a=a.where("tenant_id","=",e.tenantId)),(await a.orderBy("updatedAt","desc").limit(t).offset(r).execute()).map(e=>({threadId:e.thread_id,appId:e.app_id,tenantId:e.tenant_id,userId:e.user_id,title:e.title,createdAt:e.createdAt,updatedAt:e.updatedAt}))}async getThread(e){let t=await this.db.selectFrom("thread").selectAll().where("thread_id","=",e.threadId).where("app_id","=",e.appId).executeTakeFirst();return t?{threadId:t.thread_id,appId:t.app_id,tenantId:t.tenant_id,userId:t.user_id,title:t.title,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listGenerations(e){let r=e.limit||50,a=this.db.selectFrom("generation").leftJoin("generation_metrics","generation.generation_id","generation_metrics.generation_id").select(["generation.generation_id","generation.request_id","generation.user_id","generation.model","generation.name","generation.messages","generation.createdAt","generation.updatedAt","generation_metrics.latency_ms","generation_metrics.input_tokens","generation_metrics.output_tokens","generation_metrics.total_tokens","generation_metrics.reasoning_tokens","generation_metrics.cached_input_tokens","generation_metrics.input_cost_usd","generation_metrics.output_cost_usd","generation_metrics.total_cost_usd"]).where("generation.app_id","=",e.appId).$if(!!e.tenantId,t=>t.where("tenant_id","=",e.tenantId)).$if(!!e.threadId,t=>t.where("thread_id","=",e.threadId)).$if(!!e.requestId,t=>t.where("request_id","=",e.requestId));if(e.cursor)try{let r=Buffer.from(e.cursor,"base64").toString("utf-8"),i=r.lastIndexOf("|");if(i>0){let e=r.substring(0,i),s=r.substring(i+1);a=a.where(t.sql`("generation"."createdAt", generation_id) < (${new Date(e)}, ${s})`)}}catch{}let i=await a.orderBy("generation.createdAt","desc").orderBy("generation.generation_id","desc").limit(r+1).execute(),s=i.length>r,n=i.slice(0,r),o=null;if(s&&n.length>0){let e=n[n.length-1],t=`${e.createdAt.toISOString()}|${e.generation_id}`;o=Buffer.from(t).toString("base64")}let p=n.map(e=>e.generation_id),d=new Map;if(p.length>0)for(let e of(await this.db.selectFrom("generation_error").select(["generation_id","message"]).where("generation_id","in",p).where("kind","=","error").orderBy("createdAt","desc").execute()))d.has(e.generation_id)||d.set(e.generation_id,e.message);return{generations:n.map(e=>({generationId:e.generation_id,requestId:e.request_id,userId:e.user_id,model:e.model,name:e.name,messages:e.messages,error:d.get(e.generation_id)||null,latencyMs:e.latency_ms,inputTokens:e.input_tokens,outputTokens:e.output_tokens,totalTokens:e.total_tokens,reasoningTokens:e.reasoning_tokens,cachedInputTokens:e.cached_input_tokens,inputCostUsd:e.input_cost_usd,outputCostUsd:e.output_cost_usd,totalCostUsd:e.total_cost_usd,createdAt:e.createdAt,updatedAt:e.updatedAt})),nextCursor:o,hasMore:s}}async getGeneration(e){let t=await this.db.selectFrom("generation").leftJoin("generation_metrics","generation.generation_id","generation_metrics.generation_id").select(["generation.generation_id","generation.request_id","generation.user_id","generation.model","generation.name","generation.messages","generation.createdAt","generation.updatedAt","generation_metrics.latency_ms","generation_metrics.input_tokens","generation_metrics.output_tokens","generation_metrics.total_tokens","generation_metrics.reasoning_tokens","generation_metrics.cached_input_tokens","generation_metrics.input_cost_usd","generation_metrics.output_cost_usd","generation_metrics.total_cost_usd"]).where("generation.generation_id","=",e.generationId).where("generation.app_id","=",e.appId).executeTakeFirst();if(!t)return null;let r=await this.db.selectFrom("generation_error").select("message").where("generation_id","=",e.generationId).where("kind","=","error").orderBy("createdAt","desc").limit(1).executeTakeFirst();return{generationId:t.generation_id,requestId:t.request_id,userId:t.user_id,model:t.model,name:t.name,messages:t.messages,error:r?.message||null,latencyMs:t.latency_ms,inputTokens:t.input_tokens,outputTokens:t.output_tokens,totalTokens:t.total_tokens,reasoningTokens:t.reasoning_tokens,cachedInputTokens:t.cached_input_tokens,inputCostUsd:t.input_cost_usd,outputCostUsd:t.output_cost_usd,totalCostUsd:t.total_cost_usd,createdAt:t.createdAt,updatedAt:t.updatedAt}}async getGenerationErrors(e){return(await this.db.selectFrom("generation_error").selectAll().where("generation_id","=",e.generationId).orderBy("createdAt","asc").execute()).map(e=>({errorId:e.error_id,generationId:e.generation_id,kind:e.kind,message:e.message,code:e.code,stack:e.stack,data:e.data,createdAt:e.createdAt}))}async getGenerationErrorsByIds(e){if(0===e.generationIds.length)return new Map;let t=await this.db.selectFrom("generation_error").selectAll().where("generation_id","in",e.generationIds).orderBy("createdAt","asc").execute(),r=new Map;for(let e of t){let t={errorId:e.error_id,generationId:e.generation_id,kind:e.kind,message:e.message,code:e.code,stack:e.stack,data:e.data,createdAt:e.createdAt},a=r.get(e.generation_id)??[];a.push(t),r.set(e.generation_id,a)}return r}async getGenerationFiles(e){return(await this.db.selectFrom("generation_file").selectAll().where("generation_id","=",e.generationId).orderBy("createdAt","asc").execute()).map(e=>({fileId:e.file_id,generationId:e.generation_id,filename:e.filename,contentType:e.content_type,sizeBytes:e.size_bytes,sha256Hex:e.sha256_hex,gcsPath:e.gcs_path,createdAt:e.createdAt}))}async getGenerationFilesByIds(e){if(0===e.generationIds.length)return new Map;let t=await this.db.selectFrom("generation_file").selectAll().where("generation_id","in",e.generationIds).orderBy("createdAt","asc").execute(),r=new Map;for(let e of t){let t={fileId:e.file_id,generationId:e.generation_id,filename:e.filename,contentType:e.content_type,sizeBytes:e.size_bytes,sha256Hex:e.sha256_hex,gcsPath:e.gcs_path,createdAt:e.createdAt},a=r.get(e.generation_id)??[];a.push(t),r.set(e.generation_id,a)}return r}async getGenerationFile(e){let t=await this.db.selectFrom("generation_file").selectAll().where("file_id","=",e.fileId).where("generation_id","=",e.generationId).executeTakeFirst();return t?{fileId:t.file_id,generationId:t.generation_id,filename:t.filename,contentType:t.content_type,sizeBytes:t.size_bytes,sha256Hex:t.sha256_hex,gcsPath:t.gcs_path,createdAt:t.createdAt}:null}async listThreadsByApp(e){let r=e.limit||50,a=this.db.selectFrom("thread").selectAll().where("app_id","=",e.appId);if(e.cursor)try{let r=Buffer.from(e.cursor,"base64").toString("utf-8"),i=r.lastIndexOf("|");if(i>0){let e=r.substring(0,i),s=r.substring(i+1);a=a.where(t.sql`("updatedAt", thread_id) < (${new Date(e)}, ${s})`)}}catch{}e.filters?.tenantId&&(a=a.where("tenant_id","=",e.filters.tenantId)),e.filters?.userId&&(a=a.where("user_id","=",e.filters.userId)),e.filters?.fromDate&&(a=a.where("createdAt",">=",new Date(e.filters.fromDate))),e.filters?.toDate&&(a=a.where("createdAt","<=",new Date(e.filters.toDate)));let i=await a.orderBy("updatedAt","desc").orderBy("thread_id","desc").limit(r+1).execute(),s=i.length>r,n=i.slice(0,r),o=null;if(s&&n.length>0){let e=n[n.length-1],t=`${e.updatedAt.toISOString()}|${e.thread_id}`;o=Buffer.from(t).toString("base64")}return{threads:n.map(e=>({threadId:e.thread_id,appId:e.app_id,tenantId:e.tenant_id,userId:e.user_id,title:e.title,createdAt:e.createdAt,updatedAt:e.updatedAt})),nextCursor:o,hasMore:s}}}e.s(["PostgresLogStore",()=>a])},97836,e=>{"use strict";var t=e.i(24868),r=e.i(14747),a=e.i(7273);async function i(e){try{let r=await (0,t.readFile)(e,"utf-8");return JSON.parse(r)}catch(e){if("ENOENT"===e.code)return null;throw e}}async function s(e,i){await (0,t.mkdir)((0,r.dirname)(e),{recursive:!0});let s=`${e}.${(0,a.nanoid)()}.tmp`;await (0,t.writeFile)(s,JSON.stringify(i,null,2),"utf-8"),await (0,t.rename)(s,e)}async function n(e){try{let r=await (0,t.readFile)(e,"utf-8"),a=await (0,t.stat)(e);return{data:JSON.parse(r),createdAt:a.birthtime,updatedAt:a.mtime}}catch(e){if("ENOENT"===e.code)return null;throw e}}async function o(e){try{return(await (0,t.readdir)(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(".json")).map(e=>e.name.replace(".json",""))}catch(e){if("ENOENT"===e.code)return[];throw e}}async function p(e){try{let a=await (0,t.readdir)(e,{withFileTypes:!0}),i=[];for(let s of a){if(!s.isFile()||!s.name.endsWith(".json"))continue;let a=(0,r.join)(e,s.name),n=await (0,t.stat)(a);i.push({name:s.name.replace(".json",""),createdAt:n.birthtime})}return i}catch(e){if("ENOENT"===e.code)return[];throw e}}class d{basePath;constructor(e){this.basePath=e}getAppDir(e){return(0,r.join)(this.basePath,"apps",e)}getThreadsDir(e){return(0,r.join)(this.getAppDir(e),"threads")}getThreadPath(e,t){return(0,r.join)(this.getThreadsDir(e),`${t}.json`)}getGenerationsDir(e){return(0,r.join)(this.getAppDir(e),"generations")}getGenerationPath(e,t){return(0,r.join)(this.getGenerationsDir(e),`${t}.json`)}getGenerationsByThreadDir(e,t){return(0,r.join)(this.getAppDir(e),"generations-by-thread",t)}getGenerationByThreadPath(e,t,a){return(0,r.join)(this.getGenerationsByThreadDir(e,t),a)}getGenerationErrorsDir(e,t){return(0,r.join)(this.getAppDir(e),"generation-errors",t)}getGenerationErrorPath(e,t,a){return(0,r.join)(this.getGenerationErrorsDir(e,t),`${a}.json`)}getGenerationFilesDir(e,t){return(0,r.join)(this.getAppDir(e),"generation-files",t)}getGenerationFilePath(e,t,a){return(0,r.join)(this.getGenerationFilesDir(e,t),`${a}.json`)}async upsertThread(e){let t=this.getThreadPath(e.appId,e.threadId),r=await i(t),a={threadId:e.threadId,appId:e.appId,tenantId:e.tenantId||null,userId:e.userId,title:void 0!==e.title?e.title??null:r?.title??null};return await s(t,a),{threadId:e.threadId}}async upsertThreadByGenerationId(e){let t=await i(this.getGenerationPath(e.appId,e.generationId));t&&await this.upsertThread({threadId:t.threadId,appId:t.appId,tenantId:t.tenantId??void 0,userId:t.userId,title:e.title})}async startGeneration(e){let a={generationId:e.generationId,appId:e.appId,tenantId:e.tenantId||null,threadId:e.threadId,requestId:e.requestId,userId:e.userId,model:e.model,name:e.name||null,messages:e.messages,latencyMs:null,inputTokens:null,outputTokens:null,totalTokens:null,reasoningTokens:null,cachedInputTokens:null,inputCostUsd:null,outputCostUsd:null,totalCostUsd:null};await s(this.getGenerationPath(e.appId,e.generationId),a);let i=this.getGenerationByThreadPath(e.appId,e.threadId,e.generationId);return await (0,t.mkdir)((0,r.dirname)(i),{recursive:!0}),await (0,t.writeFile)(i,""),{generationId:e.generationId}}async endGeneration(e){let t=this.getGenerationPath(e.appId,e.generationId),r=await i(t);if(!r)return;let a=e.responseMessages&&e.responseMessages.length>0?[...r.messages,...e.responseMessages]:r.messages,n={...r,messages:a,latencyMs:e.latencyMs??r.latencyMs,inputTokens:e.usage?.inputTokens??r.inputTokens,outputTokens:e.usage?.outputTokens??r.outputTokens,totalTokens:e.usage?.totalTokens??r.totalTokens,reasoningTokens:e.usage?.reasoningTokens??r.reasoningTokens,cachedInputTokens:e.usage?.cachedInputTokens??r.cachedInputTokens,inputCostUsd:e.cost?.inputCostUsd?.toString()??r.inputCostUsd,outputCostUsd:e.cost?.outputCostUsd?.toString()??r.outputCostUsd,totalCostUsd:e.cost?.totalCostUsd?.toString()??r.totalCostUsd};await s(t,n)}async appendGenerationError(e){let t=(0,a.nanoid)(),r={errorId:t,generationId:e.generationId,kind:e.kind||"error",message:e.message,code:e.code||null,stack:e.stack||null,data:e.data||{}};return await s(this.getGenerationErrorPath(e.appId,e.generationId,t),r),{errorId:t}}async listThreads(e){let t=e.limit||50,r=e.offset||0,a=await p(this.getThreadsDir(e.appId));if(a.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),e.tenantId){let i=[],s=0;for(let o of a){let a=await n(this.getThreadPath(e.appId,o.name));if(a&&a.data.tenantId===e.tenantId){if(s<r){s++;continue}if(i.push({threadId:a.data.threadId,appId:a.data.appId,tenantId:a.data.tenantId,userId:a.data.userId,title:a.data.title,createdAt:a.createdAt,updatedAt:a.updatedAt}),i.length>=t)break}}return i}let i=a.slice(r,r+t),s=[];for(let t of i){let r=await n(this.getThreadPath(e.appId,t.name));r&&s.push({threadId:r.data.threadId,appId:r.data.appId,tenantId:r.data.tenantId,userId:r.data.userId,title:r.data.title,createdAt:r.createdAt,updatedAt:r.updatedAt})}return s}async getThread(e){let t=await n(this.getThreadPath(e.appId,e.threadId));return t?{threadId:t.data.threadId,appId:t.data.appId,tenantId:t.data.tenantId,userId:t.data.userId,title:t.data.title,createdAt:t.createdAt,updatedAt:t.updatedAt}:null}async listGenerations(e){let r,a=e.limit||50,i=e.tenantId||e.requestId;if(e.threadId){let a,i=this.getGenerationsByThreadDir(e.appId,e.threadId);try{a=(await (0,t.readdir)(i,{withFileTypes:!0})).filter(e=>e.isFile()).map(e=>e.name)}catch(e){if("ENOENT"===e.code)a=[];else throw e}let s=[];for(let r of a){let a=this.getGenerationPath(e.appId,r);try{let e=await (0,t.stat)(a);s.push({name:r,createdAt:e.birthtime})}catch{}}r=s}else r=await p(this.getGenerationsDir(e.appId));if(r.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),e.cursor)try{let t=Buffer.from(e.cursor,"base64").toString("utf-8"),a=t.lastIndexOf("|");if(a>0){let e=new Date(t.substring(0,a)),i=t.substring(a+1);r=r.filter(t=>!!(t.createdAt<e)||t.createdAt.getTime()===e.getTime()&&!!(t.name<i))}}catch{}if(i){let t=[];for(let i of r){let r=await n(this.getGenerationPath(e.appId,i.name));if(r&&(!e.tenantId||r.data.tenantId===e.tenantId)&&(!e.requestId||r.data.requestId===e.requestId)&&(t.push({generationId:r.data.generationId,requestId:r.data.requestId,userId:r.data.userId,model:r.data.model,name:r.data.name,messages:r.data.messages,error:null,latencyMs:r.data.latencyMs,inputTokens:r.data.inputTokens,outputTokens:r.data.outputTokens,totalTokens:r.data.totalTokens,reasoningTokens:r.data.reasoningTokens,cachedInputTokens:r.data.cachedInputTokens,inputCostUsd:r.data.inputCostUsd,outputCostUsd:r.data.outputCostUsd,totalCostUsd:r.data.totalCostUsd,createdAt:r.createdAt,updatedAt:r.updatedAt}),t.length>a))break}let i=t.length>a,s=t.slice(0,a),o=null;if(i&&s.length>0){let e=s[s.length-1];o=Buffer.from(`${e.createdAt.toISOString()}|${e.generationId}`).toString("base64")}return{generations:s,nextCursor:o,hasMore:i}}let s=r.length>a,o=r.slice(0,a),d=[];for(let t of o){let r=await n(this.getGenerationPath(e.appId,t.name));r&&d.push({generationId:r.data.generationId,requestId:r.data.requestId,userId:r.data.userId,model:r.data.model,name:r.data.name,messages:r.data.messages,error:null,latencyMs:r.data.latencyMs,inputTokens:r.data.inputTokens,outputTokens:r.data.outputTokens,totalTokens:r.data.totalTokens,reasoningTokens:r.data.reasoningTokens,cachedInputTokens:r.data.cachedInputTokens,inputCostUsd:r.data.inputCostUsd,outputCostUsd:r.data.outputCostUsd,totalCostUsd:r.data.totalCostUsd,createdAt:r.createdAt,updatedAt:r.updatedAt})}let l=null;if(s&&d.length>0){let e=d[d.length-1];l=Buffer.from(`${e.createdAt.toISOString()}|${e.generationId}`).toString("base64")}return{generations:d,nextCursor:l,hasMore:s}}async getGeneration(e){let t=await n(this.getGenerationPath(e.appId,e.generationId));if(!t)return null;let r=(await this.getGenerationErrors({generationId:e.generationId,appId:e.appId})).filter(e=>"error"===e.kind).pop();return{generationId:t.data.generationId,requestId:t.data.requestId,userId:t.data.userId,model:t.data.model,name:t.data.name,messages:t.data.messages,error:r?.message||null,latencyMs:t.data.latencyMs,inputTokens:t.data.inputTokens,outputTokens:t.data.outputTokens,totalTokens:t.data.totalTokens,reasoningTokens:t.data.reasoningTokens,cachedInputTokens:t.data.cachedInputTokens,inputCostUsd:t.data.inputCostUsd,outputCostUsd:t.data.outputCostUsd,totalCostUsd:t.data.totalCostUsd,createdAt:t.createdAt,updatedAt:t.updatedAt}}async getGenerationErrors(e){let t=await o(this.getGenerationErrorsDir(e.appId,e.generationId)),r=[];for(let a of t){let t=await n(this.getGenerationErrorPath(e.appId,e.generationId,a));t&&r.push({errorId:t.data.errorId,generationId:t.data.generationId,kind:t.data.kind,message:t.data.message,code:t.data.code,stack:t.data.stack,data:t.data.data,createdAt:t.createdAt})}return r.sort((e,t)=>e.createdAt.getTime()-t.createdAt.getTime()),r}async getGenerationErrorsByIds(e){let t=new Map;for(let r of e.generationIds){let a=await this.getGenerationErrors({generationId:r,appId:e.appId});t.set(r,a)}return t}async getGenerationFiles(e){let t=await o(this.getGenerationFilesDir(e.appId,e.generationId)),r=[];for(let a of t){let t=await n(this.getGenerationFilePath(e.appId,e.generationId,a));t&&r.push({fileId:t.data.fileId,generationId:t.data.generationId,filename:t.data.filename,contentType:t.data.contentType,sizeBytes:t.data.sizeBytes,sha256Hex:t.data.sha256Hex,gcsPath:t.data.gcsPath,createdAt:t.createdAt})}return r.sort((e,t)=>e.createdAt.getTime()-t.createdAt.getTime()),r}async getGenerationFilesByIds(e){let t=new Map;for(let r of e.generationIds){let a=await this.getGenerationFiles({generationId:r,appId:e.appId});t.set(r,a)}return t}async getGenerationFile(e){let t=await n(this.getGenerationFilePath(e.appId,e.generationId,e.fileId));return t?{fileId:t.data.fileId,generationId:t.data.generationId,filename:t.data.filename,contentType:t.data.contentType,sizeBytes:t.data.sizeBytes,sha256Hex:t.data.sha256Hex,gcsPath:t.data.gcsPath,createdAt:t.createdAt}:null}async listThreadsByApp(e){let t=e.limit||50,r=e.filters?.tenantId||e.filters?.userId||e.filters?.fromDate||e.filters?.toDate,a=await p(this.getThreadsDir(e.appId));if(a.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),e.cursor)try{let t=Buffer.from(e.cursor,"base64").toString("utf-8"),r=t.lastIndexOf("|");if(r>0){let e=new Date(t.substring(0,r)),i=t.substring(r+1);a=a.filter(t=>!!(t.createdAt<e)||t.createdAt.getTime()===e.getTime()&&!!(t.name<i))}}catch{}if(r){let r=[];for(let i of a){let a=await n(this.getThreadPath(e.appId,i.name));if(!(!a||e.filters?.tenantId&&a.data.tenantId!==e.filters.tenantId||e.filters?.userId&&a.data.userId!==e.filters.userId||e.filters?.fromDate&&a.createdAt<new Date(e.filters.fromDate))&&!(e.filters?.toDate&&a.createdAt>new Date(e.filters.toDate))&&(r.push({threadId:a.data.threadId,appId:a.data.appId,tenantId:a.data.tenantId,userId:a.data.userId,title:a.data.title,createdAt:a.createdAt,updatedAt:a.updatedAt}),r.length>t))break}let i=r.length>t,s=r.slice(0,t),o=null;if(i&&s.length>0){let e=s[s.length-1];o=Buffer.from(`${e.createdAt.toISOString()}|${e.threadId}`).toString("base64")}return{threads:s,nextCursor:o,hasMore:i}}let i=a.length>t,s=a.slice(0,t),o=[];for(let t of s){let r=await n(this.getThreadPath(e.appId,t.name));r&&o.push({threadId:r.data.threadId,appId:r.data.appId,tenantId:r.data.tenantId,userId:r.data.userId,title:r.data.title,createdAt:r.createdAt,updatedAt:r.updatedAt})}let d=null;if(i&&o.length>0){let e=o[o.length-1];d=Buffer.from(`${e.createdAt.toISOString()}|${e.threadId}`).toString("base64")}return{threads:o,nextCursor:d,hasMore:i}}}e.s(["LocalLogStore",()=>d])},51e3,e=>{"use strict";e.i(55340),e.i(97836),e.s([])},95678,e=>e.a(async(t,r)=>{try{var a=e.i(14281),i=e.i(96401);e.i(54906);var s=e.i(13932),n=e.i(69855);e.i(37893);var o=e.i(59613),p=e.i(36553);e.i(51e3);var d=e.i(97836),l=e.i(55340),c=t([a]);[a]=c.then?(await c)():c;let u="local"===i.resolvedStoreTypes.log?new d.LocalLogStore(i.config.paths.localStore):new l.PostgresLogStore(a.db),h="local"===i.resolvedStoreTypes.app?new s.LocalAppStore(i.config.paths.localStore,i.config.serverPepper):new n.PostgresAppStore(a.db,i.config.serverPepper),m=function(){if("local"===i.resolvedStoreTypes.blob)return new p.LocalBlobStore(i.config.paths.blobStore,i.config.paths.localStore);let e=i.config.gcs.bucketName;if(!e)throw Error("GCS_BUCKET_NAME environment variable is required when BLOB_STORE_TYPE is gcs");return new o.GCSBlobStore(a.db,e)}();e.s(["appStore",0,h,"blobStore",0,m,"logStore",0,u]),r()}catch(e){r(e)}},!1),53163,e=>{"use strict";var t=e.i(16172);let r=t.z.union([t.z.string(),t.z.custom(e=>e instanceof Uint8Array),t.z.custom(e=>e instanceof ArrayBuffer),t.z.custom(e=>e instanceof URL)]),a=t.z.object({type:t.z.literal("text"),text:t.z.string()}),i=t.z.object({type:t.z.literal("image"),image:r,mediaType:t.z.string().optional()}),s=t.z.object({type:t.z.literal("file"),data:r,filename:t.z.string().optional(),mediaType:t.z.string()}),n=t.z.object({type:t.z.literal("reasoning"),text:t.z.string()}),o=t.z.object({type:t.z.literal("tool-call"),toolCallId:t.z.string(),toolName:t.z.string(),input:t.z.unknown()}),p=t.z.object({type:t.z.literal("tool-result"),toolCallId:t.z.string(),toolName:t.z.string(),output:t.z.unknown()}),d=t.z.object({role:t.z.literal("system"),content:t.z.string()}),l=t.z.object({role:t.z.literal("user"),content:t.z.union([t.z.string(),t.z.array(t.z.union([a,i,s]))])}),c=t.z.object({role:t.z.literal("assistant"),content:t.z.union([t.z.string(),t.z.array(t.z.union([a,s,n,o,p]))]).nullable()}),u=t.z.object({role:t.z.literal("tool"),content:t.z.array(p)}),h=t.z.discriminatedUnion("role",[d,l,c,u]);e.s(["ModelMessageSchema",0,h])},16516,e=>{"use strict";var t=e.i(16172),r=e.i(53163);let a=t.z.object({tenantId:t.z.string().optional(),threadId:t.z.string(),userId:t.z.string(),title:t.z.string().optional()});t.z.object({threadId:t.z.string()});let i=t.z.object({tenantId:t.z.string().optional(),threadId:t.z.string(),requestId:t.z.string(),generationId:t.z.string(),userId:t.z.string(),model:t.z.string(),name:t.z.string().optional(),messages:t.z.array(r.ModelMessageSchema),threadTitle:t.z.string().optional()});t.z.object({generationId:t.z.string()});let s=t.z.object({generationId:t.z.string(),responseMessages:t.z.array(r.ModelMessageSchema).optional(),latencyMs:t.z.number().optional(),usage:t.z.object({inputTokens:t.z.number().optional(),outputTokens:t.z.number().optional(),totalTokens:t.z.number().optional(),reasoningTokens:t.z.number().optional(),cachedInputTokens:t.z.number().optional()}).optional(),cost:t.z.object({inputCostUsd:t.z.number().optional(),outputCostUsd:t.z.number().optional(),totalCostUsd:t.z.number().optional()}).optional(),threadTitle:t.z.string().optional()});t.z.object({generationId:t.z.string()});let n=t.z.object({kind:t.z.enum(["error","warning","retry","tool_error"]).optional(),message:t.z.string(),code:t.z.string().optional(),stack:t.z.string().optional(),data:t.z.record(t.z.unknown()).optional()});t.z.object({errorId:t.z.string()}),t.z.object({fileId:t.z.string()});let o=t.z.object({generationId:t.z.string(),kind:t.z.enum(["error","warning","retry","tool_error"]).optional(),message:t.z.string(),code:t.z.string().optional(),stack:t.z.string().optional(),data:t.z.record(t.z.unknown()).optional()}),p=t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("generation_start"),data:i}),t.z.object({type:t.z.literal("generation_end"),data:s}),t.z.object({type:t.z.literal("generation_error"),data:o})]),d=t.z.object({operations:t.z.array(p)}),l=t.z.object({success:t.z.boolean(),generationId:t.z.string().optional(),errorId:t.z.string().optional(),error:t.z.string().optional()});t.z.object({results:t.z.array(l)}),e.s(["BatchRequestSchema",0,d,"GenerationEndRequestSchema",0,s,"GenerationErrorRequestSchema",0,n,"GenerationStartRequestSchema",0,i,"ThreadUpsertRequestSchema",0,a])},5941,e=>{"use strict";let t="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,r=new Set,a="object"==typeof process&&process?process:{},i=(e,t,r,i)=>{"function"==typeof a.emitWarning?a.emitWarning(e,t,r,i):console.error(`[${r}] ${t}: ${e}`)},s=globalThis.AbortController,n=globalThis.AbortSignal;if(void 0===s){n=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},s=class{constructor(){t()}signal=new n;abort(e){if(!this.signal.aborted){for(let t of(this.signal.reason=e,this.signal.aborted=!0,this.signal._onabort))t(e);this.signal.onabort?.(e)}}};let e=a.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,i("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");let o=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),p=e=>o(e)?e<=256?Uint8Array:e<=65536?Uint16Array:e<=0x100000000?Uint32Array:e<=Number.MAX_SAFE_INTEGER?d:null:null;class d extends Array{constructor(e){super(e),this.fill(0)}}class l{heap;length;static #eG=!1;static create(e){let t=p(e);if(!t)return[];l.#eG=!0;let r=new l(e,t);return l.#eG=!1,r}constructor(e,t){if(!l.#eG)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class c{#eH;#eK;#eJ;#eZ;#eQ;#eY;#eX;#e1;get perf(){return this.#e1}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#e0;#e2;#e6;#e4;#e3;#e9;#e5;#e8;#e7;#te;#tt;#tr;#ta;#ti;#ts;#tn;#to;#tp;#td;static unsafeExposeInternals(e){return{starts:e.#ta,ttls:e.#ti,autopurgeTimers:e.#ts,sizes:e.#tr,keyMap:e.#e6,keyList:e.#e4,valList:e.#e3,next:e.#e9,prev:e.#e5,get head(){return e.#e8},get tail(){return e.#e7},free:e.#te,isBackgroundFetch:t=>e.#tl(t),backgroundFetch:(t,r,a,i)=>e.#tc(t,r,a,i),moveToTail:t=>e.#tu(t),indexes:t=>e.#th(t),rindexes:t=>e.#tm(t),isStale:t=>e.#tf(t)}}get max(){return this.#eH}get maxSize(){return this.#eK}get calculatedSize(){return this.#e2}get size(){return this.#e0}get fetchMethod(){return this.#eY}get memoMethod(){return this.#eX}get dispose(){return this.#eJ}get onInsert(){return this.#eZ}get disposeAfter(){return this.#eQ}constructor(e){const{max:a=0,ttl:s,ttlResolution:n=1,ttlAutopurge:d,updateAgeOnGet:u,updateAgeOnHas:h,allowStale:m,dispose:f,onInsert:g,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:w,maxSize:b=0,maxEntrySize:_=0,sizeCalculation:x,fetchMethod:N,memoMethod:T,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:k,ignoreFetchAbort:O,perf:C}=e;if(void 0!==C&&"function"!=typeof C?.now)throw TypeError("perf option must have a now() method if specified");if(this.#e1=C??t,0!==a&&!o(a))throw TypeError("max option must be a nonnegative integer");const I=a?p(a):Array;if(!I)throw Error("invalid max value: "+a);if(this.#eH=a,this.#eK=b,this.maxEntrySize=_||this.#eK,this.sizeCalculation=x,this.sizeCalculation){if(!this.#eK&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw TypeError("sizeCalculation set to non-function")}if(void 0!==T&&"function"!=typeof T)throw TypeError("memoMethod must be a function if defined");if(this.#eX=T,void 0!==N&&"function"!=typeof N)throw TypeError("fetchMethod must be a function if specified");if(this.#eY=N,this.#to=!!N,this.#e6=new Map,this.#e4=Array(a).fill(void 0),this.#e3=Array(a).fill(void 0),this.#e9=new I(a),this.#e5=new I(a),this.#e8=0,this.#e7=0,this.#te=l.create(a),this.#e0=0,this.#e2=0,"function"==typeof f&&(this.#eJ=f),"function"==typeof g&&(this.#eZ=g),"function"==typeof v?(this.#eQ=v,this.#tt=[]):(this.#eQ=void 0,this.#tt=void 0),this.#tn=!!this.#eJ,this.#td=!!this.#eZ,this.#tp=!!this.#eQ,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!k,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#eK&&!o(this.#eK))throw TypeError("maxSize must be a positive integer if specified");if(!o(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#tg()}if(this.allowStale=!!m,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!u,this.updateAgeOnHas=!!h,this.ttlResolution=o(n)||0===n?n:1,this.ttlAutopurge=!!d,this.ttl=s||0,this.ttl){if(!o(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#tv()}if(0===this.#eH&&0===this.ttl&&0===this.#eK)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#eH&&!this.#eK){const e="LRU_CACHE_UNBOUNDED";r.has(e)||(r.add(e),i("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,c))}}getRemainingTTL(e){return this.#e6.has(e)?1/0:0}#tv(){let e=new d(this.#eH),t=new d(this.#eH);this.#ti=e,this.#ta=t;let r=this.ttlAutopurge?Array(this.#eH):void 0;this.#ts=r,this.#ty=(a,i,s=this.#e1.now())=>{if(t[a]=0!==i?s:0,e[a]=i,r?.[a]&&(clearTimeout(r[a]),r[a]=void 0),0!==i&&r){let e=setTimeout(()=>{this.#tf(a)&&this.#tw(this.#e4[a],"expire")},i+1);e.unref&&e.unref(),r[a]=e}},this.#tb=r=>{t[r]=0!==e[r]?this.#e1.now():0},this.#t_=(r,s)=>{if(e[s]){let n=e[s],o=t[s];if(!n||!o)return;r.ttl=n,r.start=o,r.now=a||i();let p=r.now-o;r.remainingTTL=n-p}};let a=0,i=()=>{let e=this.#e1.now();if(this.ttlResolution>0){a=e;let t=setTimeout(()=>a=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=r=>{let s=this.#e6.get(r);if(void 0===s)return 0;let n=e[s],o=t[s];return n&&o?n-((a||i())-o):1/0},this.#tf=r=>{let s=t[r],n=e[r];return!!n&&!!s&&(a||i())-s>n}}#tb=()=>{};#t_=()=>{};#ty=()=>{};#tf=()=>!1;#tg(){let e=new d(this.#eH);this.#e2=0,this.#tr=e,this.#tx=t=>{this.#e2-=e[t],e[t]=0},this.#tN=(e,t,r,a)=>{if(this.#tl(t))return 0;if(!o(r))if(a){if("function"!=typeof a)throw TypeError("sizeCalculation must be a function");if(!o(r=a(t,e)))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#tT=(t,r,a)=>{if(e[t]=r,this.#eK){let r=this.#eK-e[t];for(;this.#e2>r;)this.#tE(!0)}this.#e2+=e[t],a&&(a.entrySize=r,a.totalCalculatedSize=this.#e2)}}#tx=e=>{};#tT=(e,t,r)=>{};#tN=(e,t,r,a)=>{if(r||a)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#th({allowStale:e=this.allowStale}={}){if(this.#e0)for(let t=this.#e7;this.#tA(t)&&((e||!this.#tf(t))&&(yield t),t!==this.#e8);)t=this.#e5[t]}*#tm({allowStale:e=this.allowStale}={}){if(this.#e0)for(let t=this.#e8;this.#tA(t)&&((e||!this.#tf(t))&&(yield t),t!==this.#e7);)t=this.#e9[t]}#tA(e){return void 0!==e&&this.#e6.get(this.#e4[e])===e}*entries(){for(let e of this.#th())void 0===this.#e3[e]||void 0===this.#e4[e]||this.#tl(this.#e3[e])||(yield[this.#e4[e],this.#e3[e]])}*rentries(){for(let e of this.#tm())void 0===this.#e3[e]||void 0===this.#e4[e]||this.#tl(this.#e3[e])||(yield[this.#e4[e],this.#e3[e]])}*keys(){for(let e of this.#th()){let t=this.#e4[e];void 0===t||this.#tl(this.#e3[e])||(yield t)}}*rkeys(){for(let e of this.#tm()){let t=this.#e4[e];void 0===t||this.#tl(this.#e3[e])||(yield t)}}*values(){for(let e of this.#th())void 0===this.#e3[e]||this.#tl(this.#e3[e])||(yield this.#e3[e])}*rvalues(){for(let e of this.#tm())void 0===this.#e3[e]||this.#tl(this.#e3[e])||(yield this.#e3[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#th()){let a=this.#e3[r],i=this.#tl(a)?a.__staleWhileFetching:a;if(void 0!==i&&e(i,this.#e4[r],this))return this.get(this.#e4[r],t)}}forEach(e,t=this){for(let r of this.#th()){let a=this.#e3[r],i=this.#tl(a)?a.__staleWhileFetching:a;void 0!==i&&e.call(t,i,this.#e4[r],this)}}rforEach(e,t=this){for(let r of this.#tm()){let a=this.#e3[r],i=this.#tl(a)?a.__staleWhileFetching:a;void 0!==i&&e.call(t,i,this.#e4[r],this)}}purgeStale(){let e=!1;for(let t of this.#tm({allowStale:!0}))this.#tf(t)&&(this.#tw(this.#e4[t],"expire"),e=!0);return e}info(e){let t=this.#e6.get(e);if(void 0===t)return;let r=this.#e3[t],a=this.#tl(r)?r.__staleWhileFetching:r;if(void 0===a)return;let i={value:a};if(this.#ti&&this.#ta){let e=this.#ti[t],r=this.#ta[t];e&&r&&(i.ttl=e-(this.#e1.now()-r),i.start=Date.now())}return this.#tr&&(i.size=this.#tr[t]),i}dump(){let e=[];for(let t of this.#th({allowStale:!0})){let r=this.#e4[t],a=this.#e3[t],i=this.#tl(a)?a.__staleWhileFetching:a;if(void 0===i||void 0===r)continue;let s={value:i};if(this.#ti&&this.#ta){s.ttl=this.#ti[t];let e=this.#e1.now()-this.#ta[t];s.start=Math.floor(Date.now()-e)}this.#tr&&(s.size=this.#tr[t]),e.unshift([r,s])}return e}load(e){for(let[t,r]of(this.clear(),e)){if(r.start){let e=Date.now()-r.start;r.start=this.#e1.now()-e}this.set(t,r.value,r)}}set(e,t,r={}){if(void 0===t)return this.delete(e),this;let{ttl:a=this.ttl,start:i,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:n=this.sizeCalculation,status:o}=r,{noUpdateTTL:p=this.noUpdateTTL}=r,d=this.#tN(e,t,r.size||0,n);if(this.maxEntrySize&&d>this.maxEntrySize)return o&&(o.set="miss",o.maxEntrySizeExceeded=!0),this.#tw(e,"set"),this;let l=0===this.#e0?void 0:this.#e6.get(e);if(void 0===l)l=0===this.#e0?this.#e7:0!==this.#te.length?this.#te.pop():this.#e0===this.#eH?this.#tE(!1):this.#e0,this.#e4[l]=e,this.#e3[l]=t,this.#e6.set(e,l),this.#e9[this.#e7]=l,this.#e5[l]=this.#e7,this.#e7=l,this.#e0++,this.#tT(l,d,o),o&&(o.set="add"),p=!1,this.#td&&this.#eZ?.(t,e,"add");else{this.#tu(l);let r=this.#e3[l];if(t!==r){if(this.#to&&this.#tl(r)){r.__abortController.abort(Error("replaced"));let{__staleWhileFetching:t}=r;void 0!==t&&!s&&(this.#tn&&this.#eJ?.(t,e,"set"),this.#tp&&this.#tt?.push([t,e,"set"]))}else!s&&(this.#tn&&this.#eJ?.(r,e,"set"),this.#tp&&this.#tt?.push([r,e,"set"]));if(this.#tx(l),this.#tT(l,d,o),this.#e3[l]=t,o){o.set="replace";let e=r&&this.#tl(r)?r.__staleWhileFetching:r;void 0!==e&&(o.oldValue=e)}}else o&&(o.set="update");this.#td&&this.onInsert?.(t,e,t===r?"update":"replace")}if(0===a||this.#ti||this.#tv(),this.#ti&&(p||this.#ty(l,a,i),o&&this.#t_(o,l)),!s&&this.#tp&&this.#tt){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}return this}pop(){try{for(;this.#e0;){let e=this.#e3[this.#e8];if(this.#tE(!0),this.#tl(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#tp&&this.#tt){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}}}#tE(e){let t=this.#e8,r=this.#e4[t],a=this.#e3[t];return this.#to&&this.#tl(a)?a.__abortController.abort(Error("evicted")):(this.#tn||this.#tp)&&(this.#tn&&this.#eJ?.(a,r,"evict"),this.#tp&&this.#tt?.push([a,r,"evict"])),this.#tx(t),this.#ts?.[t]&&(clearTimeout(this.#ts[t]),this.#ts[t]=void 0),e&&(this.#e4[t]=void 0,this.#e3[t]=void 0,this.#te.push(t)),1===this.#e0?(this.#e8=this.#e7=0,this.#te.length=0):this.#e8=this.#e9[t],this.#e6.delete(r),this.#e0--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:a}=t,i=this.#e6.get(e);if(void 0!==i){let e=this.#e3[i];if(this.#tl(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#tf(i))return r&&this.#tb(i),a&&(a.has="hit",this.#t_(a,i)),!0;a&&(a.has="stale",this.#t_(a,i))}else a&&(a.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,a=this.#e6.get(e);if(void 0===a||!r&&this.#tf(a))return;let i=this.#e3[a];return this.#tl(i)?i.__staleWhileFetching:i}#tc(e,t,r,a){let i=void 0===t?void 0:this.#e3[t];if(this.#tl(i))return i;let n=new s,{signal:o}=r;o?.addEventListener("abort",()=>n.abort(o.reason),{signal:n.signal});let p={signal:n.signal,options:r,context:a},d=(a,i=!1)=>{let{aborted:s}=n.signal,o=r.ignoreFetchAbort&&void 0!==a;if(r.status&&(s&&!i?(r.status.fetchAborted=!0,r.status.fetchError=n.signal.reason,o&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),s&&!o&&!i)return l(n.signal.reason);let d=this.#e3[t];return(d===u||o&&i&&void 0===d)&&(void 0===a?void 0!==u.__staleWhileFetching?this.#e3[t]=u.__staleWhileFetching:this.#tw(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,a,p.options))),a},l=a=>{let{aborted:i}=n.signal,s=i&&r.allowStaleOnFetchAbort,o=s||r.allowStaleOnFetchRejection,p=o||r.noDeleteOnFetchRejection;if(this.#e3[t]===u&&(p&&void 0!==u.__staleWhileFetching?s||(this.#e3[t]=u.__staleWhileFetching):this.#tw(e,"fetch")),o)return r.status&&void 0!==u.__staleWhileFetching&&(r.status.returnedStale=!0),u.__staleWhileFetching;if(u.__returned===u)throw a},c=(t,a)=>{let s=this.#eY?.(e,i,p);s&&s instanceof Promise&&s.then(e=>t(void 0===e?void 0:e),a),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>d(e,!0)))})};r.status&&(r.status.fetchDispatched=!0);let u=new Promise(c).then(d,e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),l(e))),h=Object.assign(u,{__abortController:n,__staleWhileFetching:i,__returned:void 0});return void 0===t?(this.set(e,h,{...p.options,status:void 0}),t=this.#e6.get(e)):this.#e3[t]=h,h}#tl(e){return!!this.#to&&!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof s}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:n=this.noDisposeOnSet,size:o=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:c=this.allowStaleOnFetchRejection,ignoreFetchAbort:u=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:m,forceRefresh:f=!1,status:g,signal:v}=t;if(!this.#to)return g&&(g.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:i,status:g});let y={allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:i,ttl:s,noDisposeOnSet:n,size:o,sizeCalculation:p,noUpdateTTL:d,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:h,ignoreFetchAbort:u,status:g,signal:v},w=this.#e6.get(e);if(void 0===w){g&&(g.fetch="miss");let t=this.#tc(e,w,y,m);return t.__returned=t}{let t=this.#e3[w];if(this.#tl(t)){let e=r&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#tf(w);if(!f&&!i)return g&&(g.fetch="hit"),this.#tu(w),a&&this.#tb(w),g&&this.#t_(g,w),t;let s=this.#tc(e,w,y,m),n=void 0!==s.__staleWhileFetching&&r;return g&&(g.fetch=i?"stale":"refresh",n&&i&&(g.returnedStale=!0)),n?s.__staleWhileFetching:s.__returned=s}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(void 0===r)throw Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#eX;if(!r)throw Error("no memoMethod provided to constructor");let{context:a,forceRefresh:i,...s}=t,n=this.get(e,s);if(!i&&void 0!==n)return n;let o=r(e,n,{options:s,context:a});return this.set(e,o,s),o}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:s}=t,n=this.#e6.get(e);if(void 0!==n){let t=this.#e3[n],o=this.#tl(t);return(s&&this.#t_(s,n),this.#tf(n))?(s&&(s.get="stale"),o)?(s&&r&&void 0!==t.__staleWhileFetching&&(s.returnedStale=!0),r?t.__staleWhileFetching:void 0):(i||this.#tw(e,"expire"),s&&r&&(s.returnedStale=!0),r?t:void 0):(s&&(s.get="hit"),o)?t.__staleWhileFetching:(this.#tu(n),a&&this.#tb(n),t)}s&&(s.get="miss")}#tS(e,t){this.#e5[t]=e,this.#e9[e]=t}#tu(e){e!==this.#e7&&(e===this.#e8?this.#e8=this.#e9[e]:this.#tS(this.#e5[e],this.#e9[e]),this.#tS(this.#e7,e),this.#e7=e)}delete(e){return this.#tw(e,"delete")}#tw(e,t){let r=!1;if(0!==this.#e0){let a=this.#e6.get(e);if(void 0!==a)if(this.#ts?.[a]&&(clearTimeout(this.#ts?.[a]),this.#ts[a]=void 0),r=!0,1===this.#e0)this.#tk(t);else{this.#tx(a);let r=this.#e3[a];if(this.#tl(r)?r.__abortController.abort(Error("deleted")):(this.#tn||this.#tp)&&(this.#tn&&this.#eJ?.(r,e,t),this.#tp&&this.#tt?.push([r,e,t])),this.#e6.delete(e),this.#e4[a]=void 0,this.#e3[a]=void 0,a===this.#e7)this.#e7=this.#e5[a];else if(a===this.#e8)this.#e8=this.#e9[a];else{let e=this.#e5[a];this.#e9[e]=this.#e9[a];let t=this.#e9[a];this.#e5[t]=this.#e5[a]}this.#e0--,this.#te.push(a)}}if(this.#tp&&this.#tt?.length){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}return r}clear(){return this.#tk("delete")}#tk(e){for(let t of this.#tm({allowStale:!0})){let r=this.#e3[t];if(this.#tl(r))r.__abortController.abort(Error("deleted"));else{let a=this.#e4[t];this.#tn&&this.#eJ?.(r,a,e),this.#tp&&this.#tt?.push([r,a,e])}}if(this.#e6.clear(),this.#e3.fill(void 0),this.#e4.fill(void 0),this.#ti&&this.#ta){for(let e of(this.#ti.fill(0),this.#ta.fill(0),this.#ts??[]))void 0!==e&&clearTimeout(e);this.#ts?.fill(void 0)}if(this.#tr&&this.#tr.fill(0),this.#e8=0,this.#e7=0,this.#te.length=0,this.#e2=0,this.#e0=0,this.#tp&&this.#tt){let e,t=this.#tt;for(;e=t?.shift();)this.#eQ?.(...e)}}}let u=new c({max:1e3,ttl:3e5});function h(e){return async(t,r)=>{let a=t.req.header("Authorization"),i=t.req.header("X-API-Key"),s=null;if(a?.startsWith("Bearer ")?s=a.substring(7):i&&(s=i),!s)return t.json({error:"Missing API key"},401);let n=u.get(s);if(n){t.set("auth",n),await r();return}let o=await e.verifyApiKey(s);return o?o.scopes.includes("log:write")?void(u.set(s,o),t.set("auth",o),await r()):t.json({error:"Insufficient permissions"},403):t.json({error:"Invalid or revoked API key"},401)}}e.s(["createAuthMiddleware",()=>h],5941)},17016,e=>{"use strict";function t(e){return async(t,r)=>{let a=t.req.header("X-App")||"default",i={keyId:"standalone",appId:(await e.getOrCreateAppByName(a)).appId,scopes:["log:write"]};t.set("auth",i),await r()}}e.s(["createStandaloneAuthMiddleware",()=>t])},23802,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(96401),n=e.i(95678),o=e.i(16516),p=e.i(5941),d=e.i(17016),l=t([n]);[n]=l.then?(await l)():l;let c=s.config.standaloneMode?(0,d.createStandaloneAuthMiddleware)(n.appStore):(0,p.createAuthMiddleware)(n.appStore),u=new a.Hono().use(c).post("/thread",(0,i.zValidator)("json",o.ThreadUpsertRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth");await n.logStore.upsertThread({threadId:t.threadId,appId:r.appId,tenantId:t.tenantId,userId:t.userId,title:t.title});let a={threadId:t.threadId};return e.json(a)}).post("/generation/start",(0,i.zValidator)("json",o.GenerationStartRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth");await n.logStore.upsertThread({threadId:t.threadId,appId:r.appId,tenantId:t.tenantId,userId:t.userId,title:t.threadTitle});let{generationId:a}=await n.logStore.startGeneration({generationId:t.generationId,appId:r.appId,tenantId:t.tenantId,threadId:t.threadId,requestId:t.requestId,userId:t.userId,model:t.model,name:t.name,messages:t.messages});return e.json({generationId:a})}).post("/generation/end",(0,i.zValidator)("json",o.GenerationEndRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth");await n.logStore.endGeneration({appId:r.appId,generationId:t.generationId,responseMessages:t.responseMessages,latencyMs:t.latencyMs,usage:t.usage,cost:t.cost}),t.threadTitle&&await n.logStore.upsertThreadByGenerationId({appId:r.appId,generationId:t.generationId,title:t.threadTitle});let a={generationId:t.generationId};return e.json(a)}).post("/generation/:generationId/error",(0,i.zValidator)("json",o.GenerationErrorRequestSchema),async e=>{let t=e.req.param("generationId"),r=e.req.valid("json"),a=e.get("auth"),i={errorId:(await n.logStore.appendGenerationError({appId:a.appId,generationId:t,kind:r.kind,message:r.message,code:r.code,stack:r.stack,data:r.data})).errorId};return e.json(i)}).post("/generation/:generationId/file",async e=>{let t=e.req.param("generationId"),r=e.get("auth"),a=await e.req.formData(),i=a.get("file"),s=a.get("filename"),o=a.get("contentType");if(!i||!s||!o)return e.json({error:"Missing required fields: file, filename, contentType"},400);if(i.size>0xa00000)return e.json({error:"File too large. Maximum size is 10MB"},413);let p=await i.arrayBuffer(),d=Buffer.from(p),{fileId:l}=await n.blobStore.saveGenerationFile({appId:r.appId,generationId:t,filename:s,contentType:o,content:d});return e.json({fileId:l})}).post("/batch",(0,i.zValidator)("json",o.BatchRequestSchema),async e=>{let t=e.req.valid("json"),r=e.get("auth"),a=[];for(let e of t.operations)try{switch(e.type){case"generation_start":{let t=e.data;await n.logStore.upsertThread({threadId:t.threadId,appId:r.appId,tenantId:t.tenantId,userId:t.userId,title:t.threadTitle});let{generationId:i}=await n.logStore.startGeneration({generationId:t.generationId,appId:r.appId,tenantId:t.tenantId,threadId:t.threadId,requestId:t.requestId,userId:t.userId,model:t.model,name:t.name,messages:t.messages});a.push({success:!0,generationId:i});break}case"generation_end":{let t=e.data;await n.logStore.endGeneration({appId:r.appId,generationId:t.generationId,responseMessages:t.responseMessages,latencyMs:t.latencyMs,usage:t.usage,cost:t.cost}),t.threadTitle&&await n.logStore.upsertThreadByGenerationId({appId:r.appId,generationId:t.generationId,title:t.threadTitle}),a.push({success:!0,generationId:t.generationId});break}case"generation_error":{let t=e.data,i=await n.logStore.appendGenerationError({appId:r.appId,generationId:t.generationId,kind:t.kind,message:t.message,code:t.code,stack:t.stack,data:t.data});a.push({success:!0,errorId:i.errorId})}}}catch(e){a.push({success:!1,error:e instanceof Error?e.message:"Unknown error"})}return e.json({results:a})});e.s(["collectRoutes",0,u]),r()}catch(e){r(e)}},!1),99030,e=>{"use strict";var t=e.i(16172),r=e.i(53163);let a=t.z.object({name:t.z.string(),metadata:t.z.record(t.z.unknown()).optional()}),i=t.z.object({name:t.z.string().optional(),metadata:t.z.record(t.z.unknown()).optional()});t.z.object({appId:t.z.string(),name:t.z.string(),metadata:t.z.record(t.z.unknown()),createdAt:t.z.string(),updatedAt:t.z.string()});let s=t.z.object({threadId:t.z.string(),tenantId:t.z.string().nullable(),userId:t.z.string(),title:t.z.string().nullable(),createdAt:t.z.string(),updatedAt:t.z.string()});t.z.object({threads:t.z.array(s),nextCursor:t.z.string().nullable(),hasMore:t.z.boolean()});let n=t.z.object({generationId:t.z.string(),requestId:t.z.string(),userId:t.z.string(),model:t.z.string(),name:t.z.string().nullable(),messages:t.z.array(r.ModelMessageSchema),error:t.z.string().nullable(),latencyMs:t.z.number().nullable(),usage:t.z.object({inputTokens:t.z.number().nullable(),outputTokens:t.z.number().nullable(),totalTokens:t.z.number().nullable(),reasoningTokens:t.z.number().nullable(),cachedInputTokens:t.z.number().nullable()}).nullable(),cost:t.z.object({inputCostUsd:t.z.number().nullable(),outputCostUsd:t.z.number().nullable(),totalCostUsd:t.z.number().nullable()}).nullable(),metadata:t.z.record(t.z.unknown()),createdAt:t.z.string(),updatedAt:t.z.string()}),o=t.z.object({errorId:t.z.string(),generationId:t.z.string(),kind:t.z.string(),message:t.z.string(),code:t.z.string().nullable(),stack:t.z.string().nullable(),data:t.z.record(t.z.unknown()).nullable(),createdAt:t.z.string()}),p=t.z.object({fileId:t.z.string(),generationId:t.z.string(),filename:t.z.string(),contentType:t.z.string(),sizeBytes:t.z.string(),sha256Hex:t.z.string(),gcsPath:t.z.string(),createdAt:t.z.string()});n.extend({errors:t.z.array(o),files:t.z.array(p)});let d=t.z.object({name:t.z.string(),scopes:t.z.array(t.z.string()),metadata:t.z.record(t.z.unknown()).optional()});t.z.object({keyId:t.z.string(),keyPrefix:t.z.string(),appId:t.z.string(),name:t.z.string(),scopes:t.z.array(t.z.string()),lastUsedAt:t.z.string().nullable(),revokedAt:t.z.string().nullable(),createdAt:t.z.string()}),t.z.object({keyId:t.z.string(),keyPrefix:t.z.string(),apiKey:t.z.string()}),e.s(["CreateApiKeyRequestSchema",0,d,"CreateAppRequestSchema",0,a,"UpdateAppRequestSchema",0,i])},9253,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(95678),n=e.i(99030),o=t([s]);[s]=o.then?(await o)():o;let p=new a.Hono().post("/apps",(0,i.zValidator)("json",n.CreateAppRequestSchema),async e=>{let t=e.req.valid("json"),r=await s.appStore.createApp({name:t.name,metadata:t.metadata}),a={appId:r.appId,name:r.name,metadata:r.metadata,createdAt:r.createdAt.toISOString(),updatedAt:r.updatedAt.toISOString()};return e.json(a,201)}).get("/apps",async e=>{let t=e.req.query("limit")?parseInt(e.req.query("limit")):50,r=e.req.query("offset")?parseInt(e.req.query("offset")):0,a=(await s.appStore.listApps({limit:t,offset:r})).map(e=>({appId:e.appId,name:e.name,metadata:e.metadata,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()}));return e.json({apps:a})}).get("/apps/:appId",async e=>{let t=e.req.param("appId"),r=await s.appStore.getApp(t);if(!r)return e.json({error:"App not found"},404);let a={appId:r.appId,name:r.name,metadata:r.metadata,createdAt:r.createdAt.toISOString(),updatedAt:r.updatedAt.toISOString()};return e.json(a)}).put("/apps/:appId",(0,i.zValidator)("json",n.UpdateAppRequestSchema),async e=>{let t=e.req.param("appId"),r=e.req.valid("json"),a=await s.appStore.updateApp({appId:t,name:r.name,metadata:r.metadata});if(!a)return e.json({error:"App not found"},404);let i={appId:a.appId,name:a.name,metadata:a.metadata,createdAt:a.createdAt.toISOString(),updatedAt:a.updatedAt.toISOString()};return e.json(i)}).delete("/apps/:appId",async e=>{let t=e.req.param("appId");return await s.appStore.deleteApp(t),e.json({success:!0})}).get("/apps/:appId/api-keys",async e=>{let t=e.req.param("appId"),r=(await s.appStore.listApiKeys({appId:t})).map(e=>({keyId:e.keyId,keyPrefix:e.keyPrefix,appId:e.appId,name:e.name,scopes:e.scopes,lastUsedAt:e.lastUsedAt?.toISOString()??null,revokedAt:e.revokedAt?.toISOString()??null,createdAt:e.createdAt.toISOString()}));return e.json({keys:r})}).post("/apps/:appId/api-keys",(0,i.zValidator)("json",n.CreateApiKeyRequestSchema),async e=>{let t=e.req.param("appId"),r=e.req.valid("json"),a=await s.appStore.createApiKey({appId:t,name:r.name,scopes:r.scopes,metadata:r.metadata});return e.json({keyId:a.keyId,keyPrefix:a.keyPrefix,apiKey:a.apiKey},201)}).delete("/apps/:appId/api-keys/:keyId",async e=>{let t=e.req.param("appId"),r=e.req.param("keyId");return await s.appStore.revokeApiKey(t,r),e.json({success:!0})});e.s(["appsRoutes",0,p]),r()}catch(e){r(e)}},!1),49534,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(16172),n=e.i(95678),o=t([n]);[n]=o.then?(await o)():o;let p=s.z.object({tenantId:s.z.string().optional(),userId:s.z.string().optional(),from:s.z.string().optional(),to:s.z.string().optional(),limit:s.z.string().optional(),cursor:s.z.string().optional()}),d=new a.Hono().get("/apps/:appId/threads",(0,i.zValidator)("query",p),async e=>{let t=e.req.param("appId"),r=e.req.valid("query"),a=r.tenantId,i=r.userId,s=r.from,o=r.to,p=r.limit?parseInt(r.limit):50,d=r.cursor,l=await n.logStore.listThreadsByApp({appId:t,limit:p,cursor:d,filters:{tenantId:a||void 0,userId:i||void 0,fromDate:s||void 0,toDate:o||void 0}}),c={threads:l.threads.map(e=>({threadId:e.threadId,tenantId:e.tenantId,userId:e.userId,title:e.title,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString()})),nextCursor:l.nextCursor,hasMore:l.hasMore};return e.json(c)}).get("/apps/:appId/threads/:threadId",async e=>{let t=e.req.param("appId"),r=e.req.param("threadId"),a=await n.logStore.getThread({threadId:r,appId:t});if(!a)return e.json({error:"Thread not found"},404);let i={threadId:a.threadId,tenantId:a.tenantId,userId:a.userId,title:a.title,createdAt:a.createdAt.toISOString(),updatedAt:a.updatedAt.toISOString()};return e.json(i)});e.s(["threadsRoutes",0,d]),r()}catch(e){r(e)}},!1),54743,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(13558),s=e.i(16172),n=e.i(95678),o=t([n]);function p(e){return{errorId:e.errorId,generationId:e.generationId,kind:e.kind,message:e.message,code:e.code,stack:e.stack,data:e.data,createdAt:e.createdAt.toISOString()}}function d(e){return{fileId:e.fileId,generationId:e.generationId,filename:e.filename,contentType:e.contentType,sizeBytes:e.sizeBytes,sha256Hex:e.sha256Hex,gcsPath:e.gcsPath,createdAt:e.createdAt.toISOString()}}function l(e,t,r){return{generationId:e.generationId,requestId:e.requestId,userId:e.userId,model:e.model,name:e.name,messages:e.messages,error:e.error,latencyMs:e.latencyMs,usage:{inputTokens:e.inputTokens,outputTokens:e.outputTokens,totalTokens:e.totalTokens,reasoningTokens:e.reasoningTokens,cachedInputTokens:e.cachedInputTokens},cost:{inputCostUsd:e.inputCostUsd?parseFloat(e.inputCostUsd):null,outputCostUsd:e.outputCostUsd?parseFloat(e.outputCostUsd):null,totalCostUsd:e.totalCostUsd?parseFloat(e.totalCostUsd):null},metadata:{},createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString(),errors:t.map(p),files:r.map(d)}}[n]=o.then?(await o)():o;let c=s.z.object({tenantId:s.z.string().optional(),threadId:s.z.string().optional(),requestId:s.z.string().optional(),limit:s.z.string().optional(),cursor:s.z.string().optional()}),u=new a.Hono().get("/",(0,i.zValidator)("query",c),async e=>{let t=e.req.param("appId"),r=e.req.valid("query"),a=r.tenantId,i=r.threadId,s=r.requestId,o=r.limit?parseInt(r.limit):50,p=r.cursor,{generations:d,nextCursor:c,hasMore:u}=await n.logStore.listGenerations({appId:t,tenantId:a,threadId:i,requestId:s,limit:o,cursor:p}),h=d.map(e=>e.generationId),[m,f]=await Promise.all([n.logStore.getGenerationErrorsByIds({generationIds:h,appId:t}),n.logStore.getGenerationFilesByIds({generationIds:h,appId:t})]),g=d.map(e=>l(e,m.get(e.generationId)??[],f.get(e.generationId)??[]));return e.json({generations:g,nextCursor:c,hasMore:u})}).get("/:generationId",async e=>{let t=e.req.param("appId"),r=e.req.param("generationId"),a=await n.logStore.getGeneration({generationId:r,appId:t});if(!a)return e.json({error:"Generation not found"},404);let[i,s]=await Promise.all([n.logStore.getGenerationErrors({generationId:r,appId:t}),n.logStore.getGenerationFiles({generationId:r,appId:t})]);return e.json(l(a,i,s))}).get("/:generationId/files/:fileId/download",async e=>{let t=e.req.param("appId"),r=e.req.param("generationId"),a=e.req.param("fileId"),i=await n.logStore.getGenerationFile({fileId:a,generationId:r,appId:t});if(!i)return e.json({error:"File not found"},404);let s=await n.blobStore.downloadFile(i.gcsPath);return new Response(new Uint8Array(s),{headers:{"Content-Type":i.contentType,"Content-Disposition":`attachment; filename="${encodeURIComponent(i.filename)}"`,"Content-Length":i.sizeBytes}})});e.s(["generationsRoutes",0,u]),r()}catch(e){r(e)}},!1),12303,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481),i=e.i(7805);e.i(39768);var s=e.i(79296),n=e.i(96401),o=e.i(23802),p=e.i(9253),d=e.i(49534),l=e.i(54743),c=t([o,p,d,l]);[o,p,d,l]=c.then?(await c)():c;let u=new a.Hono().use((0,i.cors)()).onError((e,t)=>(console.error(e,`Error caught by global handler [${t.req.method} ${t.req.path}]`),e instanceof s.ZodError)?t.json({error:{issues:e.issues}},400):t.json({error:String(e)})).get("/health",e=>e.json({status:"ok"})).get("/api/health",e=>e.json({status:"ok"})).get("/api/config",e=>e.json({standaloneMode:n.config.standaloneMode})).route("/api/collect",o.collectRoutes).route("/api/admin",p.appsRoutes).route("/api/admin/",d.threadsRoutes).route("/api/admin/apps/:appId/generations",l.generationsRoutes);e.s(["routes",()=>u]),r()}catch(e){r(e)}},!1),80719,e=>e.a(async(t,r)=>{try{var a=e.i(12303),i=t([a]);[a]=i.then?(await i)():i,process.env.PORT&&parseInt(process.env.PORT),a.routes.fetch,e.s([]),r()}catch(e){r(e)}},!1),14608,e=>e.a(async(t,r)=>{try{e.i(19991);var a=e.i(26481);e.i(66587);var i=e.i(66349),s=e.i(80719),n=e.i(12303),o=t([s,n]);[s,n]=o.then?(await o)():o;let p=new a.Hono;p.route("/",n.routes);let d=(0,i.handle)(p),l=(0,i.handle)(p),c=(0,i.handle)(p),u=(0,i.handle)(p),h=(0,i.handle)(p);e.s(["DELETE",0,h,"GET",0,d,"PATCH",0,u,"POST",0,l,"PUT",0,c]),r()}catch(e){r(e)}},!1),41689,e=>e.a(async(t,r)=>{try{var a=e.i(71882),i=e.i(10915),s=e.i(54628),n=e.i(74462),o=e.i(12036),p=e.i(56971),d=e.i(61158),l=e.i(20794),c=e.i(73240),u=e.i(90993),h=e.i(38778),m=e.i(59155),f=e.i(77190),g=e.i(77366),v=e.i(97308),y=e.i(70941),w=e.i(93695);e.i(2260);var b=e.i(49590),_=e.i(14608),x=t([_]);[_]=x.then?(await x)():x;let E=new a.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/[[...route]]/route",pathname:"/api/[[...route]]",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/[[...route]]/route.ts",nextConfigOutput:"standalone",userland:_}),{workAsyncStorage:A,workUnitAsyncStorage:S,serverHooks:k}=E;function N(){return(0,s.patchFetch)({workAsyncStorage:A,workUnitAsyncStorage:S})}async function T(e,t,r){E.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let a="/api/[[...route]]/route";a=a.replace(/\/index$/,"")||"/";let s=await E.prepare(e,t,{srcPage:a,multiZoneDraftMode:!1});if(!s)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:_,params:x,nextConfig:N,parsedUrl:T,isDraftMode:A,prerenderManifest:S,routerServerContext:k,isOnDemandRevalidate:O,revalidateOnlyGenerated:C,resolvedPathname:I,clientReferenceManifest:R,serverActionsManifest:D}=s,P=(0,l.normalizeAppPath)(a),j=!!(S.dynamicRoutes[P]||S.routes[I]),q=async()=>((null==k?void 0:k.render404)?await k.render404(e,t,T,!1):t.end("This page could not be found"),null);if(j&&!A){let e=!!S.routes[I],t=S.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(N.experimental.adapterPath)return await q();throw new w.NoFallbackError}}let L=null;!j||E.isDev||A||(L=I,L="/index"===L?"/":L);let M=!0===E.isDev||!j,F=j&&!M;D&&R&&(0,p.setReferenceManifestsSingleton)({page:a,clientReferenceManifest:R,serverActionsManifest:D,serverModuleMap:(0,d.createServerModuleMap)({serverActionsManifest:D})});let U=e.method||"GET",B=(0,o.getTracer)(),V=B.getActiveScopeSpan(),z={params:x,prerenderManifest:S,renderOpts:{experimental:{authInterrupts:!!N.experimental.authInterrupts},cacheComponents:!!N.cacheComponents,supportsDynamicResponse:M,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:N.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a)=>E.onRequestError(e,t,a,k)},sharedContext:{buildId:_}},W=new c.NodeNextRequest(e),$=new c.NodeNextResponse(t),G=u.NextRequestAdapter.fromNodeNextRequest(W,(0,u.signalFromNodeResponse)(t));try{let s=async e=>E.handle(G,z).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=B.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==h.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let i=r.get("next.route");if(i){let t=`${U} ${i}`;e.setAttributes({"next.route":i,"http.route":i,"next.span_name":t}),e.updateName(t)}else e.updateName(`${U} ${a}`)}),p=!!(0,n.getRequestMeta)(e,"minimalMode"),d=async n=>{var o,d;let l=async({previousCacheEntry:i})=>{try{if(!p&&O&&C&&!i)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await s(n);e.fetchMetrics=z.renderOpts.fetchMetrics;let o=z.renderOpts.pendingWaitUntil;o&&r.waitUntil&&(r.waitUntil(o),o=void 0);let d=z.renderOpts.collectedTags;if(!j)return await (0,f.sendResponse)(W,$,a,z.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,g.toNodeOutgoingHttpHeaders)(a.headers);d&&(t[y.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==z.renderOpts.collectedRevalidate&&!(z.renderOpts.collectedRevalidate>=y.INFINITE_CACHE)&&z.renderOpts.collectedRevalidate,i=void 0===z.renderOpts.collectedExpire||z.renderOpts.collectedExpire>=y.INFINITE_CACHE?void 0:z.renderOpts.collectedExpire;return{value:{kind:b.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:i}}}}catch(t){throw(null==i?void 0:i.isStale)&&await E.onRequestError(e,t,{routerKind:"App Router",routePath:a,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:F,isOnDemandRevalidate:O})},k),t}},c=await E.handleResponse({req:e,nextConfig:N,cacheKey:L,routeKind:i.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:S,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:C,responseGenerator:l,waitUntil:r.waitUntil,isMinimalMode:p});if(!j)return null;if((null==c||null==(o=c.value)?void 0:o.kind)!==b.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(d=c.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});p||t.setHeader("x-nextjs-cache",O?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),A&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,g.fromNodeOutgoingHttpHeaders)(c.value.headers);return p&&j||u.delete(y.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,v.getCacheControlHeader)(c.cacheControl)),await (0,f.sendResponse)(W,$,new Response(c.value.body,{headers:u,status:c.value.status||200})),null};V?await d(V):await B.withPropagatedContext(e.headers,()=>B.trace(h.BaseServerSpan.handleRequest,{spanName:`${U} ${a}`,kind:o.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},d))}catch(t){if(t instanceof w.NoFallbackError||await E.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:F,isOnDemandRevalidate:O})}),j)throw t;return await (0,f.sendResponse)(W,$,new Response(null,{status:500})),null}}e.s(["handler",()=>T,"patchFetch",()=>N,"routeModule",()=>E,"serverHooks",()=>k,"workAsyncStorage",()=>A,"workUnitAsyncStorage",()=>S]),r()}catch(e){r(e)}},!1)];
27
27
 
28
28
  //# sourceMappingURL=%5Broot-of-the-server%5D__a0f47697._.js.map