nfets 0.0.143 → 0.0.144
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/core/index.cjs +1 -1
- package/dist/core/index.d.cts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.mjs +1 -1
- package/package.json +1 -1
package/dist/core/index.cjs
CHANGED
|
@@ -91,7 +91,7 @@ Actual: `+R.attribValue);else{var Ue=R.tag,B=R.tags[R.tags.length-1]||R;Ue.ns===
|
|
|
91
91
|
`&&h!==" "&&h!=="\r")return f;f++,s()}return-1}o(i,"skipBlanks");function a(){return r.substring(t)}o(a,"substringFromIndex");function u(f){return r.substring(t,t+f.length)===f}o(u,"substringStartsWith");function c(f){return r.substring(t,t+f.length).toUpperCase()===f.toUpperCase()}o(c,"substringStartsWithCaseInsensitive");function l(f){var h=Ct.reg("^",f),d=h.exec(a());return d?(s(d[0].length),d[0]):null}return o(l,"getMatch"),{char:n,getIndex:o(function(){return t},"getIndex"),getMatch:l,getSource:o(function(){return r},"getSource"),skip:s,skipBlanks:i,substringFromIndex:a,substringStartsWith:u,substringStartsWithCaseInsensitive:c}}o(rX,"parseUtils");function Hge(r,e){function t(u,c){var l=Ct.PI.exec(u.substringFromIndex());return l?l[1].toLowerCase()==="xml"?c.fatalError("xml declaration is only allowed at the start of the document, but found at position "+u.getIndex()):(u.skip(l[0].length),l[0]):c.fatalError("processing instruction is not well-formed at position "+u.getIndex())}o(t,"parsePI");var n=r.getSource();if(r.char()==="["){r.skip(1);for(var s=r.getIndex();r.getIndex()<n.length;){if(r.skipBlanks(),r.char()==="]"){var i=n.substring(s,r.getIndex());return r.skip(1),i}var a=null;if(r.char()==="<"&&r.char(1)==="!")switch(r.char(2)){case"E":r.char(3)==="L"?a=r.getMatch(Ct.elementdecl):r.char(3)==="N"&&(a=r.getMatch(Ct.EntityDecl));break;case"A":a=r.getMatch(Ct.AttlistDecl);break;case"N":a=r.getMatch(Ct.NotationDecl);break;case"-":a=r.getMatch(Ct.Comment);break}else if(r.char()==="<"&&r.char(1)==="?")a=t(r,e);else if(r.char()==="%")a=r.getMatch(Ct.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!a)return e.fatalError("Error in internal subset at position "+r.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}o(Hge,"parseDoctypeInternalSubset");function nX(r,e,t,n,s){var i=rX(r,e);switch(s?i.char(2).toUpperCase():i.char(2)){case"-":var a=i.getMatch(Ct.Comment);return a?(t.comment(a,Ct.COMMENT_START.length,a.length-Ct.COMMENT_START.length-Ct.COMMENT_END.length),i.getIndex()):n.fatalError("comment is not well-formed at position "+i.getIndex());case"[":var u=i.getMatch(Ct.CDSect);return u?!s&&!t.currentElement?n.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(u,Ct.CDATA_START.length,u.length-Ct.CDATA_START.length-Ct.CDATA_END.length),t.endCDATA(),i.getIndex()):n.fatalError("Invalid CDATA starting at position "+e);case"D":{if(t.doc&&t.doc.documentElement)return n.fatalError("Doctype not allowed inside or after documentElement at position "+i.getIndex());if(s?!i.substringStartsWithCaseInsensitive(Ct.DOCTYPE_DECL_START):!i.substringStartsWith(Ct.DOCTYPE_DECL_START))return n.fatalError("Expected "+Ct.DOCTYPE_DECL_START+" at position "+i.getIndex());if(i.skip(Ct.DOCTYPE_DECL_START.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+Ct.DOCTYPE_DECL_START+" at position "+i.getIndex());var c={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(c.name=i.getMatch(Ct.Name),!c.name)return n.fatalError("doctype name missing or contains unexpected characters at position "+i.getIndex());if(s&&c.name.toLowerCase()!=="html"&&n.warning("Unexpected DOCTYPE in HTML document at position "+i.getIndex()),i.skipBlanks(),i.substringStartsWith(Ct.PUBLIC)||i.substringStartsWith(Ct.SYSTEM)){var l=Ct.ExternalID_match.exec(i.substringFromIndex());if(!l)return n.fatalError("doctype external id is not well-formed at position "+i.getIndex());l.groups.SystemLiteralOnly!==void 0?c.systemId=l.groups.SystemLiteralOnly:(c.systemId=l.groups.SystemLiteral,c.publicId=l.groups.PubidLiteral),i.skip(l[0].length)}else if(s&&i.substringStartsWithCaseInsensitive(Ct.SYSTEM)){if(i.skip(Ct.SYSTEM.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+Ct.SYSTEM+" at position "+i.getIndex());if(c.systemId=i.getMatch(Ct.ABOUT_LEGACY_COMPAT_SystemLiteral),!c.systemId)return n.fatalError("Expected "+Ct.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+Ct.SYSTEM+" at position "+i.getIndex())}return s&&c.systemId&&!Ct.ABOUT_LEGACY_COMPAT_SystemLiteral.test(c.systemId)&&n.warning("Unexpected doctype.systemId in HTML document at position "+i.getIndex()),s||(i.skipBlanks(),c.internalSubset=Hge(i,n)),i.skipBlanks(),i.char()!==">"?n.fatalError("doctype not terminated with > at position "+i.getIndex()):(i.skip(1),t.startDTD(c.name,c.publicId,c.systemId,c.internalSubset),t.endDTD(),i.getIndex())}default:return n.fatalError('Not well-formed XML starting with "<!" at position '+e)}}o(nX,"parseDoctypeCommentOrCData");function Kge(r,e,t,n){var s=r.substring(e).match(Ct.PI);if(!s)return n.fatalError("Invalid processing instruction starting at position "+e);if(s[1].toLowerCase()==="xml"){if(e>0)return n.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!Ct.XMLDecl.test(r.substring(e)))return n.fatalError("xml declaration is not well-formed")}return t.processingInstruction(s[1],s[2]),e+s[0].length}o(Kge,"parseProcessingInstruction");function sX(){this.attributeNames=Object.create(null)}o(sX,"ElementAttributes");sX.prototype={setTagName:o(function(r){if(!Ct.QName_exact.test(r))throw new Error("invalid tagName:"+r);this.tagName=r},"setTagName"),addValue:o(function(r,e,t){if(!Ct.QName_exact.test(r))throw new Error("invalid attribute:"+r);this.attributeNames[r]=this.length,this[this.length++]={qName:r,value:e,offset:t}},"addValue"),length:0,getLocalName:o(function(r){return this[r].localName},"getLocalName"),getLocator:o(function(r){return this[r].locator},"getLocator"),getQName:o(function(r){return this[r].qName},"getQName"),getURI:o(function(r){return this[r].uri},"getURI"),getValue:o(function(r){return this[r].value},"getValue")};xC.XMLReader=tX;xC.parseUtils=rX;xC.parseDoctypeCommentOrCData=nX});var hX=z(D0=>{"use strict";var Ch=Sh(),$ge=iP(),Xge=Fx(),aX=J$(),Gge=iX(),zge=$ge.DOMImplementation,Wge=Ch.hasDefaultHTMLNamespace,Jge=Ch.isHTMLMimeType,Yge=Ch.isValidMimeType,cX=Ch.MIME_TYPE,oP=Ch.NAMESPACE,oX=Xge.ParseError,Qge=Gge.XMLReader;function lX(r){return r.replace(/\r[\n\u0085]/g,`
|
|
92
92
|
`).replace(/[\r\u0085\u2028\u2029]/g,`
|
|
93
93
|
`)}o(lX,"normalizeLineEndings");function fX(r){if(r=r||{},r.locator===void 0&&(r.locator=!0),this.assign=r.assign||Ch.assign,this.domHandler=r.domHandler||wC,this.onError=r.onError||r.errorHandler,r.errorHandler&&typeof r.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");r.errorHandler&&r.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=r.normalizeLineEndings||lX,this.locator=!!r.locator,this.xmlns=this.assign(Object.create(null),r.xmlns)}o(fX,"DOMParser");fX.prototype.parseFromString=function(r,e){if(!Yge(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),n=aX.XML_ENTITIES,s=t[""]||null;Wge(e)?(n=aX.HTML_ENTITIES,s=oP.HTML):e===cX.XML_SVG_IMAGE&&(s=oP.SVG),t[""]=s,t.xml=t.xml||oP.XML;var i=new this.domHandler({mimeType:e,defaultNamespace:s,onError:this.onError}),a=this.locator?{}:void 0;this.locator&&i.setDocumentLocator(a);var u=new Qge;u.errorHandler=i,u.domBuilder=i;var c=!Ch.isHTMLMimeType(e);return c&&typeof r!="string"&&u.errorHandler.fatalError("source is not a string"),u.parse(this.normalizeLineEndings(String(r)),t,n),i.doc.documentElement||u.errorHandler.fatalError("missing root element"),i.doc};function wC(r){var e=r||{};this.mimeType=e.mimeType||cX.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}o(wC,"DOMHandler");function I0(r,e){e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber}o(I0,"position");wC.prototype={startDocument:o(function(){var r=new zge;this.doc=Jge(this.mimeType)?r.createHTMLDocument(!1):r.createDocument(this.defaultNamespace,"")},"startDocument"),startElement:o(function(r,e,t,n){var s=this.doc,i=s.createElementNS(r,t||e),a=n.length;EC(this,i),this.currentElement=i,this.locator&&I0(this.locator,i);for(var u=0;u<a;u++){var r=n.getURI(u),c=n.getValue(u),t=n.getQName(u),l=s.createAttributeNS(r,t);this.locator&&I0(n.getLocator(u),l),l.value=l.nodeValue=c,i.setAttributeNode(l)}},"startElement"),endElement:o(function(r,e,t){this.currentElement=this.currentElement.parentNode},"endElement"),startPrefixMapping:o(function(r,e){},"startPrefixMapping"),endPrefixMapping:o(function(r){},"endPrefixMapping"),processingInstruction:o(function(r,e){var t=this.doc.createProcessingInstruction(r,e);this.locator&&I0(this.locator,t),EC(this,t)},"processingInstruction"),ignorableWhitespace:o(function(r,e,t){},"ignorableWhitespace"),characters:o(function(r,e,t){if(r=uX.apply(this,arguments),r){if(this.cdata)var n=this.doc.createCDATASection(r);else var n=this.doc.createTextNode(r);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(r)&&this.doc.appendChild(n),this.locator&&I0(this.locator,n)}},"characters"),skippedEntity:o(function(r){},"skippedEntity"),endDocument:o(function(){this.doc.normalize()},"endDocument"),setDocumentLocator:o(function(r){r&&(r.lineNumber=0),this.locator=r},"setDocumentLocator"),comment:o(function(r,e,t){r=uX.apply(this,arguments);var n=this.doc.createComment(r);this.locator&&I0(this.locator,n),EC(this,n)},"comment"),startCDATA:o(function(){this.cdata=!0},"startCDATA"),endCDATA:o(function(){this.cdata=!1},"endCDATA"),startDTD:o(function(r,e,t,n){var s=this.doc.implementation;if(s&&s.createDocumentType){var i=s.createDocumentType(r,e,t,n);this.locator&&I0(this.locator,i),EC(this,i),this.doc.doctype=i}},"startDTD"),reportError:o(function(r,e){if(typeof this.onError=="function")try{this.onError(r,e,this)}catch(t){throw new oX("Reporting "+r+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+r+"] "+e,Zge(this.locator))},"reportError"),warning:o(function(r){this.reportError("warning",r)},"warning"),error:o(function(r){this.reportError("error",r)},"error"),fatalError:o(function(r,e){throw this.reportError("fatalError",r),new oX(r,this.locator,e)},"fatalError")};function Zge(r){if(r)return`
|
|
94
|
-
@#[line:`+r.lineNumber+",col:"+r.columnNumber+"]"}o(Zge,"_locator");function uX(r,e,t){return typeof r=="string"?r.substr(e,t):r.length>=e+t||e?new java.lang.String(r,e,t)+"":r}o(uX,"_toString");"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){wC.prototype[r]=function(){return null}});function EC(r,e){r.currentElement?r.currentElement.appendChild(e):r.doc.appendChild(e)}o(EC,"appendElement");function eye(r){if(r==="error")throw"onErrorStopParsing"}o(eye,"onErrorStopParsing");function tye(){throw"onWarningStopParsing"}o(tye,"onWarningStopParsing");D0.__DOMHandler=wC;D0.DOMParser=fX;D0.normalizeLineEndings=lX;D0.onErrorStopParsing=eye;D0.onWarningStopParsing=tye});var pX=z(tr=>{"use strict";var _0=Sh();tr.assign=_0.assign;tr.hasDefaultHTMLNamespace=_0.hasDefaultHTMLNamespace;tr.isHTMLMimeType=_0.isHTMLMimeType;tr.isValidMimeType=_0.isValidMimeType;tr.MIME_TYPE=_0.MIME_TYPE;tr.NAMESPACE=_0.NAMESPACE;var bC=Fx();tr.DOMException=bC.DOMException;tr.DOMExceptionName=bC.DOMExceptionName;tr.ExceptionCode=bC.ExceptionCode;tr.ParseError=bC.ParseError;var yn=iP();tr.Attr=yn.Attr;tr.CDATASection=yn.CDATASection;tr.CharacterData=yn.CharacterData;tr.Comment=yn.Comment;tr.Document=yn.Document;tr.DocumentFragment=yn.DocumentFragment;tr.DocumentType=yn.DocumentType;tr.DOMImplementation=yn.DOMImplementation;tr.Element=yn.Element;tr.Entity=yn.Entity;tr.EntityReference=yn.EntityReference;tr.LiveNodeList=yn.LiveNodeList;tr.NamedNodeMap=yn.NamedNodeMap;tr.Node=yn.Node;tr.NodeList=yn.NodeList;tr.Notation=yn.Notation;tr.ProcessingInstruction=yn.ProcessingInstruction;tr.Text=yn.Text;tr.XMLSerializer=yn.XMLSerializer;var SC=hX();tr.DOMParser=SC.DOMParser;tr.normalizeLineEndings=SC.normalizeLineEndings;tr.onErrorStopParsing=SC.onErrorStopParsing;tr.onWarningStopParsing=SC.onWarningStopParsing});var oye={};Jx(oye,{ASN1:()=>Wa,CanonicalizationMethod:()=>CC,Choice:()=>nye,Decimal:()=>Zc,DigestAlgorithm:()=>Zx,EntitySigner:()=>TC,Environment:()=>kX,IsDecimal:()=>cP,Left:()=>tE,MemoryCacheAdapter:()=>UC,NFeTsError:()=>Xt,NativeCertificateRepository:()=>XN,NullCacheAdapter:()=>tg,Once:()=>sye,PdfkitPdfBuilder:()=>FC,Right:()=>L0,SignatureAlgorithm:()=>Ha,SignatureMethod:()=>Qx,SignatureNamespace:()=>Yx,Signer:()=>Qc,SkipAllValidations:()=>FX,SkipValidation:()=>LX,SkipValidationMetadata:()=>Th,SoapRemoteTransmissionRepository:()=>Y_,StateAcronyms:()=>PX,StateCodeAcValidator:()=>fP,StateCodeAlValidator:()=>hP,StateCodeAmValidator:()=>pP,StateCodeApValidator:()=>dP,StateCodeBaValidator:()=>mP,StateCodeCeValidator:()=>gP,StateCodeDfValidator:()=>yP,StateCodeEsValidator:()=>vP,StateCodeGoValidator:()=>xP,StateCodeMaValidator:()=>EP,StateCodeMgValidator:()=>wP,StateCodeMsValidator:()=>bP,StateCodeMtValidator:()=>SP,StateCodePaValidator:()=>AP,StateCodePbValidator:()=>CP,StateCodePeValidator:()=>NP,StateCodePiValidator:()=>TP,StateCodePrValidator:()=>IP,StateCodeRjValidator:()=>DP,StateCodeRnValidator:()=>_P,StateCodeRoValidator:()=>RP,StateCodeRrValidator:()=>BP,StateCodeRsValidator:()=>OP,StateCodeScValidator:()=>PP,StateCodeSeValidator:()=>kP,StateCodeSpValidator:()=>LP,StateCodeToValidator:()=>FP,StateCodes:()=>lr,TransformDateString:()=>aye,TransformDecimal:()=>iye,TransmissionError:()=>P0,TransmissionHostNotFoundError:()=>Wo,TransmissionTimeoutError:()=>Jo,ValidateErrorsMetadata:()=>_C,Validates:()=>UX,ValidationError:()=>NC,Xml2JsToolkit:()=>uP,XmlSigner:()=>IC,clearEmptyValues:()=>F0,dateToolkit:()=>ll,fixUtf8Mojibake:()=>z9,left:()=>rr,leftFromError:()=>gs,leftFromTransmissionError:()=>z_,mapConstraintsToErrors:()=>RC,mapTransmissionError:()=>G9,normalizeTransmissionStrings:()=>J_,plainToInstance:()=>DC,right:()=>sn,search:()=>HE,timezones:()=>qP,unreachable:()=>eE});module.exports=OX(oye);var Yx="http://www.w3.org/2000/09/xmldsig#",CC="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",Qx=(function(r){return r.RSA_SHA1="http://www.w3.org/2000/09/xmldsig#rsa-sha1",r.RSA_SHA256="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",r})({}),Ha=(function(r){return r.SHA1="sha1",r.SHA256="sha256",r})({}),Zx=(function(r){return r.SHA1="http://www.w3.org/2000/09/xmldsig#sha1",r.SHA256="http://www.w3.org/2001/04/xmlenc#sha256",r})({});var lr={AC:"12",AL:"27",AM:"13",AP:"16",BA:"29",CE:"23",DF:"53",ES:"32",GO:"52",MA:"21",MG:"31",MS:"50",MT:"51",PA:"15",PB:"25",PE:"26",PI:"22",PR:"41",RJ:"33",RN:"24",RO:"11",RR:"14",RS:"43",SC:"42",SE:"28",SP:"35",TO:"17"},PX=Object.keys(lr);var kX={Production:"1",Homolog:"2"};var qP={[lr.AC]:"America/Rio_Branco",[lr.AL]:"America/Maceio",[lr.AM]:"America/Manaus",[lr.AP]:"America/Belem",[lr.BA]:"America/Bahia",[lr.CE]:"America/Fortaleza",[lr.DF]:"America/Sao_Paulo",[lr.ES]:"America/Sao_Paulo",[lr.GO]:"America/Sao_Paulo",[lr.MA]:"America/Fortaleza",[lr.MG]:"America/Sao_Paulo",[lr.MS]:"America/Campo_Grande",[lr.MT]:"America/Cuiaba",[lr.PA]:"America/Belem",[lr.PB]:"America/Fortaleza",[lr.PE]:"America/Recife",[lr.PI]:"America/Fortaleza",[lr.PR]:"America/Sao_Paulo",[lr.RJ]:"America/Sao_Paulo",[lr.RN]:"America/Fortaleza",[lr.RO]:"America/Porto_Velho",[lr.RR]:"America/Boa_Vista",[lr.RS]:"America/Sao_Paulo",[lr.SC]:"America/Sao_Paulo",[lr.SE]:"America/Maceio",[lr.SP]:"America/Sao_Paulo",[lr.TO]:"America/Araguaina"};var Xt=class extends Error{static{o(this,"NFeTsError")}};var P0=class extends Xt{static{o(this,"TransmissionError")}},Wo=class extends P0{static{o(this,"TransmissionHostNotFoundError")}},Jo=class extends P0{static{o(this,"TransmissionTimeoutError")}};var NC=class extends Xt{static{o(this,"ValidationError")}};var k0={includeComments:!1,exclusive:!0};var eE=o(r=>{throw new Xt("Didn't expect to get here")},"unreachable");var Qc=class{static{o(this,"Signer")}toolkit;certificateRepository;algorithm;canonical;constructor(e,t,n=Ha.SHA1,s=k0){this.toolkit=e,this.certificateRepository=t,this.algorithm=n,this.canonical=s}assemble(e,t,n){let s=this.certificateRepository.getStringCertificate(n);return{$:{xmlns:Yx},SignedInfo:e,SignatureValue:t,KeyInfo:{X509Data:{X509Certificate:s}}}}signedInfo(e,t){return{CanonicalizationMethod:{$:{Algorithm:CC}},SignatureMethod:{$:{Algorithm:this.signatureMethod}},Reference:{$:{URI:`#${this.toolkit.getAttribute(e,t)}`},Transforms:this.transforms,DigestMethod:{$:{Algorithm:this.digestAlgorithm}},DigestValue:this.digest(e)}}}digest(e){return this.toolkit.digest(e,this.algorithm,this.canonical)}async signOrLeft(e,t){let n=this.toolkit.canonicalize(await this.toolkit.build({$:{xmlns:Yx},...e},{rootName:"SignedInfo"}),this.canonical);return this.certificateRepository.sign(n,t,this.algorithm)}get transforms(){return{Transform:[{$:{Algorithm:"http://www.w3.org/2000/09/xmldsig#enveloped-signature"}},{$:{Algorithm:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"}}]}}get digestAlgorithm(){switch(this.algorithm){case Ha.SHA256:return Zx.SHA256;case Ha.SHA1:return Zx.SHA1;default:return eE(this.algorithm)}}get signatureMethod(){switch(this.algorithm){case Ha.SHA256:return Qx.RSA_SHA256;case Ha.SHA1:return Qx.RSA_SHA1;default:return eE(this.algorithm)}}};var tE=class{static{o(this,"Left")}value;constructor(e){this.value=e}isLeft(){return!0}isRight(){return!1}},L0=class{static{o(this,"Right")}value;constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}},rr=o(r=>new tE(r),"left"),sn=o(r=>r===void 0?new L0(void 0):new L0(r),"right");var TC=class extends Qc{static{o(this,"EntitySigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n;if(!e[s])return rr(new Xt(`Node ${String(s)} not found`));let u=await this.toolkit.build(this.ns(e,s),{headless:!0,rootName:String(s),renderOpts:{pretty:!1}}),c=this.signedInfo(u,i),l=await this.signOrLeft(c,n);if(l.isLeft())return l;let f=e;return f.Signature=this.assemble(c,l.value,a),sn(f)}ns(e,t){let n=e.$?.xmlns,{$:s,...i}=e[t],{xmlns:a,...u}=s??{};return{$:{xmlns:n,...u},...i}}};var IC=class extends Qc{static{o(this,"XmlSigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n,u=this.toolkit.getNode(e,s);if(!u)return rr(new Xt(`Node ${s} not found`));let c=this.signedInfo(u,i),l=await this.signOrLeft(c,n);if(l.isLeft())return l;let f=await this.toolkit.build(this.assemble(c,l.value,a),{rootName:"Signature"});return sn(this.toolkit.appendNode(e,f))}};var l1e=require("reflect-metadata"),KP=require("class-validator");var i1e=require("reflect-metadata");var Th="__SkipValidation__",LX=o(()=>(r,e)=>{Reflect.defineMetadata(Th,!0,r,e.toString())},"SkipValidation"),FX=o(()=>r=>{Reflect.defineMetadata(Th,!0,r)},"SkipAllValidations");var HP=require("class-transformer");var F0=o(r=>{for(let[e,t]of Object.entries(r))typeof t>"u"&&delete r[e],t===""&&delete r[e],t&&typeof t=="object"&&F0(t)},"clearEmptyValues"),DC=o((r,e,t={})=>{let n=(0,HP.plainToInstance)(e,r);return t.clearEmptyValues&&F0(n),n},"plainToInstance");var _C="__ValidateErrors__",RC=o((r,e)=>r.reduce((t,n)=>{if(n.children?.length)return t.concat(RC(n.children,e?`${e}.${n.property}`:n.property));let s=Object.values(n.constraints??{}).map(i=>e?`${e}.${i}`:i).join(", ");return s?t.concat(s):t},[]),"mapConstraintsToErrors"),UX=o((r,e)=>(t,n,s)=>{let i=s.value;if(i==null)return;let a=o((u,c,l)=>{let f=DC(c,r),h=(0,KP.validateSync)(f,{whitelist:!0});if(F0(f),h.length){let d=Reflect.getMetadata(_C,u)??[];Reflect.defineMetadata(_C,d.concat(RC(h,l)),u)}return f},"validate");s.value=function(...u){let c=Reflect.getMetadata(Th,this.constructor);if(Reflect.getMetadata(Th,this.constructor.prototype,n.toString())===!0||c===!0)return i.apply(this,u);let[f,...h]=u;if(!f)return i.apply(this,u);let d=e?.each&&Array.isArray(f)?f.map((m,g)=>a(this,m,`${i.name}.${g}`)):a(this,f,i.name);return i.apply(this,[d,...h])}},"Validates");var yFe=require("reflect-metadata");var Ih=9e15,eu=1e9,BC="0123456789abcdef",sE="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",iE="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",OC={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Ih,maxE:Ih,crypto:!1},zP,Ka,xt=!0,oE="[DecimalError] ",Zo=oE+"Invalid argument: ",WP=oE+"Precision limit exceeded",JP=oE+"crypto unavailable",YP="[object Decimal]",$n=Math.floor,ln=Math.pow,VX=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,MX=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,jX=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,QP=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Di=1e7,ft=7,qX=9007199254740991,HX=sE.length-1,PC=iE.length-1,Ie={toStringTag:YP};Ie.absoluteValue=Ie.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),at(r)};Ie.ceil=function(){return at(new this.constructor(this),this.e+1,2)};Ie.clampedTo=Ie.clamp=function(r,e){var t,n=this,s=n.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(Zo+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};Ie.comparedTo=Ie.cmp=function(r){var e,t,n,s,i=this,a=i.d,u=(r=new i.constructor(r)).d,c=i.s,l=r.s;if(!a||!u)return!c||!l?NaN:c!==l?c:a===u?0:!a^c<0?1:-1;if(!a[0]||!u[0])return a[0]?c:u[0]?-l:0;if(c!==l)return c;if(i.e!==r.e)return i.e>r.e^c<0?1:-1;for(n=a.length,s=u.length,e=0,t=n<s?n:s;e<t;++e)if(a[e]!==u[e])return a[e]>u[e]^c<0?1:-1;return n===s?0:n>s^c<0?1:-1};Ie.cosine=Ie.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+ft,n.rounding=1,t=KX(n,n3(n,t)),n.precision=r,n.rounding=e,at(Ka==2||Ka==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};Ie.cubeRoot=Ie.cbrt=function(){var r,e,t,n,s,i,a,u,c,l,f=this,h=f.constructor;if(!f.isFinite()||f.isZero())return new h(f);for(xt=!1,i=f.s*ln(f.s*f,1/3),!i||Math.abs(i)==1/0?(t=On(f.d),r=f.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=ln(t,1/3),r=$n((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new h(t),n.s=f.s):n=new h(i.toString()),a=(r=h.precision)+3;;)if(u=n,c=u.times(u).times(u),l=c.plus(f),n=Er(l.plus(f).times(u),l.plus(c),a+2,1),On(u.d).slice(0,a)===(t=On(n.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(at(u,r+1,0),u.times(u).times(u).eq(f))){n=u;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(at(n,r+1,1),e=!n.times(n).times(n).eq(f));break}return xt=!0,at(n,r,h.rounding,e)};Ie.decimalPlaces=Ie.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-$n(this.e/ft))*ft,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};Ie.dividedBy=Ie.div=function(r){return Er(this,new this.constructor(r))};Ie.dividedToIntegerBy=Ie.divToInt=function(r){var e=this,t=e.constructor;return at(Er(e,new t(r),0,1,1),t.precision,t.rounding)};Ie.equals=Ie.eq=function(r){return this.cmp(r)===0};Ie.floor=function(){return at(new this.constructor(this),this.e+1,3)};Ie.greaterThan=Ie.gt=function(r){return this.cmp(r)>0};Ie.greaterThanOrEqualTo=Ie.gte=function(r){var e=this.cmp(r);return e==1||e===0};Ie.hyperbolicCosine=Ie.cosh=function(){var r,e,t,n,s,i=this,a=i.constructor,u=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return u;t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,s=i.d.length,s<32?(r=Math.ceil(s/3),e=(1/cE(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=Dh(a,1,i.times(e),new a(1),!0);for(var c,l=r,f=new a(8);l--;)c=i.times(i),i=u.minus(c.times(f.minus(c.times(f))));return at(i,a.precision=t,a.rounding=n,!0)};Ie.hyperbolicSine=Ie.sinh=function(){var r,e,t,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(s.e,s.sd())+4,i.rounding=1,n=s.d.length,n<3)s=Dh(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/cE(5,r)),s=Dh(i,2,s,s,!0);for(var a,u=new i(5),c=new i(16),l=new i(20);r--;)a=s.times(s),s=s.times(u.plus(a.times(c.times(a).plus(l))))}return i.precision=e,i.rounding=t,at(s,e,t,!0)};Ie.hyperbolicTangent=Ie.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,Er(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};Ie.inverseCosine=Ie.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,s=e.rounding;return t!==-1?t===0?r.isNeg()?Qi(e,n,s):new e(0):new e(NaN):r.isZero()?Qi(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=s,r.times(2))};Ie.inverseHyperbolicCosine=Ie.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,xt=!1,t=t.times(t).minus(1).sqrt().plus(t),xt=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};Ie.inverseHyperbolicSine=Ie.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,xt=!1,t=t.times(t).plus(1).sqrt().plus(t),xt=!0,n.precision=r,n.rounding=e,t.ln())};Ie.inverseHyperbolicTangent=Ie.atanh=function(){var r,e,t,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=i.precision,e=i.rounding,n=s.sd(),Math.max(n,r)<2*-s.e-1?at(new i(s),r,e,!0):(i.precision=t=n-s.e,s=Er(s.plus(1),new i(1).minus(s),t+r,1),i.precision=r+4,i.rounding=1,s=s.ln(),i.precision=r,i.rounding=e,s.times(.5))):new i(NaN)};Ie.inverseSine=Ie.asin=function(){var r,e,t,n,s=this,i=s.constructor;return s.isZero()?new i(s):(e=s.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=Qi(i,t+4,n).times(.5),r.s=s.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,s.times(2)))};Ie.inverseTangent=Ie.atan=function(){var r,e,t,n,s,i,a,u,c,l=this,f=l.constructor,h=f.precision,d=f.rounding;if(l.isFinite()){if(l.isZero())return new f(l);if(l.abs().eq(1)&&h+4<=PC)return a=Qi(f,h+4,d).times(.25),a.s=l.s,a}else{if(!l.s)return new f(NaN);if(h+4<=PC)return a=Qi(f,h+4,d).times(.5),a.s=l.s,a}for(f.precision=u=h+10,f.rounding=1,t=Math.min(28,u/ft+2|0),r=t;r;--r)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(xt=!1,e=Math.ceil(u/ft),n=1,c=l.times(l),a=new f(l),s=l;r!==-1;)if(s=s.times(c),i=a.minus(s.div(n+=2)),s=s.times(c),a=i.plus(s.div(n+=2)),a.d[e]!==void 0)for(r=e;a.d[r]===i.d[r]&&r--;);return t&&(a=a.times(2<<t-1)),xt=!0,at(a,f.precision=h,f.rounding=d,!0)};Ie.isFinite=function(){return!!this.d};Ie.isInteger=Ie.isInt=function(){return!!this.d&&$n(this.e/ft)>this.d.length-2};Ie.isNaN=function(){return!this.s};Ie.isNegative=Ie.isNeg=function(){return this.s<0};Ie.isPositive=Ie.isPos=function(){return this.s>0};Ie.isZero=function(){return!!this.d&&this.d[0]===0};Ie.lessThan=Ie.lt=function(r){return this.cmp(r)<0};Ie.lessThanOrEqualTo=Ie.lte=function(r){return this.cmp(r)<1};Ie.logarithm=Ie.log=function(r){var e,t,n,s,i,a,u,c,l=this,f=l.constructor,h=f.precision,d=f.rounding,m=5;if(r==null)r=new f(10),e=!0;else{if(r=new f(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new f(NaN);e=r.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new f(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(s=t[0];s%10===0;)s/=10;i=s!==1}if(xt=!1,u=h+m,a=Qo(l,u),n=e?aE(f,u+10):Qo(r,u),c=Er(a,n,u,1),U0(c.d,s=h,d))do if(u+=10,a=Qo(l,u),n=e?aE(f,u+10):Qo(r,u),c=Er(a,n,u,1),!i){+On(c.d).slice(s+1,s+15)+1==1e14&&(c=at(c,h+1,0));break}while(U0(c.d,s+=10,d));return xt=!0,at(c,h,d)};Ie.minus=Ie.sub=function(r){var e,t,n,s,i,a,u,c,l,f,h,d,m=this,g=m.constructor;if(r=new g(r),!m.d||!r.d)return!m.s||!r.s?r=new g(NaN):m.d?r.s=-r.s:r=new g(r.d||m.s!==r.s?m:NaN),r;if(m.s!=r.s)return r.s=-r.s,m.plus(r);if(l=m.d,d=r.d,u=g.precision,c=g.rounding,!l[0]||!d[0]){if(d[0])r.s=-r.s;else if(l[0])r=new g(m);else return new g(c===3?-0:0);return xt?at(r,u,c):r}if(t=$n(r.e/ft),f=$n(m.e/ft),l=l.slice(),i=f-t,i){for(h=i<0,h?(e=l,i=-i,a=d.length):(e=d,t=f,a=l.length),n=Math.max(Math.ceil(u/ft),a)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=l.length,a=d.length,h=n<a,h&&(a=n),n=0;n<a;n++)if(l[n]!=d[n]){h=l[n]<d[n];break}i=0}for(h&&(e=l,l=d,d=e,r.s=-r.s),a=l.length,n=d.length-a;n>0;--n)l[a++]=0;for(n=d.length;n>i;){if(l[--n]<d[n]){for(s=n;s&&l[--s]===0;)l[s]=Di-1;--l[s],l[n]+=Di}l[n]-=d[n]}for(;l[--a]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(r.d=l,r.e=uE(l,t),xt?at(r,u,c):r):new g(c===3?-0:0)};Ie.modulo=Ie.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?at(new n(t),n.precision,n.rounding):(xt=!1,n.modulo==9?(e=Er(t,r.abs(),0,3,1),e.s*=r.s):e=Er(t,r,0,n.modulo,1),e=e.times(r),xt=!0,t.minus(e))};Ie.naturalExponential=Ie.exp=function(){return kC(this)};Ie.naturalLogarithm=Ie.ln=function(){return Qo(this)};Ie.negated=Ie.neg=function(){var r=new this.constructor(this);return r.s=-r.s,at(r)};Ie.plus=Ie.add=function(r){var e,t,n,s,i,a,u,c,l,f,h=this,d=h.constructor;if(r=new d(r),!h.d||!r.d)return!h.s||!r.s?r=new d(NaN):h.d||(r=new d(r.d||h.s===r.s?h:NaN)),r;if(h.s!=r.s)return r.s=-r.s,h.minus(r);if(l=h.d,f=r.d,u=d.precision,c=d.rounding,!l[0]||!f[0])return f[0]||(r=new d(h)),xt?at(r,u,c):r;if(i=$n(h.e/ft),n=$n(r.e/ft),l=l.slice(),s=i-n,s){for(s<0?(t=l,s=-s,a=f.length):(t=f,n=i,a=l.length),i=Math.ceil(u/ft),a=i>a?i+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=l.length,s=f.length,a-s<0&&(s=a,t=f,f=l,l=t),e=0;s;)e=(l[--s]=l[s]+f[s]+e)/Di|0,l[s]%=Di;for(e&&(l.unshift(e),++n),a=l.length;l[--a]==0;)l.pop();return r.d=l,r.e=uE(l,n),xt?at(r,u,c):r};Ie.precision=Ie.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(Zo+r);return t.d?(e=ZP(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};Ie.round=function(){var r=this,e=r.constructor;return at(new e(r),r.e+1,e.rounding)};Ie.sine=Ie.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+ft,n.rounding=1,t=XX(n,n3(n,t)),n.precision=r,n.rounding=e,at(Ka>2?t.neg():t,r,e,!0)):new n(NaN)};Ie.squareRoot=Ie.sqrt=function(){var r,e,t,n,s,i,a=this,u=a.d,c=a.e,l=a.s,f=a.constructor;if(l!==1||!u||!u[0])return new f(!l||l<0&&(!u||u[0])?NaN:u?a:1/0);for(xt=!1,l=Math.sqrt(+a),l==0||l==1/0?(e=On(u),(e.length+c)%2==0&&(e+="0"),l=Math.sqrt(e),c=$n((c+1)/2)-(c<0||c%2),l==1/0?e="5e"+c:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),n=new f(e)):n=new f(l.toString()),t=(c=f.precision)+3;;)if(i=n,n=i.plus(Er(a,i,t+2,1)).times(.5),On(i.d).slice(0,t)===(e=On(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(at(i,c+1,0),i.times(i).eq(a))){n=i;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(at(n,c+1,1),r=!n.times(n).eq(a));break}return xt=!0,at(n,c,f.rounding,r)};Ie.tangent=Ie.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=Er(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,at(Ka==2||Ka==4?t.neg():t,r,e,!0)):new n(NaN)};Ie.times=Ie.mul=function(r){var e,t,n,s,i,a,u,c,l,f=this,h=f.constructor,d=f.d,m=(r=new h(r)).d;if(r.s*=f.s,!d||!d[0]||!m||!m[0])return new h(!r.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?r.s/0:r.s*0);for(t=$n(f.e/ft)+$n(r.e/ft),c=d.length,l=m.length,c<l&&(i=d,d=m,m=i,a=c,c=l,l=a),i=[],a=c+l,n=a;n--;)i.push(0);for(n=l;--n>=0;){for(e=0,s=c+n;s>n;)u=i[s]+m[n]*d[s-n-1]+e,i[s--]=u%Di|0,e=u/Di|0;i[s]=(i[s]+e)%Di|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),r.d=i,r.e=uE(i,t),xt?at(r,h.precision,h.rounding):r};Ie.toBinary=function(r,e){return LC(this,2,r,e)};Ie.toDecimalPlaces=Ie.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(ps(r,0,eu),e===void 0?e=n.rounding:ps(e,0,8),at(t,r+t.e+1,e))};Ie.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Zi(n,!0):(ps(r,0,eu),e===void 0?e=s.rounding:ps(e,0,8),n=at(new s(n),r+1,e),t=Zi(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};Ie.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=Zi(s):(ps(r,0,eu),e===void 0?e=i.rounding:ps(e,0,8),n=at(new i(s),r+s.e+1,e),t=Zi(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};Ie.toFraction=function(r){var e,t,n,s,i,a,u,c,l,f,h,d,m=this,g=m.d,x=m.constructor;if(!g)return new x(m);if(l=t=new x(1),n=c=new x(0),e=new x(n),i=e.e=ZP(g)-m.e-1,a=i%ft,e.d[0]=ln(10,a<0?ft+a:a),r==null)r=i>0?e:l;else{if(u=new x(r),!u.isInt()||u.lt(l))throw Error(Zo+u);r=u.gt(e)?i>0?e:l:u}for(xt=!1,u=new x(On(g)),f=x.precision,x.precision=i=g.length*ft*2;h=Er(u,e,0,1,1),s=t.plus(h.times(n)),s.cmp(r)!=1;)t=n,n=s,s=l,l=c.plus(h.times(s)),c=s,s=e,e=u.minus(h.times(s)),u=s;return s=Er(r.minus(t),n,0,1,1),c=c.plus(s.times(l)),t=t.plus(s.times(n)),c.s=l.s=m.s,d=Er(l,n,i,1).minus(m).abs().cmp(Er(c,t,i,1).minus(m).abs())<1?[l,n]:[c,t],x.precision=f,xt=!0,d};Ie.toHexadecimal=Ie.toHex=function(r,e){return LC(this,16,r,e)};Ie.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:ps(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(xt=!1,t=Er(t,r,0,e,1).times(r),xt=!0,at(t)):(r.s=t.s,t=r),t};Ie.toNumber=function(){return+this};Ie.toOctal=function(r,e){return LC(this,8,r,e)};Ie.toPower=Ie.pow=function(r){var e,t,n,s,i,a,u=this,c=u.constructor,l=+(r=new c(r));if(!u.d||!r.d||!u.d[0]||!r.d[0])return new c(ln(+u,l));if(u=new c(u),u.eq(1))return u;if(n=c.precision,i=c.rounding,r.eq(1))return at(u,n,i);if(e=$n(r.e/ft),e>=r.d.length-1&&(t=l<0?-l:l)<=qX)return s=e3(c,u,t,n),r.s<0?new c(1).div(s):at(s,n,i);if(a=u.s,a<0){if(e<r.d.length-1)return new c(NaN);if((r.d[e]&1)==0&&(a=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=a,u}return t=ln(+u,l),e=t==0||!isFinite(t)?$n(l*(Math.log("0."+On(u.d))/Math.LN10+u.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?a/0:0):(xt=!1,c.rounding=u.s=1,t=Math.min(12,(e+"").length),s=kC(r.times(Qo(u,n+t)),n),s.d&&(s=at(s,n+5,1),U0(s.d,n,i)&&(e=n+10,s=at(kC(r.times(Qo(u,e+t)),e),e+5,1),+On(s.d).slice(n+1,n+15)+1==1e14&&(s=at(s,n+1,0)))),s.s=a,xt=!0,c.rounding=i,at(s,n,i))};Ie.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Zi(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(ps(r,1,eu),e===void 0?e=s.rounding:ps(e,0,8),n=at(new s(n),r,e),t=Zi(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};Ie.toSignificantDigits=Ie.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(ps(r,1,eu),e===void 0?e=n.rounding:ps(e,0,8)),at(new n(t),r,e)};Ie.toString=function(){var r=this,e=r.constructor,t=Zi(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};Ie.truncated=Ie.trunc=function(){return at(new this.constructor(this),this.e+1,1)};Ie.valueOf=Ie.toJSON=function(){var r=this,e=r.constructor,t=Zi(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function On(r){var e,t,n,s=r.length-1,i="",a=r[0];if(s>0){for(i+=a,e=1;e<s;e++)n=r[e]+"",t=ft-n.length,t&&(i+=Yo(t)),i+=n;a=r[e],n=a+"",t=ft-n.length,t&&(i+=Yo(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}o(On,"digitsToString");function ps(r,e,t){if(r!==~~r||r<e||r>t)throw Error(Zo+r)}o(ps,"checkInt32");function U0(r,e,t,n){var s,i,a,u;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=ft,s=0):(s=Math.ceil((e+1)/ft),e%=ft),i=ln(10,ft-e),u=r[s]%i|0,n==null?e<3?(e==0?u=u/100|0:e==1&&(u=u/10|0),a=t<4&&u==99999||t>3&&u==49999||u==5e4||u==0):a=(t<4&&u+1==i||t>3&&u+1==i/2)&&(r[s+1]/i/100|0)==ln(10,e-2)-1||(u==i/2||u==0)&&(r[s+1]/i/100|0)==0:e<4?(e==0?u=u/1e3|0:e==1?u=u/100|0:e==2&&(u=u/10|0),a=(n||t<4)&&u==9999||!n&&t>3&&u==4999):a=((n||t<4)&&u+1==i||!n&&t>3&&u+1==i/2)&&(r[s+1]/i/1e3|0)==ln(10,e-3)-1,a}o(U0,"checkRoundingDigits");function rE(r,e,t){for(var n,s=[0],i,a=0,u=r.length;a<u;){for(i=s.length;i--;)s[i]*=e;for(s[0]+=BC.indexOf(r.charAt(a++)),n=0;n<s.length;n++)s[n]>t-1&&(s[n+1]===void 0&&(s[n+1]=0),s[n+1]+=s[n]/t|0,s[n]%=t)}return s.reverse()}o(rE,"convertBase");function KX(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/cE(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=Dh(r,1,e.times(s),new r(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return r.precision-=t,e}o(KX,"cosine");var Er=(function(){function r(n,s,i){var a,u=0,c=n.length;for(n=n.slice();c--;)a=n[c]*s+u,n[c]=a%i|0,u=a/i|0;return u&&n.unshift(u),n}o(r,"multiplyInteger");function e(n,s,i,a){var u,c;if(i!=a)c=i>a?1:-1;else for(u=c=0;u<i;u++)if(n[u]!=s[u]){c=n[u]>s[u]?1:-1;break}return c}o(e,"compare");function t(n,s,i,a){for(var u=0;i--;)n[i]-=u,u=n[i]<s[i]?1:0,n[i]=u*a+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return o(t,"subtract"),function(n,s,i,a,u,c){var l,f,h,d,m,g,x,y,v,b,E,w,S,A,V,I,D,O,U,j,ae=n.constructor,Z=n.s==s.s?1:-1,se=n.d,G=s.d;if(!se||!se[0]||!G||!G[0])return new ae(!n.s||!s.s||(se?G&&se[0]==G[0]:!G)?NaN:se&&se[0]==0||!G?Z*0:Z/0);for(c?(m=1,f=n.e-s.e):(c=Di,m=ft,f=$n(n.e/m)-$n(s.e/m)),U=G.length,D=se.length,v=new ae(Z),b=v.d=[],h=0;G[h]==(se[h]||0);h++);if(G[h]>(se[h]||0)&&f--,i==null?(A=i=ae.precision,a=ae.rounding):u?A=i+(n.e-s.e)+1:A=i,A<0)b.push(1),g=!0;else{if(A=A/m+2|0,h=0,U==1){for(d=0,G=G[0],A++;(h<D||d)&&A--;h++)V=d*c+(se[h]||0),b[h]=V/G|0,d=V%G|0;g=d||h<D}else{for(d=c/(G[0]+1)|0,d>1&&(G=r(G,d,c),se=r(se,d,c),U=G.length,D=se.length),I=U,E=se.slice(0,U),w=E.length;w<U;)E[w++]=0;j=G.slice(),j.unshift(0),O=G[0],G[1]>=c/2&&++O;do d=0,l=e(G,E,U,w),l<0?(S=E[0],U!=w&&(S=S*c+(E[1]||0)),d=S/O|0,d>1?(d>=c&&(d=c-1),x=r(G,d,c),y=x.length,w=E.length,l=e(x,E,y,w),l==1&&(d--,t(x,U<y?j:G,y,c))):(d==0&&(l=d=1),x=G.slice()),y=x.length,y<w&&x.unshift(0),t(E,x,w,c),l==-1&&(w=E.length,l=e(G,E,U,w),l<1&&(d++,t(E,U<w?j:G,w,c))),w=E.length):l===0&&(d++,E=[0]),b[h++]=d,l&&E[0]?E[w++]=se[I]||0:(E=[se[I]],w=1);while((I++<D||E[0]!==void 0)&&A--);g=E[0]!==void 0}b[0]||b.shift()}if(m==1)v.e=f,zP=g;else{for(h=1,d=b[0];d>=10;d/=10)h++;v.e=h+f*m-1,at(v,u?i+v.e+1:i,a,g)}return v}})();function at(r,e,t,n){var s,i,a,u,c,l,f,h,d,m=r.constructor;e:if(e!=null){if(h=r.d,!h)return r;for(s=1,u=h[0];u>=10;u/=10)s++;if(i=e-s,i<0)i+=ft,a=e,f=h[d=0],c=f/ln(10,s-a-1)%10|0;else if(d=Math.ceil((i+1)/ft),u=h.length,d>=u)if(n){for(;u++<=d;)h.push(0);f=c=0,s=1,i%=ft,a=i-ft+1}else break e;else{for(f=u=h[d],s=1;u>=10;u/=10)s++;i%=ft,a=i-ft+s,c=a<0?0:f/ln(10,s-a-1)%10|0}if(n=n||e<0||h[d+1]!==void 0||(a<0?f:f%ln(10,s-a-1)),l=t<4?(c||n)&&(t==0||t==(r.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(i>0?a>0?f/ln(10,s-a):0:h[d-1])%10&1||t==(r.s<0?8:7)),e<1||!h[0])return h.length=0,l?(e-=r.e+1,h[0]=ln(10,(ft-e%ft)%ft),r.e=-e||0):h[0]=r.e=0,r;if(i==0?(h.length=d,u=1,d--):(h.length=d+1,u=ln(10,ft-i),h[d]=a>0?(f/ln(10,s-a)%ln(10,a)|0)*u:0),l)for(;;)if(d==0){for(i=1,a=h[0];a>=10;a/=10)i++;for(a=h[0]+=u,u=1;a>=10;a/=10)u++;i!=u&&(r.e++,h[0]==Di&&(h[0]=1));break}else{if(h[d]+=u,h[d]!=Di)break;h[d--]=0,u=1}for(i=h.length;h[--i]===0;)h.pop()}return xt&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}o(at,"finalise");function Zi(r,e,t){if(!r.isFinite())return r3(r);var n,s=r.e,i=On(r.d),a=i.length;return e?(t&&(n=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+Yo(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+Yo(-s-1)+i,t&&(n=t-a)>0&&(i+=Yo(n))):s>=a?(i+=Yo(s+1-a),t&&(n=t-s-1)>0&&(i=i+"."+Yo(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-a)>0&&(s+1===a&&(i+="."),i+=Yo(n))),i}o(Zi,"finiteToString");function uE(r,e){var t=r[0];for(e*=ft;t>=10;t/=10)e++;return e}o(uE,"getBase10Exponent");function aE(r,e,t){if(e>HX)throw xt=!0,t&&(r.precision=t),Error(WP);return at(new r(sE),e,1,!0)}o(aE,"getLn10");function Qi(r,e,t){if(e>PC)throw Error(WP);return at(new r(iE),e,t,!0)}o(Qi,"getPi");function ZP(r){var e=r.length-1,t=e*ft+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}o(ZP,"getPrecision");function Yo(r){for(var e="";r--;)e+="0";return e}o(Yo,"getZeroString");function e3(r,e,t,n){var s,i=new r(1),a=Math.ceil(n/ft+4);for(xt=!1;;){if(t%2&&(i=i.times(e),XP(i.d,a)&&(s=!0)),t=$n(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),XP(e.d,a)}return xt=!0,i}o(e3,"intPow");function $P(r){return r.d[r.d.length-1]&1}o($P,"isOdd");function t3(r,e,t){for(var n,s,i=new r(e[0]),a=0;++a<e.length;){if(s=new r(e[a]),!s.s){i=s;break}n=i.cmp(s),(n===t||n===0&&i.s===t)&&(i=s)}return i}o(t3,"maxOrMin");function kC(r,e){var t,n,s,i,a,u,c,l=0,f=0,h=0,d=r.constructor,m=d.rounding,g=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(xt=!1,c=g):c=e,u=new d(.03125);r.e>-2;)r=r.times(u),h+=5;for(n=Math.log(ln(2,h))/Math.LN10*2+5|0,c+=n,t=i=a=new d(1),d.precision=c;;){if(i=at(i.times(r),c,1),t=t.times(++f),u=a.plus(Er(i,t,c,1)),On(u.d).slice(0,c)===On(a.d).slice(0,c)){for(s=h;s--;)a=at(a.times(a),c,1);if(e==null)if(l<3&&U0(a.d,c-n,m,l))d.precision=c+=10,t=i=u=new d(1),f=0,l++;else return at(a,d.precision=g,m,xt=!0);else return d.precision=g,a}a=u}}o(kC,"naturalExponential");function Qo(r,e){var t,n,s,i,a,u,c,l,f,h,d,m=1,g=10,x=r,y=x.d,v=x.constructor,b=v.rounding,E=v.precision;if(x.s<0||!y||!y[0]||!x.e&&y[0]==1&&y.length==1)return new v(y&&!y[0]?-1/0:x.s!=1?NaN:y?0:x);if(e==null?(xt=!1,f=E):f=e,v.precision=f+=g,t=On(y),n=t.charAt(0),Math.abs(i=x.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)x=x.times(r),t=On(x.d),n=t.charAt(0),m++;i=x.e,n>1?(x=new v("0."+t),i++):x=new v(n+"."+t.slice(1))}else return l=aE(v,f+2,E).times(i+""),x=Qo(new v(n+"."+t.slice(1)),f-g).plus(l),v.precision=E,e==null?at(x,E,b,xt=!0):x;for(h=x,c=a=x=Er(x.minus(1),x.plus(1),f,1),d=at(x.times(x),f,1),s=3;;){if(a=at(a.times(d),f,1),l=c.plus(Er(a,new v(s),f,1)),On(l.d).slice(0,f)===On(c.d).slice(0,f))if(c=c.times(2),i!==0&&(c=c.plus(aE(v,f+2,E).times(i+""))),c=Er(c,new v(m),f,1),e==null)if(U0(c.d,f-g,b,u))v.precision=f+=g,l=a=x=Er(h.minus(1),h.plus(1),f,1),d=at(x.times(x),f,1),s=u=1;else return at(c,v.precision=E,b,xt=!0);else return v.precision=E,c;c=l,s+=2}}o(Qo,"naturalLogarithm");function r3(r){return String(r.s*r.s/0)}o(r3,"nonFiniteToString");function nE(r,e){var t,n,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(n,s),e){if(s-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%ft,t<0&&(n+=ft),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=ft;n<s;)r.d.push(+e.slice(n,n+=ft));e=e.slice(n),n=ft-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),xt&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}o(nE,"parseDecimal");function $X(r,e){var t,n,s,i,a,u,c,l,f;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),QP.test(e))return nE(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(MX.test(e))t=16,e=e.toLowerCase();else if(VX.test(e))t=2;else if(jX.test(e))t=8;else throw Error(Zo+e);for(i=e.search(/p/i),i>0?(c=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,n=r.constructor,a&&(e=e.replace(".",""),u=e.length,i=u-i,s=e3(n,new n(t),i,i*2)),l=rE(e,t,Di),f=l.length-1,i=f;l[i]===0;--i)l.pop();return i<0?new n(r.s*0):(r.e=uE(l,f),r.d=l,xt=!1,a&&(r=Er(r,s,u*4)),c&&(r=r.times(Math.abs(c)<54?ln(2,c):_h.pow(2,c))),xt=!0,r)}o($X,"parseOther");function XX(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Dh(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/cE(5,t)),e=Dh(r,2,e,e);for(var s,i=new r(5),a=new r(16),u=new r(20);t--;)s=e.times(e),e=e.times(i.plus(s.times(a.times(s).minus(u))));return e}o(XX,"sine");function Dh(r,e,t,n,s){var i,a,u,c,l=1,f=r.precision,h=Math.ceil(f/ft);for(xt=!1,c=t.times(t),u=new r(n);;){if(a=Er(u.times(c),new r(e++*e++),f,1),u=s?n.plus(a):n.minus(a),n=Er(a.times(c),new r(e++*e++),f,1),a=u.plus(n),a.d[h]!==void 0){for(i=h;a.d[i]===u.d[i]&&i--;);if(i==-1)break}i=u,u=n,n=a,a=i,l++}return xt=!0,a.d.length=h+1,a}o(Dh,"taylorSeries");function cE(r,e){for(var t=r;--e;)t*=r;return t}o(cE,"tinyPow");function n3(r,e){var t,n=e.s<0,s=Qi(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return Ka=n?4:1,e;if(t=e.divToInt(s),t.isZero())Ka=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return Ka=$P(t)?n?2:3:n?4:1,e;Ka=$P(t)?n?1:4:n?3:2}return e.minus(s).abs()}o(n3,"toLessThanHalfPi");function LC(r,e,t,n){var s,i,a,u,c,l,f,h,d,m=r.constructor,g=t!==void 0;if(g?(ps(t,1,eu),n===void 0?n=m.rounding:ps(n,0,8)):(t=m.precision,n=m.rounding),!r.isFinite())f=r3(r);else{for(f=Zi(r),a=f.indexOf("."),g?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(f=f.replace(".",""),d=new m(1),d.e=f.length-a,d.d=rE(Zi(d),10,s),d.e=d.d.length),h=rE(f,10,s),i=c=h.length;h[--c]==0;)h.pop();if(!h[0])f=g?"0p+0":"0";else{if(a<0?i--:(r=new m(r),r.d=h,r.e=i,r=Er(r,d,t,n,0,s),h=r.d,i=r.e,l=zP),a=h[t],u=s/2,l=l||h[t+1]!==void 0,l=n<4?(a!==void 0||l)&&(n===0||n===(r.s<0?3:2)):a>u||a===u&&(n===4||l||n===6&&h[t-1]&1||n===(r.s<0?8:7)),h.length=t,l)for(;++h[--t]>s-1;)h[t]=0,t||(++i,h.unshift(1));for(c=h.length;!h[c-1];--c);for(a=0,f="";a<c;a++)f+=BC.charAt(h[a]);if(g){if(c>1)if(e==16||e==8){for(a=e==16?4:3,--c;c%a;c++)f+="0";for(h=rE(f,s,e),c=h.length;!h[c-1];--c);for(a=1,f="1.";a<c;a++)f+=BC.charAt(h[a])}else f=f.charAt(0)+"."+f.slice(1);f=f+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)f="0"+f;f="0."+f}else if(++i>c)for(i-=c;i--;)f+="0";else i<c&&(f=f.slice(0,i)+"."+f.slice(i))}f=(e==16?"0x":e==2?"0b":e==8?"0o":"")+f}return r.s<0?"-"+f:f}o(LC,"toStringBinary");function XP(r,e){if(r.length>e)return r.length=e,!0}o(XP,"truncate");function GX(r){return new this(r).abs()}o(GX,"abs");function zX(r){return new this(r).acos()}o(zX,"acos");function WX(r){return new this(r).acosh()}o(WX,"acosh");function JX(r,e){return new this(r).plus(e)}o(JX,"add");function YX(r){return new this(r).asin()}o(YX,"asin");function QX(r){return new this(r).asinh()}o(QX,"asinh");function ZX(r){return new this(r).atan()}o(ZX,"atan");function eG(r){return new this(r).atanh()}o(eG,"atanh");function tG(r,e){r=new this(r),e=new this(e);var t,n=this.precision,s=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=Qi(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?Qi(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=Qi(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(Er(r,e,i,1)),e=Qi(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(Er(r,e,i,1)),t}o(tG,"atan2");function rG(r){return new this(r).cbrt()}o(rG,"cbrt");function nG(r){return at(r=new this(r),r.e+1,2)}o(nG,"ceil");function sG(r,e,t){return new this(r).clamp(e,t)}o(sG,"clamp");function iG(r){if(!r||typeof r!="object")throw Error(oE+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,eu,"rounding",0,8,"toExpNeg",-Ih,0,"toExpPos",0,Ih,"maxE",0,Ih,"minE",-Ih,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=OC[t]),(n=r[t])!==void 0)if($n(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(Zo+t+": "+n);if(t="crypto",s&&(this[t]=OC[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(JP);else this[t]=!1;else throw Error(Zo+t+": "+n);return this}o(iG,"config");function aG(r){return new this(r).cos()}o(aG,"cos");function oG(r){return new this(r).cosh()}o(oG,"cosh");function s3(r){var e,t,n;function s(i){var a,u,c,l=this;if(!(l instanceof s))return new s(i);if(l.constructor=s,GP(i)){l.s=i.s,xt?!i.d||i.e>s.maxE?(l.e=NaN,l.d=null):i.e<s.minE?(l.e=0,l.d=[0]):(l.e=i.e,l.d=i.d.slice()):(l.e=i.e,l.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){l.s=1/i<0?-1:1,l.e=0,l.d=[0];return}if(i<0?(i=-i,l.s=-1):l.s=1,i===~~i&&i<1e7){for(a=0,u=i;u>=10;u/=10)a++;xt?a>s.maxE?(l.e=NaN,l.d=null):a<s.minE?(l.e=0,l.d=[0]):(l.e=a,l.d=[i]):(l.e=a,l.d=[i]);return}if(i*0!==0){i||(l.s=NaN),l.e=NaN,l.d=null;return}return nE(l,i.toString())}if(c==="string")return(u=i.charCodeAt(0))===45?(i=i.slice(1),l.s=-1):(u===43&&(i=i.slice(1)),l.s=1),QP.test(i)?nE(l,i):$X(l,i);if(c==="bigint")return i<0?(i=-i,l.s=-1):l.s=1,nE(l,i.toString());throw Error(Zo+i)}if(o(s,"Decimal"),s.prototype=Ie,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=iG,s.clone=s3,s.isDecimal=GP,s.abs=GX,s.acos=zX,s.acosh=WX,s.add=JX,s.asin=YX,s.asinh=QX,s.atan=ZX,s.atanh=eG,s.atan2=tG,s.cbrt=rG,s.ceil=nG,s.clamp=sG,s.cos=aG,s.cosh=oG,s.div=uG,s.exp=cG,s.floor=lG,s.hypot=fG,s.ln=hG,s.log=pG,s.log10=mG,s.log2=dG,s.max=gG,s.min=yG,s.mod=vG,s.mul=xG,s.pow=EG,s.random=wG,s.round=bG,s.sign=SG,s.sin=AG,s.sinh=CG,s.sqrt=NG,s.sub=TG,s.sum=IG,s.tan=DG,s.tanh=_G,s.trunc=RG,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return s.config(r),s}o(s3,"clone");function uG(r,e){return new this(r).div(e)}o(uG,"div");function cG(r){return new this(r).exp()}o(cG,"exp");function lG(r){return at(r=new this(r),r.e+1,3)}o(lG,"floor");function fG(){var r,e,t=new this(0);for(xt=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return xt=!0,new this(1/0);t=e}return xt=!0,t.sqrt()}o(fG,"hypot");function GP(r){return r instanceof _h||r&&r.toStringTag===YP||!1}o(GP,"isDecimalInstance");function hG(r){return new this(r).ln()}o(hG,"ln");function pG(r,e){return new this(r).log(e)}o(pG,"log");function dG(r){return new this(r).log(2)}o(dG,"log2");function mG(r){return new this(r).log(10)}o(mG,"log10");function gG(){return t3(this,arguments,-1)}o(gG,"max");function yG(){return t3(this,arguments,1)}o(yG,"min");function vG(r,e){return new this(r).mod(e)}o(vG,"mod");function xG(r,e){return new this(r).mul(e)}o(xG,"mul");function EG(r,e){return new this(r).pow(e)}o(EG,"pow");function wG(r){var e,t,n,s,i=0,a=new this(1),u=[];if(r===void 0?r=this.precision:ps(r,1,eu),n=Math.ceil(r/ft),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)s=e[i],s>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:u[i++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)s=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,i):(u.push(s%1e7),i+=4);i=n/4}else throw Error(JP);else for(;i<n;)u[i++]=Math.random()*1e7|0;for(n=u[--i],r%=ft,n&&r&&(s=ln(10,ft-r),u[i]=(n/s|0)*s);u[i]===0;i--)u.pop();if(i<0)t=0,u=[0];else{for(t=-1;u[0]===0;t-=ft)u.shift();for(n=1,s=u[0];s>=10;s/=10)n++;n<ft&&(t-=ft-n)}return a.e=t,a.d=u,a}o(wG,"random");function bG(r){return at(r=new this(r),r.e+1,this.rounding)}o(bG,"round");function SG(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}o(SG,"sign");function AG(r){return new this(r).sin()}o(AG,"sin");function CG(r){return new this(r).sinh()}o(CG,"sinh");function NG(r){return new this(r).sqrt()}o(NG,"sqrt");function TG(r,e){return new this(r).sub(e)}o(TG,"sub");function IG(){var r=0,e=arguments,t=new this(e[r]);for(xt=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return xt=!0,at(t,this.precision,this.rounding)}o(IG,"sum");function DG(r){return new this(r).tan()}o(DG,"tan");function _G(r){return new this(r).tanh()}o(_G,"tanh");function RG(r){return at(r=new this(r),r.e+1,1)}o(RG,"trunc");Ie[Symbol.for("nodejs.util.inspect.custom")]=Ie.toString;Ie[Symbol.toStringTag]="Decimal";var _h=Ie.constructor=s3(OC);sE=new _h(sE);iE=new _h(iE);var Zc=class r extends _h{static{o(this,"Decimal")}static from(e){return new r(e)}static newOrZero(e){return e===void 0?r.from(0):r.from(e)}static newOrUndefined(e){if(e!==void 0)return r.from(e)}};var i3=Lt(require("pdfkit"),1);var FC=class r{static{o(this,"PdfkitPdfBuilder")}defaults={autoFirstPage:!1};doc=new i3.default(this.defaults);constructor(e){e&&this.configure(e)}static new(e){return new r(e)}configure(e){return this.doc.options={...this.doc.options,...e},this}pipe(e){return this.doc.pipe(e),this}end(){return this.doc.end()}restore(){return this.doc.restore(),this}save(){return this.doc.save(),this}stroke(e){return this.doc.stroke(e),this}page(e){return this.doc.addPage(e),this}table(e){return this.doc.table(e),this}text(e,t){let{x:n,y:s,...i}=t??{};return n||s?(this.doc.text(e,n,s,i),this):(this.doc.text(e,t),this)}fontSize(e){return this.doc.fontSize(e),this}font(e,t,n){return typeof t=="string"?(this.doc.font(e,t,n),this):typeof t=="number"?(this.doc.font(e,t),this):(this.doc.font(e),this)}image(e,t,n,s){return typeof t=="number"&&typeof n=="number"?(this.doc.image(e,t,n,s),this):(this.doc.image(e,t),this)}rect(e,t,n,s){return this.doc.rect(e,t,n,s),this}roundedRect(e,t,n,s,i){return this.doc.roundedRect(e,t,n,s,i),this}path(e){return this.doc.path(e),this}translate(e,t){return this.doc.translate(e,t),this}scale(e,t){return this.doc.scale(e,t),this}rotate(e,t){return this.doc.rotate(e,t),this}moveTo(e,t){return this.doc.moveTo(e,t),this}lineTo(e,t){return this.doc.lineTo(e,t),this}lineWidth(e){return this.doc.lineWidth(e),this}dash(e,t){return this.doc.dash(e,t),this}undash(){return this.doc.undash(),this}fillColor(e,t){return this.doc.fillColor(e,t),this}strokeColor(e,t){return this.doc.strokeColor(e,t),this}fill(e,t){return this.doc.fill(e,t),this}pageWidth(){return this.doc.page.width}pageHeight(){return this.doc.page.height}heightOfString(e,t){return this.doc.heightOfString(e,t)}widthOfString(e,t){return this.doc.widthOfString(e,t)}pageMargins(){return this.doc.page.margins}currentLineHeight(e){return this.doc.currentLineHeight(e)}x(){return this.doc.x}y(){return this.doc.y}moveDown(e){return this.doc.moveDown(e),this}row(e,...t){let n,s;typeof e=="function"?(n={},s=[e,...t]):(n=e??{},s=t),n.columns??=1;let i=this.y(),a=n.right??0,u=n.left??0,c=n.gap??0,l=this.pageWidth(),f=l-u-a-c*(n.columns-1);n.size??=Array(n.columns).fill(12/n.columns);let h=[];for(let d=0;d<n.columns;d++){let m=n.size[d]/12;h[d]=f*m}for(let d=0,m=u;d<n.columns;d++){let g=d===n.columns-1,x=h[d];if(g&&n.columns>1){let b=l-a-m;b>0&&Math.abs(b-x)>.01&&(x=b)}let y={y:i,x:m,width:x};s[d](y),m+=x,c>0&&!g&&(m+=c)}return this}};var UC=class{static{o(this,"MemoryCacheAdapter")}cache=new Map;async get(e){return Promise.resolve(this.cache.get(e)??null)}has(e){return Promise.resolve(this.cache.has(e))}set(e,t){return this.cache.set(e,t),Promise.resolve(!0)}};var N4=Lt(require("os"),1),$N=Lt(require("fs"),1),T4=Lt(require("path"),1),zh=Lt(require("crypto"),1),hu=Lt(w4(),1);var gY=o(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessageInRecord"),gs=o(r=>typeof r=="string"?rr(new Xt(r)):r instanceof Error?rr(new Xt(r.message,{cause:r.cause})):gY(r)?rr(new Xt(r.message)):rr(new Xt("unexpected error")),"leftFromError");var tg=class{static{o(this,"NullCacheAdapter")}async get(e){return Promise.resolve(null)}has(e){return Promise.resolve(!1)}set(e,t){return Promise.resolve(!0)}};var rg=require("os"),la=require("path");var qN=require("path"),jN=require("module"),qE=require("url");var yY=typeof jest<"u"||process.env.JEST_WORKER_ID!==void 0,Xh,b4=o(()=>{if(Xh!==void 0)return Xh;if(yY){Xh=void 0;return}try{Xh=new Function("try { return import.meta.url; } catch { return undefined; }")()}catch{Xh=void 0}return Xh},"getImportMetaUrl"),S4=o(()=>{if(typeof require<"u")return require;let r=b4();if(r)return(0,jN.createRequire)(r);let e=(0,qE.pathToFileURL)((0,qN.resolve)(process.cwd(),"package.json")).href;return(0,jN.createRequire)(e)},"getRequireFn"),A4=o(()=>{if(typeof __filename<"u")return __filename;let r=b4();return r?(0,qE.fileURLToPath)(r):(0,qN.resolve)(process.cwd())},"getCurrentFile");var Ms=require("path"),cl=require("fs");var C4=o(()=>typeof process<"u"&&typeof process.versions<"u"&&"electron"in process.versions,"isElectron"),vY=o(()=>{if(!C4())return null;try{let e=require("electron").app;if(e?.getAppPath&&typeof e.getAppPath=="function")return{getAppPath:e.getAppPath}}catch{}return null},"getElectronApp"),xY=o(()=>{if(!C4())return null;let r=process;if(r.resourcesPath)return r.resourcesPath;let e=vY();if(e)try{let t=e.getAppPath();if(typeof t=="string")return(0,Ms.dirname)(t.replace(/\.asar$/,""))}catch{}return null},"getElectronResourcesPath"),HE=o((r,{onFound:e,onNotFound:t})=>{let n=xY();if(n){let l=(0,Ms.resolve)(n,"node_modules","nfets",r);if((0,cl.existsSync)(l))return e(l);let f=(0,Ms.resolve)(n,"app.asar.unpacked","node_modules","nfets",r);if((0,cl.existsSync)(f))return e(f)}let s=A4(),i=s.includes(".asar")?process.cwd():s,a=(0,Ms.resolve)(i,"../../../../"),u=(0,Ms.resolve)(a,r);if((0,cl.existsSync)(u))return e(u);let c=i;for(let l=0;l<5;l++){let f=(0,Ms.resolve)(c,r);if((0,cl.existsSync)(f))return e(f);let h=(0,Ms.dirname)(c);if(h===c)break;c=h}c=i;for(let l=0;l<5;l++){let f=(0,Ms.resolve)(c,"node_modules","nfets",r);if((0,cl.existsSync)(f))return e(f);let h=(0,Ms.dirname)(c);if(h===c)break;c=h}c=i;for(let l=0;l<5;l++){let f=(0,Ms.resolve)(c,r.replace(/^build\//,"Release/"));if((0,cl.existsSync)(f))return e(f);let h=(0,Ms.dirname)(c);if(h===c)break;c=h}return t()},"search");var EY=o(r=>{let e=r.replace(/^\\\\\?\\/,"");return(0,la.resolve)((0,la.normalize)(e))},"normalizePath"),wY=o(r=>{(0,rg.platform)()==="win32"&&(process.env.PATH=`${(0,la.dirname)(r)}${la.delimiter}${process.env.PATH}`)},"addAddonDirToPath"),HN=o(r=>{let e=EY(r);return wY(e),S4()(e)},"exportRequireModule"),Gh=o(r=>{if(r=`${r}.node`,process.env.NFETS_ADDONS_DIR)return HN((0,la.join)(process.env.NFETS_ADDONS_DIR,r));let e=`${(0,rg.platform)()}-${(0,rg.arch)()}`;try{return HE(`build/addons/${e}/${r}`,{onFound:o(t=>HN(t),"onFound"),onNotFound:o(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}catch{return HE(`build/Release/${r}`,{onFound:o(t=>HN(t),"onFound"),onNotFound:o(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}},"addon");var Wa=class{static{o(this,"ASN1")}extractCertificateInfo(e){let n=e.subject.split(`
|
|
94
|
+
@#[line:`+r.lineNumber+",col:"+r.columnNumber+"]"}o(Zge,"_locator");function uX(r,e,t){return typeof r=="string"?r.substr(e,t):r.length>=e+t||e?new java.lang.String(r,e,t)+"":r}o(uX,"_toString");"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){wC.prototype[r]=function(){return null}});function EC(r,e){r.currentElement?r.currentElement.appendChild(e):r.doc.appendChild(e)}o(EC,"appendElement");function eye(r){if(r==="error")throw"onErrorStopParsing"}o(eye,"onErrorStopParsing");function tye(){throw"onWarningStopParsing"}o(tye,"onWarningStopParsing");D0.__DOMHandler=wC;D0.DOMParser=fX;D0.normalizeLineEndings=lX;D0.onErrorStopParsing=eye;D0.onWarningStopParsing=tye});var pX=z(tr=>{"use strict";var _0=Sh();tr.assign=_0.assign;tr.hasDefaultHTMLNamespace=_0.hasDefaultHTMLNamespace;tr.isHTMLMimeType=_0.isHTMLMimeType;tr.isValidMimeType=_0.isValidMimeType;tr.MIME_TYPE=_0.MIME_TYPE;tr.NAMESPACE=_0.NAMESPACE;var bC=Fx();tr.DOMException=bC.DOMException;tr.DOMExceptionName=bC.DOMExceptionName;tr.ExceptionCode=bC.ExceptionCode;tr.ParseError=bC.ParseError;var yn=iP();tr.Attr=yn.Attr;tr.CDATASection=yn.CDATASection;tr.CharacterData=yn.CharacterData;tr.Comment=yn.Comment;tr.Document=yn.Document;tr.DocumentFragment=yn.DocumentFragment;tr.DocumentType=yn.DocumentType;tr.DOMImplementation=yn.DOMImplementation;tr.Element=yn.Element;tr.Entity=yn.Entity;tr.EntityReference=yn.EntityReference;tr.LiveNodeList=yn.LiveNodeList;tr.NamedNodeMap=yn.NamedNodeMap;tr.Node=yn.Node;tr.NodeList=yn.NodeList;tr.Notation=yn.Notation;tr.ProcessingInstruction=yn.ProcessingInstruction;tr.Text=yn.Text;tr.XMLSerializer=yn.XMLSerializer;var SC=hX();tr.DOMParser=SC.DOMParser;tr.normalizeLineEndings=SC.normalizeLineEndings;tr.onErrorStopParsing=SC.onErrorStopParsing;tr.onWarningStopParsing=SC.onWarningStopParsing});var oye={};Jx(oye,{ASN1:()=>Wa,CanonicalizationMethod:()=>CC,Choice:()=>nye,Decimal:()=>Zc,DigestAlgorithm:()=>Zx,EntitySigner:()=>TC,Environment:()=>kX,IsDecimal:()=>cP,Left:()=>tE,MemoryCacheAdapter:()=>UC,NFeTsError:()=>Xt,NativeCertificateRepository:()=>XN,NullCacheAdapter:()=>tg,Once:()=>sye,PdfkitPdfBuilder:()=>FC,Right:()=>L0,SignatureAlgorithm:()=>Ha,SignatureMethod:()=>Qx,SignatureNamespace:()=>Yx,Signer:()=>Qc,SkipAllValidations:()=>FX,SkipValidation:()=>LX,SkipValidationMetadata:()=>Th,SoapRemoteTransmissionRepository:()=>Y_,StateAcronyms:()=>PX,StateCodeAcValidator:()=>fP,StateCodeAlValidator:()=>hP,StateCodeAmValidator:()=>pP,StateCodeApValidator:()=>dP,StateCodeBaValidator:()=>mP,StateCodeCeValidator:()=>gP,StateCodeDfValidator:()=>yP,StateCodeEsValidator:()=>vP,StateCodeGoValidator:()=>xP,StateCodeMaValidator:()=>EP,StateCodeMgValidator:()=>wP,StateCodeMsValidator:()=>bP,StateCodeMtValidator:()=>SP,StateCodePaValidator:()=>AP,StateCodePbValidator:()=>CP,StateCodePeValidator:()=>NP,StateCodePiValidator:()=>TP,StateCodePrValidator:()=>IP,StateCodeRjValidator:()=>DP,StateCodeRnValidator:()=>_P,StateCodeRoValidator:()=>RP,StateCodeRrValidator:()=>BP,StateCodeRsValidator:()=>OP,StateCodeScValidator:()=>PP,StateCodeSeValidator:()=>kP,StateCodeSpValidator:()=>LP,StateCodeToValidator:()=>FP,StateCodes:()=>lr,TransformDateString:()=>aye,TransformDecimal:()=>iye,TransmissionError:()=>P0,TransmissionHostNotFoundError:()=>Wo,TransmissionTimeoutError:()=>Jo,ValidateErrorsMetadata:()=>_C,Validates:()=>UX,ValidationError:()=>NC,Xml2JsToolkit:()=>uP,XmlSigner:()=>IC,clearEmptyValues:()=>F0,dateToolkit:()=>ll,fixUtf8Mojibake:()=>z9,left:()=>rr,leftFromError:()=>gs,leftFromTransmissionError:()=>z_,mapConstraintsToErrors:()=>RC,mapTransmissionError:()=>G9,normalizeTransmissionStrings:()=>J_,plainToInstance:()=>DC,right:()=>sn,search:()=>HE,timezones:()=>qP,unreachable:()=>eE});module.exports=OX(oye);var Yx="http://www.w3.org/2000/09/xmldsig#",CC="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",Qx=(function(r){return r.RSA_SHA1="http://www.w3.org/2000/09/xmldsig#rsa-sha1",r.RSA_SHA256="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",r})({}),Ha=(function(r){return r.SHA1="sha1",r.SHA256="sha256",r})({}),Zx=(function(r){return r.SHA1="http://www.w3.org/2000/09/xmldsig#sha1",r.SHA256="http://www.w3.org/2001/04/xmlenc#sha256",r})({});var lr={AC:"12",AL:"27",AM:"13",AP:"16",BA:"29",CE:"23",DF:"53",ES:"32",GO:"52",MA:"21",MG:"31",MS:"50",MT:"51",PA:"15",PB:"25",PE:"26",PI:"22",PR:"41",RJ:"33",RN:"24",RO:"11",RR:"14",RS:"43",SC:"42",SE:"28",SP:"35",TO:"17"},PX=Object.keys(lr);var kX={Production:"1",Homolog:"2"};var qP={[lr.AC]:"America/Rio_Branco",[lr.AL]:"America/Maceio",[lr.AM]:"America/Manaus",[lr.AP]:"America/Belem",[lr.BA]:"America/Bahia",[lr.CE]:"America/Fortaleza",[lr.DF]:"America/Sao_Paulo",[lr.ES]:"America/Sao_Paulo",[lr.GO]:"America/Sao_Paulo",[lr.MA]:"America/Fortaleza",[lr.MG]:"America/Sao_Paulo",[lr.MS]:"America/Campo_Grande",[lr.MT]:"America/Cuiaba",[lr.PA]:"America/Belem",[lr.PB]:"America/Fortaleza",[lr.PE]:"America/Recife",[lr.PI]:"America/Fortaleza",[lr.PR]:"America/Sao_Paulo",[lr.RJ]:"America/Sao_Paulo",[lr.RN]:"America/Fortaleza",[lr.RO]:"America/Porto_Velho",[lr.RR]:"America/Boa_Vista",[lr.RS]:"America/Sao_Paulo",[lr.SC]:"America/Sao_Paulo",[lr.SE]:"America/Maceio",[lr.SP]:"America/Sao_Paulo",[lr.TO]:"America/Araguaina"};var Xt=class extends Error{static{o(this,"NFeTsError")}};var P0=class extends Xt{static{o(this,"TransmissionError")}},Wo=class extends P0{static{o(this,"TransmissionHostNotFoundError")}},Jo=class extends P0{static{o(this,"TransmissionTimeoutError")}};var NC=class extends Xt{static{o(this,"ValidationError")}};var k0={includeComments:!1,exclusive:!0};var eE=o(r=>{throw new Xt("Didn't expect to get here")},"unreachable");var Qc=class{static{o(this,"Signer")}toolkit;certificateRepository;algorithm;canonical;constructor(e,t,n=Ha.SHA1,s=k0){this.toolkit=e,this.certificateRepository=t,this.algorithm=n,this.canonical=s}assemble(e,t,n){let s=this.certificateRepository.getStringCertificate(n);return{$:{xmlns:Yx},SignedInfo:e,SignatureValue:t,KeyInfo:{X509Data:{X509Certificate:s}}}}signedInfo(e,t){return{CanonicalizationMethod:{$:{Algorithm:CC}},SignatureMethod:{$:{Algorithm:this.signatureMethod}},Reference:{$:{URI:`#${this.toolkit.getAttribute(e,t)}`},Transforms:this.transforms,DigestMethod:{$:{Algorithm:this.digestAlgorithm}},DigestValue:this.digest(e)}}}digest(e){return this.toolkit.digest(e,this.algorithm,this.canonical)}async signOrLeft(e,t){let n=this.toolkit.canonicalize(await this.toolkit.build({$:{xmlns:Yx},...e},{rootName:"SignedInfo"}),this.canonical);return this.certificateRepository.sign(n,t,this.algorithm)}get transforms(){return{Transform:[{$:{Algorithm:"http://www.w3.org/2000/09/xmldsig#enveloped-signature"}},{$:{Algorithm:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"}}]}}get digestAlgorithm(){switch(this.algorithm){case Ha.SHA256:return Zx.SHA256;case Ha.SHA1:return Zx.SHA1;default:return eE(this.algorithm)}}get signatureMethod(){switch(this.algorithm){case Ha.SHA256:return Qx.RSA_SHA256;case Ha.SHA1:return Qx.RSA_SHA1;default:return eE(this.algorithm)}}};var tE=class{static{o(this,"Left")}value;constructor(e){this.value=e}isLeft(){return!0}isRight(){return!1}},L0=class{static{o(this,"Right")}value;constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}},rr=o(r=>new tE(r),"left"),sn=o(r=>r===void 0?new L0(void 0):new L0(r),"right");var TC=class extends Qc{static{o(this,"EntitySigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n;if(!e[s])return rr(new Xt(`Node ${String(s)} not found`));let u=await this.toolkit.build(this.ns(e,s),{headless:!0,rootName:String(s),renderOpts:{pretty:!1}}),c=this.signedInfo(u,i),l=await this.signOrLeft(c,n);if(l.isLeft())return l;let f=e;return f.Signature=this.assemble(c,l.value,a),sn(f)}ns(e,t){let n=e.$?.xmlns,{$:s,...i}=e[t],{xmlns:a,...u}=s??{};return{$:{xmlns:n,...u},...i}}};var IC=class extends Qc{static{o(this,"XmlSigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n,u=this.toolkit.getNode(e,s);if(!u)return rr(new Xt(`Node ${s} not found`));let c=this.signedInfo(u,i),l=await this.signOrLeft(c,n);if(l.isLeft())return l;let f=await this.toolkit.build(this.assemble(c,l.value,a),{rootName:"Signature"});return sn(this.toolkit.appendNode(e,f))}};var l1e=require("reflect-metadata"),KP=require("class-validator");var i1e=require("reflect-metadata");var Th="__SkipValidation__",LX=o(()=>(r,e)=>{Reflect.defineMetadata(Th,!0,r,e.toString())},"SkipValidation"),FX=o(()=>r=>{Reflect.defineMetadata(Th,!0,r)},"SkipAllValidations");var HP=require("class-transformer");var F0=o(r=>{for(let[e,t]of Object.entries(r))typeof t>"u"&&delete r[e],t===""&&delete r[e],t&&typeof t=="object"&&F0(t)},"clearEmptyValues"),DC=o((r,e,t={})=>{let n=(0,HP.plainToInstance)(e,r);return t.clearEmptyValues&&F0(n),n},"plainToInstance");var _C="__ValidateErrors__",RC=o((r,e)=>r.reduce((t,n)=>{if(n.children?.length)return t.concat(RC(n.children,e?`${e}.${n.property}`:n.property));let s=Object.values(n.constraints??{}).map(i=>e?`${e}.${i}`:i).join(", ");return s?t.concat(s):t},[]),"mapConstraintsToErrors"),UX=o((r,e)=>(t,n,s)=>{let i=s.value;if(i==null)return;let a=o((u,c,l)=>{let f=DC(c,r),h=(0,KP.validateSync)(f,{whitelist:!0});if(F0(f),h.length){let d=Reflect.getMetadata(_C,u)??[];Reflect.defineMetadata(_C,d.concat(RC(h,l)),u)}return f},"validate");s.value=function(...u){let c=Reflect.getMetadata(Th,this.constructor);if(Reflect.getMetadata(Th,this.constructor.prototype,n.toString())===!0||c===!0)return i.apply(this,u);let[f,...h]=u;if(!f)return i.apply(this,u);let d=e?.each&&Array.isArray(f)?f.map((m,g)=>a(this,m,`${i.name}.${g}`)):a(this,f,i.name);return i.apply(this,[d,...h])}},"Validates");var yFe=require("reflect-metadata");var Ih=9e15,eu=1e9,BC="0123456789abcdef",sE="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",iE="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",OC={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Ih,maxE:Ih,crypto:!1},zP,Ka,xt=!0,oE="[DecimalError] ",Zo=oE+"Invalid argument: ",WP=oE+"Precision limit exceeded",JP=oE+"crypto unavailable",YP="[object Decimal]",$n=Math.floor,ln=Math.pow,VX=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,MX=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,jX=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,QP=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Di=1e7,ft=7,qX=9007199254740991,HX=sE.length-1,PC=iE.length-1,Ie={toStringTag:YP};Ie.absoluteValue=Ie.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),at(r)};Ie.ceil=function(){return at(new this.constructor(this),this.e+1,2)};Ie.clampedTo=Ie.clamp=function(r,e){var t,n=this,s=n.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(Zo+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};Ie.comparedTo=Ie.cmp=function(r){var e,t,n,s,i=this,a=i.d,u=(r=new i.constructor(r)).d,c=i.s,l=r.s;if(!a||!u)return!c||!l?NaN:c!==l?c:a===u?0:!a^c<0?1:-1;if(!a[0]||!u[0])return a[0]?c:u[0]?-l:0;if(c!==l)return c;if(i.e!==r.e)return i.e>r.e^c<0?1:-1;for(n=a.length,s=u.length,e=0,t=n<s?n:s;e<t;++e)if(a[e]!==u[e])return a[e]>u[e]^c<0?1:-1;return n===s?0:n>s^c<0?1:-1};Ie.cosine=Ie.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+ft,n.rounding=1,t=KX(n,n3(n,t)),n.precision=r,n.rounding=e,at(Ka==2||Ka==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};Ie.cubeRoot=Ie.cbrt=function(){var r,e,t,n,s,i,a,u,c,l,f=this,h=f.constructor;if(!f.isFinite()||f.isZero())return new h(f);for(xt=!1,i=f.s*ln(f.s*f,1/3),!i||Math.abs(i)==1/0?(t=On(f.d),r=f.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=ln(t,1/3),r=$n((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new h(t),n.s=f.s):n=new h(i.toString()),a=(r=h.precision)+3;;)if(u=n,c=u.times(u).times(u),l=c.plus(f),n=Er(l.plus(f).times(u),l.plus(c),a+2,1),On(u.d).slice(0,a)===(t=On(n.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(at(u,r+1,0),u.times(u).times(u).eq(f))){n=u;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(at(n,r+1,1),e=!n.times(n).times(n).eq(f));break}return xt=!0,at(n,r,h.rounding,e)};Ie.decimalPlaces=Ie.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-$n(this.e/ft))*ft,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};Ie.dividedBy=Ie.div=function(r){return Er(this,new this.constructor(r))};Ie.dividedToIntegerBy=Ie.divToInt=function(r){var e=this,t=e.constructor;return at(Er(e,new t(r),0,1,1),t.precision,t.rounding)};Ie.equals=Ie.eq=function(r){return this.cmp(r)===0};Ie.floor=function(){return at(new this.constructor(this),this.e+1,3)};Ie.greaterThan=Ie.gt=function(r){return this.cmp(r)>0};Ie.greaterThanOrEqualTo=Ie.gte=function(r){var e=this.cmp(r);return e==1||e===0};Ie.hyperbolicCosine=Ie.cosh=function(){var r,e,t,n,s,i=this,a=i.constructor,u=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return u;t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,s=i.d.length,s<32?(r=Math.ceil(s/3),e=(1/cE(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=Dh(a,1,i.times(e),new a(1),!0);for(var c,l=r,f=new a(8);l--;)c=i.times(i),i=u.minus(c.times(f.minus(c.times(f))));return at(i,a.precision=t,a.rounding=n,!0)};Ie.hyperbolicSine=Ie.sinh=function(){var r,e,t,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(s.e,s.sd())+4,i.rounding=1,n=s.d.length,n<3)s=Dh(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/cE(5,r)),s=Dh(i,2,s,s,!0);for(var a,u=new i(5),c=new i(16),l=new i(20);r--;)a=s.times(s),s=s.times(u.plus(a.times(c.times(a).plus(l))))}return i.precision=e,i.rounding=t,at(s,e,t,!0)};Ie.hyperbolicTangent=Ie.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,Er(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};Ie.inverseCosine=Ie.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,s=e.rounding;return t!==-1?t===0?r.isNeg()?Qi(e,n,s):new e(0):new e(NaN):r.isZero()?Qi(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=s,r.times(2))};Ie.inverseHyperbolicCosine=Ie.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,xt=!1,t=t.times(t).minus(1).sqrt().plus(t),xt=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};Ie.inverseHyperbolicSine=Ie.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,xt=!1,t=t.times(t).plus(1).sqrt().plus(t),xt=!0,n.precision=r,n.rounding=e,t.ln())};Ie.inverseHyperbolicTangent=Ie.atanh=function(){var r,e,t,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=i.precision,e=i.rounding,n=s.sd(),Math.max(n,r)<2*-s.e-1?at(new i(s),r,e,!0):(i.precision=t=n-s.e,s=Er(s.plus(1),new i(1).minus(s),t+r,1),i.precision=r+4,i.rounding=1,s=s.ln(),i.precision=r,i.rounding=e,s.times(.5))):new i(NaN)};Ie.inverseSine=Ie.asin=function(){var r,e,t,n,s=this,i=s.constructor;return s.isZero()?new i(s):(e=s.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=Qi(i,t+4,n).times(.5),r.s=s.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,s.times(2)))};Ie.inverseTangent=Ie.atan=function(){var r,e,t,n,s,i,a,u,c,l=this,f=l.constructor,h=f.precision,d=f.rounding;if(l.isFinite()){if(l.isZero())return new f(l);if(l.abs().eq(1)&&h+4<=PC)return a=Qi(f,h+4,d).times(.25),a.s=l.s,a}else{if(!l.s)return new f(NaN);if(h+4<=PC)return a=Qi(f,h+4,d).times(.5),a.s=l.s,a}for(f.precision=u=h+10,f.rounding=1,t=Math.min(28,u/ft+2|0),r=t;r;--r)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(xt=!1,e=Math.ceil(u/ft),n=1,c=l.times(l),a=new f(l),s=l;r!==-1;)if(s=s.times(c),i=a.minus(s.div(n+=2)),s=s.times(c),a=i.plus(s.div(n+=2)),a.d[e]!==void 0)for(r=e;a.d[r]===i.d[r]&&r--;);return t&&(a=a.times(2<<t-1)),xt=!0,at(a,f.precision=h,f.rounding=d,!0)};Ie.isFinite=function(){return!!this.d};Ie.isInteger=Ie.isInt=function(){return!!this.d&&$n(this.e/ft)>this.d.length-2};Ie.isNaN=function(){return!this.s};Ie.isNegative=Ie.isNeg=function(){return this.s<0};Ie.isPositive=Ie.isPos=function(){return this.s>0};Ie.isZero=function(){return!!this.d&&this.d[0]===0};Ie.lessThan=Ie.lt=function(r){return this.cmp(r)<0};Ie.lessThanOrEqualTo=Ie.lte=function(r){return this.cmp(r)<1};Ie.logarithm=Ie.log=function(r){var e,t,n,s,i,a,u,c,l=this,f=l.constructor,h=f.precision,d=f.rounding,m=5;if(r==null)r=new f(10),e=!0;else{if(r=new f(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new f(NaN);e=r.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new f(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(s=t[0];s%10===0;)s/=10;i=s!==1}if(xt=!1,u=h+m,a=Qo(l,u),n=e?aE(f,u+10):Qo(r,u),c=Er(a,n,u,1),U0(c.d,s=h,d))do if(u+=10,a=Qo(l,u),n=e?aE(f,u+10):Qo(r,u),c=Er(a,n,u,1),!i){+On(c.d).slice(s+1,s+15)+1==1e14&&(c=at(c,h+1,0));break}while(U0(c.d,s+=10,d));return xt=!0,at(c,h,d)};Ie.minus=Ie.sub=function(r){var e,t,n,s,i,a,u,c,l,f,h,d,m=this,g=m.constructor;if(r=new g(r),!m.d||!r.d)return!m.s||!r.s?r=new g(NaN):m.d?r.s=-r.s:r=new g(r.d||m.s!==r.s?m:NaN),r;if(m.s!=r.s)return r.s=-r.s,m.plus(r);if(l=m.d,d=r.d,u=g.precision,c=g.rounding,!l[0]||!d[0]){if(d[0])r.s=-r.s;else if(l[0])r=new g(m);else return new g(c===3?-0:0);return xt?at(r,u,c):r}if(t=$n(r.e/ft),f=$n(m.e/ft),l=l.slice(),i=f-t,i){for(h=i<0,h?(e=l,i=-i,a=d.length):(e=d,t=f,a=l.length),n=Math.max(Math.ceil(u/ft),a)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=l.length,a=d.length,h=n<a,h&&(a=n),n=0;n<a;n++)if(l[n]!=d[n]){h=l[n]<d[n];break}i=0}for(h&&(e=l,l=d,d=e,r.s=-r.s),a=l.length,n=d.length-a;n>0;--n)l[a++]=0;for(n=d.length;n>i;){if(l[--n]<d[n]){for(s=n;s&&l[--s]===0;)l[s]=Di-1;--l[s],l[n]+=Di}l[n]-=d[n]}for(;l[--a]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(r.d=l,r.e=uE(l,t),xt?at(r,u,c):r):new g(c===3?-0:0)};Ie.modulo=Ie.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?at(new n(t),n.precision,n.rounding):(xt=!1,n.modulo==9?(e=Er(t,r.abs(),0,3,1),e.s*=r.s):e=Er(t,r,0,n.modulo,1),e=e.times(r),xt=!0,t.minus(e))};Ie.naturalExponential=Ie.exp=function(){return kC(this)};Ie.naturalLogarithm=Ie.ln=function(){return Qo(this)};Ie.negated=Ie.neg=function(){var r=new this.constructor(this);return r.s=-r.s,at(r)};Ie.plus=Ie.add=function(r){var e,t,n,s,i,a,u,c,l,f,h=this,d=h.constructor;if(r=new d(r),!h.d||!r.d)return!h.s||!r.s?r=new d(NaN):h.d||(r=new d(r.d||h.s===r.s?h:NaN)),r;if(h.s!=r.s)return r.s=-r.s,h.minus(r);if(l=h.d,f=r.d,u=d.precision,c=d.rounding,!l[0]||!f[0])return f[0]||(r=new d(h)),xt?at(r,u,c):r;if(i=$n(h.e/ft),n=$n(r.e/ft),l=l.slice(),s=i-n,s){for(s<0?(t=l,s=-s,a=f.length):(t=f,n=i,a=l.length),i=Math.ceil(u/ft),a=i>a?i+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=l.length,s=f.length,a-s<0&&(s=a,t=f,f=l,l=t),e=0;s;)e=(l[--s]=l[s]+f[s]+e)/Di|0,l[s]%=Di;for(e&&(l.unshift(e),++n),a=l.length;l[--a]==0;)l.pop();return r.d=l,r.e=uE(l,n),xt?at(r,u,c):r};Ie.precision=Ie.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(Zo+r);return t.d?(e=ZP(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};Ie.round=function(){var r=this,e=r.constructor;return at(new e(r),r.e+1,e.rounding)};Ie.sine=Ie.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+ft,n.rounding=1,t=XX(n,n3(n,t)),n.precision=r,n.rounding=e,at(Ka>2?t.neg():t,r,e,!0)):new n(NaN)};Ie.squareRoot=Ie.sqrt=function(){var r,e,t,n,s,i,a=this,u=a.d,c=a.e,l=a.s,f=a.constructor;if(l!==1||!u||!u[0])return new f(!l||l<0&&(!u||u[0])?NaN:u?a:1/0);for(xt=!1,l=Math.sqrt(+a),l==0||l==1/0?(e=On(u),(e.length+c)%2==0&&(e+="0"),l=Math.sqrt(e),c=$n((c+1)/2)-(c<0||c%2),l==1/0?e="5e"+c:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),n=new f(e)):n=new f(l.toString()),t=(c=f.precision)+3;;)if(i=n,n=i.plus(Er(a,i,t+2,1)).times(.5),On(i.d).slice(0,t)===(e=On(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(at(i,c+1,0),i.times(i).eq(a))){n=i;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(at(n,c+1,1),r=!n.times(n).eq(a));break}return xt=!0,at(n,c,f.rounding,r)};Ie.tangent=Ie.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=Er(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,at(Ka==2||Ka==4?t.neg():t,r,e,!0)):new n(NaN)};Ie.times=Ie.mul=function(r){var e,t,n,s,i,a,u,c,l,f=this,h=f.constructor,d=f.d,m=(r=new h(r)).d;if(r.s*=f.s,!d||!d[0]||!m||!m[0])return new h(!r.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?r.s/0:r.s*0);for(t=$n(f.e/ft)+$n(r.e/ft),c=d.length,l=m.length,c<l&&(i=d,d=m,m=i,a=c,c=l,l=a),i=[],a=c+l,n=a;n--;)i.push(0);for(n=l;--n>=0;){for(e=0,s=c+n;s>n;)u=i[s]+m[n]*d[s-n-1]+e,i[s--]=u%Di|0,e=u/Di|0;i[s]=(i[s]+e)%Di|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),r.d=i,r.e=uE(i,t),xt?at(r,h.precision,h.rounding):r};Ie.toBinary=function(r,e){return LC(this,2,r,e)};Ie.toDecimalPlaces=Ie.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(ps(r,0,eu),e===void 0?e=n.rounding:ps(e,0,8),at(t,r+t.e+1,e))};Ie.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Zi(n,!0):(ps(r,0,eu),e===void 0?e=s.rounding:ps(e,0,8),n=at(new s(n),r+1,e),t=Zi(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};Ie.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=Zi(s):(ps(r,0,eu),e===void 0?e=i.rounding:ps(e,0,8),n=at(new i(s),r+s.e+1,e),t=Zi(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};Ie.toFraction=function(r){var e,t,n,s,i,a,u,c,l,f,h,d,m=this,g=m.d,x=m.constructor;if(!g)return new x(m);if(l=t=new x(1),n=c=new x(0),e=new x(n),i=e.e=ZP(g)-m.e-1,a=i%ft,e.d[0]=ln(10,a<0?ft+a:a),r==null)r=i>0?e:l;else{if(u=new x(r),!u.isInt()||u.lt(l))throw Error(Zo+u);r=u.gt(e)?i>0?e:l:u}for(xt=!1,u=new x(On(g)),f=x.precision,x.precision=i=g.length*ft*2;h=Er(u,e,0,1,1),s=t.plus(h.times(n)),s.cmp(r)!=1;)t=n,n=s,s=l,l=c.plus(h.times(s)),c=s,s=e,e=u.minus(h.times(s)),u=s;return s=Er(r.minus(t),n,0,1,1),c=c.plus(s.times(l)),t=t.plus(s.times(n)),c.s=l.s=m.s,d=Er(l,n,i,1).minus(m).abs().cmp(Er(c,t,i,1).minus(m).abs())<1?[l,n]:[c,t],x.precision=f,xt=!0,d};Ie.toHexadecimal=Ie.toHex=function(r,e){return LC(this,16,r,e)};Ie.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:ps(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(xt=!1,t=Er(t,r,0,e,1).times(r),xt=!0,at(t)):(r.s=t.s,t=r),t};Ie.toNumber=function(){return+this};Ie.toOctal=function(r,e){return LC(this,8,r,e)};Ie.toPower=Ie.pow=function(r){var e,t,n,s,i,a,u=this,c=u.constructor,l=+(r=new c(r));if(!u.d||!r.d||!u.d[0]||!r.d[0])return new c(ln(+u,l));if(u=new c(u),u.eq(1))return u;if(n=c.precision,i=c.rounding,r.eq(1))return at(u,n,i);if(e=$n(r.e/ft),e>=r.d.length-1&&(t=l<0?-l:l)<=qX)return s=e3(c,u,t,n),r.s<0?new c(1).div(s):at(s,n,i);if(a=u.s,a<0){if(e<r.d.length-1)return new c(NaN);if((r.d[e]&1)==0&&(a=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=a,u}return t=ln(+u,l),e=t==0||!isFinite(t)?$n(l*(Math.log("0."+On(u.d))/Math.LN10+u.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?a/0:0):(xt=!1,c.rounding=u.s=1,t=Math.min(12,(e+"").length),s=kC(r.times(Qo(u,n+t)),n),s.d&&(s=at(s,n+5,1),U0(s.d,n,i)&&(e=n+10,s=at(kC(r.times(Qo(u,e+t)),e),e+5,1),+On(s.d).slice(n+1,n+15)+1==1e14&&(s=at(s,n+1,0)))),s.s=a,xt=!0,c.rounding=i,at(s,n,i))};Ie.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Zi(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(ps(r,1,eu),e===void 0?e=s.rounding:ps(e,0,8),n=at(new s(n),r,e),t=Zi(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};Ie.toSignificantDigits=Ie.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(ps(r,1,eu),e===void 0?e=n.rounding:ps(e,0,8)),at(new n(t),r,e)};Ie.toString=function(){var r=this,e=r.constructor,t=Zi(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};Ie.truncated=Ie.trunc=function(){return at(new this.constructor(this),this.e+1,1)};Ie.valueOf=Ie.toJSON=function(){var r=this,e=r.constructor,t=Zi(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function On(r){var e,t,n,s=r.length-1,i="",a=r[0];if(s>0){for(i+=a,e=1;e<s;e++)n=r[e]+"",t=ft-n.length,t&&(i+=Yo(t)),i+=n;a=r[e],n=a+"",t=ft-n.length,t&&(i+=Yo(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}o(On,"digitsToString");function ps(r,e,t){if(r!==~~r||r<e||r>t)throw Error(Zo+r)}o(ps,"checkInt32");function U0(r,e,t,n){var s,i,a,u;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=ft,s=0):(s=Math.ceil((e+1)/ft),e%=ft),i=ln(10,ft-e),u=r[s]%i|0,n==null?e<3?(e==0?u=u/100|0:e==1&&(u=u/10|0),a=t<4&&u==99999||t>3&&u==49999||u==5e4||u==0):a=(t<4&&u+1==i||t>3&&u+1==i/2)&&(r[s+1]/i/100|0)==ln(10,e-2)-1||(u==i/2||u==0)&&(r[s+1]/i/100|0)==0:e<4?(e==0?u=u/1e3|0:e==1?u=u/100|0:e==2&&(u=u/10|0),a=(n||t<4)&&u==9999||!n&&t>3&&u==4999):a=((n||t<4)&&u+1==i||!n&&t>3&&u+1==i/2)&&(r[s+1]/i/1e3|0)==ln(10,e-3)-1,a}o(U0,"checkRoundingDigits");function rE(r,e,t){for(var n,s=[0],i,a=0,u=r.length;a<u;){for(i=s.length;i--;)s[i]*=e;for(s[0]+=BC.indexOf(r.charAt(a++)),n=0;n<s.length;n++)s[n]>t-1&&(s[n+1]===void 0&&(s[n+1]=0),s[n+1]+=s[n]/t|0,s[n]%=t)}return s.reverse()}o(rE,"convertBase");function KX(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/cE(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=Dh(r,1,e.times(s),new r(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return r.precision-=t,e}o(KX,"cosine");var Er=(function(){function r(n,s,i){var a,u=0,c=n.length;for(n=n.slice();c--;)a=n[c]*s+u,n[c]=a%i|0,u=a/i|0;return u&&n.unshift(u),n}o(r,"multiplyInteger");function e(n,s,i,a){var u,c;if(i!=a)c=i>a?1:-1;else for(u=c=0;u<i;u++)if(n[u]!=s[u]){c=n[u]>s[u]?1:-1;break}return c}o(e,"compare");function t(n,s,i,a){for(var u=0;i--;)n[i]-=u,u=n[i]<s[i]?1:0,n[i]=u*a+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return o(t,"subtract"),function(n,s,i,a,u,c){var l,f,h,d,m,g,x,y,v,b,E,w,S,A,V,I,D,O,U,j,ae=n.constructor,Z=n.s==s.s?1:-1,se=n.d,G=s.d;if(!se||!se[0]||!G||!G[0])return new ae(!n.s||!s.s||(se?G&&se[0]==G[0]:!G)?NaN:se&&se[0]==0||!G?Z*0:Z/0);for(c?(m=1,f=n.e-s.e):(c=Di,m=ft,f=$n(n.e/m)-$n(s.e/m)),U=G.length,D=se.length,v=new ae(Z),b=v.d=[],h=0;G[h]==(se[h]||0);h++);if(G[h]>(se[h]||0)&&f--,i==null?(A=i=ae.precision,a=ae.rounding):u?A=i+(n.e-s.e)+1:A=i,A<0)b.push(1),g=!0;else{if(A=A/m+2|0,h=0,U==1){for(d=0,G=G[0],A++;(h<D||d)&&A--;h++)V=d*c+(se[h]||0),b[h]=V/G|0,d=V%G|0;g=d||h<D}else{for(d=c/(G[0]+1)|0,d>1&&(G=r(G,d,c),se=r(se,d,c),U=G.length,D=se.length),I=U,E=se.slice(0,U),w=E.length;w<U;)E[w++]=0;j=G.slice(),j.unshift(0),O=G[0],G[1]>=c/2&&++O;do d=0,l=e(G,E,U,w),l<0?(S=E[0],U!=w&&(S=S*c+(E[1]||0)),d=S/O|0,d>1?(d>=c&&(d=c-1),x=r(G,d,c),y=x.length,w=E.length,l=e(x,E,y,w),l==1&&(d--,t(x,U<y?j:G,y,c))):(d==0&&(l=d=1),x=G.slice()),y=x.length,y<w&&x.unshift(0),t(E,x,w,c),l==-1&&(w=E.length,l=e(G,E,U,w),l<1&&(d++,t(E,U<w?j:G,w,c))),w=E.length):l===0&&(d++,E=[0]),b[h++]=d,l&&E[0]?E[w++]=se[I]||0:(E=[se[I]],w=1);while((I++<D||E[0]!==void 0)&&A--);g=E[0]!==void 0}b[0]||b.shift()}if(m==1)v.e=f,zP=g;else{for(h=1,d=b[0];d>=10;d/=10)h++;v.e=h+f*m-1,at(v,u?i+v.e+1:i,a,g)}return v}})();function at(r,e,t,n){var s,i,a,u,c,l,f,h,d,m=r.constructor;e:if(e!=null){if(h=r.d,!h)return r;for(s=1,u=h[0];u>=10;u/=10)s++;if(i=e-s,i<0)i+=ft,a=e,f=h[d=0],c=f/ln(10,s-a-1)%10|0;else if(d=Math.ceil((i+1)/ft),u=h.length,d>=u)if(n){for(;u++<=d;)h.push(0);f=c=0,s=1,i%=ft,a=i-ft+1}else break e;else{for(f=u=h[d],s=1;u>=10;u/=10)s++;i%=ft,a=i-ft+s,c=a<0?0:f/ln(10,s-a-1)%10|0}if(n=n||e<0||h[d+1]!==void 0||(a<0?f:f%ln(10,s-a-1)),l=t<4?(c||n)&&(t==0||t==(r.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(i>0?a>0?f/ln(10,s-a):0:h[d-1])%10&1||t==(r.s<0?8:7)),e<1||!h[0])return h.length=0,l?(e-=r.e+1,h[0]=ln(10,(ft-e%ft)%ft),r.e=-e||0):h[0]=r.e=0,r;if(i==0?(h.length=d,u=1,d--):(h.length=d+1,u=ln(10,ft-i),h[d]=a>0?(f/ln(10,s-a)%ln(10,a)|0)*u:0),l)for(;;)if(d==0){for(i=1,a=h[0];a>=10;a/=10)i++;for(a=h[0]+=u,u=1;a>=10;a/=10)u++;i!=u&&(r.e++,h[0]==Di&&(h[0]=1));break}else{if(h[d]+=u,h[d]!=Di)break;h[d--]=0,u=1}for(i=h.length;h[--i]===0;)h.pop()}return xt&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}o(at,"finalise");function Zi(r,e,t){if(!r.isFinite())return r3(r);var n,s=r.e,i=On(r.d),a=i.length;return e?(t&&(n=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+Yo(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+Yo(-s-1)+i,t&&(n=t-a)>0&&(i+=Yo(n))):s>=a?(i+=Yo(s+1-a),t&&(n=t-s-1)>0&&(i=i+"."+Yo(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-a)>0&&(s+1===a&&(i+="."),i+=Yo(n))),i}o(Zi,"finiteToString");function uE(r,e){var t=r[0];for(e*=ft;t>=10;t/=10)e++;return e}o(uE,"getBase10Exponent");function aE(r,e,t){if(e>HX)throw xt=!0,t&&(r.precision=t),Error(WP);return at(new r(sE),e,1,!0)}o(aE,"getLn10");function Qi(r,e,t){if(e>PC)throw Error(WP);return at(new r(iE),e,t,!0)}o(Qi,"getPi");function ZP(r){var e=r.length-1,t=e*ft+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}o(ZP,"getPrecision");function Yo(r){for(var e="";r--;)e+="0";return e}o(Yo,"getZeroString");function e3(r,e,t,n){var s,i=new r(1),a=Math.ceil(n/ft+4);for(xt=!1;;){if(t%2&&(i=i.times(e),XP(i.d,a)&&(s=!0)),t=$n(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),XP(e.d,a)}return xt=!0,i}o(e3,"intPow");function $P(r){return r.d[r.d.length-1]&1}o($P,"isOdd");function t3(r,e,t){for(var n,s,i=new r(e[0]),a=0;++a<e.length;){if(s=new r(e[a]),!s.s){i=s;break}n=i.cmp(s),(n===t||n===0&&i.s===t)&&(i=s)}return i}o(t3,"maxOrMin");function kC(r,e){var t,n,s,i,a,u,c,l=0,f=0,h=0,d=r.constructor,m=d.rounding,g=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(xt=!1,c=g):c=e,u=new d(.03125);r.e>-2;)r=r.times(u),h+=5;for(n=Math.log(ln(2,h))/Math.LN10*2+5|0,c+=n,t=i=a=new d(1),d.precision=c;;){if(i=at(i.times(r),c,1),t=t.times(++f),u=a.plus(Er(i,t,c,1)),On(u.d).slice(0,c)===On(a.d).slice(0,c)){for(s=h;s--;)a=at(a.times(a),c,1);if(e==null)if(l<3&&U0(a.d,c-n,m,l))d.precision=c+=10,t=i=u=new d(1),f=0,l++;else return at(a,d.precision=g,m,xt=!0);else return d.precision=g,a}a=u}}o(kC,"naturalExponential");function Qo(r,e){var t,n,s,i,a,u,c,l,f,h,d,m=1,g=10,x=r,y=x.d,v=x.constructor,b=v.rounding,E=v.precision;if(x.s<0||!y||!y[0]||!x.e&&y[0]==1&&y.length==1)return new v(y&&!y[0]?-1/0:x.s!=1?NaN:y?0:x);if(e==null?(xt=!1,f=E):f=e,v.precision=f+=g,t=On(y),n=t.charAt(0),Math.abs(i=x.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)x=x.times(r),t=On(x.d),n=t.charAt(0),m++;i=x.e,n>1?(x=new v("0."+t),i++):x=new v(n+"."+t.slice(1))}else return l=aE(v,f+2,E).times(i+""),x=Qo(new v(n+"."+t.slice(1)),f-g).plus(l),v.precision=E,e==null?at(x,E,b,xt=!0):x;for(h=x,c=a=x=Er(x.minus(1),x.plus(1),f,1),d=at(x.times(x),f,1),s=3;;){if(a=at(a.times(d),f,1),l=c.plus(Er(a,new v(s),f,1)),On(l.d).slice(0,f)===On(c.d).slice(0,f))if(c=c.times(2),i!==0&&(c=c.plus(aE(v,f+2,E).times(i+""))),c=Er(c,new v(m),f,1),e==null)if(U0(c.d,f-g,b,u))v.precision=f+=g,l=a=x=Er(h.minus(1),h.plus(1),f,1),d=at(x.times(x),f,1),s=u=1;else return at(c,v.precision=E,b,xt=!0);else return v.precision=E,c;c=l,s+=2}}o(Qo,"naturalLogarithm");function r3(r){return String(r.s*r.s/0)}o(r3,"nonFiniteToString");function nE(r,e){var t,n,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(n,s),e){if(s-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%ft,t<0&&(n+=ft),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=ft;n<s;)r.d.push(+e.slice(n,n+=ft));e=e.slice(n),n=ft-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),xt&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}o(nE,"parseDecimal");function $X(r,e){var t,n,s,i,a,u,c,l,f;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),QP.test(e))return nE(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(MX.test(e))t=16,e=e.toLowerCase();else if(VX.test(e))t=2;else if(jX.test(e))t=8;else throw Error(Zo+e);for(i=e.search(/p/i),i>0?(c=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,n=r.constructor,a&&(e=e.replace(".",""),u=e.length,i=u-i,s=e3(n,new n(t),i,i*2)),l=rE(e,t,Di),f=l.length-1,i=f;l[i]===0;--i)l.pop();return i<0?new n(r.s*0):(r.e=uE(l,f),r.d=l,xt=!1,a&&(r=Er(r,s,u*4)),c&&(r=r.times(Math.abs(c)<54?ln(2,c):_h.pow(2,c))),xt=!0,r)}o($X,"parseOther");function XX(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Dh(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/cE(5,t)),e=Dh(r,2,e,e);for(var s,i=new r(5),a=new r(16),u=new r(20);t--;)s=e.times(e),e=e.times(i.plus(s.times(a.times(s).minus(u))));return e}o(XX,"sine");function Dh(r,e,t,n,s){var i,a,u,c,l=1,f=r.precision,h=Math.ceil(f/ft);for(xt=!1,c=t.times(t),u=new r(n);;){if(a=Er(u.times(c),new r(e++*e++),f,1),u=s?n.plus(a):n.minus(a),n=Er(a.times(c),new r(e++*e++),f,1),a=u.plus(n),a.d[h]!==void 0){for(i=h;a.d[i]===u.d[i]&&i--;);if(i==-1)break}i=u,u=n,n=a,a=i,l++}return xt=!0,a.d.length=h+1,a}o(Dh,"taylorSeries");function cE(r,e){for(var t=r;--e;)t*=r;return t}o(cE,"tinyPow");function n3(r,e){var t,n=e.s<0,s=Qi(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return Ka=n?4:1,e;if(t=e.divToInt(s),t.isZero())Ka=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return Ka=$P(t)?n?2:3:n?4:1,e;Ka=$P(t)?n?1:4:n?3:2}return e.minus(s).abs()}o(n3,"toLessThanHalfPi");function LC(r,e,t,n){var s,i,a,u,c,l,f,h,d,m=r.constructor,g=t!==void 0;if(g?(ps(t,1,eu),n===void 0?n=m.rounding:ps(n,0,8)):(t=m.precision,n=m.rounding),!r.isFinite())f=r3(r);else{for(f=Zi(r),a=f.indexOf("."),g?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(f=f.replace(".",""),d=new m(1),d.e=f.length-a,d.d=rE(Zi(d),10,s),d.e=d.d.length),h=rE(f,10,s),i=c=h.length;h[--c]==0;)h.pop();if(!h[0])f=g?"0p+0":"0";else{if(a<0?i--:(r=new m(r),r.d=h,r.e=i,r=Er(r,d,t,n,0,s),h=r.d,i=r.e,l=zP),a=h[t],u=s/2,l=l||h[t+1]!==void 0,l=n<4?(a!==void 0||l)&&(n===0||n===(r.s<0?3:2)):a>u||a===u&&(n===4||l||n===6&&h[t-1]&1||n===(r.s<0?8:7)),h.length=t,l)for(;++h[--t]>s-1;)h[t]=0,t||(++i,h.unshift(1));for(c=h.length;!h[c-1];--c);for(a=0,f="";a<c;a++)f+=BC.charAt(h[a]);if(g){if(c>1)if(e==16||e==8){for(a=e==16?4:3,--c;c%a;c++)f+="0";for(h=rE(f,s,e),c=h.length;!h[c-1];--c);for(a=1,f="1.";a<c;a++)f+=BC.charAt(h[a])}else f=f.charAt(0)+"."+f.slice(1);f=f+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)f="0"+f;f="0."+f}else if(++i>c)for(i-=c;i--;)f+="0";else i<c&&(f=f.slice(0,i)+"."+f.slice(i))}f=(e==16?"0x":e==2?"0b":e==8?"0o":"")+f}return r.s<0?"-"+f:f}o(LC,"toStringBinary");function XP(r,e){if(r.length>e)return r.length=e,!0}o(XP,"truncate");function GX(r){return new this(r).abs()}o(GX,"abs");function zX(r){return new this(r).acos()}o(zX,"acos");function WX(r){return new this(r).acosh()}o(WX,"acosh");function JX(r,e){return new this(r).plus(e)}o(JX,"add");function YX(r){return new this(r).asin()}o(YX,"asin");function QX(r){return new this(r).asinh()}o(QX,"asinh");function ZX(r){return new this(r).atan()}o(ZX,"atan");function eG(r){return new this(r).atanh()}o(eG,"atanh");function tG(r,e){r=new this(r),e=new this(e);var t,n=this.precision,s=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=Qi(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?Qi(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=Qi(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(Er(r,e,i,1)),e=Qi(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(Er(r,e,i,1)),t}o(tG,"atan2");function rG(r){return new this(r).cbrt()}o(rG,"cbrt");function nG(r){return at(r=new this(r),r.e+1,2)}o(nG,"ceil");function sG(r,e,t){return new this(r).clamp(e,t)}o(sG,"clamp");function iG(r){if(!r||typeof r!="object")throw Error(oE+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,eu,"rounding",0,8,"toExpNeg",-Ih,0,"toExpPos",0,Ih,"maxE",0,Ih,"minE",-Ih,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=OC[t]),(n=r[t])!==void 0)if($n(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(Zo+t+": "+n);if(t="crypto",s&&(this[t]=OC[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(JP);else this[t]=!1;else throw Error(Zo+t+": "+n);return this}o(iG,"config");function aG(r){return new this(r).cos()}o(aG,"cos");function oG(r){return new this(r).cosh()}o(oG,"cosh");function s3(r){var e,t,n;function s(i){var a,u,c,l=this;if(!(l instanceof s))return new s(i);if(l.constructor=s,GP(i)){l.s=i.s,xt?!i.d||i.e>s.maxE?(l.e=NaN,l.d=null):i.e<s.minE?(l.e=0,l.d=[0]):(l.e=i.e,l.d=i.d.slice()):(l.e=i.e,l.d=i.d?i.d.slice():i.d);return}if(c=typeof i,c==="number"){if(i===0){l.s=1/i<0?-1:1,l.e=0,l.d=[0];return}if(i<0?(i=-i,l.s=-1):l.s=1,i===~~i&&i<1e7){for(a=0,u=i;u>=10;u/=10)a++;xt?a>s.maxE?(l.e=NaN,l.d=null):a<s.minE?(l.e=0,l.d=[0]):(l.e=a,l.d=[i]):(l.e=a,l.d=[i]);return}if(i*0!==0){i||(l.s=NaN),l.e=NaN,l.d=null;return}return nE(l,i.toString())}if(c==="string")return(u=i.charCodeAt(0))===45?(i=i.slice(1),l.s=-1):(u===43&&(i=i.slice(1)),l.s=1),QP.test(i)?nE(l,i):$X(l,i);if(c==="bigint")return i<0?(i=-i,l.s=-1):l.s=1,nE(l,i.toString());throw Error(Zo+i)}if(o(s,"Decimal"),s.prototype=Ie,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=iG,s.clone=s3,s.isDecimal=GP,s.abs=GX,s.acos=zX,s.acosh=WX,s.add=JX,s.asin=YX,s.asinh=QX,s.atan=ZX,s.atanh=eG,s.atan2=tG,s.cbrt=rG,s.ceil=nG,s.clamp=sG,s.cos=aG,s.cosh=oG,s.div=uG,s.exp=cG,s.floor=lG,s.hypot=fG,s.ln=hG,s.log=pG,s.log10=mG,s.log2=dG,s.max=gG,s.min=yG,s.mod=vG,s.mul=xG,s.pow=EG,s.random=wG,s.round=bG,s.sign=SG,s.sin=AG,s.sinh=CG,s.sqrt=NG,s.sub=TG,s.sum=IG,s.tan=DG,s.tanh=_G,s.trunc=RG,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return s.config(r),s}o(s3,"clone");function uG(r,e){return new this(r).div(e)}o(uG,"div");function cG(r){return new this(r).exp()}o(cG,"exp");function lG(r){return at(r=new this(r),r.e+1,3)}o(lG,"floor");function fG(){var r,e,t=new this(0);for(xt=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return xt=!0,new this(1/0);t=e}return xt=!0,t.sqrt()}o(fG,"hypot");function GP(r){return r instanceof _h||r&&r.toStringTag===YP||!1}o(GP,"isDecimalInstance");function hG(r){return new this(r).ln()}o(hG,"ln");function pG(r,e){return new this(r).log(e)}o(pG,"log");function dG(r){return new this(r).log(2)}o(dG,"log2");function mG(r){return new this(r).log(10)}o(mG,"log10");function gG(){return t3(this,arguments,-1)}o(gG,"max");function yG(){return t3(this,arguments,1)}o(yG,"min");function vG(r,e){return new this(r).mod(e)}o(vG,"mod");function xG(r,e){return new this(r).mul(e)}o(xG,"mul");function EG(r,e){return new this(r).pow(e)}o(EG,"pow");function wG(r){var e,t,n,s,i=0,a=new this(1),u=[];if(r===void 0?r=this.precision:ps(r,1,eu),n=Math.ceil(r/ft),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)s=e[i],s>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:u[i++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)s=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,i):(u.push(s%1e7),i+=4);i=n/4}else throw Error(JP);else for(;i<n;)u[i++]=Math.random()*1e7|0;for(n=u[--i],r%=ft,n&&r&&(s=ln(10,ft-r),u[i]=(n/s|0)*s);u[i]===0;i--)u.pop();if(i<0)t=0,u=[0];else{for(t=-1;u[0]===0;t-=ft)u.shift();for(n=1,s=u[0];s>=10;s/=10)n++;n<ft&&(t-=ft-n)}return a.e=t,a.d=u,a}o(wG,"random");function bG(r){return at(r=new this(r),r.e+1,this.rounding)}o(bG,"round");function SG(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}o(SG,"sign");function AG(r){return new this(r).sin()}o(AG,"sin");function CG(r){return new this(r).sinh()}o(CG,"sinh");function NG(r){return new this(r).sqrt()}o(NG,"sqrt");function TG(r,e){return new this(r).sub(e)}o(TG,"sub");function IG(){var r=0,e=arguments,t=new this(e[r]);for(xt=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return xt=!0,at(t,this.precision,this.rounding)}o(IG,"sum");function DG(r){return new this(r).tan()}o(DG,"tan");function _G(r){return new this(r).tanh()}o(_G,"tanh");function RG(r){return at(r=new this(r),r.e+1,1)}o(RG,"trunc");Ie[Symbol.for("nodejs.util.inspect.custom")]=Ie.toString;Ie[Symbol.toStringTag]="Decimal";var _h=Ie.constructor=s3(OC);sE=new _h(sE);iE=new _h(iE);var Zc=class r extends _h{static{o(this,"Decimal")}static from(e){return new r(e)}static newOrZero(e){return e===void 0?r.from(0):r.from(e)}static newOrUndefined(e){if(e!==void 0)return r.from(e)}};var i3=Lt(require("pdfkit"),1);var FC=class r{static{o(this,"PdfkitPdfBuilder")}defaults={autoFirstPage:!1};doc=new i3.default(this.defaults);constructor(e){e&&this.configure(e)}static new(e){return new r(e)}configure(e){return this.doc.options={...this.doc.options,...e},this}pipe(e){return this.doc.pipe(e),this}end(){return this.doc.end()}restore(){return this.doc.restore(),this}save(){return this.doc.save(),this}stroke(e){return this.doc.stroke(e),this}page(e){return this.doc.addPage(e),this}table(e){return this.doc.table(e),this}text(e,t){let{x:n,y:s,...i}=t??{};return n||s?(this.doc.text(e,n,s,i),this):(this.doc.text(e,t),this)}fontSize(e){return this.doc.fontSize(e),this}font(e,t,n){return typeof t=="string"?(this.doc.font(e,t,n),this):typeof t=="number"?(this.doc.font(e,t),this):(this.doc.font(e),this)}image(e,t,n,s){let i=this.imageSource(e);return typeof t=="number"&&typeof n=="number"?(this.doc.image(i,t,n,s),this):(this.doc.image(i,t),this)}imageSource(e){if(e.startsWith("data:")||!/^[A-Za-z0-9+/]+={0,2}$/.test(e))return e;let t=Buffer.from(e,"base64"),n=t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71,s=t[0]===255&&t[1]===216;return n||s?t:e}rect(e,t,n,s){return this.doc.rect(e,t,n,s),this}roundedRect(e,t,n,s,i){return this.doc.roundedRect(e,t,n,s,i),this}path(e){return this.doc.path(e),this}translate(e,t){return this.doc.translate(e,t),this}scale(e,t){return this.doc.scale(e,t),this}rotate(e,t){return this.doc.rotate(e,t),this}moveTo(e,t){return this.doc.moveTo(e,t),this}lineTo(e,t){return this.doc.lineTo(e,t),this}lineWidth(e){return this.doc.lineWidth(e),this}dash(e,t){return this.doc.dash(e,t),this}undash(){return this.doc.undash(),this}fillColor(e,t){return this.doc.fillColor(e,t),this}strokeColor(e,t){return this.doc.strokeColor(e,t),this}fill(e,t){return this.doc.fill(e,t),this}pageWidth(){return this.doc.page.width}pageHeight(){return this.doc.page.height}heightOfString(e,t){return this.doc.heightOfString(e,t)}widthOfString(e,t){return this.doc.widthOfString(e,t)}pageMargins(){return this.doc.page.margins}currentLineHeight(e){return this.doc.currentLineHeight(e)}x(){return this.doc.x}y(){return this.doc.y}moveDown(e){return this.doc.moveDown(e),this}row(e,...t){let n,s;typeof e=="function"?(n={},s=[e,...t]):(n=e??{},s=t),n.columns??=1;let i=this.y(),a=n.right??0,u=n.left??0,c=n.gap??0,l=this.pageWidth(),f=l-u-a-c*(n.columns-1);n.size??=Array(n.columns).fill(12/n.columns);let h=[];for(let d=0;d<n.columns;d++){let m=n.size[d]/12;h[d]=f*m}for(let d=0,m=u;d<n.columns;d++){let g=d===n.columns-1,x=h[d];if(g&&n.columns>1){let b=l-a-m;b>0&&Math.abs(b-x)>.01&&(x=b)}let y={y:i,x:m,width:x};s[d](y),m+=x,c>0&&!g&&(m+=c)}return this}};var UC=class{static{o(this,"MemoryCacheAdapter")}cache=new Map;async get(e){return Promise.resolve(this.cache.get(e)??null)}has(e){return Promise.resolve(this.cache.has(e))}set(e,t){return this.cache.set(e,t),Promise.resolve(!0)}};var N4=Lt(require("os"),1),$N=Lt(require("fs"),1),T4=Lt(require("path"),1),zh=Lt(require("crypto"),1),hu=Lt(w4(),1);var gY=o(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessageInRecord"),gs=o(r=>typeof r=="string"?rr(new Xt(r)):r instanceof Error?rr(new Xt(r.message,{cause:r.cause})):gY(r)?rr(new Xt(r.message)):rr(new Xt("unexpected error")),"leftFromError");var tg=class{static{o(this,"NullCacheAdapter")}async get(e){return Promise.resolve(null)}has(e){return Promise.resolve(!1)}set(e,t){return Promise.resolve(!0)}};var rg=require("os"),la=require("path");var qN=require("path"),jN=require("module"),qE=require("url");var yY=typeof jest<"u"||process.env.JEST_WORKER_ID!==void 0,Xh,b4=o(()=>{if(Xh!==void 0)return Xh;if(yY){Xh=void 0;return}try{Xh=new Function("try { return import.meta.url; } catch { return undefined; }")()}catch{Xh=void 0}return Xh},"getImportMetaUrl"),S4=o(()=>{if(typeof require<"u")return require;let r=b4();if(r)return(0,jN.createRequire)(r);let e=(0,qE.pathToFileURL)((0,qN.resolve)(process.cwd(),"package.json")).href;return(0,jN.createRequire)(e)},"getRequireFn"),A4=o(()=>{if(typeof __filename<"u")return __filename;let r=b4();return r?(0,qE.fileURLToPath)(r):(0,qN.resolve)(process.cwd())},"getCurrentFile");var Ms=require("path"),cl=require("fs");var C4=o(()=>typeof process<"u"&&typeof process.versions<"u"&&"electron"in process.versions,"isElectron"),vY=o(()=>{if(!C4())return null;try{let e=require("electron").app;if(e?.getAppPath&&typeof e.getAppPath=="function")return{getAppPath:e.getAppPath}}catch{}return null},"getElectronApp"),xY=o(()=>{if(!C4())return null;let r=process;if(r.resourcesPath)return r.resourcesPath;let e=vY();if(e)try{let t=e.getAppPath();if(typeof t=="string")return(0,Ms.dirname)(t.replace(/\.asar$/,""))}catch{}return null},"getElectronResourcesPath"),HE=o((r,{onFound:e,onNotFound:t})=>{let n=xY();if(n){let l=(0,Ms.resolve)(n,"node_modules","nfets",r);if((0,cl.existsSync)(l))return e(l);let f=(0,Ms.resolve)(n,"app.asar.unpacked","node_modules","nfets",r);if((0,cl.existsSync)(f))return e(f)}let s=A4(),i=s.includes(".asar")?process.cwd():s,a=(0,Ms.resolve)(i,"../../../../"),u=(0,Ms.resolve)(a,r);if((0,cl.existsSync)(u))return e(u);let c=i;for(let l=0;l<5;l++){let f=(0,Ms.resolve)(c,r);if((0,cl.existsSync)(f))return e(f);let h=(0,Ms.dirname)(c);if(h===c)break;c=h}c=i;for(let l=0;l<5;l++){let f=(0,Ms.resolve)(c,"node_modules","nfets",r);if((0,cl.existsSync)(f))return e(f);let h=(0,Ms.dirname)(c);if(h===c)break;c=h}c=i;for(let l=0;l<5;l++){let f=(0,Ms.resolve)(c,r.replace(/^build\//,"Release/"));if((0,cl.existsSync)(f))return e(f);let h=(0,Ms.dirname)(c);if(h===c)break;c=h}return t()},"search");var EY=o(r=>{let e=r.replace(/^\\\\\?\\/,"");return(0,la.resolve)((0,la.normalize)(e))},"normalizePath"),wY=o(r=>{(0,rg.platform)()==="win32"&&(process.env.PATH=`${(0,la.dirname)(r)}${la.delimiter}${process.env.PATH}`)},"addAddonDirToPath"),HN=o(r=>{let e=EY(r);return wY(e),S4()(e)},"exportRequireModule"),Gh=o(r=>{if(r=`${r}.node`,process.env.NFETS_ADDONS_DIR)return HN((0,la.join)(process.env.NFETS_ADDONS_DIR,r));let e=`${(0,rg.platform)()}-${(0,rg.arch)()}`;try{return HE(`build/addons/${e}/${r}`,{onFound:o(t=>HN(t),"onFound"),onNotFound:o(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}catch{return HE(`build/Release/${r}`,{onFound:o(t=>HN(t),"onFound"),onNotFound:o(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}},"addon");var Wa=class{static{o(this,"ASN1")}extractCertificateInfo(e){let n=e.subject.split(`
|
|
95
95
|
`).reduce((i,a)=>{let[u,c]=a.split("=").map(l=>l.trim());return!u||!c?i:i.set(u,c)},new Map),s=this.oid("2.16.76.1.3.1",e.raw);return{CNPJ:this.oid("2.16.76.1.3.3",e.raw),CPF:s,CN:n.get("CN"),O:n.get("O"),OU:n.get("OU"),ST:n.get("ST"),L:n.get("L"),C:n.get("C")}}oid(e,t){let n=this.marker(e),s=t.indexOf(n);if(s===-1)return;let i=[t.subarray(0,s),t.subarray(s)];if(i.length<=1)return;let u=i[0].subarray(-4),c=u.subarray(-2);u[0]===48?c=u:u[1]===48&&(c=u.subarray(-3));let l=Buffer.concat([c,n,i[1]]),f=this.length(l),h=n.length,d=l.subarray(2+h,2+h+f),m=d.length-c.length-2;if(m<=0||m>d.length)return;let x=d.subarray(-m).toString("utf8");return x.substring(Buffer.from(x).findIndex((y,v)=>x.charCodeAt(v)>=32&&x.charCodeAt(v)<=126))}length(e){return e.length<2?0:e[1]<=127?e[1]:Buffer.from([e[1]&15]).reduce((t,n)=>t<<8|n,0)}marker(e){let t=e.split("."),n=t.slice(2).reduce((s,i)=>{let a=this.base128(s,Number.parseInt(i,10),!0);return s.length=0,s.push(...a),s},[]);return Buffer.from([6,n.length+1,40*Number.parseInt(t[0],10)+Number.parseInt(t[1],10),...n])}base128(e,t,n){let s=[...e];if(t>127){let a=this.base128(e,Math.floor(t/128),!1);a.length=0,s.push(...a)}let i=t%128;return n?s.push(i):s.push(128|i),s}};var KE=class{static{o(this,"WincryptSignerRepository")}async sign(e,t,n){try{let s=Gh("wincrypt_certificate_store"),i=new Wa,{CN:a}=i.extractCertificateInfo(t.certificate),u=await s.sign(a??"",Buffer.from(e),n,Buffer.from(t.certificate.raw)),c=Buffer.from(u).toString("base64");return await Promise.resolve(sn(c))}catch(s){return Promise.resolve(gs(s))}}};var KN=Lt(require("crypto"),1);var $E=class{static{o(this,"CryptoSignerRepository")}async sign(e,t,n){try{if(!t.privateKey)return rr(new Xt("Certificate private key not found"));let i=KN.default.sign(n,Buffer.from(e),{key:t.privateKey,padding:KN.default.constants.RSA_PKCS1_PADDING}).toString("base64");return await Promise.resolve(sn(i))}catch(s){return Promise.resolve(gs(s))}}};var XN=class{static{o(this,"NativeCertificateRepository")}httpClient;cache;signer;constructor(e,t=new tg,n=N4.default.platform()==="win32"?new KE:new $E){this.httpClient=e,this.cache=t,this.signer=n}async read(e){try{let{password:t,pfxPathOrBase64:n,publicCertDerBase64:s}=e,i=s?.trim(),a=n?.trim();if(i&&a)return rr(new Xt("Use either pfxPathOrBase64 or publicCertDerBase64, not both"));if(i)try{let v=Buffer.from(i,"base64"),b=new zh.default.X509Certificate(v);return sn({ca:[],password:t,certificate:b,privateKey:void 0})}catch(v){return gs(v)}if(!a)return rr(new Xt("Certificate path (pfxPathOrBase64) is required"));let u=await this.getPfxBuffer({...e,pfxPathOrBase64:a});if(u.isLeft())return u;let c=hu.default.asn1.fromDer(u.value.toString("binary")),l=hu.default.pkcs12.pkcs12FromAsn1(c,t),{certBag:f}=hu.default.pki.oids,d=l.getBags({bagType:f})[f];if(!d?.length)return rr(new Xt("Cannot read certificate"));let[{cert:m},...g]=d;if(!m)return rr(new Xt("Issuer Certificate not found"));let x=g.reduce((v,{cert:b})=>(b&&v.push(new zh.default.X509Certificate(hu.default.pki.certificateToPem(b))),v),[]),y=new zh.default.X509Certificate(hu.default.pki.certificateToPem(m));return sn({ca:x,password:t,certificate:y,privateKey:this.getPrivateKey(l)})}catch(t){return gs(t)}}getPrivateKey(e){let{pkcs8ShroudedKeyBag:t}=hu.default.pki.oids,s=e.getBags({bagType:t})[t]?.[0]?.key;if(s)return zh.default.createPrivateKey(hu.default.pki.privateKeyToPem(s))}async sign(e,t,n=Ha.SHA1){return this.signer.sign(e,t,n)}getCertificateInfo(e){return new Wa().extractCertificateInfo(e)}getStringCertificate(e){return e.raw.toString("base64")}getStringPrivateKey(e){try{return e.export({type:"pkcs8",format:"pem"})}catch{throw new Xt("Cannot extract private key")}}async getPfxBuffer(e){let{pfxPathOrBase64:t,password:n}=e,s=this.getCacheKey(t,n),i=await this.cache.get(s);if(i)return sn(i);if(T4.default.isAbsolute(t)||$N.default.existsSync(t))return this.hitBufferOnCache(s,$N.default.readFileSync(t));if(this.isValidRemoteUrl(t))try{let a=await this.httpClient.get(t,{responseType:"arraybuffer"});return await this.hitBufferOnCache(s,Buffer.from(a.data))}catch(a){return gs(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return zh.default.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),sn(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};var J9=Lt(require("os"),1);var XE=Lt(require("dayjs"),1),I4=Lt(require("dayjs/plugin/utc"),1),D4=Lt(require("dayjs/plugin/timezone"),1);XE.default.extend(I4.default);XE.default.extend(D4.default);var ll=XE.default;var Y9=require("crypto"),Ww=require("https"),Q9=Lt(pj(),1);function Qg(r,e){return o(function(){return r.apply(e,arguments)},"wrap")}o(Qg,"bind");var{toString:hce}=Object.prototype,{getPrototypeOf:_p}=Object,{iterator:ey,toStringTag:gj}=Symbol,Ow=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Zg=o((r,e)=>{let t=r,n=[];for(;t!=null&&t!==Object.prototype;){if(n.indexOf(t)!==-1)return!1;if(n.push(t),Ow(t,e))return!0;t=_p(t)}return!1},"hasOwnInPrototypeChain"),pce=o((r,e)=>r!=null&&Zg(r,e)?r[e]:void 0,"getSafeProp"),f_=(r=>e=>{let t=hce.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),mi=o(r=>(r=r.toLowerCase(),e=>f_(e)===r),"kindOfTest"),Pw=o(r=>e=>typeof e===r,"typeOfTest"),{isArray:_l}=Array,Rl=Pw("undefined");function Rp(r){return r!==null&&!Rl(r)&&r.constructor!==null&&!Rl(r.constructor)&&Ts(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}o(Rp,"isBuffer");var yj=mi("ArrayBuffer");function dce(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&yj(r.buffer),e}o(dce,"isArrayBufferView");var mce=Pw("string"),Ts=Pw("function"),vj=Pw("number"),Bp=o(r=>r!==null&&typeof r=="object","isObject"),gce=o(r=>r===!0||r===!1,"isBoolean"),Bw=o(r=>{if(!Bp(r))return!1;let e=_p(r);return(e===null||e===Object.prototype||_p(e)===null)&&!Zg(r,gj)&&!Zg(r,ey)},"isPlainObject"),yce=o(r=>{if(!Bp(r)||Rp(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},"isEmptyObject"),vce=mi("Date"),xce=mi("File"),Ece=o(r=>!!(r&&typeof r.uri<"u"),"isReactNativeBlob"),wce=o(r=>r&&typeof r.getParts<"u","isReactNative"),bce=mi("Blob"),Sce=mi("FileList"),Ace=mi("Set"),Cce=o(r=>Bp(r)&&Ts(r.pipe),"isStream");function Nce(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}o(Nce,"getGlobal");var dj=Nce(),mj=typeof dj.FormData<"u"?dj.FormData:void 0,Tce=o(r=>{if(!r)return!1;if(mj&&r instanceof mj)return!0;let e=_p(r);if(!e||e===Object.prototype||!Ts(r.append))return!1;let t=f_(r);return t==="formdata"||t==="object"&&Ts(r.toString)&&r.toString()==="[object FormData]"},"isFormData"),Ice=mi("URLSearchParams"),[Dce,_ce,Rce,Bce]=["ReadableStream","Request","Response","Headers"].map(mi),Oce=o(r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),"trim");function ty(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,s;if(typeof r!="object"&&(r=[r]),_l(r))for(n=0,s=r.length;n<s;n++)e.call(null,r[n],n,r);else{if(Rp(r))return;let i=t?Object.getOwnPropertyNames(r):Object.keys(r),a=i.length,u;for(n=0;n<a;n++)u=i[n],e.call(null,r[u],u,r)}}o(ty,"forEach");function xj(r,e){if(Rp(r))return null;e=e.toLowerCase();let t=Object.keys(r),n=t.length,s;for(;n-- >0;)if(s=t[n],e===s.toLowerCase())return s;return null}o(xj,"findKey");var Dl=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ej=o(r=>!Rl(r)&&r!==Dl,"isContextDefined");function l_(...r){let{caseless:e,skipUndefined:t}=Ej(this)&&this||{},n={},s=o((i,a)=>{if(a==="__proto__"||a==="constructor"||a==="prototype")return;let u=e&&typeof a=="string"&&xj(n,a)||a,c=Ow(n,u)?n[u]:void 0;Bw(c)&&Bw(i)?n[u]=l_(c,i):Bw(i)?n[u]=l_({},i):_l(i)?n[u]=i.slice():(!t||!Rl(i))&&(n[u]=i)},"assignValue");for(let i=0,a=r.length;i<a;i++){let u=r[i];if(!u||Rp(u)||(ty(u,s),typeof u!="object"||_l(u)))continue;let c=Object.getOwnPropertySymbols(u);for(let l=0;l<c.length;l++){let f=c[l];$ce.call(u,f)&&s(u[f],f)}}return n}o(l_,"merge");var Pce=o((r,e,t,{allOwnKeys:n}={})=>(ty(e,(s,i)=>{t&&Ts(s)?Object.defineProperty(r,i,{__proto__:null,value:Qg(s,t),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(r,i,{__proto__:null,value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),r),"extend"),kce=o(r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),"stripBOM"),Lce=o((r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),Object.defineProperty(r.prototype,"constructor",{__proto__:null,value:r,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(r,"super",{__proto__:null,value:e.prototype}),t&&Object.assign(r.prototype,t)},"inherits"),Fce=o((r,e,t,n)=>{let s,i,a,u={};if(e=e||{},r==null)return e;do{for(s=Object.getOwnPropertyNames(r),i=s.length;i-- >0;)a=s[i],(!n||n(a,r,e))&&!u[a]&&(e[a]=r[a],u[a]=!0);r=t!==!1&&_p(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},"toFlatObject"),Uce=o((r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;let n=r.indexOf(e,t);return n!==-1&&n===t},"endsWith"),Vce=o(r=>{if(!r)return null;if(_l(r))return r;let e=r.length;if(!vj(e))return null;let t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},"toArray"),Mce=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&_p(Uint8Array)),jce=o((r,e)=>{let n=(r&&r[ey]).call(r),s;for(;(s=n.next())&&!s.done;){let i=s.value;e.call(r,i[0],i[1])}},"forEachEntry"),qce=o((r,e)=>{let t,n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},"matchAll"),Hce=mi("HTMLFormElement"),Kce=o(r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,o(function(t,n,s){return n.toUpperCase()+s},"replacer")),"toCamelCase"),{propertyIsEnumerable:$ce}=Object.prototype,Xce=mi("RegExp"),wj=o((r,e)=>{let t=Object.getOwnPropertyDescriptors(r),n={};ty(t,(s,i)=>{let a;(a=e(s,i,r))!==!1&&(n[i]=a||s)}),Object.defineProperties(r,n)},"reduceDescriptors"),Gce=o(r=>{wj(r,(e,t)=>{if(Ts(r)&&["arguments","caller","callee"].includes(t))return!1;let n=r[t];if(Ts(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},"freezeMethods"),zce=o((r,e)=>{let t={},n=o(s=>{s.forEach(i=>{t[i]=!0})},"define");return _l(r)?n(r):n(String(r).split(e)),t},"toObjectSet"),Wce=o(()=>{},"noop"),Jce=o((r,e)=>r!=null&&Number.isFinite(r=+r)?r:e,"toFiniteNumber");function Yce(r){return!!(r&&Ts(r.append)&&r[gj]==="FormData"&&r[ey])}o(Yce,"isSpecCompliantForm");var Qce=o(r=>{let e=new WeakSet,t=o(n=>{if(Bp(n)){if(e.has(n))return;if(Rp(n))return n;if(!("toJSON"in n)){e.add(n);let s;if(Ace(n)){s=[];for(let i of n){let a=t(i);!Rl(a)&&s.push(a)}}else s=_l(n)?[]:{},ty(n,(i,a)=>{let u=t(i);!Rl(u)&&(s[a]=u)});return e.delete(n),s}}return n},"visit");return t(r)},"toJSONObject"),Zce=mi("AsyncFunction"),ele=o(r=>r&&(Bp(r)||Ts(r))&&Ts(r.then)&&Ts(r.catch),"isThenable"),bj=((r,e)=>r?setImmediate:e?((t,n)=>(Dl.addEventListener("message",({source:s,data:i})=>{s===Dl&&i===t&&n.length&&n.shift()()},!1),s=>{n.push(s),Dl.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ts(Dl.postMessage)),tle=typeof queueMicrotask<"u"?queueMicrotask.bind(Dl):typeof process<"u"&&process.nextTick||bj,Sj=o(r=>r!=null&&Ts(r[ey]),"isIterable"),rle=o(r=>r!=null&&Zg(r,ey)&&Sj(r),"isSafeIterable"),K={isArray:_l,isArrayBuffer:yj,isBuffer:Rp,isFormData:Tce,isArrayBufferView:dce,isString:mce,isNumber:vj,isBoolean:gce,isObject:Bp,isPlainObject:Bw,isEmptyObject:yce,isReadableStream:Dce,isRequest:_ce,isResponse:Rce,isHeaders:Bce,isUndefined:Rl,isDate:vce,isFile:xce,isReactNativeBlob:Ece,isReactNative:wce,isBlob:bce,isRegExp:Xce,isFunction:Ts,isStream:Cce,isURLSearchParams:Ice,isTypedArray:Mce,isFileList:Sce,forEach:ty,merge:l_,extend:Pce,trim:Oce,stripBOM:kce,inherits:Lce,toFlatObject:Fce,kindOf:f_,kindOfTest:mi,endsWith:Uce,toArray:Vce,forEachEntry:jce,matchAll:qce,isHTMLForm:Hce,hasOwnProperty:Ow,hasOwnProp:Ow,hasOwnInPrototypeChain:Zg,getSafeProp:pce,reduceDescriptors:wj,freezeMethods:Gce,toObjectSet:zce,toCamelCase:Kce,noop:Wce,toFiniteNumber:Jce,findKey:xj,global:Dl,isContextDefined:Ej,isSpecCompliantForm:Yce,toJSONObject:Qce,isAsyncFn:Zce,isThenable:ele,setImmediate:bj,asap:tle,isIterable:Sj,isSafeIterable:rle};var nle=K.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Aj=o((r=>{let e={},t,n,s;return r&&r.split(`
|
|
96
96
|
`).forEach(o(function(a){s=a.indexOf(":"),t=a.substring(0,s).trim().toLowerCase(),n=a.substring(s+1).trim();let u=K.hasOwnProp(e,t);!t||u&&K.hasOwnProp(nle,t)||(t==="set-cookie"?u?e[t].push(n):e[t]=[n]:e[t]=u?e[t]+", "+n:n)},"parser")),e}),"default");function sle(r){let e=0,t=r.length;for(;e<t;){let n=r.charCodeAt(e);if(n!==9&&n!==32)break;e+=1}for(;t>e;){let n=r.charCodeAt(t-1);if(n!==9&&n!==32)break;t-=1}return e===0&&t===r.length?r:r.slice(e,t)}o(sle,"trimSPorHTAB");var ile=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),ale=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function h_(r,e){return K.isArray(r)?r.map(t=>h_(t,e)):sle(String(r).replace(e,""))}o(h_,"sanitizeValue");var Cj=o(r=>h_(r,ile),"sanitizeHeaderValue"),ole=o(r=>h_(r,ale),"sanitizeByteStringHeaderValue");function Op(r){let e=Object.create(null);return K.forEach(r.toJSON(),(t,n)=>{e[n]=ole(t)}),e}o(Op,"toByteStringHeaderObject");var Nj=Symbol("internals");function ry(r){return r&&String(r).trim().toLowerCase()}o(ry,"normalizeHeader");function kw(r){return r===!1||r==null?r:K.isArray(r)?r.map(kw):Cj(String(r))}o(kw,"normalizeValue");function ule(r){let e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=t.exec(r);)e[n[1]]=n[2];return e}o(ule,"parseTokens");var cle=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function p_(r){let e=0,t=r.length;for(;e<t;){let n=r.charCodeAt(e);if(n!==9&&n!==32)break;e+=1}for(;t>e;){let n=r.charCodeAt(t-1);if(n!==9&&n!==32)break;t-=1}return e===0&&t===r.length?r:r.slice(e,t)}o(p_,"trimOWS");function lle(r){let e=r.length-1;if(e<1||r.charCodeAt(0)!==34||r.charCodeAt(e)!==34)return r;let t="";for(let n=1;n<e;n++){let s=r.charCodeAt(n);if(s===34||s===92&&(n+=1,n>=e))return r;t+=r[n]}return t}o(lle,"decodeQuotedString");function fle(r){let e=Object.create(null),t=String(r),n=0,s=!1,i=!1;function a(u){let c=p_(t.slice(n,u)),l=c.indexOf("=");if(l<1)return;let f=p_(c.slice(0,l));if(!cle.test(f))return;let h=f.toLowerCase();if(h==="__proto__"||h==="constructor"||h==="prototype")return;let d=p_(c.slice(l+1));e[h]=lle(d)}o(a,"parseParameter");for(let u=0;u<t.length;u++){let c=t.charCodeAt(u);s?i?i=!1:c===92?i=!0:c===34&&(s=!1):c===34?s=!0:(c===44||c===59)&&(a(u),n=u+1)}return a(t.length),e}o(fle,"parseParameters");var hle=o(r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim()),"isValidHeaderName");function d_(r,e,t,n,s){if(K.isFunction(n))return n.call(this,e,t);if(s&&(e=t),!!K.isString(e)){if(K.isString(n))return e.indexOf(n)!==-1;if(K.isRegExp(n))return n.test(e)}}o(d_,"matchHeaderValue");function ple(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}o(ple,"formatHeader");function dle(r,e){let t=K.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{__proto__:null,value:o(function(s,i,a){return this[n].call(this,e,s,i,a)},"value"),configurable:!0})})}o(dle,"buildAccessors");var Lw=class{static{o(this,"AxiosHeaders")}constructor(e){e&&this.set(e)}set(e,t,n){let s=this;function i(u,c,l){let f=ry(c);if(!f)return;let h=K.findKey(s,f);(!h||s[h]===void 0||l===!0||l===void 0&&s[h]!==!1)&&(s[h||c]=kw(u))}o(i,"setHeader");let a=o((u,c)=>K.forEach(u,(l,f)=>i(l,f,c)),"setHeaders");if(K.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(K.isString(e)&&(e=e.trim())&&!hle(e))a(Aj(e),t);else if(K.isObject(e)&&K.isSafeIterable(e)){let u=Object.create(null),c,l;for(let f of e){if(!K.isArray(f))throw new TypeError("Object iterator must return a key-value pair");l=f[0],K.hasOwnProp(u,l)?(c=u[l],u[l]=K.isArray(c)?[...c,f[1]]:[c,f[1]]):u[l]=f[1]}a(u,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=ry(e),e){let n=K.findKey(this,e);if(n){let s=this[n];if(!t)return s;if(t===!0)return ule(s);if(K.isFunction(t))return t.call(this,s,n);if(K.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ry(e),e){let n=K.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||d_(this,this[n],n,t)))}return!1}delete(e,t){let n=this,s=!1;function i(a){if(a=ry(a),a){let u=K.findKey(n,a);u&&(!t||d_(n,n[u],u,t))&&(delete n[u],s=!0)}}return o(i,"deleteHeader"),K.isArray(e)?e.forEach(i):i(e),s}clear(e){let t=Object.keys(this),n=t.length,s=!1;for(;n--;){let i=t[n];(!e||d_(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){let t=this,n={};return K.forEach(this,(s,i)=>{let a=K.findKey(n,i);if(a){t[a]=kw(s),delete t[i];return}let u=e?ple(i):String(i).trim();u!==i&&delete t[i],t[u]=kw(s),n[u]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return K.forEach(this,(n,s)=>{n!=null&&n!==!1&&(t[s]=e&&K.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
|
|
97
97
|
`)}getSetCookie(){let e=this.get("set-cookie");return K.isArray(e)?e:e==null||e===!1?[]:[e]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static parseParameters(e){return fle(e)}static concat(e,...t){let n=new this(e);return t.forEach(s=>n.set(s)),n}static accessor(e){let n=(this[Nj]=this[Nj]={accessors:{}}).accessors,s=this.prototype;function i(a){let u=ry(a);n[u]||(dle(s,a),n[u]=!0)}return o(i,"defineAccessor"),K.isArray(e)?e.forEach(i):i(e),this}};Lw.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);K.reduceDescriptors(Lw.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:o(()=>r,"get"),set(n){this[t]=n}}});K.freezeMethods(Lw);var Nr=Lw;var ny="[REDACTED ****]";function mle(r){if(K.hasOwnProp(r,"toJSON"))return!0;let e=Object.getPrototypeOf(r);for(;e&&e!==Object.prototype;){if(K.hasOwnProp(e,"toJSON"))return!0;e=Object.getPrototypeOf(e)}return!1}o(mle,"hasOwnOrPrototypeToJSON");function gle(r,e){let t=new Set(e.map(i=>String(i).toLowerCase())),n=[],s=o(i=>{if(i===null||typeof i!="object"||K.isBuffer(i))return i;if(n.indexOf(i)!==-1)return;i instanceof Nr&&(i=i.toJSON()),n.push(i);let a;if(K.isArray(i))a=[],i.forEach((u,c)=>{let l=s(u);K.isUndefined(l)||(a[c]=l)});else{if(!K.isPlainObject(i)&&mle(i))return n.pop(),i;a=Object.create(null);for(let[u,c]of Object.entries(i)){let l=t.has(u.toLowerCase())?ny:s(c);K.isUndefined(l)||(a[u]=l)}}return n.pop(),a},"visit");return s(r)}o(gle,"redactConfig");function Tj(r){try{return String(r)}catch{return""}}o(Tj,"stringifySafely");function yle(r){return r.errors.map(t=>{try{return t&&t.message?Tj(t.message):Tj(t)}catch{return""}}).filter(Boolean).join("; ")||r.name||"AggregateError"}o(yle,"aggregateErrorMessage");var us=class Ij extends Error{static{o(this,"AxiosError")}static from(e,t,n,s,i,a){let u=e.message;!u&&K.isArray(e.errors)&&e.errors.length&&(u=yle(e));let c=new Ij(u,t||e.code,n,s,i);return Object.defineProperty(c,"cause",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),c.name=e.name,e.status!=null&&c.status==null&&(c.status=e.status),a&&Object.assign(c,a),c}constructor(e,t,n,s,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),s&&(this.request=s),i&&(this.response=i,this.status=i.status)}toJSON(){let e=this.config,t=e&&K.hasOwnProp(e,"redact")?e.redact:void 0,n=K.isArray(t)&&t.length>0?gle(e,t):K.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}};us.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";us.ERR_BAD_OPTION="ERR_BAD_OPTION";us.ECONNABORTED="ECONNABORTED";us.ETIMEDOUT="ETIMEDOUT";us.ECONNREFUSED="ECONNREFUSED";us.ERR_NETWORK="ERR_NETWORK";us.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";us.ERR_DEPRECATED="ERR_DEPRECATED";us.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";us.ERR_BAD_REQUEST="ERR_BAD_REQUEST";us.ERR_CANCELED="ERR_CANCELED";us.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";us.ERR_INVALID_URL="ERR_INVALID_URL";us.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";var be=us;var Dj=Lt(yT(),1),Fw=Dj.default;var Uw={isBufferAvailable(){return typeof Buffer<"u"},from(r){return Buffer.from(r)}};var y_=100;function g_(r){return K.isPlainObject(r)||K.isArray(r)}o(g_,"isVisitable");function _j(r){return K.endsWith(r,"[]")?r.slice(0,-2):r}o(_j,"removeBrackets");function m_(r,e,t){return r?r.concat(e).map(o(function(s,i){return s=_j(s),!t&&i?"["+s+"]":s},"each")).join(t?".":""):e}o(m_,"renderKey");function vle(r){return K.isArray(r)&&!r.some(g_)}o(vle,"isFlatArray");var xle=K.toFlatObject(K,{},null,o(function(e){return/^is[A-Z]/.test(e)},"filter"));function Ele(r,e,t){if(!K.isObject(r))throw new TypeError("target must be an object");e=e||new(Fw||FormData),t=K.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,o(function(b,E){return!K.isUndefined(E[b])},"defined"));let n=t.metaTokens,s=t.visitor||g,i=t.dots,a=t.indexes,u=t.Blob||typeof Blob<"u"&&Blob,c=t.maxDepth===void 0?y_:t.maxDepth,l=u&&K.isSpecCompliantForm(e),f=[];if(!K.isFunction(s))throw new TypeError("visitor must be a function");function h(v){if(v===null)return"";if(K.isDate(v))return v.toISOString();if(K.isBoolean(v))return v.toString();if(!l&&K.isBlob(v))throw new be("Blob is not supported. Use a Buffer instead.");if(K.isArrayBuffer(v)||K.isTypedArray(v)){if(l&&typeof u=="function")return new u([v]);if(Uw&&Uw.isBufferAvailable())return Uw.from(v);throw new be("Blob is not supported. Use a Buffer instead.",be.ERR_NOT_SUPPORT)}return v}o(h,"convertValue");function d(v){if(v>c)throw new be("Object is too deeply nested ("+v+" levels). Max depth: "+c,be.ERR_FORM_DATA_DEPTH_EXCEEDED)}o(d,"throwIfMaxDepthExceeded");function m(v,b){if(c===1/0)return JSON.stringify(v);let E=[];return JSON.stringify(v,o(function(S,A){if(!K.isObject(A))return A;for(;E.length&&E[E.length-1]!==this;)E.pop();return E.push(A),d(b+E.length-1),A},"limitDepth"))}o(m,"stringifyWithDepthLimit");function g(v,b,E){let w=v;if(K.isReactNative(e)&&K.isReactNativeBlob(v))return e.append(m_(E,b,i),h(v)),!1;if(v&&!E&&typeof v=="object"){if(K.endsWith(b,"{}"))b=n?b:b.slice(0,-2),v=m(v,1);else if(K.isArray(v)&&vle(v)||(K.isFileList(v)||K.endsWith(b,"[]"))&&(w=K.toArray(v)))return b=_j(b),w.forEach(o(function(A,V){!(K.isUndefined(A)||A===null)&&e.append(a===!0?m_([b],V,i):a===null?b:b+"[]",h(A))},"each")),!1}return g_(v)?!0:(e.append(m_(E,b,i),h(v)),!1)}o(g,"defaultVisitor");let x=Object.assign(xle,{defaultVisitor:g,convertValue:h,isVisitable:g_});function y(v,b,E=0){if(!K.isUndefined(v)){if(d(E),f.indexOf(v)!==-1)throw new Error("Circular reference detected in "+b.join("."));f.push(v),K.forEach(v,o(function(S,A){(!(K.isUndefined(S)||S===null)&&s.call(e,S,K.isString(A)?A.trim():A,b,x))===!0&&y(S,b?b.concat(A):[A],E+1)},"each")),f.pop()}}if(o(y,"build"),!K.isObject(r))throw new TypeError("data must be an object");return y(r),e}o(Ele,"toFormData");var Ou=Ele;function Rj(r){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(r).replace(/[!'()~]|%20/g,o(function(n){return e[n]},"replacer"))}o(Rj,"encode");function Bj(r,e){this._pairs=[],r&&Ou(r,this,e)}o(Bj,"AxiosURLSearchParams");var Oj=Bj.prototype;Oj.append=o(function(e,t){this._pairs.push([e,t])},"append");Oj.toString=o(function(e){let t=e?n=>e.call(this,n,Rj):Rj;return this._pairs.map(o(function(s){return t(s[0])+"="+t(s[1])},"each"),"").join("&")},"toString");var Pj=Bj;function wle(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}o(wle,"encode");function Bl(r,e,t){if(!e)return r;r=r||"";let n=K.isFunction(t)?{serialize:t}:t,s=K.getSafeProp(n,"encode")||wle,i=K.getSafeProp(n,"serialize"),a;if(i?a=i(e,n):a=K.isURLSearchParams(e)?e.toString():new Pj(e,n).toString(s),a){let u=r.indexOf("#");u!==-1&&(r=r.slice(0,u)),r+=(r.indexOf("?")===-1?"?":"&")+a}return r}o(Bl,"buildURL");var ble=class{static{o(this,"InterceptorManager")}constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){K.forEach(this.handlers,o(function(n){n!==null&&e(n)},"forEachHandler"))}},v_=ble;var Pu={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0};var Uj=Lt(require("crypto"),1);var kj=Lt(require("url"),1),Lj=kj.default.URLSearchParams;var x_="abcdefghijklmnopqrstuvwxyz",Fj="0123456789",Vj={DIGIT:Fj,ALPHA:x_,ALPHA_DIGIT:x_+x_.toUpperCase()+Fj},Sle=o((r=16,e=Vj.ALPHA_DIGIT)=>{let t="",{length:n}=e,s=new Uint32Array(r);Uj.default.randomFillSync(s);for(let i=0;i<r;i++)t+=e[s[i]%n];return t},"generateString"),Mj={isNode:!0,classes:{URLSearchParams:Lj,FormData:Fw,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Vj,generateString:Sle,protocols:["http","https","file","data"]};var b_={};Jx(b_,{hasBrowserEnv:()=>w_,hasStandardBrowserEnv:()=>Ale,hasStandardBrowserWebWorkerEnv:()=>Cle,navigator:()=>E_,origin:()=>Nle});var w_=typeof window<"u"&&typeof document<"u",E_=typeof navigator=="object"&&navigator||void 0,Ale=w_&&(!E_||["ReactNative","NativeScript","NS"].indexOf(E_.product)<0),Cle=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Nle=w_&&window.location.href||"http://localhost";var ir={...b_,...Mj};function S_(r,e){return Ou(r,new ir.classes.URLSearchParams,{visitor:o(function(t,n,s,i){return ir.isNode&&K.isBuffer(t)?(this.append(n,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},"visitor"),...e})}o(S_,"toURLEncodedForm");var jj=y_;function qj(r){if(r>jj)throw new be("FormData field is too deeply nested ("+r+" levels). Max depth: "+jj,be.ERR_FORM_DATA_DEPTH_EXCEEDED)}o(qj,"throwIfDepthExceeded");function Tle(r){let e=[],t=/[^.[\]]+|\[([^.[\]]*)]/g,n;for(;(n=t.exec(r))!==null;)qj(e.length),e.push(n[0]==="[]"?"":n[1]||n[0]);return e}o(Tle,"parsePropPath");function Ile(r){let e={},t=Object.keys(r),n,s=t.length,i;for(n=0;n<s;n++)i=t[n],e[i]=r[i];return e}o(Ile,"arrayToObject");function Dle(r){function e(t,n,s,i){qj(i);let a=t[i++];if(a==="__proto__")return!0;let u=Number.isFinite(+a),c=i>=t.length;return a=!a&&K.isArray(s)?s.length:a,c?(K.hasOwnProp(s,a)?s[a]=K.isArray(s[a])?s[a].concat(n):[s[a],n]:s[a]=n,!u):((!K.hasOwnProp(s,a)||!K.isObject(s[a]))&&(s[a]=[]),e(t,n,s[a],i)&&K.isArray(s[a])&&(s[a]=Ile(s[a])),!u)}if(o(e,"buildPath"),K.isFormData(r)&&K.isFunction(r.entries)){let t={};return K.forEachEntry(r,(n,s)=>{e(Tle(n),s,t,0)}),t}return null}o(Dle,"formDataToJSON");var Vw=Dle;var Pp=o((r,e)=>r!=null&&K.hasOwnProp(r,e)?r[e]:void 0,"own");function _le(r,e,t){if(K.isString(r))try{return(e||JSON.parse)(r),K.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}o(_le,"stringifySafely");var A_={transitional:Pu,adapter:["xhr","http","fetch"],transformRequest:[o(function(e,t){let n=t.getContentType()||"",s=n.indexOf("application/json")>-1,i=K.isObject(e);if(i&&K.isHTMLForm(e)&&(e=new FormData(e)),K.isFormData(e))return s?JSON.stringify(Vw(e)):e;if(K.isArrayBuffer(e)||K.isBuffer(e)||K.isStream(e)||K.isFile(e)||K.isBlob(e)||K.isReadableStream(e))return e;if(K.isArrayBufferView(e))return e.buffer;if(K.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let u;if(i){let c=Pp(this,"formSerializer");if(n.indexOf("application/x-www-form-urlencoded")>-1)return S_(e,c).toString();if((u=K.isFileList(e))||n.indexOf("multipart/form-data")>-1){let l=Pp(this,"env"),f=l&&l.FormData;return Ou(u?{"files[]":e}:e,f&&new f,c)}}return i||s?(t.setContentType("application/json",!1),_le(e)):e},"transformRequest")],transformResponse:[o(function(e){let t=Pp(this,"transitional")||A_.transitional,n=t&&t.forcedJSONParsing,s=Pp(this,"responseType"),i=s==="json";if(K.isResponse(e)||K.isReadableStream(e))return e;if(e&&K.isString(e)&&(n&&!s||i)){let u=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,Pp(this,"parseReviver"))}catch(c){if(u)throw c.name==="SyntaxError"?be.from(c,be.ERR_BAD_RESPONSE,this,null,Pp(this,"response")):c}}return e},"transformResponse")],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ir.classes.FormData,Blob:ir.classes.Blob},validateStatus:o(function(e){return e>=200&&e<300},"validateStatus"),headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch","query"],r=>{A_.headers[r]={}});var kp=A_;function sy(r,e){let t=this||kp,n=e||t,s=Nr.from(n.headers),i=n.data;return K.forEach(r,o(function(u){i=u.call(t,i,s.normalize(),e?e.status:void 0)},"transform")),s.normalize(),i}o(sy,"transformData");function iy(r){return!!(r&&r.__CANCEL__)}o(iy,"isCancel");var Rle=class extends be{static{o(this,"CanceledError")}constructor(e,t,n){super(e??"canceled",be.ERR_CANCELED,t,n),this.name="CanceledError",this.__CANCEL__=!0}},Hs=Rle;function wa(r,e,t){let n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new be("Request failed with status code "+t.status,t.status>=400&&t.status<500?be.ERR_BAD_REQUEST:be.ERR_BAD_RESPONSE,t.config,t.request,t))}o(wa,"settle");function C_(r){return typeof r!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}o(C_,"isAbsoluteURL");function N_(r,e){if(!e)return r;let t=r.length;for(;t>0&&r.charCodeAt(t-1)===47;)t--;return r.slice(0,t)+"/"+e.replace(/^\/+/,"")}o(N_,"combineURLs");var Ble=/^https?:(?!\/\/)/i,Ole=/[\t\n\r]/g;function Ple(r){let e=0;for(;e<r.length&&r.charCodeAt(e)<=32;)e++;return r.slice(e)}o(Ple,"stripLeadingC0ControlOrSpace");function kle(r){return Ple(r).replace(Ole,"")}o(kle,"normalizeURLForProtocolCheck");function Lle(r){return r&&r.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,t,n="")=>`${t}${n}${ny}`)}o(Lle,"redactFragment");function Fle(r){let e=r.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${ny}@`),t=e.indexOf("#"),s=(t===-1?e:e.slice(0,t)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${ny}`);return t===-1?s:`${s}#${Lle(e.slice(t+1))}`}o(Fle,"redactSensitiveURLParts");function Hj(r,e){if(typeof r=="string"){let t=kle(r);if(Ble.test(t))throw new be(`Invalid URL ${JSON.stringify(Fle(t))}: missing "//" after protocol`,be.ERR_INVALID_URL,e)}}o(Hj,"assertValidHttpProtocolURL");function Ol(r,e,t,n){Hj(e,n);let s=!C_(e);return r&&(s||t===!1)?(Hj(r,n),N_(r,e)):e}o(Ol,"buildFullPath");var Ule={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function Vle(r){try{return new URL(r)}catch{return null}}o(Vle,"parseUrl");function Kj(r){var e=(typeof r=="string"?Vle(r):r)||{},t=e.protocol,n=e.host,s=e.port;if(typeof n!="string"||!n||typeof t!="string"||(t=t.split(":",1)[0],n=n.replace(/:\d*$/,""),s=parseInt(s)||Ule[t]||0,!Mle(n,s)))return"";var i=T_(t+"_proxy")||T_("all_proxy");return i&&i.indexOf("://")===-1&&(i=t+"://"+i),i}o(Kj,"getProxyForUrl");function Mle(r,e){var t=T_("no_proxy").toLowerCase();return t?t==="*"?!1:t.split(/[,\s]/).every(function(n){if(!n)return!0;var s=n.match(/^(.+):(\d+)$/),i=s?s[1]:n,a=s?parseInt(s[2]):0;return a&&a!==e?!0:/^[.*]/.test(i)?(i.charAt(0)==="*"&&(i=i.slice(1)),!r.endsWith(i)):r!==i}):!0}o(Mle,"shouldProxy");function T_(r){return process.env[r.toLowerCase()]||process.env[r.toUpperCase()]||""}o(T_,"getEnv");var L_=Lt(AT(),1),F_=Lt(require("http"),1),U_=Lt(require("https"),1),b9=Lt(require("http2"),1),S9=Lt(require("util"),1),k_=require("path"),A9=Lt(FT(),1),Ks=Lt(require("zlib"),1);var uo="1.19.0";function ay(r){let e=/^([-+\w]{1,25}):(?:\/\/)?/.exec(r);return e&&e[1]||""}o(ay,"parseProtocol");var jle=/^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;function I_(r,e,t){let n=t&&t.Blob||ir.classes.Blob,s=ay(r);if(e===void 0&&n&&(e=!0),s==="data"){r=s.length?r.slice(s.length+1):r;let i=jle.exec(r);if(!i)throw new be("Invalid URL",be.ERR_INVALID_URL);let a=i[1],u=i[2],c=i[3]?"base64":"utf8",l=i[4],f="";a?f=u?a+u:a:u&&(f="text/plain"+u);let h=c==="base64"?Buffer.from(l,"base64"):Buffer.from(decodeURIComponent(l),c);if(e){if(!n)throw new be("Blob is not supported",be.ERR_NOT_SUPPORT);return new n([h],{type:f})}return h}throw new be("Unsupported protocol "+s,be.ERR_NOT_SUPPORT)}o(I_,"fromDataURI");var gi=Lt(require("stream"),1);var qle=["content-type","content-length"];function oy(r,e,t){if(t!=="content-only"){r.set(e);return}Object.entries(e||{}).forEach(([n,s])=>{qle.includes(n.toLowerCase())&&r.set(n,s)})}o(oy,"setFormDataHeaders");var $j=Lt(require("stream"),1);var D_=Symbol("internals"),Hle=class extends $j.default.Transform{static{o(this,"AxiosTransformStream")}constructor(e){e=K.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,s)=>!K.isUndefined(s[n])),super({readableHighWaterMark:e.chunkSize});let t=this[D_]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){let t=this[D_];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){let s=this[D_],i=s.maxRate,a=this.readableHighWaterMark,u=s.timeWindow,c=1e3/u,l=i/c,f=s.minChunkSize!==!1?Math.max(s.minChunkSize,l*.01):0,h=o((m,g)=>{let x=Buffer.byteLength(m);s.bytesSeen+=x,s.bytes+=x,s.isCaptured&&this.emit("progress",s.bytesSeen),this.push(m)?process.nextTick(g):s.onReadCallback=()=>{s.onReadCallback=null,process.nextTick(g)}},"pushChunk"),d=o((m,g)=>{let x=Buffer.byteLength(m),y=null,v=a,b,E=0;if(i){let w=Date.now();(!s.ts||(E=w-s.ts)>=u)&&(s.ts=w,b=l-s.bytes,s.bytes=b<0?-b:0,E=0),b=l-s.bytes}if(i){if(b<=0)return setTimeout(()=>{g(null,m)},u-E);b<v&&(v=b)}v&&x>v&&x-v>f&&(y=m.subarray(v),m=m.subarray(0,v)),h(m,y?()=>{process.nextTick(g,null,y)}:g)},"transformChunk");d(e,o(function m(g,x){if(g)return n(g);x?d(x,m):n(null)},"transformNextChunk"))}},__=Hle;var C9=require("events");var Gj=Lt(require("util"),1),zj=require("stream");var{asyncIterator:Xj}=Symbol,Kle=o(async function*(r){r.stream?yield*r.stream():r.arrayBuffer?yield await r.arrayBuffer():r[Xj]?yield*r[Xj]():yield r},"readBlob"),Mw=Kle;var $le=ir.ALPHABET.ALPHA_DIGIT+"-_",uy=typeof TextEncoder=="function"?new TextEncoder:new Gj.default.TextEncoder,Pl=`\r
|
package/dist/core/index.d.cts
CHANGED
|
@@ -251,6 +251,7 @@ declare class PdfkitPdfBuilder implements PdfBuilder {
|
|
|
251
251
|
font(font: string): this;
|
|
252
252
|
image(image: string, options?: ImageOptions): this;
|
|
253
253
|
image(image: string, x: number, y: number, options?: ImageOptions): this;
|
|
254
|
+
private imageSource;
|
|
254
255
|
rect(x: number, y: number, w: number, h: number): this;
|
|
255
256
|
roundedRect(x: number, y: number, w: number, h: number, r?: number): this;
|
|
256
257
|
path(path: string): this;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -251,6 +251,7 @@ declare class PdfkitPdfBuilder implements PdfBuilder {
|
|
|
251
251
|
font(font: string): this;
|
|
252
252
|
image(image: string, options?: ImageOptions): this;
|
|
253
253
|
image(image: string, x: number, y: number, options?: ImageOptions): this;
|
|
254
|
+
private imageSource;
|
|
254
255
|
rect(x: number, y: number, w: number, h: number): this;
|
|
255
256
|
roundedRect(x: number, y: number, w: number, h: number, r?: number): this;
|
|
256
257
|
path(path: string): this;
|
package/dist/core/index.mjs
CHANGED
|
@@ -79,7 +79,7 @@ Actual: `+O.attribValue);else{var Pe=O.tag,R=O.tags[O.tags.length-1]||O;Pe.ns===
|
|
|
79
79
|
`&&p!==" "&&p!=="\r")return f;f++,s()}return-1}u(i,"skipBlanks");function a(){return r.substring(t)}u(a,"substringFromIndex");function o(f){return r.substring(t,t+f.length)===f}u(o,"substringStartsWith");function l(f){return r.substring(t,t+f.length).toUpperCase()===f.toUpperCase()}u(l,"substringStartsWithCaseInsensitive");function c(f){var p=wt.reg("^",f),d=p.exec(a());return d?(s(d[0].length),d[0]):null}return u(c,"getMatch"),{char:n,getIndex:u(function(){return t},"getIndex"),getMatch:c,getSource:u(function(){return r},"getSource"),skip:s,skipBlanks:i,substringFromIndex:a,substringStartsWith:o,substringStartsWithCaseInsensitive:l}}u(rV,"parseUtils");function FZ(r,e){function t(o,l){var c=wt.PI.exec(o.substringFromIndex());return c?c[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+o.getIndex()):(o.skip(c[0].length),c[0]):l.fatalError("processing instruction is not well-formed at position "+o.getIndex())}u(t,"parsePI");var n=r.getSource();if(r.char()==="["){r.skip(1);for(var s=r.getIndex();r.getIndex()<n.length;){if(r.skipBlanks(),r.char()==="]"){var i=n.substring(s,r.getIndex());return r.skip(1),i}var a=null;if(r.char()==="<"&&r.char(1)==="!")switch(r.char(2)){case"E":r.char(3)==="L"?a=r.getMatch(wt.elementdecl):r.char(3)==="N"&&(a=r.getMatch(wt.EntityDecl));break;case"A":a=r.getMatch(wt.AttlistDecl);break;case"N":a=r.getMatch(wt.NotationDecl);break;case"-":a=r.getMatch(wt.Comment);break}else if(r.char()==="<"&&r.char(1)==="?")a=t(r,e);else if(r.char()==="%")a=r.getMatch(wt.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!a)return e.fatalError("Error in internal subset at position "+r.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}u(FZ,"parseDoctypeInternalSubset");function nV(r,e,t,n,s){var i=rV(r,e);switch(s?i.char(2).toUpperCase():i.char(2)){case"-":var a=i.getMatch(wt.Comment);return a?(t.comment(a,wt.COMMENT_START.length,a.length-wt.COMMENT_START.length-wt.COMMENT_END.length),i.getIndex()):n.fatalError("comment is not well-formed at position "+i.getIndex());case"[":var o=i.getMatch(wt.CDSect);return o?!s&&!t.currentElement?n.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(o,wt.CDATA_START.length,o.length-wt.CDATA_START.length-wt.CDATA_END.length),t.endCDATA(),i.getIndex()):n.fatalError("Invalid CDATA starting at position "+e);case"D":{if(t.doc&&t.doc.documentElement)return n.fatalError("Doctype not allowed inside or after documentElement at position "+i.getIndex());if(s?!i.substringStartsWithCaseInsensitive(wt.DOCTYPE_DECL_START):!i.substringStartsWith(wt.DOCTYPE_DECL_START))return n.fatalError("Expected "+wt.DOCTYPE_DECL_START+" at position "+i.getIndex());if(i.skip(wt.DOCTYPE_DECL_START.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+wt.DOCTYPE_DECL_START+" at position "+i.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=i.getMatch(wt.Name),!l.name)return n.fatalError("doctype name missing or contains unexpected characters at position "+i.getIndex());if(s&&l.name.toLowerCase()!=="html"&&n.warning("Unexpected DOCTYPE in HTML document at position "+i.getIndex()),i.skipBlanks(),i.substringStartsWith(wt.PUBLIC)||i.substringStartsWith(wt.SYSTEM)){var c=wt.ExternalID_match.exec(i.substringFromIndex());if(!c)return n.fatalError("doctype external id is not well-formed at position "+i.getIndex());c.groups.SystemLiteralOnly!==void 0?l.systemId=c.groups.SystemLiteralOnly:(l.systemId=c.groups.SystemLiteral,l.publicId=c.groups.PubidLiteral),i.skip(c[0].length)}else if(s&&i.substringStartsWithCaseInsensitive(wt.SYSTEM)){if(i.skip(wt.SYSTEM.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+wt.SYSTEM+" at position "+i.getIndex());if(l.systemId=i.getMatch(wt.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return n.fatalError("Expected "+wt.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+wt.SYSTEM+" at position "+i.getIndex())}return s&&l.systemId&&!wt.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&n.warning("Unexpected doctype.systemId in HTML document at position "+i.getIndex()),s||(i.skipBlanks(),l.internalSubset=FZ(i,n)),i.skipBlanks(),i.char()!==">"?n.fatalError("doctype not terminated with > at position "+i.getIndex()):(i.skip(1),t.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),t.endDTD(),i.getIndex())}default:return n.fatalError('Not well-formed XML starting with "<!" at position '+e)}}u(nV,"parseDoctypeCommentOrCData");function MZ(r,e,t,n){var s=r.substring(e).match(wt.PI);if(!s)return n.fatalError("Invalid processing instruction starting at position "+e);if(s[1].toLowerCase()==="xml"){if(e>0)return n.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!wt.XMLDecl.test(r.substring(e)))return n.fatalError("xml declaration is not well-formed")}return t.processingInstruction(s[1],s[2]),e+s[0].length}u(MZ,"parseProcessingInstruction");function sV(){this.attributeNames=Object.create(null)}u(sV,"ElementAttributes");sV.prototype={setTagName:u(function(r){if(!wt.QName_exact.test(r))throw new Error("invalid tagName:"+r);this.tagName=r},"setTagName"),addValue:u(function(r,e,t){if(!wt.QName_exact.test(r))throw new Error("invalid attribute:"+r);this.attributeNames[r]=this.length,this[this.length++]={qName:r,value:e,offset:t}},"addValue"),length:0,getLocalName:u(function(r){return this[r].localName},"getLocalName"),getLocator:u(function(r){return this[r].locator},"getLocator"),getQName:u(function(r){return this[r].qName},"getQName"),getURI:u(function(r){return this[r].uri},"getURI"),getValue:u(function(r){return this[r].value},"getValue")};cA.XMLReader=tV;cA.parseUtils=rV;cA.parseDoctypeCommentOrCData=nV});var hV=le(Zd=>{"use strict";var df=hf(),jZ=II(),qZ=Sy(),aV=JL(),HZ=iV(),KZ=jZ.DOMImplementation,XZ=df.hasDefaultHTMLNamespace,$Z=df.isHTMLMimeType,GZ=df.isValidMimeType,lV=df.MIME_TYPE,BI=df.NAMESPACE,oV=qZ.ParseError,WZ=HZ.XMLReader;function cV(r){return r.replace(/\r[\n\u0085]/g,`
|
|
80
80
|
`).replace(/[\r\u0085\u2028\u2029]/g,`
|
|
81
81
|
`)}u(cV,"normalizeLineEndings");function fV(r){if(r=r||{},r.locator===void 0&&(r.locator=!0),this.assign=r.assign||df.assign,this.domHandler=r.domHandler||hA,this.onError=r.onError||r.errorHandler,r.errorHandler&&typeof r.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");r.errorHandler&&r.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=r.normalizeLineEndings||cV,this.locator=!!r.locator,this.xmlns=this.assign(Object.create(null),r.xmlns)}u(fV,"DOMParser");fV.prototype.parseFromString=function(r,e){if(!GZ(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),n=aV.XML_ENTITIES,s=t[""]||null;XZ(e)?(n=aV.HTML_ENTITIES,s=BI.HTML):e===lV.XML_SVG_IMAGE&&(s=BI.SVG),t[""]=s,t.xml=t.xml||BI.XML;var i=new this.domHandler({mimeType:e,defaultNamespace:s,onError:this.onError}),a=this.locator?{}:void 0;this.locator&&i.setDocumentLocator(a);var o=new WZ;o.errorHandler=i,o.domBuilder=i;var l=!df.isHTMLMimeType(e);return l&&typeof r!="string"&&o.errorHandler.fatalError("source is not a string"),o.parse(this.normalizeLineEndings(String(r)),t,n),i.doc.documentElement||o.errorHandler.fatalError("missing root element"),i.doc};function hA(r){var e=r||{};this.mimeType=e.mimeType||lV.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}u(hA,"DOMHandler");function Qd(r,e){e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber}u(Qd,"position");hA.prototype={startDocument:u(function(){var r=new KZ;this.doc=$Z(this.mimeType)?r.createHTMLDocument(!1):r.createDocument(this.defaultNamespace,"")},"startDocument"),startElement:u(function(r,e,t,n){var s=this.doc,i=s.createElementNS(r,t||e),a=n.length;fA(this,i),this.currentElement=i,this.locator&&Qd(this.locator,i);for(var o=0;o<a;o++){var r=n.getURI(o),l=n.getValue(o),t=n.getQName(o),c=s.createAttributeNS(r,t);this.locator&&Qd(n.getLocator(o),c),c.value=c.nodeValue=l,i.setAttributeNode(c)}},"startElement"),endElement:u(function(r,e,t){this.currentElement=this.currentElement.parentNode},"endElement"),startPrefixMapping:u(function(r,e){},"startPrefixMapping"),endPrefixMapping:u(function(r){},"endPrefixMapping"),processingInstruction:u(function(r,e){var t=this.doc.createProcessingInstruction(r,e);this.locator&&Qd(this.locator,t),fA(this,t)},"processingInstruction"),ignorableWhitespace:u(function(r,e,t){},"ignorableWhitespace"),characters:u(function(r,e,t){if(r=uV.apply(this,arguments),r){if(this.cdata)var n=this.doc.createCDATASection(r);else var n=this.doc.createTextNode(r);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(r)&&this.doc.appendChild(n),this.locator&&Qd(this.locator,n)}},"characters"),skippedEntity:u(function(r){},"skippedEntity"),endDocument:u(function(){this.doc.normalize()},"endDocument"),setDocumentLocator:u(function(r){r&&(r.lineNumber=0),this.locator=r},"setDocumentLocator"),comment:u(function(r,e,t){r=uV.apply(this,arguments);var n=this.doc.createComment(r);this.locator&&Qd(this.locator,n),fA(this,n)},"comment"),startCDATA:u(function(){this.cdata=!0},"startCDATA"),endCDATA:u(function(){this.cdata=!1},"endCDATA"),startDTD:u(function(r,e,t,n){var s=this.doc.implementation;if(s&&s.createDocumentType){var i=s.createDocumentType(r,e,t,n);this.locator&&Qd(this.locator,i),fA(this,i),this.doc.doctype=i}},"startDTD"),reportError:u(function(r,e){if(typeof this.onError=="function")try{this.onError(r,e,this)}catch(t){throw new oV("Reporting "+r+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+r+"] "+e,zZ(this.locator))},"reportError"),warning:u(function(r){this.reportError("warning",r)},"warning"),error:u(function(r){this.reportError("error",r)},"error"),fatalError:u(function(r,e){throw this.reportError("fatalError",r),new oV(r,this.locator,e)},"fatalError")};function zZ(r){if(r)return`
|
|
82
|
-
@#[line:`+r.lineNumber+",col:"+r.columnNumber+"]"}u(zZ,"_locator");function uV(r,e,t){return typeof r=="string"?r.substr(e,t):r.length>=e+t||e?new java.lang.String(r,e,t)+"":r}u(uV,"_toString");"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){hA.prototype[r]=function(){return null}});function fA(r,e){r.currentElement?r.currentElement.appendChild(e):r.doc.appendChild(e)}u(fA,"appendElement");function JZ(r){if(r==="error")throw"onErrorStopParsing"}u(JZ,"onErrorStopParsing");function YZ(){throw"onWarningStopParsing"}u(YZ,"onWarningStopParsing");Zd.__DOMHandler=hA;Zd.DOMParser=fV;Zd.normalizeLineEndings=cV;Zd.onErrorStopParsing=JZ;Zd.onWarningStopParsing=YZ});var pV=le($t=>{"use strict";var e0=hf();$t.assign=e0.assign;$t.hasDefaultHTMLNamespace=e0.hasDefaultHTMLNamespace;$t.isHTMLMimeType=e0.isHTMLMimeType;$t.isValidMimeType=e0.isValidMimeType;$t.MIME_TYPE=e0.MIME_TYPE;$t.NAMESPACE=e0.NAMESPACE;var pA=Sy();$t.DOMException=pA.DOMException;$t.DOMExceptionName=pA.DOMExceptionName;$t.ExceptionCode=pA.ExceptionCode;$t.ParseError=pA.ParseError;var tn=II();$t.Attr=tn.Attr;$t.CDATASection=tn.CDATASection;$t.CharacterData=tn.CharacterData;$t.Comment=tn.Comment;$t.Document=tn.Document;$t.DocumentFragment=tn.DocumentFragment;$t.DocumentType=tn.DocumentType;$t.DOMImplementation=tn.DOMImplementation;$t.Element=tn.Element;$t.Entity=tn.Entity;$t.EntityReference=tn.EntityReference;$t.LiveNodeList=tn.LiveNodeList;$t.NamedNodeMap=tn.NamedNodeMap;$t.Node=tn.Node;$t.NodeList=tn.NodeList;$t.Notation=tn.Notation;$t.ProcessingInstruction=tn.ProcessingInstruction;$t.Text=tn.Text;$t.XMLSerializer=tn.XMLSerializer;var dA=hV();$t.DOMParser=dA.DOMParser;$t.normalizeLineEndings=dA.normalizeLineEndings;$t.onErrorStopParsing=dA.onErrorStopParsing;$t.onWarningStopParsing=dA.onWarningStopParsing});var gA="http://www.w3.org/2000/09/xmldsig#",kI="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",yA=(function(r){return r.RSA_SHA1="http://www.w3.org/2000/09/xmldsig#rsa-sha1",r.RSA_SHA256="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",r})({}),io=(function(r){return r.SHA1="sha1",r.SHA256="sha256",r})({}),vA=(function(r){return r.SHA1="http://www.w3.org/2000/09/xmldsig#sha1",r.SHA256="http://www.w3.org/2001/04/xmlenc#sha256",r})({});var sr={AC:"12",AL:"27",AM:"13",AP:"16",BA:"29",CE:"23",DF:"53",ES:"32",GO:"52",MA:"21",MG:"31",MS:"50",MT:"51",PA:"15",PB:"25",PE:"26",PI:"22",PR:"41",RJ:"33",RN:"24",RO:"11",RR:"14",RS:"43",SC:"42",SE:"28",SP:"35",TO:"17"},iee=Object.keys(sr);var oee={Production:"1",Homolog:"2"};var r6={[sr.AC]:"America/Rio_Branco",[sr.AL]:"America/Maceio",[sr.AM]:"America/Manaus",[sr.AP]:"America/Belem",[sr.BA]:"America/Bahia",[sr.CE]:"America/Fortaleza",[sr.DF]:"America/Sao_Paulo",[sr.ES]:"America/Sao_Paulo",[sr.GO]:"America/Sao_Paulo",[sr.MA]:"America/Fortaleza",[sr.MG]:"America/Sao_Paulo",[sr.MS]:"America/Campo_Grande",[sr.MT]:"America/Cuiaba",[sr.PA]:"America/Belem",[sr.PB]:"America/Fortaleza",[sr.PE]:"America/Recife",[sr.PI]:"America/Fortaleza",[sr.PR]:"America/Sao_Paulo",[sr.RJ]:"America/Sao_Paulo",[sr.RN]:"America/Fortaleza",[sr.RO]:"America/Porto_Velho",[sr.RR]:"America/Boa_Vista",[sr.RS]:"America/Sao_Paulo",[sr.SC]:"America/Sao_Paulo",[sr.SE]:"America/Maceio",[sr.SP]:"America/Sao_Paulo",[sr.TO]:"America/Araguaina"};var Mt=class extends Error{static{u(this,"NFeTsError")}};var Ly=class extends Mt{static{u(this,"TransmissionError")}},el=class extends Ly{static{u(this,"TransmissionHostNotFoundError")}},tl=class extends Ly{static{u(this,"TransmissionTimeoutError")}};var LI=class extends Mt{static{u(this,"ValidationError")}};var n0={includeComments:!1,exclusive:!0};var EA=u(r=>{throw new Mt("Didn't expect to get here")},"unreachable");var gf=class{static{u(this,"Signer")}toolkit;certificateRepository;algorithm;canonical;constructor(e,t,n=io.SHA1,s=n0){this.toolkit=e,this.certificateRepository=t,this.algorithm=n,this.canonical=s}assemble(e,t,n){let s=this.certificateRepository.getStringCertificate(n);return{$:{xmlns:gA},SignedInfo:e,SignatureValue:t,KeyInfo:{X509Data:{X509Certificate:s}}}}signedInfo(e,t){return{CanonicalizationMethod:{$:{Algorithm:kI}},SignatureMethod:{$:{Algorithm:this.signatureMethod}},Reference:{$:{URI:`#${this.toolkit.getAttribute(e,t)}`},Transforms:this.transforms,DigestMethod:{$:{Algorithm:this.digestAlgorithm}},DigestValue:this.digest(e)}}}digest(e){return this.toolkit.digest(e,this.algorithm,this.canonical)}async signOrLeft(e,t){let n=this.toolkit.canonicalize(await this.toolkit.build({$:{xmlns:gA},...e},{rootName:"SignedInfo"}),this.canonical);return this.certificateRepository.sign(n,t,this.algorithm)}get transforms(){return{Transform:[{$:{Algorithm:"http://www.w3.org/2000/09/xmldsig#enveloped-signature"}},{$:{Algorithm:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"}}]}}get digestAlgorithm(){switch(this.algorithm){case io.SHA256:return vA.SHA256;case io.SHA1:return vA.SHA1;default:return EA(this.algorithm)}}get signatureMethod(){switch(this.algorithm){case io.SHA256:return yA.RSA_SHA256;case io.SHA1:return yA.RSA_SHA1;default:return EA(this.algorithm)}}};var wA=class{static{u(this,"Left")}value;constructor(e){this.value=e}isLeft(){return!0}isRight(){return!1}},Vy=class{static{u(this,"Right")}value;constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}},Jt=u(r=>new wA(r),"left"),Wr=u(r=>r===void 0?new Vy(void 0):new Vy(r),"right");var VI=class extends gf{static{u(this,"EntitySigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n;if(!e[s])return Jt(new Mt(`Node ${String(s)} not found`));let o=await this.toolkit.build(this.ns(e,s),{headless:!0,rootName:String(s),renderOpts:{pretty:!1}}),l=this.signedInfo(o,i),c=await this.signOrLeft(l,n);if(c.isLeft())return c;let f=e;return f.Signature=this.assemble(l,c.value,a),Wr(f)}ns(e,t){let n=e.$?.xmlns,{$:s,...i}=e[t],{xmlns:a,...o}=s??{};return{$:{xmlns:n,...o},...i}}};var UI=class extends gf{static{u(this,"XmlSigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n,o=this.toolkit.getNode(e,s);if(!o)return Jt(new Mt(`Node ${s} not found`));let l=this.signedInfo(o,i),c=await this.signOrLeft(l,n);if(c.isLeft())return c;let f=await this.toolkit.build(this.assemble(l,c.value,a),{rootName:"Signature"});return Wr(this.toolkit.appendNode(e,f))}};import"reflect-metadata";import{validateSync as s6}from"class-validator";import"reflect-metadata";var s0="__SkipValidation__",nte=u(()=>(r,e)=>{Reflect.defineMetadata(s0,!0,r,e.toString())},"SkipValidation"),ste=u(()=>r=>{Reflect.defineMetadata(s0,!0,r)},"SkipAllValidations");import{plainToInstance as n6}from"class-transformer";var Uy=u(r=>{for(let[e,t]of Object.entries(r))typeof t>"u"&&delete r[e],t===""&&delete r[e],t&&typeof t=="object"&&Uy(t)},"clearEmptyValues"),FI=u((r,e,t={})=>{let n=n6(e,r);return t.clearEmptyValues&&Uy(n),n},"plainToInstance");var MI="__ValidateErrors__",jI=u((r,e)=>r.reduce((t,n)=>{if(n.children?.length)return t.concat(jI(n.children,e?`${e}.${n.property}`:n.property));let s=Object.values(n.constraints??{}).map(i=>e?`${e}.${i}`:i).join(", ");return s?t.concat(s):t},[]),"mapConstraintsToErrors"),dte=u((r,e)=>(t,n,s)=>{let i=s.value;if(i==null)return;let a=u((o,l,c)=>{let f=FI(l,r),p=s6(f,{whitelist:!0});if(Uy(f),p.length){let d=Reflect.getMetadata(MI,o)??[];Reflect.defineMetadata(MI,d.concat(jI(p,c)),o)}return f},"validate");s.value=function(...o){let l=Reflect.getMetadata(s0,this.constructor);if(Reflect.getMetadata(s0,this.constructor.prototype,n.toString())===!0||l===!0)return i.apply(this,o);let[f,...p]=o;if(!f)return i.apply(this,o);let d=e?.each&&Array.isArray(f)?f.map((m,g)=>a(this,m,`${i.name}.${g}`)):a(this,f,i.name);return i.apply(this,[d,...p])}},"Validates");import"reflect-metadata";var yf=9e15,lo=1e9,SA="0123456789abcdef",jy="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",qy="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",AA={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-yf,maxE:yf,crypto:!1},XI,aa,gt=!0,Ky="[DecimalError] ",uo=Ky+"Invalid argument: ",$I=Ky+"Precision limit exceeded",GI=Ky+"crypto unavailable",WI="[object Decimal]",In=Math.floor,zr=Math.pow,i6=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,a6=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,o6=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,zI=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ys=1e7,lt=7,u6=9007199254740991,l6=jy.length-1,CA=qy.length-1,Ce={toStringTag:WI};Ce.absoluteValue=Ce.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),rt(r)};Ce.ceil=function(){return rt(new this.constructor(this),this.e+1,2)};Ce.clampedTo=Ce.clamp=function(r,e){var t,n=this,s=n.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(uo+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};Ce.comparedTo=Ce.cmp=function(r){var e,t,n,s,i=this,a=i.d,o=(r=new i.constructor(r)).d,l=i.s,c=r.s;if(!a||!o)return!l||!c?NaN:l!==c?l:a===o?0:!a^l<0?1:-1;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(n=a.length,s=o.length,e=0,t=n<s?n:s;e<t;++e)if(a[e]!==o[e])return a[e]>o[e]^l<0?1:-1;return n===s?0:n>s^l<0?1:-1};Ce.cosine=Ce.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+lt,n.rounding=1,t=c6(n,eD(n,t)),n.precision=r,n.rounding=e,rt(aa==2||aa==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};Ce.cubeRoot=Ce.cbrt=function(){var r,e,t,n,s,i,a,o,l,c,f=this,p=f.constructor;if(!f.isFinite()||f.isZero())return new p(f);for(gt=!1,i=f.s*zr(f.s*f,1/3),!i||Math.abs(i)==1/0?(t=yn(f.d),r=f.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=zr(t,1/3),r=In((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new p(t),n.s=f.s):n=new p(i.toString()),a=(r=p.precision)+3;;)if(o=n,l=o.times(o).times(o),c=l.plus(f),n=cr(c.plus(f).times(o),c.plus(l),a+2,1),yn(o.d).slice(0,a)===(t=yn(n.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(rt(o,r+1,0),o.times(o).times(o).eq(f))){n=o;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(rt(n,r+1,1),e=!n.times(n).times(n).eq(f));break}return gt=!0,rt(n,r,p.rounding,e)};Ce.decimalPlaces=Ce.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-In(this.e/lt))*lt,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};Ce.dividedBy=Ce.div=function(r){return cr(this,new this.constructor(r))};Ce.dividedToIntegerBy=Ce.divToInt=function(r){var e=this,t=e.constructor;return rt(cr(e,new t(r),0,1,1),t.precision,t.rounding)};Ce.equals=Ce.eq=function(r){return this.cmp(r)===0};Ce.floor=function(){return rt(new this.constructor(this),this.e+1,3)};Ce.greaterThan=Ce.gt=function(r){return this.cmp(r)>0};Ce.greaterThanOrEqualTo=Ce.gte=function(r){var e=this.cmp(r);return e==1||e===0};Ce.hyperbolicCosine=Ce.cosh=function(){var r,e,t,n,s,i=this,a=i.constructor,o=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return o;t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,s=i.d.length,s<32?(r=Math.ceil(s/3),e=(1/$y(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=vf(a,1,i.times(e),new a(1),!0);for(var l,c=r,f=new a(8);c--;)l=i.times(i),i=o.minus(l.times(f.minus(l.times(f))));return rt(i,a.precision=t,a.rounding=n,!0)};Ce.hyperbolicSine=Ce.sinh=function(){var r,e,t,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(s.e,s.sd())+4,i.rounding=1,n=s.d.length,n<3)s=vf(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/$y(5,r)),s=vf(i,2,s,s,!0);for(var a,o=new i(5),l=new i(16),c=new i(20);r--;)a=s.times(s),s=s.times(o.plus(a.times(l.times(a).plus(c))))}return i.precision=e,i.rounding=t,rt(s,e,t,!0)};Ce.hyperbolicTangent=Ce.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,cr(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};Ce.inverseCosine=Ce.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,s=e.rounding;return t!==-1?t===0?r.isNeg()?vi(e,n,s):new e(0):new e(NaN):r.isZero()?vi(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=s,r.times(2))};Ce.inverseHyperbolicCosine=Ce.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,gt=!1,t=t.times(t).minus(1).sqrt().plus(t),gt=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};Ce.inverseHyperbolicSine=Ce.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,gt=!1,t=t.times(t).plus(1).sqrt().plus(t),gt=!0,n.precision=r,n.rounding=e,t.ln())};Ce.inverseHyperbolicTangent=Ce.atanh=function(){var r,e,t,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=i.precision,e=i.rounding,n=s.sd(),Math.max(n,r)<2*-s.e-1?rt(new i(s),r,e,!0):(i.precision=t=n-s.e,s=cr(s.plus(1),new i(1).minus(s),t+r,1),i.precision=r+4,i.rounding=1,s=s.ln(),i.precision=r,i.rounding=e,s.times(.5))):new i(NaN)};Ce.inverseSine=Ce.asin=function(){var r,e,t,n,s=this,i=s.constructor;return s.isZero()?new i(s):(e=s.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=vi(i,t+4,n).times(.5),r.s=s.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,s.times(2)))};Ce.inverseTangent=Ce.atan=function(){var r,e,t,n,s,i,a,o,l,c=this,f=c.constructor,p=f.precision,d=f.rounding;if(c.isFinite()){if(c.isZero())return new f(c);if(c.abs().eq(1)&&p+4<=CA)return a=vi(f,p+4,d).times(.25),a.s=c.s,a}else{if(!c.s)return new f(NaN);if(p+4<=CA)return a=vi(f,p+4,d).times(.5),a.s=c.s,a}for(f.precision=o=p+10,f.rounding=1,t=Math.min(28,o/lt+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(gt=!1,e=Math.ceil(o/lt),n=1,l=c.times(c),a=new f(c),s=c;r!==-1;)if(s=s.times(l),i=a.minus(s.div(n+=2)),s=s.times(l),a=i.plus(s.div(n+=2)),a.d[e]!==void 0)for(r=e;a.d[r]===i.d[r]&&r--;);return t&&(a=a.times(2<<t-1)),gt=!0,rt(a,f.precision=p,f.rounding=d,!0)};Ce.isFinite=function(){return!!this.d};Ce.isInteger=Ce.isInt=function(){return!!this.d&&In(this.e/lt)>this.d.length-2};Ce.isNaN=function(){return!this.s};Ce.isNegative=Ce.isNeg=function(){return this.s<0};Ce.isPositive=Ce.isPos=function(){return this.s>0};Ce.isZero=function(){return!!this.d&&this.d[0]===0};Ce.lessThan=Ce.lt=function(r){return this.cmp(r)<0};Ce.lessThanOrEqualTo=Ce.lte=function(r){return this.cmp(r)<1};Ce.logarithm=Ce.log=function(r){var e,t,n,s,i,a,o,l,c=this,f=c.constructor,p=f.precision,d=f.rounding,m=5;if(r==null)r=new f(10),e=!0;else{if(r=new f(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new f(NaN);e=r.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new f(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(s=t[0];s%10===0;)s/=10;i=s!==1}if(gt=!1,o=p+m,a=oo(c,o),n=e?Hy(f,o+10):oo(r,o),l=cr(a,n,o,1),i0(l.d,s=p,d))do if(o+=10,a=oo(c,o),n=e?Hy(f,o+10):oo(r,o),l=cr(a,n,o,1),!i){+yn(l.d).slice(s+1,s+15)+1==1e14&&(l=rt(l,p+1,0));break}while(i0(l.d,s+=10,d));return gt=!0,rt(l,p,d)};Ce.minus=Ce.sub=function(r){var e,t,n,s,i,a,o,l,c,f,p,d,m=this,g=m.constructor;if(r=new g(r),!m.d||!r.d)return!m.s||!r.s?r=new g(NaN):m.d?r.s=-r.s:r=new g(r.d||m.s!==r.s?m:NaN),r;if(m.s!=r.s)return r.s=-r.s,m.plus(r);if(c=m.d,d=r.d,o=g.precision,l=g.rounding,!c[0]||!d[0]){if(d[0])r.s=-r.s;else if(c[0])r=new g(m);else return new g(l===3?-0:0);return gt?rt(r,o,l):r}if(t=In(r.e/lt),f=In(m.e/lt),c=c.slice(),i=f-t,i){for(p=i<0,p?(e=c,i=-i,a=d.length):(e=d,t=f,a=c.length),n=Math.max(Math.ceil(o/lt),a)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=c.length,a=d.length,p=n<a,p&&(a=n),n=0;n<a;n++)if(c[n]!=d[n]){p=c[n]<d[n];break}i=0}for(p&&(e=c,c=d,d=e,r.s=-r.s),a=c.length,n=d.length-a;n>0;--n)c[a++]=0;for(n=d.length;n>i;){if(c[--n]<d[n]){for(s=n;s&&c[--s]===0;)c[s]=Ys-1;--c[s],c[n]+=Ys}c[n]-=d[n]}for(;c[--a]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(r.d=c,r.e=Xy(c,t),gt?rt(r,o,l):r):new g(l===3?-0:0)};Ce.modulo=Ce.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?rt(new n(t),n.precision,n.rounding):(gt=!1,n.modulo==9?(e=cr(t,r.abs(),0,3,1),e.s*=r.s):e=cr(t,r,0,n.modulo,1),e=e.times(r),gt=!0,t.minus(e))};Ce.naturalExponential=Ce.exp=function(){return xA(this)};Ce.naturalLogarithm=Ce.ln=function(){return oo(this)};Ce.negated=Ce.neg=function(){var r=new this.constructor(this);return r.s=-r.s,rt(r)};Ce.plus=Ce.add=function(r){var e,t,n,s,i,a,o,l,c,f,p=this,d=p.constructor;if(r=new d(r),!p.d||!r.d)return!p.s||!r.s?r=new d(NaN):p.d||(r=new d(r.d||p.s===r.s?p:NaN)),r;if(p.s!=r.s)return r.s=-r.s,p.minus(r);if(c=p.d,f=r.d,o=d.precision,l=d.rounding,!c[0]||!f[0])return f[0]||(r=new d(p)),gt?rt(r,o,l):r;if(i=In(p.e/lt),n=In(r.e/lt),c=c.slice(),s=i-n,s){for(s<0?(t=c,s=-s,a=f.length):(t=f,n=i,a=c.length),i=Math.ceil(o/lt),a=i>a?i+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=c.length,s=f.length,a-s<0&&(s=a,t=f,f=c,c=t),e=0;s;)e=(c[--s]=c[s]+f[s]+e)/Ys|0,c[s]%=Ys;for(e&&(c.unshift(e),++n),a=c.length;c[--a]==0;)c.pop();return r.d=c,r.e=Xy(c,n),gt?rt(r,o,l):r};Ce.precision=Ce.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(uo+r);return t.d?(e=JI(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};Ce.round=function(){var r=this,e=r.constructor;return rt(new e(r),r.e+1,e.rounding)};Ce.sine=Ce.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+lt,n.rounding=1,t=h6(n,eD(n,t)),n.precision=r,n.rounding=e,rt(aa>2?t.neg():t,r,e,!0)):new n(NaN)};Ce.squareRoot=Ce.sqrt=function(){var r,e,t,n,s,i,a=this,o=a.d,l=a.e,c=a.s,f=a.constructor;if(c!==1||!o||!o[0])return new f(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(gt=!1,c=Math.sqrt(+a),c==0||c==1/0?(e=yn(o),(e.length+l)%2==0&&(e+="0"),c=Math.sqrt(e),l=In((l+1)/2)-(l<0||l%2),c==1/0?e="5e"+l:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),n=new f(e)):n=new f(c.toString()),t=(l=f.precision)+3;;)if(i=n,n=i.plus(cr(a,i,t+2,1)).times(.5),yn(i.d).slice(0,t)===(e=yn(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(rt(i,l+1,0),i.times(i).eq(a))){n=i;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(rt(n,l+1,1),r=!n.times(n).eq(a));break}return gt=!0,rt(n,l,f.rounding,r)};Ce.tangent=Ce.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=cr(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,rt(aa==2||aa==4?t.neg():t,r,e,!0)):new n(NaN)};Ce.times=Ce.mul=function(r){var e,t,n,s,i,a,o,l,c,f=this,p=f.constructor,d=f.d,m=(r=new p(r)).d;if(r.s*=f.s,!d||!d[0]||!m||!m[0])return new p(!r.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?r.s/0:r.s*0);for(t=In(f.e/lt)+In(r.e/lt),l=d.length,c=m.length,l<c&&(i=d,d=m,m=i,a=l,l=c,c=a),i=[],a=l+c,n=a;n--;)i.push(0);for(n=c;--n>=0;){for(e=0,s=l+n;s>n;)o=i[s]+m[n]*d[s-n-1]+e,i[s--]=o%Ys|0,e=o/Ys|0;i[s]=(i[s]+e)%Ys|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),r.d=i,r.e=Xy(i,t),gt?rt(r,p.precision,p.rounding):r};Ce.toBinary=function(r,e){return bA(this,2,r,e)};Ce.toDecimalPlaces=Ce.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(Gn(r,0,lo),e===void 0?e=n.rounding:Gn(e,0,8),rt(t,r+t.e+1,e))};Ce.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Ei(n,!0):(Gn(r,0,lo),e===void 0?e=s.rounding:Gn(e,0,8),n=rt(new s(n),r+1,e),t=Ei(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};Ce.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=Ei(s):(Gn(r,0,lo),e===void 0?e=i.rounding:Gn(e,0,8),n=rt(new i(s),r+s.e+1,e),t=Ei(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};Ce.toFraction=function(r){var e,t,n,s,i,a,o,l,c,f,p,d,m=this,g=m.d,w=m.constructor;if(!g)return new w(m);if(c=t=new w(1),n=l=new w(0),e=new w(n),i=e.e=JI(g)-m.e-1,a=i%lt,e.d[0]=zr(10,a<0?lt+a:a),r==null)r=i>0?e:c;else{if(o=new w(r),!o.isInt()||o.lt(c))throw Error(uo+o);r=o.gt(e)?i>0?e:c:o}for(gt=!1,o=new w(yn(g)),f=w.precision,w.precision=i=g.length*lt*2;p=cr(o,e,0,1,1),s=t.plus(p.times(n)),s.cmp(r)!=1;)t=n,n=s,s=c,c=l.plus(p.times(s)),l=s,s=e,e=o.minus(p.times(s)),o=s;return s=cr(r.minus(t),n,0,1,1),l=l.plus(s.times(c)),t=t.plus(s.times(n)),l.s=c.s=m.s,d=cr(c,n,i,1).minus(m).abs().cmp(cr(l,t,i,1).minus(m).abs())<1?[c,n]:[l,t],w.precision=f,gt=!0,d};Ce.toHexadecimal=Ce.toHex=function(r,e){return bA(this,16,r,e)};Ce.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:Gn(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(gt=!1,t=cr(t,r,0,e,1).times(r),gt=!0,rt(t)):(r.s=t.s,t=r),t};Ce.toNumber=function(){return+this};Ce.toOctal=function(r,e){return bA(this,8,r,e)};Ce.toPower=Ce.pow=function(r){var e,t,n,s,i,a,o=this,l=o.constructor,c=+(r=new l(r));if(!o.d||!r.d||!o.d[0]||!r.d[0])return new l(zr(+o,c));if(o=new l(o),o.eq(1))return o;if(n=l.precision,i=l.rounding,r.eq(1))return rt(o,n,i);if(e=In(r.e/lt),e>=r.d.length-1&&(t=c<0?-c:c)<=u6)return s=YI(l,o,t,n),r.s<0?new l(1).div(s):rt(s,n,i);if(a=o.s,a<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(a=1),o.e==0&&o.d[0]==1&&o.d.length==1)return o.s=a,o}return t=zr(+o,c),e=t==0||!isFinite(t)?In(c*(Math.log("0."+yn(o.d))/Math.LN10+o.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(gt=!1,l.rounding=o.s=1,t=Math.min(12,(e+"").length),s=xA(r.times(oo(o,n+t)),n),s.d&&(s=rt(s,n+5,1),i0(s.d,n,i)&&(e=n+10,s=rt(xA(r.times(oo(o,e+t)),e),e+5,1),+yn(s.d).slice(n+1,n+15)+1==1e14&&(s=rt(s,n+1,0)))),s.s=a,gt=!0,l.rounding=i,rt(s,n,i))};Ce.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Ei(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(Gn(r,1,lo),e===void 0?e=s.rounding:Gn(e,0,8),n=rt(new s(n),r,e),t=Ei(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};Ce.toSignificantDigits=Ce.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(Gn(r,1,lo),e===void 0?e=n.rounding:Gn(e,0,8)),rt(new n(t),r,e)};Ce.toString=function(){var r=this,e=r.constructor,t=Ei(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};Ce.truncated=Ce.trunc=function(){return rt(new this.constructor(this),this.e+1,1)};Ce.valueOf=Ce.toJSON=function(){var r=this,e=r.constructor,t=Ei(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function yn(r){var e,t,n,s=r.length-1,i="",a=r[0];if(s>0){for(i+=a,e=1;e<s;e++)n=r[e]+"",t=lt-n.length,t&&(i+=ao(t)),i+=n;a=r[e],n=a+"",t=lt-n.length,t&&(i+=ao(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}u(yn,"digitsToString");function Gn(r,e,t){if(r!==~~r||r<e||r>t)throw Error(uo+r)}u(Gn,"checkInt32");function i0(r,e,t,n){var s,i,a,o;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=lt,s=0):(s=Math.ceil((e+1)/lt),e%=lt),i=zr(10,lt-e),o=r[s]%i|0,n==null?e<3?(e==0?o=o/100|0:e==1&&(o=o/10|0),a=t<4&&o==99999||t>3&&o==49999||o==5e4||o==0):a=(t<4&&o+1==i||t>3&&o+1==i/2)&&(r[s+1]/i/100|0)==zr(10,e-2)-1||(o==i/2||o==0)&&(r[s+1]/i/100|0)==0:e<4?(e==0?o=o/1e3|0:e==1?o=o/100|0:e==2&&(o=o/10|0),a=(n||t<4)&&o==9999||!n&&t>3&&o==4999):a=((n||t<4)&&o+1==i||!n&&t>3&&o+1==i/2)&&(r[s+1]/i/1e3|0)==zr(10,e-3)-1,a}u(i0,"checkRoundingDigits");function Fy(r,e,t){for(var n,s=[0],i,a=0,o=r.length;a<o;){for(i=s.length;i--;)s[i]*=e;for(s[0]+=SA.indexOf(r.charAt(a++)),n=0;n<s.length;n++)s[n]>t-1&&(s[n+1]===void 0&&(s[n+1]=0),s[n+1]+=s[n]/t|0,s[n]%=t)}return s.reverse()}u(Fy,"convertBase");function c6(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/$y(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=vf(r,1,e.times(s),new r(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return r.precision-=t,e}u(c6,"cosine");var cr=(function(){function r(n,s,i){var a,o=0,l=n.length;for(n=n.slice();l--;)a=n[l]*s+o,n[l]=a%i|0,o=a/i|0;return o&&n.unshift(o),n}u(r,"multiplyInteger");function e(n,s,i,a){var o,l;if(i!=a)l=i>a?1:-1;else for(o=l=0;o<i;o++)if(n[o]!=s[o]){l=n[o]>s[o]?1:-1;break}return l}u(e,"compare");function t(n,s,i,a){for(var o=0;i--;)n[i]-=o,o=n[i]<s[i]?1:0,n[i]=o*a+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return u(t,"subtract"),function(n,s,i,a,o,l){var c,f,p,d,m,g,w,y,S,C,E,v,A,x,F,D,B,V,U,q,ie=n.constructor,Y=n.s==s.s?1:-1,se=n.d,$=s.d;if(!se||!se[0]||!$||!$[0])return new ie(!n.s||!s.s||(se?$&&se[0]==$[0]:!$)?NaN:se&&se[0]==0||!$?Y*0:Y/0);for(l?(m=1,f=n.e-s.e):(l=Ys,m=lt,f=In(n.e/m)-In(s.e/m)),U=$.length,B=se.length,S=new ie(Y),C=S.d=[],p=0;$[p]==(se[p]||0);p++);if($[p]>(se[p]||0)&&f--,i==null?(x=i=ie.precision,a=ie.rounding):o?x=i+(n.e-s.e)+1:x=i,x<0)C.push(1),g=!0;else{if(x=x/m+2|0,p=0,U==1){for(d=0,$=$[0],x++;(p<B||d)&&x--;p++)F=d*l+(se[p]||0),C[p]=F/$|0,d=F%$|0;g=d||p<B}else{for(d=l/($[0]+1)|0,d>1&&($=r($,d,l),se=r(se,d,l),U=$.length,B=se.length),D=U,E=se.slice(0,U),v=E.length;v<U;)E[v++]=0;q=$.slice(),q.unshift(0),V=$[0],$[1]>=l/2&&++V;do d=0,c=e($,E,U,v),c<0?(A=E[0],U!=v&&(A=A*l+(E[1]||0)),d=A/V|0,d>1?(d>=l&&(d=l-1),w=r($,d,l),y=w.length,v=E.length,c=e(w,E,y,v),c==1&&(d--,t(w,U<y?q:$,y,l))):(d==0&&(c=d=1),w=$.slice()),y=w.length,y<v&&w.unshift(0),t(E,w,v,l),c==-1&&(v=E.length,c=e($,E,U,v),c<1&&(d++,t(E,U<v?q:$,v,l))),v=E.length):c===0&&(d++,E=[0]),C[p++]=d,c&&E[0]?E[v++]=se[D]||0:(E=[se[D]],v=1);while((D++<B||E[0]!==void 0)&&x--);g=E[0]!==void 0}C[0]||C.shift()}if(m==1)S.e=f,XI=g;else{for(p=1,d=C[0];d>=10;d/=10)p++;S.e=p+f*m-1,rt(S,o?i+S.e+1:i,a,g)}return S}})();function rt(r,e,t,n){var s,i,a,o,l,c,f,p,d,m=r.constructor;e:if(e!=null){if(p=r.d,!p)return r;for(s=1,o=p[0];o>=10;o/=10)s++;if(i=e-s,i<0)i+=lt,a=e,f=p[d=0],l=f/zr(10,s-a-1)%10|0;else if(d=Math.ceil((i+1)/lt),o=p.length,d>=o)if(n){for(;o++<=d;)p.push(0);f=l=0,s=1,i%=lt,a=i-lt+1}else break e;else{for(f=o=p[d],s=1;o>=10;o/=10)s++;i%=lt,a=i-lt+s,l=a<0?0:f/zr(10,s-a-1)%10|0}if(n=n||e<0||p[d+1]!==void 0||(a<0?f:f%zr(10,s-a-1)),c=t<4?(l||n)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||n||t==6&&(i>0?a>0?f/zr(10,s-a):0:p[d-1])%10&1||t==(r.s<0?8:7)),e<1||!p[0])return p.length=0,c?(e-=r.e+1,p[0]=zr(10,(lt-e%lt)%lt),r.e=-e||0):p[0]=r.e=0,r;if(i==0?(p.length=d,o=1,d--):(p.length=d+1,o=zr(10,lt-i),p[d]=a>0?(f/zr(10,s-a)%zr(10,a)|0)*o:0),c)for(;;)if(d==0){for(i=1,a=p[0];a>=10;a/=10)i++;for(a=p[0]+=o,o=1;a>=10;a/=10)o++;i!=o&&(r.e++,p[0]==Ys&&(p[0]=1));break}else{if(p[d]+=o,p[d]!=Ys)break;p[d--]=0,o=1}for(i=p.length;p[--i]===0;)p.pop()}return gt&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}u(rt,"finalise");function Ei(r,e,t){if(!r.isFinite())return ZI(r);var n,s=r.e,i=yn(r.d),a=i.length;return e?(t&&(n=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+ao(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+ao(-s-1)+i,t&&(n=t-a)>0&&(i+=ao(n))):s>=a?(i+=ao(s+1-a),t&&(n=t-s-1)>0&&(i=i+"."+ao(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-a)>0&&(s+1===a&&(i+="."),i+=ao(n))),i}u(Ei,"finiteToString");function Xy(r,e){var t=r[0];for(e*=lt;t>=10;t/=10)e++;return e}u(Xy,"getBase10Exponent");function Hy(r,e,t){if(e>l6)throw gt=!0,t&&(r.precision=t),Error($I);return rt(new r(jy),e,1,!0)}u(Hy,"getLn10");function vi(r,e,t){if(e>CA)throw Error($I);return rt(new r(qy),e,t,!0)}u(vi,"getPi");function JI(r){var e=r.length-1,t=e*lt+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}u(JI,"getPrecision");function ao(r){for(var e="";r--;)e+="0";return e}u(ao,"getZeroString");function YI(r,e,t,n){var s,i=new r(1),a=Math.ceil(n/lt+4);for(gt=!1;;){if(t%2&&(i=i.times(e),HI(i.d,a)&&(s=!0)),t=In(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),HI(e.d,a)}return gt=!0,i}u(YI,"intPow");function qI(r){return r.d[r.d.length-1]&1}u(qI,"isOdd");function QI(r,e,t){for(var n,s,i=new r(e[0]),a=0;++a<e.length;){if(s=new r(e[a]),!s.s){i=s;break}n=i.cmp(s),(n===t||n===0&&i.s===t)&&(i=s)}return i}u(QI,"maxOrMin");function xA(r,e){var t,n,s,i,a,o,l,c=0,f=0,p=0,d=r.constructor,m=d.rounding,g=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(gt=!1,l=g):l=e,o=new d(.03125);r.e>-2;)r=r.times(o),p+=5;for(n=Math.log(zr(2,p))/Math.LN10*2+5|0,l+=n,t=i=a=new d(1),d.precision=l;;){if(i=rt(i.times(r),l,1),t=t.times(++f),o=a.plus(cr(i,t,l,1)),yn(o.d).slice(0,l)===yn(a.d).slice(0,l)){for(s=p;s--;)a=rt(a.times(a),l,1);if(e==null)if(c<3&&i0(a.d,l-n,m,c))d.precision=l+=10,t=i=o=new d(1),f=0,c++;else return rt(a,d.precision=g,m,gt=!0);else return d.precision=g,a}a=o}}u(xA,"naturalExponential");function oo(r,e){var t,n,s,i,a,o,l,c,f,p,d,m=1,g=10,w=r,y=w.d,S=w.constructor,C=S.rounding,E=S.precision;if(w.s<0||!y||!y[0]||!w.e&&y[0]==1&&y.length==1)return new S(y&&!y[0]?-1/0:w.s!=1?NaN:y?0:w);if(e==null?(gt=!1,f=E):f=e,S.precision=f+=g,t=yn(y),n=t.charAt(0),Math.abs(i=w.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)w=w.times(r),t=yn(w.d),n=t.charAt(0),m++;i=w.e,n>1?(w=new S("0."+t),i++):w=new S(n+"."+t.slice(1))}else return c=Hy(S,f+2,E).times(i+""),w=oo(new S(n+"."+t.slice(1)),f-g).plus(c),S.precision=E,e==null?rt(w,E,C,gt=!0):w;for(p=w,l=a=w=cr(w.minus(1),w.plus(1),f,1),d=rt(w.times(w),f,1),s=3;;){if(a=rt(a.times(d),f,1),c=l.plus(cr(a,new S(s),f,1)),yn(c.d).slice(0,f)===yn(l.d).slice(0,f))if(l=l.times(2),i!==0&&(l=l.plus(Hy(S,f+2,E).times(i+""))),l=cr(l,new S(m),f,1),e==null)if(i0(l.d,f-g,C,o))S.precision=f+=g,c=a=w=cr(p.minus(1),p.plus(1),f,1),d=rt(w.times(w),f,1),s=o=1;else return rt(l,S.precision=E,C,gt=!0);else return S.precision=E,l;l=c,s+=2}}u(oo,"naturalLogarithm");function ZI(r){return String(r.s*r.s/0)}u(ZI,"nonFiniteToString");function My(r,e){var t,n,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(n,s),e){if(s-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%lt,t<0&&(n+=lt),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=lt;n<s;)r.d.push(+e.slice(n,n+=lt));e=e.slice(n),n=lt-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),gt&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}u(My,"parseDecimal");function f6(r,e){var t,n,s,i,a,o,l,c,f;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),zI.test(e))return My(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(a6.test(e))t=16,e=e.toLowerCase();else if(i6.test(e))t=2;else if(o6.test(e))t=8;else throw Error(uo+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,n=r.constructor,a&&(e=e.replace(".",""),o=e.length,i=o-i,s=YI(n,new n(t),i,i*2)),c=Fy(e,t,Ys),f=c.length-1,i=f;c[i]===0;--i)c.pop();return i<0?new n(r.s*0):(r.e=Xy(c,f),r.d=c,gt=!1,a&&(r=cr(r,s,o*4)),l&&(r=r.times(Math.abs(l)<54?zr(2,l):Ef.pow(2,l))),gt=!0,r)}u(f6,"parseOther");function h6(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:vf(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/$y(5,t)),e=vf(r,2,e,e);for(var s,i=new r(5),a=new r(16),o=new r(20);t--;)s=e.times(e),e=e.times(i.plus(s.times(a.times(s).minus(o))));return e}u(h6,"sine");function vf(r,e,t,n,s){var i,a,o,l,c=1,f=r.precision,p=Math.ceil(f/lt);for(gt=!1,l=t.times(t),o=new r(n);;){if(a=cr(o.times(l),new r(e++*e++),f,1),o=s?n.plus(a):n.minus(a),n=cr(a.times(l),new r(e++*e++),f,1),a=o.plus(n),a.d[p]!==void 0){for(i=p;a.d[i]===o.d[i]&&i--;);if(i==-1)break}i=o,o=n,n=a,a=i,c++}return gt=!0,a.d.length=p+1,a}u(vf,"taylorSeries");function $y(r,e){for(var t=r;--e;)t*=r;return t}u($y,"tinyPow");function eD(r,e){var t,n=e.s<0,s=vi(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return aa=n?4:1,e;if(t=e.divToInt(s),t.isZero())aa=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return aa=qI(t)?n?2:3:n?4:1,e;aa=qI(t)?n?1:4:n?3:2}return e.minus(s).abs()}u(eD,"toLessThanHalfPi");function bA(r,e,t,n){var s,i,a,o,l,c,f,p,d,m=r.constructor,g=t!==void 0;if(g?(Gn(t,1,lo),n===void 0?n=m.rounding:Gn(n,0,8)):(t=m.precision,n=m.rounding),!r.isFinite())f=ZI(r);else{for(f=Ei(r),a=f.indexOf("."),g?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(f=f.replace(".",""),d=new m(1),d.e=f.length-a,d.d=Fy(Ei(d),10,s),d.e=d.d.length),p=Fy(f,10,s),i=l=p.length;p[--l]==0;)p.pop();if(!p[0])f=g?"0p+0":"0";else{if(a<0?i--:(r=new m(r),r.d=p,r.e=i,r=cr(r,d,t,n,0,s),p=r.d,i=r.e,c=XI),a=p[t],o=s/2,c=c||p[t+1]!==void 0,c=n<4?(a!==void 0||c)&&(n===0||n===(r.s<0?3:2)):a>o||a===o&&(n===4||c||n===6&&p[t-1]&1||n===(r.s<0?8:7)),p.length=t,c)for(;++p[--t]>s-1;)p[t]=0,t||(++i,p.unshift(1));for(l=p.length;!p[l-1];--l);for(a=0,f="";a<l;a++)f+=SA.charAt(p[a]);if(g){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)f+="0";for(p=Fy(f,s,e),l=p.length;!p[l-1];--l);for(a=1,f="1.";a<l;a++)f+=SA.charAt(p[a])}else f=f.charAt(0)+"."+f.slice(1);f=f+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)f="0"+f;f="0."+f}else if(++i>l)for(i-=l;i--;)f+="0";else i<l&&(f=f.slice(0,i)+"."+f.slice(i))}f=(e==16?"0x":e==2?"0b":e==8?"0o":"")+f}return r.s<0?"-"+f:f}u(bA,"toStringBinary");function HI(r,e){if(r.length>e)return r.length=e,!0}u(HI,"truncate");function p6(r){return new this(r).abs()}u(p6,"abs");function d6(r){return new this(r).acos()}u(d6,"acos");function m6(r){return new this(r).acosh()}u(m6,"acosh");function g6(r,e){return new this(r).plus(e)}u(g6,"add");function y6(r){return new this(r).asin()}u(y6,"asin");function v6(r){return new this(r).asinh()}u(v6,"asinh");function E6(r){return new this(r).atan()}u(E6,"atan");function w6(r){return new this(r).atanh()}u(w6,"atanh");function S6(r,e){r=new this(r),e=new this(e);var t,n=this.precision,s=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=vi(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?vi(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=vi(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(cr(r,e,i,1)),e=vi(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(cr(r,e,i,1)),t}u(S6,"atan2");function A6(r){return new this(r).cbrt()}u(A6,"cbrt");function C6(r){return rt(r=new this(r),r.e+1,2)}u(C6,"ceil");function x6(r,e,t){return new this(r).clamp(e,t)}u(x6,"clamp");function b6(r){if(!r||typeof r!="object")throw Error(Ky+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,lo,"rounding",0,8,"toExpNeg",-yf,0,"toExpPos",0,yf,"maxE",0,yf,"minE",-yf,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=AA[t]),(n=r[t])!==void 0)if(In(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(uo+t+": "+n);if(t="crypto",s&&(this[t]=AA[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(GI);else this[t]=!1;else throw Error(uo+t+": "+n);return this}u(b6,"config");function N6(r){return new this(r).cos()}u(N6,"cos");function T6(r){return new this(r).cosh()}u(T6,"cosh");function tD(r){var e,t,n;function s(i){var a,o,l,c=this;if(!(c instanceof s))return new s(i);if(c.constructor=s,KI(i)){c.s=i.s,gt?!i.d||i.e>s.maxE?(c.e=NaN,c.d=null):i.e<s.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(a=0,o=i;o>=10;o/=10)a++;gt?a>s.maxE?(c.e=NaN,c.d=null):a<s.minE?(c.e=0,c.d=[0]):(c.e=a,c.d=[i]):(c.e=a,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return My(c,i.toString())}if(l==="string")return(o=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(o===43&&(i=i.slice(1)),c.s=1),zI.test(i)?My(c,i):f6(c,i);if(l==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,My(c,i.toString());throw Error(uo+i)}if(u(s,"Decimal"),s.prototype=Ce,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=b6,s.clone=tD,s.isDecimal=KI,s.abs=p6,s.acos=d6,s.acosh=m6,s.add=g6,s.asin=y6,s.asinh=v6,s.atan=E6,s.atanh=w6,s.atan2=S6,s.cbrt=A6,s.ceil=C6,s.clamp=x6,s.cos=N6,s.cosh=T6,s.div=I6,s.exp=D6,s.floor=B6,s.hypot=R6,s.ln=O6,s.log=_6,s.log10=k6,s.log2=P6,s.max=L6,s.min=V6,s.mod=U6,s.mul=F6,s.pow=M6,s.random=j6,s.round=q6,s.sign=H6,s.sin=K6,s.sinh=X6,s.sqrt=$6,s.sub=G6,s.sum=W6,s.tan=z6,s.tanh=J6,s.trunc=Y6,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return s.config(r),s}u(tD,"clone");function I6(r,e){return new this(r).div(e)}u(I6,"div");function D6(r){return new this(r).exp()}u(D6,"exp");function B6(r){return rt(r=new this(r),r.e+1,3)}u(B6,"floor");function R6(){var r,e,t=new this(0);for(gt=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return gt=!0,new this(1/0);t=e}return gt=!0,t.sqrt()}u(R6,"hypot");function KI(r){return r instanceof Ef||r&&r.toStringTag===WI||!1}u(KI,"isDecimalInstance");function O6(r){return new this(r).ln()}u(O6,"ln");function _6(r,e){return new this(r).log(e)}u(_6,"log");function P6(r){return new this(r).log(2)}u(P6,"log2");function k6(r){return new this(r).log(10)}u(k6,"log10");function L6(){return QI(this,arguments,-1)}u(L6,"max");function V6(){return QI(this,arguments,1)}u(V6,"min");function U6(r,e){return new this(r).mod(e)}u(U6,"mod");function F6(r,e){return new this(r).mul(e)}u(F6,"mul");function M6(r,e){return new this(r).pow(e)}u(M6,"pow");function j6(r){var e,t,n,s,i=0,a=new this(1),o=[];if(r===void 0?r=this.precision:Gn(r,1,lo),n=Math.ceil(r/lt),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)s=e[i],s>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)s=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,i):(o.push(s%1e7),i+=4);i=n/4}else throw Error(GI);else for(;i<n;)o[i++]=Math.random()*1e7|0;for(n=o[--i],r%=lt,n&&r&&(s=zr(10,lt-r),o[i]=(n/s|0)*s);o[i]===0;i--)o.pop();if(i<0)t=0,o=[0];else{for(t=-1;o[0]===0;t-=lt)o.shift();for(n=1,s=o[0];s>=10;s/=10)n++;n<lt&&(t-=lt-n)}return a.e=t,a.d=o,a}u(j6,"random");function q6(r){return rt(r=new this(r),r.e+1,this.rounding)}u(q6,"round");function H6(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}u(H6,"sign");function K6(r){return new this(r).sin()}u(K6,"sin");function X6(r){return new this(r).sinh()}u(X6,"sinh");function $6(r){return new this(r).sqrt()}u($6,"sqrt");function G6(r,e){return new this(r).sub(e)}u(G6,"sub");function W6(){var r=0,e=arguments,t=new this(e[r]);for(gt=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return gt=!0,rt(t,this.precision,this.rounding)}u(W6,"sum");function z6(r){return new this(r).tan()}u(z6,"tan");function J6(r){return new this(r).tanh()}u(J6,"tanh");function Y6(r){return rt(r=new this(r),r.e+1,1)}u(Y6,"trunc");Ce[Symbol.for("nodejs.util.inspect.custom")]=Ce.toString;Ce[Symbol.toStringTag]="Decimal";var Ef=Ce.constructor=tD(AA);jy=new Ef(jy);qy=new Ef(qy);var wf=class r extends Ef{static{u(this,"Decimal")}static from(e){return new r(e)}static newOrZero(e){return e===void 0?r.from(0):r.from(e)}static newOrUndefined(e){if(e!==void 0)return r.from(e)}};import Q6 from"pdfkit";var rD=class r{static{u(this,"PdfkitPdfBuilder")}defaults={autoFirstPage:!1};doc=new Q6(this.defaults);constructor(e){e&&this.configure(e)}static new(e){return new r(e)}configure(e){return this.doc.options={...this.doc.options,...e},this}pipe(e){return this.doc.pipe(e),this}end(){return this.doc.end()}restore(){return this.doc.restore(),this}save(){return this.doc.save(),this}stroke(e){return this.doc.stroke(e),this}page(e){return this.doc.addPage(e),this}table(e){return this.doc.table(e),this}text(e,t){let{x:n,y:s,...i}=t??{};return n||s?(this.doc.text(e,n,s,i),this):(this.doc.text(e,t),this)}fontSize(e){return this.doc.fontSize(e),this}font(e,t,n){return typeof t=="string"?(this.doc.font(e,t,n),this):typeof t=="number"?(this.doc.font(e,t),this):(this.doc.font(e),this)}image(e,t,n,s){return typeof t=="number"&&typeof n=="number"?(this.doc.image(e,t,n,s),this):(this.doc.image(e,t),this)}rect(e,t,n,s){return this.doc.rect(e,t,n,s),this}roundedRect(e,t,n,s,i){return this.doc.roundedRect(e,t,n,s,i),this}path(e){return this.doc.path(e),this}translate(e,t){return this.doc.translate(e,t),this}scale(e,t){return this.doc.scale(e,t),this}rotate(e,t){return this.doc.rotate(e,t),this}moveTo(e,t){return this.doc.moveTo(e,t),this}lineTo(e,t){return this.doc.lineTo(e,t),this}lineWidth(e){return this.doc.lineWidth(e),this}dash(e,t){return this.doc.dash(e,t),this}undash(){return this.doc.undash(),this}fillColor(e,t){return this.doc.fillColor(e,t),this}strokeColor(e,t){return this.doc.strokeColor(e,t),this}fill(e,t){return this.doc.fill(e,t),this}pageWidth(){return this.doc.page.width}pageHeight(){return this.doc.page.height}heightOfString(e,t){return this.doc.heightOfString(e,t)}widthOfString(e,t){return this.doc.widthOfString(e,t)}pageMargins(){return this.doc.page.margins}currentLineHeight(e){return this.doc.currentLineHeight(e)}x(){return this.doc.x}y(){return this.doc.y}moveDown(e){return this.doc.moveDown(e),this}row(e,...t){let n,s;typeof e=="function"?(n={},s=[e,...t]):(n=e??{},s=t),n.columns??=1;let i=this.y(),a=n.right??0,o=n.left??0,l=n.gap??0,c=this.pageWidth(),f=c-o-a-l*(n.columns-1);n.size??=Array(n.columns).fill(12/n.columns);let p=[];for(let d=0;d<n.columns;d++){let m=n.size[d]/12;p[d]=f*m}for(let d=0,m=o;d<n.columns;d++){let g=d===n.columns-1,w=p[d];if(g&&n.columns>1){let C=c-a-m;C>0&&Math.abs(C-w)>.01&&(w=C)}let y={y:i,x:m,width:w};s[d](y),m+=w,l>0&&!g&&(m+=l)}return this}};var nD=class{static{u(this,"MemoryCacheAdapter")}cache=new Map;async get(e){return Promise.resolve(this.cache.get(e)??null)}has(e){return Promise.resolve(this.cache.has(e))}set(e,t){return this.cache.set(e,t),Promise.resolve(!0)}};var Co=Py(ER(),1);import Y9 from"os";import IR from"fs";import Q9 from"path";import A0 from"crypto";var V9=u(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessageInRecord"),ms=u(r=>typeof r=="string"?Jt(new Mt(r)):r instanceof Error?Jt(new Mt(r.message,{cause:r.cause})):V9(r)?Jt(new Mt(r.message)):Jt(new Mt("unexpected error")),"leftFromError");var bv=class{static{u(this,"NullCacheAdapter")}async get(e){return Promise.resolve(null)}has(e){return Promise.resolve(!1)}set(e,t){return Promise.resolve(!0)}};import{arch as H9,platform as NR}from"os";import{dirname as K9,join as X9,resolve as $9,normalize as G9,delimiter as W9}from"path";import{resolve as SR}from"path";import{createRequire as wR}from"module";import{fileURLToPath as U9,pathToFileURL as F9}from"url";var M9=typeof jest<"u"||process.env.JEST_WORKER_ID!==void 0,Lf,AR=u(()=>{if(Lf!==void 0)return Lf;if(M9){Lf=void 0;return}try{Lf=new Function("try { return import.meta.url; } catch { return undefined; }")()}catch{Lf=void 0}return Lf},"getImportMetaUrl"),CR=u(()=>{if(typeof ot<"u")return ot;let r=AR();if(r)return wR(r);let e=F9(SR(process.cwd(),"package.json")).href;return wR(e)},"getRequireFn"),xR=u(()=>{if(typeof __filename<"u")return __filename;let r=AR();return r?U9(r):SR(process.cwd())},"getCurrentFile");import{dirname as Nv,resolve as fl}from"path";import{existsSync as Vf}from"fs";var bR=u(()=>typeof process<"u"&&typeof process.versions<"u"&&"electron"in process.versions,"isElectron"),j9=u(()=>{if(!bR())return null;try{let e=ot("electron").app;if(e?.getAppPath&&typeof e.getAppPath=="function")return{getAppPath:e.getAppPath}}catch{}return null},"getElectronApp"),q9=u(()=>{if(!bR())return null;let r=process;if(r.resourcesPath)return r.resourcesPath;let e=j9();if(e)try{let t=e.getAppPath();if(typeof t=="string")return Nv(t.replace(/\.asar$/,""))}catch{}return null},"getElectronResourcesPath"),IC=u((r,{onFound:e,onNotFound:t})=>{let n=q9();if(n){let c=fl(n,"node_modules","nfets",r);if(Vf(c))return e(c);let f=fl(n,"app.asar.unpacked","node_modules","nfets",r);if(Vf(f))return e(f)}let s=xR(),i=s.includes(".asar")?process.cwd():s,a=fl(i,"../../../../"),o=fl(a,r);if(Vf(o))return e(o);let l=i;for(let c=0;c<5;c++){let f=fl(l,r);if(Vf(f))return e(f);let p=Nv(l);if(p===l)break;l=p}l=i;for(let c=0;c<5;c++){let f=fl(l,"node_modules","nfets",r);if(Vf(f))return e(f);let p=Nv(l);if(p===l)break;l=p}l=i;for(let c=0;c<5;c++){let f=fl(l,r.replace(/^build\//,"Release/"));if(Vf(f))return e(f);let p=Nv(l);if(p===l)break;l=p}return t()},"search");var z9=u(r=>{let e=r.replace(/^\\\\\?\\/,"");return $9(G9(e))},"normalizePath"),J9=u(r=>{NR()==="win32"&&(process.env.PATH=`${K9(r)}${W9}${process.env.PATH}`)},"addAddonDirToPath"),DC=u(r=>{let e=z9(r);return J9(e),CR()(e)},"exportRequireModule"),Uf=u(r=>{if(r=`${r}.node`,process.env.NFETS_ADDONS_DIR)return DC(X9(process.env.NFETS_ADDONS_DIR,r));let e=`${NR()}-${H9()}`;try{return IC(`build/addons/${e}/${r}`,{onFound:u(t=>DC(t),"onFound"),onNotFound:u(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}catch{return IC(`build/Release/${r}`,{onFound:u(t=>DC(t),"onFound"),onNotFound:u(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}},"addon");var Ao=class{static{u(this,"ASN1")}extractCertificateInfo(e){let n=e.subject.split(`
|
|
82
|
+
@#[line:`+r.lineNumber+",col:"+r.columnNumber+"]"}u(zZ,"_locator");function uV(r,e,t){return typeof r=="string"?r.substr(e,t):r.length>=e+t||e?new java.lang.String(r,e,t)+"":r}u(uV,"_toString");"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){hA.prototype[r]=function(){return null}});function fA(r,e){r.currentElement?r.currentElement.appendChild(e):r.doc.appendChild(e)}u(fA,"appendElement");function JZ(r){if(r==="error")throw"onErrorStopParsing"}u(JZ,"onErrorStopParsing");function YZ(){throw"onWarningStopParsing"}u(YZ,"onWarningStopParsing");Zd.__DOMHandler=hA;Zd.DOMParser=fV;Zd.normalizeLineEndings=cV;Zd.onErrorStopParsing=JZ;Zd.onWarningStopParsing=YZ});var pV=le($t=>{"use strict";var e0=hf();$t.assign=e0.assign;$t.hasDefaultHTMLNamespace=e0.hasDefaultHTMLNamespace;$t.isHTMLMimeType=e0.isHTMLMimeType;$t.isValidMimeType=e0.isValidMimeType;$t.MIME_TYPE=e0.MIME_TYPE;$t.NAMESPACE=e0.NAMESPACE;var pA=Sy();$t.DOMException=pA.DOMException;$t.DOMExceptionName=pA.DOMExceptionName;$t.ExceptionCode=pA.ExceptionCode;$t.ParseError=pA.ParseError;var tn=II();$t.Attr=tn.Attr;$t.CDATASection=tn.CDATASection;$t.CharacterData=tn.CharacterData;$t.Comment=tn.Comment;$t.Document=tn.Document;$t.DocumentFragment=tn.DocumentFragment;$t.DocumentType=tn.DocumentType;$t.DOMImplementation=tn.DOMImplementation;$t.Element=tn.Element;$t.Entity=tn.Entity;$t.EntityReference=tn.EntityReference;$t.LiveNodeList=tn.LiveNodeList;$t.NamedNodeMap=tn.NamedNodeMap;$t.Node=tn.Node;$t.NodeList=tn.NodeList;$t.Notation=tn.Notation;$t.ProcessingInstruction=tn.ProcessingInstruction;$t.Text=tn.Text;$t.XMLSerializer=tn.XMLSerializer;var dA=hV();$t.DOMParser=dA.DOMParser;$t.normalizeLineEndings=dA.normalizeLineEndings;$t.onErrorStopParsing=dA.onErrorStopParsing;$t.onWarningStopParsing=dA.onWarningStopParsing});var gA="http://www.w3.org/2000/09/xmldsig#",kI="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",yA=(function(r){return r.RSA_SHA1="http://www.w3.org/2000/09/xmldsig#rsa-sha1",r.RSA_SHA256="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",r})({}),io=(function(r){return r.SHA1="sha1",r.SHA256="sha256",r})({}),vA=(function(r){return r.SHA1="http://www.w3.org/2000/09/xmldsig#sha1",r.SHA256="http://www.w3.org/2001/04/xmlenc#sha256",r})({});var sr={AC:"12",AL:"27",AM:"13",AP:"16",BA:"29",CE:"23",DF:"53",ES:"32",GO:"52",MA:"21",MG:"31",MS:"50",MT:"51",PA:"15",PB:"25",PE:"26",PI:"22",PR:"41",RJ:"33",RN:"24",RO:"11",RR:"14",RS:"43",SC:"42",SE:"28",SP:"35",TO:"17"},iee=Object.keys(sr);var oee={Production:"1",Homolog:"2"};var r6={[sr.AC]:"America/Rio_Branco",[sr.AL]:"America/Maceio",[sr.AM]:"America/Manaus",[sr.AP]:"America/Belem",[sr.BA]:"America/Bahia",[sr.CE]:"America/Fortaleza",[sr.DF]:"America/Sao_Paulo",[sr.ES]:"America/Sao_Paulo",[sr.GO]:"America/Sao_Paulo",[sr.MA]:"America/Fortaleza",[sr.MG]:"America/Sao_Paulo",[sr.MS]:"America/Campo_Grande",[sr.MT]:"America/Cuiaba",[sr.PA]:"America/Belem",[sr.PB]:"America/Fortaleza",[sr.PE]:"America/Recife",[sr.PI]:"America/Fortaleza",[sr.PR]:"America/Sao_Paulo",[sr.RJ]:"America/Sao_Paulo",[sr.RN]:"America/Fortaleza",[sr.RO]:"America/Porto_Velho",[sr.RR]:"America/Boa_Vista",[sr.RS]:"America/Sao_Paulo",[sr.SC]:"America/Sao_Paulo",[sr.SE]:"America/Maceio",[sr.SP]:"America/Sao_Paulo",[sr.TO]:"America/Araguaina"};var Mt=class extends Error{static{u(this,"NFeTsError")}};var Ly=class extends Mt{static{u(this,"TransmissionError")}},el=class extends Ly{static{u(this,"TransmissionHostNotFoundError")}},tl=class extends Ly{static{u(this,"TransmissionTimeoutError")}};var LI=class extends Mt{static{u(this,"ValidationError")}};var n0={includeComments:!1,exclusive:!0};var EA=u(r=>{throw new Mt("Didn't expect to get here")},"unreachable");var gf=class{static{u(this,"Signer")}toolkit;certificateRepository;algorithm;canonical;constructor(e,t,n=io.SHA1,s=n0){this.toolkit=e,this.certificateRepository=t,this.algorithm=n,this.canonical=s}assemble(e,t,n){let s=this.certificateRepository.getStringCertificate(n);return{$:{xmlns:gA},SignedInfo:e,SignatureValue:t,KeyInfo:{X509Data:{X509Certificate:s}}}}signedInfo(e,t){return{CanonicalizationMethod:{$:{Algorithm:kI}},SignatureMethod:{$:{Algorithm:this.signatureMethod}},Reference:{$:{URI:`#${this.toolkit.getAttribute(e,t)}`},Transforms:this.transforms,DigestMethod:{$:{Algorithm:this.digestAlgorithm}},DigestValue:this.digest(e)}}}digest(e){return this.toolkit.digest(e,this.algorithm,this.canonical)}async signOrLeft(e,t){let n=this.toolkit.canonicalize(await this.toolkit.build({$:{xmlns:gA},...e},{rootName:"SignedInfo"}),this.canonical);return this.certificateRepository.sign(n,t,this.algorithm)}get transforms(){return{Transform:[{$:{Algorithm:"http://www.w3.org/2000/09/xmldsig#enveloped-signature"}},{$:{Algorithm:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"}}]}}get digestAlgorithm(){switch(this.algorithm){case io.SHA256:return vA.SHA256;case io.SHA1:return vA.SHA1;default:return EA(this.algorithm)}}get signatureMethod(){switch(this.algorithm){case io.SHA256:return yA.RSA_SHA256;case io.SHA1:return yA.RSA_SHA1;default:return EA(this.algorithm)}}};var wA=class{static{u(this,"Left")}value;constructor(e){this.value=e}isLeft(){return!0}isRight(){return!1}},Vy=class{static{u(this,"Right")}value;constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}},Jt=u(r=>new wA(r),"left"),Wr=u(r=>r===void 0?new Vy(void 0):new Vy(r),"right");var VI=class extends gf{static{u(this,"EntitySigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n;if(!e[s])return Jt(new Mt(`Node ${String(s)} not found`));let o=await this.toolkit.build(this.ns(e,s),{headless:!0,rootName:String(s),renderOpts:{pretty:!1}}),l=this.signedInfo(o,i),c=await this.signOrLeft(l,n);if(c.isLeft())return c;let f=e;return f.Signature=this.assemble(l,c.value,a),Wr(f)}ns(e,t){let n=e.$?.xmlns,{$:s,...i}=e[t],{xmlns:a,...o}=s??{};return{$:{xmlns:n,...o},...i}}};var UI=class extends gf{static{u(this,"XmlSigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n,o=this.toolkit.getNode(e,s);if(!o)return Jt(new Mt(`Node ${s} not found`));let l=this.signedInfo(o,i),c=await this.signOrLeft(l,n);if(c.isLeft())return c;let f=await this.toolkit.build(this.assemble(l,c.value,a),{rootName:"Signature"});return Wr(this.toolkit.appendNode(e,f))}};import"reflect-metadata";import{validateSync as s6}from"class-validator";import"reflect-metadata";var s0="__SkipValidation__",nte=u(()=>(r,e)=>{Reflect.defineMetadata(s0,!0,r,e.toString())},"SkipValidation"),ste=u(()=>r=>{Reflect.defineMetadata(s0,!0,r)},"SkipAllValidations");import{plainToInstance as n6}from"class-transformer";var Uy=u(r=>{for(let[e,t]of Object.entries(r))typeof t>"u"&&delete r[e],t===""&&delete r[e],t&&typeof t=="object"&&Uy(t)},"clearEmptyValues"),FI=u((r,e,t={})=>{let n=n6(e,r);return t.clearEmptyValues&&Uy(n),n},"plainToInstance");var MI="__ValidateErrors__",jI=u((r,e)=>r.reduce((t,n)=>{if(n.children?.length)return t.concat(jI(n.children,e?`${e}.${n.property}`:n.property));let s=Object.values(n.constraints??{}).map(i=>e?`${e}.${i}`:i).join(", ");return s?t.concat(s):t},[]),"mapConstraintsToErrors"),dte=u((r,e)=>(t,n,s)=>{let i=s.value;if(i==null)return;let a=u((o,l,c)=>{let f=FI(l,r),p=s6(f,{whitelist:!0});if(Uy(f),p.length){let d=Reflect.getMetadata(MI,o)??[];Reflect.defineMetadata(MI,d.concat(jI(p,c)),o)}return f},"validate");s.value=function(...o){let l=Reflect.getMetadata(s0,this.constructor);if(Reflect.getMetadata(s0,this.constructor.prototype,n.toString())===!0||l===!0)return i.apply(this,o);let[f,...p]=o;if(!f)return i.apply(this,o);let d=e?.each&&Array.isArray(f)?f.map((m,g)=>a(this,m,`${i.name}.${g}`)):a(this,f,i.name);return i.apply(this,[d,...p])}},"Validates");import"reflect-metadata";var yf=9e15,lo=1e9,SA="0123456789abcdef",jy="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",qy="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",AA={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-yf,maxE:yf,crypto:!1},XI,aa,gt=!0,Ky="[DecimalError] ",uo=Ky+"Invalid argument: ",$I=Ky+"Precision limit exceeded",GI=Ky+"crypto unavailable",WI="[object Decimal]",In=Math.floor,zr=Math.pow,i6=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,a6=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,o6=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,zI=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ys=1e7,lt=7,u6=9007199254740991,l6=jy.length-1,CA=qy.length-1,Ce={toStringTag:WI};Ce.absoluteValue=Ce.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),rt(r)};Ce.ceil=function(){return rt(new this.constructor(this),this.e+1,2)};Ce.clampedTo=Ce.clamp=function(r,e){var t,n=this,s=n.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(uo+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};Ce.comparedTo=Ce.cmp=function(r){var e,t,n,s,i=this,a=i.d,o=(r=new i.constructor(r)).d,l=i.s,c=r.s;if(!a||!o)return!l||!c?NaN:l!==c?l:a===o?0:!a^l<0?1:-1;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(n=a.length,s=o.length,e=0,t=n<s?n:s;e<t;++e)if(a[e]!==o[e])return a[e]>o[e]^l<0?1:-1;return n===s?0:n>s^l<0?1:-1};Ce.cosine=Ce.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+lt,n.rounding=1,t=c6(n,eD(n,t)),n.precision=r,n.rounding=e,rt(aa==2||aa==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};Ce.cubeRoot=Ce.cbrt=function(){var r,e,t,n,s,i,a,o,l,c,f=this,p=f.constructor;if(!f.isFinite()||f.isZero())return new p(f);for(gt=!1,i=f.s*zr(f.s*f,1/3),!i||Math.abs(i)==1/0?(t=yn(f.d),r=f.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=zr(t,1/3),r=In((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new p(t),n.s=f.s):n=new p(i.toString()),a=(r=p.precision)+3;;)if(o=n,l=o.times(o).times(o),c=l.plus(f),n=cr(c.plus(f).times(o),c.plus(l),a+2,1),yn(o.d).slice(0,a)===(t=yn(n.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(rt(o,r+1,0),o.times(o).times(o).eq(f))){n=o;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(rt(n,r+1,1),e=!n.times(n).times(n).eq(f));break}return gt=!0,rt(n,r,p.rounding,e)};Ce.decimalPlaces=Ce.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-In(this.e/lt))*lt,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};Ce.dividedBy=Ce.div=function(r){return cr(this,new this.constructor(r))};Ce.dividedToIntegerBy=Ce.divToInt=function(r){var e=this,t=e.constructor;return rt(cr(e,new t(r),0,1,1),t.precision,t.rounding)};Ce.equals=Ce.eq=function(r){return this.cmp(r)===0};Ce.floor=function(){return rt(new this.constructor(this),this.e+1,3)};Ce.greaterThan=Ce.gt=function(r){return this.cmp(r)>0};Ce.greaterThanOrEqualTo=Ce.gte=function(r){var e=this.cmp(r);return e==1||e===0};Ce.hyperbolicCosine=Ce.cosh=function(){var r,e,t,n,s,i=this,a=i.constructor,o=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return o;t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,s=i.d.length,s<32?(r=Math.ceil(s/3),e=(1/$y(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=vf(a,1,i.times(e),new a(1),!0);for(var l,c=r,f=new a(8);c--;)l=i.times(i),i=o.minus(l.times(f.minus(l.times(f))));return rt(i,a.precision=t,a.rounding=n,!0)};Ce.hyperbolicSine=Ce.sinh=function(){var r,e,t,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(s.e,s.sd())+4,i.rounding=1,n=s.d.length,n<3)s=vf(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/$y(5,r)),s=vf(i,2,s,s,!0);for(var a,o=new i(5),l=new i(16),c=new i(20);r--;)a=s.times(s),s=s.times(o.plus(a.times(l.times(a).plus(c))))}return i.precision=e,i.rounding=t,rt(s,e,t,!0)};Ce.hyperbolicTangent=Ce.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,cr(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};Ce.inverseCosine=Ce.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,s=e.rounding;return t!==-1?t===0?r.isNeg()?vi(e,n,s):new e(0):new e(NaN):r.isZero()?vi(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=s,r.times(2))};Ce.inverseHyperbolicCosine=Ce.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,gt=!1,t=t.times(t).minus(1).sqrt().plus(t),gt=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};Ce.inverseHyperbolicSine=Ce.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,gt=!1,t=t.times(t).plus(1).sqrt().plus(t),gt=!0,n.precision=r,n.rounding=e,t.ln())};Ce.inverseHyperbolicTangent=Ce.atanh=function(){var r,e,t,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=i.precision,e=i.rounding,n=s.sd(),Math.max(n,r)<2*-s.e-1?rt(new i(s),r,e,!0):(i.precision=t=n-s.e,s=cr(s.plus(1),new i(1).minus(s),t+r,1),i.precision=r+4,i.rounding=1,s=s.ln(),i.precision=r,i.rounding=e,s.times(.5))):new i(NaN)};Ce.inverseSine=Ce.asin=function(){var r,e,t,n,s=this,i=s.constructor;return s.isZero()?new i(s):(e=s.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=vi(i,t+4,n).times(.5),r.s=s.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,s.times(2)))};Ce.inverseTangent=Ce.atan=function(){var r,e,t,n,s,i,a,o,l,c=this,f=c.constructor,p=f.precision,d=f.rounding;if(c.isFinite()){if(c.isZero())return new f(c);if(c.abs().eq(1)&&p+4<=CA)return a=vi(f,p+4,d).times(.25),a.s=c.s,a}else{if(!c.s)return new f(NaN);if(p+4<=CA)return a=vi(f,p+4,d).times(.5),a.s=c.s,a}for(f.precision=o=p+10,f.rounding=1,t=Math.min(28,o/lt+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(gt=!1,e=Math.ceil(o/lt),n=1,l=c.times(c),a=new f(c),s=c;r!==-1;)if(s=s.times(l),i=a.minus(s.div(n+=2)),s=s.times(l),a=i.plus(s.div(n+=2)),a.d[e]!==void 0)for(r=e;a.d[r]===i.d[r]&&r--;);return t&&(a=a.times(2<<t-1)),gt=!0,rt(a,f.precision=p,f.rounding=d,!0)};Ce.isFinite=function(){return!!this.d};Ce.isInteger=Ce.isInt=function(){return!!this.d&&In(this.e/lt)>this.d.length-2};Ce.isNaN=function(){return!this.s};Ce.isNegative=Ce.isNeg=function(){return this.s<0};Ce.isPositive=Ce.isPos=function(){return this.s>0};Ce.isZero=function(){return!!this.d&&this.d[0]===0};Ce.lessThan=Ce.lt=function(r){return this.cmp(r)<0};Ce.lessThanOrEqualTo=Ce.lte=function(r){return this.cmp(r)<1};Ce.logarithm=Ce.log=function(r){var e,t,n,s,i,a,o,l,c=this,f=c.constructor,p=f.precision,d=f.rounding,m=5;if(r==null)r=new f(10),e=!0;else{if(r=new f(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new f(NaN);e=r.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new f(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(s=t[0];s%10===0;)s/=10;i=s!==1}if(gt=!1,o=p+m,a=oo(c,o),n=e?Hy(f,o+10):oo(r,o),l=cr(a,n,o,1),i0(l.d,s=p,d))do if(o+=10,a=oo(c,o),n=e?Hy(f,o+10):oo(r,o),l=cr(a,n,o,1),!i){+yn(l.d).slice(s+1,s+15)+1==1e14&&(l=rt(l,p+1,0));break}while(i0(l.d,s+=10,d));return gt=!0,rt(l,p,d)};Ce.minus=Ce.sub=function(r){var e,t,n,s,i,a,o,l,c,f,p,d,m=this,g=m.constructor;if(r=new g(r),!m.d||!r.d)return!m.s||!r.s?r=new g(NaN):m.d?r.s=-r.s:r=new g(r.d||m.s!==r.s?m:NaN),r;if(m.s!=r.s)return r.s=-r.s,m.plus(r);if(c=m.d,d=r.d,o=g.precision,l=g.rounding,!c[0]||!d[0]){if(d[0])r.s=-r.s;else if(c[0])r=new g(m);else return new g(l===3?-0:0);return gt?rt(r,o,l):r}if(t=In(r.e/lt),f=In(m.e/lt),c=c.slice(),i=f-t,i){for(p=i<0,p?(e=c,i=-i,a=d.length):(e=d,t=f,a=c.length),n=Math.max(Math.ceil(o/lt),a)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=c.length,a=d.length,p=n<a,p&&(a=n),n=0;n<a;n++)if(c[n]!=d[n]){p=c[n]<d[n];break}i=0}for(p&&(e=c,c=d,d=e,r.s=-r.s),a=c.length,n=d.length-a;n>0;--n)c[a++]=0;for(n=d.length;n>i;){if(c[--n]<d[n]){for(s=n;s&&c[--s]===0;)c[s]=Ys-1;--c[s],c[n]+=Ys}c[n]-=d[n]}for(;c[--a]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(r.d=c,r.e=Xy(c,t),gt?rt(r,o,l):r):new g(l===3?-0:0)};Ce.modulo=Ce.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?rt(new n(t),n.precision,n.rounding):(gt=!1,n.modulo==9?(e=cr(t,r.abs(),0,3,1),e.s*=r.s):e=cr(t,r,0,n.modulo,1),e=e.times(r),gt=!0,t.minus(e))};Ce.naturalExponential=Ce.exp=function(){return xA(this)};Ce.naturalLogarithm=Ce.ln=function(){return oo(this)};Ce.negated=Ce.neg=function(){var r=new this.constructor(this);return r.s=-r.s,rt(r)};Ce.plus=Ce.add=function(r){var e,t,n,s,i,a,o,l,c,f,p=this,d=p.constructor;if(r=new d(r),!p.d||!r.d)return!p.s||!r.s?r=new d(NaN):p.d||(r=new d(r.d||p.s===r.s?p:NaN)),r;if(p.s!=r.s)return r.s=-r.s,p.minus(r);if(c=p.d,f=r.d,o=d.precision,l=d.rounding,!c[0]||!f[0])return f[0]||(r=new d(p)),gt?rt(r,o,l):r;if(i=In(p.e/lt),n=In(r.e/lt),c=c.slice(),s=i-n,s){for(s<0?(t=c,s=-s,a=f.length):(t=f,n=i,a=c.length),i=Math.ceil(o/lt),a=i>a?i+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=c.length,s=f.length,a-s<0&&(s=a,t=f,f=c,c=t),e=0;s;)e=(c[--s]=c[s]+f[s]+e)/Ys|0,c[s]%=Ys;for(e&&(c.unshift(e),++n),a=c.length;c[--a]==0;)c.pop();return r.d=c,r.e=Xy(c,n),gt?rt(r,o,l):r};Ce.precision=Ce.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(uo+r);return t.d?(e=JI(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};Ce.round=function(){var r=this,e=r.constructor;return rt(new e(r),r.e+1,e.rounding)};Ce.sine=Ce.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+lt,n.rounding=1,t=h6(n,eD(n,t)),n.precision=r,n.rounding=e,rt(aa>2?t.neg():t,r,e,!0)):new n(NaN)};Ce.squareRoot=Ce.sqrt=function(){var r,e,t,n,s,i,a=this,o=a.d,l=a.e,c=a.s,f=a.constructor;if(c!==1||!o||!o[0])return new f(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(gt=!1,c=Math.sqrt(+a),c==0||c==1/0?(e=yn(o),(e.length+l)%2==0&&(e+="0"),c=Math.sqrt(e),l=In((l+1)/2)-(l<0||l%2),c==1/0?e="5e"+l:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),n=new f(e)):n=new f(c.toString()),t=(l=f.precision)+3;;)if(i=n,n=i.plus(cr(a,i,t+2,1)).times(.5),yn(i.d).slice(0,t)===(e=yn(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(rt(i,l+1,0),i.times(i).eq(a))){n=i;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(rt(n,l+1,1),r=!n.times(n).eq(a));break}return gt=!0,rt(n,l,f.rounding,r)};Ce.tangent=Ce.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=cr(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,rt(aa==2||aa==4?t.neg():t,r,e,!0)):new n(NaN)};Ce.times=Ce.mul=function(r){var e,t,n,s,i,a,o,l,c,f=this,p=f.constructor,d=f.d,m=(r=new p(r)).d;if(r.s*=f.s,!d||!d[0]||!m||!m[0])return new p(!r.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?r.s/0:r.s*0);for(t=In(f.e/lt)+In(r.e/lt),l=d.length,c=m.length,l<c&&(i=d,d=m,m=i,a=l,l=c,c=a),i=[],a=l+c,n=a;n--;)i.push(0);for(n=c;--n>=0;){for(e=0,s=l+n;s>n;)o=i[s]+m[n]*d[s-n-1]+e,i[s--]=o%Ys|0,e=o/Ys|0;i[s]=(i[s]+e)%Ys|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),r.d=i,r.e=Xy(i,t),gt?rt(r,p.precision,p.rounding):r};Ce.toBinary=function(r,e){return bA(this,2,r,e)};Ce.toDecimalPlaces=Ce.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(Gn(r,0,lo),e===void 0?e=n.rounding:Gn(e,0,8),rt(t,r+t.e+1,e))};Ce.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Ei(n,!0):(Gn(r,0,lo),e===void 0?e=s.rounding:Gn(e,0,8),n=rt(new s(n),r+1,e),t=Ei(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};Ce.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=Ei(s):(Gn(r,0,lo),e===void 0?e=i.rounding:Gn(e,0,8),n=rt(new i(s),r+s.e+1,e),t=Ei(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};Ce.toFraction=function(r){var e,t,n,s,i,a,o,l,c,f,p,d,m=this,g=m.d,w=m.constructor;if(!g)return new w(m);if(c=t=new w(1),n=l=new w(0),e=new w(n),i=e.e=JI(g)-m.e-1,a=i%lt,e.d[0]=zr(10,a<0?lt+a:a),r==null)r=i>0?e:c;else{if(o=new w(r),!o.isInt()||o.lt(c))throw Error(uo+o);r=o.gt(e)?i>0?e:c:o}for(gt=!1,o=new w(yn(g)),f=w.precision,w.precision=i=g.length*lt*2;p=cr(o,e,0,1,1),s=t.plus(p.times(n)),s.cmp(r)!=1;)t=n,n=s,s=c,c=l.plus(p.times(s)),l=s,s=e,e=o.minus(p.times(s)),o=s;return s=cr(r.minus(t),n,0,1,1),l=l.plus(s.times(c)),t=t.plus(s.times(n)),l.s=c.s=m.s,d=cr(c,n,i,1).minus(m).abs().cmp(cr(l,t,i,1).minus(m).abs())<1?[c,n]:[l,t],w.precision=f,gt=!0,d};Ce.toHexadecimal=Ce.toHex=function(r,e){return bA(this,16,r,e)};Ce.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:Gn(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(gt=!1,t=cr(t,r,0,e,1).times(r),gt=!0,rt(t)):(r.s=t.s,t=r),t};Ce.toNumber=function(){return+this};Ce.toOctal=function(r,e){return bA(this,8,r,e)};Ce.toPower=Ce.pow=function(r){var e,t,n,s,i,a,o=this,l=o.constructor,c=+(r=new l(r));if(!o.d||!r.d||!o.d[0]||!r.d[0])return new l(zr(+o,c));if(o=new l(o),o.eq(1))return o;if(n=l.precision,i=l.rounding,r.eq(1))return rt(o,n,i);if(e=In(r.e/lt),e>=r.d.length-1&&(t=c<0?-c:c)<=u6)return s=YI(l,o,t,n),r.s<0?new l(1).div(s):rt(s,n,i);if(a=o.s,a<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(a=1),o.e==0&&o.d[0]==1&&o.d.length==1)return o.s=a,o}return t=zr(+o,c),e=t==0||!isFinite(t)?In(c*(Math.log("0."+yn(o.d))/Math.LN10+o.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(gt=!1,l.rounding=o.s=1,t=Math.min(12,(e+"").length),s=xA(r.times(oo(o,n+t)),n),s.d&&(s=rt(s,n+5,1),i0(s.d,n,i)&&(e=n+10,s=rt(xA(r.times(oo(o,e+t)),e),e+5,1),+yn(s.d).slice(n+1,n+15)+1==1e14&&(s=rt(s,n+1,0)))),s.s=a,gt=!0,l.rounding=i,rt(s,n,i))};Ce.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=Ei(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(Gn(r,1,lo),e===void 0?e=s.rounding:Gn(e,0,8),n=rt(new s(n),r,e),t=Ei(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};Ce.toSignificantDigits=Ce.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(Gn(r,1,lo),e===void 0?e=n.rounding:Gn(e,0,8)),rt(new n(t),r,e)};Ce.toString=function(){var r=this,e=r.constructor,t=Ei(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};Ce.truncated=Ce.trunc=function(){return rt(new this.constructor(this),this.e+1,1)};Ce.valueOf=Ce.toJSON=function(){var r=this,e=r.constructor,t=Ei(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function yn(r){var e,t,n,s=r.length-1,i="",a=r[0];if(s>0){for(i+=a,e=1;e<s;e++)n=r[e]+"",t=lt-n.length,t&&(i+=ao(t)),i+=n;a=r[e],n=a+"",t=lt-n.length,t&&(i+=ao(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}u(yn,"digitsToString");function Gn(r,e,t){if(r!==~~r||r<e||r>t)throw Error(uo+r)}u(Gn,"checkInt32");function i0(r,e,t,n){var s,i,a,o;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=lt,s=0):(s=Math.ceil((e+1)/lt),e%=lt),i=zr(10,lt-e),o=r[s]%i|0,n==null?e<3?(e==0?o=o/100|0:e==1&&(o=o/10|0),a=t<4&&o==99999||t>3&&o==49999||o==5e4||o==0):a=(t<4&&o+1==i||t>3&&o+1==i/2)&&(r[s+1]/i/100|0)==zr(10,e-2)-1||(o==i/2||o==0)&&(r[s+1]/i/100|0)==0:e<4?(e==0?o=o/1e3|0:e==1?o=o/100|0:e==2&&(o=o/10|0),a=(n||t<4)&&o==9999||!n&&t>3&&o==4999):a=((n||t<4)&&o+1==i||!n&&t>3&&o+1==i/2)&&(r[s+1]/i/1e3|0)==zr(10,e-3)-1,a}u(i0,"checkRoundingDigits");function Fy(r,e,t){for(var n,s=[0],i,a=0,o=r.length;a<o;){for(i=s.length;i--;)s[i]*=e;for(s[0]+=SA.indexOf(r.charAt(a++)),n=0;n<s.length;n++)s[n]>t-1&&(s[n+1]===void 0&&(s[n+1]=0),s[n+1]+=s[n]/t|0,s[n]%=t)}return s.reverse()}u(Fy,"convertBase");function c6(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/$y(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=vf(r,1,e.times(s),new r(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return r.precision-=t,e}u(c6,"cosine");var cr=(function(){function r(n,s,i){var a,o=0,l=n.length;for(n=n.slice();l--;)a=n[l]*s+o,n[l]=a%i|0,o=a/i|0;return o&&n.unshift(o),n}u(r,"multiplyInteger");function e(n,s,i,a){var o,l;if(i!=a)l=i>a?1:-1;else for(o=l=0;o<i;o++)if(n[o]!=s[o]){l=n[o]>s[o]?1:-1;break}return l}u(e,"compare");function t(n,s,i,a){for(var o=0;i--;)n[i]-=o,o=n[i]<s[i]?1:0,n[i]=o*a+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return u(t,"subtract"),function(n,s,i,a,o,l){var c,f,p,d,m,g,w,y,S,C,E,v,A,x,F,D,B,V,U,q,ie=n.constructor,Y=n.s==s.s?1:-1,se=n.d,$=s.d;if(!se||!se[0]||!$||!$[0])return new ie(!n.s||!s.s||(se?$&&se[0]==$[0]:!$)?NaN:se&&se[0]==0||!$?Y*0:Y/0);for(l?(m=1,f=n.e-s.e):(l=Ys,m=lt,f=In(n.e/m)-In(s.e/m)),U=$.length,B=se.length,S=new ie(Y),C=S.d=[],p=0;$[p]==(se[p]||0);p++);if($[p]>(se[p]||0)&&f--,i==null?(x=i=ie.precision,a=ie.rounding):o?x=i+(n.e-s.e)+1:x=i,x<0)C.push(1),g=!0;else{if(x=x/m+2|0,p=0,U==1){for(d=0,$=$[0],x++;(p<B||d)&&x--;p++)F=d*l+(se[p]||0),C[p]=F/$|0,d=F%$|0;g=d||p<B}else{for(d=l/($[0]+1)|0,d>1&&($=r($,d,l),se=r(se,d,l),U=$.length,B=se.length),D=U,E=se.slice(0,U),v=E.length;v<U;)E[v++]=0;q=$.slice(),q.unshift(0),V=$[0],$[1]>=l/2&&++V;do d=0,c=e($,E,U,v),c<0?(A=E[0],U!=v&&(A=A*l+(E[1]||0)),d=A/V|0,d>1?(d>=l&&(d=l-1),w=r($,d,l),y=w.length,v=E.length,c=e(w,E,y,v),c==1&&(d--,t(w,U<y?q:$,y,l))):(d==0&&(c=d=1),w=$.slice()),y=w.length,y<v&&w.unshift(0),t(E,w,v,l),c==-1&&(v=E.length,c=e($,E,U,v),c<1&&(d++,t(E,U<v?q:$,v,l))),v=E.length):c===0&&(d++,E=[0]),C[p++]=d,c&&E[0]?E[v++]=se[D]||0:(E=[se[D]],v=1);while((D++<B||E[0]!==void 0)&&x--);g=E[0]!==void 0}C[0]||C.shift()}if(m==1)S.e=f,XI=g;else{for(p=1,d=C[0];d>=10;d/=10)p++;S.e=p+f*m-1,rt(S,o?i+S.e+1:i,a,g)}return S}})();function rt(r,e,t,n){var s,i,a,o,l,c,f,p,d,m=r.constructor;e:if(e!=null){if(p=r.d,!p)return r;for(s=1,o=p[0];o>=10;o/=10)s++;if(i=e-s,i<0)i+=lt,a=e,f=p[d=0],l=f/zr(10,s-a-1)%10|0;else if(d=Math.ceil((i+1)/lt),o=p.length,d>=o)if(n){for(;o++<=d;)p.push(0);f=l=0,s=1,i%=lt,a=i-lt+1}else break e;else{for(f=o=p[d],s=1;o>=10;o/=10)s++;i%=lt,a=i-lt+s,l=a<0?0:f/zr(10,s-a-1)%10|0}if(n=n||e<0||p[d+1]!==void 0||(a<0?f:f%zr(10,s-a-1)),c=t<4?(l||n)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||n||t==6&&(i>0?a>0?f/zr(10,s-a):0:p[d-1])%10&1||t==(r.s<0?8:7)),e<1||!p[0])return p.length=0,c?(e-=r.e+1,p[0]=zr(10,(lt-e%lt)%lt),r.e=-e||0):p[0]=r.e=0,r;if(i==0?(p.length=d,o=1,d--):(p.length=d+1,o=zr(10,lt-i),p[d]=a>0?(f/zr(10,s-a)%zr(10,a)|0)*o:0),c)for(;;)if(d==0){for(i=1,a=p[0];a>=10;a/=10)i++;for(a=p[0]+=o,o=1;a>=10;a/=10)o++;i!=o&&(r.e++,p[0]==Ys&&(p[0]=1));break}else{if(p[d]+=o,p[d]!=Ys)break;p[d--]=0,o=1}for(i=p.length;p[--i]===0;)p.pop()}return gt&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}u(rt,"finalise");function Ei(r,e,t){if(!r.isFinite())return ZI(r);var n,s=r.e,i=yn(r.d),a=i.length;return e?(t&&(n=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+ao(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+ao(-s-1)+i,t&&(n=t-a)>0&&(i+=ao(n))):s>=a?(i+=ao(s+1-a),t&&(n=t-s-1)>0&&(i=i+"."+ao(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-a)>0&&(s+1===a&&(i+="."),i+=ao(n))),i}u(Ei,"finiteToString");function Xy(r,e){var t=r[0];for(e*=lt;t>=10;t/=10)e++;return e}u(Xy,"getBase10Exponent");function Hy(r,e,t){if(e>l6)throw gt=!0,t&&(r.precision=t),Error($I);return rt(new r(jy),e,1,!0)}u(Hy,"getLn10");function vi(r,e,t){if(e>CA)throw Error($I);return rt(new r(qy),e,t,!0)}u(vi,"getPi");function JI(r){var e=r.length-1,t=e*lt+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}u(JI,"getPrecision");function ao(r){for(var e="";r--;)e+="0";return e}u(ao,"getZeroString");function YI(r,e,t,n){var s,i=new r(1),a=Math.ceil(n/lt+4);for(gt=!1;;){if(t%2&&(i=i.times(e),HI(i.d,a)&&(s=!0)),t=In(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),HI(e.d,a)}return gt=!0,i}u(YI,"intPow");function qI(r){return r.d[r.d.length-1]&1}u(qI,"isOdd");function QI(r,e,t){for(var n,s,i=new r(e[0]),a=0;++a<e.length;){if(s=new r(e[a]),!s.s){i=s;break}n=i.cmp(s),(n===t||n===0&&i.s===t)&&(i=s)}return i}u(QI,"maxOrMin");function xA(r,e){var t,n,s,i,a,o,l,c=0,f=0,p=0,d=r.constructor,m=d.rounding,g=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(gt=!1,l=g):l=e,o=new d(.03125);r.e>-2;)r=r.times(o),p+=5;for(n=Math.log(zr(2,p))/Math.LN10*2+5|0,l+=n,t=i=a=new d(1),d.precision=l;;){if(i=rt(i.times(r),l,1),t=t.times(++f),o=a.plus(cr(i,t,l,1)),yn(o.d).slice(0,l)===yn(a.d).slice(0,l)){for(s=p;s--;)a=rt(a.times(a),l,1);if(e==null)if(c<3&&i0(a.d,l-n,m,c))d.precision=l+=10,t=i=o=new d(1),f=0,c++;else return rt(a,d.precision=g,m,gt=!0);else return d.precision=g,a}a=o}}u(xA,"naturalExponential");function oo(r,e){var t,n,s,i,a,o,l,c,f,p,d,m=1,g=10,w=r,y=w.d,S=w.constructor,C=S.rounding,E=S.precision;if(w.s<0||!y||!y[0]||!w.e&&y[0]==1&&y.length==1)return new S(y&&!y[0]?-1/0:w.s!=1?NaN:y?0:w);if(e==null?(gt=!1,f=E):f=e,S.precision=f+=g,t=yn(y),n=t.charAt(0),Math.abs(i=w.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)w=w.times(r),t=yn(w.d),n=t.charAt(0),m++;i=w.e,n>1?(w=new S("0."+t),i++):w=new S(n+"."+t.slice(1))}else return c=Hy(S,f+2,E).times(i+""),w=oo(new S(n+"."+t.slice(1)),f-g).plus(c),S.precision=E,e==null?rt(w,E,C,gt=!0):w;for(p=w,l=a=w=cr(w.minus(1),w.plus(1),f,1),d=rt(w.times(w),f,1),s=3;;){if(a=rt(a.times(d),f,1),c=l.plus(cr(a,new S(s),f,1)),yn(c.d).slice(0,f)===yn(l.d).slice(0,f))if(l=l.times(2),i!==0&&(l=l.plus(Hy(S,f+2,E).times(i+""))),l=cr(l,new S(m),f,1),e==null)if(i0(l.d,f-g,C,o))S.precision=f+=g,c=a=w=cr(p.minus(1),p.plus(1),f,1),d=rt(w.times(w),f,1),s=o=1;else return rt(l,S.precision=E,C,gt=!0);else return S.precision=E,l;l=c,s+=2}}u(oo,"naturalLogarithm");function ZI(r){return String(r.s*r.s/0)}u(ZI,"nonFiniteToString");function My(r,e){var t,n,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(n,s),e){if(s-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%lt,t<0&&(n+=lt),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=lt;n<s;)r.d.push(+e.slice(n,n+=lt));e=e.slice(n),n=lt-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),gt&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}u(My,"parseDecimal");function f6(r,e){var t,n,s,i,a,o,l,c,f;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),zI.test(e))return My(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(a6.test(e))t=16,e=e.toLowerCase();else if(i6.test(e))t=2;else if(o6.test(e))t=8;else throw Error(uo+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,n=r.constructor,a&&(e=e.replace(".",""),o=e.length,i=o-i,s=YI(n,new n(t),i,i*2)),c=Fy(e,t,Ys),f=c.length-1,i=f;c[i]===0;--i)c.pop();return i<0?new n(r.s*0):(r.e=Xy(c,f),r.d=c,gt=!1,a&&(r=cr(r,s,o*4)),l&&(r=r.times(Math.abs(l)<54?zr(2,l):Ef.pow(2,l))),gt=!0,r)}u(f6,"parseOther");function h6(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:vf(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/$y(5,t)),e=vf(r,2,e,e);for(var s,i=new r(5),a=new r(16),o=new r(20);t--;)s=e.times(e),e=e.times(i.plus(s.times(a.times(s).minus(o))));return e}u(h6,"sine");function vf(r,e,t,n,s){var i,a,o,l,c=1,f=r.precision,p=Math.ceil(f/lt);for(gt=!1,l=t.times(t),o=new r(n);;){if(a=cr(o.times(l),new r(e++*e++),f,1),o=s?n.plus(a):n.minus(a),n=cr(a.times(l),new r(e++*e++),f,1),a=o.plus(n),a.d[p]!==void 0){for(i=p;a.d[i]===o.d[i]&&i--;);if(i==-1)break}i=o,o=n,n=a,a=i,c++}return gt=!0,a.d.length=p+1,a}u(vf,"taylorSeries");function $y(r,e){for(var t=r;--e;)t*=r;return t}u($y,"tinyPow");function eD(r,e){var t,n=e.s<0,s=vi(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return aa=n?4:1,e;if(t=e.divToInt(s),t.isZero())aa=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return aa=qI(t)?n?2:3:n?4:1,e;aa=qI(t)?n?1:4:n?3:2}return e.minus(s).abs()}u(eD,"toLessThanHalfPi");function bA(r,e,t,n){var s,i,a,o,l,c,f,p,d,m=r.constructor,g=t!==void 0;if(g?(Gn(t,1,lo),n===void 0?n=m.rounding:Gn(n,0,8)):(t=m.precision,n=m.rounding),!r.isFinite())f=ZI(r);else{for(f=Ei(r),a=f.indexOf("."),g?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(f=f.replace(".",""),d=new m(1),d.e=f.length-a,d.d=Fy(Ei(d),10,s),d.e=d.d.length),p=Fy(f,10,s),i=l=p.length;p[--l]==0;)p.pop();if(!p[0])f=g?"0p+0":"0";else{if(a<0?i--:(r=new m(r),r.d=p,r.e=i,r=cr(r,d,t,n,0,s),p=r.d,i=r.e,c=XI),a=p[t],o=s/2,c=c||p[t+1]!==void 0,c=n<4?(a!==void 0||c)&&(n===0||n===(r.s<0?3:2)):a>o||a===o&&(n===4||c||n===6&&p[t-1]&1||n===(r.s<0?8:7)),p.length=t,c)for(;++p[--t]>s-1;)p[t]=0,t||(++i,p.unshift(1));for(l=p.length;!p[l-1];--l);for(a=0,f="";a<l;a++)f+=SA.charAt(p[a]);if(g){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)f+="0";for(p=Fy(f,s,e),l=p.length;!p[l-1];--l);for(a=1,f="1.";a<l;a++)f+=SA.charAt(p[a])}else f=f.charAt(0)+"."+f.slice(1);f=f+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)f="0"+f;f="0."+f}else if(++i>l)for(i-=l;i--;)f+="0";else i<l&&(f=f.slice(0,i)+"."+f.slice(i))}f=(e==16?"0x":e==2?"0b":e==8?"0o":"")+f}return r.s<0?"-"+f:f}u(bA,"toStringBinary");function HI(r,e){if(r.length>e)return r.length=e,!0}u(HI,"truncate");function p6(r){return new this(r).abs()}u(p6,"abs");function d6(r){return new this(r).acos()}u(d6,"acos");function m6(r){return new this(r).acosh()}u(m6,"acosh");function g6(r,e){return new this(r).plus(e)}u(g6,"add");function y6(r){return new this(r).asin()}u(y6,"asin");function v6(r){return new this(r).asinh()}u(v6,"asinh");function E6(r){return new this(r).atan()}u(E6,"atan");function w6(r){return new this(r).atanh()}u(w6,"atanh");function S6(r,e){r=new this(r),e=new this(e);var t,n=this.precision,s=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=vi(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?vi(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=vi(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(cr(r,e,i,1)),e=vi(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(cr(r,e,i,1)),t}u(S6,"atan2");function A6(r){return new this(r).cbrt()}u(A6,"cbrt");function C6(r){return rt(r=new this(r),r.e+1,2)}u(C6,"ceil");function x6(r,e,t){return new this(r).clamp(e,t)}u(x6,"clamp");function b6(r){if(!r||typeof r!="object")throw Error(Ky+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,lo,"rounding",0,8,"toExpNeg",-yf,0,"toExpPos",0,yf,"maxE",0,yf,"minE",-yf,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=AA[t]),(n=r[t])!==void 0)if(In(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(uo+t+": "+n);if(t="crypto",s&&(this[t]=AA[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(GI);else this[t]=!1;else throw Error(uo+t+": "+n);return this}u(b6,"config");function N6(r){return new this(r).cos()}u(N6,"cos");function T6(r){return new this(r).cosh()}u(T6,"cosh");function tD(r){var e,t,n;function s(i){var a,o,l,c=this;if(!(c instanceof s))return new s(i);if(c.constructor=s,KI(i)){c.s=i.s,gt?!i.d||i.e>s.maxE?(c.e=NaN,c.d=null):i.e<s.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(a=0,o=i;o>=10;o/=10)a++;gt?a>s.maxE?(c.e=NaN,c.d=null):a<s.minE?(c.e=0,c.d=[0]):(c.e=a,c.d=[i]):(c.e=a,c.d=[i]);return}if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return My(c,i.toString())}if(l==="string")return(o=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(o===43&&(i=i.slice(1)),c.s=1),zI.test(i)?My(c,i):f6(c,i);if(l==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,My(c,i.toString());throw Error(uo+i)}if(u(s,"Decimal"),s.prototype=Ce,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=b6,s.clone=tD,s.isDecimal=KI,s.abs=p6,s.acos=d6,s.acosh=m6,s.add=g6,s.asin=y6,s.asinh=v6,s.atan=E6,s.atanh=w6,s.atan2=S6,s.cbrt=A6,s.ceil=C6,s.clamp=x6,s.cos=N6,s.cosh=T6,s.div=I6,s.exp=D6,s.floor=B6,s.hypot=R6,s.ln=O6,s.log=_6,s.log10=k6,s.log2=P6,s.max=L6,s.min=V6,s.mod=U6,s.mul=F6,s.pow=M6,s.random=j6,s.round=q6,s.sign=H6,s.sin=K6,s.sinh=X6,s.sqrt=$6,s.sub=G6,s.sum=W6,s.tan=z6,s.tanh=J6,s.trunc=Y6,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return s.config(r),s}u(tD,"clone");function I6(r,e){return new this(r).div(e)}u(I6,"div");function D6(r){return new this(r).exp()}u(D6,"exp");function B6(r){return rt(r=new this(r),r.e+1,3)}u(B6,"floor");function R6(){var r,e,t=new this(0);for(gt=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return gt=!0,new this(1/0);t=e}return gt=!0,t.sqrt()}u(R6,"hypot");function KI(r){return r instanceof Ef||r&&r.toStringTag===WI||!1}u(KI,"isDecimalInstance");function O6(r){return new this(r).ln()}u(O6,"ln");function _6(r,e){return new this(r).log(e)}u(_6,"log");function P6(r){return new this(r).log(2)}u(P6,"log2");function k6(r){return new this(r).log(10)}u(k6,"log10");function L6(){return QI(this,arguments,-1)}u(L6,"max");function V6(){return QI(this,arguments,1)}u(V6,"min");function U6(r,e){return new this(r).mod(e)}u(U6,"mod");function F6(r,e){return new this(r).mul(e)}u(F6,"mul");function M6(r,e){return new this(r).pow(e)}u(M6,"pow");function j6(r){var e,t,n,s,i=0,a=new this(1),o=[];if(r===void 0?r=this.precision:Gn(r,1,lo),n=Math.ceil(r/lt),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)s=e[i],s>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)s=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,i):(o.push(s%1e7),i+=4);i=n/4}else throw Error(GI);else for(;i<n;)o[i++]=Math.random()*1e7|0;for(n=o[--i],r%=lt,n&&r&&(s=zr(10,lt-r),o[i]=(n/s|0)*s);o[i]===0;i--)o.pop();if(i<0)t=0,o=[0];else{for(t=-1;o[0]===0;t-=lt)o.shift();for(n=1,s=o[0];s>=10;s/=10)n++;n<lt&&(t-=lt-n)}return a.e=t,a.d=o,a}u(j6,"random");function q6(r){return rt(r=new this(r),r.e+1,this.rounding)}u(q6,"round");function H6(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}u(H6,"sign");function K6(r){return new this(r).sin()}u(K6,"sin");function X6(r){return new this(r).sinh()}u(X6,"sinh");function $6(r){return new this(r).sqrt()}u($6,"sqrt");function G6(r,e){return new this(r).sub(e)}u(G6,"sub");function W6(){var r=0,e=arguments,t=new this(e[r]);for(gt=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return gt=!0,rt(t,this.precision,this.rounding)}u(W6,"sum");function z6(r){return new this(r).tan()}u(z6,"tan");function J6(r){return new this(r).tanh()}u(J6,"tanh");function Y6(r){return rt(r=new this(r),r.e+1,1)}u(Y6,"trunc");Ce[Symbol.for("nodejs.util.inspect.custom")]=Ce.toString;Ce[Symbol.toStringTag]="Decimal";var Ef=Ce.constructor=tD(AA);jy=new Ef(jy);qy=new Ef(qy);var wf=class r extends Ef{static{u(this,"Decimal")}static from(e){return new r(e)}static newOrZero(e){return e===void 0?r.from(0):r.from(e)}static newOrUndefined(e){if(e!==void 0)return r.from(e)}};import Q6 from"pdfkit";var rD=class r{static{u(this,"PdfkitPdfBuilder")}defaults={autoFirstPage:!1};doc=new Q6(this.defaults);constructor(e){e&&this.configure(e)}static new(e){return new r(e)}configure(e){return this.doc.options={...this.doc.options,...e},this}pipe(e){return this.doc.pipe(e),this}end(){return this.doc.end()}restore(){return this.doc.restore(),this}save(){return this.doc.save(),this}stroke(e){return this.doc.stroke(e),this}page(e){return this.doc.addPage(e),this}table(e){return this.doc.table(e),this}text(e,t){let{x:n,y:s,...i}=t??{};return n||s?(this.doc.text(e,n,s,i),this):(this.doc.text(e,t),this)}fontSize(e){return this.doc.fontSize(e),this}font(e,t,n){return typeof t=="string"?(this.doc.font(e,t,n),this):typeof t=="number"?(this.doc.font(e,t),this):(this.doc.font(e),this)}image(e,t,n,s){let i=this.imageSource(e);return typeof t=="number"&&typeof n=="number"?(this.doc.image(i,t,n,s),this):(this.doc.image(i,t),this)}imageSource(e){if(e.startsWith("data:")||!/^[A-Za-z0-9+/]+={0,2}$/.test(e))return e;let t=Buffer.from(e,"base64"),n=t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71,s=t[0]===255&&t[1]===216;return n||s?t:e}rect(e,t,n,s){return this.doc.rect(e,t,n,s),this}roundedRect(e,t,n,s,i){return this.doc.roundedRect(e,t,n,s,i),this}path(e){return this.doc.path(e),this}translate(e,t){return this.doc.translate(e,t),this}scale(e,t){return this.doc.scale(e,t),this}rotate(e,t){return this.doc.rotate(e,t),this}moveTo(e,t){return this.doc.moveTo(e,t),this}lineTo(e,t){return this.doc.lineTo(e,t),this}lineWidth(e){return this.doc.lineWidth(e),this}dash(e,t){return this.doc.dash(e,t),this}undash(){return this.doc.undash(),this}fillColor(e,t){return this.doc.fillColor(e,t),this}strokeColor(e,t){return this.doc.strokeColor(e,t),this}fill(e,t){return this.doc.fill(e,t),this}pageWidth(){return this.doc.page.width}pageHeight(){return this.doc.page.height}heightOfString(e,t){return this.doc.heightOfString(e,t)}widthOfString(e,t){return this.doc.widthOfString(e,t)}pageMargins(){return this.doc.page.margins}currentLineHeight(e){return this.doc.currentLineHeight(e)}x(){return this.doc.x}y(){return this.doc.y}moveDown(e){return this.doc.moveDown(e),this}row(e,...t){let n,s;typeof e=="function"?(n={},s=[e,...t]):(n=e??{},s=t),n.columns??=1;let i=this.y(),a=n.right??0,o=n.left??0,l=n.gap??0,c=this.pageWidth(),f=c-o-a-l*(n.columns-1);n.size??=Array(n.columns).fill(12/n.columns);let p=[];for(let d=0;d<n.columns;d++){let m=n.size[d]/12;p[d]=f*m}for(let d=0,m=o;d<n.columns;d++){let g=d===n.columns-1,w=p[d];if(g&&n.columns>1){let C=c-a-m;C>0&&Math.abs(C-w)>.01&&(w=C)}let y={y:i,x:m,width:w};s[d](y),m+=w,l>0&&!g&&(m+=l)}return this}};var nD=class{static{u(this,"MemoryCacheAdapter")}cache=new Map;async get(e){return Promise.resolve(this.cache.get(e)??null)}has(e){return Promise.resolve(this.cache.has(e))}set(e,t){return this.cache.set(e,t),Promise.resolve(!0)}};var Co=Py(ER(),1);import Y9 from"os";import IR from"fs";import Q9 from"path";import A0 from"crypto";var V9=u(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessageInRecord"),ms=u(r=>typeof r=="string"?Jt(new Mt(r)):r instanceof Error?Jt(new Mt(r.message,{cause:r.cause})):V9(r)?Jt(new Mt(r.message)):Jt(new Mt("unexpected error")),"leftFromError");var bv=class{static{u(this,"NullCacheAdapter")}async get(e){return Promise.resolve(null)}has(e){return Promise.resolve(!1)}set(e,t){return Promise.resolve(!0)}};import{arch as H9,platform as NR}from"os";import{dirname as K9,join as X9,resolve as $9,normalize as G9,delimiter as W9}from"path";import{resolve as SR}from"path";import{createRequire as wR}from"module";import{fileURLToPath as U9,pathToFileURL as F9}from"url";var M9=typeof jest<"u"||process.env.JEST_WORKER_ID!==void 0,Lf,AR=u(()=>{if(Lf!==void 0)return Lf;if(M9){Lf=void 0;return}try{Lf=new Function("try { return import.meta.url; } catch { return undefined; }")()}catch{Lf=void 0}return Lf},"getImportMetaUrl"),CR=u(()=>{if(typeof ot<"u")return ot;let r=AR();if(r)return wR(r);let e=F9(SR(process.cwd(),"package.json")).href;return wR(e)},"getRequireFn"),xR=u(()=>{if(typeof __filename<"u")return __filename;let r=AR();return r?U9(r):SR(process.cwd())},"getCurrentFile");import{dirname as Nv,resolve as fl}from"path";import{existsSync as Vf}from"fs";var bR=u(()=>typeof process<"u"&&typeof process.versions<"u"&&"electron"in process.versions,"isElectron"),j9=u(()=>{if(!bR())return null;try{let e=ot("electron").app;if(e?.getAppPath&&typeof e.getAppPath=="function")return{getAppPath:e.getAppPath}}catch{}return null},"getElectronApp"),q9=u(()=>{if(!bR())return null;let r=process;if(r.resourcesPath)return r.resourcesPath;let e=j9();if(e)try{let t=e.getAppPath();if(typeof t=="string")return Nv(t.replace(/\.asar$/,""))}catch{}return null},"getElectronResourcesPath"),IC=u((r,{onFound:e,onNotFound:t})=>{let n=q9();if(n){let c=fl(n,"node_modules","nfets",r);if(Vf(c))return e(c);let f=fl(n,"app.asar.unpacked","node_modules","nfets",r);if(Vf(f))return e(f)}let s=xR(),i=s.includes(".asar")?process.cwd():s,a=fl(i,"../../../../"),o=fl(a,r);if(Vf(o))return e(o);let l=i;for(let c=0;c<5;c++){let f=fl(l,r);if(Vf(f))return e(f);let p=Nv(l);if(p===l)break;l=p}l=i;for(let c=0;c<5;c++){let f=fl(l,"node_modules","nfets",r);if(Vf(f))return e(f);let p=Nv(l);if(p===l)break;l=p}l=i;for(let c=0;c<5;c++){let f=fl(l,r.replace(/^build\//,"Release/"));if(Vf(f))return e(f);let p=Nv(l);if(p===l)break;l=p}return t()},"search");var z9=u(r=>{let e=r.replace(/^\\\\\?\\/,"");return $9(G9(e))},"normalizePath"),J9=u(r=>{NR()==="win32"&&(process.env.PATH=`${K9(r)}${W9}${process.env.PATH}`)},"addAddonDirToPath"),DC=u(r=>{let e=z9(r);return J9(e),CR()(e)},"exportRequireModule"),Uf=u(r=>{if(r=`${r}.node`,process.env.NFETS_ADDONS_DIR)return DC(X9(process.env.NFETS_ADDONS_DIR,r));let e=`${NR()}-${H9()}`;try{return IC(`build/addons/${e}/${r}`,{onFound:u(t=>DC(t),"onFound"),onNotFound:u(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}catch{return IC(`build/Release/${r}`,{onFound:u(t=>DC(t),"onFound"),onNotFound:u(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}},"addon");var Ao=class{static{u(this,"ASN1")}extractCertificateInfo(e){let n=e.subject.split(`
|
|
83
83
|
`).reduce((i,a)=>{let[o,l]=a.split("=").map(c=>c.trim());return!o||!l?i:i.set(o,l)},new Map),s=this.oid("2.16.76.1.3.1",e.raw);return{CNPJ:this.oid("2.16.76.1.3.3",e.raw),CPF:s,CN:n.get("CN"),O:n.get("O"),OU:n.get("OU"),ST:n.get("ST"),L:n.get("L"),C:n.get("C")}}oid(e,t){let n=this.marker(e),s=t.indexOf(n);if(s===-1)return;let i=[t.subarray(0,s),t.subarray(s)];if(i.length<=1)return;let o=i[0].subarray(-4),l=o.subarray(-2);o[0]===48?l=o:o[1]===48&&(l=o.subarray(-3));let c=Buffer.concat([l,n,i[1]]),f=this.length(c),p=n.length,d=c.subarray(2+p,2+p+f),m=d.length-l.length-2;if(m<=0||m>d.length)return;let w=d.subarray(-m).toString("utf8");return w.substring(Buffer.from(w).findIndex((y,S)=>w.charCodeAt(S)>=32&&w.charCodeAt(S)<=126))}length(e){return e.length<2?0:e[1]<=127?e[1]:Buffer.from([e[1]&15]).reduce((t,n)=>t<<8|n,0)}marker(e){let t=e.split("."),n=t.slice(2).reduce((s,i)=>{let a=this.base128(s,Number.parseInt(i,10),!0);return s.length=0,s.push(...a),s},[]);return Buffer.from([6,n.length+1,40*Number.parseInt(t[0],10)+Number.parseInt(t[1],10),...n])}base128(e,t,n){let s=[...e];if(t>127){let a=this.base128(e,Math.floor(t/128),!1);a.length=0,s.push(...a)}let i=t%128;return n?s.push(i):s.push(128|i),s}};var Tv=class{static{u(this,"WincryptSignerRepository")}async sign(e,t,n){try{let s=Uf("wincrypt_certificate_store"),i=new Ao,{CN:a}=i.extractCertificateInfo(t.certificate),o=await s.sign(a??"",Buffer.from(e),n,Buffer.from(t.certificate.raw)),l=Buffer.from(o).toString("base64");return await Promise.resolve(Wr(l))}catch(s){return Promise.resolve(ms(s))}}};import TR from"crypto";var Iv=class{static{u(this,"CryptoSignerRepository")}async sign(e,t,n){try{if(!t.privateKey)return Jt(new Mt("Certificate private key not found"));let i=TR.sign(n,Buffer.from(e),{key:t.privateKey,padding:TR.constants.RSA_PKCS1_PADDING}).toString("base64");return await Promise.resolve(Wr(i))}catch(s){return Promise.resolve(ms(s))}}};var DR=class{static{u(this,"NativeCertificateRepository")}httpClient;cache;signer;constructor(e,t=new bv,n=Y9.platform()==="win32"?new Tv:new Iv){this.httpClient=e,this.cache=t,this.signer=n}async read(e){try{let{password:t,pfxPathOrBase64:n,publicCertDerBase64:s}=e,i=s?.trim(),a=n?.trim();if(i&&a)return Jt(new Mt("Use either pfxPathOrBase64 or publicCertDerBase64, not both"));if(i)try{let S=Buffer.from(i,"base64"),C=new A0.X509Certificate(S);return Wr({ca:[],password:t,certificate:C,privateKey:void 0})}catch(S){return ms(S)}if(!a)return Jt(new Mt("Certificate path (pfxPathOrBase64) is required"));let o=await this.getPfxBuffer({...e,pfxPathOrBase64:a});if(o.isLeft())return o;let l=Co.default.asn1.fromDer(o.value.toString("binary")),c=Co.default.pkcs12.pkcs12FromAsn1(l,t),{certBag:f}=Co.default.pki.oids,d=c.getBags({bagType:f})[f];if(!d?.length)return Jt(new Mt("Cannot read certificate"));let[{cert:m},...g]=d;if(!m)return Jt(new Mt("Issuer Certificate not found"));let w=g.reduce((S,{cert:C})=>(C&&S.push(new A0.X509Certificate(Co.default.pki.certificateToPem(C))),S),[]),y=new A0.X509Certificate(Co.default.pki.certificateToPem(m));return Wr({ca:w,password:t,certificate:y,privateKey:this.getPrivateKey(c)})}catch(t){return ms(t)}}getPrivateKey(e){let{pkcs8ShroudedKeyBag:t}=Co.default.pki.oids,s=e.getBags({bagType:t})[t]?.[0]?.key;if(s)return A0.createPrivateKey(Co.default.pki.privateKeyToPem(s))}async sign(e,t,n=io.SHA1){return this.signer.sign(e,t,n)}getCertificateInfo(e){return new Ao().extractCertificateInfo(e)}getStringCertificate(e){return e.raw.toString("base64")}getStringPrivateKey(e){try{return e.export({type:"pkcs8",format:"pem"})}catch{throw new Mt("Cannot extract private key")}}async getPfxBuffer(e){let{pfxPathOrBase64:t,password:n}=e,s=this.getCacheKey(t,n),i=await this.cache.get(s);if(i)return Wr(i);if(Q9.isAbsolute(t)||IR.existsSync(t))return this.hitBufferOnCache(s,IR.readFileSync(t));if(this.isValidRemoteUrl(t))try{let a=await this.httpClient.get(t,{responseType:"arraybuffer"});return await this.hitBufferOnCache(s,Buffer.from(a.data))}catch(a){return ms(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return A0.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),Wr(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};import nW from"os";import BC from"dayjs";import Z9 from"dayjs/plugin/utc.js";import ej from"dayjs/plugin/timezone.js";BC.extend(Z9);BC.extend(ej);var Ff=BC;var Q3=Py(G3(),1);import{constants as sW}from"crypto";import{Agent as wb}from"https";var MG=new Set(["ENOTFOUND","EAI_AGAIN","EAI_FAIL","EAI_NONAME"]),jG=new Set(["ETIMEDOUT","ESOCKETTIMEDOUT","ECONNABORTED"]),qG=new Set(["ECONNREFUSED","ENETUNREACH","EHOSTUNREACH","EPIPE"]),HG=new Set([12002,12152,12175]),KG=new Set([12007]),XG=new Set([12029,12030]),$G=/Failed to send request\. Error: (\d+)/i,GG=u(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessage"),WG=u(r=>{if(!r||typeof r!="object"||!("code"in r))return;let{code:e}=r;return typeof e=="string"?e:void 0},"getCode"),zG=u(r=>{if(!r||typeof r!="object"||!("hostname"in r))return;let{hostname:e}=r;return typeof e=="string"?e:void 0},"getHostname"),vb=u(r=>{if(typeof r=="string")return r;if(r instanceof Error||GG(r))return r.message},"getMessage"),W3=u(r=>{let e=r.toLowerCase();return e.includes("timeout")||e.includes("timed out")||e.includes("time-out")||e.includes("read econnreset")},"isTimeoutMessage"),JG=u(r=>/getaddrinfo\s+ENOTFOUND/i.test(r)||/\bENOTFOUND\b/i.test(r),"isHostNotFoundMessage"),YG=u(r=>{let e=$G.exec(r);if(!e)return;let t=Number(e[1]);return Number.isFinite(t)?t:void 0},"getWinHttpErrorCode"),QG=u(r=>{let e=[],t=new Set,n=r;for(;n!=null&&!t.has(n);){if(t.add(n),e.push(n),n instanceof AggregateError)for(let i of n.errors)t.has(i)||e.push(i);n=n instanceof Error?n.cause:void 0}return e},"collectErrorChain"),Vo=u(r=>r instanceof Error?{cause:r}:void 0,"errorOptions"),ZG=u(r=>{let e=QG(r),t=vb(r)??e.map(vb).find(s=>!!s);for(let s of e){let i=WG(s);if(i&&MG.has(i))return Jt(new el(t??`Host not found (${zG(s)??i})`,Vo(r)));if(i&&jG.has(i))return Jt(new tl(t??"Transmission timeout",Vo(r)));if(i&&qG.has(i))return Jt(new el(t??`Connection failed (${i})`,Vo(r)));let a=vb(s);if(a&&W3(a))return Jt(new tl(a,Vo(r)))}if(!t)return ms(r);let n=YG(t);if(n!==void 0){if(HG.has(n))return Jt(new tl(t,Vo(r)));if(KG.has(n)||XG.has(n))return Jt(new el(t,Vo(r)))}return JG(t)?Jt(new el(t,Vo(r))):W3(t)?Jt(new tl(t,Vo(r))):ms(r)},"mapTransmissionError"),z3=u(r=>ZG(r),"leftFromTransmissionError");var eW=/Ã[\u0080-\u00BF]/;function tW(r){if(!eW.test(r))return r;let e=Buffer.from(r,"latin1").toString("utf8");return e.includes("\uFFFD")?r:e}u(tW,"fixUtf8Mojibake");function Eb(r){if(typeof r=="string")return tW(r);if(Array.isArray(r))return r.map(e=>Eb(e));if(r!==null&&typeof r=="object"){let e={};for(let[t,n]of Object.entries(r))e[t]=Eb(n);return e}return r}u(Eb,"normalizeValue");function J3(r){return Eb(r)}u(J3,"normalizeTransmissionStrings");import rW from"os";var M2=class r{static{u(this,"WinHttpClient")}certificate;interceptors={request:{use:u(()=>0,"use"),eject:u(()=>{},"eject"),clear:u(()=>{},"clear")},response:{use:u(()=>0,"use"),eject:u(()=>{},"eject"),clear:u(()=>{},"clear")}};defaults={headers:{}};constructor(e){this.certificate=e}parseRequestHeaders(e){return e?Object.entries(e).filter(([t,n])=>n!=null).map(([t,n])=>`${t}: ${Array.isArray(n)?n.join(", "):String(n)}`).join(rW.EOL):""}parseRequestBody(e){return e?Buffer.isBuffer(e)?e:typeof e=="string"?Buffer.from(e,"utf8"):Array.isArray(e)?Buffer.concat(e):Buffer.from(JSON.stringify(e),"utf8"):Buffer.from("")}parseResponseHeaders(e){return e?e.split(`\r
|
|
84
84
|
`).reduce((t,n)=>{if(!n.trim()||n.startsWith("HTTP/"))return t;let[s,i]=n.split(":").map(a=>a.trim());return t[s]=i,t},{}):{}}parseResponseBody(e){return e?Buffer.isBuffer(e)?e.toString("utf8"):e:""}async request(e){let t=e.url??"",n=(e.method??"GET").toUpperCase(),s=Uf("winhttp_ssl_client"),{CN:i}=new Ao().extractCertificateInfo(this.certificate.certificate),a=await s.request(i??"",n,t,{headers:this.parseRequestHeaders(e.headers),body:this.parseRequestBody(e.data),timeout:e.timeout,certificateDer:Buffer.from(this.certificate.certificate.raw)});return{status:a.statusCode,data:this.parseResponseBody(a.body),statusText:this.getStatusText(a.statusCode),headers:this.parseResponseHeaders(a.headers),config:e,request:{}}}get(e,t){return this.request({...t,method:"GET",url:e})}post(e,t,n){return this.request({...n,method:"POST",url:e,data:t})}put(e,t,n){return this.request({...n,method:"PUT",url:e,data:t})}patch(e,t,n){return this.request({...n,method:"PATCH",url:e,data:t})}delete(e,t){return this.request({...t,method:"DELETE",url:e})}head(e,t){return this.request({...t,method:"HEAD",url:e})}options(e,t){return this.request({...t,method:"OPTIONS",url:e})}getUri(e){if(!e?.url)return"";try{return new URL(e.url).toString()}catch{return e.url}}static create(e){let t=new r(e),n=t.request.bind(t);return Object.setPrototypeOf(n,r.prototype),Object.assign(n,t),n}getStatusText(e){return{200:"OK",201:"Created",202:"Accepted",204:"No Content",400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"}[e]??"Unknown"}};var Y3=class{static{u(this,"SoapRemoteTransmissionRepository")}toolkit;certificateRepository;constructor(e,t){this.toolkit=e,this.certificateRepository=t}setCertificate(e){return this.certificate=e,this}validateCertificatePeriod(){if(!this.certificate)return Wr(void 0);let{certificate:e}=this.certificate,t=new Date;return t>new Date(e.validTo)?Jt(new Mt(`Certificado expirado (${Ff(e.validTo).format("DD/MM/YYYY")}). Renove o certificado.`)):t<new Date(e.validFrom)?Jt(new Mt(`O certificado ainda n\xE3o est\xE1 v\xE1lido (${Ff(e.validFrom).format("DD/MM/YYYY")}).`)):Wr(void 0)}get httpsAgent(){let e={rejectUnauthorized:!1,secureOptions:sW.SSL_OP_LEGACY_SERVER_CONNECT};if(!this.certificate)return new wb({...e});let{ca:t,password:n,certificate:s,privateKey:i}=this.certificate;return i?new wb({passphrase:n,cert:s.toString(),ca:t.map(a=>a.toString()),key:this.certificateRepository.getStringPrivateKey(i),...e}):new wb({...e})}get defaultSoapHeaders(){return{"Content-Type":"application/soap+xml; charset=utf-8"}}getDefaultRequest(e){let t=PI.create({timeout:e.timeout});return t.defaults.httpsAgent=this.httpsAgent,t}request(e){if(nW.platform()==="win32")try{return this.certificate?M2.create(this.certificate):this.getDefaultRequest({timeout:e.timeout})}catch{return this.getDefaultRequest({timeout:e.timeout})}return this.getDefaultRequest({timeout:e.timeout})}documentNode(e,t){let n=this.toolkit.getFirstNode(e)??"";for(;n&&this.toolkit.getAttribute(n,"xmlns")===t;)n=this.toolkit.getFirstNode(n)??"";return n}async send(e){let t=this.validateCertificatePeriod();if(t.isLeft())return t;try{let n=this.request({timeout:e.timeout}),s=await(0,Q3.createClientAsync)(`${e.url}?wsdl`,{request:n,endpoint:e.url,attributesKey:"$",wsdl_options:{request:n,timeout:e.timeout},forceSoap12Headers:!0});e.payload.$={xmlns:s.wsdl.definitions.$targetNamespace,...e.payload.$};let i=await this.toolkit.build(e.payload,{headless:!0,renderOpts:{pretty:!1},rootName:e.root}),a=this.documentNode(i,s.wsdl.definitions.$targetNamespace),o=e.xsd,l=await this.toolkit.validate(a,o);if(l.isLeft())return l;let c=`${e.method}Async`;if(typeof s[c]!="function"){let p=Object.keys(s).filter(d=>d.endsWith("Async"));return Jt(new Mt(`M\xE9todo SOAP "${c}" n\xE3o encontrado em ${e.url}. Dispon\xEDveis: ${p.join(", ")||"nenhum"}`))}let[f]=await s[c]({_xml:i},{request:n,timeout:e.timeout});return Wr(J3(f))}catch(n){return z3(n)}}};var iW=Uf("xml_validator"),Z3=iW;var ZZ=Py(Ak(),1);import QZ from"crypto";var Ck="application/xml";var Ct;(function(r){r[r.None=0]="None",r[r.Element=1]="Element",r[r.Attribute=2]="Attribute",r[r.Text=3]="Text",r[r.CDATA=4]="CDATA",r[r.EntityReference=5]="EntityReference",r[r.Entity=6]="Entity",r[r.ProcessingInstruction=7]="ProcessingInstruction",r[r.Comment=8]="Comment",r[r.Document=9]="Document",r[r.DocumentType=10]="DocumentType",r[r.DocumentFragment=11]="DocumentFragment",r[r.Notation=12]="Notation",r[r.Whitespace=13]="Whitespace",r[r.SignificantWhitespace=14]="SignificantWhitespace",r[r.EndElement=15]="EndElement",r[r.EndEntity=16]="EndEntity",r[r.XmlDeclaration=17]="XmlDeclaration"})(Ct||(Ct={}));function aW(r,e){let t=r.ownerDocument==null?r:r.ownerDocument,n=document.createNSResolver(r.ownerDocument==null?r.documentElement:r.ownerDocument.documentElement),s=t.evaluate(e,r,n,XPathResult.ANY_TYPE,null),i=[],a;for(;a=s.iterateNext();)i.push(a);return i}u(aW,"SelectNodesEx");function oW(r,e){let t=lh("xpath").select;return t(e,r)}u(oW,"SelectNodesNode");var xk=typeof self<"u"?aW:oW;function Q0(r){r=r.replace(/\r\n/g,`
|
|
85
85
|
`).replace(/\r/g,`
|