labsign 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +9 -12
- package/README.md +9 -12
- package/dist/THIRD_PARTY_LICENSES.txt +1 -1
- package/dist/labsign.js +1 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -21,7 +21,7 @@ You say "sign this contract". A screen opens: you draw your signature (or pick a
|
|
|
21
21
|
|
|
22
22
|
### Claude Desktop
|
|
23
23
|
|
|
24
|
-
1. Download `labsign-<version>.mcpb` from Releases, or build it yourself (see [Development](#development)).
|
|
24
|
+
1. Download `labsign-<version>.mcpb` from the [Releases page](https://github.com/paullabs/labsign/releases), or build it yourself (see [Development](#development)).
|
|
25
25
|
2. Double-click it (or drag it into **Settings → Extensions**) and click **Install**.
|
|
26
26
|
3. In a conversation, ask: _"sign the contract at ~/Downloads/contract.pdf"_. If you only attached the PDF to the conversation, say _"I want to sign this PDF"_: the screen asks you to drop the file on it, because Claude doesn't hand attachments to extensions.
|
|
27
27
|
|
|
@@ -29,30 +29,27 @@ The screen opens inside the conversation in Claude Desktop versions that support
|
|
|
29
29
|
|
|
30
30
|
### Claude Code
|
|
31
31
|
|
|
32
|
-
For now, from the source (installing straight from GitHub comes with the npm release):
|
|
33
|
-
|
|
34
32
|
```bash
|
|
35
|
-
|
|
36
|
-
npm ci && npm run mcpb
|
|
37
|
-
claude plugin marketplace add "$(pwd)"
|
|
33
|
+
claude plugin marketplace add paullabs/labsign
|
|
38
34
|
claude plugin install labsign@labsign
|
|
39
35
|
```
|
|
40
36
|
|
|
41
|
-
The plugin
|
|
37
|
+
The plugin fetches the MCP server from [npm](https://www.npmjs.com/package/labsign) (via `npx`, at run time) and already brings a skill that teaches Claude Code how to use labsign. Claude Code runs in the terminal, so the screen opens in the browser.
|
|
42
38
|
|
|
43
39
|
### Codex
|
|
44
40
|
|
|
45
41
|
```bash
|
|
46
|
-
codex mcp add labsign --
|
|
47
|
-
|
|
42
|
+
codex mcp add labsign -- npx -y labsign@latest mcp
|
|
43
|
+
mkdir -p ~/.agents/skills/labsign
|
|
44
|
+
curl -fsSL https://raw.githubusercontent.com/paullabs/labsign/main/plugin/skills/labsign/SKILL.md -o ~/.agents/skills/labsign/SKILL.md
|
|
48
45
|
```
|
|
49
46
|
|
|
50
|
-
Codex stops tools after 60 seconds, so labsign answers within 45 seconds and then follows the signing through `labsign_status`.
|
|
47
|
+
Codex stops tools after 60 seconds, so labsign answers within 45 seconds and then follows the signing through `labsign_status`. The skill isn't part of the npm package (it's specific to Codex/Claude Code), so `curl` fetches it straight from the repository.
|
|
51
48
|
|
|
52
49
|
### Terminal (and any other app)
|
|
53
50
|
|
|
54
51
|
```bash
|
|
55
|
-
npm
|
|
52
|
+
npm install -g labsign
|
|
56
53
|
labsign sign contract.pdf --anchor Signature
|
|
57
54
|
```
|
|
58
55
|
|
|
@@ -98,7 +95,7 @@ npm ci
|
|
|
98
95
|
npm run build # dist/labsign.js (CLI + MCP) and dist/ui.html, dist/ui-app.html (the screen)
|
|
99
96
|
npm test # build + tests (needs Node 24; poppler is optional and enables pixel checks)
|
|
100
97
|
npm run typecheck
|
|
101
|
-
npm run mcpb # dist/labsign-<version>.mcpb
|
|
98
|
+
npm run mcpb # dist/labsign-<version>.mcpb (Claude Desktop installer)
|
|
102
99
|
```
|
|
103
100
|
|
|
104
101
|
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Você diz "assina esse contrato". Abre uma tela, você desenha a assinatura (ou
|
|
|
21
21
|
|
|
22
22
|
### Claude Desktop
|
|
23
23
|
|
|
24
|
-
1. Baixe o `labsign-<versão>.mcpb` na página de Releases, ou gere o arquivo você mesmo (veja [Desenvolvimento](#desenvolvimento)).
|
|
24
|
+
1. Baixe o `labsign-<versão>.mcpb` na [página de Releases](https://github.com/paullabs/labsign/releases), ou gere o arquivo você mesmo (veja [Desenvolvimento](#desenvolvimento)).
|
|
25
25
|
2. Dê dois cliques no arquivo (ou arraste-o em **Configurações → Extensões**) e clique em **Instalar**.
|
|
26
26
|
3. Numa conversa, peça: _"assina o contrato que está em ~/Downloads/contrato.pdf"_. Se você só anexou o PDF na conversa, diga _"quero assinar esse PDF"_: a tela vai pedir para você soltar o arquivo nela, porque o Claude não repassa anexos para extensões.
|
|
27
27
|
|
|
@@ -29,30 +29,27 @@ A tela abre dentro da conversa nas versões do Claude Desktop que suportam MCP A
|
|
|
29
29
|
|
|
30
30
|
### Claude Code
|
|
31
31
|
|
|
32
|
-
Por enquanto, a partir do código (a instalação direto do GitHub vem com a publicação no npm):
|
|
33
|
-
|
|
34
32
|
```bash
|
|
35
|
-
|
|
36
|
-
npm ci && npm run mcpb
|
|
37
|
-
claude plugin marketplace add "$(pwd)"
|
|
33
|
+
claude plugin marketplace add paullabs/labsign
|
|
38
34
|
claude plugin install labsign@labsign
|
|
39
35
|
```
|
|
40
36
|
|
|
41
|
-
O plugin
|
|
37
|
+
O plugin busca o servidor MCP do [npm](https://www.npmjs.com/package/labsign) (via `npx`, na hora de usar) e já traz a skill que ensina o Claude Code a usar o labsign. Como o Claude Code roda no terminal, a tela abre no navegador.
|
|
42
38
|
|
|
43
39
|
### Codex
|
|
44
40
|
|
|
45
41
|
```bash
|
|
46
|
-
codex mcp add labsign --
|
|
47
|
-
|
|
42
|
+
codex mcp add labsign -- npx -y labsign@latest mcp
|
|
43
|
+
mkdir -p ~/.agents/skills/labsign
|
|
44
|
+
curl -fsSL https://raw.githubusercontent.com/paullabs/labsign/main/plugin/skills/labsign/SKILL.md -o ~/.agents/skills/labsign/SKILL.md
|
|
48
45
|
```
|
|
49
46
|
|
|
50
|
-
O Codex corta as ferramentas em 60 segundos. Por isso o labsign responde em até 45 segundos e depois acompanha a assinatura pelo `labsign_status`.
|
|
47
|
+
O Codex corta as ferramentas em 60 segundos. Por isso o labsign responde em até 45 segundos e depois acompanha a assinatura pelo `labsign_status`. A skill não vai dentro do pacote do npm (é específica do Codex/Claude Code), por isso o `curl` busca ela direto do repositório.
|
|
51
48
|
|
|
52
49
|
### Terminal (e qualquer outro app)
|
|
53
50
|
|
|
54
51
|
```bash
|
|
55
|
-
npm
|
|
52
|
+
npm install -g labsign
|
|
56
53
|
labsign sign contrato.pdf --anchor CONTRATANTE
|
|
57
54
|
```
|
|
58
55
|
|
|
@@ -98,7 +95,7 @@ npm ci
|
|
|
98
95
|
npm run build # dist/labsign.js (CLI + MCP) e dist/ui.html, dist/ui-app.html (a tela)
|
|
99
96
|
npm test # build + testes (precisa do Node 24; o poppler é opcional e ativa as checagens de pixel)
|
|
100
97
|
npm run typecheck
|
|
101
|
-
npm run mcpb # dist/labsign-<versão>.mcpb
|
|
98
|
+
npm run mcpb # dist/labsign-<versão>.mcpb (instalador do Claude Desktop)
|
|
102
99
|
```
|
|
103
100
|
|
|
104
101
|
| Pasta | Conteúdo |
|
package/dist/labsign.js
CHANGED
|
@@ -213,7 +213,7 @@ startxref
|
|
|
213
213
|
`),u=new Q(n);return u.set("FormType",1),u.setIfName("Subtype","Form"),u.setIfName("Type","XObject"),u.set("BBox",i),u.set("Length",l.length),new Us(l,u)}static async createNewAppearanceStream(e,n,r){if(e.oldAnnotation)return null;if(e.isSignature)return this.#t(e,n);let{rotation:s}=e,{imageRef:i,width:o,height:a}=r.image,c=new Q(n),l=new Q(n);c.set("XObject",l),l.set("Im0",i);let u=`q ${o} 0 0 ${a} 0 0 cm /Im0 Do Q`,h=new Q(n);if(h.set("FormType",1),h.setIfName("Subtype","Form"),h.setIfName("Type","XObject"),h.set("BBox",[0,0,o,a]),h.set("Resources",c),s){let d=a5(s,o,a);h.set("Matrix",d)}return new Us(u,h)}},ON=class extends Oi{static{f(this,"FileAttachmentAnnotation")}constructor(e){super(e);let{annotationGlobals:n,dict:r}=e,s=r.get("FS");this.data.hasOwnCanvas=this.data.noRotate,this.data.noHTML=!1,this.data.fileId=this._getAttachmentId(s,r.getRaw("FS"),n),this.data.file=new Ui(s).serializable;let i=r.get("Name");this.data.name=i instanceof ve?Ht(i.name):"PushPin";let o=r.get("ca");this.data.fillAlpha=typeof o=="number"&&o>=0&&o<=1?o:null}},k0=class t extends tu{static{f(this,"MediaAnnotation")}static#e=/^(?:video|audio)\//;constructor(e){super(e),this.data.noHTML=!0}_setMediaData({assetRef:e,assetDict:n,filename:r,contentType:s,wrapSound:i=!1},o){this.data.noHTML=!1,this.data.richMedia={fileId:this._getAttachmentId(n,e,o,i),filename:r,contentType:s}}static _getContentType(e,n,r=null){if(typeof r=="string"&&t.#e.test(r))return r;let s=Ui.pickPlatformItem(e.get("EF")),i=s instanceof kt?s.dict?.get("Subtype"):null;if(i instanceof ve&&t.#e.test(i.name))return i.name;switch(n.split(".").at(-1)?.toLowerCase()){case"mp4":case"m4v":return"video/mp4";case"webm":return"video/webm";case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"mp3":return"audio/mpeg";case"m4a":return"audio/mp4";case"wav":return"audio/wav";case"oga":case"ogg":return"audio/ogg";default:return null}}},FN=class t extends k0{static{f(this,"RichMediaAnnotation")}constructor(e){super(e);let{dict:n,xref:r,annotationGlobals:s}=e,i=n.get("RichMediaContent");if(!(i instanceof Q))return;let o=t.#e(i,r);if(!o){te("RichMedia annotation has no playable asset.");return}this._setMediaData(o,s)}static#e(e,n){let r=e.get("Configurations");if(!Array.isArray(r))return null;for(let s of r){let i=n.fetchIfRef(s);if(!(i instanceof Q))continue;let o=i.get("Instances");if(Array.isArray(o))for(let a of o){let c=n.fetchIfRef(a);if(!(c instanceof Q)||It(c.get("Subtype"),"Flash"))continue;let l=c.getRaw("Asset"),u=n.fetchIfRef(l);if(!(u instanceof Q)||!Ui.hasEmbeddedFile(u))continue;let{filename:h}=new Ui(u).serializable,d=k0._getContentType(u,h);if(d)return{assetRef:l instanceof Se?l:null,assetDict:u,filename:h,contentType:d}}}return null}},DN=class t extends k0{static{f(this,"ScreenAnnotation")}constructor(e){super(e);let{dict:n,xref:r,annotationGlobals:s}=e,i=t.#e(n,r);i&&this._setMediaData(i,s)}static#e(e,n){for(let r of this.#t(e)){let s=this.#r(r.get("R"),n,new En);if(s)return s}return null}static*#t(e){let n=e.get("A");n instanceof Q&&It(n.get("S"),"Rendition")&&this.#n(n)&&(yield n);let r=e.get("AA");if(r instanceof Q)for(let[,s]of r)s instanceof Q&&It(s.get("S"),"Rendition")&&this.#n(s)&&(yield s)}static#n(e){let n=e.get("OP");return n===void 0||n===mY.PLAY_OR_RESUME||n===mY.PLAY}static#r(e,n,r){if(!(e instanceof Q))return null;let s=e.get("S");if(It(s,"MR"))return this.#s(e.get("C"),n);if(It(s,"SR")){let i=e.get("R");if(Array.isArray(i))for(let o of i){if(o instanceof Se){if(r.has(o))continue;r.put(o)}let a=this.#r(n.fetchIfRef(o),n,r);if(a)return a}}return null}static#s(e,n){if(!(e instanceof Q)||!It(e.get("S"),"MCD"))return null;let r=e.getRaw("D"),s=n.fetchIfRef(r),i=e.get("CT"),o=typeof i=="string"?i:null,a,c;if(s instanceof kt){a=s.dict;let u=e.get("N");if(c=typeof u=="string"?Ht(u):"",!o){let h=s.dict.get("Subtype");h instanceof ve&&(o=h.name)}}else if(s instanceof Q){if(!Ui.hasEmbeddedFile(s))return null;a=s,{filename:c}=new Ui(s).serializable}else return null;let l=k0._getContentType(a,c,o);return l?{assetRef:r instanceof Se?r:null,assetDict:a,filename:c,contentType:l}:null}},NN=class extends k0{static{f(this,"SoundAnnotation")}constructor(e){super(e);let{dict:n,xref:r,annotationGlobals:s}=e,i=n.getRaw("Sound");if(!(i instanceof Se))return;let o;try{o=r.fetch(i)}catch(a){if(a instanceof Un)throw a;te(`SoundAnnotation: "${a}".`);return}!(o instanceof kt)||!aZ(o.dict)||this._setMediaData({assetRef:i,assetDict:o.dict,filename:"sound.wav",contentType:"audio/wav",wrapSound:!0},s)}},Pge={get r(){return ze(this,"r",new Uint8Array([7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21]))},get k(){return ze(this,"k",new Int32Array([-680876936,-389564586,606105819,-1044525330,-176418897,1200080426,-1473231341,-45705983,1770035416,-1958414417,-42063,-1990404162,1804603682,-40341101,-1502002290,1236535329,-165796510,-1069501632,643717713,-373897302,-701558691,38016083,-660478335,-405537848,568446438,-1019803690,-187363961,1163531501,-1444681467,-51403784,1735328473,-1926607734,-378558,-2022574463,1839030562,-35309556,-1530992060,1272893353,-155497632,-1094730640,681279174,-358537222,-722521979,76029189,-640364487,-421815835,530742520,-995338651,-198630844,1126891415,-1416354905,-57434055,1700485571,-1894986606,-1051523,-2054922799,1873313359,-30611744,-1560198380,1309151649,-145523070,-1120210379,718787259,-343485551]))}};f($f,"calculateMD5");f(hJ,"decodeString");MN=class extends Wp{static{f(this,"DatasetXMLParser")}node=null;onEndElement(e){let n=super.onEndElement(e);if(n&&e==="xfa:datasets")throw this.node=n,new Error("Aborting DatasetXMLParser.")}},zN=class{static{f(this,"DatasetReader")}constructor(e){if(e.datasets)this.node=new Wp({hasAttributes:!0}).parseFromString(e.datasets).documentElement;else{let n=new MN({hasAttributes:!0});try{n.parseFromString(e["xdp:xdp"])}catch{}this.node=n.node}}getValue(e){if(!this.node||!e)return"";let n=this.node.searchNode(RJ(e),0);return n?n.firstChild?.nodeName==="value"?n.children.map(s=>hJ(s.textContent)):hJ(n.textContent):""}},LN=class{static{f(this,"SingleIntersector")}#e;minX=1/0;minY=1/0;maxX=-1/0;maxY=-1/0;#t=null;#n=[];#r=[];#s=-1;#o=!1;constructor(e){this.#e=e;let n=e.data.quadPoints;if(!n){[this.minX,this.minY,this.maxX,this.maxY]=e.data.rect;return}for(let r=0,s=n.length;r<s;r+=8)this.minX=Math.min(this.minX,n[r]),this.maxX=Math.max(this.maxX,n[r+2]),this.minY=Math.min(this.minY,n[r+5]),this.maxY=Math.max(this.maxY,n[r+1]);n.length>8&&(this.#t=n)}#i(e,n){if(this.minX>=e||this.maxX<=e||this.minY>=n||this.maxY<=n)return!1;let r=this.#t;if(!r)return!0;if(this.#s>=0){let s=this.#s;if(!(r[s]>=e||r[s+2]<=e||r[s+5]>=n||r[s+1]<=n))return!0;this.#s=-1}for(let s=0,i=r.length;s<i;s+=8)if(!(r[s]>=e||r[s+2]<=e||r[s+5]>=n||r[s+1]<=n))return this.#s=s,!0;return!1}addGlyph(e,n,r){return this.#i(e,n)?(this.#r.length>0&&(this.#n.push(this.#r.join("")),this.#r.length=0),this.#n.push(r),this.#o=!0,!0):(this.disableExtraChars(),!1)}addExtraChar(e){this.#o&&this.#r.push(e)}disableExtraChars(){this.#o&&(this.#o=!1,this.#r.length=0)}setText(){this.#e.data.overlaidText=this.#n.join("")}},Yh=64,_N=class{static{f(this,"Intersector")}#e=[];#t=[];#n;#r;#s;#o;#i;#a;constructor(e){let n=1/0,r=1/0,s=-1/0,i=-1/0,o=this.#e;for(let a of e){if(!a.data.quadPoints&&!a.data.rect)continue;let c=new LN(a);o.push(c),n=Math.min(n,c.minX),r=Math.min(r,c.minY),s=Math.max(s,c.maxX),i=Math.max(i,c.maxY)}this.#n=n,this.#s=r,this.#r=s,this.#o=i,this.#i=(Yh-1)/(s-n),this.#a=(Yh-1)/(i-r);for(let a of o){let c=this.#c(a.minX,a.minY),l=this.#c(a.maxX,a.maxY),u=(l-c)%Yh,h=Math.floor((l-c)/Yh);for(let d=c;d<=c+h*Yh;d+=Yh)for(let p=0;p<=u;p++)(this.#t[d+p]??=[]).push(a)}}#c(e,n){let r=Math.floor((e-this.#n)*this.#i),s=Math.floor((n-this.#s)*this.#a);return r+s*Yh}addGlyph(e,n,r,s){let i=e[4]+n/2,o=e[5]+r/2;if(i<this.#n||o<this.#s||i>this.#r||o>this.#o)return;let a=this.#t[this.#c(i,o)];if(a)for(let c of a)c.addGlyph(i,o,s)}addExtraChar(e){for(let n of this.#e)n.addExtraChar(e)}setText(){for(let e of this.#e)e.setText()}},Ge=class{static{f(this,"Word64")}constructor(e,n){this.high=e|0,this.low=n|0}and(e){this.high&=e.high,this.low&=e.low}xor(e){this.high^=e.high,this.low^=e.low}shiftRight(e){this.low=this.low>>>e|this.high<<32-e,this.high=this.high>>>e|0}rotateRight(e){let n,r;e&32?(r=this.low,n=this.high):(n=this.low,r=this.high),e&=31,this.low=n>>>e|r<<32-e,this.high=r>>>e|n<<32-e}not(){this.high=~this.high,this.low=~this.low}add(e){let n=(this.low>>>0)+(e.low>>>0),r=(this.high>>>0)+(e.high>>>0);n>4294967295&&(r+=1),this.low=n|0,this.high=r|0}copyTo(e,n){e[n]=this.high>>>24&255,e[n+1]=this.high>>16&255,e[n+2]=this.high>>8&255,e[n+3]=this.high&255,e[n+4]=this.low>>>24&255,e[n+5]=this.low>>16&255,e[n+6]=this.low>>8&255,e[n+7]=this.low&255}assign(e){this.high=e.high,this.low=e.low}},qge={get k(){return ze(this,"k",[new Ge(1116352408,3609767458),new Ge(1899447441,602891725),new Ge(3049323471,3964484399),new Ge(3921009573,2173295548),new Ge(961987163,4081628472),new Ge(1508970993,3053834265),new Ge(2453635748,2937671579),new Ge(2870763221,3664609560),new Ge(3624381080,2734883394),new Ge(310598401,1164996542),new Ge(607225278,1323610764),new Ge(1426881987,3590304994),new Ge(1925078388,4068182383),new Ge(2162078206,991336113),new Ge(2614888103,633803317),new Ge(3248222580,3479774868),new Ge(3835390401,2666613458),new Ge(4022224774,944711139),new Ge(264347078,2341262773),new Ge(604807628,2007800933),new Ge(770255983,1495990901),new Ge(1249150122,1856431235),new Ge(1555081692,3175218132),new Ge(1996064986,2198950837),new Ge(2554220882,3999719339),new Ge(2821834349,766784016),new Ge(2952996808,2566594879),new Ge(3210313671,3203337956),new Ge(3336571891,1034457026),new Ge(3584528711,2466948901),new Ge(113926993,3758326383),new Ge(338241895,168717936),new Ge(666307205,1188179964),new Ge(773529912,1546045734),new Ge(1294757372,1522805485),new Ge(1396182291,2643833823),new Ge(1695183700,2343527390),new Ge(1986661051,1014477480),new Ge(2177026350,1206759142),new Ge(2456956037,344077627),new Ge(2730485921,1290863460),new Ge(2820302411,3158454273),new Ge(3259730800,3505952657),new Ge(3345764771,106217008),new Ge(3516065817,3606008344),new Ge(3600352804,1432725776),new Ge(4094571909,1467031594),new Ge(275423344,851169720),new Ge(430227734,3100823752),new Ge(506948616,1363258195),new Ge(659060556,3750685593),new Ge(883997877,3785050280),new Ge(958139571,3318307427),new Ge(1322822218,3812723403),new Ge(1537002063,2003034995),new Ge(1747873779,3602036899),new Ge(1955562222,1575990012),new Ge(2024104815,1125592928),new Ge(2227730452,2716904306),new Ge(2361852424,442776044),new Ge(2428436474,593698344),new Ge(2756734187,3733110249),new Ge(3204031479,2999351573),new Ge(3329325298,3815920427),new Ge(3391569614,3928383900),new Ge(3515267271,566280711),new Ge(3940187606,3454069534),new Ge(4118630271,4000239992),new Ge(116418474,1914138554),new Ge(174292421,2731055270),new Ge(289380356,3203993006),new Ge(460393269,320620315),new Ge(685471733,587496836),new Ge(852142971,1086792851),new Ge(1017036298,365543100),new Ge(1126000580,2618297676),new Ge(1288033470,3409855158),new Ge(1501505948,4234509866),new Ge(1607167915,987167468),new Ge(1816402316,1246189591)])}};f(Oge,"ch");f(Fge,"maj");f(Dge,"sigma");f(Nge,"sigmaPrime");f(Mge,"littleSigma");f(zge,"littleSigmaPrime");f(IZ,"calculateSHA512");f(Lge,"calculateSHA384");_ge={get k(){return ze(this,"k",[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298])}};f(Mc,"rotr");f(Bge,"calculate_sha256_ch");f(Hge,"calculate_sha256_maj");f(Uge,"calculate_sha256_sigma");f($ge,"calculate_sha256_sigmaPrime");f(Vge,"calculate_sha256_littleSigma");f(Gge,"calculate_sha256_littleSigmaPrime");f(BN,"calculateSHA256");dJ=512,HN=class extends ti{static{f(this,"DecryptStream")}#e=null;constructor(e,n,r){super(n),this.stream=e,this.dict=e.dict,this.decrypt=r}readBlock(){let e=this.#e??this.stream.getBytes(dJ);if(!e.length){this.eof=!0;return}this.#e=this.stream.getBytes(dJ);let n=this.#e.length>0,r=this.decrypt;e=r(e,!n);let s=this.bufferLength,i=s+e.length;this.ensureBuffer(i).set(e,s),this.bufferLength=i}getOriginalStream(){return this}},Wge=new Set([160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8203,8239,8287,12288]),Kge=new Set([173,847,6150,6155,6156,6157,8203,8204,8205,8288,65024,65025,65026,65027,65028,65029,65030,65031,65032,65033,65034,65035,65036,65037,65038,65039,65279]);f(Xge,"saslPrep");wl=class{static{f(this,"ARCFourCipher")}a=0;b=0;constructor(e){let n=new Uint8Array(256),r=e.length;for(let s=0;s<256;++s)n[s]=s;for(let s=0,i=0;s<256;++s){let o=n[s];i=i+o+e[s%r]&255,n[s]=n[i],n[i]=o}this.s=n}encryptBlock(e){let n=this.a,r=this.b,s=this.s,i=e.length,o=new Uint8Array(i);for(let a=0;a<i;++a){n=n+1&255;let c=s[n];r=r+c&255;let l=s[r];s[n]=l,s[r]=c,o[a]=e[a]^s[c+l&255]}return this.a=n,this.b=r,o}decryptBlock(e){return this.encryptBlock(e)}encrypt(e){return this.encryptBlock(e)}},UN=class{static{f(this,"NullCipher")}decryptBlock(e){return e}encrypt(e){return e}},aw=class{static{f(this,"AESBaseCipher")}_s=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]);_inv_s=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]);_mix=new Uint32Array([0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795]);_mixCol=Uint8Array.from({length:256},(e,n)=>n<128?n<<1:n<<1^27);constructor(){this.buffer=new Uint8Array(16),this.bufferPosition=0}_expandKey(e){rn("Cannot call `_expandKey` on the base class")}_decrypt(e,n){let r,s,i,o=new Uint8Array(16);o.set(e);for(let a=0,c=this._keySize;a<16;++a,++c)o[a]^=n[c];for(let a=this._cyclesOfRepetition-1;a>=1;--a){r=o[13],o[13]=o[9],o[9]=o[5],o[5]=o[1],o[1]=r,r=o[14],s=o[10],o[14]=o[6],o[10]=o[2],o[6]=r,o[2]=s,r=o[15],s=o[11],i=o[7],o[15]=o[3],o[11]=r,o[7]=s,o[3]=i;for(let c=0;c<16;++c)o[c]=this._inv_s[o[c]];for(let c=0,l=a*16;c<16;++c,++l)o[c]^=n[l];for(let c=0;c<16;c+=4){let l=this._mix[o[c]],u=this._mix[o[c+1]],h=this._mix[o[c+2]],d=this._mix[o[c+3]];r=l^u>>>8^u<<24^h>>>16^h<<16^d>>>24^d<<8,o[c]=r>>>24&255,o[c+1]=r>>16&255,o[c+2]=r>>8&255,o[c+3]=r&255}}r=o[13],o[13]=o[9],o[9]=o[5],o[5]=o[1],o[1]=r,r=o[14],s=o[10],o[14]=o[6],o[10]=o[2],o[6]=r,o[2]=s,r=o[15],s=o[11],i=o[7],o[15]=o[3],o[11]=r,o[7]=s,o[3]=i;for(let a=0;a<16;++a)o[a]=this._inv_s[o[a]],o[a]^=n[a];return o}_encrypt(e,n){let r=this._s,s,i,o,a=new Uint8Array(16);a.set(e);for(let c=0;c<16;++c)a[c]^=n[c];for(let c=1;c<this._cyclesOfRepetition;c++){for(let l=0;l<16;++l)a[l]=r[a[l]];o=a[1],a[1]=a[5],a[5]=a[9],a[9]=a[13],a[13]=o,o=a[2],i=a[6],a[2]=a[10],a[6]=a[14],a[10]=o,a[14]=i,o=a[3],i=a[7],s=a[11],a[3]=a[15],a[7]=o,a[11]=i,a[15]=s;for(let l=0;l<16;l+=4){let u=a[l],h=a[l+1],d=a[l+2],p=a[l+3];s=u^h^d^p,a[l]^=s^this._mixCol[u^h],a[l+1]^=s^this._mixCol[h^d],a[l+2]^=s^this._mixCol[d^p],a[l+3]^=s^this._mixCol[p^u]}for(let l=0,u=c*16;l<16;++l,++u)a[l]^=n[u]}for(let c=0;c<16;++c)a[c]=r[a[c]];o=a[1],a[1]=a[5],a[5]=a[9],a[9]=a[13],a[13]=o,o=a[2],i=a[6],a[2]=a[10],a[6]=a[14],a[10]=o,a[14]=i,o=a[3],i=a[7],s=a[11],a[3]=a[15],a[7]=o,a[11]=i,a[15]=s;for(let c=0,l=this._keySize;c<16;++c,++l)a[c]^=n[l];return a}_decryptBlock2(e,n){let r=e.length,s=this.buffer,i=this.bufferPosition,o=[],a=this.iv;for(let u=0;u<r;++u){if(s[i]=e[u],++i,i<16)continue;let h=this._decrypt(s,this._key);for(let d=0;d<16;++d)h[d]^=a[d];a=s,o.push(h),s=new Uint8Array(16),i=0}if(this.buffer=s,this.bufferLength=i,this.iv=a,o.length===0)return new Uint8Array(0);let c=16*o.length;if(n){let u=o.at(-1),h=u[15];if(h<=16){for(let d=15,p=16-h;d>=p;--d)if(u[d]!==h){h=0;break}c-=h,o[o.length-1]=u.subarray(0,16-h)}}let l=new Uint8Array(c);for(let u=0,h=0,d=o.length;u<d;++u,h+=16)l.set(o[u],h);return l}decryptBlock(e,n,r=null){let s=e.length,i=this.buffer,o=this.bufferPosition;if(r)this.iv=r;else{for(let a=0;o<16&&a<s;++a,++o)i[o]=e[a];if(o<16)return this.bufferLength=o,new Uint8Array(0);this.iv=i,e=e.subarray(16)}return this.buffer=new Uint8Array(16),this.bufferLength=0,this.decryptBlock=this._decryptBlock2,this.decryptBlock(e,n)}encrypt(e,n){let r=e.length,s=this.buffer,i=this.bufferPosition,o=[];n||=new Uint8Array(16);for(let l=0;l<r;++l){if(s[i]=e[l],++i,i<16)continue;for(let h=0;h<16;++h)s[h]^=n[h];let u=this._encrypt(s,this._key);n=u,o.push(u),s=new Uint8Array(16),i=0}if(this.buffer=s,this.bufferLength=i,this.iv=n,o.length===0)return new Uint8Array(0);let a=16*o.length,c=new Uint8Array(a);for(let l=0,u=0,h=o.length;l<h;++l,u+=16)c.set(o[l],u);return c}},xS=class extends aw{static{f(this,"AES128Cipher")}_rcon=new Uint8Array([141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141]);constructor(e){super(),this._cyclesOfRepetition=10,this._keySize=160,this._key=this._expandKey(e)}_expandKey(e){let r=this._s,s=this._rcon,i=new Uint8Array(176);i.set(e);for(let o=16,a=1;o<176;++a){let c=i[o-3],l=i[o-2],u=i[o-1],h=i[o-4];c=r[c],l=r[l],u=r[u],h=r[h],c^=s[a];for(let d=0;d<4;++d)i[o]=c^=i[o-16],o++,i[o]=l^=i[o-16],o++,i[o]=u^=i[o-16],o++,i[o]=h^=i[o-16],o++}return i}},cw=class extends aw{static{f(this,"AES256Cipher")}constructor(e){super(),this._cyclesOfRepetition=14,this._keySize=224,this._key=this._expandKey(e)}_expandKey(e){let r=this._s,s=new Uint8Array(240);s.set(e);let i=1,o,a,c,l;for(let u=32,h=1;u<240;++h){u%32===16?(o=r[o],a=r[a],c=r[c],l=r[l]):u%32===0&&(o=s[u-3],a=s[u-2],c=s[u-1],l=s[u-4],o=r[o],a=r[a],c=r[c],l=r[l],o^=i,(i<<=1)>=256&&(i=(i^27)&255));for(let d=0;d<4;++d)s[u]=o^=s[u-32],u++,s[u]=a^=s[u-32],u++,s[u]=c^=s[u-32],u++,s[u]=l^=s[u-32],u++}return s}},wS=class{static{f(this,"PDFBase")}_hash(e,n,r){rn("Abstract method `_hash` called")}checkOwnerPassword(e,n,r,s){let i=new Uint8Array(e.length+56);i.set(e,0),i.set(n,e.length),i.set(r,e.length+n.length);let o=this._hash(e,i,r);return g0(o,s)}checkUserPassword(e,n,r){let s=new Uint8Array(e.length+8);s.set(e,0),s.set(n,e.length);let i=this._hash(e,s,[]);return g0(i,r)}getOwnerKey(e,n,r,s){let i=new Uint8Array(e.length+56);i.set(e,0),i.set(n,e.length),i.set(r,e.length+n.length);let o=this._hash(e,i,r);return new cw(o).decryptBlock(s,!1,new Uint8Array(16))}getUserKey(e,n,r){let s=new Uint8Array(e.length+8);s.set(e,0),s.set(n,e.length);let i=this._hash(e,s,[]);return new cw(i).decryptBlock(r,!1,new Uint8Array(16))}},$N=class extends wS{static{f(this,"PDF17")}_hash(e,n,r){return BN(n,0,n.length)}},VN=class extends wS{static{f(this,"PDF20")}_hash(e,n,r){let s=BN(n,0,n.length).subarray(0,32),i=[0],o=0;for(;o<64||i.at(-1)>o-32;){let a=e.length+s.length+r.length,c=new Uint8Array(a),l=0;c.set(e,l),l+=e.length,c.set(s,l),l+=s.length,c.set(r,l);let u=new Uint8Array(a*64);for(let p=0,m=0;p<64;p++,m+=a)u.set(c,m);i=new xS(s.subarray(0,16)).encrypt(u,s.subarray(16,32));let d=Math.sumPrecise(i.slice(0,16))%3;d===0?s=BN(i,0,i.length):d===1?s=Lge(i,0,i.length):d===2&&(s=IZ(i,0,i.length)),o++}return s.subarray(0,32)}},yS=class{static{f(this,"CipherTransform")}#e=new Map;embeddedFilterName=null;constructor(e,n=null,r=null){this.resolveCipher=e,this.streamFilterName=r,this.stringFilterName=n}#t(e=null){let n=e instanceof ve?e.name:"__default__";return this.#e.getOrInsertComputed(n,()=>this.resolveCipher(e))}createStream(e,n,r=null){let s=this.embeddedFilterName&&_p(e.dict,"EmbeddedFile")?this.embeddedFilterName:this.streamFilterName,i=this.#t(r||s),o=new i;return new HN(e,n,f(function(c,l){return o.decryptBlock(c,l)},"cipherTransformDecryptStream"))}decryptString(e){let n=this.#t(this.stringFilterName),r=new n,s=Sr(e);return s=r.decryptBlock(s,!0),$i(s)}encryptString(e){let n=this.#t(this.stringFilterName),r=new n;if(r instanceof aw){let o=16-e.length%16;e+=String.fromCharCode(o).repeat(o);let a=new Uint8Array(16);crypto.getRandomValues(a);let c=Sr(e);c=r.encrypt(c,a);let l=new Uint8Array(16+c.length);return l.set(a),l.set(c,16),$i(l)}let s=Sr(e);return s=r.encrypt(s),$i(s)}};f(fR,"utf8PasswordToBytes");GN=class t{static{f(this,"CipherTransformFactory")}#e;static get _defaultPasswordBytes(){return ze(this,"_defaultPasswordBytes",new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]))}#t(e,n,r,s,i,o,a,c,l,u,h,d){if(n){let m=Math.min(127,n.length);n=n.subarray(0,m)}else n=[];let p=e===6?new VN:new $N;return p.checkUserPassword(n,c,a)?p.getUserKey(n,l,h):n.length&&p.checkOwnerPassword(n,s,o,r)?p.getOwnerKey(n,i,o,u):null}#n(e,n,r,s,i,o,a,c){let l=40+r.length+e.length,u=new Uint8Array(l),h=0,d,p;if(n)for(p=Math.min(32,n.length);h<p;++h)u[h]=n[h];for(d=0;h<32;)u[h++]=t._defaultPasswordBytes[d++];u.set(r,h),h+=r.length,u[h++]=i&255,u[h++]=i>>8&255,u[h++]=i>>16&255,u[h++]=i>>>24&255,u.set(e,h),h+=e.length,o>=4&&!c&&(u.fill(255,h,h+4),h+=4);let m=$f(u,0,h),g=a>>3;if(o>=3)for(d=0;d<50;++d)m=$f(m,0,g);let b=m.subarray(0,g),x,w;if(o>=3){h=0,u.set(t._defaultPasswordBytes,h),h+=32,u.set(e,h),h+=e.length,x=new wl(b),w=x.encryptBlock($f(u,0,h)),p=b.length;let y=new Uint8Array(p);for(d=1;d<=19;++d){for(let S=0;S<p;++S)y[S]=b[S]^d;x=new wl(y),w=x.encryptBlock(w)}}else x=new wl(b),w=x.encryptBlock(t._defaultPasswordBytes);return w.every((y,S)=>s[S]===y)?b:null}#r(e,n,r,s){let i=new Uint8Array(32),o=0,a=Math.min(32,e.length);for(;o<a;++o)i[o]=e[o];let c=0;for(;o<32;)i[o++]=t._defaultPasswordBytes[c++];let l=$f(i,0,o),u=s>>3;if(r>=3)for(c=0;c<50;++c)l=$f(l,0,l.length);let h,d;if(r>=3){d=n;let p=new Uint8Array(u);for(c=19;c>=0;c--){for(let m=0;m<u;++m)p[m]=l[m]^c;h=new wl(p),d=h.encryptBlock(d)}}else h=new wl(l.subarray(0,u)),d=h.encryptBlock(n);return d}#s(e,n,r,s=!1){let i=r.length,o=new Uint8Array(i+9);o.set(r);let a=i;return o[a++]=e&255,o[a++]=e>>8&255,o[a++]=e>>16&255,o[a++]=n&255,o[a++]=n>>8&255,s&&(o[a++]=115,o[a++]=65,o[a++]=108,o[a++]=84),$f(o,0,a).subarray(0,Math.min(i+5,16))}constructor(e,n,r){let s=e.get("Filter");if(!It(s,"Standard"))throw new xe("unknown encryption method");this.filterName=s.name,this.dict=e,this.#e=n;let i=e.get("V");if(!Number.isInteger(i)||i!==1&&i!==2&&i!==4&&i!==5)throw new xe("unsupported encryption algorithm");this.algorithm=i;let o=e.get("Length");if(!o)if(i<=3)o=40;else{let v=e.get("CF"),A=e.get("StmF");v instanceof Q&&A instanceof ve&&(v.suppressEncryption=!0,o=v.get(A.name)?.get("Length")||128,o<40&&(o<<=3))}if(!Number.isInteger(o)||o<40||o%8!==0)throw new xe("invalid key length");let a=null,c=ve.get("Identity"),l=ve.get("Identity"),u=c;i>=4&&(a=e.get("CF"),a instanceof Q&&(a.suppressEncryption=!0),c=e.get("StmF")||ve.get("Identity"),l=e.get("StrF")||ve.get("Identity"),u=e.get("EFF")||c),this.cf=a,this.stmf=c,this.strf=l,this.eff=u;let h=Sr(e.get("O")),d=Sr(e.get("U")),p=h.subarray(0,32),m=d.subarray(0,32),g=e.get("P"),b=e.get("R"),x=(i===4||i===5)&&e.get("EncryptMetadata")!==!1;this.encryptMetadata=x;let w=Sr(n),y,S;if(r)if(b===6){let v=Xge(r);y=fR(v),v!==r&&(S=fR(r))}else i===5?y=fR(r):y=Sr(r);let k;if(i!==5)k=this.#n(w,y,p,m,g,b,o,x);else{let v=h.subarray(32,40),A=h.subarray(40,48),j=d.subarray(0,48),C=d.subarray(32,40),I=d.subarray(40,48),R=Sr(e.get("OE")),E=Sr(e.get("UE")),P=Sr(e.get("Perms"));for(let F of S?[y,S]:[y])if(k=this.#t(b,F,p,v,A,j,m,C,I,R,E,P),k)break}if(!k){if(!r){if(this.algorithm>=4&&It(this.stmf,"Identity")&&It(this.strf,"Identity")){let j=this.cf?.get(this.eff.name)?.get("AuthEvent");if(It(j,"EFOpen")){this.encryptionKey=null;return}}throw new Ja("No password given",K3.NEED_PASSWORD)}let v=this.#r(y,p,b,o);k=this.#n(w,v,p,m,g,b,o,x)}if(!k)throw new Ja("Incorrect Password",K3.INCORRECT_PASSWORD);i===4&&k.length<16?(this.encryptionKey=new Uint8Array(16),this.encryptionKey.set(k)):this.encryptionKey=k}setPassword(e){let n=new t(this.dict,this.#e,e);this.encryptionKey=n.encryptionKey}createCipherTransform(e,n){if(this.algorithm===4||this.algorithm===5){let s=f(o=>{if(!(o instanceof ve))throw new xe("Invalid crypt filter name.");let c=this.cf.get(o.name)?.get("CFM");if(!c||c.name==="None")return UN;if(!this.encryptionKey)throw new Ja("No password given",K3.NEED_PASSWORD);if(this.algorithm===5||c.name==="AESV3")return cw.bind(null,this.encryptionKey);if(c.name==="V2")return wl.bind(null,this.#s(e,n,this.encryptionKey,!1));if(c.name==="AESV2")return xS.bind(null,this.#s(e,n,this.encryptionKey,!0));throw new xe("Unknown crypto method")},"resolveCipher"),i=new yS(s,this.strf,this.stmf);return i.embeddedFilterName=this.eff,i}let r=f(()=>wl.bind(null,this.#s(e,n,this.encryptionKey,!1)),"resolveCipher");return new yS(r)}},WN=class{static{f(this,"XRef")}#e=new Map;#t=[];#n=null;#r=null;#s=!1;#o=new En;#i=null;#a=new Set;#c=!0;#l=new Set;constructor(e,n){this.stream=e,this.pdfManager=n}getNewPersistentRef(e){this.#n===null&&(this.#n=this.#t.length||1);let n=this.#n++;return this.#e.set(n,e),Se.get(n,0)}getNewTemporaryRef(){if(this.#r===null&&(this.#r=this.#t.length||1,this.#n)){this.#i=new Map;for(let e=this.#r;e<this.#n;e++)this.#i.set(e,this.#e.get(e)),this.#e.delete(e)}return Se.get(this.#r++,0)}resetNewTemporaryRef(){if(this.#r=null,this.#i)for(let[e,n]of this.#i)this.#e.set(e,n);this.#i=null}setStartXRef(e){this.startXRefQueue=[e]}parse(e=!1){this.#s=e;let n;e?(te("Indexing all PDF objects"),n=this.indexObjects()):n=this.readXRef(),n.assignXref(this),this.trailer=n;let r;try{r=n.get("Encrypt")}catch(i){if(i instanceof Un)throw i;te(`XRef.parse - Invalid "Encrypt" reference: "${i}".`)}if(r instanceof Q){let i=n.get("ID"),o=i?.length?i[0]:"";r.suppressEncryption=!0,this.encrypt=new GN(r,o,this.pdfManager.password)}let s;try{s=n.get("Root")}catch(i){if(i instanceof Un)throw i;te(`XRef.parse - Invalid "Root" reference: "${i}".`)}if(s instanceof Q)try{if(s.get("Pages")instanceof Q){this.root=s;return}}catch(i){if(i instanceof Un)throw i;te(`XRef.parse - Invalid "Pages" reference: "${i}".`)}throw e?new m0("Invalid Root reference."):new kl}processXRefTable(e){this._tableState??={entryNum:0,streamPos:e.lexer.stream.pos,parserBuf1:e.buf1,parserBuf2:e.buf2};let n=this.readXRefTable(e);if(!Bs(n,"trailer"))throw new xe("Invalid XRef table: could not find trailer dictionary");let r=e.getObj();if(r instanceof kt&&(r=r.dict),!(r instanceof Q))throw new xe("Invalid XRef table: could not parse trailer dictionary");return delete this._tableState,r}readXRefTable(e){let n=e.lexer.stream,r=this._tableState;n.pos=r.streamPos,e.buf1=r.parserBuf1,e.buf2=r.parserBuf2;let s;for(;;){if(!("firstEntryNum"in r)||!("entryCount"in r)){if(Bs(s=e.getObj(),"trailer"))break;r.firstEntryNum=s,r.entryCount=e.getObj()}let i=r.firstEntryNum,o=r.entryCount;if(!Number.isInteger(i)||!Number.isInteger(o))throw new xe("Invalid XRef table: wrong types in subsection header");for(let a=r.entryNum;a<o;a++){r.streamPos=n.pos,r.entryNum=a,r.parserBuf1=e.buf1,r.parserBuf2=e.buf2;let c={offset:e.getObj(),gen:e.getObj(),free:!1,uncompressed:!1},l=e.getObj();if(l instanceof ms)switch(l.cmd){case"f":c.free=!0;break;case"n":c.uncompressed=!0;break}if(!Number.isInteger(c.offset)||!Number.isInteger(c.gen)||!(c.free||c.uncompressed))throw new xe(`Invalid entry in XRef subsection: ${i}, ${o}`);a===0&&c.free&&i===1&&(i=0),this.#t[i+a]??=c}r.entryNum=0,r.streamPos=n.pos,r.parserBuf1=e.buf1,r.parserBuf2=e.buf2,delete r.firstEntryNum,delete r.entryCount}if(this.#t[0]&&!this.#t[0].free)throw new xe("Invalid XRef table: unexpected first object");return s}processXRefStream(e){if(!("streamState"in this)){let{dict:n,pos:r}=e,s=n.get("W"),i=n.get("Index")||[0,n.get("Size")];this.streamState={entryRanges:i,byteWidths:s,entryNum:0,streamPos:r}}return this.readXRefStream(e),delete this.streamState,e.dict}readXRefStream(e){let n=this.streamState;e.pos=n.streamPos;let[r,s,i]=n.byteWidths,o=n.entryRanges;for(;o.length>0;){let[a,c]=o;if(!Number.isInteger(a)||!Number.isInteger(c))throw new xe(`Invalid XRef range fields: ${a}, ${c}`);if(!Number.isInteger(r)||!Number.isInteger(s)||!Number.isInteger(i))throw new xe(`Invalid XRef entry fields length: ${a}, ${c}`);for(let l=n.entryNum;l<c;++l){n.entryNum=l,n.streamPos=e.pos;let u=0,h=0,d=0;for(let m=0;m<r;++m){let g=e.getByte();if(g===-1)throw new xe("Invalid XRef byteWidths 'type'.");u=u<<8|g}r===0&&(u=1);for(let m=0;m<s;++m){let g=e.getByte();if(g===-1)throw new xe("Invalid XRef byteWidths 'offset'.");h=h<<8|g}for(let m=0;m<i;++m){let g=e.getByte();if(g===-1)throw new xe("Invalid XRef byteWidths 'generation'.");d=d<<8|g}let p={offset:h,gen:d,free:!1,uncompressed:!1};switch(u){case 0:p.free=!0;break;case 1:p.uncompressed=!0;break;case 2:break;default:throw new xe(`Invalid XRef entry type: ${u}`)}this.#t[a+l]??=p}n.entryNum=0,n.streamPos=e.pos,o.splice(0,2)}}indexObjects(){function a(I,R){let E="",P=I[R];for(;P!==10&&P!==13&&P!==60&&!(++R>=I.length);)E+=String.fromCharCode(P),P=I[R];return E}f(a,"readToken");function c(I,R,E){let P=E.length,F=I.length,_=0;for(;R<F;){let B=0;for(;B<P&&I[R+B]===E[B];)++B;if(B>=P)break;R++,_++}return _}f(c,"skipUntil");let l=/\b(endobj|\d+\s+\d+\s+obj|xref|trailer\s*<<)\b/g,u=/\b(startxref|\d+\s+\d+\s+obj)\b/g,h=/^(\d+)\s+(\d+)\s+obj\b/,d=new Uint8Array([116,114,97,105,108,101,114]),p=new Uint8Array([115,116,97,114,116,120,114,101,102]),m=new Uint8Array([47,88,82,101,102]);this.#t.length=0,this.#e.clear();let g=this.stream;g.pos=0;let b=g.getBytes(),x=$i(b),w=b.length,y=g.start,S=[],k=[];for(;y<w;){let I=b[y];if(I===9||I===10||I===13||I===32){++y;continue}if(I===37){do{if(++y,y>=w)break;I=b[y]}while(I!==10&&I!==13);continue}let R=a(b,y),E;if(R.startsWith("xref")&&(R.length===4||/\s/.test(R[4])))y+=c(b,y,d),S.push(y),y+=c(b,y,p);else if(E=h.exec(R)){let P=E[1]|0,F=E[2]|0,_=y+R.length,B,W=!1;if(!this.#t[P])W=!0;else if(this.#t[P].gen===F)try{new qc({lexer:new Vo(g.makeSubStream(_))}).getObj(),W=!0}catch(ee){ee instanceof Sx?te(`indexObjects -- checking object (${R}): "${ee}".`):W=!0}W&&(this.#t[P]={offset:y-g.start,gen:F,free:!1,uncompressed:!0}),l.lastIndex=_;let Y=l.exec(x);Y?(B=l.lastIndex+1-y,Y[1]!=="endobj"&&(te(`indexObjects: Found "${Y[1]}" inside of another "obj", caused by missing "endobj" -- trying to recover.`),B-=Y[1].length+1)):B=w-y;let K=b.subarray(y,y+B),U=c(K,0,m);U<B&&K[U+5]<64&&(k.push(y-g.start),this.#l.add(y-g.start)),y+=B}else if(R.startsWith("trailer")&&(R.length===7||/\s/.test(R[7]))){S.push(y);let P=y+R.length,F;u.lastIndex=P;let _=u.exec(x);_?(F=u.lastIndex+1-y,_[1]!=="startxref"&&(te(`indexObjects: Found "${_[1]}" after "trailer", caused by missing "startxref" -- trying to recover.`),F-=_[1].length+1)):F=w-y,y+=F}else y+=R.length+1}for(let I of k)this.startXRefQueue.push(I),this.readXRef(!0);let v=[],A=!1;for(let I of S){g.pos=I;let R=new qc({lexer:new Vo(g),xref:this,allowStreams:!0,recoveryMode:!0}),E=R.getObj();if(!Bs(E,"trailer"))continue;let P=R.getObj();P instanceof Q&&(v.push(P),P.has("Encrypt")&&(A=!0))}let j,C;for(let I of[...v,"genFallback",...v]){if(I==="genFallback"){if(!C)break;this._generationFallback=!0;continue}let R=!1;try{let E=I.get("Root");if(!(E instanceof Q))continue;let P=E.get("Pages");if(!(P instanceof Q))continue;let F=P.get("Count");Number.isInteger(F)&&(R=!0)}catch(E){C=E;continue}if(R&&(!A||I.has("Encrypt"))&&I.has("ID"))return I;j=I}if(j)return j;if(this.topDict)return this.topDict;if(!v.length)for(let I in this.#t){let R=this.#t[I];if(!R)continue;let E=Se.get(parseInt(I,10),R.gen),P;try{P=this.fetch(E)}catch{continue}if(P instanceof kt&&(P=P.dict),P instanceof Q&&P.has("Root"))return P}throw new m0("Invalid PDF structure.")}readXRef(e=!1){let n=this.stream,r=new Set;for(;this.startXRefQueue.length;){try{let s=this.startXRefQueue[0];if(r.has(s)){te("readXRef - skipping XRef table since it was already parsed."),this.startXRefQueue.shift();continue}r.add(s),n.pos=s+n.start;let i=new qc({lexer:new Vo(n),xref:this,allowStreams:!0}),o=i.getObj(),a;if(Bs(o,"xref"))a=this.processXRefTable(i),this.topDict||=a,o=a.get("XRefStm"),Number.isInteger(o)&&!this.#l.has(o)&&(this.#l.add(o),this.startXRefQueue.push(o));else if(Number.isInteger(o)){if(!Number.isInteger(i.getObj())||!Bs(i.getObj(),"obj")||!((o=i.getObj())instanceof kt))throw new xe("Invalid XRef stream");if(a=this.processXRefStream(o),this.topDict||=a,!a)throw new xe("Failed to read XRef stream")}else throw new xe("Invalid XRef stream header");this.#a.add(s),o=a.get("Prev"),Number.isInteger(o)?this.startXRefQueue.push(o):o instanceof Se&&this.startXRefQueue.push(o.num)}catch(s){if(s instanceof Un)throw s;this.#c=!1,Cn("(while reading XRef): "+s)}this.startXRefQueue.shift()}if(this.topDict)return this.topDict;if(!e)throw new kl}countUpdatesAfter(e){if(this.#s||!this.#c)return null;let n=e-this.stream.start,r=0;for(let s of this.#a)s>=n&&!this.#l.has(s)&&r++;return r}getEntry(e){let n=this.#t[e];return n&&!n.free&&n.offset?n:null}fetchIfRef(e,n=!1){return e instanceof Se?this.fetch(e,n):e}fetch(e,n=!1){if(!(e instanceof Se))throw new Error("ref object is not a reference");let r=e.num,s=this.#e.get(r);if(s!==void 0)return s instanceof Q&&!s.objId&&(s.objId=e.toString()),s;let i=this.getEntry(r);if(i===null)return i;if(this.#o.has(e))return this.#o.remove(e),te(`Ignoring circular reference: ${e}.`),E0e;this.#o.put(e);try{i=i.uncompressed?this.fetchUncompressed(e,i,n):this.fetchCompressed(e,i,n),this.#o.remove(e)}catch(o){throw this.#o.remove(e),o}return i instanceof Q?i.objId=e.toString():i instanceof kt&&(i.dict.objId=e.toString()),i}fetchUncompressed(e,n,r=!1){let s=e.gen,i=e.num;if(n.gen!==s){let h=`Inconsistent generation in XRef: ${e}`;if(this._generationFallback&&n.gen<s)return te(h),this.fetchUncompressed(Se.get(i,n.gen),n,r);throw new Fc(h)}let o=this.stream.makeSubStream(n.offset+this.stream.start),a=new qc({lexer:new Vo(o),xref:this,allowStreams:!0}),c=a.getObj(),l=a.getObj(),u=a.getObj();if(c!==i||l!==s||!(u instanceof ms))throw new Fc(`Bad (uncompressed) XRef entry: ${e}`);if(u.cmd!=="obj"){if(u.cmd.startsWith("obj")&&(i=parseInt(u.cmd.substring(3),10),!Number.isNaN(i)))return i;throw new Fc(`Bad (uncompressed) XRef entry: ${e}`)}return n=this.encrypt&&!r?a.getObj(this.encrypt.createCipherTransform(i,s)):a.getObj(),n instanceof kt||this.#e.set(i,n),n}fetchCompressed(e,n,r=!1){let s=n.offset,i=this.fetch(Se.get(s,0));if(!(i instanceof kt))throw new xe("bad ObjStm stream");let o=i.dict.get("First"),a=i.dict.get("N");if(!Number.isInteger(o)||!Number.isInteger(a))throw new xe("invalid first and n parameters for ObjStm stream");let c=new qc({lexer:new Vo(i),xref:this,allowStreams:!0}),l=new Array(a),u=new Array(a);for(let p=0;p<a;++p){let m=c.getObj();if(!Number.isInteger(m))throw new xe(`invalid object number in the ObjStm stream: ${m}`);let g=c.getObj();if(!Number.isInteger(g))throw new xe(`invalid object offset in the ObjStm stream: ${g}`);l[p]=m;let b=this.getEntry(m);b?.offset===s&&b.gen!==p&&(b.gen=p),u[p]=g}let h=(i.start||0)+o,d=new Array(a);for(let p=0;p<a;++p){let m=p<a-1?u[p+1]-u[p]:void 0;if(m<0)throw new xe("Invalid offset in the ObjStm stream.");c=new qc({lexer:new Vo(i.makeSubStream(h+u[p],m,i.dict)),xref:this,allowStreams:!0});let g=c.getObj();if(d[p]=g,g instanceof kt)continue;let b=l[p],x=this.#t[b];x&&x.offset===s&&x.gen===p&&this.#e.set(b,g)}if(n=d[n.gen],n===void 0)throw new Fc(`Bad (compressed) XRef entry: ${e}`);return n}async fetchIfRefAsync(e,n){return e instanceof Se?this.fetchAsync(e,n):e}async fetchAsync(e,n){try{return this.fetch(e,n)}catch(r){if(!(r instanceof Un))throw r;return await this.pdfManager.requestRange(r.begin,r.end),this.fetchAsync(e,n)}}getCatalogObj(){return this.root}},RZ=[0,0,612,792],pJ=65536,vS=class{static{f(this,"Page")}#e=null;constructor({pdfManager:e,xref:n,pageIndex:r,pageDict:s,ref:i,globalIdFactory:o,fontCache:a,builtInCMapCache:c,standardFontDataCache:l,globalColorSpaceCache:u,globalImageCache:h,systemFontCache:d,nonBlendModesSet:p,xfaFactory:m}){this.pdfManager=e,this.pageIndex=r,this.pageDict=s,this.xref=n,this.ref=i,this.fontCache=a,this.builtInCMapCache=c,this.standardFontDataCache=l,this.globalColorSpaceCache=u,this.globalImageCache=h,this.systemFontCache=d,this.nonBlendModesSet=p,this.evaluatorOptions=e.evaluatorOptions,this.xfaFactory=m;let g={obj:0};this._localIdFactory=class extends o{static createObjId(){return`p${r}_${++g.obj}`}static getPageObjId(){return`p${i.toString()}`}}}_createPartialEvaluator(e,n=this.pageIndex){return new Lx({xref:this.xref,handler:e,pageIndex:n,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalColorSpaceCache:this.globalColorSpaceCache,globalImageCache:this.globalImageCache,systemFontCache:this.systemFontCache,options:this.evaluatorOptions})}#t(e,n=!1){let r=ei({dict:this.pageDict,key:e,getArray:n,stopWhenFound:!1});return Array.isArray(r)?r.length===1||!(r[0]instanceof Q)?r[0]:Q.merge({xref:this.xref,dictArray:r}):r}get content(){return this.pageDict.getArray("Contents")}get resources(){let e=this.#t("Resources");return ze(this,"resources",e instanceof Q?e:Q.empty)}getBoundingBox(e){if(this.xfaData)return this.xfaData.bbox;let n=zc(this.#t(e,!0),null);if(n){if(n[2]-n[0]>0&&n[3]-n[1]>0)return n;te(`Empty, or invalid, /${e} entry.`)}return null}get mediaBox(){return ze(this,"mediaBox",this.getBoundingBox("MediaBox")||RZ)}get cropBox(){return ze(this,"cropBox",this.getBoundingBox("CropBox")||this.mediaBox)}get userUnit(){let e=this.pageDict.get("UserUnit");return ze(this,"userUnit",typeof e=="number"&&e>0?e:1)}get view(){let{cropBox:e,mediaBox:n}=this;if(e!==n&&!g0(e,n)){let r=pn.intersect(e,n);if(r&&r[2]-r[0]>0&&r[3]-r[1]>0)return ze(this,"view",r);te("Empty /CropBox and /MediaBox intersection.")}return ze(this,"view",n)}get rotate(){let e=this.#t("Rotate")||0;return e%90!==0?e=0:e>=360?e%=360:e<0&&(e=(e%360+360)%360),ze(this,"rotate",e)}#n(e,n){if(this.evaluatorOptions.ignoreErrors){te(`getContentStream - ignoring sub-stream (${n}): "${e}".`);return}throw e}async getContentStream(){let e=await this.pdfManager.ensure(this,"content");if(e instanceof kt&&!e.isImageStream){if(e.isAsync){let n=await e.asyncGetBytes();if(n)return new Jn(n,0,n.length,e.dict)}return e}if(Array.isArray(e)){let n=[];for(let r=0,s=e.length;r<s;r++){let i=e[r];i instanceof kt&&i.isAsync&&n.push(i.asyncGetBytes().then(o=>{o&&(e[r]=new Jn(o,0,o.length,i.dict))}))}return n.length>0&&await Promise.all(n),new qR(e,this.#n.bind(this))}return new jx}get xfaData(){return ze(this,"xfaData",this.xfaFactory?{bbox:this.xfaFactory.getBoundingBox(this.pageIndex)}:null)}async#r(e,n,r){let s=[];for(let i of e){if(!i.id)continue;let o=Se.fromString(i.id);if(!o){te(`A non-linked annotation cannot be modified: ${i.id}`);continue}if(i.deleted){if(n.put(o),i.popupRef){let a=Se.fromString(i.popupRef);a&&n.put(a)}continue}if(i.popup?.deleted){let a=Se.fromString(i.popupRef);a&&n.put(a)}r?.put(o),i.ref=o,s.push(this.xref.fetchAsync(o).then(a=>{a instanceof Q&&(i.oldAnnotation=a.clone())},()=>{te(`Cannot fetch \`oldAnnotation\` for: ${o}.`)})),delete i.id}await Promise.all(s)}async saveNewAnnotations(e,n,r,s,i){if(this.xfaFactory)throw new Error("XFA: Cannot save new annotations.");let o=this._createPartialEvaluator(e),a=new En,c=new En;await this.#r(r,a,c);let l=this.pageDict,u=this.annotations.filter(p=>!(p instanceof Se&&a.has(p))),h=await Wo.saveNewAnnotations(o,this.xref,n,r,s,i);for(let{ref:p}of h.annotations)p instanceof Se&&!c.has(p)&&u.push(p);let d=l.clone();d.set("Annots",u),i.put(this.ref,{data:d});for(let p of a)i.put(p,{data:null})}async save(e,n,r,s){let i=this._createPartialEvaluator(e),o=await this._parsedAnnotations,a=[];for(let c of o)a.push(c.save(i,n,r,s).catch(function(l){return te(`save - ignoring annotation data during "${n.name}" task: "${l}".`),null}));return Promise.all(a)}async loadResources(e){await(this.#e??=this.pdfManager.ensure(this,"resources")),await Kp.load(this.resources,e,this.xref)}async#s(e,n){let r=e?.get("Resources");return r instanceof Q&&r.size?(await Kp.load(r,n,this.xref),Q.merge({xref:this.xref,dictArray:[r,this.resources],mergeSubDicts:!0})):this.resources}async getOperatorList({handler:e,sink:n,task:r,intent:s,cacheKey:i,pageIndex:o=this.pageIndex,annotationStorage:a=null,modifiedIds:c=null}){let l=this.getContentStream(),u=this.loadResources(gR),h=this._createPartialEvaluator(e,o),p=(this.xfaFactory?null:aM(a))?.get(this.pageIndex),m=Promise.resolve(null),g=null;if(p){let P=this.pdfManager.ensureDoc("annotationGlobals"),F,_=new Set;for(let{bitmapId:W,bitmap:Y}of p)W&&!Y&&!_.has(W)&&_.add(W);let{isOffscreenCanvasSupported:B}=this.evaluatorOptions;if(_.size>0){let W=p.slice();for(let[Y,K]of a)Y.startsWith(xJ)&&K.bitmap&&_.has(K.bitmapId)&&W.push(K);F=Wo.generateImages(W,this.xref,B)}else F=Wo.generateImages(p,this.xref,B);g=new En,m=Promise.all([P,this.#r(p,g,null)]).then(([W])=>W?Wo.printNewAnnotations(W,h,r,p,F):null)}let b=Promise.all([l,u]).then(async([P])=>{let F=await this.#s(P.dict,gR),_=new Ko(s,n);return e.send("StartRenderPage",{transparency:h.hasBlendModes(F,this.nonBlendModesSet),pageIndex:o,cacheKey:i}),await h.getOperatorList({stream:P,task:r,resources:F,operatorList:_}),_}),[x,w,y]=await Promise.all([b,this._parsedAnnotations,m]);if(y){w=w.filter(P=>!(P.ref&&g.has(P.ref)));for(let P=0,F=y.length;P<F;P++){let _=y[P];if(_.refToReplace){let B=w.findIndex(W=>W.ref&&Bp(W.ref,_.refToReplace));B>=0&&(w.splice(B,1,_),y.splice(P--,1),F--)}}w=w.concat(y)}if(w.length===0||s&Qs.ANNOTATIONS_DISABLE)return x.flush(!0),{length:x.totalLength};let S=!!(s&Qs.ANNOTATIONS_FORMS),k=!!(s&Qs.IS_EDITING),v=!!(s&Qs.ANY),A=!!(s&Qs.DISPLAY),j=!!(s&Qs.PRINT),C=[];for(let P of w)(v||A&&P.mustBeViewed(a,S)&&P.mustBeViewedWhenEditing(k,c)||j&&P.mustBePrinted(a))&&C.push(P.getOperatorList(h,r,s,a).catch(function(F){return te(`getOperatorList - ignoring annotation data during "${r.name}" task: "${F}".`),{opList:null,separateForm:!1,separateCanvas:!1}}));let I=await Promise.all(C),R=!1,E=!1;for(let{opList:P,separateForm:F,separateCanvas:_}of I)x.addOpList(P),R||=F,E||=_;return x.flush(!0,{form:R,canvas:E}),{length:x.totalLength}}async extractTextContent({handler:e,task:n,includeMarkedContent:r,disableNormalization:s,sink:i,intersector:o=null}){let a=this.getContentStream(),c=this.loadResources(bR),l=this.pdfManager.ensureCatalog("lang"),[u,,h]=await Promise.all([a,c,l]),d=await this.#s(u.dict,bR);return this._createPartialEvaluator(e).getTextContent({stream:u,task:n,resources:d,includeMarkedContent:r,disableNormalization:s,sink:i,viewBox:this.view,lang:h,intersector:o})}async getStructTree(){let e=await this.pdfManager.ensureCatalog("structTreeRoot");if(!e)return null;await this._parsedAnnotations;try{let n=await this.pdfManager.ensure(this,"_parseStructTree",[e]);return await this.pdfManager.ensure(n,"serializable")}catch(n){return te(`getStructTree: "${n}".`),null}}_parseStructTree(e){let n=new G5(e,this.pageDict);return n.parse(this.ref),n}async getAnnotationsData(e,n,r){let s=await this._parsedAnnotations;if(s.length===0)return s;let i=[],o=[],a,c=!!(r&Qs.ANY),l=!!(r&Qs.DISPLAY),u=!!(r&Qs.PRINT),h=[];for(let d of s){let p=c||l&&d.viewable;(p||u&&d.printable)&&i.push(d.data),d.hasTextContent&&p?(a??=this._createPartialEvaluator(e),o.push(d.extractTextContent(a,n,[-1/0,-1/0,1/0,1/0]).catch(function(m){te(`getAnnotationsData - ignoring textContent during "${n.name}" task: "${m}".`)}))):d.overlaysTextContent&&p&&h.push(d)}if(h.length>0){let d=new _N(h);o.push(this.extractTextContent({handler:e,task:n,includeMarkedContent:!1,disableNormalization:!1,sink:null,intersector:d}).then(()=>{d.setText()}))}return await Promise.all(o),i}get annotations(){let e=this.#t("Annots");return ze(this,"annotations",Array.isArray(e)?e:[])}get _parsedAnnotations(){let e=this.pdfManager.ensure(this,"annotations").then(async n=>{if(n.length===0)return n;let[r,s]=await Promise.all([this.pdfManager.ensureDoc("annotationGlobals"),this.pdfManager.ensureDoc("fieldObjects")]);if(!r)return[];let i=s?.orphanFields,o=[];for(let u of n)o.push(Wo.create(this.xref,u,r,this._localIdFactory,!1,i,null,this.ref).catch(function(h){return te(`_parsedAnnotations: "${h}".`),null}));let a=[],c,l;for(let u of await Promise.all(o))if(u){if(u instanceof Bc){(l||=[]).push(u);continue}if(u instanceof ow){(c||=[]).push(u);continue}a.push(u)}return l&&a.push(...l),c&&a.push(...c),a});return ze(this,"_parsedAnnotations",e)}get jsActions(){let e=CS(this.xref,this.pageDict,v0e);return ze(this,"jsActions",e)}async collectAnnotationsByType(e,n,r,s,i){let{pageIndex:o}=this;if(Object.hasOwn(this,"_parsedAnnotations")){let l=await this._parsedAnnotations;for(let{data:u}of l)(!r||r.has(u.annotationType))&&(u.pageIndex=o,s.push(Promise.resolve(u)));return}let a=await this.pdfManager.ensure(this,"annotations"),c;for(let l of a)s.push(Wo.create(this.xref,l,i,this._localIdFactory,!1,null,r,this.ref).then(async u=>u?(u.data.pageIndex=o,u.hasTextContent&&u.viewable&&(c??=this._createPartialEvaluator(e),await u.extractTextContent(c,n,[-1/0,-1/0,1/0,1/0])),u.data):null).catch(function(u){return te(`collectAnnotationsByType: "${u}".`),null}))}},mJ=new Uint8Array([37,80,68,70,45]),gJ=new Uint8Array([115,116,97,114,116,120,114,101,102]),Yge=new Uint8Array([101,110,100,111,98,106]);f(uR,"find");SS=class{static{f(this,"PDFDocument")}#e=new Map;#t=null;#n=null;constructor(e,n){if(n.length<=0)throw new m0("The PDF file is empty, i.e. its size is zero bytes.");this.pdfManager=e,this.stream=n,this.xref=new WN(n,e);let r={font:0};this._globalIdFactory=class{static getDocId(){return`g_${e.docId}`}static createFontId(){return`f${++r.font}`}static createObjId(){rn("Abstract method `createObjId` called.")}static getPageObjId(){rn("Abstract method `getPageObjId` called.")}}}parse(e){this.xref.parse(e),this.catalog=new Hx(this.pdfManager,this.xref)}get linearization(){let e=null;try{e=XR.create(this.stream)}catch(n){if(n instanceof Un)throw n;Cn(n)}return ze(this,"linearization",e)}get startXRef(){let e=this.stream,n=0;if(this.linearization){if(e.reset(),uR(e,Yge)){e.skip(6);let r=e.peekByte();for(;ka(r);)e.pos++,r=e.peekByte();n=e.pos-e.start}}else{let s=gJ.length,i=!1,o=e.end;for(;!i&&o>0;)o-=1024-s,o<0&&(o=0),e.pos=o,i=uR(e,gJ,1024,!0);if(i){e.skip(9);let a;do a=e.getByte();while(ka(a));let c="";for(;a>=32&&a<=57;)c+=String.fromCharCode(a),a=e.getByte();n=parseInt(c,10),isNaN(n)&&(n=0)}}return ze(this,"startXRef",n)}checkHeader(){let e=this.stream;if(e.reset(),!uR(e,mJ))return;e.moveStart(),e.skip(mJ.length);let n="",r;for(;(r=e.getByte())>32&&n.length<7;)n+=String.fromCharCode(r);TJ.test(n)?this.#n=n:te(`Invalid PDF header version: ${n}`)}parseStartXRef(){this.xref.setStartXRef(this.startXRef)}get numPages(){let e=0;return this.catalog.hasActualNumPages?e=this.catalog.numPages:this.xfaFactory?e=this.xfaFactory.getNumPages():this.linearization?e=this.linearization.numPages:e=this.catalog.numPages,ze(this,"numPages",e)}#r(e,n=0){return Array.isArray(e)?e.every(s=>{if(s=this.xref.fetchIfRef(s),!(s instanceof Q))return!1;if(s.has("Kids"))return++n>10?(te("#hasOnlyDocumentSignatures: maximum recursion depth reached"),!1):this.#r(s.get("Kids"),n);let i=It(ei({dict:s,key:"FT"}),"Sig"),o=s.get("Rect"),a=Array.isArray(o)&&o.every(c=>c===0);return i&&a}):!1}get _xfaStreams(){let{acroForm:e}=this.catalog;if(!e)return null;let n=e.get("XFA"),r=new Map(["xdp:xdp","template","datasets","config","connectionSet","localeSet","stylesheet","/xdp:xdp"].map(s=>[s,null]));if(n instanceof kt&&!n.isEmpty)return r.set("xdp:xdp",n),r;if(!Array.isArray(n)||n.length===0)return null;for(let s=0,i=n.length;s<i;s+=2){let o;if(s===0?o="xdp:xdp":s===i-2?o="/xdp:xdp":o=n[s],!r.has(o))continue;let a=this.xref.fetchIfRef(n[s+1]);!(a instanceof kt)||a.isEmpty||r.set(o,a)}return r}get xfaDatasets(){let e=this._xfaStreams;if(!e)return ze(this,"xfaDatasets",null);for(let n of["datasets","xdp:xdp"]){let r=e.get(n);if(r)try{let s=Lp(r.getString()),i={[n]:s};return ze(this,"xfaDatasets",new zN(i))}catch{te("XFA - Invalid utf-8 string.");break}}return ze(this,"xfaDatasets",null)}get xfaData(){let e=this._xfaStreams;if(!e)return null;let n=new Map;for(let[r,s]of e)if(s)try{n.set(r,Lp(s.getString()))}catch{return te("XFA - Invalid utf-8 string."),null}return n}get xfaFactory(){let e;return this.pdfManager.enableXfa&&this.catalog.needsRendering&&this.formInfo.hasXfa&&!this.formInfo.hasAcroForm&&(e=this.xfaData),ze(this,"xfaFactory",e?new iw(e):null)}get isPureXfa(){return this.xfaFactory?this.xfaFactory.isValid():!1}get htmlForXfa(){return this.xfaFactory?this.xfaFactory.getPages():null}async#s(){let e=await this.pdfManager.ensureCatalog("xfaImages");e&&this.xfaFactory.setImages(e)}async#o(e,n){let r=await this.pdfManager.ensureCatalog("acroForm");if(!r)return;let s=await r.getAsync("DR");if(!(s instanceof Q))return;await Kp.load(s,["Font"],this.xref);let i=s.get("Font");if(!(i instanceof Q))return;let o=Object.assign(Object.create(null),this.pdfManager.evaluatorOptions,{useSystemFonts:!1}),{builtInCMapCache:a,fontCache:c,standardFontDataCache:l}=this.catalog,u=new Lx({xref:this.xref,handler:e,pageIndex:-1,idFactory:this._globalIdFactory,fontCache:c,builtInCMapCache:a,standardFontDataCache:l,options:o}),h=new Ko,d=[],p={get font(){return d.at(-1)},set font(w){d.push(w)},clone(){return this}},m=f((w,y,S)=>u.handleSetFont(s,[ve.get(w),1],null,h,n,p,y,S).catch(k=>(te(`loadXfaFonts: "${k}".`),null)),"parseFont"),g=[];for(let[w,y]of i){let S=y.get("FontDescriptor");if(!(S instanceof Q))continue;let k=H0e(S.get("FontFamily")),v=S.get("FontWeight"),A=-S.get("ItalicAngle"),j={fontFamily:k,fontWeight:v,italicAngle:A};U0e(j)&&g.push(m(w,null,j))}await Promise.all(g);let b=this.xfaFactory.setFonts(d);if(!b)return;o.ignoreErrors=!0,g.length=0,d.length=0;let x=new Set;for(let w of b)hM(`${w}-Regular`)||x.add(w);x.size&&b.push("PdfJS-Fallback");for(let w of b)if(!x.has(w))for(let y of[{name:"Regular",fontWeight:400,italicAngle:0},{name:"Bold",fontWeight:700,italicAngle:0},{name:"Italic",fontWeight:400,italicAngle:12},{name:"BoldItalic",fontWeight:700,italicAngle:12}]){let S=`${w}-${y.name}`;g.push(m(S,tZ(S),{fontFamily:w,fontWeight:y.fontWeight,italicAngle:y.italicAngle}))}await Promise.all(g),this.xfaFactory.appendFonts(d,x)}loadXfaResources(e,n){return Promise.all([this.#o(e,n).catch(()=>{}),this.#s()])}serializeXfaData(e){return this.xfaFactory?this.xfaFactory.serializeData(e):null}get version(){return this.catalog.version||this.#n}get formInfo(){let e={hasFields:!1,hasAcroForm:!1,hasXfa:!1,hasSignatures:!1},{acroForm:n}=this.catalog;if(!n)return ze(this,"formInfo",e);try{let r=n.get("Fields"),s=Array.isArray(r)&&r.length>0;e.hasFields=s;let i=n.get("XFA");e.hasXfa=Array.isArray(i)&&i.length>0||i instanceof kt&&!i.isEmpty;let a=!!(n.get("SigFlags")&1),c=a&&this.#r(r);e.hasAcroForm=s&&!c,e.hasSignatures=a}catch(r){if(r instanceof Un)throw r;te(`Cannot fetch form information: "${r}".`)}return ze(this,"formInfo",e)}get documentInfo(){let{catalog:e,formInfo:n,xref:r}=this,s={PDFFormatVersion:this.version,Language:e.lang,EncryptFilterName:r.encrypt?.filterName??null,IsLinearized:!!this.linearization,IsAcroFormPresent:n.hasAcroForm,IsXFAPresent:n.hasXfa,IsCollectionPresent:!!e.collection,IsSignaturesPresent:n.hasSignatures},i;try{i=r.trailer.get("Info")}catch(o){if(o instanceof Un)throw o;Cn("The document information dictionary is invalid.")}if(!(i instanceof Q))return ze(this,"documentInfo",s);for(let[o,a]of i){switch(o){case"Title":case"Author":case"Subject":case"Keywords":case"Creator":case"Producer":case"CreationDate":case"ModDate":if(typeof a=="string"){s[o]=Ht(a);continue}break;case"Trapped":if(a instanceof ve){s[o]=a;continue}break;default:let c;switch(typeof a){case"string":c=Ht(a);break;case"number":case"boolean":c=a;break;default:if(a instanceof ve){c=a;break}te(`Bad value, for custom key "${o}", in Info: ${a}.`);continue}(s.Custom??=new Map).set(o,c);continue}te(`Bad value, for key "${o}", in Info: ${a}.`)}return ze(this,"documentInfo",s)}get fingerprints(){let n="\0".repeat(16);function r(a){return typeof a=="string"&&a.length===16&&a!==n}f(r,"validate");let s=this.xref.trailer.get("ID"),i,o;return Array.isArray(s)&&r(s[0])?(i=Sr(s[0]),s[1]!==s[0]&&r(s[1])&&(o=Sr(s[1]))):i=$f(this.stream.getByteRange(0,1024),0,1024),ze(this,"fingerprints",[i.toHex(),o?.toHex()??null])}async#i(e){let{catalog:n,linearization:r,xref:s}=this,i=Se.get(r.objectNumberFirst,0);try{let o=await s.fetchAsync(i);if(o instanceof Q){let a=o.getRaw("Type");if(a instanceof Se&&(a=await s.fetchAsync(a)),It(a,"Page")||!o.has("Type")&&!o.has("Kids")&&o.has("Contents"))return n.pageKidsCountCache.has(i)||n.pageKidsCountCache.put(i,1),n.pageIndexCache.has(i)||n.pageIndexCache.put(i,0),[o,i]}throw new xe("The Linearization dictionary doesn't point to a valid Page dictionary.")}catch(o){return te(`_getLinearizationPage: "${o.message}".`),n.getPageDict(e)}}getPage(e){let n=this.#e.get(e);if(n)return n;let{catalog:r,linearization:s,xfaFactory:i}=this,o;return i?o=Promise.resolve([Q.empty,null]):s?.pageFirst===e?o=this.#i(e):o=r.getPageDict(e),o=o.then(([a,c])=>new vS({pdfManager:this.pdfManager,xref:this.xref,pageIndex:e,pageDict:a,ref:c,globalIdFactory:this._globalIdFactory,fontCache:r.fontCache,builtInCMapCache:r.builtInCMapCache,standardFontDataCache:r.standardFontDataCache,globalColorSpaceCache:r.globalColorSpaceCache,globalImageCache:r.globalImageCache,systemFontCache:r.systemFontCache,nonBlendModesSet:r.nonBlendModesSet,xfaFactory:i})),this.#e.set(e,o),o}async checkFirstPage(e=!1){if(!e)try{await this.getPage(0)}catch(n){if(n instanceof Fc)throw this.#e.delete(0),await this.cleanup(),new kl}}async checkLastPage(e=!1){let{catalog:n,pdfManager:r}=this;n.setActualNumPages();let s;try{if(await Promise.all([r.ensureDoc("xfaFactory"),r.ensureDoc("linearization"),r.ensureCatalog("numPages")]),this.xfaFactory)return;if(this.linearization?s=this.linearization.numPages:s=n.numPages,Number.isInteger(s)){if(s<=1)return}else throw new xe("Page count is not an integer.");await this.getPage(s-1)}catch(i){if(this.#e.delete(s-1),await this.cleanup(),i instanceof Fc&&!e)throw new kl;te(`checkLastPage - invalid /Pages tree /Count: ${s}.`);let o;try{o=await n.getAllPageDicts(e)}catch(a){if(a instanceof Fc&&!e)throw new kl;n.setActualNumPages(1);return}for(let[a,[c,l]]of o){let u;c instanceof Error?(u=Promise.reject(c),u.catch(()=>{})):u=Promise.resolve(new vS({pdfManager:r,xref:this.xref,pageIndex:a,pageDict:c,ref:l,globalIdFactory:this._globalIdFactory,fontCache:n.fontCache,builtInCMapCache:n.builtInCMapCache,standardFontDataCache:n.standardFontDataCache,globalColorSpaceCache:this.globalColorSpaceCache,globalImageCache:n.globalImageCache,systemFontCache:n.systemFontCache,nonBlendModesSet:n.nonBlendModesSet,xfaFactory:null})),this.#e.set(a,u)}n.setActualNumPages(o.size)}}async fontFallback(e,n){let{catalog:r,pdfManager:s}=this;for(let i of await Promise.all(r.fontCache))if(i.loadedName===e){i.fallback(n,s.evaluatorOptions);return}}async cleanup(e=!1){return this.catalog?this.catalog.cleanup(e):mM()}async#a(e,n,r,s,i,o,a){let{xref:c}=this;if(!(r instanceof Se)||o.has(r))return;o.put(r);let l=await c.fetchAsync(r);if(!(l instanceof Q))return;let u=await l.getAsync("Subtype");if(u=u instanceof ve?u.name:null,u==="Link")return;if(l.has("T")){let d=Ht(await l.getAsync("T"));e=e===""?d:`${e}.${d}`}else{let d=l,p=new En;for(;;){if(d=d.getRaw("Parent")||n,d instanceof Se){if(o.has(d)||p.has(d))break;p.put(d),d=await c.fetchAsync(d)}if(!(d instanceof Q))break;if(d.has("T")){let m=Ht(await d.getAsync("T"));e=e===""?m:`${e}.${m}`;break}}}if(n&&!l.has("Parent")&&It(l.get("Subtype"),"Widget")&&a.put(r,n),s.getOrInsertComputed(e,Xf).push(Wo.create(c,r,i,null,!0,a,null,null).then(d=>d?.getFieldObject()).catch(function(d){return te(`#collectFieldObjects: "${d}".`),null})),!l.has("Kids"))return;let h=await l.getAsync("Kids");if(Array.isArray(h))for(let d of h)await this.#a(e,r,d,s,i,o,a)}get fieldObjects(){let e=this.pdfManager.ensureDoc("formInfo").then(async n=>{if(!n.hasFields)return null;let r=await this.annotationGlobals;if(!r)return null;let{acroForm:s}=r,i=new En,o=new Map,a=new Map,c=new Qr;for(let u of s.get("Fields"))await this.#a("",null,u,a,r,i,c);let l=[];for(let[u,h]of a)l.push(Promise.all(h).then(d=>{d=d.filter(Boolean),d.length>0&&o.set(u,d)}));return await Promise.all(l),{allFields:o.size?o:null,orphanFields:c}});return ze(this,"fieldObjects",e)}async#c(e,n,r){if(Array.isArray(e))for(let s of e){if(s instanceof Se){if(r.has(s))continue;r.put(s)}let i=await this.xref.fetchIfRefAsync(s);if(i instanceof Q){if(It(await i.getAsync("FT"),"Sig")){let o=await i.getAsync("V");if(o instanceof Q){let a=await this.#f(i,o,s);a&&n.push(a)}}i.has("Kids")&&await this.#c(await i.getAsync("Kids"),n,r)}}}async#l(e,n){try{return this.stream.getByteRange(e,n)}catch(r){if(!(r instanceof Un))throw r;return await this.pdfManager.requestRange(e,n),this.#l(e,n)}}async#h(e,n){if(n>0)return!1;let r=this.stream.end;for(let s=e;s<r;s+=pJ){let i=Math.min(s+pJ,r),o=await this.#l(s,i);for(let a of o)if(a!==0&&a!==9&&a!==10&&a!==12&&a!==13&&a!==32)return!1}return!0}async#f(e,n,r){let s=await n.getAsync("ByteRange");if(!Array.isArray(s)||s.length!==4||s.some(A=>!Number.isInteger(A)||A<0))return null;let[i,o,a,c]=s,l=this.stream.end||0;if(i!==0||o<=0||i+o>a||a+c>l||l===0)return null;let u=await n.getAsync("Contents");if(typeof u!="string"||u.length===0)return null;let[h,d,p,m,g,b,x,w]=await Promise.all([n.getAsync("Filter"),n.getAsync("SubFilter"),e.getAsync("T"),n.getAsync("Name"),n.getAsync("Reason"),n.getAsync("Location"),n.getAsync("ContactInfo"),n.getAsync("M")]),y=h instanceof ve?h.name:null,S=d instanceof ve?d.name:null,k=null;return S==="adbe.pkcs7.detached"?k=0:S==="adbe.pkcs7.sha1"&&(k=1),{id:`${r instanceof Se?r.toString():"inline"}:${i}-${o}-${a}-${c}`,fieldName:typeof p=="string"?Ht(p):"",signerName:typeof m=="string"?Ht(m):null,reason:typeof g=="string"?Ht(g):null,location:typeof b=="string"?Ht(b):null,contactInfo:typeof x=="string"?Ht(x):null,signingTime:typeof w=="string"?w:null,filter:y,subFilter:S,signatureType:k,byteRange:s,pkcs7:Sr(u),revisionIndex:0,parentId:null}}get signatures(){let e=this.pdfManager.ensureDoc("formInfo").then(async n=>{if(!n.hasSignatures||!n.hasFields)return null;let r=await this.annotationGlobals;if(!r)return null;let s=r.acroForm.get("Fields"),i=[];await this.#c(s,i,new En),await Promise.all(i.map(async c=>{let l=c.byteRange[2]+c.byteRange[3];c.modificationsAfterSignature=this.xref.countUpdatesAfter(l),c.coversWholeDocument=await this.#h(l,c.modificationsAfterSignature)})),i.sort((c,l)=>l.byteRange[2]+l.byteRange[3]-(c.byteRange[2]+c.byteRange[3]));for(let c=0,l=i.length;c<l;c++){let u=i[c];u.revisionIndex=c;for(let h=c-1;h>=0;h--){let d=i[h];if(d.byteRange[2]+d.byteRange[3]>u.byteRange[2]+u.byteRange[3]){u.parentId=d.id;break}}}let o=new Map,a=i.map(c=>{let{pkcs7:l,...u}=c;return o.set(c.id,{byteRange:c.byteRange,pkcs7:l}),u});return this.#t=o,a.length?a:null});return ze(this,"signatures",e)}async getSignatureData(e){await this.signatures;let n=this.#t?.get(e);if(!n)return null;let{byteRange:r,pkcs7:s}=n,[i,o,a,c]=r;return{data:await Promise.all([this.#l(i,i+o),this.#l(a,a+c)]),pkcs7:s}}get hasJSActions(){let e=Promise.all([this.pdfManager.ensureCatalog("jsActions"),this.pdfManager.ensureDoc("fieldObjects")]).then(([n,r])=>n?!0:r?.allFields?r.allFields.values().some(s=>s.some(i=>i.actions!==null)):!1);return ze(this,"hasJSActions",e)}get calculationOrderIds(){let e=this.catalog.acroForm?.get("CO");if(!Array.isArray(e)||e.length===0)return ze(this,"calculationOrderIds",null);let n=[];for(let r of e)r instanceof Se&&n.push(r.toString());return ze(this,"calculationOrderIds",n.length?n:null)}get annotationGlobals(){return ze(this,"annotationGlobals",Wo.createGlobals(this.pdfManager))}async toJSObject(e,n=!0){throw new Error("Not implemented: toJSObject")}};f(Jge,"parseDocBaseUrl");kS=class{static{f(this,"BasePdfManager")}constructor({docBaseUrl:e,docId:n,enableXfa:r,evaluatorOptions:s,handler:i,password:o}){this._docBaseUrl=Jge(e),this._docId=n,this._password=o,this.enableXfa=r,s.isOffscreenCanvasSupported&&=mi.isOffscreenCanvasSupported,s.isImageDecoderSupported&&=mi.isImageDecoderSupported,this.evaluatorOptions=Object.freeze(s),wa.setOptions(s),Up.setOptions(s),Ko.setOptions(s);let a={...s,handler:i};b0.setOptions(a),Ax.setOptions(a),zx.setOptions(a),p5.setOptions(a),$p.setOptions(a)}get docId(){return this._docId}get password(){return this._password}get docBaseUrl(){return this._docBaseUrl}ensureDoc(e,n){return this.ensure(this.pdfDocument,e,n)}ensureCatalog(e,n){return this.ensure(this.pdfDocument.catalog,e,n)}async initDocument(e){await this.ensureDoc("checkHeader"),await this.ensureDoc("parseStartXRef"),await this.ensureDoc("parse",[e]),await this.ensureDoc("checkFirstPage",[e]),await this.ensureDoc("checkLastPage",[e])}getPage(e){return this.pdfDocument.getPage(e)}fontFallback(e,n){return this.pdfDocument.fontFallback(e,n)}cleanup(e=!1){return this.pdfDocument.cleanup(e)}async ensure(e,n,r){rn("Abstract method `ensure` called")}requestRange(e,n){rn("Abstract method `requestRange` called")}requestLoadedStream(e=!1){rn("Abstract method `requestLoadedStream` called")}sendProgressiveData(e){rn("Abstract method `sendProgressiveData` called")}updatePassword(e){this._password=e,this.pdfDocument.xref.encrypt?.setPassword(e)}terminate(e){rn("Abstract method `terminate` called")}},yx=class extends kS{static{f(this,"LocalPdfManager")}constructor(e){super(e);let n=new Jn(e.source);this.pdfDocument=new SS(this,n),this._loadedStreamPromise=Promise.resolve(n)}async ensure(e,n,r){let s=e[n];return typeof s=="function"?s.apply(e,r):s}requestLoadedStream(e=!1){return this._loadedStreamPromise}terminate(e){}},KN=class extends kS{static{f(this,"NetworkPdfManager")}constructor(e){super(e),this.streamManager=new ER(e.source,{msgHandler:e.handler,length:e.length,disableAutoFetch:e.disableAutoFetch,rangeChunkSize:e.rangeChunkSize}),this.pdfDocument=new SS(this,this.streamManager.getStream())}async ensure(e,n,r){try{let s=e[n];return typeof s=="function"?await s.apply(e,r):s}catch(s){if(!(s instanceof Un))throw s;return await this.requestRange(s.begin,s.end),this.ensure(e,n,r)}}requestRange(e,n){return this.streamManager.requestRange(e,n)}requestLoadedStream(e=!1){return this.streamManager.requestAllChunks(e)}sendProgressiveData(e){this.streamManager.onReceiveData({chunk:e})}terminate(e){this.streamManager.abort(e)}},AKe=qn(1689),W3={DATA:1,ERROR:2},Cs={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};f(bJ,"onFn");f(Bo,"wrapReason");AS=class{static{f(this,"MessageHandler")}#e=new AbortController;constructor(e,n,r){this.sourceName=e,this.targetName=n,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let r=e.callbackId,s=this.callbackCapabilities[r];if(!s)throw new Error(`Cannot resolve callback ${r}`);if(delete this.callbackCapabilities[r],e.callback===W3.DATA)s.resolve(e.data);else if(e.callback===W3.ERROR)s.reject(Bo(e.reason));else throw new Error("Unexpected callback case");return}let n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let r=this.sourceName,s=e.sourceName,i=this.comObj;Promise.try(n,e.data).then(function(o){i.postMessage({sourceName:r,targetName:s,callback:W3.DATA,callbackId:e.callbackId,data:o})},function(o){i.postMessage({sourceName:r,targetName:s,callback:W3.ERROR,callbackId:e.callbackId,reason:Bo(o)})});return}if(e.streamId){this.#n(e);return}n(e.data)}on(e,n){let r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=n}send(e,n,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:n},r)}sendWithPromise(e,n,r){let s=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[s]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:s,data:n},r)}catch(o){i.reject(o)}return i.promise}sendWithStream(e,n,r,s){let i=this.streamId++,o=this.sourceName,a=this.targetName,c=this.comObj;return new ReadableStream({start:f(l=>{let u=Promise.withResolvers();return this.streamControllers[i]={controller:l,startCall:u,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:o,targetName:a,action:e,streamId:i,data:n,desiredSize:l.desiredSize},s),u.promise},"start"),pull:f(l=>{let u=Promise.withResolvers();return this.streamControllers[i].pullCall=u,c.postMessage({sourceName:o,targetName:a,stream:Cs.PULL,streamId:i,desiredSize:l.desiredSize}),u.promise},"pull"),cancel:f(l=>{xr(l instanceof Error,"cancel must have a valid reason");let u=Promise.withResolvers();return this.streamControllers[i].cancelCall=u,this.streamControllers[i].isClosed=!0,c.postMessage({sourceName:o,targetName:a,stream:Cs.CANCEL,streamId:i,reason:Bo(l)}),u.promise},"cancel")},r)}#n(e){let n=e.streamId,r=this.sourceName,s=e.sourceName,i=this.comObj,o=this,a=this.actionHandler[e.action],c={enqueue(l,u=1,h){if(this.isCancelled)return;let d=this.desiredSize;this.desiredSize-=u,d>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:s,stream:Cs.ENQUEUE,streamId:n,chunk:l},h)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:s,stream:Cs.CLOSE,streamId:n}),delete o.streamSinks[n])},error(l){xr(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:s,stream:Cs.ERROR,streamId:n,reason:Bo(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[n]=c,Promise.try(a,e.data,c).then(function(){i.postMessage({sourceName:r,targetName:s,stream:Cs.START_COMPLETE,streamId:n,success:!0})},function(l){i.postMessage({sourceName:r,targetName:s,stream:Cs.START_COMPLETE,streamId:n,reason:Bo(l)})})}#r(e){let n=e.streamId,r=this.sourceName,s=e.sourceName,i=this.comObj,o=this.streamControllers[n],a=this.streamSinks[n];switch(e.stream){case Cs.START_COMPLETE:e.success?o.startCall.resolve():o.startCall.reject(Bo(e.reason));break;case Cs.PULL_COMPLETE:e.success?o.pullCall.resolve():o.pullCall.reject(Bo(e.reason));break;case Cs.PULL:if(!a){i.postMessage({sourceName:r,targetName:s,stream:Cs.PULL_COMPLETE,streamId:n,success:!0});break}a.desiredSize<=0&&e.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=e.desiredSize,Promise.try(a.onPull||bJ).then(function(){i.postMessage({sourceName:r,targetName:s,stream:Cs.PULL_COMPLETE,streamId:n,success:!0})},function(l){i.postMessage({sourceName:r,targetName:s,stream:Cs.PULL_COMPLETE,streamId:n,reason:Bo(l)})});break;case Cs.ENQUEUE:if(xr(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case Cs.CLOSE:if(xr(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),this.#s(o,n);break;case Cs.ERROR:xr(o,"error should have stream controller"),o.controller.error(Bo(e.reason)),this.#s(o,n);break;case Cs.CANCEL_COMPLETE:e.success?o.cancelCall.resolve():o.cancelCall.reject(Bo(e.reason)),this.#s(o,n);break;case Cs.CANCEL:if(!a)break;let c=Bo(e.reason);Promise.try(a.onCancel||bJ,c).then(function(){i.postMessage({sourceName:r,targetName:s,stream:Cs.CANCEL_COMPLETE,streamId:n,success:!0})},function(l){i.postMessage({sourceName:r,targetName:s,stream:Cs.CANCEL_COMPLETE,streamId:n,reason:Bo(l)})}),a.sinkCapability.reject(c),a.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}}async#s(e,n){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[n]}destroy(){this.#e?.abort(),this.#e=null}};f(EZ,"writeObject");f(AM,"writeDict");f(Zge,"writeStream");f(Qge,"writeArray");f(e1e,"numberToPDFString");f(lw,"writeValue");f(hR,"writeInt");f(PZ,"writeString");f(t1e,"computeMD5");f(n1e,"writeXFADataForAcroform");f(r1e,"updateAcroform");f(s1e,"updateXFA");f(i1e,"getXRefTable");f(qZ,"getIndexes");f(o1e,"getXRefStreamTable");f(OZ,"computeIDs");f(a1e,"getTrailerDict");f(c1e,"writeChanges");f(FZ,"incrementalUpdate");l1e=16,f1e=64,XN=class{static{f(this,"PageData")}constructor(e,n){this.page=e,this.documentData=n,this.annotations=null,this.pointingNamedDestinations=null,this.copyLevel=0,n.pagesMap.put(e.ref,this)}},YN=class{static{f(this,"DocumentData")}constructor(e){this.document=e,this.destinations=null,this.pageLabels=null,this.pagesMap=new Qr,this.oldRefMapping=new Qr,this.dedupNamedDestinations=new Map,this.usedNamedDestinations=new Set,this.postponedRefCopies=new Qr,this.resourceStreamPromises=new Map,this.usedStructParents=new Set,this.oldStructParentMapping=new Map,this.structTreeRoot=null,this.parentTree=null,this.idTree=null,this.roleMap=null,this.classMap=null,this.namespaces=null,this.structTreeAF=null,this.structTreePronunciationLexicon=[],this.acroForm=null,this.acroFormDefaultAppearance="",this.acroFormDefaultResources=null,this.acroFormQ=0,this.hasSignatureAnnotations=!1,this.fieldToParent=new Qr,this.outline=null,this.embeddedFiles=null}},JN=class{static{f(this,"XRefWrapper")}constructor(e,n){this.entries=e,this._getNewRef=n}getNewTemporaryRef(){return this._getNewRef()}countUpdatesAfter(e){return null}fetchIfRef(e){return e instanceof Se?this.fetch(e):e}fetch(e){if(!(e instanceof Se))throw new Error("ref object is not a reference");return this.entries[e.num]}async fetchIfRefAsync(e){return e instanceof Se?this.fetchAsync(e):e}async fetchAsync(e){return this.fetch(e)}},ZN=class{static{f(this,"PDFEditor")}isSingleFile=!1;#e=null;#t=null;#n=new Map;currentDocument=null;oldPages=[];newPages=[];xref=[null];xrefWrapper=new JN(this.xref,()=>this.newRef);newRefCount=1;namesDict=null;version="1.7";pageLabels=null;namedDestinations=new Map;parentTree=new Map;structTreeKids=[];idTree=new Map;classMap=new Q;roleMap=new Q;namespaces=new Map;structTreeAF=[];structTreePronunciationLexicon=[];fields=[];acroFormDefaultAppearance="";acroFormDefaultResources=null;acroFormNeedAppearances=!1;acroFormSigFlags=0;acroFormCalculationOrder=null;acroFormQ=0;outlineItems=null;embeddedFiles=new Map;constructor({useObjectStreams:e=!0,title:n="",author:r=""}={}){[this.rootRef,this.rootDict]=this.newDict,[this.infoRef,this.infoDict]=this.newDict,[this.pagesRef,this.pagesDict]=this.newDict,this.useObjectStreams=e,this.objStreamRefs=e?new Set:null,this.title=n,this.author=r}get newRef(){return Se.get(this.newRefCount++,0)}get newDict(){let e=this.newRef,n=this.xref[e.num]=new Q;return[e,n]}async#r(e,n){let r=this.newRef;return this.xref[r.num]=await this.#s(e,!0,n),r}cloneDict(e){let n=e.clone();return n.xref=this.xrefWrapper,n}async#s(e,n,r,s=new En){if(e instanceof Se){let{currentDocument:{fieldToParent:c,oldRefMapping:l}}=this,u=l.get(e);if(u)return u;let h=e;e=await r.fetchAsync(h);let d=l.get(h);if(d)return d;if(typeof e=="number")return e;if(e instanceof kt&&this.#o(e.dict))return this.#l(h,e,r,s);let p=this.newRef;l.put(h,p);let m=!0;return c.has(h)&&e instanceof Q&&(e=this.cloneDict(e),e.delete("Parent"),m=!1),this.xref[p.num]=await this.#s(e,m,r,s),p}let i=[],{currentDocument:{postponedRefCopies:o}}=this;if(Array.isArray(e)){n&&(e=e.slice());for(let c=0,l=e.length;c<l;c++){let u=e[c]instanceof Se&&o.get(e[c]);if(u){u.push(h=>e[c]=h);continue}i.push(this.#s(e[c],!0,r,s).then(h=>e[c]=h))}return await Promise.all(i),e}let a;if(e instanceof kt?({dict:a}=e=e.getOriginalStream().clone(),a.xref=this.xrefWrapper):e instanceof Q&&(n&&(e=e.clone(),e.xref=this.xrefWrapper),a=e),a){for(let[c,l]of a.getRawEntries()){let u=l instanceof Se&&o.get(l);if(u){u.push(h=>a.set(c,h));continue}i.push(this.#s(l,!0,r,s).then(h=>a.set(c,h)))}await Promise.all(i)}return e}#o(e){let n=e.get("Subtype");return It(n,"Image")||e.has("Length1")||It(n,"Type1C")||It(n,"CIDFontType0C")||It(n,"OpenType")}#i(e){let n=e.getOriginalStream();return n.reset(),n.getBytes()}async#a(e){let n=[];return await lw(e,n,null),n.join("")}#c(e,n){let{length:i}=n,o=new B5;if(o.update(e),o.update(`#${i}`),i<=256*4)o.update(n);else{let a=Math.floor((i-256)/3);for(let c=0;c<4;c++){let l=Math.min(c*a,i-256);o.update(n.subarray(l,l+256))}}return o.hexdigest()}async#l(e,n,r,s){let{currentDocument:{oldRefMapping:i,resourceStreamPromises:o}}=this;if(s.has(e))return i.getOrPutComputed(e,()=>this.newRef);let a=e.toString(),c=o.get(a);if(c)return c;let l=new En(s);l.put(e);let u=Promise.resolve().then(async()=>{let h=await this.#s(n,!0,r,l),d=i.get(e);if(d)return this.xref[d.num]=h,d;let p=await this.#h(h);return i.put(e,p),p});o.set(a,u);try{return await u}finally{o.get(a)===u&&o.delete(a)}}async#h(e){let n=await this.#a(e.dict),r=this.#i(e),s=this.#c(n,r),i=this.#n.getOrInsertComputed(s,Xf);for(let a of i)if(a.dictStr===n&&g0(this.#i(a.stream),r))return a.ref;let o=this.newRef;return this.xref[o.num]=e,i.push({ref:o,dictStr:n,stream:e}),o}async#f(e,n){if(e instanceof Se){let r=await n.fetchAsync(e);return Array.isArray(r)?r:[e]}return Array.isArray(e)?e:[e]}async#d(e,n,r,s,i,o,a,c=new En){let{currentDocument:{pagesMap:l,oldRefMapping:u}}=this,h=n.getRaw("Pg");if(h instanceof Se&&!l.has(h))return null;let d=n.getRaw("K");if(d instanceof Se&&c.has(d))return null;let p=await this.#f(d,r),m=[],g=[];for(let v of p){let A=v instanceof Se?v:null;if(A){if(c.has(A))continue;c.put(A),v=await r.fetchAsync(A)}if(typeof v=="number"){m.push(v);continue}if(!(v instanceof Q))continue;let j=v.getRaw("Pg");if(j instanceof Se&&!l.has(j))continue;let C=v.get("Type");if(!C||It(C,"StructElem")){let I=!1;if(A&&s.has(A)){if(!It(v.get("S"),"Link"))continue;I=!0}let R=await this.#d(A,v,r,s,i,o,a,c);R&&(g.push(m.length),m.push(R),A&&u.put(A,R),I&&this.xref[R.num].setIfName("S","Span"));continue}if(It(C,"OBJR")){if(!A)continue;let I=v.getRaw("Obj");if(I instanceof Se&&!u.get(I))continue;let R=u.get(A)||await this.#s(A,!0,r),P=this.xref[R.num].getRaw("Obj");if(P instanceof Se){let F=this.xref[P.num];if(F instanceof Q&&!F.has("StructParent")&&e){let _=this.parentTree.size;this.parentTree.set(_,[u,e]),F.set("StructParent",_)}}m.push(R);continue}if(It(C,"MCR")){let I=await this.#s(A||v,!0,r);m.push(I);continue}if(A){let I=await this.#s(A,!0,r);m.push(I)}}if(p.length!==0&&m.length===0)return null;let b=this.newRef,x=this.xref[b.num]=this.cloneDict(n);x.delete("ID"),x.delete("C"),x.delete("K"),x.delete("P"),x.delete("S"),await this.#s(x,!1,r);let w=n.get("C");if(w instanceof ve){let v=o.get(w.name);x.set("C",v?ve.get(v):w)}else if(Array.isArray(w)){let v=[];for(let A of w)if(A instanceof ve){let j=o.get(A.name);v.push(j?ve.get(j):A)}x.set("C",v)}let y=n.get("S");if(y instanceof ve){let v=a.get(y.name);x.set("S",v?ve.get(v):y)}let S=n.get("ID");if(typeof S=="string"){let v=Ht(S,!1),A=i.get(v);x.set("ID",A?Hs(A):S)}let k=x.get("A");if(k){Array.isArray(k)||(k=[k]);for(let v of k)if(v=this.xrefWrapper.fetchIfRef(v),v instanceof Q&&It(v.get("O"),"Table")&&v.has("Headers")){let A=this.xrefWrapper.fetchIfRef(v.getRaw("Headers"));if(Array.isArray(A))for(let j=0,C=A.length;j<C;j++){let I=this.xrefWrapper.fetchIfRef(A[j]);if(typeof I!="string")continue;let R=i.get(Ht(I,!1));R&&(A[j]=R)}}}for(let v of g){let A=m[v];this.xref[A.num].set("P",b)}return m.length===1?x.set("K",m[0]):m.length>1&&x.set("K",m),b}#m({document:e,includePages:n,excludePages:r}){if(!e)return[];let s=f(l=>{if(!l?.length)return null;let u=new Set,h=[];for(let d of l)Array.isArray(d)?h.push(d):u.add(d);return{indices:u,ranges:h}},"compile"),i=f((l,{indices:u,ranges:h})=>u.has(l)||h.some(([d,p])=>l>=d&&l<=p),"matches"),o=s(n),a=s(r),c=[];for(let l=0,u=e.numPages;l<u;l++)a&&i(l,a)||(!o||i(l,o))&&c.push(l);return c}#g(e){let n=new Array(e.length),r=[],s=[];for(let c=0;c<e.length;c++){let l=e[c],u;if(l.image)u=n[c]=1;else if(l.document)u=n[c]=this.#m(l).length;else{n[c]=0;continue}if(!l.pageIndices)if(l.insertAfter===void 0)for(let h=0;h<u;h++)r.push(c);else s.push({i:c,insertAfter:l.insertAfter,count:u})}if(s.length===0)return e;let i=f(c=>!!(c.document||c.image),"hasContent");for(let c=0;c<e.length;c++){let l=e[c];if(i(l)&&l.pageIndices&&l.pageIndices.length<n[c])throw new Error("extractPages: partial pageIndices cannot be combined with insertAfter entries.")}if(s.sort((c,l)=>c.insertAfter-l.insertAfter||c.i-l.i),r.length===0&&e.some(c=>i(c)&&c.pageIndices)){let c=e.slice(),l=-1;for(let h of e)if(!(!i(h)||!h.pageIndices))for(let d of h.pageIndices)d>l&&(l=d);let u=0;for(let{i:h,insertAfter:d,count:p}of s){let m=Math.min(Math.max(d,-1)+u,l);for(let x=0;x<c.length;x++){let w=c[x];!i(w)||!w.pageIndices||w.pageIndices.every(y=>y<=m)||(c[x]={...w,pageIndices:w.pageIndices.map(y=>y>m?y+p:y)})}let g=[];for(let x=0;x<p;x++)g.push(m+1+x);let b={...c[h],pageIndices:g};delete b.insertAfter,c[h]=b,u+=p,l+=p}return c}let o=0;for(let{i:c,insertAfter:l,count:u}of s){let h=Math.max(l,-1)+1+o;r.splice(h,0,...new Array(u).fill(c)),o+=u}let a=new Array(e.length);for(let c=0;c<r.length;c++){let l=r[c];(a[l]||=[]).push(c)}return e.map((c,l)=>{if(!i(c)||c.pageIndices)return c;let u={...c,pageIndices:a[l]||[]};return delete u.insertAfter,u})}async extractPages(e,n,r,s,i){this.#t=r,e=this.#g(e);let o=[],a=0,c=f(g=>{if(!Number.isInteger(g)||g<0)throw new Error("extractPages: invalid page index.");if(this.oldPages[g]!==void 0)throw new Error("extractPages: overlapping pageIndices.");this.oldPages[g]=null},"reservePageSlot"),l=[];n&&(this.#e={handler:s,task:i,newAnnotationsByPage:aM(n),imagesPromises:Wo.generateImages(n.values(),this.xrefWrapper,!0)});let u=[];for(let g of e){let{document:b,image:x,includePages:w,excludePages:y,pageIndices:S}=g;if(x){if(S&&(a=-1,S.length>1))throw new Error("extractPages: too many pageIndices.");let j;if(S?.length)j=S[0];else if(a!==-1)j=a++;else for(j=0;this.oldPages[j]!==void 0;j++);c(j),u.push({image:x,slot:j});continue}if(!b)continue;S&&(a=-1);let k=this.#m({document:b,includePages:w,excludePages:y});if(S&&S.length>k.length)throw new Error("extractPages: too many pageIndices.");let v=new YN(b);l.push(v),o.push(this.#u(v));let A=0;for(let j of k){let C;if(S&&(C=S[A++]),C===void 0)if(a!==-1)C=a++;else for(C=0;this.oldPages[C]!==void 0;C++);c(C),o.push(b.getPage(j).then(I=>{this.oldPages[C]=new XN(I,v)}))}}if(await Promise.all(o),this.oldPages.length===0)throw new Error("extractPages: nothing to extract.");let h=new Map,d=new Set;for(let g=0,b=this.oldPages.length;g<b;g++){let x=this.oldPages[g];if(x===void 0)throw new Error("extractPages: sparse pageIndices.");if(x){let{page:w}=x,y=h.get(w)??0;h.set(w,y+1),x.copyLevel=y,d.add(x.documentData.document)}}this.isSingleFile=d.size===1,o.length=0,this.#k(l),this.#j(l),this.#v();for(let g of this.oldPages)g&&o.push(this.#p(g));await Promise.all(o),this.#S(),this.#b(l);let p=new Map;for(let g of u)p.set(g.slot,g);let m=p.size>0?this.#U():null;for(let g=0,b=this.oldPages.length;g<b;g++){let x=p.get(g);x?this.newPages[g]=await this.#V(x.image,m):this.newPages[g]=await this.#z(g,null)}return this.#x(l),await this.#y(l),await this.#O(l),this.#T(l),await this.#D(l),this.writePDF()}async#u(e){let{document:{pdfManager:n,xref:r}}=e;await Promise.all([n.ensureCatalog("destinations").then(i=>e.destinations=i),n.ensureCatalog("rawPageLabels").then(i=>e.pageLabels=i),n.ensureCatalog("structTreeRoot").then(i=>e.structTreeRoot=i),n.ensureCatalog("acroForm").then(i=>e.acroForm=i),n.ensureCatalog("documentOutlineForEditor").then(i=>e.outline=i),n.ensureCatalog("rawEmbeddedFiles").then(i=>e.embeddedFiles=i)]);let s=e.structTreeRoot;if(s){let i=s.dict,o=i.get("ParentTree");if(o){let l=new y0(o,r);e.parentTree=l.getAll(!0)}let a=i.get("IDTree");if(a){let l=new Va(a,r);e.idTree=l.getAll(!0)}e.roleMap=i.get("RoleMap")||null,e.classMap=i.get("ClassMap")||null;let c=i.get("Namespaces")||null;c&&!Array.isArray(c)&&(c=[c]),e.namespaces=c,e.structTreeAF=i.get("AF")||null,e.structTreePronunciationLexicon=i.get("PronunciationLexicon")||null}}async#p(e){let{page:{xref:n,annotations:r},documentData:{pagesMap:s,destinations:i,usedNamedDestinations:o,fieldToParent:a}}=e;if(!r)return;let c=[],l=[],u=0,{hasSignatureAnnotations:h}=e.documentData;for(let d of r){let p=u++;c.push(n.fetchIfRefAsync(d).then(async m=>{if(!It(m.get("Subtype"),"Link")){if(It(m.get("Subtype"),"Widget")){h||=It(ei({dict:m,key:"FT"}),"Sig");let x=m.getRaw("Parent")||null;a.put(d,x)}l[p]=d;return}let g=m.get("A");if(g instanceof Q&&!It(g.get("S"),"GoTo")){l[p]=d;return}let b=g instanceof Q?g.get("D"):m.get("Dest");if(!b||Array.isArray(b)&&(!(b[0]instanceof Se)||s.has(b[0])))l[p]=d;else if(b instanceof ve||typeof b=="string"){let x=Ht(b instanceof ve?b.name:b,!0);i.has(x)&&(l[p]=d,o.add(x))}}))}await Promise.all(c),l=l.filter(Boolean),e.annotations=l.length>0?l:null,e.documentData.hasSignatureAnnotations||=h}#b(e){for(let{postponedRefCopies:n,pagesMap:r}of e)for(let s of r.keys())n.put(s,[])}#x(e){for(let{postponedRefCopies:n,oldRefMapping:r}of e){for(let[s,i]of n.items()){let o=r.get(s);for(let a of i)a(o)}n.clear()}}#w(e,n,r=new En){if(e instanceof Se){r.has(e)||(r.put(e),this.#w(this.xref[e.num],n,r));return}if(Array.isArray(e)){for(let i of e)this.#w(i,n,r);return}let s;if(e instanceof kt?{dict:s}=e:e instanceof Q&&(s=e),s){n(s);for(let i of s.getRawValues())this.#w(i,n,r)}}async#y(e){let n=0,{parentTree:r}=this;for(let h=0,d=this.newPages.length;h<d;h++){if(!this.oldPages[h])continue;let{documentData:{parentTree:p,oldRefMapping:m,oldStructParentMapping:g,usedStructParents:b,document:{xref:x}}}=this.oldPages[h];if(!p)continue;let w=this.newPages[h],y=this.xref[w.num],S=new En;S.put(w),this.#w(y,k=>{let v=k.get("StructParent")??k.get("StructParents");if(typeof v!="number")return;b.add(v);let A=p.get(v),j=A instanceof Se?A:null;if(j){let I=x.fetch(j);Array.isArray(I)&&(A=I)}if(Array.isArray(A)&&A.every(I=>I===null)&&(A=null),!A){k.has("StructParent")?k.delete("StructParent"):k.delete("StructParents");return}let C=g.get(v);C===void 0&&(C=n++,g.set(v,C),r.set(C,[m,A])),k.has("StructParent")?k.set("StructParent",C):k.set("StructParents",C)},S)}let{structTreeKids:s,idTree:i,classMap:o,roleMap:a,namespaces:c,structTreeAF:l,structTreePronunciationLexicon:u}=this;for(let h of e){let{document:{xref:d},oldRefMapping:p,parentTree:m,usedStructParents:g,structTreeRoot:b,idTree:x,classMap:w,roleMap:y,namespaces:S,structTreeAF:k,structTreePronunciationLexicon:v}=h;if(!b)continue;this.currentDocument=h;let A=new En;for(let[P,F]of m||[])!g.has(P)&&F instanceof Se&&A.put(F);let j=new Map;for(let[P,F]of x||[]){let _=P;if(i.has(P))for(let B=1;;B++){let W=`${P}_${B}`;if(!i.has(W)){j.set(P,W),_=W;break}}i.set(_,F)}let C=new Map;if(w?.size>0)for(let[P,F]of w){if(F=await this.#s(F,!0,d),o.has(P))for(let _=1;;_++){let B=`${P}_${_}`;if(!o.has(B)){C.set(P,B),P=B;break}}o.set(P,F)}let I=new Map;if(y?.size>0)for(let[P,F]of y){let _=a.get(P);if(!_){a.set(P,F);continue}if(_!==F)for(let B=1;;B++){let W=`${P}_${B}`;if(!a.has(W)){I.set(P,W),a.set(W,F);break}}}if(S?.length>0)for(let P of S){let F=await d.fetchIfRefAsync(P),_=F.get("NS");if(!_||c.has(_))continue;_=Ht(_,!1);let B=await this.#s(F,!0,d);c.set(_,B)}if(k)for(let P of k)l.push(await this.#s(P,!0,d));if(v)for(let P of v)u.push(await this.#s(P,!0,d));let R=b.dict.getRaw("K");if(!R)continue;let E=await this.#f(R,d);for(let P of E){let F=P instanceof Se?P:null;if(P=await d.fetchIfRefAsync(P),!(P instanceof Q))continue;let _=!1;if(F&&A.has(F)){if(!It(P.get("S"),"Link"))continue;_=!0}let B=await this.#d(F,P,d,A,j,C,I);B&&(s.push(B),F&&p.put(F,B),_&&this.xref[B.num].setIfName("S","Span"))}for(let[P,F]of x||[]){let _=F instanceof Se&&p.get(F),B=j.get(P)||P;_?i.set(B,_):i.delete(B)}}for(let[h,[d,p]]of r){if(!p){r.delete(h);continue}if(!Array.isArray(p)){let g=d.get(p);g===void 0?r.delete(h):r.set(h,g);continue}let m=p.map(g=>g instanceof Se&&d.get(g)||null);if(m.length===0||m.every(g=>g===null)){r.delete(h);continue}r.set(h,m)}this.currentDocument=null}#k(e){for(let n of e){if(!n.destinations)continue;let{destinations:r,pagesMap:s}=n,i=n.destinations=new Map;for(let[o,a]of r){let c=a[0],l=c instanceof Se&&s.get(c);l&&((l.pointingNamedDestinations||=new Set).add(o),i.set(o,a))}}}#S(){let{namedDestinations:e}=this,n=f(r=>{if(!e.has(r))return r;for(let s=1;;s++){let i=`${r}_${s}`;if(!e.has(i))return i}},"getUniqueDestinationName");for(let r=0,s=this.oldPages.length;r<s;r++){let i=this.oldPages[r];if(!i)continue;let{documentData:{destinations:o,dedupNamedDestinations:a,usedNamedDestinations:c}}=i,{pointingNamedDestinations:l}=i;if(l){i.pointingNamedDestinations=l=l.intersection(c);for(let u of l){if(!c.has(u))continue;let h=o.get(u).slice();if(!e.has(u)){e.set(u,h);continue}let d=n(`${u}_p${r+1}`);a.set(u,d),e.set(d,h)}}}}#A(e,n){if(n.size===0)return;let r=f((s,i,o)=>{typeof o=="string"&&s.set(i,n.get(Ht(o,!0))||o)},"fixDestination");for(let s of e){let i=this.xref[s.num];if(!It(i.get("Subtype"),"Link"))continue;let o=i.get("A");if(o instanceof Q&&o.has("D")){let c=o.get("D");r(o,"D",c);continue}let a=i.get("Dest");r(i,"Dest",a)}}#j(e){let n=f((r,s,i)=>{for(let o of r)typeof o.dest=="string"&&s?.has(o.dest)&&i.add(o.dest),o.items.length>0&&n(o.items,s,i)},"collect");for(let r of e){let{outline:s,destinations:i,usedNamedDestinations:o}=r;s?.length&&n(s,i,o)}}#R(e,n){let{dest:r,action:s,url:i,unsafeUrl:o,attachment:a,setOCGState:c}=e;if(s||i||o||a||c)return!0;if(!r)return!1;if(typeof r=="string"){let l=n.dedupNamedDestinations.get(r)||r;return this.namedDestinations.has(l)}return Array.isArray(r)&&r[0]instanceof Se?!!n.oldRefMapping.get(r[0]):!1}#I(e,n){let r=[];for(let s of e){let i=this.#I(s.items,n),o=this.#R(s,n);(o||i.length>0)&&r.push({...s,dest:o?s.dest:null,rawDict:o?s.rawDict:null,items:i,_documentData:n})}return r}#T(e){let n=[];for(let r of e){let{outline:s}=r;s?.length&&n.push(...this.#I(s,r))}this.outlineItems=n.length>0?n:null}async#q(e,n){let{dest:r,rawDict:s}=n,i=n._documentData;if(r){if(typeof r=="string"){let a=i.dedupNamedDestinations.get(r)||r;e.set("Dest",Hs(a))}else if(Array.isArray(r)){let a=r.slice();a[0]instanceof Se&&(a[0]=i.oldRefMapping.get(a[0])||a[0]),e.set("Dest",a)}return}let o=s?.get("A");if(o instanceof Q){this.currentDocument=i;let a=await this.#r(o,i.document.xref);this.currentDocument=null,e.set("A",a)}}async#E(){let{outlineItems:e}=this;if(!e?.length)return;let[n,r]=this.newDict;r.setIfName("Type","Outlines");let s=f(a=>{for(let c of a)[c._ref]=this.newDict,c.items.length>0&&s(c.items)},"assignRefs");s(e);let i=f(async(a,c)=>{let l=0;for(let u=0;u<a.length;u++){let h=a[u],d=this.xref[h._ref.num];if(d.set("Title",Hs(h.title)),d.set("Parent",c),u>0&&d.set("Prev",a[u-1]._ref),u<a.length-1&&d.set("Next",a[u+1]._ref),h.items.length>0){d.set("First",h.items[0]._ref),d.set("Last",h.items.at(-1)._ref);let m=await i(h.items,h._ref);h.count!==void 0&&d.set("Count",h.count<0?-m:m),l+=h.count!==void 0&&h.count<0?1:m+1}else l+=1;await this.#q(d,h);let p=(h.bold?2:0)|(h.italic?1:0);p!==0&&d.set("F",p),h.color&&(h.color[0]!==0||h.color[1]!==0||h.color[2]!==0)&&d.set("C",[h.color[0]/255,h.color[1]/255,h.color[2]/255])}return l},"fillItems"),o=await i(e,n);r.set("First",e[0]._ref),r.set("Last",e.at(-1)._ref),r.set("Count",o),this.rootDict.set("Outlines",n)}async#O(e){this.#F(e),this.#$(e),this.#B(e),await this.#M(e);let n=this.fields;for(let r of e){let s=r.acroForm?.get("Fields")||null;!s&&r.fieldToParent.size>0&&(s=this.#H(r.fieldToParent,r.document.xref)),Array.isArray(s)&&s.length>0&&(this.currentDocument=r,await this.#C(n,s),this.currentDocument=null)}this.#N(e)}#B(e){let n=0,r=null;for(let s of e){let i=s.acroForm?.get("Q");if(!(typeof i!="number"||i===0)){if(r?.acroFormQ>0){s.acroFormQ=i;continue}if(n===0){n=i,r=s;continue}i!==n&&(r.acroFormQ||=n,s.acroFormQ=i,n=0)}}n>0&&(this.acroFormQ=n)}#F(e){let n=0,r=!1;for(let s of e){if(!s.acroForm)continue;let i=s.acroForm.get("SigFlags");typeof i=="number"&&s.hasSignatureAnnotations&&(n|=i),s.acroForm.get("NeedAppearances")===!0&&(r=!0)}this.acroFormSigFlags=n,this.acroFormNeedAppearances=r}#N(e){let n=[];for(let r of e){let s=r.acroForm?.get("CO")||null;if(!Array.isArray(s))continue;let{oldRefMapping:i}=r;for(let o of s){let a=o instanceof Se&&i.get(o);a&&n.push(a)}}this.acroFormCalculationOrder=n.length>0?n:null}#$(e){let n=null,r=null;for(let s of e){let i=s.acroForm?.get("DA")||null;if(!(!i||typeof i!="string")){if(r?.acroFormDefaultAppearance){s.acroFormDefaultAppearance=i;continue}if(!n){n=i,r=s;continue}i!==n&&(r.acroFormDefaultAppearance||=n,s.acroFormDefaultAppearance=i,n=null)}}n&&(this.acroFormDefaultAppearance=n)}async#M(e){let n=null,r=null,s=null;for(let i of e){let o=i.acroForm?.get("DR")||null;if(!(!o||!(o instanceof Q))){if(s?.acroFormDefaultResources){i.acroFormDefaultResources=o;continue}if(!n){n=o,r=i.acroForm.getRaw("DR"),s=i;continue}wR(n,o)||(s.acroFormDefaultResources||=n,i.acroFormDefaultResources=o,n=null,r=null)}}n&&(this.currentDocument=s,this.acroFormDefaultResources=await this.#s(r,!0,s.document.xref),this.currentDocument=null)}#H(e,n){let r=[],s=new En;for(let[i,o]of e.items()){if(!o){r.push(i);continue}let a=o,c=o,l=new En;for(;;){if(a instanceof Se){if(l.has(a))break;l.put(a)}let u=n.fetchIfRef(a);if(!(u instanceof Q)||(a=u.getRaw("Parent")||null,!a))break;c=a}c instanceof Se&&!s.has(c)&&(r.push(c),s.put(c))}return r}async#C(e,n){let r=new En,s=[{kids:n,newKids:e,pos:0,oldParentRef:null,parentRef:null,parent:null}],{document:{xref:i},oldRefMapping:o,fieldToParent:a,acroFormDefaultAppearance:c,acroFormDefaultResources:l,acroFormQ:u}=this.currentDocument,h=[],d=[];for(;s.length>0;){let g=s.at(-1),{kids:b,newKids:x,parent:w,pos:y}=g;if(y===b.length){if(s.pop(),x.length===0||!w)continue;let j=this.xref[g.parentRef.num]=this.cloneDict(w);if(j.delete("Parent"),j.delete("Kids"),await this.#s(j,!1,i),j.set("Kids",x),s.length>0){let C=s.at(-1);if(!C.parentRef&&C.oldParentRef){let I=C.parentRef=this.newRef;j.set("Parent",I),o.put(C.oldParentRef,I)}C.newKids.push(g.parentRef)}continue}let S=b[g.pos++];if(!(S instanceof Se)||r.has(S))continue;r.put(S);let k=i.fetchIfRef(S);if(!(k instanceof Q))continue;if(k.has("Kids")){let j=k.get("Kids");if(!Array.isArray(j))continue;s.push({kids:j,newKids:[],pos:0,oldParentRef:S,parentRef:null,parent:k});continue}if(!a.has(S))continue;let v=o.get(S);if(!v)continue;x.push(v),!g.parentRef&&g.oldParentRef&&(g.parentRef=this.newRef,o.put(g.oldParentRef,g.parentRef));let A=this.xref[v.num];g.parentRef&&A.set("Parent",g.parentRef),c&&!A.has("DA")&&h.push(A),l&&!A.has("Kids")&&A.get("AP")instanceof Q&&d.push(A),u&&!A.has("Q")&&A.set("Q",u)}for(let g of h){let b=ei({dict:g,key:"FT"});if(!It(b,"Tx"))continue;ei({dict:g,key:"DA"})||g.set("DA",c)}let p=new Map,m=f(async g=>{let b=g.dict.getRaw("Resources");if(b&&=this.xrefWrapper.fetchIfRef(b),!(b instanceof Q)){let x=await p.getOrInsertComputed(l,()=>this.#r(l,i));g.dict.set("Resources",x);return}for(let[x,w]of l.getRawEntries()){if(b.has(x))continue;let y=w;w instanceof Se?y=await this.#s(w,!0,i):(w instanceof Q||w instanceof kt||Array.isArray(w))&&(y=await p.getOrInsertComputed(w,()=>this.#r(w,i))),b.set(x,y)}},"fixAppearanceResources");for(let g of d){let b=g.get("AP");for(let[,x]of b)if(x instanceof kt)await m(x);else if(x instanceof Q)for(let[,w]of x)w instanceof kt&&await m(w)}}async#v(){if(!this.isSingleFile)return;let e=this.oldPages.find(h=>!!h);if(!e)return;let{documentData:{document:n,pageLabels:r}}=e;if(!r)return;let s=n.numPages,i=new Map,o=new Set(this.oldPages.filter(Boolean).map(({page:{pageIndex:h}})=>h)),a=null,c=-1;for(let h=0;h<s;h++){let d=r.get(h);if(d&&(a=d,c=a.has("St")?h:-1),!!o.has(h)){if(c!==-1){let p=a.get("St");a=this.cloneDict(a),a.set("St",p+(h-c)),c=-1}i.set(h,a)}}let l=f(h=>{let d=new Q;return d.setIfName("S","D"),d.set("St",h+1),d},"defaultLabel");a=null;let u=this.pageLabels=[];for(let h=0,d=this.oldPages.length;h<d;h++){let p=this.oldPages[h],m=p&&i.get(p.page.pageIndex)||l(h);m!==a&&(a=m,u.push([h,a]))}}async#z(e){let{page:n,documentData:r,annotations:s,pointingNamedDestinations:i,copyLevel:o}=this.oldPages[e];this.currentDocument=r;let{dedupNamedDestinations:a,oldRefMapping:c}=r,{xref:l,rotate:u,mediaBox:h,resources:d,ref:p}=n,m=this.newRef,g=this.xref[m.num]=this.cloneDict(n.pageDict);if(c.put(p,m),i)for(let S of i){let k=a.get(S)||S,v=this.namedDestinations.get(k);v[0]=m}for(let S of["Rotate","MediaBox","CropBox","BleedBox","TrimBox","ArtBox","Resources","Annots","Parent","UserUnit"])g.delete(S);let b=this.newRefCount;await this.#s(g,!1,l),g.set("Rotate",u),g.set("MediaBox",h);for(let S of["CropBox","BleedBox","TrimBox","ArtBox"]){let k=n.getBoundingBox(S);k?.some((v,A)=>v!==h[A])&&g.set(S,k)}let x=n.userUnit;x!==1&&g.set("UserUnit",x),g.setIfDict("Resources",await this.#s(d,!0,l));let w=null;if(s){let S=await this.#s(s,!0,l);this.#A(S,a),Array.isArray(S)&&S.length>0&&(w=S)}let y=r.document===this.#t?this.#e?.newAnnotationsByPage?.get(n.pageIndex)?.filter(({copyLevel:S})=>(S??0)===o):null;if(y?.length){let{handler:S,task:k,imagesPromises:v}=this.#e,A=new Qr,j=await Wo.saveNewAnnotations(n._createPartialEvaluator(S),this.xrefWrapper,k,y,v,A);for(let[C,{data:I}]of A.items())this.xref[C.num]=I;w||=[];for(let{ref:C}of j.annotations)w.push(C)}if(g.setIfArray("Annots",w),this.useObjectStreams){let S=this.newRefCount,k=[];for(let v=b;v<S;v++)this.xref[v]instanceof kt||k.push(Se.get(v,0));for(let v=0;v<k.length;v+=65535){let A=this.newRef;this.objStreamRefs.add(A.num),this.xref[A.num]=k.slice(v,v+65535)}}return this.currentDocument=null,m}#U(){let e=new Map;for(let r of this.oldPages){if(!r)continue;let{page:s}=r,[i,o,a,c]=s.view,l=a-i,u=c-o;if(l<=0||u<=0)continue;s.rotate%180!==0&&([l,u]=[u,l]);let h=`${l}x${u}`,d=e.get(h);d?d.count++:e.set(h,{width:l,height:u,count:1})}if(e.size===0){let[,,r,s]=RZ;return{width:r,height:s}}let n=null;for(let r of e.values())(!n||r.count>n.count||r.count===n.count&&r.width*r.height>n.width*n.height)&&(n=r);return{width:n.width,height:n.height}}async#V(e,n){let{width:r,height:s}=n,o=r*.1,a=Math.max(1,r-2*o),c=Math.max(1,s-2*o),l=this.newRefCount,{imageStream:u,smaskStream:h,width:d,height:p}=await cZ(e,this.xrefWrapper,{closeBitmap:!0}),m=Math.min(a/d,c/p),g=d*m,b=p*m,x=(r-g)/2,w=(s-b)/2;if(h){let R=this.newRef;this.xref[R.num]=h,u.dict.set("SMask",R)}let y=this.newRef;this.xref[y.num]=u;let S=new Q(this.xrefWrapper);S.set("Im0",y);let k=new Q(this.xrefWrapper);k.set("XObject",S),k.set("ProcSet",[ve.get("PDF"),ve.get("ImageC")]);let v=`q ${Wn(g)} 0 0 ${Wn(b)} ${Wn(x)} ${Wn(w)} cm /Im0 Do Q`,A=new Us(v,new Q(this.xrefWrapper)),j=this.newRef;this.xref[j.num]=A;let C=this.newRef,I=this.xref[C.num]=new Q(this.xrefWrapper);if(I.setIfName("Type","Page"),I.set("MediaBox",[0,0,r,s]),I.set("Resources",k),I.set("Contents",j),this.useObjectStreams){let R=this.newRefCount,E=[];for(let P=l;P<R;P++)this.xref[P]instanceof kt||E.push(Se.get(P,0));for(let P=0;P<E.length;P+=65535){let F=this.newRef;this.objStreamRefs.add(F.num),this.xref[F.num]=E.slice(P,P+65535)}}return C}#Y(){let{newPages:e,rootDict:n,pagesRef:r,pagesDict:s}=this;n.set("Pages",r),s.setIfName("Type","Pages"),s.set("Count",e.length);let i=l1e,o=[{dict:s,kids:e,parentRef:r}];for(;o.length>0;){let{dict:a,kids:c,parentRef:l}=o.pop();if(c.length<=i){a.set("Kids",c);for(let p of c)this.xref[p.num].set("Parent",l);continue}let u=Math.max(i,Math.ceil(c.length/i)),h=[];for(let p=0;p<c.length;p+=u)h.push(c.slice(p,p+u));let d=[];a.set("Kids",d);for(let p of h){let[m,g]=this.newDict;d.push(m),g.setIfName("Type","Pages"),g.set("Parent",l),g.set("Count",p.length),o.push({dict:g,kids:p,parentRef:m})}}}#L(e,n){let r=e.sort(n?([l],[u])=>l<u?-1:l>u?1:0:([l],[u])=>l-u),s=f1e,[i,o]=this.newDict,a=[{dict:o,entries:r,isRoot:!0}],c=n?"Names":"Nums";for(;a.length>0;){let{dict:l,entries:u,isRoot:h}=a.pop();if(u.length<=s){h||l.set("Limits",[u[0][0],u.at(-1)[0]]),l.set(c,u.flat());continue}let d=[],p=Math.max(s,Math.ceil(u.length/s));for(let g=0;g<u.length;g+=p)d.push(u.slice(g,g+p));let m=[];l.set("Kids",m);for(let g of d){let[b,x]=this.newDict;m.push(b),x.set("Limits",[g[0][0],g.at(-1)[0]]),a.push({dict:x,entries:g})}}return i}#X(){let{pageLabels:e}=this;if(!e?.length)return;let{rootDict:n}=this,r=this.#L(this.pageLabels,!1);n.set("PageLabels",r)}async#D(e){let{embeddedFiles:n}=this;for(let r of e){let{embeddedFiles:s,document:{xref:i}}=r;if(s?.size){this.currentDocument=r;for(let[o,a]of s){let c=o;if(n.has(c)){let l=Ht(o,!0);for(let u=1;;u++){let h=Hs(`${l}_${u}`);if(!n.has(h)){c=h;break}}}n.set(c,await this.#s(a,!0,i))}this.currentDocument=null}}}#G(){let{embeddedFiles:e}=this;e.size!==0&&(this.namesDict||([this.namesRef,this.namesDict]=this.newDict,this.rootDict.set("Names",this.namesRef)),this.namesDict.set("EmbeddedFiles",this.#L(Array.from(e.entries()),!0)))}#W(){let{namedDestinations:e}=this;e.size!==0&&(this.namesDict||([this.namesRef,this.namesDict]=this.newDict,this.rootDict.set("Names",this.namesRef)),this.namesDict.set("Dests",this.#L(Array.from(e,([n,r])=>[Hs(n),r]),!0)))}#Z(){let{structTreeKids:e}=this;if(!e?.length)return;let{rootDict:n}=this,r=this.newRef,s=this.xref[r.num]=new Q;s.setIfName("Type","StructTreeRoot"),s.setIfArray("K",e);for(let i of e){let o=this.xref[i.num],a=o.get("Type");(!a||It(a,"StructElem"))&&o.set("P",r)}if(this.parentTree.size>0){let i=this.#L(Array.from(this.parentTree.entries()),!1);this.xref[i.num].setIfName("Type","ParentTree"),s.set("ParentTree",i);let a=0;for(let c of this.parentTree.keys())a=Math.max(a,c+1);s.set("ParentTreeNextKey",a)}if(this.idTree.size>0){let i=this.#L(Array.from(this.idTree.entries()),!0);this.xref[i.num].setIfName("Type","IDTree"),s.set("IDTree",i)}if(this.classMap.size>0){let i=this.newRef;this.xref[i.num]=this.classMap,s.set("ClassMap",i)}if(this.roleMap.size>0){let i=this.newRef;this.xref[i.num]=this.roleMap,s.set("RoleMap",i)}if(this.namespaces.size>0){let i=this.newRef;this.xref[i.num]=Array.from(this.namespaces.values()),s.set("Namespaces",i)}if(this.structTreeAF.length>0){let i=this.newRef;this.xref[i.num]=this.structTreeAF,s.set("AF",i)}if(this.structTreePronunciationLexicon.length>0){let i=this.newRef;this.xref[i.num]=this.structTreePronunciationLexicon,s.set("PronunciationLexicon",i)}n.set("StructTreeRoot",r)}#Q(){if(this.fields.length===0)return;let{rootDict:e}=this,n=this.newRef,r=this.xref[n.num]=new Q;e.set("AcroForm",n),r.set("Fields",this.fields),this.acroFormNeedAppearances&&r.set("NeedAppearances",!0),this.acroFormSigFlags>0&&r.set("SigFlags",this.acroFormSigFlags),r.setIfArray("CO",this.acroFormCalculationOrder),r.setIfDefined("DR",this.acroFormDefaultResources),this.acroFormDefaultAppearance&&r.set("DA",this.acroFormDefaultAppearance),this.acroFormQ>0&&r.set("Q",this.acroFormQ)}async#_(){let{rootDict:e}=this;e.setIfName("Type","Catalog"),e.setIfName("Version",this.version),this.#Q(),this.#Y(),this.#X(),this.#G(),this.#W(),this.#Z(),await this.#E()}#J(){let e=new Map;if(this.isSingleFile){let n=this.oldPages.find(i=>!!i),{xref:{trailer:r}}=n.documentData.document,s=r.get("Info");for(let[i,o]of s||[])typeof o=="string"&&e.set(i,Ht(o))}e.delete("ModDate"),e.set("CreationDate",Yf()),e.set("Creator","PDF.js"),e.set("Producer","Firefox"),this.author&&e.set("Author",this.author),this.title&&e.set("Title",this.title);for(let[n,r]of e)this.infoDict.set(n,Hs(r));return e}async#ee(){if(!this.isSingleFile)return[null,null,null];let e=this.oldPages.find(a=>!!a),{documentData:n}=e,{document:{xref:{trailer:r,encrypt:s}}}=n;if(!r.has("Encrypt"))return[null,null,null];let i=r.get("Encrypt");if(!(i instanceof Q))return[null,null,null];this.currentDocument=n;let o=[await this.#r(i,r.xref),s,r.get("ID")];return this.currentDocument=null,o}async#re(){let e=new Qr;e.put(Se.get(0,65535),{data:null});for(let n=1,r=this.xref.length;n<r;n++)this.objStreamRefs?.has(n)?await this.#se(Se.get(n,0),this.xref[n],e):e.put(Se.get(n,0),{data:this.xref[n]});return[e,this.newRef]}async#se(e,n,r){let s=[""],i=[],o=0,a=[];for(let u=0,h=n.length;u<h;u++){let d=n[u];r.put(d,{data:null,objStreamRef:e,index:u}),i.push(`${d.num} ${o}`);let p=this.xref[d.num];await lw(p,a,null);let m=a.join("");a.length=0,s.push(m),o+=m.length+1}s[0]=i.join(`
|
|
214
214
|
`);let c=new Q;c.setIfName("Type","ObjStm"),c.set("N",n.length),c.set("First",s[0].length+1);let l=new Us(s.join(`
|
|
215
215
|
`),c);r.put(e,{data:l})}async writePDF(){await this.#_();let e=this.#J(),[n,r,s]=await this.#ee(),[i,o]=await this.#re(),a=Sr(`%PDF-${this.version}
|
|
216
|
-
%\xFA\xDE\xFA\xCE`);return FZ({originalData:a,changes:i,xrefInfo:{startXRef:null,rootRef:this.rootRef,infoRef:this.infoRef,encryptRef:n,newRef:o,fileIds:s||[null,null],infoMap:e},useXrefStream:this.useObjectStreams,xref:{encrypt:r,encryptRef:n}})}},QN=class{static{f(this,"BasePDFStream")}#e=null;#t=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(e,n,r){this._source=e,this.#e=n,this.#t=r}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return xr(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#e(this)}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;let r=new this.#t(this,e,n);return this._rangeReaders.add(r),r}cancelAllRequests(e){this._fullReader?.cancel(e);for(let n of new Set(this._rangeReaders))n.cancel(e)}},eM=class{static{f(this,"BasePDFStreamReader")}onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(e){this._stream=e}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){rn("Abstract method `read` called")}cancel(e){rn("Abstract method `cancel` called")}},tM=class{static{f(this,"BasePDFStreamRangeReader")}_stream=null;constructor(e,n,r){this._stream=e}async read(){rn("Abstract method `read` called")}cancel(e){rn("Abstract method `cancel` called")}},nM=class extends QN{static{f(this,"PDFWorkerStream")}constructor(e){super(e,rM,sM)}},rM=class extends eM{static{f(this,"PDFWorkerStreamReader")}_reader=null;constructor(e){super(e);let{msgHandler:n}=e._source,r=n.sendWithStream("GetReader");this._reader=r.getReader(),n.sendWithPromise("ReaderHeadersReady").then(s=>{this._contentLength=s.contentLength,this._isStreamingSupported=s.isStreamingSupported,this._isRangeSupported=s.isRangeSupported,this._headersCapability.resolve()},this._headersCapability.reject)}async read(){let{value:e,done:n}=await this._reader.read();return n?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}},sM=class extends tM{static{f(this,"PDFWorkerStreamRangeReader")}_reader=null;constructor(e,n,r){super(e,n,r);let{msgHandler:s}=e._source,i=s.sendWithStream("GetRangeReader",{begin:n,end:r});this._reader=i.getReader()}async read(){let{value:e,done:n}=await this._reader.read();return n?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}},$a=class{static{f(this,"WorkerTask")}#e=Promise.withResolvers();terminated=!1;constructor(e){this.name=e}get finished(){return this.#e.promise}finish(){this.#e.resolve()}terminate(){this.terminated=!0}ensureNotTerminated(){if(this.terminated)throw new Error("Worker task was terminated")}},iM=class{static{f(this,"WorkerMessageHandler")}static{typeof window>"u"&&!m0e&&typeof self<"u"&&typeof self.postMessage=="function"&&"onmessage"in self&&this.initializeFromPort(self)}static setup(e,n){let r=!1;e.on("test",s=>{r||(r=!0,e.send("test",s instanceof Uint8Array))}),e.on("configure",s=>{S0e(s.verbosity)}),e.on("GetDocRequest",s=>this.createDocumentHandler(s,n))}static createDocumentHandler(e,n){let r,s=!1,i=null,o=new Set,a=k0e(),{docId:c,apiVersion:l}=e,u="6.3.289";if(l!==u)throw new Error(`The API version "${l}" does not match the Worker version "${u}".`);let h=f((k,v)=>`The \`${k}.prototype\` contains unexpected enumerable property "${v}", thus breaking e.g. \`for...in\` iteration of ${k}s.`,"buildMsg");for(let k in{})throw new Error(h("Object",k));for(let k in[])throw new Error(h("Array",k));let d=c+"_worker",p=new AS(d,c,n);function m(){if(s)throw new Error("Worker was terminated")}f(m,"ensureNotTerminated");function g(k){o.add(k)}f(g,"startWorkerTask");function b(k){k.finish(),o.delete(k)}f(b,"finishWorkerTask");async function x(k){await r.initDocument(k);let v=await r.ensureDoc("isPureXfa");if(v){let I=new $a("loadXfaResources");g(I),await r.ensureDoc("loadXfaResources",[p,I]),b(I)}let[A,j]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("fingerprints")]),C=v?await r.ensureDoc("htmlForXfa"):null;return{numPages:A,fingerprints:j,htmlForXfa:C}}f(x,"loadDocument");async function w({data:k,password:v,disableAutoFetch:A,rangeChunkSize:j,docBaseUrl:C,enableXfa:I,evaluatorOptions:R}){let E={source:null,disableAutoFetch:A,docBaseUrl:C,docId:c,enableXfa:I,evaluatorOptions:R,handler:p,length:0,password:v,rangeChunkSize:j};if(k)return E.source=k,new yx(E);let P=new nM({msgHandler:p}),F=P.getFullReader(),{promise:_,resolve:B,reject:W}=Promise.withResolvers(),Y,K=[];i=f(ee=>P.cancelAllRequests(ee),"cancelXHRs"),F.headersReady.then(()=>{if(F.isRangeSupported){E.source=P,E.length=F.contentLength,E.disableAutoFetch||=F.isStreamingSupported,Y=new KN(E);for(let ee of K)Y.sendProgressiveData(ee);K=null,B(Y),i=null}}).catch(ee=>{W(ee),i=null});async function U(){let ee=0;for(;;){let{value:V,done:D}=await F.read();if(m(),D)break;ee+=V.byteLength,F.isStreamingSupported||p.send("DocProgress",{loaded:ee,total:F.contentLength}),Y?Y.sendProgressiveData(V):K.push(V)}Y||(E.source=IJ(K),K=null,Y=new yx(E),B(Y)),i=null}return f(U,"readData"),U().catch(ee=>{W(ee),i=null}),_}f(w,"getPdfManager");async function y(k){let v=new $a(`PasswordException: response ${k.code}`);g(v);try{return(await p.sendWithPromise("PasswordRequest",k)).password}finally{Promise.resolve().then(()=>{b(v)})}}f(y,"getPassword");function S(k){function v(C){m(),p.send("GetDoc",{pdfInfo:C})}f(v,"onSuccess");function A(C){s||(C instanceof Ja?y(C).then(I=>{r.updatePassword(I),j()}).catch(()=>{p.send("DocException",C)}):p.send("DocException",Bo(C)))}f(A,"onFailure");function j(){m(),x(!1).then(v,function(C){if(m(),!(C instanceof kl)){A(C);return}r.requestLoadedStream().then(function(){m(),x(!0).then(v,A)},A)})}f(j,"pdfManagerReady"),m(),w(k).then(function(C){if(s)throw C.terminate(new _s("Worker was terminated.")),new Error("Worker was terminated");r=C,r.requestLoadedStream(!0).then(I=>{p.send("DataLoaded",{length:I.bytes.byteLength})},()=>{})}).then(j,A)}return f(S,"setupDoc"),p.on("GetPage",async function({pageIndex:k}){let v=await r.getPage(k),[A,j,C,I]=await Promise.all([r.ensure(v,"rotate"),r.ensure(v,"ref"),r.ensure(v,"userUnit"),r.ensure(v,"view")]);return{rotate:A,ref:j,refStr:j?.toString()??null,userUnit:C,view:I}}),p.on("GetPageIndex",function({num:k,gen:v}){return r.ensureCatalog("getPageIndex",[Se.get(k,v)])}),p.on("GetDestinations",function(){return r.ensureCatalog("destinations")}),p.on("GetDestination",function({id:k}){return r.ensureCatalog("getDestination",[k])}),p.on("GetPageLabels",function(){return r.ensureCatalog("pageLabels")}),p.on("GetPageLayout",function(){return r.ensureCatalog("pageLayout")}),p.on("GetPageMode",function(){return r.ensureCatalog("pageMode")}),p.on("GetViewerPreferences",function(){return r.ensureCatalog("viewerPreferences")}),p.on("GetOpenAction",function(){return r.ensureCatalog("openAction")}),p.on("GetAttachments",function(){return r.ensureCatalog("attachments")}),p.on("GetAttachmentContent",async function(k){let v;for(;;){let A=v?await y(v):null;try{return A&&r.updatePassword(A),await r.ensureCatalog("attachmentContent",[k])}catch(j){if(j instanceof Ja){v=j;continue}throw j}}}),p.on("GetDocJSActions",function(){return r.ensureCatalog("jsActions")}),p.on("GetPageJSActions",async function({pageIndex:k}){let v=await r.getPage(k);return r.ensure(v,"jsActions")}),p.on("GetAnnotationsByType",async function({types:k,pageIndexesToSkip:v}){let[A,j]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("annotationGlobals")]);if(!j)return null;let C=[],I=[],R=null;try{for(let P=0,F=A;P<F;P++)v?.has(P)||(R||(R=new $a("GetAnnotationsByType"),g(R)),C.push(r.getPage(P).then(_=>_.collectAnnotationsByType(p,R,k,I,j))));return await Promise.all(C),(await Promise.all(I)).filter(Boolean)}finally{R&&b(R)}}),p.on("GetOutline",function(){return r.ensureCatalog("documentOutline")}),p.on("GetOptionalContentConfig",function(){return r.ensureCatalog("optionalContentConfig")}),p.on("GetPermissions",function(){return r.ensureCatalog("permissions")}),p.on("GetMetadata",function(){return Promise.all([r.ensureDoc("documentInfo"),r.ensureCatalog("metadata"),r.ensureCatalog("hasStructTree")])}),p.on("GetMarkInfo",function(){return r.ensureCatalog("markInfo")}),p.on("GetData",async function(){return(await r.requestLoadedStream()).bytes}),p.on("GetAnnotations",async function({pageIndex:k,intent:v}){let A=await r.getPage(k),j=new $a(`GetAnnotations: page ${k}`);g(j);try{return await A.getAnnotationsData(p,j,v)}finally{b(j)}}),p.on("GetFieldObjects",async function(){return(await r.ensureDoc("fieldObjects"))?.allFields||null}),p.on("GetSignatures",function(){return r.ensureDoc("signatures")}),p.on("GetSignatureData",function(k){return r.ensureDoc("getSignatureData",[k])}),p.on("HasJSActions",function(){return r.ensureDoc("hasJSActions")}),p.on("GetCalculationOrderIds",function(){return r.ensureDoc("calculationOrderIds")}),p.on("ExtractPages",async function({pageInfos:k,annotationStorage:v}){if(!k)return te("extractPages: nothing to extract."),null;Array.isArray(k)||(k=[k]);let A=0;for(let C of k)if(!C.image)if(C.document===null)C.document=r.pdfDocument;else if(ArrayBuffer.isView(C.document)){let I=new yx({source:C.document,docId:`${c}_extractPages_${A++}`,handler:p,password:C.password??null,evaluatorOptions:Object.assign({},r.evaluatorOptions)}),R=!1,E=!0;for(;;)try{await I.requestLoadedStream(),await I.initDocument(R);break}catch(F){if(F instanceof kl)if(R===!1){R=!0;continue}else E=!1,te("extractPages: XRefParseException.");else if(F instanceof Ja)try{let _=await y(F);I.updatePassword(_)}catch{E=!1,te("extractPages: invalid password.")}else E=!1,te("extractPages: invalid document.");if(!E)break}E||(C.document=null),await I.ensureDoc("isPureXfa")?(C.document=null,te("extractPages does not support pure XFA documents.")):C.document=I.pdfDocument}else te("extractPages: invalid document.");let j;try{let C=new ZN;return j=new $a(`ExtractPages: ${k.length} page(s)`),g(j),await C.extractPages(k,v,r.pdfDocument,p,j)}catch(C){return te(`extractPages: "${C}".`),null}finally{j&&b(j)}}),p.on("SaveDocument",async function({isPureXfa:k,numPages:v,annotationStorage:A,filename:j}){let C=[r.requestLoadedStream(),r.ensureCatalog("acroForm"),r.ensureCatalog("acroFormRef"),r.ensureDoc("startXRef"),r.ensureDoc("xref"),r.ensureCatalog("structTreeRoot")],I=new Qr,R=[],E=k?null:aM(A),[P,F,_,B,W,Y]=await Promise.all(C),K=W.trailer.getRaw("Root")||null,U;if(E){Y?await Y.canUpdateStructTree({pdfManager:r,newAnnotationsByPage:E})&&(U=Y):await Bx.canCreateStructureTree({catalogRef:K,pdfManager:r,newAnnotationsByPage:E})&&(U=null);let X=Wo.generateImages(A.values(),W,r.evaluatorOptions.isOffscreenCanvasSupported),oe=U===void 0?R:[];for(let[pe,ae]of E)oe.push(r.getPage(pe).then(N=>{let re=new $a(`Save (editor): page ${pe}`);return g(re),N.saveNewAnnotations(p,re,ae,X,I).finally(()=>{b(re)})}));U===null?R.push(Promise.all(oe).then(async()=>{await Bx.createStructureTree({newAnnotationsByPage:E,xref:W,catalogRef:K,pdfManager:r,changes:I})})):U&&R.push(Promise.all(oe).then(async()=>{await U.updateStructureTree({newAnnotationsByPage:E,pdfManager:r,changes:I})}))}if(k)R.push(r.ensureDoc("serializeXfaData",[A]));else for(let X=0;X<v;X++)R.push(r.getPage(X).then(function(oe){let pe=new $a(`Save: page ${X}`);return g(pe),oe.save(p,pe,A,I).finally(()=>{b(pe)})}));let ee=await Promise.all(R),V=null;if(k){if(V=ee[0],!V)return P.bytes}else if(I.size===0)return P.bytes;let D=_&&F instanceof Q&&I.values().some(X=>X.needAppearances),G=F instanceof Q&&F.get("XFA")||null,z=null,M=!1;if(Array.isArray(G)){for(let X=0,oe=G.length;X<oe;X+=2)G[X]==="datasets"&&(z=G[X+1],M=!0);z===null&&(z=W.getNewTemporaryRef())}else G&&te("Unsupported XFA type.");let L=Object.create(null);if(W.trailer){let X=new Map,oe=W.trailer.get("Info")||null;if(oe instanceof Q)for(let[pe,ae]of oe)typeof ae=="string"&&X.set(pe,Ht(ae));L={rootRef:K,encryptRef:W.trailer.getRaw("Encrypt")||null,newRef:W.getNewTemporaryRef(),infoRef:W.trailer.getRaw("Info")||null,infoMap:X,fileIds:W.trailer.get("ID")||null,startXRef:B,filename:j}}return FZ({originalData:P.bytes,xrefInfo:L,changes:I,xref:W,hasXfa:!!G,xfaDatasetsRef:z,hasXfaDatasetsEntry:M,needAppearances:D,acroFormRef:_,acroForm:F,xfaData:V,useXrefStream:_p(W.topDict,"XRef")}).finally(()=>{W.resetNewTemporaryRef()})}),p.on("GetOperatorList",function({pageId:k,pageIndex:v,intent:A,cacheKey:j,annotationStorage:C,modifiedIds:I},R){r.getPage(k).then(function(E){let P=new $a(`GetOperatorList: page ${v}`);g(P);let F=a>=vx.INFOS?Date.now():0;E.getOperatorList({handler:p,sink:R,task:P,intent:A,cacheKey:j,annotationStorage:C,modifiedIds:I,pageIndex:v}).then(_=>{F&&Cn(`${P.name}; time=${Date.now()-F}ms, len=${_.length}`),R.close()},_=>{P.terminated||R.error(_)}).finally(()=>{b(P)})})}),p.on("GetTextContent",function({pageId:k,pageIndex:v,includeMarkedContent:A,disableNormalization:j},C){r.getPage(k).then(function(I){let R=new $a("GetTextContent: page "+v);g(R);let E=a>=vx.INFOS?Date.now():0;I.extractTextContent({handler:p,task:R,sink:C,includeMarkedContent:A,disableNormalization:j}).then(()=>{E&&Cn(`${R.name}; time=${Date.now()-E}ms`),C.close()},P=>{R.terminated||C.error(P)}).finally(()=>{b(R)})})}),p.on("GetStructTree",async function({pageIndex:k}){let v=await r.getPage(k);return r.ensure(v,"getStructTree")}),p.on("FontFallback",function({id:k}){return r.fontFallback(k,p)}),p.on("Cleanup",function(){return r.cleanup(!0)}),p.on("Terminate",async function(){s=!0;let k=[];if(r){r.terminate(new _s("Worker was terminated."));let v=r.cleanup();k.push(v),r=null}else mM();i?.(new _s("Worker was terminated."));for(let v of o)k.push(v.finished),v.terminate();await Promise.all(k),p.destroy(),p=null}),p.on("Ready",function(){S(e),e=null}),d}static initializeFromPort(e){let n=new AS("worker","main",e);this.setup(n,e),n.send("ready",null)}};globalThis.pdfjsWorker={WorkerMessageHandler:iM}});function u1e(t){let e=t.width??ru.width;if(t.bottom!=null){let n=t.maxHeight??ru.maxHeight;return{pageIndex:t.pageIndex,x:t.x,y:t.bottom-n,w:e,h:n,align:"bottom"}}return{pageIndex:t.pageIndex,x:t.x,y:t.y??0,w:e,h:t.maxHeight??1/0,align:"top"}}function h1e(t,e){let n=Math.min(t.w,t.h/e),r=n*e,s=t.align==="bottom"?t.y+t.h-r:t.y;return{pageIndex:t.pageIndex,x:t.x,y:s,width:n,height:r}}var ru,NZ,jM=H(()=>{"use strict";ru={width:170,maxHeight:55};f(u1e,"frameFromPlacement");f(h1e,"boxInFrame");NZ=f((t,e)=>h1e(u1e(t),e),"fitPlacement")});var HZ={};$l(HZ,{assertPdfReadable:()=>CM,locateSignatureSpot:()=>pw,normalizeText:()=>_Z,placementAbove:()=>zZ});function zZ(t){return{pageIndex:t.pageIndex,x:t.x+8,bottom:t.baseline-18,width:ru.width,maxHeight:ru.maxHeight}}function b1e(t,e){let[n,r,s,i]=e.transform,o=[],a=[];for(let u of t){if(typeof u.str!="string"||!u.str.trim()||!u.transform)continue;let h=u.transform,[d,p]=e.convertToViewportPoint(h[4],h[5]),m=Math.hypot(h[2],h[3])||u.height||10,g={str:u.str,x:d,y:p,w:Math.max(0,u.width??0),size:m},b=n*h[0]+s*h[1],x=r*h[0]+i*h[1];(b>0&&Math.abs(x)<=Math.abs(b)*.05?o:a).push(g)}o.sort((u,h)=>u.y-h.y||u.x-h.x);let c=[];for(let u of o){let h=c[c.length-1];h&&Math.abs(u.y-h[0].y)<=Math.max(1,.3*Math.min(u.size,h[0].size))?h.push(u):c.push([u])}let l=[];for(let u of[...c,...a.map(h=>[h])]){u.sort((g,b)=>g.x-b.x);let h={text:"",at:[]},d=null,p=-1/0,m=f((g,b,x)=>{if(/\s/.test(g)){if(!h.text||h.text.endsWith(" "))return;g=" "}h.text+=g,h.at.push({x:b,y:x})},"push");for(let g of u){if(d&&g.str===d.str&&Math.abs(g.x-d.x)<.5*g.size)continue;let b=g.x-p;d&&b>g1e*g.size?(l.push(h),h={text:"",at:[]}):d&&b>m1e*g.size&&m(" ",g.x,g.y);let x=[...g.str];x.forEach((w,y)=>{let S=g.x+g.w*y/x.length;for(let k of LZ(w))m(k,S,g.y)}),d=g,p=Math.max(p,g.x+g.w)}l.push(h)}for(let u of l)u.text.endsWith(" ")&&(u.text=u.text.slice(0,-1),u.at.pop());return l.filter(u=>u.text)}function MZ(t,e){return e?t.pageIndex!==e.pageIndex?t.pageIndex>e.pageIndex:Math.abs(t.y-e.y)>1?t.y>e.y:t.x>e.x:!0}function x1e(t,e){let n=/^[^\p{L}\p{N}]*/u.exec(t)?.[0].length??0,r=t.slice(n);return!r.startsWith(e)||r.length>e.length+p1e||/[\p{L}\p{N}]/u.test(r[e.length]??"")?-1:n}async function BZ(t){let e=_I({data:new Uint8Array(t),useSystemFonts:!1,disableFontFace:!0,verbosity:0});try{let n=await e.promise;if(await n.getPermissions()!==null)throw new Mt("ENCRYPTED");return{task:e,doc:n}}catch(n){if(await e.destroy(),n instanceof Mt)throw n;let r=n?.name;throw r==="PasswordException"?new Mt("ENCRYPTED"):r==="InvalidPDFException"||r==="FormatError"||r==="UnknownErrorException"?new Mt("NOT_PDF"):n}}async function CM(t){await(await BZ(t)).task.destroy()}async function pw(t,e){let{task:n,doc:r}=await BZ(t);try{let s=d1e(e??"");if(s){let c=null;for(let l=r.numPages;l>=1;l--){let u=await r.getPage(l),h=u.getViewport({scale:1}),{items:d}=await u.getTextContent(),p=null,m=null;for(let g of b1e(d,h)){let b=x1e(g.text,s);if(b>=0){let w={pageIndex:l-1,...g.at[b]};MZ(w,p)&&(p=w)}let x=g.text.lastIndexOf(s);if(x>=0){let w={pageIndex:l-1,...g.at[x]};MZ(w,m)&&(m=w)}}if(p){c=p;break}c??=m}if(c){let l={pageIndex:c.pageIndex,x:Math.round(c.x),baseline:Math.round(c.y)};return{placement:zZ(l),anchor:{text:e??null,found:!0,page:c.pageIndex+1},pageCount:r.numPages}}}let i=await r.getPage(r.numPages),{width:o,height:a}=i.getViewport({scale:1});return{placement:{pageIndex:r.numPages-1,x:Math.round((o-ru.width)/2),bottom:Math.round(a-96),width:ru.width,maxHeight:ru.maxHeight},anchor:{text:e||null,found:!1,page:r.numPages},pageCount:r.numPages}}finally{await n.destroy()}}var LZ,_Z,d1e,p1e,m1e,g1e,LS=H(()=>{"use strict";hY();DZ();jM();Vl();f(zZ,"placementAbove");LZ=f(t=>t.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase(),"fold"),_Z=f(t=>LZ(t).replace(/\s+/g," ").trim(),"normalizeText"),d1e=f(t=>_Z(t).replace(/\s*:$/,"").trim(),"needleOf"),p1e=60,m1e=.15,g1e=3;f(b1e,"pageSegments");f(MZ,"later");f(x1e,"labelStart");f(BZ,"openReadable");f(CM,"assertPdfReadable");f(pw,"locateSignatureSpot")});var ZZ={};$l(ZZ,{CLOSE_GRACE_MS:()=>LM,MAX_PENDING:()=>PM,MAX_UPLOAD:()=>C0,createAwaitingSignSession:()=>DM,createSession:()=>nm,documentBytes:()=>$S,getSession:()=>iu,nextOutputPath:()=>FM,outputDir:()=>BS,pageOpened:()=>OM,prepareSignSession:()=>US,publicState:()=>Xi,readPdf:()=>gw,safePdfName:()=>XZ,sameToken:()=>su,signedBytes:()=>VS,startDetached:()=>GS,uiCancel:()=>rm,uiClose:()=>_M,uiConfirm:()=>vw,uiDeleteSignature:()=>yw,uiDocumentChunk:()=>NM,uiFinish:()=>T0,uiReveal:()=>Sw,uiSaveSignature:()=>ww,uiSetPrefs:()=>xw,uiSignedChunk:()=>zM,uiState:()=>mw,uiUploadChunk:()=>bw,waitForClose:()=>O1e,waitForSession:()=>HS});import{readFileSync as VZ,writeFileSync as w1e,existsSync as GZ}from"node:fs";import{randomBytes as WZ,timingSafeEqual as y1e}from"node:crypto";import{basename as Qp,dirname as _S,extname as v1e,join as qM,sep as S1e}from"node:path";import{EventEmitter as k1e}from"node:events";import{spawn as A1e}from"node:child_process";import{homedir as EM}from"node:os";function nm({kind:t,client:e,closeOnSave:n=!0}){let r=0;for(let i of em.values())i.status==="pending"&&r++;if(r>=PM)throw new Mt("TOO_MANY_OPEN",{max:PM});let s={id:WZ(6).toString("hex"),kind:t,status:"pending",client:e,openToken:TM(),viewToken:TM(),cookie:TM(),opened:!1,closed:!1,openPages:0,signing:!1,createdAt:Date.now(),closeOnSave:n,saved:[],result:null,file:null,original:null,placements:null,anchor:null,anchorText:null,hasDigitalSignature:!1,awaiting:!1,uploaded:!1,upload:null};return em.set(s.id,s),setTimeout(()=>{s.status==="pending"&&(s.kind==="pad"&&s.saved.length?T0(s):tm(s,"expired",null))},j1e).unref(),s}function tm(t,e,n){return t.status!=="pending"?!1:(t.status=e,t.result=n,t.upload=null,j0.emit(t.id),setTimeout(()=>t.original=null,C1e).unref(),setTimeout(()=>em.delete(t.id),T1e).unref(),!0)}function OM(t){t.opened=!0,t.openPages++,t.closed=!1}function HS(t,e){let n=em.get(t);return!n||n.status!=="pending"?Promise.resolve(n):new Promise(r=>{let s=f(()=>{clearTimeout(i),j0.off(t,s),r(n)},"done"),i=setTimeout(s,e);j0.once(t,s)})}function Xi(t){return t?{request_id:t.id,kind:t.kind,status:t.status,...t.kind==="sign"&&t.awaiting?{awaiting_document:!0}:{},...t.kind==="sign"&&t.anchor?{anchor_found:t.anchor.found}:{},...t.result??{}}:{status:"unknown"}}function FM(t){let e=v1e(t),n=qM(_S(t),Qp(t,e)),r=`${n}.assinado${e}`;for(let s=2;GZ(r);s++)r=`${n}.assinado-${s}${e}`;return r}function mw(t){let e=null;return t.kind==="sign"&&(e=t.awaiting?{awaiting:!0,maxBytes:C0,outputDir:BS(),outputDirLabel:$Z(BS())}:{name:Qp(t.file),outputName:Qp(FM(t.file)),outputDir:_S(t.file),outputDirLabel:$Z(_S(t.file)),uploaded:t.uploaded,bytes:t.original?.length??0,hasDigitalSignature:t.hasDigitalSignature,anchor:t.anchor,placements:t.placements}),{kind:t.kind,status:t.status,result:t.status==="pending"?null:Xi(t),document:e,signatures:gk(),prefs:Wm()}}function gw(t){let e;try{e=VZ(t)}catch(n){let r=n.code;throw r==="ENOENT"?new Mt("FILE_NOT_FOUND",{file:t}):r==="EISDIR"?new Mt("NOT_PDF"):n}return KZ(e),e}function KZ(t){if(t.subarray(0,5).toString()!=="%PDF-")throw new Mt("NOT_PDF")}function US({file:t,bytes:e=gw(t),placements:n,anchor:r=null,client:s}){let i=nm({kind:"sign",client:s});return i.file=t,i.original=e,i.placements=n,i.anchor=r,i.hasDigitalSignature=UC(e),i}function DM({anchorText:t,client:e}){let n=nm({kind:"sign",client:e});return n.awaiting=!0,n.anchorText=t||"CONTRATANTE",n}function YZ(t){if(!(t.status==="pending"||t.kind==="pad"&&t.status==="signed"))throw new Mt("SESSION_CLOSED",{status:t.status})}function $S(t){if(t.kind!=="sign"||!t.original)throw new Mt("NO_DOCUMENT");return t.original}function JZ(t,e,n){let r=Math.max(0,Math.min(Number(e)||0,t.length)),s=Math.min(t.length,r+Math.min(Number(n)||UZ,UZ));return{total:t.length,offset:r,data:t.subarray(r,s).toString("base64")}}async function bw(t,{name:e,size:n,offset:r=0,data:s}){if(t.status!=="pending")throw new Mt("SESSION_CLOSED",{status:t.status});if(t.kind!=="sign"||!t.awaiting)throw new Mt("NOT_AWAITING");if(n=Number(n),!Number.isInteger(n)||n<5)throw new Mt("UPLOAD_EMPTY");if(n>C0)throw new Mt("UPLOAD_TOO_BIG",{mb:C0/1024/1024});let i=Buffer.isBuffer(s)?s:Buffer.from(String(s??""),"base64");(Number(r)===0||!t.upload)&&(t.upload={name:XZ(e),size:n,parts:[],received:0});let o=t.upload;if(o.size!==n||Number(r)!==o.received)throw new Mt("UPLOAD_OUT_OF_ORDER");if(o.received+i.length>n)throw new Mt("UPLOAD_OVERFLOW");if(o.parts.push(i),o.received+=i.length,o.received<n)return{received:o.received,total:n,done:!1};let a=Buffer.concat(o.parts);t.upload=null,KZ(a);let{placement:c,anchor:l}=await pw(a,t.anchorText);if(t.status!=="pending")throw new Mt("SESSION_CLOSED",{status:t.status});return t.original=a,t.file=qM(BS(),o.name),t.placements=[c],t.anchor=l,t.hasDigitalSignature=UC(a),t.awaiting=!1,t.uploaded=!0,Yl({event:"document_received",name:o.name,bytes:a.length,sha256:$c(a),client:t.client}),{received:n,total:n,done:!0}}function E1e(t){if(!Array.isArray(t)||!t.length||t.length>I1e)throw new Mt("EMPTY_DRAWING");let e=0;for(let n of t){if(!Array.isArray(n)||!n.length)throw new Mt("EMPTY_DRAWING");if(e+=n.length,e>R1e)throw new Mt("EMPTY_DRAWING");for(let r of n)if(!Array.isArray(r)||r.length<2||r.length>3||!r.every(s=>typeof s=="number"&&Number.isFinite(s)&&Math.abs(s)<1e5))throw new Mt("EMPTY_DRAWING")}}function ww(t,{label:e,kind:n,strokes:r}){YZ(t),E1e(r);let s=bk({label:e,kind:n,strokes:r});return Yl({event:"signature_created",signature:s.id,label:s.label,client:t.client}),t.saved.push(s),t.kind==="pad"&&t.closeOnSave&&t.status==="pending"&&tm(t,"signed",{signature_id:s.id,signature_label:s.label,signatures_saved:1}),s}function yw(t,{id:e}){YZ(t);let n=xk(e);return t.saved=t.saved.filter(r=>r.id!==e),Yl({event:"signature_deleted",signature:n.id,label:n.label,client:t.client}),n}function T0(t){if(t.status==="pending"){let e=t.saved.at(-1);t.kind==="pad"&&e?tm(t,"signed",{signature_id:e.id,signature_label:e.label,signatures_saved:t.saved.length}):tm(t,"cancelled",null)}return Xi(t)}function rm(t){return t.status==="pending"&&tm(t,"cancelled",null),Xi(t)}function P1e(t){if(!Array.isArray(t)||t.length===0||t.length>500)throw new Mt("INVALID_PLACEMENT");return t.map(e=>{let n={pageIndex:Number(e?.pageIndex),x:Number(e?.x),y:Number(e?.y),width:Number(e?.width)};if(!Number.isInteger(n.pageIndex)||n.pageIndex<0||![n.x,n.y,n.width].every(Number.isFinite)||n.width<10||n.width>2e3)throw new Mt("INVALID_PLACEMENT");return n})}async function vw(t,{signatureId:e,placements:n,ink:r,pen:s}){if(t.kind!=="sign")throw new Mt("NOT_A_SIGN_SESSION");if(t.status!=="pending"||t.signing)throw new Mt("SESSION_CLOSED",{status:t.signing?"signing":t.status});if(t.awaiting||!t.original||!t.file||!t.placements)throw new Mt("NO_DOCUMENT");let i=Wm(),o=r??i.ink,a=s??i.pen;if(!G0(o))throw new Mt("INVALID_INK");if(!V0(a))throw new Mt("INVALID_PEN");let c=Gm(e),l=$m(c.strokes,RB(a)),u=l.height/l.width,h=Array.isArray(n)&&n.length?P1e(n):t.placements.map(m=>NZ(m,u)),d=t.original,p=t.file;t.signing=!0;try{let{bytes:m}=await yX({pdfBytes:d,signature:l,placements:h,mode:"incremental",color:EB(o)});if(t.status!=="pending")throw new Mt("SESSION_CLOSED",{status:t.status});let g=FM(p);w1e(g,m,{flag:"wx"});let b=[...new Set(h.map(w=>w.pageIndex+1))],x;try{wk(c.id),x=Yl({event:"document_signed",file:t.uploaded?null:p,received_as:t.uploaded?Qp(p):void 0,output:g,sha256_original:$c(d),sha256_signed:$c(m),signature:c.id,label:c.label,ink:o,pen:a,pages:b,placements:h.map(w=>({page:w.pageIndex+1,x:IM(w.x),y:IM(w.y),width:IM(w.width)})),client:t.client}).hash.slice(0,12)}catch(w){console.error("[labsign] assinado, mas o registro de auditoria falhou:",w?.message??w)}return tm(t,"signed",{signed_file:g,sha256_original:$c(d),sha256_signed:$c(m),pages:b,signature_label:c.label,audit_id:x,original_preserved_as_prefix:!0}),Xi(t)}finally{t.signing=!1}}function MM(t){if(t.kind!=="sign"||t.status!=="signed"||!t.result?.signed_file)throw new Mt("NOT_SIGNED_YET");return t.result.signed_file}async function Sw(t){let e=MM(t);if(process.env.LABSIGN_NO_OPEN==="1")return{revealed:!1,file:e};let n=process.platform==="win32",[r,s]=process.platform==="darwin"?["open",["-R",e]]:n?["explorer.exe",[`/select,"${e}"`]]:["xdg-open",[_S(e)]];return{revealed:await GS(r,s,{windowsVerbatimArguments:n}),file:e}}function GS(t,e,n={}){return new Promise(r=>{try{let s=A1e(t,e,{stdio:"ignore",detached:!0,windowsHide:!0,...n});s.once("error",()=>r(!1)),s.once("spawn",()=>{s.unref(),r(!0)})}catch{r(!1)}})}function _M(t,e=LM){return t.openPages=Math.max(0,t.openPages-1),t.openPages>0?{closed:!1}:(t.closed=!0,j0.emit(`close:${t.id}`),clearTimeout(RM.get(t.id)),t.status==="pending"&&RM.set(t.id,setTimeout(()=>{RM.delete(t.id),t.closed&&T0(t)},e).unref()),{closed:!0})}function q1e(t,e){return new Promise(n=>{let r=f(()=>{clearTimeout(s),j0.off(`close:${t}`,r),n()},"done"),s=setTimeout(r,e);j0.once(`close:${t}`,r)})}async function O1e(t,e,n=LM){let r=em.get(t),s=Date.now()+e;for(;r&&Date.now()<s;)if(r.closed||await q1e(t,s-Date.now()),!r.closed||(await new Promise(i=>setTimeout(i,Math.min(n,Math.max(0,s-Date.now())))),r.closed))return}var em,j0,j1e,C1e,T1e,PM,UZ,C0,TM,su,iu,BS,$Z,XZ,NM,xw,I1e,R1e,IM,VS,zM,LM,RM,WS=H(()=>{"use strict";Vl();vX();LS();jM();dk();Y0();em=new Map,j0=new k1e;j0.setMaxListeners(100);j1e=1800*1e3,C1e=3600*1e3,T1e=1440*60*1e3,PM=20,UZ=512*1024,C0=30*1024*1024,TM=f(()=>WZ(24).toString("base64url"),"token"),su=f((t,e)=>{let n=Buffer.from(String(t??"")),r=Buffer.from(String(e??""));return n.length===r.length&&y1e(n,r)},"sameToken");f(nm,"createSession");iu=f(t=>em.get(t),"getSession");f(tm,"finish");f(OM,"pageOpened");f(HS,"waitForSession");f(Xi,"publicState");f(FM,"nextOutputPath");BS=f(()=>{let t=process.env.LABSIGN_OUTPUT_DIR||qM(EM(),"Downloads");return GZ(t)?t:EM()},"outputDir"),$Z=f(t=>{let e=EM();return t===e||t.startsWith(e+S1e)?`~${t.slice(e.length)}`:t},"folderLabel");f(mw,"uiState");f(gw,"readPdf");f(KZ,"checkPdf");f(US,"prepareSignSession");f(DM,"createAwaitingSignSession");XZ=f(t=>{let e=Qp(String(t||"")).replace(/[\x00-\x1f<>:"/\\|?*]+/g," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").slice(0,120)||"documento.pdf";return/\.pdf$/i.test(e)?e:`${e}.pdf`},"safePdfName");f(YZ,"assertOpen");f($S,"documentBytes");f(JZ,"chunkOf");NM=f((t,{offset:e,length:n}={})=>JZ($S(t),e,n),"uiDocumentChunk");f(bw,"uiUploadChunk");xw=f((t,e)=>yk(e),"uiSetPrefs"),I1e=400,R1e=6e4;f(E1e,"checkStrokes");f(ww,"uiSaveSignature");f(yw,"uiDeleteSignature");f(T0,"uiFinish");f(rm,"uiCancel");f(P1e,"sanitizePlacements");IM=f(t=>Math.round(t*10)/10,"r1");f(vw,"uiConfirm");f(MM,"signedPath");VS=f(t=>VZ(MM(t)),"signedBytes"),zM=f((t,{offset:e,length:n}={})=>({...JZ(VS(t),e,n),name:Qp(MM(t))}),"uiSignedChunk");f(Sw,"uiReveal");f(GS,"startDetached");LM=3e3,RM=new Map;f(_M,"uiClose");f(q1e,"onceClosed");f(O1e,"waitForClose")});var nQ={};$l(nQ,{ensureHttp:()=>kw,openInBrowser:()=>XS,publicUrl:()=>Aw,sessionUrl:()=>KS,uiFile:()=>sm});import F1e from"node:http";import{readFileSync as D1e,existsSync as N1e}from"node:fs";import{randomBytes as M1e}from"node:crypto";import{fileURLToPath as z1e}from"node:url";import{dirname as L1e,join as QZ}from"node:path";function sm(t){let e=L1e(z1e(import.meta.url)),n=[QZ(e,t),QZ(e,"../../dist",t)].find(r=>N1e(r));if(!n)throw new Error(`${t} not found \u2014 run "npm run build"`);return n}function kw(){return BM??=new Promise((t,e)=>{let n=F1e.createServer((r,s)=>{B1e(r,s).catch(i=>gs(s,500,Mi(i)))});n.once("error",r=>{BM=null,e(r)}),n.listen(0,"127.0.0.1",()=>{I0=n.address().port,n.unref(),t(I0)})}),BM}function XS(t){if(process.env.LABSIGN_NO_OPEN==="1")return Promise.resolve(!1);let e=process.env.LABSIGN_BROWSER,[n,r]=e?[e,[t]]:process.platform==="darwin"?["open",[t]]:process.platform==="win32"?["cmd",["/c","start","",t]]:["xdg-open",[t]];return GS(n,r)}function gs(t,e,n){t.headersSent||(t.writeHead(e,{"content-type":"application/json; charset=utf-8","cache-control":"no-store",...YS}),t.end(JSON.stringify(n)))}function HM(t,e,n,r){let s=Hm(String(t.headers["accept-language"]??"").split(",")[0]),[i,o]=_1e[s][r];e.writeHead(n,{"content-type":"text/html; charset=utf-8","cache-control":"no-store","content-security-policy":"default-src 'none'; style-src 'unsafe-inline'",...YS}),e.end(`<!doctype html><html lang="${s}"><meta charset="utf-8"><title>labsign</title><body style="font:16px system-ui;padding:48px;max-width:560px;margin:auto"><h1 style="font-size:20px">${i}</h1><p>${o}</p>`)}async function B1e(t,e){if(t.headers.host!==`127.0.0.1:${I0}`)return gs(e,403,Mi(new Mt("BAD_HOST")));let n=new URL(t.url??"/",`http://127.0.0.1:${I0}`),r=n.pathname.split("/").filter(Boolean);if(t.method==="GET"&&r[0]==="s"&&r[1]){let s=iu(r[1]);if(!s)return HM(t,e,404,"notFound");let i=su(eQ(t,`ls_${s.id}`),s.cookie);if(!i&&!su(n.searchParams.get("t"),s.openToken))return HM(t,e,404,"notFound");if(s.opened&&!i)return Yl({event:"session_reopen_blocked",session:s.id,ua:String(t.headers["user-agent"]??"")}),HM(t,e,409,"reopened");OM(s);let o=M1e(18).toString("base64"),a=process.env.LABSIGN_LANG?{lang:Hm(process.env.LABSIGN_LANG)}:{},c=`<script nonce="${o}">window.__LABSIGN_HTTP__=${JSON.stringify({sessionId:s.id,viewToken:s.viewToken,...a})}</script>`;e.writeHead(200,{"content-type":"text/html; charset=utf-8","cache-control":"no-store","set-cookie":`ls_${s.id}=${s.cookie}; HttpOnly; SameSite=Strict; Path=/`,"content-security-policy":`default-src 'none'; script-src 'nonce-${o}'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,"referrer-policy":"no-referrer","x-content-type-options":"nosniff",...YS});let l=D1e(sm("ui.html"),"utf8").replace("<!--LABSIGN_BOOT-->",()=>c).replace('nonce="__LABSIGN_NONCE__"',()=>`nonce="${o}"`);return void e.end(l)}if(t.method==="POST"&&r[0]==="api"&&r[1]&&r[2]){let s=iu(r[1]);if(!s)return gs(e,404,Mi(new Mt("NOT_FOUND")));let i=t.headers.origin;if(i&&i!==`http://127.0.0.1:${I0}`)return gs(e,403,Mi(new Mt("BAD_ORIGIN")));let o=t.headers["sec-fetch-site"];if(o&&o!=="same-origin"&&o!=="none")return gs(e,403,Mi(new Mt("BAD_ORIGIN")));let a=r[2]==="upload_document",c=a?C0:5e6,l=[],u=0;for await(let m of t){if(u+=m.length,u>c)return gs(e,413,Mi(new Mt(a?"UPLOAD_TOO_BIG":"BODY_TOO_BIG",{mb:C0/1024/1024})));l.push(m)}let h=Buffer.concat(l),d={};try{d=a||!h.length?{}:JSON.parse(h.toString("utf8"))}catch{return gs(e,400,Mi(new Mt("INVALID_PLACEMENT")))}if(!d||typeof d!="object"||Array.isArray(d))return gs(e,400,Mi(new Mt("INVALID_PLACEMENT")));let p=t.headers["x-labsign-view"]??(r[2]==="close"?d.view_token:void 0);if(!su(p,s.viewToken)||!su(eQ(t,`ls_${s.id}`),s.cookie))return gs(e,401,Mi(new Mt("UNAUTHORIZED")));try{switch(r[2]){case"state":return gs(e,200,mw(s));case"document":return tQ(e,$S(s));case"signed_document":return tQ(e,VS(s));case"upload_document":return gs(e,200,await bw(s,{name:H1e(String(t.headers["x-labsign-filename"]??"")),size:h.length,offset:0,data:h}));case"save_signature":return gs(e,200,ww(s,d));case"delete_signature":return gs(e,200,yw(s,d));case"set_prefs":return gs(e,200,xw(s,d));case"confirm":return gs(e,200,await vw(s,d));case"reveal":return gs(e,200,await Sw(s));case"cancel":return gs(e,200,rm(s));case"finish":return gs(e,200,T0(s));case"close":return gs(e,200,_M(s))}}catch(m){return gs(e,400,Mi(m))}}return gs(e,404,Mi(new Mt("NOT_FOUND")))}function H1e(t){try{return decodeURIComponent(t)}catch{return t}}function tQ(t,e){t.writeHead(200,{"content-type":"application/pdf","content-length":e.length,"cache-control":"no-store",...YS}),t.end(e)}var BM,I0,KS,Aw,YS,_1e,eQ,JS=H(()=>{"use strict";Vl();Uy();WS();Y0();f(sm,"uiFile");BM=null,I0=0;f(kw,"ensureHttp");KS=f(t=>`http://127.0.0.1:${I0}/s/${t.id}?t=${t.openToken}`,"sessionUrl"),Aw=f(t=>`http://127.0.0.1:${I0}/s/${t.id}`,"publicUrl");f(XS,"openInBrowser");YS={connection:"close"};f(gs,"json");_1e={pt:{notFound:["Sess\xE3o n\xE3o encontrada","O link expirou ou \xE9 inv\xE1lido. Pe\xE7a um novo pedido de assinatura."],reopened:["Esta sess\xE3o j\xE1 foi aberta em outro lugar","Por seguran\xE7a, cada pedido de assinatura s\xF3 abre uma vez. Se n\xE3o foi voc\xEA, cancele e pe\xE7a um novo."]},en:{notFound:["Session not found","The link expired or is invalid. Ask for a new signing request."],reopened:["This session was already opened elsewhere","For safety, each signing request opens only once. If it wasn\u2019t you, cancel and ask for a new one."]}};f(HM,"page");eQ=f((t,e)=>(t.headers.cookie??"").split(/;\s*/).map(n=>n.split("=")).find(([n])=>n===e)?.[1],"cookieOf");f(B1e,"handle");f(H1e,"safeDecode");f(tQ,"sendPdf")});var Hc,ZS=H(()=>{"use strict";Hc="0.1.1"});var Zt={};$l(Zt,{BIGINT_FORMAT_RANGES:()=>r4,CONSTANT_CATCH:()=>gQ,Class:()=>KM,NUMBER_FORMAT_RANGES:()=>Cw,aborted:()=>ec,allowsEval:()=>ez,assert:()=>J1e,assertEqual:()=>W1e,assertIs:()=>X1e,assertNever:()=>Y1e,assertNotEqual:()=>K1e,assignProp:()=>xo,attachSchema:()=>i4,base64ToUint8Array:()=>pQ,base64urlToUint8Array:()=>gbe,cached:()=>lm,captureStackTrace:()=>t4,cleanEnum:()=>mbe,cleanRegex:()=>jw,clone:()=>Ta,cloneDef:()=>ebe,codePointLength:()=>Tw,constantCatch:()=>bQ,createTransparentProxy:()=>obe,defineLazy:()=>JM,defineLazyInternal:()=>Mn,derived:()=>ybe,esc:()=>ZM,escapeRegex:()=>ql,explicitlyAborted:()=>rz,extend:()=>lbe,finalizeIssue:()=>tc,floatSafeRemainder:()=>YM,getElementAtPath:()=>tbe,getEnumValues:()=>am,getLengthableOrigin:()=>Iw,getParsedType:()=>ibe,getSizableOrigin:()=>dQ,hexToUint8Array:()=>xbe,hide:()=>o4,installLazyProp:()=>Abe,isObject:()=>E0,isPlainObject:()=>cu,issue:()=>um,joinValues:()=>e4,jsonStringifyReplacer:()=>cm,members:()=>iz,merge:()=>ube,mergeDefs:()=>Pl,normalizeParams:()=>$t,nullish:()=>XM,numKeys:()=>sbe,objectClone:()=>Z1e,omit:()=>cbe,optionalKeys:()=>nz,own:()=>au,parsedType:()=>sz,partial:()=>hbe,pick:()=>abe,prefixIssues:()=>Ol,primitiveTypes:()=>uQ,promiseAllObject:()=>nbe,propertyKeyTypes:()=>tz,randomString:()=>rbe,rawShape:()=>fm,required:()=>dbe,safeExtend:()=>fbe,shallowClone:()=>fQ,slugify:()=>QM,stringifyPrimitive:()=>n4,toZod:()=>aQ,uint8ArrayToBase64:()=>mQ,uint8ArrayToBase64url:()=>bbe,uint8ArrayToHex:()=>wbe,unwrapMessage:()=>om});function W1e(t){return t}function K1e(t){return t}function aQ(){return t=>t}function X1e(t){}function Y1e(t){throw new Error("Unexpected value in exhaustive check")}function J1e(t){}function am(t){let e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}function e4(t,e="|"){return t.map(n=>n4(n)).join(e)}function cm(t,e){return typeof e=="bigint"?e.toString():e}function lm(t){return new WM(t)}function XM(t){return t==null}function jw(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function YM(t,e){let n=t/e,r=Math.round(n),s=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<s?0:n-r}function JM(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==oQ)return r===void 0&&(r=oQ,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Z1e(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function xo(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fm(t){let e=Object.getOwnPropertyDescriptor(t,"shape");return e?.get?e.get.raw:e?.value}function El(t){return fm(t._zod.def)??t._zod.def.shape}function cQ(t,e,n){Object.defineProperty(t,e,{get(){let r=n();return xo(this,e,r),r},enumerable:!0,configurable:!0})}function lQ(t,e,n){e in t?xo(t,e,n):t[e]=n}function R0(t,e,n,r){let s=El(e);for(let i of n){let o=Object.getOwnPropertyDescriptor(s,i);o.enumerable&&(o.get?cQ(t,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):lQ(t,i,r?r(o.value,i):o.value))}}function Q1e(t,e){for(let n of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,n);r.enumerable&&(r.get?cQ(t,n,()=>e[n]):lQ(t,n,r.value))}}function Pl(...t){let e={};for(let n of t){let r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function ebe(t){return Pl(t._zod.def)}function tbe(t,e){return e?e.reduce((n,r)=>n?.[r],t):t}function nbe(t){let e=Object.keys(t),n=e.map(r=>t[r]);return Promise.all(n).then(r=>{let s={};for(let i=0;i<e.length;i++)s[e[i]]=r[i];return s})}function rbe(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<t;r++)n+=e[Math.floor(Math.random()*e.length)];return n}function ZM(t){return JSON.stringify(t)}function QM(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function E0(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function cu(t){if(E0(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let n=e.prototype;return!(E0(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function fQ(t){return cu(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function sbe(t){let e=0;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function ql(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ta(t,e,n){let r=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(r._zod.parent=t),r}function $t(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:f(()=>e,"error")};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:f(()=>e.error,"error")}:e}function obe(t){let e;return new Proxy({},{get(n,r,s){return e??(e=t()),Reflect.get(e,r,s)},set(n,r,s,i){return e??(e=t()),Reflect.set(e,r,s,i)},has(n,r){return e??(e=t()),Reflect.has(e,r)},deleteProperty(n,r){return e??(e=t()),Reflect.deleteProperty(e,r)},ownKeys(n){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(n,r){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,r)},defineProperty(n,r,s){return e??(e=t()),Reflect.defineProperty(e,r,s)}})}function n4(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function nz(t){return Object.keys(t).filter(e=>t[e]._zod.optin!==void 0&&t[e]._zod.optout==="optional")}function abe(t,e){let n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return R0(i,t,s4(t,e)),Ta(t,Pl(n,{shape:i,checks:[]}))}function s4(t,e){let n=El(t),r=[];for(let s of Reflect.ownKeys(e)){if(!Object.getOwnPropertyDescriptor(n,s)?.enumerable)throw new Error(`Unrecognized key: "${String(s)}"`);e[s]&&r.push(s)}return r}function cbe(t,e){let n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(s4(t,e)),o={};return R0(o,t,Reflect.ownKeys(El(t)).filter(a=>!i.has(a))),Ta(t,Pl(n,{shape:o,checks:[]}))}function lbe(t,e){if(!cu(e))throw new Error("Invalid input to extend: expected a plain object");let n=t._zod.def.checks;if(n&&n.length>0){let s=El(t);for(let i of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ta(t,Pl(t._zod.def,{shape:hQ(t,e)}))}function hQ(t,e){let n={};return R0(n,t,Reflect.ownKeys(El(t))),Q1e(n,e),n}function fbe(t,e){if(!cu(e))throw new Error("Invalid input to safeExtend: expected a plain object");return Ta(t,Pl(t._zod.def,{shape:hQ(t,e)}))}function ube(t,e){if(!e?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};R0(n,t,Reflect.ownKeys(El(t))),R0(n,e,Reflect.ownKeys(El(e)));let r=Pl(t._zod.def,{shape:n,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ta(t,r)}function hbe(t,e,n,r="partial"){let i=e._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(s4(e,n)):void 0,c={};return R0(c,e,Reflect.ownKeys(El(e)),t&&((l,u)=>a&&!a.has(u)?l:new t({type:"optional",innerType:l}))),Ta(e,Pl(e._zod.def,{shape:c,checks:[]}))}function dbe(t,e,n){let r=n?new Set(s4(e,n)):void 0,s={};return R0(s,e,Reflect.ownKeys(El(e)),(i,o)=>r&&!r.has(o)?i:new t({type:"nonoptional",innerType:i})),Ta(e,Pl(e._zod.def,{shape:s}))}function ec(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function rz(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue===!1)return!0;return!1}function Ol(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function om(t){return typeof t=="string"?t:t?.message}function i4(t,e,n){var r;for(let s=e;s<t.length;s++)(r=t[s]).schema??(r.schema=n)}function tc(t,e,n){var r;let s=t.inst?._zod?.traits;s?.has("$ZodType")&&(s.has("$ZodCheck")?(r=t).schema??(r.schema=t.inst):t.schema=t.inst);let i=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,o=t.message?t.message:om(t.inst?._zod.def?.error?.(t))??om(i?.(t))??om(e?.error?.(t))??om(n.customError?.(t))??om(n.localeError?.(t))??"Invalid input",a={};for(let c of Object.keys(t))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=t[c]);return a.path??(a.path=[]),a.message=o,e?.reportInput&&(a.input=t.input),a}function dQ(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Tw(t){let e=t.length;if(!pbe.test(t))return e;let n=e;for(let r=0;r<e-1;r++)(t.charCodeAt(r)&64512)===55296&&(t.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function Iw(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function sz(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let n=t;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return e}function um(...t){let[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}function mbe(t){return Object.entries(t).filter(([e,n])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function pQ(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}function mQ(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function gbe(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return pQ(e+n)}function bbe(t){return mQ(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function xbe(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)n[r/2]=Number.parseInt(e.slice(r,r+2),16);return n}function wbe(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function iz(t,e){for(let n in e){let r=Object.getOwnPropertyDescriptor(e,n);r.get?Object.defineProperty(t,n,{...r,enumerable:!1}):vbe(t,n,r.value)}}function au(t,e,n,r=!0){return Object.defineProperty(t,e,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function o4(t,e,n){return au(t,e,n,!1)}function ybe(t,e){for(let n in t){let r=t[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get(){return au(this,n,r(this))},set(s){au(this,n,s)}})}return e}function vbe(t,e,n){Object.defineProperty(t,e,{configurable:!0,get(){return this==null?n:au(this,e,n.bind(this))},set(r){au(this,e,r)}})}function Sbe(t,e){let n=Object.getPrototypeOf(t);return e in n?void 0:n}function Mn(t,e,n){let r=Object.getPrototypeOf(t._zod);if(e in r&&GM!==t._zod){GM=void 0;return}GM=t._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,kbe);let s=ou;ou=!1;try{let i=n(this);return ou?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),ou=ou||s,i}catch(i){throw delete this[e],ou=ou||s,i}},set(s){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:s})}})}function Abe(t,e,n,r){let s=Sbe(t,e);s&&Object.defineProperty(s,e,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,e,i),i.value=n(this),Object.defineProperty(this,e,i),i.value},set(i){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:r,value:i})}})}function bQ(t){let e=f(()=>t,"fn");return e[gQ]=!0,e}var WM,oQ,t4,ez,ibe,tz,uQ,Cw,r4,pbe,KM,GM,ou,kbe,gQ,wo=H(()=>{P0();f(W1e,"assertEqual");f(K1e,"assertNotEqual");f(aQ,"toZod");f(X1e,"assertIs");f(Y1e,"assertNever");f(J1e,"assert");f(am,"getEnumValues");f(e4,"joinValues");f(cm,"jsonStringifyReplacer");WM=class{static{f(this,"Cached")}constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};f(lm,"cached");f(XM,"nullish");f(jw,"cleanRegex");f(YM,"floatSafeRemainder");oQ=Symbol("evaluating");f(JM,"defineLazy");f(Z1e,"objectClone");f(xo,"assignProp");f(fm,"rawShape");f(El,"sourceShape");f(cQ,"deferProp");f(lQ,"putProp");f(R0,"mirrorShape");f(Q1e,"mirrorProps");f(Pl,"mergeDefs");f(ebe,"cloneDef");f(tbe,"getElementAtPath");f(nbe,"promiseAllObject");f(rbe,"randomString");f(ZM,"esc");f(QM,"slugify");t4="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};f(E0,"isObject");ez=lm(()=>{if(yo.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});f(cu,"isPlainObject");f(fQ,"shallowClone");f(sbe,"numKeys");ibe=f(t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},"getParsedType"),tz=new Set(["string","number","symbol"]),uQ=new Set(["string","number","bigint","boolean","symbol","undefined"]);f(ql,"escapeRegex");f(Ta,"clone");f($t,"normalizeParams");f(obe,"createTransparentProxy");f(n4,"stringifyPrimitive");f(nz,"optionalKeys");Cw={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},r4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};f(abe,"pick");f(s4,"maskedKeys");f(cbe,"omit");f(lbe,"extend");f(hQ,"extended");f(fbe,"safeExtend");f(ube,"merge");f(hbe,"partial");f(dbe,"required");f(ec,"aborted");f(rz,"explicitlyAborted");f(Ol,"prefixIssues");f(om,"unwrapMessage");f(i4,"attachSchema");f(tc,"finalizeIssue");f(dQ,"getSizableOrigin");pbe=/[\uD800-\uDBFF]/;f(Tw,"codePointLength");f(Iw,"getLengthableOrigin");f(sz,"parsedType");f(um,"issue");f(mbe,"cleanEnum");f(pQ,"base64ToUint8Array");f(mQ,"uint8ArrayToBase64");f(gbe,"base64urlToUint8Array");f(bbe,"uint8ArrayToBase64url");f(xbe,"hexToUint8Array");f(wbe,"uint8ArrayToHex");KM=class{static{f(this,"Class")}constructor(...e){}};f(iz,"members");f(au,"own");f(o4,"hide");f(ybe,"derived");f(vbe,"defineBound");f(Sbe,"claim");ou=!1,kbe={configurable:!0,get(){ou=!0}};f(Mn,"defineLazyInternal");f(Abe,"installLazyProp");gQ="~constantCatch";f(bQ,"constantCatch")});function jbe(t){let e=wQ;if(e){let n=e.stackTraceLimit;if(typeof n=="number"){try{e.stackTraceLimit=0}catch{return wQ=null,new t}try{return new t}finally{e.stackTraceLimit=n}}}return new t}function Oe(t,e,n,r){let s={};function i(d){this.def=d,this.constr=h,this.traits=new Set}f(i,"Internals"),i.prototype=s;let o=n,a=o&&new WeakSet;function c(d,p){if(d._zod){if(d._zod.traits.has(t))return}else{oz.value=new i(p);try{Object.defineProperty(d,"_zod",oz)}finally{oz.value=void 0}}if(d._zod.traits.add(t),e(d,p),a){let g=Object.getPrototypeOf(d),b=d._zod.constr.prototype,x=g;for(;x&&x!==b;)x=Object.getPrototypeOf(x);let w=x??g;a.has(w)||(a.add(w),iz(w,o))}let m=h.prototype;for(let g in m)Object.prototype.hasOwnProperty.call(m,g)&&(g in d||(d[g]=m[g].bind(d)))}f(c,"init");let l=r?.Parent??Object;class u extends l{static{f(this,"Definition")}}Object.defineProperty(u,"name",{value:t});function h(d){let p=r?.Parent?jbe(u):this;c(p,d);let m=p._zod.deferred;if(m){for(let b of m)b();p._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;return g&&g(p),p}return f(h,"_"),Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:f(d=>r?.Parent&&d instanceof r.Parent?!0:d?._zod?.traits?.has(t),"value")}),Object.defineProperty(h,"name",{value:t}),h}function vo(t){return t&&Object.assign(yo,t),yo}var xQ,az,oz,wQ,nc,hm,yo,P0=H(()=>{wo();az=Object.freeze({status:"aborted"}),oz={value:void 0,enumerable:!1},wQ="captureStackTrace"in Error?Error:null;f(jbe,"newError");f(Oe,"$constructor");nc=class extends Error{static{f(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},hm=class extends Error{static{f(this,"$ZodEncodeError")}constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(xQ=globalThis).__zod_globalConfig??(xQ.__zod_globalConfig={});yo=globalThis.__zod_globalConfig;f(vo,"config")});function Cbe(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,cm,2)),t.message}function Tbe(t){this._zod.message=t}function Rbe(t,e,n){return Object.prototype.hasOwnProperty.call(t,e)||(e==="__proto__"?Object.defineProperty(t,e,{value:n(),writable:!0,enumerable:!0,configurable:!0}):t[e]=n()),t[e]}function fz(t,e=n=>n.message){let n={},r=[];for(let s of t.issues)s.path.length>0?Rbe(n,s.path[0],()=>[]).push(e(s)):r.push(e(s));return{formErrors:r,fieldErrors:n}}function uz(t,e=n=>n.message){let n={_errors:[]},r=f((s,i=[])=>{for(let o of s.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>r({issues:a},[...i,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...i,...o.path]);else{let a=[...i,...o.path];if(a.length===0)n._errors.push(e(o));else{let c=n,l=0;for(;l<a.length;){let u=a[l],h=l===a.length-1;if(u==="_errors"){h&&c._errors.push(e(o)),l++;continue}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];h&&d._errors.push(e(o)),c=d,l++}}}},"processError");return r(t),n}var Ibe,lz,yQ,vQ,SQ,yXe,kQ=H(()=>{P0();wo();f(Cbe,"_getMessage");f(Tbe,"_setMessage");Ibe={get:Cbe,set:Tbe,enumerable:!0,configurable:!0},lz={value:void 0,enumerable:!1},yQ=new WeakSet([Object.prototype,Error.prototype]),vQ=f((t,e)=>{t.name="$ZodError",lz.value=e,Object.defineProperty(t,"issues",lz),lz.value=void 0,Object.defineProperty(t,"message",Ibe);let n=Object.getPrototypeOf(t);yQ.has(n)||(yQ.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=f(()=>this.message,"value");return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},"initializer"),SQ=Oe("$ZodError",vQ),yXe=Oe("$ZodError",vQ,void 0,{Parent:Error});f(Rbe,"node");f(fz,"flattenError");f(uz,"formatError")});function a4(t,e){return{callee:e?.callee??t,Err:e?.Err}}function AQ(t,e,n){let r;return{success:!1,get error(){return r||(r=new t(e.map(s=>tc(s,n,vo()))),e=void 0,n=void 0),r},set error(s){r=s,e=void 0,n=void 0}}}function qbe(t,e,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},s=t._zod.bag.fallbackRun,i;if(s?(r[Pbe]=!0,i=s({value:e,issues:[]},r)):i=t._zod.run({value:e,issues:[]},r),i instanceof Promise)throw new nc;return i.issues.length===0}var c4,l4,f4,u4,Ebe,Pbe,hz,dz,jQ,CQ,TQ,IQ,RQ,EQ,PQ,qQ,OQ=H(()=>{P0();wo();f(a4,"finalizeParams");c4=f(t=>{let e=f((n,r,s,i)=>{let o=s?{...s,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new nc;if(a.issues.length){let c=new(i?.Err??t)(a.issues.map(l=>tc(l,o,vo())));throw t4(c,i?.callee??e),c}return a.value},"fn");return e},"_parse"),l4=f(t=>{let e=f(async(n,r,s,i)=>{let o=s?{...s,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??t)(a.issues.map(l=>tc(l,o,vo())));throw t4(c,i?.callee??e),c}return a.value},"fn");return e},"_parseAsync"),f4=f(t=>(e,n,r)=>{let s=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new nc;return i.issues.length?AQ(t,i.issues,s):{success:!0,data:i.value}},"_safeParse");f(AQ,"failure");u4=f(t=>async(e,n,r)=>{let s=r?{...r,async:!0}:{async:!0},i=e._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?AQ(t,i.issues,s):{success:!0,data:i.value}},"_safeParseAsync"),Ebe=Symbol.for("zod.compile.invalid"),Pbe=Symbol.for("zod.compile.fallback"),hz=f(((t,e,n)=>{let r=t._zod.bag.validator;if(r!==void 0){if(r(e)!==Ebe)return!0;if(r.definite===!0&&n===void 0)return!1}return qbe(t,e,n)}),"validate");f(qbe,"validateFallback");dz=f(async(t,e,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},s=t._zod.run({value:e,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length===0},"validateAsync"),jQ=f(t=>{let e=c4(t),n=f((r,s,i,o)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return e(r,s,a,a4(n,o))},"fn");return n},"_encode"),CQ=f(t=>{let e=c4(t),n=f((r,s,i,o)=>e(r,s,i,a4(n,o)),"fn");return n},"_decode"),TQ=f(t=>{let e=l4(t),n=f(async(r,s,i,o)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await e(r,s,a,a4(n,o))},"fn");return n},"_encodeAsync"),IQ=f(t=>{let e=l4(t),n=f(async(r,s,i,o)=>await e(r,s,i,a4(n,o)),"fn");return n},"_decodeAsync"),RQ=f(t=>(e,n,r)=>{let s=r?{...r,direction:"backward"}:{direction:"backward"};return f4(t)(e,n,s)},"_safeEncode"),EQ=f(t=>(e,n,r)=>f4(t)(e,n,r),"_safeDecode"),PQ=f(t=>async(e,n,r)=>{let s=r?{...r,direction:"backward"}:{direction:"backward"};return u4(t)(e,n,s)},"_safeEncodeAsync"),qQ=f(t=>async(e,n,r)=>u4(t)(e,n,r),"_safeDecodeAsync")});function _Q(t){return new RegExp(`^[a-zA-Z0-9_-]{${t}}$`)}function $Q(){return new RegExp(Obe,"u")}function Fbe(t){return new RegExp(`^${t}$`)}function pz(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${e}:[0-5]\\d(?:\\.\\d+)?`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tee(t){return new RegExp(`^${pz(t)}$`)}function nee(t){let e=["Z"];t.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${pz({precision:t.precision,seconds:!0})}(?:${e.join("|")})`,r=t.local?`${n}|${pz({precision:t.precision})}`:n;return new RegExp(`^${QQ}T(?:${r})$`)}var FQ,DQ,NQ,MQ,zQ,LQ,BQ,HQ,mz,UQ,Obe,VQ,GQ,WQ,KQ,XQ,YQ,JQ,ZQ,QQ,eee,ree,see,gz,Rw,iee,oee,aee,cee,Ew=H(()=>{FQ=/^[cC][0-9a-z]{6,}$/,DQ=/^[0-9a-z]+$/,NQ=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,MQ=/^[0-9a-vA-V]{20}$/,zQ=/^[A-Za-z0-9]{27}$/,LQ=/^[a-zA-Z0-9_-]{21}$/;f(_Q,"nanoidOfLength");BQ=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,HQ=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mz=f(t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,"uuid"),UQ=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Obe="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";f($Q,"emoji");VQ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,GQ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,WQ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,KQ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,XQ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,YQ=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,JQ=/^https?$/,ZQ=/^\+[1-9]\d{6,14}$/,QQ="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";f(Fbe,"anchor");eee=Fbe(QQ);f(pz,"timeSource");f(tee,"time");f(nee,"datetime");ree=/^[\s\S]{0,}$/,see=/^-?\d+n?$/,gz=/^-?\d+$/,Rw=/^-?\d+(?:\.\d+)?$/,iee=/^(?:true|false)$/i,oee=/^null$/i,aee=/^[^A-Z]*$/,cee=/^[^a-z]*$/});var bi,bz,h4,xz,wz,lee,fee,uee,hee,dee,Pw,pee,mee,gee,bee,xee,wee,yee,d4=H(()=>{P0();Ew();wo();bi=Oe("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),bz=f(t=>{let e=t.value;return!XM(e)&&e.length!==void 0},"_whenHasLength"),h4={number:"number",bigint:"bigint",object:"date"},xz=Oe("$ZodCheckLessThan",(t,e)=>{bi.init(t,e);let n=h4[typeof e.value];t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:h4[typeof r.value]??n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),wz=Oe("$ZodCheckGreaterThan",(t,e)=>{bi.init(t,e);let n=h4[typeof e.value];t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:h4[typeof r.value]??n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),lee=Oe("$ZodCheckMultipleOf",(t,e)=>{bi.init(t,e),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?e.value!==BigInt(0)&&n.value%e.value===BigInt(0):YM(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),fee=Oe("$ZodCheckNumberFormat",(t,e)=>{bi.init(t,e),e.format=e.format||"float64";let n=e.format?.includes("int"),r=n?"int":"number",[s,i]=Cw[e.format];t._zod.check=o=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}a<s&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>i&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),uee=Oe("$ZodCheckMaxLength",(t,e)=>{var n;bi.init(t,e),(n=t._zod.def).when??(n.when=bz),t._zod.check=r=>{let s=r.value,i=s.length;if((typeof s=="string"&&i>e.maximum?Tw(s):i)<=e.maximum)return;let a=Iw(s);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),hee=Oe("$ZodCheckMinLength",(t,e)=>{var n;bi.init(t,e),(n=t._zod.def).when??(n.when=bz),t._zod.check=r=>{let s=r.value,i=s.length;if((typeof s=="string"&&i>=e.minimum&&i<e.minimum*2?Tw(s):i)>=e.minimum)return;let a=Iw(s);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),dee=Oe("$ZodCheckLengthEquals",(t,e)=>{var n;bi.init(t,e),(n=t._zod.def).when??(n.when=bz),t._zod.check=r=>{let s=r.value,i=s.length,o=typeof s=="string"&&i>=e.length&&i<=e.length*2?Tw(s):i;if(o===e.length)return;let a=Iw(s),c=o>e.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Pw=Oe("$ZodCheckStringFormat",(t,e)=>{var n,r;bi.init(t,e),e.pattern?(n=t._zod).check??(n.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),pee=Oe("$ZodCheckRegex",(t,e)=>{Pw.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),mee=Oe("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=aee),Pw.init(t,e)}),gee=Oe("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=cee),Pw.init(t,e)}),bee=Oe("$ZodCheckIncludes",(t,e)=>{bi.init(t,e);let n=ql(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position},}${n}`:n);e.pattern=r,t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),xee=Oe("$ZodCheckStartsWith",(t,e)=>{bi.init(t,e);let n=new RegExp(`^${ql(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),wee=Oe("$ZodCheckEndsWith",(t,e)=>{bi.init(t,e);let n=new RegExp(`.*${ql(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),yee=Oe("$ZodCheckOverwrite",(t,e)=>{bi.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}})});var p4,yz=H(()=>{p4=class{static{f(this,"Doc")}constructor(e=[],n={}){this.content=[],this.indent=0,this.args=e,this.closed=n}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
216
|
+
%\xFA\xDE\xFA\xCE`);return FZ({originalData:a,changes:i,xrefInfo:{startXRef:null,rootRef:this.rootRef,infoRef:this.infoRef,encryptRef:n,newRef:o,fileIds:s||[null,null],infoMap:e},useXrefStream:this.useObjectStreams,xref:{encrypt:r,encryptRef:n}})}},QN=class{static{f(this,"BasePDFStream")}#e=null;#t=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(e,n,r){this._source=e,this.#e=n,this.#t=r}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return xr(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#e(this)}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;let r=new this.#t(this,e,n);return this._rangeReaders.add(r),r}cancelAllRequests(e){this._fullReader?.cancel(e);for(let n of new Set(this._rangeReaders))n.cancel(e)}},eM=class{static{f(this,"BasePDFStreamReader")}onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(e){this._stream=e}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){rn("Abstract method `read` called")}cancel(e){rn("Abstract method `cancel` called")}},tM=class{static{f(this,"BasePDFStreamRangeReader")}_stream=null;constructor(e,n,r){this._stream=e}async read(){rn("Abstract method `read` called")}cancel(e){rn("Abstract method `cancel` called")}},nM=class extends QN{static{f(this,"PDFWorkerStream")}constructor(e){super(e,rM,sM)}},rM=class extends eM{static{f(this,"PDFWorkerStreamReader")}_reader=null;constructor(e){super(e);let{msgHandler:n}=e._source,r=n.sendWithStream("GetReader");this._reader=r.getReader(),n.sendWithPromise("ReaderHeadersReady").then(s=>{this._contentLength=s.contentLength,this._isStreamingSupported=s.isStreamingSupported,this._isRangeSupported=s.isRangeSupported,this._headersCapability.resolve()},this._headersCapability.reject)}async read(){let{value:e,done:n}=await this._reader.read();return n?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}},sM=class extends tM{static{f(this,"PDFWorkerStreamRangeReader")}_reader=null;constructor(e,n,r){super(e,n,r);let{msgHandler:s}=e._source,i=s.sendWithStream("GetRangeReader",{begin:n,end:r});this._reader=i.getReader()}async read(){let{value:e,done:n}=await this._reader.read();return n?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}},$a=class{static{f(this,"WorkerTask")}#e=Promise.withResolvers();terminated=!1;constructor(e){this.name=e}get finished(){return this.#e.promise}finish(){this.#e.resolve()}terminate(){this.terminated=!0}ensureNotTerminated(){if(this.terminated)throw new Error("Worker task was terminated")}},iM=class{static{f(this,"WorkerMessageHandler")}static{typeof window>"u"&&!m0e&&typeof self<"u"&&typeof self.postMessage=="function"&&"onmessage"in self&&this.initializeFromPort(self)}static setup(e,n){let r=!1;e.on("test",s=>{r||(r=!0,e.send("test",s instanceof Uint8Array))}),e.on("configure",s=>{S0e(s.verbosity)}),e.on("GetDocRequest",s=>this.createDocumentHandler(s,n))}static createDocumentHandler(e,n){let r,s=!1,i=null,o=new Set,a=k0e(),{docId:c,apiVersion:l}=e,u="6.3.289";if(l!==u)throw new Error(`The API version "${l}" does not match the Worker version "${u}".`);let h=f((k,v)=>`The \`${k}.prototype\` contains unexpected enumerable property "${v}", thus breaking e.g. \`for...in\` iteration of ${k}s.`,"buildMsg");for(let k in{})throw new Error(h("Object",k));for(let k in[])throw new Error(h("Array",k));let d=c+"_worker",p=new AS(d,c,n);function m(){if(s)throw new Error("Worker was terminated")}f(m,"ensureNotTerminated");function g(k){o.add(k)}f(g,"startWorkerTask");function b(k){k.finish(),o.delete(k)}f(b,"finishWorkerTask");async function x(k){await r.initDocument(k);let v=await r.ensureDoc("isPureXfa");if(v){let I=new $a("loadXfaResources");g(I),await r.ensureDoc("loadXfaResources",[p,I]),b(I)}let[A,j]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("fingerprints")]),C=v?await r.ensureDoc("htmlForXfa"):null;return{numPages:A,fingerprints:j,htmlForXfa:C}}f(x,"loadDocument");async function w({data:k,password:v,disableAutoFetch:A,rangeChunkSize:j,docBaseUrl:C,enableXfa:I,evaluatorOptions:R}){let E={source:null,disableAutoFetch:A,docBaseUrl:C,docId:c,enableXfa:I,evaluatorOptions:R,handler:p,length:0,password:v,rangeChunkSize:j};if(k)return E.source=k,new yx(E);let P=new nM({msgHandler:p}),F=P.getFullReader(),{promise:_,resolve:B,reject:W}=Promise.withResolvers(),Y,K=[];i=f(ee=>P.cancelAllRequests(ee),"cancelXHRs"),F.headersReady.then(()=>{if(F.isRangeSupported){E.source=P,E.length=F.contentLength,E.disableAutoFetch||=F.isStreamingSupported,Y=new KN(E);for(let ee of K)Y.sendProgressiveData(ee);K=null,B(Y),i=null}}).catch(ee=>{W(ee),i=null});async function U(){let ee=0;for(;;){let{value:V,done:D}=await F.read();if(m(),D)break;ee+=V.byteLength,F.isStreamingSupported||p.send("DocProgress",{loaded:ee,total:F.contentLength}),Y?Y.sendProgressiveData(V):K.push(V)}Y||(E.source=IJ(K),K=null,Y=new yx(E),B(Y)),i=null}return f(U,"readData"),U().catch(ee=>{W(ee),i=null}),_}f(w,"getPdfManager");async function y(k){let v=new $a(`PasswordException: response ${k.code}`);g(v);try{return(await p.sendWithPromise("PasswordRequest",k)).password}finally{Promise.resolve().then(()=>{b(v)})}}f(y,"getPassword");function S(k){function v(C){m(),p.send("GetDoc",{pdfInfo:C})}f(v,"onSuccess");function A(C){s||(C instanceof Ja?y(C).then(I=>{r.updatePassword(I),j()}).catch(()=>{p.send("DocException",C)}):p.send("DocException",Bo(C)))}f(A,"onFailure");function j(){m(),x(!1).then(v,function(C){if(m(),!(C instanceof kl)){A(C);return}r.requestLoadedStream().then(function(){m(),x(!0).then(v,A)},A)})}f(j,"pdfManagerReady"),m(),w(k).then(function(C){if(s)throw C.terminate(new _s("Worker was terminated.")),new Error("Worker was terminated");r=C,r.requestLoadedStream(!0).then(I=>{p.send("DataLoaded",{length:I.bytes.byteLength})},()=>{})}).then(j,A)}return f(S,"setupDoc"),p.on("GetPage",async function({pageIndex:k}){let v=await r.getPage(k),[A,j,C,I]=await Promise.all([r.ensure(v,"rotate"),r.ensure(v,"ref"),r.ensure(v,"userUnit"),r.ensure(v,"view")]);return{rotate:A,ref:j,refStr:j?.toString()??null,userUnit:C,view:I}}),p.on("GetPageIndex",function({num:k,gen:v}){return r.ensureCatalog("getPageIndex",[Se.get(k,v)])}),p.on("GetDestinations",function(){return r.ensureCatalog("destinations")}),p.on("GetDestination",function({id:k}){return r.ensureCatalog("getDestination",[k])}),p.on("GetPageLabels",function(){return r.ensureCatalog("pageLabels")}),p.on("GetPageLayout",function(){return r.ensureCatalog("pageLayout")}),p.on("GetPageMode",function(){return r.ensureCatalog("pageMode")}),p.on("GetViewerPreferences",function(){return r.ensureCatalog("viewerPreferences")}),p.on("GetOpenAction",function(){return r.ensureCatalog("openAction")}),p.on("GetAttachments",function(){return r.ensureCatalog("attachments")}),p.on("GetAttachmentContent",async function(k){let v;for(;;){let A=v?await y(v):null;try{return A&&r.updatePassword(A),await r.ensureCatalog("attachmentContent",[k])}catch(j){if(j instanceof Ja){v=j;continue}throw j}}}),p.on("GetDocJSActions",function(){return r.ensureCatalog("jsActions")}),p.on("GetPageJSActions",async function({pageIndex:k}){let v=await r.getPage(k);return r.ensure(v,"jsActions")}),p.on("GetAnnotationsByType",async function({types:k,pageIndexesToSkip:v}){let[A,j]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("annotationGlobals")]);if(!j)return null;let C=[],I=[],R=null;try{for(let P=0,F=A;P<F;P++)v?.has(P)||(R||(R=new $a("GetAnnotationsByType"),g(R)),C.push(r.getPage(P).then(_=>_.collectAnnotationsByType(p,R,k,I,j))));return await Promise.all(C),(await Promise.all(I)).filter(Boolean)}finally{R&&b(R)}}),p.on("GetOutline",function(){return r.ensureCatalog("documentOutline")}),p.on("GetOptionalContentConfig",function(){return r.ensureCatalog("optionalContentConfig")}),p.on("GetPermissions",function(){return r.ensureCatalog("permissions")}),p.on("GetMetadata",function(){return Promise.all([r.ensureDoc("documentInfo"),r.ensureCatalog("metadata"),r.ensureCatalog("hasStructTree")])}),p.on("GetMarkInfo",function(){return r.ensureCatalog("markInfo")}),p.on("GetData",async function(){return(await r.requestLoadedStream()).bytes}),p.on("GetAnnotations",async function({pageIndex:k,intent:v}){let A=await r.getPage(k),j=new $a(`GetAnnotations: page ${k}`);g(j);try{return await A.getAnnotationsData(p,j,v)}finally{b(j)}}),p.on("GetFieldObjects",async function(){return(await r.ensureDoc("fieldObjects"))?.allFields||null}),p.on("GetSignatures",function(){return r.ensureDoc("signatures")}),p.on("GetSignatureData",function(k){return r.ensureDoc("getSignatureData",[k])}),p.on("HasJSActions",function(){return r.ensureDoc("hasJSActions")}),p.on("GetCalculationOrderIds",function(){return r.ensureDoc("calculationOrderIds")}),p.on("ExtractPages",async function({pageInfos:k,annotationStorage:v}){if(!k)return te("extractPages: nothing to extract."),null;Array.isArray(k)||(k=[k]);let A=0;for(let C of k)if(!C.image)if(C.document===null)C.document=r.pdfDocument;else if(ArrayBuffer.isView(C.document)){let I=new yx({source:C.document,docId:`${c}_extractPages_${A++}`,handler:p,password:C.password??null,evaluatorOptions:Object.assign({},r.evaluatorOptions)}),R=!1,E=!0;for(;;)try{await I.requestLoadedStream(),await I.initDocument(R);break}catch(F){if(F instanceof kl)if(R===!1){R=!0;continue}else E=!1,te("extractPages: XRefParseException.");else if(F instanceof Ja)try{let _=await y(F);I.updatePassword(_)}catch{E=!1,te("extractPages: invalid password.")}else E=!1,te("extractPages: invalid document.");if(!E)break}E||(C.document=null),await I.ensureDoc("isPureXfa")?(C.document=null,te("extractPages does not support pure XFA documents.")):C.document=I.pdfDocument}else te("extractPages: invalid document.");let j;try{let C=new ZN;return j=new $a(`ExtractPages: ${k.length} page(s)`),g(j),await C.extractPages(k,v,r.pdfDocument,p,j)}catch(C){return te(`extractPages: "${C}".`),null}finally{j&&b(j)}}),p.on("SaveDocument",async function({isPureXfa:k,numPages:v,annotationStorage:A,filename:j}){let C=[r.requestLoadedStream(),r.ensureCatalog("acroForm"),r.ensureCatalog("acroFormRef"),r.ensureDoc("startXRef"),r.ensureDoc("xref"),r.ensureCatalog("structTreeRoot")],I=new Qr,R=[],E=k?null:aM(A),[P,F,_,B,W,Y]=await Promise.all(C),K=W.trailer.getRaw("Root")||null,U;if(E){Y?await Y.canUpdateStructTree({pdfManager:r,newAnnotationsByPage:E})&&(U=Y):await Bx.canCreateStructureTree({catalogRef:K,pdfManager:r,newAnnotationsByPage:E})&&(U=null);let X=Wo.generateImages(A.values(),W,r.evaluatorOptions.isOffscreenCanvasSupported),oe=U===void 0?R:[];for(let[pe,ae]of E)oe.push(r.getPage(pe).then(N=>{let re=new $a(`Save (editor): page ${pe}`);return g(re),N.saveNewAnnotations(p,re,ae,X,I).finally(()=>{b(re)})}));U===null?R.push(Promise.all(oe).then(async()=>{await Bx.createStructureTree({newAnnotationsByPage:E,xref:W,catalogRef:K,pdfManager:r,changes:I})})):U&&R.push(Promise.all(oe).then(async()=>{await U.updateStructureTree({newAnnotationsByPage:E,pdfManager:r,changes:I})}))}if(k)R.push(r.ensureDoc("serializeXfaData",[A]));else for(let X=0;X<v;X++)R.push(r.getPage(X).then(function(oe){let pe=new $a(`Save: page ${X}`);return g(pe),oe.save(p,pe,A,I).finally(()=>{b(pe)})}));let ee=await Promise.all(R),V=null;if(k){if(V=ee[0],!V)return P.bytes}else if(I.size===0)return P.bytes;let D=_&&F instanceof Q&&I.values().some(X=>X.needAppearances),G=F instanceof Q&&F.get("XFA")||null,z=null,M=!1;if(Array.isArray(G)){for(let X=0,oe=G.length;X<oe;X+=2)G[X]==="datasets"&&(z=G[X+1],M=!0);z===null&&(z=W.getNewTemporaryRef())}else G&&te("Unsupported XFA type.");let L=Object.create(null);if(W.trailer){let X=new Map,oe=W.trailer.get("Info")||null;if(oe instanceof Q)for(let[pe,ae]of oe)typeof ae=="string"&&X.set(pe,Ht(ae));L={rootRef:K,encryptRef:W.trailer.getRaw("Encrypt")||null,newRef:W.getNewTemporaryRef(),infoRef:W.trailer.getRaw("Info")||null,infoMap:X,fileIds:W.trailer.get("ID")||null,startXRef:B,filename:j}}return FZ({originalData:P.bytes,xrefInfo:L,changes:I,xref:W,hasXfa:!!G,xfaDatasetsRef:z,hasXfaDatasetsEntry:M,needAppearances:D,acroFormRef:_,acroForm:F,xfaData:V,useXrefStream:_p(W.topDict,"XRef")}).finally(()=>{W.resetNewTemporaryRef()})}),p.on("GetOperatorList",function({pageId:k,pageIndex:v,intent:A,cacheKey:j,annotationStorage:C,modifiedIds:I},R){r.getPage(k).then(function(E){let P=new $a(`GetOperatorList: page ${v}`);g(P);let F=a>=vx.INFOS?Date.now():0;E.getOperatorList({handler:p,sink:R,task:P,intent:A,cacheKey:j,annotationStorage:C,modifiedIds:I,pageIndex:v}).then(_=>{F&&Cn(`${P.name}; time=${Date.now()-F}ms, len=${_.length}`),R.close()},_=>{P.terminated||R.error(_)}).finally(()=>{b(P)})})}),p.on("GetTextContent",function({pageId:k,pageIndex:v,includeMarkedContent:A,disableNormalization:j},C){r.getPage(k).then(function(I){let R=new $a("GetTextContent: page "+v);g(R);let E=a>=vx.INFOS?Date.now():0;I.extractTextContent({handler:p,task:R,sink:C,includeMarkedContent:A,disableNormalization:j}).then(()=>{E&&Cn(`${R.name}; time=${Date.now()-E}ms`),C.close()},P=>{R.terminated||C.error(P)}).finally(()=>{b(R)})})}),p.on("GetStructTree",async function({pageIndex:k}){let v=await r.getPage(k);return r.ensure(v,"getStructTree")}),p.on("FontFallback",function({id:k}){return r.fontFallback(k,p)}),p.on("Cleanup",function(){return r.cleanup(!0)}),p.on("Terminate",async function(){s=!0;let k=[];if(r){r.terminate(new _s("Worker was terminated."));let v=r.cleanup();k.push(v),r=null}else mM();i?.(new _s("Worker was terminated."));for(let v of o)k.push(v.finished),v.terminate();await Promise.all(k),p.destroy(),p=null}),p.on("Ready",function(){S(e),e=null}),d}static initializeFromPort(e){let n=new AS("worker","main",e);this.setup(n,e),n.send("ready",null)}};globalThis.pdfjsWorker={WorkerMessageHandler:iM}});function u1e(t){let e=t.width??ru.width;if(t.bottom!=null){let n=t.maxHeight??ru.maxHeight;return{pageIndex:t.pageIndex,x:t.x,y:t.bottom-n,w:e,h:n,align:"bottom"}}return{pageIndex:t.pageIndex,x:t.x,y:t.y??0,w:e,h:t.maxHeight??1/0,align:"top"}}function h1e(t,e){let n=Math.min(t.w,t.h/e),r=n*e,s=t.align==="bottom"?t.y+t.h-r:t.y;return{pageIndex:t.pageIndex,x:t.x,y:s,width:n,height:r}}var ru,NZ,jM=H(()=>{"use strict";ru={width:170,maxHeight:55};f(u1e,"frameFromPlacement");f(h1e,"boxInFrame");NZ=f((t,e)=>h1e(u1e(t),e),"fitPlacement")});var HZ={};$l(HZ,{assertPdfReadable:()=>CM,locateSignatureSpot:()=>pw,normalizeText:()=>_Z,placementAbove:()=>zZ});function zZ(t){return{pageIndex:t.pageIndex,x:t.x+8,bottom:t.baseline-18,width:ru.width,maxHeight:ru.maxHeight}}function b1e(t,e){let[n,r,s,i]=e.transform,o=[],a=[];for(let u of t){if(typeof u.str!="string"||!u.str.trim()||!u.transform)continue;let h=u.transform,[d,p]=e.convertToViewportPoint(h[4],h[5]),m=Math.hypot(h[2],h[3])||u.height||10,g={str:u.str,x:d,y:p,w:Math.max(0,u.width??0),size:m},b=n*h[0]+s*h[1],x=r*h[0]+i*h[1];(b>0&&Math.abs(x)<=Math.abs(b)*.05?o:a).push(g)}o.sort((u,h)=>u.y-h.y||u.x-h.x);let c=[];for(let u of o){let h=c[c.length-1];h&&Math.abs(u.y-h[0].y)<=Math.max(1,.3*Math.min(u.size,h[0].size))?h.push(u):c.push([u])}let l=[];for(let u of[...c,...a.map(h=>[h])]){u.sort((g,b)=>g.x-b.x);let h={text:"",at:[]},d=null,p=-1/0,m=f((g,b,x)=>{if(/\s/.test(g)){if(!h.text||h.text.endsWith(" "))return;g=" "}h.text+=g,h.at.push({x:b,y:x})},"push");for(let g of u){if(d&&g.str===d.str&&Math.abs(g.x-d.x)<.5*g.size)continue;let b=g.x-p;d&&b>g1e*g.size?(l.push(h),h={text:"",at:[]}):d&&b>m1e*g.size&&m(" ",g.x,g.y);let x=[...g.str];x.forEach((w,y)=>{let S=g.x+g.w*y/x.length;for(let k of LZ(w))m(k,S,g.y)}),d=g,p=Math.max(p,g.x+g.w)}l.push(h)}for(let u of l)u.text.endsWith(" ")&&(u.text=u.text.slice(0,-1),u.at.pop());return l.filter(u=>u.text)}function MZ(t,e){return e?t.pageIndex!==e.pageIndex?t.pageIndex>e.pageIndex:Math.abs(t.y-e.y)>1?t.y>e.y:t.x>e.x:!0}function x1e(t,e){let n=/^[^\p{L}\p{N}]*/u.exec(t)?.[0].length??0,r=t.slice(n);return!r.startsWith(e)||r.length>e.length+p1e||/[\p{L}\p{N}]/u.test(r[e.length]??"")?-1:n}async function BZ(t){let e=_I({data:new Uint8Array(t),useSystemFonts:!1,disableFontFace:!0,verbosity:0});try{let n=await e.promise;if(await n.getPermissions()!==null)throw new Mt("ENCRYPTED");return{task:e,doc:n}}catch(n){if(await e.destroy(),n instanceof Mt)throw n;let r=n?.name;throw r==="PasswordException"?new Mt("ENCRYPTED"):r==="InvalidPDFException"||r==="FormatError"||r==="UnknownErrorException"?new Mt("NOT_PDF"):n}}async function CM(t){await(await BZ(t)).task.destroy()}async function pw(t,e){let{task:n,doc:r}=await BZ(t);try{let s=d1e(e??"");if(s){let c=null;for(let l=r.numPages;l>=1;l--){let u=await r.getPage(l),h=u.getViewport({scale:1}),{items:d}=await u.getTextContent(),p=null,m=null;for(let g of b1e(d,h)){let b=x1e(g.text,s);if(b>=0){let w={pageIndex:l-1,...g.at[b]};MZ(w,p)&&(p=w)}let x=g.text.lastIndexOf(s);if(x>=0){let w={pageIndex:l-1,...g.at[x]};MZ(w,m)&&(m=w)}}if(p){c=p;break}c??=m}if(c){let l={pageIndex:c.pageIndex,x:Math.round(c.x),baseline:Math.round(c.y)};return{placement:zZ(l),anchor:{text:e??null,found:!0,page:c.pageIndex+1},pageCount:r.numPages}}}let i=await r.getPage(r.numPages),{width:o,height:a}=i.getViewport({scale:1});return{placement:{pageIndex:r.numPages-1,x:Math.round((o-ru.width)/2),bottom:Math.round(a-96),width:ru.width,maxHeight:ru.maxHeight},anchor:{text:e||null,found:!1,page:r.numPages},pageCount:r.numPages}}finally{await n.destroy()}}var LZ,_Z,d1e,p1e,m1e,g1e,LS=H(()=>{"use strict";hY();DZ();jM();Vl();f(zZ,"placementAbove");LZ=f(t=>t.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase(),"fold"),_Z=f(t=>LZ(t).replace(/\s+/g," ").trim(),"normalizeText"),d1e=f(t=>_Z(t).replace(/\s*:$/,"").trim(),"needleOf"),p1e=60,m1e=.15,g1e=3;f(b1e,"pageSegments");f(MZ,"later");f(x1e,"labelStart");f(BZ,"openReadable");f(CM,"assertPdfReadable");f(pw,"locateSignatureSpot")});var ZZ={};$l(ZZ,{CLOSE_GRACE_MS:()=>LM,MAX_PENDING:()=>PM,MAX_UPLOAD:()=>C0,createAwaitingSignSession:()=>DM,createSession:()=>nm,documentBytes:()=>$S,getSession:()=>iu,nextOutputPath:()=>FM,outputDir:()=>BS,pageOpened:()=>OM,prepareSignSession:()=>US,publicState:()=>Xi,readPdf:()=>gw,safePdfName:()=>XZ,sameToken:()=>su,signedBytes:()=>VS,startDetached:()=>GS,uiCancel:()=>rm,uiClose:()=>_M,uiConfirm:()=>vw,uiDeleteSignature:()=>yw,uiDocumentChunk:()=>NM,uiFinish:()=>T0,uiReveal:()=>Sw,uiSaveSignature:()=>ww,uiSetPrefs:()=>xw,uiSignedChunk:()=>zM,uiState:()=>mw,uiUploadChunk:()=>bw,waitForClose:()=>O1e,waitForSession:()=>HS});import{readFileSync as VZ,writeFileSync as w1e,existsSync as GZ}from"node:fs";import{randomBytes as WZ,timingSafeEqual as y1e}from"node:crypto";import{basename as Qp,dirname as _S,extname as v1e,join as qM,sep as S1e}from"node:path";import{EventEmitter as k1e}from"node:events";import{spawn as A1e}from"node:child_process";import{homedir as EM}from"node:os";function nm({kind:t,client:e,closeOnSave:n=!0}){let r=0;for(let i of em.values())i.status==="pending"&&r++;if(r>=PM)throw new Mt("TOO_MANY_OPEN",{max:PM});let s={id:WZ(6).toString("hex"),kind:t,status:"pending",client:e,openToken:TM(),viewToken:TM(),cookie:TM(),opened:!1,closed:!1,openPages:0,signing:!1,createdAt:Date.now(),closeOnSave:n,saved:[],result:null,file:null,original:null,placements:null,anchor:null,anchorText:null,hasDigitalSignature:!1,awaiting:!1,uploaded:!1,upload:null};return em.set(s.id,s),setTimeout(()=>{s.status==="pending"&&(s.kind==="pad"&&s.saved.length?T0(s):tm(s,"expired",null))},j1e).unref(),s}function tm(t,e,n){return t.status!=="pending"?!1:(t.status=e,t.result=n,t.upload=null,j0.emit(t.id),setTimeout(()=>t.original=null,C1e).unref(),setTimeout(()=>em.delete(t.id),T1e).unref(),!0)}function OM(t){t.opened=!0,t.openPages++,t.closed=!1}function HS(t,e){let n=em.get(t);return!n||n.status!=="pending"?Promise.resolve(n):new Promise(r=>{let s=f(()=>{clearTimeout(i),j0.off(t,s),r(n)},"done"),i=setTimeout(s,e);j0.once(t,s)})}function Xi(t){return t?{request_id:t.id,kind:t.kind,status:t.status,...t.kind==="sign"&&t.awaiting?{awaiting_document:!0}:{},...t.kind==="sign"&&t.anchor?{anchor_found:t.anchor.found}:{},...t.result??{}}:{status:"unknown"}}function FM(t){let e=v1e(t),n=qM(_S(t),Qp(t,e)),r=`${n}.assinado${e}`;for(let s=2;GZ(r);s++)r=`${n}.assinado-${s}${e}`;return r}function mw(t){let e=null;return t.kind==="sign"&&(e=t.awaiting?{awaiting:!0,maxBytes:C0,outputDir:BS(),outputDirLabel:$Z(BS())}:{name:Qp(t.file),outputName:Qp(FM(t.file)),outputDir:_S(t.file),outputDirLabel:$Z(_S(t.file)),uploaded:t.uploaded,bytes:t.original?.length??0,hasDigitalSignature:t.hasDigitalSignature,anchor:t.anchor,placements:t.placements}),{kind:t.kind,status:t.status,result:t.status==="pending"?null:Xi(t),document:e,signatures:gk(),prefs:Wm()}}function gw(t){let e;try{e=VZ(t)}catch(n){let r=n.code;throw r==="ENOENT"?new Mt("FILE_NOT_FOUND",{file:t}):r==="EISDIR"?new Mt("NOT_PDF"):n}return KZ(e),e}function KZ(t){if(t.subarray(0,5).toString()!=="%PDF-")throw new Mt("NOT_PDF")}function US({file:t,bytes:e=gw(t),placements:n,anchor:r=null,client:s}){let i=nm({kind:"sign",client:s});return i.file=t,i.original=e,i.placements=n,i.anchor=r,i.hasDigitalSignature=UC(e),i}function DM({anchorText:t,client:e}){let n=nm({kind:"sign",client:e});return n.awaiting=!0,n.anchorText=t||"CONTRATANTE",n}function YZ(t){if(!(t.status==="pending"||t.kind==="pad"&&t.status==="signed"))throw new Mt("SESSION_CLOSED",{status:t.status})}function $S(t){if(t.kind!=="sign"||!t.original)throw new Mt("NO_DOCUMENT");return t.original}function JZ(t,e,n){let r=Math.max(0,Math.min(Number(e)||0,t.length)),s=Math.min(t.length,r+Math.min(Number(n)||UZ,UZ));return{total:t.length,offset:r,data:t.subarray(r,s).toString("base64")}}async function bw(t,{name:e,size:n,offset:r=0,data:s}){if(t.status!=="pending")throw new Mt("SESSION_CLOSED",{status:t.status});if(t.kind!=="sign"||!t.awaiting)throw new Mt("NOT_AWAITING");if(n=Number(n),!Number.isInteger(n)||n<5)throw new Mt("UPLOAD_EMPTY");if(n>C0)throw new Mt("UPLOAD_TOO_BIG",{mb:C0/1024/1024});let i=Buffer.isBuffer(s)?s:Buffer.from(String(s??""),"base64");(Number(r)===0||!t.upload)&&(t.upload={name:XZ(e),size:n,parts:[],received:0});let o=t.upload;if(o.size!==n||Number(r)!==o.received)throw new Mt("UPLOAD_OUT_OF_ORDER");if(o.received+i.length>n)throw new Mt("UPLOAD_OVERFLOW");if(o.parts.push(i),o.received+=i.length,o.received<n)return{received:o.received,total:n,done:!1};let a=Buffer.concat(o.parts);t.upload=null,KZ(a);let{placement:c,anchor:l}=await pw(a,t.anchorText);if(t.status!=="pending")throw new Mt("SESSION_CLOSED",{status:t.status});return t.original=a,t.file=qM(BS(),o.name),t.placements=[c],t.anchor=l,t.hasDigitalSignature=UC(a),t.awaiting=!1,t.uploaded=!0,Yl({event:"document_received",name:o.name,bytes:a.length,sha256:$c(a),client:t.client}),{received:n,total:n,done:!0}}function E1e(t){if(!Array.isArray(t)||!t.length||t.length>I1e)throw new Mt("EMPTY_DRAWING");let e=0;for(let n of t){if(!Array.isArray(n)||!n.length)throw new Mt("EMPTY_DRAWING");if(e+=n.length,e>R1e)throw new Mt("EMPTY_DRAWING");for(let r of n)if(!Array.isArray(r)||r.length<2||r.length>3||!r.every(s=>typeof s=="number"&&Number.isFinite(s)&&Math.abs(s)<1e5))throw new Mt("EMPTY_DRAWING")}}function ww(t,{label:e,kind:n,strokes:r}){YZ(t),E1e(r);let s=bk({label:e,kind:n,strokes:r});return Yl({event:"signature_created",signature:s.id,label:s.label,client:t.client}),t.saved.push(s),t.kind==="pad"&&t.closeOnSave&&t.status==="pending"&&tm(t,"signed",{signature_id:s.id,signature_label:s.label,signatures_saved:1}),s}function yw(t,{id:e}){YZ(t);let n=xk(e);return t.saved=t.saved.filter(r=>r.id!==e),Yl({event:"signature_deleted",signature:n.id,label:n.label,client:t.client}),n}function T0(t){if(t.status==="pending"){let e=t.saved.at(-1);t.kind==="pad"&&e?tm(t,"signed",{signature_id:e.id,signature_label:e.label,signatures_saved:t.saved.length}):tm(t,"cancelled",null)}return Xi(t)}function rm(t){return t.status==="pending"&&tm(t,"cancelled",null),Xi(t)}function P1e(t){if(!Array.isArray(t)||t.length===0||t.length>500)throw new Mt("INVALID_PLACEMENT");return t.map(e=>{let n={pageIndex:Number(e?.pageIndex),x:Number(e?.x),y:Number(e?.y),width:Number(e?.width)};if(!Number.isInteger(n.pageIndex)||n.pageIndex<0||![n.x,n.y,n.width].every(Number.isFinite)||n.width<10||n.width>2e3)throw new Mt("INVALID_PLACEMENT");return n})}async function vw(t,{signatureId:e,placements:n,ink:r,pen:s}){if(t.kind!=="sign")throw new Mt("NOT_A_SIGN_SESSION");if(t.status!=="pending"||t.signing)throw new Mt("SESSION_CLOSED",{status:t.signing?"signing":t.status});if(t.awaiting||!t.original||!t.file||!t.placements)throw new Mt("NO_DOCUMENT");let i=Wm(),o=r??i.ink,a=s??i.pen;if(!G0(o))throw new Mt("INVALID_INK");if(!V0(a))throw new Mt("INVALID_PEN");let c=Gm(e),l=$m(c.strokes,RB(a)),u=l.height/l.width,h=Array.isArray(n)&&n.length?P1e(n):t.placements.map(m=>NZ(m,u)),d=t.original,p=t.file;t.signing=!0;try{let{bytes:m}=await yX({pdfBytes:d,signature:l,placements:h,mode:"incremental",color:EB(o)});if(t.status!=="pending")throw new Mt("SESSION_CLOSED",{status:t.status});let g=FM(p);w1e(g,m,{flag:"wx"});let b=[...new Set(h.map(w=>w.pageIndex+1))],x;try{wk(c.id),x=Yl({event:"document_signed",file:t.uploaded?null:p,received_as:t.uploaded?Qp(p):void 0,output:g,sha256_original:$c(d),sha256_signed:$c(m),signature:c.id,label:c.label,ink:o,pen:a,pages:b,placements:h.map(w=>({page:w.pageIndex+1,x:IM(w.x),y:IM(w.y),width:IM(w.width)})),client:t.client}).hash.slice(0,12)}catch(w){console.error("[labsign] assinado, mas o registro de auditoria falhou:",w?.message??w)}return tm(t,"signed",{signed_file:g,sha256_original:$c(d),sha256_signed:$c(m),pages:b,signature_label:c.label,audit_id:x,original_preserved_as_prefix:!0}),Xi(t)}finally{t.signing=!1}}function MM(t){if(t.kind!=="sign"||t.status!=="signed"||!t.result?.signed_file)throw new Mt("NOT_SIGNED_YET");return t.result.signed_file}async function Sw(t){let e=MM(t);if(process.env.LABSIGN_NO_OPEN==="1")return{revealed:!1,file:e};let n=process.platform==="win32",[r,s]=process.platform==="darwin"?["open",["-R",e]]:n?["explorer.exe",[`/select,"${e}"`]]:["xdg-open",[_S(e)]];return{revealed:await GS(r,s,{windowsVerbatimArguments:n}),file:e}}function GS(t,e,n={}){return new Promise(r=>{try{let s=A1e(t,e,{stdio:"ignore",detached:!0,windowsHide:!0,...n});s.once("error",()=>r(!1)),s.once("spawn",()=>{s.unref(),r(!0)})}catch{r(!1)}})}function _M(t,e=LM){return t.openPages=Math.max(0,t.openPages-1),t.openPages>0?{closed:!1}:(t.closed=!0,j0.emit(`close:${t.id}`),clearTimeout(RM.get(t.id)),t.status==="pending"&&RM.set(t.id,setTimeout(()=>{RM.delete(t.id),t.closed&&T0(t)},e).unref()),{closed:!0})}function q1e(t,e){return new Promise(n=>{let r=f(()=>{clearTimeout(s),j0.off(`close:${t}`,r),n()},"done"),s=setTimeout(r,e);j0.once(`close:${t}`,r)})}async function O1e(t,e,n=LM){let r=em.get(t),s=Date.now()+e;for(;r&&Date.now()<s;)if(r.closed||await q1e(t,s-Date.now()),!r.closed||(await new Promise(i=>setTimeout(i,Math.min(n,Math.max(0,s-Date.now())))),r.closed))return}var em,j0,j1e,C1e,T1e,PM,UZ,C0,TM,su,iu,BS,$Z,XZ,NM,xw,I1e,R1e,IM,VS,zM,LM,RM,WS=H(()=>{"use strict";Vl();vX();LS();jM();dk();Y0();em=new Map,j0=new k1e;j0.setMaxListeners(100);j1e=1800*1e3,C1e=3600*1e3,T1e=1440*60*1e3,PM=20,UZ=512*1024,C0=30*1024*1024,TM=f(()=>WZ(24).toString("base64url"),"token"),su=f((t,e)=>{let n=Buffer.from(String(t??"")),r=Buffer.from(String(e??""));return n.length===r.length&&y1e(n,r)},"sameToken");f(nm,"createSession");iu=f(t=>em.get(t),"getSession");f(tm,"finish");f(OM,"pageOpened");f(HS,"waitForSession");f(Xi,"publicState");f(FM,"nextOutputPath");BS=f(()=>{let t=process.env.LABSIGN_OUTPUT_DIR||qM(EM(),"Downloads");return GZ(t)?t:EM()},"outputDir"),$Z=f(t=>{let e=EM();return t===e||t.startsWith(e+S1e)?`~${t.slice(e.length)}`:t},"folderLabel");f(mw,"uiState");f(gw,"readPdf");f(KZ,"checkPdf");f(US,"prepareSignSession");f(DM,"createAwaitingSignSession");XZ=f(t=>{let e=Qp(String(t||"")).replace(/[\x00-\x1f<>:"/\\|?*]+/g," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").slice(0,120)||"documento.pdf";return/\.pdf$/i.test(e)?e:`${e}.pdf`},"safePdfName");f(YZ,"assertOpen");f($S,"documentBytes");f(JZ,"chunkOf");NM=f((t,{offset:e,length:n}={})=>JZ($S(t),e,n),"uiDocumentChunk");f(bw,"uiUploadChunk");xw=f((t,e)=>yk(e),"uiSetPrefs"),I1e=400,R1e=6e4;f(E1e,"checkStrokes");f(ww,"uiSaveSignature");f(yw,"uiDeleteSignature");f(T0,"uiFinish");f(rm,"uiCancel");f(P1e,"sanitizePlacements");IM=f(t=>Math.round(t*10)/10,"r1");f(vw,"uiConfirm");f(MM,"signedPath");VS=f(t=>VZ(MM(t)),"signedBytes"),zM=f((t,{offset:e,length:n}={})=>({...JZ(VS(t),e,n),name:Qp(MM(t))}),"uiSignedChunk");f(Sw,"uiReveal");f(GS,"startDetached");LM=3e3,RM=new Map;f(_M,"uiClose");f(q1e,"onceClosed");f(O1e,"waitForClose")});var nQ={};$l(nQ,{ensureHttp:()=>kw,openInBrowser:()=>XS,publicUrl:()=>Aw,sessionUrl:()=>KS,uiFile:()=>sm});import F1e from"node:http";import{readFileSync as D1e,existsSync as N1e}from"node:fs";import{randomBytes as M1e}from"node:crypto";import{fileURLToPath as z1e}from"node:url";import{dirname as L1e,join as QZ}from"node:path";function sm(t){let e=L1e(z1e(import.meta.url)),n=[QZ(e,t),QZ(e,"../../dist",t)].find(r=>N1e(r));if(!n)throw new Error(`${t} not found \u2014 run "npm run build"`);return n}function kw(){return BM??=new Promise((t,e)=>{let n=F1e.createServer((r,s)=>{B1e(r,s).catch(i=>gs(s,500,Mi(i)))});n.once("error",r=>{BM=null,e(r)}),n.listen(0,"127.0.0.1",()=>{I0=n.address().port,n.unref(),t(I0)})}),BM}function XS(t){if(process.env.LABSIGN_NO_OPEN==="1")return Promise.resolve(!1);let e=process.env.LABSIGN_BROWSER,[n,r]=e?[e,[t]]:process.platform==="darwin"?["open",[t]]:process.platform==="win32"?["cmd",["/c","start","",t]]:["xdg-open",[t]];return GS(n,r)}function gs(t,e,n){t.headersSent||(t.writeHead(e,{"content-type":"application/json; charset=utf-8","cache-control":"no-store",...YS}),t.end(JSON.stringify(n)))}function HM(t,e,n,r){let s=Hm(String(t.headers["accept-language"]??"").split(",")[0]),[i,o]=_1e[s][r];e.writeHead(n,{"content-type":"text/html; charset=utf-8","cache-control":"no-store","content-security-policy":"default-src 'none'; style-src 'unsafe-inline'",...YS}),e.end(`<!doctype html><html lang="${s}"><meta charset="utf-8"><title>labsign</title><body style="font:16px system-ui;padding:48px;max-width:560px;margin:auto"><h1 style="font-size:20px">${i}</h1><p>${o}</p>`)}async function B1e(t,e){if(t.headers.host!==`127.0.0.1:${I0}`)return gs(e,403,Mi(new Mt("BAD_HOST")));let n=new URL(t.url??"/",`http://127.0.0.1:${I0}`),r=n.pathname.split("/").filter(Boolean);if(t.method==="GET"&&r[0]==="s"&&r[1]){let s=iu(r[1]);if(!s)return HM(t,e,404,"notFound");let i=su(eQ(t,`ls_${s.id}`),s.cookie);if(!i&&!su(n.searchParams.get("t"),s.openToken))return HM(t,e,404,"notFound");if(s.opened&&!i)return Yl({event:"session_reopen_blocked",session:s.id,ua:String(t.headers["user-agent"]??"")}),HM(t,e,409,"reopened");OM(s);let o=M1e(18).toString("base64"),a=process.env.LABSIGN_LANG?{lang:Hm(process.env.LABSIGN_LANG)}:{},c=`<script nonce="${o}">window.__LABSIGN_HTTP__=${JSON.stringify({sessionId:s.id,viewToken:s.viewToken,...a})}</script>`;e.writeHead(200,{"content-type":"text/html; charset=utf-8","cache-control":"no-store","set-cookie":`ls_${s.id}=${s.cookie}; HttpOnly; SameSite=Strict; Path=/`,"content-security-policy":`default-src 'none'; script-src 'nonce-${o}'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,"referrer-policy":"no-referrer","x-content-type-options":"nosniff",...YS});let l=D1e(sm("ui.html"),"utf8").replace("<!--LABSIGN_BOOT-->",()=>c).replace('nonce="__LABSIGN_NONCE__"',()=>`nonce="${o}"`);return void e.end(l)}if(t.method==="POST"&&r[0]==="api"&&r[1]&&r[2]){let s=iu(r[1]);if(!s)return gs(e,404,Mi(new Mt("NOT_FOUND")));let i=t.headers.origin;if(i&&i!==`http://127.0.0.1:${I0}`)return gs(e,403,Mi(new Mt("BAD_ORIGIN")));let o=t.headers["sec-fetch-site"];if(o&&o!=="same-origin"&&o!=="none")return gs(e,403,Mi(new Mt("BAD_ORIGIN")));let a=r[2]==="upload_document",c=a?C0:5e6,l=[],u=0;for await(let m of t){if(u+=m.length,u>c)return gs(e,413,Mi(new Mt(a?"UPLOAD_TOO_BIG":"BODY_TOO_BIG",{mb:C0/1024/1024})));l.push(m)}let h=Buffer.concat(l),d={};try{d=a||!h.length?{}:JSON.parse(h.toString("utf8"))}catch{return gs(e,400,Mi(new Mt("INVALID_PLACEMENT")))}if(!d||typeof d!="object"||Array.isArray(d))return gs(e,400,Mi(new Mt("INVALID_PLACEMENT")));let p=t.headers["x-labsign-view"]??(r[2]==="close"?d.view_token:void 0);if(!su(p,s.viewToken)||!su(eQ(t,`ls_${s.id}`),s.cookie))return gs(e,401,Mi(new Mt("UNAUTHORIZED")));try{switch(r[2]){case"state":return gs(e,200,mw(s));case"document":return tQ(e,$S(s));case"signed_document":return tQ(e,VS(s));case"upload_document":return gs(e,200,await bw(s,{name:H1e(String(t.headers["x-labsign-filename"]??"")),size:h.length,offset:0,data:h}));case"save_signature":return gs(e,200,ww(s,d));case"delete_signature":return gs(e,200,yw(s,d));case"set_prefs":return gs(e,200,xw(s,d));case"confirm":return gs(e,200,await vw(s,d));case"reveal":return gs(e,200,await Sw(s));case"cancel":return gs(e,200,rm(s));case"finish":return gs(e,200,T0(s));case"close":return gs(e,200,_M(s))}}catch(m){return gs(e,400,Mi(m))}}return gs(e,404,Mi(new Mt("NOT_FOUND")))}function H1e(t){try{return decodeURIComponent(t)}catch{return t}}function tQ(t,e){t.writeHead(200,{"content-type":"application/pdf","content-length":e.length,"cache-control":"no-store",...YS}),t.end(e)}var BM,I0,KS,Aw,YS,_1e,eQ,JS=H(()=>{"use strict";Vl();Uy();WS();Y0();f(sm,"uiFile");BM=null,I0=0;f(kw,"ensureHttp");KS=f(t=>`http://127.0.0.1:${I0}/s/${t.id}?t=${t.openToken}`,"sessionUrl"),Aw=f(t=>`http://127.0.0.1:${I0}/s/${t.id}`,"publicUrl");f(XS,"openInBrowser");YS={connection:"close"};f(gs,"json");_1e={pt:{notFound:["Sess\xE3o n\xE3o encontrada","O link expirou ou \xE9 inv\xE1lido. Pe\xE7a um novo pedido de assinatura."],reopened:["Esta sess\xE3o j\xE1 foi aberta em outro lugar","Por seguran\xE7a, cada pedido de assinatura s\xF3 abre uma vez. Se n\xE3o foi voc\xEA, cancele e pe\xE7a um novo."]},en:{notFound:["Session not found","The link expired or is invalid. Ask for a new signing request."],reopened:["This session was already opened elsewhere","For safety, each signing request opens only once. If it wasn\u2019t you, cancel and ask for a new one."]}};f(HM,"page");eQ=f((t,e)=>(t.headers.cookie??"").split(/;\s*/).map(n=>n.split("=")).find(([n])=>n===e)?.[1],"cookieOf");f(B1e,"handle");f(H1e,"safeDecode");f(tQ,"sendPdf")});var Hc,ZS=H(()=>{"use strict";Hc="0.1.2"});var Zt={};$l(Zt,{BIGINT_FORMAT_RANGES:()=>r4,CONSTANT_CATCH:()=>gQ,Class:()=>KM,NUMBER_FORMAT_RANGES:()=>Cw,aborted:()=>ec,allowsEval:()=>ez,assert:()=>J1e,assertEqual:()=>W1e,assertIs:()=>X1e,assertNever:()=>Y1e,assertNotEqual:()=>K1e,assignProp:()=>xo,attachSchema:()=>i4,base64ToUint8Array:()=>pQ,base64urlToUint8Array:()=>gbe,cached:()=>lm,captureStackTrace:()=>t4,cleanEnum:()=>mbe,cleanRegex:()=>jw,clone:()=>Ta,cloneDef:()=>ebe,codePointLength:()=>Tw,constantCatch:()=>bQ,createTransparentProxy:()=>obe,defineLazy:()=>JM,defineLazyInternal:()=>Mn,derived:()=>ybe,esc:()=>ZM,escapeRegex:()=>ql,explicitlyAborted:()=>rz,extend:()=>lbe,finalizeIssue:()=>tc,floatSafeRemainder:()=>YM,getElementAtPath:()=>tbe,getEnumValues:()=>am,getLengthableOrigin:()=>Iw,getParsedType:()=>ibe,getSizableOrigin:()=>dQ,hexToUint8Array:()=>xbe,hide:()=>o4,installLazyProp:()=>Abe,isObject:()=>E0,isPlainObject:()=>cu,issue:()=>um,joinValues:()=>e4,jsonStringifyReplacer:()=>cm,members:()=>iz,merge:()=>ube,mergeDefs:()=>Pl,normalizeParams:()=>$t,nullish:()=>XM,numKeys:()=>sbe,objectClone:()=>Z1e,omit:()=>cbe,optionalKeys:()=>nz,own:()=>au,parsedType:()=>sz,partial:()=>hbe,pick:()=>abe,prefixIssues:()=>Ol,primitiveTypes:()=>uQ,promiseAllObject:()=>nbe,propertyKeyTypes:()=>tz,randomString:()=>rbe,rawShape:()=>fm,required:()=>dbe,safeExtend:()=>fbe,shallowClone:()=>fQ,slugify:()=>QM,stringifyPrimitive:()=>n4,toZod:()=>aQ,uint8ArrayToBase64:()=>mQ,uint8ArrayToBase64url:()=>bbe,uint8ArrayToHex:()=>wbe,unwrapMessage:()=>om});function W1e(t){return t}function K1e(t){return t}function aQ(){return t=>t}function X1e(t){}function Y1e(t){throw new Error("Unexpected value in exhaustive check")}function J1e(t){}function am(t){let e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}function e4(t,e="|"){return t.map(n=>n4(n)).join(e)}function cm(t,e){return typeof e=="bigint"?e.toString():e}function lm(t){return new WM(t)}function XM(t){return t==null}function jw(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function YM(t,e){let n=t/e,r=Math.round(n),s=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<s?0:n-r}function JM(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==oQ)return r===void 0&&(r=oQ,r=n()),r},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Z1e(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function xo(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function fm(t){let e=Object.getOwnPropertyDescriptor(t,"shape");return e?.get?e.get.raw:e?.value}function El(t){return fm(t._zod.def)??t._zod.def.shape}function cQ(t,e,n){Object.defineProperty(t,e,{get(){let r=n();return xo(this,e,r),r},enumerable:!0,configurable:!0})}function lQ(t,e,n){e in t?xo(t,e,n):t[e]=n}function R0(t,e,n,r){let s=El(e);for(let i of n){let o=Object.getOwnPropertyDescriptor(s,i);o.enumerable&&(o.get?cQ(t,i,()=>{let a=e._zod.def.shape[i];return r?r(a,i):a}):lQ(t,i,r?r(o.value,i):o.value))}}function Q1e(t,e){for(let n of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,n);r.enumerable&&(r.get?cQ(t,n,()=>e[n]):lQ(t,n,r.value))}}function Pl(...t){let e={};for(let n of t){let r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function ebe(t){return Pl(t._zod.def)}function tbe(t,e){return e?e.reduce((n,r)=>n?.[r],t):t}function nbe(t){let e=Object.keys(t),n=e.map(r=>t[r]);return Promise.all(n).then(r=>{let s={};for(let i=0;i<e.length;i++)s[e[i]]=r[i];return s})}function rbe(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<t;r++)n+=e[Math.floor(Math.random()*e.length)];return n}function ZM(t){return JSON.stringify(t)}function QM(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function E0(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function cu(t){if(E0(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let n=e.prototype;return!(E0(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function fQ(t){return cu(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function sbe(t){let e=0;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function ql(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ta(t,e,n){let r=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(r._zod.parent=t),r}function $t(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:f(()=>e,"error")};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:f(()=>e.error,"error")}:e}function obe(t){let e;return new Proxy({},{get(n,r,s){return e??(e=t()),Reflect.get(e,r,s)},set(n,r,s,i){return e??(e=t()),Reflect.set(e,r,s,i)},has(n,r){return e??(e=t()),Reflect.has(e,r)},deleteProperty(n,r){return e??(e=t()),Reflect.deleteProperty(e,r)},ownKeys(n){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(n,r){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,r)},defineProperty(n,r,s){return e??(e=t()),Reflect.defineProperty(e,r,s)}})}function n4(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function nz(t){return Object.keys(t).filter(e=>t[e]._zod.optin!==void 0&&t[e]._zod.optout==="optional")}function abe(t,e){let n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return R0(i,t,s4(t,e)),Ta(t,Pl(n,{shape:i,checks:[]}))}function s4(t,e){let n=El(t),r=[];for(let s of Reflect.ownKeys(e)){if(!Object.getOwnPropertyDescriptor(n,s)?.enumerable)throw new Error(`Unrecognized key: "${String(s)}"`);e[s]&&r.push(s)}return r}function cbe(t,e){let n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(s4(t,e)),o={};return R0(o,t,Reflect.ownKeys(El(t)).filter(a=>!i.has(a))),Ta(t,Pl(n,{shape:o,checks:[]}))}function lbe(t,e){if(!cu(e))throw new Error("Invalid input to extend: expected a plain object");let n=t._zod.def.checks;if(n&&n.length>0){let s=El(t);for(let i of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ta(t,Pl(t._zod.def,{shape:hQ(t,e)}))}function hQ(t,e){let n={};return R0(n,t,Reflect.ownKeys(El(t))),Q1e(n,e),n}function fbe(t,e){if(!cu(e))throw new Error("Invalid input to safeExtend: expected a plain object");return Ta(t,Pl(t._zod.def,{shape:hQ(t,e)}))}function ube(t,e){if(!e?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};R0(n,t,Reflect.ownKeys(El(t))),R0(n,e,Reflect.ownKeys(El(e)));let r=Pl(t._zod.def,{shape:n,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ta(t,r)}function hbe(t,e,n,r="partial"){let i=e._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(s4(e,n)):void 0,c={};return R0(c,e,Reflect.ownKeys(El(e)),t&&((l,u)=>a&&!a.has(u)?l:new t({type:"optional",innerType:l}))),Ta(e,Pl(e._zod.def,{shape:c,checks:[]}))}function dbe(t,e,n){let r=n?new Set(s4(e,n)):void 0,s={};return R0(s,e,Reflect.ownKeys(El(e)),(i,o)=>r&&!r.has(o)?i:new t({type:"nonoptional",innerType:i})),Ta(e,Pl(e._zod.def,{shape:s}))}function ec(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function rz(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue===!1)return!0;return!1}function Ol(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function om(t){return typeof t=="string"?t:t?.message}function i4(t,e,n){var r;for(let s=e;s<t.length;s++)(r=t[s]).schema??(r.schema=n)}function tc(t,e,n){var r;let s=t.inst?._zod?.traits;s?.has("$ZodType")&&(s.has("$ZodCheck")?(r=t).schema??(r.schema=t.inst):t.schema=t.inst);let i=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,o=t.message?t.message:om(t.inst?._zod.def?.error?.(t))??om(i?.(t))??om(e?.error?.(t))??om(n.customError?.(t))??om(n.localeError?.(t))??"Invalid input",a={};for(let c of Object.keys(t))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=t[c]);return a.path??(a.path=[]),a.message=o,e?.reportInput&&(a.input=t.input),a}function dQ(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Tw(t){let e=t.length;if(!pbe.test(t))return e;let n=e;for(let r=0;r<e-1;r++)(t.charCodeAt(r)&64512)===55296&&(t.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function Iw(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function sz(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let n=t;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return e}function um(...t){let[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}function mbe(t){return Object.entries(t).filter(([e,n])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function pQ(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}function mQ(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function gbe(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return pQ(e+n)}function bbe(t){return mQ(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function xbe(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)n[r/2]=Number.parseInt(e.slice(r,r+2),16);return n}function wbe(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function iz(t,e){for(let n in e){let r=Object.getOwnPropertyDescriptor(e,n);r.get?Object.defineProperty(t,n,{...r,enumerable:!1}):vbe(t,n,r.value)}}function au(t,e,n,r=!0){return Object.defineProperty(t,e,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function o4(t,e,n){return au(t,e,n,!1)}function ybe(t,e){for(let n in t){let r=t[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get(){return au(this,n,r(this))},set(s){au(this,n,s)}})}return e}function vbe(t,e,n){Object.defineProperty(t,e,{configurable:!0,get(){return this==null?n:au(this,e,n.bind(this))},set(r){au(this,e,r)}})}function Sbe(t,e){let n=Object.getPrototypeOf(t);return e in n?void 0:n}function Mn(t,e,n){let r=Object.getPrototypeOf(t._zod);if(e in r&&GM!==t._zod){GM=void 0;return}GM=t._zod,Object.defineProperty(r,e,{configurable:!0,get(){Object.defineProperty(this,e,kbe);let s=ou;ou=!1;try{let i=n(this);return ou?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:i}),ou=ou||s,i}catch(i){throw delete this[e],ou=ou||s,i}},set(s){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:s})}})}function Abe(t,e,n,r){let s=Sbe(t,e);s&&Object.defineProperty(s,e,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,e,i),i.value=n(this),Object.defineProperty(this,e,i),i.value},set(i){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:r,value:i})}})}function bQ(t){let e=f(()=>t,"fn");return e[gQ]=!0,e}var WM,oQ,t4,ez,ibe,tz,uQ,Cw,r4,pbe,KM,GM,ou,kbe,gQ,wo=H(()=>{P0();f(W1e,"assertEqual");f(K1e,"assertNotEqual");f(aQ,"toZod");f(X1e,"assertIs");f(Y1e,"assertNever");f(J1e,"assert");f(am,"getEnumValues");f(e4,"joinValues");f(cm,"jsonStringifyReplacer");WM=class{static{f(this,"Cached")}constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};f(lm,"cached");f(XM,"nullish");f(jw,"cleanRegex");f(YM,"floatSafeRemainder");oQ=Symbol("evaluating");f(JM,"defineLazy");f(Z1e,"objectClone");f(xo,"assignProp");f(fm,"rawShape");f(El,"sourceShape");f(cQ,"deferProp");f(lQ,"putProp");f(R0,"mirrorShape");f(Q1e,"mirrorProps");f(Pl,"mergeDefs");f(ebe,"cloneDef");f(tbe,"getElementAtPath");f(nbe,"promiseAllObject");f(rbe,"randomString");f(ZM,"esc");f(QM,"slugify");t4="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};f(E0,"isObject");ez=lm(()=>{if(yo.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});f(cu,"isPlainObject");f(fQ,"shallowClone");f(sbe,"numKeys");ibe=f(t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},"getParsedType"),tz=new Set(["string","number","symbol"]),uQ=new Set(["string","number","bigint","boolean","symbol","undefined"]);f(ql,"escapeRegex");f(Ta,"clone");f($t,"normalizeParams");f(obe,"createTransparentProxy");f(n4,"stringifyPrimitive");f(nz,"optionalKeys");Cw={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},r4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};f(abe,"pick");f(s4,"maskedKeys");f(cbe,"omit");f(lbe,"extend");f(hQ,"extended");f(fbe,"safeExtend");f(ube,"merge");f(hbe,"partial");f(dbe,"required");f(ec,"aborted");f(rz,"explicitlyAborted");f(Ol,"prefixIssues");f(om,"unwrapMessage");f(i4,"attachSchema");f(tc,"finalizeIssue");f(dQ,"getSizableOrigin");pbe=/[\uD800-\uDBFF]/;f(Tw,"codePointLength");f(Iw,"getLengthableOrigin");f(sz,"parsedType");f(um,"issue");f(mbe,"cleanEnum");f(pQ,"base64ToUint8Array");f(mQ,"uint8ArrayToBase64");f(gbe,"base64urlToUint8Array");f(bbe,"uint8ArrayToBase64url");f(xbe,"hexToUint8Array");f(wbe,"uint8ArrayToHex");KM=class{static{f(this,"Class")}constructor(...e){}};f(iz,"members");f(au,"own");f(o4,"hide");f(ybe,"derived");f(vbe,"defineBound");f(Sbe,"claim");ou=!1,kbe={configurable:!0,get(){ou=!0}};f(Mn,"defineLazyInternal");f(Abe,"installLazyProp");gQ="~constantCatch";f(bQ,"constantCatch")});function jbe(t){let e=wQ;if(e){let n=e.stackTraceLimit;if(typeof n=="number"){try{e.stackTraceLimit=0}catch{return wQ=null,new t}try{return new t}finally{e.stackTraceLimit=n}}}return new t}function Oe(t,e,n,r){let s={};function i(d){this.def=d,this.constr=h,this.traits=new Set}f(i,"Internals"),i.prototype=s;let o=n,a=o&&new WeakSet;function c(d,p){if(d._zod){if(d._zod.traits.has(t))return}else{oz.value=new i(p);try{Object.defineProperty(d,"_zod",oz)}finally{oz.value=void 0}}if(d._zod.traits.add(t),e(d,p),a){let g=Object.getPrototypeOf(d),b=d._zod.constr.prototype,x=g;for(;x&&x!==b;)x=Object.getPrototypeOf(x);let w=x??g;a.has(w)||(a.add(w),iz(w,o))}let m=h.prototype;for(let g in m)Object.prototype.hasOwnProperty.call(m,g)&&(g in d||(d[g]=m[g].bind(d)))}f(c,"init");let l=r?.Parent??Object;class u extends l{static{f(this,"Definition")}}Object.defineProperty(u,"name",{value:t});function h(d){let p=r?.Parent?jbe(u):this;c(p,d);let m=p._zod.deferred;if(m){for(let b of m)b();p._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;return g&&g(p),p}return f(h,"_"),Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:f(d=>r?.Parent&&d instanceof r.Parent?!0:d?._zod?.traits?.has(t),"value")}),Object.defineProperty(h,"name",{value:t}),h}function vo(t){return t&&Object.assign(yo,t),yo}var xQ,az,oz,wQ,nc,hm,yo,P0=H(()=>{wo();az=Object.freeze({status:"aborted"}),oz={value:void 0,enumerable:!1},wQ="captureStackTrace"in Error?Error:null;f(jbe,"newError");f(Oe,"$constructor");nc=class extends Error{static{f(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},hm=class extends Error{static{f(this,"$ZodEncodeError")}constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(xQ=globalThis).__zod_globalConfig??(xQ.__zod_globalConfig={});yo=globalThis.__zod_globalConfig;f(vo,"config")});function Cbe(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,cm,2)),t.message}function Tbe(t){this._zod.message=t}function Rbe(t,e,n){return Object.prototype.hasOwnProperty.call(t,e)||(e==="__proto__"?Object.defineProperty(t,e,{value:n(),writable:!0,enumerable:!0,configurable:!0}):t[e]=n()),t[e]}function fz(t,e=n=>n.message){let n={},r=[];for(let s of t.issues)s.path.length>0?Rbe(n,s.path[0],()=>[]).push(e(s)):r.push(e(s));return{formErrors:r,fieldErrors:n}}function uz(t,e=n=>n.message){let n={_errors:[]},r=f((s,i=[])=>{for(let o of s.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>r({issues:a},[...i,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...i,...o.path]);else{let a=[...i,...o.path];if(a.length===0)n._errors.push(e(o));else{let c=n,l=0;for(;l<a.length;){let u=a[l],h=l===a.length-1;if(u==="_errors"){h&&c._errors.push(e(o)),l++;continue}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];h&&d._errors.push(e(o)),c=d,l++}}}},"processError");return r(t),n}var Ibe,lz,yQ,vQ,SQ,yXe,kQ=H(()=>{P0();wo();f(Cbe,"_getMessage");f(Tbe,"_setMessage");Ibe={get:Cbe,set:Tbe,enumerable:!0,configurable:!0},lz={value:void 0,enumerable:!1},yQ=new WeakSet([Object.prototype,Error.prototype]),vQ=f((t,e)=>{t.name="$ZodError",lz.value=e,Object.defineProperty(t,"issues",lz),lz.value=void 0,Object.defineProperty(t,"message",Ibe);let n=Object.getPrototypeOf(t);yQ.has(n)||(yQ.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=f(()=>this.message,"value");return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},"initializer"),SQ=Oe("$ZodError",vQ),yXe=Oe("$ZodError",vQ,void 0,{Parent:Error});f(Rbe,"node");f(fz,"flattenError");f(uz,"formatError")});function a4(t,e){return{callee:e?.callee??t,Err:e?.Err}}function AQ(t,e,n){let r;return{success:!1,get error(){return r||(r=new t(e.map(s=>tc(s,n,vo()))),e=void 0,n=void 0),r},set error(s){r=s,e=void 0,n=void 0}}}function qbe(t,e,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},s=t._zod.bag.fallbackRun,i;if(s?(r[Pbe]=!0,i=s({value:e,issues:[]},r)):i=t._zod.run({value:e,issues:[]},r),i instanceof Promise)throw new nc;return i.issues.length===0}var c4,l4,f4,u4,Ebe,Pbe,hz,dz,jQ,CQ,TQ,IQ,RQ,EQ,PQ,qQ,OQ=H(()=>{P0();wo();f(a4,"finalizeParams");c4=f(t=>{let e=f((n,r,s,i)=>{let o=s?{...s,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new nc;if(a.issues.length){let c=new(i?.Err??t)(a.issues.map(l=>tc(l,o,vo())));throw t4(c,i?.callee??e),c}return a.value},"fn");return e},"_parse"),l4=f(t=>{let e=f(async(n,r,s,i)=>{let o=s?{...s,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??t)(a.issues.map(l=>tc(l,o,vo())));throw t4(c,i?.callee??e),c}return a.value},"fn");return e},"_parseAsync"),f4=f(t=>(e,n,r)=>{let s=r?{...r,async:!1}:{async:!1},i=e._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new nc;return i.issues.length?AQ(t,i.issues,s):{success:!0,data:i.value}},"_safeParse");f(AQ,"failure");u4=f(t=>async(e,n,r)=>{let s=r?{...r,async:!0}:{async:!0},i=e._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?AQ(t,i.issues,s):{success:!0,data:i.value}},"_safeParseAsync"),Ebe=Symbol.for("zod.compile.invalid"),Pbe=Symbol.for("zod.compile.fallback"),hz=f(((t,e,n)=>{let r=t._zod.bag.validator;if(r!==void 0){if(r(e)!==Ebe)return!0;if(r.definite===!0&&n===void 0)return!1}return qbe(t,e,n)}),"validate");f(qbe,"validateFallback");dz=f(async(t,e,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},s=t._zod.run({value:e,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length===0},"validateAsync"),jQ=f(t=>{let e=c4(t),n=f((r,s,i,o)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return e(r,s,a,a4(n,o))},"fn");return n},"_encode"),CQ=f(t=>{let e=c4(t),n=f((r,s,i,o)=>e(r,s,i,a4(n,o)),"fn");return n},"_decode"),TQ=f(t=>{let e=l4(t),n=f(async(r,s,i,o)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await e(r,s,a,a4(n,o))},"fn");return n},"_encodeAsync"),IQ=f(t=>{let e=l4(t),n=f(async(r,s,i,o)=>await e(r,s,i,a4(n,o)),"fn");return n},"_decodeAsync"),RQ=f(t=>(e,n,r)=>{let s=r?{...r,direction:"backward"}:{direction:"backward"};return f4(t)(e,n,s)},"_safeEncode"),EQ=f(t=>(e,n,r)=>f4(t)(e,n,r),"_safeDecode"),PQ=f(t=>async(e,n,r)=>{let s=r?{...r,direction:"backward"}:{direction:"backward"};return u4(t)(e,n,s)},"_safeEncodeAsync"),qQ=f(t=>async(e,n,r)=>u4(t)(e,n,r),"_safeDecodeAsync")});function _Q(t){return new RegExp(`^[a-zA-Z0-9_-]{${t}}$`)}function $Q(){return new RegExp(Obe,"u")}function Fbe(t){return new RegExp(`^${t}$`)}function pz(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${e}:[0-5]\\d(?:\\.\\d+)?`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tee(t){return new RegExp(`^${pz(t)}$`)}function nee(t){let e=["Z"];t.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${pz({precision:t.precision,seconds:!0})}(?:${e.join("|")})`,r=t.local?`${n}|${pz({precision:t.precision})}`:n;return new RegExp(`^${QQ}T(?:${r})$`)}var FQ,DQ,NQ,MQ,zQ,LQ,BQ,HQ,mz,UQ,Obe,VQ,GQ,WQ,KQ,XQ,YQ,JQ,ZQ,QQ,eee,ree,see,gz,Rw,iee,oee,aee,cee,Ew=H(()=>{FQ=/^[cC][0-9a-z]{6,}$/,DQ=/^[0-9a-z]+$/,NQ=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,MQ=/^[0-9a-vA-V]{20}$/,zQ=/^[A-Za-z0-9]{27}$/,LQ=/^[a-zA-Z0-9_-]{21}$/;f(_Q,"nanoidOfLength");BQ=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,HQ=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mz=f(t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,"uuid"),UQ=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Obe="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";f($Q,"emoji");VQ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,GQ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,WQ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,KQ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,XQ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,YQ=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,JQ=/^https?$/,ZQ=/^\+[1-9]\d{6,14}$/,QQ="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";f(Fbe,"anchor");eee=Fbe(QQ);f(pz,"timeSource");f(tee,"time");f(nee,"datetime");ree=/^[\s\S]{0,}$/,see=/^-?\d+n?$/,gz=/^-?\d+$/,Rw=/^-?\d+(?:\.\d+)?$/,iee=/^(?:true|false)$/i,oee=/^null$/i,aee=/^[^A-Z]*$/,cee=/^[^a-z]*$/});var bi,bz,h4,xz,wz,lee,fee,uee,hee,dee,Pw,pee,mee,gee,bee,xee,wee,yee,d4=H(()=>{P0();Ew();wo();bi=Oe("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),bz=f(t=>{let e=t.value;return!XM(e)&&e.length!==void 0},"_whenHasLength"),h4={number:"number",bigint:"bigint",object:"date"},xz=Oe("$ZodCheckLessThan",(t,e)=>{bi.init(t,e);let n=h4[typeof e.value];t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:h4[typeof r.value]??n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),wz=Oe("$ZodCheckGreaterThan",(t,e)=>{bi.init(t,e);let n=h4[typeof e.value];t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:h4[typeof r.value]??n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),lee=Oe("$ZodCheckMultipleOf",(t,e)=>{bi.init(t,e),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?e.value!==BigInt(0)&&n.value%e.value===BigInt(0):YM(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),fee=Oe("$ZodCheckNumberFormat",(t,e)=>{bi.init(t,e),e.format=e.format||"float64";let n=e.format?.includes("int"),r=n?"int":"number",[s,i]=Cw[e.format];t._zod.check=o=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}a<s&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>i&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),uee=Oe("$ZodCheckMaxLength",(t,e)=>{var n;bi.init(t,e),(n=t._zod.def).when??(n.when=bz),t._zod.check=r=>{let s=r.value,i=s.length;if((typeof s=="string"&&i>e.maximum?Tw(s):i)<=e.maximum)return;let a=Iw(s);r.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),hee=Oe("$ZodCheckMinLength",(t,e)=>{var n;bi.init(t,e),(n=t._zod.def).when??(n.when=bz),t._zod.check=r=>{let s=r.value,i=s.length;if((typeof s=="string"&&i>=e.minimum&&i<e.minimum*2?Tw(s):i)>=e.minimum)return;let a=Iw(s);r.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),dee=Oe("$ZodCheckLengthEquals",(t,e)=>{var n;bi.init(t,e),(n=t._zod.def).when??(n.when=bz),t._zod.check=r=>{let s=r.value,i=s.length,o=typeof s=="string"&&i>=e.length&&i<=e.length*2?Tw(s):i;if(o===e.length)return;let a=Iw(s),c=o>e.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Pw=Oe("$ZodCheckStringFormat",(t,e)=>{var n,r;bi.init(t,e),e.pattern?(n=t._zod).check??(n.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),pee=Oe("$ZodCheckRegex",(t,e)=>{Pw.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),mee=Oe("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=aee),Pw.init(t,e)}),gee=Oe("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=cee),Pw.init(t,e)}),bee=Oe("$ZodCheckIncludes",(t,e)=>{bi.init(t,e);let n=ql(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position},}${n}`:n);e.pattern=r,t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),xee=Oe("$ZodCheckStartsWith",(t,e)=>{bi.init(t,e);let n=new RegExp(`^${ql(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),wee=Oe("$ZodCheckEndsWith",(t,e)=>{bi.init(t,e);let n=new RegExp(`.*${ql(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),yee=Oe("$ZodCheckOverwrite",(t,e)=>{bi.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}})});var p4,yz=H(()=>{p4=class{static{f(this,"Doc")}constructor(e=[],n={}){this.content=[],this.indent=0,this.args=e,this.closed=n}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
217
217
|
`).filter(o=>o),s=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(let o of i)this.content.push(o)}compile(){let e=Function,n=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
218
218
|
${n.join(`
|
|
219
219
|
`)}
|