@reviseio/engine 0.0.0-stage → 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.
- package/CHANGELOG.md +21 -0
- package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
- package/FONT-LICENSE-KATEX.txt +95 -0
- package/FONT-LICENSE-LIBERATION.txt +102 -0
- package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
- package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
- package/FONT-LICENSE-NOTO.txt +94 -0
- package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
- package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
- package/LICENSE +141 -0
- package/README.md +11 -2
- package/THIRD-PARTY-NOTICES.md +3376 -0
- package/assets/historyMaterializeWorker-Kl0syEbc.js +618 -0
- package/chunks/AgentHtmlConverter-CnnB8-WI.js +379 -0
- package/chunks/AgentPageRenderViews-BTLjPZJQ.js +2 -0
- package/chunks/AgentPageRenderer-DLgUGrGy.js +180 -0
- package/chunks/BidiText-Bkp4Y90s.js +160 -0
- package/chunks/BlockDiff-B6-aJxHo.js +42 -0
- package/chunks/CanvasRenderer-C1Vegx9Y.js +110 -0
- package/chunks/ColorParserFull-BKH72fK8.js +446 -0
- package/chunks/DocumentCompare-C8295s35.js +6 -0
- package/chunks/DocumentLayout-CsU5MR-3.js +12 -0
- package/chunks/DocumentLayoutEngine-C62pyGVf.js +218 -0
- package/chunks/DocumentMutator-Bat_oLBQ.js +13 -0
- package/chunks/DocumentScrubber-BZQn_z92.js +21 -0
- package/chunks/DocumentSession-BDcazSEv.js +1 -0
- package/chunks/DocumentStylesheet-CEEt18sr.js +7 -0
- package/chunks/DocxConverter-BC31uYIL.js +1236 -0
- package/chunks/DocxGraft-L10HXM3U.js +8 -0
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -0
- package/chunks/HtmlConverter-C5ihhZ6G.js +267 -0
- package/chunks/ListNumbering-Qlu6AuRZ.js +23 -0
- package/chunks/MarkdownConverter-DofaSeC4.js +57 -0
- package/chunks/MathRenderer-Bz9WEVvF.js +68 -0
- package/chunks/OdtConverter-c1fTWoAt.js +125 -0
- package/chunks/OfficeImportShared-CrOpHpJ-.js +30 -0
- package/chunks/PageNumeralFonts-BWzI061X.js +5 -0
- package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
- package/chunks/PdfConverter-DX7fsRH5.js +457 -0
- package/chunks/RtfConverter-hbJ2529G.js +186 -0
- package/chunks/TableBorders-DVhdvo6f.js +32 -0
- package/chunks/TableGrid-DbroRucl.js +12 -0
- package/chunks/TextDecoding-IPbuUqcC.js +2 -0
- package/chunks/TextFileDecoder-BZBBejlR.js +10 -0
- package/chunks/TxtConverter-YHv5FXWb.js +14 -0
- package/chunks/Typography-B4gndEdB.js +28 -0
- package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
- package/chunks/XmlConverter-BRRluy9k.js +55 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -0
- package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
- package/chunks/base64-Di1bxoXD.js +1 -0
- package/chunks/browser-module-CFmqfGkE.js +1791 -0
- package/chunks/bundle.min-DRpfgV69.js +782 -0
- package/chunks/capture-i_dPkQIS.js +11 -0
- package/chunks/carrier-pYM9xf6x.js +6 -0
- package/chunks/chromeImageLayout-BiQ3Iz1-.js +18 -0
- package/chunks/engine-LMUnxdm2.js +520 -0
- package/chunks/footnoteFlatten-EE85Hjre.js +6 -0
- package/chunks/graftExport-G-dG7Vcc.js +104 -0
- package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
- package/chunks/index-BLb10wQt.js +1002 -0
- package/chunks/index-BWdRWxoH.js +1807 -0
- package/chunks/index.es-CI0QPo8w.js +780 -0
- package/chunks/jspdf.es.min-DU74zN8b.js +1792 -0
- package/chunks/jszip.min-CPW0h1Kx.js +476 -0
- package/chunks/katex-DWj8TvwO.js +1462 -0
- package/chunks/pdf-BLWDCiFF.js +1828 -0
- package/chunks/purify.es-BwLardii.js +107 -0
- package/chunks/serverDocumentSession-DGDU5Lh3.js +1011 -0
- package/chunks/signatures-DTNDS2PH.js +21 -0
- package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
- package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
- package/chunks/xmlScan-DXjt2cTS.js +8 -0
- package/engine.d.ts +179 -0
- package/engine.js +3 -0
- package/package.json +64 -4
- package/serverToolContract.d.ts +420 -0
- package/serverToolInputs.generated.d.ts +264 -0
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import*as S from"yjs";import"y-protocols/awareness";const sn=[{id:"markdown",label:"Markdown",extensions:[".md",".markdown"],mimeType:"text/markdown",binary:!1,import:!0,export:!0},{id:"txt",label:"Pl\
|
|
2
|
+
ain text",extensions:[".txt"],mimeType:"text/plain",binary:!1,import:!0,export:!0},{id:"html",label:"HTML",extensions:[".html",".htm"],mimeType:"text/html",binary:!1,import:!0,export:!0},{id:"docx",label:"\
|
|
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
|
+
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
|
+
".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-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
|
+
ly: "+t)}}const qr=Object.freeze(Object.defineProperty({__proto__:null,DOCUMENT_FORMATS:sn,detectDocumentFormat:cn,parseDocumentFormat:ln,serializeDocumentFormat:at},Symbol.toStringTag,{value:"Module"})),
|
|
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
|
+
:${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(
|
|
18
|
+
r),16777619);return(n>>>0).toString(36)}function dn(e){const t=Y(e).get(Te);return typeof t=="string"&&t!==ct(se(e))}function Oe(e){const t=se(e);return Array.isArray(t)?t:[]}const fn=new WeakMap,lt=new WeakMap;
|
|
19
|
+
function Jr(e){let t=fn.get(e);if(!t){const n={version:0};Y(e).observe(()=>{n.version++}),fn.set(e,n),t=n}return t.version}function Le(e){lt.delete(e)}function gn(e){if(dn(e))return Oe(e);const t=Y(e),
|
|
20
|
+
n=Oe(e).filter(i=>!t.has(Re(i.side,i.slot))),r=un.flatMap(([i,a])=>{const o=t.get(Re(i,a));return Array.isArray(o)?o:[]});return[...n,...r]}function ut(e){const t=se(e),n=Jr(e),r=lt.get(e);if(r&&r.legacy===
|
|
21
|
+
t&&r.version===n)return r.records;const i=gn(e),a=i.length>0?i:void 0;return lt.set(e,{legacy:t,version:n,records:a}),a}function Yr(e,t,n){return(ut(e)??[]).filter(r=>r.side===t&&r.slot===n)}function Kr(e,t,n,r){
|
|
22
|
+
Le(e),Zr(e);const i=Re(t,n),a=Y(e);r.length>0?a.set(i,r):Oe(e).some(o=>o.side===t&&o.slot===n)?a.set(i,[]):a.has(i)&&a.delete(i),mn(e)}function Zr(e){dn(e)&&pn(e,Oe(e))}function pn(e,t){const n=Y(e);for(const[
|
|
23
|
+
r,i]of un){const a=Re(r,i),o=t.filter(s=>s.side===r&&s.slot===i);o.length>0?n.set(a,o):n.has(a)&&n.delete(a)}n.set(Te,ct(se(e)))}function mn(e){Le(e);const t=gn(e);e.getMap("metadata").set(st,t.map(n=>({
|
|
24
|
+
...n}))),Y(e).set(Te,ct(se(e))),Le(e)}function hn(e,t){Le(e);const n=Y(e);for(const r of Array.from(n.keys()))r!==Te&&n.delete(r);e.getMap("metadata").set(st,[]),pn(e,t??[]),mn(e)}const ce=["lineSpaci\
|
|
25
|
+
ng","spaceBefore","spaceAfter"];function Qr(e,t){for(const n of ce)t[n]!==void 0?e.setAttribute(n,String(t[n])):e.doc&&e.removeAttribute(n)}const bn=128,eo=1<<29,E=(e,t)=>e>>>t|e<<32-t,to=e=>E(e,2)^E(
|
|
26
|
+
e,13)^E(e,22),no=e=>E(e,6)^E(e,11)^E(e,25),ro=e=>E(e,7)^E(e,18)^e>>>3,oo=e=>E(e,17)^E(e,19)^e>>>10,io=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,
|
|
27
|
+
3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,
|
|
28
|
+
3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,
|
|
29
|
+
4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ao=new Uint32Array(
|
|
30
|
+
[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class so{constructor(){const t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(ao),this._W=new Uint32Array(
|
|
31
|
+
t,64,64)}_updateHash(){const t=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=oo(n[d-2])+n[d-7]+ro(n[d-15])+n[d-16];let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7];for(let d=0,g,p;d<64;d++)g=
|
|
32
|
+
u+no(s)+(s&c^~s&l)+io[d]+n[d]>>>0,p=to(r)+(r&i^r&a^i&a)>>>0,u=l,l=c,c=s,s=o+g>>>0,o=a,a=i,i=r,r=g+p>>>0;t[0]+=r,t[1]+=i,t[2]+=a,t[3]+=o,t[4]+=s,t[5]+=c,t[6]+=l,t[7]+=u}digest(t){let n=0;for(;n+56<=t.length;){
|
|
33
|
+
let o=0;for(;o<16&&n+3<t.length;o++)this._W[o]=t[n++]<<24|t[n++]<<16|t[n++]<<8|t[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<t.length;)this._W[o]|=t[n]<<(3-n%4)*8,n++;this._W[o]|=bn<<(3-n%4)*8}this._updateHash()}
|
|
34
|
+
const r=n%64!==0;this._W.fill(0,0,16);let i=0;for(;n<t.length;i++)for(let o=3;o>=0&&n<t.length;o--)this._W[i]|=t[n++]<<o*8;r||(this._W[i-(n%4===0?0:1)]|=bn<<(3-n%4)*8),this._W[14]=t.byteLength/eo,this.
|
|
35
|
+
_W[15]=t.byteLength*8,this._updateHash();const a=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let s=0;s<4;s++)a[o*4+s]=this._H[o]>>>(3-s)*8;return a}}const co=e=>new so().digest(e),Ee="revi\
|
|
36
|
+
se:styles:v1",yn="sharedStylesVersion",lo=Symbol.for("revise.shared-styles.migration"),B="_reviseTextStyle",je="_reviseParagraphStyle",uo=Object.freeze({_reviseStyleUnset:1}),X=new Set(["fontFamily","\
|
|
37
|
+
fontSize","bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","allCaps","superscript","subscript","hidden","color","backgroundColor","letterSpacing","lang","code","docxRunPro\
|
|
38
|
+
pertyResets","oxmlRPr"]),le=new Set(["align","lineSpacing","spaceBefore","spaceAfter","contextualSpacing","direction","tabStops","borders","shading","leftIndent","firstLineIndent","pagination"]);class K extends Error{constructor(){
|
|
39
|
+
super(...arguments),this.name="SharedStyleError"}}function dt(e){return JSON.stringify(Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null).sort(([t],[n])=>t<n?-1:t>n?1:0)))}function xn(e,t){return`${e}\
|
|
40
|
+
:${Array.from(co(new TextEncoder().encode(t)).subarray(0,16),n=>n.toString(16).padStart(2,"0")).join("")}`}function z(e){return!!e?.share.has("metadata")&&e.getMap("metadata").get(yn)===1}function ft(e,t,n){
|
|
41
|
+
const r=dt(n),i=xn(t,r),a=e.getMap(Ee),o=a.get(i);if(o!==void 0&&o!==r)throw new K("Shared style identity collision or modified definition");return o===void 0&&a.set(i,r),i}const Sn=new WeakMap;function gt(e,t,n){
|
|
42
|
+
if(t==null)return{};if(!e||typeof t!="string"||!t.startsWith(`${n}:`))throw new K("Invalid shared style reference");const r=e.getMap(Ee).get(t);if(typeof r!="string")throw new K("Missing shared style \
|
|
43
|
+
definition; resync the document");let i=Sn.get(e);i||Sn.set(e,i=new Map);const a=i.get(t);if(a?.json===r)return a.marks;if(xn(n,r)!==t)throw new K("Modified shared style definition");const o=JSON.parse(
|
|
44
|
+
r),s=n==="t"?X:le;if(!o||typeof o!="object"||Array.isArray(o)||Object.entries(o).some(([c,l])=>!s.has(c)||!["string","number","boolean"].includes(typeof l)))throw new K("Invalid shared style propertie\
|
|
45
|
+
s");return Object.freeze(o),i.size>=4096&&i.clear(),i.set(t,{json:r,marks:o}),o}function fo(e,t={}){const n={...gt(e.doc,t[B],"t"),...t};delete n[B];for(const[r,i]of Object.entries(t))X.has(r)&&i!==null&&
|
|
46
|
+
typeof i=="object"&&i._reviseStyleUnset===1&&Object.keys(i).length===1&&delete n[r];return n}function ue(e){if(!z(e.doc))return e.toDelta();const t=[];for(const n of e.toDelta()){const r=fo(e,n.attributes),
|
|
47
|
+
i={...n};Object.keys(r).length?i.attributes=r:delete i.attributes;const a=t[t.length-1];a&&typeof a.insert=="string"&&typeof i.insert=="string"&&dt(a.attributes??{})===dt(i.attributes??{})?a.insert+=i.
|
|
48
|
+
insert:t.push(i)}return t}function wn(e,t,n,r){if(B in r)throw new K("Existing style bases are immutable");if(!e.doc||!z(e.doc)||!Object.keys(r).some(i=>X.has(i))){e.format(t,n,r);return}e.doc.transact(
|
|
49
|
+
()=>{let i=t;for(const a of kn(e,t,n,r))e.format(i,a.retain,a.attributes),i+=a.retain})}function kn(e,t,n,r){if(!Object.entries(r).some(([o,s])=>X.has(o)&&s===null))return[{retain:n,attributes:r}];const i=[];
|
|
50
|
+
let a=0;for(const o of e.toDelta()){const s=a+(typeof o.insert=="string"?o.insert.length:1),c=Math.min(s,t+n)-Math.max(a,t);if(c>0){const l=gt(e.doc,o.attributes?.[B],"t");i.push({retain:c,attributes:Object.
|
|
51
|
+
fromEntries(Object.entries(r).map(([u,d])=>[u,X.has(u)&&d===null&&u in l?uo:d]))})}if(a=s,a>=t+n)break}return i}function Be(e,t){const n=Object.fromEntries(Object.entries(t).filter(([i,a])=>X.has(i)&&
|
|
52
|
+
a!==null&&a!==void 0));if(Object.keys(n).length<2)return{...t};const r=Object.fromEntries(Object.entries(t).filter(([i])=>!X.has(i)));return r[B]=ft(e,"t",n),r}function de(e,t,n,r){if(!r||!e.doc||!z(e.
|
|
53
|
+
doc)){e.insert(t,n,r);return}e.doc.transact(()=>e.insert(t,n,Be(e.doc,r)))}function go(e,t,n){if(!e.doc||!z(e.doc)){e.applyDelta(t,n);return}e.doc.transact(()=>{let r=0;const i=t.flatMap(a=>{const o=r;
|
|
54
|
+
return a.retain!==void 0?r+=a.retain:a.delete!==void 0&&(r+=a.delete),a.attributes?a.insert!==void 0?[{...a,attributes:Be(e.doc,a.attributes)}]:a.retain!==void 0?kn(e,o,a.retain,a.attributes):[a]:[a]});
|
|
55
|
+
e.applyDelta(i,n)})}function Z(e,t){const n=e.getAttribute(t);return n!=null||!le.has(t)||!e.doc?n:gt(e.doc,e.getAttribute(je),"p")[t]}function pt(e,t){e.doc&&z(e.doc)&&le.has(t)?e.setAttribute(t,""):
|
|
56
|
+
e.removeAttribute(t)}function po(e,t){const n=Object.fromEntries(Object.entries(t).filter(([r,i])=>le.has(r)&&i!==""));return Object.keys(n).length<2?t:{...Object.fromEntries(Object.entries(t).filter(
|
|
57
|
+
([r])=>!(r in n))),[je]:ft(e,"p",n)}}function mo(e,t){if(!t.exclusive)throw new K("Shared style migration requires exclusive access");let n=0,r=0;const i=e.getMap(Ee).size;return e.transact(()=>{z(e)||
|
|
58
|
+
e.getMap("metadata").set(yn,1);const a=o=>{if(o?.constructor?.name==="YXmlText"||o?.constructor?.name==="YText"){let s=0;for(const c of o.toDelta()){const l=typeof c.insert=="string"?c.insert.length:1,
|
|
59
|
+
u=c.attributes??{};if(!u[B]){const d=Be(e,u);if(d[B]){const g={[B]:d[B]};for(const p of Object.keys(u))X.has(p)&&(g[p]=null);o.format(s,l,g),n++}}s+=l}}else if(typeof o?.toArray=="function"){if(o.nodeName===
|
|
60
|
+
"paragraph"&&!o.getAttribute(je)){const s={};for(const c of le){const l=o.getAttribute(c);typeof l=="string"&&l!==""&&(s[c]=l)}if(Object.keys(s).length>=2){o.setAttribute(je,ft(e,"p",s));for(const c of Object.
|
|
61
|
+
keys(s))o.removeAttribute(c);r++}}for(const s of o.toArray())a(s)}};for(const o of["content","chrome","notes"])e.share.has(o)&&a(e.getXmlFragment(o))},lo),{textSpans:n,paragraphs:r,definitions:e.getMap(
|
|
62
|
+
Ee).size-i}}const ho=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]];function vn(e){if(!Number.isFinite(e)||e<1)return"";let t=Math.
|
|
63
|
+
floor(e),n="";for(const[r,i]of ho)for(;t>=r;)n+=i,t-=r;return n}function bo(e){if(!/^[mdclxvi]+$/.test(e))return null;const t={m:1e3,d:500,c:100,l:50,x:10,v:5,i:1};let n=0;for(let r=0;r<e.length;r++){
|
|
64
|
+
const i=t[e[r]],a=t[e[r+1]]??0;n+=i<a?-i:i}return vn(n)===e?n:null}function yo(e,t){return t==="endnote"?vn(e):String(e)}function xo(e){return/^\d+$/.test(e)?"footnote":bo(e)!==null?"endnote":"footnot\
|
|
65
|
+
e"}const Pn=10*(96/72);function So(e){const t=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){n.forEach(t);return}const r=n;if(r.type==="text"){typeof r.marks?.fontSize!="number"&&(r.marks={
|
|
66
|
+
...r.marks??{},fontSize:Pn});return}t(r.children)};t(e)}function An(e){const t=e.notes;if(!t||t.length===0)return;const n=new Map;let r;const i=s=>{if(!s||typeof s!="object")return;if(Array.isArray(s)){
|
|
67
|
+
for(const l of s)i(l);return}const c=s;if(c.type==="text"){r===void 0&&typeof c.text=="string"&&c.text.length>0&&(r=c.marks?.fontFamily),c.marks?.footnoteRef&&!n.has(c.marks.footnoteRef)&&n.set(c.marks.
|
|
68
|
+
footnoteRef,c.marks?.fontFamily);return}c.children&&i(c.children)};i(e.children);let a=!1;const o=t.map(s=>{const c=s.id,l=n.has(c)?n.get(c)??r:r;let u=!1;const d=s.children.map(g=>{if(g.type!=="parag\
|
|
69
|
+
raph"||!Array.isArray(g.children))return g;let p=!1;const f=g.children.map(h=>{if(h.type!=="text")return h;const b=h.marks??{};if(b.fontFamily===l||l===void 0&&b.fontFamily===void 0)return h;p=!0;const x={
|
|
70
|
+
...b};return l===void 0?delete x.fontFamily:x.fontFamily=l,{...h,marks:x}});return p?(u=!0,{...g,children:f}):g});return u?(a=!0,{...s,children:d}):s});a&&(e.notes=o)}const Nn=["bold","italic","underl\
|
|
71
|
+
ine","strikethrough","doubleStrikethrough","smallCaps","allCaps","hidden","letterSpacing","lang","code","latex","superscript","subscript","fontSize","color","backgroundColor","fontFamily","link","foot\
|
|
72
|
+
noteRef","footnotePendingBody","footnotePendingKind","sdtInline"],wo=[...Nn,"aiGenerated","comment","field","bookmark","fieldInstr","oxmlRange","docxRunPropertyResets","oxmlRPr","__htmlClassName"],ko=[
|
|
73
|
+
"bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","allCaps","hidden","letterSpacing","code","latex","superscript","subscript","fontFamily","fontSize","color","backgroundCol\
|
|
74
|
+
or","link","footnotePendingBody"],vo=["bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","allCaps","letterSpacing","code","superscript","subscript","fontSize","color","backg\
|
|
75
|
+
roundColor","fontFamily","oxmlRPr"];function Po(e){if(!e)return;const t={};for(const n of vo)n in e&&e[n]!==void 0&&e[n]!==!1&&(t[n]=e[n]);return e.footnoteRef&&delete t.superscript,Object.keys(t).length>
|
|
76
|
+
0?t:void 0}const Ao=["align","heading","leftIndent","firstLineIndent","lineSpacing","spaceBefore","spaceAfter","contextualSpacing","keepNext","keepLines","widowControl","styleId","direction","borders",
|
|
77
|
+
"shading","tabStops"];function No(e,t){return Ao.every(n=>e[n]===t[n])}const fe={style:"single",width:1,color:"#A6A6A6"};function In(e={}){return JSON.stringify({bottom:{...fe,...e}})}const Io={thin:{},
|
|
78
|
+
thick:{width:3},double:{style:"double"},dashed:{style:"dashed"},dotted:{style:"dotted",width:2},stars:{style:"stars"},diamonds:{style:"diamonds"}},Mo=[{pattern:/^-\*\*-$/,style:"stars",contexts:["typi\
|
|
79
|
+
ng","markdown"]},{pattern:/^-<>-$/,style:"diamonds",contexts:["typing","markdown"]},{pattern:/^-{3,}$/,style:"thin",contexts:["typing"]},{pattern:/^_{3,}$/,style:"thick",contexts:["typing"]},{pattern:/^={3,}$/,
|
|
80
|
+
style:"double",contexts:["typing"]},{pattern:/^\*{3,}$/,style:"dotted",contexts:["typing"]},{pattern:/^([-*_])[ \t]*(?:\1[ \t]*){2,}$/,style:"thin",contexts:["markdown"]}];function Co(e,t){let n;{if(/^ {4,}/.
|
|
81
|
+
test(e))return null;n=e.trim()}for(const r of Mo)if(r.contexts.includes(t)&&r.pattern.test(n))return r.style;return null}const Fo=new Set(["single","dashed","dotted","double","none","stars","diamonds"]);
|
|
82
|
+
function Mn(e){if(e.type!=="paragraph"||!e.borders||e.shading!==void 0||e.heading!==void 0||e.styleId!==void 0||e.align!==void 0||e.leftIndent!==void 0||e.firstLineIndent!==void 0||e.tabStops!==void 0||
|
|
83
|
+
e.children.some(a=>a.text!==""))return null;let t;try{t=JSON.parse(e.borders)}catch{return null}const n=a=>a!=null&&a.style!=="none",r=t?.bottom;if(!n(r)||n(t.top)||n(t.left)||n(t.right))return null;const i=r.
|
|
84
|
+
style;return{style:i&&Fo.has(i)?i:fe.style,width:r.width??fe.width,color:r.color??fe.color}}const To=e=>Mn(e)!==null,Ro=new Set(["left","right","center","decimal"]),Oo=new Set(["dot","hyphen","undersc\
|
|
85
|
+
ore"]),_e=new Map,Lo=512;function Eo(e){if(!e)return null;const t=_e.get(e);if(t!==void 0)return t;let n=null;try{const r=JSON.parse(e);if(Array.isArray(r)){const i=[];for(const a of r)if(a&&typeof a==
|
|
86
|
+
"object"&&typeof a.pos=="number"&&Number.isFinite(a.pos)&&a.pos>=0&&typeof a.align=="string"&&Ro.has(a.align)){const o={pos:a.pos,align:a.align};typeof a.leader=="string"&&Oo.has(a.leader)&&(o.leader=
|
|
87
|
+
a.leader),i.push(o)}i.length>0&&(i.sort((a,o)=>a.pos-o.pos),n=i)}}catch{n=null}return _e.size>=Lo&&_e.clear(),_e.set(e,n),n}function $e(e){const t=[];return e.keepNext&&t.push("keepNext"),e.keepLines&&
|
|
88
|
+
t.push("keepLines"),e.widowControl===!1&&t.push("noWidow"),t.length>0?t.join(","):void 0}function Ge(e,t){if(!t)return;const n=new Set(t.split(","));n.has("keepNext")&&(e.keepNext=!0),n.has("keepLines")&&
|
|
89
|
+
(e.keepLines=!0),n.has("noWidow")&&(e.widowControl=!1)}function jo(e,t){return e.variant===t.variant&&e.startNumber===t.startNumber&&e.numberingChainId===t.numberingChainId&&e.numberingFormat===t.numberingFormat&&
|
|
90
|
+
e.lineSpacing===t.lineSpacing&&e.spaceBefore===t.spaceBefore&&e.spaceAfter===t.spaceAfter&&e.contextualSpacing===t.contextualSpacing}const Cn=e=>"type"in e&&e.type==="doc",Bo=e=>Cn(e)?!0:"type"in e?e.
|
|
91
|
+
type==="container"||e.type==="footnote"||e.type==="header-footer"||e.type==="table-cell":!1;function P(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t="";for(let n=0;n<
|
|
92
|
+
6;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return t}function _o(e=[{type:"text",text:"",marks:{}}]){return{type:"paragraph",id:P(),children:e}}function $o(e,t={}){return{type:"math",id:P(),
|
|
93
|
+
content:e,displayMode:t.displayMode??"block",align:t.align??"center"}}function Go(e){return{type:"paragraph",id:P(),children:[{type:"text",text:"",marks:{}}],borders:In(e)}}const mt=[{value:"arial",label:"\
|
|
94
|
+
Arial",cssValue:"Arial, sans-serif"},{value:"helvetica",label:"Helvetica",cssValue:"Helvetica, Arial, sans-serif"},{value:"times",label:"Times New Roman",cssValue:"'Times New Roman', Times, serif"},{value:"\
|
|
95
|
+
computermodern",label:"Computer Modern",cssValue:"KaTeX_Main, 'Times New Roman', serif"},{value:"georgia",label:"Georgia",cssValue:"Georgia, serif"},{value:"sourceserif4",label:"Source Serif 4",cssValue:"\
|
|
96
|
+
'Source Serif 4', serif"},{value:"garamond",label:"Garamond",cssValue:"Garamond, 'Times New Roman', serif"},{value:"palatino",label:"Palatino",cssValue:"'Palatino Linotype', Palatino, serif"},{value:"\
|
|
97
|
+
bookman",label:"Bookman",cssValue:"'Bookman Old Style', Bookman, serif"},{value:"verdana",label:"Verdana",cssValue:"Verdana, Geneva, sans-serif"},{value:"trebuchet",label:"Trebuchet MS",cssValue:"'Tre\
|
|
98
|
+
buchet MS', Helvetica, sans-serif"},{value:"courier",label:"Courier New",cssValue:"'Courier New', Courier, monospace"},{value:"lucida",label:"Lucida Console",cssValue:"'Lucida Console', Monaco, monosp\
|
|
99
|
+
ace"},{value:"impact",label:"Impact",cssValue:"Impact, Charcoal, sans-serif"},{value:"comicsans",label:"Comic Sans MS",cssValue:"'Comic Sans MS', cursive"}];function Xo(e){if(!e||e==="default")return"\
|
|
100
|
+
Arial, sans-serif";const t=mt.find(n=>n.value.includes(e.split(",")[0].trim()));return t?t.cssValue:"inherit"}const Fn={calibri:"'Calibri', 'Carlito', 'Helvetica Neue', Arial, sans-serif",cambria:"'Ca\
|
|
101
|
+
mbria', 'Caladea', Georgia, serif",aptos:"'Aptos', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif","segoe ui":"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",candara:"'Candara', 'Trebuchet MS', san\
|
|
102
|
+
s-serif",constantia:"'Constantia', Georgia, serif",corbel:"'Corbel', 'Segoe UI', sans-serif",tahoma:"Tahoma, 'Segoe UI', Geneva, sans-serif","franklin gothic":"'Franklin Gothic', 'Franklin Gothic Medi\
|
|
103
|
+
um', 'Arial Narrow', sans-serif","franklin gothic medium":"'Franklin Gothic Medium', 'Arial Narrow', sans-serif","century gothic":"'Century Gothic', 'Avant Garde', 'Futura', sans-serif","book antiqua":"\
|
|
104
|
+
'Book Antiqua', 'Palatino Linotype', Palatino, serif","century schoolbook":"'Century Schoolbook', 'New Century Schoolbook', serif","sitka text":"'Sitka Text', Georgia, serif",consolas:"Consolas, Menlo\
|
|
105
|
+
, Monaco, 'Courier New', monospace","helvetica neue":"'Helvetica Neue', Helvetica, Arial, sans-serif",avenir:"Avenir, 'Avenir Next', 'Century Gothic', sans-serif","avenir next":"'Avenir Next', Avenir,\
|
|
106
|
+
'Century Gothic', sans-serif",futura:"Futura, 'Century Gothic', sans-serif","gill sans":"'Gill Sans', 'Gill Sans MT', Calibri, sans-serif",optima:"Optima, Candara, 'Segoe UI', sans-serif",baskerville:"\
|
|
107
|
+
Baskerville, 'Libre Baskerville', Georgia, serif",didot:"Didot, 'Bodoni MT', Georgia, serif","hoefler text":"'Hoefler Text', Baskerville, Georgia, serif",charter:"Charter, 'Bitstream Charter', Georgia\
|
|
108
|
+
, serif","american typewriter":"'American Typewriter', 'Courier New', monospace",menlo:"Menlo, Consolas, Monaco, monospace",monaco:"Monaco, Menlo, Consolas, monospace",seravek:"Seravek, 'Segoe UI', sa\
|
|
109
|
+
ns-serif",roboto:"Roboto, 'Helvetica Neue', Arial, sans-serif","open sans":"'Open Sans', 'Segoe UI', Arial, sans-serif",lato:"Lato, 'Helvetica Neue', Arial, sans-serif",montserrat:"Montserrat, 'Centur\
|
|
110
|
+
y Gothic', sans-serif",inter:"Inter, 'Helvetica Neue', Arial, sans-serif","source sans pro":"'Source Sans Pro', 'Segoe UI', sans-serif","noto sans":"'Noto Sans', 'Helvetica Neue', Arial, sans-serif","\
|
|
111
|
+
noto serif":"'Noto Serif', Georgia, serif","pt serif":"'PT Serif', Georgia, serif","pt sans":"'PT Sans', 'Helvetica Neue', Arial, sans-serif",merriweather:"Merriweather, Georgia, serif","liberation sa\
|
|
112
|
+
ns":"'Liberation Sans', Arial, sans-serif","liberation serif":"'Liberation Serif', 'Times New Roman', serif",carlito:"'Carlito', 'Calibri', 'Helvetica Neue', sans-serif",caladea:"'Caladea', 'Cambria',\
|
|
113
|
+
Georgia, serif"},zo=["times","georgia","garamond","cambria","palatino","antiqua","baskerville","didot","bodoni","hoefler","charter","constantia","caladea","schoolbook","sitka","minion","merriweather",
|
|
114
|
+
"playfair","caslon","sabon","utopia","serif"],Do=["mono","courier","consol","menlo","monaco","typewriter","code","andale"];function ht(e){const t=e.toLowerCase();return Do.some(n=>t.includes(n))?"mono\
|
|
115
|
+
space":zo.some(n=>t.includes(n))?"serif":"sans-serif"}function D(e){return e.trim().replace(/^["']|["']$/g,"")}function bt(e){return/[^a-zA-Z0-9-]/.test(e)?`'${e}'`:e}const yt=new Map,Uo=["'Revise Not\
|
|
116
|
+
o SC'","'Revise Noto JP'","'Revise Noto KR'","'Revise Han Ext B'","'Revise Noto Arabic'","'Revise Noto Hebrew'","'Revise Noto Devanagari'","'Revise Noto Bengali'","'Revise Noto Gurmukhi'","'Revise Not\
|
|
117
|
+
o Gujarati'","'Revise Noto Oriya'","'Revise Noto Tamil'","'Revise Noto Telugu'","'Revise Noto Kannada'","'Revise Noto Malayalam'","'Revise Noto Sinhala'","'Revise Noto Thai'","'Revise Noto Lao'","'Rev\
|
|
118
|
+
ise Noto Khmer'","'Revise Noto Myanmar'","'Revise Noto Armenian'","'Revise Noto Kartvelian'","'Revise Noto Ethiopic'","'Revise Noto Syriac'","'Revise Noto Thaana'","'Revise Noto Tibetan'","'Revise Not\
|
|
119
|
+
o Symbols'","'Revise Noto Symbols 2'","'Revise Noto Emoji'"],Tn=Uo.join(", ");function Wo(e){const t=e?.toLowerCase().split(/[-_]/)[0];if(t==="ja")return"'Revise Noto JP'";if(t==="ko")return"'Revise N\
|
|
120
|
+
oto KR'";if(t==="zh")return"'Revise Noto SC'"}function Ho(e){if(e.includes("Revise Noto"))return e;const t=e.split(","),n=t.at(-1)?.trim();return n&&Xe.has(D(n).toLowerCase())?`${t.slice(0,-1).join(",")}\
|
|
121
|
+
, ${Tn}, ${n}`:`${e}, ${Tn}`}let xt={};function Rn(e){!e||Object.keys(e).length===0||(xt={...xt,...e},yt.clear())}function qo(e){const t=xt[e.toLowerCase()];if(!t)return;const n=[bt(e)];if(t.alt&&t.alt.
|
|
122
|
+
toLowerCase()!==e.toLowerCase()){const r=Fn[t.alt.toLowerCase()];n.push(r??bt(t.alt))}return n.push(t.generic??ht(e)),Vo(n.join(", "))}function Vo(e){const t=e.split(",").map(s=>s.trim()).filter(Boolean),
|
|
123
|
+
n=t.filter(s=>Xe.has(D(s).toLowerCase())),r=t.filter(s=>!Xe.has(D(s).toLowerCase())),i=new Set,a=r.filter(s=>{const c=D(s).toLowerCase();return i.has(c)?!1:(i.add(c),!0)}),o=n.at(-1);return o?[...a,o].
|
|
124
|
+
join(", "):a.join(", ")}function Jo(e){const t=yt.get(e);if(t!==void 0)return t;let n;if(e.includes(","))n=e;else{const r=D(e);n=Fn[r.toLowerCase()]??qo(r)??`${bt(r)}, ${ht(r)}`}return n=Ho(n),yt.set(
|
|
125
|
+
e,n),n}const Xe=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),On="mmmmmmmmmmlliWQ@#0123456789",Ln=72;let Q;function Yo(){
|
|
126
|
+
if(Q!==void 0)return Q;if(typeof document>"u")return Q=null,null;try{const e=document.createElement("canvas");e.width=4,e.height=4,Q=e.getContext("2d")}catch{Q=null}return Q??null}const En=new Map;function Ko(e){
|
|
127
|
+
const t=D(e.split(",")[0]);if(!t)return!1;if(Xe.has(t.toLowerCase()))return!0;const n=t.toLowerCase(),r=En.get(n);if(r!==void 0)return r;const i=Yo();if(!i)return!1;let a=!1;try{for(const o of["monosp\
|
|
128
|
+
ace","sans-serif","serif"]){i.font=`${Ln}px ${o}`;const s=i.measureText(On).width;i.font=`${Ln}px '${t}', ${o}`;const c=i.measureText(On).width;if(s>0&&Math.abs(c-s)>.5){a=!0;break}}}catch{a=!1}return En.
|
|
129
|
+
set(n,a),a}function Zo(){return typeof window<"u"&&"queryLocalFonts"in window}let ge=null;async function Qo(){if(ge)return ge;const e=await window.queryLocalFonts();return ge=e,e}async function ei(){if(!Zo())
|
|
130
|
+
return"denied";try{return(await navigator.permissions.query({name:"local-fonts"})).state}catch{return"prompt"}}async function ti(){return ge?!0:await ei()==="granted"}async function ni(){return ge||(await ti()?
|
|
131
|
+
await Qo():null)}function ri(e){if(e.length<4)return"unknown";const t=String.fromCharCode(e[0],e[1],e[2],e[3]);return t==="OTTO"?"otf":t==="ttcf"?"ttc":t==="true"||e[0]===0&&e[1]===1&&e[2]===0&&e[3]===
|
|
132
|
+
0?"ttf":"unknown"}function oi(e){const t=(e??"").toLowerCase();return{bold:t.includes("bold")||t.includes("black")||t.includes("heavy"),italic:t.includes("italic")||t.includes("oblique")}}const ii=new Set(
|
|
133
|
+
mt.map(e=>D(e.cssValue.split(",")[0]).toLowerCase()));function ai(e){const t=new Map,n=i=>{const a=i.marks?.fontFamily;if(!a)return;const o=D(a.split(",")[0]);if(!o)return;const s=o.toLowerCase();t.has(
|
|
134
|
+
s)||t.set(s,{value:a,family:o,available:Ko(o),builtin:ii.has(s)})},r=i=>{if(!(!i||typeof i!="object")){if(i.type==="text"){n(i);return}if(Array.isArray(i.children))for(const a of i.children)r(a)}};for(const i of e.
|
|
135
|
+
children)r(i);for(const i of e.chrome??[])r(i);for(const i of e.notes??[])r(i);return Array.from(t.values())}const ze=["bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","al\
|
|
136
|
+
lCaps","hidden","superscript","subscript"],si=new Set(["color","highlight"]);function ci(e){return ze.filter(t=>e[t]===!1)}function jn(e){const t=Array.from(new Set((e??"").split(",").map(n=>n.trim()).
|
|
137
|
+
filter(n=>si.has(n)))).sort();return t.length>0?t.join(","):void 0}function li(e,t,n){const r=new Set((t??"").split(",").map(a=>a.trim()).filter(Boolean));for(const a of ze)r.has(a)&&(e[a]=!1);const i=jn(
|
|
138
|
+
n);i&&(e.docxRunPropertyResets=i)}const pe="Arial, sans-serif",ui=new Set(ze);function St(e){const t=Bn(e);for(const n of ui)e?.[n]===!1&&(t[n]=!1);return t}function Bn(e){const t={};for(const[n,r]of Object.
|
|
139
|
+
entries(e??{}))r===!0?t[n]=!0:(typeof r=="string"&&r!==""||typeof r=="number")&&(t[n]=r);return t.fontFamily||(t.fontFamily=pe),t}function di(e){const t=e;return JSON.stringify(Object.keys(t).sort().map(
|
|
140
|
+
n=>[n,t[n]]))}function _n(e){const t=[];let n=null;for(const r of e){const i=di(r.marks??{}),a=t[t.length-1];if(a&&i===n){t[t.length-1]={...a,text:a.text+r.text};continue}t.push(r),n=i}return t}const fi=72/
|
|
141
|
+
96,gi={paddingPx:16,borderColor:"#cccccc",borderWidthPx:1},pi={cellPaddingPx:8,borderColor:"#cccccc",borderWidthPx:1},mi={maxIndentLevel:2,sublistIndentPx:20,markerWidthPx:20,variantIndentPx:{todo:35,
|
|
142
|
+
ordered:30,unordered:25},todoCheckboxSizePx:16,todoCheckboxRadiusPx:3,todoCheckboxOffsetPx:4},hi={fontSizePx:14,lineHeightMultiplier:1.5,paddingPx:12,borderRadiusPx:4,diagramMinHeightPx:120,diagramSourceGapPx:10},
|
|
143
|
+
bi={gutterPx:26,verticalPaddingPx:4,blockSpacingPx:2,separatorSpacePx:18,inlineEndnoteGapPx:10,separatorToContentPx:12,newPageSeparatorOffsetPx:6,minimumBodyLinesBeforeFootnotes:2,bodyKeepSlackPx:6,separatorWidthMinPx:96,
|
|
144
|
+
separatorWidthFraction:.3},U={paddingYPx:10,levelIndentPx:24,pageNumberGapPx:6,labelClipGapPx:12,leaderStartGapPx:4,minimumLeaderWidthPx:8},yi={displayHeightPx:20,indicatorInsetXPx:0,indicatorWidthPx:36,
|
|
145
|
+
caretOffsetXPx:12,iconInsetXPx:2,iconInsetYPx:2},xi={blockInsertMarkerMarginXPx:16,blockInsertMarkerOffsetYPx:13,blockInsertMarkerArmPx:4,blockInsertMarkerLineWidthPx:2,breakTintOpacity:.12,breakIconOpacity:.55,
|
|
146
|
+
tocTintOpacity:.08,placeholderTintOpacity:.25,tableTintOpacity:{insert:.08,delete:.06},tableRowTintOpacity:{insert:.2,delete:.15},tableRowRailOpacity:.8,tableCellRailWidthPx:2,pendingBreakLabelFontSizePx:10,
|
|
147
|
+
pendingBreakRuleStartPx:24,pendingBreakLabelGapPx:8,pendingBreakDashPx:3,pendingBreakRuleOpacity:.65,pendingBreakLabelOpacity:.9};let ee=null,wt=null;function $n(){return ee?Promise.resolve(ee):(wt||(wt=
|
|
148
|
+
import("./ColorParserFull-BKH72fK8.js").then(e=>(ee=e.parseCssColorFull,ee))),wt)}const Si=/\b(?:hwb|lab|lch|oklab|oklch|color|color-mix|device-cmyk|calc|var)\s*\(|\b(?:rgba?|hsla?)\s*\([^)]*(?:%|deg|rad|grad|turn|none)/i;
|
|
149
|
+
function wi(e){return Si.test(e)}const ki=Object.fromEntries("aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanchedalmond:ffe\
|
|
150
|
+
bcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00ffff,darkbl\
|
|
151
|
+
ue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkgrey:a9a9a9,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,darkred:8b\
|
|
152
|
+
0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkslategrey:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:696969,dimgr\
|
|
153
|
+
ey:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,greenyellow:a\
|
|
154
|
+
dff2f,grey:808080,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:add8e6,lig\
|
|
155
|
+
htcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgray:d3d3d3,lightgreen:90ee90,lightgrey:d3d3d3,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,lightslateg\
|
|
156
|
+
ray:778899,lightslategrey:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,mediumorchid:\
|
|
157
|
+
ba55d3,mediumpurple:9370db,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:ffe4e1,moc\
|
|
158
|
+
casin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afeeee,palevio\
|
|
159
|
+
letred:db7093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddlebrown:8b451\
|
|
160
|
+
3,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,slategrey:708090,snow:fffafa,springgreen:00ff7f,steelblue\
|
|
161
|
+
:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32".split(",").map(e=>e.split(":"))),
|
|
162
|
+
A="(-?\\d+(?:\\.\\d+)?|-?\\.\\d+)",vi=new RegExp(`^rgba?\\(\\s*${A}\\s*,\\s*${A}\\s*,\\s*${A}\\s*(?:,\\s*${A}\\s*)?\\)$`,"i"),Pi=new RegExp(`^rgba?\\(\\s*${A}\\s+${A}\\s+${A}\\s*(?:\\/\\s*${A}\\s*)?\\)$`,
|
|
163
|
+
"i"),Ai=new RegExp(`^hsla?\\(\\s*${A}\\s*,\\s*${A}%\\s*,\\s*${A}%\\s*(?:,\\s*${A}\\s*)?\\)$`,"i"),Ni=new RegExp(`^hsla?\\(\\s*${A}\\s+${A}%\\s+${A}%\\s*(?:\\/\\s*${A}\\s*)?\\)$`,"i"),kt=e=>Math.max(0,
|
|
164
|
+
Math.min(255,Math.round(e))),De=e=>Math.max(0,Math.min(1,e));function Gn(e){const t=e.length;if(t!==3&&t!==4&&t!==6&&t!==8||!/^[0-9a-f]+$/i.test(e))return null;const n=t<=4?e.split("").map(s=>s+s).join(
|
|
165
|
+
""):e,r=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16),o=n.length===8?parseInt(n.slice(6,8),16)/255:1;return{r,g:i,b:a,a:o}}function Ii(e){if(e[0]==="#")return Gn(e.
|
|
166
|
+
slice(1));const t=e.toLowerCase();if(t==="transparent")return{r:0,g:0,b:0,a:0};const n=ki[t];if(n)return Gn(n);if(/^[a-z]+$/.test(t))return null;let r=t.match(vi)??t.match(Pi);if(r)return{r:kt(Number(
|
|
167
|
+
r[1])),g:kt(Number(r[2])),b:kt(Number(r[3])),a:r[4]===void 0?1:De(Number(r[4]))};if(r=t.match(Ai)??t.match(Ni),r){const i=(Number(r[1])%360+360)%360/360;return{...Pt(i,De(Number(r[2])/100),De(Number(r[3])/
|
|
168
|
+
100)),a:r[4]===void 0?1:De(Number(r[4]))}}}function me(e){const t=e.trim();if(!t)return null;const n=Ii(t);return n!==void 0?n:ee?ee(t):($n(),null)}function he(e){const t=me(e);return t?{r:t.r,g:t.g,b:t.
|
|
169
|
+
b}:null}function vt({r:e,g:t,b:n}){const r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2;if(o===s)return{h:0,s:0,l:c};const l=o-s,u=c>.5?l/(2-o-s):l/(o+s);let d;return o===r?d=((i-
|
|
170
|
+
a)/l+(i<a?6:0))/6:o===i?d=((a-r)/l+2)/6:d=((r-i)/l+4)/6,{h:d,s:u,l:c}}function Pt(e,t,n){if(t===0){const o=Math.round(n*255);return{r:o,g:o,b:o}}const r=(o,s,c)=>(c<0&&(c+=1),c>1&&(c-=1),c<1/6?o+(s-o)*
|
|
171
|
+
6*c:c<1/2?s:c<2/3?o+(s-o)*(2/3-c)*6:o),i=n<.5?n*(1+t):n+t-n*t,a=2*n-i;return{r:Math.round(r(a,i,e+1/3)*255),g:Math.round(r(a,i,e)*255),b:Math.round(r(a,i,e-1/3)*255)}}function At({r:e,g:t,b:n}){const r=i=>i.
|
|
172
|
+
toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Nt(e){if(!e)return;const t=me(e);return t&&t.a>0?At(t):void 0}const Mi=.08,Ci=.2,Fi=.85;function It(e){const t=he(e);if(!t)return!0;
|
|
173
|
+
const{s:n,l:r}=vt(t);return n<=Mi&&(r<=Ci||r>=Fi)}const Xn=.3,Ti=.8,zn=new Map;function Dn(e,t){const n=`${e}|${t?1:0}`,r=zn.get(n);if(r!==void 0)return r;const i=Ri(e,t);return zn.set(n,i),i}function Ri(e,t){
|
|
174
|
+
const n=he(e);if(!n||It(e))return null;if(!t)return e;const{h:r,s:i,l:a}=vt(n),o=1-a,s=Xn+o*(Ti-Xn);return At(Pt(r,i,s))}function Oi({r:e,g:t,b:n}){const r=i=>{const a=i/255;return a<=.03928?a/12.92:((a+
|
|
175
|
+
.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function Un(e,t){if(!t)return;const n=me(t);if(!(!n||n.a<.5))return e&&he(e)?e:Oi(n)>.179?"#000000":"#ffffff"}const Li=Object.freeze(Object.defineProperty(
|
|
176
|
+
{__proto__:null,cssNeedsFullColorParser:wi,hslToRgb:Pt,isEffectivelyDefaultInk:It,loadFullColorParser:$n,normalizeTextColor:Nt,parseCssColor:he,parseCssColorWithAlpha:me,resolveTextColorOnFill:Un,resolveThemedTextColor:Dn,
|
|
177
|
+
rgbToHex:At,rgbToHsl:vt},Symbol.toStringTag,{value:"Module"})),Mt=3,Ct=6,Ft=96;function Wn(e){return typeof e=="number"&&Number.isFinite(e)&&e>=Ct&&e<=Ft}function Ei(e){const t={};if(!e)return t;const n=e.
|
|
178
|
+
match(/font-family:\s*([^;]+)/i);n&&(t.fontFamily=n[1].trim());const r=e.match(/font-size:\s*(\d+(?:\.\d+)?)px/i);if(r){const o=parseFloat(r[1]);Wn(o)&&(t.fontSize=o)}const i=e.match(/(?:^|;)\s*color\s*:\s*([^;]+)/i),
|
|
179
|
+
a=i?Nt(i[1].trim()):null;return a&&(t.color=a),t}function ji(e){const t=e.style,n=t?.direction||e.getAttribute("dir"),r=t?.textAlign,i={};return(n==="rtl"||n==="ltr")&&(i.direction=n),(r==="left"||r===
|
|
180
|
+
"right"||r==="center"||r==="justify")&&(i.align=r),r==="start"&&(i.align=n==="rtl"?"right":"left"),r==="end"&&(i.align=n==="rtl"?"left":"right"),i}function Bi(e,t,n,r,i,a,o=1){const s=e.direction==="r\
|
|
181
|
+
tl",c=e.align&&e.align!=="justify"?e.align:s?"right":"left",l=n+r,u=(t.level-1)*U.levelIndentPx*o,d=a(i),g=s?n:l-d,p=i?(U.pageNumberGapPx+U.labelClipGapPx)*o:0,f=s?n+d+p:n+u,h=s?l-u:l-d-p,b=Math.max(h-
|
|
182
|
+
f,0);let x=t.text;if(a(x)>b){const R=Array.from(x);for(;R.length&&a(R.join("")+"…")>b;)R.pop();x=a("…")<=b?R.join("")+"…":""}const y=a(x),v=c==="right"?h:c==="center"?(f+h)/2:f,C=c==="right"?v-y:
|
|
183
|
+
c==="center"?v-y/2:v,H=s?g+d+U.pageNumberGapPx*o:C+y+U.leaderStartGapPx*o,$=s?C-U.leaderStartGapPx*o:g-U.pageNumberGapPx*o;return{text:x,textX:v,align:c,numberX:g,leaderStart:H,leaderEnd:$,rtl:s}}function _i(e){
|
|
184
|
+
return`TOC \\o "1-${e}" \\h \\z \\u`}function Hn(e){const t=e?.match(/\\o\s+"?(\d)\s*-\s*(\d)"?/);if(!t)return Mt;const n=parseInt(t[2],10);return Number.isFinite(n)?Math.min(Math.max(n,1),6):Mt}function qn(e){
|
|
185
|
+
return typeof e.levels=="number"&&Number.isFinite(e.levels)?Math.min(Math.max(Math.round(e.levels),1),6):e.instr?Hn(e.instr):Mt}function $i(e){return e.instr??_i(qn(e))}function Gi(e,t){const n=[];if(!e)
|
|
186
|
+
return n;const r=i=>{for(const a of i)if(a.type==="paragraph"){const o=a.heading;if(typeof o=="number"&&o>=1&&o<=t){const s=a.children.map(c=>c.type==="text"?c.text:"").join("").trim();s.length>0&&a.id&&
|
|
187
|
+
n.push({blockId:a.id,text:s,level:o})}}else if(a.type==="container")r(a.children);else if(a.type==="table")for(const o of a.children)for(const s of o.children)r(s.children)};return r(e.children),n}const F=96,
|
|
188
|
+
Xi=1,Ue=Xi*F,zi="'Source Code Pro', Consolas, Monaco, 'Courier New', monospace",Di=.5,L=F*Di,Vn=1,Ui=1,Wi=/^(-?\d+(?:\.\d+)?)(px|pt|in|cm|mm)?$/i;function Hi(e){return typeof e!="number"||!Number.isFinite(
|
|
189
|
+
e)?0:Math.max(0,e)}function Tt(e){return typeof e!="number"||!Number.isFinite(e)?0:Math.max(0,Math.round(e))}function Rt(e){if(typeof e!="number"||!Number.isFinite(e))return 0;const t=Math.round(e);return t<
|
|
190
|
+
0?-1:t>0?1:0}function We(e){const t=Tt(e);return t>0?t:void 0}function He(e){const t=Rt(e);return t===0?void 0:t}function qi(e){return Tt(e.leftIndent)}function Vi(e){return Rt(e.firstLineIndent)}function Jn(e,t=L){
|
|
191
|
+
return Lt(qi(e),t)}function Yn(e,t=L){const n=Vi(e);return Math.sign(n)*Lt(Math.abs(n),t)}function Ot(e,t,n=L){const r=Jn(e,n),i=Yn(e,n);return r+(t===0?i:0)}function Ji(e,t,n,r=L){return n==="rtl"?0:
|
|
192
|
+
Ot(e,t,r)}function Yi(e,t,n,r=L){return Math.max(Ui,e-Ot(t,n,r))}function Kn(e,t=L){return!Number.isFinite(t)||t<=0?0:Math.max(0,Math.round(Hi(e)/t))}function Lt(e,t=L){return!Number.isFinite(t)||t<=0?
|
|
193
|
+
0:Math.max(0,Math.round(e))*t}function te(e,t){const n=t?.indentStepPx??L;if(t?.firstLine){const i=t?.storedAsUnits?Rt(e):e&&e<0?-1:Kn(e,n)>0?Vn:0;return i===0?void 0:i}const r=t?.storedAsUnits?Tt(e):
|
|
194
|
+
Kn(e,n);return r>0?r:void 0}function Ki(e){if(!e)return;const t=e.trim().match(Wi);if(!t)return;const n=Number.parseFloat(t[1]);if(!Number.isFinite(n))return;const r=(t[2]||"px").toLowerCase(),i={px:1,
|
|
195
|
+
pt:F/72,in:F,cm:F/2.54,mm:F/25.4};return n*i[r]}function Zi(e,t){const n=Ki(e);if(n!==void 0)return n===0?0:t?.firstLine?n<0?-1:Vn:te(n,{indentStepPx:t?.indentStepPx,storedAsUnits:!1,firstLine:t?.firstLine})}
|
|
196
|
+
function Zn(e,t){return typeof e=="object"&&e!==null&&e.constructor?.name===t}function Et(e){return e instanceof S.XmlElement||Zn(e,"YXmlElement")&&typeof e.nodeName=="string"&&typeof e.getAttribute==
|
|
197
|
+
"function"}function Qi(e){return e instanceof S.XmlText||Zn(e,"YXmlText")&&typeof e.toDelta=="function"}const Qn="Arial, sans-serif",T=[{attr:"structuralSuggestionId",kind:"string"},{attr:"structuralS\
|
|
198
|
+
uggestionKind",kind:"enum",enum:["insert","delete","split","merge","change"]},{attr:"structuralSuggestionRole",kind:"enum",enum:["before","after"]},{attr:"structuralSuggestionLabel",kind:"string"},{attr:"\
|
|
199
|
+
structuralSuggestionRecord",kind:"string"},{attr:"structuralSuggestionRecords",kind:"string"}],M=[{attr:"diffState",kind:"enum",enum:["insert","delete","equal"]},{attr:"suggestionId",kind:"string"}];function ea(e){
|
|
200
|
+
return(_[e]?.attrs??[]).map(t=>t.attr)}function ta(e){return _[e]?.children==="rawtext"}const na=[...T.map(e=>e.attr),...M.map(e=>e.attr)],_=Object.fromEntries([{type:"paragraph",attrs:[{attr:"heading",
|
|
201
|
+
kind:"int"},{attr:"align",kind:"string"},{attr:"lineSpacing",kind:"float"},{attr:"spaceBefore",kind:"float"},{attr:"spaceAfter",kind:"float"},{attr:"contextualSpacing",kind:"boolean"},{attr:"styleId",
|
|
202
|
+
kind:"string"},{attr:"direction",kind:"string"},{attr:"tabStops",kind:"string"},{attr:"borders",kind:"string"},{attr:"shading",kind:"string"},{attr:"oxmlAttrs",kind:"string"},{attr:"oxmlPPr",kind:"str\
|
|
203
|
+
ing"},{attr:"leftIndent",kind:"float"},{attr:"firstLineIndent",kind:"float"},...T,...M],children:"text"},{type:"list",attrs:[{attr:"variant",kind:"string"},{attr:"startNumber",kind:"int"},{attr:"numbe\
|
|
204
|
+
ringChainId",kind:"string"},{attr:"numberingFormat",kind:"string"},...ce.map(e=>({attr:e,kind:"float"})),{attr:"contextualSpacing",kind:"boolean"},...T,...M],children:"list-items"},{type:"list-item",attrs:[
|
|
205
|
+
...ce.map(e=>({attr:e,kind:"float"})),{attr:"checked",kind:"boolean"},{attr:"indentLevel",kind:"int",validate:e=>e>0},{attr:"direction",kind:"string"},...T],children:"text"},{type:"table",attrs:[{attr:"\
|
|
206
|
+
columnWidths",kind:"json"},{attr:"tableWidth",kind:"int"},{attr:"align",kind:"enum",enum:["left","center","right"]},{attr:"borderColor",kind:"string"},{attr:"borderWidth",kind:"int"},{attr:"borders",kind:"\
|
|
207
|
+
string"},{attr:"cellPadding",kind:"int"},{attr:"hasHeader",kind:"booleanTrue"},{attr:"docxTablePropertyOverrides",kind:"string"},{attr:"oxmlTblPr",kind:"string"},...T,...M],children:"table-rows"},{type:"\
|
|
208
|
+
table-row",attrs:[{attr:"oxmlAttrs",kind:"string"},{attr:"oxmlTrPr",kind:"string"},...M,...T],children:"blocks"},{type:"table-cell",attrs:[{attr:"verticalAlign",kind:"string"},{attr:"backgroundColor",
|
|
209
|
+
kind:"string"},{attr:"borders",kind:"string"},{attr:"padding",kind:"string"},{attr:"colSpan",kind:"int",validate:e=>e>1},{attr:"rowSpan",kind:"int",validate:e=>e>1},{attr:"oxmlTcPr",kind:"string"},...M,
|
|
210
|
+
...T],children:"blocks"},{type:"container",attrs:[{attr:"borderColor",kind:"string"},{attr:"padding",kind:"int"},...T,...M],children:"blocks"},{type:"header-footer",attrs:[{attr:"side",kind:"enum",enum:[
|
|
211
|
+
"header","footer"]},{attr:"slot",kind:"enum",enum:["default","first","even"]},{attr:"sectionIndex",kind:"int",validate:e=>e>=0}],children:"blocks"},{type:"footnote",attrs:[{attr:"noteKind",kind:"enum",
|
|
212
|
+
enum:["endnote"]},...T,...M],children:"blocks"},{type:"code",attrs:[{attr:"language",kind:"string"},{attr:"toolCallId",kind:"string"},{attr:"renderDiagram",kind:"boolean"},{attr:"showDiagramSource",kind:"\
|
|
213
|
+
boolean"},...M,...T],children:"rawtext"},{type:"math",attrs:[{attr:"displayMode",kind:"enum",enum:["inline","block"]},{attr:"align",kind:"enum",enum:["left","center","right"]},{attr:"showDiagramSource",
|
|
214
|
+
kind:"boolean"},...M,...T],children:"rawtext"},{type:"image",attrs:[{attr:"src",kind:"string"},{attr:"sourceUrl",kind:"string"},{attr:"width",kind:"int"},{attr:"height",kind:"int"},{attr:"alt",kind:"s\
|
|
215
|
+
tring"},{attr:"align",kind:"string"},{attr:"uploading",kind:"boolean"},{attr:"tempId",kind:"string"},{attr:"originalFormat",kind:"enum",enum:["emf","wmf"]},{attr:"originalDataUrl",kind:"string"},{attr:"\
|
|
216
|
+
anchorXml",kind:"string"},...M,...T],children:"none"},{type:"page-break",attrs:[...M,{attr:"structuralSuggestionRecord",kind:"string"}],children:"none"},{type:"docx-raw",attrs:[{attr:"xml",kind:"strin\
|
|
217
|
+
g"},{attr:"tagName",kind:"string"},{attr:"detail",kind:"string"},{attr:"origin",kind:"enum",enum:["run","body"]},...T,...M],children:"none"},{type:"section-break",attrs:[{attr:"layout",kind:"json"},{attr:"\
|
|
218
|
+
breakType",kind:"enum",enum:["nextPage","continuous","evenPage","oddPage"]},...M],children:"none"},{type:"toc",attrs:[{attr:"direction",kind:"enum",enum:["rtl","ltr"]},{attr:"align",kind:"enum",enum:[
|
|
219
|
+
"left","center","right","justify"]},{attr:"levels",kind:"int",validate:e=>e>=1&&e<=6},{attr:"instr",kind:"string"},{attr:"fontFamily",kind:"string"},{attr:"fontSize",kind:"float",validate:e=>e>=Ct&&e<=
|
|
220
|
+
Ft},{attr:"color",kind:"string"},...M,{attr:"structuralSuggestionRecord",kind:"string"}],children:"none"},{type:"placeholder",attrs:[{attr:"height",kind:"int"}],children:"none"}].map(e=>[e.type,e])),ra={
|
|
221
|
+
image:{src:"",width:200,height:200},code:{content:""},math:{displayMode:"block"},placeholder:{height:100},list:{variant:"unordered"}};function oa(e,t){if(!(t==null||t===""))switch(e.kind){case"string":
|
|
222
|
+
return t;case"int":{const n=parseInt(t,10);return Number.isNaN(n)||e.validate&&!e.validate(n)?void 0:n}case"float":{const n=parseFloat(t);return Number.isNaN(n)||e.validate&&!e.validate(n)?void 0:n}case"\
|
|
223
|
+
boolean":return t==="true"?!0:t==="false"?!1:void 0;case"booleanTrue":return t==="true"?!0:void 0;case"json":try{return JSON.parse(t)}catch{return}case"enum":return e.enum?.includes(t)?t:void 0}}function er(e,t){
|
|
224
|
+
if(t==null)return null;switch(e.kind){case"string":case"enum":return typeof t=="string"&&t!==""?t:null;case"int":case"float":return typeof t=="number"?String(t):null;case"boolean":return typeof t=="bo\
|
|
225
|
+
olean"?String(t):null;case"booleanTrue":return t===!0?"true":null;case"json":return JSON.stringify(t)}}function ia(e){const t=[],n=ue(e);for(const r of n){if(typeof r.insert!="string")continue;const i=r.
|
|
226
|
+
attributes||{},a={type:"text",text:r.insert,marks:St(i)};t.push(a)}return _n(t)}function tr(e){for(let t=0;t<e.length;t++){const n=e.get(t);if(Qi(n))return n}return null}function nr(e){const t=Z(e,"_e\
|
|
227
|
+
mptyTextMarks");let n={fontFamily:Qn};if(t)try{n=JSON.parse(t)}catch{}return[{type:"text",text:"",marks:n}]}function aa(e){const t=tr(e);if(!t)return nr(e);const n=ia(t);return n.length>0?n:nr(e)}function sa(e,t){
|
|
228
|
+
for(const[n,r]of[["leftIndent",!1],["firstLineIndent",!0]])if(typeof e[n]=="number"){if(e[n]===0)continue;const i=te(e[n],{indentStepPx:t.indentStepPx,storedAsUnits:t.storedAsUnits,firstLine:r});i===void 0?
|
|
229
|
+
delete e[n]:e[n]=i}}function be(e,t,n,r){const i=e.nodeName,a=_[i]??_.paragraph,o=_[i]?i:"paragraph",s={type:o,id:Z(e,"id")||P()};for(const l of a.attrs){const u=oa(l,Z(e,l.attr));u!==void 0&&(s[l.field??
|
|
230
|
+
l.attr]=u)}o==="paragraph"&&Ge(s,Z(e,"pagination"));const c=ra[o];if(c)for(const[l,u]of Object.entries(c))s[l]===void 0&&(s[l]=u);switch(a.children){case"text":s.children=aa(e);break;case"rawtext":{const l=tr(
|
|
231
|
+
e);s.content=l?l.toString():"";break}case"blocks":{const l=[];for(const u of e.toArray())if(Et(u)){const d=r?r(u):be(u,t);d&&l.push(d)}s.children=l;break}case"list-items":{const l=[];for(const u of e.
|
|
232
|
+
toArray())if(Et(u)&&u.nodeName==="list-item"){const d=r?r(u):be(u,t);d&&l.push(d)}s.children=l;break}case"table-rows":{const l=[];for(const u of e.toArray())if(Et(u)&&u.nodeName==="table-row"){const d=r?
|
|
233
|
+
r(u):be(u,t);d&&l.push(d)}s.children=l,s.columnWidths===void 0&&(s.columnWidths=[]);break}}return(o==="paragraph"||a.children==="text")&&sa(s,t),s}function ca(e,t){const n=new S.XmlText,r=new Set;for(const o of e){
|
|
234
|
+
const s=o;if(s?.type==="text"&&s.marks)for(const c of Object.keys(s.marks))r.add(c)}let i=0;for(const o of e){const s=o;if(s?.type!=="text"||!s.text)continue;const c=s.marks??{};if(t&&z(t)){n.insert(i,
|
|
235
|
+
s.text,Be(t,c)),i+=s.text.length;continue}de(n,i,s.text);for(const l of r)wn(n,i,s.text.length,{[l]:l in c?c[l]:null});i+=s.text.length}let a=null;if(i===0){const o=e.find(s=>s?.type==="text"&&s.text.
|
|
236
|
+
length===0&&s.marks&&Object.keys(s.marks).length>0);o?.marks&&(a=o.marks)}return{yText:n,emptyMarks:a}}function la(e,t,n){const r=_[t.type];if(!r)return;let i={id:String(t.id??P())};for(const a of r.attrs){
|
|
237
|
+
const o=a.field??a.attr;let s=t[o];o==="leftIndent"&&typeof s=="number"?s=s===0?0:We(s):o==="firstLineIndent"&&typeof s=="number"&&(s=s===0?0:He(s));const c=er(a,s);c!==null&&(i[a.attr]=c)}if(r.type===
|
|
238
|
+
"paragraph"){const a=$e(t);a!==void 0&&(i.pagination=a)}t.type==="paragraph"&&n&&z(n)&&(i=po(n,i));for(const[a,o]of Object.entries(i))e.setAttribute(a,o)}function ua(e,t){const n=t,r=_[n.type];if(!r)return;
|
|
239
|
+
const i=String(n.id??P());e.getAttribute("id")!==i&&e.setAttribute("id",i);for(const a of r.attrs){const o=a.field??a.attr;let s=n[o];o==="leftIndent"&&typeof s=="number"?s=s===0?0:We(s):o==="firstLin\
|
|
240
|
+
eIndent"&&typeof s=="number"&&(s=s===0?0:He(s));const c=er(a,s);if(c===null){const l=Z(e,a.attr);l!==void 0&&l!==""&&pt(e,a.attr)}else Z(e,a.attr)!==c&&e.setAttribute(a.attr,c)}if(r.type==="paragraph"){
|
|
241
|
+
const a=$e(n);a===void 0?pt(e,"pagination"):e.setAttribute("pagination",a)}}function rr(e,t){const n=e.children;if(!Array.isArray(n))return e;const r=n.flatMap(i=>{if(i?.type==="text"){const a=t(i);return Array.
|
|
242
|
+
isArray(a)?a:[a]}return[rr(i,t)]});return{...e,children:r}}function jt(e,t){const n=e,r=_[n.type]??_.paragraph,i=new S.XmlElement(r.type);la(i,n,t);let a=0;switch(r.children){case"text":{const{yText:o,
|
|
243
|
+
emptyMarks:s}=ca(n.children??[],t);i.insert(a++,[o]),s&&i.setAttribute("_emptyTextMarks",JSON.stringify(s));break}case"rawtext":{const o=new S.XmlText,s=typeof n.content=="string"?n.content:"";s&&de(o,
|
|
244
|
+
0,s),i.insert(a++,[o]);break}case"blocks":case"list-items":case"table-rows":{const o=n.children??[];for(const s of o)i.insert(a++,[jt(s,t)]);break}}return i}function ye(e,t,n,r){const i=a=>e.find(o=>o.
|
|
245
|
+
type==="header-footer"&&o.side===t&&o.slot===n&&o.sectionIndex===a);if(r!==void 0){const a=i(r);if(a)return a}return i(void 0)}function da(e,t,n,r){if(n===1){const i=ye(e,t,"first",r);if(i)return i}if(n%
|
|
246
|
+
2===0){const i=ye(e,t,"even",r);if(i)return i}return ye(e,t,"default",r)}const xe=[void 0,"center","right"];function fa(e,t){const n=xe[e];return{type:"paragraph",id:P(),children:[{type:"text",text:"",
|
|
247
|
+
...t?{marks:{fontFamily:t}}:{}}],...n?{align:n}:{}}}function ga(e,t){if(!t)return e;let n=!1;const r=e.children.map(i=>i.type!=="text"||i.marks?.fontFamily?i:(n=!0,{...i,marks:{...i.marks??{},fontFamily:t}}));
|
|
248
|
+
return n?{...e,children:r}:e}function pa(e,t){const n=xe[t];return!n||e.align?e:{...e,align:n}}function or(e,t,n,r,i){const a=n??[],o=s=>a[s]?ga(pa(a[s],s),r):fa(s,r);return{type:"header-footer",id:P(),
|
|
249
|
+
side:e,slot:t,...i!==void 0?{sectionIndex:i}:{},children:[o(0),o(1),o(2)]}}function ir(e){return!!e?.children.some(t=>t.type==="text"&&t.text.trim()!=="")}function ma(e){return e.children.some(t=>ir(t))}
|
|
250
|
+
function Bt(e){const t=e.children,n=[2,1,0].find(i=>ir(t[i]))??-1;if(n===-1)return;const r=[];for(let i=0;i<=n;i++){i>0&&r.push({type:"text",text:" "});for(const a of t[i]?.children??[])a.type==="text"&&
|
|
251
|
+
a.text&&r.push(a)}return{type:"paragraph",id:e.id?`${e.id}-zone`:P(),children:r}}function ar(e){const t=[[],[],[]],n=e?.[0],r=!!n?.children.some(o=>o.type==="text"&&o.text.includes(" "));let i=!r&&n?.
|
|
252
|
+
align==="right"?2:!r&&n?.align==="center"?1:0;const a=n?.children??[];for(const o of a)o.type==="text"&&o.text.split(" ").forEach((s,c)=>{c>0&&i<2&&(i+=1),s&&t[i].push({type:"text",text:s,...o.marks?{
|
|
253
|
+
marks:{...o.marks}}:{}})});for(const o of e?.slice(1)??[])for(const s of o.children)s.type==="text"&&s.text&&t[0].push({...s});return t.map((o,s)=>({type:"paragraph",id:P(),children:o.length>0?o:[{type:"\
|
|
254
|
+
text",text:""}],...xe[s]?{align:xe[s]}:{}}))}function sr(e){const t={},n={};for(const r of e){if(r.type!=="header-footer"||r.sectionIndex!==void 0)continue;const i=Bt(r);if(!i)continue;const a=r.side===
|
|
255
|
+
"header"?t:n;a[r.slot]=[i]}return{...Object.keys(t).length>0?{headers:t}:{},...Object.keys(n).length>0?{footers:n}:{}}}function ha(e,t){const n={},r={};for(const i of["header","footer"])for(const a of[
|
|
256
|
+
"default","first","even"]){const o=ye(e,i,a,t);if(!o)continue;const s=Bt(o);if(!s)continue;const c=i==="header"?n:r;c[a]=[s]}return{...Object.keys(n).length>0?{headers:n}:{},...Object.keys(r).length>0?
|
|
257
|
+
{footers:r}:{}}}function ba(e){return e.some(t=>t.type==="header-footer"&&t.sectionIndex!==void 0)}function _t(e,t,n){const r=[];for(const[i,a]of[["header",e],["footer",t]])if(a)for(const o of["defaul\
|
|
258
|
+
t","first","even"]){const s=a[o];!s||s.length===0||r.push(or(i,o,ar(s),n))}return r}function ya(e){for(const t of e)if(!(t.type==="header-footer"||t.type==="footnote")){if(t.type==="paragraph"){for(const n of t.
|
|
259
|
+
children)if(n.type==="text"&&n.marks?.fontFamily)return n.marks.fontFamily}else if(t.type==="list"){for(const n of t.children)for(const r of n.children)if(r.type==="text"&&r.marks?.fontFamily)return r.
|
|
260
|
+
marks.fontFamily}}}function xa(e){let t="";for(const r of e?.children??[])r.type==="text"&&(r.marks?.field==="page"?t+="{PAGE}":r.marks?.field==="numPages"?t+="{PAGES}":t+=r.text);const n=t.replace(/\s+/g,
|
|
261
|
+
" ").trim();return n.length>60?`${n.slice(0,59)}…`:n}const cr={default:"default","default page":"default","default pages":"default",all:"default","all pages":"default",first:"first","first page":"fi\
|
|
262
|
+
rst",title:"first","title page":"first",titlepg:"first",even:"even","even page":"even","even pages":"even"};function Sa(e){if(e==null)return;if(typeof e!="string")return null;const t=e.trim().toLowerCase().
|
|
263
|
+
replace(/[\s_-]+/g," ");return Object.prototype.hasOwnProperty.call(cr,t)?cr[t]:null}function wa(e){const t=new Set,n=[];for(const r of e){if(r.type!=="header-footer")continue;const i=r.sectionIndex===
|
|
264
|
+
void 0?"all sections":`section ${r.sectionIndex+1} only`,a=`${r.side}:${r.slot}:${r.sectionIndex??""}`,o=t.has(a);t.add(a);const s=["left","center","right"].map((c,l)=>{const u=xa(r.children[l]);return u?
|
|
265
|
+
`${c} ${JSON.stringify(u)}`:null}).filter(c=>c!==null);n.push(`${r.side} ${r.slot} (${i})${o?" [duplicate, not rendered]":""}: ${s.length>0?s.join(" | "):"(empty)"}`)}return n}function ka(e,t){const n=[
|
|
266
|
+
...e.chrome??[],...e.children.filter(r=>r.type==="header-footer")];for(const r of n){if(r.id===t)return{block:r,columnIndex:0};const i=r.children.findIndex(a=>a.id===t);if(i!==-1)return{block:r,columnIndex:i}}
|
|
267
|
+
return null}const lr=["decimal","lowerRoman","upperRoman"],va=3999,Pa=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function $t(e){
|
|
268
|
+
return typeof e=="string"&&lr.includes(e)}function Aa(e){let t=e,n="";for(const[r,i]of Pa)for(;t>=r;)n+=i,t-=r;return n}function ur(e,t="decimal"){if(!Number.isFinite(e))return"";const n=Math.round(e);
|
|
269
|
+
if((t==="lowerRoman"||t==="upperRoman")&&n>=1&&n<=va){const r=Aa(n);return t==="lowerRoman"?r.toLowerCase():r}return String(n)}const Gt=["top","right","bottom","left"],Na=["single","double","dotted","\
|
|
270
|
+
dashed"];function ne(e){if(e===null||e==="")return null;if(e===void 0)return;if(typeof e=="string")try{e=JSON.parse(e)}catch{return}if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n={offsetFrom:t.
|
|
271
|
+
offsetFrom==="page"?"page":"text",display:t.display==="firstPage"||t.display==="notFirstPage"?t.display:"allPages",zOrder:t.zOrder==="back"?"back":"front"};for(const r of Gt){const i=t[r];if(i!=null){
|
|
272
|
+
if(!Na.includes(i.style)||typeof i.color!="string"||!/^#[0-9a-f]{6}$/i.test(i.color)||typeof i.widthPt!="number"||!Number.isFinite(i.widthPt)||i.widthPt<.25||i.widthPt>12||typeof i.spacePt!="number"||
|
|
273
|
+
!Number.isFinite(i.spacePt)||i.spacePt<0||i.spacePt>31)return;n[r]={style:i.style,color:i.color.toLowerCase(),widthPt:i.widthPt,spacePt:i.spacePt}}}return n}function Xt(e){const t=ne(e);return t===void 0?
|
|
274
|
+
void 0:t===null?"":JSON.stringify(t)}function Ia(e,t,n,r,i){if(!e||e.display==="firstPage"&&!i||e.display==="notFirstPage"&&i)return[];const a=d=>{const g=e[d]?.spacePt??0,p=(e[d]?.widthPt??0)/2;return e.
|
|
275
|
+
offsetFrom==="page"?g+p:r[d]-g-p},o=Math.max(0,a("left")),s=Math.min(t,t-a("right")),c=Math.max(0,a("top")),l=Math.min(n,n-a("bottom")),u={top:[o,c,s,c],right:[s,c,s,l],bottom:[o,l,s,l],left:[o,c,o,l]};
|
|
276
|
+
return Gt.flatMap(d=>{const g=e[d];if(!g)return[];const[p,f,h,b]=u[d];return[{...g,x1:p,y1:f,x2:h,y2:b}]})}function Ma(e,t){e.save(),e.globalAlpha=1,e.lineCap="square",e.scale(96/72,96/72);for(const n of t){
|
|
277
|
+
e.strokeStyle=n.color,e.lineWidth=n.style==="double"?n.widthPt/3:n.widthPt,e.setLineDash(n.style==="dotted"?[n.widthPt,n.widthPt*2]:n.style==="dashed"?[n.widthPt*4,n.widthPt*2]:[]);const r=n.style==="\
|
|
278
|
+
double"?[-n.widthPt/3,n.widthPt/3]:[0];for(const i of r){const a=n.x1===n.x2?i:0,o=n.y1===n.y2?i:0;e.beginPath(),e.moveTo(n.x1+a,n.y1+o),e.lineTo(n.x2+a,n.y2+o),e.stroke()}}e.restore()}function Ca(e){
|
|
279
|
+
if(!e)return;const t={offsetFrom:e.getAttribute("w:offsetFrom")==="page"?"page":"text",display:e.getAttribute("w:display")||"allPages",zOrder:e.getAttribute("w:zOrder")==="back"?"back":"front"};for(const n of Gt){
|
|
280
|
+
const r=Array.from(e.children).find(o=>o.localName===n);if(!r)continue;const i=r.getAttribute("w:val");if(i==="none"||i==="nil")continue;if(r.hasAttribute("w:themeColor")||["1","true","on"].includes(r.
|
|
281
|
+
getAttribute("w:shadow")??"")||["1","true","on"].includes(r.getAttribute("w:frame")??"")||Array.from(r.attributes).some(o=>o.namespaceURI==="http://schemas.openxmlformats.org/officeDocument/2006/relat\
|
|
282
|
+
ionships"))return;const a=r.getAttribute("w:color")||"auto";t[n]={style:i,color:a==="auto"?"#000000":`#${a}`,widthPt:Number(r.getAttribute("w:sz")||8)/8,spacePt:Number(r.getAttribute("w:space")||0)}}return ne(
|
|
283
|
+
t)??void 0}function dr(e){const t=ne(e?.pageBorders),n=e?.oxmlSectPr||"";if(t===void 0)return n||void 0;const r=n.replace(/<w:pgBorders\b[^>]*(?:\/>|>[\s\S]*?<\/w:pgBorders>)/g,"");if(t===null)return r||
|
|
284
|
+
void 0;const i=["top","left","bottom","right"].map(a=>{const o=t[a];return o?`<w:${a} w:val="${o.style}" w:color="${o.color.slice(1).toUpperCase()}" w:sz="${Math.round(o.widthPt*8)}" w:space="${Math.round(
|
|
285
|
+
o.spacePt)}"/>`:""}).join("");return`${r}<w:pgBorders w:offsetFrom="${t.offsetFrom}" w:display="${t.display}" w:zOrder="${t.zOrder}">${i}</w:pgBorders>`}function Fa(e,t){const n=/<w:pgBorders\b/.test(
|
|
286
|
+
t?.oxmlSectPr??"");return dr({pageBorders:t?.pageBorders!==void 0?t.pageBorders:n?void 0:e?.pageBorders,oxmlSectPr:t?.oxmlSectPr})}const Se=(e,t,n)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?
|
|
287
|
+
e:void 0;function zt(e){let t=e;if(typeof e=="string"){const n=e.trim();if(n==="")return null;try{t=JSON.parse(n)}catch{return null}}return!t||typeof t!="object"||Array.isArray(t)?null:t}function Dt(e){
|
|
288
|
+
const t=zt(e);if(!t)return null;const n=typeof t.countBy=="number"&&Number.isFinite(t.countBy)&&t.countBy>=1?Math.round(t.countBy):1,r=typeof t.start=="number"&&Number.isFinite(t.start)&&t.start>=1?Math.
|
|
289
|
+
round(t.start):1,i=t.restart==="newSection"||t.restart==="continuous"?t.restart:"newPage",a=typeof t.distancePx=="number"&&Number.isFinite(t.distancePx)&&t.distancePx>=0?t.distancePx:void 0;return{countBy:n,
|
|
290
|
+
start:r,restart:i,...a!==void 0?{distancePx:a}:{}}}function qe(e){const t=zt(e);if(!t)return null;const n=Se(t.rows,1,200),r=Se(t.pitchPx,8,96);if(n===void 0||r===void 0)return null;const i=Se(t.firstBaselinePx,
|
|
291
|
+
0,2e3),a=Se(t.distancePx,0,400),o=typeof t.fontFamily=="string"&&t.fontFamily.trim()!==""&&t.fontFamily.length<=200?t.fontFamily.trim():void 0,s=Se(t.fontSizePx,4,96);return{rows:Math.round(n),pitchPx:r,
|
|
292
|
+
...i!==void 0?{firstBaselinePx:i}:{},...a!==void 0?{distancePx:a}:{},...o!==void 0?{fontFamily:o}:{},...s!==void 0?{fontSizePx:s}:{}}}function Ta(e){const t=zt(e);return t?qe({rows:t.gridLines,pitchPx:t.
|
|
293
|
+
gridPitchPx,fontFamily:t.fontFamily}):null}function we(e){if(e)return JSON.stringify({rows:e.rows,pitchPx:e.pitchPx,...e.firstBaselinePx!==void 0?{firstBaselinePx:e.firstBaselinePx}:{},...e.distancePx!==
|
|
294
|
+
void 0?{distancePx:e.distancePx}:{},...e.fontFamily?{fontFamily:e.fontFamily}:{},...e.fontSizePx!==void 0?{fontSizePx:e.fontSizePx}:{}})}function ke(e){if(e)return JSON.stringify({countBy:e.countBy,start:e.
|
|
295
|
+
start,restart:e.restart,...e.distancePx!==void 0?{distancePx:e.distancePx}:{}})}const Ve=1,m={pageBorders:"pageBorders",pageSize:"pageSize",orientation:"pageOrientation",marginPx:"pageMarginPx",marginTopPx:"\
|
|
296
|
+
pageMarginTopPx",marginRightPx:"pageMarginRightPx",marginBottomPx:"pageMarginBottomPx",marginLeftPx:"pageMarginLeftPx",indentStepPx:"indentStepPx",blockSpacingPx:"blockSpacingPx",showPageNumbers:"show\
|
|
297
|
+
PageNumbers",pageNumberPosition:"pageNumberPosition",pageNumberStart:"pageNumberStart",pageNumberFormat:"pageNumberFormat",pageNumberRestart:"pageNumberRestart",paragraphIndentStorageVersion:"paragrap\
|
|
298
|
+
hIndentStorageVersion",hyphenationEnabled:"hyphenationEnabled",lineNumbering:"lineNumbering",pleadingGrid:"pleadingGrid",columnCount:"columnCount",columnGapTwips:"columnGapTwips",oxmlSectPr:"oxmlSectP\
|
|
299
|
+
r"},fr=["top-left","top-right","bottom-left","bottom-right"],Ra={"top-left":"Top left","top-right":"Top right","bottom-left":"Bottom left","bottom-right":"Bottom right"};function Je(e){return typeof e==
|
|
300
|
+
"string"&&fr.includes(e)}const ve={letter:{width:8.5,height:11},tabloid:{width:11,height:17},legal:{width:8.5,height:14},statement:{width:5.5,height:8.5},executive:{width:7.25,height:10.5},folio:{width:8.5,
|
|
301
|
+
height:13},a3:{width:11.6929,height:16.5354},a4:{width:8.2677,height:11.6929},a5:{width:5.8268,height:8.2677},b4:{width:9.8425,height:13.8976},b5:{width:6.9291,height:9.8425}},Oa={letter:"Letter",tabloid:"\
|
|
302
|
+
Tabloid",legal:"Legal",statement:"Statement",executive:"Executive",folio:"Folio",a3:"A3",a4:"A4",a5:"A5",b4:"B4",b5:"B5"},gr=["apa7"],La=2.54,Ea=Object.entries(ve).map(([e,t])=>({pageSize:e,width:Math.
|
|
303
|
+
min(t.width,t.height),height:Math.max(t.width,t.height)}));function pr(e){return typeof e=="string"&&gr.includes(e)}function Ye(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(ve,e)}
|
|
304
|
+
function mr(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string")return;const t=e.trim().match(/^(-?(?:\d+(?:\.\d+)?|\.\d+))\s*(px|in|cm)?$/i);if(!t)return;const n=Number.
|
|
305
|
+
parseFloat(t[1]);if(Number.isFinite(n))switch((t[2]??"px").toLowerCase()){case"px":return n;case"in":return W(n);case"cm":return W(n/La);default:return}}function hr(e,t){if(!Number.isFinite(e)||e<=0||
|
|
306
|
+
!Number.isFinite(t)||t<=0)return;const n=e>t?"landscape":"portrait",r=Ae(Math.min(e,t)),i=Ae(Math.max(e,t));let a=N.pageSize,o=Number.POSITIVE_INFINITY;for(const s of Ea){const c=Math.abs(r-s.width)+Math.
|
|
307
|
+
abs(i-s.height);c<o&&(o=c,a=s.pageSize)}return{pageSize:a,orientation:n}}const ja=0,Ba=3*F,_a=.125*F,$a=2*F,Ga=0,Xa=2*F,za=12,br=1,Da=99999,N={pageSize:"letter",orientation:"portrait",marginTopPx:Ue,marginRightPx:Ue,
|
|
308
|
+
marginBottomPx:Ue,marginLeftPx:Ue,indentStepPx:L,blockSpacingPx:za,showPageNumbers:!1,pageNumberPosition:"top-right",pageNumberStart:1,pageNumberFormat:"decimal",noteMode:"footnotes",columnCount:1,columnGapTwips:720,
|
|
309
|
+
hyphenationEnabled:!1,lineNumbering:null,pleadingGrid:null};function re(e,t,n){return Math.max(t,Math.min(n,e))}function Pe(e){return typeof e!="number"||!Number.isFinite(e)?N.marginLeftPx:re(e,ja,Ba)}
|
|
310
|
+
function Ua(e){return typeof e!="number"||!Number.isFinite(e)?N.indentStepPx:re(e,_a,$a)}function Wa(e){return typeof e!="number"||!Number.isFinite(e)?N.blockSpacingPx:re(e,Ga,Xa)}function Ha(e){return Je(
|
|
311
|
+
e)?e:N.pageNumberPosition}function qa(e){return typeof e!="number"||!Number.isFinite(e)?N.pageNumberStart:re(Math.round(e),br,Da)}function Va(e){return typeof e!="number"||!Number.isFinite(e)?N.columnCount:
|
|
312
|
+
re(Math.round(e),1,12)}function Ja(e){return typeof e!="number"||!Number.isFinite(e)?N.columnGapTwips:re(Math.round(e),0,14400)}function j(e){const t=e?.pageSize&&Ye(e.pageSize)?e.pageSize:N.pageSize,
|
|
313
|
+
n=e?.orientation==="landscape"||e?.orientation==="portrait"?e.orientation:N.orientation,r=Pe(e?.marginPx);return{pageSize:t,orientation:n,pageBorders:ne(e?.pageBorders),marginTopPx:Pe(e?.marginTopPx??
|
|
314
|
+
r),marginRightPx:Pe(e?.marginRightPx??r),marginBottomPx:Pe(e?.marginBottomPx??r),marginLeftPx:Pe(e?.marginLeftPx??r),indentStepPx:Ua(e?.indentStepPx),blockSpacingPx:Wa(e?.blockSpacingPx),showPageNumbers:e?.
|
|
315
|
+
showPageNumbers===!0,pageNumberPosition:Ha(e?.pageNumberPosition),pageNumberStart:qa(e?.pageNumberStart),pageNumberFormat:$t(e?.pageNumberFormat)?e.pageNumberFormat:N.pageNumberFormat,...e?.pageNumberRestart===
|
|
316
|
+
!0?{pageNumberRestart:!0}:{},noteMode:e?.noteMode==="endnotes"?"endnotes":"footnotes",columnCount:Va(e?.columnCount),columnGapTwips:Ja(e?.columnGapTwips),hyphenationEnabled:e?.hyphenationEnabled===!0,
|
|
317
|
+
...(()=>{const i=e?.lineNumbering,a=e?.pleadingGrid,o=Ta(i),s=a!==void 0?qe(a):o;return{lineNumbering:o||s?null:Dt(i),pleadingGrid:s}})(),...(()=>{const i=e?.oxmlSectPr;return typeof i=="string"&&i?{oxmlSectPr:i}:
|
|
318
|
+
{}})()}}function yr(e){const t=ve[e.pageSize],n=t.width*F,r=t.height*F;return e.orientation==="landscape"?{pageWidth:r,pageHeight:n}:{pageWidth:n,pageHeight:r}}function Ae(e){return Number.isFinite(e)?
|
|
319
|
+
e/F:0}function W(e){return Number.isFinite(e)?e*F:0}const Ne=1440,Ya=72;function Ut(e){return W(e/Ne)}function xr(e){return Ae(e)*Ne}function Sr(e){return e/Ne*Ya}function wr(e){return e/Ne}const kr=Ut(
|
|
320
|
+
N.columnGapTwips),vr=[1,2,3];function Pr(e){return typeof e=="number"&&vr.includes(e)}function Wt(e,t){if(!t)return e??void 0;const n={...e??{}};for(const[r,i]of Object.entries(t))i!==void 0&&(n[r]=i);
|
|
321
|
+
return t.pageBorders===void 0&&/<w:pgBorders\b/.test(t.oxmlSectPr??"")&&delete n.pageBorders,n}function Ar(e,t){return j(Wt(e,t))}function Ka(e,t){return Xt(e.pageBorders)===Xt(t.pageBorders)&&e.pageSize===
|
|
322
|
+
t.pageSize&&e.orientation===t.orientation&&e.marginTopPx===t.marginTopPx&&e.marginRightPx===t.marginRightPx&&e.marginBottomPx===t.marginBottomPx&&e.marginLeftPx===t.marginLeftPx&&e.indentStepPx===t.indentStepPx&&
|
|
323
|
+
e.blockSpacingPx===t.blockSpacingPx&&e.showPageNumbers===t.showPageNumbers&&e.pageNumberPosition===t.pageNumberPosition&&e.pageNumberStart===t.pageNumberStart&&e.pageNumberFormat===t.pageNumberFormat&&
|
|
324
|
+
e.pageNumberRestart===t.pageNumberRestart&&e.columnCount===t.columnCount&&e.columnGapTwips===t.columnGapTwips&&e.hyphenationEnabled===t.hyphenationEnabled&&ke(e.lineNumbering)===ke(t.lineNumbering)&&we(
|
|
325
|
+
e.pleadingGrid)===we(t.pleadingGrid)}function Ht(e,t){return Math.max(br,e.pageNumberStart+t)}function Nr(e,t){return ur(Ht(e,t),e.pageNumberFormat)}function Za(e){return e.marginTopPx===e.marginRightPx&&
|
|
326
|
+
e.marginTopPx===e.marginBottomPx&&e.marginTopPx===e.marginLeftPx}function Ir(e){switch(e){case"apa7":return{pageLayout:j({pageSize:"letter",orientation:"portrait",marginTopPx:W(1),marginRightPx:W(1),marginBottomPx:W(
|
|
327
|
+
1),marginLeftPx:W(1),indentStepPx:L,blockSpacingPx:0,showPageNumbers:!0,pageNumberPosition:"top-right",pageNumberStart:1}),pageless:!1}}}function Mr(e){const t=e.startsWith("top"),n=e.endsWith("right");
|
|
328
|
+
return{side:t?"headers":"footers",paragraph:{type:"paragraph",id:`pgnum-${Math.random().toString(36).slice(2,8)}`,...n?{align:"right"}:{},children:[{type:"text",text:"1",marks:{field:"page"}}]}}}const Qa=Object.
|
|
329
|
+
freeze(Object.defineProperty({__proto__:null,DEFAULT_COLUMN_GAP_PX:kr,DEFAULT_PAGE_LAYOUT_SETTINGS:N,PAGE_LAYOUT_METADATA_KEYS:m,PAGE_LAYOUT_PRESETS:gr,PAGE_NUMBER_POSITIONS:fr,PAGE_NUMBER_POSITION_LABELS:Ra,
|
|
330
|
+
PAGE_SIZE_DIMENSIONS_INCHES:ve,PAGE_SIZE_LABELS:Oa,PARAGRAPH_INDENT_STORAGE_UNITS_VERSION:Ve,SUPPORTED_COLUMN_COUNTS:vr,TWIPS_PER_INCH:Ne,areMarginsUniform:Za,arePageLayoutSettingsEqual:Ka,buildPageNumberSlot:Mr,
|
|
331
|
+
getPageDimensionsPx:yr,getRenderedPageLabel:Nr,getRenderedPageNumber:Ht,inchesToPx:W,inferPageSizePresetFromDimensionsPx:hr,isPageLayoutPreset:pr,isPageNumberPosition:Je,isPageSizePreset:Ye,isSupportedColumnCount:Pr,
|
|
332
|
+
mergeSectionLayout:Wt,parseLineNumberingConfig:Dt,parsePageLayoutLengthPx:mr,parsePleadingGridConfig:qe,pxToInches:Ae,pxToTwips:xr,resolvePageLayoutPreset:Ir,resolvePageLayoutSettings:j,resolveSectionLayout:Ar,
|
|
333
|
+
serializeLineNumberingConfig:ke,serializePleadingGridConfig:we,twipsToInches:wr,twipsToPt:Sr,twipsToPx:Ut},Symbol.toStringTag,{value:"Module"})),es=[m.pageBorders,m.pageSize,m.orientation,m.marginTopPx,
|
|
334
|
+
m.marginRightPx,m.marginBottomPx,m.marginLeftPx,m.marginPx,m.indentStepPx,m.blockSpacingPx,m.showPageNumbers,m.pageNumberPosition,m.pageNumberStart,m.pageNumberFormat,m.pageNumberRestart,m.hyphenationEnabled,
|
|
335
|
+
m.lineNumbering,m.pleadingGrid,m.columnCount,m.columnGapTwips,m.oxmlSectPr];function qt(e,t){if(e.set(m.paragraphIndentStorageVersion,Ve),!t)return;const n=j(t),r=Xt(n.pageBorders);r!==void 0?e.set(m.
|
|
336
|
+
pageBorders,r):e.delete(m.pageBorders),e.set(m.pageSize,n.pageSize),e.set(m.orientation,n.orientation),e.set(m.marginTopPx,n.marginTopPx),e.set(m.marginRightPx,n.marginRightPx),e.set(m.marginBottomPx,
|
|
337
|
+
n.marginBottomPx),e.set(m.marginLeftPx,n.marginLeftPx),n.marginTopPx===n.marginRightPx&&n.marginTopPx===n.marginBottomPx&&n.marginTopPx===n.marginLeftPx?e.set(m.marginPx,n.marginTopPx):e.delete(m.marginPx),
|
|
338
|
+
e.set(m.indentStepPx,n.indentStepPx),e.set(m.blockSpacingPx,n.blockSpacingPx),e.set(m.showPageNumbers,n.showPageNumbers),e.set(m.pageNumberPosition,n.pageNumberPosition),e.set(m.pageNumberStart,n.pageNumberStart),
|
|
339
|
+
n.pageNumberFormat!==N.pageNumberFormat?e.set(m.pageNumberFormat,n.pageNumberFormat):e.delete(m.pageNumberFormat),n.pageNumberRestart===!0?e.set(m.pageNumberRestart,!0):e.delete(m.pageNumberRestart),n.
|
|
340
|
+
hyphenationEnabled?e.set(m.hyphenationEnabled,!0):e.delete(m.hyphenationEnabled);const i=ke(n.lineNumbering);i!==void 0?e.set(m.lineNumbering,i):e.delete(m.lineNumbering);const a=we(n.pleadingGrid);a!==
|
|
341
|
+
void 0?e.set(m.pleadingGrid,a):e.delete(m.pleadingGrid),n.columnCount!==N.columnCount?e.set(m.columnCount,n.columnCount):e.delete(m.columnCount),n.columnGapTwips!==N.columnGapTwips?e.set(m.columnGapTwips,
|
|
342
|
+
n.columnGapTwips):e.delete(m.columnGapTwips),n.oxmlSectPr?e.set(m.oxmlSectPr,n.oxmlSectPr):e.delete(m.oxmlSectPr)}function Ke(e){if(!es.some(C=>e.has(C)))return;const t=e.get(m.pageSize),n=e.get(m.orientation),
|
|
343
|
+
r=e.get(m.marginTopPx),i=e.get(m.marginRightPx),a=e.get(m.marginBottomPx),o=e.get(m.marginLeftPx),s=e.get(m.marginPx),c=e.get(m.indentStepPx),l=e.get(m.blockSpacingPx),u=e.get(m.showPageNumbers),d=e.get(
|
|
344
|
+
m.pageNumberPosition),g=e.get(m.pageNumberStart),p=e.get(m.hyphenationEnabled),f=e.get(m.lineNumbering),h=e.get(m.pleadingGrid),b=e.get(m.columnCount),x=e.get(m.columnGapTwips),y=e.get(m.oxmlSectPr),v=Ye(
|
|
345
|
+
t)?t:void 0;return j({pageSize:v,orientation:n==="portrait"||n==="landscape"?n:void 0,marginTopPx:typeof r=="number"?r:void 0,marginRightPx:typeof i=="number"?i:void 0,marginBottomPx:typeof a=="number"?
|
|
346
|
+
a:void 0,marginLeftPx:typeof o=="number"?o:void 0,marginPx:typeof s=="number"?s:void 0,indentStepPx:typeof c=="number"?c:void 0,blockSpacingPx:typeof l=="number"?l:void 0,showPageNumbers:typeof u=="bo\
|
|
347
|
+
olean"?u:void 0,pageNumberPosition:Je(d)?d:void 0,pageNumberStart:typeof g=="number"?g:void 0,pageNumberFormat:$t(e.get(m.pageNumberFormat))?e.get(m.pageNumberFormat):void 0,pageNumberRestart:e.get(m.
|
|
348
|
+
pageNumberRestart)===!0?!0:void 0,hyphenationEnabled:typeof p=="boolean"?p:void 0,pageBorders:ne(e.get(m.pageBorders)),lineNumbering:typeof f=="string"?f:void 0,pleadingGrid:typeof h=="string"?h:void 0,
|
|
349
|
+
columnCount:typeof b=="number"?b:void 0,columnGapTwips:typeof x=="number"?x:void 0,oxmlSectPr:typeof y=="string"&&y?y:void 0})}function Cr(e,t){for(const[n,r]of e.afterState){const i=e.beforeState.get(
|
|
350
|
+
n)??0;if(i>=r)continue;const a=e.doc.store.clients.get(n);if(a)for(let o=S.findIndexSS(a,i);o<a.length&&a[o].id.clock<r;o++){const s=a[o];s instanceof S.Item&&t(s)}}}function Ie(e,t){return typeof e==
|
|
351
|
+
"object"&&e!==null&&e.constructor?.name===t}function I(e){return e instanceof S.XmlElement||Ie(e,"YXmlElement")&&typeof e.nodeName=="string"&&typeof e.getAttribute=="function"&&typeof e.setAttribute==
|
|
352
|
+
"function"&&typeof e.get=="function"&&typeof e.length=="number"}function ts(e){return e instanceof S.XmlText||Ie(e,"YXmlText")&&typeof e.insert=="function"&&typeof e.toDelta=="function"&&typeof e.toString==
|
|
353
|
+
"function"}function Fr(e){return e instanceof S.Map||Ie(e,"YMap")&&typeof e.get=="function"&&typeof e.set=="function"&&typeof e.forEach=="function"}function ns(e){return e instanceof S.Array||Ie(e,"YA\
|
|
354
|
+
rray")&&typeof e.get=="function"&&typeof e.insert=="function"&&typeof e.delete=="function"&&typeof e.length=="number"}function rs(e){return e instanceof S.YXmlEvent||Ie(e,"YXmlEvent")&&typeof e.childListChanged==
|
|
355
|
+
"boolean"}function Vt(e){return e.get(m.paragraphIndentStorageVersion)===Ve}const Jt=new WeakMap;function os(e){let t=Jt.get(e);if(!t){const n=new Map,r=[et(e),e.getXmlFragment("chrome"),e.getXmlFragment(
|
|
356
|
+
"notes")];let i=new WeakMap,a=new WeakMap;const o=d=>{const g=d.getAttribute("id");g&&(n.set(g,d),a.set(d,g));const p=new Set(d.toArray().filter(I));i.set(d,p);for(const f of p)o(f)},s=d=>{const g=a.get(
|
|
357
|
+
d);g&&n.get(g)===d&&n.delete(g);for(const p of i.get(d)??[])s(p);i.delete(d),a.delete(d)},c=d=>{const g=i.get(d)??new Set,p=new Set(d.toArray().filter(I));for(const f of g)p.has(f)||s(f);for(const f of p)
|
|
358
|
+
g.has(f)||o(f);i.set(d,p)},l=()=>{n.clear(),i=new WeakMap,a=new WeakMap;for(const d of r)c(d)};l();const u=d=>{for(const g of d){if(!rs(g))continue;const p=g.target;if(g.changes.added.size||g.changes.
|
|
359
|
+
deleted.size){const f=i.get(p)??new Set;for(const h of g.changes.deleted)for(const b of h.content.getContent())I(b)&&f.delete(b)&&s(b);for(const h of g.changes.added)for(const b of h.content.getContent())
|
|
360
|
+
I(b)&&!f.has(b)&&(f.add(b),o(b));i.set(p,f)}if(I(p)&&g.changes.keys.has("id")){const f=a.get(p);f&&n.get(f)===p&&n.delete(f),a.delete(p);const h=p.getAttribute("id");h&&(n.set(h,p),a.set(p,h))}}};for(const d of r)
|
|
361
|
+
d.observeDeep(u);t={index:n,observer:u,rebuild:l},Jt.set(e,t)}return t.index}function Ze(e){return e.share.has("paragraphs")?e.getArray("paragraphs").length>0:!1}function Yt(e){return e.share.has("con\
|
|
362
|
+
tent")?e.getXmlFragment("content").length>0:!1}function Tr(e){return!!(Yt(e)||Ze(e))}function is(e){if(!Ze(e)||Yt(e))return;const t=e.getArray("paragraphs"),n=e.getXmlFragment("content"),r=e.getMap("m\
|
|
363
|
+
etadata"),i=r?.get("defaultFontFamily"),a=Ke(r),o=j(a).indentStepPx,s=Vt(r);e.transact(()=>{t.forEach(c=>{const l=Kt(c,i,o,s);l&&n.push([l])}),t.delete(0,t.length)})}function Kt(e,t,n,r=!1){const i=e.
|
|
364
|
+
get("type")||"paragraph",a=e.get("id")||P();switch(i){case"page-break":{const o=new S.XmlElement("page-break");o.setAttribute("id",a);const s=e.get("diffState"),c=e.get("suggestionId");return(s==="ins\
|
|
365
|
+
ert"||s==="delete"||s==="equal")&&o.setAttribute("diffState",s),typeof c=="string"&&o.setAttribute("suggestionId",c),o}case"section-break":{const o=new S.XmlElement("section-break");o.setAttribute("id",
|
|
366
|
+
a);const s=e.get("layout");typeof s=="string"&&o.setAttribute("layout",s);const c=e.get("breakType");typeof c=="string"&&o.setAttribute("breakType",c);const l=e.get("diffState"),u=e.get("suggestionId");
|
|
367
|
+
return(l==="insert"||l==="delete"||l==="equal")&&o.setAttribute("diffState",l),typeof u=="string"&&o.setAttribute("suggestionId",u),o}case"toc":{const o=new S.XmlElement("toc");o.setAttribute("id",a);
|
|
368
|
+
const s=e.get("levels");typeof s=="number"&&s>=1&&s<=6&&o.setAttribute("levels",String(s));const c=e.get("instr");typeof c=="string"&&c!==""&&o.setAttribute("instr",c);const l=e.get("direction"),u=e.get(
|
|
369
|
+
"align");(l==="rtl"||l==="ltr")&&o.setAttribute("direction",l),(u==="left"||u==="center"||u==="right"||u==="justify")&&o.setAttribute("align",u);const d=e.get("fontFamily");typeof d=="string"&&d!==""&&
|
|
370
|
+
o.setAttribute("fontFamily",d);const g=e.get("fontSize");typeof g=="number"&&g>0&&o.setAttribute("fontSize",String(g));const p=e.get("color");typeof p=="string"&&p!==""&&o.setAttribute("color",p);const f=e.
|
|
371
|
+
get("diffState"),h=e.get("suggestionId");return(f==="insert"||f==="delete"||f==="equal")&&o.setAttribute("diffState",f),typeof h=="string"&&o.setAttribute("suggestionId",h),o}case"placeholder":{const o=new S.
|
|
372
|
+
XmlElement("placeholder");return o.setAttribute("id",a),o.setAttribute("height",String(e.get("height")||100)),o}case"image":{const o=new S.XmlElement("image");o.setAttribute("id",a);const s=e.get("dif\
|
|
373
|
+
fState"),c=e.get("suggestionId");return(s==="insert"||s==="delete"||s==="equal")&&o.setAttribute("diffState",s),typeof c=="string"&&o.setAttribute("suggestionId",c),o.setAttribute("src",e.get("src")||
|
|
374
|
+
""),e.get("sourceUrl")&&o.setAttribute("sourceUrl",e.get("sourceUrl")),o.setAttribute("width",String(e.get("width")||200)),o.setAttribute("height",String(e.get("height")||200)),e.get("alt")&&o.setAttribute(
|
|
375
|
+
"alt",e.get("alt")),e.get("align")&&o.setAttribute("align",e.get("align")),e.get("uploading")!==void 0&&o.setAttribute("uploading",String(e.get("uploading"))),e.get("tempId")&&o.setAttribute("tempId",
|
|
376
|
+
e.get("tempId")),e.get("originalFormat")&&o.setAttribute("originalFormat",e.get("originalFormat")),e.get("originalDataUrl")&&o.setAttribute("originalDataUrl",e.get("originalDataUrl")),e.get("anchorXml")&&
|
|
377
|
+
o.setAttribute("anchorXml",e.get("anchorXml")),o}case"list":{const o=new S.XmlElement("list");o.setAttribute("id",a),o.setAttribute("variant",e.get("variant")||"unordered"),e.get("startNumber")!==void 0&&
|
|
378
|
+
o.setAttribute("startNumber",String(e.get("startNumber"))),e.get("numberingChainId")&&o.setAttribute("numberingChainId",e.get("numberingChainId")),e.get("numberingFormat")&&o.setAttribute("numberingFo\
|
|
379
|
+
rmat",e.get("numberingFormat"));const s=e.get("items");return s&&s.forEach(c=>{const l=as(c,t);l&&o.push([l])}),o}case"footnote":{const o=new S.XmlElement("footnote");o.setAttribute("id",a),e.get("not\
|
|
380
|
+
eKind")==="endnote"&&o.setAttribute("noteKind","endnote");const s=e.get("children");return s&&s.forEach(c=>{const l=Kt(c,t,n,r);l&&o.push([l])}),o}case"container":{const o=new S.XmlElement("container");
|
|
381
|
+
o.setAttribute("id",a),e.get("borderColor")&&o.setAttribute("borderColor",e.get("borderColor")),typeof e.get("padding")=="number"&&o.setAttribute("padding",String(e.get("padding")));const s=e.get("chi\
|
|
382
|
+
ldren");return s&&s.forEach(c=>{const l=Kt(c,t,n,r);l&&o.push([l])}),o}case"paragraph":default:{const o=new S.XmlElement("paragraph");o.setAttribute("id",a),e.get("heading")!==void 0&&o.setAttribute("\
|
|
383
|
+
heading",String(e.get("heading"))),e.get("align")!==void 0&&o.setAttribute("align",e.get("align")),e.get("lineSpacing")!==void 0&&o.setAttribute("lineSpacing",String(e.get("lineSpacing")));{const f={};
|
|
384
|
+
Ge(f,e.get("pagination"));const h=$e(f);h!==void 0&&o.setAttribute("pagination",h)}{const f=e.get("styleId");typeof f=="string"&&f&&o.setAttribute("styleId",f)}{const f=e.get("direction");(f==="rtl"||
|
|
385
|
+
f==="ltr")&&o.setAttribute("direction",f)}{const f=e.get("tabStops");typeof f=="string"&&f&&o.setAttribute("tabStops",f)}{const f=e.get("borders");typeof f=="string"&&f&&o.setAttribute("borders",f)}{const f=e.
|
|
386
|
+
get("shading");typeof f=="string"&&f&&o.setAttribute("shading",f)}const s=e.get("leftIndent"),c=s===0?0:We(te(s,{indentStepPx:n,storedAsUnits:r}));c!==void 0&&o.setAttribute("leftIndent",String(c));const l=e.
|
|
387
|
+
get("firstLineIndent"),u=l===0?0:He(te(l,{indentStepPx:n,storedAsUnits:r,firstLine:!0}));u!==void 0&&o.setAttribute("firstLineIndent",String(u));const d=e.get("content"),g=new S.XmlText;if(d){const f=ue(
|
|
388
|
+
d);let h=0;for(const b of f)if(typeof b.insert=="string"){const x=b.attributes||{};t&&!x.fontFamily&&(x.fontFamily=t),de(g,h,b.insert,x),h+=b.insert.length}}const p=e.get("_emptyTextMarks");return p&&
|
|
389
|
+
o.setAttribute("_emptyTextMarks",JSON.stringify(p)),o.push([g]),o}}}function as(e,t){if(!e)return null;const n=new S.XmlElement("list-item");n.setAttribute("id",e.get("id")||P()),e.get("checked")!==void 0&&
|
|
390
|
+
n.setAttribute("checked",String(e.get("checked"))),typeof e.get("indentLevel")=="number"&&e.get("indentLevel")>0&&n.setAttribute("indentLevel",String(e.get("indentLevel"))),(e.get("direction")==="rtl"||
|
|
391
|
+
e.get("direction")==="ltr")&&n.setAttribute("direction",e.get("direction"));const r=e.get("content"),i=new S.XmlText;if(r){const o=ue(r);let s=0;for(const c of o)if(typeof c.insert=="string"){const l=c.
|
|
392
|
+
attributes||{};t&&!l.fontFamily&&(l.fontFamily=t),de(i,s,c.insert,l),s+=c.insert.length}}const a=e.get("_emptyTextMarks");return a&&n.setAttribute("_emptyTextMarks",JSON.stringify(a)),n.push([i]),n}const Rr={
|
|
393
|
+
indentStepPx:j(void 0).indentStepPx,storedAsUnits:!1};function Or(e,t,n=!1){return te(e,{indentStepPx:t.indentStepPx,storedAsUnits:t.storedAsUnits,firstLine:n})}function ss(e,t){return cs(e,t)}function cs(e,t){
|
|
394
|
+
const n=new S.Doc({gc:!0,autoLoad:!1,shouldLoad:!1}),r=n.getXmlFragment("content"),i=n.getMap("metadata");if(t?.sharedStyles&&i.set("sharedStylesVersion",1),e.title&&i.set("title",e.title),e.pageless!==
|
|
395
|
+
void 0?i.set("pageless",e.pageless):i.has("pageless")||i.set("pageless",!1),qt(i,e.pageLayout),e.coreProperties&&Object.keys(e.coreProperties).length>0&&i.set("coreProperties",e.coreProperties),e.fontSubstitutes&&
|
|
396
|
+
Object.keys(e.fontSubstitutes).length>0&&i.set("fontSubstitutes",e.fontSubstitutes),e.comments&&e.comments.length>0){const a=n.getMap("comments");for(const o of e.comments)a.set(o.id,o)}if(e.sdtWrappers&&
|
|
397
|
+
e.sdtWrappers.length>0){const a=n.getMap("sdt-wrappers");for(const o of e.sdtWrappers)a.set(o.id,o)}if(e.oxmlRanges&&e.oxmlRanges.length>0){const a=n.getMap("oxml-ranges");for(const o of e.oxmlRanges)
|
|
398
|
+
a.set(o.id,o)}return e.stylesXml&&i.set("stylesXml",e.stylesXml),e.stylesheet&&e.stylesheet.paragraphStyles.length>0&&i.set("stylesheet",e.stylesheet),e.docxSource&&i.set("docxSource",e.docxSource),e.
|
|
399
|
+
watermark&&i.set("watermark",e.watermark),e.chromeImages&&e.chromeImages.length>0&&hn(n,e.chromeImages),n.transact(()=>{const a=n.getXmlFragment("chrome"),o=e.chrome&&e.chrome.length>0?e.chrome:e.children.
|
|
400
|
+
some(l=>l.type==="header-footer")?e.children.filter(l=>l.type==="header-footer"):_t(e.headers,e.footers),s=n.getXmlFragment("notes"),c=e.notes&&e.notes.length>0?e.notes:e.children.filter(l=>l.type==="\
|
|
401
|
+
footnote");e.children.forEach(l=>{l.type==="header-footer"||l.type==="footnote"||oe(l,r)}),o.forEach(l=>{oe(l,a)}),c.forEach(l=>{oe(l,s)})}),n}function Lr(e,t){const n=e.getXmlFragment("content"),r=e.
|
|
402
|
+
getMap("metadata");e.transact(()=>{if(t.title&&r.set("title",t.title),t.pageless!==void 0&&r.set("pageless",t.pageless),qt(r,t.pageLayout),t.coreProperties&&Object.keys(t.coreProperties).length>0&&r.set(
|
|
403
|
+
"coreProperties",t.coreProperties),t.fontSubstitutes&&Object.keys(t.fontSubstitutes).length>0&&r.set("fontSubstitutes",t.fontSubstitutes),t.comments&&t.comments.length>0){const c=e.getMap("comments");
|
|
404
|
+
for(const l of t.comments)c.set(l.id,l)}if(t.sdtWrappers&&t.sdtWrappers.length>0){const c=e.getMap("sdt-wrappers");for(const l of t.sdtWrappers)c.set(l.id,l)}if(t.oxmlRanges&&t.oxmlRanges.length>0){const c=e.
|
|
405
|
+
getMap("oxml-ranges");for(const l of t.oxmlRanges)c.set(l.id,l)}t.stylesXml&&r.set("stylesXml",t.stylesXml),t.stylesheet&&t.stylesheet.paragraphStyles.length>0&&r.set("stylesheet",t.stylesheet),t.docxSource&&
|
|
406
|
+
r.set("docxSource",t.docxSource),t.watermark&&r.set("watermark",t.watermark),t.chromeImages&&t.chromeImages.length>0&&hn(e,t.chromeImages);const i=e.getXmlFragment("chrome"),a=t.chrome&&t.chrome.length>
|
|
407
|
+
0?t.chrome:t.children.some(c=>c.type==="header-footer")?t.children.filter(c=>c.type==="header-footer"):_t(t.headers,t.footers),o=e.getXmlFragment("notes"),s=t.notes&&t.notes.length>0?t.notes:t.children.
|
|
408
|
+
filter(c=>c.type==="footnote");t.children.forEach(c=>{c.type==="header-footer"||c.type==="footnote"||oe(c,n)}),a.forEach(c=>{oe(c,i)}),s.forEach(c=>{oe(c,o)})})}function ls(e,t){const n=Gr(e,t);if(!n)
|
|
409
|
+
return null;const r=e.getMap("metadata"),i=j(Ke(r));return Qe(n,{indentStepPx:i.indentStepPx,storedAsUnits:Vt(r)})}function Er(e){const t=e.getMap("metadata"),n=t?.get("title"),r=t?.get("pageless"),i=Ke(
|
|
410
|
+
t),a={indentStepPx:j(i).indentStepPx,storedAsUnits:Vt(t)},o=e.getXmlFragment("content");let s;if(o.length>0){s=[];for(const k of o.toArray())if(I(k)){const w=Qe(k,a);w&&s.push(w)}}else{const k=e.getArray(
|
|
411
|
+
"paragraphs"),w=t?.get("defaultFontFamily");s=[],k.forEach(G=>{const O=Me(G,w,a);O&&s.push(O)})}const c={type:"doc",children:s};n&&(c.title=n),r!==void 0&&(c.pageless=r),i&&(c.pageLayout=i);const l=t?.
|
|
412
|
+
get("coreProperties");l&&typeof l=="object"&&Object.keys(l).length>0&&(c.coreProperties={...l});const u=t?.get("fontSubstitutes");u&&typeof u=="object"&&Object.keys(u).length>0&&(c.fontSubstitutes={...u},
|
|
413
|
+
Rn(c.fontSubstitutes));const d=e.getXmlFragment("chrome"),g=[];for(const k of d.toArray())if(I(k)){const w=Qe(k,a);w&&w.type==="header-footer"&&g.push(w)}g.length>0&&(c.chrome=g);const p=e.getXmlFragment(
|
|
414
|
+
"notes"),f=[];for(const k of p.toArray())if(I(k)){const w=Qe(k,a);w&&w.type==="footnote"&&f.push(w)}const h=c.children.filter(k=>k.type==="footnote");h.length>0&&(c.children=c.children.filter(k=>k.type!==
|
|
415
|
+
"footnote"),f.push(...h)),f.length>0&&(c.notes=f,An(c));const b=sr(g),x=t?.get("headers"),y=t?.get("footers"),v=b.headers??(x&&Object.keys(x).length>0?x:void 0),C=b.footers??(y&&Object.keys(y).length>
|
|
416
|
+
0?y:void 0);v&&(c.headers=v),C&&(c.footers=C);const H=e.getMap("comments");if(H.size>0){const k=[];H.forEach(w=>{w&&typeof w=="object"&&k.push(w)}),k.length>0&&(k.sort((w,G)=>(w.createdAt??"").localeCompare(
|
|
417
|
+
G.createdAt??"")),c.comments=k)}const $=e.getMap("sdt-wrappers");if($.size>0){const k=[];if($.forEach(w=>{w&&typeof w=="object"&&k.push(w)}),k.length>0){const w=new Map;c.children.forEach((O,Fe)=>{O.id&&
|
|
418
|
+
w.set(O.id,Fe)});const G=O=>O.blockIds?.[0]??O.startBlockId??"";k.sort((O,Fe)=>(w.get(G(O))??Number.MAX_SAFE_INTEGER)-(w.get(G(Fe))??Number.MAX_SAFE_INTEGER)||O.id.localeCompare(Fe.id)),c.sdtWrappers=
|
|
419
|
+
k}}const R=e.getMap("oxml-ranges");if(R.size>0){const k=[];R.forEach(w=>{w&&typeof w=="object"&&k.push(w)}),k.length>0&&(k.sort((w,G)=>w.id.localeCompare(G.id)),c.oxmlRanges=k)}const q=e.getMap("metad\
|
|
420
|
+
ata").get("stylesXml");typeof q=="string"&&q.length>0&&(c.stylesXml=q);const V=e.getMap("metadata").get("stylesheet");V&&typeof V=="object"&&Array.isArray(V.paragraphStyles)&&V.paragraphStyles.length>
|
|
421
|
+
0&&(c.stylesheet=V);const J=e.getMap("metadata").get("docxSource");J&&typeof J=="object"&&Array.isArray(J.spans)&&(c.docxSource=J);const it=e.getMap("metadata").get("watermark");typeof it=="string"&&it.
|
|
422
|
+
length>0&&(c.watermark=it);const an=ut(e);return an&&(c.chromeImages=an),c}function oe(e,t){t.push([jt(e,t.doc??void 0)])}function Qe(e,t=Rr){return be(e,t)}function Me(e,t,n=Rr){const r=e.get("type")||
|
|
423
|
+
"paragraph",i=e.get("id")||P();switch(r){case"page-break":const a={type:"page-break",id:i};{const o=e.get("diffState"),s=e.get("suggestionId");(o==="insert"||o==="delete"||o==="equal")&&(a.diffState=o),
|
|
424
|
+
typeof s=="string"&&(a.suggestionId=s)}return a;case"section-break":{const o={type:"section-break",id:i},s=e.get("layout");if(typeof s=="string")try{o.layout=JSON.parse(s)}catch{}const c=e.get("breakT\
|
|
425
|
+
ype");(c==="nextPage"||c==="continuous"||c==="evenPage"||c==="oddPage")&&(o.breakType=c);const l=e.get("diffState"),u=e.get("suggestionId");return(l==="insert"||l==="delete"||l==="equal")&&(o.diffState=
|
|
426
|
+
l),typeof u=="string"&&(o.suggestionId=u),o}case"toc":{const o={type:"toc",id:i},s=e.get("levels");typeof s=="number"&&s>=1&&s<=6&&(o.levels=s);const c=e.get("instr");typeof c=="string"&&c!==""&&(o.instr=
|
|
427
|
+
c);const l=e.get("direction"),u=e.get("align");(l==="rtl"||l==="ltr")&&(o.direction=l),(u==="left"||u==="center"||u==="right"||u==="justify")&&(o.align=u);const d=e.get("fontFamily");typeof d=="string"&&
|
|
428
|
+
d!==""&&(o.fontFamily=d);const g=e.get("fontSize");typeof g=="number"&&g>0&&(o.fontSize=g);const p=e.get("color");typeof p=="string"&&p!==""&&(o.color=p);const f=e.get("diffState"),h=e.get("suggestion\
|
|
429
|
+
Id");return(f==="insert"||f==="delete"||f==="equal")&&(o.diffState=f),typeof h=="string"&&(o.suggestionId=h),o}case"placeholder":return{type:"placeholder",id:i,height:e.get("height")||100};case"image":{
|
|
430
|
+
const o={type:"image",id:i,src:e.get("src")||"",sourceUrl:e.get("sourceUrl")||void 0,width:e.get("width")||200,height:e.get("height")||200,alt:e.get("alt")||void 0,align:e.get("align")||void 0},s=e.get(
|
|
431
|
+
"diffState"),c=e.get("suggestionId");(s==="insert"||s==="delete"||s==="equal")&&(o.diffState=s),typeof c=="string"&&(o.suggestionId=c);const l=e.get("uploading");l!==void 0&&(o.uploading=l);const u=e.
|
|
432
|
+
get("tempId");u&&(o.tempId=u);const d=e.get("originalFormat");(d==="emf"||d==="wmf")&&(o.originalFormat=d);const g=e.get("originalDataUrl");typeof g=="string"&&g&&(o.originalDataUrl=g);const p=e.get("\
|
|
433
|
+
anchorXml");return typeof p=="string"&&p&&(o.anchorXml=p),o}case"list":{const o=e.get("items"),s=[];o&&o.forEach(g=>{const p=us(g);p&&s.push(p)});const c={type:"list",id:i,variant:e.get("variant")||"u\
|
|
434
|
+
nordered",children:s},l=e.get("startNumber");l!==void 0&&(c.startNumber=l);const u=e.get("numberingChainId");u&&(c.numberingChainId=u);const d=e.get("numberingFormat");return d&&(c.numberingFormat=d),
|
|
435
|
+
c}case"footnote":{const o=e.get("children"),s=[];o&&o.forEach(l=>{const u=Me(l,t,n);u&&s.push(u)});const c={type:"footnote",id:i,children:s};return e.get("noteKind")==="endnote"&&(c.noteKind="endnote"),
|
|
436
|
+
c}case"container":{const o=e.get("children"),s=[];o&&o.forEach(d=>{const g=Me(d,t,n);g&&s.push(g)});const c={type:"container",id:i,children:s},l=e.get("borderColor");l&&(c.borderColor=l);const u=e.get(
|
|
437
|
+
"padding");return typeof u=="number"&&(c.padding=u),c}case"table":{const o=e.get("children"),s=[];o&&o.forEach(y=>{const v=y.get("id")||P(),C=y.get("children"),H=[];C&&C.forEach(V=>{const J=Me(V,t,n);
|
|
438
|
+
J&&H.push(J)});const $={type:"table-row",id:v,children:H},R=y.get("oxmlAttrs");typeof R=="string"&&R&&($.oxmlAttrs=R);const q=y.get("oxmlTrPr");typeof q=="string"&&q&&($.oxmlTrPr=q),s.push($)});const c=e.
|
|
439
|
+
get("columnWidths")||[],l={type:"table",id:i,children:s,columnWidths:c},u=e.get("tableWidth"),d=e.get("align"),g=e.get("borderColor"),p=e.get("borderWidth"),f=e.get("borders"),h=e.get("cellPadding"),b=e.
|
|
440
|
+
get("hasHeader");u!==void 0&&(l.tableWidth=u),(d==="left"||d==="center"||d==="right")&&(l.align=d),g&&(l.borderColor=g),p!==void 0&&(l.borderWidth=p),typeof f=="string"&&f&&(l.borders=f),h!==void 0&&(l.
|
|
441
|
+
cellPadding=h),b!==void 0&&(l.hasHeader=b);const x=e.get("oxmlTblPr");return typeof x=="string"&&x&&(l.oxmlTblPr=x),l}case"table-cell":{const o=e.get("children"),s=[];o&&o.forEach(b=>{const x=Me(b,t,n);
|
|
442
|
+
x&&s.push(x)});const c={type:"table-cell",id:i,children:s},l=e.get("verticalAlign"),u=e.get("backgroundColor");l&&(c.verticalAlign=l),u&&(c.backgroundColor=u);const d=e.get("borders"),g=e.get("padding");
|
|
443
|
+
typeof d=="string"&&d&&(c.borders=d),typeof g=="string"&&g&&(c.padding=g);const p=Number(e.get("colSpan")),f=Number(e.get("rowSpan"));Number.isFinite(p)&&p>1&&(c.colSpan=p),Number.isFinite(f)&&f>1&&(c.
|
|
444
|
+
rowSpan=f);const h=e.get("oxmlTcPr");return typeof h=="string"&&h&&(c.oxmlTcPr=h),c}case"code":{const o=e.get("renderDiagram"),s=e.get("showDiagramSource"),c={type:"code",id:i,content:e.get("content")||
|
|
445
|
+
"",language:e.get("language")||void 0,renderDiagram:typeof o=="boolean"?o:void 0,showDiagramSource:typeof s=="boolean"?s:void 0},l=e.get("diffState"),u=e.get("suggestionId");return(l==="insert"||l==="\
|
|
446
|
+
delete"||l==="equal")&&(c.diffState=l),typeof u=="string"&&(c.suggestionId=u),c}case"math":{const o=e.get("displayMode")||"block",s={type:"math",id:i,content:e.get("content")||"",displayMode:o},c=e.get(
|
|
447
|
+
"align");(c==="left"||c==="center"||c==="right"||c==="justify")&&(s.align=c);const l=e.get("diffState"),u=e.get("suggestionId");return(l==="insert"||l==="delete"||l==="equal")&&(s.diffState=l),typeof u==
|
|
448
|
+
"string"&&(s.suggestionId=u),e.get("showDiagramSource")===!0&&(s.showDiagramSource=!0),s}case"paragraph":default:{const o={type:"paragraph",id:i,children:[]},s=e.get("heading"),c=e.get("align"),l=e.get(
|
|
449
|
+
"lineSpacing"),u=e.get("leftIndent"),d=e.get("firstLineIndent"),g=e.get("structuralSuggestionId"),p=e.get("structuralSuggestionKind"),f=e.get("structuralSuggestionRole");s!==void 0&&(o.heading=s),c!==
|
|
450
|
+
void 0&&(o.align=c),l!==void 0&&(o.lineSpacing=l),Ge(o,e.get("pagination"));{const y=e.get("styleId");typeof y=="string"&&y&&(o.styleId=y)}{const y=e.get("direction");(y==="rtl"||y==="ltr")&&(o.direction=
|
|
451
|
+
y)}{const y=e.get("tabStops");typeof y=="string"&&y&&(o.tabStops=y)}{const y=e.get("borders");typeof y=="string"&&y&&(o.borders=y)}{const y=e.get("shading");typeof y=="string"&&y&&(o.shading=y)}{const y=e.
|
|
452
|
+
get("oxmlAttrs");typeof y=="string"&&y&&(o.oxmlAttrs=y);const v=e.get("oxmlPPr");typeof v=="string"&&v&&(o.oxmlPPr=v)}typeof g=="string"&&(o.structuralSuggestionId=g),(p==="insert"||p==="delete"||p===
|
|
453
|
+
"split"||p==="merge"||p==="change")&&(o.structuralSuggestionKind=p),(f==="before"||f==="after")&&(o.structuralSuggestionRole=f);const h=Or(u,n);u===0?o.leftIndent=0:h!==void 0&&(o.leftIndent=h);const b=Or(
|
|
454
|
+
d,n,!0);d===0?o.firstLineIndent=0:b!==void 0&&(o.firstLineIndent=b);const x=e.get("content");if(x){const y=jr(x);if(y.length>0)o.children=y;else{const v=e.get("_emptyTextMarks"),C={type:"text",text:""};
|
|
455
|
+
v&&Object.keys(v).length>0?C.marks=v:C.marks={fontFamily:pe},o.children=[C]}}else o.children=[{type:"text",text:"",marks:{fontFamily:pe}}];return t&&o.children.forEach(y=>{y.type==="text"&&(y.marks={fontFamily:t,
|
|
456
|
+
...y.marks||{}})}),o}}}function us(e){if(!e)return null;const t={type:"list-item",id:e.get("id")||P(),children:[]},n=e.get("checked");n!==void 0&&(t.checked=n);const r=e.get("indentLevel");typeof r=="\
|
|
457
|
+
number"&&r>0&&(t.indentLevel=r);for(const o of ce){const s=e.get(o);typeof s=="number"&&Number.isFinite(s)&&s>=0&&(t[o]=s)}const i=e.get("direction");(i==="rtl"||i==="ltr")&&(t.direction=i);const a=e.
|
|
458
|
+
get("content");if(a){const o=jr(a);if(o.length>0)t.children=o;else{const s=e.get("_emptyTextMarks");t.children=[{type:"text",text:"",marks:s||{fontFamily:pe}}]}}else t.children=[{type:"text",text:"",marks:{
|
|
459
|
+
fontFamily:pe}}];return t}function jr(e){const t=[];return ue(e).forEach(n=>{if(typeof n.insert=="string"){const r=n.attributes||{},i={type:"text",text:n.insert};i.marks=St(r),t.push(i)}}),_n(t)}function et(e){
|
|
460
|
+
return e.getXmlFragment("content")}const Br="block-id-repair";function ds(e,t){let n=0;const r=i=>{for(const a of i.toArray())I(a)&&(a.getAttribute("id")===t&&n++,r(a))};for(const i of["content","chro\
|
|
461
|
+
me","notes"])e.share.has(i)&&r(e.getXmlFragment(i));return n}function fs(e){const t=new Set,n=r=>{if(r instanceof S.XmlFragment){if(I(r)){const i=r.getAttribute("id");i&&t.add(i)}for(const i of r.toArray())
|
|
462
|
+
n(i)}};return Cr(e,r=>{if(r.deleted)return;const i=r.content;if(i instanceof S.ContentType)n(i.type);else if(r.parentSub==="id"&&I(r.parent)){const a=r.parent.getAttribute("id");a&&t.add(a)}}),t}function tt(e,t,n){
|
|
463
|
+
if(Array.isArray(e))return e.map(i=>tt(i,t,n));if(!e||typeof e!="object")return e;const r=e;return Object.fromEntries(Object.entries(r).map(([i,a])=>{const o=i==="id"&&typeof r.type=="string"&&!["bloc\
|
|
464
|
+
k-change","block-insert","block-delete","table-change","inline-text","inline-format","paragraph-split","paragraph-merge"].includes(r.type);return a===t&&(o||/^(blockId|tableId|rowId|cellId|itemId|firstBlockId|secondBlockId|anchorBlockId|insertedBlockId|cleanupTrailingParagraphId)$/.
|
|
465
|
+
test(i))?[i,n]:(i==="blockIds"||i==="sequenceBlockIds")&&Array.isArray(a)?[i,a.map(s=>s===t?n:s)]:[i,tt(a,t,n)]}))}function gs(e,t,n){for(const r of["structuralSuggestionRecord","structuralSuggestionR\
|
|
466
|
+
ecords"]){const i=e.getAttribute(r);if(i)try{const a=tt(JSON.parse(i),t,n);e.setAttribute(r,JSON.stringify(a));const o=e.doc?.share.get("liveSuggestions");if(Fr(o))for(const s of Array.isArray(a)?a:[a])
|
|
467
|
+
s?.id&&o.has(s.id)&&o.set(s.id,tt(o.get(s.id),t,n))}catch{}}}function ps(e){let t=P();for(;e.has(t);)t=P();return t}function _r(e,t,n,r,i){const a=e.toArray();for(let o=a.length-1;o>=0;o--){const s=a[o];
|
|
468
|
+
I(s)&&i.has(s)&&e.delete(o,1)}for(const o of e.toArray()){if(!I(o))continue;const s=o.getAttribute("id");if(s)if(t.has(s)){const c=o._item.id,l=`dup_${c.client.toString(36)}_${c.clock.toString(36)}`;let u=l;
|
|
469
|
+
for(let d=1;r.has(u);d++)u=`${l}_${d}`;r.add(u),o.setAttribute("id",u),gs(o,s,u),n.push({oldId:s,newId:u}),t.add(u)}else t.add(s);_r(o,t,n,r,i)}}function $r(e,t,n){for(const r of e.toArray()){if(!Fr(r))
|
|
470
|
+
continue;const i=r.get("id");if(typeof i=="string"&&i.length>0)if(t.has(i)){const a=ps(t);r.set("id",a),n.push({oldId:i,newId:a}),t.add(a)}else t.add(i);r.forEach(a=>{ns(a)&&$r(a,t,n)})}}function ms(e,t={}){
|
|
471
|
+
const n=new Set,r=[],i=[],a={duplicatesFound:0,remappedIds:r,droppedIds:i},o=e.share.has("paragraphs")&&e.getArray("paragraphs").length>0,s=t.transaction?fs(t.transaction):null;if(s&&s.size===0&&!o)return a;
|
|
472
|
+
const c=["content","chrome","notes"].filter(f=>e.share.has(f)).map(f=>e.getXmlFragment(f)),l=new Set,u=new Map;let d=!1;const g=f=>{for(const h of f.toArray()){if(!I(h))continue;const b=h.getAttribute(
|
|
473
|
+
"id");if(b&&(l.has(b)&&(d=!0),l.add(b),!s||s.has(b))){const x=u.get(b);x?x.push(h):u.set(b,[h])}g(h)}};if(c.forEach(g),!d&&!o)return a;const p=new Set;if(t.shouldDrop)for(const f of u.values()){if(f.length<
|
|
474
|
+
2)continue;const h=f.filter(b=>t.shouldDrop(b));if(!(h.length===0||h.length===f.length))for(const b of h)p.add(b),i.push(b.getAttribute("id"))}return e.transact(()=>{for(const f of c)_r(f,n,r,l,p);if(o){
|
|
475
|
+
const f=e.getArray("paragraphs");$r(f,n,r)}},Br),{duplicatesFound:r.length+i.length,remappedIds:r,droppedIds:i}}function hs(e){return Yt(e)?et(e).length:Ze(e)?e.getArray("paragraphs").length:0}function Gr(e,t){
|
|
476
|
+
const n=os(e),r=n.get(t)??null,i=r?r._item:null;return r&&!i?.deleted&&r.getAttribute("id")===t?r:(Jt.get(e).rebuild(),n.get(t)??null)}function ie(e,t){const n=e.toArray();for(let r=0;r<n.length;r++){
|
|
477
|
+
const i=n[r];if(I(i)){if(i.getAttribute("id")===t)return{yBlock:i,yParent:e,index:r};if(i.nodeName==="list"||i.nodeName==="container"||i.nodeName==="footnote"||i.nodeName==="header-footer"||i.nodeName===
|
|
478
|
+
"table-cell"){const a=ie(i,t);if(a)return a}if(i.nodeName==="table"){const a=i.toArray();for(let o=0;o<a.length;o++){const s=a[o];if(I(s)&&s.nodeName==="table-row"){if(s.getAttribute("id")===t)return{
|
|
479
|
+
yBlock:s,yParent:i,index:o};const c=ie(s,t);if(c)return c}}}if(i.nodeName==="table-row"){const a=ie(i,t);if(a)return a}}}return null}function bs(e,t){const n=et(e),r=ie(n,t);return r||ie(e.getXmlFragment(
|
|
480
|
+
"chrome"),t)||ie(e.getXmlFragment("notes"),t)}function ys(e){for(const t of e.toArray())if(ts(t))return t;return null}let xs=0;function Ss(){const e=Date.now().toString(36),t=Math.random().toString(36).
|
|
481
|
+
substring(2,9),n=(xs++).toString(36);return`${e}-${t}-${n}`}const Xr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function zr(){const e=new Uint8Array(8);crypto.getRandomValues(e);
|
|
482
|
+
let t="";for(let n=0;n<8;n++)t+=Xr[e[n]%Xr.length];return t}const Zt="seed-claims",ws="revise:seed-race-repair";function Qt(e){const t=[];for(const n of e.toArray())if(n instanceof S.XmlElement){const r=n.
|
|
483
|
+
getAttribute("id");r&&t.push(r)}return t}function Dr(e){return{blockIds:Qt(e.getXmlFragment("content")),chromeIds:Qt(e.getXmlFragment("chrome")),noteIds:Qt(e.getXmlFragment("notes")),commentIds:[...e.
|
|
484
|
+
getMap("comments").keys()],sdtIds:[...e.getMap("sdt-wrappers").keys()],oxmlRangeIds:[...e.getMap("oxml-ranges").keys()]}}function ae(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function en(e,t){
|
|
485
|
+
const n=Dr(e);e.transact(()=>{Lr(e,t);const r=Dr(e),i={clientId:e.clientID,blockIds:ae(r.blockIds,n.blockIds),chromeIds:ae(r.chromeIds,n.chromeIds),noteIds:ae(r.noteIds,n.noteIds),commentIds:ae(r.commentIds,
|
|
486
|
+
n.commentIds),sdtIds:ae(r.sdtIds,n.sdtIds),oxmlRangeIds:ae(r.oxmlRangeIds,n.oxmlRangeIds)},a=`${Date.now().toString(36).padStart(9,"0")}-${zr()}`;e.getMap("metadata").set("seedNonce",a),e.getMap(Zt).set(
|
|
487
|
+
a,i)})}function Ur(e){const t=e._item;return typeof t?.id?.client=="number"?t.id.client:null}function tn(e,t,n,r){if(t.size===0)return 0;const i=new Set,a=[],o=new Set;if(r!==void 0){for(const s of e.
|
|
488
|
+
toArray())if(s instanceof S.XmlElement&&Ur(s)===r){const c=s.getAttribute("id");c&&o.add(c)}}for(let s=0;s<e.length;s++){const c=e.get(s);if(!(c instanceof S.XmlElement))continue;const l=c.getAttribute(
|
|
489
|
+
"id")??"";t.has(l)&&(n.has(l)&&(r!==void 0&&o.has(l)?Ur(c)===r&&!i.has(l):!i.has(l))?i.add(l):a.push(s))}for(let s=a.length-1;s>=0;s--)e.delete(a[s],1);return a.length}function Wr(e){const t=e.getMap(
|
|
490
|
+
Zt);if(t.size<2)return null;const n=e.getMap("metadata").get("seedNonce"),r=[...t.keys()].sort(),i=typeof n=="string"&&t.has(n)?n:r[0],a=[i,...r.filter(u=>u!==i)],o=t.get(a[0]),s=new Set([...o?.blockIds??
|
|
491
|
+
[],...o?.chromeIds??[],...o?.noteIds??[]]),c=a.slice(1);let l=0;return e.transact(()=>{for(const u of c){const d=t.get(u);if(d){l+=tn(e.getXmlFragment("content"),new Set(d.blockIds??[]),s,o?.clientId),
|
|
492
|
+
tn(e.getXmlFragment("chrome"),new Set(d.chromeIds??[]),s,o?.clientId),tn(e.getXmlFragment("notes"),new Set(d.noteIds??[]),s,o?.clientId);const g=new Set([...o?.commentIds??[],...o?.sdtIds??[],...o?.oxmlRangeIds??
|
|
493
|
+
[]]);for(const p of d.commentIds??[])g.has(p)||e.getMap("comments").delete(p);for(const p of d.sdtIds??[])g.has(p)||e.getMap("sdt-wrappers").delete(p);for(const p of d.oxmlRangeIds??[])g.has(p)||e.getMap(
|
|
494
|
+
"oxml-ranges").delete(p)}t.delete(u)}},ws),{losingClaims:c.length,removedBlocks:l}}function ks(e,t){const n=e.getMap(Zt),r=()=>{const i=Wr(e);i&&t&&t(i)};return n.observe(r),r(),()=>n.unobserve(r)}function nn(){
|
|
495
|
+
return new S.Doc({gc:!0,autoLoad:!1,shouldLoad:!1})}const rn=["window","document","DOMParser","XMLSerializer","Node","Element","HTMLElement","NodeFilter","XPathResult","File"];let nt=null;function vs(e){
|
|
496
|
+
const t=globalThis;if(t.__reviseServerRuntime=!0,rn.every(r=>t[r]))return;const n=e().window;for(const r of rn)t[r]??(t[r]=n[r]);t.navigator??(t.navigator=n.navigator)}function Ce(){if(!nt){const e=Ps();
|
|
497
|
+
e.catch(()=>{nt=null}),nt=e}return nt}async function Ps(){const e=globalThis;if(e.__reviseServerRuntime=!0,!e.File){const{File:i}=await import("node:buffer");i&&(e.File=i)}if(rn.every(i=>e[i]))return;
|
|
498
|
+
let t;try{t=await import("jsdom")}catch(i){const a=new Error("@reviseio/editor/server needs the optional peer dependency jsdom in Node. Install it with: npm i jsdom");throw a.cause=i,a}const{JSDOM:n,VirtualConsole:r}=t;
|
|
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
|
+
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
|
+
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-L10HXM3U.js");
|
|
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-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
|
+
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-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
|
+
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
|
+
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
|
+
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,
|
|
516
|
+
jo as aj,ce as ak,ko as al,ds as am,ua as an,ls as ao,ta as ap,Br as aq,Wt as ar,Sa as as,ye as at,ne as au,$t as av,lr as aw,pr as ax,Ir as ay,Ye as az,Lr as b,Ms as b$,Gi as b0,So as b1,xo as b2,Co as b3,
|
|
517
|
+
Go as b4,Io as b5,$o as b6,Xo as b7,ve as b8,Rn as b9,oi as bA,ht as bB,kr as bC,zr as bD,Yi as bE,Un as bF,Dn as bG,Ji as bH,Jn as bI,Yn as bJ,xi as bK,yi as bL,zi as bM,Bo as bN,Jo as bO,Wo as bP,Ma as bQ,
|
|
518
|
+
me as bR,Es as bS,nn as bT,Ls as bU,Os as bV,rt as bW,Rs as bX,Fs as bY,Is as bZ,on as b_,Ca as ba,ba as bb,Fa as bc,dr as bd,$i as be,Hn as bf,Eo as bg,Bn as bh,St as bi,L as bj,fi as bk,mi as bl,ri as bm,
|
|
519
|
+
ai as bn,Sr as bo,ur as bp,Ia as bq,Nr as br,Ot as bs,bi as bt,U as bu,Bi as bv,gi as bw,pi as bx,hi as by,ni as bz,Ht as c,Ts as c0,ot as c1,en as c2,ss as d,yr as e,ka as f,Ss as g,da as h,wa as i,Ce as j,
|
|
520
|
+
Tr as k,Cn as l,mo as m,ut as n,ks as o,he as p,Ke as q,j as r,Ve as s,Ut as t,be as u,sr as v,An as w,jt as x,Er as y,jn as z};
|