filex-cli 0.1.1 → 0.1.2
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/dist/filex.cjs +1 -1
- package/package.json +5 -3
package/dist/filex.cjs
CHANGED
|
@@ -70,7 +70,7 @@ end`},TD=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];re
|
|
|
70
70
|
`);for(var L=1,O={x:d+L,y:d+L,width:v-(d+L)*2,height:g-(d+L)*2},q=Ti.layoutMultilineText(S,{alignment:bl.TextAlignment.Left,fontSize:s??l,font:r,bounds:O}),H=q.lines,U=q.fontSize,ne=q.lineHeight,pe=[],P=0,A=H.length;P<A;P++){var J=H[P];C.includes(J.text)&&pe.push(P)}var Oe=Te.rgb(153/255,193/255,218/255),xt=(i=a??o)!==null&&i!==void 0?i:b;return fr(a||s!==void 0?e:t.acroField,xt,r,U),le.__spreadArrays(m,st.drawOptionList({x:0+d/2,y:0+d/2,width:v-d,height:g-d,borderWidth:d??0,borderColor:w,textColor:xt,font:r.name,fontSize:U,color:F,textLines:H,lineHeight:ne,selectedColor:Oe,selectedLines:pe,padding:L}))}});var _l=D(h0=>{"use strict";Object.defineProperty(h0,"__esModule",{value:!0});var d0=(k(),R(T)),h3=d0.__importDefault(Xn()),oF=et(),xl=ae(),p3=(function(){function t(e,r,n){this.alreadyEmbedded=!1,xl.assertIs(e,"ref",[[oF.PDFRef,"PDFRef"]]),xl.assertIs(r,"doc",[[h3.default,"PDFDocument"]]),xl.assertIs(n,"embedder",[[oF.PDFPageEmbedder,"PDFPageEmbedder"]]),this.ref=e,this.doc=r,this.width=n.width,this.height=n.height,this.embedder=n}return t.prototype.scale=function(e){return xl.assertIs(e,"factor",["number"]),{width:this.width*e,height:this.height*e}},t.prototype.size=function(){return this.scale(1)},t.prototype.embed=function(){return d0.__awaiter(this,void 0,void 0,function(){return d0.__generator(this,function(e){switch(e.label){case 0:return this.alreadyEmbedded?[3,2]:[4,this.embedder.embedIntoContext(this.doc.context,this.ref)];case 1:e.sent(),this.alreadyEmbedded=!0,e.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})();h0.default=p3});var bn=D(v0=>{"use strict";Object.defineProperty(v0,"__esModule",{value:!0});var p0=(k(),R(T)),v3=p0.__importDefault(Xn()),Cl=et(),Fn=ae(),m3=(function(){function t(e,r,n){this.modified=!0,Fn.assertIs(e,"ref",[[Cl.PDFRef,"PDFRef"]]),Fn.assertIs(r,"doc",[[v3.default,"PDFDocument"]]),Fn.assertIs(n,"embedder",[[Cl.CustomFontEmbedder,"CustomFontEmbedder"],[Cl.StandardFontEmbedder,"StandardFontEmbedder"]]),this.ref=e,this.doc=r,this.name=n.fontName,this.embedder=n}return t.prototype.encodeText=function(e){return Fn.assertIs(e,"text",["string"]),this.modified=!0,this.embedder.encodeText(e)},t.prototype.widthOfTextAtSize=function(e,r){return Fn.assertIs(e,"text",["string"]),Fn.assertIs(r,"size",["number"]),this.embedder.widthOfTextAtSize(e,r)},t.prototype.heightAtSize=function(e,r){var n;return Fn.assertIs(e,"size",["number"]),Fn.assertOrUndefined(r?.descender,"options.descender",["boolean"]),this.embedder.heightOfFontAtSize(e,{descender:(n=r?.descender)!==null&&n!==void 0?n:!0})},t.prototype.sizeAtHeight=function(e){return Fn.assertIs(e,"height",["number"]),this.embedder.sizeOfFontAtHeight(e)},t.prototype.getCharacterSet=function(){return this.embedder instanceof Cl.StandardFontEmbedder?this.embedder.encoding.supportedCodePoints:this.embedder.font.characterSet},t.prototype.embed=function(){return p0.__awaiter(this,void 0,void 0,function(){return p0.__generator(this,function(e){switch(e.label){case 0:return this.modified?[4,this.embedder.embedIntoContext(this.doc.context,this.ref)]:[3,2];case 1:e.sent(),this.modified=!1,e.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})();v0.default=m3});var wl=D(D0=>{"use strict";Object.defineProperty(D0,"__esModule",{value:!0});var g0=(k(),R(T)),g3=g0.__importDefault(Xn()),m0=et(),Xa=ae(),D3=(function(){function t(e,r,n){Xa.assertIs(e,"ref",[[m0.PDFRef,"PDFRef"]]),Xa.assertIs(r,"doc",[[g3.default,"PDFDocument"]]),Xa.assertIs(n,"embedder",[[m0.JpegEmbedder,"JpegEmbedder"],[m0.PngEmbedder,"PngEmbedder"]]),this.ref=e,this.doc=r,this.width=n.width,this.height=n.height,this.embedder=n}return t.prototype.scale=function(e){return Xa.assertIs(e,"factor",["number"]),{width:this.width*e,height:this.height*e}},t.prototype.scaleToFit=function(e,r){Xa.assertIs(e,"width",["number"]),Xa.assertIs(r,"height",["number"]);var n=e/this.width,i=r/this.height,a=Math.min(n,i);return this.scale(a)},t.prototype.size=function(){return this.scale(1)},t.prototype.embed=function(){return g0.__awaiter(this,void 0,void 0,function(){var e,r,n;return g0.__generator(this,function(i){switch(i.label){case 0:return this.embedder?(this.embedTask||(e=this,r=e.doc,n=e.ref,this.embedTask=this.embedder.embedIntoContext(r.context,n)),[4,this.embedTask]):[2];case 1:return i.sent(),this.embedder=void 0,[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})();D0.default=D3});var Pl=D(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.ImageAlignment=void 0;var y3;(function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right"})(y3=Cs.ImageAlignment||(Cs.ImageAlignment={}))});var F0=D(y0=>{"use strict";Object.defineProperty(y0,"__esModule",{value:!0});var F3=(k(),R(T));F3.__exportStar(Pl(),y0)});var xn=D(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.assertFieldAppearanceOptions=void 0;var El=(k(),R(T)),b3=El.__importDefault(Xn()),b0=ur(),ki=Zt(),ct=et(),Yt=ae(),sF=F0(),uF=Ga();ws.assertFieldAppearanceOptions=function(t){Yt.assertOrUndefined(t?.x,"options.x",["number"]),Yt.assertOrUndefined(t?.y,"options.y",["number"]),Yt.assertOrUndefined(t?.width,"options.width",["number"]),Yt.assertOrUndefined(t?.height,"options.height",["number"]),Yt.assertOrUndefined(t?.textColor,"options.textColor",[[Object,"Color"]]),Yt.assertOrUndefined(t?.backgroundColor,"options.backgroundColor",[[Object,"Color"]]),Yt.assertOrUndefined(t?.borderColor,"options.borderColor",[[Object,"Color"]]),Yt.assertOrUndefined(t?.borderWidth,"options.borderWidth",["number"]),Yt.assertOrUndefined(t?.rotate,"options.rotate",[[Object,"Rotation"]])};var x3=(function(){function t(e,r,n){Yt.assertIs(e,"acroField",[[ct.PDFAcroTerminal,"PDFAcroTerminal"]]),Yt.assertIs(r,"ref",[[ct.PDFRef,"PDFRef"]]),Yt.assertIs(n,"doc",[[b3.default,"PDFDocument"]]),this.acroField=e,this.ref=r,this.doc=n}return t.prototype.getName=function(){var e;return(e=this.acroField.getFullyQualifiedName())!==null&&e!==void 0?e:""},t.prototype.isReadOnly=function(){return this.acroField.hasFlag(ct.AcroFieldFlags.ReadOnly)},t.prototype.enableReadOnly=function(){this.acroField.setFlagTo(ct.AcroFieldFlags.ReadOnly,!0)},t.prototype.disableReadOnly=function(){this.acroField.setFlagTo(ct.AcroFieldFlags.ReadOnly,!1)},t.prototype.isRequired=function(){return this.acroField.hasFlag(ct.AcroFieldFlags.Required)},t.prototype.enableRequired=function(){this.acroField.setFlagTo(ct.AcroFieldFlags.Required,!0)},t.prototype.disableRequired=function(){this.acroField.setFlagTo(ct.AcroFieldFlags.Required,!1)},t.prototype.isExported=function(){return!this.acroField.hasFlag(ct.AcroFieldFlags.NoExport)},t.prototype.enableExporting=function(){this.acroField.setFlagTo(ct.AcroFieldFlags.NoExport,!1)},t.prototype.disableExporting=function(){this.acroField.setFlagTo(ct.AcroFieldFlags.NoExport,!0)},t.prototype.needsAppearancesUpdate=function(){throw new ct.MethodNotImplementedError(this.constructor.name,"needsAppearancesUpdate")},t.prototype.defaultUpdateAppearances=function(e){throw new ct.MethodNotImplementedError(this.constructor.name,"defaultUpdateAppearances")},t.prototype.markAsDirty=function(){this.doc.getForm().markFieldAsDirty(this.ref)},t.prototype.markAsClean=function(){this.doc.getForm().markFieldAsClean(this.ref)},t.prototype.isDirty=function(){return this.doc.getForm().fieldIsDirty(this.ref)},t.prototype.createWidget=function(e){var r,n=e.textColor,i=e.backgroundColor,a=e.borderColor,o=e.borderWidth,s=ki.toDegrees(e.rotate),l=e.caption,u=e.x,c=e.y,f=e.width+o,d=e.height+o,p=!!e.hidden,h=e.page;Yt.assertMultiple(s,"degreesAngle",90);var v=ct.PDFWidgetAnnotation.create(this.doc.context,this.ref),g=ki.rotateRectangle({x:u,y:c,width:f,height:d},o,s);v.setRectangle(g),h&&v.setP(h);var m=v.getOrCreateAppearanceCharacteristics();i&&m.setBackgroundColor(b0.colorToComponents(i)),m.setRotation(s),l&&m.setCaptions({normal:l}),a&&m.setBorderColor(b0.colorToComponents(a));var b=v.getOrCreateBorderStyle();if(o!==void 0&&b.setWidth(o),v.setFlagTo(ct.AnnotationFlags.Print,!0),v.setFlagTo(ct.AnnotationFlags.Hidden,p),v.setFlagTo(ct.AnnotationFlags.Invisible,!1),n){var w=(r=this.acroField.getDefaultAppearance())!==null&&r!==void 0?r:"",F=w+`
|
|
71
71
|
`+b0.setFillingColor(n).toString();this.acroField.setDefaultAppearance(F)}return v},t.prototype.updateWidgetAppearanceWithFont=function(e,r,n){var i=n.normal,a=n.rollover,o=n.down;this.updateWidgetAppearances(e,{normal:this.createAppearanceStream(e,i,r),rollover:a&&this.createAppearanceStream(e,a,r),down:o&&this.createAppearanceStream(e,o,r)})},t.prototype.updateOnOffWidgetAppearance=function(e,r,n){var i=n.normal,a=n.rollover,o=n.down;this.updateWidgetAppearances(e,{normal:this.createAppearanceDict(e,i,r),rollover:a&&this.createAppearanceDict(e,a,r),down:o&&this.createAppearanceDict(e,o,r)})},t.prototype.updateWidgetAppearances=function(e,r){var n=r.normal,i=r.rollover,a=r.down;e.setNormalAppearance(n),i?e.setRolloverAppearance(i):e.removeRolloverAppearance(),a?e.setDownAppearance(a):e.removeDownAppearance()},t.prototype.createAppearanceStream=function(e,r,n){var i,a=this.acroField.dict.context,o=e.getRectangle(),s=o.width,l=o.height,u=n&&{Font:(i={},i[n.name]=n.ref,i)},c=a.formXObject(r,{Resources:u,BBox:a.obj([0,0,s,l]),Matrix:a.obj([1,0,0,1,0,0])}),f=a.register(c);return f},t.prototype.createImageAppearanceStream=function(e,r,n){var i,a,o=this.acroField.dict.context,s=e.getRectangle(),l=e.getAppearanceCharacteristics(),u=e.getBorderStyle(),c=(a=u?.getWidth())!==null&&a!==void 0?a:0,f=ki.reduceRotation(l?.getRotation()),d=uF.rotateInPlace(El.__assign(El.__assign({},s),{rotation:f})),p=ki.adjustDimsForRotation(s,f),h=r.scaleToFit(p.width-c*2,p.height-c*2),v={x:c,y:c,width:h.width,height:h.height,rotate:ki.degrees(0),xSkew:ki.degrees(0),ySkew:ki.degrees(0)};n===sF.ImageAlignment.Center?(v.x+=(p.width-c*2)/2-h.width/2,v.y+=(p.height-c*2)/2-h.height/2):n===sF.ImageAlignment.Right&&(v.x=p.width-c-h.width,v.y=p.height-c-h.height);var g=this.doc.context.addRandomSuffix("Image",10),m=El.__spreadArrays(d,uF.drawImage(g,v)),b={XObject:(i={},i[g]=r.ref,i)},w=o.formXObject(m,{Resources:b,BBox:o.obj([0,0,s.width,s.height]),Matrix:o.obj([1,0,0,1,0,0])});return o.register(w)},t.prototype.createAppearanceDict=function(e,r,n){var i=this.acroField.dict.context,a=this.createAppearanceStream(e,r.on),o=this.createAppearanceStream(e,r.off),s=i.obj({});return s.set(n,a),s.set(ct.PDFName.of("Off"),o),s},t})();ws.default=x3});var P0=D(w0=>{"use strict";Object.defineProperty(w0,"__esModule",{value:!0});var C0=(k(),R(T)),_3=C0.__importDefault(_n()),lF=Kn(),x0=ur(),C3=Zt(),cF=C0.__importStar(xn()),Ri=et(),_0=ae(),w3=(function(t){C0.__extends(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return _0.assertIs(r,"acroCheckBox",[[Ri.PDFAcroCheckBox,"PDFAcroCheckBox"]]),a.acroField=r,a}return e.prototype.check=function(){var r,n=(r=this.acroField.getOnValue())!==null&&r!==void 0?r:Ri.PDFName.of("Yes");this.markAsDirty(),this.acroField.setValue(n)},e.prototype.uncheck=function(){this.markAsDirty(),this.acroField.setValue(Ri.PDFName.of("Off"))},e.prototype.isChecked=function(){var r=this.acroField.getOnValue();return!!r&&r===this.acroField.getValue()},e.prototype.addToPage=function(r,n){var i,a,o,s,l,u;_0.assertIs(r,"page",[[_3.default,"PDFPage"]]),cF.assertFieldAppearanceOptions(n),n||(n={}),"textColor"in n||(n.textColor=x0.rgb(0,0,0)),"backgroundColor"in n||(n.backgroundColor=x0.rgb(1,1,1)),"borderColor"in n||(n.borderColor=x0.rgb(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var c=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:50,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(l=n.borderWidth)!==null&&l!==void 0?l:0,rotate:(u=n.rotate)!==null&&u!==void 0?u:C3.degrees(0),hidden:n.hidden,page:r.ref}),f=this.doc.context.register(c.dict);this.acroField.addWidget(f),c.setAppearanceState(Ri.PDFName.of("Off")),this.updateWidgetAppearance(c,Ri.PDFName.of("Yes")),r.node.addAnnot(f)},e.prototype.needsAppearancesUpdate=function(){for(var r,n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getAppearanceState(),l=(r=o.getAppearances())===null||r===void 0?void 0:r.normal;if(!(l instanceof Ri.PDFDict)||s&&!l.has(s))return!0}return!1},e.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},e.prototype.updateAppearances=function(r){var n;_0.assertOrUndefined(r,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a],l=(n=s.getOnValue())!==null&&n!==void 0?n:Ri.PDFName.of("Yes");l&&this.updateWidgetAppearance(s,l,r)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??lF.defaultCheckBoxAppearanceProvider,o=lF.normalizeAppearance(a(this,r));this.updateOnOffWidgetAppearance(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(cF.default);w0.default=w3});var O0=D(S0=>{"use strict";Object.defineProperty(S0,"__esModule",{value:!0});var Sl=(k(),R(T)),P3=Sl.__importDefault(_n()),fF=Sl.__importDefault(bn()),dF=Sl.__importStar(xn()),hF=Kn(),E0=ur(),E3=Zt(),tt=et(),Zr=ae(),S3=(function(t){Sl.__extends(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return Zr.assertIs(r,"acroComboBox",[[tt.PDFAcroComboBox,"PDFAcroComboBox"]]),a.acroField=r,a}return e.prototype.getOptions=function(){for(var r=this.acroField.getOptions(),n=new Array(r.length),i=0,a=n.length;i<a;i++){var o=r[i],s=o.display,l=o.value;n[i]=(s??l).decodeText()}return n},e.prototype.getSelected=function(){for(var r=this.acroField.getValues(),n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n},e.prototype.setOptions=function(r){Zr.assertIs(r,"options",[Array]);for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]={value:tt.PDFHexString.fromText(r[i])};this.acroField.setOptions(n)},e.prototype.addOptions=function(r){Zr.assertIs(r,"options",["string",Array]);for(var n=Array.isArray(r)?r:[r],i=this.acroField.getOptions(),a=new Array(n.length),o=0,s=n.length;o<s;o++)a[o]={value:tt.PDFHexString.fromText(n[o])};this.acroField.setOptions(i.concat(a))},e.prototype.select=function(r,n){n===void 0&&(n=!1),Zr.assertIs(r,"options",["string",Array]),Zr.assertIs(n,"merge",["boolean"]);var i=Array.isArray(r)?r:[r],a=this.getOptions(),o=i.find(function(f){return!a.includes(f)});o&&this.enableEditing(),this.markAsDirty(),(i.length>1||i.length===1&&n)&&this.enableMultiselect();for(var s=new Array(i.length),l=0,u=i.length;l<u;l++)s[l]=tt.PDFHexString.fromText(i[l]);if(n){var c=this.acroField.getValues();this.acroField.setValues(c.concat(s))}else this.acroField.setValues(s)},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},e.prototype.setFontSize=function(r){Zr.assertPositive(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isEditable=function(){return this.acroField.hasFlag(tt.AcroChoiceFlags.Edit)},e.prototype.enableEditing=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.Edit,!0)},e.prototype.disableEditing=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.Edit,!1)},e.prototype.isSorted=function(){return this.acroField.hasFlag(tt.AcroChoiceFlags.Sort)},e.prototype.enableSorting=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.Sort,!0)},e.prototype.disableSorting=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.Sort,!1)},e.prototype.isMultiselect=function(){return this.acroField.hasFlag(tt.AcroChoiceFlags.MultiSelect)},e.prototype.enableMultiselect=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.MultiSelect,!0)},e.prototype.disableMultiselect=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.MultiSelect,!1)},e.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(tt.AcroChoiceFlags.DoNotSpellCheck)},e.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.DoNotSpellCheck,!1)},e.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.DoNotSpellCheck,!0)},e.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(tt.AcroChoiceFlags.CommitOnSelChange)},e.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.CommitOnSelChange,!0)},e.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(tt.AcroChoiceFlags.CommitOnSelChange,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,l,u,c;Zr.assertIs(r,"page",[[P3.default,"PDFPage"]]),dF.assertFieldAppearanceOptions(n),n||(n={}),"textColor"in n||(n.textColor=E0.rgb(0,0,0)),"backgroundColor"in n||(n.backgroundColor=E0.rgb(1,1,1)),"borderColor"in n||(n.borderColor=E0.rgb(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var f=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(l=n.borderWidth)!==null&&l!==void 0?l:0,rotate:(u=n.rotate)!==null&&u!==void 0?u:E3.degrees(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(f.dict);this.acroField.addWidget(d);var p=(c=n.font)!==null&&c!==void 0?c:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(f,p),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof tt.PDFStream;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){Zr.assertIs(r,"font",[[fF.default,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){Zr.assertIs(r,"font",[[fF.default,"PDFFont"]]),Zr.assertOrUndefined(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??hF.defaultDropdownAppearanceProvider,o=hF.normalizeAppearance(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(dF.default);S0.default=S3});var k0=D(T0=>{"use strict";Object.defineProperty(T0,"__esModule",{value:!0});var Ol=(k(),R(T)),O3=Ol.__importDefault(_n()),pF=Ol.__importDefault(bn()),vF=Ol.__importStar(xn()),mF=Kn(),A0=ur(),A3=Zt(),Vt=et(),Er=ae(),T3=(function(t){Ol.__extends(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return Er.assertIs(r,"acroListBox",[[Vt.PDFAcroListBox,"PDFAcroListBox"]]),a.acroField=r,a}return e.prototype.getOptions=function(){for(var r=this.acroField.getOptions(),n=new Array(r.length),i=0,a=n.length;i<a;i++){var o=r[i],s=o.display,l=o.value;n[i]=(s??l).decodeText()}return n},e.prototype.getSelected=function(){for(var r=this.acroField.getValues(),n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n},e.prototype.setOptions=function(r){Er.assertIs(r,"options",[Array]),this.markAsDirty();for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]={value:Vt.PDFHexString.fromText(r[i])};this.acroField.setOptions(n)},e.prototype.addOptions=function(r){Er.assertIs(r,"options",["string",Array]),this.markAsDirty();for(var n=Array.isArray(r)?r:[r],i=this.acroField.getOptions(),a=new Array(n.length),o=0,s=n.length;o<s;o++)a[o]={value:Vt.PDFHexString.fromText(n[o])};this.acroField.setOptions(i.concat(a))},e.prototype.select=function(r,n){n===void 0&&(n=!1),Er.assertIs(r,"options",["string",Array]),Er.assertIs(n,"merge",["boolean"]);var i=Array.isArray(r)?r:[r],a=this.getOptions();Er.assertIsSubset(i,"option",a),this.markAsDirty(),(i.length>1||i.length===1&&n)&&this.enableMultiselect();for(var o=new Array(i.length),s=0,l=i.length;s<l;s++)o[s]=Vt.PDFHexString.fromText(i[s]);if(n){var u=this.acroField.getValues();this.acroField.setValues(u.concat(o))}else this.acroField.setValues(o)},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValues([])},e.prototype.setFontSize=function(r){Er.assertPositive(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isSorted=function(){return this.acroField.hasFlag(Vt.AcroChoiceFlags.Sort)},e.prototype.enableSorting=function(){this.acroField.setFlagTo(Vt.AcroChoiceFlags.Sort,!0)},e.prototype.disableSorting=function(){this.acroField.setFlagTo(Vt.AcroChoiceFlags.Sort,!1)},e.prototype.isMultiselect=function(){return this.acroField.hasFlag(Vt.AcroChoiceFlags.MultiSelect)},e.prototype.enableMultiselect=function(){this.acroField.setFlagTo(Vt.AcroChoiceFlags.MultiSelect,!0)},e.prototype.disableMultiselect=function(){this.acroField.setFlagTo(Vt.AcroChoiceFlags.MultiSelect,!1)},e.prototype.isSelectOnClick=function(){return this.acroField.hasFlag(Vt.AcroChoiceFlags.CommitOnSelChange)},e.prototype.enableSelectOnClick=function(){this.acroField.setFlagTo(Vt.AcroChoiceFlags.CommitOnSelChange,!0)},e.prototype.disableSelectOnClick=function(){this.acroField.setFlagTo(Vt.AcroChoiceFlags.CommitOnSelChange,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,l,u,c;Er.assertIs(r,"page",[[O3.default,"PDFPage"]]),vF.assertFieldAppearanceOptions(n),n||(n={}),"textColor"in n||(n.textColor=A0.rgb(0,0,0)),"backgroundColor"in n||(n.backgroundColor=A0.rgb(1,1,1)),"borderColor"in n||(n.borderColor=A0.rgb(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var f=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:100,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(l=n.borderWidth)!==null&&l!==void 0?l:0,rotate:(u=n.rotate)!==null&&u!==void 0?u:A3.degrees(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(f.dict);this.acroField.addWidget(d);var p=(c=n.font)!==null&&c!==void 0?c:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(f,p),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof Vt.PDFStream;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){Er.assertIs(r,"font",[[pF.default,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){Er.assertIs(r,"font",[[pF.default,"PDFFont"]]),Er.assertOrUndefined(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??mF.defaultOptionListAppearanceProvider,o=mF.normalizeAppearance(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(vF.default);T0.default=T3});var I0=D(N0=>{"use strict";Object.defineProperty(N0,"__esModule",{value:!0});var B0=(k(),R(T)),k3=B0.__importDefault(_n()),gF=B0.__importStar(xn()),DF=Kn(),R0=ur(),R3=Zt(),dr=et(),Za=ae(),B3=(function(t){B0.__extends(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return Za.assertIs(r,"acroRadioButton",[[dr.PDFAcroRadioButton,"PDFAcroRadioButton"]]),a.acroField=r,a}return e.prototype.getOptions=function(){var r=this.acroField.getExportValues();if(r){for(var n=new Array(r.length),i=0,a=r.length;i<a;i++)n[i]=r[i].decodeText();return n}for(var o=this.acroField.getOnValues(),s=new Array(o.length),i=0,a=s.length;i<a;i++)s[i]=o[i].decodeText();return s},e.prototype.getSelected=function(){var r=this.acroField.getValue();if(r!==dr.PDFName.of("Off")){var n=this.acroField.getExportValues();if(n){for(var i=this.acroField.getOnValues(),a=0,o=i.length;a<o;a++)if(i[a]===r)return n[a].decodeText()}return r.decodeText()}},e.prototype.select=function(r){Za.assertIs(r,"option",["string"]);var n=this.getOptions();Za.assertIsOneOf(r,"option",n),this.markAsDirty();var i=this.acroField.getOnValues(),a=this.acroField.getExportValues();if(a)for(var o=0,s=a.length;o<s;o++)a[o].decodeText()===r&&this.acroField.setValue(i[o]);else for(var o=0,s=i.length;o<s;o++){var l=i[o];l.decodeText()===r&&this.acroField.setValue(l)}},e.prototype.clear=function(){this.markAsDirty(),this.acroField.setValue(dr.PDFName.of("Off"))},e.prototype.isOffToggleable=function(){return!this.acroField.hasFlag(dr.AcroButtonFlags.NoToggleToOff)},e.prototype.enableOffToggling=function(){this.acroField.setFlagTo(dr.AcroButtonFlags.NoToggleToOff,!1)},e.prototype.disableOffToggling=function(){this.acroField.setFlagTo(dr.AcroButtonFlags.NoToggleToOff,!0)},e.prototype.isMutuallyExclusive=function(){return!this.acroField.hasFlag(dr.AcroButtonFlags.RadiosInUnison)},e.prototype.enableMutualExclusion=function(){this.acroField.setFlagTo(dr.AcroButtonFlags.RadiosInUnison,!1)},e.prototype.disableMutualExclusion=function(){this.acroField.setFlagTo(dr.AcroButtonFlags.RadiosInUnison,!0)},e.prototype.addOptionToPage=function(r,n,i){var a,o,s,l,u,c,f,d,p;Za.assertIs(r,"option",["string"]),Za.assertIs(n,"page",[[k3.default,"PDFPage"]]),gF.assertFieldAppearanceOptions(i);var h=this.createWidget({x:(a=i?.x)!==null&&a!==void 0?a:0,y:(o=i?.y)!==null&&o!==void 0?o:0,width:(s=i?.width)!==null&&s!==void 0?s:50,height:(l=i?.height)!==null&&l!==void 0?l:50,textColor:(u=i?.textColor)!==null&&u!==void 0?u:R0.rgb(0,0,0),backgroundColor:(c=i?.backgroundColor)!==null&&c!==void 0?c:R0.rgb(1,1,1),borderColor:(f=i?.borderColor)!==null&&f!==void 0?f:R0.rgb(0,0,0),borderWidth:(d=i?.borderWidth)!==null&&d!==void 0?d:1,rotate:(p=i?.rotate)!==null&&p!==void 0?p:R3.degrees(0),hidden:i?.hidden,page:n.ref}),v=this.doc.context.register(h.dict),g=this.acroField.addWidgetWithOpt(v,dr.PDFHexString.fromText(r),!this.isMutuallyExclusive());h.setAppearanceState(dr.PDFName.of("Off")),this.updateWidgetAppearance(h,g),n.node.addAnnot(v)},e.prototype.needsAppearancesUpdate=function(){for(var r,n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getAppearanceState(),l=(r=o.getAppearances())===null||r===void 0?void 0:r.normal;if(!(l instanceof dr.PDFDict)||s&&!l.has(s))return!0}return!1},e.prototype.defaultUpdateAppearances=function(){this.updateAppearances()},e.prototype.updateAppearances=function(r){Za.assertOrUndefined(r,"provider",[Function]);for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=o.getOnValue();s&&this.updateWidgetAppearance(o,s,r)}},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??DF.defaultRadioGroupAppearanceProvider,o=DF.normalizeAppearance(a(this,r));this.updateOnOffWidgetAppearance(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(gF.default);N0.default=B3});var j0=D(q0=>{"use strict";Object.defineProperty(q0,"__esModule",{value:!0});var yF=(k(),R(T)),N3=yF.__importDefault(xn()),I3=et(),q3=ae(),j3=(function(t){yF.__extends(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return q3.assertIs(r,"acroSignature",[[I3.PDFAcroSignature,"PDFAcroSignature"]]),a.acroField=r,a}return e.prototype.needsAppearancesUpdate=function(){return!1},e.of=function(r,n,i){return new e(r,n,i)},e})(N3.default);q0.default=j3});var W0=D(z0=>{"use strict";Object.defineProperty(z0,"__esModule",{value:!0});var Al=(k(),R(T)),M3=Al.__importDefault(_n()),FF=Al.__importDefault(bn()),bF=Al.__importStar(xn()),xF=Kn(),M0=ur(),U3=Zt(),U0=Ha(),V0=Pl(),Bi=_s(),qe=et(),Cn=ae(),V3=(function(t){Al.__extends(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return Cn.assertIs(r,"acroText",[[qe.PDFAcroText,"PDFAcroText"]]),a.acroField=r,a}return e.prototype.getText=function(){var r=this.acroField.getValue();if(!r&&this.isRichFormatted())throw new U0.RichTextFieldReadError(this.getName());return r?.decodeText()},e.prototype.setText=function(r){Cn.assertOrUndefined(r,"text",["string"]);var n=this.getMaxLength();if(n!==void 0&&r&&r.length>n)throw new U0.ExceededMaxLengthError(r.length,n,this.getName());this.markAsDirty(),this.disableRichFormatting(),r?this.acroField.setValue(qe.PDFHexString.fromText(r)):this.acroField.removeValue()},e.prototype.getAlignment=function(){var r=this.acroField.getQuadding();return r===0?Bi.TextAlignment.Left:r===1?Bi.TextAlignment.Center:r===2?Bi.TextAlignment.Right:Bi.TextAlignment.Left},e.prototype.setAlignment=function(r){Cn.assertIsOneOf(r,"alignment",Bi.TextAlignment),this.markAsDirty(),this.acroField.setQuadding(r)},e.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},e.prototype.setMaxLength=function(r){if(Cn.assertRangeOrUndefined(r,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),r===void 0)this.acroField.removeMaxLength();else{var n=this.getText();if(n&&n.length>r)throw new U0.InvalidMaxLengthError(n.length,r,this.getName());this.acroField.setMaxLength(r)}},e.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},e.prototype.setImage=function(r){for(var n=this.getAlignment(),i=n===Bi.TextAlignment.Center?V0.ImageAlignment.Center:n===Bi.TextAlignment.Right?V0.ImageAlignment.Right:V0.ImageAlignment.Left,a=this.acroField.getWidgets(),o=0,s=a.length;o<s;o++){var l=a[o],u=this.createImageAppearanceStream(l,r,i);this.updateWidgetAppearances(l,{normal:u})}this.markAsClean()},e.prototype.setFontSize=function(r){Cn.assertPositive(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.isMultiline=function(){return this.acroField.hasFlag(qe.AcroTextFlags.Multiline)},e.prototype.enableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(qe.AcroTextFlags.Multiline,!0)},e.prototype.disableMultiline=function(){this.markAsDirty(),this.acroField.setFlagTo(qe.AcroTextFlags.Multiline,!1)},e.prototype.isPassword=function(){return this.acroField.hasFlag(qe.AcroTextFlags.Password)},e.prototype.enablePassword=function(){this.acroField.setFlagTo(qe.AcroTextFlags.Password,!0)},e.prototype.disablePassword=function(){this.acroField.setFlagTo(qe.AcroTextFlags.Password,!1)},e.prototype.isFileSelector=function(){return this.acroField.hasFlag(qe.AcroTextFlags.FileSelect)},e.prototype.enableFileSelection=function(){this.acroField.setFlagTo(qe.AcroTextFlags.FileSelect,!0)},e.prototype.disableFileSelection=function(){this.acroField.setFlagTo(qe.AcroTextFlags.FileSelect,!1)},e.prototype.isSpellChecked=function(){return!this.acroField.hasFlag(qe.AcroTextFlags.DoNotSpellCheck)},e.prototype.enableSpellChecking=function(){this.acroField.setFlagTo(qe.AcroTextFlags.DoNotSpellCheck,!1)},e.prototype.disableSpellChecking=function(){this.acroField.setFlagTo(qe.AcroTextFlags.DoNotSpellCheck,!0)},e.prototype.isScrollable=function(){return!this.acroField.hasFlag(qe.AcroTextFlags.DoNotScroll)},e.prototype.enableScrolling=function(){this.acroField.setFlagTo(qe.AcroTextFlags.DoNotScroll,!1)},e.prototype.disableScrolling=function(){this.acroField.setFlagTo(qe.AcroTextFlags.DoNotScroll,!0)},e.prototype.isCombed=function(){return this.acroField.hasFlag(qe.AcroTextFlags.Comb)&&!this.isMultiline()&&!this.isPassword()&&!this.isFileSelector()&&this.getMaxLength()!==void 0},e.prototype.enableCombing=function(){if(this.getMaxLength()===void 0){var r="PDFTextFields must have a max length in order to be combed";console.warn(r)}this.markAsDirty(),this.disableMultiline(),this.disablePassword(),this.disableFileSelection(),this.acroField.setFlagTo(qe.AcroTextFlags.Comb,!0)},e.prototype.disableCombing=function(){this.markAsDirty(),this.acroField.setFlagTo(qe.AcroTextFlags.Comb,!1)},e.prototype.isRichFormatted=function(){return this.acroField.hasFlag(qe.AcroTextFlags.RichText)},e.prototype.enableRichFormatting=function(){this.acroField.setFlagTo(qe.AcroTextFlags.RichText,!0)},e.prototype.disableRichFormatting=function(){this.acroField.setFlagTo(qe.AcroTextFlags.RichText,!1)},e.prototype.addToPage=function(r,n){var i,a,o,s,l,u,c;Cn.assertIs(r,"page",[[M3.default,"PDFPage"]]),bF.assertFieldAppearanceOptions(n),n||(n={}),"textColor"in n||(n.textColor=M0.rgb(0,0,0)),"backgroundColor"in n||(n.backgroundColor=M0.rgb(1,1,1)),"borderColor"in n||(n.borderColor=M0.rgb(0,0,0)),"borderWidth"in n||(n.borderWidth=1);var f=this.createWidget({x:(i=n.x)!==null&&i!==void 0?i:0,y:(a=n.y)!==null&&a!==void 0?a:0,width:(o=n.width)!==null&&o!==void 0?o:200,height:(s=n.height)!==null&&s!==void 0?s:50,textColor:n.textColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,borderWidth:(l=n.borderWidth)!==null&&l!==void 0?l:0,rotate:(u=n.rotate)!==null&&u!==void 0?u:U3.degrees(0),hidden:n.hidden,page:r.ref}),d=this.doc.context.register(f.dict);this.acroField.addWidget(d);var p=(c=n.font)!==null&&c!==void 0?c:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(f,p),r.node.addAnnot(d)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof qe.PDFStream;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){Cn.assertIs(r,"font",[[FF.default,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){Cn.assertIs(r,"font",[[FF.default,"PDFFont"]]),Cn.assertOrUndefined(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}this.markAsClean()},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??xF.defaultTextFieldAppearanceProvider,o=xF.normalizeAppearance(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(bF.default);z0.default=V3});var Tl=D(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.StandardFonts=void 0;var z3;(function(t){t.Courier="Courier",t.CourierBold="Courier-Bold",t.CourierOblique="Courier-Oblique",t.CourierBoldOblique="Courier-BoldOblique",t.Helvetica="Helvetica",t.HelveticaBold="Helvetica-Bold",t.HelveticaOblique="Helvetica-Oblique",t.HelveticaBoldOblique="Helvetica-BoldOblique",t.TimesRoman="Times-Roman",t.TimesRomanBold="Times-Bold",t.TimesRomanItalic="Times-Italic",t.TimesRomanBoldItalic="Times-BoldItalic",t.Symbol="Symbol",t.ZapfDingbats="ZapfDingbats"})(z3=Ps.StandardFonts||(Ps.StandardFonts={}))});var H0=D(G0=>{"use strict";Object.defineProperty(G0,"__esModule",{value:!0});var hr=(k(),R(T)),W3=hr.__importDefault(Xn()),Rl=hr.__importDefault(K0()),Es=hr.__importDefault(P0()),Bl=hr.__importDefault(O0()),Nl=hr.__importDefault(k0()),Ss=hr.__importDefault(I0()),L0=hr.__importDefault(j0()),Il=hr.__importDefault(W0()),Sr=Ha(),L3=hr.__importDefault(bn()),G3=Tl(),H3=Ga(),kl=Wn(),we=et(),He=ae(),K3=(function(){function t(e,r){var n=this;this.embedDefaultFont=function(){return n.doc.embedStandardFont(G3.StandardFonts.Helvetica)},He.assertIs(e,"acroForm",[[we.PDFAcroForm,"PDFAcroForm"]]),He.assertIs(r,"doc",[[W3.default,"PDFDocument"]]),this.acroForm=e,this.doc=r,this.dirtyFields=new Set,this.defaultFontCache=He.Cache.populatedBy(this.embedDefaultFont)}return t.prototype.hasXFA=function(){return this.acroForm.dict.has(we.PDFName.of("XFA"))},t.prototype.deleteXFA=function(){this.acroForm.dict.delete(we.PDFName.of("XFA"))},t.prototype.getFields=function(){for(var e=this.acroForm.getAllFields(),r=[],n=0,i=e.length;n<i;n++){var a=e[n],o=a[0],s=a[1],l=X3(o,s,this.doc);l&&r.push(l)}return r},t.prototype.getFieldMaybe=function(e){He.assertIs(e,"name",["string"]);for(var r=this.getFields(),n=0,i=r.length;n<i;n++){var a=r[n];if(a.getName()===e)return a}},t.prototype.getField=function(e){He.assertIs(e,"name",["string"]);var r=this.getFieldMaybe(e);if(r)return r;throw new Sr.NoSuchFieldError(e)},t.prototype.getButton=function(e){He.assertIs(e,"name",["string"]);var r=this.getField(e);if(r instanceof Rl.default)return r;throw new Sr.UnexpectedFieldTypeError(e,Rl.default,r)},t.prototype.getCheckBox=function(e){He.assertIs(e,"name",["string"]);var r=this.getField(e);if(r instanceof Es.default)return r;throw new Sr.UnexpectedFieldTypeError(e,Es.default,r)},t.prototype.getDropdown=function(e){He.assertIs(e,"name",["string"]);var r=this.getField(e);if(r instanceof Bl.default)return r;throw new Sr.UnexpectedFieldTypeError(e,Bl.default,r)},t.prototype.getOptionList=function(e){He.assertIs(e,"name",["string"]);var r=this.getField(e);if(r instanceof Nl.default)return r;throw new Sr.UnexpectedFieldTypeError(e,Nl.default,r)},t.prototype.getRadioGroup=function(e){He.assertIs(e,"name",["string"]);var r=this.getField(e);if(r instanceof Ss.default)return r;throw new Sr.UnexpectedFieldTypeError(e,Ss.default,r)},t.prototype.getSignature=function(e){He.assertIs(e,"name",["string"]);var r=this.getField(e);if(r instanceof L0.default)return r;throw new Sr.UnexpectedFieldTypeError(e,L0.default,r)},t.prototype.getTextField=function(e){He.assertIs(e,"name",["string"]);var r=this.getField(e);if(r instanceof Il.default)return r;throw new Sr.UnexpectedFieldTypeError(e,Il.default,r)},t.prototype.createButton=function(e){He.assertIs(e,"name",["string"]);var r=Ya(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=we.PDFAcroPushButton.create(this.doc.context);return i.setPartialName(r.terminal),Ja(n,[i,i.ref],r.terminal),Rl.default.of(i,i.ref,this.doc)},t.prototype.createCheckBox=function(e){He.assertIs(e,"name",["string"]);var r=Ya(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=we.PDFAcroCheckBox.create(this.doc.context);return i.setPartialName(r.terminal),Ja(n,[i,i.ref],r.terminal),Es.default.of(i,i.ref,this.doc)},t.prototype.createDropdown=function(e){He.assertIs(e,"name",["string"]);var r=Ya(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=we.PDFAcroComboBox.create(this.doc.context);return i.setPartialName(r.terminal),Ja(n,[i,i.ref],r.terminal),Bl.default.of(i,i.ref,this.doc)},t.prototype.createOptionList=function(e){He.assertIs(e,"name",["string"]);var r=Ya(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=we.PDFAcroListBox.create(this.doc.context);return i.setPartialName(r.terminal),Ja(n,[i,i.ref],r.terminal),Nl.default.of(i,i.ref,this.doc)},t.prototype.createRadioGroup=function(e){He.assertIs(e,"name",["string"]);var r=Ya(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=we.PDFAcroRadioButton.create(this.doc.context);return i.setPartialName(r.terminal),Ja(n,[i,i.ref],r.terminal),Ss.default.of(i,i.ref,this.doc)},t.prototype.createTextField=function(e){He.assertIs(e,"name",["string"]);var r=Ya(e),n=this.findOrCreateNonTerminals(r.nonTerminal),i=we.PDFAcroText.create(this.doc.context);return i.setPartialName(r.terminal),Ja(n,[i,i.ref],r.terminal),Il.default.of(i,i.ref,this.doc)},t.prototype.flatten=function(e){e===void 0&&(e={updateFieldAppearances:!0}),e.updateFieldAppearances&&this.updateFieldAppearances();for(var r=this.getFields(),n=0,i=r.length;n<i;n++){for(var a=r[n],o=a.acroField.getWidgets(),s=0,l=o.length;s<l;s++){var u=o[s],c=this.findWidgetPage(u),f=this.findWidgetAppearanceRef(a,u),d=c.node.newXObject("FlatWidget",f),p=u.getRectangle(),h=hr.__spreadArrays([kl.pushGraphicsState(),kl.translate(p.x,p.y)],H3.rotateInPlace(hr.__assign(hr.__assign({},p),{rotation:0})),[kl.drawObject(d),kl.popGraphicsState()]).filter(Boolean);c.pushOperators.apply(c,h)}this.removeField(a)}},t.prototype.removeField=function(e){for(var r=e.acroField.getWidgets(),n=new Set,i=0,a=r.length;i<a;i++){var o=r[i],s=this.findWidgetAppearanceRef(e,o),l=this.findWidgetPage(o);n.add(l),l.node.removeAnnot(s)}n.forEach(function(p){return p.node.removeAnnot(e.ref)}),this.acroForm.removeField(e.acroField);for(var u=e.acroField.normalizedEntries().Kids,c=u.size(),f=0;f<c;f++){var d=u.get(f);d instanceof we.PDFRef&&this.doc.context.delete(d)}this.doc.context.delete(e.ref)},t.prototype.updateFieldAppearances=function(e){He.assertOrUndefined(e,"font",[[L3.default,"PDFFont"]]),e=e??this.getDefaultFont();for(var r=this.getFields(),n=0,i=r.length;n<i;n++){var a=r[n];a.needsAppearancesUpdate()&&a.defaultUpdateAppearances(e)}},t.prototype.markFieldAsDirty=function(e){He.assertOrUndefined(e,"fieldRef",[[we.PDFRef,"PDFRef"]]),this.dirtyFields.add(e)},t.prototype.markFieldAsClean=function(e){He.assertOrUndefined(e,"fieldRef",[[we.PDFRef,"PDFRef"]]),this.dirtyFields.delete(e)},t.prototype.fieldIsDirty=function(e){return He.assertOrUndefined(e,"fieldRef",[[we.PDFRef,"PDFRef"]]),this.dirtyFields.has(e)},t.prototype.getDefaultFont=function(){return this.defaultFontCache.access()},t.prototype.findWidgetPage=function(e){var r=e.P(),n=this.doc.getPages().find(function(a){return a.ref===r});if(n===void 0){var i=this.doc.context.getObjectRef(e.dict);if(i===void 0)throw new Error("Could not find PDFRef for PDFObject");if(n=this.doc.findPageForAnnotationRef(i),n===void 0)throw new Error("Could not find page for PDFRef "+i)}return n},t.prototype.findWidgetAppearanceRef=function(e,r){var n,i=r.getNormalAppearance();if(i instanceof we.PDFDict&&(e instanceof Es.default||e instanceof Ss.default)){var a=e.acroField.getValue(),o=(n=i.get(a))!==null&&n!==void 0?n:i.get(we.PDFName.of("Off"));o instanceof we.PDFRef&&(i=o)}if(!(i instanceof we.PDFRef)){var s=e.getName();throw new Error("Failed to extract appearance ref for: "+s)}return i},t.prototype.findOrCreateNonTerminals=function(e){for(var r=[this.acroForm],n=0,i=e.length;n<i;n++){var a=e[n];if(!a)throw new Sr.InvalidFieldNamePartError(a);var o=r[0],s=r[1],l=this.findNonTerminal(a,o);if(l)r=l;else{var u=we.PDFAcroNonTerminal.create(this.doc.context);u.setPartialName(a),u.setParent(s);var c=this.doc.context.register(u.dict);o.addField(c),r=[u,c]}}return r},t.prototype.findNonTerminal=function(e,r){for(var n=r instanceof we.PDFAcroForm?this.acroForm.getFields():we.createPDFAcroFields(r.Kids()),i=0,a=n.length;i<a;i++){var o=n[i],s=o[0],l=o[1];if(s.getPartialName()===e){if(s instanceof we.PDFAcroNonTerminal)return[s,l];throw new Sr.FieldAlreadyExistsError(e)}}},t.of=function(e,r){return new t(e,r)},t})();G0.default=K3;var X3=function(t,e,r){if(t instanceof we.PDFAcroPushButton)return Rl.default.of(t,e,r);if(t instanceof we.PDFAcroCheckBox)return Es.default.of(t,e,r);if(t instanceof we.PDFAcroComboBox)return Bl.default.of(t,e,r);if(t instanceof we.PDFAcroListBox)return Nl.default.of(t,e,r);if(t instanceof we.PDFAcroText)return Il.default.of(t,e,r);if(t instanceof we.PDFAcroRadioButton)return Ss.default.of(t,e,r);if(t instanceof we.PDFAcroSignature)return L0.default.of(t,e,r)},Ya=function(t){if(t.length===0)throw new Error("PDF field names must not be empty strings");for(var e=t.split("."),r=0,n=e.length;r<n;r++)if(e[r]==="")throw new Error('Periods in PDF field names must be separated by at least one character: "'+t+'"');return e.length===1?{nonTerminal:[],terminal:e[0]}:{nonTerminal:e.slice(0,e.length-1),terminal:e[e.length-1]}},Ja=function(t,e,r){for(var n=t[0],i=t[1],a=e[0],o=e[1],s=n.normalizedEntries(),l=we.createPDFAcroFields("Kids"in s?s.Kids:s.Fields),u=0,c=l.length;u<c;u++)if(l[u][0].getPartialName()===r)throw new Sr.FieldAlreadyExistsError(r);n.addField(o),a.setParent(i)}});var X0=D(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});ql.PageSizes=void 0;ql.PageSizes={"4A0":[4767.87,6740.79],"2A0":[3370.39,4767.87],A0:[2383.94,3370.39],A1:[1683.78,2383.94],A2:[1190.55,1683.78],A3:[841.89,1190.55],A4:[595.28,841.89],A5:[419.53,595.28],A6:[297.64,419.53],A7:[209.76,297.64],A8:[147.4,209.76],A9:[104.88,147.4],A10:[73.7,104.88],B0:[2834.65,4008.19],B1:[2004.09,2834.65],B2:[1417.32,2004.09],B3:[1000.63,1417.32],B4:[708.66,1000.63],B5:[498.9,708.66],B6:[354.33,498.9],B7:[249.45,354.33],B8:[175.75,249.45],B9:[124.72,175.75],B10:[87.87,124.72],C0:[2599.37,3676.54],C1:[1836.85,2599.37],C2:[1298.27,1836.85],C3:[918.43,1298.27],C4:[649.13,918.43],C5:[459.21,649.13],C6:[323.15,459.21],C7:[229.61,323.15],C8:[161.57,229.61],C9:[113.39,161.57],C10:[79.37,113.39],RA0:[2437.8,3458.27],RA1:[1729.13,2437.8],RA2:[1218.9,1729.13],RA3:[864.57,1218.9],RA4:[609.45,864.57],SRA0:[2551.18,3628.35],SRA1:[1814.17,2551.18],SRA2:[1275.59,1814.17],SRA3:[907.09,1275.59],SRA4:[637.8,907.09],Executive:[521.86,756],Folio:[612,936],Legal:[612,1008],Letter:[612,792],Tabloid:[792,1224]}});var Z0=D(Os=>{"use strict";Object.defineProperty(Os,"__esModule",{value:!0});Os.ParseSpeeds=void 0;var Z3;(function(t){t[t.Fastest=1/0]="Fastest",t[t.Fast=1500]="Fast",t[t.Medium=500]="Medium",t[t.Slow=100]="Slow"})(Z3=Os.ParseSpeeds||(Os.ParseSpeeds={}))});var CF=D(Y0=>{"use strict";Object.defineProperty(Y0,"__esModule",{value:!0});var _F=(k(),R(T)),mt=et(),Y3=(function(){function t(e,r,n){this.alreadyEmbedded=!1,this.ref=e,this.doc=r,this.embedder=n}return t.prototype.embed=function(){return _F.__awaiter(this,void 0,void 0,function(){var e,r,n,i,a;return _F.__generator(this,function(o){switch(o.label){case 0:return this.alreadyEmbedded?[3,2]:[4,this.embedder.embedIntoContext(this.doc.context,this.ref)];case 1:e=o.sent(),this.doc.catalog.has(mt.PDFName.of("Names"))||this.doc.catalog.set(mt.PDFName.of("Names"),this.doc.context.obj({})),r=this.doc.catalog.lookup(mt.PDFName.of("Names"),mt.PDFDict),r.has(mt.PDFName.of("EmbeddedFiles"))||r.set(mt.PDFName.of("EmbeddedFiles"),this.doc.context.obj({})),n=r.lookup(mt.PDFName.of("EmbeddedFiles"),mt.PDFDict),n.has(mt.PDFName.of("Names"))||n.set(mt.PDFName.of("Names"),this.doc.context.obj([])),i=n.lookup(mt.PDFName.of("Names"),mt.PDFArray),i.push(mt.PDFHexString.fromText(this.embedder.fileName)),i.push(e),this.doc.catalog.has(mt.PDFName.of("AF"))||this.doc.catalog.set(mt.PDFName.of("AF"),this.doc.context.obj([])),a=this.doc.catalog.lookup(mt.PDFName.of("AF"),mt.PDFArray),a.push(e),this.alreadyEmbedded=!0,o.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})();Y0.default=Y3});var Q0=D(J0=>{"use strict";Object.defineProperty(J0,"__esModule",{value:!0});var wF=(k(),R(T)),Jt=et(),J3=(function(){function t(e,r,n){this.alreadyEmbedded=!1,this.ref=e,this.doc=r,this.embedder=n}return t.prototype.embed=function(){return wF.__awaiter(this,void 0,void 0,function(){var e,r,n,i,a,o,s;return wF.__generator(this,function(l){switch(l.label){case 0:return this.alreadyEmbedded?[3,2]:(e=this.doc,r=e.catalog,n=e.context,[4,this.embedder.embedIntoContext(this.doc.context,this.ref)]);case 1:i=l.sent(),r.has(Jt.PDFName.of("Names"))||r.set(Jt.PDFName.of("Names"),n.obj({})),a=r.lookup(Jt.PDFName.of("Names"),Jt.PDFDict),a.has(Jt.PDFName.of("JavaScript"))||a.set(Jt.PDFName.of("JavaScript"),n.obj({})),o=a.lookup(Jt.PDFName.of("JavaScript"),Jt.PDFDict),o.has(Jt.PDFName.of("Names"))||o.set(Jt.PDFName.of("Names"),n.obj([])),s=o.lookup(Jt.PDFName.of("Names"),Jt.PDFArray),s.push(Jt.PDFHexString.fromText(this.embedder.scriptName)),s.push(i),this.alreadyEmbedded=!0,l.label=2;case 2:return[2]}})})},t.of=function(e,r,n){return new t(e,r,n)},t})();J0.default=J3});var PF=D(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});var $0=(k(),R(T)),Q3=$0.__importDefault(kt()),$3=(function(){function t(e,r){this.script=e,this.scriptName=r}return t.for=function(e,r){return new t(e,r)},t.prototype.embedIntoContext=function(e,r){return $0.__awaiter(this,void 0,void 0,function(){var n;return $0.__generator(this,function(i){return n=e.obj({Type:"Action",S:"JavaScript",JS:Q3.default.fromText(this.script)}),r?(e.assign(r,n),[2,r]):[2,e.register(n)]})})},t})();ep.default=$3});var Xn=D(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});var de=(k(),R(T)),jl=Ha(),eT=de.__importDefault(_l()),EF=de.__importDefault(bn()),SF=de.__importDefault(wl()),Qa=de.__importDefault(_n()),tT=de.__importDefault(H0()),rT=X0(),te=et(),nT=Z0(),Y=ae(),OF=de.__importStar(Nd()),iT=de.__importDefault(CF()),aT=de.__importDefault(Q0()),oT=de.__importDefault(PF()),sT=(function(){function t(e,r,n){var i=this;if(this.defaultWordBreaks=[" "],this.computePages=function(){var a=[];return i.catalog.Pages().traverse(function(o,s){if(o instanceof te.PDFPageLeaf){var l=i.pageMap.get(o);l||(l=Qa.default.of(o,s,i),i.pageMap.set(o,l)),a.push(l)}}),a},this.getOrCreateForm=function(){var a=i.catalog.getOrCreateAcroForm();return tT.default.of(a,i)},Y.assertIs(e,"context",[[te.PDFContext,"PDFContext"]]),Y.assertIs(r,"ignoreEncryption",["boolean"]),this.context=e,this.catalog=e.lookup(e.trailerInfo.Root),this.isEncrypted=!!e.lookup(e.trailerInfo.Encrypt),this.pageCache=Y.Cache.populatedBy(this.computePages),this.pageMap=new Map,this.formCache=Y.Cache.populatedBy(this.getOrCreateForm),this.fonts=[],this.images=[],this.embeddedPages=[],this.embeddedFiles=[],this.javaScripts=[],!r&&this.isEncrypted)throw new jl.EncryptedPDFError;n&&this.updateInfoDict()}return t.load=function(e,r){return r===void 0&&(r={}),de.__awaiter(this,void 0,void 0,function(){var n,i,a,o,s,l,u,c,f,d,p,h;return de.__generator(this,function(v){switch(v.label){case 0:return n=r.ignoreEncryption,i=n===void 0?!1:n,a=r.parseSpeed,o=a===void 0?nT.ParseSpeeds.Slow:a,s=r.throwOnInvalidObject,l=s===void 0?!1:s,u=r.updateMetadata,c=u===void 0?!0:u,f=r.capNumbers,d=f===void 0?!1:f,Y.assertIs(e,"pdf",["string",Uint8Array,ArrayBuffer]),Y.assertIs(i,"ignoreEncryption",["boolean"]),Y.assertIs(o,"parseSpeed",["number"]),Y.assertIs(l,"throwOnInvalidObject",["boolean"]),p=Y.toUint8Array(e),[4,te.PDFParser.forBytesWithOptions(p,o,l,d).parseDocument()];case 1:return h=v.sent(),[2,new t(h,i,c)]}})})},t.create=function(e){return e===void 0&&(e={}),de.__awaiter(this,void 0,void 0,function(){var r,n,i,a,o,s;return de.__generator(this,function(l){return r=e.updateMetadata,n=r===void 0?!0:r,i=te.PDFContext.create(),a=te.PDFPageTree.withContext(i),o=i.register(a),s=te.PDFCatalog.withContextAndPages(i,o),i.trailerInfo.Root=i.register(s),[2,new t(i,!1,n)]})})},t.prototype.registerFontkit=function(e){this.fontkit=e},t.prototype.getForm=function(){var e=this.formCache.access();return e.hasXFA()&&(console.warn("Removing XFA form data as pdf-lib does not support reading or writing XFA"),e.deleteXFA()),e},t.prototype.getTitle=function(){var e=this.getInfoDict().lookup(te.PDFName.Title);if(e)return Zn(e),e.decodeText()},t.prototype.getAuthor=function(){var e=this.getInfoDict().lookup(te.PDFName.Author);if(e)return Zn(e),e.decodeText()},t.prototype.getSubject=function(){var e=this.getInfoDict().lookup(te.PDFName.Subject);if(e)return Zn(e),e.decodeText()},t.prototype.getKeywords=function(){var e=this.getInfoDict().lookup(te.PDFName.Keywords);if(e)return Zn(e),e.decodeText()},t.prototype.getCreator=function(){var e=this.getInfoDict().lookup(te.PDFName.Creator);if(e)return Zn(e),e.decodeText()},t.prototype.getProducer=function(){var e=this.getInfoDict().lookup(te.PDFName.Producer);if(e)return Zn(e),e.decodeText()},t.prototype.getCreationDate=function(){var e=this.getInfoDict().lookup(te.PDFName.CreationDate);if(e)return Zn(e),e.decodeDate()},t.prototype.getModificationDate=function(){var e=this.getInfoDict().lookup(te.PDFName.ModDate);if(e)return Zn(e),e.decodeDate()},t.prototype.setTitle=function(e,r){Y.assertIs(e,"title",["string"]);var n=te.PDFName.of("Title");if(this.getInfoDict().set(n,te.PDFHexString.fromText(e)),r?.showInWindowTitleBar){var i=this.catalog.getOrCreateViewerPreferences();i.setDisplayDocTitle(!0)}},t.prototype.setAuthor=function(e){Y.assertIs(e,"author",["string"]);var r=te.PDFName.of("Author");this.getInfoDict().set(r,te.PDFHexString.fromText(e))},t.prototype.setSubject=function(e){Y.assertIs(e,"author",["string"]);var r=te.PDFName.of("Subject");this.getInfoDict().set(r,te.PDFHexString.fromText(e))},t.prototype.setKeywords=function(e){Y.assertIs(e,"keywords",[Array]);var r=te.PDFName.of("Keywords");this.getInfoDict().set(r,te.PDFHexString.fromText(e.join(" ")))},t.prototype.setCreator=function(e){Y.assertIs(e,"creator",["string"]);var r=te.PDFName.of("Creator");this.getInfoDict().set(r,te.PDFHexString.fromText(e))},t.prototype.setProducer=function(e){Y.assertIs(e,"creator",["string"]);var r=te.PDFName.of("Producer");this.getInfoDict().set(r,te.PDFHexString.fromText(e))},t.prototype.setLanguage=function(e){Y.assertIs(e,"language",["string"]);var r=te.PDFName.of("Lang");this.catalog.set(r,te.PDFString.of(e))},t.prototype.setCreationDate=function(e){Y.assertIs(e,"creationDate",[[Date,"Date"]]);var r=te.PDFName.of("CreationDate");this.getInfoDict().set(r,te.PDFString.fromDate(e))},t.prototype.setModificationDate=function(e){Y.assertIs(e,"modificationDate",[[Date,"Date"]]);var r=te.PDFName.of("ModDate");this.getInfoDict().set(r,te.PDFString.fromDate(e))},t.prototype.getPageCount=function(){return this.pageCount===void 0&&(this.pageCount=this.getPages().length),this.pageCount},t.prototype.getPages=function(){return this.pageCache.access()},t.prototype.getPage=function(e){var r=this.getPages();return Y.assertRange(e,"index",0,r.length-1),r[e]},t.prototype.getPageIndices=function(){return Y.range(0,this.getPageCount())},t.prototype.removePage=function(e){var r=this.getPageCount();if(this.pageCount===0)throw new jl.RemovePageFromEmptyDocumentError;Y.assertRange(e,"index",0,r-1),this.catalog.removeLeafNode(e),this.pageCount=r-1},t.prototype.addPage=function(e){return Y.assertIs(e,"page",["undefined",[Qa.default,"PDFPage"],Array]),this.insertPage(this.getPageCount(),e)},t.prototype.insertPage=function(e,r){var n=this.getPageCount();if(Y.assertRange(e,"index",0,n),Y.assertIs(r,"page",["undefined",[Qa.default,"PDFPage"],Array]),!r||Array.isArray(r)){var i=Array.isArray(r)?r:rT.PageSizes.A4;r=Qa.default.create(this),r.setSize.apply(r,i)}else if(r.doc!==this)throw new jl.ForeignPageError;var a=this.catalog.insertLeafNode(r.ref,e);return r.node.setParent(a),this.pageMap.set(r.node,r),this.pageCache.invalidate(),this.pageCount=n+1,r},t.prototype.copyPages=function(e,r){return de.__awaiter(this,void 0,void 0,function(){var n,i,a,o,s,l,u,c;return de.__generator(this,function(f){switch(f.label){case 0:return Y.assertIs(e,"srcDoc",[[t,"PDFDocument"]]),Y.assertIs(r,"indices",[Array]),[4,e.flush()];case 1:for(f.sent(),n=te.PDFObjectCopier.for(e.context,this.context),i=e.getPages(),a=new Array(r.length),o=0,s=r.length;o<s;o++)l=i[r[o]],u=n.copy(l.node),c=this.context.register(u),a[o]=Qa.default.of(u,c,this);return[2,a]}})})},t.prototype.copy=function(){return de.__awaiter(this,void 0,void 0,function(){var e,r,n,i;return de.__generator(this,function(a){switch(a.label){case 0:return[4,t.create()];case 1:return e=a.sent(),[4,e.copyPages(this,this.getPageIndices())];case 2:for(r=a.sent(),n=0,i=r.length;n<i;n++)e.addPage(r[n]);return this.getAuthor()!==void 0&&e.setAuthor(this.getAuthor()),this.getCreationDate()!==void 0&&e.setCreationDate(this.getCreationDate()),this.getCreator()!==void 0&&e.setCreator(this.getCreator()),this.getModificationDate()!==void 0&&e.setModificationDate(this.getModificationDate()),this.getProducer()!==void 0&&e.setProducer(this.getProducer()),this.getSubject()!==void 0&&e.setSubject(this.getSubject()),this.getTitle()!==void 0&&e.setTitle(this.getTitle()),e.defaultWordBreaks=this.defaultWordBreaks,[2,e]}})})},t.prototype.addJavaScript=function(e,r){Y.assertIs(e,"name",["string"]),Y.assertIs(r,"script",["string"]);var n=oT.default.for(r,e),i=this.context.nextRef(),a=aT.default.of(i,this,n);this.javaScripts.push(a)},t.prototype.attach=function(e,r,n){return n===void 0&&(n={}),de.__awaiter(this,void 0,void 0,function(){var i,a,o,s;return de.__generator(this,function(l){return Y.assertIs(e,"attachment",["string",Uint8Array,ArrayBuffer]),Y.assertIs(r,"name",["string"]),Y.assertOrUndefined(n.mimeType,"mimeType",["string"]),Y.assertOrUndefined(n.description,"description",["string"]),Y.assertOrUndefined(n.creationDate,"options.creationDate",[Date]),Y.assertOrUndefined(n.modificationDate,"options.modificationDate",[Date]),Y.assertIsOneOfOrUndefined(n.afRelationship,"options.afRelationship",OF.AFRelationship),i=Y.toUint8Array(e),a=OF.default.for(i,r,n),o=this.context.nextRef(),s=iT.default.of(o,this,a),this.embeddedFiles.push(s),[2]})})},t.prototype.embedFont=function(e,r){return r===void 0&&(r={}),de.__awaiter(this,void 0,void 0,function(){var n,i,a,o,s,l,u,c,f,d;return de.__generator(this,function(p){switch(p.label){case 0:return n=r.subset,i=n===void 0?!1:n,a=r.customName,o=r.features,Y.assertIs(e,"font",["string",Uint8Array,ArrayBuffer]),Y.assertIs(i,"subset",["boolean"]),Y.isStandardFont(e)?(s=te.StandardFontEmbedder.for(e,a),[3,7]):[3,1];case 1:return Y.canBeConvertedToUint8Array(e)?(l=Y.toUint8Array(e),u=this.assertFontkit(),i?[4,te.CustomFontSubsetEmbedder.for(u,l,a,o)]:[3,3]):[3,6];case 2:return c=p.sent(),[3,5];case 3:return[4,te.CustomFontEmbedder.for(u,l,a,o)];case 4:c=p.sent(),p.label=5;case 5:return s=c,[3,7];case 6:throw new TypeError("`font` must be one of `StandardFonts | string | Uint8Array | ArrayBuffer`");case 7:return f=this.context.nextRef(),d=EF.default.of(f,this,s),this.fonts.push(d),[2,d]}})})},t.prototype.embedStandardFont=function(e,r){if(Y.assertIs(e,"font",["string"]),!Y.isStandardFont(e))throw new TypeError("`font` must be one of type `StandardFonts`");var n=te.StandardFontEmbedder.for(e,r),i=this.context.nextRef(),a=EF.default.of(i,this,n);return this.fonts.push(a),a},t.prototype.embedJpg=function(e){return de.__awaiter(this,void 0,void 0,function(){var r,n,i,a;return de.__generator(this,function(o){switch(o.label){case 0:return Y.assertIs(e,"jpg",["string",Uint8Array,ArrayBuffer]),r=Y.toUint8Array(e),[4,te.JpegEmbedder.for(r)];case 1:return n=o.sent(),i=this.context.nextRef(),a=SF.default.of(i,this,n),this.images.push(a),[2,a]}})})},t.prototype.embedPng=function(e){return de.__awaiter(this,void 0,void 0,function(){var r,n,i,a;return de.__generator(this,function(o){switch(o.label){case 0:return Y.assertIs(e,"png",["string",Uint8Array,ArrayBuffer]),r=Y.toUint8Array(e),[4,te.PngEmbedder.for(r)];case 1:return n=o.sent(),i=this.context.nextRef(),a=SF.default.of(i,this,n),this.images.push(a),[2,a]}})})},t.prototype.embedPdf=function(e,r){return r===void 0&&(r=[0]),de.__awaiter(this,void 0,void 0,function(){var n,i,a;return de.__generator(this,function(o){switch(o.label){case 0:return Y.assertIs(e,"pdf",["string",Uint8Array,ArrayBuffer,[t,"PDFDocument"]]),Y.assertIs(r,"indices",[Array]),e instanceof t?(i=e,[3,3]):[3,1];case 1:return[4,t.load(e)];case 2:i=o.sent(),o.label=3;case 3:return n=i,a=Y.pluckIndices(n.getPages(),r),[2,this.embedPages(a)]}})})},t.prototype.embedPage=function(e,r,n){return de.__awaiter(this,void 0,void 0,function(){var i;return de.__generator(this,function(a){switch(a.label){case 0:return Y.assertIs(e,"page",[[Qa.default,"PDFPage"]]),[4,this.embedPages([e],[r],[n])];case 1:return i=a.sent()[0],[2,i]}})})},t.prototype.embedPages=function(e,r,n){return r===void 0&&(r=[]),n===void 0&&(n=[]),de.__awaiter(this,void 0,void 0,function(){var u,c,i,a,o,s,l,u,c,f,d,p,h,v,g;return de.__generator(this,function(m){switch(m.label){case 0:if(e.length===0)return[2,[]];for(u=0,c=e.length-1;u<c;u++)if(i=e[u],a=e[u+1],i.node.context!==a.node.context)throw new te.PageEmbeddingMismatchedContextError;o=e[0].node.context,s=o===this.context?function(b){return b}:te.PDFObjectCopier.for(o,this.context).copy,l=new Array(e.length),u=0,c=e.length,m.label=1;case 1:return u<c?(f=s(e[u].node),d=r[u],p=n[u],[4,te.PDFPageEmbedder.for(f,d,p)]):[3,4];case 2:h=m.sent(),v=this.context.nextRef(),l[u]=eT.default.of(v,this,h),m.label=3;case 3:return u++,[3,1];case 4:return(g=this.embeddedPages).push.apply(g,l),[2,l]}})})},t.prototype.flush=function(){return de.__awaiter(this,void 0,void 0,function(){return de.__generator(this,function(e){switch(e.label){case 0:return[4,this.embedAll(this.fonts)];case 1:return e.sent(),[4,this.embedAll(this.images)];case 2:return e.sent(),[4,this.embedAll(this.embeddedPages)];case 3:return e.sent(),[4,this.embedAll(this.embeddedFiles)];case 4:return e.sent(),[4,this.embedAll(this.javaScripts)];case 5:return e.sent(),[2]}})})},t.prototype.save=function(e){return e===void 0&&(e={}),de.__awaiter(this,void 0,void 0,function(){var r,n,i,a,o,s,l,u,c,f;return de.__generator(this,function(d){switch(d.label){case 0:return r=e.useObjectStreams,n=r===void 0?!0:r,i=e.addDefaultPage,a=i===void 0?!0:i,o=e.objectsPerTick,s=o===void 0?50:o,l=e.updateFieldAppearances,u=l===void 0?!0:l,Y.assertIs(n,"useObjectStreams",["boolean"]),Y.assertIs(a,"addDefaultPage",["boolean"]),Y.assertIs(s,"objectsPerTick",["number"]),Y.assertIs(u,"updateFieldAppearances",["boolean"]),a&&this.getPageCount()===0&&this.addPage(),u&&(c=this.formCache.getValue(),c&&c.updateFieldAppearances()),[4,this.flush()];case 1:return d.sent(),f=n?te.PDFStreamWriter:te.PDFWriter,[2,f.forContext(this.context,s).serializeToBuffer()]}})})},t.prototype.saveAsBase64=function(e){return e===void 0&&(e={}),de.__awaiter(this,void 0,void 0,function(){var r,n,i,a,o;return de.__generator(this,function(s){switch(s.label){case 0:return r=e.dataUri,n=r===void 0?!1:r,i=de.__rest(e,["dataUri"]),Y.assertIs(n,"dataUri",["boolean"]),[4,this.save(i)];case 1:return a=s.sent(),o=Y.encodeToBase64(a),[2,n?"data:application/pdf;base64,"+o:o]}})})},t.prototype.findPageForAnnotationRef=function(e){for(var r=this.getPages(),n=0,i=r.length;n<i;n++){var a=r[n],o=a.node.Annots();if(o?.indexOf(e)!==void 0)return a}},t.prototype.embedAll=function(e){return de.__awaiter(this,void 0,void 0,function(){var r,n;return de.__generator(this,function(i){switch(i.label){case 0:r=0,n=e.length,i.label=1;case 1:return r<n?[4,e[r].embed()]:[3,4];case 2:i.sent(),i.label=3;case 3:return r++,[3,1];case 4:return[2]}})})},t.prototype.updateInfoDict=function(){var e="pdf-lib (https://github.com/Hopding/pdf-lib)",r=new Date,n=this.getInfoDict();this.setProducer(e),this.setModificationDate(r),n.get(te.PDFName.of("Creator"))||this.setCreator(e),n.get(te.PDFName.of("CreationDate"))||this.setCreationDate(r)},t.prototype.getInfoDict=function(){var e=this.context.lookup(this.context.trailerInfo.Info);if(e instanceof te.PDFDict)return e;var r=this.context.obj({});return this.context.trailerInfo.Info=this.context.register(r),r},t.prototype.assertFontkit=function(){if(!this.fontkit)throw new jl.FontkitNotRegisteredError;return this.fontkit},t})();tp.default=sT;function Zn(t){if(!(t instanceof te.PDFHexString)&&!(t instanceof te.PDFString))throw new te.UnexpectedObjectTypeError([te.PDFHexString,te.PDFString],t)}});var rp=D(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.BlendMode=void 0;var uT;(function(t){t.Normal="Normal",t.Multiply="Multiply",t.Screen="Screen",t.Overlay="Overlay",t.Darken="Darken",t.Lighten="Lighten",t.ColorDodge="ColorDodge",t.ColorBurn="ColorBurn",t.HardLight="HardLight",t.SoftLight="SoftLight",t.Difference="Difference",t.Exclusion="Exclusion"})(uT=As.BlendMode||(As.BlendMode={}))});var _n=D(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});var Yn=(k(),R(T)),Ts=ur(),Ni=Ga(),Yr=Wn(),AF=Yn.__importDefault(Xn()),lT=Yn.__importDefault(_l()),TF=Yn.__importDefault(bn()),cT=Yn.__importDefault(wl()),Ii=rp(),St=Zt(),fT=Tl(),ft=et(),_=ae(),dT=(function(){function t(e,r,n){this.fontSize=24,this.fontColor=Ts.rgb(0,0,0),this.lineHeight=24,this.x=0,this.y=0,_.assertIs(e,"leafNode",[[ft.PDFPageLeaf,"PDFPageLeaf"]]),_.assertIs(r,"ref",[[ft.PDFRef,"PDFRef"]]),_.assertIs(n,"doc",[[AF.default,"PDFDocument"]]),this.node=e,this.ref=r,this.doc=n}return t.prototype.setRotation=function(e){var r=St.toDegrees(e);_.assertMultiple(r,"degreesAngle",90),this.node.set(ft.PDFName.of("Rotate"),this.doc.context.obj(r))},t.prototype.getRotation=function(){var e=this.node.Rotate();return St.degrees(e?e.asNumber():0)},t.prototype.setSize=function(e,r){_.assertIs(e,"width",["number"]),_.assertIs(r,"height",["number"]);var n=this.getMediaBox();this.setMediaBox(n.x,n.y,e,r);var i=this.getCropBox(),a=this.getBleedBox(),o=this.getTrimBox(),s=this.getArtBox(),l=this.node.CropBox(),u=this.node.BleedBox(),c=this.node.TrimBox(),f=this.node.ArtBox();l&&_.rectanglesAreEqual(i,n)&&this.setCropBox(n.x,n.y,e,r),u&&_.rectanglesAreEqual(a,n)&&this.setBleedBox(n.x,n.y,e,r),c&&_.rectanglesAreEqual(o,n)&&this.setTrimBox(n.x,n.y,e,r),f&&_.rectanglesAreEqual(s,n)&&this.setArtBox(n.x,n.y,e,r)},t.prototype.setWidth=function(e){_.assertIs(e,"width",["number"]),this.setSize(e,this.getSize().height)},t.prototype.setHeight=function(e){_.assertIs(e,"height",["number"]),this.setSize(this.getSize().width,e)},t.prototype.setMediaBox=function(e,r,n,i){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),_.assertIs(n,"width",["number"]),_.assertIs(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(ft.PDFName.MediaBox,a)},t.prototype.setCropBox=function(e,r,n,i){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),_.assertIs(n,"width",["number"]),_.assertIs(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(ft.PDFName.CropBox,a)},t.prototype.setBleedBox=function(e,r,n,i){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),_.assertIs(n,"width",["number"]),_.assertIs(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(ft.PDFName.BleedBox,a)},t.prototype.setTrimBox=function(e,r,n,i){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),_.assertIs(n,"width",["number"]),_.assertIs(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(ft.PDFName.TrimBox,a)},t.prototype.setArtBox=function(e,r,n,i){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),_.assertIs(n,"width",["number"]),_.assertIs(i,"height",["number"]);var a=this.doc.context.obj([e,r,e+n,r+i]);this.node.set(ft.PDFName.ArtBox,a)},t.prototype.getSize=function(){var e=this.getMediaBox(),r=e.width,n=e.height;return{width:r,height:n}},t.prototype.getWidth=function(){return this.getSize().width},t.prototype.getHeight=function(){return this.getSize().height},t.prototype.getMediaBox=function(){var e=this.node.MediaBox();return e.asRectangle()},t.prototype.getCropBox=function(){var e,r=this.node.CropBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getMediaBox()},t.prototype.getBleedBox=function(){var e,r=this.node.BleedBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.getTrimBox=function(){var e,r=this.node.TrimBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.getArtBox=function(){var e,r=this.node.ArtBox();return(e=r?.asRectangle())!==null&&e!==void 0?e:this.getCropBox()},t.prototype.translateContent=function(e,r){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),this.node.normalize(),this.getContentStream();var n=this.createContentStream(Yr.pushGraphicsState(),Yr.translate(e,r)),i=this.doc.context.register(n),a=this.createContentStream(Yr.popGraphicsState()),o=this.doc.context.register(a);this.node.wrapContentStreams(i,o)},t.prototype.scale=function(e,r){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),this.setSize(this.getWidth()*e,this.getHeight()*r),this.scaleContent(e,r),this.scaleAnnotations(e,r)},t.prototype.scaleContent=function(e,r){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),this.node.normalize(),this.getContentStream();var n=this.createContentStream(Yr.pushGraphicsState(),Yr.scale(e,r)),i=this.doc.context.register(n),a=this.createContentStream(Yr.popGraphicsState()),o=this.doc.context.register(a);this.node.wrapContentStreams(i,o)},t.prototype.scaleAnnotations=function(e,r){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]);var n=this.node.Annots();if(n)for(var i=0;i<n.size();i++){var a=n.lookup(i);a instanceof ft.PDFDict&&this.scaleAnnot(a,e,r)}},t.prototype.resetPosition=function(){this.getContentStream(!1),this.x=0,this.y=0},t.prototype.setFont=function(e){_.assertIs(e,"font",[[TF.default,"PDFFont"]]),this.font=e,this.fontKey=this.node.newFontDictionary(this.font.name,this.font.ref)},t.prototype.setFontSize=function(e){_.assertIs(e,"fontSize",["number"]),this.fontSize=e},t.prototype.setFontColor=function(e){_.assertIs(e,"fontColor",[[Object,"Color"]]),this.fontColor=e},t.prototype.setLineHeight=function(e){_.assertIs(e,"lineHeight",["number"]),this.lineHeight=e},t.prototype.getPosition=function(){return{x:this.x,y:this.y}},t.prototype.getX=function(){return this.x},t.prototype.getY=function(){return this.y},t.prototype.moveTo=function(e,r){_.assertIs(e,"x",["number"]),_.assertIs(r,"y",["number"]),this.x=e,this.y=r},t.prototype.moveDown=function(e){_.assertIs(e,"yDecrease",["number"]),this.y-=e},t.prototype.moveUp=function(e){_.assertIs(e,"yIncrease",["number"]),this.y+=e},t.prototype.moveLeft=function(e){_.assertIs(e,"xDecrease",["number"]),this.x-=e},t.prototype.moveRight=function(e){_.assertIs(e,"xIncrease",["number"]),this.x+=e},t.prototype.pushOperators=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];_.assertEachIs(e,"operator",[[ft.PDFOperator,"PDFOperator"]]);var n=this.getContentStream();n.push.apply(n,e)},t.prototype.drawText=function(e,r){var n,i,a,o,s,l,u;r===void 0&&(r={}),_.assertIs(e,"text",["string"]),_.assertOrUndefined(r.color,"options.color",[[Object,"Color"]]),_.assertRangeOrUndefined(r.opacity,"opacity.opacity",0,1),_.assertOrUndefined(r.font,"options.font",[[TF.default,"PDFFont"]]),_.assertOrUndefined(r.size,"options.size",["number"]),_.assertOrUndefined(r.rotate,"options.rotate",[[Object,"Rotation"]]),_.assertOrUndefined(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),_.assertOrUndefined(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),_.assertOrUndefined(r.x,"options.x",["number"]),_.assertOrUndefined(r.y,"options.y",["number"]),_.assertOrUndefined(r.lineHeight,"options.lineHeight",["number"]),_.assertOrUndefined(r.maxWidth,"options.maxWidth",["number"]),_.assertOrUndefined(r.wordBreaks,"options.wordBreaks",[Array]),_.assertIsOneOfOrUndefined(r.blendMode,"options.blendMode",Ii.BlendMode);for(var c=this.setOrEmbedFont(r.font),f=c.oldFont,d=c.newFont,p=c.newFontKey,h=r.size||this.fontSize,v=r.wordBreaks||this.doc.defaultWordBreaks,g=function(S){return d.widthOfTextAtSize(S,h)},m=r.maxWidth===void 0?_.lineSplit(_.cleanText(e)):_.breakTextIntoLines(e,v,r.maxWidth,g),b=new Array(m.length),w=0,F=m.length;w<F;w++)b[w]=d.encodeText(m[w]);var y=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),C=this.getContentStream();C.push.apply(C,Ni.drawLinesOfText(b,{color:(n=r.color)!==null&&n!==void 0?n:this.fontColor,font:p,size:h,rotate:(i=r.rotate)!==null&&i!==void 0?i:St.degrees(0),xSkew:(a=r.xSkew)!==null&&a!==void 0?a:St.degrees(0),ySkew:(o=r.ySkew)!==null&&o!==void 0?o:St.degrees(0),x:(s=r.x)!==null&&s!==void 0?s:this.x,y:(l=r.y)!==null&&l!==void 0?l:this.y,lineHeight:(u=r.lineHeight)!==null&&u!==void 0?u:this.lineHeight,graphicsState:y})),r.font&&(f?this.setFont(f):this.resetFont())},t.prototype.drawImage=function(e,r){var n,i,a,o,s,l,u;r===void 0&&(r={}),_.assertIs(e,"image",[[cT.default,"PDFImage"]]),_.assertOrUndefined(r.x,"options.x",["number"]),_.assertOrUndefined(r.y,"options.y",["number"]),_.assertOrUndefined(r.width,"options.width",["number"]),_.assertOrUndefined(r.height,"options.height",["number"]),_.assertOrUndefined(r.rotate,"options.rotate",[[Object,"Rotation"]]),_.assertOrUndefined(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),_.assertOrUndefined(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),_.assertRangeOrUndefined(r.opacity,"opacity.opacity",0,1),_.assertIsOneOfOrUndefined(r.blendMode,"options.blendMode",Ii.BlendMode);var c=this.node.newXObject("Image",e.ref),f=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),d=this.getContentStream();d.push.apply(d,Ni.drawImage(c,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,width:(a=r.width)!==null&&a!==void 0?a:e.size().width,height:(o=r.height)!==null&&o!==void 0?o:e.size().height,rotate:(s=r.rotate)!==null&&s!==void 0?s:St.degrees(0),xSkew:(l=r.xSkew)!==null&&l!==void 0?l:St.degrees(0),ySkew:(u=r.ySkew)!==null&&u!==void 0?u:St.degrees(0),graphicsState:f}))},t.prototype.drawPage=function(e,r){var n,i,a,o,s;r===void 0&&(r={}),_.assertIs(e,"embeddedPage",[[lT.default,"PDFEmbeddedPage"]]),_.assertOrUndefined(r.x,"options.x",["number"]),_.assertOrUndefined(r.y,"options.y",["number"]),_.assertOrUndefined(r.xScale,"options.xScale",["number"]),_.assertOrUndefined(r.yScale,"options.yScale",["number"]),_.assertOrUndefined(r.width,"options.width",["number"]),_.assertOrUndefined(r.height,"options.height",["number"]),_.assertOrUndefined(r.rotate,"options.rotate",[[Object,"Rotation"]]),_.assertOrUndefined(r.xSkew,"options.xSkew",[[Object,"Rotation"]]),_.assertOrUndefined(r.ySkew,"options.ySkew",[[Object,"Rotation"]]),_.assertRangeOrUndefined(r.opacity,"opacity.opacity",0,1),_.assertIsOneOfOrUndefined(r.blendMode,"options.blendMode",Ii.BlendMode);var l=this.node.newXObject("EmbeddedPdfPage",e.ref),u=this.maybeEmbedGraphicsState({opacity:r.opacity,blendMode:r.blendMode}),c=r.width!==void 0?r.width/e.width:r.xScale!==void 0?r.xScale:1,f=r.height!==void 0?r.height/e.height:r.yScale!==void 0?r.yScale:1,d=this.getContentStream();d.push.apply(d,Ni.drawPage(l,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,xScale:c,yScale:f,rotate:(a=r.rotate)!==null&&a!==void 0?a:St.degrees(0),xSkew:(o=r.xSkew)!==null&&o!==void 0?o:St.degrees(0),ySkew:(s=r.ySkew)!==null&&s!==void 0?s:St.degrees(0),graphicsState:u}))},t.prototype.drawSvgPath=function(e,r){var n,i,a,o,s,l,u,c,f;r===void 0&&(r={}),_.assertIs(e,"path",["string"]),_.assertOrUndefined(r.x,"options.x",["number"]),_.assertOrUndefined(r.y,"options.y",["number"]),_.assertOrUndefined(r.scale,"options.scale",["number"]),_.assertOrUndefined(r.rotate,"options.rotate",[[Object,"Rotation"]]),_.assertOrUndefined(r.borderWidth,"options.borderWidth",["number"]),_.assertOrUndefined(r.color,"options.color",[[Object,"Color"]]),_.assertRangeOrUndefined(r.opacity,"opacity.opacity",0,1),_.assertOrUndefined(r.borderColor,"options.borderColor",[[Object,"Color"]]),_.assertOrUndefined(r.borderDashArray,"options.borderDashArray",[Array]),_.assertOrUndefined(r.borderDashPhase,"options.borderDashPhase",["number"]),_.assertIsOneOfOrUndefined(r.borderLineCap,"options.borderLineCap",Yr.LineCapStyle),_.assertRangeOrUndefined(r.borderOpacity,"options.borderOpacity",0,1),_.assertIsOneOfOrUndefined(r.blendMode,"options.blendMode",Ii.BlendMode);var d=this.maybeEmbedGraphicsState({opacity:r.opacity,borderOpacity:r.borderOpacity,blendMode:r.blendMode});!("color"in r)&&!("borderColor"in r)&&(r.borderColor=Ts.rgb(0,0,0));var p=this.getContentStream();p.push.apply(p,Ni.drawSvgPath(e,{x:(n=r.x)!==null&&n!==void 0?n:this.x,y:(i=r.y)!==null&&i!==void 0?i:this.y,scale:r.scale,rotate:(a=r.rotate)!==null&&a!==void 0?a:St.degrees(0),color:(o=r.color)!==null&&o!==void 0?o:void 0,borderColor:(s=r.borderColor)!==null&&s!==void 0?s:void 0,borderWidth:(l=r.borderWidth)!==null&&l!==void 0?l:0,borderDashArray:(u=r.borderDashArray)!==null&&u!==void 0?u:void 0,borderDashPhase:(c=r.borderDashPhase)!==null&&c!==void 0?c:void 0,borderLineCap:(f=r.borderLineCap)!==null&&f!==void 0?f:void 0,graphicsState:d}))},t.prototype.drawLine=function(e){var r,n,i,a,o;_.assertIs(e.start,"options.start",[[Object,"{ x: number, y: number }"]]),_.assertIs(e.end,"options.end",[[Object,"{ x: number, y: number }"]]),_.assertIs(e.start.x,"options.start.x",["number"]),_.assertIs(e.start.y,"options.start.y",["number"]),_.assertIs(e.end.x,"options.end.x",["number"]),_.assertIs(e.end.y,"options.end.y",["number"]),_.assertOrUndefined(e.thickness,"options.thickness",["number"]),_.assertOrUndefined(e.color,"options.color",[[Object,"Color"]]),_.assertOrUndefined(e.dashArray,"options.dashArray",[Array]),_.assertOrUndefined(e.dashPhase,"options.dashPhase",["number"]),_.assertIsOneOfOrUndefined(e.lineCap,"options.lineCap",Yr.LineCapStyle),_.assertRangeOrUndefined(e.opacity,"opacity.opacity",0,1),_.assertIsOneOfOrUndefined(e.blendMode,"options.blendMode",Ii.BlendMode);var s=this.maybeEmbedGraphicsState({borderOpacity:e.opacity,blendMode:e.blendMode});"color"in e||(e.color=Ts.rgb(0,0,0));var l=this.getContentStream();l.push.apply(l,Ni.drawLine({start:e.start,end:e.end,thickness:(r=e.thickness)!==null&&r!==void 0?r:1,color:(n=e.color)!==null&&n!==void 0?n:void 0,dashArray:(i=e.dashArray)!==null&&i!==void 0?i:void 0,dashPhase:(a=e.dashPhase)!==null&&a!==void 0?a:void 0,lineCap:(o=e.lineCap)!==null&&o!==void 0?o:void 0,graphicsState:s}))},t.prototype.drawRectangle=function(e){var r,n,i,a,o,s,l,u,c,f,d,p,h;e===void 0&&(e={}),_.assertOrUndefined(e.x,"options.x",["number"]),_.assertOrUndefined(e.y,"options.y",["number"]),_.assertOrUndefined(e.width,"options.width",["number"]),_.assertOrUndefined(e.height,"options.height",["number"]),_.assertOrUndefined(e.rotate,"options.rotate",[[Object,"Rotation"]]),_.assertOrUndefined(e.xSkew,"options.xSkew",[[Object,"Rotation"]]),_.assertOrUndefined(e.ySkew,"options.ySkew",[[Object,"Rotation"]]),_.assertOrUndefined(e.borderWidth,"options.borderWidth",["number"]),_.assertOrUndefined(e.color,"options.color",[[Object,"Color"]]),_.assertRangeOrUndefined(e.opacity,"opacity.opacity",0,1),_.assertOrUndefined(e.borderColor,"options.borderColor",[[Object,"Color"]]),_.assertOrUndefined(e.borderDashArray,"options.borderDashArray",[Array]),_.assertOrUndefined(e.borderDashPhase,"options.borderDashPhase",["number"]),_.assertIsOneOfOrUndefined(e.borderLineCap,"options.borderLineCap",Yr.LineCapStyle),_.assertRangeOrUndefined(e.borderOpacity,"options.borderOpacity",0,1),_.assertIsOneOfOrUndefined(e.blendMode,"options.blendMode",Ii.BlendMode);var v=this.maybeEmbedGraphicsState({opacity:e.opacity,borderOpacity:e.borderOpacity,blendMode:e.blendMode});!("color"in e)&&!("borderColor"in e)&&(e.color=Ts.rgb(0,0,0));var g=this.getContentStream();g.push.apply(g,Ni.drawRectangle({x:(r=e.x)!==null&&r!==void 0?r:this.x,y:(n=e.y)!==null&&n!==void 0?n:this.y,width:(i=e.width)!==null&&i!==void 0?i:150,height:(a=e.height)!==null&&a!==void 0?a:100,rotate:(o=e.rotate)!==null&&o!==void 0?o:St.degrees(0),xSkew:(s=e.xSkew)!==null&&s!==void 0?s:St.degrees(0),ySkew:(l=e.ySkew)!==null&&l!==void 0?l:St.degrees(0),borderWidth:(u=e.borderWidth)!==null&&u!==void 0?u:0,color:(c=e.color)!==null&&c!==void 0?c:void 0,borderColor:(f=e.borderColor)!==null&&f!==void 0?f:void 0,borderDashArray:(d=e.borderDashArray)!==null&&d!==void 0?d:void 0,borderDashPhase:(p=e.borderDashPhase)!==null&&p!==void 0?p:void 0,graphicsState:v,borderLineCap:(h=e.borderLineCap)!==null&&h!==void 0?h:void 0}))},t.prototype.drawSquare=function(e){e===void 0&&(e={});var r=e.size;_.assertOrUndefined(r,"size",["number"]),this.drawRectangle(Yn.__assign(Yn.__assign({},e),{width:r,height:r}))},t.prototype.drawEllipse=function(e){var r,n,i,a,o,s,l,u,c,f,d;e===void 0&&(e={}),_.assertOrUndefined(e.x,"options.x",["number"]),_.assertOrUndefined(e.y,"options.y",["number"]),_.assertOrUndefined(e.xScale,"options.xScale",["number"]),_.assertOrUndefined(e.yScale,"options.yScale",["number"]),_.assertOrUndefined(e.rotate,"options.rotate",[[Object,"Rotation"]]),_.assertOrUndefined(e.color,"options.color",[[Object,"Color"]]),_.assertRangeOrUndefined(e.opacity,"opacity.opacity",0,1),_.assertOrUndefined(e.borderColor,"options.borderColor",[[Object,"Color"]]),_.assertRangeOrUndefined(e.borderOpacity,"options.borderOpacity",0,1),_.assertOrUndefined(e.borderWidth,"options.borderWidth",["number"]),_.assertOrUndefined(e.borderDashArray,"options.borderDashArray",[Array]),_.assertOrUndefined(e.borderDashPhase,"options.borderDashPhase",["number"]),_.assertIsOneOfOrUndefined(e.borderLineCap,"options.borderLineCap",Yr.LineCapStyle),_.assertIsOneOfOrUndefined(e.blendMode,"options.blendMode",Ii.BlendMode);var p=this.maybeEmbedGraphicsState({opacity:e.opacity,borderOpacity:e.borderOpacity,blendMode:e.blendMode});!("color"in e)&&!("borderColor"in e)&&(e.color=Ts.rgb(0,0,0));var h=this.getContentStream();h.push.apply(h,Ni.drawEllipse({x:(r=e.x)!==null&&r!==void 0?r:this.x,y:(n=e.y)!==null&&n!==void 0?n:this.y,xScale:(i=e.xScale)!==null&&i!==void 0?i:100,yScale:(a=e.yScale)!==null&&a!==void 0?a:100,rotate:(o=e.rotate)!==null&&o!==void 0?o:void 0,color:(s=e.color)!==null&&s!==void 0?s:void 0,borderColor:(l=e.borderColor)!==null&&l!==void 0?l:void 0,borderWidth:(u=e.borderWidth)!==null&&u!==void 0?u:0,borderDashArray:(c=e.borderDashArray)!==null&&c!==void 0?c:void 0,borderDashPhase:(f=e.borderDashPhase)!==null&&f!==void 0?f:void 0,borderLineCap:(d=e.borderLineCap)!==null&&d!==void 0?d:void 0,graphicsState:p}))},t.prototype.drawCircle=function(e){e===void 0&&(e={});var r=e.size,n=r===void 0?100:r;_.assertOrUndefined(n,"size",["number"]),this.drawEllipse(Yn.__assign(Yn.__assign({},e),{xScale:n,yScale:n}))},t.prototype.setOrEmbedFont=function(e){var r=this.font,n=this.fontKey;e?this.setFont(e):this.getFont();var i=this.font,a=this.fontKey;return{oldFont:r,oldFontKey:n,newFont:i,newFontKey:a}},t.prototype.getFont=function(){if(!this.font||!this.fontKey){var e=this.doc.embedStandardFont(fT.StandardFonts.Helvetica);this.setFont(e)}return[this.font,this.fontKey]},t.prototype.resetFont=function(){this.font=void 0,this.fontKey=void 0},t.prototype.getContentStream=function(e){return e===void 0&&(e=!0),e&&this.contentStream?this.contentStream:(this.contentStream=this.createContentStream(),this.contentStreamRef=this.doc.context.register(this.contentStream),this.node.addContentStream(this.contentStreamRef),this.contentStream)},t.prototype.createContentStream=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=this.doc.context.obj({}),i=ft.PDFContentStream.of(n,e);return i},t.prototype.maybeEmbedGraphicsState=function(e){var r=e.opacity,n=e.borderOpacity,i=e.blendMode;if(!(r===void 0&&n===void 0&&i===void 0)){var a=this.doc.context.obj({Type:"ExtGState",ca:r,CA:n,BM:i}),o=this.node.newExtGState("GS",a);return o}},t.prototype.scaleAnnot=function(e,r,n){for(var i=["RD","CL","Vertices","QuadPoints","L","Rect"],a=0,o=i.length;a<o;a++){var s=e.lookup(ft.PDFName.of(i[a]));s instanceof ft.PDFArray&&s.scalePDFNumbers(r,n)}var l=e.lookup(ft.PDFName.of("InkList"));if(l instanceof ft.PDFArray)for(var a=0,o=l.size();a<o;a++){var u=l.lookup(a);u instanceof ft.PDFArray&&u.scalePDFNumbers(r,n)}},t.of=function(e,r,n){return new t(e,r,n)},t.create=function(e){_.assertIs(e,"doc",[[AF.default,"PDFDocument"]]);var r=ft.PDFRef.of(-1),n=ft.PDFPageLeaf.withContextAndParent(e.context,r),i=e.context.register(n);return new t(n,i,e)},t})();np.default=dT});var K0=D(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});var Ml=(k(),R(T)),hT=Ml.__importDefault(_n()),kF=Ml.__importDefault(bn()),pT=Pl(),RF=Kn(),BF=Ml.__importStar(xn()),NF=ur(),vT=Zt(),IF=et(),qi=ae(),mT=(function(t){Ml.__extends(e,t);function e(r,n,i){var a=t.call(this,r,n,i)||this;return qi.assertIs(r,"acroButton",[[IF.PDFAcroPushButton,"PDFAcroPushButton"]]),a.acroField=r,a}return e.prototype.setImage=function(r,n){n===void 0&&(n=pT.ImageAlignment.Center);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a],l=this.createImageAppearanceStream(s,r,n);this.updateWidgetAppearances(s,{normal:l})}this.markAsClean()},e.prototype.setFontSize=function(r){qi.assertPositive(r,"fontSize"),this.acroField.setFontSize(r),this.markAsDirty()},e.prototype.addToPage=function(r,n,i){var a,o,s,l,u,c,f,d,p,h,v;qi.assertOrUndefined(r,"text",["string"]),qi.assertOrUndefined(n,"page",[[hT.default,"PDFPage"]]),BF.assertFieldAppearanceOptions(i);var g=this.createWidget({x:((a=i?.x)!==null&&a!==void 0?a:0)-((o=i?.borderWidth)!==null&&o!==void 0?o:0)/2,y:((s=i?.y)!==null&&s!==void 0?s:0)-((l=i?.borderWidth)!==null&&l!==void 0?l:0)/2,width:(u=i?.width)!==null&&u!==void 0?u:100,height:(c=i?.height)!==null&&c!==void 0?c:50,textColor:(f=i?.textColor)!==null&&f!==void 0?f:NF.rgb(0,0,0),backgroundColor:(d=i?.backgroundColor)!==null&&d!==void 0?d:NF.rgb(.75,.75,.75),borderColor:i?.borderColor,borderWidth:(p=i?.borderWidth)!==null&&p!==void 0?p:0,rotate:(h=i?.rotate)!==null&&h!==void 0?h:vT.degrees(0),caption:r,hidden:i?.hidden,page:n.ref}),m=this.doc.context.register(g.dict);this.acroField.addWidget(m);var b=(v=i?.font)!==null&&v!==void 0?v:this.doc.getForm().getDefaultFont();this.updateWidgetAppearance(g,b),n.node.addAnnot(m)},e.prototype.needsAppearancesUpdate=function(){var r;if(this.isDirty())return!0;for(var n=this.acroField.getWidgets(),i=0,a=n.length;i<a;i++){var o=n[i],s=((r=o.getAppearances())===null||r===void 0?void 0:r.normal)instanceof IF.PDFStream;if(!s)return!0}return!1},e.prototype.defaultUpdateAppearances=function(r){qi.assertIs(r,"font",[[kF.default,"PDFFont"]]),this.updateAppearances(r)},e.prototype.updateAppearances=function(r,n){qi.assertIs(r,"font",[[kF.default,"PDFFont"]]),qi.assertOrUndefined(n,"provider",[Function]);for(var i=this.acroField.getWidgets(),a=0,o=i.length;a<o;a++){var s=i[a];this.updateWidgetAppearance(s,r,n)}},e.prototype.updateWidgetAppearance=function(r,n,i){var a=i??RF.defaultButtonAppearanceProvider,o=RF.normalizeAppearance(a(this,r,n));this.updateWidgetAppearanceWithFont(r,n,o)},e.of=function(r,n,i){return new e(r,n,i)},e})(BF.default);ip.default=mT});var qF=D(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});var gT=(k(),R(T));gT.__exportStar(Kn(),pr);var DT=K0();Object.defineProperty(pr,"PDFButton",{enumerable:!0,get:function(){return DT.default}});var yT=P0();Object.defineProperty(pr,"PDFCheckBox",{enumerable:!0,get:function(){return yT.default}});var FT=O0();Object.defineProperty(pr,"PDFDropdown",{enumerable:!0,get:function(){return FT.default}});var bT=xn();Object.defineProperty(pr,"PDFField",{enumerable:!0,get:function(){return bT.default}});var xT=H0();Object.defineProperty(pr,"PDFForm",{enumerable:!0,get:function(){return xT.default}});var _T=k0();Object.defineProperty(pr,"PDFOptionList",{enumerable:!0,get:function(){return _T.default}});var CT=I0();Object.defineProperty(pr,"PDFRadioGroup",{enumerable:!0,get:function(){return CT.default}});var wT=j0();Object.defineProperty(pr,"PDFSignature",{enumerable:!0,get:function(){return wT.default}});var PT=W0();Object.defineProperty(pr,"PDFTextField",{enumerable:!0,get:function(){return PT.default}})});var MF=D(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});var jF=(k(),R(T));jF.__exportStar(_s(),Ul);jF.__exportStar(f0(),Ul)});var UF=D(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});var Qt=(k(),R(T));Qt.__exportStar(qF(),Ze);Qt.__exportStar(MF(),Ze);Qt.__exportStar(ur(),Ze);Qt.__exportStar(Ha(),Ze);Qt.__exportStar(F0(),Ze);Qt.__exportStar(pl(),Ze);Qt.__exportStar(Ga(),Ze);Qt.__exportStar(Wn(),Ze);Qt.__exportStar(Zt(),Ze);Qt.__exportStar(X0(),Ze);Qt.__exportStar(rp(),Ze);Qt.__exportStar(Z0(),Ze);Qt.__exportStar(Tl(),Ze);var ET=Xn();Object.defineProperty(Ze,"PDFDocument",{enumerable:!0,get:function(){return ET.default}});var ST=bn();Object.defineProperty(Ze,"PDFFont",{enumerable:!0,get:function(){return ST.default}});var OT=wl();Object.defineProperty(Ze,"PDFImage",{enumerable:!0,get:function(){return OT.default}});var AT=_n();Object.defineProperty(Ze,"PDFPage",{enumerable:!0,get:function(){return AT.default}});var TT=_l();Object.defineProperty(Ze,"PDFEmbeddedPage",{enumerable:!0,get:function(){return TT.default}});var kT=Q0();Object.defineProperty(Ze,"PDFJavaScript",{enumerable:!0,get:function(){return kT.default}})});var zF=D(VF=>{"use strict";Object.defineProperty(VF,"__esModule",{value:!0})});var WF=D($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});var Vl=(k(),R(T));Vl.__exportStar(UF(),$a);Vl.__exportStar(et(),$a);Vl.__exportStar(zF(),$a);Vl.__exportStar(ae(),$a)});(function(){gp().config(Object.assign({},yp(),bp()(process.argv)))})();var Bp=je(Rp(),1),{program:gk,createCommand:Dk,createArgument:yk,createOption:Fk,CommanderError:bk,InvalidArgumentError:xk,InvalidOptionArgumentError:_k,Command:Np,Argument:Ck,Option:wk,Help:Pk}=Bp.default;kr();var an=je(require("node:path"),1),Tv=je(require("sharp"),1);xo();kr();var ia=je(require("node:fs/promises"),1),nn=je(require("node:path"),1),E1=[".png",".jpg",".jpeg"],S1=[".pdf"];async function Ys(t,e){let r=nn.resolve(t);try{if(!(await ia.stat(r)).isDirectory())throw new Error(`Not a directory: ${r}`)}catch(o){throw o.code==="ENOENT"?new Error(`Directory not found: ${r}`):o}let n=await ia.readdir(r,{withFileTypes:!0}),i=e.map(o=>o.startsWith(".")?o.toLowerCase():`.${o.toLowerCase()}`),a=[];for(let o of n)if(o.isFile()){let s=nn.extname(o.name).toLowerCase();i.includes(s)&&a.push(nn.join(r,o.name))}return a.sort((o,s)=>nn.basename(o).localeCompare(nn.basename(s))),{directory:r,files:a,count:a.length}}async function Sv(t){return Ys(t,E1)}async function Ov(t){return Ys(t,S1)}var Av=je(require("node:readline"),1);kr();async function aa(t){let{fileCount:e,fileType:r,actions:n,preserveOriginals:i=!0}=t;console.log(),console.log(Q.cyan(`Found ${Q.bold(e)} ${r}`)),console.log(),console.log(Q.yellow("Planned actions:"));for(let a of n)console.log(Q.white(` \u2022 ${a}`));return i&&console.log(Q.white(" \u2022 Originals will remain unchanged")),console.log(),new Promise(a=>{let o=Av.createInterface({input:process.stdin,output:process.stdout}),s=!1;o.on("close",()=>{s||(s=!0,console.log(),console.log(Q.red("Aborted.")),a(!1))}),o.question(Q.green("Continue? (y/N) "),l=>{s=!0,o.close();let u=l.trim().toLowerCase();u==="y"||u==="yes"?a(!0):(console.log(Q.red("Aborted.")),a(!1))})})}var O1=["png","jpg","jpeg","webp","gif","tiff","avif"];async function jc(t,e={}){let{from:r,to:n="webp",quality:i=80,maxWidth:a}=e,s=(r?Array.isArray(r)?r:[r]:[...O1]).filter(v=>n==="jpg"&&(v==="jpg"||v==="jpeg")?!1:v!==n);if(s.length===0){console.log(Q.yellow("No valid source formats to convert."));return}let l=await Ys(t,s);if(l.count===0){let v=s.map(g=>g.toUpperCase()).join(", ");console.log(Q.yellow(`No ${v} images found in directory.`));return}let u=r?(Array.isArray(r)?r.join(", "):r).toUpperCase():"all supported formats",c=[`Convert ${u} \u2192 ${n.toUpperCase()}`];if(a&&c.push(`Resize to max width ${a}px`),c.push(`Quality: ${i}%`),!await aa({fileCount:l.count,fileType:`${u} images`,actions:c,preserveOriginals:!0}))return;let d=rn("Converting images...").start(),p=0,h=0;for(let v of l.files)try{let g=an.dirname(v),m=an.basename(v,an.extname(v)),w=an.join(g,`${m}.${n==="jpg"?"jpg":n}`),F=(0,Tv.default)(v);switch(a&&(F=F.resize({width:a,withoutEnlargement:!0})),n){case"webp":await F.webp({quality:i}).toFile(w);break;case"png":await F.png({quality:i}).toFile(w);break;case"jpg":await F.jpeg({quality:i}).toFile(w);break}p++,d.text=`Converting images... (${p}/${l.count})`}catch{h++,d.warn(`Failed to convert: ${an.basename(v)}`),d.start()}d.stop(),console.log(),console.log(Q.green(`\u2713 Converted ${p} images to ${n.toUpperCase()}`)),h>0&&console.log(Q.red(`\u2717 Failed to convert ${h} images`))}var Rr=je(require("node:path"),1),Mc=je(require("sharp"),1);xo();kr();async function Uc(t,e){let{maxWidth:r,quality:n=80}=e,i=await Sv(t);if(i.count===0){console.log(Q.yellow("No images found in directory."));return}let a=[`Resize to max width ${r}px`,"Preserve aspect ratio"];if(!await aa({fileCount:i.count,fileType:"images",actions:a,preserveOriginals:!0}))return;let s=rn("Resizing images...").start(),l=0,u=0;for(let c of i.files)try{let f=Rr.dirname(c),d=Rr.extname(c),p=Rr.basename(c,d),h=Rr.join(f,`${p}_resized${d}`),v=await(0,Mc.default)(c).metadata();if(v.width&&v.width<=r){s.text=`Skipping ${Rr.basename(c)} (already ${v.width}px wide)`,l++;continue}await(0,Mc.default)(c).resize({width:r,withoutEnlargement:!0}).toFile(h),l++,s.text=`Resizing images... (${l}/${i.count})`}catch{u++,s.warn(`Failed to resize: ${Rr.basename(c)}`),s.start()}s.stop(),console.log(),console.log(Q.green(`\u2713 Resized ${l} images successfully`)),u>0&&console.log(Q.red(`\u2717 Failed to resize ${u} images`))}var eo=je(require("node:fs/promises"),1),zl=je(require("node:path"),1),ap=je(WF(),1);xo();kr();async function LF(t){return(await eo.stat(t)).mtimeMs}async function RT(t,e){let r=[...t];switch(e){case"name":return r;case"name-desc":return r.reverse();case"date":{let n=await Promise.all(r.map(async i=>({path:i,mtime:await LF(i)})));return n.sort((i,a)=>i.mtime-a.mtime),n.map(i=>i.path)}case"date-desc":{let n=await Promise.all(r.map(async i=>({path:i,mtime:await LF(i)})));return n.sort((i,a)=>a.mtime-i.mtime),n.map(i=>i.path)}case"random":for(let n=r.length-1;n>0;n--){let i=Math.floor(Math.random()*(n+1));[r[n],r[i]]=[r[i],r[n]]}return r;default:return r}}function BT(t){switch(t){case"name":return"alphabetical (A\u2192Z)";case"name-desc":return"reverse alphabetical (Z\u2192A)";case"date":return"oldest first";case"date-desc":return"newest first";case"random":return"random";default:return"alphabetical"}}async function op(t,e={}){let{outputFile:r="merged.pdf",order:n="name"}=e,i=await Ov(t);if(i.count===0){console.log(Q.yellow("No PDF files found in directory."));return}if(i.count===1){console.log(Q.yellow("Only one PDF found. Nothing to merge."));return}let a=await RT(i.files,n),o=zl.join(i.directory,r),s=BT(n),l=[`Merge ${i.count} PDFs (${s})`,`Output: ${r}`];if(!await aa({fileCount:i.count,fileType:"PDF files",actions:l,preserveOriginals:!0}))return;let c=rn("Merging PDFs...").start();try{let f=await ap.PDFDocument.create();for(let p=0;p<a.length;p++){let h=a[p];c.text=`Merging PDFs... (${p+1}/${i.count})`;try{let v=await eo.readFile(h),g=await ap.PDFDocument.load(v),m=await f.copyPages(g,g.getPageIndices());for(let b of m)f.addPage(b)}catch{c.warn(`Failed to read: ${zl.basename(h)}`),c.start()}}let d=await f.save();await eo.writeFile(o,d),c.stop(),console.log(),console.log(Q.green(`\u2713 Created ${r} with ${f.getPageCount()} pages`))}catch(f){c.stop(),console.log(Q.red(`\u2717 Failed to merge PDFs: ${f.message}`))}}kr();var Ye={};Yl(Ye,{BRAND:()=>o8,DIRTY:()=>ji,EMPTY_PATH:()=>jT,INVALID:()=>re,NEVER:()=>L8,OK:()=>bt,ParseStatus:()=>gt,Schema:()=>he,ZodAny:()=>$n,ZodArray:()=>Sn,ZodBigInt:()=>Ui,ZodBoolean:()=>Vi,ZodBranded:()=>Rs,ZodCatch:()=>Qi,ZodDate:()=>zi,ZodDefault:()=>Ji,ZodDiscriminatedUnion:()=>Gl,ZodEffects:()=>gr,ZodEnum:()=>Zi,ZodError:()=>zt,ZodFirstPartyTypeKind:()=>ie,ZodFunction:()=>Kl,ZodIntersection:()=>Hi,ZodIssueCode:()=>N,ZodLazy:()=>Ki,ZodLiteral:()=>Xi,ZodMap:()=>oo,ZodNaN:()=>uo,ZodNativeEnum:()=>Yi,ZodNever:()=>Or,ZodNull:()=>Li,ZodNullable:()=>$r,ZodNumber:()=>Mi,ZodObject:()=>Wt,ZodOptional:()=>vr,ZodParsedType:()=>V,ZodPipeline:()=>Bs,ZodPromise:()=>ei,ZodReadonly:()=>$i,ZodRecord:()=>Hl,ZodSchema:()=>he,ZodSet:()=>so,ZodString:()=>Qn,ZodSymbol:()=>io,ZodTransformer:()=>gr,ZodTuple:()=>Qr,ZodType:()=>he,ZodUndefined:()=>Wi,ZodUnion:()=>Gi,ZodUnknown:()=>En,ZodVoid:()=>ao,addIssueToContext:()=>M,any:()=>v8,array:()=>y8,bigint:()=>c8,boolean:()=>tb,coerce:()=>W8,custom:()=>QF,date:()=>f8,datetimeRegex:()=>YF,defaultErrorMap:()=>wn,discriminatedUnion:()=>_8,effect:()=>N8,enum:()=>k8,function:()=>O8,getErrorMap:()=>to,getParsedType:()=>Jr,instanceof:()=>u8,intersection:()=>C8,isAborted:()=>Wl,isAsync:()=>ro,isDirty:()=>Ll,isValid:()=>Jn,late:()=>s8,lazy:()=>A8,literal:()=>T8,makeIssue:()=>ks,map:()=>E8,nan:()=>l8,nativeEnum:()=>R8,never:()=>g8,null:()=>p8,nullable:()=>q8,number:()=>eb,object:()=>F8,objectUtil:()=>sp,oboolean:()=>z8,onumber:()=>V8,optional:()=>I8,ostring:()=>U8,pipeline:()=>M8,preprocess:()=>j8,promise:()=>B8,quotelessJson:()=>NT,record:()=>P8,set:()=>S8,setErrorMap:()=>qT,strictObject:()=>b8,string:()=>$F,symbol:()=>d8,transformer:()=>N8,tuple:()=>w8,undefined:()=>h8,union:()=>x8,unknown:()=>m8,util:()=>ve,void:()=>D8});var ve;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{let a={};for(let o of i)a[o]=o;return a},t.getValidEnumValues=i=>{let a=t.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(let s of a)o[s]=i[s];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},t.find=(i,a)=>{for(let o of i)if(a(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(ve||(ve={}));var sp;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(sp||(sp={}));var V=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Jr=t=>{switch(typeof t){case"undefined":return V.undefined;case"string":return V.string;case"number":return Number.isNaN(t)?V.nan:V.number;case"boolean":return V.boolean;case"function":return V.function;case"bigint":return V.bigint;case"symbol":return V.symbol;case"object":return Array.isArray(t)?V.array:t===null?V.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?V.promise:typeof Map<"u"&&t instanceof Map?V.map:typeof Set<"u"&&t instanceof Set?V.set:typeof Date<"u"&&t instanceof Date?V.date:V.object;default:return V.unknown}};var N=ve.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),NT=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),zt=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let s=n,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(o))):s[u]=s[u]||{_errors:[]},s=s[u],l++}}};return i(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let a=i.path[0];r[a]=r[a]||[],r[a].push(e(i))}else n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};zt.create=t=>new zt(t);var IT=(t,e)=>{let r;switch(t.code){case N.invalid_type:t.received===V.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case N.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ve.jsonStringifyReplacer)}`;break;case N.unrecognized_keys:r=`Unrecognized key(s) in object: ${ve.joinValues(t.keys,", ")}`;break;case N.invalid_union:r="Invalid input";break;case N.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ve.joinValues(t.options)}`;break;case N.invalid_enum_value:r=`Invalid enum value. Expected ${ve.joinValues(t.options)}, received '${t.received}'`;break;case N.invalid_arguments:r="Invalid function arguments";break;case N.invalid_return_type:r="Invalid function return type";break;case N.invalid_date:r="Invalid date";break;case N.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ve.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case N.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case N.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case N.custom:r="Invalid input";break;case N.invalid_intersection_types:r="Intersection results could not be merged";break;case N.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case N.not_finite:r="Number must be finite";break;default:r=e.defaultError,ve.assertNever(t)}return{message:r}},wn=IT;var GF=wn;function qT(t){GF=t}function to(){return GF}var ks=t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)s=u(o,{data:e,defaultError:s}).message;return{...i,path:a,message:s}},jT=[];function M(t,e){let r=to(),n=ks({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===wn?void 0:wn].filter(i=>!!i)});t.common.issues.push(n)}var gt=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return re;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r){let a=await i.key,o=await i.value;n.push({key:a,value:o})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return re;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}},re=Object.freeze({status:"aborted"}),ji=t=>({status:"dirty",value:t}),bt=t=>({status:"valid",value:t}),Wl=t=>t.status==="aborted",Ll=t=>t.status==="dirty",Jn=t=>t.status==="valid",ro=t=>typeof Promise<"u"&&t instanceof Promise;var G;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(G||(G={}));var mr=class{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},HF=(t,e)=>{if(Jn(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new zt(t.common.issues);return this._error=r,this._error}}};function fe(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,s)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??n??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:l??r??s.defaultError}},description:i}}var he=class{get description(){return this._def.description}_getType(e){return Jr(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Jr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:Jr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(ro(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Jr(e)},i=this._parseSync({data:e,path:n.path,parent:n});return HF(n,i)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Jr(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Jn(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Jn(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Jr(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(ro(i)?i:Promise.resolve(i));return HF(n,a)}refine(e,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{let o=e(i),s=()=>a.addIssue({code:N.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new gr({schema:this,typeName:ie.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return vr.create(this,this._def)}nullable(){return $r.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Sn.create(this)}promise(){return ei.create(this,this._def)}or(e){return Gi.create([this,e],this._def)}and(e){return Hi.create(this,e,this._def)}transform(e){return new gr({...fe(this._def),schema:this,typeName:ie.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ji({...fe(this._def),innerType:this,defaultValue:r,typeName:ie.ZodDefault})}brand(){return new Rs({typeName:ie.ZodBranded,type:this,...fe(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Qi({...fe(this._def),innerType:this,catchValue:r,typeName:ie.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Bs.create(this,e)}readonly(){return $i.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},MT=/^c[^\s-]{8,}$/i,UT=/^[0-9a-z]+$/,VT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zT=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,WT=/^[a-z0-9_-]{21}$/i,LT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,GT=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,HT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,KT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",up,XT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ZT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,YT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,JT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,QT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$T=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,XF="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",e8=new RegExp(`^${XF}$`);function ZF(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function t8(t){return new RegExp(`^${ZF(t)}$`)}function YF(t){let e=`${XF}T${ZF(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function r8(t,e){return!!((e==="v4"||!e)&&XT.test(t)||(e==="v6"||!e)&&YT.test(t))}function n8(t,e){if(!LT.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function i8(t,e){return!!((e==="v4"||!e)&&ZT.test(t)||(e==="v6"||!e)&&JT.test(t))}var Qn=class t extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==V.string){let a=this._getOrReturnCtx(e);return M(a,{code:N.invalid_type,expected:V.string,received:a.parsedType}),re}let n=new gt,i;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),M(i,{code:N.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),M(i,{code:N.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,s=e.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(e,i),o?M(i,{code:N.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&M(i,{code:N.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")HT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"email",code:N.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")up||(up=new RegExp(KT,"u")),up.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"emoji",code:N.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")zT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"uuid",code:N.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")WT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"nanoid",code:N.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")MT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"cuid",code:N.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")UT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"cuid2",code:N.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")VT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"ulid",code:N.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),M(i,{validation:"url",code:N.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"regex",code:N.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),M(i,{code:N.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),M(i,{code:N.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),M(i,{code:N.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?YF(a).test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{code:N.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?e8.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{code:N.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?t8(a).test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{code:N.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?GT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"duration",code:N.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?r8(e.data,a.version)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"ip",code:N.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?n8(e.data,a.alg)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"jwt",code:N.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?i8(e.data,a.version)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"cidr",code:N.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?QT.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"base64",code:N.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?$T.test(e.data)||(i=this._getOrReturnCtx(e,i),M(i,{validation:"base64url",code:N.invalid_string,message:a.message}),n.dirty()):ve.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:N.invalid_string,...G.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...G.errToObj(e)})}url(e){return this._addCheck({kind:"url",...G.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...G.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...G.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...G.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...G.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...G.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...G.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...G.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...G.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...G.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...G.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...G.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...G.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...G.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...G.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...G.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...G.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...G.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...G.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...G.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...G.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...G.errToObj(r)})}nonempty(e){return this.min(1,G.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Qn.create=t=>new Qn({checks:[],typeName:ie.ZodString,coerce:t?.coerce??!1,...fe(t)});function a8(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return a%o/10**i}var Mi=class t extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==V.number){let a=this._getOrReturnCtx(e);return M(a,{code:N.invalid_type,expected:V.number,received:a.parsedType}),re}let n,i=new gt;for(let a of this._def.checks)a.kind==="int"?ve.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),M(n,{code:N.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),M(n,{code:N.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),M(n,{code:N.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?a8(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),M(n,{code:N.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),M(n,{code:N.not_finite,message:a.message}),i.dirty()):ve.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,G.toString(r))}gt(e,r){return this.setLimit("min",e,!1,G.toString(r))}lte(e,r){return this.setLimit("max",e,!0,G.toString(r))}lt(e,r){return this.setLimit("max",e,!1,G.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:G.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:G.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:G.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:G.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:G.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:G.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:G.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ve.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Mi.create=t=>new Mi({checks:[],typeName:ie.ZodNumber,coerce:t?.coerce||!1,...fe(t)});var Ui=class t extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==V.bigint)return this._getInvalidInput(e);let n,i=new gt;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),M(n,{code:N.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),M(n,{code:N.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),M(n,{code:N.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):ve.assertNever(a);return{status:i.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:V.bigint,received:r.parsedType}),re}gte(e,r){return this.setLimit("min",e,!0,G.toString(r))}gt(e,r){return this.setLimit("min",e,!1,G.toString(r))}lte(e,r){return this.setLimit("max",e,!0,G.toString(r))}lt(e,r){return this.setLimit("max",e,!1,G.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:G.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:G.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:G.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Ui.create=t=>new Ui({checks:[],typeName:ie.ZodBigInt,coerce:t?.coerce??!1,...fe(t)});var Vi=class extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==V.boolean){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:V.boolean,received:n.parsedType}),re}return bt(e.data)}};Vi.create=t=>new Vi({typeName:ie.ZodBoolean,coerce:t?.coerce||!1,...fe(t)});var zi=class t extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==V.date){let a=this._getOrReturnCtx(e);return M(a,{code:N.invalid_type,expected:V.date,received:a.parsedType}),re}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return M(a,{code:N.invalid_date}),re}let n=new gt,i;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),M(i,{code:N.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),M(i,{code:N.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):ve.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:G.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:G.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};zi.create=t=>new zi({checks:[],coerce:t?.coerce||!1,typeName:ie.ZodDate,...fe(t)});var io=class extends he{_parse(e){if(this._getType(e)!==V.symbol){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:V.symbol,received:n.parsedType}),re}return bt(e.data)}};io.create=t=>new io({typeName:ie.ZodSymbol,...fe(t)});var Wi=class extends he{_parse(e){if(this._getType(e)!==V.undefined){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:V.undefined,received:n.parsedType}),re}return bt(e.data)}};Wi.create=t=>new Wi({typeName:ie.ZodUndefined,...fe(t)});var Li=class extends he{_parse(e){if(this._getType(e)!==V.null){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:V.null,received:n.parsedType}),re}return bt(e.data)}};Li.create=t=>new Li({typeName:ie.ZodNull,...fe(t)});var $n=class extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return bt(e.data)}};$n.create=t=>new $n({typeName:ie.ZodAny,...fe(t)});var En=class extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return bt(e.data)}};En.create=t=>new En({typeName:ie.ZodUnknown,...fe(t)});var Or=class extends he{_parse(e){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:V.never,received:r.parsedType}),re}};Or.create=t=>new Or({typeName:ie.ZodNever,...fe(t)});var ao=class extends he{_parse(e){if(this._getType(e)!==V.undefined){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:V.void,received:n.parsedType}),re}return bt(e.data)}};ao.create=t=>new ao({typeName:ie.ZodVoid,...fe(t)});var Sn=class t extends he{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==V.array)return M(r,{code:N.invalid_type,expected:V.array,received:r.parsedType}),re;if(i.exactLength!==null){let o=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(o||s)&&(M(r,{code:o?N.too_big:N.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(M(r,{code:N.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(M(r,{code:N.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>i.type._parseAsync(new mr(r,o,r.path,s)))).then(o=>gt.mergeArray(n,o));let a=[...r.data].map((o,s)=>i.type._parseSync(new mr(r,o,r.path,s)));return gt.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:G.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:G.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:G.toString(r)}})}nonempty(e){return this.min(1,e)}};Sn.create=(t,e)=>new Sn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ie.ZodArray,...fe(e)});function no(t){if(t instanceof Wt){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=vr.create(no(n))}return new Wt({...t._def,shape:()=>e})}else return t instanceof Sn?new Sn({...t._def,type:no(t.element)}):t instanceof vr?vr.create(no(t.unwrap())):t instanceof $r?$r.create(no(t.unwrap())):t instanceof Qr?Qr.create(t.items.map(e=>no(e))):t}var Wt=class t extends he{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=ve.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==V.object){let u=this._getOrReturnCtx(e);return M(u,{code:N.invalid_type,expected:V.object,received:u.parsedType}),re}let{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof Or&&this._def.unknownKeys==="strip"))for(let u in i.data)o.includes(u)||s.push(u);let l=[];for(let u of o){let c=a[u],f=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new mr(i,f,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Or){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of s)l.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(u==="strict")s.length>0&&(M(i,{code:N.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let c of s){let f=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new mr(i,f,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let c of l){let f=await c.key,d=await c.value;u.push({key:f,value:d,alwaysSet:c.alwaysSet})}return u}).then(u=>gt.mergeObjectSync(n,u)):gt.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return G.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:G.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ie.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of ve.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of ve.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return no(this)}partial(e){let r={};for(let n of ve.objectKeys(this.shape)){let i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of ve.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof vr;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return JF(ve.objectKeys(this.shape))}};Wt.create=(t,e)=>new Wt({shape:()=>t,unknownKeys:"strip",catchall:Or.create(),typeName:ie.ZodObject,...fe(e)});Wt.strictCreate=(t,e)=>new Wt({shape:()=>t,unknownKeys:"strict",catchall:Or.create(),typeName:ie.ZodObject,...fe(e)});Wt.lazycreate=(t,e)=>new Wt({shape:t,unknownKeys:"strip",catchall:Or.create(),typeName:ie.ZodObject,...fe(e)});var Gi=class extends he{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new zt(s.ctx.common.issues));return M(r,{code:N.invalid_union,unionErrors:o}),re}if(r.common.async)return Promise.all(n.map(async a=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(i);{let a,o=[];for(let l of n){let u={...r,common:{...r.common,issues:[]},parent:null},c=l._parseSync({data:r.data,path:r.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(l=>new zt(l));return M(r,{code:N.invalid_union,unionErrors:s}),re}}get options(){return this._def.options}};Gi.create=(t,e)=>new Gi({options:t,typeName:ie.ZodUnion,...fe(e)});var Pn=t=>t instanceof Ki?Pn(t.schema):t instanceof gr?Pn(t.innerType()):t instanceof Xi?[t.value]:t instanceof Zi?t.options:t instanceof Yi?ve.objectValues(t.enum):t instanceof Ji?Pn(t._def.innerType):t instanceof Wi?[void 0]:t instanceof Li?[null]:t instanceof vr?[void 0,...Pn(t.unwrap())]:t instanceof $r?[null,...Pn(t.unwrap())]:t instanceof Rs||t instanceof $i?Pn(t.unwrap()):t instanceof Qi?Pn(t._def.innerType):[],Gl=class t extends he{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==V.object)return M(r,{code:N.invalid_type,expected:V.object,received:r.parsedType}),re;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(M(r,{code:N.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),re)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let a of r){let o=Pn(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,a)}}return new t({typeName:ie.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...fe(n)})}};function lp(t,e){let r=Jr(t),n=Jr(e);if(t===e)return{valid:!0,data:t};if(r===V.object&&n===V.object){let i=ve.objectKeys(e),a=ve.objectKeys(t).filter(s=>i.indexOf(s)!==-1),o={...t,...e};for(let s of a){let l=lp(t[s],e[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(r===V.array&&n===V.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let a=0;a<t.length;a++){let o=t[a],s=e[a],l=lp(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return r===V.date&&n===V.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Hi=class extends he{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=(a,o)=>{if(Wl(a)||Wl(o))return re;let s=lp(a.value,o.value);return s.valid?((Ll(a)||Ll(o))&&r.dirty(),{status:r.value,value:s.data}):(M(n,{code:N.invalid_intersection_types}),re)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Hi.create=(t,e,r)=>new Hi({left:t,right:e,typeName:ie.ZodIntersection,...fe(r)});var Qr=class t extends he{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==V.array)return M(n,{code:N.invalid_type,expected:V.array,received:n.parsedType}),re;if(n.data.length<this._def.items.length)return M(n,{code:N.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),re;!this._def.rest&&n.data.length>this._def.items.length&&(M(n,{code:N.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((o,s)=>{let l=this._def.items[s]||this._def.rest;return l?l._parse(new mr(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>gt.mergeArray(r,o)):gt.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Qr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qr({items:t,typeName:ie.ZodTuple,rest:null,...fe(e)})};var Hl=class t extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==V.object)return M(n,{code:N.invalid_type,expected:V.object,received:n.parsedType}),re;let i=[],a=this._def.keyType,o=this._def.valueType;for(let s in n.data)i.push({key:a._parse(new mr(n,s,n.path,s)),value:o._parse(new mr(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?gt.mergeObjectAsync(r,i):gt.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof he?new t({keyType:e,valueType:r,typeName:ie.ZodRecord,...fe(n)}):new t({keyType:Qn.create(),valueType:e,typeName:ie.ZodRecord,...fe(r)})}},oo=class extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==V.map)return M(n,{code:N.invalid_type,expected:V.map,received:n.parsedType}),re;let i=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([s,l],u)=>({key:i._parse(new mr(n,s,n.path,[u,"key"])),value:a._parse(new mr(n,l,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,c=await l.value;if(u.status==="aborted"||c.status==="aborted")return re;(u.status==="dirty"||c.status==="dirty")&&r.dirty(),s.set(u.value,c.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let l of o){let u=l.key,c=l.value;if(u.status==="aborted"||c.status==="aborted")return re;(u.status==="dirty"||c.status==="dirty")&&r.dirty(),s.set(u.value,c.value)}return{status:r.value,value:s}}}};oo.create=(t,e,r)=>new oo({valueType:e,keyType:t,typeName:ie.ZodMap,...fe(r)});var so=class t extends he{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==V.set)return M(n,{code:N.invalid_type,expected:V.set,received:n.parsedType}),re;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(M(n,{code:N.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(M(n,{code:N.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function o(l){let u=new Set;for(let c of l){if(c.status==="aborted")return re;c.status==="dirty"&&r.dirty(),u.add(c.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((l,u)=>a._parse(new mr(n,l,n.path,u)));return n.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:G.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:G.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};so.create=(t,e)=>new so({valueType:t,minSize:null,maxSize:null,typeName:ie.ZodSet,...fe(e)});var Kl=class t extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==V.function)return M(r,{code:N.invalid_type,expected:V.function,received:r.parsedType}),re;function n(s,l){return ks({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,to(),wn].filter(u=>!!u),issueData:{code:N.invalid_arguments,argumentsError:l}})}function i(s,l){return ks({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,to(),wn].filter(u=>!!u),issueData:{code:N.invalid_return_type,returnTypeError:l}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ei){let s=this;return bt(async function(...l){let u=new zt([]),c=await s._def.args.parseAsync(l,a).catch(p=>{throw u.addIssue(n(l,p)),u}),f=await Reflect.apply(o,this,c);return await s._def.returns._def.type.parseAsync(f,a).catch(p=>{throw u.addIssue(i(f,p)),u})})}else{let s=this;return bt(function(...l){let u=s._def.args.safeParse(l,a);if(!u.success)throw new zt([n(l,u.error)]);let c=Reflect.apply(o,this,u.data),f=s._def.returns.safeParse(c,a);if(!f.success)throw new zt([i(c,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Qr.create(e).rest(En.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Qr.create([]).rest(En.create()),returns:r||En.create(),typeName:ie.ZodFunction,...fe(n)})}},Ki=class extends he{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ki.create=(t,e)=>new Ki({getter:t,typeName:ie.ZodLazy,...fe(e)});var Xi=class extends he{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return M(r,{received:r.data,code:N.invalid_literal,expected:this._def.value}),re}return{status:"valid",value:e.data}}get value(){return this._def.value}};Xi.create=(t,e)=>new Xi({value:t,typeName:ie.ZodLiteral,...fe(e)});function JF(t,e){return new Zi({values:t,typeName:ie.ZodEnum,...fe(e)})}var Zi=class t extends he{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return M(r,{expected:ve.joinValues(n),received:r.parsedType,code:N.invalid_type}),re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return M(r,{received:r.data,code:N.invalid_enum_value,options:n}),re}return bt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Zi.create=JF;var Yi=class extends he{_parse(e){let r=ve.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==V.string&&n.parsedType!==V.number){let i=ve.objectValues(r);return M(n,{expected:ve.joinValues(i),received:n.parsedType,code:N.invalid_type}),re}if(this._cache||(this._cache=new Set(ve.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=ve.objectValues(r);return M(n,{received:n.data,code:N.invalid_enum_value,options:i}),re}return bt(e.data)}get enum(){return this._def.values}};Yi.create=(t,e)=>new Yi({values:t,typeName:ie.ZodNativeEnum,...fe(e)});var ei=class extends he{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==V.promise&&r.common.async===!1)return M(r,{code:N.invalid_type,expected:V.promise,received:r.parsedType}),re;let n=r.parsedType===V.promise?r.data:Promise.resolve(r.data);return bt(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ei.create=(t,e)=>new ei({type:t,typeName:ie.ZodPromise,...fe(e)});var gr=class extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ie.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:o=>{M(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let o=i.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return re;let l=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return l.status==="aborted"?re:l.status==="dirty"?ji(l.value):r.value==="dirty"?ji(l.value):l});{if(r.value==="aborted")return re;let s=this._def.schema._parseSync({data:o,path:n.path,parent:n});return s.status==="aborted"?re:s.status==="dirty"?ji(s.value):r.value==="dirty"?ji(s.value):s}}if(i.type==="refinement"){let o=s=>{let l=i.refinement(s,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?re:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?re:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Jn(o))return re;let s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Jn(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:r.value,value:s})):re);ve.assertNever(i)}};gr.create=(t,e,r)=>new gr({schema:t,typeName:ie.ZodEffects,effect:e,...fe(r)});gr.createWithPreprocess=(t,e,r)=>new gr({schema:e,effect:{type:"preprocess",transform:t},typeName:ie.ZodEffects,...fe(r)});var vr=class extends he{_parse(e){return this._getType(e)===V.undefined?bt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vr.create=(t,e)=>new vr({innerType:t,typeName:ie.ZodOptional,...fe(e)});var $r=class extends he{_parse(e){return this._getType(e)===V.null?bt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$r.create=(t,e)=>new $r({innerType:t,typeName:ie.ZodNullable,...fe(e)});var Ji=class extends he{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===V.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ji.create=(t,e)=>new Ji({innerType:t,typeName:ie.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...fe(e)});var Qi=class extends he{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ro(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Qi.create=(t,e)=>new Qi({innerType:t,typeName:ie.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...fe(e)});var uo=class extends he{_parse(e){if(this._getType(e)!==V.nan){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:V.nan,received:n.parsedType}),re}return{status:"valid",value:e.data}}};uo.create=t=>new uo({typeName:ie.ZodNaN,...fe(t)});var o8=Symbol("zod_brand"),Rs=class extends he{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Bs=class t extends he{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?re:a.status==="dirty"?(r.dirty(),ji(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?re:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:ie.ZodPipeline})}},$i=class extends he{_parse(e){let r=this._def.innerType._parse(e),n=i=>(Jn(i)&&(i.value=Object.freeze(i.value)),i);return ro(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};$i.create=(t,e)=>new $i({innerType:t,typeName:ie.ZodReadonly,...fe(e)});function KF(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function QF(t,e={},r){return t?$n.create().superRefine((n,i)=>{let a=t(n);if(a instanceof Promise)return a.then(o=>{if(!o){let s=KF(e,n),l=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:l})}});if(!a){let o=KF(e,n),s=o.fatal??r??!0;i.addIssue({code:"custom",...o,fatal:s})}}):$n.create()}var s8={object:Wt.lazycreate},ie;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ie||(ie={}));var u8=(t,e={message:`Input not instance of ${t.name}`})=>QF(r=>r instanceof t,e),$F=Qn.create,eb=Mi.create,l8=uo.create,c8=Ui.create,tb=Vi.create,f8=zi.create,d8=io.create,h8=Wi.create,p8=Li.create,v8=$n.create,m8=En.create,g8=Or.create,D8=ao.create,y8=Sn.create,F8=Wt.create,b8=Wt.strictCreate,x8=Gi.create,_8=Gl.create,C8=Hi.create,w8=Qr.create,P8=Hl.create,E8=oo.create,S8=so.create,O8=Kl.create,A8=Ki.create,T8=Xi.create,k8=Zi.create,R8=Yi.create,B8=ei.create,N8=gr.create,I8=vr.create,q8=$r.create,j8=gr.createWithPreprocess,M8=Bs.create,U8=()=>$F().optional(),V8=()=>eb().optional(),z8=()=>tb().optional(),W8={string:(t=>Qn.create({...t,coerce:!0})),number:(t=>Mi.create({...t,coerce:!0})),boolean:(t=>Vi.create({...t,coerce:!0})),bigint:(t=>Ui.create({...t,coerce:!0})),date:(t=>zi.create({...t,coerce:!0}))};var L8=re;var G8=Ye.object({from:Ye.enum(["png","jpg","jpeg","webp","gif","tiff","avif"]).optional(),to:Ye.enum(["webp","png","jpg"]).optional(),format:Ye.literal("webp").optional(),maxWidth:Ye.number().positive().optional(),quality:Ye.number().min(1).max(100).optional()}).strict().optional(),H8=Ye.object({maxWidth:Ye.number().positive()}).strict(),K8=Ye.object({outputFile:Ye.string().optional(),order:Ye.enum(["name","name-desc","date","date-desc","random"]).optional()}).strict().optional(),X8=Ye.object({action:Ye.literal("convert_images"),options:G8}).strict(),Z8=Ye.object({action:Ye.literal("resize_images"),options:H8}).strict(),Y8=Ye.object({action:Ye.literal("merge_pdfs"),options:K8}).strict(),J8=Ye.discriminatedUnion("action",[X8,Z8,Y8]);function rb(t){let e=J8.safeParse(t);return e.success?e.data:null}var Q8=process.env.FILEX_API_URL||"https://filex-xi.vercel.app/api/parse-intent";async function nb(t){try{let e=await fetch(Q8,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t})});if(!e.ok)return{success:!1,error:(await e.json().catch(()=>({}))).error||`API error: ${e.status}`};let r=await e.json();if(typeof r=="object"&&r!==null&&"error"in r){let i=r;return i.error==="unsupported"?{success:!1,error:"This feature is not supported yet. Let us know and we'll add it!"}:i.error==="unclear"?{success:!1,error:"Could not understand your request. Please use a manual command."}:{success:!1,error:i.error}}let n=rb(r);return n?{success:!0,action:n}:{success:!1,error:"Response did not match expected schema. Please use a manual command."}}catch(e){return{success:!1,error:`Request failed: ${e.message}`}}}function ib(t){console.log(),console.log(Q.red("Error:"),t),console.log(),console.log(Q.yellow("Manual commands:")),console.log(),console.log(Q.cyan(" Convert images:")),console.log(Q.gray(" filex convert ./photos --to webp")),console.log(Q.gray(" filex convert ./photos --from png --to jpg")),console.log(),console.log(Q.cyan(" Resize images:")),console.log(Q.gray(" filex resize ./photos --max-width 1200")),console.log(),console.log(Q.cyan(" Merge PDFs:")),console.log(Q.gray(" filex merge-pdfs ./docs")),console.log(Q.gray(" filex merge-pdfs ./docs --order date --output combined.pdf")),console.log()}kr();function $8(t){switch(t.action){case"convert_images":return"Image Conversion";case"resize_images":return"Image Resize";case"merge_pdfs":return"PDF Merge";default:return"Unknown"}}function ek(t){switch(t.action){case"convert_images":{let e=[],r=t.options?.from,n=t.options?.to??t.options?.format??"webp";return r?e.push(`Convert: ${r.toUpperCase()} \u2192 ${n.toUpperCase()}`):e.push(`Convert to: ${n.toUpperCase()}`),t.options?.maxWidth&&e.push(`Max width: ${t.options.maxWidth}px`),t.options?.quality&&e.push(`Quality: ${t.options.quality}%`),e}case"resize_images":return[`Max width: ${t.options.maxWidth}px`,"Aspect ratio preserved"];case"merge_pdfs":{let e=t.options?.outputFile??"merged.pdf",r=t.options?.order??"name";return[`Order: ${{name:"Alphabetical (A\u2192Z)","name-desc":"Reverse (Z\u2192A)",date:"Oldest first","date-desc":"Newest first",random:"Random"}[r]??"Alphabetical"}`,`Output: ${e}`]}default:return["Unknown action"]}}function ab(t){let e=$8(t),n=ek(t).map(i=>` ${Q.gray("\u203A")} ${Q.white(i)}`).join(`
|
|
72
72
|
`);return`${Q.cyan.bold(`\u25B8 ${e}`)}
|
|
73
|
-
${n}`}var tk="0.
|
|
73
|
+
${n}`}var tk="0.1.2";async function rk(t,e){switch(t.action){case"convert_images":await jc(e,{from:t.options?.from,to:t.options?.to??t.options?.format,maxWidth:t.options?.maxWidth,quality:t.options?.quality});break;case"resize_images":await Uc(e,{maxWidth:t.options.maxWidth});break;case"merge_pdfs":await op(e,{outputFile:t.options?.outputFile,order:t.options?.order});break}}async function nk(t,e){let r=(await Promise.resolve().then(()=>(xo(),Pv))).default("Processing...").start(),n=await nb(t);n.success||(r.fail("Could not parse request"),ib(n.error),process.exit(1)),r.succeed("Request parsed"),console.log(),console.log(ab(n.action)),console.log(),await rk(n.action,e)}function ob(){let t=new Np;t.name("filex").description("A CLI agent to modify and interact with your files").version(tk),t.command("convert").description("Convert images between formats").argument("<directory>","Directory containing images").option("--from <format>","Source format (png, jpg, webp, gif, tiff, avif)").option("--to <format>","Target format (webp, png, jpg)","webp").option("--max-width <pixels>","Maximum width in pixels",parseInt).option("--quality <percent>","Output quality (1-100)",parseInt,80).action(async(e,r)=>{try{await jc(e,{from:r.from,to:r.to||"webp",maxWidth:r.maxWidth,quality:r.quality})}catch(n){console.error(Q.red(`Error: ${n.message}`)),process.exit(1)}}),t.command("resize").description("Resize images to a maximum width").argument("<directory>","Directory containing images").requiredOption("--max-width <pixels>","Maximum width in pixels",parseInt).action(async(e,r)=>{try{await Uc(e,{maxWidth:r.maxWidth})}catch(n){console.error(Q.red(`Error: ${n.message}`)),process.exit(1)}}),t.command("merge-pdfs").description("Merge all PDFs in a directory").argument("<directory>","Directory containing PDFs").option("-o, --output <filename>","Output filename","merged.pdf").option("--order <type>","Sort order: name, name-desc, date, date-desc, random","name").action(async(e,r)=>{try{await op(e,{outputFile:r.output,order:r.order})}catch(n){console.error(Q.red(`Error: ${n.message}`)),process.exit(1)}}),t.argument("[input...]","Natural language input for AI parsing").option("-d, --directory <path>","Target directory",".").action(async(e,r)=>{let n=e.join(" ").trim();if(!n){t.help();return}if(["convert","resize","merge-pdfs","help","--help","-h","--version","-V"].includes(n.toLowerCase())){t.help();return}try{await nk(n,r.directory)}catch(a){console.error(Q.red(`Error: ${a.message}`)),process.exit(1)}}),process.on("SIGINT",()=>{console.log(),console.log(Q.red("Interrupted.")),process.exit(0)}),t.parse()}ob();
|
|
74
74
|
/*! Bundled license information:
|
|
75
75
|
|
|
76
76
|
tslib/tslib.es6.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "filex-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A CLI agent to modify and interact with your files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cli.js",
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "esbuild bin/filex.ts --bundle --platform=node --format=cjs --minify --outfile=dist/filex.cjs --external:sharp",
|
|
15
|
+
"build": "esbuild bin/filex.ts --bundle --platform=node --format=cjs --minify --outfile=dist/filex.cjs --external:sharp --define:__VERSION__=\\\"$(node -p \"require('./package.json').version\")\\\"",
|
|
16
16
|
"dev": "tsx bin/filex.ts",
|
|
17
|
-
"start": "node dist/filex.cjs"
|
|
17
|
+
"start": "node dist/filex.cjs",
|
|
18
|
+
"prepare": "husky"
|
|
18
19
|
},
|
|
19
20
|
"keywords": [
|
|
20
21
|
"cli",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"@types/node": "^22.10.5",
|
|
43
44
|
"@vercel/node": "^4.0.0",
|
|
44
45
|
"esbuild": "^0.27.2",
|
|
46
|
+
"husky": "^9.1.7",
|
|
45
47
|
"tsx": "^4.19.2",
|
|
46
48
|
"typescript": "^5.7.3"
|
|
47
49
|
}
|