@docx-editor.dev/core 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +1 -1
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.js +1 -1
- package/dist/{chunk-KRBBWATQ.js → chunk-2LXGB2X7.js} +1 -1
- package/dist/chunk-3OMDEMLL.js +1 -0
- package/dist/{chunk-PCPBDYEL.cjs → chunk-6CPYOVRT.cjs} +1 -1
- package/dist/chunk-AKF5KM2W.cjs +4 -0
- package/dist/{chunk-QTFAXWVI.cjs → chunk-BOGQGMMU.cjs} +1 -1
- package/dist/chunk-CVNDMQIX.cjs +26 -0
- package/dist/{chunk-FWX535CS.cjs → chunk-DF7F7TNU.cjs} +1 -1
- package/dist/{chunk-UMBHUW6R.js → chunk-G765WG4R.js} +1 -1
- package/dist/{chunk-BUDXZ7T2.cjs → chunk-IEXYOLNR.cjs} +5 -5
- package/dist/chunk-J3EM5ZEA.js +18 -0
- package/dist/{chunk-QK23BSRK.cjs → chunk-JDAAGZNE.cjs} +1 -1
- package/dist/chunk-JNE6QF47.js +26 -0
- package/dist/{chunk-KV5HFE23.cjs → chunk-JQTVFP72.cjs} +1 -1
- package/dist/chunk-JXL25DRU.js +11 -0
- package/dist/{chunk-GRVRQBKU.js → chunk-KPSGB64S.js} +1 -1
- package/dist/chunk-P4SBMHHO.cjs +5 -0
- package/dist/chunk-QQAF64KN.js +5 -0
- package/dist/chunk-SI5FLZGU.js +4 -0
- package/dist/{chunk-DZOGUV7O.js → chunk-SOUJNWXV.js} +1 -1
- package/dist/chunk-T4TKRNZT.cjs +11 -0
- package/dist/{chunk-EHT4LKKZ.cjs → chunk-TBFZZX7Z.cjs} +1 -1
- package/dist/chunk-VPKKYCZI.cjs +2 -0
- package/dist/chunk-W3ZUPQIZ.cjs +18 -0
- package/dist/chunk-XMWH2R23.js +5 -0
- package/dist/{chunk-6QS5WL63.js → chunk-XWXJB4J7.js} +1 -1
- package/dist/chunk-YIBEBHT3.js +2 -0
- package/dist/{chunk-RLO64PHP.cjs → chunk-ZSM6X52G.cjs} +1 -1
- package/dist/chunk-ZXAGLAY2.js +2 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.js +1 -1
- package/dist/contracts/editor.d.ts +3 -3
- package/dist/{editor-DhUQsWWH.d.ts → editor-BU6rjQZz.d.ts} +3 -1
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.d.ts +12 -12
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +5 -5
- package/dist/export.js +1 -1
- package/dist/{font-resolver-BwoHFBlr.d.ts → font-resolver-CPO7wtg6.d.ts} +1 -1
- package/dist/{index-BYaCkGKO.d.ts → index-BOkQYOsZ.d.ts} +21 -17
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-DpWQG26a.d.ts → layout-shaping-BOOxnLxF.d.ts} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +55 -40
- package/dist/layout.js +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +3 -3
- package/dist/output.js +1 -1
- package/dist/{semantic-cell-selection-B8GF_H2e.d.ts → semantic-cell-selection-BtO2s2Za.d.ts} +2 -2
- package/dist/{semantic-interaction-DQjtIruQ.d.ts → semantic-interaction-COMnWyBQ.d.ts} +1 -1
- package/dist/{semantic-paint-DoPl85nR.d.ts → semantic-paint-C032N0ps.d.ts} +1 -1
- package/dist/{semantic-records-DB0VgWsr.d.ts → semantic-records-BSjo-xck.d.ts} +3 -3
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +0 -1
- package/dist/store.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-4OAXZNBU.js +0 -5
- package/dist/chunk-6745I4XF.cjs +0 -20
- package/dist/chunk-6KA3L3FR.cjs +0 -11
- package/dist/chunk-DYRXA5UJ.cjs +0 -2
- package/dist/chunk-F5LAOPAD.js +0 -20
- package/dist/chunk-JN62FLHE.cjs +0 -4
- package/dist/chunk-Q4RDWB3U.cjs +0 -18
- package/dist/chunk-T7RGKBCE.cjs +0 -5
- package/dist/chunk-VE6H5EJA.js +0 -5
- package/dist/chunk-WHG23WNI.js +0 -1
- package/dist/chunk-XBYZTDF7.js +0 -4
- package/dist/chunk-XRBPZCNK.js +0 -11
- package/dist/chunk-Y5JCIWTF.js +0 -2
- package/dist/chunk-ZA6HEWUM.js +0 -2
- package/dist/chunk-ZCRSPN4Q.js +0 -18
package/dist/chunk-Y5JCIWTF.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {N as N$1,ma,M,L}from'./chunk-XBYZTDF7.js';import {va,Wb,xa,$a,Jb,Ya,Za,Ja,ya,ta,Ca,Sb,da,ca,ke as ke$1,sa,Tb,Aa,Sd,bb,db}from'./chunk-ZCRSPN4Q.js';function Ue(t,e,o){let n=e.marker?.picture,i=o.urlRegistry;if(!n||n.resource.kind!=="ready"||!i)return null;let r=o.scale,a=i.urlForReady(n.resource.validatedHandle,n.resource.mime);if(a===null)return null;let s=n.box,l=t.createElement("span");l.className="docx-list-marker",l.dataset.docxMarker="",l.setAttribute("contenteditable","false"),l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.left=`${(s.x-e.box.x)*r}px`,l.style.top=`${(s.y-e.box.y)*r}px`,l.style.width=`${s.width*r}px`,l.style.height=`${s.height*r}px`,l.style.display="block",l.style.overflow="hidden";let d=t.createElement("img");return d.className="docx-list-marker-image",d.setAttribute("src",a),d.setAttribute("alt",""),d.setAttribute("draggable","false"),d.style.display="block",d.style.width=`${s.width*r}px`,d.style.height=`${s.height*r}px`,d.style.maxWidth="none",d.style.maxHeight="none",l.append(d),l}function je(t,e,o,n){let i=t.createElement("span");i.dataset.docxNoteRule="single",i.setAttribute("contenteditable","false"),i.setAttribute("aria-hidden","true"),i.style.display="inline-block",i.style.position="relative",i.style.verticalAlign="top",i.style.width=`${e.box.width*n}px`,i.style.height=`${Math.min(e.box.height+(o.leading??0),o.box.height)*n}px`;let r=ke$1(e,o),a=t.createElement("span");return a.style.position="absolute",a.style.left="0",a.style.top=`${(r.y-o.box.y)*n}px`,a.style.width=`${r.width*n}px`,a.style.height=`${r.height*n}px`,a.style.backgroundColor=e.style.color?`#${e.style.color}`:"#000000",i.append(a),i}function Y(t){return t==="double"||t==="triple"||t==="doubleWave"||t.startsWith("thinThick")||t.startsWith("thickThin")}function I(t,e,o,n,i,r){switch(e){case "dashed":case "dashSmallGap":case "dotDash":case "dotDotDash":case "dashDotStroked":{let a=Math.max(4,4*r);t.style.backgroundColor="transparent",t.style.backgroundImage=`linear-gradient(to ${n?"bottom":"right"}, #${o} 60%, transparent 60%)`,t.style.backgroundSize=n?`100% ${a}px`:`${a}px 100%`;return}case "dotted":{let a=Math.max(3,3*r);t.style.backgroundColor="transparent",t.style.backgroundImage=`linear-gradient(to ${n?"bottom":"right"}, #${o} 35%, transparent 35%)`,t.style.backgroundSize=n?`100% ${a}px`:`${a}px 100%`;return}case "double":case "doubleWave":case "triple":case "thinThickSmallGap":case "thickThinSmallGap":case "thinThickThinSmallGap":case "thinThickMediumGap":case "thickThinMediumGap":case "thinThickThinMediumGap":case "thinThickLargeGap":case "thickThinLargeGap":case "thinThickThinLargeGap":{let a=i/3;t.style.backgroundColor="transparent",t.style.backgroundImage=`linear-gradient(to ${n?"right":"bottom"}, #${o} 0px, #${o} ${a}px, transparent ${a}px, transparent ${a*2}px, #${o} ${a*2}px)`;return}case "threeDEmboss":case "ridge":{t.style.backgroundColor="transparent";let a=n?"borderLeft":"borderTop";t.style[a]=`${Math.max(1,i)}px ridge #${o}`,n?t.style.width="0px":t.style.height="0px";return}case "threeDEngrave":case "groove":{t.style.backgroundColor="transparent";let a=n?"borderLeft":"borderTop";t.style[a]=`${Math.max(1,i)}px groove #${o}`,n?t.style.width="0px":t.style.height="0px";return}case "inset":{t.style.backgroundColor="transparent";let a=n?"borderLeft":"borderTop";t.style[a]=`${Math.max(1,i)}px inset #${o}`,n?t.style.width="0px":t.style.height="0px";return}case "outset":{t.style.backgroundColor="transparent";let a=n?"borderLeft":"borderTop";t.style[a]=`${Math.max(1,i)}px outset #${o}`,n?t.style.width="0px":t.style.height="0px";return}default:return}}var io=/^[0-9A-Fa-f]{6}$/;function Ge(t,e,o,n){for(let{box:i,edge:r,side:a}of Tb(o)){let s=r.color&&io.test(r.color)?r.color:"000000",l=t.createElement("span");l.className=`docx-run-border docx-run-border-${a}`,l.dataset.docxMarker="",l.setAttribute("aria-hidden","true"),l.setAttribute("contenteditable","false"),Object.assign(l.style,{position:"absolute",pointerEvents:"none",left:`${(i.x-o.contentX)*n}px`,top:`${(i.y-o.box.y)*n}px`,width:`${i.width*n}px`,height:`${i.height*n}px`,backgroundColor:`#${s}`});let d=a==="left"||a==="right";I(l,r.val,s,d,(d?i.width:i.height)*n,n),e.append(l);}}function We(t,e){let o=e.fieldAtom?.formControl;if(o?.kind!=="dropdown"||o.entries.length===0)return;let n=t.ownerDocument.createElement("select");n.dataset.docxFormDropdown="",n.dataset.docxMarker="",n.setAttribute("aria-label",o.accessibleName??e.text);for(let[i,r]of o.entries.entries()){let a=t.ownerDocument.createElement("option");a.value=String(i),a.textContent=r,n.append(a);}n.selectedIndex=o.selectedIndex,Object.assign(n.style,{position:"absolute",inset:"0",width:"100%",height:"100%",opacity:"0",cursor:"pointer",font:"inherit",padding:"0",border:"0"}),t.style.position="relative",t.append(n);}function Ve(t,e,o){let n=e.fieldAtom?.formControl;if(n?.kind!=="checkbox")return;t.dataset.docxFormCheckbox="",t.dataset.checked=String(n.checked),t.setAttribute("role","checkbox"),t.tabIndex=0,t.setAttribute("aria-checked",String(n.checked)),n.accessibleName&&t.setAttribute("aria-label",n.accessibleName),t.style.width=`${e.box.width*o}px`;let i=t.ownerDocument.createElement("span");i.className="docx-form-checkbox-hit",i.dataset.docxMarker="",i.setAttribute("aria-hidden","true"),t.append(i);}var $=8,Ye={color:"painted",background:"painted",activeBackground:"painted",spanClassName:"painted",avatarUrl:"card-only"},Ze=Object.keys(Ye),ao=Ze.filter(t=>Ye[t]==="painted"),so=new Set(["http","https","data","blob"]),lo=/^([a-zA-Z][a-zA-Z0-9+.-]*):/;function co(t){let e=t.replace(/[\u0000-\u0020\u007f]/g,"");if(e.length===0)return;let o=lo.exec(e);if(o)return !so.has(o[1].toLowerCase())||/^data:/i.test(e)&&!/^data:image\/(?!svg)/i.test(e)?void 0:e;let n=i=>e[i]==="/"||e[i]==="\\";return n(0)&&n(1)?void 0:e}function uo(t){if(typeof t=="string")return t.length>0?{color:t}:null;if(t===null||typeof t!="object")return null;let e={},o=Object.prototype.hasOwnProperty;for(let n of Ze){if(!o.call(t,n))continue;let i=t[n];if(!(typeof i!="string"||i.length===0)){if(n==="avatarUrl"){let r=co(i);r!==void 0&&(e.avatarUrl=r);continue}e[n]=i;}}return Object.keys(e).length>0?e:null}function J(t){return `var(--doc-review-author-${t%$})`}function Je(t){let e=new Map;if(t===void 0||t==="kind"||t==="author")return e;for(let[o,n]of Object.entries(t.authors)){let i=uo(n);i&&e.set(o,i);}return e}function jn(t,e){let o=Je(e);return [...t].map(([n,i])=>{let r=o.get(n);return {author:n,slot:i,color:r?.color??J(i),...r?{style:r}:{}}})}var yo=128;function Z(t,e,o=yo){let n=e.length<o?e.length:o,i=t;for(let r=0;r<n;r+=1)i=Math.imul(i^e.charCodeAt(r),16777619);return Math.imul(i^e.length,16777619)}function po(t,e,o){let n=Z(2166136261,o);for(let i of t.keys())n=Z(n,i);for(let[i,r]of e){n=Z(n,i);for(let a of ao)n=Z(n,r[a]??"",1/0);}return `${t.size}.${e.size}.${(n>>>0).toString(36)}`}function Qe(t){return t===null?"kind":t.key}var le=new WeakMap;function et(t,e,o){if(t==="kind")return null;let n=le.get(e);if(n&&n.option===t&&n.authorSlots===o)return n.context;let i=Je(t),r=t===void 0||t==="author"?"author":t.others??"author";if(i.size===0&&r==="kind")return le.set(e,{option:t,authorSlots:o,context:null}),null;let a=o??fo(e),s=new Map;for(let[d,c]of i){if(!c.spanClassName)continue;let u=c.spanClassName.split(/\s+/).filter(h=>h.length>0);u.length>0&&s.set(d,u);}let l={authorSlots:a,styles:i,classTokens:s,others:r,key:po(a,i,r)};return le.set(e,{option:t,authorSlots:o,context:l}),l}var Xe=new WeakMap;function ho(t){let e=Xe.get(t);if(e)return e;let o=[],n=new Set,i=r=>{r===""||n.has(r)||(n.add(r),o.push(r));};for(let r of va(t)){for(let s of r.lines)for(let l of s.spans){let d=l.revisions;if(d!==void 0)for(let c=0;c<d.length;c+=1)i(d[c].author);for(let c of l.props){if(c.localName!=="rPrChange"&&c.localName!=="pPrChange")continue;let u=c.attributes?.author;i(u??"");break}}for(let s of r.lines){let l=s.drawings;if(l!==void 0)for(let d=0;d<l.length;d+=1){let c=l[d].revisions;if(c!==void 0)for(let u=0;u<c.length;u+=1)i(c[u].author);}}let a=r.markRevisions;if(a)for(let s=0;s<a.length;s+=1)i(a[s].author);}return Xe.set(t,o),o}var qe=new WeakMap;function fo(t){let e=qe.get(t);if(e)return e;let o=new Map,n=i=>{for(let r of ho(i))o.has(r)||o.set(r,o.size);};for(let i of t.pages){n(i.fragments),i.header&&n(i.header.fragments),i.footer&&n(i.footer.fragments);for(let r of [i.footnotes,i.endnotes])if(r){r.separator&&n(r.separator.fragments),r.continuationNotice&&n(r.continuationNotice.fragments);for(let a of r.notes)n(a.fragments);}for(let r of [i.anchoredDrawings,i.header?.anchoredDrawings,i.footer?.anchoredDrawings])if(r)for(let a of r){if(a.accessibility.hidden)continue;let s=a.revisions;if(s!==void 0)for(let l=0;l<s.length;l+=1){let d=s[l].author;d!==""&&!o.has(d)&&o.set(d,o.size);}a.textboxStory&&n(a.textboxStory.fragments);}}return qe.set(t,o),o}function go(t,e){let o=null;for(let n of e)n===""||t.has(n)||(o===null&&(o=new Map(t)),o.has(n)||o.set(n,o.size));return o??t}function Gn(){let t=new Map,e=0;return {resolve(o,n){let i=go(o,n);for(let r of i.keys())t.has(r)||(t.set(r,e),e+=1);return new Map([...i.keys()].map(r=>[r,t.get(r)]).sort((r,a)=>r[1]-a[1]))}}}function F(t,e,o){if(t===void 0||t.length===0)return null;let n=t[t.length-1],i=t.some(s=>s.kind==="delete"||s.kind==="moveFrom"),r=n.kind,a=r==="delete"||r==="moveFrom"?"line-through":r==="insert"||r==="moveTo"?"underline":null;return {attribution:n,line:i&&a==="underline"?"line-through":a,decorationStyle:r==="moveFrom"||r==="moveTo"?"double":"solid",color:i?"var(--doc-revision-deletion)":"var(--doc-revision-insertion)",authorColor:o?.get(n.author)?.color??J(e?.get(n.author)??0),deleted:i}}function de(t,e=false){let o=t.spans.find(i=>i.style.shaping)?.style.shaping?.baseLevel,n=o===void 0?e:o===1;return t.spans.length?{x:n?t.spans.reduce((i,r)=>Math.min(i,r.box.x),1/0):t.spans.reduce((i,r)=>Math.max(i,r.box.x+r.box.width),-1/0),rtl:n}:{x:t.contentX,rtl:n}}function ce(t,e,o,n){t.style.left=`${(e.x-o)*n}px`,t.style.marginLeft=`${(e.rtl?-2:2)*n}px`,e.rtl&&(t.style.transform="translateX(-100%)");}function tt(t,e,o,n,i=false){let r=t.createElement("span"),a=e.spans[e.spans.length-1];r.className="docx-line-break-mark",r.dataset.docxMarker="",r.setAttribute("aria-hidden","true"),r.contentEditable="false",r.textContent="\u21B5",r.style.position="absolute",r.style.pointerEvents="none",r.style.userSelect="none",ce(r,de(e,i),e.contentX,o),r.style.top=`${e.leading*o}px`,r.style.fontSize=`${(a?.style.fontSizePt??e.box.height)*o}px`,r.style.lineHeight=`${Math.max(0,e.box.height-e.leading-(e.trailingSpacing??0))*o}px`,r.style.color="var(--doc-revision-format)";let s=F(a?.revisions,n?.authorSlots,n?.styles);if(s){let{attribution:l}=s,d=n?.styles.get(l.author),c=n&&(d?.color!==void 0||n.others==="author");if(r.style.color=c?s.authorColor:s.color,r.dataset.revisionKind=l.kind,r.dataset.revisionId=l.id,r.dataset.reviewAuthor=l.author,n){r.dataset.reviewAuthorSlot=String((n.authorSlots.get(l.author)??0)%$);for(let u of n.classTokens.get(l.author)??[])r.classList.add(u);}s.line&&(r.style.textDecorationLine=s.line,r.style.textDecorationStyle=s.decorationStyle,r.style.textDecorationColor=r.style.color);}return r}function ot(t,e,o,n){let i=Ya(e);if(!i){let d=t.createElement("span");return d.className="docx-paragraph-mark",d.setAttribute("aria-hidden","true"),d.contentEditable="false",d.textContent="\xB6",d.style.position="absolute",d.style.pointerEvents="none",d.style.marginLeft=`${2*o}px`,d.style.color="var(--doc-revision-format)",d}let r=t.createElement("span");r.className=`docx-paragraph-mark docx-revision-pmark docx-revision-pmark-${i.kind}`,r.setAttribute("aria-hidden","true"),r.contentEditable="false",r.dataset.revisionKind=i.kind,r.dataset.revisionId=i.id,i.author!==""&&(r.dataset.reviewAuthor=i.author),r.dataset.revisionIds=e.map(d=>d.id).join(" "),r.dataset.revisionKinds=e.map(d=>d.kind).join(" "),r.textContent="\xB6",r.style.position="absolute",r.style.pointerEvents="none",r.style.marginLeft=`${2*o}px`;let a=Za(i),s=n?.styles.get(i.author),l=n?(n.authorSlots.get(i.author)??0)%$:0;if(n){r.dataset.reviewAuthorSlot=String(l);let d=n.classTokens.get(i.author);if(d)for(let c=0;c<d.length;c+=1)r.classList.add(d[c]);}return r.style.color=s?.color??(n?.others==="author"?J(l):a?"var(--doc-revision-deletion)":"var(--doc-revision-insertion)"),a&&(r.style.textDecorationLine="line-through"),r}function ue(t,e,o=false){let n=o?null:$a(e.props.filter(r=>r.localName==="pPrChange")),i=n??e.markFormatRevision;i&&(mo(t,i,n?"pPrChange":"rPrChange"),t.dataset.paragraphId=e.paragraphId,t.dataset.reviewStart=String(e.range.start),t.dataset.reviewEnd=String(e.range.end));}function mo(t,e,o){t.dataset.revisionKind="format",t.dataset.revisionId=e.id,t.dataset.formattingKind=o,e.author&&(t.dataset.reviewAuthor=e.author),e.date!==void 0&&(t.dataset.revisionDate=e.date);}function nt(t,e,o,n,i,r){for(let a of [o.footnotes,o.endnotes])a&&e.append(xo(t,o,a,n,i,r));}function xo(t,e,o,n,i,r){let a=t.createElement("div");a.className="docx-notes",a.dataset.docxNotes=o.kind,a.dataset.docxNotesPlacement=o.placement,a.style.position="absolute",a.style.left=`${(o.box.x-e.box.x)*n.scale}px`,a.style.top=`${(o.box.y-e.box.y)*n.scale}px`,a.style.width=`${o.box.width*n.scale}px`,a.style.height=`${o.box.height*n.scale}px`;for(let s of [o.separator,o.continuationNotice]){if(!s)continue;let l=t.createElement("div");l.className="docx-note-separator",l.dataset.docxNoteSeparator=s.kind,l.setAttribute("contenteditable","false"),l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.left=`${(s.box.x-o.box.x)*n.scale}px`,l.style.top=`${(s.box.y-o.box.y)*n.scale}px`,l.style.width=`${s.box.width*n.scale}px`,l.style.height=`${s.box.height*n.scale}px`;let d=s.ruleStyle;if(d||s.synthetic)bo(l,t,d??"single",n.scale,s.box.height,s.ruleColor);else {let c={...n,tabLeaderOriginXPt:s.box.x-e.box.x};for(let u of s.fragments)l.append(u.kind==="table"?r(t,u,c):i(t,u,c));}a.append(l);}for(let s of o.notes){let l={...n,tabLeaderOriginXPt:s.box.x-e.box.x},d=t.createElement("div");d.className="docx-note",d.dataset.docxNote=s.noteKind,d.dataset.docxNoteId=String(s.noteId),d.dataset.docxNoteScope=s.scopeId,s.mark!==null&&(d.dataset.docxNoteMark=s.mark),s.continuation&&(d.dataset.docxNoteContinuation=""),d.setAttribute("role","doc-footnote"),d.style.position="absolute",d.style.left=`${(s.box.x-o.box.x)*n.scale}px`,d.style.top=`${(s.box.y-o.box.y)*n.scale}px`,d.style.width=`${s.box.width*n.scale}px`,d.style.height=`${s.box.height*n.scale}px`;for(let c of s.fragments)d.append(c.kind==="table"?r(t,c,l):i(t,c,l));a.append(d);}return a}function bo(t,e,o,n,i,r){t.dataset.docxNoteRule=o;let a=r&&/^[a-f\d]{6}$/i.test(r)?`#${r}`:"#000000";t.style.color=a;let s=Math.max(1,n*.75);if(o==="single"){t.style.backgroundColor=a,t.style.height=`${i*n}px`;return}t.style.opacity="0.85";let l=Math.max(1,n*1.25);for(let d of [0,s+l]){let c=e.createElement("div");c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.left="0",c.style.right="0",c.style.top=`${d}px`,c.style.height="0",c.style.borderTop=`${s}px solid currentColor`,t.append(c);}}var vo=new Set(["dropdown","comboBox","date","checkbox","picture","buildingBlockGallery"]);function rt(t,e,o,n){let i=n.contentControlChrome,r=i?.suppressedIds,a=(o.contentControls??[]).filter(h=>r?.has(h.id)!==true),s=[...a,...(i?.additionalBoundaries??[]).filter(h=>r?.has(h.id)!==true&&!a.some(p=>p.id===h.id))];if(s.length===0)return;let l=i?.showAll===true,d=i?.activeIds,c=i?.hoverIds,u=i?.tocControlIds;for(let h of s){let p=u?.has(h.id)===true,y=!p&&d?.has(h.id)===true,x=c?.has(h.id)===true;e.append(Ro(t,o,h,n.scale,y,x,l||y||p&&x,i?.checkedIds?.has(h.id),p,i?.readOnly===true));}}function So(t,e,o,n){let i=t.contentBox.x-t.box.x,r=t.contentBox.y-t.box.y;if(o==="checkbox"){let h=Math.max(1,Math.min(e.height,16))*n,p=e.width>0?(i+e.x+e.width/2)*n-h/2:(i+e.x)*n,y=(r+e.y)*n+Math.max(0,(e.height*n-h)/2);return {left:p,top:y,size:h}}let a=16*n,s=(i+e.x+e.width)*n,l=t.box.width*n,d=s+2*n,c=d+a<=l?d:Math.max(0,s-a),u=(r+e.y)*n+Math.max(0,(e.height*n-a)/2);return {left:c,top:u,size:a}}function Ro(t,e,o,n,i,r,a,s,l,d){let c=t.createElement("div");c.className="docx-content-control-chrome",c.dataset.docxContentControl=o.id,c.dataset.docxMarker="",c.dataset.controlType=o.controlType,c.dataset.lock=o.effectiveLock,o.bound&&(c.dataset.bound=""),o.placeholder&&(c.dataset.placeholder=""),l&&(c.dataset.docxToc=""),d&&(c.dataset.readOnly=""),i&&(c.dataset.active=""),r&&(c.dataset.hover=""),a&&(c.dataset.boundaryVisible=""),c.setAttribute("contenteditable","false"),c.setAttribute("role","group"),o.alias&&(c.dataset.alias=o.alias),o.tag&&(c.dataset.tag=o.tag),o.alias&&c.setAttribute("aria-label",o.alias),c.style.position="absolute",c.style.inset="0",c.style.pointerEvents="none",c.style.zIndex="2";let u=e.contentBox.x-e.box.x,h=e.contentBox.y-e.box.y;for(let y of o.fragments){if(y.pageIndex!==e.index)continue;let x=t.createElement("div");x.className="docx-content-control-boundary",x.dataset.docxMarker="",x.setAttribute("contenteditable","false"),x.setAttribute("aria-hidden","true"),x.style.position="absolute",x.style.left=`${(u+y.box.x)*n}px`,x.style.top=`${(h+y.box.y)*n}px`,x.style.width=`${Math.max(y.box.width,1)*n}px`,x.style.height=`${Math.max(y.box.height,1)*n}px`,x.style.pointerEvents="none",c.append(x);}let p=o.fragments.find(y=>y.pageIndex===e.index);if(p&&o.alias){let y=t.createElement("div");y.className="docx-content-control-label",y.dataset.docxMarker="",y.setAttribute("contenteditable","false"),y.setAttribute("aria-hidden","true"),y.textContent=o.alias,y.style.position="absolute",y.style.left=`${(u+p.box.x)*n}px`,y.style.top=`${Math.max(0,(h+p.box.y)*n-16)}px`,y.style.pointerEvents="none",c.append(y);}if(p&&vo.has(o.controlType)){let y=t.createElement("button");y.type="button",y.className="docx-content-control-widget",y.dataset.docxMarker="",y.dataset.docxCcWidget=o.controlType,y.dataset.docxCcId=o.id,y.setAttribute("contenteditable","false"),y.setAttribute("tabindex","-1"),o.controlType==="checkbox"?y.setAttribute("role","checkbox"):o.controlType==="dropdown"||o.controlType==="comboBox"||o.controlType==="buildingBlockGallery"?y.setAttribute("role","listbox"):(o.controlType==="date"||o.controlType==="picture")&&y.setAttribute("role","button"),o.alias&&(y.dataset.name=o.alias),o.alias&&y.setAttribute("aria-label",o.alias),o.controlType==="checkbox"&&(y.setAttribute("data-checked",s?"true":"false"),y.setAttribute("aria-checked",s?"true":"false"));let x=o.effectiveLock==="contentLocked"||o.effectiveLock==="sdtContentLocked";(d||x||o.bound)&&(y.disabled=true,y.dataset.disabledReason=d?"readOnly":o.bound?"bound":"locked",y.setAttribute("aria-disabled","true"));let m=So(e,p.box,o.controlType,n);y.style.position="absolute",y.style.left=`${m.left}px`,y.style.top=`${m.top}px`,y.style.width=`${m.size}px`,y.style.height=`${m.size}px`,y.style.fontSize=`${m.size}px`,y.style.pointerEvents="auto",y.style.padding="0",y.style.margin="0",y.style.cursor=y.disabled?"not-allowed":"pointer",c.append(y);}return c}var at="docx-change-bars",Q="docx-change-bar",wo=.5;function st(t,e){for(let o of e)switch(o.kind){case "insert":case "moveTo":t.insertion=true;break;case "delete":case "moveFrom":t.deletion=true;break;case "format":t.format=true;break}}function lt(t,e,o){let n=t.lines,i=n.length-1,r=[];for(let a=0;a<=i;a+=1){let s=n[a];if(r.length=0,e.mode==="simple-markup"){s.changeSites&&r.push(...s.changeSites),a===i&&t.markChangeSites&&r.push(...t.markChangeSites),r.length>0&&it(t,n,a,e,r,o);continue}for(let l of s.spans){l.revisions&&r.push(...l.revisions);let d=$a(l.props);d&&r.push(d);}for(let l of s.drawings??[])l.revisions&&r.push(...l.revisions);if(s.anchorRevisions&&r.push(...s.anchorRevisions),a===i){t.markRevisions&&r.push(...t.markRevisions),t.markFormatRevision&&r.push(t.markFormatRevision);let l=$a(t.props);l&&r.push(l);}r.length!==0&&it(t,n,a,e,r,o);}}function it(t,e,o,n,i,r){let a=e[o],s=e.length-1,l=(o===0?t.box.y:a.box.y)+n.dy,d=Math.min((o===s?t.box.y+t.box.height:e[o+1].box.y)+n.dy,n.limit);if(d<=l)return;let c={top:l,bottom:d,story:n.story,insertion:false,deletion:false,format:false};st(c,i),r.push(c);}function ko(t,e,o){for(let n of t.rows){let i=e.mode==="simple-markup"?n.changeSites:void 0;if(e.mode==="all-markup"&&n.revisionKind||i&&i.length>0){let r=Sd(n)?Math.max(n.box.y,...n.cells.map(s=>s.box.y+s.box.height)):n.box.y+n.box.height,a={top:n.box.y+e.dy,bottom:Math.min(r+e.dy,e.limit),story:e.story,insertion:n.revisionKind==="insert",deletion:n.revisionKind==="delete",format:false};i&&st(a,i),o.push(a);}for(let r of n.cells){if(r.textDirection==="btLr"){let a=[];if(ye(r.blocks,e,a),a.length===0)continue;let s={top:r.box.y+e.dy,bottom:Math.min(r.box.y+r.box.height+e.dy,e.limit),story:e.story,insertion:false,deletion:false,format:false};for(let l of a)s.insertion||=l.insertion,s.deletion||=l.deletion,s.format||=l.format;s.bottom>s.top&&o.push(s);continue}ye(r.blocks,e,o);}}}function ye(t,e,o){for(let n of t)n.kind==="table"?ko(n,e,o):lt(n,e,o);}function Po(t){t.sort((o,n)=>o.top-n.top||o.bottom-n.bottom);let e=[];for(let o of t){let n=e[e.length-1];if(n&&n.story===o.story&&o.top<=n.bottom+wo){n.bottom=Math.max(n.bottom,o.bottom),n.insertion||=o.insertion,n.deletion||=o.deletion,n.format||=o.format;continue}e.push({...o});}return e}function dt(t,e,o,n=false){let i=[];if(o==="none")return {mode:o,toggle:n,left:0,runs:i,signature:"none"};let r=t.box.height,a=t.contentBox.y-t.box.y+t.contentBox.height,s={x:t.box.x,y:t.box.y};ya(t,u=>{if(u.story==="note-separator")return;let h={mode:o,story:u.story,dy:u.origin.y-t.box.y,limit:u.story==="body"?a:r};ye(u.host.fragments,h,i);let p=u.story==="header"||u.story==="footer"?y=>ta(y,u.origin,s):void 0;Ca(u.host,(y,x)=>{x.textboxDepth!==0&<(y,{mode:o,story:u.story,dy:x.storyOrigin.y-t.box.y,limit:r},i);},u.origin,p);});let l=Math.round(Math.max(0,(t.contentBox.x-t.box.x)/2)*e),d=Po(i),c=`${o}|${n?"t":""}|${l}`;for(let u of d)c+=`|${u.story}:${u.top.toFixed(3)}-${u.bottom.toFixed(3)}${u.insertion?"i":""}${u.deletion?"d":""}${u.format?"f":""}`;return {mode:o,toggle:n,left:l,runs:d,signature:c}}function ct(t,e,o){if(e.runs.length===0)return null;let n=e.mode==="simple-markup",i=t.createElement("div");i.className=at,i.dataset.docxChangeBars=e.signature,i.dataset.docxChangeBarsMode=e.mode,i.setAttribute("aria-hidden","true"),i.setAttribute("contenteditable","false"),i.style.position="absolute",i.style.inset="0",i.style.pointerEvents="none";for(let r of e.runs){let a=t.createElement("div");a.className=Q,r.insertion&&a.classList.add(`${Q}-insertion`),r.deletion&&a.classList.add(`${Q}-deletion`),r.format&&a.classList.add(`${Q}-format`),a.dataset.docxStory=r.story,a.style.position="absolute",a.style.left=`${e.left}px`,a.style.top=`${r.top*o}px`,a.style.height=`${(r.bottom-r.top)*o}px`,a.style.width=n?"var(--doc-review-change-bar-simple-width)":"var(--doc-review-change-bar-width)",a.style.backgroundColor=n?"var(--doc-review-change-bar-simple)":"var(--doc-review-change-bar)",e.toggle?(a.dataset.docxChangeBarToggle="",a.style.pointerEvents="auto",a.style.cursor="pointer"):a.style.pointerEvents="none",i.append(a);}return i}function ut(t,e,o,n,i=false){return ct(t,dt(e,o,n,i),o)}function yt(t,e,o,n,i,r=false){let a=e.querySelector(`:scope > .${at}`),s=dt(o,n,i,r);if(a&&a.dataset.docxChangeBars===s.signature)return;a?.remove();let l=ct(t,s,n);l&&e.append(l);}function ee(t,e,o){return !!o.activeHeaderFooterRId&&!!t.rId&&o.activeHeaderFooterRId===t.rId&&(o.activeHeaderFooterPageIndex===void 0||o.activeHeaderFooterPageIndex===e)}function pe(t,e,o){return o?t.kind==="footer"?Math.max(t.box.height,e.box.y+e.box.height-t.box.y):Math.max(t.box.height,e.contentBox.y-t.box.y):t.box.height}function Ao(t,e){let{box:o}=e,n=t.contentBox,i=e.kind==="header"?o.y:Math.max(o.y,n.y+n.height),r=e.kind==="header"?Math.min(o.y+o.height,n.y):o.y+o.height;return r>i?{x:o.x,y:i,width:o.width,height:r-i}:null}function Eo(t,e){let o=e.box,n=t.contentBox;return o.x<n.x+n.width&&n.x<o.x+o.width&&o.y<n.y+n.height&&n.y<o.y+o.height}function pt(t,e,o,n,i,r){let a=i.box;if(Eo(n,i)){o.dataset.docxHfOverBody="";let l=Ao(n,i);if(!l)return;let d=t.createElement("div");d.className="docx-hf-hover",d.dataset.docxHfHover=i.kind,d.setAttribute("contenteditable","false"),d.style.position="absolute",d.style.left=`${(l.x-n.box.x)*r}px`,d.style.top=`${(l.y-n.box.y)*r}px`,d.style.width=`${l.width*r}px`,d.style.height=`${l.height*r}px`,o.before(d),a=l;}let s=t.createElement("div");s.className="docx-hf-edit-hint",s.dataset.docxHfHint=i.kind,s.setAttribute("contenteditable","false"),s.style.position="absolute",s.style.left=`${(a.x-n.box.x)*r}px`,s.style.width=`${a.width*r}px`,s.style.top=i.kind==="header"?`${(a.y+a.height-n.box.y)*r}px`:`${(a.y-n.box.y)*r}px`,i.kind==="footer"&&(s.style.transform="translateY(-100%)"),e.append(s);}function ht(t,e){for(let{record:o,element:n,materialized:i}of t){if(!i)continue;let r=n.querySelector(":scope > .docx-page-content");r&&(e.activeHeaderFooterRId?r.setAttribute("contenteditable","false"):r.removeAttribute("contenteditable")),delete n.dataset.docxHfActiveKind;for(let a of n.querySelectorAll(":scope > .docx-hf:not(.docx-hf--placeholder)")){let s=Lo(o,a);if(!s)continue;let l=ee(s,o.index,e);l&&(n.dataset.docxHfActiveKind=s.kind),$o(a,o,s,l,e.scale);}for(let a of n.querySelectorAll(":scope > [data-docx-hf-front]")){let s=ft(o,a.dataset.docxHfFront);gt(a,!!s&&ee(s,o.index,e));}}}function Lo(t,e){return ft(t,e.dataset.docxHf)}function ft(t,e){if(e==="header")return t.header;if(e==="footer")return t.footer}function $o(t,e,o,n,i){n?(t.dataset.docxHfActive="",t.setAttribute("contenteditable","true")):(delete t.dataset.docxHfActive,t.setAttribute("contenteditable","false")),t.style.height=`${pe(o,e,n)*i}px`,gt(t,n);}function gt(t,e){let o=t.querySelectorAll(t instanceof Element&&t.classList.contains("docx-drawing-layer")?":scope > *":":scope > .docx-drawing-layer > *");for(let n of o){n.style.pointerEvents=e?"auto":"none";for(let i of n.querySelectorAll(".docx-drawing"))i.style.pointerEvents=e?"auto":"none";}}var Mo=0;function mt(t,e,o,n){if(n===void 0||!Number.isFinite(n)||n<0||n>1)return;let i="http://www.w3.org/2000/svg",r=(u,h)=>{let p=t.createElementNS(i,u);for(let[y,x]of Object.entries(h))p.setAttribute(y,x);return p},a=`docx-bilevel-${++Mo}`,s=r("svg",{width:"0",height:"0","aria-hidden":"true"});s.style.position="absolute",s.style.pointerEvents="none";let l=r("filter",{id:a,"color-interpolation-filters":"sRGB"});l.append(r("feColorMatrix",{type:"saturate",values:"0"}));let d=r("feComponentTransfer",{}),c=Array.from({length:256},(u,h)=>h/255>=n?1:0).join(" ");for(let u of ["R","G","B"])d.append(r(`feFunc${u}`,{type:"discrete",tableValues:c}));l.append(d),s.append(l),e.append(s),o.style.filter=`${o.style.filter} url(#${a})`.trim();}function xt(t){return Math.max(-1,Math.min(1,t))}function To(t,e){if(!Number.isFinite(t)||!Number.isFinite(e))return null;let o=xt(t/100),n=xt(e/100);if(o===0&&n===0)return null;let i=n>=0?Math.min(1e3,1/(1-n)):Math.max(0,1+n),r=.5-o/2,a=r+o-i*r;return Object.freeze({slope:i,intercept:a})}function te(t){if(!Number.isFinite(t))return "0";let e=Math.round(t*1e6)/1e6;return String(Object.is(e,-0)?0:e)}function Co(t){let{slope:e,intercept:o}=t;if(o>=0){let i=e+2*o;return i<=0?"brightness(0)":`contrast(${te(e/i)}) brightness(${te(i)})`}let n=1-2*o;return `brightness(${te(e/n)}) contrast(${te(n)})`}function he(t){let e=[];t.grayscale&&e.push("grayscale(1)");let o=To(t.brightness,t.contrast);o&&e.push(Co(o));let{opacity:n}=t;return n!==void 0&&Number.isFinite(n)&&n>=0&&n<1&&e.push(`opacity(${Math.round(n*1e3)/1e3})`),e.length>0?e.join(" "):void 0}var bt="http://www.w3.org/2000/svg",Do=0;function vt(t,e){let{cx:o,cy:n}=t.extentEmu;if(o>0&&n>0)return {viewBox:[0,0,o,n],frame:e};let i=1;for(let a of t.components)i=Math.max(i,a.strokeWidthEmu);if(o<=0){let a=n>0?e.height/n:0;return {viewBox:[-i,0,2*i,Math.max(1,n)],frame:{...e,x:e.x-i*a,width:2*i*a}}}let r=e.width/o;return {viewBox:[0,-i,o,2*i],frame:{...e,y:e.y-i*r,height:2*i*r}}}function St(t,e,o,n,i){let r=`docx-inset-${++Do}`,a=t.createElementNS(bt,"clipPath");a.setAttribute("id",r);let s=t.createElementNS(bt,"path");s.setAttribute("d",n),s.setAttribute("clip-rule","evenodd"),a.append(s),e.append(a),o.setAttribute("stroke-width",String(2*Math.max(1,i))),o.setAttribute("clip-path",`url(#${r})`);}var fe="http://www.w3.org/2000/svg";function T(t){return Number.isFinite(t)?String(t):"0"}function ge(t,e,o,n,i){if(n===o)return;let r=a=>`${T(-a*i)}px`;t.style.overflow="visible",t.style.clipPath=`inset(${r(o.y-n.y)} ${r(n.x+n.width-(o.x+o.width))} ${r(n.y+n.height-(o.y+o.height))} ${r(o.x-n.x)})`,e.style.pointerEvents="none";}function me(t,e,o){let n=e.vectorShape,i=e.geometry.contentBounds,r=e.paintBounds,a=t.createElement("div");a.className="docx-drawing-image-frame",a.style.position="absolute";let s=vt(n,i);a.style.left=`${(s.frame.x-r.x)*o}px`,a.style.top=`${(s.frame.y-r.y)*o}px`,a.style.width=`${s.frame.width*o}px`,a.style.height=`${s.frame.height*o}px`;let l=t.createElementNS(fe,"svg");l.setAttribute("viewBox",s.viewBox.map(T).join(" ")),l.setAttribute("preserveAspectRatio","none"),l.setAttribute("width","100%"),l.setAttribute("height","100%"),l.style.display="block",l.style.overflow="visible";for(let d of n.components){let c=t.createElementNS(fe,"path"),u=d.subpathsEmu.map((h,p)=>`M${h.map(y=>`${T(y.x)} ${T(y.y)}`).join("L")}${d.subpathsClosed?.[p]===false?"":"Z"}`).join("");if(c.setAttribute("d",u),c.setAttribute("fill",d.fillHex!==null?`#${d.fillHex}`:"none"),c.setAttribute("fill-rule","evenodd"),d.fillAlpha<1&&c.setAttribute("fill-opacity",T(Math.max(0,d.fillAlpha))),d.strokeHex!==null&&(c.setAttribute("stroke",`#${d.strokeHex}`),c.setAttribute("stroke-width",T(Math.max(1,d.strokeWidthEmu))),d.strokeInset&&St(t,l,c,u,bb(d.strokeWidthEmu)),d.strokeAlpha<1&&c.setAttribute("stroke-opacity",T(Math.max(0,d.strokeAlpha)))),l.append(c),d.strokeHex!==null)for(let h of d.arrowheadsEmu??[]){let p=t.createElementNS(fe,"path");p.setAttribute("d",`M${h.map(y=>`${T(y.x)} ${T(y.y)}`).join("L")}Z`),p.setAttribute("fill",`#${d.strokeHex}`),p.setAttribute("fill-opacity",T(Math.max(0,Math.min(1,d.strokeAlpha)))),p.setAttribute("data-docx-line-end","triangle"),l.append(p);}}return a.append(l),a}var Ho=new Map([["image/svg+xml","SVG"],["image/tiff","TIFF"],["image/x-emf","EMF"],["image/x-wmf","WMF"]]),Bo="Unknown",ne=new WeakMap,oe=new WeakMap,Io=256;function kt(t,e){let o=ne.get(t);if(o)return o;let n=new Map,i=new Map;return o=Object.freeze({urlForReady(r,a){let s=n.get(r.resourceKey);if(s)return s;let l;try{l=e.create(r,a);}catch(d){if(d instanceof Error&&d.message.startsWith("PaintImageUrlSource:"))return null;throw d}return n.set(r.resourceKey,l),l},imageFor(r,a,s){let l=i.get(r);if(l&&l.resourceKey===a)return l.element;let d=s.createElement("img");return i.size<Io&&i.set(r,{element:d,resourceKey:a,...l?.readyElement?{readyElement:l.readyElement}:{}}),d},imageForPending(r){return i.get(r)?.element??null},readyElementFor(r){return i.get(r)?.readyElement??null},rememberReadyElement(r,a){let s=i.get(r);s&&i.set(r,{...s,readyElement:a});},reconcile(r,a){for(let[s,l]of n)r.has(s)||(e.revoke(l),n.delete(s));for(let[s,l]of i)a.has(s)||(l.element.removeAttribute("src"),i.delete(s));},revokeAll(){for(let r of n.values())e.revoke(r);n.clear();for(let r of i.values())r.element.removeAttribute("src");i.clear();}}),ne.set(t,o),o}function xe(t,e){return `${e.paintInstance??""}|${t.drawingNodeId}`}function vr(t){ne.get(t)?.revokeAll(),ne.delete(t);}function N(t){return Number.isFinite(t)?String(t):"0"}function Pt(t,e){if(t.length<3||e.width<=0||e.height<=0)return null;let o=[];for(let n of t){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))return null;let i=(n.x-e.x)/e.width*100,r=(n.y-e.y)/e.height*100;o.push(`${N(i)}% ${N(r)}%`);}return `polygon(${o.join(", ")})`}function At(t){let e=t.geometry.contentBounds;return db({transform:t.transform,contentWidth:e.width,contentHeight:e.height})}function Et(t,e){let{crop:o}=t,n=Math.max(0,Math.min(1,o.left)),i=Math.max(0,Math.min(1,o.top)),r=Math.max(0,Math.min(1,o.right)),a=Math.max(0,Math.min(1,o.bottom)),s=Math.max(1e-4,1-n-r),l=Math.max(1e-4,1-i-a);return Object.freeze({width:`${N(1/s*100)}%`,height:`${N(1/l*100)}%`,left:`${N(-n/s*100)}%`,top:`${N(-i/l*100)}%`})}function Fo(t,e){let{resource:o}=t;switch(o.kind){case "external":return e.externalResource;case "missing":return e.missingResource;case "pending":return e.pendingResource;case "unrenderable":switch(o.reason){case "unsupported-format":return e.unsupportedFormat(Ho.get(o.mime)??Bo);case "non-picture-graphic":return e.nonPictureGraphic(t.placeholderGraphicKind??"graphic");case "signature-mismatch":return e.contentMismatch;case "decode-failed":return e.decodeFailed;case "resource-limit":return e.resourceLimit;default:return e.invalidResource}default:return e.invalidResource}}function B(t,e,o){let{accessibility:n}=e;n.hidden||(t.setAttribute("role",o?"link":"img"),n.label?t.setAttribute("aria-label",n.label):o||t.setAttribute("aria-hidden","true"));}function G(t,e,o,n){let i=n?.x??0,r=n?.y??0;t.style.position="absolute",t.style.left=`${(e.x-i)*o}px`,t.style.top=`${(e.y-r)*o}px`,t.style.width=`${e.width*o}px`,t.style.height=`${e.height*o}px`,t.style.boxSizing="border-box",t.style.overflow="hidden",t.style.pointerEvents="auto";}function Lt(t){let e=t.groupPicture?t.geometry.imageTransformCorners:void 0;if(!e||e.length===0)return t.geometry.contentBounds;let o=1/0,n=1/0,i=-1/0,r=-1/0;for(let a of e)o=Math.min(o,a.x),n=Math.min(n,a.y),i=Math.max(i,a.x),r=Math.max(r,a.y);return {x:o,y:n,width:i-o,height:r-n}}function No(t,e,o,n,i){let r=t.paintBounds,a=Lt(t),s=Et(t);return [n,o.scale,i?.x??0,i?.y??0,r.x,r.y,r.width,r.height,a.x,a.y,a.width,a.height,Pt(t.geometry.clipPolygon??[],r)??"",he(t.effects)??"",t.effects.bilevel??"",At(t)??"",s.width,s.height,s.left,s.top,o.inertLinks?"":t.hyperlinkHref??"",t.accessibility.label??""].join("|")}function j(t,e,o,n){let i=t.createElement("div");i.className="docx-drawing docx-drawing-placeholder",i.dataset.drawingNodeId=e.drawingNodeId,G(i,e.paintBounds,o.scale,n);let r=t.createElement("div");r.className="docx-drawing-placeholder-card";let a=t.createElement("span");return a.className="docx-drawing-placeholder-label",a.textContent=Fo(e,o.strings),r.append(a),i.append(r),e.hyperlinkHref&&!o.inertLinks?(i.dataset.docxDrawingLink=e.drawingNodeId,i.dataset.docxDrawingLinkKind="external",i.dataset.docxDrawingLinkHref=e.hyperlinkHref,i.setAttribute("tabindex","-1"),B(i,e,true)):B(i,e,false),i}function Oo(t,e,o,n,i,r){let a=e.resource;if(a.kind!=="ready")return j(t,e,o,r);let s=xe(e,o),l=i?.readyElementFor?.(s)??t.createElement("div"),d=No(e,a,o,n,r),c=!e.vectorShape;if(c&&oe.get(l)===d)return l;l.className="docx-drawing docx-drawing-ready",l.style.cssText="",l.dataset.drawingNodeId=e.drawingNodeId,delete l.dataset.docxDrawingLink,delete l.dataset.docxDrawingLinkKind,delete l.dataset.docxDrawingLinkHref,l.removeAttribute("aria-hidden"),l.removeAttribute("aria-label"),l.removeAttribute("role"),l.removeAttribute("tabindex"),G(l,e.paintBounds,o.scale,r);let u=t.createElement("div");u.className="docx-drawing-image-frame",u.style.position="absolute";let h=Lt(e),p=e.paintBounds,y=Pt(e.geometry.clipPolygon??[],e.groupPicture?h:p);y&&((e.groupPicture?u:l).style.clipPath=y),u.style.left=`${(h.x-p.x)*o.scale}px`,u.style.top=`${(h.y-p.y)*o.scale}px`,u.style.width=`${h.width*o.scale}px`,u.style.height=`${h.height*o.scale}px`;let x=he(e.effects);x&&(u.style.filter=x);let m=t.createElement("div");m.className="docx-drawing-transform-stage",m.style.position="relative",m.style.width="100%",m.style.height="100%";let A=At(e);A&&(m.style.transform=A,m.style.transformOrigin="0 0");let w=t.createElement("div");w.className="docx-drawing-crop-viewport",w.style.position="relative",w.style.width="100%",w.style.height="100%",w.style.overflow="hidden";let b=i?.imageFor?.(s,a.resourceKey,t)??t.createElement("img");b.className="docx-drawing-image",b.setAttribute("draggable","false"),b.getAttribute("src")!==n&&b.setAttribute("src",n),b.setAttribute("alt","");let k=Et(e);if(b.style.position="absolute",b.style.width=k.width,b.style.height=k.height,b.style.left=k.left,b.style.top=k.top,b.style.maxWidth="none",b.style.maxHeight="none",w.append(b),m.append(w),u.append(m),l.replaceChildren(u),e.vectorShape){let L$1=me(t,e,o.scale),E=e.paintBounds;ge(l,L$1,E,L(e,E),o.scale),l.append(L$1);}return mt(t,l,u,e.effects.bilevel),e.hyperlinkHref&&!o.inertLinks?(l.dataset.docxDrawingLink=e.drawingNodeId,l.dataset.docxDrawingLinkKind="external",l.dataset.docxDrawingLinkHref=e.hyperlinkHref,l.setAttribute("tabindex","-1"),B(l,e,true)):B(l,e,false),i?.rememberReadyElement?.(s,l),c?oe.set(l,d):oe.delete(l),l}function Ko(t,e,o,n,i){let r=t.createElement("div");r.className="docx-drawing docx-drawing-shape",r.dataset.drawingNodeId=e.drawingNodeId;let a=e.paintBounds;G(r,a,o.scale,i);let s=me(t,e,o.scale);return ge(r,s,a,n,o.scale),r.append(s),e.hyperlinkHref&&!o.inertLinks?(r.dataset.docxDrawingLink=e.drawingNodeId,r.dataset.docxDrawingLinkKind="external",r.dataset.docxDrawingLinkHref=e.hyperlinkHref,r.setAttribute("tabindex","-1"),B(r,e,true)):B(r,e,false),r}function zo(t,e,o,n,i){let r=n.scale,a=t.createElement("div");a.className="docx-drawing docx-drawing-textbox",a.dataset.drawingNodeId=e.drawingNodeId,a.setAttribute("contenteditable","false"),G(a,e.paintBounds,n.scale,i),a.style.overflow="hidden";let s=(e.x-e.paintBounds.x)*r,l=(e.y-e.paintBounds.y)*r;if(o.fillHex!==null||o.strokeHex!==null){let c=t.createElement("div");c.className="docx-drawing-textbox-box",c.style.position="absolute",c.style.left=`${s}px`,c.style.top=`${l}px`,c.style.width=`${e.width*r}px`,c.style.height=`${e.height*r}px`,c.style.boxSizing="border-box",o.fillHex!==null&&(c.style.backgroundColor=`#${o.fillHex}`),o.strokeHex!==null&&(c.style.border=`${Math.max(o.strokeWidthPt*r,.5)}px solid #${o.strokeHex}`),a.append(c);}let d=t.createElement("div");d.className="docx-drawing-textbox-content",d.style.position="absolute",d.style.left=`${s+o.contentOffset.x*r}px`,d.style.top=`${l+o.contentOffset.y*r}px`,d.style.width=`${o.contentWidth*r}px`,d.style.height=`${Math.max(0,o.contentHeight)*r}px`,d.style.overflow="hidden";for(let c of o.fragments)d.append(n.paintStoryFragment(t,c));for(let c of d.querySelectorAll("[data-paragraph-id]"))delete c.dataset.paragraphId;return a.append(d),B(a,e,false),a}function _o(t,e,o){let n=o.revisionStyles,i=F(e.revisions,n?.authorSlots,n?.styles);if(!i){if(t.dataset.revisionKind===void 0)return;t.classList.remove("docx-drawing--revision","docx-drawing--revision-insertion","docx-drawing--revision-deletion"),delete t.dataset.revisionKind,delete t.dataset.revisionId,delete t.dataset.reviewAuthor,delete t.dataset.revisionDate,delete t.dataset.reviewAuthorSlot;return}let{attribution:r}=i;t.classList.add("docx-drawing--revision",i.deleted?"docx-drawing--revision-deletion":"docx-drawing--revision-insertion"),t.classList.remove(i.deleted?"docx-drawing--revision-insertion":"docx-drawing--revision-deletion"),t.dataset.revisionKind=r.kind,t.dataset.revisionId=r.id,r.author!==""?t.dataset.reviewAuthor=r.author:delete t.dataset.reviewAuthor,r.date!==void 0?t.dataset.revisionDate=r.date:delete t.dataset.revisionDate,n?t.dataset.reviewAuthorSlot=String((n.authorSlots.get(r.author)??0)%$):delete t.dataset.reviewAuthorSlot;}function $t(t,e,o,n,i){let r=Uo(t,e,o,n,i);return r&&_o(r,e,o),r}function Uo(t,e,o,n,i){if(e.accessibility.hidden)return null;let r=e.vectorShape?L(e,e.paintBounds):e.paintBounds;if(r.width<=0||r.height<=0)return null;if(e.kind==="anchoredDrawing"&&e.textboxStory!==void 0&&o.paintStoryFragment!==void 0)return zo(t,e,e.textboxStory,o,i);let{resource:a}=e,s=a.kind==="ready"&&o.imageUrlPort&&n?n.urlForReady(a.validatedHandle,a.mime):null;if(e.groupPicture&&a.kind!=="pending"&&!s)return j(t,e,o,i);let l=e.groupPicture!==void 0&&s!==null;if(e.vectorShape&&e.vectorShape.subpathsEmu.length>0&&!l)return Ko(t,e,o,r,i);if(a.kind==="ready")return !s||!n?j(t,e,o,i):Oo(t,e,o,s,n,i);if(a.kind==="pending"){let d=n?.readyElementFor?.(xe(e,o))??n?.imageForPending?.(xe(e,o))?.closest(".docx-drawing-ready");return d?(oe.delete(d),d.dataset.drawingNodeId=e.drawingNodeId,G(d,e.paintBounds,o.scale,i),d):j(t,e,o,i)}return j(t,e,o,i)}function Mt(t,e,o,n,i){let r=[];for(let a of e.drawings??[]){let s=$t(t,a,o,n,i);s&&r.push(s);}return Object.freeze(r)}function Tt(t,e,o,n,i,r){let a=[];for(let s of e){if(Sb(s)!==o)continue;let l=$t(t,s,n,i,r);l&&(l.dataset.drawingLayer=o,a.push(l));}return Object.freeze(a)}function jo(t,e){ya(t,({host:o})=>Aa(o,e));}var Rt=new WeakMap;function Go(t){let e=Rt.get(t);if(e)return e;let o=[],n=[];jo(t,r=>{r.resource.kind==="ready"&&o.push(r.resource.resourceKey),n.push(`p${t.index}|${r.drawingNodeId}`);}),ya(t,({host:r})=>Ca(r,a=>{let s=a.marker?.picture;s?.resource.kind==="ready"&&o.push(s.resource.resourceKey);}));let i=Object.freeze({resourceKeys:Object.freeze(o),elementKeys:Object.freeze(n)});return Rt.set(t,i),i}var wt=new WeakMap;function Ct(t){let e=wt.get(t);if(e)return e;let o=new Set,n=new Set;for(let r of t.pages){let a=Go(r);for(let s of a.resourceKeys)o.add(s);for(let s of a.elementKeys)n.add(s);}let i=Object.freeze({resourceKeys:o,elementKeys:n});return wt.set(t,i),i}function Dt(t){return Ct(t).resourceKeys}function Ht(t){return Ct(t).elementKeys}function Bt(t){return [t.missingResource,t.externalResource,t.invalidResource,t.contentMismatch,t.decodeFailed,t.resourceLimit,t.pendingResource,t.unsupportedFormat("probe"),t.nonPictureGraphic("probe")].join("\0")}var be=Object.freeze({unsupportedFormat:t=>`Unsupported image format (${t})`,nonPictureGraphic:t=>`Unsupported graphic (${t})`,missingResource:"Image missing",externalResource:"External image not loaded",invalidResource:"Invalid image",contentMismatch:"Image content does not match its type",decodeFailed:"Image could not be decoded",resourceLimit:"Image exceeds size limits",pendingResource:"Loading image"});function Sr(t){return Object.freeze({unsupportedFormat:e=>t("image.unsupportedFormat",{format:e}),nonPictureGraphic:e=>t("image.nonPictureGraphic",{kind:e}),missingResource:t("image.missingResource"),externalResource:t("image.externalResource"),invalidResource:t("image.invalidResource"),contentMismatch:t("image.contentMismatch"),decodeFailed:t("image.decodeFailed"),resourceLimit:t("image.resourceLimit"),pendingResource:t("image.pendingResource")})}function Wo(t,e,o){t.style.position="absolute",t.style.left=`${e.x*o}px`,t.style.top=`${e.y*o}px`,t.style.width=`${e.width*o}px`,t.style.height=`${e.height*o}px`;}function It(t,e,o,n){let i=t.createElement("span");return i.className=e,i.setAttribute("aria-hidden","true"),i.style.position="absolute",i.style.display="block",i.style.left=`${o.x*n}px`,i.style.top=`${o.y*n}px`,i.style.width=`${o.width*n}px`,i.style.height=`${o.height*n}px`,i.style.backgroundColor="currentColor",i.style.pointerEvents="none",i}function P(t,e,o,n,i=0,r=0,a=[]){let s=i+o.box.x,l=r+o.box.y,d=[...a,o.kind];switch(o.kind){case "text":case "fallback":{let c=t.createElement("span");c.className=["docx-equation-node",...d.map(u=>`docx-equation-${u}`)].join(" "),Wo(c,{x:s,y:l,width:o.box.width,height:o.box.height},n),c.textContent=o.text,c.style.display="block",c.style.fontSize=`${o.fontSizePt*n}px`,c.style.lineHeight=`${o.box.height*n}px`,c.style.whiteSpace="pre",e.append(c);break}case "row":for(let c of o.items)P(t,e,c,n,s,l,d);break;case "fraction":P(t,e,o.numerator,n,s,l,d),e.append(It(t,"docx-equation-fraction-bar",{...o.bar,x:s+o.bar.x,y:l+o.bar.y},n)),P(t,e,o.denominator,n,s,l,d);break;case "radical":P(t,e,o.sign,n,s,l,d),o.degree&&P(t,e,o.degree,n,s,l,d),e.append(It(t,"docx-equation-radical-bar",{...o.bar,x:s+o.bar.x,y:l+o.bar.y},n)),P(t,e,o.radicand,n,s,l,d);break;case "script":P(t,e,o.base,n,s,l,d),o.subscript&&P(t,e,o.subscript,n,s,l,d),o.superscript&&P(t,e,o.superscript,n,s,l,d);break;case "nary":P(t,e,o.operator,n,s,l,d),o.lowerLimit&&P(t,e,o.lowerLimit,n,s,l,d),o.upperLimit&&P(t,e,o.upperLimit,n,s,l,d),P(t,e,o.body,n,s,l,d);break}}function Ft(t,e,o,n){let i=o.geometry;e.className="layout-run docx-equation",e.dataset.docxEquation=o.sourceNodeId,e.setAttribute("contenteditable","false"),e.setAttribute("role","math"),o.fallbackText&&e.setAttribute("aria-label",o.fallbackText),e.style.position="relative",e.style.display="inline-block",e.style.width=`${i.box.width*n}px`,e.style.height=`${i.box.height*n}px`,e.style.lineHeight="0",e.style.pointerEvents="auto",e.style.userSelect="none",e.style.verticalAlign=`${-(i.box.height-i.baseline)*n}px`;let r=t.createDocumentFragment();P(t,r,i,n),e.append(r);}function Nt(t,e,o,n){if(o.glyphOffsetPt!==void 0){let s=o.style.horizontalScalePercent/100,l=o.box.width*n;e.style.width=`${l/s}px`,s!==1&&(e.style.marginRight=`${l-l/s}px`);let d=t.createElement("span");if(d.dataset.docxGlyphOffset="",s!==1&&(d.style.letterSpacing=`${o.style.characterSpacingPt*n/s}px`),o.glyphOffsetPt){d.dataset.docxShiftedInk="",d.style.setProperty("forced-color-adjust","preserve-parent-color"),d.style.setProperty("-webkit-text-fill-color","transparent");let c=`${o.glyphOffsetPt*n/s}px`;d.style.setProperty("--docx-glyph-ink-offset",c),e.style.color&&e.style.color!=="inherit"&&d.style.setProperty("--docx-glyph-ink-color",e.style.color),d.style.textShadow=`${c} 0 currentColor`;}return e.append(d),d}let i=o.lineEndWhitespace===true;(o.style.horizontalScalePercent!==100||o.text===" "||i)&&(e.style.width=`${o.box.width*n}px`);let r=o.style.shaping!==void 0&&o.style.horizontalScalePercent!==100;if(!i&&!r||(i&&(e.style.clipPath="inset(-1em 0)"),o.style.horizontalScalePercent===100))return e;let a=t.createElement("span");if(a.dataset.docxClippedFill="",a.style.display="inline-block",a.style.transform=e.style.transform,a.style.transformOrigin=e.style.transformOrigin,r){let s=o.style.horizontalScalePercent/100;a.style.width=`${o.box.width*n/s}px`,a.style.letterSpacing=`${o.style.characterSpacingPt*n/s}px`,o.style.shaping?.wordSpacingPt&&(a.style.wordSpacing=`${o.style.shaping.wordSpacingPt*n/s}px`),a.style.direction=o.style.shaping?.direction??"ltr",a.style.transformOrigin=a.style.direction==="rtl"?"right":"left";}return a.style.textDecorationLine=e.style.textDecorationLine,a.style.textDecorationStyle=e.style.textDecorationStyle,a.style.textDecorationColor=e.style.textDecorationColor,a.style.textDecorationThickness=e.style.textDecorationThickness,e.style.removeProperty("transform"),e.style.removeProperty("transform-origin"),e.style.removeProperty("text-decoration-line"),e.style.removeProperty("text-decoration-style"),e.style.removeProperty("text-decoration-color"),e.style.removeProperty("text-decoration-thickness"),e.append(a),a}function Ot(t,e,o){let n=e.textOutline;if(!n||!Number.isFinite(o)||o<=0||!Number.isFinite(n.widthPt)||n.widthPt<=0||n.widthPt>1584||!/^[0-9a-f]{6}$/i.test(n.color))return;let i=n.widthPt*o;Number.isFinite(i)&&(t.setProperty("-webkit-text-stroke-width",`${i}px`),t.setProperty("-webkit-text-stroke-color",`#${n.color}`));}var Vo=/^[0-9A-Fa-f]{6}$/;function Xo(t,e,o){let n=t.createElement("div");n.className=`docx-page-border docx-page-border-${e.side}`,n.setAttribute("aria-hidden","true"),n.style.position="absolute";let i=e.side==="left"||e.side==="right",r=(i?e.box.width:e.box.height)*o,a=Y(e.edge.val)?r:Math.max(1,r),s=a-r;n.style.left=`${e.box.x*o-(e.side==="right"?s:0)}px`,n.style.top=`${e.box.y*o-(e.side==="bottom"?s:0)}px`,n.style.width=i?`${a}px`:`${e.box.width*o}px`,n.style.height=i?`${e.box.height*o}px`:`${a}px`;let l=e.edge.color&&Vo.test(e.edge.color)?e.edge.color:"000000";return n.style.backgroundColor=`#${l}`,I(n,e.edge.val,l,i,a,o),n}function Kt(t,e,o){let n=t.createElement("div");n.className="docx-page-borders",n.setAttribute("aria-hidden","true"),n.setAttribute("contenteditable","false"),n.style.position="absolute",n.style.inset="0",n.style.pointerEvents="none";for(let i of e.strokes)n.append(Xo(t,i,o));return n}var qo=/^[0-9A-Fa-f]{6}$/;function Yo(t){switch(t){case "dashed":return "dashed";case "dotted":return "dotted";case "double":case "triple":return "solid";default:return "solid"}}function Re(t){return t&&qo.test(t)?t:"000000"}function ve(t,e){let o=t.createElement("div");return o.className=e,o.setAttribute("aria-hidden","true"),o.setAttribute("contenteditable","false"),o.style.position="absolute",o.style.left="0",o.style.top="0",o.style.right="0",o.style.bottom="0",o.style.overflow="visible",o.style.pointerEvents="none",o.style.boxSizing="border-box",o}function Zo(t,e,o,n){if(!o)return;let i=`#${Re(o.color)}`,r=`${Math.max(0,o.widthPt*n)}px`;if(t.style[`border${e}Width`]=r,t.style[`border${e}Color`]=i,o.style==="double"||o.style==="triple"){t.style[`border${e}Style`]="none";return}t.style[`border${e}Style`]=Yo(o.style);}function Se(t,e,o,n,i){let r=t.createElement("div");if(r.className=i,r.dataset.edge=o.side,r.dataset.stroke=o.role,r.style.position="absolute",r.style.left=`${o.x*n}px`,r.style.top=`${o.y*n}px`,r.style.width=`${o.width*n}px`,r.style.height=`${o.height*n}px`,r.style.pointerEvents="none",o.cssStyle==="solid")r.style.backgroundColor=`#${Re(o.color)}`;else {let a=o.side==="top"||o.side==="bottom";r.style.boxSizing="border-box",r.style[a?"borderTop":"borderLeft"]=`${(a?o.height:o.width)*n}px ${o.cssStyle} #${Re(o.color)}`;}e.append(r);}function Jo(t){let e=new Set;for(let o of t)e.add(`${o.side}\0${o.role}`);return e}function Qo(t,e,o,n){let i=Jo(o),r=h=>i.has(`${h}\0middle`),a=ve(t,"docx-table-border-double"),s=ve(t,"docx-table-border-triple"),l=ve(t,"docx-table-border-edge");for(let h of [a,s,l])h.style.zIndex="1";let d=false,c=false,u=false;for(let h of o){if(h.role==="edge"){u=true,Se(t,l,h,n,"docx-table-border-edge-stroke");continue}if(r(h.side)){c=true,Se(t,s,h,n,"docx-table-border-triple-stroke");continue}(h.role==="outer"||h.role==="inner")&&(d=true,Se(t,a,h,n,"docx-table-border-double-stroke"));}d&&e.append(a),c&&e.append(s),u&&e.append(l);}function zt(t,e,o,n){let i=new Set((o?.strokes??[]).map(r=>r.side));for(let r of ["top","right","bottom","left"]){let a=`${r[0].toUpperCase()}${r.slice(1)}`;Zo(e,a,o?.[r],n),i.has(r)&&(e.style[`border${a}Style`]="none");}o?.strokes&&o.strokes.length>0&&Qo(t,e,o.strokes,n);}function _t(t,e,o,n){if(e.textDirection!=="btLr")return n;let i=t.createElement("div");return i.className="docx-table-cell-content-btlr",i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width=`${e.box.height*o}px`,i.style.height=`${e.box.width*o}px`,i.style.transformOrigin="0 0",i.style.transform=`translateY(${e.box.height*o}px) rotate(-90deg)`,n.append(i),i}var we="when-selected",Ut=new WeakMap,jt=0;function en(t){let e=Ut.get(t);return e||(jt+=1,e=`alias${jt}`,Ut.set(t,e)),e}function Pe(t){return {...t,drawingStrings:t.drawingStrings??be,urlRegistry:t.urlRegistry??null,changeBars:t.changeBars??"none",changeBarsToggle:t.changeBarsToggle??false}}function tn(t){let e={...t,inertLinks:true,tabLeaderOriginXPt:0};return Object.freeze({scale:t.scale,strings:t.drawingStrings,...t.imageUrlPort?{imageUrlPort:t.imageUrlPort}:{},...t.inertLinks?{inertLinks:true}:{},...t.paintInstance?{paintInstance:t.paintInstance}:{},...t.revisionStyles?{revisionStyles:t.revisionStyles}:{},paintStoryFragment:(o,n)=>n.kind==="table"?K(o,n,e):O(o,n,e)})}function Qt(t){return Object.freeze({ctx:tn(t),urlRegistry:t.urlRegistry})}function Gt(t,e,o,n,i,r){ie(t,e,xa(o),n,i,r);}function ie(t,e,o,n,i,r,a=true,s){if(o.length===0)return;let l=Qt(n),d=t.createElement("div");d.className=r==="behind"?"docx-drawing-layer docx-drawing-layer-behind":"docx-drawing-layer docx-drawing-layer-front",d.style.position="absolute",d.style.inset="0",d.style.pointerEvents="none",s&&(d.dataset.docxHfFront=s);for(let c of Tt(t,o,r,l.ctx,l.urlRegistry,i)){if(c.style.pointerEvents=a?"auto":"none",!a)for(let u of c.querySelectorAll(".docx-drawing"))u.style.pointerEvents="none";d.append(c);}d.childElementCount>0&&e.append(d);}function eo(t){return t.horizontalFrame==="page"||t.verticalFrame==="page"}function to(t,e,o){let n=e.paintBounds,i=ta(e,t.box,o),r=i.x-e.x,a=i.y-e.y,s=l=>Object.freeze({x:l.x+r,y:l.y+a,width:l.width,height:l.height});return Object.freeze({...e,x:e.x+r,y:e.y+a,paintBounds:s(n),hitBounds:s(e.hitBounds),geometry:Object.freeze({...e.geometry,contentBounds:s(e.geometry.contentBounds),paintBounds:s(e.geometry.paintBounds),...e.geometry.clipPolygon?{clipPolygon:Object.freeze(e.geometry.clipPolygon.map(l=>Object.freeze({x:l.x+r,y:l.y+a})))}:{}})})}function on(t,e,o,n,i,r){let a=n.map(l=>to(o,l,r)),s=t.createElement("div");s.className="docx-hf-behind-layer",s.dataset.docxHfBehind=o.kind,s.setAttribute("contenteditable","false"),s.style.position="absolute",s.style.inset="0",s.style.overflow="hidden",s.style.pointerEvents="none",ie(t,s,a,i,r,"behind",false),s.childElementCount>0&&e.append(s);}function nn(t,e,o,n,i,r,a,s=false){let l=n.filter(eo).map(d=>to(o,d,r));ie(t,e,l,i,r,a,s,o.kind);}var z=/^[0-9A-Fa-f]{6}$/,Wt=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,rn=new Map(Object.entries({single:"solid",words:"solid",thick:"solid",double:"double",dotted:"dotted",dottedHeavy:"dotted",dash:"dashed",dashedHeavy:"dashed",dashLong:"dashed",dashLongHeavy:"dashed",dotDash:"dashed",dashDotHeavy:"dashed",dotDotDash:"dashed",dashDotDotHeavy:"dashed",wave:"wavy",wavyHeavy:"wavy",wavyDouble:"wavy"})),an=new Map(Object.entries({black:"#000000",blue:"#0000ff",cyan:"#00ffff",darkBlue:"#000080",darkCyan:"#008080",darkGray:"#808080",darkGreen:"#008000",darkMagenta:"#800080",darkRed:"#800000",darkYellow:"#808000",green:"#00ff00",lightGray:"#c0c0c0",magenta:"#ff00ff",red:"#ff0000",yellow:"#ffff00",white:"#ffffff"}));function sn(t){return t.doubleStrike?"double":t.strike?"single":"none"}function ln(t){return t==="thick"||t.endsWith("Heavy")}function oo(t){if(!t.underline)return null;let e=t.underline.color&&z.test(t.underline.color)?t.underline.color:null;return {cssStyle:rn.get(t.underline.variant)??"solid",color:e,heavy:ln(t.underline.variant)}}function no(t,e,o,n){t.textDecorationLine=e,t.textDecorationStyle=o,n.color&&(t.textDecorationColor=`#${n.color}`),n.heavy&&(t.textDecorationThickness=`max(${2*n.scale}px, 0.12em)`);}function Vt(t,e,o){e!=="none"&&no(t,"line-through",e==="double"?"double":"solid",{scale:o});}function Xt(t,e,o){no(t,"underline",e.cssStyle,{color:e.color,heavy:e.heavy,scale:o});}function dn(t,e,o){let n=e.color?`#${e.color}`:"currentColor";t.borderBottomWidth=`${(e.heavy?2:1)*o}px`,t.borderBottomStyle=e.cssStyle==="wavy"?"solid":e.cssStyle,t.borderBottomColor=n;}function re(t,e,o){let n=t.style,i=o.scale;Ot(n,e,i);let r=da(e);n.fontSize=`${e.fontSizePt*r*i}px`,e.bold&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let a=e.fontFamily&&Wt.test(e.fontFamily)?e.fontFamily:o.defaultFontFamily&&Wt.test(o.defaultFontFamily)?o.defaultFontFamily:null;if(a){let d=o.fontAlias?.(a);n.fontFamily=d?`"${d}", "${a}", ${N$1}`:`"${a}", ${N$1}`;}e.color&&z.test(e.color)&&(n.color=`#${e.color}`);let s=e.highlight?an.get(e.highlight):void 0;s?(n.backgroundColor=s,t.dataset.highlight=e.highlight??""):e.shading&&z.test(e.shading)&&(n.backgroundColor=`#${e.shading}`),e.caps&&(n.textTransform="uppercase"),n.fontKerning=M(e)?"normal":"none",e.smallCaps&&(n.fontVariant="small-caps");let l=ca(e);l!==0&&(n.position="relative",n.top=`${-l*i}px`),e.characterSpacingPt!==0&&(n.letterSpacing=`${e.characterSpacingPt*i}px`),e.horizontalScalePercent!==100&&(n.transformOrigin="left",n.transform=`scaleX(${e.horizontalScalePercent/100})`);}function ro(t,e,o,n,i){let r=o===" "?null:oo(n),a=sn(n),s=e;if(r&&a!=="none"){let l=t.createElement("span");l.dataset.docxDeco="underline",Xt(l.style,r,i);let d=t.createElement("span");d.dataset.docxDeco="strike",Vt(d.style,a,i),l.append(d),e.append(l),s=d;}else r?Xt(e.style,r,i):a!=="none"&&Vt(e.style,a,i);s.textContent=o;}function D(t,e,o,n){let i=t.createElement(e);return i.style.position="absolute",i.style.left=`${o.x*n}px`,i.style.top=`${o.y*n}px`,i.style.width=`${o.width*n}px`,i.style.height=`${o.height*n}px`,i}function cn(t,e,o){let n=e.fieldAtom;!n||(t.dataset.fieldAtom=n.formField?"form":"field",!(n.formField?o.shadeFormFields!==false:(o.fieldShading??we)!=="never"))||(t.classList.add("docx-field-atom"),(n.formField||(o.fieldShading??we)==="always")&&t.classList.add("docx-field-atom--shaded"));}function qt(t,e,o){let n=$a(e.props),i=o.revisionStyles,r=F(e.revisions,i?.authorSlots,i?.styles);if(!(!r&&!n)){if(r){let{attribution:a}=r;t.classList.add("docx-revision",`docx-revision-${a.kind}`),t.dataset.revisionKind=a.kind,t.dataset.revisionId=a.id,a.author!==""&&(t.dataset.reviewAuthor=a.author),a.date!==void 0&&(t.dataset.revisionDate=a.date);let s=i?.styles.get(a.author);if(i){t.dataset.reviewAuthorSlot=String((i.authorSlots.get(a.author)??0)%$);let c=i.classTokens.get(a.author);if(c)for(let u=0;u<c.length;u+=1)t.classList.add(c[u]);}let d=i!==void 0&&(s?.color!==void 0||i.others==="author")?r.authorColor:r.color;t.style.color=d,t.style.backgroundColor=s?.background??(r.deleted?"var(--doc-revision-deletion-wash)":"var(--doc-revision-insertion-wash)"),r.line&&(t.style.textDecorationLine=r.line,a.kind==="insert"&&r.line==="underline"?(t.style.textDecorationStyle="var(--doc-revision-insertion-decoration-style)",t.style.textDecorationThickness="var(--doc-revision-insertion-decoration-thickness)",t.style.textUnderlineOffset="var(--doc-revision-insertion-underline-offset)"):t.style.textDecorationStyle=r.decorationStyle,t.style.textDecorationColor=d);return}if(t.classList.add("docx-revision","docx-revision-format"),t.dataset.revisionKind="format",t.dataset.formattingKind="rPrChange",t.dataset.revisionId=n.id,n.author!==""&&(t.dataset.reviewAuthor=n.author),n.date!==void 0&&(t.dataset.revisionDate=n.date),i){let a=i.styles.get(n.author);t.dataset.reviewAuthorSlot=String((i.authorSlots.get(n.author)??0)%$);let s=i.classTokens.get(n.author);if(s)for(let l=0;l<s.length;l+=1)t.classList.add(s[l]);a?.color!==void 0&&(t.style.color=a.color),a?.background!==void 0&&(t.style.backgroundColor=a.background);}}}function un(t,e,o,n,i){let r=t.createElement("span"),a=sa(e.style,e.fontSlot);if(e.equation)return r.dataset.paragraphId=e.range.paragraphId,r.dataset.start=String(e.range.start),r.dataset.end=String(e.range.end),re(r,a,o),Ft(t,r,e.equation,o.scale),qt(r,e,o),r;r.className="layout-run layout-run-text",r.style.display="inline-block",r.style.verticalAlign="baseline",r.style.boxSizing="border-box",r.style.height=`${n*o.scale}px`,r.style.paddingTop=`${i*o.scale}px`,r.style.lineHeight=`${(n-i)*o.scale}px`,e.range.end>e.range.start?(r.dataset.paragraphId=e.range.paragraphId,r.dataset.start=String(e.range.start),r.dataset.end=String(e.range.end)):(r.setAttribute("aria-hidden","true"),r.contentEditable="false"),re(r,a,o),cn(r,e,o),qt(r,e,o);let s=Nt(t,r,e,o.scale);if(e.text===" "){r.style.overflow="hidden",r.style.verticalAlign="top";let l=oo(e.style);l&&e.tabLeader!=="underscore"&&(r.dataset.docxTabUnderline="",dn(r.style,l,o.scale));}return ro(t,s,e.text,e.style,o.scale),Ve(r,e,o.scale),We(r,e),e.projected&&(r.dataset.docxField="",r.setAttribute("contenteditable","false"),e.noteNav?(r.style.userSelect="none",e.noteNav.direction==="to-note"?(r.dataset.docxNoteRef="",r.dataset.docxNoteScope=e.noteNav.scopeId,e.text.length>0&&r.setAttribute("aria-description",e.text)):(r.dataset.docxNoteMarkBack="",r.dataset.docxNoteScope=e.noteNav.scopeId)):e.fieldAtom?.formControl?(r.style.userSelect="none",r.style.cursor="pointer"):(r.style.pointerEvents="none",r.style.userSelect="none")),r}function Yt(t,e,o){let n=t.createElement("a");return n.className="docx-hyperlink",n.style.cursor=!o.inertLinks&&e.href?"pointer":"default",n.dataset.docxLink=e.id,n.dataset.docxLinkKind=e.kind,n.setAttribute("tabindex","-1"),!o.inertLinks&&e.href&&(n.setAttribute("href",e.href),e.kind==="external"&&n.setAttribute("rel","noopener noreferrer")),e.tooltip&&n.setAttribute("title",e.tooltip),n.style.display="inline-block",n.style.verticalAlign="baseline",n.style.textDecoration="none",n.style.color="inherit",n}function yn(t,e,o,n=false){let i=o.scale,r=t.createElement("div");r.className="docx-line layout-line",r.dataset.lineId=e.id,r.dataset.paragraphId=e.range.paragraphId,r.style.position="absolute",r.style.top=`${e.box.y*i}px`,r.style.left=`${e.contentX*i}px`,r.style.height=`${e.box.height*i}px`,r.style.fontSize="0",r.style.whiteSpace="pre",r.style.overflow="visible";let a=e.leading??0,s=Math.min(Math.max(a,...e.spans.map(f=>f.box.height+a),e.spans.length===0?e.box.height-(e.trailingSpacing??0):0),e.box.height),l=Math.max(0,e.box.height-s);r.style.boxSizing="border-box",r.style.paddingBottom=`${l*i}px`,r.style.lineHeight=`${(e.box.height-l)*i}px`;let d=null,c=null,u=null,h=new Map;for(let[f,g]of Ja(e).entries())h.set(g.paragraphId,f);let p=f=>h.get(f)??0,y=[...e.drawings??[]].sort((f,g)=>p(f.paragraphId)-p(g.paragraphId)||f.start-g.start),x=0,m=(f,g)=>{for(;x<y.length&&(p(y[x].paragraphId)<p(f)||p(y[x].paragraphId)===p(f)&&y[x].start<g);){let v=y[x],S=Math.max(0,v.advanceEnd-v.advanceStart),R=t.createElement("span");R.className="docx-inline-drawing-advance",R.dataset.docxMarker="",R.setAttribute("contenteditable","false"),R.setAttribute("aria-hidden","true"),R.style.display="inline-block",R.style.width=`${S*i}px`,R.style.height=`${v.baselineOffset*i}px`,R.style.lineHeight="0",R.style.pointerEvents="none",R.style.verticalAlign="baseline",r.append(R),x+=1,d=null,c=null;}},A=f=>{let g=f.wrapAdvanceBefore??0;if(g<=.001)return;let v=t.createElement("span");v.className="docx-wrap-advance",v.dataset.docxMarker="",v.setAttribute("contenteditable","false"),v.setAttribute("aria-hidden","true"),v.style.display="inline-block",v.style.width=`${g*i}px`,v.style.height="0",v.style.lineHeight="0",v.style.pointerEvents="none",v.style.verticalAlign="baseline",r.append(v),d=null,c=null;},w=e.spans.some(f=>f.style.shaping!==void 0),b=0,k=0,L=false;for(let[f,g]of e.spans.entries()){m(g.range.paragraphId,g.range.start),w||A(g);let v=Math.min(g.box.height+a,e.box.height),S=g.noteSeparator?je(t,g,e,i):un(t,g,o,v,a);w&&(S.style.position="relative",S.style.left=`${(g.box.x-e.contentX-b)*i}px`,S.style.width||(S.style.width=`${g.box.width*i}px`),S.style.direction=g.style.shaping?.direction??"ltr",S.style.unicodeBidi="isolate",g.style.shaping?.wordSpacingPt&&(S.style.wordSpacing=`${g.style.shaping.wordSpacingPt*i}px`),b+=g.box.width),k>0&&!L&&(S.style.marginLeft=`${k*i}px`);let R=e.spans[f+1],_=w?0:pn(e,f+1,p);L=_>0&&R!==void 0&&fn(g,R),L&&(S.style.wordSpacing=`${_*i}px`),k=_;let M=g.link;if(!M){d=null,c=null,u=null,r.append(S);continue}if(g.fieldAtom){d!==null&&c===M.id&&u===g.range.start||(d=Yt(t,M,o),c=M.id,u=g.range.start,r.append(d)),d.append(S);continue}(!d||c!==M.id||u!==null)&&(d=Yt(t,M,o),c=M.id,u=null,r.append(d)),d.append(S);}if(m(Ja(e)[Ja(e).length-1]?.paragraphId??e.range.paragraphId,Number.POSITIVE_INFINITY),e.spans.length===0){let f=t.createElement("br");f.style.lineHeight=`${e.box.height*i}px`,r.append(f);}let E=Object.freeze({x:e.contentX,y:e.box.y,width:e.box.width,height:e.box.height});Ge(t,r,e,i),o.showParagraphMarks&&e.manualBreakAfter&&r.append(tt(t,e,i,o.revisionStyles,n));let C=Qt(Pe(o));if(e.drawings&&e.drawings.length>0)for(let f of Mt(t,e,C.ctx,C.urlRegistry,E))r.append(f);return r}function pn(t,e,o){if(e<=0||e>=t.spans.length)return 0;let n=t.spans[e-1],i=t.spans[e],r=o(n.range.paragraphId),a=o(i.range.paragraphId);if(t.drawings?.some(d=>{let c=o(d.paragraphId),u=c>r||c===r&&d.start>=n.range.start,h=c<a||c===a&&d.start<i.range.start;return u&&h}))return 0;let l=i.box.x-(n.box.x+n.box.width)-(i.wrapAdvanceBefore??0);return l>.001?l:0}var hn=/[\t\n\r \u00A0\u1361\u{10100}-\u{10102}\u{1039F}\u{1091F}]/u;function fn(t,e){return !t.text.endsWith(" ")||t.style.horizontalScalePercent!==100||!gn(t,e)||(e.wrapAdvanceBefore??0)>.001?false:!hn.test(t.text.slice(0,-1))}function gn(t,e){return !t.link&&!e.link?true:!t.link||!e.link||t.link.id!==e.link.id||!!t.fieldAtom!=!!e.fieldAtom?false:!t.fieldAtom||t.range.start===e.range.start}function O(t,e,o){let n=o.scale,i=D(t,"div",e.box,n);i.className="docx-paragraph-fragment layout-paragraph",e.clipToBox&&(i.style.overflow="hidden"),i.dataset.paragraphId=e.paragraphId,i.dataset.fragmentIndex=String(e.fragmentIndex),ue(i,e),o.readOnlyParagraphIds?.has(e.paragraphId)&&(i.classList.add("docx-generated-region"),i.dataset.docxReadOnly="",i.setAttribute("contenteditable","false")),o.emptyTocPlaceholderIds?.has(e.paragraphId)&&(i.classList.add("docx-toc-empty-placeholder"),i.dataset.docxTocEmpty=""),e.shading&&z.test(e.shading)&&e.shadingBox&&i.append(bn(t,e,n)),e.marker&&i.append(mn(t,e,o));for(let r of e.lines)for(let a of r.spans){if(!a.tabLeader)continue;let s=xn(t,e,r,a,o);s&&i.append(s);}if(o.showParagraphMarks&&e.paragraphEnd||e.markRevisions&&e.markRevisions.length>0){let r=ot(t,e.markRevisions??[],n,o.revisionStyles),a=e.lines[e.lines.length-1];a&&(r.style.top=`${(a.box.y-e.box.y)*n}px`,ce(r,de(a,Wb(e.props)),e.box.x,n),i.append(r));}for(let r of e.lines){let a=yn(t,r,o,Wb(e.props));e.markFormatRevision&&r===e.lines[e.lines.length-1]&&ue(a,e,true),a.style.top=`${(r.box.y-e.box.y)*n}px`,a.style.left=`${(r.contentX-e.box.x)*n}px`,i.append(a);}if(e.borders)for(let r of e.borders)i.append(Zt(t,e,r,n));else e.bottomBorder&&i.append(Zt(t,e,{side:"bottom",edge:e.bottomBorder.edge,box:e.bottomBorder.box},n));return i}function mn(t,e,o){let n=e.marker,i=o.scale,r=Ue(t,e,Pe(o));if(r)return r;let a=e.lines[0]?.leading??0,s=D(t,"span",n.box,i);s.className="docx-list-marker",s.dataset.docxMarker="",s.setAttribute("contenteditable","false"),s.setAttribute("aria-hidden","true"),s.style.left=`${(n.box.x-e.box.x)*i}px`,s.style.top=`${(n.box.y-e.box.y)*i}px`,s.style.display="block",s.style.overflow="visible",s.style.whiteSpace="pre";let l=e.lines[0],d=l?Math.max(a,...l.spans.map(p=>p.box.height+a),l.spans.length===0?l.box.height-(l.trailingSpacing??0):0):n.box.height,c=Math.min(d,n.box.height),u=Math.max(0,n.box.height-c);s.style.fontSize="0",s.style.boxSizing="border-box",s.style.paddingBottom=`${u*i}px`,s.style.lineHeight=`${c*i}px`;let h=t.createElement("span");return h.style.display="inline-block",h.style.verticalAlign="baseline",h.style.boxSizing="border-box",h.style.height=`${c*i}px`,h.style.paddingTop=`${a*i}px`,h.style.lineHeight=`${(c-a)*i}px`,re(h,n.style,o),n.pieces&&(h.dir="rtl"),ro(t,h,n.text,n.style,i),s.append(h),s}function xn(t,e,o,n,i){let r=n.tabLeader?Jb.get(n.tabLeader):void 0;if(!r||n.box.width<=0)return null;let a=i.scale,s=t.createElement("div");s.className="docx-tab-leader",s.dataset.docxTabLeader="",s.setAttribute("contenteditable","false"),s.setAttribute("aria-hidden","true"),s.style.position="absolute",n.tabLeader==="underscore"&&(s.style.zIndex="1"),s.style.left=`${(n.box.x-e.box.x)*a}px`,s.style.top=`${(o.box.y-e.box.y)*a}px`,s.style.width=`${n.box.width*a}px`,s.style.height=`${o.box.height*a}px`,s.style.overflow="hidden",s.style.whiteSpace="pre",s.style.pointerEvents="none",s.style.userSelect="none";let l=o.leading??0,d=Math.min(n.box.height+l,o.box.height),c=Math.max(0,o.box.height-d);s.style.fontSize="0",s.style.boxSizing="border-box",s.style.paddingBottom=`${c*a}px`,s.style.lineHeight=`${(o.box.height-c)*a}px`;let u=t.createElement("span");u.style.display="inline-block",u.style.verticalAlign="baseline",re(u,n.style,i),u.style.boxSizing="border-box",u.style.height=`${d*a}px`,u.style.paddingTop=`${l*a}px`,u.style.lineHeight=`${(d-l)*a}px`,n.tabLeader==="heavy"&&(u.style.fontWeight="bold");let h=n.tabLeaderAdvancePt&&n.tabLeaderAdvancePt>0?n.tabLeaderAdvancePt:Math.max(.5,n.style.fontSizePt*.2),p=ma((i.tabLeaderOriginXPt??0)+n.box.x,n.box.width,h);return u.style.marginLeft=`${p.offsetPt*a}px`,u.textContent=r.repeat(p.count),u.style.letterSpacing="0",s.append(u),s}function bn(t,e,o){let n=e.shadingBox,i=D(t,"div",n,o);return i.className="docx-paragraph-shading",i.setAttribute("aria-hidden","true"),i.style.left=`${(n.x-e.box.x)*o}px`,i.style.top=`${(n.y-e.box.y)*o}px`,i.style.backgroundColor=`#${e.shading}`,i}function Zt(t,e,o,n){let i=D(t,"div",o.box,n);i.className=`docx-paragraph-border docx-paragraph-border-${o.side}`,i.setAttribute("aria-hidden","true");let r=(o.box.x-e.box.x)*n,a=(o.box.y-e.box.y)*n,s=o.side==="left"||o.side==="right"||o.side==="bar",l=(s?o.box.width:o.box.height)*n,c=Y(o.edge.val)?l:Math.max(1,l);i.style.left=`${o.side==="right"?r-(c-l):r}px`,i.style.top=`${o.side==="bottom"?a-(c-l):a}px`,s?i.style.width=`${c}px`:i.style.height=`${c}px`;let u=o.edge.color&&z.test(o.edge.color)?o.edge.color:"000000";return i.style.backgroundColor=`#${u}`,I(i,o.edge.val,u,s,c,n),i}function vn(t,e,o,n){let i=n.scale,r=D(t,"div",e.box,i);if(r.className="docx-table-cell",r.style.left=`${(e.box.x-o.x)*i}px`,r.style.top=`${(e.box.y-o.y)*i}px`,r.style.boxSizing="border-box",r.style.overflow="visible",r.dataset.cellId=e.id,r.dataset.gridColumn=String(e.gridColumn),r.dataset.gridSpan=String(e.gridSpan),e.rowSpan&&e.rowSpan>1&&(r.dataset.rowSpan=String(e.rowSpan)),e.paintInert||e.vMergeContinue)return r.dataset.vMergeContinue="true",r.style.border="none",r.style.backgroundColor="transparent",r;r.style.border="none",zt(t,r,e.borders,i),e.shading&&z.test(e.shading)&&(r.style.backgroundColor=`#${e.shading}`);let a=_t(t,e,i,r);for(let s of e.blocks){let l=s.kind==="table"?K(t,s,n):O(t,s,n);l.style.left=`${(s.box.x-e.box.x)*i}px`,l.style.top=`${(s.box.y-e.box.y)*i}px`,a.append(l);}return r}function K(t,e,o){let n=o.scale,i=D(t,"div",e.box,n);i.className="docx-table-fragment layout-table",i.dataset.tableId=e.tableId,i.dataset.fragmentIndex=String(e.fragmentIndex),i.style.overflow="visible";for(let r of e.rows){let a=D(t,"div",r.box,n);a.className="docx-table-row",r.revisionKind&&(a.classList.add("docx-table-row--revision",r.revisionKind==="insert"?"layout-revision-ins":"layout-revision-del"),a.dataset.revisionKind=r.revisionKind,r.revisionId!==void 0&&(a.dataset.revisionId=r.revisionId),r.revisionAuthor!==void 0&&(a.dataset.reviewAuthor=r.revisionAuthor),r.revisionDate!==void 0&&(a.dataset.revisionDate=r.revisionDate)),a.dataset.rowId=r.id,r.isHeaderRepeat&&(a.dataset.headerRepeat="true"),a.style.left=`${(r.box.x-e.box.x)*n}px`,a.style.top=`${(r.box.y-e.box.y)*n}px`,a.style.overflow="visible";for(let s of r.cells)a.append(vn(t,s,r.box,o));i.append(a);}return i}function Sn(t,e,o,n,i){let r={...o,paintInstance:`p${e.index}`,tabLeaderOriginXPt:e.contentBox.x-e.box.x},a=D(t,"div",e.box,r.scale);if(a.className="docx-page",a.style.fontFamily=N$1,a.dataset.pageIndex=String(e.index),r.ariaHidden&&(a.setAttribute("aria-hidden","true"),a.setAttribute("role","presentation")),a.dataset.materialized=String(n),!n)return a;let s=Object.freeze({x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height}),l=Object.freeze({x:-(e.contentBox.x-e.box.x),y:-(e.contentBox.y-e.box.y),width:e.box.width,height:e.box.height});Gt(t,a,e,r,l,"behind");for(let p of [e.header,e.footer])p?.anchoredDrawings?.length&&on(t,a,p,p.anchoredDrawings,r,{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height});let d=e.pageBorders?Kt(t,e.pageBorders,r.scale):null;d&&e.pageBorders?.zOrder==="back"&&a.append(d);let c=t.createElement("div");c.className="docx-page-content",c.style.position="absolute",c.style.left=`${(e.contentBox.x-e.box.x)*r.scale}px`,c.style.top=`${(e.contentBox.y-e.box.y)*r.scale}px`,c.style.width=`${e.contentBox.width*r.scale}px`,c.style.height=`${e.contentBox.height*r.scale}px`,r.activeHeaderFooterRId&&c.setAttribute("contenteditable","false");for(let p of e.columnSeparators??[]){let y=t.createElement("div");y.className="docx-column-separator",y.setAttribute("contenteditable","false"),y.style.position="absolute",y.style.left=`${p.x*r.scale}px`,y.style.top=`${p.y*r.scale}px`,y.style.width=`${p.width*r.scale}px`,y.style.height=`${p.height*r.scale}px`,y.style.backgroundColor="currentColor",y.style.pointerEvents="none",c.append(y);}let u=i?new Map:null;for(let p of e.fragments){let y=p.kind==="table"?K(t,p,r):O(t,p,r);u?.set(p,y),c.append(y);}i&&u&&(i.content=c,i.blocks=u),a.append(c),d&&e.pageBorders?.zOrder==="front"&&a.append(d),Gt(t,a,e,r,l,"inFront"),nt(t,a,e,r,O,K);for(let p of ["header","footer"]){if(e[p]||e.parityBlank)continue;let y=t.createElement("div");y.className="docx-hf docx-hf--placeholder",y.dataset.docxHf=p,y.setAttribute("contenteditable","false");let x=p==="header"?e.contentBox.y-e.box.y:e.box.y+e.box.height-(e.contentBox.y+e.contentBox.height),m=Math.min(x,Rn);if(m<=0)continue;let A=Math.max(0,Math.min(wn,x-m)),w=p==="header"?A:e.box.height-A-m;y.style.position="absolute",y.style.left=`${(e.contentBox.x-e.box.x)*r.scale}px`,y.style.top=`${w*r.scale}px`,y.style.width=`${e.contentBox.width*r.scale}px`,y.style.height=`${m*r.scale}px`,a.append(y);}for(let p of [e.header,e.footer]){if(!p)continue;let y=p.anchoredDrawings??[],x=ee(p,e.index,r),m=t.createElement("div");m.className="docx-hf",m.dataset.docxHf=p.kind,p.rId&&(m.dataset.docxRId=p.rId),x?(m.dataset.docxHfActive="",m.setAttribute("contenteditable","true")):m.setAttribute("contenteditable","false"),m.style.position="absolute",m.style.left=`${(p.box.x-e.box.x)*r.scale}px`,m.style.top=`${(p.box.y-e.box.y)*r.scale}px`,m.style.width=`${p.box.width*r.scale}px`;let A=pe(p,e,x);m.style.height=`${A*r.scale}px`,m.style.overflow="visible";let w=(e.box.x-p.box.x)*r.scale,b=(e.box.y-p.box.y)*r.scale,k=w+e.box.width*r.scale,L=b+e.box.height*r.scale;m.style.clipPath=`polygon(${w}px ${b}px, ${k}px ${b}px, ${k}px ${L}px, ${w}px ${L}px)`;let E=Object.freeze({x:0,y:0,width:p.box.width,height:p.box.height}),C=y.filter(g=>!eo(g)),f={...r,inertLinks:true,tabLeaderOriginXPt:p.box.x-e.box.x};for(let g of p.fragments)m.append(g.kind==="table"?K(t,g,f):O(t,g,f));ie(t,m,C,Pe(r),E,"inFront",x),a.append(m),pt(t,a,m,e,p,r.scale),nn(t,a,p,y,r,s,"inFront",x);}rt(t,a,e,r);let h=ut(t,e,r.scale,r.changeBars,r.changeBarsToggle);return h&&a.append(h),a}var Rn=30,wn=36,ke=new WeakMap;function ii(t){ke.delete(t);}function kn(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Pn(t,e){let o=Object.keys(t);if(o.length!==Object.keys(e).length)return false;for(let n of o){let i=t[n],r=e[n];if(i!==r)return false}return true}function An(t,e){if(t.length!==e.length)return false;for(let o=0;o<t.length;o+=1)if(t[o]!==e[o])return false;return true}function En(t,e){if(t===e)return false;let o=new Set([...Object.keys(t),...Object.keys(e)]);for(let n of o){if(n==="fragments")continue;let i=t[n],r=e[n];if(i!==r&&!(Array.isArray(i)&&Array.isArray(r)&&An(i,r))&&!(typeof i=="object"&&typeof r=="object"&&i!==null&&r!==null&&!Array.isArray(i)&&!Array.isArray(r)&&Pn(i,r)))return false}return true}var Jt="docx-column-separator";function Ln(t,e,o,n){let i=e.content,r=e.blocks;if(!i||!r||i.parentElement!==e.element)return null;let a={...n,paintInstance:`p${o.index}`,tabLeaderOriginXPt:o.contentBox.x-o.box.x},s=new Map,l=[];for(let h of o.fragments){let p=r.get(h)??(h.kind==="table"?K(t,h,a):O(t,h,a));s.set(h,p),l.push(p);}let d=new Set(l),c=i.firstChild;for(;c;){let h=c.nextSibling,p=c;!d.has(p)&&p.classList?.contains(Jt)!==true&&c.remove(),c=h;}let u=i.firstChild;for(;u&&u.classList?.contains(Jt);)u=u.nextSibling;for(let h of l){if(h===u){u=u.nextSibling;continue}i.insertBefore(h,u);}return yt(t,e.element,o,n.scale,n.changeBars,n.changeBarsToggle),{record:o,materialized:true,element:e.element,content:i,blocks:s}}function $n(t,e,o,n){let i=t.element;return !t.materialized&&kn(t.record.box,e.box)&&i.style.left===`${e.box.x*o}px`&&i.style.top===`${e.box.y*o}px`&&i.style.width===`${e.box.width*o}px`&&i.style.height===`${e.box.height*o}px`&&i.getAttribute("aria-hidden")===(n?"true":null)}function Mn(t,e,o={}){Tn(t,e,o);}function Tn(t,e,o,n){t.classList.toggle("docx-show-paragraph-marks",o.showParagraphMarks??false);let i=o.contentControlChrome,r=i?`${i.showAll===true?"1":"0"}:${i.activeIds?[...i.activeIds].sort().join(","):""}:${i.checkedIds?[...i.checkedIds].sort().join(","):""}:${i.tocControlIds?[...i.tocControlIds].sort().join(","):""}:${i.suppressedIds?[...i.suppressedIds].sort().join(","):""}:${i.readOnly===true?"ro":""}`:"",a=o.drawingStrings??be,s=o.imageUrlPort!==void 0?kt(t,o.imageUrlPort):null,l=i?.additionalBoundaries?i.additionalBoundaries.flatMap(f=>f.fragments.map(g=>`${f.id}:${g.pageIndex}:${g.box.x}:${g.box.y}:${g.box.width}:${g.box.height}`)).sort().join(","):"",d=o.readOnlyParagraphIds?[...o.readOnlyParagraphIds].sort().join(","):"",c=o.emptyTocPlaceholderIds?[...o.emptyTocPlaceholderIds].sort().join(","):"",u=i?.tocControlIds?[...i.tocControlIds].sort().join(","):"",h=et(o.revisionStyles,e,n),p={scale:o.scale??96/72,ariaHidden:o.ariaHidden??true,drawingStrings:a,urlRegistry:s,...o.fontAlias?{fontAlias:o.fontAlias}:{},...o.readOnlyParagraphIds?{readOnlyParagraphIds:o.readOnlyParagraphIds}:{},...o.emptyTocPlaceholderIds?{emptyTocPlaceholderIds:o.emptyTocPlaceholderIds}:{},...o.defaultFontFamily?{defaultFontFamily:o.defaultFontFamily}:{},...o.fieldShading?{fieldShading:o.fieldShading}:{},showParagraphMarks:o.showParagraphMarks??false,changeBars:o.changeBars??"all-markup",changeBarsToggle:o.changeBarsToggle??false,...o.shadeFormFields!==void 0?{shadeFormFields:o.shadeFormFields}:{},...h?{revisionStyles:h}:{},...o.imageUrlPort?{imageUrlPort:o.imageUrlPort}:{},...o.activeHeaderFooterRId?{activeHeaderFooterRId:o.activeHeaderFooterRId}:{},...o.activeHeaderFooterPageIndex!==void 0?{activeHeaderFooterPageIndex:o.activeHeaderFooterPageIndex}:{},...i?{contentControlChrome:i}:{}},y=t.ownerDocument,x=`${p.scale}|${p.ariaHidden}|${p.fontAlias?en(p.fontAlias):""}|${p.defaultFontFamily??""}|cc:${r}:${l}|toc:${u}|ro:${d}|tocEmpty:${c}|${o.imageUrlPort?"url":""}|${Bt(a)}|rev:${Qe(h)}|marks:${o.showParagraphMarks??false}|bars:${p.changeBars}:${p.changeBarsToggle}`,m=ke.get(t),A=m?.parameters===x,w=A?new Map(m.pages.map(f=>[f.record,f])):null,b=m?new Map(m.pages.map(f=>[f.record.index,f])):null,k=e.pages.map(f=>{let g=o.materialize?.has(f.index)??true,v=w?.get(f);if(v&&v.materialized===g)return v;let S=b?.get(f.index);if(!g&&S&&$n(S,f,p.scale,p.ariaHidden))return {record:f,materialized:false,element:S.element};if(A&&g&&S?.materialized&&En(S.record,f)){let M=Ln(y,S,f,p);if(M)return M}let R={},_=Sn(y,f,p,g,R);return {record:f,materialized:g,element:_,...R.content?{content:R.content}:{},...R.blocks?{blocks:R.blocks}:{}}});ke.set(t,{parameters:x,pages:k}),t.dataset.revision=String(e.revision),s&&s.reconcile(Dt(e),Ht(e));let L=new Set(k.map(f=>f.element)),E=t.firstChild;for(;E;){let f=E.nextSibling;L.has(E)||E.remove(),E=f;}let C=t.firstChild;for(let f of k){if(f.element===C){C=C.nextSibling;continue}t.insertBefore(f.element,C);}ht(k,p);}function Cn(t,e,o,n){let i=t.ownerDocument,r=n.scale,a=[];for(let s of o){let l=e.pages[s.pageIndex];if(!l)continue;let d=i.createElement("div");d.className=s.className??n.className??"docx-cell-selection-rect",d.style.position="absolute";let c=n.pageOffsetX?.get(s.pageIndex)??0;d.style.left=`${(l.contentBox.x+s.x+c)*r}px`,d.style.top=`${(l.contentBox.y+s.y)*r}px`,d.style.width=`${s.width*r}px`,d.style.height=`${s.height*r}px`,s.reviewAuthor&&(d.dataset.reviewAuthor=s.reviewAuthor.author,d.dataset.reviewAuthorSlot=String(s.reviewAuthor.slot%$),d.style.setProperty("--doc-review-author-current",s.reviewAuthor.color)),s.activeBackground!==void 0&&(d.style.backgroundColor=s.activeBackground,d.style.boxShadow="none"),a.push(d);}t.replaceChildren(...a);}
|
|
2
|
-
export{J as a,Je as b,jn as c,fo as d,Gn as e,vr as f,Bt as g,be as h,Sr as i,we as j,an as k,ii as l,Mn as m,Tn as n,Cn as o};
|
package/dist/chunk-ZA6HEWUM.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {e}from'./chunk-WHG23WNI.js';import {Wc,cc,dc,fc,ac,Ad}from'./chunk-ZCRSPN4Q.js';import {b,c,a}from'./chunk-DZOGUV7O.js';import {da as da$1,ca,la as la$1,Ja as Ja$1,ma,R,S,U,T,Ga as Ga$1,xa as xa$1,Z,_,ya,ta as ta$1}from'./chunk-VE6H5EJA.js';import {Ha as Ha$1,af,xg,Hg,Mg,ce as ce$1,bg,Wb,Zb,Xb,ec,ae,Ac,zc,nc,ic,Sf,O,Hi,Ia as Ia$1,oc,_a as _a$1,wb,pg,mf,kf,rj,pc,_e as _e$1,Ye,sj,wj,tj,vj,uj,ub,yb,cf,Ab,ji,$h,Ff,Rc,Hf,Pc,Bg,zg,Og,Ze,lc,Te as Te$1,We as We$1,qj,Kd,Ei as Ei$1,cd,$e,ai as ai$1,Mf,Bi as Bi$1,Ri as Ri$1,da as da$2,ah,bh,_g,Yi,Fa as Fa$1,Ma as Ma$1,zf,jd,od,Cd,zd,Dd,Bd,Xh,se,xa as xa$2,Oc,nf,lf}from'./chunk-XRBPZCNK.js';function ba(t){let e=[];for(let o of t.pages){let n=o.pageFieldSource?.pageNumber??o.index+1,a=Wc(n,o.pageFieldSource?.format),s=d=>{for(let c of d)if(c.kind==="paragraph")for(let u of c.lines)e.push({...u.range,pageNumber:n,pageNumberText:a});else for(let u of c.rows)for(let m of u.cells)s(m.blocks);};s(o.fragments),o.header&&s(o.header.fragments),o.footer&&s(o.footer.fragments);for(let d of o.footnotes?.notes??[])s(d.fragments);for(let d of o.endnotes?.notes??[])s(d.fragments);}return {pageCount:t.pages.length,ranges:e}}function Di(t,e,o,n){if(!t||!Number.isInteger(t.pageCount)||t.pageCount<1)return null;let a=Ha$1(e,o);if(!a||a.kind!=="paragraph")return null;let s=af(a).find(c=>c.node.id===n);if(!s)return null;let d=t.ranges.find(c=>c.paragraphId===o&&c.start<=s.start&&c.end>s.start);return !d||!Number.isInteger(d.pageNumber)||d.pageNumber<1?null:{pageNumber:d.pageNumber,pageNumberText:d.pageNumberText,pageCount:t.pageCount}}function Bi(t){return async e$1=>{let o=e(e$1,{measurer:t.measurer,producer:t.producer,displayMode:"proposed"});if(!o.ok)throw new Error("field pagination could not open the document");try{return ba(await o.session.layout())}finally{o.session.dispose();}}}var Ce=Object.freeze(["default","first","even"]),Ht=Object.freeze({kind:"body"});function G(t){switch(t.kind){case "body":return "body";case "note":return `note:${t.noteKind}:${String(t.noteId)}`;default:return `${t.kind}:${String(t.sectionIndex)}:${t.variant}`}}function Ho(t){if(typeof t!="object"||t===null)return false;let e=t;return e.kind==="body"?true:e.kind==="note"?(e.noteKind==="footnote"||e.noteKind==="endnote")&&Number.isInteger(e.noteId):e.kind!=="header"&&e.kind!=="footer"?false:Number.isInteger(e.sectionIndex)&&e.sectionIndex>=0&&Ce.includes(e.variant)}var Wi=["getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","getFields","getField","getInlinePictures","getInlinePicture","getChangeTrackingMode","getDocument","getBody","getParagraphs","getRange","getSpanParagraphs","getText","getSpanText","getParagraphId","search","getFont","getParagraphFormat","getStyle","getSections","getPageSetup","getFurniture","getNotes","getNoteBody","getNoteText","getNoteKind","getLists","getListId","getListById","getListParagraphs","getParagraphList","getListLevel","getHyperlink","getBookmarks","getBookmarkName","getBookmarkRange","getComments","getCommentReplies","getCommentId","getCommentAuthor","getCommentDate","getCommentText","getCommentRange","getCommentResolved","getRevisions","getRevisionType","getRevisionAuthor","getRevisionDate","getRevisionRange","getContentControls","getContentControlById","getContentControlsByTag","getContentControlsByTitle","getContentControlTag","getContentControlTitle","getContentControlFileId","getContentControlSubtype","getContentControlLock","getContentControlIsBound","getContentControlPlaceholderShown","getContentControlTemporary","getContentControlText","getContentControlParagraphs","getContentControlRange"],xa=["insertTable","updateTable","updateTableCell","setInlinePicture","deleteInlinePicture","insertField","setFieldCode","deleteField","updateFieldResult","insertInlinePicture","insertBreak","setChangeTrackingMode","proposeInsertion","proposeDeletion","proposeReplacement","insertText","replaceSpan","replaceStoryBlocks","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","startNewList","attachToList","detachFromList","setListLevelFormat","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","resolveRevisionBatch","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],Aa=["resolveRevisionBatch","insertTable","insertInlinePicture","insertBreak","startNewList","deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],va=new Set(Aa);function an(t){return va.has(t.op)||t.op==="updateTable"&&["addRows","addColumns","deleteRows","deleteColumns","delete"].includes(t.mutation.kind)}var Ia=new Set(xa);function Wt(t){return Ia.has(t.op)}var Pa=63360;function Tt(t){return Math.round(mf(kf(t))*100)/100}function Oa(t,e){if(typeof t!="number"||!Number.isFinite(t))return null;let o=nf(lf(t));return o>Pa||o<0||o===0&&!e?null:o}var Ra=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function Mo(t){if(typeof t!="object"||t===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let e=t,o={},n=0;for(let[s,d,c]of Ra){let u=e[s];if(u===void 0)continue;let m=Oa(u,c);if(m===null)return {ok:false,reason:`that is not a value for ${s}`,detail:String(u)};o[d]=m,n+=1;}let a=e.orientation;if(a!==void 0){if(a!=="portrait"&&a!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(a)};o.orientation=a,n+=1;}return n===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:o}}function Sa(t){let e=Hi(t),o=e.widthTwips>e.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:Tt(e.widthTwips),pageHeight:Tt(e.heightTwips),orientation:o,topMargin:Tt(e.topTwips),rightMargin:Tt(e.rightTwips),bottomMargin:Tt(e.bottomTwips),leftMargin:Tt(e.leftTwips),headerDistance:Tt(e.headerTwips),footerDistance:Tt(e.footerTwips),gutter:Tt(e.gutterTwips)})}function Ca(t,e){if(!e)return null;let o=null,n=(a,s,d)=>{if(o!==null||a.kind==="textValue"||d>64)return;let c=a.kind==="paragraph"?a.id:s;if(a.id===e.id){o=c;return}for(let u of a.children)n(u,c,d+1);};return n(t.root,null,0),o}function jo(t,e,o){let n=ae(e.root);return Object.freeze(n.map((a,s)=>{let d=o[s];return Object.freeze({index:s,markParagraphId:Ca(e,a),pageSetup:Sa(a),titlePage:d?.titlePage??false,evenAndOddHeaders:d?.evenAndOddHeaders??false})}))}var wa=255,Ta=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false});function Do(t){let e=Ac(t);if(!e)return Ta;let o=new Map,n=new Map,a=null;for(let s of zc(e).values())if(s.type==="paragraph"){if(o.set(s.styleId,s.name),s.name!==null){let d=s.name.trim().toLowerCase();n.has(d)||n.set(d,s.styleId);}s.isDefault&&a===null&&(a=s.styleId);}return Object.freeze({nameOf:s=>o.get(s)??null,idOf:s=>n.get(s.trim().toLowerCase())??null,defaultId:a,present:true})}function we(t,e,o){let n=Ha$1(t,e);if(!n||n.kind!=="paragraph")return null;let a=Na(_e$1(Ye(n),"pStyle"));return a!==null?o.nameOf(a):o.defaultId===null?null:o.nameOf(o.defaultId)}function Na(t){if(!t)return null;for(let e of t.attributes)if(e.localName==="val")return e.value;return null}function Te(t,e){if(typeof t!="string"||t.trim().length===0)return {ok:false,detail:"style: not a name"};if(t.length>wa)return {ok:false,detail:"style: name too long"};if(!O(t))return {ok:false,detail:"style: not valid XML text"};if(!e.present)return {ok:false,detail:"style: this document defines no styles"};let o=e.idOf(t);return o===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:o}}function Bo(t,e,o){return e>=o?null:{text:t.text.slice(e-t.rawStart,o-t.rawStart),rawStart:e,rawEnd:o}}function Ea(t,e){let o=[],n=0;for(let a of t){for(;n<e.length&&e[n].end<=a.rawStart;)n+=1;let s=a.rawEnd-a.rawStart;if(a.text.length!==s){let u=e[n];(!u||u.start>=a.rawEnd)&&o.push(a);continue}let d=a.rawStart;for(;n<e.length;){let u=e[n];if(u.end<=d){n+=1;continue}if(u.start>=a.rawEnd)break;let m=Bo(a,d,Math.min(u.start,a.rawEnd));if(m&&o.push(m),d=Math.max(d,u.end),u.end<=a.rawEnd&&(n+=1),d>=a.rawEnd)break}let c=Bo(a,d,a.rawEnd);c&&o.push(c);}return o}function Ne(t,e,o){if(o==="model")return b(e);let n=c(t,e,o);if(o==="allMarkup")return a(n);let a$1=La(t);if(a$1.length===0)return a(n);let s=Ea(n,a$1);return a(s)}function La(t){let e=cf(t),o=[],n=(s,d)=>{if(!(d>64||s.kind==="textValue")){if(s.kind==="revisionInsert"||s.kind==="revisionMoveTo"){let c=e.spanOf(s);c&&c.end>c.start&&o.push({start:c.start,end:c.end});return}for(let c of s.children)n(c,d+1);}};n(t,0),o.sort((s,d)=>s.start-d.start||d.end-s.end);let a=[];for(let s of o){let d=a[a.length-1];d&&s.start<=d.end?d.end=Math.max(d.end,s.end):a.push({...s});}return a}var sn="\r",Fa=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false}),Ha=Object.freeze([]),Ma=Object.freeze([]),_o=Object.freeze([]),ja=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>Ma,furniture:()=>_o,noteIds:()=>({ok:true,ids:Vo}),styles:()=>Fa});function Da(t){return t.kind==="textValue"?Ha:Object.freeze(t.children.filter(e=>e.kind!=="textValue").map(e=>{let o=[];pc([e],o,0);let n=e.kind==="paragraph"?"paragraph":e.kind==="table"?"table":"other",a=e.kind==="paragraph"&&_e$1(Ye(e),"sectPr")!==void 0;return Object.freeze({id:e.id,kind:n,paragraphIds:Object.freeze(o.map(s=>s.id)),removable:n!=="other"&&!a})}))}function Ee(t,e,o,n,a){let s=oc(n),d=Object.freeze(s.map(g=>g.id)),c=new Map,u=new Map;s.forEach((g,A)=>{c.set(g.id,A),u.set(g.id,g);});let m=new Map,x=g=>{if(!c.has(g))return null;let A=m.get(g);if(A!==void 0)return A;let v=rj(e,g)??"";return m.set(g,v),v},y=new Map,b=(g,A="allMarkup")=>{let v=u.get(g);if(!v||v.kind!=="paragraph")return null;let O=`${g}:${A}`,w=y.get(O);if(w)return w;let L=Ne(v,x(g)??"",A);return y.set(O,L),L};return {story:t,part:e,root:n,scope:o,paragraphIds:d,blocks:Da(n),has:g=>c.has(g),indexOf:g=>c.get(g)??-1,paragraph(g){let A=u.get(g);return A?{nodeId:g,paraId:_a$1(A),text:b(g)?.text??""}:null},node:g=>u.get(g)??null,rawText:x,paragraphText:(g,A)=>b(g,A)?.text??null,projectedText:b,text:g=>d.map(A=>b(A,g)?.text??"").join(sn),styles:a}}function Le(t,e){let o=Ee(t.story,t.part,t.scope,e,t.styles);return {...o,indexOf:n=>o.has(n)?t.indexOf(n):-1}}function ce(t){let e=t.parts.get(t.mainDocumentPart);if(!e)return ja;let o,n=()=>o??=Do(t),a,s=()=>a??=ce$1(t),d,c=new Map,u=new Map,m=A=>{let v=u.get(A);if(v)return v;let O=bg(t,A);if(!O){let C={ok:true,ids:Vo};return u.set(A,C),C}let w=[],L=new Set,H=new Set,j=0,N=false;for(let C of O.root.children){if(Wb(C)!==A)continue;if(j+=1,C.kind!=="note"){N=true;continue}if(!Zb(C))continue;let W=Xb(C);if(W===null){N=true;continue}L.has(W)?H.add(W):(L.add(W),w.push(W));}let K=j>ec?{ok:false,reason:"truncated"}:N?{ok:false,reason:"malformed"}:H.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...H])}:{ok:true,ids:Object.freeze(w)};return u.set(A,K),K},x=A=>{let v=s()[A.sectionIndex];return v?(A.kind==="header"?v.headers:v.footers).get(A.variant)??null:null},y=A=>{if(A.kind==="body"){let O=nc(e);return O?Ee(A,e,{kind:"body"},O,n):null}if(A.kind==="note"){let O=m(A.noteKind);if(!O.ok||!O.ids.includes(A.noteId))return null;let w=bg(t,A.noteKind);if(!w)return null;let L=ic(w.root,A.noteId);return !L||!Zb(L)?null:Ee(A,w,{kind:"notesPart",noteKind:A.noteKind},L,n)}let v=x(A);return v?Ee(A,v.part,{kind:"headerFooter",rId:v.rId},v.part.root,n):null},b=A=>{let v=G(A);if(c.has(v))return c.get(v)??null;let O=y(A);return c.set(v,O),O};return {package:t,get body(){return b(Ht)},story:b,storyOf:A=>{if(b(Ht)?.has(A))return Ht;for(let[O]of s().entries())for(let w of ["header","footer"])for(let L of Ce){let H={kind:w,sectionIndex:O,variant:L};if(b(H)?.has(A))return H}for(let O of ["footnote","endnote"]){let w=m(O);if(w.ok)for(let L of w.ids){let H={kind:"note",noteKind:O,noteId:L};if(b(H)?.has(A))return H}}return null},sections:()=>d??=jo(t,e,s()),furniture(A){let v=s()[A];if(!v)return _o;let O=[];for(let w of ["header","footer"]){let L=w==="header"?v.headers:v.footers;for(let H of Ce){let j=L.get(H);j&&O.push(Object.freeze({kind:w,variant:H,declared:!j.inherited}));}}return Object.freeze(O)},noteIds:m,styles:n}}var Vo=Object.freeze([]);function Wo(t,e,o){let n=a=>({state:o,step:{ok:false,error:{code:"unsupported-capability",message:a,detail:"changeTrackingMode"}}});return t.op==="getChangeTrackingMode"||t.op==="setChangeTrackingMode"?e?t.op==="getChangeTrackingMode"?{state:o,step:{ok:true,kind:"query",value:{kind:"text",text:o.mode}}}:t.mode!=="Off"&&t.mode!=="TrackMineOnly"?n("TrackAll requires shared tracking enforcement for every peer and is not supported"):t.mode==="TrackMineOnly"&&(typeof t.author!="string"||!t.author.trim()||!O(t.author))?n("TrackMineOnly requires a non-empty XML-safe runtime author"):{state:{mode:t.mode,...t.mode==="TrackMineOnly"?{author:t.author.trim()}:{}},step:{ok:true,kind:"query",value:{kind:"applied"}}}:n("this host does not support runtime-local change tracking"):o.mode==="Off"||ln(t)?null:n(`${t.op} does not support TrackMineOnly; no permanent edit was applied`)}function ln(t){return !Wt(t)||t.op==="setChangeTrackingMode"||t.op==="insertText"||t.op==="replaceSpan"&&!("body"in t.span)?true:["proposeInsertion","proposeDeletion","proposeReplacement","insertComment","replyToComment","deleteComment","setCommentResolved","acceptRevision","rejectRevision","resolveRevisionBatch","acceptAllRevisions","rejectAllRevisions","selectSpan","selectBookmark"].includes(t.op)}function Ba(){let t=globalThis.crypto,e=t?.getRandomValues;if(typeof e!="function")throw new Error("automation: no secure random source. globalThis.crypto.getRandomValues is required to scope document handles to one host.");let o=e.call(t,new Uint8Array(16)),n="";for(let a of o)n+=a.toString(16).padStart(2,"0");return n}function _a(t){return typeof t=="object"&&t!==null&&"kind"in t&&"ref"in t}function Uo(){let t=new Map,e=new Map,o=new Map,n=new Map,a=Ba(),s=null,d=(u,m)=>{let x=(n.get(u)??0)+1;n.set(u,x);let y=`${u}:${a}:${String(x)}`;return t.set(y,m),Object.freeze({kind:u,ref:y})},c=(u,m,x)=>{let y=`${u}\0${m}`,b=o.get(y);if(b)return Object.freeze({kind:u,ref:b});let g=d(u,x);return o.set(y,g.ref),g};return {document(){return s??=d("document",{kind:"document"}),s},body(u,m){return c("body",`${G(u)}:${m??""}`,{kind:"body",story:u,...m?{rootNodeId:m}:{}})},table(u,m){return c("table",`${G(m)}:${u}`,{kind:"table",nodeId:u,story:m})},tableRow(u,m){return c("tableRow",`${G(m)}:${u}`,{kind:"tableRow",nodeId:u,story:m})},tableCell(u,m){return c("tableCell",`${G(m)}:${u}`,{kind:"tableCell",nodeId:u,story:m})},field(u,m,x){return c("field",`${G(x)}:${m}`,{kind:"field",paragraphId:u,fieldNodeId:m,story:x})},inlinePicture(u,m){return c("inlinePicture",`${G(m)}:${u}`,{kind:"inlinePicture",drawingNodeId:u,story:m})},paragraph(u,m){let x=e.get(u);if(x)return Object.freeze({kind:"paragraph",ref:x});let y=d("paragraph",{kind:"paragraph",paragraphId:u,story:m});return e.set(u,y.ref),y},section(u){return c("section",String(u),{kind:"section",index:u})},note(u,m){return c("note",`${u}:${String(m)}`,{kind:"note",noteKind:u,noteId:m})},comment(u,m){return c("comment",`${G(m)}\0${u}`,{kind:"comment",commentId:u,story:m})},revision(u,m){return c("revision",`${G(m)}\0${u}`,{kind:"revision",revisionId:u,story:m})},bookmark(u,m){return c("bookmark",`${G(m)}\0${u}`,{kind:"bookmark",name:u,story:m})},list(u,m){return c("list",`${G(m)}\0${u}`,{kind:"list",numId:u,story:m})},contentControl(u,m){return c("contentControl",`${G(m)}\0${u}`,{kind:"contentControl",nodeId:u,story:m})},retarget(u,m){let x=e.get(u);if(!x||u===m)return;let y=t.get(x);!y||y.kind!=="paragraph"||(e.delete(u),t.set(x,{kind:"paragraph",paragraphId:m,story:y.story}),e.has(m)||e.set(m,x));},resolve(u,m){if(!_a(u)||u.kind!==m||typeof u.ref!="string")return null;let x=t.get(u.ref);return !x||x.kind!==m?null:x}}}var $o=new WeakMap,Va=0;function Wa(t){if(!t)return;let e=$o.get(t);return e||(e={...t,cacheKey:`formatting-${++Va}`},$o.set(t,e)),e}function Ko(t){let e=new WeakMap;return (o,n,a,s)=>{let d=Wa(s),c=Ia$1(o,n.id),u;for(;c&&c.kind!=="table";){if(c.localName==="txbxContent")return;c.kind==="tableCell"&&(u=c.id),c=Ia$1(o,c.id);}if(!c||!u)return;let m=e.get(c);if(!m||m.mode!==a||m.filter!==d){let x=new Map,y=Ad(c,1,0,t,a,d);for(let b of y?.rows??[])for(let g of b.cells)x.set(g.id,g.styleFormatting);m={mode:a,filter:d,cells:x},e.set(c,m);}return m.cells.get(u)}}var zo={},Go=new WeakMap;function Xo(t,e=null,o="all-markup",n){let a=t??zo,s=Go.get(a);s||Go.set(a,s=new WeakMap);let d=e??zo,c=s.get(d);c||s.set(d,c=Ua(t,e));let u=c;return (m,x,y,b,g=o,A=n)=>u(m,x,y,b,g,A)}function Ua(t,e){let o=cc(t,void 0,e),n=Ko(o),a=new WeakMap;return (s,d,c,u,m="all-markup",x)=>{let y=n(u,s,m,x),b=a.get(s);if(!b||b.cellStyle!==y){let w=dc(o,xg(s,"paragraphProperties","pPr"),y);b={cellStyle:y,inherited:w},a.set(s,b);}let{inherited:g}=b,A=c?g.markRunProperties:fc(g.runProperties,ac(d),o),v=false,O=false;for(let w of A){if(w.localName!=="rtl"&&w.localName!=="cs")continue;let L=w.attributes?.val,H=L===void 0||["1","true","on"].includes(L);w.localName==="rtl"?v=H:O=H;}return v||O}}function Yo(t,e=()=>null,o=()=>"all-markup",n=()=>{}){return {runPropertyEdits(...a){return Mg(a[0],a[1],a[2],a[3],a[4],a[5],a[6],Xo(t(),e(),o(),n()))},mergedParagraphMarkProperties(...a){return Hg(a[0],a[1],a[2],Xo(t(),e(),o(),n()))}}}function bt(t,e){return {ok:false,code:t,detail:e}}function xt(t){return {ok:true,value:t}}function at(t,e,o,n){let a=o.resolve(t,e);if(!a||a.kind!=="body"&&a.kind!=="paragraph")return bt("invalid-handle",`not-a-${e}-handle`);let s=n.story(a.story);if(!s)return bt("invalid-handle",`no-such-story:${G(a.story)}`);if(a.kind==="body"&&a.rootNodeId){let d=Ha$1(s.part,a.rootNodeId);return !d||d.kind!=="tableCell"?bt("invalid-handle","cell no longer exists"):xt(Le(s,d))}return xt(s)}function pt(t,e,o){let n=e.resolve(t,"paragraph");if(!n||n.kind!=="paragraph")return bt("invalid-handle","not-a-paragraph-handle");let a=o.story(n.story);if(!a)return bt("invalid-handle",`no-such-story:${G(n.story)}`);let s=a.indexOf(n.paragraphId);return s<0?bt("invalid-handle","paragraph-not-in-body"):xt({story:n.story,paragraphId:n.paragraphId,index:s,offset:0})}function $a(t,e,o){let n=pt(t.paragraph,e,o);if(!n.ok)return n;let s=(o.story(n.value.story)?.rawText(n.value.paragraphId)??"").length,{offset:d}=t;return !Number.isInteger(d)||d<0||d>s?bt("invalid-offset",`offset ${String(d)} outside 0..${String(s)}`):xt({...n.value,offset:d})}function te(t,e,o){if("paragraph"in t){if(!("at"in t))return $a(t,e,o);let c=pt(t.paragraph,e,o);if(!c.ok||t.at==="start")return c;let m=(o.story(c.value.story)?.rawText(c.value.paragraphId)??"").length;return xt({...c.value,offset:m})}let n=at(t.body,"body",e,o);if(!n.ok)return n;let a=n.value.paragraphIds;if(a.length===0)return bt("invalid-offset","empty-story");if(t.at==="start")return xt({story:n.value.story,paragraphId:a[0],index:n.value.indexOf(a[0]),offset:0});let s=a.length-1,d=a[s];return xt({story:n.value.story,paragraphId:d,index:n.value.indexOf(d),offset:(n.value.rawText(d)??"").length})}function Ka(t,e){return t.index<e.index||t.index===e.index&&t.offset<=e.offset}function za(t){let e=t.paragraphIds;if(e.length===0)return null;let o=e.length-1,n=e[o];return {start:{story:t.story,paragraphId:e[0],index:t.indexOf(e[0]),offset:0},end:{story:t.story,paragraphId:n,index:t.indexOf(n),offset:(t.rawText(n)??"").length}}}function z(t,e,o){if("body"in t){let s=at(t.body,"body",e,o);return s.ok?xt(za(s.value)):s}if("paragraph"in t){let s=pt(t.paragraph,e,o);if(!s.ok)return s;let c=(o.story(s.value.story)?.rawText(s.value.paragraphId)??"").length;return xt({start:s.value,end:{...s.value,offset:c}})}let n=te(t.start,e,o);if(!n.ok)return n;let a=te(t.end,e,o);return a.ok?G(n.value.story)!==G(a.value.story)?bt("invalid-handle","span-crosses-stories"):Ka(n.value,a.value)?xt({start:n.value,end:a.value}):bt("invalid-offset","span-start-after-end"):a}function ot(t,e,o){if("body"in t)return at(t.body,"body",e,o);if("paragraph"in t)return at(t.paragraph,"paragraph",e,o);let n=t.start;return "paragraph"in n?at(n.paragraph,"paragraph",e,o):at(n.body,"body",e,o)}function Fe(t,e,o){if("paragraph"in t)return pt(t.paragraph,e,o);let n=at(t.body,"body",e,o);if(!n.ok)return n;let a=n.value.paragraphIds;if(a.length===0)return bt("invalid-offset","empty-story");let s=t.at==="first"?0:a.length-1;return xt({story:n.value.story,paragraphId:a[s],index:s,offset:0})}function At(t,e){if(!t)return [];let o=e.paragraphIds,n=o[t.start.index]===t.start.paragraphId?t.start.index:o.indexOf(t.start.paragraphId),a=o[t.end.index]===t.end.paragraphId?t.end.index:o.indexOf(t.end.paragraphId);return n<0||a<n?[]:o.slice(n,a+1)}function Ut(t,e){if(!t)return [];let o=At(t,e),n=o.length-1;return o.map((a,s)=>{let d=(e.rawText(a)??"").length,c=s===0?t.start.offset:0,u=s===n?t.end.offset:d;return {paragraphId:a,start:c,end:u,whole:c===0&&u===d}})}function Jo(t,e,o,n="allMarkup"){if(!t)return "";let a=At(t,e);return a.length===1?e.projectedText(t.start.paragraphId,n)?.sliceRaw(t.start.offset,t.end.offset)??"":a.map((s,d)=>{let c=e.projectedText(s,n);if(!c)return "";let u=(e.rawText(s)??"").length;return d===0?c.sliceRaw(t.start.offset,u):d===a.length-1?c.sliceRaw(0,t.end.offset):c.text}).join(o)}function Nt(t,e){return {start:{paragraph:e.paragraph(t.start.paragraphId,t.start.story),offset:t.start.offset},end:{paragraph:e.paragraph(t.end.paragraphId,t.end.story),offset:t.end.offset}}}function Ga(t){return t?.kind!=="paragraph"?false:t.children.every(e=>e.namespaceUri!==da$2?false:e.localName==="pPr"?true:e.kind==="run"&&e.children.every(o=>o.namespaceUri===da$2&&(o.localName==="rPr"||o.localName==="t"&&o.children.every(n=>n.kind==="textValue"))))}function dn(t,e,o){return Ga(Ha$1(t,e))&&Yi(t,e,o)===null}function Qo(t,e,o,n){let a=Yi(t,e,o);if(!a)return null;let s=o===a.offset?qj(t,{op:"insertText",paragraphId:e,offset:o,text:n}):null;return s?.ok&&rj(s.part,e)?.slice(o,o+n.length)===n?null:{ok:false,error:{code:"unsupported-capability",message:"insert at the placeholder start or replace the complete prompt",detail:"placeholder-insertion-offset"}}}function Xa(t,e,o){return t.start===t.end?e<t.start&&t.start<o:e===o?t.start<e&&e<t.end:Math.max(t.start,e)<Math.min(t.end,o)}var He=class{#t=new Map;has(e){return this.#t.has(e)}append(e,o,n,a,s=false){let d=this.#t.get(e)??[];if(d.some(y=>Xa(y,o,n)))return null;let c=o,u=n;for(let y of d){let b=y.length-(y.end-y.start);y.end<=o&&!(s&&y.start===o&&y.end===o)&&(c+=b),(y.end<n||y.end===n&&y.start!==y.end)&&(u+=b);}o===n&&(u=c);let m=a-(n-o);for(let y of d)n<=y.start&&!(o===n&&y.start===y.end&&o===y.start&&!s)&&(y.result.start+=m,y.result.end+=m);let x={start:c,end:c+a};return d.push({start:o,end:n,length:a,result:x}),this.#t.set(e,d),{start:c,end:u,result:x}}};function Zo(t,e,o,n,a=false){let s=e.start.paragraphId,d=t.append(s,e.start.offset,e.end.offset,o.length,a);return d?{ok:true,kind:"command",ops:qo(s,d.start,d.end,o),story:e.start.story,answer:()=>({kind:"span",span:Nt({start:{...e.start,offset:d.result.start},end:{...e.start,offset:d.result.end}},n)})}:{ok:false,error:{code:"conflicting-operations",message:"text edits overlap in the batch snapshot",detail:s}}}function qo(t,e,o,n){let a=[];return n.length&&a.push({op:"insertText",paragraphId:t,offset:e,text:n,...o>e?{bias:"right"}:{}}),o>e&&a.push({op:"deleteText",paragraphId:t,start:e+n.length,end:o+n.length}),a}function tr(t,e,o,n){let a=e.start.paragraphId,s=rj(t,a),d=Yi(t,a,e.start.offset),c=d&&o.length?[{op:"insertText",paragraphId:a,offset:e.start.offset,text:o,bias:"right"}]:qo(a,e.start.offset,e.end.offset,o),u=t;for(let x of c){let y=qj(u,x);if(!y.ok)return {ok:false,error:{code:"unsupported-content",message:"that replacement cannot preserve the targeted text safely",detail:y.reason}};u=y.part;}let m=rj(u,a);return s===null||m!==s.slice(0,e.start.offset)+o+s.slice(e.end.offset)?{ok:false,error:{code:d?"unsupported-capability":"unsupported-content",message:d?"replace the complete placeholder prompt to avoid consuming unrelated text":"that replacement changes the expected text positions",detail:a}}:{ok:true,kind:"command",ops:c,story:e.start.story,answer:()=>({kind:"span",span:Nt({start:e.start,end:{...e.start,offset:e.start.offset+o.length}},n)})}}var er=/\s/;function nr(t,e){let o=[],n=0;for(;n<t.length;){let a=null;for(let s of e){let d=t.indexOf(s,n);d<0||(!a||d<a.start||d===a.start&&s.length>a.length)&&(a={start:d,length:s.length});}if(!a)break;o.push(a),n=a.start+a.length;}return o}function or(t,e,o){let n=e[o]?.markParagraphId??null;if(n!==null)return n;let a=t.paragraphIds,s=a[a.length-1];return s===void 0||new Set(e.map(c=>c.markParagraphId).filter(c=>c!==null)).has(s)?null:s}function rr(t,e){for(let o of [t.start,t.end]){let n=e.rawText(o.paragraphId);if(n===null||o.offset>n.length)return false}return true}function ar(t,e,o){let n=e,a=o;for(;n<a&&er.test(t[n]);)n+=1;for(;a>n&&er.test(t[a-1]);)a-=1;return [n,a]}function Me(t,e){let o=Ha$1(t,e);if(!o||o.kind!=="paragraph")return [];let n=af(o);return Xh(o).flatMap(a=>{let s=n.find(c=>c.node.id===a.fieldNodeId),d=Ha$1(t,a.fieldNodeId);return s?[{paragraphId:e,fieldNodeId:a.fieldNodeId,code:a.instruction,start:s.start,end:s.end,rewritable:a.rewritable,locked:!!d&&se(d,"fldLock")===true}]:[]})}function ir(t){let o=xa$2(`<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:fldSimple w:instr="${t==="PAGE"?"PAGE":"NUMPAGES"}"><w:r><w:t/></w:r></w:fldSimple></w:p></w:body></w:document>`,{name:"/word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"});if(!o.ok)throw new Error("could not build a page field");let n=o.part.root.children.find(s=>s.kind==="body"),a=n&&oc(n)[0];if(!a||a.kind!=="paragraph")throw new Error("could not build a page field paragraph");return a}var dt=(t,e="unsupported-content")=>({ok:false,error:{code:e,message:t}});function sr(t,e,o,n,a){if(t.op==="getFields"||t.op==="insertField"){let x=z(t.span,e,o),y=ot(t.span,e,o);if(!x.ok||!y.ok)return dt("that field range no longer exists","invalid-handle");let b=y.value;if(t.op==="getFields")return {ok:true,kind:"query",value:{kind:"handles",handles:Ut(x.value,b).flatMap(N=>Me(b.part,N.paragraphId).filter(K=>K.start>=N.start&&K.end<=N.end)).map(N=>e.field(N.paragraphId,N.fieldNodeId,b.story))}};if(!x.value)return dt("insert a paragraph before inserting a field");if(t.removeFormatting!==void 0&&t.removeFormatting!==false)return dt("removeFormatting is not supported");if(t.text!==void 0&&typeof t.text!="string")return dt("field text must be a string");if(t.fieldType!==void 0&&typeof t.fieldType!="string")return dt("field type must be a string");let g=t.fieldType??"Empty",A=null;if(g==="Page"||g==="NumPages"){if(t.text!==void 0&&t.text.trim()!=="")return dt("field switches are not supported");A=g==="Page"?"PAGE":"NUMPAGES";}else g==="Empty"&&(A=ai$1(t.text??""));if(!A)return dt("only PAGE and NUMPAGES fields are supported");let{start:v,end:O}=x.value;if(!["Before","After","Start","End","Replace"].includes(t.location))return dt("unsupported field insert location");if(t.location==="Replace"&&v.paragraphId!==O.paragraphId)return dt("field replacement requires one paragraph");let w=t.location==="After"||t.location==="End"?O:v,L=n(b,w.paragraphId);if(L)return L;let H=[];return t.location==="Replace"&&O.offset>v.offset&&H.push({op:"deleteText",paragraphId:v.paragraphId,start:v.offset,end:O.offset}),H.push({op:"insertFragment",paragraphId:w.paragraphId,offset:w.offset,blocks:[ir(A)],lastMarkCovered:false}),{ok:true,kind:"command",story:b.story,ops:H,answer:j=>{let N=j.story(b.story)?.part,K=N&&Me(N,w.paragraphId).find(C=>C.start===w.offset);if(!K)throw new Error("inserted field was not committed");return {kind:"handle",handle:e.field(w.paragraphId,K.fieldNodeId,b.story)}}}}let s=e.resolve(t.field,"field");if(!s||s.kind!=="field")return dt("that is not a field handle","invalid-handle");let d=o.story(s.story),c=d&&Me(d.part,s.paragraphId).find(x=>x.fieldNodeId===s.fieldNodeId);if(!d||!d.has(s.paragraphId)||!c)return dt("that field no longer exists","invalid-handle");if(t.op==="getField")return {ok:true,kind:"query",value:{kind:"field",field:{code:c.code}}};if(c.locked||Te$1(d.part,s.fieldNodeId).content||We$1(d.part,s.fieldNodeId))return dt("field is protected");let u=n(d,s.paragraphId,t.op==="updateFieldResult");if(u)return u;let m=[];if(t.op==="deleteField")m.push({op:"deleteText",paragraphId:s.paragraphId,start:c.start,end:c.end});else if(t.op==="setFieldCode"){if(!ai$1(c.code)||!ai$1(t.code))return dt("only PAGE and NUMPAGES code writes are supported");m.push({op:"setFieldCode",paragraphId:s.paragraphId,fieldNodeId:s.fieldNodeId,code:t.code});}else {let x=ai$1(c.code);if(!x||!c.rewritable)return dt("this field result cannot be evaluated","unsupported-capability");let y=a?.(d.story,s.paragraphId,s.fieldNodeId);if(!y||!Number.isInteger(y.pageNumber)||y.pageNumber<1||!Number.isInteger(y.pageCount)||y.pageCount<1)return dt("field update requires actual semantic pagination","unsupported-capability");let b=x==="PAGE"?y.pageNumberText??String(y.pageNumber):String(y.pageCount);m.push({op:"refreshFieldResults",updates:[{paragraphId:s.paragraphId,fieldNodeId:s.fieldNodeId,text:b}]});}return {ok:true,kind:"command",story:d.story,ops:m,answer:()=>({kind:"applied"})}}var it=(t,e)=>({ok:false,error:{code:t,message:e,detail:e}}),$t=t=>({ok:true,kind:"query",value:t}),Ya=new Set(["getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","updateTable","updateTableCell","insertTable"]);function pe(t){let e=new Set,o=[t];for(;o.length;){let n=o.pop();n.kind==="paragraph"&&e.add(n.id),n.kind!=="textValue"&&o.push(...n.children);}return e}function lr(t,e){let o=pe(t);return [...pe(e)].filter(n=>!o.has(n)).length}function Ja(t,e){let o=[{node:t}];for(;o.length;){let{node:n,table:a}=o.pop();if(n.id===e)return a;if(n.kind==="textValue")continue;let s=n.kind==="table"?n:a;for(let d of n.children)o.push({node:d,table:s});}}function dr(t){let e=t.package&&Ac(t.package);return e?[...zc(e).values()].filter(o=>o.type==="table"):[]}function ur(t,e){if(!Ya.has(t.op))return null;let{handles:o,reads:n}=e;if(t.op==="getTables"||t.op==="insertTable"){let y=t.op==="getTables"?t.scope:t.span,b=ot(y,o,n);if(!b.ok)return it(b.code,b.detail);let g=z(y,o,n);if(!g.ok)return it(g.code,g.detail);let A=b.value;if(t.op==="getTables"){let H=g.value,j=sj(A.root).filter(N=>{if("body"in y)return true;if(!H)return false;let K=[...pe(N)].sort((X,Z)=>A.indexOf(X)-A.indexOf(Z)),C=K[0],W=K[K.length-1];return !C||!W?false:A.indexOf(C)>=H.start.index&&A.indexOf(W)<=H.end.index});return $t({kind:"handles",handles:j.map(N=>o.table(N.id,A.story))})}if(!g.value)return it("invalid-offset","empty-table-insertion-range");if(!["Before","After"].includes(t.location))return it("unsupported-content","table-insertion-location");let v=t.location==="Before"?g.value.start:g.value.end,O=wj(A,v.paragraphId,v.offset,t.rowCount,t.columnCount,t.values);if(!O.ok)return it("unsupported-content",O.reason);let w=e.admitWrite(A,lr(A.part.root,O.resultPart.root),[v.paragraphId]);if(w)return w;let L=new Set(sj(A.root).map(H=>H.id));return {ok:true,kind:"command",story:A.story,ops:[{op:"authorTable",action:{kind:"insert",paragraphId:v.paragraphId,offset:v.offset,rowCount:t.rowCount,columnCount:t.columnCount,...t.values?{values:t.values}:{}}}],answer:H=>{let j=H.story(A.story),N=j&&sj(j.root).find(K=>!L.has(K.id));return N?{kind:"handle",handle:o.table(N.id,A.story)}:{kind:"applied"}}}}let a=t.op==="getTableCells"?"tableRow":"cell"in t?"tableCell":"table",s=t.op==="getTableCells"?t.row:"cell"in t?t.cell:"table"in t?t.table:{kind:"document",ref:""},d=o.resolve(s,a);if(!d||!("nodeId"in d)||!("story"in d))return it("invalid-handle","unknown-table-object");let c=n.story(d.story);if(!c)return it("invalid-handle","missing-table-story");let u=Ha$1(c.part,d.nodeId);if(!u||u.kind!==a)return it("invalid-handle","deleted-table-object");let m=a==="table"?u:Ja(c.root,d.nodeId);if(!m)return it("invalid-handle","missing-parent-table");let x=tj(c,m.id);if(!x)return it("unsupported-content","unsupported-table-topology");switch(t.op){case "getTable":return $t({kind:"table",table:{values:x.values,headerRowCount:x.headerRowCount,rowCount:x.rowIds.length,columnCount:x.columnCount,style:dr(n).find(y=>y.styleId===x.styleId)?.name??""}});case "getTableRows":return $t({kind:"handles",handles:x.rowIds.map(y=>o.tableRow(y,c.story))});case "getTableCells":{let y=x.rowIds.indexOf(d.nodeId);return $t({kind:"handles",handles:(x.cellIds[y]??[]).map(b=>o.tableCell(b,c.story))})}case "getTableCell":{if(!Number.isInteger(t.rowIndex)||!Number.isInteger(t.cellIndex))return it("invalid-offset","invalid-cell-index");let y=x.cellIds[t.rowIndex]?.[t.cellIndex];return y?$t({kind:"handle",handle:o.tableCell(y,c.story)}):it("invalid-handle","cell-not-found")}case "getTableCellBody":return $t({kind:"handle",handle:o.body(c.story,d.nodeId)});case "getTableCellProperties":{let y=uj(c,m.id,d.nodeId);return y?$t({kind:"tableCell",cell:{value:y.value,columnWidth:y.columnWidth,shadingColor:y.shadingColor,verticalAlignment:y.verticalAlignment}}):it("invalid-handle","cell-not-found")}case "updateTable":case "updateTableCell":{let y=t.op==="updateTable"?t.mutation:{...t.properties,kind:"cell",cellId:d.nodeId};if(y.kind==="properties"&&y.styleId!==void 0){let v=y.styleId;if(typeof v!="string"||v.trim().length===0)return it("unsupported-content","invalid-table-style-name");let O=dr(n).find(w=>w.name?.trim().toLowerCase()===v.trim().toLowerCase());if(!O)return it("unsupported-content","table-style-not-defined");y={...y,styleId:O.styleId};}let b=vj(c,m.id,y);if(!b.ok)return it("unsupported-content",b.reason);let g=e.admitWrite(c,lr(c.part.root,b.resultPart.root),y.kind==="values"?[...pe(m)]:y.kind==="cell"&&y.value!==void 0?[...pe(u)]:[]);if(g)return g;let A=new Set(x.rowIds);return {ok:true,kind:"command",story:c.story,ops:[{op:"authorTable",action:{kind:"existing",tableId:m.id,mutation:y}}],answer:v=>{if(y.kind!=="addRows")return {kind:"applied"};let O=v.story(c.story);return {kind:"handles",handles:((O&&tj(O,m.id))?.rowIds??[]).filter(L=>!A.has(L)).map(L=>o.tableRow(L,c.story))}}}}default:return it("unsupported-content","unknown-table-operation")}}var cr=t=>({ok:false,error:{code:"unsupported-content",message:t}});function Qa(t){if(t.op==="getText")return t.target;if("body"in t)return t.body;if(t.op==="insertText"&&"body"in t.at)return t.at.body;if(t.op==="replaceSpan"&&"body"in t.span)return t.span.body;if(t.op==="insertParagraph"&&"body"in t.anchor)return t.anchor.body}function pr(t,e,o){let n=Qa(t);if(!n)return null;let a=e.handles.resolve(n,"body");if(!a||a.kind!=="body"||a.story.kind!=="header"&&a.story.kind!=="footer")return null;let s=a.story,d=e.reads.package;if(!d||e.reads.story(s))return null;if(!e.reads.sections()[s.sectionIndex])return cr("that section no longer exists");if(t.op==="getText")return {ok:true,kind:"query",value:{kind:"text",text:""}};if(t.op==="getParagraphs"||t.op==="getLists")return {ok:true,kind:"query",value:{kind:"handles",handles:[]}};if(t.op!=="insertText"&&t.op!=="replaceSpan"&&t.op!=="insertParagraph")return null;let c=m=>{let x=Mf(m,{op:"createHeaderFooter",sectionIndex:s.sectionIndex,kind:s.kind,variant:s.variant,...s.variant==="first"?{titlePage:true}:{},...s.variant==="even"?{evenAndOddHeaders:true}:{}});if(!x.ok||!x.createdPartName)return null;let y=ce(x.package),b=o(y),g=b.plan(t);if(!g.ok||g.kind!=="command"||g.relate||g.lifecycle||g.packageEdits?.length)return null;let A=x.package.parts.get(x.createdPartName);if(!A)return null;for(let O of g.ops){let w=qj(A,O);if(!w.ok)return null;A=w.part;}let v=Kd(x.package,A);return b.settle(ce(v)).ok?{pkg:v,planner:b,step:g}:null},u=c(d);return u?{ok:true,kind:"command",story:{kind:"body"},ops:[],solitary:true,packageEdits:[m=>{let x=c(m);if(!x)throw new Error("header/footer creation changed during transaction");return u=x,x.pkg}],answer:m=>u.step.answer(m)}:cr("cannot create this header or footer with that content")}var Za=20*1024*1024;function qa(t){if(typeof t!="string"||t.length===0||t.length>Math.ceil(Za/3)*4||t.length%4!==0)return null;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=t.endsWith("==")?2:t.endsWith("=")?1:0,n=new Uint8Array(t.length/4*3-o),a=0;for(let s=0;s<t.length;s+=4){let d=s+4===t.length,c=d?4-o:4,u=[0,0,0,0];for(let x=0;x<c;x++){let y=e.indexOf(t[s+x]);if(y<0)return null;u[x]=y;}if(d&&(o===2&&(u[1]&15)!==0||o===1&&(u[2]&3)!==0))return null;let m=u[0]<<18|u[1]<<12|u[2]<<6|u[3];a<n.length&&(n[a++]=m>>>16),a<n.length&&(n[a++]=m>>>8),a<n.length&&(n[a++]=m);}return n}function mr(t,e,o,n,a){let s=qa(a);if(!s)return {ok:false,detail:"picture: invalid or oversized base64 (20 MiB maximum)"};let d=jd(s);if(d!=="image/png"&&d!=="image/jpeg")return {ok:false,detail:"picture: only PNG and JPEG are supported"};if(!ti(s,d))return {ok:false,detail:"picture: truncated raster container"};let c=od(s,d);if(!c||c.pixelWidth*c.pixelHeight>4e7)return {ok:false,detail:"picture: invalid or oversized raster dimensions"};let u=c.pixelWidth*72/(c.dpiX??96),m=c.pixelHeight*72/(c.dpiY??96),x=Cd(u),y=Cd(m);if(x===null||y===null)return {ok:false,detail:"picture: invalid physical dimensions"};let b=zd(t,e,{bytes:s,mime:d});if(!b.ok)return {ok:false,detail:`picture: ${b.reason}`};let g=Dd({docPrId:b.docPrId,lockAspectRatio:true,relationshipId:b.relationshipId,extentEmu:{cx:x,cy:y}});return {ok:true,docPrId:b.docPrId,ops:[{op:"insertDrawing",paragraphId:o,offset:n,drawing:g}],packageEdits:[A=>{let v=zd(A,e,{bytes:s,mime:d});if(!v.ok||v.relationshipId!==b.relationshipId||v.docPrId!==b.docPrId||v.partName!==b.partName)throw new Error("picture allocation changed during the batch");return v.pkg}]}}function fr(t,e){return cd(t).find(o=>o.drawingNodeId===e&&o.kind==="inline"&&o.picture!==null)??null}function gr(t){return {width:t.extentEmu.cx/Bd,height:t.extentEmu.cy/Bd,lockAspectRatio:t.locks.changeAspect,altTextDescription:t.description}}function yr(t,e){let o=new Set(cd(t).filter(a=>a.kind==="inline"&&a.picture!==null).map(a=>a.drawingNodeId)),n=[];for(let a of e){let s=Ha$1(t,a.paragraphId);if(!(!s||s.kind!=="paragraph"))for(let d of af(s))d.start>=a.start&&d.end<=a.end&&o.has(d.node.id)&&n.push(d.node.id);}return n}function hr(t,e){let o=[],n=t.drawingNodeId;if(e.lockAspectRatio!==void 0&&typeof e.lockAspectRatio!="boolean")return {ok:false,detail:"lockAspectRatio: not a boolean"};let a=e.lockAspectRatio??t.locks.changeAspect;if(e.lockAspectRatio===false&&o.push({op:"setDrawingLocks",drawingNodeId:n,locks:{changeAspect:false}}),e.width!==void 0||e.height!==void 0){let s=e.width??t.extentEmu.cx/Bd,d=e.height??t.extentEmu.cy/Bd;if(a){let m=t.extentEmu.cx/t.extentEmu.cy;if(e.width!==void 0&&e.height!==void 0&&Math.abs(s/d-m)>1e-6)return {ok:false,detail:"picture: width and height disagree with the locked aspect ratio"};e.width!==void 0&&e.height===void 0&&(d=s/m),e.height!==void 0&&e.width===void 0&&(s=d*m);}let c=Cd(s),u=Cd(d);if(c===null||u===null)return {ok:false,detail:"picture: dimensions must be finite positive points"};o.push({op:"resizeDrawing",drawingNodeId:n,extentEmu:{cx:c,cy:u}});}if(e.lockAspectRatio===true&&o.push({op:"setDrawingLocks",drawingNodeId:n,locks:{changeAspect:true}}),e.altTextDescription!==void 0){if(typeof e.altTextDescription!="string"||e.altTextDescription.length>32767||!O(e.altTextDescription))return {ok:false,detail:"altTextDescription: invalid XML text or length"};o.push({op:"setDrawingMetadata",drawingNodeId:n,title:t.title,description:e.altTextDescription});}return o.length?{ok:true,ops:o}:{ok:false,detail:"picture: no properties requested"}}function ti(t,e){if(e==="image/jpeg")return t.length>=4&&t[t.length-2]===255&&t[t.length-1]===217;let o=new DataView(t.buffer,t.byteOffset,t.byteLength),n=8,a=false;for(;n+12<=t.length;){let s=o.getUint32(n);if(s>t.length-n-12)return false;let d=String.fromCharCode(t[n+4],t[n+5],t[n+6],t[n+7]);if(d==="IDAT"&&s>0&&(a=true),n+=s+12,d==="IEND")return a&&s===0&&n===t.length}return false}var vt=(t,e="unsupported-content")=>({ok:false,error:{code:e,message:t}});function kr(t,e,o,n){if(t.op==="getInlinePictures"||t.op==="insertInlinePicture"){let x=z(t.span,e,o),y=ot(t.span,e,o);if(!x.ok||!y.ok)return vt("that picture range no longer exists","invalid-handle");let b=y.value;if(t.op==="getInlinePictures")return {ok:true,kind:"query",value:{kind:"handles",handles:yr(b.part,Ut(x.value,b)).map(j=>e.inlinePicture(j,b.story))}};if(!x.value||!o.package)return vt("insert a paragraph before inserting a picture");let{start:g,end:A}=x.value;if(!["Before","After","Start","End","Replace"].includes(t.location))return vt("unsupported picture insert location");if(t.location==="Replace"&&g.paragraphId!==A.paragraphId)return vt("picture replacement requires a single paragraph");let v=t.location==="After"||t.location==="End"?A:g;if(Te$1(b.part,v.paragraphId).content||We$1(b.part,v.paragraphId))return vt("picture insertion is inside protected content");let O=Ha$1(b.part,v.paragraphId);if(O?.kind==="paragraph"){for(let j of af(O))if((t.location==="Replace"?j.start<A.offset&&j.end>g.offset:j.start<v.offset&&j.end>v.offset)&&(Te$1(b.part,j.node.id).content||We$1(b.part,j.node.id)))return vt("picture insertion touches protected content")}let w=n(b,v.paragraphId);if(w)return w;let L=mr(o.package,b.part.name,v.paragraphId,v.offset,t.base64);if(!L.ok)return vt(L.detail);let H=[];return t.location==="Replace"&&A.offset>g.offset&&H.push({op:"deleteText",paragraphId:g.paragraphId,start:g.offset,end:A.offset}),H.push(...L.ops),{ok:true,kind:"command",story:b.story,ops:H,packageEdits:L.packageEdits,answer:j=>{let N=j.story(b.story)?.part,K=N&&cd(N).find(C=>C.docPrId===L.docPrId&&C.kind==="inline");if(!K)throw new Error("inserted picture was not committed");return {kind:"handle",handle:e.inlinePicture(K.drawingNodeId,b.story)}}}}let a=e.resolve(t.picture,"inlinePicture");if(!a||a.kind!=="inlinePicture")return vt("that is not a picture handle","invalid-handle");let s=o.story(a.story),d=s&&fr(s.part,a.drawingNodeId);if(!s||!d)return vt("that inline picture no longer exists","invalid-handle");if(t.op==="getInlinePicture")return {ok:true,kind:"query",value:{kind:"inlinePicture",picture:gr(d)}};let c=Ha$1(s.part,a.drawingNodeId);for(;c&&c.kind!=="paragraph";)c=$e(s.part,c.id);if(!c||!s.has(c.id))return vt("picture is outside this story","invalid-handle");let u=n(s,c.id);if(u)return u;let m=t.op==="deleteInlinePicture"?{ok:true,ops:[{op:"deleteDrawing",drawingNodeId:a.drawingNodeId}]}:hr(d,t.properties);return m.ok?{ok:true,kind:"command",story:s.story,ops:m.ops,answer:()=>({kind:"applied"})}:vt(m.detail)}function br(t,e,o,n){let a=b=>({ok:false,error:{code:"unsupported-content",message:b}});if(t.breakType!=="Page"&&t.breakType!=="SectionNext")return a("only Page and SectionNext breaks are supported");if(!["Before","After","Start","End","Replace"].includes(t.location))return a("invalid break insertion location");let s=z(t.span,e,o);if(!s.ok)return {ok:false,error:{code:s.code,message:s.detail}};let d=s.value;if(!d)return a("empty story has no break position");let c=t.location==="After"||t.location==="End"?d.end:d.start,u=o.story(c.story);if(!u)return a("missing story");if(t.location==="Replace"&&d.start.paragraphId!==d.end.paragraphId)return a("break replacement must remain in one paragraph");let m=t.breakType==="SectionNext";if(m&&(u.story.kind!=="body"||Ei$1(u.part,c.paragraphId)))return a("section breaks require a body paragraph outside a table");let x=n(u,c.paragraphId,m?1:0);if(x)return x;let y=[];return t.location==="Replace"&&d.end.offset>d.start.offset&&y.push({op:"deleteText",paragraphId:c.paragraphId,start:d.start.offset,end:d.end.offset}),m?y.push({op:"splitParagraph",paragraphId:c.paragraphId,offset:c.offset},{op:"setSectionMark",paragraphId:c.paragraphId,breakType:"nextPage"}):y.push({op:"insertPageBreak",paragraphId:c.paragraphId,offset:c.offset}),{ok:true,kind:"command",story:u.story,ops:y,answer:()=>({kind:"applied"})}}var St=(t,e)=>t.children.find(o=>o.kind!=="textValue"&&o.namespaceUri===da$2&&o.localName===e),It=(t,e)=>t.attributes.find(o=>o.namespaceUri===da$2&&o.localName===e)?.value,je=t=>t.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">"),un=t=>typeof t=="string"&&t.length<=255&&!/[\x00-\x08\x0b\x0c\x0e-\x1f\uFFFE\uFFFF]/.test(t),xr={None:"none",Arabic:"decimal",UpperRoman:"upperRoman",LowerRoman:"lowerRoman",UpperLetter:"upperLetter",LowerLetter:"lowerLetter"},Ar={Solid:["\uF0B7","Symbol"],Hollow:["o","Courier New"],Square:["\uF0A7","Wingdings"],Diamonds:["\uF076","Wingdings"],Arrow:["\uF0D8","Wingdings"],Checkmark:["\uF0FC","Wingdings"]};function cn(t){let e=zf(t,"bullet");if(!e)return null;let o=e.pkg;for(let n=0;n<=8;n+=1)if(!me(o,e.numId,n)){let a=De(o,e.numId,n,{bullet:n%3===0?"Solid":n%3===1?"Hollow":"Square"});if(!a)return null;o=a;}return {pkg:o,numId:e.numId}}function me(t,e,o){let n=t.parts.get("/word/numbering.xml")?.root;if(!n)return false;let a=n.children,s=a.find(m=>m.kind!=="textValue"&&m.namespaceUri===da$2&&m.localName==="num"&&It(m,"numId")===e);if(!s)return false;let d=s.children.find(m=>m.kind!=="textValue"&&m.namespaceUri===da$2&&m.localName==="lvlOverride"&&It(m,"ilvl")===String(o));if(d&&St(d,"lvl"))return true;let c=St(s,"abstractNumId"),u=c&&a.find(m=>m.kind!=="textValue"&&m.namespaceUri===da$2&&m.localName==="abstractNum"&&It(m,"abstractNumId")===It(c,"val"));return !!u&&!St(u,"numStyleLink")&&u.children.some(m=>m.kind!=="textValue"&&m.namespaceUri===da$2&&m.localName==="lvl"&&It(m,"ilvl")===String(o))}function pn(t,e){if(!Number.isInteger(t)||t<0||t>8||!e||typeof e!="object")return false;if(e.bullet!==void 0){if(e.numbering!==void 0)return false;if(e.bullet==="Custom"){if(!Number.isInteger(e.charCode)||e.charCode<1||e.charCode>65535||e.charCode>=55296&&e.charCode<=57343||!un(String.fromCharCode(e.charCode)))return false}else if(!Object.hasOwn(Ar,e.bullet))return false;if(e.fontName!==void 0&&(!un(e.fontName)||!e.fontName.trim()))return false}if(e.numbering!==void 0&&!Object.hasOwn(xr,e.numbering)||e.formatString!==void 0&&(!Array.isArray(e.formatString)||e.formatString.length>32||e.formatString.some(n=>typeof n=="number"?!Number.isInteger(n)||n<0||n>t:!un(n)||/%[1-9]/.test(n)))||e.startingNumber!==void 0&&(!Number.isInteger(e.startingNumber)||e.startingNumber<0||e.startingNumber>2147483647))return false;for(let n of [e.textIndent,e.bulletNumberPictureIndent])if(n!==void 0&&(!Number.isFinite(n)||Math.abs(n)>1584))return false;let o=["bullet","charCode","fontName","numbering","formatString","startingNumber","textIndent","bulletNumberPictureIndent"];return Object.keys(e).some(n=>!o.includes(n))||e.bullet===void 0&&(e.charCode!==void 0||e.fontName!==void 0)||e.numbering===void 0&&e.formatString!==void 0?false:Object.keys(e).length>0}function De(t,e,o,n){if(!pn(o,n))return null;let a=t.parts.get("/word/numbering.xml");if(!a)return null;let s=a.root.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===da$2&&C.localName==="num"&&It(C,"numId")===e),d=s&&St(s,"abstractNumId");if(!s||!d)return null;let c=a.root.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===da$2&&C.localName==="abstractNum"&&It(C,"abstractNumId")===It(d,"val"));if(!c||St(c,"numStyleLink"))return null;let u=s.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===da$2&&C.localName==="lvlOverride"&&It(C,"ilvl")===String(o)),m=(u&&St(u,"lvl"))??c.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===da$2&&C.localName==="lvl"&&It(C,"ilvl")===String(o));if(m&&St(m,"lvlPicBulletId"))return null;let x=Fa$1(a),y=C=>C.kind==="textValue"?{...C,id:x()}:{...C,id:x(),children:C.children.map(y)},b=C=>{let W=xa$2(`<w:numbering xmlns:w="${da$2}">${C}</w:numbering>`,{name:a.name,contentType:a.contentType}),X=W.ok?W.part.root.children[0]:void 0;return X&&X.kind!=="textValue"?y(X):null};if(m??=b(`<w:lvl w:ilvl="${o}"><w:start w:val="1"/><w:numFmt w:val="decimal"/><w:lvlText w:val="%${o+1}."/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${720*(o+1)}" w:hanging="360"/></w:pPr></w:lvl>`)??void 0,!m)return null;let g=[...m.children],A=["start","numFmt","lvlRestart","pStyle","isLgl","suff","lvlText","lvlPicBulletId","legacy","lvlJc","pPr","rPr"],v=(C,W)=>{let X=b(W);if(!X)return false;let Z=g.findIndex(D=>D.kind!=="textValue"&&D.namespaceUri===da$2&&D.localName===C);if(Z>=0){let D=g[Z];g.splice(Z,1,{...D,attributes:[...D.attributes.filter(nt=>!X.attributes.some(rt=>rt.namespaceUri===nt.namespaceUri&&rt.localName===nt.localName)),...X.attributes]});}else {let D=g.findIndex(nt=>nt.kind!=="textValue"&&nt.namespaceUri===da$2&&A.indexOf(nt.localName)>A.indexOf(C));g.splice(D<0?g.length:D,0,X);}return true};if(n.startingNumber!==void 0&&!v("start",`<w:start w:val="${n.startingNumber}"/>`))return null;if(n.numbering!==void 0){let C=n.formatString?.map(W=>typeof W=="number"?`%${W+1}`:W).join("")??(n.numbering==="None"?"":`%${o+1}.`);if(!v("numFmt",`<w:numFmt w:val="${xr[n.numbering]}"/>`)||!v("lvlText",`<w:lvlText w:val="${je(C)}"/>`))return null}if(n.numbering!==void 0&&(g=g.map(C=>C.kind!=="textValue"&&C.namespaceUri===da$2&&C.localName==="rPr"?{...C,children:C.children.filter(W=>W.kind==="textValue"||W.namespaceUri!==da$2||W.localName!=="rFonts")}:C)),n.bullet!==void 0){let[C,W]=n.bullet==="Custom"?[String.fromCharCode(n.charCode),n.fontName??"Symbol"]:Ar[n.bullet];if(!v("numFmt",'<w:numFmt w:val="bullet"/>')||!v("lvlText",`<w:lvlText w:val="${je(C)}"/>`))return null;let X=St(m,"rPr"),Z=b(`<w:rFonts w:ascii="${je(W)}" w:hAnsi="${je(W)}"/>`);if(!Z)return null;let D=X?.children.filter(ct=>ct.kind==="textValue"||ct.namespaceUri!==da$2||ct.localName!=="rFonts")??[],nt=X?{...X,children:[Z,...D]}:b("<w:rPr/>");if(!nt)return null;let rt=g.findIndex(ct=>ct.kind!=="textValue"&&ct.namespaceUri===da$2&&ct.localName==="rPr");rt<0?g.push({...nt,children:[Z,...D]}):g[rt]={...nt,children:[Z,...D]};}if(n.textIndent!==void 0||n.bulletNumberPictureIndent!==void 0){let C=St(m,"pPr"),W=C&&St(C,"ind"),X=W?.attributes.filter(q=>q.namespaceUri!==da$2||!["left","start","firstLine","hanging"].includes(q.localName))??[],Z=n.textIndent===void 0?It(W??m,"left")??"0":String(Math.round(n.textIndent*20)),D=n.bulletNumberPictureIndent,nt=D===void 0?W?.attributes.filter(q=>q.namespaceUri===da$2&&["firstLine","hanging"].includes(q.localName))??[]:[],rt=b(`<w:ind w:left="${Z}"${D===void 0?"":` w:${D<0?"hanging":"firstLine"}="${Math.abs(Math.round(D*20))}"`}/>`);if(!rt)return null;let ct={...rt,attributes:[...X,...nt,...rt.attributes]},Mt=C?.children.filter(q=>q.kind==="textValue"||q.namespaceUri!==da$2||q.localName!=="ind")??[],jt=C??b("<w:pPr/>");if(!jt)return null;let oe=W?C.children.indexOf(W):-1,B=[...Mt],Pt=["contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"],ht=B.findIndex(q=>q.kind!=="textValue"&&q.namespaceUri===da$2&&Pt.includes(q.localName));B.splice(oe>=0?oe:ht>=0?ht:B.length,0,ct);let tt={...jt,children:B},gt=g.findIndex(q=>q.kind!=="textValue"&&q.namespaceUri===da$2&&q.localName==="pPr");if(gt>=0)g[gt]=tt;else {let q=g.findIndex(Et=>Et.kind!=="textValue"&&Et.localName==="rPr"&&Et.namespaceUri===da$2);g.splice(q<0?g.length:q,0,tt);}}let O=y({...m,children:g}),w=u?.children.filter(C=>C.kind==="textValue"||C.namespaceUri!==da$2||C.localName!=="lvl"&&(n.startingNumber===void 0||C.localName!=="startOverride"))??[],L=u??b(`<w:lvlOverride w:ilvl="${o}"/>`);if(!L)return null;let H={...L,children:[...w,O]},j=[...s.children],N=u?j.indexOf(u):-1;N>=0?j[N]=H:j.push(H);let K=Ma$1(a,s.id,{...s,children:j});return K.ok?Kd(t,K.part):null}var ee=8;function vr(t){if(!t||t.kind==="textValue")return null;for(let e of t.attributes)if(e.namespaceUri===da$2&&e.localName==="val")return e.value;return null}function Be(t){let e=_e$1(Ye(t),"numPr");if(!e)return null;let o=vr(_e$1(e,"numId"));if(o===null||!/^\d{1,10}$/.test(o)||o==="0")return null;let n=vr(_e$1(e,"ilvl")),a=n===null?0:Number(n);return !Number.isInteger(a)||a<0||a>ee?null:{numId:o,level:a}}function Kt(t){let e=new Map;for(let o of t.paragraphIds){let n=t.node(o);if(!n)continue;let a=Be(n);if(!a)continue;let s=e.get(a.numId);s?s.push(o):e.set(a.numId,[o]);}return Object.freeze([...e].map(([o,n])=>Object.freeze({numId:o,paragraphIds:Object.freeze(n)})))}function fe(t,e){let o=t.node(e);return o?Be(o):null}var mt=t=>({ok:false,error:{code:"unsupported-content",message:t}});function ei(t,e){if(t.root.namespaceUri!==da$2||t.root.localName!=="styles")return false;let o=[t.root];for(;o.length;){let n=o.pop();if(n.kind!=="textValue"){if(n.namespaceUri===da$2&&n.localName==="numId"&&n.attributes.some(a=>a.namespaceUri===da$2&&a.localName==="val"&&a.value===e))return true;for(let a of n.children)o.push(a);}}return false}function Ir(t,e,o,n){let a=o.package;if(!a)return mt("no document");if(t.op==="setListLevelFormat"){let b=e.resolve(t.list,"list");if(!b||b.kind!=="list")return mt("that is not a list");let g=o.story(b.story),A=g&&Kt(g).find(v=>v.numId===b.numId);if(!g||!A)return mt("that list no longer exists");if(!pn(t.level,t.format))return mt("invalid list level format");for(let v of a.parts.values()){if(ei(v,b.numId))return mt("list is referenced by a style");for(let O of lc(v))for(let w of oc(O.root))if(Be(w)?.numId===b.numId&&!g.has(w.id))return mt("list is shared across stories")}for(let v of A.paragraphIds){if(Te$1(g.part,v).content||We$1(g.part,v))return mt("list contains protected content");let O=n(g,v,{numId:b.numId,level:t.level});if(O)return O}return De(a,b.numId,t.level,t.format)?{ok:true,kind:"command",story:g.story,ops:[],packageEdits:[v=>{let O=De(v,b.numId,t.level,t.format);if(!O)throw new Error("list definition changed during transaction");return O}],answer:()=>({kind:"applied"})}:mt("cannot format this list")}let s=pt(t.paragraph,e,o);if(!s.ok)return {ok:false,error:{code:s.code,message:s.detail}};let d=o.story(s.value.story);if(!d)return mt("missing story");let c=n(d,s.value.paragraphId);if(c)return c;let u=null,m=0,x=[];if(t.op==="startNewList"){let b=cn(a);if(!b)return mt("cannot create numbering definition");let g=s.value.paragraphId;if(!qj(d.part,{op:"setListNumbering",paragraphId:g,numId:b.numId,level:0}).ok)return mt("cannot number this paragraph");let v=b.numId;return {ok:true,kind:"command",story:d.story,ops:[],packageEdits:[O=>{let w=cn(O),L=w?.pkg.parts.get(d.part.name);if(!w||!L)throw new Error("cannot create numbering definition");let H=qj(L,{op:"setListNumbering",paragraphId:g,numId:w.numId,level:0});if(!H.ok)throw new Error("cannot number this paragraph");return v=w.numId,Kd(w.pkg,H.part)}],answer:()=>({kind:"handle",handle:e.list(v,d.story)})}}else if(t.op==="attachToList"){if(!Number.isSafeInteger(t.listId)||t.listId<=0||!Number.isInteger(t.level)||t.level<0||t.level>8)return mt("invalid list identity or level");if(u=String(t.listId),m=t.level,!me(a,u,m))return mt("list level is not defined; configure that level first");if(!Kt(d).some(b=>b.numId===u))return mt("that list does not exist in this story")}let y=u;return {ok:true,kind:"command",story:d.story,ops:[{op:"setListNumbering",paragraphId:s.value.paragraphId,numId:t.op==="detachFromList"?"0":u,level:m}],packageEdits:x,answer:()=>y===null?{kind:"applied"}:{kind:"handle",handle:e.list(y,d.story)}}}var mn=Object.freeze({None:"none",Single:"single",Word:"words",Double:"double",Thick:"thick",Dotted:"dotted",DottedHeavy:"dottedHeavy",DashLine:"dash",DashLineHeavy:"dashedHeavy",DashLineLong:"dashLong",DashLineLongHeavy:"dashLongHeavy",DotDashLine:"dotDash",DotDashLineHeavy:"dashDotHeavy",TwoDotDashLine:"dotDotDash",TwoDotDashLineHeavy:"dashDotDotHeavy",Wave:"wave",WaveHeavy:"wavyHeavy",WaveDouble:"wavyDouble"}),Pr=[["Yellow","yellow","#FFFF00"],["Lime","green","#00FF00"],["Turquoise","cyan","#00FFFF"],["Pink","magenta","#FF00FF"],["Blue","blue","#0000FF"],["Red","red","#FF0000"],["DarkBlue","darkBlue","#000080"],["Teal","darkCyan","#008080"],["Green","darkGreen","#008000"],["Purple","darkMagenta","#800080"],["DarkRed","darkRed","#800000"],["Olive","darkYellow","#808000"],["Gray","darkGray","#808080"],["LightGray","lightGray","#C0C0C0"],["Black","black","#000000"],["White","white","#FFFFFF"]];function Or(t){return Object.entries(mn).find(([,e])=>e===t)?.[0]??null}function Rr(t){return Pr.find(([,e])=>e===t)?.[2]??null}function Sr(t){let e=[];if(t.underline!==void 0){let o=typeof t.underline=="string"&&Object.hasOwn(mn,t.underline)?mn[t.underline]:void 0;if(!o)return {ok:false,detail:"underline: unsupported underline style"};e.push({localName:"u",attributes:{val:o}});}if(t.strikeThrough!==void 0){if(typeof t.strikeThrough!="boolean")return {ok:false,detail:"strikeThrough: not a boolean"};e.push({localName:"strike",attributes:{val:t.strikeThrough?"1":"0"}});}for(let o of ["subscript","superscript"])if(t[o]!==void 0&&typeof t[o]!="boolean")return {ok:false,detail:`${o}: not a boolean`};if(t.subscript===true&&t.superscript===true)return {ok:false,detail:"subscript and superscript are mutually exclusive"};if(t.highlightColor!==void 0){let o=t.highlightColor,n=typeof o=="string"?Pr.find(([a,,s])=>a.toLowerCase()===o.toLowerCase()||s===o.toUpperCase()):void 0;if(o!==null&&!n)return {ok:false,detail:"highlightColor: use an exact Word palette color or null to clear"};e.push({localName:"highlight",attributes:{val:n?.[1]??"none"}});}return {ok:true,value:e}}var ni=31680,oi=1999,ri=Object.freeze({bold:null,italic:null,underline:null,strikeThrough:null,highlightColor:null,subscript:null,superscript:null,name:null,size:null,color:null});function st(t,e){if(!t)return null;for(let o of t.attributes)if(o.localName===e)return o.value;return null}function Ve(t){if(!t)return null;let e=st(t,"val");if(e===null)return true;let o=e.trim().toLowerCase();return !(o==="0"||o==="false"||o==="off"||o==="none")}function ai(t){if(t===null)return null;let e=t.trim();return /^[0-9a-fA-F]{6}$/.test(e)?`#${e.toUpperCase()}`:null}function ii(t){if(t===null)return null;let e=Number(t.trim());return !Number.isFinite(e)||e<=0?null:e/2}function zt(t){if(t===null)return null;let e=Number(t.trim());return Number.isFinite(e)?mf(kf(e)):null}function Ct(t){if(t.length===0)return null;let e=t[0];if(e===null)return null;for(let o of t)if(o!==e)return null;return e}function Tr(t,e,o=pg){let n=[];for(let a of e)for(let s of Og(t,a.paragraphId,a.start,a.end,o))n.push(Ze(s));return n.length===0?ri:{bold:Ct(n.map(a=>Ve(_e$1(a,"b")))),italic:Ct(n.map(a=>Ve(_e$1(a,"i")))),underline:Ct(n.map(a=>Or(st(_e$1(a,"u"),"val")))),strikeThrough:Ct(n.map(a=>Ve(_e$1(a,"strike")))),highlightColor:Ct(n.map(a=>Rr(st(_e$1(a,"highlight"),"val")))),subscript:Ct(n.map(a=>wr(a,"subscript"))),superscript:Ct(n.map(a=>wr(a,"superscript"))),name:Ct(n.map(a=>{let s=_e$1(a,"rFonts"),d=st(s,"ascii");return d===null||d.length===0?null:d})),size:Ct(n.map(a=>ii(st(_e$1(a,"sz"),"val")))),color:Ct(n.map(a=>ai(st(_e$1(a,"color"),"val"))))}}var si=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),li=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function di(t){let e=st(_e$1(t,"jc"),"val");return e===null?"Unknown":si[e.trim().toLowerCase()]??"Unknown"}function Nr(t,e,o){let n=Ha$1(t,e);if(!n||n.kind!=="paragraph")return null;let a=Ye(n),s=_e$1(a,"spacing"),d=_e$1(a,"ind");return {alignment:di(a),style:we(t,e,o),firstLineIndent:ui(d),leftIndent:zt(st(d,"left")??st(d,"start")),rightIndent:zt(st(d,"right")??st(d,"end")),lineSpacing:zt(st(s,"line")),spaceBefore:zt(st(s,"before")),spaceAfter:zt(st(s,"after")),widowControl:Ve(_e$1(a,"widowControl"))}}function ui(t){let e=zt(st(t,"hanging"));if(e!==null&&e>0)return -e;let o=zt(st(t,"firstLine"));return o!==null?o:e===null?null:-e}function _e(t,e){if(typeof t!="number"||!Number.isFinite(t))return {ok:false,detail:`${e}: not a measurement`};let o=nf(lf(t));return Math.abs(o)>ni?{ok:false,detail:`${e}: out of range`}:{ok:true,value:o}}function Er(t){let e=Sr(t);if(!e.ok)return e;let o=e.value;if(t.bold!==void 0){if(typeof t.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};o.push({localName:"b",...t.bold?{}:{attributes:{val:"0"}}});}if(t.italic!==void 0){if(typeof t.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};o.push({localName:"i",...t.italic?{}:{attributes:{val:"0"}}});}if(t.name!==void 0){let n=t.name;if(typeof n!="string"||n.length===0||n.length>128)return {ok:false,detail:"name: not a font name"};if(!O(n))return {ok:false,detail:"name: not valid XML text"};o.push({localName:"rFonts",attributes:{ascii:n,hAnsi:n}});}if(t.size!==void 0){let n=t.size;if(typeof n!="number"||!Number.isFinite(n)||n<=0)return {ok:false,detail:"size: not a positive number of points"};let a=Math.round(n*2);if(a<1||a>oi)return {ok:false,detail:"size: out of range"};o.push({localName:"sz",attributes:{val:String(a)}}),o.push({localName:"szCs",attributes:{val:String(a)}});}if(t.color!==void 0){let n=t.color;if(typeof n!="string"||!/^#[0-9a-fA-F]{6}$/.test(n.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};o.push({localName:"color",attributes:{val:n.trim().slice(1).toUpperCase()}});}return o.length===0&&t.subscript===void 0&&t.superscript===void 0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:o}}function Lr(t,e,o,n){let a=Ha$1(t,e);if(!a||a.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let s=Ye(a),d=[];if(o.style!==void 0){let g=Te(o.style,n);if(!g.ok)return {ok:false,detail:g.detail};d.push({localName:"pStyle",attributes:{val:g.styleId}});}if(o.alignment!==void 0){let g=li[o.alignment];if(g===void 0)return {ok:false,detail:`alignment: ${String(o.alignment)}`};d.push({localName:"jc",attributes:{val:g}});}let c=_e$1(s,"ind"),u=Cr(c),m=false;if(o.firstLineIndent!==void 0){let g=_e(o.firstLineIndent,"firstLineIndent");if(!g.ok)return g;delete u.firstLine,delete u.hanging,g.value<0?u.hanging=String(-g.value):u.firstLine=String(g.value),m=true;}for(let[g,A,v]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let O=o[g];if(O===void 0)continue;let w=_e(O,g);if(!w.ok)return w;delete u[v],u[A]=String(w.value),m=true;}m&&d.push({localName:"ind",attributes:u});let x=_e$1(s,"spacing"),y=Cr(x),b=false;for(let[g,A]of [["spaceBefore","before"],["spaceAfter","after"]]){let v=o[g];if(v===void 0)continue;let O=_e(v,g);if(!O.ok)return O;if(O.value<0)return {ok:false,detail:`${g}: out of range`};y[A]=String(O.value),b=true;}if(o.lineSpacing!==void 0){let g=_e(o.lineSpacing,"lineSpacing");if(!g.ok)return g;if(g.value<=0)return {ok:false,detail:"lineSpacing: out of range"};y.line=String(g.value),y.lineRule??="auto",b=true;}if(b&&d.push({localName:"spacing",attributes:y}),o.widowControl!==void 0){if(typeof o.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};d.push({localName:"widowControl",...o.widowControl?{}:{attributes:{val:"0"}}});}return d.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:Bg(zg(t,e),d)}}function Cr(t){let e=Object.create(null);if(!t)return e;for(let o of t.attributes)e[o.localName]=o.value;return e}function fn(t,e){if(e.subscript===void 0&&e.superscript===void 0)return [...t];let o=t.find(a=>a.localName==="vertAlign")?.attributes?.val,n=e.subscript===true?"subscript":e.superscript===true?"superscript":o==="subscript"&&e.subscript===false||o==="superscript"&&e.superscript===false?"baseline":o??"baseline";return Bg(t,[{localName:"vertAlign",attributes:{val:n}}])}function wr(t,e){let o=st(_e$1(t,"vertAlign"),"val");return o===null?null:o===e}function Fr(){let t=false,e=false,o=false,n=false;return {conflict(a){let s=Wt(a),d=an(a),c=a.op==="deleteComment",u=a.op==="updateFieldResult";return s&&(u&&t&&!n||n&&!u)?{message:"field result updates require a batch without other edits; sync document edits before updating fields",detail:a.op}:d&&t||e&&s?{message:"that command commits on its own and cannot share a batch",detail:a.op}:c&&t&&!o||o&&s&&!c?{message:"comment deletions may share a batch only with other comment deletions",detail:a.op}:null},note(a){Wt(a)&&(t=true,an(a)&&(e=true),a.op==="deleteComment"&&(o=true),a.op==="updateFieldResult"&&(n=true));},get hasCommands(){return t}}}var ci=256,Hr=1e4;function gn(t,e){if(t.kind!=="textValue"){for(let o of t.attributes)if(o.namespaceUri===da$2&&o.localName===e)return o.value}}function pi(t){return t.startsWith("_")}function yn(t){let e=new Map,o=[],n=new Set;for(let a of t.paragraphIds){let s=t.node(a);if(s?.kind!=="paragraph")continue;let d=cf(s),c=u=>{if(u.kind!=="textValue"){if(u.kind==="bookmarkStart"){if(o.length>=Hr||e.size>=Hr)return;let m=gn(u,"id"),x=gn(u,"name");if(m===void 0||x===void 0||x.length===0||x.length>ci||pi(x)||n.has(x)||e.has(m))return;let y=d.spanOf(u)?.start??0;e.set(m,{name:x,start:{paragraphId:a,offset:y}});return}if(u.kind==="bookmarkEnd"){let m=gn(u,"id");if(m===void 0)return;let x=e.get(m);if(!x)return;e.delete(m),n.add(x.name);let y=d.spanOf(u)?.start??0;o.push(Object.freeze({name:x.name,start:x.start,end:{paragraphId:a,offset:y}}));return}for(let m of u.children)c(m);}};for(let u of s.children)c(u);}return Object.freeze(o)}function hn(t,e){return yn(t).find(o=>o.name===e)??null}function Mr(t,e){let o=t.node(e);if(o?.kind!=="paragraph")return Object.freeze([]);let n=cf(o),a=[],s=(d,c)=>{if(!(d.kind==="textValue"||c>32)){if(Oc(d)){let u=n.spanOf(d);u&&a.push(Object.freeze({id:d.id,paragraphId:e,start:u.start,end:u.end}));return}for(let u of d.children)s(u,c+1);}};for(let d of o.children)s(d,0);return Object.freeze(a)}function jr(t,e,o){let n=Rc(o,a=>Hf(t,e,a));if(n.kind==="external")return n.href;if(n.kind==="internal"){let a=Pc(o);return a===void 0||a.length===0?null:`#${a}`}return null}function Dr(t,e,o,n,a){let s=Math.min(a?.limit??2e3,2e3),d=[],c=At(e,t),u=c.length-1;for(let[m,x]of c.entries()){if(s<=0)break;let y=t.projectedText(x,a?.projection??"allMarkup");if(!y)continue;let b=y.findOccurrences(n,s,{matchCase:a?.matchCase===true,wholeWord:a?.matchWholeWord===true,...m===0&&e?{from:y.projectedOffset(e.start.offset)}:{},...m===u&&e?{to:y.projectedOffset(e.end.offset)}:{}});for(let g of b.matches){if(m===0&&e&&g.rawStart<e.start.offset||m===u&&e&&g.rawEnd>e.end.offset)continue;let A=o.paragraph(x,t.story);d.push({start:{paragraph:A,offset:g.rawStart},end:{paragraph:A,offset:g.rawEnd}}),s-=1;}}return {ok:true,spans:d}}var mi={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function fi(t){return t.kind==="note"}function gi(t,e){return e.length===0?!fi(t.story):e.every(o=>t.has(o.start.paragraphId))}function yi(t){return Object.freeze(xa$1(t.part).filter(e=>gi(t,e.ranges)))}function kn(t){let e=[];for(let o of yi(t)){if(o.readOnly)continue;let n=o.structuralChanges?.length===1?o.structuralChanges[0]:void 0,a=o.revisionKind==="structural"?n==="rowInsert"?"Insert":n==="rowDelete"?"Delete":void 0:mi[o.revisionKind];a!==void 0&&e.push(Object.freeze({id:o.id,type:a,author:o.author,date:o.date??"",item:o}));}return Object.freeze(e)}function hi(t,e){let o=t;for(let n=0;o!==void 0&&n<=64;n+=1){if(o.parentId===void 0)return o.range!==null;o=e.get(o.parentId);}return false}var ki=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function Br(t,e){let o=t.parts.get(Z(t,e.part.name));if(!o)return ki;let n=t.parts.get(_(t,e.part.name)),a=ah(o),s=n?bh(n):new Map,d=_g(e.part).filter(y=>e.has(y.start.paragraphId)),c=ya(a,d,s),u=new Map(c.map(y=>[y.id,y])),m=c.filter(y=>hi(y,u)),x=new Map(m.map(y=>[y.id,y]));return Object.freeze({items:Object.freeze(m),roots:Object.freeze(m.filter(y=>y.parentId===void 0)),byId:y=>x.get(y)??null,textOf:y=>{let b=x.get(y);return b?ta$1(b.comment):""}})}var bi=/[\r\n\v\f\u2028\u2029]/;function We(t,e,o){return {code:t,message:e,detail:o}}function _r(t,e=false){if(typeof t.author!="string"||!t.author.trim()||!O(t.author))return We("unsupported-content","proposals need a non-empty XML-safe author","author");let o=t.op==="proposeInsertion";return !(t.op==="proposeDeletion")&&(typeof t.text!="string"||!e&&!t.text.length||bi.test(t.text)||!O(t.text))?We("unsupported-content","proposals need non-empty inline XML-safe text","text"):o&&t.where!=="Before"&&t.where!=="After"?We("unsupported-content","insertion needs Before or After","where"):null}function Vr(t,e,o,n){let a=xa$1(t.part),s=new Set;if(a.some(c=>c.revisionKind==="structural"))for(let c=Ia$1(t.part,e);c!==null&&(s.add(c.id),c.id!==t.root.id);c=Ia$1(t.part,c.id));return a.some(c=>{if(c.revisionKind==="structural"){let u=la$1(c),m=0;for(let x of u){let y=Ia$1(t.part,x),b=y&&Ia$1(t.part,y.id),g=b?.kind==="tableRow"?"trPr":b?.kind==="tableCell"?"tcPr":null;if(!(!b||!g||_e$1(b,g)?.id!==y?.id)){if(s.has(b.id))return true;m+=1;}}if(u.length>0&&m===u.length)return false}return c.ranges.some(u=>{let m=t.indexOf(u.start.paragraphId),x=t.indexOf(u.end.paragraphId),y=t.indexOf(e);if(m<0||x<0||y<m||y>x)return false;let b=y===m?u.start.offset:0,g=y===x?u.end.offset:1/0;return o<=g&&n>=b})})?We("unsupported-revision","proposal touches or overlaps a pending revision","span"):null}function Wr(t,e,o,n,a){let s=(N,K,C)=>({ok:false,error:{code:N,message:K,...C===void 0?{}:{detail:C}}}),d=N=>Nt(N,o),c=N=>({ok:true,kind:"query",value:N}),u=_r(t,e);if(u)return {ok:false,error:u};let m=t.op==="proposeInsertion",x=t.op==="proposeDeletion",y=z(t.span,o,n);if(!y.ok)return s(y.code,"that span is not a place",y.detail);let b=y.value;if(!b||b.start.paragraphId!==b.end.paragraphId)return s("unsupported-content","proposals require a single paragraph range","span");if(!e&&!m&&b.start.offset===b.end.offset)return s("unsupported-content","deletion and replacement need a non-empty range","span");let g=ot(t.span,o,n);if(!g.ok)return s(g.code,"that story is not a place",g.detail);let A=b.start.paragraphId,v=m&&t.where==="After"?b.end.offset:b.start.offset,O=m?v:b.end.offset;if(e&&!x&&v===O&&t.text==="")return c({kind:"span",span:d({start:b.start,end:b.start})});let w=Vr(g.value,A,v,O);if(w)return {ok:false,error:w};let L=a(g.value,A);if(L)return L;let H={author:t.author.trim(),date:new Date().toISOString()},j=[];return !m&&O>v&&j.push({op:"deleteText",paragraphId:A,start:v,end:O,revision:H}),!x&&t.text.length>0&&j.push({op:"insertText",paragraphId:A,offset:m?v:O,text:t.text,revision:H}),{ok:true,kind:"command",ops:j,story:g.value.story,answer:()=>{if(!e)return {kind:"applied"};let N={...b.start,offset:m?v:O};return {kind:"span",span:d({start:N,end:{...N,offset:N.offset+(x?0:t.text.length)}})}}}}function bn(t,e,o){if("body"in t){let n=at(t.body,"body",e,o);return n.ok?{ok:true,reads:n.value}:{ok:false,code:n.code,message:"that handle does not name a body",detail:n.detail}}return e.resolve(t.document,"document")?o.body?{ok:true,reads:o.body}:{ok:false,code:"document-unavailable",message:"this host holds no document"}:{ok:false,code:"invalid-handle",message:"that handle does not name a document",detail:"document"}}function xi(t,e){let o=t.op==="acceptAllRevisions",n=e.story.kind==="note"?{scopeRootId:e.root.id}:{};return [o?{op:"acceptAllRevisions",...n}:{op:"rejectAllRevisions",...n}]}function Ai(t,e,o){let n=bn({op:"acceptAllRevisions",body:t.body},e,o);if(!n.ok)return n;if(!["accept","reject"].includes(t.action)||t.revisions!==void 0&&!Array.isArray(t.revisions))return {ok:false,code:"unsupported-content",message:"invalid revision batch"};let a=t.revisions===void 0?void 0:[];for(let d of t.revisions??[]){let c=e.resolve(d,"revision");if(!c||c.kind!=="revision"||G(c.story)!==G(n.reads.story))return {ok:false,code:"invalid-handle",message:"revision does not belong to this story"};a.push(`revision-${c.revisionId}`);}let s=Ja$1(n.reads.part,t.action,a,n.reads.story.kind==="note"?n.reads.root:void 0);return {ok:true,reads:n.reads,...s}}function vi(t,e,o,n){let a=bn({op:"acceptAllRevisions",body:t},o,n);if(!a.ok)throw new Error("resolved story disappeared");let{part:s,root:d,story:c}=a.reads,u=xa$1(c.kind==="note"&&d.kind!=="textValue"?{...s,root:d}:s).length;return {kind:"revisionBatch",result:{...e,remaining:u}}}function Ur(t,e,o,n){if(t.op==="resolveRevisionBatch"){let d=Ai(t,e,o);if(!d.ok)return {ok:false,error:{code:d.code,message:d.message}};let c=n(d.reads);return c||{ok:true,kind:"command",story:d.reads.story,ops:d.ops,answer:u=>vi(t.body,d.result,e,u)}}let a=bn(t,e,o);if(!a.ok)return {ok:false,error:{code:a.code,message:a.message,detail:a.detail}};let s=n(a.reads);return s||{ok:true,kind:"command",story:a.reads.story,ops:xi(t,a.reads),answer:()=>({kind:"applied"})}}function $r(t,e,o){if(e.revisionKind==="structural"||ji(t.root).length>0||e.revisionKind==="format"&&la$1(e).length>1){let n=Ja$1(t.part,o,[ma(e)],t.story.kind==="note"?t.root:void 0);return n.result.skipped.length?[]:n.ops}return e.addresses.map(n=>({op:o==="accept"?"acceptRevision":"rejectRevision",revision:n}))}var Ii=/[\r\n\u2028\u2029]/u,zr=Object.freeze({kind:"applied"});function ne(t,e,o){return {ok:false,error:Object.freeze(o===void 0?{code:t,message:e}:{code:t,message:e,detail:o})}}function xn(t,e){return ne("unsupported-content",t==="author"?"a comment records who wrote it":t==="date"?"a comment date must be a valid ISO-8601 instant":e==="reply"?"a reply says something":"a comment says something",t)}function An(t){return R(t.author)?xn("author",t.kind):S(t.text)?xn("text",t.kind):typeof t.text=="string"&&Ii.test(t.text)?ne("unsupported-content",t.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):U(t.date)?xn("date",t.kind):null}function vn(t){if(t===void 0)return;let e=T(t);return e.ok?e.value:void 0}function Kr(t,e){let o=Ha$1(t.part,e);for(;o;){if(o.kind==="tableCell"||o.kind!=="textValue"&&o.namespaceUri===da$2&&o.localName==="tc")return o.id;o=Ia$1(t.part,o.id);}return null}function Gr(t,e,o,n){let a=An({author:t.author,text:t.text,date:t.date,kind:"comment"});if(a)return a;let s=z(t.span,e,o);if(!s.ok)return ne(s.code,"that span is not a place",s.detail);if(s.value===null)return ne("invalid-handle","an empty story has no comment anchor");let d=ot(t.span,e,o);if(!d.ok)return ne(d.code,"that span is not a place",d.detail);let c=s.value;if(Kr(d.value,c.start.paragraphId)!==Kr(d.value,c.end.paragraphId))return ne("unsupported-content","a comment range cannot cross a table-cell boundary");let u=n(d.value);if(u)return u;let m=vn(t.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:c.start.paragraphId,start:c.start.offset,end:c.end.offset,...c.end.paragraphId===c.start.paragraphId?{}:{endParagraphId:c.end.paragraphId}},text:t.text,author:t.author,...m===void 0?{}:{date:m}},story:d.value.story,answer:(y,b)=>b===void 0?zr:{kind:"handle",handle:e.comment(b,d.value.story)}}}function Xr(t,e,o){let n=o(e);if(n)return n;let a=e.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:t.id,...t.parentId===void 0?{}:{parentCommentId:t.parentId},...a.kind==="note"?{noteId:a.noteId}:{}},story:a,answer:()=>zr}}var Pi=1e4;function Yr(t,e){let o=[],n=e.kind==="contentControl"?ub(e):e;if(!n)return o;for(let a of yb(n))if(!(a.ancestors.length>0)){if(o.length>=Pi)break;o.push(ta(t,a.node));}return o}function Jr(t,e){for(let o of yb(t.root))if(o.node.id===e)return ta(t,o.node);return null}function Qr(t,e){for(let o of yb(t.root))if(o.node.id===e)return o.node;return null}function Zr(t,e){for(let o of t.paragraphIds){let n=t.node(o);if(!(!n||n.kind!=="paragraph")&&yb(n).some(a=>a.node.id===e))return n}return null}function Ue(t,e){let o=ea(e);if(o.length>0){let s=o[0],d=o[o.length-1],c=t.rawText(d);return c===null||!t.has(s)?null:{start:{paragraphId:s,offset:0},end:{paragraphId:d,offset:c.length}}}let n=Zr(t,e.id);if(!n)return null;let a=cf(n).spanOf(e);return a?{start:{paragraphId:n.id,offset:a.start},end:{paragraphId:n.id,offset:a.end}}:null}function Oi(t,e,o){let n=Zr(t,e.id),a=ub(e);if(!n||!a)return null;let s={...n,children:a.children},d=Bi$1(s);return Ne(s,d,o).text}function qr(t,e,o="allMarkup"){if(o==="allMarkup")return Ab(e);let n=Oi(t,e,o);if(n!==null)return n;let a=Ue(t,e);if(!a)return "";let s=t.indexOf(a.start.paragraphId),d=t.indexOf(a.end.paragraphId);if(s<0||d<s)return "";let c=[];for(let u=s;u<=d;u+=1){let m=t.paragraphIds[u],x=t.projectedText(m,o),y=t.rawText(m);if(!x||y===null)return "";c.push(x.sliceRaw(u===s?a.start.offset:0,u===d?a.end.offset:y.length));}return c.join("\r")}function ta(t,e){return {nodeId:e.id,properties:wb(e),lock:Ri$1(t.part,e.id),paragraphIds:ea(e)}}function ea(t){let e=ub(t);if(!e)return [];let o=[];return pc(e.children,o,0),o.map(n=>n.id)}function ge(t){let e=t.kind==="contentControl"?ub(t):t;return e?yb(e).map(o=>o.node):[]}var na=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),oa=new Set(["whole","content","start","end","before","after"]),ra=new Set(["richText","plainText","dropDownList","comboBox","date"]),Ri=4096;function aa(t){let e=(a,s)=>({ok:false,code:"unsupported-content",message:a,detail:s});if(typeof t!="object"||t===null||!("kind"in t))return e("a control value states its kind","value");let o=t,n=o.kind;if(n==="text"||n==="listItem"){let a=n==="text"?o.text:o.value;return typeof a!="string"?e("that value is not a string",String(n)):a.length>Ri?e("that value is too long",String(a.length)):{ok:true,value:n==="text"?{kind:"text",text:a}:{kind:"listItem",value:a}}}if(n==="checkbox"){let a=o.checked;return typeof a!="boolean"?e("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:a}}}if(n==="date"){let a=o.iso;return typeof a!="string"?e("a date is an ISO-8601 string","iso"):a.length>64?e("that is not a date",String(a.length)):{ok:true,value:{kind:"date",iso:a}}}return e("that is not a value any control accepts",String(n))}var Si=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),Ci=4096,ia=64;function sa(t){if(t===void 0)return {ok:true,value:null};if(typeof t!="object"||t===null)return {ok:false,field:"payload"};let e=t;for(let o of ["namespaceUri","rootLocalName","nodeId"]){let n=e[o];if(typeof n!="string"||n.length===0||n.length>Ci)return {ok:false,field:o}}return typeof e.label!="string"||e.label.length>da$1?{ok:false,field:"label"}:typeof e.data!="string"||e.data.length===0||e.data.length>ca?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:e.namespaceUri,rootLocalName:e.rootLocalName,nodeId:e.nodeId,label:e.label,data:e.data}}}function la(t){let e=t.at!==void 0,o=t.span!==void 0;return e===o?{message:"a custom node goes at a position or over a span, not both",detail:e?"at+span":"no-place"}:typeof t.tag!="string"||t.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:t.tag.length>ia?{message:`w:tag caps at ${String(ia)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof t.text!="string"||t.text.length===0?{message:"a custom node shows some text",detail:"text"}:t.lock!==void 0&&!Si.has(t.lock)?{message:"that is not a lock",detail:String(t.lock)}:null}function da(t,e,o,n){return {paragraphId:e.paragraphId,offset:e.offset,...o.offset>e.offset?{replaceUntil:o.offset}:{},tag:t.tag,text:t.text,...t.title===void 0?{}:{alias:t.title},...t.lock===void 0||t.lock==="unlocked"?{}:{lock:t.lock},...n===null?{}:{payload:n}}}function ua(t,e,o){if(t.span){let a=z(t.span,e,o);return a.ok?a.value?a.value.start.paragraphId!==a.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:a.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:a.code,message:"that span is not a place",detail:a.detail}}let n=te(t.at,e,o);return n.ok?{range:{start:n.value,end:n.value}}:{code:n.code,message:"that is not a place",detail:n.detail}}var ye=/[\r\n\v\f\u2028\u2029]/,wi=16,Ti=64;function Ni(t,e,o){return Object.freeze(o===void 0?{code:t,message:e}:{code:t,message:e,detail:o})}function f(t,e,o){return {ok:false,error:Ni(t,e,o)}}var et=Object.freeze({kind:"applied"});function E(t){return {ok:true,kind:"query",value:t}}function In(t){let{runPropertyEdits:e,mergedParagraphMarkProperties:o}=Yo(()=>t.reads.package?Ac(t.reads.package)?.root??null:null,()=>t.reads.package?Sf(t.reads.package)?.root??null:null,()=>t.displayMode??"proposed"),{handles:n,capabilities:a}=t,s=t.reads,d=new Map,c=new Map,u=i=>{let p=`${G(i.story)}:${i.root.id}`,h=d.get(p);if(h)return h;let I=new Map,R=i.paragraphIds.map(l=>{let k={id:l};return I.set(l,k),k}),r={externalCreatedCount:0,reads:i,order:R,slotById:I,created:[],restructured:new Set,touched:new Set,textEdits:new He,formatted:new Set,selected:new Set,retargets:[]};return d.set(p,r),r},m=[],x=Fr(),y=false,b=null,g=i=>b===null?(b=i,null):b===i?null:f("conflicting-operations","one batch writes into one story",`${G(b.reads.story)} then ${G(i.reads.story)}`),A=i=>g(u(i)),v=i=>{let p=s.package;return p===null?null:Br(p,i)},O$1=i=>{let p=n.resolve(i,"comment");if(!p||p.kind!=="comment")return {ok:false,planned:f("invalid-handle","that handle does not name a comment","comment")};let h=s.story(p.story);if(!h)return {ok:false,planned:f("invalid-handle","that story is not in this document")};let R=v(h)?.byId(p.commentId)??null;return R?{ok:true,reads:h,item:R}:{ok:false,planned:f("invalid-handle","this document no longer holds that comment",p.commentId)}},w=i=>{let p=n.resolve(i,"revision");if(!p||p.kind!=="revision")return {ok:false,planned:f("invalid-handle","that handle does not name a tracked change","revision")};let h=s.story(p.story);if(!h)return {ok:false,planned:f("invalid-handle","that story is not in this document")};let I=kn(h).find(R=>R.id===p.revisionId)??null;return I?{ok:true,reads:h,item:I}:{ok:false,planned:f("invalid-handle","this document no longer holds that tracked change",p.revisionId)}},L=(i,p)=>{let h=i.rawText(p.start.paragraphId),I=i.rawText(p.end.paragraphId);if(h===null||I===null)return null;let R={story:i.story,paragraphId:p.start.paragraphId,index:i.indexOf(p.start.paragraphId),offset:Math.min(p.start.offset,h.length)},r={story:i.story,paragraphId:p.end.paragraphId,index:i.indexOf(p.end.paragraphId),offset:Math.min(p.end.offset,I.length)};return X({start:R,end:r})},H=(i,p)=>i.order.indexOf(p),j=(i,p)=>i.selected.has(p)?f("conflicting-operations","this batch selects a paragraph it also edits",p):null,N=(i,p)=>{let h=j(i,p);return h||(i.restructured.has(p)||i.touched.has(p)?f("conflicting-operations","another operation in this batch already changes that paragraph",p):(i.restructured.add(p),i.touched.add(p),null))},K=(i,p)=>{let h=j(i,p);return h||(i.restructured.has(p)||i.textEdits.has(p)?f("conflicting-operations","another operation in this batch restructures that paragraph",p):(i.touched.add(p),null))},C=(i,p,h)=>{let I=`${h}:${p}`;if(i.formatted.has(I))return f("conflicting-operations","another operation in this batch already writes that formatting",p);let R=K(i,p);return R||(i.formatted.add(I),null)},W=(i,p)=>{let h={id:null};return i.order.splice(p,0,h),i.created.push(h),h},X=i=>Nt(i,n),Z=i=>i===null?null:s.story(i.start.story),D=i=>i===void 0||i==="allMarkup"||i==="original"||i==="model",nt=(i,p,h,I)=>{if(!D(I?.projection))return f("unsupported-content","unknown text projection","projection");if(I?.matchWildcards===true)return f("unsupported-capability","wildcard search is not implemented","matchWildcards");if(I?.ignorePunct===true)return f("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(I?.ignoreSpace===true)return f("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!Ga$1(h))return f("unsupported-content","that is not a query this host will scan for","text");let R=I?.limit;if(R!==void 0&&(!Number.isInteger(R)||R<0))return f("invalid-offset","limit must be a non-negative integer",String(R));let r=Dr(i,p,n,h,I);return E({kind:"spans",spans:r.spans})},rt=(i,p,h,I=false)=>{let R=p.start.paragraphId,r=i.textEdits.has(R)?j(i,R):i.touched.has(R)?f("conflicting-operations","text edits cannot share a paragraph with other edits",R):K(i,R);return r||Zo(i.textEdits,p,h,n,I)},ct=(i,p,h,I=false)=>{if(typeof h!="string"||ye.test(h))return f("unsupported-content","insertText needs text without paragraph marks","text");let R=g(i);if(R)return R;let r=t.replacementLanding?.(p.paragraphId,p.offset,p.offset)!=null,l=!r&&Qo(i.reads.part,p.paragraphId,p.offset,h);if(l)return l;if(!r&&dn(i.reads.part,p.paragraphId,p.offset))return rt(i,{start:p,end:p},h,I);let k=N(i,p.paragraphId);return k||{ok:true,kind:"command",ops:h.length?[{op:"insertText",paragraphId:p.paragraphId,offset:p.offset,text:h}]:[],story:i.reads.story,answer:()=>({kind:"span",span:X({start:p,end:{...p,offset:p.offset+h.length}})})}},Mt=(i,p,h)=>{let I=i.reads;if(typeof h!="string")return f("unsupported-content","replaceSpan needs text","text");if(ye.test(h))return f("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let R=At(p,I),r=p.start.paragraphId,l=[],k=g(i);if(k)return k;let P=R.length===1?p.end.offset:(I.rawText(r)??"").length,S=t.replacementLanding?.(r,p.start.offset,P);if(R.length===1&&S==null&&dn(I.part,r,p.start.offset))return rt(i,p,h);if(R.length===1){let Y=N(i,r);if(Y)return Y;if(S==null)return tr(I.part,p,h,n);p.end.offset>p.start.offset&&l.push({op:"deleteText",paragraphId:r,start:p.start.offset,end:p.end.offset});}else {for(let M of R){let _=N(i,M);if(_)return _}let Y=p.end.paragraphId,U=(I.rawText(r)??"").length;p.start.offset<U&&l.push({op:"deleteText",paragraphId:r,start:p.start.offset,end:U}),p.end.offset>0&&l.push({op:"deleteText",paragraphId:Y,start:0,end:p.end.offset});for(let M of R.slice(1,-1))l.push({op:"deleteBlock",blockId:M});l.push({op:"joinParagraphs",firstId:r,secondId:Y});for(let M of R.slice(1)){let _=i.slotById.get(M);_&&i.order.splice(H(i,_),1);}}let T=S??p.start.offset;h.length>0&&l.push({op:"insertText",paragraphId:r,offset:T,text:h});let F={...p.start,paragraphId:r,offset:T},$=()=>({kind:"span",span:X({start:F,end:{...F,offset:F.offset+h.length}})});return {ok:true,kind:"command",ops:l,story:i.reads.story,answer:$}},jt=(i,p)=>{let h=i.reads;if(typeof p!="string")return f("unsupported-content","replaceSpan needs text","text");if(ye.test(p))return f("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let I=h.blocks,R=I.filter(M=>M.removable),r=I.filter(M=>!M.removable).flatMap(M=>M.paragraphIds),l=r.length===0?R.find(M=>M.kind==="paragraph"):void 0;if(!l&&r.length===0)return f("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let k=g(i);if(k)return k;for(let M of h.paragraphIds){let _=N(i,M);if(_)return _}let P=[],S=(l?[l.id]:[...r]).sort((M,_)=>h.indexOf(M)-h.indexOf(_)),T=S[0],F=(h.rawText(T)??"").length;for(let M of S){let _=(h.rawText(M)??"").length;_>0&&P.push({op:"deleteText",paragraphId:M,start:0,end:_});}for(let M of R)M.id!==l?.id&&P.push({op:"deleteBlock",blockId:M.id});let $=t.replacementLanding?.(T,0,F)??0;p.length>0&&P.push({op:"insertText",paragraphId:T,offset:$,text:p});for(let M of R)if(M.id!==l?.id)for(let _ of M.paragraphIds){let kt=i.slotById.get(_);kt&&i.order.splice(H(i,kt),1);}let Y={story:h.story,paragraphId:T,index:h.indexOf(T),offset:$},U=()=>({kind:"span",span:X({start:Y,end:{...Y,offset:$+p.length}})});return {ok:true,kind:"command",ops:P,story:h.story,answer:U}},oe=(i,p)=>{if(!Array.isArray(p)||p.length<1||p.length>1e4||p.some(I=>typeof I!="string"||ye.test(I)||!O(I)))return f("unsupported-content","replaceStoryBlocks needs 1-10000 valid XML text strings without paragraph marks","paragraphs");let h=g(i);if(h)return h;for(let I of i.reads.paragraphIds){let R=N(i,I);if(R)return R}i.order.splice(0,i.order.length);for(let I=0;I<p.length;I+=1)W(i,I);return {ok:true,kind:"command",ops:[{op:"replaceStoryBlocks",storyRootId:i.reads.root.id,paragraphs:p}],story:i.reads.story,answer:()=>et}},B=(i,p,h,I)=>{let R=i.reads;if(typeof I!="string")return f("unsupported-content","insertParagraph needs text","text");if(ye.test(I))return f("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let r=g(i);if(r)return r;let l=N(i,p.paragraphId);if(l)return l;let k=i.slotById.get(p.paragraphId);if(!k)return f("invalid-handle","that paragraph is not in the body");let P=(R.rawText(p.paragraphId)??"").length,S=[];h==="after"?(I.length>0&&S.push({op:"insertText",paragraphId:p.paragraphId,offset:P,text:I}),S.push({op:"splitParagraph",paragraphId:p.paragraphId,offset:P})):(I.length>0&&S.push({op:"insertText",paragraphId:p.paragraphId,offset:0,text:I}),S.push({op:"splitParagraph",paragraphId:p.paragraphId,offset:I.length}));let T=W(i,H(i,k)+1);h==="before"&&i.retargets.push({from:p.paragraphId,slot:T});let F=()=>{let $=h==="after"?T.id:p.paragraphId;return $===null?et:{kind:"handle",handle:n.paragraph($,R.story)}};return {ok:true,kind:"command",ops:S,story:R.story,answer:F}},Pt=(i,p,h,I,R)=>{let r=i.reads;if(!Array.isArray(h)||h.length===0)return f("unsupported-content","split needs at least one delimiter","delimiters");if(h.length>wi)return f("unsupported-content","too many delimiters",String(h.length));for(let _ of h){if(typeof _!="string"||_.length===0)return f("unsupported-content","a delimiter must be a non-empty string","delimiters");if(_.length>Ti)return f("unsupported-content","that delimiter is too long","delimiters")}let l=g(i);if(l)return l;let k=N(i,p.paragraphId);if(k)return k;let P=i.slotById.get(p.paragraphId);if(!P)return f("invalid-handle","that paragraph is not in the body");let S=r.rawText(p.paragraphId)??"",T=nr(S,h),F=[],$=[],Y=[];if(T.length===0)Y.push(S);else if(I){for(let lt of [...T].reverse())F.push({op:"deleteText",paragraphId:p.paragraphId,start:lt.start,end:lt.start+lt.length});let _=0,kt=0;for(let lt of T){let ze=lt.start-_;$.push(ze),Y.push(S.slice(kt,lt.start)),kt=lt.start+lt.length,_+=lt.length;}Y.push(S.slice(kt));}else {let _=0;for(let kt of T){let lt=kt.start+kt.length;$.push(lt),Y.push(S.slice(_,lt)),_=lt;}Y.push(S.slice(_));}$.length>0&&F.push({op:"splitParagraphMany",paragraphId:p.paragraphId,offsets:$});let U=[P];for(let _=0;_<$.length;_+=1)U.push(W(i,H(i,P)+1+_));let M=_=>{let kt=_.story(r.story),lt=[];return U.forEach((ze,ya)=>{let Ge=ze.id;if(Ge===null)return;let Xe=kt?.rawText(Ge)??Y[ya]??"",[ha,ka]=R?ar(Xe,0,Xe.length):[0,Xe.length],Sn=n.paragraph(Ge,r.story);lt.push({start:{paragraph:Sn,offset:ha},end:{paragraph:Sn,offset:ka}});}),{kind:"spans",spans:lt}};return {ok:true,kind:"command",ops:F,story:r.story,answer:M}},ht=(i,p)=>{let h=g(i);if(h)return h;let I=N(i,p.paragraphId);if(I)return I;let R=i.slotById.get(p.paragraphId);return R&&i.order.splice(H(i,R),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:p.paragraphId}],story:i.reads.story,answer:()=>et}},tt=(i,p,h)=>{let I=i.reads,R=I.part,r=g(i);if(r)return r;let l=Er(h??{});if(!l.ok)return f("unsupported-content","that is not formatting this host writes",l.detail);let k=[];for(let P of Ut(p,I)){if(P.end<=P.start&&!P.whole)continue;let S=C(i,P.paragraphId,"runs");if(S)return S;for(let T of e(R,P.paragraphId,P.start,P.end,l.value.filter(F=>F.localName!=="vertAlign"),t.displayMode))k.push({op:"setRunProperties",paragraphId:P.paragraphId,start:T.start,end:T.end,properties:fn(T.properties,h),...T.targetRunIds?{targetRunIds:T.targetRunIds}:{}});P.whole&&k.push({op:"setParagraphMarkProperties",paragraphId:P.paragraphId,properties:fn(o(R,P.paragraphId,l.value.filter(T=>T.localName!=="vertAlign")),h)});}return k.length===0?f("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:k,story:I.story,answer:()=>et}},gt=(i,p,h)=>{let I=i.reads,R=I.part,r=g(i);if(r)return r;let l=Te(h,I.styles());if(!l.ok)return f("unsupported-content","that is not a style this document has",l.detail);let k={localName:"pStyle",attributes:{val:l.styleId}},P=[];for(let S of At(p,I)){let T=C(i,S,"paragraph");if(T)return T;P.push({op:"setParagraphProperties",paragraphId:S,properties:Bg(zg(R,S),k)});}return P.length===0?f("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:P,story:I.story,answer:()=>et}},q=(i,p,h)=>{let I=i.reads,R=I.part,r=g(i);if(r)return r;let l=Lr(R,p.paragraphId,h??{},I.styles());if(!l.ok)return f("unsupported-content","that is not paragraph formatting this host writes",l.detail);let k=C(i,p.paragraphId,"paragraph");return k||{ok:true,kind:"command",ops:[{op:"setParagraphProperties",paragraphId:p.paragraphId,properties:l.value}],story:I.story,answer:()=>et}},Et=(i,p)=>{let h=s.body;if(!h)return f("document-unavailable","this host holds no document right now");let I=s.sections();if(!I[i])return f("invalid-handle","that section is not in this document");let r=Mo(p);if(!r.ok)return f("unsupported-content",r.reason,r.detail);let l=or(h,I,i);if(l===null)return f("unsupported-content","that section holds no paragraph to address it by","no-anchor");let k=u(h),P=g(k);return P||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...r.value,anchorParagraphId:l}],story:Ht,answer:()=>et}},ca=(i,p)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:i,noteId:p}],story:Ht,lifecycle:true,answer:()=>et}),$e=i=>{let p=n.resolve(i,"list");if(!p||p.kind!=="list")return f("invalid-handle","that handle does not name a list","list");let h=s.story(p.story);if(!h)return f("invalid-handle","that story is not in this document");let I=Kt(h).find(R=>R.numId===p.numId);return I?{ok:true,plan:u(h),list:I}:f("invalid-handle","this story numbers nothing with that list",p.numId)},Ke=i=>{if(typeof i!="object"||i===null)return f("invalid-handle","that is not a scope a control lives in","scope");let p=i;if("body"in i){let h=at(p.body,"body",n,s);return h.ok?{reads:h.value,node:h.value.root}:f(h.code,"that handle does not name a body",h.detail)}if("contentControl"in i){let h=Ot(p.contentControl);return "control"in h?{reads:h.reads,node:h.node}:h}return f("invalid-handle","that is not a scope a control lives in","scope")},Ot=i=>{let p=n.resolve(i,"contentControl");if(!p||p.kind!=="contentControl")return f("invalid-handle","that handle does not name a content control","contentControl");let h=s.story(p.story);if(!h)return f("invalid-handle","that story is not in this document");let I=Jr(h,p.nodeId),R=Qr(h,p.nodeId);return !I||!R?f("invalid-handle","this document no longer holds that content control"):{reads:h,control:I,node:R}},pa=(i,p,h)=>{if(!Number.isInteger(h)||h<0||h>ee)return f("invalid-offset",`a list level is 0 to ${String(ee)}`,String(h));let I=fe(i.reads,p);if(!I)return f("unsupported-content","that paragraph is not in a list",p);if(!s.package||!me(s.package,I.numId,h))return f("unsupported-content","list level is not defined; configure that level first",p);let R=g(i);if(R)return R;let r=C(i,p,"paragraph");return r||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:p,level:h}],story:i.reads.story,answer:()=>et}},ma=(i,p,h,I)=>{if(h!=="start"&&h!=="end")return f("unknown-operation","a list takes an item at its start or its end",String(h));let R=i.reads,r=h==="start"?p.paragraphIds[0]:p.paragraphIds[p.paragraphIds.length-1];if(r===void 0)return f("invalid-handle","that list holds no paragraph");let l={story:R.story,paragraphId:r,index:R.indexOf(r)};return B(i,l,h==="start"?"before":"after",I)},Pn=(i,p)=>{if(p.start.paragraphId!==p.end.paragraphId)return null;for(let h of Mr(i,p.start.paragraphId))if(h.start<=p.start.offset&&h.end>=p.end.offset)return h;return null},fa=(i,p,h)=>{if(typeof h!="string")return f("unsupported-content","a hyperlink target is a string","target");let I=i.reads,R=Pn(I,p),r=p.start.paragraphId===p.end.paragraphId&&p.start.offset===p.end.offset,l=R&&(p.start.offset!==R.start||p.end.offset!==R.end),k=l?{range:{start:p.start.offset,end:p.end.offset}}:{};if(l){let U=I.node(R.paragraphId),M=U?.kind==="paragraph"?U.children.find(_=>_.id===R.id):void 0;if(r||!M||!$h(M)||U?.kind!=="paragraph"||!U.children.some(_=>_.id===R.id))return f("unsupported-capability","partial hyperlink edits require ordinary text in a paragraph")}if(h.length===0){if(!R)return f("unsupported-content","that text is not a link","no-link");let U=g(i);if(U)return U;let M=K(i,R.paragraphId);return M||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:R.id,...k}],story:I.story,answer:()=>et}}let P={},S=null;if(h.startsWith("#")){let U=h.slice(1);if(U.length===0||!hn(I,U))return f("unsupported-content","this document declares no such bookmark",h);P={anchor:U};}else {if(Ff(h)===null)return f("unsupported-content","this engine will not author that target","target");S=h;}let T=g(i);if(T)return T;let F=U=>S===null?{ok:true,kind:"command",ops:[U(P)],story:I.story,answer:()=>et}:{ok:true,kind:"command",ops:[],relate:{url:S,ops:M=>[U({relationshipId:M})]},story:I.story,answer:()=>et};if(R){let U=K(i,R.paragraphId);return U||F(M=>({op:"setHyperlinkTarget",linkId:R.id,...k,...M}))}if(r)return f("unsupported-content","a link with no text has nothing to click","collapsed");if(p.start.paragraphId!==p.end.paragraphId)return f("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let $=K(i,p.start.paragraphId);if($)return $;let Y=I.styles().idOf("hyperlink");return F(U=>({op:"insertHyperlink",paragraphId:p.start.paragraphId,start:p.start.offset,end:p.end.offset,...U,...Y===null?{}:{styleId:Y}}))},On=(i,p,h)=>{let I=i.reads;if(!a.selection||!t.select)return f("unsupported-capability","this host has no reader to move","selection");if(h!=="select"&&h!=="start"&&h!=="end")return f("unknown-operation","that is not a selection mode",String(h));let R=At(p,I);for(let r of R)if(i.touched.has(r))return f("conflicting-operations","this batch edits a paragraph the selection covers",r);for(let r of R)i.selected.add(r);return m.push({range:p,mode:h}),{ok:true,kind:"command",ops:[],story:I.story,answer:()=>et}},Rn=i=>{let p=n.resolve(i,"bookmark");if(!p||p.kind!=="bookmark")return f("invalid-handle","that handle does not name a bookmark","bookmark");let h=s.story(p.story);if(!h)return f("invalid-handle","that story is not in this document");let I=hn(h,p.name);if(!I)return f("invalid-handle","this document no longer declares that bookmark",p.name);let R=r=>({story:h.story,paragraphId:r.paragraphId,index:h.indexOf(r.paragraphId),offset:r.offset});return {reads:h,range:{start:R(I.start),end:R(I.end)}}},ga=(i,p)=>{let h=pr(i,t,r=>In({...t,reads:r}));if(h)return p&&h.ok&&h.kind==="command"?f("unsupported-content","header/footer creation cannot be tracked"):h;let I=ur(i,{handles:n,reads:s,admitWrite:(r,l,k)=>{let P=u(r),S=g(P);if(S)return S;for(let T of k){let F=N(P,T);if(F)return F}return P.externalCreatedCount+=l,null}});if(I)return I;let R=p!==void 0;switch(R&&i.op==="insertText"?i={op:"proposeInsertion",span:{start:i.at,end:i.at},text:i.text,where:"Before",author:p}:R&&i.op==="replaceSpan"&&(i={op:"proposeReplacement",span:i.span,text:i.text,author:p}),i.op){case "getFields":case "getField":case "setFieldCode":case "deleteField":case "updateFieldResult":case "insertField":return sr(i,n,s,(r,l,k)=>{let P=u(r);return g(P)??(k?null:N(P,l))},t.fieldPageContext);case "getInlinePictures":case "getInlinePicture":case "setInlinePicture":case "deleteInlinePicture":case "insertInlinePicture":return kr(i,n,s,(r,l)=>{let k=u(r);return g(k)??N(k,l)});case "insertBreak":return br(i,n,s,(r,l,k)=>{let P=u(r),S=g(P)??N(P,l);return S||(P.externalCreatedCount+=k),S});case "startNewList":case "attachToList":case "detachFromList":case "setListLevelFormat":return Ir(i,n,s,(r,l,k)=>{let P=u(r);return g(P)??C(P,l,k?`list:${k.numId}:${k.level}`:"paragraph")});case "getDocument":return E({kind:"handle",handle:n.document()});case "getBody":return n.resolve(i.document,"document")?s.body?E({kind:"handle",handle:n.body(Ht)}):f("document-unavailable","this host holds no document right now"):f("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let r=at(i.body,"body",n,s);return r.ok?E({kind:"handles",handles:r.value.paragraphIds.map(l=>n.paragraph(l,r.value.story))}):f(r.code,"that handle does not name a body",r.detail)}case "getRange":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);if(!r.value)return f("invalid-offset","empty story");if(!["Whole","Content","Start","End"].includes(i.location))return f("unsupported-content","unsupported range location");let l=r.value,k=i.location==="Start"?{start:l.start,end:l.start}:i.location==="End"?{start:l.end,end:l.end}:l;return E({kind:"span",span:Nt(k,n)})}case "getSpanParagraphs":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);let l=ot(i.span,n,s);return l.ok?E({kind:"handles",handles:At(r.value,l.value).map(k=>n.paragraph(k,l.value.story))}):f(l.code,"that span is not a place",l.detail)}case "getText":{if(!D(i.projection))return f("unsupported-content","unknown text projection","projection");if(n.resolve(i.target,"body")){let P=at(i.target,"body",n,s);return P.ok?E({kind:"text",text:P.value.text(i.projection??"allMarkup")}):f(P.code,"that handle does not name a body",P.detail)}let l=pt(i.target,n,s);if(!l.ok)return f(l.code,"that handle does not name a body or a paragraph",l.detail);let k=s.story(l.value.story);return E({kind:"text",text:k?.paragraphText(l.value.paragraphId,i.projection??"allMarkup")??""})}case "getSpanText":{if(!D(i.projection))return f("unsupported-content","unknown text projection","projection");let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);let l=ot(i.span,n,s);return l.ok?E({kind:"text",text:Jo(r.value,l.value,sn,i.projection??"allMarkup")}):f(l.code,"that span is not a place",l.detail)}case "getParagraphId":{let r=pt(i.paragraph,n,s);if(!r.ok)return f(r.code,"that handle does not name a paragraph",r.detail);let k=s.story(r.value.story)?.paragraph(r.value.paragraphId);return E({kind:"text",text:k?.paraId??""})}case "search":{let r=z(i.scope,n,s);if(!r.ok)return f(r.code,"that is not a scope to search",r.detail);let l=ot(i.scope,n,s);return l.ok?nt(l.value,r.value,i.text,i.options):f(l.code,"that is not a scope to search",l.detail)}case "proposeInsertion":case "proposeDeletion":case "proposeReplacement":return Wr(i,R,n,s,(r,l)=>{let k=u(r);return g(k)??N(k,l)});case "insertText":{let r=te(i.at,n,s);if(!r.ok)return f(r.code,"that is not a place to insert at",r.detail);let l=s.story(r.value.story);return l?ct(u(l),r.value,i.text,"at"in i.at&&i.at.at==="start"):f("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in i.span){let k=at(i.span.body,"body",n,s);return k.ok?jt(u(k.value),i.text):f(k.code,"that handle does not name a body",k.detail)}let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);if(!r.value)return f("invalid-offset","that story holds no paragraph to write into","empty-story");let l=Z(r.value);return l?Mt(u(l),r.value,i.text):f("invalid-handle","that story is not in this document")}case "replaceStoryBlocks":{let r=at(i.body,"body",n,s);return r.ok?oe(u(r.value),i.paragraphs):f(r.code,"that handle does not name a body",r.detail)}case "insertParagraph":{let r=Fe(i.anchor,n,s);if(!r.ok)return f(r.code,"that is not a paragraph to insert beside",r.detail);if(i.where!=="before"&&i.where!=="after")return f("unknown-operation","that is not a place to insert",String(i.where));let l=s.story(r.value.story);return l?B(u(l),r.value,i.where,i.text):f("invalid-handle","that story is not in this document")}case "splitParagraph":{let r=pt(i.paragraph,n,s);if(!r.ok)return f(r.code,"that handle does not name a paragraph",r.detail);let l=s.story(r.value.story);return l?Pt(u(l),r.value,i.delimiters,i.trimDelimiters===true,i.trimSpacing===true):f("invalid-handle","that story is not in this document")}case "getFont":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);let l=ot(i.span,n,s);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let k=Ut(r.value,l.value);return E({kind:"font",font:Tr(l.value.part,k,t.displayMode)})}case "setFont":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);if(!r.value)return f("invalid-offset","that story holds no paragraph to format","empty-story");let l=Z(r.value);return l?tt(u(l),r.value,i.font):f("invalid-handle","that story is not in this document")}case "getStyle":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);let l=ot(i.span,n,s);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let k=l.value.part,P=l.value.styles(),S=At(r.value,l.value).map(F=>we(k,F,P)),T=S.length>0&&S.every(F=>F!==null&&F===S[0])?S[0]:null;return E({kind:"style",name:T})}case "setStyle":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);if(!r.value)return f("invalid-offset","that story holds no paragraph to style","empty-story");let l=Z(r.value);return l?gt(u(l),r.value,i.name):f("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let r=Fe(i.paragraph,n,s);if(!r.ok)return f(r.code,"that is not a paragraph",r.detail);let l=s.story(r.value.story);if(!l)return f("document-unavailable","this host holds no document right now");let k=Nr(l.part,r.value.paragraphId,l.styles());return k?E({kind:"paragraphFormat",format:k}):f("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let r=Fe(i.paragraph,n,s);if(!r.ok)return f(r.code,"that is not a paragraph",r.detail);let l=s.story(r.value.story);return l?q(u(l),r.value,i.format):f("invalid-handle","that story is not in this document")}case "deleteParagraph":{let r=pt(i.paragraph,n,s);if(!r.ok)return f(r.code,"that handle does not name a paragraph",r.detail);let l=s.story(r.value.story);return l?ht(u(l),r.value):f("invalid-handle","that story is not in this document")}case "getSections":return n.resolve(i.document,"document")?E({kind:"handles",handles:s.sections().map(r=>n.section(r.index))}):f("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let r=n.resolve(i.section,"section");if(!r||r.kind!=="section")return f("invalid-handle","that handle does not name a section","section");let l=s.sections()[r.index];return l?E({kind:"pageSetup",setup:l.pageSetup}):f("invalid-handle","that section is not in this document")}case "setPageSetup":{let r=n.resolve(i.section,"section");return !r||r.kind!=="section"?f("invalid-handle","that handle does not name a section","section"):Et(r.index,i.setup)}case "getFurniture":{let r=n.resolve(i.section,"section");if(!r||r.kind!=="section")return f("invalid-handle","that handle does not name a section","section");if(i.kind!=="header"&&i.kind!=="footer")return f("unknown-operation","that is not furniture",String(i.kind));let l={kind:i.kind,sectionIndex:r.index,variant:i.variant};return Ho(l)?s.sections()[r.index]?E({kind:"handle",handle:n.body(l)}):f("invalid-handle","that section no longer exists"):f("unknown-operation","that is not a furniture variant",String(i.variant))}case "getNotes":{if(!n.resolve(i.document,"document"))return f("invalid-handle","that handle does not name a document","document");if(i.noteKind!=="footnote"&&i.noteKind!=="endnote")return f("unknown-operation","that is not a kind of note",String(i.noteKind));let r=i.noteKind,l=s.noteIds(r);return l.ok?E({kind:"handles",handles:l.ids.map(k=>n.note(r,k))}):f("ambiguous-document",`${r} identities are not completely and unambiguously enumerable`,l.reason==="duplicates"?l.duplicateIds.join(","):l.reason)}case "getNoteBody":case "getNoteText":{let r=n.resolve(i.note,"note");if(!r||r.kind!=="note")return f("invalid-handle","that handle does not name a note","note");let l=r,k=s.story(l);return k?i.op==="getNoteText"?E({kind:"text",text:k.text(i.projection)}):E({kind:"handle",handle:n.body(l)}):f("invalid-handle","that note is not in this document",G(l))}case "getNoteKind":{let r=n.resolve(i.note,"note");return !r||r.kind!=="note"?f("invalid-handle","that handle does not name a note","note"):E({kind:"text",text:r.noteKind})}case "deleteNote":{let r=n.resolve(i.note,"note");if(!r||r.kind!=="note")return f("invalid-handle","that handle does not name a note","note");let l=s.noteIds(r.noteKind);return l.ok?l.ids.includes(r.noteId)?ca(r.noteKind,r.noteId):f("invalid-handle","that note is not in this document"):f("ambiguous-document",`${r.noteKind} identities are not completely and unambiguously enumerable`,l.reason==="duplicates"?l.duplicateIds.join(","):l.reason)}case "getLists":{let r=at(i.body,"body",n,s);return r.ok?E({kind:"handles",handles:Kt(r.value).map(l=>n.list(l.numId,r.value.story))}):f(r.code,"that handle does not name a body",r.detail)}case "getListId":{let r=$e(i.list);return "list"in r?E({kind:"number",value:Number(r.list.numId)}):r}case "getListById":{let r=at(i.body,"body",n,s);if(!r.ok)return f(r.code,"that handle does not name a body",r.detail);if(!Number.isInteger(i.id)||i.id<=0)return f("unsupported-content","a list is numbered from one",String(i.id));let l=String(i.id),k=Kt(r.value).find(P=>P.numId===l);return k?E({kind:"handle",handle:n.list(k.numId,r.value.story)}):f("invalid-handle","no list in that story carries that number",l)}case "getListParagraphs":{let r=$e(i.list);if(!("list"in r))return r;let l=i.level;if(l!==void 0&&(!Number.isInteger(l)||l<0||l>ee))return f("invalid-offset",`a list level is 0 to ${String(ee)}`,String(l));let k=r.plan.reads,P=l===void 0?r.list.paragraphIds:r.list.paragraphIds.filter(S=>fe(k,S)?.level===l);return E({kind:"handles",handles:P.map(S=>n.paragraph(S,k.story))})}case "getParagraphList":{let r=pt(i.paragraph,n,s);if(!r.ok)return f(r.code,"that handle does not name a paragraph",r.detail);let l=s.story(r.value.story);if(!l)return f("invalid-handle","that story is not in this document");let k=fe(l,r.value.paragraphId);return k?E({kind:"handle",handle:n.list(k.numId,l.story)}):f("unsupported-content","that paragraph is not in a list",r.value.paragraphId)}case "getListLevel":{let r=pt(i.paragraph,n,s);if(!r.ok)return f(r.code,"that handle does not name a paragraph",r.detail);let l=s.story(r.value.story);if(!l)return f("invalid-handle","that story is not in this document");let k=fe(l,r.value.paragraphId);return k?E({kind:"number",value:k.level}):f("unsupported-content","that paragraph is not in a list",r.value.paragraphId)}case "setListLevel":{let r=pt(i.paragraph,n,s);if(!r.ok)return f(r.code,"that handle does not name a paragraph",r.detail);let l=s.story(r.value.story);return l?pa(u(l),r.value.paragraphId,i.level):f("invalid-handle","that story is not in this document")}case "insertListParagraph":{let r=$e(i.list);return "list"in r?ma(r.plan,r.list,i.where,i.text):r}case "getHyperlink":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);let l=ot(i.span,n,s);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let k=s.package;if(!k||!r.value)return E({kind:"text",text:""});let P=Pn(l.value,r.value);if(!P)return E({kind:"text",text:""});let S=Ha$1(l.value.part,P.id),T=S?jr(k,l.value.part.name,S):null;return E({kind:"text",text:T??""})}case "setHyperlink":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);if(!r.value)return f("invalid-offset","that story holds no text to link","empty-story");let l=Z(r.value);return l?fa(u(l),r.value,i.target):f("invalid-handle","that story is not in this document")}case "getBookmarks":{let r=z(i.scope,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);let l=ot(i.scope,n,s);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let k=l.value,P=r.value,S=P===null?null:new Set(At(P,k)),T=yn(k).filter(F=>{if(!S||!S.has(F.start.paragraphId)&&!S.has(F.end.paragraphId)||P===null)return false;let $=F.start.paragraphId===P.end.paragraphId&&F.start.offset>P.end.offset,Y=F.end.paragraphId===P.start.paragraphId&&F.end.offset<P.start.offset;return !$&&!Y});return E({kind:"handles",handles:T.map(F=>n.bookmark(F.name,k.story))})}case "getBookmarkName":{let r=n.resolve(i.bookmark,"bookmark");return !r||r.kind!=="bookmark"?f("invalid-handle","that handle does not name a bookmark","bookmark"):E({kind:"text",text:r.name})}case "getBookmarkRange":{let r=Rn(i.bookmark);return "reads"in r?E({kind:"span",span:X(r.range)}):r}case "getComments":{let r=z(i.scope,n,s);if(!r.ok)return f(r.code,"that scope is not a place",r.detail);let l=ot(i.scope,n,s);if(!l.ok)return f(l.code,"that scope names no story",l.detail);let k=l.value,P=v(k);if(!P)return f("document-unavailable","this host holds no document");let S=r.value,T=P.roots.filter(F=>{if(!S)return true;let $=F.range;if(!$)return false;let Y=k.indexOf($.start.paragraphId),U=k.indexOf($.end.paragraphId),M=k.indexOf(S.start.paragraphId),_=k.indexOf(S.end.paragraphId);return U<M||Y>_?false:U===M&&Y===M&&_===M?$.end.offset>S.start.offset&&$.start.offset<S.end.offset:true});return E({kind:"handles",handles:T.map(F=>n.comment(F.id,k.story))})}case "getCommentReplies":{let r=O$1(i.comment);return r.ok?E({kind:"handles",handles:r.item.replyIds.map(l=>n.comment(l,r.reads.story))}):r.planned}case "getCommentId":{let r=O$1(i.comment);return r.ok?E({kind:"text",text:r.item.id}):r.planned}case "getCommentAuthor":{let r=O$1(i.comment);return r.ok?E({kind:"text",text:r.item.comment.author}):r.planned}case "getCommentDate":{let r=O$1(i.comment);return r.ok?E({kind:"text",text:r.item.comment.date??""}):r.planned}case "getCommentText":{let r=O$1(i.comment);if(!r.ok)return r.planned;let l=v(r.reads);return E({kind:"text",text:l?.textOf(r.item.id)??""})}case "getCommentRange":{let r=O$1(i.comment);if(!r.ok)return r.planned;let l=r.item.range;if(!l||r.item.orphaned)return f("invalid-handle","that comment has no range in this document");let k=L(r.reads,l);return k?E({kind:"span",span:k}):f("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let r=O$1(i.comment);return r.ok?E({kind:"flag",value:r.item.resolved}):r.planned}case "insertComment":return Gr(i,n,s,A);case "setCommentResolved":{let r=O$1(i.comment);if(!r.ok)return r.planned;if(typeof i.resolved!="boolean")return f("unsupported-content","resolved is a yes or a no",String(i.resolved));let l=g(u(r.reads));return l||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:r.item.id,resolved:i.resolved},story:r.reads.story,answer:()=>et}}case "replyToComment":{let r=O$1(i.comment);if(!r.ok)return r.planned;let l=An({author:i.author,text:i.text,date:i.date,kind:"reply"});if(l)return l;let k=r.item.range;if(!k||r.item.orphaned)return f("invalid-handle","that comment has no range to reply over");let P=g(u(r.reads));if(P)return P;let S=r.reads.story,T=vn(i.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:r.item.id,anchor:{paragraphId:k.start.paragraphId,start:k.start.offset,end:k.end.offset,...k.end.paragraphId===k.start.paragraphId?{}:{endParagraphId:k.end.paragraphId}},text:i.text,author:i.author,...T===void 0?{}:{date:T}},story:r.reads.story,answer:(F,$)=>$===void 0?et:{kind:"handle",handle:n.comment($,S)}}}case "deleteComment":{let r=O$1(i.comment);return r.ok?Xr(r.item,r.reads,l=>g(u(l))):r.planned}case "getRevisions":{let r=at(i.body,"body",n,s);if(!r.ok)return f(r.code,"that handle does not name a body",r.detail);let l=r.value;return E({kind:"handles",handles:kn(l).map(k=>n.revision(k.id,l.story))})}case "getRevisionType":{let r=w(i.revision);return r.ok?E({kind:"text",text:r.item.type}):r.planned}case "getRevisionAuthor":{let r=w(i.revision);return r.ok?E({kind:"text",text:r.item.author}):r.planned}case "getRevisionDate":{let r=w(i.revision);return r.ok?E({kind:"text",text:r.item.date}):r.planned}case "getRevisionRange":{let r=w(i.revision);if(!r.ok)return r.planned;let[l]=r.item.item.ranges;if(!l)return f("invalid-handle","that change covers no characters");let k=L(r.reads,l);return k?E({kind:"span",span:k}):f("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let r=w(i.revision);if(!r.ok)return r.planned;let l=u(r.reads),k=g(l);if(k)return k;let P=$r(r.reads,r.item.item,i.op==="acceptRevision"?"accept":"reject");return P.length?{ok:true,kind:"command",story:r.reads.story,ops:P,answer:()=>et}:f("unsupported-revision","the table decision has unresolved dependencies")}case "resolveRevisionBatch":case "acceptAllRevisions":case "rejectAllRevisions":return Ur(i,n,s,r=>g(u(r)));case "selectSpan":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);if(!r.value)return f("invalid-offset","that story holds no paragraph to select","empty-story");let l=Z(r.value);return l?On(u(l),r.value,i.mode):f("invalid-handle","that story is not in this document")}case "selectBookmark":{let r=Rn(i.bookmark);return "reads"in r?On(u(r.reads),r.range,i.mode):r}case "getContentControls":{let r=Ke(i.scope);return "reads"in r?E({kind:"handles",handles:Yr(r.reads,r.node).map(l=>n.contentControl(l.nodeId,r.reads.story))}):r}case "getContentControlById":{let r=Ke(i.scope);if(!("reads"in r))return r;if(!Number.isInteger(i.id))return f("unsupported-content","a control id is a whole number",String(i.id));let l=ge(r.node).find(k=>wb(k).id===i.id);return l?E({kind:"handle",handle:n.contentControl(l.id,r.reads.story)}):f("invalid-handle","no control in that scope carries that id",String(i.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let r=Ke(i.scope);if(!("reads"in r))return r;let l=i.op==="getContentControlsByTag"?i.tag:i.title;if(typeof l!="string"||l.length===0)return f("unsupported-content","a tag or title to match is required",i.op);let k=ge(r.node).filter(P=>{let S=wb(P);return i.op==="getContentControlsByTag"?S.tag===l:S.alias===l});return E({kind:"handles",handles:k.map(P=>n.contentControl(P.id,r.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let r=Ot(i.contentControl);if(!("control"in r))return r;let l=r.control.properties;if(i.op==="getContentControlLock")return E({kind:"text",text:r.control.lock});if(i.op==="getContentControlSubtype")return E({kind:"text",text:l.type});if(i.op==="getContentControlFileId")return E({kind:"text",text:l.id===void 0?"":String(l.id)});let k=i.op==="getContentControlTag"?l.tag:l.alias;return E({kind:"text",text:k??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let r=Ot(i.contentControl);if(!("control"in r))return r;let l=i.op==="getContentControlIsBound"?r.control.properties.dataBinding!==void 0:i.op==="getContentControlPlaceholderShown"?r.control.properties.showingPlaceholder:r.control.properties.temporary;return E({kind:"flag",value:l})}case "getContentControlText":{let r=Ot(i.contentControl);return "control"in r?E({kind:"text",text:qr(r.reads,r.node,i.projection)}):r}case "getContentControlParagraphs":{let r=Ot(i.contentControl);return "control"in r?E({kind:"handles",handles:r.control.paragraphIds.map(l=>n.paragraph(l,r.reads.story))}):r}case "getContentControlRange":{let r=Ot(i.contentControl);if(!("control"in r))return r;let l=i.location??"whole";if(!oa.has(l))return f("unsupported-content","that is not a place in a control",l);let k=Ue(r.reads,r.node);if(!k)return f("unsupported-content","that control holds nothing addressable","empty");let P=l==="start"||l==="before"?k.start:k.end,S=l!=="whole"&&l!=="content",T=F=>({story:r.reads.story,paragraphId:F.paragraphId,index:r.reads.indexOf(F.paragraphId),offset:F.offset});return E({kind:"span",span:Nt(S?{start:T(P),end:T(P)}:{start:T(k.start),end:T(k.end)},n)})}case "setContentControlValue":{let r=Ot(i.contentControl);if(!("control"in r))return r;let l=aa(i.value);if(!l.ok)return f(l.code,l.message,l.detail);let k=u(r.reads),P=g(k);return P||{ok:true,kind:"command",story:r.reads.story,ops:[{op:"setContentControlValue",controlId:r.control.nodeId,value:l.value}],answer:()=>et}}case "setContentControlProperties":{let r=Ot(i.contentControl);if(!("control"in r))return r;if(i.tag===void 0&&i.title===void 0&&i.lock===void 0&&i.cannotEdit===void 0&&i.cannotDelete===void 0)return f("unsupported-content","nothing to write","no-properties");if(i.lock!==void 0&&!na.has(i.lock))return f("unsupported-content","that is not a lock this schema declares",i.lock);for(let S of [i.cannotEdit,i.cannotDelete])if(S!==void 0&&typeof S!="boolean")return f("unsupported-content","lock flags must be boolean");let l=u(r.reads),k=i.lock;if(i.cannotEdit!==void 0||i.cannotDelete!==void 0){let S=k??c.get(l)?.get(r.control.nodeId)??r.control.properties.lock,T=i.cannotEdit??(S==="contentLocked"||S==="sdtContentLocked"),F=i.cannotDelete??(S==="sdtLocked"||S==="sdtContentLocked");k=T?F?"sdtContentLocked":"contentLocked":F?"sdtLocked":"unlocked";}let P=g(l);if(P)return P;if(k!==void 0){let S=c.get(l)??new Map;S.set(r.control.nodeId,k),c.set(l,S);}return {ok:true,kind:"command",story:r.reads.story,ops:[{op:"setContentControlProperties",controlId:r.control.nodeId,...i.tag===void 0?{}:{tag:i.tag},...i.title===void 0?{}:{alias:i.title},...k===void 0?{}:{lock:k}}],answer:()=>et}}case "insertContentControlText":{let r=Ot(i.contentControl);if(!("control"in r))return r;if(typeof i.text!="string")return f("unsupported-content","text is required","text");if(i.at!=="replace"&&i.at!=="start"&&i.at!=="end")return f("unsupported-content","that is not a place to insert at",String(i.at));let l=u(r.reads),k=g(l);if(k)return k;let P=Ue(r.reads,r.node);if(!P)return f("unsupported-content","that control holds nothing addressable","empty");let S=i.at==="end"?P.end:P.start,T=()=>({kind:"span",span:X({start:{story:r.reads.story,paragraphId:S.paragraphId,index:r.reads.indexOf(S.paragraphId),offset:S.offset},end:{story:r.reads.story,paragraphId:S.paragraphId,index:r.reads.indexOf(S.paragraphId),offset:S.offset+i.text.length}})});return i.at==="replace"?{ok:true,kind:"command",story:r.reads.story,ops:[{op:"setContentControlValue",controlId:r.control.nodeId,value:{kind:"text",text:i.text}}],answer:T}:{ok:true,kind:"command",story:r.reads.story,ops:i.text.length===0?[]:[{op:"insertText",paragraphId:S.paragraphId,offset:S.offset,text:i.text,inside:r.node.id}],answer:T}}case "deleteContentControl":{let r=Ot(i.contentControl);if(!("control"in r))return r;if(typeof i.keepContent!="boolean")return f("unsupported-content","keepContent is required","keepContent");let l=u(r.reads),k=g(l);return k||{ok:true,kind:"command",story:r.reads.story,ops:[{op:"removeContentControl",controlId:r.control.nodeId,keepContent:i.keepContent}],answer:()=>et}}case "insertContentControl":{let r=z(i.span,n,s);if(!r.ok)return f(r.code,"that span is not a place",r.detail);if(!r.value)return f("invalid-offset","that story holds nothing to wrap","empty-story");let l=Z(r.value);if(!l)return f("invalid-handle","that story is not in this document");let k=r.value;if(k.start.paragraphId!==k.end.paragraphId)return f("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!ra.has(i.subtype))return f("unsupported-content","that control type cannot be inserted",i.subtype);let P=new Set(ge(l.root).map($=>$.id)),S=u(l),T=g(S);if(T)return T;let F=N(S,k.start.paragraphId);return F||{ok:true,kind:"command",story:l.story,ops:[{op:"insertContentControl",paragraphId:k.start.paragraphId,start:k.start.offset,end:k.end.offset,type:i.subtype,...i.tag===void 0?{}:{tag:i.tag},...i.title===void 0?{}:{alias:i.title}}],answer:$=>{if(!i.returnHandle)return et;let Y=$.story(l.story),U=Y&&ge(Y.root).find(M=>!P.has(M.id));if(!U)throw new Error("content control insertion did not create a control");return {kind:"handle",handle:n.contentControl(U.id,l.story)}}}}case "insertCustomNode":{let r=la(i);if(r)return f("unsupported-content",r.message,r.detail);let l=sa(i.payload);if(!l.ok)return f("unsupported-content","that payload cannot be written",l.field);let k=ua(i,n,s);if("code"in k)return f(k.code,k.message,k.detail);let{start:P,end:S}=k.range,T=Z(k.range);if(!T)return f("invalid-handle","that story is not in this document");let F=g(u(T));return F||{ok:true,kind:"customNodeWrite",story:T.story,write:da(i,P,S,l.value),answer:()=>et}}default:return f("unknown-operation","this host does not implement that operation",String(i.op))}};return {plan(i,p){if(y&&Wt(i))return f("conflicting-operations","header/footer creation must commit alone");let h=x.conflict(i);if(h)return f("conflicting-operations",h.message,h.detail);let I=ga(i,p);if(I.ok&&I.kind==="command"&&I.solitary){if(x.hasCommands)return f("conflicting-operations","header/footer creation must commit alone");y=true;}return I.ok&&x.note(i),I},get hasCommands(){return x.hasCommands},get writeScope(){return b?.reads.scope??null},settle(i){let p=b;if(p){let h=i.story(p.reads.story),I=h&&Ha$1(h.part,p.reads.root.id),R=h&&I&&I.id!==h.root.id?Le(h,I):h;if(!R)return {ok:false,detail:`the story this batch wrote is gone: ${G(p.reads.story)}`};let r=new Set(p.reads.paragraphIds),l=R.paragraphIds.filter(P=>!r.has(P));if(l.length!==p.created.length+p.externalCreatedCount)return {ok:false,detail:`planned ${String(p.created.length+p.externalCreatedCount)} new paragraphs, the transaction made ${String(l.length)}`};p.order.filter(P=>P.id===null).forEach((P,S)=>{P.id=l[S]??null;});for(let P of p.retargets)P.slot.id&&n.retarget(P.from,P.slot.id);}for(let h of m){let I=i.story(h.range.start.story);!I||!rr(h.range,I)||t.select?.(h.range,h.mode);}return {ok:true}}}}var Ei=Object.freeze({status:"skipped"});function ut(t,e,o){return Object.freeze(o===void 0?{code:t,message:e}:{code:t,message:e,detail:o})}function Li(t){if(t==="review-module-required"||t==="automation-structural-tracking-unsupported")return ut("unsupported-capability","this edit requires a supported review mode",t);let e=t==="unsupported-revision"||t.startsWith("unsupported-revision:");return ut(e?"unsupported-revision":"transaction-refused",e?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",t)}function yt(t,e,o,n){return {ok:false,results:t.map((a,s)=>s===e?{status:"error",error:o}:Ei),revision:n,changed:false}}function Du(t){let{port:e}=t,o=Object.freeze({...t.capabilities}),n=Uo(),a=new Set,s=false,d={mode:"Off"},c=0,u=null,m=null,x=o.events?e.subscribe(()=>{if(s)return;let A=Object.freeze({revision:e.revision()});if(c>0)u=A;else for(let v of [...a])v(A);}):()=>{},y=A=>{if(m&&m.pkg===A)return m.value;let v=ce(A);return m={pkg:A,value:v},v},b=A=>{let v=Array.isArray(A?.operations)?A.operations:[],O=e.revision();if(s)return yt(v,0,ut("disposed","this host was disposed"),O);if(!o.document)return yt(v,0,ut("unsupported-capability","this host has no document","document"),O);let w=e.currentPackage();if(!w)return yt(v,0,ut("document-unavailable","this host holds no document right now"),O);if(A.expectedRevision!==void 0&&A.expectedRevision!==O)return yt(v,0,ut("stale-revision","the document moved since that revision",`expected ${String(A.expectedRevision)}, at ${O}`),O);let L=In({handles:n,reads:y(w),capabilities:o,...e.revisionDisplayMode?{displayMode:e.revisionDisplayMode()}:{},...e.replacementLanding?{replacementLanding:e.replacementLanding.bind(e)}:{},...e.fieldPageContext?{fieldPageContext:e.fieldPageContext.bind(e)}:{},...e.select?{select:e.select.bind(e)}:{}}),H=[],j=[],N=null,K=[],C=[],W=null,X,Z=null,D=-1,nt=d;for(let B=0;B<v.length;B+=1){let Pt=v[B];if(e.suggesting?.()&&Pt.op!=="replaceSpan"&&!ln(Pt))return yt(v,B,ut("unsupported-capability","this operation has no supported tracked form in suggesting mode"),O);let ht=Wo(Pt,e.localChangeTracking===true,nt),tt=ht?.step??L.plan(Pt,nt.author);if(ht&&(nt=ht.state),!tt.ok)return yt(v,B,tt.error,O);if(H.push(tt),tt.kind==="command")if(tt.packageEdits&&K.push(...tt.packageEdits),D<0&&(D=B),tt.lifecycle)N=tt.ops[0]??null;else if(tt.relate){let gt=tt.relate;j.push(q=>{let Et=q(gt.url);return Et===null?null:gt.ops(Et)});}else {let{ops:gt}=tt;j.push(()=>gt);}else tt.kind==="commentWrite"?(D<0&&(D=B),C.push(tt.write),W=L.writeScope??{kind:"body"}):tt.kind==="customNodeWrite"&&(D<0&&(D=B),Z={write:tt.write,scope:L.writeScope??{kind:"body"}});}let rt=false;if(C.length>0){let B=e.applyCommentWrites(C,W??{kind:"body"});if(!B.ok)return yt(v,D<0?0:D,ut("transaction-refused","the document store refused the comment write",B.reason),O);rt=B.changed,X=B.commentId;}if(Z){let B=e.applyCustomNodeWrite(Z.write,Z.scope);if(!B.ok)return yt(v,D<0?0:D,ut("transaction-refused","the document store refused the custom-node write",B.reason),O);rt=B.changed;}if(N){let B=e.applyLifecycle(N);if(!B.ok)return yt(v,D<0?0:D,ut("transaction-refused","the document store refused the transaction",B.reason),O);rt=B.changed;}if(j.length>0){let B=e.apply(Pt=>{let ht=[];for(let tt of j){let gt=tt(Pt);if(gt===null)return null;ht.push(...gt);}return ht},L.writeScope??{kind:"body"},K);if(!B.ok)return yt(v,D<0?0:D,Li(B.reason),O);rt=B.changed;}let ct=e.currentPackage();if(!ct)return yt(v,0,ut("document-unavailable","this host holds no document right now"),O);let Mt=y(ct),jt=L.settle(Mt);return jt.ok?(d=nt,{ok:true,results:H.map(B=>({status:"ok",value:B.kind==="query"?B.value:B.kind==="customNodeWrite"?B.answer(Mt):B.answer(Mt,X)})),revision:e.revision(),changed:rt}):yt(v,D<0?0:D,ut("transaction-refused","the transaction did not produce the document the batch planned",jt.detail),e.revision())};return {capabilities:o,revision:()=>e.revision(),execute:A=>{c+=1;try{return b(A)}finally{if(c-=1,c===0&&u){let v=u;u=null;for(let O of [...a])O(v);}}},...e.prepare?{prepare:e.prepare.bind(e)}:{},save(){if(s)return {ok:false,error:ut("disposed","this host was disposed")};if(!o.save)return {ok:false,error:ut("unsupported-capability","this host cannot save","save")};let A=e.save();return A?{ok:true,bytes:A}:{ok:false,error:ut("document-unavailable","this host holds no document right now")}},subscribe(A){return s||!o.events?()=>{}:(a.add(A),()=>{a.delete(A);})},dispose(){s||(s=true,a.clear(),x(),e.dispose(),m=null);}}}
|
|
2
|
-
export{Xo as a,Yo as b,ba as c,Di as d,Bi as e,Ce as f,ce as g,Wi as h,xa as i,Aa as j,an as k,Wt as l,Du as m};
|