@mlightcad/cad-pdf-plugin 1.7.1 → 1.7.3

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 mlightcad
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mlightcad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,180 +1,180 @@
1
- # @mlightcad/cad-pdf-plugin
2
-
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![npm version](https://img.shields.io/npm/v/@mlightcad/cad-pdf-plugin.svg)](https://www.npmjs.com/package/@mlightcad/cad-pdf-plugin)
5
-
6
- PDF **export** and **import** plugin for [`@mlightcad/cad-simple-viewer`](../cad-simple-viewer). Registers system commands:
7
-
8
- | Command | Description |
9
- |---------|-------------|
10
- | `-cpdf` | Export via **command-line prompts** (no dialog; AutoCAD-style `-` prefix) |
11
- | `cpdf` | Same as `-cpdf` when no UI command is registered. In [`cad-viewer`](../cad-viewer), `cpdf` opens an **export options dialog** instead |
12
- | `ipdf` | Import vector geometry from a PDF file into model space |
13
-
14
- The plugin is designed for **lazy loading** so PDF libraries (`pdf-lib` via `@mlightcad/pdf-renderer`, `pdfjs-dist`) are only downloaded when a user runs `-cpdf` / `cpdf` or `ipdf`.
15
-
16
- ## Key features
17
-
18
- - **Vector PDF export** — renders model space and each paper-space layout as PDF pages with `@mlightcad/pdf-renderer` (native AcGi PDF backend). Paper-space pages include model content shown through viewports, clipped to each viewport frame.
19
- - **Busy indicator** — export shows the same conversion spinner as `chtml` so the browser stays responsive
20
- - **Export options** — model-space framing (`Extents` / `Display`) and optional paper-space layouts
21
- - **PDF import** — parses vector paths from the first page of a PDF (lines, polylines, Bézier curves) and appends CAD entities
22
- - **Plugin API** — implements `AcApPlugin`; register once with `registerLazyPdfPlugin`
23
- - **Framework-agnostic** — no Vue/React dependency; works anywhere `cad-simple-viewer` runs
24
-
25
- ## Installation
26
-
27
- ```bash
28
- pnpm add @mlightcad/cad-pdf-plugin
29
- ```
30
-
31
- Peer dependencies:
32
-
33
- - `@mlightcad/cad-simple-viewer`
34
- - `@mlightcad/data-model`
35
- - `@mlightcad/pdf-renderer`
36
-
37
- Runtime dependencies (bundled with this package):
38
-
39
- - `pdfjs-dist` (import only)
40
-
41
- ## Build
42
-
43
- Produces `dist/index.js` (main library) and `dist/register.js` (lazy-registration entry).
44
-
45
- ```bash
46
- pnpm --filter @mlightcad/cad-pdf-plugin build
47
- ```
48
-
49
- ## Usage
50
-
51
- ### Lazy registration (recommended)
52
-
53
- Register the plugin with the document manager's plugin manager. Import from the `/register` subpath so only the registration stub enters your initial bundle; the main plugin chunk loads on first use of `-cpdf`, `cpdf`, or `ipdf`:
54
-
55
- ```typescript
56
- import { AcApDocManager } from '@mlightcad/cad-simple-viewer'
57
- import { registerLazyPdfPlugin } from '@mlightcad/cad-pdf-plugin/register'
58
-
59
- registerLazyPdfPlugin(AcApDocManager.instance.pluginManager)
60
- ```
61
-
62
- Do **not** import `registerLazyPdfPlugin` from the package root in application code — that resolves to the full library build and defeats lazy loading.
63
-
64
- Equivalent manual registration:
65
-
66
- ```typescript
67
- import {
68
- createPdfPlugin,
69
- PDF_PLUGIN_NAME,
70
- PDF_PLUGIN_TRIGGERS
71
- } from '@mlightcad/cad-pdf-plugin'
72
-
73
- AcApDocManager.instance.pluginManager.registerLazyPlugin({
74
- name: PDF_PLUGIN_NAME,
75
- triggers: [...PDF_PLUGIN_TRIGGERS],
76
- loader: createPdfPlugin
77
- })
78
- ```
79
-
80
- After registration, users (or your UI) invoke commands through the editor:
81
-
82
- ```typescript
83
- // Export current drawing to PDF (command-line prompts)
84
- await AcApDocManager.instance.editor.executeCommand('-cpdf')
85
-
86
- // Open file picker and import PDF vectors
87
- await AcApDocManager.instance.editor.executeCommand('ipdf')
88
- ```
89
-
90
- In [`cad-viewer`](../cad-viewer), use `cpdf` to open the export options dialog; `-cpdf` remains available on the command line for prompt-based export.
91
-
92
- `cad-viewer` registers this plugin automatically via `registerLazyPlugins()` in its app bootstrap and registers the `cpdf` dialog command separately.
93
-
94
- ### Eager registration
95
-
96
- If you prefer loading PDF support up front:
97
-
98
- ```typescript
99
- import { AcApPdfPlugin } from '@mlightcad/cad-pdf-plugin'
100
-
101
- await AcApDocManager.instance.pluginManager.loadPlugin(new AcApPdfPlugin())
102
- ```
103
-
104
- ### Programmatic convertors
105
-
106
- You can bypass the command layer and call the convertors directly:
107
-
108
- ```typescript
109
- import { AcApContext } from '@mlightcad/cad-simple-viewer'
110
- import {
111
- AcApPdfConvertor,
112
- AcApPdfImportConvertor,
113
- resolveAcApPdfExportOptions
114
- } from '@mlightcad/cad-pdf-plugin'
115
-
116
- // Export
117
- const context: AcApContext = /* active context */
118
- await new AcApPdfConvertor().convert(
119
- context,
120
- resolveAcApPdfExportOptions({
121
- modelSpaceFit: 'extents',
122
- exportLayouts: true
123
- })
124
- )
125
-
126
- // Import from bytes
127
- const buffer: ArrayBuffer = /* PDF file */
128
- await new AcApPdfImportConvertor().convert(context, buffer, 1) // page 1
129
- ```
130
-
131
- ## How it works
132
-
133
- ### Export (`-cpdf` / dialog)
134
-
135
- 1. Collect options: model-space framing (`Extents` / `Display`) and whether to export layouts.
136
- 2. Show the application busy overlay (same animation pattern as `chtml`).
137
- 3. Call `@mlightcad/pdf-renderer` `exportDatabaseToPdf`. With layouts enabled, model space and every paper space become one PDF page each.
138
- 4. Download the resulting PDF bytes.
139
-
140
- ### Import (`ipdf`)
141
-
142
- 1. Show a native file picker (`.pdf`).
143
- 2. Use `pdfjs-dist` to read operator lists from the selected page.
144
- 3. Convert path operators (move, line, cubic Bézier, close) into `AcDbLine` / `AcDbPolyline` entities in model space.
145
-
146
- Import is **vector-only**; raster/scanned PDF pages produce no entities. Only the requested page is processed (default: page 1).
147
-
148
- ## Main exports
149
-
150
- | Export | Role |
151
- |--------|------|
152
- | `createPdfPlugin` | Async factory used by lazy loader |
153
- | `PDF_PLUGIN_NAME`, `PDF_PLUGIN_TRIGGERS` | Plugin id and command triggers |
154
- | `@mlightcad/cad-pdf-plugin/register` | `registerLazyPdfPlugin` and registration constants |
155
- | `AcApPdfPlugin` | `AcApPlugin` implementation |
156
- | `AcApConvertToPdfCmd` | `-cpdf` / fallback `cpdf` command class |
157
- | `AcApImportPdfCmd` | `ipdf` command class |
158
- | `AcApPdfConvertor` | CAD → PDF export utility |
159
- | `AcApPdfExportOptions`, `resolveAcApPdfExportOptions` | Export option types and defaults |
160
- | `AcApPdfImportConvertor` | PDF → CAD entities import utility |
161
-
162
- ## Project layout
163
-
164
- | Path | Role |
165
- |------|------|
166
- | `src/register.ts` | Lazy plugin registration (`/register` entry) and `createPdfPlugin` |
167
- | `src/AcApPdfPlugin.ts` | Plugin lifecycle (`onLoad` / `onUnload`) |
168
- | `src/AcApConvertToPdfCmd.ts` | `-cpdf` command (command-line prompts) |
169
- | `src/AcApImportPdfCmd.ts` | `ipdf` command |
170
- | `src/AcApPdfConvertor.ts` | Export pipeline (`exportDatabaseToPdf`) |
171
- | `src/AcApPdfExportOptions.ts` | Export option types and defaults |
172
- | `src/AcApPdfImportConvertor.ts` | Import pipeline (pdf.js operator parsing) |
173
-
174
- ## Role in MLightCAD
175
-
176
- This package extends `cad-simple-viewer` with optional PDF I/O. Export uses `@mlightcad/pdf-renderer`; import uses `pdfjs-dist`. Heavy PDF dependencies stay out of the core viewer bundle through lazy loading.
177
-
178
- ## License
179
-
180
- MIT
1
+ # @mlightcad/cad-pdf-plugin
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm version](https://img.shields.io/npm/v/@mlightcad/cad-pdf-plugin.svg)](https://www.npmjs.com/package/@mlightcad/cad-pdf-plugin)
5
+
6
+ PDF **export** and **import** plugin for [`@mlightcad/cad-simple-viewer`](../cad-simple-viewer). Registers system commands:
7
+
8
+ | Command | Description |
9
+ |---------|-------------|
10
+ | `-cpdf` | Export via **command-line prompts** (no dialog; AutoCAD-style `-` prefix) |
11
+ | `cpdf` | Same as `-cpdf` when no UI command is registered. In [`cad-viewer`](../cad-viewer), `cpdf` opens an **export options dialog** instead |
12
+ | `ipdf` | Import vector geometry from a PDF file into model space |
13
+
14
+ The plugin is designed for **lazy loading** so PDF libraries (`pdf-lib` via `@mlightcad/pdf-renderer`, `pdfjs-dist`) are only downloaded when a user runs `-cpdf` / `cpdf` or `ipdf`.
15
+
16
+ ## Key features
17
+
18
+ - **Vector PDF export** — renders model space and each paper-space layout as PDF pages with `@mlightcad/pdf-renderer` (native AcGi PDF backend). Paper-space pages include model content shown through viewports, clipped to each viewport frame.
19
+ - **Busy indicator** — export shows the same conversion spinner as `chtml` so the browser stays responsive
20
+ - **Export options** — model-space framing (`Extents` / `Display`) and optional paper-space layouts
21
+ - **PDF import** — parses vector paths from the first page of a PDF (lines, polylines, Bézier curves) and appends CAD entities
22
+ - **Plugin API** — implements `AcApPlugin`; register once with `registerLazyPdfPlugin`
23
+ - **Framework-agnostic** — no Vue/React dependency; works anywhere `cad-simple-viewer` runs
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pnpm add @mlightcad/cad-pdf-plugin
29
+ ```
30
+
31
+ Peer dependencies:
32
+
33
+ - `@mlightcad/cad-simple-viewer`
34
+ - `@mlightcad/data-model`
35
+ - `@mlightcad/pdf-renderer`
36
+
37
+ Runtime dependencies (bundled with this package):
38
+
39
+ - `pdfjs-dist` (import only)
40
+
41
+ ## Build
42
+
43
+ Produces `dist/index.js` (main library) and `dist/register.js` (lazy-registration entry).
44
+
45
+ ```bash
46
+ pnpm --filter @mlightcad/cad-pdf-plugin build
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### Lazy registration (recommended)
52
+
53
+ Register the plugin with the document manager's plugin manager. Import from the `/register` subpath so only the registration stub enters your initial bundle; the main plugin chunk loads on first use of `-cpdf`, `cpdf`, or `ipdf`:
54
+
55
+ ```typescript
56
+ import { AcApDocManager } from '@mlightcad/cad-simple-viewer'
57
+ import { registerLazyPdfPlugin } from '@mlightcad/cad-pdf-plugin/register'
58
+
59
+ registerLazyPdfPlugin(AcApDocManager.instance.pluginManager)
60
+ ```
61
+
62
+ Do **not** import `registerLazyPdfPlugin` from the package root in application code — that resolves to the full library build and defeats lazy loading.
63
+
64
+ Equivalent manual registration:
65
+
66
+ ```typescript
67
+ import {
68
+ createPdfPlugin,
69
+ PDF_PLUGIN_NAME,
70
+ PDF_PLUGIN_TRIGGERS
71
+ } from '@mlightcad/cad-pdf-plugin'
72
+
73
+ AcApDocManager.instance.pluginManager.registerLazyPlugin({
74
+ name: PDF_PLUGIN_NAME,
75
+ triggers: [...PDF_PLUGIN_TRIGGERS],
76
+ loader: createPdfPlugin
77
+ })
78
+ ```
79
+
80
+ After registration, users (or your UI) invoke commands through the editor:
81
+
82
+ ```typescript
83
+ // Export current drawing to PDF (command-line prompts)
84
+ await AcApDocManager.instance.editor.executeCommand('-cpdf')
85
+
86
+ // Open file picker and import PDF vectors
87
+ await AcApDocManager.instance.editor.executeCommand('ipdf')
88
+ ```
89
+
90
+ In [`cad-viewer`](../cad-viewer), use `cpdf` to open the export options dialog; `-cpdf` remains available on the command line for prompt-based export.
91
+
92
+ `cad-viewer` registers this plugin automatically via `registerLazyPlugins()` in its app bootstrap and registers the `cpdf` dialog command separately.
93
+
94
+ ### Eager registration
95
+
96
+ If you prefer loading PDF support up front:
97
+
98
+ ```typescript
99
+ import { AcApPdfPlugin } from '@mlightcad/cad-pdf-plugin'
100
+
101
+ await AcApDocManager.instance.pluginManager.loadPlugin(new AcApPdfPlugin())
102
+ ```
103
+
104
+ ### Programmatic convertors
105
+
106
+ You can bypass the command layer and call the convertors directly:
107
+
108
+ ```typescript
109
+ import { AcApContext } from '@mlightcad/cad-simple-viewer'
110
+ import {
111
+ AcApPdfConvertor,
112
+ AcApPdfImportConvertor,
113
+ resolveAcApPdfExportOptions
114
+ } from '@mlightcad/cad-pdf-plugin'
115
+
116
+ // Export
117
+ const context: AcApContext = /* active context */
118
+ await new AcApPdfConvertor().convert(
119
+ context,
120
+ resolveAcApPdfExportOptions({
121
+ modelSpaceFit: 'extents',
122
+ exportLayouts: true
123
+ })
124
+ )
125
+
126
+ // Import from bytes
127
+ const buffer: ArrayBuffer = /* PDF file */
128
+ await new AcApPdfImportConvertor().convert(context, buffer, 1) // page 1
129
+ ```
130
+
131
+ ## How it works
132
+
133
+ ### Export (`-cpdf` / dialog)
134
+
135
+ 1. Collect options: model-space framing (`Extents` / `Display`) and whether to export layouts.
136
+ 2. Show the application busy overlay (same animation pattern as `chtml`).
137
+ 3. Call `@mlightcad/pdf-renderer` `exportDatabaseToPdf`. With layouts enabled, model space and every paper space become one PDF page each.
138
+ 4. Download the resulting PDF bytes.
139
+
140
+ ### Import (`ipdf`)
141
+
142
+ 1. Show a native file picker (`.pdf`).
143
+ 2. Use `pdfjs-dist` to read operator lists from the selected page.
144
+ 3. Convert path operators (move, line, cubic Bézier, close) into `AcDbLine` / `AcDbPolyline` entities in model space.
145
+
146
+ Import is **vector-only**; raster/scanned PDF pages produce no entities. Only the requested page is processed (default: page 1).
147
+
148
+ ## Main exports
149
+
150
+ | Export | Role |
151
+ |--------|------|
152
+ | `createPdfPlugin` | Async factory used by lazy loader |
153
+ | `PDF_PLUGIN_NAME`, `PDF_PLUGIN_TRIGGERS` | Plugin id and command triggers |
154
+ | `@mlightcad/cad-pdf-plugin/register` | `registerLazyPdfPlugin` and registration constants |
155
+ | `AcApPdfPlugin` | `AcApPlugin` implementation |
156
+ | `AcApConvertToPdfCmd` | `-cpdf` / fallback `cpdf` command class |
157
+ | `AcApImportPdfCmd` | `ipdf` command class |
158
+ | `AcApPdfConvertor` | CAD → PDF export utility |
159
+ | `AcApPdfExportOptions`, `resolveAcApPdfExportOptions` | Export option types and defaults |
160
+ | `AcApPdfImportConvertor` | PDF → CAD entities import utility |
161
+
162
+ ## Project layout
163
+
164
+ | Path | Role |
165
+ |------|------|
166
+ | `src/register.ts` | Lazy plugin registration (`/register` entry) and `createPdfPlugin` |
167
+ | `src/AcApPdfPlugin.ts` | Plugin lifecycle (`onLoad` / `onUnload`) |
168
+ | `src/AcApConvertToPdfCmd.ts` | `-cpdf` command (command-line prompts) |
169
+ | `src/AcApImportPdfCmd.ts` | `ipdf` command |
170
+ | `src/AcApPdfConvertor.ts` | Export pipeline (`exportDatabaseToPdf`) |
171
+ | `src/AcApPdfExportOptions.ts` | Export option types and defaults |
172
+ | `src/AcApPdfImportConvertor.ts` | Import pipeline (pdf.js operator parsing) |
173
+
174
+ ## Role in MLightCAD
175
+
176
+ This package extends `cad-simple-viewer` with optional PDF I/O. Export uses `@mlightcad/pdf-renderer`; import uses `pdfjs-dist`. Heavy PDF dependencies stay out of the core viewer bundle through lazy loading.
177
+
178
+ ## License
179
+
180
+ MIT
@@ -18851,7 +18851,7 @@ class Ww extends lm {
18851
18851
  new Vw().importFromFilePicker(t);
18852
18852
  }
18853
18853
  }
