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