@zuplo/core 6.60.20 → 6.60.22
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.
- package/customer.cli.minified.js +15 -15
- package/index.minified.js +120 -120
- package/package.json +4 -4
package/customer.cli.minified.js
CHANGED
|
@@ -34,7 +34,7 @@ var Htr=Object.create;var BH=Object.defineProperty;var Gtr=Object.getOwnProperty
|
|
|
34
34
|
`):l+=h;return l}t(xot,"highlight");var yot=!1,vot=/\r\n|[\n\r\u2028\u2029]/;function Nrr(a,s,l){let _=Object.assign({column:0,line:-1},a.start),h=Object.assign({},_,a.end),{linesAbove:b=2,linesBelow:w=3}=l||{},N=_.line,B=_.column,q=h.line,le=h.column,se=Math.max(N-(b+1),0),te=Math.min(s.length,q+w);N===-1&&(se=0),q===-1&&(te=s.length);let Ue=q-N,Ie={};if(Ue)for(let De=0;De<=Ue;De++){let Tt=De+N;if(!B)Ie[Tt]=!0;else if(De===0){let mt=s[Tt-1].length;Ie[Tt]=[B,mt-B+1]}else if(De===Ue)Ie[Tt]=[0,le];else{let mt=s[Tt-De].length;Ie[Tt]=[0,mt]}}else B===le?B?Ie[N]=[B,0]:Ie[N]=!0:Ie[N]=[B,le-B];return{start:se,end:te,markerLines:Ie}}t(Nrr,"getMarkerLines");function Eot(a,s,l={}){let _=l.forceColor||Crr()&&l.highlightCode,h=Sot(_),b=a.split(vot),{start:w,end:N,markerLines:B}=Nrr(s,b,l),q=s.start&&typeof s.start.column=="number",le=String(N).length,te=(_?xot(a):a).split(vot,N).slice(w,N).map((Ue,Ie)=>{let De=w+1+Ie,mt=` ${` ${De}`.slice(-le)} |`,hr=B[De],rn=!B[De+1];if(hr){let jr="";if(Array.isArray(hr)){let Qr=Ue.slice(0,Math.max(hr[0]-1,0)).replace(/[^\t]/g," "),br=hr[1]||1;jr=[`
|
|
35
35
|
`,h.gutter(mt.replace(/\d/g," "))," ",Qr,h.marker("^").repeat(br)].join(""),rn&&l.message&&(jr+=" "+h.message(l.message))}return[h.marker(">"),h.gutter(mt),Ue.length>0?` ${Ue}`:"",jr].join("")}else return` ${h.gutter(mt)}${Ue.length>0?` ${Ue}`:""}`}).join(`
|
|
36
36
|
`);return l.message&&!q&&(te=`${" ".repeat(le+1)}${l.message}
|
|
37
|
-
${te}`),_?h.reset(te):te}t(Eot,"codeFrameColumns");function Irr(a,s,l,_={}){if(!yot){yot=!0;let b="Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";if(process.emitWarning)process.emitWarning(b,"DeprecationWarning");else{let w=new Error(b);w.name="DeprecationWarning",console.warn(new Error(b))}}return l=Math.max(l,0),Eot(a,{start:{column:l,line:s}},_)}t(Irr,"index");VH.codeFrameColumns=Eot;VH.default=Irr;VH.highlight=xot});var Aot=Et((f7r,Pot)=>{"use strict";Pot.exports=kot;function kot(a,s,l){a instanceof RegExp&&(a=wot(a,l)),s instanceof RegExp&&(s=wot(s,l));var _=Dot(a,s,l);return _&&{start:_[0],end:_[1],pre:l.slice(0,_[0]),body:l.slice(_[0]+a.length,_[1]),post:l.slice(_[1]+s.length)}}t(kot,"balanced");function wot(a,s){var l=s.match(a);return l?l[0]:null}t(wot,"maybeMatch");kot.range=Dot;function Dot(a,s,l){var _,h,b,w,N,B=l.indexOf(a),q=l.indexOf(s,B+1),le=B;if(B>=0&&q>0){if(a===s)return[B,q];for(_=[],b=l.length;le>=0&&!N;)le==B?(_.push(le),B=l.indexOf(a,le+1)):_.length==1?N=[_.pop(),q]:(h=_.pop(),h<b&&(b=h,w=q),q=l.indexOf(s,le+1)),le=B<q&&B>=0?B:q;_.length&&(N=[b,w])}return N}t(Dot,"range")});var jot=Et((p7r,Mot)=>{var Not=Aot();Mot.exports=Lrr;var Iot="\0SLASH"+Math.random()+"\0",Oot="\0OPEN"+Math.random()+"\0",_Ne="\0CLOSE"+Math.random()+"\0",Fot="\0COMMA"+Math.random()+"\0",Lot="\0PERIOD"+Math.random()+"\0";function fNe(a){return parseInt(a,10)==a?parseInt(a,10):a.charCodeAt(0)}t(fNe,"numeric");function Orr(a){return a.split("\\\\").join(Iot).split("\\{").join(Oot).split("\\}").join(_Ne).split("\\,").join(Fot).split("\\.").join(Lot)}t(Orr,"escapeBraces");function Frr(a){return a.split(Iot).join("\\").split(Oot).join("{").split(_Ne).join("}").split(Fot).join(",").split(Lot).join(".")}t(Frr,"unescapeBraces");function Rot(a){if(!a)return[""];var s=[],l=Not("{","}",a);if(!l)return a.split(",");var _=l.pre,h=l.body,b=l.post,w=_.split(",");w[w.length-1]+="{"+h+"}";var N=Rot(b);return b.length&&(w[w.length-1]+=N.shift(),w.push.apply(w,N)),s.push.apply(s,w),s}t(Rot,"parseCommaParts");function Lrr(a){return a?(a.substr(0,2)==="{}"&&(a="\\{\\}"+a.substr(2)),WH(Orr(a),!0).map(Frr)):[]}t(Lrr,"expandTop");function Rrr(a){return"{"+a+"}"}t(Rrr,"embrace");function Mrr(a){return/^-?0\d/.test(a)}t(Mrr,"isPadded");function jrr(a,s){return a<=s}t(jrr,"lte");function Brr(a,s){return a>=s}t(Brr,"gte");function WH(a,s){var l=[],_=Not("{","}",a);if(!_)return[a];var h=_.pre,b=_.post.length?WH(_.post,!1):[""];if(/\$$/.test(_.pre))for(var w=0;w<b.length;w++){var N=h+"{"+_.body+"}"+b[w];l.push(N)}else{var B=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(_.body),q=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(_.body),le=B||q,se=_.body.indexOf(",")>=0;if(!le&&!se)return _.post.match(
|
|
37
|
+
${te}`),_?h.reset(te):te}t(Eot,"codeFrameColumns");function Irr(a,s,l,_={}){if(!yot){yot=!0;let b="Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";if(process.emitWarning)process.emitWarning(b,"DeprecationWarning");else{let w=new Error(b);w.name="DeprecationWarning",console.warn(new Error(b))}}return l=Math.max(l,0),Eot(a,{start:{column:l,line:s}},_)}t(Irr,"index");VH.codeFrameColumns=Eot;VH.default=Irr;VH.highlight=xot});var Aot=Et((f7r,Pot)=>{"use strict";Pot.exports=kot;function kot(a,s,l){a instanceof RegExp&&(a=wot(a,l)),s instanceof RegExp&&(s=wot(s,l));var _=Dot(a,s,l);return _&&{start:_[0],end:_[1],pre:l.slice(0,_[0]),body:l.slice(_[0]+a.length,_[1]),post:l.slice(_[1]+s.length)}}t(kot,"balanced");function wot(a,s){var l=s.match(a);return l?l[0]:null}t(wot,"maybeMatch");kot.range=Dot;function Dot(a,s,l){var _,h,b,w,N,B=l.indexOf(a),q=l.indexOf(s,B+1),le=B;if(B>=0&&q>0){if(a===s)return[B,q];for(_=[],b=l.length;le>=0&&!N;)le==B?(_.push(le),B=l.indexOf(a,le+1)):_.length==1?N=[_.pop(),q]:(h=_.pop(),h<b&&(b=h,w=q),q=l.indexOf(s,le+1)),le=B<q&&B>=0?B:q;_.length&&(N=[b,w])}return N}t(Dot,"range")});var jot=Et((p7r,Mot)=>{var Not=Aot();Mot.exports=Lrr;var Iot="\0SLASH"+Math.random()+"\0",Oot="\0OPEN"+Math.random()+"\0",_Ne="\0CLOSE"+Math.random()+"\0",Fot="\0COMMA"+Math.random()+"\0",Lot="\0PERIOD"+Math.random()+"\0";function fNe(a){return parseInt(a,10)==a?parseInt(a,10):a.charCodeAt(0)}t(fNe,"numeric");function Orr(a){return a.split("\\\\").join(Iot).split("\\{").join(Oot).split("\\}").join(_Ne).split("\\,").join(Fot).split("\\.").join(Lot)}t(Orr,"escapeBraces");function Frr(a){return a.split(Iot).join("\\").split(Oot).join("{").split(_Ne).join("}").split(Fot).join(",").split(Lot).join(".")}t(Frr,"unescapeBraces");function Rot(a){if(!a)return[""];var s=[],l=Not("{","}",a);if(!l)return a.split(",");var _=l.pre,h=l.body,b=l.post,w=_.split(",");w[w.length-1]+="{"+h+"}";var N=Rot(b);return b.length&&(w[w.length-1]+=N.shift(),w.push.apply(w,N)),s.push.apply(s,w),s}t(Rot,"parseCommaParts");function Lrr(a){return a?(a.substr(0,2)==="{}"&&(a="\\{\\}"+a.substr(2)),WH(Orr(a),!0).map(Frr)):[]}t(Lrr,"expandTop");function Rrr(a){return"{"+a+"}"}t(Rrr,"embrace");function Mrr(a){return/^-?0\d/.test(a)}t(Mrr,"isPadded");function jrr(a,s){return a<=s}t(jrr,"lte");function Brr(a,s){return a>=s}t(Brr,"gte");function WH(a,s){var l=[],_=Not("{","}",a);if(!_)return[a];var h=_.pre,b=_.post.length?WH(_.post,!1):[""];if(/\$$/.test(_.pre))for(var w=0;w<b.length;w++){var N=h+"{"+_.body+"}"+b[w];l.push(N)}else{var B=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(_.body),q=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(_.body),le=B||q,se=_.body.indexOf(",")>=0;if(!le&&!se)return _.post.match(/,(?!,).*\}/)?(a=_.pre+"{"+_.body+_Ne+_.post,WH(a)):[a];var te;if(le)te=_.body.split(/\.\./);else if(te=Rot(_.body),te.length===1&&(te=WH(te[0],!1).map(Rrr),te.length===1))return b.map(function(Po){return _.pre+te[0]+Po});var Ue;if(le){var Ie=fNe(te[0]),De=fNe(te[1]),Tt=Math.max(te[0].length,te[1].length),mt=te.length==3?Math.abs(fNe(te[2])):1,hr=jrr,rn=De<Ie;rn&&(mt*=-1,hr=Brr);var jr=te.some(Mrr);Ue=[];for(var Qr=Ie;hr(Qr,De);Qr+=mt){var br;if(q)br=String.fromCharCode(Qr),br==="\\"&&(br="");else if(br=String(Qr),jr){var yr=Tt-br.length;if(yr>0){var Zi=new Array(yr+1).join("0");Qr<0?br="-"+Zi+br.slice(1):br=Zi+br}}Ue.push(br)}}else{Ue=[];for(var Ci=0;Ci<te.length;Ci++)Ue.push.apply(Ue,WH(te[Ci],!1))}for(var Ci=0;Ci<Ue.length;Ci++)for(var w=0;w<b.length;w++){var N=h+Ue[Ci]+b[w];(!s||le||N)&&l.push(N)}}return l}t(WH,"expand")});var Kle=Et(aj=>{"use strict";Object.defineProperty(aj,"__esModule",{value:!0});aj.getDeepKeys=aj.toJSON=void 0;var jir=["function","symbol","undefined"],Bir=["constructor","prototype","__proto__"],$ir=Object.getPrototypeOf({});function Uir(){let a={},s=this;for(let l of Oct(s))if(typeof l=="string"){let _=s[l],h=typeof _;jir.includes(h)||(a[l]=_)}return a}t(Uir,"toJSON");aj.toJSON=Uir;function Oct(a,s=[]){let l=[];for(;a&&a!==$ir;)l=l.concat(Object.getOwnPropertyNames(a),Object.getOwnPropertySymbols(a)),a=Object.getPrototypeOf(a);let _=new Set(l);for(let h of s.concat(Bir))_.delete(h);return _}t(Oct,"getDeepKeys");aj.getDeepKeys=Oct});var UNe=Et(oj=>{"use strict";Object.defineProperty(oj,"__esModule",{value:!0});oj.addInspectMethod=oj.format=void 0;var Fct=_o("util"),zir=Kle(),Lct=Fct.inspect.custom||Symbol.for("nodejs.util.inspect.custom");oj.format=Fct.format;function Jir(a){a[Lct]=qir}t(Jir,"addInspectMethod");oj.addInspectMethod=Jir;function qir(){let a={},s=this;for(let l of zir.getDeepKeys(s)){let _=s[l];a[l]=_}return delete a[Lct],a}t(qir,"inspect")});var jct=Et(dk=>{"use strict";Object.defineProperty(dk,"__esModule",{value:!0});dk.lazyJoinStacks=dk.joinStacks=dk.isWritableStack=dk.isLazyStack=void 0;var Vir=/\r?\n/,Wir=/\bono[ @]/;function Hir(a){return!!(a&&a.configurable&&typeof a.get=="function")}t(Hir,"isLazyStack");dk.isLazyStack=Hir;function Gir(a){return!!(!a||a.writable||typeof a.set=="function")}t(Gir,"isWritableStack");dk.isWritableStack=Gir;function Rct(a,s){let l=Mct(a.stack),_=s?s.stack:void 0;return l&&_?l+`
|
|
38
38
|
|
|
39
39
|
`+_:l||_}t(Rct,"joinStacks");dk.joinStacks=Rct;function Kir(a,s,l){l?Object.defineProperty(s,"stack",{get:t(()=>{let _=a.get.apply(s);return Rct({stack:_},l)},"get"),enumerable:!1,configurable:!0}):Yir(s,a)}t(Kir,"lazyJoinStacks");dk.lazyJoinStacks=Kir;function Mct(a){if(a){let s=a.split(Vir),l;for(let _=0;_<s.length;_++){let h=s[_];if(Wir.test(h))l===void 0&&(l=_);else if(l!==void 0){s.splice(l,_-l);break}}if(s.length>0)return s.join(`
|
|
40
40
|
`)}return a}t(Mct,"popStack");function Yir(a,s){Object.defineProperty(a,"stack",{get:t(()=>Mct(s.get.apply(a)),"get"),enumerable:!1,configurable:!0})}t(Yir,"lazyPopStack")});var Uct=Et(Xle=>{"use strict";Object.defineProperty(Xle,"__esModule",{value:!0});Xle.extendError=void 0;var Bct=UNe(),Yle=jct(),$ct=Kle(),Xir=["name","message","stack"];function Zir(a,s,l){let _=a;return Qir(_,s),s&&typeof s=="object"&&esr(_,s),_.toJSON=$ct.toJSON,Bct.addInspectMethod&&Bct.addInspectMethod(_),l&&typeof l=="object"&&Object.assign(_,l),_}t(Zir,"extendError");Xle.extendError=Zir;function Qir(a,s){let l=Object.getOwnPropertyDescriptor(a,"stack");Yle.isLazyStack(l)?Yle.lazyJoinStacks(l,a,s):Yle.isWritableStack(l)&&(a.stack=Yle.joinStacks(a,s))}t(Qir,"extendStack");function esr(a,s){let l=$ct.getDeepKeys(s,Xir),_=a,h=s;for(let b of l)if(_[b]===void 0)try{_[b]=h[b]}catch{}}t(esr,"mergeErrors")});var zct=Et(cj=>{"use strict";Object.defineProperty(cj,"__esModule",{value:!0});cj.normalizeArgs=cj.normalizeOptions=void 0;var tsr=UNe();function rsr(a){return a=a||{},{concatMessages:a.concatMessages===void 0?!0:!!a.concatMessages,format:a.format===void 0?tsr.format:typeof a.format=="function"?a.format:!1}}t(rsr,"normalizeOptions");cj.normalizeOptions=rsr;function nsr(a,s){let l,_,h,b="";return typeof a[0]=="string"?h=a:typeof a[1]=="string"?(a[0]instanceof Error?l=a[0]:_=a[0],h=a.slice(1)):(l=a[0],_=a[1],h=a.slice(2)),h.length>0&&(s.format?b=s.format.apply(void 0,h):b=h.join(" ")),s.concatMessages&&l&&l.message&&(b+=(b?`
|
|
@@ -561,7 +561,7 @@ No Segments
|
|
|
561
561
|
`;for(let l=0;l<a._capnp.segments.length;l++){s+=`================
|
|
562
562
|
Segment #${l}
|
|
563
563
|
================
|
|
564
|
-
`;let{buffer:_,byteLength:h}=a._capnp.segments[l],b=new Uint8Array(_,0,h);s+=VB.dumpBuffer(b)}return s}t(Q5e,"dump");Hf.dump=Q5e;function eLe(a,s){let l=new a(s.getSegment(0),0);d2t.validate(ade.PointerType.STRUCT,l);let _=d2t.getTargetStructSize(l);return(_.dataByteLength<a._capnp.size.dataByteLength||_.pointerLength<a._capnp.size.pointerLength)&&($k("need to resize root struct %s",l),m2t.resize(a._capnp.size,l)),l}t(eLe,"getRoot");Hf.getRoot=eLe;function cde(a,s){let l=s._capnp.segments.length;if(a===0&&l===0){if(P4.Arena.getNumSegments(s._capnp.arena)===0?ode(DY.DEFAULT_BUFFER_SIZE,s):s._capnp.segments[0]=new Z5e.Segment(0,s,P4.Arena.getBuffer(0,s._capnp.arena)),!s._capnp.segments[0].hasCapacity(8))throw new Error(qB.MSG_SEGMENT_TOO_SMALL);return s._capnp.segments[0].allocate(8),s._capnp.segments[0]}if(a<0||a>=l)throw new Error(VB.format(qB.MSG_SEGMENT_OUT_OF_BOUNDS,a,s));return s._capnp.segments[a]}t(cde,"getSegment");Hf.getSegment=cde;function tLe(a,s){let l=new a(s.getSegment(0),0);return m2t.initStruct(a._capnp.size,l),$k("Initialized root pointer %s for %s.",l,s),l}t(tLe,"initRoot");Hf.initRoot=tLe;function b2t(a){return new ade.Pointer(new rx(a).getSegment(0),0)}t(b2t,"readRawPointer");Hf.readRawPointer=b2t;function S2t(a,s){ade.Pointer.copyFrom(a,new ade.Pointer(s.getSegment(0),0))}t(S2t,"setRoot");Hf.setRoot=S2t;function rLe(a){let s=iLe(a);a._capnp.segments.length===0&&cde(0,a);let l=a._capnp.segments,_=s.byteLength+l.reduce((w,N)=>w+VB.padToWord(N.byteLength),0),h=new Uint8Array(new ArrayBuffer(_)),b=s.byteLength;return h.set(new Uint8Array(s)),l.forEach(w=>{let N=VB.padToWord(w.byteLength);h.set(new Uint8Array(w.buffer,0,N),b),b+=N}),h.buffer}t(rLe,"toArrayBuffer");Hf.toArrayBuffer=rLe;function nLe(a){let s=X5e.pack(iLe(a));a._capnp.segments.length===0&&a.getSegment(0);let l=a._capnp.segments.map(w=>X5e.pack(w.buffer,0,VB.padToWord(w.byteLength))),_=s.byteLength+l.reduce((w,N)=>w+N.byteLength,0),h=new Uint8Array(new ArrayBuffer(_)),b=s.byteLength;return h.set(new Uint8Array(s)),l.forEach(w=>{h.set(new Uint8Array(w),b),b+=w.byteLength}),h.buffer}t(nLe,"toPackedArrayBuffer");Hf.toPackedArrayBuffer=nLe;function iLe(a){let s=a._capnp.segments.length;if(s===0)return new Float64Array(1).buffer;let l=4+s*4+(1-s%2)*4,_=new DataView(new ArrayBuffer(l));return $k("Writing message stream frame with segment count: %d.",s),_.setUint32(0,s-1,!0),a._capnp.segments.forEach((h,b)=>{$k("Message segment %d word count: %d.",h.id,h.byteLength/8),_.setUint32(b*4+4,h.byteLength/8,!0)}),_.buffer}t(iLe,"getStreamFrame");Hf.getStreamFrame=iLe});var C2t=Et(nx=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});nx.ObjectSize=nx.readRawPointer=nx.Message=nx.ListElementSize=void 0;var x2t=(qu(),Qu(Ju));x2t.__exportStar(rbt(),nx);var KAr=mm();Object.defineProperty(nx,"ListElementSize",{enumerable:!0,get:t(function(){return KAr.ListElementSize},"get")});var E2t=T2t();Object.defineProperty(nx,"Message",{enumerable:!0,get:t(function(){return E2t.Message},"get")});Object.defineProperty(nx,"readRawPointer",{enumerable:!0,get:t(function(){return E2t.readRawPointer},"get")});var YAr=nF();Object.defineProperty(nx,"ObjectSize",{enumerable:!0,get:t(function(){return YAr.ObjectSize},"get")});x2t.__exportStar(ide(),nx)});var lde=Et(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.Uint64=Rs.Int64=Rs.getUint8Mask=Rs.getUint64Mask=Rs.getUint32Mask=Rs.getUint16Mask=Rs.getInt8Mask=Rs.getInt64Mask=Rs.getInt32Mask=Rs.getInt16Mask=Rs.getFloat64Mask=Rs.getFloat32Mask=Rs.getBitMask=Rs.Void=Rs.VoidList=Rs.Uint8List=Rs.Uint64List=Rs.Uint32List=Rs.Uint16List=Rs.TextList=Rs.Text=Rs.Struct=Rs.Pointer=Rs.PointerType=Rs.PointerList=Rs.Orphan=Rs.List=Rs.InterfaceList=Rs.Interface=Rs.Int8List=Rs.Int64List=Rs.Int32List=Rs.Int16List=Rs.Float64List=Rs.Float32List=Rs.DataList=Rs.Data=Rs.CompositeList=Rs.BoolList=Rs.AnyPointerList=Rs.readRawPointer=Rs.ObjectSize=Rs.Message=Rs.ListElementSize=void 0;var fl=C2t();Object.defineProperty(Rs,"ListElementSize",{enumerable:!0,get:t(function(){return fl.ListElementSize},"get")});Object.defineProperty(Rs,"Message",{enumerable:!0,get:t(function(){return fl.Message},"get")});Object.defineProperty(Rs,"ObjectSize",{enumerable:!0,get:t(function(){return fl.ObjectSize},"get")});Object.defineProperty(Rs,"readRawPointer",{enumerable:!0,get:t(function(){return fl.readRawPointer},"get")});Object.defineProperty(Rs,"AnyPointerList",{enumerable:!0,get:t(function(){return fl.AnyPointerList},"get")});Object.defineProperty(Rs,"BoolList",{enumerable:!0,get:t(function(){return fl.BoolList},"get")});Object.defineProperty(Rs,"CompositeList",{enumerable:!0,get:t(function(){return fl.CompositeList},"get")});Object.defineProperty(Rs,"Data",{enumerable:!0,get:t(function(){return fl.Data},"get")});Object.defineProperty(Rs,"DataList",{enumerable:!0,get:t(function(){return fl.DataList},"get")});Object.defineProperty(Rs,"Float32List",{enumerable:!0,get:t(function(){return fl.Float32List},"get")});Object.defineProperty(Rs,"Float64List",{enumerable:!0,get:t(function(){return fl.Float64List},"get")});Object.defineProperty(Rs,"Int16List",{enumerable:!0,get:t(function(){return fl.Int16List},"get")});Object.defineProperty(Rs,"Int32List",{enumerable:!0,get:t(function(){return fl.Int32List},"get")});Object.defineProperty(Rs,"Int64List",{enumerable:!0,get:t(function(){return fl.Int64List},"get")});Object.defineProperty(Rs,"Int8List",{enumerable:!0,get:t(function(){return fl.Int8List},"get")});Object.defineProperty(Rs,"Interface",{enumerable:!0,get:t(function(){return fl.Interface},"get")});Object.defineProperty(Rs,"InterfaceList",{enumerable:!0,get:t(function(){return fl.InterfaceList},"get")});Object.defineProperty(Rs,"List",{enumerable:!0,get:t(function(){return fl.List},"get")});Object.defineProperty(Rs,"Orphan",{enumerable:!0,get:t(function(){return fl.Orphan},"get")});Object.defineProperty(Rs,"PointerList",{enumerable:!0,get:t(function(){return fl.PointerList},"get")});Object.defineProperty(Rs,"PointerType",{enumerable:!0,get:t(function(){return fl.PointerType},"get")});Object.defineProperty(Rs,"Pointer",{enumerable:!0,get:t(function(){return fl.Pointer},"get")});Object.defineProperty(Rs,"Struct",{enumerable:!0,get:t(function(){return fl.Struct},"get")});Object.defineProperty(Rs,"Text",{enumerable:!0,get:t(function(){return fl.Text},"get")});Object.defineProperty(Rs,"TextList",{enumerable:!0,get:t(function(){return fl.TextList},"get")});Object.defineProperty(Rs,"Uint16List",{enumerable:!0,get:t(function(){return fl.Uint16List},"get")});Object.defineProperty(Rs,"Uint32List",{enumerable:!0,get:t(function(){return fl.Uint32List},"get")});Object.defineProperty(Rs,"Uint64List",{enumerable:!0,get:t(function(){return fl.Uint64List},"get")});Object.defineProperty(Rs,"Uint8List",{enumerable:!0,get:t(function(){return fl.Uint8List},"get")});Object.defineProperty(Rs,"VoidList",{enumerable:!0,get:t(function(){return fl.VoidList},"get")});Object.defineProperty(Rs,"Void",{enumerable:!0,get:t(function(){return fl.Void},"get")});Object.defineProperty(Rs,"getBitMask",{enumerable:!0,get:t(function(){return fl.getBitMask},"get")});Object.defineProperty(Rs,"getFloat32Mask",{enumerable:!0,get:t(function(){return fl.getFloat32Mask},"get")});Object.defineProperty(Rs,"getFloat64Mask",{enumerable:!0,get:t(function(){return fl.getFloat64Mask},"get")});Object.defineProperty(Rs,"getInt16Mask",{enumerable:!0,get:t(function(){return fl.getInt16Mask},"get")});Object.defineProperty(Rs,"getInt32Mask",{enumerable:!0,get:t(function(){return fl.getInt32Mask},"get")});Object.defineProperty(Rs,"getInt64Mask",{enumerable:!0,get:t(function(){return fl.getInt64Mask},"get")});Object.defineProperty(Rs,"getInt8Mask",{enumerable:!0,get:t(function(){return fl.getInt8Mask},"get")});Object.defineProperty(Rs,"getUint16Mask",{enumerable:!0,get:t(function(){return fl.getUint16Mask},"get")});Object.defineProperty(Rs,"getUint32Mask",{enumerable:!0,get:t(function(){return fl.getUint32Mask},"get")});Object.defineProperty(Rs,"getUint64Mask",{enumerable:!0,get:t(function(){return fl.getUint64Mask},"get")});Object.defineProperty(Rs,"getUint8Mask",{enumerable:!0,get:t(function(){return fl.getUint8Mask},"get")});var w2t=Rpe();Object.defineProperty(Rs,"Int64",{enumerable:!0,get:t(function(){return w2t.Int64},"get")});Object.defineProperty(Rs,"Uint64",{enumerable:!0,get:t(function(){return w2t.Uint64},"get")})});var cLe=Et(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.Extension=rs.Extension_Module=rs.TlsOptions=rs.TlsOptions_Version=rs.TlsOptions_Keypair=rs.HttpOptions=rs.HttpOptions_Header=rs.HttpOptions_Style=rs.DiskDirectory=rs.Network=rs.ExternalServer=rs.ExternalServer_Which=rs.ExternalServer_Tcp=rs.ExternalServer_Https=rs.Worker=rs.Worker_Which=rs.Worker_DurableObjectStorage=rs.Worker_DurableObjectStorage_Which=rs.Worker_DurableObjectNamespace=rs.Worker_DurableObjectNamespace_Which=rs.Worker_Binding=rs.Worker_Binding_Which=rs.Worker_Binding_MemoryCache=rs.Worker_Binding_Hyperdrive=rs.Worker_Binding_Parameter=rs.Worker_Binding_WrappedBinding=rs.Worker_Binding_MemoryCacheLimits=rs.Worker_Binding_CryptoKey=rs.Worker_Binding_CryptoKey_Which=rs.Worker_Binding_CryptoKey_Algorithm=rs.Worker_Binding_CryptoKey_Algorithm_Which=rs.Worker_Binding_CryptoKey_Usage=rs.Worker_Binding_DurableObjectNamespaceDesignator=rs.Worker_Binding_Type=rs.Worker_Binding_Type_Which=rs.Worker_Module=rs.Worker_Module_Which=rs.ServiceDesignator=rs.Service=rs.Service_Which=rs.Socket=rs.Socket_Which=rs.Socket_Https=rs.Config=rs._capnpFileId=void 0;var Zl=lde(),oe=lde();rs._capnpFileId="e6afd26682091c01";var pF=class a extends oe.Struct{static{t(this,"Config")}adoptServices(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownServices(){return oe.Struct.disown(this.getServices())}getServices(){return oe.Struct.getList(0,a._Services,this)}hasServices(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initServices(s){return oe.Struct.initList(0,a._Services,s,this)}setServices(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}adoptSockets(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownSockets(){return oe.Struct.disown(this.getSockets())}getSockets(){return oe.Struct.getList(1,a._Sockets,this)}hasSockets(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initSockets(s){return oe.Struct.initList(1,a._Sockets,s,this)}setSockets(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptV8Flags(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownV8Flags(){return oe.Struct.disown(this.getV8Flags())}getV8Flags(){return oe.Struct.getList(2,Zl.TextList,this)}hasV8Flags(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initV8Flags(s){return oe.Struct.initList(2,Zl.TextList,s,this)}setV8Flags(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptExtensions(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownExtensions(){return oe.Struct.disown(this.getExtensions())}getExtensions(){return oe.Struct.getList(3,a._Extensions,this)}hasExtensions(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initExtensions(s){return oe.Struct.initList(3,a._Extensions,s,this)}setExtensions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}adoptAutogates(s){oe.Struct.adopt(s,oe.Struct.getPointer(4,this))}disownAutogates(){return oe.Struct.disown(this.getAutogates())}getAutogates(){return oe.Struct.getList(4,Zl.TextList,this)}hasAutogates(){return!oe.Struct.isNull(oe.Struct.getPointer(4,this))}initAutogates(s){return oe.Struct.initList(4,Zl.TextList,s,this)}setAutogates(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(4,this))}toString(){return"Config_"+super.toString()}};rs.Config=pF;pF._capnp={displayName:"Config",id:"8794486c76aaa7d6",size:new oe.ObjectSize(0,5)};var WB=class extends oe.Struct{static{t(this,"Socket_Https")}adoptOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownOptions(){return oe.Struct.disown(this.getOptions())}getOptions(){return oe.Struct.getStruct(2,Zy,this)}hasOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initOptions(){return oe.Struct.initStructAt(2,Zy,this)}setOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(3,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initTlsOptions(){return oe.Struct.initStructAt(3,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}toString(){return"Socket_Https_"+super.toString()}};rs.Socket_Https=WB;WB._capnp={displayName:"https",id:"de123876383cbbdc",size:new oe.ObjectSize(8,5)};var sLe;(function(a){a[a.HTTP=0]="HTTP",a[a.HTTPS=1]="HTTPS"})(sLe=rs.Socket_Which||(rs.Socket_Which={}));var dF=class extends oe.Struct{static{t(this,"Socket")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getAddress(){return oe.Struct.getText(1,this)}setAddress(s){oe.Struct.setText(1,s,this)}adoptHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownHttp(){return oe.Struct.disown(this.getHttp())}getHttp(){return oe.Struct.testWhich("http",oe.Struct.getUint16(0,this),0,this),oe.Struct.getStruct(2,Zy,this)}hasHttp(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initHttp(){return oe.Struct.setUint16(0,0,this),oe.Struct.initStructAt(2,Zy,this)}isHttp(){return oe.Struct.getUint16(0,this)===0}setHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}getHttps(){return oe.Struct.testWhich("https",oe.Struct.getUint16(0,this),1,this),oe.Struct.getAs(WB,this)}initHttps(){return oe.Struct.setUint16(0,1,this),oe.Struct.getAs(WB,this)}isHttps(){return oe.Struct.getUint16(0,this)===1}setHttps(){oe.Struct.setUint16(0,1,this)}adoptService(s){oe.Struct.adopt(s,oe.Struct.getPointer(4,this))}disownService(){return oe.Struct.disown(this.getService())}getService(){return oe.Struct.getStruct(4,ud,this)}hasService(){return!oe.Struct.isNull(oe.Struct.getPointer(4,this))}initService(){return oe.Struct.initStructAt(4,ud,this)}setService(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(4,this))}toString(){return"Socket_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Socket=dF;dF.HTTP=sLe.HTTP;dF.HTTPS=sLe.HTTPS;dF._capnp={displayName:"Socket",id:"9a0eba45530ee79f",size:new oe.ObjectSize(8,5)};var t$;(function(a){a[a.UNSPECIFIED=0]="UNSPECIFIED",a[a.WORKER=1]="WORKER",a[a.NETWORK=2]="NETWORK",a[a.EXTERNAL=3]="EXTERNAL",a[a.DISK=4]="DISK"})(t$=rs.Service_Which||(rs.Service_Which={}));var Uk=class extends oe.Struct{static{t(this,"Service")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}isUnspecified(){return oe.Struct.getUint16(0,this)===0}setUnspecified(){oe.Struct.setUint16(0,0,this)}adoptWorker(s){oe.Struct.setUint16(0,1,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWorker(){return oe.Struct.disown(this.getWorker())}getWorker(){return oe.Struct.testWhich("worker",oe.Struct.getUint16(0,this),1,this),oe.Struct.getStruct(1,uv,this)}hasWorker(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWorker(){return oe.Struct.setUint16(0,1,this),oe.Struct.initStructAt(1,uv,this)}isWorker(){return oe.Struct.getUint16(0,this)===1}setWorker(s){oe.Struct.setUint16(0,1,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptNetwork(s){oe.Struct.setUint16(0,2,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownNetwork(){return oe.Struct.disown(this.getNetwork())}getNetwork(){return oe.Struct.testWhich("network",oe.Struct.getUint16(0,this),2,this),oe.Struct.getStruct(1,ZB,this)}hasNetwork(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initNetwork(){return oe.Struct.setUint16(0,2,this),oe.Struct.initStructAt(1,ZB,this)}isNetwork(){return oe.Struct.getUint16(0,this)===2}setNetwork(s){oe.Struct.setUint16(0,2,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptExternal(s){oe.Struct.setUint16(0,3,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownExternal(){return oe.Struct.disown(this.getExternal())}getExternal(){return oe.Struct.testWhich("external",oe.Struct.getUint16(0,this),3,this),oe.Struct.getStruct(1,KA,this)}hasExternal(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initExternal(){return oe.Struct.setUint16(0,3,this),oe.Struct.initStructAt(1,KA,this)}isExternal(){return oe.Struct.getUint16(0,this)===3}setExternal(s){oe.Struct.setUint16(0,3,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptDisk(s){oe.Struct.setUint16(0,4,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDisk(){return oe.Struct.disown(this.getDisk())}getDisk(){return oe.Struct.testWhich("disk",oe.Struct.getUint16(0,this),4,this),oe.Struct.getStruct(1,QB,this)}hasDisk(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDisk(){return oe.Struct.setUint16(0,4,this),oe.Struct.initStructAt(1,QB,this)}isDisk(){return oe.Struct.getUint16(0,this)===4}setDisk(s){oe.Struct.setUint16(0,4,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}toString(){return"Service_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Service=Uk;Uk.UNSPECIFIED=t$.UNSPECIFIED;Uk.WORKER=t$.WORKER;Uk.NETWORK=t$.NETWORK;Uk.EXTERNAL=t$.EXTERNAL;Uk.DISK=t$.DISK;Uk._capnp={displayName:"Service",id:"e5c88e8bb7bcb6b9",size:new oe.ObjectSize(8,2)};var ud=class extends oe.Struct{static{t(this,"ServiceDesignator")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getEntrypoint(){return oe.Struct.getText(1,this)}setEntrypoint(s){oe.Struct.setText(1,s,this)}toString(){return"ServiceDesignator_"+super.toString()}};rs.ServiceDesignator=ud;ud._capnp={displayName:"ServiceDesignator",id:"ae8ec91cee724450",size:new oe.ObjectSize(0,2)};var zk;(function(a){a[a.ES_MODULE=0]="ES_MODULE",a[a.COMMON_JS_MODULE=1]="COMMON_JS_MODULE",a[a.TEXT=2]="TEXT",a[a.DATA=3]="DATA",a[a.WASM=4]="WASM",a[a.JSON=5]="JSON",a[a.NODE_JS_COMPAT_MODULE=6]="NODE_JS_COMPAT_MODULE",a[a.PYTHON_MODULE=7]="PYTHON_MODULE",a[a.PYTHON_REQUIREMENT=8]="PYTHON_REQUIREMENT"})(zk=rs.Worker_Module_Which||(rs.Worker_Module_Which={}));var lv=class extends oe.Struct{static{t(this,"Worker_Module")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getEsModule(){return oe.Struct.testWhich("esModule",oe.Struct.getUint16(0,this),0,this),oe.Struct.getText(1,this)}isEsModule(){return oe.Struct.getUint16(0,this)===0}setEsModule(s){oe.Struct.setUint16(0,0,this),oe.Struct.setText(1,s,this)}getCommonJsModule(){return oe.Struct.testWhich("commonJsModule",oe.Struct.getUint16(0,this),1,this),oe.Struct.getText(1,this)}isCommonJsModule(){return oe.Struct.getUint16(0,this)===1}setCommonJsModule(s){oe.Struct.setUint16(0,1,this),oe.Struct.setText(1,s,this)}getText(){return oe.Struct.testWhich("text",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(1,this)}isText(){return oe.Struct.getUint16(0,this)===2}setText(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(1,s,this)}adoptData(s){oe.Struct.setUint16(0,3,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownData(){return oe.Struct.disown(this.getData())}getData(){return oe.Struct.testWhich("data",oe.Struct.getUint16(0,this),3,this),oe.Struct.getData(1,this)}hasData(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initData(s){return oe.Struct.setUint16(0,3,this),oe.Struct.initData(1,s,this)}isData(){return oe.Struct.getUint16(0,this)===3}setData(s){oe.Struct.setUint16(0,3,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptWasm(s){oe.Struct.setUint16(0,4,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWasm(){return oe.Struct.disown(this.getWasm())}getWasm(){return oe.Struct.testWhich("wasm",oe.Struct.getUint16(0,this),4,this),oe.Struct.getData(1,this)}hasWasm(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWasm(s){return oe.Struct.setUint16(0,4,this),oe.Struct.initData(1,s,this)}isWasm(){return oe.Struct.getUint16(0,this)===4}setWasm(s){oe.Struct.setUint16(0,4,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getJson(){return oe.Struct.testWhich("json",oe.Struct.getUint16(0,this),5,this),oe.Struct.getText(1,this)}isJson(){return oe.Struct.getUint16(0,this)===5}setJson(s){oe.Struct.setUint16(0,5,this),oe.Struct.setText(1,s,this)}getNodeJsCompatModule(){return oe.Struct.testWhich("nodeJsCompatModule",oe.Struct.getUint16(0,this),6,this),oe.Struct.getText(1,this)}isNodeJsCompatModule(){return oe.Struct.getUint16(0,this)===6}setNodeJsCompatModule(s){oe.Struct.setUint16(0,6,this),oe.Struct.setText(1,s,this)}getPythonModule(){return oe.Struct.testWhich("pythonModule",oe.Struct.getUint16(0,this),7,this),oe.Struct.getText(1,this)}isPythonModule(){return oe.Struct.getUint16(0,this)===7}setPythonModule(s){oe.Struct.setUint16(0,7,this),oe.Struct.setText(1,s,this)}getPythonRequirement(){return oe.Struct.testWhich("pythonRequirement",oe.Struct.getUint16(0,this),8,this),oe.Struct.getText(1,this)}isPythonRequirement(){return oe.Struct.getUint16(0,this)===8}setPythonRequirement(s){oe.Struct.setUint16(0,8,this),oe.Struct.setText(1,s,this)}adoptNamedExports(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownNamedExports(){return oe.Struct.disown(this.getNamedExports())}getNamedExports(){return oe.Struct.getList(2,Zl.TextList,this)}hasNamedExports(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initNamedExports(s){return oe.Struct.initList(2,Zl.TextList,s,this)}setNamedExports(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Module_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Module=lv;lv.ES_MODULE=zk.ES_MODULE;lv.COMMON_JS_MODULE=zk.COMMON_JS_MODULE;lv.TEXT=zk.TEXT;lv.DATA=zk.DATA;lv.WASM=zk.WASM;lv.JSON=zk.JSON;lv.NODE_JS_COMPAT_MODULE=zk.NODE_JS_COMPAT_MODULE;lv.PYTHON_MODULE=zk.PYTHON_MODULE;lv.PYTHON_REQUIREMENT=zk.PYTHON_REQUIREMENT;lv._capnp={displayName:"Module",id:"d9d87a63770a12f3",size:new oe.ObjectSize(8,3)};var fv;(function(a){a[a.UNSPECIFIED=0]="UNSPECIFIED",a[a.TEXT=1]="TEXT",a[a.DATA=2]="DATA",a[a.JSON=3]="JSON",a[a.WASM=4]="WASM",a[a.CRYPTO_KEY=5]="CRYPTO_KEY",a[a.SERVICE=6]="SERVICE",a[a.DURABLE_OBJECT_NAMESPACE=7]="DURABLE_OBJECT_NAMESPACE",a[a.KV_NAMESPACE=8]="KV_NAMESPACE",a[a.R2BUCKET=9]="R2BUCKET",a[a.R2ADMIN=10]="R2ADMIN",a[a.QUEUE=11]="QUEUE",a[a.ANALYTICS_ENGINE=12]="ANALYTICS_ENGINE",a[a.HYPERDRIVE=13]="HYPERDRIVE"})(fv=rs.Worker_Binding_Type_Which||(rs.Worker_Binding_Type_Which={}));var zm=class extends oe.Struct{static{t(this,"Worker_Binding_Type")}isUnspecified(){return oe.Struct.getUint16(0,this)===0}setUnspecified(){oe.Struct.setUint16(0,0,this)}isText(){return oe.Struct.getUint16(0,this)===1}setText(){oe.Struct.setUint16(0,1,this)}isData(){return oe.Struct.getUint16(0,this)===2}setData(){oe.Struct.setUint16(0,2,this)}isJson(){return oe.Struct.getUint16(0,this)===3}setJson(){oe.Struct.setUint16(0,3,this)}isWasm(){return oe.Struct.getUint16(0,this)===4}setWasm(){oe.Struct.setUint16(0,4,this)}adoptCryptoKey(s){oe.Struct.setUint16(0,5,this),oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownCryptoKey(){return oe.Struct.disown(this.getCryptoKey())}getCryptoKey(){return oe.Struct.testWhich("cryptoKey",oe.Struct.getUint16(0,this),5,this),oe.Struct.getList(0,Zl.Uint16List,this)}hasCryptoKey(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initCryptoKey(s){return oe.Struct.setUint16(0,5,this),oe.Struct.initList(0,Zl.Uint16List,s,this)}isCryptoKey(){return oe.Struct.getUint16(0,this)===5}setCryptoKey(s){oe.Struct.setUint16(0,5,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}isService(){return oe.Struct.getUint16(0,this)===6}setService(){oe.Struct.setUint16(0,6,this)}isDurableObjectNamespace(){return oe.Struct.getUint16(0,this)===7}setDurableObjectNamespace(){oe.Struct.setUint16(0,7,this)}isKvNamespace(){return oe.Struct.getUint16(0,this)===8}setKvNamespace(){oe.Struct.setUint16(0,8,this)}isR2Bucket(){return oe.Struct.getUint16(0,this)===9}setR2Bucket(){oe.Struct.setUint16(0,9,this)}isR2Admin(){return oe.Struct.getUint16(0,this)===10}setR2Admin(){oe.Struct.setUint16(0,10,this)}isQueue(){return oe.Struct.getUint16(0,this)===11}setQueue(){oe.Struct.setUint16(0,11,this)}isAnalyticsEngine(){return oe.Struct.getUint16(0,this)===12}setAnalyticsEngine(){oe.Struct.setUint16(0,12,this)}isHyperdrive(){return oe.Struct.getUint16(0,this)===13}setHyperdrive(){oe.Struct.setUint16(0,13,this)}toString(){return"Worker_Binding_Type_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Binding_Type=zm;zm.UNSPECIFIED=fv.UNSPECIFIED;zm.TEXT=fv.TEXT;zm.DATA=fv.DATA;zm.JSON=fv.JSON;zm.WASM=fv.WASM;zm.CRYPTO_KEY=fv.CRYPTO_KEY;zm.SERVICE=fv.SERVICE;zm.DURABLE_OBJECT_NAMESPACE=fv.DURABLE_OBJECT_NAMESPACE;zm.KV_NAMESPACE=fv.KV_NAMESPACE;zm.R2BUCKET=fv.R2BUCKET;zm.R2ADMIN=fv.R2ADMIN;zm.QUEUE=fv.QUEUE;zm.ANALYTICS_ENGINE=fv.ANALYTICS_ENGINE;zm.HYPERDRIVE=fv.HYPERDRIVE;zm._capnp={displayName:"Type",id:"8906a1296519bf8a",size:new oe.ObjectSize(8,1)};var mF=class extends oe.Struct{static{t(this,"Worker_Binding_DurableObjectNamespaceDesignator")}getClassName(){return oe.Struct.getText(0,this)}setClassName(s){oe.Struct.setText(0,s,this)}getServiceName(){return oe.Struct.getText(1,this)}setServiceName(s){oe.Struct.setText(1,s,this)}toString(){return"Worker_Binding_DurableObjectNamespaceDesignator_"+super.toString()}};rs.Worker_Binding_DurableObjectNamespaceDesignator=mF;mF._capnp={displayName:"DurableObjectNamespaceDesignator",id:"804f144ff477aac7",size:new oe.ObjectSize(0,2)};var k2t;(function(a){a[a.ENCRYPT=0]="ENCRYPT",a[a.DECRYPT=1]="DECRYPT",a[a.SIGN=2]="SIGN",a[a.VERIFY=3]="VERIFY",a[a.DERIVE_KEY=4]="DERIVE_KEY",a[a.DERIVE_BITS=5]="DERIVE_BITS",a[a.WRAP_KEY=6]="WRAP_KEY",a[a.UNWRAP_KEY=7]="UNWRAP_KEY"})(k2t=rs.Worker_Binding_CryptoKey_Usage||(rs.Worker_Binding_CryptoKey_Usage={}));var aLe;(function(a){a[a.NAME=0]="NAME",a[a.JSON=1]="JSON"})(aLe=rs.Worker_Binding_CryptoKey_Algorithm_Which||(rs.Worker_Binding_CryptoKey_Algorithm_Which={}));var A4=class extends oe.Struct{static{t(this,"Worker_Binding_CryptoKey_Algorithm")}getName(){return oe.Struct.testWhich("name",oe.Struct.getUint16(2,this),0,this),oe.Struct.getText(1,this)}isName(){return oe.Struct.getUint16(2,this)===0}setName(s){oe.Struct.setUint16(2,0,this),oe.Struct.setText(1,s,this)}getJson(){return oe.Struct.testWhich("json",oe.Struct.getUint16(2,this),1,this),oe.Struct.getText(1,this)}isJson(){return oe.Struct.getUint16(2,this)===1}setJson(s){oe.Struct.setUint16(2,1,this),oe.Struct.setText(1,s,this)}toString(){return"Worker_Binding_CryptoKey_Algorithm_"+super.toString()}which(){return oe.Struct.getUint16(2,this)}};rs.Worker_Binding_CryptoKey_Algorithm=A4;A4.NAME=aLe.NAME;A4.JSON=aLe.JSON;A4._capnp={displayName:"algorithm",id:"a1a040c5e00d7021",size:new oe.ObjectSize(8,3)};var bF;(function(a){a[a.RAW=0]="RAW",a[a.HEX=1]="HEX",a[a.BASE64=2]="BASE64",a[a.PKCS8=3]="PKCS8",a[a.SPKI=4]="SPKI",a[a.JWK=5]="JWK"})(bF=rs.Worker_Binding_CryptoKey_Which||(rs.Worker_Binding_CryptoKey_Which={}));var Nb=class a extends oe.Struct{static{t(this,"Worker_Binding_CryptoKey")}adoptRaw(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownRaw(){return oe.Struct.disown(this.getRaw())}getRaw(){return oe.Struct.testWhich("raw",oe.Struct.getUint16(0,this),0,this),oe.Struct.getData(0,this)}hasRaw(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initRaw(s){return oe.Struct.setUint16(0,0,this),oe.Struct.initData(0,s,this)}isRaw(){return oe.Struct.getUint16(0,this)===0}setRaw(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}getHex(){return oe.Struct.testWhich("hex",oe.Struct.getUint16(0,this),1,this),oe.Struct.getText(0,this)}isHex(){return oe.Struct.getUint16(0,this)===1}setHex(s){oe.Struct.setUint16(0,1,this),oe.Struct.setText(0,s,this)}getBase64(){return oe.Struct.testWhich("base64",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(0,this)}isBase64(){return oe.Struct.getUint16(0,this)===2}setBase64(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(0,s,this)}getPkcs8(){return oe.Struct.testWhich("pkcs8",oe.Struct.getUint16(0,this),3,this),oe.Struct.getText(0,this)}isPkcs8(){return oe.Struct.getUint16(0,this)===3}setPkcs8(s){oe.Struct.setUint16(0,3,this),oe.Struct.setText(0,s,this)}getSpki(){return oe.Struct.testWhich("spki",oe.Struct.getUint16(0,this),4,this),oe.Struct.getText(0,this)}isSpki(){return oe.Struct.getUint16(0,this)===4}setSpki(s){oe.Struct.setUint16(0,4,this),oe.Struct.setText(0,s,this)}getJwk(){return oe.Struct.testWhich("jwk",oe.Struct.getUint16(0,this),5,this),oe.Struct.getText(0,this)}isJwk(){return oe.Struct.getUint16(0,this)===5}setJwk(s){oe.Struct.setUint16(0,5,this),oe.Struct.setText(0,s,this)}getAlgorithm(){return oe.Struct.getAs(A4,this)}initAlgorithm(){return oe.Struct.getAs(A4,this)}getExtractable(){return oe.Struct.getBit(32,this,a._capnp.defaultExtractable)}setExtractable(s){oe.Struct.setBit(32,s,this)}adoptUsages(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownUsages(){return oe.Struct.disown(this.getUsages())}getUsages(){return oe.Struct.getList(2,Zl.Uint16List,this)}hasUsages(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initUsages(s){return oe.Struct.initList(2,Zl.Uint16List,s,this)}setUsages(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Binding_CryptoKey_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Binding_CryptoKey=Nb;Nb.RAW=bF.RAW;Nb.HEX=bF.HEX;Nb.BASE64=bF.BASE64;Nb.PKCS8=bF.PKCS8;Nb.SPKI=bF.SPKI;Nb.JWK=bF.JWK;Nb.Usage=k2t;Nb._capnp={displayName:"CryptoKey",id:"b5e1bff0e57d6eb0",size:new oe.ObjectSize(8,3),defaultExtractable:Zl.getBitMask(!1,0)};var hF=class extends oe.Struct{static{t(this,"Worker_Binding_MemoryCacheLimits")}getMaxKeys(){return oe.Struct.getUint32(0,this)}setMaxKeys(s){oe.Struct.setUint32(0,s,this)}getMaxValueSize(){return oe.Struct.getUint32(4,this)}setMaxValueSize(s){oe.Struct.setUint32(4,s,this)}getMaxTotalValueSize(){return oe.Struct.getUint64(8,this)}setMaxTotalValueSize(s){oe.Struct.setUint64(8,s,this)}toString(){return"Worker_Binding_MemoryCacheLimits_"+super.toString()}};rs.Worker_Binding_MemoryCacheLimits=hF;hF._capnp={displayName:"MemoryCacheLimits",id:"8d66725b0867e634",size:new oe.ObjectSize(16,0)};var N4=class a extends oe.Struct{static{t(this,"Worker_Binding_WrappedBinding")}getModuleName(){return oe.Struct.getText(0,this)}setModuleName(s){oe.Struct.setText(0,s,this)}getEntrypoint(){return oe.Struct.getText(1,this,a._capnp.defaultEntrypoint)}setEntrypoint(s){oe.Struct.setText(1,s,this)}adoptInnerBindings(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownInnerBindings(){return oe.Struct.disown(this.getInnerBindings())}getInnerBindings(){return oe.Struct.getList(2,a._InnerBindings,this)}hasInnerBindings(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initInnerBindings(s){return oe.Struct.initList(2,a._InnerBindings,s,this)}setInnerBindings(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Binding_WrappedBinding_"+super.toString()}};rs.Worker_Binding_WrappedBinding=N4;N4._capnp={displayName:"WrappedBinding",id:"e6f066b75f0ea113",size:new oe.ObjectSize(0,3),defaultEntrypoint:"default"};var HB=class extends oe.Struct{static{t(this,"Worker_Binding_Parameter")}adoptType(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownType(){return oe.Struct.disown(this.getType())}getType(){return oe.Struct.getStruct(1,zm,this)}hasType(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initType(){return oe.Struct.initStructAt(1,zm,this)}setType(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getOptional(){return oe.Struct.getBit(16,this)}setOptional(s){oe.Struct.setBit(16,s,this)}toString(){return"Worker_Binding_Parameter_"+super.toString()}};rs.Worker_Binding_Parameter=HB;HB._capnp={displayName:"parameter",id:"dc57e1258d26d152",size:new oe.ObjectSize(8,6)};var GB=class extends oe.Struct{static{t(this,"Worker_Binding_Hyperdrive")}adoptDesignator(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDesignator(){return oe.Struct.disown(this.getDesignator())}getDesignator(){return oe.Struct.getStruct(1,ud,this)}hasDesignator(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDesignator(){return oe.Struct.initStructAt(1,ud,this)}setDesignator(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getDatabase(){return oe.Struct.getText(2,this)}setDatabase(s){oe.Struct.setText(2,s,this)}getUser(){return oe.Struct.getText(3,this)}setUser(s){oe.Struct.setText(3,s,this)}getPassword(){return oe.Struct.getText(4,this)}setPassword(s){oe.Struct.setText(4,s,this)}getScheme(){return oe.Struct.getText(5,this)}setScheme(s){oe.Struct.setText(5,s,this)}toString(){return"Worker_Binding_Hyperdrive_"+super.toString()}};rs.Worker_Binding_Hyperdrive=GB;GB._capnp={displayName:"hyperdrive",id:"ad6c391cd55f3134",size:new oe.ObjectSize(8,6)};var KB=class extends oe.Struct{static{t(this,"Worker_Binding_MemoryCache")}getId(){return oe.Struct.getText(1,this)}setId(s){oe.Struct.setText(1,s,this)}adoptLimits(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownLimits(){return oe.Struct.disown(this.getLimits())}getLimits(){return oe.Struct.getStruct(2,hF,this)}hasLimits(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initLimits(){return oe.Struct.initStructAt(2,hF,this)}setLimits(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Binding_MemoryCache_"+super.toString()}};rs.Worker_Binding_MemoryCache=KB;KB._capnp={displayName:"memoryCache",id:"aed5760c349869da",size:new oe.ObjectSize(8,6)};var uh;(function(a){a[a.UNSPECIFIED=0]="UNSPECIFIED",a[a.PARAMETER=1]="PARAMETER",a[a.TEXT=2]="TEXT",a[a.DATA=3]="DATA",a[a.JSON=4]="JSON",a[a.WASM_MODULE=5]="WASM_MODULE",a[a.CRYPTO_KEY=6]="CRYPTO_KEY",a[a.SERVICE=7]="SERVICE",a[a.DURABLE_OBJECT_NAMESPACE=8]="DURABLE_OBJECT_NAMESPACE",a[a.KV_NAMESPACE=9]="KV_NAMESPACE",a[a.R2BUCKET=10]="R2BUCKET",a[a.R2ADMIN=11]="R2ADMIN",a[a.WRAPPED=12]="WRAPPED",a[a.QUEUE=13]="QUEUE",a[a.FROM_ENVIRONMENT=14]="FROM_ENVIRONMENT",a[a.ANALYTICS_ENGINE=15]="ANALYTICS_ENGINE",a[a.HYPERDRIVE=16]="HYPERDRIVE",a[a.UNSAFE_EVAL=17]="UNSAFE_EVAL",a[a.MEMORY_CACHE=18]="MEMORY_CACHE"})(uh=rs.Worker_Binding_Which||(rs.Worker_Binding_Which={}));var Af=class extends oe.Struct{static{t(this,"Worker_Binding")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}isUnspecified(){return oe.Struct.getUint16(0,this)===0}setUnspecified(){oe.Struct.setUint16(0,0,this)}getParameter(){return oe.Struct.testWhich("parameter",oe.Struct.getUint16(0,this),1,this),oe.Struct.getAs(HB,this)}initParameter(){return oe.Struct.setUint16(0,1,this),oe.Struct.getAs(HB,this)}isParameter(){return oe.Struct.getUint16(0,this)===1}setParameter(){oe.Struct.setUint16(0,1,this)}getText(){return oe.Struct.testWhich("text",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(1,this)}isText(){return oe.Struct.getUint16(0,this)===2}setText(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(1,s,this)}adoptData(s){oe.Struct.setUint16(0,3,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownData(){return oe.Struct.disown(this.getData())}getData(){return oe.Struct.testWhich("data",oe.Struct.getUint16(0,this),3,this),oe.Struct.getData(1,this)}hasData(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initData(s){return oe.Struct.setUint16(0,3,this),oe.Struct.initData(1,s,this)}isData(){return oe.Struct.getUint16(0,this)===3}setData(s){oe.Struct.setUint16(0,3,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getJson(){return oe.Struct.testWhich("json",oe.Struct.getUint16(0,this),4,this),oe.Struct.getText(1,this)}isJson(){return oe.Struct.getUint16(0,this)===4}setJson(s){oe.Struct.setUint16(0,4,this),oe.Struct.setText(1,s,this)}adoptWasmModule(s){oe.Struct.setUint16(0,5,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWasmModule(){return oe.Struct.disown(this.getWasmModule())}getWasmModule(){return oe.Struct.testWhich("wasmModule",oe.Struct.getUint16(0,this),5,this),oe.Struct.getData(1,this)}hasWasmModule(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWasmModule(s){return oe.Struct.setUint16(0,5,this),oe.Struct.initData(1,s,this)}isWasmModule(){return oe.Struct.getUint16(0,this)===5}setWasmModule(s){oe.Struct.setUint16(0,5,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptCryptoKey(s){oe.Struct.setUint16(0,6,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownCryptoKey(){return oe.Struct.disown(this.getCryptoKey())}getCryptoKey(){return oe.Struct.testWhich("cryptoKey",oe.Struct.getUint16(0,this),6,this),oe.Struct.getStruct(1,Nb,this)}hasCryptoKey(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initCryptoKey(){return oe.Struct.setUint16(0,6,this),oe.Struct.initStructAt(1,Nb,this)}isCryptoKey(){return oe.Struct.getUint16(0,this)===6}setCryptoKey(s){oe.Struct.setUint16(0,6,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptService(s){oe.Struct.setUint16(0,7,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownService(){return oe.Struct.disown(this.getService())}getService(){return oe.Struct.testWhich("service",oe.Struct.getUint16(0,this),7,this),oe.Struct.getStruct(1,ud,this)}hasService(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initService(){return oe.Struct.setUint16(0,7,this),oe.Struct.initStructAt(1,ud,this)}isService(){return oe.Struct.getUint16(0,this)===7}setService(s){oe.Struct.setUint16(0,7,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptDurableObjectNamespace(s){oe.Struct.setUint16(0,8,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDurableObjectNamespace(){return oe.Struct.disown(this.getDurableObjectNamespace())}getDurableObjectNamespace(){return oe.Struct.testWhich("durableObjectNamespace",oe.Struct.getUint16(0,this),8,this),oe.Struct.getStruct(1,mF,this)}hasDurableObjectNamespace(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDurableObjectNamespace(){return oe.Struct.setUint16(0,8,this),oe.Struct.initStructAt(1,mF,this)}isDurableObjectNamespace(){return oe.Struct.getUint16(0,this)===8}setDurableObjectNamespace(s){oe.Struct.setUint16(0,8,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptKvNamespace(s){oe.Struct.setUint16(0,9,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownKvNamespace(){return oe.Struct.disown(this.getKvNamespace())}getKvNamespace(){return oe.Struct.testWhich("kvNamespace",oe.Struct.getUint16(0,this),9,this),oe.Struct.getStruct(1,ud,this)}hasKvNamespace(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initKvNamespace(){return oe.Struct.setUint16(0,9,this),oe.Struct.initStructAt(1,ud,this)}isKvNamespace(){return oe.Struct.getUint16(0,this)===9}setKvNamespace(s){oe.Struct.setUint16(0,9,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptR2Bucket(s){oe.Struct.setUint16(0,10,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownR2Bucket(){return oe.Struct.disown(this.getR2Bucket())}getR2Bucket(){return oe.Struct.testWhich("r2Bucket",oe.Struct.getUint16(0,this),10,this),oe.Struct.getStruct(1,ud,this)}hasR2Bucket(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initR2Bucket(){return oe.Struct.setUint16(0,10,this),oe.Struct.initStructAt(1,ud,this)}isR2Bucket(){return oe.Struct.getUint16(0,this)===10}setR2Bucket(s){oe.Struct.setUint16(0,10,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptR2Admin(s){oe.Struct.setUint16(0,11,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownR2Admin(){return oe.Struct.disown(this.getR2Admin())}getR2Admin(){return oe.Struct.testWhich("r2Admin",oe.Struct.getUint16(0,this),11,this),oe.Struct.getStruct(1,ud,this)}hasR2Admin(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initR2Admin(){return oe.Struct.setUint16(0,11,this),oe.Struct.initStructAt(1,ud,this)}isR2Admin(){return oe.Struct.getUint16(0,this)===11}setR2Admin(s){oe.Struct.setUint16(0,11,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptWrapped(s){oe.Struct.setUint16(0,12,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWrapped(){return oe.Struct.disown(this.getWrapped())}getWrapped(){return oe.Struct.testWhich("wrapped",oe.Struct.getUint16(0,this),12,this),oe.Struct.getStruct(1,N4,this)}hasWrapped(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWrapped(){return oe.Struct.setUint16(0,12,this),oe.Struct.initStructAt(1,N4,this)}isWrapped(){return oe.Struct.getUint16(0,this)===12}setWrapped(s){oe.Struct.setUint16(0,12,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptQueue(s){oe.Struct.setUint16(0,13,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownQueue(){return oe.Struct.disown(this.getQueue())}getQueue(){return oe.Struct.testWhich("queue",oe.Struct.getUint16(0,this),13,this),oe.Struct.getStruct(1,ud,this)}hasQueue(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initQueue(){return oe.Struct.setUint16(0,13,this),oe.Struct.initStructAt(1,ud,this)}isQueue(){return oe.Struct.getUint16(0,this)===13}setQueue(s){oe.Struct.setUint16(0,13,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getFromEnvironment(){return oe.Struct.testWhich("fromEnvironment",oe.Struct.getUint16(0,this),14,this),oe.Struct.getText(1,this)}isFromEnvironment(){return oe.Struct.getUint16(0,this)===14}setFromEnvironment(s){oe.Struct.setUint16(0,14,this),oe.Struct.setText(1,s,this)}adoptAnalyticsEngine(s){oe.Struct.setUint16(0,15,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownAnalyticsEngine(){return oe.Struct.disown(this.getAnalyticsEngine())}getAnalyticsEngine(){return oe.Struct.testWhich("analyticsEngine",oe.Struct.getUint16(0,this),15,this),oe.Struct.getStruct(1,ud,this)}hasAnalyticsEngine(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initAnalyticsEngine(){return oe.Struct.setUint16(0,15,this),oe.Struct.initStructAt(1,ud,this)}isAnalyticsEngine(){return oe.Struct.getUint16(0,this)===15}setAnalyticsEngine(s){oe.Struct.setUint16(0,15,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getHyperdrive(){return oe.Struct.testWhich("hyperdrive",oe.Struct.getUint16(0,this),16,this),oe.Struct.getAs(GB,this)}initHyperdrive(){return oe.Struct.setUint16(0,16,this),oe.Struct.getAs(GB,this)}isHyperdrive(){return oe.Struct.getUint16(0,this)===16}setHyperdrive(){oe.Struct.setUint16(0,16,this)}isUnsafeEval(){return oe.Struct.getUint16(0,this)===17}setUnsafeEval(){oe.Struct.setUint16(0,17,this)}getMemoryCache(){return oe.Struct.testWhich("memoryCache",oe.Struct.getUint16(0,this),18,this),oe.Struct.getAs(KB,this)}initMemoryCache(){return oe.Struct.setUint16(0,18,this),oe.Struct.getAs(KB,this)}isMemoryCache(){return oe.Struct.getUint16(0,this)===18}setMemoryCache(){oe.Struct.setUint16(0,18,this)}toString(){return"Worker_Binding_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Binding=Af;Af.UNSPECIFIED=uh.UNSPECIFIED;Af.PARAMETER=uh.PARAMETER;Af.TEXT=uh.TEXT;Af.DATA=uh.DATA;Af.JSON=uh.JSON;Af.WASM_MODULE=uh.WASM_MODULE;Af.CRYPTO_KEY=uh.CRYPTO_KEY;Af.SERVICE=uh.SERVICE;Af.DURABLE_OBJECT_NAMESPACE=uh.DURABLE_OBJECT_NAMESPACE;Af.KV_NAMESPACE=uh.KV_NAMESPACE;Af.R2BUCKET=uh.R2BUCKET;Af.R2ADMIN=uh.R2ADMIN;Af.WRAPPED=uh.WRAPPED;Af.QUEUE=uh.QUEUE;Af.FROM_ENVIRONMENT=uh.FROM_ENVIRONMENT;Af.ANALYTICS_ENGINE=uh.ANALYTICS_ENGINE;Af.HYPERDRIVE=uh.HYPERDRIVE;Af.UNSAFE_EVAL=uh.UNSAFE_EVAL;Af.MEMORY_CACHE=uh.MEMORY_CACHE;Af.Type=zm;Af.DurableObjectNamespaceDesignator=mF;Af.CryptoKey=Nb;Af.MemoryCacheLimits=hF;Af.WrappedBinding=N4;Af._capnp={displayName:"Binding",id:"8e7e492fd7e35f3e",size:new oe.ObjectSize(8,6)};var oLe;(function(a){a[a.UNIQUE_KEY=0]="UNIQUE_KEY",a[a.EPHEMERAL_LOCAL=1]="EPHEMERAL_LOCAL"})(oLe=rs.Worker_DurableObjectNamespace_Which||(rs.Worker_DurableObjectNamespace_Which={}));var I4=class extends oe.Struct{static{t(this,"Worker_DurableObjectNamespace")}getClassName(){return oe.Struct.getText(0,this)}setClassName(s){oe.Struct.setText(0,s,this)}getUniqueKey(){return oe.Struct.testWhich("uniqueKey",oe.Struct.getUint16(0,this),0,this),oe.Struct.getText(1,this)}isUniqueKey(){return oe.Struct.getUint16(0,this)===0}setUniqueKey(s){oe.Struct.setUint16(0,0,this),oe.Struct.setText(1,s,this)}isEphemeralLocal(){return oe.Struct.getUint16(0,this)===1}setEphemeralLocal(){oe.Struct.setUint16(0,1,this)}getPreventEviction(){return oe.Struct.getBit(16,this)}setPreventEviction(s){oe.Struct.setBit(16,s,this)}getEnableSql(){return oe.Struct.getBit(17,this)}setEnableSql(s){oe.Struct.setBit(17,s,this)}toString(){return"Worker_DurableObjectNamespace_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_DurableObjectNamespace=I4;I4.UNIQUE_KEY=oLe.UNIQUE_KEY;I4.EPHEMERAL_LOCAL=oLe.EPHEMERAL_LOCAL;I4._capnp={displayName:"DurableObjectNamespace",id:"b429dd547d15747d",size:new oe.ObjectSize(8,2)};var ude;(function(a){a[a.NONE=0]="NONE",a[a.IN_MEMORY=1]="IN_MEMORY",a[a.LOCAL_DISK=2]="LOCAL_DISK"})(ude=rs.Worker_DurableObjectStorage_Which||(rs.Worker_DurableObjectStorage_Which={}));var GA=class extends oe.Struct{static{t(this,"Worker_DurableObjectStorage")}isNone(){return oe.Struct.getUint16(2,this)===0}setNone(){oe.Struct.setUint16(2,0,this)}isInMemory(){return oe.Struct.getUint16(2,this)===1}setInMemory(){oe.Struct.setUint16(2,1,this)}getLocalDisk(){return oe.Struct.testWhich("localDisk",oe.Struct.getUint16(2,this),2,this),oe.Struct.getText(8,this)}isLocalDisk(){return oe.Struct.getUint16(2,this)===2}setLocalDisk(s){oe.Struct.setUint16(2,2,this),oe.Struct.setText(8,s,this)}toString(){return"Worker_DurableObjectStorage_"+super.toString()}which(){return oe.Struct.getUint16(2,this)}};rs.Worker_DurableObjectStorage=GA;GA.NONE=ude.NONE;GA.IN_MEMORY=ude.IN_MEMORY;GA.LOCAL_DISK=ude.LOCAL_DISK;GA._capnp={displayName:"durableObjectStorage",id:"cc72b3faa57827d4",size:new oe.ObjectSize(8,10)};var fde;(function(a){a[a.MODULES=0]="MODULES",a[a.SERVICE_WORKER_SCRIPT=1]="SERVICE_WORKER_SCRIPT",a[a.INHERIT=2]="INHERIT"})(fde=rs.Worker_Which||(rs.Worker_Which={}));var uv=class a extends oe.Struct{static{t(this,"Worker")}adoptModules(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownModules(){return oe.Struct.disown(this.getModules())}getModules(){return oe.Struct.testWhich("modules",oe.Struct.getUint16(0,this),0,this),oe.Struct.getList(0,a._Modules,this)}hasModules(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initModules(s){return oe.Struct.setUint16(0,0,this),oe.Struct.initList(0,a._Modules,s,this)}isModules(){return oe.Struct.getUint16(0,this)===0}setModules(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}getServiceWorkerScript(){return oe.Struct.testWhich("serviceWorkerScript",oe.Struct.getUint16(0,this),1,this),oe.Struct.getText(0,this)}isServiceWorkerScript(){return oe.Struct.getUint16(0,this)===1}setServiceWorkerScript(s){oe.Struct.setUint16(0,1,this),oe.Struct.setText(0,s,this)}getInherit(){return oe.Struct.testWhich("inherit",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(0,this)}isInherit(){return oe.Struct.getUint16(0,this)===2}setInherit(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(0,s,this)}getCompatibilityDate(){return oe.Struct.getText(1,this)}setCompatibilityDate(s){oe.Struct.setText(1,s,this)}adoptCompatibilityFlags(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownCompatibilityFlags(){return oe.Struct.disown(this.getCompatibilityFlags())}getCompatibilityFlags(){return oe.Struct.getList(2,Zl.TextList,this)}hasCompatibilityFlags(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initCompatibilityFlags(s){return oe.Struct.initList(2,Zl.TextList,s,this)}setCompatibilityFlags(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptBindings(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownBindings(){return oe.Struct.disown(this.getBindings())}getBindings(){return oe.Struct.getList(3,a._Bindings,this)}hasBindings(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initBindings(s){return oe.Struct.initList(3,a._Bindings,s,this)}setBindings(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}adoptGlobalOutbound(s){oe.Struct.adopt(s,oe.Struct.getPointer(4,this))}disownGlobalOutbound(){return oe.Struct.disown(this.getGlobalOutbound())}getGlobalOutbound(){return oe.Struct.getStruct(4,ud,this,a._capnp.defaultGlobalOutbound)}hasGlobalOutbound(){return!oe.Struct.isNull(oe.Struct.getPointer(4,this))}initGlobalOutbound(){return oe.Struct.initStructAt(4,ud,this)}setGlobalOutbound(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(4,this))}adoptCacheApiOutbound(s){oe.Struct.adopt(s,oe.Struct.getPointer(7,this))}disownCacheApiOutbound(){return oe.Struct.disown(this.getCacheApiOutbound())}getCacheApiOutbound(){return oe.Struct.getStruct(7,ud,this)}hasCacheApiOutbound(){return!oe.Struct.isNull(oe.Struct.getPointer(7,this))}initCacheApiOutbound(){return oe.Struct.initStructAt(7,ud,this)}setCacheApiOutbound(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(7,this))}adoptDurableObjectNamespaces(s){oe.Struct.adopt(s,oe.Struct.getPointer(5,this))}disownDurableObjectNamespaces(){return oe.Struct.disown(this.getDurableObjectNamespaces())}getDurableObjectNamespaces(){return oe.Struct.getList(5,a._DurableObjectNamespaces,this)}hasDurableObjectNamespaces(){return!oe.Struct.isNull(oe.Struct.getPointer(5,this))}initDurableObjectNamespaces(s){return oe.Struct.initList(5,a._DurableObjectNamespaces,s,this)}setDurableObjectNamespaces(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(5,this))}getDurableObjectUniqueKeyModifier(){return oe.Struct.getText(6,this)}setDurableObjectUniqueKeyModifier(s){oe.Struct.setText(6,s,this)}getDurableObjectStorage(){return oe.Struct.getAs(GA,this)}initDurableObjectStorage(){return oe.Struct.getAs(GA,this)}getModuleFallback(){return oe.Struct.getText(9,this)}setModuleFallback(s){oe.Struct.setText(9,s,this)}toString(){return"Worker_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker=uv;uv.MODULES=fde.MODULES;uv.SERVICE_WORKER_SCRIPT=fde.SERVICE_WORKER_SCRIPT;uv.INHERIT=fde.INHERIT;uv.Module=lv;uv.Binding=Af;uv.DurableObjectNamespace=I4;uv._capnp={displayName:"Worker",id:"acfa77e88fd97d1c",size:new oe.ObjectSize(8,10),defaultGlobalOutbound:Zl.readRawPointer(new Uint8Array([16,5,64,2,17,5,74,0,0,255,105,110,116,101,114,110,101,116,0,0,0]).buffer)};var YB=class extends oe.Struct{static{t(this,"ExternalServer_Https")}adoptOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownOptions(){return oe.Struct.disown(this.getOptions())}getOptions(){return oe.Struct.getStruct(1,Zy,this)}hasOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initOptions(){return oe.Struct.initStructAt(1,Zy,this)}setOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(2,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initTlsOptions(){return oe.Struct.initStructAt(2,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}getCertificateHost(){return oe.Struct.getText(3,this)}setCertificateHost(s){oe.Struct.setText(3,s,this)}toString(){return"ExternalServer_Https_"+super.toString()}};rs.ExternalServer_Https=YB;YB._capnp={displayName:"https",id:"ac37e02afd3dc6db",size:new oe.ObjectSize(8,4)};var XB=class extends oe.Struct{static{t(this,"ExternalServer_Tcp")}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(1,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initTlsOptions(){return oe.Struct.initStructAt(1,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getCertificateHost(){return oe.Struct.getText(2,this)}setCertificateHost(s){oe.Struct.setText(2,s,this)}toString(){return"ExternalServer_Tcp_"+super.toString()}};rs.ExternalServer_Tcp=XB;XB._capnp={displayName:"tcp",id:"d941637df0fb39f1",size:new oe.ObjectSize(8,4)};var _de;(function(a){a[a.HTTP=0]="HTTP",a[a.HTTPS=1]="HTTPS",a[a.TCP=2]="TCP"})(_de=rs.ExternalServer_Which||(rs.ExternalServer_Which={}));var KA=class extends oe.Struct{static{t(this,"ExternalServer")}getAddress(){return oe.Struct.getText(0,this)}setAddress(s){oe.Struct.setText(0,s,this)}adoptHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownHttp(){return oe.Struct.disown(this.getHttp())}getHttp(){return oe.Struct.testWhich("http",oe.Struct.getUint16(0,this),0,this),oe.Struct.getStruct(1,Zy,this)}hasHttp(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initHttp(){return oe.Struct.setUint16(0,0,this),oe.Struct.initStructAt(1,Zy,this)}isHttp(){return oe.Struct.getUint16(0,this)===0}setHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getHttps(){return oe.Struct.testWhich("https",oe.Struct.getUint16(0,this),1,this),oe.Struct.getAs(YB,this)}initHttps(){return oe.Struct.setUint16(0,1,this),oe.Struct.getAs(YB,this)}isHttps(){return oe.Struct.getUint16(0,this)===1}setHttps(){oe.Struct.setUint16(0,1,this)}getTcp(){return oe.Struct.testWhich("tcp",oe.Struct.getUint16(0,this),2,this),oe.Struct.getAs(XB,this)}initTcp(){return oe.Struct.setUint16(0,2,this),oe.Struct.getAs(XB,this)}isTcp(){return oe.Struct.getUint16(0,this)===2}setTcp(){oe.Struct.setUint16(0,2,this)}toString(){return"ExternalServer_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.ExternalServer=KA;KA.HTTP=_de.HTTP;KA.HTTPS=_de.HTTPS;KA.TCP=_de.TCP;KA._capnp={displayName:"ExternalServer",id:"ff209f9aa352f5a4",size:new oe.ObjectSize(8,4)};var ZB=class a extends oe.Struct{static{t(this,"Network")}adoptAllow(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownAllow(){return oe.Struct.disown(this.getAllow())}getAllow(){return oe.Struct.getList(0,Zl.TextList,this,a._capnp.defaultAllow)}hasAllow(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initAllow(s){return oe.Struct.initList(0,Zl.TextList,s,this)}setAllow(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}adoptDeny(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDeny(){return oe.Struct.disown(this.getDeny())}getDeny(){return oe.Struct.getList(1,Zl.TextList,this)}hasDeny(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDeny(s){return oe.Struct.initList(1,Zl.TextList,s,this)}setDeny(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(2,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initTlsOptions(){return oe.Struct.initStructAt(2,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Network_"+super.toString()}};rs.Network=ZB;ZB._capnp={displayName:"Network",id:"fa42244f950c9b9c",size:new oe.ObjectSize(0,3),defaultAllow:Zl.readRawPointer(new Uint8Array([16,3,17,1,14,17,1,58,63,112,117,98,108,105,99]).buffer)};var QB=class a extends oe.Struct{static{t(this,"DiskDirectory")}getPath(){return oe.Struct.getText(0,this)}setPath(s){oe.Struct.setText(0,s,this)}getWritable(){return oe.Struct.getBit(0,this,a._capnp.defaultWritable)}setWritable(s){oe.Struct.setBit(0,s,this)}getAllowDotfiles(){return oe.Struct.getBit(1,this,a._capnp.defaultAllowDotfiles)}setAllowDotfiles(s){oe.Struct.setBit(1,s,this)}toString(){return"DiskDirectory_"+super.toString()}};rs.DiskDirectory=QB;QB._capnp={displayName:"DiskDirectory",id:"9048ab22835f51c3",size:new oe.ObjectSize(8,1),defaultWritable:Zl.getBitMask(!1,0),defaultAllowDotfiles:Zl.getBitMask(!1,1)};var D2t;(function(a){a[a.HOST=0]="HOST",a[a.PROXY=1]="PROXY"})(D2t=rs.HttpOptions_Style||(rs.HttpOptions_Style={}));var gF=class extends oe.Struct{static{t(this,"HttpOptions_Header")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getValue(){return oe.Struct.getText(1,this)}setValue(s){oe.Struct.setText(1,s,this)}toString(){return"HttpOptions_Header_"+super.toString()}};rs.HttpOptions_Header=gF;gF._capnp={displayName:"Header",id:"dc0394b5a6f3417e",size:new oe.ObjectSize(0,2)};var Zy=class a extends oe.Struct{static{t(this,"HttpOptions")}getStyle(){return oe.Struct.getUint16(0,this,a._capnp.defaultStyle)}setStyle(s){oe.Struct.setUint16(0,s,this)}getForwardedProtoHeader(){return oe.Struct.getText(0,this)}setForwardedProtoHeader(s){oe.Struct.setText(0,s,this)}getCfBlobHeader(){return oe.Struct.getText(1,this)}setCfBlobHeader(s){oe.Struct.setText(1,s,this)}adoptInjectRequestHeaders(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownInjectRequestHeaders(){return oe.Struct.disown(this.getInjectRequestHeaders())}getInjectRequestHeaders(){return oe.Struct.getList(2,a._InjectRequestHeaders,this)}hasInjectRequestHeaders(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initInjectRequestHeaders(s){return oe.Struct.initList(2,a._InjectRequestHeaders,s,this)}setInjectRequestHeaders(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptInjectResponseHeaders(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownInjectResponseHeaders(){return oe.Struct.disown(this.getInjectResponseHeaders())}getInjectResponseHeaders(){return oe.Struct.getList(3,a._InjectResponseHeaders,this)}hasInjectResponseHeaders(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initInjectResponseHeaders(s){return oe.Struct.initList(3,a._InjectResponseHeaders,s,this)}setInjectResponseHeaders(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}getCapnpConnectHost(){return oe.Struct.getText(4,this)}setCapnpConnectHost(s){oe.Struct.setText(4,s,this)}toString(){return"HttpOptions_"+super.toString()}};rs.HttpOptions=Zy;Zy.Style=D2t;Zy.Header=gF;Zy._capnp={displayName:"HttpOptions",id:"aa8dc6885da78f19",size:new oe.ObjectSize(8,5),defaultStyle:Zl.getUint16Mask(0)};var yF=class extends oe.Struct{static{t(this,"TlsOptions_Keypair")}getPrivateKey(){return oe.Struct.getText(0,this)}setPrivateKey(s){oe.Struct.setText(0,s,this)}getCertificateChain(){return oe.Struct.getText(1,this)}setCertificateChain(s){oe.Struct.setText(1,s,this)}toString(){return"TlsOptions_Keypair_"+super.toString()}};rs.TlsOptions_Keypair=yF;yF._capnp={displayName:"Keypair",id:"f546bf2d5d8bd13e",size:new oe.ObjectSize(0,2)};var P2t;(function(a){a[a.GOOD_DEFAULT=0]="GOOD_DEFAULT",a[a.SSL3=1]="SSL3",a[a.TLS1DOT0=2]="TLS1DOT0",a[a.TLS1DOT1=3]="TLS1DOT1",a[a.TLS1DOT2=4]="TLS1DOT2",a[a.TLS1DOT3=5]="TLS1DOT3"})(P2t=rs.TlsOptions_Version||(rs.TlsOptions_Version={}));var Ib=class a extends oe.Struct{static{t(this,"TlsOptions")}adoptKeypair(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownKeypair(){return oe.Struct.disown(this.getKeypair())}getKeypair(){return oe.Struct.getStruct(0,yF,this)}hasKeypair(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initKeypair(){return oe.Struct.initStructAt(0,yF,this)}setKeypair(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}getRequireClientCerts(){return oe.Struct.getBit(0,this,a._capnp.defaultRequireClientCerts)}setRequireClientCerts(s){oe.Struct.setBit(0,s,this)}getTrustBrowserCas(){return oe.Struct.getBit(1,this,a._capnp.defaultTrustBrowserCas)}setTrustBrowserCas(s){oe.Struct.setBit(1,s,this)}adoptTrustedCertificates(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownTrustedCertificates(){return oe.Struct.disown(this.getTrustedCertificates())}getTrustedCertificates(){return oe.Struct.getList(1,Zl.TextList,this)}hasTrustedCertificates(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initTrustedCertificates(s){return oe.Struct.initList(1,Zl.TextList,s,this)}setTrustedCertificates(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getMinVersion(){return oe.Struct.getUint16(2,this,a._capnp.defaultMinVersion)}setMinVersion(s){oe.Struct.setUint16(2,s,this)}getCipherList(){return oe.Struct.getText(2,this)}setCipherList(s){oe.Struct.setText(2,s,this)}toString(){return"TlsOptions_"+super.toString()}};rs.TlsOptions=Ib;Ib.Keypair=yF;Ib.Version=P2t;Ib._capnp={displayName:"TlsOptions",id:"aabb3c3778ac4311",size:new oe.ObjectSize(8,3),defaultRequireClientCerts:Zl.getBitMask(!1,0),defaultTrustBrowserCas:Zl.getBitMask(!1,1),defaultMinVersion:Zl.getUint16Mask(0)};var e$=class a extends oe.Struct{static{t(this,"Extension_Module")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getInternal(){return oe.Struct.getBit(0,this,a._capnp.defaultInternal)}setInternal(s){oe.Struct.setBit(0,s,this)}getEsModule(){return oe.Struct.getText(1,this)}setEsModule(s){oe.Struct.setText(1,s,this)}toString(){return"Extension_Module_"+super.toString()}};rs.Extension_Module=e$;e$._capnp={displayName:"Module",id:"d5d16e76fdedc37d",size:new oe.ObjectSize(8,2),defaultInternal:Zl.getBitMask(!1,0)};var vF=class a extends oe.Struct{static{t(this,"Extension")}adoptModules(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownModules(){return oe.Struct.disown(this.getModules())}getModules(){return oe.Struct.getList(0,a._Modules,this)}hasModules(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initModules(s){return oe.Struct.initList(0,a._Modules,s,this)}setModules(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}toString(){return"Extension_"+super.toString()}};rs.Extension=vF;vF.Module=e$;vF._capnp={displayName:"Extension",id:"e390128a861973a6",size:new oe.ObjectSize(0,1)};pF._Services=Zl.CompositeList(Uk);pF._Sockets=Zl.CompositeList(dF);pF._Extensions=Zl.CompositeList(vF);N4._InnerBindings=Zl.CompositeList(Af);uv._Modules=Zl.CompositeList(lv);uv._Bindings=Zl.CompositeList(Af);uv._DurableObjectNamespaces=Zl.CompositeList(I4);Zy._InjectRequestHeaders=Zl.CompositeList(gF);Zy._InjectResponseHeaders=Zl.CompositeList(gF);vF._Modules=Zl.CompositeList(e$)});var uLe=Et(Jk=>{"use strict";Object.defineProperty(Jk,"__esModule",{value:!0});Jk.kVoid=Jk.Worker_Binding_CryptoKey_Usage=Jk.TlsOptions_Version=Jk.HttpOptions_Style=void 0;var lLe=cLe();Object.defineProperty(Jk,"HttpOptions_Style",{enumerable:!0,get:t(function(){return lLe.HttpOptions_Style},"get")});Object.defineProperty(Jk,"TlsOptions_Version",{enumerable:!0,get:t(function(){return lLe.TlsOptions_Version},"get")});Object.defineProperty(Jk,"Worker_Binding_CryptoKey_Usage",{enumerable:!0,get:t(function(){return lLe.Worker_Binding_CryptoKey_Usage},"get")});Jk.kVoid=Symbol("kVoid")});var _Le=Et(O4=>{"use strict";var XAr=O4&&O4.__createBinding||(Object.create?function(a,s,l,_){_===void 0&&(_=l);var h=Object.getOwnPropertyDescriptor(s,l);(!h||("get"in h?!s.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:t(function(){return s[l]},"get")}),Object.defineProperty(a,_,h)}:function(a,s,l,_){_===void 0&&(_=l),a[_]=s[l]}),ZAr=O4&&O4.__exportStar||function(a,s){for(var l in a)l!=="default"&&!Object.prototype.hasOwnProperty.call(s,l)&&XAr(s,a,l)};Object.defineProperty(O4,"__esModule",{value:!0});O4.serializeConfig=n6r;var QAr=lde(),e6r=uLe(),t6r=cLe();function r6r(a){return a.length>0?a[0].toUpperCase()+a.substring(1):a}t(r6r,"capitalize");function fLe(a,s){let l=s;for(let[_,h]of Object.entries(a)){let b=r6r(_);if(h instanceof Uint8Array)l[`init${b}`](h.byteLength).copyBuffer(h);else if(Array.isArray(h)){let w=l[`init${b}`](h.length);for(let N=0;N<h.length;N++)typeof h[N]=="object"?fLe(h[N],w.get(N)):w.set(N,h[N])}else if(typeof h=="object"){let w=l[`init${b}`]();fLe(h,w)}else h===e6r.kVoid?l[`set${b}`]():h!==void 0&&l[`set${b}`](h)}}t(fLe,"encodeCapnpStruct");function n6r(a){let s=new QAr.Message,l=s.initRoot(t6r.Config);return fLe(a,l),Buffer.from(s.toArrayBuffer())}t(n6r,"serializeConfig");ZAr(uLe(),O4)});var R2t=Et(fh=>{"use strict";var F2t=fh&&fh.__createBinding||(Object.create?function(a,s,l,_){_===void 0&&(_=l);var h=Object.getOwnPropertyDescriptor(s,l);(!h||("get"in h?!s.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:t(function(){return s[l]},"get")}),Object.defineProperty(a,_,h)}:function(a,s,l,_){_===void 0&&(_=l),a[_]=s[l]}),i6r=fh&&fh.__setModuleDefault||(Object.create?function(a,s){Object.defineProperty(a,"default",{enumerable:!0,value:s})}:function(a,s){a.default=s}),s6r=fh&&fh.__importStar||function(){var a=t(function(s){return a=Object.getOwnPropertyNames||function(l){var _=[];for(var h in l)Object.prototype.hasOwnProperty.call(l,h)&&(_[_.length]=h);return _},a(s)},"ownKeys");return function(s){if(s&&s.__esModule)return s;var l={};if(s!=null)for(var _=a(s),h=0;h<_.length;h++)_[h]!=="default"&&F2t(l,s,_[h]);return i6r(l,s),l}}(),a6r=fh&&fh.__exportStar||function(a,s){for(var l in a)l!=="default"&&!Object.prototype.hasOwnProperty.call(s,l)&&F2t(s,a,l)},hLe=fh&&fh.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(fh,"__esModule",{value:!0});fh.supportedCompatibilityDate=fh.Runtime=fh.kInspectorSocket=void 0;var o6r=hLe(_o("node:assert")),A2t=hLe(_o("node:child_process")),pLe=_o("node:events"),N2t=_o("node:fs"),dLe=hLe(_o("node:readline")),c6r=_o("node:stream"),L2t=s6r(_o("workerd"));Object.defineProperty(fh,"supportedCompatibilityDate",{enumerable:!0,get:t(function(){return L2t.compatibilityDate},"get")});fh.kInspectorSocket=Symbol("kInspectorSocket");async function l6r(a,s){if(s?.signal?.aborted)return;let l=dLe.default.createInterface(a),_=t(()=>l.close(),"abortListener");s?.signal?.addEventListener("abort",_,{once:!0});let h=Array.from(s.requiredSockets),b=new Map;try{for await(let w of l){let N=JSON.parse(w),B=N.event==="listen-inspector"?fh.kInspectorSocket:N.socket,q=h.indexOf(B);if(q!==-1&&(b.set(B,N.port),h.splice(q,1),h.length===0))return b}}finally{s?.signal?.removeEventListener("abort",_)}}t(l6r,"waitForPorts");function I2t(a){return new Promise(s=>{a.once("exit",()=>s())})}t(I2t,"waitForExit");function u6r(a,s){dLe.default.createInterface(a).on("line",l=>console.log(l)),dLe.default.createInterface(s).on("line",l=>console.error(l))}t(u6r,"pipeOutput");function O2t(){return L2t.default}t(O2t,"getRuntimeCommand");function f6r(a){let s=["serve","--binary","--experimental","--control-fd=3","-"];return a.inspectorAddress!==void 0&&s.push(`--inspector-addr=localhost:${a.inspectorAddress}`),a.verbose&&s.push("--verbose"),s}t(f6r,"getServeArgs");function _6r(a){let s=["compile","--binary","-"];return a.verbose&&s.push("--verbose"),s}t(_6r,"getCompileArgs");var mLe=class{static{t(this,"Runtime")}process;processExitPromise;async updateConfig(s,l){await this.dispose();let _=O2t(),h=f6r(l),w=A2t.default.spawn(_,h,{stdio:["pipe","pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}});this.process=w,this.processExitPromise=I2t(w),(l.handleRuntimeStdio??u6r)(w.stdout,w.stderr);let B=w.stdio[3];return(0,o6r.default)(B instanceof c6r.Readable),w.stdin.write(s),w.stdin.end(),await(0,pLe.once)(w.stdin,"finish"),l6r(B,l)}async compileBinary(s,l){await this.dispose();let _=O2t(),h=_6r(l),b=A2t.default.spawn(_,h,{stdio:["pipe","pipe","pipe"],env:{...process.env}});this.process=b,this.processExitPromise=I2t(b),b.stdin.write(s),b.stdin.end(),await(0,pLe.once)(b.stdin,"finish");let w=(0,N2t.createWriteStream)(l.binaryPath);b.stdout.pipe(w),await(0,pLe.once)(b.stdout,"finish"),(0,N2t.chmodSync)(l.binaryPath,493),await this.dispose()}dispose(){return this.process?.kill("SIGKILL"),this.processExitPromise}};fh.Runtime=mLe;a6r(_Le(),fh)});var M2t=Et(pde=>{"use strict";Object.defineProperty(pde,"__esModule",{value:!0});pde.ZUPLO_CACHE_EXTENSION=void 0;pde.ZUPLO_CACHE_EXTENSION='var X=Object.defineProperty;var s=(e,t)=>X(e,"name",{value:t,configurable:!0});import{Buffer as N}from"node:buffer";var R={AGE:"age",NAMESPACE:"cf-cache-namespace",STATUS:"cf-cache-status"};import{connect as D}from"cloudflare:sockets";var C="*",_="$",k=C.charCodeAt(0),v=124,M=40,W=33,$=35,j=_.charCodeAt(0),K=44,Z=45,V=58,J=37,Y=95,Q=62,z=126,q=43,ee=61,E=new TextEncoder,g=new TextDecoder,T=`\\r\n`,x=E.encode(T),m=class{static{s(this,"MinimalRedisClient")}socket;reader;writer;constructor(t){this.socket=D({hostname:t.redisHost,port:t.redisPort},{secureTransport:"starttls",allowHalfOpen:!0}),this.reader=this.socket.readable.getReader(),this.writer=this.socket.writable.getWriter()}async sendCommand(t,r=!1){return await ye(this.reader,this.writer,t,r)}};function L(e){let t=0;for(let n of e)t+=n.length;let r=new Uint8Array(t),a=0;for(let n of e)r.set(n,a),a+=n.length;return r}s(L,"concat");function te(e){let t=[E.encode(C+e.length+T)];for(let r of e){let a=r instanceof Uint8Array?r:E.encode(r.toString());t.push(E.encode(_+a.byteLength+T)),t.push(a),t.push(x)}return L(t)}s(te,"createRequest");async function re(e,t){let r=te(t);await e.write(r)}s(re,"writeCommand");function A(e){return g.decode(e.slice(1))}s(A,"removePrefix");function ne(e){return Object.fromEntries(fe(e,2))}s(ne,"toObject");async function H(e,t,r=!1){let a=[];for(let n=0;n<e;n++)a.push(await S(t,r));return a}s(H,"readNReplies");async function O(e,t){let r=b(e);return r===-1?null:await H(r,t)}s(O,"readArray");async function ae(e,t,r=!1){return await F(e,t),await S(t,r)}s(ae,"readAttribute");function se(e){return BigInt(A(e))}s(se,"readBigNumber");async function oe(e){let{value:t}=await e.next();return await Promise.reject(g.decode(t))}s(oe,"readBlobError");function ce(e){return A(e)==="t"}s(ce,"readBoolean");async function ie(e,t,r=!1){if(b(e)===-1)return null;let{value:a}=await t.next();return r?a:g.decode(a)}s(ie,"readBulkOrVerbatimString");async function le(e){return await Promise.reject(A(e))}s(le,"readError");async function F(e,t){let r=b(e)*2,a=await H(r,t);return ne(a)}s(F,"readMap");function b(e){let t=A(e);switch(t){case"inf":return 1/0;case"-inf":return-1/0;default:return Number(t)}}s(b,"readNumberOrDouble");async function ue(e,t){return new Set(await O(e,t))}s(ue,"readSet");function de(e){return A(e)}s(de,"readSimpleString");async function S(e,t=!1){let{value:r}=await e.next();if(r.length===0)return await Promise.reject(new TypeError("No reply received"));switch(r[0]){case k:case Q:return await O(r,e);case v:return await ae(r,e);case M:return se(r);case W:return oe(e);case $:return ce(r);case j:case ee:return await ie(r,e,t);case K:case V:return b(r);case Z:return le(r);case J:return await F(r,e);case Y:return null;case z:return await ue(r,e);case q:return de(r);default:return g.decode(r)}}s(S,"readReply");async function ye(e,t,r,a=!1){return await re(t,r),await S(he(e,x),a)}s(ye,"sendCommand");function fe(e,t){if(t<=0||!Number.isInteger(t))throw new Error(`Expected size to be an integer greater than 0 but found ${t}`);if(e.length===0)return[];let r=Array.from({length:Math.ceil(e.length/t)}),a=0,n=0;for(;a<e.length;)r[n]=e.slice(a,a+t),n+=1,a+=t;return r}s(fe,"chunk");function Re(e){let t=new Uint8Array(e.length);t[0]=0;let r=0,a=1;for(;a<t.length;)e[a]===e[r]?(r++,t[a]=r,a++):r===0?(t[a]=0,a++):r=t[r-1];return t}s(Re,"createLPS");async function*he(e,t){let r=t.length,a=Re(t),n=new Uint8Array,o=0,c=0;for(;;){let{value:i,done:d}=await e.read();if(d){yield n;return}n=L([n,i]);let u=0;for(;o<n.length;)if(i[u]===t[c]){if(o++,u++,c++,c===r){let y=o-r;yield n.slice(0,y),n=n.slice(o),o=0,c=0}}else c===0?(o++,u++):c=a[c-1]}}s(he,"readDelim");var B=13,G=10,me=/^HTTP\\/\\d(?:\\.\\d)? (?<rawStatusCode>\\d+) (?<statusText>.*)$/;async function Ae(e){let t=N.alloc(0),r=-1;for await(let f of e.values({preventCancel:!0}))if(t=N.concat([t,f]),r=t.findIndex((I,w)=>t[w]===B&&t[w+1]===G&&t[w+2]===B&&t[w+3]===G),r!==-1)break;let a=t.subarray(0,r).toString(),[n,...o]=a.split(`\\r\n`),c=n.match(me),{rawStatusCode:i,statusText:d}=c.groups,u=parseInt(i),y=o.map(f=>{let I=f.indexOf(":");return[f.substring(0,I),f.substring(I+1).trim()]}),l=t.subarray(r+4),{readable:p,writable:h}=new IdentityTransformStream,U=h.getWriter();return U.write(l).then(()=>(U.releaseLock(),e.pipeTo(h))).catch(f=>console.error("Error writing HTTP body:",f)),new Response(p,{status:u,statusText:d,headers:y})}s(Ae,"parseHttpResponse");function P(e){let t=e.headers.get(R.NAMESPACE)??"default";return e.cf?.cacheKey?`${t}:${String(e.cf?.cacheKey)}`:`${t}:${e.url}`}s(P,"getCacheKey");function pe(e){let t={};return e&&e.split(",").forEach(a=>{let[n,o]=a.trim().split("=");t[n.toLowerCase()]=o?o.trim():!0}),t}s(pe,"parseHeaderValue");function we(e){let t={};for(let[r,a]of e.entries())t[r]=a;return t}s(we,"objectifyHeaders");async function Ee(e){let t=await e.arrayBuffer(),r=new Uint8Array(t),a="";for(let n=0;n<r.length;n++)a+=String.fromCharCode(r[n]);return btoa(a)}s(Ee,"serializeResponseBody");function ge(e){let t=atob(e),r=t.length,a=new Uint8Array(r);for(let n=0;n<r;n++)a[n]=t.charCodeAt(n);return a}s(ge,"deserializeResponseBody");async function be(e){return e.method==="GET"?new Response(null,{status:504,headers:{[R.STATUS]:"MISS"}}):e.method==="PUT"?(await e.body?.pipeTo(new WritableStream),new Response(null,{status:204})):e.method==="PURGE"?new Response(null,{status:404}):new Response(null,{status:405})}s(be,"handleWithNoOp");async function Ie(e,t){let r=t.ZUPLO_CACHE_REDIS_HOSTNAME,a=parseInt(t.ZUPLO_CACHE_REDIS_PORT);if(e.method==="GET")try{let n=P(e),o=new m({redisHost:r,redisPort:a});await o.sendCommand(["HELLO",3]);let c=await o.sendCommand(["TTL",n]);if(c===-2)return new Response(null,{status:504,headers:{[R.STATUS]:"MISS"}});if(c<2)return new Response(null,{status:504,headers:{[R.STATUS]:"EXPIRE"}});{let i=await o.sendCommand(["HGETALL",n]),d=parseInt(i.maxage),u=i.status,y=i.status,l=new Headers(JSON.parse(i.headers));return l.set(R.AGE,`${d-c}`),l.set(R.STATUS,"HIT"),new Response(ge(i.body),{status:u,statusText:y,headers:l})}}catch(n){return console.error("Error on GET from cache: "+n),new Response("Error on GET from cache: "+n,{status:500})}else if(e.method==="PUT")try{let o=await Ae(e.body),c=pe(o.headers.get("cache-control")),i=parseInt(c["s-maxage"]),d=parseInt(c["max-age"]),u=c["no-store"],y=c["no-cache"],l=i||d||0;if(l===0&&!u&&!y&&(l=3600,o.headers.append("cache-control","s-maxage=3600")),l>0){let p=P(e),h=new m({redisHost:r,redisPort:a});return await h.sendCommand(["HELLO",3]),await h.sendCommand(["HSET",p,"maxage",l,"status",o.status,"statusText",o.statusText,"headers",JSON.stringify(we(o.headers)),"body",await Ee(o)]),await h.sendCommand(["EXPIRE",p,l]),new Response(null,{status:204})}else return new Response(null,{status:413})}catch(n){return console.error("Error on PUT to cache: "+n),new Response("Error on PUT to cache: "+n,{status:413})}else if(e.method==="PURGE")try{let n=P(e);return await new m({redisHost:r,redisPort:a}).sendCommand(["DEL",n])===1?new Response(null,{status:200}):new Response(null,{status:404})}catch(n){return console.error("Error on PURGE to cache: "+n),new Response("Error on PURGE to cache: "+n,{status:404})}else return new Response(null,{status:405})}s(Ie,"handleWithRedis");var He={async fetch(e,t){return t.ZUPLO_CACHE_REDIS_HOSTNAME&&t.ZUPLO_CACHE_REDIS_PORT?Ie(e,t):be(e)}};export{He as default};\n'});var yLe=Et(r$=>{"use strict";var p6r=r$&&r$.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r$,"__esModule",{value:!0});r$.ZuploWorkerd=void 0;var d6r=_o("node:fs"),m6r=p6r(_o("node:path")),h6r=_o("node:url"),g6r=R2t(),j2t=_Le(),y6r=M2t(),B2t="2024-12-30",gLe=class{static{t(this,"ZuploWorkerd")}options;runtime;constructor(s){this.options=s,this.runtime=new g6r.Runtime}async serve(){let s=await this.configure(),l=(0,j2t.serializeConfig)(s),_={requiredSockets:["http"],inspectorAddress:this.options.inspectorPort,handleRuntimeStdio:this.options.handleRuntimeStdio};await this.runtime.updateConfig(l,_)}async compileBinary(s){let l=await this.configure({embedVariables:!1}),_=(0,j2t.serializeConfig)(l);await this.runtime.compileBinary(_,s)}async dispose(){await this.runtime.dispose()}withSourceURL(s,l){if(s.lastIndexOf("//# sourceURL=")!==-1)return s;let h=`
|
|
564
|
+
`;let{buffer:_,byteLength:h}=a._capnp.segments[l],b=new Uint8Array(_,0,h);s+=VB.dumpBuffer(b)}return s}t(Q5e,"dump");Hf.dump=Q5e;function eLe(a,s){let l=new a(s.getSegment(0),0);d2t.validate(ade.PointerType.STRUCT,l);let _=d2t.getTargetStructSize(l);return(_.dataByteLength<a._capnp.size.dataByteLength||_.pointerLength<a._capnp.size.pointerLength)&&($k("need to resize root struct %s",l),m2t.resize(a._capnp.size,l)),l}t(eLe,"getRoot");Hf.getRoot=eLe;function cde(a,s){let l=s._capnp.segments.length;if(a===0&&l===0){if(P4.Arena.getNumSegments(s._capnp.arena)===0?ode(DY.DEFAULT_BUFFER_SIZE,s):s._capnp.segments[0]=new Z5e.Segment(0,s,P4.Arena.getBuffer(0,s._capnp.arena)),!s._capnp.segments[0].hasCapacity(8))throw new Error(qB.MSG_SEGMENT_TOO_SMALL);return s._capnp.segments[0].allocate(8),s._capnp.segments[0]}if(a<0||a>=l)throw new Error(VB.format(qB.MSG_SEGMENT_OUT_OF_BOUNDS,a,s));return s._capnp.segments[a]}t(cde,"getSegment");Hf.getSegment=cde;function tLe(a,s){let l=new a(s.getSegment(0),0);return m2t.initStruct(a._capnp.size,l),$k("Initialized root pointer %s for %s.",l,s),l}t(tLe,"initRoot");Hf.initRoot=tLe;function b2t(a){return new ade.Pointer(new rx(a).getSegment(0),0)}t(b2t,"readRawPointer");Hf.readRawPointer=b2t;function S2t(a,s){ade.Pointer.copyFrom(a,new ade.Pointer(s.getSegment(0),0))}t(S2t,"setRoot");Hf.setRoot=S2t;function rLe(a){let s=iLe(a);a._capnp.segments.length===0&&cde(0,a);let l=a._capnp.segments,_=s.byteLength+l.reduce((w,N)=>w+VB.padToWord(N.byteLength),0),h=new Uint8Array(new ArrayBuffer(_)),b=s.byteLength;return h.set(new Uint8Array(s)),l.forEach(w=>{let N=VB.padToWord(w.byteLength);h.set(new Uint8Array(w.buffer,0,N),b),b+=N}),h.buffer}t(rLe,"toArrayBuffer");Hf.toArrayBuffer=rLe;function nLe(a){let s=X5e.pack(iLe(a));a._capnp.segments.length===0&&a.getSegment(0);let l=a._capnp.segments.map(w=>X5e.pack(w.buffer,0,VB.padToWord(w.byteLength))),_=s.byteLength+l.reduce((w,N)=>w+N.byteLength,0),h=new Uint8Array(new ArrayBuffer(_)),b=s.byteLength;return h.set(new Uint8Array(s)),l.forEach(w=>{h.set(new Uint8Array(w),b),b+=w.byteLength}),h.buffer}t(nLe,"toPackedArrayBuffer");Hf.toPackedArrayBuffer=nLe;function iLe(a){let s=a._capnp.segments.length;if(s===0)return new Float64Array(1).buffer;let l=4+s*4+(1-s%2)*4,_=new DataView(new ArrayBuffer(l));return $k("Writing message stream frame with segment count: %d.",s),_.setUint32(0,s-1,!0),a._capnp.segments.forEach((h,b)=>{$k("Message segment %d word count: %d.",h.id,h.byteLength/8),_.setUint32(b*4+4,h.byteLength/8,!0)}),_.buffer}t(iLe,"getStreamFrame");Hf.getStreamFrame=iLe});var C2t=Et(nx=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});nx.ObjectSize=nx.readRawPointer=nx.Message=nx.ListElementSize=void 0;var x2t=(qu(),Qu(Ju));x2t.__exportStar(rbt(),nx);var KAr=mm();Object.defineProperty(nx,"ListElementSize",{enumerable:!0,get:t(function(){return KAr.ListElementSize},"get")});var E2t=T2t();Object.defineProperty(nx,"Message",{enumerable:!0,get:t(function(){return E2t.Message},"get")});Object.defineProperty(nx,"readRawPointer",{enumerable:!0,get:t(function(){return E2t.readRawPointer},"get")});var YAr=nF();Object.defineProperty(nx,"ObjectSize",{enumerable:!0,get:t(function(){return YAr.ObjectSize},"get")});x2t.__exportStar(ide(),nx)});var lde=Et(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.Uint64=Rs.Int64=Rs.getUint8Mask=Rs.getUint64Mask=Rs.getUint32Mask=Rs.getUint16Mask=Rs.getInt8Mask=Rs.getInt64Mask=Rs.getInt32Mask=Rs.getInt16Mask=Rs.getFloat64Mask=Rs.getFloat32Mask=Rs.getBitMask=Rs.Void=Rs.VoidList=Rs.Uint8List=Rs.Uint64List=Rs.Uint32List=Rs.Uint16List=Rs.TextList=Rs.Text=Rs.Struct=Rs.Pointer=Rs.PointerType=Rs.PointerList=Rs.Orphan=Rs.List=Rs.InterfaceList=Rs.Interface=Rs.Int8List=Rs.Int64List=Rs.Int32List=Rs.Int16List=Rs.Float64List=Rs.Float32List=Rs.DataList=Rs.Data=Rs.CompositeList=Rs.BoolList=Rs.AnyPointerList=Rs.readRawPointer=Rs.ObjectSize=Rs.Message=Rs.ListElementSize=void 0;var fl=C2t();Object.defineProperty(Rs,"ListElementSize",{enumerable:!0,get:t(function(){return fl.ListElementSize},"get")});Object.defineProperty(Rs,"Message",{enumerable:!0,get:t(function(){return fl.Message},"get")});Object.defineProperty(Rs,"ObjectSize",{enumerable:!0,get:t(function(){return fl.ObjectSize},"get")});Object.defineProperty(Rs,"readRawPointer",{enumerable:!0,get:t(function(){return fl.readRawPointer},"get")});Object.defineProperty(Rs,"AnyPointerList",{enumerable:!0,get:t(function(){return fl.AnyPointerList},"get")});Object.defineProperty(Rs,"BoolList",{enumerable:!0,get:t(function(){return fl.BoolList},"get")});Object.defineProperty(Rs,"CompositeList",{enumerable:!0,get:t(function(){return fl.CompositeList},"get")});Object.defineProperty(Rs,"Data",{enumerable:!0,get:t(function(){return fl.Data},"get")});Object.defineProperty(Rs,"DataList",{enumerable:!0,get:t(function(){return fl.DataList},"get")});Object.defineProperty(Rs,"Float32List",{enumerable:!0,get:t(function(){return fl.Float32List},"get")});Object.defineProperty(Rs,"Float64List",{enumerable:!0,get:t(function(){return fl.Float64List},"get")});Object.defineProperty(Rs,"Int16List",{enumerable:!0,get:t(function(){return fl.Int16List},"get")});Object.defineProperty(Rs,"Int32List",{enumerable:!0,get:t(function(){return fl.Int32List},"get")});Object.defineProperty(Rs,"Int64List",{enumerable:!0,get:t(function(){return fl.Int64List},"get")});Object.defineProperty(Rs,"Int8List",{enumerable:!0,get:t(function(){return fl.Int8List},"get")});Object.defineProperty(Rs,"Interface",{enumerable:!0,get:t(function(){return fl.Interface},"get")});Object.defineProperty(Rs,"InterfaceList",{enumerable:!0,get:t(function(){return fl.InterfaceList},"get")});Object.defineProperty(Rs,"List",{enumerable:!0,get:t(function(){return fl.List},"get")});Object.defineProperty(Rs,"Orphan",{enumerable:!0,get:t(function(){return fl.Orphan},"get")});Object.defineProperty(Rs,"PointerList",{enumerable:!0,get:t(function(){return fl.PointerList},"get")});Object.defineProperty(Rs,"PointerType",{enumerable:!0,get:t(function(){return fl.PointerType},"get")});Object.defineProperty(Rs,"Pointer",{enumerable:!0,get:t(function(){return fl.Pointer},"get")});Object.defineProperty(Rs,"Struct",{enumerable:!0,get:t(function(){return fl.Struct},"get")});Object.defineProperty(Rs,"Text",{enumerable:!0,get:t(function(){return fl.Text},"get")});Object.defineProperty(Rs,"TextList",{enumerable:!0,get:t(function(){return fl.TextList},"get")});Object.defineProperty(Rs,"Uint16List",{enumerable:!0,get:t(function(){return fl.Uint16List},"get")});Object.defineProperty(Rs,"Uint32List",{enumerable:!0,get:t(function(){return fl.Uint32List},"get")});Object.defineProperty(Rs,"Uint64List",{enumerable:!0,get:t(function(){return fl.Uint64List},"get")});Object.defineProperty(Rs,"Uint8List",{enumerable:!0,get:t(function(){return fl.Uint8List},"get")});Object.defineProperty(Rs,"VoidList",{enumerable:!0,get:t(function(){return fl.VoidList},"get")});Object.defineProperty(Rs,"Void",{enumerable:!0,get:t(function(){return fl.Void},"get")});Object.defineProperty(Rs,"getBitMask",{enumerable:!0,get:t(function(){return fl.getBitMask},"get")});Object.defineProperty(Rs,"getFloat32Mask",{enumerable:!0,get:t(function(){return fl.getFloat32Mask},"get")});Object.defineProperty(Rs,"getFloat64Mask",{enumerable:!0,get:t(function(){return fl.getFloat64Mask},"get")});Object.defineProperty(Rs,"getInt16Mask",{enumerable:!0,get:t(function(){return fl.getInt16Mask},"get")});Object.defineProperty(Rs,"getInt32Mask",{enumerable:!0,get:t(function(){return fl.getInt32Mask},"get")});Object.defineProperty(Rs,"getInt64Mask",{enumerable:!0,get:t(function(){return fl.getInt64Mask},"get")});Object.defineProperty(Rs,"getInt8Mask",{enumerable:!0,get:t(function(){return fl.getInt8Mask},"get")});Object.defineProperty(Rs,"getUint16Mask",{enumerable:!0,get:t(function(){return fl.getUint16Mask},"get")});Object.defineProperty(Rs,"getUint32Mask",{enumerable:!0,get:t(function(){return fl.getUint32Mask},"get")});Object.defineProperty(Rs,"getUint64Mask",{enumerable:!0,get:t(function(){return fl.getUint64Mask},"get")});Object.defineProperty(Rs,"getUint8Mask",{enumerable:!0,get:t(function(){return fl.getUint8Mask},"get")});var w2t=Rpe();Object.defineProperty(Rs,"Int64",{enumerable:!0,get:t(function(){return w2t.Int64},"get")});Object.defineProperty(Rs,"Uint64",{enumerable:!0,get:t(function(){return w2t.Uint64},"get")})});var cLe=Et(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.Extension=rs.Extension_Module=rs.TlsOptions=rs.TlsOptions_Version=rs.TlsOptions_Keypair=rs.HttpOptions=rs.HttpOptions_Header=rs.HttpOptions_Style=rs.DiskDirectory=rs.Network=rs.ExternalServer=rs.ExternalServer_Which=rs.ExternalServer_Tcp=rs.ExternalServer_Https=rs.Worker=rs.Worker_Which=rs.Worker_DurableObjectStorage=rs.Worker_DurableObjectStorage_Which=rs.Worker_DurableObjectNamespace=rs.Worker_DurableObjectNamespace_Which=rs.Worker_Binding=rs.Worker_Binding_Which=rs.Worker_Binding_MemoryCache=rs.Worker_Binding_Hyperdrive=rs.Worker_Binding_Parameter=rs.Worker_Binding_WrappedBinding=rs.Worker_Binding_MemoryCacheLimits=rs.Worker_Binding_CryptoKey=rs.Worker_Binding_CryptoKey_Which=rs.Worker_Binding_CryptoKey_Algorithm=rs.Worker_Binding_CryptoKey_Algorithm_Which=rs.Worker_Binding_CryptoKey_Usage=rs.Worker_Binding_DurableObjectNamespaceDesignator=rs.Worker_Binding_Type=rs.Worker_Binding_Type_Which=rs.Worker_Module=rs.Worker_Module_Which=rs.ServiceDesignator=rs.Service=rs.Service_Which=rs.Socket=rs.Socket_Which=rs.Socket_Https=rs.Config=rs._capnpFileId=void 0;var Zl=lde(),oe=lde();rs._capnpFileId="e6afd26682091c01";var pF=class a extends oe.Struct{static{t(this,"Config")}adoptServices(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownServices(){return oe.Struct.disown(this.getServices())}getServices(){return oe.Struct.getList(0,a._Services,this)}hasServices(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initServices(s){return oe.Struct.initList(0,a._Services,s,this)}setServices(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}adoptSockets(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownSockets(){return oe.Struct.disown(this.getSockets())}getSockets(){return oe.Struct.getList(1,a._Sockets,this)}hasSockets(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initSockets(s){return oe.Struct.initList(1,a._Sockets,s,this)}setSockets(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptV8Flags(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownV8Flags(){return oe.Struct.disown(this.getV8Flags())}getV8Flags(){return oe.Struct.getList(2,Zl.TextList,this)}hasV8Flags(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initV8Flags(s){return oe.Struct.initList(2,Zl.TextList,s,this)}setV8Flags(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptExtensions(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownExtensions(){return oe.Struct.disown(this.getExtensions())}getExtensions(){return oe.Struct.getList(3,a._Extensions,this)}hasExtensions(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initExtensions(s){return oe.Struct.initList(3,a._Extensions,s,this)}setExtensions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}adoptAutogates(s){oe.Struct.adopt(s,oe.Struct.getPointer(4,this))}disownAutogates(){return oe.Struct.disown(this.getAutogates())}getAutogates(){return oe.Struct.getList(4,Zl.TextList,this)}hasAutogates(){return!oe.Struct.isNull(oe.Struct.getPointer(4,this))}initAutogates(s){return oe.Struct.initList(4,Zl.TextList,s,this)}setAutogates(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(4,this))}toString(){return"Config_"+super.toString()}};rs.Config=pF;pF._capnp={displayName:"Config",id:"8794486c76aaa7d6",size:new oe.ObjectSize(0,5)};var WB=class extends oe.Struct{static{t(this,"Socket_Https")}adoptOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownOptions(){return oe.Struct.disown(this.getOptions())}getOptions(){return oe.Struct.getStruct(2,Zy,this)}hasOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initOptions(){return oe.Struct.initStructAt(2,Zy,this)}setOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(3,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initTlsOptions(){return oe.Struct.initStructAt(3,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}toString(){return"Socket_Https_"+super.toString()}};rs.Socket_Https=WB;WB._capnp={displayName:"https",id:"de123876383cbbdc",size:new oe.ObjectSize(8,5)};var sLe;(function(a){a[a.HTTP=0]="HTTP",a[a.HTTPS=1]="HTTPS"})(sLe=rs.Socket_Which||(rs.Socket_Which={}));var dF=class extends oe.Struct{static{t(this,"Socket")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getAddress(){return oe.Struct.getText(1,this)}setAddress(s){oe.Struct.setText(1,s,this)}adoptHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownHttp(){return oe.Struct.disown(this.getHttp())}getHttp(){return oe.Struct.testWhich("http",oe.Struct.getUint16(0,this),0,this),oe.Struct.getStruct(2,Zy,this)}hasHttp(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initHttp(){return oe.Struct.setUint16(0,0,this),oe.Struct.initStructAt(2,Zy,this)}isHttp(){return oe.Struct.getUint16(0,this)===0}setHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}getHttps(){return oe.Struct.testWhich("https",oe.Struct.getUint16(0,this),1,this),oe.Struct.getAs(WB,this)}initHttps(){return oe.Struct.setUint16(0,1,this),oe.Struct.getAs(WB,this)}isHttps(){return oe.Struct.getUint16(0,this)===1}setHttps(){oe.Struct.setUint16(0,1,this)}adoptService(s){oe.Struct.adopt(s,oe.Struct.getPointer(4,this))}disownService(){return oe.Struct.disown(this.getService())}getService(){return oe.Struct.getStruct(4,ud,this)}hasService(){return!oe.Struct.isNull(oe.Struct.getPointer(4,this))}initService(){return oe.Struct.initStructAt(4,ud,this)}setService(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(4,this))}toString(){return"Socket_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Socket=dF;dF.HTTP=sLe.HTTP;dF.HTTPS=sLe.HTTPS;dF._capnp={displayName:"Socket",id:"9a0eba45530ee79f",size:new oe.ObjectSize(8,5)};var t$;(function(a){a[a.UNSPECIFIED=0]="UNSPECIFIED",a[a.WORKER=1]="WORKER",a[a.NETWORK=2]="NETWORK",a[a.EXTERNAL=3]="EXTERNAL",a[a.DISK=4]="DISK"})(t$=rs.Service_Which||(rs.Service_Which={}));var Uk=class extends oe.Struct{static{t(this,"Service")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}isUnspecified(){return oe.Struct.getUint16(0,this)===0}setUnspecified(){oe.Struct.setUint16(0,0,this)}adoptWorker(s){oe.Struct.setUint16(0,1,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWorker(){return oe.Struct.disown(this.getWorker())}getWorker(){return oe.Struct.testWhich("worker",oe.Struct.getUint16(0,this),1,this),oe.Struct.getStruct(1,uv,this)}hasWorker(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWorker(){return oe.Struct.setUint16(0,1,this),oe.Struct.initStructAt(1,uv,this)}isWorker(){return oe.Struct.getUint16(0,this)===1}setWorker(s){oe.Struct.setUint16(0,1,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptNetwork(s){oe.Struct.setUint16(0,2,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownNetwork(){return oe.Struct.disown(this.getNetwork())}getNetwork(){return oe.Struct.testWhich("network",oe.Struct.getUint16(0,this),2,this),oe.Struct.getStruct(1,ZB,this)}hasNetwork(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initNetwork(){return oe.Struct.setUint16(0,2,this),oe.Struct.initStructAt(1,ZB,this)}isNetwork(){return oe.Struct.getUint16(0,this)===2}setNetwork(s){oe.Struct.setUint16(0,2,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptExternal(s){oe.Struct.setUint16(0,3,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownExternal(){return oe.Struct.disown(this.getExternal())}getExternal(){return oe.Struct.testWhich("external",oe.Struct.getUint16(0,this),3,this),oe.Struct.getStruct(1,KA,this)}hasExternal(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initExternal(){return oe.Struct.setUint16(0,3,this),oe.Struct.initStructAt(1,KA,this)}isExternal(){return oe.Struct.getUint16(0,this)===3}setExternal(s){oe.Struct.setUint16(0,3,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptDisk(s){oe.Struct.setUint16(0,4,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDisk(){return oe.Struct.disown(this.getDisk())}getDisk(){return oe.Struct.testWhich("disk",oe.Struct.getUint16(0,this),4,this),oe.Struct.getStruct(1,QB,this)}hasDisk(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDisk(){return oe.Struct.setUint16(0,4,this),oe.Struct.initStructAt(1,QB,this)}isDisk(){return oe.Struct.getUint16(0,this)===4}setDisk(s){oe.Struct.setUint16(0,4,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}toString(){return"Service_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Service=Uk;Uk.UNSPECIFIED=t$.UNSPECIFIED;Uk.WORKER=t$.WORKER;Uk.NETWORK=t$.NETWORK;Uk.EXTERNAL=t$.EXTERNAL;Uk.DISK=t$.DISK;Uk._capnp={displayName:"Service",id:"e5c88e8bb7bcb6b9",size:new oe.ObjectSize(8,2)};var ud=class extends oe.Struct{static{t(this,"ServiceDesignator")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getEntrypoint(){return oe.Struct.getText(1,this)}setEntrypoint(s){oe.Struct.setText(1,s,this)}toString(){return"ServiceDesignator_"+super.toString()}};rs.ServiceDesignator=ud;ud._capnp={displayName:"ServiceDesignator",id:"ae8ec91cee724450",size:new oe.ObjectSize(0,2)};var zk;(function(a){a[a.ES_MODULE=0]="ES_MODULE",a[a.COMMON_JS_MODULE=1]="COMMON_JS_MODULE",a[a.TEXT=2]="TEXT",a[a.DATA=3]="DATA",a[a.WASM=4]="WASM",a[a.JSON=5]="JSON",a[a.NODE_JS_COMPAT_MODULE=6]="NODE_JS_COMPAT_MODULE",a[a.PYTHON_MODULE=7]="PYTHON_MODULE",a[a.PYTHON_REQUIREMENT=8]="PYTHON_REQUIREMENT"})(zk=rs.Worker_Module_Which||(rs.Worker_Module_Which={}));var lv=class extends oe.Struct{static{t(this,"Worker_Module")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getEsModule(){return oe.Struct.testWhich("esModule",oe.Struct.getUint16(0,this),0,this),oe.Struct.getText(1,this)}isEsModule(){return oe.Struct.getUint16(0,this)===0}setEsModule(s){oe.Struct.setUint16(0,0,this),oe.Struct.setText(1,s,this)}getCommonJsModule(){return oe.Struct.testWhich("commonJsModule",oe.Struct.getUint16(0,this),1,this),oe.Struct.getText(1,this)}isCommonJsModule(){return oe.Struct.getUint16(0,this)===1}setCommonJsModule(s){oe.Struct.setUint16(0,1,this),oe.Struct.setText(1,s,this)}getText(){return oe.Struct.testWhich("text",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(1,this)}isText(){return oe.Struct.getUint16(0,this)===2}setText(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(1,s,this)}adoptData(s){oe.Struct.setUint16(0,3,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownData(){return oe.Struct.disown(this.getData())}getData(){return oe.Struct.testWhich("data",oe.Struct.getUint16(0,this),3,this),oe.Struct.getData(1,this)}hasData(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initData(s){return oe.Struct.setUint16(0,3,this),oe.Struct.initData(1,s,this)}isData(){return oe.Struct.getUint16(0,this)===3}setData(s){oe.Struct.setUint16(0,3,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptWasm(s){oe.Struct.setUint16(0,4,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWasm(){return oe.Struct.disown(this.getWasm())}getWasm(){return oe.Struct.testWhich("wasm",oe.Struct.getUint16(0,this),4,this),oe.Struct.getData(1,this)}hasWasm(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWasm(s){return oe.Struct.setUint16(0,4,this),oe.Struct.initData(1,s,this)}isWasm(){return oe.Struct.getUint16(0,this)===4}setWasm(s){oe.Struct.setUint16(0,4,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getJson(){return oe.Struct.testWhich("json",oe.Struct.getUint16(0,this),5,this),oe.Struct.getText(1,this)}isJson(){return oe.Struct.getUint16(0,this)===5}setJson(s){oe.Struct.setUint16(0,5,this),oe.Struct.setText(1,s,this)}getNodeJsCompatModule(){return oe.Struct.testWhich("nodeJsCompatModule",oe.Struct.getUint16(0,this),6,this),oe.Struct.getText(1,this)}isNodeJsCompatModule(){return oe.Struct.getUint16(0,this)===6}setNodeJsCompatModule(s){oe.Struct.setUint16(0,6,this),oe.Struct.setText(1,s,this)}getPythonModule(){return oe.Struct.testWhich("pythonModule",oe.Struct.getUint16(0,this),7,this),oe.Struct.getText(1,this)}isPythonModule(){return oe.Struct.getUint16(0,this)===7}setPythonModule(s){oe.Struct.setUint16(0,7,this),oe.Struct.setText(1,s,this)}getPythonRequirement(){return oe.Struct.testWhich("pythonRequirement",oe.Struct.getUint16(0,this),8,this),oe.Struct.getText(1,this)}isPythonRequirement(){return oe.Struct.getUint16(0,this)===8}setPythonRequirement(s){oe.Struct.setUint16(0,8,this),oe.Struct.setText(1,s,this)}adoptNamedExports(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownNamedExports(){return oe.Struct.disown(this.getNamedExports())}getNamedExports(){return oe.Struct.getList(2,Zl.TextList,this)}hasNamedExports(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initNamedExports(s){return oe.Struct.initList(2,Zl.TextList,s,this)}setNamedExports(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Module_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Module=lv;lv.ES_MODULE=zk.ES_MODULE;lv.COMMON_JS_MODULE=zk.COMMON_JS_MODULE;lv.TEXT=zk.TEXT;lv.DATA=zk.DATA;lv.WASM=zk.WASM;lv.JSON=zk.JSON;lv.NODE_JS_COMPAT_MODULE=zk.NODE_JS_COMPAT_MODULE;lv.PYTHON_MODULE=zk.PYTHON_MODULE;lv.PYTHON_REQUIREMENT=zk.PYTHON_REQUIREMENT;lv._capnp={displayName:"Module",id:"d9d87a63770a12f3",size:new oe.ObjectSize(8,3)};var fv;(function(a){a[a.UNSPECIFIED=0]="UNSPECIFIED",a[a.TEXT=1]="TEXT",a[a.DATA=2]="DATA",a[a.JSON=3]="JSON",a[a.WASM=4]="WASM",a[a.CRYPTO_KEY=5]="CRYPTO_KEY",a[a.SERVICE=6]="SERVICE",a[a.DURABLE_OBJECT_NAMESPACE=7]="DURABLE_OBJECT_NAMESPACE",a[a.KV_NAMESPACE=8]="KV_NAMESPACE",a[a.R2BUCKET=9]="R2BUCKET",a[a.R2ADMIN=10]="R2ADMIN",a[a.QUEUE=11]="QUEUE",a[a.ANALYTICS_ENGINE=12]="ANALYTICS_ENGINE",a[a.HYPERDRIVE=13]="HYPERDRIVE"})(fv=rs.Worker_Binding_Type_Which||(rs.Worker_Binding_Type_Which={}));var zm=class extends oe.Struct{static{t(this,"Worker_Binding_Type")}isUnspecified(){return oe.Struct.getUint16(0,this)===0}setUnspecified(){oe.Struct.setUint16(0,0,this)}isText(){return oe.Struct.getUint16(0,this)===1}setText(){oe.Struct.setUint16(0,1,this)}isData(){return oe.Struct.getUint16(0,this)===2}setData(){oe.Struct.setUint16(0,2,this)}isJson(){return oe.Struct.getUint16(0,this)===3}setJson(){oe.Struct.setUint16(0,3,this)}isWasm(){return oe.Struct.getUint16(0,this)===4}setWasm(){oe.Struct.setUint16(0,4,this)}adoptCryptoKey(s){oe.Struct.setUint16(0,5,this),oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownCryptoKey(){return oe.Struct.disown(this.getCryptoKey())}getCryptoKey(){return oe.Struct.testWhich("cryptoKey",oe.Struct.getUint16(0,this),5,this),oe.Struct.getList(0,Zl.Uint16List,this)}hasCryptoKey(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initCryptoKey(s){return oe.Struct.setUint16(0,5,this),oe.Struct.initList(0,Zl.Uint16List,s,this)}isCryptoKey(){return oe.Struct.getUint16(0,this)===5}setCryptoKey(s){oe.Struct.setUint16(0,5,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}isService(){return oe.Struct.getUint16(0,this)===6}setService(){oe.Struct.setUint16(0,6,this)}isDurableObjectNamespace(){return oe.Struct.getUint16(0,this)===7}setDurableObjectNamespace(){oe.Struct.setUint16(0,7,this)}isKvNamespace(){return oe.Struct.getUint16(0,this)===8}setKvNamespace(){oe.Struct.setUint16(0,8,this)}isR2Bucket(){return oe.Struct.getUint16(0,this)===9}setR2Bucket(){oe.Struct.setUint16(0,9,this)}isR2Admin(){return oe.Struct.getUint16(0,this)===10}setR2Admin(){oe.Struct.setUint16(0,10,this)}isQueue(){return oe.Struct.getUint16(0,this)===11}setQueue(){oe.Struct.setUint16(0,11,this)}isAnalyticsEngine(){return oe.Struct.getUint16(0,this)===12}setAnalyticsEngine(){oe.Struct.setUint16(0,12,this)}isHyperdrive(){return oe.Struct.getUint16(0,this)===13}setHyperdrive(){oe.Struct.setUint16(0,13,this)}toString(){return"Worker_Binding_Type_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Binding_Type=zm;zm.UNSPECIFIED=fv.UNSPECIFIED;zm.TEXT=fv.TEXT;zm.DATA=fv.DATA;zm.JSON=fv.JSON;zm.WASM=fv.WASM;zm.CRYPTO_KEY=fv.CRYPTO_KEY;zm.SERVICE=fv.SERVICE;zm.DURABLE_OBJECT_NAMESPACE=fv.DURABLE_OBJECT_NAMESPACE;zm.KV_NAMESPACE=fv.KV_NAMESPACE;zm.R2BUCKET=fv.R2BUCKET;zm.R2ADMIN=fv.R2ADMIN;zm.QUEUE=fv.QUEUE;zm.ANALYTICS_ENGINE=fv.ANALYTICS_ENGINE;zm.HYPERDRIVE=fv.HYPERDRIVE;zm._capnp={displayName:"Type",id:"8906a1296519bf8a",size:new oe.ObjectSize(8,1)};var mF=class extends oe.Struct{static{t(this,"Worker_Binding_DurableObjectNamespaceDesignator")}getClassName(){return oe.Struct.getText(0,this)}setClassName(s){oe.Struct.setText(0,s,this)}getServiceName(){return oe.Struct.getText(1,this)}setServiceName(s){oe.Struct.setText(1,s,this)}toString(){return"Worker_Binding_DurableObjectNamespaceDesignator_"+super.toString()}};rs.Worker_Binding_DurableObjectNamespaceDesignator=mF;mF._capnp={displayName:"DurableObjectNamespaceDesignator",id:"804f144ff477aac7",size:new oe.ObjectSize(0,2)};var k2t;(function(a){a[a.ENCRYPT=0]="ENCRYPT",a[a.DECRYPT=1]="DECRYPT",a[a.SIGN=2]="SIGN",a[a.VERIFY=3]="VERIFY",a[a.DERIVE_KEY=4]="DERIVE_KEY",a[a.DERIVE_BITS=5]="DERIVE_BITS",a[a.WRAP_KEY=6]="WRAP_KEY",a[a.UNWRAP_KEY=7]="UNWRAP_KEY"})(k2t=rs.Worker_Binding_CryptoKey_Usage||(rs.Worker_Binding_CryptoKey_Usage={}));var aLe;(function(a){a[a.NAME=0]="NAME",a[a.JSON=1]="JSON"})(aLe=rs.Worker_Binding_CryptoKey_Algorithm_Which||(rs.Worker_Binding_CryptoKey_Algorithm_Which={}));var A4=class extends oe.Struct{static{t(this,"Worker_Binding_CryptoKey_Algorithm")}getName(){return oe.Struct.testWhich("name",oe.Struct.getUint16(2,this),0,this),oe.Struct.getText(1,this)}isName(){return oe.Struct.getUint16(2,this)===0}setName(s){oe.Struct.setUint16(2,0,this),oe.Struct.setText(1,s,this)}getJson(){return oe.Struct.testWhich("json",oe.Struct.getUint16(2,this),1,this),oe.Struct.getText(1,this)}isJson(){return oe.Struct.getUint16(2,this)===1}setJson(s){oe.Struct.setUint16(2,1,this),oe.Struct.setText(1,s,this)}toString(){return"Worker_Binding_CryptoKey_Algorithm_"+super.toString()}which(){return oe.Struct.getUint16(2,this)}};rs.Worker_Binding_CryptoKey_Algorithm=A4;A4.NAME=aLe.NAME;A4.JSON=aLe.JSON;A4._capnp={displayName:"algorithm",id:"a1a040c5e00d7021",size:new oe.ObjectSize(8,3)};var bF;(function(a){a[a.RAW=0]="RAW",a[a.HEX=1]="HEX",a[a.BASE64=2]="BASE64",a[a.PKCS8=3]="PKCS8",a[a.SPKI=4]="SPKI",a[a.JWK=5]="JWK"})(bF=rs.Worker_Binding_CryptoKey_Which||(rs.Worker_Binding_CryptoKey_Which={}));var Nb=class a extends oe.Struct{static{t(this,"Worker_Binding_CryptoKey")}adoptRaw(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownRaw(){return oe.Struct.disown(this.getRaw())}getRaw(){return oe.Struct.testWhich("raw",oe.Struct.getUint16(0,this),0,this),oe.Struct.getData(0,this)}hasRaw(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initRaw(s){return oe.Struct.setUint16(0,0,this),oe.Struct.initData(0,s,this)}isRaw(){return oe.Struct.getUint16(0,this)===0}setRaw(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}getHex(){return oe.Struct.testWhich("hex",oe.Struct.getUint16(0,this),1,this),oe.Struct.getText(0,this)}isHex(){return oe.Struct.getUint16(0,this)===1}setHex(s){oe.Struct.setUint16(0,1,this),oe.Struct.setText(0,s,this)}getBase64(){return oe.Struct.testWhich("base64",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(0,this)}isBase64(){return oe.Struct.getUint16(0,this)===2}setBase64(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(0,s,this)}getPkcs8(){return oe.Struct.testWhich("pkcs8",oe.Struct.getUint16(0,this),3,this),oe.Struct.getText(0,this)}isPkcs8(){return oe.Struct.getUint16(0,this)===3}setPkcs8(s){oe.Struct.setUint16(0,3,this),oe.Struct.setText(0,s,this)}getSpki(){return oe.Struct.testWhich("spki",oe.Struct.getUint16(0,this),4,this),oe.Struct.getText(0,this)}isSpki(){return oe.Struct.getUint16(0,this)===4}setSpki(s){oe.Struct.setUint16(0,4,this),oe.Struct.setText(0,s,this)}getJwk(){return oe.Struct.testWhich("jwk",oe.Struct.getUint16(0,this),5,this),oe.Struct.getText(0,this)}isJwk(){return oe.Struct.getUint16(0,this)===5}setJwk(s){oe.Struct.setUint16(0,5,this),oe.Struct.setText(0,s,this)}getAlgorithm(){return oe.Struct.getAs(A4,this)}initAlgorithm(){return oe.Struct.getAs(A4,this)}getExtractable(){return oe.Struct.getBit(32,this,a._capnp.defaultExtractable)}setExtractable(s){oe.Struct.setBit(32,s,this)}adoptUsages(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownUsages(){return oe.Struct.disown(this.getUsages())}getUsages(){return oe.Struct.getList(2,Zl.Uint16List,this)}hasUsages(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initUsages(s){return oe.Struct.initList(2,Zl.Uint16List,s,this)}setUsages(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Binding_CryptoKey_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Binding_CryptoKey=Nb;Nb.RAW=bF.RAW;Nb.HEX=bF.HEX;Nb.BASE64=bF.BASE64;Nb.PKCS8=bF.PKCS8;Nb.SPKI=bF.SPKI;Nb.JWK=bF.JWK;Nb.Usage=k2t;Nb._capnp={displayName:"CryptoKey",id:"b5e1bff0e57d6eb0",size:new oe.ObjectSize(8,3),defaultExtractable:Zl.getBitMask(!1,0)};var hF=class extends oe.Struct{static{t(this,"Worker_Binding_MemoryCacheLimits")}getMaxKeys(){return oe.Struct.getUint32(0,this)}setMaxKeys(s){oe.Struct.setUint32(0,s,this)}getMaxValueSize(){return oe.Struct.getUint32(4,this)}setMaxValueSize(s){oe.Struct.setUint32(4,s,this)}getMaxTotalValueSize(){return oe.Struct.getUint64(8,this)}setMaxTotalValueSize(s){oe.Struct.setUint64(8,s,this)}toString(){return"Worker_Binding_MemoryCacheLimits_"+super.toString()}};rs.Worker_Binding_MemoryCacheLimits=hF;hF._capnp={displayName:"MemoryCacheLimits",id:"8d66725b0867e634",size:new oe.ObjectSize(16,0)};var N4=class a extends oe.Struct{static{t(this,"Worker_Binding_WrappedBinding")}getModuleName(){return oe.Struct.getText(0,this)}setModuleName(s){oe.Struct.setText(0,s,this)}getEntrypoint(){return oe.Struct.getText(1,this,a._capnp.defaultEntrypoint)}setEntrypoint(s){oe.Struct.setText(1,s,this)}adoptInnerBindings(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownInnerBindings(){return oe.Struct.disown(this.getInnerBindings())}getInnerBindings(){return oe.Struct.getList(2,a._InnerBindings,this)}hasInnerBindings(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initInnerBindings(s){return oe.Struct.initList(2,a._InnerBindings,s,this)}setInnerBindings(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Binding_WrappedBinding_"+super.toString()}};rs.Worker_Binding_WrappedBinding=N4;N4._capnp={displayName:"WrappedBinding",id:"e6f066b75f0ea113",size:new oe.ObjectSize(0,3),defaultEntrypoint:"default"};var HB=class extends oe.Struct{static{t(this,"Worker_Binding_Parameter")}adoptType(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownType(){return oe.Struct.disown(this.getType())}getType(){return oe.Struct.getStruct(1,zm,this)}hasType(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initType(){return oe.Struct.initStructAt(1,zm,this)}setType(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getOptional(){return oe.Struct.getBit(16,this)}setOptional(s){oe.Struct.setBit(16,s,this)}toString(){return"Worker_Binding_Parameter_"+super.toString()}};rs.Worker_Binding_Parameter=HB;HB._capnp={displayName:"parameter",id:"dc57e1258d26d152",size:new oe.ObjectSize(8,6)};var GB=class extends oe.Struct{static{t(this,"Worker_Binding_Hyperdrive")}adoptDesignator(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDesignator(){return oe.Struct.disown(this.getDesignator())}getDesignator(){return oe.Struct.getStruct(1,ud,this)}hasDesignator(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDesignator(){return oe.Struct.initStructAt(1,ud,this)}setDesignator(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getDatabase(){return oe.Struct.getText(2,this)}setDatabase(s){oe.Struct.setText(2,s,this)}getUser(){return oe.Struct.getText(3,this)}setUser(s){oe.Struct.setText(3,s,this)}getPassword(){return oe.Struct.getText(4,this)}setPassword(s){oe.Struct.setText(4,s,this)}getScheme(){return oe.Struct.getText(5,this)}setScheme(s){oe.Struct.setText(5,s,this)}toString(){return"Worker_Binding_Hyperdrive_"+super.toString()}};rs.Worker_Binding_Hyperdrive=GB;GB._capnp={displayName:"hyperdrive",id:"ad6c391cd55f3134",size:new oe.ObjectSize(8,6)};var KB=class extends oe.Struct{static{t(this,"Worker_Binding_MemoryCache")}getId(){return oe.Struct.getText(1,this)}setId(s){oe.Struct.setText(1,s,this)}adoptLimits(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownLimits(){return oe.Struct.disown(this.getLimits())}getLimits(){return oe.Struct.getStruct(2,hF,this)}hasLimits(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initLimits(){return oe.Struct.initStructAt(2,hF,this)}setLimits(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Worker_Binding_MemoryCache_"+super.toString()}};rs.Worker_Binding_MemoryCache=KB;KB._capnp={displayName:"memoryCache",id:"aed5760c349869da",size:new oe.ObjectSize(8,6)};var uh;(function(a){a[a.UNSPECIFIED=0]="UNSPECIFIED",a[a.PARAMETER=1]="PARAMETER",a[a.TEXT=2]="TEXT",a[a.DATA=3]="DATA",a[a.JSON=4]="JSON",a[a.WASM_MODULE=5]="WASM_MODULE",a[a.CRYPTO_KEY=6]="CRYPTO_KEY",a[a.SERVICE=7]="SERVICE",a[a.DURABLE_OBJECT_NAMESPACE=8]="DURABLE_OBJECT_NAMESPACE",a[a.KV_NAMESPACE=9]="KV_NAMESPACE",a[a.R2BUCKET=10]="R2BUCKET",a[a.R2ADMIN=11]="R2ADMIN",a[a.WRAPPED=12]="WRAPPED",a[a.QUEUE=13]="QUEUE",a[a.FROM_ENVIRONMENT=14]="FROM_ENVIRONMENT",a[a.ANALYTICS_ENGINE=15]="ANALYTICS_ENGINE",a[a.HYPERDRIVE=16]="HYPERDRIVE",a[a.UNSAFE_EVAL=17]="UNSAFE_EVAL",a[a.MEMORY_CACHE=18]="MEMORY_CACHE"})(uh=rs.Worker_Binding_Which||(rs.Worker_Binding_Which={}));var Af=class extends oe.Struct{static{t(this,"Worker_Binding")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}isUnspecified(){return oe.Struct.getUint16(0,this)===0}setUnspecified(){oe.Struct.setUint16(0,0,this)}getParameter(){return oe.Struct.testWhich("parameter",oe.Struct.getUint16(0,this),1,this),oe.Struct.getAs(HB,this)}initParameter(){return oe.Struct.setUint16(0,1,this),oe.Struct.getAs(HB,this)}isParameter(){return oe.Struct.getUint16(0,this)===1}setParameter(){oe.Struct.setUint16(0,1,this)}getText(){return oe.Struct.testWhich("text",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(1,this)}isText(){return oe.Struct.getUint16(0,this)===2}setText(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(1,s,this)}adoptData(s){oe.Struct.setUint16(0,3,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownData(){return oe.Struct.disown(this.getData())}getData(){return oe.Struct.testWhich("data",oe.Struct.getUint16(0,this),3,this),oe.Struct.getData(1,this)}hasData(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initData(s){return oe.Struct.setUint16(0,3,this),oe.Struct.initData(1,s,this)}isData(){return oe.Struct.getUint16(0,this)===3}setData(s){oe.Struct.setUint16(0,3,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getJson(){return oe.Struct.testWhich("json",oe.Struct.getUint16(0,this),4,this),oe.Struct.getText(1,this)}isJson(){return oe.Struct.getUint16(0,this)===4}setJson(s){oe.Struct.setUint16(0,4,this),oe.Struct.setText(1,s,this)}adoptWasmModule(s){oe.Struct.setUint16(0,5,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWasmModule(){return oe.Struct.disown(this.getWasmModule())}getWasmModule(){return oe.Struct.testWhich("wasmModule",oe.Struct.getUint16(0,this),5,this),oe.Struct.getData(1,this)}hasWasmModule(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWasmModule(s){return oe.Struct.setUint16(0,5,this),oe.Struct.initData(1,s,this)}isWasmModule(){return oe.Struct.getUint16(0,this)===5}setWasmModule(s){oe.Struct.setUint16(0,5,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptCryptoKey(s){oe.Struct.setUint16(0,6,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownCryptoKey(){return oe.Struct.disown(this.getCryptoKey())}getCryptoKey(){return oe.Struct.testWhich("cryptoKey",oe.Struct.getUint16(0,this),6,this),oe.Struct.getStruct(1,Nb,this)}hasCryptoKey(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initCryptoKey(){return oe.Struct.setUint16(0,6,this),oe.Struct.initStructAt(1,Nb,this)}isCryptoKey(){return oe.Struct.getUint16(0,this)===6}setCryptoKey(s){oe.Struct.setUint16(0,6,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptService(s){oe.Struct.setUint16(0,7,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownService(){return oe.Struct.disown(this.getService())}getService(){return oe.Struct.testWhich("service",oe.Struct.getUint16(0,this),7,this),oe.Struct.getStruct(1,ud,this)}hasService(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initService(){return oe.Struct.setUint16(0,7,this),oe.Struct.initStructAt(1,ud,this)}isService(){return oe.Struct.getUint16(0,this)===7}setService(s){oe.Struct.setUint16(0,7,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptDurableObjectNamespace(s){oe.Struct.setUint16(0,8,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDurableObjectNamespace(){return oe.Struct.disown(this.getDurableObjectNamespace())}getDurableObjectNamespace(){return oe.Struct.testWhich("durableObjectNamespace",oe.Struct.getUint16(0,this),8,this),oe.Struct.getStruct(1,mF,this)}hasDurableObjectNamespace(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDurableObjectNamespace(){return oe.Struct.setUint16(0,8,this),oe.Struct.initStructAt(1,mF,this)}isDurableObjectNamespace(){return oe.Struct.getUint16(0,this)===8}setDurableObjectNamespace(s){oe.Struct.setUint16(0,8,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptKvNamespace(s){oe.Struct.setUint16(0,9,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownKvNamespace(){return oe.Struct.disown(this.getKvNamespace())}getKvNamespace(){return oe.Struct.testWhich("kvNamespace",oe.Struct.getUint16(0,this),9,this),oe.Struct.getStruct(1,ud,this)}hasKvNamespace(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initKvNamespace(){return oe.Struct.setUint16(0,9,this),oe.Struct.initStructAt(1,ud,this)}isKvNamespace(){return oe.Struct.getUint16(0,this)===9}setKvNamespace(s){oe.Struct.setUint16(0,9,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptR2Bucket(s){oe.Struct.setUint16(0,10,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownR2Bucket(){return oe.Struct.disown(this.getR2Bucket())}getR2Bucket(){return oe.Struct.testWhich("r2Bucket",oe.Struct.getUint16(0,this),10,this),oe.Struct.getStruct(1,ud,this)}hasR2Bucket(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initR2Bucket(){return oe.Struct.setUint16(0,10,this),oe.Struct.initStructAt(1,ud,this)}isR2Bucket(){return oe.Struct.getUint16(0,this)===10}setR2Bucket(s){oe.Struct.setUint16(0,10,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptR2Admin(s){oe.Struct.setUint16(0,11,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownR2Admin(){return oe.Struct.disown(this.getR2Admin())}getR2Admin(){return oe.Struct.testWhich("r2Admin",oe.Struct.getUint16(0,this),11,this),oe.Struct.getStruct(1,ud,this)}hasR2Admin(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initR2Admin(){return oe.Struct.setUint16(0,11,this),oe.Struct.initStructAt(1,ud,this)}isR2Admin(){return oe.Struct.getUint16(0,this)===11}setR2Admin(s){oe.Struct.setUint16(0,11,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptWrapped(s){oe.Struct.setUint16(0,12,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownWrapped(){return oe.Struct.disown(this.getWrapped())}getWrapped(){return oe.Struct.testWhich("wrapped",oe.Struct.getUint16(0,this),12,this),oe.Struct.getStruct(1,N4,this)}hasWrapped(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initWrapped(){return oe.Struct.setUint16(0,12,this),oe.Struct.initStructAt(1,N4,this)}isWrapped(){return oe.Struct.getUint16(0,this)===12}setWrapped(s){oe.Struct.setUint16(0,12,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptQueue(s){oe.Struct.setUint16(0,13,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownQueue(){return oe.Struct.disown(this.getQueue())}getQueue(){return oe.Struct.testWhich("queue",oe.Struct.getUint16(0,this),13,this),oe.Struct.getStruct(1,ud,this)}hasQueue(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initQueue(){return oe.Struct.setUint16(0,13,this),oe.Struct.initStructAt(1,ud,this)}isQueue(){return oe.Struct.getUint16(0,this)===13}setQueue(s){oe.Struct.setUint16(0,13,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getFromEnvironment(){return oe.Struct.testWhich("fromEnvironment",oe.Struct.getUint16(0,this),14,this),oe.Struct.getText(1,this)}isFromEnvironment(){return oe.Struct.getUint16(0,this)===14}setFromEnvironment(s){oe.Struct.setUint16(0,14,this),oe.Struct.setText(1,s,this)}adoptAnalyticsEngine(s){oe.Struct.setUint16(0,15,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownAnalyticsEngine(){return oe.Struct.disown(this.getAnalyticsEngine())}getAnalyticsEngine(){return oe.Struct.testWhich("analyticsEngine",oe.Struct.getUint16(0,this),15,this),oe.Struct.getStruct(1,ud,this)}hasAnalyticsEngine(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initAnalyticsEngine(){return oe.Struct.setUint16(0,15,this),oe.Struct.initStructAt(1,ud,this)}isAnalyticsEngine(){return oe.Struct.getUint16(0,this)===15}setAnalyticsEngine(s){oe.Struct.setUint16(0,15,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getHyperdrive(){return oe.Struct.testWhich("hyperdrive",oe.Struct.getUint16(0,this),16,this),oe.Struct.getAs(GB,this)}initHyperdrive(){return oe.Struct.setUint16(0,16,this),oe.Struct.getAs(GB,this)}isHyperdrive(){return oe.Struct.getUint16(0,this)===16}setHyperdrive(){oe.Struct.setUint16(0,16,this)}isUnsafeEval(){return oe.Struct.getUint16(0,this)===17}setUnsafeEval(){oe.Struct.setUint16(0,17,this)}getMemoryCache(){return oe.Struct.testWhich("memoryCache",oe.Struct.getUint16(0,this),18,this),oe.Struct.getAs(KB,this)}initMemoryCache(){return oe.Struct.setUint16(0,18,this),oe.Struct.getAs(KB,this)}isMemoryCache(){return oe.Struct.getUint16(0,this)===18}setMemoryCache(){oe.Struct.setUint16(0,18,this)}toString(){return"Worker_Binding_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_Binding=Af;Af.UNSPECIFIED=uh.UNSPECIFIED;Af.PARAMETER=uh.PARAMETER;Af.TEXT=uh.TEXT;Af.DATA=uh.DATA;Af.JSON=uh.JSON;Af.WASM_MODULE=uh.WASM_MODULE;Af.CRYPTO_KEY=uh.CRYPTO_KEY;Af.SERVICE=uh.SERVICE;Af.DURABLE_OBJECT_NAMESPACE=uh.DURABLE_OBJECT_NAMESPACE;Af.KV_NAMESPACE=uh.KV_NAMESPACE;Af.R2BUCKET=uh.R2BUCKET;Af.R2ADMIN=uh.R2ADMIN;Af.WRAPPED=uh.WRAPPED;Af.QUEUE=uh.QUEUE;Af.FROM_ENVIRONMENT=uh.FROM_ENVIRONMENT;Af.ANALYTICS_ENGINE=uh.ANALYTICS_ENGINE;Af.HYPERDRIVE=uh.HYPERDRIVE;Af.UNSAFE_EVAL=uh.UNSAFE_EVAL;Af.MEMORY_CACHE=uh.MEMORY_CACHE;Af.Type=zm;Af.DurableObjectNamespaceDesignator=mF;Af.CryptoKey=Nb;Af.MemoryCacheLimits=hF;Af.WrappedBinding=N4;Af._capnp={displayName:"Binding",id:"8e7e492fd7e35f3e",size:new oe.ObjectSize(8,6)};var oLe;(function(a){a[a.UNIQUE_KEY=0]="UNIQUE_KEY",a[a.EPHEMERAL_LOCAL=1]="EPHEMERAL_LOCAL"})(oLe=rs.Worker_DurableObjectNamespace_Which||(rs.Worker_DurableObjectNamespace_Which={}));var I4=class extends oe.Struct{static{t(this,"Worker_DurableObjectNamespace")}getClassName(){return oe.Struct.getText(0,this)}setClassName(s){oe.Struct.setText(0,s,this)}getUniqueKey(){return oe.Struct.testWhich("uniqueKey",oe.Struct.getUint16(0,this),0,this),oe.Struct.getText(1,this)}isUniqueKey(){return oe.Struct.getUint16(0,this)===0}setUniqueKey(s){oe.Struct.setUint16(0,0,this),oe.Struct.setText(1,s,this)}isEphemeralLocal(){return oe.Struct.getUint16(0,this)===1}setEphemeralLocal(){oe.Struct.setUint16(0,1,this)}getPreventEviction(){return oe.Struct.getBit(16,this)}setPreventEviction(s){oe.Struct.setBit(16,s,this)}getEnableSql(){return oe.Struct.getBit(17,this)}setEnableSql(s){oe.Struct.setBit(17,s,this)}toString(){return"Worker_DurableObjectNamespace_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker_DurableObjectNamespace=I4;I4.UNIQUE_KEY=oLe.UNIQUE_KEY;I4.EPHEMERAL_LOCAL=oLe.EPHEMERAL_LOCAL;I4._capnp={displayName:"DurableObjectNamespace",id:"b429dd547d15747d",size:new oe.ObjectSize(8,2)};var ude;(function(a){a[a.NONE=0]="NONE",a[a.IN_MEMORY=1]="IN_MEMORY",a[a.LOCAL_DISK=2]="LOCAL_DISK"})(ude=rs.Worker_DurableObjectStorage_Which||(rs.Worker_DurableObjectStorage_Which={}));var GA=class extends oe.Struct{static{t(this,"Worker_DurableObjectStorage")}isNone(){return oe.Struct.getUint16(2,this)===0}setNone(){oe.Struct.setUint16(2,0,this)}isInMemory(){return oe.Struct.getUint16(2,this)===1}setInMemory(){oe.Struct.setUint16(2,1,this)}getLocalDisk(){return oe.Struct.testWhich("localDisk",oe.Struct.getUint16(2,this),2,this),oe.Struct.getText(8,this)}isLocalDisk(){return oe.Struct.getUint16(2,this)===2}setLocalDisk(s){oe.Struct.setUint16(2,2,this),oe.Struct.setText(8,s,this)}toString(){return"Worker_DurableObjectStorage_"+super.toString()}which(){return oe.Struct.getUint16(2,this)}};rs.Worker_DurableObjectStorage=GA;GA.NONE=ude.NONE;GA.IN_MEMORY=ude.IN_MEMORY;GA.LOCAL_DISK=ude.LOCAL_DISK;GA._capnp={displayName:"durableObjectStorage",id:"cc72b3faa57827d4",size:new oe.ObjectSize(8,10)};var fde;(function(a){a[a.MODULES=0]="MODULES",a[a.SERVICE_WORKER_SCRIPT=1]="SERVICE_WORKER_SCRIPT",a[a.INHERIT=2]="INHERIT"})(fde=rs.Worker_Which||(rs.Worker_Which={}));var uv=class a extends oe.Struct{static{t(this,"Worker")}adoptModules(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownModules(){return oe.Struct.disown(this.getModules())}getModules(){return oe.Struct.testWhich("modules",oe.Struct.getUint16(0,this),0,this),oe.Struct.getList(0,a._Modules,this)}hasModules(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initModules(s){return oe.Struct.setUint16(0,0,this),oe.Struct.initList(0,a._Modules,s,this)}isModules(){return oe.Struct.getUint16(0,this)===0}setModules(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}getServiceWorkerScript(){return oe.Struct.testWhich("serviceWorkerScript",oe.Struct.getUint16(0,this),1,this),oe.Struct.getText(0,this)}isServiceWorkerScript(){return oe.Struct.getUint16(0,this)===1}setServiceWorkerScript(s){oe.Struct.setUint16(0,1,this),oe.Struct.setText(0,s,this)}getInherit(){return oe.Struct.testWhich("inherit",oe.Struct.getUint16(0,this),2,this),oe.Struct.getText(0,this)}isInherit(){return oe.Struct.getUint16(0,this)===2}setInherit(s){oe.Struct.setUint16(0,2,this),oe.Struct.setText(0,s,this)}getCompatibilityDate(){return oe.Struct.getText(1,this)}setCompatibilityDate(s){oe.Struct.setText(1,s,this)}adoptCompatibilityFlags(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownCompatibilityFlags(){return oe.Struct.disown(this.getCompatibilityFlags())}getCompatibilityFlags(){return oe.Struct.getList(2,Zl.TextList,this)}hasCompatibilityFlags(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initCompatibilityFlags(s){return oe.Struct.initList(2,Zl.TextList,s,this)}setCompatibilityFlags(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptBindings(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownBindings(){return oe.Struct.disown(this.getBindings())}getBindings(){return oe.Struct.getList(3,a._Bindings,this)}hasBindings(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initBindings(s){return oe.Struct.initList(3,a._Bindings,s,this)}setBindings(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}adoptGlobalOutbound(s){oe.Struct.adopt(s,oe.Struct.getPointer(4,this))}disownGlobalOutbound(){return oe.Struct.disown(this.getGlobalOutbound())}getGlobalOutbound(){return oe.Struct.getStruct(4,ud,this,a._capnp.defaultGlobalOutbound)}hasGlobalOutbound(){return!oe.Struct.isNull(oe.Struct.getPointer(4,this))}initGlobalOutbound(){return oe.Struct.initStructAt(4,ud,this)}setGlobalOutbound(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(4,this))}adoptCacheApiOutbound(s){oe.Struct.adopt(s,oe.Struct.getPointer(7,this))}disownCacheApiOutbound(){return oe.Struct.disown(this.getCacheApiOutbound())}getCacheApiOutbound(){return oe.Struct.getStruct(7,ud,this)}hasCacheApiOutbound(){return!oe.Struct.isNull(oe.Struct.getPointer(7,this))}initCacheApiOutbound(){return oe.Struct.initStructAt(7,ud,this)}setCacheApiOutbound(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(7,this))}adoptDurableObjectNamespaces(s){oe.Struct.adopt(s,oe.Struct.getPointer(5,this))}disownDurableObjectNamespaces(){return oe.Struct.disown(this.getDurableObjectNamespaces())}getDurableObjectNamespaces(){return oe.Struct.getList(5,a._DurableObjectNamespaces,this)}hasDurableObjectNamespaces(){return!oe.Struct.isNull(oe.Struct.getPointer(5,this))}initDurableObjectNamespaces(s){return oe.Struct.initList(5,a._DurableObjectNamespaces,s,this)}setDurableObjectNamespaces(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(5,this))}getDurableObjectUniqueKeyModifier(){return oe.Struct.getText(6,this)}setDurableObjectUniqueKeyModifier(s){oe.Struct.setText(6,s,this)}getDurableObjectStorage(){return oe.Struct.getAs(GA,this)}initDurableObjectStorage(){return oe.Struct.getAs(GA,this)}getModuleFallback(){return oe.Struct.getText(9,this)}setModuleFallback(s){oe.Struct.setText(9,s,this)}toString(){return"Worker_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.Worker=uv;uv.MODULES=fde.MODULES;uv.SERVICE_WORKER_SCRIPT=fde.SERVICE_WORKER_SCRIPT;uv.INHERIT=fde.INHERIT;uv.Module=lv;uv.Binding=Af;uv.DurableObjectNamespace=I4;uv._capnp={displayName:"Worker",id:"acfa77e88fd97d1c",size:new oe.ObjectSize(8,10),defaultGlobalOutbound:Zl.readRawPointer(new Uint8Array([16,5,64,2,17,5,74,0,0,255,105,110,116,101,114,110,101,116,0,0,0]).buffer)};var YB=class extends oe.Struct{static{t(this,"ExternalServer_Https")}adoptOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownOptions(){return oe.Struct.disown(this.getOptions())}getOptions(){return oe.Struct.getStruct(1,Zy,this)}hasOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initOptions(){return oe.Struct.initStructAt(1,Zy,this)}setOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(2,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initTlsOptions(){return oe.Struct.initStructAt(2,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}getCertificateHost(){return oe.Struct.getText(3,this)}setCertificateHost(s){oe.Struct.setText(3,s,this)}toString(){return"ExternalServer_Https_"+super.toString()}};rs.ExternalServer_Https=YB;YB._capnp={displayName:"https",id:"ac37e02afd3dc6db",size:new oe.ObjectSize(8,4)};var XB=class extends oe.Struct{static{t(this,"ExternalServer_Tcp")}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(1,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initTlsOptions(){return oe.Struct.initStructAt(1,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getCertificateHost(){return oe.Struct.getText(2,this)}setCertificateHost(s){oe.Struct.setText(2,s,this)}toString(){return"ExternalServer_Tcp_"+super.toString()}};rs.ExternalServer_Tcp=XB;XB._capnp={displayName:"tcp",id:"d941637df0fb39f1",size:new oe.ObjectSize(8,4)};var _de;(function(a){a[a.HTTP=0]="HTTP",a[a.HTTPS=1]="HTTPS",a[a.TCP=2]="TCP"})(_de=rs.ExternalServer_Which||(rs.ExternalServer_Which={}));var KA=class extends oe.Struct{static{t(this,"ExternalServer")}getAddress(){return oe.Struct.getText(0,this)}setAddress(s){oe.Struct.setText(0,s,this)}adoptHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownHttp(){return oe.Struct.disown(this.getHttp())}getHttp(){return oe.Struct.testWhich("http",oe.Struct.getUint16(0,this),0,this),oe.Struct.getStruct(1,Zy,this)}hasHttp(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initHttp(){return oe.Struct.setUint16(0,0,this),oe.Struct.initStructAt(1,Zy,this)}isHttp(){return oe.Struct.getUint16(0,this)===0}setHttp(s){oe.Struct.setUint16(0,0,this),oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getHttps(){return oe.Struct.testWhich("https",oe.Struct.getUint16(0,this),1,this),oe.Struct.getAs(YB,this)}initHttps(){return oe.Struct.setUint16(0,1,this),oe.Struct.getAs(YB,this)}isHttps(){return oe.Struct.getUint16(0,this)===1}setHttps(){oe.Struct.setUint16(0,1,this)}getTcp(){return oe.Struct.testWhich("tcp",oe.Struct.getUint16(0,this),2,this),oe.Struct.getAs(XB,this)}initTcp(){return oe.Struct.setUint16(0,2,this),oe.Struct.getAs(XB,this)}isTcp(){return oe.Struct.getUint16(0,this)===2}setTcp(){oe.Struct.setUint16(0,2,this)}toString(){return"ExternalServer_"+super.toString()}which(){return oe.Struct.getUint16(0,this)}};rs.ExternalServer=KA;KA.HTTP=_de.HTTP;KA.HTTPS=_de.HTTPS;KA.TCP=_de.TCP;KA._capnp={displayName:"ExternalServer",id:"ff209f9aa352f5a4",size:new oe.ObjectSize(8,4)};var ZB=class a extends oe.Struct{static{t(this,"Network")}adoptAllow(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownAllow(){return oe.Struct.disown(this.getAllow())}getAllow(){return oe.Struct.getList(0,Zl.TextList,this,a._capnp.defaultAllow)}hasAllow(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initAllow(s){return oe.Struct.initList(0,Zl.TextList,s,this)}setAllow(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}adoptDeny(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownDeny(){return oe.Struct.disown(this.getDeny())}getDeny(){return oe.Struct.getList(1,Zl.TextList,this)}hasDeny(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initDeny(s){return oe.Struct.initList(1,Zl.TextList,s,this)}setDeny(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}adoptTlsOptions(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownTlsOptions(){return oe.Struct.disown(this.getTlsOptions())}getTlsOptions(){return oe.Struct.getStruct(2,Ib,this)}hasTlsOptions(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initTlsOptions(){return oe.Struct.initStructAt(2,Ib,this)}setTlsOptions(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}toString(){return"Network_"+super.toString()}};rs.Network=ZB;ZB._capnp={displayName:"Network",id:"fa42244f950c9b9c",size:new oe.ObjectSize(0,3),defaultAllow:Zl.readRawPointer(new Uint8Array([16,3,17,1,14,17,1,58,63,112,117,98,108,105,99]).buffer)};var QB=class a extends oe.Struct{static{t(this,"DiskDirectory")}getPath(){return oe.Struct.getText(0,this)}setPath(s){oe.Struct.setText(0,s,this)}getWritable(){return oe.Struct.getBit(0,this,a._capnp.defaultWritable)}setWritable(s){oe.Struct.setBit(0,s,this)}getAllowDotfiles(){return oe.Struct.getBit(1,this,a._capnp.defaultAllowDotfiles)}setAllowDotfiles(s){oe.Struct.setBit(1,s,this)}toString(){return"DiskDirectory_"+super.toString()}};rs.DiskDirectory=QB;QB._capnp={displayName:"DiskDirectory",id:"9048ab22835f51c3",size:new oe.ObjectSize(8,1),defaultWritable:Zl.getBitMask(!1,0),defaultAllowDotfiles:Zl.getBitMask(!1,1)};var D2t;(function(a){a[a.HOST=0]="HOST",a[a.PROXY=1]="PROXY"})(D2t=rs.HttpOptions_Style||(rs.HttpOptions_Style={}));var gF=class extends oe.Struct{static{t(this,"HttpOptions_Header")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getValue(){return oe.Struct.getText(1,this)}setValue(s){oe.Struct.setText(1,s,this)}toString(){return"HttpOptions_Header_"+super.toString()}};rs.HttpOptions_Header=gF;gF._capnp={displayName:"Header",id:"dc0394b5a6f3417e",size:new oe.ObjectSize(0,2)};var Zy=class a extends oe.Struct{static{t(this,"HttpOptions")}getStyle(){return oe.Struct.getUint16(0,this,a._capnp.defaultStyle)}setStyle(s){oe.Struct.setUint16(0,s,this)}getForwardedProtoHeader(){return oe.Struct.getText(0,this)}setForwardedProtoHeader(s){oe.Struct.setText(0,s,this)}getCfBlobHeader(){return oe.Struct.getText(1,this)}setCfBlobHeader(s){oe.Struct.setText(1,s,this)}adoptInjectRequestHeaders(s){oe.Struct.adopt(s,oe.Struct.getPointer(2,this))}disownInjectRequestHeaders(){return oe.Struct.disown(this.getInjectRequestHeaders())}getInjectRequestHeaders(){return oe.Struct.getList(2,a._InjectRequestHeaders,this)}hasInjectRequestHeaders(){return!oe.Struct.isNull(oe.Struct.getPointer(2,this))}initInjectRequestHeaders(s){return oe.Struct.initList(2,a._InjectRequestHeaders,s,this)}setInjectRequestHeaders(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(2,this))}adoptInjectResponseHeaders(s){oe.Struct.adopt(s,oe.Struct.getPointer(3,this))}disownInjectResponseHeaders(){return oe.Struct.disown(this.getInjectResponseHeaders())}getInjectResponseHeaders(){return oe.Struct.getList(3,a._InjectResponseHeaders,this)}hasInjectResponseHeaders(){return!oe.Struct.isNull(oe.Struct.getPointer(3,this))}initInjectResponseHeaders(s){return oe.Struct.initList(3,a._InjectResponseHeaders,s,this)}setInjectResponseHeaders(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(3,this))}getCapnpConnectHost(){return oe.Struct.getText(4,this)}setCapnpConnectHost(s){oe.Struct.setText(4,s,this)}toString(){return"HttpOptions_"+super.toString()}};rs.HttpOptions=Zy;Zy.Style=D2t;Zy.Header=gF;Zy._capnp={displayName:"HttpOptions",id:"aa8dc6885da78f19",size:new oe.ObjectSize(8,5),defaultStyle:Zl.getUint16Mask(0)};var yF=class extends oe.Struct{static{t(this,"TlsOptions_Keypair")}getPrivateKey(){return oe.Struct.getText(0,this)}setPrivateKey(s){oe.Struct.setText(0,s,this)}getCertificateChain(){return oe.Struct.getText(1,this)}setCertificateChain(s){oe.Struct.setText(1,s,this)}toString(){return"TlsOptions_Keypair_"+super.toString()}};rs.TlsOptions_Keypair=yF;yF._capnp={displayName:"Keypair",id:"f546bf2d5d8bd13e",size:new oe.ObjectSize(0,2)};var P2t;(function(a){a[a.GOOD_DEFAULT=0]="GOOD_DEFAULT",a[a.SSL3=1]="SSL3",a[a.TLS1DOT0=2]="TLS1DOT0",a[a.TLS1DOT1=3]="TLS1DOT1",a[a.TLS1DOT2=4]="TLS1DOT2",a[a.TLS1DOT3=5]="TLS1DOT3"})(P2t=rs.TlsOptions_Version||(rs.TlsOptions_Version={}));var Ib=class a extends oe.Struct{static{t(this,"TlsOptions")}adoptKeypair(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownKeypair(){return oe.Struct.disown(this.getKeypair())}getKeypair(){return oe.Struct.getStruct(0,yF,this)}hasKeypair(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initKeypair(){return oe.Struct.initStructAt(0,yF,this)}setKeypair(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}getRequireClientCerts(){return oe.Struct.getBit(0,this,a._capnp.defaultRequireClientCerts)}setRequireClientCerts(s){oe.Struct.setBit(0,s,this)}getTrustBrowserCas(){return oe.Struct.getBit(1,this,a._capnp.defaultTrustBrowserCas)}setTrustBrowserCas(s){oe.Struct.setBit(1,s,this)}adoptTrustedCertificates(s){oe.Struct.adopt(s,oe.Struct.getPointer(1,this))}disownTrustedCertificates(){return oe.Struct.disown(this.getTrustedCertificates())}getTrustedCertificates(){return oe.Struct.getList(1,Zl.TextList,this)}hasTrustedCertificates(){return!oe.Struct.isNull(oe.Struct.getPointer(1,this))}initTrustedCertificates(s){return oe.Struct.initList(1,Zl.TextList,s,this)}setTrustedCertificates(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(1,this))}getMinVersion(){return oe.Struct.getUint16(2,this,a._capnp.defaultMinVersion)}setMinVersion(s){oe.Struct.setUint16(2,s,this)}getCipherList(){return oe.Struct.getText(2,this)}setCipherList(s){oe.Struct.setText(2,s,this)}toString(){return"TlsOptions_"+super.toString()}};rs.TlsOptions=Ib;Ib.Keypair=yF;Ib.Version=P2t;Ib._capnp={displayName:"TlsOptions",id:"aabb3c3778ac4311",size:new oe.ObjectSize(8,3),defaultRequireClientCerts:Zl.getBitMask(!1,0),defaultTrustBrowserCas:Zl.getBitMask(!1,1),defaultMinVersion:Zl.getUint16Mask(0)};var e$=class a extends oe.Struct{static{t(this,"Extension_Module")}getName(){return oe.Struct.getText(0,this)}setName(s){oe.Struct.setText(0,s,this)}getInternal(){return oe.Struct.getBit(0,this,a._capnp.defaultInternal)}setInternal(s){oe.Struct.setBit(0,s,this)}getEsModule(){return oe.Struct.getText(1,this)}setEsModule(s){oe.Struct.setText(1,s,this)}toString(){return"Extension_Module_"+super.toString()}};rs.Extension_Module=e$;e$._capnp={displayName:"Module",id:"d5d16e76fdedc37d",size:new oe.ObjectSize(8,2),defaultInternal:Zl.getBitMask(!1,0)};var vF=class a extends oe.Struct{static{t(this,"Extension")}adoptModules(s){oe.Struct.adopt(s,oe.Struct.getPointer(0,this))}disownModules(){return oe.Struct.disown(this.getModules())}getModules(){return oe.Struct.getList(0,a._Modules,this)}hasModules(){return!oe.Struct.isNull(oe.Struct.getPointer(0,this))}initModules(s){return oe.Struct.initList(0,a._Modules,s,this)}setModules(s){oe.Struct.copyFrom(s,oe.Struct.getPointer(0,this))}toString(){return"Extension_"+super.toString()}};rs.Extension=vF;vF.Module=e$;vF._capnp={displayName:"Extension",id:"e390128a861973a6",size:new oe.ObjectSize(0,1)};pF._Services=Zl.CompositeList(Uk);pF._Sockets=Zl.CompositeList(dF);pF._Extensions=Zl.CompositeList(vF);N4._InnerBindings=Zl.CompositeList(Af);uv._Modules=Zl.CompositeList(lv);uv._Bindings=Zl.CompositeList(Af);uv._DurableObjectNamespaces=Zl.CompositeList(I4);Zy._InjectRequestHeaders=Zl.CompositeList(gF);Zy._InjectResponseHeaders=Zl.CompositeList(gF);vF._Modules=Zl.CompositeList(e$)});var uLe=Et(Jk=>{"use strict";Object.defineProperty(Jk,"__esModule",{value:!0});Jk.kVoid=Jk.Worker_Binding_CryptoKey_Usage=Jk.TlsOptions_Version=Jk.HttpOptions_Style=void 0;var lLe=cLe();Object.defineProperty(Jk,"HttpOptions_Style",{enumerable:!0,get:t(function(){return lLe.HttpOptions_Style},"get")});Object.defineProperty(Jk,"TlsOptions_Version",{enumerable:!0,get:t(function(){return lLe.TlsOptions_Version},"get")});Object.defineProperty(Jk,"Worker_Binding_CryptoKey_Usage",{enumerable:!0,get:t(function(){return lLe.Worker_Binding_CryptoKey_Usage},"get")});Jk.kVoid=Symbol("kVoid")});var _Le=Et(O4=>{"use strict";var XAr=O4&&O4.__createBinding||(Object.create?function(a,s,l,_){_===void 0&&(_=l);var h=Object.getOwnPropertyDescriptor(s,l);(!h||("get"in h?!s.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:t(function(){return s[l]},"get")}),Object.defineProperty(a,_,h)}:function(a,s,l,_){_===void 0&&(_=l),a[_]=s[l]}),ZAr=O4&&O4.__exportStar||function(a,s){for(var l in a)l!=="default"&&!Object.prototype.hasOwnProperty.call(s,l)&&XAr(s,a,l)};Object.defineProperty(O4,"__esModule",{value:!0});O4.serializeConfig=n6r;var QAr=lde(),e6r=uLe(),t6r=cLe();function r6r(a){return a.length>0?a[0].toUpperCase()+a.substring(1):a}t(r6r,"capitalize");function fLe(a,s){let l=s;for(let[_,h]of Object.entries(a)){let b=r6r(_);if(h instanceof Uint8Array)l[`init${b}`](h.byteLength).copyBuffer(h);else if(Array.isArray(h)){let w=l[`init${b}`](h.length);for(let N=0;N<h.length;N++)typeof h[N]=="object"?fLe(h[N],w.get(N)):w.set(N,h[N])}else if(typeof h=="object"){let w=l[`init${b}`]();fLe(h,w)}else h===e6r.kVoid?l[`set${b}`]():h!==void 0&&l[`set${b}`](h)}}t(fLe,"encodeCapnpStruct");function n6r(a){let s=new QAr.Message,l=s.initRoot(t6r.Config);return fLe(a,l),Buffer.from(s.toArrayBuffer())}t(n6r,"serializeConfig");ZAr(uLe(),O4)});var R2t=Et(fh=>{"use strict";var F2t=fh&&fh.__createBinding||(Object.create?function(a,s,l,_){_===void 0&&(_=l);var h=Object.getOwnPropertyDescriptor(s,l);(!h||("get"in h?!s.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:t(function(){return s[l]},"get")}),Object.defineProperty(a,_,h)}:function(a,s,l,_){_===void 0&&(_=l),a[_]=s[l]}),i6r=fh&&fh.__setModuleDefault||(Object.create?function(a,s){Object.defineProperty(a,"default",{enumerable:!0,value:s})}:function(a,s){a.default=s}),s6r=fh&&fh.__importStar||function(){var a=t(function(s){return a=Object.getOwnPropertyNames||function(l){var _=[];for(var h in l)Object.prototype.hasOwnProperty.call(l,h)&&(_[_.length]=h);return _},a(s)},"ownKeys");return function(s){if(s&&s.__esModule)return s;var l={};if(s!=null)for(var _=a(s),h=0;h<_.length;h++)_[h]!=="default"&&F2t(l,s,_[h]);return i6r(l,s),l}}(),a6r=fh&&fh.__exportStar||function(a,s){for(var l in a)l!=="default"&&!Object.prototype.hasOwnProperty.call(s,l)&&F2t(s,a,l)},hLe=fh&&fh.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(fh,"__esModule",{value:!0});fh.supportedCompatibilityDate=fh.Runtime=fh.kInspectorSocket=void 0;var o6r=hLe(_o("node:assert")),A2t=hLe(_o("node:child_process")),pLe=_o("node:events"),N2t=_o("node:fs"),dLe=hLe(_o("node:readline")),c6r=_o("node:stream"),L2t=s6r(_o("workerd"));Object.defineProperty(fh,"supportedCompatibilityDate",{enumerable:!0,get:t(function(){return L2t.compatibilityDate},"get")});fh.kInspectorSocket=Symbol("kInspectorSocket");async function l6r(a,s){if(s?.signal?.aborted)return;let l=dLe.default.createInterface(a),_=t(()=>l.close(),"abortListener");s?.signal?.addEventListener("abort",_,{once:!0});let h=Array.from(s.requiredSockets),b=new Map;try{for await(let w of l){let N=JSON.parse(w),B=N.event==="listen-inspector"?fh.kInspectorSocket:N.socket,q=h.indexOf(B);if(q!==-1&&(b.set(B,N.port),h.splice(q,1),h.length===0))return b}}finally{s?.signal?.removeEventListener("abort",_)}}t(l6r,"waitForPorts");function I2t(a){return new Promise(s=>{a.once("exit",()=>s())})}t(I2t,"waitForExit");function u6r(a,s){dLe.default.createInterface(a).on("line",l=>console.log(l)),dLe.default.createInterface(s).on("line",l=>console.error(l))}t(u6r,"pipeOutput");function O2t(){return L2t.default}t(O2t,"getRuntimeCommand");function f6r(a){let s=["serve","--binary","--experimental","--control-fd=3","-"];return a.inspectorAddress!==void 0&&s.push(`--inspector-addr=localhost:${a.inspectorAddress}`),a.verbose&&s.push("--verbose"),s}t(f6r,"getServeArgs");function _6r(a){let s=["compile","--binary","-"];return a.verbose&&s.push("--verbose"),s}t(_6r,"getCompileArgs");var mLe=class{static{t(this,"Runtime")}process;processExitPromise;async updateConfig(s,l){await this.dispose();let _=O2t(),h=f6r(l),w=A2t.default.spawn(_,h,{stdio:["pipe","pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}});this.process=w,this.processExitPromise=I2t(w),(l.handleRuntimeStdio??u6r)(w.stdout,w.stderr);let B=w.stdio[3];return(0,o6r.default)(B instanceof c6r.Readable),w.stdin.write(s),w.stdin.end(),await(0,pLe.once)(w.stdin,"finish"),l6r(B,l)}async compileBinary(s,l){await this.dispose();let _=O2t(),h=_6r(l),b=A2t.default.spawn(_,h,{stdio:["pipe","pipe","pipe"],env:{...process.env}});this.process=b,this.processExitPromise=I2t(b),b.stdin.write(s),b.stdin.end(),await(0,pLe.once)(b.stdin,"finish");let w=(0,N2t.createWriteStream)(l.binaryPath);b.stdout.pipe(w),await(0,pLe.once)(b.stdout,"finish"),(0,N2t.chmodSync)(l.binaryPath,493),await this.dispose()}dispose(){return this.process?.kill("SIGKILL"),this.processExitPromise}};fh.Runtime=mLe;a6r(_Le(),fh)});var M2t=Et(pde=>{"use strict";Object.defineProperty(pde,"__esModule",{value:!0});pde.ZUPLO_CACHE_EXTENSION=void 0;pde.ZUPLO_CACHE_EXTENSION='var D=Object.defineProperty;var s=(e,t)=>D(e,"name",{value:t,configurable:!0});import{Buffer as B}from"node:buffer";var f={AGE:"age",NAMESPACE:"cf-cache-namespace",STATUS:"cf-cache-status"};import{connect as k}from"cloudflare:sockets";var U="*",_="$",G=U.charCodeAt(0),v=124,M=40,W=33,$=35,j=_.charCodeAt(0),K=44,Z=45,V=58,J=37,Y=95,Q=62,z=126,q=43,ee=61,g=new TextEncoder,E=new TextDecoder,S=`\\r\n`,x=g.encode(S),m=class{static{s(this,"MinimalRedisClient")}socket;reader;writer;constructor(t){this.socket=k({hostname:t.redisHost,port:t.redisPort},{secureTransport:"starttls",allowHalfOpen:!0}),this.reader=this.socket.readable.getReader(),this.writer=this.socket.writable.getWriter()}async sendCommand(t,n=!1){return await ye(this.reader,this.writer,t,n)}};function L(e){let t=0;for(let a of e)t+=a.length;let n=new Uint8Array(t),r=0;for(let a of e)n.set(a,r),r+=a.length;return n}s(L,"concat");function te(e){let t=[g.encode(U+e.length+S)];for(let n of e){let r=n instanceof Uint8Array?n:g.encode(n.toString());t.push(g.encode(_+r.byteLength+S)),t.push(r),t.push(x)}return L(t)}s(te,"createRequest");async function ne(e,t){let n=te(t);await e.write(n)}s(ne,"writeCommand");function A(e){return E.decode(e.slice(1))}s(A,"removePrefix");function re(e){return Object.fromEntries(fe(e,2))}s(re,"toObject");async function O(e,t,n=!1){let r=[];for(let a=0;a<e;a++)r.push(await P(t,n));return r}s(O,"readNReplies");async function H(e,t){let n=I(e);return n===-1?null:await O(n,t)}s(H,"readArray");async function ae(e,t,n=!1){return await N(e,t),await P(t,n)}s(ae,"readAttribute");function se(e){return BigInt(A(e))}s(se,"readBigNumber");async function oe(e){let{value:t}=await e.next();return await Promise.reject(E.decode(t))}s(oe,"readBlobError");function ce(e){return A(e)==="t"}s(ce,"readBoolean");async function ie(e,t,n=!1){if(I(e)===-1)return null;let{value:r}=await t.next();return n?r:E.decode(r)}s(ie,"readBulkOrVerbatimString");async function ue(e){return await Promise.reject(A(e))}s(ue,"readError");async function N(e,t){let n=I(e)*2,r=await O(n,t);return re(r)}s(N,"readMap");function I(e){let t=A(e);switch(t){case"inf":return 1/0;case"-inf":return-1/0;default:return Number(t)}}s(I,"readNumberOrDouble");async function le(e,t){return new Set(await H(e,t))}s(le,"readSet");function de(e){return A(e)}s(de,"readSimpleString");async function P(e,t=!1){let{value:n}=await e.next();if(n.length===0)return await Promise.reject(new TypeError("No reply received"));switch(n[0]){case G:case Q:return await H(n,e);case v:return await ae(n,e);case M:return se(n);case W:return oe(e);case $:return ce(n);case j:case ee:return await ie(n,e,t);case K:case V:return I(n);case Z:return ue(n);case J:return await N(n,e);case Y:return null;case z:return await le(n,e);case q:return de(n);default:return E.decode(n)}}s(P,"readReply");async function ye(e,t,n,r=!1){return await ne(t,n),await P(he(e,x),r)}s(ye,"sendCommand");function fe(e,t){if(t<=0||!Number.isInteger(t))throw new Error(`Expected size to be an integer greater than 0 but found ${t}`);if(e.length===0)return[];let n=Array.from({length:Math.ceil(e.length/t)}),r=0,a=0;for(;r<e.length;)n[a]=e.slice(r,r+t),a+=1,r+=t;return n}s(fe,"chunk");function Re(e){let t=new Uint8Array(e.length);t[0]=0;let n=0,r=1;for(;r<t.length;)e[r]===e[n]?(n++,t[r]=n,r++):n===0?(t[r]=0,r++):n=t[n-1];return t}s(Re,"createLPS");async function*he(e,t){let n=t.length,r=Re(t),a=new Uint8Array,o=0,c=0;for(;;){let{value:i,done:d}=await e.read();if(d){yield a;return}a=L([a,i]);let l=0;for(;o<a.length;)if(i[l]===t[c]){if(o++,l++,c++,c===n){let y=o-n;yield a.slice(0,y),a=a.slice(o),o=0,c=0}}else c===0?(o++,l++):c=r[c-1]}}s(he,"readDelim");var F=13,X=10,me=/^HTTP\\/\\d(?:\\.\\d)? (?<rawStatusCode>\\d+) (?<statusText>.*)$/;async function Ae(e){let t=B.alloc(0),n=-1;for await(let h of e.values({preventCancel:!0}))if(t=B.concat([t,h]),n=t.findIndex((b,w)=>t[w]===F&&t[w+1]===X&&t[w+2]===F&&t[w+3]===X),n!==-1)break;let r=t.subarray(0,n).toString(),[a,...o]=r.split(`\\r\n`),c=a.match(me),{rawStatusCode:i,statusText:d}=c.groups,l=parseInt(i,10),y=o.map(h=>{let b=h.indexOf(":");return[h.substring(0,b),h.substring(b+1).trim()]}),u=t.subarray(n+4),{readable:p,writable:R}=new IdentityTransformStream,C=R.getWriter();return C.write(u).then(()=>(C.releaseLock(),e.pipeTo(R))).catch(h=>{}),new Response(p,{status:l,statusText:d,headers:y})}s(Ae,"parseHttpResponse");function T(e){let t=e.headers.get(f.NAMESPACE)??"default";return e.cf?.cacheKey?`${t}:${String(e.cf?.cacheKey)}`:`${t}:${e.url}`}s(T,"getCacheKey");function pe(e){let t={};return e&&e.split(",").forEach(r=>{let[a,o]=r.trim().split("=");t[a.toLowerCase()]=o?o.trim():!0}),t}s(pe,"parseHeaderValue");function we(e){let t={};for(let[n,r]of e.entries())t[n]=r;return t}s(we,"objectifyHeaders");async function ge(e){let t=await e.arrayBuffer(),n=new Uint8Array(t),r="";for(let a=0;a<n.length;a++)r+=String.fromCharCode(n[a]);return btoa(r)}s(ge,"serializeResponseBody");function Ee(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let a=0;a<n;a++)r[a]=t.charCodeAt(a);return r}s(Ee,"deserializeResponseBody");async function Ie(e){return e.method==="GET"?new Response(null,{status:504,headers:{[f.STATUS]:"MISS"}}):e.method==="PUT"?(await e.body?.pipeTo(new WritableStream),new Response(null,{status:204})):e.method==="PURGE"?new Response(null,{status:404}):new Response(null,{status:405})}s(Ie,"handleWithNoOp");async function be(e,t){let n=t.ZUPLO_CACHE_REDIS_HOSTNAME,r=parseInt(t.ZUPLO_CACHE_REDIS_PORT,10);if(e.method==="GET")try{let a=T(e),o=new m({redisHost:n,redisPort:r});await o.sendCommand(["HELLO",3]);let c=await o.sendCommand(["TTL",a]);if(c===-2)return new Response(null,{status:504,headers:{[f.STATUS]:"MISS"}});if(c<2)return new Response(null,{status:504,headers:{[f.STATUS]:"EXPIRE"}});{let i=await o.sendCommand(["HGETALL",a]),d=parseInt(i.maxage,10),l=i.status,y=i.status,u=new Headers(JSON.parse(i.headers));return u.set(f.AGE,`${d-c}`),u.set(f.STATUS,"HIT"),new Response(Ee(i.body),{status:l,statusText:y,headers:u})}}catch(a){return new Response(`Error on GET from cache: ${a}`,{status:500})}else if(e.method==="PUT")try{let o=await Ae(e.body),c=pe(o.headers.get("cache-control")),i=parseInt(c["s-maxage"],10),d=parseInt(c["max-age"],10),l=c["no-store"],y=c["no-cache"],u=i||d||0;if(u===0&&!l&&!y&&(u=3600,o.headers.append("cache-control","s-maxage=3600")),u>0){let p=T(e),R=new m({redisHost:n,redisPort:r});return await R.sendCommand(["HELLO",3]),await R.sendCommand(["HSET",p,"maxage",u,"status",o.status,"statusText",o.statusText,"headers",JSON.stringify(we(o.headers)),"body",await ge(o)]),await R.sendCommand(["EXPIRE",p,u]),new Response(null,{status:204})}else return new Response(null,{status:413})}catch(a){return new Response(`Error on PUT to cache: ${a}`,{status:413})}else if(e.method==="PURGE")try{let a=T(e);return await new m({redisHost:n,redisPort:r}).sendCommand(["DEL",a])===1?new Response(null,{status:200}):new Response(null,{status:404})}catch(a){return new Response(`Error on PURGE to cache: ${a}`,{status:404})}else return new Response(null,{status:405})}s(be,"handleWithRedis");var Oe={async fetch(e,t){return t.ZUPLO_CACHE_REDIS_HOSTNAME&&t.ZUPLO_CACHE_REDIS_PORT?be(e,t):Ie(e)}};export{Oe as default};\n'});var yLe=Et(r$=>{"use strict";var p6r=r$&&r$.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(r$,"__esModule",{value:!0});r$.ZuploWorkerd=void 0;var d6r=_o("node:fs"),m6r=p6r(_o("node:path")),h6r=_o("node:url"),g6r=R2t(),j2t=_Le(),y6r=M2t(),B2t="2024-12-30",gLe=class{static{t(this,"ZuploWorkerd")}options;runtime;constructor(s){this.options=s,this.runtime=new g6r.Runtime}async serve(){let s=await this.configure(),l=(0,j2t.serializeConfig)(s),_={requiredSockets:["http"],inspectorAddress:this.options.inspectorPort,handleRuntimeStdio:this.options.handleRuntimeStdio};await this.runtime.updateConfig(l,_)}async compileBinary(s){let l=await this.configure({embedVariables:!1}),_=(0,j2t.serializeConfig)(l);await this.runtime.compileBinary(_,s)}async dispose(){await this.runtime.dispose()}withSourceURL(s,l){if(s.lastIndexOf("//# sourceURL=")!==-1)return s;let h=`
|
|
565
565
|
//# sourceURL=${(0,h6r.pathToFileURL)(l)}
|
|
566
566
|
`;return s+h}async configure(s={embedVariables:!0}){let l=this.options.compatibilityDate??"2024-09-02";if(new Date(l)>new Date(B2t)&&(l=B2t),this.options.modules.length===0)throw new Error("No modules provided. Cannot run local dev server.");let _=this.options.modules.filter(w=>!w.endsWith(".js.map")).map(w=>{let N=m6r.default.join(this.options.scriptDirectory,w),B=(0,d6r.readFileSync)(N,"utf8"),q=this.withSourceURL(B,N);return{name:w,esModule:q}}).sort(w=>w.name==="./worker.js"?-1:1),h;s.embedVariables?h=Object.entries(this.options.bindings).map(([w,N])=>({name:w,json:JSON.stringify(N)})):h=Object.entries(this.options.bindings).map(([w])=>({name:w,fromEnvironment:w}));let b;return s.embedVariables?b=Object.entries(this.options.bindings).filter(([w])=>w.startsWith("ZUPLO_CACHE")).map(([w,N])=>({name:w,json:JSON.stringify(N)})):b=Object.entries(this.options.bindings).filter(([w])=>w.startsWith("ZUPLO_CACHE")).map(([w])=>({name:w,fromEnvironment:w})),{services:[{name:"zuplo-entry",worker:{modules:_,compatibilityDate:l,compatibilityFlags:["nodejs_compat"],bindings:h,cacheApiOutbound:{name:"zuplo-cache-extension"}}},{name:"zuplo-cache-extension",worker:{modules:[{name:"zuplo-cache-extension.js",esModule:y6r.ZUPLO_CACHE_EXTENSION}],bindings:b,compatibilityDate:l,compatibilityFlags:["nodejs_compat"]}},{name:"internet",network:{allow:["public","private"],deny:[],tlsOptions:{trustBrowserCas:!0,trustedCertificates:[]}}}],sockets:[{name:"http",address:`*:${this.options.port}`,http:{},service:{name:"zuplo-entry"}}]}}};r$.ZuploWorkerd=gLe});var z2t=Et((jXr,S6r)=>{S6r.exports={name:"dotenv",version:"16.5.0",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var H2t=Et((BXr,YA)=>{var bLe=_o("fs"),SLe=_o("path"),T6r=_o("os"),x6r=_o("crypto"),E6r=z2t(),q2t=E6r.version,C6r=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function w6r(a){let s={},l=a.toString();l=l.replace(/\r\n?/mg,`
|
|
567
567
|
`);let _;for(;(_=C6r.exec(l))!=null;){let h=_[1],b=_[2]||"";b=b.trim();let w=b[0];b=b.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),w==='"'&&(b=b.replace(/\\n/g,`
|
|
@@ -574,12 +574,12 @@ globstar while`,s,te,l,Ue,Ie),this.matchOne(s.slice(te),l.slice(Ue),_))return th
|
|
|
574
574
|
>>> no match, partial?`,s,te,l,Ue),te===B))}let De;if(typeof le=="string"?(De=se===le,this.debug("string match",le,se,De)):(De=le.test(se),this.debug("pattern match",le,se,De)),!De)return!1}if(w===B&&N===q)return!0;if(w===B)return _;if(N===q)return w===B-1&&s[w]==="";throw new Error("wtf?")}braceExpand(){return Yot(this.pattern,this.options)}parse(s){HH(s);let l=this.options;if(s==="**")return M0;if(s==="")return"";let _,h=null;(_=s.match(inr))?h=l.dot?anr:snr:(_=s.match(Grr))?h=(l.nocase?l.dot?Zrr:Xrr:l.dot?Yrr:Krr)(_[1]):(_=s.match(onr))?h=(l.nocase?l.dot?lnr:cnr:l.dot?unr:fnr)(_):(_=s.match(Qrr))?h=l.dot?tnr:enr:(_=s.match(rnr))&&(h=nnr);let b=KM.fromGlob(s,this.options).toMMPattern();return h&&typeof b=="object"&&Reflect.defineProperty(b,"test",{value:h}),b}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let s=this.set;if(!s.length)return this.regexp=!1,this.regexp;let l=this.options,_=l.noglobstar?dnr:l.dot?mnr:hnr,h=new Set(l.nocase?["i"]:[]),b=s.map(B=>{let q=B.map(le=>{if(le instanceof RegExp)for(let se of le.flags.split(""))h.add(se);return typeof le=="string"?Snr(le):le===M0?M0:le._src});return q.forEach((le,se)=>{let te=q[se+1],Ue=q[se-1];le!==M0||Ue===M0||(Ue===void 0?te!==void 0&&te!==M0?q[se+1]="(?:\\/|"+_+"\\/)?"+te:q[se]=_:te===void 0?q[se-1]=Ue+"(?:\\/|"+_+")?":te!==M0&&(q[se-1]=Ue+"(?:\\/|\\/"+_+"\\/)"+te,q[se+1]=M0))}),q.filter(le=>le!==M0).join("/")}).join("|"),[w,N]=s.length>1?["(?:",")"]:["",""];b="^"+w+b+N+"$",this.negate&&(b="^(?!"+b+").+$");try{this.regexp=new RegExp(b,[...h].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(s){return this.preserveMultipleSlashes?s.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(s)?["",...s.split(/\/+/)]:s.split(/\/+/)}match(s,l=this.partial){if(this.debug("match",s,this.pattern),this.comment)return!1;if(this.empty)return s==="";if(s==="/"&&l)return!0;let _=this.options;this.isWindows&&(s=s.split("\\").join("/"));let h=this.slashSplit(s);this.debug(this.pattern,"split",h);let b=this.set;this.debug(this.pattern,"set",b);let w=h[h.length-1];if(!w)for(let N=h.length-2;!w&&N>=0;N--)w=h[N];for(let N=0;N<b.length;N++){let B=b[N],q=h;if(_.matchBase&&B.length===1&&(q=[w]),this.matchOne(q,B,l))return _.flipNegate?!0:!this.negate}return _.flipNegate?!1:this.negate}static defaults(s){return Y1.defaults(s).Minimatch}};Y1.AST=KM;Y1.Minimatch=XS;Y1.escape=YM;Y1.unescape=GE;import{fileURLToPath as Qnr}from"node:url";var XM=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zot=new Set,dNe=typeof process=="object"&&process?process:{},Qot=t((a,s,l,_)=>{typeof dNe.emitWarning=="function"?dNe.emitWarning(a,s,l,_):console.error(`[${l}] ${s}: ${a}`)},"emitWarning"),Cle=globalThis.AbortController,Xot=globalThis.AbortSignal;if(typeof Cle>"u"){Xot=class{static{t(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(_,h){this._onabort.push(h)}},Cle=class{static{t(this,"AbortController")}constructor(){s()}signal=new Xot;abort(_){if(!this.signal.aborted){this.signal.reason=_,this.signal.aborted=!0;for(let h of this.signal._onabort)h(_);this.signal.onabort?.(_)}}};let a=dNe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",s=t(()=>{a&&(a=!1,Qot("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",s))},"warnACPolyfill")}var Tnr=t(a=>!Zot.has(a),"shouldWarn"),$7r=Symbol("type"),LI=t(a=>a&&a===Math.floor(a)&&a>0&&isFinite(a),"isPosInt"),ect=t(a=>LI(a)?a<=Math.pow(2,8)?Uint8Array:a<=Math.pow(2,16)?Uint16Array:a<=Math.pow(2,32)?Uint32Array:a<=Number.MAX_SAFE_INTEGER?ZM:null:null,"getUintArray"),ZM=class extends Array{static{t(this,"ZeroArray")}constructor(s){super(s),this.fill(0)}},mNe=class a{static{t(this,"Stack")}heap;length;static#e=!1;static create(s){let l=ect(s);if(!l)return[];a.#e=!0;let _=new a(s,l);return a.#e=!1,_}constructor(s,l){if(!a.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new l(s),this.length=0}push(s){this.heap[this.length++]=s}pop(){return this.heap[--this.length]}},KH=class a{static{t(this,"LRUCache")}#e;#n;#t;#r;#s;#p;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#_;#u;#c;#i;#a;#h;#m;#f;#d;#g;#y;#E;#T;#C;#w;#v;static unsafeExposeInternals(s){return{starts:s.#E,ttls:s.#T,sizes:s.#y,keyMap:s.#u,keyList:s.#c,valList:s.#i,next:s.#a,prev:s.#h,get head(){return s.#m},get tail(){return s.#f},free:s.#d,isBackgroundFetch:t(l=>s.#b(l),"isBackgroundFetch"),backgroundFetch:t((l,_,h,b)=>s.#U(l,_,h,b),"backgroundFetch"),moveToTail:t(l=>s.#S(l),"moveToTail"),indexes:t(l=>s.#F(l),"indexes"),rindexes:t(l=>s.#L(l),"rindexes"),isStale:t(l=>s.#k(l),"isStale")}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#_}get size(){return this.#o}get fetchMethod(){return this.#s}get memoMethod(){return this.#p}get dispose(){return this.#t}get disposeAfter(){return this.#r}constructor(s){let{max:l=0,ttl:_,ttlResolution:h=1,ttlAutopurge:b,updateAgeOnGet:w,updateAgeOnHas:N,allowStale:B,dispose:q,disposeAfter:le,noDisposeOnSet:se,noUpdateTTL:te,maxSize:Ue=0,maxEntrySize:Ie=0,sizeCalculation:De,fetchMethod:Tt,memoMethod:mt,noDeleteOnFetchRejection:hr,noDeleteOnStaleGet:rn,allowStaleOnFetchRejection:jr,allowStaleOnFetchAbort:Qr,ignoreFetchAbort:br}=s;if(l!==0&&!LI(l))throw new TypeError("max option must be a nonnegative integer");let yr=l?ect(l):Array;if(!yr)throw new Error("invalid max value: "+l);if(this.#e=l,this.#n=Ue,this.maxEntrySize=Ie||this.#n,this.sizeCalculation=De,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(mt!==void 0&&typeof mt!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#p=mt,Tt!==void 0&&typeof Tt!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#s=Tt,this.#w=!!Tt,this.#u=new Map,this.#c=new Array(l).fill(void 0),this.#i=new Array(l).fill(void 0),this.#a=new yr(l),this.#h=new yr(l),this.#m=0,this.#f=0,this.#d=mNe.create(l),this.#o=0,this.#_=0,typeof q=="function"&&(this.#t=q),typeof le=="function"?(this.#r=le,this.#g=[]):(this.#r=void 0,this.#g=void 0),this.#C=!!this.#t,this.#v=!!this.#r,this.noDisposeOnSet=!!se,this.noUpdateTTL=!!te,this.noDeleteOnFetchRejection=!!hr,this.allowStaleOnFetchRejection=!!jr,this.allowStaleOnFetchAbort=!!Qr,this.ignoreFetchAbort=!!br,this.maxEntrySize!==0){if(this.#n!==0&&!LI(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!LI(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#D()}if(this.allowStale=!!B,this.noDeleteOnStaleGet=!!rn,this.updateAgeOnGet=!!w,this.updateAgeOnHas=!!N,this.ttlResolution=LI(h)||h===0?h:1,this.ttlAutopurge=!!b,this.ttl=_||0,this.ttl){if(!LI(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#x()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let Zi="LRU_CACHE_UNBOUNDED";Tnr(Zi)&&(Zot.add(Zi),Qot("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Zi,a))}}getRemainingTTL(s){return this.#u.has(s)?1/0:0}#x(){let s=new ZM(this.#e),l=new ZM(this.#e);this.#T=s,this.#E=l,this.#O=(b,w,N=XM.now())=>{if(l[b]=w!==0?N:0,s[b]=w,w!==0&&this.ttlAutopurge){let B=setTimeout(()=>{this.#k(b)&&this.#M(this.#c[b],"expire")},w+1);B.unref&&B.unref()}},this.#A=b=>{l[b]=s[b]!==0?XM.now():0},this.#l=(b,w)=>{if(s[w]){let N=s[w],B=l[w];if(!N||!B)return;b.ttl=N,b.start=B,b.now=_||h();let q=b.now-B;b.remainingTTL=N-q}};let _=0,h=t(()=>{let b=XM.now();if(this.ttlResolution>0){_=b;let w=setTimeout(()=>_=0,this.ttlResolution);w.unref&&w.unref()}return b},"getNow");this.getRemainingTTL=b=>{let w=this.#u.get(b);if(w===void 0)return 0;let N=s[w],B=l[w];if(!N||!B)return 1/0;let q=(_||h())-B;return N-q},this.#k=b=>{let w=l[b],N=s[b];return!!N&&!!w&&(_||h())-w>N}}#A=t(()=>{},"#updateItemAge");#l=t(()=>{},"#statusTTL");#O=t(()=>{},"#setItemTTL");#k=t(()=>!1,"#isStale");#D(){let s=new ZM(this.#e);this.#_=0,this.#y=s,this.#P=l=>{this.#_-=s[l],s[l]=0},this.#R=(l,_,h,b)=>{if(this.#b(_))return 0;if(!LI(h))if(b){if(typeof b!="function")throw new TypeError("sizeCalculation must be a function");if(h=b(_,l),!LI(h))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return h},this.#$=(l,_,h)=>{if(s[l]=_,this.#n){let b=this.#n-s[l];for(;this.#_>b;)this.#I(!0)}this.#_+=s[l],h&&(h.entrySize=_,h.totalCalculatedSize=this.#_)}}#P=t(s=>{},"#removeItemSize");#$=t((s,l,_)=>{},"#addItemSize");#R=t((s,l,_,h)=>{if(_||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#F({allowStale:s=this.allowStale}={}){if(this.#o)for(let l=this.#f;!(!this.#N(l)||((s||!this.#k(l))&&(yield l),l===this.#m));)l=this.#h[l]}*#L({allowStale:s=this.allowStale}={}){if(this.#o)for(let l=this.#m;!(!this.#N(l)||((s||!this.#k(l))&&(yield l),l===this.#f));)l=this.#a[l]}#N(s){return s!==void 0&&this.#u.get(this.#c[s])===s}*entries(){for(let s of this.#F())this.#i[s]!==void 0&&this.#c[s]!==void 0&&!this.#b(this.#i[s])&&(yield[this.#c[s],this.#i[s]])}*rentries(){for(let s of this.#L())this.#i[s]!==void 0&&this.#c[s]!==void 0&&!this.#b(this.#i[s])&&(yield[this.#c[s],this.#i[s]])}*keys(){for(let s of this.#F()){let l=this.#c[s];l!==void 0&&!this.#b(this.#i[s])&&(yield l)}}*rkeys(){for(let s of this.#L()){let l=this.#c[s];l!==void 0&&!this.#b(this.#i[s])&&(yield l)}}*values(){for(let s of this.#F())this.#i[s]!==void 0&&!this.#b(this.#i[s])&&(yield this.#i[s])}*rvalues(){for(let s of this.#L())this.#i[s]!==void 0&&!this.#b(this.#i[s])&&(yield this.#i[s])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(s,l={}){for(let _ of this.#F()){let h=this.#i[_],b=this.#b(h)?h.__staleWhileFetching:h;if(b!==void 0&&s(b,this.#c[_],this))return this.get(this.#c[_],l)}}forEach(s,l=this){for(let _ of this.#F()){let h=this.#i[_],b=this.#b(h)?h.__staleWhileFetching:h;b!==void 0&&s.call(l,b,this.#c[_],this)}}rforEach(s,l=this){for(let _ of this.#L()){let h=this.#i[_],b=this.#b(h)?h.__staleWhileFetching:h;b!==void 0&&s.call(l,b,this.#c[_],this)}}purgeStale(){let s=!1;for(let l of this.#L({allowStale:!0}))this.#k(l)&&(this.#M(this.#c[l],"expire"),s=!0);return s}info(s){let l=this.#u.get(s);if(l===void 0)return;let _=this.#i[l],h=this.#b(_)?_.__staleWhileFetching:_;if(h===void 0)return;let b={value:h};if(this.#T&&this.#E){let w=this.#T[l],N=this.#E[l];if(w&&N){let B=w-(XM.now()-N);b.ttl=B,b.start=Date.now()}}return this.#y&&(b.size=this.#y[l]),b}dump(){let s=[];for(let l of this.#F({allowStale:!0})){let _=this.#c[l],h=this.#i[l],b=this.#b(h)?h.__staleWhileFetching:h;if(b===void 0||_===void 0)continue;let w={value:b};if(this.#T&&this.#E){w.ttl=this.#T[l];let N=XM.now()-this.#E[l];w.start=Math.floor(Date.now()-N)}this.#y&&(w.size=this.#y[l]),s.unshift([_,w])}return s}load(s){this.clear();for(let[l,_]of s){if(_.start){let h=Date.now()-_.start;_.start=XM.now()-h}this.set(l,_.value,_)}}set(s,l,_={}){if(l===void 0)return this.delete(s),this;let{ttl:h=this.ttl,start:b,noDisposeOnSet:w=this.noDisposeOnSet,sizeCalculation:N=this.sizeCalculation,status:B}=_,{noUpdateTTL:q=this.noUpdateTTL}=_,le=this.#R(s,l,_.size||0,N);if(this.maxEntrySize&&le>this.maxEntrySize)return B&&(B.set="miss",B.maxEntrySizeExceeded=!0),this.#M(s,"set"),this;let se=this.#o===0?void 0:this.#u.get(s);if(se===void 0)se=this.#o===0?this.#f:this.#d.length!==0?this.#d.pop():this.#o===this.#e?this.#I(!1):this.#o,this.#c[se]=s,this.#i[se]=l,this.#u.set(s,se),this.#a[this.#f]=se,this.#h[se]=this.#f,this.#f=se,this.#o++,this.#$(se,le,B),B&&(B.set="add"),q=!1;else{this.#S(se);let te=this.#i[se];if(l!==te){if(this.#w&&this.#b(te)){te.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:Ue}=te;Ue!==void 0&&!w&&(this.#C&&this.#t?.(Ue,s,"set"),this.#v&&this.#g?.push([Ue,s,"set"]))}else w||(this.#C&&this.#t?.(te,s,"set"),this.#v&&this.#g?.push([te,s,"set"]));if(this.#P(se),this.#$(se,le,B),this.#i[se]=l,B){B.set="replace";let Ue=te&&this.#b(te)?te.__staleWhileFetching:te;Ue!==void 0&&(B.oldValue=Ue)}}else B&&(B.set="update")}if(h!==0&&!this.#T&&this.#x(),this.#T&&(q||this.#O(se,h,b),B&&this.#l(B,se)),!w&&this.#v&&this.#g){let te=this.#g,Ue;for(;Ue=te?.shift();)this.#r?.(...Ue)}return this}pop(){try{for(;this.#o;){let s=this.#i[this.#m];if(this.#I(!0),this.#b(s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(this.#v&&this.#g){let s=this.#g,l;for(;l=s?.shift();)this.#r?.(...l)}}}#I(s){let l=this.#m,_=this.#c[l],h=this.#i[l];return this.#w&&this.#b(h)?h.__abortController.abort(new Error("evicted")):(this.#C||this.#v)&&(this.#C&&this.#t?.(h,_,"evict"),this.#v&&this.#g?.push([h,_,"evict"])),this.#P(l),s&&(this.#c[l]=void 0,this.#i[l]=void 0,this.#d.push(l)),this.#o===1?(this.#m=this.#f=0,this.#d.length=0):this.#m=this.#a[l],this.#u.delete(_),this.#o--,l}has(s,l={}){let{updateAgeOnHas:_=this.updateAgeOnHas,status:h}=l,b=this.#u.get(s);if(b!==void 0){let w=this.#i[b];if(this.#b(w)&&w.__staleWhileFetching===void 0)return!1;if(this.#k(b))h&&(h.has="stale",this.#l(h,b));else return _&&this.#A(b),h&&(h.has="hit",this.#l(h,b)),!0}else h&&(h.has="miss");return!1}peek(s,l={}){let{allowStale:_=this.allowStale}=l,h=this.#u.get(s);if(h===void 0||!_&&this.#k(h))return;let b=this.#i[h];return this.#b(b)?b.__staleWhileFetching:b}#U(s,l,_,h){let b=l===void 0?void 0:this.#i[l];if(this.#b(b))return b;let w=new Cle,{signal:N}=_;N?.addEventListener("abort",()=>w.abort(N.reason),{signal:w.signal});let B={signal:w.signal,options:_,context:h},q=t((De,Tt=!1)=>{let{aborted:mt}=w.signal,hr=_.ignoreFetchAbort&&De!==void 0;if(_.status&&(mt&&!Tt?(_.status.fetchAborted=!0,_.status.fetchError=w.signal.reason,hr&&(_.status.fetchAbortIgnored=!0)):_.status.fetchResolved=!0),mt&&!hr&&!Tt)return se(w.signal.reason);let rn=Ue;return this.#i[l]===Ue&&(De===void 0?rn.__staleWhileFetching?this.#i[l]=rn.__staleWhileFetching:this.#M(s,"fetch"):(_.status&&(_.status.fetchUpdated=!0),this.set(s,De,B.options))),De},"cb"),le=t(De=>(_.status&&(_.status.fetchRejected=!0,_.status.fetchError=De),se(De)),"eb"),se=t(De=>{let{aborted:Tt}=w.signal,mt=Tt&&_.allowStaleOnFetchAbort,hr=mt||_.allowStaleOnFetchRejection,rn=hr||_.noDeleteOnFetchRejection,jr=Ue;if(this.#i[l]===Ue&&(!rn||jr.__staleWhileFetching===void 0?this.#M(s,"fetch"):mt||(this.#i[l]=jr.__staleWhileFetching)),hr)return _.status&&jr.__staleWhileFetching!==void 0&&(_.status.returnedStale=!0),jr.__staleWhileFetching;if(jr.__returned===jr)throw De},"fetchFail"),te=t((De,Tt)=>{let mt=this.#s?.(s,b,B);mt&&mt instanceof Promise&&mt.then(hr=>De(hr===void 0?void 0:hr),Tt),w.signal.addEventListener("abort",()=>{(!_.ignoreFetchAbort||_.allowStaleOnFetchAbort)&&(De(void 0),_.allowStaleOnFetchAbort&&(De=t(hr=>q(hr,!0),"res")))})},"pcall");_.status&&(_.status.fetchDispatched=!0);let Ue=new Promise(te).then(q,le),Ie=Object.assign(Ue,{__abortController:w,__staleWhileFetching:b,__returned:void 0});return l===void 0?(this.set(s,Ie,{...B.options,status:void 0}),l=this.#u.get(s)):this.#i[l]=Ie,Ie}#b(s){if(!this.#w)return!1;let l=s;return!!l&&l instanceof Promise&&l.hasOwnProperty("__staleWhileFetching")&&l.__abortController instanceof Cle}async fetch(s,l={}){let{allowStale:_=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:b=this.noDeleteOnStaleGet,ttl:w=this.ttl,noDisposeOnSet:N=this.noDisposeOnSet,size:B=0,sizeCalculation:q=this.sizeCalculation,noUpdateTTL:le=this.noUpdateTTL,noDeleteOnFetchRejection:se=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:te=this.allowStaleOnFetchRejection,ignoreFetchAbort:Ue=this.ignoreFetchAbort,allowStaleOnFetchAbort:Ie=this.allowStaleOnFetchAbort,context:De,forceRefresh:Tt=!1,status:mt,signal:hr}=l;if(!this.#w)return mt&&(mt.fetch="get"),this.get(s,{allowStale:_,updateAgeOnGet:h,noDeleteOnStaleGet:b,status:mt});let rn={allowStale:_,updateAgeOnGet:h,noDeleteOnStaleGet:b,ttl:w,noDisposeOnSet:N,size:B,sizeCalculation:q,noUpdateTTL:le,noDeleteOnFetchRejection:se,allowStaleOnFetchRejection:te,allowStaleOnFetchAbort:Ie,ignoreFetchAbort:Ue,status:mt,signal:hr},jr=this.#u.get(s);if(jr===void 0){mt&&(mt.fetch="miss");let Qr=this.#U(s,jr,rn,De);return Qr.__returned=Qr}else{let Qr=this.#i[jr];if(this.#b(Qr)){let Po=_&&Qr.__staleWhileFetching!==void 0;return mt&&(mt.fetch="inflight",Po&&(mt.returnedStale=!0)),Po?Qr.__staleWhileFetching:Qr.__returned=Qr}let br=this.#k(jr);if(!Tt&&!br)return mt&&(mt.fetch="hit"),this.#S(jr),h&&this.#A(jr),mt&&this.#l(mt,jr),Qr;let yr=this.#U(s,jr,rn,De),Ci=yr.__staleWhileFetching!==void 0&&_;return mt&&(mt.fetch=br?"stale":"refresh",Ci&&br&&(mt.returnedStale=!0)),Ci?yr.__staleWhileFetching:yr.__returned=yr}}async forceFetch(s,l={}){let _=await this.fetch(s,l);if(_===void 0)throw new Error("fetch() returned undefined");return _}memo(s,l={}){let _=this.#p;if(!_)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:b,...w}=l,N=this.get(s,w);if(!b&&N!==void 0)return N;let B=_(s,N,{options:w,context:h});return this.set(s,B,w),B}get(s,l={}){let{allowStale:_=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:b=this.noDeleteOnStaleGet,status:w}=l,N=this.#u.get(s);if(N!==void 0){let B=this.#i[N],q=this.#b(B);return w&&this.#l(w,N),this.#k(N)?(w&&(w.get="stale"),q?(w&&_&&B.__staleWhileFetching!==void 0&&(w.returnedStale=!0),_?B.__staleWhileFetching:void 0):(b||this.#M(s,"expire"),w&&_&&(w.returnedStale=!0),_?B:void 0)):(w&&(w.get="hit"),q?B.__staleWhileFetching:(this.#S(N),h&&this.#A(N),B))}else w&&(w.get="miss")}#j(s,l){this.#h[l]=s,this.#a[s]=l}#S(s){s!==this.#f&&(s===this.#m?this.#m=this.#a[s]:this.#j(this.#h[s],this.#a[s]),this.#j(this.#f,s),this.#f=s)}delete(s){return this.#M(s,"delete")}#M(s,l){let _=!1;if(this.#o!==0){let h=this.#u.get(s);if(h!==void 0)if(_=!0,this.#o===1)this.#z(l);else{this.#P(h);let b=this.#i[h];if(this.#b(b)?b.__abortController.abort(new Error("deleted")):(this.#C||this.#v)&&(this.#C&&this.#t?.(b,s,l),this.#v&&this.#g?.push([b,s,l])),this.#u.delete(s),this.#c[h]=void 0,this.#i[h]=void 0,h===this.#f)this.#f=this.#h[h];else if(h===this.#m)this.#m=this.#a[h];else{let w=this.#h[h];this.#a[w]=this.#a[h];let N=this.#a[h];this.#h[N]=this.#h[h]}this.#o--,this.#d.push(h)}}if(this.#v&&this.#g?.length){let h=this.#g,b;for(;b=h?.shift();)this.#r?.(...b)}return _}clear(){return this.#z("delete")}#z(s){for(let l of this.#L({allowStale:!0})){let _=this.#i[l];if(this.#b(_))_.__abortController.abort(new Error("deleted"));else{let h=this.#c[l];this.#C&&this.#t?.(_,h,s),this.#v&&this.#g?.push([_,h,s])}}if(this.#u.clear(),this.#i.fill(void 0),this.#c.fill(void 0),this.#T&&this.#E&&(this.#T.fill(0),this.#E.fill(0)),this.#y&&this.#y.fill(0),this.#m=0,this.#f=0,this.#d.length=0,this.#_=0,this.#o=0,this.#v&&this.#g){let l=this.#g,_;for(;_=l?.shift();)this.#r?.(..._)}}};import{posix as Onr,win32 as CNe}from"node:path";import{fileURLToPath as Fnr}from"node:url";import{lstatSync as Lnr,readdir as Rnr,readdirSync as Mnr,readlinkSync as jnr,realpathSync as Bnr}from"fs";import*as $nr from"node:fs";import{lstat as znr,readdir as Jnr,readlink as qnr,realpath as Vnr}from"node:fs/promises";import{EventEmitter as TNe}from"node:events";import sct from"node:stream";import{StringDecoder as xnr}from"node:string_decoder";var tct=typeof process=="object"&&process?process:{stdout:null,stderr:null},Enr=t(a=>!!a&&typeof a=="object"&&(a instanceof MI||a instanceof sct||Cnr(a)||wnr(a)),"isStream"),Cnr=t(a=>!!a&&typeof a=="object"&&a instanceof TNe&&typeof a.pipe=="function"&&a.pipe!==sct.Writable.prototype.pipe,"isReadable"),wnr=t(a=>!!a&&typeof a=="object"&&a instanceof TNe&&typeof a.write=="function"&&typeof a.end=="function","isWritable"),TA=Symbol("EOF"),xA=Symbol("maybeEmitEnd"),RI=Symbol("emittedEnd"),wle=Symbol("emittingEnd"),YH=Symbol("emittedError"),kle=Symbol("closed"),rct=Symbol("read"),Dle=Symbol("flush"),nct=Symbol("flushChunk"),KE=Symbol("encoding"),QM=Symbol("decoder"),Hg=Symbol("flowing"),XH=Symbol("paused"),ej=Symbol("resume"),Gg=Symbol("buffer"),X1=Symbol("pipes"),Kg=Symbol("bufferLength"),hNe=Symbol("bufferPush"),Ple=Symbol("bufferShift"),zy=Symbol("objectMode"),jm=Symbol("destroyed"),gNe=Symbol("error"),yNe=Symbol("emitData"),ict=Symbol("emitEnd"),vNe=Symbol("emitEnd2"),_k=Symbol("async"),bNe=Symbol("abort"),Ale=Symbol("aborted"),ZH=Symbol("signal"),l7=Symbol("dataListeners"),ZS=Symbol("discarded"),QH=t(a=>Promise.resolve().then(a),"defer"),knr=t(a=>a(),"nodefer"),Dnr=t(a=>a==="end"||a==="finish"||a==="prefinish","isEndish"),Pnr=t(a=>a instanceof ArrayBuffer||!!a&&typeof a=="object"&&a.constructor&&a.constructor.name==="ArrayBuffer"&&a.byteLength>=0,"isArrayBufferLike"),Anr=t(a=>!Buffer.isBuffer(a)&&ArrayBuffer.isView(a),"isArrayBufferView"),Nle=class{static{t(this,"Pipe")}src;dest;opts;ondrain;constructor(s,l,_){this.src=s,this.dest=l,this.opts=_,this.ondrain=()=>s[ej](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(s){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},SNe=class extends Nle{static{t(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(s,l,_){super(s,l,_),this.proxyErrors=h=>l.emit("error",h),s.on("error",this.proxyErrors)}},Nnr=t(a=>!!a.objectMode,"isObjectModeOptions"),Inr=t(a=>!a.objectMode&&!!a.encoding&&a.encoding!=="buffer","isEncodingOptions"),MI=class extends TNe{static{t(this,"Minipass")}[Hg]=!1;[XH]=!1;[X1]=[];[Gg]=[];[zy];[KE];[_k];[QM];[TA]=!1;[RI]=!1;[wle]=!1;[kle]=!1;[YH]=null;[Kg]=0;[jm]=!1;[ZH];[Ale]=!1;[l7]=0;[ZS]=!1;writable=!0;readable=!0;constructor(...s){let l=s[0]||{};if(super(),l.objectMode&&typeof l.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Nnr(l)?(this[zy]=!0,this[KE]=null):Inr(l)?(this[KE]=l.encoding,this[zy]=!1):(this[zy]=!1,this[KE]=null),this[_k]=!!l.async,this[QM]=this[KE]?new xnr(this[KE]):null,l&&l.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:t(()=>this[Gg],"get")}),l&&l.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:t(()=>this[X1],"get")});let{signal:_}=l;_&&(this[ZH]=_,_.aborted?this[bNe]():_.addEventListener("abort",()=>this[bNe]()))}get bufferLength(){return this[Kg]}get encoding(){return this[KE]}set encoding(s){throw new Error("Encoding must be set at instantiation time")}setEncoding(s){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[zy]}set objectMode(s){throw new Error("objectMode must be set at instantiation time")}get async(){return this[_k]}set async(s){this[_k]=this[_k]||!!s}[bNe](){this[Ale]=!0,this.emit("abort",this[ZH]?.reason),this.destroy(this[ZH]?.reason)}get aborted(){return this[Ale]}set aborted(s){}write(s,l,_){if(this[Ale])return!1;if(this[TA])throw new Error("write after end");if(this[jm])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof l=="function"&&(_=l,l="utf8"),l||(l="utf8");let h=this[_k]?QH:knr;if(!this[zy]&&!Buffer.isBuffer(s)){if(Anr(s))s=Buffer.from(s.buffer,s.byteOffset,s.byteLength);else if(Pnr(s))s=Buffer.from(s);else if(typeof s!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[zy]?(this[Hg]&&this[Kg]!==0&&this[Dle](!0),this[Hg]?this.emit("data",s):this[hNe](s),this[Kg]!==0&&this.emit("readable"),_&&h(_),this[Hg]):s.length?(typeof s=="string"&&!(l===this[KE]&&!this[QM]?.lastNeed)&&(s=Buffer.from(s,l)),Buffer.isBuffer(s)&&this[KE]&&(s=this[QM].write(s)),this[Hg]&&this[Kg]!==0&&this[Dle](!0),this[Hg]?this.emit("data",s):this[hNe](s),this[Kg]!==0&&this.emit("readable"),_&&h(_),this[Hg]):(this[Kg]!==0&&this.emit("readable"),_&&h(_),this[Hg])}read(s){if(this[jm])return null;if(this[ZS]=!1,this[Kg]===0||s===0||s&&s>this[Kg])return this[xA](),null;this[zy]&&(s=null),this[Gg].length>1&&!this[zy]&&(this[Gg]=[this[KE]?this[Gg].join(""):Buffer.concat(this[Gg],this[Kg])]);let l=this[rct](s||null,this[Gg][0]);return this[xA](),l}[rct](s,l){if(this[zy])this[Ple]();else{let _=l;s===_.length||s===null?this[Ple]():typeof _=="string"?(this[Gg][0]=_.slice(s),l=_.slice(0,s),this[Kg]-=s):(this[Gg][0]=_.subarray(s),l=_.subarray(0,s),this[Kg]-=s)}return this.emit("data",l),!this[Gg].length&&!this[TA]&&this.emit("drain"),l}end(s,l,_){return typeof s=="function"&&(_=s,s=void 0),typeof l=="function"&&(_=l,l="utf8"),s!==void 0&&this.write(s,l),_&&this.once("end",_),this[TA]=!0,this.writable=!1,(this[Hg]||!this[XH])&&this[xA](),this}[ej](){this[jm]||(!this[l7]&&!this[X1].length&&(this[ZS]=!0),this[XH]=!1,this[Hg]=!0,this.emit("resume"),this[Gg].length?this[Dle]():this[TA]?this[xA]():this.emit("drain"))}resume(){return this[ej]()}pause(){this[Hg]=!1,this[XH]=!0,this[ZS]=!1}get destroyed(){return this[jm]}get flowing(){return this[Hg]}get paused(){return this[XH]}[hNe](s){this[zy]?this[Kg]+=1:this[Kg]+=s.length,this[Gg].push(s)}[Ple](){return this[zy]?this[Kg]-=1:this[Kg]-=this[Gg][0].length,this[Gg].shift()}[Dle](s=!1){do;while(this[nct](this[Ple]())&&this[Gg].length);!s&&!this[Gg].length&&!this[TA]&&this.emit("drain")}[nct](s){return this.emit("data",s),this[Hg]}pipe(s,l){if(this[jm])return s;this[ZS]=!1;let _=this[RI];return l=l||{},s===tct.stdout||s===tct.stderr?l.end=!1:l.end=l.end!==!1,l.proxyErrors=!!l.proxyErrors,_?l.end&&s.end():(this[X1].push(l.proxyErrors?new SNe(this,s,l):new Nle(this,s,l)),this[_k]?QH(()=>this[ej]()):this[ej]()),s}unpipe(s){let l=this[X1].find(_=>_.dest===s);l&&(this[X1].length===1?(this[Hg]&&this[l7]===0&&(this[Hg]=!1),this[X1]=[]):this[X1].splice(this[X1].indexOf(l),1),l.unpipe())}addListener(s,l){return this.on(s,l)}on(s,l){let _=super.on(s,l);if(s==="data")this[ZS]=!1,this[l7]++,!this[X1].length&&!this[Hg]&&this[ej]();else if(s==="readable"&&this[Kg]!==0)super.emit("readable");else if(Dnr(s)&&this[RI])super.emit(s),this.removeAllListeners(s);else if(s==="error"&&this[YH]){let h=l;this[_k]?QH(()=>h.call(this,this[YH])):h.call(this,this[YH])}return _}removeListener(s,l){return this.off(s,l)}off(s,l){let _=super.off(s,l);return s==="data"&&(this[l7]=this.listeners("data").length,this[l7]===0&&!this[ZS]&&!this[X1].length&&(this[Hg]=!1)),_}removeAllListeners(s){let l=super.removeAllListeners(s);return(s==="data"||s===void 0)&&(this[l7]=0,!this[ZS]&&!this[X1].length&&(this[Hg]=!1)),l}get emittedEnd(){return this[RI]}[xA](){!this[wle]&&!this[RI]&&!this[jm]&&this[Gg].length===0&&this[TA]&&(this[wle]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[kle]&&this.emit("close"),this[wle]=!1)}emit(s,...l){let _=l[0];if(s!=="error"&&s!=="close"&&s!==jm&&this[jm])return!1;if(s==="data")return!this[zy]&&!_?!1:this[_k]?(QH(()=>this[yNe](_)),!0):this[yNe](_);if(s==="end")return this[ict]();if(s==="close"){if(this[kle]=!0,!this[RI]&&!this[jm])return!1;let b=super.emit("close");return this.removeAllListeners("close"),b}else if(s==="error"){this[YH]=_,super.emit(gNe,_);let b=!this[ZH]||this.listeners("error").length?super.emit("error",_):!1;return this[xA](),b}else if(s==="resume"){let b=super.emit("resume");return this[xA](),b}else if(s==="finish"||s==="prefinish"){let b=super.emit(s);return this.removeAllListeners(s),b}let h=super.emit(s,...l);return this[xA](),h}[yNe](s){for(let _ of this[X1])_.dest.write(s)===!1&&this.pause();let l=this[ZS]?!1:super.emit("data",s);return this[xA](),l}[ict](){return this[RI]?!1:(this[RI]=!0,this.readable=!1,this[_k]?(QH(()=>this[vNe]()),!0):this[vNe]())}[vNe](){if(this[QM]){let l=this[QM].end();if(l){for(let _ of this[X1])_.dest.write(l);this[ZS]||super.emit("data",l)}}for(let l of this[X1])l.end();let s=super.emit("end");return this.removeAllListeners("end"),s}async collect(){let s=Object.assign([],{dataLength:0});this[zy]||(s.dataLength=0);let l=this.promise();return this.on("data",_=>{s.push(_),this[zy]||(s.dataLength+=_.length)}),await l,s}async concat(){if(this[zy])throw new Error("cannot concat in objectMode");let s=await this.collect();return this[KE]?s.join(""):Buffer.concat(s,s.dataLength)}async promise(){return new Promise((s,l)=>{this.on(jm,()=>l(new Error("stream destroyed"))),this.on("error",_=>l(_)),this.on("end",()=>s())})}[Symbol.asyncIterator](){this[ZS]=!1;let s=!1,l=t(async()=>(this.pause(),s=!0,{value:void 0,done:!0}),"stop");return{next:t(()=>{if(s)return l();let h=this.read();if(h!==null)return Promise.resolve({done:!1,value:h});if(this[TA])return l();let b,w,N=t(se=>{this.off("data",B),this.off("end",q),this.off(jm,le),l(),w(se)},"onerr"),B=t(se=>{this.off("error",N),this.off("end",q),this.off(jm,le),this.pause(),b({value:se,done:!!this[TA]})},"ondata"),q=t(()=>{this.off("error",N),this.off("data",B),this.off(jm,le),l(),b({done:!0,value:void 0})},"onend"),le=t(()=>N(new Error("stream destroyed")),"ondestroy");return new Promise((se,te)=>{w=te,b=se,this.once(jm,le),this.once("error",N),this.once("end",q),this.once("data",B)})},"next"),throw:l,return:l,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[ZS]=!1;let s=!1,l=t(()=>(this.pause(),this.off(gNe,l),this.off(jm,l),this.off("end",l),s=!0,{done:!0,value:void 0}),"stop"),_=t(()=>{if(s)return l();let h=this.read();return h===null?l():{done:!1,value:h}},"next");return this.once("end",l),this.once(gNe,l),this.once(jm,l),{next:_,throw:l,return:l,[Symbol.iterator](){return this}}}destroy(s){if(this[jm])return s?this.emit("error",s):this.emit(jm),this;this[jm]=!0,this[ZS]=!0,this[Gg].length=0,this[Kg]=0;let l=this;return typeof l.close=="function"&&!this[kle]&&l.close(),s?this.emit("error",s):this.emit(jm),this}static get isStream(){return Enr}};var Unr=Bnr.native,tG={lstatSync:Lnr,readdir:Rnr,readdirSync:Mnr,readlinkSync:jnr,realpathSync:Unr,promises:{lstat:znr,readdir:Jnr,readlink:qnr,realpath:Vnr}},uct=t(a=>!a||a===tG||a===$nr?tG:{...tG,...a,promises:{...tG.promises,...a.promises||{}}},"fsFromOption"),fct=/^\\\\\?\\([a-z]:)\\?$/i,Wnr=t(a=>a.replace(/\//g,"\\").replace(fct,"$1\\"),"uncToDrive"),Hnr=/[\\\/]/,IT=0,_ct=1,pct=2,pk=4,dct=6,mct=8,u7=10,hct=12,NT=15,eG=~NT,xNe=16,act=32,rG=64,YE=128,Ile=256,Fle=512,oct=rG|YE|Fle,Gnr=1023,ENe=t(a=>a.isFile()?mct:a.isDirectory()?pk:a.isSymbolicLink()?u7:a.isCharacterDevice()?pct:a.isBlockDevice()?dct:a.isSocket()?hct:a.isFIFO()?_ct:IT,"entToType"),cct=new Map,nG=t(a=>{let s=cct.get(a);if(s)return s;let l=a.normalize("NFKD");return cct.set(a,l),l},"normalize"),lct=new Map,Ole=t(a=>{let s=lct.get(a);if(s)return s;let l=nG(a.toLowerCase());return lct.set(a,l),l},"normalizeNocase"),Lle=class extends KH{static{t(this,"ResolveCache")}constructor(){super({max:256})}},wNe=class extends KH{static{t(this,"ChildrenCache")}constructor(s=16*1024){super({maxSize:s,sizeCalculation:t(l=>l.length+1,"sizeCalculation")})}},gct=Symbol("PathScurry setAsCwd"),Jy=class{static{t(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#e;#n;get dev(){return this.#n}#t;get mode(){return this.#t}#r;get nlink(){return this.#r}#s;get uid(){return this.#s}#p;get gid(){return this.#p}#o;get rdev(){return this.#o}#_;get blksize(){return this.#_}#u;get ino(){return this.#u}#c;get size(){return this.#c}#i;get blocks(){return this.#i}#a;get atimeMs(){return this.#a}#h;get mtimeMs(){return this.#h}#m;get ctimeMs(){return this.#m}#f;get birthtimeMs(){return this.#f}#d;get atime(){return this.#d}#g;get mtime(){return this.#g}#y;get ctime(){return this.#y}#E;get birthtime(){return this.#E}#T;#C;#w;#v;#x;#A;#l;#O;#k;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(s,l=IT,_,h,b,w,N){this.name=s,this.#T=b?Ole(s):nG(s),this.#l=l&Gnr,this.nocase=b,this.roots=h,this.root=_||this,this.#O=w,this.#w=N.fullpath,this.#x=N.relative,this.#A=N.relativePosix,this.parent=N.parent,this.parent?this.#e=this.parent.#e:this.#e=uct(N.fs)}depth(){return this.#C!==void 0?this.#C:this.parent?this.#C=this.parent.depth()+1:this.#C=0}childrenCache(){return this.#O}resolve(s){if(!s)return this;let l=this.getRootString(s),h=s.substring(l.length).split(this.splitSep);return l?this.getRoot(l).#P(h):this.#P(h)}#P(s){let l=this;for(let _ of s)l=l.child(_);return l}children(){let s=this.#O.get(this);if(s)return s;let l=Object.assign([],{provisional:0});return this.#O.set(this,l),this.#l&=~xNe,l}child(s,l){if(s===""||s===".")return this;if(s==="..")return this.parent||this;let _=this.children(),h=this.nocase?Ole(s):nG(s);for(let B of _)if(B.#T===h)return B;let b=this.parent?this.sep:"",w=this.#w?this.#w+b+s:void 0,N=this.newChild(s,IT,{...l,parent:this,fullpath:w});return this.canReaddir()||(N.#l|=YE),_.push(N),N}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let s=this.name,l=this.parent;if(!l)return this.#x=this.name;let _=l.relative();return _+(!_||!l.parent?"":this.sep)+s}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#A!==void 0)return this.#A;let s=this.name,l=this.parent;if(!l)return this.#A=this.fullpathPosix();let _=l.relativePosix();return _+(!_||!l.parent?"":"/")+s}fullpath(){if(this.#w!==void 0)return this.#w;let s=this.name,l=this.parent;if(!l)return this.#w=this.name;let h=l.fullpath()+(l.parent?this.sep:"")+s;return this.#w=h}fullpathPosix(){if(this.#v!==void 0)return this.#v;if(this.sep==="/")return this.#v=this.fullpath();if(!this.parent){let h=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(h)?this.#v=`//?/${h}`:this.#v=h}let s=this.parent,l=s.fullpathPosix(),_=l+(!l||!s.parent?"":"/")+this.name;return this.#v=_}isUnknown(){return(this.#l&NT)===IT}isType(s){return this[`is${s}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#l&NT)===mct}isDirectory(){return(this.#l&NT)===pk}isCharacterDevice(){return(this.#l&NT)===pct}isBlockDevice(){return(this.#l&NT)===dct}isFIFO(){return(this.#l&NT)===_ct}isSocket(){return(this.#l&NT)===hct}isSymbolicLink(){return(this.#l&u7)===u7}lstatCached(){return this.#l&act?this:void 0}readlinkCached(){return this.#k}realpathCached(){return this.#D}readdirCached(){let s=this.children();return s.slice(0,s.provisional)}canReadlink(){if(this.#k)return!0;if(!this.parent)return!1;let s=this.#l&NT;return!(s!==IT&&s!==u7||this.#l&Ile||this.#l&YE)}calledReaddir(){return!!(this.#l&xNe)}isENOENT(){return!!(this.#l&YE)}isNamed(s){return this.nocase?this.#T===Ole(s):this.#T===nG(s)}async readlink(){let s=this.#k;if(s)return s;if(this.canReadlink()&&this.parent)try{let l=await this.#e.promises.readlink(this.fullpath()),_=(await this.parent.realpath())?.resolve(l);if(_)return this.#k=_}catch(l){this.#b(l.code);return}}readlinkSync(){let s=this.#k;if(s)return s;if(this.canReadlink()&&this.parent)try{let l=this.#e.readlinkSync(this.fullpath()),_=this.parent.realpathSync()?.resolve(l);if(_)return this.#k=_}catch(l){this.#b(l.code);return}}#$(s){this.#l|=xNe;for(let l=s.provisional;l<s.length;l++){let _=s[l];_&&_.#R()}}#R(){this.#l&YE||(this.#l=(this.#l|YE)&eG,this.#F())}#F(){let s=this.children();s.provisional=0;for(let l of s)l.#R()}#L(){this.#l|=Fle,this.#N()}#N(){if(this.#l&rG)return;let s=this.#l;(s&NT)===pk&&(s&=eG),this.#l=s|rG,this.#F()}#I(s=""){s==="ENOTDIR"||s==="EPERM"?this.#N():s==="ENOENT"?this.#R():this.children().provisional=0}#U(s=""){s==="ENOTDIR"?this.parent.#N():s==="ENOENT"&&this.#R()}#b(s=""){let l=this.#l;l|=Ile,s==="ENOENT"&&(l|=YE),(s==="EINVAL"||s==="UNKNOWN")&&(l&=eG),this.#l=l,s==="ENOTDIR"&&this.parent&&this.parent.#N()}#j(s,l){return this.#M(s,l)||this.#S(s,l)}#S(s,l){let _=ENe(s),h=this.newChild(s.name,_,{parent:this}),b=h.#l&NT;return b!==pk&&b!==u7&&b!==IT&&(h.#l|=rG),l.unshift(h),l.provisional++,h}#M(s,l){for(let _=l.provisional;_<l.length;_++){let h=l[_];if((this.nocase?Ole(s.name):nG(s.name))===h.#T)return this.#z(s,h,_,l)}}#z(s,l,_,h){let b=l.name;return l.#l=l.#l&eG|ENe(s),b!==s.name&&(l.name=s.name),_!==h.provisional&&(_===h.length-1?h.pop():h.splice(_,1),h.unshift(l)),h.provisional++,l}async lstat(){if((this.#l&YE)===0)try{return this.#B(await this.#e.promises.lstat(this.fullpath())),this}catch(s){this.#U(s.code)}}lstatSync(){if((this.#l&YE)===0)try{return this.#B(this.#e.lstatSync(this.fullpath())),this}catch(s){this.#U(s.code)}}#B(s){let{atime:l,atimeMs:_,birthtime:h,birthtimeMs:b,blksize:w,blocks:N,ctime:B,ctimeMs:q,dev:le,gid:se,ino:te,mode:Ue,mtime:Ie,mtimeMs:De,nlink:Tt,rdev:mt,size:hr,uid:rn}=s;this.#d=l,this.#a=_,this.#E=h,this.#f=b,this.#_=w,this.#i=N,this.#y=B,this.#m=q,this.#n=le,this.#p=se,this.#u=te,this.#t=Ue,this.#g=Ie,this.#h=De,this.#r=Tt,this.#o=mt,this.#c=hr,this.#s=rn;let jr=ENe(s);this.#l=this.#l&eG|jr|act,jr!==IT&&jr!==pk&&jr!==u7&&(this.#l|=rG)}#J=[];#V=!1;#W(s){this.#V=!1;let l=this.#J.slice();this.#J.length=0,l.forEach(_=>_(null,s))}readdirCB(s,l=!1){if(!this.canReaddir()){l?s(null,[]):queueMicrotask(()=>s(null,[]));return}let _=this.children();if(this.calledReaddir()){let b=_.slice(0,_.provisional);l?s(null,b):queueMicrotask(()=>s(null,b));return}if(this.#J.push(s),this.#V)return;this.#V=!0;let h=this.fullpath();this.#e.readdir(h,{withFileTypes:!0},(b,w)=>{if(b)this.#I(b.code),_.provisional=0;else{for(let N of w)this.#j(N,_);this.#$(_)}this.#W(_.slice(0,_.provisional))})}#q;async readdir(){if(!this.canReaddir())return[];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let l=this.fullpath();if(this.#q)await this.#q;else{let _=t(()=>{},"resolve");this.#q=new Promise(h=>_=h);try{for(let h of await this.#e.promises.readdir(l,{withFileTypes:!0}))this.#j(h,s);this.#$(s)}catch(h){this.#I(h.code),s.provisional=0}this.#q=void 0,_()}return s.slice(0,s.provisional)}readdirSync(){if(!this.canReaddir())return[];let s=this.children();if(this.calledReaddir())return s.slice(0,s.provisional);let l=this.fullpath();try{for(let _ of this.#e.readdirSync(l,{withFileTypes:!0}))this.#j(_,s);this.#$(s)}catch(_){this.#I(_.code),s.provisional=0}return s.slice(0,s.provisional)}canReaddir(){if(this.#l&oct)return!1;let s=NT&this.#l;return s===IT||s===pk||s===u7}shouldWalk(s,l){return(this.#l&pk)===pk&&!(this.#l&oct)&&!s.has(this)&&(!l||l(this))}async realpath(){if(this.#D)return this.#D;if(!((Fle|Ile|YE)&this.#l))try{let s=await this.#e.promises.realpath(this.fullpath());return this.#D=this.resolve(s)}catch{this.#L()}}realpathSync(){if(this.#D)return this.#D;if(!((Fle|Ile|YE)&this.#l))try{let s=this.#e.realpathSync(this.fullpath());return this.#D=this.resolve(s)}catch{this.#L()}}[gct](s){if(s===this)return;s.isCWD=!1,this.isCWD=!0;let l=new Set([]),_=[],h=this;for(;h&&h.parent;)l.add(h),h.#x=_.join(this.sep),h.#A=_.join("/"),h=h.parent,_.push("..");for(h=s;h&&h.parent&&!l.has(h);)h.#x=void 0,h.#A=void 0,h=h.parent}},Rle=class a extends Jy{static{t(this,"PathWin32")}sep="\\";splitSep=Hnr;constructor(s,l=IT,_,h,b,w,N){super(s,l,_,h,b,w,N)}newChild(s,l=IT,_={}){return new a(s,l,this.root,this.roots,this.nocase,this.childrenCache(),_)}getRootString(s){return CNe.parse(s).root}getRoot(s){if(s=Wnr(s.toUpperCase()),s===this.root.name)return this.root;for(let[l,_]of Object.entries(this.roots))if(this.sameRoot(s,l))return this.roots[s]=_;return this.roots[s]=new tj(s,this).root}sameRoot(s,l=this.root.name){return s=s.toUpperCase().replace(/\//g,"\\").replace(fct,"$1\\"),s===l}},Mle=class a extends Jy{static{t(this,"PathPosix")}splitSep="/";sep="/";constructor(s,l=IT,_,h,b,w,N){super(s,l,_,h,b,w,N)}getRootString(s){return s.startsWith("/")?"/":""}getRoot(s){return this.root}newChild(s,l=IT,_={}){return new a(s,l,this.root,this.roots,this.nocase,this.childrenCache(),_)}},jle=class{static{t(this,"PathScurryBase")}root;rootPath;roots;cwd;#e;#n;#t;nocase;#r;constructor(s=process.cwd(),l,_,{nocase:h,childrenCacheSize:b=16*1024,fs:w=tG}={}){this.#r=uct(w),(s instanceof URL||s.startsWith("file://"))&&(s=Fnr(s));let N=l.resolve(s);this.roots=Object.create(null),this.rootPath=this.parseRootPath(N),this.#e=new Lle,this.#n=new Lle,this.#t=new wNe(b);let B=N.substring(this.rootPath.length).split(_);if(B.length===1&&!B[0]&&B.pop(),h===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=h,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let q=this.root,le=B.length-1,se=l.sep,te=this.rootPath,Ue=!1;for(let Ie of B){let De=le--;q=q.child(Ie,{relative:new Array(De).fill("..").join(se),relativePosix:new Array(De).fill("..").join("/"),fullpath:te+=(Ue?"":se)+Ie}),Ue=!0}this.cwd=q}depth(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.depth()}childrenCache(){return this.#t}resolve(...s){let l="";for(let b=s.length-1;b>=0;b--){let w=s[b];if(!(!w||w===".")&&(l=l?`${w}/${l}`:w,this.isAbsolute(w)))break}let _=this.#e.get(l);if(_!==void 0)return _;let h=this.cwd.resolve(l).fullpath();return this.#e.set(l,h),h}resolvePosix(...s){let l="";for(let b=s.length-1;b>=0;b--){let w=s[b];if(!(!w||w===".")&&(l=l?`${w}/${l}`:w,this.isAbsolute(w)))break}let _=this.#n.get(l);if(_!==void 0)return _;let h=this.cwd.resolve(l).fullpathPosix();return this.#n.set(l,h),h}relative(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relative()}relativePosix(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.relativePosix()}basename(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.name}dirname(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),(s.parent||s).fullpath()}async readdir(s=this.cwd,l={withFileTypes:!0}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd);let{withFileTypes:_}=l;if(s.canReaddir()){let h=await s.readdir();return _?h:h.map(b=>b.name)}else return[]}readdirSync(s=this.cwd,l={withFileTypes:!0}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd);let{withFileTypes:_=!0}=l;return s.canReaddir()?_?s.readdirSync():s.readdirSync().map(h=>h.name):[]}async lstat(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstat()}lstatSync(s=this.cwd){return typeof s=="string"&&(s=this.cwd.resolve(s)),s.lstatSync()}async readlink(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s.withFileTypes,s=this.cwd);let _=await s.readlink();return l?_:_?.fullpath()}readlinkSync(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s.withFileTypes,s=this.cwd);let _=s.readlinkSync();return l?_:_?.fullpath()}async realpath(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s.withFileTypes,s=this.cwd);let _=await s.realpath();return l?_:_?.fullpath()}realpathSync(s=this.cwd,{withFileTypes:l}={withFileTypes:!1}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s.withFileTypes,s=this.cwd);let _=s.realpathSync();return l?_:_?.fullpath()}async walk(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:h=!1,filter:b,walkFilter:w}=l,N=[];(!b||b(s))&&N.push(_?s:s.fullpath());let B=new Set,q=t((se,te)=>{B.add(se),se.readdirCB((Ue,Ie)=>{if(Ue)return te(Ue);let De=Ie.length;if(!De)return te();let Tt=t(()=>{--De===0&&te()},"next");for(let mt of Ie)(!b||b(mt))&&N.push(_?mt:mt.fullpath()),h&&mt.isSymbolicLink()?mt.realpath().then(hr=>hr?.isUnknown()?hr.lstat():hr).then(hr=>hr?.shouldWalk(B,w)?q(hr,Tt):Tt()):mt.shouldWalk(B,w)?q(mt,Tt):Tt()},!0)},"walk"),le=s;return new Promise((se,te)=>{q(le,Ue=>{if(Ue)return te(Ue);se(N)})})}walkSync(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:h=!1,filter:b,walkFilter:w}=l,N=[];(!b||b(s))&&N.push(_?s:s.fullpath());let B=new Set([s]);for(let q of B){let le=q.readdirSync();for(let se of le){(!b||b(se))&&N.push(_?se:se.fullpath());let te=se;if(se.isSymbolicLink()){if(!(h&&(te=se.realpathSync())))continue;te.isUnknown()&&te.lstatSync()}te.shouldWalk(B,w)&&B.add(te)}}return N}[Symbol.asyncIterator](){return this.iterate()}iterate(s=this.cwd,l={}){return typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd),this.stream(s,l)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:h=!1,filter:b,walkFilter:w}=l;(!b||b(s))&&(yield _?s:s.fullpath());let N=new Set([s]);for(let B of N){let q=B.readdirSync();for(let le of q){(!b||b(le))&&(yield _?le:le.fullpath());let se=le;if(le.isSymbolicLink()){if(!(h&&(se=le.realpathSync())))continue;se.isUnknown()&&se.lstatSync()}se.shouldWalk(N,w)&&N.add(se)}}}stream(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:h=!1,filter:b,walkFilter:w}=l,N=new MI({objectMode:!0});(!b||b(s))&&N.write(_?s:s.fullpath());let B=new Set,q=[s],le=0,se=t(()=>{let te=!1;for(;!te;){let Ue=q.shift();if(!Ue){le===0&&N.end();return}le++,B.add(Ue);let Ie=t((Tt,mt,hr=!1)=>{if(Tt)return N.emit("error",Tt);if(h&&!hr){let rn=[];for(let jr of mt)jr.isSymbolicLink()&&rn.push(jr.realpath().then(Qr=>Qr?.isUnknown()?Qr.lstat():Qr));if(rn.length){Promise.all(rn).then(()=>Ie(null,mt,!0));return}}for(let rn of mt)rn&&(!b||b(rn))&&(N.write(_?rn:rn.fullpath())||(te=!0));le--;for(let rn of mt){let jr=rn.realpathCached()||rn;jr.shouldWalk(B,w)&&q.push(jr)}te&&!N.flowing?N.once("drain",se):De||se()},"onReaddir"),De=!0;Ue.readdirCB(Ie,!0),De=!1}},"process");return se(),N}streamSync(s=this.cwd,l={}){typeof s=="string"?s=this.cwd.resolve(s):s instanceof Jy||(l=s,s=this.cwd);let{withFileTypes:_=!0,follow:h=!1,filter:b,walkFilter:w}=l,N=new MI({objectMode:!0}),B=new Set;(!b||b(s))&&N.write(_?s:s.fullpath());let q=[s],le=0,se=t(()=>{let te=!1;for(;!te;){let Ue=q.shift();if(!Ue){le===0&&N.end();return}le++,B.add(Ue);let Ie=Ue.readdirSync();for(let De of Ie)(!b||b(De))&&(N.write(_?De:De.fullpath())||(te=!0));le--;for(let De of Ie){let Tt=De;if(De.isSymbolicLink()){if(!(h&&(Tt=De.realpathSync())))continue;Tt.isUnknown()&&Tt.lstatSync()}Tt.shouldWalk(B,w)&&q.push(Tt)}}te&&!N.flowing&&N.once("drain",se)},"process");return se(),N}chdir(s=this.cwd){let l=this.cwd;this.cwd=typeof s=="string"?this.cwd.resolve(s):s,this.cwd[gct](l)}},tj=class extends jle{static{t(this,"PathScurryWin32")}sep="\\";constructor(s=process.cwd(),l={}){let{nocase:_=!0}=l;super(s,CNe,"\\",{...l,nocase:_}),this.nocase=_;for(let h=this.cwd;h;h=h.parent)h.nocase=this.nocase}parseRootPath(s){return CNe.parse(s).root.toUpperCase()}newRoot(s){return new Rle(this.rootPath,pk,void 0,this.roots,this.nocase,this.childrenCache(),{fs:s})}isAbsolute(s){return s.startsWith("/")||s.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(s)}},rj=class extends jle{static{t(this,"PathScurryPosix")}sep="/";constructor(s=process.cwd(),l={}){let{nocase:_=!1}=l;super(s,Onr,"/",{...l,nocase:_}),this.nocase=_}parseRootPath(s){return"/"}newRoot(s){return new Mle(this.rootPath,pk,void 0,this.roots,this.nocase,this.childrenCache(),{fs:s})}isAbsolute(s){return s.startsWith("/")}},iG=class extends rj{static{t(this,"PathScurryDarwin")}constructor(s=process.cwd(),l={}){let{nocase:_=!0}=l;super(s,{...l,nocase:_})}},eFr=process.platform==="win32"?Rle:Mle,yct=process.platform==="win32"?tj:process.platform==="darwin"?iG:rj;var Knr=t(a=>a.length>=1,"isPatternList"),Ynr=t(a=>a.length>=1,"isGlobList"),nj=class a{static{t(this,"Pattern")}#e;#n;#t;length;#r;#s;#p;#o;#_;#u;#c=!0;constructor(s,l,_,h){if(!Knr(s))throw new TypeError("empty pattern list");if(!Ynr(l))throw new TypeError("empty glob list");if(l.length!==s.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=s.length,_<0||_>=this.length)throw new TypeError("index out of range");if(this.#e=s,this.#n=l,this.#t=_,this.#r=h,this.#t===0){if(this.isUNC()){let[b,w,N,B,...q]=this.#e,[le,se,te,Ue,...Ie]=this.#n;q[0]===""&&(q.shift(),Ie.shift());let De=[b,w,N,B,""].join("/"),Tt=[le,se,te,Ue,""].join("/");this.#e=[De,...q],this.#n=[Tt,...Ie],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[b,...w]=this.#e,[N,...B]=this.#n;w[0]===""&&(w.shift(),B.shift());let q=b+"/",le=N+"/";this.#e=[q,...w],this.#n=[le,...B],this.length=this.#e.length}}}pattern(){return this.#e[this.#t]}isString(){return typeof this.#e[this.#t]=="string"}isGlobstar(){return this.#e[this.#t]===M0}isRegExp(){return this.#e[this.#t]instanceof RegExp}globString(){return this.#p=this.#p||(this.#t===0?this.isAbsolute()?this.#n[0]+this.#n.slice(1).join("/"):this.#n.join("/"):this.#n.slice(this.#t).join("/"))}hasMore(){return this.length>this.#t+1}rest(){return this.#s!==void 0?this.#s:this.hasMore()?(this.#s=new a(this.#e,this.#n,this.#t+1,this.#r),this.#s.#u=this.#u,this.#s.#_=this.#_,this.#s.#o=this.#o,this.#s):this.#s=null}isUNC(){let s=this.#e;return this.#_!==void 0?this.#_:this.#_=this.#r==="win32"&&this.#t===0&&s[0]===""&&s[1]===""&&typeof s[2]=="string"&&!!s[2]&&typeof s[3]=="string"&&!!s[3]}isDrive(){let s=this.#e;return this.#o!==void 0?this.#o:this.#o=this.#r==="win32"&&this.#t===0&&this.length>1&&typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0])}isAbsolute(){let s=this.#e;return this.#u!==void 0?this.#u:this.#u=s[0]===""&&s.length>1||this.isDrive()||this.isUNC()}root(){let s=this.#e[0];return typeof s=="string"&&this.isAbsolute()&&this.#t===0?s:""}checkFollowGlobstar(){return!(this.#t===0||!this.isGlobstar()||!this.#c)}markFollowGlobstar(){return this.#t===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var Xnr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ij=class{static{t(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(s,{nobrace:l,nocase:_,noext:h,noglobstar:b,platform:w=Xnr}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=w,this.mmopts={dot:!0,nobrace:l,nocase:_,noext:h,noglobstar:b,optimizationLevel:2,platform:w,nocomment:!0,nonegate:!0};for(let N of s)this.add(N)}add(s){let l=new XS(s,this.mmopts);for(let _=0;_<l.set.length;_++){let h=l.set[_],b=l.globParts[_];if(!h||!b)throw new Error("invalid pattern object");for(;h[0]==="."&&b[0]===".";)h.shift(),b.shift();let w=new nj(h,b,0,this.platform),N=new XS(w.globString(),this.mmopts),B=b[b.length-1]==="**",q=w.isAbsolute();q?this.absolute.push(N):this.relative.push(N),B&&(q?this.absoluteChildren.push(N):this.relativeChildren.push(N))}}ignored(s){let l=s.fullpath(),_=`${l}/`,h=s.relative()||".",b=`${h}/`;for(let w of this.relative)if(w.match(h)||w.match(b))return!0;for(let w of this.absolute)if(w.match(l)||w.match(_))return!0;return!1}childrenIgnored(s){let l=s.fullpath()+"/",_=(s.relative()||".")+"/";for(let h of this.relativeChildren)if(h.match(_))return!0;for(let h of this.absoluteChildren)if(h.match(l))return!0;return!1}};var kNe=class a{static{t(this,"HasWalkedCache")}store;constructor(s=new Map){this.store=s}copy(){return new a(new Map(this.store))}hasWalked(s,l){return this.store.get(s.fullpath())?.has(l.globString())}storeWalked(s,l){let _=s.fullpath(),h=this.store.get(_);h?h.add(l.globString()):this.store.set(_,new Set([l.globString()]))}},DNe=class{static{t(this,"MatchRecord")}store=new Map;add(s,l,_){let h=(l?2:0)|(_?1:0),b=this.store.get(s);this.store.set(s,b===void 0?h:h&b)}entries(){return[...this.store.entries()].map(([s,l])=>[s,!!(l&2),!!(l&1)])}},PNe=class{static{t(this,"SubWalks")}store=new Map;add(s,l){if(!s.canReaddir())return;let _=this.store.get(s);_?_.find(h=>h.globString()===l.globString())||_.push(l):this.store.set(s,[l])}get(s){let l=this.store.get(s);if(!l)throw new Error("attempting to walk unknown path");return l}entries(){return this.keys().map(s=>[s,this.store.get(s)])}keys(){return[...this.store.keys()].filter(s=>s.canReaddir())}},sG=class a{static{t(this,"Processor")}hasWalkedCache;matches=new DNe;subwalks=new PNe;patterns;follow;dot;opts;constructor(s,l){this.opts=s,this.follow=!!s.follow,this.dot=!!s.dot,this.hasWalkedCache=l?l.copy():new kNe}processPatterns(s,l){this.patterns=l;let _=l.map(h=>[s,h]);for(let[h,b]of _){this.hasWalkedCache.storeWalked(h,b);let w=b.root(),N=b.isAbsolute()&&this.opts.absolute!==!1;if(w){h=h.resolve(w==="/"&&this.opts.root!==void 0?this.opts.root:w);let se=b.rest();if(se)b=se;else{this.matches.add(h,!0,!1);continue}}if(h.isENOENT())continue;let B,q,le=!1;for(;typeof(B=b.pattern())=="string"&&(q=b.rest());)h=h.resolve(B),b=q,le=!0;if(B=b.pattern(),q=b.rest(),le){if(this.hasWalkedCache.hasWalked(h,b))continue;this.hasWalkedCache.storeWalked(h,b)}if(typeof B=="string"){let se=B===".."||B===""||B===".";this.matches.add(h.resolve(B),N,se);continue}else if(B===M0){(!h.isSymbolicLink()||this.follow||b.checkFollowGlobstar())&&this.subwalks.add(h,b);let se=q?.pattern(),te=q?.rest();if(!q||(se===""||se===".")&&!te)this.matches.add(h,N,se===""||se===".");else if(se===".."){let Ue=h.parent||h;te?this.hasWalkedCache.hasWalked(Ue,te)||this.subwalks.add(Ue,te):this.matches.add(Ue,N,!0)}}else B instanceof RegExp&&this.subwalks.add(h,b)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new a(this.opts,this.hasWalkedCache)}filterEntries(s,l){let _=this.subwalks.get(s),h=this.child();for(let b of l)for(let w of _){let N=w.isAbsolute(),B=w.pattern(),q=w.rest();B===M0?h.testGlobstar(b,w,q,N):B instanceof RegExp?h.testRegExp(b,B,q,N):h.testString(b,B,q,N)}return h}testGlobstar(s,l,_,h){if((this.dot||!s.name.startsWith("."))&&(l.hasMore()||this.matches.add(s,h,!1),s.canReaddir()&&(this.follow||!s.isSymbolicLink()?this.subwalks.add(s,l):s.isSymbolicLink()&&(_&&l.checkFollowGlobstar()?this.subwalks.add(s,_):l.markFollowGlobstar()&&this.subwalks.add(s,l)))),_){let b=_.pattern();if(typeof b=="string"&&b!==".."&&b!==""&&b!==".")this.testString(s,b,_.rest(),h);else if(b===".."){let w=s.parent||s;this.subwalks.add(w,_)}else b instanceof RegExp&&this.testRegExp(s,b,_.rest(),h)}}testRegExp(s,l,_,h){l.test(s.name)&&(_?this.subwalks.add(s,_):this.matches.add(s,h,!1))}testString(s,l,_,h){s.isNamed(l)&&(_?this.subwalks.add(s,_):this.matches.add(s,h,!1))}};var Znr=t((a,s)=>typeof a=="string"?new ij([a],s):Array.isArray(a)?new ij(a,s):a,"makeIgnore"),Ble=class{static{t(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#n;#t;signal;maxDepth;includeChildMatches;constructor(s,l,_){if(this.patterns=s,this.path=l,this.opts=_,this.#t=!_.posix&&_.platform==="win32"?"\\":"/",this.includeChildMatches=_.includeChildMatches!==!1,(_.ignore||!this.includeChildMatches)&&(this.#n=Znr(_.ignore??[],_),!this.includeChildMatches&&typeof this.#n.add!="function")){let h="cannot ignore child matches, ignore lacks add() method.";throw new Error(h)}this.maxDepth=_.maxDepth||1/0,_.signal&&(this.signal=_.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#r(s){return this.seen.has(s)||!!this.#n?.ignored?.(s)}#s(s){return!!this.#n?.childrenIgnored?.(s)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let s;for(;!this.paused&&(s=this.#e.shift());)s()}onResume(s){this.signal?.aborted||(this.paused?this.#e.push(s):s())}async matchCheck(s,l){if(l&&this.opts.nodir)return;let _;if(this.opts.realpath){if(_=s.realpathCached()||await s.realpath(),!_)return;s=_}let b=s.isUnknown()||this.opts.stat?await s.lstat():s;if(this.opts.follow&&this.opts.nodir&&b?.isSymbolicLink()){let w=await b.realpath();w&&(w.isUnknown()||this.opts.stat)&&await w.lstat()}return this.matchCheckTest(b,l)}matchCheckTest(s,l){return s&&(this.maxDepth===1/0||s.depth()<=this.maxDepth)&&(!l||s.canReaddir())&&(!this.opts.nodir||!s.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!s.isSymbolicLink()||!s.realpathCached()?.isDirectory())&&!this.#r(s)?s:void 0}matchCheckSync(s,l){if(l&&this.opts.nodir)return;let _;if(this.opts.realpath){if(_=s.realpathCached()||s.realpathSync(),!_)return;s=_}let b=s.isUnknown()||this.opts.stat?s.lstatSync():s;if(this.opts.follow&&this.opts.nodir&&b?.isSymbolicLink()){let w=b.realpathSync();w&&(w?.isUnknown()||this.opts.stat)&&w.lstatSync()}return this.matchCheckTest(b,l)}matchFinish(s,l){if(this.#r(s))return;if(!this.includeChildMatches&&this.#n?.add){let b=`${s.relativePosix()}/**`;this.#n.add(b)}let _=this.opts.absolute===void 0?l:this.opts.absolute;this.seen.add(s);let h=this.opts.mark&&s.isDirectory()?this.#t:"";if(this.opts.withFileTypes)this.matchEmit(s);else if(_){let b=this.opts.posix?s.fullpathPosix():s.fullpath();this.matchEmit(b+h)}else{let b=this.opts.posix?s.relativePosix():s.relative(),w=this.opts.dotRelative&&!b.startsWith(".."+this.#t)?"."+this.#t:"";this.matchEmit(b?w+b+h:"."+h)}}async match(s,l,_){let h=await this.matchCheck(s,_);h&&this.matchFinish(h,l)}matchSync(s,l,_){let h=this.matchCheckSync(s,_);h&&this.matchFinish(h,l)}walkCB(s,l,_){this.signal?.aborted&&_(),this.walkCB2(s,l,new sG(this.opts),_)}walkCB2(s,l,_,h){if(this.#s(s))return h();if(this.signal?.aborted&&h(),this.paused){this.onResume(()=>this.walkCB2(s,l,_,h));return}_.processPatterns(s,l);let b=1,w=t(()=>{--b===0&&h()},"next");for(let[N,B,q]of _.matches.entries())this.#r(N)||(b++,this.match(N,B,q).then(()=>w()));for(let N of _.subwalkTargets()){if(this.maxDepth!==1/0&&N.depth()>=this.maxDepth)continue;b++;let B=N.readdirCached();N.calledReaddir()?this.walkCB3(N,B,_,w):N.readdirCB((q,le)=>this.walkCB3(N,le,_,w),!0)}w()}walkCB3(s,l,_,h){_=_.filterEntries(s,l);let b=1,w=t(()=>{--b===0&&h()},"next");for(let[N,B,q]of _.matches.entries())this.#r(N)||(b++,this.match(N,B,q).then(()=>w()));for(let[N,B]of _.subwalks.entries())b++,this.walkCB2(N,B,_.child(),w);w()}walkCBSync(s,l,_){this.signal?.aborted&&_(),this.walkCB2Sync(s,l,new sG(this.opts),_)}walkCB2Sync(s,l,_,h){if(this.#s(s))return h();if(this.signal?.aborted&&h(),this.paused){this.onResume(()=>this.walkCB2Sync(s,l,_,h));return}_.processPatterns(s,l);let b=1,w=t(()=>{--b===0&&h()},"next");for(let[N,B,q]of _.matches.entries())this.#r(N)||this.matchSync(N,B,q);for(let N of _.subwalkTargets()){if(this.maxDepth!==1/0&&N.depth()>=this.maxDepth)continue;b++;let B=N.readdirSync();this.walkCB3Sync(N,B,_,w)}w()}walkCB3Sync(s,l,_,h){_=_.filterEntries(s,l);let b=1,w=t(()=>{--b===0&&h()},"next");for(let[N,B,q]of _.matches.entries())this.#r(N)||this.matchSync(N,B,q);for(let[N,B]of _.subwalks.entries())b++,this.walkCB2Sync(N,B,_.child(),w);w()}},aG=class extends Ble{static{t(this,"GlobWalker")}matches=new Set;constructor(s,l,_){super(s,l,_)}matchEmit(s){this.matches.add(s)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((s,l)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?l(this.signal.reason):s(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},oG=class extends Ble{static{t(this,"GlobStream")}results;constructor(s,l,_){super(s,l,_),this.results=new MI({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(s){this.results.write(s),this.results.flowing||this.pause()}stream(){let s=this.path;return s.isUnknown()?s.lstat().then(()=>{this.walkCB(s,this.patterns,()=>this.results.end())}):this.walkCB(s,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var eir=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",XE=class{static{t(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(s,l){if(!l)throw new TypeError("glob options required");if(this.withFileTypes=!!l.withFileTypes,this.signal=l.signal,this.follow=!!l.follow,this.dot=!!l.dot,this.dotRelative=!!l.dotRelative,this.nodir=!!l.nodir,this.mark=!!l.mark,l.cwd?(l.cwd instanceof URL||l.cwd.startsWith("file://"))&&(l.cwd=Qnr(l.cwd)):this.cwd="",this.cwd=l.cwd||"",this.root=l.root,this.magicalBraces=!!l.magicalBraces,this.nobrace=!!l.nobrace,this.noext=!!l.noext,this.realpath=!!l.realpath,this.absolute=l.absolute,this.includeChildMatches=l.includeChildMatches!==!1,this.noglobstar=!!l.noglobstar,this.matchBase=!!l.matchBase,this.maxDepth=typeof l.maxDepth=="number"?l.maxDepth:1/0,this.stat=!!l.stat,this.ignore=l.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof s=="string"&&(s=[s]),this.windowsPathsNoEscape=!!l.windowsPathsNoEscape||l.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(s=s.map(B=>B.replace(/\\/g,"/"))),this.matchBase){if(l.noglobstar)throw new TypeError("base matching requires globstar");s=s.map(B=>B.includes("/")?B:`./**/${B}`)}if(this.pattern=s,this.platform=l.platform||eir,this.opts={...l,platform:this.platform},l.scurry){if(this.scurry=l.scurry,l.nocase!==void 0&&l.nocase!==l.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let B=l.platform==="win32"?tj:l.platform==="darwin"?iG:l.platform?rj:yct;this.scurry=new B(this.cwd,{nocase:l.nocase,fs:l.fs})}this.nocase=this.scurry.nocase;let _=this.platform==="darwin"||this.platform==="win32",h={...l,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:_,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},b=this.pattern.map(B=>new XS(B,h)),[w,N]=b.reduce((B,q)=>(B[0].push(...q.set),B[1].push(...q.globParts),B),[[],[]]);this.patterns=w.map((B,q)=>{let le=N[q];if(!le)throw new Error("invalid pattern object");return new nj(B,le,0,this.platform)})}async walk(){return[...await new aG(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new aG(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new oG(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new oG(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var ANe=t((a,s={})=>{Array.isArray(a)||(a=[a]);for(let l of a)if(new XS(l,s).hasMagic())return!0;return!1},"hasMagic");function $le(a,s={}){return new XE(a,s).streamSync()}t($le,"globStreamSync");function bct(a,s={}){return new XE(a,s).stream()}t(bct,"globStream");function Sct(a,s={}){return new XE(a,s).walkSync()}t(Sct,"globSync");async function vct(a,s={}){return new XE(a,s).walk()}t(vct,"glob_");function Ule(a,s={}){return new XE(a,s).iterateSync()}t(Ule,"globIterateSync");function Tct(a,s={}){return new XE(a,s).iterate()}t(Tct,"globIterate");var tir=$le,rir=Object.assign(bct,{sync:$le}),nir=Ule,iir=Object.assign(Tct,{sync:Ule}),sir=Object.assign(Sct,{stream:$le,iterate:Ule}),cG=Object.assign(vct,{glob:vct,globSync:Sct,sync:sir,globStream:bct,stream:rir,globStreamSync:$le,streamSync:tir,globIterate:Tct,iterate:iir,globIterateSync:Ule,iterateSync:nir,Glob:XE,hasMagic:ANe,escape:YM,unescape:GE});cG.glob=cG;var Z1=class extends Error{static{t(this,"CompilationError")}buildMessages;constructor(s){super("An error occurred during compilation."),this.buildMessages=Array.isArray(s)?s:[s]}toBuildResult(){return{content:"",errors:this.buildMessages}}};var air="[",oir="]",cir="{",lir="}",uir=":",fir=",",_ir="true",pir="false",dir="null",mir="NaN",hir="Infinity",INe='"',lG=new Map([[34,INe],[92,"\\"],[47,"/"],[98,"\b"],[110,`
|
|
575
575
|
`],[102,"\f"],[114,"\r"],[116," "]]),qle=new Map([...lG,[118,"\v"],[48,"\0"]]),gir=new Map([[INe,INe],["\\","\\"],["/","/"],["\b","b"],[`
|
|
576
576
|
`,"n"],["\f","f"],["\r","r"],[" ","t"]]),BFr=new Map([...gir,["\v","v"],["\0","0"],["\u2028","u2028"],["\u2029","u2029"]]),Jle=new Map([[air,"LBracket"],[oir,"RBracket"],[cir,"LBrace"],[lir,"RBrace"],[uir,"Colon"],[fir,"Comma"],[_ir,"Boolean"],[pir,"Boolean"],[dir,"Null"]]),zle=new Map([...Jle,[mir,"Number"],[hir,"Number"]]),ONe=new Set([10,13,8232,8233]),CA=class extends Error{static{t(this,"ErrorWithLocation")}constructor(s,{line:l,column:_,offset:h}){super(`${s} (${l}:${_})`),this.line=l,this.column=_,this.offset=h}},FNe=class extends CA{static{t(this,"UnexpectedChar")}constructor(s,l){super(`Unexpected character '${String.fromCharCode(s)}' found.`,l)}},LNe=class extends CA{static{t(this,"UnexpectedIdentifier")}constructor(s,l){super(`Unexpected identifier '${s}' found.`,l)}},f7=class extends CA{static{t(this,"UnexpectedToken")}constructor(s){super(`Unexpected token ${s.type} found.`,s.loc.start)}},Vle=class extends CA{static{t(this,"UnexpectedEOF")}constructor(s){super("Unexpected end of input found.",s)}},yir=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,vir=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,bir=13,xct=10,RNe=class{static{t(this,"CharCodeReader")}#e="";#n=1;#t=0;#r=-1;#s=!1;#p=-1;#o=!1;constructor(s){this.#e=s}#_(){this.#o||(this.#t++,this.#r++,this.#p=-1,this.#o=!0)}locate(){return{line:this.#n,column:this.#t,offset:this.#r}}next(){if(this.#r>=this.#e.length-1)return this.#_(),-1;this.#r++;let s=this.#e.charCodeAt(this.#r);return this.#s?(this.#n++,this.#t=1,this.#s=!1):this.#t++,s===bir?(this.#s=!0,this.peek()===xct&&this.#r++):s===xct&&(this.#s=!0),this.#p=s,s}peek(){return this.#r===this.#e.length-1?-1:this.#e.charCodeAt(this.#r+1)}match(s){return s(this.peek())?(this.next(),!0):!1}current(){return this.#p}},Sir="Infinity",Tir="NaN",xir=new Set([116,102,110]),MNe=new Set([32,9,10,13]),Ect=new Set([...MNe,11,12,160,8232,8233,65279,160,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288]),Eir={mode:"json",ranges:!1},Cir=new Set(["true","false","null"]),P_={EOF:0,Number:1,String:2,Boolean:3,Null:4,NaN:5,Infinity:6,Identifier:7,Colon:20,LBrace:21,RBrace:22,LBracket:23,RBracket:24,Comma:25,LineComment:40,BlockComment:41};function EA(a){return a>=48&&a<=57}t(EA,"isDigit");function NNe(a){return EA(a)||a>=65&&a<=70||a>=97&&a<=102}t(NNe,"isHexDigit");function wir(a){return a>=49&&a<=57}t(wir,"isPositiveDigit");function kir(a){return xir.has(a)}t(kir,"isKeywordStart");function wct(a){return EA(a)||a===46||a===45}t(wct,"isNumberStart");function Dir(a){return wct(a)||a===43}t(Dir,"isJSON5NumberStart");function Cct(a,s){return a===34||s&&a===39}t(Cct,"isStringStart");function kct(a){if(a===36||a===95||a===92||a>=97&&a<=122||a>=65&&a<=90||a===8204||a===8205)return!0;let s=String.fromCharCode(a);return yir.test(s)}t(kct,"isJSON5IdentifierStart");function Pir(a){if(kct(a)||EA(a))return!0;let s=String.fromCharCode(a);return vir.test(s)}t(Pir,"isJSON5IdentifierPart");var jNe=class{static{t(this,"Tokenizer")}#e;#n;#t;#r;#s;#p;#o;#_;#u;#c;#i;constructor(s,l){this.#n=s,this.#e={...Eir,...l},this.#t=new RNe(s),this.#r=this.#e.mode==="json5",this.#s=this.#e.mode!=="json",this.#p=this.#e.ranges,this.#_=this.#r?qle.has.bind(qle):lG.has.bind(lG),this.#u=this.#r?ONe.has.bind(ONe):()=>!1,this.#c=this.#r?_=>_===120:()=>!1,this.#i=this.#r?Ect.has.bind(Ect):MNe.has.bind(MNe)}#a(s,l=this.#t.locate()){throw new FNe(s,l)}#h(s,l=this.#t.locate()){throw new LNe(s,l)}#m(){throw new Vle(this.#t.locate())}#f(s,l,_,h){let b=_.offset+l,w=this.#e.ranges?{range:[_.offset,b]}:void 0;return{type:s,loc:{start:_,end:h||{line:_.line,column:_.column+l,offset:b}},...w}}#d(s){let l="",_;for(let h=0;h<s;h++){if(_=this.#t.peek(),NNe(_)){this.#t.next(),l+=String.fromCharCode(_);continue}this.#a(_)}return l}#g(s){let l="";do{if(l+=String.fromCharCode(s),s===92&&(s=this.#t.next(),s!==117&&this.#a(s),l+=String.fromCharCode(s),l+=this.#d(4)),s=this.#t.peek(),!Pir(s))break;this.#t.next()}while(!0);return l}#y(s){let l=s,_=1;for(s=this.#t.peek();s!==-1&&s!==l;){if(this.#t.next(),_++,s===92)if(s=this.#t.peek(),this.#_(s)||this.#u(s))this.#t.next(),_++;else if(s===117){this.#t.next(),_++;let h=this.#d(4);_+=h.length}else if(this.#c(s)){this.#t.next(),_++;let h=this.#d(2);_+=h.length}else this.#r?(this.#t.next(),_++):this.#a(s);s=this.#t.peek()}return s===-1&&(this.#t.next(),this.#m()),this.#t.next(),_++,_}#E(s){let l=1;if(s===45||this.#r&&s===43){if(s=this.#t.peek(),this.#r&&(s===73||s===78)){this.#t.next();let _=this.#g(s);return _!==Sir&&_!==Tir&&this.#a(s),l+_.length}EA(s)||this.#a(s),this.#t.next(),l++}if(s===48)if(s=this.#t.peek(),this.#r&&(s===120||s===88)){this.#t.next(),l++,s=this.#t.peek(),NNe(s)||(this.#t.next(),this.#a(s));do this.#t.next(),l++,s=this.#t.peek();while(NNe(s))}else EA(s)&&this.#a(s);else if(!this.#r||s!==46)for(wir(s)||this.#a(s),s=this.#t.peek();EA(s);)this.#t.next(),l++,s=this.#t.peek();if(s===46){let _=-1;for(this.#t.next(),l++,_++,s=this.#t.peek();EA(s);)this.#t.next(),l++,_++,s=this.#t.peek();!this.#r&&_===0&&(this.#t.next(),s?this.#a(s):this.#m())}if(s===101||s===69)for(this.#t.next(),l++,s=this.#t.peek(),(s===43||s===45)&&(this.#t.next(),l++,s=this.#t.peek()),s===-1&&(this.#t.next(),this.#m()),EA(s)||(this.#t.next(),this.#a(s));EA(s);)this.#t.next(),l++,s=this.#t.peek();return l}#T(s){let l=1;if(s=this.#t.peek(),s===47){do this.#t.next(),l+=1,s=this.#t.peek();while(s>-1&&s!==13&&s!==10);return{length:l,multiline:!1}}if(s===42){for(this.#t.next(),l+=1;s>-1;)if(s=this.#t.peek(),s===42){if(this.#t.next(),l+=1,s=this.#t.peek(),s===47)return this.#t.next(),l+=1,{length:l,multiline:!0}}else this.#t.next(),l+=1;this.#t.next(),this.#m()}this.#t.next(),this.#a(s)}next(){let s=this.#t.next();for(;this.#i(s);)s=this.#t.next();if(s===-1)return P_.EOF;let l=this.#t.locate(),_=String.fromCharCode(s);if(this.#r)if(zle.has(_))this.#o=this.#f(zle.get(_),1,l);else if(kct(s)){let h=this.#g(s);zle.has(h)?this.#o=this.#f(zle.get(h),h.length,l):this.#o=this.#f("Identifier",h.length,l)}else if(Dir(s)){let h=this.#E(s);this.#o=this.#f("Number",h,l)}else if(Cct(s,this.#r)){let h=this.#y(s),b=this.#t.locate();this.#o=this.#f("String",h,l,{line:b.line,column:b.column+1,offset:b.offset+1})}else if(s===47&&this.#s){let h=this.#T(s),b=this.#t.locate();this.#o=this.#f(h.multiline?"BlockComment":"LineComment",h.length,l,{line:b.line,column:b.column+1,offset:b.offset+1})}else this.#a(s);else if(Jle.has(_))this.#o=this.#f(Jle.get(_),1,l);else if(kir(s)){let h=this.#g(s);Cir.has(h)||this.#h(h,l),this.#o=this.#f(Jle.get(h),h.length,l)}else if(wct(s)){let h=this.#E(s);this.#o=this.#f("Number",h,l)}else if(Cct(s,this.#r)){let h=this.#y(s);this.#o=this.#f("String",h,l)}else if(s===47&&this.#s){let h=this.#T(s),b=this.#t.locate();this.#o=this.#f(h.multiline?"BlockComment":"LineComment",h.length,l,{line:b.line,column:b.column+1,offset:b.offset+1})}else this.#a(s);return P_[this.#o.type]}get token(){return this.#o}};var OT={document(a,s={}){return{type:"Document",body:a,loc:s.loc,...s}},string(a,s={}){return{type:"String",value:a,loc:s.loc,...s}},number(a,s={}){return{type:"Number",value:a,loc:s.loc,...s}},boolean(a,s={}){return{type:"Boolean",value:a,loc:s.loc,...s}},null(a={}){return{type:"Null",loc:a.loc,...a}},array(a,s={}){return{type:"Array",elements:a,loc:s.loc,...s}},element(a,s={}){return{type:"Element",value:a,loc:s.loc,...s}},object(a,s={}){return{type:"Object",members:a,loc:s.loc,...s}},member(a,s,l={}){return{type:"Member",name:a,value:s,loc:l.loc,...l}},identifier(a,s={}){return{type:"Identifier",name:a,loc:s.loc,...s}},nan(a="",s={}){return{type:"NaN",sign:a,loc:s.loc,...s}},infinity(a="",s={}){return{type:"Infinity",sign:a,loc:s.loc,...s}}},Air={mode:"json",ranges:!1,tokens:!1,allowTrailingCommas:!1};function Nir(a,s,l=!1){let _="",h=a.indexOf("\\"),b=0;for(;h>=0;){_+=a.slice(b,h);let w=a.charAt(h+1),N=w.charCodeAt(0);if(l&&qle.has(N))_+=qle.get(N),b=h+2;else if(lG.has(N))_+=lG.get(N),b=h+2;else if(w==="u"){let B=a.slice(h+2,h+6);if(B.length<4||/[^0-9a-f]/i.test(B))throw new CA(`Invalid unicode escape \\u${B}.`,{line:s.loc.start.line,column:s.loc.start.column+h,offset:s.loc.start.offset+h});_+=String.fromCharCode(parseInt(B,16)),b=h+6}else if(l&&w==="x"){let B=a.slice(h+2,h+4);if(B.length<2||/[^0-9a-f]/i.test(B))throw new CA(`Invalid hex escape \\x${B}.`,{line:s.loc.start.line,column:s.loc.start.column+h,offset:s.loc.start.offset+h});_+=String.fromCharCode(parseInt(B,16)),b=h+4}else if(l&&ONe.has(N))b=h+2,w==="\r"&&a.charAt(b)===`
|
|
577
|
-
`&&b++;else if(l)_+=w,b=h+2;else throw new CA(`Invalid escape \\${w}.`,{line:s.loc.start.line,column:s.loc.start.column+h,offset:s.loc.start.offset+h});h=a.indexOf("\\",b)}return _+=a.slice(b),_}t(Nir,"getStringValue");function Iir(a,s,l=!1){switch(s.type){case"Boolean":return a==="true";case"Number":return Number(a);case"String":return Nir(a.slice(1,-1),s,l);default:throw new TypeError(`Unknown token type "${s.type}.`)}}t(Iir,"getLiteralValue");function Dct(a,s){s=Object.freeze({...Air,...s});let l=[],_=new jNe(a,{mode:s.mode,ranges:s.ranges}),h=s.mode==="json5",b=s.allowTrailingCommas||h;function w(){let br=_.next();return br&&s.tokens&&l.push(_.token),br}t(w,"nextNoComments");function N(){let br=_.next();return br&&s.tokens&&l.push(_.token),br>=P_.LineComment?N():br}t(N,"nextSkipComments");let B=s.mode==="json"?w:N;function q(br,yr){if(br!==yr)throw new f7(_.token)}t(q,"assertTokenType");function le(br,yr){if(!yr.includes(br))throw new f7(_.token)}t(le,"assertTokenTypes");function se(br,yr){return s.ranges?{range:[br.offset,yr.offset]}:void 0}t(se,"createRange");function te(br){let yr=_.token,Zi=se(yr.loc.start,yr.loc.end),Ci=Iir(a.slice(yr.loc.start.offset,yr.loc.end.offset),yr,h),di={loc:{start:{...yr.loc.start},end:{...yr.loc.end}},...Zi};switch(br){case P_.String:return OT.string(Ci,di);case P_.Number:return OT.number(Ci,di);case P_.Boolean:return OT.boolean(Ci,di);default:throw new TypeError(`Unknown token type ${yr.type}.`)}}t(te,"createLiteralNode");function Ue(br){let yr=se(br.loc.start,br.loc.end),Zi=a.slice(br.loc.start.offset,br.loc.end.offset),Po={loc:{start:{...br.loc.start},end:{...br.loc.end}},...yr};if(br.type!=="Identifier"){let di="";return(Zi[0]==="+"||Zi[0]==="-")&&(di=Zi[0]),OT[Zi.includes("NaN")?"nan":"infinity"](di,Po)}return OT.identifier(Zi,Po)}t(Ue,"createJSON5IdentifierNode");function Ie(br){let yr=se(br.loc.start,br.loc.end);return OT.null({loc:{start:{...br.loc.start},end:{...br.loc.end}},...yr})}t(Ie,"createNullNode");function De(br){h?le(br,[P_.String,P_.Identifier,P_.Number]):q(br,P_.String);let yr=_.token,Zi=br===P_.String?te(br):Ue(yr);if(h&&(Zi.type==="NaN"||Zi.type==="Infinity")){if(Zi.sign!=="")throw new f7(_.token);Zi=OT.identifier(Zi.type,{loc:Zi.loc,...se(Zi.loc.start,Zi.loc.end)})}br=B(),q(br,P_.Colon);let Ci=hr(),Po=se(Zi.loc.start,Ci.loc.end);return OT.member(Zi,Ci,{loc:{start:{...Zi.loc.start},end:{...Ci.loc.end}},...Po})}t(De,"parseProperty");function Tt(br){q(br,P_.LBrace);let yr=_.token,Zi=[],Ci=B();if(Ci!==P_.RBrace)do{if(Zi.push(De(Ci)),Ci=B(),!Ci)throw new Vle(Zi[Zi.length-1].loc.end);if(Ci===P_.Comma){if(Ci=B(),b&&Ci===P_.RBrace)break}else break}while(Ci);q(Ci,P_.RBrace);let Po=_.token,di=se(yr.loc.start,Po.loc.end);return OT.object(Zi,{loc:{start:{...yr.loc.start},end:{...Po.loc.end}},...di})}t(Tt,"parseObject");function mt(br){q(br,P_.LBracket);let yr=_.token,Zi=[],Ci=B();if(Ci!==P_.RBracket)do{let vf=hr(Ci);if(Zi.push(OT.element(vf,{loc:vf.loc})),Ci=B(),Ci===P_.Comma){if(Ci=B(),b&&Ci===P_.RBracket)break}else break}while(Ci);q(Ci,P_.RBracket);let Po=_.token,di=se(yr.loc.start,Po.loc.end);return OT.array(Zi,{loc:{start:{...yr.loc.start},end:{...Po.loc.end}},...di})}t(mt,"parseArray");function hr(br){br=br??B();let yr=_.token;switch(br){case P_.String:case P_.Boolean:return te(br);case P_.Number:if(h){let Zi=a.slice(yr.loc.start.offset,yr.loc.end.offset);if((Zi[0]==="+"||Zi[0]==="-")&&(Zi=Zi.slice(1)),Zi==="NaN"||Zi==="Infinity")return Ue(yr)}return te(br);case P_.Null:return Ie(yr);case P_.LBrace:return Tt(br);case P_.LBracket:return mt(br);default:throw new f7(yr)}}t(hr,"parseValue");let rn=hr();if(B())throw new f7(_.token);let Qr={loc:{start:{line:1,column:1,offset:0},end:{...rn.loc.end}}};return s.tokens&&(Qr.tokens=l),s.ranges&&(Qr.range=[Qr.loc.start.offset,Qr.loc.end.offset]),OT.document(rn,Qr)}t(Dct,"parse");var Oir=new Map([["Document",["body"]],["Object",["members"]],["Member",["name","value"]],["Element",["value"]],["Array",["elements"]],["String",[]],["Number",[]],["Boolean",[]],["Null",[]],["NaN",[]],["Infinity",[]],["Identifier",[]]]);function Pct(a){return a&&typeof a=="object"}t(Pct,"isObject");function Fir(a){return Pct(a)&&typeof a.type=="string"}t(Fir,"isNode");function Lir(a,s){function l(_,h){typeof s.enter=="function"&&s.enter(_,h);for(let b of Oir.get(_.type)){let w=_[b];Pct(w)&&(Array.isArray(w)?w.forEach(N=>l(N,_)):Fir(w)&&l(w,_))}typeof s.exit=="function"&&s.exit(_,h)}t(l,"visitNode"),l(a)}t(Lir,"traverse");function Act(a,s=()=>!0){let l=[];return Lir(a,{enter(_,h){l.push({node:_,parent:h,phase:"enter"})},exit(_,h){l.push({node:_,parent:h,phase:"exit"})}}),l.filter(s).values()}t(Act,"iterator");import Rir from"node:fs/promises";var uG=t((a,s)=>a.split(/\r?\n/)[s-1],"getFileLineContent"),Wle=t(async a=>{try{return await Rir.readFile(a,"utf-8")}catch{return}},"getSchemaContent"),fG=t(async a=>{try{return Dct(a)}catch(s){if(s.column&&s.line&&s.message){let l=uG(a,s.line);return{column:s.column,line:s.line,length:void 0,lineText:l}}return}},"getSchemaAST");var Nct=t(async(a,s,l)=>{try{if(a.length===0)return;for(let _ of a){let h=await Wle(_),b=await Mir(h,_,s,l);if(b)return b}}catch{}},"getRouteLocationByValue"),Mir=t(async(a,s,l,_)=>{try{if(!a)return;let h=null,b=await fG(a);if(b){for(let{node:w}of Act(b))if(w.value&&w.value===l){h=w.loc;break}if(h!==null){let w=uG(a,h.start.line);return{file:s,line:h.start.line,column:h.start.column,length:h.end.column-h.start.column,lineText:w,suggestion:_}}}}catch{}},"getRouteLocationByValueFromSchema");import Ict from"node:fs/promises";import ZE from"node:path";var BNe="schemas",$Ne=".oas.json";var _7=t(async a=>(await Ict.readdir(a)).map(l=>ZE.join(a,l)).filter(l=>l.endsWith($Ne)).sort(),"getOpenApiFilesByAlphabetical"),sj=t(async a=>{let s=ZE.resolve(a,"config");return(await Ict.readdir(s)).filter(_=>_.endsWith($Ne)).length>=1},"oasFileInProject");function _G(a,s,l,_,h,b,w){if(b.has(l))return;let N;try{N=_.get(l)}catch(Ie){throw new G1({text:`Failed to resolve reference: ${l}`,detail:Ie.message,severity:"error",message:"Failed to resolve reference",location:{file:a,column:0,line:0,length:0,lineText:l,namespace:s,suggestion:"Check the reference and try again."}})}let B=Gle(l),q=ZE.basename(B,ZE.extname(B)),le=l.indexOf("#"),se=le>=0?l.substring(0,le):l,te=le>=0?l.substring(le+1):"",Ue=_.get(se);if(te){let Ie=te.split("/").filter(Boolean);for(let De of Ie)if(Ue=Ue[De],Ue===void 0)throw new Error(`Cannot resolve JSON pointer: ${te}`)}if(Ue&&typeof Ue=="object"&&"$ref"in Ue&&typeof Ue.$ref=="string"&&!Ue.$ref.startsWith("#")){let Ie=ZE.resolve(ZE.dirname(se),Ue.$ref);if(B=Ie,q=ZE.basename(B,ZE.extname(B)),se=Ie,b.has(se)){let Tt=b.get(se);if(Tt===void 0)throw new Error(`Expected to find ${se} in refsVisited map`);b.set(l,Tt);return}let De=h.length;b.set(l,De),b.set(se,De),h.push(se),Hle(B,q,N,_,h,b,w)}else b.set(l,h.length),h.push(l),Hle(Gle(l),s,N,_,h,b,w)}t(_G,"chaseRefs");function Hle(a,s,l,_,h,b,w){if(Array.isArray(l))for(let N of l)Hle(a,s,N,_,h,b,w);else if(typeof l=="object")for(let N in l){if(N==="$ref"){let B=l[N];w&&(l[N]=w(s,B,a)),_G(a,s,jI(a,B),_,h,b,w)}Hle(a,s,l[N],_,h,b,w)}}t(Hle,"lookForRefs");function jI(a,s){let l=s.indexOf("#");return l>=0?`${ZE.resolve(a,s.substring(0,l))}${s.substring(l)}`:ZE.resolve(ZE.dirname(a),s)}t(jI,"getFullyQualifiedRefName");function Gle(a){let s=a.indexOf("#");return s>=0?a.substring(0,s):a}t(Gle,"getFilePathNameFromRefName");var PG=Rd(t4e(),1);import{readFile as Mlr}from"node:fs/promises";var n4e={};Fat(n4e,{UnsafePathError:()=>Sue,deleteFolder:()=>Rlr,dirExists:()=>r4e,fileExists:()=>wlr,getParentDirFilename:()=>Olr,isNotFileOrDirectory:()=>Dlr,listFolderContents:()=>aft,listFolders:()=>Alr,mkDirTemp:()=>klr,mkdirForFilePathIfNotExits:()=>Nlr,mkdirIfNotExists:()=>oft,safePath:()=>Ilr,tarFolder:()=>Flr,untarFile:()=>Llr});import{spawn as ift}from"node:child_process";import{randomUUID as xlr}from"node:crypto";import VI from"node:fs/promises";import{platform as Elr,tmpdir as Clr}from"node:os";import ev from"node:path";var sft=[".git","node_modules",".yarn",".DS_Store"];async function wlr(a){try{return(await VI.stat(a)).isFile()}catch{return!1}}t(wlr,"fileExists");async function klr(){let a=process.env.BUILD_FILE_PATH??Clr(),s=xlr().replaceAll("-",""),l=ev.join(a,s);return await VI.mkdir(l,{recursive:!0}),l}t(klr,"mkDirTemp");async function r4e(a){try{return(await VI.stat(a)).isDirectory()}catch{return!1}}t(r4e,"dirExists");async function Dlr(a){try{return await VI.stat(a),!1}catch{return!0}}t(Dlr,"isNotFileOrDirectory");function Plr(a,s){let l=ev.sep==="\\"?"\\\\":ev.sep,_=new RegExp(`(.*)(${l}${s})$|(.*)(${s}${l})`),h=a.match(_);if(!h)return"";let b=a.split(h[0]);return b[1]===""?"":ev.join(ev.sep,b[1])}t(Plr,"getParentDirectory");async function Alr(a){if(!await r4e(a))return[];let s=await VI.readdir(a,{withFileTypes:!0}),l=[];for await(let _ of s)sft.includes(_.name)||_.isDirectory()&&l.push(_.name);return l}t(Alr,"listFolders");async function aft(a,s,l=!0){let _=Plr(a,s),h=await VI.readdir(a,{withFileTypes:!0}),b=[];for await(let w of h)if(!sft.includes(w.name)||!l)if(w.isDirectory()){let N=await aft(ev.join(a,w.name),s,l);b.push(...N)}else b.push(ev.join(_,w.name));return b}t(aft,"listFolderContents");var oft=t(async a=>{await VI.mkdir(a,{recursive:!0})},"mkdirIfNotExists"),Nlr=t(async a=>{let s=ev.dirname(a);return oft(s)},"mkdirForFilePathIfNotExits"),Sue=class extends Error{static{t(this,"UnsafePathError")}constructor(s){super(s)}};function Ilr(a){let s=ev.normalize(a),l=t(_=>{let h=ev.normalize(_),b=process.platform==="win32",w=!1;if(b?w=h.toLowerCase().startsWith(s.toLowerCase()):w=h.startsWith(s),!w)throw new Sue("Resolved path is not part of the project.");return h},"ensureSafePath");return{resolve:t((..._)=>l(ev.resolve(..._)),"resolve")}}t(Ilr,"safePath");function Olr(a){return ev.join(ev.basename(ev.dirname(a)),ev.basename(a))}t(Olr,"getParentDirFilename");async function Flr({folderPath:a,outputTarPath:s,exclude:l=["node_modules",".git","dist"],logger:_}){let h=[],b=[],w;try{await new Promise((N,B)=>{let q=ift("tar",[...l.map(le=>["--exclude",le]).flat(),...Elr()!=="darwin"?["--warning=no-file-changed"]:[],"-cvf",s,"-C",a,"."]);q.stdout.on("data",le=>{let se=le.toString().trim();se.length>0&&h.push(se.trim())}),q.stderr.on("data",le=>{let se=le.toString().trim();se.length>0&&b.push(se.trim())}),q.on("close",le=>{w=le,le===0?N():B(new Error(`tar process exited with code ${le}`))}),q.on("error",le=>{B(le)})})}catch(N){throw new Error("Failed to tar folder",{cause:N})}finally{_.info({stdout:h.join(`
|
|
577
|
+
`&&b++;else if(l)_+=w,b=h+2;else throw new CA(`Invalid escape \\${w}.`,{line:s.loc.start.line,column:s.loc.start.column+h,offset:s.loc.start.offset+h});h=a.indexOf("\\",b)}return _+=a.slice(b),_}t(Nir,"getStringValue");function Iir(a,s,l=!1){switch(s.type){case"Boolean":return a==="true";case"Number":return Number(a);case"String":return Nir(a.slice(1,-1),s,l);default:throw new TypeError(`Unknown token type "${s.type}.`)}}t(Iir,"getLiteralValue");function Dct(a,s){s=Object.freeze({...Air,...s});let l=[],_=new jNe(a,{mode:s.mode,ranges:s.ranges}),h=s.mode==="json5",b=s.allowTrailingCommas||h;function w(){let br=_.next();return br&&s.tokens&&l.push(_.token),br}t(w,"nextNoComments");function N(){let br=_.next();return br&&s.tokens&&l.push(_.token),br>=P_.LineComment?N():br}t(N,"nextSkipComments");let B=s.mode==="json"?w:N;function q(br,yr){if(br!==yr)throw new f7(_.token)}t(q,"assertTokenType");function le(br,yr){if(!yr.includes(br))throw new f7(_.token)}t(le,"assertTokenTypes");function se(br,yr){return s.ranges?{range:[br.offset,yr.offset]}:void 0}t(se,"createRange");function te(br){let yr=_.token,Zi=se(yr.loc.start,yr.loc.end),Ci=Iir(a.slice(yr.loc.start.offset,yr.loc.end.offset),yr,h),di={loc:{start:{...yr.loc.start},end:{...yr.loc.end}},...Zi};switch(br){case P_.String:return OT.string(Ci,di);case P_.Number:return OT.number(Ci,di);case P_.Boolean:return OT.boolean(Ci,di);default:throw new TypeError(`Unknown token type ${yr.type}.`)}}t(te,"createLiteralNode");function Ue(br){let yr=se(br.loc.start,br.loc.end),Zi=a.slice(br.loc.start.offset,br.loc.end.offset),Po={loc:{start:{...br.loc.start},end:{...br.loc.end}},...yr};if(br.type!=="Identifier"){let di="";return(Zi[0]==="+"||Zi[0]==="-")&&(di=Zi[0]),OT[Zi.includes("NaN")?"nan":"infinity"](di,Po)}return OT.identifier(Zi,Po)}t(Ue,"createJSON5IdentifierNode");function Ie(br){let yr=se(br.loc.start,br.loc.end);return OT.null({loc:{start:{...br.loc.start},end:{...br.loc.end}},...yr})}t(Ie,"createNullNode");function De(br){h?le(br,[P_.String,P_.Identifier,P_.Number]):q(br,P_.String);let yr=_.token,Zi=br===P_.String?te(br):Ue(yr);if(h&&(Zi.type==="NaN"||Zi.type==="Infinity")){if(Zi.sign!=="")throw new f7(_.token);Zi=OT.identifier(Zi.type,{loc:Zi.loc,...se(Zi.loc.start,Zi.loc.end)})}br=B(),q(br,P_.Colon);let Ci=hr(),Po=se(Zi.loc.start,Ci.loc.end);return OT.member(Zi,Ci,{loc:{start:{...Zi.loc.start},end:{...Ci.loc.end}},...Po})}t(De,"parseProperty");function Tt(br){q(br,P_.LBrace);let yr=_.token,Zi=[],Ci=B();if(Ci!==P_.RBrace)do{if(Zi.push(De(Ci)),Ci=B(),!Ci)throw new Vle(Zi[Zi.length-1].loc.end);if(Ci===P_.Comma){if(Ci=B(),b&&Ci===P_.RBrace)break}else break}while(Ci);q(Ci,P_.RBrace);let Po=_.token,di=se(yr.loc.start,Po.loc.end);return OT.object(Zi,{loc:{start:{...yr.loc.start},end:{...Po.loc.end}},...di})}t(Tt,"parseObject");function mt(br){q(br,P_.LBracket);let yr=_.token,Zi=[],Ci=B();if(Ci!==P_.RBracket)do{let vf=hr(Ci);if(Zi.push(OT.element(vf,{loc:vf.loc})),Ci=B(),Ci===P_.Comma){if(Ci=B(),b&&Ci===P_.RBracket)break}else break}while(Ci);q(Ci,P_.RBracket);let Po=_.token,di=se(yr.loc.start,Po.loc.end);return OT.array(Zi,{loc:{start:{...yr.loc.start},end:{...Po.loc.end}},...di})}t(mt,"parseArray");function hr(br){br=br??B();let yr=_.token;switch(br){case P_.String:case P_.Boolean:return te(br);case P_.Number:if(h){let Zi=a.slice(yr.loc.start.offset,yr.loc.end.offset);if((Zi[0]==="+"||Zi[0]==="-")&&(Zi=Zi.slice(1)),Zi==="NaN"||Zi==="Infinity")return Ue(yr)}return te(br);case P_.Null:return Ie(yr);case P_.LBrace:return Tt(br);case P_.LBracket:return mt(br);default:throw new f7(yr)}}t(hr,"parseValue");let rn=hr();if(B())throw new f7(_.token);let Qr={loc:{start:{line:1,column:1,offset:0},end:{...rn.loc.end}}};return s.tokens&&(Qr.tokens=l),s.ranges&&(Qr.range=[Qr.loc.start.offset,Qr.loc.end.offset]),OT.document(rn,Qr)}t(Dct,"parse");var Oir=new Map([["Document",["body"]],["Object",["members"]],["Member",["name","value"]],["Element",["value"]],["Array",["elements"]],["String",[]],["Number",[]],["Boolean",[]],["Null",[]],["NaN",[]],["Infinity",[]],["Identifier",[]]]);function Pct(a){return a&&typeof a=="object"}t(Pct,"isObject");function Fir(a){return Pct(a)&&typeof a.type=="string"}t(Fir,"isNode");function Lir(a,s){function l(_,h){typeof s.enter=="function"&&s.enter(_,h);for(let b of Oir.get(_.type)){let w=_[b];Pct(w)&&(Array.isArray(w)?w.forEach(N=>l(N,_)):Fir(w)&&l(w,_))}typeof s.exit=="function"&&s.exit(_,h)}t(l,"visitNode"),l(a)}t(Lir,"traverse");function Act(a,s=()=>!0){let l=[];return Lir(a,{enter(_,h){l.push({node:_,parent:h,phase:"enter"})},exit(_,h){l.push({node:_,parent:h,phase:"exit"})}}),l.filter(s).values()}t(Act,"iterator");import Rir from"node:fs/promises";var uG=t((a,s)=>a.split(/\r?\n/)[s-1],"getFileLineContent"),Wle=t(async a=>{try{return await Rir.readFile(a,"utf-8")}catch{return}},"getSchemaContent"),fG=t(async a=>{try{return Dct(a)}catch(s){if(s.column&&s.line&&s.message){let l=uG(a,s.line);return{column:s.column,line:s.line,length:void 0,lineText:l}}return}},"getSchemaAST");var Nct=t(async(a,s,l)=>{try{if(a.length===0)return;for(let _ of a){let h=await Wle(_),b=await Mir(h,_,s,l);if(b)return b}}catch{}},"getRouteLocationByValue"),Mir=t(async(a,s,l,_)=>{try{if(!a)return;let h=null,b=await fG(a);if(b){for(let{node:w}of Act(b))if(w.value&&w.value===l){h=w.loc;break}if(h!==null){let w=uG(a,h.start.line);return{file:s,line:h.start.line,column:h.start.column,length:h.end.column-h.start.column,lineText:w,suggestion:_}}}}catch{}},"getRouteLocationByValueFromSchema");import Ict from"node:fs/promises";import ZE from"node:path";var BNe="schemas",$Ne=".oas.json";var _7=t(async a=>(await Ict.readdir(a)).map(l=>ZE.join(a,l)).filter(l=>l.endsWith($Ne)).sort(),"getOpenApiFilesByAlphabetical"),sj=t(async a=>{let s=ZE.resolve(a,"config");return(await Ict.readdir(s)).filter(_=>_.endsWith($Ne)).length>=1},"oasFileInProject");function _G(a,s,l,_,h,b,w){if(b.has(l))return;let N;try{N=_.get(l)}catch(Ie){throw new G1({text:`Failed to resolve reference: ${l}`,detail:Ie.message,severity:"error",message:"Failed to resolve reference",location:{file:a,column:0,line:0,length:0,lineText:l,namespace:s,suggestion:"Check the reference and try again."}})}let B=Gle(l),q=ZE.basename(B,ZE.extname(B)),le=l.indexOf("#"),se=le>=0?l.substring(0,le):l,te=le>=0?l.substring(le+1):"",Ue=_.get(se);if(te){let Ie=te.split("/").filter(Boolean);for(let De of Ie)if(Ue=Ue[De],Ue===void 0)throw new Error(`Cannot resolve JSON pointer: ${te}`)}if(Ue&&typeof Ue=="object"&&"$ref"in Ue&&typeof Ue.$ref=="string"&&!Ue.$ref.startsWith("#")){let Ie=ZE.resolve(ZE.dirname(se),Ue.$ref);if(B=Ie,q=ZE.basename(B,ZE.extname(B)),se=Ie,b.has(se)){let Tt=b.get(se);if(Tt===void 0)throw new Error(`Expected to find ${se} in refsVisited map`);b.set(l,Tt);return}let De=h.length;b.set(l,De),b.set(se,De),h.push(se),Hle(B,q,N,_,h,b,w)}else b.set(l,h.length),h.push(l),Hle(Gle(l),s,N,_,h,b,w)}t(_G,"chaseRefs");function Hle(a,s,l,_,h,b,w){if(Array.isArray(l))for(let N of l)Hle(a,s,N,_,h,b,w);else if(typeof l=="object")for(let N in l){if(N==="$ref"){let B=l[N];w&&(l[N]=w(s,B,a)),_G(a,s,jI(a,B),_,h,b,w)}Hle(a,s,l[N],_,h,b,w)}}t(Hle,"lookForRefs");function jI(a,s){let l=s.indexOf("#");return l>=0?`${ZE.resolve(a,s.substring(0,l))}${s.substring(l)}`:ZE.resolve(ZE.dirname(a),s)}t(jI,"getFullyQualifiedRefName");function Gle(a){let s=a.indexOf("#");return s>=0?a.substring(0,s):a}t(Gle,"getFilePathNameFromRefName");var PG=Rd(t4e(),1);import{readFile as Mlr}from"node:fs/promises";var n4e={};Fat(n4e,{UnsafePathError:()=>Sue,deleteFolder:()=>Rlr,dirExists:()=>r4e,fileExists:()=>wlr,getParentDirFilename:()=>Olr,isNotFileOrDirectory:()=>Dlr,listFolderContents:()=>aft,listFolders:()=>Alr,mkDirTemp:()=>klr,mkdirForFilePathIfNotExits:()=>Nlr,mkdirIfNotExists:()=>oft,safePath:()=>Ilr,tarFolder:()=>Flr,untarFile:()=>Llr});import{spawn as ift}from"node:child_process";import{randomUUID as xlr}from"node:crypto";import VI from"node:fs/promises";import{platform as Elr,tmpdir as Clr}from"node:os";import ev from"node:path";var sft=[".git","node_modules",".yarn",".DS_Store"];async function wlr(a){try{return(await VI.stat(a)).isFile()}catch{return!1}}t(wlr,"fileExists");async function klr(){let a=process.env.BUILD_FILE_PATH??Clr(),s=xlr().replaceAll("-",""),l=ev.join(a,s);return await VI.mkdir(l,{recursive:!0}),l}t(klr,"mkDirTemp");async function r4e(a){try{return(await VI.stat(a)).isDirectory()}catch{return!1}}t(r4e,"dirExists");async function Dlr(a){try{return await VI.stat(a),!1}catch{return!0}}t(Dlr,"isNotFileOrDirectory");function Plr(a,s){let l=ev.sep==="\\"?"\\\\":ev.sep,_=new RegExp(`(.*)(${l}${s})$|(.*)(${s}${l})`),h=a.match(_);if(!h)return"";let b=a.split(h[0]);return b[1]===""?"":ev.join(ev.sep,b[1])}t(Plr,"getParentDirectory");async function Alr(a){if(!await r4e(a))return[];let s=await VI.readdir(a,{withFileTypes:!0}),l=[];for await(let _ of s)sft.includes(_.name)||_.isDirectory()&&l.push(_.name);return l}t(Alr,"listFolders");async function aft(a,s,l=!0){let _=Plr(a,s),h=await VI.readdir(a,{withFileTypes:!0}),b=[];for await(let w of h)if(!sft.includes(w.name)||!l)if(w.isDirectory()){let N=await aft(ev.join(a,w.name),s,l);b.push(...N)}else b.push(ev.join(_,w.name));return b}t(aft,"listFolderContents");var oft=t(async a=>{await VI.mkdir(a,{recursive:!0})},"mkdirIfNotExists"),Nlr=t(async a=>{let s=ev.dirname(a);return oft(s)},"mkdirForFilePathIfNotExits"),Sue=class extends Error{static{t(this,"UnsafePathError")}};function Ilr(a){let s=ev.normalize(a),l=t(_=>{let h=ev.normalize(_),b=process.platform==="win32",w=!1;if(b?w=h.toLowerCase().startsWith(s.toLowerCase()):w=h.startsWith(s),!w)throw new Sue("Resolved path is not part of the project.");return h},"ensureSafePath");return{resolve:t((..._)=>l(ev.resolve(..._)),"resolve")}}t(Ilr,"safePath");function Olr(a){return ev.join(ev.basename(ev.dirname(a)),ev.basename(a))}t(Olr,"getParentDirFilename");async function Flr({folderPath:a,outputTarPath:s,exclude:l=["node_modules",".git","dist"],logger:_}){let h=[],b=[],w;try{await new Promise((N,B)=>{let q=ift("tar",[...l.flatMap(le=>["--exclude",le]),...Elr()!=="darwin"?["--warning=no-file-changed"]:[],"-cvf",s,"-C",a,"."]);q.stdout.on("data",le=>{let se=le.toString().trim();se.length>0&&h.push(se.trim())}),q.stderr.on("data",le=>{let se=le.toString().trim();se.length>0&&b.push(se.trim())}),q.on("close",le=>{w=le,le===0?N():B(new Error(`tar process exited with code ${le}`))}),q.on("error",le=>{B(le)})})}catch(N){throw new Error("Failed to tar folder",{cause:N})}finally{_.info({stdout:h.join(`
|
|
578
578
|
`),stderr:b.join(`
|
|
579
579
|
`),exitCode:w},"Tar process logs")}}t(Flr,"tarFolder");async function Llr({tarFilePath:a,outputDir:s,logger:l}){let _=[],h=[],b;try{await new Promise((w,N)=>{let B=ift("sh",["-c",`tar -xvf ${a} -C ${s};`]);B.stdout.on("data",q=>{let le=q.toString().trim();le.length>0&&_.push(le.trim())}),B.stderr.on("data",q=>{let le=q.toString().trim();le.length>0&&h.push(le.trim())}),B.on("close",q=>{b=q,q===0?w():N(new Error(`tar process exited with code ${q}`))}),B.on("error",q=>{N(q)})})}catch(w){throw new Error("Failed to untar file",{cause:w})}finally{l.info({stdout:_.join(`
|
|
580
580
|
`),stderr:h.join(`
|
|
581
|
-
`),exitCode:b},"Untar process logs")}}t(Llr,"untarFile");async function Rlr(a){if(await r4e(a))return await VI.rm(a,{recursive:!0})}t(Rlr,"deleteFolder");var ou=n4e;var MT=Rd(t4e(),1);var S7=class extends Error{static{t(this,"CustomResolveError")}},WI=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return PG.$RefParser.dereference(s,{resolve:{json:!0,file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return PG.$RefParser.bundle(s,{resolve:{file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return PG.$RefParser.parse(s,{resolve:{file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return PG.$RefParser.resolve(s,{resolve:{file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Tue(a,s){return{order:100,canRead(l){let _=$lr(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=cft(l.url)}catch(w){throw new S7(`Malformed URI: ${l.url}`,{cause:w})}try{ou.safePath(a).resolve(b)}catch(w){return s?.warn(w),!1}return!0},async read(l){let _;try{_=cft(l.url)}catch(h){throw new S7(`Malformed URI: ${l.url}`,{cause:h})}try{return await Mlr(_)}catch(h){throw new S7(`Error opening file "${_}"`,{cause:h})}}}}t(Tue,"customResolver");var bj=/^win/.test(globalThis.process?globalThis.process.platform:""),jlr=/\//g,Blr=/^(\w{2,}):\/\//i,i4e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function $lr(a){let s=Blr.exec(a);if(s)return s[1].toLowerCase()}t($lr,"getProtocol");function cft(a,s){a=decodeURI(a);for(let _=0;_<i4e.length;_+=2)a=a.replace(i4e[_],i4e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),bj&&a[1]==="/"&&(a=a[0]+":"+a.substr(1)),s?a="file:///"+a:(l=!1,a=bj?a:"/"+a)),!l){let _=a.split(bj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(bj?"\\":"/"),!bj&&h[0]===""&&(a="/"+a.substring(1))}return bj&&!l&&(a=a.replace(jlr,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(cft,"toFileSystemPath");var lft="YOUR_KEY_HERE";async function uft(a){let l=await new WI(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return Ulr({...a,relativeOpenApiPath:_},l)}t(uft,"buildPublicOpenApiFile");async function Ulr(a,s){Vlr({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=Jlr(l),zlr(l,a.urls?.api?.defaultUrl),l=qlr(l,a),fft(l,"x-zuplo"),l}t(Ulr,"buildRawOpenApiFile");function zlr(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(zlr,"addServerHost");function Jlr(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[w,N])=>(VM in N&&dle(N[VM])&&(b.push(w),l.parameters&&delete l.parameters[w]),b),[]));let h=Object.entries(a.paths).reduce((b,[w,N])=>{if(!N)return b;let B={...N},q=["delete","get","head","patch","post","put","trace","options"];return q.forEach(le=>{let se=N[le];if(!se)return;if(dle(se[VM])){delete B[le];return}let{parameters:te}=se;if(!te)return;let Ue=te.filter(Ie=>{if(VM in Ie&&dle(Ie[VM]))return!1;if("$ref"in Ie){let De=Ie.$ref.split("/").pop();return De?!_.includes(De):!0}return!0});B[le]={...se,parameters:Ue}}),q.some(le=>!!B[le])&&(b[w]=B),b},{});return{...a,paths:h,components:l}}t(Jlr,"removeHiddenRoutesAndParams");function qlr(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let w={...b};return[w.delete,w.get,w.head,w.patch,w.post,w.put,w.trace,w.options].forEach(N=>{if(!N)return;let B=N["x-zuplo-route"]?.policies?.inbound?.reduce((se,te)=>{let Ue=s.policies?.find(({name:Tt})=>Tt===te);if(!Ue)return se;if(!(Ue.handler.export==="CompositeInboundPolicy"))return se.concat(te);let De=Ue.handler.options?.policies;return De?se.concat(De):se},[]),q=[];if(B&&B.forEach(se=>{s.policies?.forEach(te=>{te.name===se&&(te.handler.export==="ApiAuthKeyInboundPolicy"||te.handler.export==="ApiKeyInboundPolicy")&&!te.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&q.push(te)})}),q.length>0){let se=q.length>0&&q[0].handler&&q[0].handler.options&&q[0].handler.options.authHeader?q[0].handler.options.authHeader:"Authorization",te=q.length>0&&q[0].handler&&q[0].handler.options&&(q[0].handler.options.authScheme||q[0].handler.options.authScheme==="")?q[0].handler.options.authScheme:"Bearer",Ue=te!==""?`${te} ${lft}`:lft,Ie={name:se,in:"header",required:!0,example:Ue,schema:{type:"string"},description:`The \`${se}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ue}\`.`};N.parameters?N.parameters.some(hr=>"name"in hr&&hr.name===Ie.name)||N.parameters.unshift(Ie):N.parameters=[Ie];let De={type:"http",scheme:te.toLowerCase()},Tt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(hr=>"name"in hr&&hr.type==="apiKey"||"type"in hr&&hr.type==="http"&&hr.scheme===te)||(a.components.securitySchemes={...a.components.securitySchemes,[Tt]:De}):(a.components||(a.components={}),a.components.securitySchemes={[Tt]:De});let mt={[Tt]:[]};N.security?N.security.some(hr=>hr[Tt]!==void 0)||N.security.unshift(mt):N.security=[mt]}let le=[];if(B&&B.forEach(se=>{s.policies?.forEach(te=>{te.name===se&&(te.handler.export==="RateLimitInboundPolicy"||te.handler.export==="ComplexRateLimitInboundPolicy")&&le.push(te)})}),le.length>0){let se={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},te={...se,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:se,RateLimitWithRetryAfter:te},N.responses||(N.responses={});let Ue=le.some(Ie=>Ie.handler.options?.headerMode!=="none");N.responses[429]||(N.responses[429]={$ref:Ue?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=w,_},{});return{...a,paths:l}}t(qlr,"enrichSpecWithZuploData");function fft(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&fft(a[l],s)}t(fft,"removePropertiesByPrefix");function Vlr({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new G1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new G1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new G1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(Vlr,"assertIsZuploOpenApiSpec");import PK from"node:path";function Wlr(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let q=0;q<s.length;q++)s[q]=255;for(let q=0;q<a.length;q++){let le=a.charAt(q),se=le.charCodeAt(0);if(s[se]!==255)throw new TypeError(le+" is ambiguous");s[se]=q}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function w(q){if(q instanceof Uint8Array||(ArrayBuffer.isView(q)?q=new Uint8Array(q.buffer,q.byteOffset,q.byteLength):Array.isArray(q)&&(q=Uint8Array.from(q))),!(q instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(q.length===0)return"";let le=0,se=0,te=0,Ue=q.length;for(;te!==Ue&&q[te]===0;)te++,le++;let Ie=(Ue-te)*b+1>>>0,De=new Uint8Array(Ie);for(;te!==Ue;){let hr=q[te],rn=0;for(let jr=Ie-1;(hr!==0||rn<se)&&jr!==-1;jr--,rn++)hr+=256*De[jr]>>>0,De[jr]=hr%l>>>0,hr=hr/l>>>0;if(hr!==0)throw new Error("Non-zero carry");se=rn,te++}let Tt=Ie-se;for(;Tt!==Ie&&De[Tt]===0;)Tt++;let mt=_.repeat(le);for(;Tt<Ie;++Tt)mt+=a.charAt(De[Tt]);return mt}t(w,"encode");function N(q){if(typeof q!="string")throw new TypeError("Expected String");if(q.length===0)return new Uint8Array;let le=0,se=0,te=0;for(;q[le]===_;)se++,le++;let Ue=(q.length-le)*h+1>>>0,Ie=new Uint8Array(Ue);for(;q[le];){let hr=s[q.charCodeAt(le)];if(hr===255)return;let rn=0;for(let jr=Ue-1;(hr!==0||rn<te)&&jr!==-1;jr--,rn++)hr+=l*Ie[jr]>>>0,Ie[jr]=hr%256>>>0,hr=hr/256>>>0;if(hr!==0)throw new Error("Non-zero carry");te=rn,le++}let De=Ue-te;for(;De!==Ue&&Ie[De]===0;)De++;let Tt=new Uint8Array(se+(Ue-De)),mt=se;for(;De!==Ue;)Tt[mt++]=Ie[De++];return Tt}t(N,"decodeUnsafe");function B(q){let le=N(q);if(le)return le;throw new Error("Non-base"+l+" character")}return t(B,"decode"),{encode:w,decodeUnsafe:N,decode:B}}t(Wlr,"base");var _ft=Wlr;var Hlr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",xue=_ft(Hlr);var Glr=!1;function Sj(a,s){return{open:`\x1B[${a.join(";")}m`,close:`\x1B[${s}m`,regexp:new RegExp(`\\x1b\\[${s}m`,"g")}}t(Sj,"code");function Tj(a,s){return Glr?`${s.open}${a.replace(s.regexp,s.open)}${s.close}`:a}t(Tj,"run");function Klr(a){return Tj(a,Sj([31],39))}t(Klr,"red");function Ylr(a){return Tj(a,Sj([32],39))}t(Ylr,"green");function Xlr(a){return Tj(a,Sj([33],39))}t(Xlr,"yellow");function Zlr(a){return Tj(a,Sj([34],39))}t(Zlr,"blue");function Qlr(a){return Tj(a,Sj([35],39))}t(Qlr,"magenta");function eur(a){return Tj(a,Sj([36],39))}t(eur,"cyan");var bRr=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|"),"g");var pft=[Klr,Ylr,Xlr,Zlr,Qlr,eur];function tur(a){let s=0,l=a.length,_=0;if(l>0)for(;_<l;)s=(s<<5)-s+a.charCodeAt(_++)|0;return s}t(tur,"hashCode");function dft(a){let s=Math.abs(tur(a));return pft[s%pft.length]}t(dft,"generateColor");import{inspect as rur}from"node:util";function mft(a,s,...l){let _=0,h=l.length,b=String(s).replace(/%[sdjoO%]/g,w=>{if(w==="%%")return"%";if(_>=h)return w;switch(w){case"%s":return String(l[_++]);case"%d":return Number(l[_++]).toString();case"%o":return a(l[_++]).split(`
|
|
582
|
-
`).map(N=>N.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return w}});for(let w of l.splice(_))w===null||!(typeof w=="object"&&w!==null)?b+=" "+w:b+=" "+a(w);return b}t(mft,"format");var hft=t((a,...s)=>mft(rur,a,s),"format");var s4e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=dft(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let h=Date.now()-(this.last||Date.now());l=hft(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${h}ms`)}`;console.log(b),this.last=Date.now()}},a4e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function nur(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(nur,"extract");var Eue;function Cue(a){Eue||(Eue=new a4e(nur(process.env.DEBUG)));let s=new s4e(Eue,a);return Eue.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(Cue,"debug");var AA=class extends Error{static{t(this,"RuntimeError")}extensionMembers;constructor(s,l){typeof s=="string"?super(s,l):(super(s.message,l),this.extensionMembers=s.extensionMembers),this.name="RuntimeError"}};var gft="zp-local-service";var RRr=Symbol("zuplo_meters"),MRr=Symbol("zuplo_dynamic_meters");var HI=Cue("zuplo:runtime:external-service");function iur(){let a,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:s}=j0.instance.runtime;if(s&&s!=="undefined")try{let l=atob(s);a=JSON.parse(l)}catch{}return a}t(iur,"getServiceAuth");async function yft(a,s){let l=".proxy",_=".tunnel";if(typeof a=="string"){let h=new URL(a),b=h.hostname;if(b.endsWith(l)){let Tt=b.slice(0,-l.length),mt=new URL(`http://${Tt}${h.pathname}${h.search}`);HI(`Routing to proxy: ${mt.toString()}`);let hr=s??{};return xj(mt.toString(),hr)}let w=b.endsWith(_),N=b.indexOf(".")===-1;if(!(w||N))throw new AA(`Invalid service hostname suffix: ${b}. Use .proxy for proxy routing, .tunnel for explicit tunnel routing, or no suffix for default tunnel routing.`);let q=w?b.slice(0,-_.length):b,le=iur();if(!le)throw HI("There is no external service auth configured for this zup."),new AA("There are no external services configured for this zup.");HI(`Using external service auth. ClientId: ${le.clientId})`);let se=s??{},te=new Headers(se.headers||{});te.set("CF-Access-Client-Id",le.clientId),te.set("CF-Access-Client-Secret",le.clientSecret),se.headers=te;let Ue;if(le.customServiceMapping&&le.customServiceMapping[q])Ue=`https://${le.customServiceMapping[q]}`;else if(j0.instance.useLegacyServiceRouting)Ue=`https://${q}.zuptunnel.com`;else{HI("Using sha256 service routing");let Tt=j0.instance.build;if(Tt.ACCOUNT_NAME&&Tt.PROJECT_NAME&&Tt.ENVIRONMENT_TYPE){let mt=await sur(q,Tt.ACCOUNT_NAME,Tt.PROJECT_NAME,Tt.ENVIRONMENT_TYPE),hr=bft(Tt.ENVIRONMENT_TYPE),rn=await o4e(`${Tt.ACCOUNT_NAME}-${Tt.PROJECT_NAME}-${hr}`);rn==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||rn==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?Ue=`https://${mt}.zuptunnel.com`:Ue=`https://${mt}.t.zuplo.app`}else throw HI("Cannot use sha256 service routing, missing build variables"),new AA("Failed to generate fully qualified tunnel url.")}let Ie=new URL(`${Ue}${h.pathname}${h.search}`);HI(`Calling external service: ${Ie.toString()}`);let De=await xj(Ie.toString(),se);if(De.status===403&&De.headers.get("cf-access-domain")!==null)throw AG.console.error("403 Forbidden when calling external service.",{clientId:le.clientId,tunnelHost:Ue}),new AA("Could not connect to secure tunnel.");return De}else throw HI("Cannot call external service with Request object"),new AA("Currently, we only support fetch(<some_string>, ...).")}t(yft,"externalServiceHandler");async function vft(a,s){if(typeof a=="string"){let l=new URL(a),_=l.hostname,h=s??{},b=`http://${_}.zuplo.svc.cluster.local:9000`,w=new URL(`${b}${l.pathname}${l.search}`),N=new Headers(h.headers||{});return N.set(gft,_),h.headers=N,await xj(w.toString(),h)}else throw new AA("Currently, we only support fetch(<some_string>, ...).")}t(vft,"clusterServiceHandler");async function sur(a,s,l,_){let h=a.toLowerCase(),b=s.toLowerCase(),w=l.toLowerCase(),N=bft(_);HI(`Hashing service name: ${b}-${h}.${b}-${w}-${N}`);let B=await o4e(`${b}-${h}`),q=await o4e(`${b}-${w}-${N}`);return`${B}.${q}`}t(sur,"hashServiceName");async function o4e(a){let s=new TextEncoder().encode(a),l=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(l)).map(b=>b.toString(16).padStart(2,"0")).join("").slice(0,-1)}t(o4e,"hashSegment");function bft(a){let s=a.toLowerCase();switch(s){case"production":case"preview":return s;default:return"working-copy"}}t(bft,"sanitizeEnvironmentType");var c4e=new Map;c4e.set("service:",yft);c4e.set("local:",vft);var xj=globalThis.fetch;function l4e(a,s){let l=aur(s);if(typeof a=="string"){let _=new URL(a),h=c4e.get(_.protocol);return h?h(a,l):xj(a,l)}else return xj(a,l)}t(l4e,"internalFetch");globalThis.fetch=l4e;var aur=t(a=>{if(!a||a instanceof Request)return a;let s=a;if(!s.zuplo)return a;let l=a;return l.cf={cacheEverything:s.zuplo?.cacheEverything,cacheTtl:s.zuplo?.cacheTtlSeconds},delete a.zuplo,a},"transformInit");var our={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:l4e},AG=our;var u4e="2025-02-06",Sft=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function Tft(){return new j0({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:u4e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Sft[u4e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:"",ZUPLO_SERVICE_BUCKET_ID:"mock-bucket-id"}})}t(Tft,"getMockEnvironment");var j0=class a{static{t(this,"Environment")}config;static#e;static#n=!1;static initialize(s){this.#e||(this.#e=new a(s),this.#n=!0)}static get instance(){return this.#n||(AG.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#e=Tft()),this.#e}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(xue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let w of Object.keys(b))l[w]||(l[w]=b[w])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){AG.console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let s=typeof globalThis.Deno<"u"&&globalThis.Deno.version&&globalThis.Deno.version.deno;return typeof WebSocketPair!="function"&&s}}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}get rateLimitServiceTimeoutMs(){let s=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,l=this.config.rate_limit_service_timeout_ms,_=s??l;if(!_)return 500;let h=Number(_);return Number.isFinite(h)&&h>0?h:500}};var cur=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function xft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!cur.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):a.startsWith("ZUDOKU_")?!a.startsWith("ZUDOKU_PUBLIC_"):!1}t(xft,"isRestrictedEnvVariableName");function Eft(a){return!!a.startsWith("ZUPLO_")}t(Eft,"isZuploReadableEnvVariableName");var l9r=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return j0.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return j0.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return j0.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return j0.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return j0.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return j0.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return j0.instance.build.COMPATIBILITY_DATE}if(!(xft(l)&&!Eft(l)))return j0.instance.runtime[l]}});function NG(a,s,l){return`_${NA(`${a}_${s}_${l}`)}`}t(NG,"getRawOperationDataIdentifierName");function f4e(a,s,l,_){return`_${NA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(f4e,"getIdForParameterSchema");function _4e(a,s,l){return`_${NA(a.toLowerCase())}_${s.toLowerCase()}_rb_${NA(l.toLowerCase())}`}t(_4e,"getIdForRequestBodySchema");function IG(a,s){return`_${NA(a)}_${NA(s)}`}t(IG,"getIdForRefSchema");function NA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s="_"+s),s}t(NA,"sanitizedIdentifierName");var Oht=Rd(V_t(),1);var VG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},L_r=/[$_\p{ID_Start}]/u,R_r=/[$_\u200C\u200D\p{ID_Continue}]/u,W4e=".*";function M_r(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(M_r,"Re");function G_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(w){if(!s)throw new TypeError(w);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let w="",N=_+1;for(;N<a.length;){let B=a.substr(N,1);if(N===_+1&&L_r.test(B)||N!==_+1&&R_r.test(B)){w+=a[N++];continue}break}if(!w){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:w}),_=N;continue}if(h==="("){let w=1,N="",B=_+1,q=!1;if(a[B]==="?"){b(`Pattern cannot start with "?" at ${B}`);continue}for(;B<a.length;){if(!M_r(a[B],!1)){b(`Invalid character '${a[B]}' at ${B}.`),q=!0;break}if(a[B]==="\\"){N+=a[B++]+a[B++];continue}if(a[B]===")"){if(w--,w===0){B++;break}}else if(a[B]==="("&&(w++,a[B+1]!=="?")){b(`Capturing groups are not allowed at ${B}`),q=!0;break}N+=a[B++]}if(q)continue;if(w){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=B;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(G_t,"v");function K_t(a,s={}){let l=G_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${$T(s.delimiter)}]+?`,h=[],b=0,w=0,N="",B=new Set,q=t(rn=>{if(w<l.length&&l[w].type===rn)return l[w++].value},"a"),le=t(()=>q("OTHER_MODIFIER")??q("ASTERISK"),"f"),se=t(rn=>{let jr=q(rn);if(jr!==void 0)return jr;let{type:Qr,index:br}=l[w];throw new TypeError(`Unexpected ${Qr} at ${br}, expected ${rn}`)},"d"),te=t(()=>{let rn="",jr;for(;jr=q("CHAR")??q("ESCAPED_CHAR");)rn+=jr;return rn},"T"),Ue=t(rn=>rn,"Se"),Ie=s.encodePart||Ue,De="",Tt=t(rn=>{De+=rn},"U"),mt=t(()=>{De.length&&(h.push(new VG(3,"","",Ie(De),"",3)),De="")},"$"),hr=t((rn,jr,Qr,br,yr)=>{let Zi=3;switch(yr){case"?":Zi=1;break;case"*":Zi=0;break;case"+":Zi=2;break}if(!jr&&!Qr&&Zi===3){Tt(rn);return}if(mt(),!jr&&!Qr){if(!rn)return;h.push(new VG(3,"","",Ie(rn),"",Zi));return}let Ci;Qr?Qr==="*"?Ci=W4e:Ci=Qr:Ci=_;let Po=2;Ci===_?(Po=1,Ci=""):Ci===W4e&&(Po=0,Ci="");let di;if(jr?di=jr:Qr&&(di=b++),B.has(di))throw new TypeError(`Duplicate name '${di}'.`);B.add(di),h.push(new VG(Po,di,Ie(rn),Ci,Ie(br),Zi))},"V");for(;w<l.length;){let rn=q("CHAR"),jr=q("NAME"),Qr=q("REGEX");if(!jr&&!Qr&&(Qr=q("ASTERISK")),jr||Qr){let yr=rn??"";s.prefixes.indexOf(yr)===-1&&(Tt(yr),yr=""),mt();let Zi=le();hr(yr,jr,Qr,"",Zi);continue}let br=rn??q("ESCAPED_CHAR");if(br){Tt(br);continue}if(q("OPEN")){let yr=te(),Zi=q("NAME"),Ci=q("REGEX");!Zi&&!Ci&&(Ci=q("ASTERISK"));let Po=te();se("CLOSE");let di=le();hr(yr,Zi,Ci,Po,di);continue}mt(),se("END")}return h}t(K_t,"D");function $T(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t($T,"S");function W_t(a){return a&&a.ignoreCase?"ui":"u"}t(W_t,"X");function j_r(a,s,l){return Y_t(K_t(a,l),s,l)}t(j_r,"Z");function Dj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Dj,"k");function Y_t(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=$T(N.value):_+=`(?:${$T(N.value)})${Dj(N.modifier)}`;continue}s&&s.push(N.name);let B=`[^${$T(l.delimiter)}]+?`,q=N.value;if(N.type===1?q=B:N.type===0&&(q=W4e),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${q})${Dj(N.modifier)}`:_+=`((?:${q})${Dj(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${$T(N.prefix)}(${q})${$T(N.suffix)})`,_+=Dj(N.modifier);continue}_+=`(?:${$T(N.prefix)}`,_+=`((?:${q})(?:`,_+=$T(N.suffix),_+=$T(N.prefix),_+=`(?:${q}))*)${$T(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${$T(l.endsWith)}]|$`,b=`[${$T(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,W_t(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let w=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(w=l.delimiter.indexOf(N)>-1)}return w||(_+=`(?=${b}|${h})`),new RegExp(_,W_t(l))}t(Y_t,"F");var XI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},B_r={delimiter:".",prefixes:"",sensitive:!0,strict:!0},$_r={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function U_r(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(U_r,"J");function X_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(X_t,"Q");function z_r(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(z_r,"Ee");function Z_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(Z_t,"W");var Q_t=["ftp","file","http","https","ws","wss"];function ept(a){if(!a)return!0;for(let s of Q_t)if(a.test(s))return!0;return!1}t(ept,"N");function J_r(a,s){if(a=X_t(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(J_r,"te");function q_r(a,s){if(a=X_t(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(q_r,"re");function V_r(a,s){return s||a===""?a:Z_t(a)?npt(a):rpt(a)}t(V_r,"ne");function W_r(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(W_r,"se");function H_r(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(H_r,"ie");function G_r(a,s,l){if(l||a==="")return a;if(s&&!Q_t.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(G_r,"ae");function K_r(a,s,l){return tpt(s)===a&&(a=""),l||a===""?a:ipt(a)}t(K_r,"oe");function Y_r(a,s){return a=z_r(a,":"),s||a===""?a:H4e(a)}t(Y_r,"ce");function tpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(tpt,"_");function H4e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(H4e,"y");function X_r(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(X_r,"le");function Z_r(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Z_r,"fe");function rpt(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(rpt,"z");function npt(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(npt,"j");function ipt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(ipt,"K");function Q_r(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Q_r,"he");function epr(a){return a===""?a:new URL(`data:${a}`).pathname}t(epr,"ue");function tpr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(tpr,"de");function rpr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(rpr,"pe");var npr=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#p=0;#o=0;#_=0;#u=0;#c=!1;constructor(a){this.#e=a}get result(){return this.#t}parse(){for(this.#n=G_t(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#o===0){this.#h(),this.#x()?this.#i(9,1):this.#v()?this.#i(8,1):this.#i(7,0);continue}else if(this.#o===2){this.#m(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#l())this.#_-=1;else continue;if(this.#A()){this.#_+=1;continue}switch(this.#o){case 0:this.#g()&&this.#m(1);break;case 1:if(this.#g()){this.#P();let a=7,s=1;this.#y()?(a=2,s=3):this.#c&&(a=2),this.#i(a,s)}break;case 2:this.#E()?this.#m(3):(this.#w()||this.#v()||this.#x())&&this.#m(5);break;case 3:this.#T()?this.#i(4,1):this.#E()&&this.#i(5,1);break;case 4:this.#E()&&this.#i(5,1);break;case 5:this.#O()?this.#u+=1:this.#k()&&(this.#u-=1),this.#C()&&!this.#u?this.#i(6,1):this.#w()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 6:this.#w()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 7:this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 8:this.#x()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#i(a,s){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#D();break;case 2:break;case 3:this.#t.username=this.#D();break;case 4:this.#t.password=this.#D();break;case 5:this.#t.hostname=this.#D();break;case 6:this.#t.port=this.#D();break;case 7:this.#t.pathname=this.#D();break;case 8:this.#t.search=this.#D();break;case 9:this.#t.hash=this.#D();break;case 10:break}this.#o!==0&&a!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(a)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(a)&&(this.#t.pathname??=this.#c?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&a===9&&(this.#t.search??="")),this.#a(a,s)}#a(a,s){this.#o=a,this.#p=this.#r+s,this.#r+=s,this.#s=0}#h(){this.#r=this.#p,this.#s=0}#m(a){this.#h(),this.#o=a}#f(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#d(a,s){let l=this.#f(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#d(this.#r,":")}#y(){return this.#d(this.#r+1,"/")&&this.#d(this.#r+2,"/")}#E(){return this.#d(this.#r,"@")}#T(){return this.#d(this.#r,":")}#C(){return this.#d(this.#r,":")}#w(){return this.#d(this.#r,"/")}#v(){if(this.#d(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let a=this.#f(this.#r-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#x(){return this.#d(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#d(this.#r,"[")}#k(){return this.#d(this.#r,"]")}#D(){let a=this.#n[this.#r],s=this.#f(this.#p).index;return this.#e.substring(s,a.index)}#P(){let a={};Object.assign(a,XI),a.encodePart=H4e;let s=j_r(this.#D(),void 0,a);this.#c=ept(s)}},V4e=["protocol","username","password","hostname","port","pathname","search","hash"],YI="*";function H_t(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(H_t,"ge");function LA(a,s){return s?qG(a):a}t(LA,"b");function JG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=LA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=LA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=LA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=LA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=LA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=LA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=LA(_.search.substring(1,_.search.length),l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=LA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Y_r(s.protocol,l)),typeof s.username=="string"&&(a.username=H_r(s.username,l)),typeof s.password=="string"&&(a.password=W_r(s.password,l)),typeof s.hostname=="string"&&(a.hostname=V_r(s.hostname,l)),typeof s.port=="string"&&(a.port=K_r(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!U_r(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=LA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=G_r(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=q_r(s.search,l)),typeof s.hash=="string"&&(a.hash=J_r(s.hash,l)),a}t(JG,"w");function qG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(qG,"C");function ipr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(ipr,"Oe");function spr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${ipr(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let w=0;w<a.length;++w){let N=a[w];if(N.type===3){if(N.modifier===3){b+=qG(N.value);continue}b+=`{${qG(N.value)}}${Dj(N.modifier)}`;continue}let B=N.hasCustomName(),q=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),le=w>0?a[w-1]:null,se=w<a.length-1?a[w+1]:null;if(!q&&B&&N.type===1&&N.modifier===3&&se&&!se.prefix.length&&!se.suffix.length)if(se.type===3){let te=se.value.length>0?se.value[0]:"";q=h.test(te)}else q=!se.hasCustomName();if(!q&&!N.prefix.length&&le&&le.type===3){let te=le.value[le.value.length-1];q=s.prefixes.includes(te)}q&&(b+="{"),b+=qG(N.prefix),B&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?B||(b+=`(${_})`):N.type===0&&(!B&&(!le||le.type===3||le.modifier!==3||q||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&B&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=qG(N.suffix),q&&(b+="}"),N.modifier!==3&&(b+=Dj(N.modifier))}return b}t(spr,"ke");var spt=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new npr(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:YI,protocol:YI,username:YI,password:YI,hostname:YI,port:YI,search:YI,hash:YI};this.#e=JG(b,a,!0),tpt(this.#e.protocol)===this.#e.port&&(this.#e.port="");let w;for(w of V4e){if(!(w in this.#e))continue;let N={},B=this.#e[w];switch(this.#t[w]=[],w){case"protocol":Object.assign(N,XI),N.encodePart=H4e;break;case"username":Object.assign(N,XI),N.encodePart=X_r;break;case"password":Object.assign(N,XI),N.encodePart=Z_r;break;case"hostname":Object.assign(N,B_r),Z_t(B)?N.encodePart=npt:N.encodePart=rpt;break;case"port":Object.assign(N,XI),N.encodePart=ipt;break;case"pathname":ept(this.#n.protocol)?(Object.assign(N,$_r,h),N.encodePart=Q_r):(Object.assign(N,XI,h),N.encodePart=epr);break;case"search":Object.assign(N,XI,h),N.encodePart=tpr;break;case"hash":Object.assign(N,XI,h),N.encodePart=rpr;break}try{this.#s[w]=K_t(B,N),this.#n[w]=Y_t(this.#s[w],this.#t[w],N),this.#r[w]=spr(this.#s[w],N),this.#p=this.#p||this.#s[w].some(q=>q.type===2)}catch{throw new TypeError(`invalid ${w} pattern '${this.#e[w]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?l=JG(l,a,!1):l=JG(l,H_t(a,s),!1)}catch{return!1}let _;for(_ of V4e)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?l=JG(l,a,!1):l=JG(l,H_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of V4e){let b=this.#n[h].exec(l[h]);if(!b)return null;let w={};for(let[N,B]of this.#t[h].entries())if(typeof B=="string"||typeof B=="number"){let q=b[N+1];w[B]=q}_[h]={input:l[h]??"",groups:w}}return _}static compareComponent(a,s,l){let _=t((N,B)=>{for(let q of["type","modifier","prefix","value","suffix"]){if(N[q]<B[q])return-1;if(N[q]!==B[q])return 1}return 0},"o"),h=new VG(3,"","","","",3),b=new VG(0,"","","","",3),w=t((N,B)=>{let q=0;for(;q<Math.min(N.length,B.length);++q){let le=_(N[q],B[q]);if(le)return le}return N.length===B.length?0:_(N[q]??h,B[q]??h)},"s");return!s.#r[a]&&!l.#r[a]?0:s.#r[a]&&!l.#r[a]?w(s.#s[a],[b]):!s.#r[a]&&l.#r[a]?w([b],l.#s[a]):w(s.#s[a],l.#s[a])}get protocol(){return this.#r.protocol}get username(){return this.#r.username}get password(){return this.#r.password}get hostname(){return this.#r.hostname}get port(){return this.#r.port}get pathname(){return this.#r.pathname}get search(){return this.#r.search}get hash(){return this.#r.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=spt);import{AssertionError as apr}from"node:assert";function RA(a,s){if(a===!1)throw new apr({message:s})}t(RA,"assert");var Zo;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(Zo||(Zo={}));function Pj(a){return a.type===Zo.Object}t(Pj,"isAstObject");function MA(a){return a.type===Zo.Property}t(MA,"isAstProperty");function apt(a){return a.type===Zo.Array}t(apt,"isAstArray");function Aj(a){return a.type===Zo.Literal}t(Aj,"isAstLiteral");function ZI(a){if(a===void 0)throw new Error("Node is undefined");if(!Pj(a))throw new Error("Node is not object")}t(ZI,"assertAstObject");import{findNodeAtLocation as opr,getNodeValue as cpr,printParseErrorCode as lpr,visit as upr}from"jsonc-parser";var fpr={DEFAULT:{allowTrailingComma:!1}};function WG(a,s=[],l=fpr.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(B){_.type==="property"&&(_.length=B-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(B){return _.children?.push(B),B}t(b,"onValue"),upr(a,{onObjectBegin:t((B,q,le)=>{_=b({type:"object",offset:B,length:-1,line:q+1,column:le+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((B,q,le,se,te)=>{_=b({type:"property",offset:q,length:-1,line:se+1,column:te+1,parent:_,children:[]}),_.children?.push({type:"string",value:B,offset:q,length:le,line:se,column:te,parent:_})},"onObjectProperty"),onObjectEnd:t((B,q)=>{h(B+q),_.length=B+q-_.offset,_=_.parent,h(B+q)},"onObjectEnd"),onArrayBegin:t((B,q,le,se)=>{_=b({type:"array",offset:B,length:-1,line:le+1,column:se+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((B,q)=>{_.length=B+q-_.offset,_=_.parent,h(B+q)},"onArrayEnd"),onLiteralValue:t((B,q,le,se,te)=>{b({type:_pr(B),offset:q,length:le,line:se+1,column:te+1,parent:_,value:B}),h(q+le)},"onLiteralValue"),onSeparator:t((B,q)=>{_.type==="property"&&(B===":"?_.colonOffset=q:B===","&&h(q))},"onSeparator"),onError:t((B,q,le,se,te)=>{s.push({error:B,offset:q,length:le,line:se+1,column:te+1})},"onError")},l);let N=_.children[0];return N&&delete N.parent,N}t(WG,"parse");function _pr(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(_pr,"getNodeType");function G4e(a,s){return opr(a,s)}t(G4e,"findNodeAtLocation");function HG(a){return cpr(a)}t(HG,"getNodeValue");function opt(a){return lpr(a)}t(opt,"printParseErrorCode");var GG=class{static{t(this,"AstAdapter")}parse(s){let _=WG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:Zo.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:Zo.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){RA(s.children?.length===2,"Invalid property node");let _={type:Zo.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Zo.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:Zo.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var UT={createLiteral:t((a,s)=>({type:Zo.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Zo.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Zo.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:Zo.Property,parent:l,name:null,value:s};return _.name={value:a,type:Zo.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:Zo.Array,parent:s,children:[]};for(let _ of a)l.children.push(UT.createLiteral(_,l));return l},"createArrayOfLiterals")};var ppr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,KG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case Zo.Array:return this.generateArray(s,l);case Zo.Object:return this.generateObject(s,l);case Zo.Property:return this.generateProperty(s,l);case Zo.Literal:return this.generateLiteral(s,l);case Zo.FunctionCall:return this.generateFunctionCall(s,l);case Zo.Identifier:return this.generateIdentifier(s,l);case Zo.Raw:return this.generateRaw(s,l);case Zo.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=ppr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import dpr from"node:fs/promises";import{parse as mpr}from"@swc/core";var cpt=t(async a=>{let s=new Set;try{let l=await dpr.readFile(a,"utf-8");(await mpr(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var lpt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var K4e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var upt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var Y4e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var X4e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var xht=Rd(Wmt(),1),Eht=Rd(Tht(),1);var jfe=class a{static{t(this,"JsonValidator")}static#e=new a;static get instance(){return a.#e}ajv;constructor(){this.ajv=new Eht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,xht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},w=h.instancePath.split("/");if(w.length>2){let B=w[1],q=w[2]?parseInt(w[2]):0,le=w[3],se=isNaN(q)?void 0:l[B][q][le];b={details:{property:B,index:q,field:le,fieldValue:se}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let B=h.instancePath.split("/"),q=B[B.length-1];h.message=`Value of property '${q}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var c4=jfe.instance;c4.addSchema(X4e,"route-configuration.schema.json");c4.addSchema(upt,"policy-configuration.schema.json");c4.addSchema(K4e,"policies.schema.json");c4.addSchema(Y4e,"open-api-route-configuration.schema.json");c4.addSchema(lpt,"fragments.schema.json");var z$r=c4.compile(X4e),Cht=c4.compile(Y4e),_8e=c4.compile(K4e);var Bfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=_8e(s),this.results}};var $fe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Cht(s),this.results}};import T1r from"node:path";var p8e=/\$import\((.*)\)/,Ufe=/\$env\((.*?)\)/g;var zA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},S1r=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),l4=t((a,s)=>{if(!a)return!1;let l=S1r(a);return s.split("/").every((b,w)=>{let N=l[w];return N?b==="*"||MA(N)&&N.name.value===b?!0:b==="{}"?N.type===Zo.Object:b==="[]"?N.type===Zo.Array:!1:!1})},"testPosition");var zfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),Pj(s)?s.children.forEach(l=>{this.visitor(l)}):apt(s)?s.children.forEach(l=>{this.visitor(l)}):MA(s)&&this.visitor(s.value)}},wht=t((a,s,l)=>_=>{if(!MA(_)||!Aj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>l4(_,b))){Ufe.test(_.value.value)&&s.push(new zA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(Ufe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:Zo.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(Ufe),(w,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=UT.createTemplateString(b,_))}},"getEnvStatementTransformer");var DK="config/routes.json",x1r=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],E1r=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],kht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],C1r="handler/{}/options/{}/rewritePattern",w1r="handler/{}/options/{}/baseUrl",Jfe=class extends zfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!MA(s)||!Aj(s.value)||typeof s.value.value!="string")&&l4(s,C1r)){if(!s.parent||!Pj(s.parent)){this.errors.push(new zA("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Zo.Raw,parent:null,value:Dht(l)},h=UT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!MA(s)||!Aj(s.value)||typeof s.value.value!="string")&&l4(s,w1r)){if(!s.parent||!Pj(s.parent)){this.errors.push(new zA("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Zo.Raw,parent:null,value:Dht(l)},h=UT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!MA(s)||!Aj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!E1r.some(N=>l4(s,N))&&!kht.some(N=>l4(s,N))){if(p8e.test(l)){if(s.name.value==="$ref")return;this.errors.push(new zA("An $import() statement is not expected at this location.",DK,s.location,l))}return}let _=p8e.exec(l);if(kht.some(N=>l4(s,N))&&!_)return;if(!_){this.errors.push(new zA("Invalid $import() statement",DK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=T1r.posix.join("..",h));let b=this.getImportName(h),w={type:Zo.Identifier,parent:s.parent,value:b};s.value=w}replaceEnvStatements=wht(x1r,this.errors,DK)};function Dht(a){return`(request, context) => {
|
|
581
|
+
`),exitCode:b},"Untar process logs")}}t(Llr,"untarFile");async function Rlr(a){if(await r4e(a))return await VI.rm(a,{recursive:!0})}t(Rlr,"deleteFolder");var ou=n4e;var MT=Rd(t4e(),1);var S7=class extends Error{static{t(this,"CustomResolveError")}},WI=class{static{t(this,"RefParser")}sourceDirectory;logger;constructor(s,l){this.sourceDirectory=s,this.logger=l}dereference(s,l){return PG.$RefParser.dereference(s,{resolve:{json:!0,file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1},dereference:{circular:"ignore",onDereference:l?.onDereference}})}bundle(s){return PG.$RefParser.bundle(s,{resolve:{file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1}})}parse(s){return PG.$RefParser.parse(s,{resolve:{file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1}})}resolve(s){return PG.$RefParser.resolve(s,{resolve:{file:Tue(this.sourceDirectory,this.logger),external:!0,http:!1}})}};function Tue(a,s){return{order:100,canRead(l){let _=$lr(l.url);if(!(_===void 0||_==="file"))return!1;let b;try{b=cft(l.url)}catch(w){throw new S7(`Malformed URI: ${l.url}`,{cause:w})}try{ou.safePath(a).resolve(b)}catch(w){return s?.warn(w),!1}return!0},async read(l){let _;try{_=cft(l.url)}catch(h){throw new S7(`Malformed URI: ${l.url}`,{cause:h})}try{return await Mlr(_)}catch(h){throw new S7(`Error opening file "${_}"`,{cause:h})}}}}t(Tue,"customResolver");var bj=/^win/.test(globalThis.process?globalThis.process.platform:""),jlr=/\//g,Blr=/^(\w{2,}):\/\//i,i4e=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"];function $lr(a){let s=Blr.exec(a);if(s)return s[1].toLowerCase()}t($lr,"getProtocol");function cft(a,s){a=decodeURI(a);for(let _=0;_<i4e.length;_+=2)a=a.replace(i4e[_],i4e[_+1]);let l=a.substr(0,7).toLowerCase()==="file://";if(l&&(a=a[7]==="/"?a.substr(8):a.substr(7),bj&&a[1]==="/"&&(a=`${a[0]}:${a.substr(1)}`),s?a=`file:///${a}`:(l=!1,a=bj?a:`/${a}`)),!l){let _=a.split(bj?"\\":"/"),h=[];for(let b of _)b===".."?h.length&&h[h.length-1]!==""&&h.pop():(b!==""||h.length===0)&&h.push(b);a=h.join(bj?"\\":"/"),!bj&&h[0]===""&&(a=`/${a.substring(1)}`)}return bj&&!l&&(a=a.replace(jlr,"\\"),a.substr(1,2)===":\\"&&(a=a[0].toUpperCase()+a.substr(1))),a}t(cft,"toFileSystemPath");var lft="YOUR_KEY_HERE";async function uft(a){let l=await new WI(a.sourceDirectory,a.logger).bundle(a.openApiDocPath),_=a.openApiDocPath.replace(a.sourceDirectory,"");return Ulr({...a,relativeOpenApiPath:_},l)}t(uft,"buildPublicOpenApiFile");async function Ulr(a,s){Vlr({relativeOpenApiPath:a.relativeOpenApiPath},s);let l=s;return l=Jlr(l),zlr(l,a.urls?.api?.defaultUrl),l=qlr(l,a),fft(l,"x-zuplo"),l}t(Ulr,"buildRawOpenApiFile");function zlr(a,s){s?a.servers=[{url:s}]:a.servers=[]}t(zlr,"addServerHost");function Jlr(a){if(!a.paths)return a;let{components:s}=a,l=s?{...s}:void 0,_=[];l&&l.parameters&&(_=Object.entries(l.parameters).reduce((b,[w,N])=>(VM in N&&dle(N[VM])&&(b.push(w),l.parameters&&delete l.parameters[w]),b),[]));let h=Object.entries(a.paths).reduce((b,[w,N])=>{if(!N)return b;let B={...N},q=["delete","get","head","patch","post","put","trace","options"];return q.forEach(le=>{let se=N[le];if(!se)return;if(dle(se[VM])){delete B[le];return}let{parameters:te}=se;if(!te)return;let Ue=te.filter(Ie=>{if(VM in Ie&&dle(Ie[VM]))return!1;if("$ref"in Ie){let De=Ie.$ref.split("/").pop();return De?!_.includes(De):!0}return!0});B[le]={...se,parameters:Ue}}),q.some(le=>!!B[le])&&(b[w]=B),b},{});return{...a,paths:h,components:l}}t(Jlr,"removeHiddenRoutesAndParams");function qlr(a,{policiesConfig:s}){if(!a.paths)return a;let l=Object.entries(a.paths).reduce((_,[h,b])=>{if(!b)return _;let w={...b};return[w.delete,w.get,w.head,w.patch,w.post,w.put,w.trace,w.options].forEach(N=>{if(!N)return;let B=N["x-zuplo-route"]?.policies?.inbound?.reduce((se,te)=>{let Ue=s.policies?.find(({name:Tt})=>Tt===te);if(!Ue)return se;if(!(Ue.handler.export==="CompositeInboundPolicy"))return se.concat(te);let De=Ue.handler.options?.policies;return De?se.concat(De):se},[]),q=[];if(B&&B.forEach(se=>{s.policies?.forEach(te=>{te.name===se&&(te.handler.export==="ApiAuthKeyInboundPolicy"||te.handler.export==="ApiKeyInboundPolicy")&&!te.handler.options?.disableAutomaticallyAddingKeyHeaderToOpenApi&&q.push(te)})}),q.length>0){let se=q.length>0&&q[0].handler&&q[0].handler.options&&q[0].handler.options.authHeader?q[0].handler.options.authHeader:"Authorization",te=q.length>0&&q[0].handler&&q[0].handler.options&&(q[0].handler.options.authScheme||q[0].handler.options.authScheme==="")?q[0].handler.options.authScheme:"Bearer",Ue=te!==""?`${te} ${lft}`:lft,Ie={name:se,in:"header",required:!0,example:Ue,schema:{type:"string"},description:`The \`${se}\` header is used to authenticate with the API using your API key. Value is of the format \`${Ue}\`.`};N.parameters?N.parameters.some(hr=>"name"in hr&&hr.name===Ie.name)||N.parameters.unshift(Ie):N.parameters=[Ie];let De={type:"http",scheme:te.toLowerCase()},Tt="api_key";a.components?.securitySchemes?Object.values(a.components?.securitySchemes).some(hr=>"name"in hr&&hr.type==="apiKey"||"type"in hr&&hr.type==="http"&&hr.scheme===te)||(a.components.securitySchemes={...a.components.securitySchemes,[Tt]:De}):(a.components||(a.components={}),a.components.securitySchemes={[Tt]:De});let mt={[Tt]:[]};N.security?N.security.some(hr=>hr[Tt]!==void 0)||N.security.unshift(mt):N.security=[mt]}let le=[];if(B&&B.forEach(se=>{s.policies?.forEach(te=>{te.name===se&&(te.handler.export==="RateLimitInboundPolicy"||te.handler.export==="ComplexRateLimitInboundPolicy")&&le.push(te)})}),le.length>0){let se={description:"Rate Limiting Response",content:{"application/json":{schema:{type:"object",required:["type","title","status"],examples:[{type:"https://httpproblems.com/http-status/429",title:"Too Many Requests",status:429,instance:"/foo/bar"}],properties:{type:{type:"string",example:"https://httpproblems.com/http-status/429",description:"A URI reference that identifies the problem."},title:{type:"string",example:"Too Many Requests",description:"A short, human-readable summary of the problem."},status:{type:"number",example:429,description:"The HTTP status code."},instance:{type:"string",example:"/foo/bar"}}}}}},te={...se,headers:{"retry-after":{description:"The number of seconds to wait before making a new request.",schema:{type:"integer",example:60}}}};a.components?.responses||a.components||(a.components={}),a.components.responses={...a.components.responses,RateLimitNoRetryAfter:se,RateLimitWithRetryAfter:te},N.responses||(N.responses={});let Ue=le.some(Ie=>Ie.handler.options?.headerMode!=="none");N.responses[429]||(N.responses[429]={$ref:Ue?"#/components/responses/RateLimitWithRetryAfter":"#/components/responses/RateLimitNoRetryAfter"})}}),_[h]=w,_},{});return{...a,paths:l}}t(qlr,"enrichSpecWithZuploData");function fft(a,s){for(let l in a)l.startsWith(s)?delete a[l]:typeof a[l]=="object"&&fft(a[l],s)}t(fft,"removePropertiesByPrefix");function Vlr({relativeOpenApiPath:a},s){if(!s||typeof s!="object")throw new G1({message:"The OpenAPI Document could not be parsed.",severity:"error"});if(!("info"in s)||typeof s.info!="object"||!s.info)throw new G1({message:"The OpenAPI document does not have the required 'info' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"});if(!("title"in s.info)||typeof s.info.title!="string")throw new G1({message:"The OpenAPI document does not have the required 'info.title' property.",location:{file:a,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:"Add the required 'info.title' property. https://spec.openapis.org/oas/v3.1.0#info-object"},severity:"error"})}t(Vlr,"assertIsZuploOpenApiSpec");import PK from"node:path";function Wlr(a){if(a.length>=255)throw new TypeError("Alphabet too long");let s=new Uint8Array(256);for(let q=0;q<s.length;q++)s[q]=255;for(let q=0;q<a.length;q++){let le=a.charAt(q),se=le.charCodeAt(0);if(s[se]!==255)throw new TypeError(le+" is ambiguous");s[se]=q}let l=a.length,_=a.charAt(0),h=Math.log(l)/Math.log(256),b=Math.log(256)/Math.log(l);function w(q){if(q instanceof Uint8Array||(ArrayBuffer.isView(q)?q=new Uint8Array(q.buffer,q.byteOffset,q.byteLength):Array.isArray(q)&&(q=Uint8Array.from(q))),!(q instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(q.length===0)return"";let le=0,se=0,te=0,Ue=q.length;for(;te!==Ue&&q[te]===0;)te++,le++;let Ie=(Ue-te)*b+1>>>0,De=new Uint8Array(Ie);for(;te!==Ue;){let hr=q[te],rn=0;for(let jr=Ie-1;(hr!==0||rn<se)&&jr!==-1;jr--,rn++)hr+=256*De[jr]>>>0,De[jr]=hr%l>>>0,hr=hr/l>>>0;if(hr!==0)throw new Error("Non-zero carry");se=rn,te++}let Tt=Ie-se;for(;Tt!==Ie&&De[Tt]===0;)Tt++;let mt=_.repeat(le);for(;Tt<Ie;++Tt)mt+=a.charAt(De[Tt]);return mt}t(w,"encode");function N(q){if(typeof q!="string")throw new TypeError("Expected String");if(q.length===0)return new Uint8Array;let le=0,se=0,te=0;for(;q[le]===_;)se++,le++;let Ue=(q.length-le)*h+1>>>0,Ie=new Uint8Array(Ue);for(;q[le];){let hr=s[q.charCodeAt(le)];if(hr===255)return;let rn=0;for(let jr=Ue-1;(hr!==0||rn<te)&&jr!==-1;jr--,rn++)hr+=l*Ie[jr]>>>0,Ie[jr]=hr%256>>>0,hr=hr/256>>>0;if(hr!==0)throw new Error("Non-zero carry");te=rn,le++}let De=Ue-te;for(;De!==Ue&&Ie[De]===0;)De++;let Tt=new Uint8Array(se+(Ue-De)),mt=se;for(;De!==Ue;)Tt[mt++]=Ie[De++];return Tt}t(N,"decodeUnsafe");function B(q){let le=N(q);if(le)return le;throw new Error("Non-base"+l+" character")}return t(B,"decode"),{encode:w,decodeUnsafe:N,decode:B}}t(Wlr,"base");var _ft=Wlr;var Hlr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",xue=_ft(Hlr);var Glr=!1;function Sj(a,s){return{open:`\x1B[${a.join(";")}m`,close:`\x1B[${s}m`,regexp:new RegExp(`\\x1b\\[${s}m`,"g")}}t(Sj,"code");function Tj(a,s){return Glr?`${s.open}${a.replace(s.regexp,s.open)}${s.close}`:a}t(Tj,"run");function Klr(a){return Tj(a,Sj([31],39))}t(Klr,"red");function Ylr(a){return Tj(a,Sj([32],39))}t(Ylr,"green");function Xlr(a){return Tj(a,Sj([33],39))}t(Xlr,"yellow");function Zlr(a){return Tj(a,Sj([34],39))}t(Zlr,"blue");function Qlr(a){return Tj(a,Sj([35],39))}t(Qlr,"magenta");function eur(a){return Tj(a,Sj([36],39))}t(eur,"cyan");var bRr=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|"),"g");var pft=[Klr,Ylr,Xlr,Zlr,Qlr,eur];function tur(a){let s=0,l=a.length,_=0;if(l>0)for(;_<l;)s=(s<<5)-s+a.charCodeAt(_++)|0;return s}t(tur,"hashCode");function dft(a){let s=Math.abs(tur(a));return pft[s%pft.length]}t(dft,"generateColor");import{inspect as rur}from"node:util";function mft(a,s,...l){let _=0,h=l.length,b=String(s).replace(/%[sdjoO%]/g,w=>{if(w==="%%")return"%";if(_>=h)return w;switch(w){case"%s":return String(l[_++]);case"%d":return Number(l[_++]).toString();case"%o":return a(l[_++]).split(`
|
|
582
|
+
`).map(N=>N.trim()).join(" ");case"%O":return a(l[_++]);case"%j":try{return JSON.stringify(l[_++])}catch{return"[Circular]"}default:return w}});for(let w of l.splice(_))w===null||!(typeof w=="object"&&w!==null)?b+=" "+w:b+=" "+a(w);return b}t(mft,"format");var hft=t((a,...s)=>mft(rur,a,s),"format");var s4e=class{static{t(this,"Debugger")}manager;ns;color;last;enabled;constructor(s,l){this.manager=s,this.ns=l,this.color=dft(l),this.last=0,this.enabled=s.enabled.some(_=>_.test(l))}log(...s){if(!this.enabled)return;let l,_=s[0];typeof _=="function"?l=_():l=String(_);let h=Date.now()-(this.last||Date.now());l=hft(l,...s);let b=`${this.color(this.ns)} ${l} ${this.color(`+${h}ms`)}`;console.log(b),this.last=Date.now()}},a4e=class{static{t(this,"DebugManager")}debuggers;enabled;constructor(s){this.debuggers=new Map,this.enabled=s??[]}};function nur(a){return!a||a.length===0?[]:(a=a.replace(/\s/g,"").replace(/\*/g,".+"),a.split(",").map(s=>new RegExp(`^${s}$`)))}t(nur,"extract");var Eue;function Cue(a){Eue||(Eue=new a4e(nur(process.env.DEBUG)));let s=new s4e(Eue,a);return Eue.debuggers.set(a,s),Object.assign(s.log.bind(s),{self:s})}t(Cue,"debug");var AA=class extends Error{static{t(this,"RuntimeError")}extensionMembers;constructor(s,l){typeof s=="string"?super(s,l):(super(s.message,l),this.extensionMembers=s.extensionMembers),this.name="RuntimeError"}};var gft="zp-local-service";var RRr=Symbol("zuplo_meters"),MRr=Symbol("zuplo_dynamic_meters");var HI=Cue("zuplo:runtime:external-service");function iur(){let a,{__ZUPLO_EXTERNAL_SERVICE_TOKEN:s}=j0.instance.runtime;if(s&&s!=="undefined")try{let l=atob(s);a=JSON.parse(l)}catch{}return a}t(iur,"getServiceAuth");async function yft(a,s){let l=".proxy",_=".tunnel";if(typeof a=="string"){let h=new URL(a),b=h.hostname;if(b.endsWith(l)){let Tt=b.slice(0,-l.length),mt=new URL(`http://${Tt}${h.pathname}${h.search}`);HI(`Routing to proxy: ${mt.toString()}`);let hr=s??{};return xj(mt.toString(),hr)}let w=b.endsWith(_),N=b.indexOf(".")===-1;if(!(w||N))throw new AA(`Invalid service hostname suffix: ${b}. Use .proxy for proxy routing, .tunnel for explicit tunnel routing, or no suffix for default tunnel routing.`);let q=w?b.slice(0,-_.length):b,le=iur();if(!le)throw HI("There is no external service auth configured for this zup."),new AA("There are no external services configured for this zup.");HI(`Using external service auth. ClientId: ${le.clientId})`);let se=s??{},te=new Headers(se.headers||{});te.set("CF-Access-Client-Id",le.clientId),te.set("CF-Access-Client-Secret",le.clientSecret),se.headers=te;let Ue;if(le.customServiceMapping?.[q])Ue=`https://${le.customServiceMapping[q]}`;else if(j0.instance.useLegacyServiceRouting)Ue=`https://${q}.zuptunnel.com`;else{HI("Using sha256 service routing");let Tt=j0.instance.build;if(Tt.ACCOUNT_NAME&&Tt.PROJECT_NAME&&Tt.ENVIRONMENT_TYPE){let mt=await sur(q,Tt.ACCOUNT_NAME,Tt.PROJECT_NAME,Tt.ENVIRONMENT_TYPE),hr=bft(Tt.ENVIRONMENT_TYPE),rn=await o4e(`${Tt.ACCOUNT_NAME}-${Tt.PROJECT_NAME}-${hr}`);rn==="40d7ad502f5d743997999594c177184a00161a77865423511f3a1ea21eb5a5e"||rn==="d05bffe8fa91a300187d2cf43e8aa4a56bd809c442ae10d1ee49af7d29a5a11"?Ue=`https://${mt}.zuptunnel.com`:Ue=`https://${mt}.t.zuplo.app`}else throw HI("Cannot use sha256 service routing, missing build variables"),new AA("Failed to generate fully qualified tunnel url.")}let Ie=new URL(`${Ue}${h.pathname}${h.search}`);HI(`Calling external service: ${Ie.toString()}`);let De=await xj(Ie.toString(),se);if(De.status===403&&De.headers.get("cf-access-domain")!==null)throw AG.console.error("403 Forbidden when calling external service.",{clientId:le.clientId,tunnelHost:Ue}),new AA("Could not connect to secure tunnel.");return De}else throw HI("Cannot call external service with Request object"),new AA("Currently, we only support fetch(<some_string>, ...).")}t(yft,"externalServiceHandler");async function vft(a,s){if(typeof a=="string"){let l=new URL(a),_=l.hostname,h=s??{},b=`http://${_}.zuplo.svc.cluster.local:9000`,w=new URL(`${b}${l.pathname}${l.search}`),N=new Headers(h.headers||{});return N.set(gft,_),h.headers=N,await xj(w.toString(),h)}else throw new AA("Currently, we only support fetch(<some_string>, ...).")}t(vft,"clusterServiceHandler");async function sur(a,s,l,_){let h=a.toLowerCase(),b=s.toLowerCase(),w=l.toLowerCase(),N=bft(_);HI(`Hashing service name: ${b}-${h}.${b}-${w}-${N}`);let B=await o4e(`${b}-${h}`),q=await o4e(`${b}-${w}-${N}`);return`${B}.${q}`}t(sur,"hashServiceName");async function o4e(a){let s=new TextEncoder().encode(a),l=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(l)).map(b=>b.toString(16).padStart(2,"0")).join("").slice(0,-1)}t(o4e,"hashSegment");function bft(a){let s=a.toLowerCase();switch(s){case"production":case"preview":return s;default:return"working-copy"}}t(bft,"sanitizeEnvironmentType");var c4e=new Map;c4e.set("service:",yft);c4e.set("local:",vft);var xj=globalThis.fetch;function l4e(a,s){let l=aur(s);if(typeof a=="string"){let _=new URL(a),h=c4e.get(_.protocol);return h?h(a,l):xj(a,l)}else return xj(a,l)}t(l4e,"internalFetch");globalThis.fetch=l4e;var aur=t(a=>{if(!a||a instanceof Request)return a;let s=a;if(!s.zuplo)return a;let l=a;return l.cf={cacheEverything:s.zuplo?.cacheEverything,cacheTtl:s.zuplo?.cacheTtlSeconds},delete a.zuplo,a},"transformInit");var our={console:{log:console.log.bind(console),info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:console.debug.bind(console),assert:console.assert.bind(console),clear:console.clear.bind(console),count:console.count.bind(console),countReset:console.countReset.bind(console),dir:console.dir.bind(console),dirxml:console.dirxml.bind(console),group:console.group.bind(console),groupCollapsed:console.groupCollapsed.bind(console),groupEnd:console.groupEnd.bind(console),table:console.table.bind(console),time:console.time.bind(console),timeEnd:console.timeEnd.bind(console),timeLog:console.timeLog.bind(console),timeStamp:console.timeStamp.bind(console),trace:console.trace.bind(console),profile:console.profile.bind(console),profileEnd:console.profileEnd.bind(console)},fetch:l4e},AG=our;var u4e="2025-02-06",Sft=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!1,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2024-09-02":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!1,useForwardRedirectsPropOnUrlForwardHandler:!1},"2025-02-06":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0,allowCustomPorts:!0,removeLegacyLogInitialization:!0,useForwardRedirectsPropOnUrlForwardHandler:!0}});function Tft(){return new j0({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:u4e,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,IS_LOCAL_DEVELOPMENT:!1,COMPATIBILITY_FLAGS:Sft[u4e]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:"",ZUPLO_SERVICE_BUCKET_ID:"mock-bucket-id"}})}t(Tft,"getMockEnvironment");var j0=class a{static{t(this,"Environment")}config;static#e;static#n=!1;static initialize(s){a.#e||(a.#e=new a(s),a.#n=!0)}static get instance(){return a.#n||(AG.console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),a.#e=Tft()),a.#e}constructor({build:s,runtime:l}){let _;try{if(l.ZUPLO_SYSTEM_CONFIGURATIONS){let h=new TextDecoder().decode(xue.decode(l.ZUPLO_SYSTEM_CONFIGURATIONS)),b=JSON.parse(h);for(let w of Object.keys(b))l[w]||(l[w]=b[w])}if(l.__ZUPLO_CONFIG){let h=atob(l.__ZUPLO_CONFIG);_=JSON.parse(h)}}catch(h){AG.console.error("Failed to parse runtime configuration",h)}this.config=_??{},this.build=s,this.runtime=l,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useLegacyServiceRouting(){return this.config.use_legacy_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get zuploEdgeApiUrl(){return this.config.zuplo_edge_api_url??"https://api.zuploedge.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get zuploClientAuthBucketId(){return this.config.zuplo_auth_client_bucket_id??"auth_o8PUdhKxSTOiB794GWPwLQCD"}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get developerApiUrl(){return this.config.developer_api_url??"https://dev.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuploedge.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuploedge.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuploedge.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuploedge.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get authClientId(){return this.config.auth_client_id??this.runtime.__ZUPLO_AUTH_CLIENT_ID}get authClientSecret(){return this.config.auth_client_secret??this.runtime.__ZUPLO_AUTH_CLIENT_SECRET}get authPublicKey(){return this.config.auth_public_key??this.runtime.__ZUPLO_AUTH_PUBLIC_KEY}get authPrivateKey(){return this.config.auth_private_key??this.runtime.__ZUPLO_AUTH_PRIVATE_KEY}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isManagedDedicated(){return this.runtime.__ZUPLO_IS_MANAGED_DEDICATED==="true"}get isDeno(){if(this.runtime.__ZUPLO_RUNTIME_TYPE)return this.runtime.__ZUPLO_RUNTIME_TYPE==="deno";if(this.config.runtime_type)return this.config.runtime_type==="deno";{let s=globalThis.Deno?.version?.deno;return typeof WebSocketPair!="function"&&s}}get isLocalDevelopment(){return this.build.IS_LOCAL_DEVELOPMENT}get isTestMode(){return!!this.runtime.__ZUPLO_TEST_MODE}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}get rateLimitServiceTimeoutMs(){let s=this.runtime.__ZUPLO_RATE_LIMIT_TIMEOUT_MS,l=this.config.rate_limit_service_timeout_ms,_=s??l;if(!_)return 500;let h=Number(_);return Number.isFinite(h)&&h>0?h:500}};var cur=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function xft(a){return a.startsWith("__ZUPLO")||a.startsWith("ZUPLO_")?!cur.includes(a)&&!a.startsWith("ZUPLO_PUBLIC_"):a.startsWith("ZUDOKU_")?!a.startsWith("ZUDOKU_PUBLIC_"):!1}t(xft,"isRestrictedEnvVariableName");function Eft(a){return!!a.startsWith("ZUPLO_")}t(Eft,"isZuploReadableEnvVariableName");var l9r=new Proxy({},{get(a,s){let l=String(s);switch(l){case"ZUPLO_ENVIRONMENT_TYPE":return j0.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return j0.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return j0.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return j0.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return j0.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return j0.instance.build.BUILD_ID;case"ZUPLO_COMPATIBILITY_DATE":return j0.instance.build.COMPATIBILITY_DATE}if(!(xft(l)&&!Eft(l)))return j0.instance.runtime[l]}});function NG(a,s,l){return`_${NA(`${a}_${s}_${l}`)}`}t(NG,"getRawOperationDataIdentifierName");function f4e(a,s,l,_){return`_${NA(a.toLowerCase())}_${s.toLowerCase()}_${l.toLowerCase()}_${_.toLowerCase()}`}t(f4e,"getIdForParameterSchema");function _4e(a,s,l){return`_${NA(a.toLowerCase())}_${s.toLowerCase()}_rb_${NA(l.toLowerCase())}`}t(_4e,"getIdForRequestBodySchema");function IG(a,s){return`_${NA(a)}_${NA(s)}`}t(IG,"getIdForRefSchema");function NA(a){let s=a.replace(/\[/g,"_LBRACKET_").replace(/\]/g,"_RBRACKET_").replace(/\{/g,"_LCURLY_").replace(/\}/g,"_RCURLY_").replace(/\//g,"_SLASH_").replace(/-/g,"_DASH_").replace(/\./g,"_DOT_").replace(/\+/g,"_PLUS_").replace(/:/g,"_COLON_").replace(/@/g,"_AT_").replace(/\$/g,"_DOLLAR_").replace(/[^a-zA-Z0-9_]/g,"_");return/^[a-zA-Z_]/.test(s)||(s=`_${s}`),s}t(NA,"sanitizedIdentifierName");var Oht=Rd(V_t(),1);var VG=class{static{t(this,"R")}type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(a,s,l,_,h,b){this.type=a,this.name=s,this.prefix=l,this.value=_,this.suffix=h,this.modifier=b}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},L_r=/[$_\p{ID_Start}]/u,R_r=/[$_\u200C\u200D\p{ID_Continue}]/u,W4e=".*";function M_r(a,s){return(s?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(a)}t(M_r,"Re");function G_t(a,s=!1){let l=[],_=0;for(;_<a.length;){let h=a[_],b=t(function(w){if(!s)throw new TypeError(w);l.push({type:"INVALID_CHAR",index:_,value:a[_++]})},"c");if(h==="*"){l.push({type:"ASTERISK",index:_,value:a[_++]});continue}if(h==="+"||h==="?"){l.push({type:"OTHER_MODIFIER",index:_,value:a[_++]});continue}if(h==="\\"){l.push({type:"ESCAPED_CHAR",index:_++,value:a[_++]});continue}if(h==="{"){l.push({type:"OPEN",index:_,value:a[_++]});continue}if(h==="}"){l.push({type:"CLOSE",index:_,value:a[_++]});continue}if(h===":"){let w="",N=_+1;for(;N<a.length;){let B=a.substr(N,1);if(N===_+1&&L_r.test(B)||N!==_+1&&R_r.test(B)){w+=a[N++];continue}break}if(!w){b(`Missing parameter name at ${_}`);continue}l.push({type:"NAME",index:_,value:w}),_=N;continue}if(h==="("){let w=1,N="",B=_+1,q=!1;if(a[B]==="?"){b(`Pattern cannot start with "?" at ${B}`);continue}for(;B<a.length;){if(!M_r(a[B],!1)){b(`Invalid character '${a[B]}' at ${B}.`),q=!0;break}if(a[B]==="\\"){N+=a[B++]+a[B++];continue}if(a[B]===")"){if(w--,w===0){B++;break}}else if(a[B]==="("&&(w++,a[B+1]!=="?")){b(`Capturing groups are not allowed at ${B}`),q=!0;break}N+=a[B++]}if(q)continue;if(w){b(`Unbalanced pattern at ${_}`);continue}if(!N){b(`Missing pattern at ${_}`);continue}l.push({type:"REGEX",index:_,value:N}),_=B;continue}l.push({type:"CHAR",index:_,value:a[_++]})}return l.push({type:"END",index:_,value:""}),l}t(G_t,"v");function K_t(a,s={}){let l=G_t(a);s.delimiter??="/#?",s.prefixes??="./";let _=`[^${$T(s.delimiter)}]+?`,h=[],b=0,w=0,N="",B=new Set,q=t(rn=>{if(w<l.length&&l[w].type===rn)return l[w++].value},"a"),le=t(()=>q("OTHER_MODIFIER")??q("ASTERISK"),"f"),se=t(rn=>{let jr=q(rn);if(jr!==void 0)return jr;let{type:Qr,index:br}=l[w];throw new TypeError(`Unexpected ${Qr} at ${br}, expected ${rn}`)},"d"),te=t(()=>{let rn="",jr;for(;jr=q("CHAR")??q("ESCAPED_CHAR");)rn+=jr;return rn},"T"),Ue=t(rn=>rn,"Se"),Ie=s.encodePart||Ue,De="",Tt=t(rn=>{De+=rn},"U"),mt=t(()=>{De.length&&(h.push(new VG(3,"","",Ie(De),"",3)),De="")},"$"),hr=t((rn,jr,Qr,br,yr)=>{let Zi=3;switch(yr){case"?":Zi=1;break;case"*":Zi=0;break;case"+":Zi=2;break}if(!jr&&!Qr&&Zi===3){Tt(rn);return}if(mt(),!jr&&!Qr){if(!rn)return;h.push(new VG(3,"","",Ie(rn),"",Zi));return}let Ci;Qr?Qr==="*"?Ci=W4e:Ci=Qr:Ci=_;let Po=2;Ci===_?(Po=1,Ci=""):Ci===W4e&&(Po=0,Ci="");let di;if(jr?di=jr:Qr&&(di=b++),B.has(di))throw new TypeError(`Duplicate name '${di}'.`);B.add(di),h.push(new VG(Po,di,Ie(rn),Ci,Ie(br),Zi))},"V");for(;w<l.length;){let rn=q("CHAR"),jr=q("NAME"),Qr=q("REGEX");if(!jr&&!Qr&&(Qr=q("ASTERISK")),jr||Qr){let yr=rn??"";s.prefixes.indexOf(yr)===-1&&(Tt(yr),yr=""),mt();let Zi=le();hr(yr,jr,Qr,"",Zi);continue}let br=rn??q("ESCAPED_CHAR");if(br){Tt(br);continue}if(q("OPEN")){let yr=te(),Zi=q("NAME"),Ci=q("REGEX");!Zi&&!Ci&&(Ci=q("ASTERISK"));let Po=te();se("CLOSE");let di=le();hr(yr,Zi,Ci,Po,di);continue}mt(),se("END")}return h}t(K_t,"D");function $T(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t($T,"S");function W_t(a){return a&&a.ignoreCase?"ui":"u"}t(W_t,"X");function j_r(a,s,l){return Y_t(K_t(a,l),s,l)}t(j_r,"Z");function Dj(a){switch(a){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}t(Dj,"k");function Y_t(a,s,l={}){l.delimiter??="/#?",l.prefixes??="./",l.sensitive??=!1,l.strict??=!1,l.end??=!0,l.start??=!0,l.endsWith="";let _=l.start?"^":"";for(let N of a){if(N.type===3){N.modifier===3?_+=$T(N.value):_+=`(?:${$T(N.value)})${Dj(N.modifier)}`;continue}s&&s.push(N.name);let B=`[^${$T(l.delimiter)}]+?`,q=N.value;if(N.type===1?q=B:N.type===0&&(q=W4e),!N.prefix.length&&!N.suffix.length){N.modifier===3||N.modifier===1?_+=`(${q})${Dj(N.modifier)}`:_+=`((?:${q})${Dj(N.modifier)})`;continue}if(N.modifier===3||N.modifier===1){_+=`(?:${$T(N.prefix)}(${q})${$T(N.suffix)})`,_+=Dj(N.modifier);continue}_+=`(?:${$T(N.prefix)}`,_+=`((?:${q})(?:`,_+=$T(N.suffix),_+=$T(N.prefix),_+=`(?:${q}))*)${$T(N.suffix)})`,N.modifier===0&&(_+="?")}let h=`[${$T(l.endsWith)}]|$`,b=`[${$T(l.delimiter)}]`;if(l.end)return l.strict||(_+=`${b}?`),l.endsWith.length?_+=`(?=${h})`:_+="$",new RegExp(_,W_t(l));l.strict||(_+=`(?:${b}(?=${h}))?`);let w=!1;if(a.length){let N=a[a.length-1];N.type===3&&N.modifier===3&&(w=l.delimiter.indexOf(N)>-1)}return w||(_+=`(?=${b}|${h})`),new RegExp(_,W_t(l))}t(Y_t,"F");var XI={delimiter:"",prefixes:"",sensitive:!0,strict:!0},B_r={delimiter:".",prefixes:"",sensitive:!0,strict:!0},$_r={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function U_r(a,s){return a.length?a[0]==="/"?!0:!s||a.length<2?!1:(a[0]=="\\"||a[0]=="{")&&a[1]=="/":!1}t(U_r,"J");function X_t(a,s){return a.startsWith(s)?a.substring(s.length,a.length):a}t(X_t,"Q");function z_r(a,s){return a.endsWith(s)?a.substr(0,a.length-s.length):a}t(z_r,"Ee");function Z_t(a){return!a||a.length<2?!1:a[0]==="["||(a[0]==="\\"||a[0]==="{")&&a[1]==="["}t(Z_t,"W");var Q_t=["ftp","file","http","https","ws","wss"];function ept(a){if(!a)return!0;for(let s of Q_t)if(a.test(s))return!0;return!1}t(ept,"N");function J_r(a,s){if(a=X_t(a,"#"),s||a==="")return a;let l=new URL("https://example.com");return l.hash=a,l.hash?l.hash.substring(1,l.hash.length):""}t(J_r,"te");function q_r(a,s){if(a=X_t(a,"?"),s||a==="")return a;let l=new URL("https://example.com");return l.search=a,l.search?l.search.substring(1,l.search.length):""}t(q_r,"re");function V_r(a,s){return s||a===""?a:Z_t(a)?npt(a):rpt(a)}t(V_r,"ne");function W_r(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.password=a,l.password}t(W_r,"se");function H_r(a,s){if(s||a==="")return a;let l=new URL("https://example.com");return l.username=a,l.username}t(H_r,"ie");function G_r(a,s,l){if(l||a==="")return a;if(s&&!Q_t.includes(s))return new URL(`${s}:${a}`).pathname;let _=a[0]=="/";return a=new URL(_?a:"/-"+a,"https://example.com").pathname,_||(a=a.substring(2,a.length)),a}t(G_r,"ae");function K_r(a,s,l){return tpt(s)===a&&(a=""),l||a===""?a:ipt(a)}t(K_r,"oe");function Y_r(a,s){return a=z_r(a,":"),s||a===""?a:H4e(a)}t(Y_r,"ce");function tpt(a){switch(a){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}t(tpt,"_");function H4e(a){if(a==="")return a;if(/^[-+.A-Za-z0-9]*$/.test(a))return a.toLowerCase();throw new TypeError(`Invalid protocol '${a}'.`)}t(H4e,"y");function X_r(a){if(a==="")return a;let s=new URL("https://example.com");return s.username=a,s.username}t(X_r,"le");function Z_r(a){if(a==="")return a;let s=new URL("https://example.com");return s.password=a,s.password}t(Z_r,"fe");function rpt(a){if(a==="")return a;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(a))throw new TypeError(`Invalid hostname '${a}'`);let s=new URL("https://example.com");return s.hostname=a,s.hostname}t(rpt,"z");function npt(a){if(a==="")return a;if(/[^0-9a-fA-F[\]:]/g.test(a))throw new TypeError(`Invalid IPv6 hostname '${a}'`);return a.toLowerCase()}t(npt,"j");function ipt(a){if(a===""||/^[0-9]*$/.test(a)&&parseInt(a)<=65535)return a;throw new TypeError(`Invalid port '${a}'.`)}t(ipt,"K");function Q_r(a){if(a==="")return a;let s=new URL("https://example.com");return s.pathname=a[0]!=="/"?"/-"+a:a,a[0]!=="/"?s.pathname.substring(2,s.pathname.length):s.pathname}t(Q_r,"he");function epr(a){return a===""?a:new URL(`data:${a}`).pathname}t(epr,"ue");function tpr(a){if(a==="")return a;let s=new URL("https://example.com");return s.search=a,s.search.substring(1,s.search.length)}t(tpr,"de");function rpr(a){if(a==="")return a;let s=new URL("https://example.com");return s.hash=a,s.hash.substring(1,s.hash.length)}t(rpr,"pe");var npr=class{static{t(this,"H")}#e;#n=[];#t={};#r=0;#s=1;#p=0;#o=0;#_=0;#u=0;#c=!1;constructor(a){this.#e=a}get result(){return this.#t}parse(){for(this.#n=G_t(this.#e,!0);this.#r<this.#n.length;this.#r+=this.#s){if(this.#s=1,this.#n[this.#r].type==="END"){if(this.#o===0){this.#h(),this.#x()?this.#i(9,1):this.#v()?this.#i(8,1):this.#i(7,0);continue}else if(this.#o===2){this.#m(5);continue}this.#i(10,0);break}if(this.#_>0)if(this.#l())this.#_-=1;else continue;if(this.#A()){this.#_+=1;continue}switch(this.#o){case 0:this.#g()&&this.#m(1);break;case 1:if(this.#g()){this.#P();let a=7,s=1;this.#y()?(a=2,s=3):this.#c&&(a=2),this.#i(a,s)}break;case 2:this.#E()?this.#m(3):(this.#w()||this.#v()||this.#x())&&this.#m(5);break;case 3:this.#T()?this.#i(4,1):this.#E()&&this.#i(5,1);break;case 4:this.#E()&&this.#i(5,1);break;case 5:this.#O()?this.#u+=1:this.#k()&&(this.#u-=1),this.#C()&&!this.#u?this.#i(6,1):this.#w()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 6:this.#w()?this.#i(7,0):this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 7:this.#v()?this.#i(8,1):this.#x()&&this.#i(9,1);break;case 8:this.#x()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#i(a,s){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#D();break;case 2:break;case 3:this.#t.username=this.#D();break;case 4:this.#t.password=this.#D();break;case 5:this.#t.hostname=this.#D();break;case 6:this.#t.port=this.#D();break;case 7:this.#t.pathname=this.#D();break;case 8:this.#t.search=this.#D();break;case 9:this.#t.hash=this.#D();break;case 10:break}this.#o!==0&&a!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(a)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(a)&&(this.#t.pathname??=this.#c?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&a===9&&(this.#t.search??="")),this.#a(a,s)}#a(a,s){this.#o=a,this.#p=this.#r+s,this.#r+=s,this.#s=0}#h(){this.#r=this.#p,this.#s=0}#m(a){this.#h(),this.#o=a}#f(a){return a<0&&(a=this.#n.length-a),a<this.#n.length?this.#n[a]:this.#n[this.#n.length-1]}#d(a,s){let l=this.#f(a);return l.value===s&&(l.type==="CHAR"||l.type==="ESCAPED_CHAR"||l.type==="INVALID_CHAR")}#g(){return this.#d(this.#r,":")}#y(){return this.#d(this.#r+1,"/")&&this.#d(this.#r+2,"/")}#E(){return this.#d(this.#r,"@")}#T(){return this.#d(this.#r,":")}#C(){return this.#d(this.#r,":")}#w(){return this.#d(this.#r,"/")}#v(){if(this.#d(this.#r,"?"))return!0;if(this.#n[this.#r].value!=="?")return!1;let a=this.#f(this.#r-1);return a.type!=="NAME"&&a.type!=="REGEX"&&a.type!=="CLOSE"&&a.type!=="ASTERISK"}#x(){return this.#d(this.#r,"#")}#A(){return this.#n[this.#r].type=="OPEN"}#l(){return this.#n[this.#r].type=="CLOSE"}#O(){return this.#d(this.#r,"[")}#k(){return this.#d(this.#r,"]")}#D(){let a=this.#n[this.#r],s=this.#f(this.#p).index;return this.#e.substring(s,a.index)}#P(){let a={};Object.assign(a,XI),a.encodePart=H4e;let s=j_r(this.#D(),void 0,a);this.#c=ept(s)}},V4e=["protocol","username","password","hostname","port","pathname","search","hash"],YI="*";function H_t(a,s){if(typeof a!="string")throw new TypeError("parameter 1 is not of type 'string'.");let l=new URL(a,s);return{protocol:l.protocol.substring(0,l.protocol.length-1),username:l.username,password:l.password,hostname:l.hostname,port:l.port,pathname:l.pathname,search:l.search!==""?l.search.substring(1,l.search.length):void 0,hash:l.hash!==""?l.hash.substring(1,l.hash.length):void 0}}t(H_t,"ge");function LA(a,s){return s?qG(a):a}t(LA,"b");function JG(a,s,l){let _;if(typeof s.baseURL=="string")try{_=new URL(s.baseURL),s.protocol===void 0&&(a.protocol=LA(_.protocol.substring(0,_.protocol.length-1),l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&(a.username=LA(_.username,l)),!l&&s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.username===void 0&&s.password===void 0&&(a.password=LA(_.password,l)),s.protocol===void 0&&s.hostname===void 0&&(a.hostname=LA(_.hostname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&(a.port=LA(_.port,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&(a.pathname=LA(_.pathname,l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&(a.search=LA(_.search.substring(1,_.search.length),l)),s.protocol===void 0&&s.hostname===void 0&&s.port===void 0&&s.pathname===void 0&&s.search===void 0&&s.hash===void 0&&(a.hash=LA(_.hash.substring(1,_.hash.length),l))}catch{throw new TypeError(`invalid baseURL '${s.baseURL}'.`)}if(typeof s.protocol=="string"&&(a.protocol=Y_r(s.protocol,l)),typeof s.username=="string"&&(a.username=H_r(s.username,l)),typeof s.password=="string"&&(a.password=W_r(s.password,l)),typeof s.hostname=="string"&&(a.hostname=V_r(s.hostname,l)),typeof s.port=="string"&&(a.port=K_r(s.port,a.protocol,l)),typeof s.pathname=="string"){if(a.pathname=s.pathname,_&&!U_r(a.pathname,l)){let h=_.pathname.lastIndexOf("/");h>=0&&(a.pathname=LA(_.pathname.substring(0,h+1),l)+a.pathname)}a.pathname=G_r(a.pathname,a.protocol,l)}return typeof s.search=="string"&&(a.search=q_r(s.search,l)),typeof s.hash=="string"&&(a.hash=J_r(s.hash,l)),a}t(JG,"w");function qG(a){return a.replace(/([+*?:{}()\\])/g,"\\$1")}t(qG,"C");function ipr(a){return a.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}t(ipr,"Oe");function spr(a,s){s.delimiter??="/#?",s.prefixes??="./",s.sensitive??=!1,s.strict??=!1,s.end??=!0,s.start??=!0,s.endsWith="";let l=".*",_=`[^${ipr(s.delimiter)}]+?`,h=/[$_\u200C\u200D\p{ID_Continue}]/u,b="";for(let w=0;w<a.length;++w){let N=a[w];if(N.type===3){if(N.modifier===3){b+=qG(N.value);continue}b+=`{${qG(N.value)}}${Dj(N.modifier)}`;continue}let B=N.hasCustomName(),q=!!N.suffix.length||!!N.prefix.length&&(N.prefix.length!==1||!s.prefixes.includes(N.prefix)),le=w>0?a[w-1]:null,se=w<a.length-1?a[w+1]:null;if(!q&&B&&N.type===1&&N.modifier===3&&se&&!se.prefix.length&&!se.suffix.length)if(se.type===3){let te=se.value.length>0?se.value[0]:"";q=h.test(te)}else q=!se.hasCustomName();if(!q&&!N.prefix.length&&le&&le.type===3){let te=le.value[le.value.length-1];q=s.prefixes.includes(te)}q&&(b+="{"),b+=qG(N.prefix),B&&(b+=`:${N.name}`),N.type===2?b+=`(${N.value})`:N.type===1?B||(b+=`(${_})`):N.type===0&&(!B&&(!le||le.type===3||le.modifier!==3||q||N.prefix!=="")?b+="*":b+=`(${l})`),N.type===1&&B&&N.suffix.length&&h.test(N.suffix[0])&&(b+="\\"),b+=qG(N.suffix),q&&(b+="}"),N.modifier!==3&&(b+=Dj(N.modifier))}return b}t(spr,"ke");var spt=class{static{t(this,"me")}#e;#n={};#t={};#r={};#s={};#p=!1;constructor(a={},s,l){try{let _;if(typeof s=="string"?_=s:l=s,typeof a=="string"){let N=new npr(a);if(N.parse(),a=N.result,_===void 0&&typeof a.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");a.baseURL=_}else{if(!a||typeof a!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(_)throw new TypeError("parameter 1 is not of type 'string'.")}typeof l>"u"&&(l={ignoreCase:!1});let h={ignoreCase:l.ignoreCase===!0},b={pathname:YI,protocol:YI,username:YI,password:YI,hostname:YI,port:YI,search:YI,hash:YI};this.#e=JG(b,a,!0),tpt(this.#e.protocol)===this.#e.port&&(this.#e.port="");let w;for(w of V4e){if(!(w in this.#e))continue;let N={},B=this.#e[w];switch(this.#t[w]=[],w){case"protocol":Object.assign(N,XI),N.encodePart=H4e;break;case"username":Object.assign(N,XI),N.encodePart=X_r;break;case"password":Object.assign(N,XI),N.encodePart=Z_r;break;case"hostname":Object.assign(N,B_r),Z_t(B)?N.encodePart=npt:N.encodePart=rpt;break;case"port":Object.assign(N,XI),N.encodePart=ipt;break;case"pathname":ept(this.#n.protocol)?(Object.assign(N,$_r,h),N.encodePart=Q_r):(Object.assign(N,XI,h),N.encodePart=epr);break;case"search":Object.assign(N,XI,h),N.encodePart=tpr;break;case"hash":Object.assign(N,XI,h),N.encodePart=rpr;break}try{this.#s[w]=K_t(B,N),this.#n[w]=Y_t(this.#s[w],this.#t[w],N),this.#r[w]=spr(this.#s[w],N),this.#p=this.#p||this.#s[w].some(q=>q.type===2)}catch{throw new TypeError(`invalid ${w} pattern '${this.#e[w]}'.`)}}}catch(_){throw new TypeError(`Failed to construct 'URLPattern': ${_.message}`)}}test(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return!1;try{typeof a=="object"?l=JG(l,a,!1):l=JG(l,H_t(a,s),!1)}catch{return!1}let _;for(_ of V4e)if(!this.#n[_].exec(l[_]))return!1;return!0}exec(a={},s){let l={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof a!="string"&&s)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof a>"u")return;try{typeof a=="object"?l=JG(l,a,!1):l=JG(l,H_t(a,s),!1)}catch{return null}let _={};s?_.inputs=[a,s]:_.inputs=[a];let h;for(h of V4e){let b=this.#n[h].exec(l[h]);if(!b)return null;let w={};for(let[N,B]of this.#t[h].entries())if(typeof B=="string"||typeof B=="number"){let q=b[N+1];w[B]=q}_[h]={input:l[h]??"",groups:w}}return _}static compareComponent(a,s,l){let _=t((N,B)=>{for(let q of["type","modifier","prefix","value","suffix"]){if(N[q]<B[q])return-1;if(N[q]!==B[q])return 1}return 0},"o"),h=new VG(3,"","","","",3),b=new VG(0,"","","","",3),w=t((N,B)=>{let q=0;for(;q<Math.min(N.length,B.length);++q){let le=_(N[q],B[q]);if(le)return le}return N.length===B.length?0:_(N[q]??h,B[q]??h)},"s");return!s.#r[a]&&!l.#r[a]?0:s.#r[a]&&!l.#r[a]?w(s.#s[a],[b]):!s.#r[a]&&l.#r[a]?w([b],l.#s[a]):w(s.#s[a],l.#s[a])}get protocol(){return this.#r.protocol}get username(){return this.#r.username}get password(){return this.#r.password}get hostname(){return this.#r.hostname}get port(){return this.#r.port}get pathname(){return this.#r.pathname}get search(){return this.#r.search}get hash(){return this.#r.hash}get hasRegExpGroups(){return this.#p}};globalThis.URLPattern||(globalThis.URLPattern=spt);import{AssertionError as apr}from"node:assert";function RA(a,s){if(a===!1)throw new apr({message:s})}t(RA,"assert");var Zo;(function(a){a.Object="Object",a.Property="Property",a.Array="Array",a.Literal="Literal",a.TemplateString="TemplateString",a.Identifier="Identifier",a.FunctionCall="FunctionCall",a.Raw="Raw"})(Zo||(Zo={}));function Pj(a){return a.type===Zo.Object}t(Pj,"isAstObject");function MA(a){return a.type===Zo.Property}t(MA,"isAstProperty");function apt(a){return a.type===Zo.Array}t(apt,"isAstArray");function Aj(a){return a.type===Zo.Literal}t(Aj,"isAstLiteral");function ZI(a){if(a===void 0)throw new Error("Node is undefined");if(!Pj(a))throw new Error("Node is not object")}t(ZI,"assertAstObject");import{findNodeAtLocation as opr,getNodeValue as cpr,printParseErrorCode as lpr,visit as upr}from"jsonc-parser";var fpr={DEFAULT:{allowTrailingComma:!1}};function WG(a,s=[],l=fpr.DEFAULT){let _={type:"array",offset:-1,length:-1,line:-1,column:-1,children:[],parent:void 0};function h(B){_.type==="property"&&(_.length=B-_.offset,_=_.parent)}t(h,"ensurePropertyComplete");function b(B){return _.children?.push(B),B}t(b,"onValue"),upr(a,{onObjectBegin:t((B,q,le)=>{_=b({type:"object",offset:B,length:-1,line:q+1,column:le+1,parent:_,children:[]})},"onObjectBegin"),onObjectProperty:t((B,q,le,se,te)=>{_=b({type:"property",offset:q,length:-1,line:se+1,column:te+1,parent:_,children:[]}),_.children?.push({type:"string",value:B,offset:q,length:le,line:se,column:te,parent:_})},"onObjectProperty"),onObjectEnd:t((B,q)=>{h(B+q),_.length=B+q-_.offset,_=_.parent,h(B+q)},"onObjectEnd"),onArrayBegin:t((B,q,le,se)=>{_=b({type:"array",offset:B,length:-1,line:le+1,column:se+1,parent:_,children:[]})},"onArrayBegin"),onArrayEnd:t((B,q)=>{_.length=B+q-_.offset,_=_.parent,h(B+q)},"onArrayEnd"),onLiteralValue:t((B,q,le,se,te)=>{b({type:_pr(B),offset:q,length:le,line:se+1,column:te+1,parent:_,value:B}),h(q+le)},"onLiteralValue"),onSeparator:t((B,q)=>{_.type==="property"&&(B===":"?_.colonOffset=q:B===","&&h(q))},"onSeparator"),onError:t((B,q,le,se,te)=>{s.push({error:B,offset:q,length:le,line:se+1,column:te+1})},"onError")},l);let N=_.children?.[0];return N&&delete N.parent,N}t(WG,"parse");function _pr(a){switch(typeof a){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(a){if(Array.isArray(a))return"array"}else return"null";return"object"}default:return"null"}}t(_pr,"getNodeType");function G4e(a,s){return opr(a,s)}t(G4e,"findNodeAtLocation");function HG(a){return cpr(a)}t(HG,"getNodeValue");function opt(a){return lpr(a)}t(opt,"printParseErrorCode");var GG=class{static{t(this,"AstAdapter")}parse(s){let _=WG(s,[]);if(_)return this.parseNode(_,void 0);throw new Error("Failed to parse JSON")}convert(s){return this.parseNode(s,void 0)}parseNode(s,l){switch(s.type){case"object":return this.createObject(s,l);case"array":return this.createArray(s,l);case"property":return this.createProperty(s,l);case"string":return this.createLiteral(s,l);case"number":return this.createLiteral(s,l);case"boolean":return this.createLiteral(s,l);case"null":return this.createLiteral(s,l)}}createLiteral(s,l){return{type:Zo.Literal,location:{line:s.line,column:s.column},parent:l,value:s.type==="null"?null:s.value}}createObject(s,l){let _={type:Zo.Object,children:[],parent:l,location:{line:s.line,column:s.column}};return s.children?.forEach(h=>{_.children.push(this.parseNode(h,_))}),_}createProperty(s,l){RA(s.children?.length===2,"Invalid property node");let _={type:Zo.Property,location:{line:s.line,column:s.column},parent:l,name:null,value:null};return _.name={value:s.children[0].value,location:{line:s.line,column:s.column},type:Zo.Identifier,parent:_},_.value=this.parseNode(s.children[1],_),_}createArray(s,l){let _={type:Zo.Array,location:{line:s.line,column:s.column},parent:l,children:[]};return s.children?.forEach(h=>_.children.push(this.parseNode(h,_))),_}};var UT={createLiteral:t((a,s)=>({type:Zo.Literal,parent:s,value:a}),"createLiteral"),createTemplateString:t((a,s)=>({type:Zo.TemplateString,parent:s,value:a}),"createTemplateString"),createIdentifier:t((a,s)=>({type:Zo.Identifier,value:a,parent:s}),"createIdentifier"),createProperty:t((a,s,l)=>{let _={type:Zo.Property,parent:l,name:null,value:s};return _.name={value:a,type:Zo.Identifier,parent:_},_.value.parent=_,_},"createProperty"),createArrayOfLiterals:t((a,s)=>{let l={type:Zo.Array,parent:s,children:[]};for(let _ of a)l.children.push(UT.createLiteral(_,l));return l},"createArrayOfLiterals")};var ppr=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/,KG=class{static{t(this,"SourceGenerator")}generate(s){let l=[];return this.generateSource(l,s),l.join("")}generateSource(s,l){switch(l.type){case Zo.Array:return this.generateArray(s,l);case Zo.Object:return this.generateObject(s,l);case Zo.Property:return this.generateProperty(s,l);case Zo.Literal:return this.generateLiteral(s,l);case Zo.FunctionCall:return this.generateFunctionCall(s,l);case Zo.Identifier:return this.generateIdentifier(s,l);case Zo.Raw:return this.generateRaw(s,l);case Zo.TemplateString:return this.generateTemplateString(s,l)}}generateArray(s,l){s.push("["),l.children.map(_=>{this.generateSource(s,_),s.push(",")}),s.push("]")}generateObject(s,l){s.push("{"),l.children.forEach(_=>{this.generateSource(s,_),s.push(",")}),s.push("}")}generateProperty(s,l){this.generateIdentifier(s,l.name),s.push(":"),this.generateSource(s,l.value)}generateFunctionCall(s,l){s.push(l.name.value),s.push("("),l.children.forEach((_,h,b)=>{this.generateSource(s,_),h<b.length&&s.push(",")}),s.push(")")}generateRaw(s,l){s.push(l.value)}generateTemplateString(s,l){s.push("`"),s.push(l.value.replaceAll("`","\\`")),s.push("`")}generateLiteral(s,l){if(l.value===null)return s.push("null");switch(typeof l.value){case"number":case"boolean":return s.push(`${l.value}`);case"string":{let _=l.value,h=JSON.stringify(_);return s.push(`${h}`)}}}generateIdentifier(s,l){let _=ppr.test(l.value)?l.value:`'${l.value}'`;s.push(_)}};import dpr from"node:fs/promises";import{parse as mpr}from"@swc/core";var cpt=t(async a=>{let s=new Set;try{let l=await dpr.readFile(a,"utf-8");(await mpr(l,{syntax:"typescript"})).body.forEach(h=>{h.type==="ExportDefaultDeclaration"||h.type==="ExportDefaultExpression"?s.add("default"):h.type==="ExportDeclaration"&&h.declaration.type==="FunctionDeclaration"?s.add(h.declaration.identifier.value):h.type==="ExportDeclaration"&&h.declaration.type==="VariableDeclaration"&&h.declaration.declarations[0].id.type==="Identifier"&&s.add(h.declaration.declarations[0].id.value)})}catch{return null}return s},"getJSFileExports");var lpt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/fragments.schema.json",$defs:{corsPolicyConfiguration:{type:"object",required:["name","allowedOrigins"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},allowCredentials:{type:"boolean"},maxAge:{type:"number"},allowedOrigins:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},allowedMethods:{oneOf:[{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},{type:"string"}]},allowedHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]},exposeHeaders:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}]}}},handlerDefinition:{type:"object",properties:{module:{type:"string",pattern:"^\\$import\\([^ )]*?\\)$"},export:{type:"string"},options:{type:"object",additionalProperties:!0}},additionalProperties:!1,required:["module","export"]},httpMethod:{type:"string",enum:["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"]}}};var K4e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policies.schema.json",title:"Policies Config File",type:"object",additionalProperties:!1,properties:{policies:{type:"array",items:{$ref:"policy-configuration.schema.json"}},corsPolicies:{type:"array",items:{$ref:"fragments.schema.json#/$defs/corsPolicyConfiguration"}}}};var upt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/policy-configuration.schema.json",title:"Policy Configuration Fragment",type:"object",required:["name","policyType","handler"],additionalProperties:!1,properties:{name:{type:"string",pattern:"^[0-9a-z-]+$"},policyType:{type:"string"},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},options:{type:"object",additionalProperties:!0}}};var Y4e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration-open-api.schema.json",title:"Open API Route Configuration Fragment",description:"These are the properties that can appear under the x-zuplo-route extension in a PathObject in Open API. It's a subset of what can appear in Zuplo's routes.json.",type:"object",required:["handler"],additionalProperties:!1,properties:{label:{type:"string",description:"An internal user-friendly identifier of the route."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},tags:{type:"array",items:{type:"string"}}}};var X4e={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"http://schemas.zuplo.com/route-configuration.schema.json",title:"Route Configuration Fragment",description:"",type:"object",required:["path","methods","handler"],additionalProperties:!1,$defs:{corsPolicy:{type:"string",pattern:"^[0-9a-z-]+$"}},properties:{operationId:{type:"string"},path:{type:"string",pattern:"^/[^\\s]*$"},methods:{type:"array",items:{$ref:"fragments.schema.json#/$defs/httpMethod"}},label:{type:"string",description:"An internal user-friendly identifier of the route."},enforceOpenApi:{type:"boolean",description:"If true, schema validation found in the OpenAPI spec will be enforced on requests/responses."},key:{type:"string",deprecated:!0},handler:{$ref:"fragments.schema.json#/$defs/handlerDefinition"},corsPolicy:{$ref:"#/$defs/corsPolicy"},custom:{},mcp:{type:"object",additionalProperties:!1,properties:{enabled:{type:"boolean"}}},policies:{type:"object",additionalProperties:!1,properties:{inbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}},outbound:{type:"array",items:{type:"string",pattern:"^[0-9a-z-]+$"}}}},summary:{type:"string"},description:{type:"string"},excludeFromOpenApi:{type:"boolean"},tags:{type:"array",items:{type:"string"}}}};var xht=Rd(Wmt(),1),Eht=Rd(Tht(),1);var jfe=class a{static{t(this,"JsonValidator")}static#e=new a;static get instance(){return a.#e}ajv;constructor(){this.ajv=new Eht.Ajv2020({allErrors:!0,allowUnionTypes:!0}),this.ajv.addKeyword("faker"),(0,xht.default)(this.ajv,{mode:"fast"})}addSchema(s,l){this.ajv.addSchema(s,l)}compile(s){let l=this.ajv.compile(s);return t(h=>({isValid:l(h),errors:this.toSimpleErrors(l.errors,h),warnings:[]}),"validator")}toSimpleErrors(s,l){let _=[];return s?.forEach(h=>{h.keyword==="enum"&&h.params.allowedValues&&Array.isArray(h.params.allowedValues)&&(h.message+=`; ${h.params.allowedValues.join(", ")}`),h.instancePath&&(h.instancePath=h.instancePath.replaceAll(/(\/)?(~1)(\/)?/gm,"/"));let b={details:{}},w=h.instancePath.split("/");if(w.length>2){let B=w[1],q=w[2]?parseInt(w[2],10):0,le=w[3],se=Number.isNaN(q)?void 0:l[B][q][le];b={details:{property:B,index:q,field:le,fieldValue:se}}}if(h.keyword==="required"&&h.params.missingProperty&&h.instancePath&&(h.message=`A 'path' is missing required property '${h.params.missingProperty}'`),h.keyword==="additionalProperties"&&h.params.additionalProperty&&h.instancePath&&(h.message=`A 'path' should NOT include property '${h.params.additionalProperty}'`),h.keyword==="type"&&h.params.type&&h.instancePath){let B=h.instancePath.split("/"),q=B[B.length-1];h.message=`Value of property '${q}' must be '${h.params.type}'`}let N=Object.assign(h,b);_.push(N)}),_}};var c4=jfe.instance;c4.addSchema(X4e,"route-configuration.schema.json");c4.addSchema(upt,"policy-configuration.schema.json");c4.addSchema(K4e,"policies.schema.json");c4.addSchema(Y4e,"open-api-route-configuration.schema.json");c4.addSchema(lpt,"fragments.schema.json");var z$r=c4.compile(X4e),Cht=c4.compile(Y4e),_8e=c4.compile(K4e);var Bfe=class{static{t(this,"PoliciesConfigurationValidator")}results;validate(s){return this.results=_8e(s),this.results}};var $fe=class{static{t(this,"OpenAPILocalizedValidator")}results;validate(s){return this.results=Cht(s),this.results}};import T1r from"node:path";var p8e=/\$import\((.*)\)/,Ufe=/\$env\((.*?)\)/g;var zA=class extends Error{static{t(this,"CodeGenError")}location;constructor(s,l,_,h){super(s),this.location={file:l,namespace:"",line:_?_.line:0,column:_?_.column:0,length:0,lineText:h??"",suggestion:""}}},S1r=t(a=>{let s=[],l=a;for(;l.parent;)s.push(l),l=l.parent;return s.reverse()},"invertTree"),l4=t((a,s)=>{if(!a)return!1;let l=S1r(a);return s.split("/").every((b,w)=>{let N=l[w];return N?b==="*"||MA(N)&&N.name.value===b?!0:b==="{}"?N.type===Zo.Object:b==="[]"?N.type===Zo.Array:!1:!1})},"testPosition");var zfe=class{static{t(this,"AstTransformer")}errors=[];transform(s){return this.visitor(s),s}visitor(s){this.visit(s),Pj(s)?s.children.forEach(l=>{this.visitor(l)}):apt(s)?s.children.forEach(l=>{this.visitor(l)}):MA(s)&&this.visitor(s.value)}},wht=t((a,s,l)=>_=>{if(!MA(_)||!Aj(_.value)||typeof _.value.value!="string")return;if(!a.some(b=>l4(_,b))){Ufe.test(_.value.value)&&s.push(new zA("An $env() statement is not expected at this location.",l,_.location,_.value.value));return}let h=new RegExp(Ufe).exec(_.value.value);if(h?.length===2&&h[0]===_.value.value){let b={type:Zo.Raw,parent:null,value:`environment["${h[1]}"]`};_.value=b}else{let b=_.value.value.replaceAll(new RegExp(Ufe),(w,N)=>`\${environment["${N}"] ? environment["${N}"] : ""}`);b!==_.value.value&&(_.value=UT.createTemplateString(b,_))}},"getEnvStatementTransformer");var DK="config/routes.json",x1r=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*","corsPolicies/[]/{}/*"],E1r=["handler/{}/module","handler/{}/options/{}/policies/{}/inbound/[]/{}/module","handler/{}/options/{}/policies/{}/outbound/[]/{}/module","policies/[]/{}/handler/{}/module","policies/[]/{}/handler/{}/options/{}/identifier/{}/module","policies/[]/{}/handler/{}/options/{}/validator"],kht=["handler/{}/options/*","policies/[]/{}/handler/{}/options/*"],C1r="handler/{}/options/{}/rewritePattern",w1r="handler/{}/options/{}/baseUrl",Jfe=class extends zfe{static{t(this,"OpenAPIRoutesFragmentAstTransformer")}importCount=0;addedImports=new Map;getImportName(s){this.addedImports.has(s)||this.addedImports.set(s,`__import${this.importCount++}`);let l=this.addedImports.get(s);if(!l)throw new Error("Import name is undefined. This should not happen.");return l}getImports(){let s=[];return this.addedImports.forEach((l,_)=>{s.push({name:l,path:_})}),s}visit(s){this.rewriteHandlerFunction(s),this.rewriteForwardFunction(s),this.replaceImportStatements(s),this.replaceEnvStatements(s)}rewriteHandlerFunction(s){if(!(!MA(s)||!Aj(s.value)||typeof s.value.value!="string")&&l4(s,C1r)){if(!s.parent||!Pj(s.parent)){this.errors.push(new zA("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Zo.Raw,parent:null,value:Dht(l)},h=UT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}rewriteForwardFunction(s){if(!(!MA(s)||!Aj(s.value)||typeof s.value.value!="string")&&l4(s,w1r)){if(!s.parent||!Pj(s.parent)){this.errors.push(new zA("Invalid node, expected object",DK,s.parent?s.parent.location:s.location,void 0));return}let l=s.value.value,_={type:Zo.Raw,parent:null,value:Dht(l)},h=UT.createProperty("__rewriteFunction",_,s);s.parent.children.push(h)}}replaceImportStatements(s){if(!MA(s)||!Aj(s.value))return;let l=s.value.value;if(typeof l!="string")return;if(!E1r.some(N=>l4(s,N))&&!kht.some(N=>l4(s,N))){if(p8e.test(l)){if(s.name.value==="$ref")return;this.errors.push(new zA("An $import() statement is not expected at this location.",DK,s.location,l))}return}let _=p8e.exec(l);if(kht.some(N=>l4(s,N))&&!_)return;if(!_){this.errors.push(new zA("Invalid $import() statement",DK,s.location,l));return}let h=_[1];h=h.replace(/\\/g,"/"),h.startsWith(".")&&(h=T1r.posix.join("..",h));let b=this.getImportName(h),w={type:Zo.Identifier,parent:s.parent,value:b};s.value=w}replaceEnvStatements=wht(x1r,this.errors,DK)};function Dht(a){return`(request, context) => {
|
|
583
583
|
const { params, url, query, method, headers } = request;
|
|
584
584
|
const { host, hostname, origin, pathname, port, search } = new URL(url);
|
|
585
585
|
const e = encodeURIComponent;
|
|
@@ -603,20 +603,20 @@ globstar while`,s,te,l,Ue,Ie),this.matchOne(s.slice(te),l.slice(Ue),_))return th
|
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
605
|
export default routes;
|
|
606
|
-
`),P1r=["2023-03-14","2024-01-15","2024-03-14","2024-09-02"];function Fht(a){return!a||P1r.includes(a)}t(Fht,"isLegacyPathBehavior");async function m8e(a){try{let{content:s,warnings:l}=await A1r(a);return{content:s,errors:[],warnings:l}}catch(s){if(s instanceof Z1)return s.toBuildResult();throw s}}t(m8e,"compileRoutes");async function A1r({sourceDirectory:a,policiesContent:s,oasContent:l,compatibilityDate:_,allowDuplicateRoutes:h}){let b=[],w=[],N=new Jfe,B=new KG,{policiesNode:q,policiesData:le}=O1r(s),{generatedPolicies:se,policyNames:te}=F1r(N,B,q,le),{generatedCorsPolicies:Ue,corsPoliciesNames:Ie}=L1r(N,B,q,le),De=R1r(a,l),Tt=[],mt=new Map;for(let Qr of De){let{node:br,oas:yr,oasProjectRelativePath:Zi}=Qr,Ci=G4e(br,["paths"]);if(!Ci)continue;let Po=PK.basename(yr.fileName,".oas.json");for(let di of Ci.children??[])if(di.children){let vf=z1r(di),Nf=vf[Pht]?.pathMode;if(Nf){if(Nf!==Vfe&&Nf!==d8e)throw new Z1({text:`Unknown path mode ${Nf}`,location:{line:0,column:0,file:Zi}})}else Nf=Vfe;for(let[Rn,xC]of Object.entries(vf)){if(!Wfe(Rn))continue;let Bl=Rn,Ar=Bl.split(/,/).map(Hs=>Hs.trim().toUpperCase()),ax=xC,Sc=ax[qfe];if(Sc){let Gh=new $fe().validate(Sc);if(Gh.isValid){let V0=Aht(di);if(!mt.has(V0)&&(mt.set(V0,new Set),Fht(_)))try{new URLPattern({pathname:V0})}catch{w.push({text:`Path '${V0}' contains invalid characters. The value must be a valid URLPattern.`,location:{line:di.line,column:di.column,file:Zi}})}if(!h){let W0=mt.get(V0);Ar.forEach(ox=>{W0.has(ox)?w.push({text:`Cannot have duplicate routes declared. Route '${ox.toUpperCase()} ${V0}' declared more than once.`,location:{line:di.line,column:di.column,file:Zi}}):W0.add(ox)})}let kF=Nht(di,[V0,Bl,qfe]),qk=await q1r(kF,yr);if(!qk.valid)throw new Z1({text:qk.errorMsg??`Unknown error on handler for path '${V0}'`,location:{line:qk.line??0,column:qk.column??0,file:Zi}});let qi=W1r(kF,yr);if(!qi.valid)throw new Z1(qi.errors);qi.warnings&&b.push(...qi.warnings),Tt.push({path:V0,pathPattern:V0,pathMode:Nf,httpMethods:Ar,rawOperation:Bl,rawOpenAPI:ax,oasFileName:Po,oasProjectRelativePath:Zi,config:Nht(di,[V0,Bl,qfe])})}else throw new Z1({text:JSON.stringify(Gh.errors),location:{line:0,column:0,file:Zi}})}else{let Hs=Aht(di),Gh={corsPolicy:"none",handler:J1r(Hs,br)};Tt.push({path:Hs,pathPattern:Hs,pathMode:Vfe,rawOpenAPI:ax,oasFileName:Po,oasProjectRelativePath:Zi,httpMethods:Ar,rawOperation:Bl,config:WG(JSON.stringify(Gh))})}if(Sc&&"policies"in Sc){let Hs=Sc.policies;Hs.inbound?.forEach(Gh=>{te.includes(Gh)||w.push({text:`Policy '${Gh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:vf.line,column:vf.column,file:Zi}})}),Hs.outbound?.forEach(Gh=>{te.includes(Gh)||w.push({text:`Policy '${Gh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:vf.line,column:vf.column,file:Zi}})})}if(w.length>0)throw new Z1(w);let pd=["none","anything-goes"];if(Sc&&"corsPolicy"in Sc){let Hs=Sc.corsPolicy;if(pd.includes(Hs))continue;Ie.includes(Hs)||w.push({text:`Cors policy '${Hs}' does not exist in policies.json. Please add it and rebuild.`,location:{line:vf.line,column:vf.column,file:Zi}})}}}if(w.length>0)throw new Z1(w)}let hr=[];for(let Qr of Tt){let br=new GG().convert(Qr.config);M1r(br,Qr),j1r(br,Qr,_),B1r(br,Qr),$1r(br,Qr),U1r(br,Qr);let yr=N.transform(br),Zi=N.errors;if(Zi.length>0)throw new Z1({text:JSON.stringify(Zi),location:{line:0,column:0,file:Qr.oasProjectRelativePath}});let Po=new KG().generate(yr);hr.push(Po)}if(RA(De.length===l.length,"Tree length should match OAS file length"),RA(Tt.length===hr.length,`The number of validated nodes should match the number of generated fragments. There were ${Tt.length} validated nodes and ${hr.length} generated fragments.`),w.length>0)throw new Z1(w);let rn={routes:hr,imports:N.getImports(),policies:se,corsPolicies:Ue};return{content:D1r(rn),warnings:b}}t(A1r,"generateSourceCode");var N1r=0,I1r=1;function O1r(a){let s=new Bfe,l=JSON.parse(a.content),_=s.validate(l);if(!_.isValid)throw new Z1({text:JSON.stringify(_.errors),location:{line:0,column:0,file:"/config/policies.json"}});let h=new GG().parse(JSON.stringify(l));return{policiesData:l,policiesNode:h}}t(O1r,"getPolicyData");function F1r(a,s,l,_){let h=[],b;ZI(l);let w=l.children.find(N=>N.name.value==="policies");if(w){let N=a.transform(w);b=s.generate(N),h=_.policies.map(({name:B})=>B)}else b="policies: []";return{generatedPolicies:b,policyNames:h}}t(F1r,"generatePolicies");function L1r(a,s,l,_){let h,b;ZI(l);let w=l.children.find(N=>N.name.value==="corsPolicies");if(w){let N=a.transform(w);b=s.generate(N),h=_.corsPolicies.map(({name:B})=>B)}else b="corsPolicies: []",h=[];return{generatedCorsPolicies:b,corsPoliciesNames:h}}t(L1r,"generateCorsPolicies");function R1r(a,s){let l=[];for(let _ of s){let h=[],b=WG(_.content,h),w=`.${PK.sep}${PK.relative(a,_.fileName)}`;if(h.length>0)throw new Z1(h.map(N=>({text:opt(N.error),location:{file:w,line:N.line,column:N.column}})));if(!b)throw new Z1({text:"Error parsing the OpenAPI file. Check the contents of the file.",location:{file:w,line:0,column:0}});l.push({node:b,oas:_,oasProjectRelativePath:w})}return l}t(R1r,"getOasTrees");function M1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"path",type:Zo.Identifier,parent:l},l.value=UT.createLiteral(s.path,l),ZI(a),a.children.unshift(l)}t(M1r,"embellishWithPath");function j1r(a,s,l){let _={type:Zo.Property,parent:a,name:null,value:null};if(_.name={value:"pathPattern",type:Zo.Identifier,parent:_},s.pathMode===d8e)_.value=UT.createLiteral(s.path,_);else{let h=/{(\S+?)}/gm,b=":$1",w=Fht(l)?s.path:s.path.replace(/([*+?()[\].|^$\\:])/g,"\\$1");w=w.replace(h,b),s.path.endsWith("/")||(w=w+"{/}?"),_.value=UT.createLiteral(w,_)}ZI(a),a.children.unshift(_)}t(j1r,"embellishWithPathPattern");function B1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"methods",type:Zo.Identifier,parent:l},l.value=UT.createArrayOfLiterals(s.httpMethods,l),ZI(a),a.children.unshift(l)}t(B1r,"embellishWithMethods");function $1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"raw",type:Zo.Identifier,parent:a};let _=NG(s.oasFileName,s.path,s.rawOperation);l.value={type:Zo.Raw,parent:l,value:`() => {return rawRouteData.${_};}`},ZI(a),a.children.unshift(l)}t($1r,"embellishWithRawOpenApi");function U1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"metadata",type:Zo.Identifier,parent:a};let _={type:Zo.Property,parent:l,name:null,value:null};_.name={value:"filepath",type:Zo.Identifier,parent:_},_.value=UT.createLiteral(s.oasProjectRelativePath,_),l.value={type:Zo.Object,parent:l,children:[_]},ZI(a),a.children.unshift(l)}t(U1r,"embellishWithMetadata");function z1r(a){return RA(a.type==="property"),RA(Array.isArray(a.children)),HG(a.children[I1r])}t(z1r,"evaluatePathItem");function Aht(a){return RA(a.type==="property"),RA(Array.isArray(a.children)),HG(a.children[N1r])}t(Aht,"evaluatePath");function Nht(a,s){return G4e(a.parent,s)}t(Nht,"extractZuploRouteNode");function Lht(a){return HG(a)}t(Lht,"evaluateZuploRouteNode");function J1r(a,s){let l=/{(\S+?)}/gm,h=a.replace(l,"${params.$1}"),b=HG(s);return{export:"urlRewriteHandler",module:"$import(@zuplo/runtime)",options:{rewritePattern:`${b.servers&&b.servers.length>0?b.servers[0].url:"http://example.com"}${h}`,forwardSearch:!0}}}t(J1r,"addDefaultUrlRewriteHandler");async function q1r(a,s){let l=Lht(a),_=l.handler.module.replace(/^\$import\(/,"").replace(/\)$/,""),h=PK.join(PK.dirname(s.fileName),"..",`${_}.ts`),b=l.handler.export;if(_==="@zuplo/runtime")return{valid:!0};if(await ou.fileExists(h)){let w=await cpt(h);if(w===null)return{valid:!1,errorMsg:`Could not find any export due to a compile error in '${ou.getParentDirFilename(h)}'`};if(!w.has(b)){let N=`Could not find export "${b}" in '${ou.getParentDirFilename(h)}'`,B=0,q=0;if(a.children)for(let le of a.children)le.children&&le.children.forEach(se=>{se.value==="handler"&&(B=se.line,q=se.column)});return{valid:!1,errorMsg:N,line:B,column:q}}return{valid:!0}}else return{valid:!1,errorMsg:`Could not find module '${_}'`}}t(q1r,"checkModuleIsValid");var Iht=t((a,s)=>{let l=0,_=0;if(a.children)for(let h of a.children)h.children&&h.children.forEach(b=>{b.value==="options"&&b.children?.forEach(w=>{b.value===s&&(l=w.line,_=w.column)})});return{line:l,column:_}},"getHandlerOptionLocation"),V1r="$env(";function W1r(a,s){let l=Lht(a),_=l.handler.export;if(_!=="urlForwardHandler"&&_!=="urlRewriteHandler")return{valid:!0};let h="rewritePattern";_==="urlForwardHandler"&&(h="baseUrl");let b=l.handler.options[h];if(!b){let w=Iht(a,h);return{valid:!1,errors:[{text:`Invalid request handler configuration. handler.options.${h} is required but was not provided.`,location:{file:s.fileName,line:w.line,column:w.column}}]}}if(b.includes(V1r)){let w=Iht(a,h);return{valid:!0,warnings:[{text:`Invalid environment variable access syntax detected. Use \${env.VAR_NAME} instead of $env(VAR_NAME) for handler.options.${h}.`,location:{file:s.fileName,line:w.line,column:w.column}}]}}return{valid:!0}}t(W1r,"checkHandlerIsValid");import Q1r from"node:fs/promises";import evr from"node:path";var{stringify:H1r}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");var Hfe={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},pC=17,G1r={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:pC,ClassExpression:pC,FunctionExpression:pC,ObjectExpression:pC,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function Xj(a,s){let{generator:l}=a;if(a.write("("),s!=null&&s.length>0){l[s[0].type](s[0],a);let{length:_}=s;for(let h=1;h<_;h++){let b=s[h];a.write(", "),l[b.type](b,a)}}a.write(")")}t(Xj,"formatSequence");function zht(a,s,l,_){let h=a.expressionsPrecedence[s.type];if(h===pC)return!0;let b=a.expressionsPrecedence[l.type];return h!==b?!_&&h===15&&b===14&&l.operator==="**"||h<b:h!==13&&h!==14?!1:s.operator==="**"&&l.operator==="**"?!_:h===13&&b===13&&(s.operator==="??"||l.operator==="??")?!0:_?Hfe[s.operator]<=Hfe[l.operator]:Hfe[s.operator]<Hfe[l.operator]}t(zht,"expressionNeedsParenthesis");function Gfe(a,s,l,_){let{generator:h}=a;zht(a,s,l,_)?(a.write("("),h[s.type](s,a),a.write(")")):h[s.type](s,a)}t(Gfe,"formatExpression");function K1r(a,s,l,_){let h=s.split(`
|
|
606
|
+
`),P1r=["2023-03-14","2024-01-15","2024-03-14","2024-09-02"];function Fht(a){return!a||P1r.includes(a)}t(Fht,"isLegacyPathBehavior");async function m8e(a){try{let{content:s,warnings:l}=await A1r(a);return{content:s,errors:[],warnings:l}}catch(s){if(s instanceof Z1)return s.toBuildResult();throw s}}t(m8e,"compileRoutes");async function A1r({sourceDirectory:a,policiesContent:s,oasContent:l,compatibilityDate:_,allowDuplicateRoutes:h}){let b=[],w=[],N=new Jfe,B=new KG,{policiesNode:q,policiesData:le}=O1r(s),{generatedPolicies:se,policyNames:te}=F1r(N,B,q,le),{generatedCorsPolicies:Ue,corsPoliciesNames:Ie}=L1r(N,B,q,le),De=R1r(a,l),Tt=[],mt=new Map;for(let Qr of De){let{node:br,oas:yr,oasProjectRelativePath:Zi}=Qr,Ci=G4e(br,["paths"]);if(!Ci)continue;let Po=PK.basename(yr.fileName,".oas.json");for(let di of Ci.children??[])if(di.children){let vf=z1r(di),Nf=vf[Pht]?.pathMode;if(Nf){if(Nf!==Vfe&&Nf!==d8e)throw new Z1({text:`Unknown path mode ${Nf}`,location:{line:0,column:0,file:Zi}})}else Nf=Vfe;for(let[Rn,xC]of Object.entries(vf)){if(!Wfe(Rn))continue;let Bl=Rn,Ar=Bl.split(/,/).map(Hs=>Hs.trim().toUpperCase()),ax=xC,Sc=ax[qfe];if(Sc){let Gh=new $fe().validate(Sc);if(Gh.isValid){let V0=Aht(di);if(!mt.has(V0)&&(mt.set(V0,new Set),Fht(_)))try{new URLPattern({pathname:V0})}catch{w.push({text:`Path '${V0}' contains invalid characters. The value must be a valid URLPattern.`,location:{line:di.line,column:di.column,file:Zi}})}if(!h){let W0=mt.get(V0);Ar.forEach(ox=>{W0.has(ox)?w.push({text:`Cannot have duplicate routes declared. Route '${ox.toUpperCase()} ${V0}' declared more than once.`,location:{line:di.line,column:di.column,file:Zi}}):W0.add(ox)})}let kF=Nht(di,[V0,Bl,qfe]),qk=await q1r(kF,yr);if(!qk.valid)throw new Z1({text:qk.errorMsg??`Unknown error on handler for path '${V0}'`,location:{line:qk.line??0,column:qk.column??0,file:Zi}});let qi=W1r(kF,yr);if(!qi.valid)throw new Z1(qi.errors);qi.warnings&&b.push(...qi.warnings),Tt.push({path:V0,pathPattern:V0,pathMode:Nf,httpMethods:Ar,rawOperation:Bl,rawOpenAPI:ax,oasFileName:Po,oasProjectRelativePath:Zi,config:Nht(di,[V0,Bl,qfe])})}else throw new Z1({text:JSON.stringify(Gh.errors),location:{line:0,column:0,file:Zi}})}else{let Hs=Aht(di),Gh={corsPolicy:"none",handler:J1r(Hs,br)};Tt.push({path:Hs,pathPattern:Hs,pathMode:Vfe,rawOpenAPI:ax,oasFileName:Po,oasProjectRelativePath:Zi,httpMethods:Ar,rawOperation:Bl,config:WG(JSON.stringify(Gh))})}if(Sc&&"policies"in Sc){let Hs=Sc.policies;Hs.inbound?.forEach(Gh=>{te.includes(Gh)||w.push({text:`Policy '${Gh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:vf.line,column:vf.column,file:Zi}})}),Hs.outbound?.forEach(Gh=>{te.includes(Gh)||w.push({text:`Policy '${Gh}' does not exist in policies.json. Please add it and rebuild.`,location:{line:vf.line,column:vf.column,file:Zi}})})}if(w.length>0)throw new Z1(w);let pd=["none","anything-goes"];if(Sc&&"corsPolicy"in Sc){let Hs=Sc.corsPolicy;if(pd.includes(Hs))continue;Ie.includes(Hs)||w.push({text:`Cors policy '${Hs}' does not exist in policies.json. Please add it and rebuild.`,location:{line:vf.line,column:vf.column,file:Zi}})}}}if(w.length>0)throw new Z1(w)}let hr=[];for(let Qr of Tt){let br=new GG().convert(Qr.config);M1r(br,Qr),j1r(br,Qr,_),B1r(br,Qr),$1r(br,Qr),U1r(br,Qr);let yr=N.transform(br),Zi=N.errors;if(Zi.length>0)throw new Z1({text:JSON.stringify(Zi),location:{line:0,column:0,file:Qr.oasProjectRelativePath}});let Po=new KG().generate(yr);hr.push(Po)}if(RA(De.length===l.length,"Tree length should match OAS file length"),RA(Tt.length===hr.length,`The number of validated nodes should match the number of generated fragments. There were ${Tt.length} validated nodes and ${hr.length} generated fragments.`),w.length>0)throw new Z1(w);let rn={routes:hr,imports:N.getImports(),policies:se,corsPolicies:Ue};return{content:D1r(rn),warnings:b}}t(A1r,"generateSourceCode");var N1r=0,I1r=1;function O1r(a){let s=new Bfe,l=JSON.parse(a.content),_=s.validate(l);if(!_.isValid)throw new Z1({text:JSON.stringify(_.errors),location:{line:0,column:0,file:"/config/policies.json"}});let h=new GG().parse(JSON.stringify(l));return{policiesData:l,policiesNode:h}}t(O1r,"getPolicyData");function F1r(a,s,l,_){let h=[],b;ZI(l);let w=l.children.find(N=>N.name.value==="policies");if(w){let N=a.transform(w);b=s.generate(N),h=_.policies.map(({name:B})=>B)}else b="policies: []";return{generatedPolicies:b,policyNames:h}}t(F1r,"generatePolicies");function L1r(a,s,l,_){let h,b;ZI(l);let w=l.children.find(N=>N.name.value==="corsPolicies");if(w){let N=a.transform(w);b=s.generate(N),h=_.corsPolicies.map(({name:B})=>B)}else b="corsPolicies: []",h=[];return{generatedCorsPolicies:b,corsPoliciesNames:h}}t(L1r,"generateCorsPolicies");function R1r(a,s){let l=[];for(let _ of s){let h=[],b=WG(_.content,h),w=`.${PK.sep}${PK.relative(a,_.fileName)}`;if(h.length>0)throw new Z1(h.map(N=>({text:opt(N.error),location:{file:w,line:N.line,column:N.column}})));if(!b)throw new Z1({text:"Error parsing the OpenAPI file. Check the contents of the file.",location:{file:w,line:0,column:0}});l.push({node:b,oas:_,oasProjectRelativePath:w})}return l}t(R1r,"getOasTrees");function M1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"path",type:Zo.Identifier,parent:l},l.value=UT.createLiteral(s.path,l),ZI(a),a.children.unshift(l)}t(M1r,"embellishWithPath");function j1r(a,s,l){let _={type:Zo.Property,parent:a,name:null,value:null};if(_.name={value:"pathPattern",type:Zo.Identifier,parent:_},s.pathMode===d8e)_.value=UT.createLiteral(s.path,_);else{let h=/{(\S+?)}/gm,b=":$1",w=Fht(l)?s.path:s.path.replace(/([*+?()[\].|^$\\:])/g,"\\$1");w=w.replace(h,b),s.path.endsWith("/")||(w=`${w}{/}?`),_.value=UT.createLiteral(w,_)}ZI(a),a.children.unshift(_)}t(j1r,"embellishWithPathPattern");function B1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"methods",type:Zo.Identifier,parent:l},l.value=UT.createArrayOfLiterals(s.httpMethods,l),ZI(a),a.children.unshift(l)}t(B1r,"embellishWithMethods");function $1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"raw",type:Zo.Identifier,parent:a};let _=NG(s.oasFileName,s.path,s.rawOperation);l.value={type:Zo.Raw,parent:l,value:`() => {return rawRouteData.${_};}`},ZI(a),a.children.unshift(l)}t($1r,"embellishWithRawOpenApi");function U1r(a,s){let l={type:Zo.Property,parent:a,name:null,value:null};l.name={value:"metadata",type:Zo.Identifier,parent:a};let _={type:Zo.Property,parent:l,name:null,value:null};_.name={value:"filepath",type:Zo.Identifier,parent:_},_.value=UT.createLiteral(s.oasProjectRelativePath,_),l.value={type:Zo.Object,parent:l,children:[_]},ZI(a),a.children.unshift(l)}t(U1r,"embellishWithMetadata");function z1r(a){return RA(a.type==="property"),RA(Array.isArray(a.children)),HG(a.children[I1r])}t(z1r,"evaluatePathItem");function Aht(a){return RA(a.type==="property"),RA(Array.isArray(a.children)),HG(a.children[N1r])}t(Aht,"evaluatePath");function Nht(a,s){return G4e(a.parent,s)}t(Nht,"extractZuploRouteNode");function Lht(a){return HG(a)}t(Lht,"evaluateZuploRouteNode");function J1r(a,s){let l=/{(\S+?)}/gm,h=a.replace(l,"${params.$1}"),b=HG(s);return{export:"urlRewriteHandler",module:"$import(@zuplo/runtime)",options:{rewritePattern:`${b.servers&&b.servers.length>0?b.servers[0].url:"http://example.com"}${h}`,forwardSearch:!0}}}t(J1r,"addDefaultUrlRewriteHandler");async function q1r(a,s){let l=Lht(a),_=l.handler.module.replace(/^\$import\(/,"").replace(/\)$/,""),h=PK.join(PK.dirname(s.fileName),"..",`${_}.ts`),b=l.handler.export;if(_==="@zuplo/runtime")return{valid:!0};if(await ou.fileExists(h)){let w=await cpt(h);if(w===null)return{valid:!1,errorMsg:`Could not find any export due to a compile error in '${ou.getParentDirFilename(h)}'`};if(!w.has(b)){let N=`Could not find export "${b}" in '${ou.getParentDirFilename(h)}'`,B=0,q=0;if(a.children)for(let le of a.children)le.children&&le.children.forEach(se=>{se.value==="handler"&&(B=se.line,q=se.column)});return{valid:!1,errorMsg:N,line:B,column:q}}return{valid:!0}}else return{valid:!1,errorMsg:`Could not find module '${_}'`}}t(q1r,"checkModuleIsValid");var Iht=t((a,s)=>{let l=0,_=0;if(a.children)for(let h of a.children)h.children&&h.children.forEach(b=>{b.value==="options"&&b.children?.forEach(w=>{b.value===s&&(l=w.line,_=w.column)})});return{line:l,column:_}},"getHandlerOptionLocation"),V1r="$env(";function W1r(a,s){let l=Lht(a),_=l.handler.export;if(_!=="urlForwardHandler"&&_!=="urlRewriteHandler")return{valid:!0};let h="rewritePattern";_==="urlForwardHandler"&&(h="baseUrl");let b=l.handler.options[h];if(!b){let w=Iht(a,h);return{valid:!1,errors:[{text:`Invalid request handler configuration. handler.options.${h} is required but was not provided.`,location:{file:s.fileName,line:w.line,column:w.column}}]}}if(b.includes(V1r)){let w=Iht(a,h);return{valid:!0,warnings:[{text:`Invalid environment variable access syntax detected. Use \${env.VAR_NAME} instead of $env(VAR_NAME) for handler.options.${h}.`,location:{file:s.fileName,line:w.line,column:w.column}}]}}return{valid:!0}}t(W1r,"checkHandlerIsValid");import Q1r from"node:fs/promises";import evr from"node:path";var{stringify:H1r}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");var Hfe={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},pC=17,G1r={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:pC,ClassExpression:pC,FunctionExpression:pC,ObjectExpression:pC,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function Xj(a,s){let{generator:l}=a;if(a.write("("),s!=null&&s.length>0){l[s[0].type](s[0],a);let{length:_}=s;for(let h=1;h<_;h++){let b=s[h];a.write(", "),l[b.type](b,a)}}a.write(")")}t(Xj,"formatSequence");function zht(a,s,l,_){let h=a.expressionsPrecedence[s.type];if(h===pC)return!0;let b=a.expressionsPrecedence[l.type];return h!==b?!_&&h===15&&b===14&&l.operator==="**"||h<b:h!==13&&h!==14?!1:s.operator==="**"&&l.operator==="**"?!_:h===13&&b===13&&(s.operator==="??"||l.operator==="??")?!0:_?Hfe[s.operator]<=Hfe[l.operator]:Hfe[s.operator]<Hfe[l.operator]}t(zht,"expressionNeedsParenthesis");function Gfe(a,s,l,_){let{generator:h}=a;zht(a,s,l,_)?(a.write("("),h[s.type](s,a),a.write(")")):h[s.type](s,a)}t(Gfe,"formatExpression");function K1r(a,s,l,_){let h=s.split(`
|
|
607
607
|
`),b=h.length-1;if(a.write(h[0].trim()),b>0){a.write(_);for(let w=1;w<b;w++)a.write(l+h[w].trim()+_);a.write(l+h[b].trim())}}t(K1r,"reindent");function iv(a,s,l,_){let{length:h}=s;for(let b=0;b<h;b++){let w=s[b];a.write(l),w.type[0]==="L"?a.write("// "+w.value.trim()+`
|
|
608
608
|
`,w):(a.write("/*"),K1r(a,w.value,l,_),a.write("*/"+_))}}t(iv,"formatComments");function Y1r(a){let s=a;for(;s!=null;){let{type:l}=s;if(l[0]==="C"&&l[1]==="a")return!0;if(l[0]==="M"&&l[1]==="e"&&l[2]==="m")s=s.object;else return!1}}t(Y1r,"hasCallExpression");function h8e(a,s){let{generator:l}=a,{declarations:_}=s;a.write(s.kind+" ");let{length:h}=_;if(h>0){l.VariableDeclarator(_[0],a);for(let b=1;b<h;b++)a.write(", "),l.VariableDeclarator(_[b],a)}}t(h8e,"formatVariableDeclaration");var Rht,Mht,jht,Bht,$ht,Uht,X1r={Program(a,s){let l=s.indent.repeat(s.indentLevel),{lineEnd:_,writeComments:h}=s;h&&a.comments!=null&&iv(s,a.comments,l,_);let b=a.body,{length:w}=b;for(let N=0;N<w;N++){let B=b[N];h&&B.comments!=null&&iv(s,B.comments,l,_),s.write(l),this[B.type](B,s),s.write(_)}h&&a.trailingComments!=null&&iv(s,a.trailingComments,l,_)},BlockStatement:Uht=t(function(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s,b=l+s.indent;s.write("{");let w=a.body;if(w!=null&&w.length>0){s.write(_),h&&a.comments!=null&&iv(s,a.comments,b,_);let{length:N}=w;for(let B=0;B<N;B++){let q=w[B];h&&q.comments!=null&&iv(s,q.comments,b,_),s.write(b),this[q.type](q,s),s.write(_)}s.write(l)}else h&&a.comments!=null&&(s.write(_),iv(s,a.comments,b,_),s.write(l));h&&a.trailingComments!=null&&iv(s,a.trailingComments,b,_),s.write("}"),s.indentLevel--},"BlockStatement"),ClassBody:Uht,StaticBlock(a,s){s.write("static "),this.BlockStatement(a,s)},EmptyStatement(a,s){s.write(";")},ExpressionStatement(a,s){let l=s.expressionsPrecedence[a.expression.type];l===pC||l===3&&a.expression.left.type[0]==="O"?(s.write("("),this[a.expression.type](a.expression,s),s.write(")")):this[a.expression.type](a.expression,s),s.write(";")},IfStatement(a,s){s.write("if ("),this[a.test.type](a.test,s),s.write(") "),this[a.consequent.type](a.consequent,s),a.alternate!=null&&(s.write(" else "),this[a.alternate.type](a.alternate,s))},LabeledStatement(a,s){this[a.label.type](a.label,s),s.write(": "),this[a.body.type](a.body,s)},BreakStatement(a,s){s.write("break"),a.label!=null&&(s.write(" "),this[a.label.type](a.label,s)),s.write(";")},ContinueStatement(a,s){s.write("continue"),a.label!=null&&(s.write(" "),this[a.label.type](a.label,s)),s.write(";")},WithStatement(a,s){s.write("with ("),this[a.object.type](a.object,s),s.write(") "),this[a.body.type](a.body,s)},SwitchStatement(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s;s.indentLevel++;let b=l+s.indent,w=b+s.indent;s.write("switch ("),this[a.discriminant.type](a.discriminant,s),s.write(") {"+_);let{cases:N}=a,{length:B}=N;for(let q=0;q<B;q++){let le=N[q];h&&le.comments!=null&&iv(s,le.comments,b,_),le.test?(s.write(b+"case "),this[le.test.type](le.test,s),s.write(":"+_)):s.write(b+"default:"+_);let{consequent:se}=le,{length:te}=se;for(let Ue=0;Ue<te;Ue++){let Ie=se[Ue];h&&Ie.comments!=null&&iv(s,Ie.comments,w,_),s.write(w),this[Ie.type](Ie,s),s.write(_)}}s.indentLevel-=2,s.write(l+"}")},ReturnStatement(a,s){s.write("return"),a.argument&&(s.write(" "),this[a.argument.type](a.argument,s)),s.write(";")},ThrowStatement(a,s){s.write("throw "),this[a.argument.type](a.argument,s),s.write(";")},TryStatement(a,s){if(s.write("try "),this[a.block.type](a.block,s),a.handler){let{handler:l}=a;l.param==null?s.write(" catch "):(s.write(" catch ("),this[l.param.type](l.param,s),s.write(") ")),this[l.body.type](l.body,s)}a.finalizer&&(s.write(" finally "),this[a.finalizer.type](a.finalizer,s))},WhileStatement(a,s){s.write("while ("),this[a.test.type](a.test,s),s.write(") "),this[a.body.type](a.body,s)},DoWhileStatement(a,s){s.write("do "),this[a.body.type](a.body,s),s.write(" while ("),this[a.test.type](a.test,s),s.write(");")},ForStatement(a,s){if(s.write("for ("),a.init!=null){let{init:l}=a;l.type[0]==="V"?h8e(s,l):this[l.type](l,s)}s.write("; "),a.test&&this[a.test.type](a.test,s),s.write("; "),a.update&&this[a.update.type](a.update,s),s.write(") "),this[a.body.type](a.body,s)},ForInStatement:Rht=t(function(a,s){s.write(`for ${a.await?"await ":""}(`);let{left:l}=a;l.type[0]==="V"?h8e(s,l):this[l.type](l,s),s.write(a.type[3]==="I"?" in ":" of "),this[a.right.type](a.right,s),s.write(") "),this[a.body.type](a.body,s)},"ForInStatement"),ForOfStatement:Rht,DebuggerStatement(a,s){s.write("debugger;",a)},FunctionDeclaration:Mht=t(function(a,s){s.write((a.async?"async ":"")+(a.generator?"function* ":"function ")+(a.id?a.id.name:""),a),Xj(s,a.params),s.write(" "),this[a.body.type](a.body,s)},"FunctionDeclaration"),FunctionExpression:Mht,VariableDeclaration(a,s){h8e(s,a),s.write(";")},VariableDeclarator(a,s){this[a.id.type](a.id,s),a.init!=null&&(s.write(" = "),this[a.init.type](a.init,s))},ClassDeclaration(a,s){if(s.write("class "+(a.id?`${a.id.name} `:""),a),a.superClass){s.write("extends ");let{superClass:l}=a,{type:_}=l,h=s.expressionsPrecedence[_];(_[0]!=="C"||_[1]!=="l"||_[5]!=="E")&&(h===pC||h<s.expressionsPrecedence.ClassExpression)?(s.write("("),this[a.superClass.type](l,s),s.write(")")):this[l.type](l,s),s.write(" ")}this.ClassBody(a.body,s)},ImportDeclaration(a,s){s.write("import ");let{specifiers:l,attributes:_}=a,{length:h}=l,b=0;if(h>0){for(;b<h;){b>0&&s.write(", ");let w=l[b],N=w.type[6];if(N==="D")s.write(w.local.name,w),b++;else if(N==="N")s.write("* as "+w.local.name,w),b++;else break}if(b<h){for(s.write("{");;){let w=l[b],{name:N}=w.imported;if(s.write(N,w),N!==w.local.name&&s.write(" as "+w.local.name),++b<h)s.write(", ");else break}s.write("}")}s.write(" from ")}if(this.Literal(a.source,s),_&&_.length>0){s.write(" with { ");for(let w=0;w<_.length;w++)this.ImportAttribute(_[w],s),w<_.length-1&&s.write(", ");s.write(" }")}s.write(";")},ImportAttribute(a,s){this.Identifier(a.key,s),s.write(": "),this.Literal(a.value,s)},ImportExpression(a,s){s.write("import("),this[a.source.type](a.source,s),s.write(")")},ExportDefaultDeclaration(a,s){s.write("export default "),this[a.declaration.type](a.declaration,s),s.expressionsPrecedence[a.declaration.type]!=null&&a.declaration.type[0]!=="F"&&s.write(";")},ExportNamedDeclaration(a,s){if(s.write("export "),a.declaration)this[a.declaration.type](a.declaration,s);else{s.write("{");let{specifiers:l}=a,{length:_}=l;if(_>0)for(let h=0;;){let b=l[h],{name:w}=b.local;if(s.write(w,b),w!==b.exported.name&&s.write(" as "+b.exported.name),++h<_)s.write(", ");else break}if(s.write("}"),a.source&&(s.write(" from "),this.Literal(a.source,s)),a.attributes&&a.attributes.length>0){s.write(" with { ");for(let h=0;h<a.attributes.length;h++)this.ImportAttribute(a.attributes[h],s),h<a.attributes.length-1&&s.write(", ");s.write(" }")}s.write(";")}},ExportAllDeclaration(a,s){if(a.exported!=null?s.write("export * as "+a.exported.name+" from "):s.write("export * from "),this.Literal(a.source,s),a.attributes&&a.attributes.length>0){s.write(" with { ");for(let l=0;l<a.attributes.length;l++)this.ImportAttribute(a.attributes[l],s),l<a.attributes.length-1&&s.write(", ");s.write(" }")}s.write(";")},MethodDefinition(a,s){a.static&&s.write("static ");let l=a.kind[0];(l==="g"||l==="s")&&s.write(a.kind+" "),a.value.async&&s.write("async "),a.value.generator&&s.write("*"),a.computed?(s.write("["),this[a.key.type](a.key,s),s.write("]")):this[a.key.type](a.key,s),Xj(s,a.value.params),s.write(" "),this[a.value.body.type](a.value.body,s)},ClassExpression(a,s){this.ClassDeclaration(a,s)},ArrowFunctionExpression(a,s){s.write(a.async?"async ":"",a);let{params:l}=a;l!=null&&(l.length===1&&l[0].type[0]==="I"?s.write(l[0].name,l[0]):Xj(s,a.params)),s.write(" => "),a.body.type[0]==="O"?(s.write("("),this.ObjectExpression(a.body,s),s.write(")")):this[a.body.type](a.body,s)},ThisExpression(a,s){s.write("this",a)},Super(a,s){s.write("super",a)},RestElement:jht=t(function(a,s){s.write("..."),this[a.argument.type](a.argument,s)},"RestElement"),SpreadElement:jht,YieldExpression(a,s){s.write(a.delegate?"yield*":"yield"),a.argument&&(s.write(" "),this[a.argument.type](a.argument,s))},AwaitExpression(a,s){s.write("await ",a),Gfe(s,a.argument,a)},TemplateLiteral(a,s){let{quasis:l,expressions:_}=a;s.write("`");let{length:h}=_;for(let w=0;w<h;w++){let N=_[w],B=l[w];s.write(B.value.raw,B),s.write("${"),this[N.type](N,s),s.write("}")}let b=l[l.length-1];s.write(b.value.raw,b),s.write("`")},TemplateElement(a,s){s.write(a.value.raw,a)},TaggedTemplateExpression(a,s){Gfe(s,a.tag,a),this[a.quasi.type](a.quasi,s)},ArrayExpression:$ht=t(function(a,s){if(s.write("["),a.elements.length>0){let{elements:l}=a,{length:_}=l;for(let h=0;;){let b=l[h];if(b!=null&&this[b.type](b,s),++h<_)s.write(", ");else{b==null&&s.write(", ");break}}}s.write("]")},"ArrayExpression"),ArrayPattern:$ht,ObjectExpression(a,s){let l=s.indent.repeat(s.indentLevel++),{lineEnd:_,writeComments:h}=s,b=l+s.indent;if(s.write("{"),a.properties.length>0){s.write(_),h&&a.comments!=null&&iv(s,a.comments,b,_);let w=","+_,{properties:N}=a,{length:B}=N;for(let q=0;;){let le=N[q];if(h&&le.comments!=null&&iv(s,le.comments,b,_),s.write(b),this[le.type](le,s),++q<B)s.write(w);else break}s.write(_),h&&a.trailingComments!=null&&iv(s,a.trailingComments,b,_),s.write(l+"}")}else h?a.comments!=null?(s.write(_),iv(s,a.comments,b,_),a.trailingComments!=null&&iv(s,a.trailingComments,b,_),s.write(l+"}")):a.trailingComments!=null?(s.write(_),iv(s,a.trailingComments,b,_),s.write(l+"}")):s.write("}"):s.write("}");s.indentLevel--},Property(a,s){a.method||a.kind[0]!=="i"?this.MethodDefinition(a,s):(a.shorthand||(a.computed?(s.write("["),this[a.key.type](a.key,s),s.write("]")):this[a.key.type](a.key,s),s.write(": ")),this[a.value.type](a.value,s))},PropertyDefinition(a,s){if(a.static&&s.write("static "),a.computed&&s.write("["),this[a.key.type](a.key,s),a.computed&&s.write("]"),a.value==null){a.key.type[0]!=="F"&&s.write(";");return}s.write(" = "),this[a.value.type](a.value,s),s.write(";")},ObjectPattern(a,s){if(s.write("{"),a.properties.length>0){let{properties:l}=a,{length:_}=l;for(let h=0;this[l[h].type](l[h],s),++h<_;)s.write(", ")}s.write("}")},SequenceExpression(a,s){Xj(s,a.expressions)},UnaryExpression(a,s){if(a.prefix){let{operator:l,argument:_,argument:{type:h}}=a;s.write(l);let b=zht(s,_,a);!b&&(l.length>1||h[0]==="U"&&(h[1]==="n"||h[1]==="p")&&_.prefix&&_.operator[0]===l&&(l==="+"||l==="-"))&&s.write(" "),b?(s.write(l.length>1?" (":"("),this[h](_,s),s.write(")")):this[h](_,s)}else this[a.argument.type](a.argument,s),s.write(a.operator)},UpdateExpression(a,s){a.prefix?(s.write(a.operator),this[a.argument.type](a.argument,s)):(this[a.argument.type](a.argument,s),s.write(a.operator))},AssignmentExpression(a,s){this[a.left.type](a.left,s),s.write(" "+a.operator+" "),this[a.right.type](a.right,s)},AssignmentPattern(a,s){this[a.left.type](a.left,s),s.write(" = "),this[a.right.type](a.right,s)},BinaryExpression:Bht=t(function(a,s){let l=a.operator==="in";l&&s.write("("),Gfe(s,a.left,a,!1),s.write(" "+a.operator+" "),Gfe(s,a.right,a,!0),l&&s.write(")")},"BinaryExpression"),LogicalExpression:Bht,ConditionalExpression(a,s){let{test:l}=a,_=s.expressionsPrecedence[l.type];_===pC||_<=s.expressionsPrecedence.ConditionalExpression?(s.write("("),this[l.type](l,s),s.write(")")):this[l.type](l,s),s.write(" ? "),this[a.consequent.type](a.consequent,s),s.write(" : "),this[a.alternate.type](a.alternate,s)},NewExpression(a,s){s.write("new ");let l=s.expressionsPrecedence[a.callee.type];l===pC||l<s.expressionsPrecedence.CallExpression||Y1r(a.callee)?(s.write("("),this[a.callee.type](a.callee,s),s.write(")")):this[a.callee.type](a.callee,s),Xj(s,a.arguments)},CallExpression(a,s){let l=s.expressionsPrecedence[a.callee.type];l===pC||l<s.expressionsPrecedence.CallExpression?(s.write("("),this[a.callee.type](a.callee,s),s.write(")")):this[a.callee.type](a.callee,s),a.optional&&s.write("?."),Xj(s,a.arguments)},ChainExpression(a,s){this[a.expression.type](a.expression,s)},MemberExpression(a,s){let l=s.expressionsPrecedence[a.object.type];l===pC||l<s.expressionsPrecedence.MemberExpression?(s.write("("),this[a.object.type](a.object,s),s.write(")")):this[a.object.type](a.object,s),a.computed?(a.optional&&s.write("?."),s.write("["),this[a.property.type](a.property,s),s.write("]")):(a.optional?s.write("?."):s.write("."),this[a.property.type](a.property,s))},MetaProperty(a,s){s.write(a.meta.name+"."+a.property.name,a)},Identifier(a,s){s.write(a.name,a)},PrivateIdentifier(a,s){s.write(`#${a.name}`,a)},Literal(a,s){a.raw!=null?s.write(a.raw,a):a.regex!=null?this.RegExpLiteral(a,s):a.bigint!=null?s.write(a.bigint+"n",a):s.write(H1r(a.value),a)},RegExpLiteral(a,s){let{regex:l}=a;s.write(`/${l.pattern}/${l.flags}`,a)}},Z1r={};var g8e=class{static{t(this,"State")}constructor(s){let l=s??Z1r;this.output="",l.output!=null?(this.output=l.output,this.write=this.writeToStream):this.output="",this.generator=l.generator!=null?l.generator:X1r,this.expressionsPrecedence=l.expressionsPrecedence!=null?l.expressionsPrecedence:G1r,this.indent=l.indent!=null?l.indent:" ",this.lineEnd=l.lineEnd!=null?l.lineEnd:`
|
|
609
609
|
`,this.indentLevel=l.startingIndentLevel!=null?l.startingIndentLevel:0,this.writeComments=l.comments?l.comments:!1,l.sourceMap!=null&&(this.write=l.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=l.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
|
|
610
610
|
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:l.sourceMap.file||l.sourceMap._file})}write(s){this.output+=s}writeToStream(s){this.output.write(s)}writeAndMap(s,l){this.output+=s,this.map(s,l)}writeToStreamAndMap(s,l){this.output.write(s),this.map(s,l)}map(s,l){if(l!=null){let{type:b}=l;if(b[0]==="L"&&b[2]==="n"){this.column=0,this.line++;return}if(l.loc!=null){let{mapping:w}=this;w.original=l.loc.start,w.name=l.name,this.sourceMap.addMapping(w)}if(b[0]==="T"&&b[8]==="E"||b[0]==="L"&&b[1]==="i"&&typeof l.value=="string"){let{length:w}=s,{column:N,line:B}=this;for(let q=0;q<w;q++)s[q]===`
|
|
611
|
-
`?(N=0,B++):N++;this.column=N,this.line=B;return}}let{length:_}=s,{lineEnd:h}=this;_>0&&(this.lineEndSize>0&&(h.length===1?s[_-1]===h:s.endsWith(h))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function Jht(a,s){let l=new g8e(s);return l.generator[a.type](a,l),l.output}t(Jht,"generate");async function y8e({oasFiles:a,sourceDirectory:s,logger:l}){let _=await tvr({oasFiles:a,sourceDirectory:s,logger:l});return Jht(_)}t(y8e,"generateRawRouteSource");async function tvr({oasFiles:a,sourceDirectory:s,logger:l}){let _=new WI(s,l),h=[];for(let w of a){let N=evr.basename(w,".oas.json"),B=await _.resolve(w),q=[],le=new Map,se=await Q1r.readFile(w,"utf-8"),te=JSON.parse(se);for(let Ue in te.paths){let Ie=te.paths[Ue],De=Ie.parameters||[],Tt={};Ie.summary&&(Tt.pathSummary=Ie.summary),Ie.description&&(Tt.pathDescription=Ie.description),Ie.servers&&(Tt.pathServers=Ie.servers);for(let mt in Ie){if(!Wfe(mt))continue;let hr=Ie[mt],rn=[...De,...hr.parameters||[]],jr={...hr,...rn.length>0&&{parameters:rn},...Tt,...hr.description&&{description:hr.description.length>350
|
|
612
|
-
export default environment;`;function Qht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:Zht,pluginName:Xht,path:Yht.join(a.sourceDirectory,Wg,"environment.js")})),s.onLoad({filter:/.*/,namespace:Zht},async l=>({contents:svr,loader:"ts",resolveDir:Yht.dirname(l.path),pluginName:Xht}))}}}t(Qht,"environmentPlugin");import cCr from"node:fs/promises";import ZT from"node:path";var u1t=Rd(uFe(),1),f1t=Rd(Iyt(),1),_1t=Rd(LFe(),1),p1t=Rd(RFe(),1);import{performance as bC}from"node:perf_hooks";var cY=[];async function sCr(a,s){let l=bC.now();try{return await s()}finally{let _=bC.now()-l;cY.push({name:a,duration:_})}}t(sCr,"timeFn");var aCr={mark:t(a=>{bC.mark(a)},"mark"),measure:t((a,s,l)=>{try{bC.measure(a,s,l)}finally{bC.clearMarks(s),bC.clearMarks(l),bC.clearMeasures(a)}},"measure"),timeFn:sCr,report:t(()=>{if(cY.length>0){let a=cY.reduce((s,{name:l,duration:_})=>(s[l]=`${_.toFixed(0)}ms`,s),{});console.table(a),cY.length=0}},"report"),getDuration:t(a=>{let s=bC.getEntriesByName(a);if(s.length===0)return 0;let l=s[0].duration;return bC.clearMeasures(a),l},"getDuration"),clear:t(()=>{cY.length=0,bC.clearMarks(),bC.clearMeasures()},"clear")},zu=aCr;import{writeFile as oCr}from"node:fs/promises";async function Nk(a,s){await ou.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await oCr(a,_,"utf-8")}t(Nk,"writeDebugSourceFile");var Ik="schemas",N_e="json-schema";function d1t(a){return{name:Ik,async setup(s){let l=new _1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0}),_=ZT.join(a.sourceDirectory,zH),h=[],b=[],w;await zu.timeFn("Initializing schema validation",async()=>{if((0,f1t.default)(l,{mode:"fast"}),l.opts.code.formats=u1t._`require("ajv-formats/dist/formats").fastFormats`,await ou.dirExists(_)&&(l.addKeyword("faker"),w=(await ou.listFolderContents(_,zH)).sort(),await Promise.all(w.map(async N=>{try{let B=ou.safePath(a.sourceDirectory).resolve(_,N);if(!B.startsWith(_))throw new Error("All schemas must be in the schemas directory");let q=await cCr.readFile(B,"utf-8");if(q===""||q===void 0)throw new Error(`Schema 'schemas/${N}' is empty and will be ignored.`);let le=JSON.parse(q);if(le.$schema&&le.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${N}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(l.addSchema(le,N),l.errors?.length){let se=l.errors[0];h.push({id:"json-schema-validation-error",pluginName:Ik,text:`Error: ${se.message}`,location:{file:ZT.join(zH,N)},detail:{params:se.params,propertyName:se.propertyName,schemaPath:se.schemaPath,data:se.data}})}}catch(B){if(B.message.endsWith("is empty and will be ignored.")){b.push({id:"empty-json-schema-file",pluginName:Ik,text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let q=await v8e(N,a.sourceDirectory,B.message);h.push({id:"json-schema-add-error",pluginName:Ik,text:`Error: ${B.message}`,location:q,detail:"InvalidAddSchemaError",notes:[{text:B.message}]})}})),await Promise.all(w.map(async N=>{try{let B=l.getSchema(N);B&&l.compile(B.schema).errors?.forEach(le=>{h.push({text:`Failed to compile ${N}: ${le.message}`})})}catch(B){let q=await v8e(N,a.sourceDirectory,B.message);h.push({id:"json-schema-compile-error",pluginName:Ik,text:`The schema file '${N}' is not valid. Error: ${B.message}`,location:q,detail:"InvalidSchemaError",notes:[{text:B.message}]})}})),lh.DEBUG_BUILD_MODE)){let N=ZT.resolve(a.outputDirectory,zH);await ou.mkdirIfNotExists(N)}}),s.onStart(async()=>{if(w)return{errors:h,warnings:b}}),s.onResolve({filter:/schemas\/.*\.json$/},async N=>zu.timeFn("Generating JSON schemas...",async()=>{let B=ZT.isAbsolute(N.path)?N.path:ZT.join(N.resolveDir,N.path);if(N.importer&&N.namespace!=="open-api-routes-json")return{path:B};if(!await ou.fileExists(B)){let q="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${N.path}' from ${q}`,location:{file:ZT.join(N.resolveDir,q),namespace:N_e,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${q}`,suggestion:""},detail:"RouteReferenceError",pluginName:Ik,notes:[{text:`Unable to resolve reference to '${N.path}' from ${q}`,location:null}]}],namespace:N_e,path:B,pluginName:Ik}}return{path:B,namespace:N_e,pluginName:Ik}})),s.onLoad({filter:/.*/,namespace:N_e},async N=>zu.timeFn(`Generating json schema data: ${ZT.basename(N.path)}`,async()=>{let B=[],q;try{let le=ZT.relative(_,N.path),se=l.getSchema(le);if(!se)throw new Error(`Could not load schema at ${N.path}`);q=se.source?.validateCode;let te=l.compile(se.schema);q=(0,p1t.default)(l,te)}catch(le){B.push({pluginName:Ik,text:`Cannot parse project's schemas/${ZT.basename(N.path)} file. Error: ${le.message}`,location:null,notes:[{text:le.message,location:null}],detail:le})}if(lh.DEBUG_BUILD_MODE&&q){let le=ZT.relative(_,N.path),se=ZT.join(a.sourceDirectory,Wg,`${le}.js`);await Nk(se,q)}return{contents:q,errors:B,pluginName:Ik,resolveDir:ZT.dirname(N.path),watchFiles:[N.path]}}))}}}t(d1t,"jsonSchemaPlugin");import{relative as lCr}from"node:path";var m1t=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],uCr="nodejs-compat-plugin";function h1t({sourceDirectory:a}){return{name:uCr,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:h,resolveDir:b,...w})=>{let N=`${_}:${h}:${b}:${w.importer}`;if(l.has(N))return;l.add(N);let B=await s.resolve(_,{kind:h,resolveDir:b,importer:w.importer});return B.errors.length>0?m1t.includes(_)||_.includes("/")&&m1t.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:B.errors.map(le=>({...le,location:{file:lCr(a,w.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${_}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:B})}}}t(h1t,"nodejsCompatPlugin");import g1t from"node:fs/promises";import SC from"node:path";var y4="open-api-routes-plugin",lY="open-api-routes-json";function y1t(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/zuplo:routes$/},l=>({watchFiles:[...MFe(SC.join(a.sourceDirectory,K1),[".oas.json"],!0),SC.join(a.sourceDirectory,K1,yle)],namespace:lY,path:SC.isAbsolute(l.path)?l.path:SC.join(l.resolveDir,l.path),pluginName:y4})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:lY},async l=>zu.timeFn("Generating route data...",async()=>{async function _(){let b=SC.resolve(a.sourceDirectory,"config"),w=await _7(b),N=`$import(.${l.path.replace(/^../,"")})`;return{location:await Nct(w,N,"Update your route configuration to use code from the 'modules' folder"),originalImportValue:N}}t(_,"getLocation");let h=SC.join(l.resolveDir,`${l.path}.ts`);if(l.path.endsWith(".ts")){let{location:b,originalImportValue:w}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference '${w}' in ${b?.file??"OpenAPI file"}. Imports must NOT include the '.ts' file extension.`,location:b,detail:"RouteReferenceError",pluginName:y4}],namespace:lY,path:l.path,pluginName:y4}}else if(!await ou.fileExists(h)){let{location:b,originalImportValue:w}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference in route. Unable to resolve reference to '${w}' in ${b?.file??"OpenAPI file"}`,location:b,detail:"RouteReferenceError",pluginName:y4}],namespace:lY,path:l.path,pluginName:y4}}})),s.onLoad({filter:/.*/,namespace:lY},async l=>zu.timeFn("Generating route.json data",async()=>{let _=SC.resolve(a.sourceDirectory,"config"),h=await _7(_),b=await Promise.all(h.map(async q=>({content:await g1t.readFile(q,"utf-8"),fileName:q}))),w=SC.resolve(_,"policies.json");if(!await ou.fileExists(w))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:y4,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:y4};let N={content:await g1t.readFile(w,"utf-8"),fileName:w},B;try{B=await m8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:N,compatibilityDate:a.config.compatibilityDate,allowDuplicateRoutes:a.config.allowDuplicateRoutes})}catch(q){throw new Error("Error compiling routes: "+q.message)}if(lh.DEBUG_BUILD_MODE&&B.content){let q=SC.join(a.sourceDirectory,Wg),le=SC.resolve(q,"routes.js");await Nk(le,B.content)}return{contents:B.content,errors:B.errors,pluginName:y4,resolveDir:SC.dirname(l.path),watchFiles:[l.path]}}))}}}t(y1t,"openApiRoutesPlugin");import I_e from"node:path";var uY="raw-route-plugin",v1t="raw-route";function b1t(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/zuplo:raw-routes$/},l=>({namespace:v1t,path:l.path,pluginName:uY})),s.onLoad({filter:/.*/,namespace:v1t},async l=>zu.timeFn("Building route data",async()=>{let _=I_e.resolve(a.sourceDirectory,K1);if(!await ou.dirExists(_))return{loader:"js",resolveDir:I_e.dirname(l.path),pluginName:uY};let h=await _7(_);try{let b=await y8e({oasFiles:h,sourceDirectory:a.sourceDirectory,logger:a.logger});if(lh.DEBUG_BUILD_MODE&&b){let w=I_e.join(a.sourceDirectory,Wg,"raw-routes.js");await Nk(w,b)}return{contents:b,loader:"js",resolveDir:I_e.dirname(l.path),pluginName:uY}}catch(b){if(b instanceof G1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:uY}],pluginName:uY};throw b}}))}}}t(b1t,"rawRoutePlugin");import fCr from"node:fs/promises";import S1t from"node:path";var O_e="runtime-extensions-plugin",T1t="runtime-extensions";function x1t(a){return{name:O_e,setup(s){s.onResolve({filter:/zuplo:runtime-extension$/},l=>({namespace:T1t,path:l.path,pluginName:O_e})),s.onLoad({filter:/.*/,namespace:T1t},async()=>zu.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=S1t.resolve(a.sourceDirectory,Xat,"zuplo.runtime.ts"),h=[];return await ou.fileExists(_)?(l=await fCr.readFile(_,"utf-8"),{contents:l,loader:"ts",resolveDir:S1t.dirname(_),errors:h,pluginName:O_e,watchFiles:[_]}):{contents:l,loader:"ts",errors:h,pluginName:O_e}}))}}}t(x1t,"runtimeExtensionsPlugin");import C1t from"node:path";import{readFile as _Cr}from"node:fs/promises";import v4 from"node:path";var vB=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(s,l){super(s,l),this.name="DevPortalConfigError",this.filename=l?.filename}};async function E1t(a){let s=v4.join(K1,Qat),l=v4.join(a,s),_=!0,h;if(await ou.fileExists(l)){try{let w=await _Cr(l,"utf-8"),N=JSON.parse(w);N.enabled===!1&&(_=!1),h=N.sitePathname}catch(w){throw new vB("Failed to parse dev-portal.json file.",{cause:w,filename:s})}return{enabled:_,type:"legacy",basePath:h,filepath:s}}let b=["zudoku.config.js","zudoku.config.jsx","zudoku.config.ts","zudoku.config.tsx","zudoku.config.mjs"];for(;b.length;){let w=b.pop();if(w){let N=v4.join("docs",w),B=v4.join(a,N);try{if(await ou.fileExists(B))return{enabled:!0,type:"zudoku",basePath:void 0,filepath:N}}catch(q){throw new vB("Failed to read dev portal configuration file.",{cause:q,filename:N})}}}return{enabled:!1,type:void 0,basePath:void 0,filepath:void 0}}t(E1t,"getDevPortalConfig");function bB(a,s){let l=v4.resolve(a,GM);return Object.keys(s?.outputs??{}).map(b=>{let w=v4.normalize(b);return`./${v4.relative(l,w).split(v4.sep).join("/")}`})}t(bB,"getBuildModules");var w1t="/docs",pCr="/__zuplo/dev-portal";function dCr(a){let s=a.trim().toLowerCase();return s.endsWith("/")&&(s=s.slice(0,-1)),s}t(dCr,"normalizePathname");function mCr(a,s){let _={developerPortal:{basePath:a?.basePath===pCr?w1t:a?.basePath?dCr(a.basePath):w1t,enabled:a?a.enabled??!0:!1,type:a?.type??void 0,urls:a?.urls?{defaultUrl:a.urls.defaultUrl,urls:a.urls.urls.map(b=>new URL(b).origin)}:void 0},api:s};return`const runtimeSettings = ${JSON.stringify(_)};
|
|
613
|
-
export default runtimeSettings;`}t(mCr,"generateSource");var fY="runtime-settings-plugin",F_e="runtime-settings";function k1t(a){return{name:fY,setup(s){s.onResolve({filter:/zuplo:runtime-settings$/},l=>({namespace:F_e,path:l.path,pluginName:fY})),s.onLoad({filter:/.*/,namespace:F_e},async()=>zu.timeFn("Generating runtime settings",async()=>{let l=[],_,h;try{let N=await E1t(a.sourceDirectory);h=N.filepath,_={...N,urls:a.urls?.devPortal}}catch(N){let B="Failed to load dev portal config",q="config/dev-portal.json";N instanceof vB&&(B=N.message,q=N.filename??q),l.push({id:"dev-portal-build-error",text:B,location:{file:q,namespace:F_e,line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:fY,notes:[{text:N.message,location:null}]})}let b={urls:a.urls?.api},w;try{if(w=mCr(_,b),lh.DEBUG_BUILD_MODE&&w){let N=C1t.join(a.sourceDirectory,Wg,"dev-portal.js");await Nk(N,w)}}catch(N){l.push({id:"dev-portal-build-error",text:N.message,location:{file:"dev-portal.json",namespace:F_e,line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:fY,notes:[{text:N.message,location:null}]})}return{contents:w,errors:l,pluginName:fY,loader:"js",resolveDir:h?C1t.dirname(h):void 0}}))}}}t(k1t,"runtimeSettingsPlugin");import $Fe from"node:fs/promises";import G7 from"node:path";var P1t=Rd(LFe(),1),A1t=Rd(RFe(),1);var jFe="schema-validation-plugin",D1t="schema-validation",hCr="module.exports = {}";function N1t(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/zuplo:schema-validations$/},l=>({namespace:D1t,path:l.path,pluginName:jFe})),s.onLoad({filter:/.*/,namespace:D1t},async()=>zu.timeFn("Validating schemas",async()=>{let l=G7.resolve(a.sourceDirectory,K1,"policies.json");if(!await ou.fileExists(l))return{contents:hCr,loader:"js",resolveDir:G7.dirname(l),pluginName:jFe};let _=await yCr(a.sourceDirectory),h=G7.resolve(a.sourceDirectory,K1),b=await _7(h),w=await TCr(b,_),N=await gCr({oasFiles:b,routesWithSchemaValidation:w,sourceDirectory:a.sourceDirectory,logger:a.logger});if(lh.DEBUG_BUILD_MODE&&N){let B=G7.join(a.sourceDirectory,Wg,"schema-validation.js");await Nk(B,N)}return{contents:N,loader:"js",resolveDir:G7.dirname(l),pluginName:jFe}}))}}}t(N1t,"schemaValidationPlugin");async function gCr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let h="",b=new WI(l,_);if(s.length===0)return h;let w=new P1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let N of a){let B=await $Fe.readFile(N,"utf-8"),q=G7.basename(N,".oas.json"),le=s.filter(De=>De.fileName===q),se=await b.resolve(N),te=JSON.parse(B),Ue=[],Ie=new Map;le.forEach(De=>{let Tt=te.paths[De.path][De.method];if(Tt.requestBody){let mt;if(Tt.requestBody.$ref){let hr=Tt.requestBody.$ref;mt=se.get(hr)?.content}else Tt.requestBody.content&&(mt=Tt.requestBody.content);if(mt)for(let hr in mt){let rn=mt[hr].schema,jr=_4e(De.path,De.method,hr);rn.$id=jr,w.addSchema(rn),BFe(rn,N,q,w,se,Ue,Ie)}}if(Tt.parameters)for(let mt of Tt.parameters){let hr=mt.$ref?se.get(mt.$ref):mt,rn=hr.schema.$ref?se.get(hr.schema.$ref):hr.schema,jr=f4e(De.path,De.method,hr.in,hr.name);rn.$id=jr,w.addSchema(rn),BFe(hr,N,q,w,se,Ue,Ie)}});for(let De of Ue){let Tt=se.get(De),mt=IG(q,De);w.addSchema(Tt,mt)}}return h=(0,A1t.default)(w),h}t(gCr,"schemaValidationSource");function BFe(a,s,l,_,h,b,w){for(let N in a){let B=a[N];if(N==="$ref"){let q=IG(l,jI(s,B));a[N]=q,_G(s,l,jI(s,B),h,b,w,(le,se,te)=>IG(le,jI(te,se)))}else typeof B=="object"&&BFe(B,s,l,_,h,b,w)}}t(BFe,"addRefsToSchema");async function yCr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await $Fe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return vCr(_,s)}t(yCr,"getPolicyNamesUsingSchemaValidationPolicies");function vCr(a,s){let l=new Set;a.policies?.forEach(h=>{h.handler?.export&&s.has(h.handler.export)&&h.handler.module==="$import(@zuplo/runtime)"&&l.add(h.name)});let _=bCr(a,l);return new Set([...l,..._])}t(vCr,"getPolicyNamesReferencingPolicyHandlers");function bCr(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(h=>{s.has(h)&&l.add(_.name)})}),l}t(bCr,"getCompositePoliciesContainingPolicy");function SCr(a,s){if(!a["x-zuplo-route"]||!a["x-zuplo-route"].policies)return!1;let l=a["x-zuplo-route"].policies.inbound;if(l){for(let h of l)if(s.has(h))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let h of _)if(s.has(h))return!0}return!1}t(SCr,"isPolicyPresentInOperation");async function TCr(a,s){let l=[];for(let _ of a){let h=await $Fe.readFile(_,"utf-8"),w=JSON.parse(h).paths;for(let N in w){let B=w[N];for(let q in B){let le=B[q];SCr(le,s)&&l.push({fileName:G7.basename(_,".oas.json"),path:N,method:q})}}}return l}t(TCr,"getRoutesContainingPolicies");import{mkdirSync as xCr,writeFileSync as ECr}from"node:fs";import CCr from"node:path";function I1t(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=bB(a.sourceDirectory,l.metafile);xCr(a.outputDirectory,{recursive:!0}),ECr(CCr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(I1t,"writeModulesPlugin");var wCr=Cue("zuplo:core:build"),kCr=["workerd","worker","browser"],L1t=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],UFe.resolve(O1t(F1t(import.meta.url)),"..","..","..","node_modules"),UFe.resolve(O1t(F1t(import.meta.url)),"..","..","..","..","..","node_modules")];async function _Y({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:h,minify:b=!0,command:w,config:N,urls:B}){let q=UFe.join(a,ble);wCr(`Building with node paths: ${L1t.join(", ")}`);let le=b&&w!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},se=Object.freeze({sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:h,debugMode:lh.DEBUG_BUILD_MODE,config:N,urls:B});return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:L1t,entryPoints:[q],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...le,external:[],logLevel:"silent",conditions:kCr,plugins:[Qht(se),Kht(se),y1t(se),b1t(se),N1t(se),x1t(se),k1t(se),d1t(se),h1t(se),I1t(se)]}}t(_Y,"getBaseESBuildConfig");var K7="run-esbuild",M1t=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:h,logger:b,config:w,command:N,minify:B,urls:q},{data:le}){b.debug("Running esbuild");let se=await _Y({command:N,minify:B,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,config:w,urls:q}),te;try{if(!await sj(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");te=await R1t.build(se),le.set("metafile",te.metafile)}catch(De){if(b.error(De),De.errors||De.warnings)te=De;else if(De.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))te={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:K7,location:null,notes:[],detail:"Failed to build project because no open-api file was found on the 'config' folder"}],outputFiles:void 0,metafile:void 0,mangleCache:void 0};else throw De}te.errors.length>0&&te.errors.length>1&&(te.errors.length=1);let{errors:Ue,warnings:Ie}=zFe({buildId:h,result:te});return{errors:Ue,warnings:Ie}},"runEsbuild");function zFe({buildId:a,result:s}){return{status:s.errors.length>0?"Failed":s.warnings.length>0?"Warnings":"Good",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:a,warnings:s.warnings.map(_=>_.text==="Using direct eval with a bundler is not recommended and may cause problems"?{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:"We do not support the use of 'eval' or 'new Function(...)'",severity:ple,pluginName:_.pluginName||K7}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:ple,pluginName:_.pluginName||K7}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:Q6e,pluginName:_.pluginName||K7})),metafile:s.metafile}}t(zFe,"esbuildResultToBuildResult");var DCr=t((a,s)=>{let l=s;if(s.includes(a)){let _=new RegExp(`.*(${a})`,"g");l=s.replace(_,"")}return l.match(/^(\/)?(\.\.(\/)?)+/)&&(l=l.replace(/^(\/)?(\.\.(\/)?)+/,"/")),l},"removePrefixFromString"),PCr=t((a,s)=>{let l=s;if(l.includes(a)){let _=new RegExp(`[a-zA-Z0-9-_.\\/]+(${a})`,"g");l=l.replace(_,"")}return l},"cleanFilePathsInMessage"),j1t=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(h=>h.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(h=>{try{h.location&&h.location.file&&(h.location.file=DCr(s,h.location.file)),h.location&&h.location.lineText&&h.location.lineText.includes("@zuplo/core/index.minified.js")&&(h.location.lineText=h.location.lineText.substring(0,200)+"...<Truncated>"),h.message=PCr(s,h.message),h.notes&&h.notes.length>0&&delete h.notes,h.text&&delete h.text,h.pluginName===""&&(h.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function B1t(a,s){let l=JFe.basename(s);a.errors&&(a.errors=j1t(a.errors,l,K7)),a.warnings&&(a.warnings=j1t(a.warnings,l,K7))}t(B1t,"formatBuildResult");var ACr=t(a=>JFe.basename(a).startsWith("."),"isHiddenOnUnix"),NCr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function MFe(a,s=[],l=!1){let _=[],h;if(!L_e.existsSync(a)){let b;if(cG.hasMagic(a))b=a;else{let w=s.map(N=>N.startsWith(".")?N:`.${N}`).join("|");b=`${a}+(${w})`}if(_.push(...cG.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(h=L_e.statSync(a),h.isFile())return[a]}catch{return[]}return L_e.readdirSync(a).forEach(b=>{let w=JFe.join(a,b),N;try{if(N=L_e.statSync(w),N.isDirectory()){l&&_.push(...MFe(w,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!N.isFile()||!NCr(w,s)||ACr(w)||_.push(w)}),_}t(MFe,"lookupFiles");var Y7=new hle,b4=` ${Y7.gray("|")} `;function qFe({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let h=["Building Zuplo API...",`${b4}Build ID: ${s}`,`${b4}Runtime Version: ${l}`];_&&h.push(`${b4}Compatibility Date: ${_}`),a.info(h.join(`
|
|
614
|
-
`))}t(qFe,"outputApiBuildStart");async function R_e(a,s,l){B1t(l,a),await Promise.all(l.warnings.map(async h=>$1t(a,s,h))),await Promise.all(l.errors.map(async h=>$1t(a,s,h)));let _=process.env.CODEBUILD_BUILD_ID?new Date(
|
|
611
|
+
`?(N=0,B++):N++;this.column=N,this.line=B;return}}let{length:_}=s,{lineEnd:h}=this;_>0&&(this.lineEndSize>0&&(h.length===1?s[_-1]===h:s.endsWith(h))?(this.line+=this.lineEndSize,this.column=0):this.column+=_)}toString(){return this.output}};function Jht(a,s){let l=new g8e(s);return l.generator[a.type](a,l),l.output}t(Jht,"generate");async function y8e({oasFiles:a,sourceDirectory:s,logger:l}){let _=await tvr({oasFiles:a,sourceDirectory:s,logger:l});return Jht(_)}t(y8e,"generateRawRouteSource");async function tvr({oasFiles:a,sourceDirectory:s,logger:l}){let _=new WI(s,l),h=[];for(let w of a){let N=evr.basename(w,".oas.json"),B=await _.resolve(w),q=[],le=new Map,se=await Q1r.readFile(w,"utf-8"),te=JSON.parse(se);for(let Ue in te.paths){let Ie=te.paths[Ue],De=Ie.parameters||[],Tt={};Ie.summary&&(Tt.pathSummary=Ie.summary),Ie.description&&(Tt.pathDescription=Ie.description),Ie.servers&&(Tt.pathServers=Ie.servers);for(let mt in Ie){if(!Wfe(mt))continue;let hr=Ie[mt],rn=[...De,...hr.parameters||[]],jr={...hr,...rn.length>0&&{parameters:rn},...Tt,...hr.description&&{description:hr.description.length>350?`${hr.description.substring(0,350).trim()}...`:hr.description}},Qr=NG(N,Ue,mt),br=Kfe(w,N,jr,B,q,le);h.unshift(Vht(Qr,br))}}h.unshift(...rvr(N,B,q,le).reverse())}return{type:"Program",body:h,sourceType:"module"}}t(tvr,"generateAst");function Kfe(a,s,l,_,h,b){let w=[];for(let N in l){let B=l[N];if(N==="$ref")return _G(a,s,jI(a,B),_,h,b),{type:"Identifier",name:Wht(s,b.get(jI(a,B)))};let q;switch(typeof B){case"string":case"number":case"boolean":q={type:"Literal",value:B};break;default:Array.isArray(B)?q=qht(B,a,s,_,h,b):typeof B=="object"&&B!==null&&(q=Kfe(a,s,B,_,h,b));break}if(q){let le=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(N),se=le?{type:"Identifier",name:N}:{type:"Literal",value:N};w.push({type:"Property",key:se,value:q,kind:"init",method:!1,shorthand:!1,computed:!le})}}return{type:"ObjectExpression",properties:w}}t(Kfe,"processNode");function qht(a,s,l,_,h,b){return{type:"ArrayExpression",elements:a.map(w=>{if(Array.isArray(w))return qht(w,s,l,_,h,b);if(typeof w=="object"&&w!==null){let N=Kfe(s,l,w,_,h,b);return N.type==="Identifier"?N:{type:"ObjectExpression",properties:N.properties||[]}}else return{type:"Literal",value:w}})}}t(qht,"processArray");function Vht(a,s){return{type:"ExportNamedDeclaration",declaration:{type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s}],kind:"var"},specifiers:[],source:null}}t(Vht,"createExportedConstAssignment");function rvr(a,s,l,_){let h=[];for(let b=0;b<l.length;b++){let w=Wht(a,b),N=s.get(l[b]),B=Kfe(Gle(l[b]),a,N,s,l,_);h.push(Vht(w,B))}return h}t(rvr,"generateRefs");function Wht(a,s){return`${NA(a)}__ref__${s}`}t(Wht,"getRefIdentifierName");import Hht from"node:path";var Ght=t(a=>{let s=null;if(a.value.type==="Object"&&a.value.members.length>0)for(let l of a.value.members){let _=Ght(l);if(_!==null&&(s=_),l.name.value==="enum"&&l.value.type==="Array"&&l.value.elements.length===0){let h=l.value,b=h.loc.start.line,w=h.loc.start.column,N=h.loc.end.column;s={line:b,column:w,length:N-w,lineText:""}}}return s},"findEmptyEnums"),nvr=t(a=>{if(a.startsWith("schema with key or id")&&a.endsWith("already exists"))return"Update your schema's '$id' to be unique across your project.";if(a.includes("All JSON schemas must use version 2020-12"))return"All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html";if(a==='"nullable" cannot be used without "type"')return'Property "nullable" can only be used when property "type" value is "object".';if(a==='NOT SUPPORTED: keyword "id", use "$id" for schema ID')return'Replace keyword "id" with "$id" when defining a schema Id.';if(a.startsWith("can't resolve reference http"))return"Cannot resolve remote references, try adding them directly to the schema file or as a schema file in the project.";if(a.startsWith("can't resolve reference"))return"Make sure all references are defined in the schema.";if(a.includes("oneOf must NOT have fewer than 1 items"))return'Property "oneOf" must have at least 1 item configured.';if(a.includes("enum must have non-empty array"))return'Property "enum" must be configured with at least one value.';if(a.includes("Unexpected")&&a.includes("in JSON at position"))return"Update your schema to only use valid properties."},"getSuggestions"),v8e=t(async(a,s,l)=>{if(!a)return null;let _={file:Hht.join(BNe,a),suggestion:nvr(l)},h=Hht.join(s,BNe),b=ou.safePath(s).resolve(h,a),w=await Wle(b);if(l.includes("enum must have non-empty array")){if(w){let N=await fG(w);if(N&&N.body.members!==null)for(let B of N.body.members){let q=Ght(B);q&&q!==null&&(_=Object.assign(_??{},q))}if(_){let B=_.line?_.line:0;_.lineText=uG(w,B)}}}else if(l.includes("Unexpected")&&l.includes("in JSON at position")&&w){let N=await fG(w);N&&"lineText"in N&&(_=Object.assign(_??{},N))}return _},"getLocation");import*as R1t from"esbuild";import UFe,{dirname as O1t}from"node:path";import{fileURLToPath as F1t}from"node:url";var b8e=class{static{t(this,"Environment")}get DEV_SERVER_PORT(){return process.env.DEV_SERVER_PORT?parseInt(process.env.DEV_SERVER_PORT,10):3e3}get DEBUG_BUILD_MODE(){return!!process.env.DEBUG_BUILD_MODE}get USE_MONOREPO_PACKAGES(){return process.env.USE_MONOREPO_PACKAGES==="true"}get EXPERIMENTAL_CODEGEN(){return!!process.env.EXPERIMENTAL_CODEGEN}get NODE_ENV(){return process.env.NODE_ENV}isProduction(){return this.NODE_ENV==="production"}isLocalDevelopment(){return process.env.ZUPLO_IS_LOCAL_DEVELOPMENT==="true"}},ivr=new b8e,lh=ivr;var S8e="no-remote-module";function Kht({logger:a}){return{name:S8e,async setup(s){s.onResolve({filter:/^https?:\/\//},l=>(a.error(l,"User attempted to load a remote module"),{errors:[{text:`Remote modules are not supported. Attempted to load module ${l.path}`,detail:"InvalidRemoteModule",pluginName:S8e,location:{line:0,column:0,file:""}}],pluginName:S8e}))}}}t(Kht,"blockRemoteModulePlugin");import Yht from"node:path";var Xht="legacy-environment",Zht="legacy-environment",svr=`import { environment } from "@zuplo/runtime";
|
|
612
|
+
export default environment;`;function Qht(a){return{name:"environment",setup(s){s.onResolve({filter:/@app\/environment$/},()=>({namespace:Zht,pluginName:Xht,path:Yht.join(a.sourceDirectory,Wg,"environment.js")})),s.onLoad({filter:/.*/,namespace:Zht},async l=>({contents:svr,loader:"ts",resolveDir:Yht.dirname(l.path),pluginName:Xht}))}}}t(Qht,"environmentPlugin");import cCr from"node:fs/promises";import ZT from"node:path";var u1t=Rd(uFe(),1),f1t=Rd(Iyt(),1),_1t=Rd(LFe(),1),p1t=Rd(RFe(),1);import{performance as bC}from"node:perf_hooks";var cY=[];async function sCr(a,s){let l=bC.now();try{return await s()}finally{let _=bC.now()-l;cY.push({name:a,duration:_})}}t(sCr,"timeFn");var aCr={mark:t(a=>{bC.mark(a)},"mark"),measure:t((a,s,l)=>{try{bC.measure(a,s,l)}finally{bC.clearMarks(s),bC.clearMarks(l),bC.clearMeasures(a)}},"measure"),timeFn:sCr,report:t(()=>{if(cY.length>0){let a=cY.reduce((s,{name:l,duration:_})=>(s[l]=`${_.toFixed(0)}ms`,s),{});console.table(a),cY.length=0}},"report"),getDuration:t(a=>{let s=bC.getEntriesByName(a);if(s.length===0)return 0;let l=s[0].duration;return bC.clearMeasures(a),l},"getDuration"),clear:t(()=>{cY.length=0,bC.clearMarks(),bC.clearMeasures()},"clear")},zu=aCr;import{writeFile as oCr}from"node:fs/promises";async function Nk(a,s){await ou.mkdirForFilePathIfNotExits(a);let l=await import("prettier"),_=s;try{_=await l.format(s,{parser:"babel"})}catch{}await oCr(a,_,"utf-8")}t(Nk,"writeDebugSourceFile");var Ik="schemas",N_e="json-schema";function d1t(a){return{name:Ik,async setup(s){let l=new _1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0}),_=ZT.join(a.sourceDirectory,zH),h=[],b=[],w;await zu.timeFn("Initializing schema validation",async()=>{if((0,f1t.default)(l,{mode:"fast"}),l.opts.code.formats=u1t._`require("ajv-formats/dist/formats").fastFormats`,await ou.dirExists(_)&&(l.addKeyword("faker"),w=(await ou.listFolderContents(_,zH)).sort(),await Promise.all(w.map(async N=>{try{let B=ou.safePath(a.sourceDirectory).resolve(_,N);if(!B.startsWith(_))throw new Error("All schemas must be in the schemas directory");let q=await cCr.readFile(B,"utf-8");if(q===""||q===void 0)throw new Error(`Schema 'schemas/${N}' is empty and will be ignored.`);let le=JSON.parse(q);if(le.$schema&&le.$schema!=="https://json-schema.org/draft/2020-12/schema")throw new Error(`Error in ${N}: All JSON schemas must use version 2020-12. See release notes for changes: https://json-schema.org/draft/2020-12/release-notes.html`);if(l.addSchema(le,N),l.errors?.length){let se=l.errors[0];h.push({id:"json-schema-validation-error",pluginName:Ik,text:`Error: ${se.message}`,location:{file:ZT.join(zH,N)},detail:{params:se.params,propertyName:se.propertyName,schemaPath:se.schemaPath,data:se.data}})}}catch(B){if(B.message.endsWith("is empty and will be ignored.")){b.push({id:"empty-json-schema-file",pluginName:Ik,text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."},detail:"EmptyJSONSchemaFile",notes:[{text:`Schema 'schemas/${N}' is empty and will be ignored.`,location:{file:`schemas/${N}`,suggestion:"Add schema details or remove the file from the project."}}]});return}let q=await v8e(N,a.sourceDirectory,B.message);h.push({id:"json-schema-add-error",pluginName:Ik,text:`Error: ${B.message}`,location:q,detail:"InvalidAddSchemaError",notes:[{text:B.message}]})}})),await Promise.all(w.map(async N=>{try{let B=l.getSchema(N);B&&l.compile(B.schema).errors?.forEach(le=>{h.push({text:`Failed to compile ${N}: ${le.message}`})})}catch(B){let q=await v8e(N,a.sourceDirectory,B.message);h.push({id:"json-schema-compile-error",pluginName:Ik,text:`The schema file '${N}' is not valid. Error: ${B.message}`,location:q,detail:"InvalidSchemaError",notes:[{text:B.message}]})}})),lh.DEBUG_BUILD_MODE)){let N=ZT.resolve(a.outputDirectory,zH);await ou.mkdirIfNotExists(N)}}),s.onStart(async()=>{if(w)return{errors:h,warnings:b}}),s.onResolve({filter:/schemas\/.*\.json$/},async N=>zu.timeFn("Generating JSON schemas...",async()=>{let B=ZT.isAbsolute(N.path)?N.path:ZT.join(N.resolveDir,N.path);if(N.importer&&N.namespace!=="open-api-routes-json")return{path:B};if(!await ou.fileExists(B)){let q="policies.json";return{errors:[{id:"json-schema-build-error",text:`Unable to resolve reference to '${N.path}' from ${q}`,location:{file:ZT.join(N.resolveDir,q),namespace:N_e,line:1,column:0,length:0,lineText:`Invalid JSON schema reference in ${q}`,suggestion:""},detail:"RouteReferenceError",pluginName:Ik,notes:[{text:`Unable to resolve reference to '${N.path}' from ${q}`,location:null}]}],namespace:N_e,path:B,pluginName:Ik}}return{path:B,namespace:N_e,pluginName:Ik}})),s.onLoad({filter:/.*/,namespace:N_e},async N=>zu.timeFn(`Generating json schema data: ${ZT.basename(N.path)}`,async()=>{let B=[],q;try{let le=ZT.relative(_,N.path),se=l.getSchema(le);if(!se)throw new Error(`Could not load schema at ${N.path}`);q=se.source?.validateCode;let te=l.compile(se.schema);q=(0,p1t.default)(l,te)}catch(le){B.push({pluginName:Ik,text:`Cannot parse project's schemas/${ZT.basename(N.path)} file. Error: ${le.message}`,location:null,notes:[{text:le.message,location:null}],detail:le})}if(lh.DEBUG_BUILD_MODE&&q){let le=ZT.relative(_,N.path),se=ZT.join(a.sourceDirectory,Wg,`${le}.js`);await Nk(se,q)}return{contents:q,errors:B,pluginName:Ik,resolveDir:ZT.dirname(N.path),watchFiles:[N.path]}}))}}}t(d1t,"jsonSchemaPlugin");import{relative as lCr}from"node:path";var m1t=["node:assert","node:async_hooks","node:buffer","node:crypto","node:diagnostics_channel","node:events","node:path","node:process","node:stream","node:string_decoder","node:util"],uCr="nodejs-compat-plugin";function h1t({sourceDirectory:a}){return{name:uCr,setup(s){let l=new Set;s.onStart(()=>{l.clear()}),s.onResolve({filter:/node:.*/},async({path:_,kind:h,resolveDir:b,...w})=>{let N=`${_}:${h}:${b}:${w.importer}`;if(l.has(N))return;l.add(N);let B=await s.resolve(_,{kind:h,resolveDir:b,importer:w.importer});return B.errors.length>0?m1t.includes(_)||_.includes("/")&&m1t.includes(_.split("/")[0])?{external:!0}:{external:!0,warnings:B.errors.map(le=>({...le,location:{file:lCr(a,w.importer),line:0,column:0,namespace:"",length:0,lineText:"",suggestion:"Remove the imported node module"},detail:`The package "${_}" wasn't found on the file system but is built into node. If this code is executed it will fail.`}))}:B})}}}t(h1t,"nodejsCompatPlugin");import g1t from"node:fs/promises";import SC from"node:path";var y4="open-api-routes-plugin",lY="open-api-routes-json";function y1t(a){return{name:"open-api-routes-plugin",setup(s){s.onResolve({filter:/zuplo:routes$/},l=>({watchFiles:[...MFe(SC.join(a.sourceDirectory,K1),[".oas.json"],!0),SC.join(a.sourceDirectory,K1,yle)],namespace:lY,path:SC.isAbsolute(l.path)?l.path:SC.join(l.resolveDir,l.path),pluginName:y4})),s.onResolve({filter:/^\.\.\/modules\/.*/,namespace:lY},async l=>zu.timeFn("Generating route data...",async()=>{async function _(){let b=SC.resolve(a.sourceDirectory,"config"),w=await _7(b),N=`$import(.${l.path.replace(/^../,"")})`;return{location:await Nct(w,N,"Update your route configuration to use code from the 'modules' folder"),originalImportValue:N}}t(_,"getLocation");let h=SC.join(l.resolveDir,`${l.path}.ts`);if(l.path.endsWith(".ts")){let{location:b,originalImportValue:w}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference '${w}' in ${b?.file??"OpenAPI file"}. Imports must NOT include the '.ts' file extension.`,location:b,detail:"RouteReferenceError",pluginName:y4}],namespace:lY,path:l.path,pluginName:y4}}else if(!await ou.fileExists(h)){let{location:b,originalImportValue:w}=await _();return{errors:[{id:"route-build-error",text:`Invalid handler reference in route. Unable to resolve reference to '${w}' in ${b?.file??"OpenAPI file"}`,location:b,detail:"RouteReferenceError",pluginName:y4}],namespace:lY,path:l.path,pluginName:y4}}})),s.onLoad({filter:/.*/,namespace:lY},async l=>zu.timeFn("Generating route.json data",async()=>{let _=SC.resolve(a.sourceDirectory,"config"),h=await _7(_),b=await Promise.all(h.map(async q=>({content:await g1t.readFile(q,"utf-8"),fileName:q}))),w=SC.resolve(_,"policies.json");if(!await ou.fileExists(w))return{errors:[{text:"The project must include a policies file ('/config/policies.json')",detail:"OASPoliciesFileMissing",pluginName:y4,location:{line:0,column:0,file:"/config/policies.json"}}],pluginName:y4};let N={content:await g1t.readFile(w,"utf-8"),fileName:w},B;try{B=await m8e({sourceDirectory:a.sourceDirectory,oasContent:b,policiesContent:N,compatibilityDate:a.config.compatibilityDate,allowDuplicateRoutes:a.config.allowDuplicateRoutes})}catch(q){throw new Error(`Error compiling routes: ${q.message}`)}if(lh.DEBUG_BUILD_MODE&&B.content){let q=SC.join(a.sourceDirectory,Wg),le=SC.resolve(q,"routes.js");await Nk(le,B.content)}return{contents:B.content,errors:B.errors,pluginName:y4,resolveDir:SC.dirname(l.path),watchFiles:[l.path]}}))}}}t(y1t,"openApiRoutesPlugin");import I_e from"node:path";var uY="raw-route-plugin",v1t="raw-route";function b1t(a){return{name:"raw-route-plugin",setup(s){s.onResolve({filter:/zuplo:raw-routes$/},l=>({namespace:v1t,path:l.path,pluginName:uY})),s.onLoad({filter:/.*/,namespace:v1t},async l=>zu.timeFn("Building route data",async()=>{let _=I_e.resolve(a.sourceDirectory,K1);if(!await ou.dirExists(_))return{loader:"js",resolveDir:I_e.dirname(l.path),pluginName:uY};let h=await _7(_);try{let b=await y8e({oasFiles:h,sourceDirectory:a.sourceDirectory,logger:a.logger});if(lh.DEBUG_BUILD_MODE&&b){let w=I_e.join(a.sourceDirectory,Wg,"raw-routes.js");await Nk(w,b)}return{contents:b,loader:"js",resolveDir:I_e.dirname(l.path),pluginName:uY}}catch(b){if(b instanceof G1)return{contents:"",loader:"ts",errors:[{id:"route-build-error",text:b.issue.text,location:b.issue.location,detail:b.issue.detail,pluginName:uY}],pluginName:uY};throw b}}))}}}t(b1t,"rawRoutePlugin");import fCr from"node:fs/promises";import S1t from"node:path";var O_e="runtime-extensions-plugin",T1t="runtime-extensions";function x1t(a){return{name:O_e,setup(s){s.onResolve({filter:/zuplo:runtime-extension$/},l=>({namespace:T1t,path:l.path,pluginName:O_e})),s.onLoad({filter:/.*/,namespace:T1t},async()=>zu.timeFn("Generating zuplo.runtime.ts data",async()=>{let l="export const runtimeInit = undefined;",_=S1t.resolve(a.sourceDirectory,Xat,"zuplo.runtime.ts"),h=[];return await ou.fileExists(_)?(l=await fCr.readFile(_,"utf-8"),{contents:l,loader:"ts",resolveDir:S1t.dirname(_),errors:h,pluginName:O_e,watchFiles:[_]}):{contents:l,loader:"ts",errors:h,pluginName:O_e}}))}}}t(x1t,"runtimeExtensionsPlugin");import C1t from"node:path";import{readFile as _Cr}from"node:fs/promises";import v4 from"node:path";var vB=class extends Error{static{t(this,"DevPortalConfigError")}filename;constructor(s,l){super(s,l),this.name="DevPortalConfigError",this.filename=l?.filename}};async function E1t(a){let s=v4.join(K1,Qat),l=v4.join(a,s),_=!0,h;if(await ou.fileExists(l)){try{let w=await _Cr(l,"utf-8"),N=JSON.parse(w);N.enabled===!1&&(_=!1),h=N.sitePathname}catch(w){throw new vB("Failed to parse dev-portal.json file.",{cause:w,filename:s})}return{enabled:_,type:"legacy",basePath:h,filepath:s}}let b=["zudoku.config.js","zudoku.config.jsx","zudoku.config.ts","zudoku.config.tsx","zudoku.config.mjs"];for(;b.length;){let w=b.pop();if(w){let N=v4.join("docs",w),B=v4.join(a,N);try{if(await ou.fileExists(B))return{enabled:!0,type:"zudoku",basePath:void 0,filepath:N}}catch(q){throw new vB("Failed to read dev portal configuration file.",{cause:q,filename:N})}}}return{enabled:!1,type:void 0,basePath:void 0,filepath:void 0}}t(E1t,"getDevPortalConfig");function bB(a,s){let l=v4.resolve(a,GM);return Object.keys(s?.outputs??{}).map(b=>{let w=v4.normalize(b);return`./${v4.relative(l,w).split(v4.sep).join("/")}`})}t(bB,"getBuildModules");var w1t="/docs",pCr="/__zuplo/dev-portal";function dCr(a){let s=a.trim().toLowerCase();return s.endsWith("/")&&(s=s.slice(0,-1)),s}t(dCr,"normalizePathname");function mCr(a,s){let _={developerPortal:{basePath:a?.basePath===pCr?w1t:a?.basePath?dCr(a.basePath):w1t,enabled:a?a.enabled??!0:!1,type:a?.type??void 0,urls:a?.urls?{defaultUrl:a.urls.defaultUrl,urls:a.urls.urls.map(b=>new URL(b).origin)}:void 0},api:s};return`const runtimeSettings = ${JSON.stringify(_)};
|
|
613
|
+
export default runtimeSettings;`}t(mCr,"generateSource");var fY="runtime-settings-plugin",F_e="runtime-settings";function k1t(a){return{name:fY,setup(s){s.onResolve({filter:/zuplo:runtime-settings$/},l=>({namespace:F_e,path:l.path,pluginName:fY})),s.onLoad({filter:/.*/,namespace:F_e},async()=>zu.timeFn("Generating runtime settings",async()=>{let l=[],_,h;try{let N=await E1t(a.sourceDirectory);h=N.filepath,_={...N,urls:a.urls?.devPortal}}catch(N){let B="Failed to load dev portal config",q="config/dev-portal.json";N instanceof vB&&(B=N.message,q=N.filename??q),l.push({id:"dev-portal-build-error",text:B,location:{file:q,namespace:F_e,line:1,column:0,length:0,lineText:"",suggestion:""},detail:"DevPortalValidationError",pluginName:fY,notes:[{text:N.message,location:null}]})}let b={urls:a.urls?.api},w;try{if(w=mCr(_,b),lh.DEBUG_BUILD_MODE&&w){let N=C1t.join(a.sourceDirectory,Wg,"dev-portal.js");await Nk(N,w)}}catch(N){l.push({id:"dev-portal-build-error",text:N.message,location:{file:"dev-portal.json",namespace:F_e,line:1,column:0,length:0,lineText:"issue",suggestion:""},detail:"DevPortalValidationError",pluginName:fY,notes:[{text:N.message,location:null}]})}return{contents:w,errors:l,pluginName:fY,loader:"js",resolveDir:h?C1t.dirname(h):void 0}}))}}}t(k1t,"runtimeSettingsPlugin");import $Fe from"node:fs/promises";import G7 from"node:path";var P1t=Rd(LFe(),1),A1t=Rd(RFe(),1);var jFe="schema-validation-plugin",D1t="schema-validation",hCr="module.exports = {}";function N1t(a){return{name:"schema-validation-plugin",setup(s){s.onResolve({filter:/zuplo:schema-validations$/},l=>({namespace:D1t,path:l.path,pluginName:jFe})),s.onLoad({filter:/.*/,namespace:D1t},async()=>zu.timeFn("Validating schemas",async()=>{let l=G7.resolve(a.sourceDirectory,K1,"policies.json");if(!await ou.fileExists(l))return{contents:hCr,loader:"js",resolveDir:G7.dirname(l),pluginName:jFe};let _=await yCr(a.sourceDirectory),h=G7.resolve(a.sourceDirectory,K1),b=await _7(h),w=await TCr(b,_),N=await gCr({oasFiles:b,routesWithSchemaValidation:w,sourceDirectory:a.sourceDirectory,logger:a.logger});if(lh.DEBUG_BUILD_MODE&&N){let B=G7.join(a.sourceDirectory,Wg,"schema-validation.js");await Nk(B,N)}return{contents:N,loader:"js",resolveDir:G7.dirname(l),pluginName:jFe}}))}}}t(N1t,"schemaValidationPlugin");async function gCr({oasFiles:a,routesWithSchemaValidation:s,sourceDirectory:l,logger:_}){let h="",b=new WI(l,_);if(s.length===0)return h;let w=new P1t.Ajv2020({code:{source:!0},allErrors:!0,strict:!1,verbose:!0,meta:!0});for(let N of a){let B=await $Fe.readFile(N,"utf-8"),q=G7.basename(N,".oas.json"),le=s.filter(De=>De.fileName===q),se=await b.resolve(N),te=JSON.parse(B),Ue=[],Ie=new Map;le.forEach(De=>{let Tt=te.paths[De.path][De.method];if(Tt.requestBody){let mt;if(Tt.requestBody.$ref){let hr=Tt.requestBody.$ref;mt=se.get(hr)?.content}else Tt.requestBody.content&&(mt=Tt.requestBody.content);if(mt)for(let hr in mt){let rn=mt[hr].schema,jr=_4e(De.path,De.method,hr);rn.$id=jr,w.addSchema(rn),BFe(rn,N,q,w,se,Ue,Ie)}}if(Tt.parameters)for(let mt of Tt.parameters){let hr=mt.$ref?se.get(mt.$ref):mt,rn=hr.schema.$ref?se.get(hr.schema.$ref):hr.schema,jr=f4e(De.path,De.method,hr.in,hr.name);rn.$id=jr,w.addSchema(rn),BFe(hr,N,q,w,se,Ue,Ie)}});for(let De of Ue){let Tt=se.get(De),mt=IG(q,De);w.addSchema(Tt,mt)}}return h=(0,A1t.default)(w),h}t(gCr,"schemaValidationSource");function BFe(a,s,l,_,h,b,w){for(let N in a){let B=a[N];if(N==="$ref"){let q=IG(l,jI(s,B));a[N]=q,_G(s,l,jI(s,B),h,b,w,(le,se,te)=>IG(le,jI(te,se)))}else typeof B=="object"&&BFe(B,s,l,_,h,b,w)}}t(BFe,"addRefsToSchema");async function yCr(a){let s=new Set(["RequestValidationInboundPolicy"]),l=await $Fe.readFile(`${a}/config/policies.json`,"utf-8"),_=JSON.parse(l);return vCr(_,s)}t(yCr,"getPolicyNamesUsingSchemaValidationPolicies");function vCr(a,s){let l=new Set;a.policies?.forEach(h=>{h.handler?.export&&s.has(h.handler.export)&&h.handler.module==="$import(@zuplo/runtime)"&&l.add(h.name)});let _=bCr(a,l);return new Set([...l,..._])}t(vCr,"getPolicyNamesReferencingPolicyHandlers");function bCr(a,s){let l=new Set;return a.policies?.forEach(_=>{_.handler?.export==="CompositeInboundPolicy"&&_.handler?.options?.policies?.forEach(h=>{s.has(h)&&l.add(_.name)})}),l}t(bCr,"getCompositePoliciesContainingPolicy");function SCr(a,s){if(!a["x-zuplo-route"]||!a["x-zuplo-route"].policies)return!1;let l=a["x-zuplo-route"].policies.inbound;if(l){for(let h of l)if(s.has(h))return!0}let _=a["x-zuplo-route"].policies.outbound;if(_){for(let h of _)if(s.has(h))return!0}return!1}t(SCr,"isPolicyPresentInOperation");async function TCr(a,s){let l=[];for(let _ of a){let h=await $Fe.readFile(_,"utf-8"),w=JSON.parse(h).paths;for(let N in w){let B=w[N];for(let q in B){let le=B[q];SCr(le,s)&&l.push({fileName:G7.basename(_,".oas.json"),path:N,method:q})}}}return l}t(TCr,"getRoutesContainingPolicies");import{mkdirSync as xCr,writeFileSync as ECr}from"node:fs";import CCr from"node:path";function I1t(a){return{name:"write-modules-plugin",setup(s){s.onEnd(async l=>{if(l){let _=bB(a.sourceDirectory,l.metafile);xCr(a.outputDirectory,{recursive:!0}),ECr(CCr.join(a.outputDirectory,"modules.json"),JSON.stringify(_,null,2))}})}}}t(I1t,"writeModulesPlugin");var wCr=Cue("zuplo:core:build"),kCr=["workerd","worker","browser"],L1t=[...process.env.GLOBAL_MODULE_LOCATION?[process.env.GLOBAL_MODULE_LOCATION]:[],UFe.resolve(O1t(F1t(import.meta.url)),"..","..","..","node_modules"),UFe.resolve(O1t(F1t(import.meta.url)),"..","..","..","..","..","node_modules")];async function _Y({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,logger:h,minify:b=!0,command:w,config:N,urls:B}){let q=UFe.join(a,ble);wCr(`Building with node paths: ${L1t.join(", ")}`);let le=b&&w!=="dev"&&!process.env.DEBUG_BUILD_DISABLE_MINIFY?{minify:!0,chunkNames:"[hash]"}:{minify:!1,keepNames:!0,chunkNames:"[name]-[hash]"},se=Object.freeze({sourceDirectory:l,outputDirectory:s,cacheDirectory:_,logger:h,debugMode:lh.DEBUG_BUILD_MODE,config:N,urls:B});return{platform:"browser",target:"es2022",outdir:s,splitting:!0,metafile:!0,format:"esm",nodePaths:L1t,entryPoints:[q],sourcemap:"linked",legalComments:"none",treeShaking:!0,bundle:!0,...le,external:[],logLevel:"silent",conditions:kCr,plugins:[Qht(se),Kht(se),y1t(se),b1t(se),N1t(se),x1t(se),k1t(se),d1t(se),h1t(se),I1t(se)]}}t(_Y,"getBaseESBuildConfig");var K7="run-esbuild",M1t=t(async function({systemDirectory:a,outputDirectory:s,sourceDirectory:l,cacheDirectory:_,buildId:h,logger:b,config:w,command:N,minify:B,urls:q},{data:le}){b.debug("Running esbuild");let se=await _Y({command:N,minify:B,systemDirectory:a,outputDirectory:s,cacheDirectory:_,sourceDirectory:l,logger:b,config:w,urls:q}),te;try{if(!await sj(l))throw new Error("Failed to build project because no open-api file was found on the 'config' folder");te=await R1t.build(se),le.set("metafile",te.metafile)}catch(De){if(b.error(De),De.errors||De.warnings)te=De;else if(De.message.includes("Failed to build project because no open-api file was found on the 'config' folder"))te={warnings:[],errors:[{id:"missing-open-api-file",text:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:K7,location:null,notes:[],detail:"Failed to build project because no open-api file was found on the 'config' folder"}],outputFiles:void 0,metafile:void 0,mangleCache:void 0};else throw De}te.errors.length>0&&te.errors.length>1&&(te.errors.length=1);let{errors:Ue,warnings:Ie}=zFe({buildId:h,result:te});return{errors:Ue,warnings:Ie}},"runEsbuild");function zFe({buildId:a,result:s}){return{status:s.errors.length>0?"Failed":s.warnings.length>0?"Warnings":"Good",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:a,warnings:s.warnings.map(_=>_.text==="Using direct eval with a bundler is not recommended and may cause problems"?{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:"We do not support the use of 'eval' or 'new Function(...)'",severity:ple,pluginName:_.pluginName||K7}:{location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:ple,pluginName:_.pluginName||K7}),errors:s.errors.map(_=>({location:_.location,detail:_.detail,id:_.id,notes:_.notes,message:_.text,severity:Q6e,pluginName:_.pluginName||K7})),metafile:s.metafile}}t(zFe,"esbuildResultToBuildResult");var DCr=t((a,s)=>{let l=s;if(s.includes(a)){let _=new RegExp(`.*(${a})`,"g");l=s.replace(_,"")}return l.match(/^(\/)?(\.\.(\/)?)+/)&&(l=l.replace(/^(\/)?(\.\.(\/)?)+/,"/")),l},"removePrefixFromString"),PCr=t((a,s)=>{let l=s;if(l.includes(a)){let _=new RegExp(`[a-zA-Z0-9-_.\\/]+(${a})`,"g");l=l.replace(_,"")}return l},"cleanFilePathsInMessage"),j1t=t((a,s,l)=>{if(!a||a.length<=0)return a;let _=a.filter(h=>h.message!=='Could not resolve "@zuplo/runtime"');return _&&_.length>0&&_.forEach(h=>{try{h.location?.file&&(h.location.file=DCr(s,h.location.file)),h.location?.lineText?.includes("@zuplo/core/index.minified.js")&&(h.location.lineText=`${h.location.lineText.substring(0,200)}...<Truncated>`),h.message=PCr(s,h.message),h.notes&&h.notes.length>0&&delete h.notes,h.text&&delete h.text,h.pluginName===""&&(h.pluginName=l)}catch{}}),_},"cleanDataOnBuildIssue");function B1t(a,s){let l=JFe.basename(s);a.errors&&(a.errors=j1t(a.errors,l,K7)),a.warnings&&(a.warnings=j1t(a.warnings,l,K7))}t(B1t,"formatBuildResult");var ACr=t(a=>JFe.basename(a).startsWith("."),"isHiddenOnUnix"),NCr=t((a,s=[])=>s.map(l=>l.startsWith(".")?l:`.${l}`).some(l=>a.endsWith(l)),"hasMatchingExtname");function MFe(a,s=[],l=!1){let _=[],h;if(!L_e.existsSync(a)){let b;if(cG.hasMagic(a))b=a;else{let w=s.map(N=>N.startsWith(".")?N:`.${N}`).join("|");b=`${a}+(${w})`}if(_.push(...cG.sync(b,{nodir:!0})),!_.length)throw Error(`Cannot find any files matching pattern "${a}"`);return _}try{if(h=L_e.statSync(a),h.isFile())return[a]}catch{return[]}return L_e.readdirSync(a).forEach(b=>{let w=JFe.join(a,b),N;try{if(N=L_e.statSync(w),N.isDirectory()){l&&_.push(...MFe(w,s,l));return}}catch{return}if(!s.length)throw Error(`Argument '${s}' required when argument '${a}' is a directory`);!N.isFile()||!NCr(w,s)||ACr(w)||_.push(w)}),_}t(MFe,"lookupFiles");var Y7=new hle,b4=` ${Y7.gray("|")} `;function qFe({output:a,buildId:s,runtimeVersion:l,compatibilityDate:_}){let h=["Building Zuplo API...",`${b4}Build ID: ${s}`,`${b4}Runtime Version: ${l}`];_&&h.push(`${b4}Compatibility Date: ${_}`),a.info(h.join(`
|
|
614
|
+
`))}t(qFe,"outputApiBuildStart");async function R_e(a,s,l){B1t(l,a),await Promise.all(l.warnings.map(async h=>$1t(a,s,h))),await Promise.all(l.errors.map(async h=>$1t(a,s,h)));let _=process.env.CODEBUILD_BUILD_ID?new Date(Date.now()+1):new Date;l.status==="Good"?s.info(Y7.green("Build succeeded"),{timestamp:_}):l.status==="Warnings"?s.warn(Y7.yellow("Build succeeded with warnings"),{timestamp:_}):l.status==="Failed"&&s.error(Y7.red("Build failed."),{timestamp:_})}t(R_e,"outputBuildResult");async function $1t(a,s,l){let _=[],h=l.severity??"error",b=h==="error"?Y7.red:Y7.yellow,w=b(`${h.toUpperCase()}: ${l.message}${l.detail?`
|
|
615
615
|
${b4}${l.detail.toString().split(`
|
|
616
616
|
`).join(`
|
|
617
|
-
${b4}`)}`:""}`);_.push(w);let N=FCr(l.location??void 0);if(N&&_.push(`${b4}${b(`The error was found in the file: ${N}`)}`),l.location
|
|
617
|
+
${b4}`)}`:""}`);_.push(w);let N=FCr(l.location??void 0);if(N&&_.push(`${b4}${b(`The error was found in the file: ${N}`)}`),l.location?.file&&l.location.column!==0&&l.location.line!==0)try{let B=OCr.join(a,l.location.file),q=await ICr(B,"utf-8"),le=(0,U1t.codeFrameColumns)(q,{start:{line:l.location.line,column:l.location.column}},{highlightCode:!0,message:l.message,linesAbove:3,linesBelow:3});_.push(b4),_.push(le)}catch{}else l.location?.file&&_.push(Y7.red(`${b4}File: ${l.location.file}:${l.location.line}:${l.location.column}`));_.push(""),l.severity==="warning"?s.warn(_.join(`
|
|
618
618
|
`)):s.error(_.join(`
|
|
619
|
-
`))}t($1t,"logIssue");function FCr(a){if(a
|
|
619
|
+
`))}t($1t,"logIssue");function FCr(a){if(a?.file){let s=a.file;if(a.line)return`${s}:${a.line}`;if(a.column)return`${s}:${a.column}`}}t(FCr,"getFileLocation");var QT=class{static{t(this,"PluginResult")}errors=[];warnings=[];constructor(s){s&&this.errors.push(s)}};async function z1t(a,s,l){let _=[],h=[],b=new Map;for await(let w of a)try{let N=await w(s,{data:b,errors:h,warnings:_});if(h.push(...N.errors.map(B=>(B.pluginName===""&&(B.pluginName=w.name),B))),_.push(...N.warnings),N.errors.length>0)break}catch(N){if(N instanceof G1?h.push({...N.issue,pluginName:N.pluginName??"unknown"}):h.push(N),l?.throwOnException)throw N;break}return{errors:h,warnings:_,data:b}}t(z1t,"runPlugins");import{readFile as LCr}from"node:fs/promises";import J1t from"node:path";import{parse as RCr}from"jsonc-parser";var VFe={version:1,compatibilityDate:void 0,allowDuplicateRoutes:!1,allowHostHeaderOverride:!1,flags:{},experimental:{},projectType:"managed-edge"};async function SB(a){let s=J1t.join(a,eot),l=J1t.join(a,tot),_=!1,h=s;await ou.fileExists(s)?(_=!0,h=s):await ou.fileExists(l)&&(_=!0,h=l);let b;if(_){let N=await LCr(h,"utf-8");if(b=RCr(N,[]),typeof b!="object")return{status:JM,errors:[{message:"Invalid zuplo.jsonc file.",detail:"The zuplo.jsonc file is not a valid JSON object",pluginName:"buildData",severity:"error"}]};let q=[];"version"in b&&b.version!==1&&q.push({message:"Invalid version set in zuplo.jsonc file.",detail:"version in zuplo.jsonc must be set to 1",pluginName:"buildData",severity:"error"}),"compatibilityDate"in b&&qM&&typeof b.compatibilityDate=="string"&&(qM.includes(b.compatibilityDate)||q.push({message:"Invalid compatibilityDate set in zuplo.jsonc file.",detail:`compatibilityDate was set to ${b.compatibilityDate}. Valid compatibility dates are ${qM.join(", ")}`,pluginName:"buildData",severity:"error"}));for(let le of["allowDuplicateRoutes","allowHostHeaderOverride"]){let se=b[le];se!==void 0&&typeof se!="boolean"&&q.push({message:`Invalid property type for ${le}`,detail:`The property ${le} must be a boolean.`,pluginName:"buildData",severity:"error"})}if(b.projectType!==void 0&&!["managed-edge","managed-dedicated","self-managed"].includes(b.projectType)&&q.push({message:"Invalid projectType set in zuplo.jsonc file.",detail:`projectType was set to ${b.projectType}. Valid project types are managed-edge, managed-dedicated, self-managed`,pluginName:"buildData",severity:"error"}),q.length>0)return{status:JM,errors:q};b.flags=_le(b.compatibilityDate,b.flags)}else b={version:1,flags:_le(void 0,void 0)};let w={...VFe,...b};return{status:SA,config:w}}t(SB,"getZuploConfig");import MCr from"node:fs";import{mkdir as q1t,readFile as jCr,readdir as BCr,writeFile as $Cr}from"node:fs/promises";import pY from"node:path";import UCr from"node:readline";var V1t=t(async function({sourceDirectory:a,logger:s,outputDirectory:l,deploymentName:_,environmentType:h,urls:b}){return zu.timeFn("Building OpenAPI files",async()=>{s.debug("Building OpenAPI files");let w=pY.join(a,K1),N=pY.join(w,yle),B=pY.join(l,Zat,K1);try{if(await ou.dirExists(l)||await q1t(l),await ou.dirExists(B)||await q1t(B,{recursive:!0}),!await sj(a))return new QT({message:"Failed to build project because no OpenAPI file was found on the 'config' folder",pluginName:"build-open-api-files",severity:"error"});let se=(await BCr(w)).filter(De=>De.endsWith(".oas.json"));if(!await ou.fileExists(N))return new QT({message:"The project must include a policies file ('/config/policies.json')",pluginName:"build-open-api-files",severity:"error"});let te=await jCr(N,"utf-8"),Ue=JSON.parse(te),Ie=t(async De=>{let Tt=pY.join(w,De);if(!await zCr(Tt)){s.debug(`Skipping ${De} as it does not use the OpenAPI handler`);return}let mt;try{mt=await uft({sourceDirectory:a,openApiDocPath:Tt,policiesConfig:Ue,logger:s,environmentType:h,deploymentName:_,urls:b})}catch(jr){if(s.error(jr),jr instanceof SyntaxError||jr instanceof MT.ResolverError||jr instanceof MT.JSONParserError||jr instanceof MT.ParserError||jr instanceof MT.MissingPointerError||jr instanceof S7)return new QT({message:jr.message,location:{file:De,column:0,length:0,line:0,lineText:"",namespace:"",suggestion:""},pluginName:"build-open-api-files",severity:"error"});if(jr instanceof G1)return new QT({...jr.issue,pluginName:"build-open-api-files"});throw jr}let hr=JSON.stringify(mt,null,2),rn=pY.join(B,De);await $Cr(rn,hr,"utf-8")},"processFile");await Promise.all(se.map(Ie))}catch(q){return s.error(q),new QT({message:"Error building OpenAPI files",pluginName:"build-open-api-files",severity:"error"})}return new QT})},"buildOpenApiFiles");async function zCr(a){let s=MCr.createReadStream(a),l=UCr.createInterface({input:s,crlfDelay:1/0}),_=!1,h=!1;for await(let b of l)if(b.includes('"openApiSpecHandler"')&&(_=!0),b.includes('"openApiFilePath"')&&(h=!0),_&&h)break;return l.close(),s.destroy(),_&&h}t(zCr,"usesOpenApiHandler");import JCr from"node:fs/promises";import qCr from"node:path";var W1t=t(async function({outputDirectory:a,systemDirectory:s,cacheDirectory:l,logger:_}){return zu.timeFn("Cleaning output",async()=>{_.debug("Cleaning output");let h=qCr.join(l,"routes");return await Promise.all([a,s,h].map(async b=>{try{await JCr.rm(b,{recursive:!0,force:!0})}catch(w){_.error(w)}})),{warnings:[],errors:[]}})},"cleanOutput");import H1t from"node:fs/promises";var G1t=t(async function({systemDirectory:a,cacheDirectory:s,logger:l}){return zu.timeFn("Creating system directory",async()=>{l.debug("Creating system directory");try{return await Promise.all([H1t.mkdir(a,{recursive:!0}),H1t.mkdir(s,{recursive:!0})]),{warnings:[],errors:[]}}catch(_){return l.error(_),{warnings:[],errors:[]}}return{warnings:[],errors:[]}})},"createSystemDir");var K1t=t(async function({logger:a}){return zu.timeFn("Checking for breaking changes",async()=>(a.debug("Checking for breaking changes"),{warnings:[],errors:[]}))},"checkForDeprecations");import{readFile as VCr,writeFile as WCr}from"node:fs/promises";import HCr from"node:path";var Y1t=t(async function({systemDirectory:a,buildId:s,logger:l,config:_,publicZuploEnvironmentVariables:h}){return zu.timeFn("Generating build data",async()=>{l.debug("Generating build data");let b=await VCr(new URL("../../../package.json",import.meta.url),"utf-8"),w=JSON.parse(b),N={BUILD_ID:s??"",GIT_SHA:process.env.GIT_SHA,TIMESTAMP:new Date().toISOString(),BUILD_ENV:lh.NODE_ENV,ZUPLO_VERSION:w.version,API_VERSION:process.env.API_VERSION,COMPATIBILITY_DATE:_?.compatibilityDate,ACCOUNT_NAME:h?.ZUPLO_ACCOUNT_NAME,PROJECT_NAME:h?.ZUPLO_PROJECT_NAME,ENVIRONMENT_TYPE:h?.ZUPLO_ENVIRONMENT_TYPE,IS_LOCAL_DEVELOPMENT:lh.isLocalDevelopment(),COMPATIBILITY_FLAGS:eNe[_?.compatibilityDate??"none"]},B=JSON.stringify(N,void 0,2),q=HCr.join(a,vle);try{await WCr(q,B.trimStart(),"utf-8")}catch(le){l.error(le);let se={message:`Error creating file at ${q}`,pluginName:"buildData",severity:"error"};return{warnings:[],errors:[se]}}return{warnings:[],errors:[]}})},"generateBuildData");import GCr from"node:fs/promises";import KCr from"node:path";var YCr=`import { Handler, ServiceProviderImpl } from "@zuplo/runtime";
|
|
620
620
|
import routeLoader from "zuplo:routes";
|
|
621
621
|
import * as schemaValidations from "zuplo:schema-validations";
|
|
622
622
|
import { runtimeInit } from "zuplo:runtime-extension";
|
|
@@ -644,12 +644,12 @@ export default {
|
|
|
644
644
|
return handler.requestHandler(request, env, ctx)
|
|
645
645
|
},
|
|
646
646
|
};
|
|
647
|
-
`,X1t=t(async function({systemDirectory:a,logger:s}){return zu.timeFn("Generating Worker shim",async()=>{s.debug("Generating Worker shim");let l=KCr.join(a,ble);try{await GCr.writeFile(l,YCr,"utf-8")}catch(_){s.error(_);let h={message:`Error creating file at ${l}`,pluginName:"generate-worker-entry",severity:"error"};return{warnings:[],errors:[h]}}return{warnings:[],errors:[]}})},"generateWorker");import{readFile as XCr,readdir as ZCr}from"node:fs/promises";import Z1t from"node:path";var M_e="validate-open-api-files",Q1t=t(async function({sourceDirectory:a,logger:s}){return zu.timeFn("Validating OpenAPI files",async()=>{s.debug("Validating OpenAPI files");let l=Z1t.join(a,K1),_=[];try{if(!await sj(a))return new QT({message:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:M_e,severity:"error"});let w=(await ZCr(l)).filter(B=>B.endsWith(".oas.json")),N=t(async B=>{let q=Z1t.join(l,B);try{B==="zp.oas.json"&&_.push({message:"Open API files cannot be named 'zp.oas.json' since 'zp' is a reserved prefix. Update the file name to solve this build issue.",pluginName:M_e,severity:"error"});let le=await XCr(q,"utf-8"),se=JSON.parse(le);if(se
|
|
647
|
+
`,X1t=t(async function({systemDirectory:a,logger:s}){return zu.timeFn("Generating Worker shim",async()=>{s.debug("Generating Worker shim");let l=KCr.join(a,ble);try{await GCr.writeFile(l,YCr,"utf-8")}catch(_){s.error(_);let h={message:`Error creating file at ${l}`,pluginName:"generate-worker-entry",severity:"error"};return{warnings:[],errors:[h]}}return{warnings:[],errors:[]}})},"generateWorker");import{readFile as XCr,readdir as ZCr}from"node:fs/promises";import Z1t from"node:path";var M_e="validate-open-api-files",Q1t=t(async function({sourceDirectory:a,logger:s}){return zu.timeFn("Validating OpenAPI files",async()=>{s.debug("Validating OpenAPI files");let l=Z1t.join(a,K1),_=[];try{if(!await sj(a))return new QT({message:"Failed to build project because no open-api file was found on the 'config' folder",pluginName:M_e,severity:"error"});let w=(await ZCr(l)).filter(B=>B.endsWith(".oas.json")),N=t(async B=>{let q=Z1t.join(l,B);try{B==="zp.oas.json"&&_.push({message:"Open API files cannot be named 'zp.oas.json' since 'zp' is a reserved prefix. Update the file name to solve this build issue.",pluginName:M_e,severity:"error"});let le=await XCr(q,"utf-8"),se=JSON.parse(le);if(se?.paths){let te=Object.entries(se.paths).filter(Ue=>Ue[0]==="zp"||Ue[0]==="/zp");if(te.length>0){let Ue=te.length===1?"includes one route path":`includes '${te.length}' routes`;_.push({message:`Open API file '${B}' ${Ue} that's named '/zp' which is a reserved route name. Updating the route to something other than '/zp' will solve this build issue.`,pluginName:M_e,severity:"error"})}}}catch(le){s.error(le)}},"validateOpenApiFile");await Promise.all(w.map(N))}catch(h){return s.error(h),_.length>0?{errors:_,warnings:[]}:new QT({message:"Failed while validating the open api files in the project",pluginName:M_e,severity:"warning"})}return{errors:_,warnings:[]}})},"validateOpenAPIFiles");import{readFile as ywr,writeFile as vvt}from"node:fs/promises";import vwr from"node:path";var EB=Rd(a5e(),1);import{parse as bwr}from"jsonc-parser";var xB=Rd(a5e(),1);var yvt=t(()=>({include:["modules/**/*",".zuplo/**/*","tests/**/*"],exclude:["./node_modules","./dist"],compilerOptions:{module:xB.ModuleKind.ESNext,target:xB.ScriptTarget.ES2022,moduleResolution:xB.ModuleResolutionKind.Bundler,lib:["ESNext","WebWorker","Webworker.Iterable"],preserveConstEnums:!0,useUnknownInCatchVariables:!1,forceConsistentCasingInFileNames:!0,importHelpers:!0,esModuleInterop:!0,strictNullChecks:!0,noEmit:!0}}),"getZuploTsConfigTemplate");var Q7="validate-tsconfig",bvt=t(async function({sourceDirectory:a,logger:s,command:l,environmentType:_}){return zu.timeFn("Validate TSConfig",async()=>{s.debug("Validate TSConfig");let h=_==="WORKING_COPY"||l==="dev";try{let b=yvt(),w=vwr.join(a,"tsconfig.json");if(!await ou.fileExists(w))return h?(await vvt(w,JSON.stringify(b,null,2)),{warnings:[{message:"This project does not have a tsconfig.json file. The file has been created for you.",severity:"warning",pluginName:Q7,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project does not have a tsconfig.json file.",severity:"error",pluginName:Q7,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let N=await ywr(w,"utf-8"),B=bwr(N);if(!(B&&typeof B=="object"&&"compilerOptions"in B))return h?(await vvt(w,JSON.stringify(b,null,2)),{warnings:[{message:"This project's tsconfig.json file was invalid. A valid file has been written for you.",severity:"warning",pluginName:Q7,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}],errors:[]}):{warnings:[],errors:[{message:"This project's tsconfig.json file is invalid. It must have a compilerOptions.",severity:"error",pluginName:Q7,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}]};let q=EB.default.convertCompilerOptionsFromJson(B.compilerOptions,a);if(q.errors.length>0)return{warnings:[],errors:q.errors.map(Qr=>({severity:"error",pluginName:Q7,message:Qr.messageText.toString(),detail:"You will need to modify your tsconfig.json file to build this project.",helpUrl:"https://zuplo.com/docs/articles/tsconfig",location:Qr.file?{line:Qr.file.getLineStarts()[0],length:Qr.file.getWidth(),file:Qr.file.fileName,column:Qr.file.getStart(),lineText:"",namespace:"",suggestion:""}:void 0}))};if(!B||typeof B!="object")throw new TypeError("The userConfigRaw is not an object, this should not happen.");if(!("compilerOptions"in B)||B.compilerOptions===null||B.compilerOptions===void 0||typeof B.compilerOptions!="object")throw new TypeError("The userConfigRaw.compilerOptions property is not an object, this should not happen.");let le=t((Qr,br,yr)=>`The compiler option '${Qr}' should ${br===void 0?"not be set":`be set to '${typeof br=="string"?br:JSON.stringify(br)}'`}, it was ${yr===void 0?"not set":`set to '${typeof yr=="string"?yr:JSON.stringify(yr)}'`}`,"getMessage"),se="ESNext",te=EB.ModuleKind.ESNext,Ue=[];q.options.module!==te&&Ue.push(le("module",se,B.compilerOptions.module));let Ie="ES2022",De=EB.default.ScriptTarget.ES2022;q.options.target!==De&&Ue.push(le("target",Ie,B.compilerOptions.target));let Tt="Bundler",mt=EB.default.ModuleResolutionKind.Bundler;q.options.moduleResolution!==mt&&Ue.push(le("moduleResolution",Tt,B.compilerOptions.moduleResolution));let hr=["ESNext","WebWorker","Webworker.Iterable"];t(Qr=>{let br=hr.map(Zi=>Zi.toLowerCase()),yr=Qr.map(Zi=>Zi.toLowerCase());return br.every(Zi=>yr.includes(Zi))},"includesAllLibs")(B.compilerOptions.lib??[])||Ue.push(le("lib",hr,B.compilerOptions.lib)),q.options.baseUrl&&Ue.push(le("baseUrl",void 0,B.compilerOptions.baseUrl));let jr=[];return Ue.length>0&&jr.push({message:"This project's tsconfig.json was not set to the recommended settings. Custom settings may cause build issues. For guidance on how to adjust your settings, please visit: https://zuplo.com/docs/articles/tsconfig",severity:"warning",detail:Ue.join(`
|
|
648
648
|
`),pluginName:Q7,helpUrl:"https://zuplo.com/docs/articles/tsconfig"}),{warnings:jr,errors:[]}}catch(b){s.error(b);let w={message:`Error validating tsconfig.json : ${b.message}`,severity:"error",pluginName:Q7};return{warnings:[],errors:[w]}}})},"validateTSConfig");var eF;try{let a=Swr(new URL("../../package.json",import.meta.url),"utf-8");eF=JSON.parse(a).version}catch{eF="0.0.0"}function Twr(a){let{ZUPLO:s,ZUPLO_BUILD_ID:l,ZUPLO_BUILD_CONFIG:_}=process.env;if(s&&l&&_){let h;try{h=JSON.parse(_)}catch{throw new Error("Couuld not parse ZUPLO_BUILD_CONFIG")}let b={ZUPLO_PROJECT_ID:h.projectId,ZUPLO_ACCOUNT_NAME:h.accountName,ZUPLO_PROJECT_NAME:h.projectName,ZUPLO_ENVIRONMENT_TYPE:h.environmentType};for(let[w,N]of Object.entries(process.env))w.startsWith("ZUPLO_PUBLIC_")&&(b[w]=N??"");return{...a,buildId:l,...h,publicZuploEnvironmentVariables:b}}return a}t(Twr,"getBuildConfig");async function o5e(a){let s=performance.now(),{buildId:l,sourceDirectory:_,deploymentName:h=U_e.basename(_),command:b,minify:w,entitlements:N,environmentType:B,logger:q,output:le,noCompile:se=!1,projectId:te,urls:Ue,publicZuploEnvironmentVariables:Ie}=Twr(a),De=await SB(_),Tt=U_e.join(_,GM),mt;if("errors"in De)qFe({output:le.child("api"),buildId:l,runtimeVersion:eF}),mt={status:"Failed",runtimeVersion:eF,outputPath:Tt,buildTime:new Date().toISOString(),buildTimeMs:0,buildId:l,warnings:[],errors:De.errors,metafile:void 0,config:void 0};else{se||qFe({output:le.child("api"),buildId:l,runtimeVersion:eF,compatibilityDate:De.config.compatibilityDate});let jr={command:b,minify:w,deploymentName:h,sourceDirectory:_,outputDirectory:Tt,systemDirectory:U_e.join(_,Wg),cacheDirectory:U_e.join(_,"node_modules",Wg),buildId:l,logger:q,output:le,config:De.config,publicZuploEnvironmentVariables:Ie,projectId:te,entitlements:N,environmentType:B,urls:Ue},Qr=[];Qr.push(W1t),Qr.push(G1t),Qr.push(K1t),Qr.push(Y1t),Qr.push(bvt),Qr.push(Q1t),Qr.push(X1t),se||Qr.push(M1t),Qr.push(V1t);let br=await z1t(Qr,jr),yr=br.errors.length>0?JM:br.warnings.length>0?Z6e:SA,Zi=br.data.get("metafile");mt=yr==="Failed"?{status:yr,config:void 0,runtimeVersion:eF,outputPath:Tt,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:Zi,buildId:l,warnings:br.warnings,errors:br.errors}:{status:yr,config:De.config,runtimeVersion:eF,outputPath:Tt,buildTime:new Date().toISOString(),buildTimeMs:0,metafile:Zi,buildId:l,warnings:br.warnings,errors:br.errors}}mt.warnings.length>0&&mt.warnings.forEach(jr=>{q.warn(jr)}),mt.errors.length>0&&mt.errors.forEach(jr=>{q.error(jr)});let{metafile:hr,...rn}=mt;if(q.debug(rn,"Compiler completed"),mt.buildTimeMs=performance.now()-s,se||await R_e(_,le.child("api"),mt),process.env.ZUPLO_SHOW_PERF){console.log();let jr=mt.buildTimeMs<2e3?"green":mt.buildTimeMs<5e3?"yellow":"red";console.log(D_[jr](`Build time: ${mt.buildTimeMs.toFixed(0)}ms`)),zu.report()}return zu.clear(),mt}t(o5e,"build");import{existsSync as QNr}from"node:fs";import{mkdir as eIr,readFile as tIr}from"node:fs/promises";import FY from"node:path";var Txt=Rd(yLe(),1);import{randomUUID as $2t}from"node:crypto";import v6r from"node:events";import PY from"node:path";import b6r from"chokidar";import*as U2t from"esbuild";var vLe=class extends v6r{static{t(this,"WatchEmitter")}},F4=class{static{t(this,"BuildWatcher")}esbuildContext;emitter=new vLe;envFilesWatcher;outputDirectory;sourceDirectory;command;logger;publicZuploEnvironmentVariables;buildId;output;urls;constructor({sourceDirectory:s,command:l,logger:_,publicZuploEnvironmentVariables:h={},buildId:b,output:w,urls:N}){this.sourceDirectory=s,this.command=l,this.outputDirectory=PY.join(s,GM),this.logger=_,this.publicZuploEnvironmentVariables=h,this.buildId=b,this.output=w,this.urls=N,this.envFilesWatcher=b6r.watch([PY.join(s,".env"),PY.join(s,".env.zuplo")])}watchEnvFiles(){this.envFilesWatcher.on("change",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("add",()=>{this.emitter.emit("reload",null,null)}),this.envFilesWatcher.on("unlink",()=>{this.emitter.emit("reload",null,null)})}onReload=t(s=>{this.emitter.on("reload",s)},"onReload");async start(){let{sourceDirectory:s}=this;if(this.esbuildContext!==void 0)throw new Error("Watcher cannot be started more than once");let l=await o5e({buildId:this.buildId,output:this.output,sourceDirectory:s,noCompile:!0,command:this.command,publicZuploEnvironmentVariables:this.publicZuploEnvironmentVariables,logger:this.logger,urls:this.urls}),_=await _Y({command:this.command,systemDirectory:PY.join(s,Wg),cacheDirectory:PY.join(s,"node_modules",Wg),outputDirectory:this.outputDirectory,sourceDirectory:s,config:l.config??VFe,logger:this.logger,urls:this.urls}),h=this;_.plugins?.push({name:"on-end",setup(b){b.onEnd(w=>{h.logger.debug("Watcher (build) reloaded");let N=zFe({buildId:$2t(),result:w});N.errors.length>0?h.logger.error(N.errors,"Build errors"):h.logger.debug(`Successfully rebuilt watched project. Build id ${N.buildId}`);let B={...N,...l.status==="Good"?{config:l.config}:{config:void 0}};h.emitter.emit("reload",B,null)})}}),this.esbuildContext=await U2t.context(_);try{if((await this.esbuildContext.rebuild()).errors.length>0){let w={status:"Failed",runtimeVersion:"0.0.0",buildTime:"",buildTimeMs:0,buildId:$2t(),warnings:[],errors:[],metafile:void 0,config:void 0};await R_e(s,h.output.child("api"),w),this.logger.error(w.errors,"Build errors")}}catch(b){throw await this.close(),b}await this.esbuildContext.watch()}async close(){try{await this.envFilesWatcher.close(),this.esbuildContext&&(await this.esbuildContext.dispose(),this.logger.debug("ESBuild watcher closed"))}catch(s){this.logger.error(s)}}};import{existsSync as bxt,readFileSync as Sxt}from"node:fs";import Cde from"node:path";var qLe=Rd(H2t(),1);var yxt=Rd(LTt(),1);import{Buffer as HNr}from"node:buffer";import GNr from"node:path";import gxt from"node:child_process";import Ede from"node:process";function NLe(a){let s=typeof a=="string"?`
|
|
649
649
|
`:10,l=typeof a=="string"?"\r":13;return a[a.length-1]===s&&(a=a.slice(0,-1)),a[a.length-1]===l&&(a=a.slice(0,-1)),a}t(NLe,"stripFinalNewline");import hde from"node:process";import NY from"node:path";import{fileURLToPath as RTt}from"node:url";function mde(a={}){let{env:s=process.env,platform:l=process.platform}=a;return l!=="win32"?"PATH":Object.keys(s).reverse().find(_=>_.toUpperCase()==="PATH")||"Path"}t(mde,"pathKey");var oNr=t(({cwd:a=hde.cwd(),path:s=hde.env[mde()],preferLocal:l=!0,execPath:_=hde.execPath,addExecPath:h=!0}={})=>{let b=a instanceof URL?RTt(a):a,w=NY.resolve(b),N=[];return l&&cNr(N,w),h&&lNr(N,_,w),[...N,s].join(NY.delimiter)},"npmRunPath"),cNr=t((a,s)=>{let l;for(;l!==s;)a.push(NY.join(s,"node_modules/.bin")),l=s,s=NY.resolve(s,"..")},"applyPreferLocal"),lNr=t((a,s,l)=>{let _=s instanceof URL?RTt(s):s;a.push(NY.resolve(l,_,".."))},"applyExecPath"),MTt=t(({env:a=hde.env,...s}={})=>{a={...a};let l=mde({env:a});return s.path=a[l],a[l]=oNr(s),a},"npmRunPathEnv");var uNr=t((a,s,l,_)=>{if(l==="length"||l==="prototype"||l==="arguments"||l==="caller")return;let h=Object.getOwnPropertyDescriptor(a,l),b=Object.getOwnPropertyDescriptor(s,l);!fNr(h,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),fNr=t(function(a,s){return a===void 0||a.configurable||a.writable===s.writable&&a.enumerable===s.enumerable&&a.configurable===s.configurable&&(a.writable||a.value===s.value)},"canCopyProperty"),_Nr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),pNr=t((a,s)=>`/* Wrapped ${a}*/
|
|
650
650
|
${s}`,"wrappedToString"),dNr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),mNr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),hNr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,h=pNr.bind(null,_,s.toString());Object.defineProperty(h,"name",mNr),Object.defineProperty(a,"toString",{...dNr,value:h})},"changeToString");function ILe(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let h of Reflect.ownKeys(s))uNr(a,s,h,l);return _Nr(a,s),hNr(a,s,_),a}t(ILe,"mimicFunction");var gde=new WeakMap,jTt=t((a,s={})=>{if(typeof a!="function")throw new TypeError("Expected a function");let l,_=0,h=a.displayName||a.name||"<anonymous>",b=t(function(...w){if(gde.set(b,++_),_===1)l=a.apply(this,w),a=null;else if(s.throw===!0)throw new Error(`Function \`${h}\` can only be called once`);return l},"onetime");return ILe(b,a),gde.set(b,_),b},"onetime");jTt.callCount=a=>{if(!gde.has(a))throw new Error(`The given function \`${a.name}\` is not wrapped by the \`onetime\` package`);return gde.get(a)};var BTt=jTt;import{constants as bNr}from"os";var $Tt=t(function(){let a=OLe-UTt+1;return Array.from({length:a},gNr)},"getRealtimeSignals"),gNr=t(function(a,s){return{name:`SIGRT${s+1}`,number:UTt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),UTt=34,OLe=64;import{constants as yNr}from"os";var zTt=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var FLe=t(function(){let a=$Tt();return[...zTt,...a].map(vNr)},"getSignals"),vNr=t(function({name:a,number:s,description:l,action:_,forced:h=!1,standard:b}){let{signals:{[a]:w}}=yNr,N=w!==void 0;return{name:a,number:N?w:s,description:l,supported:N,action:_,forced:h,standard:b}},"normalizeSignal");var SNr=t(function(){return FLe().reduce(TNr,{})},"getSignalsByName"),TNr=t(function(a,{name:s,number:l,description:_,supported:h,action:b,forced:w,standard:N}){return{...a,[s]:{name:s,number:l,description:_,supported:h,action:b,forced:w,standard:N}}},"getSignalByName"),JTt=SNr(),xNr=t(function(){let a=FLe(),s=OLe+1,l=Array.from({length:s},(_,h)=>ENr(h,a));return Object.assign({},...l)},"getSignalsByNumber"),ENr=t(function(a,s){let l=CNr(a,s);if(l===void 0)return{};let{name:_,description:h,supported:b,action:w,forced:N,standard:B}=l;return{[a]:{name:_,number:a,description:h,supported:b,action:w,forced:N,standard:B}}},"getSignalByNumber"),CNr=t(function(a,s){let l=s.find(({name:_})=>bNr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),jZr=xNr();var wNr=t(({timedOut:a,timeout:s,errorCode:l,signal:_,signalDescription:h,exitCode:b,isCanceled:w})=>a?`timed out after ${s} milliseconds`:w?"was canceled":l!==void 0?`failed with ${l}`:_!==void 0?`was killed with ${_} (${h})`:b!==void 0?`failed with exit code ${b}`:"failed","getErrorPrefix"),LLe=t(({stdout:a,stderr:s,all:l,error:_,signal:h,exitCode:b,command:w,escapedCommand:N,timedOut:B,isCanceled:q,killed:le,parsed:{options:{timeout:se}}})=>{b=b===null?void 0:b,h=h===null?void 0:h;let te=h===void 0?void 0:JTt[h].description,Ue=_&&_.code,De=`Command ${wNr({timedOut:B,timeout:se,errorCode:Ue,signal:h,signalDescription:te,exitCode:b,isCanceled:q})}: ${w}`,Tt=Object.prototype.toString.call(_)==="[object Error]",mt=Tt?`${De}
|
|
651
651
|
${_.message}`:De,hr=[mt,s,a].filter(Boolean).join(`
|
|
652
|
-
`);return Tt?(_.originalMessage=_.message,_.message=hr):_=new Error(hr),_.shortMessage=mt,_.command=w,_.escapedCommand=N,_.exitCode=b,_.signal=h,_.signalDescription=te,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!B,_.isCanceled=q,_.killed=le&&!B,_},"makeError");var yde=["stdin","stdout","stderr"],kNr=t(a=>yde.some(s=>a[s]!==void 0),"hasAlias"),qTt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return yde.map(_=>a[_]);if(kNr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${yde.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,yde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var XTt=Rd(YTt(),1);import DNr from"node:os";var PNr=1e3*5,ZTt=t((a,s="SIGTERM",l={})=>{let _=a(s);return ANr(a,s,l,_),_},"spawnedKill"),ANr=t((a,s,l,_)=>{if(!NNr(s,l,_))return;let h=ONr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),NNr=t((a,{forceKillAfterTimeout:s},l)=>INr(a)&&s!==!1&&l,"shouldForceKill"),INr=t(a=>a===DNr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),ONr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return PNr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),QTt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),FNr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),ext=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((N,B)=>{h=setTimeout(()=>{FNr(a,l,B)},s)}),w=_.finally(()=>{clearTimeout(h)});return Promise.race([b,w])},"setupTimeout"),txt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),rxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,XTt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function nxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(nxt,"isStream");var ULe=Rd(axt(),1),lxt=Rd(cxt(),1);var uxt=t((a,s)=>{s===void 0||a.stdin===void 0||(nxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),fxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,lxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),BLe=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),$Le=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,ULe.default)(a,{encoding:s,maxBuffer:_}):ULe.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),_xt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},w)=>{let N=$Le(a,{encoding:_,buffer:h,maxBuffer:b}),B=$Le(s,{encoding:_,buffer:h,maxBuffer:b}),q=$Le(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([w,N,B,q])}catch(le){return Promise.all([{error:le,signal:le.signal,timedOut:le.timedOut},BLe(a,N),BLe(s,B),BLe(l,q)])}},"getSpawnedResult");var zNr=(async()=>{})().constructor.prototype,JNr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(zNr,a)]),zLe=t((a,s)=>{for(let[l,_]of JNr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),pxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var dxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),qNr=/^[\w.-]+$/,VNr=/"/g,WNr=t(a=>typeof a!="string"||qNr.test(a)?a:`"${a.replace(VNr,'\\"')}"`,"escapeArg"),mxt=t((a,s)=>dxt(a,s).join(" "),"joinCommand"),hxt=t((a,s)=>dxt(a,s).map(l=>WNr(l)).join(" "),"getEscapedCommand");var KNr=1e3*1e3*100,YNr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...Ede.env,...a}:a;return l?MTt({env:b,cwd:_,execPath:h}):b},"getEnv"),XNr=t((a,s,l={})=>{let _=yxt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:KNr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||Ede.cwd(),execPath:Ede.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=YNr(l),l.stdio=qTt(l),Ede.platform==="win32"&&GNr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),JLe=t((a,s,l)=>typeof s!="string"&&!HNr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?NLe(s):s,"handleOutput");function vxt(a,s,l){let _=XNr(a,s,l),h=mxt(a,s),b=hxt(a,s);txt(_.options);let w;try{w=gxt.spawn(_.file,_.args,_.options)}catch(Ue){let Ie=new gxt.ChildProcess,De=Promise.reject(LLe({error:Ue,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return zLe(Ie,De)}let N=pxt(w),B=ext(w,_.options,N),q=rxt(w,_.options,B),le={isCanceled:!1};w.kill=ZTt.bind(null,w.kill.bind(w)),w.cancel=QTt.bind(null,w,le);let te=BTt(t(async()=>{let[{error:Ue,exitCode:Ie,signal:De,timedOut:Tt},mt,hr,rn]=await _xt(w,_.options,q),jr=JLe(_.options,mt),Qr=JLe(_.options,hr),br=JLe(_.options,rn);if(Ue||Ie!==0||De!==null){let yr=LLe({error:Ue,exitCode:Ie,signal:De,stdout:jr,stderr:Qr,all:br,command:h,escapedCommand:b,parsed:_,timedOut:Tt,isCanceled:le.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:w.killed});if(!_.options.reject)return yr;throw yr}return{command:h,escapedCommand:b,exitCode:0,stdout:jr,stderr:Qr,all:br,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return uxt(w,_.options.input),w.all=fxt(w,_.options),zLe(w,te)}t(vxt,"execa");async function wde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await ZNr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),bxt(Cde.join(s,".env.zuplo"))){let l=Sxt(Cde.join(s,".env.zuplo"),"utf8"),_=qLe.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(xue.decode(_[h])).toString(),w=JSON.parse(b);for(let N of Object.keys(w))a[N]=w[N]}}if(bxt(Cde.join(s,".env"))){let l=Sxt(Cde.join(s,".env"),"utf8"),_=qLe.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(wde,"setEnvironment");async function ZNr(a){let s="unknown";try{let{stdout:l}=await vxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(ZNr,"getGitSha");async function rIr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:w,logger:N,handleRuntimeStdio:B}){if(_){let le=FY.join(l,_,"modules.json");if(!QNr(le))throw new Error("The bundled-dir does not contain a modules.json file.");let se=await tIr(le,"utf-8").then(JSON.parse),te=await SB(l);return te.status===SA?new Promise((Ue,Ie)=>{q(te.config.compatibilityDate,FY.join(l,_),se,Ue,B)().catch(De=>{N.error(De),Ie(De)})}):(N.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Ue,Ie)=>{q(void 0,l,se,Ue,B)().catch(De=>{N.error(De),Ie(De)})}))}else{let le=new F4({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:N,publicZuploEnvironmentVariables:w??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await le.start()}catch{N.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((se,te)=>{le.onReload((Ue,Ie)=>{(Ie||Ue&&Ue.errors&&Ue.errors.length>0)&&te(Ie??Ue?.errors),q(Ue?.config?.compatibilityDate,FY.join(l,"dist"),bB(l,Ue?.metafile),se,B)().catch(De=>{N.error(De),te(De)})})})}function q(le,se,te,Ue,Ie){return async()=>{let De={};await wde(De,l);let Tt=new Txt.ZuploWorkerd({compatibilityDate:le,scriptDirectory:se,modules:te,port:h??lh.DEV_SERVER_PORT,bindings:De,handleRuntimeStdio:Ie}),mt=b??"compiled-zup",hr=FY.join(l,"dist");await eIr(hr,{recursive:!0}),await Tt.compileBinary({binaryPath:FY.join(l,"dist",mt)}),await Tt.dispose(),Ue(void 0)}}t(q,"compile")}t(rIr,"compileWorkerdServer");var xxt=Rd(yLe(),1);import iIr from"node:path";import nIr from"node:net";function LY(a,s){return new Promise(l=>{let _=new nIr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(LY,"isPortAvailable");var kde=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??lh.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new F4({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await LY("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await wde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new xxt.ZuploWorkerd({compatibilityDate:s?.config?.compatibilityDate,scriptDirectory:iIr.join(this.sourceDirectory,"dist"),modules:bB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as Dxt}from"node:url";import{Readable as Ext}from"node:stream";import Cxt from"node:assert";import sIr from"node:child_process";import aIr from"node:fs";import Dde from"node:os";import oIr from"node:path";function wxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(aIr.existsSync(h))return Dxt(h)}t(wxt,"getValidExecutablePath");function cIr(){let a=Dde.platform()==="win32"?"deno.exe":"deno",s=wxt("deno/package.json",a);if(s)return s;let l=lIr(),_=wxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(cIr,"locateDenoExecutable");function lIr(){let a=Dde.platform();return a==="linux"?a+"-"+kxt()+"-glibc":a+"-"+kxt()}t(lIr,"getTarget");function kxt(){let a=Dde.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Dde.arch()+". Only x64 and aarch64 binaries are available.");return a}t(kxt,"getArch");var Pde=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;port;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;unsafelyIgnoreCertificateErrors;constructor(s){if(this.port=s.port??9e3,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,this.unsafelyIgnoreCertificateErrors=!!s.unsafelyIgnoreCertificateErrors,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new F4({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=cIr()}getServeArgs(){let s=`${oIr.dirname(Dxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write",...this.unsafelyIgnoreCertificateErrors?["--unsafely-ignore-certificate-errors"]:[]];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l.push("--dir",this.sourceDirectory),l.push("--port",this.port.toString()),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await LY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await LY("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error("The following ports are not available: "+s.join(", "));if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=sIr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Cxt(this.serverProcess.stdout instanceof Ext),Cxt(this.serverProcess.stderr instanceof Ext),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};async function uIr(a){let s=await SB(a),l=!1;return s.status===SA&&(l=s.config.projectType!=="managed-edge"||(s.config.flags?.managedDedicatedFlags?.useZeno??!1)),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(uIr,"useZeno");async function fIr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,unsafelyIgnoreCertificateErrors:h,logger:b,output:w,buildId:N,onReload:B,handleRuntimeStdio:q}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let le;await uIr(a)?(b.debug("Starting managed-dedicated local dev server."),le=new Pde({sourceDirectory:a,port:s,debugPort:l,logger:b,output:w,publicZuploEnvironmentVariables:_,onReload:B,handleRuntimeStdio:q,unsafelyIgnoreCertificateErrors:h})):(b.debug("Starting edge local dev server."),le=new kde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:b,output:w,buildId:N,onReload:B,handleRuntimeStdio:q})),await le.start();async function se(){await le.stop()}t(se,"handle"),process.on("SIGTERM",se),process.on("SIGINT",se)}t(fIr,"startDevServer");var Qy=new URL("./public/",import.meta.url);import{readFile as Ade}from"fs/promises";var _v=class{static{t(this,"BaseComponent")}#e;#n;#t;scriptFile;cssFile;constructor(a){this.#t=a}async getStyles(){return this.cssFile?this.#t?await Ade(this.cssFile,"utf-8"):(this.#e=this.#e??await Ade(this.cssFile,"utf-8"),this.#e):null}async getScript(){return this.scriptFile?this.#t?await Ade(this.scriptFile,"utf-8"):(this.#n=this.#n??await Ade(this.scriptFile,"utf-8"),this.#n):null}};var Pxt=class extends _v{static{t(this,"Layout")}cssFile=new URL("./layout/style.css",Qy);scriptFile=new URL("./layout/script.js",Qy);async toHTML(a){return`<!DOCTYPE html>
|
|
652
|
+
`);return Tt?(_.originalMessage=_.message,_.message=hr):_=new Error(hr),_.shortMessage=mt,_.command=w,_.escapedCommand=N,_.exitCode=b,_.signal=h,_.signalDescription=te,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!B,_.isCanceled=q,_.killed=le&&!B,_},"makeError");var yde=["stdin","stdout","stderr"],kNr=t(a=>yde.some(s=>a[s]!==void 0),"hasAlias"),qTt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return yde.map(_=>a[_]);if(kNr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${yde.map(_=>`\`${_}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let l=Math.max(s.length,yde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var XTt=Rd(YTt(),1);import DNr from"node:os";var PNr=1e3*5,ZTt=t((a,s="SIGTERM",l={})=>{let _=a(s);return ANr(a,s,l,_),_},"spawnedKill"),ANr=t((a,s,l,_)=>{if(!NNr(s,l,_))return;let h=ONr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),NNr=t((a,{forceKillAfterTimeout:s},l)=>INr(a)&&s!==!1&&l,"shouldForceKill"),INr=t(a=>a===DNr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),ONr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return PNr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),QTt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),FNr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),ext=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((N,B)=>{h=setTimeout(()=>{FNr(a,l,B)},s)}),w=_.finally(()=>{clearTimeout(h)});return Promise.race([b,w])},"setupTimeout"),txt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),rxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,XTt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function nxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(nxt,"isStream");var ULe=Rd(axt(),1),lxt=Rd(cxt(),1);var uxt=t((a,s)=>{s===void 0||a.stdin===void 0||(nxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),fxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,lxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),BLe=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),$Le=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,ULe.default)(a,{encoding:s,maxBuffer:_}):ULe.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),_xt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},w)=>{let N=$Le(a,{encoding:_,buffer:h,maxBuffer:b}),B=$Le(s,{encoding:_,buffer:h,maxBuffer:b}),q=$Le(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([w,N,B,q])}catch(le){return Promise.all([{error:le,signal:le.signal,timedOut:le.timedOut},BLe(a,N),BLe(s,B),BLe(l,q)])}},"getSpawnedResult");var zNr=(async()=>{})().constructor.prototype,JNr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(zNr,a)]),zLe=t((a,s)=>{for(let[l,_]of JNr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),pxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var dxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),qNr=/^[\w.-]+$/,VNr=/"/g,WNr=t(a=>typeof a!="string"||qNr.test(a)?a:`"${a.replace(VNr,'\\"')}"`,"escapeArg"),mxt=t((a,s)=>dxt(a,s).join(" "),"joinCommand"),hxt=t((a,s)=>dxt(a,s).map(l=>WNr(l)).join(" "),"getEscapedCommand");var KNr=1e3*1e3*100,YNr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...Ede.env,...a}:a;return l?MTt({env:b,cwd:_,execPath:h}):b},"getEnv"),XNr=t((a,s,l={})=>{let _=yxt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:KNr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||Ede.cwd(),execPath:Ede.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=YNr(l),l.stdio=qTt(l),Ede.platform==="win32"&&GNr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),JLe=t((a,s,l)=>typeof s!="string"&&!HNr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?NLe(s):s,"handleOutput");function vxt(a,s,l){let _=XNr(a,s,l),h=mxt(a,s),b=hxt(a,s);txt(_.options);let w;try{w=gxt.spawn(_.file,_.args,_.options)}catch(Ue){let Ie=new gxt.ChildProcess,De=Promise.reject(LLe({error:Ue,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return zLe(Ie,De)}let N=pxt(w),B=ext(w,_.options,N),q=rxt(w,_.options,B),le={isCanceled:!1};w.kill=ZTt.bind(null,w.kill.bind(w)),w.cancel=QTt.bind(null,w,le);let te=BTt(t(async()=>{let[{error:Ue,exitCode:Ie,signal:De,timedOut:Tt},mt,hr,rn]=await _xt(w,_.options,q),jr=JLe(_.options,mt),Qr=JLe(_.options,hr),br=JLe(_.options,rn);if(Ue||Ie!==0||De!==null){let yr=LLe({error:Ue,exitCode:Ie,signal:De,stdout:jr,stderr:Qr,all:br,command:h,escapedCommand:b,parsed:_,timedOut:Tt,isCanceled:le.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:w.killed});if(!_.options.reject)return yr;throw yr}return{command:h,escapedCommand:b,exitCode:0,stdout:jr,stderr:Qr,all:br,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return uxt(w,_.options.input),w.all=fxt(w,_.options),zLe(w,te)}t(vxt,"execa");async function wde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await ZNr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),bxt(Cde.join(s,".env.zuplo"))){let l=Sxt(Cde.join(s,".env.zuplo"),"utf8"),_=qLe.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(xue.decode(_[h])).toString(),w=JSON.parse(b);for(let N of Object.keys(w))a[N]=w[N]}}if(bxt(Cde.join(s,".env"))){let l=Sxt(Cde.join(s,".env"),"utf8"),_=qLe.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(wde,"setEnvironment");async function ZNr(a){let s="unknown";try{let{stdout:l}=await vxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(ZNr,"getGitSha");async function rIr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:w,logger:N,handleRuntimeStdio:B}){if(_){let le=FY.join(l,_,"modules.json");if(!QNr(le))throw new Error("The bundled-dir does not contain a modules.json file.");let se=await tIr(le,"utf-8").then(JSON.parse),te=await SB(l);return te.status===SA?new Promise((Ue,Ie)=>{q(te.config.compatibilityDate,FY.join(l,_),se,Ue,B)().catch(De=>{N.error(De),Ie(De)})}):(N.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Ue,Ie)=>{q(void 0,l,se,Ue,B)().catch(De=>{N.error(De),Ie(De)})}))}else{let le=new F4({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:N,publicZuploEnvironmentVariables:w??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await le.start()}catch{N.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((se,te)=>{le.onReload((Ue,Ie)=>{(Ie||Ue?.errors&&Ue.errors.length>0)&&te(Ie??Ue?.errors),q(Ue?.config?.compatibilityDate,FY.join(l,"dist"),bB(l,Ue?.metafile),se,B)().catch(De=>{N.error(De),te(De)})})})}function q(le,se,te,Ue,Ie){return async()=>{let De={};await wde(De,l);let Tt=new Txt.ZuploWorkerd({compatibilityDate:le,scriptDirectory:se,modules:te,port:h??lh.DEV_SERVER_PORT,bindings:De,handleRuntimeStdio:Ie}),mt=b??"compiled-zup",hr=FY.join(l,"dist");await eIr(hr,{recursive:!0}),await Tt.compileBinary({binaryPath:FY.join(l,"dist",mt)}),await Tt.dispose(),Ue(void 0)}}t(q,"compile")}t(rIr,"compileWorkerdServer");var xxt=Rd(yLe(),1);import iIr from"node:path";import nIr from"node:net";function LY(a,s){return new Promise(l=>{let _=new nIr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(LY,"isPortAvailable");var kde=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??lh.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new F4({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await LY("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}this.buildWatcher?.onReload((l,_)=>{_||l?.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await wde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new xxt.ZuploWorkerd({compatibilityDate:s?.config?.compatibilityDate,scriptDirectory:iIr.join(this.sourceDirectory,"dist"),modules:bB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as Dxt}from"node:url";import{Readable as Ext}from"node:stream";import Cxt from"node:assert";import sIr from"node:child_process";import aIr from"node:fs";import Dde from"node:os";import oIr from"node:path";function wxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(aIr.existsSync(h))return Dxt(h)}t(wxt,"getValidExecutablePath");function cIr(){let a=Dde.platform()==="win32"?"deno.exe":"deno",s=wxt("deno/package.json",a);if(s)return s;let l=lIr(),_=wxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(cIr,"locateDenoExecutable");function lIr(){let a=Dde.platform();return a==="linux"?`${a}-${kxt()}-glibc`:`${a}-${kxt()}`}t(lIr,"getTarget");function kxt(){let a=Dde.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Dde.arch()+". Only x64 and aarch64 binaries are available.");return a}t(kxt,"getArch");var Pde=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;port;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;unsafelyIgnoreCertificateErrors;constructor(s){if(this.port=s.port??9e3,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,this.unsafelyIgnoreCertificateErrors=!!s.unsafelyIgnoreCertificateErrors,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new F4({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=cIr()}getServeArgs(){let s=`${oIr.dirname(Dxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write",...this.unsafelyIgnoreCertificateErrors?["--unsafely-ignore-certificate-errors"]:[]];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l.push("--dir",this.sourceDirectory),l.push("--port",this.port.toString()),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await LY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await LY("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error(`The following ports are not available: ${s.join(", ")}`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l?.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=sIr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Cxt(this.serverProcess.stdout instanceof Ext),Cxt(this.serverProcess.stderr instanceof Ext),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};async function uIr(a){let s=await SB(a),l=!1;return s.status===SA&&(l=s.config.projectType!=="managed-edge"||(s.config.flags?.managedDedicatedFlags?.useZeno??!1)),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(uIr,"useZeno");async function fIr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,unsafelyIgnoreCertificateErrors:h,logger:b,output:w,buildId:N,onReload:B,handleRuntimeStdio:q}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let le;await uIr(a)?(b.debug("Starting managed-dedicated local dev server."),le=new Pde({sourceDirectory:a,port:s,debugPort:l,logger:b,output:w,publicZuploEnvironmentVariables:_,onReload:B,handleRuntimeStdio:q,unsafelyIgnoreCertificateErrors:h})):(b.debug("Starting edge local dev server."),le=new kde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:b,output:w,buildId:N,onReload:B,handleRuntimeStdio:q})),await le.start();async function se(){await le.stop()}t(se,"handle"),process.on("SIGTERM",se),process.on("SIGINT",se)}t(fIr,"startDevServer");var Qy=new URL("./public/",import.meta.url);import{readFile as Ade}from"fs/promises";var _v=class{static{t(this,"BaseComponent")}#e;#n;#t;scriptFile;cssFile;constructor(a){this.#t=a}async getStyles(){return this.cssFile?this.#t?await Ade(this.cssFile,"utf-8"):(this.#e=this.#e??await Ade(this.cssFile,"utf-8"),this.#e):null}async getScript(){return this.scriptFile?this.#t?await Ade(this.scriptFile,"utf-8"):(this.#n=this.#n??await Ade(this.scriptFile,"utf-8"),this.#n):null}};var Pxt=class extends _v{static{t(this,"Layout")}cssFile=new URL("./layout/style.css",Qy);scriptFile=new URL("./layout/script.js",Qy);async toHTML(a){return`<!DOCTYPE html>
|
|
653
653
|
<html lang="en">
|
|
654
654
|
<head>
|
|
655
655
|
<meta charset="UTF-8" />
|
|
@@ -924,7 +924,7 @@ ${(await ykt(b,l)).split(`
|
|
|
924
924
|
${s}`,scripts:_.join(`
|
|
925
925
|
`)}}async#s(a){if(!this.#n.has(a)){let s=await this.#e[a].getStyles();s&&this.#n.set(a,s)}if(!this.#t.has(a)){let s=await this.#e[a].getScript();s&&this.#t.set(a,s)}}async#p(a,s){let l=this.#e[a];if(!l)throw new Error(`Invalid template "${a}"`);return await this.#s(a),l.toHTML(s)}async#o(a,s){let l=this.#e[a];if(!l)throw new Error(`Invalid template "${a}"`);return l.toANSI(s)}use(a,s){return this.#e[a]=s,this}injectStyles(a){let s=this.#n.get("injected")??"";return s+=`
|
|
926
926
|
${a}`,this.#n.set("injected",s),this}async toHTML(a){let s=await this.#p("layout",{title:a.title,ide:a.ide,cspNonce:a.cspNonce,children:t(async()=>{let h=await this.#p("header",a),b=await this.#p("errorInfo",a),w=await this.#p("errorStack",{ide:process.env.EDITOR??"vscode",sourceCodeRenderer:t((q,le)=>this.#p("errorStackSource",{error:q,frame:le,ide:a.ide,cspNonce:a.cspNonce}),"sourceCodeRenderer"),...a}),N=await this.#p("errorCause",a),B=await this.#p("errorMetadata",a);return`${h}${b}${w}${N}${B}`},"children")}),{scripts:l,styles:_}=this.#r(a.cspNonce);return s.replace("<!-- STYLES -->",_).replace("<!-- SCRIPTS -->",l)}async toANSI(a){return await this.#o("layout",{title:a.title,children:t(async()=>{let l=await this.#o("header",{}),_=await this.#o("errorInfo",a),h=await this.#o("errorStack",{ide:process.env.EDITOR??"vscode",sourceCodeRenderer:t((N,B)=>this.#o("errorStackSource",{error:N,frame:B}),"sourceCodeRenderer"),...a}),b=await this.#o("errorCause",a),w=await this.#o("errorMetadata",a);return`${l}${_}${h}${b}${w}`},"children")})}},$kt=class{static{t(this,"Youch")}#e;#n=[];#t=[];templates=new zOr(!1);metadata=new UOr;#r(a){let s=new Mkt(a);return this.#e&&s.defineSourceLoader(this.#e),this.#n.forEach(l=>s.useParser(l)),this.#t.forEach(l=>s.useTransformer(l)),s}#s(a){!a||Object.keys(a).length===0||this.metadata.group("Request",{...a.url?{url:{key:"URL",value:a.url}}:{},...a.method?{method:{key:"Method",value:a.method}}:{},...a.headers?{headers:Object.keys(a.headers).map(s=>{let l=a.headers[s];return{key:s,value:s==="cookie"?{...Bkt.default.parse(l)}:l}})}:{}})}defineSourceLoader(a){return this.#e=a,this}useParser(a){return this.#n.push(a),this}useTransformer(a){return this.#t.push(a),this}async toJSON(a,s){return s={...s},this.#r({offset:s.offset}).parse(a)}async toHTML(a,s){s={...s},this.#s(s.request);let l=await this.#r({offset:s.offset}).parse(a);return this.templates.toHTML({title:s.title??"An error has occurred",ide:s.ide??process.env.IDE??"vscode",cspNonce:s.cspNonce,error:l,metadata:this.metadata})}async toANSI(a,s){s={...s};let l=await this.#r({offset:s.offset}).parse(a);return this.templates.toANSI({title:"",error:l,metadata:this.metadata})}};import{SourceMapConsumer as qOr}from"source-map";var l$=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,zkt=new Set,vRe=typeof process=="object"&&process?process:{},Jkt=t((a,s,l,_)=>{typeof vRe.emitWarning=="function"?vRe.emitWarning(a,s,l,_):console.error(`[${l}] ${s}: ${a}`)},"emitWarning"),Vde=globalThis.AbortController,Ukt=globalThis.AbortSignal;if(typeof Vde>"u"){Ukt=class{static{t(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(_,h){this._onabort.push(h)}},Vde=class{static{t(this,"AbortController")}constructor(){s()}signal=new Ukt;abort(_){if(!this.signal.aborted){this.signal.reason=_,this.signal.aborted=!0;for(let h of this.signal._onabort)h(_);this.signal.onabort?.(_)}}};let a=vRe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",s=t(()=>{a&&(a=!1,Jkt("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",s))},"warnACPolyfill")}var JOr=t(a=>!zkt.has(a),"shouldWarn"),Grn=Symbol("type"),U4=t(a=>a&&a===Math.floor(a)&&a>0&&isFinite(a),"isPosInt"),qkt=t(a=>U4(a)?a<=Math.pow(2,8)?Uint8Array:a<=Math.pow(2,16)?Uint16Array:a<=Math.pow(2,32)?Uint32Array:a<=Number.MAX_SAFE_INTEGER?u$:null:null,"getUintArray"),u$=class extends Array{static{t(this,"ZeroArray")}constructor(s){super(s),this.fill(0)}},bRe=class a{static{t(this,"Stack")}heap;length;static#e=!1;static create(s){let l=qkt(s);if(!l)return[];a.#e=!0;let _=new a(s,l);return a.#e=!1,_}constructor(s,l){if(!a.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new l(s),this.length=0}push(s){this.heap[this.length++]=s}pop(){return this.heap[--this.length]}},Wde=class a{static{t(this,"LRUCache")}#e;#n;#t;#r;#s;#p;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#_;#u;#c;#i;#a;#h;#m;#f;#d;#g;#y;#E;#T;#C;#w;#v;#x;#A;static unsafeExposeInternals(s){return{starts:s.#T,ttls:s.#C,sizes:s.#E,keyMap:s.#c,keyList:s.#i,valList:s.#a,next:s.#h,prev:s.#m,get head(){return s.#f},get tail(){return s.#d},free:s.#g,isBackgroundFetch:t(l=>s.#S(l),"isBackgroundFetch"),backgroundFetch:t((l,_,h,b)=>s.#j(l,_,h,b),"backgroundFetch"),moveToTail:t(l=>s.#z(l),"moveToTail"),indexes:t(l=>s.#N(l),"indexes"),rindexes:t(l=>s.#I(l),"rindexes"),isStale:t(l=>s.#P(l),"isStale")}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#u}get size(){return this.#_}get fetchMethod(){return this.#p}get memoMethod(){return this.#o}get dispose(){return this.#t}get onInsert(){return this.#r}get disposeAfter(){return this.#s}constructor(s){let{max:l=0,ttl:_,ttlResolution:h=1,ttlAutopurge:b,updateAgeOnGet:w,updateAgeOnHas:N,allowStale:B,dispose:q,onInsert:le,disposeAfter:se,noDisposeOnSet:te,noUpdateTTL:Ue,maxSize:Ie=0,maxEntrySize:De=0,sizeCalculation:Tt,fetchMethod:mt,memoMethod:hr,noDeleteOnFetchRejection:rn,noDeleteOnStaleGet:jr,allowStaleOnFetchRejection:Qr,allowStaleOnFetchAbort:br,ignoreFetchAbort:yr}=s;if(l!==0&&!U4(l))throw new TypeError("max option must be a nonnegative integer");let Zi=l?qkt(l):Array;if(!Zi)throw new Error("invalid max value: "+l);if(this.#e=l,this.#n=Ie,this.maxEntrySize=De||this.#n,this.sizeCalculation=Tt,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(hr!==void 0&&typeof hr!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#o=hr,mt!==void 0&&typeof mt!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#p=mt,this.#v=!!mt,this.#c=new Map,this.#i=new Array(l).fill(void 0),this.#a=new Array(l).fill(void 0),this.#h=new Zi(l),this.#m=new Zi(l),this.#f=0,this.#d=0,this.#g=bRe.create(l),this.#_=0,this.#u=0,typeof q=="function"&&(this.#t=q),typeof le=="function"&&(this.#r=le),typeof se=="function"?(this.#s=se,this.#y=[]):(this.#s=void 0,this.#y=void 0),this.#w=!!this.#t,this.#A=!!this.#r,this.#x=!!this.#s,this.noDisposeOnSet=!!te,this.noUpdateTTL=!!Ue,this.noDeleteOnFetchRejection=!!rn,this.allowStaleOnFetchRejection=!!Qr,this.allowStaleOnFetchAbort=!!br,this.ignoreFetchAbort=!!yr,this.maxEntrySize!==0){if(this.#n!==0&&!U4(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!U4(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#$()}if(this.allowStale=!!B,this.noDeleteOnStaleGet=!!jr,this.updateAgeOnGet=!!w,this.updateAgeOnHas=!!N,this.ttlResolution=U4(h)||h===0?h:1,this.ttlAutopurge=!!b,this.ttl=_||0,this.ttl){if(!U4(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#l()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let Ci="LRU_CACHE_UNBOUNDED";JOr(Ci)&&(zkt.add(Ci),Jkt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ci,a))}}getRemainingTTL(s){return this.#c.has(s)?1/0:0}#l(){let s=new u$(this.#e),l=new u$(this.#e);this.#C=s,this.#T=l,this.#D=(b,w,N=l$.now())=>{if(l[b]=w!==0?N:0,s[b]=w,w!==0&&this.ttlAutopurge){let B=setTimeout(()=>{this.#P(b)&&this.#B(this.#i[b],"expire")},w+1);B.unref&&B.unref()}},this.#O=b=>{l[b]=s[b]!==0?l$.now():0},this.#k=(b,w)=>{if(s[w]){let N=s[w],B=l[w];if(!N||!B)return;b.ttl=N,b.start=B,b.now=_||h();let q=b.now-B;b.remainingTTL=N-q}};let _=0,h=t(()=>{let b=l$.now();if(this.ttlResolution>0){_=b;let w=setTimeout(()=>_=0,this.ttlResolution);w.unref&&w.unref()}return b},"getNow");this.getRemainingTTL=b=>{let w=this.#c.get(b);if(w===void 0)return 0;let N=s[w],B=l[w];if(!N||!B)return 1/0;let q=(_||h())-B;return N-q},this.#P=b=>{let w=l[b],N=s[b];return!!N&&!!w&&(_||h())-w>N}}#O=t(()=>{},"#updateItemAge");#k=t(()=>{},"#statusTTL");#D=t(()=>{},"#setItemTTL");#P=t(()=>!1,"#isStale");#$(){let s=new u$(this.#e);this.#u=0,this.#E=s,this.#R=l=>{this.#u-=s[l],s[l]=0},this.#L=(l,_,h,b)=>{if(this.#S(_))return 0;if(!U4(h))if(b){if(typeof b!="function")throw new TypeError("sizeCalculation must be a function");if(h=b(_,l),!U4(h))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return h},this.#F=(l,_,h)=>{if(s[l]=_,this.#n){let b=this.#n-s[l];for(;this.#u>b;)this.#b(!0)}this.#u+=s[l],h&&(h.entrySize=_,h.totalCalculatedSize=this.#u)}}#R=t(s=>{},"#removeItemSize");#F=t((s,l,_)=>{},"#addItemSize");#L=t((s,l,_,h)=>{if(_||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#N({allowStale:s=this.allowStale}={}){if(this.#_)for(let l=this.#d;!(!this.#U(l)||((s||!this.#P(l))&&(yield l),l===this.#f));)l=this.#m[l]}*#I({allowStale:s=this.allowStale}={}){if(this.#_)for(let l=this.#f;!(!this.#U(l)||((s||!this.#P(l))&&(yield l),l===this.#d));)l=this.#h[l]}#U(s){return s!==void 0&&this.#c.get(this.#i[s])===s}*entries(){for(let s of this.#N())this.#a[s]!==void 0&&this.#i[s]!==void 0&&!this.#S(this.#a[s])&&(yield[this.#i[s],this.#a[s]])}*rentries(){for(let s of this.#I())this.#a[s]!==void 0&&this.#i[s]!==void 0&&!this.#S(this.#a[s])&&(yield[this.#i[s],this.#a[s]])}*keys(){for(let s of this.#N()){let l=this.#i[s];l!==void 0&&!this.#S(this.#a[s])&&(yield l)}}*rkeys(){for(let s of this.#I()){let l=this.#i[s];l!==void 0&&!this.#S(this.#a[s])&&(yield l)}}*values(){for(let s of this.#N())this.#a[s]!==void 0&&!this.#S(this.#a[s])&&(yield this.#a[s])}*rvalues(){for(let s of this.#I())this.#a[s]!==void 0&&!this.#S(this.#a[s])&&(yield this.#a[s])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(s,l={}){for(let _ of this.#N()){let h=this.#a[_],b=this.#S(h)?h.__staleWhileFetching:h;if(b!==void 0&&s(b,this.#i[_],this))return this.get(this.#i[_],l)}}forEach(s,l=this){for(let _ of this.#N()){let h=this.#a[_],b=this.#S(h)?h.__staleWhileFetching:h;b!==void 0&&s.call(l,b,this.#i[_],this)}}rforEach(s,l=this){for(let _ of this.#I()){let h=this.#a[_],b=this.#S(h)?h.__staleWhileFetching:h;b!==void 0&&s.call(l,b,this.#i[_],this)}}purgeStale(){let s=!1;for(let l of this.#I({allowStale:!0}))this.#P(l)&&(this.#B(this.#i[l],"expire"),s=!0);return s}info(s){let l=this.#c.get(s);if(l===void 0)return;let _=this.#a[l],h=this.#S(_)?_.__staleWhileFetching:_;if(h===void 0)return;let b={value:h};if(this.#C&&this.#T){let w=this.#C[l],N=this.#T[l];if(w&&N){let B=w-(l$.now()-N);b.ttl=B,b.start=Date.now()}}return this.#E&&(b.size=this.#E[l]),b}dump(){let s=[];for(let l of this.#N({allowStale:!0})){let _=this.#i[l],h=this.#a[l],b=this.#S(h)?h.__staleWhileFetching:h;if(b===void 0||_===void 0)continue;let w={value:b};if(this.#C&&this.#T){w.ttl=this.#C[l];let N=l$.now()-this.#T[l];w.start=Math.floor(Date.now()-N)}this.#E&&(w.size=this.#E[l]),s.unshift([_,w])}return s}load(s){this.clear();for(let[l,_]of s){if(_.start){let h=Date.now()-_.start;_.start=l$.now()-h}this.set(l,_.value,_)}}set(s,l,_={}){if(l===void 0)return this.delete(s),this;let{ttl:h=this.ttl,start:b,noDisposeOnSet:w=this.noDisposeOnSet,sizeCalculation:N=this.sizeCalculation,status:B}=_,{noUpdateTTL:q=this.noUpdateTTL}=_,le=this.#L(s,l,_.size||0,N);if(this.maxEntrySize&&le>this.maxEntrySize)return B&&(B.set="miss",B.maxEntrySizeExceeded=!0),this.#B(s,"set"),this;let se=this.#_===0?void 0:this.#c.get(s);if(se===void 0)se=this.#_===0?this.#d:this.#g.length!==0?this.#g.pop():this.#_===this.#e?this.#b(!1):this.#_,this.#i[se]=s,this.#a[se]=l,this.#c.set(s,se),this.#h[this.#d]=se,this.#m[se]=this.#d,this.#d=se,this.#_++,this.#F(se,le,B),B&&(B.set="add"),q=!1,this.#A&&this.#r?.(l,s,"add");else{this.#z(se);let te=this.#a[se];if(l!==te){if(this.#v&&this.#S(te)){te.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:Ue}=te;Ue!==void 0&&!w&&(this.#w&&this.#t?.(Ue,s,"set"),this.#x&&this.#y?.push([Ue,s,"set"]))}else w||(this.#w&&this.#t?.(te,s,"set"),this.#x&&this.#y?.push([te,s,"set"]));if(this.#R(se),this.#F(se,le,B),this.#a[se]=l,B){B.set="replace";let Ue=te&&this.#S(te)?te.__staleWhileFetching:te;Ue!==void 0&&(B.oldValue=Ue)}}else B&&(B.set="update");this.#A&&this.onInsert?.(l,s,l===te?"update":"replace")}if(h!==0&&!this.#C&&this.#l(),this.#C&&(q||this.#D(se,h,b),B&&this.#k(B,se)),!w&&this.#x&&this.#y){let te=this.#y,Ue;for(;Ue=te?.shift();)this.#s?.(...Ue)}return this}pop(){try{for(;this.#_;){let s=this.#a[this.#f];if(this.#b(!0),this.#S(s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(this.#x&&this.#y){let s=this.#y,l;for(;l=s?.shift();)this.#s?.(...l)}}}#b(s){let l=this.#f,_=this.#i[l],h=this.#a[l];return this.#v&&this.#S(h)?h.__abortController.abort(new Error("evicted")):(this.#w||this.#x)&&(this.#w&&this.#t?.(h,_,"evict"),this.#x&&this.#y?.push([h,_,"evict"])),this.#R(l),s&&(this.#i[l]=void 0,this.#a[l]=void 0,this.#g.push(l)),this.#_===1?(this.#f=this.#d=0,this.#g.length=0):this.#f=this.#h[l],this.#c.delete(_),this.#_--,l}has(s,l={}){let{updateAgeOnHas:_=this.updateAgeOnHas,status:h}=l,b=this.#c.get(s);if(b!==void 0){let w=this.#a[b];if(this.#S(w)&&w.__staleWhileFetching===void 0)return!1;if(this.#P(b))h&&(h.has="stale",this.#k(h,b));else return _&&this.#O(b),h&&(h.has="hit",this.#k(h,b)),!0}else h&&(h.has="miss");return!1}peek(s,l={}){let{allowStale:_=this.allowStale}=l,h=this.#c.get(s);if(h===void 0||!_&&this.#P(h))return;let b=this.#a[h];return this.#S(b)?b.__staleWhileFetching:b}#j(s,l,_,h){let b=l===void 0?void 0:this.#a[l];if(this.#S(b))return b;let w=new Vde,{signal:N}=_;N?.addEventListener("abort",()=>w.abort(N.reason),{signal:w.signal});let B={signal:w.signal,options:_,context:h},q=t((De,Tt=!1)=>{let{aborted:mt}=w.signal,hr=_.ignoreFetchAbort&&De!==void 0;if(_.status&&(mt&&!Tt?(_.status.fetchAborted=!0,_.status.fetchError=w.signal.reason,hr&&(_.status.fetchAbortIgnored=!0)):_.status.fetchResolved=!0),mt&&!hr&&!Tt)return se(w.signal.reason);let rn=Ue;return this.#a[l]===Ue&&(De===void 0?rn.__staleWhileFetching?this.#a[l]=rn.__staleWhileFetching:this.#B(s,"fetch"):(_.status&&(_.status.fetchUpdated=!0),this.set(s,De,B.options))),De},"cb"),le=t(De=>(_.status&&(_.status.fetchRejected=!0,_.status.fetchError=De),se(De)),"eb"),se=t(De=>{let{aborted:Tt}=w.signal,mt=Tt&&_.allowStaleOnFetchAbort,hr=mt||_.allowStaleOnFetchRejection,rn=hr||_.noDeleteOnFetchRejection,jr=Ue;if(this.#a[l]===Ue&&(!rn||jr.__staleWhileFetching===void 0?this.#B(s,"fetch"):mt||(this.#a[l]=jr.__staleWhileFetching)),hr)return _.status&&jr.__staleWhileFetching!==void 0&&(_.status.returnedStale=!0),jr.__staleWhileFetching;if(jr.__returned===jr)throw De},"fetchFail"),te=t((De,Tt)=>{let mt=this.#p?.(s,b,B);mt&&mt instanceof Promise&&mt.then(hr=>De(hr===void 0?void 0:hr),Tt),w.signal.addEventListener("abort",()=>{(!_.ignoreFetchAbort||_.allowStaleOnFetchAbort)&&(De(void 0),_.allowStaleOnFetchAbort&&(De=t(hr=>q(hr,!0),"res")))})},"pcall");_.status&&(_.status.fetchDispatched=!0);let Ue=new Promise(te).then(q,le),Ie=Object.assign(Ue,{__abortController:w,__staleWhileFetching:b,__returned:void 0});return l===void 0?(this.set(s,Ie,{...B.options,status:void 0}),l=this.#c.get(s)):this.#a[l]=Ie,Ie}#S(s){if(!this.#v)return!1;let l=s;return!!l&&l instanceof Promise&&l.hasOwnProperty("__staleWhileFetching")&&l.__abortController instanceof Vde}async fetch(s,l={}){let{allowStale:_=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:b=this.noDeleteOnStaleGet,ttl:w=this.ttl,noDisposeOnSet:N=this.noDisposeOnSet,size:B=0,sizeCalculation:q=this.sizeCalculation,noUpdateTTL:le=this.noUpdateTTL,noDeleteOnFetchRejection:se=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:te=this.allowStaleOnFetchRejection,ignoreFetchAbort:Ue=this.ignoreFetchAbort,allowStaleOnFetchAbort:Ie=this.allowStaleOnFetchAbort,context:De,forceRefresh:Tt=!1,status:mt,signal:hr}=l;if(!this.#v)return mt&&(mt.fetch="get"),this.get(s,{allowStale:_,updateAgeOnGet:h,noDeleteOnStaleGet:b,status:mt});let rn={allowStale:_,updateAgeOnGet:h,noDeleteOnStaleGet:b,ttl:w,noDisposeOnSet:N,size:B,sizeCalculation:q,noUpdateTTL:le,noDeleteOnFetchRejection:se,allowStaleOnFetchRejection:te,allowStaleOnFetchAbort:Ie,ignoreFetchAbort:Ue,status:mt,signal:hr},jr=this.#c.get(s);if(jr===void 0){mt&&(mt.fetch="miss");let Qr=this.#j(s,jr,rn,De);return Qr.__returned=Qr}else{let Qr=this.#a[jr];if(this.#S(Qr)){let Po=_&&Qr.__staleWhileFetching!==void 0;return mt&&(mt.fetch="inflight",Po&&(mt.returnedStale=!0)),Po?Qr.__staleWhileFetching:Qr.__returned=Qr}let br=this.#P(jr);if(!Tt&&!br)return mt&&(mt.fetch="hit"),this.#z(jr),h&&this.#O(jr),mt&&this.#k(mt,jr),Qr;let yr=this.#j(s,jr,rn,De),Ci=yr.__staleWhileFetching!==void 0&&_;return mt&&(mt.fetch=br?"stale":"refresh",Ci&&br&&(mt.returnedStale=!0)),Ci?yr.__staleWhileFetching:yr.__returned=yr}}async forceFetch(s,l={}){let _=await this.fetch(s,l);if(_===void 0)throw new Error("fetch() returned undefined");return _}memo(s,l={}){let _=this.#o;if(!_)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:b,...w}=l,N=this.get(s,w);if(!b&&N!==void 0)return N;let B=_(s,N,{options:w,context:h});return this.set(s,B,w),B}get(s,l={}){let{allowStale:_=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:b=this.noDeleteOnStaleGet,status:w}=l,N=this.#c.get(s);if(N!==void 0){let B=this.#a[N],q=this.#S(B);return w&&this.#k(w,N),this.#P(N)?(w&&(w.get="stale"),q?(w&&_&&B.__staleWhileFetching!==void 0&&(w.returnedStale=!0),_?B.__staleWhileFetching:void 0):(b||this.#B(s,"expire"),w&&_&&(w.returnedStale=!0),_?B:void 0)):(w&&(w.get="hit"),q?B.__staleWhileFetching:(this.#z(N),h&&this.#O(N),B))}else w&&(w.get="miss")}#M(s,l){this.#m[l]=s,this.#h[s]=l}#z(s){s!==this.#d&&(s===this.#f?this.#f=this.#h[s]:this.#M(this.#m[s],this.#h[s]),this.#M(this.#d,s),this.#d=s)}delete(s){return this.#B(s,"delete")}#B(s,l){let _=!1;if(this.#_!==0){let h=this.#c.get(s);if(h!==void 0)if(_=!0,this.#_===1)this.#J(l);else{this.#R(h);let b=this.#a[h];if(this.#S(b)?b.__abortController.abort(new Error("deleted")):(this.#w||this.#x)&&(this.#w&&this.#t?.(b,s,l),this.#x&&this.#y?.push([b,s,l])),this.#c.delete(s),this.#i[h]=void 0,this.#a[h]=void 0,h===this.#d)this.#d=this.#m[h];else if(h===this.#f)this.#f=this.#h[h];else{let w=this.#m[h];this.#h[w]=this.#h[h];let N=this.#h[h];this.#m[N]=this.#m[h]}this.#_--,this.#g.push(h)}}if(this.#x&&this.#y?.length){let h=this.#y,b;for(;b=h?.shift();)this.#s?.(...b)}return _}clear(){return this.#J("delete")}#J(s){for(let l of this.#I({allowStale:!0})){let _=this.#a[l];if(this.#S(_))_.__abortController.abort(new Error("deleted"));else{let h=this.#i[l];this.#w&&this.#t?.(_,h,s),this.#x&&this.#y?.push([_,h,s])}}if(this.#c.clear(),this.#a.fill(void 0),this.#i.fill(void 0),this.#C&&this.#T&&(this.#C.fill(0),this.#T.fill(0)),this.#E&&this.#E.fill(0),this.#f=0,this.#d=0,this.#g.length=0,this.#u=0,this.#_=0,this.#x&&this.#y){let l=this.#y,_;for(;_=l?.shift();)this.#s?.(..._)}}};import*as Hde from"node:path";var SRe=new Wde({max:100,ttl:1e3*60*5,dispose:t(a=>{a&&a.destroy()},"dispose")});function VOr(a){let s=a.split(`
|
|
927
|
-
`),l=[],_="",h=/^\s*at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/;for(let b=0;b<s.length&&!(b>10);b++){let w=s[b],N=h.exec(w);N?l.push({functionName:N[1]||"<anonymous>",fileName:N[2],lineNumber:parseInt(N[3],10),columnNumber:parseInt(N[4],10),source:w}):b===0&&(_=w)}return{errorMessage:_,frames:l}}t(VOr,"parseStackTrace");async function Vkt(a,s){try{return await s(a)}catch{return null}}t(Vkt,"loadSourceMap");async function WOr(a,s){let l
|
|
927
|
+
`),l=[],_="",h=/^\s*at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/;for(let b=0;b<s.length&&!(b>10);b++){let w=s[b],N=h.exec(w);N?l.push({functionName:N[1]||"<anonymous>",fileName:N[2],lineNumber:parseInt(N[3],10),columnNumber:parseInt(N[4],10),source:w}):b===0&&(_=w)}return{errorMessage:_,frames:l}}t(VOr,"parseStackTrace");async function Vkt(a,s){try{return await s(a)}catch{return null}}t(Vkt,"loadSourceMap");async function WOr(a,s){let l=`${a}.map`,_=await Vkt(l,s);if(_)return _;try{let h=await s(a),w=/\/\/[#@]\s*sourceMappingURL=(.+?)$/m.exec(h);if(w){let N=w[1].trim();if(N.startsWith("data:")){let le=/^data:application\/json;(?:charset=utf-8;)?base64,(.+)$/.exec(N);if(le)return Buffer.from(le[1],"base64").toString("utf-8")}let B=Hde.resolve(Hde.dirname(a),N);if(_=await Vkt(B,s),_)return _}}catch{}return null}t(WOr,"findSourceMap");async function Wkt(a,s){let{errorMessage:l,frames:_}=VOr(a),h=[];for(let b of _){if(!b.fileName||!b.lineNumber||!b.columnNumber){h.push(b);continue}if(b.fileName.startsWith("http://")||b.fileName.startsWith("https://")){h.push(b);continue}let w=b.fileName.replace(/^file:\/\//,"");if(!SRe.has(w)){let B=await WOr(w,s);if(B)try{let q=await new qOr(JSON.parse(B));SRe.set(w,q)}catch{}}let N=SRe.get(w);if(N)try{let B=N.originalPositionFor({line:b.lineNumber,column:b.columnNumber-1});if(B.source){let q=B.source.startsWith("../")?B.source.replace(/^\.\.\/+/,""):B.source;q.includes("@zuplo/")&&(q=q.replace(/@zuplo\/([^/]+)\/out\/(?:esm|cjs)\/@zuplo\/\1\//,"@zuplo/$1/"),q=q.replace(/@zuplo\/([^/]+)\/dist\/@zuplo\/\1\//,"@zuplo/$1/")),q.includes("/app/packages/")&&q.includes("/src/")&&(q=q.replace(/.*\/app\/packages\/([^/]+)\/src\//,"@zuplo/$1/")),q.includes("node_modules/")&&(q=q.replace(/.*node_modules\//,""));let le=B.name??void 0;if(!le&&b.functionName&&b.functionName.length<=2){let te=[];for(let Ie=1;Ie<=30;Ie++){let De=N.originalPositionFor({line:b.lineNumber,column:Math.max(0,b.columnNumber-1-Ie)});De.name&&te.push({name:De.name,distance:Ie})}let Ue=te.find(Ie=>Ie.name.includes("default")||Ie.name.includes("Default"))||te.find(Ie=>Ie.name.includes("_"))||te.find(Ie=>/^[a-z][A-Za-z0-9]*$/.test(Ie.name)&&Ie.name.length>5)||te[0];Ue&&(le=Ue.name)}le=le??b.functionName;let se={...b,originalFileName:q,originalLineNumber:B.line??void 0,originalColumnNumber:B.column!=null?B.column+1:void 0,originalFunctionName:le};if(B.line){let te=N.sourceContentFor(B.source,!0);if(te){let Ue=te.split(`
|
|
928
928
|
`);Ue[B.line-1]&&(se.originalSource=Ue[B.line-1].trim())}}if(se.originalFileName?.includes("@opentelemetry/api/")&&(se.originalFileName.includes("/context/")||se.originalFileName.includes("/trace/")||se.originalFunctionName?.includes(".with")||se.originalFunctionName?.includes("startActiveSpan")))continue;h.push(se);continue}}catch{}h.push(b)}return HOr(l,h)}t(Wkt,"mapStacktrace");function HOr(a,s){let l=[];a&&l.push(a);for(let _ of s)if(_.originalFileName&&_.originalLineNumber){let h=_.originalFunctionName||_.functionName||"<anonymous>",b=_.originalFileName,w=_.originalLineNumber,N=_.originalColumnNumber||1;l.push(` at ${h} (${b}:${w}:${N})`),_.originalSource&&l.push(` ${_.originalSource}`)}else l.push(_.source);return l.join(`
|
|
929
929
|
`)}t(HOr,"formatMappedStackTrace");var GOr={GET:D_.green(D_.bold("GET")),POST:D_.blue(D_.bold("POST")),PUT:D_.yellow(D_.bold("PUT")),DELETE:D_.red(D_.bold("DELETE")),PATCH:D_.magenta(D_.bold("PATCH")),HEAD:D_.cyan(D_.bold("HEAD")),OPTIONS:D_.gray(D_.bold("OPTIONS"))},Hkt={error:D_.red(D_.bold("ERROR".padEnd(5))),warn:D_.yellow(D_.bold("WARN".padEnd(5))),info:D_.blue(D_.bold("INFO".padEnd(5))),debug:D_.gray(D_.bold("DEBUG".padEnd(5)))},Gkt;function KOr(){return Gkt??=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,fractionalSecondDigits:3}),Gkt}t(KOr,"getTimeFormatter");function Kkt(a){return D_.white(D_.dim(`[${KOr().format(a?new Date(a):new Date)}]`))}t(Kkt,"getTimestamp");var Ykt=class{static{t(this,"LogFormatter")}getFile;youch=new $kt;constructor(s){this.getFile=s}formatLine(s,l){let _=typeof l=="string"?l:JSON.stringify(l);return`${Kkt()} ${Hkt[s]} ${_}`}async formatStructured(s,l){if(typeof l=="object"&&l&&Object.keys(l).length===0)return;let{level:_,route:h,method:b,timestamp:w}=s,N=h.endsWith("{/}?")?h.slice(0,-4):h,B=await this.formatMessage(l);return`${Kkt(w)} ${Hkt[_]} [${GOr[b.toUpperCase()]} ${D_.blue(N)}] ${B}`}async formatMessage(s){let l=s.trim();if(l.startsWith("{")&&l.endsWith("}"))try{let _=JSON.parse(l);if("stack"in _&&YOr(_.stack)){let{stack:h,message:b,name:w,...N}=_,B=await this.formatError(h),q;return w&&b?q=`${w}: ${b}`:b?q=`Error: ${b}`:q="An error occurred",Object.keys(N).length>0&&(q+=`
|
|
930
930
|
`,q+=JSON.stringify(N)),`${q}
|