@reviseio/engine 3.0.0 → 3.0.1

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 (37) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/chunks/{AgentHtmlConverter-BnK7NaYA.js → AgentHtmlConverter-CnnB8-WI.js} +3 -3
  3. package/chunks/{AgentPageRenderer-DLwq6nAa.js → AgentPageRenderer-DLgUGrGy.js} +4 -4
  4. package/chunks/{BlockDiff-BdlcKY-t.js → BlockDiff-B6-aJxHo.js} +1 -1
  5. package/chunks/{CanvasRenderer-Bqsj1S0p.js → CanvasRenderer-C1Vegx9Y.js} +2 -2
  6. package/chunks/{DocumentCompare-BqyiP87r.js → DocumentCompare-C8295s35.js} +1 -1
  7. package/chunks/{DocumentLayoutEngine-7iOYvyVb.js → DocumentLayoutEngine-C62pyGVf.js} +3 -3
  8. package/chunks/{DocumentMutator-DIrZBuLr.js → DocumentMutator-Bat_oLBQ.js} +2 -2
  9. package/chunks/{DocumentScrubber-Cz8Q05hF.js → DocumentScrubber-BZQn_z92.js} +1 -1
  10. package/chunks/{DocumentSession-lXSXqua5.js → DocumentSession-BDcazSEv.js} +1 -1
  11. package/chunks/{DocxConverter-BfDw7777.js → DocxConverter-BC31uYIL.js} +3 -3
  12. package/chunks/{DocxGraft-D0uCnGCo.js → DocxGraft-L10HXM3U.js} +2 -2
  13. package/chunks/{HtmlConverter-7Xj_g9Jr.js → HtmlConverter-C5ihhZ6G.js} +3 -3
  14. package/chunks/{MarkdownConverter-cnW_oePY.js → MarkdownConverter-DofaSeC4.js} +1 -1
  15. package/chunks/{OdtConverter-GwRDMnwS.js → OdtConverter-c1fTWoAt.js} +1 -1
  16. package/chunks/{OfficeImportShared-nlMtIUni.js → OfficeImportShared-CrOpHpJ-.js} +1 -1
  17. package/chunks/{PdfConverter-yOlWiVIj.js → PdfConverter-DX7fsRH5.js} +5 -5
  18. package/chunks/{RtfConverter--wLd0qrw.js → RtfConverter-hbJ2529G.js} +66 -66
  19. package/chunks/{TableBorders-C5pNsuxP.js → TableBorders-DVhdvo6f.js} +1 -1
  20. package/chunks/TextDecoding-IPbuUqcC.js +2 -0
  21. package/chunks/TextFileDecoder-BZBBejlR.js +10 -0
  22. package/chunks/{TxtConverter-BoRVCDZw.js → TxtConverter-YHv5FXWb.js} +1 -1
  23. package/chunks/{Typography-DAGM5kfI.js → Typography-B4gndEdB.js} +1 -1
  24. package/chunks/XmlConverter-BRRluy9k.js +55 -0
  25. package/chunks/{capture-Dtinb4bY.js → capture-i_dPkQIS.js} +1 -1
  26. package/chunks/{carrier-RNy67HN4.js → carrier-pYM9xf6x.js} +1 -1
  27. package/chunks/{chromeImageLayout-bgHYmqTp.js → chromeImageLayout-BiQ3Iz1-.js} +1 -1
  28. package/chunks/{engine-TnK8N-gT.js → engine-LMUnxdm2.js} +18 -18
  29. package/chunks/{footnoteFlatten-BcKaWzVs.js → footnoteFlatten-EE85Hjre.js} +1 -1
  30. package/chunks/{graftExport-DxAALMHp.js → graftExport-G-dG7Vcc.js} +1 -1
  31. package/chunks/{index-CTti7wRd.js → index-BLb10wQt.js} +3 -3
  32. package/chunks/{serverDocumentSession-BmYdjC6e.js → serverDocumentSession-DGDU5Lh3.js} +5 -5
  33. package/chunks/{signatures-CU2LMLBp.js → signatures-DTNDS2PH.js} +1 -1
  34. package/engine.js +1 -1
  35. package/package.json +2 -2
  36. package/chunks/TextFileDecoder--rsVs3NR.js +0 -9
  37. package/chunks/XmlConverter-CO8Z28dX.js +0 -55
