@docx-editor.dev/core 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-CZFUMACF.cjs → chunk-F2VQQW5R.cjs} +3 -3
- package/dist/{chunk-WOGYVM3W.js → chunk-RKNH4ZFT.js} +3 -3
- package/dist/editor.cjs +1 -1
- package/dist/editor.d.cts +2 -2
- package/dist/editor.d.ts +2 -2
- package/dist/editor.js +1 -1
- package/dist/{index-BjZelfWL.d.cts → index-DQhDm4o0.d.cts} +6 -2
- package/dist/{index-DP1yJJ3R.d.ts → index-DTbKoFJL.d.ts} +6 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {b as b$1,d as d$1,e as e$1,a as a$3,c as c$1}from'./chunk-QRAUDDVY.js';import {k as k$1,h,g,m,jc as jc$1,jd as jd$1,kb,dd as dd$1,tc as tc$2,nd as nd$1,vc as vc$1,qd as qd$1,fd as fd$1,td as td$1,R,sd as sd$1,vd as vd$1,Fd as Fd$1,Gd as Gd$1,yd as yd$1,xd as xd$1,Dd as Dd$1,W,Qb,Ia as Ia$1,rb,ud as ud$1,kc as kc$1,Dc as Dc$1,rc as rc$1,Cc as Cc$1,wd as wd$1,md as md$1,ib,zd as zd$2,Hd as Hd$1,nb,Id as Id$1,dc as dc$1,ac as ac$1,oc as oc$1,lc as lc$1,mc as mc$1,nc as nc$1,Bc as Bc$2,pd as pd$1,Fc as Fc$1,ld as ld$1,S,fc as fc$1,Ed as Ed$1,Bd as Bd$2,cc as cc$1,Ib,Cd as Cd$2,cd as cd$1,Rb,Vb}from'./chunk-STCITBJK.js';import {g as g$1}from'./chunk-6WIIHJFY.js';import {j as j$1,d as d$2,i as i$1}from'./chunk-TBBXCC7D.js';import {b as b$2,h as h$1,j as j$2,l,c as c$2,d as d$3,k as k$2}from'./chunk-4WWEDTTE.js';import {H,N}from'./chunk-2DTQDAN7.js';import {d,a as a$1,b,c,k,e,j,i,Wa as Wa$1,tc as tc$1,xf,Bc as Bc$1,Ea as Ea$1,Md as Md$1,Nd as Nd$1,ab,Xa as Xa$1,Ya as Ya$1,Za as Za$1,U,nf as nf$1,pf as pf$1,kf as kf$1,of as of$1,_c as _c$1,Tf as Tf$1,Sf as Sf$1,Uf as Uf$1,Rd as Rd$1,zd as zd$1,Ad as Ad$1,Bd as Bd$1,Cd as Cd$1,Dd as Dd$2,xd as xd$2,yd as yd$2,Ta as Ta$1,Zc as Zc$1,gg as gg$1,sc as sc$1,td as td$2,vf as vf$1,if as _if,jf as jf$1,Vf as Vf$1,Qb as Qb$1,Pf as Pf$1,Jb,sd as sd$2,jd as jd$2,hd as hd$1,Fa as Fa$1,Rf as Rf$1,Qf as Qf$1,Of as Of$1,Wf as Wf$1,Kd as Kd$1,dd as dd$2,gf as gf$1,hf as hf$1,ee,la,N as N$1}from'./chunk-Y7TA7TPF.js';import {a}from'./chunk-REZUWYB7.js';import {a as a$2}from'./chunk-GQQOL4PV.js';import {zipSync,strToU8}from'fflate';import {createT,en,locales,deepMerge}from'@docx-editor.dev/i18n';var zu=Object.freeze({kern:1,liga:1});function no(e){return Object.freeze({family:e.family,weight:e.weight,style:e.style})}function bn(e){return e instanceof a?e:e instanceof d?new a(e.code,e.message,{request:no(e.request),diagnostic:e.diagnostic}):new a("initializationFailed",e instanceof Error?e.message:"Font initialization failed",{diagnostic:e instanceof Error?e.message:String(e)})}async function ro(e,t){try{if(!Number.isSafeInteger(e.maxFontBytes)||e.maxFontBytes<=0||e.maxFontBytes>a$1)throw new a("overLimit",`Font byte ceiling must not exceed the engine hard maximum of ${a$1}`);if(!Number.isSafeInteger(e.sources.length)||e.sources.length===0||e.sources.length>b)throw new a("overLimit",`Font source count must be between 1 and ${b}`);let n=0;for(let o of e.sources){if(!Number.isSafeInteger(o.bytes.byteLength)||o.bytes.byteLength>e.maxFontBytes||o.bytes.byteLength>a$1)throw new a("overLimit",`Font source ${o.id} exceeds the per-font byte ceiling`);if(o.bytes.byteLength>c-n)throw new a("overLimit",`Font sources exceed the aggregate byte ceiling of ${c}`);n+=o.bytes.byteLength;}let r={epoch:e.epoch,maxFontBytes:e.maxFontBytes,sources:e.sources.map(o=>({request:no(o.request),id:o.id,bytes:o.bytes,hash:o.hash,faceIndex:o.faceIndex,availability:o.availability})),substitutions:e.substitutions?.map(o=>({from:no(o.from),to:no(o.to)})),defaultFont:Object.freeze({family:e.defaultFont.family,sizeHalfPoints:e.defaultFont.sizeHalfPoints}),language:e.language},a$2=k({epoch:r.epoch,maxFontBytes:r.maxFontBytes,resources:r.sources,substitutions:r.substitutions,validateFont:k$1,instrumentation:{onOwnedByteCopy:t?.onFontByteCopy,onHash:t?.onFontHash,onAdmission:t?.onFontAdmission}});return await h(),Object.freeze({fonts:a$2,shaper:m(),defaultFont:Object.freeze({family:r.defaultFont.family,sizeHalfPoints:r.defaultFont.sizeHalfPoints}),environment:Object.freeze({variationAxes:Object.freeze({}),shapingLibrary:g,unicodeDataVersion:"16.0.0",normalization:"none",language:r.language??"en",features:zu,fixedPointScale:20,roundingMode:"halfAwayFromZero"}),ligatureCaretPolicy:"cluster-edges-only",operation:Object.freeze({resourceEpoch:a$2.epoch,configEpoch:r.epoch,extensionFingerprint:`fonts:${r.sources.map(o=>`${o.hash}#${o.faceIndex}`).join(",")}`,shapingHash:`hb:${g.version}:kern+liga`,producerVersion:1})})}catch(n){throw bn(n)}}function xn(e){e.shaper.dispose?.();}var va=64,oo=Object.freeze({family:"Calibri",sizeHalfPoints:22});function ao(e$1,...t){let n=[e$1,...t],r=[],a=new Set;for(let l of n)for(let d of l.sources??[]){let p=e(d.request);a.has(p)||(a.add(p),r.push(d));}let o=[],i=new Set;for(let l of n)for(let d of l.substitutions??[]){let p=e(d.from);a.has(p)||i.has(p)||(i.add(p),o.push(d));}return Object.freeze({epoch:e$1.epoch??0,maxFontBytes:e$1.maxFontBytes??a$1,sources:Object.freeze(r),...o.length>0?{substitutions:Object.freeze(o)}:{},defaultFont:e$1.defaultFont??oo,...e$1.language!==void 0?{language:e$1.language}:{}})}var il="http://schemas.openxmlformats.org/wordprocessingml/2006/main",ju="http://schemas.openxmlformats.org/package/2006/content-types",sl="http://schemas.openxmlformats.org/package/2006/relationships",Vu="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",Uu="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",Gu=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${ju}"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/></Types>`,Wu=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${sl}"><Relationship Id="rId1" Type="${Vu}" Target="word/document.xml"/></Relationships>`,Xu=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${sl}"><Relationship Id="rId1" Type="${Uu}" Target="styles.xml"/></Relationships>`,$u=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${il}"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:eastAsia="Calibri" w:cs="Calibri"/><w:sz w:val="22"/><w:szCs w:val="22"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="160" w:line="259" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style></w:styles>`,Yu=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="${il}"><w:body><w:p/><w:sectPr><w:pgSz w:w="12240" w:h="15840"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/></w:sectPr></w:body></w:document>`;function Qu(){return zipSync({"[Content_Types].xml":strToU8(Gu),"_rels/.rels":strToU8(Wu),"word/_rels/document.xml.rels":strToU8(Xu),"word/document.xml":strToU8(Yu),"word/styles.xml":strToU8($u)})}function ll(e){return e.family.trim().length===0?"font family must not be empty":!Number.isInteger(e.weight)||e.weight<1||e.weight>1e3?"font weight must be an integer from 1 through 1000":e.style!=="normal"&&e.style!=="italic"?"font style must be normal or italic":null}function Ju(e){try{return typeof caches>"u"?Promise.resolve(null):caches.open(e).catch(()=>null)}catch{return Promise.resolve(null)}}async function ef(e,t){if(!e)return null;try{let n=await e.match(t);return n?new Uint8Array(await n.arrayBuffer()):null}catch{return null}}async function tf(e,t,n){if(e)try{await e.put(t,new Response(n.slice(),{headers:{"Content-Length":String(n.byteLength)}}));}catch{}}async function nf(e,t){if(e)try{await e.delete(t);}catch{}}async function rf(e){let t=e.fetcher??fetch,n=e.maxFontBytes??a$1,r=await Ju(e.cacheName??"docx-editor-fonts");async function a(d){let p=Object.freeze({family:d.family,weight:d.weight,style:d.style}),y=ll(p);if(y)return {failure:{url:d.url,request:p,reason:"invalidRequest",diagnostic:y}};let C=(F,B)=>{if(F.byteLength===0)return {url:d.url,request:p,reason:"emptyResponse"};if(F.byteLength>n)return {url:d.url,request:p,reason:"overLimit"};let A=j(F,d.faceIndex??0);if(!A.valid)return {url:d.url,request:p,reason:"malformed",diagnostic:A.diagnostic};let k=i(F);return d.hash!==void 0&&d.hash!==k?{url:d.url,request:p,reason:"hashMismatch",expectedHash:d.hash,actualHash:k,...B?{diagnostic:"cached bytes failed revalidation"}:{}}:{request:p,id:`url:${d.url}`,bytes:F,hash:k,faceIndex:d.faceIndex??0}},S=await ef(r,d.url);if(S){let F=C(S,true);if(!("reason"in F))return {source:F};await nf(r,d.url);}let I;try{I=await t(d.url);}catch(F){return {failure:{url:d.url,request:p,reason:"networkError",diagnostic:F instanceof Error?F.message:String(F)}}}if(!I.ok)return {failure:{url:d.url,request:p,reason:"httpError",status:I.status}};let O;try{O=new Uint8Array(await I.arrayBuffer());}catch(F){return {failure:{url:d.url,request:p,reason:"networkError",diagnostic:F instanceof Error?F.message:String(F)}}}let m=C(O,false);return "reason"in m?{failure:m}:(await tf(r,d.url,O),{source:m})}let o=await Promise.all(e.sources.map(d=>a(d))),i$1=[],l=[];for(let d of o)"source"in d?i$1.push(d.source):l.push(d.failure);return {sources:i$1,failures:l}}function of(e,t,n={}){let r=Object.freeze({family:t.family,weight:t.weight,style:t.style}),a=n.id??`bytes:${r.family}#${r.weight}#${r.style}`,o=ll(r);if(o)return {failure:{url:a,request:r,reason:"invalidRequest",diagnostic:o}};if(e.byteLength===0)return {failure:{url:a,request:r,reason:"emptyResponse"}};if(e.byteLength>(n.maxFontBytes??a$1))return {failure:{url:a,request:r,reason:"overLimit"}};let i$1=t.faceIndex??0,l=j(e,i$1);return l.valid?{source:{request:r,id:a,bytes:e,hash:i(e),faceIndex:i$1}}:{failure:{url:a,request:r,reason:"malformed",diagnostic:l.diagnostic}}}var af=96,dl=37.79527559055118;function sf(e,t){if(!Number.isFinite(e)||e<=0)return [];let n=[];if(t==="inch"){let i=Math.floor(e/12);for(let l=0;l<=i;l+=1){let d=l*12;if(l%8===0){let p=l/8;n.push({position:d,height:10,...p>0?{label:String(p)}:{}});}else l%4===0?n.push({position:d,height:6}):l%2===0?n.push({position:d,height:4}):n.push({position:d,height:2});}return n}let r=dl/10,a=Math.floor(e/r);for(let o=0;o<=a;o+=1){let i=o*r;if(o%10===0){let l=o/10;n.push({position:i,height:10,...l>0?{label:String(l)}:{}});}else o%5===0?n.push({position:i,height:6}):n.push({position:i,height:3});}return n}function lf(e){let t=[...e].sort((n,r)=>n.index-r.index)[0];return t?t.box:null}var df=1440,cf=567,uf=180,ff=56.7,io=(e,t,n)=>n<t||e<t?t:e>n?n:e;function pf(e,t,n){switch(e){case "firstLine":return n.leftMargin+t.left+t.firstLine;case "hanging":case "left":return n.leftMargin+t.left;case "right":return n.pageWidth-n.rightMargin-t.right}}function cl(e,t,n){if(n)return Math.round(e);let r=t==="cm"?56.7:180;return Math.round(Math.round(e/r)*r)}function gf(e,t,n,r,a={}){let o=cl(t,a.unit??"inch",a.precise??false),i=r.pageWidth-r.rightMargin-n.right,l=r.leftMargin+n.left+Math.max(0,n.firstLine);switch(e){case "firstLine":{let d=io(o,0,i);return {...n,firstLine:d-r.leftMargin-n.left}}case "left":{let d=-r.leftMargin-Math.min(0,n.firstLine),p=i-r.leftMargin-Math.max(0,n.firstLine);return {...n,left:io(o-r.leftMargin,d,p)}}case "hanging":{let d=io(o-r.leftMargin,-r.leftMargin,i-r.leftMargin);return {...n,left:d,firstLine:n.firstLine+(n.left-d)}}case "right":{let d=io(o,l,r.pageWidth);return {...n,right:r.pageWidth-r.rightMargin-d}}}}function Pt(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.paraId=="string"&&t.paraId.length>0&&(t.search===void 0||typeof t.search=="string"&&t.search.length>0)&&(t.occurrence===void 0||typeof t.occurrence=="number"&&Number.isInteger(t.occurrence)&&t.occurrence>=1)}function In(e){if(typeof e!="object"||e===null)return false;let t=e;return Pt(t.from)&&Pt(t.to)}function ul(e,t,n){let r=[],a=e.indexOf(t);for(;a>=0&&r.length<n;)r.push(a),a=e.indexOf(t,a+1);return r}function ur(e,t,n){if(typeof n.paraId!="string"||n.paraId.length===0)return {ok:false,code:"invalidArgs",reason:"paraId must be a non-empty string"};let r=t.nodeByParaId.get(n.paraId.toUpperCase());if(r===void 0)return {ok:false,code:"notFound",reason:`no paragraph with paraId '${n.paraId}'`};let a=vf$1(e,r)??"";if(n.search===void 0)return {ok:true,span:{nodeId:r,start:0,end:a.length}};if(n.search.length===0)return {ok:false,code:"invalidArgs",reason:"search must be a non-empty phrase"};if(n.occurrence!==void 0){if(!Number.isInteger(n.occurrence)||n.occurrence<1)return {ok:false,code:"invalidArgs",reason:"occurrence must be a positive integer (1-based)"};let i=ul(a,n.search,n.occurrence),l=i[n.occurrence-1];return l===void 0?{ok:false,code:"notFound",reason:`'${n.search}' matches ${i.length} time(s) in paragraph '${n.paraId}'; occurrence ${n.occurrence} does not exist`}:{ok:true,span:{nodeId:r,start:l,end:l+n.search.length}}}let o=ul(a,n.search,2);return o.length===0?{ok:false,code:"notFound",reason:`'${n.search}' does not occur in paragraph '${n.paraId}'`}:o.length>1?{ok:false,code:"ambiguous",reason:`'${n.search}' matches more than once in paragraph '${n.paraId}'; pass occurrence to disambiguate`}:{ok:true,span:{nodeId:r,start:o[0],end:o[0]+n.search.length}}}function fl(e,t,n){if("anchor"in n){let l=ur(e,t,n.anchor);if(!l.ok)return {ok:false,code:l.code,reason:l.reason,target:n.anchor};let d={paragraphId:l.span.nodeId,offset:l.span.start};return {ok:true,selection:{anchor:d,head:d}}}let{from:r,to:a}=n.range;if(!Pt(r)||!Pt(a))return {ok:false,code:"unsupported",reason:"DocLocation endpoints are not supported; address paragraphs by paraId",target:n.range};let o=ur(e,t,r);if(!o.ok)return {ok:false,code:o.code,reason:o.reason,target:r};let i=ur(e,t,a);return i.ok?{ok:true,selection:{anchor:{paragraphId:o.span.nodeId,offset:o.span.start},head:{paragraphId:i.span.nodeId,offset:i.span.end}}}:{ok:false,code:i.code,reason:i.reason,target:a}}var fr=/^[0-9A-Fa-f]{6}$/,pl={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folhlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedhyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"},mf={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"};function ba(e){return typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=1}function so(e){return Math.max(0,Math.min(1,e))}function gl(e){let t=e.replace(/^#/,"").padStart(6,"0").slice(0,6);return {r:parseInt(t.slice(0,2),16)||0,g:parseInt(t.slice(2,4),16)||0,b:parseInt(t.slice(4,6),16)||0}}function ml(e,t,n){let r=a=>Math.max(0,Math.min(255,Math.round(a))).toString(16).padStart(2,"0");return `${r(e)}${r(t)}${r(n)}`.toUpperCase()}function hl(e,t){if(t>=1)return e.toUpperCase();if(t<=0)return "FFFFFF";let r=Math.max(0,Math.min(255,Math.round((1-so(t))*255)))/255,a=gl(e);return ml(r*255+(1-r)*a.r,r*255+(1-r)*a.g,r*255+(1-r)*a.b)}function yl(e,t){if(t>=1)return e.toUpperCase();if(t<=0)return "000000";let r=Math.max(0,Math.min(255,Math.round(so(t)*255)))/255,a=gl(e);return ml(r*a.r,r*a.g,r*a.b)}function xa(e){return pl[e]??pl[e.toLowerCase()]??null}function hf(e,t){let n=xa(e);if(!n)return null;let r=t.find(o=>o.slot===n)?.hex;if(r&&fr.test(r))return r.toUpperCase();let a=mf[n];return a&&fr.test(a)?a.toUpperCase():null}function lo(e,t){let n=hf(e.slot,t);if(!n)return {ok:false,reason:"the theme colour could not be resolved for this document"};if(e.tint!==void 0&&!ba(e.tint))return {ok:false,reason:"theme tint is out of range"};if(e.shade!==void 0&&!ba(e.shade))return {ok:false,reason:"theme shade is out of range"};let r=n;return e.tint!==void 0?r=hl(r,so(e.tint)):e.shade!==void 0&&(r=yl(r,so(e.shade))),{ok:true,hex:r}}var yf="000000";function Ia(e,t){if(e.kind==="hex"){let a=e.value.toUpperCase();return fr.test(a)?{ok:true,color:{kind:"hex",value:a}}:{ok:false,reason:"border colour requires a six-digit hex value"}}if(e.kind==="auto")return {ok:true,color:{kind:"auto",resolvedHex:yf}};let n=lo(e,t);return n.ok?{ok:true,color:{kind:"theme",slot:xa(e.slot)??e.slot,resolvedHex:n.hex,...e.tint!==void 0?{tint:e.tint}:{},...e.shade!==void 0?{shade:e.shade}:{}}}:n}function Sa(e,t){if(e.kind==="auto")return {ok:false,reason:"automatic fill cannot be written without a resolved colour"};if(e.kind==="hex"){let a=e.value.toUpperCase();return fr.test(a)?{ok:true,color:{kind:"hex",value:a}}:{ok:false,reason:"fill colour requires a six-digit hex value"}}let n=lo(e,t);return n.ok?{ok:true,color:{kind:"theme",slot:xa(e.slot)??e.slot,resolvedHex:n.hex,...e.tint!==void 0?{tint:e.tint}:{},...e.shade!==void 0?{shade:e.shade}:{}}}:n}function vf(e,t,n="000000"){if(!e||e.kind==="auto")return `#${n}`;if(e.kind==="hex"){let a=e.value.replace(/^#/,"").toUpperCase();return fr.test(a)?`#${a}`:`#${n}`}let r=lo(e,t);return `#${r.ok?r.hex:n}`}var Sf=new Set(["insertRow","deleteRow","insertColumn","deleteColumn","deleteTable","setCellFill","setTableCellVerticalAlignment","setTableBorders","commitTableColumnDividerResize","commitTableRightEdgeResize","mergeCells","splitCell","toggleHeaderRow","selectTableRegion","setTableProperties"]);function Sn(e){return Sf.has(e.type)}function te(e,t){return {ok:false,code:e,reason:t}}function ka(e,t){switch(e){case "unknown-table":case "unknown-row":case "unknown-grid-column":return te("invalidArgs","the table target is no longer valid");case "table-has-merge":return te("unsupported","this table has merged cells");case "vertical-merge-crossing":return te("unsupported","the row cannot be inserted across a vertical merge");case "block-required":return te("unsupported","the table must keep at least one row or column");case "resource-limit":return te("unsupported","the table has reached the supported size limit");case "invalidArgs":case "invalid-property-value":case "unsupported-property":return te("invalidArgs","the table command arguments are invalid");default:return te("unsupported",`the table operation was refused (${e})`)}}function Ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ot(e,t){return !Ze(e)||Object.keys(e).length!==t.length?false:t.every(r=>Object.prototype.hasOwnProperty.call(e,r))}function Il(e){if(!Ze(e))return false;let t=e.kind;if(t==="hex")return ot(e,["kind","value"])&&typeof e.value=="string";if(t==="auto")return ot(e,["kind"]);if(t==="theme"){if(typeof e.slot!="string")return false;let n=["kind","slot"];if(e.tint!==void 0){if(typeof e.tint!="number"||!Number.isFinite(e.tint))return false;n.push("tint");}if(e.shade!==void 0){if(typeof e.shade!="number"||!Number.isFinite(e.shade))return false;n.push("shade");}return ot(e,n)}return false}function Sl(e){return Ze(e)&&ot(e,["sourceRevision","tableId","rowId","isHeaderRepeat"])&&typeof e.sourceRevision=="number"&&Number.isInteger(e.sourceRevision)&&typeof e.tableId=="string"&&e.tableId.length>0&&typeof e.rowId=="string"&&e.rowId.length>0&&typeof e.isHeaderRepeat=="boolean"}function kl(e){return Ze(e)&&ot(e,["sourceRevision","tableId","gridColumnId","isHeaderRepeat"])&&typeof e.sourceRevision=="number"&&Number.isInteger(e.sourceRevision)&&typeof e.tableId=="string"&&e.tableId.length>0&&typeof e.gridColumnId=="string"&&e.gridColumnId.length>0&&typeof e.isHeaderRepeat=="boolean"}function kf(e){return Ze(e)&&ot(e,["sourceRevision","tableId","leftGridColumnId","rightGridColumnId","isHeaderRepeat"])&&typeof e.sourceRevision=="number"&&Number.isInteger(e.sourceRevision)&&typeof e.tableId=="string"&&typeof e.leftGridColumnId=="string"&&typeof e.rightGridColumnId=="string"&&typeof e.isHeaderRepeat=="boolean"}function Tf(e){return Ze(e)&&ot(e,["sourceRevision","tableId","gridColumnId","isHeaderRepeat"])&&typeof e.sourceRevision=="number"&&Number.isInteger(e.sourceRevision)&&typeof e.tableId=="string"&&typeof e.gridColumnId=="string"&&typeof e.isHeaderRepeat=="boolean"}function Pf(e){return !Ze(e)||!ot(e,["style","size","color"])?false:typeof e.style=="string"&&typeof e.size=="number"&&Number.isInteger(e.size)&&Il(e.color)}function vl(e){return !("target"in e)||e.target===void 0||Sl(e.target)}function bl(e){return !("target"in e)||e.target===void 0||kl(e.target)}function wf(e){switch(e.type){case "insertRow":return !Ze(e)||e.type!=="insertRow"?te("invalidArgs","insertRow command shape is invalid"):e.where!=="above"&&e.where!=="below"?te("invalidArgs","insertRow where must be above or below"):vl(e)?null:te("invalidArgs","insertRow target shape is invalid");case "deleteRow":return !Ze(e)||e.type!=="deleteRow"?te("invalidArgs","deleteRow command shape is invalid"):vl(e)?null:te("invalidArgs","deleteRow target shape is invalid");case "insertColumn":return !Ze(e)||e.type!=="insertColumn"?te("invalidArgs","insertColumn command shape is invalid"):e.where!=="left"&&e.where!=="right"?te("invalidArgs","insertColumn where must be left or right"):bl(e)?null:te("invalidArgs","insertColumn target shape is invalid");case "deleteColumn":return !Ze(e)||e.type!=="deleteColumn"?te("invalidArgs","deleteColumn command shape is invalid"):bl(e)?null:te("invalidArgs","deleteColumn target shape is invalid");case "deleteTable":return !Ze(e)||!ot(e,["type"])?te("invalidArgs","deleteTable command shape is invalid"):null;case "setCellFill":return !Ze(e)||!ot(e,["type","color"])?te("invalidArgs","setCellFill command shape is invalid"):e.color!==null&&!Il(e.color)?te("invalidArgs","setCellFill color shape is invalid"):null;case "setTableCellVerticalAlignment":return !Ze(e)||!ot(e,["type","alignment"])||!["top","center","bottom"].includes(e.alignment)?te("invalidArgs","cell vertical alignment command shape is invalid"):null;case "setTableBorders":return !Ze(e)||e.type!=="setTableBorders"?te("invalidArgs","setTableBorders command shape is invalid"):e.scope==="none"?typeof e.target!="string"?te("invalidArgs","border none scope requires a target edge"):null:!("spec"in e)||!Pf(e.spec)?te("invalidArgs","concrete border scopes require a complete spec"):null;case "commitTableColumnDividerResize":return !Ze(e)||!ot(e,["type","target","leftWidthTwips","rightWidthTwips"])||!kf(e.target)||typeof e.leftWidthTwips!="number"||typeof e.rightWidthTwips!="number"?te("invalidArgs","column divider resize command shape is invalid"):null;case "commitTableRightEdgeResize":return !Ze(e)||!ot(e,["type","target","columnWidthTwips","tableWidthTwips"])||!Tf(e.target)||typeof e.columnWidthTwips!="number"||typeof e.tableWidthTwips!="number"?te("invalidArgs","right-edge resize command shape is invalid"):null;default:return null}}function Cf(e){return !("target"in e)||e.target===void 0?null:Sl(e.target)?e.target:null}function Rf(e){return !("target"in e)||e.target===void 0?null:kl(e.target)?e.target:null}function xl(e,t,n){let r=_if(e.root,t);return !r.ok||!r.topology.grid?null:r.topology.gridColumns[n]?.id??null}function Ef(e){let t=Id$1(e.layout,e.selection.head.paragraphId,e.cellSelection);return t?{tableId:t.tableId,rowId:t.rowId,cellId:t.cellId,cellIds:[...t.cellIds],gridColumnIndex:t.gridColumnIndex,isHeaderRepeat:t.isHeaderRepeat}:null}function Ff(e){let t=gf$1(e,"tcPr"),n=t&&gf$1(t,"gridSpan"),r=n&&hf$1(n,"val");if(!r||!/^\d{1,7}$/.test(r))return 1;let a=Number(r);return Number.isInteger(a)&&a>1?Math.min(a,1024):1}function Of(e,t,n){let r=e.gridColumns.findIndex(a=>a.id===n);if(r===-1)return null;for(let{row:a,cells:o}of e.rows){let i=0;for(let l of o){let d=Ff(l);if(r>=i&&r<i+d)return {tableId:t,rowId:a.id,cellId:l.id,cellIds:[l.id],gridColumnIndex:r,isHeaderRepeat:false};i+=d;}}return null}function Af(e,t){if(t.sourceRevision!==e.storeRevision||t.isHeaderRepeat)return null;let n=_if(e.part.root,t.tableId);if(!n.ok)return null;let r=n.topology.rows.findIndex(i=>i.row.id===t.rowId);if(r===-1)return null;let o=n.topology.rows[r].cells[0];return o?{tableId:t.tableId,rowId:t.rowId,cellId:o.id,cellIds:[o.id],gridColumnIndex:0,isHeaderRepeat:false}:null}function Mf(e,t){if(t.sourceRevision!==e.storeRevision||t.isHeaderRepeat)return null;let n=_if(e.part.root,t.tableId);return n.ok?Of(n.topology,t.tableId,t.gridColumnId):null}function Hf(e,t){for(let n of t){let r=xf(e,n);if(r)return ka(r)}return null}function ct(e,t,n){let r=Hf(e,t);return r||{ok:true,ops:t,selection:n}}function Lf(e,t){if(!jf$1.includes(e.style))return {ok:false,reason:"border style is not allowlisted"};if(!Number.isInteger(e.size)||e.size<1)return {ok:false,reason:"border size is out of range"};if(e.size>96)return {ok:false,reason:"border size is out of range"};let n=Ia(e.color,t);return n.ok?{ok:true,spec:{style:e.style,size:e.size,color:n.color}}:{ok:false,reason:n.reason}}function pr(e,t,n){return n!==e.storeRevision?te("invalidArgs","the table target is stale"):_if(e.part.root,t).ok?null:te("invalidArgs","the table target is no longer valid")}function Df(e){return e?.isHeaderRepeat?te("unsupported","repeated header rows cannot be edited"):null}function Nf(e,t,n,r){let a=pr(e,t.tableId,t.sourceRevision);if(a)return a;if(t.isHeaderRepeat)return te("unsupported","repeated header rows cannot be edited");if(!Number.isInteger(n)||!Number.isInteger(r))return te("invalidArgs","column widths must be whole twips");if(n<300||r<300)return te("invalidArgs","column widths are below the minimum");let o=_if(e.part.root,t.tableId);if(!o.ok){let C=o.reason==="duplicate-node-id"?"unknown-table":o.reason;return ka(C)}if(o.topology.hasMerge)return te("unsupported","this table has merged cells");let i=o.topology.gridColumns.find(C=>C.id===t.leftGridColumnId),l=o.topology.gridColumns.find(C=>C.id===t.rightGridColumnId);if(!i||!l)return te("invalidArgs","the table target is no longer valid");let d=o.topology.gridColumns.indexOf(i);if(o.topology.gridColumns.indexOf(l)!==d+1)return te("invalidArgs","the column divider target is not adjacent");let y={op:"setTableColumnWidths",tableId:t.tableId,leftGridColumnId:t.leftGridColumnId,rightGridColumnId:t.rightGridColumnId,leftWidthTwips:n,rightWidthTwips:r};return ct(e.part,[y],{kind:"preserveSelection"})}function _f(e,t,n,r){let a=pr(e,t.tableId,t.sourceRevision);if(a)return a;if(t.isHeaderRepeat)return te("unsupported","repeated header rows cannot be edited");if(!Number.isInteger(n)||!Number.isInteger(r))return te("invalidArgs","column widths must be whole twips");if(n<300)return te("invalidArgs","column widths are below the minimum");let o=_if(e.part.root,t.tableId);if(!o.ok){let d=o.reason==="duplicate-node-id"?"unknown-table":o.reason;return ka(d)}if(o.topology.hasMerge)return te("unsupported","this table has merged cells");let i=o.topology.gridColumns[o.topology.gridColumns.length-1];if(!i||i.id!==t.gridColumnId)return te("invalidArgs","the resize target is not the table right edge");let l={op:"setTableRightEdgeWidth",tableId:t.tableId,gridColumnId:t.gridColumnId,columnWidthTwips:n,tableWidthTwips:r};return ct(e.part,[l],{kind:"preserveSelection"})}function Tl(e,t,n){if(e.viewing||!e.editable)return te("locked","the document is open for viewing");let r=pr(e,t.tableId,t.sourceRevision);if(r)return r;if(t.isHeaderRepeat)return te("unsupported","repeated header rows cannot be edited");if(!Number.isInteger(n)||n<20||n>31680)return te("invalidArgs","row height is outside the supported range");let a={op:"setTableRowHeight",tableId:t.tableId,rowId:t.rowId,heightTwips:n};return ct(e.part,[a],{kind:"preserveSelection"})}function Nt(e){let{command:t,part:n,viewing:r,editable:a}=e;if(r||!a)return te("locked","the document is open for viewing");switch(t.type){case "mergeCells":return te("unsupported","cell merge is not supported yet");case "splitCell":return te("unsupported","cell split is not supported yet");case "toggleHeaderRow":case "selectTableRegion":case "setTableProperties":return te("unsupported",`command '${t.type}' is not supported by the tree editor`);}let o=wf(t);if(o)return o;let i=Cf(t),l=Rf(t),d=Df(i??l);if(d)return d;if(i){let y=pr(e,i.tableId,i.sourceRevision);if(y)return y}if(l){let y=pr(e,l.tableId,l.sourceRevision);if(y)return y}let p=i!==null?Af(e,i):l!==null?Mf(e,l):Ef(e);if(t.type!=="commitTableColumnDividerResize"&&t.type!=="commitTableRightEdgeResize"&&!p)return i||l?te("invalidArgs","the table target is no longer valid"):te("unsupported","the selection is not inside a table");if(p?.isHeaderRepeat)return te("unsupported","repeated header rows cannot be edited");switch(t.type){case "insertRow":{if(!p)return te("unsupported","the selection is not inside a table");let y={op:"insertTableRow",tableId:p.tableId,rowId:p.rowId,where:t.where};return ct(n,[y],{kind:"adoptCommittedCaret"})}case "deleteRow":{if(!p)return te("unsupported","the selection is not inside a table");let y={op:"deleteTableRow",tableId:p.tableId,rowId:p.rowId,referenceCellId:p.cellId};return ct(n,[y],{kind:"adoptCommittedCaret"})}case "insertColumn":{if(!p)return te("unsupported","the selection is not inside a table");let y=l?.tableId??p.tableId,C=l?.gridColumnId??xl(n,y,p.gridColumnIndex),S=C?{op:"insertTableColumn",tableId:y,where:t.where,gridColumnId:C}:{op:"insertTableColumn",tableId:y,where:t.where,referenceCellId:p.cellId};return ct(n,[S],{kind:"adoptCommittedCaret"})}case "deleteColumn":{if(!p)return te("unsupported","the selection is not inside a table");let y=l?.tableId??p.tableId,C=l?.gridColumnId??xl(n,y,p.gridColumnIndex);return C?ct(n,[{op:"deleteTableColumn",tableId:y,gridColumnId:C}],{kind:"adoptCommittedCaret"}):te("invalidArgs","the table has no grid column to delete")}case "deleteTable":{if(!p)return te("unsupported","the selection is not inside a table");let y={op:"deleteBlock",blockId:p.tableId};return ct(n,[y],{kind:"adoptCommittedCaret"})}case "setCellFill":{if(!p)return te("unsupported","the selection is not inside a table");let y;if(t.color===null)y=null;else {let S=Sa(t.color,e.themeColors);if(!S.ok)return te("invalidArgs",S.reason);y=S.color;}let C={op:"setTableCellFill",tableId:p.tableId,cellIds:p.cellIds,color:y};return ct(n,[C],{kind:"preserveSelection"})}case "setTableCellVerticalAlignment":{if(!p)return te("unsupported","the selection is not inside a table");let y={op:"setTableCellVerticalAlignment",tableId:p.tableId,cellIds:p.cellIds,alignment:t.alignment};return ct(n,[y],{kind:"preserveSelection"})}case "setTableBorders":{if(!p)return te("unsupported","the selection is not inside a table");if(t.scope==="none"){let S={op:"setTableCellBorders",tableId:p.tableId,cellIds:p.cellIds,scope:"none",target:t.target};return ct(n,[S],{kind:"preserveSelection"})}let y=Lf(t.spec,e.themeColors);if(!y.ok)return te("invalidArgs",y.reason);let C={op:"setTableCellBorders",tableId:p.tableId,cellIds:p.cellIds,scope:t.scope,spec:y.spec};return ct(n,[C],{kind:"preserveSelection"})}case "commitTableColumnDividerResize":return Nf(e,t.target,t.leftWidthTwips,t.rightWidthTwips);case "commitTableRightEdgeResize":return _f(e,t.target,t.columnWidthTwips,t.tableWidthTwips);default:return te("unsupported",`command '${t.type}' is not a table command`)}}function Pl(e){if(!Sn(e))return {supported:false,reason:`command '${e.type}' is not a table command`};switch(e.type){case "mergeCells":return {supported:false,reason:"cell merge is not supported yet"};case "splitCell":return {supported:false,reason:"cell split is not supported yet"};case "toggleHeaderRow":case "selectTableRegion":case "setTableProperties":return {supported:false,reason:`command '${e.type}' is not supported by the tree editor`};default:return {supported:true}}}function co(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;if(Array.isArray(e)){for(let n of e)co(n);return Object.freeze(e)}let t=e;for(let n of Object.keys(t))co(t[n]);return Object.freeze(e)}var Ta=new Map([["bold",{localName:"b"}],["italic",{localName:"i"}],["underline",{localName:"u",attributes:{val:"single"}}],["strike",{localName:"strike"}],["superscript",{localName:"vertAlign",attributes:{val:"superscript"}}],["subscript",{localName:"vertAlign",attributes:{val:"subscript"}}]]),Bf=new Set(["none","black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","red","yellow","white"]),Zf=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,qf=/^[0-9A-Fa-f]{6}$/;function Pa(e){let{mark:t,value:n}=e;switch(t){case "fontFamily":return typeof n!="string"||!Zf.test(n)?{ok:false,code:"invalidArgs",reason:"fontFamily requires a family name of 1-64 letters, digits, or [ -.+_]"}:{ok:true,localName:"rFonts",attributes:{ascii:n,hAnsi:n}};case "fontSize":return typeof n!="number"||!Number.isInteger(n)||n<2||n>3276?{ok:false,code:"invalidArgs",reason:"fontSize requires an integer half-point value between 2 and 3276"}:{ok:true,localName:"sz",attributes:{val:String(n)}};case "color":return typeof n!="string"||n!=="auto"&&!qf.test(n)?{ok:false,code:"invalidArgs",reason:"color requires a six-digit hex value like FF0000, or 'auto'"}:{ok:true,localName:"color",attributes:{val:n}};case "highlight":return typeof n!="string"||!Bf.has(n)?{ok:false,code:"invalidArgs",reason:"highlight requires an ST_HighlightColor name (yellow, cyan, ...)"}:{ok:true,localName:"highlight",attributes:{val:n}};default:return {ok:false,code:"unsupported",reason:`mark '${t}' is not supported by setMarkAttr`}}}function El(e){return typeof e=="object"&&e!==null&&typeof e.paragraphId=="string"&&typeof e.offset=="number"}function wa(e){return typeof e=="object"&&e!==null&&El(e.anchor)&&El(e.head)}function kn(e,t){let n=new Error(t);return n.code=e,n}function Ca(e,t){return e===t?true:!e||!t?false:e.anchor.paragraphId===t.anchor.paragraphId&&e.anchor.offset===t.anchor.offset&&e.head.paragraphId===t.head.paragraphId&&e.head.offset===t.head.offset}function Ra(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function gr(e){switch(e.type){case "toggleMark":return Ta.has(e.mark)?{supported:true,mutating:true}:{supported:false,reason:`mark '${e.mark}' is not supported`};case "setMarkAttr":{let t=Pa(e);return t.ok?{supported:true,mutating:true}:{supported:false,reason:t.reason,code:t.code}}case "setAlignment":return {supported:true,mutating:true};case "clearFormatting":return {supported:true,mutating:true};case "setLineSpacing":{if(!["multiple","exact","atLeast"].includes(e.rule))return {supported:false,code:"invalidArgs",reason:"setLineSpacing requires a rule of 'multiple', 'exact' or 'atLeast'"};let n=e.rule==="multiple"?e.value*240:e.value*20;return !Number.isFinite(e.value)||e.value<=0||Math.round(n)>31680?{supported:false,code:"invalidArgs",reason:"setLineSpacing requires a positive value no taller than 1584pt"}:{supported:true,mutating:true}}case "setParagraphSpacing":{for(let t of ["beforePt","afterPt"]){let n=e[t];if(n!=null&&(!Number.isFinite(n)||n<0||n>1584))return {supported:false,code:"invalidArgs",reason:`setParagraphSpacing requires ${t} between 0 and 1584 points`}}return {supported:true,mutating:true}}case "setParagraphStyle":return e.target!==void 0?{supported:false,reason:"DocTarget addressing is not supported; the style applies at the selection"}:typeof e.styleId!="string"||e.styleId.length===0||e.styleId.length>128||/[\u0000-\u001f\u007f-\u009f]/.test(e.styleId)?{supported:false,code:"invalidArgs",reason:"setParagraphStyle requires a styleId of 1-128 printable characters"}:{supported:true,mutating:true};case "insertHyperlink":return e.target!==void 0?{supported:false,reason:"DocTarget addressing is not supported; a link applies at the selection"}:typeof e.href!="string"||e.href.length===0?{supported:false,code:"invalidArgs",reason:"insertHyperlink requires an href"}:{supported:true,mutating:true};case "removeHyperlink":return e.target===void 0?{supported:true,mutating:true}:{supported:false,reason:"DocTarget addressing is not supported; unlink acts at the selection"};case "setIndent":{let t=[e.left,e.right,e.firstLine];if(t.every(n=>n===void 0))return {supported:false,reason:"setIndent requires at least one indent field"};for(let n of t)if(n!=null){if(!Number.isInteger(n))return {supported:false,reason:"indent values must be whole twips"};if(Math.abs(n)>nb)return {supported:false,reason:`indent values must be within \xB1${nb} twips`}}return {supported:true,mutating:true}}case "toggleList":return e.kind==="bullet"||e.kind==="ordered"?{supported:true,mutating:true}:{supported:false,reason:`list kind '${e.kind}' is not supported`};case "adjustIndent":return e.direction==="increase"||e.direction==="decrease"?{supported:true,mutating:true}:{supported:false,reason:`indent direction '${e.direction}' is not supported`};case "insertBreak":return e.kind==="line"||e.kind==="page"||e.kind==="section"?{supported:true,mutating:true}:{supported:false,reason:`break kind '${e.kind}' is not supported`};case "insertText":return e.target===void 0?{supported:true,mutating:true}:{supported:false,reason:"DocTarget addressing is not supported; text inserts at the selection"};case "deleteText":return e.target===void 0?{supported:true,mutating:true}:{supported:false,reason:"DocTarget addressing is not supported; deletion removes the selection"};case "setPageSetup":{let t=[e.pageWidth,e.pageHeight],n=[e.marginTop,e.marginRight,e.marginBottom,e.marginLeft];if(t.every(r=>r===void 0)&&n.every(r=>r===void 0)&&e.orientation===void 0)return {supported:false,reason:"setPageSetup requires at least one field"};for(let r of t)if(r!==void 0&&(!Number.isInteger(r)||r<1||r>63360))return {supported:false,code:"invalidArgs",reason:"page dimensions must be integer twips between 1 and 63360"};for(let r of n)if(r!==void 0&&(!Number.isInteger(r)||r<0||r>31680))return {supported:false,code:"invalidArgs",reason:"margins must be integer twips between 0 and 31680"};return e.orientation!==void 0&&e.orientation!=="portrait"&&e.orientation!=="landscape"?{supported:false,code:"invalidArgs",reason:"orientation must be 'portrait' or 'landscape'"}:e.scope!==void 0&&e.scope!=="document"&&e.scope!=="section"?{supported:false,code:"invalidArgs",reason:"scope must be 'document' or 'section'"}:{supported:true,mutating:true}}case "undo":case "redo":return {supported:true,mutating:true};case "insertTable":return Number.isInteger(e.rows)&&Number.isInteger(e.cols)&&e.rows>=1&&e.cols>=1&&e.rows<=32767&&e.cols<=63&&e.rows*e.cols<=2e4?{supported:true,mutating:true}:{supported:false,code:"invalidArgs",reason:`insertTable needs whole rows and cols of at least 1, at most ${32767}\xD7${63}, and at most ${2e4} cells`};case "insertToc":return {supported:true,mutating:true};case "refreshToc":return e.mode!==void 0&&e.mode!=="entire"&&e.mode!=="pageNumbers"?{supported:false,code:"invalidArgs",reason:"refreshToc mode must be 'entire' or 'pageNumbers'"}:e.tocId!==void 0&&(typeof e.tocId!="string"||e.tocId.length===0)?{supported:false,code:"invalidArgs",reason:"refreshToc tocId must be a non-empty string"}:{supported:true,mutating:true};case "editHeaderFooter":return e.position!=="header"&&e.position!=="footer"?{supported:false,reason:"editHeaderFooter requires position 'header' or 'footer'"}:e.variant!==void 0&&e.variant!=="default"&&e.variant!=="first"&&e.variant!=="even"?{supported:false,reason:"editHeaderFooter variant must be 'default', 'first', or 'even'"}:{supported:true,mutating:true};case "exitHeaderFooter":return {supported:true,mutating:false};case "removeHeaderFooter":case "linkHeaderFooterToPrevious":case "unlinkHeaderFooterFromPrevious":return "variant"in e&&e.variant!==void 0&&e.variant!=="default"&&e.variant!=="first"&&e.variant!=="even"?{supported:false,reason:"furniture variant must be 'default', 'first', or 'even'"}:{supported:true,mutating:true};case "setHeaderFooterOptions":return e.titlePage===void 0&&e.evenAndOddHeaders===void 0&&e.headerDistanceTwips===void 0&&e.footerDistanceTwips===void 0?{supported:false,reason:"setHeaderFooterOptions requires at least one option"}:{supported:true,mutating:true};case "insertPageField":return e.field==="PAGE"||e.field==="NUMPAGES"||e.field==="SECTIONPAGES"||e.field==="PAGE_X_OF_Y"?{supported:true,mutating:true}:{supported:false,reason:"insertPageField field must be 'PAGE', 'NUMPAGES', 'SECTIONPAGES', or 'PAGE_X_OF_Y'"};case "insertNote":return e.noteKind==="footnote"||e.noteKind==="endnote"?{supported:true,mutating:true}:{supported:false,reason:"insertNote noteKind must be 'footnote' or 'endnote'"};case "deleteNote":return e.noteKind==="footnote"||e.noteKind==="endnote"?{supported:true,mutating:true}:{supported:false,reason:"deleteNote noteKind must be 'footnote' or 'endnote'"};case "convertNote":return e.fromKind==="footnote"||e.fromKind==="endnote"?{supported:true,mutating:true}:{supported:false,reason:"convertNote fromKind must be 'footnote' or 'endnote'"};case "convertAllNotes":return e.fromKind==="footnote"||e.fromKind==="endnote"?{supported:true,mutating:true}:{supported:false,reason:"convertAllNotes fromKind must be 'footnote' or 'endnote'"};case "setNoteProperties":return e.endnote?.position==="pageBottom"?{supported:false,reason:"endnote-pageBottom"}:e.footnote!==void 0||e.endnote!==void 0?{supported:true,mutating:true}:{supported:false,reason:"setNoteProperties requires footnote and/or endnote fields"};case "selectAll":case "copy":return {supported:true,mutating:false};case "cut":return {supported:true,mutating:true};case "paste":return typeof e.text!="string"?{supported:false,code:"invalidArgs",reason:"paste requires text"}:e.text===""?{supported:false,code:"invalidArgs",reason:"there is nothing to paste"}:{supported:true,mutating:true};case "insertRow":case "deleteRow":case "insertColumn":case "deleteColumn":case "deleteTable":case "setCellFill":case "setTableCellVerticalAlignment":case "setTableBorders":case "commitTableColumnDividerResize":case "commitTableRightEdgeResize":case "mergeCells":case "splitCell":case "toggleHeaderRow":case "selectTableRegion":case "setTableProperties":{let t=Pl(e);return t.supported?{supported:true,mutating:true}:{supported:false,reason:t.reason??"unsupported table command"}}case "setSelection":return "range"in e&&(wa(e.range)||In(e.range))||"anchor"in e&&Pt(e.anchor)?{supported:true,mutating:false}:{supported:false,reason:"setSelection accepts { anchor: { paraId } }, a { range } whose from/to are paraId anchors, or a { range } carrying a semantic { anchor: { paragraphId, offset }, head } selection"};case "insertImage":return e.data instanceof Uint8Array&&(e.mime==="image/png"||e.mime==="image/jpeg"||e.mime==="image/gif")&&Number.isFinite(e.widthPoints)&&Number.isFinite(e.heightPoints)&&e.widthPoints>0&&e.heightPoints>0?{supported:true,mutating:true}:{supported:false,code:"invalidArgs",reason:"insertImage requires png/jpeg/gif bytes and finite dimensions"};case "replaceImage":return e.data instanceof Uint8Array?{supported:true,mutating:true}:{supported:false,code:"invalidArgs",reason:"replaceImage requires image bytes"};case "deleteImage":return {supported:true,mutating:true};case "setImageWrapType":return ["inline","square","squareLeft","squareRight","tight","through","topAndBottom","behind","inFront"].includes(e.target)?{supported:true,mutating:true}:{supported:false,code:"invalidArgs",reason:"unsupported wrap target"};case "transformImage":return e.action==="rotateCW"||e.action==="rotateCCW"||e.action==="flipH"||e.action==="flipV"?{supported:true,mutating:true}:{supported:false,code:"invalidArgs",reason:"unsupported transform action"};case "setImagePosition":return {supported:true,mutating:true};case "setImageProperties":return {supported:true,mutating:true};default:return {supported:false,reason:`command '${e.type}' is not supported by the tree editor`}}}function Ol(e,t){if(e===t)return true;if(!e||!t||e.bold!==t.bold||e.italic!==t.italic||e.underline!==t.underline||e.strike!==t.strike||e.superscript!==t.superscript||e.subscript!==t.subscript||e.highlight!==t.highlight||e.fontFamily!==t.fontFamily||e.fontSizePt!==t.fontSizePt||e.alignment!==t.alignment||e.styleId!==t.styleId||e.spaceBeforePt!==t.spaceBeforePt||e.spaceAfterPt!==t.spaceAfterPt||e.lineSpacing?.rule!==t.lineSpacing?.rule||e.lineSpacing?.value!==t.lineSpacing?.value||e.indent?.left!==t.indent?.left||e.indent?.right!==t.indent?.right||e.indent?.firstLine!==t.indent?.firstLine||e.indent?.mixed.left!==t.indent?.mixed.left||e.indent?.mixed.right!==t.indent?.mixed.right||e.indent?.mixed.firstLine!==t.indent?.mixed.firstLine)return false;if(e.color===t.color)return true;if(!e.color||!t.color)return false;let n=e.color,r=t.color,a=new Set([...Object.keys(n),...Object.keys(r)]);for(let o of a)if(n[o]!==r[o])return false;return true}function Al(e,t){return e.current===t.current&&e.total===t.total}function Ml(e,t){return e===t?true:!e||!t?false:e.pageWidthTwips===t.pageWidthTwips&&e.pageHeightTwips===t.pageHeightTwips&&e.orientation===t.orientation&&e.marginsTwips.top===t.marginsTwips.top&&e.marginsTwips.right===t.marginsTwips.right&&e.marginsTwips.bottom===t.marginsTwips.bottom&&e.marginsTwips.left===t.marginsTwips.left&&e.gutterTwips===t.gutterTwips}function Fl(e,t){if(e===t)return true;if(!e||!t)return false;let n=e,r=t;return n.paraId===r.paraId&&n.search===r.search&&n.occurrence===r.occurrence}function Hl(e,t){return e===t?true:!e||!t||!In(e)||!In(t)?false:Fl(e.from,t.from)&&Fl(e.to,t.to)}function Ll(e,t){return e.scope===t.scope&&e.isLoading===t.isLoading&&e.parseError===t.parseError&&e.editable===t.editable&&e.zoom===t.zoom&&e.selection===t.selection&&e.selectionCollapsed===t.selectionCollapsed&&e.formatting===t.formatting&&e.table===t.table&&e.tocContext===t.tocContext&&e.image===t.image&&e.fontSubstitutions===t.fontSubstitutions&&e.page===t.page&&e.canUndo===t.canUndo&&e.canRedo===t.canRedo&&e.pageSetup===t.pageSetup&&e.reviewPaneOpen===t.reviewPaneOpen&&e.editingMode===t.editingMode&&e.lastRejection===t.lastRejection}function zf(e){return [e.left,e.top,e.right,e.bottom]}function Ea(e){return Object.freeze({left:e.left*100,top:e.top*100,right:e.right*100,bottom:e.bottom*100})}function Kf(e){return Object.freeze({left:e.left/100,top:e.top/100,right:e.right/100,bottom:e.bottom/100})}function mr(e){return Math.round(e*1e3)}function hr(e){return e/1e3}function Fa(e){return Object.freeze({left:mr(e.left),top:mr(e.top),right:mr(e.right),bottom:mr(e.bottom)})}function jf(e){return Object.freeze({left:hr(e.left),top:hr(e.top),right:hr(e.right),bottom:hr(e.bottom)})}function Oa(e){return zf(e).some(n=>!Number.isFinite(n)||n<0||n>100)?false:e.left+e.right<100&&e.top+e.bottom<100}var Vf=new Set(["insertImage","replaceImage"]),Uf=new Set(["insertImage","replaceImage","deleteImage","setImageWrapType","transformImage","setImagePosition","setImageProperties"]);function Gf(e,t){if(!e)return null;for(let n of e.drawings??[])if(n.start===t||n.start+1===t)return n;return null}function Wf(e,t,n){let r=e.layout();for(let a of r.pages){for(let o of a.anchoredDrawings??[])if(o.anchorParagraphId===t&&(o.start===n||o.start+1===n))return o;for(let o of [a.header,a.footer])if(o){for(let i of o.anchoredDrawings??[])if(i.anchorParagraphId===t&&(i.start===n||i.start+1===n))return i}}return null}function Dl(e){if(!e)return null;let{anchor:t,head:n}=e.state().selection;if(t.paragraphId!==n.paragraphId||t.offset!==n.offset)return null;let r=W(e.layout(),t.paragraphId,t.offset),a=Gf(r,t.offset);return a||Wf(e,t.paragraphId,t.offset)}function Nl(e,t){let n=e.storyScope(),r=e.session.partFor(n)??e.session.part(),a=Ea$1(r,t.drawingNodeId);return !a||a.kind!=="drawing"?null:ab(a,{ownerPartName:t.ownerPartName,supportedMcRequires:Ya$1,limits:Xa$1,resolveRelationship:Za$1(e.session.currentPackage(),t.ownerPartName)})}function _l(e){if(e.kind!=="anchored"||!e.position)return null;let t=e.position;return e.anchor?.simplePos?Object.freeze({mode:"simple",horizontalEmu:t.simplePosition.xEmu,verticalEmu:t.simplePosition.yEmu}):Object.freeze({mode:"frame",...t.horizontal.offsetEmu!==null?{horizontalEmu:t.horizontal.offsetEmu}:{},...t.vertical.offsetEmu!==null?{verticalEmu:t.vertical.offsetEmu}:{},relativeToH:t.horizontal.relativeFrom,relativeToV:t.vertical.relativeFrom})}function Xf(e){let t=e.resource;return t.kind!=="ready"?null:Object.freeze({pixelWidth:t.pixelWidth,pixelHeight:t.pixelHeight,dpiX:t.dpiX,dpiY:t.dpiY})}function Bl(e){let t=e.locks;return Object.freeze({canResize:!t.resize&&!e.hidden,canMove:!t.move&&!e.hidden,canChangeWrap:!t.move&&e.kind==="anchored"&&!e.hidden,canCrop:!t.resize&&!t.changeAspect&&!e.hidden})}function $f(e){return e.kind==="inlineDrawing"?"inline":e.wrap}function wt(e){let t=Dl(e);if(!t||t.placeholderGraphicKind!==null)return null;let n=e?Nl(e,t):null;if(!n||n.hidden||n.locks.select)return null;let r=t.transform;return Object.freeze({id:t.drawingNodeId,kind:n.kind,widthEmu:n.extentEmu.cx,heightEmu:n.extentEmu.cy,crop:Ea(t.crop),rotationDegrees:r.rotationDegrees,wrap:$f(t),position:_l(n),name:n.name,title:n.title,description:n.description,hyperlink:n.hyperlinkHref,locks:n.locks,hidden:n.hidden,resourceStatus:t.resource.kind,intrinsic:Xf(t),...Bl(n)})}function Zl(e,t){return e===t?true:!e||!t?false:e.id===t.id&&e.kind===t.kind&&e.widthEmu===t.widthEmu&&e.heightEmu===t.heightEmu&&e.crop.left===t.crop.left&&e.crop.top===t.crop.top&&e.crop.right===t.crop.right&&e.crop.bottom===t.crop.bottom&&e.rotationDegrees===t.rotationDegrees&&e.wrap===t.wrap&&e.name===t.name&&e.title===t.title&&e.description===t.description&&e.hyperlink===t.hyperlink&&e.hidden===t.hidden&&e.resourceStatus===t.resourceStatus&&e.canResize===t.canResize&&e.canMove===t.canMove&&e.canChangeWrap===t.canChangeWrap&&e.canCrop===t.canCrop&&e.locks.select===t.locks.select&&e.locks.move===t.locks.move&&e.locks.resize===t.locks.resize&&e.locks.changeAspect===t.locks.changeAspect&&(e.position?.mode??"frame")===(t.position?.mode??"frame")&&(e.position?.horizontalEmu??null)===(t.position?.horizontalEmu??null)&&(e.position?.verticalEmu??null)===(t.position?.verticalEmu??null)&&(e.position?.relativeToH??null)===(t.position?.relativeToH??null)&&(e.position?.relativeToV??null)===(t.position?.relativeToV??null)&&(e.intrinsic?.pixelWidth??null)===(t.intrinsic?.pixelWidth??null)&&(e.intrinsic?.pixelHeight??null)===(t.intrinsic?.pixelHeight??null)&&(e.intrinsic?.dpiX??null)===(t.intrinsic?.dpiX??null)&&(e.intrinsic?.dpiY??null)===(t.intrinsic?.dpiY??null)}function Aa(e){if("drawingNodeId"in e&&typeof e.drawingNodeId=="string")return e.drawingNodeId}function ql(e){if("expectedPackageRevision"in e&&typeof e.expectedPackageRevision=="number")return e.expectedPackageRevision}function Ma(e){return Aa(e)!==void 0||ql(e)!==void 0||e.type==="setImageProperties"&&e.selectionParagraphId!==void 0}function Ha(e,t,n){let r=e.surface;if(!r)return {ok:false,code:"notFound",reason:"no document is loaded"};let a=ql(t);if(a!==void 0&&r.session.packageRevision()!==a)return {ok:false,code:"notFound",reason:"stale package revision"};let o=Aa(t),i=wt(r);if(o!==void 0&&(!i||i.id!==o))return {ok:false,code:"notFound",reason:"stale drawing selection"};if(t.type==="setImageProperties"&&t.selectionParagraphId!==void 0&&t.selectionOffset!==void 0){let{anchor:l,head:d}=r.state().selection;if(l.paragraphId!==t.selectionParagraphId||l.offset!==t.selectionOffset||d.paragraphId!==t.selectionParagraphId||d.offset!==t.selectionOffset)return {ok:false,code:"notFound",reason:"stale drawing selection"}}return Pn(e,n,{requireDrawing:o!==void 0||n.drawingNodeId!==null,drawingNodeId:o??n.drawingNodeId??void 0})}function Gt(e,t){let n=wt(e),r=Aa(t);return r?!n||n.id!==r?{ok:false,code:"notFound",reason:"stale drawing selection"}:{id:r}:n?{id:n.id}:{ok:false,code:"notFound",reason:"no drawing is selected"}}function Yf(e){return e.rejected?{ok:false,code:"invalidArgs",reason:e.reason==="drawing-locked"?"the drawing is locked":e.reason==="unknown-drawing"?"stale drawing selection":typeof e.reason=="string"?e.reason:"the image change was refused"}:null}function uo(e,t){return Yf(e.applyDrawingOps(t))}function Qf(e){if(!e.intrinsic)return null;let t=Math.round(e.intrinsic.pixelWidth*914400/e.intrinsic.dpiX),n=Math.round(e.intrinsic.pixelHeight*914400/e.intrinsic.dpiY);return !Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{cx:t,cy:n}}function Jf(e){return e.borderWidthEmu!==void 0||e.borderColor!==void 0}function ep(e){return e.horizontalEmu!==void 0||e.verticalEmu!==void 0||e.relativeToH!==void 0||e.relativeToV!==void 0}function tp(e){return e.widthEmu!==void 0||e.heightEmu!==void 0||e.alt!==void 0||e.title!==void 0||e.description!==void 0||e.hyperlink!==void 0||e.crop!==void 0||e.wrap!==void 0||e.resetToNaturalSize===true||nf$1(e)}function zl(e,t){return t?.position?.mode==="simple"?Object.freeze({mode:"simple",...e.horizontalEmu!==void 0?{horizontalEmu:e.horizontalEmu}:{},...e.verticalEmu!==void 0?{verticalEmu:e.verticalEmu}:{}}):Object.freeze({mode:"frame",...e.horizontalEmu!==void 0?{horizontalEmu:e.horizontalEmu}:{},...e.verticalEmu!==void 0?{verticalEmu:e.verticalEmu}:{},...e.relativeToH!==void 0?{relativeToH:e.relativeToH}:{},...e.relativeToV!==void 0?{relativeToV:e.relativeToV}:{}})}function yr(e){return Uf.has(e.type)}function np(e){return Vf.has(e.type)}function Kl(e){return {ok:false,code:"unsupported",reason:`${e.type} is asynchronous; use executeImageCommand`}}function jl(e){if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};let t=e.editingMode();return t==="view"?{ok:false,code:"locked",reason:"the document is open for viewing"}:t==="suggest"?{ok:false,code:"invalidArgs",reason:"image property edits are not supported in suggesting mode"}:null}function vr(e){let t=e.surface;if(!t)return null;let{anchor:n}=t.state().selection,r=wt(t);return Object.freeze({mountGeneration:e.mountGeneration,packageRevision:t.session.packageRevision(),drawingNodeId:r?.id??null,selectionParagraphId:n.paragraphId,selectionOffset:n.offset})}function Pn(e,t,n){let r=e.surface;if(!r)return {ok:false,code:"notFound",reason:"no document is loaded"};if(e.mountGeneration!==t.mountGeneration)return {ok:false,code:"notFound",reason:"the editor is no longer attached"};let{anchor:a,head:o}=r.state().selection;if(a.paragraphId!==t.selectionParagraphId||a.offset!==t.selectionOffset)return {ok:false,code:"notFound",reason:"stale drawing selection"};if(a.paragraphId!==o.paragraphId||a.offset!==o.offset)return {ok:false,code:"notFound",reason:"stale drawing selection"};if(n?.requireDrawing){let i=wt(r),l=n.drawingNodeId??t.drawingNodeId;if(!i||!l||i.id!==l)return {ok:false,code:"notFound",reason:"stale drawing selection"}}return null}function br(e,t){if(!yr(e))return null;if(!t)return {ok:false,code:"notFound",reason:"no document is loaded"};if(e.type==="insertImage")return !(e.data instanceof Uint8Array)||e.data.byteLength===0?{ok:false,code:"invalidArgs",reason:"insertImage requires image bytes"}:!Number.isFinite(e.widthPoints)||!Number.isFinite(e.heightPoints)?{ok:false,code:"invalidArgs",reason:"insertImage requires finite dimensions"}:e.widthPoints<=0||e.heightPoints<=0?{ok:false,code:"invalidArgs",reason:"insertImage dimensions must be positive"}:null;if(e.type==="replaceImage"){if(!(e.data instanceof Uint8Array)||e.data.byteLength===0)return {ok:false,code:"invalidArgs",reason:"replaceImage requires image bytes"};let a=Gt(t,e);return "ok"in a?a:null}let n=Gt(t,e);if("ok"in n)return n;let r=wt(t);if(!r)return {ok:false,code:"notFound",reason:"no drawing is selected"};if(t.editingMode()==="suggest")return e.type==="deleteImage"?{ok:false,code:"invalidArgs",reason:"trackedDrawingDeletionUnsupported"}:{ok:false,code:"invalidArgs",reason:"image property edits are not supported in suggesting mode"};switch(e.type){case "deleteImage":return r.locks.select?{ok:false,code:"locked",reason:"the drawing cannot be selected"}:null;case "setImageWrapType":return r.canChangeWrap?null:{ok:false,code:"locked",reason:"wrap cannot be changed on this drawing"};case "transformImage":return r.locks.changeAspect||r.locks.resize?{ok:false,code:"locked",reason:"the drawing is locked"}:null;case "setImagePosition":if(!r.canMove||r.kind!=="anchored")return {ok:false,code:"locked",reason:"position cannot be changed on this drawing"};if(!ep(e))return {ok:false,code:"invalidArgs",reason:"setImagePosition requires at least one field"};let a=r.position?.mode??"frame";return pf$1(e,a)?kf$1(zl(e,r))?null:{ok:false,code:"invalidArgs",reason:"setImagePosition carries invalid position values"}:{ok:false,code:"invalidArgs",reason:"setImagePosition carries invalid position values"};case "setImageProperties":{if(Jf(e))return {ok:false,code:"unsupported",reason:"image border properties are not supported yet"};if(!tp(e))return {ok:false,code:"invalidArgs",reason:"setImageProperties requires at least one field"};if(e.resetToNaturalSize&&!r.intrinsic)return {ok:false,code:"invalidArgs",reason:"natural size is unavailable for this image"};if(e.widthEmu!==void 0&&(!Number.isFinite(e.widthEmu)||e.widthEmu<=0))return {ok:false,code:"invalidArgs",reason:"widthEmu must be a positive finite number"};if(e.heightEmu!==void 0&&(!Number.isFinite(e.heightEmu)||e.heightEmu<=0))return {ok:false,code:"invalidArgs",reason:"heightEmu must be a positive finite number"};if(e.widthEmu!==void 0&&!r.canResize)return {ok:false,code:"locked",reason:"the drawing is locked"};if(e.heightEmu!==void 0&&!r.canResize)return {ok:false,code:"locked",reason:"the drawing is locked"};if(e.crop!==void 0&&!Oa(e.crop))return {ok:false,code:"invalidArgs",reason:"crop values are out of range"};if(e.crop!==void 0&&!r.canCrop)return {ok:false,code:"locked",reason:"crop cannot be changed on this drawing"};if(e.hyperlink!==void 0&&e.hyperlink!==null&&!U(e.hyperlink).ok)return {ok:false,code:"invalidArgs",reason:"unsafe hyperlink URL"};if(e.wrap!==void 0&&!r.canChangeWrap)return {ok:false,code:"locked",reason:"wrap cannot be changed on this drawing"};if(nf$1(e)){if(!r.canMove||r.kind!=="anchored")return {ok:false,code:"locked",reason:"position cannot be changed on this drawing"};let o=r.position?.mode??"frame";if(!pf$1(e,o))return {ok:false,code:"invalidArgs",reason:"setImageProperties carries invalid position values"};if(!kf$1(of$1(e,r)))return {ok:false,code:"invalidArgs",reason:"setImageProperties carries invalid position values"}}return null}default:return null}}function La(e,t){let n=jl(t);if(n)return n;let r=br(e,t);return r||{ok:true}}function Vl(e,t){let n=br(e,t);return n||Kl(e)}function Ul(e,t,n){if(np(t))return Kl(t);let r=n&&Ma(t)?vr(n):null;if(r&&n){let a=Ha(n,t,r);if(a)return a}switch(t.type){case "deleteImage":{let a=Gt(e,t);if("ok"in a)return a;let o=e.deleteImage(a.id);return o.ok?null:{ok:false,code:"invalidArgs",reason:o.detail??o.reason??"deleteImage was refused"}}case "setImageWrapType":{let a=Gt(e,t);return "ok"in a?a:uo(e,[{op:"setDrawingWrap",drawingNodeId:a.id,wrap:t.target}])}case "transformImage":{let a=Gt(e,t);return "ok"in a?a:uo(e,[{op:"transformDrawing",drawingNodeId:a.id,action:t.action}])}case "setImagePosition":{let a=Gt(e,t);if("ok"in a)return a;let o=wt(e),i=zl(t,o);return uo(e,[{op:"positionDrawing",drawingNodeId:a.id,position:i}])}case "setImageProperties":{let a=Gt(e,t);if("ok"in a)return a;let o=wt(e);if(!o)return {ok:false,code:"notFound",reason:"no drawing is selected"};let i=[];if(t.resetToNaturalSize){let p=Qf(o);if(!p)return {ok:false,code:"invalidArgs",reason:"natural size is unavailable for this image"};i.push({op:"resizeDrawing",drawingNodeId:a.id,extentEmu:p});}else (t.widthEmu!==void 0||t.heightEmu!==void 0)&&i.push({op:"resizeDrawing",drawingNodeId:a.id,extentEmu:{cx:t.widthEmu??o.widthEmu,cy:t.heightEmu??o.heightEmu}});t.crop!==void 0&&i.push({op:"cropDrawing",drawingNodeId:a.id,crop:Fa(t.crop)});let l=t.title??t.alt,d=t.description??t.alt;if((l!==void 0||d!==void 0)&&i.push({op:"setDrawingMetadata",drawingNodeId:a.id,title:l??o.title,description:d??o.description}),t.wrap!==void 0&&i.push({op:"setDrawingWrap",drawingNodeId:a.id,wrap:t.wrap}),nf$1(t)){let p=of$1(t,o);i.push({op:"positionDrawing",drawingNodeId:a.id,position:p});}if(t.hyperlink!==void 0){let p=e.applyImageProperties({drawingNodeId:a.id,ops:i,hyperlink:t.hyperlink});return p.ok?null:{ok:false,code:"invalidArgs",reason:p.detail??p.reason??"setImageProperties was refused"}}return i.length===0?{ok:false,code:"invalidArgs",reason:"setImageProperties requires at least one field"}:uo(e,i)}default:return null}}async function Da(e,t){let n=e.surface;if(!n)return {ok:false,code:"notFound",reason:"no document is loaded"};let r=jl(n);if(r)return r;let a=br(t,n);if(a)return a;let o=vr(e);if(!o)return {ok:false,code:"notFound",reason:"no document is loaded"};if(t.type==="insertImage"){let{anchor:C}=n.state().selection,S=t.expectedPackageRevision??o.packageRevision;if(t.expectedPackageRevision!==void 0&&n.session.packageRevision()!==t.expectedPackageRevision)return {ok:false,code:"notFound",reason:"stale package revision"};let I=await n.insertImage({paragraphId:C.paragraphId,offset:C.offset,bytes:t.data,mime:t.mime,widthPoints:t.widthPoints,heightPoints:t.heightPoints,expectedPackageRevision:S,commitGuard:()=>Pn(e,o)===null,...t.title!==void 0?{title:t.title}:{},...t.description!==void 0?{description:t.description}:{},...t.hyperlink!==void 0?{hyperlink:t.hyperlink}:{}}),O=Pn(e,o);return O||(I.ok?{ok:true,changed:I.change!==null}:{ok:false,code:"invalidArgs",reason:I.detail==="stale-package-epoch"?"stale package revision":I.detail??I.reason??"insertImage was refused"})}let i=Gt(n,t);if("ok"in i)return i;let l=t.expectedPackageRevision??o.packageRevision;if(t.expectedPackageRevision!==void 0&&n.session.packageRevision()!==t.expectedPackageRevision)return {ok:false,code:"notFound",reason:"stale package revision"};let d=t.mime??"image/png",p=await n.replaceImage(i.id,t.data,d,{expectedPackageRevision:l,commitGuard:()=>Pn(e,o,{requireDrawing:true,drawingNodeId:i.id})===null}),y=Pn(e,o,{requireDrawing:true,drawingNodeId:i.id});return y||(p.ok?{ok:true,changed:p.change!==null}:{ok:false,code:"invalidArgs",reason:p.detail==="stale-package-epoch"?"stale package revision":p.detail??p.reason??"replaceImage was refused"})}var rp=1,op=10,xr=12700;function ap(e,t){if(!t||t.hidden||t.locks.select)return Object.freeze({canResize:false,canMove:false,aspectLocked:true});let n=Bl(t);return Object.freeze({canResize:n.canResize,canMove:n.canMove,aspectLocked:t.locks.changeAspect})}function ip(e){if(!e)return null;let{anchor:t,head:n}=e.state().selection;if(t.paragraphId!==n.paragraphId||t.offset!==n.offset)return null;let r=Dl(e);if(!r||r.accessibility.hidden)return null;let a=e.publishedLayout(),o=jc$1(a,r.drawingNodeId);if(!o)return null;let i=Nl(e,r);if(!i||i.locks.select)return null;let l=ap(r,i),d=r.kind==="anchoredDrawing"?Object.freeze({x:r.horizontalFrameOrigin,y:r.verticalFrameOrigin}):null;return Object.freeze({id:r.drawingNodeId,pageIndex:o.pageIndex,x:o.x,y:o.y,width:o.width,height:o.height,kind:r.kind==="inlineDrawing"?"inline":"anchored",widthEmu:i.extentEmu.cx,heightEmu:i.extentEmu.cy,position:_l(i),anchorFrameOrigin:d,transform:r.transform,...l})}function Ve(e){return Math.round(e*xr)}function Tn(e){return e/xr}function sp(e,t,n,r,a,o){let i=Tn(e),l=Tn(t),d=i/l,p=n.includes("e")?r:n.includes("w")?-r:0,y=n.includes("s")?a:n.includes("n")?-a:0;if(i=Math.max(1,i+p),l=Math.max(1,l+y),o)if(n.length===2){let S=Math.max(i/Tn(e),l/Tn(t));i=Math.max(1,Tn(e)*S),l=Math.max(1,i/d);}else n==="e"||n==="w"?l=Math.max(1,i/d):i=Math.max(1,l*d);return Object.freeze({cx:Ve(i),cy:Ve(l)})}function Na(e,t,n){return e.mode==="simple"?Object.freeze({mode:"simple",horizontalEmu:(e.horizontalEmu??0)+Ve(t),verticalEmu:(e.verticalEmu??0)+Ve(n)}):Object.freeze({mode:"frame",...e.horizontalEmu!==void 0?{horizontalEmu:e.horizontalEmu+Ve(t)}:{},...e.verticalEmu!==void 0?{verticalEmu:e.verticalEmu+Ve(n)}:{},...e.relativeToH!==void 0?{relativeToH:e.relativeToH}:{},...e.relativeToV!==void 0?{relativeToV:e.relativeToV}:{}})}function lp(e,t){let n=e.surface;return n?n.publishedLayout().revision!==t.layoutRevision?{ok:false,code:"notFound",reason:"stale layout revision"}:n.session.packageRevision()!==t.packageRevision?{ok:false,code:"notFound",reason:"stale package revision"}:Pn(e,t.preconditions,{requireDrawing:true,drawingNodeId:t.drawingNodeId}):{ok:false,code:"notFound",reason:"no document is loaded"}}function Gl(e){if(!e)return null;let t=e.formatting();return {bold:t.bold,italic:t.italic,underline:t.underline,strike:t.strikethrough,superscript:t.superscript,subscript:t.subscript,...t.color?{color:{kind:"hex",value:t.color}}:{},...t.highlight?{highlight:t.highlight}:{},...t.fontFamily?{fontFamily:t.fontFamily}:{},...t.fontSizeHalfPoints!==null?{fontSizePt:t.fontSizeHalfPoints/2}:{},...t.alignment?{alignment:t.alignment}:{},...t.styleId?{styleId:t.styleId}:{},...t.lineSpacing?{lineSpacing:t.lineSpacing}:{},...t.spaceBeforePt!==null?{spaceBeforePt:t.spaceBeforePt}:{},...t.spaceAfterPt!==null?{spaceAfterPt:t.spaceAfterPt}:{},...t.indent!==null?{indent:t.indent}:{}}}function _a(e){if(!e)return null;let t=e.sectionPropertiesAt(e.state().selection.head.paragraphId);return {pageWidthTwips:t.pageSize.widthTwips,pageHeightTwips:t.pageSize.heightTwips,orientation:t.landscape?"landscape":"portrait",marginsTwips:{top:t.margins.topTwips,right:t.margins.rightTwips,bottom:t.margins.bottomTwips,left:t.margins.leftTwips},gutterTwips:t.margins.gutterTwips}}function Ba(e){if(!e)return null;let{anchor:t,head:n}=e.state().selection,r=e.session.paragraphAnchors(),a=r.paraIdByNode.get(t.paragraphId),o=r.paraIdByNode.get(n.paragraphId);if(a===void 0||o===void 0)return null;let i=r.ordinalByNode.get(t.paragraphId)??0,l=r.ordinalByNode.get(n.paragraphId)??0;return l<i||l===i&&n.offset<t.offset?{from:{paraId:o},to:{paraId:a}}:{from:{paraId:a},to:{paraId:o}}}function Wl(e){if(!e)return null;let t=e.hyperlinks.linkAtCaret();if(!t)return null;let n=e.session.paragraphAnchors().paraIdByNode.get(t.paragraphId);return n===void 0?null:{href:t.href??"",range:{from:{paraId:n},to:{paraId:n}},...t.tooltip!==void 0?{tooltip:t.tooltip}:{}}}function Xl(e,t){if(!e)return [];if(t!==void 0&&t.part!=="body")return [];let n=e.session.part(),r=e.session.paragraphAnchors();return d$2(n).map(a=>{let o=r.paraIdByNode.get(a.id),i=a.kind==="textValue"?void 0:i$1(a);return {...o!==void 0?{paraId:o}:{},text:vf$1(n,a.id)??"",...i!==void 0?{styleId:i}:{}}})}function Za(e){return e?e.state().pageCount:0}function qa(e,t="caret"){return e?e.currentPage(t):1}function dp(e,t){if(!Sn(e))return {ok:false,refusal:{ok:false,code:"unsupported",reason:"not a table command"}};let n=fo(e,t);return n.can.ok?{ok:true,tablePlan:n.plan}:{ok:false,refusal:{ok:false,code:n.can.code,reason:n.can.reason}}}function cp(e,t){return {command:e,part:t.session.part(),layout:t.layout(),storeRevision:t.session.revision(),selection:t.state().selection,cellSelection:t.state().cellSelection,themeColors:t.session.documentThemeColors(),editable:t.session.editable,viewing:t.editingMode()==="view"}}function fo(e,t){let n=Nt(cp(e,t));return n.ok?{can:{ok:true},plan:n}:{can:{ok:false,code:n.code,reason:n.reason},plan:n}}function Ir(e,t,n,r){if(r?.scope){if(r.scope.kind==="all")return {ok:false,refusal:{ok:false,code:"unsupported",reason:"the all scope is read-only"}};if(r.scope.kind==="note"||r.scope.kind==="frame")return {ok:false,refusal:{ok:false,code:"unsupported",reason:`scope kind '${r.scope.kind}' is not supported`}};if(r.scope.kind==="headerFooter"){let i=t?.activeScope?.()??{kind:"body"};if(i.kind!=="headerFooter"||i.rId!==r.scope.rId)return {ok:false,refusal:{ok:false,code:"unsupported",reason:"open that header or footer before dispatching against its scope"}}}}let a=gr(e);if(!a.supported)return {ok:false,refusal:{ok:false,code:a.code??"unsupported",reason:a.reason}};if(!t)return {ok:false,refusal:{ok:false,code:"notFound",reason:"no document is loaded"}};if(a.mutating&&(n==="view"||!t.session.editable))return {ok:false,refusal:{ok:false,code:"locked",reason:"the document is read-only"}};if(e.type==="adjustIndent"&&!t.canAdjustIndent(e.direction))return {ok:false,refusal:{ok:false,code:"unsupported",reason:e.direction==="decrease"?"the selection is already at the outermost level":"the selection cannot indent any further"}};if(e.type==="copy"||e.type==="cut"||e.type==="deleteText"){let{anchor:i,head:l}=t.state().selection;if(i.paragraphId===l.paragraphId&&i.offset===l.offset)return {ok:false,refusal:{ok:false,code:"unsupported",reason:"nothing is selected"}}}if(e.type==="setParagraphStyle"&&!t.session.documentStyles().some(i=>i.type==="paragraph"))return {ok:false,refusal:{ok:false,code:"unsupported",reason:"this document defines no paragraph styles"}};if(e.type==="undo"&&!t.session.canUndo())return {ok:false,refusal:{ok:false,code:"unsupported",reason:"nothing to undo"}};if(e.type==="redo"&&!t.session.canRedo())return {ok:false,refusal:{ok:false,code:"unsupported",reason:"nothing to redo"}};if(e.type==="insertTable"&&!t.canInsertTable(e.rows,e.cols))return {ok:false,refusal:{ok:false,code:"unsupported",reason:"a table can only be inserted at a caret in editable body, cell, or note text"}};if(e.type==="insertToc"&&!t.canInsertToc())return {ok:false,refusal:{ok:false,code:"unsupported",reason:"a table of contents can only be inserted in the editable document body"}};if(e.type==="refreshToc"&&!t.canRefreshToc(e.tocId))return {ok:false,refusal:{ok:false,code:"notFound",reason:"there is no refreshable table of contents at the selection"}};if(e.type==="insertPageField"&&(t.activeScope?.()??{kind:"body"}).kind!=="headerFooter")return {ok:false,refusal:{ok:false,code:"unsupported",reason:"insertPageField requires an open header or footer scope"}};if(e.type==="insertNote"&&(t.activeScope?.()??{kind:"body"}).kind!=="body")return {ok:false,refusal:{ok:false,code:"unsupported",reason:"insertNote requires body scope"}};if(e.type==="linkHeaderFooterToPrevious"){let i=t.headerFooterState?.();if((e.sectionIndex??i?.sectionIndex??0)===0)return {ok:false,refusal:{ok:false,code:"invalidArgs",reason:"the first section cannot link to a previous header or footer"}}}if(Sn(e)){let i=dp(e,t);return i.ok?{ok:true,tablePlan:i.tablePlan}:i}let o=br(e,t);return o&&!o.ok?{ok:false,refusal:o}:{ok:true}}function $l(e){if(!e)return null;let t=e.state(),n=t.cellSelection,r=Hd$1(e.layout(),t.selection.head.paragraphId);return r?{blockId:r.tableId,rowCount:r.rows,columnCount:r.columns,cell:{row:n?n.rows.from:r.rowIndex,column:n?n.columns.from:r.columnIndex}}:null}function za(e){if(!e)return null;let t=e.state(),n=t.cellSelection,r=Hd$1(e.layout(),t.selection.head.paragraphId);return r?{rows:r.rows,columns:r.columns,rowIndex:n?n.rows.from:r.rowIndex,columnIndex:n?n.columns.from:r.columnIndex}:null}function Yl(e){return e?{...e.bold!==void 0?{bold:e.bold}:{},...e.italic!==void 0?{italic:e.italic}:{},...e.underline!==void 0?{underline:e.underline}:{},...e.fontFamily?{fontFamily:e.fontFamily}:{},...e.fontSizePt!==void 0?{fontSizeHalfPoints:Math.round(e.fontSizePt*2)}:{},...e.styleId?{styleId:e.styleId}:{},...e.alignment?{alignment:e.alignment}:{}}:null}var ae={undo:["M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"],redo:["M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"],print:["M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"],file_download:["M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"],file_upload:["M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"],format_bold:["M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"],format_italic:["M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"],format_underlined:["M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"],strikethrough_s:["M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"],superscript:["M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"],subscript:["M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"],link:["M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"],format_clear:["m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"],format_align_left:["M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"],format_align_center:["M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"],format_align_right:["M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"],format_align_justify:["M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"],format_line_spacing:["M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"],format_list_bulleted:["M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"],format_list_numbered:["M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"],format_indent_increase:["M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"],format_indent_decrease:["M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"],format_color_text:["M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"],ink_highlighter:["M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z"],format_color_reset:["M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"],arrow_drop_down:["M480-360 280-560h400L480-360Z"],table:["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"],table_chart:["M760-120H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120ZM200-640h560v-120H200v120Zm100 80H200v360h100v-360Zm360 0v360h100v-360H660Zm-80 0H380v360h200v-360Z"],grid_on:["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z"],table_rows:["M760-200v-120H200v120h560Zm0-200v-160H200v160h560Zm0-240v-120H200v120h560ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"],view_column:["M121-280v-400q0-33 23.5-56.5T201-760h559q33 0 56.5 23.5T840-680v400q0 33-23.5 56.5T760-200H201q-33 0-56.5-23.5T121-280Zm79 0h133v-400H200v400Zm213 0h133v-400H413v400Zm213 0h133v-400H626v400Z"],border_all:["M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"],select_all:["M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"],border_outer:["M200-200h560v-560H200v560Zm-80 80v-720h720v720H120Zm160-320v-80h80v80h-80Zm160 160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 160v-80h80v80h-80Z"],border_inner:["M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm320 640v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm-160 0v-80h80v80h-80ZM440-120v-320H120v-80h320v-320h80v320h320v80H520v320h-80Z"],border_clear:["M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"],add:["M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"],remove:["M200-440v-80h560v80H200Z"],delete:["M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"],delete_sweep:["M600-240v-80h160v80H600Zm0-320v-80h280v80H600Zm0 160v-80h240v80H600ZM120-640H80v-80h160v-60h160v60h160v80h-40v360q0 33-23.5 56.5T440-200H200q-33 0-56.5-23.5T120-280v-360Zm80 0v360h240v-360H200Zm0 0v360-360Z"],call_merge:["m296-160-56-56 200-200v-269L337-582l-57-57 200-200 201 201-57 57-104-104v301L296-160Zm368 1L536-286l57-57 127 128-56 56Z"],call_split:["M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"],drag_indicator:["M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z"],image:["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"],format_image_left:["M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"],format_image_right:["M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"],horizontal_rule:["M160-440v-80h640v80H160Z"],flip_to_back:["M200-120q-33 0-56.5-23.5T120-200v-480h80v480h480v80H200Zm160-240v80q-33 0-56.5-23.5T280-360h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T360-840v80Zm80 480v-80h80v80h-80Zm0-480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0 480v-80h80v80h-80Zm160-480v-80q33 0 56.5 23.5T840-760h-80Zm0 400h80q0 33-23.5 56.5T760-280v-80Zm0-80v-80h80v80h-80Zm0-160v-80h80v80h-80Z"],flip_to_front:["M360-280q-33 0-56.5-23.5T280-360v-400q0-33 23.5-56.5T360-840h400q33 0 56.5 23.5T840-760v400q0 33-23.5 56.5T760-280H360Zm0-80h400v-400H360v400ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"],open_with:["M480-80 310-250l57-57 73 73v-166h80v165l72-73 58 58L480-80ZM250-310 80-480l169-169 57 57-72 72h166v80H235l73 72-58 58Zm460 0-57-57 73-73H560v-80h165l-73-72 58-58 170 170-170 170ZM440-560v-166l-73 73-57-57 170-170 170 170-57 57-73-73v166h-80Z"],tune:["M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"],rotate_right:["M522-80v-82q34-5 66.5-18t61.5-34l56 58q-42 32-88 51.5T522-80Zm-80 0Q304-98 213-199.5T122-438q0-75 28.5-140.5t77-114q48.5-48.5 114-77T482-798h6l-62-62 56-58 160 160-160 160-56-56 64-64h-8q-117 0-198.5 81.5T202-438q0 104 68 182.5T442-162v82Zm322-134-58-56q21-29 34-61.5t18-66.5h82q-5 50-24.5 96T764-214Zm76-264h-82q-5-34-18-66.5T706-606l58-56q32 39 51 86t25 98Z"],rotate_left:["M440-80q-50-5-96-24.5T256-156l56-58q29 21 61.5 34t66.5 18v82Zm80 0v-82q104-15 172-93.5T760-438q0-117-81.5-198.5T480-718h-8l64 64-56 56-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-438q0 137-91 238.5T520-80ZM198-214q-32-42-51.5-88T122-398h82q5 34 18 66.5t34 61.5l-58 56Zm-76-264q6-51 25-98t51-86l58 56q-21 29-34 61.5T204-478h-82Z"],swap_horiz:["M280-160 80-360l200-200 56 57-103 103h287v80H233l103 103-56 57Zm400-240-56-57 103-103H440v-80h287L624-743l56-57 200 200-200 200Z"],swap_vert:["M320-440v-287L217-624l-57-56 200-200 200 200-57 56-103-103v287h-80ZM600-80 400-280l57-56 103 103v-287h80v287l103-103 57 56L600-80Z"],shapes:["M600-360ZM320-242q10 1 19.5 1.5t20.5.5q11 0 20.5-.5T400-242v82h400v-400h-82q1-10 1.5-19.5t.5-20.5q0-11-.5-20.5T718-640h82q33 0 56.5 23.5T880-560v400q0 33-23.5 56.5T800-80H400q-33 0-56.5-23.5T320-160v-82Zm40-78q-117 0-198.5-81.5T80-600q0-117 81.5-198.5T360-880q117 0 198.5 81.5T640-600q0 117-81.5 198.5T360-320Zm0-80q83 0 141.5-58.5T560-600q0-83-58.5-141.5T360-800q-83 0-141.5 58.5T160-600q0 83 58.5 141.5T360-400Zm0-200Z"],format_paint:["M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"],expand_more:["M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"],expand_less:["m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"],border_top:["M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h720v80H120Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"],border_bottom:["M120-120v-80h720v80H120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"],border_left:["M120-120v-720h80v720h-80Zm160 0v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"],border_right:["M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-720h80v720h-80Z"],border_horizontal:["M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h720v60H120Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Z"],border_vertical:["M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-720h60v720h-60Zm165 0v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Z"],padding:["M320-600q17 0 28.5-11.5T360-640q0-17-11.5-28.5T320-680q-17 0-28.5 11.5T280-640q0 17 11.5 28.5T320-600Zm160 0q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm160 0q17 0 28.5-11.5T680-640q0-17-11.5-28.5T640-680q-17 0-28.5 11.5T600-640q0 17 11.5 28.5T640-600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"],text_rotation_none:["M160-200v-80h528l-42-42 56-56 138 138-138 138-56-56 42-42H160Zm116-200 164-440h80l164 440h-76l-38-112H392l-40 112h-76Zm138-176h132l-64-182h-4l-64 182Z"],wrap_text:["M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"],height:["M480-120 320-280l56-56 64 63v-414l-64 63-56-56 160-160 160 160-56 57-64-64v414l64-63 56 56-160 160Z"],fit_width:["M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"],settings:["m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"],border_color:["M80 0v-160h800V0H80Zm160-320h56l312-311-29-29-28-28-311 312v56Zm-80 80v-170l448-447q11-11 25.5-17t30.5-6q16 0 31 6t27 18l55 56q12 11 17.5 26t5.5 31q0 15-5.5 29.5T777-687L330-240H160Zm560-504-56-56 56 56ZM608-631l-29-29-28-28 57 57Z"],format_color_fill:["m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm360 471q-33 0-56.5-23.5T680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280ZM80 0v-160h800V0H80Z"],vertical_align_top:["M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"],vertical_align_center:["M440-80v-168l-64 64-56-56 160-160 160 160-56 56-64-64v168h-80ZM160-440v-80h640v80H160Zm320-120L320-720l56-56 64 64v-168h80v168l64-64 56 56-160 160Z"],vertical_align_bottom:["M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"],line_weight:["M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"],keyboard_arrow_up:["M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"],keyboard_arrow_down:["M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"],keyboard_arrow_left:["M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"],keyboard_arrow_right:["M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"],more_vert:["M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"],page_break:["M120-440v-80h160v80H120Zm200 0v-80h160v80H320Zm200 0v-80h160v80H520Zm200 0v-80h120v80H720ZM240-120q-33 0-56.5-23.5T160-200v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-120H240Zm-80-520v-120q0-33 23.5-56.5T240-840h480q33 0 56.5 23.5T800-760v120h-80v-120H240v120h-80Z"],branding_watermark:["M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm0-80h640v-480H160v480Zm320-60q66 0 113-37t47-93q0-29-13-58t-34-55q-21-26-50-49t-50-31q-21 8-50 31t-50 49q-21 26-34 55t-13 58q0 56 47 93t140 37Z"],arrow_back:["M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"],search:["M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"],toc:["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],done_all:["M268-240 42-466l57-56 170 170 56 56-57 56Zm226 0L268-466l56-57 170 170 368-368 57 57-425 424Zm0-226-57-56 198-198 57 56-198 198Z"],check_circle:["m424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z"],chat_bubble_outline:["M80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"],chat_bubble_check:["M80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"],check:["M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"],close:["m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"],add_comment:["M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"],comment:["M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"],edit_note:["M160-400h280v-80H160v80Zm0-160h440v-80H160v80Zm0-160h440v-80H160v80Zm360 360v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T863-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z"],rate_review:["M240-400h122l200-200q9-9 13.5-20.5T580-643q0-11-5-21.5T562-684l-36-38q-9-9-20-13.5t-23-4.5q-11 0-22.5 4.5T440-722L240-522v122Zm280-243-37-37 37 37ZM300-460v-38l101-101 20 18 18 20-101 101h-38Zm121-121 18 20-38-38 20 18Zm26 181h273v-80H527l-80 80ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"],visibility:["M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Zm0-300Zm0 220q113 0 207.5-59.5T832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280Z"],format_textdirection_l_to_r:["M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"],format_textdirection_r_to_l:["M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"],"agent-sparkle":["m760-600-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110Zm0 560-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110ZM360-160 260-380 40-480l220-100 100-220 100 220 220 100-220 100-100 220Zm0-194 40-86 86-40-86-40-40-86-40 86-86 40 86 40 40 86Zm0-126Z"]};var wn={activeTarget:"all",spec:{style:"single",size:8,color:{kind:"hex",value:"000000"}}},Jl=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"];function Ka(e){return createT(en)(e)}function po(e){return Jl.includes(e)}function pp(e){return e!=null}var ed=[{value:"all",icon:"border_all",labelKey:"table.borders.all"},{value:"outside",icon:"border_outer",labelKey:"table.borders.outside"},{value:"inside",icon:"border_inner",labelKey:"table.borders.inside"},{value:"top",icon:"border_top",labelKey:"table.borders.top"},{value:"bottom",icon:"border_bottom",labelKey:"table.borders.bottom"},{value:"left",icon:"border_left",labelKey:"table.borders.left"},{value:"right",icon:"border_right",labelKey:"table.borders.right"},{value:"none",icon:"border_clear",labelKey:"table.borders.none"}],td=[{value:"single",labelKey:"table.borderStyles.single",previewClass:"docx-table-line--single"},{value:"dashed",labelKey:"table.borderStyles.dashed",previewClass:"docx-table-line--dashed"},{value:"dotted",labelKey:"table.borderStyles.dotted",previewClass:"docx-table-line--dotted"},{value:"double",labelKey:"table.borderStyles.double",previewClass:"docx-table-line--double"},{value:"triple",labelKey:"table.borderStyles.triple",previewClass:"docx-table-line--triple"},{value:"thick",labelKey:"table.borderStyles.thick",previewClass:"docx-table-line--thick"}],gp=[{size:4,labelKey:"table.borderWidths.halfPt",previewThickness:.5},{size:8,labelKey:"table.borderWidths.onePt",previewThickness:1},{size:12,labelKey:"table.borderWidths.oneHalfPt",previewThickness:1.5},{size:16,labelKey:"table.borderWidths.twoPt",previewThickness:2},{size:24,labelKey:"table.borderWidths.threePt",previewThickness:3}];function mp(e){return e==="all"||e==="outside"||e==="inside"||e==="top"||e==="bottom"||e==="left"||e==="right"}function hp(e){return e==="none"||mp(e)}function Ql(e){if(!e||typeof e!="object")return false;let t=e.kind;return t==="hex"||t==="theme"||t==="auto"}function yp(e){return td.some(t=>t.value===e)}function dn(e,t,n){switch(t){case "table.borderTarget":return hp(n)?n==="none"?{command:{type:"setTableBorders",scope:"none",target:e.activeTarget},nextDraft:e}:{command:{type:"setTableBorders",scope:n,spec:e.spec},nextDraft:{activeTarget:n,spec:e.spec}}:null;case "table.borderColor":{if(!Ql(n))return null;let r={...e.spec,color:n};return {command:{type:"setTableBorders",scope:e.activeTarget,spec:r},nextDraft:{activeTarget:e.activeTarget,spec:r}}}case "table.borderStyle":{if(!yp(n))return null;let r={...e.spec,style:n};return {command:{type:"setTableBorders",scope:e.activeTarget,spec:r},nextDraft:{activeTarget:e.activeTarget,spec:r}}}case "table.borderWidth":{if(typeof n!="number"||!Number.isInteger(n))return null;let r={...e.spec,size:n};return {command:{type:"setTableBorders",scope:e.activeTarget,spec:r},nextDraft:{activeTarget:e.activeTarget,spec:r}}}case "table.cellFill":return n!==null&&!Ql(n)?null:{command:{type:"setCellFill",color:n},nextDraft:e};default:return null}}function ja(e,t=wn){switch(e){case "table.borderTarget":return {type:"setTableBorders",scope:t.activeTarget,spec:t.spec};case "table.borderColor":return dn(t,e,{kind:"hex",value:"000000"})?.command??null;case "table.borderStyle":return dn(t,e,"single")?.command??null;case "table.borderWidth":return dn(t,e,8)?.command??null;case "table.cellFill":return {type:"setCellFill",color:{kind:"hex",value:"FFFF00"}};default:return null}}function vp(e){return ed.find(n=>n.value===e)?.labelKey??"table.borders.all"}function bp(e){return ae[e]}function Cn(e){return e.surface??null}var xp={"review.comments":{type:"toggleReviewPane"},"history.undo":{type:"undo"},"history.redo":{type:"redo"},"text.bold":{type:"toggleMark",mark:"bold"},"text.italic":{type:"toggleMark",mark:"italic"},"text.underline":{type:"toggleMark",mark:"underline"},"text.strike":{type:"toggleMark",mark:"strike"},"script.super":{type:"toggleMark",mark:"superscript"},"script.sub":{type:"toggleMark",mark:"subscript"},"format.clear":{type:"clearFormatting"},"alignment.left":{type:"setAlignment",align:"left"},"alignment.center":{type:"setAlignment",align:"center"},"alignment.right":{type:"setAlignment",align:"right"},"alignment.justify":{type:"setAlignment",align:"justify"},"list.bullet":{type:"toggleList",kind:"bullet"},"list.numbered":{type:"toggleList",kind:"ordered"},"list.indent":{type:"adjustIndent",direction:"increase"},"list.outdent":{type:"adjustIndent",direction:"decrease"},"insert.footnote":{type:"insertNote",noteKind:"footnote"},"insert.endnote":{type:"insertNote",noteKind:"endnote"},"insert.pageNumber":{type:"insertPageField",field:"PAGE"},"insert.totalPages":{type:"insertPageField",field:"NUMPAGES"},"insert.sectionPages":{type:"insertPageField",field:"SECTIONPAGES"},"insert.pageXofY":{type:"insertPageField",field:"PAGE_X_OF_Y"},"insert.pageBreak":{type:"insertBreak",kind:"page"},"insert.sectionBreakNextPage":{type:"insertBreak",kind:"section"},"insert.toc":{type:"insertToc"},"contentControl.remove":{type:"removeContentControl"}};function Ip(e){return rd[e]??null}var nd=Uint8Array.from(atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e=>e.charCodeAt(0)),rd={"text.link":{type:"insertHyperlink",href:"https://example.com"},"image.insert":{type:"insertImage",data:nd,mime:"image/png",widthPoints:72,heightPoints:72},"image.properties":{type:"setImageProperties",description:"probe"},"table.insert":{type:"insertTable",rows:1,cols:1},"file.pageSetup":{type:"setPageSetup",orientation:"portrait"}};function go(e){return xp[e]??null}var Sp={"font.family":{mark:"fontFamily",attr:"family"},"font.size":{mark:"fontSize",attr:"val"},"text.color":{mark:"color",attr:"val"},"text.highlight":{mark:"highlight",attr:"val"}},kp={"font.family":"Arial","font.size":22,"text.color":"000000","text.highlight":"yellow","styles.style":"Normal","list.lineSpacing":1,"image.wrap":"square","image.altText":"probe alt text"};function od(e,t,n){return dn(n,e,t)?.command??null}function mo(e,t){if(e==="review.editingMode")return {type:"setEditingMode",mode:t};if(e==="styles.style")return {type:"setParagraphStyle",styleId:t};if(e==="list.lineSpacing")return {type:"setLineSpacing",rule:"multiple",value:t};if(po(e))return od(e,t,wn);if(e==="image.wrap")return typeof t!="string"||!Wa$1.includes(t)?null:{type:"setImageWrapType",target:t};if(e==="image.altText")return typeof t!="string"?null:{type:"setImageProperties",description:t};let n=Sp[e];return n?{type:"setMarkAttr",mark:n.mark,attr:n.attr,value:t}:null}function ad(e,t,n=wn){if(!e)return {id:t,enabled:false,disabledReason:"editor is not ready",active:false};let r=ja(t,n);if(!r)return {id:t,enabled:false,disabledReason:"not wired to an editor command",active:false};let a=e.can(r);return a.ok?{id:t,enabled:true,disabledReason:null,active:false}:{id:t,enabled:false,disabledReason:a.reason,active:false}}function id(e,t){if(!e)return {id:t,enabled:false,disabledReason:"editor is not ready",active:false};if(po(t))return ad(e,t);if(t==="review.editingMode"){let o=e.getEditingMode?.()??"editing",i=e.can(mo(t,o==="editing"?"suggesting":"editing"));return {id:t,enabled:i.ok,disabledReason:i.ok?null:i.reason,active:false,value:o}}if(t==="contentControl.showAll"||t==="contentControl.formFill"){let o=Cn(e),i=o?.state().contentControls,l=t==="contentControl.showAll"?i?.showAll??false:i?.formFill??false;return {id:t,enabled:o!==null,disabledReason:o?null:"editor is not ready",active:l}}if(t==="contentControl.inspector"){let o=Cn(e);return o?o.state().contentControls.activeControlId?{id:t,enabled:true,disabledReason:null,active:false}:{id:t,enabled:false,disabledReason:"no content control at the selection",active:false}:{id:t,enabled:false,disabledReason:"editor is not ready",active:false}}let n=go(t);if(!n){let o=kp[t];if(o!==void 0){let l=mo(t,o);if(!l)return {id:t,enabled:false,disabledReason:"not wired to an editor command",active:false};let d=e.can(l),p=e.getSelectedImage?.()??null,y=t==="image.wrap"?p?.wrap:t==="image.altText"?p?.description:void 0;return d.ok?{id:t,enabled:true,disabledReason:null,active:false,...y!==void 0?{value:y}:{}}:{id:t,enabled:false,disabledReason:d.reason,active:false,...y!==void 0?{value:y}:{}}}let i=rd[t];if(i){if(t==="image.insert"&&i.type==="insertImage"){let d=e.canExecuteImageCommand?.({type:"insertImage",data:nd,mime:"image/png",widthPoints:72,heightPoints:72})??e.can(i);return d.ok?{id:t,enabled:true,disabledReason:null,active:false}:{id:t,enabled:false,disabledReason:d.reason,active:false}}if(t==="image.properties"&&i.type==="setImageProperties"){let d=e.can(i);return d.ok?{id:t,enabled:true,disabledReason:null,active:false}:{id:t,enabled:false,disabledReason:d.reason,active:false}}if(t==="table.insert"&&i.type==="insertTable"){let d=e.can(i);return d.ok?{id:t,enabled:true,disabledReason:null,active:false}:{id:t,enabled:false,disabledReason:d.reason,active:false}}let l=e.can(i);if(!l.ok)return {id:t,enabled:false,disabledReason:l.reason,active:false}}return t==="file.save"?{id:t,enabled:false,disabledReason:"save is not a command; run it with runSave(editor)",active:false}:t==="file.open"?{id:t,enabled:false,disabledReason:"open is not a command; run it with editor.load(bytes)",active:false}:{id:t,enabled:false,disabledReason:"not wired to an editor command",active:false}}let r=e.can(n),a=e.isActive?.(n)??false;return r.ok?{id:t,enabled:true,disabledReason:null,active:a}:{id:t,enabled:false,disabledReason:r.reason,active:a}}function Tp(e,t){return t.map(n=>id(e,n))}function Pp(e,t,n,r){if(!e)return {result:{ok:false,code:"unsupported",reason:"editor is not ready"},nextDraft:null};let a=dn(r,t,n);if(!a)return {result:{ok:false,code:"unsupported",reason:"invalid table chrome value"},nextDraft:null};let o=e.can(a.command);if(!o.ok)return {result:{ok:false,code:o.code,reason:o.reason},nextDraft:null};let i=e.exec(a.command);return i.ok?{result:i,nextDraft:a.nextDraft}:{result:i,nextDraft:null}}function wp(e,t,n){if(!e)return {ok:false,code:"unsupported",reason:"editor is not ready"};if(t==="contentControl.showAll"){let o=Cn(e);return o?(o.contentControls.setShowAll(!o.contentControls.showAll()),{ok:true,changed:false}):{ok:false,code:"unsupported",reason:"editor is not ready"}}if(t==="contentControl.formFill"){let o=Cn(e);return o?(o.contentControls.setFormFill(!o.contentControls.formFill()),{ok:true,changed:false}):{ok:false,code:"unsupported",reason:"editor is not ready"}}if(t==="contentControl.inspector"){let o=Cn(e);return o?o.state().contentControls.activeControlId?{ok:true,changed:false}:{ok:false,code:"notFound",reason:"no content control at the selection"}:{ok:false,code:"unsupported",reason:"editor is not ready"}}if(t==="contentControl.remove"){let o=Cn(e);if(!o)return {ok:false,code:"unsupported",reason:"editor is not ready"};let i=o.state().contentControls.activeControlId;if(!i)return {ok:false,code:"notFound",reason:"no content control at the selection"};let l=o.contentControls.disabledReason(i,"remove");return l?{ok:false,code:l==="bound"?"bound":"locked",reason:l}:o.contentControls.remove(i)?{ok:true,changed:true}:{ok:false,code:o.state().lastRejection??"unsupported",reason:o.state().lastRejection??"removeContentControl was refused"}}let r=n===void 0?go(t):mo(t,n)??go(t);if(!r)return n!==void 0?{ok:false,code:"unsupported",reason:"invalid value for toolbar command"}:t==="file.save"?{ok:false,code:"unsupported",reason:"save is not a command; run it with runSave(editor)"}:t==="file.open"?{ok:false,code:"unsupported",reason:"open is not a command; run it with editor.load(bytes)"}:{ok:false,code:"unsupported",reason:"not wired to an editor command"};let a=e.can(r);return a.ok?e.exec(r):{ok:false,code:a.code,reason:a.reason}}function Cp(e){return e?e.save():Promise.reject(new Error("editor is not ready"))}function Rp(e,t){if(!e)return {enabled:false,disabledReason:"editor is not ready"};let n=fo(t,e);return n.can.ok?{enabled:true,disabledReason:null}:{enabled:false,disabledReason:n.can.reason}}function Ep(e,t){if(!e)return {ok:false,code:"unsupported",reason:"editor is not ready"};let n=e.can(t);return n.ok?e.exec(t):{ok:false,code:n.code,reason:n.reason}}var Va=[{id:"history",labelKey:"formattingBar.groups.history",controls:[{id:"undo",labelKey:"formattingBar.undoShortcut",paths:ae.undo,state:{kind:"command"}},{id:"redo",labelKey:"formattingBar.redoShortcut",paths:ae.redo,state:{kind:"command"}}]},{id:"zoom",labelKey:"formattingBar.groups.zoom",controls:[{id:"level",shape:"stepper",valueText:"100%",labelKey:"formattingBar.groups.zoom",paths:null,valueKey:"zoom.zoomLevel",state:{kind:"command"}}]},{id:"styles",labelKey:"formattingBar.groups.styles",controls:[{id:"style",shape:"dropdown",labelKey:"styles.selectAriaLabel",paths:null,valueKey:"styles.normalText",state:{kind:"value"}}]},{id:"font",labelKey:"formattingBar.groups.font",controls:[{id:"family",shape:"dropdown",labelKey:"font.selectAriaLabel",paths:null,valueKey:"font.sansSerif",state:{kind:"value"}},{id:"size",shape:"stepper",valueText:"11",labelKey:"fontSize.listLabel",paths:null,valueKey:"fontSize.label",state:{kind:"value"}}]},{id:"text",labelKey:"formattingBar.groups.textFormatting",controls:[{id:"bold",labelKey:"formattingBar.boldShortcut",paths:ae.format_bold,state:{kind:"command"}},{id:"italic",labelKey:"formattingBar.italicShortcut",paths:ae.format_italic,state:{kind:"command"}},{id:"underline",labelKey:"formattingBar.underlineShortcut",paths:ae.format_underlined,state:{kind:"command"}},{id:"strike",labelKey:"formattingBar.strikethrough",paths:ae.strikethrough_s,state:{kind:"command"}},{id:"color",shape:"colorSplit",swatch:"#ff0000",labelKey:"formattingBar.fontColor",paths:ae.format_color_text,state:{kind:"value"}},{id:"highlight",shape:"colorSplit",swatch:"#ffff00",labelKey:"formattingBar.highlightColor",paths:ae.ink_highlighter,state:{kind:"value"}},{id:"link",labelKey:"formattingBar.insertLinkShortcut",paths:ae.link,state:{kind:"command"}}]},{id:"script",labelKey:"formattingBar.groups.script",controls:[{id:"super",labelKey:"formattingBar.superscript",paths:ae.superscript,state:{kind:"command"}},{id:"sub",labelKey:"formattingBar.subscript",paths:ae.subscript,state:{kind:"command"}}]},{id:"alignment",labelKey:"formattingBar.groups.alignment",controls:[{id:"left",labelKey:"alignment.alignLeft",paths:ae.format_align_left,state:{kind:"command"}},{id:"center",labelKey:"alignment.center",paths:ae.format_align_center,state:{kind:"command"}},{id:"right",labelKey:"alignment.alignRight",paths:ae.format_align_right,state:{kind:"command"}},{id:"justify",labelKey:"alignment.justify",paths:ae.format_align_justify,state:{kind:"command"}}]},{id:"list",labelKey:"formattingBar.groups.listFormatting",controls:[{id:"bullet",labelKey:"lists.bulletList",paths:ae.format_list_bulleted,state:{kind:"command"}},{id:"numbered",labelKey:"lists.numberedList",paths:ae.format_list_numbered,state:{kind:"command"}},{id:"outdent",labelKey:"lists.decreaseIndent",paths:ae.format_indent_decrease,state:{kind:"command"}},{id:"indent",labelKey:"lists.increaseIndent",paths:ae.format_indent_increase,state:{kind:"command"}},{id:"lineSpacing",shape:"dropdown",labelKey:"lineSpacing.label",paths:ae.format_line_spacing,state:{kind:"command"}}]},{id:"format",labelKey:"formattingBar.clearFormatting",controls:[{id:"clear",labelKey:"formattingBar.clearFormatting",paths:ae.format_clear,state:{kind:"command"}}]},{id:"review",labelKey:"formattingBar.commentsAndChanges",controls:[{id:"comments",shape:"icon",labelKey:"formattingBar.commentsAndChanges",paths:ae.comment,state:{kind:"command"}},{id:"editingMode",shape:"dropdown",labelKey:"editingMode.label",valueKey:"editingMode.editing",paths:ae.edit_note,state:{kind:"command"}}]},{id:"contentControl",labelKey:"contentControl.group",contextual:true,controls:[{id:"showAll",labelKey:"contentControl.showAll",paths:ae.visibility,state:{kind:"command"}},{id:"formFill",labelKey:"contentControl.formFill",paths:ae.edit_note,state:{kind:"command"}},{id:"inspector",labelKey:"contentControl.inspector",paths:ae.tune,state:{kind:"command"}},{id:"remove",labelKey:"contentControl.remove",paths:ae.delete,state:{kind:"command"}}]},{id:"image",labelKey:"formattingBar.groups.image",contextual:true,controls:[{id:"insert",labelKey:"toolbar.image",paths:ae.image,state:{kind:"command"}},{id:"properties",labelKey:"formattingBar.imagePropertiesShortcut",paths:ae.tune,state:{kind:"command"}},{id:"wrap",shape:"dropdown",labelKey:"formattingBar.imageWrap",paths:ae.wrap_text,valueKey:"imageWrap.inline",state:{kind:"value"}},{id:"altText",shape:"dropdown",labelKey:"formattingBar.altText",paths:null,valueKey:"imageProperties.altText",state:{kind:"value"}}]},{id:"table",labelKey:"formattingBar.groups.table",contextual:true,controls:[{id:"insert",labelKey:"toolbar.table",paths:ae.table,state:{kind:"command"}},{id:"borderTarget",shape:"dropdown",labelKey:"table.borders.tooltip",paths:ae.border_all,state:{kind:"value"}},{id:"borderColor",shape:"colorSplit",swatch:"#000000",labelKey:"table.borderColor",paths:ae.border_color,state:{kind:"value"}},{id:"borderStyle",shape:"dropdown",labelKey:"table.borders.styleAriaLabel",paths:ae.border_horizontal,state:{kind:"value"}},{id:"borderWidth",shape:"dropdown",labelKey:"table.borderWidth",paths:ae.line_weight,state:{kind:"value"}},{id:"cellFill",shape:"colorSplit",swatch:"#ffffff",labelKey:"table.cellFillColor",paths:ae.format_color_fill,state:{kind:"value"}}]},{id:"file",labelKey:"toolbar.file",contextual:true,controls:[{id:"open",labelKey:"toolbar.open",paths:ae.file_upload,state:{kind:"load"}},{id:"save",labelKey:"toolbar.saveShortcut",paths:ae.file_download,state:{kind:"save"}},{id:"pageSetup",labelKey:"toolbar.pageSetup",paths:ae.settings,state:{kind:"command"}}]},{id:"insert",labelKey:"toolbar.insert",contextual:true,controls:[{id:"footnote",labelKey:"toolbar.insertFootnote",paths:ae.superscript,state:{kind:"command"}},{id:"endnote",labelKey:"toolbar.insertEndnote",paths:ae.edit_note,state:{kind:"command"}},{id:"pageNumber",labelKey:"headerFooter.insertPageNumber",paths:ae.format_list_numbered,state:{kind:"command"}},{id:"totalPages",labelKey:"headerFooter.insertTotalPages",paths:ae.format_list_numbered,state:{kind:"command"}},{id:"sectionPages",labelKey:"headerFooter.insertSectionPages",paths:ae.format_list_numbered,state:{kind:"command"}},{id:"pageXofY",labelKey:"headerFooter.insertPageXofY",paths:ae.format_list_numbered,state:{kind:"command"}},{id:"pageBreak",labelKey:"toolbar.pageBreak",paths:ae.page_break,state:{kind:"command"}},{id:"sectionBreakNextPage",labelKey:"toolbar.sectionBreakNextPage",paths:ae.horizontal_rule,state:{kind:"command"}},{id:"sectionBreakContinuous",labelKey:"toolbar.sectionBreakContinuous",paths:ae.border_horizontal,state:{kind:"command"}},{id:"toc",labelKey:"toolbar.tableOfContents",paths:ae.toc,state:{kind:"command"}}]}],sd=Va;function Fp(e,t){return `${e.id}.${t.id}`}function ld(){return sd.filter(e=>!e.contextual)}function Op(e){let t=ld();if(!e)return t;let n=sd.find(r=>r.id==="image");return n?[...t,n]:t}var dd=[{id:"file",labelKey:"toolbar.file",entries:[{kind:"item",slot:"file.open",shortcutKey:"toolbar.openShortcut"},{kind:"item",slot:"file.save",labelKey:"toolbar.save",shortcutKey:"toolbar.saveShortcut"},{kind:"separator"},{kind:"item",slot:"file.pageSetup"}]},{id:"format",labelKey:"toolbar.format",entries:[{kind:"item",slot:"text.bold",labelKey:"formattingBar.bold"},{kind:"item",slot:"text.italic",labelKey:"formattingBar.italic"},{kind:"item",slot:"text.underline",labelKey:"formattingBar.underline"},{kind:"item",slot:"text.strike"},{kind:"separator"},{kind:"item",slot:"alignment.left"},{kind:"item",slot:"alignment.center"},{kind:"item",slot:"alignment.right"},{kind:"item",slot:"alignment.justify"},{kind:"separator"},{kind:"item",slot:"format.clear"}]},{id:"insert",labelKey:"toolbar.insert",entries:[{kind:"item",slot:"table.insert",picker:"tableGrid"},{kind:"separator"},{kind:"item",slot:"insert.footnote"},{kind:"item",slot:"insert.endnote"},{kind:"separator"},{kind:"submenu",labelKey:"toolbar.break",paths:ae.page_break,items:[{kind:"item",slot:"insert.pageBreak"},{kind:"item",slot:"insert.sectionBreakNextPage"},{kind:"item",slot:"insert.sectionBreakContinuous"}]},{kind:"item",slot:"insert.toc"}]},{id:"help",labelKey:"toolbar.help",entries:[]}];function Ap(){let e=[],t=n=>{for(let r of n)r.kind==="item"?e.push(r.slot):r.kind==="submenu"&&t(r.items);};for(let n of dd)t(n.entries);return e}function Mp(){return Va.reduce((e,t)=>e+t.controls.length,0)}var Hp="formattingBar.unavailableInPreview";function Rn(e){try{return e.createElement("canvas").getContext("2d")}catch{return null}}function Fe(e){return {anchor:e,head:e}}function ho(e){if(e.anchor.paragraphId!==e.head.paragraphId)return null;let t=Math.min(e.anchor.offset,e.head.offset),n=Math.max(e.anchor.offset,e.head.offset);return {paragraphId:e.head.paragraphId,start:t,end:n}}function Ua(e,t,n){let{anchor:r,head:a}=t;if(r.paragraphId===a.paragraphId)return r.offset<=a.offset?{from:r,to:a}:{from:a,to:r};let o=n??wd$1(e);return o.indexOf(r.paragraphId)<=o.indexOf(a.paragraphId)?{from:r,to:a}:{from:a,to:r}}function yo(e,t,n){let r=t[0],a=o=>{let i=t.includes(o.paragraphId)?o.paragraphId:r??o.paragraphId,l=xd$1(e,i).length;return {paragraphId:i,offset:Math.max(0,Math.min(o.offset,l))}};return {anchor:a(n.anchor),head:a(n.head)}}function ud(e,t,n,r){if(t.paragraphId===n.paragraphId)return xd$1(e,t.paragraphId).slice(t.offset,n.offset);let a=r??wd$1(e),o=a.indexOf(t.paragraphId),i=a.indexOf(n.paragraphId);if(o===-1||i===-1)return "";let l=[xd$1(e,t.paragraphId).slice(t.offset)];for(let d=o+1;d<i;d+=1)l.push(xd$1(e,a[d]));return l.push(xd$1(e,n.paragraphId).slice(0,n.offset)),l.join(`
|
|
2
|
-
`)}function fd(e){let t=[],n=r=>{if(r.kind!=="textValue"){r.kind==="paragraph"&&t.push(r.id);for(let a of r.children)n(a);}};return n(e),t}function pd(e){return e.kind}function Lp(e){return e.kind!=="textValue"&&pd(e)==="contentControl"}function cd(e){return e.kind!=="textValue"&&pd(e)==="contentControlContent"}function Dp(e,t){let n=new Map,r=a=>{if(a.kind!=="textValue"){if(a.kind==="table"){let o=fd(a);if(o.length>0&&o.every(i=>t.has(i))){n.set(a.id,o);return}}for(let o of a.children)r(o);}};return r(e.root),n}function Np(e,t,n){let r=new Set,a=(o,i)=>{if(o.kind!=="textValue"){if(o.kind==="table"&&n.has(o.id)){for(let l of o.children)a(l,true);return}if(Lp(o)){let l=fd(o);!i&&l.length>0&&l.every(d=>t.has(d))&&r.add(o.id);for(let d of o.children)a(d,i);return}for(let l of o.children)a(l,i);}};return a(e.root,false),r}function gd(e,t,n,r,a){let o=v=>xd$1(e,v);if(n.paragraphId===r.paragraphId)return n.offset===r.offset?{ops:[],collapseTo:n}:{ops:[{op:"deleteText",paragraphId:n.paragraphId,start:n.offset,end:r.offset}],collapseTo:n};let i=a??wd$1(e),l=i.indexOf(n.paragraphId),d=i.indexOf(r.paragraphId);if(l===-1||d===-1)return {ops:[],collapseTo:n};let p=new Set;for(let v=l;v<=d;v+=1){let T=i[v];(v===l?n.offset===0:v!==d||r.offset===o(T).length)&&p.add(T);}let y=Dp(t,p),C=new Map;for(let[v,T]of y)for(let M of T)C.set(M,v);let S=Np(t,p,y),I=l;if(C.has(n.paragraphId)){I=-1;for(let v=l+1;v<=d;v+=1)if(!C.has(i[v])){I=v;break}if(I===-1){let v=C.get(n.paragraphId);for(let T of y.get(v)??[])C.delete(T);y.delete(v),I=l;}}let O=i[I],m=I===l?n:{paragraphId:O,offset:0},F=[];for(let v=l;v<=d;v+=1){let T=i[v];if(C.has(T))continue;let M=o(T).length,G=v===l?n.offset:0,$=v===d?r.offset:M;G<$&&F.push({op:"deleteText",paragraphId:T,start:G,end:$});}for(let v of y.keys())F.push({op:"deleteBlock",blockId:v});for(let v of S)F.push({op:"removeContentControl",controlId:v});let B=v=>{let T=Fa$1(t,v);for(;T&&cd(T);){let M=Fa$1(t,T.id);if(!M||!S.has(M.id))break;T=Fa$1(t,M.id);}return T},A=v=>{let T=[],M=G=>{for(let $ of G)if($.kind!=="textValue"&&!y.has($.id)){if(S.has($.id)){let L=$.children.find(cd);L&&L.kind!=="textValue"&&M(L.children);continue}if($.kind==="paragraph"){T.push($.id);continue}T.push(`\0barrier:${$.id}`);}};return M(v.children),T},k=(v,T)=>{let M=B(v);if(!M||B(T)!==M)return false;let G=A(M),$=G.indexOf(v),L=G.indexOf(T);return $!==-1&&L===$+1},
|
|
2
|
+
`)}function fd(e){let t=[],n=r=>{if(r.kind!=="textValue"){r.kind==="paragraph"&&t.push(r.id);for(let a of r.children)n(a);}};return n(e),t}function pd(e){return e.kind}function Lp(e){return e.kind!=="textValue"&&pd(e)==="contentControl"}function cd(e){return e.kind!=="textValue"&&pd(e)==="contentControlContent"}function Dp(e,t){let n=new Map,r=a=>{if(a.kind!=="textValue"){if(a.kind==="table"){let o=fd(a);if(o.length>0&&o.every(i=>t.has(i))){n.set(a.id,o);return}}for(let o of a.children)r(o);}};return r(e.root),n}function Np(e,t,n){let r=new Set,a=(o,i)=>{if(o.kind!=="textValue"){if(o.kind==="table"&&n.has(o.id)){for(let l of o.children)a(l,true);return}if(Lp(o)){let l=fd(o);!i&&l.length>0&&l.every(d=>t.has(d))&&r.add(o.id);for(let d of o.children)a(d,i);return}for(let l of o.children)a(l,i);}};return a(e.root,false),r}function gd(e,t,n,r,a){let o=v=>xd$1(e,v);if(n.paragraphId===r.paragraphId)return n.offset===r.offset?{ops:[],collapseTo:n}:{ops:[{op:"deleteText",paragraphId:n.paragraphId,start:n.offset,end:r.offset}],collapseTo:n};let i=a??wd$1(e),l=i.indexOf(n.paragraphId),d=i.indexOf(r.paragraphId);if(l===-1||d===-1)return {ops:[],collapseTo:n};let p=new Set;for(let v=l;v<=d;v+=1){let T=i[v];(v===l?n.offset===0:v!==d||r.offset===o(T).length)&&p.add(T);}let y=Dp(t,p),C=new Map;for(let[v,T]of y)for(let M of T)C.set(M,v);let S=Np(t,p,y),I=l;if(C.has(n.paragraphId)){I=-1;for(let v=l+1;v<=d;v+=1)if(!C.has(i[v])){I=v;break}if(I===-1){let v=C.get(n.paragraphId);for(let T of y.get(v)??[])C.delete(T);y.delete(v),I=l;}}let O=i[I],m=I===l?n:{paragraphId:O,offset:0},F=[];for(let v=l;v<=d;v+=1){let T=i[v];if(C.has(T))continue;let M=o(T).length,G=v===l?n.offset:0,$=v===d?r.offset:M;G<$&&F.push({op:"deleteText",paragraphId:T,start:G,end:$});}for(let v of y.keys())F.push({op:"deleteBlock",blockId:v});for(let v of S)F.push({op:"removeContentControl",controlId:v});let B=v=>{let T=Fa$1(t,v);for(;T&&cd(T);){let M=Fa$1(t,T.id);if(!M||!S.has(M.id))break;T=Fa$1(t,M.id);}return T},A=v=>{let T=[],M=G=>{for(let $ of G)if($.kind!=="textValue"&&!y.has($.id)){if(S.has($.id)){let L=$.children.find(cd);L&&L.kind!=="textValue"&&M(L.children);continue}if($.kind==="paragraph"){T.push($.id);continue}T.push(`\0barrier:${$.id}`);}};return M(v.children),T},k=(v,T)=>{let M=B(v);if(!M||B(T)!==M)return false;let G=A(M),$=G.indexOf(v),L=G.indexOf(T);return $!==-1&&L===$+1},V=O,P=O;for(let v=I+1;v<=d;v+=1){let T=i[v];C.has(T)||(k(P,T)?F.push({op:"joinParagraphs",firstId:V,secondId:T}):V=T,P=T);}return {ops:F,collapseTo:m}}var _p={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xA0"};function Bp(e){return e.replace(/&(#x[0-9a-fA-F]+|#\d+|[a-zA-Z]+);/g,(t,n)=>{if(n.startsWith("#")){let r=n.startsWith("#x")?Number.parseInt(n.slice(2),16):Number.parseInt(n.slice(1),10);return !Number.isFinite(r)||r<0||r>1114111||r>=55296&&r<=57343?t:String.fromCodePoint(r)}return _p[n.toLowerCase()]??t})}function Zp(e){let t=e.length>2e6?e.slice(0,2e6):e;return Bp(t.replace(/<!--[\s\S]*?-->/g,"").replace(/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,"").replace(/<(script|style)\b[^>]*>[\s\S]*$/gi,"").replace(/<br\s*\/?>/gi,`
|
|
3
3
|
`).replace(/<\/(td|th)\s*>/gi," ").replace(/<\/(p|div|li|tr|h[1-6]|blockquote|section|article|pre|table)\s*>/gi,`
|
|
4
4
|
`).replace(/<[^>]*>/g,"")).replace(/\r\n?/g,`
|
|
5
5
|
`).replace(/\t+\n/g,`
|
|
@@ -7,6 +7,6 @@ import {b as b$1,d as d$1,e as e$1,a as a$3,c as c$1}from'./chunk-QRAUDDVY.js';i
|
|
|
7
7
|
|
|
8
8
|
`).trim()}function md(e){let t="";for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r===12){t+=`
|
|
9
9
|
`;continue}if(r===13){t+=`
|
|
10
|
-
`,e.charCodeAt(n+1)===10&&(n+=1);continue}if(r===9||r===10){t+=e[n];continue}if(!(r<32||r===65534||r===65535)){if(r>=55296&&r<=56319){let a=e.charCodeAt(n+1);a>=56320&&a<=57343&&(t+=e[n]+e[n+1],n+=1);continue}r>=56320&&r<=57343||(t+=e[n]);}}return t}function Ga(e){if(!e)return "";let t=e.getData("text/plain");if(t.length>0)return t;let n=e.getData("text/html");return n.length>0?Zp(n):""}var qp={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down",Home:"lineStart",End:"lineEnd"},hd={l:"left",e:"center",r:"right",j:"both"},yd={1:"240",5:"360",2:"480"},vd={b:{localName:"b"},i:{localName:"i"},u:{localName:"u",attributes:{val:"single"}}};function xd(e,t={}){return n=>{if(n.defaultPrevented)return;if(n.key==="Escape"&&e.activeScope().kind==="headerFooter"){e.exitHeaderFooter(),n.preventDefault();return}if(n.key==="Escape"&&e.activeScope().kind==="note"){e.exitNote(),n.preventDefault();return}if((n.ctrlKey||n.metaKey)&&n.altKey&&!n.shiftKey){let o=n.key.toLowerCase();if(o==="f"){n.preventDefault(),e.insertNote("footnote");return}if(o==="d"){n.preventDefault(),e.insertNote("endnote");return}}let r=n.metaKey||n.ctrlKey,a=qp[n.key];if(a){let o=a;n.key==="Home"||n.key==="End"?r&&(o=n.key==="Home"?"documentStart":"documentEnd"):(n.key==="ArrowLeft"||n.key==="ArrowRight")&&(n.altKey||n.ctrlKey)?o=n.key==="ArrowLeft"?"wordLeft":"wordRight":n.metaKey&&(n.key==="ArrowLeft"||n.key==="ArrowRight")?o=n.key==="ArrowLeft"?"lineStart":"lineEnd":r&&(n.key==="ArrowUp"||n.key==="ArrowDown")&&(o=n.key==="ArrowUp"?"documentStart":"documentEnd"),e.navigate(o,n.shiftKey),n.preventDefault();return}if(n.key==="PageUp"||n.key==="PageDown"){e.navigate(r?n.key==="PageUp"?"documentStart":"documentEnd":n.key==="PageUp"?"pageUp":"pageDown",n.shiftKey),n.preventDefault();return}if(n.key==="Backspace"){r||n.altKey?e.deleteWordBackward():e.deleteBackward(),n.preventDefault();return}if(n.key==="Delete"){r||n.altKey?e.deleteWordForward():e.deleteForward(),n.preventDefault();return}if(n.key==="Tab"){if(e.contentControls.formFill()&&e.contentControls.navigate(n.shiftKey?"previous":"next")){n.preventDefault();return}e.isListParagraph()?e.adjustIndent(n.shiftKey?"decrease":"increase"):n.shiftKey?e.adjustIndent("decrease"):e.insertTab(),n.preventDefault();return}if(n.key==="Enter"){r?e.insertPageBreak():n.shiftKey?e.insertLineBreak():e.exitListOnEmptyItem()||e.splitParagraph(),n.preventDefault();return}if(r&&n.key.toLowerCase()==="a"){e.selectAll(),n.preventDefault();return}if(r&&!n.shiftKey&&n.key.toLowerCase()==="k"&&t.onRequestHyperlink){t.onRequestHyperlink(),n.preventDefault();return}if(r&&!n.shiftKey&&vd[n.key.toLowerCase()]){let o=vd[n.key.toLowerCase()];e.toggleRunProperty(o.localName,o.attributes),n.preventDefault();return}if(r&&(n.key==="="||n.key==="+"||n.code==="Equal")){e.toggleRunProperty("vertAlign",{val:n.shiftKey?"superscript":"subscript"}),n.preventDefault();return}if(r&&n.shiftKey&&n.key.toLowerCase()==="m"){e.adjustIndent("decrease"),n.preventDefault();return}if(r&&!n.shiftKey&&n.key.toLowerCase()==="m"){e.adjustIndent("increase"),n.preventDefault();return}if(r&&!n.shiftKey&&hd[n.key.toLowerCase()]){if(n.metaKey&&n.key.toLowerCase()==="r")return;e.setParagraphProperty("jc",{val:hd[n.key.toLowerCase()]}),n.preventDefault();return}if(r&&!n.shiftKey&&yd[n.key]){e.setParagraphProperty("spacing",{line:yd[n.key],lineRule:"auto"}),n.preventDefault();return}if(r&&n.key.toLowerCase()==="y"){e.redo(),n.preventDefault();return}(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()==="z"&&(n.shiftKey?e.redo():e.undo(),n.preventDefault());}}function Id(e,t){return {onCopy:o=>{let i=e.selectedText();i&&(o.clipboardData?.setData("text/plain",i),o.preventDefault());},onCut:o=>{let i=e.selectedText();i&&(o.clipboardData?.setData("text/plain",i),e.deleteSelection(),o.preventDefault());},onPaste:o=>{let i=Ga(o.clipboardData);o.preventDefault(),i&&t(i);}}}function bd(e){let t=Ga(e.dataTransfer);return t.length>0?t:null}function Sd(e,t){return n=>{if(n.preventDefault(),!t.isComposing()){if(n.inputType==="insertText"&&n.data!=null){e.type(n.data);return}if(n.inputType!=="insertFromPaste"){if(n.inputType==="insertReplacementText"){let r=n.data??bd(n);r&&e.type(r);return}if(n.inputType==="deleteContentBackward"){e.deleteBackward();return}if(n.inputType==="deleteWordBackward"){e.deleteWordBackward();return}if(n.inputType==="deleteContentForward"){e.deleteForward();return}if(n.inputType==="deleteWordForward"){e.deleteWordForward();return}if(n.inputType==="insertLineBreak"){e.insertLineBreak();return}if(n.inputType==="insertFromDrop"||n.inputType==="insertFromPasteAsQuotation"){let r=bd(n);r&&t.insertPlainText(r);return}n.inputType==="insertParagraph"&&e.splitParagraph();}}}}function kd(e,t){let n=e.querySelectorAll("[data-paragraph-id][data-start]"),r=[];for(let a of n){let o=a;if(o.dataset.paragraphId!==t)continue;let i=Number(o.dataset.start);Number.isInteger(i)&&r.push({start:i,text:o.textContent??""});}return r.length===0?null:(r.sort((a,o)=>a.start-o.start),r.map(a=>a.text).join(""))}function Td(e,t,n){if(n===t)return null;let r=0;for(;r<n.length&&r<t.length&&n[r]===t[r];)r+=1;let a=0;for(;a<n.length-r&&a<t.length-r&&n[n.length-1-a]===t[t.length-1-a];)a+=1;let o=n.slice(r,n.length-a),i=[];return t.length-a>r&&i.push({op:"deleteText",paragraphId:e,start:r,end:t.length-a}),o.length>0&&i.push({op:"insertText",paragraphId:e,offset:r,text:o}),i.length===0?null:{ops:i,caret:r+o.length}}function Wa(e){let{session:t,measurer:n,producer:r,cache:a,styleCascade:o,defaultTabStopPt:i,inlineDrawingLayoutForPart:l,drawingLayoutTokenForPart:d,drawingTokenForParagraphForPart:p}=e,y=new WeakMap,C=null,S=-1;function I(k){let j=t.packageRevision();return (!C||S!==j)&&(C=jp(t.currentPackage()),S=j),C.get(k)}function O(k,j,P){let v=d?.(k.name)??"",T=P?.height??0,M=P?.margin.top??0,G=P?.margin.bottom??0,$=P?.margin.left??0,L=P?.margin.right??0,z=y.get(k);if(z&&z.width===j&&z.pageHeight===T&&z.marginTop===M&&z.marginBottom===G&&z.marginLeft===$&&z.marginRight===L&&z.producer===r&&z.drawingLayoutToken===v)return z.story;let oe=l?.(k.name),re=cd$1(k,j,n,r,a,o,void 0,void 0,i,void 0,oe,p?Oe=>p(k.name,Oe):void 0,void 0,P?{pageNumber:1,pageWidth:P.width,pageHeight:P.height,marginLeft:P.margin.left,marginRight:P.margin.right,marginTop:P.margin.top,marginBottom:P.margin.bottom}:void 0),we=I(k.name),le=we?Pd(re,we):re;return y.set(k,{width:j,pageHeight:T,marginTop:M,marginBottom:G,marginLeft:$,marginRight:L,producer:r,drawingLayoutToken:v,story:le}),le}function m(k,j,P){let v=new Map;for(let[T,M]of k)v.set(T,O(M,j,P));return v}function F(k,j){if(!k||k.headers.size===0&&k.footers.size===0)return;let P=j.width-j.margin.left-j.margin.right;return {titlePage:k.titlePage,evenAndOddHeaders:k.evenAndOddHeaders,headers:m(k.headers,P,j),footers:m(k.footers,P,j)}}function B(){let k=Dc$1(t.part()),j=t.headerFooterPartsBySection();return k.map((P,v)=>F(j[v],Fc$1(P.properties)))}function A(){let k=B();return k[k.length-1]}return {furniture:A,sectionFurniture:B}}var zp="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",Kp="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function jp(e){let t=new Map,n=e.relationships.get(e.mainDocumentPart)??[];for(let r of n){if(r.type!==zp&&r.type!==Kp)continue;let a=N$1(r);if(a.mode!=="Internal"||!a.target.ok)continue;let o=a.target.partName;t.has(o)||t.set(o,r.id);}return t}function Pd(e,t){return e.rId===t?e:{...e,rId:t,withPageContext:n=>Pd(e.withPageContext(n),t)}}function wd(e){let t,n;return {styleCascade:rb(e.stylesRoot(),e.documentThemeFonts()),defaultTabStopPt:Ia$1(e.settingsRoot()),numberingIndex(){let r=e.numberingRoot();return (n===void 0||r!==t)&&(t=r,n=Qb(r)),n}}}function Ct(e){return e.closest(".docx-editor__scroll-container")}function Cd(e,t,n){let r=e.getBoundingClientRect(),a=t.getBoundingClientRect();return {top:(t.scrollTop!==0&&r.top===0&&a.top===0?t.scrollTop-e.offsetTop:a.top+t.clientTop-r.top)/n,height:t.clientHeight/n}}function Rd(e,t,n){let r=Ct(e);if(!r||r.clientHeight<=0||t.pages.length===0||n<=0)return null;let a=Cd(e,r,n),o=a.top+a.height/2;for(let i of t.pages)if(o<i.box.y+i.box.height)return i.index+1;return t.pages.length}function Ed(e,t,n,r){let a=Ct(e);if(!a||a.clientHeight===0)return;let o=Cd(e,a,r),i=[];for(let l of [n.anchor,n.head]){let d=qd$1(t,l);d&&i.push(d.pageIndex);}return md$1({layout:t,viewport:o,overscanPages:1,pinnedPages:i})}function Xa(e,t){if(e===t)return true;if(!e||!t||e.size!==t.size)return false;for(let n of e)if(!t.has(n))return false;return true}function vo(e,t){let n=e.pages,r=n[n.length-1],a=r?r.box.y+r.box.height:0,o=t?n.filter(p=>t.has(p.index)):n,i=0;for(let p of o){let y=p.box.x+p.box.width;y>i&&(i=y);}let l=new Set(o.map(p=>p.box.width)),d=new Map;if(o.length>0&&l.size>1)for(let p of n)d.set(p.index,(i-p.box.width)/2-p.box.x);return {width:i,height:a,pageOffsetX:d}}function Fd(e,t){if(e.width!==t.width||e.height!==t.height||e.pageOffsetX.size!==t.pageOffsetX.size)return false;for(let[n,r]of e.pageOffsetX)if(t.pageOffsetX.get(n)!==r)return false;return true}function Od(e){let t=e.session.currentPackage(),n=Rd$1(t,"footnote"),r=Rd$1(t,"endnote");if(!n&&!r)return;let a=zd$1(t),o=Ad$1(a),i=Bd$1(a),l=Cd$1(void 0,o),d=Dd$2(void 0,i),p=e.session.part(),y=Dc$1(p),C=Vp(p,y),S=y.map((B,A)=>Cd$1(xd$2(C[A]),o)),I=y.map((B,A)=>Dd$2(yd$2(C[A]),i)),O=e.inlineDrawingLayoutForPart,m=e.drawingTokenForParagraphForPart,F=O?B=>{let A=O(B);if(A)return {inlineDrawingLayout:A,...m?{drawingTokenForParagraph:k=>m(B,k)}:{}}}:void 0;return {footnotesPart:n,endnotesPart:r,footnotePropsBySection:S.length>0?S:[l],endnotePropsBySection:I.length>0?I:[d],documentFootnoteProps:l,documentEndnoteProps:d,measurer:e.measurer,producer:e.producer,cache:e.cache,styleCascade:e.styleCascade,defaultTabStopPt:e.defaultTabStopPt,...F?{drawingsForPart:F}:{}}}function Vp(e,t){let n=rc$1(e),r=[];for(let a=0;a<n.length;a+=1){let o=n[a];if(o.kind!=="paragraph")continue;let i=Bc$2(o);i&&r.push(i);}for(;r.length<t.length;)r.push(void 0);return r}function Md(e){if(typeof e.defaultView?.createImageBitmap!="function")return null;let t=e.defaultView;return Object.freeze({async decode(n,r,a){let o=new Blob([new Uint8Array(n)],{type:r}),i=await t.createImageBitmap(o);try{let l=i.width,d=i.height;if(l<=0||d<=0)throw new Error("image dimensions invalid");if(l*d>a.maxPixels)throw new Error("image dimensions exceed limits");return Object.freeze({pixelWidth:l,pixelHeight:d,dpiX:96,dpiY:96})}finally{i.close();}},convertPreserved(n,r,a){return r==="image/tiff"?Wp(e,n,a):Up(n,r)}})}async function Up(e,t,n){let{convertEmfToDataUrl:r,convertWmfToDataUrl:a}=await import('emf-converter'),o=new Uint8Array(e),i=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),l={maxWidth:4096,maxHeight:4096},d=t==="image/x-emf"?await r(i,l):await a(i,l);if(!d)return null;let p="data:image/png;base64,";if(!d.startsWith(p))return null;let y=atob(d.slice(p.length)),C=new Uint8Array(y.length);for(let S=0;S<y.length;S+=1)C[S]=y.charCodeAt(S);return Object.freeze({bytes:C,mime:"image/png"})}function Ad(e,t){let n=e[t];if(!Array.isArray(n)||n.length===0)return null;let r=Number(n[0]);return Number.isSafeInteger(r)&&r>0?r:null}async function Gp(e,t){let n=await import('utif2'),r=n.default??n,a=e.slice().buffer,o=r.decode(a)[0];if(!o)return null;let i=Ad(o,"t256"),l=Ad(o,"t257");if(i===null||l===null||i>t.maxDimension||l>t.maxDimension||i>t.maxPixels/l)return null;let d=i*l;if(d*4>t.maxDecodedBytes||(r.decodeImage(a,o),o.width!==i||o.height!==l))return null;let p=r.toRGBA8(o);return p.length!==d*4?null:Object.freeze({rgba:p,pixelWidth:i,pixelHeight:l})}async function Wp(e,t,n){let r=await Gp(t,n);if(r===null)return null;let a=await Xp(e,r.rgba,r.pixelWidth,r.pixelHeight);return a===null?null:Object.freeze({bytes:a,mime:"image/png"})}async function Xp(e,t,n,r){let a=e.createElement("canvas");if(a.width=n,a.height=r,a.width!==n||a.height!==r)return null;let o=a.getContext("2d");if(!o)return null;let i=o.createImageData(n,r);i.data.set(t),o.putImageData(i,0,0);let l=await new Promise(d=>{a.toBlob(p=>d(p),"image/png");});return l?new Uint8Array(await l.arrayBuffer()):null}function Hd(){return Object.freeze({async decode(){throw new Error("Image decode unavailable in headless environment")}})}function Ld(e){return typeof URL.createObjectURL!="function"||typeof URL.revokeObjectURL!="function"?null:Object.freeze({create(t,n){let r=e.mintValidatedBytes(t,t.contentId);if(!r)throw new Error(`PaintImageUrlSource: validated bytes unavailable for ${t.resourceKey}`);let a=new Uint8Array(r);return URL.createObjectURL(new Blob([a],{type:n}))},revoke(t){URL.revokeObjectURL(t);}})}var $p="docx-editor-one-surface__caret",$a="docx-editor-one-surface__caret--steady",Yp=530;function Dd(e,t,n){let r=e.ownerDocument,a=r.createElement("div");a.className=$p,a.dataset.docxCaret="",a.dataset.docxMarker="",a.setAttribute("contenteditable","false"),a.setAttribute("aria-hidden","true"),a.dataset.noColorInvert="",a.style.position="absolute",a.style.pointerEvents="none",a.style.userSelect="none",a.style.setProperty("-webkit-user-select","none");let o=false,i=null,l=null,d=null;function p(){let A=r.activeElement;return A===e||!!A&&e.contains(A)}function y(A){return A.anchor.paragraphId===A.head.paragraphId&&A.anchor.offset===A.head.offset}function C(){l=null,i!==null&&(clearTimeout(i),i=null),a.classList.remove($a),a.remove(),e.style.removeProperty("caret-color"),d?.style.removeProperty("caret-color"),d=null;}function S(){a.classList.add($a),i!==null&&clearTimeout(i),i=setTimeout(()=>{i=null,a.classList.remove($a);},Yp);}function I(){if(o||!p()||n().suppress){C();return}let{layout:A,selection:k,scopedHost:j,scopedHostKind:P,preferredPageIndex:v,measurer:T}=n(),M=t();if(!y(k)){C();return}let G=qd$1(A,k.head,{...T?{measurer:T}:{},...v!==void 0?{preferredPageIndex:v}:{}});if(!G||!Number.isInteger(G.pageIndex)){C();return}let $=j??e.querySelector(`[data-page-index="${G.pageIndex}"] > .docx-page-content`);if(!$){C();return}a.style.left=`${G.x*M}px`,a.style.top=`${G.y*M}px`,a.style.height=`${G.height*M}px`,a.parentNode!==$&&$.append(a),e.style.caretColor="transparent",d&&d!==j&&d.style.removeProperty("caret-color"),d=j??null,d?.style.setProperty("caret-color","transparent");let L=$===j?P??"scoped":"body",z=`${G.pageIndex}:${L}:${G.x}:${G.y}:${G.height}`;z!==l&&(l=z,S());}let O=()=>{o=true,I();},m=()=>{o=false,I();},F=()=>I(),B=A=>{let k=A.relatedTarget;k&&e.contains(k)||C();};return e.addEventListener("compositionstart",O),e.addEventListener("compositionend",m),e.addEventListener("focusin",F),e.addEventListener("focusout",B),{update:I,destroy(){e.removeEventListener("compositionstart",O),e.removeEventListener("compositionend",m),e.removeEventListener("focusin",F),e.removeEventListener("focusout",B),C();}}}function Nd(e,t){for(let n of e)if(n.kind==="table"){t(n);for(let r of n.rows)for(let a of r.cells)Nd(a.blocks,t);}}function Qp(e,t){for(let n of e.pages)Nd(n.fragments,r=>{for(let a=0;a<r.rows.length;a+=1)t({table:r,row:r.rows[a],rowIndex:a});});}function Ya(e,t,n,r){let a=null;return Qp(e,o=>{o.table.tableId===t&&o.row.id===n&&o.row.isHeaderRepeat===r&&(a=o);}),a}function Qa(e,t){return {sourceRevision:e,tableId:t.table.tableId,rowId:t.row.id,isHeaderRepeat:t.row.isHeaderRepeat}}function _d(e,t,n){let r=n.gridColumnId;return r?{sourceRevision:e,tableId:t.table.tableId,gridColumnId:r,isHeaderRepeat:t.row.isHeaderRepeat}:null}function Bd(e,t,n,r){return {sourceRevision:e,tableId:t.table.tableId,leftGridColumnId:n,rightGridColumnId:r,isHeaderRepeat:t.row.isHeaderRepeat}}function Zd(e,t,n){return {sourceRevision:e,tableId:t.table.tableId,gridColumnId:n,isHeaderRepeat:t.row.isHeaderRepeat}}var Jp=120,qd=20;function bo(e){let t=hf$1(e,"w"),n=t?Number.parseInt(t,10):Number.NaN;return Number.isFinite(n)?n:0}function eg(e,t,n){let r=e.pagesLayer.getBoundingClientRect(),a=e.scale();return {x:(t-r.left)/a,y:(n-r.top)/a}}function Ja(e){let t=e.editingMode==="view";return {editable:!t,viewing:t}}function xo(e,t,n){let r=a=>{for(let o of a)if(o.kind==="table"){if(o.tableId===t)return o;for(let i of o.rows)for(let l of i.cells){let d=r(l.blocks);if(d)return d}}return null};return r(e.pages[n]?.fragments??[])}function ei(e,t){return t.kind==="insertColumn"?Ya(e,t.tableId,t.rowId,t.isHeaderRepeat):"rowId"in t?Ya(e,t.tableId,t.rowId,t.isHeaderRepeat):null}function zd(e){let t=e.furnitureLayer;t.className="docx-table-furniture",t.setAttribute("contenteditable","false"),t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.pointerEvents="none";let n=null,r=null,a=null,o=null,i=null,l=null,d=false,p=0,y=0,C=null,S=null,I=null;function O(h){return h instanceof HTMLButtonElement&&(h.classList.contains("docx-table-insert-row")||h.classList.contains("docx-table-insert-column"))}function m(){let h=document.activeElement;return h!==null&&O(h)&&h.closest(".docx-table-furniture")===t?h:null}function F(h){for(let x of [...t.children])O(x)&&x!==h&&x.remove();}function B(){S=null,I=null;}function A(){n!==null&&(clearTimeout(n),n=null);}function k(){for(let x of [...t.children])O(x)||x.remove();let h=m();if(!h){F(null),B();return}S=h,F(h);}function j(h){let x=S??m(),N=x!==null&&document.activeElement===x;B(),t.replaceChildren(),h&&N&&e.pagesLayer.focus({preventScroll:true});}function P(){for(let h of [...t.children])O(h)||h.remove();}function v(h,x,N){let Z=e.read().layout.pages[h];if(!Z)return {left:0,top:0};let ee=e.scale(),ne=e.pageOffsetX(h);return {left:(Z.contentBox.x+x+ne)*ee,top:(Z.contentBox.y+N)*ee}}function T(h,x){let N=e.read(),D=xo(N.layout,x.tableId,x.pageIndex);if(!D)return;let Z=document.createElement("div");Z.className="docx-table-resize-preview",Z.style.position="absolute",Z.style.pointerEvents="none";let ee=x.kind!=="rowDivider",ne=v(x.pageIndex,ee?D.box.x+h:D.box.x,ee?D.box.y:D.box.y+h);Z.style.left=`${ne.left}px`,Z.style.top=`${ne.top}px`,Z.style.width=ee?"2px":`${D.box.width*e.scale()}px`,Z.style.height=ee?`${D.box.height*e.scale()}px`:"2px",t.append(Z);}function M(){let h=document.createElement("button");return h.type="button",h.textContent="+",h.style.position="absolute",h.style.pointerEvents="auto",h}function G(h){oe(h);let x=I;if(!x)return;let N=e.read();x.kind==="insertRow"?we(x,N):x.kind==="insertColumn"&&le(x,N);}function $(){queueMicrotask(()=>{!S||document.activeElement===S||d||r?.kind==="insertRow"||r?.kind==="insertColumn"||(S.remove(),B());});}function L(){if(S&&t.contains(S))return S;let h=m();if(h)return S=h,h;let x=M();return x.addEventListener("pointerenter",()=>{d=true,A();}),x.addEventListener("pointerleave",()=>{d=false;}),x.addEventListener("pointerdown",oe),x.addEventListener("mousedown",oe),x.addEventListener("click",G),x.addEventListener("blur",$),S=x,x}function z(h,x){let N=xo(x.layout,h.tableId,h.pageIndex);if(!N)return;let D=L();if(F(D),I=h,D.dataset.tableId=h.tableId,h.kind==="insertRow"){let Z=N.rows.find(ge=>ge.id===h.rowId);if(!Z)return;D.dataset.rowId=h.rowId,delete D.dataset.gridColumnId,D.className="docx-table-insert-row",D.setAttribute("aria-label",e.label("table.insertRowBelow"));let ee=Z.box.y+Z.box.height/2,ne=v(h.pageIndex,N.box.x-14,ee);D.style.left=`${ne.left}px`,D.style.top=`${ne.top-8}px`;}else {let Z=N.rows[0]?.cells.find(Ce=>Ce.gridColumnId===h.gridColumnId);if(!Z)return;D.dataset.gridColumnId=h.gridColumnId,delete D.dataset.rowId;let ee=N.columnEdges[Z.gridColumn]??0,ne=N.columnEdges[Z.gridColumn+1]??N.box.width;D.className="docx-table-insert-column",D.setAttribute("aria-label",e.label("table.insertColumnRight"));let ge=v(h.pageIndex,N.box.x+(ee+ne)/2-8,N.box.y-14);D.style.left=`${ge.left}px`,D.style.top=`${ge.top}px`;}t.contains(D)||t.append(D);}function oe(h){h.preventDefault(),h.stopPropagation();}function re(h,x){if(P(),F(S??m()),!(l||x.editingMode==="view")){if((h.kind==="columnDivider"||h.kind==="rightEdge")&&!h.isHeaderRepeat){let N=xo(x.layout,h.tableId,h.pageIndex);if(!N)return;let D=document.createElement("div");D.className=h.kind==="rightEdge"?"docx-table-edge-handle-right layout-table-edge-handle-right":"docx-table-divider-handle layout-table-resize-handle",D.style.position="absolute",D.style.pointerEvents="auto",D.style.cursor="col-resize",D.dataset.active="true";let Z=v(h.pageIndex,N.box.x+h.edgeX,N.box.y);D.style.left=`${Z.left-3}px`,D.style.top=`${Z.top}px`,D.style.width="6px",D.style.height=`${N.box.height*e.scale()}px`,D.addEventListener("pointerdown",Oe),t.append(D);}if(h.kind==="rowDivider"&&!h.isHeaderRepeat){let N=xo(x.layout,h.tableId,h.pageIndex);if(!N)return;let D=document.createElement("div");D.className="docx-table-row-divider-handle layout-table-row-resize-handle",D.style.position="absolute",D.style.pointerEvents="auto",D.style.cursor="row-resize",D.dataset.active="true";let Z=v(h.pageIndex,N.box.x,N.box.y+h.edgeY);D.style.left=`${Z.left}px`,D.style.top=`${Z.top-3}px`,D.style.width=`${N.box.width*e.scale()}px`,D.style.height="6px",D.addEventListener("pointerdown",Oe),t.append(D);}h.kind==="insertRow"&&!h.isHeaderRepeat&&z(h,x),h.kind==="insertColumn"&&!h.isHeaderRepeat&&z(h,x);}}function we(h,x){let N=ei(x.layout,h);if(!N)return;let D=Ja(x),Z=Nt({command:{type:"insertRow",where:"below",target:Qa(h.sourceRevision,N)},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...D});e.applyTableCommandPlan(Z);}function le(h,x){let N=ei(x.layout,h);if(!N)return;let D=N.row.cells.find(ge=>ge.gridColumnId===h.gridColumnId);if(!D)return;let Z=_d(h.sourceRevision,N,D);if(!Z)return;let ee=Ja(x),ne=Nt({command:{type:"insertColumn",where:"right",target:Z},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...ee});e.applyTableCommandPlan(ne);}function Oe(h){if(h.button!==0)return;let x=e.read();if(x.editingMode==="view"||!r||r.kind!=="columnDivider"&&r.kind!=="rightEdge"&&r.kind!=="rowDivider")return;h.preventDefault(),h.stopPropagation();let N=r,D=ei(x.layout,N);if(!D)return;let Z=_if(e.session().part().root,N.tableId);if(!Z.ok||N.kind!=="rowDivider"&&Z.topology.hasMerge)return;let ee=0,ne=0,ge=0,Ce=Z.topology.gridColumns.reduce((Be,Ae)=>Be+bo(Ae),0),Je;if(N.kind==="columnDivider"){let Be=Z.topology.gridColumns.find(Ie=>Ie.id===N.leftGridColumnId),Ae=Z.topology.gridColumns.find(Ie=>Ie.id===N.rightGridColumnId);if(!Be||!Ae)return;ee=bo(Be),ne=bo(Ae),Je=Bd(N.sourceRevision,D,N.leftGridColumnId,N.rightGridColumnId);}else if(N.kind==="rightEdge"){let Be=Z.topology.gridColumns.find(Ae=>Ae.id===N.gridColumnId);if(!Be)return;ee=bo(Be),ne=0,Je=Zd(N.sourceRevision,D,N.gridColumnId);}else ge=Math.max(20,Math.round(D.row.box.height*qd)),Je=Qa(N.sourceRevision,D);let qe=h.currentTarget;qe.setPointerCapture(h.pointerId),p=h.clientX,y=h.clientY,l={pointerId:h.pointerId,startClientX:h.clientX,startClientY:h.clientY,startEdgePt:N.kind==="rowDivider"?N.edgeY:N.edgeX,leftTwips:ee,rightTwips:ne,tableWidthTwips:Ce,rowHeightTwips:ge,target:N,ref:D,resizeTarget:Je,captureElement:qe,rightEdge:N.kind==="rightEdge",vertical:N.kind==="rowDivider",cancelled:false};for(let Be of [...t.children])Be!==qe&&Be.remove();T(N.kind==="rowDivider"?N.edgeY:N.edgeX,N);}function Ue(){if(l){try{l.captureElement.hasPointerCapture(l.pointerId)&&l.captureElement.releasePointerCapture(l.pointerId);}catch{}l.cancelled=true,l=null,k(),r=null;}}function xe(){if(!l||l.cancelled){l=null,k();return}let h=l;l=null;try{h.captureElement.hasPointerCapture(h.pointerId)&&h.captureElement.releasePointerCapture(h.pointerId);}catch{}if(h.vertical?y===h.startClientY:p===h.startClientX){k();return}let x=e.read(),N=Ja(x),D=(h.vertical?y-h.startClientY:p-h.startClientX)/e.scale(),Z=Math.round(D*qd),ee;if(h.target.kind==="rowDivider")ee=Tl({part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...N},h.resizeTarget,Math.max(20,h.rowHeightTwips+Z));else if(h.rightEdge&&h.target.kind==="rightEdge"){let ne=Math.max(300,h.leftTwips+Z),ge=Math.max(ne,h.tableWidthTwips+Z);ee=Nt({command:{type:"commitTableRightEdgeResize",target:h.resizeTarget,columnWidthTwips:ne,tableWidthTwips:ge},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...N});}else if(h.target.kind==="columnDivider"){let ne=h.leftTwips+Z,ge=h.rightTwips-Z;ne=Math.max(300,ne),ge=Math.max(300,ge);let Ce=h.leftTwips+h.rightTwips;ne+ge!==Ce&&(ne>Ce-300?(ne=Ce-300,ge=300):ge=Ce-ne),ee=Nt({command:{type:"commitTableColumnDividerResize",target:h.resizeTarget,leftWidthTwips:ne,rightWidthTwips:ge},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...N});}else {k();return}e.applyTableCommandPlan(ee),k();}function at(h){if(!a||!C)return null;let x=e.pageOffsetX(C.pageIndex);return oc$1(a,C.x,C.y,h.layout,x,C.pageIndex)}function Le(h){if(!r||l||h.editingMode==="view")return;A();let x=at(h);if(!x||x.kind==="tableBody"){r=null,k();return}if(mc$1(x)!==mc$1(r)){r=null,k();return}r=x,re(x,h);}function Ne(){let h=S??m(),x=h!==null&&document.activeElement===h;B(),h&&t.contains(h)&&h.remove(),x&&e.pagesLayer.focus({preventScroll:true});}function Xe(h){if(l||h.editingMode==="view")return;let x=S??m();if(!x||!t.contains(x)){I&&B();return}if(S=x,!I||I.kind!=="insertRow"&&I.kind!=="insertColumn")return;if(!a){Ne();return}let N=mc$1(I),D=nc$1(a,I);if(!D||mc$1(D)!==N){Ne();return}I=D,z(D,h);}function De(h){let x=e.read();if(l&&h.pointerId===l.pointerId){p=h.clientX,y=h.clientY;let ne=(l.vertical?h.clientY-l.startClientY:h.clientX-l.startClientX)/e.scale();for(let ge of [...t.children])ge!==l.captureElement&&ge.remove();T(l.startEdgePt+ne,l.target);return}if(x.editingMode==="view"){j(false);return}let N=eg(e,h.clientX,h.clientY),D=ac$1(x.layout,N.y);D>=0&&(C={x:N.x,y:N.y,pageIndex:D});let Z=D>=0?e.pageOffsetX(D):0,ee=a?oc$1(a,N.x,N.y,x.layout,Z,D>=0?D:void 0):null;if(!ee||ee.kind==="tableBody"){if(d)return;!n&&r&&(n=setTimeout(()=>{n=null,r=null,k();},Jp));return}n&&(clearTimeout(n),n=null),!(r&&lc$1(ee)===lc$1(r))&&(r=ee,re(ee,x));}function pe(h){if(!(!l||h.pointerId!==l.pointerId)){if(e.read().editingMode==="view"){Ue();return}xe();}}function R(h){!l||h.pointerId!==l.pointerId||Ue();}function X(h){h.key!=="Escape"||!l||Ue();}return e.pagesLayer.addEventListener("pointermove",De),document.addEventListener("pointermove",De),document.addEventListener("pointerup",pe),document.addEventListener("pointercancel",R),e.pagesLayer.addEventListener("keydown",X),{update(){let h=e.read(),x=o,N=i;a=kc$1(h.layout),o=h.layout.revision,i=h.storeRevision,h.editingMode==="view"?(Ue(),r=null,A(),j(true)):x!==null&&(x!==h.layout.revision||N!==h.storeRevision)&&(r!==null&&Le(h),Xe(h)),t.style.width=e.pagesLayer.style.width,t.style.height=e.pagesLayer.style.height;},refreshLabels(){let h=e.read();if(h.editingMode==="view")return;let x=S??m();if(x&&t.contains(x)&&I&&(I.kind==="insertRow"||I.kind==="insertColumn")){z(I,h);return}r&&(r.kind==="insertRow"||r.kind==="insertColumn")&&z(r,h);},destroy(){A(),Ue(),B(),k(),e.pagesLayer.removeEventListener("pointermove",De),document.removeEventListener("pointermove",De),document.removeEventListener("pointerup",pe),document.removeEventListener("pointercancel",R),e.pagesLayer.removeEventListener("keydown",X),t.remove();}}}var Kd=new WeakMap;function Io(e,t){let n=Kd.get(e);if(!n){n=new Map;for(let r of e.pages)for(let a of R(r))n.has(a.paragraphId)||n.set(a.paragraphId,a.props);Kd.set(e,n);}return n.get(t)??[]}var jd=new WeakMap;function tg(e,t){let n=jd.get(e);if(!n){let r=new Map,a=(o,i)=>{for(let l of o){if(l.kind==="paragraph"){r.has(l.paragraphId)||r.set(l.paragraphId,{indent:l.indent,inTable:i});continue}for(let d of l.rows)for(let p of d.cells)a(p.blocks,true);}};for(let o of e.pages)a(o.fragments,false);n=r,jd.set(e,r);}return n.get(t)??null}function So(e,t,n,r,a){let o=Ea$1(e,t);if(!o||o.kind!=="paragraph")return [];let i=[],l=Vf$1(o),d=Wf$1(o);return Qb$1(o.children,0,p=>{if(p.kind!=="run")return;let y=l.get(p.id);if(!y||y.end<=y.start)return;let C=Math.max(y.start,n),S=Math.min(y.end,r);C>=S||i.push({start:C,end:S,properties:Uf$1(Rf$1(Qf$1(p,"runProperties","rPr"),Of$1),a),...d.has(p.id)?{targetRunIds:[p.id]}:{}});}),i}function Vd(e,t,n,r){let a=Ea$1(e,t);if(!a||a.kind!=="paragraph")return false;let o=Vf$1(a),i=false,l=d=>{if(i||d.kind!=="run")return;let p=o.get(d.id);!p||p.end<=p.start||Math.max(p.start,n)>=Math.min(p.end,r)||Rf$1(Qf$1(d,"runProperties","rPr"),Of$1).length>0&&(i=true);};return Qb$1(a.children,0,l),i}function Ud(e,t,n){let r=Ea$1(e,t);if(!r||r.kind!=="paragraph")return [];let a=Vf$1(r),o=null,i=null,l=p=>{if(p.kind!=="run")return;let y=a.get(p.id);!y||y.end<=y.start||(y.start<n&&n<=y.end&&(o=p),i===null&&y.start<=n&&n<y.end&&(i=p));};Qb$1(r.children,0,l);let d=o??i;return d?Rf$1(Qf$1(d,"runProperties","rPr"),Of$1):Tf$1(e,t)}function En(e,t,n){let r=e?.find(o=>o.localName===t);if(!r)return null;let a=r.attributes?.val;return t==="vertAlign"?a===n:(t==="u"||a!=="0"&&a!=="false"&&a!=="off")&&a!=="none"}function Gd(e,t){if(!t||t.length===0)return e;let n=e;for(let r of t){let a=r.attributes?.val;switch(r.localName){case "b":n={...n,bold:En(t,"b")===true};break;case "i":n={...n,italic:En(t,"i")===true};break;case "u":n={...n,underline:En(t,"u")===true};break;case "strike":n={...n,strikethrough:En(t,"strike")===true};break;case "vertAlign":n={...n,superscript:a==="superscript",subscript:a==="subscript"};break;case "rFonts":n={...n,fontFamily:r.attributes?.ascii??n.fontFamily};break;case "sz":{let o=Number(a);Number.isFinite(o)&&(n={...n,fontSizeHalfPoints:o});break}case "color":n={...n,color:a==="auto"?null:a??n.color};break;case "highlight":n={...n,highlight:a==="none"?null:a??n.highlight};break;}}return n}function Wd(e,t,n){return n&&n.length>0?Ed$1(e,n):Bd$2(e,t)}function ti(e,t,n,r,a){let o=Wd(e,t,r);if(o.length===0)return false;let i=l=>{switch(n){case "b":return l.style.bold;case "i":return l.style.italic;case "u":return l.style.underline!==null;case "strike":return l.style.strike;case "vertAlign":return l.style.verticalAlign===a;default:return false}};return o.every(i)}function Xd(e,t,n,r,a){let o=Wd(e,t,r),i=o.map(v=>v.style),l=v=>{if(i.length===0)return null;let T=v(i[0]);return i.every(M=>v(M)===T)?T:null},d=v=>v.length>0&&v.every(T=>T===v[0])?v[0]:null,p=(v,T)=>v.props.some(M=>M.localName===T),y=v=>v.style.fontFamily??n?.(v.range.paragraphId,v.props).fontFamily??null,C=v=>p(v,"sz")?Math.round(v.style.fontSizePt*2):n?.(v.range.paragraphId,v.props).fontSizeHalfPoints??Math.round(v.style.fontSizePt*2),S=o.length===0?n?.(t.head.paragraphId,[]):void 0,I=ng(e,t),O=v=>d(I.map(T=>v(Io(e,T)))),m=O(v=>{let T=v.find(M=>M.localName==="jc")?.attributes?.val;return T==="center"||T==="right"||T==="both"?T:T==="end"?"right":"left"}),F=O(v=>v.find(T=>T.localName==="pStyle")?.attributes?.val??a??void 0)??null,B=v=>v.find(T=>T.localName==="spacing")?.attributes,A=O(v=>{let T=B(v),M=Number(T?.line);if(!Number.isFinite(M))return "";let G=T?.lineRule??"auto";return G==="auto"?`multiple:${Math.round(M/240*100)/100}`:`${G==="exact"?"exact":"atLeast"}:${Math.round(M/20*100)/100}`}),k=(()=>{if(!A)return null;let[v,T]=A.split(":");return {rule:v,value:Number(T)}})(),j=v=>O(T=>{let M=Number(B(T)?.[v]);return Number.isFinite(M)?Math.round(M/20*100)/100:null}),P=(()=>{let v=I.map(re=>tg(e,re)),T=v[0];if(!T||v.some(re=>re===null||re.inTable))return null;let M=re=>Math.round(re*20),G=re=>M(re.hanging>0?-re.hanging:re.firstLine),$=v,L=M(T.indent.left),z=M(T.indent.right),oe=G(T.indent);return {left:L,right:z,firstLine:oe,mixed:{left:$.some(re=>M(re.indent.left)!==L),right:$.some(re=>M(re.indent.right)!==z),firstLine:$.some(re=>G(re.indent)!==oe)}}})();return {bold:i.length>0&&i.every(v=>v.bold),italic:i.length>0&&i.every(v=>v.italic),underline:i.length>0&&i.every(v=>v.underline!==null),strikethrough:i.length>0&&i.every(v=>v.strike),superscript:i.length>0&&i.every(v=>v.verticalAlign==="superscript"),subscript:i.length>0&&i.every(v=>v.verticalAlign==="subscript"),fontFamily:o.length>0?d(o.map(y)):S?.fontFamily??null,fontSizeHalfPoints:o.length>0?d(o.map(C)):S?.fontSizeHalfPoints??null,color:l(v=>v.color),highlight:l(v=>v.highlight),alignment:m,styleId:F,lineSpacing:k,spaceBeforePt:j("before"),spaceAfterPt:j("after"),indent:P}}function ng(e,t){if(t.anchor.paragraphId===t.head.paragraphId)return [t.head.paragraphId];let n=wd$1(e),r=n.indexOf(t.anchor.paragraphId),a=n.indexOf(t.head.paragraphId);return r===-1||a===-1?[t.head.paragraphId]:n.slice(Math.min(r,a),Math.max(r,a)+1)}function $d(e,t,n,r){return t.paragraphId!==n.paragraphId?[]:t.offset!==0||n.offset!==e.length?[]:e.length===0?[]:[{op:"setParagraphMarkProperties",paragraphId:t.paragraphId,properties:r}]}function Yd(e){let{session:t,commit:n,orderedRange:r,selectionMark:a,textOf:o}=e,i=()=>t.partFor(e.storyScope())??t.part(),l=(I,O,m)=>t.applyTreeOps(I,O,m,e.storyScope()),d={get value(){return e.layout()}},p={get value(){return e.selection()}},y=(I,O,m)=>{let F=i();if(I.paragraphId===O.paragraphId){let P=So(F,I.paragraphId,I.offset,O.offset,m);if(P.length===0)return;let v=Uf$1(Tf$1(F,I.paragraphId),m);n(()=>l([...P.map(T=>({op:"setRunProperties",paragraphId:I.paragraphId,start:T.start,end:T.end,properties:T.properties,...T.targetRunIds?{targetRunIds:T.targetRunIds}:{}})),...$d(o(I.paragraphId),I,O,v)],a()));return}let B=e.paragraphOrder(),A=B.indexOf(I.paragraphId),k=B.indexOf(O.paragraphId);if(A===-1||k===-1)return;let j=[];for(let P=A;P<=k;P+=1){let v=B[P],T=o(v),M=P===A?I.offset:0,G=P===k?O.offset:T.length,$=M<G?So(F,v,M,G,m):[];for(let z of $)j.push({op:"setRunProperties",paragraphId:v,start:z.start,end:z.end,properties:z.properties,...z.targetRunIds?{targetRunIds:z.targetRunIds}:{}});(P<k||M===0&&G===T.length&&T.length>0)&&j.push({op:"setParagraphMarkProperties",paragraphId:v,properties:Uf$1(Tf$1(F,v),m)});}j.length!==0&&n(()=>l(j,a()));},C=(I,O)=>{let m=i(),F=[];for(let B of Dd$1(d.value,I)){let A=o(B);for(let k of So(m,B,0,A.length,O))F.push({op:"setRunProperties",paragraphId:B,start:k.start,end:k.end,properties:k.properties,...k.targetRunIds?{targetRunIds:k.targetRunIds}:{}});F.push({op:"setParagraphMarkProperties",paragraphId:B,properties:Uf$1(Tf$1(m,B),O)});}return F.length===0?false:(n(()=>l(F,a()),void 0,{keepCellSelection:true}),true)},S=I=>{Pf$1(I.localName)&&e.setPendingFormats(Uf$1(e.pendingFormats()??[],I));};return {setRunProperty(I,O){let m={localName:I,...O?{attributes:O}:{}},F=e.selectedCells?.();if(F&&F.length>0){C(F,m);return}let{from:B,to:A}=r();if(B.paragraphId===A.paragraphId&&B.offset===A.offset){S(m);return}y(B,A,m);},setParagraphProperty(I,O,m){let{from:F,to:B}=r(),A=e.paragraphOrder(),k=A.indexOf(F.paragraphId),j=A.indexOf(B.paragraphId);if(k===-1||j===-1)return;let P=i(),v=A.slice(k,j+1).map(T=>{let M=Sf$1(P,T),G=m?.mergeAttributes?{...M.find(L=>L.localName===I)?.attributes??{},...O}:O??{},$=Object.fromEntries(Object.entries(G).filter(([,L])=>L!=null));return {op:"setParagraphProperties",paragraphId:T,properties:Uf$1(M,{localName:I,...Object.keys($).length>0?{attributes:$}:{}})}});v.length!==0&&n(()=>l(v,a()));},formatting:()=>Gd(Xd(d.value,p.value,(I,O)=>{let m=t.effectiveRunDefaults(I,O);if(m.fontFamily!==null)return m;let F=e.defaultFontFamily?.()??null;return F===null?m:{...m,fontFamily:F}},e.selectedCells?.(),e.defaultParagraphStyleId?.()??null),e.pendingFormats()),toggleRunProperty(I,O){let m=e.selectedCells?.(),F=O?.val,B=En(e.pendingFormats(),I,F)??ti(d.value,p.value,I,m,F),A=B?{localName:I,attributes:{val:rg[I]??"0"}}:{localName:I,...O?{attributes:O}:{}};if(m&&m.length>0){C(m,A);return}let{from:k,to:j}=r();if(k.paragraphId===j.paragraphId&&k.offset===j.offset){let P=e.pendingFormats()??[],v=ti(d.value,p.value,I,void 0,F);if(!B===v){let T=P.filter(M=>M.localName!==I);e.setPendingFormats(T.length>0?T:null);}else S(A);return}y(k,j,A);},clearFormatting(){e.setPendingFormats(null);let I=d.value,O=e.paragraphOrder(),m=e.selectedCells?.(),F=m&&m.length>0?[...Dd$1(I,m)]:og(O,r());if(F.length===0)return;let{from:B,to:A}=r(),k=m!==void 0&&m.length>0,j=i(),P=[];for(let v of F){let T=o(v),M=k||v!==B.paragraphId?0:B.offset,G=k||v!==A.paragraphId?T.length:A.offset;M<G&&Vd(j,v,M,G)&&P.push({op:"setRunProperties",paragraphId:v,start:M,end:G,properties:[]}),Tf$1(j,v).length>0&&P.push({op:"setParagraphMarkProperties",paragraphId:v,properties:[]}),Sf$1(j,v).length>0&&P.push({op:"setParagraphProperties",paragraphId:v,properties:[]});}P.length!==0&&n(()=>l(P,a()),void 0,{keepCellSelection:k});}}}var rg={u:"none",vertAlign:"baseline"};function og(e,t){let n=e.indexOf(t.from.paragraphId),r=e.indexOf(t.to.paragraphId);return n===-1||r===-1?[]:e.slice(n,r+1)}var ag=Object.freeze({kind:"body"});function ko(e,t){if(e)return {kind:"headerFooter",rId:e.scope.rId};if(t){let n=_c$1(t.id);if(n)return {kind:"notesPart",noteKind:n.noteKind}}return {kind:"body"}}function Jd(e,t){return e?e.scope:t||ag}function ig(e,t,n){if(n){let a=[];for(let o of [e.footnotes,e.endnotes])if(o)for(let i of o.notes)i.scopeId===n&&a.push(...Qd(i.fragments));return a}if(!t)return R(e);let r=Fn(e,t);return r?Qd(r.fragments):[]}function Fn(e,t){let n=t.kind==="header"?e.header:e.footer;if(n&&(n.rId&&n.rId===t.scope.rId||!n.rId&&n.partName===t.partName))return n}function ec(e,t){for(let n of e.pages)for(let r of ["header","footer"]){let a=n[r];if(a?.rId===t)return {pageIndex:n.index,kind:r,story:a}}return null}function ni(e,t){return !!(e.rId&&e.rId===t.scope.rId||!e.rId&&e.partName===t.partName&&e.kind===t.kind)}function ri(e,t,n){let r=ac$1(e,t.y),a=e.pages[r];if(!a)return false;let o=t.x-n(r),i=t.y,l=a.contentBox;return o>=l.x&&o<l.x+l.width&&i>=l.y&&i<l.y+l.height}function oi(e,t,n,r,a={}){return dc$1(e,t,n.fragments,r,a)}function sg(e,t,n){let r=e.pages[t.pageIndex]??e.pages[0];if(!r)return null;let a=Fn(r,t);return a?pd$1(e,t.pageIndex,a.fragments,n):null}function lg(e,t,n){let r=[];for(let a of e.pages)for(let o of [a.footnotes,a.endnotes]){let i=o?.notes.find(l=>l.scopeId===t);i&&r.push(...pd$1(e,a.index,i.fragments,n));}return r.length>0?r:null}function tc(e,t){return e.querySelector(`[data-page-index="${t}"] > [data-docx-hf-active]`)??e.querySelector("[data-docx-hf-active]")}function nc(e,t,n){let r=e.querySelectorAll("[data-docx-note-scope]"),a=null;for(let o of r){if(o.dataset.docxNoteScope!==t||!o.matches("[data-docx-note]"))continue;a??=o;let i=Number(o.closest("[data-page-index]")?.dataset.pageIndex);if(n!==null&&i===n)return o}return a}function rc(e,t,n){if((o=>{let i=e.pages[o];return !!i&&!!Fn(i,t)})(t.pageIndex)&&(n===void 0||n.has(t.pageIndex)))return t.pageIndex;let a=null;for(let o of e.pages)if(Fn(o,t)&&(a===null&&(a=o.index),n===void 0||n.has(o.index)))return o.index;return a??t.pageIndex}function oc(e){return e?{rId:e.scope.rId,pageIndex:e.pageIndex,kind:e.kind,partName:e.partName,variant:e.variant}:null}function ac(e,t,n){e.classList.toggle("docx-paginated-surface--hf-editing",n),t.classList.toggle("docx-pages--hf-editing",n);}function ai(e,t,n,r,a,o,i){let l=a?sg(e,a,i):o?lg(e,o,i):null,d=zd$2(e,t,n,r,{...i?{measurer:i}:{},...l?{stops:l}:{}});if(!d)return null;if(!l)return d;let p=l.find(y=>y.position.paragraphId===d.position.paragraphId&&y.position.offset===d.position.offset);return p?{...d,pageIndex:p.pageIndex}:d}function ii(e,t,n){for(let r of e.pages){let a=n(r.index);for(let o of [r.footnotes,r.endnotes])if(o)for(let i of o.notes){let l=i.box,d=l.x+a,p=l.y;if(t.x>=d&&t.x<d+l.width&&t.y>=p&&t.y<p+l.height)return {pageIndex:r.index,scopeId:i.scopeId,noteKind:i.noteKind,noteId:i.noteId,local:{x:t.x-d,y:t.y-p},fragments:i.fragments}}}return null}function ic(e,t){let n=e[t],r=e.contentBox,a=e.box;if(t==="header"){let p=a.y,y=r.y,C=n?Math.max(y,n.box.y+n.box.height):y,S=n?Math.min(p,n.box.y):p;return C<=S?null:{x:r.x,y:S,width:r.width,height:C-S}}let o=r.y+r.height,i=a.y+a.height,l=n?Math.min(o,n.box.y):o,d=n?Math.max(i,n.box.y+n.box.height):i;return d<=l?null:{x:r.x,y:l,width:r.width,height:d-l}}function si(e,t,n){for(let r of e.pages){let a=n(r.index);for(let o of ["header","footer"]){if(r[o])continue;let i=ic(r,o);if(!i)continue;let l=i.x+a;if(t.x>=l&&t.x<l+i.width&&t.y>=i.y&&t.y<i.y+i.height)return {pageIndex:r.index,kind:o}}}return null}function li(e,t,n){for(let r of e.pages){let a=n(r.index);for(let o of ["header","footer"]){let i=r[o];if(!i)continue;let l=i.box,d=ic(r,o)??l,p=d.x+a,y=d.y;if(t.x>=p&&t.x<p+d.width&&t.y>=y&&t.y<y+d.height)return {pageIndex:r.index,kind:o,story:i,local:{x:t.x-(l.x+a),y:t.y-l.y}}}}return null}function On(e,t,n){if(!t&&!n)return wd$1(e);let r=new Set,a=[];for(let o of e.pages)for(let i of ig(o,t,n))r.has(i.paragraphId)||(r.add(i.paragraphId),a.push(i.paragraphId));return a}function To(e,t,n,r){let a=On(e,n,r);if(a.length===0)return t;let o=new Set(a),i=l=>o.has(l.paragraphId)?l:{paragraphId:a[0],offset:0};return {anchor:i(t.anchor),head:i(t.head)}}function Qd(e){let t=[],n=r=>{for(let a of r){if(a.kind==="paragraph"){t.push(a);continue}for(let o of a.rows)if(!o.isHeaderRepeat)for(let i of o.cells)n(i.blocks);}};return n(e),t}var dg=500,sc=4,An=40,Po=12;function cg(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),a=Math.min(e.x+e.width,t.x+t.width),o=Math.min(e.y+e.height,t.y+t.height);return a<=n||o<=r?0:(a-n)*(o-r)}function lc(e,t){return cg(e,t)>0?true:e.width===0?t.x<=e.x&&e.x<=t.x+t.width&&!(e.y+e.height<t.y||t.y+t.height<e.y):false}function ft(e,t,n){let r=wd$1(e),a=r.indexOf(t.paragraphId),o=r.indexOf(n.paragraphId);return a!==o?a-o:t.offset-n.offset}function uc(e,t,n){if(!(t>Ib))for(let r of e){if(r.kind==="paragraph"){n(r);continue}if(!(t>=Ib)){for(let a of r.rows)if(!a.isHeaderRepeat)for(let o of a.cells)uc(o.blocks,t+1,n);}}}function di(e,t){if(!t.placeholder||t.fragments.length===0)return null;let n=null,r=null,a=(i,l)=>{(!n||ft(e,i,n)<0)&&(n=i),(!r||ft(e,l,r)>0)&&(r=l);},o=t.level!=="inline";for(let i of t.fragments){let l=e.pages[i.pageIndex];l&&uc(l.fragments,0,d=>{if(lc(i.box,d.box)){if(o){let p=xd$1(e,d.paragraphId).length;a({paragraphId:d.paragraphId,offset:0},{paragraphId:d.paragraphId,offset:p});return}for(let p of d.lines)for(let y of p.spans)lc(i.box,y.box)&&a({paragraphId:y.range.paragraphId,offset:y.range.start},{paragraphId:y.range.paragraphId,offset:y.range.end});}});}return !n||!r?null:{from:n,to:r}}function ug(e,t){return (e.contentControls??[]).find(n=>n.id===t)??null}function dc(e,t){let n=t.contentControlId;if(!n){let a={x:t.caret.x,y:t.caret.y+t.caret.height/2},o=fc$1(e,t.pageIndex,a);return o?.placeholder?o:null}let r=ug(e,n);return r?.placeholder?r:null}function cc(e,t){let n=e.contentControls??[];if(n.length===0)return t;let r=ft(e,t.anchor,t.head)<=0?t.anchor:t.head,a=ft(e,t.anchor,t.head)<=0?t.head:t.anchor,o=true;for(;o;){o=false;for(let l of n){if(!l.placeholder)continue;let d=di(e,l);!d||!(ft(e,r,a)===0?ft(e,r,d.from)>=0&&ft(e,r,d.to)<0:ft(e,r,d.to)<0&&ft(e,a,d.from)>0)||(ft(e,d.from,r)<0&&(r=d.from,o=true),ft(e,d.to,a)>0&&(a=d.to,o=true));}}return ft(e,t.anchor,t.head)<=0?{anchor:r,head:a}:{anchor:a,head:r}}function fc(e,t={}){if(t.mode==="native")return {dragging:()=>false,destroy:()=>{}};let{pagesLayer:n,container:r}=e,a=n.ownerDocument,o=a.defaultView,i=null,l=null,d=0,p=0,y=0,C=0,S=null;function I(R,X){if(!l){let x=n.getBoundingClientRect();l={left:x.left,top:x.top};}let h=e.scale()||1;return {x:(R-l.left)/h,y:(X-l.top)/h}}function O(R){return {scope:{kind:"headerFooter",rId:R.rId},pageIndex:R.pageIndex,kind:R.kind,partName:R.partName,variant:R.variant}}function m(R,X){let h=e.layout(),x=I(R,X),N=ac$1(h,x.y),D=h.pages[N];if(!D)return null;let Z=e.measurer();return cc$1(h,N,{x:x.x-D.contentBox.x-e.pageOffsetX(N),y:x.y-D.contentBox.y},Z?{measurer:Z}:{})}function F(R,X){let h=e.activeNote?.()??null;if(h){let ee=e.layout(),ne=ii(ee,I(R,X),e.pageOffsetX);if(!ne||ne.scopeId!==h.scopeId)return null;let ge=e.measurer();return dc$1(ee,ne.pageIndex,ne.fragments,ne.local,{...ge?{measurer:ge}:{}})}let x=e.activeHeaderFooter?.()??null;if(!x)return m(R,X);let N=e.layout(),D=I(R,X),Z=li(N,D,e.pageOffsetX);if(Z&&ni(Z.story,O(x))){let ee=e.measurer();return oi(N,Z.pageIndex,Z.story,Z.local,ee?{measurer:ee}:{})}return null}function B(R,X){let{story:h,pageIndex:x,kind:N}=R;return {rId:h.rId,pageIndex:x,kind:N,partName:h.partName,variant:h.variant,...X?{position:X}:{}}}function A(R){let X=e.measurer();return oi(e.layout(),R.pageIndex,R.story,R.local,X?{measurer:X}:{})?.position??void 0}let k=new WeakMap;function j(R,X){let h=e.activeNote?.();if(h){let Z=On(R,null,h.scopeId).indexOf(X);return Z===-1?-1:Z}let x=e.activeHeaderFooter?.();if(x){let Z=On(R,O(x)).indexOf(X);return Z===-1?-1:Z}let N=k.get(R);return N||(N=new Map(wd$1(R).map((D,Z)=>[D,Z])),k.set(R,N)),N.get(X)??-1}function P(R,X,h){let x=j(R,X.paragraphId),N=j(R,h.paragraphId);return x!==N?x<N:X.offset<h.offset}let v=/[\p{L}\p{N}_'’]/u,T=R=>R!==void 0&&v.test(R);function M(R,X,h){if(h==="character")return {from:X,to:X};let x=xd$1(R,X.paragraphId),N=X.paragraphId;if(h==="paragraph")return {from:{paragraphId:N,offset:0},to:{paragraphId:N,offset:x.length}};let D=Math.max(0,Math.min(X.offset,x.length)),Z=-1;if(T(x[D])?Z=D:D>0&&T(x[D-1])&&(Z=D-1),Z===-1){let ee=D,ne=D;for(;ee>0&&/\s/.test(x[ee-1]??"");)ee-=1;for(;ne<x.length&&/\s/.test(x[ne]??"");)ne+=1;return ee===ne&&ne<x.length&&(ne+=1),{from:{paragraphId:N,offset:ee},to:{paragraphId:N,offset:ne}}}return {from:{paragraphId:N,offset:yd$1(x,Z+1,-1)},to:{paragraphId:N,offset:yd$1(x,Z,1)}}}function G(R,X,h,x,N){let D=N?dc(R,N):null,Z=D?di(R,D)??M(R,h,x):M(R,h,x),ee=P(R,Z.from,X.from)?{anchor:X.to,head:Z.from}:{anchor:X.from,head:Z.to};return cc(R,ee)}let $=r.closest(".docx-editor__scroll-container");function L(){return r.closest(".docx-editor__scroll-container")}function z(R,X,h){if(h<R+An){let x=Math.max(0,R+An-h);return -Math.min(Po,x/An*Po)}if(h>X-An){let x=Math.max(0,h-(X-An));return Math.min(Po,x/An*Po)}return 0}function oe(){S!==null&&(o?.cancelAnimationFrame(S),S=null);}function re(){S=null;let R=i,X=L();if(!R||!X||!o)return;let h=X.getBoundingClientRect(),x=z(h.top,h.bottom,R.clientY);x!==0&&(X.scrollTop+=x,l=null,le(R.clientX,R.clientY),S=o.requestAnimationFrame(re));}function we(){if(S!==null||!o||!i)return;let R=L();if(!R)return;let X=R.getBoundingClientRect();z(X.top,X.bottom,i.clientY)!==0&&(S=o.requestAnimationFrame(re));}function le(R,X){let h=i;if(!h)return;let x=F(R,X);x&&(e.isReadOnlyParagraph?.(x.position.paragraphId)||Oe(h,x)||e.setSelection(G(e.layout(),h.anchorRange,x.position,h.granularity,x)));}function Oe(R,X){let h=R.anchorCell;if(!h)return false;if(!X.cell||X.cell.tableId!==h.tableId)return R.cellDragging;if(!R.cellDragging&&X.cell.cellId===h.cellId)return false;let x=Cd$2(e.layout(),h,X.cell);return x?(R.cellDragging=true,e.setCellSelection(x),true):R.cellDragging}function Ue(R){let X=Date.now(),h=X-p;return d=Math.abs(R.clientX-y)<=sc&&Math.abs(R.clientY-C)<=sc&&h>=0&&h<=dg?d+1:1,p=X,y=R.clientX,C=R.clientY,d}let xe=["character","word","paragraph"],at=R=>{if(R.button!==0)return;let X=R.target?.closest?.("[data-docx-cc-widget]");if(X){if(R.preventDefault(),R.stopPropagation(),X.hasAttribute("disabled")||X.dataset.disabledReason)return;let me=X.dataset.docxCcId,ye=X.dataset.docxCcWidget;me&&ye&&e.onContentControlWidget?.(me,ye);return}if(R.pointerType==="touch")return;i&&De(),l=null;let h=e.layout(),x=I(R.clientX,R.clientY),N=e.activeHeaderFooter?.()??null,D=e.activeNote?.()??null,Z=li(h,x,e.pageOffsetX),ee=ii(h,x,e.pageOffsetX),ne=R.target?.closest("[data-docx-hf]"),ge=!!(ne||Z),Ce=R.target,Je=Ce?.closest("[data-docx-note-ref]"),qe=Ce?.closest("[data-docx-note-mark-back]"),Be=null,Ae=()=>Be??=Ue(R);if(Je?.dataset.docxNoteScope){R.preventDefault(),e.focus(),e.enterNote?.(Je.dataset.docxNoteScope);return}if(qe){R.preventDefault(),e.focus(),e.exitNote?.(true);return}if(ee&&!ge){let me=e.measurer?.(),ye=dc$1(h,ee.pageIndex,ee.fragments,ee.local,{...me?{measurer:me}:{}});if(!D||D.scopeId!==ee.scopeId){R.preventDefault(),e.focus(),e.enterNote?.(ee.scopeId,ye?{paragraphId:ye.position.paragraphId,offset:ye.position.offset}:void 0,ee.pageIndex);return}if(D.pageIndex!==ee.pageIndex){R.preventDefault(),e.focus(),e.enterNote?.(ee.scopeId,ye?{paragraphId:ye.position.paragraphId,offset:ye.position.offset}:void 0,ee.pageIndex);return}}else if(D){if(!ri(h,x,e.pageOffsetX))return;e.exitNote?.(false),e.focus();}if(N)if(Z&&ni(Z.story,O(N)))Z.pageIndex!==N.pageIndex&&e.enterHeaderFooter?.(B(Z,A(Z)));else if(Z&&Z.story.rId){R.preventDefault(),e.focus(),e.enterHeaderFooter?.(B(Z,A(Z)));return}else if(ri(h,x,e.pageOffsetX)){R.preventDefault(),e.exitHeaderFooter?.(true),e.focus();return}else {let me=Ae()>=2?si(h,x,e.pageOffsetX):null;me&&(R.preventDefault(),e.focus(),e.enterEmptyHeaderFooter?.(me.kind,me.pageIndex));return}else if(ge&&Ae()>=2){if(Z?.story.rId)R.preventDefault(),e.focus(),e.enterHeaderFooter?.(B(Z,A(Z)));else if(ne instanceof HTMLElement){let me=ne.dataset.docxRId,ye=ne.dataset.docxHf,Y=ne.closest("[data-page-index]")?.getAttribute("data-page-index"),bt=Y!=null?Number(Y):NaN;if((ye==="header"||ye==="footer")&&Number.isInteger(bt))if(me){let $t=h.pages[bt]?.[ye];R.preventDefault(),e.focus(),e.enterHeaderFooter?.({rId:me,pageIndex:bt,kind:ye,partName:$t?.partName??"",variant:$t?.variant??"default"});}else h.pages[bt]?.[ye]||(R.preventDefault(),e.focus(),e.enterEmptyHeaderFooter?.(ye,bt));}return}else if(Ae()>=2){let me=si(h,x,e.pageOffsetX);if(me){R.preventDefault(),e.focus(),e.enterEmptyHeaderFooter?.(me.kind,me.pageIndex);return}}let Ie=F(R.clientX,R.clientY);if(!Ie)return;if(e.isReadOnlyParagraph?.(Ie.position.paragraphId)){R.preventDefault();return}R.preventDefault(),e.focus();try{n.setPointerCapture(R.pointerId);}catch{}a.addEventListener("pointermove",Ne),a.addEventListener("pointerup",Xe),a.addEventListener("pointercancel",Xe);let Mn=Ae(),$e=R.shiftKey?"character":xe[(Mn-1)%xe.length],it=dc(h,Ie);if(it&&!R.shiftKey){if(e.selectContentControl?.(it.id)){let ye=e.selection(),Y=P(h,ye.anchor,ye.head)||ye.anchor.paragraphId===ye.head.paragraphId&&ye.anchor.offset===ye.head.offset?{from:ye.anchor,to:ye.head}:{from:ye.head,to:ye.anchor};i={pointerId:R.pointerId,granularity:"character",anchorRange:Y,anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY};return}let me=di(h,it);if(me){i={pointerId:R.pointerId,granularity:"character",anchorRange:me,anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY},Le(()=>e.setSelection({anchor:me.from,head:me.to}));return}}if(R.shiftKey){let me=e.selection();i={pointerId:R.pointerId,granularity:$e,anchorRange:{from:me.anchor,to:me.anchor},anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY},Le(()=>e.setSelection(G(h,{from:me.anchor,to:me.anchor},Ie.position,$e,Ie)));}else {let me=M(h,Ie.position,$e);i={pointerId:R.pointerId,granularity:$e,anchorRange:me,anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY},Le(()=>e.setSelection(cc(h,{anchor:me.from,head:me.to})));}};function Le(R){try{R();}catch(X){throw De(),X}}let Ne=R=>{let X=i;!X||R.pointerId!==X.pointerId||(R.preventDefault(),X.clientX=R.clientX,X.clientY=R.clientY,le(R.clientX,R.clientY),we());},Xe=R=>{let X=i;if(!X||R.pointerId!==X.pointerId)return;De();try{n.releasePointerCapture(X.pointerId);}catch{}let h=e.cellSelection();h?e.setCellSelection(h):e.setSelection(e.selection());};function De(){if(i)try{n.releasePointerCapture(i.pointerId);}catch{}i=null,l=null,oe(),a.removeEventListener("pointermove",Ne),a.removeEventListener("pointerup",Xe),a.removeEventListener("pointercancel",Xe);}let pe=()=>{l=null;};return n.addEventListener("pointerdown",at),$?.addEventListener("scroll",pe,{passive:true}),o?.addEventListener("scroll",pe,{capture:true,passive:true}),o?.addEventListener("resize",pe,{passive:true}),{dragging:()=>i!==null,destroy(){De(),n.removeEventListener("pointerdown",at),$?.removeEventListener("scroll",pe),o?.removeEventListener("scroll",pe,{capture:true}),o?.removeEventListener("resize",pe);}}}var hc=/^[^\s]{1,512}$/;function wo(e){let t=e.dataset?.paragraphId,n=e.dataset?.start;return !t||n===void 0||!/^\d{1,9}$/.test(n)||!hc.test(t)||t==="__proto__"?null:{paragraphId:t,start:Number(n)}}function yc(e){let t=e.nodeType===Node.TEXT_NODE?e.parentNode:e;for(;t&&t.nodeType===Node.ELEMENT_NODE;){let n=wo(t);if(n)return {element:t,identity:n};t=t.parentNode;}return null}function vc(e){return e.querySelector("[data-docx-hf-active]")}function fg(e){let t=vc(e);return t?[t,e]:[e]}function pc(e,t){let n=yc(e);if(n)return n;if(e.nodeType!==Node.ELEMENT_NODE)return null;let r=e.querySelectorAll("[data-paragraph-id][data-start]"),a=t?[...r].reverse():[...r];for(let o of a){let i=wo(o);if(i)return {element:o,identity:i}}return null}function pg(e,t){let n=[...e.childNodes];if(n.length===0)return null;for(let r=Math.max(0,t);r<n.length;r+=1){let a=pc(n[r],false);if(a)return {paragraphId:a.identity.paragraphId,offset:a.identity.start}}for(let r=Math.min(t,n.length)-1;r>=0;r-=1){let a=pc(n[r],true);if(a)return {paragraphId:a.identity.paragraphId,offset:a.identity.start+(a.element.textContent?.length??0)}}return null}function gc(e,t,n){if(!n.contains(e))return null;let r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;if(r?.closest("[data-docx-field]"))return null;let a=r?.closest("[data-docx-hf]");if(a&&!a.hasAttribute("data-docx-hf-active")||vc(n)&&r?.closest(".docx-page-content"))return null;let o=r?.closest("[data-docx-marker]");if(o)return o.parentElement?xc(o.parentElement):null;if(r?.closest("[data-docx-tab-leader]"))return null;if(e.nodeType===Node.ELEMENT_NODE){let p=e,y=wo(p);if(y){let S=p.textContent?.length??0;return {paragraphId:y.paragraphId,offset:y.start+(t>0?S:0)}}let C=pg(p,t);return C||yg(p)}let i=yc(e);if(!i)return null;let l=t,d=i.element.textContent?.length??0;return {paragraphId:i.identity.paragraphId,offset:i.identity.start+Math.max(0,Math.min(l,d))}}function Co(e,t){if(!t||t.rangeCount===0)return null;let{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=t;if(!n||!a)return null;let i=gc(n,r,e),l=gc(a,o,e);if(!i||!l){let d=i??l;return d?{anchor:d,head:d}:null}return {anchor:i,head:l}}function bc(e,t){if(!t||t.rangeCount===0)return false;let{anchorNode:n,focusNode:r}=t;return !!n&&e.contains(n)||!!r&&e.contains(r)}function mc(e,t){for(let n of fg(e)){let r=gg(n,t);if(r)return r}return null}function gg(e,t){let n=e.querySelectorAll("[data-paragraph-id][data-start]"),r=null,a=null;for(let o of n){let i=wo(o);if(!i||i.paragraphId!==t.paragraphId)continue;let l=mg(o),d=o.textContent?.length??0,p=i.start+d;if(l&&t.offset>=i.start&&t.offset<=p){let y={node:l,offset:t.offset-i.start};if(t.offset<p)return y;r=y;}}return r||(a=hg(e,t.paragraphId),a?{node:a,offset:0}:null)}function mg(e){let t=e.firstChild;for(;t&&t.nodeType===Node.ELEMENT_NODE;)t=t.firstChild;return t&&t.nodeType===Node.TEXT_NODE?t:null}function hg(e,t){let n=null;for(let r of e.querySelectorAll("[data-paragraph-id]"))if(r.dataset?.paragraphId===t&&r.dataset?.start===void 0){if(r.dataset?.lineId!==void 0)return r;n??=r;}return n}function xc(e){let t=e.closest("[data-paragraph-id]");if(!t||t.dataset.start!==void 0)return null;let n=t.dataset.paragraphId;return !n||!hc.test(n)||n==="__proto__"?null:{paragraphId:n,offset:0}}function yg(e){let t=xc(e);return !t||e.closest("[data-paragraph-id]").querySelector("[data-paragraph-id][data-start]")?null:t}function Ic(e,t,n){if(!n)return false;let r=mc(e,t.anchor),a=mc(e,t.head);if(!r||!a)return false;let o=Co(e,n);if(o&&Sr(o,t))return true;try{return n.setBaseAndExtent(r.node,r.offset,a.node,a.offset),!0}catch{return false}}function Sr(e,t){return e.anchor.paragraphId===t.anchor.paragraphId&&e.anchor.offset===t.anchor.offset&&e.head.paragraphId===t.head.paragraphId&&e.head.offset===t.head.offset}function Sc(e){let{document:t,pagesLayer:n,session:r}=e,a=false,o=false,i=false,l=null;function d(){let S=Co(n,t.getSelection());return !S||Sr(S,e.selection())?false:(e.adoptSelection(S),true)}function p(){let S=t.activeElement;if(S&&n.contains(S))return true;let I=t.getSelection();if(!I||I.rangeCount===0)return true;let O=I.anchorNode;return !O||!O.isConnected?true:n.contains(O)}let y=()=>{let S=t.getSelection(),I=Co(n,S);if(!I){if(!bc(n,S))return;let O=Fe(e.selection().head);if(Sr(O,e.selection()))return;e.setSelection(O);return}Sr(I,e.selection())||e.setSelection(I);};function C(S){let I=kd(n,S);if(I===null)return;let O=Td(S,e.textOf(S),I);if(!O)return;let m=O.ops.find(A=>A.op==="insertText"),F=m?e.pendingFormatOps?.(S,m.offset,m.text.length)??[]:[],B=e.storyScope();e.commit(()=>{let A=r.applyTreeOps([...O.ops,...F],e.selectionMark(),void 0,B);return F.length===0||!A.rejected?A:r.applyTreeOps(O.ops,e.selectionMark(),void 0,B)}),e.setSelection(Fe({paragraphId:S,offset:O.caret}));}return {adoptBeforePaint(){let S=e.holdsCellSelection?.()===true||e.isGesturing?.()===true,I=o||S?false:d();return o=false,I},noteModelMoved(){o=true;},noteSelectionSettled(){o=false;},mirrorToDom(S=false){if(e.updateCaret(),!S&&!p())return;a=true;let I=e.now();Ic(n,e.domSelection?.()??e.selection(),t.getSelection()),e.recordSelectionMs(e.now()-I),queueMicrotask(()=>{a=false;});},isComposing:()=>i,onSelectionChange:()=>{a||i||e.isGesturing?.()||e.holdsCellSelection?.()||y();},onCompositionStart:()=>{i=true,l=e.selection().head.paragraphId,r.beginComposition(e.storyScope());},onCompositionEnd:()=>{i=false;let S=l??e.selection().head.paragraphId;l=null,C(S),r.endComposition(),e.flushLayout(),e.render();}}}function vg(e,t){let n={...e??{}};return e?.start!==void 0&&(n.start=t),(e?.start===void 0||e.left!==void 0)&&(n.left=t),n}function kc(e,t,n,r){let a={...e};if(r===null)return delete a[t],delete a[n],a;let o=String(r),i=e[n]!==void 0;return i&&(a[n]=o),(!i||e[t]!==void 0)&&(a[t]=o),a}function bg(e,t){let n={...e};return t===null?(delete n.firstLine,delete n.hanging,n):(t>=0?(n.firstLine=String(t),n.hanging="0"):(n.hanging=String(-t),n.firstLine="0"),n)}function Tc(e){let{session:t,commit:n,orderedStart:r,orderedRange:a,selectionMark:o,collapsedAt:i}=e,l=e.deleteSelectionPlan,d=()=>t.partFor(e.storyScope())??t.part(),p=(P,v,T)=>t.applyTreeOps(P,v,T,e.storyScope()),y=()=>e.paragraphOrder(),C={get value(){return e.layout()}},S=720,I=8;function O(P){return m(P)?.level??null}function m(P){for(let v of C.value.pages)for(let T of R(v))if(T.paragraphId===P)return T.marker??null;return null}function F(P){let v=m(P);return v?v.numFmt==="bullet"?"bullet":"ordered":null}function B(P,v){let T=y(),M=T.indexOf(P[0]??""),G=T.indexOf(P[P.length-1]??"");if(M===-1||G===-1)return null;for(let $ of [M-1,G+1]){let L=T[$];if(!L)continue;let z=m(L);if(z&&(z.numFmt==="bullet"?"bullet":"ordered")===v)return z.numId}return null}function A(P,v){return v<0||v>I?false:e.numberingLevelExists(P.numId,v)}function k(P,v){return v<0||v>I?false:e.numberingLevelExists(P.numId,v)?true:t.ensureNumberingLevel(P.numId,v,P.numFmt==="bullet"?"bullet":"ordered")&&e.numberingLevelExists(P.numId,v)}function j(P){let v=P.find(M=>M.localName==="ind"),T=v?.attributes?.left??v?.attributes?.start;return !T||!/^-?\d{1,7}$/.test(T)?0:Number(T)}return {insertTab(){let P=l(),v=P.collapseTo;n(()=>p([...P.ops,{op:"insertTab",paragraphId:v.paragraphId,offset:v.offset}],o()),()=>i({...v,offset:v.offset+1}));},insertLineBreak(){let P=l(),v=P.collapseTo;n(()=>p([...P.ops,{op:"insertHardBreak",paragraphId:v.paragraphId,offset:v.offset}],o()),()=>i({...v,offset:v.offset+1}));},insertPageBreak(){let P=l(),v=P.collapseTo;n(()=>p([...P.ops,{op:"insertPageBreak",paragraphId:v.paragraphId,offset:v.offset}],o()),()=>i({...v,offset:v.offset+1}));},exitListOnEmptyItem(){let{from:P,to:v}=a();if(P.paragraphId!==v.paragraphId||P.offset!==v.offset)return false;let T=m(P.paragraphId);if(!T||e.paragraphTextOf(P.paragraphId).length>0)return false;let $=T.level>0&&A(T,T.level-1)?{op:"setListLevel",paragraphId:P.paragraphId,level:T.level-1}:{op:"setListNumbering",paragraphId:P.paragraphId,numId:null},L=false;return n(()=>{let z=p([$],o());return L=z.committed,z}),L},isListParagraph(){let{paragraphId:P}=r();return O(P)!==null},isListActive(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=P==="bullet"?"bullet":"ordered",z=M.slice(G,$+1);return z.length>0&&z.every(oe=>F(oe)===L)},toggleList(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=M.slice(G,$+1);if(L.length===0)return false;let z=L.every(le=>F(le)===P),oe=z?null:B(L,P)??t.ensureListDefinition(P);if(!z&&oe===null)return false;let re=L.map(le=>({op:"setListNumbering",paragraphId:le,numId:oe})),we=false;return n(()=>{let le=p(re,o());return we=le.committed,le}),we},canAdjustIndent(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=P==="increase"?1:-1;return M.slice(G,$+1).some(z=>{let oe=m(z);if(oe){let we=oe.level+L;return we>=0&&we<=I}let re=j(Io(C.value,z));return Math.max(0,re+L*S)!==re})},adjustIndent(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=P==="increase"?1:-1,z=[];for(let re of M.slice(G,$+1)){let we=Io(C.value,re),le=m(re),Oe=le?.level??null;if(le&&Oe!==null){let Ne=Oe+L;if(Ne<0||Ne>I||!k(le,Ne))continue;z.push({op:"setListLevel",paragraphId:re,level:Ne});continue}let Ue=j(we),xe=Math.max(0,Ue+L*S);if(xe===Ue)continue;let at=Sf$1(d(),re),Le=at.find(Ne=>Ne.localName==="ind");z.push({op:"setParagraphProperties",paragraphId:re,properties:Uf$1(at,{localName:"ind",attributes:vg(Le?.attributes,String(xe))})});}if(z.length===0)return false;let oe=false;return n(()=>{let re=p(z,o());return oe=re.committed,re}),oe},setIndent(P){if(P.left===void 0&&P.right===void 0&&P.firstLine===void 0)return false;let{from:v,to:T}=a(),M=wd$1(C.value),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=[];for(let oe of M.slice(G,$+1)){let re=Sf$1(t.part(),oe),le={...re.find(Oe=>Oe.localName==="ind")?.attributes??{}};P.left!==void 0&&(le=kc(le,"left","start",P.left)),P.right!==void 0&&(le=kc(le,"right","end",P.right)),P.firstLine!==void 0&&(le=bg(le,P.firstLine)),L.push({op:"setParagraphProperties",paragraphId:oe,properties:Uf$1(re,{localName:"ind",...Object.keys(le).length>0?{attributes:le}:{}})});}if(L.length===0)return false;let z=false;return n(()=>{let oe=t.applyTreeOps(L,o());return z=oe.committed,oe}),z},sectionProperties:()=>Cc$1(t.part()),sectionPropertiesAt(P){let v=Dc$1(t.part());if(v.length===1)return v[0].properties;let T=rc$1(t.part()),M=(L,z)=>{if(L.id===z)return true;for(let oe of L.children)if(oe.kind!=="textValue"&&M(oe,z))return true;return false},G=T.findIndex(L=>L.id===P||M(L,P)),$=v[v.length-1];if(G!==-1)for(let L of v)if(L.blockStart<=G)$=L;else break;return $.properties},setSectionProperties(P){let v=false;return n(()=>{let T=t.applyTreeOps([{op:"setSectionProperties",...P}],o(),void 0,{kind:"body"});return v=T.committed,T}),v},insertSectionBreak(){if(e.storyScope().kind!=="body")return false;let P=l(),v=P.collapseTo,T=new Set(t.paragraphIds()),M=false;return n(()=>{let G=t.applyTreeOps([...P.ops,{op:"splitParagraph",paragraphId:v.paragraphId,offset:v.offset},{op:"setSectionMark",paragraphId:v.paragraphId}],o(),void 0,{kind:"body"});return M=G.committed,G},()=>{let G=t.paragraphIds().find($=>!T.has($));return G?i({paragraphId:G,offset:0}):null}),M}}}var wc=32;function ui(e){return e.kind!=="textValue"&&e.kind==="contentControl"}function fi(e){return e.kind!=="textValue"&&e.kind==="contentControlContent"}function cn(e){return e.kind==="textValue"?[]:e.children}function ci(e,t=0){return e.kind==="run"?[e]:e.kind==="hyperlink"?e.children.flatMap(n=>ci(n,t)):ui(e)?t>=wc?[]:cn(e).filter(n=>fi(n)).flatMap(n=>cn(n).flatMap(r=>ci(r,t+1))):[]}function Ro(e){if(e.kind==="textValue")return e.value.length;if(e.kind==="tab"||e.kind==="hardBreak")return 1;if(e.kind==="runProperties"||e.kind==="generic")return 0;if(ui(e)){let n=0;for(let r of cn(e))if(fi(r))for(let a of cn(r))n+=Ro(a);return n}let t=0;for(let n of cn(e))t+=Ro(n);return t}function Cc(e,t,n){for(let r of e){if(r.kind==="hyperlink"){n(r);continue}if(ui(r)){if(t>=wc)continue;for(let a of cn(r))fi(a)&&Cc(cn(a),t+1,n);continue}n(r);}}function xg(e,t,n,r){let a=Ig(e,t);if(!a||a.kind!=="paragraph")return [];let o=r(t),i=[],l=0;return Cc(a.children,0,d=>{if(d.kind==="run"){l+=Ro(d);return}if(d.kind!=="hyperlink")return;let p=l;for(let C of ci(d))l+=Ro(C);let y=Ta$1(d,n);i.push({id:d.id,paragraphId:t,start:p,end:l,text:o.slice(p,l),kind:y.kind,href:y.href,authored:y.authored,...y.anchor!==void 0?{anchor:y.anchor}:{},...y.tooltip!==void 0?{tooltip:y.tooltip}:{}});}),i}function Ig(e,t){let n=r=>{if(r.kind==="textValue")return r.id===t?r:null;if(r.id===t)return r;for(let a of r.children){let o=n(a);if(o)return o}return null};return n(e.root)}function Sg(e,t){for(let n of e)if(n.paragraphId===t.paragraphId&&t.offset>=n.start&&t.offset<=n.end)return n;return null}function Rc(e){let t=()=>e.storyScope(),n=()=>e.session.partFor(t()),r=d=>e.session.relationshipTarget(d,t()),a=(d,p,y)=>e.session.applyTreeOps(d,p,y,t()),o=d=>{let p=n();return p?xg(p,d,r,e.textOf):[]},i=()=>Sg(o(e.selection().head.paragraphId),e.selection().head),l=d=>{let p=e.selection().head.paragraphId,y=o(p).find(C=>C.id===d);if(y)return y;for(let C of e.session.paragraphIdsIn(t())){let S=o(C).find(I=>I.id===d);if(S)return S}return null};return {linksInCaretParagraph:()=>o(e.selection().head.paragraphId),linkAtCaret:i,linkById:l,applyHyperlink(d){let p=d.url!==void 0&&d.url.length>0,y=d.anchor!==void 0&&d.anchor.length>0;if(p===y)return false;let C=t();if(!n()||e.refusesWrite())return false;let S;if(p){let M=e.session.ensureHyperlinkRelationship(d.url,C);if(!M)return false;S=M;}let I={...S!==void 0?{relationshipId:S}:{},...y?{anchor:d.anchor}:{},...d.tooltip!==void 0?{tooltip:d.tooltip}:{}},O=i(),m=e.orderedRange(),F=m.from.paragraphId===m.to.paragraphId&&m.from.offset===m.to.offset;if(O&&(F||Tg(O,m))){let M=[{op:"setHyperlinkTarget",linkId:O.id,...I}];if(d.text!==void 0&&d.text!==O.text){let $=Pc(O.paragraphId,O.start,O.end,d.text);if(!$)return false;M.push(...$);}let G=false;return e.commit(()=>{let $=a(M,e.selectionMark());return G=$.committed,$},()=>null),G}let B=m.from.paragraphId;if(m.to.paragraphId!==B)return false;let A=[],k=m.from.offset,j=m.to.offset;if(F){let M=d.text??d.url??d.anchor??"";if(M.length===0)return false;A.push({op:"insertText",paragraphId:B,offset:k,text:M}),j=k+M.length;}else if(d.text!==void 0&&d.text!==e.textOf(B).slice(k,j)){let M=Pc(B,k,j,d.text);if(!M)return false;A.push(...M),j=k+d.text.length;}if(j<=k)return false;let P=kg(e.session);A.push({op:"insertHyperlink",paragraphId:B,start:k,end:j,...I,...P?{styleId:P}:{}});let v=false,T={paragraphId:B,offset:j};return e.commit(()=>{let M=a(A,e.selectionMark(),{paragraphId:B,start:j,end:j});return v=M.committed,M},()=>({anchor:T,head:T})),v},removeHyperlink(d){if(!n())return false;let p=d?l(d):i();if(!p)return false;let y=false,C={paragraphId:p.paragraphId,offset:p.end};return e.commit(()=>{let S=a([{op:"removeHyperlink",linkId:p.id}],e.selectionMark());return y=S.committed,S},()=>({anchor:C,head:C})),y}}}function kg(e){for(let t of e.documentStyles())if(t.type==="character"&&t.styleId.toLowerCase()==="hyperlink")return t.styleId;return null}function Tg(e,t){return t.from.paragraphId===e.paragraphId&&t.to.paragraphId===e.paragraphId&&t.from.offset>=e.start&&t.to.offset<=e.end}function Pc(e,t,n,r){if(r.length===0)return null;let a=[{op:"insertText",paragraphId:e,offset:t,text:r,bias:"right"}];return n>t&&a.push({op:"deleteText",paragraphId:e,start:t+r.length,end:n+r.length}),a}var Pg=24;function Ec(e){let{pagesLayer:t}=e,n=t.ownerDocument.defaultView;function r(){return e.container.closest(".docx-editor__scroll-container")}let a=S=>{if(!S||S.length===0||S.startsWith("#"))return false;let I=U(S);return !I.ok||!I.href||!n?false:(n.open(I.href,"_blank","noopener,noreferrer"),true)},o=S=>{let I=e.layout(),O=qd$1(I,S);if(!O)return false;let m=I.pages[O.pageIndex];if(!m)return false;let F=m.box.y+(m.contentBox.y-m.box.y)+O.y,B=r();return B&&(B.scrollTop=Math.max(0,F*e.scale()-Pg),e.onScrolled?.()),e.setSelection(S),true},i=S=>{let I=e.bookmarks().get(S);return I?o(I):false},l=null;function d(S){if(!S||S.closest("[data-docx-hf]"))return null;let I=S.closest("a.docx-hyperlink");if(I){let m=I.dataset.docxLink;return m?{linkId:m,drawing:false}:null}let O=S.closest("[data-docx-drawing-link]");if(O){let m=O.dataset.docxDrawingLink;return m?{linkId:m,drawing:true}:null}return null}let p=S=>{l=null;let I=S.target,O=d(I);if(!O)return;let F=I.closest("[data-docx-drawing-link], a.docx-hyperlink").getBoundingClientRect();l={linkId:O.linkId,drawing:O.drawing,rect:{left:F.left,top:F.top,bottom:F.bottom,right:F.right}};},y=S=>{let I=S.target,O=d(I);if(!O){let B=l;if(l=null,!B)return;S.preventDefault(),C(B.linkId,B.rect,S,B.drawing);return}l=null,S.preventDefault();let F=I.closest("[data-docx-drawing-link], a.docx-hyperlink").getBoundingClientRect();C(O.linkId,{left:F.left,top:F.top,bottom:F.bottom,right:F.right},S,O.drawing);};function C(S,I,O,m){let F=m?e.drawingLinkById?.(S)??null:e.linkById(S);if(!F)return;if(O.metaKey||O.ctrlKey){F.kind==="external"?a(F.href):F.anchor&&i(F.anchor);return}if(e.isCollapsedSelection()){if(F.kind==="internal"){F.anchor&&i(F.anchor);return}e.onPopover?.({link:F,rect:I});}}return t.addEventListener("pointerdown",p,true),t.addEventListener("click",y),{goToPosition:o,goToBookmark:i,openExternal:a,destroy(){t.removeEventListener("pointerdown",p,true),t.removeEventListener("click",y);}}}function wg(e){let t=e.hyperlinkHref;if(!t)return null;let n=e.kind==="anchoredDrawing"?e.anchorParagraphId:e.paragraphId,r=e.kind==="inlineDrawing"?e.start:0,a=t.startsWith("#")?"internal":"external";return Object.freeze({id:e.drawingNodeId,paragraphId:n,start:r,end:r+1,text:"",kind:a,href:t,authored:t,...a==="internal"?{anchor:t.slice(1)}:{}})}function pi(e,t){return e.drawingNodeId!==t?null:wg(e)}function Fc(e,t){if(!e)return null;for(let n of e.anchoredDrawings??[]){let r=pi(n,t);if(r)return r}return null}function Cg(e,t){for(let r of e.anchoredDrawings??[]){let a=pi(r,t);if(a)return a}for(let r of e.fragments){if(r.kind==="table"){for(let o of r.rows)for(let i of o.cells)for(let l of i.blocks){let d=Ac(l,t);if(d)return d}continue}let a=Oc(r,t);if(a)return a}let n=Fc(e.header,t);return n||Fc(e.footer,t)}function Oc(e,t){for(let n of e.lines)for(let r of n.drawings??[]){let a=pi(r,t);if(a)return a}return null}function Ac(e,t){if(e.kind==="table"){for(let n of e.rows)for(let r of n.cells)for(let a of r.blocks){let o=Ac(a,t);if(o)return o}return null}return Oc(e,t)}function Mc(e,t){for(let n of e.pages){let r=Cg(n,t);if(r)return r}return null}function Hc(e){return {applyHeaderFooterLifecycle(t){let n=null;return e.commit(()=>{let r=e.applyOps([t]);return r.rejected&&(n=String(r.reason??"rejected")),r}),n?{ok:false,reason:n}:{ok:true}},insertPageField(t){if(!e.isHeaderFooterOpen())return false;let n=e.orderedStart();return e.commit(()=>e.applyOps([...e.deleteSelectionOps(),{op:"insertPageField",paragraphId:n.paragraphId,offset:n.offset,field:t}],e.selectionMark()),()=>e.collapsedAt({paragraphId:n.paragraphId,offset:n.offset+(t==="PAGE_X_OF_Y"?6:1)})),e.lastRejection()===null}}}var kr="the document is open for viewing",Eo="image property edits are not supported in suggesting mode",Rg="trackedDrawingDeletionUnsupported";function Lc(e){function t(){return {committed:false,rejected:true,opCount:0,reason:kr}}function n(){return {committed:false,rejected:true,opCount:0,reason:Eo}}return {applyDrawingOps(r){if(e.editingMode()==="view")return t();if(e.editingMode()==="suggest")return n();let a=e.selectionMark();return e.applyOps(r,a,a)},applyImageProperties(r){if(e.editingMode()==="view")return {ok:false,reason:"invalidArgs",detail:kr};if(e.editingMode()==="suggest")return {ok:false,reason:"invalidArgs",detail:Eo};let a={ok:false,reason:"invalidArgs"};return e.commit(()=>(a=e.session.applyImageProperties(e.storyScope(),r),{committed:a.ok,rejected:!a.ok,opCount:a.ok?1:0,...a.ok?{}:{reason:a.detail??a.reason}})),a},deleteImage(r){if(e.editingMode()==="view")return {ok:false,reason:"invalidArgs",detail:kr};if(e.editingMode()==="suggest")return {ok:false,reason:"invalidArgs",detail:Rg};let a={ok:false,reason:"invalidArgs"};return e.commit(()=>(a=e.session.deleteImage(e.storyScope(),r),{committed:a.ok,rejected:!a.ok,opCount:a.ok?1:0,...a.ok?{}:{reason:a.detail??a.reason}})),a},insertImage(r){return e.editingMode()==="view"?Promise.resolve({ok:false,reason:"invalidArgs",detail:kr}):e.editingMode()==="suggest"?Promise.resolve({ok:false,reason:"invalidArgs",detail:Eo}):e.session.insertImage(e.storyScope(),{...r,decodePort:e.decodePort()})},replaceImage(r,a,o,i){return e.editingMode()==="view"?Promise.resolve({ok:false,reason:"invalidArgs",detail:kr}):e.editingMode()==="suggest"?Promise.resolve({ok:false,reason:"invalidArgs",detail:Eo}):e.session.replaceImage(e.storyScope(),r,a,o,e.decodePort(),i)}}}function Dc(e){let t=null,n=null,r="",a=()=>{if(!t)return;let l=rc(e.layout(),t,e.materializedPages?.());l!==t.pageIndex&&(t={...t,pageIndex:l});},o=l=>{if(!l.rId||e.session.partFor({kind:"headerFooter",rId:l.rId})===null)return false;let d=e.layout(),p=ec(d,l.rId),y=t,C=y?.scope.rId===l.rId,S=p?null:Eg(e.session,l.rId);if(!p&&!S)return false;let I=l.pageIndex??(C&&y?y.pageIndex:p?.pageIndex??0),O=l.kind??(C&&y?y.kind:p?.kind??S.kind),m=l.variant??(C&&y?y.variant:p?.story.variant??S.variant),F=C&&y?y.partName:p?.story.partName??S.partName,B=d.pages[I]??d.pages[p?.pageIndex??0],A=(B?Fn(B,{scope:{kind:"headerFooter",rId:l.rId},kind:O,partName:F}):null)??p?.story??{scope:{rId:l.rId},variant:m,partName:F},k=e.selection(),j=y?y.savedBodySelection:{anchor:{...k.anchor},head:{...k.head}},P=l.sectionIndex??(C&&y?.sectionIndex!==void 0?y.sectionIndex:S?.sectionIndex);t={scope:{kind:"headerFooter",rId:l.rId},pageIndex:I,...P!==void 0?{sectionIndex:P}:{},kind:O,variant:A.variant,partName:A.partName,savedBodySelection:j};let T=e.session.paragraphIdsIn(ko(t))[0];if(!T)return t=null,false;let M=l.position?To(d,{anchor:l.position,head:l.position},t):C?To(d,k,t):{anchor:{paragraphId:T,offset:0},head:{paragraphId:T,offset:0}};return e.setScopeSelection(M),e.noteModelMoved(),e.render(),e.mirrorToDom(),e.notify(),true},i=()=>{if(!t)return;let l=t.savedBodySelection;t=null,e.setScopeSelection(To(e.layout(),l,null)),e.noteModelMoved(),e.render(),e.mirrorToDom(),e.notify();};return {getActive:()=>t,activeScope:()=>Jd(t),setActiveScope(l){return l.kind==="body"?(i(),true):l.kind==="headerFooter"?o({rId:l.rId}):false},enterHeaderFooter:o,exitHeaderFooter:i,reconcileOccurrence:a,headerFooterState(){if(!t)return null;let l=e.session.headerFooterResolutionBySection(),d=t.sectionIndex??0,p,y,C,S=B=>{let A=l[B];if(!A)return false;let j=(t.kind==="header"?A.headers:A.footers).get(t.variant);return !j||j.rId!==t.scope.rId?false:(d=B,p=j.inherited,y=A.titlePage,C=A.evenAndOddHeaders,true)};if(!(t.sectionIndex!==void 0&&S(t.sectionIndex))){let B;l.forEach((A,k)=>{let P=(t.kind==="header"?A.headers:A.footers).get(t.variant);!P||P.rId!==t.scope.rId||!(B===void 0||B&&!P.inherited||B===P.inherited&&k<d)||(d=k,p=P.inherited,y=A.titlePage,C=A.evenAndOddHeaders,B=P.inherited);});}let I=Dc$1(e.session.part()),O=I[d]?.properties??I.at(-1)?.properties,m=O?.margins.headerTwips,F=O?.margins.footerTwips;return {editing:t.kind,sectionIndex:d,variant:t.variant,rId:t.scope.rId,partName:t.partName,...p!==void 0?{inherited:p}:{},...y!==void 0?{titlePage:y}:{},...C!==void 0?{evenAndOddHeaders:C}:{},...m!==void 0?{headerDistanceTwips:m}:{},...F!==void 0?{footerDistanceTwips:F}:{}}},headerFooterStateStable(l){if(!t)return n=null,r="",null;let d=this.headerFooterState();if(!d)return null;let p=[l,d.editing,d.sectionIndex,d.variant??"",d.rId??"",d.partName??"",String(d.inherited),String(d.titlePage),String(d.evenAndOddHeaders),String(d.headerDistanceTwips??""),String(d.footerDistanceTwips??"")].join("|");return n&&r===p||(n=Object.freeze({...d}),r=p),n}}}function Eg(e,t){let n=e.headerFooterResolutionBySection();for(let r=0;r<n.length;r+=1){let a=n[r];for(let o of ["header","footer"]){let i=o==="header"?a.headers:a.footers;for(let[l,d]of i)if(d.rId===t)return {sectionIndex:r,kind:o,variant:l,partName:d.partName}}}return null}function _c(e){let t=null,n=null,r=null,a=i=>(e.setLastRejection(null),e.commit(()=>{let l=e.applyOps([i],e.selectionMark());return l.rejected&&e.setLastRejection(String(l.reason??"rejected")),l}),e.lastRejection()===null),o=(i,l,d)=>{let p=_c$1(i);if(!p)return e.setLastRejection("invalid note scope id"),false;let y=e.session.currentPackage(),C=Rd$1(y,p.noteKind),S=C?td$2(C.root,p.noteId):null;if(!C||!S)return e.setLastRejection("note not found"),false;if(e.activeScope().kind==="body"){let I=e.selection();r={anchor:{paragraphId:I.anchor.paragraphId,offset:I.anchor.offset},head:{paragraphId:I.head.paragraphId,offset:I.head.offset}};}if(t={kind:"note",id:Zc$1(p.noteKind,p.noteId)},n=Number.isInteger(d)?d:null,l)e.setSelection({anchor:l,head:l});else {let I=Fg(S),O=new Set(e.session.paragraphIdsIn({kind:"notesPart",noteKind:p.noteKind})),m=I.find(F=>O.has(F.id));if(m){let F=Og(m);e.setSelection({anchor:{paragraphId:m.id,offset:F},head:{paragraphId:m.id,offset:F}});}}return e.noteModelMoved(),e.render(),n??=e.revealNote(t.id),e.notify(),true};return {insertNote(i){if(e.activeScope().kind!=="body")return e.setLastRejection("insertNote requires body scope"),false;let l=e.orderedStart(),d=Nc(e.session.currentPackage(),i);if(!a({op:"insertNote",noteKind:i,paragraphId:l.paragraphId,offset:l.offset}))return false;let C=[...Nc(e.session.currentPackage(),i)].find(S=>!d.has(S));return C===void 0?true:o(Zc$1(i,C))},deleteNote(i,l){return a({op:"deleteNote",noteKind:i,noteId:l})},convertNote(i,l){return a({op:"convertNote",fromKind:i,noteId:l})},convertAllNotes(i){return a({op:"convertAllNotes",fromKind:i})},setNoteProperties(i){return a({op:"setNoteProperties",scope:i.scope,sectionIndex:i.sectionIndex,footnote:i.footnote,endnote:i.endnote})},enterNote:o,exitNote(i=true){if(!t)return;let l=r;t=null,n=null,r=null,e.setActiveScopeBodyOrHf({kind:"body"}),i&&l&&e.setSelection(l),e.noteModelMoved(),e.render(),e.notify();},activeNoteScope(){return t},activeNotePageIndex(){return n},setActiveNotePageIndex(i){!t||!Number.isInteger(i)||n!==i&&(n=i);}}}function Fg(e){let t=[],n=(r,a)=>{if(!(a>32)){if(r.kind==="paragraph"){t.push(r);return}if("children"in r)for(let o of r.children)n(o,a+1);}};return n(e,0),t}function Og(e){let t=Kd$1(e)[0];return t&&dd$2(t.node)?t.end:0}function Nc(e,t){let n=Rd$1(e,t),r=new Set;if(!n)return r;for(let a of sd$2(n.root)){if(!jd$2(a))continue;let o=hd$1(a);o!==null&&r.add(o);}return r}var Ag=500;function Mg(e,t){let n=e.part(),r=Dc$1(n),a=rc$1(n),o=new Map;for(let i=0;i<r.length;i+=1){let l=r[i];for(let d=l.blockStart;d<l.blockEndExclusive;d+=1){let p=a[d];if(!p)continue;if(p.kind==="paragraph"){o.set(p.id,i);continue}let y=(C,S)=>{if(!(S>32)){if(C.kind==="paragraph"&&typeof C.id=="string"){o.set(C.id,i);return}for(let I of C.children??[])y(I,S+1);}};y(p,0);}}return o.get(t)??0}function Hg(e,t){let n=e.part(),r=rc$1(n),a=[];for(let o=0;o<r.length;o+=1){let i=r[o];if(i.kind!=="paragraph")continue;let l=Bc$2(i);l&&a.push(l);}for(;a.length<t.length;)a.push(void 0);return a}function Bc(e){if(!e)return null;let t=e.session,n=e.state().selection.head.paragraphId,r=Mg(t,n),a=t.currentPackage(),o=zd$1(a),i=Ad$1(o),l=Bd$1(o),d=Dc$1(t.part()),p=Hg(t,d),y=xd$2(p[r]),C=yd$2(p[r]),S=Cd$1(y,i),I=Dd$2(C,l);return {sectionIndex:r,footnote:{resolved:S,...i?{documentAuthored:i}:{},...y?{sectionAuthored:y}:{}},endnote:{resolved:I,...l?{documentAuthored:l}:{},...C?{sectionAuthored:C}:{}}}}function Zc(e,t){let n=_c$1(t);if(!n)return null;let r=Rd$1(e.currentPackage(),n.noteKind);if(!r)return null;let a=r,o=td$2(a.root,n.noteId);if(!o)return null;let i=[],l=Ag,d=(y,C)=>{if(!(C>32||l<=0)){if(y.kind==="paragraph"&&typeof y.id=="string"){let S=(vf$1(a,y.id)??"").replace(/\uFFFC/g,"").trim();if(S){let I=S.slice(0,l);i.push(I),l-=I.length;}return}if(y.kind!=="textValue")for(let S of y.children)d(S,C+1);}};d(o,0);let p=i.filter(Boolean).join(" ").trim();return p.length>0?p:null}function qc(e,t){let n=e.setScale;return typeof n!="function"?false:n.call(e,t)}function gi(e,t,n={}){let r=n,a=j$1(t,n.reviewModel?{reviewModel:n.reviewModel}:{});if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let o=a.session,i=n.scale??96/72,l={resolve:n.tableInteractionLabel??(s=>Ka(s))},d="the document is open for viewing",p="the table of contents is generated and read-only",y="\0range\0",C=()=>`${new Date().toISOString().slice(0,19)}Z`,S=n.measurer?null:jd$1(i,{context:Rn(e.ownerDocument),...n.fontAlias?{fontAlias:n.fontAlias}:{}}),I=n.measurer??S.measurer,O=kb(),m=dd$1();function F(){return n.measurer?n.producer??"host-measurer":`${n.producer??S?.producer??"fixed-measurer"}@scale:${i}`}let B=F(),A=e.ownerDocument,k=A.createElement("div");k.className="docx-pages",k.style.position="relative",k.contentEditable="true",k.spellcheck=false,k.setAttribute("role","textbox"),k.setAttribute("aria-multiline","true"),k.style.outline="none";let j=A.createElement("div");j.className="docx-selection-overlay",j.contentEditable="false",j.setAttribute("aria-hidden","true"),j.style.position="absolute",j.style.left="0",j.style.top="0",j.style.pointerEvents="none";let P=A.createElement("div");P.className="docx-comment-overlay",P.contentEditable="false",P.setAttribute("aria-hidden","true"),P.style.position="absolute",P.style.left="0",P.style.top="0",P.style.pointerEvents="none";let v=A.createElement("div");v.className="docx-table-furniture",v.contentEditable="false",v.style.position="absolute",v.style.left="0",v.style.top="0",v.style.pointerEvents="none",e.style.position="relative",e.replaceChildren(k,v,P,j);let T=Dd(k,()=>i,()=>{let s=pe?.getActive()??null,c=R$1?.activeNoteScope()??null,u=R$1?.activeNotePageIndex()??null,g=s?tc(k,s.pageIndex):c?nc(k,c.id,u):null;return {layout:Y,selection:L,measurer:I,...s?{preferredPageIndex:s.pageIndex}:u!==null?{preferredPageIndex:u}:{},scopedHost:g,...s?{scopedHostKind:"headerFooter"}:c?{scopedHostKind:"note"}:{}}}),M=new Set(tc$1(o.part()).flatMap(s=>[s.beginParagraphId,...s.resultParagraphIds,s.endParagraphId])),G=o.paragraphIds(),$=G.find(s=>!M.has(s))??G[0]??"",L={anchor:{paragraphId:$,offset:0},head:{paragraphId:$,offset:0}},z=null,oe=null,re=false,we=false,le=null;function Oe(s,c){if(s.paragraphId===c.paragraphId)return s.offset-c.offset;let u=D();return u.indexOf(s.paragraphId)-u.indexOf(c.paragraphId)}function Ue(s){if(!le)return;let{from:c,to:u}=Ua(Y,le),g=s.head;Oe(g,c)>=0&&Oe(g,u)<=0||(le=null);}let xe=null;function at(){return Le()?.properties??null}function Le(){if(!xe)return null;let s=xe.position,c=u=>u.paragraphId===s.paragraphId&&u.offset===s.offset;return c(L.anchor)&&c(L.head)?xe:null}function Ne(s){if(!xe)return;let c=xe.position;s.anchor.paragraphId===c.paragraphId&&s.anchor.offset===c.offset&&s.head.paragraphId===c.paragraphId&&s.head.offset===c.offset||(xe=null);}function Xe(s,c,u,g){let b=He([...s],u,g);return s.length===c.length||!b.rejected?b:He([...c],u,g)}function De(s,c,u){let g=Le();if(!g||u===0)return [];let b=xe.position;return b.paragraphId!==s||b.offset!==c?[]:[{op:"setRunProperties",paragraphId:s,start:c,end:c+u,properties:g.properties.reduce((E,_)=>Uf$1(E,_),[...g.base])}]}let pe=null,R$1=null,X=null,h="",x=()=>ko(pe?.getActive()??null,R$1?.activeNoteScope()??null),N=()=>R$1?.activeNoteScope()?.id??null,D=()=>On(Y,pe?.getActive()??null,N()),Z=()=>globalThis.performance?.now()??Date.now(),ee=0,ne=0,ge=0,{styleCascade:Ce,numberingIndex:Je,defaultTabStopPt:qe}=wd(o),Be=null,Ae=n.imageDecodePort??Md(A)??Hd(),Ie=tc$2({session:o,decodePort:Ae,onResourcesChanged:()=>Be?.()}),Mn=n.drawingStrings??b$1,$e=Ld({mintValidatedBytes:(s,c)=>Ie.mintValidatedBytes(s,c)}),it=Wa({session:o,measurer:I,producer:B,cache:O,styleCascade:Ce,defaultTabStopPt:qe,inlineDrawingLayoutForPart:s=>Ie.contextForPart(s),drawingLayoutTokenForPart:s=>Ie.cacheTokenForPart(s),drawingTokenForParagraphForPart:(s,c)=>Ie.drawingTokenForParagraph(c,s)}),me=s=>{let c=Ta$1(s,u=>o.relationshipTarget(u));return s.kind==="textValue"?null:{id:s.id,kind:c.kind,href:c.href,...c.anchor!==void 0?{anchor:c.anchor}:{},...c.tooltip!==void 0?{tooltip:c.tooltip}:{}}},ye={...o,applyTreeOps:(s,c,u)=>He(s,c,u),applyPmDoc:s=>_e==="view"?{committed:false,rejected:true,opCount:0,reason:d}:_o()?{committed:false,rejected:true,opCount:0,reason:p}:o.applyPmDoc(s)},Y=Pr(),bt=Yd({session:ye,storyScope:x,paragraphOrder:D,layout:()=>Y,selection:()=>L,commit:(s,c,u)=>ke(s,c,u),orderedRange:()=>Jt(),selectionMark:()=>Pe(),textOf:s=>Ot(s),selectedCells:()=>z?.cellIds,defaultParagraphStyleId:()=>Ce?.defaultParagraphStyleId??null,defaultFontFamily:()=>n.defaultFontFamily??null,pendingFormats:()=>at(),setPendingFormats:s=>{if(s===null||s.length===0){if(!xe)return;xe=null;}else {let{anchor:c,head:u}=L;if(c.paragraphId!==u.paragraphId||c.offset!==u.offset)return;let g=Le()?.base??Ud(o.partFor(x())??o.part(),u.paragraphId,u.offset);xe={position:u,properties:s,base:g};}n.onChange?.(he());}}),fn=Tc({session:ye,storyScope:x,paragraphOrder:D,layout:()=>Y,commit:(s,c)=>ke(s,c,{rearmPending:Le()??void 0}),orderedStart:()=>Lr(),orderedRange:()=>Jt(),selectionMark:()=>Pe(),collapsedAt:s=>Fe(s),deleteSelectionPlan:()=>en(),paragraphTextOf:s=>Ot(s),numberingLevelExists:(s,c)=>Rb(Vb(Je(),Ce),s,c)!==null}),$t=Rc({session:ye,refusesWrite:()=>Ar(true)!==null,storyScope:x,selection:()=>L,orderedRange:()=>Jt(),selectionMark:()=>Pe(),textOf:s=>Ot(s),commit:(s,c)=>ke(s,c)}),xt=Ec({pagesLayer:k,container:e,scale:()=>i,layout:()=>Y,bookmarks:()=>o.bookmarks(),linkById:s=>$t.linkById(s),drawingLinkById:s=>Mc(Y,s),setSelection:s=>pt(Fe(s)),isCollapsedSelection:()=>L.anchor.paragraphId===L.head.paragraphId&&L.anchor.offset===L.head.offset,onScrolled:()=>Kt(),...n.onHyperlinkPopover?{onPopover:n.onHyperlinkPopover}:{}});k.addEventListener("contextmenu",Q),k.addEventListener("click",J),k.addEventListener("pointermove",Dn),k.addEventListener("pointerleave",Er);let It=null;function Hn(s){Ie.sync(o);let c=Od({session:o,measurer:I,producer:B,cache:O,styleCascade:Ce,defaultTabStopPt:qe,inlineDrawingLayoutForPart:u=>Ie.contextForPart(u),drawingTokenForParagraphForPart:(u,g)=>Ie.drawingTokenForParagraph(g,u)});return fd$1(o.part(),s,{measurer:I,cache:O,session:m,producer:B,styleCascade:Ce,defaultTabStopPt:qe,numberingIndex:Je(),sectionFurniture:it.sectionFurniture(),furniture:it.furniture(),projectLink:me,inlineDrawingLayout:Ie.bodyContext,drawingTokenForParagraph:u=>Ie.drawingTokenForParagraph(u,o.part().name),...c?{notes:c}:{},...n.revisionDisplayMode?{displayMode:n.revisionDisplayMode}:{}})}function Pr(){let s=Z(),c=Hn(o.packageRevision());return ee=Z()-s,c}let et=nd$1({run:s=>{let c=Z(),u=Hn(s.revision);return ee=Z()-c,u},currentRevision:()=>o.packageRevision(),publish:s=>{Y=s,Ge();}}),_t=false;Be=()=>{et.invalidateAll(o.packageRevision(),"drawing-resources"),!_t&&(_t=true,setTimeout(()=>{_t=false,tt();},0));};let Ho=o.subscribe(s=>{xe=null,et.notify(s);});function Ln(){let s=Ed(e,Y,L,i),c=pe?.getActive()?.pageIndex;return c===void 0||s===void 0||s.has(c)?s:new Set([...s,c])}function tt(){return et.pending()?et.flush():false}let Bt=null;function wr(s){return s.contentControlId??`toc:${s.id}`}function st(s){return tc$1(o.part()).find(c=>c.beginParagraphId===s||c.endParagraphId===s||c.resultParagraphIds.includes(s))}function Cr(){for(let s of k.querySelectorAll(".docx-content-control-chrome[data-docx-toc]")){if(s.getAttribute("data-docx-content-control")===Bt){s.dataset.hover="",s.dataset.boundaryVisible="";continue}delete s.dataset.hover,re||delete s.dataset.boundaryVisible;}}function Rr(s){Bt!==s&&(Bt=s,Cr());}function Dn(s){let u=s.target?.closest("[data-paragraph-id]")?.dataset.paragraphId,g=u?st(u):null;Rr(g?wr(g):null);}function Nn(s){let c=s.target,u=c?.isConnected?c.closest("[data-paragraph-id]"):void 0;if(u)return u.dataset.paragraphId;let g=k.ownerDocument;return typeof g.elementFromPoint!="function"?void 0:g.elementFromPoint(s.clientX,s.clientY)?.closest("[data-paragraph-id]")?.dataset.paragraphId}function Er(){Rr(null);}function Lo(){let s=Rt(),c=vc$1(o.part()),g=tc$1(o.part()).map(K=>{let se=St(K);return se?{...se,empty:c.has(K.beginParagraphId)}:null}).filter(K=>K!==null),b=new Set(g.map(K=>K.boundary.id)),E=new Set(g.filter(K=>K.empty).map(K=>K.boundary.id)),_=s&&!b.has(s.id)?new Set([s.id]):void 0,U=Bt?new Set([Bt]):void 0,V=new Set(td$1(Y).filter(K=>K.controlType==="checkbox"&&f(K.id)).map(K=>K.id)),ie=g.filter(K=>K.additional&&!K.empty).map(K=>K.boundary);if(!(!re&&!_&&!U&&V.size===0&&ie.length===0&&b.size===0))return {...re?{showAll:true}:{},..._?{activeIds:_}:{},...U?{hoverIds:U}:{},...V.size>0?{checkedIds:V}:{},...ie.length>0?{additionalBoundaries:ie}:{},...b.size>0?{tocControlIds:b}:{},...E.size>0?{suppressedIds:E}:{}}}function St(s){let c=s.contentControlId?td$1(Y).find(b=>b.id===s.contentControlId):void 0;if(c)return {tocId:s.id,boundary:c,additional:false};let u=new Set([s.beginParagraphId,...s.resultParagraphIds,s.endParagraphId]),g=Y.pages.flatMap(b=>{let E=R(b).filter(K=>u.has(K.paragraphId)).map(K=>K.box);if(E.length===0)return [];let _=Math.min(...E.map(K=>K.x)),U=Math.min(...E.map(K=>K.y)),V=Math.max(...E.map(K=>K.x+K.width)),ie=Math.max(...E.map(K=>K.y+K.height));return [{pageIndex:b.index,box:{x:_,y:U,width:V-_,height:ie-U}}]});return g.length===0?null:{tocId:s.id,additional:true,boundary:{id:`toc:${s.id}`,controlType:"richText",lock:"unlocked",effectiveLock:"unlocked",placeholder:false,bound:false,nestingDepth:0,level:"block",fragments:g}}}function Rt(){let s=qd$1(Y,L.head,I);return s?sd$1(Y,{x:s.x,y:s.y+s.height/2,pageIndex:s.pageIndex}):null}function _n(s){return s.bound?"bound":s.effectiveLock==="contentLocked"||s.effectiveLock==="sdtContentLocked"?"locked":null}function pn(s){return s.effectiveLock==="sdtLocked"||s.effectiveLock==="sdtContentLocked"?"locked":null}function Yt(s){return Jb(s)}function Et(s){let c=Ea$1(o.part(),s);return !c||!Yt(c)?null:c}function Fr(s){let c=Et(s);if(!c)return null;for(let u of c.children)if(u.kind!=="textValue"&&(u.kind==="contentControlProperties"||u.localName==="sdtPr"))for(let g of u.children){if(g.kind==="textValue"||g.localName!=="tabIndex")continue;let b=g.attributes.find(_=>_.localName==="val")?.value;if(b===void 0)return null;let E=Number(b);return Number.isFinite(E)?E:null}return null}function Or(){return [...td$1(Y)].filter(c=>_n(c)===null).sort((c,u)=>{let g=Fr(c.id),b=Fr(u.id);return g!==null&&b!==null&&g!==b?g-b:g!==null&&b===null?-1:g===null&&b!==null?1:0})}function kt(s){if(s.kind==="textValue")return s.value.length;if(s.kind==="tab"||s.kind==="hardBreak")return 1;if(s.kind==="runProperties"||s.kind==="generic")return 0;if(s.kind==="contentControl"){let g=0;for(let b of s.children)if(b.kind!=="textValue"&&(b.kind==="contentControlContent"||b.localName==="sdtContent"))for(let E of b.children)g+=kt(E);return g}let u=0;for(let g of s.children)u+=kt(g);return u}function Bn(s){for(let c of s.children)if(c.kind!=="textValue"&&(c.kind==="contentControlContent"||c.localName==="sdtContent"))return c.children;return []}function Zn(s){let c=Et(s);if(!c)return false;let u=Bn(c),g=[],b=ie=>{for(let K of ie){if(K.kind==="paragraph"){g.push({id:K.id,length:kt(K)});continue}if(K.kind==="textValue")continue;if(K.kind==="contentControl"){b(Bn(K));continue}b(K.children);}};if(b(u),g.length>0){let ie=g[0],K=g[g.length-1];return pt({anchor:{paragraphId:ie.id,offset:0},head:{paragraphId:K.id,offset:K.length}}),true}let E=null,_=0,U=0,V=(ie,K,se)=>{let ue=K;for(let be of ie){if(be.id===s)return E=se,_=ue,U=ue+kt(be),true;if(be.kind==="textValue"){ue+=be.value.length;continue}if(be.kind==="contentControl"){let tn=kt(be);if(V(Bn(be),ue,se))return true;ue+=tn;continue}if(be.kind==="run"||be.kind==="hyperlink"){if(V(be.children,ue,se))return true;ue+=kt(be);continue}if(be.kind==="paragraph"){if(V(be.children,0,be.id))return true;continue}if(be.kind==="tab"||be.kind==="hardBreak"){ue+=1;continue}if(V(be.children,ue,se))return true;ue+=kt(be);}return false};return V(o.part().root.children,0,""),E?(pt({anchor:{paragraphId:E,offset:_},head:{paragraphId:E,offset:U}}),true):false}function Zt(s){let c=Et(s);if(!c)return [];for(let u of c.children)if(u.kind!=="textValue"&&!(u.kind!=="contentControlProperties"&&u.localName!=="sdtPr"))for(let g of u.children){if(g.kind==="textValue"||g.localName!=="dropDownList"&&g.localName!=="comboBox")continue;let b=[];for(let E of g.children){if(E.kind==="textValue"||E.localName!=="listItem")continue;let _=E.attributes.find(V=>V.localName==="value")?.value??"",U=E.attributes.find(V=>V.localName==="displayText")?.value??_;b.push({displayText:U,value:_});}return b}return []}function f(s){let c=Et(s);if(!c)return false;for(let u of c.children)if(u.kind!=="textValue"&&!(u.kind!=="contentControlProperties"&&u.localName!=="sdtPr")){for(let g of u.children)if(g.kind==="contentControlCheckbox")for(let b of g.children){if(b.kind!=="contentControlChecked")continue;let E=b.attributes.find(_=>_.localName==="val")?.value;return !(E==="0"||E==="false"||E==="off")}}return false}function w(s){let c=Et(s);if(c){for(let u of c.children)if(u.kind==="contentControlProperties"){for(let g of u.children)if(g.kind==="contentControlDate")return g.attributes.find(b=>b.localName==="fullDate")?.value}}}function H$1(s,c){for(let u of k.querySelectorAll("[data-docx-content-control]"))u.getAttribute("data-docx-content-control")===s&&(c?u.dataset.open="":delete u.dataset.open);}function W(s){let c=s.dataset.docxCcId;s.remove(),c&&H$1(c,false);}function q(){let s=k.querySelector(".docx-content-control-menu");s&&W(s);}function Q(s){let c=Nn(s),u=c?st(c):void 0;Me(u&&qo(u.id)?u.id:null);}let de=null;function Me(s){de!==s&&(de=s,n.onChange?.(he()));}function J(s){if(s.button!==0||s.target?.closest("a.docx-hyperlink")||L.anchor.paragraphId!==L.head.paragraphId||L.anchor.offset!==L.head.offset)return;let c=Nn(s);if(!c)return;let u=tc$1(o.part()).find(E=>E.resultParagraphIds.includes(c));if(!u)return;let b=H(o.part(),u,o.documentOutline(),Bo(u))[u.resultParagraphIds.indexOf(c)];b&&(s.preventDefault(),xt.goToPosition({paragraphId:b,offset:0}));}function Se(s,c){let u=ce.disabledReason(s,"edit");if(u){oe=u,n.onChange?.(he());return}if(c==="checkbox"){ce.setValue(s,f(s)?"false":"true");return}if(c==="dropdown"||c==="comboBox"){let g=Zt(s);if(g.length===0&&c==="dropdown")return;q();let b=A.createElement("div");b.className="docx-content-control-menu",b.dataset.docxMarker="",b.dataset.docxCcId=s,b.setAttribute("contenteditable","false"),b.setAttribute("role","listbox"),b.style.position="absolute",b.style.zIndex="20",b.style.pointerEvents="auto",b.addEventListener("pointerdown",V=>V.stopPropagation());let _=td$1(Y).find(V=>V.id===s)?.fragments[0];if(_){let V=Y.pages[_.pageIndex],ie=Te?.pageOffsetX.get(_.pageIndex)??0;if(V){let K=V.contentBox.x-V.box.x,se=V.contentBox.y-V.box.y;b.style.left=`${(V.box.x+ie+K+_.box.x+_.box.width)*i}px`,b.style.top=`${(V.box.y+se+_.box.y+_.box.height)*i}px`,b.style.transform="translateX(-100%)";}}for(let V of g){let ie=A.createElement("button");ie.type="button",ie.className="docx-content-control-menu-item",ie.dataset.docxMarker="",ie.setAttribute("contenteditable","false"),ie.setAttribute("role","option"),ie.textContent=V.displayText,ie.addEventListener("mousedown",K=>{K.preventDefault(),K.stopPropagation(),W(b),ce.setValue(s,V.value);}),b.append(ie);}if(c==="comboBox"){let V=A.createElement("input");V.type="text",V.className="docx-content-control-menu-input",V.dataset.docxMarker="",V.setAttribute("contenteditable","false"),V.addEventListener("mousedown",ie=>ie.stopPropagation()),V.addEventListener("keydown",ie=>{ie.key==="Enter"&&(ie.preventDefault(),W(b),ce.setValue(s,V.value));}),b.append(V);}k.append(b),H$1(s,true);let U=V=>{b.contains(V.target)||(W(b),A.removeEventListener("mousedown",U,true));};A.addEventListener("mousedown",U,true);return}if(c==="date"){q();let g=A.createElement("div");g.className="docx-content-control-menu",g.dataset.docxMarker="",g.dataset.docxCcId=s,g.setAttribute("contenteditable","false"),g.style.position="absolute",g.style.zIndex="20",g.style.pointerEvents="auto",g.addEventListener("pointerdown",ve=>ve.stopPropagation());let b=td$1(Y).find(ve=>ve.id===s),E=b?.fragments[0];if(E){let ve=Y.pages[E.pageIndex],nn=Te?.pageOffsetX.get(E.pageIndex)??0;if(ve){let Xn=ve.contentBox.x-ve.box.x,$n=ve.contentBox.y-ve.box.y;g.style.left=`${(ve.box.x+nn+Xn+E.box.x+E.box.width)*i}px`,g.style.top=`${(ve.box.y+$n+E.box.y+E.box.height)*i}px`,g.style.transform="translateX(-100%)";}}g.classList.add("docx-content-control-calendar");let _=w(s),U=_?new Date(_):new Date,V=Number.isNaN(U.getTime())?null:U,ie=V??new Date,K=ie.getFullYear(),se=ie.getMonth(),ue=new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}),be=new Intl.DateTimeFormat(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),At=new Intl.DateTimeFormat(void 0,{weekday:"narrow"}),tn=ve=>`${ve.getFullYear().toString().padStart(4,"0")}-${(ve.getMonth()+1).toString().padStart(2,"0")}-${ve.getDate().toString().padStart(2,"0")}`,Wn=(ve,nn)=>ve.getFullYear()===nn.getFullYear()&&ve.getMonth()===nn.getMonth()&&ve.getDate()===nn.getDate(),Gi=null,Wo=()=>{let ve=A.createElement("input");ve.type="date",ve.className="docx-content-control-calendar-input",ve.value=V?tn(V):"";let nn=ve.value;b?.alias&&ve.setAttribute("aria-label",b.alias);let Xn=()=>{if(!ve.value||ve.value===nn)return false;let je=ve.value;return W(g),ce.setValue(s,je),true};Gi=Xn,ve.addEventListener("keydown",je=>{je.key==="Enter"&&(je.preventDefault(),Xn()||W(g));}),ve.addEventListener("blur",()=>{queueMicrotask(()=>{!g.isConnected||g.contains(A.activeElement)||Xn()||W(g);});});let $n=A.createElement("div");$n.className="docx-content-control-calendar-header";let rn=A.createElement("button");rn.type="button",rn.className="docx-content-control-calendar-nav",rn.textContent="\u2039";let Nu=new Date(K,se-1,1);rn.setAttribute("aria-label",ue.format(Nu));let Xo=A.createElement("div");Xo.className="docx-content-control-calendar-title",Xo.textContent=ue.format(new Date(K,se,1));let on=A.createElement("button");on.type="button",on.className="docx-content-control-calendar-nav",on.textContent="\u203A";let _u=new Date(K,se+1,1);on.setAttribute("aria-label",ue.format(_u)),rn.addEventListener("mousedown",je=>je.stopPropagation()),on.addEventListener("mousedown",je=>je.stopPropagation()),rn.addEventListener("click",()=>{se-=1,se<0&&(se=11,K-=1),Wo();}),on.addEventListener("click",()=>{se+=1,se>11&&(se=0,K+=1),Wo();}),$n.append(rn,Xo,on);let $o=A.createElement("div");$o.className="docx-content-control-calendar-weekdays";for(let je=0;je<7;je+=1){let Mt=A.createElement("span");Mt.textContent=At.format(new Date(2024,0,1+je)),$o.append(Mt);}let Dr=A.createElement("div");Dr.className="docx-content-control-calendar-grid",Dr.setAttribute("role","grid");let Bu=(new Date(K,se,1).getDay()+6)%7,Zu=new Date;for(let je=0;je<42;je+=1){let Mt=new Date(K,se,je-Bu+1),lt=A.createElement("button");lt.type="button",lt.className="docx-content-control-calendar-day",lt.textContent=String(Mt.getDate()),lt.setAttribute("role","gridcell"),lt.setAttribute("aria-label",be.format(Mt)),Mt.getMonth()!==se&&(lt.dataset.otherMonth=""),V&&Wn(Mt,V)&&(lt.dataset.selected="",lt.setAttribute("aria-selected","true")),Wn(Mt,Zu)&&(lt.dataset.today=""),lt.addEventListener("mousedown",qu=>qu.stopPropagation()),lt.addEventListener("click",()=>{W(g),ce.setValue(s,tn(Mt));}),Dr.append(lt);}g.replaceChildren(ve,$n,$o,Dr);};Wo(),k.append(g),H$1(s,true);let Wi=ve=>{g.contains(ve.target)||(Gi?.()||W(g),A.removeEventListener("mousedown",Wi,true));};A.addEventListener("mousedown",Wi,true),g.querySelector("[data-selected], [data-today], .docx-content-control-calendar-day")?.focus({preventScroll:true});}}let ce={setShowAll(s){re!==s&&(re=s,Ge());},setFormFill(s){we!==s&&(we=s,n.onChange?.(he()));},showAll:()=>re,formFill:()=>we,atCaret:()=>Rt(),navigate(s){let c=Or();if(c.length===0)return false;let u=Rt(),g=u?c.findIndex(E=>E.id===u.id):-1;s==="next"?g=g<0?0:(g+1)%c.length:g=g<0?c.length-1:(g-1+c.length)%c.length;let b=c[g];return Zn(b.id)},setValue(s,c){let u=ce.disabledReason(s,"edit");if(u)return oe=u,n.onChange?.(he()),false;let g=false;return ke(()=>{let b=o.applyTreeOps([{op:"setContentControlValue",controlId:s,value:c}],Pe());return g=b.committed,b}),g},remove(s){let c=s??Rt()?.id;if(!c)return oe="notFound",n.onChange?.(he()),false;let u=ce.disabledReason(c,"remove");if(u)return oe=u,n.onChange?.(he()),false;let g=false;return ke(()=>{let b=o.applyTreeOps([{op:"removeContentControl",controlId:c}],Pe());return g=b.committed,b}),g},disabledReason(s,c){let u=td$1(Y).find(b=>b.id===s);if(u)return c==="remove"?pn(u):_n(u);let g=Et(s);if(!g)return "notFound";for(let b of g.children)if(b.kind!=="textValue"&&!(b.kind!=="contentControlProperties"&&b.localName!=="sdtPr")){if(b.children.some(E=>E.kind!=="textValue"&&E.localName==="dataBinding")&&c==="edit")return "bound";for(let E of b.children){if(E.kind==="textValue"||E.localName!=="lock")continue;let _=E.attributes.find(U=>U.localName==="val")?.value;if(c==="remove"){if(_==="sdtLocked"||_==="sdtContentLocked")return "locked"}else if(_==="contentLocked"||_==="sdtContentLocked")return "locked"}}return null}};function he(){return {revision:o.packageRevision(),pageCount:Y.pages.length,selection:L,cellSelection:z,canUndo:o.canUndo(),canRedo:o.canRedo(),lastRejection:oe,pendingFormat:at(),contentControls:{showAll:re,formFill:we,activeControlId:Rt()?.id??null},contextTocId:de,perf:{layoutMs:ee,paintMs:ne,selectionMs:ge,placed:m.stats.placed,total:m.stats.total,reusedPages:m.stats.reusedPages,fullPasses:m.stats.fullPasses,staleDiscards:et.staleDiscards,cancelledRuns:et.cancelledRuns}}}let ze,Te,qt=null,Ft=false,fe=null,Re=null;function zt(s){for(let c of Y.pages){let u=k.querySelector(`[data-page-index="${c.index}"]`);if(!u)continue;let g=s.pageOffsetX.get(c.index)??0;u.style.left=`${(c.box.x+g)*i}px`;}}function Ge(s=true){let c=Ke.adoptBeforePaint(),u=Z();ze=Ln(),pe?.reconcileOccurrence();let g=pe?.getActive()??null,b=Lo(),E=vc$1(o.part());d$1(k,Y,{scale:i,readOnlyParagraphIds:Hr(),...E.size>0?{emptyTocPlaceholderIds:E}:{},...n.fontAlias?{fontAlias:n.fontAlias}:{},...n.defaultFontFamily?{defaultFontFamily:n.defaultFontFamily}:{},materialize:ze,ariaHidden:false,drawingStrings:Mn,...$e?{imageUrlPort:$e}:{},...g?{activeHeaderFooterRId:g.scope.rId,activeHeaderFooterPageIndex:g.pageIndex}:{},...b?{contentControlChrome:b}:{}}),ac(e,k,g!=null),e.classList.toggle("docx-paginated-surface--viewing",_e==="view"),Te=vo(Y,ze),zt(Te),k.style.width=`${Te.width*i}px`,k.style.height=`${Te.height*i}px`,e.style.width=`${Te.width*i}px`,e.style.height=`${Te.height*i}px`,j.style.width=`${Te.width*i}px`,j.style.height=`${Te.height*i}px`,P.style.width=j.style.width,P.style.height=j.style.height,v.style.width=j.style.width,v.style.height=j.style.height,gn.update(),ne=Z()-u,Vn(),jn(),Ui(),Ke.mirrorToDom(),qn(Ft),Ft=false,(s||c)&&n.onChange?.(he());}function Kt(){let s=Ln(),c=vo(Y,s);Te&&Xa(s,ze)&&Fd(c,Te)||Ge(false);}function qn(s=false){if(pe?.getActive()||R$1?.activeNoteScope()||L.anchor.paragraphId!==L.head.paragraphId||L.anchor.offset!==L.head.offset)return;let c=A.activeElement;if(c!==k&&(!c||!k.contains(c)))return;let u=qd$1(Y,L.head,{measurer:I});if(!u)return;let g=qt!==null&&qt!==u.pageIndex;if(qt=u.pageIndex,!s&&!g)return;let b=Y.pages[u.pageIndex],E=Ct(e);if(!b||!E||E.clientHeight<=0)return;let _=24,U=b.contentBox.y-b.box.y,V=(b.box.y+U+u.y)*i+e.offsetTop,ie=V+u.height*i,K=E.scrollTop,se=K+E.clientHeight,ue=K;if(V<K+_)ue=V-_;else if(ie>se-_)ue=ie+_-E.clientHeight;else return;let be=Math.max(0,E.scrollHeight-E.clientHeight),At=Math.max(0,Math.min(ue,be));Math.abs(At-E.scrollTop)<.5||(E.scrollTop=At,Vo());}let _e=n.editingMode??"edit",Iu=Object.freeze({kind:"body"});function He(s,c,u,g=x(),b=true){let E=Ar(s.some(Su),s,b);if(E!==null)return {committed:false,rejected:true,opCount:0,reason:E};let _=Tu(s),U=o.applyTreeOps(_,c,u,g);return U.committed&&_e==="suggest"&&_.some(ku)&&r.onTrackedChange?.(),U}function Ar(s,c=[],u=true){return _e==="view"?d:s&&(u&&_o()||c.some(g=>Ou(g)))?p:_e==="suggest"&&!n.author?.trim()&&s?"suggesting needs an author before it can propose a change":null}function Su(s){return s.op!=="acceptRevision"&&s.op!=="rejectRevision"&&s.op!=="acceptAllRevisions"&&s.op!=="rejectAllRevisions"}function ku(s){switch(s.op){case "insertText":case "deleteText":case "insertTableRow":case "deleteTableRow":return s.revision!==void 0;case "setParagraphMarkRevision":case "proposeParagraphMerge":return true;default:return false}}function Tu(s){let c=n.author?.trim();if(_e!=="suggest"||!c)return [...s];let u={author:c,date:C()};return s.flatMap(g=>g.op==="insertText"||g.op==="deleteText"||g.op==="insertTableRow"||g.op==="deleteTableRow"?[{...g,revision:u}]:g.op==="splitParagraph"?[g,{op:"setParagraphMarkRevision",paragraphId:g.paragraphId,kind:"ins",revision:u}]:g.op==="joinParagraphs"?[{op:"proposeParagraphMerge",paragraphId:g.secondId,revision:u}]:[g])}function ke(s,c,u={}){u?.keepCellSelection||(z=null),xe=null,Ke.noteModelMoved();let g=s();if(typeof g!="boolean"&&g.rejected)oe=String(g.reason??"rejected");else {oe=null;let b=c?.();b&&(L=b,It=null,Ft=true);let E=u?.rearmPending;if(E&&E.properties.length>0){let{anchor:_,head:U}=L;_.paragraphId===U.paragraphId&&_.offset===U.offset&&(xe={properties:E.properties,base:E.base,position:U});}}tt()||Ge();}function Pu(){if(!ze)return true;for(let s of [L.anchor,L.head]){let c=qd$1(Y,s);if(c&&!ze.has(c.pageIndex))return false}return true}function pt(s,c=false){Ne(s),Ue(s);let u=Rt()?.id??null,g=Un(L.head.paragraphId);L=s,z=null,c||(It=null),Pu()||(Ke.noteModelMoved(),Ge(false)),Ke.noteSelectionSettled(),Ke.mirrorToDom(true),qn(true),Vn(),Kn=null,jn();let b=Rt()?.id??null,E=Un(L.head.paragraphId);(u!==b||g!==E)&&Ge(false),n.onChange?.(he());}let Ke=Sc({session:o,storyScope:x,document:A,pagesLayer:k,selection:()=>L,setSelection:s=>pt(s),adoptSelection:s=>{Ne(s),Ue(s),L=s,It=null,Ft=true;},commit:s=>ke(s),render:()=>Ge(),flushLayout:()=>tt(),updateCaret:()=>T.update(),textOf:s=>Ot(s),pendingFormatOps:(s,c,u)=>De(s,c,u),selectionMark:()=>Pe(),now:Z,recordSelectionMs:s=>{ge=s;},isGesturing:()=>zo?.dragging()??false,domSelection:()=>z?Fe(z.text.anchor):L,holdsCellSelection:()=>z!==null});pe=Dc({session:o,layout:()=>Y,selection:()=>L,setScopeSelection:s=>{L=s,z=null,It=null;},noteModelMoved:()=>Ke.noteModelMoved(),render:()=>Ge(),mirrorToDom:()=>Ke.mirrorToDom(),notify:()=>n.onChange?.(he()),materializedPages:()=>ze}),R$1=_c({session:o,applyOps:He,commit:ke,selection:()=>L,selectionMark:()=>Pe(),orderedStart:()=>Lr(),activeScope:()=>{let s=R$1?.activeNoteScope();return s||(pe?.activeScope()??{kind:"body"})},setActiveScopeBodyOrHf:s=>pe.setActiveScope(s),setSelection:s=>pt(s),noteModelMoved:()=>Ke.noteModelMoved(),render:()=>Ge(),revealNote:s=>{for(let c of Y.pages){let u=[...c.footnotes?.notes??[],...c.endnotes?.notes??[]].find(g=>g.scopeId===s);if(u)return Gn(u.box.y,u.box.height,{block:"nearest",offsetPx:48}),c.index}return null},notify:()=>n.onChange?.(he()),lastRejection:()=>oe,setLastRejection:s=>{oe=s;}});function Ci(s){z=s,s&&(Ne(s.text),L=s.text),It=null,Ke.noteSelectionSettled(),Ke.mirrorToDom(),Vn(),Kn=null,jn(),n.onChange?.(he());}let Qt=null;function wu(){let c=qd$1(Y,L.head)?.pageIndex??0,u=new Set;for(let g=c-1;g<=c+1;g+=1)g>=0&&g<Y.pages.length&&u.add(g);return u}let Ri=new WeakMap;function Cu(s){let c=Ri.get(s);if(c)return c;let u=new Map;for(let g of s.pages)for(let b of R(g))u.has(b.paragraphId)||u.set(b.paragraphId,g.index);return Ri.set(s,u),u}function Ru(){let s=o.revision(),c=ze??wu();if(Qt?.layout===Y&&Qt.revision===s&&Xa(Qt.pages,c))return Qt.rects;let u=Cu(Y),g=(U,V)=>{if(!c)return true;let ie=u.get(U),K=u.get(V);if(ie===void 0||K===void 0)return true;for(let se=Math.min(ie,K);se<=Math.max(ie,K);se+=1)if(c.has(se))return true;return false},b=[];for(let U of o.reviewItems()){if(U.kind==="comment"){if(U.range===null||U.resolved||!g(U.range.start.paragraphId,U.range.end.paragraphId))continue;b.push({key:b$2(U),from:{paragraphId:U.range.start.paragraphId,offset:U.range.start.offset},to:{paragraphId:U.range.end.paragraphId,offset:U.range.end.offset}});continue}let V=b$2(U),ie=U.kind==="revision"?U.ranges:U.range?[U.range]:[];for(let[K,se]of ie.entries())g(se.start.paragraphId,se.end.paragraphId)&&b.push({key:ie.length===1?V:`${V}${y}${K}`,from:{paragraphId:se.start.paragraphId,offset:se.start.offset},to:{paragraphId:se.end.paragraphId,offset:se.end.offset}});}let E=vd$1(Y,b,c),_=[];for(let[U,V]of E)for(let ie of V)_.push({...ie,key:U});return Qt={layout:Y,revision:s,pages:c,rects:_},_}let zn=null;function Eu(){let s=o.packageRevision(),c=o.part().root;if(zn&&zn.packageRevision===s&&zn.bodyRoot===c)return zn.index;let u=new Map,g=E=>{let _=u.size;for(let[U,V]of E)u.has(U)||u.set(U,_+V);};g(gg$1(o.part()));let b=new Set([o.part()]);for(let E of o.headerFooterPartsBySection())for(let _ of [E.headers,E.footers])for(let U of _.values())b.has(U)||(b.add(U),g(gg$1(U)));for(let E of ["footnote","endnote"]){let _=o.partFor({kind:"notesPart",noteKind:E});!_||b.has(_)||(b.add(_),g(gg$1(_)));}return zn={packageRevision:s,bodyRoot:c,index:u},u}let Kn=null,Do=null;function No(){let s=L?.head;if(!s)return null;let u=h$1(o.reviewItems(),s,Eu()).filter(b=>!(b.kind==="comment"&&b.resolved)&&b$2(b)!==Kn&&!(b.kind==="revision"&&Do!==null&&Do.has(b.revisionKind)))[0];if(!u)return null;if(u.kind!=="comment")return u;let g=j$2(o.reviewItems(),u);return b$2(g)===Kn?null:g}function Fu(s,c,u){let g=s.split(y),b=g[0],E=c!==null&&b===b$2(c);if(s.startsWith("comment-"))return E?"docx-comment-band docx-comment-band--active":"docx-comment-band";if(s.startsWith("custom-"))return E?"docx-comment-band docx-comment-band--active":null;let _=u.get(b);if(!_||_.kind!=="revision")return null;let U=g.length>1?Number(g[1]):0;return `docx-revision-band docx-revision-band--${(K=>K==="delete"||K==="moveFrom"?"delete":K==="insert"||K==="moveTo"?"insert":K==="replace"&&_.replacedRangeCount!==void 0?U<_.replacedRangeCount?"delete":"insert":"other")(_.revisionKind)}${E?" docx-revision-band--active":""}`}function jn(){let s=No(),c=new Map;for(let g of o.reviewItems())c.set(b$2(g),g);let u=[];for(let g of Ru()){let b=Fu(g.key,s,c);b&&u.push({...g,className:b});}e$1(P,Y,u,{scale:i,...Te?{pageOffsetX:Te.pageOffsetX}:{}});}function Vn(){e$1(j,Y,z?Fd$1(Y,z.cellIds):le?ud$1(Y,le):[],{scale:i,pageOffsetX:Te?.pageOffsetX,...z?{}:{className:"docx-retained-selection-rect"}});}function Mr(s){let c=tc$1(o.part());if(s)return c.find(b=>b.id===s)??null;let u=de?c.find(b=>b.id===de):void 0;if(u)return u;let g=L.head.paragraphId;return c.find(b=>b.beginParagraphId===g||b.endParagraphId===g||b.resultParagraphIds.includes(g))??(c.length===1?c[0]:null)}function Un(s){return tc$1(o.part()).find(u=>u.beginParagraphId===s||u.endParagraphId===s||u.resultParagraphIds.includes(s))?.id??null}function _o(){return Un(L.anchor.paragraphId)!==null||Un(L.head.paragraphId)!==null}function Ou(s){let c=Hr(),u=(g,b="")=>typeof g=="string"?/(?:Id|Ids)$/.test(b)&&c.has(g):Array.isArray(g)?g.some(E=>u(E,b)):!g||typeof g!="object"?false:Object.entries(g).some(([E,_])=>u(_,E));return u(s)}function Hr(){return new Set(tc$1(o.part()).flatMap(s=>[s.beginParagraphId,...s.resultParagraphIds,s.endParagraphId]))}function Bo(s){return new Set([s.beginParagraphId,s.endParagraphId,...s.resultParagraphIds])}function Au(s){let c=0;for(let u of Y.pages)for(let g of R(u))s.has(g.paragraphId)&&(c+=g.lines.length);return c}function Zo(s,c){let u=new Set(c),g=new Map;for(let b of s.pages)for(let E of R(b)){if(!u.has(E.paragraphId)||g.has(E.paragraphId))continue;let _=b.pageFieldSource;g.set(E.paragraphId,ib(_?.pageNumber??b.index+1,_?.format));}return g}function qo(s){if(_e==="view"||!o.editable)return false;let c=Mr(s);return c?xf(o.part(),{op:"rewriteTocPageNumbers",tocId:c.id,updates:[]})===null:false}function Ei(s,c){if(!Number.isInteger(s)||!Number.isInteger(c)||s<1||c<1)return null;let u=fn.sectionPropertiesAt(L.head.paragraphId),g=u.pageSize.widthTwips-u.margins.leftTwips-u.margins.rightTwips-u.margins.gutterTwips,b=Math.max(300,Math.floor(g/c));return {op:"insertTable",beforeParagraphId:L.head.paragraphId,rows:s,cols:c,columnWidthTwips:b}}function Fi(s,c){if(_e==="view"||!o.editable)return false;let u=Ei(s,c);return u!==null&&xf(o.part(),u)===null}function Mu(s,c){if(!Fi(s,c))return false;let u=Ei(s,c);if(!u)return false;let g=null,b=o.subscribe(_=>{_.caret&&(g=_.caret);}),E=false;try{ke(()=>{let _=He([u],Pe());return _.committed||(oe=_.reason??"the table could not be inserted here"),E=_.committed,_},()=>{let _=g;return _?Fe({paragraphId:_.paragraphId,offset:_.start}):null});}finally{b();}return E}let Oi='TOC \\o "1-3" \\h';function Ai(){let s=sc$1(Oi);if(!s)return null;let c=o.documentOutline(),u=Bc$1(o.part(),c,s,Zo(Ee.layout(),c.map(g=>g.blockId)),Hr());return {op:"insertToc",beforeParagraphId:L.head.paragraphId,instruction:Oi,alias:n.tocLabels?.title??"TOC",entries:u.entries,bookmarksToCreate:u.bookmarksToCreate}}function Mi(){if(_e==="view"||!o.editable||_o())return false;let s=Ai();return s!==null&&xf(o.part(),s)===null}function Hu(){if(!Mi())return false;let s=Ai();if(!s)return false;let c=new Set(tc$1(o.part()).map(b=>b.id)),u=o.applyTreeOps([s]);if(!u.committed)return oe=u.reason??"the table of contents could not be inserted",false;let g=tc$1(o.part()).find(b=>!c.has(b.id));return g?Hi(g.id,"pageNumbers"):true}function Hi(s,c="entire"){let u=Mr(s);if(!u||!qo(u.id))return false;let g=Ee.layout(),b=o.documentOutline(),E=b.map(U=>U.blockId);if(c==="entire"){let U=Bc$1(o.part(),b,u.instruction,Zo(g,E),Bo(u)),V=o.applyTreeOps([{op:"replaceTocResult",tocId:u.id,entries:U.entries,bookmarksToCreate:U.bookmarksToCreate}]);if(!V.committed)return oe=V.reason??"the table of contents could not be refreshed",false;if(g=Ee.layout(),u=Mr(u.id),!u)return true}let _="";for(let U=0;U<3;U+=1){let V=Zo(g,E),ie=H(o.part(),u,b,Bo(u)),K=u.resultParagraphIds.flatMap((be,At)=>{let tn=ie[At],Wn=tn?V.get(tn):void 0;return Wn===void 0?[]:[{paragraphId:be,pageNumberText:Wn}]});if(K.length===0)break;let se=K.map(be=>`${be.paragraphId}\0${be.pageNumberText}`).join("");if(se===_)break;_=se;let ue=o.applyTreeOps([{op:"rewriteTocPageNumbers",tocId:u.id,updates:K}]);if(!ue.committed){if(ue.rejected)return oe=ue.reason??"the table of contents page numbers were refused",false;break}g=Ee.layout(),u=Mr(u.id)??u;}return true}let Ee={session:o,storyScope:x,imageDecodePort:()=>Ae,layout:()=>(tt(),Y),state:he,currentPage:(s="caret")=>{if(tt(),s==="viewport"){let u=Rd(e,Y,i);if(u!==null)return u}let c=qd$1(Y,L.head);return c?c.pageIndex+1:1},setScale(s){if(!(s>0)||!Number.isFinite(s))return false;if(s===i)return true;let c={scale:i,defaults:S,measurer:I,producer:B,furnitureSource:it};try{let u=Ct(e),g=u?{x:(u.scrollLeft-e.offsetLeft+u.clientWidth/2)/i,y:(u.scrollTop-e.offsetTop+u.clientHeight/2)/i}:null;if(i=s,n.measurer||(S=jd$1(i,{context:Rn(e.ownerDocument),...n.fontAlias?{fontAlias:n.fontAlias}:{}}),I=S.measurer),B=F(),it=Wa({session:o,measurer:I,producer:B,cache:O,styleCascade:Ce,defaultTabStopPt:qe}),ze=void 0,Te=void 0,Qt=null,et.invalidateAll(o.packageRevision(),"zoom"),et.flush(),u&&g){let b=Math.max(0,g.x*i+e.offsetLeft-u.clientWidth/2),E=Math.max(0,g.y*i+e.offsetTop-u.clientHeight/2),_=Number.isFinite(u.scrollWidth)?Math.max(0,u.scrollWidth-u.clientWidth):null,U=Number.isFinite(u.scrollHeight)?Math.max(0,u.scrollHeight-u.clientHeight):null;u.scrollLeft=_===null?b:Math.min(b,_),u.scrollTop=U===null?E:Math.min(E,U),Kt();}return !0}catch{(({scale:i,defaults:S,measurer:I,producer:B,furnitureSource:it}=c)),ze=void 0,Te=void 0,Qt=null;try{et.invalidateAll(o.packageRevision(),"zoom-rollback"),et.flush();}catch{}return false}},type(s){let c=en(),u=c.collapseTo,g=De(u.paragraphId,u.offset,s.length),b=_e==="suggest"?Jt():null,E=b&&b.to.paragraphId===u.paragraphId?b.to.offset:u.offset,_=[...c.ops,{op:"insertText",paragraphId:u.paragraphId,offset:E,text:s}],U={paragraphId:u.paragraphId,start:E+s.length,end:E+s.length};ke(()=>Xe([..._,...g],_,Pe(),U),()=>Fe({paragraphId:u.paragraphId,offset:E+s.length}));},insertPlainText:s=>Ko(s),deleteBackward(){let s=en();if(s.ops.length>0){ke(()=>He(s.ops,Pe()),()=>Fe(s.collapseTo));return}let c=Le()??void 0,u=L.head;if(u.offset===0){let b=D(),E=b.indexOf(u.paragraphId),_=b[E-1];if(!_)return;let U=Ot(_).length;ke(()=>He([{op:"joinParagraphs",firstId:_,secondId:u.paragraphId}],Pe()),()=>Fe({paragraphId:_,offset:U}),{rearmPending:c});return}let g=Di(u,"before");if(g){ke(()=>He([{op:"removeContentControl",controlId:g.controlId,keepContent:false}],Pe()),()=>Fe({paragraphId:u.paragraphId,offset:g.start}),{rearmPending:c});return}ke(()=>He([{op:"deleteText",paragraphId:u.paragraphId,start:u.offset-1,end:u.offset}],Pe()),()=>Fe({...u,offset:u.offset-1}),{rearmPending:c});},splitParagraph(){let s=en(),c=s.collapseTo,u=new Set(o.paragraphIdsIn(x())),g=Le()??void 0;ke(()=>He([...s.ops,{op:"splitParagraph",paragraphId:c.paragraphId,offset:c.offset}],Pe()),()=>{let b=o.paragraphIdsIn(x()).find(E=>!u.has(E));return b?Fe({paragraphId:b,offset:0}):null},{rearmPending:g});},navigate(s,c=false){let u=ai(Y,L.head,s,It,pe?.getActive()??null,N(),I);if(!u)return;let g=Hr();if(g.has(u.position.paragraphId)){if(c)return;let E=new Set(["left","wordLeft","lineStart","up","pageUp"]).has(s)?"up":"down",_=Au(g)+4;for(let U=0;U<_;U+=1){let V=ai(Y,u.position,E,u.desiredX,pe?.getActive()??null,N(),I);if(!V||V.position.paragraphId===u.position.paragraphId&&V.position.offset===u.position.offset)return;if(u=V,!g.has(u.position.paragraphId))break}if(g.has(u.position.paragraphId))return}It=u.desiredX,R$1?.activeNoteScope()&&u.pageIndex!==void 0&&Number.isInteger(u.pageIndex)&&R$1.setActiveNotePageIndex(u.pageIndex),pt({anchor:c?L.anchor:u.position,head:u.position},true);},deleteWordBackward(){if(Ee.deleteSelection())return;let s=L.head,c=yd$1(Ot(s.paragraphId),s.offset,-1);if(c===s.offset){Ee.deleteBackward();return}ke(()=>He([{op:"deleteText",paragraphId:s.paragraphId,start:c,end:s.offset}],Pe()),()=>Fe({...s,offset:c}),{rearmPending:Le()??void 0});},deleteWordForward(){if(Ee.deleteSelection())return;let s=L.head,c=yd$1(Ot(s.paragraphId),s.offset,1);if(c===s.offset){Ee.deleteForward();return}ke(()=>He([{op:"deleteText",paragraphId:s.paragraphId,start:s.offset,end:c}],Pe()),void 0,{rearmPending:Le()??void 0});},deleteForward(){if(Ee.deleteSelection())return;let s=Le()??void 0,c=L.head,u=Ot(c.paragraphId);if(c.offset<u.length){let E=Di(c,"after");if(E){ke(()=>He([{op:"removeContentControl",controlId:E.controlId,keepContent:false}],Pe()),()=>Fe(c),{rearmPending:s});return}ke(()=>He([{op:"deleteText",paragraphId:c.paragraphId,start:c.offset,end:c.offset+1}],Pe()),void 0,{rearmPending:s});return}let g=D(),b=g[g.indexOf(c.paragraphId)+1];b&&ke(()=>He([{op:"joinParagraphs",firstId:c.paragraphId,secondId:b}],Pe()),()=>Fe(c),{rearmPending:s});},...fn,...bt,setSelection:s=>pt(s),revealPage(s,c){let u=Y.pages.find(g=>g.index===s);return u?Gn(u.box.y,u.box.height,c):false},revealParagraph(s,c){tt();let u=qd$1(Y,{paragraphId:s,offset:0});if(!u)return false;let g=Y.pages.find(b=>b.index===u.pageIndex);return g?Gn(g.box.y+u.y,u.height,c):false},revealPosition(s,c){tt();let u=qd$1(Y,s);if(!u)return false;let g=Y.pages.find(b=>b.index===u.pageIndex);return g?Gn(g.box.y+u.y,u.height,{block:"nearest",...c}):false},setEditable(s){k.contentEditable=s?"true":"false",k.setAttribute("aria-readonly",s?"false":"true");},selectAll(){let s=D(),c=s[0],u=s[s.length-1];!c||!u||pt({anchor:{paragraphId:c,offset:0},head:{paragraphId:u,offset:Ot(u).length}});},hyperlinks:$t,contentControls:ce,canInsertTable:Fi,insertTable:Mu,canInsertToc:Mi,insertToc:Hu,canRefreshToc:qo,refreshToc:Hi,isInsideToc:s=>tc$1(o.part()).some(c=>c.beginParagraphId===s||c.endParagraphId===s||c.resultParagraphIds.includes(s)),retainSelection:()=>{le=L,Vn();},releaseSelection:()=>{le&&(le=null,Vn());},retainedSelection:()=>le,publishedLayout:()=>Y,overlayCoordinates:()=>Object.freeze({paintScale:i,pageOffsetX:Te?.pageOffsetX??new Map}),commitReviewOps:s=>ke(()=>{if(_e==="view")return {committed:false,rejected:true,opCount:0,reason:d};let c=s();return {committed:c.committed,rejected:!c.committed,opCount:0,...typeof c.reason=="string"?{reason:c.reason}:{}}},()=>{tt(),Ke.noteModelMoved();let c=D();return c.length===0?null:yo(Y,c,L)}),applyAutomationOps:(s,c)=>{let u={committed:false,rejected:false,opCount:0},g=c??Iu;return ke(()=>{let b=Ar(false);if(b!==null)return u={committed:false,rejected:true,opCount:0,reason:b};let E=null,_=s(U=>{let V=Ar(true,[],false);return V===null?o.ensureHyperlinkRelationship(U,g):(E=V,null)});return _===null?u={committed:false,rejected:true,opCount:0,reason:E??"this engine will not author that hyperlink target"}:u=He(_,void 0,void 0,g,false)},()=>{tt(),Ke.noteModelMoved();let b=D();return b.length===0?null:yo(Y,b,L)}),u},editingMode:()=>_e,setEditingMode:s=>{_e=s,oe=null,n.onChange?.(he());},setReviewActivationExclusions(s){Do=s===null?null:new Set(s),jn(),n.onChange?.(he());},activeReviewKey:()=>{let s=No();return s?b$2(s):null},dismissActiveReview:()=>{let s=No();s&&(Kn=b$2(s),jn(),n.onChange?.(he()));},navigation:xt,bookmarks:()=>o.bookmarks(),selectedText(){if(z)return Gd$1(Y,z);let{from:s,to:c}=Jt();return ud(Y,s,c,D())},deleteSelection(){let s=en();return s.ops.length===0?false:(ke(()=>He(s.ops,Pe()),()=>Fe(s.collapseTo)),true)},setCellSelection:Ci,layoutSession:()=>m,undo:()=>{if(_e==="view"){oe=d,n.onChange?.(he());return}Li(o.undo());},redo:()=>{if(_e==="view"){oe=d,n.onChange?.(he());return}Li(o.redo());},activeScope:()=>{let s=R$1?.activeNoteScope();return s||pe.activeScope()},setActiveScope:s=>s.kind==="note"?R$1.enterNote(s.id):s.kind!=="body"&&s.kind!=="headerFooter"?false:(R$1?.exitNote(),pe.setActiveScope(s)),insertNote:s=>R$1.insertNote(s),deleteNote:(s,c)=>R$1.deleteNote(s,c),convertNote:(s,c)=>R$1.convertNote(s,c),convertAllNotes:s=>R$1.convertAllNotes(s),setNoteProperties:s=>R$1.setNoteProperties(s),enterNote:(s,c)=>R$1.enterNote(s,c),exitNote:()=>R$1.exitNote(),notePropertiesState:()=>{let s=Ee.state().selection.head.paragraphId,c=`${o.packageRevision()}:${s}`;if(c===h)return X;let u=Bc(Ee);return X=u,h=c,u},notePreviewText:s=>Zc(o,s),applyTableCommandPlan(s){if(!s.ok)return {ok:false,code:s.code,reason:s.reason};let c=null,u=o.subscribe(g=>{g.caret&&(c=g.caret);});try{let g=Pe(),b=s.selection.kind==="adoptCommittedCaret";ke(()=>He(s.ops,g),b?()=>{let E=c;return E?Fe({paragraphId:E.paragraphId,offset:E.start}):null}:void 0,s.selection.kind==="preserveSelection"?{keepCellSelection:!0}:void 0);}finally{u();}return oe?{ok:false,code:"invalidArgs",reason:oe}:{ok:true,changed:true}},enterHeaderFooter:s=>{let c=pe.enterHeaderFooter(s);if(!c)return c;let u=pe.getActive(),g=u?Y.pages[u.pageIndex]:void 0;if(u&&g){let b=u.kind==="header"?g.header:g.footer,E=b?.box.y??(u.kind==="header"?g.box.y:g.box.y+g.box.height-1),_=b?.box.height??1;Gn(E,_,{block:"nearest"});}return c},exitHeaderFooter:()=>pe.exitHeaderFooter(),headerFooterState:()=>pe.headerFooterStateStable(o.packageRevision()),...Hc({applyOps:He,commit:ke,deleteSelectionOps:Lu,orderedStart:Lr,selectionMark:Pe,collapsedAt:Fe,isHeaderFooterOpen:()=>pe?.getActive()!==null,lastRejection:()=>oe}),...Lc({session:o,applyOps:He,commit:ke,storyScope:x,selectionMark:Pe,editingMode:()=>_e,author:()=>n.author,trackedDate:C,decodePort:()=>Ae}),focus:()=>k.focus({preventScroll:true}),setTableInteractionLabel(s){l.resolve=s;},refreshTableInteractionLabels(){gn.refreshLabels();},destroy(){A.removeEventListener("selectionchange",Ni),k.removeEventListener("keydown",Zi),k.removeEventListener("beforeinput",ji),k.removeEventListener("copy",qi),k.removeEventListener("cut",zi),k.removeEventListener("paste",Ki),k.removeEventListener("compositionstart",_i),k.removeEventListener("compositionend",Bi),A.removeEventListener("scroll",Vi,{capture:true}),e.ownerDocument.defaultView?.removeEventListener("resize",Uo),fe?.disconnect(),Re=null,zo?.destroy(),gn.destroy(),xt.destroy(),k.removeEventListener("contextmenu",Q),k.removeEventListener("click",J),k.removeEventListener("pointermove",Dn),k.removeEventListener("pointerleave",Er),et.cancel(),Ie.dispose(),a$3(k),T.destroy(),Ho(),e.replaceChildren();}};function Li(s){if(xe=null,Ke.noteModelMoved(),tt(),!s){pt(yo(Y,D(),L));return}pt({anchor:{paragraphId:s.paragraphId,offset:s.start},head:{paragraphId:s.paragraphId,offset:s.end}});}function Gn(s,c,u){let g=Ct(e);if(!g||g.clientHeight===0)return false;let b=s*i+e.offsetTop,E=c*i,_=u?.offsetPx??24,U=u?.block??"start",V=g.clientHeight;if(U==="nearest"){let se=b<g.scrollTop,ue=b+E>g.scrollTop+V;if(!se&&!ue)return true}let ie=U==="center"?b-Math.max(0,(V-E)/2):U==="nearest"&&b>g.scrollTop?b+E+_-V:b-_,K=Math.max(0,g.scrollHeight-V);return g.scrollTo({top:Math.max(0,Math.min(ie,K)),behavior:u?.behavior??"auto"}),Kt(),true}function Pe(){return ho(L)}function Jt(){return Ua(Y,L,D())}function Lr(){return Jt().from}function Ot(s){return xd$1(Y,s)}function Di(s,c){let u=o.partFor(x())??o.part(),g=Ea$1(u,s.paragraphId);return !g||g.kind!=="paragraph"?null:c==="before"?Md$1(g,s.offset):Nd$1(g,s.offset)}function en(){if(z){let u=[];for(let g of Dd$1(Y,z.cellIds)){let b=xd$1(Y,g).length;b>0&&u.push({op:"deleteText",paragraphId:g,start:0,end:b});}return {ops:u,collapseTo:Lr()}}let{from:s,to:c}=Jt();return gd(Y,o.partFor(x())??o.part(),s,c,D())}function Lu(){return en().ops}let{onSelectionChange:Ni,onCompositionStart:_i,onCompositionEnd:Bi}=Ke,zo=null,Zi=xd(Ee,n.onRequestHyperlink?{onRequestHyperlink:n.onRequestHyperlink}:{}),{onCopy:qi,onCut:zi,onPaste:Ki}=Id(Ee,Ko),ji=Sd(Ee,{isComposing:()=>Ke.isComposing(),insertPlainText:Ko});function Ko(s){let c=md(s).split(`
|
|
11
|
-
`),u=en(),g=u.collapseTo,b=c.join(""),E=[...u.ops],_=De(g.paragraphId,g.offset,b.length);b.length>0&&(E.push({op:"insertText",paragraphId:g.paragraphId,offset:g.offset,text:b}),E.push(..._));let U=[],V=0;for(let ue=0;ue<c.length-1;ue+=1)V+=c[ue].length,U.push(g.offset+V);if(U.length>0&&E.push({op:"splitParagraphMany",paragraphId:g.paragraphId,offsets:U}),E.length===0)return;let ie=new Set(o.paragraphIdsIn(x())),K=c[c.length-1],se=E.filter(ue=>!_.includes(ue));ke(()=>Xe(E,se,Pe()),()=>{if(U.length===0)return Fe({paragraphId:g.paragraphId,offset:g.offset+K.length});let ue=o.paragraphIdsIn(x()).filter(At=>!ie.has(At)),be=ue[ue.length-1];return be?Fe({paragraphId:be,offset:K.length}):null});}A.addEventListener("selectionchange",Ni),k.addEventListener("keydown",Zi),k.addEventListener("beforeinput",ji),k.addEventListener("copy",qi),k.addEventListener("cut",zi),k.addEventListener("paste",Ki),k.addEventListener("compositionstart",_i),k.addEventListener("compositionend",Bi);let jo=false;function Vo(){if(jo)return;jo=true;let s=e.ownerDocument.defaultView?.requestAnimationFrame,c=()=>{jo=false,Kt();};s?s(c):queueMicrotask(c);}let Vi=s=>{let c=Ct(e);!c||s.target!==c||Vo();};A.addEventListener("scroll",Vi,{capture:true,passive:true});let Uo=()=>{Vo();},Go=e.ownerDocument.defaultView;Go?.addEventListener("resize",Uo,{passive:true}),fe=typeof Go?.ResizeObserver=="function"?new Go.ResizeObserver(Uo):null;function Ui(){if(!fe)return;let s=Ct(e);s!==Re&&(fe.disconnect(),Re=s,s&&fe.observe(s));}Ui(),zo=fc({pagesLayer:k,container:e,scale:()=>i,pageOffsetX:s=>Te?.pageOffsetX.get(s)??0,layout:()=>Y,measurer:()=>I,selection:()=>L,setSelection:s=>pt(s),cellSelection:()=>z,setCellSelection:s=>Ci(s),focus:()=>k.focus({preventScroll:true}),activeHeaderFooter:()=>oc(pe?.getActive()??null),activeNote:()=>{let s=R$1?.activeNoteScope();return s?{scopeId:s.id,pageIndex:R$1?.activeNotePageIndex()??null}:null},enterHeaderFooter:s=>{pe?.enterHeaderFooter({rId:s.rId,pageIndex:s.pageIndex,kind:s.kind,...s.position?{position:s.position}:{}});},enterNote:(s,c,u)=>{R$1?.enterNote(s,c,u);},exitNote:s=>{R$1?.exitNote(s);},exitHeaderFooter:()=>pe?.exitHeaderFooter(),enterEmptyHeaderFooter:(s,c)=>{if(_e==="view")return;let u=m.multi?.spans,g=0,b=0;if(u&&u.length>0)for(let se=0;se<u.length;se+=1){let ue=u[se];if(g=se,b=ue.startIndex,c<ue.startIndex+ue.pageCount)break}let E=o.headerFooterResolutionBySection(),_=E[Math.min(g,Math.max(0,E.length-1))],U=Y.pages[c]?.pageFieldSource?.pageNumber??c+1,V=_?.evenAndOddHeaders&&U%2===0?"even":_?.titlePage&&c===b?"first":"default",ie=se=>{let ue=se[Math.min(g,Math.max(0,se.length-1))];return s==="header"?ue?.headers:ue?.footers},K=ie(E)?.get(V)?.rId;if(!K){if(!Ee.applyHeaderFooterLifecycle?.({op:"createHeaderFooter",sectionIndex:g,kind:s,variant:V,...V==="first"?{titlePage:true}:{},...V==="even"?{evenAndOddHeaders:true}:{}})?.ok)return;K=ie(o.headerFooterResolutionBySection())?.get(V)?.rId;}K&&pe?.enterHeaderFooter({rId:K,pageIndex:c,sectionIndex:g,kind:s,variant:V});},onContentControlWidget:(s,c)=>Se(s,c),isReadOnlyParagraph:s=>Un(s)!==null},n.pointer?{mode:n.pointer}:{});let gn=zd({pagesLayer:k,furnitureLayer:v,scale:()=>i,pageOffsetX:s=>Te?.pageOffsetX.get(s)??0,read:()=>({layout:Y,storeRevision:o.packageRevision(),selection:L,cellSelection:z,editingMode:_e,themeColors:o.documentThemeColors()}),session:()=>o,applyTableCommandPlan:s=>Ee.applyTableCommandPlan(s),label:s=>l.resolve(s)});Ge();let Du=Ee.setEditingMode.bind(Ee);return Ee.setEditingMode=s=>{Du(s),gn.update();},Ee.setTableInteractionLabel=s=>{l.resolve=s,gn.refreshLabels();},Ee.refreshTableInteractionLabels=()=>{gn.refreshLabels();},{ok:true,surface:Ee}}function mi(e){if(e==="")return;let t=globalThis.navigator?.clipboard;if(t?.writeText)try{t.writeText(e).catch(()=>{});}catch{}}function Lg(e){return e.evenPage?"even":e.firstPage?"first":"default"}function zc(e){return e.variant!==void 0?e.variant==="default"||e.variant==="first"||e.variant==="even"?e.variant:{ok:false,reason:"variant must be 'default', 'first', or 'even'"}:Lg(e)}function hi(e,t){let n=e.headerFooterState(),r=t.position??n?.editing??null;if(r!=="header"&&r!=="footer")return {ok:false,refusal:{ok:false,code:"invalidArgs",reason:"header/footer position is required when no furniture scope is open"}};let o=t.variant!==void 0||t.firstPage!==void 0||t.evenPage!==void 0?zc(t):n?.variant??"default";if(typeof o=="object"&&o.ok===false)return {ok:false,refusal:{ok:false,code:"invalidArgs",reason:o.reason}};let i=o,l=t.sectionIndex??n?.sectionIndex??0;return !Number.isInteger(l)||l<0?{ok:false,refusal:{ok:false,code:"invalidArgs",reason:"sectionIndex must be a non-negative integer"}}:{ok:true,sectionIndex:l,kind:r,variant:i}}function Dg(e){let t=e??"rejected";return t==="first-section"||t.includes("first-section")?{ok:false,code:"invalidArgs",reason:"the first section cannot link to a previous header or footer"}:{ok:false,code:"invalidArgs",reason:`header/footer lifecycle refused: ${t}`}}function Tr(e,t){if(typeof e.applyHeaderFooterLifecycle!="function")return {ok:false,code:"unsupported",reason:"header/footer lifecycle is not available"};let n=e.applyHeaderFooterLifecycle(t);return n.ok?{ok:true,changed:true}:Dg(n.reason)}function Fo(e,t,n,r){let o=e.session.headerFooterResolutionBySection()[t];if(!o)return null;let l=(n==="header"?o.headers:o.footers).get(r);return l?{rId:l.rId,partName:l.partName,inherited:l.inherited,titlePage:o.titlePage,evenAndOddHeaders:o.evenAndOddHeaders}:null}function Kc(e,t){if(typeof e.enterHeaderFooter!="function")return {ok:false,code:"unsupported",reason:"header/footer editing is not available"};let n=t.sectionIndex??0;if(!Number.isInteger(n)||n<0)return {ok:false,code:"invalidArgs",reason:"sectionIndex must be a non-negative integer"};let r=t.position,a=zc(t);if(typeof a=="object"&&a.ok===false)return {ok:false,code:"invalidArgs",reason:a.reason};let o=a,l=Fo(e,n,r,o)?.rId,d=false;if(!l){let y=Tr(e,{op:"createHeaderFooter",sectionIndex:n,kind:r,variant:o,...o==="first"?{titlePage:true}:{},...o==="even"?{evenAndOddHeaders:true}:{}});if(!y.ok)return y;d=true,l=Fo(e,n,r,o)?.rId;}return l?e.enterHeaderFooter({rId:l,kind:r,sectionIndex:n,variant:o})?{ok:true,changed:d}:{ok:false,code:"invalidArgs",reason:"the header/footer relationship could not be opened"}:{ok:false,code:"notFound",reason:`no ${r} story is available to edit`}}function jc(e,t){let n=hi(e,t);if(!n.ok)return n.refusal;let r=e.headerFooterState(),a=r?.rId,o=Tr(e,{op:"deleteHeaderFooter",sectionIndex:n.sectionIndex,kind:n.kind,variant:n.variant});return o.ok&&a&&r?.editing===n.kind&&r.sectionIndex===n.sectionIndex&&r.variant===n.variant&&e.exitHeaderFooter(),o}function Vc(e,t){let n=hi(e,t);if(!n.ok)return n.refusal;if(n.sectionIndex===0)return {ok:false,code:"invalidArgs",reason:"the first section cannot link to a previous header or footer"};let r=e.headerFooterState(),a=r?.editing===n.kind&&r.sectionIndex===n.sectionIndex&&r.variant===n.variant,o=Tr(e,{op:"linkToPrevious",sectionIndex:n.sectionIndex,kind:n.kind,variant:n.variant});if(!o.ok)return o;if(a){let i=Fo(e,n.sectionIndex,n.kind,n.variant);i?e.enterHeaderFooter({rId:i.rId,kind:n.kind,sectionIndex:n.sectionIndex}):e.exitHeaderFooter();}return o}function Uc(e,t){let n=hi(e,t);if(!n.ok)return n.refusal;let r=e.headerFooterState(),a=!!r&&r.editing===n.kind&&r.sectionIndex===n.sectionIndex&&r.variant===n.variant,o=r?.rId,i=Tr(e,{op:"unlinkFromPrevious",sectionIndex:n.sectionIndex,kind:n.kind,variant:n.variant});if(!i.ok)return i;let l=Fo(e,n.sectionIndex,n.kind,n.variant);return a&&l&&l.rId!==o&&e.enterHeaderFooter({rId:l.rId,kind:n.kind,sectionIndex:n.sectionIndex}),i}function Gc(e,t){let n=e.headerFooterState(),r=t.sectionIndex??n?.sectionIndex;return Tr(e,{op:"setSectionFurnitureOptions",...r!==void 0?{sectionIndex:r}:{},...t.titlePage!==void 0?{titlePage:t.titlePage}:{},...t.evenAndOddHeaders!==void 0?{evenAndOddHeaders:t.evenAndOddHeaders}:{},...t.headerDistanceTwips!==void 0?{headerDistanceTwips:t.headerDistanceTwips}:{},...t.footerDistanceTwips!==void 0?{footerDistanceTwips:t.footerDistanceTwips}:{}})}function Wc(e,t){return e.activeScope().kind!=="headerFooter"?{ok:false,code:"unsupported",reason:"insertPageField requires an open header or footer scope"}:typeof e.insertPageField!="function"?{ok:false,code:"unsupported",reason:"page field insertion is not available"}:e.insertPageField(t.field)?{ok:true,changed:true}:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"page field insertion was refused"}}function Xc(e,t){let n=e.activeScope();return n.kind==="headerFooter"?{ok:false,code:"invalidArgs",reason:"cannot insert a note reference inside a header or footer"}:n.kind==="note"?{ok:false,code:"invalidArgs",reason:"cannot insert a note reference inside another note"}:typeof e.insertNote!="function"?{ok:false,code:"unsupported",reason:"insertNote is not available"}:e.insertNote(t.noteKind)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"insertNote was refused"}}function $c(e,t){return typeof e.deleteNote!="function"?{ok:false,code:"unsupported",reason:"deleteNote is not available"}:e.deleteNote(t.noteKind,t.noteId)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"deleteNote was refused"}}function Yc(e,t){return typeof e.convertNote!="function"?{ok:false,code:"unsupported",reason:"convertNote is not available"}:e.convertNote(t.fromKind,t.noteId)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"convertNote was refused"}}function Qc(e,t){return typeof e.convertAllNotes!="function"?{ok:false,code:"unsupported",reason:"convertAllNotes is not available"}:e.convertAllNotes(t.fromKind)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"convertAllNotes was refused"}}function Jc(e,t){if(typeof e.setNoteProperties!="function")return {ok:false,code:"unsupported",reason:"setNoteProperties is not available"};let n=t.scope??"document";return e.setNoteProperties({scope:n,sectionIndex:t.sectionIndex,footnote:t.footnote,endnote:t.endnote})?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"setNoteProperties was refused"}}function eu(e,t,n){switch(t.type){case "toggleMark":{let r=Ta.get(t.mark);e.toggleRunProperty(r.localName,r.attributes);break}case "setMarkAttr":{let r=Pa(t);if(!r.ok)return {ok:false,code:r.code,reason:r.reason};e.setRunProperty(r.localName,r.attributes);break}case "clearFormatting":e.clearFormatting();break;case "setLineSpacing":e.setParagraphProperty("spacing",t.rule==="multiple"?{line:String(Math.round(t.value*240)),lineRule:"auto"}:{line:String(Math.round(t.value*20)),lineRule:t.rule==="exact"?"exact":"atLeast"},{mergeAttributes:true});break;case "setParagraphSpacing":e.setParagraphProperty("spacing",{...t.beforePt!==void 0?{before:t.beforePt===null?null:String(Math.round(t.beforePt*20))}:{},...t.afterPt!==void 0?{after:t.afterPt===null?null:String(Math.round(t.afterPt*20))}:{}},{mergeAttributes:true});break;case "setAlignment":e.setParagraphProperty("jc",{val:t.align==="justify"?"both":t.align});break;case "setParagraphStyle":{if(!e.session.documentStyles().some(a=>a.type==="paragraph"&&a.styleId===t.styleId))return {ok:false,code:"invalidArgs",reason:`style '${t.styleId}' is not a paragraph style of this document`};e.setParagraphProperty("pStyle",{val:t.styleId});break}case "setIndent":{e.setIndent({...t.left!==void 0?{left:t.left}:{},...t.right!==void 0?{right:t.right}:{},...t.firstLine!==void 0?{firstLine:t.firstLine}:{}});break}case "setPageSetup":{let r=t.scope==="section"?e.state().selection.head.paragraphId:void 0,a=t.pageWidth,o=t.pageHeight;if(t.orientation!==void 0&&(a!==void 0||o!==void 0)){let l=r?e.sectionPropertiesAt(r):e.sectionProperties(),d=a??l.pageSize.widthTwips,p=o??l.pageSize.heightTwips;a=t.orientation==="landscape"?Math.max(d,p):Math.min(d,p),o=t.orientation==="landscape"?Math.min(d,p):Math.max(d,p);}if(!e.setSectionProperties({...a!==void 0?{pageWidthTwips:a}:{},...o!==void 0?{pageHeightTwips:o}:{},...t.orientation!==void 0?{orientation:t.orientation}:{},...t.marginTop!==void 0?{marginTopTwips:t.marginTop}:{},...t.marginRight!==void 0?{marginRightTwips:t.marginRight}:{},...t.marginBottom!==void 0?{marginBottomTwips:t.marginBottom}:{},...t.marginLeft!==void 0?{marginLeftTwips:t.marginLeft}:{},...r!==void 0?{anchorParagraphId:r}:{}}))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the page setup change was refused"};break}case "toggleList":if(!e.toggleList(t.kind))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the list change was refused"};break;case "adjustIndent":if(!e.adjustIndent(t.direction))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the selection is already at that indent level"};break;case "insertBreak":if(t.kind==="section"){if(!e.insertSectionBreak())return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the section break was refused"};break}if(t.kind==="page"){e.insertPageBreak();break}e.insertLineBreak();break;case "insertHyperlink":{let r=t.href.startsWith("#");if(!e.hyperlinks.applyHyperlink({...r?{anchor:t.href.slice(1)}:{url:t.href},...t.text!==void 0?{text:t.text}:{}}))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the link was refused: the target is not an allowed scheme, or there is no text to link"};break}case "removeHyperlink":if(!e.hyperlinks.removeHyperlink())return {ok:false,code:"notFound",reason:"there is no hyperlink at the selection"};break;case "insertText":e.type(t.text);break;case "deleteText":e.deleteSelection();break;case "undo":e.undo();break;case "redo":e.redo();break;case "insertTable":if(!e.insertTable(t.rows,t.cols))return {ok:false,code:"unsupported",reason:e.state().lastRejection??"the table could not be inserted here"};break;case "insertToc":if(!e.insertToc())return {ok:false,code:"unsupported",reason:e.state().lastRejection??"the table of contents could not be inserted"};break;case "refreshToc":if(!e.refreshToc(t.tocId,t.mode))return {ok:false,code:"unsupported",reason:e.state().lastRejection??"the table of contents could not be refreshed"};break;case "editHeaderFooter":return Kc(e,t);case "exitHeaderFooter":return typeof e.exitHeaderFooter=="function"&&e.exitHeaderFooter(),{ok:true,changed:false};case "removeHeaderFooter":return jc(e,t);case "linkHeaderFooterToPrevious":return Vc(e,t);case "unlinkHeaderFooterFromPrevious":return Uc(e,t);case "setHeaderFooterOptions":return Gc(e,t);case "insertPageField":return Wc(e,t);case "insertNote":return Xc(e,t);case "deleteNote":return $c(e,t);case "convertNote":return Yc(e,t);case "convertAllNotes":return Qc(e,t);case "setNoteProperties":return Jc(e,t);case "insertRow":case "deleteRow":case "insertColumn":case "deleteColumn":case "deleteTable":case "setCellFill":case "setTableCellVerticalAlignment":case "setTableBorders":case "commitTableColumnDividerResize":case "commitTableRightEdgeResize":case "mergeCells":case "splitCell":case "toggleHeaderRow":case "selectTableRegion":case "setTableProperties":{if(!Sn(t))return {ok:false,code:"unsupported",reason:"unsupported command"};let r=n?.admittedTablePlan??Nt({command:t,part:e.session.part(),layout:e.layout(),storeRevision:e.session.revision(),selection:e.state().selection,cellSelection:e.state().cellSelection,themeColors:e.session.documentThemeColors(),editable:e.session.editable,viewing:e.editingMode()==="view"});return e.applyTableCommandPlan(r)}case "selectAll":return e.selectAll(),{ok:true,changed:false};case "copy":return mi(e.selectedText()),{ok:true,changed:false};case "cut":mi(e.selectedText()),e.deleteSelection();break;case "paste":e.insertPlainText(t.text);break;case "setSelection":{if("range"in t&&wa(t.range))return e.setSelection(t.range),e.revealPosition(t.range.head,{block:"nearest"}),{ok:true,changed:false};let r="anchor"in t&&Pt(t.anchor)?{anchor:t.anchor}:"range"in t&&In(t.range)?{range:t.range}:null;if(r===null)return {ok:false,code:"unsupported",reason:"unsupported selection form"};let a=fl(e.session.part(),e.session.paragraphAnchors(),r);return a.ok?(e.setSelection(a.selection),e.revealPosition(a.selection.head,{block:"nearest"}),{ok:true,changed:false}):a}default:return yr(t)?Ul(e,t,n?.editor):{ok:false,code:"unsupported",reason:"unsupported command"}}return null}function tu(e){return t=>{for(let n of e.customNodeDiagnostics)try{n(t);}catch{}}}function nu(e,t){t.customNodePayloadNamespaces.length!==0&&e.session.sweepCustomNodePayloads(t.customNodePayloadNamespaces);}var Ng="http://schemas.microsoft.com/office/word/2010/wordml",_g="http://schemas.microsoft.com/office/word/2012/wordml",Bg=32;function Wt(e){return Jb(e)}function Zg(e){return e.kind==="textValue"?[]:e.children}function Oo(e){if(e.kind==="textValue")return e.value.length;if(e.kind==="tab"||e.kind==="hardBreak")return 1;if(e.kind==="runProperties"||e.kind==="generic")return 0;if(Wt(e)){let n=0;for(let r of ee(e))n+=Oo(r);return n}let t=0;for(let n of Zg(e))t+=Oo(n);return t}function yi(e){for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="contentControlProperties"||t.localName==="sdtPr"))return t}function qg(e){if(e.kind!=="textValue"){for(let t of e.attributes)if(t.localName==="val"&&t.namespaceUri===la)return t.value}}function vi(e,t){if(e){for(let n of e.children)if(n.kind!=="textValue"&&n.localName===t)return qg(n)}}function zg(e){if(!e)return "richText";for(let t of e.children){if(t.kind==="textValue")continue;let n=Kg(t);if(n!==void 0)return n}return "richText"}function Kg(e){if(e.kind==="textValue")return;let t=e.kind,n=e.localName,r=e.namespaceUri;if(t==="contentControlDropDownList"||n==="dropDownList")return "dropdown";if(t==="contentControlComboBox"||n==="comboBox")return "comboBox";if(t==="contentControlDate"||n==="date")return "date";if(n==="picture")return "picture";if(t==="contentControlText"||n==="text")return "plainText";if(n==="richText")return "richText";if(n==="checkbox"&&(r===Ng||t==="contentControlCheckbox"))return "checkbox";if(n==="repeatingSection"&&r===_g)return "repeatingSection"}function bi(e){let t=vi(e,"lock");return t==="contentLocked"||t==="sdtContentLocked"}function jg(e,t){if(bi(yi(t)))return true;let n=Fa$1(e,t.id);for(;n;){if(Wt(n)&&bi(yi(n)))return true;n=Fa$1(e,n.id);}return false}function Ii(e,t){let n=yi(e),r=vi(n,"tag"),a=vi(n,"alias"),o=t?jg(t,e):bi(n);return {id:e.id,controlType:zg(n),...r!==void 0?{tag:r}:{},...a!==void 0?{alias:a}:{},...o?{locked:true}:{}}}function xi(e,t){return t?!(t.tag!==void 0&&e.tag!==t.tag||t.alias!==void 0&&e.alias!==t.alias||t.controlType!==void 0&&e.controlType!==t.controlType):true}function Vg(e){let t=[],n=(r,a,o,i)=>{let l=a;for(let d of r)if(d.kind!=="paragraphProperties"){if(d.kind==="run"){l+=Oo(d);continue}if(d.kind==="hyperlink"){l=n(d.children,l,o,i);continue}if(Wt(d)&&i<Bg){let p=l,y=o+1;l=n(ee(d),l,y,i+1),t.push({control:d,start:p,end:l,depth:y});continue}l+=Oo(d);}return l};return n(e.children,0,-1,0),t}function Si(e,t,n){return Vg(e).filter(r=>t>=r.start&&t<r.end).sort((r,a)=>a.depth-r.depth).map(r=>Ii(r.control,n))}function Ug(e){let t=[],n=r=>{if(r.kind!=="textValue"){Wt(r)&&t.push(Ii(r,e));for(let a of r.children)n(a);}};return n(e.root),t}function ki(e,t){let n=[],r=Fa$1(e,t);for(;r;)Wt(r)&&n.push(Ii(r,e)),r=Fa$1(e,r.id);return n.reverse()}function ru(e,t){return e?Ug(e.session.part()).filter(n=>xi(n,t)):[]}function Ti(e,t){if(!e)return null;let n=e.session.part(),{paragraphId:r,offset:a}=e.state().selection.head,o=Ea$1(n,r);if(o&&o.kind==="paragraph"){for(let l of Si(o,a,n))if(xi(l,t))return l}let i=ki(n,r);for(let l=i.length-1;l>=0;l-=1){let d=i[l];if(xi(d,t))return d}return null}function Pi(e){return e.type==="setContentControlValue"||e.type==="removeContentControl"}function Gg(e){return typeof e=="object"&&e!==null&&"container"in e&&"path"in e}function Wg(e){return typeof e=="object"&&e!==null&&"from"in e&&"to"in e}function Xg(e){let t=n=>{if(n.kind==="textValue")return null;if(n.kind==="body")return n;for(let r of n.children){let a=t(r);if(a)return a}return null};return t(e.root)}function Ao(e){let t=[];for(let n of e)n.kind!=="textValue"&&(n.kind==="paragraph"||n.kind==="table"||Wt(n))&&t.push(n);return t}function $g(e){let t=[];for(let n of e.children)if(n.kind==="tableRow")for(let r of n.children)r.kind==="tableCell"&&t.push(...Ao(r.children));return t}function Yg(e){return e.kind==="table"?$g(e):Wt(e)?Ao(ee(e)):e.kind==="body"?Ao(e.children):[]}function Qg(e,t,n){if(Wt(t))return {ok:true,controlId:t.id};if(t.kind==="paragraph"){let r=n??0;for(let i of Si(t,r,e))return {ok:true,controlId:i.id};let o=ki(e,t.id).at(-1);if(o)return {ok:true,controlId:o.id}}return {ok:false,code:"notFound",reason:"no content control at the addressed block"}}function Jg(e,t){if(t.container.part!=="body")return {ok:false,code:"unsupported",reason:"only the body container is supported",target:t};let n=Xg(e);if(!n)return {ok:false,code:"notFound",reason:"the document body was not found",target:t};if(t.path.length===0)return {ok:false,code:"notFound",reason:"DocLocation path is empty",target:t};let r=Ao(n.children),a=null;for(let i=0;i<t.path.length;i+=1){if(a=r[t.path[i]]??null,!a)return {ok:false,code:"notFound",reason:`block index ${t.path[i]} is out of range`,target:t};i<t.path.length-1&&(r=Yg(a));}if(!a)return {ok:false,code:"notFound",reason:"the addressed block was not found",target:t};let o=Qg(e,a,t.offset);return o.ok?o:{...o,target:t}}function em(e,t,n){let r=ur(e,t,n);if(!r.ok)return {ok:false,code:r.code,reason:r.reason,target:n};let a=Ea$1(e,r.span.nodeId);if(!a||a.kind!=="paragraph")return {ok:false,code:"notFound",reason:`paragraph '${n.paraId}' was not found`,target:n};let o=r.span.start;for(let d of Si(a,o,e))return {ok:true,controlId:d.id};let l=ki(e,a.id).at(-1);return l?{ok:true,controlId:l.id}:{ok:false,code:"notFound",reason:`no content control encloses paragraph '${n.paraId}'`,target:n}}function ou(e,t){if(t===void 0){let r=Ti(e);return r?{ok:true,controlId:r.id}:{ok:false,code:"notFound",reason:"no content control at the current selection"}}if(Wg(t))return {ok:false,code:"unsupported",reason:"DocRange targeting is not supported for content controls",target:t};let n=e.session.part();return Gg(t)?Jg(n,t):Pt(t)?em(n,e.session.paragraphAnchors(),t):{ok:false,code:"invalidArgs",reason:"unrecognized target shape",target:t}}function au(e){switch(e){case "locked":case "bound":case "typeMismatch":case "invalidArgs":case "unsupported":return e;case "unknown-control":return "notFound";default:return "unsupported"}}function iu(e){switch(e){case "locked":return "the content control is locked";case "bound":return "the content control is bound to external data";case "typeMismatch":return "the value does not match the control type";case "invalidArgs":return "the value is not valid for this control";case "unsupported":return "this control type is not supported";case "unknown-control":return "the content control was not found";default:return `the edit was refused (${e})`}}function tm(e,t){return {ok:false,code:au(e),reason:iu(e),...t!==void 0?{target:t}:{}}}function nm(e,t,n,r){return r?.scope&&r.scope.kind!=="body"?{ok:false,refusal:{ok:false,code:"unsupported",reason:"only the body scope is supported"}}:t?n==="view"||!t.session.editable?{ok:false,refusal:{ok:false,code:"locked",reason:"the document is read-only"}}:e.type==="setContentControlValue"&&typeof e.value!="string"?{ok:false,refusal:{ok:false,code:"invalidArgs",reason:"setContentControlValue requires a string value"}}:{ok:true}:{ok:false,refusal:{ok:false,code:"notFound",reason:"no document is loaded"}}}function wi(e,t,n,r){let a=nm(e,t,n,r);if(!a.ok)return a.refusal;let o=ou(t,e.target);if(!o.ok)return {ok:false,code:o.code,reason:o.reason};let i=e.type==="setContentControlValue"?{op:"setContentControlValue",controlId:o.controlId,value:e.value}:{op:"removeContentControl",controlId:o.controlId},l=xf(t.session.part(),i);return l?{ok:false,code:au(l),reason:iu(l)}:{ok:true}}function su(e,t){let n=ou(e,t.target);if(!n.ok){let l=n.target??t.target;return {ok:false,code:n.code,reason:n.reason,...l!==void 0?{target:l}:{}}}let r=e.session.revision(),a=ho(e.state().selection),o=t.type==="setContentControlValue"?{op:"setContentControlValue",controlId:n.controlId,value:t.value}:{op:"removeContentControl",controlId:n.controlId},i=e.session.applyTreeOps([o],a,a);return i.rejected?tm(i.reason??"unsupported",t.target):(e.layout(),{ok:true,changed:e.session.revision()!==r})}var lu=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function Mo(e){let t=e?.defaultFont?.family;return t!==void 0&&lu.test(t)?t:oo.family}function du(e,t){let n=new Map,r=l=>{if(l===void 0||!lu.test(l))return;let d=l.toLowerCase();n.has(d)||n.set(d,l);};r(Mo(e));let a=e?.substitutions??[],o=new Set(a.map(l=>l.to.family.toLowerCase()));for(let l of a)r(l.from.family);for(let l of e?.sources??[])o.has(l.request.family.toLowerCase())||r(l.request.family);for(let l of t)r(l);let i=[...n.values()];return i.sort((l,d)=>l<d?-1:l>d?1:0),i}var rm={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}};function cu(e$1,t){let n=[],r=[],a=t.aggregateBudget,o=new Set;for(let i$1 of e$1){let l=rm[i$1.style],d=Object.freeze({family:i$1.family,weight:l.weight,style:l.style});if(i$1.family.trim().length===0){r.push({request:d,partName:i$1.partName,reason:"malformed"});continue}let p=e(d);if(!(t.shadowedRequests?.has(p)||o.has(p))){if(o.add(p),i$1.bytes.byteLength>t.maxFontBytes||i$1.bytes.byteLength>a){r.push({request:d,partName:i$1.partName,reason:"overLimit"});continue}a-=i$1.bytes.byteLength,n.push({request:d,id:`embedded:${i$1.partName}#${i$1.style}`,bytes:i$1.bytes,hash:i(i$1.bytes),faceIndex:0});}}return {sources:n,dropped:r}}var om="The quick brown fox 0123 \u2014 {}#@",am=["monospace","serif"],im=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function uu(e){if(!e)return ()=>true;let t=new Map,n=r=>(e.font=r,e.measureText(om).width);return r=>{let a=t.get(r);if(a!==void 0)return a;if(!im.test(r))return t.set(r,true),true;let o=false;for(let i of am){let l=n(`32px ${i}`);if(n(`32px "${r}", ${i}`)!==l){o=true;break}}return t.set(r,o),o}}function fu(e,t,n){let r=[];for(let a of e)t(a)||n(a)||r.push(a);return r}var pu=Object.freeze({installed:0,alias:()=>{},dispose(){}});function sm(e){let t=0;for(let n of e)for(let r=0;r<n.length;r+=1)t=t*31+n.charCodeAt(r)>>>0;return `docx-embedded-${t.toString(36)}`}function lm(){let t=(typeof document<"u"?document:void 0)?.fonts;return !t||typeof FontFace>"u"?{}:{fontSet:t,createFontFace:(n,r,a)=>new FontFace(n,r.slice().buffer,a)}}async function gu(e,t=lm(),n=[]){let{fontSet:r,createFontFace:a}=t;if(!r||!a||e.length===0)return pu;let o=new Map;for(let p of e){let y=p.request.family,C=o.get(y);C?C.push(p):o.set(y,[p]);}let i=new Map,l=[];if(await Promise.all([...o].map(async([p,y])=>{let C=sm(y.map(I=>I.hash)),S=false;await Promise.all(y.map(async I=>{try{let O=a(C,I.bytes,{weight:String(I.request.weight),style:I.request.style});await O.load(),r.add(O),l.push(O),S=!0;}catch{}})),S&&i.set(p,C);})),l.length===0)return pu;for(let p of n){if(i.has(p.from.family))continue;let y=i.get(p.to.family);y!==void 0&&i.set(p.from.family,y);}let d=false;return {installed:l.length,alias:p=>d?void 0:i.get(p),dispose(){if(!d){d=true;for(let p of l)try{r.delete(p);}catch{}}}}}function hu(e){let t=1.3333333333333333;return {x:e.x*t,y:e.y*t,width:e.width*t,height:e.height*t}}var fm=Object.freeze({kind:"body"}),pm=Object.freeze([]),Xt="comments and tracked changes require the pro review module (@docx-editor.dev/pro)";function gm(e$1){let t=e$1.locale&&e$1.locale in locales?e$1.locale:"en",r={title:createT(deepMerge(en,t==="en"?void 0:locales[t]),t)("toolbar.tableOfContents")},a$3=e$1.container??null,o=a$2(e$1.modules),i=tu(o),l$1=o.review!==null,d$1=null,p=e$1.mode==="view"?"viewing":"editing",y=null,C=false,S$1=null,I=e$1.mode??"edit",O=e$1.zoom!==void 0&&Number.isFinite(e$1.zoom)&&e$1.zoom>=.1&&e$1.zoom<=5?e$1.zoom:1,m=null,F=null,B=null,A=null,k=null,j=null,P=[],v=()=>P[P.length-1]??{},T=false,M,G,$=null;function L(){$?.dispose(),$=null;}let z=0,oe,re=()=>typeof e$1.fonts=="function"?oe:e$1.fonts,we=-1,le=false,Oe=null,Ue=f=>(Oe||(Oe=uu(a$3?Rn(a$3.ownerDocument):null)),Oe(f)),xe=null,at=()=>{let f=re();return (xe===null||xe.configuration!==f)&&(xe={configuration:f,families:new Set([...(f?.sources??[]).map(w=>w.request.family),...(f?.substitutions??[]).map(w=>w.from.family)].filter(w=>typeof w=="string"&&w.trim().length>0).map(w=>w.toLowerCase()))}),xe.families},Le=f=>at().has(f.toLowerCase())||$?.alias(f)!==void 0,Ne=()=>!m||le?pm:fu(m.session.documentFonts(),Le,Ue),Xe=0,De=null,pe=null,R$1=-1,X=0,h=-1;function x(){Xe+=1;}let N$1={change:new Set,selectionChange:new Set,error:new Set};function D(f){for(let w of [...N$1.error])w(f);}function Z(f){for(let w of [...N$1.change])w(f);}function ee(){if(N$1.selectionChange.size===0)return;let f=$e();for(let w of [...N$1.selectionChange])w(f);}function ne(){B?.(),B=null,m?.destroy(),m=null,A=null,k=null,j=null,X+=1;}let ge=()=>O*(96/72);function Ce(f){if(!a$3){d$1=f,F=null,x();return}ne();let w=gi(a$3,f,{scale:ge(),defaultFontFamily:Mo(re()),...e$1.translate?{drawingStrings:c$1(e$1.translate)}:{},...e$1.author?{author:e$1.author}:{},editingMode:p==="suggesting"?"suggest":p==="viewing"?"view":"edit",...l$1?{}:{revisionDisplayMode:"proposed"},...o.review?{reviewModel:{...o.review,collectReviewItems:H=>o.review.collectReviewItems(o.customNodes.length>0?{...H,customNodes:o.customNodes,...o.customNodeDiagnostics.length>0?{reportCustomNodeDiagnostic:i}:{}}:H)}}:{},...M?{measurer:M,...G?{producer:G}:{}}:{},...$?{fontAlias:$.alias}:{},...e$1.tableInteractionLabel?{tableInteractionLabel:e$1.tableInteractionLabel}:{},...e$1.imageDecodePort?{imageDecodePort:e$1.imageDecodePort}:{},onHyperlinkPopover:H=>v().onPopover?.(H),onRequestHyperlink:()=>v().onRequest?.(),onTrackedChange:()=>{st||(st=true,x(),ee());},tocLabels:r,onChange:H=>{if(!m)return;x();let W=H.pendingFormat!==k;k=H.pendingFormat;let q=m.headerFooterState?.(),Q=q?.editing&&q.rId?`${q.editing}:${q.rId}`:null,de=Q!==j;j=Q,!(Ca(H.selection,A)&&!W&&!de)&&(A=H.selection,ee());}});if(!w.ok){F=w.detail?`${w.reason}: ${w.detail}`:w.reason,x(),D(kn(w.reason,`failed to open document: ${F}`));return}F=null,m=w.surface,Fr(),nu(m,o),X+=1,m.setEditable(p!=="viewing"),y!==null&&m.setReviewActivationExclusions(y),A=m.state().selection,B=m.session.subscribe(H=>{let W={revision:H.toRevision,created:H.created,deleted:H.deleted,dirty:H.dirty};x(),Z(W);}),x(),Z({revision:m.session.revision()}),ee(),we!==z&&(we=z,Be(z,m));}function Je(f){if(z+=1,M=void 0,G=void 0,oe=void 0,L(),le=false,a$3){let w=Ct(a$3);w&&(w.scrollTop=0,w.scrollLeft=0);}Ce(f);}function qe(f){try{e$1.onFontError?.(f);}catch{}D(f);}async function Be(f,w){let H=e$1.fonts,W=w.session.embeddedFonts();if(!(!H&&W.length===0)){le=true,x();try{let q=typeof H=="function"?await H({families:w.session.documentFonts().slice(0,va),defaultFamily:Mo(re())}):H;if(T||f!==z){f===z&&(le=!1);return}if(oe=q,!q&&W.length===0){le=!1,x();return}let Q=(q&&"maxFontBytes"in q?q.maxFontBytes:void 0)??a$1,de=(q?.sources??[]).reduce((fe,Re)=>fe+Re.bytes.byteLength,0),Me=new Set((q?.sources??[]).filter(fe=>fe.request.family.trim().length>0).map(fe=>e(fe.request))),J=cu(W,{maxFontBytes:Q,aggregateBudget:Math.max(0,c-de),shadowedRequests:Me});for(let fe of J.dropped)qe(new a(fe.reason,fe.reason==="overLimit"?`embedded font ${fe.request.family} (${fe.partName}) exceeds the font byte budget`:`embedded font part ${fe.partName} declares an invalid family name`,{request:fe.request}));let Se=ao({epoch:f,...q},J);if(Se.sources.length===0){le=!1,x(),q&&qe(new a("missing","the supplied font configuration contains no usable sources; the fixed measurer stays in effect"));return}let ce=await ro(Se);if(T||f!==z){xn(ce),f===z&&(le=!1);return}let he=new Set;for(let fe of J.sources){let Re=ce.fonts.resolve(fe.request);Re instanceof d&&(qe(bn(Re)),he.add(fe.id));}if(he.size>0&&he.size<J.sources.length){let fe=J.sources.filter(zt=>!he.has(zt.id)),Re=ce;if(ce=await ro(ao({epoch:f,...q},{sources:fe})),xn(Re),T||f!==z){xn(ce),f===z&&(le=!1);return}}else if(he.size===J.sources.length&&!q){le=!1,x();return}let ze=[...q?.sources??[],...J.sources].filter(fe=>!he.has(fe.id)).map(fe=>{let Re=ce.fonts.resolve(fe.request);return Re instanceof d||Re.id!==fe.id?null:{request:fe.request,id:Re.id,bytes:Re.bytes,hash:Re.hash,faceIndex:Re.faceIndex}}).filter(fe=>fe!==null),Te=await gu(ze,void 0,Se.substitutions??[]);if(T||f!==z){Te.dispose(),xn(ce),f===z&&(le=!1);return}L(),$=Te;let qt=jd$1(ge(),{context:a$3?Rn(a$3.ownerDocument):null,...$?{fontAlias:$.alias}:{}}),Ft=new Map;if(M=ld$1({shaper:ce.shaper,resolveFont:fe=>{let Re=fe.fontFamily??Se.defaultFont.family;if(Re.trim().length===0)return null;let zt={family:Re,weight:fe.bold?700:400,style:fe.italic?"italic":"normal"},Ge=e(zt);if(Ft.has(Ge))return Ft.get(Ge)??null;let Kt;try{Kt=ce.fonts.resolve(zt);}catch{return Ft.set(Ge,null),null}let qn=Kt instanceof d?null:Kt;return Ft.set(Ge,qn),qn},fallback:qt.measurer,shapingLibrary:g,unicodeDataVersion:"16.0.0",...Se.language?{language:Se.language}:{}}),G=`shaped:${ce.operation.extensionFingerprint}+fallback:${qt.producer}@scale:${ge()}`,le=!1,m){let fe=m.session.save(),Re=typeof document<"u"&&document.activeElement!==null&&a$3!==null&&a$3.contains(document.activeElement);try{Ce(fe),Re&&m?.focus();}catch(zt){M=void 0,G=void 0,m||(d$1=fe,Ce(fe)),qe(bn(zt));}}else x();}catch(q){if(T||f!==z)return;le=false,x(),qe(bn(q));}}}let Ae=null;function Ie(f){return f===null?Ae=null:Ae?.id!==f&&(Ae=Object.freeze({id:f})),Ae}function Mn(){let f=m?.state()??null;return {scope:m?.activeScope?.()??fm,isLoading:F===null&&m===null&&d$1===null,parseError:F,editable:m!==null&&m.session.editable&&I!=="view"&&p!=="viewing",zoom:O,selection:Ba(m),selectionCollapsed:f===null||f.selection.anchor.paragraphId===f.selection.head.paragraphId&&f.selection.anchor.offset===f.selection.head.offset,formatting:Gl(m),table:za(m),tocContext:Ie(f?.contextTocId??null),image:wt(m),page:{current:qa(m),total:Za(m)},canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,pageSetup:_a(m),reviewPaneOpen:st,hasReviewContent:m?.session.hasReviewContent()??false,editingMode:p,lastRejection:f?.lastRejection??S$1,fontSubstitutions:Ne()}}function $e(){if(De&&h===Xe)return De;let f=De,w=m?.state().selection??null,H=Ca(w,pe);pe=w;let W=m?.session.packageRevision()??-1,q=W===R$1;R$1=W;let Q=Mn(),de=Q;if(f){let Me=Ol(Q.formatting,f.formatting)?f.formatting:Q.formatting,J=Al(Q.page,f.page)?f.page:Q.page,Se=Ml(Q.pageSetup??null,f.pageSetup??null)?f.pageSetup:Q.pageSetup,ce=Hl(Q.selection,f.selection)?f.selection:Q.selection,he=Zl(Q.image,f.image)?f.image:Q.image,ze=f.fontSubstitutions!==void 0&&Q.fontSubstitutions!==void 0&&f.fontSubstitutions.length===Q.fontSubstitutions.length&&Q.fontSubstitutions.every((Te,qt)=>f.fontSubstitutions[qt]===Te)?f.fontSubstitutions:Q.fontSubstitutions;de={...Q,formatting:Me,page:J,pageSetup:Se,selection:ce,image:he,fontSubstitutions:ze},Ll(de,f)&&H&&q&&(de=f);}return De=co(de),h=Xe,De}if(e$1.document){let f=Ra(e$1.document);f?Je(f):(F="a DocumentHandle cannot be re-loaded; pass DOCX bytes",D(kn("unsupported",F)));}let it=0,me=null,ye="",Y=null,bt=true,fn=null;function $t(){let f=`${m?.session.packageRevision()??-1}:${m?.session.revision()??-1}`,w=pn(),H=_n()?.anchorY??null;return (m!==me||f!==ye||w!==Y||st!==bt||H!==fn)&&(me=m,ye=f,Y=w,bt=st,fn=H,it+=1),it}function xt(f){return f.kind==="revision"?f.ranges[0]??null:f.range}let It=new WeakMap;function Hn(f){let w=It.get(f);if(w)return w;let H=k$2(f,W=>R(W));for(let W of f.pages){for(let q of [W.header,W.footer])if(q)for(let Q of S(q.fragments))H.has(Q.paragraphId)||H.set(Q.paragraphId,{pageIndex:W.index,contentY:q.box.y,fragmentY:Q.box.y,...Q.lines?{lines:Q.lines}:{}});for(let q of [W.footnotes,W.endnotes])if(q)for(let Q of q.notes)for(let de of S(Q.fragments))H.has(de.paragraphId)||H.set(de.paragraphId,{pageIndex:W.index,contentY:Q.box.y,fragmentY:de.box.y,...de.lines?{lines:de.lines}:{}});}return It.set(f,H),H}let Pr=new WeakMap;function et(f){let w=Pr.get(f);if(w)return w;let H=new Map;for(let W of f.pages)for(let q of [W.footnotes,W.endnotes])if(q)for(let Q of q.notes)for(let de of S(Q.fragments))H.has(de.paragraphId)||H.set(de.paragraphId,Q.scopeId);return Pr.set(f,H),H}function _t(f){let w=xt(f)?.partName;if(!w||!m||w===m.session.part().name)return null;for(let H of m.session.headerFooterResolutionBySection())for(let W of ["header","footer"]){let q=W==="header"?H.headers:H.footers;for(let Q of q.values())if(Q.partName===w)return {kind:W,rId:Q.rId}}return null}function Ho(f){let w=xt(f),H=m?.publishedLayout();return !w||!H?null:et(H).get(w.start.paragraphId)??null}function Ln(f){let w=xt(f)?.partName;if(!w||!m)return null;for(let H of ["footnote","endnote"])if(Rd$1(m.session.currentPackage(),H)?.name===w)return {kind:"notesPart",noteKind:H};return null}function tt(f){let w=_t(f);return w!==null?{kind:"headerFooter",rId:w.rId}:Ln(f)??{kind:"body"}}function Bt(f){!m||m.activeScope().kind==="body"||m.session.paragraphIds().includes(f)&&(m.exitNote?.(),m.exitHeaderFooter?.());}let wr=()=>`${new Date().toISOString().slice(0,19)}Z`,st=true,Cr=new WeakMap;function Rr(f){let w=Cr.get(f);if(w)return w;let H=new Map;for(let[W,q]of wd$1(f).entries())H.set(q,W);return Cr.set(f,H),H}function Dn(){let f=m?.retainedSelection()??m?.state().selection??null;if(!f)return null;let{anchor:w,head:H}=f;if(w.paragraphId===H.paragraphId&&w.offset===H.offset)return null;let W=m?.publishedLayout();if(!W)return null;let q=Rr(W),Q=q.get(w.paragraphId)??-1,de=q.get(H.paragraphId)??-1;if(Q===-1||de===-1){let J=Lo();Q=J.get(w.paragraphId)??-1,de=J.get(H.paragraphId)??-1;}return Q===-1||de===-1?null:Q<de||Q===de&&w.offset<=H.offset?{from:w,to:H}:{from:H,to:w}}function Nn(){let f=m?.activeScope();if(f?.kind==="headerFooter")return {kind:"headerFooter",rId:f.rId};if(f?.kind==="note"){let w=_c$1(f.id);if(w)return {kind:"notesPart",noteKind:w.noteKind}}return {kind:"body"}}function Er(f){if(!m)return {kind:"body"};let w=f.slice(0,f.indexOf("#"));if(w.length===0||w===m.session.part().name)return {kind:"body"};for(let H of m.session.headerFooterResolutionBySection())for(let W of [H.headers,H.footers])for(let q of W.values())if(q.partName===w)return {kind:"headerFooter",rId:q.rId};for(let H of ["footnote","endnote"])if(Rd$1(m.session.currentPackage(),H)?.name===w)return {kind:"notesPart",noteKind:H};return Nn()}function Lo(){if(!m)return new Map;let f=Nn();if(f.kind==="body")return new Map;let w=new Map;for(let[H,W]of m.session.paragraphIdsIn(f).entries())w.set(W,H);return w}let St=null;function Rt(f){if(f.kind==="revision"){let H=f.ranges;if(H.length===0)return null;let q=f.revisionKind==="replace"||f.revisionKind==="insert"||f.revisionKind==="delete"?H[H.length-1]:H[0];return {start:H[0].start,end:q.end}}let w=xt(f);return w?{start:w.start,end:w.end}:null}function _n(){if(St&&m){let q=m.retainedSelection()??m.state().selection,Q=(Me,J)=>Me.paragraphId===J.paragraphId&&Me.offset===J.offset;if(!(Q(q.anchor,St.to)&&Q(q.head,St.from)||Q(q.anchor,St.from)&&Q(q.head,St.to)))St=null;else if(pn()===St.key)return null}let f=Dn(),w=m?.publishedLayout();if(!f||!w)return null;let H=Hn(w).get(f.from.paragraphId);if(!H)return null;let W=H.lines?.find(q=>f.from.offset<q.range.end);return {pageIndex:H.pageIndex,anchorY:H.contentY+(W?W.box.y:H.fragmentY)}}function pn(){return m?.activeReviewKey()??null}function Yt(f){if(!l$1)return [];let w=m?.session.reviewItems()??[],H=f?.excludeRevisionKinds;if(H&&H.length>0){let J=new Set(H);w=w.filter(ce=>ce.kind!=="revision"||!J.has(ce.revisionKind));let Se=new Set(w.filter(ce=>ce.kind==="revision").map(ce=>ce.id));w=w.map(ce=>{if(ce.kind!=="comment"||ce.parentRevisionId===void 0||Se.has(ce.parentRevisionId))return ce;let{parentRevisionId:he,...ze}=ce;return ze});}let W=f?.placement!==false,q=null;if(W&&w.length>0){let J=m?.publishedLayout()??null;J&&(q=Hn(J));}let Q=pn(),de=J=>{let Se=_t(J);return Se===null?1:Se.kind==="header"?0:2},Me=w.map((J,Se)=>({item:J,position:Se,pageIndex:q?l(J,q)?.pageIndex??null:null,group:de(J)}));return Me.sort((J,Se)=>{let ce=J.pageIndex??Number.MAX_SAFE_INTEGER,he=Se.pageIndex??Number.MAX_SAFE_INTEGER;return ce!==he?ce-he:J.group!==Se.group?J.group-Se.group:J.position-Se.position}),Me.map(({item:J})=>{let Se=b$2(J),ce=q?l(J,q):null,he={key:Se,id:J.id,...kt(J)!==void 0?{date:kt(J)}:{},anchorY:ce?.y??null,pageIndex:ce?.pageIndex??null,isActive:Se===Q};return J.kind==="comment"?{...he,kind:"comment",author:J.comment.author,initials:d$3(J.comment),text:c$2(J.comment),resolved:J.resolved,...J.parentId!==void 0?{parentId:J.parentId}:{},...J.parentRevisionId!==void 0?{parentRevisionId:J.parentRevisionId}:{},replyIds:J.replyIds,readOnly:false,item:J}:J.kind==="revision"?{...he,kind:"revision",revisionKind:J.revisionKind,author:J.author,initials:Bn(J.author),text:J.text,...J.replacedText?{replacedText:J.replacedText}:{},replyIds:J.replyIds,readOnly:J.readOnly,item:J}:{...he,kind:"custom",author:"",initials:"",text:J.detail??J.text,replyIds:[],readOnly:true,item:J}})}function Et(){return m?.session.trackingSettings()??N}function Fr(){if(l$1&&!(I==="view"||p!=="editing"||C)&&Et().trackRevisions){if(!e$1.author){S$1="this document asks for tracked changes, but no author is configured";return}p="suggesting",m?.setEditingMode("suggest");}}function Or(f){return f!=="editing"||!Et().restrictedToTrackedChanges?null:{ok:false,code:"locked",reason:"this document permits editing only as tracked changes"}}function kt(f){return f.kind==="comment"?f.comment.date:f.kind==="revision"?f.date:void 0}function Bn(f){let w=f.trim().split(/\s+/).filter(Boolean);return w.length===0?"?":w.slice(0,2).map(H=>H[0].toUpperCase()).join("")}function Zn(f,w){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let W=Yt().find(Q=>Q.key===f)?.item;if(!W||W.kind!=="revision")return {ok:false,code:"notFound",reason:"no revision with that key"};if(W.readOnly)return {ok:false,code:"unsupported",reason:"this revision kind has no structural accept/reject yet"};let q;return m?.commitReviewOps(()=>(q=m.session.applyTreeOps(W.addresses.map(Q=>w==="accept"?{op:"acceptRevision",revision:Q}:{op:"rejectRevision",revision:Q}),void 0,void 0,tt(W)),q)),q?.committed?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:typeof q?.reason=="string"?q.reason:"the revision was refused"}}let Zt={get mountGeneration(){return X},get surface(){return m},setHyperlinkChrome(f){return P.push(f),()=>{let w=P.lastIndexOf(f);w>=0&&P.splice(w,1);}},stateVersion:()=>Xe,fontMeasurement:()=>({measurer:M?"shaped":"fixed",resolving:le,...M&&G?{producer:G}:{}}),attach(f){if(T){D(kn("destroyed","this editor was destroyed; create a new instance to remount"));return}if(m&&a$3===f)return;m&&(d$1=m.session.save(),ne()),a$3=f,Oe=null;let w=d$1;d$1=null,w?Ce(w):x();},detach(){T||(m&&(d$1=m.session.save(),ne()),a$3=null,Oe=null,x());},load(f){let w=Ra(f);if(!w){D(kn("unsupported","a DocumentHandle cannot be re-loaded; pass DOCX bytes"));return}Je(w);},save(){if(!m)return Promise.reject(kn("notFound","no document is loaded"));let w=m.session.save().slice();return Promise.resolve(w.buffer)},getDocumentHandle(){return Object.freeze({revision:m?.session.revision()??0})},exec(f,w){if(T&&(f.type==="toggleReviewPane"||f.type==="setEditingMode"))return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(f.type==="setEditingMode"){if(I==="view"&&f.mode!=="viewing")return {ok:false,code:"locked",reason:"this document was opened for viewing"};if(f.mode==="suggesting"&&!l$1)return {ok:false,code:"unsupported",reason:Xt};let Me=Or(f.mode);return Me||(C=true,S$1=null,p=f.mode,m?.setEditingMode(f.mode==="suggesting"?"suggest":f.mode==="viewing"?"view":"edit"),m?.setEditable(f.mode!=="viewing"),x(),ee(),{ok:true,changed:false})}if(f.type==="toggleReviewPane")return l$1?(st=!st,x(),ee(),{ok:true,changed:false}):{ok:false,code:"unsupported",reason:Xt};if(Pi(f)){let Me=wi(f,m,I,w);return Me.ok?su(m,f):Me}let H=gr(f);if(p==="viewing"&&H.supported&&H.mutating)return {ok:false,code:"locked",reason:"the document is open for viewing"};let W=Ir(f,m,I,w);if(!W.ok)return W.refusal;let q=m,Q=q.session.packageRevision(),de=eu(q,f,{...W.tablePlan?{admittedTablePlan:W.tablePlan}:{},editor:Zt});return de||{ok:true,changed:q.session.packageRevision()!==Q}},can(f,w){if(f.type==="insertImage"||f.type==="replaceImage"){if(T)return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(w?.scope){let q=Ir(f,m,I,w);if(!q.ok)return q.refusal}return Vl(f,m)}if(f.type==="toggleReviewPane"||f.type==="setEditingMode"){if(T)return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(f.type==="toggleReviewPane"&&!l$1)return {ok:false,code:"unsupported",reason:Xt};if(f.type==="setEditingMode"&&I==="view"&&f.mode!=="viewing")return {ok:false,code:"locked",reason:"this document was opened for viewing"};if(f.type==="setEditingMode"){if(f.mode==="suggesting"&&!l$1)return {ok:false,code:"unsupported",reason:Xt};let q=Or(f.mode);if(q)return q}return {ok:true}}if(Pi(f))return wi(f,m,I,w);let H=gr(f);if(p==="viewing"&&H.supported&&H.mutating)return {ok:false,code:"locked",reason:"the document is open for viewing"};let W=Ir(f,m,I,w);if(!W.ok)return W.refusal;if(yr(f)&&Ma(f)){let q=vr(Zt);if(q){let Q=Ha(Zt,f,q);if(Q)return Q}}return {ok:true}},isActive(f){if(f.type==="toggleReviewPane")return st;if(f.type==="setEditingMode")return p===f.mode;let w=m?$e().formatting:null;if(!w)return false;switch(f.type){case "toggleMark":switch(f.mark){case "bold":return w.bold===true;case "italic":return w.italic===true;case "underline":return w.underline===true;case "strike":return w.strike===true;case "superscript":return w.superscript===true;case "subscript":return w.subscript===true;default:return false}case "setAlignment":return w.alignment===(f.align==="justify"?"both":f.align);case "toggleList":return m?.isListActive(f.kind)??false;default:return false}},getDocumentStyles:()=>m?.session.documentStyles()??[],getDocumentFonts:()=>m?.session.documentFonts()??[],getAvailableFonts:()=>du(re(),m?.session.documentFonts()??[]),getDocumentThemeColors:()=>m?.session.documentThemeColors()??[],getOutline:()=>m?.session.documentOutline()??[],getComments:()=>[],getSelectionFormatting:()=>Yl(m?$e().formatting:null),findMatches:(f,w)=>m?.session.findText(f,{...w?.matchCase!==void 0?{matchCase:w.matchCase}:{},...w?.wholeWord!==void 0?{wholeWord:w.wholeWord}:{}}).matches??[],selectMatch(f){return m?typeof f?.blockId!="string"||f.blockId.length===0||!Number.isInteger(f.start)||f.start<0||!Number.isInteger(f.length)||f.length<0?{ok:false,code:"invalidArgs",reason:"match must carry a blockId and offsets"}:(Bt(f.blockId),m.setSelection({anchor:{paragraphId:f.blockId,offset:f.start},head:{paragraphId:f.blockId,offset:f.start+f.length}}),m.revealParagraph(f.blockId),{ok:true,changed:false}):{ok:false,code:"notFound",reason:"no document is loaded"}},getSelectedImage:()=>$e().image,getSelectedTable:()=>$l(m),getTableCellSelection:()=>{let f=m?.state().cellSelection;return f?{tableId:f.tableId,rows:f.rows,columns:f.columns,cellIds:f.cellIds}:null},setTableInteractionLabel(f){m?.setTableInteractionLabel(f);},canExecuteImageCommand(f,w){if(T)return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(w?.scope){let H=Ir(f,m,I,w);if(!H.ok)return H.refusal}return La(f,m)},executeImageCommand(f){return T?Promise.resolve({ok:false,code:"notFound",reason:"the editor was destroyed"}):Da(Zt,f)},getPageSetup:()=>_a(m),getWatermark:()=>null,getTrackedChanges:()=>(m?.session.reviewItems()??[]).filter(f=>f.kind==="revision").map(f=>{let w=_t(f);return {id:f.id,kind:f.kind==="revision"?f.revisionKind:"revision",...f.kind==="revision"&&f.author?{author:f.author}:{},story:w!==null?w.kind:Ln(f)?.noteKind??"body"}}),getReviewItems:f=>Yt(f),getCustomNodeDefinitions:()=>o.customNodes,reportCustomNodeDiagnostic:i,addComment(f,w){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let H=Dn();if(!H||!m)return {ok:false,code:"invalidArgs",reason:"a comment needs a selected range"};let W=(w??e$1.author??"").trim();if(W.length===0||f.trim().length===0)return {ok:false,code:"invalidArgs",reason:"a comment needs both an author and text"};let q=null;return m.commitReviewOps(()=>(q=m.session.replyToComment(null,{paragraphId:H.from.paragraphId,start:H.from.offset,end:H.to.offset,...H.to.paragraphId===H.from.paragraphId?{}:{endParagraphId:H.to.paragraphId}},f,W,wr(),Er(H.from.paragraphId)),{committed:q!==null})),q===null?{ok:false,code:"unsupported",reason:"the comment could not be committed"}:(m.releaseSelection(),{ok:true,changed:true})},getSelectionPlacement:()=>_n(),getRenderScale:()=>ge(),isReviewPaneOpen:()=>st,getEditingMode:()=>p,setEditingMode:f=>Zt.exec({type:"setEditingMode",mode:f}),getReviewRevision:()=>$t(),setActiveReviewItem(f){if(f===null){m?.dismissActiveReview(),x(),ee();return}let H=Yt().find(de=>de.key===f)?.item,W=H?xt(H):null;if(!W||!m)return;let q=H?_t(H):null,Q=q===null&&H?Ho(H):null;if(q!==null){if(!m.enterHeaderFooter?.({rId:q.rId,kind:q.kind,position:{paragraphId:W.start.paragraphId,offset:W.start.offset}}))return}else if(Q!==null){if(!m.enterNote?.(Q,{paragraphId:W.start.paragraphId,offset:W.start.offset}))return}else {m.exitNote?.(),m.exitHeaderFooter?.();let de=Rt(H)??W;m.setSelection({anchor:{paragraphId:de.end.paragraphId,offset:de.end.offset},head:{paragraphId:de.start.paragraphId,offset:de.start.offset}}),St={key:f,from:de.start,to:de.end},m.revealPosition?.(de.start,{block:"nearest"});}x(),ee();},setReviewActivationExclusions(f){y=f===null?null:[...f],m?.setReviewActivationExclusions(y);},acceptReviewItem:f=>Zn(f,"accept"),rejectReviewItem:f=>Zn(f,"reject"),deleteReviewItem(f){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let H=Yt().find(q=>q.key===f)?.item;if(!H||!m)return {ok:false,code:"notFound",reason:"no review item with that key"};if(H.kind==="revision")return Zn(f,"reject");if(H.kind!=="comment")return {ok:false,code:"unsupported",reason:"a custom node card cannot be deleted"};pn()===f&&m.dismissActiveReview();let W=false;return m.commitReviewOps(()=>(W=m.session.deleteComment(H.id),{committed:W})),W?(x(),{ok:true,changed:true}):{ok:false,code:"unsupported",reason:"the comment could not be deleted"}},replyToReviewItem(f,w,H){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let q=Yt().find(Se=>Se.key===f)?.item;if(!q||!m)return {ok:false,code:"notFound",reason:"no review item with that key"};let Q=xt(q);if(!Q)return {ok:false,code:"invalidArgs",reason:"the item has no anchorable range"};let de=(H??e$1.author??"").trim();if(de.length===0||w.trim().length===0)return {ok:false,code:"invalidArgs",reason:"a reply needs both an author and text"};if(q.kind==="custom")return {ok:false,code:"unsupported",reason:"a custom node card takes no replies"};let Me=q.kind==="comment"?q.id:null,J=null;return m.commitReviewOps(()=>(J=m.session.replyToComment(Me,{paragraphId:Q.start.paragraphId,start:Q.start.offset,end:Q.end.offset},w,de,wr(),tt(q)),{committed:J!==null})),J===null?{ok:false,code:"unsupported",reason:"the reply could not be committed"}:{ok:true,changed:true}},getHeaderFooterState:()=>m?.headerFooterState()??null,getNotePropertiesState:()=>m?.notePropertiesState?.()??null,getNotePreviewText:f=>m?.notePreviewText?.(f)??null,setActiveScope(f){m?.setActiveScope(f)&&x();},getActiveScope:()=>m?.activeScope()??{kind:"body"},query(f){switch(f.type){case "selectedText":return m?.selectedText()??"";case "selectionFormatting":return m?$e().formatting:null;case "selection":return Ba(m);case "paragraphs":return Xl(m,f.container);case "isInsideToc":return m?m.isInsideToc(m.state().selection.head.paragraphId):false;case "hyperlinkAt":return Wl(m);case "contentControls":return ru(m,f.filter);case "trackedChanges":case "revisions":case "findText":case "comments":return [];case "styles":return {paragraph:new Map,character:new Map,table:new Map};case "variables":return {};case "contentControlAt":return Ti(m,f.filter);case "tableContext":return za(m);default:return null}},snapshot:()=>$e(),getTotalPages:()=>Za(m),getCurrentPage:f=>qa(m,f),scrollToPage:f=>Number.isInteger(f)&&f>=1?m?.revealPage(f-1)??false:false,scrollToBlock:f=>typeof f!="string"||f.length===0?false:(Bt(f),m?.revealParagraph(f)??false),getZoom:()=>O,setZoom(f){return !Number.isFinite(f)||f<.1||f>5?{ok:false,code:"invalidArgs",reason:`zoom must be between 0.1 and 5, got ${f}`}:f===O?{ok:true,changed:false}:m&&!qc(m,f*(96/72))?{ok:false,code:"unsupported",reason:`the mounted surface could not apply zoom ${f}`}:(O=f,x(),ee(),{ok:true,changed:true})},getPageGeometry:()=>m?m.layout().pages.map(f=>({index:f.index,box:hu(f.box),contentBox:hu(f.contentBox)})):[],relayout(f){f?.sync,m?.layout();},focus(f){return m?f&&f.kind==="all"?{ok:false,code:"invalidTarget",reason:"the all scope cannot take focus"}:f&&!m.setActiveScope(f)?{ok:false,code:"invalidTarget",reason:"that scope cannot be opened"}:(m.focus(),{ok:true,value:void 0}):{ok:false,code:"invalidTarget",reason:"no document is loaded"}},destroy(){T=true,L(),ne(),a$3=null,d$1=null,X+=1,x();for(let f of Object.values(N$1))f.clear();},on(f,w){return N$1[f].add(w),()=>{N$1[f].delete(w);}}};return Zt}var yu=Object.freeze({document:true,save:true,events:true,selection:true,scrolling:true,layout:true});function mm(e){return g$1({port:hm(e),capabilities:yu})}function hm(e){let t=0,n=0,r=null,a=false,o=false,i=()=>{if(o)return null;let l=e.surface?.session??null;return l!==r&&(a&&(t+=n+1),a=true,r=l,n=0),l&&(n=l.packageRevision()),l};return {revision(){return i(),t+n},currentPackage:()=>i()?.currentPackage()??null,apply(l,d){i();let p=e.surface;if(!p)return {ok:false,reason:"no-document"};let y=p.applyAutomationOps(l,d);return y.rejected?{ok:false,reason:String(y.reason??"refused")}:{ok:true,changed:y.committed}},applyLifecycle(l){i();let d=e.surface;if(!d)return {ok:false,reason:"no-document"};let p=d.applyAutomationOps(()=>[l]);return p.rejected?{ok:false,reason:String(p.reason??"refused")}:{ok:true,changed:p.committed}},applyCommentWrite(l,d){let p=e.surface,y=i();if(!p||!y)return {ok:false,reason:"no-document"};if(d.kind!=="body")return {ok:false,reason:"unsupported-story"};let C={ok:false,reason:"refused"};return p.commitReviewOps(()=>{if(l.kind==="resolve"){let I=y.setCommentResolved(l.commentId,l.resolved);return C=I?{ok:true,changed:true}:{ok:false,reason:"unknown-comment"},{committed:I}}let S=y.replyToComment(l.parentCommentId,l.anchor,l.text,l.author,l.date);return C=S===null?{ok:false,reason:"refused"}:{ok:true,changed:true,commentId:S},{committed:S!==null}}),C},applyCustomNodeWrite(l,d){let p=e.surface,y=i();if(!p||!y)return {ok:false,reason:"no-document"};if(d.kind!=="body")return {ok:false,reason:"unsupported-story"};let C={ok:false,reason:"refused"};return p.commitReviewOps(()=>{let S=y.insertCustomNode(l);return C=S.ok?{ok:true,changed:S.change!==null}:{ok:false,reason:S.detail?`${S.reason}: ${S.detail}`:S.reason},{committed:S.ok}}),C},save:()=>i()?.save()??null,select(l,d){let p=e.surface;if(!p)return;let y=d==="end"?l.end:l.start,C=d==="start"?l.start:l.end;p.setSelection({anchor:{paragraphId:y.paragraphId,offset:y.offset},head:{paragraphId:C.paragraphId,offset:C.offset}});},subscribe:l=>e.on("change",()=>l()),dispose(){o=true,r=null;}}}function ym(e){return e*(96/72)}function vm(e,t){return e*t}function bm(e,t){return e/t}function xm(e,t,n){let r=e.pages[t.pageIndex];if(!r)return {left:0,top:0,width:0,height:0};let a=n.pageOffsetX.get(r.index)??0,o=n.paintScale;return Object.freeze({left:(r.contentBox.x+t.x+a)*o,top:(r.contentBox.y+t.y)*o,width:t.width*o,height:t.height*o})}function bu(e,t,n){return t?true:e.length===1?false:!n}var vu=["e","se","s","sw","w","nw","n","ne"];function Im(e,t){let n=vu.indexOf(e);t.flipHorizontal&&(n=(4-n+8)%8),t.flipVertical&&(n=(8-n)%8);let r=Math.round(t.rotationDegrees/45)%8;return vu[(n-r+8)%8]}function Sm(e,t,n){let r=e,a=t,o=-n.rotationDegrees*Math.PI/180,i=Math.cos(o),l=Math.sin(o),d=r*i-a*l,p=r*l+a*i;return r=d,a=p,n.flipHorizontal&&(r=-r),n.flipVertical&&(a=-a),Object.freeze({x:r,y:a})}function un(e){return e/xr}function xu(e){let t=Sm(e.deltaXPt,e.deltaYPt,e.transform),n=un(e.startWidthEmu),r=un(e.startHeightEmu),a=n/r,o=Im(e.handle,e.transform),i=o.includes("e")?t.x:o.includes("w")?-t.x:0,l=o.includes("s")?t.y:o.includes("n")?-t.y:0;if(n=Math.max(1,n+i),r=Math.max(1,r+l),e.preserveAspect)if(o.length===2){let k=Math.max(n/un(e.startWidthEmu),r/un(e.startHeightEmu));n=Math.max(1,un(e.startWidthEmu)*k),r=Math.max(1,n/a);}else o==="e"||o==="w"?r=Math.max(1,n/a):n=Math.max(1,r*a);let d=un(e.startWidthEmu),p=un(e.startHeightEmu),y=n/d,C=r/p,S=Math.max(1,e.startBounds.width*y),I=Math.max(1,e.startBounds.height*C),O=e.startBounds.x,m=e.startBounds.y,F=e.handle;F.includes("w")&&(O=e.startBounds.x+e.startBounds.width-S),F.includes("n")&&(m=e.startBounds.y+e.startBounds.height-I);let B=null;if(e.kind==="anchored"&&e.startPosition&&(F.includes("w")||F.includes("n")))if(e.startPosition.mode==="simple"){let A=F.includes("w")?Ve(O-e.startBounds.x):0,k=F.includes("n")?Ve(m-e.startBounds.y):0;B=Object.freeze({mode:"simple",horizontalEmu:(e.startPosition.horizontalEmu??0)+A,verticalEmu:(e.startPosition.verticalEmu??0)+k});}else if(e.anchorFrameOrigin)B=Object.freeze({mode:"frame",...e.startPosition.relativeToH!==void 0?{relativeToH:e.startPosition.relativeToH}:{},...e.startPosition.relativeToV!==void 0?{relativeToV:e.startPosition.relativeToV}:{},...F.includes("w")?{horizontalEmu:Ve(O-e.anchorFrameOrigin.x)}:e.startPosition.horizontalEmu!==void 0?{horizontalEmu:e.startPosition.horizontalEmu}:{},...F.includes("n")?{verticalEmu:Ve(m-e.anchorFrameOrigin.y)}:e.startPosition.verticalEmu!==void 0?{verticalEmu:e.startPosition.verticalEmu}:{}});else {let A=F.includes("w")?Ve(O-e.startBounds.x):0,k=F.includes("n")?Ve(m-e.startBounds.y):0;B=Object.freeze({mode:"frame",...e.startPosition.horizontalEmu!==void 0?{horizontalEmu:e.startPosition.horizontalEmu+A}:{},...e.startPosition.verticalEmu!==void 0?{verticalEmu:e.startPosition.verticalEmu+k}:{},...e.startPosition.relativeToH!==void 0?{relativeToH:e.startPosition.relativeToH}:{},...e.startPosition.relativeToV!==void 0?{relativeToV:e.startPosition.relativeToV}:{}});}return Object.freeze({widthEmu:Ve(n),heightEmu:Ve(r),previewBounds:Object.freeze({x:O,y:m,width:S,height:I}),position:B})}function km(e,t){return Object.freeze({scrollBy(n){if(!Number.isFinite(n)||n===0)return 0;let r=e.scrollTop;return e.scrollTop+=n*t,(e.scrollTop-r)/t}})}function Tm(e){if(e.session.mode==="move"){let t=e.session.startBounds.x+e.deltaXPt,n=e.session.startBounds.y+e.deltaYPt+e.accumulatedScrollPt,r=e.session.startPosition&&Na(e.session.startPosition,e.deltaXPt,e.deltaYPt+e.accumulatedScrollPt);return Object.freeze({widthEmu:e.session.startWidthEmu,heightEmu:e.session.startHeightEmu,previewBounds:Object.freeze({x:t,y:n,width:e.session.startBounds.width,height:e.session.startBounds.height}),position:r??null})}return e.session.handle?xu({handle:e.session.handle,startWidthEmu:e.session.startWidthEmu,startHeightEmu:e.session.startHeightEmu,startBounds:e.session.startBounds,startPosition:e.session.startPosition,anchorFrameOrigin:e.anchorFrameOrigin,deltaXPt:e.deltaXPt,deltaYPt:e.deltaYPt,transform:e.session.transform,preserveAspect:bu(e.session.handle,e.aspectLocked,e.shiftKey),kind:e.session.kind}):Object.freeze({widthEmu:e.session.startWidthEmu,heightEmu:e.session.startHeightEmu,previewBounds:e.session.startBounds,position:null})}
|
|
10
|
+
`,e.charCodeAt(n+1)===10&&(n+=1);continue}if(r===9||r===10){t+=e[n];continue}if(!(r<32||r===65534||r===65535)){if(r>=55296&&r<=56319){let a=e.charCodeAt(n+1);a>=56320&&a<=57343&&(t+=e[n]+e[n+1],n+=1);continue}r>=56320&&r<=57343||(t+=e[n]);}}return t}function Ga(e){if(!e)return "";let t=e.getData("text/plain");if(t.length>0)return t;let n=e.getData("text/html");return n.length>0?Zp(n):""}var qp={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down",Home:"lineStart",End:"lineEnd"},hd={l:"left",e:"center",r:"right",j:"both"},yd={1:"240",5:"360",2:"480"},vd={b:{localName:"b"},i:{localName:"i"},u:{localName:"u",attributes:{val:"single"}}};function xd(e,t={}){return n=>{if(n.defaultPrevented)return;if(n.key==="Escape"&&e.activeScope().kind==="headerFooter"){e.exitHeaderFooter(),n.preventDefault();return}if(n.key==="Escape"&&e.activeScope().kind==="note"){e.exitNote(),n.preventDefault();return}if((n.ctrlKey||n.metaKey)&&n.altKey&&!n.shiftKey){let o=n.key.toLowerCase();if(o==="f"){n.preventDefault(),e.insertNote("footnote");return}if(o==="d"){n.preventDefault(),e.insertNote("endnote");return}}let r=n.metaKey||n.ctrlKey,a=qp[n.key];if(a){let o=a;n.key==="Home"||n.key==="End"?r&&(o=n.key==="Home"?"documentStart":"documentEnd"):(n.key==="ArrowLeft"||n.key==="ArrowRight")&&(n.altKey||n.ctrlKey)?o=n.key==="ArrowLeft"?"wordLeft":"wordRight":n.metaKey&&(n.key==="ArrowLeft"||n.key==="ArrowRight")?o=n.key==="ArrowLeft"?"lineStart":"lineEnd":r&&(n.key==="ArrowUp"||n.key==="ArrowDown")&&(o=n.key==="ArrowUp"?"documentStart":"documentEnd"),e.navigate(o,n.shiftKey),n.preventDefault();return}if(n.key==="PageUp"||n.key==="PageDown"){e.navigate(r?n.key==="PageUp"?"documentStart":"documentEnd":n.key==="PageUp"?"pageUp":"pageDown",n.shiftKey),n.preventDefault();return}if(n.key==="Backspace"){r||n.altKey?e.deleteWordBackward():e.deleteBackward(),n.preventDefault();return}if(n.key==="Delete"){r||n.altKey?e.deleteWordForward():e.deleteForward(),n.preventDefault();return}if(n.key==="Tab"){if(e.contentControls.formFill()&&e.contentControls.navigate(n.shiftKey?"previous":"next")){n.preventDefault();return}e.isListParagraph()?e.adjustIndent(n.shiftKey?"decrease":"increase"):n.shiftKey?e.adjustIndent("decrease"):e.insertTab(),n.preventDefault();return}if(n.key==="Enter"){r?e.insertPageBreak():n.shiftKey?e.insertLineBreak():e.exitListOnEmptyItem()||e.splitParagraph(),n.preventDefault();return}if(r&&n.key.toLowerCase()==="a"){e.selectAll(),n.preventDefault();return}if(r&&!n.shiftKey&&n.key.toLowerCase()==="k"&&t.onRequestHyperlink){t.onRequestHyperlink(),n.preventDefault();return}if(r&&!n.shiftKey&&vd[n.key.toLowerCase()]){let o=vd[n.key.toLowerCase()];e.toggleRunProperty(o.localName,o.attributes),n.preventDefault();return}if(r&&(n.key==="="||n.key==="+"||n.code==="Equal")){e.toggleRunProperty("vertAlign",{val:n.shiftKey?"superscript":"subscript"}),n.preventDefault();return}if(r&&n.shiftKey&&n.key.toLowerCase()==="m"){e.adjustIndent("decrease"),n.preventDefault();return}if(r&&!n.shiftKey&&n.key.toLowerCase()==="m"){e.adjustIndent("increase"),n.preventDefault();return}if(r&&!n.shiftKey&&hd[n.key.toLowerCase()]){if(n.metaKey&&n.key.toLowerCase()==="r")return;e.setParagraphProperty("jc",{val:hd[n.key.toLowerCase()]}),n.preventDefault();return}if(r&&!n.shiftKey&&yd[n.key]){e.setParagraphProperty("spacing",{line:yd[n.key],lineRule:"auto"}),n.preventDefault();return}if(r&&n.key.toLowerCase()==="y"){e.redo(),n.preventDefault();return}(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()==="z"&&(n.shiftKey?e.redo():e.undo(),n.preventDefault());}}function Id(e,t){return {onCopy:o=>{let i=e.selectedText();i&&(o.clipboardData?.setData("text/plain",i),o.preventDefault());},onCut:o=>{let i=e.selectedText();i&&(o.clipboardData?.setData("text/plain",i),e.deleteSelection(),o.preventDefault());},onPaste:o=>{let i=Ga(o.clipboardData);o.preventDefault(),i&&t(i);}}}function bd(e){let t=Ga(e.dataTransfer);return t.length>0?t:null}function Sd(e,t){return n=>{if(n.preventDefault(),!t.isComposing()){if(n.inputType==="insertText"&&n.data!=null){e.type(n.data);return}if(n.inputType!=="insertFromPaste"){if(n.inputType==="insertReplacementText"){let r=n.data??bd(n);r&&e.type(r);return}if(n.inputType==="deleteContentBackward"){e.deleteBackward();return}if(n.inputType==="deleteWordBackward"){e.deleteWordBackward();return}if(n.inputType==="deleteContentForward"){e.deleteForward();return}if(n.inputType==="deleteWordForward"){e.deleteWordForward();return}if(n.inputType==="insertLineBreak"){e.insertLineBreak();return}if(n.inputType==="insertFromDrop"||n.inputType==="insertFromPasteAsQuotation"){let r=bd(n);r&&t.insertPlainText(r);return}n.inputType==="insertParagraph"&&e.splitParagraph();}}}}function kd(e,t){let n=e.querySelectorAll("[data-paragraph-id][data-start]"),r=[];for(let a of n){let o=a;if(o.dataset.paragraphId!==t)continue;let i=Number(o.dataset.start);Number.isInteger(i)&&r.push({start:i,text:o.textContent??""});}return r.length===0?null:(r.sort((a,o)=>a.start-o.start),r.map(a=>a.text).join(""))}function Td(e,t,n){if(n===t)return null;let r=0;for(;r<n.length&&r<t.length&&n[r]===t[r];)r+=1;let a=0;for(;a<n.length-r&&a<t.length-r&&n[n.length-1-a]===t[t.length-1-a];)a+=1;let o=n.slice(r,n.length-a),i=[];return t.length-a>r&&i.push({op:"deleteText",paragraphId:e,start:r,end:t.length-a}),o.length>0&&i.push({op:"insertText",paragraphId:e,offset:r,text:o}),i.length===0?null:{ops:i,caret:r+o.length}}function Wa(e){let{session:t,measurer:n,producer:r,cache:a,styleCascade:o,defaultTabStopPt:i,inlineDrawingLayoutForPart:l,drawingLayoutTokenForPart:d,drawingTokenForParagraphForPart:p}=e,y=new WeakMap,C=null,S=-1;function I(k){let V=t.packageRevision();return (!C||S!==V)&&(C=jp(t.currentPackage()),S=V),C.get(k)}function O(k,V,P){let v=d?.(k.name)??"",T=P?.height??0,M=P?.margin.top??0,G=P?.margin.bottom??0,$=P?.margin.left??0,L=P?.margin.right??0,z=y.get(k);if(z&&z.width===V&&z.pageHeight===T&&z.marginTop===M&&z.marginBottom===G&&z.marginLeft===$&&z.marginRight===L&&z.producer===r&&z.drawingLayoutToken===v)return z.story;let oe=l?.(k.name),re=cd$1(k,V,n,r,a,o,void 0,void 0,i,void 0,oe,p?Oe=>p(k.name,Oe):void 0,void 0,P?{pageNumber:1,pageWidth:P.width,pageHeight:P.height,marginLeft:P.margin.left,marginRight:P.margin.right,marginTop:P.margin.top,marginBottom:P.margin.bottom}:void 0),we=I(k.name),le=we?Pd(re,we):re;return y.set(k,{width:V,pageHeight:T,marginTop:M,marginBottom:G,marginLeft:$,marginRight:L,producer:r,drawingLayoutToken:v,story:le}),le}function m(k,V,P){let v=new Map;for(let[T,M]of k)v.set(T,O(M,V,P));return v}function F(k,V){if(!k||k.headers.size===0&&k.footers.size===0)return;let P=V.width-V.margin.left-V.margin.right;return {titlePage:k.titlePage,evenAndOddHeaders:k.evenAndOddHeaders,headers:m(k.headers,P,V),footers:m(k.footers,P,V)}}function B(){let k=Dc$1(t.part()),V=t.headerFooterPartsBySection();return k.map((P,v)=>F(V[v],Fc$1(P.properties)))}function A(){let k=B();return k[k.length-1]}return {furniture:A,sectionFurniture:B}}var zp="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",Kp="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function jp(e){let t=new Map,n=e.relationships.get(e.mainDocumentPart)??[];for(let r of n){if(r.type!==zp&&r.type!==Kp)continue;let a=N$1(r);if(a.mode!=="Internal"||!a.target.ok)continue;let o=a.target.partName;t.has(o)||t.set(o,r.id);}return t}function Pd(e,t){return e.rId===t?e:{...e,rId:t,withPageContext:n=>Pd(e.withPageContext(n),t)}}function wd(e){let t,n;return {styleCascade:rb(e.stylesRoot(),e.documentThemeFonts()),defaultTabStopPt:Ia$1(e.settingsRoot()),numberingIndex(){let r=e.numberingRoot();return (n===void 0||r!==t)&&(t=r,n=Qb(r)),n}}}function Ct(e){return e.closest(".docx-editor__scroll-container")}function Cd(e,t,n){let r=e.getBoundingClientRect(),a=t.getBoundingClientRect();return {top:(t.scrollTop!==0&&r.top===0&&a.top===0?t.scrollTop-e.offsetTop:a.top+t.clientTop-r.top)/n,height:t.clientHeight/n}}function Rd(e,t,n){let r=Ct(e);if(!r||r.clientHeight<=0||t.pages.length===0||n<=0)return null;let a=Cd(e,r,n),o=a.top+a.height/2;for(let i of t.pages)if(o<i.box.y+i.box.height)return i.index+1;return t.pages.length}function Ed(e,t,n,r){let a=Ct(e);if(!a||a.clientHeight===0)return;let o=Cd(e,a,r),i=[];for(let l of [n.anchor,n.head]){let d=qd$1(t,l);d&&i.push(d.pageIndex);}return md$1({layout:t,viewport:o,overscanPages:1,pinnedPages:i})}function Xa(e,t){if(e===t)return true;if(!e||!t||e.size!==t.size)return false;for(let n of e)if(!t.has(n))return false;return true}function vo(e,t){let n=e.pages,r=n[n.length-1],a=r?r.box.y+r.box.height:0,o=t?n.filter(p=>t.has(p.index)):n,i=0;for(let p of o){let y=p.box.x+p.box.width;y>i&&(i=y);}let l=new Set(o.map(p=>p.box.width)),d=new Map;if(o.length>0&&l.size>1)for(let p of n)d.set(p.index,(i-p.box.width)/2-p.box.x);return {width:i,height:a,pageOffsetX:d}}function Fd(e,t){if(e.width!==t.width||e.height!==t.height||e.pageOffsetX.size!==t.pageOffsetX.size)return false;for(let[n,r]of e.pageOffsetX)if(t.pageOffsetX.get(n)!==r)return false;return true}function Od(e){let t=e.session.currentPackage(),n=Rd$1(t,"footnote"),r=Rd$1(t,"endnote");if(!n&&!r)return;let a=zd$1(t),o=Ad$1(a),i=Bd$1(a),l=Cd$1(void 0,o),d=Dd$2(void 0,i),p=e.session.part(),y=Dc$1(p),C=Vp(p,y),S=y.map((B,A)=>Cd$1(xd$2(C[A]),o)),I=y.map((B,A)=>Dd$2(yd$2(C[A]),i)),O=e.inlineDrawingLayoutForPart,m=e.drawingTokenForParagraphForPart,F=O?B=>{let A=O(B);if(A)return {inlineDrawingLayout:A,...m?{drawingTokenForParagraph:k=>m(B,k)}:{}}}:void 0;return {footnotesPart:n,endnotesPart:r,footnotePropsBySection:S.length>0?S:[l],endnotePropsBySection:I.length>0?I:[d],documentFootnoteProps:l,documentEndnoteProps:d,measurer:e.measurer,producer:e.producer,cache:e.cache,styleCascade:e.styleCascade,defaultTabStopPt:e.defaultTabStopPt,...F?{drawingsForPart:F}:{}}}function Vp(e,t){let n=rc$1(e),r=[];for(let a=0;a<n.length;a+=1){let o=n[a];if(o.kind!=="paragraph")continue;let i=Bc$2(o);i&&r.push(i);}for(;r.length<t.length;)r.push(void 0);return r}function Md(e){if(typeof e.defaultView?.createImageBitmap!="function")return null;let t=e.defaultView;return Object.freeze({async decode(n,r,a){let o=new Blob([new Uint8Array(n)],{type:r}),i=await t.createImageBitmap(o);try{let l=i.width,d=i.height;if(l<=0||d<=0)throw new Error("image dimensions invalid");if(l*d>a.maxPixels)throw new Error("image dimensions exceed limits");return Object.freeze({pixelWidth:l,pixelHeight:d,dpiX:96,dpiY:96})}finally{i.close();}},convertPreserved(n,r,a){return r==="image/tiff"?Wp(e,n,a):Up(n,r)}})}async function Up(e,t,n){let{convertEmfToDataUrl:r,convertWmfToDataUrl:a}=await import('emf-converter'),o=new Uint8Array(e),i=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),l={maxWidth:4096,maxHeight:4096},d=t==="image/x-emf"?await r(i,l):await a(i,l);if(!d)return null;let p="data:image/png;base64,";if(!d.startsWith(p))return null;let y=atob(d.slice(p.length)),C=new Uint8Array(y.length);for(let S=0;S<y.length;S+=1)C[S]=y.charCodeAt(S);return Object.freeze({bytes:C,mime:"image/png"})}function Ad(e,t){let n=e[t];if(!Array.isArray(n)||n.length===0)return null;let r=Number(n[0]);return Number.isSafeInteger(r)&&r>0?r:null}async function Gp(e,t){let n=await import('utif2'),r=n.default??n,a=e.slice().buffer,o=r.decode(a)[0];if(!o)return null;let i=Ad(o,"t256"),l=Ad(o,"t257");if(i===null||l===null||i>t.maxDimension||l>t.maxDimension||i>t.maxPixels/l)return null;let d=i*l;if(d*4>t.maxDecodedBytes||(r.decodeImage(a,o),o.width!==i||o.height!==l))return null;let p=r.toRGBA8(o);return p.length!==d*4?null:Object.freeze({rgba:p,pixelWidth:i,pixelHeight:l})}async function Wp(e,t,n){let r=await Gp(t,n);if(r===null)return null;let a=await Xp(e,r.rgba,r.pixelWidth,r.pixelHeight);return a===null?null:Object.freeze({bytes:a,mime:"image/png"})}async function Xp(e,t,n,r){let a=e.createElement("canvas");if(a.width=n,a.height=r,a.width!==n||a.height!==r)return null;let o=a.getContext("2d");if(!o)return null;let i=o.createImageData(n,r);i.data.set(t),o.putImageData(i,0,0);let l=await new Promise(d=>{a.toBlob(p=>d(p),"image/png");});return l?new Uint8Array(await l.arrayBuffer()):null}function Hd(){return Object.freeze({async decode(){throw new Error("Image decode unavailable in headless environment")}})}function Ld(e){return typeof URL.createObjectURL!="function"||typeof URL.revokeObjectURL!="function"?null:Object.freeze({create(t,n){let r=e.mintValidatedBytes(t,t.contentId);if(!r)throw new Error(`PaintImageUrlSource: validated bytes unavailable for ${t.resourceKey}`);let a=new Uint8Array(r);return URL.createObjectURL(new Blob([a],{type:n}))},revoke(t){URL.revokeObjectURL(t);}})}var $p="docx-editor-one-surface__caret",$a="docx-editor-one-surface__caret--steady",Yp=530;function Dd(e,t,n){let r=e.ownerDocument,a=r.createElement("div");a.className=$p,a.dataset.docxCaret="",a.dataset.docxMarker="",a.setAttribute("contenteditable","false"),a.setAttribute("aria-hidden","true"),a.dataset.noColorInvert="",a.style.position="absolute",a.style.pointerEvents="none",a.style.userSelect="none",a.style.setProperty("-webkit-user-select","none");let o=false,i=null,l=null,d=null;function p(){let A=r.activeElement;return A===e||!!A&&e.contains(A)}function y(A){return A.anchor.paragraphId===A.head.paragraphId&&A.anchor.offset===A.head.offset}function C(){l=null,i!==null&&(clearTimeout(i),i=null),a.classList.remove($a),a.remove(),e.style.removeProperty("caret-color"),d?.style.removeProperty("caret-color"),d=null;}function S(){a.classList.add($a),i!==null&&clearTimeout(i),i=setTimeout(()=>{i=null,a.classList.remove($a);},Yp);}function I(){if(o||!p()||n().suppress){C();return}let{layout:A,selection:k,scopedHost:V,scopedHostKind:P,preferredPageIndex:v,measurer:T}=n(),M=t();if(!y(k)){C();return}let G=qd$1(A,k.head,{...T?{measurer:T}:{},...v!==void 0?{preferredPageIndex:v}:{}});if(!G||!Number.isInteger(G.pageIndex)){C();return}let $=V??e.querySelector(`[data-page-index="${G.pageIndex}"] > .docx-page-content`);if(!$){C();return}a.style.left=`${G.x*M}px`,a.style.top=`${G.y*M}px`,a.style.height=`${G.height*M}px`,a.parentNode!==$&&$.append(a),e.style.caretColor="transparent",d&&d!==V&&d.style.removeProperty("caret-color"),d=V??null,d?.style.setProperty("caret-color","transparent");let L=$===V?P??"scoped":"body",z=`${G.pageIndex}:${L}:${G.x}:${G.y}:${G.height}`;z!==l&&(l=z,S());}let O=()=>{o=true,I();},m=()=>{o=false,I();},F=()=>I(),B=A=>{let k=A.relatedTarget;k&&e.contains(k)||C();};return e.addEventListener("compositionstart",O),e.addEventListener("compositionend",m),e.addEventListener("focusin",F),e.addEventListener("focusout",B),{update:I,destroy(){e.removeEventListener("compositionstart",O),e.removeEventListener("compositionend",m),e.removeEventListener("focusin",F),e.removeEventListener("focusout",B),C();}}}function Nd(e,t){for(let n of e)if(n.kind==="table"){t(n);for(let r of n.rows)for(let a of r.cells)Nd(a.blocks,t);}}function Qp(e,t){for(let n of e.pages)Nd(n.fragments,r=>{for(let a=0;a<r.rows.length;a+=1)t({table:r,row:r.rows[a],rowIndex:a});});}function Ya(e,t,n,r){let a=null;return Qp(e,o=>{o.table.tableId===t&&o.row.id===n&&o.row.isHeaderRepeat===r&&(a=o);}),a}function Qa(e,t){return {sourceRevision:e,tableId:t.table.tableId,rowId:t.row.id,isHeaderRepeat:t.row.isHeaderRepeat}}function _d(e,t,n){let r=n.gridColumnId;return r?{sourceRevision:e,tableId:t.table.tableId,gridColumnId:r,isHeaderRepeat:t.row.isHeaderRepeat}:null}function Bd(e,t,n,r){return {sourceRevision:e,tableId:t.table.tableId,leftGridColumnId:n,rightGridColumnId:r,isHeaderRepeat:t.row.isHeaderRepeat}}function Zd(e,t,n){return {sourceRevision:e,tableId:t.table.tableId,gridColumnId:n,isHeaderRepeat:t.row.isHeaderRepeat}}var Jp=120,qd=20;function bo(e){let t=hf$1(e,"w"),n=t?Number.parseInt(t,10):Number.NaN;return Number.isFinite(n)?n:0}function eg(e,t,n){let r=e.pagesLayer.getBoundingClientRect(),a=e.scale();return {x:(t-r.left)/a,y:(n-r.top)/a}}function Ja(e){let t=e.editingMode==="view";return {editable:!t,viewing:t}}function xo(e,t,n){let r=a=>{for(let o of a)if(o.kind==="table"){if(o.tableId===t)return o;for(let i of o.rows)for(let l of i.cells){let d=r(l.blocks);if(d)return d}}return null};return r(e.pages[n]?.fragments??[])}function ei(e,t){return t.kind==="insertColumn"?Ya(e,t.tableId,t.rowId,t.isHeaderRepeat):"rowId"in t?Ya(e,t.tableId,t.rowId,t.isHeaderRepeat):null}function zd(e){let t=e.furnitureLayer;t.className="docx-table-furniture",t.setAttribute("contenteditable","false"),t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.pointerEvents="none";let n=null,r=null,a=null,o=null,i=null,l=null,d=false,p=0,y=0,C=null,S=null,I=null;function O(h){return h instanceof HTMLButtonElement&&(h.classList.contains("docx-table-insert-row")||h.classList.contains("docx-table-insert-column"))}function m(){let h=document.activeElement;return h!==null&&O(h)&&h.closest(".docx-table-furniture")===t?h:null}function F(h){for(let x of [...t.children])O(x)&&x!==h&&x.remove();}function B(){S=null,I=null;}function A(){n!==null&&(clearTimeout(n),n=null);}function k(){for(let x of [...t.children])O(x)||x.remove();let h=m();if(!h){F(null),B();return}S=h,F(h);}function V(h){let x=S??m(),N=x!==null&&document.activeElement===x;B(),t.replaceChildren(),h&&N&&e.pagesLayer.focus({preventScroll:true});}function P(){for(let h of [...t.children])O(h)||h.remove();}function v(h,x,N){let Z=e.read().layout.pages[h];if(!Z)return {left:0,top:0};let ee=e.scale(),ne=e.pageOffsetX(h);return {left:(Z.contentBox.x+x+ne)*ee,top:(Z.contentBox.y+N)*ee}}function T(h,x){let N=e.read(),D=xo(N.layout,x.tableId,x.pageIndex);if(!D)return;let Z=document.createElement("div");Z.className="docx-table-resize-preview",Z.style.position="absolute",Z.style.pointerEvents="none";let ee=x.kind!=="rowDivider",ne=v(x.pageIndex,ee?D.box.x+h:D.box.x,ee?D.box.y:D.box.y+h);Z.style.left=`${ne.left}px`,Z.style.top=`${ne.top}px`,Z.style.width=ee?"2px":`${D.box.width*e.scale()}px`,Z.style.height=ee?`${D.box.height*e.scale()}px`:"2px",t.append(Z);}function M(){let h=document.createElement("button");return h.type="button",h.textContent="+",h.style.position="absolute",h.style.pointerEvents="auto",h}function G(h){oe(h);let x=I;if(!x)return;let N=e.read();x.kind==="insertRow"?we(x,N):x.kind==="insertColumn"&&le(x,N);}function $(){queueMicrotask(()=>{!S||document.activeElement===S||d||r?.kind==="insertRow"||r?.kind==="insertColumn"||(S.remove(),B());});}function L(){if(S&&t.contains(S))return S;let h=m();if(h)return S=h,h;let x=M();return x.addEventListener("pointerenter",()=>{d=true,A();}),x.addEventListener("pointerleave",()=>{d=false;}),x.addEventListener("pointerdown",oe),x.addEventListener("mousedown",oe),x.addEventListener("click",G),x.addEventListener("blur",$),S=x,x}function z(h,x){let N=xo(x.layout,h.tableId,h.pageIndex);if(!N)return;let D=L();if(F(D),I=h,D.dataset.tableId=h.tableId,h.kind==="insertRow"){let Z=N.rows.find(ge=>ge.id===h.rowId);if(!Z)return;D.dataset.rowId=h.rowId,delete D.dataset.gridColumnId,D.className="docx-table-insert-row",D.setAttribute("aria-label",e.label("table.insertRowBelow"));let ee=Z.box.y+Z.box.height/2,ne=v(h.pageIndex,N.box.x-14,ee);D.style.left=`${ne.left}px`,D.style.top=`${ne.top-8}px`;}else {let Z=N.rows[0]?.cells.find(Ce=>Ce.gridColumnId===h.gridColumnId);if(!Z)return;D.dataset.gridColumnId=h.gridColumnId,delete D.dataset.rowId;let ee=N.columnEdges[Z.gridColumn]??0,ne=N.columnEdges[Z.gridColumn+1]??N.box.width;D.className="docx-table-insert-column",D.setAttribute("aria-label",e.label("table.insertColumnRight"));let ge=v(h.pageIndex,N.box.x+(ee+ne)/2-8,N.box.y-14);D.style.left=`${ge.left}px`,D.style.top=`${ge.top}px`;}t.contains(D)||t.append(D);}function oe(h){h.preventDefault(),h.stopPropagation();}function re(h,x){if(P(),F(S??m()),!(l||x.editingMode==="view")){if((h.kind==="columnDivider"||h.kind==="rightEdge")&&!h.isHeaderRepeat){let N=xo(x.layout,h.tableId,h.pageIndex);if(!N)return;let D=document.createElement("div");D.className=h.kind==="rightEdge"?"docx-table-edge-handle-right layout-table-edge-handle-right":"docx-table-divider-handle layout-table-resize-handle",D.style.position="absolute",D.style.pointerEvents="auto",D.style.cursor="col-resize",D.dataset.active="true";let Z=v(h.pageIndex,N.box.x+h.edgeX,N.box.y);D.style.left=`${Z.left-3}px`,D.style.top=`${Z.top}px`,D.style.width="6px",D.style.height=`${N.box.height*e.scale()}px`,D.addEventListener("pointerdown",Oe),t.append(D);}if(h.kind==="rowDivider"&&!h.isHeaderRepeat){let N=xo(x.layout,h.tableId,h.pageIndex);if(!N)return;let D=document.createElement("div");D.className="docx-table-row-divider-handle layout-table-row-resize-handle",D.style.position="absolute",D.style.pointerEvents="auto",D.style.cursor="row-resize",D.dataset.active="true";let Z=v(h.pageIndex,N.box.x,N.box.y+h.edgeY);D.style.left=`${Z.left}px`,D.style.top=`${Z.top-3}px`,D.style.width=`${N.box.width*e.scale()}px`,D.style.height="6px",D.addEventListener("pointerdown",Oe),t.append(D);}h.kind==="insertRow"&&!h.isHeaderRepeat&&z(h,x),h.kind==="insertColumn"&&!h.isHeaderRepeat&&z(h,x);}}function we(h,x){let N=ei(x.layout,h);if(!N)return;let D=Ja(x),Z=Nt({command:{type:"insertRow",where:"below",target:Qa(h.sourceRevision,N)},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...D});e.applyTableCommandPlan(Z);}function le(h,x){let N=ei(x.layout,h);if(!N)return;let D=N.row.cells.find(ge=>ge.gridColumnId===h.gridColumnId);if(!D)return;let Z=_d(h.sourceRevision,N,D);if(!Z)return;let ee=Ja(x),ne=Nt({command:{type:"insertColumn",where:"right",target:Z},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...ee});e.applyTableCommandPlan(ne);}function Oe(h){if(h.button!==0)return;let x=e.read();if(x.editingMode==="view"||!r||r.kind!=="columnDivider"&&r.kind!=="rightEdge"&&r.kind!=="rowDivider")return;h.preventDefault(),h.stopPropagation();let N=r,D=ei(x.layout,N);if(!D)return;let Z=_if(e.session().part().root,N.tableId);if(!Z.ok||N.kind!=="rowDivider"&&Z.topology.hasMerge)return;let ee=0,ne=0,ge=0,Ce=Z.topology.gridColumns.reduce((Be,Ae)=>Be+bo(Ae),0),Je;if(N.kind==="columnDivider"){let Be=Z.topology.gridColumns.find(Ie=>Ie.id===N.leftGridColumnId),Ae=Z.topology.gridColumns.find(Ie=>Ie.id===N.rightGridColumnId);if(!Be||!Ae)return;ee=bo(Be),ne=bo(Ae),Je=Bd(N.sourceRevision,D,N.leftGridColumnId,N.rightGridColumnId);}else if(N.kind==="rightEdge"){let Be=Z.topology.gridColumns.find(Ae=>Ae.id===N.gridColumnId);if(!Be)return;ee=bo(Be),ne=0,Je=Zd(N.sourceRevision,D,N.gridColumnId);}else ge=Math.max(20,Math.round(D.row.box.height*qd)),Je=Qa(N.sourceRevision,D);let qe=h.currentTarget;qe.setPointerCapture(h.pointerId),p=h.clientX,y=h.clientY,l={pointerId:h.pointerId,startClientX:h.clientX,startClientY:h.clientY,startEdgePt:N.kind==="rowDivider"?N.edgeY:N.edgeX,leftTwips:ee,rightTwips:ne,tableWidthTwips:Ce,rowHeightTwips:ge,target:N,ref:D,resizeTarget:Je,captureElement:qe,rightEdge:N.kind==="rightEdge",vertical:N.kind==="rowDivider",cancelled:false};for(let Be of [...t.children])Be!==qe&&Be.remove();T(N.kind==="rowDivider"?N.edgeY:N.edgeX,N);}function Ue(){if(l){try{l.captureElement.hasPointerCapture(l.pointerId)&&l.captureElement.releasePointerCapture(l.pointerId);}catch{}l.cancelled=true,l=null,k(),r=null;}}function xe(){if(!l||l.cancelled){l=null,k();return}let h=l;l=null;try{h.captureElement.hasPointerCapture(h.pointerId)&&h.captureElement.releasePointerCapture(h.pointerId);}catch{}if(h.vertical?y===h.startClientY:p===h.startClientX){k();return}let x=e.read(),N=Ja(x),D=(h.vertical?y-h.startClientY:p-h.startClientX)/e.scale(),Z=Math.round(D*qd),ee;if(h.target.kind==="rowDivider")ee=Tl({part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...N},h.resizeTarget,Math.max(20,h.rowHeightTwips+Z));else if(h.rightEdge&&h.target.kind==="rightEdge"){let ne=Math.max(300,h.leftTwips+Z),ge=Math.max(ne,h.tableWidthTwips+Z);ee=Nt({command:{type:"commitTableRightEdgeResize",target:h.resizeTarget,columnWidthTwips:ne,tableWidthTwips:ge},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...N});}else if(h.target.kind==="columnDivider"){let ne=h.leftTwips+Z,ge=h.rightTwips-Z;ne=Math.max(300,ne),ge=Math.max(300,ge);let Ce=h.leftTwips+h.rightTwips;ne+ge!==Ce&&(ne>Ce-300?(ne=Ce-300,ge=300):ge=Ce-ne),ee=Nt({command:{type:"commitTableColumnDividerResize",target:h.resizeTarget,leftWidthTwips:ne,rightWidthTwips:ge},part:e.session().part(),layout:x.layout,storeRevision:x.storeRevision,selection:x.selection,cellSelection:x.cellSelection,themeColors:x.themeColors,...N});}else {k();return}e.applyTableCommandPlan(ee),k();}function at(h){if(!a||!C)return null;let x=e.pageOffsetX(C.pageIndex);return oc$1(a,C.x,C.y,h.layout,x,C.pageIndex)}function Le(h){if(!r||l||h.editingMode==="view")return;A();let x=at(h);if(!x||x.kind==="tableBody"){r=null,k();return}if(mc$1(x)!==mc$1(r)){r=null,k();return}r=x,re(x,h);}function Ne(){let h=S??m(),x=h!==null&&document.activeElement===h;B(),h&&t.contains(h)&&h.remove(),x&&e.pagesLayer.focus({preventScroll:true});}function Xe(h){if(l||h.editingMode==="view")return;let x=S??m();if(!x||!t.contains(x)){I&&B();return}if(S=x,!I||I.kind!=="insertRow"&&I.kind!=="insertColumn")return;if(!a){Ne();return}let N=mc$1(I),D=nc$1(a,I);if(!D||mc$1(D)!==N){Ne();return}I=D,z(D,h);}function De(h){let x=e.read();if(l&&h.pointerId===l.pointerId){p=h.clientX,y=h.clientY;let ne=(l.vertical?h.clientY-l.startClientY:h.clientX-l.startClientX)/e.scale();for(let ge of [...t.children])ge!==l.captureElement&&ge.remove();T(l.startEdgePt+ne,l.target);return}if(x.editingMode==="view"){V(false);return}let N=eg(e,h.clientX,h.clientY),D=ac$1(x.layout,N.y);D>=0&&(C={x:N.x,y:N.y,pageIndex:D});let Z=D>=0?e.pageOffsetX(D):0,ee=a?oc$1(a,N.x,N.y,x.layout,Z,D>=0?D:void 0):null;if(!ee||ee.kind==="tableBody"){if(d)return;!n&&r&&(n=setTimeout(()=>{n=null,r=null,k();},Jp));return}n&&(clearTimeout(n),n=null),!(r&&lc$1(ee)===lc$1(r))&&(r=ee,re(ee,x));}function pe(h){if(!(!l||h.pointerId!==l.pointerId)){if(e.read().editingMode==="view"){Ue();return}xe();}}function R(h){!l||h.pointerId!==l.pointerId||Ue();}function X(h){h.key!=="Escape"||!l||Ue();}return e.pagesLayer.addEventListener("pointermove",De),document.addEventListener("pointermove",De),document.addEventListener("pointerup",pe),document.addEventListener("pointercancel",R),e.pagesLayer.addEventListener("keydown",X),{update(){let h=e.read(),x=o,N=i;a=kc$1(h.layout),o=h.layout.revision,i=h.storeRevision,h.editingMode==="view"?(Ue(),r=null,A(),V(true)):x!==null&&(x!==h.layout.revision||N!==h.storeRevision)&&(r!==null&&Le(h),Xe(h)),t.style.width=e.pagesLayer.style.width,t.style.height=e.pagesLayer.style.height;},refreshLabels(){let h=e.read();if(h.editingMode==="view")return;let x=S??m();if(x&&t.contains(x)&&I&&(I.kind==="insertRow"||I.kind==="insertColumn")){z(I,h);return}r&&(r.kind==="insertRow"||r.kind==="insertColumn")&&z(r,h);},destroy(){A(),Ue(),B(),k(),e.pagesLayer.removeEventListener("pointermove",De),document.removeEventListener("pointermove",De),document.removeEventListener("pointerup",pe),document.removeEventListener("pointercancel",R),e.pagesLayer.removeEventListener("keydown",X),t.remove();}}}var Kd=new WeakMap;function Io(e,t){let n=Kd.get(e);if(!n){n=new Map;for(let r of e.pages)for(let a of R(r))n.has(a.paragraphId)||n.set(a.paragraphId,a.props);Kd.set(e,n);}return n.get(t)??[]}var jd=new WeakMap;function tg(e,t){let n=jd.get(e);if(!n){let r=new Map,a=(o,i)=>{for(let l of o){if(l.kind==="paragraph"){r.has(l.paragraphId)||r.set(l.paragraphId,{indent:l.indent,inTable:i});continue}for(let d of l.rows)for(let p of d.cells)a(p.blocks,true);}};for(let o of e.pages)a(o.fragments,false);n=r,jd.set(e,r);}return n.get(t)??null}function So(e,t,n,r,a){let o=Ea$1(e,t);if(!o||o.kind!=="paragraph")return [];let i=[],l=Vf$1(o),d=Wf$1(o);return Qb$1(o.children,0,p=>{if(p.kind!=="run")return;let y=l.get(p.id);if(!y||y.end<=y.start)return;let C=Math.max(y.start,n),S=Math.min(y.end,r);C>=S||i.push({start:C,end:S,properties:Uf$1(Rf$1(Qf$1(p,"runProperties","rPr"),Of$1),a),...d.has(p.id)?{targetRunIds:[p.id]}:{}});}),i}function Vd(e,t,n,r){let a=Ea$1(e,t);if(!a||a.kind!=="paragraph")return false;let o=Vf$1(a),i=false,l=d=>{if(i||d.kind!=="run")return;let p=o.get(d.id);!p||p.end<=p.start||Math.max(p.start,n)>=Math.min(p.end,r)||Rf$1(Qf$1(d,"runProperties","rPr"),Of$1).length>0&&(i=true);};return Qb$1(a.children,0,l),i}function Ud(e,t,n){let r=Ea$1(e,t);if(!r||r.kind!=="paragraph")return [];let a=Vf$1(r),o=null,i=null,l=p=>{if(p.kind!=="run")return;let y=a.get(p.id);!y||y.end<=y.start||(y.start<n&&n<=y.end&&(o=p),i===null&&y.start<=n&&n<y.end&&(i=p));};Qb$1(r.children,0,l);let d=o??i;return d?Rf$1(Qf$1(d,"runProperties","rPr"),Of$1):Tf$1(e,t)}function En(e,t,n){let r=e?.find(o=>o.localName===t);if(!r)return null;let a=r.attributes?.val;return t==="vertAlign"?a===n:(t==="u"||a!=="0"&&a!=="false"&&a!=="off")&&a!=="none"}function Gd(e,t){if(!t||t.length===0)return e;let n=e;for(let r of t){let a=r.attributes?.val;switch(r.localName){case "b":n={...n,bold:En(t,"b")===true};break;case "i":n={...n,italic:En(t,"i")===true};break;case "u":n={...n,underline:En(t,"u")===true};break;case "strike":n={...n,strikethrough:En(t,"strike")===true};break;case "vertAlign":n={...n,superscript:a==="superscript",subscript:a==="subscript"};break;case "rFonts":n={...n,fontFamily:r.attributes?.ascii??n.fontFamily};break;case "sz":{let o=Number(a);Number.isFinite(o)&&(n={...n,fontSizeHalfPoints:o});break}case "color":n={...n,color:a==="auto"?null:a??n.color};break;case "highlight":n={...n,highlight:a==="none"?null:a??n.highlight};break;}}return n}function Wd(e,t,n){return n&&n.length>0?Ed$1(e,n):Bd$2(e,t)}function ti(e,t,n,r,a){let o=Wd(e,t,r);if(o.length===0)return false;let i=l=>{switch(n){case "b":return l.style.bold;case "i":return l.style.italic;case "u":return l.style.underline!==null;case "strike":return l.style.strike;case "vertAlign":return l.style.verticalAlign===a;default:return false}};return o.every(i)}function Xd(e,t,n,r,a){let o=Wd(e,t,r),i=o.map(v=>v.style),l=v=>{if(i.length===0)return null;let T=v(i[0]);return i.every(M=>v(M)===T)?T:null},d=v=>v.length>0&&v.every(T=>T===v[0])?v[0]:null,p=(v,T)=>v.props.some(M=>M.localName===T),y=v=>v.style.fontFamily??n?.(v.range.paragraphId,v.props).fontFamily??null,C=v=>p(v,"sz")?Math.round(v.style.fontSizePt*2):n?.(v.range.paragraphId,v.props).fontSizeHalfPoints??Math.round(v.style.fontSizePt*2),S=o.length===0?n?.(t.head.paragraphId,[]):void 0,I=ng(e,t),O=v=>d(I.map(T=>v(Io(e,T)))),m=O(v=>{let T=v.find(M=>M.localName==="jc")?.attributes?.val;return T==="center"||T==="right"||T==="both"?T:T==="end"?"right":"left"}),F=O(v=>v.find(T=>T.localName==="pStyle")?.attributes?.val??a??void 0)??null,B=v=>v.find(T=>T.localName==="spacing")?.attributes,A=O(v=>{let T=B(v),M=Number(T?.line);if(!Number.isFinite(M))return "";let G=T?.lineRule??"auto";return G==="auto"?`multiple:${Math.round(M/240*100)/100}`:`${G==="exact"?"exact":"atLeast"}:${Math.round(M/20*100)/100}`}),k=(()=>{if(!A)return null;let[v,T]=A.split(":");return {rule:v,value:Number(T)}})(),V=v=>O(T=>{let M=Number(B(T)?.[v]);return Number.isFinite(M)?Math.round(M/20*100)/100:null}),P=(()=>{let v=I.map(re=>tg(e,re)),T=v[0];if(!T||v.some(re=>re===null||re.inTable))return null;let M=re=>Math.round(re*20),G=re=>M(re.hanging>0?-re.hanging:re.firstLine),$=v,L=M(T.indent.left),z=M(T.indent.right),oe=G(T.indent);return {left:L,right:z,firstLine:oe,mixed:{left:$.some(re=>M(re.indent.left)!==L),right:$.some(re=>M(re.indent.right)!==z),firstLine:$.some(re=>G(re.indent)!==oe)}}})();return {bold:i.length>0&&i.every(v=>v.bold),italic:i.length>0&&i.every(v=>v.italic),underline:i.length>0&&i.every(v=>v.underline!==null),strikethrough:i.length>0&&i.every(v=>v.strike),superscript:i.length>0&&i.every(v=>v.verticalAlign==="superscript"),subscript:i.length>0&&i.every(v=>v.verticalAlign==="subscript"),fontFamily:o.length>0?d(o.map(y)):S?.fontFamily??null,fontSizeHalfPoints:o.length>0?d(o.map(C)):S?.fontSizeHalfPoints??null,color:l(v=>v.color),highlight:l(v=>v.highlight),alignment:m,styleId:F,lineSpacing:k,spaceBeforePt:V("before"),spaceAfterPt:V("after"),indent:P}}function ng(e,t){if(t.anchor.paragraphId===t.head.paragraphId)return [t.head.paragraphId];let n=wd$1(e),r=n.indexOf(t.anchor.paragraphId),a=n.indexOf(t.head.paragraphId);return r===-1||a===-1?[t.head.paragraphId]:n.slice(Math.min(r,a),Math.max(r,a)+1)}function $d(e,t,n,r){return t.paragraphId!==n.paragraphId?[]:t.offset!==0||n.offset!==e.length?[]:e.length===0?[]:[{op:"setParagraphMarkProperties",paragraphId:t.paragraphId,properties:r}]}function Yd(e){let{session:t,commit:n,orderedRange:r,selectionMark:a,textOf:o}=e,i=()=>t.partFor(e.storyScope())??t.part(),l=(I,O,m)=>t.applyTreeOps(I,O,m,e.storyScope()),d={get value(){return e.layout()}},p={get value(){return e.selection()}},y=(I,O,m)=>{let F=i();if(I.paragraphId===O.paragraphId){let P=So(F,I.paragraphId,I.offset,O.offset,m);if(P.length===0)return;let v=Uf$1(Tf$1(F,I.paragraphId),m);n(()=>l([...P.map(T=>({op:"setRunProperties",paragraphId:I.paragraphId,start:T.start,end:T.end,properties:T.properties,...T.targetRunIds?{targetRunIds:T.targetRunIds}:{}})),...$d(o(I.paragraphId),I,O,v)],a()));return}let B=e.paragraphOrder(),A=B.indexOf(I.paragraphId),k=B.indexOf(O.paragraphId);if(A===-1||k===-1)return;let V=[];for(let P=A;P<=k;P+=1){let v=B[P],T=o(v),M=P===A?I.offset:0,G=P===k?O.offset:T.length,$=M<G?So(F,v,M,G,m):[];for(let z of $)V.push({op:"setRunProperties",paragraphId:v,start:z.start,end:z.end,properties:z.properties,...z.targetRunIds?{targetRunIds:z.targetRunIds}:{}});(P<k||M===0&&G===T.length&&T.length>0)&&V.push({op:"setParagraphMarkProperties",paragraphId:v,properties:Uf$1(Tf$1(F,v),m)});}V.length!==0&&n(()=>l(V,a()));},C=(I,O)=>{let m=i(),F=[];for(let B of Dd$1(d.value,I)){let A=o(B);for(let k of So(m,B,0,A.length,O))F.push({op:"setRunProperties",paragraphId:B,start:k.start,end:k.end,properties:k.properties,...k.targetRunIds?{targetRunIds:k.targetRunIds}:{}});F.push({op:"setParagraphMarkProperties",paragraphId:B,properties:Uf$1(Tf$1(m,B),O)});}return F.length===0?false:(n(()=>l(F,a()),void 0,{keepCellSelection:true}),true)},S=I=>{Pf$1(I.localName)&&e.setPendingFormats(Uf$1(e.pendingFormats()??[],I));};return {setRunProperty(I,O){let m={localName:I,...O?{attributes:O}:{}},F=e.selectedCells?.();if(F&&F.length>0){C(F,m);return}let{from:B,to:A}=r();if(B.paragraphId===A.paragraphId&&B.offset===A.offset){S(m);return}y(B,A,m);},setParagraphProperty(I,O,m){let{from:F,to:B}=r(),A=e.paragraphOrder(),k=A.indexOf(F.paragraphId),V=A.indexOf(B.paragraphId);if(k===-1||V===-1)return;let P=i(),v=A.slice(k,V+1).map(T=>{let M=Sf$1(P,T),G=m?.mergeAttributes?{...M.find(L=>L.localName===I)?.attributes??{},...O}:O??{},$=Object.fromEntries(Object.entries(G).filter(([,L])=>L!=null));return {op:"setParagraphProperties",paragraphId:T,properties:Uf$1(M,{localName:I,...Object.keys($).length>0?{attributes:$}:{}})}});v.length!==0&&n(()=>l(v,a()));},formatting:()=>Gd(Xd(d.value,p.value,(I,O)=>{let m=t.effectiveRunDefaults(I,O);if(m.fontFamily!==null)return m;let F=e.defaultFontFamily?.()??null;return F===null?m:{...m,fontFamily:F}},e.selectedCells?.(),e.defaultParagraphStyleId?.()??null),e.pendingFormats()),toggleRunProperty(I,O){let m=e.selectedCells?.(),F=O?.val,B=En(e.pendingFormats(),I,F)??ti(d.value,p.value,I,m,F),A=B?{localName:I,attributes:{val:rg[I]??"0"}}:{localName:I,...O?{attributes:O}:{}};if(m&&m.length>0){C(m,A);return}let{from:k,to:V}=r();if(k.paragraphId===V.paragraphId&&k.offset===V.offset){let P=e.pendingFormats()??[],v=ti(d.value,p.value,I,void 0,F);if(!B===v){let T=P.filter(M=>M.localName!==I);e.setPendingFormats(T.length>0?T:null);}else S(A);return}y(k,V,A);},clearFormatting(){e.setPendingFormats(null);let I=d.value,O=e.paragraphOrder(),m=e.selectedCells?.(),F=m&&m.length>0?[...Dd$1(I,m)]:og(O,r());if(F.length===0)return;let{from:B,to:A}=r(),k=m!==void 0&&m.length>0,V=i(),P=[];for(let v of F){let T=o(v),M=k||v!==B.paragraphId?0:B.offset,G=k||v!==A.paragraphId?T.length:A.offset;M<G&&Vd(V,v,M,G)&&P.push({op:"setRunProperties",paragraphId:v,start:M,end:G,properties:[]}),Tf$1(V,v).length>0&&P.push({op:"setParagraphMarkProperties",paragraphId:v,properties:[]}),Sf$1(V,v).length>0&&P.push({op:"setParagraphProperties",paragraphId:v,properties:[]});}P.length!==0&&n(()=>l(P,a()),void 0,{keepCellSelection:k});}}}var rg={u:"none",vertAlign:"baseline"};function og(e,t){let n=e.indexOf(t.from.paragraphId),r=e.indexOf(t.to.paragraphId);return n===-1||r===-1?[]:e.slice(n,r+1)}var ag=Object.freeze({kind:"body"});function ko(e,t){if(e)return {kind:"headerFooter",rId:e.scope.rId};if(t){let n=_c$1(t.id);if(n)return {kind:"notesPart",noteKind:n.noteKind}}return {kind:"body"}}function Jd(e,t){return e?e.scope:t||ag}function ig(e,t,n){if(n){let a=[];for(let o of [e.footnotes,e.endnotes])if(o)for(let i of o.notes)i.scopeId===n&&a.push(...Qd(i.fragments));return a}if(!t)return R(e);let r=Fn(e,t);return r?Qd(r.fragments):[]}function Fn(e,t){let n=t.kind==="header"?e.header:e.footer;if(n&&(n.rId&&n.rId===t.scope.rId||!n.rId&&n.partName===t.partName))return n}function ec(e,t){for(let n of e.pages)for(let r of ["header","footer"]){let a=n[r];if(a?.rId===t)return {pageIndex:n.index,kind:r,story:a}}return null}function ni(e,t){return !!(e.rId&&e.rId===t.scope.rId||!e.rId&&e.partName===t.partName&&e.kind===t.kind)}function ri(e,t,n){let r=ac$1(e,t.y),a=e.pages[r];if(!a)return false;let o=t.x-n(r),i=t.y,l=a.contentBox;return o>=l.x&&o<l.x+l.width&&i>=l.y&&i<l.y+l.height}function oi(e,t,n,r,a={}){return dc$1(e,t,n.fragments,r,a)}function sg(e,t,n){let r=e.pages[t.pageIndex]??e.pages[0];if(!r)return null;let a=Fn(r,t);return a?pd$1(e,t.pageIndex,a.fragments,n):null}function lg(e,t,n){let r=[];for(let a of e.pages)for(let o of [a.footnotes,a.endnotes]){let i=o?.notes.find(l=>l.scopeId===t);i&&r.push(...pd$1(e,a.index,i.fragments,n));}return r.length>0?r:null}function tc(e,t){return e.querySelector(`[data-page-index="${t}"] > [data-docx-hf-active]`)??e.querySelector("[data-docx-hf-active]")}function nc(e,t,n){let r=e.querySelectorAll("[data-docx-note-scope]"),a=null;for(let o of r){if(o.dataset.docxNoteScope!==t||!o.matches("[data-docx-note]"))continue;a??=o;let i=Number(o.closest("[data-page-index]")?.dataset.pageIndex);if(n!==null&&i===n)return o}return a}function rc(e,t,n){if((o=>{let i=e.pages[o];return !!i&&!!Fn(i,t)})(t.pageIndex)&&(n===void 0||n.has(t.pageIndex)))return t.pageIndex;let a=null;for(let o of e.pages)if(Fn(o,t)&&(a===null&&(a=o.index),n===void 0||n.has(o.index)))return o.index;return a??t.pageIndex}function oc(e){return e?{rId:e.scope.rId,pageIndex:e.pageIndex,kind:e.kind,partName:e.partName,variant:e.variant}:null}function ac(e,t,n){e.classList.toggle("docx-paginated-surface--hf-editing",n),t.classList.toggle("docx-pages--hf-editing",n);}function ai(e,t,n,r,a,o,i){let l=a?sg(e,a,i):o?lg(e,o,i):null,d=zd$2(e,t,n,r,{...i?{measurer:i}:{},...l?{stops:l}:{}});if(!d)return null;if(!l)return d;let p=l.find(y=>y.position.paragraphId===d.position.paragraphId&&y.position.offset===d.position.offset);return p?{...d,pageIndex:p.pageIndex}:d}function ii(e,t,n){for(let r of e.pages){let a=n(r.index);for(let o of [r.footnotes,r.endnotes])if(o)for(let i of o.notes){let l=i.box,d=l.x+a,p=l.y;if(t.x>=d&&t.x<d+l.width&&t.y>=p&&t.y<p+l.height)return {pageIndex:r.index,scopeId:i.scopeId,noteKind:i.noteKind,noteId:i.noteId,local:{x:t.x-d,y:t.y-p},fragments:i.fragments}}}return null}function ic(e,t){let n=e[t],r=e.contentBox,a=e.box;if(t==="header"){let p=a.y,y=r.y,C=n?Math.max(y,n.box.y+n.box.height):y,S=n?Math.min(p,n.box.y):p;return C<=S?null:{x:r.x,y:S,width:r.width,height:C-S}}let o=r.y+r.height,i=a.y+a.height,l=n?Math.min(o,n.box.y):o,d=n?Math.max(i,n.box.y+n.box.height):i;return d<=l?null:{x:r.x,y:l,width:r.width,height:d-l}}function si(e,t,n){for(let r of e.pages){let a=n(r.index);for(let o of ["header","footer"]){if(r[o])continue;let i=ic(r,o);if(!i)continue;let l=i.x+a;if(t.x>=l&&t.x<l+i.width&&t.y>=i.y&&t.y<i.y+i.height)return {pageIndex:r.index,kind:o}}}return null}function li(e,t,n){for(let r of e.pages){let a=n(r.index);for(let o of ["header","footer"]){let i=r[o];if(!i)continue;let l=i.box,d=ic(r,o)??l,p=d.x+a,y=d.y;if(t.x>=p&&t.x<p+d.width&&t.y>=y&&t.y<y+d.height)return {pageIndex:r.index,kind:o,story:i,local:{x:t.x-(l.x+a),y:t.y-l.y}}}}return null}function On(e,t,n){if(!t&&!n)return wd$1(e);let r=new Set,a=[];for(let o of e.pages)for(let i of ig(o,t,n))r.has(i.paragraphId)||(r.add(i.paragraphId),a.push(i.paragraphId));return a}function To(e,t,n,r){let a=On(e,n,r);if(a.length===0)return t;let o=new Set(a),i=l=>o.has(l.paragraphId)?l:{paragraphId:a[0],offset:0};return {anchor:i(t.anchor),head:i(t.head)}}function Qd(e){let t=[],n=r=>{for(let a of r){if(a.kind==="paragraph"){t.push(a);continue}for(let o of a.rows)if(!o.isHeaderRepeat)for(let i of o.cells)n(i.blocks);}};return n(e),t}var dg=500,sc=4,An=40,Po=12;function cg(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),a=Math.min(e.x+e.width,t.x+t.width),o=Math.min(e.y+e.height,t.y+t.height);return a<=n||o<=r?0:(a-n)*(o-r)}function lc(e,t){return cg(e,t)>0?true:e.width===0?t.x<=e.x&&e.x<=t.x+t.width&&!(e.y+e.height<t.y||t.y+t.height<e.y):false}function ft(e,t,n){let r=wd$1(e),a=r.indexOf(t.paragraphId),o=r.indexOf(n.paragraphId);return a!==o?a-o:t.offset-n.offset}function uc(e,t,n){if(!(t>Ib))for(let r of e){if(r.kind==="paragraph"){n(r);continue}if(!(t>=Ib)){for(let a of r.rows)if(!a.isHeaderRepeat)for(let o of a.cells)uc(o.blocks,t+1,n);}}}function di(e,t){if(!t.placeholder||t.fragments.length===0)return null;let n=null,r=null,a=(i,l)=>{(!n||ft(e,i,n)<0)&&(n=i),(!r||ft(e,l,r)>0)&&(r=l);},o=t.level!=="inline";for(let i of t.fragments){let l=e.pages[i.pageIndex];l&&uc(l.fragments,0,d=>{if(lc(i.box,d.box)){if(o){let p=xd$1(e,d.paragraphId).length;a({paragraphId:d.paragraphId,offset:0},{paragraphId:d.paragraphId,offset:p});return}for(let p of d.lines)for(let y of p.spans)lc(i.box,y.box)&&a({paragraphId:y.range.paragraphId,offset:y.range.start},{paragraphId:y.range.paragraphId,offset:y.range.end});}});}return !n||!r?null:{from:n,to:r}}function ug(e,t){return (e.contentControls??[]).find(n=>n.id===t)??null}function dc(e,t){let n=t.contentControlId;if(!n){let a={x:t.caret.x,y:t.caret.y+t.caret.height/2},o=fc$1(e,t.pageIndex,a);return o?.placeholder?o:null}let r=ug(e,n);return r?.placeholder?r:null}function cc(e,t){let n=e.contentControls??[];if(n.length===0)return t;let r=ft(e,t.anchor,t.head)<=0?t.anchor:t.head,a=ft(e,t.anchor,t.head)<=0?t.head:t.anchor,o=true;for(;o;){o=false;for(let l of n){if(!l.placeholder)continue;let d=di(e,l);!d||!(ft(e,r,a)===0?ft(e,r,d.from)>=0&&ft(e,r,d.to)<0:ft(e,r,d.to)<0&&ft(e,a,d.from)>0)||(ft(e,d.from,r)<0&&(r=d.from,o=true),ft(e,d.to,a)>0&&(a=d.to,o=true));}}return ft(e,t.anchor,t.head)<=0?{anchor:r,head:a}:{anchor:a,head:r}}function fc(e,t={}){if(t.mode==="native")return {dragging:()=>false,destroy:()=>{}};let{pagesLayer:n,container:r}=e,a=n.ownerDocument,o=a.defaultView,i=null,l=null,d=0,p=0,y=0,C=0,S=null;function I(R,X){if(!l){let x=n.getBoundingClientRect();l={left:x.left,top:x.top};}let h=e.scale()||1;return {x:(R-l.left)/h,y:(X-l.top)/h}}function O(R){return {scope:{kind:"headerFooter",rId:R.rId},pageIndex:R.pageIndex,kind:R.kind,partName:R.partName,variant:R.variant}}function m(R,X){let h=e.layout(),x=I(R,X),N=ac$1(h,x.y),D=h.pages[N];if(!D)return null;let Z=e.measurer();return cc$1(h,N,{x:x.x-D.contentBox.x-e.pageOffsetX(N),y:x.y-D.contentBox.y},Z?{measurer:Z}:{})}function F(R,X){let h=e.activeNote?.()??null;if(h){let ee=e.layout(),ne=ii(ee,I(R,X),e.pageOffsetX);if(!ne||ne.scopeId!==h.scopeId)return null;let ge=e.measurer();return dc$1(ee,ne.pageIndex,ne.fragments,ne.local,{...ge?{measurer:ge}:{}})}let x=e.activeHeaderFooter?.()??null;if(!x)return m(R,X);let N=e.layout(),D=I(R,X),Z=li(N,D,e.pageOffsetX);if(Z&&ni(Z.story,O(x))){let ee=e.measurer();return oi(N,Z.pageIndex,Z.story,Z.local,ee?{measurer:ee}:{})}return null}function B(R,X){let{story:h,pageIndex:x,kind:N}=R;return {rId:h.rId,pageIndex:x,kind:N,partName:h.partName,variant:h.variant,...X?{position:X}:{}}}function A(R){let X=e.measurer();return oi(e.layout(),R.pageIndex,R.story,R.local,X?{measurer:X}:{})?.position??void 0}let k=new WeakMap;function V(R,X){let h=e.activeNote?.();if(h){let Z=On(R,null,h.scopeId).indexOf(X);return Z===-1?-1:Z}let x=e.activeHeaderFooter?.();if(x){let Z=On(R,O(x)).indexOf(X);return Z===-1?-1:Z}let N=k.get(R);return N||(N=new Map(wd$1(R).map((D,Z)=>[D,Z])),k.set(R,N)),N.get(X)??-1}function P(R,X,h){let x=V(R,X.paragraphId),N=V(R,h.paragraphId);return x!==N?x<N:X.offset<h.offset}let v=/[\p{L}\p{N}_'’]/u,T=R=>R!==void 0&&v.test(R);function M(R,X,h){if(h==="character")return {from:X,to:X};let x=xd$1(R,X.paragraphId),N=X.paragraphId;if(h==="paragraph")return {from:{paragraphId:N,offset:0},to:{paragraphId:N,offset:x.length}};let D=Math.max(0,Math.min(X.offset,x.length)),Z=-1;if(T(x[D])?Z=D:D>0&&T(x[D-1])&&(Z=D-1),Z===-1){let ee=D,ne=D;for(;ee>0&&/\s/.test(x[ee-1]??"");)ee-=1;for(;ne<x.length&&/\s/.test(x[ne]??"");)ne+=1;return ee===ne&&ne<x.length&&(ne+=1),{from:{paragraphId:N,offset:ee},to:{paragraphId:N,offset:ne}}}return {from:{paragraphId:N,offset:yd$1(x,Z+1,-1)},to:{paragraphId:N,offset:yd$1(x,Z,1)}}}function G(R,X,h,x,N){let D=N?dc(R,N):null,Z=D?di(R,D)??M(R,h,x):M(R,h,x),ee=P(R,Z.from,X.from)?{anchor:X.to,head:Z.from}:{anchor:X.from,head:Z.to};return cc(R,ee)}let $=r.closest(".docx-editor__scroll-container");function L(){return r.closest(".docx-editor__scroll-container")}function z(R,X,h){if(h<R+An){let x=Math.max(0,R+An-h);return -Math.min(Po,x/An*Po)}if(h>X-An){let x=Math.max(0,h-(X-An));return Math.min(Po,x/An*Po)}return 0}function oe(){S!==null&&(o?.cancelAnimationFrame(S),S=null);}function re(){S=null;let R=i,X=L();if(!R||!X||!o)return;let h=X.getBoundingClientRect(),x=z(h.top,h.bottom,R.clientY);x!==0&&(X.scrollTop+=x,l=null,le(R.clientX,R.clientY),S=o.requestAnimationFrame(re));}function we(){if(S!==null||!o||!i)return;let R=L();if(!R)return;let X=R.getBoundingClientRect();z(X.top,X.bottom,i.clientY)!==0&&(S=o.requestAnimationFrame(re));}function le(R,X){let h=i;if(!h)return;let x=F(R,X);x&&(e.isReadOnlyParagraph?.(x.position.paragraphId)||Oe(h,x)||e.setSelection(G(e.layout(),h.anchorRange,x.position,h.granularity,x)));}function Oe(R,X){let h=R.anchorCell;if(!h)return false;if(!X.cell||X.cell.tableId!==h.tableId)return R.cellDragging;if(!R.cellDragging&&X.cell.cellId===h.cellId)return false;let x=Cd$2(e.layout(),h,X.cell);return x?(R.cellDragging=true,e.setCellSelection(x),true):R.cellDragging}function Ue(R){let X=Date.now(),h=X-p;return d=Math.abs(R.clientX-y)<=sc&&Math.abs(R.clientY-C)<=sc&&h>=0&&h<=dg?d+1:1,p=X,y=R.clientX,C=R.clientY,d}let xe=["character","word","paragraph"],at=R=>{if(R.button!==0)return;let X=R.target?.closest?.("[data-docx-cc-widget]");if(X){if(R.preventDefault(),R.stopPropagation(),X.hasAttribute("disabled")||X.dataset.disabledReason)return;let me=X.dataset.docxCcId,ye=X.dataset.docxCcWidget;me&&ye&&e.onContentControlWidget?.(me,ye);return}if(R.pointerType==="touch")return;i&&De(),l=null;let h=e.layout(),x=I(R.clientX,R.clientY),N=e.activeHeaderFooter?.()??null,D=e.activeNote?.()??null,Z=li(h,x,e.pageOffsetX),ee=ii(h,x,e.pageOffsetX),ne=R.target?.closest("[data-docx-hf]"),ge=!!(ne||Z),Ce=R.target,Je=Ce?.closest("[data-docx-note-ref]"),qe=Ce?.closest("[data-docx-note-mark-back]"),Be=null,Ae=()=>Be??=Ue(R);if(Je?.dataset.docxNoteScope){R.preventDefault(),e.focus(),e.enterNote?.(Je.dataset.docxNoteScope);return}if(qe){R.preventDefault(),e.focus(),e.exitNote?.(true);return}if(ee&&!ge){let me=e.measurer?.(),ye=dc$1(h,ee.pageIndex,ee.fragments,ee.local,{...me?{measurer:me}:{}});if(!D||D.scopeId!==ee.scopeId){R.preventDefault(),e.focus(),e.enterNote?.(ee.scopeId,ye?{paragraphId:ye.position.paragraphId,offset:ye.position.offset}:void 0,ee.pageIndex);return}if(D.pageIndex!==ee.pageIndex){R.preventDefault(),e.focus(),e.enterNote?.(ee.scopeId,ye?{paragraphId:ye.position.paragraphId,offset:ye.position.offset}:void 0,ee.pageIndex);return}}else if(D){if(!ri(h,x,e.pageOffsetX))return;e.exitNote?.(false),e.focus();}if(N)if(Z&&ni(Z.story,O(N)))Z.pageIndex!==N.pageIndex&&e.enterHeaderFooter?.(B(Z,A(Z)));else if(Z&&Z.story.rId){R.preventDefault(),e.focus(),e.enterHeaderFooter?.(B(Z,A(Z)));return}else if(ri(h,x,e.pageOffsetX)){R.preventDefault(),e.exitHeaderFooter?.(true),e.focus();return}else {let me=Ae()>=2?si(h,x,e.pageOffsetX):null;me&&(R.preventDefault(),e.focus(),e.enterEmptyHeaderFooter?.(me.kind,me.pageIndex));return}else if(ge&&Ae()>=2){if(Z?.story.rId)R.preventDefault(),e.focus(),e.enterHeaderFooter?.(B(Z,A(Z)));else if(ne instanceof HTMLElement){let me=ne.dataset.docxRId,ye=ne.dataset.docxHf,Y=ne.closest("[data-page-index]")?.getAttribute("data-page-index"),bt=Y!=null?Number(Y):NaN;if((ye==="header"||ye==="footer")&&Number.isInteger(bt))if(me){let $t=h.pages[bt]?.[ye];R.preventDefault(),e.focus(),e.enterHeaderFooter?.({rId:me,pageIndex:bt,kind:ye,partName:$t?.partName??"",variant:$t?.variant??"default"});}else h.pages[bt]?.[ye]||(R.preventDefault(),e.focus(),e.enterEmptyHeaderFooter?.(ye,bt));}return}else if(Ae()>=2){let me=si(h,x,e.pageOffsetX);if(me){R.preventDefault(),e.focus(),e.enterEmptyHeaderFooter?.(me.kind,me.pageIndex);return}}let Ie=F(R.clientX,R.clientY);if(!Ie)return;if(e.isReadOnlyParagraph?.(Ie.position.paragraphId)){R.preventDefault();return}R.preventDefault(),e.focus();try{n.setPointerCapture(R.pointerId);}catch{}a.addEventListener("pointermove",Ne),a.addEventListener("pointerup",Xe),a.addEventListener("pointercancel",Xe);let Mn=Ae(),$e=R.shiftKey?"character":xe[(Mn-1)%xe.length],it=dc(h,Ie);if(it&&!R.shiftKey){if(e.selectContentControl?.(it.id)){let ye=e.selection(),Y=P(h,ye.anchor,ye.head)||ye.anchor.paragraphId===ye.head.paragraphId&&ye.anchor.offset===ye.head.offset?{from:ye.anchor,to:ye.head}:{from:ye.head,to:ye.anchor};i={pointerId:R.pointerId,granularity:"character",anchorRange:Y,anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY};return}let me=di(h,it);if(me){i={pointerId:R.pointerId,granularity:"character",anchorRange:me,anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY},Le(()=>e.setSelection({anchor:me.from,head:me.to}));return}}if(R.shiftKey){let me=e.selection();i={pointerId:R.pointerId,granularity:$e,anchorRange:{from:me.anchor,to:me.anchor},anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY},Le(()=>e.setSelection(G(h,{from:me.anchor,to:me.anchor},Ie.position,$e,Ie)));}else {let me=M(h,Ie.position,$e);i={pointerId:R.pointerId,granularity:$e,anchorRange:me,anchorCell:Ie.cell,cellDragging:false,clientX:R.clientX,clientY:R.clientY},Le(()=>e.setSelection(cc(h,{anchor:me.from,head:me.to})));}};function Le(R){try{R();}catch(X){throw De(),X}}let Ne=R=>{let X=i;!X||R.pointerId!==X.pointerId||(R.preventDefault(),X.clientX=R.clientX,X.clientY=R.clientY,le(R.clientX,R.clientY),we());},Xe=R=>{let X=i;if(!X||R.pointerId!==X.pointerId)return;De();try{n.releasePointerCapture(X.pointerId);}catch{}let h=e.cellSelection();h?e.setCellSelection(h):e.setSelection(e.selection());};function De(){if(i)try{n.releasePointerCapture(i.pointerId);}catch{}i=null,l=null,oe(),a.removeEventListener("pointermove",Ne),a.removeEventListener("pointerup",Xe),a.removeEventListener("pointercancel",Xe);}let pe=()=>{l=null;};return n.addEventListener("pointerdown",at),$?.addEventListener("scroll",pe,{passive:true}),o?.addEventListener("scroll",pe,{capture:true,passive:true}),o?.addEventListener("resize",pe,{passive:true}),{dragging:()=>i!==null,destroy(){De(),n.removeEventListener("pointerdown",at),$?.removeEventListener("scroll",pe),o?.removeEventListener("scroll",pe,{capture:true}),o?.removeEventListener("resize",pe);}}}var hc=/^[^\s]{1,512}$/;function wo(e){let t=e.dataset?.paragraphId,n=e.dataset?.start;return !t||n===void 0||!/^\d{1,9}$/.test(n)||!hc.test(t)||t==="__proto__"?null:{paragraphId:t,start:Number(n)}}function yc(e){let t=e.nodeType===Node.TEXT_NODE?e.parentNode:e;for(;t&&t.nodeType===Node.ELEMENT_NODE;){let n=wo(t);if(n)return {element:t,identity:n};t=t.parentNode;}return null}function vc(e){return e.querySelector("[data-docx-hf-active]")}function fg(e){let t=vc(e);return t?[t,e]:[e]}function pc(e,t){let n=yc(e);if(n)return n;if(e.nodeType!==Node.ELEMENT_NODE)return null;let r=e.querySelectorAll("[data-paragraph-id][data-start]"),a=t?[...r].reverse():[...r];for(let o of a){let i=wo(o);if(i)return {element:o,identity:i}}return null}function pg(e,t){let n=[...e.childNodes];if(n.length===0)return null;for(let r=Math.max(0,t);r<n.length;r+=1){let a=pc(n[r],false);if(a)return {paragraphId:a.identity.paragraphId,offset:a.identity.start}}for(let r=Math.min(t,n.length)-1;r>=0;r-=1){let a=pc(n[r],true);if(a)return {paragraphId:a.identity.paragraphId,offset:a.identity.start+(a.element.textContent?.length??0)}}return null}function gc(e,t,n){if(!n.contains(e))return null;let r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;if(r?.closest("[data-docx-field]"))return null;let a=r?.closest("[data-docx-hf]");if(a&&!a.hasAttribute("data-docx-hf-active")||vc(n)&&r?.closest(".docx-page-content"))return null;let o=r?.closest("[data-docx-marker]");if(o)return o.parentElement?xc(o.parentElement):null;if(r?.closest("[data-docx-tab-leader]"))return null;if(e.nodeType===Node.ELEMENT_NODE){let p=e,y=wo(p);if(y){let S=p.textContent?.length??0;return {paragraphId:y.paragraphId,offset:y.start+(t>0?S:0)}}let C=pg(p,t);return C||yg(p)}let i=yc(e);if(!i)return null;let l=t,d=i.element.textContent?.length??0;return {paragraphId:i.identity.paragraphId,offset:i.identity.start+Math.max(0,Math.min(l,d))}}function Co(e,t){if(!t||t.rangeCount===0)return null;let{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=t;if(!n||!a)return null;let i=gc(n,r,e),l=gc(a,o,e);if(!i||!l){let d=i??l;return d?{anchor:d,head:d}:null}return {anchor:i,head:l}}function bc(e,t){if(!t||t.rangeCount===0)return false;let{anchorNode:n,focusNode:r}=t;return !!n&&e.contains(n)||!!r&&e.contains(r)}function mc(e,t){for(let n of fg(e)){let r=gg(n,t);if(r)return r}return null}function gg(e,t){let n=e.querySelectorAll("[data-paragraph-id][data-start]"),r=null,a=null;for(let o of n){let i=wo(o);if(!i||i.paragraphId!==t.paragraphId)continue;let l=mg(o),d=o.textContent?.length??0,p=i.start+d;if(l&&t.offset>=i.start&&t.offset<=p){let y={node:l,offset:t.offset-i.start};if(t.offset<p)return y;r=y;}}return r||(a=hg(e,t.paragraphId),a?{node:a,offset:0}:null)}function mg(e){let t=e.firstChild;for(;t&&t.nodeType===Node.ELEMENT_NODE;)t=t.firstChild;return t&&t.nodeType===Node.TEXT_NODE?t:null}function hg(e,t){let n=null;for(let r of e.querySelectorAll("[data-paragraph-id]"))if(r.dataset?.paragraphId===t&&r.dataset?.start===void 0){if(r.dataset?.lineId!==void 0)return r;n??=r;}return n}function xc(e){let t=e.closest("[data-paragraph-id]");if(!t||t.dataset.start!==void 0)return null;let n=t.dataset.paragraphId;return !n||!hc.test(n)||n==="__proto__"?null:{paragraphId:n,offset:0}}function yg(e){let t=xc(e);return !t||e.closest("[data-paragraph-id]").querySelector("[data-paragraph-id][data-start]")?null:t}function Ic(e,t,n){if(!n)return false;let r=mc(e,t.anchor),a=mc(e,t.head);if(!r||!a)return false;let o=Co(e,n);if(o&&Sr(o,t))return true;try{return n.setBaseAndExtent(r.node,r.offset,a.node,a.offset),!0}catch{return false}}function Sr(e,t){return e.anchor.paragraphId===t.anchor.paragraphId&&e.anchor.offset===t.anchor.offset&&e.head.paragraphId===t.head.paragraphId&&e.head.offset===t.head.offset}function Sc(e){let{document:t,pagesLayer:n,session:r}=e,a=false,o=false,i=false,l=null;function d(){let S=Co(n,t.getSelection());return !S||Sr(S,e.selection())?false:(e.adoptSelection(S),true)}function p(){let S=t.activeElement;if(S&&n.contains(S))return true;let I=t.getSelection();if(!I||I.rangeCount===0)return true;let O=I.anchorNode;return !O||!O.isConnected?true:n.contains(O)}let y=()=>{let S=t.getSelection(),I=Co(n,S);if(!I){if(!bc(n,S))return;let O=Fe(e.selection().head);if(Sr(O,e.selection()))return;e.setSelection(O);return}Sr(I,e.selection())||e.setSelection(I);};function C(S){let I=kd(n,S);if(I===null)return;let O=Td(S,e.textOf(S),I);if(!O)return;let m=O.ops.find(A=>A.op==="insertText"),F=m?e.pendingFormatOps?.(S,m.offset,m.text.length)??[]:[],B=e.storyScope();e.commit(()=>{let A=r.applyTreeOps([...O.ops,...F],e.selectionMark(),void 0,B);return F.length===0||!A.rejected?A:r.applyTreeOps(O.ops,e.selectionMark(),void 0,B)}),e.setSelection(Fe({paragraphId:S,offset:O.caret}));}return {adoptBeforePaint(){let S=e.holdsCellSelection?.()===true||e.isGesturing?.()===true,I=o||S?false:d();return o=false,I},noteModelMoved(){o=true;},noteSelectionSettled(){o=false;},mirrorToDom(S=false){if(e.updateCaret(),!S&&!p())return;a=true;let I=e.now();Ic(n,e.domSelection?.()??e.selection(),t.getSelection()),e.recordSelectionMs(e.now()-I),queueMicrotask(()=>{a=false;});},isComposing:()=>i,onSelectionChange:()=>{a||i||e.isGesturing?.()||e.holdsCellSelection?.()||y();},onCompositionStart:()=>{i=true,l=e.selection().head.paragraphId,r.beginComposition(e.storyScope());},onCompositionEnd:()=>{i=false;let S=l??e.selection().head.paragraphId;l=null,C(S),r.endComposition(),e.flushLayout(),e.render();}}}function vg(e,t){let n={...e??{}};return e?.start!==void 0&&(n.start=t),(e?.start===void 0||e.left!==void 0)&&(n.left=t),n}function kc(e,t,n,r){let a={...e};if(r===null)return delete a[t],delete a[n],a;let o=String(r),i=e[n]!==void 0;return i&&(a[n]=o),(!i||e[t]!==void 0)&&(a[t]=o),a}function bg(e,t){let n={...e};return t===null?(delete n.firstLine,delete n.hanging,n):(t>=0?(n.firstLine=String(t),n.hanging="0"):(n.hanging=String(-t),n.firstLine="0"),n)}function Tc(e){let{session:t,commit:n,orderedStart:r,orderedRange:a,selectionMark:o,collapsedAt:i}=e,l=e.deleteSelectionPlan,d=()=>t.partFor(e.storyScope())??t.part(),p=(P,v,T)=>t.applyTreeOps(P,v,T,e.storyScope()),y=()=>e.paragraphOrder(),C={get value(){return e.layout()}},S=720,I=8;function O(P){return m(P)?.level??null}function m(P){for(let v of C.value.pages)for(let T of R(v))if(T.paragraphId===P)return T.marker??null;return null}function F(P){let v=m(P);return v?v.numFmt==="bullet"?"bullet":"ordered":null}function B(P,v){let T=y(),M=T.indexOf(P[0]??""),G=T.indexOf(P[P.length-1]??"");if(M===-1||G===-1)return null;for(let $ of [M-1,G+1]){let L=T[$];if(!L)continue;let z=m(L);if(z&&(z.numFmt==="bullet"?"bullet":"ordered")===v)return z.numId}return null}function A(P,v){return v<0||v>I?false:e.numberingLevelExists(P.numId,v)}function k(P,v){return v<0||v>I?false:e.numberingLevelExists(P.numId,v)?true:t.ensureNumberingLevel(P.numId,v,P.numFmt==="bullet"?"bullet":"ordered")&&e.numberingLevelExists(P.numId,v)}function V(P){let v=P.find(M=>M.localName==="ind"),T=v?.attributes?.left??v?.attributes?.start;return !T||!/^-?\d{1,7}$/.test(T)?0:Number(T)}return {insertTab(){let P=l(),v=P.collapseTo;n(()=>p([...P.ops,{op:"insertTab",paragraphId:v.paragraphId,offset:v.offset}],o()),()=>i({...v,offset:v.offset+1}));},insertLineBreak(){let P=l(),v=P.collapseTo;n(()=>p([...P.ops,{op:"insertHardBreak",paragraphId:v.paragraphId,offset:v.offset}],o()),()=>i({...v,offset:v.offset+1}));},insertPageBreak(){let P=l(),v=P.collapseTo;n(()=>p([...P.ops,{op:"insertPageBreak",paragraphId:v.paragraphId,offset:v.offset}],o()),()=>i({...v,offset:v.offset+1}));},exitListOnEmptyItem(){let{from:P,to:v}=a();if(P.paragraphId!==v.paragraphId||P.offset!==v.offset)return false;let T=m(P.paragraphId);if(!T||e.paragraphTextOf(P.paragraphId).length>0)return false;let $=T.level>0&&A(T,T.level-1)?{op:"setListLevel",paragraphId:P.paragraphId,level:T.level-1}:{op:"setListNumbering",paragraphId:P.paragraphId,numId:null},L=false;return n(()=>{let z=p([$],o());return L=z.committed,z}),L},isListParagraph(){let{paragraphId:P}=r();return O(P)!==null},isListActive(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=P==="bullet"?"bullet":"ordered",z=M.slice(G,$+1);return z.length>0&&z.every(oe=>F(oe)===L)},toggleList(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=M.slice(G,$+1);if(L.length===0)return false;let z=L.every(le=>F(le)===P),oe=z?null:B(L,P)??t.ensureListDefinition(P);if(!z&&oe===null)return false;let re=L.map(le=>({op:"setListNumbering",paragraphId:le,numId:oe})),we=false;return n(()=>{let le=p(re,o());return we=le.committed,le}),we},canAdjustIndent(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=P==="increase"?1:-1;return M.slice(G,$+1).some(z=>{let oe=m(z);if(oe){let we=oe.level+L;return we>=0&&we<=I}let re=V(Io(C.value,z));return Math.max(0,re+L*S)!==re})},adjustIndent(P){let{from:v,to:T}=a(),M=y(),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=P==="increase"?1:-1,z=[];for(let re of M.slice(G,$+1)){let we=Io(C.value,re),le=m(re),Oe=le?.level??null;if(le&&Oe!==null){let Ne=Oe+L;if(Ne<0||Ne>I||!k(le,Ne))continue;z.push({op:"setListLevel",paragraphId:re,level:Ne});continue}let Ue=V(we),xe=Math.max(0,Ue+L*S);if(xe===Ue)continue;let at=Sf$1(d(),re),Le=at.find(Ne=>Ne.localName==="ind");z.push({op:"setParagraphProperties",paragraphId:re,properties:Uf$1(at,{localName:"ind",attributes:vg(Le?.attributes,String(xe))})});}if(z.length===0)return false;let oe=false;return n(()=>{let re=p(z,o());return oe=re.committed,re}),oe},setIndent(P){if(P.left===void 0&&P.right===void 0&&P.firstLine===void 0)return false;let{from:v,to:T}=a(),M=wd$1(C.value),G=M.indexOf(v.paragraphId),$=M.indexOf(T.paragraphId);if(G===-1||$===-1)return false;let L=[];for(let oe of M.slice(G,$+1)){let re=Sf$1(t.part(),oe),le={...re.find(Oe=>Oe.localName==="ind")?.attributes??{}};P.left!==void 0&&(le=kc(le,"left","start",P.left)),P.right!==void 0&&(le=kc(le,"right","end",P.right)),P.firstLine!==void 0&&(le=bg(le,P.firstLine)),L.push({op:"setParagraphProperties",paragraphId:oe,properties:Uf$1(re,{localName:"ind",...Object.keys(le).length>0?{attributes:le}:{}})});}if(L.length===0)return false;let z=false;return n(()=>{let oe=t.applyTreeOps(L,o());return z=oe.committed,oe}),z},sectionProperties:()=>Cc$1(t.part()),sectionPropertiesAt(P){let v=Dc$1(t.part());if(v.length===1)return v[0].properties;let T=rc$1(t.part()),M=(L,z)=>{if(L.id===z)return true;for(let oe of L.children)if(oe.kind!=="textValue"&&M(oe,z))return true;return false},G=T.findIndex(L=>L.id===P||M(L,P)),$=v[v.length-1];if(G!==-1)for(let L of v)if(L.blockStart<=G)$=L;else break;return $.properties},setSectionProperties(P){let v=false;return n(()=>{let T=t.applyTreeOps([{op:"setSectionProperties",...P}],o(),void 0,{kind:"body"});return v=T.committed,T}),v},insertSectionBreak(){if(e.storyScope().kind!=="body")return false;let P=l(),v=P.collapseTo,T=new Set(t.paragraphIds()),M=false;return n(()=>{let G=t.applyTreeOps([...P.ops,{op:"splitParagraph",paragraphId:v.paragraphId,offset:v.offset},{op:"setSectionMark",paragraphId:v.paragraphId}],o(),void 0,{kind:"body"});return M=G.committed,G},()=>{let G=t.paragraphIds().find($=>!T.has($));return G?i({paragraphId:G,offset:0}):null}),M}}}var wc=32;function ui(e){return e.kind!=="textValue"&&e.kind==="contentControl"}function fi(e){return e.kind!=="textValue"&&e.kind==="contentControlContent"}function cn(e){return e.kind==="textValue"?[]:e.children}function ci(e,t=0){return e.kind==="run"?[e]:e.kind==="hyperlink"?e.children.flatMap(n=>ci(n,t)):ui(e)?t>=wc?[]:cn(e).filter(n=>fi(n)).flatMap(n=>cn(n).flatMap(r=>ci(r,t+1))):[]}function Ro(e){if(e.kind==="textValue")return e.value.length;if(e.kind==="tab"||e.kind==="hardBreak")return 1;if(e.kind==="runProperties"||e.kind==="generic")return 0;if(ui(e)){let n=0;for(let r of cn(e))if(fi(r))for(let a of cn(r))n+=Ro(a);return n}let t=0;for(let n of cn(e))t+=Ro(n);return t}function Cc(e,t,n){for(let r of e){if(r.kind==="hyperlink"){n(r);continue}if(ui(r)){if(t>=wc)continue;for(let a of cn(r))fi(a)&&Cc(cn(a),t+1,n);continue}n(r);}}function xg(e,t,n,r){let a=Ig(e,t);if(!a||a.kind!=="paragraph")return [];let o=r(t),i=[],l=0;return Cc(a.children,0,d=>{if(d.kind==="run"){l+=Ro(d);return}if(d.kind!=="hyperlink")return;let p=l;for(let C of ci(d))l+=Ro(C);let y=Ta$1(d,n);i.push({id:d.id,paragraphId:t,start:p,end:l,text:o.slice(p,l),kind:y.kind,href:y.href,authored:y.authored,...y.anchor!==void 0?{anchor:y.anchor}:{},...y.tooltip!==void 0?{tooltip:y.tooltip}:{}});}),i}function Ig(e,t){let n=r=>{if(r.kind==="textValue")return r.id===t?r:null;if(r.id===t)return r;for(let a of r.children){let o=n(a);if(o)return o}return null};return n(e.root)}function Sg(e,t){for(let n of e)if(n.paragraphId===t.paragraphId&&t.offset>=n.start&&t.offset<=n.end)return n;return null}function Rc(e){let t=()=>e.storyScope(),n=()=>e.session.partFor(t()),r=d=>e.session.relationshipTarget(d,t()),a=(d,p,y)=>e.session.applyTreeOps(d,p,y,t()),o=d=>{let p=n();return p?xg(p,d,r,e.textOf):[]},i=()=>Sg(o(e.selection().head.paragraphId),e.selection().head),l=d=>{let p=e.selection().head.paragraphId,y=o(p).find(C=>C.id===d);if(y)return y;for(let C of e.session.paragraphIdsIn(t())){let S=o(C).find(I=>I.id===d);if(S)return S}return null};return {linksInCaretParagraph:()=>o(e.selection().head.paragraphId),linkAtCaret:i,linkById:l,applyHyperlink(d){let p=d.url!==void 0&&d.url.length>0,y=d.anchor!==void 0&&d.anchor.length>0;if(p===y)return false;let C=t();if(!n()||e.refusesWrite())return false;let S;if(p){let M=e.session.ensureHyperlinkRelationship(d.url,C);if(!M)return false;S=M;}let I={...S!==void 0?{relationshipId:S}:{},...y?{anchor:d.anchor}:{},...d.tooltip!==void 0?{tooltip:d.tooltip}:{}},O=i(),m=e.orderedRange(),F=m.from.paragraphId===m.to.paragraphId&&m.from.offset===m.to.offset;if(O&&(F||Tg(O,m))){let M=[{op:"setHyperlinkTarget",linkId:O.id,...I}];if(d.text!==void 0&&d.text!==O.text){let $=Pc(O.paragraphId,O.start,O.end,d.text);if(!$)return false;M.push(...$);}let G=false;return e.commit(()=>{let $=a(M,e.selectionMark());return G=$.committed,$},()=>null),G}let B=m.from.paragraphId;if(m.to.paragraphId!==B)return false;let A=[],k=m.from.offset,V=m.to.offset;if(F){let M=d.text??d.url??d.anchor??"";if(M.length===0)return false;A.push({op:"insertText",paragraphId:B,offset:k,text:M}),V=k+M.length;}else if(d.text!==void 0&&d.text!==e.textOf(B).slice(k,V)){let M=Pc(B,k,V,d.text);if(!M)return false;A.push(...M),V=k+d.text.length;}if(V<=k)return false;let P=kg(e.session);A.push({op:"insertHyperlink",paragraphId:B,start:k,end:V,...I,...P?{styleId:P}:{}});let v=false,T={paragraphId:B,offset:V};return e.commit(()=>{let M=a(A,e.selectionMark(),{paragraphId:B,start:V,end:V});return v=M.committed,M},()=>({anchor:T,head:T})),v},removeHyperlink(d){if(!n())return false;let p=d?l(d):i();if(!p)return false;let y=false,C={paragraphId:p.paragraphId,offset:p.end};return e.commit(()=>{let S=a([{op:"removeHyperlink",linkId:p.id}],e.selectionMark());return y=S.committed,S},()=>({anchor:C,head:C})),y}}}function kg(e){for(let t of e.documentStyles())if(t.type==="character"&&t.styleId.toLowerCase()==="hyperlink")return t.styleId;return null}function Tg(e,t){return t.from.paragraphId===e.paragraphId&&t.to.paragraphId===e.paragraphId&&t.from.offset>=e.start&&t.to.offset<=e.end}function Pc(e,t,n,r){if(r.length===0)return null;let a=[{op:"insertText",paragraphId:e,offset:t,text:r,bias:"right"}];return n>t&&a.push({op:"deleteText",paragraphId:e,start:t+r.length,end:n+r.length}),a}var Pg=24;function Ec(e){let{pagesLayer:t}=e,n=t.ownerDocument.defaultView;function r(){return e.container.closest(".docx-editor__scroll-container")}let a=S=>{if(!S||S.length===0||S.startsWith("#"))return false;let I=U(S);return !I.ok||!I.href||!n?false:(n.open(I.href,"_blank","noopener,noreferrer"),true)},o=S=>{let I=e.layout(),O=qd$1(I,S);if(!O)return false;let m=I.pages[O.pageIndex];if(!m)return false;let F=m.box.y+(m.contentBox.y-m.box.y)+O.y,B=r();return B&&(B.scrollTop=Math.max(0,F*e.scale()-Pg),e.onScrolled?.()),e.setSelection(S),true},i=S=>{let I=e.bookmarks().get(S);return I?o(I):false},l=null;function d(S){if(!S||S.closest("[data-docx-hf]"))return null;let I=S.closest("a.docx-hyperlink");if(I){let m=I.dataset.docxLink;return m?{linkId:m,drawing:false}:null}let O=S.closest("[data-docx-drawing-link]");if(O){let m=O.dataset.docxDrawingLink;return m?{linkId:m,drawing:true}:null}return null}let p=S=>{l=null;let I=S.target,O=d(I);if(!O)return;let F=I.closest("[data-docx-drawing-link], a.docx-hyperlink").getBoundingClientRect();l={linkId:O.linkId,drawing:O.drawing,rect:{left:F.left,top:F.top,bottom:F.bottom,right:F.right}};},y=S=>{let I=S.target,O=d(I);if(!O){let B=l;if(l=null,!B)return;S.preventDefault(),C(B.linkId,B.rect,S,B.drawing);return}l=null,S.preventDefault();let F=I.closest("[data-docx-drawing-link], a.docx-hyperlink").getBoundingClientRect();C(O.linkId,{left:F.left,top:F.top,bottom:F.bottom,right:F.right},S,O.drawing);};function C(S,I,O,m){let F=m?e.drawingLinkById?.(S)??null:e.linkById(S);if(!F)return;if(O.metaKey||O.ctrlKey){F.kind==="external"?a(F.href):F.anchor&&i(F.anchor);return}if(e.isCollapsedSelection()){if(F.kind==="internal"){F.anchor&&i(F.anchor);return}e.onPopover?.({link:F,rect:I});}}return t.addEventListener("pointerdown",p,true),t.addEventListener("click",y),{goToPosition:o,goToBookmark:i,openExternal:a,destroy(){t.removeEventListener("pointerdown",p,true),t.removeEventListener("click",y);}}}function wg(e){let t=e.hyperlinkHref;if(!t)return null;let n=e.kind==="anchoredDrawing"?e.anchorParagraphId:e.paragraphId,r=e.kind==="inlineDrawing"?e.start:0,a=t.startsWith("#")?"internal":"external";return Object.freeze({id:e.drawingNodeId,paragraphId:n,start:r,end:r+1,text:"",kind:a,href:t,authored:t,...a==="internal"?{anchor:t.slice(1)}:{}})}function pi(e,t){return e.drawingNodeId!==t?null:wg(e)}function Fc(e,t){if(!e)return null;for(let n of e.anchoredDrawings??[]){let r=pi(n,t);if(r)return r}return null}function Cg(e,t){for(let r of e.anchoredDrawings??[]){let a=pi(r,t);if(a)return a}for(let r of e.fragments){if(r.kind==="table"){for(let o of r.rows)for(let i of o.cells)for(let l of i.blocks){let d=Ac(l,t);if(d)return d}continue}let a=Oc(r,t);if(a)return a}let n=Fc(e.header,t);return n||Fc(e.footer,t)}function Oc(e,t){for(let n of e.lines)for(let r of n.drawings??[]){let a=pi(r,t);if(a)return a}return null}function Ac(e,t){if(e.kind==="table"){for(let n of e.rows)for(let r of n.cells)for(let a of r.blocks){let o=Ac(a,t);if(o)return o}return null}return Oc(e,t)}function Mc(e,t){for(let n of e.pages){let r=Cg(n,t);if(r)return r}return null}function Hc(e){return {applyHeaderFooterLifecycle(t){let n=null;return e.commit(()=>{let r=e.applyOps([t]);return r.rejected&&(n=String(r.reason??"rejected")),r}),n?{ok:false,reason:n}:{ok:true}},insertPageField(t){if(!e.isHeaderFooterOpen())return false;let n=e.orderedStart();return e.commit(()=>e.applyOps([...e.deleteSelectionOps(),{op:"insertPageField",paragraphId:n.paragraphId,offset:n.offset,field:t}],e.selectionMark()),()=>e.collapsedAt({paragraphId:n.paragraphId,offset:n.offset+(t==="PAGE_X_OF_Y"?6:1)})),e.lastRejection()===null}}}var kr="the document is open for viewing",Eo="image property edits are not supported in suggesting mode",Rg="trackedDrawingDeletionUnsupported";function Lc(e){function t(){return {committed:false,rejected:true,opCount:0,reason:kr}}function n(){return {committed:false,rejected:true,opCount:0,reason:Eo}}return {applyDrawingOps(r){if(e.editingMode()==="view")return t();if(e.editingMode()==="suggest")return n();let a=e.selectionMark();return e.applyOps(r,a,a)},applyImageProperties(r){if(e.editingMode()==="view")return {ok:false,reason:"invalidArgs",detail:kr};if(e.editingMode()==="suggest")return {ok:false,reason:"invalidArgs",detail:Eo};let a={ok:false,reason:"invalidArgs"};return e.commit(()=>(a=e.session.applyImageProperties(e.storyScope(),r),{committed:a.ok,rejected:!a.ok,opCount:a.ok?1:0,...a.ok?{}:{reason:a.detail??a.reason}})),a},deleteImage(r){if(e.editingMode()==="view")return {ok:false,reason:"invalidArgs",detail:kr};if(e.editingMode()==="suggest")return {ok:false,reason:"invalidArgs",detail:Rg};let a={ok:false,reason:"invalidArgs"};return e.commit(()=>(a=e.session.deleteImage(e.storyScope(),r),{committed:a.ok,rejected:!a.ok,opCount:a.ok?1:0,...a.ok?{}:{reason:a.detail??a.reason}})),a},insertImage(r){return e.editingMode()==="view"?Promise.resolve({ok:false,reason:"invalidArgs",detail:kr}):e.editingMode()==="suggest"?Promise.resolve({ok:false,reason:"invalidArgs",detail:Eo}):e.session.insertImage(e.storyScope(),{...r,decodePort:e.decodePort()})},replaceImage(r,a,o,i){return e.editingMode()==="view"?Promise.resolve({ok:false,reason:"invalidArgs",detail:kr}):e.editingMode()==="suggest"?Promise.resolve({ok:false,reason:"invalidArgs",detail:Eo}):e.session.replaceImage(e.storyScope(),r,a,o,e.decodePort(),i)}}}function Dc(e){let t=null,n=null,r="",a=()=>{if(!t)return;let l=rc(e.layout(),t,e.materializedPages?.());l!==t.pageIndex&&(t={...t,pageIndex:l});},o=l=>{if(!l.rId||e.session.partFor({kind:"headerFooter",rId:l.rId})===null)return false;let d=e.layout(),p=ec(d,l.rId),y=t,C=y?.scope.rId===l.rId,S=p?null:Eg(e.session,l.rId);if(!p&&!S)return false;let I=l.pageIndex??(C&&y?y.pageIndex:p?.pageIndex??0),O=l.kind??(C&&y?y.kind:p?.kind??S.kind),m=l.variant??(C&&y?y.variant:p?.story.variant??S.variant),F=C&&y?y.partName:p?.story.partName??S.partName,B=d.pages[I]??d.pages[p?.pageIndex??0],A=(B?Fn(B,{scope:{kind:"headerFooter",rId:l.rId},kind:O,partName:F}):null)??p?.story??{scope:{rId:l.rId},variant:m,partName:F},k=e.selection(),V=y?y.savedBodySelection:{anchor:{...k.anchor},head:{...k.head}},P=l.sectionIndex??(C&&y?.sectionIndex!==void 0?y.sectionIndex:S?.sectionIndex);t={scope:{kind:"headerFooter",rId:l.rId},pageIndex:I,...P!==void 0?{sectionIndex:P}:{},kind:O,variant:A.variant,partName:A.partName,savedBodySelection:V};let T=e.session.paragraphIdsIn(ko(t))[0];if(!T)return t=null,false;let M=l.position?To(d,{anchor:l.position,head:l.position},t):C?To(d,k,t):{anchor:{paragraphId:T,offset:0},head:{paragraphId:T,offset:0}};return e.setScopeSelection(M),e.noteModelMoved(),e.render(),e.mirrorToDom(),e.notify(),true},i=()=>{if(!t)return;let l=t.savedBodySelection;t=null,e.setScopeSelection(To(e.layout(),l,null)),e.noteModelMoved(),e.render(),e.mirrorToDom(),e.notify();};return {getActive:()=>t,activeScope:()=>Jd(t),setActiveScope(l){return l.kind==="body"?(i(),true):l.kind==="headerFooter"?o({rId:l.rId}):false},enterHeaderFooter:o,exitHeaderFooter:i,reconcileOccurrence:a,headerFooterState(){if(!t)return null;let l=e.session.headerFooterResolutionBySection(),d=t.sectionIndex??0,p,y,C,S=B=>{let A=l[B];if(!A)return false;let V=(t.kind==="header"?A.headers:A.footers).get(t.variant);return !V||V.rId!==t.scope.rId?false:(d=B,p=V.inherited,y=A.titlePage,C=A.evenAndOddHeaders,true)};if(!(t.sectionIndex!==void 0&&S(t.sectionIndex))){let B;l.forEach((A,k)=>{let P=(t.kind==="header"?A.headers:A.footers).get(t.variant);!P||P.rId!==t.scope.rId||!(B===void 0||B&&!P.inherited||B===P.inherited&&k<d)||(d=k,p=P.inherited,y=A.titlePage,C=A.evenAndOddHeaders,B=P.inherited);});}let I=Dc$1(e.session.part()),O=I[d]?.properties??I.at(-1)?.properties,m=O?.margins.headerTwips,F=O?.margins.footerTwips;return {editing:t.kind,sectionIndex:d,variant:t.variant,rId:t.scope.rId,partName:t.partName,...p!==void 0?{inherited:p}:{},...y!==void 0?{titlePage:y}:{},...C!==void 0?{evenAndOddHeaders:C}:{},...m!==void 0?{headerDistanceTwips:m}:{},...F!==void 0?{footerDistanceTwips:F}:{}}},headerFooterStateStable(l){if(!t)return n=null,r="",null;let d=this.headerFooterState();if(!d)return null;let p=[l,d.editing,d.sectionIndex,d.variant??"",d.rId??"",d.partName??"",String(d.inherited),String(d.titlePage),String(d.evenAndOddHeaders),String(d.headerDistanceTwips??""),String(d.footerDistanceTwips??"")].join("|");return n&&r===p||(n=Object.freeze({...d}),r=p),n}}}function Eg(e,t){let n=e.headerFooterResolutionBySection();for(let r=0;r<n.length;r+=1){let a=n[r];for(let o of ["header","footer"]){let i=o==="header"?a.headers:a.footers;for(let[l,d]of i)if(d.rId===t)return {sectionIndex:r,kind:o,variant:l,partName:d.partName}}}return null}function _c(e){let t=null,n=null,r=null,a=i=>(e.setLastRejection(null),e.commit(()=>{let l=e.applyOps([i],e.selectionMark());return l.rejected&&e.setLastRejection(String(l.reason??"rejected")),l}),e.lastRejection()===null),o=(i,l,d)=>{let p=_c$1(i);if(!p)return e.setLastRejection("invalid note scope id"),false;let y=e.session.currentPackage(),C=Rd$1(y,p.noteKind),S=C?td$2(C.root,p.noteId):null;if(!C||!S)return e.setLastRejection("note not found"),false;if(e.activeScope().kind==="body"){let I=e.selection();r={anchor:{paragraphId:I.anchor.paragraphId,offset:I.anchor.offset},head:{paragraphId:I.head.paragraphId,offset:I.head.offset}};}if(t={kind:"note",id:Zc$1(p.noteKind,p.noteId)},n=Number.isInteger(d)?d:null,l)e.setSelection({anchor:l,head:l});else {let I=Fg(S),O=new Set(e.session.paragraphIdsIn({kind:"notesPart",noteKind:p.noteKind})),m=I.find(F=>O.has(F.id));if(m){let F=Og(m);e.setSelection({anchor:{paragraphId:m.id,offset:F},head:{paragraphId:m.id,offset:F}});}}return e.noteModelMoved(),e.render(),n??=e.revealNote(t.id),e.notify(),true};return {insertNote(i){if(e.activeScope().kind!=="body")return e.setLastRejection("insertNote requires body scope"),false;let l=e.orderedStart(),d=Nc(e.session.currentPackage(),i);if(!a({op:"insertNote",noteKind:i,paragraphId:l.paragraphId,offset:l.offset}))return false;let C=[...Nc(e.session.currentPackage(),i)].find(S=>!d.has(S));return C===void 0?true:o(Zc$1(i,C))},deleteNote(i,l){return a({op:"deleteNote",noteKind:i,noteId:l})},convertNote(i,l){return a({op:"convertNote",fromKind:i,noteId:l})},convertAllNotes(i){return a({op:"convertAllNotes",fromKind:i})},setNoteProperties(i){return a({op:"setNoteProperties",scope:i.scope,sectionIndex:i.sectionIndex,footnote:i.footnote,endnote:i.endnote})},enterNote:o,exitNote(i=true){if(!t)return;let l=r;t=null,n=null,r=null,e.setActiveScopeBodyOrHf({kind:"body"}),i&&l&&e.setSelection(l),e.noteModelMoved(),e.render(),e.notify();},activeNoteScope(){return t},activeNotePageIndex(){return n},setActiveNotePageIndex(i){!t||!Number.isInteger(i)||n!==i&&(n=i);}}}function Fg(e){let t=[],n=(r,a)=>{if(!(a>32)){if(r.kind==="paragraph"){t.push(r);return}if("children"in r)for(let o of r.children)n(o,a+1);}};return n(e,0),t}function Og(e){let t=Kd$1(e)[0];return t&&dd$2(t.node)?t.end:0}function Nc(e,t){let n=Rd$1(e,t),r=new Set;if(!n)return r;for(let a of sd$2(n.root)){if(!jd$2(a))continue;let o=hd$1(a);o!==null&&r.add(o);}return r}var Ag=500;function Mg(e,t){let n=e.part(),r=Dc$1(n),a=rc$1(n),o=new Map;for(let i=0;i<r.length;i+=1){let l=r[i];for(let d=l.blockStart;d<l.blockEndExclusive;d+=1){let p=a[d];if(!p)continue;if(p.kind==="paragraph"){o.set(p.id,i);continue}let y=(C,S)=>{if(!(S>32)){if(C.kind==="paragraph"&&typeof C.id=="string"){o.set(C.id,i);return}for(let I of C.children??[])y(I,S+1);}};y(p,0);}}return o.get(t)??0}function Hg(e,t){let n=e.part(),r=rc$1(n),a=[];for(let o=0;o<r.length;o+=1){let i=r[o];if(i.kind!=="paragraph")continue;let l=Bc$2(i);l&&a.push(l);}for(;a.length<t.length;)a.push(void 0);return a}function Bc(e){if(!e)return null;let t=e.session,n=e.state().selection.head.paragraphId,r=Mg(t,n),a=t.currentPackage(),o=zd$1(a),i=Ad$1(o),l=Bd$1(o),d=Dc$1(t.part()),p=Hg(t,d),y=xd$2(p[r]),C=yd$2(p[r]),S=Cd$1(y,i),I=Dd$2(C,l);return {sectionIndex:r,footnote:{resolved:S,...i?{documentAuthored:i}:{},...y?{sectionAuthored:y}:{}},endnote:{resolved:I,...l?{documentAuthored:l}:{},...C?{sectionAuthored:C}:{}}}}function Zc(e,t){let n=_c$1(t);if(!n)return null;let r=Rd$1(e.currentPackage(),n.noteKind);if(!r)return null;let a=r,o=td$2(a.root,n.noteId);if(!o)return null;let i=[],l=Ag,d=(y,C)=>{if(!(C>32||l<=0)){if(y.kind==="paragraph"&&typeof y.id=="string"){let S=(vf$1(a,y.id)??"").replace(/\uFFFC/g,"").trim();if(S){let I=S.slice(0,l);i.push(I),l-=I.length;}return}if(y.kind!=="textValue")for(let S of y.children)d(S,C+1);}};d(o,0);let p=i.filter(Boolean).join(" ").trim();return p.length>0?p:null}function qc(e,t){let n=e.setScale;return typeof n!="function"?false:n.call(e,t)}function gi(e,t,n={}){let r=n,a=j$1(t,n.reviewModel?{reviewModel:n.reviewModel}:{});if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let o=a.session,i=n.scale??96/72,l={resolve:n.tableInteractionLabel??(s=>Ka(s))},d="the document is open for viewing",p="the table of contents is generated and read-only",y="\0range\0",C=()=>`${new Date().toISOString().slice(0,19)}Z`,S=n.measurer?null:jd$1(i,{context:Rn(e.ownerDocument),...n.fontAlias?{fontAlias:n.fontAlias}:{}}),I=n.measurer??S.measurer,O=kb(),m=dd$1();function F(){return n.measurer?n.producer??"host-measurer":`${n.producer??S?.producer??"fixed-measurer"}@scale:${i}`}let B=F(),A=e.ownerDocument,k=A.createElement("div");k.className="docx-pages",k.style.position="relative",k.contentEditable="true",k.spellcheck=false,k.setAttribute("role","textbox"),k.setAttribute("aria-multiline","true"),k.style.outline="none";let V=A.createElement("div");V.className="docx-selection-overlay",V.contentEditable="false",V.setAttribute("aria-hidden","true"),V.style.position="absolute",V.style.left="0",V.style.top="0",V.style.pointerEvents="none";let P=A.createElement("div");P.className="docx-comment-overlay",P.contentEditable="false",P.setAttribute("aria-hidden","true"),P.style.position="absolute",P.style.left="0",P.style.top="0",P.style.pointerEvents="none";let v=A.createElement("div");v.className="docx-table-furniture",v.contentEditable="false",v.style.position="absolute",v.style.left="0",v.style.top="0",v.style.pointerEvents="none",e.style.position="relative",e.replaceChildren(k,v,P,V);let T=Dd(k,()=>i,()=>{let s=pe?.getActive()??null,c=R$1?.activeNoteScope()??null,u=R$1?.activeNotePageIndex()??null,g=s?tc(k,s.pageIndex):c?nc(k,c.id,u):null;return {layout:Y,selection:L,measurer:I,...s?{preferredPageIndex:s.pageIndex}:u!==null?{preferredPageIndex:u}:{},scopedHost:g,...s?{scopedHostKind:"headerFooter"}:c?{scopedHostKind:"note"}:{}}}),M=new Set(tc$1(o.part()).flatMap(s=>[s.beginParagraphId,...s.resultParagraphIds,s.endParagraphId])),G=o.paragraphIds(),$=G.find(s=>!M.has(s))??G[0]??"",L={anchor:{paragraphId:$,offset:0},head:{paragraphId:$,offset:0}},z=null,oe=null,re=false,we=false,le=null;function Oe(s,c){if(s.paragraphId===c.paragraphId)return s.offset-c.offset;let u=D();return u.indexOf(s.paragraphId)-u.indexOf(c.paragraphId)}function Ue(s){if(!le)return;let{from:c,to:u}=Ua(Y,le),g=s.head;Oe(g,c)>=0&&Oe(g,u)<=0||(le=null);}let xe=null;function at(){return Le()?.properties??null}function Le(){if(!xe)return null;let s=xe.position,c=u=>u.paragraphId===s.paragraphId&&u.offset===s.offset;return c(L.anchor)&&c(L.head)?xe:null}function Ne(s){if(!xe)return;let c=xe.position;s.anchor.paragraphId===c.paragraphId&&s.anchor.offset===c.offset&&s.head.paragraphId===c.paragraphId&&s.head.offset===c.offset||(xe=null);}function Xe(s,c,u,g){let b=He([...s],u,g);return s.length===c.length||!b.rejected?b:He([...c],u,g)}function De(s,c,u){let g=Le();if(!g||u===0)return [];let b=xe.position;return b.paragraphId!==s||b.offset!==c?[]:[{op:"setRunProperties",paragraphId:s,start:c,end:c+u,properties:g.properties.reduce((E,_)=>Uf$1(E,_),[...g.base])}]}let pe=null,R$1=null,X=null,h="",x=()=>ko(pe?.getActive()??null,R$1?.activeNoteScope()??null),N=()=>R$1?.activeNoteScope()?.id??null,D=()=>On(Y,pe?.getActive()??null,N()),Z=()=>globalThis.performance?.now()??Date.now(),ee=0,ne=0,ge=0,{styleCascade:Ce,numberingIndex:Je,defaultTabStopPt:qe}=wd(o),Be=null,Ae=n.imageDecodePort??Md(A)??Hd(),Ie=tc$2({session:o,decodePort:Ae,onResourcesChanged:()=>Be?.()}),Mn=n.drawingStrings??b$1,$e=Ld({mintValidatedBytes:(s,c)=>Ie.mintValidatedBytes(s,c)}),it=Wa({session:o,measurer:I,producer:B,cache:O,styleCascade:Ce,defaultTabStopPt:qe,inlineDrawingLayoutForPart:s=>Ie.contextForPart(s),drawingLayoutTokenForPart:s=>Ie.cacheTokenForPart(s),drawingTokenForParagraphForPart:(s,c)=>Ie.drawingTokenForParagraph(c,s)}),me=s=>{let c=Ta$1(s,u=>o.relationshipTarget(u));return s.kind==="textValue"?null:{id:s.id,kind:c.kind,href:c.href,...c.anchor!==void 0?{anchor:c.anchor}:{},...c.tooltip!==void 0?{tooltip:c.tooltip}:{}}},ye={...o,applyTreeOps:(s,c,u)=>He(s,c,u),applyPmDoc:s=>_e==="view"?{committed:false,rejected:true,opCount:0,reason:d}:_o()?{committed:false,rejected:true,opCount:0,reason:p}:o.applyPmDoc(s)},Y=Pr(),bt=Yd({session:ye,storyScope:x,paragraphOrder:D,layout:()=>Y,selection:()=>L,commit:(s,c,u)=>ke(s,c,u),orderedRange:()=>Jt(),selectionMark:()=>Pe(),textOf:s=>Ot(s),selectedCells:()=>z?.cellIds,defaultParagraphStyleId:()=>Ce?.defaultParagraphStyleId??null,defaultFontFamily:()=>n.defaultFontFamily??null,pendingFormats:()=>at(),setPendingFormats:s=>{if(s===null||s.length===0){if(!xe)return;xe=null;}else {let{anchor:c,head:u}=L;if(c.paragraphId!==u.paragraphId||c.offset!==u.offset)return;let g=Le()?.base??Ud(o.partFor(x())??o.part(),u.paragraphId,u.offset);xe={position:u,properties:s,base:g};}n.onChange?.(he());}}),fn=Tc({session:ye,storyScope:x,paragraphOrder:D,layout:()=>Y,commit:(s,c)=>ke(s,c,{rearmPending:Le()??void 0}),orderedStart:()=>Lr(),orderedRange:()=>Jt(),selectionMark:()=>Pe(),collapsedAt:s=>Fe(s),deleteSelectionPlan:()=>en(),paragraphTextOf:s=>Ot(s),numberingLevelExists:(s,c)=>Rb(Vb(Je(),Ce),s,c)!==null}),$t=Rc({session:ye,refusesWrite:()=>Ar(true)!==null,storyScope:x,selection:()=>L,orderedRange:()=>Jt(),selectionMark:()=>Pe(),textOf:s=>Ot(s),commit:(s,c)=>ke(s,c)}),xt=Ec({pagesLayer:k,container:e,scale:()=>i,layout:()=>Y,bookmarks:()=>o.bookmarks(),linkById:s=>$t.linkById(s),drawingLinkById:s=>Mc(Y,s),setSelection:s=>pt(Fe(s)),isCollapsedSelection:()=>L.anchor.paragraphId===L.head.paragraphId&&L.anchor.offset===L.head.offset,onScrolled:()=>Kt(),...n.onHyperlinkPopover?{onPopover:n.onHyperlinkPopover}:{}});k.addEventListener("contextmenu",Q),k.addEventListener("click",J),k.addEventListener("pointermove",Dn),k.addEventListener("pointerleave",Er);let It=null;function Hn(s){Ie.sync(o);let c=Od({session:o,measurer:I,producer:B,cache:O,styleCascade:Ce,defaultTabStopPt:qe,inlineDrawingLayoutForPart:u=>Ie.contextForPart(u),drawingTokenForParagraphForPart:(u,g)=>Ie.drawingTokenForParagraph(g,u)});return fd$1(o.part(),s,{measurer:I,cache:O,session:m,producer:B,styleCascade:Ce,defaultTabStopPt:qe,numberingIndex:Je(),sectionFurniture:it.sectionFurniture(),furniture:it.furniture(),projectLink:me,inlineDrawingLayout:Ie.bodyContext,drawingTokenForParagraph:u=>Ie.drawingTokenForParagraph(u,o.part().name),...c?{notes:c}:{},...n.revisionDisplayMode?{displayMode:n.revisionDisplayMode}:{}})}function Pr(){let s=Z(),c=Hn(o.packageRevision());return ee=Z()-s,c}let et=nd$1({run:s=>{let c=Z(),u=Hn(s.revision);return ee=Z()-c,u},currentRevision:()=>o.packageRevision(),publish:s=>{Y=s,Ge();}}),_t=false;Be=()=>{et.invalidateAll(o.packageRevision(),"drawing-resources"),!_t&&(_t=true,setTimeout(()=>{_t=false,tt();},0));};let Ho=o.subscribe(s=>{xe=null,et.notify(s);});function Ln(){let s=Ed(e,Y,L,i),c=pe?.getActive()?.pageIndex;return c===void 0||s===void 0||s.has(c)?s:new Set([...s,c])}function tt(){return et.pending()?et.flush():false}let Bt=null;function wr(s){return s.contentControlId??`toc:${s.id}`}function st(s){return tc$1(o.part()).find(c=>c.beginParagraphId===s||c.endParagraphId===s||c.resultParagraphIds.includes(s))}function Cr(){for(let s of k.querySelectorAll(".docx-content-control-chrome[data-docx-toc]")){if(s.getAttribute("data-docx-content-control")===Bt){s.dataset.hover="",s.dataset.boundaryVisible="";continue}delete s.dataset.hover,re||delete s.dataset.boundaryVisible;}}function Rr(s){Bt!==s&&(Bt=s,Cr());}function Dn(s){let u=s.target?.closest("[data-paragraph-id]")?.dataset.paragraphId,g=u?st(u):null;Rr(g?wr(g):null);}function Nn(s){let c=s.target,u=c?.isConnected?c.closest("[data-paragraph-id]"):void 0;if(u)return u.dataset.paragraphId;let g=k.ownerDocument;return typeof g.elementFromPoint!="function"?void 0:g.elementFromPoint(s.clientX,s.clientY)?.closest("[data-paragraph-id]")?.dataset.paragraphId}function Er(){Rr(null);}function Lo(){let s=Rt(),c=vc$1(o.part()),g=tc$1(o.part()).map(j=>{let se=St(j);return se?{...se,empty:c.has(j.beginParagraphId)}:null}).filter(j=>j!==null),b=new Set(g.map(j=>j.boundary.id)),E=new Set(g.filter(j=>j.empty).map(j=>j.boundary.id)),_=s&&!b.has(s.id)?new Set([s.id]):void 0,K=Bt?new Set([Bt]):void 0,U=new Set(td$1(Y).filter(j=>j.controlType==="checkbox"&&f(j.id)).map(j=>j.id)),ie=g.filter(j=>j.additional&&!j.empty).map(j=>j.boundary);if(!(!re&&!_&&!K&&U.size===0&&ie.length===0&&b.size===0))return {...re?{showAll:true}:{},..._?{activeIds:_}:{},...K?{hoverIds:K}:{},...U.size>0?{checkedIds:U}:{},...ie.length>0?{additionalBoundaries:ie}:{},...b.size>0?{tocControlIds:b}:{},...E.size>0?{suppressedIds:E}:{}}}function St(s){let c=s.contentControlId?td$1(Y).find(b=>b.id===s.contentControlId):void 0;if(c)return {tocId:s.id,boundary:c,additional:false};let u=new Set([s.beginParagraphId,...s.resultParagraphIds,s.endParagraphId]),g=Y.pages.flatMap(b=>{let E=R(b).filter(j=>u.has(j.paragraphId)).map(j=>j.box);if(E.length===0)return [];let _=Math.min(...E.map(j=>j.x)),K=Math.min(...E.map(j=>j.y)),U=Math.max(...E.map(j=>j.x+j.width)),ie=Math.max(...E.map(j=>j.y+j.height));return [{pageIndex:b.index,box:{x:_,y:K,width:U-_,height:ie-K}}]});return g.length===0?null:{tocId:s.id,additional:true,boundary:{id:`toc:${s.id}`,controlType:"richText",lock:"unlocked",effectiveLock:"unlocked",placeholder:false,bound:false,nestingDepth:0,level:"block",fragments:g}}}function Rt(){let s=qd$1(Y,L.head,I);return s?sd$1(Y,{x:s.x,y:s.y+s.height/2,pageIndex:s.pageIndex}):null}function _n(s){return s.bound?"bound":s.effectiveLock==="contentLocked"||s.effectiveLock==="sdtContentLocked"?"locked":null}function pn(s){return s.effectiveLock==="sdtLocked"||s.effectiveLock==="sdtContentLocked"?"locked":null}function Yt(s){return Jb(s)}function Et(s){let c=Ea$1(o.part(),s);return !c||!Yt(c)?null:c}function Fr(s){let c=Et(s);if(!c)return null;for(let u of c.children)if(u.kind!=="textValue"&&(u.kind==="contentControlProperties"||u.localName==="sdtPr"))for(let g of u.children){if(g.kind==="textValue"||g.localName!=="tabIndex")continue;let b=g.attributes.find(_=>_.localName==="val")?.value;if(b===void 0)return null;let E=Number(b);return Number.isFinite(E)?E:null}return null}function Or(){return [...td$1(Y)].filter(c=>_n(c)===null).sort((c,u)=>{let g=Fr(c.id),b=Fr(u.id);return g!==null&&b!==null&&g!==b?g-b:g!==null&&b===null?-1:g===null&&b!==null?1:0})}function kt(s){if(s.kind==="textValue")return s.value.length;if(s.kind==="tab"||s.kind==="hardBreak")return 1;if(s.kind==="runProperties"||s.kind==="generic")return 0;if(s.kind==="contentControl"){let g=0;for(let b of s.children)if(b.kind!=="textValue"&&(b.kind==="contentControlContent"||b.localName==="sdtContent"))for(let E of b.children)g+=kt(E);return g}let u=0;for(let g of s.children)u+=kt(g);return u}function Bn(s){for(let c of s.children)if(c.kind!=="textValue"&&(c.kind==="contentControlContent"||c.localName==="sdtContent"))return c.children;return []}function Zn(s){let c=Et(s);if(!c)return false;let u=Bn(c),g=[],b=ie=>{for(let j of ie){if(j.kind==="paragraph"){g.push({id:j.id,length:kt(j)});continue}if(j.kind==="textValue")continue;if(j.kind==="contentControl"){b(Bn(j));continue}b(j.children);}};if(b(u),g.length>0){let ie=g[0],j=g[g.length-1];return pt({anchor:{paragraphId:ie.id,offset:0},head:{paragraphId:j.id,offset:j.length}}),true}let E=null,_=0,K=0,U=(ie,j,se)=>{let ue=j;for(let be of ie){if(be.id===s)return E=se,_=ue,K=ue+kt(be),true;if(be.kind==="textValue"){ue+=be.value.length;continue}if(be.kind==="contentControl"){let tn=kt(be);if(U(Bn(be),ue,se))return true;ue+=tn;continue}if(be.kind==="run"||be.kind==="hyperlink"){if(U(be.children,ue,se))return true;ue+=kt(be);continue}if(be.kind==="paragraph"){if(U(be.children,0,be.id))return true;continue}if(be.kind==="tab"||be.kind==="hardBreak"){ue+=1;continue}if(U(be.children,ue,se))return true;ue+=kt(be);}return false};return U(o.part().root.children,0,""),E?(pt({anchor:{paragraphId:E,offset:_},head:{paragraphId:E,offset:K}}),true):false}function Zt(s){let c=Et(s);if(!c)return [];for(let u of c.children)if(u.kind!=="textValue"&&!(u.kind!=="contentControlProperties"&&u.localName!=="sdtPr"))for(let g of u.children){if(g.kind==="textValue"||g.localName!=="dropDownList"&&g.localName!=="comboBox")continue;let b=[];for(let E of g.children){if(E.kind==="textValue"||E.localName!=="listItem")continue;let _=E.attributes.find(U=>U.localName==="value")?.value??"",K=E.attributes.find(U=>U.localName==="displayText")?.value??_;b.push({displayText:K,value:_});}return b}return []}function f(s){let c=Et(s);if(!c)return false;for(let u of c.children)if(u.kind!=="textValue"&&!(u.kind!=="contentControlProperties"&&u.localName!=="sdtPr")){for(let g of u.children)if(g.kind==="contentControlCheckbox")for(let b of g.children){if(b.kind!=="contentControlChecked")continue;let E=b.attributes.find(_=>_.localName==="val")?.value;return !(E==="0"||E==="false"||E==="off")}}return false}function w(s){let c=Et(s);if(c){for(let u of c.children)if(u.kind==="contentControlProperties"){for(let g of u.children)if(g.kind==="contentControlDate")return g.attributes.find(b=>b.localName==="fullDate")?.value}}}function H$1(s,c){for(let u of k.querySelectorAll("[data-docx-content-control]"))u.getAttribute("data-docx-content-control")===s&&(c?u.dataset.open="":delete u.dataset.open);}function W(s){let c=s.dataset.docxCcId;s.remove(),c&&H$1(c,false);}function q(){let s=k.querySelector(".docx-content-control-menu");s&&W(s);}function Q(s){let c=Nn(s),u=c?st(c):void 0;Me(u&&qo(u.id)?u.id:null);}let de=null;function Me(s){de!==s&&(de=s,n.onChange?.(he()));}function J(s){if(s.button!==0||s.target?.closest("a.docx-hyperlink")||L.anchor.paragraphId!==L.head.paragraphId||L.anchor.offset!==L.head.offset)return;let c=Nn(s);if(!c)return;let u=tc$1(o.part()).find(E=>E.resultParagraphIds.includes(c));if(!u)return;let b=H(o.part(),u,o.documentOutline(),Bo(u))[u.resultParagraphIds.indexOf(c)];b&&(s.preventDefault(),xt.goToPosition({paragraphId:b,offset:0}));}function Se(s,c){let u=ce.disabledReason(s,"edit");if(u){oe=u,n.onChange?.(he());return}if(c==="checkbox"){ce.setValue(s,f(s)?"false":"true");return}if(c==="dropdown"||c==="comboBox"){let g=Zt(s);if(g.length===0&&c==="dropdown")return;q();let b=A.createElement("div");b.className="docx-content-control-menu",b.dataset.docxMarker="",b.dataset.docxCcId=s,b.setAttribute("contenteditable","false"),b.setAttribute("role","listbox"),b.style.position="absolute",b.style.zIndex="20",b.style.pointerEvents="auto",b.addEventListener("pointerdown",U=>U.stopPropagation());let _=td$1(Y).find(U=>U.id===s)?.fragments[0];if(_){let U=Y.pages[_.pageIndex],ie=Te?.pageOffsetX.get(_.pageIndex)??0;if(U){let j=U.contentBox.x-U.box.x,se=U.contentBox.y-U.box.y;b.style.left=`${(U.box.x+ie+j+_.box.x+_.box.width)*i}px`,b.style.top=`${(U.box.y+se+_.box.y+_.box.height)*i}px`,b.style.transform="translateX(-100%)";}}for(let U of g){let ie=A.createElement("button");ie.type="button",ie.className="docx-content-control-menu-item",ie.dataset.docxMarker="",ie.setAttribute("contenteditable","false"),ie.setAttribute("role","option"),ie.textContent=U.displayText,ie.addEventListener("mousedown",j=>{j.preventDefault(),j.stopPropagation(),W(b),ce.setValue(s,U.value);}),b.append(ie);}if(c==="comboBox"){let U=A.createElement("input");U.type="text",U.className="docx-content-control-menu-input",U.dataset.docxMarker="",U.setAttribute("contenteditable","false"),U.addEventListener("mousedown",ie=>ie.stopPropagation()),U.addEventListener("keydown",ie=>{ie.key==="Enter"&&(ie.preventDefault(),W(b),ce.setValue(s,U.value));}),b.append(U);}k.append(b),H$1(s,true);let K=U=>{b.contains(U.target)||(W(b),A.removeEventListener("mousedown",K,true));};A.addEventListener("mousedown",K,true);return}if(c==="date"){q();let g=A.createElement("div");g.className="docx-content-control-menu",g.dataset.docxMarker="",g.dataset.docxCcId=s,g.setAttribute("contenteditable","false"),g.style.position="absolute",g.style.zIndex="20",g.style.pointerEvents="auto",g.addEventListener("pointerdown",ve=>ve.stopPropagation());let b=td$1(Y).find(ve=>ve.id===s),E=b?.fragments[0];if(E){let ve=Y.pages[E.pageIndex],nn=Te?.pageOffsetX.get(E.pageIndex)??0;if(ve){let Xn=ve.contentBox.x-ve.box.x,$n=ve.contentBox.y-ve.box.y;g.style.left=`${(ve.box.x+nn+Xn+E.box.x+E.box.width)*i}px`,g.style.top=`${(ve.box.y+$n+E.box.y+E.box.height)*i}px`,g.style.transform="translateX(-100%)";}}g.classList.add("docx-content-control-calendar");let _=w(s),K=_?new Date(_):new Date,U=Number.isNaN(K.getTime())?null:K,ie=U??new Date,j=ie.getFullYear(),se=ie.getMonth(),ue=new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}),be=new Intl.DateTimeFormat(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),At=new Intl.DateTimeFormat(void 0,{weekday:"narrow"}),tn=ve=>`${ve.getFullYear().toString().padStart(4,"0")}-${(ve.getMonth()+1).toString().padStart(2,"0")}-${ve.getDate().toString().padStart(2,"0")}`,Wn=(ve,nn)=>ve.getFullYear()===nn.getFullYear()&&ve.getMonth()===nn.getMonth()&&ve.getDate()===nn.getDate(),Gi=null,Wo=()=>{let ve=A.createElement("input");ve.type="date",ve.className="docx-content-control-calendar-input",ve.value=U?tn(U):"";let nn=ve.value;b?.alias&&ve.setAttribute("aria-label",b.alias);let Xn=()=>{if(!ve.value||ve.value===nn)return false;let je=ve.value;return W(g),ce.setValue(s,je),true};Gi=Xn,ve.addEventListener("keydown",je=>{je.key==="Enter"&&(je.preventDefault(),Xn()||W(g));}),ve.addEventListener("blur",()=>{queueMicrotask(()=>{!g.isConnected||g.contains(A.activeElement)||Xn()||W(g);});});let $n=A.createElement("div");$n.className="docx-content-control-calendar-header";let rn=A.createElement("button");rn.type="button",rn.className="docx-content-control-calendar-nav",rn.textContent="\u2039";let Nu=new Date(j,se-1,1);rn.setAttribute("aria-label",ue.format(Nu));let Xo=A.createElement("div");Xo.className="docx-content-control-calendar-title",Xo.textContent=ue.format(new Date(j,se,1));let on=A.createElement("button");on.type="button",on.className="docx-content-control-calendar-nav",on.textContent="\u203A";let _u=new Date(j,se+1,1);on.setAttribute("aria-label",ue.format(_u)),rn.addEventListener("mousedown",je=>je.stopPropagation()),on.addEventListener("mousedown",je=>je.stopPropagation()),rn.addEventListener("click",()=>{se-=1,se<0&&(se=11,j-=1),Wo();}),on.addEventListener("click",()=>{se+=1,se>11&&(se=0,j+=1),Wo();}),$n.append(rn,Xo,on);let $o=A.createElement("div");$o.className="docx-content-control-calendar-weekdays";for(let je=0;je<7;je+=1){let Mt=A.createElement("span");Mt.textContent=At.format(new Date(2024,0,1+je)),$o.append(Mt);}let Dr=A.createElement("div");Dr.className="docx-content-control-calendar-grid",Dr.setAttribute("role","grid");let Bu=(new Date(j,se,1).getDay()+6)%7,Zu=new Date;for(let je=0;je<42;je+=1){let Mt=new Date(j,se,je-Bu+1),lt=A.createElement("button");lt.type="button",lt.className="docx-content-control-calendar-day",lt.textContent=String(Mt.getDate()),lt.setAttribute("role","gridcell"),lt.setAttribute("aria-label",be.format(Mt)),Mt.getMonth()!==se&&(lt.dataset.otherMonth=""),U&&Wn(Mt,U)&&(lt.dataset.selected="",lt.setAttribute("aria-selected","true")),Wn(Mt,Zu)&&(lt.dataset.today=""),lt.addEventListener("mousedown",qu=>qu.stopPropagation()),lt.addEventListener("click",()=>{W(g),ce.setValue(s,tn(Mt));}),Dr.append(lt);}g.replaceChildren(ve,$n,$o,Dr);};Wo(),k.append(g),H$1(s,true);let Wi=ve=>{g.contains(ve.target)||(Gi?.()||W(g),A.removeEventListener("mousedown",Wi,true));};A.addEventListener("mousedown",Wi,true),g.querySelector("[data-selected], [data-today], .docx-content-control-calendar-day")?.focus({preventScroll:true});}}let ce={setShowAll(s){re!==s&&(re=s,Ge());},setFormFill(s){we!==s&&(we=s,n.onChange?.(he()));},showAll:()=>re,formFill:()=>we,atCaret:()=>Rt(),navigate(s){let c=Or();if(c.length===0)return false;let u=Rt(),g=u?c.findIndex(E=>E.id===u.id):-1;s==="next"?g=g<0?0:(g+1)%c.length:g=g<0?c.length-1:(g-1+c.length)%c.length;let b=c[g];return Zn(b.id)},setValue(s,c){let u=ce.disabledReason(s,"edit");if(u)return oe=u,n.onChange?.(he()),false;let g=false;return ke(()=>{let b=o.applyTreeOps([{op:"setContentControlValue",controlId:s,value:c}],Pe());return g=b.committed,b}),g},remove(s){let c=s??Rt()?.id;if(!c)return oe="notFound",n.onChange?.(he()),false;let u=ce.disabledReason(c,"remove");if(u)return oe=u,n.onChange?.(he()),false;let g=false;return ke(()=>{let b=o.applyTreeOps([{op:"removeContentControl",controlId:c}],Pe());return g=b.committed,b}),g},disabledReason(s,c){let u=td$1(Y).find(b=>b.id===s);if(u)return c==="remove"?pn(u):_n(u);let g=Et(s);if(!g)return "notFound";for(let b of g.children)if(b.kind!=="textValue"&&!(b.kind!=="contentControlProperties"&&b.localName!=="sdtPr")){if(b.children.some(E=>E.kind!=="textValue"&&E.localName==="dataBinding")&&c==="edit")return "bound";for(let E of b.children){if(E.kind==="textValue"||E.localName!=="lock")continue;let _=E.attributes.find(K=>K.localName==="val")?.value;if(c==="remove"){if(_==="sdtLocked"||_==="sdtContentLocked")return "locked"}else if(_==="contentLocked"||_==="sdtContentLocked")return "locked"}}return null}};function he(){return {revision:o.packageRevision(),pageCount:Y.pages.length,selection:L,cellSelection:z,canUndo:o.canUndo(),canRedo:o.canRedo(),lastRejection:oe,pendingFormat:at(),contentControls:{showAll:re,formFill:we,activeControlId:Rt()?.id??null},contextTocId:de,perf:{layoutMs:ee,paintMs:ne,selectionMs:ge,placed:m.stats.placed,total:m.stats.total,reusedPages:m.stats.reusedPages,fullPasses:m.stats.fullPasses,staleDiscards:et.staleDiscards,cancelledRuns:et.cancelledRuns}}}let ze,Te,qt=null,Ft=false,fe=null,Re=null;function zt(s){for(let c of Y.pages){let u=k.querySelector(`[data-page-index="${c.index}"]`);if(!u)continue;let g=s.pageOffsetX.get(c.index)??0;u.style.left=`${(c.box.x+g)*i}px`;}}function Ge(s=true){let c=Ke.adoptBeforePaint(),u=Z();ze=Ln(),pe?.reconcileOccurrence();let g=pe?.getActive()??null,b=Lo(),E=vc$1(o.part());d$1(k,Y,{scale:i,readOnlyParagraphIds:Hr(),...E.size>0?{emptyTocPlaceholderIds:E}:{},...n.fontAlias?{fontAlias:n.fontAlias}:{},...n.defaultFontFamily?{defaultFontFamily:n.defaultFontFamily}:{},materialize:ze,ariaHidden:false,drawingStrings:Mn,...$e?{imageUrlPort:$e}:{},...g?{activeHeaderFooterRId:g.scope.rId,activeHeaderFooterPageIndex:g.pageIndex}:{},...b?{contentControlChrome:b}:{}}),ac(e,k,g!=null),e.classList.toggle("docx-paginated-surface--viewing",_e==="view"),Te=vo(Y,ze),zt(Te),k.style.width=`${Te.width*i}px`,k.style.height=`${Te.height*i}px`,e.style.width=`${Te.width*i}px`,e.style.height=`${Te.height*i}px`,V.style.width=`${Te.width*i}px`,V.style.height=`${Te.height*i}px`,P.style.width=V.style.width,P.style.height=V.style.height,v.style.width=V.style.width,v.style.height=V.style.height,gn.update(),ne=Z()-u,Vn(),jn(),Ui(),Ke.mirrorToDom(),qn(Ft),Ft=false,(s||c)&&n.onChange?.(he());}function Kt(){let s=Ln(),c=vo(Y,s);Te&&Xa(s,ze)&&Fd(c,Te)||Ge(false);}function qn(s=false){if(pe?.getActive()||R$1?.activeNoteScope()||L.anchor.paragraphId!==L.head.paragraphId||L.anchor.offset!==L.head.offset)return;let c=A.activeElement;if(c!==k&&(!c||!k.contains(c)))return;let u=qd$1(Y,L.head,{measurer:I});if(!u)return;let g=qt!==null&&qt!==u.pageIndex;if(qt=u.pageIndex,!s&&!g)return;let b=Y.pages[u.pageIndex],E=Ct(e);if(!b||!E||E.clientHeight<=0)return;let _=24,K=b.contentBox.y-b.box.y,U=(b.box.y+K+u.y)*i+e.offsetTop,ie=U+u.height*i,j=E.scrollTop,se=j+E.clientHeight,ue=j;if(U<j+_)ue=U-_;else if(ie>se-_)ue=ie+_-E.clientHeight;else return;let be=Math.max(0,E.scrollHeight-E.clientHeight),At=Math.max(0,Math.min(ue,be));Math.abs(At-E.scrollTop)<.5||(E.scrollTop=At,Vo());}let _e=n.editingMode??"edit",Iu=Object.freeze({kind:"body"});function He(s,c,u,g=x(),b=true){let E=Ar(s.some(Su),s,b);if(E!==null)return {committed:false,rejected:true,opCount:0,reason:E};let _=Tu(s),K=o.applyTreeOps(_,c,u,g);return K.committed&&_e==="suggest"&&_.some(ku)&&r.onTrackedChange?.(),K}function Ar(s,c=[],u=true){return _e==="view"?d:s&&(u&&_o()||c.some(g=>Ou(g)))?p:_e==="suggest"&&!n.author?.trim()&&s?"suggesting needs an author before it can propose a change":null}function Su(s){return s.op!=="acceptRevision"&&s.op!=="rejectRevision"&&s.op!=="acceptAllRevisions"&&s.op!=="rejectAllRevisions"}function ku(s){switch(s.op){case "insertText":case "deleteText":case "insertTableRow":case "deleteTableRow":return s.revision!==void 0;case "setParagraphMarkRevision":case "proposeParagraphMerge":return true;default:return false}}function Tu(s){let c=n.author?.trim();if(_e!=="suggest"||!c)return [...s];let u={author:c,date:C()};return s.flatMap(g=>g.op==="insertText"||g.op==="deleteText"||g.op==="insertTableRow"||g.op==="deleteTableRow"?[{...g,revision:u}]:g.op==="splitParagraph"?[g,{op:"setParagraphMarkRevision",paragraphId:g.paragraphId,kind:"ins",revision:u}]:g.op==="joinParagraphs"?[{op:"proposeParagraphMerge",paragraphId:g.secondId,revision:u}]:[g])}function ke(s,c,u={}){u?.keepCellSelection||(z=null),xe=null,Ke.noteModelMoved();let g=s();if(typeof g!="boolean"&&g.rejected)oe=String(g.reason??"rejected");else {oe=null;let b=c?.();b&&(L=b,It=null,Ft=true);let E=u?.rearmPending;if(E&&E.properties.length>0){let{anchor:_,head:K}=L;_.paragraphId===K.paragraphId&&_.offset===K.offset&&(xe={properties:E.properties,base:E.base,position:K});}}tt()||Ge();}function Pu(){if(!ze)return true;for(let s of [L.anchor,L.head]){let c=qd$1(Y,s);if(c&&!ze.has(c.pageIndex))return false}return true}function pt(s,c=false){Ne(s),Ue(s);let u=Rt()?.id??null,g=Un(L.head.paragraphId);L=s,z=null,c||(It=null),Pu()||(Ke.noteModelMoved(),Ge(false)),Ke.noteSelectionSettled(),Ke.mirrorToDom(true),qn(true),Vn(),Kn=null,jn();let b=Rt()?.id??null,E=Un(L.head.paragraphId);(u!==b||g!==E)&&Ge(false),n.onChange?.(he());}let Ke=Sc({session:o,storyScope:x,document:A,pagesLayer:k,selection:()=>L,setSelection:s=>pt(s),adoptSelection:s=>{Ne(s),Ue(s),L=s,It=null,Ft=true;},commit:s=>ke(s),render:()=>Ge(),flushLayout:()=>tt(),updateCaret:()=>T.update(),textOf:s=>Ot(s),pendingFormatOps:(s,c,u)=>De(s,c,u),selectionMark:()=>Pe(),now:Z,recordSelectionMs:s=>{ge=s;},isGesturing:()=>zo?.dragging()??false,domSelection:()=>z?Fe(z.text.anchor):L,holdsCellSelection:()=>z!==null});pe=Dc({session:o,layout:()=>Y,selection:()=>L,setScopeSelection:s=>{L=s,z=null,It=null;},noteModelMoved:()=>Ke.noteModelMoved(),render:()=>Ge(),mirrorToDom:()=>Ke.mirrorToDom(),notify:()=>n.onChange?.(he()),materializedPages:()=>ze}),R$1=_c({session:o,applyOps:He,commit:ke,selection:()=>L,selectionMark:()=>Pe(),orderedStart:()=>Lr(),activeScope:()=>{let s=R$1?.activeNoteScope();return s||(pe?.activeScope()??{kind:"body"})},setActiveScopeBodyOrHf:s=>pe.setActiveScope(s),setSelection:s=>pt(s),noteModelMoved:()=>Ke.noteModelMoved(),render:()=>Ge(),revealNote:s=>{for(let c of Y.pages){let u=[...c.footnotes?.notes??[],...c.endnotes?.notes??[]].find(g=>g.scopeId===s);if(u)return Gn(u.box.y,u.box.height,{block:"nearest",offsetPx:48}),c.index}return null},notify:()=>n.onChange?.(he()),lastRejection:()=>oe,setLastRejection:s=>{oe=s;}});function Ci(s){z=s,s&&(Ne(s.text),L=s.text),It=null,Ke.noteSelectionSettled(),Ke.mirrorToDom(),Vn(),Kn=null,jn(),n.onChange?.(he());}let Qt=null;function wu(){let c=qd$1(Y,L.head)?.pageIndex??0,u=new Set;for(let g=c-1;g<=c+1;g+=1)g>=0&&g<Y.pages.length&&u.add(g);return u}let Ri=new WeakMap;function Cu(s){let c=Ri.get(s);if(c)return c;let u=new Map;for(let g of s.pages)for(let b of R(g))u.has(b.paragraphId)||u.set(b.paragraphId,g.index);return Ri.set(s,u),u}function Ru(){let s=o.revision(),c=ze??wu();if(Qt?.layout===Y&&Qt.revision===s&&Xa(Qt.pages,c))return Qt.rects;let u=Cu(Y),g=(K,U)=>{if(!c)return true;let ie=u.get(K),j=u.get(U);if(ie===void 0||j===void 0)return true;for(let se=Math.min(ie,j);se<=Math.max(ie,j);se+=1)if(c.has(se))return true;return false},b=[];for(let K of o.reviewItems()){if(K.kind==="comment"){if(K.range===null||K.resolved||!g(K.range.start.paragraphId,K.range.end.paragraphId))continue;b.push({key:b$2(K),from:{paragraphId:K.range.start.paragraphId,offset:K.range.start.offset},to:{paragraphId:K.range.end.paragraphId,offset:K.range.end.offset}});continue}let U=b$2(K),ie=K.kind==="revision"?K.ranges:K.range?[K.range]:[];for(let[j,se]of ie.entries())g(se.start.paragraphId,se.end.paragraphId)&&b.push({key:ie.length===1?U:`${U}${y}${j}`,from:{paragraphId:se.start.paragraphId,offset:se.start.offset},to:{paragraphId:se.end.paragraphId,offset:se.end.offset}});}let E=vd$1(Y,b,c),_=[];for(let[K,U]of E)for(let ie of U)_.push({...ie,key:K});return Qt={layout:Y,revision:s,pages:c,rects:_},_}let zn=null;function Eu(){let s=o.packageRevision(),c=o.part().root;if(zn&&zn.packageRevision===s&&zn.bodyRoot===c)return zn.index;let u=new Map,g=E=>{let _=u.size;for(let[K,U]of E)u.has(K)||u.set(K,_+U);};g(gg$1(o.part()));let b=new Set([o.part()]);for(let E of o.headerFooterPartsBySection())for(let _ of [E.headers,E.footers])for(let K of _.values())b.has(K)||(b.add(K),g(gg$1(K)));for(let E of ["footnote","endnote"]){let _=o.partFor({kind:"notesPart",noteKind:E});!_||b.has(_)||(b.add(_),g(gg$1(_)));}return zn={packageRevision:s,bodyRoot:c,index:u},u}let Kn=null,Do=null;function No(){let s=L?.head;if(!s)return null;let u=h$1(o.reviewItems(),s,Eu()).filter(b=>!(b.kind==="comment"&&b.resolved)&&b$2(b)!==Kn&&!(b.kind==="revision"&&Do!==null&&Do.has(b.revisionKind)))[0];if(!u)return null;if(u.kind!=="comment")return u;let g=j$2(o.reviewItems(),u);return b$2(g)===Kn?null:g}function Fu(s,c,u){let g=s.split(y),b=g[0],E=c!==null&&b===b$2(c);if(s.startsWith("comment-"))return E?"docx-comment-band docx-comment-band--active":"docx-comment-band";if(s.startsWith("custom-"))return E?"docx-comment-band docx-comment-band--active":null;let _=u.get(b);if(!_||_.kind!=="revision")return null;let K=g.length>1?Number(g[1]):0;return `docx-revision-band docx-revision-band--${(j=>j==="delete"||j==="moveFrom"?"delete":j==="insert"||j==="moveTo"?"insert":j==="replace"&&_.replacedRangeCount!==void 0?K<_.replacedRangeCount?"delete":"insert":"other")(_.revisionKind)}${E?" docx-revision-band--active":""}`}function jn(){let s=No(),c=new Map;for(let g of o.reviewItems())c.set(b$2(g),g);let u=[];for(let g of Ru()){let b=Fu(g.key,s,c);b&&u.push({...g,className:b});}e$1(P,Y,u,{scale:i,...Te?{pageOffsetX:Te.pageOffsetX}:{}});}function Vn(){e$1(V,Y,z?Fd$1(Y,z.cellIds):le?ud$1(Y,le):[],{scale:i,pageOffsetX:Te?.pageOffsetX,...z?{}:{className:"docx-retained-selection-rect"}});}function Mr(s){let c=tc$1(o.part());if(s)return c.find(b=>b.id===s)??null;let u=de?c.find(b=>b.id===de):void 0;if(u)return u;let g=L.head.paragraphId;return c.find(b=>b.beginParagraphId===g||b.endParagraphId===g||b.resultParagraphIds.includes(g))??(c.length===1?c[0]:null)}function Un(s){return tc$1(o.part()).find(u=>u.beginParagraphId===s||u.endParagraphId===s||u.resultParagraphIds.includes(s))?.id??null}function _o(){return Un(L.anchor.paragraphId)!==null||Un(L.head.paragraphId)!==null}function Ou(s){let c=Hr(),u=(g,b="")=>typeof g=="string"?/(?:Id|Ids)$/.test(b)&&c.has(g):Array.isArray(g)?g.some(E=>u(E,b)):!g||typeof g!="object"?false:Object.entries(g).some(([E,_])=>u(_,E));return u(s)}function Hr(){return new Set(tc$1(o.part()).flatMap(s=>[s.beginParagraphId,...s.resultParagraphIds,s.endParagraphId]))}function Bo(s){return new Set([s.beginParagraphId,s.endParagraphId,...s.resultParagraphIds])}function Au(s){let c=0;for(let u of Y.pages)for(let g of R(u))s.has(g.paragraphId)&&(c+=g.lines.length);return c}function Zo(s,c){let u=new Set(c),g=new Map;for(let b of s.pages)for(let E of R(b)){if(!u.has(E.paragraphId)||g.has(E.paragraphId))continue;let _=b.pageFieldSource;g.set(E.paragraphId,ib(_?.pageNumber??b.index+1,_?.format));}return g}function qo(s){if(_e==="view"||!o.editable)return false;let c=Mr(s);return c?xf(o.part(),{op:"rewriteTocPageNumbers",tocId:c.id,updates:[]})===null:false}function Ei(s,c){if(!Number.isInteger(s)||!Number.isInteger(c)||s<1||c<1)return null;let u=fn.sectionPropertiesAt(L.head.paragraphId),g=u.pageSize.widthTwips-u.margins.leftTwips-u.margins.rightTwips-u.margins.gutterTwips,b=Math.max(300,Math.floor(g/c));return {op:"insertTable",beforeParagraphId:L.head.paragraphId,rows:s,cols:c,columnWidthTwips:b}}function Fi(s,c){if(_e==="view"||!o.editable)return false;let u=Ei(s,c);return u!==null&&xf(o.part(),u)===null}function Mu(s,c){if(!Fi(s,c))return false;let u=Ei(s,c);if(!u)return false;let g=null,b=o.subscribe(_=>{_.caret&&(g=_.caret);}),E=false;try{ke(()=>{let _=He([u],Pe());return _.committed||(oe=_.reason??"the table could not be inserted here"),E=_.committed,_},()=>{let _=g;return _?Fe({paragraphId:_.paragraphId,offset:_.start}):null});}finally{b();}return E}let Oi='TOC \\o "1-3" \\h';function Ai(){let s=sc$1(Oi);if(!s)return null;let c=o.documentOutline(),u=Bc$1(o.part(),c,s,Zo(Ee.layout(),c.map(g=>g.blockId)),Hr());return {op:"insertToc",beforeParagraphId:L.head.paragraphId,instruction:Oi,alias:n.tocLabels?.title??"TOC",entries:u.entries,bookmarksToCreate:u.bookmarksToCreate}}function Mi(){if(_e==="view"||!o.editable||_o())return false;let s=Ai();return s!==null&&xf(o.part(),s)===null}function Hu(){if(!Mi())return false;let s=Ai();if(!s)return false;let c=new Set(tc$1(o.part()).map(b=>b.id)),u=o.applyTreeOps([s]);if(!u.committed)return oe=u.reason??"the table of contents could not be inserted",false;let g=tc$1(o.part()).find(b=>!c.has(b.id));return g?Hi(g.id,"pageNumbers"):true}function Hi(s,c="entire"){let u=Mr(s);if(!u||!qo(u.id))return false;let g=Ee.layout(),b=o.documentOutline(),E=b.map(K=>K.blockId);if(c==="entire"){let K=Bc$1(o.part(),b,u.instruction,Zo(g,E),Bo(u)),U=o.applyTreeOps([{op:"replaceTocResult",tocId:u.id,entries:K.entries,bookmarksToCreate:K.bookmarksToCreate}]);if(!U.committed)return oe=U.reason??"the table of contents could not be refreshed",false;if(g=Ee.layout(),u=Mr(u.id),!u)return true}let _="";for(let K=0;K<3;K+=1){let U=Zo(g,E),ie=H(o.part(),u,b,Bo(u)),j=u.resultParagraphIds.flatMap((be,At)=>{let tn=ie[At],Wn=tn?U.get(tn):void 0;return Wn===void 0?[]:[{paragraphId:be,pageNumberText:Wn}]});if(j.length===0)break;let se=j.map(be=>`${be.paragraphId}\0${be.pageNumberText}`).join("");if(se===_)break;_=se;let ue=o.applyTreeOps([{op:"rewriteTocPageNumbers",tocId:u.id,updates:j}]);if(!ue.committed){if(ue.rejected)return oe=ue.reason??"the table of contents page numbers were refused",false;break}g=Ee.layout(),u=Mr(u.id)??u;}return true}let Ee={session:o,storyScope:x,imageDecodePort:()=>Ae,layout:()=>(tt(),Y),state:he,currentPage:(s="caret")=>{if(tt(),s==="viewport"){let u=Rd(e,Y,i);if(u!==null)return u}let c=qd$1(Y,L.head);return c?c.pageIndex+1:1},setScale(s){if(!(s>0)||!Number.isFinite(s))return false;if(s===i)return true;let c={scale:i,defaults:S,measurer:I,producer:B,furnitureSource:it};try{let u=Ct(e),g=u?{x:(u.scrollLeft-e.offsetLeft+u.clientWidth/2)/i,y:(u.scrollTop-e.offsetTop+u.clientHeight/2)/i}:null;if(i=s,n.measurer||(S=jd$1(i,{context:Rn(e.ownerDocument),...n.fontAlias?{fontAlias:n.fontAlias}:{}}),I=S.measurer),B=F(),it=Wa({session:o,measurer:I,producer:B,cache:O,styleCascade:Ce,defaultTabStopPt:qe}),ze=void 0,Te=void 0,Qt=null,et.invalidateAll(o.packageRevision(),"zoom"),et.flush(),u&&g){let b=Math.max(0,g.x*i+e.offsetLeft-u.clientWidth/2),E=Math.max(0,g.y*i+e.offsetTop-u.clientHeight/2),_=Number.isFinite(u.scrollWidth)?Math.max(0,u.scrollWidth-u.clientWidth):null,K=Number.isFinite(u.scrollHeight)?Math.max(0,u.scrollHeight-u.clientHeight):null;u.scrollLeft=_===null?b:Math.min(b,_),u.scrollTop=K===null?E:Math.min(E,K),Kt();}return !0}catch{(({scale:i,defaults:S,measurer:I,producer:B,furnitureSource:it}=c)),ze=void 0,Te=void 0,Qt=null;try{et.invalidateAll(o.packageRevision(),"zoom-rollback"),et.flush();}catch{}return false}},type(s){let c=en(),u=c.collapseTo,g=De(u.paragraphId,u.offset,s.length),b=_e==="suggest"?Jt():null,E=b&&b.to.paragraphId===u.paragraphId?b.to.offset:u.offset,_=[...c.ops,{op:"insertText",paragraphId:u.paragraphId,offset:E,text:s}],K={paragraphId:u.paragraphId,start:E+s.length,end:E+s.length};ke(()=>Xe([..._,...g],_,Pe(),K),()=>Fe({paragraphId:u.paragraphId,offset:E+s.length}));},insertPlainText:s=>Ko(s),deleteBackward(){let s=en();if(s.ops.length>0){ke(()=>He(s.ops,Pe()),()=>Fe(s.collapseTo));return}let c=Le()??void 0,u=L.head;if(u.offset===0){let b=D(),E=b.indexOf(u.paragraphId),_=b[E-1];if(!_)return;let K=Ot(_).length;ke(()=>He([{op:"joinParagraphs",firstId:_,secondId:u.paragraphId}],Pe()),()=>Fe({paragraphId:_,offset:K}),{rearmPending:c});return}let g=Di(u,"before");if(g){ke(()=>He([{op:"removeContentControl",controlId:g.controlId,keepContent:false}],Pe()),()=>Fe({paragraphId:u.paragraphId,offset:g.start}),{rearmPending:c});return}ke(()=>He([{op:"deleteText",paragraphId:u.paragraphId,start:u.offset-1,end:u.offset}],Pe()),()=>Fe({...u,offset:u.offset-1}),{rearmPending:c});},splitParagraph(){let s=en(),c=s.collapseTo,u=new Set(o.paragraphIdsIn(x())),g=Le()??void 0;ke(()=>He([...s.ops,{op:"splitParagraph",paragraphId:c.paragraphId,offset:c.offset}],Pe()),()=>{let b=o.paragraphIdsIn(x()).find(E=>!u.has(E));return b?Fe({paragraphId:b,offset:0}):null},{rearmPending:g});},navigate(s,c=false){let u=ai(Y,L.head,s,It,pe?.getActive()??null,N(),I);if(!u)return;let g=Hr();if(g.has(u.position.paragraphId)){if(c)return;let E=new Set(["left","wordLeft","lineStart","up","pageUp"]).has(s)?"up":"down",_=Au(g)+4;for(let K=0;K<_;K+=1){let U=ai(Y,u.position,E,u.desiredX,pe?.getActive()??null,N(),I);if(!U||U.position.paragraphId===u.position.paragraphId&&U.position.offset===u.position.offset)return;if(u=U,!g.has(u.position.paragraphId))break}if(g.has(u.position.paragraphId))return}It=u.desiredX,R$1?.activeNoteScope()&&u.pageIndex!==void 0&&Number.isInteger(u.pageIndex)&&R$1.setActiveNotePageIndex(u.pageIndex),pt({anchor:c?L.anchor:u.position,head:u.position},true);},deleteWordBackward(){if(Ee.deleteSelection())return;let s=L.head,c=yd$1(Ot(s.paragraphId),s.offset,-1);if(c===s.offset){Ee.deleteBackward();return}ke(()=>He([{op:"deleteText",paragraphId:s.paragraphId,start:c,end:s.offset}],Pe()),()=>Fe({...s,offset:c}),{rearmPending:Le()??void 0});},deleteWordForward(){if(Ee.deleteSelection())return;let s=L.head,c=yd$1(Ot(s.paragraphId),s.offset,1);if(c===s.offset){Ee.deleteForward();return}ke(()=>He([{op:"deleteText",paragraphId:s.paragraphId,start:s.offset,end:c}],Pe()),void 0,{rearmPending:Le()??void 0});},deleteForward(){if(Ee.deleteSelection())return;let s=Le()??void 0,c=L.head,u=Ot(c.paragraphId);if(c.offset<u.length){let E=Di(c,"after");if(E){ke(()=>He([{op:"removeContentControl",controlId:E.controlId,keepContent:false}],Pe()),()=>Fe(c),{rearmPending:s});return}ke(()=>He([{op:"deleteText",paragraphId:c.paragraphId,start:c.offset,end:c.offset+1}],Pe()),void 0,{rearmPending:s});return}let g=D(),b=g[g.indexOf(c.paragraphId)+1];b&&ke(()=>He([{op:"joinParagraphs",firstId:c.paragraphId,secondId:b}],Pe()),()=>Fe(c),{rearmPending:s});},...fn,...bt,setSelection:s=>pt(s),revealPage(s,c){let u=Y.pages.find(g=>g.index===s);return u?Gn(u.box.y,u.box.height,c):false},revealParagraph(s,c){tt();let u=qd$1(Y,{paragraphId:s,offset:0});if(!u)return false;let g=Y.pages.find(b=>b.index===u.pageIndex);return g?Gn(g.contentBox.y+u.y,u.height,c):false},revealPosition(s,c){tt();let u=qd$1(Y,s);if(!u)return false;let g=Y.pages.find(b=>b.index===u.pageIndex);return g?Gn(g.contentBox.y+u.y,u.height,{block:"nearest",...c}):false},setEditable(s){k.contentEditable=s?"true":"false",k.setAttribute("aria-readonly",s?"false":"true");},selectAll(){let s=D(),c=s[0],u=s[s.length-1];!c||!u||pt({anchor:{paragraphId:c,offset:0},head:{paragraphId:u,offset:Ot(u).length}});},hyperlinks:$t,contentControls:ce,canInsertTable:Fi,insertTable:Mu,canInsertToc:Mi,insertToc:Hu,canRefreshToc:qo,refreshToc:Hi,isInsideToc:s=>tc$1(o.part()).some(c=>c.beginParagraphId===s||c.endParagraphId===s||c.resultParagraphIds.includes(s)),retainSelection:()=>{le=L,Vn();},releaseSelection:()=>{le&&(le=null,Vn());},retainedSelection:()=>le,publishedLayout:()=>Y,overlayCoordinates:()=>Object.freeze({paintScale:i,pageOffsetX:Te?.pageOffsetX??new Map}),commitReviewOps:s=>ke(()=>{if(_e==="view")return {committed:false,rejected:true,opCount:0,reason:d};let c=s();return {committed:c.committed,rejected:!c.committed,opCount:0,...typeof c.reason=="string"?{reason:c.reason}:{}}},()=>{tt(),Ke.noteModelMoved();let c=D();return c.length===0?null:yo(Y,c,L)}),applyAutomationOps:(s,c)=>{let u={committed:false,rejected:false,opCount:0},g=c??Iu;return ke(()=>{let b=Ar(false);if(b!==null)return u={committed:false,rejected:true,opCount:0,reason:b};let E=null,_=s(K=>{let U=Ar(true,[],false);return U===null?o.ensureHyperlinkRelationship(K,g):(E=U,null)});return _===null?u={committed:false,rejected:true,opCount:0,reason:E??"this engine will not author that hyperlink target"}:u=He(_,void 0,void 0,g,false)},()=>{tt(),Ke.noteModelMoved();let b=D();return b.length===0?null:yo(Y,b,L)}),u},editingMode:()=>_e,setEditingMode:s=>{_e=s,oe=null,n.onChange?.(he());},setReviewActivationExclusions(s){Do=s===null?null:new Set(s),jn(),n.onChange?.(he());},activeReviewKey:()=>{let s=No();return s?b$2(s):null},dismissActiveReview:()=>{let s=No();s&&(Kn=b$2(s),jn(),n.onChange?.(he()));},navigation:xt,bookmarks:()=>o.bookmarks(),selectedText(){if(z)return Gd$1(Y,z);let{from:s,to:c}=Jt();return ud(Y,s,c,D())},deleteSelection(){let s=en();return s.ops.length===0?false:(ke(()=>He(s.ops,Pe()),()=>Fe(s.collapseTo)),true)},setCellSelection:Ci,layoutSession:()=>m,undo:()=>{if(_e==="view"){oe=d,n.onChange?.(he());return}Li(o.undo());},redo:()=>{if(_e==="view"){oe=d,n.onChange?.(he());return}Li(o.redo());},activeScope:()=>{let s=R$1?.activeNoteScope();return s||pe.activeScope()},setActiveScope:s=>s.kind==="note"?R$1.enterNote(s.id):s.kind!=="body"&&s.kind!=="headerFooter"?false:(R$1?.exitNote(),pe.setActiveScope(s)),insertNote:s=>R$1.insertNote(s),deleteNote:(s,c)=>R$1.deleteNote(s,c),convertNote:(s,c)=>R$1.convertNote(s,c),convertAllNotes:s=>R$1.convertAllNotes(s),setNoteProperties:s=>R$1.setNoteProperties(s),enterNote:(s,c)=>R$1.enterNote(s,c),exitNote:()=>R$1.exitNote(),notePropertiesState:()=>{let s=Ee.state().selection.head.paragraphId,c=`${o.packageRevision()}:${s}`;if(c===h)return X;let u=Bc(Ee);return X=u,h=c,u},notePreviewText:s=>Zc(o,s),applyTableCommandPlan(s){if(!s.ok)return {ok:false,code:s.code,reason:s.reason};let c=null,u=o.subscribe(g=>{g.caret&&(c=g.caret);});try{let g=Pe(),b=s.selection.kind==="adoptCommittedCaret";ke(()=>He(s.ops,g),b?()=>{let E=c;return E?Fe({paragraphId:E.paragraphId,offset:E.start}):null}:void 0,s.selection.kind==="preserveSelection"?{keepCellSelection:!0}:void 0);}finally{u();}return oe?{ok:false,code:"invalidArgs",reason:oe}:{ok:true,changed:true}},enterHeaderFooter:s=>{let c=pe.enterHeaderFooter(s);if(!c)return c;let u=pe.getActive(),g=u?Y.pages[u.pageIndex]:void 0;if(u&&g){let b=u.kind==="header"?g.header:g.footer,E=b?.box.y??(u.kind==="header"?g.box.y:g.box.y+g.box.height-1),_=b?.box.height??1;Gn(E,_,{block:"nearest"});}return c},exitHeaderFooter:()=>pe.exitHeaderFooter(),headerFooterState:()=>pe.headerFooterStateStable(o.packageRevision()),...Hc({applyOps:He,commit:ke,deleteSelectionOps:Lu,orderedStart:Lr,selectionMark:Pe,collapsedAt:Fe,isHeaderFooterOpen:()=>pe?.getActive()!==null,lastRejection:()=>oe}),...Lc({session:o,applyOps:He,commit:ke,storyScope:x,selectionMark:Pe,editingMode:()=>_e,author:()=>n.author,trackedDate:C,decodePort:()=>Ae}),focus:()=>k.focus({preventScroll:true}),setTableInteractionLabel(s){l.resolve=s;},refreshTableInteractionLabels(){gn.refreshLabels();},destroy(){A.removeEventListener("selectionchange",Ni),k.removeEventListener("keydown",Zi),k.removeEventListener("beforeinput",ji),k.removeEventListener("copy",qi),k.removeEventListener("cut",zi),k.removeEventListener("paste",Ki),k.removeEventListener("compositionstart",_i),k.removeEventListener("compositionend",Bi),A.removeEventListener("scroll",Vi,{capture:true}),e.ownerDocument.defaultView?.removeEventListener("resize",Uo),fe?.disconnect(),Re=null,zo?.destroy(),gn.destroy(),xt.destroy(),k.removeEventListener("contextmenu",Q),k.removeEventListener("click",J),k.removeEventListener("pointermove",Dn),k.removeEventListener("pointerleave",Er),et.cancel(),Ie.dispose(),a$3(k),T.destroy(),Ho(),e.replaceChildren();}};function Li(s){if(xe=null,Ke.noteModelMoved(),tt(),!s){pt(yo(Y,D(),L));return}pt({anchor:{paragraphId:s.paragraphId,offset:s.start},head:{paragraphId:s.paragraphId,offset:s.end}});}function Gn(s,c,u){let g=Ct(e);if(!g||g.clientHeight===0)return false;let b=s*i+e.offsetTop,E=c*i,_=u?.offsetPx??24,K=u?.block??"start",U=g.clientHeight;if(K==="nearest"||K==="centerIfNeeded"){let se=b<g.scrollTop,ue=b+E>g.scrollTop+U;if(!se&&!ue)return true}let ie=K==="center"||K==="centerIfNeeded"?b-Math.max(0,(U-E)/2):K==="nearest"&&b>g.scrollTop?b+E+_-U:b-_,j=Math.max(0,g.scrollHeight-U);return g.scrollTo({top:Math.max(0,Math.min(ie,j)),behavior:u?.behavior??"auto"}),Kt(),true}function Pe(){return ho(L)}function Jt(){return Ua(Y,L,D())}function Lr(){return Jt().from}function Ot(s){return xd$1(Y,s)}function Di(s,c){let u=o.partFor(x())??o.part(),g=Ea$1(u,s.paragraphId);return !g||g.kind!=="paragraph"?null:c==="before"?Md$1(g,s.offset):Nd$1(g,s.offset)}function en(){if(z){let u=[];for(let g of Dd$1(Y,z.cellIds)){let b=xd$1(Y,g).length;b>0&&u.push({op:"deleteText",paragraphId:g,start:0,end:b});}return {ops:u,collapseTo:Lr()}}let{from:s,to:c}=Jt();return gd(Y,o.partFor(x())??o.part(),s,c,D())}function Lu(){return en().ops}let{onSelectionChange:Ni,onCompositionStart:_i,onCompositionEnd:Bi}=Ke,zo=null,Zi=xd(Ee,n.onRequestHyperlink?{onRequestHyperlink:n.onRequestHyperlink}:{}),{onCopy:qi,onCut:zi,onPaste:Ki}=Id(Ee,Ko),ji=Sd(Ee,{isComposing:()=>Ke.isComposing(),insertPlainText:Ko});function Ko(s){let c=md(s).split(`
|
|
11
|
+
`),u=en(),g=u.collapseTo,b=c.join(""),E=[...u.ops],_=De(g.paragraphId,g.offset,b.length);b.length>0&&(E.push({op:"insertText",paragraphId:g.paragraphId,offset:g.offset,text:b}),E.push(..._));let K=[],U=0;for(let ue=0;ue<c.length-1;ue+=1)U+=c[ue].length,K.push(g.offset+U);if(K.length>0&&E.push({op:"splitParagraphMany",paragraphId:g.paragraphId,offsets:K}),E.length===0)return;let ie=new Set(o.paragraphIdsIn(x())),j=c[c.length-1],se=E.filter(ue=>!_.includes(ue));ke(()=>Xe(E,se,Pe()),()=>{if(K.length===0)return Fe({paragraphId:g.paragraphId,offset:g.offset+j.length});let ue=o.paragraphIdsIn(x()).filter(At=>!ie.has(At)),be=ue[ue.length-1];return be?Fe({paragraphId:be,offset:j.length}):null});}A.addEventListener("selectionchange",Ni),k.addEventListener("keydown",Zi),k.addEventListener("beforeinput",ji),k.addEventListener("copy",qi),k.addEventListener("cut",zi),k.addEventListener("paste",Ki),k.addEventListener("compositionstart",_i),k.addEventListener("compositionend",Bi);let jo=false;function Vo(){if(jo)return;jo=true;let s=e.ownerDocument.defaultView?.requestAnimationFrame,c=()=>{jo=false,Kt();};s?s(c):queueMicrotask(c);}let Vi=s=>{let c=Ct(e);!c||s.target!==c||Vo();};A.addEventListener("scroll",Vi,{capture:true,passive:true});let Uo=()=>{Vo();},Go=e.ownerDocument.defaultView;Go?.addEventListener("resize",Uo,{passive:true}),fe=typeof Go?.ResizeObserver=="function"?new Go.ResizeObserver(Uo):null;function Ui(){if(!fe)return;let s=Ct(e);s!==Re&&(fe.disconnect(),Re=s,s&&fe.observe(s));}Ui(),zo=fc({pagesLayer:k,container:e,scale:()=>i,pageOffsetX:s=>Te?.pageOffsetX.get(s)??0,layout:()=>Y,measurer:()=>I,selection:()=>L,setSelection:s=>pt(s),cellSelection:()=>z,setCellSelection:s=>Ci(s),focus:()=>k.focus({preventScroll:true}),activeHeaderFooter:()=>oc(pe?.getActive()??null),activeNote:()=>{let s=R$1?.activeNoteScope();return s?{scopeId:s.id,pageIndex:R$1?.activeNotePageIndex()??null}:null},enterHeaderFooter:s=>{pe?.enterHeaderFooter({rId:s.rId,pageIndex:s.pageIndex,kind:s.kind,...s.position?{position:s.position}:{}});},enterNote:(s,c,u)=>{R$1?.enterNote(s,c,u);},exitNote:s=>{R$1?.exitNote(s);},exitHeaderFooter:()=>pe?.exitHeaderFooter(),enterEmptyHeaderFooter:(s,c)=>{if(_e==="view")return;let u=m.multi?.spans,g=0,b=0;if(u&&u.length>0)for(let se=0;se<u.length;se+=1){let ue=u[se];if(g=se,b=ue.startIndex,c<ue.startIndex+ue.pageCount)break}let E=o.headerFooterResolutionBySection(),_=E[Math.min(g,Math.max(0,E.length-1))],K=Y.pages[c]?.pageFieldSource?.pageNumber??c+1,U=_?.evenAndOddHeaders&&K%2===0?"even":_?.titlePage&&c===b?"first":"default",ie=se=>{let ue=se[Math.min(g,Math.max(0,se.length-1))];return s==="header"?ue?.headers:ue?.footers},j=ie(E)?.get(U)?.rId;if(!j){if(!Ee.applyHeaderFooterLifecycle?.({op:"createHeaderFooter",sectionIndex:g,kind:s,variant:U,...U==="first"?{titlePage:true}:{},...U==="even"?{evenAndOddHeaders:true}:{}})?.ok)return;j=ie(o.headerFooterResolutionBySection())?.get(U)?.rId;}j&&pe?.enterHeaderFooter({rId:j,pageIndex:c,sectionIndex:g,kind:s,variant:U});},onContentControlWidget:(s,c)=>Se(s,c),isReadOnlyParagraph:s=>Un(s)!==null},n.pointer?{mode:n.pointer}:{});let gn=zd({pagesLayer:k,furnitureLayer:v,scale:()=>i,pageOffsetX:s=>Te?.pageOffsetX.get(s)??0,read:()=>({layout:Y,storeRevision:o.packageRevision(),selection:L,cellSelection:z,editingMode:_e,themeColors:o.documentThemeColors()}),session:()=>o,applyTableCommandPlan:s=>Ee.applyTableCommandPlan(s),label:s=>l.resolve(s)});Ge();let Du=Ee.setEditingMode.bind(Ee);return Ee.setEditingMode=s=>{Du(s),gn.update();},Ee.setTableInteractionLabel=s=>{l.resolve=s,gn.refreshLabels();},Ee.refreshTableInteractionLabels=()=>{gn.refreshLabels();},{ok:true,surface:Ee}}function mi(e){if(e==="")return;let t=globalThis.navigator?.clipboard;if(t?.writeText)try{t.writeText(e).catch(()=>{});}catch{}}function Lg(e){return e.evenPage?"even":e.firstPage?"first":"default"}function zc(e){return e.variant!==void 0?e.variant==="default"||e.variant==="first"||e.variant==="even"?e.variant:{ok:false,reason:"variant must be 'default', 'first', or 'even'"}:Lg(e)}function hi(e,t){let n=e.headerFooterState(),r=t.position??n?.editing??null;if(r!=="header"&&r!=="footer")return {ok:false,refusal:{ok:false,code:"invalidArgs",reason:"header/footer position is required when no furniture scope is open"}};let o=t.variant!==void 0||t.firstPage!==void 0||t.evenPage!==void 0?zc(t):n?.variant??"default";if(typeof o=="object"&&o.ok===false)return {ok:false,refusal:{ok:false,code:"invalidArgs",reason:o.reason}};let i=o,l=t.sectionIndex??n?.sectionIndex??0;return !Number.isInteger(l)||l<0?{ok:false,refusal:{ok:false,code:"invalidArgs",reason:"sectionIndex must be a non-negative integer"}}:{ok:true,sectionIndex:l,kind:r,variant:i}}function Dg(e){let t=e??"rejected";return t==="first-section"||t.includes("first-section")?{ok:false,code:"invalidArgs",reason:"the first section cannot link to a previous header or footer"}:{ok:false,code:"invalidArgs",reason:`header/footer lifecycle refused: ${t}`}}function Tr(e,t){if(typeof e.applyHeaderFooterLifecycle!="function")return {ok:false,code:"unsupported",reason:"header/footer lifecycle is not available"};let n=e.applyHeaderFooterLifecycle(t);return n.ok?{ok:true,changed:true}:Dg(n.reason)}function Fo(e,t,n,r){let o=e.session.headerFooterResolutionBySection()[t];if(!o)return null;let l=(n==="header"?o.headers:o.footers).get(r);return l?{rId:l.rId,partName:l.partName,inherited:l.inherited,titlePage:o.titlePage,evenAndOddHeaders:o.evenAndOddHeaders}:null}function Kc(e,t){if(typeof e.enterHeaderFooter!="function")return {ok:false,code:"unsupported",reason:"header/footer editing is not available"};let n=t.sectionIndex??0;if(!Number.isInteger(n)||n<0)return {ok:false,code:"invalidArgs",reason:"sectionIndex must be a non-negative integer"};let r=t.position,a=zc(t);if(typeof a=="object"&&a.ok===false)return {ok:false,code:"invalidArgs",reason:a.reason};let o=a,l=Fo(e,n,r,o)?.rId,d=false;if(!l){let y=Tr(e,{op:"createHeaderFooter",sectionIndex:n,kind:r,variant:o,...o==="first"?{titlePage:true}:{},...o==="even"?{evenAndOddHeaders:true}:{}});if(!y.ok)return y;d=true,l=Fo(e,n,r,o)?.rId;}return l?e.enterHeaderFooter({rId:l,kind:r,sectionIndex:n,variant:o})?{ok:true,changed:d}:{ok:false,code:"invalidArgs",reason:"the header/footer relationship could not be opened"}:{ok:false,code:"notFound",reason:`no ${r} story is available to edit`}}function jc(e,t){let n=hi(e,t);if(!n.ok)return n.refusal;let r=e.headerFooterState(),a=r?.rId,o=Tr(e,{op:"deleteHeaderFooter",sectionIndex:n.sectionIndex,kind:n.kind,variant:n.variant});return o.ok&&a&&r?.editing===n.kind&&r.sectionIndex===n.sectionIndex&&r.variant===n.variant&&e.exitHeaderFooter(),o}function Vc(e,t){let n=hi(e,t);if(!n.ok)return n.refusal;if(n.sectionIndex===0)return {ok:false,code:"invalidArgs",reason:"the first section cannot link to a previous header or footer"};let r=e.headerFooterState(),a=r?.editing===n.kind&&r.sectionIndex===n.sectionIndex&&r.variant===n.variant,o=Tr(e,{op:"linkToPrevious",sectionIndex:n.sectionIndex,kind:n.kind,variant:n.variant});if(!o.ok)return o;if(a){let i=Fo(e,n.sectionIndex,n.kind,n.variant);i?e.enterHeaderFooter({rId:i.rId,kind:n.kind,sectionIndex:n.sectionIndex}):e.exitHeaderFooter();}return o}function Uc(e,t){let n=hi(e,t);if(!n.ok)return n.refusal;let r=e.headerFooterState(),a=!!r&&r.editing===n.kind&&r.sectionIndex===n.sectionIndex&&r.variant===n.variant,o=r?.rId,i=Tr(e,{op:"unlinkFromPrevious",sectionIndex:n.sectionIndex,kind:n.kind,variant:n.variant});if(!i.ok)return i;let l=Fo(e,n.sectionIndex,n.kind,n.variant);return a&&l&&l.rId!==o&&e.enterHeaderFooter({rId:l.rId,kind:n.kind,sectionIndex:n.sectionIndex}),i}function Gc(e,t){let n=e.headerFooterState(),r=t.sectionIndex??n?.sectionIndex;return Tr(e,{op:"setSectionFurnitureOptions",...r!==void 0?{sectionIndex:r}:{},...t.titlePage!==void 0?{titlePage:t.titlePage}:{},...t.evenAndOddHeaders!==void 0?{evenAndOddHeaders:t.evenAndOddHeaders}:{},...t.headerDistanceTwips!==void 0?{headerDistanceTwips:t.headerDistanceTwips}:{},...t.footerDistanceTwips!==void 0?{footerDistanceTwips:t.footerDistanceTwips}:{}})}function Wc(e,t){return e.activeScope().kind!=="headerFooter"?{ok:false,code:"unsupported",reason:"insertPageField requires an open header or footer scope"}:typeof e.insertPageField!="function"?{ok:false,code:"unsupported",reason:"page field insertion is not available"}:e.insertPageField(t.field)?{ok:true,changed:true}:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"page field insertion was refused"}}function Xc(e,t){let n=e.activeScope();return n.kind==="headerFooter"?{ok:false,code:"invalidArgs",reason:"cannot insert a note reference inside a header or footer"}:n.kind==="note"?{ok:false,code:"invalidArgs",reason:"cannot insert a note reference inside another note"}:typeof e.insertNote!="function"?{ok:false,code:"unsupported",reason:"insertNote is not available"}:e.insertNote(t.noteKind)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"insertNote was refused"}}function $c(e,t){return typeof e.deleteNote!="function"?{ok:false,code:"unsupported",reason:"deleteNote is not available"}:e.deleteNote(t.noteKind,t.noteId)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"deleteNote was refused"}}function Yc(e,t){return typeof e.convertNote!="function"?{ok:false,code:"unsupported",reason:"convertNote is not available"}:e.convertNote(t.fromKind,t.noteId)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"convertNote was refused"}}function Qc(e,t){return typeof e.convertAllNotes!="function"?{ok:false,code:"unsupported",reason:"convertAllNotes is not available"}:e.convertAllNotes(t.fromKind)?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"convertAllNotes was refused"}}function Jc(e,t){if(typeof e.setNoteProperties!="function")return {ok:false,code:"unsupported",reason:"setNoteProperties is not available"};let n=t.scope??"document";return e.setNoteProperties({scope:n,sectionIndex:t.sectionIndex,footnote:t.footnote,endnote:t.endnote})?null:{ok:false,code:"invalidArgs",reason:e.state().lastRejection??"setNoteProperties was refused"}}function eu(e,t,n){switch(t.type){case "toggleMark":{let r=Ta.get(t.mark);e.toggleRunProperty(r.localName,r.attributes);break}case "setMarkAttr":{let r=Pa(t);if(!r.ok)return {ok:false,code:r.code,reason:r.reason};e.setRunProperty(r.localName,r.attributes);break}case "clearFormatting":e.clearFormatting();break;case "setLineSpacing":e.setParagraphProperty("spacing",t.rule==="multiple"?{line:String(Math.round(t.value*240)),lineRule:"auto"}:{line:String(Math.round(t.value*20)),lineRule:t.rule==="exact"?"exact":"atLeast"},{mergeAttributes:true});break;case "setParagraphSpacing":e.setParagraphProperty("spacing",{...t.beforePt!==void 0?{before:t.beforePt===null?null:String(Math.round(t.beforePt*20))}:{},...t.afterPt!==void 0?{after:t.afterPt===null?null:String(Math.round(t.afterPt*20))}:{}},{mergeAttributes:true});break;case "setAlignment":e.setParagraphProperty("jc",{val:t.align==="justify"?"both":t.align});break;case "setParagraphStyle":{if(!e.session.documentStyles().some(a=>a.type==="paragraph"&&a.styleId===t.styleId))return {ok:false,code:"invalidArgs",reason:`style '${t.styleId}' is not a paragraph style of this document`};e.setParagraphProperty("pStyle",{val:t.styleId});break}case "setIndent":{e.setIndent({...t.left!==void 0?{left:t.left}:{},...t.right!==void 0?{right:t.right}:{},...t.firstLine!==void 0?{firstLine:t.firstLine}:{}});break}case "setPageSetup":{let r=t.scope==="section"?e.state().selection.head.paragraphId:void 0,a=t.pageWidth,o=t.pageHeight;if(t.orientation!==void 0&&(a!==void 0||o!==void 0)){let l=r?e.sectionPropertiesAt(r):e.sectionProperties(),d=a??l.pageSize.widthTwips,p=o??l.pageSize.heightTwips;a=t.orientation==="landscape"?Math.max(d,p):Math.min(d,p),o=t.orientation==="landscape"?Math.min(d,p):Math.max(d,p);}if(!e.setSectionProperties({...a!==void 0?{pageWidthTwips:a}:{},...o!==void 0?{pageHeightTwips:o}:{},...t.orientation!==void 0?{orientation:t.orientation}:{},...t.marginTop!==void 0?{marginTopTwips:t.marginTop}:{},...t.marginRight!==void 0?{marginRightTwips:t.marginRight}:{},...t.marginBottom!==void 0?{marginBottomTwips:t.marginBottom}:{},...t.marginLeft!==void 0?{marginLeftTwips:t.marginLeft}:{},...r!==void 0?{anchorParagraphId:r}:{}}))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the page setup change was refused"};break}case "toggleList":if(!e.toggleList(t.kind))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the list change was refused"};break;case "adjustIndent":if(!e.adjustIndent(t.direction))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the selection is already at that indent level"};break;case "insertBreak":if(t.kind==="section"){if(!e.insertSectionBreak())return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the section break was refused"};break}if(t.kind==="page"){e.insertPageBreak();break}e.insertLineBreak();break;case "insertHyperlink":{let r=t.href.startsWith("#");if(!e.hyperlinks.applyHyperlink({...r?{anchor:t.href.slice(1)}:{url:t.href},...t.text!==void 0?{text:t.text}:{}}))return {ok:false,code:"invalidArgs",reason:e.state().lastRejection??"the link was refused: the target is not an allowed scheme, or there is no text to link"};break}case "removeHyperlink":if(!e.hyperlinks.removeHyperlink())return {ok:false,code:"notFound",reason:"there is no hyperlink at the selection"};break;case "insertText":e.type(t.text);break;case "deleteText":e.deleteSelection();break;case "undo":e.undo();break;case "redo":e.redo();break;case "insertTable":if(!e.insertTable(t.rows,t.cols))return {ok:false,code:"unsupported",reason:e.state().lastRejection??"the table could not be inserted here"};break;case "insertToc":if(!e.insertToc())return {ok:false,code:"unsupported",reason:e.state().lastRejection??"the table of contents could not be inserted"};break;case "refreshToc":if(!e.refreshToc(t.tocId,t.mode))return {ok:false,code:"unsupported",reason:e.state().lastRejection??"the table of contents could not be refreshed"};break;case "editHeaderFooter":return Kc(e,t);case "exitHeaderFooter":return typeof e.exitHeaderFooter=="function"&&e.exitHeaderFooter(),{ok:true,changed:false};case "removeHeaderFooter":return jc(e,t);case "linkHeaderFooterToPrevious":return Vc(e,t);case "unlinkHeaderFooterFromPrevious":return Uc(e,t);case "setHeaderFooterOptions":return Gc(e,t);case "insertPageField":return Wc(e,t);case "insertNote":return Xc(e,t);case "deleteNote":return $c(e,t);case "convertNote":return Yc(e,t);case "convertAllNotes":return Qc(e,t);case "setNoteProperties":return Jc(e,t);case "insertRow":case "deleteRow":case "insertColumn":case "deleteColumn":case "deleteTable":case "setCellFill":case "setTableCellVerticalAlignment":case "setTableBorders":case "commitTableColumnDividerResize":case "commitTableRightEdgeResize":case "mergeCells":case "splitCell":case "toggleHeaderRow":case "selectTableRegion":case "setTableProperties":{if(!Sn(t))return {ok:false,code:"unsupported",reason:"unsupported command"};let r=n?.admittedTablePlan??Nt({command:t,part:e.session.part(),layout:e.layout(),storeRevision:e.session.revision(),selection:e.state().selection,cellSelection:e.state().cellSelection,themeColors:e.session.documentThemeColors(),editable:e.session.editable,viewing:e.editingMode()==="view"});return e.applyTableCommandPlan(r)}case "selectAll":return e.selectAll(),{ok:true,changed:false};case "copy":return mi(e.selectedText()),{ok:true,changed:false};case "cut":mi(e.selectedText()),e.deleteSelection();break;case "paste":e.insertPlainText(t.text);break;case "setSelection":{if("range"in t&&wa(t.range))return e.setSelection(t.range),e.revealPosition(t.range.head,{block:"centerIfNeeded"}),{ok:true,changed:false};let r="anchor"in t&&Pt(t.anchor)?{anchor:t.anchor}:"range"in t&&In(t.range)?{range:t.range}:null;if(r===null)return {ok:false,code:"unsupported",reason:"unsupported selection form"};let a=fl(e.session.part(),e.session.paragraphAnchors(),r);return a.ok?(e.setSelection(a.selection),e.revealPosition(a.selection.head,{block:"centerIfNeeded"}),{ok:true,changed:false}):a}default:return yr(t)?Ul(e,t,n?.editor):{ok:false,code:"unsupported",reason:"unsupported command"}}return null}function tu(e){return t=>{for(let n of e.customNodeDiagnostics)try{n(t);}catch{}}}function nu(e,t){t.customNodePayloadNamespaces.length!==0&&e.session.sweepCustomNodePayloads(t.customNodePayloadNamespaces);}var Ng="http://schemas.microsoft.com/office/word/2010/wordml",_g="http://schemas.microsoft.com/office/word/2012/wordml",Bg=32;function Wt(e){return Jb(e)}function Zg(e){return e.kind==="textValue"?[]:e.children}function Oo(e){if(e.kind==="textValue")return e.value.length;if(e.kind==="tab"||e.kind==="hardBreak")return 1;if(e.kind==="runProperties"||e.kind==="generic")return 0;if(Wt(e)){let n=0;for(let r of ee(e))n+=Oo(r);return n}let t=0;for(let n of Zg(e))t+=Oo(n);return t}function yi(e){for(let t of e.children)if(t.kind!=="textValue"&&(t.kind==="contentControlProperties"||t.localName==="sdtPr"))return t}function qg(e){if(e.kind!=="textValue"){for(let t of e.attributes)if(t.localName==="val"&&t.namespaceUri===la)return t.value}}function vi(e,t){if(e){for(let n of e.children)if(n.kind!=="textValue"&&n.localName===t)return qg(n)}}function zg(e){if(!e)return "richText";for(let t of e.children){if(t.kind==="textValue")continue;let n=Kg(t);if(n!==void 0)return n}return "richText"}function Kg(e){if(e.kind==="textValue")return;let t=e.kind,n=e.localName,r=e.namespaceUri;if(t==="contentControlDropDownList"||n==="dropDownList")return "dropdown";if(t==="contentControlComboBox"||n==="comboBox")return "comboBox";if(t==="contentControlDate"||n==="date")return "date";if(n==="picture")return "picture";if(t==="contentControlText"||n==="text")return "plainText";if(n==="richText")return "richText";if(n==="checkbox"&&(r===Ng||t==="contentControlCheckbox"))return "checkbox";if(n==="repeatingSection"&&r===_g)return "repeatingSection"}function bi(e){let t=vi(e,"lock");return t==="contentLocked"||t==="sdtContentLocked"}function jg(e,t){if(bi(yi(t)))return true;let n=Fa$1(e,t.id);for(;n;){if(Wt(n)&&bi(yi(n)))return true;n=Fa$1(e,n.id);}return false}function Ii(e,t){let n=yi(e),r=vi(n,"tag"),a=vi(n,"alias"),o=t?jg(t,e):bi(n);return {id:e.id,controlType:zg(n),...r!==void 0?{tag:r}:{},...a!==void 0?{alias:a}:{},...o?{locked:true}:{}}}function xi(e,t){return t?!(t.tag!==void 0&&e.tag!==t.tag||t.alias!==void 0&&e.alias!==t.alias||t.controlType!==void 0&&e.controlType!==t.controlType):true}function Vg(e){let t=[],n=(r,a,o,i)=>{let l=a;for(let d of r)if(d.kind!=="paragraphProperties"){if(d.kind==="run"){l+=Oo(d);continue}if(d.kind==="hyperlink"){l=n(d.children,l,o,i);continue}if(Wt(d)&&i<Bg){let p=l,y=o+1;l=n(ee(d),l,y,i+1),t.push({control:d,start:p,end:l,depth:y});continue}l+=Oo(d);}return l};return n(e.children,0,-1,0),t}function Si(e,t,n){return Vg(e).filter(r=>t>=r.start&&t<r.end).sort((r,a)=>a.depth-r.depth).map(r=>Ii(r.control,n))}function Ug(e){let t=[],n=r=>{if(r.kind!=="textValue"){Wt(r)&&t.push(Ii(r,e));for(let a of r.children)n(a);}};return n(e.root),t}function ki(e,t){let n=[],r=Fa$1(e,t);for(;r;)Wt(r)&&n.push(Ii(r,e)),r=Fa$1(e,r.id);return n.reverse()}function ru(e,t){return e?Ug(e.session.part()).filter(n=>xi(n,t)):[]}function Ti(e,t){if(!e)return null;let n=e.session.part(),{paragraphId:r,offset:a}=e.state().selection.head,o=Ea$1(n,r);if(o&&o.kind==="paragraph"){for(let l of Si(o,a,n))if(xi(l,t))return l}let i=ki(n,r);for(let l=i.length-1;l>=0;l-=1){let d=i[l];if(xi(d,t))return d}return null}function Pi(e){return e.type==="setContentControlValue"||e.type==="removeContentControl"}function Gg(e){return typeof e=="object"&&e!==null&&"container"in e&&"path"in e}function Wg(e){return typeof e=="object"&&e!==null&&"from"in e&&"to"in e}function Xg(e){let t=n=>{if(n.kind==="textValue")return null;if(n.kind==="body")return n;for(let r of n.children){let a=t(r);if(a)return a}return null};return t(e.root)}function Ao(e){let t=[];for(let n of e)n.kind!=="textValue"&&(n.kind==="paragraph"||n.kind==="table"||Wt(n))&&t.push(n);return t}function $g(e){let t=[];for(let n of e.children)if(n.kind==="tableRow")for(let r of n.children)r.kind==="tableCell"&&t.push(...Ao(r.children));return t}function Yg(e){return e.kind==="table"?$g(e):Wt(e)?Ao(ee(e)):e.kind==="body"?Ao(e.children):[]}function Qg(e,t,n){if(Wt(t))return {ok:true,controlId:t.id};if(t.kind==="paragraph"){let r=n??0;for(let i of Si(t,r,e))return {ok:true,controlId:i.id};let o=ki(e,t.id).at(-1);if(o)return {ok:true,controlId:o.id}}return {ok:false,code:"notFound",reason:"no content control at the addressed block"}}function Jg(e,t){if(t.container.part!=="body")return {ok:false,code:"unsupported",reason:"only the body container is supported",target:t};let n=Xg(e);if(!n)return {ok:false,code:"notFound",reason:"the document body was not found",target:t};if(t.path.length===0)return {ok:false,code:"notFound",reason:"DocLocation path is empty",target:t};let r=Ao(n.children),a=null;for(let i=0;i<t.path.length;i+=1){if(a=r[t.path[i]]??null,!a)return {ok:false,code:"notFound",reason:`block index ${t.path[i]} is out of range`,target:t};i<t.path.length-1&&(r=Yg(a));}if(!a)return {ok:false,code:"notFound",reason:"the addressed block was not found",target:t};let o=Qg(e,a,t.offset);return o.ok?o:{...o,target:t}}function em(e,t,n){let r=ur(e,t,n);if(!r.ok)return {ok:false,code:r.code,reason:r.reason,target:n};let a=Ea$1(e,r.span.nodeId);if(!a||a.kind!=="paragraph")return {ok:false,code:"notFound",reason:`paragraph '${n.paraId}' was not found`,target:n};let o=r.span.start;for(let d of Si(a,o,e))return {ok:true,controlId:d.id};let l=ki(e,a.id).at(-1);return l?{ok:true,controlId:l.id}:{ok:false,code:"notFound",reason:`no content control encloses paragraph '${n.paraId}'`,target:n}}function ou(e,t){if(t===void 0){let r=Ti(e);return r?{ok:true,controlId:r.id}:{ok:false,code:"notFound",reason:"no content control at the current selection"}}if(Wg(t))return {ok:false,code:"unsupported",reason:"DocRange targeting is not supported for content controls",target:t};let n=e.session.part();return Gg(t)?Jg(n,t):Pt(t)?em(n,e.session.paragraphAnchors(),t):{ok:false,code:"invalidArgs",reason:"unrecognized target shape",target:t}}function au(e){switch(e){case "locked":case "bound":case "typeMismatch":case "invalidArgs":case "unsupported":return e;case "unknown-control":return "notFound";default:return "unsupported"}}function iu(e){switch(e){case "locked":return "the content control is locked";case "bound":return "the content control is bound to external data";case "typeMismatch":return "the value does not match the control type";case "invalidArgs":return "the value is not valid for this control";case "unsupported":return "this control type is not supported";case "unknown-control":return "the content control was not found";default:return `the edit was refused (${e})`}}function tm(e,t){return {ok:false,code:au(e),reason:iu(e),...t!==void 0?{target:t}:{}}}function nm(e,t,n,r){return r?.scope&&r.scope.kind!=="body"?{ok:false,refusal:{ok:false,code:"unsupported",reason:"only the body scope is supported"}}:t?n==="view"||!t.session.editable?{ok:false,refusal:{ok:false,code:"locked",reason:"the document is read-only"}}:e.type==="setContentControlValue"&&typeof e.value!="string"?{ok:false,refusal:{ok:false,code:"invalidArgs",reason:"setContentControlValue requires a string value"}}:{ok:true}:{ok:false,refusal:{ok:false,code:"notFound",reason:"no document is loaded"}}}function wi(e,t,n,r){let a=nm(e,t,n,r);if(!a.ok)return a.refusal;let o=ou(t,e.target);if(!o.ok)return {ok:false,code:o.code,reason:o.reason};let i=e.type==="setContentControlValue"?{op:"setContentControlValue",controlId:o.controlId,value:e.value}:{op:"removeContentControl",controlId:o.controlId},l=xf(t.session.part(),i);return l?{ok:false,code:au(l),reason:iu(l)}:{ok:true}}function su(e,t){let n=ou(e,t.target);if(!n.ok){let l=n.target??t.target;return {ok:false,code:n.code,reason:n.reason,...l!==void 0?{target:l}:{}}}let r=e.session.revision(),a=ho(e.state().selection),o=t.type==="setContentControlValue"?{op:"setContentControlValue",controlId:n.controlId,value:t.value}:{op:"removeContentControl",controlId:n.controlId},i=e.session.applyTreeOps([o],a,a);return i.rejected?tm(i.reason??"unsupported",t.target):(e.layout(),{ok:true,changed:e.session.revision()!==r})}var lu=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function Mo(e){let t=e?.defaultFont?.family;return t!==void 0&&lu.test(t)?t:oo.family}function du(e,t){let n=new Map,r=l=>{if(l===void 0||!lu.test(l))return;let d=l.toLowerCase();n.has(d)||n.set(d,l);};r(Mo(e));let a=e?.substitutions??[],o=new Set(a.map(l=>l.to.family.toLowerCase()));for(let l of a)r(l.from.family);for(let l of e?.sources??[])o.has(l.request.family.toLowerCase())||r(l.request.family);for(let l of t)r(l);let i=[...n.values()];return i.sort((l,d)=>l<d?-1:l>d?1:0),i}var rm={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}};function cu(e$1,t){let n=[],r=[],a=t.aggregateBudget,o=new Set;for(let i$1 of e$1){let l=rm[i$1.style],d=Object.freeze({family:i$1.family,weight:l.weight,style:l.style});if(i$1.family.trim().length===0){r.push({request:d,partName:i$1.partName,reason:"malformed"});continue}let p=e(d);if(!(t.shadowedRequests?.has(p)||o.has(p))){if(o.add(p),i$1.bytes.byteLength>t.maxFontBytes||i$1.bytes.byteLength>a){r.push({request:d,partName:i$1.partName,reason:"overLimit"});continue}a-=i$1.bytes.byteLength,n.push({request:d,id:`embedded:${i$1.partName}#${i$1.style}`,bytes:i$1.bytes,hash:i(i$1.bytes),faceIndex:0});}}return {sources:n,dropped:r}}var om="The quick brown fox 0123 \u2014 {}#@",am=["monospace","serif"],im=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function uu(e){if(!e)return ()=>true;let t=new Map,n=r=>(e.font=r,e.measureText(om).width);return r=>{let a=t.get(r);if(a!==void 0)return a;if(!im.test(r))return t.set(r,true),true;let o=false;for(let i of am){let l=n(`32px ${i}`);if(n(`32px "${r}", ${i}`)!==l){o=true;break}}return t.set(r,o),o}}function fu(e,t,n){let r=[];for(let a of e)t(a)||n(a)||r.push(a);return r}var pu=Object.freeze({installed:0,alias:()=>{},dispose(){}});function sm(e){let t=0;for(let n of e)for(let r=0;r<n.length;r+=1)t=t*31+n.charCodeAt(r)>>>0;return `docx-embedded-${t.toString(36)}`}function lm(){let t=(typeof document<"u"?document:void 0)?.fonts;return !t||typeof FontFace>"u"?{}:{fontSet:t,createFontFace:(n,r,a)=>new FontFace(n,r.slice().buffer,a)}}async function gu(e,t=lm(),n=[]){let{fontSet:r,createFontFace:a}=t;if(!r||!a||e.length===0)return pu;let o=new Map;for(let p of e){let y=p.request.family,C=o.get(y);C?C.push(p):o.set(y,[p]);}let i=new Map,l=[];if(await Promise.all([...o].map(async([p,y])=>{let C=sm(y.map(I=>I.hash)),S=false;await Promise.all(y.map(async I=>{try{let O=a(C,I.bytes,{weight:String(I.request.weight),style:I.request.style});await O.load(),r.add(O),l.push(O),S=!0;}catch{}})),S&&i.set(p,C);})),l.length===0)return pu;for(let p of n){if(i.has(p.from.family))continue;let y=i.get(p.to.family);y!==void 0&&i.set(p.from.family,y);}let d=false;return {installed:l.length,alias:p=>d?void 0:i.get(p),dispose(){if(!d){d=true;for(let p of l)try{r.delete(p);}catch{}}}}}function hu(e){let t=1.3333333333333333;return {x:e.x*t,y:e.y*t,width:e.width*t,height:e.height*t}}var fm=Object.freeze({kind:"body"}),pm=Object.freeze([]),Xt="comments and tracked changes require the pro review module (@docx-editor.dev/pro)";function gm(e$1){let t=e$1.locale&&e$1.locale in locales?e$1.locale:"en",r={title:createT(deepMerge(en,t==="en"?void 0:locales[t]),t)("toolbar.tableOfContents")},a$3=e$1.container??null,o=a$2(e$1.modules),i=tu(o),l$1=o.review!==null,d$1=null,p=e$1.mode==="view"?"viewing":"editing",y=null,C=false,S$1=null,I=e$1.mode??"edit",O=e$1.zoom!==void 0&&Number.isFinite(e$1.zoom)&&e$1.zoom>=.1&&e$1.zoom<=5?e$1.zoom:1,m=null,F=null,B=null,A=null,k=null,V=null,P=[],v=()=>P[P.length-1]??{},T=false,M,G,$=null;function L(){$?.dispose(),$=null;}let z=0,oe,re=()=>typeof e$1.fonts=="function"?oe:e$1.fonts,we=-1,le=false,Oe=null,Ue=f=>(Oe||(Oe=uu(a$3?Rn(a$3.ownerDocument):null)),Oe(f)),xe=null,at=()=>{let f=re();return (xe===null||xe.configuration!==f)&&(xe={configuration:f,families:new Set([...(f?.sources??[]).map(w=>w.request.family),...(f?.substitutions??[]).map(w=>w.from.family)].filter(w=>typeof w=="string"&&w.trim().length>0).map(w=>w.toLowerCase()))}),xe.families},Le=f=>at().has(f.toLowerCase())||$?.alias(f)!==void 0,Ne=()=>!m||le?pm:fu(m.session.documentFonts(),Le,Ue),Xe=0,De=null,pe=null,R$1=-1,X=0,h=-1;function x(){Xe+=1;}let N$1={change:new Set,selectionChange:new Set,error:new Set};function D(f){for(let w of [...N$1.error])w(f);}function Z(f){for(let w of [...N$1.change])w(f);}function ee(){if(N$1.selectionChange.size===0)return;let f=$e();for(let w of [...N$1.selectionChange])w(f);}function ne(){B?.(),B=null,m?.destroy(),m=null,A=null,k=null,V=null,X+=1;}let ge=()=>O*(96/72);function Ce(f){if(!a$3){d$1=f,F=null,x();return}ne();let w=gi(a$3,f,{scale:ge(),defaultFontFamily:Mo(re()),...e$1.translate?{drawingStrings:c$1(e$1.translate)}:{},...e$1.author?{author:e$1.author}:{},editingMode:p==="suggesting"?"suggest":p==="viewing"?"view":"edit",...l$1?{}:{revisionDisplayMode:"proposed"},...o.review?{reviewModel:{...o.review,collectReviewItems:H=>o.review.collectReviewItems(o.customNodes.length>0?{...H,customNodes:o.customNodes,...o.customNodeDiagnostics.length>0?{reportCustomNodeDiagnostic:i}:{}}:H)}}:{},...M?{measurer:M,...G?{producer:G}:{}}:{},...$?{fontAlias:$.alias}:{},...e$1.tableInteractionLabel?{tableInteractionLabel:e$1.tableInteractionLabel}:{},...e$1.imageDecodePort?{imageDecodePort:e$1.imageDecodePort}:{},onHyperlinkPopover:H=>v().onPopover?.(H),onRequestHyperlink:()=>v().onRequest?.(),onTrackedChange:()=>{st||(st=true,x(),ee());},tocLabels:r,onChange:H=>{if(!m)return;x();let W=H.pendingFormat!==k;k=H.pendingFormat;let q=m.headerFooterState?.(),Q=q?.editing&&q.rId?`${q.editing}:${q.rId}`:null,de=Q!==V;V=Q,!(Ca(H.selection,A)&&!W&&!de)&&(A=H.selection,ee());}});if(!w.ok){F=w.detail?`${w.reason}: ${w.detail}`:w.reason,x(),D(kn(w.reason,`failed to open document: ${F}`));return}F=null,m=w.surface,Fr(),nu(m,o),X+=1,m.setEditable(p!=="viewing"),y!==null&&m.setReviewActivationExclusions(y),A=m.state().selection,B=m.session.subscribe(H=>{let W={revision:H.toRevision,created:H.created,deleted:H.deleted,dirty:H.dirty};x(),Z(W);}),x(),Z({revision:m.session.revision()}),ee(),we!==z&&(we=z,Be(z,m));}function Je(f){if(z+=1,M=void 0,G=void 0,oe=void 0,L(),le=false,a$3){let w=Ct(a$3);w&&(w.scrollTop=0,w.scrollLeft=0);}Ce(f);}function qe(f){try{e$1.onFontError?.(f);}catch{}D(f);}async function Be(f,w){let H=e$1.fonts,W=w.session.embeddedFonts();if(!(!H&&W.length===0)){le=true,x();try{let q=typeof H=="function"?await H({families:w.session.documentFonts().slice(0,va),defaultFamily:Mo(re())}):H;if(T||f!==z){f===z&&(le=!1);return}if(oe=q,!q&&W.length===0){le=!1,x();return}let Q=(q&&"maxFontBytes"in q?q.maxFontBytes:void 0)??a$1,de=(q?.sources??[]).reduce((fe,Re)=>fe+Re.bytes.byteLength,0),Me=new Set((q?.sources??[]).filter(fe=>fe.request.family.trim().length>0).map(fe=>e(fe.request))),J=cu(W,{maxFontBytes:Q,aggregateBudget:Math.max(0,c-de),shadowedRequests:Me});for(let fe of J.dropped)qe(new a(fe.reason,fe.reason==="overLimit"?`embedded font ${fe.request.family} (${fe.partName}) exceeds the font byte budget`:`embedded font part ${fe.partName} declares an invalid family name`,{request:fe.request}));let Se=ao({epoch:f,...q},J);if(Se.sources.length===0){le=!1,x(),q&&qe(new a("missing","the supplied font configuration contains no usable sources; the fixed measurer stays in effect"));return}let ce=await ro(Se);if(T||f!==z){xn(ce),f===z&&(le=!1);return}let he=new Set;for(let fe of J.sources){let Re=ce.fonts.resolve(fe.request);Re instanceof d&&(qe(bn(Re)),he.add(fe.id));}if(he.size>0&&he.size<J.sources.length){let fe=J.sources.filter(zt=>!he.has(zt.id)),Re=ce;if(ce=await ro(ao({epoch:f,...q},{sources:fe})),xn(Re),T||f!==z){xn(ce),f===z&&(le=!1);return}}else if(he.size===J.sources.length&&!q){le=!1,x();return}let ze=[...q?.sources??[],...J.sources].filter(fe=>!he.has(fe.id)).map(fe=>{let Re=ce.fonts.resolve(fe.request);return Re instanceof d||Re.id!==fe.id?null:{request:fe.request,id:Re.id,bytes:Re.bytes,hash:Re.hash,faceIndex:Re.faceIndex}}).filter(fe=>fe!==null),Te=await gu(ze,void 0,Se.substitutions??[]);if(T||f!==z){Te.dispose(),xn(ce),f===z&&(le=!1);return}L(),$=Te;let qt=jd$1(ge(),{context:a$3?Rn(a$3.ownerDocument):null,...$?{fontAlias:$.alias}:{}}),Ft=new Map;if(M=ld$1({shaper:ce.shaper,resolveFont:fe=>{let Re=fe.fontFamily??Se.defaultFont.family;if(Re.trim().length===0)return null;let zt={family:Re,weight:fe.bold?700:400,style:fe.italic?"italic":"normal"},Ge=e(zt);if(Ft.has(Ge))return Ft.get(Ge)??null;let Kt;try{Kt=ce.fonts.resolve(zt);}catch{return Ft.set(Ge,null),null}let qn=Kt instanceof d?null:Kt;return Ft.set(Ge,qn),qn},fallback:qt.measurer,shapingLibrary:g,unicodeDataVersion:"16.0.0",...Se.language?{language:Se.language}:{}}),G=`shaped:${ce.operation.extensionFingerprint}+fallback:${qt.producer}@scale:${ge()}`,le=!1,m){let fe=m.session.save(),Re=typeof document<"u"&&document.activeElement!==null&&a$3!==null&&a$3.contains(document.activeElement);try{Ce(fe),Re&&m?.focus();}catch(zt){M=void 0,G=void 0,m||(d$1=fe,Ce(fe)),qe(bn(zt));}}else x();}catch(q){if(T||f!==z)return;le=false,x(),qe(bn(q));}}}let Ae=null;function Ie(f){return f===null?Ae=null:Ae?.id!==f&&(Ae=Object.freeze({id:f})),Ae}function Mn(){let f=m?.state()??null;return {scope:m?.activeScope?.()??fm,isLoading:F===null&&m===null&&d$1===null,parseError:F,editable:m!==null&&m.session.editable&&I!=="view"&&p!=="viewing",zoom:O,selection:Ba(m),selectionCollapsed:f===null||f.selection.anchor.paragraphId===f.selection.head.paragraphId&&f.selection.anchor.offset===f.selection.head.offset,formatting:Gl(m),table:za(m),tocContext:Ie(f?.contextTocId??null),image:wt(m),page:{current:qa(m),total:Za(m)},canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,pageSetup:_a(m),reviewPaneOpen:st,hasReviewContent:m?.session.hasReviewContent()??false,editingMode:p,lastRejection:f?.lastRejection??S$1,fontSubstitutions:Ne()}}function $e(){if(De&&h===Xe)return De;let f=De,w=m?.state().selection??null,H=Ca(w,pe);pe=w;let W=m?.session.packageRevision()??-1,q=W===R$1;R$1=W;let Q=Mn(),de=Q;if(f){let Me=Ol(Q.formatting,f.formatting)?f.formatting:Q.formatting,J=Al(Q.page,f.page)?f.page:Q.page,Se=Ml(Q.pageSetup??null,f.pageSetup??null)?f.pageSetup:Q.pageSetup,ce=Hl(Q.selection,f.selection)?f.selection:Q.selection,he=Zl(Q.image,f.image)?f.image:Q.image,ze=f.fontSubstitutions!==void 0&&Q.fontSubstitutions!==void 0&&f.fontSubstitutions.length===Q.fontSubstitutions.length&&Q.fontSubstitutions.every((Te,qt)=>f.fontSubstitutions[qt]===Te)?f.fontSubstitutions:Q.fontSubstitutions;de={...Q,formatting:Me,page:J,pageSetup:Se,selection:ce,image:he,fontSubstitutions:ze},Ll(de,f)&&H&&q&&(de=f);}return De=co(de),h=Xe,De}if(e$1.document){let f=Ra(e$1.document);f?Je(f):(F="a DocumentHandle cannot be re-loaded; pass DOCX bytes",D(kn("unsupported",F)));}let it=0,me=null,ye="",Y=null,bt=true,fn=null;function $t(){let f=`${m?.session.packageRevision()??-1}:${m?.session.revision()??-1}`,w=pn(),H=_n()?.anchorY??null;return (m!==me||f!==ye||w!==Y||st!==bt||H!==fn)&&(me=m,ye=f,Y=w,bt=st,fn=H,it+=1),it}function xt(f){return f.kind==="revision"?f.ranges[0]??null:f.range}let It=new WeakMap;function Hn(f){let w=It.get(f);if(w)return w;let H=k$2(f,W=>R(W));for(let W of f.pages){for(let q of [W.header,W.footer])if(q)for(let Q of S(q.fragments))H.has(Q.paragraphId)||H.set(Q.paragraphId,{pageIndex:W.index,contentY:q.box.y,fragmentY:Q.box.y,...Q.lines?{lines:Q.lines}:{}});for(let q of [W.footnotes,W.endnotes])if(q)for(let Q of q.notes)for(let de of S(Q.fragments))H.has(de.paragraphId)||H.set(de.paragraphId,{pageIndex:W.index,contentY:Q.box.y,fragmentY:de.box.y,...de.lines?{lines:de.lines}:{}});}return It.set(f,H),H}let Pr=new WeakMap;function et(f){let w=Pr.get(f);if(w)return w;let H=new Map;for(let W of f.pages)for(let q of [W.footnotes,W.endnotes])if(q)for(let Q of q.notes)for(let de of S(Q.fragments))H.has(de.paragraphId)||H.set(de.paragraphId,Q.scopeId);return Pr.set(f,H),H}function _t(f){let w=xt(f)?.partName;if(!w||!m||w===m.session.part().name)return null;for(let H of m.session.headerFooterResolutionBySection())for(let W of ["header","footer"]){let q=W==="header"?H.headers:H.footers;for(let Q of q.values())if(Q.partName===w)return {kind:W,rId:Q.rId}}return null}function Ho(f){let w=xt(f),H=m?.publishedLayout();return !w||!H?null:et(H).get(w.start.paragraphId)??null}function Ln(f){let w=xt(f)?.partName;if(!w||!m)return null;for(let H of ["footnote","endnote"])if(Rd$1(m.session.currentPackage(),H)?.name===w)return {kind:"notesPart",noteKind:H};return null}function tt(f){let w=_t(f);return w!==null?{kind:"headerFooter",rId:w.rId}:Ln(f)??{kind:"body"}}function Bt(f){!m||m.activeScope().kind==="body"||m.session.paragraphIds().includes(f)&&(m.exitNote?.(),m.exitHeaderFooter?.());}let wr=()=>`${new Date().toISOString().slice(0,19)}Z`,st=true,Cr=new WeakMap;function Rr(f){let w=Cr.get(f);if(w)return w;let H=new Map;for(let[W,q]of wd$1(f).entries())H.set(q,W);return Cr.set(f,H),H}function Dn(){let f=m?.retainedSelection()??m?.state().selection??null;if(!f)return null;let{anchor:w,head:H}=f;if(w.paragraphId===H.paragraphId&&w.offset===H.offset)return null;let W=m?.publishedLayout();if(!W)return null;let q=Rr(W),Q=q.get(w.paragraphId)??-1,de=q.get(H.paragraphId)??-1;if(Q===-1||de===-1){let J=Lo();Q=J.get(w.paragraphId)??-1,de=J.get(H.paragraphId)??-1;}return Q===-1||de===-1?null:Q<de||Q===de&&w.offset<=H.offset?{from:w,to:H}:{from:H,to:w}}function Nn(){let f=m?.activeScope();if(f?.kind==="headerFooter")return {kind:"headerFooter",rId:f.rId};if(f?.kind==="note"){let w=_c$1(f.id);if(w)return {kind:"notesPart",noteKind:w.noteKind}}return {kind:"body"}}function Er(f){if(!m)return {kind:"body"};let w=f.slice(0,f.indexOf("#"));if(w.length===0||w===m.session.part().name)return {kind:"body"};for(let H of m.session.headerFooterResolutionBySection())for(let W of [H.headers,H.footers])for(let q of W.values())if(q.partName===w)return {kind:"headerFooter",rId:q.rId};for(let H of ["footnote","endnote"])if(Rd$1(m.session.currentPackage(),H)?.name===w)return {kind:"notesPart",noteKind:H};return Nn()}function Lo(){if(!m)return new Map;let f=Nn();if(f.kind==="body")return new Map;let w=new Map;for(let[H,W]of m.session.paragraphIdsIn(f).entries())w.set(W,H);return w}let St=null;function Rt(f){if(f.kind==="revision"){let H=f.ranges;if(H.length===0)return null;let q=f.revisionKind==="replace"||f.revisionKind==="insert"||f.revisionKind==="delete"?H[H.length-1]:H[0];return {start:H[0].start,end:q.end}}let w=xt(f);return w?{start:w.start,end:w.end}:null}function _n(){if(St&&m){let q=m.retainedSelection()??m.state().selection,Q=(Me,J)=>Me.paragraphId===J.paragraphId&&Me.offset===J.offset;if(!(Q(q.anchor,St.to)&&Q(q.head,St.from)||Q(q.anchor,St.from)&&Q(q.head,St.to)))St=null;else if(pn()===St.key)return null}let f=Dn(),w=m?.publishedLayout();if(!f||!w)return null;let H=Hn(w).get(f.from.paragraphId);if(!H)return null;let W=H.lines?.find(q=>f.from.offset<q.range.end);return {pageIndex:H.pageIndex,anchorY:H.contentY+(W?W.box.y:H.fragmentY)}}function pn(){return m?.activeReviewKey()??null}function Yt(f){if(!l$1)return [];let w=m?.session.reviewItems()??[],H=f?.excludeRevisionKinds;if(H&&H.length>0){let J=new Set(H);w=w.filter(ce=>ce.kind!=="revision"||!J.has(ce.revisionKind));let Se=new Set(w.filter(ce=>ce.kind==="revision").map(ce=>ce.id));w=w.map(ce=>{if(ce.kind!=="comment"||ce.parentRevisionId===void 0||Se.has(ce.parentRevisionId))return ce;let{parentRevisionId:he,...ze}=ce;return ze});}let W=f?.placement!==false,q=null;if(W&&w.length>0){let J=m?.publishedLayout()??null;J&&(q=Hn(J));}let Q=pn(),de=J=>{let Se=_t(J);return Se===null?1:Se.kind==="header"?0:2},Me=w.map((J,Se)=>({item:J,position:Se,pageIndex:q?l(J,q)?.pageIndex??null:null,group:de(J)}));return Me.sort((J,Se)=>{let ce=J.pageIndex??Number.MAX_SAFE_INTEGER,he=Se.pageIndex??Number.MAX_SAFE_INTEGER;return ce!==he?ce-he:J.group!==Se.group?J.group-Se.group:J.position-Se.position}),Me.map(({item:J})=>{let Se=b$2(J),ce=q?l(J,q):null,he={key:Se,id:J.id,...kt(J)!==void 0?{date:kt(J)}:{},anchorY:ce?.y??null,pageIndex:ce?.pageIndex??null,isActive:Se===Q};return J.kind==="comment"?{...he,kind:"comment",author:J.comment.author,initials:d$3(J.comment),text:c$2(J.comment),resolved:J.resolved,...J.parentId!==void 0?{parentId:J.parentId}:{},...J.parentRevisionId!==void 0?{parentRevisionId:J.parentRevisionId}:{},replyIds:J.replyIds,readOnly:false,item:J}:J.kind==="revision"?{...he,kind:"revision",revisionKind:J.revisionKind,author:J.author,initials:Bn(J.author),text:J.text,...J.replacedText?{replacedText:J.replacedText}:{},replyIds:J.replyIds,readOnly:J.readOnly,item:J}:{...he,kind:"custom",author:"",initials:"",text:J.detail??J.text,replyIds:[],readOnly:true,item:J}})}function Et(){return m?.session.trackingSettings()??N}function Fr(){if(l$1&&!(I==="view"||p!=="editing"||C)&&Et().trackRevisions){if(!e$1.author){S$1="this document asks for tracked changes, but no author is configured";return}p="suggesting",m?.setEditingMode("suggest");}}function Or(f){return f!=="editing"||!Et().restrictedToTrackedChanges?null:{ok:false,code:"locked",reason:"this document permits editing only as tracked changes"}}function kt(f){return f.kind==="comment"?f.comment.date:f.kind==="revision"?f.date:void 0}function Bn(f){let w=f.trim().split(/\s+/).filter(Boolean);return w.length===0?"?":w.slice(0,2).map(H=>H[0].toUpperCase()).join("")}function Zn(f,w){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let W=Yt().find(Q=>Q.key===f)?.item;if(!W||W.kind!=="revision")return {ok:false,code:"notFound",reason:"no revision with that key"};if(W.readOnly)return {ok:false,code:"unsupported",reason:"this revision kind has no structural accept/reject yet"};let q;return m?.commitReviewOps(()=>(q=m.session.applyTreeOps(W.addresses.map(Q=>w==="accept"?{op:"acceptRevision",revision:Q}:{op:"rejectRevision",revision:Q}),void 0,void 0,tt(W)),q)),q?.committed?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:typeof q?.reason=="string"?q.reason:"the revision was refused"}}let Zt={get mountGeneration(){return X},get surface(){return m},setHyperlinkChrome(f){return P.push(f),()=>{let w=P.lastIndexOf(f);w>=0&&P.splice(w,1);}},stateVersion:()=>Xe,fontMeasurement:()=>({measurer:M?"shaped":"fixed",resolving:le,...M&&G?{producer:G}:{}}),attach(f){if(T){D(kn("destroyed","this editor was destroyed; create a new instance to remount"));return}if(m&&a$3===f)return;m&&(d$1=m.session.save(),ne()),a$3=f,Oe=null;let w=d$1;d$1=null,w?Ce(w):x();},detach(){T||(m&&(d$1=m.session.save(),ne()),a$3=null,Oe=null,x());},load(f){let w=Ra(f);if(!w){D(kn("unsupported","a DocumentHandle cannot be re-loaded; pass DOCX bytes"));return}Je(w);},save(){if(!m)return Promise.reject(kn("notFound","no document is loaded"));let w=m.session.save().slice();return Promise.resolve(w.buffer)},getDocumentHandle(){return Object.freeze({revision:m?.session.revision()??0})},exec(f,w){if(T&&(f.type==="toggleReviewPane"||f.type==="setEditingMode"))return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(f.type==="setEditingMode"){if(I==="view"&&f.mode!=="viewing")return {ok:false,code:"locked",reason:"this document was opened for viewing"};if(f.mode==="suggesting"&&!l$1)return {ok:false,code:"unsupported",reason:Xt};let Me=Or(f.mode);return Me||(C=true,S$1=null,p=f.mode,m?.setEditingMode(f.mode==="suggesting"?"suggest":f.mode==="viewing"?"view":"edit"),m?.setEditable(f.mode!=="viewing"),x(),ee(),{ok:true,changed:false})}if(f.type==="toggleReviewPane")return l$1?(st=!st,x(),ee(),{ok:true,changed:false}):{ok:false,code:"unsupported",reason:Xt};if(Pi(f)){let Me=wi(f,m,I,w);return Me.ok?su(m,f):Me}let H=gr(f);if(p==="viewing"&&H.supported&&H.mutating)return {ok:false,code:"locked",reason:"the document is open for viewing"};let W=Ir(f,m,I,w);if(!W.ok)return W.refusal;let q=m,Q=q.session.packageRevision(),de=eu(q,f,{...W.tablePlan?{admittedTablePlan:W.tablePlan}:{},editor:Zt});return de||{ok:true,changed:q.session.packageRevision()!==Q}},can(f,w){if(f.type==="insertImage"||f.type==="replaceImage"){if(T)return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(w?.scope){let q=Ir(f,m,I,w);if(!q.ok)return q.refusal}return Vl(f,m)}if(f.type==="toggleReviewPane"||f.type==="setEditingMode"){if(T)return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(f.type==="toggleReviewPane"&&!l$1)return {ok:false,code:"unsupported",reason:Xt};if(f.type==="setEditingMode"&&I==="view"&&f.mode!=="viewing")return {ok:false,code:"locked",reason:"this document was opened for viewing"};if(f.type==="setEditingMode"){if(f.mode==="suggesting"&&!l$1)return {ok:false,code:"unsupported",reason:Xt};let q=Or(f.mode);if(q)return q}return {ok:true}}if(Pi(f))return wi(f,m,I,w);let H=gr(f);if(p==="viewing"&&H.supported&&H.mutating)return {ok:false,code:"locked",reason:"the document is open for viewing"};let W=Ir(f,m,I,w);if(!W.ok)return W.refusal;if(yr(f)&&Ma(f)){let q=vr(Zt);if(q){let Q=Ha(Zt,f,q);if(Q)return Q}}return {ok:true}},isActive(f){if(f.type==="toggleReviewPane")return st;if(f.type==="setEditingMode")return p===f.mode;let w=m?$e().formatting:null;if(!w)return false;switch(f.type){case "toggleMark":switch(f.mark){case "bold":return w.bold===true;case "italic":return w.italic===true;case "underline":return w.underline===true;case "strike":return w.strike===true;case "superscript":return w.superscript===true;case "subscript":return w.subscript===true;default:return false}case "setAlignment":return w.alignment===(f.align==="justify"?"both":f.align);case "toggleList":return m?.isListActive(f.kind)??false;default:return false}},getDocumentStyles:()=>m?.session.documentStyles()??[],getDocumentFonts:()=>m?.session.documentFonts()??[],getAvailableFonts:()=>du(re(),m?.session.documentFonts()??[]),getDocumentThemeColors:()=>m?.session.documentThemeColors()??[],getOutline:()=>m?.session.documentOutline()??[],getComments:()=>[],getSelectionFormatting:()=>Yl(m?$e().formatting:null),findMatches:(f,w)=>m?.session.findText(f,{...w?.matchCase!==void 0?{matchCase:w.matchCase}:{},...w?.wholeWord!==void 0?{wholeWord:w.wholeWord}:{}}).matches??[],selectMatch(f){return m?typeof f?.blockId!="string"||f.blockId.length===0||!Number.isInteger(f.start)||f.start<0||!Number.isInteger(f.length)||f.length<0?{ok:false,code:"invalidArgs",reason:"match must carry a blockId and offsets"}:(Bt(f.blockId),m.setSelection({anchor:{paragraphId:f.blockId,offset:f.start},head:{paragraphId:f.blockId,offset:f.start+f.length}}),m.revealParagraph(f.blockId),{ok:true,changed:false}):{ok:false,code:"notFound",reason:"no document is loaded"}},getSelectedImage:()=>$e().image,getSelectedTable:()=>$l(m),getTableCellSelection:()=>{let f=m?.state().cellSelection;return f?{tableId:f.tableId,rows:f.rows,columns:f.columns,cellIds:f.cellIds}:null},setTableInteractionLabel(f){m?.setTableInteractionLabel(f);},canExecuteImageCommand(f,w){if(T)return {ok:false,code:"notFound",reason:"the editor was destroyed"};if(w?.scope){let H=Ir(f,m,I,w);if(!H.ok)return H.refusal}return La(f,m)},executeImageCommand(f){return T?Promise.resolve({ok:false,code:"notFound",reason:"the editor was destroyed"}):Da(Zt,f)},getPageSetup:()=>_a(m),getWatermark:()=>null,getTrackedChanges:()=>(m?.session.reviewItems()??[]).filter(f=>f.kind==="revision").map(f=>{let w=_t(f);return {id:f.id,kind:f.kind==="revision"?f.revisionKind:"revision",...f.kind==="revision"&&f.author?{author:f.author}:{},story:w!==null?w.kind:Ln(f)?.noteKind??"body"}}),getReviewItems:f=>Yt(f),getCustomNodeDefinitions:()=>o.customNodes,reportCustomNodeDiagnostic:i,addComment(f,w){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let H=Dn();if(!H||!m)return {ok:false,code:"invalidArgs",reason:"a comment needs a selected range"};let W=(w??e$1.author??"").trim();if(W.length===0||f.trim().length===0)return {ok:false,code:"invalidArgs",reason:"a comment needs both an author and text"};let q=null;return m.commitReviewOps(()=>(q=m.session.replyToComment(null,{paragraphId:H.from.paragraphId,start:H.from.offset,end:H.to.offset,...H.to.paragraphId===H.from.paragraphId?{}:{endParagraphId:H.to.paragraphId}},f,W,wr(),Er(H.from.paragraphId)),{committed:q!==null})),q===null?{ok:false,code:"unsupported",reason:"the comment could not be committed"}:(m.releaseSelection(),{ok:true,changed:true})},getSelectionPlacement:()=>_n(),getRenderScale:()=>ge(),isReviewPaneOpen:()=>st,getEditingMode:()=>p,setEditingMode:f=>Zt.exec({type:"setEditingMode",mode:f}),getReviewRevision:()=>$t(),setActiveReviewItem(f){if(f===null){m?.dismissActiveReview(),x(),ee();return}let H=Yt().find(de=>de.key===f)?.item,W=H?xt(H):null;if(!W||!m)return;let q=H?_t(H):null,Q=q===null&&H?Ho(H):null;if(q!==null){if(!m.enterHeaderFooter?.({rId:q.rId,kind:q.kind,position:{paragraphId:W.start.paragraphId,offset:W.start.offset}}))return}else if(Q!==null){if(!m.enterNote?.(Q,{paragraphId:W.start.paragraphId,offset:W.start.offset}))return}else {m.exitNote?.(),m.exitHeaderFooter?.();let de=Rt(H)??W;m.setSelection({anchor:{paragraphId:de.end.paragraphId,offset:de.end.offset},head:{paragraphId:de.start.paragraphId,offset:de.start.offset}}),St={key:f,from:de.start,to:de.end},m.revealPosition?.(de.start,{block:"centerIfNeeded"});}x(),ee();},setReviewActivationExclusions(f){y=f===null?null:[...f],m?.setReviewActivationExclusions(y);},acceptReviewItem:f=>Zn(f,"accept"),rejectReviewItem:f=>Zn(f,"reject"),deleteReviewItem(f){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let H=Yt().find(q=>q.key===f)?.item;if(!H||!m)return {ok:false,code:"notFound",reason:"no review item with that key"};if(H.kind==="revision")return Zn(f,"reject");if(H.kind!=="comment")return {ok:false,code:"unsupported",reason:"a custom node card cannot be deleted"};pn()===f&&m.dismissActiveReview();let W=false;return m.commitReviewOps(()=>(W=m.session.deleteComment(H.id),{committed:W})),W?(x(),{ok:true,changed:true}):{ok:false,code:"unsupported",reason:"the comment could not be deleted"}},replyToReviewItem(f,w,H){if(!l$1)return {ok:false,code:"unsupported",reason:Xt};let q=Yt().find(Se=>Se.key===f)?.item;if(!q||!m)return {ok:false,code:"notFound",reason:"no review item with that key"};let Q=xt(q);if(!Q)return {ok:false,code:"invalidArgs",reason:"the item has no anchorable range"};let de=(H??e$1.author??"").trim();if(de.length===0||w.trim().length===0)return {ok:false,code:"invalidArgs",reason:"a reply needs both an author and text"};if(q.kind==="custom")return {ok:false,code:"unsupported",reason:"a custom node card takes no replies"};let Me=q.kind==="comment"?q.id:null,J=null;return m.commitReviewOps(()=>(J=m.session.replyToComment(Me,{paragraphId:Q.start.paragraphId,start:Q.start.offset,end:Q.end.offset},w,de,wr(),tt(q)),{committed:J!==null})),J===null?{ok:false,code:"unsupported",reason:"the reply could not be committed"}:{ok:true,changed:true}},getHeaderFooterState:()=>m?.headerFooterState()??null,getNotePropertiesState:()=>m?.notePropertiesState?.()??null,getNotePreviewText:f=>m?.notePreviewText?.(f)??null,setActiveScope(f){m?.setActiveScope(f)&&x();},getActiveScope:()=>m?.activeScope()??{kind:"body"},query(f){switch(f.type){case "selectedText":return m?.selectedText()??"";case "selectionFormatting":return m?$e().formatting:null;case "selection":return Ba(m);case "paragraphs":return Xl(m,f.container);case "isInsideToc":return m?m.isInsideToc(m.state().selection.head.paragraphId):false;case "hyperlinkAt":return Wl(m);case "contentControls":return ru(m,f.filter);case "trackedChanges":case "revisions":case "findText":case "comments":return [];case "styles":return {paragraph:new Map,character:new Map,table:new Map};case "variables":return {};case "contentControlAt":return Ti(m,f.filter);case "tableContext":return za(m);default:return null}},snapshot:()=>$e(),getTotalPages:()=>Za(m),getCurrentPage:f=>qa(m,f),scrollToPage:f=>Number.isInteger(f)&&f>=1?m?.revealPage(f-1)??false:false,scrollToBlock:f=>typeof f!="string"||f.length===0?false:(Bt(f),m?.revealParagraph(f)??false),getZoom:()=>O,setZoom(f){return !Number.isFinite(f)||f<.1||f>5?{ok:false,code:"invalidArgs",reason:`zoom must be between 0.1 and 5, got ${f}`}:f===O?{ok:true,changed:false}:m&&!qc(m,f*(96/72))?{ok:false,code:"unsupported",reason:`the mounted surface could not apply zoom ${f}`}:(O=f,x(),ee(),{ok:true,changed:true})},getPageGeometry:()=>m?m.layout().pages.map(f=>({index:f.index,box:hu(f.box),contentBox:hu(f.contentBox)})):[],relayout(f){f?.sync,m?.layout();},focus(f){return m?f&&f.kind==="all"?{ok:false,code:"invalidTarget",reason:"the all scope cannot take focus"}:f&&!m.setActiveScope(f)?{ok:false,code:"invalidTarget",reason:"that scope cannot be opened"}:(m.focus(),{ok:true,value:void 0}):{ok:false,code:"invalidTarget",reason:"no document is loaded"}},destroy(){T=true,L(),ne(),a$3=null,d$1=null,X+=1,x();for(let f of Object.values(N$1))f.clear();},on(f,w){return N$1[f].add(w),()=>{N$1[f].delete(w);}}};return Zt}var yu=Object.freeze({document:true,save:true,events:true,selection:true,scrolling:true,layout:true});function mm(e){return g$1({port:hm(e),capabilities:yu})}function hm(e){let t=0,n=0,r=null,a=false,o=false,i=()=>{if(o)return null;let l=e.surface?.session??null;return l!==r&&(a&&(t+=n+1),a=true,r=l,n=0),l&&(n=l.packageRevision()),l};return {revision(){return i(),t+n},currentPackage:()=>i()?.currentPackage()??null,apply(l,d){i();let p=e.surface;if(!p)return {ok:false,reason:"no-document"};let y=p.applyAutomationOps(l,d);return y.rejected?{ok:false,reason:String(y.reason??"refused")}:{ok:true,changed:y.committed}},applyLifecycle(l){i();let d=e.surface;if(!d)return {ok:false,reason:"no-document"};let p=d.applyAutomationOps(()=>[l]);return p.rejected?{ok:false,reason:String(p.reason??"refused")}:{ok:true,changed:p.committed}},applyCommentWrite(l,d){let p=e.surface,y=i();if(!p||!y)return {ok:false,reason:"no-document"};if(d.kind!=="body")return {ok:false,reason:"unsupported-story"};let C={ok:false,reason:"refused"};return p.commitReviewOps(()=>{if(l.kind==="resolve"){let I=y.setCommentResolved(l.commentId,l.resolved);return C=I?{ok:true,changed:true}:{ok:false,reason:"unknown-comment"},{committed:I}}let S=y.replyToComment(l.parentCommentId,l.anchor,l.text,l.author,l.date);return C=S===null?{ok:false,reason:"refused"}:{ok:true,changed:true,commentId:S},{committed:S!==null}}),C},applyCustomNodeWrite(l,d){let p=e.surface,y=i();if(!p||!y)return {ok:false,reason:"no-document"};if(d.kind!=="body")return {ok:false,reason:"unsupported-story"};let C={ok:false,reason:"refused"};return p.commitReviewOps(()=>{let S=y.insertCustomNode(l);return C=S.ok?{ok:true,changed:S.change!==null}:{ok:false,reason:S.detail?`${S.reason}: ${S.detail}`:S.reason},{committed:S.ok}}),C},save:()=>i()?.save()??null,select(l,d){let p=e.surface;if(!p)return;let y=d==="end"?l.end:l.start,C=d==="start"?l.start:l.end;p.setSelection({anchor:{paragraphId:y.paragraphId,offset:y.offset},head:{paragraphId:C.paragraphId,offset:C.offset}});},subscribe:l=>e.on("change",()=>l()),dispose(){o=true,r=null;}}}function ym(e){return e*(96/72)}function vm(e,t){return e*t}function bm(e,t){return e/t}function xm(e,t,n){let r=e.pages[t.pageIndex];if(!r)return {left:0,top:0,width:0,height:0};let a=n.pageOffsetX.get(r.index)??0,o=n.paintScale;return Object.freeze({left:(r.contentBox.x+t.x+a)*o,top:(r.contentBox.y+t.y)*o,width:t.width*o,height:t.height*o})}function bu(e,t,n){return t?true:e.length===1?false:!n}var vu=["e","se","s","sw","w","nw","n","ne"];function Im(e,t){let n=vu.indexOf(e);t.flipHorizontal&&(n=(4-n+8)%8),t.flipVertical&&(n=(8-n)%8);let r=Math.round(t.rotationDegrees/45)%8;return vu[(n-r+8)%8]}function Sm(e,t,n){let r=e,a=t,o=-n.rotationDegrees*Math.PI/180,i=Math.cos(o),l=Math.sin(o),d=r*i-a*l,p=r*l+a*i;return r=d,a=p,n.flipHorizontal&&(r=-r),n.flipVertical&&(a=-a),Object.freeze({x:r,y:a})}function un(e){return e/xr}function xu(e){let t=Sm(e.deltaXPt,e.deltaYPt,e.transform),n=un(e.startWidthEmu),r=un(e.startHeightEmu),a=n/r,o=Im(e.handle,e.transform),i=o.includes("e")?t.x:o.includes("w")?-t.x:0,l=o.includes("s")?t.y:o.includes("n")?-t.y:0;if(n=Math.max(1,n+i),r=Math.max(1,r+l),e.preserveAspect)if(o.length===2){let k=Math.max(n/un(e.startWidthEmu),r/un(e.startHeightEmu));n=Math.max(1,un(e.startWidthEmu)*k),r=Math.max(1,n/a);}else o==="e"||o==="w"?r=Math.max(1,n/a):n=Math.max(1,r*a);let d=un(e.startWidthEmu),p=un(e.startHeightEmu),y=n/d,C=r/p,S=Math.max(1,e.startBounds.width*y),I=Math.max(1,e.startBounds.height*C),O=e.startBounds.x,m=e.startBounds.y,F=e.handle;F.includes("w")&&(O=e.startBounds.x+e.startBounds.width-S),F.includes("n")&&(m=e.startBounds.y+e.startBounds.height-I);let B=null;if(e.kind==="anchored"&&e.startPosition&&(F.includes("w")||F.includes("n")))if(e.startPosition.mode==="simple"){let A=F.includes("w")?Ve(O-e.startBounds.x):0,k=F.includes("n")?Ve(m-e.startBounds.y):0;B=Object.freeze({mode:"simple",horizontalEmu:(e.startPosition.horizontalEmu??0)+A,verticalEmu:(e.startPosition.verticalEmu??0)+k});}else if(e.anchorFrameOrigin)B=Object.freeze({mode:"frame",...e.startPosition.relativeToH!==void 0?{relativeToH:e.startPosition.relativeToH}:{},...e.startPosition.relativeToV!==void 0?{relativeToV:e.startPosition.relativeToV}:{},...F.includes("w")?{horizontalEmu:Ve(O-e.anchorFrameOrigin.x)}:e.startPosition.horizontalEmu!==void 0?{horizontalEmu:e.startPosition.horizontalEmu}:{},...F.includes("n")?{verticalEmu:Ve(m-e.anchorFrameOrigin.y)}:e.startPosition.verticalEmu!==void 0?{verticalEmu:e.startPosition.verticalEmu}:{}});else {let A=F.includes("w")?Ve(O-e.startBounds.x):0,k=F.includes("n")?Ve(m-e.startBounds.y):0;B=Object.freeze({mode:"frame",...e.startPosition.horizontalEmu!==void 0?{horizontalEmu:e.startPosition.horizontalEmu+A}:{},...e.startPosition.verticalEmu!==void 0?{verticalEmu:e.startPosition.verticalEmu+k}:{},...e.startPosition.relativeToH!==void 0?{relativeToH:e.startPosition.relativeToH}:{},...e.startPosition.relativeToV!==void 0?{relativeToV:e.startPosition.relativeToV}:{}});}return Object.freeze({widthEmu:Ve(n),heightEmu:Ve(r),previewBounds:Object.freeze({x:O,y:m,width:S,height:I}),position:B})}function km(e,t){return Object.freeze({scrollBy(n){if(!Number.isFinite(n)||n===0)return 0;let r=e.scrollTop;return e.scrollTop+=n*t,(e.scrollTop-r)/t}})}function Tm(e){if(e.session.mode==="move"){let t=e.session.startBounds.x+e.deltaXPt,n=e.session.startBounds.y+e.deltaYPt+e.accumulatedScrollPt,r=e.session.startPosition&&Na(e.session.startPosition,e.deltaXPt,e.deltaYPt+e.accumulatedScrollPt);return Object.freeze({widthEmu:e.session.startWidthEmu,heightEmu:e.session.startHeightEmu,previewBounds:Object.freeze({x:t,y:n,width:e.session.startBounds.width,height:e.session.startBounds.height}),position:r??null})}return e.session.handle?xu({handle:e.session.handle,startWidthEmu:e.session.startWidthEmu,startHeightEmu:e.session.startHeightEmu,startBounds:e.session.startBounds,startPosition:e.session.startPosition,anchorFrameOrigin:e.anchorFrameOrigin,deltaXPt:e.deltaXPt,deltaYPt:e.deltaYPt,transform:e.session.transform,preserveAspect:bu(e.session.handle,e.aspectLocked,e.shiftKey),kind:e.session.kind}):Object.freeze({widthEmu:e.session.startWidthEmu,heightEmu:e.session.startHeightEmu,previewBounds:e.session.startBounds,position:null})}
|
|
12
12
|
export{ed as $,vf as A,vo as Aa,Ea as B,gi as Ba,Kf as C,gm as Ca,mr as D,yu as Da,hr as E,mm as Ea,Fa as F,ym as Fa,jf as G,vm as Ga,Oa as H,bm as Ha,wt as I,xm as Ia,vr as J,bu as Ja,La as K,xu as Ka,Da as L,km as La,rp as M,Tm as Ma,op as N,xr as O,ip as P,Ve as Q,Tn as R,sp as S,Na as T,lp as U,fo as V,wn as W,Jl as X,Ka as Y,po as Z,pp as _,bn as a,td as aa,ro as b,gp as ba,xn as c,dn as ca,va as d,ja as da,oo as e,vp as ea,ao as f,bp as fa,Qu as g,Ip as ga,rf as h,go as ha,of as i,od as ia,af as j,mo as ja,dl as k,ad as ka,sf as l,id as la,lf as m,Tp as ma,df as n,Pp as na,cf as o,wp as oa,uf as p,Cp as pa,ff as q,Rp as qa,pf as r,Ep as ra,cl as s,Va as sa,gf as t,Fp as ta,ba as u,ld as ua,hl as v,Op as va,yl as w,dd as wa,lo as x,Ap as xa,Ia as y,Mp as ya,Sa as z,Hp as za};
|