@docx-editor.dev/core 2.31.0 → 2.33.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 (140) hide show
  1. package/README.md +25 -1
  2. package/THIRD_PARTY_NOTICES.md +1 -0
  3. package/dist/automation.cjs +1 -1
  4. package/dist/automation.d.ts +16 -54
  5. package/dist/automation.js +1 -1
  6. package/dist/binding.cjs +1 -1
  7. package/dist/binding.d.ts +17 -15
  8. package/dist/binding.js +1 -1
  9. package/dist/{chrome-print-BWvaVEhD.d.ts → chrome-print-CrPI9ZQc.d.ts} +128 -38
  10. package/dist/chunk-23MKR33J.js +4 -0
  11. package/dist/chunk-2CWQY27B.cjs +1 -0
  12. package/dist/chunk-2DEY5NUC.cjs +32 -0
  13. package/dist/chunk-2DR4TH6B.js +1 -0
  14. package/dist/chunk-2F2UEAE2.js +2 -0
  15. package/dist/chunk-2GPGAFOJ.cjs +5 -0
  16. package/dist/chunk-ALD626VU.cjs +2 -0
  17. package/dist/chunk-AU33YWEJ.js +236 -0
  18. package/dist/chunk-AXU63LYW.cjs +1 -0
  19. package/dist/chunk-CM5VZRBV.js +32 -0
  20. package/dist/chunk-D7FAFFTN.js +1 -0
  21. package/dist/chunk-DYUVJNDD.cjs +1 -0
  22. package/dist/chunk-ESYUKD5D.js +2 -0
  23. package/dist/chunk-F7TGQMVR.js +5 -0
  24. package/dist/chunk-FLW7KIQX.js +30 -0
  25. package/dist/chunk-JG4A6W6I.js +7 -0
  26. package/dist/chunk-JNGLSBPH.js +2 -0
  27. package/dist/chunk-KE6ZWRIY.cjs +236 -0
  28. package/dist/chunk-L3YXJDPX.js +1 -0
  29. package/dist/chunk-LI42N7OW.cjs +4 -0
  30. package/dist/chunk-PLKDS4JT.js +1 -0
  31. package/dist/chunk-PXMTQ73F.cjs +2 -0
  32. package/dist/chunk-R4R3AAE4.js +1 -0
  33. package/dist/chunk-RFUNFTGV.cjs +1 -0
  34. package/dist/chunk-SVM6PGMS.js +3 -0
  35. package/dist/chunk-SZURLHR3.cjs +3 -0
  36. package/dist/chunk-UYCGCVZ2.cjs +1 -0
  37. package/dist/chunk-WN7ICTA5.js +1 -0
  38. package/dist/chunk-X34QRAUU.cjs +1 -0
  39. package/dist/chunk-XNBYG4XJ.cjs +30 -0
  40. package/dist/chunk-ZDFJW5XS.cjs +2 -0
  41. package/dist/chunk-ZWO4JHNN.cjs +7 -0
  42. package/dist/collaboration/replication.cjs +1 -1
  43. package/dist/collaboration/replication.d.ts +29 -4
  44. package/dist/collaboration/replication.js +1 -1
  45. package/dist/collaboration.cjs +1 -1
  46. package/dist/collaboration.d.ts +5 -5
  47. package/dist/collaboration.js +1 -1
  48. package/dist/contracts/document.d.ts +3 -3
  49. package/dist/contracts/editor.d.ts +13 -9
  50. package/dist/contracts/interaction.d.ts +2 -2
  51. package/dist/contracts/modules.d.ts +15 -12
  52. package/dist/contracts/types.d.ts +135 -2
  53. package/dist/{custom-node-writes-TeUvMP13.d.ts → custom-node-writes-AqY5KpVx.d.ts} +7 -2
  54. package/dist/diagnostic-context-CuzhOX0g.d.ts +98 -0
  55. package/dist/{diagnostic-hints-C9JlLz1L.d.ts → diagnostic-hints-BtCaCqQC.d.ts} +4 -4
  56. package/dist/{document-protection-C8x3P2J6.d.ts → document-protection-BvbpSXbQ.d.ts} +1 -1
  57. package/dist/drawing-graphic-kind-CXYGYbB3.d.ts +324 -0
  58. package/dist/drawing-preview-package-B9lSLRg4.d.ts +115 -0
  59. package/dist/{editor-B2ShlO23.d.ts → editor-B7OOAAie.d.ts} +181 -244
  60. package/dist/editor-fonts-D_-vjuJi.d.ts +53 -0
  61. package/dist/{editor-scope-C7ke1KJG.d.ts → editor-scope-CA6egMaK.d.ts} +6 -2
  62. package/dist/editor.cjs +1 -1
  63. package/dist/editor.css +4 -4
  64. package/dist/editor.d.ts +259 -31
  65. package/dist/editor.js +1 -1
  66. package/dist/export.cjs +2 -2
  67. package/dist/export.d.ts +48 -19
  68. package/dist/export.js +2 -2
  69. package/dist/{failure-NS2lsya4.d.ts → failure-6KGFrDO9.d.ts} +1 -1
  70. package/dist/{font-resolver-CWh40DYp.d.ts → font-resolver-Bm9XqTNO.d.ts} +15 -1
  71. package/dist/index.cjs +1 -1
  72. package/dist/index.d.ts +43 -26
  73. package/dist/index.js +1 -1
  74. package/dist/{layout-shaping-CWS3j0Xr.d.ts → layout-shaping-Ci_BTnSU.d.ts} +1 -1
  75. package/dist/layout.cjs +1 -1
  76. package/dist/layout.d.ts +181 -99
  77. package/dist/layout.js +1 -1
  78. package/dist/metafile-drawing-DtMFyMKq.d.ts +107 -0
  79. package/dist/{note-properties-QsKh24sM.d.ts → note-properties-DCIJUKIy.d.ts} +1 -1
  80. package/dist/output.cjs +1 -1
  81. package/dist/output.d.ts +11 -7
  82. package/dist/output.js +1 -1
  83. package/dist/{protocol-COZJUKUY.d.ts → protocol-Cp_QzVxS.d.ts} +75 -5
  84. package/dist/{review-paragraph-order-C_QbCKcH.d.ts → review-paragraph-order-BJQ43_r0.d.ts} +1 -1
  85. package/dist/revision-projection-OVusTS77.d.ts +258 -0
  86. package/dist/{semantic-cell-selection-Cub9FDa8.d.ts → semantic-cell-selection-CoI5hHBm.d.ts} +2 -2
  87. package/dist/{semantic-interaction-dApRIYpt.d.ts → semantic-interaction-BbA4dgEo.d.ts} +1 -1
  88. package/dist/{semantic-paint-DLzA8sjP.d.ts → semantic-paint-B5JcIv9c.d.ts} +19 -9
  89. package/dist/{semantic-record-queries-3yp9o11g.d.ts → semantic-record-queries-DnO8J5_j.d.ts} +1 -1
  90. package/dist/{semantic-records-B-akgRch.d.ts → semantic-records-DoK0lNjS.d.ts} +439 -418
  91. package/dist/store.cjs +1 -1
  92. package/dist/store.d.ts +511 -20
  93. package/dist/store.js +1 -1
  94. package/dist/{types-barrel-CkF2JbU4.d.ts → tree-op-types-Df4oY2u4.d.ts} +1081 -524
  95. package/dist/{tree-package-store-B8l8DX3Z.d.ts → tree-package-store-DXhX1PE-.d.ts} +8 -3
  96. package/dist/{tree-session-contract-DeLRqohz.d.ts → tree-session-contract-CF2625mv.d.ts} +5 -5
  97. package/dist/unsupported-elements-CUojsaCr.d.ts +23 -0
  98. package/docs/accept-reject-without-scrolling.md +95 -0
  99. package/docs/comment-on-found-text.md +72 -0
  100. package/docs/custom-review-cards.md +178 -0
  101. package/docs/highlight-ranges.md +48 -0
  102. package/docs/index.md +36 -0
  103. package/docs/propose-rewrite.md +247 -0
  104. package/docs/tracked-replacement.md +68 -0
  105. package/licenses/ECMA-376.md +29 -0
  106. package/package.json +3 -2
  107. package/dist/bookmark-names-DDuAra_V.d.ts +0 -37
  108. package/dist/chunk-243W4WW2.cjs +0 -2
  109. package/dist/chunk-2E2RPEKX.js +0 -1
  110. package/dist/chunk-4S24UOPG.js +0 -30
  111. package/dist/chunk-5JPIEN54.cjs +0 -3
  112. package/dist/chunk-5SO5QDMV.cjs +0 -2
  113. package/dist/chunk-6IDOVU6L.cjs +0 -1
  114. package/dist/chunk-6JIJOZDW.js +0 -1
  115. package/dist/chunk-BTQKU64Q.cjs +0 -1
  116. package/dist/chunk-DBOOTED4.cjs +0 -30
  117. package/dist/chunk-EOTAXOJY.cjs +0 -5
  118. package/dist/chunk-FDAKJ2SJ.cjs +0 -30
  119. package/dist/chunk-FNNOJNGY.js +0 -3
  120. package/dist/chunk-FT33HRZP.js +0 -5
  121. package/dist/chunk-HC6YNKUI.cjs +0 -1
  122. package/dist/chunk-HZ66UCIS.js +0 -2
  123. package/dist/chunk-IBRBNT37.cjs +0 -1
  124. package/dist/chunk-IVIN7X43.js +0 -30
  125. package/dist/chunk-LZY6B6IV.js +0 -4
  126. package/dist/chunk-MOYYRVFV.cjs +0 -2
  127. package/dist/chunk-N6B3BXCL.js +0 -1
  128. package/dist/chunk-Q5K2GGNG.js +0 -2
  129. package/dist/chunk-R2XINWVE.js +0 -7
  130. package/dist/chunk-SUEXVBPR.js +0 -1
  131. package/dist/chunk-T2QQHG5C.js +0 -18
  132. package/dist/chunk-VWIJKH4A.js +0 -1
  133. package/dist/chunk-WO4V6PNS.cjs +0 -18
  134. package/dist/chunk-XMJKFURD.cjs +0 -4
  135. package/dist/chunk-XSTGE3NI.cjs +0 -1
  136. package/dist/chunk-YQWMI6J5.cjs +0 -7
  137. package/dist/chunk-ZCJS7D7S.js +0 -2
  138. package/dist/diagnostic-context-DJ0P1uZE.d.ts +0 -31
  139. package/dist/headless-document-view-qOpaCF82.d.ts +0 -143
  140. package/dist/omml-equation-BsLAa2lX.d.ts +0 -115