@@ -1,4 +1,4 @@
1
- import{W as $}from"./engine-TnK8N-gT.js";const b="#C0C0C0",p=.3,z=.5,P=.7;function y(t){if(typeof t!="string"||t.trim()==="")return null;let o;try{const i=JSON.parse(t);if(typeof i=="string")o={text:i};else if(i&&
1
+ import{W as $}from"./engine-LMUnxdm2.js";const b="#C0C0C0",p=.3,z=.5,P=.7;function y(t){if(typeof t!="string"||t.trim()==="")return null;let o;try{const i=JSON.parse(t);if(typeof i=="string")o={text:i};else if(i&&
2
2
  typeof i=="object"&&typeof i.text=="string")o=i;else return null}catch{o={text:t}}const e=o.text.trim();if(!e)return null;const n=typeof o.opacity=="number"&&o.opacity>=0&&o.opacity<=1?o.opacity:p,r=typeof o.
3
3
  fontSizePx=="number"&&o.fontSizePx>0?o.fontSizePx:void 0;return{text:e,color:typeof o.color=="string"&&o.color.trim()!==""?o.color:b,opacity:n,diagonal:o.diagonal!==!1,...r!==void 0?{fontSizePx:r}:{}}}
4
4
  function x(t){const o={text:t.text};return typeof t.color=="string"&&t.color.trim()!==""&&t.color.toUpperCase()!==b&&(o.color=t.color),typeof t.opacity=="number"&&t.opacity>=0&&t.opacity<=1&&t.opacity!==
@@ -0,0 +1,2 @@
1
+ const r="€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ";function d(e){return e.replace(/[\u0080-\u009f]/g,n=>r[n.charCodeAt(0)-128])}function u(e,n,c){const o=new TextDecoder(
2
+ n,c),t=o.decode(e);return o.encoding==="windows-1252"?d(t):t}export{u as d};
@@ -0,0 +1,10 @@
1
+ import{d as u}from"./TextDecoding-IPbuUqcC.js";const p=["shift_jis","gb18030","big5","euc-kr","windows-1251","windows-1256","windows-1252"];function w(t){return/charset\s*=\s*["']?([^;"'\s]+)/i.exec(t)?.[1]??
2
+ null}function y(t){const n=u(t.subarray(0,2048),"windows-1252");return/<meta[^>]+charset\s*=\s*["']?([^\s"'/>;]+)/i.exec(n)?.[1]??/<meta[^>]+content\s*=\s*["'][^"']*charset\s*=\s*([^\s"';]+)/i.exec(n)?.[1]??
3
+ null}function a(t,n,e=!0){try{return u(t,n,{fatal:e})}catch{return null}}function f(t){let n=0;const e=new Map;for(const c of t){c==="�"?n-=100:/\p{L}|\p{N}/u.test(c)&&(n+=1);for(const[s,r]of[["cjk",
4
+ /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u],["hangul",/\p{Script=Hangul}/u],["cyrillic",/\p{Script=Cyrillic}/u],["arabic",/\p{Script=Arabic}/u]])r.test(c)&&e.set(s,(e.get(s)??0)+1);const o=c.
5
+ codePointAt(0)??0;(o<32&&!`
6
+ \r `.includes(c)||o>=127&&o<160)&&(n-=20)}for(const c of e.values())c>=2&&(n+=c*2);return n-=(t.match(/[ÃÂ]|â[\u0080-\u00bf]/g)??[]).length*8,n}function d(t,n={}){if(t[0]===239&&t[1]===187&&t[2]===
7
+ 191)return new TextDecoder("utf-8").decode(t.subarray(3));if(t[0]===255&&t[1]===254)return new TextDecoder("utf-16le").decode(t.subarray(2));if(t[0]===254&&t[1]===255){const r=t.subarray(2).slice();for(let i=0;i+
8
+ 1<r.length;i+=2)[r[i],r[i+1]]=[r[i+1],r[i]];return new TextDecoder("utf-16le").decode(r)}const e=w(n.mimeType??"")??(n.kind==="html"?y(t):null);if(e){const r=a(t,e,!1);if(r!==null)return r}const c=a(t,
9
+ "utf-8",!0);if(c!==null)return c;let o=u(t,"windows-1252"),s=f(o);for(const r of p){const i=a(t,r,!0);if(i===null)continue;const l=f(i);l>s&&(o=i,s=l)}return o}async function m(t,n="plain"){const e=new Uint8Array(
10
+ await t.arrayBuffer());return d(e,{kind:n,mimeType:t.type})}export{d as decodeTextBytes,m as decodeTextFile};
@@ -1,4 +1,4 @@
1
- import{f as r}from"./footnoteFlatten-BcKaWzVs.js";import{a_ as p,b0 as c,aR as s,aK as l}from"./engine-TnK8N-gT.js";import{decodeTextFile as m}from"./TextFileDecoder--rsVs3NR.js";class h{static async parseFile(n){
1
+ import{f as r}from"./footnoteFlatten-EE85Hjre.js";import{a_ as p,b0 as c,aR as s,aK as l}from"./engine-LMUnxdm2.js";import{decodeTextFile as m}from"./TextFileDecoder-BZBBejlR.js";class h{static async parseFile(n){
2
2
  const o=await m(n);return this.fromText(o)}static fromText(n){const o=n.replace(/\r\n?/g,`
3
3
  `).split(/\n\s*\n+/),a=[];for(const t of o){const e=t.trim();e&&a.push(p([{type:"text",text:e}]))}return a.length===0&&a.push(p()),{type:"doc",children:a}}static toText(n,o){n=r(n);const a=t=>t.type===
4
4
  "placeholder"?"[Placeholder]":t.type==="image"?"[Image]":t.type==="code"?o?.codeText?.(t)??t.content:t.type==="math"?t.content:t.type==="toc"?c(n,s(t)).map(e=>`${" ".repeat(e.level-1)}${e.text}`).join(
@@ -1,4 +1,4 @@
1
- import{bR as h}from"./engine-TnK8N-gT.js";const p={isDark:!1,background:"#f5f5f5",text:"#000000",linkText:"#007bff",selection:"#3390ff",selectionOpacity:.4,inactiveSelection:"#9ac0e8",inactiveSelectionOpacity:.35,
1
+ import{bR as h}from"./engine-LMUnxdm2.js";const p={isDark:!1,background:"#f5f5f5",text:"#000000",linkText:"#007bff",selection:"#3390ff",selectionOpacity:.4,inactiveSelection:"#9ac0e8",inactiveSelectionOpacity:.35,
2
2
  agentReadHighlight:"#7aaee6",searchHighlight:"#cc8f00",cursor:"#000000",pageBorder:"#dee2e6",pageBackground:"#ffffff",pageShadow:"rgba(0, 0, 0, 0.1)",diffInsert:"#22c55e",diffDelete:"#CF2A2A",diffEqual:"\
3
3
  #000000",diffFormatChange:"#f59e0b",diffInsertText:"#0B8237",diffDeleteText:"#CF2A2A",diffFormatChangeText:"#78350f",debugText:"#ff0000",todoCheckboxBorder:"#c8ccd5",todoCheckboxBackground:"#ffffff",todoCheckboxChecked:"\
4
4
  #46b35e",todoCheckboxCheckmark:"#46b35e",todoCheckedText:"#6c757d",codeBackground:"#f5f5f5",codeBorder:"#e0e0e0",codeText:"#333333"},A={isDark:!0,background:"#080a0e",text:"#c9c9c9",linkText:"#4099ff",
@@ -0,0 +1,55 @@
1
+ import{d as A}from"./TextDecoding-IPbuUqcC.js";import{a as k}from"./engine-LMUnxdm2.js";import{b as S}from"./TableGrid-DbroRucl.js";import{d as T}from"./BlockDiff-B6-aJxHo.js";function M(d,e,n){const t=(i,c)=>i.
2
+ length>0&&i.every(l=>l.type==="paragraph"&&l.children.length>0&&l.children.every(r=>r.marks?.[c]&&!r.marks.layeredInsertion));if(!t(d,"deletion")||!t(e,"insertion"))return null;const s=T(d,e,{nextId:n,
3
+ nextBlockId:k,label:"Revise bill",authorOf:i=>i?.suggestionAuthorName});return s?s.blocks:null}const E={division:0,title:0,subtitle:0,chapter:0,subchapter:0,part:0,subpart:0,section:0,subsection:1,paragraph:2,
4
+ subparagraph:3,clause:4,subclause:5,item:6,subitem:7},C={division:"Division",title:"Title",subtitle:"Subtitle",chapter:"Chapter",subchapter:"Subchapter",part:"Part",subpart:"Subpart",section:"Sec."},y=new Set(
5
+ ["added-phrase","deleted-phrase","bold","italic","underline","strike","superscript","subscript","quote","term","short-title","act-name","external-xref","internal-xref","enum-in-header","header-in-text",
6
+ "definition","linebreak","nobreak","sponsor","cosponsor","committee-name","text-to-insert","text-to-strike-out","omitted-text","inline-comment"]),I=new Set(["graphic","formula","footnote","footnote-re\
7
+ f","spanspec","entrytbl"]),m=d=>Array.from(d.children),g=(d,e)=>m(d).find(n=>n.localName===e),b=d=>d.replace(/[\t\r\n ]+/g," "),q={id:"us-congress-bill",label:"U.S. Congressional bills (bill.dtd)",matches(d){
8
+ const e=d.documentElement;if(e.localName!=="bill"||e.namespaceURI||!g(e,"legis-body"))return!1;const n=d.doctype;if(n)return n.name==="bill"&&(n.publicId==="-//US Congress//DTDs/bill.dtd//EN"||!n.publicId&&
9
+ /(?:^|\/)bill\.dtd$/i.test(n.systemId));const t=g(e,"form");return!!t&&!!g(t,"congress")&&!!g(t,"legis-num")},parse(d){return new L().parse(d)}};class L{constructor(){this.revisionCount=0,this.revisions=
10
+ new WeakMap,this.committees=new Map,this.usedIds=new Set}id(){let e;do e=k();while(this.usedIds.has(e));return this.usedIds.add(e),e}parse(e){const n=e.documentElement;for(const o of Array.from(n.getElementsByTagName(
11
+ "committee-name"))){const h=o.getAttribute("committee-id");h&&this.committees.set(h,b(o.textContent??"").trim())}for(const o of Array.from(n.getElementsByTagName("*")))if(I.has(o.localName))throw new Error(
12
+ `Unsupported Congressional XML element: <${o.localName}>. This bill requires content the XML importer does not yet support.`);const t=this.context(n,{marks:{},indent:0,quoted:0}),s=[],i=m(n),c=i.map(o=>this.
13
+ blocks(o,t));for(let o=0;o<i.length;o++){const h=i[o],p=c[o],f=i[o+1];if(h.localName==="legis-body"&&f?.localName==="legis-body"&&f.getAttribute("display-enacting-clause")==="no-display-enacting-claus\
14
+ e"){const v=c[o+1],N=h.getAttribute("display-enacting-clause")!=="no-display-enacting-clause"?1:0,w=M(p.slice(N),v,()=>`congressdiff-${++this.revisionCount}`);if(w){s.push(...p.slice(0,N),...w),o++;continue}}
15
+ s.push(...p)}if(!s.length)throw new Error("The Congressional XML bill contains no readable content.");const l=g(n,"form"),r=l&&g(l,"legis-num")?.textContent?.trim(),a=n.getElementsByTagName("short-tit\
16
+ le")[0]?.textContent?.trim(),u=r?[r,a].filter(Boolean).join(" — "):e.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/","title")[0]?.textContent?.trim();return{type:"doc",children:s,...u?{title:u}:
17
+ {}}}context(e,n){const t={...n.marks},s=e.localName,i=e.getAttribute("changed")??(s==="added-phrase"?"added":s==="deleted-phrase"?"deleted":null);if(i==="added"||i==="deleted"){const l=i==="added"?"in\
18
+ sertion":"deletion",r=e.getAttribute("reporting-committee")||e.getAttribute("committee-id"),a=r?this.committees.get(r)??r:void 0;if(!t[l]||a&&a!==t.suggestionAuthorName){if(t.deletion&&l==="insertion")
19
+ throw new Error("Unsupported Congressional XML revision: insertion nested inside a deletion.");let u=this.revisions.get(e);u||(u={[l]:!0,suggestionId:`congressrev-${++this.revisionCount}`,suggestionSource:"\
20
+ manual",suggestionAuthorType:"human",suggestionLabel:l==="insertion"?"Insert":"Delete",...a?{suggestionAuthorName:a}:{}},this.revisions.set(e,u)),t.insertion&&l==="deletion"&&(t.layeredInsertion=JSON.
21
+ stringify({id:t.suggestionId,source:t.suggestionSource,authorType:t.suggestionAuthorType,authorName:t.suggestionAuthorName,label:t.suggestionLabel})),delete t.insertion,delete t.deletion,delete t.suggestionAuthorName,
22
+ Object.assign(t,u)}}s==="bold"&&(t.bold=!0),s==="italic"&&(t.italic=!0),s==="underline"&&(t.underline=!0),s==="superscript"&&(t.superscript=!0),s==="subscript"&&(t.subscript=!0);const c=e.getAttribute(
23
+ "href");return c&&/^(https?:\/\/|#)/i.test(c.trim())&&(t.link=c.trim()),s==="internal-xref"&&e.getAttribute("idref")&&(t.link=`#${e.getAttribute("idref")}`),{...n,marks:t,style:e.getAttribute("style")??
24
+ n.style}}text(e,n){return{type:"text",text:e,marks:{...n.marks}}}inline(e,n){const t=this.context(e,n);if(e.localName==="linebreak")return[this.text(`
25
+ `,t)];const s=[],i=e.localName==="quote"||e.localName==="term";i&&s.push(this.text(t.quoted?"‘":"“",t));for(const c of Array.from(e.childNodes))c.nodeType===3||c.nodeType===4?s.push(this.text(b(c.
26
+ textContent??""),t)):c.nodeType===1&&s.push(...this.inline(c,i?{...t,quoted:t.quoted+1}:t));return i&&s.push(this.text(t.quoted?"’":"”",t)),s}paragraph(e,n,t,s){for(;e.length&&!e[0].text.trim();)e.
27
+ shift();for(;e.length&&!e[e.length-1].text.trim();)e.pop();if(!e.length)return null;e[0].text=e[0].text.replace(/^ +/,""),e[e.length-1].text=e[e.length-1].text.replace(/ +$/,""),n.quoted&&e.unshift(this.
28
+ text(n.quoted>1?"‘":"“",n));const i=t?.getAttribute("id");return i&&(e[0].marks={...e[0].marks,bookmark:i}),{type:"paragraph",id:this.id(),children:e,...s?{heading:s,keepNext:!0}:{},...n.indent?{leftIndent:Math.
29
+ min(n.indent,6)}:{}}}blocks(e,n){const t=e.localName;if(t==="metadata")return[];const s=this.context(e,n);if(Object.prototype.hasOwnProperty.call(E,t))return this.structure(e,{...s,indent:E[t]+(s.quoted?
30
+ 1:0)});if(t==="table")return m(e).filter(r=>r.localName==="tgroup").length?m(e).flatMap(r=>r.localName==="tgroup"?[this.table(r,this.context(r,s))]:this.blocks(r,s)):[this.table(e,s)];if(t==="quoted-b\
31
+ lock"){const r=m(e).filter(o=>o.localName!=="after-quoted-block").flatMap(o=>this.blocks(o,{...s,quoted:s.quoted+1,indent:s.indent+1})),a=r[r.length-1],u=g(e,"after-quoted-block");if(a?.type==="paragr\
32
+ aph")a.children.push(this.text(s.quoted?"’":"”",s)),u&&a.children.push(...this.inline(u,s));else if(u){const o=this.paragraph([this.text(s.quoted?"’":"”",s),...this.inline(u,s)],s);o&&r.push(o)}
33
+ return r}if(!m(e).some(r=>!y.has(r.localName))){const r=this.paragraph(this.inline(e,n),s,e);if(r&&(t==="legis-num"||t==="legis-type")){r.align="center";for(const a of r.children)a.marks={...a.marks,bold:!0}}
34
+ return r?[r]:[]}const i=[];if(t==="legis-body"&&e.getAttribute("display-enacting-clause")!=="no-display-enacting-clause"){const r=this.paragraph([this.text("Be it enacted by the Senate and House of Re\
35
+ presentatives of the United States of America in Congress assembled,",s)],s);r&&i.push(r)}let c=[];const l=()=>{const r=this.paragraph(c,s);r&&i.push(r),c=[]};for(const r of Array.from(e.childNodes))if(r.
36
+ nodeType===3||r.nodeType===4)c.push(this.text(b(r.textContent??""),s));else if(r.nodeType===1){const a=r;y.has(a.localName)?c.push(...this.inline(a,s)):(l(),i.push(...this.blocks(a,s)))}return l(),i}structure(e,n){
37
+ const t=[],s=Object.prototype.hasOwnProperty.call(C,e.localName),i=g(e,"enum"),c=g(e,"header");let l=[];if(i&&(s&&l.push(this.text(e.localName==="section"&&n.style==="USC"?"§ ":`${C[e.localName]} `,n)),
38
+ l.push(...this.inline(i,n),this.text(" ",n))),c){const u=this.inline(c,n);for(const o of u)o.marks={...o.marks,bold:!0};l.push(...u)}const r=(u=!1)=>{const o=this.paragraph(l,n,t.length?void 0:e,u?e.localName===
39
+ "section"?2:1:void 0);o&&t.push(o),l=[]};s&&r(!0);let a=!0;for(const u of Array.from(e.childNodes))if(!(u===i||u===c)){if(u.nodeType===3||u.nodeType===4)u.textContent?.trim()&&l.push(this.text(b(u.textContent),
40
+ n));else if(u.nodeType===1){const o=u;if(o.localName==="text")a||r(),a&&!s&&c&&l.push(this.text(".—",n)),l.push(...this.inline(o,n)),a=!1;else if(y.has(o.localName))l.push(...this.inline(o,n));else{
41
+ r();const h=this.blocks(o,n),p=t[t.length-1];o.getAttribute("display-inline")==="yes-display-inline"&&p?.type==="paragraph"&&!p.heading&&h[0]?.type==="paragraph"&&(p.children.push(this.text(" ",n),...h[0].
42
+ children),h.shift()),t.push(...h)}}}return r(),t}table(e,n){const t=g(e,"tgroup")??e,s=new Map(m(t).filter(r=>r.localName==="colspec").map((r,a)=>[r.getAttribute("colname"),Number(r.getAttribute("coln\
43
+ um"))||a+1])),i=m(t).flatMap(r=>r.localName==="row"?[r]:["thead","tbody","tfoot"].includes(r.localName)?m(r).filter(a=>a.localName==="row"):[]);if(!i.length)throw new Error("Unsupported Congressional \
44
+ XML table: no rows.");const c={type:"table",id:this.id(),columnWidths:[],children:i.map(r=>({type:"table-row",id:this.id(),children:m(r).filter(a=>a.localName==="entry").map(a=>{const u=s.get(a.getAttribute(
45
+ "namest")),o=s.get(a.getAttribute("nameend")),h=u&&o?o-u+1:1,p=Number(a.getAttribute("morerows")??0)+1;if(a.hasAttribute("namest")&&(!u||!o)||!Number.isInteger(h)||h<1||h>100||!Number.isInteger(p)||p<
46
+ 1||p>i.length)throw new Error("Unsupported Congressional XML table: invalid cell span.");const f=this.blocks(a,{...this.context(r,r.parentElement&&r.parentElement!==t?this.context(r.parentElement,n):n),
47
+ indent:0});return{type:"table-cell",id:this.id(),children:f.length?f:[{type:"paragraph",id:this.id(),children:[{type:"text",text:""}]}],...h>1?{colSpan:h}:{},...p>1?{rowSpan:p}:{}}})}))},l=S(c).cols;if(!l||
48
+ l>100)throw new Error("Unsupported Congressional XML table: invalid column count.");return c.columnWidths=Array(l).fill(100/l),c}}const x=[q];class X{static async parseFile(e){return this.fromBytes(new Uint8Array(
49
+ await e.arrayBuffer()))}static fromBytes(e){let n="utf-8";if(e[0]===255&&e[1]===254||e[0]===60&&e[1]===0&&e[2]===63&&e[3]===0)n="utf-16le";else if(e[0]===254&&e[1]===255||e[0]===0&&e[1]===60&&e[2]===0&&
50
+ e[3]===63)n="utf-16be";else if(!(e[0]===239&&e[1]===187&&e[2]===191)){const s=A(e.subarray(0,512),"windows-1252");n=/^<\?xml\s[^?]*\bencoding\s*=\s*["']([^"']+)["']/i.exec(s)?.[1]??n}let t;try{t=A(e,n,
51
+ {fatal:!0})}catch{throw new Error(`Invalid or unsupported XML encoding: ${n}.`)}return this.fromXml(t)}static fromXml(e){if(/<!ENTITY\s/i.test(e))throw new Error("XML entity declarations are not suppo\
52
+ rted.");const n=new DOMParser().parseFromString(e.replace(/^\uFEFF/,""),"application/xml");if(!n.documentElement||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: the documen\
53
+ t is not well-formed.");const t=[[n.documentElement,0]];for(;t.length;){const[i,c]=t.pop();if(c>128)throw new Error("XML nesting exceeds the supported depth (128).");for(const l of Array.from(i.children))
54
+ t.push([l,c+1])}const s=x.find(i=>i.matches(n));if(!s)throw new Error(`Unsupported XML schema: <${n.documentElement.tagName}>. Supported: ${x.map(i=>i.label).join(", ")}.`);return s.parse(n)}}export{x as XML_SCHEMA_PARSERS,
55
+ X as XmlConverter};
@@ -1,4 +1,4 @@
1
- import{a as S,s as p,o as l,d as h,e as y,c as m,h as b,g as w,f as A,n as $,p as C,C as k}from"./signatures-CU2LMLBp.js";async function x(e){const t=globalThis.crypto?.subtle;if(t)try{const a=await t.
1
+ import{a as S,s as p,o as l,d as h,e as y,c as m,h as b,g as w,f as A,n as $,p as C,C as k}from"./signatures-DTNDS2PH.js";async function x(e){const t=globalThis.crypto?.subtle;if(t)try{const a=await t.
2
2
  digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(a),i=>i.toString(16).padStart(2,"0")).join("")}catch{}let s=3421674724,n=2216829733;for(let a=0;a<
3
3
  e.length;a++){n^=e[a];const i=n*435+s*435%65536*65536>>>0;s=(s*435+Math.floor(n*435/4294967296)+n&4294967295)>>>0,n=i}return`fnv1a-${s.toString(16).padStart(8,"0")}${n.toString(16).padStart(8,"0")}`}function L(e,t,s){
4
4
  const n=e.get(t);if(!n){e.set(t,{start:s,end:s});return}s<n.start&&(n.start=s),s>n.end&&(n.end=s)}function M(e){const t=e.docxSource;if(!t)return;const s={};for(const n of[...e.children,...e.chrome??[],
@@ -1,4 +1,4 @@
1
- import{h as b}from"./capture-Dtinb4bY.js";const o="docx-carrier",i=25*1024*1024,u=512*1024,g=1;async function l(n,t,e){const c=e?.byteCap??i;if(t.byteLength>c)return{stored:!1,reason:"oversize"};const a=e?.
1
+ import{h as b}from"./capture-i_dPkQIS.js";const o="docx-carrier",i=25*1024*1024,u=512*1024,g=1;async function l(n,t,e){const c=e?.byteCap??i;if(t.byteLength>c)return{stored:!1,reason:"oversize"};const a=e?.
2
2
  hash??await b(t),r=n.getMap(o),s=Math.ceil(t.byteLength/u);return n.transact(()=>{r.clear();const y={version:g,hash:a,byteLength:t.byteLength,chunkCount:s,chunkSize:u};r.set("meta",y);for(let h=0;h<s;h++)
3
3
  r.set(`c${h}`,new Uint8Array(t.subarray(h*u,Math.min((h+1)*u,t.byteLength))))}),{stored:!0,hash:a}}function f(n){const t=n.getMap(o).get("meta");return!t||t.version!==g||typeof t.hash!="string"||typeof t.
4
4
  byteLength!="number"||typeof t.chunkCount!="number"?null:{hash:t.hash,byteLength:t.byteLength}}function L(n){const t=n.getMap(o),e=t.get("meta");if(!e||e.version!==g)return null;const c=new Uint8Array(
@@ -1,4 +1,4 @@
1
- import{R as y,at as B,e as v,ad as T,h as z}from"./engine-TnK8N-gT.js";const F=8,H=4,W=10,C=8,$=8;function I(t,r,e){const o=(t??[]).filter(s=>s.side===r);if(o.length===0)return[];const a=s=>o.some(c=>c.
1
+ import{R as y,at as B,e as v,ad as T,h as z}from"./engine-LMUnxdm2.js";const F=8,H=4,W=10,C=8,$=8;function I(t,r,e){const o=(t??[]).filter(s=>s.side===r);if(o.length===0)return[];const a=s=>o.some(c=>c.
2
2
  slot===s),h=e.textSlot??(e.isFirstPage&&a("first")?"first":e.pageNumber%2===0&&a("even")?"even":"default");return o.filter(s=>s.slot===h)}function L(t){const r=t.unit??1,e=F*r,o=Math.max(10*r,0);let a,
3
3
  h;t.side==="header"?(a=e,h=t.marginTop-e,t.hasText&&(h=Math.max(o,t.marginTop/2)-(W+H)*r)):(a=t.pageHeight-t.marginBottom+e,h=t.pageHeight-e,t.hasText&&(a=t.pageHeight-Math.max(o,t.marginBottom/2)+(W+
4
4
  H)*r));const s=h-a,c=t.pageWidth-t.marginLeft-t.marginRight;return s<C*r||c<=0?null:{bandTop:a,bandHeight:s,contentWidth:c}}function N(t,r){const e=t.unit??1,{bandHeight:o,contentWidth:a}=r,h=t.records.
@@ -3,15 +3,15 @@ ain text",extensions:[".txt"],mimeType:"text/plain",binary:!1,import:!0,export:!
3
3
  Word (DOCX)",extensions:[".docx"],mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",binary:!0,import:!0,export:!0},{id:"pdf",label:"PDF",extensions:[".pdf"],mimeType:"\
4
4
  application/pdf",binary:!0,import:!1,export:!0},{id:"rtf",label:"Rich Text Format (RTF)",extensions:[".rtf"],mimeType:"application/rtf",binary:!1,import:!0,export:!1},{id:"xml",label:"XML",extensions:[
5
5
  ".xml"],mimeType:"application/xml",binary:!1,import:!0,export:!1},{id:"odt",label:"OpenDocument Text (ODT)",extensions:[".odt"],mimeType:"application/vnd.oasis.opendocument.text",binary:!0,import:!0,export:!1}];
6
- function cn(e){return sn.find(t=>t.extensions.some(n=>e.toLowerCase().endsWith(n)))}async function ln(e,t,n,r){const i={name:t||`document.${n}`,arrayBuffer:async()=>new Uint8Array(e).buffer},a=async()=>(await import("./TextFileDecoder--rsVs3NR.js")).
7
- decodeTextBytes(e,{kind:n==="html"?"html":"plain",mimeType:r});switch(n){case"xml":return(await import("./XmlConverter-CO8Z28dX.js")).XmlConverter.fromBytes(e);case"markdown":return(await import("./MarkdownConverter-cnW_oePY.js")).
8
- MarkdownConverter.fromMarkdown(await a());case"txt":return(await import("./TxtConverter-BoRVCDZw.js")).TxtConverter.fromText(await a());case"html":{const o=await a(),{htmlHasMathMl:s,loadMathMlToLatex:c}=await import("./MathRenderer-Bz9WEVvF.js").
9
- then(d=>d.f);s(o)&&await c();const{cssNeedsFullColorParser:l,loadFullColorParser:u}=await Promise.resolve().then(()=>Li);return l(o)&&await u(),(await import("./HtmlConverter-7Xj_g9Jr.js")).HtmlConverter.
10
- fromHtml(o)}case"docx":{const o=await(await import("./DocxConverter-BfDw7777.js")).DocxConverter.parseFile(i,{retainSource:!0}),s=new Uint8Array(e);return o.pendingDocxCarrier={bytes:s,hash:await(await import("./DocxGraft-D0uCnGCo.js")).
11
- hashBytes(s)},o}case"rtf":return(await import("./RtfConverter--wLd0qrw.js")).RtfConverter.parseFile(i);case"odt":return(await import("./OdtConverter-GwRDMnwS.js")).OdtConverter.parseFile(i);default:throw new Error(
12
- "This format does not support headless import: "+n)}}async function at(e,t,n={}){switch(t){case"markdown":return(await import("./MarkdownConverter-cnW_oePY.js")).MarkdownConverter.toMarkdown(e);case"t\
13
- xt":return(await import("./TxtConverter-BoRVCDZw.js")).TxtConverter.toText(e,n.text);case"html":return(await import("./HtmlConverter-7Xj_g9Jr.js")).HtmlConverter.toStyledHtml(e,n.html);case"docx":return(await import("./DocxConverter-BfDw7777.js")).
14
- DocxConverter.toBlob(e,n.syntaxTheme,n.docx);case"pdf":return(await import("./PdfConverter-yOlWiVIj.js")).PdfConverter.toBlob(e,n.title,n.syntaxTheme);default:throw new Error("This format is import-on\
6
+ function cn(e){return sn.find(t=>t.extensions.some(n=>e.toLowerCase().endsWith(n)))}async function ln(e,t,n,r){const i={name:t||`document.${n}`,arrayBuffer:async()=>new Uint8Array(e).buffer},a=async()=>(await import("./TextFileDecoder-BZBBejlR.js")).
7
+ decodeTextBytes(e,{kind:n==="html"?"html":"plain",mimeType:r});switch(n){case"xml":return(await import("./XmlConverter-BRRluy9k.js")).XmlConverter.fromBytes(e);case"markdown":return(await import("./MarkdownConverter-DofaSeC4.js")).
8
+ MarkdownConverter.fromMarkdown(await a());case"txt":return(await import("./TxtConverter-YHv5FXWb.js")).TxtConverter.fromText(await a());case"html":{const o=await a(),{htmlHasMathMl:s,loadMathMlToLatex:c}=await import("./MathRenderer-Bz9WEVvF.js").
9
+ then(d=>d.f);s(o)&&await c();const{cssNeedsFullColorParser:l,loadFullColorParser:u}=await Promise.resolve().then(()=>Li);return l(o)&&await u(),(await import("./HtmlConverter-C5ihhZ6G.js")).HtmlConverter.
10
+ fromHtml(o)}case"docx":{const o=await(await import("./DocxConverter-BC31uYIL.js")).DocxConverter.parseFile(i,{retainSource:!0}),s=new Uint8Array(e);return o.pendingDocxCarrier={bytes:s,hash:await(await import("./DocxGraft-L10HXM3U.js")).
11
+ hashBytes(s)},o}case"rtf":return(await import("./RtfConverter-hbJ2529G.js")).RtfConverter.parseFile(i);case"odt":return(await import("./OdtConverter-c1fTWoAt.js")).OdtConverter.parseFile(i);default:throw new Error(
12
+ "This format does not support headless import: "+n)}}async function at(e,t,n={}){switch(t){case"markdown":return(await import("./MarkdownConverter-DofaSeC4.js")).MarkdownConverter.toMarkdown(e);case"t\
13
+ xt":return(await import("./TxtConverter-YHv5FXWb.js")).TxtConverter.toText(e,n.text);case"html":return(await import("./HtmlConverter-C5ihhZ6G.js")).HtmlConverter.toStyledHtml(e,n.html);case"docx":return(await import("./DocxConverter-BC31uYIL.js")).
14
+ DocxConverter.toBlob(e,n.syntaxTheme,n.docx);case"pdf":return(await import("./PdfConverter-DX7fsRH5.js")).PdfConverter.toBlob(e,n.title,n.syntaxTheme);default:throw new Error("This format is import-on\
15
15
  ly: "+t)}}const qr=Object.freeze(Object.defineProperty({__proto__:null,DOCUMENT_FORMATS:sn,detectDocumentFormat:cn,parseDocumentFormat:ln,serializeDocumentFormat:at},Symbol.toStringTag,{value:"Module"})),
16
16
  Vr="chromeImageBands",st="chromeImages",Te="__legacyMirrorHash",un=[["header","default"],["header","first"],["header","even"],["footer","default"],["footer","first"],["footer","even"]],Re=(e,t)=>`${e}\
17
17
  :${t}`,Y=e=>e.getMap(Vr),se=e=>e.getMap("metadata").get(st);function ct(e){if(e===void 0)return"none";const t=JSON.stringify(e)??"";let n=2166136261;for(let r=0;r<t.length;r++)n=Math.imul(n^t.charCodeAt(
@@ -499,17 +499,17 @@ let t;try{t=await import("jsdom")}catch(i){const a=new Error("@reviseio/editor/s
499
499
  vs(()=>new n("<!doctype html><html><body></body></html>",{virtualConsole:new r,url:"https://headless.revise-sdk.invalid/"}))}const As=["docx","odt","rtf","markdown","txt","html"];function Ns(e){const t=cn(
500
500
  e);if(t&&As.includes(t.id))return t.id;throw new Error(`Revise: cannot read "${e}" on the server. Readable formats: .docx, .odt, .rtf, .md, .txt, .html.`)}async function on(e,t){await Ce();const n=Ns(
501
501
  t);return ln(e,t,n)}async function rt(e,t){await Ce();const n=await at(e,"docx",{docx:t?.originalDocx?{graft:{originalDocx:t.originalDocx,...t.onGraftOutcome?{onOutcome:t.onGraftOutcome}:{}}}:void 0});
502
- return new Uint8Array(await n.arrayBuffer())}async function Is(e,t){const n=await on(e,t),r=nn();return en(r,n),await Hr(r,n,e),r}async function Hr(e,t,n){if(!t.docxSource?.sourceHash)return;const{storeDocxCarrier:r}=await import("./DocxGraft-D0uCnGCo.js");
502
+ return new Uint8Array(await n.arrayBuffer())}async function Is(e,t){const n=await on(e,t),r=nn();return en(r,n),await Hr(r,n,e),r}async function Hr(e,t,n){if(!t.docxSource?.sourceHash)return;const{storeDocxCarrier:r}=await import("./DocxGraft-L10HXM3U.js");
503
503
  await r(e,n,{hash:t.docxSource.sourceHash})}async function Ms(e,t,n){if(Tr(e))return Wr(e),!1;const r=await on(t,n);return en(e,r),await Hr(e,r,t),!0}function ot(e){return Er(e)}async function Cs(e){const{
504
- loadDocxCarrier:t}=await import("./DocxGraft-D0uCnGCo.js"),n=t(e);return rt(ot(e),{...n?{originalDocx:n.bytes}:{}})}async function Fs(e,t={}){await Ce();const{format:n="docx",mode:r="review",title:i}=t,
505
- a=typeof e.getXmlFragment=="function";if(n==="docx"&&r==="review")return a?Cs(e):rt(e);let o=a?ot(e):e;if(r==="final"){const{scrubDocument:l}=await import("./DocumentScrubber-Cz8Q05hF.js");o=l(o,{removeComments:!0,
506
- resolveSuggestions:"accept"}).doc}if(n==="docx"){const l=a?(await import("./DocxGraft-D0uCnGCo.js")).loadDocxCarrier(e):null;return rt(o,l?{originalDocx:l.bytes}:void 0)}const{DocumentMutator:s}=await import("./DocumentMutator-DIrZBuLr.js").
504
+ loadDocxCarrier:t}=await import("./DocxGraft-L10HXM3U.js"),n=t(e);return rt(ot(e),{...n?{originalDocx:n.bytes}:{}})}async function Fs(e,t={}){await Ce();const{format:n="docx",mode:r="review",title:i}=t,
505
+ a=typeof e.getXmlFragment=="function";if(n==="docx"&&r==="review")return a?Cs(e):rt(e);let o=a?ot(e):e;if(r==="final"){const{scrubDocument:l}=await import("./DocumentScrubber-BZQn_z92.js");o=l(o,{removeComments:!0,
506
+ resolveSuggestions:"accept"}).doc}if(n==="docx"){const l=a?(await import("./DocxGraft-L10HXM3U.js")).loadDocxCarrier(e):null;return rt(o,l?{originalDocx:l.bytes}:void 0)}const{DocumentMutator:s}=await import("./DocumentMutator-Bat_oLBQ.js").
507
507
  then(l=>l.y);o=s.materializeAcceptedSuggestions(o);const c=await at(o,n,n==="html"?{html:{title:i,includeWrapper:!0}}:{});return typeof c=="string"?new TextEncoder().encode(c):new Uint8Array(await c.arrayBuffer())}
508
- async function Ts(e){const{computeSourceFidelity:t,getDocxCarrierMeta:n}=await import("./DocxGraft-D0uCnGCo.js");return t(ot(e),n(e))}function Rs(e){return S.encodeStateAsUpdate(e)}function Os(e){const t=nn();
509
- return S.applyUpdate(t,e,"revise-backend"),t}async function Ls(e,t){await Ce();const{createServerDocumentSession:n}=await import("./serverDocumentSession-BmYdjC6e.js");return n(e,t)}const Es={agentHtml:()=>import("./AgentHtmlConverter-BnK7NaYA.js").
510
- then(e=>e.p),compare:()=>import("./DocumentCompare-BqyiP87r.js"),documentFormats:()=>Promise.resolve().then(()=>qr),documentLayout:()=>import("./DocumentLayout-CsU5MR-3.js"),mutator:()=>import("./DocumentMutator-DIrZBuLr.js").
511
- then(e=>e.y),documentSession:()=>import("./DocumentSession-lXSXqua5.js"),docxGraft:()=>import("./DocxGraft-D0uCnGCo.js"),pageLayout:()=>Promise.resolve().then(()=>Qa),pageRenderer:()=>import("./AgentPageRenderer-DLwq6nAa.js"),
512
- scrubber:()=>import("./DocumentScrubber-Cz8Q05hF.js"),serverSession:()=>import("./serverDocumentSession-BmYdjC6e.js"),xmlScan:()=>import("./xmlScan-DXjt2cTS.js")};export{Nn as $,pt as A,Qn as B,Z as C,
508
+ async function Ts(e){const{computeSourceFidelity:t,getDocxCarrierMeta:n}=await import("./DocxGraft-L10HXM3U.js");return t(ot(e),n(e))}function Rs(e){return S.encodeStateAsUpdate(e)}function Os(e){const t=nn();
509
+ return S.applyUpdate(t,e,"revise-backend"),t}async function Ls(e,t){await Ce();const{createServerDocumentSession:n}=await import("./serverDocumentSession-DGDU5Lh3.js");return n(e,t)}const Es={agentHtml:()=>import("./AgentHtmlConverter-CnnB8-WI.js").
510
+ then(e=>e.p),compare:()=>import("./DocumentCompare-C8295s35.js"),documentFormats:()=>Promise.resolve().then(()=>qr),documentLayout:()=>import("./DocumentLayout-CsU5MR-3.js"),mutator:()=>import("./DocumentMutator-Bat_oLBQ.js").
511
+ then(e=>e.y),documentSession:()=>import("./DocumentSession-BDcazSEv.js"),docxGraft:()=>import("./DocxGraft-L10HXM3U.js"),pageLayout:()=>Promise.resolve().then(()=>Qa),pageRenderer:()=>import("./AgentPageRenderer-DLgUGrGy.js"),
512
+ scrubber:()=>import("./DocumentScrubber-BZQn_z92.js"),serverSession:()=>import("./serverDocumentSession-DGDU5Lh3.js"),xmlScan:()=>import("./xmlScan-DXjt2cTS.js")};export{Nn as $,pt as A,Qn as B,Z as C,
513
513
  ze as D,bs as E,ue as F,de as G,Po as H,Gr as I,et as J,wn as K,ys as L,wo as M,He as N,We as O,m as P,Zi as Q,Ar as R,go as S,rr as T,$e as U,No as V,Nt as W,Wn as X,Ct as Y,Ft as Z,Ge as _,P as a,li as a$,
514
514
  Cr as a0,ea as a1,na as a2,ya as a3,xe as a4,Yr as a5,Kr as a6,_t as a7,or as a8,ha as a9,mr as aA,Pr as aB,Je as aC,Dt as aD,ke as aE,qe as aF,we as aG,hr as aH,qt as aI,ms as aJ,To as aK,is as aL,xr as aM,
515
515
  te as aN,Ae as aO,wr as aP,ci as aQ,qn as aR,Mn as aS,fe as aT,mt as aU,It as aV,Lt as aW,In as aX,ji as aY,Ei as aZ,_o as a_,Mr as aa,ar as ab,Bt as ac,ma as ad,yo as ae,Pn as af,Ze as ag,hs as ah,Qr as ai,
@@ -1,4 +1,4 @@
1
- import{a as h}from"./engine-TnK8N-gT.js";function y(e){e=e.children.some(t=>t.type==="header-footer")?{...e,children:e.children.filter(t=>t.type!=="header-footer")}:e;const f=[...e.notes??[],...e.children.
1
+ import{a as h}from"./engine-LMUnxdm2.js";function y(e){e=e.children.some(t=>t.type==="header-footer")?{...e,children:e.children.filter(t=>t.type!=="header-footer")}:e;const f=[...e.notes??[],...e.children.
2
2
  filter(t=>t.type==="footnote")];if(f.length===0)return e;const r=new Map,c=t=>{if(!t||typeof t!="object")return;if(Array.isArray(t)){t.forEach(c);return}const o=t;o.type!=="footnote"&&(o.marks?.footnoteRef&&
3
3
  !r.has(o.marks.footnoteRef)&&r.set(o.marks.footnoteRef,o.text??""),c(o.children))};c(e.children.filter(t=>t.type!=="footnote"));const i=[];let s=r.size;const d=[...f.filter(t=>t.noteKind!=="endnote"),
4
4
  ...f.filter(t=>t.noteKind==="endnote")];for(const t of d){const o=r.get(t.id)||String(s+=1);t.children.forEach((n,p)=>{if(n.type!=="paragraph"){i.push(n);return}if(p===0){const a={...n,id:h(),children:[
@@ -1,5 +1,5 @@
1
1
  import{J as He}from"./jszip.min-CPW0h1Kx.js";import{findOpenTag as Ue,endOfTag as Je,scanElementChildren as _}from"./xmlScan-DXjt2cTS.js";import{C as Y,d as ht,e as wt,c as pt,p as xt,m as yt,h as bt,
2
- g as St,f as vt,n as $t,b as It,l as ve,k as qe}from"./signatures-CU2LMLBp.js";import{h as At}from"./capture-Dtinb4bY.js";function Xe(t){return!!(t==="word/document.xml"||t==="word/styles.xml"||t==="w\
2
+ g as St,f as vt,n as $t,b as It,l as ve,k as qe}from"./signatures-DTNDS2PH.js";import{h as At}from"./capture-i_dPkQIS.js";function Xe(t){return!!(t==="word/document.xml"||t==="word/styles.xml"||t==="w\
3
3
  ord/settings.xml"||t==="word/footnotes.xml"||t==="word/endnotes.xml"||t==="word/comments.xml"||t==="word/commentsExtended.xml"||t==="docProps/core.xml"||/^word\/(header|footer)\d*\.xml$/.test(t)||/^word\/_rels\/(header|footer)\d*\.xml\.rels$/.
4
4
  test(t)||t==="word/_rels/footnotes.xml.rels"||t==="word/_rels/endnotes.xml.rels")}function oe(t){return t==="word/footnotes.xml"||t==="word/endnotes.xml"||t==="word/_rels/footnotes.xml.rels"||t==="wor\
5
5
  d/_rels/endnotes.xml.rels"?"notes":/^word\/comments[A-Za-z]*\.xml$/.test(t)||/^word\/_rels\/comments[A-Za-z]*\.xml\.rels$/.test(t)?"comments":/^word\/(header|footer)\d*\.xml$/.test(t)||/^word\/_rels\/(header|footer)\d*\.xml\.rels$/.
@@ -1,9 +1,9 @@
1
1
  import{x as ot,a as tt,bD as St,bg as Oi,bE as ut,bF as Fi,bG as Fe,bH as Pt,bI as Ri,bJ as Wi,C as et,_ as Ai,aN as Re,F as Mt,bK as nt,bL as Lt,bp as Bi,b0 as We,aR as ne,bv as zi,bu as Ae,u as Be,bl as mt,
2
- G as $t,ak as Di,bw as ze,af as Hi,bx as Ot,by as pt,bM as Ei}from"./engine-TnK8N-gT.js";import{l as $i,s as Ni,d as ji,i as Xi}from"./HorizontalRuleOrnaments-gmUZ3R7Q.js";import*as rt from"yjs";import{
2
+ G as $t,ak as Di,bw as ze,af as Hi,bx as Ot,by as pt,bM as Ei}from"./engine-LMUnxdm2.js";import{l as $i,s as Ni,d as ji,i as Xi}from"./HorizontalRuleOrnaments-gmUZ3R7Q.js";import*as rt from"yjs";import{
3
3
  getLayoutBlockSpacingPx as bt,layoutForBlockBounds as Ft,resolveBlockSpacingMargins as De,declaresOwnSpaceBefore as Ki}from"./DocumentLayout-CsU5MR-3.js";import{k as G,f as vt,g as at,m as Yi,i as Nt,
4
- F as At,L as Gi,j as re}from"./Typography-DAGM5kfI.js";import{x as gt,y as ft,z as He,A as xt,B as Ee,C as $e,D as qi,I as Vi}from"./CanvasRenderer-Bqsj1S0p.js";import{g as jt,I as Xt,M as Ui}from"./MathRenderer-Bz9WEVvF.js";
4
+ F as At,L as Gi,j as re}from"./Typography-B4gndEdB.js";import{x as gt,y as ft,z as He,A as xt,B as Ee,C as $e,D as qi,I as Vi}from"./CanvasRenderer-C1Vegx9Y.js";import{g as jt,I as Xt,M as Ui}from"./MathRenderer-Bz9WEVvF.js";
5
5
  import{t as Ji,j as se,a as Kt,b as _i,g as Zi,k as Qi,h as Ne,p as je}from"./BidiText-Bkp4Y90s.js";import{a as wt,l as Tt,g as tn,b as Yt,c as en}from"./UnicodeUtils-CXtusU4g.js";import{o as nn,s as Xe,
6
- r as rn,n as Ke,p as Ye}from"./ListNumbering-Qlu6AuRZ.js";import{n as sn,b as oe,c as on}from"./TableGrid-DbroRucl.js";import{r as an,c as ln,b as hn,q as dn,u as Bt,t as cn}from"./TableBorders-C5pNsuxP.js";
6
+ r as rn,n as Ke,p as Ye}from"./ListNumbering-Qlu6AuRZ.js";import{n as sn,b as oe,c as on}from"./TableGrid-DbroRucl.js";import{r as an,c as ln,b as hn,q as dn,u as Bt,t as cn}from"./TableBorders-DVhdvo6f.js";
7
7
  const it={heightPx:26,paddingXPx:10,cornerRadiusPx:5,fontPx:11,fontFamily:"ui-monospace, Menlo, Consolas, monospace",approxCharWidthPx:6.7,minWidthPx:72};function ae(u){return u.detail?`${u.tagName} ·\
8
8
  ${u.detail}`:u.tagName}function Ge(u,t){const e=ae(u).length*it.approxCharWidthPx+it.paddingXPx*2;return Math.min(Math.max(it.minWidthPx,Math.ceil(e)),Math.max(t,it.minWidthPx))}class un{constructor(){
9
9
  this.type="docx-raw",this.isTextBased=!1}render(t,e,i,n,r){t.save();const s=r?.renderCtx,o=i.relativeToPage?0:s?.yOffset??0,a=i.y-o,l=s?.theme,h=l?.text??"#6b7280",c=e.diffState,d=c==="insert"&&l?l.diffInsert:
@@ -1,8 +1,8 @@
1
- import{DocumentSession as Ko}from"./DocumentSession-lXSXqua5.js";import{n as fn,A as ae,a as Vo,c as bn}from"./AgentHtmlConverter-BnK7NaYA.js";import{c as ke,a as _n,b as qt,e as Le,d as ht,g as Dt,h as Xo,
2
- i as Qo,j as Zo,k as yn,l as Pt,m as Xe,n as Yo,o as er,p as tr,q as wn,s as nr,t as or,u as kn,v as rr,w as ir}from"./DocumentMutator-DIrZBuLr.js";import{b as Ce}from"./TableGrid-DbroRucl.js";import{
3
- D as Rt,i as sr,A as ar}from"./AgentPageRenderViews-BTLjPZJQ.js";import{f as re,h as Ae,i as vn,j as lr}from"./CanvasRenderer-Bqsj1S0p.js";import*as Qe from"yjs";import{d as cr,y as In,r as xn,c as Sn,
4
- e as dr,t as ur,i as mr,j as hr}from"./engine-TnK8N-gT.js";import{b as Nt}from"./base64-Di1bxoXD.js";import{createStandardLayout as pr}from"./DocumentLayout-CsU5MR-3.js";import{c as gr,h as fr}from"./DocumentLayoutEngine-7iOYvyVb.js";
5
- import{c as br}from"./index-CTti7wRd.js";import"./ParagraphDiffAnalysis-DrmStvmz.js";import{c as _r}from"./UnicodeUtils-CXtusU4g.js";import{R as yr}from"./suggestionAuthorship-B-IuLQlE.js";class wr extends Error{constructor(t){
1
+ import{DocumentSession as Ko}from"./DocumentSession-BDcazSEv.js";import{n as fn,A as ae,a as Vo,c as bn}from"./AgentHtmlConverter-CnnB8-WI.js";import{c as ke,a as _n,b as qt,e as Le,d as ht,g as Dt,h as Xo,
2
+ i as Qo,j as Zo,k as yn,l as Pt,m as Xe,n as Yo,o as er,p as tr,q as wn,s as nr,t as or,u as kn,v as rr,w as ir}from"./DocumentMutator-Bat_oLBQ.js";import{b as Ce}from"./TableGrid-DbroRucl.js";import{
3
+ D as Rt,i as sr,A as ar}from"./AgentPageRenderViews-BTLjPZJQ.js";import{f as re,h as Ae,i as vn,j as lr}from"./CanvasRenderer-C1Vegx9Y.js";import*as Qe from"yjs";import{d as cr,y as In,r as xn,c as Sn,
4
+ e as dr,t as ur,i as mr,j as hr}from"./engine-LMUnxdm2.js";import{b as Nt}from"./base64-Di1bxoXD.js";import{createStandardLayout as pr}from"./DocumentLayout-CsU5MR-3.js";import{c as gr,h as fr}from"./DocumentLayoutEngine-C62pyGVf.js";
5
+ import{c as br}from"./index-BLb10wQt.js";import"./ParagraphDiffAnalysis-DrmStvmz.js";import{c as _r}from"./UnicodeUtils-CXtusU4g.js";import{R as yr}from"./suggestionAuthorship-B-IuLQlE.js";class wr extends Error{constructor(t){
6
6
  super(t.message),this.failure=t,this.name="ReviseToolError",this.callId=t.callId,this.tool=t.tool,this.code=t.code}}const kr={count:()=>{},gauge:()=>{},distribution:()=>{}},Mt=/(<img\b[^>]*?\bsrc\s*=\s*)(["'])([\s\S]*?)\2/gi,
7
7
  $n=/(!\[[^\]]*\]\(\s*)(<[^>]+>|[^)\s]+)((?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\))/g;function pt(e){const t=e.trim();return t.startsWith("<")&&t.endsWith(">")?t.slice(1,-1).trim():t}function vr(e){const t=new Set(
8
8
  ["images.revise.io"]);for(const n of e.flatMap(o=>(o??"").split(",")))if(n.trim())try{t.add(new URL(n.includes("://")?n.trim():"https://"+n.trim()).host)}catch{}return t}function Ir(e,t,n){try{const o=new URL(
@@ -1,4 +1,4 @@
1
- import{r as d,ad as A,a7 as k,bh as x,bi as S}from"./engine-TnK8N-gT.js";const c=2;function s(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(s).join(",")}]`:
1
+ import{r as d,ad as A,a7 as k,bh as x,bi as S}from"./engine-LMUnxdm2.js";const c=2;function s(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(s).join(",")}]`:
2
2
  `{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[t])=>r<t?-1:r>t?1:0).map(([r,t])=>`${JSON.stringify(r)}:${s(t)}`).join(",")}}`}function i(e,r=c){if(e===null||typeof e!="object")return e;if(Array.
3
3
  isArray(e))return e.map(o=>i(o,r));const t=e;if(t.type==="text")return{...t,marks:(r===1?x:S)(t.marks)};const n={};for(const[o,a]of Object.entries(t))o==="indentLevel"&&t.type==="list-item"&&!a||o==="\
4
4
  hasHeader"&&t.type==="table"&&!a||o==="footnoteNumber"&&t.type==="footnote"||(n[o]=i(a,r));if(Array.isArray(n.children)){const o=[];for(const a of n.children){const f=o[o.length-1];if(f&&f.type==="tex\
package/engine.js CHANGED
@@ -1,3 +1,3 @@
1
- import{bT as s,bU as a,bV as e,bW as o,bX as c,bS as t,bY as i,bZ as D,j as m,b_ as r,c2 as b,b$ as d,c0 as n,c1 as l}from"./chunks/engine-TnK8N-gT.js";export{s as createReviseYDoc,a as createServerDocumentSession,
1
+ import{bT as s,bU as a,bV as e,bW as o,bX as c,bS as t,bY as i,bZ as D,j as m,b_ as r,c2 as b,b$ as d,c0 as n,c1 as l}from"./chunks/engine-LMUnxdm2.js";export{s as createReviseYDoc,a as createServerDocumentSession,
2
2
  e as decodeYDoc,o as documentToDocx,c as encodeYDoc,t as engineModules,i as exportDocument,D as fileToYDoc,m as installDomShims,r as parseDocument,b as seedDocRootWithClaim,d as seedYDocFromFile,n as ydocSourceFidelity,
3
3
  l as ydocToDocument};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reviseio/engine",
3
- "version": "3.0.0",
4
- "reviseBuild": "a60344a6f",
3
+ "version": "3.0.1",
4
+ "reviseBuild": "7ef88f310",
5
5
  "description": "Revise's headless document engine: Word-faithful import and export, tracked changes, comments, layout, and agent tools. Free to use; the `revise` package is the API.",
6
6
  "keywords": [
7
7
  "docx",
@@ -1,9 +0,0 @@
1
- const f=["shift_jis","gb18030","big5","euc-kr","windows-1251","windows-1256","windows-1252"];function p(t){return/charset\s*=\s*["']?([^;"'\s]+)/i.exec(t)?.[1]??null}function w(t){const n=new TextDecoder(
2
- "windows-1252").decode(t.subarray(0,2048));return/<meta[^>]+charset\s*=\s*["']?([^\s"'/>;]+)/i.exec(n)?.[1]??/<meta[^>]+content\s*=\s*["'][^"']*charset\s*=\s*([^\s"';]+)/i.exec(n)?.[1]??null}function u(t,n,c=!0){
3
- try{return new TextDecoder(n,{fatal:c}).decode(t)}catch{return null}}function l(t){let n=0;const c=new Map;for(const r of t){r==="�"?n-=100:/\p{L}|\p{N}/u.test(r)&&(n+=1);for(const[s,e]of[["cjk",/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u],
4
- ["hangul",/\p{Script=Hangul}/u],["cyrillic",/\p{Script=Cyrillic}/u],["arabic",/\p{Script=Arabic}/u]])e.test(r)&&c.set(s,(c.get(s)??0)+1);const i=r.codePointAt(0)??0;(i<32&&!`
5
- \r `.includes(r)||i>=127&&i<160)&&(n-=20)}for(const r of c.values())r>=2&&(n+=r*2);return n-=(t.match(/[ÃÂ]|â[\u0080-\u00bf]/g)??[]).length*8,n}function d(t,n={}){if(t[0]===239&&t[1]===187&&t[2]===
6
- 191)return new TextDecoder("utf-8").decode(t.subarray(3));if(t[0]===255&&t[1]===254)return new TextDecoder("utf-16le").decode(t.subarray(2));if(t[0]===254&&t[1]===255){const e=t.subarray(2).slice();for(let o=0;o+
7
- 1<e.length;o+=2)[e[o],e[o+1]]=[e[o+1],e[o]];return new TextDecoder("utf-16le").decode(e)}const c=p(n.mimeType??"")??(n.kind==="html"?w(t):null);if(c){const e=u(t,c,!1);if(e!==null)return e}const r=u(t,
8
- "utf-8",!0);if(r!==null)return r;let i=new TextDecoder("windows-1252").decode(t),s=l(i);for(const e of f){const o=u(t,e,!0);if(o===null)continue;const a=l(o);a>s&&(i=o,s=a)}return i}async function y(t,n="\
9
- plain"){const c=new Uint8Array(await t.arrayBuffer());return d(c,{kind:n,mimeType:t.type})}export{d as decodeTextBytes,y as decodeTextFile};
@@ -1,55 +0,0 @@
1
- import{a as A}from"./engine-TnK8N-gT.js";import{b as C}from"./TableGrid-DbroRucl.js";import{d as v}from"./BlockDiff-BdlcKY-t.js";function S(d,e,n){const t=(o,c)=>o.length>0&&o.every(l=>l.type==="parag\
2
- raph"&&l.children.length>0&&l.children.every(r=>r.marks?.[c]&&!r.marks.layeredInsertion));if(!t(d,"deletion")||!t(e,"insertion"))return null;const s=v(d,e,{nextId:n,nextBlockId:A,label:"Revise bill",authorOf:o=>o?.
3
- suggestionAuthorName});return s?s.blocks:null}const k={division:0,title:0,subtitle:0,chapter:0,subchapter:0,part:0,subpart:0,section:0,subsection:1,paragraph:2,subparagraph:3,clause:4,subclause:5,item:6,
4
- subitem:7},E={division:"Division",title:"Title",subtitle:"Subtitle",chapter:"Chapter",subchapter:"Subchapter",part:"Part",subpart:"Subpart",section:"Sec."},y=new Set(["added-phrase","deleted-phrase","\
5
- bold","italic","underline","strike","superscript","subscript","quote","term","short-title","act-name","external-xref","internal-xref","enum-in-header","header-in-text","definition","linebreak","nobrea\
6
- k","sponsor","cosponsor","committee-name","text-to-insert","text-to-strike-out","omitted-text","inline-comment"]),M=new Set(["graphic","formula","footnote","footnote-ref","spanspec","entrytbl"]),m=d=>Array.
7
- from(d.children),g=(d,e)=>m(d).find(n=>n.localName===e),b=d=>d.replace(/[\t\r\n ]+/g," "),I={id:"us-congress-bill",label:"U.S. Congressional bills (bill.dtd)",matches(d){const e=d.documentElement;if(e.
8
- localName!=="bill"||e.namespaceURI||!g(e,"legis-body"))return!1;const n=d.doctype;if(n)return n.name==="bill"&&(n.publicId==="-//US Congress//DTDs/bill.dtd//EN"||!n.publicId&&/(?:^|\/)bill\.dtd$/i.test(
9
- n.systemId));const t=g(e,"form");return!!t&&!!g(t,"congress")&&!!g(t,"legis-num")},parse(d){return new q().parse(d)}};class q{constructor(){this.revisionCount=0,this.revisions=new WeakMap,this.committees=
10
- new Map,this.usedIds=new Set}id(){let e;do e=A();while(this.usedIds.has(e));return this.usedIds.add(e),e}parse(e){const n=e.documentElement;for(const i of Array.from(n.getElementsByTagName("committee-\
11
- name"))){const h=i.getAttribute("committee-id");h&&this.committees.set(h,b(i.textContent??"").trim())}for(const i of Array.from(n.getElementsByTagName("*")))if(M.has(i.localName))throw new Error(`Unsu\
12
- pported Congressional XML element: <${i.localName}>. This bill requires content the XML importer does not yet support.`);const t=this.context(n,{marks:{},indent:0,quoted:0}),s=[],o=m(n),c=o.map(i=>this.
13
- blocks(i,t));for(let i=0;i<o.length;i++){const h=o[i],p=c[i],f=o[i+1];if(h.localName==="legis-body"&&f?.localName==="legis-body"&&f.getAttribute("display-enacting-clause")==="no-display-enacting-claus\
14
- e"){const T=c[i+1],N=h.getAttribute("display-enacting-clause")!=="no-display-enacting-clause"?1:0,w=S(p.slice(N),T,()=>`congressdiff-${++this.revisionCount}`);if(w){s.push(...p.slice(0,N),...w),i++;continue}}
15
- s.push(...p)}if(!s.length)throw new Error("The Congressional XML bill contains no readable content.");const l=g(n,"form"),r=l&&g(l,"legis-num")?.textContent?.trim(),a=n.getElementsByTagName("short-tit\
16
- le")[0]?.textContent?.trim(),u=r?[r,a].filter(Boolean).join(" — "):e.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/","title")[0]?.textContent?.trim();return{type:"doc",children:s,...u?{title:u}:
17
- {}}}context(e,n){const t={...n.marks},s=e.localName,o=e.getAttribute("changed")??(s==="added-phrase"?"added":s==="deleted-phrase"?"deleted":null);if(o==="added"||o==="deleted"){const l=o==="added"?"in\
18
- sertion":"deletion",r=e.getAttribute("reporting-committee")||e.getAttribute("committee-id"),a=r?this.committees.get(r)??r:void 0;if(!t[l]||a&&a!==t.suggestionAuthorName){if(t.deletion&&l==="insertion")
19
- throw new Error("Unsupported Congressional XML revision: insertion nested inside a deletion.");let u=this.revisions.get(e);u||(u={[l]:!0,suggestionId:`congressrev-${++this.revisionCount}`,suggestionSource:"\
20
- manual",suggestionAuthorType:"human",suggestionLabel:l==="insertion"?"Insert":"Delete",...a?{suggestionAuthorName:a}:{}},this.revisions.set(e,u)),t.insertion&&l==="deletion"&&(t.layeredInsertion=JSON.
21
- stringify({id:t.suggestionId,source:t.suggestionSource,authorType:t.suggestionAuthorType,authorName:t.suggestionAuthorName,label:t.suggestionLabel})),delete t.insertion,delete t.deletion,delete t.suggestionAuthorName,
22
- Object.assign(t,u)}}s==="bold"&&(t.bold=!0),s==="italic"&&(t.italic=!0),s==="underline"&&(t.underline=!0),s==="superscript"&&(t.superscript=!0),s==="subscript"&&(t.subscript=!0);const c=e.getAttribute(
23
- "href");return c&&/^(https?:\/\/|#)/i.test(c.trim())&&(t.link=c.trim()),s==="internal-xref"&&e.getAttribute("idref")&&(t.link=`#${e.getAttribute("idref")}`),{...n,marks:t,style:e.getAttribute("style")??
24
- n.style}}text(e,n){return{type:"text",text:e,marks:{...n.marks}}}inline(e,n){const t=this.context(e,n);if(e.localName==="linebreak")return[this.text(`
25
- `,t)];const s=[],o=e.localName==="quote"||e.localName==="term";o&&s.push(this.text(t.quoted?"‘":"“",t));for(const c of Array.from(e.childNodes))c.nodeType===3||c.nodeType===4?s.push(this.text(b(c.
26
- textContent??""),t)):c.nodeType===1&&s.push(...this.inline(c,o?{...t,quoted:t.quoted+1}:t));return o&&s.push(this.text(t.quoted?"’":"”",t)),s}paragraph(e,n,t,s){for(;e.length&&!e[0].text.trim();)e.
27
- shift();for(;e.length&&!e[e.length-1].text.trim();)e.pop();if(!e.length)return null;e[0].text=e[0].text.replace(/^ +/,""),e[e.length-1].text=e[e.length-1].text.replace(/ +$/,""),n.quoted&&e.unshift(this.
28
- text(n.quoted>1?"‘":"“",n));const o=t?.getAttribute("id");return o&&(e[0].marks={...e[0].marks,bookmark:o}),{type:"paragraph",id:this.id(),children:e,...s?{heading:s,keepNext:!0}:{},...n.indent?{leftIndent:Math.
29
- min(n.indent,6)}:{}}}blocks(e,n){const t=e.localName;if(t==="metadata")return[];const s=this.context(e,n);if(Object.prototype.hasOwnProperty.call(k,t))return this.structure(e,{...s,indent:k[t]+(s.quoted?
30
- 1:0)});if(t==="table")return m(e).filter(r=>r.localName==="tgroup").length?m(e).flatMap(r=>r.localName==="tgroup"?[this.table(r,this.context(r,s))]:this.blocks(r,s)):[this.table(e,s)];if(t==="quoted-b\
31
- lock"){const r=m(e).filter(i=>i.localName!=="after-quoted-block").flatMap(i=>this.blocks(i,{...s,quoted:s.quoted+1,indent:s.indent+1})),a=r[r.length-1],u=g(e,"after-quoted-block");if(a?.type==="paragr\
32
- aph")a.children.push(this.text(s.quoted?"’":"”",s)),u&&a.children.push(...this.inline(u,s));else if(u){const i=this.paragraph([this.text(s.quoted?"’":"”",s),...this.inline(u,s)],s);i&&r.push(i)}
33
- return r}if(!m(e).some(r=>!y.has(r.localName))){const r=this.paragraph(this.inline(e,n),s,e);if(r&&(t==="legis-num"||t==="legis-type")){r.align="center";for(const a of r.children)a.marks={...a.marks,bold:!0}}
34
- return r?[r]:[]}const o=[];if(t==="legis-body"&&e.getAttribute("display-enacting-clause")!=="no-display-enacting-clause"){const r=this.paragraph([this.text("Be it enacted by the Senate and House of Re\
35
- presentatives of the United States of America in Congress assembled,",s)],s);r&&o.push(r)}let c=[];const l=()=>{const r=this.paragraph(c,s);r&&o.push(r),c=[]};for(const r of Array.from(e.childNodes))if(r.
36
- nodeType===3||r.nodeType===4)c.push(this.text(b(r.textContent??""),s));else if(r.nodeType===1){const a=r;y.has(a.localName)?c.push(...this.inline(a,s)):(l(),o.push(...this.blocks(a,s)))}return l(),o}structure(e,n){
37
- const t=[],s=Object.prototype.hasOwnProperty.call(E,e.localName),o=g(e,"enum"),c=g(e,"header");let l=[];if(o&&(s&&l.push(this.text(e.localName==="section"&&n.style==="USC"?"§ ":`${E[e.localName]} `,n)),
38
- l.push(...this.inline(o,n),this.text(" ",n))),c){const u=this.inline(c,n);for(const i of u)i.marks={...i.marks,bold:!0};l.push(...u)}const r=(u=!1)=>{const i=this.paragraph(l,n,t.length?void 0:e,u?e.localName===
39
- "section"?2:1:void 0);i&&t.push(i),l=[]};s&&r(!0);let a=!0;for(const u of Array.from(e.childNodes))if(!(u===o||u===c)){if(u.nodeType===3||u.nodeType===4)u.textContent?.trim()&&l.push(this.text(b(u.textContent),
40
- n));else if(u.nodeType===1){const i=u;if(i.localName==="text")a||r(),a&&!s&&c&&l.push(this.text(".—",n)),l.push(...this.inline(i,n)),a=!1;else if(y.has(i.localName))l.push(...this.inline(i,n));else{
41
- r();const h=this.blocks(i,n),p=t[t.length-1];i.getAttribute("display-inline")==="yes-display-inline"&&p?.type==="paragraph"&&!p.heading&&h[0]?.type==="paragraph"&&(p.children.push(this.text(" ",n),...h[0].
42
- children),h.shift()),t.push(...h)}}}return r(),t}table(e,n){const t=g(e,"tgroup")??e,s=new Map(m(t).filter(r=>r.localName==="colspec").map((r,a)=>[r.getAttribute("colname"),Number(r.getAttribute("coln\
43
- um"))||a+1])),o=m(t).flatMap(r=>r.localName==="row"?[r]:["thead","tbody","tfoot"].includes(r.localName)?m(r).filter(a=>a.localName==="row"):[]);if(!o.length)throw new Error("Unsupported Congressional \
44
- XML table: no rows.");const c={type:"table",id:this.id(),columnWidths:[],children:o.map(r=>({type:"table-row",id:this.id(),children:m(r).filter(a=>a.localName==="entry").map(a=>{const u=s.get(a.getAttribute(
45
- "namest")),i=s.get(a.getAttribute("nameend")),h=u&&i?i-u+1:1,p=Number(a.getAttribute("morerows")??0)+1;if(a.hasAttribute("namest")&&(!u||!i)||!Number.isInteger(h)||h<1||h>100||!Number.isInteger(p)||p<
46
- 1||p>o.length)throw new Error("Unsupported Congressional XML table: invalid cell span.");const f=this.blocks(a,{...this.context(r,r.parentElement&&r.parentElement!==t?this.context(r.parentElement,n):n),
47
- indent:0});return{type:"table-cell",id:this.id(),children:f.length?f:[{type:"paragraph",id:this.id(),children:[{type:"text",text:""}]}],...h>1?{colSpan:h}:{},...p>1?{rowSpan:p}:{}}})}))},l=C(c).cols;if(!l||
48
- l>100)throw new Error("Unsupported Congressional XML table: invalid column count.");return c.columnWidths=Array(l).fill(100/l),c}}const x=[I];class L{static async parseFile(e){return this.fromBytes(new Uint8Array(
49
- await e.arrayBuffer()))}static fromBytes(e){let n="utf-8";if(e[0]===255&&e[1]===254||e[0]===60&&e[1]===0&&e[2]===63&&e[3]===0)n="utf-16le";else if(e[0]===254&&e[1]===255||e[0]===0&&e[1]===60&&e[2]===0&&
50
- e[3]===63)n="utf-16be";else if(!(e[0]===239&&e[1]===187&&e[2]===191)){const s=new TextDecoder("windows-1252").decode(e.subarray(0,512));n=/^<\?xml\s[^?]*\bencoding\s*=\s*["']([^"']+)["']/i.exec(s)?.[1]??
51
- n}let t;try{t=new TextDecoder(n,{fatal:!0}).decode(e)}catch{throw new Error(`Invalid or unsupported XML encoding: ${n}.`)}return this.fromXml(t)}static fromXml(e){if(/<!ENTITY\s/i.test(e))throw new Error(
52
- "XML entity declarations are not supported.");const n=new DOMParser().parseFromString(e.replace(/^\uFEFF/,""),"application/xml");if(!n.documentElement||n.getElementsByTagName("parsererror").length)throw new Error(
53
- "Invalid XML: the document is not well-formed.");const t=[[n.documentElement,0]];for(;t.length;){const[o,c]=t.pop();if(c>128)throw new Error("XML nesting exceeds the supported depth (128).");for(const l of Array.
54
- from(o.children))t.push([l,c+1])}const s=x.find(o=>o.matches(n));if(!s)throw new Error(`Unsupported XML schema: <${n.documentElement.tagName}>. Supported: ${x.map(o=>o.label).join(", ")}.`);return s.parse(
55
- n)}}export{x as XML_SCHEMA_PARSERS,L as XmlConverter};