revise 4.0.1 → 4.1.0

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +14 -2
  3. package/THIRD-PARTY-NOTICES.md +52 -0
  4. package/chunks/{AgentPageRenderer-CHHktDQ1.js → AgentPageRenderer-BO0UO8ti.js} +1 -1
  5. package/chunks/{AgentPageRenderer-CN-N65JC.js → AgentPageRenderer-BRSnnwix.js} +1 -1
  6. package/chunks/{AttachmentDocumentImporter-DnHC9t7I.js → AttachmentDocumentImporter-B9MxjcAh.js} +1 -1
  7. package/chunks/{AttachmentDocumentImporter-Dqg7IPtK.js → AttachmentDocumentImporter-C2cOyOT7.js} +1 -1
  8. package/chunks/{DocumentScrubber-Ch_bOtHW.js → DocumentScrubber-C1FMsdbb.js} +1 -1
  9. package/chunks/{DocumentScrubber-DRzACkWJ.js → DocumentScrubber-DV8tz9HA.js} +1 -1
  10. package/chunks/{DocxConverter-BGPkGmyg.js → DocxConverter-Bm0HkBVD.js} +1 -1
  11. package/chunks/{DocxConverter-DeurS5EF.js → DocxConverter-Cu4eNMv8.js} +1 -1
  12. package/chunks/{DocxGraft-D71OgoMh.js → DocxGraft-BVF-KvfZ.js} +1 -1
  13. package/chunks/{DocxGraft-QLkGEcwQ.js → DocxGraft-CRgF0kbP.js} +1 -1
  14. package/chunks/{FileImporter-BIT0ZBDY.js → FileImporter-BQFBpy3w.js} +1 -1
  15. package/chunks/{FileImporter-Cgwoawuk.js → FileImporter-DGLb3Sr7.js} +1 -1
  16. package/chunks/{OdtConverter-2pm0SH5c.js → OdtConverter-BBJp0He7.js} +1 -1
  17. package/chunks/{OdtConverter-CSUQTfVp.js → OdtConverter-vMtWnHmN.js} +1 -1
  18. package/chunks/{OfficeImportShared-C_mYnG5V.js → OfficeImportShared-B-G9c4l3.js} +1 -1
  19. package/chunks/{OfficeImportShared-O-d47J7O.js → OfficeImportShared-D1HPkK6E.js} +1 -1
  20. package/chunks/{PdfConverter-BYg_pr5J.js → PdfConverter-BHxQ97xQ.js} +1 -1
  21. package/chunks/{PdfConverter-Z2HlY84F.js → PdfConverter-CVg1iezA.js} +1 -1
  22. package/chunks/{PdfImportService-C2gwK1Sq.js → PdfImportService-BwPyr7mK.js} +1 -1
  23. package/chunks/{PdfImportService-CxtUtxM6.js → PdfImportService-C7Ge9he-.js} +1 -1
  24. package/chunks/{RtfConverter-BrtojpDV.js → RtfConverter-Bp4De2LK.js} +1 -1
  25. package/chunks/{RtfConverter-DlztsAoK.js → RtfConverter-CSgz-99v.js} +1 -1
  26. package/chunks/{XmlConverter-3XWISlqr.js → XmlConverter-CKtlZBRJ.js} +1 -1
  27. package/chunks/{XmlConverter-B1Kcohr0.js → XmlConverter-Ce5hiL1o.js} +1 -1
  28. package/chunks/{ar-vDYSGTpE.js → ar-DXz701oH.js} +2 -2
  29. package/chunks/{browser-module-BVdVmrPb.js → browser-module-CGEsouXc.js} +1 -1
  30. package/chunks/{browser-module-CWlRHeO2.js → browser-module-Do0GxPwC.js} +1 -1
  31. package/chunks/{de-CWX4cvtt.js → de-BNDFsx8u.js} +2 -2
  32. package/chunks/{es-DoAhvF6_.js → es-K9xXHK7j.js} +2 -2
  33. package/chunks/{fil-DdAeD8Br.js → fil-DzR-wN9l.js} +2 -2
  34. package/chunks/{fr-CazsUjNQ.js → fr-B3SqCksc.js} +2 -2
  35. package/chunks/{index-DcIXw_KB.js → index-DSAJ-J8p.js} +195 -195
  36. package/chunks/{index-D9_PwgOX.js → index-DuQIqmgC.js} +195 -195
  37. package/chunks/{ja-alh_QHTB.js → ja-u4zSoY8E.js} +2 -2
  38. package/chunks/{pseudoLocale-Bld5ZUFr.js → pseudoLocale-Cu4gNRZy.js} +1 -1
  39. package/chunks/{pseudoLocale-CLm3_c4X.js → pseudoLocale-DgJzKByn.js} +1 -1
  40. package/chunks/{zh-20eXwzFZ.js → zh-Dpo4C1RV.js} +2 -2
  41. package/cli-shim.js +1 -1
  42. package/full.js +1 -1
  43. package/index.d.ts +6 -0
  44. package/index.js +1 -1
  45. package/package.json +7 -6
  46. package/server.d.ts +40 -0
  47. package/server.js +54 -0
  48. package/style.css +1 -1
  49. package/version.js +2 -2
  50. package/legacy/server.d.ts +0 -37
  51. package/legacy/server.js +0 -41
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.1.0
4
+
5
+ ### Added
6
+
7
+ - **`licenseKey`.** Pass your commercial license key to the editor:
8
+ `<ReviseEditor licenseKey="revise-…" />`. The key is checked offline against
9
+ Revise's signature and is never sent anywhere, so it is safe to ship in a
10
+ client bundle. Without a valid key the editor works the same and logs one notice
11
+ to the browser console per page load. See
12
+ [licensing](https://revise.io/developer/docs/editor-sdk/license#license-key).
13
+ - **`revise/server`.** Server-side work imports from `revise/server`, which
14
+ re-exports [`@reviseio/cli`](https://www.npmjs.com/package/@reviseio/cli)'s
15
+ library (`ReviseDocument`, `seedYDoc`, `agentTools`, and the rest) as the
16
+ same classes and functions. Install `@reviseio/cli` at the same version; it
17
+ stays an optional peer, so a browser-only app installs nothing extra. The
18
+ 2.x server names still import from `revise/server`, and each throws a
19
+ pointer to its replacement when used.
20
+
21
+ ### Fixed
22
+
23
+ - **Page keys in a longer page.** PageUp, PageDown, Home, and End scroll the
24
+ editor only when the keystroke is the editor's: when it has focus, when the
25
+ key comes from inside it, or when the page around it cannot scroll. They no
26
+ longer scroll the editor instead of the host page, or from inside the
27
+ host's own inputs.
28
+ - **Document tabs.** The whole tab is clickable, not only its title text.
29
+
3
30
  ## 4.0.1
4
31
 
5
32
  ### Fixed
package/README.md CHANGED
@@ -34,8 +34,20 @@ Refer to the [SDK Docs](https://revise.io/developer/docs/editor-sdk) for the ful
34
34
 
35
35
  ## Use Revise Headless
36
36
 
37
- For server-side work (conversion, seeding collaboration rooms, headless edits)
38
- and the `revise` command line tool, use [`@reviseio/cli`](https://www.npmjs.com/package/@reviseio/cli).
37
+ For server-side work (conversion, seeding collaboration rooms, headless edits),
38
+ import from `revise/server` in Node. It is the library of
39
+ [`@reviseio/cli`](https://www.npmjs.com/package/@reviseio/cli) (MIT), which also
40
+ has the `revise` command line tool. Install it at the same version:
41
+
42
+ ```bash
43
+ npm i @reviseio/cli
44
+ ```
45
+
46
+ ```ts
47
+ import { ReviseDocument } from "revise/server";
48
+
49
+ const doc = await ReviseDocument.open("contract.docx");
50
+ ```
39
51
 
40
52
  ## License
41
53
 
@@ -284,6 +284,58 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
284
284
  THE SOFTWARE.
285
285
  ```
286
286
 
287
+ ## @noble/curves@2.4.0 — MIT
288
+
289
+ ```
290
+ The MIT License (MIT)
291
+
292
+ Copyright (c) 2022 Paul Miller (https://paulmillr.com)
293
+
294
+ Permission is hereby granted, free of charge, to any person obtaining a copy
295
+ of this software and associated documentation files (the “Software”), to deal
296
+ in the Software without restriction, including without limitation the rights
297
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
298
+ copies of the Software, and to permit persons to whom the Software is
299
+ furnished to do so, subject to the following conditions:
300
+
301
+ The above copyright notice and this permission notice shall be included in
302
+ all copies or substantial portions of the Software.
303
+
304
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
305
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
306
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
307
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
308
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
309
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
310
+ THE SOFTWARE.
311
+ ```
312
+
313
+ ## @noble/hashes@2.4.0 — MIT
314
+
315
+ ```
316
+ The MIT License (MIT)
317
+
318
+ Copyright (c) 2022 Paul Miller (https://paulmillr.com)
319
+
320
+ Permission is hereby granted, free of charge, to any person obtaining a copy
321
+ of this software and associated documentation files (the “Software”), to deal
322
+ in the Software without restriction, including without limitation the rights
323
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
324
+ copies of the Software, and to permit persons to whom the Software is
325
+ furnished to do so, subject to the following conditions:
326
+
327
+ The above copyright notice and this permission notice shall be included in
328
+ all copies or substantial portions of the Software.
329
+
330
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
331
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
332
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
333
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
334
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
335
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
336
+ THE SOFTWARE.
337
+ ```
338
+
287
339
  ## @radix-ui/primitive@1.1.2 — MIT
288
340
 
289
341
  ## @radix-ui/primitive@1.1.3 — MIT
@@ -1 +1 @@
1
- import*as x from"yjs";import{N as P,O as Y,S as k,Q as C,T as D,U as B,V as A,W as G,X as j,E as z,Y as Q,Z as V,_ as X,$ as Z,a0 as J,a1 as K,a2 as ee,a3 as te,a4 as oe}from"./index-DcIXw_KB.js";function $(e,t,n,i){if(Array.isArray(e)){for(const s of e)$(s,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const r of s)$(r,o,n,i);else s&&typeof s=="object"&&$(s,o,n,i)}function E(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>Q(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await E(),await E()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function L(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,s=o.relativeToPage?o.y:o.y-n.pageTop,r=`${a.blockId}:${Math.round(o.x)}:${Math.round(s)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(r)||o.width<=0||o.height<=0)continue;i.add(r);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,s,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,s),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,s)+1,Math.max(1,d-4))}}e.restore()}function se(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const q=new WeakMap;let F=0;function re(e){let t=q.get(e);return t||(F+=1,t=`session-${F}`,q.set(e,t)),t}const H=new WeakMap;let W=0;function ce(e){let t=H.get(e);return t===void 0&&(W+=1,t=W,H.set(e,t)),t}function N(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,s=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${s} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const r=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${r} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${r} with all ${s} applied ${l}`:`${r} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${s} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${r} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${r} as it stands: its ${s} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${r} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=re(e),o=e.getDocumentMutator().derivedDocumentRevision,s=e.isHistoryOpen(),r=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=r==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${N(n.liveIds)}`,...l>0?[`l${l}.${N(n.legacyIds)}`]:[]],u=r==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:r,historyOpen:s,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(r,t,s,n),key:[i,a,r,...w,t].join(":")}}function _(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const s=ue(n,t,i);if(s.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:s};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:j(g),snapshot:s}}finally{g.destroy()}}const r=new x.Doc;try{if(x.applyUpdate(r,x.encodeStateAsUpdate(n.getYDoc())),s.projectedSuggestionCount===0)return{doc:j(r),snapshot:s};const g=z.createSuggestionProjectionFromYDoc(r,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:s}}finally{g.ydoc.destroy()}}finally{r.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=V(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=X(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=Z(e.computed,o.layout.fontFamily),o.headingPageNumbers=J(e.computed),o.syntaxTheme=K(e.codeTheme||"solarized",i.isDark),ee(o,1);const s={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const r={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,r,s)}else oe(o,e.editor,e.geometry.pageIndex,s);return e.mode==="layout"&&L(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,s=Math.ceil(e.length/o),r=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:s},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*r,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,s-1)*r;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<s;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+r);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+r}return u}async function fe(e){const t=e.request.view??P;if(!Y(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=_(e.editor,t),a=C(e.themeElement),o=[],s=[];$(n,null,o,s),await ne(o,a.text);const r=e.createCanvas?.()??document.createElement("canvas");r.width=8,r.height=8;const g=r.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=B(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[se(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=s.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):A(c.src)));await Promise.all(y.flatMap(c=>c.chromeImages??[]).map(c=>A(c.src)));const O=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(O,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const U=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:U,view:t,snapshot:i}}export{_ as captureAgentPageRenderSource,L as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
1
+ import*as x from"yjs";import{N as P,O as Y,S as k,Q as C,T as D,U as B,V as A,W as G,X as j,E as z,Y as Q,Z as V,_ as X,$ as Z,a0 as J,a1 as K,a2 as ee,a3 as te,a4 as oe}from"./index-DSAJ-J8p.js";function $(e,t,n,i){if(Array.isArray(e)){for(const s of e)$(s,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const r of s)$(r,o,n,i);else s&&typeof s=="object"&&$(s,o,n,i)}function E(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>Q(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await E(),await E()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function L(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,s=o.relativeToPage?o.y:o.y-n.pageTop,r=`${a.blockId}:${Math.round(o.x)}:${Math.round(s)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(r)||o.width<=0||o.height<=0)continue;i.add(r);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,s,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,s),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,s)+1,Math.max(1,d-4))}}e.restore()}function se(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const q=new WeakMap;let F=0;function re(e){let t=q.get(e);return t||(F+=1,t=`session-${F}`,q.set(e,t)),t}const H=new WeakMap;let W=0;function ce(e){let t=H.get(e);return t===void 0&&(W+=1,t=W,H.set(e,t)),t}function N(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,s=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${s} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const r=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${r} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${r} with all ${s} applied ${l}`:`${r} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${s} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${r} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${r} as it stands: its ${s} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${r} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=re(e),o=e.getDocumentMutator().derivedDocumentRevision,s=e.isHistoryOpen(),r=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=r==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${N(n.liveIds)}`,...l>0?[`l${l}.${N(n.legacyIds)}`]:[]],u=r==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:r,historyOpen:s,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(r,t,s,n),key:[i,a,r,...w,t].join(":")}}function _(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const s=ue(n,t,i);if(s.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:s};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:j(g),snapshot:s}}finally{g.destroy()}}const r=new x.Doc;try{if(x.applyUpdate(r,x.encodeStateAsUpdate(n.getYDoc())),s.projectedSuggestionCount===0)return{doc:j(r),snapshot:s};const g=z.createSuggestionProjectionFromYDoc(r,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:s}}finally{g.ydoc.destroy()}}finally{r.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=V(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=X(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=Z(e.computed,o.layout.fontFamily),o.headingPageNumbers=J(e.computed),o.syntaxTheme=K(e.codeTheme||"solarized",i.isDark),ee(o,1);const s={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const r={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,r,s)}else oe(o,e.editor,e.geometry.pageIndex,s);return e.mode==="layout"&&L(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,s=Math.ceil(e.length/o),r=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:s},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*r,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,s-1)*r;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<s;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+r);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+r}return u}async function fe(e){const t=e.request.view??P;if(!Y(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=_(e.editor,t),a=C(e.themeElement),o=[],s=[];$(n,null,o,s),await ne(o,a.text);const r=e.createCanvas?.()??document.createElement("canvas");r.width=8,r.height=8;const g=r.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=B(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[se(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=s.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):A(c.src)));await Promise.all(y.flatMap(c=>c.chromeImages??[]).map(c=>A(c.src)));const O=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(O,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const U=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:U,view:t,snapshot:i}}export{_ as captureAgentPageRenderSource,L as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
@@ -1 +1 @@
1
- import*as x from"yjs";import{N as P,O as Y,S as k,Q as C,T as D,U as B,V as A,W as G,X as j,E as z,Y as Q,Z as V,_ as X,$ as Z,a0 as J,a1 as K,a2 as ee,a3 as te,a4 as oe}from"./index-D9_PwgOX.js";function $(e,t,n,i){if(Array.isArray(e)){for(const s of e)$(s,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const r of s)$(r,o,n,i);else s&&typeof s=="object"&&$(s,o,n,i)}function E(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>Q(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await E(),await E()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function L(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,s=o.relativeToPage?o.y:o.y-n.pageTop,r=`${a.blockId}:${Math.round(o.x)}:${Math.round(s)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(r)||o.width<=0||o.height<=0)continue;i.add(r);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,s,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,s),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,s)+1,Math.max(1,d-4))}}e.restore()}function se(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const q=new WeakMap;let F=0;function re(e){let t=q.get(e);return t||(F+=1,t=`session-${F}`,q.set(e,t)),t}const H=new WeakMap;let W=0;function ce(e){let t=H.get(e);return t===void 0&&(W+=1,t=W,H.set(e,t)),t}function N(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,s=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${s} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const r=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${r} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${r} with all ${s} applied ${l}`:`${r} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${s} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${r} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${r} as it stands: its ${s} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${r} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=re(e),o=e.getDocumentMutator().derivedDocumentRevision,s=e.isHistoryOpen(),r=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=r==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${N(n.liveIds)}`,...l>0?[`l${l}.${N(n.legacyIds)}`]:[]],u=r==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:r,historyOpen:s,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(r,t,s,n),key:[i,a,r,...w,t].join(":")}}function _(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const s=ue(n,t,i);if(s.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:s};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:j(g),snapshot:s}}finally{g.destroy()}}const r=new x.Doc;try{if(x.applyUpdate(r,x.encodeStateAsUpdate(n.getYDoc())),s.projectedSuggestionCount===0)return{doc:j(r),snapshot:s};const g=z.createSuggestionProjectionFromYDoc(r,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:s}}finally{g.ydoc.destroy()}}finally{r.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=V(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=X(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=Z(e.computed,o.layout.fontFamily),o.headingPageNumbers=J(e.computed),o.syntaxTheme=K(e.codeTheme||"solarized",i.isDark),ee(o,1);const s={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const r={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,r,s)}else oe(o,e.editor,e.geometry.pageIndex,s);return e.mode==="layout"&&L(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,s=Math.ceil(e.length/o),r=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:s},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*r,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,s-1)*r;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<s;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+r);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+r}return u}async function fe(e){const t=e.request.view??P;if(!Y(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=_(e.editor,t),a=C(e.themeElement),o=[],s=[];$(n,null,o,s),await ne(o,a.text);const r=e.createCanvas?.()??document.createElement("canvas");r.width=8,r.height=8;const g=r.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=B(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[se(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=s.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):A(c.src)));await Promise.all(y.flatMap(c=>c.chromeImages??[]).map(c=>A(c.src)));const O=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(O,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const U=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:U,view:t,snapshot:i}}export{_ as captureAgentPageRenderSource,L as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
1
+ import*as x from"yjs";import{N as P,O as Y,S as k,Q as C,T as D,U as B,V as A,W as G,X as j,E as z,Y as Q,Z as V,_ as X,$ as Z,a0 as J,a1 as K,a2 as ee,a3 as te,a4 as oe}from"./index-DuQIqmgC.js";function $(e,t,n,i){if(Array.isArray(e)){for(const s of e)$(s,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const r of s)$(r,o,n,i);else s&&typeof s=="object"&&$(s,o,n,i)}function E(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>Q(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await E(),await E()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function L(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,s=o.relativeToPage?o.y:o.y-n.pageTop,r=`${a.blockId}:${Math.round(o.x)}:${Math.round(s)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(r)||o.width<=0||o.height<=0)continue;i.add(r);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,s,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,s),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,s)+1,Math.max(1,d-4))}}e.restore()}function se(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const q=new WeakMap;let F=0;function re(e){let t=q.get(e);return t||(F+=1,t=`session-${F}`,q.set(e,t)),t}const H=new WeakMap;let W=0;function ce(e){let t=H.get(e);return t===void 0&&(W+=1,t=W,H.set(e,t)),t}function N(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,s=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${s} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const r=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${r} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${r} with all ${s} applied ${l}`:`${r} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${s} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${r} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${r} as it stands: its ${s} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${r} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=re(e),o=e.getDocumentMutator().derivedDocumentRevision,s=e.isHistoryOpen(),r=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=r==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${N(n.liveIds)}`,...l>0?[`l${l}.${N(n.legacyIds)}`]:[]],u=r==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:r,historyOpen:s,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(r,t,s,n),key:[i,a,r,...w,t].join(":")}}function _(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const s=ue(n,t,i);if(s.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:s};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:j(g),snapshot:s}}finally{g.destroy()}}const r=new x.Doc;try{if(x.applyUpdate(r,x.encodeStateAsUpdate(n.getYDoc())),s.projectedSuggestionCount===0)return{doc:j(r),snapshot:s};const g=z.createSuggestionProjectionFromYDoc(r,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:s}}finally{g.ydoc.destroy()}}finally{r.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=V(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=X(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=Z(e.computed,o.layout.fontFamily),o.headingPageNumbers=J(e.computed),o.syntaxTheme=K(e.codeTheme||"solarized",i.isDark),ee(o,1);const s={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const r={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,r,s)}else oe(o,e.editor,e.geometry.pageIndex,s);return e.mode==="layout"&&L(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,s=Math.ceil(e.length/o),r=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:s},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*r,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,s-1)*r;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<s;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+r);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+r}return u}async function fe(e){const t=e.request.view??P;if(!Y(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=_(e.editor,t),a=C(e.themeElement),o=[],s=[];$(n,null,o,s),await ne(o,a.text);const r=e.createCanvas?.()??document.createElement("canvas");r.width=8,r.height=8;const g=r.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=B(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[se(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=s.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):A(c.src)));await Promise.all(y.flatMap(c=>c.chromeImages??[]).map(c=>A(c.src)));const O=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(O,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const U=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:U,view:t,snapshot:i}}export{_ as captureAgentPageRenderSource,L as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
@@ -1 +1 @@
1
- import{a5 as h,a6 as y,a7 as D,a8 as k}from"./index-D9_PwgOX.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function b(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function x(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const c=e.getWorkingDocument(),f=c.children.length,d=h(c);if(!d&&!t&&h(e.getDocumentWithPendingSuggestionsApplied())&&(t=c.children.at(-1)?.id),!d&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!c.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await b(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-Cgwoawuk.js"),s=await a.parseFile(m),i=e.getYDoc();if(t)p=y(i,s,t);else{if(!h(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{D(i),k(i,s)}),l){const{storeDocxCarrier:g}=await import("./DocxGraft-QLkGEcwQ.js");await g(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-C2gwK1Sq.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:p??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{x as importAttachmentIntoDocument,h as isEmptyDocumentForAttachmentImport};
1
+ import{a5 as h,a6 as y,a7 as D,a8 as k}from"./index-DSAJ-J8p.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function b(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function x(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const c=e.getWorkingDocument(),f=c.children.length,d=h(c);if(!d&&!t&&h(e.getDocumentWithPendingSuggestionsApplied())&&(t=c.children.at(-1)?.id),!d&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!c.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await b(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-DGLb3Sr7.js"),s=await a.parseFile(m),i=e.getYDoc();if(t)p=y(i,s,t);else{if(!h(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{D(i),k(i,s)}),l){const{storeDocxCarrier:g}=await import("./DocxGraft-CRgF0kbP.js");await g(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-C7Ge9he-.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:p??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{x as importAttachmentIntoDocument,h as isEmptyDocumentForAttachmentImport};
@@ -1 +1 @@
1
- import{a5 as h,a6 as y,a7 as D,a8 as k}from"./index-DcIXw_KB.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function b(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function x(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const c=e.getWorkingDocument(),f=c.children.length,d=h(c);if(!d&&!t&&h(e.getDocumentWithPendingSuggestionsApplied())&&(t=c.children.at(-1)?.id),!d&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!c.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await b(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-BIT0ZBDY.js"),s=await a.parseFile(m),i=e.getYDoc();if(t)p=y(i,s,t);else{if(!h(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{D(i),k(i,s)}),l){const{storeDocxCarrier:g}=await import("./DocxGraft-D71OgoMh.js");await g(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-CxtUtxM6.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:p??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{x as importAttachmentIntoDocument,h as isEmptyDocumentForAttachmentImport};
1
+ import{a5 as h,a6 as y,a7 as D,a8 as k}from"./index-DuQIqmgC.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function b(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function x(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const c=e.getWorkingDocument(),f=c.children.length,d=h(c);if(!d&&!t&&h(e.getDocumentWithPendingSuggestionsApplied())&&(t=c.children.at(-1)?.id),!d&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!c.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await b(o);let p;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-BQFBpy3w.js"),s=await a.parseFile(m),i=e.getYDoc();if(t)p=y(i,s,t);else{if(!h(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const l=s.pendingDocxCarrier;if(delete s.pendingDocxCarrier,i.transact(()=>{D(i),k(i,s)}),l){const{storeDocxCarrier:g}=await import("./DocxGraft-BVF-KvfZ.js");await g(i,l.bytes,{hash:l.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-BwPyr7mK.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:p??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{x as importAttachmentIntoDocument,h as isEmptyDocumentForAttachmentImport};
@@ -1 +1 @@
1
- import{B as p,E as N}from"./index-DcIXw_KB.js";const i="Author",h=o=>{const n=[o.children];o.notes&&n.push(o.notes),o.chrome&&n.push(o.chrome);for(const e of[o.headers,o.footers])if(e)for(const c of Object.values(e))Array.isArray(c)&&n.push(c);return n},g=(o,n)=>{n(o);for(const e of o)e&&Array.isArray(e.children)&&g(e.children,n)},l=(o,n)=>{for(const e of h(o))g(e,c=>{for(const a of c)a?.type==="text"&&n(a)})},y=o=>{o.marks&&Object.keys(o.marks).length===0&&delete o.marks},A=o=>{const n=new Set,e=c=>{typeof c=="string"&&c.length>0&&n.add(c)};for(const c of h(o))g(c,a=>{for(const t of a){if(!t||typeof t!="object")continue;e(t.suggestionId),e(t.structuralSuggestionId);for(const s of["structuralSuggestionRecord","structuralSuggestionRecords"]){const u=t[s];if(typeof u=="string")try{const f=JSON.parse(u),m=Array.isArray(f)?f:[f];for(const d of m)e(d?.id)}catch{}}const r=t.marks;if(r&&(e(r.suggestionId),typeof r.layeredInsertion=="string"))try{e(JSON.parse(r.layeredInsertion)?.id)}catch{}}});return n},S=(o,n)=>{const e=p(o);try{const c=N.createSuggestionProjectionFromYDoc(e,n);try{const a=c.doc,t={...o,children:a.children};return a.notes?t.notes=a.notes:delete t.notes,t}finally{c.ydoc.destroy()}}finally{e.destroy()}},k=(o,n)=>{o.author&&o.author!==i&&(n.add(o.author),o.author=i),delete o.initials,delete o.authorId,delete o.authorImageUrl,o.agentName&&(n.add(o.agentName),delete o.agentName)};function v(o,n){let e=structuredClone(o);const c={commentsRemoved:0,suggestionsResolved:0,hiddenRemoved:0,authorsAnonymized:0,corePropsCleared:!1};if(n.resolveSuggestions){const a=A(e);a.size>0&&(e=S(e,n.resolveSuggestions),c.suggestionsResolved=a.size)}if(n.removeComments){const a=new Set((e.comments??[]).map(t=>t.id));l(e,t=>{if(t.marks?.comment){for(const r of t.marks.comment.split(","))r&&a.add(r);delete t.marks.comment,y(t)}}),delete e.comments,c.commentsRemoved=a.size}if(n.removeHiddenText)for(const a of h(e))g(a,t=>{const r=[];for(const s of t){if(s?.type==="text"&&s.marks?.hidden){c.hiddenRemoved+=1,s.marks.footnoteRef&&(delete s.marks.hidden,y(s),r.push(s));continue}r.push(s)}r.length!==t.length&&(t.length=0,t.push(...r))});if(n.anonymizeAuthors){const a=new Set;l(e,t=>{const r=t.marks;if(r){if(r.suggestionAuthorName&&r.suggestionAuthorName!==i&&(a.add(r.suggestionAuthorName),r.suggestionAuthorName=i),typeof r.layeredInsertion=="string")try{const s=JSON.parse(r.layeredInsertion);s&&typeof s=="object"&&s.authorName&&s.authorName!==i&&(a.add(s.authorName),s.authorName=i,r.layeredInsertion=JSON.stringify(s))}catch{}if(typeof r.docxMove=="string")try{const s=JSON.parse(r.docxMove);s&&typeof s=="object"&&s.rangeAuthor&&s.rangeAuthor!==i&&(a.add(s.rangeAuthor),s.rangeAuthor=i,r.docxMove=JSON.stringify(s))}catch{}}});for(const t of h(e))g(t,r=>{for(const s of r)for(const u of["structuralSuggestionRecord","structuralSuggestionRecords"])if(typeof s?.[u]=="string")try{const f=JSON.parse(s[u]),m=Array.isArray(f)?f:[f];for(const d of m)d&&typeof d=="object"&&typeof d.agentName=="string"&&d.agentName.length>0&&d.agentName!==i&&(a.add(d.agentName),d.agentName=i);s[u]=JSON.stringify(Array.isArray(f)?m:m[0])}catch{}});for(const t of e.comments??[])k(t,a);if(e.coreProperties)for(const t of["creator","lastModifiedBy"]){const r=e.coreProperties[t];r&&r!==i&&(a.add(r),e.coreProperties[t]=i)}c.authorsAnonymized=a.size}return n.clearCoreProperties&&(e.coreProperties&&Object.keys(e.coreProperties).length>0&&(c.corePropsCleared=!0),delete e.coreProperties),{doc:e,summary:c}}export{i as SCRUBBED_AUTHOR_NAME,v as scrubDocument};
1
+ import{B as p,E as N}from"./index-DuQIqmgC.js";const i="Author",h=o=>{const n=[o.children];o.notes&&n.push(o.notes),o.chrome&&n.push(o.chrome);for(const e of[o.headers,o.footers])if(e)for(const c of Object.values(e))Array.isArray(c)&&n.push(c);return n},g=(o,n)=>{n(o);for(const e of o)e&&Array.isArray(e.children)&&g(e.children,n)},l=(o,n)=>{for(const e of h(o))g(e,c=>{for(const a of c)a?.type==="text"&&n(a)})},y=o=>{o.marks&&Object.keys(o.marks).length===0&&delete o.marks},A=o=>{const n=new Set,e=c=>{typeof c=="string"&&c.length>0&&n.add(c)};for(const c of h(o))g(c,a=>{for(const t of a){if(!t||typeof t!="object")continue;e(t.suggestionId),e(t.structuralSuggestionId);for(const s of["structuralSuggestionRecord","structuralSuggestionRecords"]){const u=t[s];if(typeof u=="string")try{const f=JSON.parse(u),m=Array.isArray(f)?f:[f];for(const d of m)e(d?.id)}catch{}}const r=t.marks;if(r&&(e(r.suggestionId),typeof r.layeredInsertion=="string"))try{e(JSON.parse(r.layeredInsertion)?.id)}catch{}}});return n},S=(o,n)=>{const e=p(o);try{const c=N.createSuggestionProjectionFromYDoc(e,n);try{const a=c.doc,t={...o,children:a.children};return a.notes?t.notes=a.notes:delete t.notes,t}finally{c.ydoc.destroy()}}finally{e.destroy()}},k=(o,n)=>{o.author&&o.author!==i&&(n.add(o.author),o.author=i),delete o.initials,delete o.authorId,delete o.authorImageUrl,o.agentName&&(n.add(o.agentName),delete o.agentName)};function v(o,n){let e=structuredClone(o);const c={commentsRemoved:0,suggestionsResolved:0,hiddenRemoved:0,authorsAnonymized:0,corePropsCleared:!1};if(n.resolveSuggestions){const a=A(e);a.size>0&&(e=S(e,n.resolveSuggestions),c.suggestionsResolved=a.size)}if(n.removeComments){const a=new Set((e.comments??[]).map(t=>t.id));l(e,t=>{if(t.marks?.comment){for(const r of t.marks.comment.split(","))r&&a.add(r);delete t.marks.comment,y(t)}}),delete e.comments,c.commentsRemoved=a.size}if(n.removeHiddenText)for(const a of h(e))g(a,t=>{const r=[];for(const s of t){if(s?.type==="text"&&s.marks?.hidden){c.hiddenRemoved+=1,s.marks.footnoteRef&&(delete s.marks.hidden,y(s),r.push(s));continue}r.push(s)}r.length!==t.length&&(t.length=0,t.push(...r))});if(n.anonymizeAuthors){const a=new Set;l(e,t=>{const r=t.marks;if(r){if(r.suggestionAuthorName&&r.suggestionAuthorName!==i&&(a.add(r.suggestionAuthorName),r.suggestionAuthorName=i),typeof r.layeredInsertion=="string")try{const s=JSON.parse(r.layeredInsertion);s&&typeof s=="object"&&s.authorName&&s.authorName!==i&&(a.add(s.authorName),s.authorName=i,r.layeredInsertion=JSON.stringify(s))}catch{}if(typeof r.docxMove=="string")try{const s=JSON.parse(r.docxMove);s&&typeof s=="object"&&s.rangeAuthor&&s.rangeAuthor!==i&&(a.add(s.rangeAuthor),s.rangeAuthor=i,r.docxMove=JSON.stringify(s))}catch{}}});for(const t of h(e))g(t,r=>{for(const s of r)for(const u of["structuralSuggestionRecord","structuralSuggestionRecords"])if(typeof s?.[u]=="string")try{const f=JSON.parse(s[u]),m=Array.isArray(f)?f:[f];for(const d of m)d&&typeof d=="object"&&typeof d.agentName=="string"&&d.agentName.length>0&&d.agentName!==i&&(a.add(d.agentName),d.agentName=i);s[u]=JSON.stringify(Array.isArray(f)?m:m[0])}catch{}});for(const t of e.comments??[])k(t,a);if(e.coreProperties)for(const t of["creator","lastModifiedBy"]){const r=e.coreProperties[t];r&&r!==i&&(a.add(r),e.coreProperties[t]=i)}c.authorsAnonymized=a.size}return n.clearCoreProperties&&(e.coreProperties&&Object.keys(e.coreProperties).length>0&&(c.corePropsCleared=!0),delete e.coreProperties),{doc:e,summary:c}}export{i as SCRUBBED_AUTHOR_NAME,v as scrubDocument};
@@ -1 +1 @@
1
- import{B as p,E as N}from"./index-D9_PwgOX.js";const i="Author",h=o=>{const n=[o.children];o.notes&&n.push(o.notes),o.chrome&&n.push(o.chrome);for(const e of[o.headers,o.footers])if(e)for(const c of Object.values(e))Array.isArray(c)&&n.push(c);return n},g=(o,n)=>{n(o);for(const e of o)e&&Array.isArray(e.children)&&g(e.children,n)},l=(o,n)=>{for(const e of h(o))g(e,c=>{for(const a of c)a?.type==="text"&&n(a)})},y=o=>{o.marks&&Object.keys(o.marks).length===0&&delete o.marks},A=o=>{const n=new Set,e=c=>{typeof c=="string"&&c.length>0&&n.add(c)};for(const c of h(o))g(c,a=>{for(const t of a){if(!t||typeof t!="object")continue;e(t.suggestionId),e(t.structuralSuggestionId);for(const s of["structuralSuggestionRecord","structuralSuggestionRecords"]){const u=t[s];if(typeof u=="string")try{const f=JSON.parse(u),m=Array.isArray(f)?f:[f];for(const d of m)e(d?.id)}catch{}}const r=t.marks;if(r&&(e(r.suggestionId),typeof r.layeredInsertion=="string"))try{e(JSON.parse(r.layeredInsertion)?.id)}catch{}}});return n},S=(o,n)=>{const e=p(o);try{const c=N.createSuggestionProjectionFromYDoc(e,n);try{const a=c.doc,t={...o,children:a.children};return a.notes?t.notes=a.notes:delete t.notes,t}finally{c.ydoc.destroy()}}finally{e.destroy()}},k=(o,n)=>{o.author&&o.author!==i&&(n.add(o.author),o.author=i),delete o.initials,delete o.authorId,delete o.authorImageUrl,o.agentName&&(n.add(o.agentName),delete o.agentName)};function v(o,n){let e=structuredClone(o);const c={commentsRemoved:0,suggestionsResolved:0,hiddenRemoved:0,authorsAnonymized:0,corePropsCleared:!1};if(n.resolveSuggestions){const a=A(e);a.size>0&&(e=S(e,n.resolveSuggestions),c.suggestionsResolved=a.size)}if(n.removeComments){const a=new Set((e.comments??[]).map(t=>t.id));l(e,t=>{if(t.marks?.comment){for(const r of t.marks.comment.split(","))r&&a.add(r);delete t.marks.comment,y(t)}}),delete e.comments,c.commentsRemoved=a.size}if(n.removeHiddenText)for(const a of h(e))g(a,t=>{const r=[];for(const s of t){if(s?.type==="text"&&s.marks?.hidden){c.hiddenRemoved+=1,s.marks.footnoteRef&&(delete s.marks.hidden,y(s),r.push(s));continue}r.push(s)}r.length!==t.length&&(t.length=0,t.push(...r))});if(n.anonymizeAuthors){const a=new Set;l(e,t=>{const r=t.marks;if(r){if(r.suggestionAuthorName&&r.suggestionAuthorName!==i&&(a.add(r.suggestionAuthorName),r.suggestionAuthorName=i),typeof r.layeredInsertion=="string")try{const s=JSON.parse(r.layeredInsertion);s&&typeof s=="object"&&s.authorName&&s.authorName!==i&&(a.add(s.authorName),s.authorName=i,r.layeredInsertion=JSON.stringify(s))}catch{}if(typeof r.docxMove=="string")try{const s=JSON.parse(r.docxMove);s&&typeof s=="object"&&s.rangeAuthor&&s.rangeAuthor!==i&&(a.add(s.rangeAuthor),s.rangeAuthor=i,r.docxMove=JSON.stringify(s))}catch{}}});for(const t of h(e))g(t,r=>{for(const s of r)for(const u of["structuralSuggestionRecord","structuralSuggestionRecords"])if(typeof s?.[u]=="string")try{const f=JSON.parse(s[u]),m=Array.isArray(f)?f:[f];for(const d of m)d&&typeof d=="object"&&typeof d.agentName=="string"&&d.agentName.length>0&&d.agentName!==i&&(a.add(d.agentName),d.agentName=i);s[u]=JSON.stringify(Array.isArray(f)?m:m[0])}catch{}});for(const t of e.comments??[])k(t,a);if(e.coreProperties)for(const t of["creator","lastModifiedBy"]){const r=e.coreProperties[t];r&&r!==i&&(a.add(r),e.coreProperties[t]=i)}c.authorsAnonymized=a.size}return n.clearCoreProperties&&(e.coreProperties&&Object.keys(e.coreProperties).length>0&&(c.corePropsCleared=!0),delete e.coreProperties),{doc:e,summary:c}}export{i as SCRUBBED_AUTHOR_NAME,v as scrubDocument};
1
+ import{B as p,E as N}from"./index-DSAJ-J8p.js";const i="Author",h=o=>{const n=[o.children];o.notes&&n.push(o.notes),o.chrome&&n.push(o.chrome);for(const e of[o.headers,o.footers])if(e)for(const c of Object.values(e))Array.isArray(c)&&n.push(c);return n},g=(o,n)=>{n(o);for(const e of o)e&&Array.isArray(e.children)&&g(e.children,n)},l=(o,n)=>{for(const e of h(o))g(e,c=>{for(const a of c)a?.type==="text"&&n(a)})},y=o=>{o.marks&&Object.keys(o.marks).length===0&&delete o.marks},A=o=>{const n=new Set,e=c=>{typeof c=="string"&&c.length>0&&n.add(c)};for(const c of h(o))g(c,a=>{for(const t of a){if(!t||typeof t!="object")continue;e(t.suggestionId),e(t.structuralSuggestionId);for(const s of["structuralSuggestionRecord","structuralSuggestionRecords"]){const u=t[s];if(typeof u=="string")try{const f=JSON.parse(u),m=Array.isArray(f)?f:[f];for(const d of m)e(d?.id)}catch{}}const r=t.marks;if(r&&(e(r.suggestionId),typeof r.layeredInsertion=="string"))try{e(JSON.parse(r.layeredInsertion)?.id)}catch{}}});return n},S=(o,n)=>{const e=p(o);try{const c=N.createSuggestionProjectionFromYDoc(e,n);try{const a=c.doc,t={...o,children:a.children};return a.notes?t.notes=a.notes:delete t.notes,t}finally{c.ydoc.destroy()}}finally{e.destroy()}},k=(o,n)=>{o.author&&o.author!==i&&(n.add(o.author),o.author=i),delete o.initials,delete o.authorId,delete o.authorImageUrl,o.agentName&&(n.add(o.agentName),delete o.agentName)};function v(o,n){let e=structuredClone(o);const c={commentsRemoved:0,suggestionsResolved:0,hiddenRemoved:0,authorsAnonymized:0,corePropsCleared:!1};if(n.resolveSuggestions){const a=A(e);a.size>0&&(e=S(e,n.resolveSuggestions),c.suggestionsResolved=a.size)}if(n.removeComments){const a=new Set((e.comments??[]).map(t=>t.id));l(e,t=>{if(t.marks?.comment){for(const r of t.marks.comment.split(","))r&&a.add(r);delete t.marks.comment,y(t)}}),delete e.comments,c.commentsRemoved=a.size}if(n.removeHiddenText)for(const a of h(e))g(a,t=>{const r=[];for(const s of t){if(s?.type==="text"&&s.marks?.hidden){c.hiddenRemoved+=1,s.marks.footnoteRef&&(delete s.marks.hidden,y(s),r.push(s));continue}r.push(s)}r.length!==t.length&&(t.length=0,t.push(...r))});if(n.anonymizeAuthors){const a=new Set;l(e,t=>{const r=t.marks;if(r){if(r.suggestionAuthorName&&r.suggestionAuthorName!==i&&(a.add(r.suggestionAuthorName),r.suggestionAuthorName=i),typeof r.layeredInsertion=="string")try{const s=JSON.parse(r.layeredInsertion);s&&typeof s=="object"&&s.authorName&&s.authorName!==i&&(a.add(s.authorName),s.authorName=i,r.layeredInsertion=JSON.stringify(s))}catch{}if(typeof r.docxMove=="string")try{const s=JSON.parse(r.docxMove);s&&typeof s=="object"&&s.rangeAuthor&&s.rangeAuthor!==i&&(a.add(s.rangeAuthor),s.rangeAuthor=i,r.docxMove=JSON.stringify(s))}catch{}}});for(const t of h(e))g(t,r=>{for(const s of r)for(const u of["structuralSuggestionRecord","structuralSuggestionRecords"])if(typeof s?.[u]=="string")try{const f=JSON.parse(s[u]),m=Array.isArray(f)?f:[f];for(const d of m)d&&typeof d=="object"&&typeof d.agentName=="string"&&d.agentName.length>0&&d.agentName!==i&&(a.add(d.agentName),d.agentName=i);s[u]=JSON.stringify(Array.isArray(f)?m:m[0])}catch{}});for(const t of e.comments??[])k(t,a);if(e.coreProperties)for(const t of["creator","lastModifiedBy"]){const r=e.coreProperties[t];r&&r!==i&&(a.add(r),e.coreProperties[t]=i)}c.authorsAnonymized=a.size}return n.clearCoreProperties&&(e.coreProperties&&Object.keys(e.coreProperties).length>0&&(c.corePropsCleared=!0),delete e.coreProperties),{doc:e,summary:c}}export{i as SCRUBBED_AUTHOR_NAME,v as scrubDocument};
@@ -1,4 +1,4 @@
1
- import{an as Ae,ao as Ni,ap as Er,aq as Ai,c as Ti,h as Mi,ar as Dr,as as Ei,at as Di,au as Bi,av as Ee,I as Ri,aw as Li,ax as Fi,ay as Oi,K as Ft,az as Ot,aA as $i,aB as _i,R as Ct,aC as Wi,aD as tr,L as Qe,aE as Br,aF as Xi,aG as Rr,aH as zi,aI as rr,aJ as Hi,aK as Lr,aL as ji,aM as Gi,aN as Ji,u as Ui,v as Ki,G as Zi,_ as Vi,aO as Fr,aP as qi,aQ as Yi,ak as Qi,aR as en,aS as tn,aT as rn,aU as ir,aV as nn,aW as on,Q as sn,aX as an,aY as Or,aZ as ln,a_ as cn,a$ as $r,J as dn,b0 as _r,b1 as pn,m as nr,b2 as Wr,b3 as hn,b4 as gn,b5 as mn,b6 as Xr,b7 as or,b8 as un,b9 as fn}from"./index-D9_PwgOX.js";const zr=()=>new XMLSerializer,Hr=new Set(["w:rStyle","w:b","w:i","w:u","w:strike","w:dstrike","w:smallCaps","w:caps","w:vanish","w:lang","w:spacing","w:vertAlign","w:color","w:highlight","w:shd","w:rFonts","w:sz","w:rPrChange","w:bCs","w:iCs","w:szCs","w:highlightCs","w:ins","w:del","w:rtl","w:specVanish","w:imprint","w:emboss","w:snapToGrid"]),jr=new Set(["w:pStyle","w:keepNext","w:keepLines","w:widowControl","w:bidi","w:jc","w:ind","w:pageBreakBefore","w:spacing","w:contextualSpacing","w:outlineLvl","w:numPr","w:pBdr","w:shd","w:tabs","w:rPr","w:sectPr","w:pPrChange"]),Gr=new Set(["w:tblStyle","w:tblW","w:jc","w:tblInd","w:tblBorders","w:tblLayout","w:tblCellMar","w:tblPrChange"]),Jr=new Set(["w:tblHeader","w:ins","w:del","w:trPrChange"]),Ur=new Set(["w:tcW","w:gridSpan","w:vMerge","w:tcBorders","w:shd","w:tcMar","w:vAlign","w:cellIns","w:cellDel","w:cellMerge","w:tcPrChange"]),Kr=new Set(["w:pgSz","w:pgMar","w:pgNumType","w:lnNumType","w:cols","w:type","w:docGrid","w:titlePg","w:headerReference","w:footerReference","w:sectPrChange","w:rPr"]);function at(F,e){if(!F)return;let r="";const t=zr();for(let i=0;i<F.children.length;i++){const n=F.children[i];e.has(n.tagName)||(r+=t.serializeToString(n))}return r?ar(r):void 0}function sr(F){if(!F||F.attributes.length===0)return;const e={};for(let i=0;i<F.attributes.length;i++){const n=F.attributes[i];n.name==="xmlns"||n.name.startsWith("xmlns:")||(e[n.name]=n.value)}const r=Object.keys(e).sort();if(r.length===0)return;const t={};for(const i of r)t[i]=e[i];return JSON.stringify(t)}function ar(F){if(!/[\n\r\t]/.test(F))return F;let e="",r=!1,t=null;for(let i=0;i<F.length;i++){const n=F[i];if(t){n===t?(t=null,e+=n):n===`
1
+ import{an as Ae,ao as Ni,ap as Er,aq as Ai,c as Ti,h as Mi,ar as Dr,as as Ei,at as Di,au as Bi,av as Ee,I as Ri,aw as Li,ax as Fi,ay as Oi,K as Ft,az as Ot,aA as $i,aB as _i,R as Ct,aC as Wi,aD as tr,L as Qe,aE as Br,aF as Xi,aG as Rr,aH as zi,aI as rr,aJ as Hi,aK as Lr,aL as ji,aM as Gi,aN as Ji,u as Ui,v as Ki,G as Zi,_ as Vi,aO as Fr,aP as qi,aQ as Yi,ak as Qi,aR as en,aS as tn,aT as rn,aU as ir,aV as nn,aW as on,Q as sn,aX as an,aY as Or,aZ as ln,a_ as cn,a$ as $r,J as dn,b0 as _r,b1 as pn,m as nr,b2 as Wr,b3 as hn,b4 as gn,b5 as mn,b6 as Xr,b7 as or,b8 as un,b9 as fn}from"./index-DuQIqmgC.js";const zr=()=>new XMLSerializer,Hr=new Set(["w:rStyle","w:b","w:i","w:u","w:strike","w:dstrike","w:smallCaps","w:caps","w:vanish","w:lang","w:spacing","w:vertAlign","w:color","w:highlight","w:shd","w:rFonts","w:sz","w:rPrChange","w:bCs","w:iCs","w:szCs","w:highlightCs","w:ins","w:del","w:rtl","w:specVanish","w:imprint","w:emboss","w:snapToGrid"]),jr=new Set(["w:pStyle","w:keepNext","w:keepLines","w:widowControl","w:bidi","w:jc","w:ind","w:pageBreakBefore","w:spacing","w:contextualSpacing","w:outlineLvl","w:numPr","w:pBdr","w:shd","w:tabs","w:rPr","w:sectPr","w:pPrChange"]),Gr=new Set(["w:tblStyle","w:tblW","w:jc","w:tblInd","w:tblBorders","w:tblLayout","w:tblCellMar","w:tblPrChange"]),Jr=new Set(["w:tblHeader","w:ins","w:del","w:trPrChange"]),Ur=new Set(["w:tcW","w:gridSpan","w:vMerge","w:tcBorders","w:shd","w:tcMar","w:vAlign","w:cellIns","w:cellDel","w:cellMerge","w:tcPrChange"]),Kr=new Set(["w:pgSz","w:pgMar","w:pgNumType","w:lnNumType","w:cols","w:type","w:docGrid","w:titlePg","w:headerReference","w:footerReference","w:sectPrChange","w:rPr"]);function at(F,e){if(!F)return;let r="";const t=zr();for(let i=0;i<F.children.length;i++){const n=F.children[i];e.has(n.tagName)||(r+=t.serializeToString(n))}return r?ar(r):void 0}function sr(F){if(!F||F.attributes.length===0)return;const e={};for(let i=0;i<F.attributes.length;i++){const n=F.attributes[i];n.name==="xmlns"||n.name.startsWith("xmlns:")||(e[n.name]=n.value)}const r=Object.keys(e).sort();if(r.length===0)return;const t={};for(const i of r)t[i]=e[i];return JSON.stringify(t)}function ar(F){if(!/[\n\r\t]/.test(F))return F;let e="",r=!1,t=null;for(let i=0;i<F.length;i++){const n=F[i];if(t){n===t?(t=null,e+=n):n===`
2
2
  `?e+="&#10;":n==="\r"?e+="&#13;":n===" "?e+="&#9;":e+=n;continue}r&&(n==='"'||n==="'")?t=n:n==="<"?r=!0:n===">"&&(r=!1),e+=n}return e}function lr(F){const e=ar(zr().serializeToString(F));let r;const t=F.getElementsByTagName("o:OLEObject")[0];if(t)r=t.getAttribute("ProgID")??void 0;else if(F.tagName==="w:altChunk")r=F.getAttribute("r:id")??void 0;else{const i=F.getElementsByTagName("a:graphicData")[0]?.getAttribute("uri")?.split("/").filter(Boolean).pop();i&&i!=="picture"&&(r=i)}return{xml:e,tagName:F.tagName,...r?{detail:r}:{}}}function cr(F){return F.includes("http://schemas.openxmlformats.org/officeDocument/2006/relationships")}const Zr=new Set(["w:p","w:tbl","w:sdt","w:customXml","w:sectPr","w:bookmarkStart","w:bookmarkEnd","w:commentRangeStart","w:commentRangeEnd","w:moveFromRangeStart","w:moveFromRangeEnd","w:moveToRangeStart","w:moveToRangeEnd","w:permStart","w:permEnd","w:ins","w:del","w:moveFrom","w:moveTo","w:proofErr","w:tcPr","w:trPr","w:tblPr","w:tblGrid","w:tblPrEx","w:pPr"]),wn=/^[A-Za-z_][\w.-]*(?::[\w.-]+)?$/;function Vr(F,e){let r;try{r=JSON.parse(F)}catch{return""}if(r===null||typeof r!="object"||Array.isArray(r))return"";let t="";for(const[i,n]of Object.entries(r)){if(typeof n!="string"||!wn.test(i)||e?.has(i))continue;const a=n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");t+=` ${i}="${a}"`}return t}const bn=Object.freeze(Object.defineProperty({__proto__:null,KNOWN_BODY_TAGS:Zr,KNOWN_PPR_TAGS:jr,KNOWN_RPR_TAGS:Hr,KNOWN_SECTPR_TAGS:Kr,KNOWN_TBLPR_TAGS:Gr,KNOWN_TCPR_TAGS:Ur,KNOWN_TRPR_TAGS:Jr,attrsJsonToXmlAttributes:Vr,captureRawElement:lr,extractElementAttrsJson:sr,extractOpaqueChildrenXml:at,stabilizeSerializedXml:ar,xmlReferencesRelationships:cr},Symbol.toStringTag,{value:"Module"})),yn="http://schemas.openxmlformats.org/officeDocument/2006/math",qr=`<m:oMath xmlns:m="${yn}">`,vn=new Set("∑∏∐∫∬∭∮∯∰∱∲∳⋀⋁⋂⋃⨀⨁⨂⨄⨆".split("")),xn=new Set(["sin","cos","tan","cot","sec","csc","arcsin","arccos","arctan","sinh","cosh","tanh","coth","log","ln","lg","exp","det","dim","ker","deg","gcd","hom","arg","max","min","sup","inf","lim","liminf","limsup","Pr"]),Sn=new Set(["lim","liminf","limsup","max","min","sup","inf","Pr"]),Yr={"^":"̂","ˆ":"̂","̂":"̂","~":"̃","˜":"̃","̃":"̃","ˉ":"̄","¯":"̄","̄":"̄","˙":"̇","̇":"̇","¨":"̈","̈":"̈","ˊ":"́","´":"́","́":"́","ˋ":"̀","`":"̀","̀":"̀","ˇ":"̌","̌":"̌","˘":"̆","̆":"̆","→":"⃗","⃗":"⃗"},In=new Set(["‾","¯","_","―","−"]),kn=new Set(["⏞","⏟","⏜","⏝","⎴","⎵"]),Pn=new Set(["⁡","⁢","⁣","⁤"]),dr={normal:'<m:sty m:val="p"/>',bold:'<m:sty m:val="b"/>',italic:'<m:sty m:val="i"/>',"bold-italic":'<m:sty m:val="bi"/>',"double-struck":'<m:scr m:val="double-struck"/><m:sty m:val="p"/>',script:'<m:scr m:val="script"/>',"bold-script":'<m:scr m:val="script"/><m:sty m:val="b"/>',fraktur:'<m:scr m:val="fraktur"/>',"bold-fraktur":'<m:scr m:val="fraktur"/><m:sty m:val="b"/>',"sans-serif":'<m:scr m:val="sans-serif"/><m:sty m:val="p"/>',monospace:'<m:scr m:val="monospace"/><m:sty m:val="p"/>'};function Qr(F){return F.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function lt(F){return Qr(F)}function We(F){return Array.from(F.children)}function $e(F){return(F.textContent??"").replace(/[⁡-⁤]/g,"")}function xe(F){return F.localName.toLowerCase()}function pr(F){let e=F;for(;["mrow","mstyle","mpadded","semantics"].includes(xe(e))&&We(e).filter(r=>!$t(r)).length===1;)e=We(e).filter(r=>!$t(r))[0];return e}function $t(F){return xe(F)==="mo"&&Pn.has((F.textContent??"").trim())}function _t(F){if(!F)return null;const e=pr(F);if(xe(e)!=="mo")return null;const r=$e(e).trim();return vn.has(r)?r:null}function Wt(F){if(!F)return null;const e=pr(F);if(!["mi","mo"].includes(xe(e)))return null;const r=$e(e).trim();return xn.has(r)?r:null}const Cn=new Set("+-−=<>≤≥≠≈≡∼≃≅∝,;:∣∈∉⊂⊆⊃⊇→←↔⇒⇐⇔".split(""));function Nn(F){return xe(F)==="mo"&&Cn.has($e(F).trim())}function ei(F,e){let r=e;for(;r<F.length&&!Nn(F[r]);)r+=1;return r}function ti(F){return!!F&&xe(F)==="mo"&&F.getAttribute("fence")==="true"}function Je(F,e){if(!F)return"";const r=/^\s+$/.test(F)?`${F}​`:F,t=/^\s|\s$/.test(r)?' xml:space="preserve"':"";return`<m:r>${e?`<m:rPr>${e}</m:rPr>`:""}<m:t${t}>${Qr(r)}</m:t></m:r>`}function An(F,e){const r=xe(F),t=$e(F);if(!t)return"";if(r==="mtext"||r==="ms")return Je(t,"<m:nor/>");const i=F.getAttribute("mathvariant")??e.mathvariant;return i&&dr[i]?Je(t,dr[i]):r==="mi"&&[...t].length>1?Je(t,'<m:sty m:val="p"/>'):Je(t,"")}function le(F,e){return`<m:${F}>${e}</m:${F}>`}function ri(F,e,r,t,i){return`<m:nary><m:naryPr>${`<m:chr m:val="${lt(F)}"/><m:limLoc m:val="${e}"/>`+(r===null?'<m:subHide m:val="1"/>':"")+(t===null?'<m:supHide m:val="1"/>':"")}</m:naryPr>`+le("sub",r??"")+le("sup",t??"")+le("e",i)+"</m:nary>"}function ii(F,e){return`<m:func>${le("fName",F)}${le("e",e)}</m:func>`}function ni(F){return parseFloat(F.getAttribute("width")??"")>0?" ":""}function Tn(F){return xe(F)==="mrow"&&F.children.length===0&&!$e(F).trim()}function Ue(F,e){const r=F.filter(i=>!$t(i)&&!Tn(i));if(r.length>=2&&ti(r[0])){const i=r[r.length-1],n=ti(i),a=r.slice(1,n?-1:void 0),o=$e(r[0]).trim(),s=n?$e(i).trim():"";return`<m:d><m:dPr><m:begChr m:val="${lt(o)}"/><m:endChr m:val="${lt(s)}"/></m:dPr>`+le("e",Ue(a,e))+"</m:d>"}let t="";for(let i=0;i<r.length;i+=1){const n=r[i],a=xe(n),o=r[i+1];if(["msub","msup","msubsup","munder","mover","munderover"].includes(a)&&_t(We(n)[0])){const[c,p,h]=We(n),g=_t(c),f=a.startsWith("mu")?"undOvr":"subSup",w=["msub","msubsup","munder","munderover"].includes(a)?pe(p,e):null,u=a==="msubsup"||a==="munderover"?pe(h,e):a==="msup"||a==="mover"?pe(p,e):null,m=ei(r,i+1);t+=ri(g,f,w,u,Ue(r.slice(i+1,m),e)),i=m-1;continue}if(a==="mo"&&_t(n)){const c=ei(r,i+1);t+=ri(_t(n),"undOvr",null,null,Ue(r.slice(i+1,c),e)),i=c-1;continue}const s=["msub","munder"].includes(a)?Wt(We(n)[0]):null;if(s&&Sn.has(s)&&o){const[c,p]=We(n),h=`<m:limLow>${le("e",Je(Wt(c),'<m:sty m:val="p"/>'))}${le("lim",pe(p,e))}</m:limLow>`;t+=ii(h,pe(o,e)),i+=1;continue}if(Wt(n)&&o){t+=ii(Je(Wt(n),'<m:sty m:val="p"/>'),pe(o,e)),i+=1;continue}if(a==="mtext"||a==="mspace"){let c="",p=i;for(;r[p]&&["mtext","mspace"].includes(xe(r[p]));)c+=xe(r[p])==="mtext"?$e(r[p]):ni(r[p]),p+=1;i=p-1;const h=c.replace(/\s{2,}/g," ");h&&(t+=Je(h,"<m:nor/>"));continue}const l=a==="mi"?n.getAttribute("mathvariant"):null;if(l){let c=$e(n);for(;r[i+1]&&xe(r[i+1])==="mi"&&r[i+1].getAttribute("mathvariant")===l;)i+=1,c+=$e(r[i]);t+=Je(c,dr[l]??"");continue}t+=pe(n,e)}return t}function pe(F,e){if(!F)return"";const r=xe(F),t=We(F);switch(r){case"math":case"semantics":case"mrow":case"mpadded":case"merror":return Ue(t,e);case"mstyle":{const i=F.getAttribute("mathvariant");return Ue(t,i?{...e,mathvariant:i}:e)}case"annotation":case"annotation-xml":case"mphantom":case"none":case"mprescripts":return"";case"mi":case"mn":case"mo":case"mtext":case"ms":return $t(F)?"":An(F,e);case"mspace":{const i=ni(F);return i?Je(i,"<m:nor/>"):""}case"mfrac":{const i=F.getAttribute("linethickness");return`<m:f>${i!==null&&parseFloat(i)===0?'<m:fPr><m:type m:val="noBar"/></m:fPr>':""}`+le("num",pe(t[0],e))+le("den",pe(t[1],e))+"</m:f>"}case"msqrt":return'<m:rad><m:radPr><m:degHide m:val="1"/></m:radPr><m:deg/>'+le("e",Ue(t,e))+"</m:rad>";case"mroot":return"<m:rad>"+le("deg",pe(t[1],e))+le("e",pe(t[0],e))+"</m:rad>";case"msub":return`<m:sSub>${le("e",pe(t[0],e))}${le("sub",pe(t[1],e))}</m:sSub>`;case"msup":return`<m:sSup>${le("e",pe(t[0],e))}${le("sup",pe(t[1],e))}</m:sSup>`;case"msubsup":return`<m:sSubSup>${le("e",pe(t[0],e))}`+le("sub",pe(t[1],e))+le("sup",pe(t[2],e))+"</m:sSubSup>";case"mover":case"munder":return Mn(F,r==="mover"?"top":"bot",e);case"munderover":{const[i,n,a]=t,o=`<m:limLow>${le("e",pe(i,e))}${le("lim",pe(n,e))}</m:limLow>`;return`<m:limUpp>${le("e",o)}${le("lim",pe(a,e))}</m:limUpp>`}case"mtable":return"<m:m>"+t.filter(i=>["mtr","mlabeledtr"].includes(xe(i))).map(i=>"<m:mr>"+We(i).filter(n=>xe(n)==="mtd").map(n=>le("e",Ue(We(n),e))).join("")+"</m:mr>").join("")+"</m:m>";case"menclose":{const i=Ue(t,e),n=F.getAttribute("notation")??"";return/\bbox\b|roundedbox/.test(n)?`<m:borderBox>${le("e",i)}</m:borderBox>`:i}case"mfenced":{const i=F.getAttribute("open")??"(",n=F.getAttribute("close")??")";return`<m:d><m:dPr><m:begChr m:val="${lt(i)}"/><m:endChr m:val="${lt(n)}"/></m:dPr>`+t.map(a=>le("e",pe(a,e))).join("")+"</m:d>"}default:return Ue(t,e)}}function Mn(F,e,r){const[t,i]=We(F),n=pe(t,r),a=i?pr(i):void 0,o=a&&xe(a)==="mo"?$e(a).trim():"";if(o&&In.has(o))return`<m:bar><m:barPr><m:pos m:val="${e}"/></m:barPr>${le("e",n)}</m:bar>`;if(o&&kn.has(o))return`<m:groupChr><m:groupChrPr><m:chr m:val="${lt(o)}"/><m:pos m:val="${e}"/><m:vertJc m:val="${e==="top"?"bot":"top"}"/></m:groupChrPr>`+le("e",n)+"</m:groupChr>";const s=F.getAttribute(e==="top"?"accent":"accentunder")==="true";if(e==="top"&&o&&(s||Yr[o])){const c=Yr[o]??o;return`<m:acc><m:accPr><m:chr m:val="${lt(c)}"/></m:accPr>${le("e",n)}</m:acc>`}const l=e==="top"?"limUpp":"limLow";return`<m:${l}>${le("e",n)}${le("lim",pe(i,r))}</m:${l}>`}function En(F){return new DOMParser().parseFromString(F,"text/html").querySelector("math")}function Dn(F){const e=En(F);if(!e)throw new Error("mathmlToOmml: no <math> element in input");return`${qr}${pe(e,{})}</m:oMath>`}const oi="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",ue=class hr{static async parseFile(e,r){if(!e.name.toLowerCase().endsWith(".docx"))throw new Error(`DocxConverter only supports .docx files, got: ${e.name}`);return this.parseDocxFile(e,r)}static async parseDocxFile(e,r){const t=await e.arrayBuffer(),i=await Er.loadAsync(t),n=await i.file("word/document.xml")?.async("string");if(!n)return{type:"doc",children:[this.createEmptyParagraph()]};const a=this.parseDocumentXml(n);if(!a)return{type:"doc",children:[this.createEmptyParagraph()]};const o=await this.loadOOXMLPackageContext(i,n),s=await this.parseDocumentPageLayoutFromPackage(n,i,a),l=await i.file("word/fontTable.xml")?.async("string"),c=this.parseFontTableXml(l),p=await i.file("word/settings.xml")?.async("string"),h=!!(p&&/<w:autoHyphenation(?![^>]*w:val="(?:0|false)")[^>]*\/?>/.test(p)),g=r?.retainSource?new Map:void 0,f=await this.parseStructuredDocxDocument(n,s,o,a,g),w=await i.file("docProps/custom.xml")?.async("string");if(w){const T=this.parseDocumentXml(w),O=(T&&Array.from(T.getElementsByTagNameNS("*","property")).find(X=>X.getAttribute("name")==="Revise.BlockSpacingPx"))?.textContent?.trim(),W=O?Number(O):NaN;Number.isFinite(W)&&W>=0&&W<=192&&(f.pageLayout={...f.pageLayout??{},blockSpacingPx:W})}h&&(f.pageLayout={...f.pageLayout??{},hyphenationEnabled:!0}),c&&(f.fontSubstitutes=c,Ai(c));const u=await i.file("word/footnotes.xml")?.async("string"),m=await i.file("word/endnotes.xml")?.async("string"),b=new Map;u&&await this.collectNotesFromXml(f,u,"w:footnote","docxfn","footnote",b,o),m&&await this.collectNotesFromXml(f,m,"w:endnote","docxen","endnote",b,o),this.finalizeImportedFootnoteRefs(f,b);const v=await i.file("word/comments.xml")?.async("string");if(v){const T=await i.file("word/commentsExtended.xml")?.async("string");this.attachCommentsFromXml(f,v,T,o)}await this.attachHeadersFootersFromPackage(f,n,i,o,a);const y=await i.file("docProps/core.xml")?.async("string");if(y){const T=this.parseCoreProperties(y);T&&(f.coreProperties=T)}return g&&Ti(f,g,await Mi(new Uint8Array(t))),f}static parseCoreProperties(e){const r=this.parseDocumentXml(e);if(!r)return;const t=new Set(this.CORE_PROPERTY_LOCAL_NAMES),i={},n=r.documentElement;for(let a=0;a<n.children.length;a++){const o=n.children[a],s=o.tagName.split(":").pop()??o.tagName;if(!t.has(s))continue;const l=o.textContent??"";l.trim().length!==0&&(i[s]=l)}return Object.keys(i).length>0?i:void 0}static readHeaderFooterReferences(e,r){const t={};for(let i=0;i<e.children.length;i++){const n=e.children[i];if(n.tagName!==r)continue;const a=n.getAttribute("w:type")??"default",o=a==="first"||a==="even"?a:"default",s=n.getAttribute("r:id")??n.getAttribute("relationships:id");s&&(t[o]=s)}return t}static resolveSectionHeaderFooterReferences(e){const r=[];for(let t=0;t<e.length;t++){const i=r[t-1]??{header:{},footer:{}};r.push({header:{...i.header,...this.readHeaderFooterReferences(e[t],"w:headerReference")},footer:{...i.footer,...this.readHeaderFooterReferences(e[t],"w:footerReference")}})}return r}static async attachHeadersFootersFromPackage(e,r,t,i,n){const a=(n??this.parseDocumentXml(r))?.getElementsByTagName("w:body")[0];if(!a)return;const o=this.findAllSectionProperties(a);if(o.length===0)return;const s=this.resolveSectionHeaderFooterReferences(o),l=o.length-1,c=s[l],p=new Map,h=async O=>{const W=p.get(O);if(W)return W;const X={paragraphs:[],images:[]},D=i?.relationships.get(O);if(D){const M=D.target.startsWith("word/")?D.target:`word/${D.target.replace(/^\//,"")}`,L=await t.file(M)?.async("string");if(L){const I=M.split("/").pop()??M,B=await t.file(`word/_rels/${I}.rels`)?.async("string");if(X.paragraphs=await this.parseHeaderFooterPart(L,B?this.parseRelationshipsXml(B,M):void 0),!e.watermark){const E=this.parseVmlWatermark(L);E&&(e.watermark=E)}X.images=await this.parseHeaderFooterImages(L,M,t,i)}}return p.set(O,X),X},g=async O=>(await h(O)).paragraphs,f=["default","first","even"],w=[],u=async(O,W)=>{const X={};for(const D of f){const M=O[D];if(!M)continue;const L=await h(M);L.paragraphs.length>0&&(X[D]=L.paragraphs);for(const I of L.images)w.push({side:W,slot:D,...I})}return Object.keys(X).length>0?X:void 0},m=await u(c.header,"header"),b=await u(c.footer,"footer");m&&(e.headers=m),b&&(e.footers=b),w.length>0&&(e.chromeImages=w);const v=[];for(let O=0;O<l;O++)for(const W of["header","footer"])for(const X of f){const D=s[O][W][X],M=c[W][X];if(D===M)continue;const L=D?await g(D):[];v.push(Dr(W,X,L.length>0?Ei(L):void 0,void 0,O))}const y=[],T=new Set(v.map(O=>`${O.side}/${O.slot}/${O.sectionIndex}`));for(let O=0;O<o.length;O++)if(o[O].getElementsByTagName("w:titlePg").length!==0)for(const W of["header","footer"]){const X=s[O][W].first;if((X?await g(X):[]).length>0||!s[O][W].default)continue;const D=O===l?void 0:O;T.has(`${W}/first/${D}`)||y.push(Dr(W,"first",void 0,void 0,D))}(v.length>0||y.length>0)&&(e.chrome=[...Di(e.headers,e.footers),...v,...y])}static parseVmlWatermark(e){if(!e.includes("v:textpath"))return;const r=this.parseDocumentXml(e);if(!r)return;const t=r.getElementsByTagName("v:textpath");for(let i=0;i<t.length;i++){const n=t[i],a=(n.getAttribute("string")??"").trim();if(!a)continue;let o=n.parentNode;for(;o&&o.tagName!=="v:shape";)o=o.parentNode;const s=(o?.getAttribute("style")??"").match(/rotation:\s*(-?\d+(?:\.\d+)?)/),l=s?(parseFloat(s[1])%360+360)%360:0,c=this.vmlFillColorToHex(o?.getAttribute("fillcolor")??"");let p;const h=o?.getElementsByTagName("v:fill")[0]?.getAttribute("opacity");if(h){const w=h.endsWith("f")?parseFloat(h)/65536:parseFloat(h);Number.isFinite(w)&&w>0&&w<=1&&(p=Math.abs(w-Fr)<.05?void 0:w)}const g=(n.getAttribute("style")??"").match(/font-size:\s*(\d+(?:\.\d+)?)pt/),f=g?parseFloat(g[1]):void 0;return Bi({text:a,...c?{color:c}:{},...p!==void 0?{opacity:p}:{},diagonal:l!==0,...f&&f>2?{fontSizePx:Math.round(f*(4/3))}:{}})}}static vmlFillColorToHex(e){const r=e.trim().toLowerCase();if(r){if(r.startsWith("#")){const t=r.slice(1,7);return/^[0-9a-f]{6}$/.test(t)?`#${t.toUpperCase()}`:void 0}return{silver:"#C0C0C0",gray:"#808080",grey:"#808080",black:"#000000",red:"#FF0000",blue:"#0000FF",green:"#008000",white:"#FFFFFF"}[r]}}static async parseHeaderFooterImages(e,r,t,i){if(!i||!e.includes("w:drawing"))return[];const n=this.parseDocumentXml(e);if(!n)return[];const a=n.getElementsByTagName("w:drawing");if(a.length===0)return[];const o=r.split("/").pop()??r,s=await t.file(`word/_rels/${o}.rels`)?.async("string"),l={...i,relationships:this.parseRelationshipsXml(s,r)},c=[];for(let p=0;p<a.length;p++){const h=await this.parseImageFromDrawing(a[p],void 0,l);if(h){const g=this.headerFooterImageAlign(a[p]);c.push({src:h.src,width:h.width,height:h.height,...h.alt?{alt:h.alt}:{},...g?{align:g}:{}})}}return c}static headerFooterImageAlign(e){let r=e.parentElement;for(;r&&r.tagName!=="w:p";)r=r.parentElement;if(!r)return;const t=Array.from(r.children).find(n=>n.tagName==="w:pPr"),i=(t?Array.from(t.children).find(n=>n.tagName==="w:jc"):void 0)?.getAttribute("w:val");if(i==="center")return"center";if(i==="right"||i==="end")return"right"}static async parseHeaderFooterPart(e,r){const t=this.parseDocumentXml(e);if(!t)return[];const i=[],n=Array.from(t.getElementsByTagName("w:p")).filter(a=>{let o=a.parentElement;for(;o;){if(o.tagName==="w:txbxContent")return!1;o=o.parentElement}return!0});for(let a=0;a<n.length;a++){const o=n[a],s=[];let l=null,c=!1;const p=m=>{const b={},v=this.getDirectChild(m,"w:rPr");v&&(this.applyRunPropertiesFromElement(b,v),(this.getDirectChild(v,"w:rStyle")?.getAttribute("w:val")||void 0)===this.CODE_INLINE_STYLE_ID&&(b.code=!0,/courier/i.test(b.fontFamily??"")&&delete b.fontFamily,/^(light)?gray$/i.test(b.backgroundColor??"")&&delete b.backgroundColor));let y=m.parentElement;for(;y&&y!==o;){if(y.tagName==="w:ins"||y.tagName==="w:del"){const O=y.tagName==="w:ins",W=this.parseTrackedRevisionMeta(y);Object.assign(b,{...O?{insertion:!0}:{deletion:!0},suggestionId:W.revisionId?`docxrev-${W.revisionId}`:this.generateId(),...this.revisionAuthorIdentity(W.author),suggestionLabel:O?"Insert":"Delete",...W.createdAt!==void 0?{suggestionCreatedAt:W.createdAt}:{},...W.author?{suggestionAuthorName:W.author}:{}});break}y=y.parentElement}let T=m.parentElement;for(;T&&T!==o;){if(T.tagName==="w:hyperlink"){const O=T.getAttribute("r:id"),W=T.getAttribute("w:anchor"),X=O?r?.get(O)?.target:void 0;X?b.link=X:W&&(b.link=`#${W}`);break}T=T.parentElement}return b},h=Array.from(o.getElementsByTagName("w:r")).filter(m=>{let b=m.parentElement;for(;b&&b!==o;){if(b.tagName==="w:p")return!1;b=b.parentElement}return b===o});for(let m=0;m<h.length;m++){const b=h[m],v=p(b);for(let y=0;y<b.children.length;y++){const T=b.children[y];if(T.tagName==="w:t"||T.tagName==="w:delText"){if(c)continue;const O=T.textContent??"";O&&s.push({type:"text",text:O,...Object.keys(v).length>0?{marks:v}:{}})}else if(T.tagName==="w:tab")s.push({type:"text",text:" "});else if(T.tagName==="w:br"&&!c&&(T.getAttribute("w:type")??"textWrapping")==="textWrapping")s.push({type:"text",text:`
3
3
  `,...Object.keys(v).length>0?{marks:v}:{}});else if(T.tagName==="w:fldChar"){const O=T.getAttribute("w:fldCharType");O==="begin"&&(c=!0),O==="end"&&(l&&s.push({type:"text",text:"1",marks:{...v,field:l}}),l=null,c=!1)}else if(T.tagName==="w:instrText"&&c){const O=(T.textContent??"").trim().toUpperCase();O.startsWith("PAGE")?l="page":O.startsWith("NUMPAGES")&&(l="numPages")}}}const g=o.getElementsByTagName("w:fldSimple");for(let m=0;m<g.length;m++){const b=(g[m].getAttribute("w:instr")??"").trim().toUpperCase();b.startsWith("PAGE")?s.push({type:"text",text:"1",marks:{field:"page"}}):b.startsWith("NUMPAGES")&&s.push({type:"text",text:"1",marks:{field:"numPages"}})}const f=this.getDirectChild(this.getDirectChild(o,"w:pPr")??o,"w:jc")?.getAttribute("w:val"),w=f==="center"?"center":f==="right"||f==="end"?"right":f==="both"?"justify":void 0;s.length>0&&i.push({type:"paragraph",id:this.generateId(),children:s,...w?{align:w}:{}});const u=await this.parseTextBoxContent(o,void 0);i.push(...u.filter(m=>m.type==="paragraph"))}return i}static attachCommentsFromXml(e,r,t,i){const n=this.parseDocumentXml(r);if(!n)return;const a=new Set,o=u=>{if(!u||typeof u!="object")return;if(Array.isArray(u)){u.forEach(o);return}const m=u;m.marks?.comment&&m.marks.comment.split(",").forEach(b=>a.add(b)),o(m.children)};o(e.children);const s=(i??this.fallbackCommentState).collapsedCommentAnchorBlockById;s?.forEach((u,m)=>a.add(`docxcmt-${m}`));const l=new Map;if(t){const u=this.parseDocumentXml(t)?.getElementsByTagName("w15:commentEx")??[];for(let m=0;m<u.length;m++){const b=u[m],v=b.getAttribute("w15:paraId");v&&l.set(v,{done:b.getAttribute("w15:done")==="1",parentParaId:b.getAttribute("w15:paraIdParent")??void 0})}}const c=[],p=new Map,h=new Map,g=n.getElementsByTagName("w:comment");for(let u=0;u<g.length;u++){const m=g[u],b=m.getAttribute("w:id");if(!b)continue;const v=`docxcmt-${b}`,y=m.getElementsByTagName("w:p"),T=[];for(let D=0;D<y.length;D++){const M=y[D].getElementsByTagName("w:t");let L="";for(let B=0;B<M.length;B++)L+=M[B].textContent??"";T.push(L);const I=y[D].getAttribute("w14:paraId");I&&(p.set(v,I),h.set(I,v))}const O=m.getAttribute("w:date"),W=O?Date.parse(O):NaN,X=s?.get(b);c.push({id:v,author:m.getAttribute("w:author")??"Unknown",...m.getAttribute("w:initials")?{initials:m.getAttribute("w:initials")}:{},createdAt:Number.isFinite(W)?new Date(W).toISOString():new Date(0).toISOString(),bodyMd:T.filter(D=>D.length>0).join(`
4
4
 
@@ -1,4 +1,4 @@
1
- import{an as Ae,ao as Ni,ap as Er,aq as Ai,c as Ti,h as Mi,ar as Dr,as as Ei,at as Di,au as Bi,av as Ee,I as Ri,aw as Li,ax as Fi,ay as Oi,K as Ft,az as Ot,aA as $i,aB as _i,R as Ct,aC as Wi,aD as tr,L as Qe,aE as Br,aF as Xi,aG as Rr,aH as zi,aI as rr,aJ as Hi,aK as Lr,aL as ji,aM as Gi,aN as Ji,u as Ui,v as Ki,G as Zi,_ as Vi,aO as Fr,aP as qi,aQ as Yi,ak as Qi,aR as en,aS as tn,aT as rn,aU as ir,aV as nn,aW as on,Q as sn,aX as an,aY as Or,aZ as ln,a_ as cn,a$ as $r,J as dn,b0 as _r,b1 as pn,m as nr,b2 as Wr,b3 as hn,b4 as gn,b5 as mn,b6 as Xr,b7 as or,b8 as un,b9 as fn}from"./index-DcIXw_KB.js";const zr=()=>new XMLSerializer,Hr=new Set(["w:rStyle","w:b","w:i","w:u","w:strike","w:dstrike","w:smallCaps","w:caps","w:vanish","w:lang","w:spacing","w:vertAlign","w:color","w:highlight","w:shd","w:rFonts","w:sz","w:rPrChange","w:bCs","w:iCs","w:szCs","w:highlightCs","w:ins","w:del","w:rtl","w:specVanish","w:imprint","w:emboss","w:snapToGrid"]),jr=new Set(["w:pStyle","w:keepNext","w:keepLines","w:widowControl","w:bidi","w:jc","w:ind","w:pageBreakBefore","w:spacing","w:contextualSpacing","w:outlineLvl","w:numPr","w:pBdr","w:shd","w:tabs","w:rPr","w:sectPr","w:pPrChange"]),Gr=new Set(["w:tblStyle","w:tblW","w:jc","w:tblInd","w:tblBorders","w:tblLayout","w:tblCellMar","w:tblPrChange"]),Jr=new Set(["w:tblHeader","w:ins","w:del","w:trPrChange"]),Ur=new Set(["w:tcW","w:gridSpan","w:vMerge","w:tcBorders","w:shd","w:tcMar","w:vAlign","w:cellIns","w:cellDel","w:cellMerge","w:tcPrChange"]),Kr=new Set(["w:pgSz","w:pgMar","w:pgNumType","w:lnNumType","w:cols","w:type","w:docGrid","w:titlePg","w:headerReference","w:footerReference","w:sectPrChange","w:rPr"]);function at(F,e){if(!F)return;let r="";const t=zr();for(let i=0;i<F.children.length;i++){const n=F.children[i];e.has(n.tagName)||(r+=t.serializeToString(n))}return r?ar(r):void 0}function sr(F){if(!F||F.attributes.length===0)return;const e={};for(let i=0;i<F.attributes.length;i++){const n=F.attributes[i];n.name==="xmlns"||n.name.startsWith("xmlns:")||(e[n.name]=n.value)}const r=Object.keys(e).sort();if(r.length===0)return;const t={};for(const i of r)t[i]=e[i];return JSON.stringify(t)}function ar(F){if(!/[\n\r\t]/.test(F))return F;let e="",r=!1,t=null;for(let i=0;i<F.length;i++){const n=F[i];if(t){n===t?(t=null,e+=n):n===`
1
+ import{an as Ae,ao as Ni,ap as Er,aq as Ai,c as Ti,h as Mi,ar as Dr,as as Ei,at as Di,au as Bi,av as Ee,I as Ri,aw as Li,ax as Fi,ay as Oi,K as Ft,az as Ot,aA as $i,aB as _i,R as Ct,aC as Wi,aD as tr,L as Qe,aE as Br,aF as Xi,aG as Rr,aH as zi,aI as rr,aJ as Hi,aK as Lr,aL as ji,aM as Gi,aN as Ji,u as Ui,v as Ki,G as Zi,_ as Vi,aO as Fr,aP as qi,aQ as Yi,ak as Qi,aR as en,aS as tn,aT as rn,aU as ir,aV as nn,aW as on,Q as sn,aX as an,aY as Or,aZ as ln,a_ as cn,a$ as $r,J as dn,b0 as _r,b1 as pn,m as nr,b2 as Wr,b3 as hn,b4 as gn,b5 as mn,b6 as Xr,b7 as or,b8 as un,b9 as fn}from"./index-DSAJ-J8p.js";const zr=()=>new XMLSerializer,Hr=new Set(["w:rStyle","w:b","w:i","w:u","w:strike","w:dstrike","w:smallCaps","w:caps","w:vanish","w:lang","w:spacing","w:vertAlign","w:color","w:highlight","w:shd","w:rFonts","w:sz","w:rPrChange","w:bCs","w:iCs","w:szCs","w:highlightCs","w:ins","w:del","w:rtl","w:specVanish","w:imprint","w:emboss","w:snapToGrid"]),jr=new Set(["w:pStyle","w:keepNext","w:keepLines","w:widowControl","w:bidi","w:jc","w:ind","w:pageBreakBefore","w:spacing","w:contextualSpacing","w:outlineLvl","w:numPr","w:pBdr","w:shd","w:tabs","w:rPr","w:sectPr","w:pPrChange"]),Gr=new Set(["w:tblStyle","w:tblW","w:jc","w:tblInd","w:tblBorders","w:tblLayout","w:tblCellMar","w:tblPrChange"]),Jr=new Set(["w:tblHeader","w:ins","w:del","w:trPrChange"]),Ur=new Set(["w:tcW","w:gridSpan","w:vMerge","w:tcBorders","w:shd","w:tcMar","w:vAlign","w:cellIns","w:cellDel","w:cellMerge","w:tcPrChange"]),Kr=new Set(["w:pgSz","w:pgMar","w:pgNumType","w:lnNumType","w:cols","w:type","w:docGrid","w:titlePg","w:headerReference","w:footerReference","w:sectPrChange","w:rPr"]);function at(F,e){if(!F)return;let r="";const t=zr();for(let i=0;i<F.children.length;i++){const n=F.children[i];e.has(n.tagName)||(r+=t.serializeToString(n))}return r?ar(r):void 0}function sr(F){if(!F||F.attributes.length===0)return;const e={};for(let i=0;i<F.attributes.length;i++){const n=F.attributes[i];n.name==="xmlns"||n.name.startsWith("xmlns:")||(e[n.name]=n.value)}const r=Object.keys(e).sort();if(r.length===0)return;const t={};for(const i of r)t[i]=e[i];return JSON.stringify(t)}function ar(F){if(!/[\n\r\t]/.test(F))return F;let e="",r=!1,t=null;for(let i=0;i<F.length;i++){const n=F[i];if(t){n===t?(t=null,e+=n):n===`
2
2
  `?e+="&#10;":n==="\r"?e+="&#13;":n===" "?e+="&#9;":e+=n;continue}r&&(n==='"'||n==="'")?t=n:n==="<"?r=!0:n===">"&&(r=!1),e+=n}return e}function lr(F){const e=ar(zr().serializeToString(F));let r;const t=F.getElementsByTagName("o:OLEObject")[0];if(t)r=t.getAttribute("ProgID")??void 0;else if(F.tagName==="w:altChunk")r=F.getAttribute("r:id")??void 0;else{const i=F.getElementsByTagName("a:graphicData")[0]?.getAttribute("uri")?.split("/").filter(Boolean).pop();i&&i!=="picture"&&(r=i)}return{xml:e,tagName:F.tagName,...r?{detail:r}:{}}}function cr(F){return F.includes("http://schemas.openxmlformats.org/officeDocument/2006/relationships")}const Zr=new Set(["w:p","w:tbl","w:sdt","w:customXml","w:sectPr","w:bookmarkStart","w:bookmarkEnd","w:commentRangeStart","w:commentRangeEnd","w:moveFromRangeStart","w:moveFromRangeEnd","w:moveToRangeStart","w:moveToRangeEnd","w:permStart","w:permEnd","w:ins","w:del","w:moveFrom","w:moveTo","w:proofErr","w:tcPr","w:trPr","w:tblPr","w:tblGrid","w:tblPrEx","w:pPr"]),wn=/^[A-Za-z_][\w.-]*(?::[\w.-]+)?$/;function Vr(F,e){let r;try{r=JSON.parse(F)}catch{return""}if(r===null||typeof r!="object"||Array.isArray(r))return"";let t="";for(const[i,n]of Object.entries(r)){if(typeof n!="string"||!wn.test(i)||e?.has(i))continue;const a=n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");t+=` ${i}="${a}"`}return t}const bn=Object.freeze(Object.defineProperty({__proto__:null,KNOWN_BODY_TAGS:Zr,KNOWN_PPR_TAGS:jr,KNOWN_RPR_TAGS:Hr,KNOWN_SECTPR_TAGS:Kr,KNOWN_TBLPR_TAGS:Gr,KNOWN_TCPR_TAGS:Ur,KNOWN_TRPR_TAGS:Jr,attrsJsonToXmlAttributes:Vr,captureRawElement:lr,extractElementAttrsJson:sr,extractOpaqueChildrenXml:at,stabilizeSerializedXml:ar,xmlReferencesRelationships:cr},Symbol.toStringTag,{value:"Module"})),yn="http://schemas.openxmlformats.org/officeDocument/2006/math",qr=`<m:oMath xmlns:m="${yn}">`,vn=new Set("∑∏∐∫∬∭∮∯∰∱∲∳⋀⋁⋂⋃⨀⨁⨂⨄⨆".split("")),xn=new Set(["sin","cos","tan","cot","sec","csc","arcsin","arccos","arctan","sinh","cosh","tanh","coth","log","ln","lg","exp","det","dim","ker","deg","gcd","hom","arg","max","min","sup","inf","lim","liminf","limsup","Pr"]),Sn=new Set(["lim","liminf","limsup","max","min","sup","inf","Pr"]),Yr={"^":"̂","ˆ":"̂","̂":"̂","~":"̃","˜":"̃","̃":"̃","ˉ":"̄","¯":"̄","̄":"̄","˙":"̇","̇":"̇","¨":"̈","̈":"̈","ˊ":"́","´":"́","́":"́","ˋ":"̀","`":"̀","̀":"̀","ˇ":"̌","̌":"̌","˘":"̆","̆":"̆","→":"⃗","⃗":"⃗"},In=new Set(["‾","¯","_","―","−"]),kn=new Set(["⏞","⏟","⏜","⏝","⎴","⎵"]),Pn=new Set(["⁡","⁢","⁣","⁤"]),dr={normal:'<m:sty m:val="p"/>',bold:'<m:sty m:val="b"/>',italic:'<m:sty m:val="i"/>',"bold-italic":'<m:sty m:val="bi"/>',"double-struck":'<m:scr m:val="double-struck"/><m:sty m:val="p"/>',script:'<m:scr m:val="script"/>',"bold-script":'<m:scr m:val="script"/><m:sty m:val="b"/>',fraktur:'<m:scr m:val="fraktur"/>',"bold-fraktur":'<m:scr m:val="fraktur"/><m:sty m:val="b"/>',"sans-serif":'<m:scr m:val="sans-serif"/><m:sty m:val="p"/>',monospace:'<m:scr m:val="monospace"/><m:sty m:val="p"/>'};function Qr(F){return F.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function lt(F){return Qr(F)}function We(F){return Array.from(F.children)}function $e(F){return(F.textContent??"").replace(/[⁡-⁤]/g,"")}function xe(F){return F.localName.toLowerCase()}function pr(F){let e=F;for(;["mrow","mstyle","mpadded","semantics"].includes(xe(e))&&We(e).filter(r=>!$t(r)).length===1;)e=We(e).filter(r=>!$t(r))[0];return e}function $t(F){return xe(F)==="mo"&&Pn.has((F.textContent??"").trim())}function _t(F){if(!F)return null;const e=pr(F);if(xe(e)!=="mo")return null;const r=$e(e).trim();return vn.has(r)?r:null}function Wt(F){if(!F)return null;const e=pr(F);if(!["mi","mo"].includes(xe(e)))return null;const r=$e(e).trim();return xn.has(r)?r:null}const Cn=new Set("+-−=<>≤≥≠≈≡∼≃≅∝,;:∣∈∉⊂⊆⊃⊇→←↔⇒⇐⇔".split(""));function Nn(F){return xe(F)==="mo"&&Cn.has($e(F).trim())}function ei(F,e){let r=e;for(;r<F.length&&!Nn(F[r]);)r+=1;return r}function ti(F){return!!F&&xe(F)==="mo"&&F.getAttribute("fence")==="true"}function Je(F,e){if(!F)return"";const r=/^\s+$/.test(F)?`${F}​`:F,t=/^\s|\s$/.test(r)?' xml:space="preserve"':"";return`<m:r>${e?`<m:rPr>${e}</m:rPr>`:""}<m:t${t}>${Qr(r)}</m:t></m:r>`}function An(F,e){const r=xe(F),t=$e(F);if(!t)return"";if(r==="mtext"||r==="ms")return Je(t,"<m:nor/>");const i=F.getAttribute("mathvariant")??e.mathvariant;return i&&dr[i]?Je(t,dr[i]):r==="mi"&&[...t].length>1?Je(t,'<m:sty m:val="p"/>'):Je(t,"")}function le(F,e){return`<m:${F}>${e}</m:${F}>`}function ri(F,e,r,t,i){return`<m:nary><m:naryPr>${`<m:chr m:val="${lt(F)}"/><m:limLoc m:val="${e}"/>`+(r===null?'<m:subHide m:val="1"/>':"")+(t===null?'<m:supHide m:val="1"/>':"")}</m:naryPr>`+le("sub",r??"")+le("sup",t??"")+le("e",i)+"</m:nary>"}function ii(F,e){return`<m:func>${le("fName",F)}${le("e",e)}</m:func>`}function ni(F){return parseFloat(F.getAttribute("width")??"")>0?" ":""}function Tn(F){return xe(F)==="mrow"&&F.children.length===0&&!$e(F).trim()}function Ue(F,e){const r=F.filter(i=>!$t(i)&&!Tn(i));if(r.length>=2&&ti(r[0])){const i=r[r.length-1],n=ti(i),a=r.slice(1,n?-1:void 0),o=$e(r[0]).trim(),s=n?$e(i).trim():"";return`<m:d><m:dPr><m:begChr m:val="${lt(o)}"/><m:endChr m:val="${lt(s)}"/></m:dPr>`+le("e",Ue(a,e))+"</m:d>"}let t="";for(let i=0;i<r.length;i+=1){const n=r[i],a=xe(n),o=r[i+1];if(["msub","msup","msubsup","munder","mover","munderover"].includes(a)&&_t(We(n)[0])){const[c,p,h]=We(n),g=_t(c),f=a.startsWith("mu")?"undOvr":"subSup",w=["msub","msubsup","munder","munderover"].includes(a)?pe(p,e):null,u=a==="msubsup"||a==="munderover"?pe(h,e):a==="msup"||a==="mover"?pe(p,e):null,m=ei(r,i+1);t+=ri(g,f,w,u,Ue(r.slice(i+1,m),e)),i=m-1;continue}if(a==="mo"&&_t(n)){const c=ei(r,i+1);t+=ri(_t(n),"undOvr",null,null,Ue(r.slice(i+1,c),e)),i=c-1;continue}const s=["msub","munder"].includes(a)?Wt(We(n)[0]):null;if(s&&Sn.has(s)&&o){const[c,p]=We(n),h=`<m:limLow>${le("e",Je(Wt(c),'<m:sty m:val="p"/>'))}${le("lim",pe(p,e))}</m:limLow>`;t+=ii(h,pe(o,e)),i+=1;continue}if(Wt(n)&&o){t+=ii(Je(Wt(n),'<m:sty m:val="p"/>'),pe(o,e)),i+=1;continue}if(a==="mtext"||a==="mspace"){let c="",p=i;for(;r[p]&&["mtext","mspace"].includes(xe(r[p]));)c+=xe(r[p])==="mtext"?$e(r[p]):ni(r[p]),p+=1;i=p-1;const h=c.replace(/\s{2,}/g," ");h&&(t+=Je(h,"<m:nor/>"));continue}const l=a==="mi"?n.getAttribute("mathvariant"):null;if(l){let c=$e(n);for(;r[i+1]&&xe(r[i+1])==="mi"&&r[i+1].getAttribute("mathvariant")===l;)i+=1,c+=$e(r[i]);t+=Je(c,dr[l]??"");continue}t+=pe(n,e)}return t}function pe(F,e){if(!F)return"";const r=xe(F),t=We(F);switch(r){case"math":case"semantics":case"mrow":case"mpadded":case"merror":return Ue(t,e);case"mstyle":{const i=F.getAttribute("mathvariant");return Ue(t,i?{...e,mathvariant:i}:e)}case"annotation":case"annotation-xml":case"mphantom":case"none":case"mprescripts":return"";case"mi":case"mn":case"mo":case"mtext":case"ms":return $t(F)?"":An(F,e);case"mspace":{const i=ni(F);return i?Je(i,"<m:nor/>"):""}case"mfrac":{const i=F.getAttribute("linethickness");return`<m:f>${i!==null&&parseFloat(i)===0?'<m:fPr><m:type m:val="noBar"/></m:fPr>':""}`+le("num",pe(t[0],e))+le("den",pe(t[1],e))+"</m:f>"}case"msqrt":return'<m:rad><m:radPr><m:degHide m:val="1"/></m:radPr><m:deg/>'+le("e",Ue(t,e))+"</m:rad>";case"mroot":return"<m:rad>"+le("deg",pe(t[1],e))+le("e",pe(t[0],e))+"</m:rad>";case"msub":return`<m:sSub>${le("e",pe(t[0],e))}${le("sub",pe(t[1],e))}</m:sSub>`;case"msup":return`<m:sSup>${le("e",pe(t[0],e))}${le("sup",pe(t[1],e))}</m:sSup>`;case"msubsup":return`<m:sSubSup>${le("e",pe(t[0],e))}`+le("sub",pe(t[1],e))+le("sup",pe(t[2],e))+"</m:sSubSup>";case"mover":case"munder":return Mn(F,r==="mover"?"top":"bot",e);case"munderover":{const[i,n,a]=t,o=`<m:limLow>${le("e",pe(i,e))}${le("lim",pe(n,e))}</m:limLow>`;return`<m:limUpp>${le("e",o)}${le("lim",pe(a,e))}</m:limUpp>`}case"mtable":return"<m:m>"+t.filter(i=>["mtr","mlabeledtr"].includes(xe(i))).map(i=>"<m:mr>"+We(i).filter(n=>xe(n)==="mtd").map(n=>le("e",Ue(We(n),e))).join("")+"</m:mr>").join("")+"</m:m>";case"menclose":{const i=Ue(t,e),n=F.getAttribute("notation")??"";return/\bbox\b|roundedbox/.test(n)?`<m:borderBox>${le("e",i)}</m:borderBox>`:i}case"mfenced":{const i=F.getAttribute("open")??"(",n=F.getAttribute("close")??")";return`<m:d><m:dPr><m:begChr m:val="${lt(i)}"/><m:endChr m:val="${lt(n)}"/></m:dPr>`+t.map(a=>le("e",pe(a,e))).join("")+"</m:d>"}default:return Ue(t,e)}}function Mn(F,e,r){const[t,i]=We(F),n=pe(t,r),a=i?pr(i):void 0,o=a&&xe(a)==="mo"?$e(a).trim():"";if(o&&In.has(o))return`<m:bar><m:barPr><m:pos m:val="${e}"/></m:barPr>${le("e",n)}</m:bar>`;if(o&&kn.has(o))return`<m:groupChr><m:groupChrPr><m:chr m:val="${lt(o)}"/><m:pos m:val="${e}"/><m:vertJc m:val="${e==="top"?"bot":"top"}"/></m:groupChrPr>`+le("e",n)+"</m:groupChr>";const s=F.getAttribute(e==="top"?"accent":"accentunder")==="true";if(e==="top"&&o&&(s||Yr[o])){const c=Yr[o]??o;return`<m:acc><m:accPr><m:chr m:val="${lt(c)}"/></m:accPr>${le("e",n)}</m:acc>`}const l=e==="top"?"limUpp":"limLow";return`<m:${l}>${le("e",n)}${le("lim",pe(i,r))}</m:${l}>`}function En(F){return new DOMParser().parseFromString(F,"text/html").querySelector("math")}function Dn(F){const e=En(F);if(!e)throw new Error("mathmlToOmml: no <math> element in input");return`${qr}${pe(e,{})}</m:oMath>`}const oi="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",ue=class hr{static async parseFile(e,r){if(!e.name.toLowerCase().endsWith(".docx"))throw new Error(`DocxConverter only supports .docx files, got: ${e.name}`);return this.parseDocxFile(e,r)}static async parseDocxFile(e,r){const t=await e.arrayBuffer(),i=await Er.loadAsync(t),n=await i.file("word/document.xml")?.async("string");if(!n)return{type:"doc",children:[this.createEmptyParagraph()]};const a=this.parseDocumentXml(n);if(!a)return{type:"doc",children:[this.createEmptyParagraph()]};const o=await this.loadOOXMLPackageContext(i,n),s=await this.parseDocumentPageLayoutFromPackage(n,i,a),l=await i.file("word/fontTable.xml")?.async("string"),c=this.parseFontTableXml(l),p=await i.file("word/settings.xml")?.async("string"),h=!!(p&&/<w:autoHyphenation(?![^>]*w:val="(?:0|false)")[^>]*\/?>/.test(p)),g=r?.retainSource?new Map:void 0,f=await this.parseStructuredDocxDocument(n,s,o,a,g),w=await i.file("docProps/custom.xml")?.async("string");if(w){const T=this.parseDocumentXml(w),O=(T&&Array.from(T.getElementsByTagNameNS("*","property")).find(X=>X.getAttribute("name")==="Revise.BlockSpacingPx"))?.textContent?.trim(),W=O?Number(O):NaN;Number.isFinite(W)&&W>=0&&W<=192&&(f.pageLayout={...f.pageLayout??{},blockSpacingPx:W})}h&&(f.pageLayout={...f.pageLayout??{},hyphenationEnabled:!0}),c&&(f.fontSubstitutes=c,Ai(c));const u=await i.file("word/footnotes.xml")?.async("string"),m=await i.file("word/endnotes.xml")?.async("string"),b=new Map;u&&await this.collectNotesFromXml(f,u,"w:footnote","docxfn","footnote",b,o),m&&await this.collectNotesFromXml(f,m,"w:endnote","docxen","endnote",b,o),this.finalizeImportedFootnoteRefs(f,b);const v=await i.file("word/comments.xml")?.async("string");if(v){const T=await i.file("word/commentsExtended.xml")?.async("string");this.attachCommentsFromXml(f,v,T,o)}await this.attachHeadersFootersFromPackage(f,n,i,o,a);const y=await i.file("docProps/core.xml")?.async("string");if(y){const T=this.parseCoreProperties(y);T&&(f.coreProperties=T)}return g&&Ti(f,g,await Mi(new Uint8Array(t))),f}static parseCoreProperties(e){const r=this.parseDocumentXml(e);if(!r)return;const t=new Set(this.CORE_PROPERTY_LOCAL_NAMES),i={},n=r.documentElement;for(let a=0;a<n.children.length;a++){const o=n.children[a],s=o.tagName.split(":").pop()??o.tagName;if(!t.has(s))continue;const l=o.textContent??"";l.trim().length!==0&&(i[s]=l)}return Object.keys(i).length>0?i:void 0}static readHeaderFooterReferences(e,r){const t={};for(let i=0;i<e.children.length;i++){const n=e.children[i];if(n.tagName!==r)continue;const a=n.getAttribute("w:type")??"default",o=a==="first"||a==="even"?a:"default",s=n.getAttribute("r:id")??n.getAttribute("relationships:id");s&&(t[o]=s)}return t}static resolveSectionHeaderFooterReferences(e){const r=[];for(let t=0;t<e.length;t++){const i=r[t-1]??{header:{},footer:{}};r.push({header:{...i.header,...this.readHeaderFooterReferences(e[t],"w:headerReference")},footer:{...i.footer,...this.readHeaderFooterReferences(e[t],"w:footerReference")}})}return r}static async attachHeadersFootersFromPackage(e,r,t,i,n){const a=(n??this.parseDocumentXml(r))?.getElementsByTagName("w:body")[0];if(!a)return;const o=this.findAllSectionProperties(a);if(o.length===0)return;const s=this.resolveSectionHeaderFooterReferences(o),l=o.length-1,c=s[l],p=new Map,h=async O=>{const W=p.get(O);if(W)return W;const X={paragraphs:[],images:[]},D=i?.relationships.get(O);if(D){const M=D.target.startsWith("word/")?D.target:`word/${D.target.replace(/^\//,"")}`,L=await t.file(M)?.async("string");if(L){const I=M.split("/").pop()??M,B=await t.file(`word/_rels/${I}.rels`)?.async("string");if(X.paragraphs=await this.parseHeaderFooterPart(L,B?this.parseRelationshipsXml(B,M):void 0),!e.watermark){const E=this.parseVmlWatermark(L);E&&(e.watermark=E)}X.images=await this.parseHeaderFooterImages(L,M,t,i)}}return p.set(O,X),X},g=async O=>(await h(O)).paragraphs,f=["default","first","even"],w=[],u=async(O,W)=>{const X={};for(const D of f){const M=O[D];if(!M)continue;const L=await h(M);L.paragraphs.length>0&&(X[D]=L.paragraphs);for(const I of L.images)w.push({side:W,slot:D,...I})}return Object.keys(X).length>0?X:void 0},m=await u(c.header,"header"),b=await u(c.footer,"footer");m&&(e.headers=m),b&&(e.footers=b),w.length>0&&(e.chromeImages=w);const v=[];for(let O=0;O<l;O++)for(const W of["header","footer"])for(const X of f){const D=s[O][W][X],M=c[W][X];if(D===M)continue;const L=D?await g(D):[];v.push(Dr(W,X,L.length>0?Ei(L):void 0,void 0,O))}const y=[],T=new Set(v.map(O=>`${O.side}/${O.slot}/${O.sectionIndex}`));for(let O=0;O<o.length;O++)if(o[O].getElementsByTagName("w:titlePg").length!==0)for(const W of["header","footer"]){const X=s[O][W].first;if((X?await g(X):[]).length>0||!s[O][W].default)continue;const D=O===l?void 0:O;T.has(`${W}/first/${D}`)||y.push(Dr(W,"first",void 0,void 0,D))}(v.length>0||y.length>0)&&(e.chrome=[...Di(e.headers,e.footers),...v,...y])}static parseVmlWatermark(e){if(!e.includes("v:textpath"))return;const r=this.parseDocumentXml(e);if(!r)return;const t=r.getElementsByTagName("v:textpath");for(let i=0;i<t.length;i++){const n=t[i],a=(n.getAttribute("string")??"").trim();if(!a)continue;let o=n.parentNode;for(;o&&o.tagName!=="v:shape";)o=o.parentNode;const s=(o?.getAttribute("style")??"").match(/rotation:\s*(-?\d+(?:\.\d+)?)/),l=s?(parseFloat(s[1])%360+360)%360:0,c=this.vmlFillColorToHex(o?.getAttribute("fillcolor")??"");let p;const h=o?.getElementsByTagName("v:fill")[0]?.getAttribute("opacity");if(h){const w=h.endsWith("f")?parseFloat(h)/65536:parseFloat(h);Number.isFinite(w)&&w>0&&w<=1&&(p=Math.abs(w-Fr)<.05?void 0:w)}const g=(n.getAttribute("style")??"").match(/font-size:\s*(\d+(?:\.\d+)?)pt/),f=g?parseFloat(g[1]):void 0;return Bi({text:a,...c?{color:c}:{},...p!==void 0?{opacity:p}:{},diagonal:l!==0,...f&&f>2?{fontSizePx:Math.round(f*(4/3))}:{}})}}static vmlFillColorToHex(e){const r=e.trim().toLowerCase();if(r){if(r.startsWith("#")){const t=r.slice(1,7);return/^[0-9a-f]{6}$/.test(t)?`#${t.toUpperCase()}`:void 0}return{silver:"#C0C0C0",gray:"#808080",grey:"#808080",black:"#000000",red:"#FF0000",blue:"#0000FF",green:"#008000",white:"#FFFFFF"}[r]}}static async parseHeaderFooterImages(e,r,t,i){if(!i||!e.includes("w:drawing"))return[];const n=this.parseDocumentXml(e);if(!n)return[];const a=n.getElementsByTagName("w:drawing");if(a.length===0)return[];const o=r.split("/").pop()??r,s=await t.file(`word/_rels/${o}.rels`)?.async("string"),l={...i,relationships:this.parseRelationshipsXml(s,r)},c=[];for(let p=0;p<a.length;p++){const h=await this.parseImageFromDrawing(a[p],void 0,l);if(h){const g=this.headerFooterImageAlign(a[p]);c.push({src:h.src,width:h.width,height:h.height,...h.alt?{alt:h.alt}:{},...g?{align:g}:{}})}}return c}static headerFooterImageAlign(e){let r=e.parentElement;for(;r&&r.tagName!=="w:p";)r=r.parentElement;if(!r)return;const t=Array.from(r.children).find(n=>n.tagName==="w:pPr"),i=(t?Array.from(t.children).find(n=>n.tagName==="w:jc"):void 0)?.getAttribute("w:val");if(i==="center")return"center";if(i==="right"||i==="end")return"right"}static async parseHeaderFooterPart(e,r){const t=this.parseDocumentXml(e);if(!t)return[];const i=[],n=Array.from(t.getElementsByTagName("w:p")).filter(a=>{let o=a.parentElement;for(;o;){if(o.tagName==="w:txbxContent")return!1;o=o.parentElement}return!0});for(let a=0;a<n.length;a++){const o=n[a],s=[];let l=null,c=!1;const p=m=>{const b={},v=this.getDirectChild(m,"w:rPr");v&&(this.applyRunPropertiesFromElement(b,v),(this.getDirectChild(v,"w:rStyle")?.getAttribute("w:val")||void 0)===this.CODE_INLINE_STYLE_ID&&(b.code=!0,/courier/i.test(b.fontFamily??"")&&delete b.fontFamily,/^(light)?gray$/i.test(b.backgroundColor??"")&&delete b.backgroundColor));let y=m.parentElement;for(;y&&y!==o;){if(y.tagName==="w:ins"||y.tagName==="w:del"){const O=y.tagName==="w:ins",W=this.parseTrackedRevisionMeta(y);Object.assign(b,{...O?{insertion:!0}:{deletion:!0},suggestionId:W.revisionId?`docxrev-${W.revisionId}`:this.generateId(),...this.revisionAuthorIdentity(W.author),suggestionLabel:O?"Insert":"Delete",...W.createdAt!==void 0?{suggestionCreatedAt:W.createdAt}:{},...W.author?{suggestionAuthorName:W.author}:{}});break}y=y.parentElement}let T=m.parentElement;for(;T&&T!==o;){if(T.tagName==="w:hyperlink"){const O=T.getAttribute("r:id"),W=T.getAttribute("w:anchor"),X=O?r?.get(O)?.target:void 0;X?b.link=X:W&&(b.link=`#${W}`);break}T=T.parentElement}return b},h=Array.from(o.getElementsByTagName("w:r")).filter(m=>{let b=m.parentElement;for(;b&&b!==o;){if(b.tagName==="w:p")return!1;b=b.parentElement}return b===o});for(let m=0;m<h.length;m++){const b=h[m],v=p(b);for(let y=0;y<b.children.length;y++){const T=b.children[y];if(T.tagName==="w:t"||T.tagName==="w:delText"){if(c)continue;const O=T.textContent??"";O&&s.push({type:"text",text:O,...Object.keys(v).length>0?{marks:v}:{}})}else if(T.tagName==="w:tab")s.push({type:"text",text:" "});else if(T.tagName==="w:br"&&!c&&(T.getAttribute("w:type")??"textWrapping")==="textWrapping")s.push({type:"text",text:`
3
3
  `,...Object.keys(v).length>0?{marks:v}:{}});else if(T.tagName==="w:fldChar"){const O=T.getAttribute("w:fldCharType");O==="begin"&&(c=!0),O==="end"&&(l&&s.push({type:"text",text:"1",marks:{...v,field:l}}),l=null,c=!1)}else if(T.tagName==="w:instrText"&&c){const O=(T.textContent??"").trim().toUpperCase();O.startsWith("PAGE")?l="page":O.startsWith("NUMPAGES")&&(l="numPages")}}}const g=o.getElementsByTagName("w:fldSimple");for(let m=0;m<g.length;m++){const b=(g[m].getAttribute("w:instr")??"").trim().toUpperCase();b.startsWith("PAGE")?s.push({type:"text",text:"1",marks:{field:"page"}}):b.startsWith("NUMPAGES")&&s.push({type:"text",text:"1",marks:{field:"numPages"}})}const f=this.getDirectChild(this.getDirectChild(o,"w:pPr")??o,"w:jc")?.getAttribute("w:val"),w=f==="center"?"center":f==="right"||f==="end"?"right":f==="both"?"justify":void 0;s.length>0&&i.push({type:"paragraph",id:this.generateId(),children:s,...w?{align:w}:{}});const u=await this.parseTextBoxContent(o,void 0);i.push(...u.filter(m=>m.type==="paragraph"))}return i}static attachCommentsFromXml(e,r,t,i){const n=this.parseDocumentXml(r);if(!n)return;const a=new Set,o=u=>{if(!u||typeof u!="object")return;if(Array.isArray(u)){u.forEach(o);return}const m=u;m.marks?.comment&&m.marks.comment.split(",").forEach(b=>a.add(b)),o(m.children)};o(e.children);const s=(i??this.fallbackCommentState).collapsedCommentAnchorBlockById;s?.forEach((u,m)=>a.add(`docxcmt-${m}`));const l=new Map;if(t){const u=this.parseDocumentXml(t)?.getElementsByTagName("w15:commentEx")??[];for(let m=0;m<u.length;m++){const b=u[m],v=b.getAttribute("w15:paraId");v&&l.set(v,{done:b.getAttribute("w15:done")==="1",parentParaId:b.getAttribute("w15:paraIdParent")??void 0})}}const c=[],p=new Map,h=new Map,g=n.getElementsByTagName("w:comment");for(let u=0;u<g.length;u++){const m=g[u],b=m.getAttribute("w:id");if(!b)continue;const v=`docxcmt-${b}`,y=m.getElementsByTagName("w:p"),T=[];for(let D=0;D<y.length;D++){const M=y[D].getElementsByTagName("w:t");let L="";for(let B=0;B<M.length;B++)L+=M[B].textContent??"";T.push(L);const I=y[D].getAttribute("w14:paraId");I&&(p.set(v,I),h.set(I,v))}const O=m.getAttribute("w:date"),W=O?Date.parse(O):NaN,X=s?.get(b);c.push({id:v,author:m.getAttribute("w:author")??"Unknown",...m.getAttribute("w:initials")?{initials:m.getAttribute("w:initials")}:{},createdAt:Number.isFinite(W)?new Date(W).toISOString():new Date(0).toISOString(),bodyMd:T.filter(D=>D.length>0).join(`
4
4
 
@@ -1 +1 @@
1
- import{z as a,C as s,D as r,G as e,v as t,a as o,b as i,d as n,l as c,c as u,g,i as S,A as l,k as R,y as p,u as E,h as C,x as f,m,n as x,p as y,t as A,q as D,r as _,e as b,s as d,o as h,w as k,f as G}from"./index-DcIXw_KB.js";export{a as CARRIER_MAP_KEY,s as CURRENT_GRAFT_SIGNATURE_VERSION,r as DEFAULT_CARRIER_BYTE_CAP,e as GraftProofError,t as assessGraftability,o as blockCanonical,i as blockSignature,n as bodySidecarsSignature,c as canonicalizeForSignature,u as captureDocxSource,g as chromeSignature,S as commentsSignature,l as computeSourceFidelity,R as corePropertiesSignature,p as getDocxCarrierMeta,E as graftExport,C as hashBytes,f as loadDocxCarrier,m as markBlockSource,x as notesSignature,y as pageLayoutSignature,A as partHeadSignature,D as partSignature,_ as refreshDocxSourceSignatures,b as settingsSignature,d as signatureDigest,h as stableStringify,k as storeDocxCarrier,G as stylesSignature};
1
+ import{z as a,C as s,D as r,G as e,v as t,a as o,b as i,d as n,l as c,c as u,g,i as S,A as l,k as R,y as p,u as E,h as C,x as f,m,n as x,p as y,t as A,q as D,r as _,e as b,s as d,o as h,w as k,f as G}from"./index-DuQIqmgC.js";export{a as CARRIER_MAP_KEY,s as CURRENT_GRAFT_SIGNATURE_VERSION,r as DEFAULT_CARRIER_BYTE_CAP,e as GraftProofError,t as assessGraftability,o as blockCanonical,i as blockSignature,n as bodySidecarsSignature,c as canonicalizeForSignature,u as captureDocxSource,g as chromeSignature,S as commentsSignature,l as computeSourceFidelity,R as corePropertiesSignature,p as getDocxCarrierMeta,E as graftExport,C as hashBytes,f as loadDocxCarrier,m as markBlockSource,x as notesSignature,y as pageLayoutSignature,A as partHeadSignature,D as partSignature,_ as refreshDocxSourceSignatures,b as settingsSignature,d as signatureDigest,h as stableStringify,k as storeDocxCarrier,G as stylesSignature};
@@ -1 +1 @@
1
- import{z as a,C as s,D as r,G as e,v as t,a as o,b as i,d as n,l as c,c as u,g,i as S,A as l,k as R,y as p,u as E,h as C,x as f,m,n as x,p as y,t as A,q as D,r as _,e as b,s as d,o as h,w as k,f as G}from"./index-D9_PwgOX.js";export{a as CARRIER_MAP_KEY,s as CURRENT_GRAFT_SIGNATURE_VERSION,r as DEFAULT_CARRIER_BYTE_CAP,e as GraftProofError,t as assessGraftability,o as blockCanonical,i as blockSignature,n as bodySidecarsSignature,c as canonicalizeForSignature,u as captureDocxSource,g as chromeSignature,S as commentsSignature,l as computeSourceFidelity,R as corePropertiesSignature,p as getDocxCarrierMeta,E as graftExport,C as hashBytes,f as loadDocxCarrier,m as markBlockSource,x as notesSignature,y as pageLayoutSignature,A as partHeadSignature,D as partSignature,_ as refreshDocxSourceSignatures,b as settingsSignature,d as signatureDigest,h as stableStringify,k as storeDocxCarrier,G as stylesSignature};
1
+ import{z as a,C as s,D as r,G as e,v as t,a as o,b as i,d as n,l as c,c as u,g,i as S,A as l,k as R,y as p,u as E,h as C,x as f,m,n as x,p as y,t as A,q as D,r as _,e as b,s as d,o as h,w as k,f as G}from"./index-DSAJ-J8p.js";export{a as CARRIER_MAP_KEY,s as CURRENT_GRAFT_SIGNATURE_VERSION,r as DEFAULT_CARRIER_BYTE_CAP,e as GraftProofError,t as assessGraftability,o as blockCanonical,i as blockSignature,n as bodySidecarsSignature,c as canonicalizeForSignature,u as captureDocxSource,g as chromeSignature,S as commentsSignature,l as computeSourceFidelity,R as corePropertiesSignature,p as getDocxCarrierMeta,E as graftExport,C as hashBytes,f as loadDocxCarrier,m as markBlockSource,x as notesSignature,y as pageLayoutSignature,A as partHeadSignature,D as partSignature,_ as refreshDocxSourceSignatures,b as settingsSignature,d as signatureDigest,h as stableStringify,k as storeDocxCarrier,G as stylesSignature};
@@ -1 +1 @@
1
- import{aa as c,ab as m,ac as o,ad as d,ae as s,af as f,ag as u}from"./index-DcIXw_KB.js";class l{static async parseFile(r){const t=r.name.toLowerCase(),e=c(t);if(e?.import){const a=await m(new Uint8Array(await r.arrayBuffer()),r.name,e.id,r.type);if(e.id!=="docx"&&e.id!=="odt"&&e.id!=="rtf")return o(a);const{persistInlineDocumentImages:n}=await import("./persistInlineDocumentImages-DQj2iaqg.js");await n(a);const i=o(a);if(i.docxSource){const{refreshDocxSourceSignatures:p}=await import("./DocxGraft-D71OgoMh.js");p(i)}return i}else throw t.endsWith(".pdf")?new Error("PDF files are imported via the AI import flow, not FileImporter."):d(t)?new Error("Image files are imported via the AI import flow, not FileImporter."):new Error(`Unsupported file type: ${r.name}. Supported formats: ${s.join(", ")}`)}static getSupportedExtensions(){return[...s]}static getAcceptString(){return f}static isSupported(r){return u(r)}}export{l as FileImporter};
1
+ import{aa as c,ab as m,ac as o,ad as d,ae as s,af as f,ag as u}from"./index-DuQIqmgC.js";class l{static async parseFile(r){const t=r.name.toLowerCase(),e=c(t);if(e?.import){const a=await m(new Uint8Array(await r.arrayBuffer()),r.name,e.id,r.type);if(e.id!=="docx"&&e.id!=="odt"&&e.id!=="rtf")return o(a);const{persistInlineDocumentImages:n}=await import("./persistInlineDocumentImages-DQj2iaqg.js");await n(a);const i=o(a);if(i.docxSource){const{refreshDocxSourceSignatures:p}=await import("./DocxGraft-BVF-KvfZ.js");p(i)}return i}else throw t.endsWith(".pdf")?new Error("PDF files are imported via the AI import flow, not FileImporter."):d(t)?new Error("Image files are imported via the AI import flow, not FileImporter."):new Error(`Unsupported file type: ${r.name}. Supported formats: ${s.join(", ")}`)}static getSupportedExtensions(){return[...s]}static getAcceptString(){return f}static isSupported(r){return u(r)}}export{l as FileImporter};
@@ -1 +1 @@
1
- import{aa as c,ab as m,ac as o,ad as d,ae as s,af as f,ag as u}from"./index-D9_PwgOX.js";class l{static async parseFile(r){const t=r.name.toLowerCase(),e=c(t);if(e?.import){const a=await m(new Uint8Array(await r.arrayBuffer()),r.name,e.id,r.type);if(e.id!=="docx"&&e.id!=="odt"&&e.id!=="rtf")return o(a);const{persistInlineDocumentImages:n}=await import("./persistInlineDocumentImages-DQj2iaqg.js");await n(a);const i=o(a);if(i.docxSource){const{refreshDocxSourceSignatures:p}=await import("./DocxGraft-QLkGEcwQ.js");p(i)}return i}else throw t.endsWith(".pdf")?new Error("PDF files are imported via the AI import flow, not FileImporter."):d(t)?new Error("Image files are imported via the AI import flow, not FileImporter."):new Error(`Unsupported file type: ${r.name}. Supported formats: ${s.join(", ")}`)}static getSupportedExtensions(){return[...s]}static getAcceptString(){return f}static isSupported(r){return u(r)}}export{l as FileImporter};
1
+ import{aa as c,ab as m,ac as o,ad as d,ae as s,af as f,ag as u}from"./index-DSAJ-J8p.js";class l{static async parseFile(r){const t=r.name.toLowerCase(),e=c(t);if(e?.import){const a=await m(new Uint8Array(await r.arrayBuffer()),r.name,e.id,r.type);if(e.id!=="docx"&&e.id!=="odt"&&e.id!=="rtf")return o(a);const{persistInlineDocumentImages:n}=await import("./persistInlineDocumentImages-DQj2iaqg.js");await n(a);const i=o(a);if(i.docxSource){const{refreshDocxSourceSignatures:p}=await import("./DocxGraft-CRgF0kbP.js");p(i)}return i}else throw t.endsWith(".pdf")?new Error("PDF files are imported via the AI import flow, not FileImporter."):d(t)?new Error("Image files are imported via the AI import flow, not FileImporter."):new Error(`Unsupported file type: ${r.name}. Supported formats: ${s.join(", ")}`)}static getSupportedExtensions(){return[...s]}static getAcceptString(){return f}static isSupported(r){return u(r)}}export{l as FileImporter};