@@ -1 +0,0 @@
1
- import {kf,bf,Pf,Xa,$a,ja,Ke,Qe,df,Oe,jc,lf,ef,Nf,af,ab,_a,jf,Ga,Ye,Ea,Ha,Da,ya,Na,je,td as td$1,qb,qe,Be,De,rd,Ce}from'./chunk-4S24UOPG.js';import {Ca,aa,ba}from'./chunk-Q5K2GGNG.js';import {ke,nf,Rj,lh,bd,if as _if,qk,jb,dk,fk,rg,ab as ab$1,vd,Jd,$,ud,td,Nd,Md,qd,sd,Bk,ii,xk,sk,mg,la,Aa}from'./chunk-T2QQHG5C.js';var Kt=Object.freeze({}),zt=Object.freeze([]);function Ht(e){let t=Object.keys(e);if(t.length===0)return Kt;let r={};for(let n of t){let o=e[n];o!==void 0&&(r[n]=o);}return Object.freeze(r)}function Wt(e){let t=new Map(rg(e.part())),r=new Set([e.part()]);for(let o of e.headerFooterPartsBySection())for(let a of [o.headers,o.footers])for(let i of a.values())if(!r.has(i)){r.add(i);for(let[s,c]of rg(i))t.has(s)||t.set(s,c);}let n=e.currentPackage();for(let o of ["footnote","endnote"]){let a=lh(n,o);if(!(!a||r.has(a))){r.add(a);for(let[i,s]of rg(a))t.has(i)||t.set(i,s);}}return t}function $t(e,t){let r=qe(e,t);if(!r)return null;let n=e.pages[r.pageIndex];if(!n)return null;let o=Be(n),a=De(e,t.paragraphId,r.pageIndex),i=Object.freeze({x:r.x+a.x,y:r.y+a.y,height:r.height});return Object.freeze({anchor:Object.freeze({...t}),pageIndex:r.pageIndex,pageContent:i,pageStack:Object.freeze({x:o.x+i.x,y:o.y+i.y})})}function Ut(e,t){let r=[];for(let n of t.values()){let o=$t(e,n);o&&r.push(o);}return r.length===0?zt:Object.freeze(r)}function ft(e,t){return {documentMetadata:Ht(e.documentProperties()),destinations:Ut(t,Wt(e))}}function Er(e,t){let r=e.destinations;if(r){for(let n of r)if(n.anchor.name===t)return n}}function yt(e={}){return Object.freeze({async decode(t,r,n){let o=ke(t,r);if(!o)throw new Error(`Unsupported or malformed ${r} image`);if(o.pixelWidth>n.maxDimension||o.pixelHeight>n.maxDimension||o.pixelWidth>n.maxPixels/o.pixelHeight)throw new Error("Image dimensions exceed resource limits");return Object.freeze({pixelWidth:o.pixelWidth,pixelHeight:o.pixelHeight,dpiX:o.dpiX??96,dpiY:o.dpiY??96})},...e.convertPreserved?{convertPreserved:e.convertPreserved}:{}})}var gt=new WeakMap;function ht(e,t){let r=gt.get(e);r||(r=Oe(e),gt.set(e,r));let n=r.styleCascade(),o=new Set;if(t===e.part())for(let c of td$1(t,void 0,void 0,n,r.numberingIndex()))for(let h of qb(c)?.slice(0,-1)??[])o.add(h.paragraph.id);let a=c=>{if(c.kind==="textValue")return false;let h=c.children.find(d=>d.kind!=="textValue"&&d.namespaceUri===la&&d.localName==="pPr"),p=h?.kind!=="textValue"?h?.children.find(d=>d.kind!=="textValue"&&d.namespaceUri===la&&d.localName==="rPr"):void 0;return p!==void 0&&Aa(p,"vanish")},i=0,s=(c,h)=>{if(++i>Jd||h>$||c.kind==="textValue")return false;if(c.kind==="paragraph"&&!o.has(c.id)&&(rd(c,n,false)||a(c))&&mg(c).length>0)return true;for(let p of c.children){if(i>=Jd)break;if(s(p,h+1))return true}return false};return s(t.root,0)}var wt=new WeakMap,Gt=new Set(["shape","rect","roundrect","oval","line","group","arc","curve","polyline","image"]);function Yt(e,t){let r=wt.get(e.root);if(r&&r.stylesPart===t)return r.codes;let n=ab$1(t),o=new Set,a=[{node:e.root,scope:vd(),depth:0,mcSelected:false,framed:false}],i=0;for(;a.length;){let{node:c,scope:h,depth:p,mcSelected:d,framed:y}=a.pop();if(++i>Jd||p>$){o.add("scan-limit");break}if(c.kind==="textValue")continue;if(i+a.length+c.children.length>Jd){o.add("scan-limit");break}let g=ud(h,c),w=y||n(c),l=td(c)?c:void 0;if(l){if(Nd(l,g).drawing)continue;let m=Md(l,g);m.refused&&o.add("scan-limit"),m.branch&&a.push({node:m.branch,scope:g,depth:p+1,mcSelected:true,framed:w});continue}if(!d&&qd(c)&&!(w&&c.localName==="object")){let m=sd(c,e.name)?.textboxStory?.content;m&&a.push({node:m,scope:g,depth:p+1,mcSelected:d,framed:w});continue}if(c.namespaceUri==="urn:schemas-microsoft-com:vml"&&c.localName==="textbox"){o.add("legacy-textbox");continue}c.namespaceUri==="urn:schemas-microsoft-com:vml"&&Gt.has(c.localName)&&!c.children.some(m=>m.kind!=="textValue"&&m.namespaceUri==="urn:schemas-microsoft-com:vml"&&m.localName==="textbox")&&o.add("legacy-drawing");for(let m of c.children)a.push({node:m,scope:g,depth:p+1,mcSelected:d,framed:w});}let s=Object.freeze([...o]);return wt.set(e.root,{stylesPart:t,codes:s}),s}function xt(e){let t=new Set([e.part()]);for(let r of e.headerFooterPartsBySection())for(let n of [r.headers,r.footers])for(let o of n.values())t.add(o);for(let r of ["footnote","endnote"]){let n=lh(e.currentPackage(),r);n&&t.add(n);}return Object.freeze([...t].flatMap(r=>[...Yt(r,bd(e.currentPackage())),...ht(e,r)?["unsupported-style-separator"]:[]].map(n=>Object.freeze({code:n,partName:r.name}))))}function bt(e){return nf(e.fieldResults,()=>jf(Xt(e)))}function Xt(e){return kf(e.fieldResults,qt(e))}function*qt(e){let t=e.defaultTabStopPt?.(),r=e.view.part().name,n={view:e.view,measurer:e.measurer,producer:e.producer,cache:e.cache,styleCascade:e.styleCascade,numberingIndex:e.numberingIndex,defaultTabStopPt:t,compatibilityMode:e.compatibilityMode?.(),inlineDrawingLayoutForPart:e.inlineDrawingLayoutForPart,drawingTokenForParagraphForPart:e.drawingTokenForParagraphForPart,drawingLayoutEpochForPart:e.drawingLayoutEpochForPart,linkProjectors:e.linkProjectors,projectFieldLink:e.projectFieldLink,showFieldCodes:e.showFieldCodes,displayMode:e.displayMode,revisionAuthorFilter:e.revisionAuthorFilter},o=bf(n),a={view:e.view,revision:e.revision,measurer:e.measurer,cache:e.cache,session:e.session,producer:e.producer,styleCascade:e.styleCascade,numberingIndex:e.numberingIndex,defaultTabStopPt:t,furniture:e.furniture,compatibilityMode:e.compatibilityMode,linkProjectors:e.linkProjectors,projectFieldLink:e.projectFieldLink,showFieldCodes:e.showFieldCodes,fieldResults:e.fieldResults,inlineDrawingLayout:e.inlineDrawingLayout,drawingTokenForParagraph:e.drawingTokenForParagraph,drawingLayoutEpoch:e.drawingLayoutEpoch,displayMode:e.displayMode,revisionAuthorFilter:e.revisionAuthorFilter,bodyBlockLimit:e.bodyBlockLimit},i={measurer:a.measurer,cache:a.cache,session:a.session,producer:a.producer,styleCascade:a.styleCascade?.(),defaultTabStopPt:a.defaultTabStopPt,compatibilityMode:a.compatibilityMode?.(),numberingIndex:a.numberingIndex?.(),sectionFurniture:a.furniture.sectionFurniture(),furniture:a.furniture.furniture(),evenAndOddHeaders:a.view.headerFooterPartsBySection()[0]?.evenAndOddHeaders===true,projectLink:a.linkProjectors.projectLink,projectFieldLink:a.projectFieldLink,showFieldCodes:a.showFieldCodes,fieldResults:a.fieldResults,documentProperties:a.view.documentProperties(),inlineDrawingLayout:a.inlineDrawingLayout,drawingTokenForParagraph:a.drawingTokenForParagraph,drawingLayoutEpoch:a.drawingLayoutEpoch,projectionTokenForParagraph:s=>a.linkProjectors.tokenForParagraphForPart(r,s),projectionTokenForTable:s=>a.linkProjectors.tokenForTableForPart(r,s),projectionEpoch:a.linkProjectors.epochForPart(r),notes:o,displayMode:a.displayMode,revisionAuthorFilter:a.revisionAuthorFilter,bodyBlockLimit:a.bodyBlockLimit};return yield*Pf(a.view.part(),a.revision,i)}var Jt=65536;function St(e,t){return {x:t.x-e.contentBox.x,y:t.y-e.contentBox.y}}function Qt(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function Zt(e,t,r){return e.rootStory!==t?false:t==="footnote"||t==="endnote"?e.noteScopeId===r:true}function er(e,t){if(t.story!=="textbox"||t.textboxPath.length===0)return null;let r=null;return Da(e,n=>{if(r||!Zt(t,n.story,n.noteScopeId))return;let o=n.story==="header"||n.story==="footer"?a=>ya(a,n.origin,{x:e.box.x,y:e.box.y}):void 0;Ha(n.host,(a,i)=>{if(r||i.textboxDepth===0)return;let s=i.textboxPath.map(c=>c.drawingNodeId);Qt(s,t.textboxPath)&&(r=St(e,i.storyOrigin));},n.origin,o);}),r}function tr(e,t){if(t.story==="textbox")return er(e,t)??{x:0,y:0};switch(t.rootStory){case "body":return {x:0,y:0};case "header":return e.header?Ce(e,e.header.box):{x:0,y:0};case "footer":return e.footer?Ce(e,e.footer.box):{x:0,y:0};case "footnote":case "endnote":{let n=(t.rootStory==="footnote"?e.footnotes:e.endnotes)?.notes.find(o=>o.scopeId===t.noteScopeId);return n?Ce(e,n.box):{x:0,y:0}}case "note-separator":{let r=t.noteAreaKind==="endnotes"?e.endnotes:e.footnotes,n=r?.separator?.box;return r?.continuationNotice&&Ha(r.continuationNotice,o=>{o.paragraphId===t.source.start.paragraphId&&(n=r.continuationNotice.box);}),n?Ce(e,n):{x:0,y:0}}default:return {x:0,y:0}}}function It(e){return Object.freeze({x:e.x,y:e.y,width:e.width,height:e.height})}function Rt(e,t){let r=Be(e);return Object.freeze({x:r.x+t.x,y:r.y+t.y,width:t.width,height:t.height})}function rr(e,t){let r=qe(e,{paragraphId:t.source.start.paragraphId,offset:t.source.start.offset},{preferredPageIndex:t.pageIndex});if(!r||r.pageIndex!==t.pageIndex)return;let n=e.pages[r.pageIndex];if(!n)return;let o=tr(n,t),a=Object.freeze([It({x:r.x+o.x,y:r.y+o.y,width:0,height:r.height})]);return Object.freeze({pageContent:a,pageStack:Object.freeze(a.map(i=>Rt(n,i)))})}function nr(e,t,r){let n=r.filter(i=>i.pageIndex===t.pageIndex);if(n.length===0)return Ot(t)?rr(e,t):void 0;let o=e.pages[t.pageIndex];if(!o)return;let a=Object.freeze(n.map(i=>It(i)));return Object.freeze({pageContent:a,pageStack:Object.freeze(a.map(i=>Rt(o,i)))})}function Ot(e){return e.source.start.paragraphId===e.source.end.paragraphId&&e.source.start.offset===e.source.end.offset}function vt(e,t){return `${e}\0${t}`}function or(e,t,r){let n=Math.max(e.start,t.offset),o=Math.min(e.end,r.offset);return o>n?{start:n,end:o}:null}function ar(e,t){let r=new Map,n=new Map,o=new Set,a=0;let i=(s,c)=>{if(a>=Jt)return false;a+=1;let h=vt(s.pageIndex,c),p=n.get(h);return p?p.push(s):n.set(h,[s]),true};for(let[s,c]of t.entries())for(let[h,p]of c.occurrences.entries()){if(Ot(p)||p.source.start.paragraphId!==p.source.end.paragraphId)continue;o.add(p.pageIndex);let d=`${s}\0${h}`,y={paragraphId:p.source.start.paragraphId,offset:p.source.start.offset},g={paragraphId:p.source.end.paragraphId,offset:p.source.end.offset},w=y.offset<=g.offset?{from:y,to:g}:{from:g,to:y};i({key:d,from:w.from,to:w.to,pageIndex:p.pageIndex},w.from.paragraphId);}if(n.size===0)return r;for(let s of e.pages)o.has(s.index)&&Da(s,c=>{let h=c.story==="header"||c.story==="footer"?p=>ya(p,c.origin,{x:s.box.x,y:s.box.y}):void 0;Ha(c.host,(p,d)=>{let y=St(s,d.storyOrigin);for(let g of p.lines)for(let w of Na(g)){let l=n.get(vt(s.index,w.paragraphId));if(l)for(let m of l){let b=or(w,m.from,m.to);if(!b)continue;let x=je(g,b.start,void 0,w),v=je(g,b.end,void 0,w,b.end>b.start),I=r.get(m.key)??[];I.push({pageIndex:s.index,x:Math.min(x,v)+y.x,y:g.box.y+y.y,width:Math.abs(v-x),height:g.box.height}),r.set(m.key,I);}}},c.origin,h);});return r}function kt(e,t){let r=false;for(let o of t)if(o.occurrences.length!==0){r=true;break}if(!r)return t;let n=ar(e,t);return t.map((o,a)=>{if(o.occurrences.length===0)return o;let i=o.occurrences.map((s,c)=>{let h=`${a}\0${c}`,p=nr(e,s,n.get(h)??[]);return p?{...s,geometry:p}:s});return {...o,occurrences:Object.freeze(i)}})}function ir(e){let t=new Map,r=[{node:e.root,depth:0}];for(;r.length>0;){let{node:n,depth:o}=r.pop();if(!(n.kind==="textValue"||o>64)){n.kind==="paragraph"&&!t.has(n.id)&&t.set(n.id,t.size);for(let a=n.children.length-1;a>=0;a-=1)r.push({node:n.children[a],depth:o+1});}}return t}function Mt(){let e=new Map,t=n=>{let o=e.get(n.root);if(o)return o;let a=ir(n);return e.set(n.root,a),a},r={retainRevisionItems:false,revisionSites:sk,locations:xk,commentAnchors:ii,deepOrder:t};return Object.freeze({collectReviewItems:n=>Bk(n,r),deepParagraphOrderOfPart:t})}function sr(e,t){if(t)return true;let r=e.map(n=>n.root);for(;r.length>0;){let n=r.pop();if(qk(n))return true;if(n.kind!=="textValue")for(let o of n.children)r.push(o);}return false}function cr(e,t){let r=[],n=new Set([t.name]),o=a=>{!a||n.has(a.name)||(n.add(a.name),r.push(a));};for(let a of _if(e)){for(let i of a.headers.values())o(i);for(let i of a.footers.values())o(i);}return o(lh(e,"footnote")),o(lh(e,"endnote")),r}function dr(e,t){switch(t.story){case "body":return e.mainDocumentPart;case "header":case "footer":return t.host.partName;case "footnote":return lh(e,"footnote")?.name??null;case "endnote":return lh(e,"endnote")?.name??null;case "note-separator":return lh(e,t.noteAreaKind==="footnotes"?"footnote":"endnote")?.name??null;default:return t}}function ur(e,t){let r=new Map;for(let n of e){let o=t.get(n.partName),a=o?.get(n.start.paragraphId),i=o?.get(n.end.paragraphId);if(a===void 0||i===void 0)continue;let s=Math.min(a,i),c=Math.max(a,i),h=r.get(n.partName);r.set(n.partName,{lower:Math.min(h?.lower??s,s),upper:Math.max(h?.upper??c,c)});}return r}function lr(e,t,r,n,o){let a=new Map(r.map(d=>[d.name,o(d)])),i=ur(n,a),s=new Map,c=new Map,h=(d,y,g,w,l,m,b)=>{let x=a.get(d)?.get(l),v=i.get(d);if(x===void 0||!v||x<v.lower||x>v.upper)return;let I=s.get(d)??new Map;s.set(d,I);let V=c.get(d)??new Map;c.set(d,V);let W=JSON.stringify([y.story,y.noteScopeId,y.noteAreaKind]),K=g==="textbox"?JSON.stringify([W,"textbox",w]):W,$=I.get(l)??[],j=`${l}\0${y.page.index}\0${K}`,T=V.get(j);T||(T={pageIndex:y.page.index,story:g,rootStory:y.story,textboxPath:w,noteScopeId:y.noteScopeId,noteAreaKind:y.noteAreaKind,laneKey:K,intervals:[],intervalKeys:new Set},V.set(j,T),$.push(T),I.set(l,$));let U=`${m}\0${b}`;T.intervalKeys?.has(U)||(T.intervalKeys?.add(U),T.intervals.push({start:m,end:b}));};Ea(e,d=>{let y=dr(t,d);!y||!i.has(y)||Ha(d.host,(g,w)=>{let l=w.textboxDepth>0?"textbox":d.story,m=w.textboxPath.map(x=>x.drawingNodeId),b=[];for(let x of g.lines){for(let v of x.spans)b.push(v.range);for(let v of x.drawings??[])b.push({paragraphId:v.paragraphId,start:v.start,end:v.start+1});}b.length===0&&b.push({paragraphId:g.range.paragraphId,start:g.range.start,end:g.range.end});for(let{paragraphId:x,start:v,end:I}of b)h(y,d,l,m,x,v,I);});}),Ga(e,d=>{let y=d.drawing.ownerPartName;d.drawing.accessibility.hidden||!i.has(y)||h(y,d.root,d.story,d.textboxPath.map(g=>g.drawingNodeId),d.drawing.paragraphId,d.drawing.start,d.drawing.start+1);});for(let d of s.values())for(let y of d.values())for(let g of y){g.intervals.sort((l,m)=>l.start-m.start||l.end-m.end);let w=[];for(let l of g.intervals){let m=w.at(-1);m&&l.start<=m.end?m.end=Math.max(m.end,l.end):w.push({...l});}g.intervals.splice(0,g.intervals.length,...w),g.intervalKeys=void 0;}let p=new Map;for(let[d,y]of s){let g=a.get(d);if(!g)continue;let w=[];for(let[l,m]of y){let b=g.get(l);b!==void 0&&w.push({paragraphId:l,position:b,laneKeys:new Set(m.map(({laneKey:x})=>x))});}w.sort((l,m)=>l.position-m.position),p.set(d,w);}return {byPart:s,orderByPart:a,visibleByPart:p}}function Dt(e,t){let r=0,n=e.length;for(;r<n;){let o=r+n>>>1;e[o].position<t?r=o+1:n=o;}return r}function pr(e,t){if(e.start.paragraphId===e.end.paragraphId)return [e.start.paragraphId];let r=t.orderByPart.get(e.partName),n=t.visibleByPart.get(e.partName),o=r?.get(e.start.paragraphId),a=r?.get(e.end.paragraphId);if(!r||!n||o===void 0||a===void 0)return [e.start.paragraphId,e.end.paragraphId];let i=Math.min(o,a),s=Math.max(o,a),c=new Set(t.byPart.get(e.partName)?.get(e.start.paragraphId)?.map(({laneKey:d})=>d)??[]),h=new Set(t.byPart.get(e.partName)?.get(e.end.paragraphId)?.map(({laneKey:d})=>d)??[]),p=new Set([...c].filter(d=>h.has(d)));return p.size===0?[e.start.paragraphId,e.end.paragraphId]:n.slice(Dt(n,i),Dt(n,s+1)).filter(d=>[...d.laneKeys].some(y=>p.has(y))).map(d=>d.paragraphId)}function mr(e,t,r,n){return n?e.intervals.filter(a=>a.start<=t&&t<a.end).length>0?[{start:t,end:t}]:[]:e.intervals.flatMap(o=>{if(o.start===o.end)return [];let a={start:Math.max(o.start,t),end:Math.min(o.end,r)};return a.end>a.start?[a]:[]})}function fr(e,t){let r=Number.NEGATIVE_INFINITY;for(let n of e)for(let o of n.intervals)r=Math.max(r,o.end);return t!==r?new Set:new Set(e.filter(n=>n.intervals.some(o=>o.end===r)))}function Lt(e,t,r){let n=[],o=new Set;for(let[a,i]of e.entries()){let s=r===void 0?void 0:r===null?"neutral":a<r?"replaced":"replacement";for(let c of pr(i,t)){let h=t.byPart.get(i.partName)?.get(c)??[],d=i.start.paragraphId===i.end.paragraphId&&i.start.offset===i.end.offset,y=c===i.start.paragraphId?i.start.offset:0,g=c===i.end.paragraphId?i.end.offset:Number.POSITIVE_INFINITY,w=d?fr(h,y):new Set;for(let l of h){let m=mr(l,y,g,d);d&&m.length===0&&w.has(l)&&(m=[{start:y,end:y}]);for(let b of m){let x=`${l.pageIndex}\0${l.story}\0${l.noteScopeId??""}\0${l.noteAreaKind??""}\0${l.textboxPath.join("\0")}\0${i.partName}\0${c}\0${b.start}\0${b.end}\0${s??""}`;o.has(x)||(o.add(x),n.push({pageIndex:l.pageIndex,physicalPageNumber:l.pageIndex+1,story:l.story,rootStory:l.rootStory,textboxPath:l.textboxPath,noteScopeId:l.noteScopeId,noteAreaKind:l.noteAreaKind,...s?{revisionRole:s}:{},source:{partName:i.partName,start:{paragraphId:c,offset:b.start},end:{paragraphId:c,offset:b.end}}}));}}}}return n}function At(e,t){let r=2166136261,n=2654435769;for(let o=0;o<t.length;o+=1){let a=t.charCodeAt(o);r=Math.imul(r^a,16777619)>>>0,n=Math.imul(n^a+o,2246822507)>>>0,n^=n>>>13;}return `${e}_${t.length.toString(36)}_${r.toString(36)}_${n.toString(36)}`}function Et(e,t,r=At){let n=new Map;for(let a of t){let i=r(e,a),s=n.get(i)??new Set;s.add(a),n.set(i,s);}let o=new Map;for(let[a,i]of n){let s=[...i].sort();for(let[c,h]of s.entries())o.set(h,s.length===1?a:`${a}_${c.toString(36)}`);}return o}function yr(e){let t=new Set,r=new Set;for(let n of e){if(n.kind==="comment"){t.add(n.id),n.parentId!==void 0&&t.add(n.parentId),n.parentRevisionId!==void 0&&r.add(n.parentRevisionId);for(let o of n.replyIds)t.add(o);}if(n.kind==="revision"){r.add(n.id),n.pairedWith!==void 0&&r.add(n.pairedWith);for(let o of n.replyIds)t.add(o);}}return {comment:Et("comment",t),revision:Et("change",r)}}function _(e,t,r){return e.get(r)??At(t,r)}function gr(e,t,r){return e.kind==="revision"?{kind:"tracked-change",id:_(r.revision,"change",e.id),change:e.revisionKind,...e.structuralChanges?{structuralChanges:e.structuralChanges}:{},...e.markDirection?{markDirection:e.markDirection}:{},author:e.author,...e.date!==void 0?{date:e.date}:{},text:jb(e.text),replacedText:jb(e.replacedText),nesting:e.nesting,...e.replacedRangeCount!==void 0?{replacedRangeCount:e.replacedRangeCount}:{},readOnly:e.readOnly,...e.pairedWith!==void 0?{pairedWith:_(r.revision,"change",e.pairedWith)}:{},replyIds:e.replyIds.map(n=>_(r.comment,"comment",n)),occurrences:t?Lt(e.ranges,t,e.revisionKind==="replace"?e.replacedRangeCount??null:void 0):[]}:e.kind!=="comment"?null:{kind:"comment",id:_(r.comment,"comment",e.id),author:e.comment.author,initials:fk(e.comment),...e.comment.date!==void 0?{date:e.comment.date}:{},text:dk(e.comment),resolved:e.resolved,...e.parentId!==void 0?{parentId:_(r.comment,"comment",e.parentId)}:{},...e.parentRevisionId!==void 0?{parentRevisionId:_(r.revision,"change",e.parentRevisionId)}:{},replyIds:e.replyIds.map(n=>_(r.comment,"comment",n)),orphaned:e.orphaned,occurrences:t&&e.range?Lt([e.range],t):[]}}function Ft(e,t){let r=t.parts.get(t.mainDocumentPart);if(!r)return [];let n=cr(t,r),o=[r,...n],a=t.parts.get(aa(t,r.name));if(!sr(o,a))return [];let i=Mt(),s=i.collectReviewItems({storyPart:r,furnitureParts:n,commentsPart:a,commentsExtendedPart:t.parts.get(ba(t,r.name))});if(s.length===0)return [];let c=s.flatMap(d=>Rj(d)),h=c.length>0?lr(e,t,o,c,i.deepParagraphOrderOfPart):null,p=yr(s);return s.map(d=>gr(d,h,p)).filter(d=>d!==null)}var hr=new Set(["part","validatedHandle"]);function Tt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function q(e,t,r,n,o){if(!(n!==void 0&&hr.has(n))){if(typeof e=="function")throw new TypeError("Semantic layout publication encountered a function value");if(!(e===null||typeof e!="object")&&!o?.has(e)){if(r.has(e))throw new TypeError("Semantic layout publication encountered a cyclic record graph");if(!t.has(e)){t.add(e),r.add(e);try{if(Array.isArray(e)){for(let a of e)q(a,t,r,void 0,o);Object.freeze(e);return}if(!Tt(e))throw new TypeError("Semantic layout publication encountered a non-record value");for(let a of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,a);if(i){if(!("value"in i))throw new TypeError("Semantic layout publication encountered an accessor property");q(i.value,t,r,a,o);}}Object.freeze(e);}finally{r.delete(e);}}}}}function Ct(e){if(!Tt(e))throw new TypeError("Semantic layout publication encountered a non-record value");let t=new Set;for(let n of e.pages)if(!(n===null||typeof n!="object"))for(let o of ["header","footer"]){let a=Object.getOwnPropertyDescriptor(n,o);if(!a||!("value"in a))continue;let i=a.value;if(i===null||typeof i!="object"||t.has(i))continue;let s=new Set;s.add(e),q(i,new Set,s,o),t.add(i);}let r=(n,o)=>{let a=new Set;for(let i of n){let s=new Set;s.add(e),q(i,a,s,void 0,o);}Object.freeze(n);};for(let n of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,n);if(!o)continue;if(!("value"in o))throw new TypeError("Semantic layout publication encountered an accessor property");if(n==="pages"&&Array.isArray(o.value)){r(o.value,t);continue}if(n==="reviewArtifacts"&&Array.isArray(o.value)){r(o.value);continue}let a=new Set;a.add(e),q(o.value,new Set,a,n);}return Object.freeze(e),e}var wr=Object.freeze([]),k=class extends Error{constructor(r,n,o){super(n,o);this.code=r;this.name="ExportResourceError";}code};function xr(e){try{return e instanceof k}catch{return false}}function br(e){try{return e instanceof Ye}catch{return false}}function Pr(e){try{return e instanceof Error&&typeof e.message=="string"&&e.message.length>0?e.message:null}catch{return null}}function vr(e){if(xr(e))return e;let t=br(e),r=Pr(e),n=r?`: ${r}`:"",o=new k(t?"layoutInvariant":"layoutFailed",t?`Authored geometry could not be represented within the bounded page model${n}`:`Export layout failed${n}`);return Object.defineProperty(o,"cause",{configurable:true,value:e}),o}function Sr(e){if(e===void 0)return 6e4;if(!Number.isFinite(e)||e<=0)throw new RangeError("resourceTimeoutMs must be a positive finite number");return Math.max(1,e)}function Nt(e){if(e==="all-markup"||e==="simple-markup"||e==="proposed"||e==="original")return e;throw new RangeError("displayMode must be all-markup, simple-markup, proposed, or original")}var Ir=50,ye=64;function Rr(e){switch(e.kind){case "pending":return true;case "ready":case "unrenderable":case "external":case "missing":return false;default:return e}}function Or(e){let t=false;return Ga(e,({drawing:r})=>{Rr(r.resource)&&(t=true);}),t}function jt(e){return !ArrayBuffer.isView(e)}function Yn(e,t={}){if(t.signal?.aborted)return {ok:false,reason:"aborted"};if(t.revisionAuthorSlots!==void 0&&(!t.revisionAuthorSlots||typeof t.revisionAuthorSlots!="object"||Array.isArray(t.revisionAuthorSlots)))throw new TypeError("revisionAuthorSlots must map author names to nonnegative safe integers.");let r=t.revisionAuthorSlots===void 0?void 0:Object.freeze(Object.fromEntries(Object.entries(t.revisionAuthorSlots).map(([f,P])=>{if(!Number.isSafeInteger(P)||P<0)throw new TypeError("revisionAuthorSlots values must be nonnegative safe integers.");return [f,P]}))),n=t.revisionMarkup?Xa(t.revisionMarkup):void 0,o=n?{revisionMarkup:n,hiddenAuthors:new Set,cacheKey:JSON.stringify(n)}:void 0,a=Nt(t.displayMode??$a),i=jt(e),s=jt(e)?{ok:true,view:e}:Ca(e);if(!s.ok)return s;let c=s.view,h=t.reuseAcrossRevisions??i,p=Sr(t.resourceTimeoutMs),d=t.measurer??ja(),y=t.producer??(t.measurer?"host-export-measurer":"export-fixed-measurer"),g=Ke({retainAcrossPasses:h}),w=0,l=new Set,m=()=>{w+=1;for(let f of l)f();l.clear();},b=Qe({session:c,decodePort:t.imageDecodePort??yt(t.convertPreservedImage?{convertPreserved:t.convertPreservedImage}:void 0),onResourcesChanged:m}),x={view:c,measurer:d,paragraphCache:g,sessions:new Map,completed:new Map,inFlight:new Map,styles:Oe(c),fieldLinks:new Map,links:df(c),drawingBundle:b,furniture:new Map},v=new AbortController,I=t.signal,V=false,W=()=>V?new k("aborted","Export resource settlement was aborted"):new k("disposed","Export session has been disposed"),K=()=>{V=true,$();};function $(){let f=x;if(f){x=null,I?.removeEventListener("abort",K),v.abort(I?.reason),f.drawingBundle.dispose(),f.paragraphCache.clear();for(let P of f.completed.values())jc(P.internal),lf(P.internal);for(let P of f.fieldLinks.values())P.registry.clear();f.fieldLinks.clear(),f.completed.clear(),f.inFlight.clear(),f.furniture.clear(),f.sessions.clear(),m();}}I?.addEventListener("abort",K,{once:true}),I?.aborted&&K();let j=()=>{if(!x)throw W();if(v.signal.aborted)throw new k("aborted","Export resource settlement was aborted")},T=(f,P,D,u)=>w!==f||x?.view.packageRevision()!==P||x?.view.currentPackage()!==D?Promise.resolve():(j(),new Promise((B,O)=>{let M=false,C,L=A=>{M||(M=true,C!==void 0&&clearTimeout(C),l.delete(E),v.signal.removeEventListener("abort",G),A?O(A):B());},E=()=>L(),G=()=>L(new k("aborted","Export resource settlement was aborted")),Y=()=>{if(x?.view.packageRevision()!==P||x?.view.currentPackage()!==D){L();return}let A=u-Date.now();if(A<=0){L(new k("timedOut",`Image resources did not settle within ${p}ms`));return}C=setTimeout(Y,Math.min(Ir,A));};if(l.add(E),v.signal.addEventListener("abort",G,{once:true}),w!==f||x?.view.packageRevision()!==P||x?.view.currentPackage()!==D){L();return}Y();})),U=async(f,P=0,D=Date.now()+p)=>{if(j(),Date.now()>=D)throw new k("timedOut",`Export layout did not stabilize within ${p}ms`);let u=x,B=D,O=u.view.packageRevision(),M=u.view.currentPackage(),C=u.completed.get(f);if(C&&C.revision===O&&C.pkg===M)return C.published;let L=()=>{if(u.view.packageRevision()===O&&u.view.currentPackage()===M)return null;if(P>=ye-1)throw new k("nonConvergent","Document revision did not stabilize during export layout");return U(f,P+1,B)},E=u.fieldLinks.get(f);if(!E||E.revision!==O||E.pkg!==M){let R=E?.registry??ef();R.clear(),E={revision:O,pkg:M,registry:R},u.fieldLinks.set(f,E),u.furniture.delete(f);}let G=E.registry,Y=u.sessions.get(f)??Nf();u.sessions.set(f,Y);let A=u.furniture.get(f);A||(A=af({view:u.view,measurer:u.measurer,producer:y,cache:u.paragraphCache,styleCascade:u.styles.styleCascade,numberingIndex:u.styles.numberingIndex,defaultTabStopPt:u.styles.defaultTabStopPt,compatibilityMode:u.styles.compatibilityMode,displayMode:_a(f),revisionAuthorFilter:f==="simple-markup"?ab(o):o,showFieldCodes:false,inlineDrawingLayoutForPart:R=>u.drawingBundle.contextForPart(R),drawingLayoutTokenForPart:R=>u.drawingBundle.cacheTokenForPart(R),drawingTokenForParagraphForPart:(R,ae)=>u.drawingBundle.drawingTokenForParagraph(ae,R),linkProjectors:u.links,projectFieldLink:R=>G.project(R)}),u.furniture.set(f,A));for(let R=0;R<ye;R+=1){let ae=w;u.drawingBundle.sync(u.view);let he=L();if(he)return he;let N=bt({view:u.view,revision:u.view.packageRevision(),measurer:u.measurer,cache:u.paragraphCache,session:Y,producer:y,styleCascade:u.styles.styleCascade,defaultTabStopPt:u.styles.defaultTabStopPt,numberingIndex:u.styles.numberingIndex,furniture:A,compatibilityMode:u.styles.compatibilityMode,linkProjectors:u.links,projectFieldLink:S=>G.project(S),inlineDrawingLayout:u.drawingBundle.bodyContext,inlineDrawingLayoutForPart:S=>u.drawingBundle.contextForPart(S),drawingTokenForParagraph:S=>u.drawingBundle.drawingTokenForParagraph(S,u.view.part().name),drawingTokenForParagraphForPart:(S,J)=>u.drawingBundle.drawingTokenForParagraph(J,S),drawingLayoutEpoch:u.drawingBundle.cacheTokenForPart(u.view.part().name),drawingLayoutEpochForPart:S=>u.drawingBundle.cacheTokenForPart(S),displayMode:_a(f),revisionAuthorFilter:f==="simple-markup"?ab(o):o,showFieldCodes:false,bodyBlockLimit:void 0,fieldResults:"atomic"});if(!Or(N)){let S=L();if(S)return S;h||(jc(N),lf(N),u.paragraphCache.clear(),u.sessions.delete(f),u.furniture.delete(f));let J=Ft(N,M),Bt=J.length===0?wr:Object.freeze(kt(N,J)),_t=ft(u.view,N),Vt={...N,..._t,reviewDisplayMode:f,...n?{revisionMarkup:n}:{},...r?{revisionAuthorSlots:r}:{},facingPages:[...M.parts.values()].some(Pe=>Pe.root.localName==="settings"&&Pe.root.children.some(Q=>Q.kind!=="textValue"&&(Q.localName==="mirrorMargins"||Q.localName==="evenAndOddHeaders")&&!Q.attributes.some(ve=>ve.localName==="val"&&["0","false","off"].includes(ve.value)))),contentWarnings:xt(u.view),reviewArtifacts:Bt},be=Ct(Vt);return u.completed.set(f,{revision:O,pkg:M,internal:N,published:be}),be}let we=ae;for(;u.drawingBundle.pendingResourceCount()>0;){await T(we,O,M,B),we=w,j();let S=L();if(S)return S}j();let xe=L();if(xe)return xe}throw new k("nonConvergent",`Image resources did not reach quiescence after ${ye} layout passes`)},ge=f=>{let P;try{P=Nt(f);}catch(O){return Promise.reject(O)}if(!x)return Promise.reject(W());let D=x,u=D.inFlight.get(P);if(u)return u;let B=U(P).catch(O=>{throw vr(O)}).finally(()=>D.inFlight.delete(P));return D.inFlight.set(P,B),B};return {ok:true,session:{layout:()=>ge(a),layoutFor:ge,validatedImageBytes(f){let P=x;return !P||f.resource.kind!=="ready"?null:P.drawingBundle.mintValidatedBytes(f.resource.validatedHandle,f.resource.contentId)?.slice()??null},dispose:$}}}export{Xt as a,Er as b,yt as c,k as d,Yn as e};