@docx-editor.dev/core 2.4.1 → 2.6.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/THIRD_PARTY_NOTICES.md +39 -1
- package/dist/automation.cjs +1 -1
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.cts +8 -8
- package/dist/binding.d.ts +8 -8
- package/dist/binding.js +1 -1
- package/dist/chunk-4GQXAXTZ.js +5 -0
- package/dist/chunk-DGUHCJPF.cjs +18 -0
- package/dist/chunk-DY3QVCWC.cjs +10 -0
- package/dist/chunk-E7BXJ4BF.js +1 -0
- package/dist/chunk-F7Z6PWAZ.cjs +2 -0
- package/dist/chunk-IJ4V3LGV.cjs +2 -0
- package/dist/chunk-JEMP5YI5.cjs +15 -0
- package/dist/{chunk-YMIMLEX4.cjs → chunk-JZXK4DKV.cjs} +1 -1
- package/dist/chunk-NIGGABAA.js +15 -0
- package/dist/chunk-OPKOTVQQ.js +18 -0
- package/dist/{chunk-GOEBQ26R.js → chunk-PSZH2VXP.js} +1 -1
- package/dist/chunk-R75OLPL6.js +10 -0
- package/dist/chunk-SFMAIFEN.cjs +2 -0
- package/dist/chunk-SKWYEZCO.cjs +5 -0
- package/dist/chunk-SMRD66T5.js +2 -0
- package/dist/chunk-UVIUNAQ6.js +2 -0
- package/dist/chunk-WAVN7MAT.js +2 -0
- package/dist/chunk-WU7PUTVA.js +2 -0
- package/dist/{chunk-OHJQ7GPZ.cjs → chunk-YMYCPY5Y.cjs} +1 -1
- package/dist/contracts/editor.cjs +1 -1
- package/dist/contracts/editor.d.cts +8 -8
- package/dist/contracts/editor.d.ts +8 -8
- package/dist/contracts/editor.js +1 -1
- package/dist/contracts/interaction.d.cts +7 -7
- package/dist/contracts/interaction.d.ts +7 -7
- package/dist/contracts/modules.d.cts +4 -4
- package/dist/contracts/modules.d.ts +4 -4
- package/dist/contracts/types.d.cts +3 -1
- package/dist/contracts/types.d.ts +3 -1
- package/dist/{custom-node-writes-C5YRoPcc.d.cts → custom-node-writes-D9G3GKQ7.d.cts} +18 -3
- package/dist/{custom-node-writes-BkMgMXxs.d.ts → custom-node-writes-tJw8U9MO.d.ts} +18 -3
- package/dist/dist-YFULGVS3.js +2 -0
- package/dist/{editor-DYvC9CZs.d.cts → editor-BZEJL3vv.d.cts} +50 -19
- package/dist/{editor-D1qHfzOt.d.ts → editor-D2zOJztO.d.ts} +50 -19
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +407 -38
- package/dist/editor.d.cts +38 -22
- package/dist/editor.d.ts +38 -22
- package/dist/editor.js +1 -1
- package/dist/harfbuzz.wasm +0 -0
- package/dist/{image-resources-DXvPZvXD.d.cts → image-resources-BaHz4QAd.d.cts} +1 -1
- package/dist/{image-resources-BG9DLyW7.d.ts → image-resources-Cl5_cNi9.d.ts} +1 -1
- package/dist/{index-DpY3WZuP.d.ts → index-D8L8WrNF.d.ts} +178 -23
- package/dist/{index-Bb-QAg_f.d.cts → index-_xF7n_z0.d.cts} +178 -23
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.cts +159 -47
- package/dist/layout.d.ts +159 -47
- package/dist/layout.js +1 -1
- package/dist/node-module-shim-TTKTT66I.js +1 -0
- package/dist/output.cjs +1 -1
- package/dist/output.d.cts +20 -6
- package/dist/output.d.ts +20 -6
- package/dist/output.js +1 -1
- package/dist/{review-reads-CxgN62yp.d.cts → review-reads-Dr0CpW6u.d.cts} +25 -1
- package/dist/{review-reads-CQmU9Lcl.d.ts → review-reads-HDvoQXK2.d.ts} +25 -1
- package/dist/{review-support-DgXTIYBW.d.ts → review-support-D4ZBdUXa.d.ts} +46 -2
- package/dist/{review-support-BJ-YjGmD.d.cts → review-support-T-riLz4Y.d.cts} +46 -2
- package/dist/{revision-projection-DHAkcD_L.d.ts → revision-projection-UKqvPa4-.d.ts} +53 -2
- package/dist/{revision-projection-72ZApe-g.d.cts → revision-projection-WzlQGBJx.d.cts} +53 -2
- package/dist/{semantic-cell-selection-DZtyMXkH.d.ts → semantic-cell-selection-B5vfPz4Q.d.ts} +7 -4
- package/dist/{semantic-cell-selection--ezfezTe.d.cts → semantic-cell-selection-BTQFpN0S.d.cts} +7 -4
- package/dist/{semantic-interaction-DrgbgKg6.d.ts → semantic-interaction-CDNEU_Tx.d.cts} +2 -30
- package/dist/{semantic-interaction-2yxdv7q0.d.cts → semantic-interaction-lvpzZRpA.d.ts} +2 -30
- package/dist/{semantic-paint-BedBxkyY.d.ts → semantic-paint-BBPL3u5w.d.ts} +111 -3
- package/dist/{semantic-paint-BYjE0Xbl.d.cts → semantic-paint-IjbL-4CT.d.cts} +111 -3
- package/dist/{semantic-records-CR5hTqMK.d.ts → semantic-records-CdQvpUj1.d.ts} +106 -8
- package/dist/{semantic-records-DSD8WENa.d.cts → semantic-records-DEOs3_tE.d.cts} +106 -8
- package/dist/{shaped-measurer-CBOTJTV_.d.cts → shaped-measurer-C2SJAjV0.d.cts} +1 -1
- package/dist/{shaped-measurer-BL8g4AcW.d.ts → shaped-measurer-l4o5ITJ0.d.ts} +1 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +38 -15
- package/dist/store.d.ts +38 -15
- package/dist/store.js +1 -1
- package/dist/{tree-op-types-EZXbR8bW.d.cts → tree-op-types-CUCwPWjT.d.cts} +1 -1
- package/dist/{tree-op-types-8a6xyRCN.d.ts → tree-op-types-D0fTNBVW.d.ts} +1 -1
- package/dist/{tree-session-SucW0znF.d.ts → tree-session-CH1oA75f.d.ts} +64 -42
- package/dist/{tree-session-DrMm8Cj2.d.cts → tree-session-b7bggR-S.d.cts} +64 -42
- package/dist/{tree-store-UYrGKF_Q.d.cts → tree-store-BqgeCa1Q.d.cts} +29 -2
- package/dist/{tree-store-BoM6eXaL.d.ts → tree-store-CIKASRHk.d.ts} +29 -2
- package/licenses/HarfBuzz-COPYING.txt +42 -0
- package/package.json +6 -4
- package/dist/chunk-33F6TRXO.js +0 -2
- package/dist/chunk-4WWEDTTE.js +0 -2
- package/dist/chunk-BS554B6D.cjs +0 -2
- package/dist/chunk-DQ5HGUWG.cjs +0 -12
- package/dist/chunk-EQO762XH.cjs +0 -10
- package/dist/chunk-F6WNPYOM.js +0 -2
- package/dist/chunk-FL4GWK76.js +0 -12
- package/dist/chunk-GWG5IVVX.cjs +0 -5
- package/dist/chunk-IZIL6BAW.cjs +0 -12
- package/dist/chunk-LIJPSHRA.js +0 -5
- package/dist/chunk-MHDO6HLI.cjs +0 -2
- package/dist/chunk-SG7OH2EK.js +0 -12
- package/dist/chunk-TCX3PVWR.js +0 -10
- package/dist/chunk-YTYKNA6X.cjs +0 -2
- package/dist/chunk-ZACHY6OS.js +0 -1
package/dist/chunk-YTYKNA6X.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkDQ5HGUWG_cjs=require('./chunk-DQ5HGUWG.cjs');var Te=8;function Z(t,e){if(t===void 0||t.length===0)return null;let n=t[t.length-1],o=t.some(i=>i.kind==="delete"||i.kind==="moveFrom"),r=n.kind,a=r==="delete"||r==="moveFrom"?"line-through":r==="insert"||r==="moveTo"?"underline":null;return {attribution:n,line:o&&a==="underline"?"line-through":a,decorationStyle:r==="moveFrom"||r==="moveTo"?"double":r==="insert"?"dashed":"solid",color:o?"var(--doc-revision-deletion)":"var(--doc-revision-insertion)",authorColor:`var(--doc-review-author-${(0)%Te})`,deleted:o}}function J(t,e,n,o,r,a){for(let i of [n.footnotes,n.endnotes])i&&e.append(ke(t,n,i,o,r,a));}function ke(t,e,n,o,r,a){let i=t.createElement("div");if(i.className="docx-notes",i.dataset.docxNotes=n.kind,i.dataset.docxNotesPlacement=n.placement,i.style.position="absolute",i.style.left=`${(n.box.x-e.box.x)*o.scale}px`,i.style.top=`${(n.box.y-e.box.y)*o.scale}px`,i.style.width=`${n.box.width*o.scale}px`,i.style.height=`${n.box.height*o.scale}px`,n.separator){let s=t.createElement("div");s.className="docx-note-separator",s.dataset.docxNoteSeparator=n.separator.kind,s.setAttribute("contenteditable","false"),s.setAttribute("aria-hidden","true"),s.style.position="absolute",s.style.left=`${(n.separator.box.x-n.box.x)*o.scale}px`,s.style.top=`${(n.separator.box.y-n.box.y)*o.scale}px`,s.style.width=`${n.separator.box.width*o.scale}px`,s.style.height=`${Math.max(n.separator.box.height,.75)*o.scale}px`;let d=n.separator.ruleStyle;if(d||n.separator.synthetic||n.separator.fragments.length===0)Ie(s,t,d??"single",o.scale);else for(let l of n.separator.fragments)s.append(l.kind==="table"?a(t,l,o):r(t,l,o));i.append(s);}for(let s of n.notes){let 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-n.box.x)*o.scale}px`,d.style.top=`${(s.box.y-n.box.y)*o.scale}px`,d.style.width=`${s.box.width*o.scale}px`,d.style.height=`${s.box.height*o.scale}px`;for(let l of s.fragments)d.append(l.kind==="table"?a(t,l,o):r(t,l,o));i.append(d);}return i}function Ie(t,e,n,o){t.dataset.docxNoteRule=n;let r=Math.max(1,o*.75);if(n==="single"){t.style.borderTop=`${r}px solid currentColor`,t.style.opacity="0.85";return}t.style.opacity="0.85";let a=Math.max(1,o*1.25);for(let i of [0,r+a]){let s=e.createElement("div");s.setAttribute("aria-hidden","true"),s.style.position="absolute",s.style.left="0",s.style.right="0",s.style.top=`${i}px`,s.style.height="0",s.style.borderTop=`${r}px solid currentColor`,t.append(s);}}var Q=Object.freeze({"image/svg+xml":"SVG","image/tiff":"TIFF","image/x-emf":"EMF","image/x-wmf":"WMF",unknown:"Unknown"}),H=new WeakMap,B=new WeakMap,Ae=256;function te(t,e){let n=H.get(t);if(n)return n;let o=new Map,r=new Map;return n=Object.freeze({urlForReady(a,i){let s=o.get(a.resourceKey);if(s)return s;let d=e.create(a,i);return o.set(a.resourceKey,d),d},imageFor(a,i,s){let d=r.get(a);if(d&&d.resourceKey===i)return d.element;let l=s.createElement("img");return r.size<Ae&&r.set(a,{element:l,resourceKey:i,...d?.readyElement?{readyElement:d.readyElement}:{}}),l},imageForPending(a){return r.get(a)?.element??null},readyElementFor(a){return r.get(a)?.readyElement??null},rememberReadyElement(a,i){let s=r.get(a);s&&r.set(a,{...s,readyElement:i});},reconcile(a,i){for(let[s,d]of o)a.has(s)||(e.revoke(d),o.delete(s));for(let[s,d]of r)i.has(s)||(d.element.removeAttribute("src"),r.delete(s));},revokeAll(){for(let a of o.values())e.revoke(a);o.clear();for(let a of r.values())a.element.removeAttribute("src");r.clear();}}),H.set(t,n),n}function O(t,e){return `${e.paintInstance??""}|${t.drawingNodeId}`}function It(t){H.get(t)?.revokeAll(),H.delete(t);}function R(t){return Number.isFinite(t)?String(t):"0"}function ne(t,e){if(t.length<3||e.width<=0||e.height<=0)return null;let n=[];for(let o of t){if(!Number.isFinite(o.x)||!Number.isFinite(o.y))return null;let r=(o.x-e.x)/e.width*100,a=(o.y-e.y)/e.height*100;n.push(`${R(r)}% ${R(a)}%`);}return `polygon(${n.join(", ")})`}function oe(t){let e=t.geometry.contentBounds;return chunkDQ5HGUWG_cjs.lb({transform:t.transform,contentWidth:e.width,contentHeight:e.height})}function re(t){let{effects:e}=t,n=[];if(e.grayscale&&n.push("grayscale(1)"),e.brightness!==0&&Number.isFinite(e.brightness)){let o=1+e.brightness/100;Number.isFinite(o)&&n.push(`brightness(${R(Math.max(0,o))})`);}if(e.contrast!==0&&Number.isFinite(e.contrast)){let o=1+e.contrast/100;Number.isFinite(o)&&n.push(`contrast(${R(Math.max(0,o))})`);}return n.length>0?n.join(" "):void 0}function ae(t,e){let{crop:n}=t,o=Math.max(0,Math.min(1,n.left)),r=Math.max(0,Math.min(1,n.top)),a=Math.max(0,Math.min(1,n.right)),i=Math.max(0,Math.min(1,n.bottom)),s=Math.max(1e-4,1-o-a),d=Math.max(1e-4,1-r-i);return Object.freeze({width:`${R(1/s*100)}%`,height:`${R(1/d*100)}%`,left:`${R(-o/s*100)}%`,top:`${R(-r/d*100)}%`})}function He(t,e){let{resource:n}=t;switch(n.kind){case "external":return e.externalResource;case "missing":return e.missingResource;case "pending":return e.pendingResource;case "unrenderable":switch(n.reason){case "unsupported-format":return e.unsupportedFormat(Q[n.mime]??Q.unknown);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 P(t,e,n){let{accessibility:o}=e;o.hidden||(t.setAttribute("role",n?"link":"img"),o.label?t.setAttribute("aria-label",o.label):n||t.setAttribute("aria-hidden","true"));}function T(t,e,n,o){let r=o?.x??0,a=o?.y??0;t.style.position="absolute",t.style.left=`${(e.x-r)*n}px`,t.style.top=`${(e.y-a)*n}px`,t.style.width=`${e.width*n}px`,t.style.height=`${e.height*n}px`,t.style.boxSizing="border-box",t.style.overflow="hidden",t.style.pointerEvents="auto";}function Me(t,e,n,o,r){let a=t.paintBounds,i=t.geometry.contentBounds,s=ae(t);return [o,n.scale,r?.x??0,r?.y??0,a.x,a.y,a.width,a.height,i.x,i.y,i.width,i.height,ne(t.geometry.clipPolygon??[],a)??"",re(t)??"",oe(t)??"",s.width,s.height,s.left,s.top,n.inertLinks?"":t.hyperlinkHref??"",t.accessibility.label??""].join("|")}function L(t,e,n,o){let r=t.createElement("div");r.className="docx-drawing docx-drawing-placeholder",r.dataset.drawingNodeId=e.drawingNodeId,T(r,e.paintBounds,n.scale,o);let a=t.createElement("div");a.className="docx-drawing-placeholder-card";let i=t.createElement("span");return i.className="docx-drawing-placeholder-label",i.textContent=He(e,n.strings),a.append(i),r.append(a),e.hyperlinkHref&&!n.inertLinks?(r.dataset.docxDrawingLink=e.drawingNodeId,r.dataset.docxDrawingLinkKind="external",r.dataset.docxDrawingLinkHref=e.hyperlinkHref,r.setAttribute("tabindex","-1"),P(r,e,true)):P(r,e,false),r}function Fe(t,e,n,o,r,a){let i=e.resource;if(i.kind!=="ready")return L(t,e,n,a);let s=O(e,n),d=r?.readyElementFor?.(s)??t.createElement("div"),l=Me(e,i,n,o,a);if(B.get(d)===l)return d;d.className="docx-drawing docx-drawing-ready",d.style.cssText="",d.dataset.drawingNodeId=e.drawingNodeId,delete d.dataset.docxDrawingLink,delete d.dataset.docxDrawingLinkKind,delete d.dataset.docxDrawingLinkHref,d.removeAttribute("aria-hidden"),d.removeAttribute("aria-label"),d.removeAttribute("role"),d.removeAttribute("tabindex"),T(d,e.paintBounds,n.scale,a);let c=ne(e.geometry.clipPolygon??[],e.paintBounds);c&&(d.style.clipPath=c);let y=t.createElement("div");y.className="docx-drawing-image-frame",y.style.position="absolute";let p=e.geometry.contentBounds,h=e.paintBounds;y.style.left=`${(p.x-h.x)*n.scale}px`,y.style.top=`${(p.y-h.y)*n.scale}px`,y.style.width=`${p.width*n.scale}px`,y.style.height=`${p.height*n.scale}px`;let g=re(e);g&&(y.style.filter=g);let v=t.createElement("div");v.className="docx-drawing-transform-stage",v.style.position="relative",v.style.width="100%",v.style.height="100%";let m=oe(e);m&&(v.style.transform=m,v.style.transformOrigin="0 0");let f=t.createElement("div");f.className="docx-drawing-crop-viewport",f.style.position="relative",f.style.width="100%",f.style.height="100%",f.style.overflow="hidden";let u=r?.imageFor?.(s,i.resourceKey,t)??t.createElement("img");u.className="docx-drawing-image",u.setAttribute("draggable","false"),u.getAttribute("src")!==o&&u.setAttribute("src",o),u.setAttribute("alt","");let b=ae(e);return u.style.position="absolute",u.style.width=b.width,u.style.height=b.height,u.style.left=b.left,u.style.top=b.top,u.style.maxWidth="none",u.style.maxHeight="none",f.append(u),v.append(f),y.append(v),d.replaceChildren(y),e.hyperlinkHref&&!n.inertLinks?(d.dataset.docxDrawingLink=e.drawingNodeId,d.dataset.docxDrawingLinkKind="external",d.dataset.docxDrawingLinkHref=e.hyperlinkHref,d.setAttribute("tabindex","-1"),P(d,e,true)):P(d,e,false),r?.rememberReadyElement?.(s,d),B.set(d,l),d}var ee="http://www.w3.org/2000/svg";function Ce(t,e,n,o){let r=e.vectorShape,a=t.createElement("div");a.className="docx-drawing docx-drawing-shape",a.dataset.drawingNodeId=e.drawingNodeId,T(a,e.paintBounds,n.scale,o);let i=e.geometry.contentBounds,s=e.paintBounds,d=t.createElement("div");d.className="docx-drawing-image-frame",d.style.position="absolute",d.style.left=`${(i.x-s.x)*n.scale}px`,d.style.top=`${(i.y-s.y)*n.scale}px`,d.style.width=`${i.width*n.scale}px`,d.style.height=`${i.height*n.scale}px`;let l=t.createElementNS(ee,"svg");l.setAttribute("viewBox",`0 0 ${R(Math.max(1,r.extentEmu.cx))} ${R(Math.max(1,r.extentEmu.cy))}`),l.setAttribute("preserveAspectRatio","none"),l.setAttribute("width","100%"),l.setAttribute("height","100%"),l.style.display="block";let c=t.createElementNS(ee,"path"),y=r.subpathsEmu.map(p=>`M${p.map(h=>`${R(h.x)} ${R(h.y)}`).join("L")}Z`).join("");return c.setAttribute("d",y),c.setAttribute("fill",r.fillHex!==null?`#${r.fillHex}`:"none"),c.setAttribute("fill-rule","evenodd"),r.strokeHex!==null&&(c.setAttribute("stroke",`#${r.strokeHex}`),c.setAttribute("stroke-width",R(Math.max(1,r.strokeWidthEmu)))),l.append(c),d.append(l),a.append(d),e.hyperlinkHref&&!n.inertLinks?(a.dataset.docxDrawingLink=e.drawingNodeId,a.dataset.docxDrawingLinkKind="external",a.dataset.docxDrawingLinkHref=e.hyperlinkHref,a.setAttribute("tabindex","-1"),P(a,e,true)):P(a,e,false),a}function Ne(t,e,n,o,r){let a=o.scale,i=t.createElement("div");i.className="docx-drawing docx-drawing-textbox",i.dataset.drawingNodeId=e.drawingNodeId,i.setAttribute("contenteditable","false"),T(i,e.paintBounds,o.scale,r),i.style.overflow="hidden";let s=(e.x-e.paintBounds.x)*a,d=(e.y-e.paintBounds.y)*a;if(n.fillHex!==null||n.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=`${d}px`,c.style.width=`${e.width*a}px`,c.style.height=`${e.height*a}px`,c.style.boxSizing="border-box",n.fillHex!==null&&(c.style.backgroundColor=`#${n.fillHex}`),n.strokeHex!==null&&(c.style.border=`${Math.max(n.strokeWidthPt*a,.5)}px solid #${n.strokeHex}`),i.append(c);}let l=t.createElement("div");l.className="docx-drawing-textbox-content",l.style.position="absolute",l.style.left=`${s+n.contentOffset.x*a}px`,l.style.top=`${d+n.contentOffset.y*a}px`,l.style.width=`${n.contentWidth*a}px`,l.style.height=`${Math.max(0,n.contentHeight)*a}px`,l.style.overflow="hidden";for(let c of n.fragments)l.append(o.paintStoryFragment(t,c));for(let c of l.querySelectorAll("[data-paragraph-id]"))delete c.dataset.paragraphId;return i.append(l),P(i,e,false),i}function ie(t,e,n,o,r){if(e.accessibility.hidden||e.paintBounds.width<=0||e.paintBounds.height<=0)return null;if(e.kind==="anchoredDrawing"&&e.textboxStory!==void 0&&n.paintStoryFragment!==void 0)return Ne(t,e,e.textboxStory,n,r);if(e.vectorShape&&e.vectorShape.subpathsEmu.length>0)return Ce(t,e,n,r);let{resource:a}=e;if(a.kind==="ready"){if(!n.imageUrlPort||!o)return L(t,e,n,r);let i=o.urlForReady(a.validatedHandle,a.mime);return i?Fe(t,e,n,i,o,r):L(t,e,n,r)}if(a.kind==="pending"){let i=o?.readyElementFor?.(O(e,n))??o?.imageForPending?.(O(e,n))?.closest(".docx-drawing-ready");return i?(B.delete(i),i.dataset.drawingNodeId=e.drawingNodeId,T(i,e.paintBounds,n.scale,r),i):L(t,e,n,r)}return L(t,e,n,r)}function se(t,e,n,o,r){let a=[];for(let i of e.drawings??[]){let s=ie(t,i,n,o,r);s&&a.push(s);}return Object.freeze(a)}function le(t,e,n,o,r,a){let i=[];for(let s of e){if(chunkDQ5HGUWG_cjs.mb(s)!==n)continue;let d=ie(t,s,o,r,a);d&&(d.dataset.drawingLayer=n,i.push(d));}return Object.freeze(i)}function de(t){let e=new Set,n=i=>{i.resource.kind==="ready"&&e.add(i.resource.resourceKey);},o=i=>{for(let s of i.drawings??[])n(s);},r=i=>{for(let s of i.lines)o(s);},a=i=>{if(i.kind==="table"){for(let s of i.rows)for(let d of s.cells)for(let l of d.blocks)a(l);return}r(i);};for(let i of t.pages){for(let s of i.anchoredDrawings??[])n(s);for(let s of i.fragments)a(s);for(let s of [i.header,i.footer])if(s){for(let d of s.anchoredDrawings??[])n(d);for(let d of s.fragments)a(d);}}return e}function ce(t){let e=new Set,n=(r,a)=>{e.add(`p${r}|${a.drawingNodeId}`);},o=(r,a)=>{if(a.kind==="table"){for(let i of a.rows)for(let s of i.cells)for(let d of s.blocks)o(r,d);return}for(let i of a.lines)for(let s of i.drawings??[])n(r,s);};for(let r of t.pages){for(let a of r.anchoredDrawings??[])n(r.index,a);for(let a of r.fragments)o(r.index,a);for(let a of [r.header,r.footer])if(a){for(let i of a.anchoredDrawings??[])n(r.index,i);for(let i of a.fragments)o(r.index,i);}}return e}function ye(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 U=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 At(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")})}var Be=/^[0-9A-Fa-f]{6}$/;function Oe(t){switch(t){case "dashed":return "dashed";case "dotted":return "dotted";case "double":case "triple":return "solid";default:return "solid"}}function he(t){return t&&Be.test(t)?t:"000000"}function z(t,e){let n=t.createElement("div");return n.className=e,n.setAttribute("aria-hidden","true"),n.setAttribute("contenteditable","false"),n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.right="0",n.style.bottom="0",n.style.overflow="visible",n.style.pointerEvents="none",n.style.boxSizing="border-box",n}function M(t,e,n,o){if(!n)return;let r=`#${he(n.color)}`,a=`${Math.max(0,n.widthPt*o)}px`;if(t.style[`border${e}Width`]=a,t.style[`border${e}Color`]=r,n.style==="double"||n.style==="triple"){t.style[`border${e}Style`]="none";return}t.style[`border${e}Style`]=Oe(n.style);}function _(t,e,n,o,r){let a=t.createElement("div");a.className=r,a.dataset.edge=n.side,a.dataset.stroke=n.role,a.style.position="absolute",a.style.left=`${n.x*o}px`,a.style.top=`${n.y*o}px`,a.style.width=`${n.width*o}px`,a.style.height=`${n.height*o}px`,a.style.pointerEvents="none",a.style.backgroundColor=`#${he(n.color)}`,n.cssStyle!=="solid"&&(a.dataset.cssStyle=n.cssStyle),e.append(a);}function Ue(t){let e=new Set;for(let n of t)e.add(`${n.side}\0${n.role}`);return e}function ze(t,e,n,o){let r=Ue(n),a=p=>r.has(`${p}\0middle`),i=z(t,"docx-table-border-double"),s=z(t,"docx-table-border-triple"),d=z(t,"docx-table-border-edge"),l=false,c=false,y=false;for(let p of n){if(p.role==="edge"){y=true,_(t,d,p,o,"docx-table-border-edge-stroke");continue}if(a(p.side)){c=true,_(t,s,p,o,"docx-table-border-triple-stroke");continue}(p.role==="outer"||p.role==="inner")&&(l=true,_(t,i,p,o,"docx-table-border-double-stroke"));}l&&e.append(i),c&&e.append(s),y&&e.append(d);}function pe(t,e,n,o){M(e,"Top",n?.top,o),M(e,"Right",n?.right,o),M(e,"Bottom",n?.bottom,o),M(e,"Left",n?.left,o),n?.strokes&&n.strokes.length>0&&ze(t,e,n.strokes,o);}var K="when-selected",ue=new WeakMap,ge=0;function _e(t){let e=ue.get(t);return e||(ge+=1,e=`alias${ge}`,ue.set(t,e)),e}function Re(t){return {...t,drawingStrings:t.drawingStrings??U,urlRegistry:t.urlRegistry??null}}function Ke(t){let e={...t,inertLinks:true};return Object.freeze({scale:t.scale,strings:t.drawingStrings,...t.imageUrlPort?{imageUrlPort:t.imageUrlPort}:{},...t.inertLinks?{inertLinks:true}:{},...t.paintInstance?{paintInstance:t.paintInstance}:{},paintStoryFragment:(n,o)=>o.kind==="table"?I(n,o,e):k(n,o,e)})}function Se(t){return Object.freeze({ctx:Ke(t),urlRegistry:t.urlRegistry})}function xe(t,e,n,o,r,a){F(t,e,chunkDQ5HGUWG_cjs.U(n),o,r,a);}function F(t,e,n,o,r,a,i=true){if(n.length===0)return;let s=Se(o),d=t.createElement("div");d.className=a==="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";for(let l of le(t,n,a,s.ctx,s.urlRegistry,r)){if(l.style.pointerEvents=i?"auto":"none",!i)for(let c of l.querySelectorAll(".docx-drawing"))c.style.pointerEvents="none";d.append(l);}d.childElementCount>0&&e.append(d);}function $e(t){return t.horizontalFrame==="page"||t.verticalFrame==="page"}function De(t,e,n){let o=e.paintBounds,r=e.horizontalFrame==="page"?n.x+(o.x-e.horizontalFrameOrigin):t.box.x+o.x,a=e.verticalFrame==="page"?n.y+(o.y-e.verticalFrameOrigin):t.box.y+o.y,i=r-o.x,s=a-o.y,d=l=>Object.freeze({x:l.x+i,y:l.y+s,width:l.width,height:l.height});return Object.freeze({...e,x:e.x+i,y:e.y+s,paintBounds:d(o),hitBounds:d(e.hitBounds),geometry:Object.freeze({...e.geometry,contentBounds:d(e.geometry.contentBounds),paintBounds:d(e.geometry.paintBounds),...e.geometry.clipPolygon?{clipPolygon:Object.freeze(e.geometry.clipPolygon.map(l=>Object.freeze({x:l.x+i,y:l.y+s})))}:{}})})}function Ge(t,e,n,o,r,a){let i=o.map(d=>De(n,d,a)),s=t.createElement("div");s.className="docx-hf-behind-layer",s.dataset.docxHfBehind=n.kind,s.setAttribute("contenteditable","false"),s.style.position="absolute",s.style.inset="0",s.style.overflow="hidden",s.style.pointerEvents="none",F(t,s,i,r,a,"behind",false),s.childElementCount>0&&e.append(s);}function je(t,e,n,o,r,a,i,s=false){let d=o.filter($e).map(l=>De(n,l,a));F(t,e,d,r,a,i,s);}var E=/^[0-9A-Fa-f]{6}$/,fe=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,We=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"})),Ve=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 Xe(t){return t.doubleStrike?"double":t.strike?"single":"none"}function Ye(t){return t==="thick"||t.endsWith("Heavy")}function Pe(t){if(!t.underline)return null;let e=t.underline.color&&E.test(t.underline.color)?t.underline.color:null;return {cssStyle:We.get(t.underline.variant)??"solid",color:e,heavy:Ye(t.underline.variant)}}function Ee(t,e,n,o){t.textDecorationLine=e,t.textDecorationStyle=n,o.color&&(t.textDecorationColor=`#${o.color}`),o.heavy&&(t.textDecorationThickness=`max(${2*o.scale}px, 0.12em)`);}function be(t,e,n){e!=="none"&&Ee(t,"line-through",e==="double"?"double":"solid",{scale:n});}function me(t,e,n){Ee(t,"underline",e.cssStyle,{color:e.color,heavy:e.heavy,scale:n});}function qe(t,e,n){let o=e.color?`#${e.color}`:"currentColor";t.borderBottomWidth=`${(e.heavy?2:1)*n}px`,t.borderBottomStyle=e.cssStyle==="wavy"?"solid":e.cssStyle,t.borderBottomColor=o;}function G(t,e,n){let o=t.style,r=n.scale,a=e.verticalAlign==="baseline"?1:.75;o.fontSize=`${e.fontSizePt*a*r}px`,e.bold&&(o.fontWeight="bold"),e.italic&&(o.fontStyle="italic");let i=e.fontFamily&&fe.test(e.fontFamily)?e.fontFamily:n.defaultFontFamily&&fe.test(n.defaultFontFamily)?n.defaultFontFamily:null;if(i){let l=n.fontAlias?.(i);o.fontFamily=l?`"${l}", "${i}", ${chunkDQ5HGUWG_cjs.gd}`:`"${i}", ${chunkDQ5HGUWG_cjs.gd}`;}e.color&&E.test(e.color)&&(o.color=`#${e.color}`);let s=e.highlight?Ve.get(e.highlight):void 0;s?(o.backgroundColor=s,t.dataset.highlight=e.highlight??""):e.shading&&E.test(e.shading)&&(o.backgroundColor=`#${e.shading}`),e.caps&&(o.textTransform="uppercase"),e.smallCaps&&(o.fontVariant="small-caps");let d=chunkDQ5HGUWG_cjs.bb(e);d!==0&&(o.position="relative",o.top=`${-d*r}px`),e.characterSpacingPt!==0&&(o.letterSpacing=`${e.characterSpacingPt*r}px`),e.horizontalScalePercent!==100&&(o.transformOrigin="left",o.transform=`scaleX(${e.horizontalScalePercent/100})`);}function Le(t,e,n,o,r){let a=n===" "?null:Pe(o),i=Xe(o),s=e;if(a&&i!=="none"){let d=t.createElement("span");d.dataset.docxDeco="underline",me(d.style,a,r);let l=t.createElement("span");l.dataset.docxDeco="strike",be(l.style,i,r),d.append(l),e.append(d),s=l;}else a?me(e.style,a,r):i!=="none"&&be(e.style,i,r);s.textContent=n;}function D(t,e,n,o){let r=t.createElement(e);return r.style.position="absolute",r.style.left=`${n.x*o}px`,r.style.top=`${n.y*o}px`,r.style.width=`${n.width*o}px`,r.style.height=`${n.height*o}px`,r}function Ze(t,e,n){let o=e.fieldAtom;!o||(t.dataset.fieldAtom=o.formField?"form":"field",!(o.formField?n.shadeFormFields!==false:(n.fieldShading??K)!=="never"))||(t.classList.add("docx-field-atom"),(o.formField||(n.fieldShading??K)==="always")&&t.classList.add("docx-field-atom--shaded"));}function Je(t,e){let n=chunkDQ5HGUWG_cjs.fb(e.props),o=Z(e.revisions);if(!(!o&&!n)){if(o){let{attribution:r}=o;t.classList.add("docx-revision",`docx-revision-${r.kind}`),t.dataset.revisionKind=r.kind,t.dataset.revisionId=r.id,t.dataset.revisionAuthor=r.author,r.date!==void 0&&(t.dataset.revisionDate=r.date),t.style.color=o.color,t.style.backgroundColor=o.deleted?"var(--doc-revision-deletion-wash)":"var(--doc-revision-insertion-wash)",o.line&&(t.style.textDecorationLine=o.line,t.style.textDecorationStyle=o.decorationStyle,t.style.textDecorationColor=o.color);return}t.classList.add("docx-revision","docx-revision-format"),t.dataset.revisionKind="format",t.dataset.revisionId=n.id,t.dataset.revisionAuthor=n.author,n.date!==void 0&&(t.dataset.revisionDate=n.date);}}function Qe(t,e,n){let o=t.createElement("span");return o.className=`docx-revision-pmark docx-revision-pmark-${e.kind}`,o.setAttribute("aria-hidden","true"),o.contentEditable="false",o.dataset.revisionKind=e.kind,o.dataset.revisionId=e.id,o.dataset.revisionAuthor=e.author,o.textContent="\xB6",o.style.position="absolute",o.style.pointerEvents="none",o.style.marginLeft=`${2*n}px`,o.style.color=e.kind==="delete"?"var(--doc-revision-deletion)":"var(--doc-revision-insertion)",e.kind==="delete"&&(o.style.textDecorationLine="line-through"),o}function et(t,e,n){let o=[];for(let a of e.lines){let i=a.spans.flatMap(y=>y.revisions??[]);if(i.length===0)continue;let s=i.some(y=>y.kind==="delete"||y.kind==="moveFrom"),d=a.box.y-e.box.y,l=d+a.box.height,c=o[o.length-1];if(c&&c.deleted===s&&d<=c.bottom+.5){c.bottom=Math.max(c.bottom,l);continue}o.push({top:d,bottom:l,deleted:s});}if(o.length===0)return null;let r=t.createElement("div");r.className="docx-change-bars",r.setAttribute("aria-hidden","true"),r.style.position="absolute",r.style.inset="0",r.style.pointerEvents="none";for(let a of o){let i=t.createElement("div");i.className=`docx-change-bar docx-change-bar-${a.deleted?"deletion":"insertion"}`,i.style.position="absolute",i.style.top=`${a.top*n}px`,i.style.height=`${(a.bottom-a.top)*n}px`,i.style.left=`${(-e.box.x-tt)*n}px`,i.style.width=`${nt*n}px`,i.style.pointerEvents="none",i.style.backgroundColor=a.deleted?"var(--doc-revision-deletion)":"var(--doc-revision-insertion)",r.append(i);}return r}var tt=7.5,nt=1.5;function ot(t,e,n,o,r){let a=t.createElement("span");if(a.className="layout-run layout-run-text",a.style.display="inline-block",a.style.verticalAlign="baseline",a.style.boxSizing="border-box",a.style.height=`${o*n.scale}px`,a.style.paddingTop=`${r*n.scale}px`,a.style.lineHeight=`${(o-r)*n.scale}px`,e.range.end>e.range.start?(a.dataset.paragraphId=e.range.paragraphId,a.dataset.start=String(e.range.start),a.dataset.end=String(e.range.end)):(a.setAttribute("aria-hidden","true"),a.contentEditable="false"),G(a,e.style,n),Ze(a,e,n),Je(a,e),(e.style.horizontalScalePercent!==100||e.text===" ")&&(a.style.width=`${e.box.width*n.scale}px`),e.text===" "){a.style.overflow="hidden",a.style.verticalAlign="top";let i=Pe(e.style);i&&(a.dataset.docxTabUnderline="",qe(a.style,i,n.scale));}return Le(t,a,e.text,e.style,n.scale),e.projected&&(a.dataset.docxField="",a.setAttribute("contenteditable","false"),e.noteNav?(a.style.userSelect="none",e.noteNav.direction==="to-note"?(a.dataset.docxNoteRef="",a.dataset.docxNoteScope=e.noteNav.scopeId,e.text.length>0&&a.setAttribute("aria-description",e.text)):(a.dataset.docxNoteMarkBack="",a.dataset.docxNoteScope=e.noteNav.scopeId)):(a.style.pointerEvents="none",a.style.userSelect="none")),a}function rt(t,e,n){let o=t.createElement("a");return o.className="docx-hyperlink",o.dataset.docxLink=e.id,o.dataset.docxLinkKind=e.kind,o.setAttribute("tabindex","-1"),!n.inertLinks&&e.href&&(o.setAttribute("href",e.href),e.kind==="external"&&o.setAttribute("rel","noopener noreferrer")),e.tooltip&&o.setAttribute("title",e.tooltip),o.style.display="inline-block",o.style.verticalAlign="baseline",o.style.textDecoration="none",o.style.color="inherit",o}function at(t,e,n){let o=n.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*o}px`,r.style.left=`${e.contentX*o}px`,r.style.height=`${e.box.height*o}px`,r.style.fontSize="0",r.style.whiteSpace="pre",r.style.overflow="visible";let a=e.leading??0,i=Math.min(Math.max(a,...e.spans.map(m=>m.box.height+a),e.spans.length===0?e.box.height-(e.trailingSpacing??0):0),e.box.height),s=Math.max(0,e.box.height-i);r.style.boxSizing="border-box",r.style.paddingBottom=`${s*o}px`,r.style.lineHeight=`${(e.box.height-s)*o}px`;let d=null,l=null,c=[...e.drawings??[]].sort((m,f)=>m.start-f.start),y=0,p=m=>{for(;y<c.length&&c[y].start<m;){let f=c[y],u=Math.max(0,f.advanceEnd-f.advanceStart),b=t.createElement("span");b.className="docx-inline-drawing-advance",b.dataset.docxMarker="",b.setAttribute("contenteditable","false"),b.setAttribute("aria-hidden","true"),b.style.display="inline-block",b.style.width=`${u*o}px`,b.style.height=`${f.baselineOffset*o}px`,b.style.lineHeight="0",b.style.pointerEvents="none",b.style.verticalAlign="baseline",r.append(b),y+=1,d=null,l=null;}},h=m=>{let f=m.wrapAdvanceBefore??0;if(f<=.001)return;let u=t.createElement("span");u.className="docx-wrap-advance",u.dataset.docxMarker="",u.setAttribute("contenteditable","false"),u.setAttribute("aria-hidden","true"),u.style.display="inline-block",u.style.width=`${f*o}px`,u.style.height="0",u.style.lineHeight="0",u.style.pointerEvents="none",u.style.verticalAlign="baseline",r.append(u),d=null,l=null;};for(let[m,f]of e.spans.entries()){p(f.range.start),h(f);let u=Math.min(f.box.height+a,e.box.height),b=ot(t,f,n,u,a),S=it(e,m);S>0&&(b.style.marginLeft=`${S*o}px`);let w=f.link;if(!w){d=null,l=null,r.append(b);continue}(!d||l!==w.id)&&(d=rt(t,w,n),l=w.id,r.append(d)),d.append(b);}if(p(Number.POSITIVE_INFINITY),e.spans.length===0){let m=t.createElement("br");m.style.lineHeight=`${e.box.height*o}px`,r.append(m);}let g=Object.freeze({x:e.contentX,y:e.box.y,width:e.box.width,height:e.box.height}),v=Se(Re(n));if(e.drawings&&e.drawings.length>0)for(let m of se(t,e,v.ctx,v.urlRegistry,g))r.append(m);return r}function it(t,e){if(e<=0)return 0;let n=t.spans[e-1],o=t.spans[e];if(t.drawings?.some(i=>i.start>=n.range.end&&i.start<o.range.start))return 0;let a=o.box.x-(n.box.x+n.box.width)-(o.wrapAdvanceBefore??0);return a>.25?a:0}function k(t,e,n){let o=n.scale,r=D(t,"div",e.box,o);r.className="docx-paragraph-fragment layout-paragraph",r.dataset.paragraphId=e.paragraphId,r.dataset.fragmentIndex=String(e.fragmentIndex),n.readOnlyParagraphIds?.has(e.paragraphId)&&(r.classList.add("docx-generated-region"),r.dataset.docxReadOnly="",r.setAttribute("contenteditable","false"),r.setAttribute("aria-readonly","true")),n.emptyTocPlaceholderIds?.has(e.paragraphId)&&(r.classList.add("docx-toc-empty-placeholder"),r.dataset.docxTocEmpty=""),e.shading&&E.test(e.shading)&&e.shadingBox&&r.append(ct(t,e,o)),e.marker&&r.append(st(t,e,n));for(let i of e.lines)for(let s of i.spans){if(!s.tabLeader)continue;let d=dt(t,e,i,s,n);d&&r.append(d);}let a=et(t,e,o);if(a&&r.append(a),e.markRevision){let i=Qe(t,e.markRevision,o),s=e.lines[e.lines.length-1];if(s){let d=s.spans[s.spans.length-1];i.style.top=`${(s.box.y-e.box.y)*o}px`,i.style.left=`${((d?d.box.x+d.box.width:s.contentX)-e.box.x)*o}px`,r.append(i);}}for(let i of e.lines){let s=at(t,i,n);s.style.top=`${(i.box.y-e.box.y)*o}px`,s.style.left=`${(i.contentX-e.box.x)*o}px`,r.append(s);}if(e.borders)for(let i of e.borders)r.append(ve(t,e,i,o));else e.bottomBorder&&r.append(ve(t,e,{side:"bottom",edge:e.bottomBorder.edge,box:e.bottomBorder.box},o));return r}function st(t,e,n){let o=e.marker,r=n.scale,a=e.lines[0]?.leading??0,i=D(t,"span",o.box,r);i.className="docx-list-marker",i.dataset.docxMarker="",i.setAttribute("contenteditable","false"),i.setAttribute("aria-hidden","true"),i.style.left=`${(o.box.x-e.box.x)*r}px`,i.style.top=`${(o.box.y-e.box.y)*r}px`,i.style.display="block",i.style.overflow="visible",i.style.whiteSpace="pre";let s=e.lines[0],d=s?Math.max(a,...s.spans.map(p=>p.box.height+a),s.spans.length===0?s.box.height-(s.trailingSpacing??0):0):o.box.height,l=Math.min(d,o.box.height),c=Math.max(0,o.box.height-l);i.style.fontSize="0",i.style.boxSizing="border-box",i.style.paddingBottom=`${c*r}px`,i.style.lineHeight=`${l*r}px`;let y=t.createElement("span");return y.style.display="inline-block",y.style.verticalAlign="baseline",y.style.boxSizing="border-box",y.style.height=`${l*r}px`,y.style.paddingTop=`${a*r}px`,y.style.lineHeight=`${(l-a)*r}px`,G(y,o.style,n),Le(t,y,o.text,o.style,r),i.append(y),i}var lt=512;function dt(t,e,n,o,r){let a=o.tabLeader?chunkDQ5HGUWG_cjs.Da.get(o.tabLeader):void 0;if(!a||o.box.width<=0)return null;let i=r.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",s.style.left=`${(o.box.x-e.box.x)*i}px`,s.style.top=`${(n.box.y-e.box.y)*i}px`,s.style.width=`${o.box.width*i}px`,s.style.height=`${n.box.height*i}px`,s.style.overflow="hidden",s.style.whiteSpace="pre",s.style.pointerEvents="none",s.style.userSelect="none";let d=n.leading??0,l=Math.min(o.box.height+d,n.box.height),c=Math.max(0,n.box.height-l);s.style.fontSize="0",s.style.boxSizing="border-box",s.style.paddingBottom=`${c*i}px`,s.style.lineHeight=`${(n.box.height-c)*i}px`;let y=t.createElement("span");y.style.display="inline-block",y.style.verticalAlign="baseline",G(y,o.style,r),y.style.boxSizing="border-box",y.style.height=`${l*i}px`,y.style.paddingTop=`${d*i}px`,y.style.lineHeight=`${(l-d)*i}px`,o.tabLeader==="heavy"&&(y.style.fontWeight="bold");let p=o.tabLeaderAdvancePt&&o.tabLeaderAdvancePt>0?o.tabLeaderAdvancePt:Math.max(.5,o.style.fontSizePt*.2),h=Math.min(lt,Math.max(1,Math.floor(o.box.width/p)+2));return y.textContent=a.repeat(h),y.style.letterSpacing="0",s.append(y),s}function ct(t,e,n){let o=e.shadingBox,r=D(t,"div",o,n);return r.className="docx-paragraph-shading",r.setAttribute("aria-hidden","true"),r.style.left=`${(o.x-e.box.x)*n}px`,r.style.top=`${(o.y-e.box.y)*n}px`,r.style.backgroundColor=`#${e.shading}`,r}function ve(t,e,n,o){let r=D(t,"div",n.box,o);r.className=`docx-paragraph-border docx-paragraph-border-${n.side}`,r.setAttribute("aria-hidden","true");let a=(n.box.x-e.box.x)*o,i=(n.box.y-e.box.y)*o,s=n.side==="left"||n.side==="right"||n.side==="bar",d=(s?n.box.width:n.box.height)*o,c=yt(n.edge.val)?d:Math.max(1,d);r.style.left=`${n.side==="right"?a-(c-d):a}px`,r.style.top=`${n.side==="bottom"?i-(c-d):i}px`,s?r.style.width=`${c}px`:r.style.height=`${c}px`;let y=n.edge.color&&E.test(n.edge.color)?n.edge.color:"000000";return r.style.backgroundColor=`#${y}`,ht(r,n.edge.val,y,s,c,o),r}function yt(t){return t==="double"||t==="triple"||t==="doubleWave"||t.startsWith("thinThick")||t.startsWith("thickThin")}function ht(t,e,n,o,r,a){switch(e){case "dashed":case "dashSmallGap":case "dotDash":case "dotDotDash":case "dashDotStroked":{let i=Math.max(4,4*a);t.style.backgroundImage=`linear-gradient(to ${o?"bottom":"right"}, #${n} 60%, transparent 60%)`,t.style.backgroundSize=o?`100% ${i}px`:`${i}px 100%`;return}case "dotted":{let i=Math.max(3,3*a);t.style.backgroundImage=`linear-gradient(to ${o?"bottom":"right"}, #${n} 35%, transparent 35%)`,t.style.backgroundSize=o?`100% ${i}px`:`${i}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 i=Math.max(1,r/3);t.style.backgroundColor="transparent",o?(t.style.borderLeft=`${i}px solid #${n}`,t.style.borderRight=`${i}px solid #${n}`):(t.style.borderTop=`${i}px solid #${n}`,t.style.borderBottom=`${i}px solid #${n}`),t.style.boxSizing="border-box";return}case "threeDEmboss":case "ridge":{t.style.backgroundColor="transparent";let i=o?"borderLeft":"borderTop";t.style[i]=`${Math.max(1,r)}px ridge #${n}`,o?t.style.width="0px":t.style.height="0px";return}case "threeDEngrave":case "groove":{t.style.backgroundColor="transparent";let i=o?"borderLeft":"borderTop";t.style[i]=`${Math.max(1,r)}px groove #${n}`,o?t.style.width="0px":t.style.height="0px";return}case "inset":{t.style.backgroundColor="transparent";let i=o?"borderLeft":"borderTop";t.style[i]=`${Math.max(1,r)}px inset #${n}`,o?t.style.width="0px":t.style.height="0px";return}case "outset":{t.style.backgroundColor="transparent";let i=o?"borderLeft":"borderTop";t.style[i]=`${Math.max(1,r)}px outset #${n}`,o?t.style.width="0px":t.style.height="0px";return}default:return}}function pt(t,e,n,o){let r=o.scale,a=D(t,"div",e.box,r);if(a.className="docx-table-cell",a.style.left=`${(e.box.x-n.x)*r}px`,a.style.top=`${(e.box.y-n.y)*r}px`,a.style.boxSizing="border-box",a.style.overflow="visible",a.dataset.cellId=e.id,a.dataset.gridColumn=String(e.gridColumn),a.dataset.gridSpan=String(e.gridSpan),e.rowSpan&&e.rowSpan>1&&(a.dataset.rowSpan=String(e.rowSpan)),e.paintInert||e.vMergeContinue)return a.dataset.vMergeContinue="true",a.style.border="none",a.style.backgroundColor="transparent",a;a.style.border="none",pe(t,a,e.borders,r),e.shading&&E.test(e.shading)&&(a.style.backgroundColor=`#${e.shading}`);for(let i of e.blocks){let s=i.kind==="table"?I(t,i,o):k(t,i,o);s.style.left=`${(i.box.x-e.box.x)*r}px`,s.style.top=`${(i.box.y-e.box.y)*r}px`,a.append(s);}return a}function I(t,e,n){let o=n.scale,r=D(t,"div",e.box,o);r.className="docx-table-fragment layout-table",r.dataset.tableId=e.tableId,r.dataset.fragmentIndex=String(e.fragmentIndex),r.style.overflow="visible";for(let a of e.rows){let i=D(t,"div",a.box,o);i.className="docx-table-row",a.revisionKind&&(i.classList.add("docx-table-row--revision",a.revisionKind==="insert"?"layout-revision-ins":"layout-revision-del"),i.dataset.revisionKind=a.revisionKind,a.revisionId!==void 0&&(i.dataset.revisionId=a.revisionId),a.revisionAuthor!==void 0&&(i.dataset.revisionAuthor=a.revisionAuthor),a.revisionDate!==void 0&&(i.dataset.revisionDate=a.revisionDate)),i.dataset.rowId=a.id,a.isHeaderRepeat&&(i.dataset.headerRepeat="true"),i.style.left=`${(a.box.x-e.box.x)*o}px`,i.style.top=`${(a.box.y-e.box.y)*o}px`,i.style.overflow="visible";for(let s of a.cells)i.append(pt(t,s,a.box,n));r.append(i);}return r}function ut(t,e,n,o){let r={...n,paintInstance:`p${e.index}`},a=D(t,"div",e.box,r.scale);if(a.className="docx-page",a.style.fontFamily=chunkDQ5HGUWG_cjs.gd,a.dataset.pageIndex=String(e.index),r.ariaHidden&&(a.setAttribute("aria-hidden","true"),a.setAttribute("role","presentation")),a.dataset.materialized=String(o),!o)return a;let i=Object.freeze({x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height}),s=Object.freeze({x:-(e.contentBox.x-e.box.x),y:-(e.contentBox.y-e.box.y),width:e.box.width,height:e.box.height});xe(t,a,e,r,s,"behind");for(let l of [e.header,e.footer])l?.anchoredDrawings?.length&&Ge(t,a,l,l.anchoredDrawings,r,{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height});let d=t.createElement("div");d.className="docx-page-content",d.style.position="absolute",d.style.left=`${(e.contentBox.x-e.box.x)*r.scale}px`,d.style.top=`${(e.contentBox.y-e.box.y)*r.scale}px`,d.style.width=`${e.contentBox.width*r.scale}px`,d.style.height=`${e.contentBox.height*r.scale}px`,r.activeHeaderFooterRId&&d.setAttribute("contenteditable","false");for(let l of e.columnSeparators??[]){let c=t.createElement("div");c.className="docx-column-separator",c.setAttribute("contenteditable","false"),c.style.position="absolute",c.style.left=`${l.x*r.scale}px`,c.style.top=`${l.y*r.scale}px`,c.style.width=`${l.width*r.scale}px`,c.style.height=`${l.height*r.scale}px`,c.style.backgroundColor="currentColor",c.style.pointerEvents="none",d.append(c);}for(let l of e.fragments)d.append(l.kind==="table"?I(t,l,r):k(t,l,r));a.append(d),xe(t,a,e,r,s,"inFront"),J(t,a,e,r,k,I);for(let l of ["header","footer"]){if(e[l])continue;let c=t.createElement("div");c.className="docx-hf docx-hf--placeholder",c.dataset.docxHf=l,c.setAttribute("contenteditable","false");let y=l==="header"?e.contentBox.y-e.box.y:e.box.y+e.box.height-(e.contentBox.y+e.contentBox.height),p=Math.min(y,gt);if(p<=0)continue;let h=Math.max(0,Math.min(xt,y-p)),g=l==="header"?h:e.box.height-h-p;c.style.position="absolute",c.style.left=`${(e.contentBox.x-e.box.x)*r.scale}px`,c.style.top=`${g*r.scale}px`,c.style.width=`${e.contentBox.width*r.scale}px`,c.style.height=`${p*r.scale}px`,a.append(c);}for(let l of [e.header,e.footer]){if(!l)continue;let c=l.anchoredDrawings??[],y=!!r.activeHeaderFooterRId&&!!l.rId&&r.activeHeaderFooterRId===l.rId&&(r.activeHeaderFooterPageIndex===void 0||r.activeHeaderFooterPageIndex===e.index),p=t.createElement("div");p.className="docx-hf",p.dataset.docxHf=l.kind,l.rId&&(p.dataset.docxRId=l.rId),y?(p.dataset.docxHfActive="",p.setAttribute("contenteditable","true")):p.setAttribute("contenteditable","false"),p.style.position="absolute",p.style.left=`${(l.box.x-e.box.x)*r.scale}px`,p.style.top=`${(l.box.y-e.box.y)*r.scale}px`,p.style.width=`${l.box.width*r.scale}px`;let h=y?l.kind==="footer"?Math.max(l.box.height,e.box.y+e.box.height-l.box.y):Math.max(l.box.height,e.contentBox.y-l.box.y):l.box.height;p.style.height=`${h*r.scale}px`,p.style.overflow="visible";let g=(e.box.x-l.box.x)*r.scale,v=(e.box.y-l.box.y)*r.scale,m=g+e.box.width*r.scale,f=v+e.box.height*r.scale;p.style.clipPath=`polygon(${g}px ${v}px, ${m}px ${v}px, ${m}px ${f}px, ${g}px ${f}px)`;let u=Object.freeze({x:0,y:0,width:l.box.width,height:l.box.height}),b=c.filter(x=>!$e(x)),S={...r,inertLinks:true};for(let x of l.fragments)p.append(x.kind==="table"?I(t,x,S):k(t,x,S));F(t,p,b,Re(r),u,"inFront",y),a.append(p);let w=t.createElement("div");w.className="docx-hf-edit-hint",w.dataset.docxHfHint=l.kind,w.setAttribute("contenteditable","false"),w.style.position="absolute",w.style.left=p.style.left,w.style.width=p.style.width,w.style.top=l.kind==="header"?`${(l.box.y+l.box.height-e.box.y)*r.scale}px`:`${(l.box.y-e.box.y)*r.scale}px`,l.kind==="footer"&&(w.style.transform="translateY(-100%)"),a.append(w),je(t,a,l,c,r,i,"inFront",y);}return mt(t,a,e,r),a}var gt=30,xt=36,ft=16,bt=new Set(["dropdown","comboBox","date","checkbox"]);function mt(t,e,n,o){let r=o.contentControlChrome,a=r?.suppressedIds,i=(n.contentControls??[]).filter(p=>a?.has(p.id)!==true),s=[...i,...(r?.additionalBoundaries??[]).filter(p=>a?.has(p.id)!==true&&!i.some(h=>h.id===p.id))];if(s.length===0)return;let d=r?.showAll===true,l=r?.activeIds,c=r?.hoverIds,y=r?.tocControlIds;for(let p of s){let h=y?.has(p.id)===true,g=!h&&l?.has(p.id)===true,v=c?.has(p.id)===true;e.append(vt(t,n,p,o.scale,g,v,d||g||h&&v,r?.checkedIds?.has(p.id),h));}}function vt(t,e,n,o,r,a,i,s,d){let l=t.createElement("div");l.className="docx-content-control-chrome",l.dataset.docxContentControl=n.id,l.dataset.docxMarker="",l.dataset.controlType=n.controlType,l.dataset.lock=n.effectiveLock,n.bound&&(l.dataset.bound=""),n.placeholder&&(l.dataset.placeholder=""),d&&(l.dataset.docxToc=""),r&&(l.dataset.active=""),a&&(l.dataset.hover=""),i&&(l.dataset.boundaryVisible=""),l.setAttribute("contenteditable","false"),l.setAttribute("role","group"),n.alias&&(l.dataset.alias=n.alias),n.tag&&(l.dataset.tag=n.tag),n.alias&&l.setAttribute("aria-label",n.alias),l.style.position="absolute",l.style.inset="0",l.style.pointerEvents="none",l.style.zIndex="2";let c=e.contentBox.x-e.box.x,y=e.contentBox.y-e.box.y;for(let h of n.fragments){if(h.pageIndex!==e.index)continue;let g=t.createElement("div");g.className="docx-content-control-boundary",g.dataset.docxMarker="",g.setAttribute("contenteditable","false"),g.setAttribute("aria-hidden","true"),g.style.position="absolute",g.style.left=`${(c+h.box.x)*o}px`,g.style.top=`${(y+h.box.y)*o}px`,g.style.width=`${Math.max(h.box.width,1)*o}px`,g.style.height=`${Math.max(h.box.height,1)*o}px`,g.style.pointerEvents="none",l.append(g);}let p=n.fragments.find(h=>h.pageIndex===e.index);if(p&&n.alias){let h=t.createElement("div");h.className="docx-content-control-label",h.dataset.docxMarker="",h.setAttribute("contenteditable","false"),h.setAttribute("aria-hidden","true"),h.textContent=n.alias,h.style.position="absolute",h.style.left=`${(c+p.box.x)*o}px`,h.style.top=`${Math.max(0,(y+p.box.y)*o-ft)}px`,h.style.pointerEvents="none",l.append(h);}if(p&&bt.has(n.controlType)){let h=t.createElement("button");h.type="button",h.className="docx-content-control-widget",h.dataset.docxMarker="",h.dataset.docxCcWidget=n.controlType,h.dataset.docxCcId=n.id,h.setAttribute("contenteditable","false"),h.setAttribute("tabindex","-1"),n.controlType==="checkbox"?h.setAttribute("role","checkbox"):n.controlType==="dropdown"||n.controlType==="comboBox"?h.setAttribute("role","listbox"):n.controlType==="date"&&h.setAttribute("role","button"),n.alias&&(h.dataset.name=n.alias),n.alias&&h.setAttribute("aria-label",n.alias),n.controlType==="checkbox"&&(h.setAttribute("data-checked",s?"true":"false"),h.setAttribute("aria-checked",s?"true":"false")),(n.effectiveLock==="contentLocked"||n.effectiveLock==="sdtContentLocked"||n.bound)&&(h.disabled=true,h.dataset.disabledReason=n.bound?"bound":"locked",h.setAttribute("aria-disabled","true")),h.style.position="absolute",h.style.left=`${(c+p.box.x+p.box.width)*o-18}px`,h.style.top=`${(y+p.box.y)*o}px`,h.style.width="16px",h.style.height="16px",h.style.pointerEvents="auto",h.style.padding="0",h.style.margin="0",h.style.cursor=h.disabled?"not-allowed":"pointer",l.append(h);}return l}var we=new WeakMap;function wt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Rt(t,e,n,o){let r=t.element;return !t.materialized&&wt(t.record.box,e.box)&&r.style.left===`${e.box.x*n}px`&&r.style.top===`${e.box.y*n}px`&&r.style.width===`${e.box.width*n}px`&&r.style.height===`${e.box.height*n}px`&&r.getAttribute("aria-hidden")===(o?"true":null)}function St(t,e,n={}){let o=n.contentControlChrome,r=o?`${o.showAll===true?"1":"0"}:${o.activeIds?[...o.activeIds].sort().join(","):""}:${o.checkedIds?[...o.checkedIds].sort().join(","):""}:${o.tocControlIds?[...o.tocControlIds].sort().join(","):""}:${o.suppressedIds?[...o.suppressedIds].sort().join(","):""}`:"",a=n.drawingStrings??U,i=n.imageUrlPort!==void 0?te(t,n.imageUrlPort):null,s=o?.additionalBoundaries?o.additionalBoundaries.flatMap(x=>x.fragments.map($=>`${x.id}:${$.pageIndex}:${$.box.x}:${$.box.y}:${$.box.width}:${$.box.height}`)).sort().join(","):"",d=n.readOnlyParagraphIds?[...n.readOnlyParagraphIds].sort().join(","):"",l=n.emptyTocPlaceholderIds?[...n.emptyTocPlaceholderIds].sort().join(","):"",c=o?.tocControlIds?[...o.tocControlIds].sort().join(","):"",y={scale:n.scale??96/72,ariaHidden:n.ariaHidden??true,drawingStrings:a,urlRegistry:i,...n.fontAlias?{fontAlias:n.fontAlias}:{},...n.readOnlyParagraphIds?{readOnlyParagraphIds:n.readOnlyParagraphIds}:{},...n.emptyTocPlaceholderIds?{emptyTocPlaceholderIds:n.emptyTocPlaceholderIds}:{},...n.defaultFontFamily?{defaultFontFamily:n.defaultFontFamily}:{},...n.fieldShading?{fieldShading:n.fieldShading}:{},...n.shadeFormFields!==void 0?{shadeFormFields:n.shadeFormFields}:{},...n.imageUrlPort?{imageUrlPort:n.imageUrlPort}:{},...n.activeHeaderFooterRId?{activeHeaderFooterRId:n.activeHeaderFooterRId}:{},...n.activeHeaderFooterPageIndex!==void 0?{activeHeaderFooterPageIndex:n.activeHeaderFooterPageIndex}:{},...o?{contentControlChrome:o}:{}},p=t.ownerDocument,h=`${y.scale}|${y.ariaHidden}|${y.fontAlias?_e(y.fontAlias):""}|${y.defaultFontFamily??""}|${y.activeHeaderFooterRId??""}|${y.activeHeaderFooterPageIndex??""}|cc:${r}:${s}|toc:${c}|ro:${d}|tocEmpty:${l}|${n.imageUrlPort?"url":""}|${ye(a)}`,g=we.get(t),m=g?.parameters===h?new Map(g.pages.map(x=>[x.record,x])):null,f=g?new Map(g.pages.map(x=>[x.record.index,x])):null,u=e.pages.map(x=>{let $=n.materialize?.has(x.index)??true,C=m?.get(x);if(C&&C.materialized===$)return C;let N=$?null:f?.get(x.index);return N&&Rt(N,x,y.scale,y.ariaHidden)?{record:x,materialized:false,element:N.element}:{record:x,materialized:$,element:ut(p,x,y,$)}});we.set(t,{parameters:h,pages:u}),t.dataset.revision=String(e.revision),i&&i.reconcile(de(e),ce(e));let b=new Set(u.map(x=>x.element)),S=t.firstChild;for(;S;){let x=S.nextSibling;b.has(S)||S.remove(),S=x;}let w=t.firstChild;for(let x of u){if(x.element===w){w=w.nextSibling;continue}t.insertBefore(x.element,w);}}function $t(t,e,n,o){let r=t.ownerDocument,a=o.scale,i=[];for(let s of n){let d=e.pages[s.pageIndex];if(!d)continue;let l=r.createElement("div");l.className=s.className??o.className??"docx-cell-selection-rect",l.style.position="absolute";let c=o.pageOffsetX?.get(s.pageIndex)??0;l.style.left=`${(d.contentBox.x+s.x+c)*a}px`,l.style.top=`${(d.contentBox.y+s.y)*a}px`,l.style.width=`${s.width*a}px`,l.style.height=`${s.height*a}px`,i.push(l);}t.replaceChildren(...i);}
|
|
2
|
-
exports.a=It;exports.b=U;exports.c=At;exports.d=K;exports.e=St;exports.f=$t;
|
package/dist/chunk-ZACHY6OS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {ne as ne$1,Ea,Ud,jd,md,kd,td,Tb,Sb,Qf,Pf,Od,re as re$1,le,pe,Gf,Hf,Jf,If,Rc,Ta,Tc,Ra,Kd,Md,bg,$f,eg,ag,fg,Ld,wg,xg,Hc,Gc,Ae,wd,jf,Ce,Bf,kg,la,Fa,Nf,Of,Fe,Ge,Ee,lg,ig,W as W$1,Be,Kc,Qa,Af}from'./chunk-TCX3PVWR.js';var Ht=Object.freeze(["default","first","even"]),ct=Object.freeze({kind:"body"});function B(n){switch(n.kind){case "body":return "body";case "note":return `note:${n.noteKind}:${String(n.noteId)}`;default:return `${n.kind}:${String(n.sectionIndex)}:${n.variant}`}}function tn(n){if(typeof n!="object"||n===null)return false;let e=n;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&&Ht.includes(e.variant)}var rr=["getDocument","getBody","getParagraphs","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"],qn=["insertText","replaceSpan","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],to=["deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],eo=new Set(to);function Yt(n){return eo.has(n.op)}var no=new Set(qn);function Gt(n){return no.has(n.op)}function oo(){let n=globalThis.crypto,e=n?.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 s=e.call(n,new Uint8Array(16)),a="";for(let l of s)a+=l.toString(16).padStart(2,"0");return a}function ro(n){return typeof n=="object"&&n!==null&&"kind"in n&&"ref"in n}function en(){let n=new Map,e=new Map,s=new Map,a=new Map,l=oo(),u=null,f=(m,y)=>{let v=(a.get(m)??0)+1;a.set(m,v);let g=`${m}:${l}:${String(v)}`;return n.set(g,y),Object.freeze({kind:m,ref:g})},k=(m,y,v)=>{let g=`${m}\0${y}`,I=s.get(g);if(I)return Object.freeze({kind:m,ref:I});let C=f(m,v);return s.set(g,C.ref),C};return {document(){return u??=f("document",{kind:"document"}),u},body(m){return k("body",B(m),{kind:"body",story:m})},paragraph(m,y){let v=e.get(m);if(v)return Object.freeze({kind:"paragraph",ref:v});let g=f("paragraph",{kind:"paragraph",paragraphId:m,story:y});return e.set(m,g.ref),g},section(m){return k("section",String(m),{kind:"section",index:m})},note(m,y){return k("note",`${m}:${String(y)}`,{kind:"note",noteKind:m,noteId:y})},comment(m,y){return k("comment",`${B(y)}\0${m}`,{kind:"comment",commentId:m,story:y})},revision(m,y){return k("revision",`${B(y)}\0${m}`,{kind:"revision",revisionId:m,story:y})},bookmark(m,y){return k("bookmark",`${B(y)}\0${m}`,{kind:"bookmark",name:m,story:y})},list(m,y){return k("list",`${B(y)}\0${m}`,{kind:"list",numId:m,story:y})},contentControl(m,y){return k("contentControl",`${B(y)}\0${m}`,{kind:"contentControl",nodeId:m,story:y})},retarget(m,y){let v=e.get(m);if(!v||m===y)return;let g=n.get(v);!g||g.kind!=="paragraph"||(e.delete(m),n.set(v,{kind:"paragraph",paragraphId:y,story:g.story}),e.has(y)||e.set(y,v));},resolve(m,y){if(!ro(m)||m.kind!==y||typeof m.ref!="string")return null;let v=n.get(m.ref);return !v||v.kind!==y?null:v}}}var ao=255,so=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false});function nn(n){let e=Hc(n);if(!e)return so;let s=new Map,a=new Map,l=null;for(let u of Gc(e).values())if(u.type==="paragraph"){if(s.set(u.styleId,u.name),u.name!==null){let f=u.name.trim().toLowerCase();a.has(f)||a.set(f,u.styleId);}u.isDefault&&l===null&&(l=u.styleId);}return Object.freeze({nameOf:u=>s.get(u)??null,idOf:u=>a.get(u.trim().toLowerCase())??null,defaultId:l,present:true})}function Lt(n,e,s){let a=Ea(n,e);if(!a||a.kind!=="paragraph")return null;let l=io(Md(Kd(a),"pStyle"));return l!==null?s.nameOf(l):s.defaultId===null?null:s.nameOf(s.defaultId)}function io(n){if(!n)return null;for(let e of n.attributes)if(e.localName==="val")return e.value;return null}function Et(n,e){if(typeof n!="string"||n.trim().length===0)return {ok:false,detail:"style: not a name"};if(n.length>ao)return {ok:false,detail:"style: name too long"};if(!W$1(n))return {ok:false,detail:"style: not valid XML text"};if(!e.present)return {ok:false,detail:"style: this document defines no styles"};let s=e.idOf(n);return s===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:s}}var rn=20,lo=31680,uo=1999,co=Object.freeze({bold:null,italic:null,name:null,size:null,color:null});function G(n,e){if(!n)return null;for(let s of n.attributes)if(s.localName===e)return s.value;return null}function Jt(n){if(!n)return null;let e=G(n,"val");if(e===null)return true;let s=e.trim().toLowerCase();return !(s==="0"||s==="false"||s==="off"||s==="none")}function po(n){if(n===null)return null;let e=n.trim();return /^[0-9a-fA-F]{6}$/.test(e)?`#${e.toUpperCase()}`:null}function mo(n){if(n===null)return null;let e=Number(n.trim());return !Number.isFinite(e)||e<=0?null:e/2}function mt(n){if(n===null)return null;let e=Number(n.trim());return Number.isFinite(e)?e/rn:null}function Rt(n){if(n.length===0)return null;let e=n[0];if(e===null)return null;for(let s of n)if(s!==e)return null;return e}function an(n,e){let s=[];for(let a of e)for(let l of fg(n,a.paragraphId,a.start,a.end))s.push(Ld(l));return s.length===0?co:{bold:Rt(s.map(a=>Jt(Md(a,"b")))),italic:Rt(s.map(a=>Jt(Md(a,"i")))),name:Rt(s.map(a=>{let l=Md(a,"rFonts"),u=G(l,"ascii");return u===null||u.length===0?null:u})),size:Rt(s.map(a=>mo(G(Md(a,"sz"),"val")))),color:Rt(s.map(a=>po(G(Md(a,"color"),"val"))))}}var fo=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),yo=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function go(n){let e=G(Md(n,"jc"),"val");return e===null?"Unknown":fo[e.trim().toLowerCase()]??"Unknown"}function sn(n,e,s){let a=Ea(n,e);if(!a||a.kind!=="paragraph")return null;let l=Kd(a),u=Md(l,"spacing"),f=Md(l,"ind");return {alignment:go(l),style:Lt(n,e,s),firstLineIndent:ho(f),leftIndent:mt(G(f,"left")??G(f,"start")),rightIndent:mt(G(f,"right")??G(f,"end")),lineSpacing:mt(G(u,"line")),spaceBefore:mt(G(u,"before")),spaceAfter:mt(G(u,"after")),widowControl:Jt(Md(l,"widowControl"))}}function ho(n){let e=mt(G(n,"firstLine"));if(e!==null)return e;let s=mt(G(n,"hanging"));return s===null?null:-s}function Mt(n,e){if(typeof n!="number"||!Number.isFinite(n))return {ok:false,detail:`${e}: not a measurement`};let s=Math.round(n*rn);return Math.abs(s)>lo?{ok:false,detail:`${e}: out of range`}:{ok:true,value:s}}function dn(n){let e=[];if(n.bold!==void 0){if(typeof n.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};e.push({localName:"b",...n.bold?{}:{attributes:{val:"0"}}});}if(n.italic!==void 0){if(typeof n.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};e.push({localName:"i",...n.italic?{}:{attributes:{val:"0"}}});}if(n.name!==void 0){let s=n.name;if(typeof s!="string"||s.length===0||s.length>128)return {ok:false,detail:"name: not a font name"};if(!W$1(s))return {ok:false,detail:"name: not valid XML text"};e.push({localName:"rFonts",attributes:{ascii:s,hAnsi:s,cs:s}});}if(n.size!==void 0){let s=n.size;if(typeof s!="number"||!Number.isFinite(s)||s<=0)return {ok:false,detail:"size: not a positive number of points"};let a=Math.round(s*2);if(a<1||a>uo)return {ok:false,detail:"size: out of range"};e.push({localName:"sz",attributes:{val:String(a)}}),e.push({localName:"szCs",attributes:{val:String(a)}});}if(n.color!==void 0){let s=n.color;if(typeof s!="string"||!/^#[0-9a-fA-F]{6}$/.test(s.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};e.push({localName:"color",attributes:{val:s.trim().slice(1).toUpperCase()}});}return e.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:e}}function ln(n,e,s,a){let l=Ea(n,e);if(!l||l.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let u=Kd(l),f=[];if(s.style!==void 0){let C=Et(s.style,a);if(!C.ok)return {ok:false,detail:C.detail};f.push({localName:"pStyle",attributes:{val:C.styleId}});}if(s.alignment!==void 0){let C=yo[s.alignment];if(C===void 0)return {ok:false,detail:`alignment: ${String(s.alignment)}`};f.push({localName:"jc",attributes:{val:C}});}let k=Md(u,"ind"),m=on(k),y=false;if(s.firstLineIndent!==void 0){let C=Mt(s.firstLineIndent,"firstLineIndent");if(!C.ok)return C;delete m.firstLine,delete m.hanging,C.value<0?m.hanging=String(-C.value):m.firstLine=String(C.value),y=true;}for(let[C,R,N]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let P=s[C];if(P===void 0)continue;let L=Mt(P,C);if(!L.ok)return L;delete m[N],m[R]=String(L.value),y=true;}y&&f.push({localName:"ind",attributes:m});let v=Md(u,"spacing"),g=on(v),I=false;for(let[C,R]of [["spaceBefore","before"],["spaceAfter","after"]]){let N=s[C];if(N===void 0)continue;let P=Mt(N,C);if(!P.ok)return P;if(P.value<0)return {ok:false,detail:`${C}: out of range`};g[R]=String(P.value),I=true;}if(s.lineSpacing!==void 0){let C=Mt(s.lineSpacing,"lineSpacing");if(!C.ok)return C;if(C.value<=0)return {ok:false,detail:"lineSpacing: out of range"};g.line=String(C.value),g.lineRule??="auto",I=true;}if(I&&f.push({localName:"spacing",attributes:g}),s.widowControl!==void 0){if(typeof s.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};f.push({localName:"widowControl",...s.widowControl?{}:{attributes:{val:"0"}}});}return f.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:bg($f(n,e),f)}}function on(n){let e=Object.create(null);if(!n)return e;for(let s of n.attributes)e[s.localName]=s.value;return e}function un(){let n=false,e=false,s=false;return {conflict(a){let l=Gt(a),u=Yt(a),f=a.op==="deleteComment";return u&&n||e&&l?{message:"that command commits on its own and cannot share a batch",detail:a.op}:f&&n&&!s||s&&l&&!f?{message:"comment deletions may share a batch only with other comment deletions",detail:a.op}:null},note(a){Gt(a)&&(n=true,Yt(a)&&(e=true),a.op==="deleteComment"&&(s=true));},get hasCommands(){return n}}}var cn=20,ko=63360;function lt(n){return Math.round(n/cn*100)/100}function Ao(n,e){if(typeof n!="number"||!Number.isFinite(n))return null;let s=Math.round(n*cn);return s>ko||s<0||s===0&&!e?null:s}var vo=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function pn(n){if(typeof n!="object"||n===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let e=n,s={},a=0;for(let[u,f,k]of vo){let m=e[u];if(m===void 0)continue;let y=Ao(m,k);if(y===null)return {ok:false,reason:`that is not a value for ${u}`,detail:String(m)};s[f]=y,a+=1;}let l=e.orientation;if(l!==void 0){if(l!=="portrait"&&l!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(l)};s.orientation=l,a+=1;}return a===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:s}}function bo(n){let e=jf(n),s=e.widthTwips>e.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:lt(e.widthTwips),pageHeight:lt(e.heightTwips),orientation:s,topMargin:lt(e.topTwips),rightMargin:lt(e.rightTwips),bottomMargin:lt(e.bottomTwips),leftMargin:lt(e.leftTwips),headerDistance:lt(e.headerTwips),footerDistance:lt(e.footerTwips),gutter:lt(e.gutterTwips)})}function Io(n,e){if(!e)return null;let s=null,a=(l,u,f)=>{if(s!==null||l.kind==="textValue"||f>64)return;let k=l.kind==="paragraph"?l.id:u;if(l.id===e.id){s=k;return}for(let m of l.children)a(m,k,f+1);};return a(n.root,null,0),s}function mn(n,e,s){let a=Sb(e.root);return Object.freeze(a.map((l,u)=>{let f=s[u];return Object.freeze({index:u,markParagraphId:Io(e,l),pageSetup:bo(l),titlePage:f?.titlePage??false,evenAndOddHeaders:f?.evenAndOddHeaders??false})}))}var Zt="\r",xo=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false}),So=Object.freeze([]),Ro=Object.freeze([]),fn=Object.freeze([]),Co=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>Ro,furniture:()=>fn,noteIds:()=>({ok:true,ids:gn}),styles:()=>xo});function Oo(n){return n.kind==="textValue"?So:Object.freeze(n.children.filter(e=>e.kind!=="textValue").map(e=>{let s=[];Ce([e],s,0);let a=e.kind==="paragraph"?"paragraph":e.kind==="table"?"table":"other",l=e.kind==="paragraph"&&Md(Kd(e),"sectPr")!==void 0;return Object.freeze({id:e.id,kind:a,paragraphIds:Object.freeze(s.map(u=>u.id)),removable:a!=="other"&&!l})}))}function Qt(n,e,s,a,l){let u=Be(a),f=Object.freeze(u.map(g=>g.id)),k=new Map,m=new Map;u.forEach((g,I)=>{k.set(g.id,I),m.set(g.id,g);});let y=new Map,v=g=>{if(!k.has(g))return null;let I=y.get(g);if(I!==void 0)return I;let C=Af(e,g)??"";return y.set(g,C),C};return {story:n,part:e,root:a,scope:s,paragraphIds:f,blocks:Oo(a),has:g=>k.has(g),indexOf:g=>k.get(g)??-1,paragraph(g){let I=m.get(g);return I?{nodeId:g,paraId:Kc(I),text:v(g)??""}:null},node:g=>m.get(g)??null,paragraphText:v,text:()=>f.map(g=>v(g)??"").join(Zt),styles:l}}function yn(n){let e=n.parts.get(n.mainDocumentPart);if(!e)return Co;let s,a=()=>s??=nn(n),l,u=()=>l??=Tb(n),f,k=new Map,m=new Map,y=R=>{let N=m.get(R);if(N)return N;let P=Ud(n,R);if(!P){let X={ok:true,ids:gn};return m.set(R,X),X}let L=[],M=new Set,j=new Set,Z=0,U=false;for(let X of P.root.children){if(jd(X)!==R)continue;if(Z+=1,X.kind!=="note"){U=true;continue}if(!md(X))continue;let et=kd(X);if(et===null){U=true;continue}M.has(et)?j.add(et):(M.add(et),L.push(et));}let E=Z>td?{ok:false,reason:"truncated"}:U?{ok:false,reason:"malformed"}:j.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...j])}:{ok:true,ids:Object.freeze(L)};return m.set(R,E),E},v=R=>{let N=u()[R.sectionIndex];return N?(R.kind==="header"?N.headers:N.footers).get(R.variant)??null:null},g=R=>{if(R.kind==="body"){let P=Ae(e);return P?Qt(R,e,{kind:"body"},P,a):null}if(R.kind==="note"){let P=y(R.noteKind);if(!P.ok||!P.ids.includes(R.noteId))return null;let L=Ud(n,R.noteKind);if(!L)return null;let M=wd(L.root,R.noteId);return !M||!md(M)?null:Qt(R,L,{kind:"notesPart",noteKind:R.noteKind},M,a)}let N=v(R);return N?Qt(R,N.part,{kind:"headerFooter",rId:N.rId},N.part.root,a):null},I=R=>{let N=B(R);if(k.has(N))return k.get(N)??null;let P=g(R);return k.set(N,P),P};return {package:n,get body(){return I(ct)},story:I,storyOf:R=>{if(I(ct)?.has(R))return ct;for(let[P]of u().entries())for(let L of ["header","footer"])for(let M of Ht){let j={kind:L,sectionIndex:P,variant:M};if(I(j)?.has(R))return j}for(let P of ["footnote","endnote"]){let L=y(P);if(L.ok)for(let M of L.ids){let j={kind:"note",noteKind:P,noteId:M};if(I(j)?.has(R))return j}}return null},sections:()=>f??=mn(n,e,u()),furniture(R){let N=u()[R];if(!N)return fn;let P=[];for(let L of ["header","footer"]){let M=L==="header"?N.headers:N.footers;for(let j of Ht){let Z=M.get(j);Z&&P.push(Object.freeze({kind:L,variant:j,declared:!Z.inherited}));}}return Object.freeze(P)},noteIds:y,styles:a}}var gn=Object.freeze([]);function ot(n,e){return {ok:false,code:n,detail:e}}function rt(n){return {ok:true,value:n}}function K(n,e,s,a){let l=s.resolve(n,e);if(!l||l.kind!=="body"&&l.kind!=="paragraph")return ot("invalid-handle",`not-a-${e}-handle`);let u=a.story(l.story);return u?rt(u):ot("invalid-handle",`no-such-story:${B(l.story)}`)}function Q(n,e,s){let a=e.resolve(n,"paragraph");if(!a||a.kind!=="paragraph")return ot("invalid-handle","not-a-paragraph-handle");let l=s.story(a.story);if(!l)return ot("invalid-handle",`no-such-story:${B(a.story)}`);let u=l.indexOf(a.paragraphId);return u<0?ot("invalid-handle","paragraph-not-in-body"):rt({story:a.story,paragraphId:a.paragraphId,index:u,offset:0})}function Po(n,e,s){let a=Q(n.paragraph,e,s);if(!a.ok)return a;let u=(s.story(a.value.story)?.paragraphText(a.value.paragraphId)??"").length,{offset:f}=n;return !Number.isInteger(f)||f<0||f>u?ot("invalid-offset",`offset ${String(f)} outside 0..${String(u)}`):rt({...a.value,offset:f})}function gt(n,e,s){if("paragraph"in n){if(!("at"in n))return Po(n,e,s);let k=Q(n.paragraph,e,s);if(!k.ok||n.at==="start")return k;let y=(s.story(k.value.story)?.paragraphText(k.value.paragraphId)??"").length;return rt({...k.value,offset:y})}let a=K(n.body,"body",e,s);if(!a.ok)return a;let l=a.value.paragraphIds;if(l.length===0)return ot("invalid-offset","empty-story");if(n.at==="start")return rt({story:a.value.story,paragraphId:l[0],index:0,offset:0});let u=l.length-1,f=l[u];return rt({story:a.value.story,paragraphId:f,index:u,offset:(a.value.paragraphText(f)??"").length})}function wo(n,e){return n.index<e.index||n.index===e.index&&n.offset<=e.offset}function To(n){let e=n.paragraphIds;if(e.length===0)return null;let s=e.length-1,a=e[s];return {start:{story:n.story,paragraphId:e[0],index:0,offset:0},end:{story:n.story,paragraphId:a,index:s,offset:(n.paragraphText(a)??"").length}}}function W(n,e,s){if("body"in n){let u=K(n.body,"body",e,s);return u.ok?rt(To(u.value)):u}if("paragraph"in n){let u=Q(n.paragraph,e,s);if(!u.ok)return u;let k=(s.story(u.value.story)?.paragraphText(u.value.paragraphId)??"").length;return rt({start:u.value,end:{...u.value,offset:k}})}let a=gt(n.start,e,s);if(!a.ok)return a;let l=gt(n.end,e,s);return l.ok?B(a.value.story)!==B(l.value.story)?ot("invalid-handle","span-crosses-stories"):wo(a.value,l.value)?rt({start:a.value,end:l.value}):ot("invalid-offset","span-start-after-end"):l}function q(n,e,s){if("body"in n)return K(n.body,"body",e,s);if("paragraph"in n)return K(n.paragraph,"paragraph",e,s);let a=n.start;return "paragraph"in a?K(a.paragraph,"paragraph",e,s):K(a.body,"body",e,s)}function _t(n,e,s){if("paragraph"in n)return Q(n.paragraph,e,s);let a=K(n.body,"body",e,s);if(!a.ok)return a;let l=a.value.paragraphIds;if(l.length===0)return ot("invalid-offset","empty-story");let u=n.at==="first"?0:l.length-1;return rt({story:a.value.story,paragraphId:l[u],index:u,offset:0})}function at(n,e){return n?e.paragraphIds.slice(n.start.index,n.end.index+1):[]}function qt(n,e){if(!n)return [];let s=at(n,e),a=s.length-1;return s.map((l,u)=>{let f=(e.paragraphText(l)??"").length,k=u===0?n.start.offset:0,m=u===a?n.end.offset:f;return {paragraphId:l,start:k,end:m,whole:k===0&&m===f}})}function hn(n,e,s){if(!n)return "";let a=at(n,e);return a.length===1?(e.paragraphText(n.start.paragraphId)??"").slice(n.start.offset,n.end.offset):a.map((l,u)=>{let f=e.paragraphText(l)??"";return u===0?f.slice(n.start.offset):u===a.length-1?f.slice(0,n.end.offset):f}).join(s)}function te(n,e){return {start:{paragraph:e.paragraph(n.start.paragraphId,n.start.story),offset:n.start.offset},end:{paragraph:e.paragraph(n.end.paragraphId,n.end.story),offset:n.end.offset}}}var No=256,kn=1e4;function ee(n,e){if(n.kind!=="textValue"){for(let s of n.attributes)if(s.namespaceUri===la&&s.localName===e)return s.value}}function Ho(n){return n.startsWith("_")}function ne(n){let e=new Map,s=[],a=new Set;for(let l of n.paragraphIds){let u=n.node(l);if(u?.kind!=="paragraph")continue;let f=Od(u),k=m=>{if(m.kind!=="textValue"){if(m.kind==="bookmarkStart"){if(s.length>=kn||e.size>=kn)return;let y=ee(m,"id"),v=ee(m,"name");if(y===void 0||v===void 0||v.length===0||v.length>No||Ho(v)||a.has(v)||e.has(y))return;let g=f.spanOf(m)?.start??0;e.set(y,{name:v,start:{paragraphId:l,offset:g}});return}if(m.kind==="bookmarkEnd"){let y=ee(m,"id");if(y===void 0)return;let v=e.get(y);if(!v)return;e.delete(y),a.add(v.name);let g=f.spanOf(m)?.start??0;s.push(Object.freeze({name:v.name,start:v.start,end:{paragraphId:l,offset:g}}));return}for(let y of m.children)k(y);}};for(let m of u.children)k(m);}return Object.freeze(s)}function oe(n,e){return ne(n).find(s=>s.name===e)??null}function An(n,e){let s=n.node(e);if(s?.kind!=="paragraph")return Object.freeze([]);let a=Od(s),l=[],u=(f,k)=>{if(!(f.kind==="textValue"||k>32)){if(Qa(f)){let m=a.spanOf(f);m&&l.push(Object.freeze({id:f.id,paragraphId:e,start:m.start,end:m.end}));return}for(let m of f.children)u(m,k+1);}};for(let f of s.children)u(f,0);return Object.freeze(l)}function vn(n,e,s){let a=Ta(s,l=>Tc(n,e,l));if(a.kind==="external")return a.href;if(a.kind==="internal"){let l=Ra(s);return l===void 0||l.length===0?null:`#${l}`}return null}var ht=8;function bn(n){if(!n||n.kind==="textValue")return null;for(let e of n.attributes)if(e.namespaceUri===la&&e.localName==="val")return e.value;return null}function In(n){let e=Md(Kd(n),"numPr");if(!e)return null;let s=bn(Md(e,"numId"));if(s===null||!/^\d{1,10}$/.test(s)||s==="0")return null;let a=bn(Md(e,"ilvl")),l=a===null?0:Number(a);return !Number.isInteger(l)||l<0||l>ht?null:{numId:s,level:l}}function Bt(n){let e=new Map;for(let s of n.paragraphIds){let a=n.node(s);if(!a)continue;let l=In(a);if(!l)continue;let u=e.get(l.numId);u?u.push(s):e.set(l.numId,[s]);}return Object.freeze([...e].map(([s,a])=>Object.freeze({numId:s,paragraphIds:Object.freeze(a)})))}function Ct(n,e){let s=n.node(e);return s?In(s):null}var Lo={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function Eo(n){return n.kind==="note"}function Mo(n,e){return e.length===0?!Eo(n.story):e.every(s=>n.has(s.start.paragraphId))}function _o(n){return Object.freeze(kg(n.part).filter(e=>Mo(n,e.ranges)))}function re(n){let e=[];for(let s of _o(n)){if(s.readOnly||s.revisionKind==="structural")continue;let a=Lo[s.revisionKind];a!==void 0&&e.push(Object.freeze({id:s.id,type:a,author:s.author,date:s.date??"",item:s}));}return Object.freeze(e)}function Bo(n,e){let s=n;for(let a=0;s!==void 0&&a<=64;a+=1){if(s.parentId===void 0)return s.range!==null;s=e.get(s.parentId);}return false}var Fo=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function xn(n,e){let s=n.parts.get(Nf(n,e.part.name));if(!s)return Fo;let a=n.parts.get(Of(n,e.part.name)),l=Fe(s),u=a?Ge(a):new Map,f=Ee(e.part).filter(g=>e.has(g.start.paragraphId)),k=lg(l,f,u),m=new Map(k.map(g=>[g.id,g])),y=k.filter(g=>Bo(g,m)),v=new Map(y.map(g=>[g.id,g]));return Object.freeze({items:Object.freeze(y),roots:Object.freeze(y.filter(g=>g.parentId===void 0)),byId:g=>v.get(g)??null,textOf:g=>{let I=v.get(g);return I?ig(I.comment):""}})}function Sn(n,e,s){if("body"in n){let a=K(n.body,"body",e,s);return a.ok?{ok:true,reads:a.value}:{ok:false,code:a.code,message:"that handle does not name a body",detail:a.detail}}return e.resolve(n.document,"document")?s.body?{ok:true,reads:s.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 Rn(n,e){let s=n.op==="acceptAllRevisions",a=e.story.kind==="note"?{scopeRootId:e.root.id}:{};return [s?{op:"acceptAllRevisions",...a}:{op:"rejectAllRevisions",...a}]}var jo=/[\r\n\u2028\u2029]/u,On=Object.freeze({kind:"applied"});function kt(n,e,s){return {ok:false,error:Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}}function ae(n,e){return kt("unsupported-content",n==="author"?"a comment records who wrote it":n==="date"?"a comment date must be a valid ISO-8601 instant":e==="reply"?"a reply says something":"a comment says something",n)}function se(n){return Gf(n.author)?ae("author",n.kind):Hf(n.text)?ae("text",n.kind):typeof n.text=="string"&&jo.test(n.text)?kt("unsupported-content",n.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):Jf(n.date)?ae("date",n.kind):null}function ie(n){if(n===void 0)return;let e=If(n);return e.ok?e.value:void 0}function Cn(n,e){let s=Ea(n.part,e);for(;s;){if(s.kind==="tableCell"||s.kind!=="textValue"&&s.namespaceUri===la&&s.localName==="tc")return s.id;s=Fa(n.part,s.id);}return null}function Pn(n,e,s,a){let l=se({author:n.author,text:n.text,date:n.date,kind:"comment"});if(l)return l;let u=W(n.span,e,s);if(!u.ok)return kt(u.code,"that span is not a place",u.detail);if(u.value===null)return kt("invalid-handle","an empty story has no comment anchor");let f=q(n.span,e,s);if(!f.ok)return kt(f.code,"that span is not a place",f.detail);let k=u.value;if(Cn(f.value,k.start.paragraphId)!==Cn(f.value,k.end.paragraphId))return kt("unsupported-content","a comment range cannot cross a table-cell boundary");let m=a(f.value);if(m)return m;let y=ie(n.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:k.start.paragraphId,start:k.start.offset,end:k.end.offset,...k.end.paragraphId===k.start.paragraphId?{}:{endParagraphId:k.end.paragraphId}},text:n.text,author:n.author,...y===void 0?{}:{date:y}},story:f.value.story,answer:(g,I)=>I===void 0?On:{kind:"handle",handle:e.comment(I,f.value.story)}}}function wn(n,e,s){let a=s(e);if(a)return a;let l=e.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:n.id,...n.parentId===void 0?{}:{parentCommentId:n.parentId},...l.kind==="note"?{noteId:l.noteId}:{}},story:l,answer:()=>On}}var Do=1e4;function Tn(n,e){let s=[],a=e.kind==="contentControl"?le(e):e;if(!a)return s;for(let l of pe(a))if(!(l.ancestors.length>0)){if(s.length>=Do)break;s.push(En(n,l.node));}return s}function Nn(n,e){for(let s of pe(n.root))if(s.node.id===e)return En(n,s.node);return null}function Hn(n,e){for(let s of pe(n.root))if(s.node.id===e)return s.node;return null}function de(n,e){let s=Mn(e);if(s.length>0){let a=s[0],l=s[s.length-1],u=n.paragraphText(l);return u===null||!n.has(a)?null:{start:{paragraphId:a,offset:0},end:{paragraphId:l,offset:u.length}}}for(let a of n.paragraphIds){let l=n.node(a);if(!l||l.kind!=="paragraph"||!l.children.some(f=>f.id===e.id))continue;let u=Od(l).spanOf(e);return u?{start:{paragraphId:a,offset:u.start},end:{paragraphId:a,offset:u.end}}:null}return null}function Ln(n){return re$1(n)}function En(n,e){return {nodeId:e.id,properties:ne$1(e),lock:Bf(n.part,e.id),paragraphIds:Mn(e)}}function Mn(n){let e=le(n);if(!e)return [];let s=[];return Ce(e.children,s,0),s.map(a=>a.id)}var Wo=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),zo=4096,_n=64;function Bn(n){if(n===void 0)return {ok:true,value:null};if(typeof n!="object"||n===null)return {ok:false,field:"payload"};let e=n;for(let s of ["namespaceUri","rootLocalName","nodeId"]){let a=e[s];if(typeof a!="string"||a.length===0||a.length>zo)return {ok:false,field:s}}return typeof e.label!="string"||e.label.length>Qf?{ok:false,field:"label"}:typeof e.data!="string"||e.data.length===0||e.data.length>Pf?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:e.namespaceUri,rootLocalName:e.rootLocalName,nodeId:e.nodeId,label:e.label,data:e.data}}}function Fn(n){let e=n.at!==void 0,s=n.span!==void 0;return e===s?{message:"a custom node goes at a position or over a span, not both",detail:e?"at+span":"no-place"}:typeof n.tag!="string"||n.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:n.tag.length>_n?{message:`w:tag caps at ${String(_n)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof n.text!="string"||n.text.length===0?{message:"a custom node shows some text",detail:"text"}:n.lock!==void 0&&!Wo.has(n.lock)?{message:"that is not a lock",detail:String(n.lock)}:null}function jn(n,e,s,a){return {paragraphId:e.paragraphId,offset:e.offset,...s.offset>e.offset?{replaceUntil:s.offset}:{},tag:n.tag,text:n.text,...n.title===void 0?{}:{alias:n.title},...n.lock===void 0||n.lock==="unlocked"?{}:{lock:n.lock},...a===null?{}:{payload:a}}}function Dn(n,e,s){if(n.span){let l=W(n.span,e,s);return l.ok?l.value?l.value.start.paragraphId!==l.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:l.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:l.code,message:"that span is not a place",detail:l.detail}}let a=gt(n.at,e,s);return a.ok?{range:{start:a.value,end:a.value}}:{code:a.code,message:"that is not a place",detail:a.detail}}var Ft=/[\r\n\v\f\u2028\u2029]/,Ko=16,Vo=64,Wn=/\s/;function $o(n,e,s){return Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}function d(n,e,s){return {ok:false,error:$o(n,e,s)}}var F=Object.freeze({kind:"applied"});function b(n){return {ok:true,kind:"query",value:n}}function zn(n){let e=n.kind==="contentControl"?le(n):n;return e?pe(e).map(s=>s.node):[]}var Uo=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),Xo=new Set(["whole","content","start","end","before","after"]),Yo=new Set(["richText","plainText","dropDownList","comboBox","date"]),Go=4096;function Jo(n){let e=(l,u)=>({ok:false,code:"unsupported-content",message:l,detail:u});if(typeof n!="object"||n===null||!("kind"in n))return e("a control value states its kind","value");let s=n,a=s.kind;if(a==="text"||a==="listItem"){let l=a==="text"?s.text:s.value;return typeof l!="string"?e("that value is not a string",String(a)):l.length>Go?e("that value is too long",String(l.length)):{ok:true,value:a==="text"?{kind:"text",text:l}:{kind:"listItem",value:l}}}if(a==="checkbox"){let l=s.checked;return typeof l!="boolean"?e("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:l}}}if(a==="date"){let l=s.iso;return typeof l!="string"?e("a date is an ISO-8601 string","iso"):l.length>64?e("that is not a date",String(l.length)):{ok:true,value:{kind:"date",iso:l}}}return e("that is not a value any control accepts",String(a))}function Qo(n,e){let s=[],a=0;for(;a<n.length;){let l=null;for(let u of e){let f=n.indexOf(u,a);f<0||(!l||f<l.start||f===l.start&&u.length>l.length)&&(l={start:f,length:u.length});}if(!l)break;s.push(l),a=l.start+l.length;}return s}function Zo(n,e,s){let a=e[s]?.markParagraphId??null;if(a!==null)return a;let l=n.paragraphIds,u=l[l.length-1];return u===void 0||new Set(e.map(k=>k.markParagraphId).filter(k=>k!==null)).has(u)?null:u}function qo(n,e){for(let s of [n.start,n.end]){let a=e.paragraphText(s.paragraphId);if(a===null||s.offset>a.length)return false}return true}function tr(n,e,s){let a=e,l=s;for(;a<l&&Wn.test(n[a]);)a+=1;for(;l>a&&Wn.test(n[l-1]);)l-=1;return [a,l]}function Kn(n){let{handles:e,capabilities:s}=n,a=n.reads,l=new Map,u=r=>{let t=B(r.story),o=l.get(t);if(o)return o;let i=new Map,c=r.paragraphIds.map(h=>{let A={id:h};return i.set(h,A),A}),p={reads:r,order:c,slotById:i,created:[],restructured:new Set,touched:new Set,formatted:new Set,selected:new Set,retargets:[]};return l.set(t,p),p},f=[],k=un(),m=null,y=r=>m===null?(m=r,null):m===r?null:d("conflicting-operations","one batch writes into one story",`${B(m.reads.story)} then ${B(r.reads.story)}`),v=r=>y(u(r)),g=r=>{let t=a.package;return t===null?null:xn(t,r)},I=r=>{let t=e.resolve(r,"comment");if(!t||t.kind!=="comment")return {ok:false,planned:d("invalid-handle","that handle does not name a comment","comment")};let o=a.story(t.story);if(!o)return {ok:false,planned:d("invalid-handle","that story is not in this document")};let c=g(o)?.byId(t.commentId)??null;return c?{ok:true,reads:o,item:c}:{ok:false,planned:d("invalid-handle","this document no longer holds that comment",t.commentId)}},C=r=>{let t=e.resolve(r,"revision");if(!t||t.kind!=="revision")return {ok:false,planned:d("invalid-handle","that handle does not name a tracked change","revision")};let o=a.story(t.story);if(!o)return {ok:false,planned:d("invalid-handle","that story is not in this document")};let i=re(o).find(c=>c.id===t.revisionId)??null;return i?{ok:true,reads:o,item:i}:{ok:false,planned:d("invalid-handle","this document no longer holds that tracked change",t.revisionId)}},R=(r,t)=>{let o=r.paragraphText(t.start.paragraphId),i=r.paragraphText(t.end.paragraphId);if(o===null||i===null)return null;let c={story:r.story,paragraphId:t.start.paragraphId,index:r.indexOf(t.start.paragraphId),offset:Math.min(t.start.offset,o.length)},p={story:r.story,paragraphId:t.end.paragraphId,index:r.indexOf(t.end.paragraphId),offset:Math.min(t.end.offset,i.length)};return U({start:c,end:p})},N=(r,t)=>r.order.indexOf(t),P=(r,t)=>r.selected.has(t)?d("conflicting-operations","this batch selects a paragraph it also edits",t):null,L=(r,t)=>{let o=P(r,t);return o||(r.restructured.has(t)||r.touched.has(t)?d("conflicting-operations","another operation in this batch already changes that paragraph",t):(r.restructured.add(t),r.touched.add(t),null))},M=(r,t)=>{let o=P(r,t);return o||(r.restructured.has(t)?d("conflicting-operations","another operation in this batch restructures that paragraph",t):(r.touched.add(t),null))},j=(r,t,o)=>{let i=`${o}:${t}`;if(r.formatted.has(i))return d("conflicting-operations","another operation in this batch already writes that formatting",t);let c=M(r,t);return c||(r.formatted.add(i),null)},Z=(r,t)=>{let o={id:null};return r.order.splice(t,0,o),r.created.push(o),o},U=r=>te(r,e),E=r=>r===null?null:a.story(r.start.story),X=(r,t,o,i)=>{if(i?.matchWildcards===true)return d("unsupported-capability","wildcard search is not implemented","matchWildcards");if(i?.ignorePunct===true)return d("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(i?.ignoreSpace===true)return d("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!wg(o))return d("unsupported-content","that is not a query this host will scan for","text");let c=i?.limit;if(c!==void 0&&(!Number.isInteger(c)||c<0))return d("invalid-offset","limit must be a non-negative integer",String(c));let p=Math.min(c??2e3,2e3),h=[],A=at(t,r),x=A.length-1;for(let[w,T]of A.entries()){if(p<=0)break;let _=r.paragraphText(T)??"",O=xg(_,o,p,{matchCase:i?.matchCase===true,wholeWord:i?.matchWholeWord===true,...w===0&&t?{from:t.start.offset}:{},...w===x&&t?{to:t.end.offset}:{}});for(let S of O.matches){let Y=e.paragraph(T,r.story);h.push({start:{paragraph:Y,offset:S.start},end:{paragraph:Y,offset:S.start+S.length}});}p-=O.matches.length;}return b({kind:"spans",spans:h})},et=(r,t,o)=>{if(typeof o!="string")return d("unsupported-content","insertText needs text","text");if(Ft.test(o))return d("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let i=y(r);if(i)return i;let c=M(r,t.paragraphId);if(c)return c;let p=o.length===0?[]:[{op:"insertText",paragraphId:t.paragraphId,offset:t.offset,text:o}],h=()=>({kind:"span",span:U({start:t,end:{...t,offset:t.offset+o.length}})});return {ok:true,kind:"command",ops:p,story:r.reads.story,answer:h}},At=(r,t,o)=>{let i=r.reads;if(typeof o!="string")return d("unsupported-content","replaceSpan needs text","text");if(Ft.test(o))return d("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let c=at(t,i),p=t.start.paragraphId,h=[],A=y(r);if(A)return A;if(c.length===1){let T=M(r,p);if(T)return T;t.end.offset>t.start.offset&&h.push({op:"deleteText",paragraphId:p,start:t.start.offset,end:t.end.offset});}else {for(let O of c){let S=L(r,O);if(S)return S}let T=t.end.paragraphId,_=(i.paragraphText(p)??"").length;t.start.offset<_&&h.push({op:"deleteText",paragraphId:p,start:t.start.offset,end:_}),t.end.offset>0&&h.push({op:"deleteText",paragraphId:T,start:0,end:t.end.offset});for(let O of c.slice(1,-1))h.push({op:"deleteBlock",blockId:O});h.push({op:"joinParagraphs",firstId:p,secondId:T});for(let O of c.slice(1)){let S=r.slotById.get(O);S&&r.order.splice(N(r,S),1);}}o.length>0&&h.push({op:"insertText",paragraphId:p,offset:t.start.offset,text:o});let x={...t.start,paragraphId:p},w=()=>({kind:"span",span:U({start:x,end:{...x,offset:x.offset+o.length}})});return {ok:true,kind:"command",ops:h,story:r.reads.story,answer:w}},Ot=(r,t)=>{let o=r.reads;if(typeof t!="string")return d("unsupported-content","replaceSpan needs text","text");if(Ft.test(t))return d("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let i=o.blocks,c=i.filter(S=>S.removable),p=i.filter(S=>!S.removable).flatMap(S=>S.paragraphIds),h=p.length===0?c.find(S=>S.kind==="paragraph"):void 0;if(!h&&p.length===0)return d("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let A=y(r);if(A)return A;for(let S of o.paragraphIds){let Y=L(r,S);if(Y)return Y}let x=[],w=(h?[h.id]:[...p]).sort((S,Y)=>o.indexOf(S)-o.indexOf(Y)),T=w[0];for(let S of w){let Y=(o.paragraphText(S)??"").length;Y>0&&x.push({op:"deleteText",paragraphId:S,start:0,end:Y});}for(let S of c)S.id!==h?.id&&x.push({op:"deleteBlock",blockId:S.id});t.length>0&&x.push({op:"insertText",paragraphId:T,offset:0,text:t});for(let S of c)if(S.id!==h?.id)for(let Y of S.paragraphIds){let Pt=r.slotById.get(Y);Pt&&r.order.splice(N(r,Pt),1);}let _={story:o.story,paragraphId:T,index:o.indexOf(T),offset:0},O=()=>({kind:"span",span:U({start:_,end:{..._,offset:t.length}})});return {ok:true,kind:"command",ops:x,story:o.story,answer:O}},jt=(r,t,o,i)=>{let c=r.reads;if(typeof i!="string")return d("unsupported-content","insertParagraph needs text","text");if(Ft.test(i))return d("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let p=y(r);if(p)return p;let h=L(r,t.paragraphId);if(h)return h;let A=r.slotById.get(t.paragraphId);if(!A)return d("invalid-handle","that paragraph is not in the body");let x=(c.paragraphText(t.paragraphId)??"").length,w=[];o==="after"?(i.length>0&&w.push({op:"insertText",paragraphId:t.paragraphId,offset:x,text:i}),w.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:x})):(i.length>0&&w.push({op:"insertText",paragraphId:t.paragraphId,offset:0,text:i}),w.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:i.length}));let T=Z(r,N(r,A)+1);o==="before"&&r.retargets.push({from:t.paragraphId,slot:T});let _=()=>{let O=o==="after"?T.id:t.paragraphId;return O===null?F:{kind:"handle",handle:e.paragraph(O,c.story)}};return {ok:true,kind:"command",ops:w,story:c.story,answer:_}},H=(r,t,o,i,c)=>{let p=r.reads;if(!Array.isArray(o)||o.length===0)return d("unsupported-content","split needs at least one delimiter","delimiters");if(o.length>Ko)return d("unsupported-content","too many delimiters",String(o.length));for(let V of o){if(typeof V!="string"||V.length===0)return d("unsupported-content","a delimiter must be a non-empty string","delimiters");if(V.length>Vo)return d("unsupported-content","that delimiter is too long","delimiters")}let h=y(r);if(h)return h;let A=L(r,t.paragraphId);if(A)return A;let x=r.slotById.get(t.paragraphId);if(!x)return d("invalid-handle","that paragraph is not in the body");let w=p.paragraphText(t.paragraphId)??"",T=Qo(w,o),_=[],O=[],S=[];if(T.length===0)S.push(w);else if(i){for(let $ of [...T].reverse())_.push({op:"deleteText",paragraphId:t.paragraphId,start:$.start,end:$.start+$.length});let V=0,ut=0;for(let $ of T){let zt=$.start-V;O.push(zt),S.push(w.slice(ut,$.start)),ut=$.start+$.length,V+=$.length;}S.push(w.slice(ut));}else {let V=0;for(let ut of T){let $=ut.start+ut.length;O.push($),S.push(w.slice(V,$)),V=$;}S.push(w.slice(V));}O.length>0&&_.push({op:"splitParagraphMany",paragraphId:t.paragraphId,offsets:O});let Y=[x];for(let V=0;V<O.length;V+=1)Y.push(Z(r,N(r,x)+1+V));let Pt=V=>{let ut=V.story(p.story),$=[];return Y.forEach((zt,Jn)=>{let Kt=zt.id;if(Kt===null)return;let Vt=ut?.paragraphText(Kt)??S[Jn]??"",[Qn,Zn]=c?tr(Vt,0,Vt.length):[0,Vt.length],pe=e.paragraph(Kt,p.story);$.push({start:{paragraph:pe,offset:Qn},end:{paragraph:pe,offset:Zn}});}),{kind:"spans",spans:$}};return {ok:true,kind:"command",ops:_,story:p.story,answer:Pt}},z=(r,t)=>{let o=y(r);if(o)return o;let i=L(r,t.paragraphId);if(i)return i;let c=r.slotById.get(t.paragraphId);return c&&r.order.splice(N(r,c),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:t.paragraphId}],story:r.reads.story,answer:()=>F}},st=(r,t,o)=>{let i=r.reads,c=i.part,p=y(r);if(p)return p;let h=dn(o??{});if(!h.ok)return d("unsupported-content","that is not formatting this host writes",h.detail);let A=[];for(let x of qt(t,i)){if(x.end<=x.start&&!x.whole)continue;let w=j(r,x.paragraphId,"runs");if(w)return w;for(let T of eg(c,x.paragraphId,x.start,x.end,h.value))A.push({op:"setRunProperties",paragraphId:x.paragraphId,start:T.start,end:T.end,properties:T.properties,...T.targetRunIds?{targetRunIds:T.targetRunIds}:{}});x.whole&&A.push({op:"setParagraphMarkProperties",paragraphId:x.paragraphId,properties:bg(ag(c,x.paragraphId),h.value)});}return A.length===0?d("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:A,story:i.story,answer:()=>F}},vt=(r,t,o)=>{let i=r.reads,c=i.part,p=y(r);if(p)return p;let h=Et(o,i.styles());if(!h.ok)return d("unsupported-content","that is not a style this document has",h.detail);let A={localName:"pStyle",attributes:{val:h.styleId}},x=[];for(let w of at(t,i)){let T=j(r,w,"paragraph");if(T)return T;x.push({op:"setParagraphProperties",paragraphId:w,properties:bg($f(c,w),A)});}return x.length===0?d("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:x,story:i.story,answer:()=>F}},pt=(r,t,o)=>{let i=r.reads,c=i.part,p=y(r);if(p)return p;let h=ln(c,t.paragraphId,o??{},i.styles());if(!h.ok)return d("unsupported-content","that is not paragraph formatting this host writes",h.detail);let A=j(r,t.paragraphId,"paragraph");return A||{ok:true,kind:"command",ops:[{op:"setParagraphProperties",paragraphId:t.paragraphId,properties:h.value}],story:i.story,answer:()=>F}},Vn=(r,t)=>{let o=a.body;if(!o)return d("document-unavailable","this host holds no document right now");let i=a.sections();if(!i[r])return d("invalid-handle","that section is not in this document");let p=pn(t);if(!p.ok)return d("unsupported-content",p.reason,p.detail);let h=Zo(o,i,r);if(h===null)return d("unsupported-content","that section holds no paragraph to address it by","no-anchor");let A=u(o),x=y(A);return x||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...p.value,anchorParagraphId:h}],story:ct,answer:()=>F}},$n=(r,t)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:r,noteId:t}],story:ct,lifecycle:true,answer:()=>F}),Dt=r=>{let t=e.resolve(r,"list");if(!t||t.kind!=="list")return d("invalid-handle","that handle does not name a list","list");let o=a.story(t.story);if(!o)return d("invalid-handle","that story is not in this document");let i=Bt(o).find(c=>c.numId===t.numId);return i?{ok:true,plan:u(o),list:i}:d("invalid-handle","this story numbers nothing with that list",t.numId)},Wt=r=>{if(typeof r!="object"||r===null)return d("invalid-handle","that is not a scope a control lives in","scope");let t=r;if("body"in r){let o=K(t.body,"body",e,a);return o.ok?{reads:o.value,node:o.value.root}:d(o.code,"that handle does not name a body",o.detail)}if("contentControl"in r){let o=nt(t.contentControl);return "control"in o?{reads:o.reads,node:o.node}:o}return d("invalid-handle","that is not a scope a control lives in","scope")},nt=r=>{let t=e.resolve(r,"contentControl");if(!t||t.kind!=="contentControl")return d("invalid-handle","that handle does not name a content control","contentControl");let o=a.story(t.story);if(!o)return d("invalid-handle","that story is not in this document");let i=Nn(o,t.nodeId),c=Hn(o,t.nodeId);return !i||!c?d("invalid-handle","this document no longer holds that content control"):{reads:o,control:i,node:c}},Un=(r,t,o)=>{if(!Number.isInteger(o)||o<0||o>ht)return d("invalid-offset",`a list level is 0 to ${String(ht)}`,String(o));if(!Ct(r.reads,t))return d("unsupported-content","that paragraph is not in a list",t);let i=y(r);if(i)return i;let c=j(r,t,"paragraph");return c||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:t,level:o}],story:r.reads.story,answer:()=>F}},Xn=(r,t,o,i)=>{if(o!=="start"&&o!=="end")return d("unknown-operation","a list takes an item at its start or its end",String(o));let c=r.reads,p=o==="start"?t.paragraphIds[0]:t.paragraphIds[t.paragraphIds.length-1];if(p===void 0)return d("invalid-handle","that list holds no paragraph");let h={story:c.story,paragraphId:p,index:c.indexOf(p)};return jt(r,h,o==="start"?"before":"after",i)},le=(r,t)=>{if(t.start.paragraphId!==t.end.paragraphId)return null;for(let o of An(r,t.start.paragraphId))if(o.start<=t.start.offset&&o.end>=t.end.offset)return o;return null},Yn=(r,t,o)=>{if(typeof o!="string")return d("unsupported-content","a hyperlink target is a string","target");let i=r.reads,c=le(i,t),p=t.start.paragraphId===t.end.paragraphId&&t.start.offset===t.end.offset;if(o.length===0){if(!c)return d("unsupported-content","that text is not a link","no-link");let O=y(r);if(O)return O;let S=M(r,c.paragraphId);return S||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:c.id}],story:i.story,answer:()=>F}}let h={},A=null;if(o.startsWith("#")){let O=o.slice(1);if(O.length===0||!oe(i,O))return d("unsupported-content","this document declares no such bookmark",o);h={anchor:O};}else {if(Rc(o)===null)return d("unsupported-content","this engine will not author that target","target");A=o;}let x=y(r);if(x)return x;let w=O=>A===null?{ok:true,kind:"command",ops:[O(h)],story:i.story,answer:()=>F}:{ok:true,kind:"command",ops:[],relate:{url:A,ops:S=>[O({relationshipId:S})]},story:i.story,answer:()=>F};if(c){let O=M(r,c.paragraphId);return O||w(S=>({op:"setHyperlinkTarget",linkId:c.id,...S}))}if(p)return d("unsupported-content","a link with no text has nothing to click","collapsed");if(t.start.paragraphId!==t.end.paragraphId)return d("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let T=M(r,t.start.paragraphId);if(T)return T;let _=i.styles().idOf("hyperlink");return w(O=>({op:"insertHyperlink",paragraphId:t.start.paragraphId,start:t.start.offset,end:t.end.offset,...O,..._===null?{}:{styleId:_}}))},ue=(r,t,o)=>{let i=r.reads;if(!s.selection||!n.select)return d("unsupported-capability","this host has no reader to move","selection");if(o!=="select"&&o!=="start"&&o!=="end")return d("unknown-operation","that is not a selection mode",String(o));let c=at(t,i);for(let p of c)if(r.touched.has(p))return d("conflicting-operations","this batch edits a paragraph the selection covers",p);for(let p of c)r.selected.add(p);return f.push({range:t,mode:o}),{ok:true,kind:"command",ops:[],story:i.story,answer:()=>F}},ce=r=>{let t=e.resolve(r,"bookmark");if(!t||t.kind!=="bookmark")return d("invalid-handle","that handle does not name a bookmark","bookmark");let o=a.story(t.story);if(!o)return d("invalid-handle","that story is not in this document");let i=oe(o,t.name);if(!i)return d("invalid-handle","this document no longer declares that bookmark",t.name);let c=p=>({story:o.story,paragraphId:p.paragraphId,index:o.indexOf(p.paragraphId),offset:p.offset});return {reads:o,range:{start:c(i.start),end:c(i.end)}}},Gn=r=>{switch(r.op){case "getDocument":return b({kind:"handle",handle:e.document()});case "getBody":return e.resolve(r.document,"document")?a.body?b({kind:"handle",handle:e.body(ct)}):d("document-unavailable","this host holds no document right now"):d("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let t=K(r.body,"body",e,a);return t.ok?b({kind:"handles",handles:t.value.paragraphIds.map(o=>e.paragraph(o,t.value.story))}):d(t.code,"that handle does not name a body",t.detail)}case "getSpanParagraphs":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);let o=q(r.span,e,a);return o.ok?b({kind:"handles",handles:at(t.value,o.value).map(i=>e.paragraph(i,o.value.story))}):d(o.code,"that span is not a place",o.detail)}case "getText":{if(e.resolve(r.target,"body")){let c=K(r.target,"body",e,a);return c.ok?b({kind:"text",text:c.value.text()}):d(c.code,"that handle does not name a body",c.detail)}let o=Q(r.target,e,a);if(!o.ok)return d(o.code,"that handle does not name a body or a paragraph",o.detail);let i=a.story(o.value.story);return b({kind:"text",text:i?.paragraphText(o.value.paragraphId)??""})}case "getSpanText":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);let o=q(r.span,e,a);return o.ok?b({kind:"text",text:hn(t.value,o.value,Zt)}):d(o.code,"that span is not a place",o.detail)}case "getParagraphId":{let t=Q(r.paragraph,e,a);if(!t.ok)return d(t.code,"that handle does not name a paragraph",t.detail);let i=a.story(t.value.story)?.paragraph(t.value.paragraphId);return b({kind:"text",text:i?.paraId??""})}case "search":{let t=W(r.scope,e,a);if(!t.ok)return d(t.code,"that is not a scope to search",t.detail);let o=q(r.scope,e,a);return o.ok?X(o.value,t.value,r.text,r.options):d(o.code,"that is not a scope to search",o.detail)}case "insertText":{let t=gt(r.at,e,a);if(!t.ok)return d(t.code,"that is not a place to insert at",t.detail);let o=a.story(t.value.story);return o?et(u(o),t.value,r.text):d("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in r.span){let i=K(r.span.body,"body",e,a);return i.ok?Ot(u(i.value),r.text):d(i.code,"that handle does not name a body",i.detail)}let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);if(!t.value)return d("invalid-offset","that story holds no paragraph to write into","empty-story");let o=E(t.value);return o?At(u(o),t.value,r.text):d("invalid-handle","that story is not in this document")}case "insertParagraph":{let t=_t(r.anchor,e,a);if(!t.ok)return d(t.code,"that is not a paragraph to insert beside",t.detail);if(r.where!=="before"&&r.where!=="after")return d("unknown-operation","that is not a place to insert",String(r.where));let o=a.story(t.value.story);return o?jt(u(o),t.value,r.where,r.text):d("invalid-handle","that story is not in this document")}case "splitParagraph":{let t=Q(r.paragraph,e,a);if(!t.ok)return d(t.code,"that handle does not name a paragraph",t.detail);let o=a.story(t.value.story);return o?H(u(o),t.value,r.delimiters,r.trimDelimiters===true,r.trimSpacing===true):d("invalid-handle","that story is not in this document")}case "getFont":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);let o=q(r.span,e,a);return o.ok?b({kind:"font",font:an(o.value.part,qt(t.value,o.value))}):d(o.code,"that span is not a place",o.detail)}case "setFont":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);if(!t.value)return d("invalid-offset","that story holds no paragraph to format","empty-story");let o=E(t.value);return o?st(u(o),t.value,r.font):d("invalid-handle","that story is not in this document")}case "getStyle":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);let o=q(r.span,e,a);if(!o.ok)return d(o.code,"that span is not a place",o.detail);let i=o.value.part,c=o.value.styles(),p=at(t.value,o.value).map(A=>Lt(i,A,c)),h=p.length>0&&p.every(A=>A!==null&&A===p[0])?p[0]:null;return b({kind:"style",name:h})}case "setStyle":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);if(!t.value)return d("invalid-offset","that story holds no paragraph to style","empty-story");let o=E(t.value);return o?vt(u(o),t.value,r.name):d("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let t=_t(r.paragraph,e,a);if(!t.ok)return d(t.code,"that is not a paragraph",t.detail);let o=a.story(t.value.story);if(!o)return d("document-unavailable","this host holds no document right now");let i=sn(o.part,t.value.paragraphId,o.styles());return i?b({kind:"paragraphFormat",format:i}):d("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let t=_t(r.paragraph,e,a);if(!t.ok)return d(t.code,"that is not a paragraph",t.detail);let o=a.story(t.value.story);return o?pt(u(o),t.value,r.format):d("invalid-handle","that story is not in this document")}case "deleteParagraph":{let t=Q(r.paragraph,e,a);if(!t.ok)return d(t.code,"that handle does not name a paragraph",t.detail);let o=a.story(t.value.story);return o?z(u(o),t.value):d("invalid-handle","that story is not in this document")}case "getSections":return e.resolve(r.document,"document")?b({kind:"handles",handles:a.sections().map(t=>e.section(t.index))}):d("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let t=e.resolve(r.section,"section");if(!t||t.kind!=="section")return d("invalid-handle","that handle does not name a section","section");let o=a.sections()[t.index];return o?b({kind:"pageSetup",setup:o.pageSetup}):d("invalid-handle","that section is not in this document")}case "setPageSetup":{let t=e.resolve(r.section,"section");return !t||t.kind!=="section"?d("invalid-handle","that handle does not name a section","section"):Vn(t.index,r.setup)}case "getFurniture":{let t=e.resolve(r.section,"section");if(!t||t.kind!=="section")return d("invalid-handle","that handle does not name a section","section");if(r.kind!=="header"&&r.kind!=="footer")return d("unknown-operation","that is not furniture",String(r.kind));let o={kind:r.kind,sectionIndex:t.index,variant:r.variant};return tn(o)?a.story(o)?b({kind:"handle",handle:e.body(o)}):d("invalid-handle","this document declares no such header or footer",B(o)):d("unknown-operation","that is not a furniture variant",String(r.variant))}case "getNotes":{if(!e.resolve(r.document,"document"))return d("invalid-handle","that handle does not name a document","document");if(r.noteKind!=="footnote"&&r.noteKind!=="endnote")return d("unknown-operation","that is not a kind of note",String(r.noteKind));let t=r.noteKind,o=a.noteIds(t);return o.ok?b({kind:"handles",handles:o.ids.map(i=>e.note(t,i))}):d("ambiguous-document",`${t} identities are not completely and unambiguously enumerable`,o.reason==="duplicates"?o.duplicateIds.join(","):o.reason)}case "getNoteBody":case "getNoteText":{let t=e.resolve(r.note,"note");if(!t||t.kind!=="note")return d("invalid-handle","that handle does not name a note","note");let o=t,i=a.story(o);return i?r.op==="getNoteText"?b({kind:"text",text:i.text()}):b({kind:"handle",handle:e.body(o)}):d("invalid-handle","that note is not in this document",B(o))}case "getNoteKind":{let t=e.resolve(r.note,"note");return !t||t.kind!=="note"?d("invalid-handle","that handle does not name a note","note"):b({kind:"text",text:t.noteKind})}case "deleteNote":{let t=e.resolve(r.note,"note");if(!t||t.kind!=="note")return d("invalid-handle","that handle does not name a note","note");let o=a.noteIds(t.noteKind);return o.ok?o.ids.includes(t.noteId)?$n(t.noteKind,t.noteId):d("invalid-handle","that note is not in this document"):d("ambiguous-document",`${t.noteKind} identities are not completely and unambiguously enumerable`,o.reason==="duplicates"?o.duplicateIds.join(","):o.reason)}case "getLists":{let t=K(r.body,"body",e,a);return t.ok?b({kind:"handles",handles:Bt(t.value).map(o=>e.list(o.numId,t.value.story))}):d(t.code,"that handle does not name a body",t.detail)}case "getListId":{let t=Dt(r.list);return "list"in t?b({kind:"number",value:Number(t.list.numId)}):t}case "getListById":{let t=K(r.body,"body",e,a);if(!t.ok)return d(t.code,"that handle does not name a body",t.detail);if(!Number.isInteger(r.id)||r.id<=0)return d("unsupported-content","a list is numbered from one",String(r.id));let o=String(r.id),i=Bt(t.value).find(c=>c.numId===o);return i?b({kind:"handle",handle:e.list(i.numId,t.value.story)}):d("invalid-handle","no list in that story carries that number",o)}case "getListParagraphs":{let t=Dt(r.list);if(!("list"in t))return t;let o=r.level;if(o!==void 0&&(!Number.isInteger(o)||o<0||o>ht))return d("invalid-offset",`a list level is 0 to ${String(ht)}`,String(o));let i=t.plan.reads,c=o===void 0?t.list.paragraphIds:t.list.paragraphIds.filter(p=>Ct(i,p)?.level===o);return b({kind:"handles",handles:c.map(p=>e.paragraph(p,i.story))})}case "getParagraphList":{let t=Q(r.paragraph,e,a);if(!t.ok)return d(t.code,"that handle does not name a paragraph",t.detail);let o=a.story(t.value.story);if(!o)return d("invalid-handle","that story is not in this document");let i=Ct(o,t.value.paragraphId);return i?b({kind:"handle",handle:e.list(i.numId,o.story)}):d("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "getListLevel":{let t=Q(r.paragraph,e,a);if(!t.ok)return d(t.code,"that handle does not name a paragraph",t.detail);let o=a.story(t.value.story);if(!o)return d("invalid-handle","that story is not in this document");let i=Ct(o,t.value.paragraphId);return i?b({kind:"number",value:i.level}):d("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "setListLevel":{let t=Q(r.paragraph,e,a);if(!t.ok)return d(t.code,"that handle does not name a paragraph",t.detail);let o=a.story(t.value.story);return o?Un(u(o),t.value.paragraphId,r.level):d("invalid-handle","that story is not in this document")}case "insertListParagraph":{let t=Dt(r.list);return "list"in t?Xn(t.plan,t.list,r.where,r.text):t}case "getHyperlink":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);let o=q(r.span,e,a);if(!o.ok)return d(o.code,"that span is not a place",o.detail);let i=a.package;if(!i||!t.value)return b({kind:"text",text:""});let c=le(o.value,t.value);if(!c)return b({kind:"text",text:""});let p=Ea(o.value.part,c.id),h=p?vn(i,o.value.part.name,p):null;return b({kind:"text",text:h??""})}case "setHyperlink":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);if(!t.value)return d("invalid-offset","that story holds no text to link","empty-story");let o=E(t.value);return o?Yn(u(o),t.value,r.target):d("invalid-handle","that story is not in this document")}case "getBookmarks":{let t=W(r.scope,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);let o=q(r.scope,e,a);if(!o.ok)return d(o.code,"that span is not a place",o.detail);let i=o.value,c=t.value,p=c===null?null:new Set(at(c,i)),h=ne(i).filter(A=>{if(!p||!p.has(A.start.paragraphId)&&!p.has(A.end.paragraphId)||c===null)return false;let x=A.start.paragraphId===c.end.paragraphId&&A.start.offset>c.end.offset,w=A.end.paragraphId===c.start.paragraphId&&A.end.offset<c.start.offset;return !x&&!w});return b({kind:"handles",handles:h.map(A=>e.bookmark(A.name,i.story))})}case "getBookmarkName":{let t=e.resolve(r.bookmark,"bookmark");return !t||t.kind!=="bookmark"?d("invalid-handle","that handle does not name a bookmark","bookmark"):b({kind:"text",text:t.name})}case "getBookmarkRange":{let t=ce(r.bookmark);return "reads"in t?b({kind:"span",span:U(t.range)}):t}case "getComments":{let t=W(r.scope,e,a);if(!t.ok)return d(t.code,"that scope is not a place",t.detail);let o=q(r.scope,e,a);if(!o.ok)return d(o.code,"that scope names no story",o.detail);let i=o.value,c=g(i);if(!c)return d("document-unavailable","this host holds no document");let p=t.value,h=c.roots.filter(A=>{if(!p)return true;let x=A.range;if(!x)return false;let w=i.indexOf(x.start.paragraphId),T=i.indexOf(x.end.paragraphId),_=i.indexOf(p.start.paragraphId),O=i.indexOf(p.end.paragraphId);return T<_||w>O?false:T===_&&w===_&&O===_?x.end.offset>p.start.offset&&x.start.offset<p.end.offset:true});return b({kind:"handles",handles:h.map(A=>e.comment(A.id,i.story))})}case "getCommentReplies":{let t=I(r.comment);return t.ok?b({kind:"handles",handles:t.item.replyIds.map(o=>e.comment(o,t.reads.story))}):t.planned}case "getCommentId":{let t=I(r.comment);return t.ok?b({kind:"text",text:t.item.id}):t.planned}case "getCommentAuthor":{let t=I(r.comment);return t.ok?b({kind:"text",text:t.item.comment.author}):t.planned}case "getCommentDate":{let t=I(r.comment);return t.ok?b({kind:"text",text:t.item.comment.date??""}):t.planned}case "getCommentText":{let t=I(r.comment);if(!t.ok)return t.planned;let o=g(t.reads);return b({kind:"text",text:o?.textOf(t.item.id)??""})}case "getCommentRange":{let t=I(r.comment);if(!t.ok)return t.planned;let o=t.item.range;if(!o||t.item.orphaned)return d("invalid-handle","that comment has no range in this document");let i=R(t.reads,o);return i?b({kind:"span",span:i}):d("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let t=I(r.comment);return t.ok?b({kind:"flag",value:t.item.resolved}):t.planned}case "insertComment":return Pn(r,e,a,v);case "setCommentResolved":{let t=I(r.comment);if(!t.ok)return t.planned;if(typeof r.resolved!="boolean")return d("unsupported-content","resolved is a yes or a no",String(r.resolved));let o=y(u(t.reads));return o||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:t.item.id,resolved:r.resolved},story:t.reads.story,answer:()=>F}}case "replyToComment":{let t=I(r.comment);if(!t.ok)return t.planned;let o=se({author:r.author,text:r.text,date:r.date,kind:"reply"});if(o)return o;let i=t.item.range;if(!i||t.item.orphaned)return d("invalid-handle","that comment has no range to reply over");let c=y(u(t.reads));if(c)return c;let p=t.reads.story,h=ie(r.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:t.item.id,anchor:{paragraphId:i.start.paragraphId,start:i.start.offset,end:i.end.offset,...i.end.paragraphId===i.start.paragraphId?{}:{endParagraphId:i.end.paragraphId}},text:r.text,author:r.author,...h===void 0?{}:{date:h}},story:t.reads.story,answer:(A,x)=>x===void 0?F:{kind:"handle",handle:e.comment(x,p)}}}case "deleteComment":{let t=I(r.comment);return t.ok?wn(t.item,t.reads,o=>y(u(o))):t.planned}case "getRevisions":{let t=K(r.body,"body",e,a);if(!t.ok)return d(t.code,"that handle does not name a body",t.detail);let o=t.value;return b({kind:"handles",handles:re(o).map(i=>e.revision(i.id,o.story))})}case "getRevisionType":{let t=C(r.revision);return t.ok?b({kind:"text",text:t.item.type}):t.planned}case "getRevisionAuthor":{let t=C(r.revision);return t.ok?b({kind:"text",text:t.item.author}):t.planned}case "getRevisionDate":{let t=C(r.revision);return t.ok?b({kind:"text",text:t.item.date}):t.planned}case "getRevisionRange":{let t=C(r.revision);if(!t.ok)return t.planned;let[o]=t.item.item.ranges;if(!o)return d("invalid-handle","that change covers no characters");let i=R(t.reads,o);return i?b({kind:"span",span:i}):d("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let t=C(r.revision);if(!t.ok)return t.planned;let o=u(t.reads),i=y(o);if(i)return i;let c=r.op==="acceptRevision";return {ok:true,kind:"command",story:t.reads.story,ops:t.item.item.addresses.map(p=>c?{op:"acceptRevision",revision:p}:{op:"rejectRevision",revision:p}),answer:()=>F}}case "acceptAllRevisions":case "rejectAllRevisions":{let t=Sn(r,e,a);if(!t.ok)return d(t.code,t.message,t.detail);let o=u(t.reads),i=y(o);if(i)return i;let c=Rn(r,t.reads);return {ok:true,kind:"command",story:t.reads.story,ops:c,answer:()=>F}}case "selectSpan":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);if(!t.value)return d("invalid-offset","that story holds no paragraph to select","empty-story");let o=E(t.value);return o?ue(u(o),t.value,r.mode):d("invalid-handle","that story is not in this document")}case "selectBookmark":{let t=ce(r.bookmark);return "reads"in t?ue(u(t.reads),t.range,r.mode):t}case "getContentControls":{let t=Wt(r.scope);return "reads"in t?b({kind:"handles",handles:Tn(t.reads,t.node).map(o=>e.contentControl(o.nodeId,t.reads.story))}):t}case "getContentControlById":{let t=Wt(r.scope);if(!("reads"in t))return t;if(!Number.isInteger(r.id))return d("unsupported-content","a control id is a whole number",String(r.id));let o=zn(t.node).find(i=>ne$1(i).id===r.id);return o?b({kind:"handle",handle:e.contentControl(o.id,t.reads.story)}):d("invalid-handle","no control in that scope carries that id",String(r.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let t=Wt(r.scope);if(!("reads"in t))return t;let o=r.op==="getContentControlsByTag"?r.tag:r.title;if(typeof o!="string"||o.length===0)return d("unsupported-content","a tag or title to match is required",r.op);let i=zn(t.node).filter(c=>{let p=ne$1(c);return r.op==="getContentControlsByTag"?p.tag===o:p.alias===o});return b({kind:"handles",handles:i.map(c=>e.contentControl(c.id,t.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let t=nt(r.contentControl);if(!("control"in t))return t;let o=t.control.properties;if(r.op==="getContentControlLock")return b({kind:"text",text:t.control.lock});if(r.op==="getContentControlSubtype")return b({kind:"text",text:o.type});if(r.op==="getContentControlFileId")return b({kind:"text",text:o.id===void 0?"":String(o.id)});let i=r.op==="getContentControlTag"?o.tag:o.alias;return b({kind:"text",text:i??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let t=nt(r.contentControl);if(!("control"in t))return t;let o=r.op==="getContentControlIsBound"?t.control.properties.dataBinding!==void 0:r.op==="getContentControlPlaceholderShown"?t.control.properties.showingPlaceholder:t.control.properties.temporary;return b({kind:"flag",value:o})}case "getContentControlText":{let t=nt(r.contentControl);return "control"in t?b({kind:"text",text:Ln(t.node)}):t}case "getContentControlParagraphs":{let t=nt(r.contentControl);return "control"in t?b({kind:"handles",handles:t.control.paragraphIds.map(o=>e.paragraph(o,t.reads.story))}):t}case "getContentControlRange":{let t=nt(r.contentControl);if(!("control"in t))return t;let o=r.location??"whole";if(!Xo.has(o))return d("unsupported-content","that is not a place in a control",o);let i=de(t.reads,t.node);if(!i)return d("unsupported-content","that control holds nothing addressable","empty");let c=o==="start"||o==="before"?i.start:i.end,p=o!=="whole"&&o!=="content",h=A=>({story:t.reads.story,paragraphId:A.paragraphId,index:t.reads.indexOf(A.paragraphId),offset:A.offset});return b({kind:"span",span:te(p?{start:h(c),end:h(c)}:{start:h(i.start),end:h(i.end)},e)})}case "setContentControlValue":{let t=nt(r.contentControl);if(!("control"in t))return t;let o=Jo(r.value);if(!o.ok)return d(o.code,o.message,o.detail);let i=u(t.reads),c=y(i);return c||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:o.value}],answer:()=>F}}case "setContentControlProperties":{let t=nt(r.contentControl);if(!("control"in t))return t;if(r.tag===void 0&&r.title===void 0&&r.lock===void 0)return d("unsupported-content","nothing to write","no-properties");if(r.lock!==void 0&&!Uo.has(r.lock))return d("unsupported-content","that is not a lock this schema declares",r.lock);let o=u(t.reads),i=y(o);return i||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlProperties",controlId:t.control.nodeId,...r.tag===void 0?{}:{tag:r.tag},...r.title===void 0?{}:{alias:r.title},...r.lock===void 0?{}:{lock:r.lock}}],answer:()=>F}}case "insertContentControlText":{let t=nt(r.contentControl);if(!("control"in t))return t;if(typeof r.text!="string")return d("unsupported-content","text is required","text");if(r.at!=="replace"&&r.at!=="start"&&r.at!=="end")return d("unsupported-content","that is not a place to insert at",String(r.at));let o=u(t.reads),i=y(o);if(i)return i;let c=de(t.reads,t.node);if(!c)return d("unsupported-content","that control holds nothing addressable","empty");let p=r.at==="end"?c.end:c.start,h=()=>({kind:"span",span:U({start:{story:t.reads.story,paragraphId:p.paragraphId,index:t.reads.indexOf(p.paragraphId),offset:p.offset},end:{story:t.reads.story,paragraphId:p.paragraphId,index:t.reads.indexOf(p.paragraphId),offset:p.offset+r.text.length}})});return r.at==="replace"?{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:{kind:"text",text:r.text}}],answer:h}:{ok:true,kind:"command",story:t.reads.story,ops:r.text.length===0?[]:[{op:"insertText",paragraphId:p.paragraphId,offset:p.offset,text:r.text,inside:t.node.id}],answer:h}}case "deleteContentControl":{let t=nt(r.contentControl);if(!("control"in t))return t;if(typeof r.keepContent!="boolean")return d("unsupported-content","keepContent is required","keepContent");let o=u(t.reads),i=y(o);return i||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"removeContentControl",controlId:t.control.nodeId,keepContent:r.keepContent}],answer:()=>F}}case "insertContentControl":{let t=W(r.span,e,a);if(!t.ok)return d(t.code,"that span is not a place",t.detail);if(!t.value)return d("invalid-offset","that story holds nothing to wrap","empty-story");let o=E(t.value);if(!o)return d("invalid-handle","that story is not in this document");let i=t.value;if(i.start.paragraphId!==i.end.paragraphId)return d("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!Yo.has(r.subtype))return d("unsupported-content","that control type cannot be inserted",r.subtype);let c=u(o),p=y(c);return p||{ok:true,kind:"command",story:o.story,ops:[{op:"insertContentControl",paragraphId:i.start.paragraphId,start:i.start.offset,end:i.end.offset,type:r.subtype,...r.tag===void 0?{}:{tag:r.tag},...r.title===void 0?{}:{alias:r.title}}],answer:()=>F}}case "insertCustomNode":{let t=Fn(r);if(t)return d("unsupported-content",t.message,t.detail);let o=Bn(r.payload);if(!o.ok)return d("unsupported-content","that payload cannot be written",o.field);let i=Dn(r,e,a);if("code"in i)return d(i.code,i.message,i.detail);let{start:c,end:p}=i.range,h=E(i.range);if(!h)return d("invalid-handle","that story is not in this document");let A=y(u(h));return A||{ok:true,kind:"customNodeWrite",story:h.story,write:jn(r,c,p,o.value),answer:()=>F}}default:return d("unknown-operation","this host does not implement that operation",String(r.op))}};return {plan(r){let t=k.conflict(r);if(t)return d("conflicting-operations",t.message,t.detail);let o=Gn(r);return o.ok&&k.note(r),o},get hasCommands(){return k.hasCommands},get writeScope(){return m?.reads.scope??null},settle(r){let t=m;if(t){let o=r.story(t.reads.story);if(!o)return {ok:false,detail:`the story this batch wrote is gone: ${B(t.reads.story)}`};let i=new Set(t.reads.paragraphIds),c=o.paragraphIds.filter(h=>!i.has(h));if(c.length!==t.created.length)return {ok:false,detail:`planned ${String(t.created.length)} new paragraphs, the transaction made ${String(c.length)}`};t.order.filter(h=>h.id===null).forEach((h,A)=>{h.id=c[A]??null;});for(let h of t.retargets)h.slot.id&&e.retarget(h.from,h.slot.id);}for(let o of f){let i=r.story(o.range.start.story);!i||!qo(o.range,i)||n.select?.(o.range,o.mode);}return {ok:true}}}}var er=Object.freeze({status:"skipped"});function J(n,e,s){return Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}function nr(n){let e=n==="unsupported-revision"||n.startsWith("unsupported-revision:");return J(e?"unsupported-revision":"transaction-refused",e?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",n)}function tt(n,e,s,a){return {ok:false,results:n.map((l,u)=>u===e?{status:"error",error:s}:er),revision:a,changed:false}}function Ma(n){let{port:e}=n,s=Object.freeze({...n.capabilities}),a=en(),l=new Set,u=false,f=null,k=s.events?e.subscribe(()=>{if(u)return;let v=Object.freeze({revision:e.revision()});for(let g of [...l])g(v);}):()=>{},m=v=>{if(f&&f.pkg===v)return f.value;let g=yn(v);return f={pkg:v,value:g},g};return {capabilities:s,revision:()=>e.revision(),execute:v=>{let g=Array.isArray(v?.operations)?v.operations:[],I=e.revision();if(u)return tt(g,0,J("disposed","this host was disposed"),I);if(!s.document)return tt(g,0,J("unsupported-capability","this host has no document","document"),I);let C=e.currentPackage();if(!C)return tt(g,0,J("document-unavailable","this host holds no document right now"),I);if(v.expectedRevision!==void 0&&v.expectedRevision!==I)return tt(g,0,J("stale-revision","the document moved since that revision",`expected ${String(v.expectedRevision)}, at ${I}`),I);let R=Kn({handles:a,reads:m(C),capabilities:s,...e.select?{select:e.select.bind(e)}:{}}),N=[],P=[],L=null,M=[],j=null,Z,U=null,E=-1;for(let H=0;H<g.length;H+=1){let z=R.plan(g[H]);if(!z.ok)return tt(g,H,z.error,I);if(N.push(z),z.kind==="command")if(E<0&&(E=H),z.lifecycle)L=z.ops[0]??null;else if(z.relate){let st=z.relate;P.push(vt=>{let pt=vt(st.url);return pt===null?null:st.ops(pt)});}else {let{ops:st}=z;P.push(()=>st);}else z.kind==="commentWrite"?(E<0&&(E=H),M.push(z.write),j=R.writeScope??{kind:"body"}):z.kind==="customNodeWrite"&&(E<0&&(E=H),U={write:z.write,scope:R.writeScope??{kind:"body"}});}let X=false;if(M.length>0){let H=e.applyCommentWrites(M,j??{kind:"body"});if(!H.ok)return tt(g,E<0?0:E,J("transaction-refused","the document store refused the comment write",H.reason),I);X=H.changed,Z=H.commentId;}if(U){let H=e.applyCustomNodeWrite(U.write,U.scope);if(!H.ok)return tt(g,E<0?0:E,J("transaction-refused","the document store refused the custom-node write",H.reason),I);X=H.changed;}if(L){let H=e.applyLifecycle(L);if(!H.ok)return tt(g,E<0?0:E,J("transaction-refused","the document store refused the transaction",H.reason),I);X=H.changed;}if(P.length>0){let H=e.apply(z=>{let st=[];for(let vt of P){let pt=vt(z);if(pt===null)return null;st.push(...pt);}return st},R.writeScope??{kind:"body"});if(!H.ok)return tt(g,E<0?0:E,nr(H.reason),I);X=H.changed;}let et=e.currentPackage();if(!et)return tt(g,0,J("document-unavailable","this host holds no document right now"),I);let At=m(et),Ot=R.settle(At);return Ot.ok?{ok:true,results:N.map(H=>({status:"ok",value:H.kind==="query"?H.value:H.kind==="customNodeWrite"?H.answer(At):H.answer(At,Z)})),revision:e.revision(),changed:X}:tt(g,E<0?0:E,J("transaction-refused","the transaction did not produce the document the batch planned",Ot.detail),e.revision())},save(){if(u)return {ok:false,error:J("disposed","this host was disposed")};if(!s.save)return {ok:false,error:J("unsupported-capability","this host cannot save","save")};let v=e.save();return v?{ok:true,bytes:v}:{ok:false,error:J("document-unavailable","this host holds no document right now")}},subscribe(v){return u||!s.events?()=>{}:(l.add(v),()=>{l.delete(v);})},dispose(){u||(u=true,l.clear(),k(),e.dispose(),f=null);}}}export{Ht as a,rr as b,qn as c,to as d,Yt as e,Gt as f,Ma as g};
|