18854
- const Xw = "1.7.1", Yw = {
18854
+ const Xw = "1.7.3", Yw = {
18855
18855
  version: Xw
18856
18856
  };
18857
18857
  class Kw {
@@ -52,4 +52,4 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
52
52
  `),position:E,pageIndex:x-1,rect:c.slice(0),rotation:u,annotationElementId:p,id:p,deleted:!1,popupRef:m,comment:(A==null?void 0:A.str)||null,richText:y,creationDate:v,modificationDate:w}}const a=await super.deserialize(e,s,i);return f(a,os,e.fontSize),a.color=D.makeHexColor(...e.color),f(a,as,b(o=wt,xn,Rp).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=At._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,os),value:b(this,Yt,Kb).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!b(this,Yt,qb).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,os)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,as).split(`
53
53
  `)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:n(this,as)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};as=new WeakMap,id=new WeakMap,Ua=new WeakMap,os=new WeakMap,Yt=new WeakSet,Wb=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,os))*this.parentScale),f(this,os,r),b(this,Yt,ru).call(this)},i=n(this,os);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Xb=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Yb=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(b(i=wt,xn,au).call(i,r)),s=r);return e.join(`
54
54
  `)},ru=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},xn=new WeakSet,au=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Rd,"")},ou=function(){if(this.editorDiv.replaceChildren(),!!n(this,as))for(const e of n(this,as).split(`
55
- `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Kb=function(){return n(this,as).replaceAll(" "," ")},Rp=function(e){return e.replaceAll(" "," ")},qb=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},g(wt,xn),P(wt,"_freeTextDefaultContent",""),P(wt,"_internalPadding",0),P(wt,"_defaultColor",null),P(wt,"_defaultFontSize",10),P(wt,"_type","freetext"),P(wt,"_editorType",$.FREETEXT);let Lp=wt;class O{toSVGPath(){rt("Abstract method `toSVGPath` must be implemented.")}get box(){rt("Abstract getter `box` must be implemented.")}serialize(t,e){rt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}P(O,"PRECISION",1e-4);var ls,Ys,Tl,Pl,vi,J,Ga,$a,nd,rd,kl,Ml,gr,ad,Ju,Zu,Jt,vh,Qb,Jb,Zb,ty,ey,sy;const Ni=class Ni{constructor({x:t,y:e},s,i,r,a,o=0){g(this,Jt);g(this,ls);g(this,Ys,[]);g(this,Tl);g(this,Pl);g(this,vi,[]);g(this,J,new Float32Array(18));g(this,Ga);g(this,$a);g(this,nd);g(this,rd);g(this,kl);g(this,Ml);g(this,gr,[]);f(this,ls,s),f(this,Ml,r*i),f(this,Pl,a),n(this,J).set([NaN,NaN,NaN,NaN,t,e],6),f(this,Tl,o),f(this,rd,n(Ni,ad)*i),f(this,nd,n(Ni,Zu)*i),f(this,kl,i),n(this,gr).push(t,e)}isEmpty(){return isNaN(n(this,J)[8])}add({x:t,y:e}){var k;f(this,Ga,t),f(this,$a,e);const[s,i,r,a]=n(this,ls);let[o,l,h,c]=n(this,J).subarray(8,12);const u=t-h,p=e-c,m=Math.hypot(u,p);if(m<n(this,nd))return!1;const y=m-n(this,rd),A=y/m,v=A*u,w=A*p;let S=o,E=l;o=h,l=c,h+=v,c+=w,(k=n(this,gr))==null||k.push(t,e);const x=-w/y,_=v/y,C=x*n(this,Ml),T=_*n(this,Ml);return n(this,J).set(n(this,J).subarray(2,8),0),n(this,J).set([h+C,c+T],4),n(this,J).set(n(this,J).subarray(14,18),12),n(this,J).set([h-C,c-T],16),isNaN(n(this,J)[6])?(n(this,vi).length===0&&(n(this,J).set([o+C,l+T],2),n(this,vi).push(NaN,NaN,NaN,NaN,(o+C-s)/r,(l+T-i)/a),n(this,J).set([o-C,l-T],14),n(this,Ys).push(NaN,NaN,NaN,NaN,(o-C-s)/r,(l-T-i)/a)),n(this,J).set([S,E,o,l,h,c],6),!this.isEmpty()):(n(this,J).set([S,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,S-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=n(this,J).subarray(2,6),n(this,vi).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,S,E]=n(this,J).subarray(14,18),n(this,Ys).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-i)/a),!0):([S,E,o,l,h,c]=n(this,J).subarray(0,6),n(this,vi).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),[h,c,o,l,S,E]=n(this,J).subarray(12,18),n(this,Ys).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,vi),e=n(this,Ys);if(isNaN(n(this,J)[6])&&!this.isEmpty())return b(this,Jt,Qb).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);b(this,Jt,Zb).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return b(this,Jt,Jb).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new iy(t,e,s,i,r,a)}getOutlines(){var u;const t=n(this,vi),e=n(this,Ys),s=n(this,J),[i,r,a,o]=n(this,ls),l=new Float32Array((((u=n(this,gr))==null?void 0:u.length)??0)+2);for(let p=0,m=l.length-2;p<m;p+=2)l[p]=(n(this,gr)[p]-i)/a,l[p+1]=(n(this,gr)[p+1]-r)/o;if(l[l.length-2]=(n(this,Ga)-i)/a,l[l.length-1]=(n(this,$a)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,Jt,ty).call(this,l);const h=new Float32Array(n(this,vi).length+24+n(this,Ys).length);let c=t.length;for(let p=0;p<c;p+=2){if(isNaN(t[p])){h[p]=h[p+1]=NaN;continue}h[p]=t[p],h[p+1]=t[p+1]}c=b(this,Jt,sy).call(this,h,c);for(let p=e.length-6;p>=6;p-=6)for(let m=0;m<6;m+=2){if(isNaN(e[p+m])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[p+m],h[c+1]=e[p+m+1],c+=2}return b(this,Jt,ey).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,ls),n(this,kl),n(this,Tl),n(this,Pl))}};ls=new WeakMap,Ys=new WeakMap,Tl=new WeakMap,Pl=new WeakMap,vi=new WeakMap,J=new WeakMap,Ga=new WeakMap,$a=new WeakMap,nd=new WeakMap,rd=new WeakMap,kl=new WeakMap,Ml=new WeakMap,gr=new WeakMap,ad=new WeakMap,Ju=new WeakMap,Zu=new WeakMap,Jt=new WeakSet,vh=function(){const t=n(this,J).subarray(4,6),e=n(this,J).subarray(16,18),[s,i,r,a]=n(this,ls);return[(n(this,Ga)+(t[0]-e[0])/2-s)/r,(n(this,$a)+(t[1]-e[1])/2-i)/a,(n(this,Ga)+(e[0]-t[0])/2-s)/r,(n(this,$a)+(e[1]-t[1])/2-i)/a]},Qb=function(){const[t,e,s,i]=n(this,ls),[r,a,o,l]=b(this,Jt,vh).call(this);return`M${(n(this,J)[2]-t)/s} ${(n(this,J)[3]-e)/i} L${(n(this,J)[4]-t)/s} ${(n(this,J)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,J)[16]-t)/s} ${(n(this,J)[17]-e)/i} L${(n(this,J)[14]-t)/s} ${(n(this,J)[15]-e)/i} Z`},Jb=function(t){const e=n(this,Ys);t.push(`L${e[4]} ${e[5]} Z`)},Zb=function(t){const[e,s,i,r]=n(this,ls),a=n(this,J).subarray(4,6),o=n(this,J).subarray(16,18),[l,h,c,u]=b(this,Jt,vh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${u} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},ty=function(t){const e=n(this,J),[s,i,r,a]=n(this,ls),[o,l,h,c]=b(this,Jt,vh).call(this),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(u,t,n(this,ls),n(this,kl),n(this,Tl),n(this,Pl))},ey=function(t,e){const s=n(this,Ys);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},sy=function(t,e){const s=n(this,J).subarray(4,6),i=n(this,J).subarray(16,18),[r,a,o,l]=n(this,ls),[h,c,u,p]=b(this,Jt,vh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},g(Ni,ad,8),g(Ni,Ju,2),g(Ni,Zu,n(Ni,ad)+n(Ni,Ju));let Cu=Ni;var Dl,ja,fn,od,hs,ld,jt,tf,ny;class iy extends O{constructor(e,s,i,r,a,o){super();g(this,tf);g(this,Dl);g(this,ja,new Float32Array(4));g(this,fn);g(this,od);g(this,hs);g(this,ld);g(this,jt);f(this,jt,e),f(this,hs,s),f(this,Dl,i),f(this,ld,r),f(this,fn,a),f(this,od,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,tf,ny).call(this,o);const[l,h,c,u]=n(this,ja);for(let p=0,m=e.length;p<m;p+=2)e[p]=(e[p]-l)/c,e[p+1]=(e[p+1]-h)/u;for(let p=0,m=s.length;p<m;p+=2)s[p]=(s[p]-l)/c,s[p+1]=(s[p+1]-h)/u}toSVGPath(){const e=[`M${n(this,jt)[4]} ${n(this,jt)[5]}`];for(let s=6,i=n(this,jt).length;s<i;s+=6){if(isNaN(n(this,jt)[s])){e.push(`L${n(this,jt)[s+4]} ${n(this,jt)[s+5]}`);continue}e.push(`C${n(this,jt)[s]} ${n(this,jt)[s+1]} ${n(this,jt)[s+2]} ${n(this,jt)[s+3]} ${n(this,jt)[s+4]} ${n(this,jt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let h,c;switch(a){case 0:h=O._rescale(n(this,jt),e,r,o,-l),c=O._rescale(n(this,hs),e,r,o,-l);break;case 90:h=O._rescaleAndSwap(n(this,jt),e,s,o,l),c=O._rescaleAndSwap(n(this,hs),e,s,o,l);break;case 180:h=O._rescale(n(this,jt),i,s,-o,l),c=O._rescale(n(this,hs),i,s,-o,l);break;case 270:h=O._rescaleAndSwap(n(this,jt),i,r,-o,-l),c=O._rescaleAndSwap(n(this,hs),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,ja)}newOutliner(e,s,i,r,a,o=0){return new Cu(e,s,i,r,a,o)}getNewOutline(e,s){const[i,r,a,o]=n(this,ja),[l,h,c,u]=n(this,Dl),p=a*c,m=o*u,y=i*c+l,A=r*u+h,v=this.newOutliner({x:n(this,hs)[0]*p+y,y:n(this,hs)[1]*m+A},n(this,Dl),n(this,ld),e,n(this,od),s??n(this,fn));for(let w=2;w<n(this,hs).length;w+=2)v.add({x:n(this,hs)[w]*p+y,y:n(this,hs)[w+1]*m+A});return v.getOutlines()}}Dl=new WeakMap,ja=new WeakMap,fn=new WeakMap,od=new WeakMap,hs=new WeakMap,ld=new WeakMap,jt=new WeakMap,tf=new WeakSet,ny=function(e){const s=n(this,jt);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,h=i,c=r;const u=e?Math.max:Math.min,p=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const v=s[y+4],w=s[y+5];isNaN(s[y])?(D.pointBoundingBox(v,w,a),l>w?(o=v,l=w):l===w&&(o=u(o,v)),c<w?(h=v,c=w):c===w&&(h=u(h,v))):(p.set(vn,0),D.bezierBoundingBox(i,r,...s.slice(y,y+6),p),D.rectBoundingBox(...p,a),l>p[1]?(o=p[0],l=p[1]):l===p[1]&&(o=u(o,p[0])),c<p[3]?(h=p[2],c=p[3]):c===p[3]&&(h=u(h,p[2]))),i=v,r=w}const m=n(this,ja);m[0]=a[0]-n(this,fn),m[1]=a[1]-n(this,fn),m[2]=a[2]-a[0]+2*n(this,fn),m[3]=a[3]-a[1]+2*n(this,fn),this.firstPoint=[o,l],this.lastPoint=[h,c]};var hd,cd,dd,mr,Ks,Be,ry,lu,ay,oy,Op;class Fp{constructor(t,e=0,s=0,i=!0){g(this,Be);g(this,hd);g(this,cd);g(this,dd);g(this,mr,[]);g(this,Ks,[]);const r=vn.slice(),a=10**-4;for(const{x:A,y:v,width:w,height:S}of t){const E=Math.floor((A-e)/a)*a,x=Math.ceil((A+w+e)/a)*a,_=Math.floor((v-e)/a)*a,C=Math.ceil((v+S+e)/a)*a,T=[E,_,C,!0],M=[x,_,C,!1];n(this,mr).push(T,M),D.rectBoundingBox(E,_,x,C,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,h=r[0]-s,c=r[1]-s;let u=i?-1/0:1/0,p=1/0;const m=n(this,mr).at(i?-1:-2),y=[m[0],m[2]];for(const A of n(this,mr)){const[v,w,S,E]=A;!E&&i?w<p?(p=w,u=v):w===p&&(u=Math.max(u,v)):E&&!i&&(w<p?(p=w,u=v):w===p&&(u=Math.min(u,v))),A[0]=(v-h)/o,A[1]=(w-c)/l,A[2]=(S-c)/l}f(this,hd,new Float32Array([h,c,o,l])),f(this,cd,[u,p]),f(this,dd,y)}getOutlines(){n(this,mr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,mr))e[3]?(t.push(...b(this,Be,Op).call(this,e)),b(this,Be,ay).call(this,e)):(b(this,Be,oy).call(this,e),t.push(...b(this,Be,Op).call(this,e)));return b(this,Be,ry).call(this,t)}}hd=new WeakMap,cd=new WeakMap,dd=new WeakMap,mr=new WeakMap,Ks=new WeakMap,Be=new WeakSet,ry=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,u]=a;s.delete(a);let p=o,m=l;for(r=[o,h],i.push(r);;){let y;if(s.has(c))y=c;else if(s.has(u))y=u;else break;s.delete(y),[o,l,h,c,u]=y,p!==o&&(r.push(p,m,o,m===l?l:h),p=o),m=m===l?h:l}r.push(p,m)}return new Rw(i,n(this,hd),n(this,cd),n(this,dd))},lu=function(t){const e=n(this,Ks);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},ay=function([,t,e]){const s=b(this,Be,lu).call(this,t);n(this,Ks).splice(s,0,[t,e])},oy=function([,t,e]){const s=b(this,Be,lu).call(this,t);for(let i=s;i<n(this,Ks).length;i++){const[r,a]=n(this,Ks)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ks).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,Ks)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ks).splice(i,1);return}}},Op=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Be,lu).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,Ks)[o];for(let c=0,u=r.length;c<u;c++){const[,p,m]=r[c];if(!(h<=p||m<=l)){if(p>=l){if(m>h)r[c][1]=h;else{if(u===1)return[];r.splice(c,1),c--,u--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var ud,Il;class Rw extends O{constructor(e,s,i,r){super();g(this,ud);g(this,Il);f(this,Il,e),f(this,ud,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const e=[];for(const s of n(this,Il)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,h=r-s;for(const c of n(this,Il)){const u=new Array(c.length);for(let p=0;p<c.length;p+=2)u[p]=e+c[p]*l,u[p+1]=r-c[p+1]*h;o.push(u)}return o}get box(){return n(this,ud)}get classNamesForOutlining(){return["highlightOutline"]}}ud=new WeakMap,Il=new WeakMap;class Np extends Cu{newFreeDrawOutline(t,e,s,i,r,a){return new Fw(t,e,s,i,r,a)}}class Fw extends iy{newOutliner(t,e,s,i,r,a=0){return new Np(t,e,s,i,r,a)}}var Ll,fd,pn,za,pd,Ve,gd,md,Va,cs,ds,ue,Rl,Fl,xe,Ol,Ls,bd,Y,Bp,hu,ly,hy,cy,Hp,Ir,Fs,bo,dy,cu,du,uy,fy,py,gy,my;const it=class it extends At{constructor(e){super({...e,name:"highlightEditor"});g(this,Y);g(this,Ll,null);g(this,fd,0);g(this,pn);g(this,za,null);g(this,pd,null);g(this,Ve,null);g(this,gd,null);g(this,md,0);g(this,Va,null);g(this,cs,null);g(this,ds,null);g(this,ue,!1);g(this,Rl,null);g(this,Fl,null);g(this,xe,null);g(this,Ol,"");g(this,Ls);g(this,bd,"");this.color=e.color||it._defaultColor,f(this,Ls,e.thickness||it._defaultThickness),this.opacity=e.opacity||it._defaultOpacity,f(this,pn,e.boxes||null),f(this,bd,e.methodOfCreation||""),f(this,Ol,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(f(this,ue,!0),b(this,Y,hu).call(this,e),b(this,Y,Ir).call(this)):n(this,pn)&&(f(this,Ll,e.anchorNode),f(this,fd,e.anchorOffset),f(this,gd,e.focusNode),f(this,md,e.focusOffset),b(this,Y,Bp).call(this),b(this,Y,Ir).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=it.prototype;return j(this,"_keyboardManager",new Td([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,ue)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,Ls),methodOfCreation:n(this,bd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;At.initialize(e,s),it._defaultColor||(it._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case V.HIGHLIGHT_COLOR:it._defaultColor=s;break;case V.HIGHLIGHT_THICKNESS:it._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,Fl)}get commentButtonPosition(){return n(this,Rl)}updateParams(e,s){switch(e){case V.HIGHLIGHT_COLOR:b(this,Y,ly).call(this,s);break;case V.HIGHLIGHT_THICKNESS:b(this,Y,hy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[V.HIGHLIGHT_COLOR,it._defaultColor],[V.HIGHLIGHT_THICKNESS,it._defaultThickness]]}get propertiesToUpdate(){return[[V.HIGHLIGHT_COLOR,this.color||it._defaultColor],[V.HIGHLIGHT_THICKNESS,n(this,Ls)||it._defaultThickness],[V.HIGHLIGHT_FREE,n(this,ue)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ds),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,pd))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",f(this,pd,new Bh({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(b(this,Y,du).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,Y,du).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,Y,Hp).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,Y,Ir).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,Y,Hp).call(this):e&&(b(this,Y,Ir).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,ue)?(e=(e-this.rotation+360)%360,i=b(r=it,Fs,bo).call(r,n(this,cs).box,e)):i=b(a=it,Fs,bo).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,ds),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,xe),{bbox:b(o=it,Fs,bo).call(o,n(this,Ve).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,Ol)&&(e.setAttribute("aria-label",n(this,Ol)),e.setAttribute("role","mark")),n(this,ue)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,Y,dy).bind(this),{signal:this._uiManager._signal});const s=f(this,Va,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,za),this.setDims(),Em(this,n(this,Va),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,Y,cu).call(this,!0);break;case 1:case 3:b(this,Y,cu).call(this,!1);break}}select(){var e;super.select(),n(this,xe)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,xe)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{selected:!1}}),n(this,ue)||b(this,Y,cu).call(this,!1))}get _mustFixPosition(){return!n(this,ue)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,ds),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,xe),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:h,height:c}=i.getBoundingClientRect(),u=new AbortController,p=e.combinedSignal(u),m=y=>{u.abort(),b(this,Fs,gy).call(this,e,y)};window.addEventListener("blur",m,{signal:p}),window.addEventListener("pointerup",m,{signal:p}),window.addEventListener("pointerdown",Tt,{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",As,{signal:p}),i.addEventListener("pointermove",b(this,Fs,py).bind(this,e),{signal:p}),this._freeHighlight=new Np({x:r,y:a},[o,l,h,c],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,i){var v,w,S,E;let r=null;if(e instanceof zb){const{data:{quadPoints:x,rect:_,rotation:C,id:T,color:M,opacity:k,popupRef:L,richText:I,contentsObj:X,creationDate:Q,modificationDate:q},parent:{page:{pageNumber:Z}}}=e;r=e={annotationType:$.HIGHLIGHT,color:Array.from(M),opacity:k,quadPoints:x,boxes:null,pageIndex:Z-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:L,richText:I,comment:(X==null?void 0:X.str)||null,creationDate:Q,modificationDate:q}}else if(e instanceof fg){const{data:{inkLists:x,rect:_,rotation:C,id:T,color:M,borderStyle:{rawWidth:k},popupRef:L,richText:I,contentsObj:X,creationDate:Q,modificationDate:q},parent:{page:{pageNumber:Z}}}=e;r=e={annotationType:$.HIGHLIGHT,color:Array.from(M),thickness:k,inkLists:x,boxes:null,pageIndex:Z-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:L,richText:I,comment:(X==null?void 0:X.str)||null,creationDate:Q,modificationDate:q}}const{color:a,quadPoints:o,inkLists:l,outlines:h,opacity:c}=e,u=await super.deserialize(e,s,i);u.color=D.makeHexColor(...a),u.opacity=c||1,l&&f(u,Ls,e.thickness),u._initialData=r,e.comment&&u.setCommentData(e);const[p,m]=u.pageDimensions,[y,A]=u.pageTranslation;if(o){const x=f(u,pn,[]);for(let _=0;_<o.length;_+=8)x.push({x:(o[_]-y)/p,y:1-(o[_+1]-A)/m,width:(o[_+2]-o[_])/p,height:(o[_+1]-o[_+5])/m});b(v=u,Y,Bp).call(v),b(w=u,Y,Ir).call(w),u.rotate(u.rotation)}else if(l||h){f(u,ue,!0);const x=(l||h.points)[0],_={x:x[0]-y,y:m-(x[1]-A)},C=new Np(_,[0,0,p,m],1,n(u,Ls)/2,!0,.001);for(let k=0,L=x.length;k<L;k+=2)_.x=x[k]-y,_.y=m-(x[k+1]-A),C.add(_);const{id:T,clipPathId:M}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);b(S=u,Y,hu).call(S,{highlightOutlines:C.getOutlines(),highlightId:T,clipPathId:M}),b(E=u,Y,Ir).call(E),u.rotate(u.parentRotation)}return u}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=At._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(e);return Object.assign(i,{color:s,opacity:this.opacity,thickness:n(this,Ls),quadPoints:b(this,Y,uy).call(this),outlines:b(this,Y,fy).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!b(this,Y,my).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};Ll=new WeakMap,fd=new WeakMap,pn=new WeakMap,za=new WeakMap,pd=new WeakMap,Ve=new WeakMap,gd=new WeakMap,md=new WeakMap,Va=new WeakMap,cs=new WeakMap,ds=new WeakMap,ue=new WeakMap,Rl=new WeakMap,Fl=new WeakMap,xe=new WeakMap,Ol=new WeakMap,Ls=new WeakMap,bd=new WeakMap,Y=new WeakSet,Bp=function(){const e=new Fp(n(this,pn),.001);f(this,cs,e.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,cs).box;const s=new Fp(n(this,pn),.0025,.001,this._uiManager.direction==="ltr");f(this,Ve,s.getOutlines());const{firstPoint:i}=n(this,cs);f(this,Rl,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:r}=n(this,Ve);f(this,Fl,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},hu=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var p,m;if(f(this,cs,e),f(this,Ve,e.getNewOutline(n(this,Ls)/2+1.5,.0025)),s>=0)f(this,ds,s),f(this,za,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),f(this,xe,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,Ve).box,path:{d:n(this,Ve).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,ds),{bbox:b(p=it,Fs,bo).call(p,n(this,cs).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,xe),{bbox:b(m=it,Fs,bo).call(m,n(this,Ve).box,y),path:{d:n(this,Ve).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[y,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/y,this.height=h*y/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[y,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/y,this.height=h*y/A;break}}const{firstPoint:c}=e;f(this,Rl,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:u}=n(this,Ve);f(this,Fl,[(u[0]-a)/l,(u[1]-o)/h])},ly=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,it._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},hy=function(e){const s=n(this,Ls),i=r=>{f(this,Ls,r),b(this,Y,cy).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},cy=function(e){n(this,ue)&&(b(this,Y,hu).call(this,{highlightOutlines:n(this,cs).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},Hp=function(){n(this,ds)===null||!this.parent||(this.parent.drawLayer.remove(n(this,ds)),f(this,ds,null),this.parent.drawLayer.remove(n(this,xe)),f(this,xe,null))},Ir=function(e=this.parent){n(this,ds)===null&&({id:Vt(this,ds)._,clipPathId:Vt(this,za)._}=e.drawLayer.draw({bbox:n(this,cs).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,ue)},path:{d:n(this,cs).toSVGPath()}},!1,!0),f(this,xe,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,ue)},bbox:n(this,Ve).box,path:{d:n(this,Ve).toSVGPath()}},n(this,ue))),n(this,Va)&&(n(this,Va).style.clipPath=n(this,za)))},Fs=new WeakSet,bo=function([e,s,i,r],a){switch(a){case 90:return[1-s-r,e,r,i];case 180:return[1-e-i,1-s-r,i,r];case 270:return[s,1-e-i,r,i]}return[e,s,i,r]},dy=function(e){it._keyboardManager.exec(this,e)},cu=function(e){if(!n(this,Ll))return;const s=window.getSelection();e?s.setPosition(n(this,Ll),n(this,fd)):s.setPosition(n(this,gd),n(this,md))},du=function(){return n(this,ue)?this.rotation:0},uy=function(){if(n(this,ue))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,pn),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:u,height:p}of a){const m=h*e+i,y=(1-c)*s+r;o[l]=o[l+4]=m,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=m+u*e,o[l+5]=o[l+7]=y-p*s,l+=8}return o},fy=function(e){return n(this,cs).serialize(e,b(this,Y,du).call(this))},py=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},gy=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},my=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},g(it,Fs),P(it,"_defaultColor",null),P(it,"_defaultOpacity",1),P(it,"_defaultThickness",12),P(it,"_type","highlight"),P(it,"_editorType",$.HIGHLIGHT),P(it,"_freeHighlightId",-1),P(it,"_freeHighlight",null),P(it,"_freeHighlightClipId","");let Tu=it;var Wa;class by{constructor(){g(this,Wa,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,Wa)[t]=e}toSVGProperties(){const t=n(this,Wa);return f(this,Wa,Object.create(null)),{root:t}}reset(){f(this,Wa,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){rt("Not implemented")}}Wa=new WeakMap;var Ie,Nl,se,Xa,Ya,et,Up,Gp,$p,Sh,yy,uu,Eh,yo;const tt=class tt extends At{constructor(e){super(e);g(this,et);g(this,Ie,null);g(this,Nl);P(this,"_colorPicker",null);P(this,"_drawId",null);f(this,Nl,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(b(this,et,Up).call(this,e),b(this,et,Sh).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){rt("Not implemented")}static get typesMap(){rt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(tt,se).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=n(this,Ie).updateProperty(s,l);h&&b(this,et,Eh).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s){const i=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[i],l=a[r],h=(c,u)=>{var p;a.updateProperty(i,c),a.updateProperty(r,u),n(this,Ie).updateProperty(i,c),n(this,Ie).updateProperty(r,u),(p=this.parent)==null||p.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,e,s),undo:h.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(n(this,Ie).getPathResizingSVGProperties(b(this,et,uu).call(this)),{bbox:b(this,et,yo).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(n(this,Ie).getPathResizedSVGProperties(b(this,et,uu).call(this)),{bbox:b(this,et,yo).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,et,yo).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(n(this,Ie).getPathTranslatedSVGProperties(b(this,et,uu).call(this),this.parentDimensions),{bbox:b(this,et,yo).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,Nl)&&(f(this,Nl,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,et,$p).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,et,Sh).call(this),b(this,et,Eh).call(this,n(this,Ie).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,et,$p).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,et,Sh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties({bbox:b(this,et,yo).call(this)},n(this,Ie).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,et,Eh).call(this,n(this,Ie).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,r,a){rt("Not implemented")}static startDrawing(e,s,i,r){var v;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(we.isInitializedAndDifferentPointerType(c))return;const{viewport:{rotation:u}}=e,{width:p,height:m}=a.getBoundingClientRect(),y=f(tt,Xa,new AbortController),A=e.combinedSignal(y);if(we.setPointer(c,h),window.addEventListener("pointerup",w=>{we.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:A}),window.addEventListener("pointercancel",w=>{we.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:A}),window.addEventListener("pointerdown",w=>{we.isSamePointerType(w.pointerType)&&(we.initializeAndAddPointerId(w.pointerId),n(tt,se).isCancellable()&&(n(tt,se).removeLastElement(),n(tt,se).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",As,{signal:A}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),a.addEventListener("touchmove",w=>{we.isSameTimeStamp(w.timeStamp)&&Tt(w)},{signal:A}),e.toggleDrawing(),(v=s._editorUndoBar)==null||v.hide(),n(tt,se)){e.drawLayer.updateProperties(this._currentDrawId,n(tt,se).startNew(o,l,p,m,u));return}s.updateUIForDefaultProperties(this),f(tt,se,this.createDrawerInstance(o,l,p,m,u)),f(tt,Ya,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(tt,Ya).toSVGProperties(),n(tt,se).defaultSVGProperties),!0,!1)}static _drawMove(e){if(we.isSameTimeStamp(e.timeStamp),!n(tt,se))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(we.isSamePointerId(r)){if(we.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(tt,se).add(s,i)),we.setTimeStamp(e.timeStamp),Tt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,f(tt,se,null),f(tt,Ya,null),we.clearTimeStamp()),n(tt,Xa)&&(n(tt,Xa).abort(),f(tt,Xa,null),we.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(tt,se).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(tt,se),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:V.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(V.DRAW_STEP),!n(tt,se).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(tt,se).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(tt,Ya),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){rt("Not implemented")}static async deserialize(e,s,i){var u,p;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),b(u=c,et,Up).call(u,{drawOutlines:h}),b(p=c,et,Sh).call(p),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,Ie).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Ie=new WeakMap,Nl=new WeakMap,se=new WeakMap,Xa=new WeakMap,Ya=new WeakMap,et=new WeakSet,Up=function({drawOutlines:e,drawId:s,drawingOptions:i}){f(this,Ie,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=b(this,et,Gp).call(this,e,this.parent),b(this,et,Eh).call(this,e.box)},Gp=function(e,s){const{id:i}=s.drawLayer.draw(tt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},$p=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Sh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,et,Gp).call(this,n(this,Ie),e)}},yy=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},uu=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},Eh=function(e){[this.x,this.y,this.width,this.height]=b(this,et,yy).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},yo=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/h),r*(h/l),i*(l/h)];case 5:return[1-s,e,i*(l/h),r*(h/l)];case 6:return[1-e-r*(h/l),1-s,r*(h/l),i*(l/h)];case 7:return[s-i*(l/h),1-e-r*(h/l),i*(l/h),r*(h/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(h/l),s,r*(h/l),i*(l/h)];case 13:return[1-s-i*(l/h),e-r*(h/l),i*(l/h),r*(h/l)];case 14:return[1-e,1-s-i*(l/h),r*(h/l),i*(l/h)];case 15:return[s,1-e,i*(l/h),r*(h/l)];default:return[e,s,i,r]}},P(tt,"_currentDrawId",-1),P(tt,"_currentParent",null),g(tt,se,null),g(tt,Xa,null),g(tt,Ya,null),P(tt,"_INNER_MARGIN",3);let Pu=tt;var Si,ie,ne,Ka,Bl,Le,fe,Rs,qa,Qa,Ja,Hl,fu;class Ow{constructor(t,e,s,i,r,a){g(this,Hl);g(this,Si,new Float64Array(6));g(this,ie);g(this,ne);g(this,Ka);g(this,Bl);g(this,Le);g(this,fe,"");g(this,Rs,0);g(this,qa,new Pd);g(this,Qa);g(this,Ja);f(this,Qa,s),f(this,Ja,i),f(this,Ka,r),f(this,Bl,a),[t,e]=b(this,Hl,fu).call(this,t,e);const o=f(this,ie,[NaN,NaN,NaN,NaN,t,e]);f(this,Le,[t,e]),f(this,ne,[{line:o,points:n(this,Le)}]),n(this,Si).set(o,0)}updateProperty(t,e){t==="stroke-width"&&f(this,Bl,e)}isEmpty(){return!n(this,ne)||n(this,ne).length===0}isCancellable(){return n(this,Le).length<=10}add(t,e){[t,e]=b(this,Hl,fu).call(this,t,e);const[s,i,r,a]=n(this,Si).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,Qa)*o,n(this,Ja)*l)<=2?null:(n(this,Le).push(t,e),isNaN(s)?(n(this,Si).set([r,a,t,e],2),n(this,ie).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,Si)[0])&&n(this,ie).splice(6,6),n(this,Si).set([s,i,r,a,t,e],0),n(this,ie).push(...O.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,Le).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){f(this,Qa,s),f(this,Ja,i),f(this,Ka,r),[t,e]=b(this,Hl,fu).call(this,t,e);const a=f(this,ie,[NaN,NaN,NaN,NaN,t,e]);f(this,Le,[t,e]);const o=n(this,ne).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,ne).push({line:a,points:n(this,Le)}),n(this,Si).set(a,0),f(this,Rs,0),this.toSVGPath(),null}getLastElement(){return n(this,ne).at(-1)}setLastElement(t){return n(this,ne)?(n(this,ne).push(t),f(this,ie,t.line),f(this,Le,t.points),f(this,Rs,0),{path:{d:this.toSVGPath()}}):n(this,qa).setLastElement(t)}removeLastElement(){if(!n(this,ne))return n(this,qa).removeLastElement();n(this,ne).pop(),f(this,fe,"");for(let t=0,e=n(this,ne).length;t<e;t++){const{line:s,points:i}=n(this,ne)[t];f(this,ie,s),f(this,Le,i),f(this,Rs,0),this.toSVGPath()}return{path:{d:n(this,fe)}}}toSVGPath(){const t=O.svgRound(n(this,ie)[4]),e=O.svgRound(n(this,ie)[5]);if(n(this,Le).length===2)return f(this,fe,`${n(this,fe)} M ${t} ${e} Z`),n(this,fe);if(n(this,Le).length<=6){const i=n(this,fe).lastIndexOf("M");f(this,fe,`${n(this,fe).slice(0,i)} M ${t} ${e}`),f(this,Rs,6)}if(n(this,Le).length===4){const i=O.svgRound(n(this,ie)[10]),r=O.svgRound(n(this,ie)[11]);return f(this,fe,`${n(this,fe)} L ${i} ${r}`),f(this,Rs,12),n(this,fe)}const s=[];n(this,Rs)===0&&(s.push(`M ${t} ${e}`),f(this,Rs,6));for(let i=n(this,Rs),r=n(this,ie).length;i<r;i+=6){const[a,o,l,h,c,u]=n(this,ie).slice(i,i+6).map(O.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}return f(this,fe,n(this,fe)+s.join(" ")),f(this,Rs,n(this,ie).length),n(this,fe)}getOutlines(t,e,s,i){const r=n(this,ne).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,qa).build(n(this,ne),t,e,s,n(this,Ka),n(this,Bl),i),f(this,Si,null),f(this,ie,null),f(this,ne,null),f(this,fe,null),n(this,qa)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Si=new WeakMap,ie=new WeakMap,ne=new WeakMap,Ka=new WeakMap,Bl=new WeakMap,Le=new WeakMap,fe=new WeakMap,Rs=new WeakMap,qa=new WeakMap,Qa=new WeakMap,Ja=new WeakMap,Hl=new WeakSet,fu=function(t,e){return O._normalizePoint(t,e,n(this,Qa),n(this,Ja),n(this,Ka))};var Re,yd,Ad,us,Ei,xi,Ul,Gl,Za,ge,Fi,Ay,wy,vy;class Pd extends O{constructor(){super(...arguments);g(this,ge);g(this,Re);g(this,yd,0);g(this,Ad);g(this,us);g(this,Ei);g(this,xi);g(this,Ul);g(this,Gl);g(this,Za)}build(e,s,i,r,a,o,l){f(this,Ei,s),f(this,xi,i),f(this,Ul,r),f(this,Gl,a),f(this,Za,o),f(this,Ad,l??0),f(this,us,e),b(this,ge,wy).call(this)}get thickness(){return n(this,Za)}setLastElement(e){return n(this,us).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,us).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,us)){if(e.push(`M${O.svgRound(s[4])} ${O.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${O.svgRound(s[10])} ${O.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,u]=s.subarray(i,i+6).map(O.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,u,p]=b(this,ge,Ay).call(this);let m,y,A,v,w,S,E,x,_;switch(n(this,Gl)){case 0:_=O._rescale,m=e,y=s+r,A=i,v=-r,w=e+h*i,S=s+(1-c-p)*r,E=e+(h+u)*i,x=s+(1-c)*r;break;case 90:_=O._rescaleAndSwap,m=e,y=s,A=i,v=r,w=e+c*i,S=s+h*r,E=e+(c+p)*i,x=s+(h+u)*r;break;case 180:_=O._rescale,m=e+i,y=s,A=-i,v=r,w=e+(1-h-u)*i,S=s+c*r,E=e+(1-h)*i,x=s+(c+p)*r;break;case 270:_=O._rescaleAndSwap,m=e+i,y=s+r,A=-i,v=-r,w=e+(1-c-p)*i,S=s+(1-h-u)*r,E=e+(1-c)*i,x=s+(1-h)*r;break}for(const{line:C,points:T}of n(this,us))o.push(_(C,m,y,A,v,a?new Array(C.length):null)),l.push(_(T,m,y,A,v,a?new Array(T.length):null));return{lines:o,points:l,rect:[w,S,E,x]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const u=[];let p,m,y,A,v;switch(h){case 0:v=O._rescale,p=-e/i,m=s/r+1,y=1/i,A=-1/r;break;case 90:v=O._rescaleAndSwap,p=-s/r,m=-e/i,y=1/r,A=1/i;break;case 180:v=O._rescale,p=e/i+1,m=-s/r,y=-1/i,A=1/r;break;case 270:v=O._rescaleAndSwap,p=s/r+1,m=e/i+1,y=-1/r,A=-1/i;break}if(!o){o=[];for(const S of l){const E=S.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const x=new Float32Array(3*(E-2));o.push(x);let[_,C,T,M]=S.subarray(0,4);x.set([NaN,NaN,NaN,NaN,_,C],0);for(let k=4;k<E;k+=2){const L=S[k],I=S[k+1];x.set(O.createBezierPoints(_,C,T,M,L,I),(k-2)*3),[_,C,T,M]=[T,M,L,I]}}}for(let S=0,E=o.length;S<E;S++)u.push({line:v(o[S].map(x=>x??NaN),p,m,y,A),points:v(l[S].map(x=>x??NaN),p,m,y,A)});const w=new this.prototype.constructor;return w.build(u,i,r,1,h,c,a),w}get box(){return n(this,Re)}updateProperty(e,s){return e==="stroke-width"?b(this,ge,vy).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,ge,Fi).call(this);f(this,Ei,e),f(this,xi,s),f(this,Ul,i);const[o,l]=b(this,ge,Fi).call(this),h=o-r,c=l-a,u=n(this,Re);return u[0]-=h,u[1]-=c,u[2]+=2*h,u[3]+=2*c,u}updateRotation(e){return f(this,yd,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,Re).map(O.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,Re);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,Re);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,yd)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${O.svgRound(l)} ${O.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,ge,Fi).call(this),[l,h,c,u]=n(this,Re);if(Math.abs(c-a)<=O.PRECISION||Math.abs(u-o)<=O.PRECISION){const v=e+i/2-(l+c/2),w=s+r/2-(h+u/2);return{path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const p=(i-2*a)/(c-2*a),m=(r-2*o)/(u-2*o),y=c/i,A=u/r;return{path:{"transform-origin":`${O.svgRound(l)} ${O.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${O.svgRound(a)} ${O.svgRound(o)}) scale(${p} ${m}) translate(${O.svgRound(-a)} ${O.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,ge,Fi).call(this),l=n(this,Re),[h,c,u,p]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(u-a)<=O.PRECISION||Math.abs(p-o)<=O.PRECISION){const w=e+i/2-(h+u/2),S=s+r/2-(c+p/2);for(const{line:E,points:x}of n(this,us))O._translate(E,w,S,E),O._translate(x,w,S,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(i-2*a)/(u-2*a),y=(r-2*o)/(p-2*o),A=-m*(h+a)+e+a,v=-y*(c+o)+s+o;if(m!==1||y!==1||A!==0||v!==0)for(const{line:w,points:S}of n(this,us))O._rescale(w,A,v,m,y,w),O._rescale(S,A,v,m,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,Re),l=e-o[0],h=s-o[1];if(n(this,Ei)===r&&n(this,xi)===a)for(const{line:c,points:u}of n(this,us))O._translate(c,l,h,c),O._translate(u,l,h,u);else{const c=n(this,Ei)/r,u=n(this,xi)/a;f(this,Ei,r),f(this,xi,a);for(const{line:p,points:m}of n(this,us))O._rescale(p,l,h,c,u,p),O._rescale(m,l,h,c,u,m);o[2]*=c,o[3]*=u}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,Re);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e[0])} ${O.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Re=new WeakMap,yd=new WeakMap,Ad=new WeakMap,us=new WeakMap,Ei=new WeakMap,xi=new WeakMap,Ul=new WeakMap,Gl=new WeakMap,Za=new WeakMap,ge=new WeakSet,Fi=function(e=n(this,Za)){const s=n(this,Ad)+e/2*n(this,Ul);return n(this,Gl)%180===0?[s/n(this,Ei),s/n(this,xi)]:[s/n(this,xi),s/n(this,Ei)]},Ay=function(){const[e,s,i,r]=n(this,Re),[a,o]=b(this,ge,Fi).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},wy=function(){const e=f(this,Re,Or.slice());for(const{line:r}of n(this,us)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)D.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;l+=6){const[c,u,p,m,y,A]=r.subarray(l,l+6);D.bezierBoundingBox(a,o,c,u,p,m,y,A,e),a=y,o=A}}const[s,i]=b(this,ge,Fi).call(this);e[0]=Et(e[0]-s,0,1),e[1]=Et(e[1]-i,0,1),e[2]=Et(e[2]+s,0,1),e[3]=Et(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},vy=function(e){const[s,i]=b(this,ge,Fi).call(this);f(this,Za,e);const[r,a]=b(this,ge,Fi).call(this),[o,l]=[r-s,a-i],h=n(this,Re);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class Sf extends by{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:At._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Sf(this._viewParameters);return t.updateAll(this),t}}var ef,Sy;const So=class So extends Pu{constructor(e){super({...e,name:"inkEditor"});g(this,ef);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){At.initialize(e,s),this._defaultDrawingOptions=new Sf(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,"typesMap",new Map([[V.INK_THICKNESS,"stroke-width"],[V.INK_COLOR,"stroke"],[V.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,r,a){return new Ow(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return Pd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof fg){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:u,opacity:p,borderStyle:{rawWidth:m},popupRef:y,richText:A,contentsObj:v,creationDate:w,modificationDate:S},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:$.INK,color:Array.from(u),thickness:m,opacity:p,paths:{points:o},boxes:null,pageIndex:E-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:y,richText:A,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:S}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new xu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return V.INK_COLOR}get colorAndOpacityType(){return V.INK_COLOR_AND_OPACITY}get opacityType(){return V.INK_OPACITY}updateParams(e,s){if(e===V.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===V.INK_COLOR_AND_OPACITY){super.updateDefaultParams(V.INK_COLOR,s.color),super.updateDefaultParams(V.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=So.getDefaultDrawingOptions({stroke:D.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:At._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!b(this,ef,Sy).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};ef=new WeakSet,Sy=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},P(So,"_type","ink"),P(So,"_editorType",$.INK),P(So,"_defaultDrawingOptions",null);let jp=So;class zp extends Pd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Fd=8,ih=3;var to,at,Vp,qs,Ey,xy,Wp,pu,_y,Cy,Ty,Xp,Yp,Py;class Mi{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const u=200,p=c.font=`${s} ${i} ${u}px ${e}`,{actualBoundingBoxLeft:m,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:S,width:E}=c.measureText(t),x=1.5,_=Math.ceil(Math.max(Math.abs(m)+Math.abs(y)||0,E)*x),C=Math.ceil(Math.max(Math.abs(A)+Math.abs(v)||u,Math.abs(w)+Math.abs(S)||u)*x);h=new OffscreenCanvas(_,C),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=p,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,_,C),c.fillStyle="black",c.fillText(t,_*(x-1)/2,C*(3-x)/2);const T=b(this,at,Xp).call(this,c.getImageData(0,0,_,C).data),M=b(this,at,Ty).call(this,T),k=b(this,at,Yp).call(this,M),L=b(this,at,Wp).call(this,T,_,C,k);return this.processDrawnLines({lines:{curves:L,width:_,height:C},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=b(this,at,Py).call(this,t),[h,c]=b(this,at,Cy).call(this,a,o,l,Math.hypot(o,l)*n(this,to).sigmaSFactor,n(this,to).sigmaR,n(this,to).kernelSize),u=b(this,at,Yp).call(this,c),p=b(this,at,Wp).call(this,h,o,l,u);return this.processDrawnLines({lines:{curves:p,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:h,height:c}=t,u=t.thickness??0,p=[],m=Math.min(e/h,s/c),y=m/e,A=m/s,v=[];for(const{points:S}of l){const E=a?b(this,at,_y).call(this,S):S;if(!E)continue;v.push(E);const x=E.length,_=new Float32Array(x),C=new Float32Array(3*(x===2?2:x-2));if(p.push({line:C,points:_}),x===2){_[0]=E[0]*y,_[1]=E[1]*A,C.set([NaN,NaN,NaN,NaN,_[0],_[1]],0);continue}let[T,M,k,L]=E;T*=y,M*=A,k*=y,L*=A,_.set([T,M,k,L],0),C.set([NaN,NaN,NaN,NaN,T,M],0);for(let I=4;I<x;I+=2){const X=_[I]=E[I]*y,Q=_[I+1]=E[I+1]*A;C.set(O.createBezierPoints(T,M,k,L,X,Q),(I-2)*3),[T,M,k,L]=[k,L,X,Q]}}if(p.length===0)return null;const w=o?new zp:new Pd;return w.build(p,e,s,1,i,o?0:u,r),{outline:w,newCurves:v,areContours:o,thickness:u,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const S of t){l+=S.length;for(let E=2,x=S.length;E<x;E++){const _=S[E]-S[E-2];a=Math.min(a,_),o=Math.max(o,_)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,u=Fd+ih*c,p=new Uint32Array(u);let m=0;p[m++]=u*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,p[m++]=0,p[m++]=i,p[m++]=r,p[m++]=e?0:1,p[m++]=Math.max(0,Math.floor(s??0)),p[m++]=c,p[m++]=h.BYTES_PER_ELEMENT;for(const S of t)p[m++]=S.length-2,p[m++]=S[0],p[m++]=S[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(p);const v=h.prototype.constructor;for(const S of t){const E=new v(S.length-2);for(let x=2,_=S.length;x<_;x++)E[x-2]=S[x]-S[x-2];A.write(E)}return A.close(),(await new Response(y.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const E of s)a||(a=new Uint8Array(new Uint32Array(E.buffer,0,4)[0])),a.set(E,o),o+=E.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],u=l[3],p=l[4]===0,m=l[5],y=l[6],A=l[7],v=[],w=(Fd+ih*y)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,w);break}o=0;for(let E=0;E<y;E++){const x=l[ih*E+Fd],_=new Float32Array(x+2);v.push(_);for(let C=0;C<ih-1;C++)_[C]=l[ih*E+Fd+C+1];for(let C=0;C<x;C++)_[C+2]=_[C]+S[o++]}return{areContours:p,thickness:m,outlines:v,width:c,height:u}}catch(e){return W(`decompressSignature: ${e}`),null}}}to=new WeakMap,at=new WeakSet,Vp=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},qs=new WeakMap,Ey=function(t,e,s,i,r,a,o){const l=b(this,at,Vp).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,u=n(this,qs)[2*c],p=n(this,qs)[2*c+1];if(t[(s+u)*e+(i+p)]!==0)return c}return-1},xy=function(t,e,s,i,r,a,o){const l=b(this,at,Vp).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,u=n(this,qs)[2*c],p=n(this,qs)[2*c+1];if(t[(s+u)*e+(i+p)]!==0)return c}return-1},Wp=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)a[c*e]=a[c*e+e-1]=0;for(let c=0;c<e;c++)a[c]=a[e*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let u=1;u<e-1;u++){const p=c*e+u,m=a[p];if(m===0)continue;let y=c,A=u;if(m===1&&a[p-1]===0)o+=1,A-=1;else if(m>=1&&a[p+1]===0)o+=1,A+=1,m>1&&(l=m);else{m!==1&&(l=Math.abs(m));continue}const v=[u,c],w=A===u+1,S={isHole:w,points:v,id:o,parent:0};h.push(S);let E;for(const I of h)if(I.id===l){E=I;break}E?E.isHole?S.parent=w?E.parent:l:S.parent=w?l:E.parent:S.parent=w?l:0;const x=b(this,at,Ey).call(this,a,e,c,u,y,A,0);if(x===-1){a[p]=-o,a[p]!==1&&(l=Math.abs(a[p]));continue}let _=n(this,qs)[2*x],C=n(this,qs)[2*x+1];const T=c+_,M=u+C;y=T,A=M;let k=c,L=u;for(;;){const I=b(this,at,xy).call(this,a,e,k,L,y,A,1);_=n(this,qs)[2*I],C=n(this,qs)[2*I+1];const X=k+_,Q=L+C;v.push(Q,X);const q=k*e+L;if(a[q+1]===0?a[q]=-o:a[q]===1&&(a[q]=o),X===c&&Q===u&&k===T&&L===M){a[p]!==1&&(l=Math.abs(a[p]));break}else y=k,A=L,k=X,L=Q}}}return h},pu=function(t,e,s,i){if(s-e<=4){for(let T=e;T<s-2;T+=2)i.push(t[T],t[T+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,h=Math.hypot(o,l),c=o/h,u=l/h,p=c*a-u*r,m=l/o,y=1/h,A=Math.atan(m),v=Math.cos(A),w=Math.sin(A),S=y*(Math.abs(v)+Math.abs(w)),E=y*(1-S+S**2),x=Math.max(Math.atan(Math.abs(w+v)*E),Math.atan(Math.abs(w-v)*E));let _=0,C=e;for(let T=e+2;T<s-2;T+=2){const M=Math.abs(p-c*t[T+1]+u*t[T]);M>_&&(C=T,_=M)}_>(h*x)**2?(b(this,at,pu).call(this,t,e,C+2,i),b(this,at,pu).call(this,t,C,s,i)):i.push(r,a)},_y=function(t){const e=[],s=t.length;return b(this,at,pu).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},Cy=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,h=a>>1;for(let A=0;A<a;A++){const v=(A-h)**2;for(let w=0;w<a;w++)o[A*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),u=-2*r**2;for(let A=0;A<256;A++)c[A]=Math.exp(A**2/u);const p=t.length,m=new Uint8Array(p),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let v=0;v<e;v++){const w=A*e+v,S=t[w];let E=0,x=0;for(let C=0;C<a;C++){const T=A+C-h;if(!(T<0||T>=s))for(let M=0;M<a;M++){const k=v+M-h;if(k<0||k>=e)continue;const L=t[T*e+k],I=o[C*a+M]*c[Math.abs(L-S)];E+=L*I,x+=I}}const _=m[w]=Math.round(E/x);y[_]++}return[m,y]},Ty=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Xp=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=t[o<<2];i=Math.max(i,h),r=Math.min(r,h)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},Yp=function(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},Py=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,to);let a=s,o=i;if(s>r||i>r){let p=s,m=i,y=Math.log2(Math.max(s,i)/r);const A=Math.floor(y);y=y===A?A-1:A;for(let w=0;w<y;w++){a=Math.ceil(p/2),o=Math.ceil(m/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,p,m,0,0,a,o),p=a,m=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const v=Math.min(r/a,r/o);a=Math.round(a*v),o=Math.round(o*v)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[b(this,at,Xp).call(this,c),a,o]},g(Mi,at),g(Mi,to,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(Mi,qs,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class pg extends by{constructor(){super(),super.updateProperties({fill:At._defaultLineColor,"stroke-width":0})}clone(){const t=new pg;return t.updateAll(this),t}}class gg extends Sf{constructor(t){super(t),super.updateProperties({stroke:At._defaultLineColor,"stroke-width":1})}clone(){const t=new gg(this._viewParameters);return t.updateAll(this),t}}var br,_i,yr,eo;const qe=class qe extends Pu{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,br,!1);g(this,_i,null);g(this,yr,null);g(this,eo,null);this._willKeepAspectRatio=!0,f(this,yr,e.signatureData||null),f(this,_i,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){At.initialize(e,s),this._defaultDrawingOptions=new pg,this._defaultDrawnSignatureOptions=new gg(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,_i)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,yr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,yr),{rawDims:{pageWidth:u,pageHeight:p},rotation:m}=this.parent.viewport,y=Mi.processDrawnLines({lines:r,pageWidth:u,pageHeight:p,rotation:m,innerMargin:qe._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,c,l,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:n(this,_i)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){f(this,eo,e),this.addEditToolbar()}getUuid(){return n(this,eo)}get description(){return n(this,_i)}set description(e){f(this,_i,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,yr),o=Math.max(r,a),l=Mi.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,r){const{x:a,y:o}=this,{outline:l}=f(this,yr,e);f(this,br,l instanceof zp),this.description=i;let h;n(this,br)?h=qe.getDefaultDrawingOptions():(h=qe._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let u=s/c;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Mi.process(e,s,i,r,qe._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return Mi.extractContoursFromText(e,s,i,r,a,qe._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Mi.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:qe._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=qe.getDefaultDrawingOptions():(this._drawingOptions=qe._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:n(this,br),color:[0,0,0],thickness:n(this,br)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,eo),a.isCopy=!0):a.lines=s,n(this,_i)&&(a.accessibilityData={type:"Figure",alt:n(this,_i)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?zp.deserialize(e,s,i,r,a,o):Pd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return f(r,br,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",f(r,eo,e.uuid),r}};br=new WeakMap,_i=new WeakMap,yr=new WeakMap,eo=new WeakMap,P(qe,"_type","signature"),P(qe,"_editorType",$.SIGNATURE),P(qe,"_defaultDrawingOptions",null);let Kp=qe;var Ct,re,Ar,gn,wr,$l,mn,so,Ci,fs,jl,st,xh,_h,gu,mu,bu,Qp,yu,ky;class qp extends At{constructor(e){super({...e,name:"stampEditor"});g(this,st);g(this,Ct,null);g(this,re,null);g(this,Ar,null);g(this,gn,null);g(this,wr,null);g(this,$l,"");g(this,mn,null);g(this,so,!1);g(this,Ci,null);g(this,fs,!1);g(this,jl,!1);f(this,gn,e.bitmapUrl),f(this,wr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){At.initialize(e,s)}static isHandlingMimeForPasting(e){return Su.includes(e)}static paste(e,s){s.pasteEditor({mode:$.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;n(this,re)&&(f(this,Ct,null),this._uiManager.imageManager.deleteId(n(this,re)),(e=n(this,mn))==null||e.remove(),f(this,mn,null),n(this,Ci)&&(clearTimeout(n(this,Ci)),f(this,Ci,null))),super.remove()}rebuild(){if(!this.parent){n(this,re)&&b(this,st,gu).call(this);return}super.rebuild(),this.div!==null&&(n(this,re)&&n(this,mn)===null&&b(this,st,gu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,Ar)||n(this,Ct)||n(this,gn)||n(this,wr)||n(this,re)||n(this,so))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,so)||(n(this,Ct)?b(this,st,mu).call(this):b(this,st,gu).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(f(this,re,i),r&&f(this,Ct,r),f(this,so,!1),b(this,st,mu).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Ci)!==null&&clearTimeout(n(this,Ci)),f(this,Ci,setTimeout(()=>{f(this,Ci,null),b(this,st,Qp).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,Ct),o=new si;let l=n(this,Ct),h=r,c=a,u=null;if(s){if(r>s||a>s){const T=Math.min(s/r,s/a);h=Math.floor(r*T),c=Math.floor(a*T)}u=document.createElement("canvas");const m=u.width=Math.ceil(h*o.sx),y=u.height=Math.ceil(c*o.sy);n(this,fs)||(l=b(this,st,bu).call(this,m,y));const A=u.getContext("2d");A.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":sA.isDarkMode&&(v="#8f8f9d",w="#42414d");const S=15,E=S*o.sx,x=S*o.sy,_=new OffscreenCanvas(E*2,x*2),C=_.getContext("2d");C.fillStyle=v,C.fillRect(0,0,E*2,x*2),C.fillStyle=w,C.fillRect(0,0,E,x),C.fillRect(E,x,E,x),A.fillStyle=A.createPattern(_,"repeat"),A.fillRect(0,0,m,y),A.drawImage(l,0,0,l.width,l.height,0,0,m,y)}let p=null;if(i){let m,y;if(o.symmetric&&l.width<e&&l.height<e)m=l.width,y=l.height;else if(l=n(this,Ct),r>e||a>e){const w=Math.min(e/r,e/a);m=Math.floor(r*w),y=Math.floor(a*w),n(this,fs)||(l=b(this,st,bu).call(this,m,y))}const v=new OffscreenCanvas(m,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,m,y),p={width:m,height:y,data:v.getImageData(0,0,m,y).data}}return{canvas:u,width:h,height:c,imageData:p}}static async deserialize(e,s,i){var v;let r=null,a=!1;if(e instanceof Vb){const{data:{rect:w,rotation:S,id:E,structParent:x,popupRef:_,richText:C,contentsObj:T,creationDate:M,modificationDate:k},container:L,parent:{page:{pageNumber:I}},canvas:X}=e;let Q,q;X?(delete e.canvas,{id:Q,bitmap:q}=i.imageManager.getFromCanvas(L.id,X),X.remove()):(a=!0,e._hasNoCanvas=!0);const Z=((v=await s._structTree.getAriaAttributes(`${wo}${E}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:$.STAMP,bitmapId:Q,bitmap:q,pageIndex:I-1,rect:w.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:Z},isSvg:!1,structParent:x,popupRef:_,richText:C,comment:(T==null?void 0:T.str)||null,creationDate:M,modificationDate:k}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:u,isSvg:p,accessibilityData:m}=e;a?(i.addMissingCanvas(e.id,o),f(o,so,!0)):u&&i.imageManager.isValidId(u)?(f(o,re,u),h&&f(o,Ct,h)):f(o,gn,c),f(o,fs,p);const[y,A]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/A,m&&(o.altTextData=m),o._initialData=r,e.comment&&o.setCommentData(e),f(o,jl,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:n(this,re),isSvg:n(this,fs)});if(this.addComment(i),e)return i.bitmapUrl=b(this,st,yu).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,st,ky).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,fs)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,re)))s.stamps.set(n(this,re),{area:o,serialized:i}),i.bitmap=b(this,st,yu).call(this,!1);else if(n(this,fs)){const l=s.stamps.get(n(this,re));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,st,yu).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Ct=new WeakMap,re=new WeakMap,Ar=new WeakMap,gn=new WeakMap,wr=new WeakMap,$l=new WeakMap,mn=new WeakMap,so=new WeakMap,Ci=new WeakMap,fs=new WeakMap,jl=new WeakMap,st=new WeakSet,xh=function(e,s=!1){if(!e){this.remove();return}f(this,Ct,e.bitmap),s||(f(this,re,e.id),f(this,fs,e.isSvg)),e.file&&f(this,$l,e.file.name),b(this,st,mu).call(this)},_h=function(){if(f(this,Ar,null),this._uiManager.enableWaiting(!1),!!n(this,mn)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Ct)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Ct)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},gu=function(){if(n(this,re)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,re)).then(i=>b(this,st,xh).call(this,i,!0)).finally(()=>b(this,st,_h).call(this));return}if(n(this,gn)){const i=n(this,gn);f(this,gn,null),this._uiManager.enableWaiting(!0),f(this,Ar,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,st,xh).call(this,r)).finally(()=>b(this,st,_h).call(this)));return}if(n(this,wr)){const i=n(this,wr);f(this,wr,null),this._uiManager.enableWaiting(!0),f(this,Ar,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,st,xh).call(this,r)).finally(()=>b(this,st,_h).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Su.join(",");const s=this._uiManager._signal;f(this,Ar,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,st,xh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,st,_h).call(this))),e.click()},mu=function(){var h;const{div:e}=this;let{width:s,height:i}=n(this,Ct);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const c=Math.min(o*r/s,o*a/i);s*=c,i*=c}this._uiManager.enableWaiting(!1);const l=f(this,mn,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/a,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,st,Qp).call(this),n(this,jl)||(this.parent.addUndoableEditor(this),f(this,jl,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,$l)&&this.div.setAttribute("aria-description",n(this,$l)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},bu=function(e,s){const{width:i,height:r}=n(this,Ct);let a=i,o=r,l=n(this,Ct);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=u.transferToImageBitmap()}return l},Qp=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new si,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,mn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,fs)?n(this,Ct):b(this,st,bu).call(this,o,l),u=h.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(c,0,0,c.width,c.height,0,0,o,l)},yu=function(e){if(e){if(n(this,fs)){const r=this._uiManager.imageManager.getSvgUrl(n(this,re));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,Ct),s.getContext("2d").drawImage(n(this,Ct),0,0),s.toDataURL()}if(n(this,fs)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Cn.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Cn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,Ct),0,0,n(this,Ct).width,n(this,Ct).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,Ct))},ky=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},P(qp,"_type","stamp"),P(qp,"_editorType",$.STAMP);var io,zl,vr,Sr,bn,We,Er,Vl,Wl,Qs,yn,ae,An,xr,Xl,N,_r,bt,Jp,My,ai,Zp,tg,Au;const Bs=class Bs{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,bt);g(this,io);g(this,zl,!1);g(this,vr,null);g(this,Sr,null);g(this,bn,null);g(this,We,new Map);g(this,Er,!1);g(this,Vl,!1);g(this,Wl,!1);g(this,Qs,null);g(this,yn,null);g(this,ae,null);g(this,An,null);g(this,xr,null);g(this,Xl,-1);g(this,N);const u=[...n(Bs,_r).values()];if(!Bs._initialized){Bs._initialized=!0;for(const p of u)p.initialize(c,t)}t.registerEditorTypes(u),f(this,N,t),this.pageIndex=e,this.div=s,f(this,io,r),f(this,vr,a),this.viewport=h,f(this,ae,l),this.drawLayer=o,this._structTree=i,n(this,N).addLayer(this)}get isEmpty(){return n(this,We).size===0}get isInvisible(){return this.isEmpty&&n(this,N).getMode()===$.NONE}updateToolbar(t){n(this,N).updateToolbar(t)}updateMode(t=n(this,N).getMode()){switch(b(this,bt,Au).call(this),t){case $.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case $.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case $.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===$.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Bs,_r).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,ae))==null?void 0:e.div)}setEditingState(t){n(this,N).setEditingState(t)}addCommands(t){n(this,N).addCommands(t)}cleanUndoStack(t){n(this,N).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=n(this,vr))==null||e.togglePointerEvents(t)}async enable(){var s;f(this,Wl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,xr))==null||s.abort(),f(this,xr,null);const t=new Set;for(const i of n(this,bt,Jp))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,N).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,vr);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,N).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}f(this,Wl,!1),n(this,N)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(f(this,Vl,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,ae)&&!n(this,xr)){f(this,xr,new AbortController);const r=n(this,N).combinedSignal(n(this,xr));n(this,ae).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,u=n(this,Xl);if(c-u>500){f(this,Xl,c);return}f(this,Xl,-1);const{classList:p}=this.div;p.toggle("getElements",!0);const m=document.elementsFromPoint(l,h);if(p.toggle("getElements",!1),!this.div.contains(m[0]))return;let y;const A=new RegExp(`^${Dh}[0-9]+$`);for(const w of m)if(A.test(w.id)){y=w.id;break}if(!y)return;const v=n(this,We).get(y);(v==null?void 0:v.annotationElementId)===null&&(Tt(a),v.dblclick(a))},{signal:r,capture:!0})}const t=n(this,vr),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,bt,Jp)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(this,N).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=a.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=r.get(l),h&&(n(this,N).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,bt,Au).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Bs,_r).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),f(this,Vl,!1)}getEditableAnnotation(t){var e;return((e=n(this,vr))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,N).getActive()!==t&&n(this,N).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,ae))!=null&&t.div&&!n(this,An)){f(this,An,new AbortController);const e=n(this,N).combinedSignal(n(this,An));n(this,ae).div.addEventListener("pointerdown",b(this,bt,My).bind(this),{signal:e}),n(this,ae).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,ae))!=null&&t.div&&n(this,An)&&(n(this,An).abort(),f(this,An,null),n(this,ae).div.classList.remove("highlighting"))}enableClick(){if(n(this,Sr))return;f(this,Sr,new AbortController);const t=n(this,N).combinedSignal(n(this,Sr));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=n(this,Sr))==null||t.abort(),f(this,Sr,null)}attach(t){n(this,We).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,N).isDeletedAnnotationElement(e)&&n(this,N).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,We).delete(t.id),(e=n(this,io))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,Vl)&&t.annotationElementId&&n(this,N).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,N).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,N).addDeletedAnnotationElement(t),At.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),n(this,N).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,Wl)),n(this,N).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,bn)&&(t._focusEventsAllowed=!1,f(this,bn,setTimeout(()=>{f(this,bn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,N)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,io))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of n(this,We).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,N).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,bt,ai))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,N).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,bt,tg).call(this),r=n(this,N).getId(),a=b(this,bt,Zp).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,N),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Bs,_r).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,N)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,N).getId(),r=b(this,bt,Zp).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,N),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,bt,tg).call(this),!0,t)}setSelected(t){n(this,N).setSelected(t)}toggleSelected(t){n(this,N).toggleSelected(t)}unselect(t){n(this,N).unselect(t)}pointerup(t){var i;const{isMac:e}=zt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,Er)||(f(this,Er,!1),(i=n(this,bt,ai))!=null&&i.isDrawer&&n(this,bt,ai).supportMultipleDrawings))return;if(!n(this,zl)){f(this,zl,!0);return}const s=n(this,N).getMode();if(s===$.STAMP||s===$.POPUP||s===$.SIGNATURE){n(this,N).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,N).getMode()===$.HIGHLIGHT&&this.enableTextSelection(),n(this,Er)){f(this,Er,!1);return}const{isMac:e}=zt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(f(this,Er,!0),(i=n(this,bt,ai))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,N).getActive();f(this,zl,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,Qs)){n(this,bt,ai).startDrawing(this,n(this,N),!1,t);return}n(this,N).setCurrentDrawingSession(this),f(this,Qs,new AbortController);const e=n(this,N).combinedSignal(n(this,Qs));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(f(this,yn,null),this.commitOrRemove())},{signal:e}),n(this,bt,ai).startDrawing(this,n(this,N),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&f(this,yn,e);return}n(this,yn)&&setTimeout(()=>{var e;(e=n(this,yn))==null||e.focus(),f(this,yn,null)},0)}endDrawingSession(t=!1){return n(this,Qs)?(n(this,N).setCurrentDrawingSession(null),n(this,Qs).abort(),f(this,Qs,null),f(this,yn,null),n(this,bt,ai).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,N).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,Qs)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,Qs)&&n(this,bt,ai).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,N).getActive())==null?void 0:t.parent)===this&&(n(this,N).commitOrRemove(),n(this,N).setActiveEditor(null)),n(this,bn)&&(clearTimeout(n(this,bn)),f(this,bn,null));for(const s of n(this,We).values())(e=n(this,io))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,We).clear(),n(this,N).removeLayer(this)}async render({viewport:t}){this.viewport=t,Cr(this.div,t);for(const e of n(this,N).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,N).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,N).commitOrRemove(),b(this,bt,Au).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Cr(this.div,{rotation:s}),e!==s)for(const i of n(this,We).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,N).viewParameters.realScale}};io=new WeakMap,zl=new WeakMap,vr=new WeakMap,Sr=new WeakMap,bn=new WeakMap,We=new WeakMap,Er=new WeakMap,Vl=new WeakMap,Wl=new WeakMap,Qs=new WeakMap,yn=new WeakMap,ae=new WeakMap,An=new WeakMap,xr=new WeakMap,Xl=new WeakMap,N=new WeakMap,_r=new WeakMap,bt=new WeakSet,Jp=function(){return n(this,We).size!==0?n(this,We).values():n(this,N).getEditors(this.pageIndex)},My=function(t){n(this,N).unselectAll();const{target:e}=t;if(e===n(this,ae).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,ae).div.contains(e)){const{isMac:s}=zt.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,N).showAllEditors("highlight",!0,!0),n(this,ae).div.classList.add("free"),this.toggleDrawing(),Tu.startHighlighting(this,n(this,N).direction==="ltr",{target:n(this,ae).div,x:t.x,y:t.y}),n(this,ae).div.addEventListener("pointerup",()=>{n(this,ae).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,N)._signal}),t.preventDefault()}},ai=function(){return n(Bs,_r).get(n(this,N).getMode())},Zp=function(t){const e=n(this,bt,ai);return e?new e.prototype.constructor(t):null},tg=function(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),h=(r+o)/2-t,c=(a+l)/2-e,[u,p]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:u,offsetY:p}},Au=function(){for(const t of n(this,We).values())t.isEmpty()&&t.remove()},P(Bs,"_initialized",!1),g(Bs,_r,new Map([Lp,jp,qp,Tu,Kp].map(t=>[t._editorType,t])));let ku=Bs;var Js,Fe,no,wd,sf,Dy,Ii,eg,Iy,sg;const qt=class qt{constructor(){g(this,Ii);g(this,Js,null);g(this,Fe,new Map);g(this,no,new Map)}setParent(t){if(!n(this,Js)){f(this,Js,t);return}if(n(this,Js)!==t){if(n(this,Fe).size>0)for(const e of n(this,Fe).values())e.remove(),t.append(e);f(this,Js,t)}}static get _svgFactory(){return j(this,"_svgFactory",new Hh)}draw(t,e=!1,s=!1){const i=Vt(qt,wd)._++,r=b(this,Ii,eg).call(this),a=qt._svgFactory.createElement("defs");r.append(a);const o=qt._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,no).set(i,o);const h=s?b(this,Ii,Iy).call(this,a,l):null,c=qt._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Fe).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=Vt(qt,wd)._++,i=b(this,Ii,eg).call(this),r=qt._svgFactory.createElement("defs");i.append(r);const a=qt._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const u=qt._svgFactory.createElement("mask");r.append(u),l=`mask_${s}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const p=qt._svgFactory.createElement("rect");u.append(p),p.setAttribute("width","1"),p.setAttribute("height","1"),p.setAttribute("fill","white");const m=qt._svgFactory.createElement("use");u.append(m),m.setAttribute("href",`#${o}`),m.setAttribute("stroke","none"),m.setAttribute("fill","black"),m.setAttribute("fill-rule","nonzero"),m.classList.add("mask")}const h=qt._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,Fe).set(s,i),s}finalizeDraw(t,e){n(this,no).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,Fe).get(t):t;if(o){if(s&&b(this,Ii,sg).call(this,o,s),i&&b(l=qt,sf,Dy).call(l,o,i),r){const{classList:h}=o;for(const[c,u]of Object.entries(r))h.toggle(c,u)}if(a){const c=o.firstElementChild.firstElementChild;b(this,Ii,sg).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Fe).get(t);s&&(n(e,Js).append(s),n(this,Fe).delete(t),n(e,Fe).set(t,s))}remove(t){n(this,no).delete(t),n(this,Js)!==null&&(n(this,Fe).get(t).remove(),n(this,Fe).delete(t))}destroy(){f(this,Js,null);for(const t of n(this,Fe).values())t.remove();n(this,Fe).clear(),n(this,no).clear()}};Js=new WeakMap,Fe=new WeakMap,no=new WeakMap,wd=new WeakMap,sf=new WeakSet,Dy=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},Ii=new WeakSet,eg=function(){const t=qt._svgFactory.create(1,1,!0);return n(this,Js).append(t),t.setAttribute("aria-hidden",!0),t},Iy=function(t,e){const s=qt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=qt._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},sg=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},g(qt,sf),g(qt,wd,0);let Mu=qt;function Od(d){return`${(d*100).toFixed(2)}%`}var Yl,vd,Sd,Kl,Ti,Pi,Ed,nf,Ly;const Mh=class Mh{constructor(t,e,s,i){g(this,nf);g(this,Yl,[]);g(this,vd,new Map);g(this,Sd,null);g(this,Kl,0);g(this,Ti,0);g(this,Pi,0);f(this,Kl,t),f(this,Yl,e),f(this,Ti,s.rawDims.pageWidth),f(this,Pi,s.rawDims.pageHeight),f(this,Sd,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,Yl).length;e+=6){const s=b(this,nf,Ly).call(this,n(this,Yl).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var w;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,vd).get(s);if(!i)return;const r=(w=n(Mh,Ed))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),f(Mh,Ed,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=i,u=n(this,Sd).call(this),p=Math.ceil(o*u.width),m=Math.ceil(l*u.height),y=Math.floor((o+h/n(this,Ti))*u.width),A=Math.floor((l+c/n(this,Pi))*u.height);s.width=y-p,s.height=A-m;const v=s.getContext("2d");v.setTransform(...a),v.translate(-p,-m),v.drawImage(u,0,0)}),t}};Yl=new WeakMap,vd=new WeakMap,Sd=new WeakMap,Kl=new WeakMap,Ti=new WeakMap,Pi=new WeakMap,Ed=new WeakMap,nf=new WeakSet,Ly=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,Ti),(a-e)*n(this,Pi)),l=Math.hypot((s-t)*n(this,Ti),(i-e)*n(this,Pi));if(o<n(this,Kl)||l<n(this,Kl))return null;const h=[(r-t)*n(this,Ti)/o,(a-e)*n(this,Pi)/o,(s-t)*n(this,Ti)/l,(i-e)*n(this,Pi)/l,0,0],c=D.inverseTransform(h),u=document.createElement("canvas");return u.className="textLayerImagePlaceholder",u.width=0,u.height=0,Object.assign(u.style,{opacity:0,position:"absolute",left:Od(t),top:Od(e),width:Od(o/n(this,Ti)),height:Od(l/n(this,Pi)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),n(this,vd).set(u,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),u},g(Mh,Ed,null);let Du=Mh;globalThis._pdfjsTestingUtils={HighlightOutliner:Fp};globalThis.pdfjsLib={AbortException:_n,AnnotationEditorLayer:ku,AnnotationEditorParamsType:V,AnnotationEditorType:$,AnnotationEditorUIManager:Tr,AnnotationLayer:_u,AnnotationMode:wn,AnnotationType:Ht,applyOpacity:gm,build:Lb,ColorPicker:Bh,createValidAbsoluteUrl:ig,CSSConstants:pm,DOMSVGFactory:Hh,DrawLayer:Mu,FeatureTest:zt,fetchData:cf,findContrastColor:mm,getDocument:cg,getFilenameFromUrl:dm,getPdfFilenameFromUrl:um,getRGB:Zl,getRGBA:ff,getUuid:rg,getXfaPageViewport:fm,GlobalWorkerOptions:Zs,ImageKind:Ch,InvalidPDFException:wu,isDataScheme:Cd,isPdfFile:uf,isValidExplicitDest:tb,makeArr:lf,makeMap:hf,makeObj:vu,MathClamp:Et,noContextMenu:As,normalizeUnicode:cm,OPS:ki,OutputScale:si,PasswordResponses:hm,PDFDataRangeTransport:dg,PDFDateString:Rh,PDFWorker:Ql,PermissionFlag:lm,PixelsPerInch:Cn,RenderingCancelledException:df,renderRichText:og,ResponseException:Ih,setLayerDimensions:Cr,shadow:j,SignatureExtractor:Mi,stopEvent:Tt,SupportedImageMimeTypes:Su,TextLayer:ql,TextLayerImages:Du,TouchManager:Fh,updateUrlHash:ng,Util:D,VerbosityLevel:xd,version:Ib,XfaLayer:ag};const Nw=Object.freeze(Object.defineProperty({__proto__:null,AbortException:_n,AnnotationEditorLayer:ku,AnnotationEditorParamsType:V,AnnotationEditorType:$,AnnotationEditorUIManager:Tr,AnnotationLayer:_u,AnnotationMode:wn,AnnotationType:Ht,CSSConstants:pm,ColorPicker:Bh,DOMSVGFactory:Hh,DrawLayer:Mu,FeatureTest:zt,GlobalWorkerOptions:Zs,ImageKind:Ch,InvalidPDFException:wu,MathClamp:Et,OPS:ki,OutputScale:si,PDFDataRangeTransport:dg,PDFDateString:Rh,PDFWorker:Ql,PasswordResponses:hm,PermissionFlag:lm,PixelsPerInch:Cn,RenderingCancelledException:df,ResponseException:Ih,SignatureExtractor:Mi,SupportedImageMimeTypes:Su,TextLayer:ql,TextLayerImages:Du,TouchManager:Fh,Util:D,VerbosityLevel:xd,XfaLayer:ag,applyOpacity:gm,build:Lb,createValidAbsoluteUrl:ig,fetchData:cf,findContrastColor:mm,getDocument:cg,getFilenameFromUrl:dm,getPdfFilenameFromUrl:um,getRGB:Zl,getRGBA:ff,getUuid:rg,getXfaPageViewport:fm,isDataScheme:Cd,isPdfFile:uf,isValidExplicitDest:tb,makeArr:lf,makeMap:hf,makeObj:vu,noContextMenu:As,normalizeUnicode:cm,renderRichText:og,setLayerDimensions:Cr,shadow:j,stopEvent:Tt,updateUrlHash:ng,version:Ib},Symbol.toStringTag,{value:"Module"}));Zs.workerSrc="";const sm=25.4/72,Lf=8;class Ry{importFromFilePicker(t){const e=document.createElement("input");e.type="file",e.accept=".pdf",e.style.display="none",document.body.appendChild(e),e.addEventListener("change",async()=>{var r;const s=(r=e.files)==null?void 0:r[0];if(document.body.removeChild(e),!s)return;const i=await s.arrayBuffer();await this.convert(t,i)}),e.click()}async convert(t,e,s=1){try{const r=await(await cg({data:e}).promise).getPage(s),o=r.getViewport({scale:1}).height,l=await r.getOperatorList(),h=this.extractEntities(l,o);if(h.length===0){Mn.log.warn("[PdfImport] No vector paths found in PDF page.");return}const c=t.doc.database.tables.blockTable.modelSpace;for(const u of h)c.appendEntity(u);Mn.log.info(`[PdfImport] Imported ${h.length} entities from PDF.`)}catch(i){Mn.log.error("[PdfImport] Failed to import PDF:",i)}}extractEntities(t,e){const{OPS:s}=Nw,{fnArray:i,argsArray:r}=t,a=[];let o=[],l=[],h=0,c=0;const u=()=>{l.length>1&&o.push(l),l=[]},p=()=>{u();for(const A of o){const v=this.subpathToEntity(A);v&&a.push(v)}o=[]},m=(A,v)=>A*sm,y=(A,v)=>(e-v)*sm;for(let A=0;A<i.length;A++){const v=i[A],w=r[A];switch(v){case s.moveTo:{u(),h=w[0],c=w[1],l=[{x:m(h),y:y(h,c)}];break}case s.lineTo:{h=w[0],c=w[1],l.push({x:m(h),y:y(h,c)});break}case s.curveTo:{const[S,E,x,_,C,T]=w,M=Rf({x:h,y:c},{x:S,y:E},{x,y:_},{x:C,y:T},Lf);for(const k of M)l.push({x:m(k.x,k.y),y:y(k.x,k.y)});h=C,c=T;break}case s.curveTo2:{const[S,E,x,_]=w,C=Rf({x:h,y:c},{x:h,y:c},{x:S,y:E},{x,y:_},Lf);for(const T of C)l.push({x:m(T.x,T.y),y:y(T.x,T.y)});h=x,c=_;break}case s.curveTo3:{const[S,E,x,_]=w,C=Rf({x:h,y:c},{x:S,y:E},{x,y:_},{x,y:_},Lf);for(const T of C)l.push({x:m(T.x,T.y),y:y(T.x,T.y)});h=x,c=_;break}case s.closePath:{l.length>0&&o.length===0&&l.push({...l[0]}),u();break}case s.stroke:case s.fill:case s.eoFill:case s.fillStroke:case s.eoFillStroke:case s.endPath:{p();break}}}return p(),a}subpathToEntity(t){if(t.length<2)return null;if(t.length===2)return new Mn.AcDbLine(new Mn.AcGePoint3d(t[0].x,t[0].y,0),new Mn.AcGePoint3d(t[1].x,t[1].y,0));const e=new Mn.AcDbPolyline;for(let o=0;o<t.length;o++)e.addVertexAt(o,new Mn.AcGePoint2d(t[o].x,t[o].y));const s=t[0],i=t[t.length-1],r=s.x-i.x,a=s.y-i.y;return Math.sqrt(r*r+a*a)<1e-6&&(e.closed=!0),e}}function Rf(d,t,e,s,i){const r=[];for(let a=1;a<=i;a++){const o=a/i,l=1-o,h=l*l*l*d.x+3*l*l*o*t.x+3*l*o*o*e.x+o*o*o*s.x,c=l*l*l*d.y+3*l*l*o*t.y+3*l*o*o*e.y+o*o*o*s.y;r.push({x:h,y:c})}return r}class Fy extends G.AcEdCommand{async execute(t){new Ry().importFromFilePicker(t)}}const Bw="1.7.1",Hw={version:Bw};class Oy{constructor(t={}){this.name="PdfPlugin",this.version=Hw.version,this.description="PDF export (-cpdf / cpdf) and import (ipdf) commands",this.registeredCommands=[],this._disableExport=t.disableExport===!0}onLoad(t,e){const s=G.AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME;if(!this._disableExport){const i=new om;e.addCommand(s,"-cpdf","-cpdf",i),this.registeredCommands.push({group:s,name:"-cpdf"}),e.lookupGlobalCmd("cpdf")||(e.addCommand(s,"cpdf","cpdf",i),this.registeredCommands.push({group:s,name:"cpdf"}))}e.addCommand(s,"ipdf","ipdf",new Fy),this.registeredCommands.push({group:s,name:"ipdf"})}onUnload(t,e){for(const s of this.registeredCommands)e.removeCmd(s.group,s.name);this.registeredCommands=[]}}async function Uw(d={}){return new Oy(d)}exports.PDF_PLUGIN_NAME=nm.PDF_PLUGIN_NAME;exports.PDF_PLUGIN_TRIGGERS=nm.PDF_PLUGIN_TRIGGERS;exports.AcApConvertToPdfCmd=om;exports.AcApImportPdfCmd=Fy;exports.AcApPdfConvertor=am;exports.AcApPdfImportConvertor=Ry;exports.AcApPdfPlugin=Oy;exports.createPdfPlugin=Uw;exports.resolveAcApPdfExportOptions=Ao;exports.resolveViewerTextFont=rm;
55
+ `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Kb=function(){return n(this,as).replaceAll(" "," ")},Rp=function(e){return e.replaceAll(" "," ")},qb=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},g(wt,xn),P(wt,"_freeTextDefaultContent",""),P(wt,"_internalPadding",0),P(wt,"_defaultColor",null),P(wt,"_defaultFontSize",10),P(wt,"_type","freetext"),P(wt,"_editorType",$.FREETEXT);let Lp=wt;class O{toSVGPath(){rt("Abstract method `toSVGPath` must be implemented.")}get box(){rt("Abstract getter `box` must be implemented.")}serialize(t,e){rt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}P(O,"PRECISION",1e-4);var ls,Ys,Tl,Pl,vi,J,Ga,$a,nd,rd,kl,Ml,gr,ad,Ju,Zu,Jt,vh,Qb,Jb,Zb,ty,ey,sy;const Ni=class Ni{constructor({x:t,y:e},s,i,r,a,o=0){g(this,Jt);g(this,ls);g(this,Ys,[]);g(this,Tl);g(this,Pl);g(this,vi,[]);g(this,J,new Float32Array(18));g(this,Ga);g(this,$a);g(this,nd);g(this,rd);g(this,kl);g(this,Ml);g(this,gr,[]);f(this,ls,s),f(this,Ml,r*i),f(this,Pl,a),n(this,J).set([NaN,NaN,NaN,NaN,t,e],6),f(this,Tl,o),f(this,rd,n(Ni,ad)*i),f(this,nd,n(Ni,Zu)*i),f(this,kl,i),n(this,gr).push(t,e)}isEmpty(){return isNaN(n(this,J)[8])}add({x:t,y:e}){var k;f(this,Ga,t),f(this,$a,e);const[s,i,r,a]=n(this,ls);let[o,l,h,c]=n(this,J).subarray(8,12);const u=t-h,p=e-c,m=Math.hypot(u,p);if(m<n(this,nd))return!1;const y=m-n(this,rd),A=y/m,v=A*u,w=A*p;let S=o,E=l;o=h,l=c,h+=v,c+=w,(k=n(this,gr))==null||k.push(t,e);const x=-w/y,_=v/y,C=x*n(this,Ml),T=_*n(this,Ml);return n(this,J).set(n(this,J).subarray(2,8),0),n(this,J).set([h+C,c+T],4),n(this,J).set(n(this,J).subarray(14,18),12),n(this,J).set([h-C,c-T],16),isNaN(n(this,J)[6])?(n(this,vi).length===0&&(n(this,J).set([o+C,l+T],2),n(this,vi).push(NaN,NaN,NaN,NaN,(o+C-s)/r,(l+T-i)/a),n(this,J).set([o-C,l-T],14),n(this,Ys).push(NaN,NaN,NaN,NaN,(o-C-s)/r,(l-T-i)/a)),n(this,J).set([S,E,o,l,h,c],6),!this.isEmpty()):(n(this,J).set([S,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,S-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=n(this,J).subarray(2,6),n(this,vi).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,S,E]=n(this,J).subarray(14,18),n(this,Ys).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-i)/a),!0):([S,E,o,l,h,c]=n(this,J).subarray(0,6),n(this,vi).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),[h,c,o,l,S,E]=n(this,J).subarray(12,18),n(this,Ys).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,vi),e=n(this,Ys);if(isNaN(n(this,J)[6])&&!this.isEmpty())return b(this,Jt,Qb).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);b(this,Jt,Zb).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return b(this,Jt,Jb).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new iy(t,e,s,i,r,a)}getOutlines(){var u;const t=n(this,vi),e=n(this,Ys),s=n(this,J),[i,r,a,o]=n(this,ls),l=new Float32Array((((u=n(this,gr))==null?void 0:u.length)??0)+2);for(let p=0,m=l.length-2;p<m;p+=2)l[p]=(n(this,gr)[p]-i)/a,l[p+1]=(n(this,gr)[p+1]-r)/o;if(l[l.length-2]=(n(this,Ga)-i)/a,l[l.length-1]=(n(this,$a)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,Jt,ty).call(this,l);const h=new Float32Array(n(this,vi).length+24+n(this,Ys).length);let c=t.length;for(let p=0;p<c;p+=2){if(isNaN(t[p])){h[p]=h[p+1]=NaN;continue}h[p]=t[p],h[p+1]=t[p+1]}c=b(this,Jt,sy).call(this,h,c);for(let p=e.length-6;p>=6;p-=6)for(let m=0;m<6;m+=2){if(isNaN(e[p+m])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[p+m],h[c+1]=e[p+m+1],c+=2}return b(this,Jt,ey).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,ls),n(this,kl),n(this,Tl),n(this,Pl))}};ls=new WeakMap,Ys=new WeakMap,Tl=new WeakMap,Pl=new WeakMap,vi=new WeakMap,J=new WeakMap,Ga=new WeakMap,$a=new WeakMap,nd=new WeakMap,rd=new WeakMap,kl=new WeakMap,Ml=new WeakMap,gr=new WeakMap,ad=new WeakMap,Ju=new WeakMap,Zu=new WeakMap,Jt=new WeakSet,vh=function(){const t=n(this,J).subarray(4,6),e=n(this,J).subarray(16,18),[s,i,r,a]=n(this,ls);return[(n(this,Ga)+(t[0]-e[0])/2-s)/r,(n(this,$a)+(t[1]-e[1])/2-i)/a,(n(this,Ga)+(e[0]-t[0])/2-s)/r,(n(this,$a)+(e[1]-t[1])/2-i)/a]},Qb=function(){const[t,e,s,i]=n(this,ls),[r,a,o,l]=b(this,Jt,vh).call(this);return`M${(n(this,J)[2]-t)/s} ${(n(this,J)[3]-e)/i} L${(n(this,J)[4]-t)/s} ${(n(this,J)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,J)[16]-t)/s} ${(n(this,J)[17]-e)/i} L${(n(this,J)[14]-t)/s} ${(n(this,J)[15]-e)/i} Z`},Jb=function(t){const e=n(this,Ys);t.push(`L${e[4]} ${e[5]} Z`)},Zb=function(t){const[e,s,i,r]=n(this,ls),a=n(this,J).subarray(4,6),o=n(this,J).subarray(16,18),[l,h,c,u]=b(this,Jt,vh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${u} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},ty=function(t){const e=n(this,J),[s,i,r,a]=n(this,ls),[o,l,h,c]=b(this,Jt,vh).call(this),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(u,t,n(this,ls),n(this,kl),n(this,Tl),n(this,Pl))},ey=function(t,e){const s=n(this,Ys);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},sy=function(t,e){const s=n(this,J).subarray(4,6),i=n(this,J).subarray(16,18),[r,a,o,l]=n(this,ls),[h,c,u,p]=b(this,Jt,vh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,u,p,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},g(Ni,ad,8),g(Ni,Ju,2),g(Ni,Zu,n(Ni,ad)+n(Ni,Ju));let Cu=Ni;var Dl,ja,fn,od,hs,ld,jt,tf,ny;class iy extends O{constructor(e,s,i,r,a,o){super();g(this,tf);g(this,Dl);g(this,ja,new Float32Array(4));g(this,fn);g(this,od);g(this,hs);g(this,ld);g(this,jt);f(this,jt,e),f(this,hs,s),f(this,Dl,i),f(this,ld,r),f(this,fn,a),f(this,od,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,tf,ny).call(this,o);const[l,h,c,u]=n(this,ja);for(let p=0,m=e.length;p<m;p+=2)e[p]=(e[p]-l)/c,e[p+1]=(e[p+1]-h)/u;for(let p=0,m=s.length;p<m;p+=2)s[p]=(s[p]-l)/c,s[p+1]=(s[p+1]-h)/u}toSVGPath(){const e=[`M${n(this,jt)[4]} ${n(this,jt)[5]}`];for(let s=6,i=n(this,jt).length;s<i;s+=6){if(isNaN(n(this,jt)[s])){e.push(`L${n(this,jt)[s+4]} ${n(this,jt)[s+5]}`);continue}e.push(`C${n(this,jt)[s]} ${n(this,jt)[s+1]} ${n(this,jt)[s+2]} ${n(this,jt)[s+3]} ${n(this,jt)[s+4]} ${n(this,jt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let h,c;switch(a){case 0:h=O._rescale(n(this,jt),e,r,o,-l),c=O._rescale(n(this,hs),e,r,o,-l);break;case 90:h=O._rescaleAndSwap(n(this,jt),e,s,o,l),c=O._rescaleAndSwap(n(this,hs),e,s,o,l);break;case 180:h=O._rescale(n(this,jt),i,s,-o,l),c=O._rescale(n(this,hs),i,s,-o,l);break;case 270:h=O._rescaleAndSwap(n(this,jt),i,r,-o,-l),c=O._rescaleAndSwap(n(this,hs),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,ja)}newOutliner(e,s,i,r,a,o=0){return new Cu(e,s,i,r,a,o)}getNewOutline(e,s){const[i,r,a,o]=n(this,ja),[l,h,c,u]=n(this,Dl),p=a*c,m=o*u,y=i*c+l,A=r*u+h,v=this.newOutliner({x:n(this,hs)[0]*p+y,y:n(this,hs)[1]*m+A},n(this,Dl),n(this,ld),e,n(this,od),s??n(this,fn));for(let w=2;w<n(this,hs).length;w+=2)v.add({x:n(this,hs)[w]*p+y,y:n(this,hs)[w+1]*m+A});return v.getOutlines()}}Dl=new WeakMap,ja=new WeakMap,fn=new WeakMap,od=new WeakMap,hs=new WeakMap,ld=new WeakMap,jt=new WeakMap,tf=new WeakSet,ny=function(e){const s=n(this,jt);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,h=i,c=r;const u=e?Math.max:Math.min,p=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const v=s[y+4],w=s[y+5];isNaN(s[y])?(D.pointBoundingBox(v,w,a),l>w?(o=v,l=w):l===w&&(o=u(o,v)),c<w?(h=v,c=w):c===w&&(h=u(h,v))):(p.set(vn,0),D.bezierBoundingBox(i,r,...s.slice(y,y+6),p),D.rectBoundingBox(...p,a),l>p[1]?(o=p[0],l=p[1]):l===p[1]&&(o=u(o,p[0])),c<p[3]?(h=p[2],c=p[3]):c===p[3]&&(h=u(h,p[2]))),i=v,r=w}const m=n(this,ja);m[0]=a[0]-n(this,fn),m[1]=a[1]-n(this,fn),m[2]=a[2]-a[0]+2*n(this,fn),m[3]=a[3]-a[1]+2*n(this,fn),this.firstPoint=[o,l],this.lastPoint=[h,c]};var hd,cd,dd,mr,Ks,Be,ry,lu,ay,oy,Op;class Fp{constructor(t,e=0,s=0,i=!0){g(this,Be);g(this,hd);g(this,cd);g(this,dd);g(this,mr,[]);g(this,Ks,[]);const r=vn.slice(),a=10**-4;for(const{x:A,y:v,width:w,height:S}of t){const E=Math.floor((A-e)/a)*a,x=Math.ceil((A+w+e)/a)*a,_=Math.floor((v-e)/a)*a,C=Math.ceil((v+S+e)/a)*a,T=[E,_,C,!0],M=[x,_,C,!1];n(this,mr).push(T,M),D.rectBoundingBox(E,_,x,C,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,h=r[0]-s,c=r[1]-s;let u=i?-1/0:1/0,p=1/0;const m=n(this,mr).at(i?-1:-2),y=[m[0],m[2]];for(const A of n(this,mr)){const[v,w,S,E]=A;!E&&i?w<p?(p=w,u=v):w===p&&(u=Math.max(u,v)):E&&!i&&(w<p?(p=w,u=v):w===p&&(u=Math.min(u,v))),A[0]=(v-h)/o,A[1]=(w-c)/l,A[2]=(S-c)/l}f(this,hd,new Float32Array([h,c,o,l])),f(this,cd,[u,p]),f(this,dd,y)}getOutlines(){n(this,mr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,mr))e[3]?(t.push(...b(this,Be,Op).call(this,e)),b(this,Be,ay).call(this,e)):(b(this,Be,oy).call(this,e),t.push(...b(this,Be,Op).call(this,e)));return b(this,Be,ry).call(this,t)}}hd=new WeakMap,cd=new WeakMap,dd=new WeakMap,mr=new WeakMap,Ks=new WeakMap,Be=new WeakSet,ry=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,u]=a;s.delete(a);let p=o,m=l;for(r=[o,h],i.push(r);;){let y;if(s.has(c))y=c;else if(s.has(u))y=u;else break;s.delete(y),[o,l,h,c,u]=y,p!==o&&(r.push(p,m,o,m===l?l:h),p=o),m=m===l?h:l}r.push(p,m)}return new Rw(i,n(this,hd),n(this,cd),n(this,dd))},lu=function(t){const e=n(this,Ks);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},ay=function([,t,e]){const s=b(this,Be,lu).call(this,t);n(this,Ks).splice(s,0,[t,e])},oy=function([,t,e]){const s=b(this,Be,lu).call(this,t);for(let i=s;i<n(this,Ks).length;i++){const[r,a]=n(this,Ks)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ks).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,Ks)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ks).splice(i,1);return}}},Op=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Be,lu).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,Ks)[o];for(let c=0,u=r.length;c<u;c++){const[,p,m]=r[c];if(!(h<=p||m<=l)){if(p>=l){if(m>h)r[c][1]=h;else{if(u===1)return[];r.splice(c,1),c--,u--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var ud,Il;class Rw extends O{constructor(e,s,i,r){super();g(this,ud);g(this,Il);f(this,Il,e),f(this,ud,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const e=[];for(const s of n(this,Il)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,h=r-s;for(const c of n(this,Il)){const u=new Array(c.length);for(let p=0;p<c.length;p+=2)u[p]=e+c[p]*l,u[p+1]=r-c[p+1]*h;o.push(u)}return o}get box(){return n(this,ud)}get classNamesForOutlining(){return["highlightOutline"]}}ud=new WeakMap,Il=new WeakMap;class Np extends Cu{newFreeDrawOutline(t,e,s,i,r,a){return new Fw(t,e,s,i,r,a)}}class Fw extends iy{newOutliner(t,e,s,i,r,a=0){return new Np(t,e,s,i,r,a)}}var Ll,fd,pn,za,pd,Ve,gd,md,Va,cs,ds,ue,Rl,Fl,xe,Ol,Ls,bd,Y,Bp,hu,ly,hy,cy,Hp,Ir,Fs,bo,dy,cu,du,uy,fy,py,gy,my;const it=class it extends At{constructor(e){super({...e,name:"highlightEditor"});g(this,Y);g(this,Ll,null);g(this,fd,0);g(this,pn);g(this,za,null);g(this,pd,null);g(this,Ve,null);g(this,gd,null);g(this,md,0);g(this,Va,null);g(this,cs,null);g(this,ds,null);g(this,ue,!1);g(this,Rl,null);g(this,Fl,null);g(this,xe,null);g(this,Ol,"");g(this,Ls);g(this,bd,"");this.color=e.color||it._defaultColor,f(this,Ls,e.thickness||it._defaultThickness),this.opacity=e.opacity||it._defaultOpacity,f(this,pn,e.boxes||null),f(this,bd,e.methodOfCreation||""),f(this,Ol,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(f(this,ue,!0),b(this,Y,hu).call(this,e),b(this,Y,Ir).call(this)):n(this,pn)&&(f(this,Ll,e.anchorNode),f(this,fd,e.anchorOffset),f(this,gd,e.focusNode),f(this,md,e.focusOffset),b(this,Y,Bp).call(this),b(this,Y,Ir).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=it.prototype;return j(this,"_keyboardManager",new Td([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,ue)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,Ls),methodOfCreation:n(this,bd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;At.initialize(e,s),it._defaultColor||(it._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case V.HIGHLIGHT_COLOR:it._defaultColor=s;break;case V.HIGHLIGHT_THICKNESS:it._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,Fl)}get commentButtonPosition(){return n(this,Rl)}updateParams(e,s){switch(e){case V.HIGHLIGHT_COLOR:b(this,Y,ly).call(this,s);break;case V.HIGHLIGHT_THICKNESS:b(this,Y,hy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[V.HIGHLIGHT_COLOR,it._defaultColor],[V.HIGHLIGHT_THICKNESS,it._defaultThickness]]}get propertiesToUpdate(){return[[V.HIGHLIGHT_COLOR,this.color||it._defaultColor],[V.HIGHLIGHT_THICKNESS,n(this,Ls)||it._defaultThickness],[V.HIGHLIGHT_FREE,n(this,ue)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ds),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,pd))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",f(this,pd,new Bh({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(b(this,Y,du).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,Y,du).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,Y,Hp).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,Y,Ir).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,Y,Hp).call(this):e&&(b(this,Y,Ir).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,ue)?(e=(e-this.rotation+360)%360,i=b(r=it,Fs,bo).call(r,n(this,cs).box,e)):i=b(a=it,Fs,bo).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,ds),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,xe),{bbox:b(o=it,Fs,bo).call(o,n(this,Ve).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,Ol)&&(e.setAttribute("aria-label",n(this,Ol)),e.setAttribute("role","mark")),n(this,ue)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,Y,dy).bind(this),{signal:this._uiManager._signal});const s=f(this,Va,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,za),this.setDims(),Em(this,n(this,Va),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,Y,cu).call(this,!0);break;case 1:case 3:b(this,Y,cu).call(this,!1);break}}select(){var e;super.select(),n(this,xe)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,xe)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,xe),{rootClass:{selected:!1}}),n(this,ue)||b(this,Y,cu).call(this,!1))}get _mustFixPosition(){return!n(this,ue)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,ds),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,xe),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:h,height:c}=i.getBoundingClientRect(),u=new AbortController,p=e.combinedSignal(u),m=y=>{u.abort(),b(this,Fs,gy).call(this,e,y)};window.addEventListener("blur",m,{signal:p}),window.addEventListener("pointerup",m,{signal:p}),window.addEventListener("pointerdown",Tt,{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",As,{signal:p}),i.addEventListener("pointermove",b(this,Fs,py).bind(this,e),{signal:p}),this._freeHighlight=new Np({x:r,y:a},[o,l,h,c],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,i){var v,w,S,E;let r=null;if(e instanceof zb){const{data:{quadPoints:x,rect:_,rotation:C,id:T,color:M,opacity:k,popupRef:L,richText:I,contentsObj:X,creationDate:Q,modificationDate:q},parent:{page:{pageNumber:Z}}}=e;r=e={annotationType:$.HIGHLIGHT,color:Array.from(M),opacity:k,quadPoints:x,boxes:null,pageIndex:Z-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:L,richText:I,comment:(X==null?void 0:X.str)||null,creationDate:Q,modificationDate:q}}else if(e instanceof fg){const{data:{inkLists:x,rect:_,rotation:C,id:T,color:M,borderStyle:{rawWidth:k},popupRef:L,richText:I,contentsObj:X,creationDate:Q,modificationDate:q},parent:{page:{pageNumber:Z}}}=e;r=e={annotationType:$.HIGHLIGHT,color:Array.from(M),thickness:k,inkLists:x,boxes:null,pageIndex:Z-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:L,richText:I,comment:(X==null?void 0:X.str)||null,creationDate:Q,modificationDate:q}}const{color:a,quadPoints:o,inkLists:l,outlines:h,opacity:c}=e,u=await super.deserialize(e,s,i);u.color=D.makeHexColor(...a),u.opacity=c||1,l&&f(u,Ls,e.thickness),u._initialData=r,e.comment&&u.setCommentData(e);const[p,m]=u.pageDimensions,[y,A]=u.pageTranslation;if(o){const x=f(u,pn,[]);for(let _=0;_<o.length;_+=8)x.push({x:(o[_]-y)/p,y:1-(o[_+1]-A)/m,width:(o[_+2]-o[_])/p,height:(o[_+1]-o[_+5])/m});b(v=u,Y,Bp).call(v),b(w=u,Y,Ir).call(w),u.rotate(u.rotation)}else if(l||h){f(u,ue,!0);const x=(l||h.points)[0],_={x:x[0]-y,y:m-(x[1]-A)},C=new Np(_,[0,0,p,m],1,n(u,Ls)/2,!0,.001);for(let k=0,L=x.length;k<L;k+=2)_.x=x[k]-y,_.y=m-(x[k+1]-A),C.add(_);const{id:T,clipPathId:M}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);b(S=u,Y,hu).call(S,{highlightOutlines:C.getOutlines(),highlightId:T,clipPathId:M}),b(E=u,Y,Ir).call(E),u.rotate(u.parentRotation)}return u}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=At._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(e);return Object.assign(i,{color:s,opacity:this.opacity,thickness:n(this,Ls),quadPoints:b(this,Y,uy).call(this),outlines:b(this,Y,fy).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!b(this,Y,my).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};Ll=new WeakMap,fd=new WeakMap,pn=new WeakMap,za=new WeakMap,pd=new WeakMap,Ve=new WeakMap,gd=new WeakMap,md=new WeakMap,Va=new WeakMap,cs=new WeakMap,ds=new WeakMap,ue=new WeakMap,Rl=new WeakMap,Fl=new WeakMap,xe=new WeakMap,Ol=new WeakMap,Ls=new WeakMap,bd=new WeakMap,Y=new WeakSet,Bp=function(){const e=new Fp(n(this,pn),.001);f(this,cs,e.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,cs).box;const s=new Fp(n(this,pn),.0025,.001,this._uiManager.direction==="ltr");f(this,Ve,s.getOutlines());const{firstPoint:i}=n(this,cs);f(this,Rl,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:r}=n(this,Ve);f(this,Fl,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},hu=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var p,m;if(f(this,cs,e),f(this,Ve,e.getNewOutline(n(this,Ls)/2+1.5,.0025)),s>=0)f(this,ds,s),f(this,za,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),f(this,xe,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,Ve).box,path:{d:n(this,Ve).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,ds),{bbox:b(p=it,Fs,bo).call(p,n(this,cs).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,xe),{bbox:b(m=it,Fs,bo).call(m,n(this,Ve).box,y),path:{d:n(this,Ve).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[y,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/y,this.height=h*y/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[y,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/y,this.height=h*y/A;break}}const{firstPoint:c}=e;f(this,Rl,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:u}=n(this,Ve);f(this,Fl,[(u[0]-a)/l,(u[1]-o)/h])},ly=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,it._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},hy=function(e){const s=n(this,Ls),i=r=>{f(this,Ls,r),b(this,Y,cy).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},cy=function(e){n(this,ue)&&(b(this,Y,hu).call(this,{highlightOutlines:n(this,cs).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},Hp=function(){n(this,ds)===null||!this.parent||(this.parent.drawLayer.remove(n(this,ds)),f(this,ds,null),this.parent.drawLayer.remove(n(this,xe)),f(this,xe,null))},Ir=function(e=this.parent){n(this,ds)===null&&({id:Vt(this,ds)._,clipPathId:Vt(this,za)._}=e.drawLayer.draw({bbox:n(this,cs).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,ue)},path:{d:n(this,cs).toSVGPath()}},!1,!0),f(this,xe,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,ue)},bbox:n(this,Ve).box,path:{d:n(this,Ve).toSVGPath()}},n(this,ue))),n(this,Va)&&(n(this,Va).style.clipPath=n(this,za)))},Fs=new WeakSet,bo=function([e,s,i,r],a){switch(a){case 90:return[1-s-r,e,r,i];case 180:return[1-e-i,1-s-r,i,r];case 270:return[s,1-e-i,r,i]}return[e,s,i,r]},dy=function(e){it._keyboardManager.exec(this,e)},cu=function(e){if(!n(this,Ll))return;const s=window.getSelection();e?s.setPosition(n(this,Ll),n(this,fd)):s.setPosition(n(this,gd),n(this,md))},du=function(){return n(this,ue)?this.rotation:0},uy=function(){if(n(this,ue))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,pn),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:u,height:p}of a){const m=h*e+i,y=(1-c)*s+r;o[l]=o[l+4]=m,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=m+u*e,o[l+5]=o[l+7]=y-p*s,l+=8}return o},fy=function(e){return n(this,cs).serialize(e,b(this,Y,du).call(this))},py=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},gy=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},my=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},g(it,Fs),P(it,"_defaultColor",null),P(it,"_defaultOpacity",1),P(it,"_defaultThickness",12),P(it,"_type","highlight"),P(it,"_editorType",$.HIGHLIGHT),P(it,"_freeHighlightId",-1),P(it,"_freeHighlight",null),P(it,"_freeHighlightClipId","");let Tu=it;var Wa;class by{constructor(){g(this,Wa,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,Wa)[t]=e}toSVGProperties(){const t=n(this,Wa);return f(this,Wa,Object.create(null)),{root:t}}reset(){f(this,Wa,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){rt("Not implemented")}}Wa=new WeakMap;var Ie,Nl,se,Xa,Ya,et,Up,Gp,$p,Sh,yy,uu,Eh,yo;const tt=class tt extends At{constructor(e){super(e);g(this,et);g(this,Ie,null);g(this,Nl);P(this,"_colorPicker",null);P(this,"_drawId",null);f(this,Nl,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(b(this,et,Up).call(this,e),b(this,et,Sh).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){rt("Not implemented")}static get typesMap(){rt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(tt,se).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=n(this,Ie).updateProperty(s,l);h&&b(this,et,Eh).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s){const i=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[i],l=a[r],h=(c,u)=>{var p;a.updateProperty(i,c),a.updateProperty(r,u),n(this,Ie).updateProperty(i,c),n(this,Ie).updateProperty(r,u),(p=this.parent)==null||p.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,e,s),undo:h.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:V.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(n(this,Ie).getPathResizingSVGProperties(b(this,et,uu).call(this)),{bbox:b(this,et,yo).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(n(this,Ie).getPathResizedSVGProperties(b(this,et,uu).call(this)),{bbox:b(this,et,yo).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,et,yo).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(n(this,Ie).getPathTranslatedSVGProperties(b(this,et,uu).call(this),this.parentDimensions),{bbox:b(this,et,yo).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,Nl)&&(f(this,Nl,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,et,$p).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,et,Sh).call(this),b(this,et,Eh).call(this,n(this,Ie).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,et,$p).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,et,Sh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties({bbox:b(this,et,yo).call(this)},n(this,Ie).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,et,Eh).call(this,n(this,Ie).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,r,a){rt("Not implemented")}static startDrawing(e,s,i,r){var v;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(we.isInitializedAndDifferentPointerType(c))return;const{viewport:{rotation:u}}=e,{width:p,height:m}=a.getBoundingClientRect(),y=f(tt,Xa,new AbortController),A=e.combinedSignal(y);if(we.setPointer(c,h),window.addEventListener("pointerup",w=>{we.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:A}),window.addEventListener("pointercancel",w=>{we.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:A}),window.addEventListener("pointerdown",w=>{we.isSamePointerType(w.pointerType)&&(we.initializeAndAddPointerId(w.pointerId),n(tt,se).isCancellable()&&(n(tt,se).removeLastElement(),n(tt,se).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",As,{signal:A}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),a.addEventListener("touchmove",w=>{we.isSameTimeStamp(w.timeStamp)&&Tt(w)},{signal:A}),e.toggleDrawing(),(v=s._editorUndoBar)==null||v.hide(),n(tt,se)){e.drawLayer.updateProperties(this._currentDrawId,n(tt,se).startNew(o,l,p,m,u));return}s.updateUIForDefaultProperties(this),f(tt,se,this.createDrawerInstance(o,l,p,m,u)),f(tt,Ya,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(tt,Ya).toSVGProperties(),n(tt,se).defaultSVGProperties),!0,!1)}static _drawMove(e){if(we.isSameTimeStamp(e.timeStamp),!n(tt,se))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(we.isSamePointerId(r)){if(we.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(tt,se).add(s,i)),we.setTimeStamp(e.timeStamp),Tt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,f(tt,se,null),f(tt,Ya,null),we.clearTimeStamp()),n(tt,Xa)&&(n(tt,Xa).abort(),f(tt,Xa,null),we.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(tt,se).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(tt,se),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:V.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(V.DRAW_STEP),!n(tt,se).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(tt,se).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(tt,Ya),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){rt("Not implemented")}static async deserialize(e,s,i){var u,p;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),b(u=c,et,Up).call(u,{drawOutlines:h}),b(p=c,et,Sh).call(p),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,Ie).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Ie=new WeakMap,Nl=new WeakMap,se=new WeakMap,Xa=new WeakMap,Ya=new WeakMap,et=new WeakSet,Up=function({drawOutlines:e,drawId:s,drawingOptions:i}){f(this,Ie,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=b(this,et,Gp).call(this,e,this.parent),b(this,et,Eh).call(this,e.box)},Gp=function(e,s){const{id:i}=s.drawLayer.draw(tt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},$p=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Sh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,et,Gp).call(this,n(this,Ie),e)}},yy=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},uu=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},Eh=function(e){[this.x,this.y,this.width,this.height]=b(this,et,yy).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},yo=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/h),r*(h/l),i*(l/h)];case 5:return[1-s,e,i*(l/h),r*(h/l)];case 6:return[1-e-r*(h/l),1-s,r*(h/l),i*(l/h)];case 7:return[s-i*(l/h),1-e-r*(h/l),i*(l/h),r*(h/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(h/l),s,r*(h/l),i*(l/h)];case 13:return[1-s-i*(l/h),e-r*(h/l),i*(l/h),r*(h/l)];case 14:return[1-e,1-s-i*(l/h),r*(h/l),i*(l/h)];case 15:return[s,1-e,i*(l/h),r*(h/l)];default:return[e,s,i,r]}},P(tt,"_currentDrawId",-1),P(tt,"_currentParent",null),g(tt,se,null),g(tt,Xa,null),g(tt,Ya,null),P(tt,"_INNER_MARGIN",3);let Pu=tt;var Si,ie,ne,Ka,Bl,Le,fe,Rs,qa,Qa,Ja,Hl,fu;class Ow{constructor(t,e,s,i,r,a){g(this,Hl);g(this,Si,new Float64Array(6));g(this,ie);g(this,ne);g(this,Ka);g(this,Bl);g(this,Le);g(this,fe,"");g(this,Rs,0);g(this,qa,new Pd);g(this,Qa);g(this,Ja);f(this,Qa,s),f(this,Ja,i),f(this,Ka,r),f(this,Bl,a),[t,e]=b(this,Hl,fu).call(this,t,e);const o=f(this,ie,[NaN,NaN,NaN,NaN,t,e]);f(this,Le,[t,e]),f(this,ne,[{line:o,points:n(this,Le)}]),n(this,Si).set(o,0)}updateProperty(t,e){t==="stroke-width"&&f(this,Bl,e)}isEmpty(){return!n(this,ne)||n(this,ne).length===0}isCancellable(){return n(this,Le).length<=10}add(t,e){[t,e]=b(this,Hl,fu).call(this,t,e);const[s,i,r,a]=n(this,Si).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,Qa)*o,n(this,Ja)*l)<=2?null:(n(this,Le).push(t,e),isNaN(s)?(n(this,Si).set([r,a,t,e],2),n(this,ie).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,Si)[0])&&n(this,ie).splice(6,6),n(this,Si).set([s,i,r,a,t,e],0),n(this,ie).push(...O.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,Le).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){f(this,Qa,s),f(this,Ja,i),f(this,Ka,r),[t,e]=b(this,Hl,fu).call(this,t,e);const a=f(this,ie,[NaN,NaN,NaN,NaN,t,e]);f(this,Le,[t,e]);const o=n(this,ne).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,ne).push({line:a,points:n(this,Le)}),n(this,Si).set(a,0),f(this,Rs,0),this.toSVGPath(),null}getLastElement(){return n(this,ne).at(-1)}setLastElement(t){return n(this,ne)?(n(this,ne).push(t),f(this,ie,t.line),f(this,Le,t.points),f(this,Rs,0),{path:{d:this.toSVGPath()}}):n(this,qa).setLastElement(t)}removeLastElement(){if(!n(this,ne))return n(this,qa).removeLastElement();n(this,ne).pop(),f(this,fe,"");for(let t=0,e=n(this,ne).length;t<e;t++){const{line:s,points:i}=n(this,ne)[t];f(this,ie,s),f(this,Le,i),f(this,Rs,0),this.toSVGPath()}return{path:{d:n(this,fe)}}}toSVGPath(){const t=O.svgRound(n(this,ie)[4]),e=O.svgRound(n(this,ie)[5]);if(n(this,Le).length===2)return f(this,fe,`${n(this,fe)} M ${t} ${e} Z`),n(this,fe);if(n(this,Le).length<=6){const i=n(this,fe).lastIndexOf("M");f(this,fe,`${n(this,fe).slice(0,i)} M ${t} ${e}`),f(this,Rs,6)}if(n(this,Le).length===4){const i=O.svgRound(n(this,ie)[10]),r=O.svgRound(n(this,ie)[11]);return f(this,fe,`${n(this,fe)} L ${i} ${r}`),f(this,Rs,12),n(this,fe)}const s=[];n(this,Rs)===0&&(s.push(`M ${t} ${e}`),f(this,Rs,6));for(let i=n(this,Rs),r=n(this,ie).length;i<r;i+=6){const[a,o,l,h,c,u]=n(this,ie).slice(i,i+6).map(O.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}return f(this,fe,n(this,fe)+s.join(" ")),f(this,Rs,n(this,ie).length),n(this,fe)}getOutlines(t,e,s,i){const r=n(this,ne).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,qa).build(n(this,ne),t,e,s,n(this,Ka),n(this,Bl),i),f(this,Si,null),f(this,ie,null),f(this,ne,null),f(this,fe,null),n(this,qa)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Si=new WeakMap,ie=new WeakMap,ne=new WeakMap,Ka=new WeakMap,Bl=new WeakMap,Le=new WeakMap,fe=new WeakMap,Rs=new WeakMap,qa=new WeakMap,Qa=new WeakMap,Ja=new WeakMap,Hl=new WeakSet,fu=function(t,e){return O._normalizePoint(t,e,n(this,Qa),n(this,Ja),n(this,Ka))};var Re,yd,Ad,us,Ei,xi,Ul,Gl,Za,ge,Fi,Ay,wy,vy;class Pd extends O{constructor(){super(...arguments);g(this,ge);g(this,Re);g(this,yd,0);g(this,Ad);g(this,us);g(this,Ei);g(this,xi);g(this,Ul);g(this,Gl);g(this,Za)}build(e,s,i,r,a,o,l){f(this,Ei,s),f(this,xi,i),f(this,Ul,r),f(this,Gl,a),f(this,Za,o),f(this,Ad,l??0),f(this,us,e),b(this,ge,wy).call(this)}get thickness(){return n(this,Za)}setLastElement(e){return n(this,us).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,us).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,us)){if(e.push(`M${O.svgRound(s[4])} ${O.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${O.svgRound(s[10])} ${O.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,u]=s.subarray(i,i+6).map(O.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,u,p]=b(this,ge,Ay).call(this);let m,y,A,v,w,S,E,x,_;switch(n(this,Gl)){case 0:_=O._rescale,m=e,y=s+r,A=i,v=-r,w=e+h*i,S=s+(1-c-p)*r,E=e+(h+u)*i,x=s+(1-c)*r;break;case 90:_=O._rescaleAndSwap,m=e,y=s,A=i,v=r,w=e+c*i,S=s+h*r,E=e+(c+p)*i,x=s+(h+u)*r;break;case 180:_=O._rescale,m=e+i,y=s,A=-i,v=r,w=e+(1-h-u)*i,S=s+c*r,E=e+(1-h)*i,x=s+(c+p)*r;break;case 270:_=O._rescaleAndSwap,m=e+i,y=s+r,A=-i,v=-r,w=e+(1-c-p)*i,S=s+(1-h-u)*r,E=e+(1-c)*i,x=s+(1-h)*r;break}for(const{line:C,points:T}of n(this,us))o.push(_(C,m,y,A,v,a?new Array(C.length):null)),l.push(_(T,m,y,A,v,a?new Array(T.length):null));return{lines:o,points:l,rect:[w,S,E,x]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const u=[];let p,m,y,A,v;switch(h){case 0:v=O._rescale,p=-e/i,m=s/r+1,y=1/i,A=-1/r;break;case 90:v=O._rescaleAndSwap,p=-s/r,m=-e/i,y=1/r,A=1/i;break;case 180:v=O._rescale,p=e/i+1,m=-s/r,y=-1/i,A=1/r;break;case 270:v=O._rescaleAndSwap,p=s/r+1,m=e/i+1,y=-1/r,A=-1/i;break}if(!o){o=[];for(const S of l){const E=S.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const x=new Float32Array(3*(E-2));o.push(x);let[_,C,T,M]=S.subarray(0,4);x.set([NaN,NaN,NaN,NaN,_,C],0);for(let k=4;k<E;k+=2){const L=S[k],I=S[k+1];x.set(O.createBezierPoints(_,C,T,M,L,I),(k-2)*3),[_,C,T,M]=[T,M,L,I]}}}for(let S=0,E=o.length;S<E;S++)u.push({line:v(o[S].map(x=>x??NaN),p,m,y,A),points:v(l[S].map(x=>x??NaN),p,m,y,A)});const w=new this.prototype.constructor;return w.build(u,i,r,1,h,c,a),w}get box(){return n(this,Re)}updateProperty(e,s){return e==="stroke-width"?b(this,ge,vy).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,ge,Fi).call(this);f(this,Ei,e),f(this,xi,s),f(this,Ul,i);const[o,l]=b(this,ge,Fi).call(this),h=o-r,c=l-a,u=n(this,Re);return u[0]-=h,u[1]-=c,u[2]+=2*h,u[3]+=2*c,u}updateRotation(e){return f(this,yd,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,Re).map(O.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,Re);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,Re);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,yd)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${O.svgRound(l)} ${O.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,ge,Fi).call(this),[l,h,c,u]=n(this,Re);if(Math.abs(c-a)<=O.PRECISION||Math.abs(u-o)<=O.PRECISION){const v=e+i/2-(l+c/2),w=s+r/2-(h+u/2);return{path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const p=(i-2*a)/(c-2*a),m=(r-2*o)/(u-2*o),y=c/i,A=u/r;return{path:{"transform-origin":`${O.svgRound(l)} ${O.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${O.svgRound(a)} ${O.svgRound(o)}) scale(${p} ${m}) translate(${O.svgRound(-a)} ${O.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,ge,Fi).call(this),l=n(this,Re),[h,c,u,p]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(u-a)<=O.PRECISION||Math.abs(p-o)<=O.PRECISION){const w=e+i/2-(h+u/2),S=s+r/2-(c+p/2);for(const{line:E,points:x}of n(this,us))O._translate(E,w,S,E),O._translate(x,w,S,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(i-2*a)/(u-2*a),y=(r-2*o)/(p-2*o),A=-m*(h+a)+e+a,v=-y*(c+o)+s+o;if(m!==1||y!==1||A!==0||v!==0)for(const{line:w,points:S}of n(this,us))O._rescale(w,A,v,m,y,w),O._rescale(S,A,v,m,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,Re),l=e-o[0],h=s-o[1];if(n(this,Ei)===r&&n(this,xi)===a)for(const{line:c,points:u}of n(this,us))O._translate(c,l,h,c),O._translate(u,l,h,u);else{const c=n(this,Ei)/r,u=n(this,xi)/a;f(this,Ei,r),f(this,xi,a);for(const{line:p,points:m}of n(this,us))O._rescale(p,l,h,c,u,p),O._rescale(m,l,h,c,u,m);o[2]*=c,o[3]*=u}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,Re);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e[0])} ${O.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Re=new WeakMap,yd=new WeakMap,Ad=new WeakMap,us=new WeakMap,Ei=new WeakMap,xi=new WeakMap,Ul=new WeakMap,Gl=new WeakMap,Za=new WeakMap,ge=new WeakSet,Fi=function(e=n(this,Za)){const s=n(this,Ad)+e/2*n(this,Ul);return n(this,Gl)%180===0?[s/n(this,Ei),s/n(this,xi)]:[s/n(this,xi),s/n(this,Ei)]},Ay=function(){const[e,s,i,r]=n(this,Re),[a,o]=b(this,ge,Fi).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},wy=function(){const e=f(this,Re,Or.slice());for(const{line:r}of n(this,us)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)D.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;l+=6){const[c,u,p,m,y,A]=r.subarray(l,l+6);D.bezierBoundingBox(a,o,c,u,p,m,y,A,e),a=y,o=A}}const[s,i]=b(this,ge,Fi).call(this);e[0]=Et(e[0]-s,0,1),e[1]=Et(e[1]-i,0,1),e[2]=Et(e[2]+s,0,1),e[3]=Et(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},vy=function(e){const[s,i]=b(this,ge,Fi).call(this);f(this,Za,e);const[r,a]=b(this,ge,Fi).call(this),[o,l]=[r-s,a-i],h=n(this,Re);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class Sf extends by{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:At._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Sf(this._viewParameters);return t.updateAll(this),t}}var ef,Sy;const So=class So extends Pu{constructor(e){super({...e,name:"inkEditor"});g(this,ef);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){At.initialize(e,s),this._defaultDrawingOptions=new Sf(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,"typesMap",new Map([[V.INK_THICKNESS,"stroke-width"],[V.INK_COLOR,"stroke"],[V.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,r,a){return new Ow(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return Pd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof fg){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:u,opacity:p,borderStyle:{rawWidth:m},popupRef:y,richText:A,contentsObj:v,creationDate:w,modificationDate:S},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:$.INK,color:Array.from(u),thickness:m,opacity:p,paths:{points:o},boxes:null,pageIndex:E-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:y,richText:A,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:S}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new xu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return V.INK_COLOR}get colorAndOpacityType(){return V.INK_COLOR_AND_OPACITY}get opacityType(){return V.INK_OPACITY}updateParams(e,s){if(e===V.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===V.INK_COLOR_AND_OPACITY){super.updateDefaultParams(V.INK_COLOR,s.color),super.updateDefaultParams(V.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=So.getDefaultDrawingOptions({stroke:D.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:At._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!b(this,ef,Sy).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};ef=new WeakSet,Sy=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},P(So,"_type","ink"),P(So,"_editorType",$.INK),P(So,"_defaultDrawingOptions",null);let jp=So;class zp extends Pd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Fd=8,ih=3;var to,at,Vp,qs,Ey,xy,Wp,pu,_y,Cy,Ty,Xp,Yp,Py;class Mi{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const u=200,p=c.font=`${s} ${i} ${u}px ${e}`,{actualBoundingBoxLeft:m,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:S,width:E}=c.measureText(t),x=1.5,_=Math.ceil(Math.max(Math.abs(m)+Math.abs(y)||0,E)*x),C=Math.ceil(Math.max(Math.abs(A)+Math.abs(v)||u,Math.abs(w)+Math.abs(S)||u)*x);h=new OffscreenCanvas(_,C),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=p,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,_,C),c.fillStyle="black",c.fillText(t,_*(x-1)/2,C*(3-x)/2);const T=b(this,at,Xp).call(this,c.getImageData(0,0,_,C).data),M=b(this,at,Ty).call(this,T),k=b(this,at,Yp).call(this,M),L=b(this,at,Wp).call(this,T,_,C,k);return this.processDrawnLines({lines:{curves:L,width:_,height:C},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=b(this,at,Py).call(this,t),[h,c]=b(this,at,Cy).call(this,a,o,l,Math.hypot(o,l)*n(this,to).sigmaSFactor,n(this,to).sigmaR,n(this,to).kernelSize),u=b(this,at,Yp).call(this,c),p=b(this,at,Wp).call(this,h,o,l,u);return this.processDrawnLines({lines:{curves:p,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:h,height:c}=t,u=t.thickness??0,p=[],m=Math.min(e/h,s/c),y=m/e,A=m/s,v=[];for(const{points:S}of l){const E=a?b(this,at,_y).call(this,S):S;if(!E)continue;v.push(E);const x=E.length,_=new Float32Array(x),C=new Float32Array(3*(x===2?2:x-2));if(p.push({line:C,points:_}),x===2){_[0]=E[0]*y,_[1]=E[1]*A,C.set([NaN,NaN,NaN,NaN,_[0],_[1]],0);continue}let[T,M,k,L]=E;T*=y,M*=A,k*=y,L*=A,_.set([T,M,k,L],0),C.set([NaN,NaN,NaN,NaN,T,M],0);for(let I=4;I<x;I+=2){const X=_[I]=E[I]*y,Q=_[I+1]=E[I+1]*A;C.set(O.createBezierPoints(T,M,k,L,X,Q),(I-2)*3),[T,M,k,L]=[k,L,X,Q]}}if(p.length===0)return null;const w=o?new zp:new Pd;return w.build(p,e,s,1,i,o?0:u,r),{outline:w,newCurves:v,areContours:o,thickness:u,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const S of t){l+=S.length;for(let E=2,x=S.length;E<x;E++){const _=S[E]-S[E-2];a=Math.min(a,_),o=Math.max(o,_)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,u=Fd+ih*c,p=new Uint32Array(u);let m=0;p[m++]=u*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,p[m++]=0,p[m++]=i,p[m++]=r,p[m++]=e?0:1,p[m++]=Math.max(0,Math.floor(s??0)),p[m++]=c,p[m++]=h.BYTES_PER_ELEMENT;for(const S of t)p[m++]=S.length-2,p[m++]=S[0],p[m++]=S[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(p);const v=h.prototype.constructor;for(const S of t){const E=new v(S.length-2);for(let x=2,_=S.length;x<_;x++)E[x-2]=S[x]-S[x-2];A.write(E)}return A.close(),(await new Response(y.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const E of s)a||(a=new Uint8Array(new Uint32Array(E.buffer,0,4)[0])),a.set(E,o),o+=E.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],u=l[3],p=l[4]===0,m=l[5],y=l[6],A=l[7],v=[],w=(Fd+ih*y)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,w);break}o=0;for(let E=0;E<y;E++){const x=l[ih*E+Fd],_=new Float32Array(x+2);v.push(_);for(let C=0;C<ih-1;C++)_[C]=l[ih*E+Fd+C+1];for(let C=0;C<x;C++)_[C+2]=_[C]+S[o++]}return{areContours:p,thickness:m,outlines:v,width:c,height:u}}catch(e){return W(`decompressSignature: ${e}`),null}}}to=new WeakMap,at=new WeakSet,Vp=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},qs=new WeakMap,Ey=function(t,e,s,i,r,a,o){const l=b(this,at,Vp).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,u=n(this,qs)[2*c],p=n(this,qs)[2*c+1];if(t[(s+u)*e+(i+p)]!==0)return c}return-1},xy=function(t,e,s,i,r,a,o){const l=b(this,at,Vp).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,u=n(this,qs)[2*c],p=n(this,qs)[2*c+1];if(t[(s+u)*e+(i+p)]!==0)return c}return-1},Wp=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)a[c*e]=a[c*e+e-1]=0;for(let c=0;c<e;c++)a[c]=a[e*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let u=1;u<e-1;u++){const p=c*e+u,m=a[p];if(m===0)continue;let y=c,A=u;if(m===1&&a[p-1]===0)o+=1,A-=1;else if(m>=1&&a[p+1]===0)o+=1,A+=1,m>1&&(l=m);else{m!==1&&(l=Math.abs(m));continue}const v=[u,c],w=A===u+1,S={isHole:w,points:v,id:o,parent:0};h.push(S);let E;for(const I of h)if(I.id===l){E=I;break}E?E.isHole?S.parent=w?E.parent:l:S.parent=w?l:E.parent:S.parent=w?l:0;const x=b(this,at,Ey).call(this,a,e,c,u,y,A,0);if(x===-1){a[p]=-o,a[p]!==1&&(l=Math.abs(a[p]));continue}let _=n(this,qs)[2*x],C=n(this,qs)[2*x+1];const T=c+_,M=u+C;y=T,A=M;let k=c,L=u;for(;;){const I=b(this,at,xy).call(this,a,e,k,L,y,A,1);_=n(this,qs)[2*I],C=n(this,qs)[2*I+1];const X=k+_,Q=L+C;v.push(Q,X);const q=k*e+L;if(a[q+1]===0?a[q]=-o:a[q]===1&&(a[q]=o),X===c&&Q===u&&k===T&&L===M){a[p]!==1&&(l=Math.abs(a[p]));break}else y=k,A=L,k=X,L=Q}}}return h},pu=function(t,e,s,i){if(s-e<=4){for(let T=e;T<s-2;T+=2)i.push(t[T],t[T+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,h=Math.hypot(o,l),c=o/h,u=l/h,p=c*a-u*r,m=l/o,y=1/h,A=Math.atan(m),v=Math.cos(A),w=Math.sin(A),S=y*(Math.abs(v)+Math.abs(w)),E=y*(1-S+S**2),x=Math.max(Math.atan(Math.abs(w+v)*E),Math.atan(Math.abs(w-v)*E));let _=0,C=e;for(let T=e+2;T<s-2;T+=2){const M=Math.abs(p-c*t[T+1]+u*t[T]);M>_&&(C=T,_=M)}_>(h*x)**2?(b(this,at,pu).call(this,t,e,C+2,i),b(this,at,pu).call(this,t,C,s,i)):i.push(r,a)},_y=function(t){const e=[],s=t.length;return b(this,at,pu).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},Cy=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,h=a>>1;for(let A=0;A<a;A++){const v=(A-h)**2;for(let w=0;w<a;w++)o[A*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),u=-2*r**2;for(let A=0;A<256;A++)c[A]=Math.exp(A**2/u);const p=t.length,m=new Uint8Array(p),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let v=0;v<e;v++){const w=A*e+v,S=t[w];let E=0,x=0;for(let C=0;C<a;C++){const T=A+C-h;if(!(T<0||T>=s))for(let M=0;M<a;M++){const k=v+M-h;if(k<0||k>=e)continue;const L=t[T*e+k],I=o[C*a+M]*c[Math.abs(L-S)];E+=L*I,x+=I}}const _=m[w]=Math.round(E/x);y[_]++}return[m,y]},Ty=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Xp=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=t[o<<2];i=Math.max(i,h),r=Math.min(r,h)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},Yp=function(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},Py=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,to);let a=s,o=i;if(s>r||i>r){let p=s,m=i,y=Math.log2(Math.max(s,i)/r);const A=Math.floor(y);y=y===A?A-1:A;for(let w=0;w<y;w++){a=Math.ceil(p/2),o=Math.ceil(m/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,p,m,0,0,a,o),p=a,m=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const v=Math.min(r/a,r/o);a=Math.round(a*v),o=Math.round(o*v)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[b(this,at,Xp).call(this,c),a,o]},g(Mi,at),g(Mi,to,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(Mi,qs,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class pg extends by{constructor(){super(),super.updateProperties({fill:At._defaultLineColor,"stroke-width":0})}clone(){const t=new pg;return t.updateAll(this),t}}class gg extends Sf{constructor(t){super(t),super.updateProperties({stroke:At._defaultLineColor,"stroke-width":1})}clone(){const t=new gg(this._viewParameters);return t.updateAll(this),t}}var br,_i,yr,eo;const qe=class qe extends Pu{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,br,!1);g(this,_i,null);g(this,yr,null);g(this,eo,null);this._willKeepAspectRatio=!0,f(this,yr,e.signatureData||null),f(this,_i,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){At.initialize(e,s),this._defaultDrawingOptions=new pg,this._defaultDrawnSignatureOptions=new gg(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,_i)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,yr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,yr),{rawDims:{pageWidth:u,pageHeight:p},rotation:m}=this.parent.viewport,y=Mi.processDrawnLines({lines:r,pageWidth:u,pageHeight:p,rotation:m,innerMargin:qe._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,c,l,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:n(this,_i)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){f(this,eo,e),this.addEditToolbar()}getUuid(){return n(this,eo)}get description(){return n(this,_i)}set description(e){f(this,_i,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,yr),o=Math.max(r,a),l=Mi.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,r){const{x:a,y:o}=this,{outline:l}=f(this,yr,e);f(this,br,l instanceof zp),this.description=i;let h;n(this,br)?h=qe.getDefaultDrawingOptions():(h=qe._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let u=s/c;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Mi.process(e,s,i,r,qe._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return Mi.extractContoursFromText(e,s,i,r,a,qe._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Mi.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:qe._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=qe.getDefaultDrawingOptions():(this._drawingOptions=qe._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:n(this,br),color:[0,0,0],thickness:n(this,br)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,eo),a.isCopy=!0):a.lines=s,n(this,_i)&&(a.accessibilityData={type:"Figure",alt:n(this,_i)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?zp.deserialize(e,s,i,r,a,o):Pd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return f(r,br,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",f(r,eo,e.uuid),r}};br=new WeakMap,_i=new WeakMap,yr=new WeakMap,eo=new WeakMap,P(qe,"_type","signature"),P(qe,"_editorType",$.SIGNATURE),P(qe,"_defaultDrawingOptions",null);let Kp=qe;var Ct,re,Ar,gn,wr,$l,mn,so,Ci,fs,jl,st,xh,_h,gu,mu,bu,Qp,yu,ky;class qp extends At{constructor(e){super({...e,name:"stampEditor"});g(this,st);g(this,Ct,null);g(this,re,null);g(this,Ar,null);g(this,gn,null);g(this,wr,null);g(this,$l,"");g(this,mn,null);g(this,so,!1);g(this,Ci,null);g(this,fs,!1);g(this,jl,!1);f(this,gn,e.bitmapUrl),f(this,wr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){At.initialize(e,s)}static isHandlingMimeForPasting(e){return Su.includes(e)}static paste(e,s){s.pasteEditor({mode:$.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;n(this,re)&&(f(this,Ct,null),this._uiManager.imageManager.deleteId(n(this,re)),(e=n(this,mn))==null||e.remove(),f(this,mn,null),n(this,Ci)&&(clearTimeout(n(this,Ci)),f(this,Ci,null))),super.remove()}rebuild(){if(!this.parent){n(this,re)&&b(this,st,gu).call(this);return}super.rebuild(),this.div!==null&&(n(this,re)&&n(this,mn)===null&&b(this,st,gu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,Ar)||n(this,Ct)||n(this,gn)||n(this,wr)||n(this,re)||n(this,so))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,so)||(n(this,Ct)?b(this,st,mu).call(this):b(this,st,gu).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(f(this,re,i),r&&f(this,Ct,r),f(this,so,!1),b(this,st,mu).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Ci)!==null&&clearTimeout(n(this,Ci)),f(this,Ci,setTimeout(()=>{f(this,Ci,null),b(this,st,Qp).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,Ct),o=new si;let l=n(this,Ct),h=r,c=a,u=null;if(s){if(r>s||a>s){const T=Math.min(s/r,s/a);h=Math.floor(r*T),c=Math.floor(a*T)}u=document.createElement("canvas");const m=u.width=Math.ceil(h*o.sx),y=u.height=Math.ceil(c*o.sy);n(this,fs)||(l=b(this,st,bu).call(this,m,y));const A=u.getContext("2d");A.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":sA.isDarkMode&&(v="#8f8f9d",w="#42414d");const S=15,E=S*o.sx,x=S*o.sy,_=new OffscreenCanvas(E*2,x*2),C=_.getContext("2d");C.fillStyle=v,C.fillRect(0,0,E*2,x*2),C.fillStyle=w,C.fillRect(0,0,E,x),C.fillRect(E,x,E,x),A.fillStyle=A.createPattern(_,"repeat"),A.fillRect(0,0,m,y),A.drawImage(l,0,0,l.width,l.height,0,0,m,y)}let p=null;if(i){let m,y;if(o.symmetric&&l.width<e&&l.height<e)m=l.width,y=l.height;else if(l=n(this,Ct),r>e||a>e){const w=Math.min(e/r,e/a);m=Math.floor(r*w),y=Math.floor(a*w),n(this,fs)||(l=b(this,st,bu).call(this,m,y))}const v=new OffscreenCanvas(m,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,m,y),p={width:m,height:y,data:v.getImageData(0,0,m,y).data}}return{canvas:u,width:h,height:c,imageData:p}}static async deserialize(e,s,i){var v;let r=null,a=!1;if(e instanceof Vb){const{data:{rect:w,rotation:S,id:E,structParent:x,popupRef:_,richText:C,contentsObj:T,creationDate:M,modificationDate:k},container:L,parent:{page:{pageNumber:I}},canvas:X}=e;let Q,q;X?(delete e.canvas,{id:Q,bitmap:q}=i.imageManager.getFromCanvas(L.id,X),X.remove()):(a=!0,e._hasNoCanvas=!0);const Z=((v=await s._structTree.getAriaAttributes(`${wo}${E}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:$.STAMP,bitmapId:Q,bitmap:q,pageIndex:I-1,rect:w.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:Z},isSvg:!1,structParent:x,popupRef:_,richText:C,comment:(T==null?void 0:T.str)||null,creationDate:M,modificationDate:k}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:u,isSvg:p,accessibilityData:m}=e;a?(i.addMissingCanvas(e.id,o),f(o,so,!0)):u&&i.imageManager.isValidId(u)?(f(o,re,u),h&&f(o,Ct,h)):f(o,gn,c),f(o,fs,p);const[y,A]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/A,m&&(o.altTextData=m),o._initialData=r,e.comment&&o.setCommentData(e),f(o,jl,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:n(this,re),isSvg:n(this,fs)});if(this.addComment(i),e)return i.bitmapUrl=b(this,st,yu).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,st,ky).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,fs)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,re)))s.stamps.set(n(this,re),{area:o,serialized:i}),i.bitmap=b(this,st,yu).call(this,!1);else if(n(this,fs)){const l=s.stamps.get(n(this,re));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,st,yu).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Ct=new WeakMap,re=new WeakMap,Ar=new WeakMap,gn=new WeakMap,wr=new WeakMap,$l=new WeakMap,mn=new WeakMap,so=new WeakMap,Ci=new WeakMap,fs=new WeakMap,jl=new WeakMap,st=new WeakSet,xh=function(e,s=!1){if(!e){this.remove();return}f(this,Ct,e.bitmap),s||(f(this,re,e.id),f(this,fs,e.isSvg)),e.file&&f(this,$l,e.file.name),b(this,st,mu).call(this)},_h=function(){if(f(this,Ar,null),this._uiManager.enableWaiting(!1),!!n(this,mn)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Ct)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Ct)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},gu=function(){if(n(this,re)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,re)).then(i=>b(this,st,xh).call(this,i,!0)).finally(()=>b(this,st,_h).call(this));return}if(n(this,gn)){const i=n(this,gn);f(this,gn,null),this._uiManager.enableWaiting(!0),f(this,Ar,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,st,xh).call(this,r)).finally(()=>b(this,st,_h).call(this)));return}if(n(this,wr)){const i=n(this,wr);f(this,wr,null),this._uiManager.enableWaiting(!0),f(this,Ar,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,st,xh).call(this,r)).finally(()=>b(this,st,_h).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Su.join(",");const s=this._uiManager._signal;f(this,Ar,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,st,xh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,st,_h).call(this))),e.click()},mu=function(){var h;const{div:e}=this;let{width:s,height:i}=n(this,Ct);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const c=Math.min(o*r/s,o*a/i);s*=c,i*=c}this._uiManager.enableWaiting(!1);const l=f(this,mn,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/a,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,st,Qp).call(this),n(this,jl)||(this.parent.addUndoableEditor(this),f(this,jl,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,$l)&&this.div.setAttribute("aria-description",n(this,$l)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},bu=function(e,s){const{width:i,height:r}=n(this,Ct);let a=i,o=r,l=n(this,Ct);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=u.transferToImageBitmap()}return l},Qp=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new si,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,mn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,fs)?n(this,Ct):b(this,st,bu).call(this,o,l),u=h.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(c,0,0,c.width,c.height,0,0,o,l)},yu=function(e){if(e){if(n(this,fs)){const r=this._uiManager.imageManager.getSvgUrl(n(this,re));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,Ct),s.getContext("2d").drawImage(n(this,Ct),0,0),s.toDataURL()}if(n(this,fs)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Cn.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Cn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,Ct),0,0,n(this,Ct).width,n(this,Ct).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,Ct))},ky=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},P(qp,"_type","stamp"),P(qp,"_editorType",$.STAMP);var io,zl,vr,Sr,bn,We,Er,Vl,Wl,Qs,yn,ae,An,xr,Xl,N,_r,bt,Jp,My,ai,Zp,tg,Au;const Bs=class Bs{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,bt);g(this,io);g(this,zl,!1);g(this,vr,null);g(this,Sr,null);g(this,bn,null);g(this,We,new Map);g(this,Er,!1);g(this,Vl,!1);g(this,Wl,!1);g(this,Qs,null);g(this,yn,null);g(this,ae,null);g(this,An,null);g(this,xr,null);g(this,Xl,-1);g(this,N);const u=[...n(Bs,_r).values()];if(!Bs._initialized){Bs._initialized=!0;for(const p of u)p.initialize(c,t)}t.registerEditorTypes(u),f(this,N,t),this.pageIndex=e,this.div=s,f(this,io,r),f(this,vr,a),this.viewport=h,f(this,ae,l),this.drawLayer=o,this._structTree=i,n(this,N).addLayer(this)}get isEmpty(){return n(this,We).size===0}get isInvisible(){return this.isEmpty&&n(this,N).getMode()===$.NONE}updateToolbar(t){n(this,N).updateToolbar(t)}updateMode(t=n(this,N).getMode()){switch(b(this,bt,Au).call(this),t){case $.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case $.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case $.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===$.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Bs,_r).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,ae))==null?void 0:e.div)}setEditingState(t){n(this,N).setEditingState(t)}addCommands(t){n(this,N).addCommands(t)}cleanUndoStack(t){n(this,N).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=n(this,vr))==null||e.togglePointerEvents(t)}async enable(){var s;f(this,Wl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,xr))==null||s.abort(),f(this,xr,null);const t=new Set;for(const i of n(this,bt,Jp))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,N).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,vr);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,N).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}f(this,Wl,!1),n(this,N)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(f(this,Vl,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,ae)&&!n(this,xr)){f(this,xr,new AbortController);const r=n(this,N).combinedSignal(n(this,xr));n(this,ae).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,u=n(this,Xl);if(c-u>500){f(this,Xl,c);return}f(this,Xl,-1);const{classList:p}=this.div;p.toggle("getElements",!0);const m=document.elementsFromPoint(l,h);if(p.toggle("getElements",!1),!this.div.contains(m[0]))return;let y;const A=new RegExp(`^${Dh}[0-9]+$`);for(const w of m)if(A.test(w.id)){y=w.id;break}if(!y)return;const v=n(this,We).get(y);(v==null?void 0:v.annotationElementId)===null&&(Tt(a),v.dblclick(a))},{signal:r,capture:!0})}const t=n(this,vr),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,bt,Jp)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(this,N).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=a.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=r.get(l),h&&(n(this,N).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,bt,Au).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Bs,_r).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),f(this,Vl,!1)}getEditableAnnotation(t){var e;return((e=n(this,vr))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,N).getActive()!==t&&n(this,N).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,ae))!=null&&t.div&&!n(this,An)){f(this,An,new AbortController);const e=n(this,N).combinedSignal(n(this,An));n(this,ae).div.addEventListener("pointerdown",b(this,bt,My).bind(this),{signal:e}),n(this,ae).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,ae))!=null&&t.div&&n(this,An)&&(n(this,An).abort(),f(this,An,null),n(this,ae).div.classList.remove("highlighting"))}enableClick(){if(n(this,Sr))return;f(this,Sr,new AbortController);const t=n(this,N).combinedSignal(n(this,Sr));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=n(this,Sr))==null||t.abort(),f(this,Sr,null)}attach(t){n(this,We).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,N).isDeletedAnnotationElement(e)&&n(this,N).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,We).delete(t.id),(e=n(this,io))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,Vl)&&t.annotationElementId&&n(this,N).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,N).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,N).addDeletedAnnotationElement(t),At.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),n(this,N).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,Wl)),n(this,N).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,bn)&&(t._focusEventsAllowed=!1,f(this,bn,setTimeout(()=>{f(this,bn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,N)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,io))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of n(this,We).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,N).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,bt,ai))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,N).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,bt,tg).call(this),r=n(this,N).getId(),a=b(this,bt,Zp).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,N),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Bs,_r).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,N)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,N).getId(),r=b(this,bt,Zp).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,N),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,bt,tg).call(this),!0,t)}setSelected(t){n(this,N).setSelected(t)}toggleSelected(t){n(this,N).toggleSelected(t)}unselect(t){n(this,N).unselect(t)}pointerup(t){var i;const{isMac:e}=zt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,Er)||(f(this,Er,!1),(i=n(this,bt,ai))!=null&&i.isDrawer&&n(this,bt,ai).supportMultipleDrawings))return;if(!n(this,zl)){f(this,zl,!0);return}const s=n(this,N).getMode();if(s===$.STAMP||s===$.POPUP||s===$.SIGNATURE){n(this,N).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,N).getMode()===$.HIGHLIGHT&&this.enableTextSelection(),n(this,Er)){f(this,Er,!1);return}const{isMac:e}=zt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(f(this,Er,!0),(i=n(this,bt,ai))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,N).getActive();f(this,zl,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,Qs)){n(this,bt,ai).startDrawing(this,n(this,N),!1,t);return}n(this,N).setCurrentDrawingSession(this),f(this,Qs,new AbortController);const e=n(this,N).combinedSignal(n(this,Qs));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(f(this,yn,null),this.commitOrRemove())},{signal:e}),n(this,bt,ai).startDrawing(this,n(this,N),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&f(this,yn,e);return}n(this,yn)&&setTimeout(()=>{var e;(e=n(this,yn))==null||e.focus(),f(this,yn,null)},0)}endDrawingSession(t=!1){return n(this,Qs)?(n(this,N).setCurrentDrawingSession(null),n(this,Qs).abort(),f(this,Qs,null),f(this,yn,null),n(this,bt,ai).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,N).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,Qs)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,Qs)&&n(this,bt,ai).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,N).getActive())==null?void 0:t.parent)===this&&(n(this,N).commitOrRemove(),n(this,N).setActiveEditor(null)),n(this,bn)&&(clearTimeout(n(this,bn)),f(this,bn,null));for(const s of n(this,We).values())(e=n(this,io))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,We).clear(),n(this,N).removeLayer(this)}async render({viewport:t}){this.viewport=t,Cr(this.div,t);for(const e of n(this,N).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,N).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,N).commitOrRemove(),b(this,bt,Au).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Cr(this.div,{rotation:s}),e!==s)for(const i of n(this,We).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,N).viewParameters.realScale}};io=new WeakMap,zl=new WeakMap,vr=new WeakMap,Sr=new WeakMap,bn=new WeakMap,We=new WeakMap,Er=new WeakMap,Vl=new WeakMap,Wl=new WeakMap,Qs=new WeakMap,yn=new WeakMap,ae=new WeakMap,An=new WeakMap,xr=new WeakMap,Xl=new WeakMap,N=new WeakMap,_r=new WeakMap,bt=new WeakSet,Jp=function(){return n(this,We).size!==0?n(this,We).values():n(this,N).getEditors(this.pageIndex)},My=function(t){n(this,N).unselectAll();const{target:e}=t;if(e===n(this,ae).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,ae).div.contains(e)){const{isMac:s}=zt.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,N).showAllEditors("highlight",!0,!0),n(this,ae).div.classList.add("free"),this.toggleDrawing(),Tu.startHighlighting(this,n(this,N).direction==="ltr",{target:n(this,ae).div,x:t.x,y:t.y}),n(this,ae).div.addEventListener("pointerup",()=>{n(this,ae).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,N)._signal}),t.preventDefault()}},ai=function(){return n(Bs,_r).get(n(this,N).getMode())},Zp=function(t){const e=n(this,bt,ai);return e?new e.prototype.constructor(t):null},tg=function(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),h=(r+o)/2-t,c=(a+l)/2-e,[u,p]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:u,offsetY:p}},Au=function(){for(const t of n(this,We).values())t.isEmpty()&&t.remove()},P(Bs,"_initialized",!1),g(Bs,_r,new Map([Lp,jp,qp,Tu,Kp].map(t=>[t._editorType,t])));let ku=Bs;var Js,Fe,no,wd,sf,Dy,Ii,eg,Iy,sg;const qt=class qt{constructor(){g(this,Ii);g(this,Js,null);g(this,Fe,new Map);g(this,no,new Map)}setParent(t){if(!n(this,Js)){f(this,Js,t);return}if(n(this,Js)!==t){if(n(this,Fe).size>0)for(const e of n(this,Fe).values())e.remove(),t.append(e);f(this,Js,t)}}static get _svgFactory(){return j(this,"_svgFactory",new Hh)}draw(t,e=!1,s=!1){const i=Vt(qt,wd)._++,r=b(this,Ii,eg).call(this),a=qt._svgFactory.createElement("defs");r.append(a);const o=qt._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,no).set(i,o);const h=s?b(this,Ii,Iy).call(this,a,l):null,c=qt._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Fe).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=Vt(qt,wd)._++,i=b(this,Ii,eg).call(this),r=qt._svgFactory.createElement("defs");i.append(r);const a=qt._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const u=qt._svgFactory.createElement("mask");r.append(u),l=`mask_${s}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const p=qt._svgFactory.createElement("rect");u.append(p),p.setAttribute("width","1"),p.setAttribute("height","1"),p.setAttribute("fill","white");const m=qt._svgFactory.createElement("use");u.append(m),m.setAttribute("href",`#${o}`),m.setAttribute("stroke","none"),m.setAttribute("fill","black"),m.setAttribute("fill-rule","nonzero"),m.classList.add("mask")}const h=qt._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,Fe).set(s,i),s}finalizeDraw(t,e){n(this,no).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,Fe).get(t):t;if(o){if(s&&b(this,Ii,sg).call(this,o,s),i&&b(l=qt,sf,Dy).call(l,o,i),r){const{classList:h}=o;for(const[c,u]of Object.entries(r))h.toggle(c,u)}if(a){const c=o.firstElementChild.firstElementChild;b(this,Ii,sg).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Fe).get(t);s&&(n(e,Js).append(s),n(this,Fe).delete(t),n(e,Fe).set(t,s))}remove(t){n(this,no).delete(t),n(this,Js)!==null&&(n(this,Fe).get(t).remove(),n(this,Fe).delete(t))}destroy(){f(this,Js,null);for(const t of n(this,Fe).values())t.remove();n(this,Fe).clear(),n(this,no).clear()}};Js=new WeakMap,Fe=new WeakMap,no=new WeakMap,wd=new WeakMap,sf=new WeakSet,Dy=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},Ii=new WeakSet,eg=function(){const t=qt._svgFactory.create(1,1,!0);return n(this,Js).append(t),t.setAttribute("aria-hidden",!0),t},Iy=function(t,e){const s=qt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=qt._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},sg=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},g(qt,sf),g(qt,wd,0);let Mu=qt;function Od(d){return`${(d*100).toFixed(2)}%`}var Yl,vd,Sd,Kl,Ti,Pi,Ed,nf,Ly;const Mh=class Mh{constructor(t,e,s,i){g(this,nf);g(this,Yl,[]);g(this,vd,new Map);g(this,Sd,null);g(this,Kl,0);g(this,Ti,0);g(this,Pi,0);f(this,Kl,t),f(this,Yl,e),f(this,Ti,s.rawDims.pageWidth),f(this,Pi,s.rawDims.pageHeight),f(this,Sd,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,Yl).length;e+=6){const s=b(this,nf,Ly).call(this,n(this,Yl).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var w;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,vd).get(s);if(!i)return;const r=(w=n(Mh,Ed))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),f(Mh,Ed,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=i,u=n(this,Sd).call(this),p=Math.ceil(o*u.width),m=Math.ceil(l*u.height),y=Math.floor((o+h/n(this,Ti))*u.width),A=Math.floor((l+c/n(this,Pi))*u.height);s.width=y-p,s.height=A-m;const v=s.getContext("2d");v.setTransform(...a),v.translate(-p,-m),v.drawImage(u,0,0)}),t}};Yl=new WeakMap,vd=new WeakMap,Sd=new WeakMap,Kl=new WeakMap,Ti=new WeakMap,Pi=new WeakMap,Ed=new WeakMap,nf=new WeakSet,Ly=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,Ti),(a-e)*n(this,Pi)),l=Math.hypot((s-t)*n(this,Ti),(i-e)*n(this,Pi));if(o<n(this,Kl)||l<n(this,Kl))return null;const h=[(r-t)*n(this,Ti)/o,(a-e)*n(this,Pi)/o,(s-t)*n(this,Ti)/l,(i-e)*n(this,Pi)/l,0,0],c=D.inverseTransform(h),u=document.createElement("canvas");return u.className="textLayerImagePlaceholder",u.width=0,u.height=0,Object.assign(u.style,{opacity:0,position:"absolute",left:Od(t),top:Od(e),width:Od(o/n(this,Ti)),height:Od(l/n(this,Pi)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),n(this,vd).set(u,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),u},g(Mh,Ed,null);let Du=Mh;globalThis._pdfjsTestingUtils={HighlightOutliner:Fp};globalThis.pdfjsLib={AbortException:_n,AnnotationEditorLayer:ku,AnnotationEditorParamsType:V,AnnotationEditorType:$,AnnotationEditorUIManager:Tr,AnnotationLayer:_u,AnnotationMode:wn,AnnotationType:Ht,applyOpacity:gm,build:Lb,ColorPicker:Bh,createValidAbsoluteUrl:ig,CSSConstants:pm,DOMSVGFactory:Hh,DrawLayer:Mu,FeatureTest:zt,fetchData:cf,findContrastColor:mm,getDocument:cg,getFilenameFromUrl:dm,getPdfFilenameFromUrl:um,getRGB:Zl,getRGBA:ff,getUuid:rg,getXfaPageViewport:fm,GlobalWorkerOptions:Zs,ImageKind:Ch,InvalidPDFException:wu,isDataScheme:Cd,isPdfFile:uf,isValidExplicitDest:tb,makeArr:lf,makeMap:hf,makeObj:vu,MathClamp:Et,noContextMenu:As,normalizeUnicode:cm,OPS:ki,OutputScale:si,PasswordResponses:hm,PDFDataRangeTransport:dg,PDFDateString:Rh,PDFWorker:Ql,PermissionFlag:lm,PixelsPerInch:Cn,RenderingCancelledException:df,renderRichText:og,ResponseException:Ih,setLayerDimensions:Cr,shadow:j,SignatureExtractor:Mi,stopEvent:Tt,SupportedImageMimeTypes:Su,TextLayer:ql,TextLayerImages:Du,TouchManager:Fh,updateUrlHash:ng,Util:D,VerbosityLevel:xd,version:Ib,XfaLayer:ag};const Nw=Object.freeze(Object.defineProperty({__proto__:null,AbortException:_n,AnnotationEditorLayer:ku,AnnotationEditorParamsType:V,AnnotationEditorType:$,AnnotationEditorUIManager:Tr,AnnotationLayer:_u,AnnotationMode:wn,AnnotationType:Ht,CSSConstants:pm,ColorPicker:Bh,DOMSVGFactory:Hh,DrawLayer:Mu,FeatureTest:zt,GlobalWorkerOptions:Zs,ImageKind:Ch,InvalidPDFException:wu,MathClamp:Et,OPS:ki,OutputScale:si,PDFDataRangeTransport:dg,PDFDateString:Rh,PDFWorker:Ql,PasswordResponses:hm,PermissionFlag:lm,PixelsPerInch:Cn,RenderingCancelledException:df,ResponseException:Ih,SignatureExtractor:Mi,SupportedImageMimeTypes:Su,TextLayer:ql,TextLayerImages:Du,TouchManager:Fh,Util:D,VerbosityLevel:xd,XfaLayer:ag,applyOpacity:gm,build:Lb,createValidAbsoluteUrl:ig,fetchData:cf,findContrastColor:mm,getDocument:cg,getFilenameFromUrl:dm,getPdfFilenameFromUrl:um,getRGB:Zl,getRGBA:ff,getUuid:rg,getXfaPageViewport:fm,isDataScheme:Cd,isPdfFile:uf,isValidExplicitDest:tb,makeArr:lf,makeMap:hf,makeObj:vu,noContextMenu:As,normalizeUnicode:cm,renderRichText:og,setLayerDimensions:Cr,shadow:j,stopEvent:Tt,updateUrlHash:ng,version:Ib},Symbol.toStringTag,{value:"Module"}));Zs.workerSrc="";const sm=25.4/72,Lf=8;class Ry{importFromFilePicker(t){const e=document.createElement("input");e.type="file",e.accept=".pdf",e.style.display="none",document.body.appendChild(e),e.addEventListener("change",async()=>{var r;const s=(r=e.files)==null?void 0:r[0];if(document.body.removeChild(e),!s)return;const i=await s.arrayBuffer();await this.convert(t,i)}),e.click()}async convert(t,e,s=1){try{const r=await(await cg({data:e}).promise).getPage(s),o=r.getViewport({scale:1}).height,l=await r.getOperatorList(),h=this.extractEntities(l,o);if(h.length===0){Mn.log.warn("[PdfImport] No vector paths found in PDF page.");return}const c=t.doc.database.tables.blockTable.modelSpace;for(const u of h)c.appendEntity(u);Mn.log.info(`[PdfImport] Imported ${h.length} entities from PDF.`)}catch(i){Mn.log.error("[PdfImport] Failed to import PDF:",i)}}extractEntities(t,e){const{OPS:s}=Nw,{fnArray:i,argsArray:r}=t,a=[];let o=[],l=[],h=0,c=0;const u=()=>{l.length>1&&o.push(l),l=[]},p=()=>{u();for(const A of o){const v=this.subpathToEntity(A);v&&a.push(v)}o=[]},m=(A,v)=>A*sm,y=(A,v)=>(e-v)*sm;for(let A=0;A<i.length;A++){const v=i[A],w=r[A];switch(v){case s.moveTo:{u(),h=w[0],c=w[1],l=[{x:m(h),y:y(h,c)}];break}case s.lineTo:{h=w[0],c=w[1],l.push({x:m(h),y:y(h,c)});break}case s.curveTo:{const[S,E,x,_,C,T]=w,M=Rf({x:h,y:c},{x:S,y:E},{x,y:_},{x:C,y:T},Lf);for(const k of M)l.push({x:m(k.x,k.y),y:y(k.x,k.y)});h=C,c=T;break}case s.curveTo2:{const[S,E,x,_]=w,C=Rf({x:h,y:c},{x:h,y:c},{x:S,y:E},{x,y:_},Lf);for(const T of C)l.push({x:m(T.x,T.y),y:y(T.x,T.y)});h=x,c=_;break}case s.curveTo3:{const[S,E,x,_]=w,C=Rf({x:h,y:c},{x:S,y:E},{x,y:_},{x,y:_},Lf);for(const T of C)l.push({x:m(T.x,T.y),y:y(T.x,T.y)});h=x,c=_;break}case s.closePath:{l.length>0&&o.length===0&&l.push({...l[0]}),u();break}case s.stroke:case s.fill:case s.eoFill:case s.fillStroke:case s.eoFillStroke:case s.endPath:{p();break}}}return p(),a}subpathToEntity(t){if(t.length<2)return null;if(t.length===2)return new Mn.AcDbLine(new Mn.AcGePoint3d(t[0].x,t[0].y,0),new Mn.AcGePoint3d(t[1].x,t[1].y,0));const e=new Mn.AcDbPolyline;for(let o=0;o<t.length;o++)e.addVertexAt(o,new Mn.AcGePoint2d(t[o].x,t[o].y));const s=t[0],i=t[t.length-1],r=s.x-i.x,a=s.y-i.y;return Math.sqrt(r*r+a*a)<1e-6&&(e.closed=!0),e}}function Rf(d,t,e,s,i){const r=[];for(let a=1;a<=i;a++){const o=a/i,l=1-o,h=l*l*l*d.x+3*l*l*o*t.x+3*l*o*o*e.x+o*o*o*s.x,c=l*l*l*d.y+3*l*l*o*t.y+3*l*o*o*e.y+o*o*o*s.y;r.push({x:h,y:c})}return r}class Fy extends G.AcEdCommand{async execute(t){new Ry().importFromFilePicker(t)}}const Bw="1.7.3",Hw={version:Bw};class Oy{constructor(t={}){this.name="PdfPlugin",this.version=Hw.version,this.description="PDF export (-cpdf / cpdf) and import (ipdf) commands",this.registeredCommands=[],this._disableExport=t.disableExport===!0}onLoad(t,e){const s=G.AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME;if(!this._disableExport){const i=new om;e.addCommand(s,"-cpdf","-cpdf",i),this.registeredCommands.push({group:s,name:"-cpdf"}),e.lookupGlobalCmd("cpdf")||(e.addCommand(s,"cpdf","cpdf",i),this.registeredCommands.push({group:s,name:"cpdf"}))}e.addCommand(s,"ipdf","ipdf",new Fy),this.registeredCommands.push({group:s,name:"ipdf"})}onUnload(t,e){for(const s of this.registeredCommands)e.removeCmd(s.group,s.name);this.registeredCommands=[]}}async function Uw(d={}){return new Oy(d)}exports.PDF_PLUGIN_NAME=nm.PDF_PLUGIN_NAME;exports.PDF_PLUGIN_TRIGGERS=nm.PDF_PLUGIN_TRIGGERS;exports.AcApConvertToPdfCmd=om;exports.AcApImportPdfCmd=Fy;exports.AcApPdfConvertor=am;exports.AcApPdfImportConvertor=Ry;exports.AcApPdfPlugin=Oy;exports.createPdfPlugin=Uw;exports.resolveAcApPdfExportOptions=Ao;exports.resolveViewerTextFont=rm;
@@ -8,7 +8,9 @@ import { type AcApPdfExportOptions } from './AcApPdfExportOptions';
8
8
  * their own drawable extents.
9
9
  *
10
10
  * When {@link AcApPdfExportOptions.exportLayouts} is true, every layout becomes
11
- * one PDF page. A busy indicator is shown for the duration.
11
+ * one PDF page. Stroke widths follow the drawing `LWDISPLAY` flag: on uses
12
+ * object lineweights, off emits true PDF hairlines. A busy indicator is shown
13
+ * for the duration.
12
14
  */
13
15
  export declare class AcApPdfConvertor {
14
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AcApPdfConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,8BAA8B,CAAA;AAMrC,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,wBAAwB,CAAA;AAI/B;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC3B;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB;IA2CtE;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,aAAa;CAYtB"}
1
+ {"version":3,"file":"AcApPdfConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,8BAA8B,CAAA;AAMrC,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,wBAAwB,CAAA;AAI/B;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAgB;IAC3B;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB;IA2CtE;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,aAAa;CAYtB"}
@@ -47,7 +47,9 @@ import { createViewerPdfGlyphProvider } from './AcApPdfGlyphProvider';
47
47
  * their own drawable extents.
48
48
  *
49
49
  * When {@link AcApPdfExportOptions.exportLayouts} is true, every layout becomes
50
- * one PDF page. A busy indicator is shown for the duration.
50
+ * one PDF page. Stroke widths follow the drawing `LWDISPLAY` flag: on uses
51
+ * object lineweights, off emits true PDF hairlines. A busy indicator is shown
52
+ * for the duration.
51
53
  */
52
54
  var AcApPdfConvertor = /** @class */ (function () {
53
55
  function AcApPdfConvertor() {
@@ -1 +1 @@
1
- {"version":3,"file":"AcApPdfConvertor.js","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,cAAc,EACd,QAAQ,EACR,kBAAkB,EAElB,yBAAyB,EAC1B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAErE;;;;;;;;;GASG;AACH;IAAA;IAmFA,CAAC;IAlFC;;;;;OAKG;IACG,kCAAO,GAAb;4DAAc,OAAoB,EAAE,OAAkC;;;YAAlC,wBAAA,EAAA,YAAkC;;;;wBAC9D,QAAQ,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAA;wBAErD,qBAAM,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC;;;;;4CACxC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA;4CACzB,UAAU,GAAuB;gDACrC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;gDACnD,OAAO,EAAE,EAAE,CAAC,OAAO;gDACnB,SAAS,EAAE,EAAE,CAAC,SAAS;gDACvB,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS;gDAC9B,WAAW,EAAE,kBAAkB,CAAC,QAAQ,CAAC,WAAW;gDACpD,UAAU,EAAE,MAAM;gDAClB,GAAG,EAAE,QAAQ,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;gDACjE,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;gDACnD,aAAa,EAAE,4BAA4B,EAAE;gDAC7C,QAAQ,EAAE,QAAQ,CAAC,QAAQ;6CAC5B,CAAA;4CACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;gDACjC,UAAU,CAAC,gBAAgB,GAAG,qBAAqB,CAAA;4CACrD,CAAC;4CAED,IAAI,QAAQ,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;gDAMnC,YAAY,GAChB,EAAE,CAAC,cAAc,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAA;gDAChE,IAAI,YAAY,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;oDAC5C,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gDACtD,CAAC;4CACH,CAAC;4CAEa,qBAAM,mBAAmB,CAAC,EAAE,EAAE,UAAU,CAAC,EAAA;;4CAAjD,KAAK,GAAG,SAAyC;4CACjD,YAAY,GAAG,yBAAyB,CAC5C,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAC5C,KAAK,CACN,CAAA;4CACD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;;;;iCACxC,EAAE,QAAQ,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,EAAA;;wBArC3C,SAqC2C,CAAA;;;;;KAC5C;IAED;;OAEG;IACK,wCAAa,GAArB,UAAsB,IAAkB;QACtC,IAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;QAClD,IAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC;YACrC,CAAC,EAAE,IAAI,CAAC,KAAK;YACb,CAAC,EAAE,IAAI,CAAC,MAAM;SACf,CAAC,CAAA;QACF,OAAO;YACL,GAAG,EAAE;gBACH,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;gBACrC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;aACtC;YACD,GAAG,EAAE;gBACH,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;gBACrC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;aACtC;SACF,CAAA;IACH,CAAC;IAEO,wCAAa,GAArB,UAAsB,KAAiB,EAAE,YAAoB;QAC3D,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,KAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAA;QACvE,IAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QACrC,IAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACf,IAAI,CAAC,QAAQ,GAAG,YAAY,IAAI,aAAa,CAAA;QAC7C,IAAI,CAAC,GAAG,GAAG,UAAU,CAAA;QACrB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC/B,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,CAAC,UAAU,CAAC,cAAM,OAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAxB,CAAwB,EAAE,KAAM,CAAC,CAAA;IAC3D,CAAC;IACH,uBAAC;AAAD,CAAC,AAnFD,IAmFC"}
1
+ {"version":3,"file":"AcApPdfConvertor.js","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,cAAc,EACd,QAAQ,EACR,kBAAkB,EAElB,yBAAyB,EAC1B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAErE;;;;;;;;;;;GAWG;AACH;IAAA;IAmFA,CAAC;IAlFC;;;;;OAKG;IACG,kCAAO,GAAb;4DAAc,OAAoB,EAAE,OAAkC;;;YAAlC,wBAAA,EAAA,YAAkC;;;;wBAC9D,QAAQ,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAA;wBAErD,qBAAM,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC;;;;;4CACxC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA;4CACzB,UAAU,GAAuB;gDACrC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;gDACnD,OAAO,EAAE,EAAE,CAAC,OAAO;gDACnB,SAAS,EAAE,EAAE,CAAC,SAAS;gDACvB,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS;gDAC9B,WAAW,EAAE,kBAAkB,CAAC,QAAQ,CAAC,WAAW;gDACpD,UAAU,EAAE,MAAM;gDAClB,GAAG,EAAE,QAAQ,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;gDACjE,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;gDACnD,aAAa,EAAE,4BAA4B,EAAE;gDAC7C,QAAQ,EAAE,QAAQ,CAAC,QAAQ;6CAC5B,CAAA;4CACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;gDACjC,UAAU,CAAC,gBAAgB,GAAG,qBAAqB,CAAA;4CACrD,CAAC;4CAED,IAAI,QAAQ,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;gDAMnC,YAAY,GAChB,EAAE,CAAC,cAAc,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAA;gDAChE,IAAI,YAAY,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;oDAC5C,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gDACtD,CAAC;4CACH,CAAC;4CAEa,qBAAM,mBAAmB,CAAC,EAAE,EAAE,UAAU,CAAC,EAAA;;4CAAjD,KAAK,GAAG,SAAyC;4CACjD,YAAY,GAAG,yBAAyB,CAC5C,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAC5C,KAAK,CACN,CAAA;4CACD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;;;;iCACxC,EAAE,QAAQ,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,EAAA;;wBArC3C,SAqC2C,CAAA;;;;;KAC5C;IAED;;OAEG;IACK,wCAAa,GAArB,UAAsB,IAAkB;QACtC,IAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;QAClD,IAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC;YACrC,CAAC,EAAE,IAAI,CAAC,KAAK;YACb,CAAC,EAAE,IAAI,CAAC,MAAM;SACf,CAAC,CAAA;QACF,OAAO;YACL,GAAG,EAAE;gBACH,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;gBACrC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;aACtC;YACD,GAAG,EAAE;gBACH,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;gBACrC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;aACtC;SACF,CAAA;IACH,CAAC;IAEO,wCAAa,GAArB,UAAsB,KAAiB,EAAE,YAAoB;QAC3D,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,KAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAA;QACvE,IAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QACrC,IAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACf,IAAI,CAAC,QAAQ,GAAG,YAAY,IAAI,aAAa,CAAA;QAC7C,IAAI,CAAC,GAAG,GAAG,UAAU,CAAA;QACrB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC/B,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,CAAC,UAAU,CAAC,cAAM,OAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAxB,CAAwB,EAAE,KAAM,CAAC,CAAA;IAC3D,CAAC;IACH,uBAAC;AAAD,CAAC,AAnFD,IAmFC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/cad-pdf-plugin",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -37,17 +37,19 @@
37
37
  }
38
38
  },
39
39
  "devDependencies": {
40
- "@mlightcad/data-model": "^1.14.8",
40
+ "@mlightcad/data-model": "^1.15.0",
41
+ "@mlightcad/mtext-parser": "^1.5.3",
41
42
  "pdfjs-dist": "^5.6.205",
42
- "@mlightcad/cad-simple-viewer": "1.7.1",
43
- "@mlightcad/pdf-renderer": "1.7.1",
44
- "@mlightcad/three-renderer": "1.7.1"
43
+ "@mlightcad/pdf-renderer": "1.7.3",
44
+ "@mlightcad/cad-simple-viewer": "1.7.3",
45
+ "@mlightcad/three-renderer": "1.7.3"
45
46
  },
46
47
  "peerDependencies": {
47
- "@mlightcad/data-model": "^1.14.8",
48
- "@mlightcad/pdf-renderer": "1.7.1",
49
- "@mlightcad/three-renderer": "1.7.1",
50
- "@mlightcad/cad-simple-viewer": "1.7.1"
48
+ "@mlightcad/data-model": "^1.15.0",
49
+ "@mlightcad/mtext-parser": "^1.5.3",
50
+ "@mlightcad/cad-simple-viewer": "1.7.3",
51
+ "@mlightcad/three-renderer": "1.7.3",
52
+ "@mlightcad/pdf-renderer": "1.7.3"
51
53
  },
52
54
  "scripts": {
53
55
  "clean": "rimraf dist lib tsconfig.tsbuildinfo",