nfets 0.0.110 → 0.0.112

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.
@@ -94,7 +94,7 @@ Actual: `+_.attribValue);else{var Oe=_.tag,R=_.tags[_.tags.length-1]||_;Oe.ns===
94
94
  `);return a===-1?"":s.stack.slice(a+1)})();try{if(!n.stack)n.stack=i;else if(i){let a=i.indexOf(`
95
95
  `),u=a===-1?-1:i.indexOf(`
96
96
  `,a+1),c=u===-1?"":i.slice(u+1);String(n.stack).endsWith(c)||(n.stack+=`
97
- `+i)}}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Ri(this.defaults,t);let{transitional:n,paramsSerializer:s,headers:i}=t;n!==void 0&&Hg.assertOptions(n,{silentJSONParsing:ai.transitional(ai.boolean),forcedJSONParsing:ai.transitional(ai.boolean),clarifyTimeoutError:ai.transitional(ai.boolean),legacyInterceptorReqResOrdering:ai.transitional(ai.boolean)},!1),s!=null&&(J.isFunction(s)?t.paramsSerializer={serialize:s}:Hg.assertOptions(s,{encode:ai.function,serialize:ai.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Hg.assertOptions(t,{baseUrl:ai.spelling("baseURL"),withXsrfToken:ai.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&J.merge(i.common,i[t.method]);i&&J.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),t.headers=_r.concat(a,i);let u=[],c=!0;this.interceptors.request.forEach(o(function(v){if(typeof v.runWhen=="function"&&v.runWhen(t)===!1)return;c=c&&v.synchronous;let y=t.transitional||Nu;y&&y.legacyInterceptorReqResOrdering?u.unshift(v.fulfilled,v.rejected):u.push(v.fulfilled,v.rejected)},"unshiftRequestInterceptors"));let l=[];this.interceptors.response.forEach(o(function(v){l.push(v.fulfilled,v.rejected)},"pushResponseInterceptors"));let f,h=0,d;if(!c){let m=[Nw.bind(this),void 0];for(m.unshift(...u),m.push(...l),d=m.length,f=Promise.resolve(t);h<d;)f=f.then(m[h++],m[h++]);return f}d=u.length;let g=t;for(;h<d;){let m=u[h++],v=u[h++];try{g=m(g)}catch(y){v.call(this,y);break}}try{f=Nw.call(this,g)}catch(m){return Promise.reject(m)}for(h=0,d=l.length;h<d;)f=f.then(l[h++],l[h++]);return f}getUri(e){e=Ri(this.defaults,e);let t=xl(e.baseURL,e.url,e.allowAbsoluteUrls);return vl(t,e.params,e.paramsSerializer)}};J.forEach(["delete","get","head","options"],o(function(e){Iw.prototype[e]=function(t,n){return this.request(Ri(n||{},{method:e,url:t,data:(n||{}).data}))}},"forEachMethodNoData"));J.forEach(["post","put","patch"],o(function(e){function t(n){return o(function(i,a,u){return this.request(Ri(u||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))},"httpMethod")}o(t,"generateHTTPMethod"),Iw.prototype[e]=t(),Iw.prototype[e+"Form"]=t(!0)},"forEachMethodWithData"));var Kg=Iw;var due=class YM{static{o(this,"CancelToken")}constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(o(function(i){t=i},"promiseExecutor"));let n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i,a=new Promise(u=>{n.subscribe(u),i=u}).then(s);return a.cancel=o(function(){n.unsubscribe(i)},"reject"),a},e(o(function(i,a,u){n.reason||(n.reason=new Fs(i,a,u),t(n.reason))},"cancel"))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=o(n=>{e.abort(n)},"abort");return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new YM(o(function(s){e=s},"executor")),cancel:e}}},QM=due;function eB(r){return o(function(t){return r.apply(null,t)},"wrap")}o(eB,"spread");function tB(r){return J.isObject(r)&&r.isAxiosError===!0}o(tB,"isAxiosError");var rB={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(rB).forEach(([r,e])=>{rB[e]=r});var ZM=rB;function ej(r){let e=new Kg(r),t=Pg(Kg.prototype.request,e);return J.extend(t,Kg.prototype,e,{allOwnKeys:!0}),J.extend(t,e,null,{allOwnKeys:!0}),t.create=o(function(s){return ej(Ri(r,s))},"create"),t}o(ej,"createInstance");var tn=ej(Ep);tn.Axios=Kg;tn.CanceledError=Fs;tn.CancelToken=QM;tn.isCancel=Mg;tn.VERSION=El;tn.toFormData=Cu;tn.AxiosError=Pe;tn.Cancel=tn.CanceledError;tn.all=o(function(e){return Promise.all(e)},"all");tn.spread=eB;tn.isAxiosError=tB;tn.mergeConfig=Ri;tn.AxiosHeaders=_r;tn.formToJSON=r=>vw(J.isHTMLForm(r)?new FormData(r):r);tn.getAdapter=Cw.getAdapter;tn.HttpStatusCode=ZM;tn.default=tn;var Dw=tn;var{Axios:HCe,AxiosError:KCe,CanceledError:$Ce,isCancel:XCe,CancelToken:GCe,VERSION:zCe,all:WCe,Cancel:JCe,isAxiosError:YCe,spread:QCe,toFormData:ZCe,AxiosHeaders:eNe,HttpStatusCode:tNe,formToJSON:rNe,getAdapter:nNe,mergeConfig:sNe}=Dw;var mue=new Set(["ENOTFOUND","EAI_AGAIN","EAI_FAIL","EAI_NONAME"]),gue=new Set(["ETIMEDOUT","ESOCKETTIMEDOUT","ECONNABORTED"]),yue=o(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessage"),vue=o(r=>{if(!r||typeof r!="object"||!("code"in r))return;let{code:e}=r;return typeof e=="string"?e:void 0},"getCode"),xue=o(r=>{if(!r||typeof r!="object"||!("hostname"in r))return;let{hostname:e}=r;return typeof e=="string"?e:void 0},"getHostname"),nB=o(r=>{if(typeof r=="string")return r;if(r instanceof Error||yue(r))return r.message},"getMessage"),tj=o(r=>{let e=r.toLowerCase();return e.includes("timeout")||e.includes("timed out")||e.includes("time-out")},"isTimeoutMessage"),Eue=o(r=>/getaddrinfo\s+ENOTFOUND/i.test(r)||/\bENOTFOUND\b/i.test(r),"isHostNotFoundMessage"),wue=o(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"),$g=o(r=>r instanceof Error?{cause:r}:void 0,"errorOptions"),rj=o(r=>{let e=wue(r),t=nB(r)??e.map(nB).find(n=>!!n);for(let n of e){let s=vue(n);if(s&&mue.has(s))return or(new gh(t??`Host not found (${xue(n)??s})`,$g(r)));if(s&&gue.has(s))return or(new qc(t??"Transmission timeout",$g(r)));let i=nB(n);if(i&&tj(i))return or(new qc(i,$g(r)))}return t?Eue(t)?or(new gh(t,$g(r))):tj(t)?or(new qc(t,$g(r))):us(r):us(r)},"mapTransmissionError"),sB=o(r=>rj(r),"leftFromTransmissionError");var nj=Rt(require("os"),1);var Bw=class r{static{o(this,"WinHttpClient")}certificate;interceptors={request:{use:o(()=>0,"use"),eject:o(()=>{},"eject"),clear:o(()=>{},"clear")},response:{use:o(()=>0,"use"),eject:o(()=>{},"eject"),clear:o(()=>{},"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(nj.default.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
97
+ `+i)}}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Ri(this.defaults,t);let{transitional:n,paramsSerializer:s,headers:i}=t;n!==void 0&&Hg.assertOptions(n,{silentJSONParsing:ai.transitional(ai.boolean),forcedJSONParsing:ai.transitional(ai.boolean),clarifyTimeoutError:ai.transitional(ai.boolean),legacyInterceptorReqResOrdering:ai.transitional(ai.boolean)},!1),s!=null&&(J.isFunction(s)?t.paramsSerializer={serialize:s}:Hg.assertOptions(s,{encode:ai.function,serialize:ai.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Hg.assertOptions(t,{baseUrl:ai.spelling("baseURL"),withXsrfToken:ai.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&J.merge(i.common,i[t.method]);i&&J.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),t.headers=_r.concat(a,i);let u=[],c=!0;this.interceptors.request.forEach(o(function(v){if(typeof v.runWhen=="function"&&v.runWhen(t)===!1)return;c=c&&v.synchronous;let y=t.transitional||Nu;y&&y.legacyInterceptorReqResOrdering?u.unshift(v.fulfilled,v.rejected):u.push(v.fulfilled,v.rejected)},"unshiftRequestInterceptors"));let l=[];this.interceptors.response.forEach(o(function(v){l.push(v.fulfilled,v.rejected)},"pushResponseInterceptors"));let f,h=0,d;if(!c){let m=[Nw.bind(this),void 0];for(m.unshift(...u),m.push(...l),d=m.length,f=Promise.resolve(t);h<d;)f=f.then(m[h++],m[h++]);return f}d=u.length;let g=t;for(;h<d;){let m=u[h++],v=u[h++];try{g=m(g)}catch(y){v.call(this,y);break}}try{f=Nw.call(this,g)}catch(m){return Promise.reject(m)}for(h=0,d=l.length;h<d;)f=f.then(l[h++],l[h++]);return f}getUri(e){e=Ri(this.defaults,e);let t=xl(e.baseURL,e.url,e.allowAbsoluteUrls);return vl(t,e.params,e.paramsSerializer)}};J.forEach(["delete","get","head","options"],o(function(e){Iw.prototype[e]=function(t,n){return this.request(Ri(n||{},{method:e,url:t,data:(n||{}).data}))}},"forEachMethodNoData"));J.forEach(["post","put","patch"],o(function(e){function t(n){return o(function(i,a,u){return this.request(Ri(u||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))},"httpMethod")}o(t,"generateHTTPMethod"),Iw.prototype[e]=t(),Iw.prototype[e+"Form"]=t(!0)},"forEachMethodWithData"));var Kg=Iw;var due=class YM{static{o(this,"CancelToken")}constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(o(function(i){t=i},"promiseExecutor"));let n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i,a=new Promise(u=>{n.subscribe(u),i=u}).then(s);return a.cancel=o(function(){n.unsubscribe(i)},"reject"),a},e(o(function(i,a,u){n.reason||(n.reason=new Fs(i,a,u),t(n.reason))},"cancel"))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=o(n=>{e.abort(n)},"abort");return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new YM(o(function(s){e=s},"executor")),cancel:e}}},QM=due;function eB(r){return o(function(t){return r.apply(null,t)},"wrap")}o(eB,"spread");function tB(r){return J.isObject(r)&&r.isAxiosError===!0}o(tB,"isAxiosError");var rB={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(rB).forEach(([r,e])=>{rB[e]=r});var ZM=rB;function ej(r){let e=new Kg(r),t=Pg(Kg.prototype.request,e);return J.extend(t,Kg.prototype,e,{allOwnKeys:!0}),J.extend(t,e,null,{allOwnKeys:!0}),t.create=o(function(s){return ej(Ri(r,s))},"create"),t}o(ej,"createInstance");var tn=ej(Ep);tn.Axios=Kg;tn.CanceledError=Fs;tn.CancelToken=QM;tn.isCancel=Mg;tn.VERSION=El;tn.toFormData=Cu;tn.AxiosError=Pe;tn.Cancel=tn.CanceledError;tn.all=o(function(e){return Promise.all(e)},"all");tn.spread=eB;tn.isAxiosError=tB;tn.mergeConfig=Ri;tn.AxiosHeaders=_r;tn.formToJSON=r=>vw(J.isHTMLForm(r)?new FormData(r):r);tn.getAdapter=Cw.getAdapter;tn.HttpStatusCode=ZM;tn.default=tn;var Dw=tn;var{Axios:HCe,AxiosError:KCe,CanceledError:$Ce,isCancel:XCe,CancelToken:GCe,VERSION:zCe,all:WCe,Cancel:JCe,isAxiosError:YCe,spread:QCe,toFormData:ZCe,AxiosHeaders:eNe,HttpStatusCode:tNe,formToJSON:rNe,getAdapter:nNe,mergeConfig:sNe}=Dw;var mue=new Set(["ENOTFOUND","EAI_AGAIN","EAI_FAIL","EAI_NONAME"]),gue=new Set(["ETIMEDOUT","ESOCKETTIMEDOUT","ECONNABORTED"]),yue=o(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessage"),vue=o(r=>{if(!r||typeof r!="object"||!("code"in r))return;let{code:e}=r;return typeof e=="string"?e:void 0},"getCode"),xue=o(r=>{if(!r||typeof r!="object"||!("hostname"in r))return;let{hostname:e}=r;return typeof e=="string"?e:void 0},"getHostname"),nB=o(r=>{if(typeof r=="string")return r;if(r instanceof Error||yue(r))return r.message},"getMessage"),tj=o(r=>{let e=r.toLowerCase();return e.includes("timeout")||e.includes("timed out")||e.includes("time-out")||e.includes("read econnreset")},"isTimeoutMessage"),Eue=o(r=>/getaddrinfo\s+ENOTFOUND/i.test(r)||/\bENOTFOUND\b/i.test(r),"isHostNotFoundMessage"),wue=o(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"),$g=o(r=>r instanceof Error?{cause:r}:void 0,"errorOptions"),rj=o(r=>{let e=wue(r),t=nB(r)??e.map(nB).find(n=>!!n);for(let n of e){let s=vue(n);if(s&&mue.has(s))return or(new gh(t??`Host not found (${xue(n)??s})`,$g(r)));if(s&&gue.has(s))return or(new qc(t??"Transmission timeout",$g(r)));let i=nB(n);if(i&&tj(i))return or(new qc(i,$g(r)))}return t?Eue(t)?or(new gh(t,$g(r))):tj(t)?or(new qc(t,$g(r))):us(r):us(r)},"mapTransmissionError"),sB=o(r=>rj(r),"leftFromTransmissionError");var nj=Rt(require("os"),1);var Bw=class r{static{o(this,"WinHttpClient")}certificate;interceptors={request:{use:o(()=>0,"use"),eject:o(()=>{},"eject"),clear:o(()=>{},"clear")},response:{use:o(()=>0,"use"),eject:o(()=>{},"eject"),clear:o(()=>{},"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(nj.default.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
98
98
  `).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=Fh("winhttp_ssl_client"),{CN:i}=new Ka().extractCertificateInfo(this.certificate.certificate),a=await s.request(i??"",n,t,{headers:this.parseRequestHeaders(e.headers),body:this.parseRequestBody(e.data),timeout:e.timeout});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 iB=class{static{o(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 Qr(void 0);let{certificate:e}=this.certificate,t=new Date;return t>new Date(e.validTo)?or(new Mt(`Certificado expirado (${tl(e.validTo).format("DD/MM/YYYY")}). Renove o certificado.`)):t<new Date(e.validFrom)?or(new Mt(`O certificado ainda n\xE3o est\xE1 v\xE1lido (${tl(e.validFrom).format("DD/MM/YYYY")}).`)):Qr(void 0)}get httpsAgent(){let e={rejectUnauthorized:!1,secureOptions:ij.constants.SSL_OP_LEGACY_SERVER_CONNECT};if(!this.certificate)return new Rw.Agent({...e});let{ca:t,password:n,certificate:s,privateKey:i}=this.certificate;return i?new Rw.Agent({passphrase:n,cert:s.toString(),ca:t.map(a=>a.toString()),key:this.certificateRepository.getStringPrivateKey(i),...e}):new Rw.Agent({...e})}get defaultSoapHeaders(){return{"Content-Type":"application/soap+xml; charset=utf-8"}}getDefaultRequest(e){let t=Dw.create({timeout:e.timeout});return t.defaults.httpsAgent=this.httpsAgent,t}request(e){if(sj.default.platform()==="win32")try{return this.certificate?Bw.create(this.certificate):this.getDefaultRequest({timeout:e.timeout})}catch{return this.getDefaultRequest({timeout:e.timeout})}return this.getDefaultRequest({timeout:e.timeout})}async send(e){let t=this.validateCertificatePeriod();if(t.isLeft())return t;try{let n=this.request({timeout:e.timeout}),s=await(0,aj.createClientAsync)(`${e.url}?wsdl`,{request:n,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.toolkit.getFirstNode(i)??"",u=e.xsd,c=await this.toolkit.validate(a,u);if(c.isLeft())return c;let[l]=await s[`${e.method}Async`]({_xml:i},{request:n,timeout:e.timeout});return Qr(l)}catch(n){return sB(n)}}};var bue=Fh("xml_validator"),oj=bue;var IK=Rt(require("crypto"),1),ude=Rt(B9(),1);var R9="application/xml";var xt;(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"})(xt||(xt={}));function Sue(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}o(Sue,"SelectNodesEx");function Aue(r,e){let t=Ap("xpath").select;return t(e,r)}o(Aue,"SelectNodesNode");var _9=typeof self<"u"?Sue:Aue;function zg(r){r=r.replace(/\r\n/g,`
99
99
  `).replace(/\r/g,`
100
100
  `);let e;return typeof DOMParser<"u"?e=DOMParser:e=Ap("DOMParser"),new e().parseFromString(r,R9)}o(zg,"Parse");function Sp(r){let e;return typeof XMLSerializer<"u"?e=XMLSerializer:e=Ap("XMLSerializer"),new e().serializeToString(r)}o(Sp,"Stringify");function zw(r,e){let t=_9(r,e);return t&&t.length>0?t[0]:null}o(zw,"SelectSingleNode");function O9(r,e){return r&&r.nodeType===e}o(O9,"isNodeType");function Vs(r){return O9(r,xt.Element)}o(Vs,"isElement");function Sl(r){return O9(r,xt.Document)}o(Sl,"isDocument");var P9=new Map;function k9(r){for(let e in r)P9.set(e,r[e])}o(k9,"setNodeDependencies");function Ap(r){let e=P9.get(r);if(!e)throw new Error(`Node dependency not found: ${r}. Please use 'setNodeDependencies' to register it.`);return e}o(Ap,"getNodeDependency");var Wg="element",Jg="attribute",Ww="content";var Cue=1e9;function gB(r,...e){let t=r;for(let n=0;n<e.length;n++){let s=e[n];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t}o(gB,"assign");function Et(r){return e=>{let t=e;t.localName=r.localName||t.name,t.namespaceURI=r.namespaceURI||t.namespaceURI||null,t.prefix=r.prefix||t.prefix||null,t.parser=r.parser||t.parser,t.target!==t&&(t.items=gB({},t.items)),t.target=e}}o(Et,"XmlElement");function Dt(r={}){return(e,t)=>{let n=e.constructor,s=t;n.items||(n.items={}),n.target!==n&&(n.items=gB({},n.items)),n.target=e;let i;r.parser?i={parser:r.parser,required:r.required||!1,maxOccurs:r.maxOccurs||Cue,minOccurs:r.minOccurs===void 0?0:r.minOccurs,noRoot:r.noRoot||!1}:i={namespaceURI:r.namespaceURI||null,required:r.required||!1,prefix:r.prefix||null,defaultValue:r.defaultValue,converter:r.converter,noRoot:r.noRoot||!1},r.localName=r.localName||r.parser&&r.parser.localName||s;let a=n.items,u=r.parser&&r.parser.namespaceURI;a[s]={...i,namespaceURI:r.namespaceURI||u||null,prefix:r.prefix||r.parser&&r.parser.prefix||null,localName:r.localName,type:Wg},F9(e,s,r)}}o(Dt,"XmlChildElement");function wr(r={required:!1,namespaceURI:null}){return(e,t)=>{let n=e.constructor,s=t;r.localName||(r.localName=t),n.items||(n.items={}),n.target!==n&&(n.items=gB({},n.items)),n.target=e;let i=n.items;i[t]=r,i[t].type=Jg,F9(e,s,r)}}o(wr,"XmlAttribute");function F9(r,e,t){let n=`_${e}`,s={set:o(function(i){this[n]!==i&&(this.element=null,this[n]=i)},"set"),get:o(function(){if(this[n]===void 0){let i=t.defaultValue;t.parser&&(i=new t.parser,i.localName=t.localName),this[n]=i}return this[n]},"get")};Object.defineProperty(r,n,{writable:!0,enumerable:!1}),Object.defineProperty(r,e,s)}o(F9,"defineProperty");var Du=class r{static{o(this,"Collection")}constructor(e){this.items=[],e&&(this.items=e)}get Count(){return this.items.length}Item(e){return this.items[e]||null}Add(e){this.items.push(e)}Pop(){return this.items.pop()}RemoveAt(e){this.items=this.items.filter((t,n)=>n!==e)}Clear(){this.items=[]}GetIterator(){return this.items}ForEach(e){this.GetIterator().forEach(e)}Map(e){return new r(this.GetIterator().map(e))}Filter(e){return new r(this.GetIterator().filter(e))}Sort(e){return new r(this.GetIterator().sort(e))}Every(e){return this.GetIterator().every(e)}Some(e){return this.GetIterator().some(e)}IsEmpty(){return this.Count===0}};function Nue(r,...e){let t=r.replace(/%([1-9]\d*)/g,(n,s)=>{let i=parseInt(s,10)-1;return e[i]!==void 0?e[i]:""});return t=t.replace(/%%/g,"%"),t}o(Nue,"printf");function Tue(r,e){let t=r+"";for(;t.length<e;)t="0"+t;return t}o(Tue,"padNum");var _e=class{static{o(this,"XmlError")}constructor(e,...t){this.prefix="XMLJS",this.code=e,this.name=this.constructor.name;let n=Nue(Jr[e],...t);this.message=`${this.prefix}${Tue(e,4)}: ${n}`,this.stack=new Error(this.message).stack}},we;(function(r){r[r.NONE=0]="NONE",r[r.NULL_REFERENCE=1]="NULL_REFERENCE",r[r.NULL_PARAM=2]="NULL_PARAM",r[r.DECORATOR_NULL_PARAM=3]="DECORATOR_NULL_PARAM",r[r.COLLECTION_LIMIT=4]="COLLECTION_LIMIT",r[r.METHOD_NOT_IMPLEMENTED=5]="METHOD_NOT_IMPLEMENTED",r[r.METHOD_NOT_SUPPORTED=6]="METHOD_NOT_SUPPORTED",r[r.PARAM_REQUIRED=7]="PARAM_REQUIRED",r[r.CONVERTER_UNSUPPORTED=8]="CONVERTER_UNSUPPORTED",r[r.ELEMENT_MALFORMED=9]="ELEMENT_MALFORMED",r[r.ELEMENT_MISSING=10]="ELEMENT_MISSING",r[r.ATTRIBUTE_MISSING=11]="ATTRIBUTE_MISSING",r[r.CONTENT_MISSING=12]="CONTENT_MISSING",r[r.CRYPTOGRAPHIC=13]="CRYPTOGRAPHIC",r[r.CRYPTOGRAPHIC_NO_MODULE=14]="CRYPTOGRAPHIC_NO_MODULE",r[r.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM=15]="CRYPTOGRAPHIC_UNKNOWN_TRANSFORM",r[r.ALGORITHM_NOT_SUPPORTED=16]="ALGORITHM_NOT_SUPPORTED",r[r.ALGORITHM_WRONG_NAME=17]="ALGORITHM_WRONG_NAME",r[r.XML_EXCEPTION=18]="XML_EXCEPTION",r[r.KEY_INFO_CLAUSE_NOT_SUPPORTED=19]="KEY_INFO_CLAUSE_NOT_SUPPORTED"})(we||(we={}));var Jr={};Jr[we.NONE]="No description";Jr[we.NULL_REFERENCE]="Null reference";Jr[we.NULL_PARAM]="'%1' has empty '%2' object";Jr[we.DECORATOR_NULL_PARAM]="Decorator '%1' has empty '%2' parameter";Jr[we.COLLECTION_LIMIT]="Collection of '%1' in element '%2' has wrong amount of items";Jr[we.METHOD_NOT_IMPLEMENTED]="Method is not implemented";Jr[we.METHOD_NOT_SUPPORTED]="Method is not supported";Jr[we.PARAM_REQUIRED]="Required parameter is missing '%1'";Jr[we.CONVERTER_UNSUPPORTED]="Converter is not supported";Jr[we.ELEMENT_MALFORMED]="Malformed element '%1'";Jr[we.ELEMENT_MISSING]="Element '%1' is missing in '%2'";Jr[we.ATTRIBUTE_MISSING]="Attribute '%1' is missing in '%2'";Jr[we.CONTENT_MISSING]="Content is missing in '%1'";Jr[we.CRYPTOGRAPHIC]="Cryptographic error: %1";Jr[we.CRYPTOGRAPHIC_NO_MODULE]="WebCrypto module is not found";Jr[we.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM]="Unknown transform %1";Jr[we.ALGORITHM_NOT_SUPPORTED]="Algorithm is not supported '%1'";Jr[we.ALGORITHM_WRONG_NAME]="Algorithm wrong name in use '%1'";Jr[we.XML_EXCEPTION]="XML exception: %1";Jr[we.KEY_INFO_CLAUSE_NOT_SUPPORTED]="KeyInfoClause type '%1' is not supported";var sr=class{static{o(this,"Convert")}static ToString(e,t="utf8"){let n=new Uint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);default:throw new _e(we.CONVERTER_UNSUPPORTED)}}static FromString(e,t="utf8"){switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);default:throw new _e(we.CONVERTER_UNSUPPORTED)}}static ToBase64(e){if(typeof btoa<"u"){let t=this.ToString(e,"binary");return btoa(t)}else{if(typeof Buffer<"u")return Buffer.from(e).toString("base64");throw new _e(we.CONVERTER_UNSUPPORTED)}}static FromBase64(e){if(e=e.replace(/\n/g,"").replace(/\r/g,"").replace(/\t/g,"").replace(/\s/g,""),typeof atob<"u")return this.FromBinary(atob(e));if(typeof Buffer<"u")return new Uint8Array(Buffer.from(e,"base64"));throw new _e(we.CONVERTER_UNSUPPORTED)}static FromBase64Url(e){return this.FromBase64(this.Base64Padding(e.replace(/-/g,"+").replace(/_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}static FromUtf8String(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}static ToUtf8String(e){let t=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(t))}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n}static ToBinary(e){let t="";for(let n=0;n<e.length;n++)t=t+String.fromCharCode(e[n]);return t}static ToHex(e){let n=[];for(let s=0;s<e.length;s++){let i=e[s].toString(16);n.push(i.length===1?"0"+i:i)}return n.join("")}static FromHex(e){let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n=n+2){let s=e.slice(n,n+2);t[n/2]=parseInt(s,16)}return t}static ToDateTime(e){return new Date(e)}static FromDateTime(e){return e.toISOString()}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}};var oi={get:o(r=>{if(r)return sr.ToBase64(r)},"get"),set:o(r=>sr.FromBase64(r),"set")},Yg={get:o(r=>r?r.toString():"0","get"),set:o(r=>Number(r),"set")};var Iue="xml_root",ws=class r{static{o(this,"XmlObject")}static LoadXml(e){let t=new this;return t.LoadXml(e),t}static GetElement(e,t,n=!0){let s=e.getElementsByTagName(t);if(n&&s.length===0)throw new _e(we.ELEMENT_MISSING,t,e.localName);return s[0]||null}static GetAttribute(e,t,n,s=!0){if(e.hasAttribute(t))return e.getAttribute(t);if(s)throw new _e(we.ATTRIBUTE_MISSING,t,e.localName);return n}static GetElementById(e,t){if(e==null||t==null)return null;let n=null;return Sl(e)&&(n=e.getElementById(t)),n==null&&(n=zw(e,`//*[@*[local-name()='Id']='${t}']`),n==null&&(n=zw(e,`//*[@*[local-name()='ID']='${t}']`),n==null&&(n=zw(e,`//*[@*[local-name()='id']='${t}']`)))),n}static CreateDocument(e=Iue,t=null,n=null){if(n&&!t)throw new _e(we.PARAM_REQUIRED,"namespaceUri",`Prefix '${n}' requires namespaceUri`);let s="",i="",a="";n&&(s=n+":",i=":"+n),t&&(a=` xmlns${i}="${t}"`);let u=`${s}${e}`;return zg(`<${u}${a}></${u}>`)}static GetChildren(e,t,n){e=Sl(e)?e.documentElement:e;let s=[];for(let i=0;i<e.childNodes.length;i++){let a=e.childNodes[i];Vs(a)&&a.localName===t&&(a.namespaceURI===n||!n)&&s.push(a)}return s}static GetFirstChild(e,t,n){e=Sl(e)?e.documentElement:e;for(let s=0;s<e.childNodes.length;s++){let i=e.childNodes[s];if(Vs(i)&&i.localName===t&&(i.namespaceURI===n||!n))return i}return null}static GetChild(e,t,n,s=!0){for(let i=0;i<e.childNodes.length;i++){let a=e.childNodes[i];if(Vs(a)&&a.localName===t&&(a.namespaceURI===n||!n))return a}if(s)throw new _e(we.ELEMENT_MISSING,t,e.localName);return null}constructor(e={}){if(this.prefix=this.GetStatic().prefix||null,this.localName=this.GetStatic().localName,this.namespaceURI=this.GetStatic().namespaceURI,e)for(let[t,n]of Object.entries(e))n!==void 0&&(this[t]=n)}get Element(){return this.element}get Prefix(){return this.prefix}set Prefix(e){this.prefix=e}get LocalName(){return this.localName||""}get NamespaceURI(){return this.namespaceURI||null}HasChanged(){let e=this.GetStatic();if(e.items)for(let t in e.items){if(!Object.prototype.hasOwnProperty.call(e.items,t))continue;let n=e.items[t],s=this[t];if(n.parser&&s&&s.HasChanged())return!0}return this.element===null}GetXml(e){if(!(e||this.HasChanged()))return this.element||null;let t=this,n=this.CreateDocument(),s=this.CreateElement(),i=this.GetStatic(),a=this.localName||"";if(i.items)for(let u in i.items){if(!Object.prototype.hasOwnProperty.call(i.items,u))continue;let c=t[u],l=i.items[u];switch(l.type){case Ww:{let f=l,h=f.converter?f.converter.get(c):c;if(f.required&&h==null)throw new _e(we.CONTENT_MISSING,a);(f.defaultValue!==c||f.required)&&(s.textContent=h);break}case Jg:{let f=l,h=f.converter?f.converter.get(c):c;if(f.required&&h==null)throw new _e(we.ATTRIBUTE_MISSING,f.localName,a);(f.defaultValue!==c||f.required)&&(f.namespaceURI?s.setAttributeNS(f.namespaceURI,f.localName||"",h):s.setAttribute(f.localName||"",h));break}case Wg:{let f=l,h=null;if(f.parser){if(f.required&&!c||f.minOccurs&&!c.Count){let d=c?.localName||f.localName;throw new _e(we.ELEMENT_MISSING,d,a)}c&&(h=c.GetXml(c.element===void 0&&(f.required||c.Count)))}else{let d=f.converter?f.converter.get(c):c;if(f.required&&d===void 0)throw new _e(we.ELEMENT_MISSING,f.localName,a);if(c!==f.defaultValue||f.required)if(f.namespaceURI?h=n.createElementNS(f.namespaceURI,`${f.prefix?f.prefix+":":""}${f.localName}`):h=n.createElement(`${f.prefix?f.prefix+":":""}${f.localName}`),Array.isArray(d))for(let g of d){let m=g instanceof r?g.GetXml(!0):g;m!==null&&h&&h.appendChild(m)}else if(d instanceof r){let g=d.GetXml(!0);g&&h&&h.appendChild(g)}else h&&(h.textContent=d)}if(h)if(f.noRoot){let d=[];for(let v=0;v<h.childNodes.length;v++){let y=h.childNodes.item(v);Vs(y)&&d.push(y)}let g=f.minOccurs||0,m=f.maxOccurs||1/0;if(d.length<g||d.length>m)throw new _e(we.COLLECTION_LIMIT,c.localName,i.localName);d.forEach(v=>s.appendChild(v.cloneNode(!0)))}else{if(h.childNodes.length<(f.minOccurs||0)||h.childNodes.length>(f.maxOccurs||1/0))throw new _e(we.COLLECTION_LIMIT,c.localName,i.localName);s.appendChild(h)}break}}}return this.OnGetXml(s),this.element=s,s}LoadXml(e){let t,n=this;if(typeof e=="string"?t=zg(e).documentElement:t=e,!t)throw new _e(we.PARAM_REQUIRED,"element");let s=this.GetStatic(),i=this.localName||"";if(!(t.localName===i&&t.namespaceURI==this.NamespaceURI))throw new _e(we.ELEMENT_MALFORMED,i);if(s.items)for(let a in s.items){if(!Object.prototype.hasOwnProperty.call(s.items,a))continue;let u=s.items[a];switch(u.type){case Ww:{let c=u;if(c.required&&!t.textContent)throw new _e(we.CONTENT_MISSING,i);if(!t.textContent)n[a]=c.defaultValue;else{let l=c.converter?c.converter.set(t.textContent):t.textContent;n[a]=l}break}case Jg:{let c=u,l,f;if(!c.localName)throw new _e(we.PARAM_REQUIRED,"localName");if(c.namespaceURI?(l=t.hasAttributeNS.bind(t,c.namespaceURI,c.localName),f=t.getAttributeNS.bind(t,c.namespaceURI,c.localName)):(l=t.hasAttribute.bind(t,c.localName),f=t.getAttribute.bind(t,c.localName)),c.required&&!l())throw new _e(we.ATTRIBUTE_MISSING,c.localName,i);if(!l())n[a]=c.defaultValue;else{let h=f(),d=c.converter&&h?c.converter.set(h):h;n[a]=d}break}case Wg:{let c=u;if(c.noRoot){if(!c.parser)throw new _e(we.XML_EXCEPTION,`Schema for '${c.localName}' with flag noRoot must have 'parser'`);let f=new c.parser;if(!(f instanceof Cp))throw new _e(we.XML_EXCEPTION,`Schema for '${c.localName}' with flag noRoot must have 'parser' like instance of XmlCollection`);f.OnLoadXml(t),delete f.element;let h=c.minOccurs||0,d=c.maxOccurs||1/0;if(f.Count<h||f.Count>d)throw new _e(we.COLLECTION_LIMIT,c.parser.localName,i);n[a]=f;continue}let l=null;for(let f=0;f<t.childNodes.length;f++){let h=t.childNodes.item(f);if(!Vs(h))continue;let d=h;if(d.localName===c.localName&&d.namespaceURI==c.namespaceURI){l=d;break}}if(c.required&&!l)throw new _e(we.ELEMENT_MISSING,c.parser?c.parser.localName:c.localName,i);if(c.parser){if(l){let f=new c.parser;f.localName=c.localName,f.namespaceURI=c.namespaceURI,n[a]=f,f.LoadXml(l)}}else if(!l)n[a]=c.defaultValue;else{let f=l.textContent||"",h=c.converter?c.converter.set(f):f;n[a]=h}break}}}this.OnLoadXml(t),this.prefix=t.prefix||"",this.element=t}toString(){let e=this.GetXml();return e?Sp(e):""}GetElement(e,t=!0){if(!this.element)throw new _e(we.NULL_PARAM,this.localName);return r.GetElement(this.element,e,t)}GetChildren(e,t){if(!this.element)throw new _e(we.NULL_PARAM,this.localName);return r.GetChildren(this.element,e,t||this.NamespaceURI||void 0)}GetChild(e,t=!0){if(!this.element)throw new _e(we.NULL_PARAM,this.localName);return r.GetChild(this.element,e,this.NamespaceURI||void 0,t)}GetFirstChild(e,t){if(!this.element)throw new _e(we.NULL_PARAM,this.localName);return r.GetFirstChild(this.element,e,t)}GetAttribute(e,t,n=!0){if(!this.element)throw new _e(we.NULL_PARAM,this.localName);return r.GetAttribute(this.element,e,t,n)}IsEmpty(){return this.Element===void 0}OnLoadXml(e){}GetStatic(){return this.constructor}GetPrefix(){return this.Prefix?this.prefix+":":""}OnGetXml(e){}CreateElement(e,t,n=null,s=null){if(!e){let u=this.CreateDocument();if(u)e=u;else throw new _e(we.XML_EXCEPTION,"Document not created")}t=t||this.localName,n=n||this.NamespaceURI,s=s||this.prefix;let i=(s?`${s}:`:"")+t,a=n&&e?e.createElementNS(n,i):e?.createElement(i);return e&&a&&e.importNode(a,!0),a}CreateDocument(){return r.CreateDocument(this.localName,this.NamespaceURI,this.Prefix)}};var Cp=class extends ws{static{o(this,"XmlCollection")}constructor(){super(...arguments),this.MaxOccurs=Number.MAX_VALUE,this.MinOccurs=0,this.items=[]}HasChanged(){let e=super.HasChanged(),t=this.Some(n=>n.HasChanged());return e||t}get Count(){return this.items.length}Item(e){return this.items[e]||null}Add(e){this.items.push(e),this.element=null}Pop(){return this.element=null,this.items.pop()}RemoveAt(e){this.items=this.items.filter((t,n)=>n!==e),this.element=null}Clear(){this.items=[],this.element=null}GetIterator(){return this.items}ForEach(e){this.GetIterator().forEach(e)}Map(e){return new Du(this.GetIterator().map(e))}Filter(e){return new Du(this.GetIterator().filter(e))}Sort(e){return new Du(this.GetIterator().sort(e))}Every(e){return this.GetIterator().every(e)}Some(e){return this.GetIterator().some(e)}IsEmpty(){return this.Count===0}OnGetXml(e){for(let t of this.GetIterator()){let n=t.GetXml();n&&e.appendChild(n)}}OnLoadXml(e){let t=this.GetStatic();if(!t.parser)throw new _e(we.XML_EXCEPTION,`${t.localName} doesn't have required 'parser' in @XmlElement`);for(let n=0;n<e.childNodes.length;n++){let s=e.childNodes.item(n);if(!(Vs(s)&&s.localName===t.parser.localName&&s.namespaceURI==t.namespaceURI))continue;let i=s,a=new t.parser;a.LoadXml(i),this.Add(a)}}};var Np=class extends Du{static{o(this,"NamespaceManager")}Add(e){e.prefix=e.prefix||"",e.namespace=e.namespace||"",super.Add(e)}GetPrefix(e,t=this.Count-1){let n=this.Count-1;e=e||"",t>n&&(t=n);for(let s=t;s>=0;s--){let i=this.items[s];if(i.prefix===e)return i}return null}GetNamespace(e,t=this.Count-1){let n=this.Count-1;e=e||"",t>n&&(t=n);for(let s=t;s>=0;s--){let i=this.items[s];if(i.namespace===e)return i}return null}};var Due="[object ArrayBuffer]",Ze=class xB{static{o(this,"BufferSourceConverter")}static isArrayBuffer(e){return Object.prototype.toString.call(e)===Due}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=xB.toUint8Array(e),s=xB.toUint8Array(t);if(n.length!==s.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==s[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let a of t)n+=a.byteLength;let s=new Uint8Array(n),i=0;for(let a of t){let u=this.toUint8Array(a);s.set(u,i),i+=u.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},vB="string",Bue=/^[0-9a-f\s]+$/i,Rue=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,_ue=/^[a-zA-Z0-9-_]+$/,U9=class{static{o(this,"Utf8Converter")}static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=Ze.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},va=class{static{o(this,"Utf16Converter")}static toString(e,t=!1){let n=Ze.toArrayBuffer(e),s=new DataView(n),i="";for(let a=0;a<n.byteLength;a+=2){let u=s.getUint16(a,t);i+=String.fromCharCode(u)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let i=0;i<e.length;i++)s.setUint16(i*2,e.charCodeAt(i),t);return n}},ut=class Tp{static{o(this,"Convert")}static isHex(e){return typeof e===vB&&Bue.test(e)}static isBase64(e){return typeof e===vB&&Rue.test(e)}static isBase64Url(e){return typeof e===vB&&_ue.test(e)}static ToString(e,t="utf8"){let n=Ze.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return va.toString(n,!0);case"utf16":case"utf16be":return va.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return va.fromString(e,!0);case"utf16":case"utf16be":return va.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Ze.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!Tp.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!Tp.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=Tp.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return U9.fromString(e);case"utf16":case"utf16be":return va.fromString(e);case"utf16le":case"usc2":return va.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=Tp.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return U9.toString(e);case"utf16":case"utf16be":return va.toString(e);case"utf16le":case"usc2":return va.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=Ze.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=Ze.toUint8Array(e),n="",s=t.length;for(let i=0;i<s;i++){let a=t[i];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!Tp.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let i=t.slice(s,s+2);n[s/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return va.toString(e,t)}static FromUtf16String(e,t=!1){return va.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};ut.DEFAULT_UTF8_ENCODING="utf8";function B(r,e,t){var n;return r instanceof Object&&(n=r[e])!==null&&n!==void 0?n:t}o(B,"getParametersValue");function Jw(r,e=0,t=r.byteLength-e,n=!1){let s="";for(let i of new Uint8Array(r,e,t)){let a=i.toString(16).toUpperCase();a.length===1&&(s+="0"),s+=a,n&&(s+=" ")}return s.trim()}o(Jw,"bufferToHexCodes");function io(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}o(io,"utilFromBase");function _i(r,e,t=-1){let n=t,s=r,i=0,a=Math.pow(2,e);for(let u=1;u<8;u++){if(r<a){let c;if(n<0)c=new ArrayBuffer(u),i=u;else{if(n<u)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let l=new Uint8Array(c);for(let f=u-1;f>=0;f--){let h=Math.pow(2,f*e);l[i-f-1]=Math.floor(s/h),s-=l[i-f-1]*h}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}o(_i,"utilToBase");function Al(...r){let e=0,t=0;for(let i of r)e+=i.byteLength;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let i of r)s.set(new Uint8Array(i),t),t+=i.byteLength;return n}o(Al,"utilConcatBuf");function Yw(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let i of r)s.set(i,t),t+=i.length;return s}o(Yw,"utilConcatView");function EB(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let u=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(u||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let u=0;u<this.valueHex.byteLength;u++)t[u]=0;t[0]=r[0]&128;let n=io(t,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let u=0;u<this.valueHex.byteLength;u++)i[u]=r[u];return i[0]&=127,io(i,8)-n}o(EB,"utilDecodeTC");function M9(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let a=t-e,u=_i(a,8,n),c=new Uint8Array(u);return c[0]|=128,u}let s=_i(e,8,n),i=new Uint8Array(s);if(i[0]&128){let a=s.slice(0),u=new Uint8Array(a);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let c=0;c<a.byteLength;c++)i[c+1]=u[c];i[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}o(M9,"utilEncodeTC");function Bu(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}o(Bu,"isEqualBuffer");function bs(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let a=0;a<n;a++)s[a]="0";return s.join("").concat(t)}o(bs,"padNumber");var j9="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",q9="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";function Qw(r,e=!1,t=!1,n=!1){let s=0,i=0,a=0,u="",c=e?q9:j9;if(n){let l=0;for(let f=0;f<r.length;f++)if(r.charCodeAt(f)!==0){l=f;break}r=r.slice(l)}for(;s<r.length;){let l=r.charCodeAt(s++);s>=r.length&&(i=1);let f=r.charCodeAt(s++);s>=r.length&&(a=1);let h=r.charCodeAt(s++),d=l>>2,g=(l&3)<<4|f>>4,m=(f&15)<<2|h>>6,v=h&63;i===1?m=v=64:a===1&&(v=64),t?m===64?u+=`${c.charAt(d)}${c.charAt(g)}`:v===64?u+=`${c.charAt(d)}${c.charAt(g)}${c.charAt(m)}`:u+=`${c.charAt(d)}${c.charAt(g)}${c.charAt(m)}${c.charAt(v)}`:u+=`${c.charAt(d)}${c.charAt(g)}${c.charAt(m)}${c.charAt(v)}`}return u}o(Qw,"toBase64");function Ip(r,e=!1,t=!1){let n=e?q9:j9;function s(c){for(let l=0;l<64;l++)if(n.charAt(l)===c)return l;return 64}o(s,"indexOf");function i(c){return c===64?0:c}o(i,"test");let a=0,u="";for(;a<r.length;){let c=s(r.charAt(a++)),l=a>=r.length?0:s(r.charAt(a++)),f=a>=r.length?0:s(r.charAt(a++)),h=a>=r.length?0:s(r.charAt(a++)),d=i(c)<<2|i(l)>>4,g=(i(l)&15)<<4|i(f)>>2,m=(i(f)&3)<<6|i(h);u+=String.fromCharCode(d),f!==64&&(u+=String.fromCharCode(g)),h!==64&&(u+=String.fromCharCode(m))}if(t){let c=u.length,l=-1;for(let f=c-1;f>=0;f--)if(u.charCodeAt(f)!==0){l=f;break}l!==-1?u=u.slice(0,l+1):u=""}return u}o(Ip,"fromBase64");function Qg(r){let e="",t=new Uint8Array(r);for(let n of t)e+=String.fromCharCode(n);return e}o(Qg,"arrayBufferToString");function Cl(r){let e=r.length,t=new ArrayBuffer(e),n=new Uint8Array(t);for(let s=0;s<e;s++)n[s]=r.charCodeAt(s);return t}o(Cl,"stringToArrayBuffer");var Oue=Math.log(2);function H9(r){let e=Math.log(r)/Oue,t=Math.floor(e),n=Math.round(e);return t===n?t:n}o(H9,"nearestPowerOf2");function Ce(r,e){for(let t of e)delete r[t]}o(Ce,"clearProps");function Zw(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}o(Zw,"assertBigInt");function AB(r){let e=0,t=0;for(let s=0;s<r.length;s++){let i=r[s];e+=i.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let i=r[s];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}o(AB,"concat");function ao(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}o(ao,"checkBufferParams");var CB=class{static{o(this,"ViewWriter")}constructor(){this.items=[]}write(e){this.items.push(e)}final(){return AB(this.items)}},Zg=[new Uint8Array([1])],$9="0123456789",wB="name",X9="valueHexView",Pue="isHexOnly",kue="idBlock",Lue="tagClass",Fue="tagNumber",Uue="isConstructed",Vue="fromBER",Mue="toBER",jue="local",Ss="",xa=new ArrayBuffer(0),eb=new Uint8Array(0),ty="EndOfContent",z9="OCTET STRING",W9="BIT STRING";function oo(r){var e;return e=class extends r{static{o(this,"Some")}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}constructor(...n){var s;super(...n);let i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?Ze.toUint8Array(i.valueHex):eb}fromBER(n,s,i){let a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!ao(this,a,s,i))return-1;let u=s+i;return this.valueHexView=a.subarray(s,u),this.valueHexView.length?(this.blockLength=i,u):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",xa)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:ut.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}o(oo,"HexBlock");var Nl=class{static{o(this,"LocalBaseBlock")}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=Ss,warnings:n=[],valueBeforeDecode:s=eb}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Ze.toUint8Array(s)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:ut.ToHex(this.valueBeforeDecodeView)}}};Nl.NAME="baseBlock";var As=class extends Nl{static{o(this,"ValueBlock")}fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};As.NAME="valueBlock";var J9=class extends oo(Nl){static{o(this,"LocalIdentificationBlock")}constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Ze.toUint8Array(e.valueHex):eb,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",xa}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=_i(this.tagNumber,7),i=new Uint8Array(s),a=s.byteLength,u=new Uint8Array(a+1);if(u[0]=t|31,!e){for(let c=0;c<a-1;c++)u[c+1]=i[c]|128;u[a]=i[a-1]}return u.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){let s=Ze.toUint8Array(e);if(!ao(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let u=i[0]&31;if(u!==31)this.tagNumber=u,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),f=255;for(;i[c]&128;){if(l[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let d=new Uint8Array(f);for(let g=0;g<l.length;g++)d[g]=l[g];l=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,l[c-1]=i[c]&127;let h=new Uint8Array(c);for(let d=0;d<c;d++)h[d]=l[d];l=this.valueHexView=new Uint8Array(c),l.set(h),this.blockLength<=9?this.tagNumber=io(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};J9.NAME="identificationBlock";var Y9=class extends Nl{static{o(this,"LocalLengthBlock")}constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=Ze.toUint8Array(e);if(!ao(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let a=i[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let u=t+1,c=s.subarray(u,u+a);return c[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=io(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=_i(this.length,8);if(s.byteLength>127)return this.error="Too big length",xa;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let i=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let a=0;a<s.byteLength;a++)n[a+1]=i[a];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Y9.NAME="lengthBlock";var ze={},ts=class extends Nl{static{o(this,"BaseBlock")}constructor({name:e=Ss,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new J9(s),this.lenBlock=new Y9(s),this.valueBlock=i?new i(s):new As(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(e,t){let n=t||new CB;t||Q9(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let a=this.lenBlock.toBER(e);n.write(a),n.write(i)}return t?xa:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():ut.ToHex(this.toBER())}onAsciiEncoding(){let e=this.constructor.NAME,t=ut.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${t}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return Bu(t,n)}};ts.NAME="BaseBlock";function Q9(r){var e;if(r instanceof ze.Constructed)for(let t of r.valueBlock.value)Q9(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}o(Q9,"prepareIndefiniteForm");var Z9=class extends ts{static{o(this,"BaseStringBlock")}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=Ss,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Z9.NAME="BaseStringBlock";var eq=class extends oo(As){static{o(this,"LocalPrimitiveValueBlock")}constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};eq.NAME="PrimitiveValueBlock";var tq,tt=class extends ts{static{o(this,"Primitive")}constructor(e={}){super(e,eq),this.idBlock.isConstructed=!1}};tq=tt;ze.Primitive=tq;tt.NAME="PRIMITIVE";function que(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}o(que,"localChangeType");function ry(r,e=0,t=r.length){let n=e,s=new ts({},As),i=new Nl;if(!ao(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let u=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),u===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=u,t-=s.idBlock.blockLength,u=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),u===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=u,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=ts;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=ze.EndOfContent;break;case 1:c=ze.Boolean;break;case 2:c=ze.Integer;break;case 3:c=ze.BitString;break;case 4:c=ze.OctetString;break;case 5:c=ze.Null;break;case 6:c=ze.ObjectIdentifier;break;case 10:c=ze.Enumerated;break;case 12:c=ze.Utf8String;break;case 13:c=ze.RelativeObjectIdentifier;break;case 14:c=ze.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=ze.Sequence;break;case 17:c=ze.Set;break;case 18:c=ze.NumericString;break;case 19:c=ze.PrintableString;break;case 20:c=ze.TeletexString;break;case 21:c=ze.VideotexString;break;case 22:c=ze.IA5String;break;case 23:c=ze.UTCTime;break;case 24:c=ze.GeneralizedTime;break;case 25:c=ze.GraphicString;break;case 26:c=ze.VisibleString;break;case 27:c=ze.GeneralString;break;case 28:c=ze.UniversalString;break;case 29:c=ze.CharacterString;break;case 30:c=ze.BmpString;break;case 31:c=ze.DATE;break;case 32:c=ze.TimeOfDay;break;case 33:c=ze.DateTime;break;case 34:c=ze.Duration;break;default:{let l=s.idBlock.isConstructed?new ze.Constructed:new ze.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?ze.Constructed:ze.Primitive}return s=que(s,c),u=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:u,result:s}}o(ry,"localFromBER");function Or(r){if(!r.byteLength){let e=new ts({},As);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ry(Ze.toUint8Array(r).slice(),0,r.byteLength)}o(Or,"fromBER");function Hue(r,e){return r?1:e}o(Hue,"checkLen");var Ru=class extends As{static{o(this,"LocalConstructedValueBlock")}constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=Ze.toUint8Array(e);if(!ao(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;Hue(this.isIndefiniteForm,n)>0;){let a=ry(s,i,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(i=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===ty)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ty?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new CB;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?xa:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Ru.NAME="ConstructedValueBlock";var rq,ae=class extends ts{static{o(this,"Constructed")}constructor(e={}){super(e,Ru),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
@@ -80,7 +80,7 @@ Actual: `+O.attribValue);else{var _e=O.tag,R=O.tags[O.tags.length-1]||O;_e.ns===
80
80
  `).replace(/[\r\u0085\u2028\u2029]/g,`
81
81
  `)}u(IL,"normalizeLineEndings");function DL(r){if(r=r||{},r.locator===void 0&&(r.locator=!0),this.assign=r.assign||nf.assign,this.domHandler=r.domHandler||iA,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||IL,this.locator=!!r.locator,this.xmlns=this.assign(Object.create(null),r.xmlns)}u(DL,"DOMParser");DL.prototype.parseFromString=function(r,e){if(!cQ(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),n=xL.XML_ENTITIES,s=t[""]||null;uQ(e)?(n=xL.HTML_ENTITIES,s=cI.HTML):e===TL.XML_SVG_IMAGE&&(s=cI.SVG),t[""]=s,t.xml=t.xml||cI.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 fQ;o.errorHandler=i,o.domBuilder=i;var l=!nf.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 iA(r){var e=r||{};this.mimeType=e.mimeType||TL.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(iA,"DOMHandler");function H0(r,e){e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber}u(H0,"position");iA.prototype={startDocument:u(function(){var r=new oQ;this.doc=lQ(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;sA(this,i),this.currentElement=i,this.locator&&H0(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&&H0(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&&H0(this.locator,t),sA(this,t)},"processingInstruction"),ignorableWhitespace:u(function(r,e,t){},"ignorableWhitespace"),characters:u(function(r,e,t){if(r=NL.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&&H0(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=NL.apply(this,arguments);var n=this.doc.createComment(r);this.locator&&H0(this.locator,n),sA(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&&H0(this.locator,i),sA(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 bL("Reporting "+r+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+r+"] "+e,hQ(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){throw this.reportError("fatalError",r),new bL(r,this.locator)},"fatalError")};function hQ(r){if(r)return`
82
82
  @#[line:`+r.lineNumber+",col:"+r.columnNumber+"]"}u(hQ,"_locator");function NL(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(NL,"_toString");"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){iA.prototype[r]=function(){return null}});function sA(r,e){r.currentElement?r.currentElement.appendChild(e):r.doc.appendChild(e)}u(sA,"appendElement");function pQ(r){if(r==="error")throw"onErrorStopParsing"}u(pQ,"onErrorStopParsing");function dQ(){throw"onWarningStopParsing"}u(dQ,"onWarningStopParsing");K0.__DOMHandler=iA;K0.DOMParser=DL;K0.normalizeLineEndings=IL;K0.onErrorStopParsing=pQ;K0.onWarningStopParsing=dQ});var RL=ue(Ut=>{"use strict";var X0=tf();Ut.assign=X0.assign;Ut.hasDefaultHTMLNamespace=X0.hasDefaultHTMLNamespace;Ut.isHTMLMimeType=X0.isHTMLMimeType;Ut.isValidMimeType=X0.isValidMimeType;Ut.MIME_TYPE=X0.MIME_TYPE;Ut.NAMESPACE=X0.NAMESPACE;var aA=dy();Ut.DOMException=aA.DOMException;Ut.DOMExceptionName=aA.DOMExceptionName;Ut.ExceptionCode=aA.ExceptionCode;Ut.ParseError=aA.ParseError;var Yr=uI();Ut.Attr=Yr.Attr;Ut.CDATASection=Yr.CDATASection;Ut.CharacterData=Yr.CharacterData;Ut.Comment=Yr.Comment;Ut.Document=Yr.Document;Ut.DocumentFragment=Yr.DocumentFragment;Ut.DocumentType=Yr.DocumentType;Ut.DOMImplementation=Yr.DOMImplementation;Ut.Element=Yr.Element;Ut.Entity=Yr.Entity;Ut.EntityReference=Yr.EntityReference;Ut.LiveNodeList=Yr.LiveNodeList;Ut.NamedNodeMap=Yr.NamedNodeMap;Ut.Node=Yr.Node;Ut.NodeList=Yr.NodeList;Ut.Notation=Yr.Notation;Ut.ProcessingInstruction=Yr.ProcessingInstruction;Ut.Text=Yr.Text;Ut.XMLSerializer=Yr.XMLSerializer;var oA=BL();Ut.DOMParser=oA.DOMParser;Ut.normalizeLineEndings=oA.normalizeLineEndings;Ut.onErrorStopParsing=oA.onErrorStopParsing;Ut.onWarningStopParsing=oA.onWarningStopParsing});var lA="http://www.w3.org/2000/09/xmldsig#",mI="http://www.w3.org/TR/2001/REC-xml-c14n-20010315",cA=(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})({}),eo=(function(r){return r.SHA1="sha1",r.SHA256="sha256",r})({}),fA=(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 Qt={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"},AQ=Object.keys(Qt);var xQ={Production:"1",Homolog:"2"};var EV={[Qt.AC]:"America/Rio_Branco",[Qt.AL]:"America/Maceio",[Qt.AM]:"America/Manaus",[Qt.AP]:"America/Belem",[Qt.BA]:"America/Bahia",[Qt.CE]:"America/Fortaleza",[Qt.DF]:"America/Sao_Paulo",[Qt.ES]:"America/Sao_Paulo",[Qt.GO]:"America/Sao_Paulo",[Qt.MA]:"America/Fortaleza",[Qt.MG]:"America/Sao_Paulo",[Qt.MS]:"America/Campo_Grande",[Qt.MT]:"America/Cuiaba",[Qt.PA]:"America/Belem",[Qt.PB]:"America/Fortaleza",[Qt.PE]:"America/Recife",[Qt.PI]:"America/Fortaleza",[Qt.PR]:"America/Sao_Paulo",[Qt.RJ]:"America/Sao_Paulo",[Qt.RN]:"America/Fortaleza",[Qt.RO]:"America/Porto_Velho",[Qt.RR]:"America/Boa_Vista",[Qt.RS]:"America/Sao_Paulo",[Qt.SC]:"America/Sao_Paulo",[Qt.SE]:"America/Maceio",[Qt.SP]:"America/Sao_Paulo",[Qt.TO]:"America/Araguaina"};var Mt=class extends Error{static{u(this,"NFeTsError")}};var Dy=class extends Mt{static{u(this,"TransmissionError")}},W0=class extends Dy{static{u(this,"TransmissionHostNotFoundError")}},uf=class extends Dy{static{u(this,"TransmissionTimeoutError")}};var gI=class extends Mt{static{u(this,"ValidationError")}};var z0={includeComments:!1,exclusive:!0};var hA=u(r=>{throw new Mt("Didn't expect to get here")},"unreachable");var lf=class{static{u(this,"Signer")}toolkit;certificateRepository;algorithm;canonical;constructor(e,t,n=eo.SHA1,s=z0){this.toolkit=e,this.certificateRepository=t,this.algorithm=n,this.canonical=s}assemble(e,t,n){let s=this.certificateRepository.getStringCertificate(n);return{$:{xmlns:lA},SignedInfo:e,SignatureValue:t,KeyInfo:{X509Data:{X509Certificate:s}}}}signedInfo(e,t){return{CanonicalizationMethod:{$:{Algorithm:mI}},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:lA},...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 eo.SHA256:return fA.SHA256;case eo.SHA1:return fA.SHA1;default:return hA(this.algorithm)}}get signatureMethod(){switch(this.algorithm){case eo.SHA256:return cA.RSA_SHA256;case eo.SHA1:return cA.RSA_SHA1;default:return hA(this.algorithm)}}};var pA=class{static{u(this,"Left")}value;constructor(e){this.value=e}isLeft(){return!0}isRight(){return!1}},By=class{static{u(this,"Right")}value;constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}},rr=u(r=>new pA(r),"left"),Hr=u(r=>r===void 0?new By(void 0):new By(r),"right");var yI=class extends lf{static{u(this,"EntitySigner")}async sign(e,t,n){let{tag:s,mark:i}=t,{certificate:a}=n;if(!e[s])return rr(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),Hr(f)}ns(e,t){let n=e.$?.xmlns,{$:s,...i}=e[t],{xmlns:a,...o}=s??{};return{$:{xmlns:n,...o},...i}}};var vI=class extends lf{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 rr(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 Hr(this.toolkit.appendNode(e,f))}};import"reflect-metadata";import{validateSync as SV}from"class-validator";import"reflect-metadata";var J0="__SkipValidation__",wZ=u(()=>(r,e)=>{Reflect.defineMetadata(J0,!0,r,e.toString())},"SkipValidation"),SZ=u(()=>r=>{Reflect.defineMetadata(J0,!0,r)},"SkipAllValidations");import{plainToInstance as wV}from"class-transformer";var Ry=u(r=>{for(let[e,t]of Object.entries(r))typeof t>"u"&&delete r[e],t===""&&delete r[e],t&&typeof t=="object"&&Ry(t)},"clearEmptyValues"),EI=u((r,e,t={})=>{let n=wV(e,r);return t.clearEmptyValues&&Ry(n),n},"plainToInstance");var wI="__ValidateErrors__",SI=u((r,e)=>r.reduce((t,n)=>{if(n.children?.length)return t.concat(SI(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"),RZ=u(r=>(e,t,n)=>{let s=n.value;n.value=function(...i){let a=Reflect.getMetadata(J0,this.constructor);if(Reflect.getMetadata(J0,this.constructor.prototype,t.toString())===!0||a===!0)return s?.apply(this,i);let[l,...c]=i;if(!l)return s?.apply(this,i);let f=EI(l,r),p=SV(f,{whitelist:!0});if(Ry(f),p.length){let d=Reflect.getMetadata(wI,this)??[];Reflect.defineMetadata(wI,d.concat(SI(p,s?.name)),this)}return s?.apply(this,[f,...c])}},"Validates");import"reflect-metadata";var cf=9e15,so=1e9,dA="0123456789abcdef",Py="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ky="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",mA={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-cf,maxE:cf,crypto:!1},bI,ra,ft=!0,Vy="[DecimalError] ",no=Vy+"Invalid argument: ",NI=Vy+"Precision limit exceeded",TI=Vy+"crypto unavailable",II="[object Decimal]",xn=Math.floor,Kr=Math.pow,AV=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,CV=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,xV=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,DI=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ws=1e7,it=7,bV=9007199254740991,NV=Py.length-1,gA=ky.length-1,Se={toStringTag:II};Se.absoluteValue=Se.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),Qe(r)};Se.ceil=function(){return Qe(new this.constructor(this),this.e+1,2)};Se.clampedTo=Se.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(no+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};Se.comparedTo=Se.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};Se.cosine=Se.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())+it,n.rounding=1,t=TV(n,PI(n,t)),n.precision=r,n.rounding=e,Qe(ra==2||ra==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};Se.cubeRoot=Se.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(ft=!1,i=f.s*Kr(f.s*f,1/3),!i||Math.abs(i)==1/0?(t=hn(f.d),r=f.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=Kr(t,1/3),r=xn((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=or(c.plus(f).times(o),c.plus(l),a+2,1),hn(o.d).slice(0,a)===(t=hn(n.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(Qe(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")&&(Qe(n,r+1,1),e=!n.times(n).times(n).eq(f));break}return ft=!0,Qe(n,r,p.rounding,e)};Se.decimalPlaces=Se.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-xn(this.e/it))*it,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};Se.dividedBy=Se.div=function(r){return or(this,new this.constructor(r))};Se.dividedToIntegerBy=Se.divToInt=function(r){var e=this,t=e.constructor;return Qe(or(e,new t(r),0,1,1),t.precision,t.rounding)};Se.equals=Se.eq=function(r){return this.cmp(r)===0};Se.floor=function(){return Qe(new this.constructor(this),this.e+1,3)};Se.greaterThan=Se.gt=function(r){return this.cmp(r)>0};Se.greaterThanOrEqualTo=Se.gte=function(r){var e=this.cmp(r);return e==1||e===0};Se.hyperbolicCosine=Se.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/Uy(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=ff(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 Qe(i,a.precision=t,a.rounding=n,!0)};Se.hyperbolicSine=Se.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=ff(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/Uy(5,r)),s=ff(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,Qe(s,e,t,!0)};Se.hyperbolicTangent=Se.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,or(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};Se.inverseCosine=Se.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()?mi(e,n,s):new e(0):new e(NaN):r.isZero()?mi(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))};Se.inverseHyperbolicCosine=Se.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,ft=!1,t=t.times(t).minus(1).sqrt().plus(t),ft=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};Se.inverseHyperbolicSine=Se.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,ft=!1,t=t.times(t).plus(1).sqrt().plus(t),ft=!0,n.precision=r,n.rounding=e,t.ln())};Se.inverseHyperbolicTangent=Se.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?Qe(new i(s),r,e,!0):(i.precision=t=n-s.e,s=or(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)};Se.inverseSine=Se.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=mi(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)))};Se.inverseTangent=Se.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<=gA)return a=mi(f,p+4,d).times(.25),a.s=c.s,a}else{if(!c.s)return new f(NaN);if(p+4<=gA)return a=mi(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/it+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(ft=!1,e=Math.ceil(o/it),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)),ft=!0,Qe(a,f.precision=p,f.rounding=d,!0)};Se.isFinite=function(){return!!this.d};Se.isInteger=Se.isInt=function(){return!!this.d&&xn(this.e/it)>this.d.length-2};Se.isNaN=function(){return!this.s};Se.isNegative=Se.isNeg=function(){return this.s<0};Se.isPositive=Se.isPos=function(){return this.s>0};Se.isZero=function(){return!!this.d&&this.d[0]===0};Se.lessThan=Se.lt=function(r){return this.cmp(r)<0};Se.lessThanOrEqualTo=Se.lte=function(r){return this.cmp(r)<1};Se.logarithm=Se.log=function(r){var e,t,n,s,i,a,o,l,c=this,f=c.constructor,p=f.precision,d=f.rounding,g=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(ft=!1,o=p+g,a=ro(c,o),n=e?Ly(f,o+10):ro(r,o),l=or(a,n,o,1),Y0(l.d,s=p,d))do if(o+=10,a=ro(c,o),n=e?Ly(f,o+10):ro(r,o),l=or(a,n,o,1),!i){+hn(l.d).slice(s+1,s+15)+1==1e14&&(l=Qe(l,p+1,0));break}while(Y0(l.d,s+=10,d));return ft=!0,Qe(l,p,d)};Se.minus=Se.sub=function(r){var e,t,n,s,i,a,o,l,c,f,p,d,g=this,m=g.constructor;if(r=new m(r),!g.d||!r.d)return!g.s||!r.s?r=new m(NaN):g.d?r.s=-r.s:r=new m(r.d||g.s!==r.s?g:NaN),r;if(g.s!=r.s)return r.s=-r.s,g.plus(r);if(c=g.d,d=r.d,o=m.precision,l=m.rounding,!c[0]||!d[0]){if(d[0])r.s=-r.s;else if(c[0])r=new m(g);else return new m(l===3?-0:0);return ft?Qe(r,o,l):r}if(t=xn(r.e/it),f=xn(g.e/it),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/it),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]=Ws-1;--c[s],c[n]+=Ws}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=Fy(c,t),ft?Qe(r,o,l):r):new m(l===3?-0:0)};Se.modulo=Se.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]?Qe(new n(t),n.precision,n.rounding):(ft=!1,n.modulo==9?(e=or(t,r.abs(),0,3,1),e.s*=r.s):e=or(t,r,0,n.modulo,1),e=e.times(r),ft=!0,t.minus(e))};Se.naturalExponential=Se.exp=function(){return yA(this)};Se.naturalLogarithm=Se.ln=function(){return ro(this)};Se.negated=Se.neg=function(){var r=new this.constructor(this);return r.s=-r.s,Qe(r)};Se.plus=Se.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)),ft?Qe(r,o,l):r;if(i=xn(p.e/it),n=xn(r.e/it),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/it),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)/Ws|0,c[s]%=Ws;for(e&&(c.unshift(e),++n),a=c.length;c[--a]==0;)c.pop();return r.d=c,r.e=Fy(c,n),ft?Qe(r,o,l):r};Se.precision=Se.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(no+r);return t.d?(e=BI(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};Se.round=function(){var r=this,e=r.constructor;return Qe(new e(r),r.e+1,e.rounding)};Se.sine=Se.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())+it,n.rounding=1,t=DV(n,PI(n,t)),n.precision=r,n.rounding=e,Qe(ra>2?t.neg():t,r,e,!0)):new n(NaN)};Se.squareRoot=Se.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(ft=!1,c=Math.sqrt(+a),c==0||c==1/0?(e=hn(o),(e.length+l)%2==0&&(e+="0"),c=Math.sqrt(e),l=xn((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(or(a,i,t+2,1)).times(.5),hn(i.d).slice(0,t)===(e=hn(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(Qe(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")&&(Qe(n,l+1,1),r=!n.times(n).eq(a));break}return ft=!0,Qe(n,l,f.rounding,r)};Se.tangent=Se.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=or(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,Qe(ra==2||ra==4?t.neg():t,r,e,!0)):new n(NaN)};Se.times=Se.mul=function(r){var e,t,n,s,i,a,o,l,c,f=this,p=f.constructor,d=f.d,g=(r=new p(r)).d;if(r.s*=f.s,!d||!d[0]||!g||!g[0])return new p(!r.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:!d||!g?r.s/0:r.s*0);for(t=xn(f.e/it)+xn(r.e/it),l=d.length,c=g.length,l<c&&(i=d,d=g,g=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]+g[n]*d[s-n-1]+e,i[s--]=o%Ws|0,e=o/Ws|0;i[s]=(i[s]+e)%Ws|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),r.d=i,r.e=Fy(i,t),ft?Qe(r,p.precision,p.rounding):r};Se.toBinary=function(r,e){return vA(this,2,r,e)};Se.toDecimalPlaces=Se.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(jn(r,0,so),e===void 0?e=n.rounding:jn(e,0,8),Qe(t,r+t.e+1,e))};Se.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=gi(n,!0):(jn(r,0,so),e===void 0?e=s.rounding:jn(e,0,8),n=Qe(new s(n),r+1,e),t=gi(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};Se.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=gi(s):(jn(r,0,so),e===void 0?e=i.rounding:jn(e,0,8),n=Qe(new i(s),r+s.e+1,e),t=gi(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};Se.toFraction=function(r){var e,t,n,s,i,a,o,l,c,f,p,d,g=this,m=g.d,v=g.constructor;if(!m)return new v(g);if(c=t=new v(1),n=l=new v(0),e=new v(n),i=e.e=BI(m)-g.e-1,a=i%it,e.d[0]=Kr(10,a<0?it+a:a),r==null)r=i>0?e:c;else{if(o=new v(r),!o.isInt()||o.lt(c))throw Error(no+o);r=o.gt(e)?i>0?e:c:o}for(ft=!1,o=new v(hn(m)),f=v.precision,v.precision=i=m.length*it*2;p=or(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=or(r.minus(t),n,0,1,1),l=l.plus(s.times(c)),t=t.plus(s.times(n)),l.s=c.s=g.s,d=or(c,n,i,1).minus(g).abs().cmp(or(l,t,i,1).minus(g).abs())<1?[c,n]:[l,t],v.precision=f,ft=!0,d};Se.toHexadecimal=Se.toHex=function(r,e){return vA(this,16,r,e)};Se.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:jn(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]?(ft=!1,t=or(t,r,0,e,1).times(r),ft=!0,Qe(t)):(r.s=t.s,t=r),t};Se.toNumber=function(){return+this};Se.toOctal=function(r,e){return vA(this,8,r,e)};Se.toPower=Se.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(Kr(+o,c));if(o=new l(o),o.eq(1))return o;if(n=l.precision,i=l.rounding,r.eq(1))return Qe(o,n,i);if(e=xn(r.e/it),e>=r.d.length-1&&(t=c<0?-c:c)<=bV)return s=RI(l,o,t,n),r.s<0?new l(1).div(s):Qe(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=Kr(+o,c),e=t==0||!isFinite(t)?xn(c*(Math.log("0."+hn(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):(ft=!1,l.rounding=o.s=1,t=Math.min(12,(e+"").length),s=yA(r.times(ro(o,n+t)),n),s.d&&(s=Qe(s,n+5,1),Y0(s.d,n,i)&&(e=n+10,s=Qe(yA(r.times(ro(o,e+t)),e),e+5,1),+hn(s.d).slice(n+1,n+15)+1==1e14&&(s=Qe(s,n+1,0)))),s.s=a,ft=!0,l.rounding=i,Qe(s,n,i))};Se.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=gi(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(jn(r,1,so),e===void 0?e=s.rounding:jn(e,0,8),n=Qe(new s(n),r,e),t=gi(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};Se.toSignificantDigits=Se.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(jn(r,1,so),e===void 0?e=n.rounding:jn(e,0,8)),Qe(new n(t),r,e)};Se.toString=function(){var r=this,e=r.constructor,t=gi(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};Se.truncated=Se.trunc=function(){return Qe(new this.constructor(this),this.e+1,1)};Se.valueOf=Se.toJSON=function(){var r=this,e=r.constructor,t=gi(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function hn(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=it-n.length,t&&(i+=to(t)),i+=n;a=r[e],n=a+"",t=it-n.length,t&&(i+=to(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}u(hn,"digitsToString");function jn(r,e,t){if(r!==~~r||r<e||r>t)throw Error(no+r)}u(jn,"checkInt32");function Y0(r,e,t,n){var s,i,a,o;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=it,s=0):(s=Math.ceil((e+1)/it),e%=it),i=Kr(10,it-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)==Kr(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)==Kr(10,e-3)-1,a}u(Y0,"checkRoundingDigits");function Oy(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]+=dA.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(Oy,"convertBase");function TV(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/Uy(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=ff(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(TV,"cosine");var or=(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,g,m,v,y,S,C,w,E,A,b,V,I,D,U,F,M,se=n.constructor,ee=n.s==s.s?1:-1,ie=n.d,X=s.d;if(!ie||!ie[0]||!X||!X[0])return new se(!n.s||!s.s||(ie?X&&ie[0]==X[0]:!X)?NaN:ie&&ie[0]==0||!X?ee*0:ee/0);for(l?(g=1,f=n.e-s.e):(l=Ws,g=it,f=xn(n.e/g)-xn(s.e/g)),F=X.length,D=ie.length,S=new se(ee),C=S.d=[],p=0;X[p]==(ie[p]||0);p++);if(X[p]>(ie[p]||0)&&f--,i==null?(b=i=se.precision,a=se.rounding):o?b=i+(n.e-s.e)+1:b=i,b<0)C.push(1),m=!0;else{if(b=b/g+2|0,p=0,F==1){for(d=0,X=X[0],b++;(p<D||d)&&b--;p++)V=d*l+(ie[p]||0),C[p]=V/X|0,d=V%X|0;m=d||p<D}else{for(d=l/(X[0]+1)|0,d>1&&(X=r(X,d,l),ie=r(ie,d,l),F=X.length,D=ie.length),I=F,w=ie.slice(0,F),E=w.length;E<F;)w[E++]=0;M=X.slice(),M.unshift(0),U=X[0],X[1]>=l/2&&++U;do d=0,c=e(X,w,F,E),c<0?(A=w[0],F!=E&&(A=A*l+(w[1]||0)),d=A/U|0,d>1?(d>=l&&(d=l-1),v=r(X,d,l),y=v.length,E=w.length,c=e(v,w,y,E),c==1&&(d--,t(v,F<y?M:X,y,l))):(d==0&&(c=d=1),v=X.slice()),y=v.length,y<E&&v.unshift(0),t(w,v,E,l),c==-1&&(E=w.length,c=e(X,w,F,E),c<1&&(d++,t(w,F<E?M:X,E,l))),E=w.length):c===0&&(d++,w=[0]),C[p++]=d,c&&w[0]?w[E++]=ie[I]||0:(w=[ie[I]],E=1);while((I++<D||w[0]!==void 0)&&b--);m=w[0]!==void 0}C[0]||C.shift()}if(g==1)S.e=f,bI=m;else{for(p=1,d=C[0];d>=10;d/=10)p++;S.e=p+f*g-1,Qe(S,o?i+S.e+1:i,a,m)}return S}})();function Qe(r,e,t,n){var s,i,a,o,l,c,f,p,d,g=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+=it,a=e,f=p[d=0],l=f/Kr(10,s-a-1)%10|0;else if(d=Math.ceil((i+1)/it),o=p.length,d>=o)if(n){for(;o++<=d;)p.push(0);f=l=0,s=1,i%=it,a=i-it+1}else break e;else{for(f=o=p[d],s=1;o>=10;o/=10)s++;i%=it,a=i-it+s,l=a<0?0:f/Kr(10,s-a-1)%10|0}if(n=n||e<0||p[d+1]!==void 0||(a<0?f:f%Kr(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/Kr(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]=Kr(10,(it-e%it)%it),r.e=-e||0):p[0]=r.e=0,r;if(i==0?(p.length=d,o=1,d--):(p.length=d+1,o=Kr(10,it-i),p[d]=a>0?(f/Kr(10,s-a)%Kr(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]==Ws&&(p[0]=1));break}else{if(p[d]+=o,p[d]!=Ws)break;p[d--]=0,o=1}for(i=p.length;p[--i]===0;)p.pop()}return ft&&(r.e>g.maxE?(r.d=null,r.e=NaN):r.e<g.minE&&(r.e=0,r.d=[0])),r}u(Qe,"finalise");function gi(r,e,t){if(!r.isFinite())return _I(r);var n,s=r.e,i=hn(r.d),a=i.length;return e?(t&&(n=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+to(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+to(-s-1)+i,t&&(n=t-a)>0&&(i+=to(n))):s>=a?(i+=to(s+1-a),t&&(n=t-s-1)>0&&(i=i+"."+to(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-a)>0&&(s+1===a&&(i+="."),i+=to(n))),i}u(gi,"finiteToString");function Fy(r,e){var t=r[0];for(e*=it;t>=10;t/=10)e++;return e}u(Fy,"getBase10Exponent");function Ly(r,e,t){if(e>NV)throw ft=!0,t&&(r.precision=t),Error(NI);return Qe(new r(Py),e,1,!0)}u(Ly,"getLn10");function mi(r,e,t){if(e>gA)throw Error(NI);return Qe(new r(ky),e,t,!0)}u(mi,"getPi");function BI(r){var e=r.length-1,t=e*it+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(BI,"getPrecision");function to(r){for(var e="";r--;)e+="0";return e}u(to,"getZeroString");function RI(r,e,t,n){var s,i=new r(1),a=Math.ceil(n/it+4);for(ft=!1;;){if(t%2&&(i=i.times(e),CI(i.d,a)&&(s=!0)),t=xn(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),CI(e.d,a)}return ft=!0,i}u(RI,"intPow");function AI(r){return r.d[r.d.length-1]&1}u(AI,"isOdd");function OI(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(OI,"maxOrMin");function yA(r,e){var t,n,s,i,a,o,l,c=0,f=0,p=0,d=r.constructor,g=d.rounding,m=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?(ft=!1,l=m):l=e,o=new d(.03125);r.e>-2;)r=r.times(o),p+=5;for(n=Math.log(Kr(2,p))/Math.LN10*2+5|0,l+=n,t=i=a=new d(1),d.precision=l;;){if(i=Qe(i.times(r),l,1),t=t.times(++f),o=a.plus(or(i,t,l,1)),hn(o.d).slice(0,l)===hn(a.d).slice(0,l)){for(s=p;s--;)a=Qe(a.times(a),l,1);if(e==null)if(c<3&&Y0(a.d,l-n,g,c))d.precision=l+=10,t=i=o=new d(1),f=0,c++;else return Qe(a,d.precision=m,g,ft=!0);else return d.precision=m,a}a=o}}u(yA,"naturalExponential");function ro(r,e){var t,n,s,i,a,o,l,c,f,p,d,g=1,m=10,v=r,y=v.d,S=v.constructor,C=S.rounding,w=S.precision;if(v.s<0||!y||!y[0]||!v.e&&y[0]==1&&y.length==1)return new S(y&&!y[0]?-1/0:v.s!=1?NaN:y?0:v);if(e==null?(ft=!1,f=w):f=e,S.precision=f+=m,t=hn(y),n=t.charAt(0),Math.abs(i=v.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)v=v.times(r),t=hn(v.d),n=t.charAt(0),g++;i=v.e,n>1?(v=new S("0."+t),i++):v=new S(n+"."+t.slice(1))}else return c=Ly(S,f+2,w).times(i+""),v=ro(new S(n+"."+t.slice(1)),f-m).plus(c),S.precision=w,e==null?Qe(v,w,C,ft=!0):v;for(p=v,l=a=v=or(v.minus(1),v.plus(1),f,1),d=Qe(v.times(v),f,1),s=3;;){if(a=Qe(a.times(d),f,1),c=l.plus(or(a,new S(s),f,1)),hn(c.d).slice(0,f)===hn(l.d).slice(0,f))if(l=l.times(2),i!==0&&(l=l.plus(Ly(S,f+2,w).times(i+""))),l=or(l,new S(g),f,1),e==null)if(Y0(l.d,f-m,C,o))S.precision=f+=m,c=a=v=or(p.minus(1),p.plus(1),f,1),d=Qe(v.times(v),f,1),s=o=1;else return Qe(l,S.precision=w,C,ft=!0);else return S.precision=w,l;l=c,s+=2}}u(ro,"naturalLogarithm");function _I(r){return String(r.s*r.s/0)}u(_I,"nonFiniteToString");function _y(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)%it,t<0&&(n+=it),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=it;n<s;)r.d.push(+e.slice(n,n+=it));e=e.slice(n),n=it-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),ft&&(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(_y,"parseDecimal");function IV(r,e){var t,n,s,i,a,o,l,c,f;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),DI.test(e))return _y(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(CV.test(e))t=16,e=e.toLowerCase();else if(AV.test(e))t=2;else if(xV.test(e))t=8;else throw Error(no+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=RI(n,new n(t),i,i*2)),c=Oy(e,t,Ws),f=c.length-1,i=f;c[i]===0;--i)c.pop();return i<0?new n(r.s*0):(r.e=Fy(c,f),r.d=c,ft=!1,a&&(r=or(r,s,o*4)),l&&(r=r.times(Math.abs(l)<54?Kr(2,l):hf.pow(2,l))),ft=!0,r)}u(IV,"parseOther");function DV(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ff(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Uy(5,t)),e=ff(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(DV,"sine");function ff(r,e,t,n,s){var i,a,o,l,c=1,f=r.precision,p=Math.ceil(f/it);for(ft=!1,l=t.times(t),o=new r(n);;){if(a=or(o.times(l),new r(e++*e++),f,1),o=s?n.plus(a):n.minus(a),n=or(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 ft=!0,a.d.length=p+1,a}u(ff,"taylorSeries");function Uy(r,e){for(var t=r;--e;)t*=r;return t}u(Uy,"tinyPow");function PI(r,e){var t,n=e.s<0,s=mi(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return ra=n?4:1,e;if(t=e.divToInt(s),t.isZero())ra=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return ra=AI(t)?n?2:3:n?4:1,e;ra=AI(t)?n?1:4:n?3:2}return e.minus(s).abs()}u(PI,"toLessThanHalfPi");function vA(r,e,t,n){var s,i,a,o,l,c,f,p,d,g=r.constructor,m=t!==void 0;if(m?(jn(t,1,so),n===void 0?n=g.rounding:jn(n,0,8)):(t=g.precision,n=g.rounding),!r.isFinite())f=_I(r);else{for(f=gi(r),a=f.indexOf("."),m?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(f=f.replace(".",""),d=new g(1),d.e=f.length-a,d.d=Oy(gi(d),10,s),d.e=d.d.length),p=Oy(f,10,s),i=l=p.length;p[--l]==0;)p.pop();if(!p[0])f=m?"0p+0":"0";else{if(a<0?i--:(r=new g(r),r.d=p,r.e=i,r=or(r,d,t,n,0,s),p=r.d,i=r.e,c=bI),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+=dA.charAt(p[a]);if(m){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)f+="0";for(p=Oy(f,s,e),l=p.length;!p[l-1];--l);for(a=1,f="1.";a<l;a++)f+=dA.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(vA,"toStringBinary");function CI(r,e){if(r.length>e)return r.length=e,!0}u(CI,"truncate");function BV(r){return new this(r).abs()}u(BV,"abs");function RV(r){return new this(r).acos()}u(RV,"acos");function OV(r){return new this(r).acosh()}u(OV,"acosh");function _V(r,e){return new this(r).plus(e)}u(_V,"add");function PV(r){return new this(r).asin()}u(PV,"asin");function kV(r){return new this(r).asinh()}u(kV,"asinh");function LV(r){return new this(r).atan()}u(LV,"atan");function VV(r){return new this(r).atanh()}u(VV,"atanh");function FV(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=mi(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?mi(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=mi(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(or(r,e,i,1)),e=mi(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(or(r,e,i,1)),t}u(FV,"atan2");function UV(r){return new this(r).cbrt()}u(UV,"cbrt");function MV(r){return Qe(r=new this(r),r.e+1,2)}u(MV,"ceil");function jV(r,e,t){return new this(r).clamp(e,t)}u(jV,"clamp");function qV(r){if(!r||typeof r!="object")throw Error(Vy+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,so,"rounding",0,8,"toExpNeg",-cf,0,"toExpPos",0,cf,"maxE",0,cf,"minE",-cf,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=mA[t]),(n=r[t])!==void 0)if(xn(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(no+t+": "+n);if(t="crypto",s&&(this[t]=mA[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(TI);else this[t]=!1;else throw Error(no+t+": "+n);return this}u(qV,"config");function HV(r){return new this(r).cos()}u(HV,"cos");function KV(r){return new this(r).cosh()}u(KV,"cosh");function kI(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,xI(i)){c.s=i.s,ft?!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++;ft?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 _y(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),DI.test(i)?_y(c,i):IV(c,i);if(l==="bigint")return i<0?(i=-i,c.s=-1):c.s=1,_y(c,i.toString());throw Error(no+i)}if(u(s,"Decimal"),s.prototype=Se,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=qV,s.clone=kI,s.isDecimal=xI,s.abs=BV,s.acos=RV,s.acosh=OV,s.add=_V,s.asin=PV,s.asinh=kV,s.atan=LV,s.atanh=VV,s.atan2=FV,s.cbrt=UV,s.ceil=MV,s.clamp=jV,s.cos=HV,s.cosh=KV,s.div=XV,s.exp=GV,s.floor=$V,s.hypot=WV,s.ln=zV,s.log=JV,s.log10=QV,s.log2=YV,s.max=ZV,s.min=e6,s.mod=t6,s.mul=r6,s.pow=n6,s.random=s6,s.round=i6,s.sign=a6,s.sin=o6,s.sinh=u6,s.sqrt=l6,s.sub=c6,s.sum=f6,s.tan=h6,s.tanh=p6,s.trunc=d6,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(kI,"clone");function XV(r,e){return new this(r).div(e)}u(XV,"div");function GV(r){return new this(r).exp()}u(GV,"exp");function $V(r){return Qe(r=new this(r),r.e+1,3)}u($V,"floor");function WV(){var r,e,t=new this(0);for(ft=!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 ft=!0,new this(1/0);t=e}return ft=!0,t.sqrt()}u(WV,"hypot");function xI(r){return r instanceof hf||r&&r.toStringTag===II||!1}u(xI,"isDecimalInstance");function zV(r){return new this(r).ln()}u(zV,"ln");function JV(r,e){return new this(r).log(e)}u(JV,"log");function YV(r){return new this(r).log(2)}u(YV,"log2");function QV(r){return new this(r).log(10)}u(QV,"log10");function ZV(){return OI(this,arguments,-1)}u(ZV,"max");function e6(){return OI(this,arguments,1)}u(e6,"min");function t6(r,e){return new this(r).mod(e)}u(t6,"mod");function r6(r,e){return new this(r).mul(e)}u(r6,"mul");function n6(r,e){return new this(r).pow(e)}u(n6,"pow");function s6(r){var e,t,n,s,i=0,a=new this(1),o=[];if(r===void 0?r=this.precision:jn(r,1,so),n=Math.ceil(r/it),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(TI);else for(;i<n;)o[i++]=Math.random()*1e7|0;for(n=o[--i],r%=it,n&&r&&(s=Kr(10,it-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-=it)o.shift();for(n=1,s=o[0];s>=10;s/=10)n++;n<it&&(t-=it-n)}return a.e=t,a.d=o,a}u(s6,"random");function i6(r){return Qe(r=new this(r),r.e+1,this.rounding)}u(i6,"round");function a6(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}u(a6,"sign");function o6(r){return new this(r).sin()}u(o6,"sin");function u6(r){return new this(r).sinh()}u(u6,"sinh");function l6(r){return new this(r).sqrt()}u(l6,"sqrt");function c6(r,e){return new this(r).sub(e)}u(c6,"sub");function f6(){var r=0,e=arguments,t=new this(e[r]);for(ft=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return ft=!0,Qe(t,this.precision,this.rounding)}u(f6,"sum");function h6(r){return new this(r).tan()}u(h6,"tan");function p6(r){return new this(r).tanh()}u(p6,"tanh");function d6(r){return Qe(r=new this(r),r.e+1,1)}u(d6,"trunc");Se[Symbol.for("nodejs.util.inspect.custom")]=Se.toString;Se[Symbol.toStringTag]="Decimal";var hf=Se.constructor=kI(mA);Py=new hf(Py);ky=new hf(ky);var pf=class r extends hf{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 m6 from"pdfkit";var LI=class r{static{u(this,"PdfkitPdfBuilder")}defaults={autoFirstPage:!1};doc=new m6(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}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}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 g=n.size[d]/12;p[d]=f*g}for(let d=0,g=o;d<n.columns;d++){let m=d===n.columns-1,v=p[d];if(m&&n.columns>1){let C=c-a-g;C>0&&Math.abs(C-v)>.01&&(v=C)}let y={y:i,x:g,width:v};s[d](y),g+=v,l>0&&!m&&(g+=l)}return this}};var VI=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 vo=Ty(ZB(),1);import d9 from"os";import uR from"fs";import m9 from"path";import dd from"crypto";var e9=u(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessageInRecord"),cs=u(r=>typeof r=="string"?rr(new Mt(r)):r instanceof Error?rr(new Mt(r.message,{cause:r.cause})):e9(r)?rr(new Mt(r.message)):rr(new Mt("unexpected error")),"leftFromError");var vv=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 a9,platform as aR}from"os";import{dirname as o9,join as u9,resolve as l9,normalize as c9,delimiter as f9}from"path";import{resolve as tR}from"path";import{createRequire as eR}from"module";import{fileURLToPath as t9,pathToFileURL as r9}from"url";var n9=typeof jest<"u"||process.env.JEST_WORKER_ID!==void 0,Df,rR=u(()=>{if(Df!==void 0)return Df;if(n9){Df=void 0;return}try{Df=new Function("try { return import.meta.url; } catch { return undefined; }")()}catch{Df=void 0}return Df},"getImportMetaUrl"),nR=u(()=>{if(typeof st<"u")return st;let r=rR();if(r)return eR(r);let e=r9(tR(process.cwd(),"package.json")).href;return eR(e)},"getRequireFn"),sR=u(()=>{if(typeof __filename<"u")return __filename;let r=rR();return r?t9(r):tR(process.cwd())},"getCurrentFile");import{dirname as Ev,resolve as nl}from"path";import{existsSync as Bf}from"fs";var iR=u(()=>typeof process<"u"&&typeof process.versions<"u"&&"electron"in process.versions,"isElectron"),s9=u(()=>{if(!iR())return null;try{let e=st("electron").app;if(e?.getAppPath&&typeof e.getAppPath=="function")return{getAppPath:e.getAppPath}}catch{}return null},"getElectronApp"),i9=u(()=>{if(!iR())return null;let r=process;if(r.resourcesPath)return r.resourcesPath;let e=s9();if(e)try{let t=e.getAppPath();if(typeof t=="string")return Ev(t.replace(/\.asar$/,""))}catch{}return null},"getElectronResourcesPath"),SC=u((r,{onFound:e,onNotFound:t})=>{let n=i9();if(n){let c=nl(n,"node_modules","nfets",r);if(Bf(c))return e(c);let f=nl(n,"app.asar.unpacked","node_modules","nfets",r);if(Bf(f))return e(f)}let s=sR(),i=s.includes(".asar")?process.cwd():s,a=nl(i,"../../../../"),o=nl(a,r);if(Bf(o))return e(o);let l=i;for(let c=0;c<5;c++){let f=nl(l,r);if(Bf(f))return e(f);let p=Ev(l);if(p===l)break;l=p}l=i;for(let c=0;c<5;c++){let f=nl(l,"node_modules","nfets",r);if(Bf(f))return e(f);let p=Ev(l);if(p===l)break;l=p}l=i;for(let c=0;c<5;c++){let f=nl(l,r.replace(/^build\//,"Release/"));if(Bf(f))return e(f);let p=Ev(l);if(p===l)break;l=p}return t()},"search");var h9=u(r=>{let e=r.replace(/^\\\\\?\\/,"");return l9(c9(e))},"normalizePath"),p9=u(r=>{aR()==="win32"&&(process.env.PATH=`${o9(r)}${f9}${process.env.PATH}`)},"addAddonDirToPath"),AC=u(r=>{let e=h9(r);return p9(e),nR()(e)},"exportRequireModule"),Rf=u(r=>{if(r=`${r}.node`,process.env.NFETS_ADDONS_DIR)return AC(u9(process.env.NFETS_ADDONS_DIR,r));let e=`${aR()}-${a9()}`;try{return SC(`build/addons/${e}/${r}`,{onFound:u(t=>AC(t),"onFound"),onNotFound:u(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}catch{return SC(`build/Release/${r}`,{onFound:u(t=>AC(t),"onFound"),onNotFound:u(()=>{throw new Error(`Addon ${e}/${r} not found`)},"onNotFound")})}},"addon");var yo=class{static{u(this,"ASN1")}extractCertificateInfo(e){let n=e.subject.split(`
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),g=d.length-l.length-2;if(g<=0||g>d.length)return;let v=d.subarray(-g).toString("utf8");return v.substring(Buffer.from(v).findIndex((y,S)=>v.charCodeAt(S)>=32&&v.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 wv=class{static{u(this,"WincryptSignerRepository")}async sign(e,t,n){try{let s=Rf("wincrypt_certificate_store"),i=new yo,{CN:a}=i.extractCertificateInfo(t.certificate),o=await s.sign(a??"",Buffer.from(e),n),l=Buffer.from(o).toString("base64");return await Promise.resolve(Hr(l))}catch(s){return Promise.resolve(cs(s))}}};import oR from"crypto";var Sv=class{static{u(this,"CryptoSignerRepository")}async sign(e,t,n){try{if(!t.privateKey)return rr(new Mt("Certificate private key not found"));let i=oR.sign(n,Buffer.from(e),{key:t.privateKey,padding:oR.constants.RSA_PKCS1_PADDING}).toString("base64");return await Promise.resolve(Hr(i))}catch(s){return Promise.resolve(cs(s))}}};var lR=class{static{u(this,"NativeCertificateRepository")}httpClient;cache;signer;constructor(e,t=new vv,n=d9.platform()==="win32"?new wv:new Sv){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 Mt("Use either pfxPathOrBase64 or publicCertDerBase64, not both"));if(i)try{let S=Buffer.from(i,"base64"),C=new dd.X509Certificate(S);return Hr({ca:[],password:t,certificate:C,privateKey:void 0})}catch(S){return cs(S)}if(!a)return rr(new Mt("Certificate path (pfxPathOrBase64) is required"));let o=await this.getPfxBuffer({...e,pfxPathOrBase64:a});if(o.isLeft())return o;let l=vo.default.asn1.fromDer(o.value.toString("binary")),c=vo.default.pkcs12.pkcs12FromAsn1(l,t),{certBag:f}=vo.default.pki.oids,d=c.getBags({bagType:f})[f];if(!d?.length)return rr(new Mt("Cannot read certificate"));let[{cert:g},...m]=d;if(!g)return rr(new Mt("Issuer Certificate not found"));let v=m.reduce((S,{cert:C})=>(C&&S.push(new dd.X509Certificate(vo.default.pki.certificateToPem(C))),S),[]),y=new dd.X509Certificate(vo.default.pki.certificateToPem(g));return Hr({ca:v,password:t,certificate:y,privateKey:this.getPrivateKey(c)})}catch(t){return cs(t)}}getPrivateKey(e){let{pkcs8ShroudedKeyBag:t}=vo.default.pki.oids,s=e.getBags({bagType:t})[t]?.[0]?.key;if(s)return dd.createPrivateKey(vo.default.pki.privateKeyToPem(s))}async sign(e,t,n=eo.SHA1){return this.signer.sign(e,t,n)}getCertificateInfo(e){return new yo().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 Hr(i);if(m9.isAbsolute(t)||uR.existsSync(t))return this.hitBufferOnCache(s,uR.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 cs(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return dd.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),Hr(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};import TG from"os";import CC from"dayjs";import g9 from"dayjs/plugin/utc.js";import y9 from"dayjs/plugin/timezone.js";CC.extend(g9);CC.extend(y9);var Of=CC;var hP=Ty(uP(),1);import{constants as IG}from"crypto";import{Agent as rb}from"https";var vG=new Set(["ENOTFOUND","EAI_AGAIN","EAI_FAIL","EAI_NONAME"]),EG=new Set(["ETIMEDOUT","ESOCKETTIMEDOUT","ECONNABORTED"]),wG=u(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessage"),SG=u(r=>{if(!r||typeof r!="object"||!("code"in r))return;let{code:e}=r;return typeof e=="string"?e:void 0},"getCode"),AG=u(r=>{if(!r||typeof r!="object"||!("hostname"in r))return;let{hostname:e}=r;return typeof e=="string"?e:void 0},"getHostname"),tb=u(r=>{if(typeof r=="string")return r;if(r instanceof Error||wG(r))return r.message},"getMessage"),lP=u(r=>{let e=r.toLowerCase();return e.includes("timeout")||e.includes("timed out")||e.includes("time-out")},"isTimeoutMessage"),CG=u(r=>/getaddrinfo\s+ENOTFOUND/i.test(r)||/\bENOTFOUND\b/i.test(r),"isHostNotFoundMessage"),xG=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"),qd=u(r=>r instanceof Error?{cause:r}:void 0,"errorOptions"),bG=u(r=>{let e=xG(r),t=tb(r)??e.map(tb).find(n=>!!n);for(let n of e){let s=SG(n);if(s&&vG.has(s))return rr(new W0(t??`Host not found (${AG(n)??s})`,qd(r)));if(s&&EG.has(s))return rr(new uf(t??"Transmission timeout",qd(r)));let i=tb(n);if(i&&lP(i))return rr(new uf(i,qd(r)))}return t?CG(t)?rr(new W0(t,qd(r))):lP(t)?rr(new uf(t,qd(r))):cs(r):cs(r)},"mapTransmissionError"),cP=u(r=>bG(r),"leftFromTransmissionError");import NG from"os";var _2=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(NG.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
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),g=d.length-l.length-2;if(g<=0||g>d.length)return;let v=d.subarray(-g).toString("utf8");return v.substring(Buffer.from(v).findIndex((y,S)=>v.charCodeAt(S)>=32&&v.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 wv=class{static{u(this,"WincryptSignerRepository")}async sign(e,t,n){try{let s=Rf("wincrypt_certificate_store"),i=new yo,{CN:a}=i.extractCertificateInfo(t.certificate),o=await s.sign(a??"",Buffer.from(e),n),l=Buffer.from(o).toString("base64");return await Promise.resolve(Hr(l))}catch(s){return Promise.resolve(cs(s))}}};import oR from"crypto";var Sv=class{static{u(this,"CryptoSignerRepository")}async sign(e,t,n){try{if(!t.privateKey)return rr(new Mt("Certificate private key not found"));let i=oR.sign(n,Buffer.from(e),{key:t.privateKey,padding:oR.constants.RSA_PKCS1_PADDING}).toString("base64");return await Promise.resolve(Hr(i))}catch(s){return Promise.resolve(cs(s))}}};var lR=class{static{u(this,"NativeCertificateRepository")}httpClient;cache;signer;constructor(e,t=new vv,n=d9.platform()==="win32"?new wv:new Sv){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 Mt("Use either pfxPathOrBase64 or publicCertDerBase64, not both"));if(i)try{let S=Buffer.from(i,"base64"),C=new dd.X509Certificate(S);return Hr({ca:[],password:t,certificate:C,privateKey:void 0})}catch(S){return cs(S)}if(!a)return rr(new Mt("Certificate path (pfxPathOrBase64) is required"));let o=await this.getPfxBuffer({...e,pfxPathOrBase64:a});if(o.isLeft())return o;let l=vo.default.asn1.fromDer(o.value.toString("binary")),c=vo.default.pkcs12.pkcs12FromAsn1(l,t),{certBag:f}=vo.default.pki.oids,d=c.getBags({bagType:f})[f];if(!d?.length)return rr(new Mt("Cannot read certificate"));let[{cert:g},...m]=d;if(!g)return rr(new Mt("Issuer Certificate not found"));let v=m.reduce((S,{cert:C})=>(C&&S.push(new dd.X509Certificate(vo.default.pki.certificateToPem(C))),S),[]),y=new dd.X509Certificate(vo.default.pki.certificateToPem(g));return Hr({ca:v,password:t,certificate:y,privateKey:this.getPrivateKey(c)})}catch(t){return cs(t)}}getPrivateKey(e){let{pkcs8ShroudedKeyBag:t}=vo.default.pki.oids,s=e.getBags({bagType:t})[t]?.[0]?.key;if(s)return dd.createPrivateKey(vo.default.pki.privateKeyToPem(s))}async sign(e,t,n=eo.SHA1){return this.signer.sign(e,t,n)}getCertificateInfo(e){return new yo().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 Hr(i);if(m9.isAbsolute(t)||uR.existsSync(t))return this.hitBufferOnCache(s,uR.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 cs(a)}return this.hitBufferOnCache(s,Buffer.from(t,"base64"))}getCacheKey(e,t){return dd.createHash("sha256").update(`${e}.${t}`).digest("hex")}async hitBufferOnCache(e,t){return await this.cache.set(e,t),Hr(t)}isValidRemoteUrl(e){try{return new URL(e),!0}catch{return!1}}};import TG from"os";import CC from"dayjs";import g9 from"dayjs/plugin/utc.js";import y9 from"dayjs/plugin/timezone.js";CC.extend(g9);CC.extend(y9);var Of=CC;var hP=Ty(uP(),1);import{constants as IG}from"crypto";import{Agent as rb}from"https";var vG=new Set(["ENOTFOUND","EAI_AGAIN","EAI_FAIL","EAI_NONAME"]),EG=new Set(["ETIMEDOUT","ESOCKETTIMEDOUT","ECONNABORTED"]),wG=u(r=>!!r&&typeof r=="object"&&"message"in r,"hasMessage"),SG=u(r=>{if(!r||typeof r!="object"||!("code"in r))return;let{code:e}=r;return typeof e=="string"?e:void 0},"getCode"),AG=u(r=>{if(!r||typeof r!="object"||!("hostname"in r))return;let{hostname:e}=r;return typeof e=="string"?e:void 0},"getHostname"),tb=u(r=>{if(typeof r=="string")return r;if(r instanceof Error||wG(r))return r.message},"getMessage"),lP=u(r=>{let e=r.toLowerCase();return e.includes("timeout")||e.includes("timed out")||e.includes("time-out")||e.includes("read econnreset")},"isTimeoutMessage"),CG=u(r=>/getaddrinfo\s+ENOTFOUND/i.test(r)||/\bENOTFOUND\b/i.test(r),"isHostNotFoundMessage"),xG=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"),qd=u(r=>r instanceof Error?{cause:r}:void 0,"errorOptions"),bG=u(r=>{let e=xG(r),t=tb(r)??e.map(tb).find(n=>!!n);for(let n of e){let s=SG(n);if(s&&vG.has(s))return rr(new W0(t??`Host not found (${AG(n)??s})`,qd(r)));if(s&&EG.has(s))return rr(new uf(t??"Transmission timeout",qd(r)));let i=tb(n);if(i&&lP(i))return rr(new uf(i,qd(r)))}return t?CG(t)?rr(new W0(t,qd(r))):lP(t)?rr(new uf(t,qd(r))):cs(r):cs(r)},"mapTransmissionError"),cP=u(r=>bG(r),"leftFromTransmissionError");import NG from"os";var _2=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(NG.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=Rf("winhttp_ssl_client"),{CN:i}=new yo().extractCertificateInfo(this.certificate.certificate),a=await s.request(i??"",n,t,{headers:this.parseRequestHeaders(e.headers),body:this.parseRequestBody(e.data),timeout:e.timeout});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 fP=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 Hr(void 0);let{certificate:e}=this.certificate,t=new Date;return t>new Date(e.validTo)?rr(new Mt(`Certificado expirado (${Of(e.validTo).format("DD/MM/YYYY")}). Renove o certificado.`)):t<new Date(e.validFrom)?rr(new Mt(`O certificado ainda n\xE3o est\xE1 v\xE1lido (${Of(e.validFrom).format("DD/MM/YYYY")}).`)):Hr(void 0)}get httpsAgent(){let e={rejectUnauthorized:!1,secureOptions:IG.SSL_OP_LEGACY_SERVER_CONNECT};if(!this.certificate)return new rb({...e});let{ca:t,password:n,certificate:s,privateKey:i}=this.certificate;return i?new rb({passphrase:n,cert:s.toString(),ca:t.map(a=>a.toString()),key:this.certificateRepository.getStringPrivateKey(i),...e}):new rb({...e})}get defaultSoapHeaders(){return{"Content-Type":"application/soap+xml; charset=utf-8"}}getDefaultRequest(e){let t=dI.create({timeout:e.timeout});return t.defaults.httpsAgent=this.httpsAgent,t}request(e){if(TG.platform()==="win32")try{return this.certificate?_2.create(this.certificate):this.getDefaultRequest({timeout:e.timeout})}catch{return this.getDefaultRequest({timeout:e.timeout})}return this.getDefaultRequest({timeout:e.timeout})}async send(e){let t=this.validateCertificatePeriod();if(t.isLeft())return t;try{let n=this.request({timeout:e.timeout}),s=await(0,hP.createClientAsync)(`${e.url}?wsdl`,{request:n,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.toolkit.getFirstNode(i)??"",o=e.xsd,l=await this.toolkit.validate(a,o);if(l.isLeft())return l;let[c]=await s[`${e.method}Async`]({_xml:i},{request:n,timeout:e.timeout});return Hr(c)}catch(n){return cP(n)}}};var DG=Rf("xml_validator"),pP=DG;var gQ=Ty(L4(),1);import mQ from"crypto";var V4="application/xml";var gt;(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"})(gt||(gt={}));function BG(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(BG,"SelectNodesEx");function RG(r,e){let t=eh("xpath").select;return t(e,r)}u(RG,"SelectNodesNode");var F4=typeof self<"u"?BG:RG;function Xd(r){r=r.replace(/\r\n/g,`
85
85
  `).replace(/\r/g,`
86
86
  `);let e;return typeof DOMParser<"u"?e=DOMParser:e=eh("DOMParser"),new e().parseFromString(r,V4)}u(Xd,"Parse");function Zf(r){let e;return typeof XMLSerializer<"u"?e=XMLSerializer:e=eh("XMLSerializer"),new e().serializeToString(r)}u(Zf,"Stringify");function J2(r,e){let t=F4(r,e);return t&&t.length>0?t[0]:null}u(J2,"SelectSingleNode");function U4(r,e){return r&&r.nodeType===e}u(U4,"isNodeType");function ps(r){return U4(r,gt.Element)}u(ps,"isElement");function ml(r){return U4(r,gt.Document)}u(ml,"isDocument");var M4=new Map;function j4(r){for(let e in r)M4.set(e,r[e])}u(j4,"setNodeDependencies");function eh(r){let e=M4.get(r);if(!e)throw new Error(`Node dependency not found: ${r}. Please use 'setNodeDependencies' to register it.`);return e}u(eh,"getNodeDependency");var Gd="element",$d="attribute",Y2="content";var OG=1e9;function pb(r,...e){let t=r;for(let n=0;n<e.length;n++){let s=e[n];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t}u(pb,"assign");function yt(r){return e=>{let t=e;t.localName=r.localName||t.name,t.namespaceURI=r.namespaceURI||t.namespaceURI||null,t.prefix=r.prefix||t.prefix||null,t.parser=r.parser||t.parser,t.target!==t&&(t.items=pb({},t.items)),t.target=e}}u(yt,"XmlElement");function Nt(r={}){return(e,t)=>{let n=e.constructor,s=t;n.items||(n.items={}),n.target!==n&&(n.items=pb({},n.items)),n.target=e;let i;r.parser?i={parser:r.parser,required:r.required||!1,maxOccurs:r.maxOccurs||OG,minOccurs:r.minOccurs===void 0?0:r.minOccurs,noRoot:r.noRoot||!1}:i={namespaceURI:r.namespaceURI||null,required:r.required||!1,prefix:r.prefix||null,defaultValue:r.defaultValue,converter:r.converter,noRoot:r.noRoot||!1},r.localName=r.localName||r.parser&&r.parser.localName||s;let a=n.items,o=r.parser&&r.parser.namespaceURI;a[s]={...i,namespaceURI:r.namespaceURI||o||null,prefix:r.prefix||r.parser&&r.parser.prefix||null,localName:r.localName,type:Gd},H4(e,s,r)}}u(Nt,"XmlChildElement");function pr(r={required:!1,namespaceURI:null}){return(e,t)=>{let n=e.constructor,s=t;r.localName||(r.localName=t),n.items||(n.items={}),n.target!==n&&(n.items=pb({},n.items)),n.target=e;let i=n.items;i[t]=r,i[t].type=$d,H4(e,s,r)}}u(pr,"XmlAttribute");function H4(r,e,t){let n=`_${e}`,s={set:u(function(i){this[n]!==i&&(this.element=null,this[n]=i)},"set"),get:u(function(){if(this[n]===void 0){let i=t.defaultValue;t.parser&&(i=new t.parser,i.localName=t.localName),this[n]=i}return this[n]},"get")};Object.defineProperty(r,n,{writable:!0,enumerable:!1}),Object.defineProperty(r,e,s)}u(H4,"defineProperty");var ko=class r{static{u(this,"Collection")}constructor(e){this.items=[],e&&(this.items=e)}get Count(){return this.items.length}Item(e){return this.items[e]||null}Add(e){this.items.push(e)}Pop(){return this.items.pop()}RemoveAt(e){this.items=this.items.filter((t,n)=>n!==e)}Clear(){this.items=[]}GetIterator(){return this.items}ForEach(e){this.GetIterator().forEach(e)}Map(e){return new r(this.GetIterator().map(e))}Filter(e){return new r(this.GetIterator().filter(e))}Sort(e){return new r(this.GetIterator().sort(e))}Every(e){return this.GetIterator().every(e)}Some(e){return this.GetIterator().some(e)}IsEmpty(){return this.Count===0}};function _G(r,...e){let t=r.replace(/%([1-9]\d*)/g,(n,s)=>{let i=parseInt(s,10)-1;return e[i]!==void 0?e[i]:""});return t=t.replace(/%%/g,"%"),t}u(_G,"printf");function PG(r,e){let t=r+"";for(;t.length<e;)t="0"+t;return t}u(PG,"padNum");var De=class{static{u(this,"XmlError")}constructor(e,...t){this.prefix="XMLJS",this.code=e,this.name=this.constructor.name;let n=_G(Fr[e],...t);this.message=`${this.prefix}${PG(e,4)}: ${n}`,this.stack=new Error(this.message).stack}},ye;(function(r){r[r.NONE=0]="NONE",r[r.NULL_REFERENCE=1]="NULL_REFERENCE",r[r.NULL_PARAM=2]="NULL_PARAM",r[r.DECORATOR_NULL_PARAM=3]="DECORATOR_NULL_PARAM",r[r.COLLECTION_LIMIT=4]="COLLECTION_LIMIT",r[r.METHOD_NOT_IMPLEMENTED=5]="METHOD_NOT_IMPLEMENTED",r[r.METHOD_NOT_SUPPORTED=6]="METHOD_NOT_SUPPORTED",r[r.PARAM_REQUIRED=7]="PARAM_REQUIRED",r[r.CONVERTER_UNSUPPORTED=8]="CONVERTER_UNSUPPORTED",r[r.ELEMENT_MALFORMED=9]="ELEMENT_MALFORMED",r[r.ELEMENT_MISSING=10]="ELEMENT_MISSING",r[r.ATTRIBUTE_MISSING=11]="ATTRIBUTE_MISSING",r[r.CONTENT_MISSING=12]="CONTENT_MISSING",r[r.CRYPTOGRAPHIC=13]="CRYPTOGRAPHIC",r[r.CRYPTOGRAPHIC_NO_MODULE=14]="CRYPTOGRAPHIC_NO_MODULE",r[r.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM=15]="CRYPTOGRAPHIC_UNKNOWN_TRANSFORM",r[r.ALGORITHM_NOT_SUPPORTED=16]="ALGORITHM_NOT_SUPPORTED",r[r.ALGORITHM_WRONG_NAME=17]="ALGORITHM_WRONG_NAME",r[r.XML_EXCEPTION=18]="XML_EXCEPTION",r[r.KEY_INFO_CLAUSE_NOT_SUPPORTED=19]="KEY_INFO_CLAUSE_NOT_SUPPORTED"})(ye||(ye={}));var Fr={};Fr[ye.NONE]="No description";Fr[ye.NULL_REFERENCE]="Null reference";Fr[ye.NULL_PARAM]="'%1' has empty '%2' object";Fr[ye.DECORATOR_NULL_PARAM]="Decorator '%1' has empty '%2' parameter";Fr[ye.COLLECTION_LIMIT]="Collection of '%1' in element '%2' has wrong amount of items";Fr[ye.METHOD_NOT_IMPLEMENTED]="Method is not implemented";Fr[ye.METHOD_NOT_SUPPORTED]="Method is not supported";Fr[ye.PARAM_REQUIRED]="Required parameter is missing '%1'";Fr[ye.CONVERTER_UNSUPPORTED]="Converter is not supported";Fr[ye.ELEMENT_MALFORMED]="Malformed element '%1'";Fr[ye.ELEMENT_MISSING]="Element '%1' is missing in '%2'";Fr[ye.ATTRIBUTE_MISSING]="Attribute '%1' is missing in '%2'";Fr[ye.CONTENT_MISSING]="Content is missing in '%1'";Fr[ye.CRYPTOGRAPHIC]="Cryptographic error: %1";Fr[ye.CRYPTOGRAPHIC_NO_MODULE]="WebCrypto module is not found";Fr[ye.CRYPTOGRAPHIC_UNKNOWN_TRANSFORM]="Unknown transform %1";Fr[ye.ALGORITHM_NOT_SUPPORTED]="Algorithm is not supported '%1'";Fr[ye.ALGORITHM_WRONG_NAME]="Algorithm wrong name in use '%1'";Fr[ye.XML_EXCEPTION]="XML exception: %1";Fr[ye.KEY_INFO_CLAUSE_NOT_SUPPORTED]="KeyInfoClause type '%1' is not supported";var zt=class{static{u(this,"Convert")}static ToString(e,t="utf8"){let n=new Uint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);default:throw new De(ye.CONVERTER_UNSUPPORTED)}}static FromString(e,t="utf8"){switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);default:throw new De(ye.CONVERTER_UNSUPPORTED)}}static ToBase64(e){if(typeof btoa<"u"){let t=this.ToString(e,"binary");return btoa(t)}else{if(typeof Buffer<"u")return Buffer.from(e).toString("base64");throw new De(ye.CONVERTER_UNSUPPORTED)}}static FromBase64(e){if(e=e.replace(/\n/g,"").replace(/\r/g,"").replace(/\t/g,"").replace(/\s/g,""),typeof atob<"u")return this.FromBinary(atob(e));if(typeof Buffer<"u")return new Uint8Array(Buffer.from(e,"base64"));throw new De(ye.CONVERTER_UNSUPPORTED)}static FromBase64Url(e){return this.FromBase64(this.Base64Padding(e.replace(/-/g,"+").replace(/_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}static FromUtf8String(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}static ToUtf8String(e){let t=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(t))}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n}static ToBinary(e){let t="";for(let n=0;n<e.length;n++)t=t+String.fromCharCode(e[n]);return t}static ToHex(e){let n=[];for(let s=0;s<e.length;s++){let i=e[s].toString(16);n.push(i.length===1?"0"+i:i)}return n.join("")}static FromHex(e){let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n=n+2){let s=e.slice(n,n+2);t[n/2]=parseInt(s,16)}return t}static ToDateTime(e){return new Date(e)}static FromDateTime(e){return e.toISOString()}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}};var Os={get:u(r=>{if(r)return zt.ToBase64(r)},"get"),set:u(r=>zt.FromBase64(r),"set")},Wd={get:u(r=>r?r.toString():"0","get"),set:u(r=>Number(r),"set")};var kG="xml_root",Yn=class r{static{u(this,"XmlObject")}static LoadXml(e){let t=new this;return t.LoadXml(e),t}static GetElement(e,t,n=!0){let s=e.getElementsByTagName(t);if(n&&s.length===0)throw new De(ye.ELEMENT_MISSING,t,e.localName);return s[0]||null}static GetAttribute(e,t,n,s=!0){if(e.hasAttribute(t))return e.getAttribute(t);if(s)throw new De(ye.ATTRIBUTE_MISSING,t,e.localName);return n}static GetElementById(e,t){if(e==null||t==null)return null;let n=null;return ml(e)&&(n=e.getElementById(t)),n==null&&(n=J2(e,`//*[@*[local-name()='Id']='${t}']`),n==null&&(n=J2(e,`//*[@*[local-name()='ID']='${t}']`),n==null&&(n=J2(e,`//*[@*[local-name()='id']='${t}']`)))),n}static CreateDocument(e=kG,t=null,n=null){if(n&&!t)throw new De(ye.PARAM_REQUIRED,"namespaceUri",`Prefix '${n}' requires namespaceUri`);let s="",i="",a="";n&&(s=n+":",i=":"+n),t&&(a=` xmlns${i}="${t}"`);let o=`${s}${e}`;return Xd(`<${o}${a}></${o}>`)}static GetChildren(e,t,n){e=ml(e)?e.documentElement:e;let s=[];for(let i=0;i<e.childNodes.length;i++){let a=e.childNodes[i];ps(a)&&a.localName===t&&(a.namespaceURI===n||!n)&&s.push(a)}return s}static GetFirstChild(e,t,n){e=ml(e)?e.documentElement:e;for(let s=0;s<e.childNodes.length;s++){let i=e.childNodes[s];if(ps(i)&&i.localName===t&&(i.namespaceURI===n||!n))return i}return null}static GetChild(e,t,n,s=!0){for(let i=0;i<e.childNodes.length;i++){let a=e.childNodes[i];if(ps(a)&&a.localName===t&&(a.namespaceURI===n||!n))return a}if(s)throw new De(ye.ELEMENT_MISSING,t,e.localName);return null}constructor(e={}){if(this.prefix=this.GetStatic().prefix||null,this.localName=this.GetStatic().localName,this.namespaceURI=this.GetStatic().namespaceURI,e)for(let[t,n]of Object.entries(e))n!==void 0&&(this[t]=n)}get Element(){return this.element}get Prefix(){return this.prefix}set Prefix(e){this.prefix=e}get LocalName(){return this.localName||""}get NamespaceURI(){return this.namespaceURI||null}HasChanged(){let e=this.GetStatic();if(e.items)for(let t in e.items){if(!Object.prototype.hasOwnProperty.call(e.items,t))continue;let n=e.items[t],s=this[t];if(n.parser&&s&&s.HasChanged())return!0}return this.element===null}GetXml(e){if(!(e||this.HasChanged()))return this.element||null;let t=this,n=this.CreateDocument(),s=this.CreateElement(),i=this.GetStatic(),a=this.localName||"";if(i.items)for(let o in i.items){if(!Object.prototype.hasOwnProperty.call(i.items,o))continue;let l=t[o],c=i.items[o];switch(c.type){case Y2:{let f=c,p=f.converter?f.converter.get(l):l;if(f.required&&p==null)throw new De(ye.CONTENT_MISSING,a);(f.defaultValue!==l||f.required)&&(s.textContent=p);break}case $d:{let f=c,p=f.converter?f.converter.get(l):l;if(f.required&&p==null)throw new De(ye.ATTRIBUTE_MISSING,f.localName,a);(f.defaultValue!==l||f.required)&&(f.namespaceURI?s.setAttributeNS(f.namespaceURI,f.localName||"",p):s.setAttribute(f.localName||"",p));break}case Gd:{let f=c,p=null;if(f.parser){if(f.required&&!l||f.minOccurs&&!l.Count){let d=l?.localName||f.localName;throw new De(ye.ELEMENT_MISSING,d,a)}l&&(p=l.GetXml(l.element===void 0&&(f.required||l.Count)))}else{let d=f.converter?f.converter.get(l):l;if(f.required&&d===void 0)throw new De(ye.ELEMENT_MISSING,f.localName,a);if(l!==f.defaultValue||f.required)if(f.namespaceURI?p=n.createElementNS(f.namespaceURI,`${f.prefix?f.prefix+":":""}${f.localName}`):p=n.createElement(`${f.prefix?f.prefix+":":""}${f.localName}`),Array.isArray(d))for(let g of d){let m=g instanceof r?g.GetXml(!0):g;m!==null&&p&&p.appendChild(m)}else if(d instanceof r){let g=d.GetXml(!0);g&&p&&p.appendChild(g)}else p&&(p.textContent=d)}if(p)if(f.noRoot){let d=[];for(let v=0;v<p.childNodes.length;v++){let y=p.childNodes.item(v);ps(y)&&d.push(y)}let g=f.minOccurs||0,m=f.maxOccurs||1/0;if(d.length<g||d.length>m)throw new De(ye.COLLECTION_LIMIT,l.localName,i.localName);d.forEach(v=>s.appendChild(v.cloneNode(!0)))}else{if(p.childNodes.length<(f.minOccurs||0)||p.childNodes.length>(f.maxOccurs||1/0))throw new De(ye.COLLECTION_LIMIT,l.localName,i.localName);s.appendChild(p)}break}}}return this.OnGetXml(s),this.element=s,s}LoadXml(e){let t,n=this;if(typeof e=="string"?t=Xd(e).documentElement:t=e,!t)throw new De(ye.PARAM_REQUIRED,"element");let s=this.GetStatic(),i=this.localName||"";if(!(t.localName===i&&t.namespaceURI==this.NamespaceURI))throw new De(ye.ELEMENT_MALFORMED,i);if(s.items)for(let a in s.items){if(!Object.prototype.hasOwnProperty.call(s.items,a))continue;let o=s.items[a];switch(o.type){case Y2:{let l=o;if(l.required&&!t.textContent)throw new De(ye.CONTENT_MISSING,i);if(!t.textContent)n[a]=l.defaultValue;else{let c=l.converter?l.converter.set(t.textContent):t.textContent;n[a]=c}break}case $d:{let l=o,c,f;if(!l.localName)throw new De(ye.PARAM_REQUIRED,"localName");if(l.namespaceURI?(c=t.hasAttributeNS.bind(t,l.namespaceURI,l.localName),f=t.getAttributeNS.bind(t,l.namespaceURI,l.localName)):(c=t.hasAttribute.bind(t,l.localName),f=t.getAttribute.bind(t,l.localName)),l.required&&!c())throw new De(ye.ATTRIBUTE_MISSING,l.localName,i);if(!c())n[a]=l.defaultValue;else{let p=f(),d=l.converter&&p?l.converter.set(p):p;n[a]=d}break}case Gd:{let l=o;if(l.noRoot){if(!l.parser)throw new De(ye.XML_EXCEPTION,`Schema for '${l.localName}' with flag noRoot must have 'parser'`);let f=new l.parser;if(!(f instanceof th))throw new De(ye.XML_EXCEPTION,`Schema for '${l.localName}' with flag noRoot must have 'parser' like instance of XmlCollection`);f.OnLoadXml(t),delete f.element;let p=l.minOccurs||0,d=l.maxOccurs||1/0;if(f.Count<p||f.Count>d)throw new De(ye.COLLECTION_LIMIT,l.parser.localName,i);n[a]=f;continue}let c=null;for(let f=0;f<t.childNodes.length;f++){let p=t.childNodes.item(f);if(!ps(p))continue;let d=p;if(d.localName===l.localName&&d.namespaceURI==l.namespaceURI){c=d;break}}if(l.required&&!c)throw new De(ye.ELEMENT_MISSING,l.parser?l.parser.localName:l.localName,i);if(l.parser){if(c){let f=new l.parser;f.localName=l.localName,f.namespaceURI=l.namespaceURI,n[a]=f,f.LoadXml(c)}}else if(!c)n[a]=l.defaultValue;else{let f=c.textContent||"",p=l.converter?l.converter.set(f):f;n[a]=p}break}}}this.OnLoadXml(t),this.prefix=t.prefix||"",this.element=t}toString(){let e=this.GetXml();return e?Zf(e):""}GetElement(e,t=!0){if(!this.element)throw new De(ye.NULL_PARAM,this.localName);return r.GetElement(this.element,e,t)}GetChildren(e,t){if(!this.element)throw new De(ye.NULL_PARAM,this.localName);return r.GetChildren(this.element,e,t||this.NamespaceURI||void 0)}GetChild(e,t=!0){if(!this.element)throw new De(ye.NULL_PARAM,this.localName);return r.GetChild(this.element,e,this.NamespaceURI||void 0,t)}GetFirstChild(e,t){if(!this.element)throw new De(ye.NULL_PARAM,this.localName);return r.GetFirstChild(this.element,e,t)}GetAttribute(e,t,n=!0){if(!this.element)throw new De(ye.NULL_PARAM,this.localName);return r.GetAttribute(this.element,e,t,n)}IsEmpty(){return this.Element===void 0}OnLoadXml(e){}GetStatic(){return this.constructor}GetPrefix(){return this.Prefix?this.prefix+":":""}OnGetXml(e){}CreateElement(e,t,n=null,s=null){if(!e){let o=this.CreateDocument();if(o)e=o;else throw new De(ye.XML_EXCEPTION,"Document not created")}t=t||this.localName,n=n||this.NamespaceURI,s=s||this.prefix;let i=(s?`${s}:`:"")+t,a=n&&e?e.createElementNS(n,i):e?.createElement(i);return e&&a&&e.importNode(a,!0),a}CreateDocument(){return r.CreateDocument(this.localName,this.NamespaceURI,this.Prefix)}};var th=class extends Yn{static{u(this,"XmlCollection")}constructor(){super(...arguments),this.MaxOccurs=Number.MAX_VALUE,this.MinOccurs=0,this.items=[]}HasChanged(){let e=super.HasChanged(),t=this.Some(n=>n.HasChanged());return e||t}get Count(){return this.items.length}Item(e){return this.items[e]||null}Add(e){this.items.push(e),this.element=null}Pop(){return this.element=null,this.items.pop()}RemoveAt(e){this.items=this.items.filter((t,n)=>n!==e),this.element=null}Clear(){this.items=[],this.element=null}GetIterator(){return this.items}ForEach(e){this.GetIterator().forEach(e)}Map(e){return new ko(this.GetIterator().map(e))}Filter(e){return new ko(this.GetIterator().filter(e))}Sort(e){return new ko(this.GetIterator().sort(e))}Every(e){return this.GetIterator().every(e)}Some(e){return this.GetIterator().some(e)}IsEmpty(){return this.Count===0}OnGetXml(e){for(let t of this.GetIterator()){let n=t.GetXml();n&&e.appendChild(n)}}OnLoadXml(e){let t=this.GetStatic();if(!t.parser)throw new De(ye.XML_EXCEPTION,`${t.localName} doesn't have required 'parser' in @XmlElement`);for(let n=0;n<e.childNodes.length;n++){let s=e.childNodes.item(n);if(!(ps(s)&&s.localName===t.parser.localName&&s.namespaceURI==t.namespaceURI))continue;let i=s,a=new t.parser;a.LoadXml(i),this.Add(a)}}};var rh=class extends ko{static{u(this,"NamespaceManager")}Add(e){e.prefix=e.prefix||"",e.namespace=e.namespace||"",super.Add(e)}GetPrefix(e,t=this.Count-1){let n=this.Count-1;e=e||"",t>n&&(t=n);for(let s=t;s>=0;s--){let i=this.items[s];if(i.prefix===e)return i}return null}GetNamespace(e,t=this.Count-1){let n=this.Count-1;e=e||"",t>n&&(t=n);for(let s=t;s>=0;s--){let i=this.items[s];if(i.namespace===e)return i}return null}};var LG="[object ArrayBuffer]",Ye=class gb{static{u(this,"BufferSourceConverter")}static isArrayBuffer(e){return Object.prototype.toString.call(e)===LG}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=gb.toUint8Array(e),s=gb.toUint8Array(t);if(n.length!==s.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==s[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let a of t)n+=a.byteLength;let s=new Uint8Array(n),i=0;for(let a of t){let o=this.toUint8Array(a);s.set(o,i),i+=o.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},mb="string",VG=/^[0-9a-f\s]+$/i,FG=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,UG=/^[a-zA-Z0-9-_]+$/,K4=class{static{u(this,"Utf8Converter")}static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=Ye.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},Li=class{static{u(this,"Utf16Converter")}static toString(e,t=!1){let n=Ye.toArrayBuffer(e),s=new DataView(n),i="";for(let a=0;a<n.byteLength;a+=2){let o=s.getUint16(a,t);i+=String.fromCharCode(o)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let i=0;i<e.length;i++)s.setUint16(i*2,e.charCodeAt(i),t);return n}},at=class nh{static{u(this,"Convert")}static isHex(e){return typeof e===mb&&VG.test(e)}static isBase64(e){return typeof e===mb&&FG.test(e)}static isBase64Url(e){return typeof e===mb&&UG.test(e)}static ToString(e,t="utf8"){let n=Ye.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Li.toString(n,!0);case"utf16":case"utf16be":return Li.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Li.fromString(e,!0);case"utf16":case"utf16be":return Li.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Ye.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!nh.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!nh.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=nh.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return K4.fromString(e);case"utf16":case"utf16be":return Li.fromString(e);case"utf16le":case"usc2":return Li.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=nh.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return K4.toString(e);case"utf16":case"utf16be":return Li.toString(e);case"utf16le":case"usc2":return Li.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=Ye.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=Ye.toUint8Array(e),n="",s=t.length;for(let i=0;i<s;i++){let a=t[i];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!nh.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let i=t.slice(s,s+2);n[s/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return Li.toString(e,t)}static FromUtf16String(e,t=!1){return Li.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};at.DEFAULT_UTF8_ENCODING="utf8";function T(r,e,t){var n;return r instanceof Object&&(n=r[e])!==null&&n!==void 0?n:t}u(T,"getParametersValue");function Q2(r,e=0,t=r.byteLength-e,n=!1){let s="";for(let i of new Uint8Array(r,e,t)){let a=i.toString(16).toUpperCase();a.length===1&&(s+="0"),s+=a,n&&(s+=" ")}return s.trim()}u(Q2,"bufferToHexCodes");function va(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}u(va,"utilFromBase");function ei(r,e,t=-1){let n=t,s=r,i=0,a=Math.pow(2,e);for(let o=1;o<8;o++){if(r<a){let l;if(n<0)l=new ArrayBuffer(o),i=o;else{if(n<o)return new ArrayBuffer(0);l=new ArrayBuffer(n),i=n}let c=new Uint8Array(l);for(let f=o-1;f>=0;f--){let p=Math.pow(2,f*e);c[i-f-1]=Math.floor(s/p),s-=c[i-f-1]*p}return l}a*=Math.pow(2,e)}return new ArrayBuffer(0)}u(ei,"utilToBase");function gl(...r){let e=0,t=0;for(let i of r)e+=i.byteLength;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let i of r)s.set(new Uint8Array(i),t),t+=i.byteLength;return n}u(gl,"utilConcatBuf");function Z2(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let i of r)s.set(i,t),t+=i.length;return s}u(Z2,"utilConcatView");function yb(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let o=r[0]===255&&r[1]&128,l=r[0]===0&&(r[1]&128)===0;(o||l)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let o=0;o<this.valueHex.byteLength;o++)t[o]=0;t[0]=r[0]&128;let n=va(t,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let o=0;o<this.valueHex.byteLength;o++)i[o]=r[o];return i[0]&=127,va(i,8)-n}u(yb,"utilDecodeTC");function G4(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let a=t-e,o=ei(a,8,n),l=new Uint8Array(o);return l[0]|=128,o}let s=ei(e,8,n),i=new Uint8Array(s);if(i[0]&128){let a=s.slice(0),o=new Uint8Array(a);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let l=0;l<a.byteLength;l++)i[l+1]=o[l];i[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}u(G4,"utilEncodeTC");function Lo(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}u(Lo,"isEqualBuffer");function Qn(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let a=0;a<n;a++)s[a]="0";return s.join("").concat(t)}u(Qn,"padNumber");var $4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",W4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";function eE(r,e=!1,t=!1,n=!1){let s=0,i=0,a=0,o="",l=e?W4:$4;if(n){let c=0;for(let f=0;f<r.length;f++)if(r.charCodeAt(f)!==0){c=f;break}r=r.slice(c)}for(;s<r.length;){let c=r.charCodeAt(s++);s>=r.length&&(i=1);let f=r.charCodeAt(s++);s>=r.length&&(a=1);let p=r.charCodeAt(s++),d=c>>2,g=(c&3)<<4|f>>4,m=(f&15)<<2|p>>6,v=p&63;i===1?m=v=64:a===1&&(v=64),t?m===64?o+=`${l.charAt(d)}${l.charAt(g)}`:v===64?o+=`${l.charAt(d)}${l.charAt(g)}${l.charAt(m)}`:o+=`${l.charAt(d)}${l.charAt(g)}${l.charAt(m)}${l.charAt(v)}`:o+=`${l.charAt(d)}${l.charAt(g)}${l.charAt(m)}${l.charAt(v)}`}return o}u(eE,"toBase64");function sh(r,e=!1,t=!1){let n=e?W4:$4;function s(l){for(let c=0;c<64;c++)if(n.charAt(c)===l)return c;return 64}u(s,"indexOf");function i(l){return l===64?0:l}u(i,"test");let a=0,o="";for(;a<r.length;){let l=s(r.charAt(a++)),c=a>=r.length?0:s(r.charAt(a++)),f=a>=r.length?0:s(r.charAt(a++)),p=a>=r.length?0:s(r.charAt(a++)),d=i(l)<<2|i(c)>>4,g=(i(c)&15)<<4|i(f)>>2,m=(i(f)&3)<<6|i(p);o+=String.fromCharCode(d),f!==64&&(o+=String.fromCharCode(g)),p!==64&&(o+=String.fromCharCode(m))}if(t){let l=o.length,c=-1;for(let f=l-1;f>=0;f--)if(o.charCodeAt(f)!==0){c=f;break}c!==-1?o=o.slice(0,c+1):o=""}return o}u(sh,"fromBase64");function zd(r){let e="",t=new Uint8Array(r);for(let n of t)e+=String.fromCharCode(n);return e}u(zd,"arrayBufferToString");function yl(r){let e=r.length,t=new ArrayBuffer(e),n=new Uint8Array(t);for(let s=0;s<e;s++)n[s]=r.charCodeAt(s);return t}u(yl,"stringToArrayBuffer");var MG=Math.log(2);function z4(r){let e=Math.log(r)/MG,t=Math.floor(e),n=Math.round(e);return t===n?t:n}u(z4,"nearestPowerOf2");function we(r,e){for(let t of e)delete r[t]}u(we,"clearProps");function tE(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}u(tE,"assertBigInt");function Sb(r){let e=0,t=0;for(let s=0;s<r.length;s++){let i=r[s];e+=i.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let i=r[s];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}u(Sb,"concat");function Ea(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}u(Ea,"checkBufferParams");var Ab=class{static{u(this,"ViewWriter")}constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Sb(this.items)}},Jd=[new Uint8Array([1])],Y4="0123456789",vb="name",Q4="valueHexView",jG="isHexOnly",qG="idBlock",HG="tagClass",KG="tagNumber",XG="isConstructed",GG="fromBER",$G="toBER",WG="local",Zn="",Vi=new ArrayBuffer(0),rE=new Uint8Array(0),Qd="EndOfContent",ek="OCTET STRING",tk="BIT STRING";function wa(r){var e;return e=class extends r{static{u(this,"Some")}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}constructor(...n){var s;super(...n);let i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?Ye.toUint8Array(i.valueHex):rE}fromBER(n,s,i){let a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Ea(this,a,s,i))return-1;let o=s+i;return this.valueHexView=a.subarray(s,o),this.valueHexView.length?(this.blockLength=i,o):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Vi)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:at.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}u(wa,"HexBlock");var vl=class{static{u(this,"LocalBaseBlock")}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=Zn,warnings:n=[],valueBeforeDecode:s=rE}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Ye.toUint8Array(s)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:at.ToHex(this.valueBeforeDecodeView)}}};vl.NAME="baseBlock";var es=class extends vl{static{u(this,"ValueBlock")}fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};es.NAME="valueBlock";var rk=class extends wa(vl){static{u(this,"LocalIdentificationBlock")}constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Ye.toUint8Array(e.valueHex):rE,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Vi}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=ei(this.tagNumber,7),i=new Uint8Array(s),a=s.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let l=0;l<a-1;l++)o[l+1]=i[l]|128;o[a]=i[a-1]}return o.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){let s=Ye.toUint8Array(e);if(!Ea(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let o=i[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let l=1,c=this.valueHexView=new Uint8Array(255),f=255;for(;i[l]&128;){if(c[l-1]=i[l]&127,l++,l>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(l===f){f+=255;let d=new Uint8Array(f);for(let g=0;g<c.length;g++)d[g]=c[g];c=this.valueHexView=new Uint8Array(f)}}this.blockLength=l+1,c[l-1]=i[l]&127;let p=new Uint8Array(l);for(let d=0;d<l;d++)p[d]=c[d];c=this.valueHexView=new Uint8Array(l),c.set(p),this.blockLength<=9?this.tagNumber=va(c,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};rk.NAME="identificationBlock";var nk=class extends vl{static{u(this,"LocalLengthBlock")}constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=Ye.toUint8Array(e);if(!Ea(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let a=i[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let o=t+1,l=s.subarray(o,o+a);return l[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=va(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=ei(this.length,8);if(s.byteLength>127)return this.error="Too big length",Vi;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let i=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let a=0;a<s.byteLength;a++)n[a+1]=i[a];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};nk.NAME="lengthBlock";var Ge={},Vn=class extends vl{static{u(this,"BaseBlock")}constructor({name:e=Zn,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new rk(s),this.lenBlock=new nk(s),this.valueBlock=i?new i(s):new es(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(e,t){let n=t||new Ab;t||sk(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let a=this.lenBlock.toBER(e);n.write(a),n.write(i)}return t?Vi:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():at.ToHex(this.toBER())}onAsciiEncoding(){let e=this.constructor.NAME,t=at.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${t}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return Lo(t,n)}};Vn.NAME="BaseBlock";function sk(r){var e;if(r instanceof Ge.Constructed)for(let t of r.valueBlock.value)sk(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}u(sk,"prepareIndefiniteForm");var ik=class extends Vn{static{u(this,"BaseStringBlock")}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=Zn,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};ik.NAME="BaseStringBlock";var ak=class extends wa(es){static{u(this,"LocalPrimitiveValueBlock")}constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};ak.NAME="PrimitiveValueBlock";var ok,Ze=class extends Vn{static{u(this,"Primitive")}constructor(e={}){super(e,ak),this.idBlock.isConstructed=!1}};ok=Ze;Ge.Primitive=ok;Ze.NAME="PRIMITIVE";function zG(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}u(zG,"localChangeType");function Zd(r,e=0,t=r.length){let n=e,s=new Vn({},es),i=new vl;if(!Ea(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let o=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),o===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=o,t-=s.idBlock.blockLength,o=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),o===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=o,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let l=Vn;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};l=Ge.EndOfContent;break;case 1:l=Ge.Boolean;break;case 2:l=Ge.Integer;break;case 3:l=Ge.BitString;break;case 4:l=Ge.OctetString;break;case 5:l=Ge.Null;break;case 6:l=Ge.ObjectIdentifier;break;case 10:l=Ge.Enumerated;break;case 12:l=Ge.Utf8String;break;case 13:l=Ge.RelativeObjectIdentifier;break;case 14:l=Ge.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:l=Ge.Sequence;break;case 17:l=Ge.Set;break;case 18:l=Ge.NumericString;break;case 19:l=Ge.PrintableString;break;case 20:l=Ge.TeletexString;break;case 21:l=Ge.VideotexString;break;case 22:l=Ge.IA5String;break;case 23:l=Ge.UTCTime;break;case 24:l=Ge.GeneralizedTime;break;case 25:l=Ge.GraphicString;break;case 26:l=Ge.VisibleString;break;case 27:l=Ge.GeneralString;break;case 28:l=Ge.UniversalString;break;case 29:l=Ge.CharacterString;break;case 30:l=Ge.BmpString;break;case 31:l=Ge.DATE;break;case 32:l=Ge.TimeOfDay;break;case 33:l=Ge.DateTime;break;case 34:l=Ge.Duration;break;default:{let c=s.idBlock.isConstructed?new Ge.Constructed:new Ge.Primitive;c.idBlock=s.idBlock,c.lenBlock=s.lenBlock,c.warnings=s.warnings,s=c}}break;case 2:case 3:case 4:default:l=s.idBlock.isConstructed?Ge.Constructed:Ge.Primitive}return s=zG(s,l),o=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:o,result:s}}u(Zd,"localFromBER");function Ar(r){if(!r.byteLength){let e=new Vn({},es);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Zd(Ye.toUint8Array(r).slice(),0,r.byteLength)}u(Ar,"fromBER");function JG(r,e){return r?1:e}u(JG,"checkLen");var Vo=class extends es{static{u(this,"LocalConstructedValueBlock")}constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=Ye.toUint8Array(e);if(!Ea(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;JG(this.isIndefiniteForm,n)>0;){let a=Zd(s,i,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(i=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===Qd)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Qd?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new Ab;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?Vi:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Vo.NAME="ConstructedValueBlock";var uk,re=class extends Vn{static{u(this,"Constructed")}constructor(e={}){super(e,Vo),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`