@docx-editor.dev/core 2.12.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -14
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.cts +5 -5
- package/dist/automation.d.ts +5 -5
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.cts +8 -8
- package/dist/binding.d.ts +8 -8
- package/dist/binding.js +1 -1
- package/dist/chunk-2PIHW2QM.cjs +1 -0
- package/dist/chunk-2QTY5S6T.js +1 -0
- package/dist/chunk-4Z5MODAE.cjs +2 -0
- package/dist/chunk-5TKAPFZT.cjs +2 -0
- package/dist/chunk-DRQHIQ4R.cjs +1 -0
- package/dist/chunk-F2K6SDHA.cjs +20 -0
- package/dist/chunk-FBA57EUJ.js +2 -0
- package/dist/{chunk-XCFM3G5L.cjs → chunk-KIAP7PFQ.cjs} +1 -1
- package/dist/chunk-KTAQ7BRQ.js +20 -0
- package/dist/chunk-LBAHXZCU.cjs +5 -0
- package/dist/chunk-MCDUQYWP.js +5 -0
- package/dist/chunk-MQP26KCF.js +1 -0
- package/dist/chunk-NDJGSR6M.cjs +19 -0
- package/dist/chunk-NJNFJPGB.cjs +11 -0
- package/dist/chunk-O5M4CR4P.cjs +2 -0
- package/dist/{chunk-W77HJGYX.js → chunk-OKEDGR65.js} +1 -1
- package/dist/{chunk-WU7PUTVA.js → chunk-RIYSCEFQ.js} +1 -1
- package/dist/chunk-UKUOZXUD.js +19 -0
- package/dist/chunk-VQ4R5LTU.js +2 -0
- package/dist/chunk-ZBEJHJN2.js +11 -0
- package/dist/chunk-ZVTW7RGD.js +2 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.cts +3 -3
- package/dist/collaboration/replication.d.ts +3 -3
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.cts +3 -3
- package/dist/collaboration.d.ts +3 -3
- package/dist/contracts/editor.d.cts +7 -7
- package/dist/contracts/editor.d.ts +7 -7
- package/dist/contracts/interaction.d.cts +7 -7
- package/dist/contracts/interaction.d.ts +7 -7
- package/dist/contracts/modules.d.cts +7 -7
- package/dist/contracts/modules.d.ts +7 -7
- package/dist/{custom-node-writes-D4rMJIES.d.cts → custom-node-writes-C46r3_5O.d.cts} +2 -2
- package/dist/{custom-node-writes-CcNeHH5C.d.ts → custom-node-writes-DntmaAVW.d.ts} +2 -2
- package/dist/{dist-YFULGVS3.js → dist-OSUJGKTK.js} +1 -1
- package/dist/{editor-B76SEMZw.d.cts → editor-AJ06hyyg.d.cts} +45 -9
- package/dist/{editor-BcdsPdbY.d.ts → editor-a6VvsfYU.d.ts} +45 -9
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.d.cts +22 -22
- package/dist/editor.d.ts +22 -22
- package/dist/editor.js +1 -1
- package/dist/{index-BYTvklN5.d.ts → index-C5ZnSRkF.d.ts} +209 -20
- package/dist/{index-CDGhPib1.d.cts → index-Cbw4lkOt.d.cts} +209 -20
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.cts +203 -593
- package/dist/layout.d.ts +203 -593
- package/dist/layout.js +1 -1
- package/dist/{note-properties-Bx7rXruA.d.ts → note-properties-CDFiNXcD.d.ts} +1 -1
- package/dist/{note-properties-zQ8w04en.d.cts → note-properties-Y6qYh2Hv.d.cts} +1 -1
- package/dist/{omml-equation-69O1Pd8G.d.ts → omml-equation-BY49UOIF.d.ts} +1 -1
- package/dist/{omml-equation-BmV51rim.d.cts → omml-equation-DB8d-jCq.d.cts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.cts +6 -6
- package/dist/output.d.ts +6 -6
- package/dist/output.js +1 -1
- package/dist/{protocol-DC7ueVuo.d.ts → protocol-BsmQgblT.d.ts} +2 -2
- package/dist/{protocol-FTXtrAIT.d.cts → protocol-gOY5GA8K.d.cts} +2 -2
- package/dist/{review-items-B78OsJU2.d.ts → review-items-CCS1h93f.d.ts} +1 -1
- package/dist/{review-items-C-2WQdEb.d.cts → review-items-CaAkgi5s.d.cts} +1 -1
- package/dist/{review-reads-UexYBp-m.d.ts → review-reads-BjZYeMd4.d.ts} +8 -21
- package/dist/{review-reads-CbBQlb-n.d.cts → review-reads-DEsV0OOW.d.cts} +8 -21
- package/dist/{revision-projection-6u8lae9J.d.cts → revision-projection-BeXVrSSV.d.ts} +24 -3
- package/dist/{revision-projection-B2v9U3qx.d.ts → revision-projection-DXbrfNGD.d.cts} +24 -3
- package/dist/{semantic-cell-selection-DsYz2Vg3.d.ts → semantic-cell-selection-BK91NCCG.d.ts} +16 -7
- package/dist/{semantic-cell-selection-nEE7E3Z8.d.cts → semantic-cell-selection-BMhku3B1.d.cts} +16 -7
- package/dist/{semantic-interaction-C00BpIyC.d.ts → semantic-interaction-BmQ7h2cq.d.ts} +4 -2
- package/dist/{semantic-interaction-DiOX0FIH.d.cts → semantic-interaction-DUAnxbgf.d.cts} +4 -2
- package/dist/{semantic-paint-Cc11nrDL.d.cts → semantic-paint-DufNL1Zr.d.cts} +2 -2
- package/dist/{semantic-paint-ofuoBsYo.d.ts → semantic-paint-WJD2KeG1.d.ts} +2 -2
- package/dist/{semantic-records-CRG1r6-a.d.cts → semantic-records-92UnKeU_.d.ts} +1146 -10
- package/dist/{semantic-records-CzI0ZEuR.d.ts → semantic-records-BpozY7-j.d.cts} +1146 -10
- package/dist/shaped-measurer-BWbindlI.d.ts +168 -0
- package/dist/shaped-measurer-CFPnXFs9.d.cts +168 -0
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +26 -16
- package/dist/store.d.ts +26 -16
- package/dist/store.js +1 -1
- package/dist/{tree-op-types-CA7qgAUF.d.cts → tree-op-types-BUulYD5y.d.cts} +15 -2
- package/dist/{tree-op-types-HKfUzt_-.d.ts → tree-op-types-D6HzlPR4.d.ts} +15 -2
- package/dist/{tree-package-fragment-oJZX_5iN.d.ts → tree-package-fragment-CWFjgH6a.d.ts} +3 -11
- package/dist/{tree-package-fragment-Cz-v-0B3.d.cts → tree-package-fragment-Dhyw7oPm.d.cts} +3 -11
- package/dist/{tree-session-contract-BPDLrEPX.d.ts → tree-session-contract-B2HfGt79.d.ts} +33 -6
- package/dist/{tree-session-contract-Cbl87xa8.d.cts → tree-session-contract-BY9xd7s_.d.cts} +33 -6
- package/dist/{tree-store-B7hd6cEa.d.ts → tree-store-APgWx6qn.d.ts} +1 -1
- package/dist/{tree-store-BenW0Mg_.d.cts → tree-store-DEEQ9wz_.d.cts} +1 -1
- package/package.json +5 -2
- package/dist/chunk-3JON7JMD.cjs +0 -1
- package/dist/chunk-5V6FNKBE.cjs +0 -2
- package/dist/chunk-BXRVGHTY.cjs +0 -18
- package/dist/chunk-BXTTPJSH.js +0 -5
- package/dist/chunk-ILTZTY3K.cjs +0 -10
- package/dist/chunk-IUM7FZPA.js +0 -2
- package/dist/chunk-JWZG4QJ5.cjs +0 -2
- package/dist/chunk-JXZYDBKU.cjs +0 -19
- package/dist/chunk-KBOOIC2Q.js +0 -19
- package/dist/chunk-L6XZTLPS.js +0 -10
- package/dist/chunk-L7OR5TJK.cjs +0 -5
- package/dist/chunk-MHQNR2OU.js +0 -2
- package/dist/chunk-MLGPISGH.js +0 -1
- package/dist/chunk-NJXQABQU.js +0 -18
- package/dist/chunk-TKEGK4GQ.cjs +0 -2
- package/dist/chunk-VGFMPWND.js +0 -2
- package/dist/shaped-measurer-CkOGZQn9.d.ts +0 -611
- package/dist/shaped-measurer-CneACGcP.d.cts +0 -611
package/dist/chunk-IUM7FZPA.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {_e,Ze,Mf,ze,Pe,df,Ea as Ea$1,Xb,ta as ta$1,ca as ca$1,ec,dc,cc,Vb,xa as xa$1,ya as ya$1,Db,b,ra as ra$1,fc,cf,pe as pe$1,Vf,af,bf,Hd,Id,E,Bb,Eb,Fb,Cb,O,Be as Be$1,xb,Ga as Ga$1,ef,ff,if as _if,hf,_b,Tf,Uf,xf,ng,ig,sg,mg,lg,gg,vg,hg,ug,og,kg,ja as ja$1,Pc,xe,ye,J as J$1,Ca as Ca$1,He as He$1,yg,Pf,Qf,Of,Ed,w,a,Ob,bc,Ag,Zg,Zb,fa as fa$1,Aa as Aa$1,De,ch,$g,Rf,wd,Ha as Ha$1,Pb,Lb,Nb,Qb,Sb,Tb,Pa as Pa$1,gf,yb,fg,zb,ub,Fa as Fa$1,Fc,Nc as Nc$1,lb,Kb,xg,Ve as Ve$1,bh,db,Za as Za$1,_a as _a$1,ab,F as F$1,pa as pa$1,g,qa as qa$1,u,Ie,We as We$1,Gb,bb,oa as oa$1,P,W,ah,Gd,Ug,Vg,da as da$1,Ib,Jb,Hb}from'./chunk-L6XZTLPS.js';import {strFromU8,strToU8}from'fflate';function J(t){return t.kind!=="textValue"}function F(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===ca$1}function ne(t,e){for(let n of t)e(n),n.kind!=="textValue"&&ne(n.children,e);}function pe(t){if(t.kind==="textValue")return `T(${t.value})`;if(t.namespaceUri===ca$1&&t.localName.startsWith("rsid"))return "";let e=t.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===fa$1&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=t.children.map(pe).join("");return `E(${t.namespaceUri}:${t.localName}[${e}]{${n}})`}function et(t){return `S[${t.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${t.children.map(pe).join("")}`}function It(t){let e=[],n=new Map,r=new Set,a=null;if(t&&J(t.root))for(let i of t.root.children){if(!J(i))continue;if(F(i,"docDefaults")){a=i;continue}if(!F(i,"style"))continue;e.push(i);let o=ze(i,"styleId");o&&n.set(o,i);let s=i.children.find(d=>F(d,"name")),l=s?ze(s,"val"):void 0;l&&r.add(l);}return {part:t,styles:e,docDefaults:a,byId:n,names:r}}function Pt(t,e,n){let r=new Map;if(!t)return r;let a=t.children.find(o=>F(o,e));if(!a||!J(a))return r;let i=a.children.find(o=>F(o,n));if(!i||!J(i))return r;for(let o of i.children)o.kind!=="textValue"&&r.set(o.localName,o);return r}function Zt(t,e,n,r){let a=e;for(let i=0;i<16&&a;i+=1){let o=t.byId.get(a);if(!o)return false;let s=o.children.find(d=>F(d,n));if(s&&J(s)&&s.children.some(d=>d.kind!=="textValue"&&d.localName===r))return true;let l=o.children.find(d=>F(d,"basedOn"));a=l?ze(l,"val"):void 0;}return false}function oi(t,e){for(let n of t.styles){if(ze(n,"type")!==e)continue;let r=ze(n,"default");if(r==="1"||r==="true")return ze(n,"styleId")}}function Ot(t,e){let n=t.children.find(r=>F(r,e));return n&&J(n)?n:null}var ai=new Map(["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"].map((t,e)=>[t,e])),ii=new Map(["rStyle","rFonts","b","bCs","i","iCs","caps","smallCaps","strike","dstrike","outline","shadow","emboss","imprint","noProof","snapToGrid","vanish","webHidden","color","spacing","w","kern","position","sz","szCs","highlight","u","effect","bdr","shd","fitText","vertAlign","rtl","cs","em","lang","eastAsianLayout","specVanish","oMath","rPrChange"].map((t,e)=>[t,e]));function en(t,e,n){let r=Pt(e.docDefaults,"rPrDefault","rPr"),a=Pt(n.docDefaults,"rPrDefault","rPr"),i=Pt(e.docDefaults,"pPrDefault","pPr"),o=Pt(n.docDefaults,"pPrDefault","pPr"),s=(f,x,p)=>{let h=oi(f,"paragraph"),N=h?f.byId.get(h):void 0;if(!N)return h;for(let[S,R]of [["rPr",x],["pPr",p]]){let v=Ot(N,S);if(v)for(let A of v.children)A.kind!=="textValue"&&R.set(A.localName,A);}return h};s(e,r,i),s(n,a,o);let l=new Map;for(let[f,x]of r){let p=a.get(f);(!p||pe(p)!==pe(x))&&l.set(f,x);}let d=new Map;for(let[f,x]of i){if(f==="sectPr")continue;let p=o.get(f);(!p||pe(p)!==pe(x))&&d.set(f,x);}if(l.size===0&&d.size===0)return t;let c=0,u=()=>`fragment#materialized-${c++}`,m=f=>{let x=p=>p.kind==="textValue"?{id:u(),kind:"textValue",value:p.value}:{...p,id:u(),children:p.children.map(x)};return x(f)},y=(f,x,p)=>{if(p.length===0)return f;let h=Ot(f,x);if(h){let S=x==="rPr"?ii:ai,R=[...h.children];for(let A of p){let V=A.kind==="textValue"?Number.MAX_SAFE_INTEGER:S.get(A.localName)??Number.MAX_SAFE_INTEGER,Z=R.length;for(let D=0;D<R.length;D+=1){let B=R[D];if(B.kind==="textValue")continue;let $=S.get(B.localName);if($!==void 0&&$>V){Z=D;break}}R.splice(Z,0,A);}let v={...h,children:R};return {...f,children:f.children.map(A=>A===h?v:A)}}let N={id:u(),kind:x==="rPr"?"runProperties":"paragraphProperties",namespaceUri:ca$1,localName:x,prefix:"w",namespaceBindings:[],attributes:[],children:p};return {...f,children:[N,...f.children]}},g=f=>{let x=Ot(f,"pPr"),p=x?.children.find(v=>F(v,"pStyle")),h=p?ze(p,"val"):void 0,N=[];for(let[v,A]of d)x?.children.some(Z=>Z.kind!=="textValue"&&Z.localName===v)||h&&Zt(e,h,"pPr",v)||N.push(m(A));let S=v=>{if(v.kind==="textValue")return v;if(v.kind==="run"){let V=Ot(v,"rPr"),Z=V?.children.find($=>F($,"rStyle")),D=Z?ze(Z,"val"):void 0,B=[];for(let[$,G]of l)V?.children.some(M=>M.kind!=="textValue"&&M.localName===$)||D&&Zt(e,D,"rPr",$)||h&&Zt(e,h,"rPr",$)||B.push(m(G));return y(v,"rPr",B)}if(v.kind==="paragraphProperties"||v.kind==="runProperties")return v;let A=v.children.map(S);return A.some((V,Z)=>V!==v.children[Z])?{...v,children:A}:v};return S(y(f,"pPr",N))},P=f=>{if(f.kind==="textValue")return f;if(f.kind==="paragraph")return g(f);let x=f.children.map(P);return x.some((p,h)=>p!==f.children[h])?{...f,children:x}:f};return t.map(P)}function si(t,e){return {...t,children:e}}function li(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===ca$1}var di=new Set(["commentRangeStart","commentRangeEnd"]),ci=new Set(["altChunk","subDoc"]);function mi(t){return t.kind==="run"&&t.children.some(e=>e.kind==="commentReference")}var ui=new Set(["DDE","DDEAUTO","INCLUDE","INCLUDEPICTURE","INCLUDETEXT","IMPORT","LINK","DATABASE","AUTOTEXT","AUTOTEXTLIST","GOTOBUTTON","MACROBUTTON","PRINT","ADDIN"]);function oo(t){if(t===void 0)return false;let e=t.trim().replace(/^"+/,"").split(/\s+/,1)[0]??"";return ui.has(e.toUpperCase())}function pi(t){if(t.kind!=="run")return null;for(let e of t.children)if(e.kind==="fldChar"){let n=ze(e,"fldCharType");return n==="separate"||n==="end"?n:"begin"}return null}function fi(t){if(t.kind!=="run")return null;let e="",n=false;for(let r of t.children)if(r.kind==="instrText"){n=true;for(let a of r.children)a.kind==="textValue"&&(e+=a.value);}return n?e:null}function gi(t){let e=[],n=new Set,r=i=>{if(i.dangerous){for(let o of i.machinery)n.add(o);for(let o of i.instr)n.add(o);for(let o of i.preResult)n.add(o);}},a=i=>{if(i.kind!=="textValue"){if(i.kind==="run"){let o=pi(i);if(o==="begin"){e.push({dangerous:false,afterSeparate:false,machinery:[i.id],instr:[],preResult:[]});return}let s=e[e.length-1];if(s){if(o==="separate"){s.afterSeparate=true,s.machinery.push(i.id);return}if(o==="end"){s.machinery.push(i.id),e.pop(),r(s);return}let l=fi(i);if(l!==null){s.instr.push(i.id),oo(l)&&(s.dangerous=true);return}s.afterSeparate||s.preResult.push(i.id);return}return}for(let o of i.children)a(o);}};for(let i of t)a(i);for(;e.length>0;){let i=e.pop();i.dangerous=true,r(i);}return n}function hi(t,e){if(t.kind==="textValue")return t;if(t.namespaceUri===ca$1&&(di.has(t.localName)||t.localName==="sectPr"||ci.has(t.localName))||mi(t)||e.has(t.id))return "drop";if(li(t,"fldSimple")&&oo(ze(t,"instr")))return tn(t.children,e);let n=tn(t.children,e);return n.length===t.children.length&&n.every((r,a)=>r===t.children[a])?t:si(t,n)}function tn(t,e){let n=[];for(let r of t){let a=hi(r,e);a!=="drop"&&(Array.isArray(a)?n.push(...a):n.push(a));}return n}function nn(t){let e=gi(t);return tn(t,e)}var ao="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function q(t,e,n,r){return {...t,attributes:t.attributes.map(a=>a.localName===n&&a.namespaceUri===e?{...a,value:r}:a)}}var yi=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),rn=We$1,fe=new Map;function Le(t,e){let n=e.styleIds??fe,r=e.numIds??fe,a=e.relIds??fe,i=e.footnoteIds??fe,o=e.endnoteIds??fe,s=e.bookmarkIds??fe,l=e.sdtIds??fe,d=e.revisionIds??fe,c=e.docPrIds??fe,u=(m,y)=>{if(m.kind==="textValue")return m;let g=m;if(m.namespaceUri===ca$1&&yi.has(m.localName)){let p=ze(m,"val"),h=p!==void 0?n.get(p):void 0;h!==void 0&&(g=q(g,ca$1,"val",h));}if(F(m,"numId")){let p=ze(m,"val"),h=p!==void 0?r.get(p):void 0;h!==void 0&&(g=q(g,ca$1,"val",h));}if(m.kind==="noteReference"){let p=m.localName==="footnoteReference"?i:o,h=ze(m,"id"),N=h!==void 0?p.get(h):void 0;N!==void 0&&(g=q(g,ca$1,"id",N));}if(m.kind==="bookmarkStart"||m.kind==="bookmarkEnd"){let p=ze(m,"id"),h=p!==void 0?s.get(p):void 0;h!==void 0&&(g=q(g,ca$1,"id",h));}if(F(m,"id")&&y==="sdtPr"){let p=ze(m,"val"),h=p!==void 0?l.get(p):void 0;h!==void 0&&(g=q(g,ca$1,"val",h));}if(rn(m)){let p=ze(m,"id"),h=p!==void 0?d.get(p):void 0;h!==void 0&&(g=q(g,ca$1,"id",h));}if(m.kind==="drawingDocPr"){let p=m.attributes.find(N=>N.localName==="id"&&N.namespaceUri==="")?.value,h=p!==void 0?c.get(p):void 0;h!==void 0&&(g=q(g,"","id",h));}for(let p of g.attributes){if(p.namespaceUri!==ao)continue;let h=a.get(p.value);h!==void 0&&h!==p.value&&(g=q(g,ao,p.localName,h));}let P=m.localName,f=g.children.map(p=>u(p,P));return g!==m||f.some((p,h)=>p!==g.children[h])?{...g,children:f}:m};return u(t,"")}function io(t,e,n){let r=t,a=n.get(t)??2;for(;e.has(r);)r=`${t}${a}`,a+=1;return n.set(t,a),r}function so(t,e,n){let r=`${t} (pasted)`,a=n.get(t)??2;for(;e.has(r);)r=`${t} (pasted ${a})`,a+=1;return n.set(t,a),r}var ki=1e5;function lo(t){let e=Eb(),n=xi(t,e),r=Pi(t,e),a=Oi(t,e);return !n||!r||!a?null:{bookmarkIds:n,revisionIds:r,docPrIds:a}}function on(t,e,n,r){if(t)return Gb(e,t,r);let a=n;return ()=>String(a++)}function co(t,e){if(t.add(e),!/^\d{1,10}$/.test(e))return;let n=Number(e);n<=Cb&&t.add(String(n));}function mo(t,e){if(e===void 0)return t;let n=Number(e);return Number.isInteger(n)&&n>t?n:t}function xi(t,e){let n=new Map;if(t.fragmentBookmarkIds.length===0)return n;let r=0,a=new Set;for(let o of [t.ownerPart,...t.notesParts])ne([o.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=ze(s,"id");l!==void 0&&(co(a,l),s.kind==="bookmarkStart"&&(r=mo(r,l)));});let i=on(e,a,r+1,Cb);for(let o of t.fragmentBookmarkIds){if(n.has(o))continue;let s=i();if(s===null)return null;n.set(o,s);}return n}function Pi(t,e){let n=new Map;if(!t.hasRevision)return n;let r=0,a=new Set;for(let s of [t.ownerPart,...t.notesParts]){let l=s===t.ownerPart;ne([s.root],d=>{if(!We$1(d))return;let c=ze(d,"id");c!==void 0&&co(a,c),l&&(r=mo(r,c));});}let i=on(e,a,r+1,Cb),o=false;return ne(t.travelling,s=>{if(o||!We$1(s))return;let l=ze(s,"id");if(l===void 0||n.has(l))return;let d=i();d===null?o=true:n.set(l,d);}),o?null:n}function Oi(t,e){let n=new Map;if(!t.hasDocPr)return n;let{used:r}=Ib(t.pkg),a=ki;if(!e){let s=Jb(t.pkg);s.ok&&(a=s.id);}let i=on(e,r,a,Hb),o=false;return ne(t.travelling,s=>{if(o||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(c=>c.localName==="id"&&c.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let d=i();d===null?o=true:n.set(l,d);}),o?null:n}var be="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ii=`${be}/hyperlink`,uo=`${be}/image`,Rt=`${be}/numbering`,an=`${be}/styles`,po="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",fo="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function tt(t,e,n,r){for(let a of Zb(t,e)){if(a.type!==n||a.targetMode==="External")continue;let i=w(a.ownerPart,a.rawTarget);if(i.ok){let o=t.parts.get(i.partName);if(o)return o}}return t.parts.get(r)??null}function sn(t,e){let n=0;return ne([t],r=>{let a=e(r);if(a===void 0)return;let i=Number(a);Number.isInteger(i)&&i>n&&(n=i);}),n}function bt(t,e,n,r){if(n.length===0)return t;let a=Aa$1(e,"paste"),i=n.map(d=>De(d,a)),o=ch(e,i),s=r??o.root.children.length,l=Ga$1(o,o.root.id,s,i,{deferValidation:true});return l.ok?Xb(t,l.part):null}function go(t){let e=new Set;return ne(t,n=>{if(n.kind!=="textValue")for(let r of n.attributes)r.namespaceUri===be&&r.value.length>0&&e.add(r.value);}),e}function ho(t,e){if(e.size===0)return [...t];let n=a=>{if(a.kind==="textValue")return a;if(a.kind==="drawing"){let o=false;return ne([a],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===be&&e.has(l.value)&&(o=true);}),o?null:a}if(a.kind==="hyperlink"){let o=a.attributes.find(s=>s.namespaceUri===be)?.value;if(o!==void 0&&e.has(o))return r(a.children)}let i=r(a.children);return i.length===a.children.length&&i.every((o,s)=>o===a.children[s])?a:{...a,children:i}};function r(a){let i=[];for(let o of a){let s=n(o);s!==null&&(Array.isArray(s)?i.push(...s):i.push(s));}return i}return r(t)}var Ri=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),yo={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function bi(t,e){let n=lb(t);return n==="unknown"||(Object.hasOwn(yo,e)?yo[e]:e)!==n||Ri.has(n)&&!Kb(t,n)?null:n}function ko(t,e,n){let r=e.parts.get(e.mainDocumentPart);if(!r)return {ok:false,reason:"no-fragment-document"};if(!t.parts.has(n))return {ok:false,reason:"no-target-part"};let a$1=r.root.kind==="document"?r.root.children.find(k=>k.kind==="body"):null;if(!a$1||!J(a$1))return {ok:false,reason:"no-fragment-document"};let i=nn(a$1.children.filter(k=>k.kind==="paragraph"||k.kind==="table"||k.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let o=t,s=tt(e,e.mainDocumentPart,Rt,"/word/numbering.xml"),l=new Map,d=[],c=[];if(s&&J(s.root)){let k=new Map,O=[];for(let C of s.root.children)if(J(C))if(F(C,"abstractNum")){let U=ze(C,"abstractNumId");U&&k.set(U,C);}else F(C,"num")&&O.push(C);let I=tt(o,o.mainDocumentPart,Rt,"/word/numbering.xml"),b=new Map,E=new Map;if(I&&J(I.root)){for(let C of I.root.children)if(J(C)&&F(C,"abstractNum")){let U=ze(C,"abstractNumId");U&&E.set(U,C);}for(let C of I.root.children){if(!J(C)||!F(C,"num"))continue;let U=ze(C,"numId");if(!U)continue;let X=C.children.find(H=>F(H,"abstractNumId")),z=X?ze(X,"val"):void 0,re=z?E.get(z):void 0;b.set(`${re?et(re):"none"}::${C.children.filter(H=>F(H,"lvlOverride")).map(pe).join("")}`,U);}}let _=(I?sn(I.root,C=>C.kind!=="textValue"&&F(C,"abstractNum")?ze(C,"abstractNumId"):void 0):0)+1,W=(I?sn(I.root,C=>C.kind!=="textValue"&&F(C,"num")?ze(C,"numId"):void 0):0)+1,le=new Map;for(let C of O){let U=ze(C,"numId");if(!U)continue;let X=C.children.find(he=>F(he,"abstractNumId")),z=X?ze(X,"val"):void 0,re=z?k.get(z):void 0,H=`${re?et(re):"none"}::${C.children.filter(he=>F(he,"lvlOverride")).map(pe).join("")}`,K=b.get(H);if(K!==void 0){l.set(U,K);continue}let ee=z?le.get(z):void 0;ee===void 0&&re&&z&&(ee=String(_++),le.set(z,ee),c.push(q(re,ca$1,"abstractNumId",ee)));let Se=String(W++);l.set(U,Se);let xe=q(C,ca$1,"numId",Se);if(ee!==void 0){let he=xe.children.map(Te=>F(Te,"abstractNumId")?q(Te,ca$1,"val",ee):Te);xe={...xe,children:he};}d.push(xe),b.set(H,Se);}}let u=It(tt(e,e.mainDocumentPart,an,"/word/styles.xml")),m=tt(o,o.mainDocumentPart,an,"/word/styles.xml"),y=It(m),g=new Map,P=[],f=new Set(y.byId.keys()),x=new Set(y.names),p=new Map,h=new Map,N=new Map,S=(k,O)=>{let I=N.get(k);return I===void 0&&(I=et(O),N.set(k,I)),I},R=k=>({...k,attributes:k.attributes.filter(O=>!(O.localName==="default"&&O.namespaceUri===ca$1))});for(let k of u.styles){let O=ze(k,"styleId");if(!O)continue;let I=y.byId.get(O),b=et(Le(k,{styleIds:g,numIds:l}));if(I&&S(O,I)===b){g.set(O,O);continue}if(!I){g.set(O,O),f.add(O),P.push(R(k));continue}let E=io(`${O}Pasted`,f,p);f.add(E),g.set(O,E),P.push(R(q(k,ca$1,"styleId",E)));}let v=P.map(k=>{let O=k.children.find(_=>F(_,"name")),I=O?ze(O,"val"):void 0;if(!I||!x.has(I))return I&&x.add(I),k;let b=so(I,x,h);x.add(b);let E=k.children.map(_=>F(_,"name")?q(_,ca$1,"val",b):_);return {...k,children:E}}),A=null,V=1,Z=()=>{if(A)return A;let k=new Map;for(let[O,I]of o.partBytes){let b=O.startsWith("/")?O:`/${O}`;if(!b.startsWith("/word/media/"))continue;k.set(a(I),b);let E=/\/image(\d+)\./.exec(b);E&&(V=Math.max(V,Number(E[1])+1));}return A=k,k},D=new Map,B=k=>{let O=D.get(k);if(!O){O=new Map;for(let I of Zb(o,k)){if(I.targetMode==="External"||I.type!==uo)continue;let b=w(I.ownerPart,I.rawTarget);b.ok&&O.set(b.partName,I.id);}D.set(k,O);}return O},$=(k,O)=>{let I=k.lastIndexOf("."),b=I===-1?"":k.slice(I+1);return /^[A-Za-z0-9]{1,8}$/.test(b)?b.toLowerCase():O==="image/jpeg"?"jpeg":O==="image/gif"?"gif":"png"},G=(k,O,I)=>{let b=new Map,E=new Set,_=B(O),W=[],le=new Set,C=[],U=[],X=new Map,z=[],re=e.relationships.get(k)??[];for(let H of re){if(!I.has(H.id))continue;if(H.targetMode==="External"){if(H.type===Ii){let we=Ed(o,H.rawTarget,O);we?(o=we.pkg,b.set(H.id,we.relationshipId)):E.add(H.id);}else E.add(H.id);continue}let K=w(H.ownerPart,H.rawTarget);if(!K.ok){E.add(H.id);continue}let ee=e.partBytes.get(K.partName)??e.partBytes.get(K.partName.replace(/^\//,"")),Se=(_b(e,K.partName)??"").toLowerCase();if(!ee||!Se.startsWith("image/")){E.add(H.id);continue}let xe=bi(ee,Se);if(xe===null){E.add(H.id);continue}let he=xe,Te=Z(),jn=a(ee),oe=Te.get(jn);if(!oe){let we=$(K.partName,he),ri=ct=>o.partBytes.has(ct)||o.partBytes.has(ct.slice(1))||o.parts.has(ct)||le.has(ct),_t=`/word/media/image${V}.${we}`;for(;ri(_t);)V+=1,_t=`/word/media/image${V}.${we}`;V+=1,oe=_t,W.push({partName:oe,bytes:ee,contentType:he}),le.add(oe),Te.set(jn,oe);}let ni=oe.startsWith("/word/")?oe.slice(6):oe,Vn=_.get(oe);if(Vn!==void 0){b.set(H.id,Vn);continue}let dt=X.get(oe);dt===void 0&&(dt=C.length,X.set(oe,dt),C.push(ni),U.push(oe)),z.push({recordId:H.id,index:dt});}if(W.length>0&&(o=Ob(o,W)),C.length>0){let H=bc(cc(o,O),O,C.map(K=>[uo,K]));if(H.ok){o=H.pkg,H.ids.forEach((K,ee)=>{_.set(U[ee],K);});for(let K of z)b.set(K.recordId,H.ids[K.index]);}else for(let K of z)E.add(K.recordId);}return {relIdMap:b,dropRelIds:E}},ae=G(e.mainDocumentPart,n,go(i));i=ho(i,ae.dropRelIds);let M=new Map,st=new Map,Q=[];for(let k of ["footnote","endnote"]){let O=k==="footnote"?"footnoteReference":"endnoteReference",I=k==="footnote"?M:st,b=new Set;if(ne(i,U=>{if(U.kind!=="textValue"&&U.kind==="noteReference"&&U.localName===O){let X=ze(U,"id");X!==void 0&&b.add(X);}}),b.size===0)continue;let E=Pe(e,k);if(!E||!J(E.root))continue;let _=df(o,k);if(!_.ok||!_.package)return {ok:false,reason:"merge-refused"};o=_.package;let W=Pe(o,k);if(!W)return {ok:false,reason:"merge-refused"};let le=sn(W.root,U=>U.kind!=="textValue"&&U.kind==="note"?ze(U,"id"):void 0)+1,C=[];for(let U of E.root.children){if(!J(U)||U.kind!=="note")continue;let X=ze(U,"id"),z=ze(U,"type");if(z==="separator"||z==="continuationSeparator"||X===void 0||!b.has(X))continue;let re=String(le++);I.set(X,re),C.push(q(U,ca$1,"id",re));}C.length>0&&Q.push({kind:k,fragmentPartName:E.name,bodies:nn(C)});}let Ne=o.parts.get(n),_n=[...i,...Q.flatMap(k=>k.bodies)],Un=[],At=new Set,Ln=false,Fn=false,Ke=new Map;ne(_n,k=>{if(k.kind!=="textValue"){if(k.kind==="bookmarkStart"||k.kind==="bookmarkEnd"){let O=ze(k,"id");if(O!==void 0&&Un.push(O),k.kind==="bookmarkStart"){let I=ze(k,"name");I&&At.add(I);}return}if(rn(k)){Ln=true;return}if(k.kind==="drawingDocPr"){Fn=true;return}if(k.kind==="contentControlProperties")for(let O of k.children){if(!F(O,"id"))continue;let I=ze(O,"val");if(I!==void 0&&!Ke.has(I)){let b=0,E=`${I}:${Ke.size}`;for(let _=0;_<E.length;_+=1)b=b*31+E.charCodeAt(_)>>>0;Ke.set(I,String(b%2147483647||1));}}}});let lt=lo({pkg:o,ownerPart:Ne,notesParts:Q.map(k=>Pe(o,k.kind)).filter(k=>k!==null),travelling:_n,fragmentBookmarkIds:Un,hasRevision:Ln,hasDocPr:Fn});if(!lt)return {ok:false,reason:"merge-refused"};let $n=lt.bookmarkIds,Hn=lt.revisionIds,Bn=lt.docPrIds;if(At.size>0){let k=new Set;if(ne([Ne.root],O=>{if(O.kind!=="textValue"&&O.kind==="bookmarkStart"){let I=ze(O,"name"),b=ze(O,"id");I&&b!==void 0&&At.has(I)&&k.add(b);}}),k.size>0){let O=b=>{if(b.kind==="textValue")return b;let E=[],_=false;for(let W of b.children){if((W.kind==="bookmarkStart"||W.kind==="bookmarkEnd")&&k.has(ze(W,"id")??"")){_=true;continue}let le=O(W);le!==W&&(_=true),E.push(le);}return _?{...b,children:E}:b},I=O(Ne.root);I!==Ne.root&&(Ea$1(Ne.root,I),o=Xb(o,{...Ne,root:I}));}}for(let k of Q){let O=Pe(o,k.kind);if(!O)return {ok:false,reason:"merge-refused"};let I=G(k.fragmentPartName,O.name,go(k.bodies)),b=ho(k.bodies,I.dropRelIds);b=[...en(b,u,y)],b=b.map(_=>Le(_,{styleIds:g,numIds:l,relIds:I.relIdMap,footnoteIds:M,endnoteIds:st,bookmarkIds:$n,sdtIds:Ke,revisionIds:Hn,docPrIds:Bn}));let E=bt(o,o.parts.get(O.name),b);if(!E)return {ok:false,reason:"merge-refused"};o=E;}if(v.length>0){let k=v.map(I=>Le(I,{styleIds:g,numIds:l}));if(!m){let I=ta$1(`<w:styles xmlns:w="${ca$1}"></w:styles>`,{name:"/word/styles.xml",contentType:fo});if(!I.ok)return {ok:false,reason:"merge-refused"};o=ec(o,"/word/styles.xml",I.part.root,fo);let b=dc(cc(o,o.mainDocumentPart),o.mainDocumentPart,an,"styles.xml");if(!b.ok)return {ok:false,reason:"merge-refused"};o=b.pkg,m=o.parts.get("/word/styles.xml")??null;}if(!m)return {ok:false,reason:"merge-refused"};let O=bt(o,o.parts.get(m.name),k);if(!O)return {ok:false,reason:"merge-refused"};o=O,y=It(o.parts.get(m.name)??null);}if(c.length>0||d.length>0){let k=tt(o,o.mainDocumentPart,Rt,"/word/numbering.xml");if(!k){let _=ta$1(`<w:numbering xmlns:w="${ca$1}"></w:numbering>`,{name:"/word/numbering.xml",contentType:po});if(!_.ok)return {ok:false,reason:"merge-refused"};o=ec(o,"/word/numbering.xml",_.part.root,po);let W=dc(cc(o,o.mainDocumentPart),o.mainDocumentPart,Rt,"numbering.xml");if(!W.ok)return {ok:false,reason:"merge-refused"};o=W.pkg,k=o.parts.get("/word/numbering.xml")??null;}if(!k)return {ok:false,reason:"merge-refused"};let O=o.parts.get(k.name),I=O.root.children.findIndex(_=>F(_,"num")),b=c.map(_=>Le(_,{styleIds:g,numIds:l})),E=bt(o,O,b,I===-1?void 0:I);if(!E)return {ok:false,reason:"merge-refused"};if(o=E,E=bt(o,o.parts.get(k.name),d),!E)return {ok:false,reason:"merge-refused"};o=E;}let ti=[...en(i,u,y)].map(k=>Le(k,{styleIds:g,numIds:l,relIds:ae.relIdMap,footnoteIds:M,endnoteIds:st,bookmarkIds:$n,sdtIds:Ke,revisionIds:Hn,docPrIds:Bn}));return {ok:true,pkg:o,blocks:ti}}var vi=16*1024*1024;function Ni(t){let e=t.parts.get(t.mainDocumentPart);if(!e||e.root.kind!=="document")return false;let n=e.root.children.find(i=>i.kind==="body");if(!n||n.kind!=="body"||n.children.length>$g)return false;let r=0,a=(i,o,s)=>{if(o>s||(r+=1,r>bh))return false;if(i.kind==="textValue")return true;for(let l of i.children)if(!a(l,o+1,s))return false;return true};for(let i of n.children)if(!a(i,1,ah))return false;for(let[i,o]of t.parts)if(i!==t.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!a(o.root,1,ah*4))return false;return true}function xo(t,e,n){if(n.fragmentBytes.byteLength>vi)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=Vb(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let a=r.package;if(!Ni(a))return {ok:false,reason:"invalidArgs",detail:"fragment-over-budget"};let i=t.resolveStory(e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let{store:o,story:s}=i;if(o.compositionActive||t.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=t.currentPackage(),d=o.checkpoint(),c=o.historyDepth,u=0,m="";return xa$1(t,()=>{let y=o.transact(P=>{for(let h of n.priorOps??[])if(!P.apply(h))return;let f=null,x=P.applyPackage(h=>(f=ko(h,a,s.partName),f.ok?f.pkg:h)),p=f;if(!p||!p.ok){m=`fragment-merge:${p?p.reason:"no-merge"}`,P.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}x&&(u=p.blocks.length,P.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:p.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return m.length>0?{ok:false,reason:"invalidArgs",detail:m}:y.ok?y.change?{ok:true,change:t.promoteStoryTransactionToPackageUnit(l,o,d,c),blockCount:u}:{ok:true,change:null,blockCount:u}:{ok:false,reason:y.reason,...y.detail?{detail:y.detail}:{}}},y=>ya$1(y))}function Si(t){if(!(t===null||t.start!==t.end))return t}var Fe={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function Ti(t){return Object.freeze({parts:new Map([[t.name,t]]),partBytes:new Map,relationships:new Map,externalTargets:[],contentTypes:{defaults:new Map,overrides:new Map([[t.name.toLowerCase(),t.contentType]])},mainDocumentPart:t.name})}var $e=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];subscribers=new Set;historyLimit;settingsPartOverride;storyRef=null;composition=null;constructor(e,n,r={}){let a="root"in e,i=typeof n=="string"?n:void 0,o=typeof n=="object"&&n!==null?n:r;this.current=a?Ti(e):e,this.storyPartName=i??(a?e.name:e.mainDocumentPart),this.historyLimit=o.historyLimit??200,this.settingsPartOverride=o.settingsPart;}setStoryRef(e){this.storyRef=e;}get part(){let e=this.current.parts.get(this.storyPartName);if(!e)throw new Error(`story part missing: ${this.storyPartName}`);return e}get package(){return this.current}get revision(){return this.rev}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get historyDepth(){return this.undoStack.length}get compositionActive(){return this.composition!==null}graftPackage(e){this.current=e(this.current);}replacePart(e){let n=this.current.parts.get(e.name);e!==n&&(this.current=Xb(this.current,e),this.rev+=1);}checkpoint(){return {pkg:this.current,revision:this.rev,undoStack:this.undoStack.slice(),redoStack:this.redoStack.slice(),composition:this.composition?{entry:{...this.composition.entry},committed:this.composition.committed}:null}}restoreCheckpoint(e){this.current=e.pkg,this.rev=e.revision,this.undoStack.length=0,this.undoStack.push(...e.undoStack),this.redoStack.length=0,this.redoStack.push(...e.redoStack),this.composition=e.composition?{entry:{...e.composition.entry},committed:e.composition.committed}:null;}restoreHistoryStacks(e){this.undoStack.length=0,this.undoStack.push(...e.undoStack),this.redoStack.length=0,this.redoStack.push(...e.redoStack);}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}transact(e,n={}){return Db(n.actorId,()=>this.commitTransaction(e,n))}commitTransaction(e,n){let r=n.origin??b.mutationHuman,a=this.current,i=this.rev,o=this.current,s=null,l=0,d=new Set,c=new Set,u=new Set,m=new Set,y=new Set,g=[],P=n.minimumImpact??"text-local",f=null,x=false,p=null,h=null,N=new Map,S=(D,B)=>{let $=xg.get(D.op);if($===void 0)return N.clear(),null;let G=`${B.name}\0${$}`,ae=N.get(G);ae||(ae={id:null},N.set(G,ae));let M=ae;return ()=>M.id??=Ve$1(B)()},R=(D,B)=>{if(s)return false;let $=o.parts.get(D);if(!$)return s={reason:"unknown-part",detail:D},false;let G=Ag($,this.settingsPartOverride?.()??pe$1(o),B);if(G)return s={reason:G},false;let ae=S(B,$),M=Zg($,B,{deferValidation:true,...ae?{revisionIds:ae}:{}});if(!M.ok)return s={reason:M.reason,...M.detail?{detail:M.detail}:{}},false;if(o=Xb(o,M.part),M.part===$&&M.effect.dirty.length===0&&M.effect.created.length===0&&M.effect.deleted.length===0&&M.effect.split===void 0&&(M.effect.splits===void 0||M.effect.splits.length===0)&&M.effect.join===void 0&&M.effect.caret===void 0)return true;d.add(D),l+=1;for(let Q of M.effect.dirty)c.add(Q);for(let Q of M.effect.created)u.add(Q);for(let Q of M.effect.deleted)m.add(Q);for(let Q of M.effect.dependencyKeys)y.add(Q);M.effect.split&&g.push({split:M.effect.split});for(let Q of M.effect.splits??[])g.push({split:Q});return M.effect.join&&g.push({join:M.effect.join}),Fe[M.effect.impact]>Fe[P]&&(P=M.effect.impact),M.effect.caret&&(h={paragraphId:M.effect.caret.paragraphId,start:0,end:0}),true};if(e({apply:D=>R(this.storyPartName,D),applyTo:(D,B)=>R(D,B),applyPackage:D=>{if(s)return false;N.clear();let B=D(o);if(B===o)return true;for(let[$,G]of B.parts)o.parts.get($)!==G&&d.add($);return o=B,l+=1,Fe["flow-structural"]>Fe[P]&&(P="flow-structural"),true},selectionBefore:D=>{f=D;},selectionAfter:D=>{x=true,p=D;}}),s){let D=s;return {ok:false,reason:D.reason,...D.detail?{detail:D.detail}:{}}}if(l===0)return {ok:true,change:null};let v=x?p:h,A=x?Si(p):h??void 0;for(let D of d){let B=a.parts.get(D),$=o.parts.get(D);if($===void 0)continue;let G=B?ra$1(B,$):ra$1($,$);if(!G.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(G.issues)}}let V=fc(o);return V.ok?((n.recordsHistory??(r!==b.projection&&r!==b.awareness))&&(this.composition?(this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:v}}):(this.pushUndo({pkg:a,revision:i,selectionBefore:f,selectionAfter:v}),this.redoStack.length=0)),this.current=o,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&Fe[n.minimumImpact]>Fe[P]&&(P=n.minimumImpact),{ok:true,change:this.publish(r,i,{dirty:c,created:u,deleted:m,dependencyKeys:y,splitJoin:g,impact:P,caret:A},n.story??this.storyRef??void 0,n.actorId,n.operationId)}):{ok:false,reason:"package-invariant",detail:JSON.stringify(V.issues)}}beginComposition(e=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:e,selectionAfter:null},committed:false});}endComposition(){let e=this.composition;this.composition=null,!(!e||!e.committed)&&(this.pushUndo(e.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}undo(){let e=this.undoStack.pop();if(!e)return null;let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=e.pkg,this.rev+=1,this.publish(b.mutationUndo,n,null,this.storyRef??void 0)}redo(){let e=this.redoStack.pop();if(!e)return null;let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=e.pkg,this.rev+=1,this.publish(b.mutationRedo,n,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}pushUndo(e){this.undoStack.push(e),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(e,n,r,a,i,o){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:e,...i?{actorId:i}:{},...o?{operationId:o}:{},dirty:r?[...r.dirty]:[],created:r?[...r.created]:[],deleted:r?[...r.deleted]:[],splitJoin:r?r.splitJoin:[],dependencyKeys:r?[...r.dependencyKeys]:[],impact:r?r.impact:a?.kind==="headerFooter"?"global":"flow-structural",...r?.caret?{caret:r.caret}:{},...a?{story:a}:{}};for(let l of this.subscribers)l(s);return s}};function ln(t,e){return [...t.values()].map(n=>n.part).filter(n=>e.parts.has(n.name))}function Po(t,e){return ln(t,e).map(n=>n.name).sort().join(",")}function Oo(t,e,n){if(t.relationships!==e.relationships||t.contentTypes!==e.contentTypes||t.partBytes!==e.partBytes||t.externalTargets!==e.externalTargets||t.mainDocumentPart!==e.mainDocumentPart)return true;if(t.parts===e.parts)return false;if(t.parts.size!==e.parts.size)return true;for(let[r,a]of e.parts)if(r!==n&&t.parts.get(r)!==a)return true;return false}var Nt="http://schemas.openxmlformats.org/wordprocessingml/2006/main",wi="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function He(t,e){for(let n of t.children)if(n.kind!=="textValue"&&n.namespaceUri===Nt&&n.localName===e)return n;return null}function vt(t,e){return t.attributes.find(n=>n.namespaceUri===Nt&&n.localName===e)?.value}function Ei(t){let e=vt(t,"val");return e===void 0||e==="1"||e==="true"||e==="on"}function Ro(t,e){return t.kind==="textValue"?Object.freeze({...t,id:e()}):Object.freeze({...t,id:e(),children:t.children.map(n=>Ro(n,e))})}function Ci(t){let e=ta$1(`<w:styles xmlns:w="${Nt}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:t.name,contentType:wi});if(!e.ok)return null;let n=He(e.part.root,"style"),r=n?He(n,"pPr"):null;return r?Ro(r,Aa$1(t)):null}var Io=["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"];function Mi(t,e){let n=Io.indexOf(e),r=0;return t.forEach((a,i)=>{if(a.kind==="textValue")return;let o=Io.indexOf(a.localName);o!==-1&&o<=n&&(r=i+1);}),r}function bo(t,e){let n=wd(t);if(!n)return null;let r=null;for(let d of n.root.children)if(d.kind!=="textValue"&&d.namespaceUri===Nt&&d.localName==="style"&&vt(d,"type")==="paragraph"&&vt(d,"styleId")===e){r=d;break}if(!r)return null;let a=He(r,"name");if(a&&vt(a,"val")?.trim().toLowerCase()!=="list paragraph"&&e!=="ListParagraph")return null;let i=Ci(n);if(!i)return null;let o=He(i,"contextualSpacing");if(!o)return null;let s=He(r,"pPr"),l;if(s){let d=He(s,"contextualSpacing");if(d&&Ei(d))return t;l=d?Ha$1(n,d.id,o):Ga$1(n,s.id,Mi(s.children,"contextualSpacing"),[o]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));l=Ga$1(n,r.id,d===-1?r.children.length:d,[i]);}return l.ok?Object.freeze({...t,parts:new Map([...t.parts,[n.name,l.part]])}):null}var To="http://schemas.openxmlformats.org/package/2006/relationships",wo="application/vnd.openxmlformats-package.relationships+xml",_i="http://schemas.openxmlformats.org/package/2006/content-types",vo="/[Content_Types].xml",Be="/word/numbering.xml",No="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",nt="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Ui=`<Override PartName="${Be}" ContentType="${nt}"/>`;function St(t){return `${t.ownerPart}\0${t.id}`}function Eo(t,e,n){let r=new Set(e.externalTargets.filter(s=>s.type===Pa$1).map(St)),a=n.externalTargets.filter(s=>s.type===Pa$1&&!r.has(St(s)));if(a.length===0)return t;let i=new Set(t.map(St)),o=a.filter(s=>!i.has(St(s)));return o.length===0?t:Object.freeze([...t,...o])}function Co(t,e,n){let r=t.filter(a=>a.ownerPart===n||e.has(a.ownerPart));return r.length===t.length?t:Object.freeze(r)}function Mo(t,e,n=[]){if(t===e)return t;let r=Li(t,e);return r=Fi(r,e,n),r}function Do(t,e){let n=new Set;for(let a of t.externalTargets)a.type===Pa$1&&a.ownerPart!==t.mainDocumentPart&&(t.parts.has(a.ownerPart)||e.has(a.ownerPart)||n.add(a.ownerPart));for(let a of t.parts.keys()){let i=ji(a);!i||i===t.mainDocumentPart||t.parts.has(i)||e.has(i)||t.externalTargets.some(o=>o.ownerPart===i)||n.add(i);}if(n.size===0)return t;let r=t;for(let a of n)r=Vi(r,a);return r}function Li(t,e){let n=e.parts.get(Be);if(!n)return t;let r=Xb(t,n),a=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.type===No),i=r.relationships.get(r.mainDocumentPart)??[];if(a&&!i.some(o=>o.type===No)&&!i.some(o=>o.id===a.id)){let o=Hi(r,{...a,ownerPart:r.mainDocumentPart});o&&(r=o);}if(r.contentTypes.overrides.get(u(Be))!==nt){let o=Wi(r);o&&(r=o);}return r}function Fi(t,e,n){let r=n.filter(i=>i.type===Pa$1);if(r.length===0)return t;let a=t;for(let i of r){let o=$i(t,e,i.ownerPart);if(!o||a.externalTargets.some(d=>d.ownerPart===o&&d.id===i.id)||new Set((a.relationships.get(o)??[]).map(d=>d.id)).has(i.id))continue;let l=Bi(a,{ownerPart:o,id:i.id,type:Pa$1,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},o);l&&(a=l);}return a}function $i(t,e,n){return n===e.mainDocumentPart?t.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function Hi(t,e){let n=t.mainDocumentPart,r=dn(n),a=t.parts.get(r),i=ta$1(`<Relationships xmlns="${To}"><Relationship Id="${P(e.id,"relationship id")}" Type="${P(e.type,"relationship type")}" Target="${P(e.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:wo});if(!i.ok)return null;let o=t.relationships.get(n)??[];if(o.some(d=>d.id===e.id))return null;let s={...e,ownerPart:n,order:o.reduce((d,c)=>Math.max(d,c.order),-1)+1},l=new Map([...t.relationships,[n,[...o,s]]]);return a?Ao(t,a,i.part.root.children[0],l):Object.freeze({...t,parts:new Map([...t.parts,[r,i.part]]),relationships:l})}function Bi(t,e,n=t.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let a=dn(r),i=t.parts.get(a),o=ta$1(`<Relationships xmlns="${To}"><Relationship Id="${P(e.id,"relationship id")}" Type="${Pa$1}" Target="${P(e.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:a,contentType:wo});if(!o.ok)return null;let s=[...t.externalTargets,e];if(!i)return Object.freeze({...t,parts:new Map([...t.parts,[a,o.part]]),externalTargets:s});let l=Ao(t,i,o.part.root.children[0],t.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Ao(t,e,n,r){if(!n)return null;let a=Aa$1(e),i=Ga$1(e,e.root.id,e.root.children.length,[_o(n,a)]);return i.ok?Object.freeze({...t,parts:new Map([...t.parts,[e.name,i.part]]),relationships:r}):null}function _o(t,e){return t.kind==="textValue"?{...t,id:e()}:{...t,id:e(),children:t.children.map(n=>_o(n,e))}}function dn(t){let e=t.lastIndexOf("/");return `${t.slice(0,e)}/_rels/${t.slice(e+1)}.rels`}function ji(t){let e=/^(.*)\/_rels\/([^/]+)\.rels$/.exec(t);if(!e)return null;let n=e[1],r=e[2];return n===""||r===""?null:`${n}/${r}`}function Vi(t,e){let n=dn(e),r=new Map(t.parts);r.delete(n);let a=new Map(t.partBytes);a.delete(n);let i=new Map(t.relationships);i.delete(e);let o=Object.freeze(t.externalTargets.filter(s=>s.ownerPart!==e));return Object.freeze({...t,parts:r,partBytes:a,relationships:i,externalTargets:o})}function Wi(t){let e=t.contentTypes.overrides.get(u(Be));if(e===nt)return t;if(e!==void 0)return null;let n=t.partBytes.get(vo);if(!n)return null;let r=strFromU8(n),a=So(r);if(!a)return null;let i=r.lastIndexOf(`</${a.rootName}>`);if(i===-1)return null;let o=r.slice(0,i)+Ui+r.slice(i),s=So(o);if(!s||s.rootName!==a.rootName)return null;let l=[...a.children,Uo("Override",{PartName:Be,ContentType:nt})];return s.children.length!==l.length||s.children.some((d,c)=>d!==l[c])?null:Object.freeze({...t,partBytes:new Map([...t.partBytes,[vo,strToU8(o)]]),contentTypes:Object.freeze({defaults:t.contentTypes.defaults,overrides:new Map([...t.contentTypes.overrides,[u(Be),nt]])})})}function So(t){let e=W(t);if(!e.ok)return null;let n=e.nodes.filter(s=>s.type==="element");if(n.length!==1)return null;let r=n[0],a=r.name.indexOf(":"),i=a===-1?"":r.name.slice(0,a);if(r.name.slice(a+1)!=="Types"||r.attributes[i?`xmlns:${i}`:"xmlns"]!==_i)return null;let o=[];for(let s of r.children)s.type==="element"&&o.push(Uo(s.name,s.attributes));return {rootName:r.name,children:o}}function Uo(t,e){let n=Object.entries(e).map(([r,a])=>`${r}=${a}`).sort();return [t,...n].join("")}var Lo=4e3,Fo=64;function $o(t){return Pe(t,"footnote")!==null||Pe(t,"endnote")!==null}function Ho(t,e,n,r){if(!$o(t))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let a=Ca$1(e,n.paragraphId);return !a||a.kind!=="paragraph"?true:He$1(a).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function Bo(t,e,n,r){if(!$o(t))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let a=Ca$1(e,n.blockId);if(!a||a.kind==="textValue")return true;let i=0,o=(s,l)=>{if(i>=Lo||l>Fo)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return He$1(s).some(d=>d.node.kind==="noteReference");for(let d of s.children)if(o(d,l+1))return true;return false};return o(a,0)}function jo(t,e,n){if(n.count>=Lo||e>Fo)return true;if(n.count+=1,t.kind==="textValue")return false;if(t.kind==="commentRangeStart"||t.kind==="commentRangeEnd"||t.kind==="commentReference")return true;for(let r of t.children)if(jo(r,e+1,n))return true;return false}function Vo(t,e,n,r){if(!Rf(t))return false;let a=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(a))return true;r.add(a);let i=Ca$1(e,a);return !i||i.kind==="textValue"?true:jo(i,0,{count:0})}var cn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",mn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function Wo(t,e){let r=(t.relationships.get(t.mainDocumentPart)??[]).find(a=>a.id===e);return r?r.type!==cn&&r.type!==mn?{ok:false,reason:"wrong-relationship-type",detail:r.type}:Ki(t,r):{ok:false,reason:"dangling-relationship",detail:e}}function Ki(t,e){let n=E(e);if(n.mode==="External")return {ok:false,reason:"external-relationship",detail:e.id};if(!n.target.ok)return {ok:false,reason:"bad-relationship-target",detail:n.target.reason};let r=t.parts.get(n.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:n.target.partName};let a=r.root.localName;return a!=="hdr"&&a!=="ftr"?{ok:false,reason:"not-a-story-part",detail:a||r.name}:{ok:true,partName:r.name,part:r}}function ve(t,e){return e.compositionActive||t.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function Ko(t,e){let n=Ca$1(t,e);return !n||n.kind!=="drawing"?null:n.children.find(a=>a.kind==="inlineDrawing"||a.kind==="anchoredDrawing")??null}function zo(t,e,n){let r=t.parts.get(e);if(!r)return null;let a=Ca$1(r,n);return !a||a.kind!=="drawing"?null:db(a,{ownerPartName:e,supportedMcRequires:_a$1,limits:Za$1,resolveRelationship:ab(t,e)})}function Go(t,e,n){let r=F$1(t.relationships.get(e)??[],e,n);return r.mode==="internal"?r.partName:null}function je(t,e,n,r){let a=t.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let i=ve(t,a.store);if(i)return i;let{store:o,story:s}=a;return xa$1(t,()=>zi(t,o,s,n,r),l=>ya$1(l))}function zi(t,e,n,r,a){let i=n.partName,o=t.currentPackage(),s=e.checkpoint(),l=e.historyDepth,d=null,c=false,u=false,m=e.transact(P=>{if(a?.commitGuard?.()===false){u=true;return}if(a?.expectedPackageRevision!==void 0&&t.packageRevision!==a.expectedPackageRevision){c=true;return}let f=r(P,i);if(f===null){P.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}d=f;},{story:n,...a?.actorId?{actorId:a.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(u)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(c)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!m.ok)return {ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}};if(!m.change)return {ok:true,change:null};let y=m.change.created.find(P=>{let f=e.part;return Ca$1(f,P)?.kind==="drawing"});return y&&(d=y),{ok:true,change:t.promoteStoryTransactionToPackageUnit(o,e,s,l),...d?{drawingNodeId:d}:{}}}function Xo(t,e,n){let r=t.parts.get(e);if(!r)return null;let a=Ko(r,n);return a?Ug(a):null}function un(t,e,n,r){let a=false;return t.applyPackage(i=>{let o=i.parts.get(e);if(!o)return i;let s=Ca$1(o,n);if(!s||s.kind!=="drawing")return i;let l=Ko(o,n);if(!l)return i;let d=Vg(l,r),c=Gi(s,d),u=Ha$1(o,s.id,c,{deferValidation:true});return u.ok?(a=true,Xb(i,u.part)):i}),a}function Gi(t,e){return {...t,children:t.children.map(n=>n.id===e.id?e:n)}}async function Yo(t,e,n){let r=Pb(n.widthPoints),a=Pb(n.heightPoints);if(r===null||a===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=t.resolveStory(e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let o=ve(t,i.store);if(o)return o;let s=i.story.partName,l=await Lb(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=l.bytes,c=Nb(t.currentPackage(),s,{bytes:d,mime:n.mime});if(!c.ok)return {ok:false,reason:"invalidArgs",detail:c.reason==="invalid-image"?"invalid-image":c.reason};let u=c.partName,m=je(t,e,(y,g)=>{let P=t.currentPackage(),f=Nb(P,g,{bytes:d,mime:n.mime});if(!f.ok)return null;P=f.pkg,u=f.partName;let x;if(n.hyperlink){let h=Ed(P,n.hyperlink,g);if(!h)return null;P=h.pkg,x=h.relationshipId;}if(!y.applyPackage(()=>P))return null;let p=Qb({docPrId:f.docPrId,relationshipId:f.relationshipId,extentEmu:{cx:r,cy:a},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...x?{hyperlinkRelationshipId:x}:{}});return y.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:p,...n.revision?{revision:n.revision}:{}})?p.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return m.ok?m.change?{...m,mediaPartName:u}:{ok:true,change:null,mediaPartName:u}:m}async function pn(t,e,n,r,a,i,o){let s=t.resolveStory(e);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=ve(t,s.store);if(l)return l;let d=s.story.partName,c=await Lb(i,r,a);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=c.bytes,m=Nb(t.currentPackage(),d,{bytes:u,mime:a});return m.ok?je(t,e,(y,g)=>{let P=t.currentPackage(),f=zo(P,d,n),x=f?.picture?.embeddedRelationshipId??null,p=f?.picture?.linkedRelationshipId??null,h=x??p;if(!h)return null;let N=x!==null?Go(P,d,x):null,S=P,R=Nb(S,g,{bytes:u,mime:a});return !R.ok||(S=R.pkg,!y.applyPackage(()=>S))||!y.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:R.relationshipId})?null:(y.applyPackage(v=>Sb(v,g,N,h)),n)},{expectedPackageRevision:o.expectedPackageRevision,...o.commitGuard?{commitGuard:o.commitGuard}:{},...o.actorId?{actorId:o.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:m.reason==="invalid-image"?"invalid-image":m.reason}}function Jo(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let a=ve(t,r.store);if(a)return a;let i=r.story.partName,o=t.currentPackage(),s=zo(o,i,n);if(!s)return {ok:false,reason:"unknown-drawing"};let l=s.picture?.embeddedRelationshipId??null,d=s.picture?.linkedRelationshipId??null,c=l??d,u=l!==null?Go(o,i,l):null;return je(t,e,(m,y)=>m.apply({op:"deleteDrawing",drawingNodeId:n})?(m.applyPackage(g=>Sb(g,y,u,c)),n):null)}function Xi(t,e){let n=null,r=i=>{let o=false,s=false,l=(d,c)=>{if(o||d.kind==="textValue")return;if(d.id===e){o=true,s=c;return}let u=c||d.kind==="revisionDelete"||d.kind==="revisionMoveFrom";for(let m of d.children)l(m,u);};return l(i,false),s},a=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let o=Ie(i).spanOf(e);if(o!==null&&o.end>o.start){let s=Ca$1(t,e);if(!s||s.kind!=="drawing"&&!bb(s))return;n={paragraphId:i.id,start:o.start,end:o.end,alreadyDeleted:r(i)};}return}for(let o of i.children)a(o);}};return a(t.root),n}function qo(t,e,n,r){let a=t.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let i=ve(t,a.store);if(i)return i;let o=t.currentPackage().parts.get(a.story.partName);if(!o)return {ok:false,reason:"unknown-drawing"};let s=Xi(o,n);return s?s.alreadyDeleted?{ok:true,change:null}:je(t,e,l=>l.apply({op:"deleteText",paragraphId:s.paragraphId,start:s.start,end:s.end,revision:r})?n:null):{ok:false,reason:"unknown-drawing"}}async function Qo(t,e,n,r,a,i,o,s){let l=await Tb(a,r,i,void 0,o);return l.ok?pn(t,e,n,l.bytes,l.mime,o,{expectedPackageRevision:t.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function Zo(t,e,n,r,a,i){let o=t.resolveStory(e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let s=ve(t,o.store);return s||je(t,e,(l,d)=>{let c=Xo(t.currentPackage(),d,n),u=null;if(i!==null){let y=Ed(t.currentPackage(),i,d);if(!y||!l.applyPackage(()=>y.pkg))return null;u=y.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:a,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!un(l,d,n,u))return null}else if(i===null&&!un(l,d,n,null))return null;let m=false;return l.applyPackage(y=>{let g=Gd(y,d,c);return g===null?(m=true,y):g}),m?null:n})}function ea(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let a=ve(t,r.store);return a||je(t,e,(i,o)=>{let s=Xo(t.currentPackage(),o,n.drawingNodeId),l=null;if(n.hyperlink!==null){let c=Ed(t.currentPackage(),n.hyperlink,o);if(!c||!i.applyPackage(()=>c.pkg))return null;l=c.relationshipId;}for(let c of n.ops)if(!i.apply(c))return null;if(!un(i,o,n.drawingNodeId,n.hyperlink===null?null:l))return null;let d=false;return i.applyPackage(c=>{let u=Gd(c,o,s);return u===null?(d=true,c):u}),d?null:n.drawingNodeId})}function Yi(t,e){if(t===e)return true;if(t.byteLength!==e.byteLength)return false;for(let n=0;n<t.byteLength;n+=1)if(t[n]!==e[n])return false;return true}function ta(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t)if(e.get(n)!==r)return false;return true}function Ji(t,e){return t===e||t.ownerPart===e.ownerPart&&t.id===e.id&&t.type===e.type&&t.rawTarget===e.rawTarget&&t.targetMode===e.targetMode&&t.order===e.order}function qi(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let a=e.get(n);if(!a||a.length!==r.length||a!==r&&r.some((i,o)=>!Ji(i,a[o])))return false}return true}function Qi(t,e){return t===e?true:t.length!==e.length?false:t.every((n,r)=>{let a=e[r];return n===a||n.ownerPart===a.ownerPart&&n.id===a.id&&n.type===a.type&&n.rawTarget===a.rawTarget&&n.sinkSafe===a.sinkSafe})}function Zi(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let a=e.get(n);if(!a||!Yi(r,a))return false}return true}function es(t,e){return t.contentTypes===e.contentTypes||ta(t.contentTypes.defaults,e.contentTypes.defaults)&&ta(t.contentTypes.overrides,e.contentTypes.overrides)}var Tt=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),wt=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function na(t){for(let[e,n]of t)if(!oa$1(e,n))return wt;return Tt}function ts(t,e){if(t===e)return Tt;if(t.mainDocumentPart!==e.mainDocumentPart||t.parts.size!==e.parts.size||!Zi(t.partBytes,e.partBytes)||!qi(t.relationships,e.relationships)||!Qi(t.externalTargets,e.externalTargets)||!es(t,e))return wt;let n=[];for(let[o,s]of t.parts){let l=e.parts.get(o);if(!l)return wt;s!==l&&n.push([s,l]);}if(n.length===0)return Tt;let[r,a]=n[0];if(n.length>1||r.name!==t.mainDocumentPart)return na(n);let i=pa$1(a.root,r.root);return i.undecided?na(n):i.equal?Tt:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?wt:{equal:false,dirty:i.paragraphIds,dependencyKeys:[g.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function fn(t){return {ok:false,reason:"package-invariant",detail:t}}function ns(t,e){if(!t.parts.get(t.mainDocumentPart))return fn("no-main-document");for(let[r,a]of t.parts){let i=e?.parts.get(r);if(i===a)continue;let o=i?ra$1(i,a):qa$1(a);if(!o.ok)return fn(`invalid-part:${r}:${o.issues[0]?.code??"invalid"}`)}let n=fc(t);return n.ok?null:fn(n.issues[0]?.code??"package-invariant")}function ra(t,e,n){let r=t.currentPackage(),a=ts(e,r);if(a.equal)return {ok:true,change:null};let i=ns(e,r);if(i)return i;let o=t.bodyStore().part.name,s=a.impact!=="global"&&e.mainDocumentPart===o;return xa$1(t,()=>{let l=t.packageRevision;return t.installAuthoritativePackageSnapshot(e),{ok:true,change:t.publishStoryWrite({change:"model-change",fromRevision:l,toRevision:l+1,commitId:`pkg-remote-${l+1}`,origin:n.origin,...n.actorId?{actorId:n.actorId}:{},...n.operationId?{operationId:n.operationId}:{},dirty:s?a.dirty:[],created:[],deleted:[],splitJoin:[],dependencyKeys:s?a.dependencyKeys:[],impact:s?a.impact:"global",story:{kind:"body",partName:o}})}},()=>false)}function ia(t,e,n,r){let a=[...e],i=new Set;for(let o of a)t.parts.has(o)&&i.add(o);for(let o of n)oa(o,a,i);for(let o of r)oa(o,a,i);return i}function sa(t,e,n,r,a){let i=new Set(t);i.add(e),i.add(n);for(let o of r)aa(o,i);for(let o of a)aa(o,i);return i}function oa(t,e,n){if(t.kind==="story"){n.add(t.partName);return}for(let r of e)(t.before.parts.has(r)||t.after.parts.has(r))&&n.add(r);}function aa(t,e){if(t.kind==="story"){e.add(t.partName);return}for(let n of t.before.parts.keys())e.add(n);for(let n of t.after.parts.keys())e.add(n);}var la=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),rs=new Set(["deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]),os=64,da=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];subscribers=new Set;historyLimit;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;constructor(e,n,r={}){this.pkg=Xb(e,n),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??os,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??cf,this.body=new $e(this.pkg,n.name,{historyLimit:this.historyLimit,settingsPart:()=>pe$1(this.pkg)}),this.body.setStoryRef({kind:"body",partName:n.name});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let e=this.currentPackageMemo;if(e&&e.pkg===this.pkg&&e.bodyPart===this.body.part){let a=0,i=true;for(let o of this.stories.values()){if(e.storyParts[a]!==o.part){i=false;break}a+=1;}if(i&&a===e.storyParts.length)return e.result}let n=Xb(this.pkg,this.body.part),r=[];for(let a of this.stories.values())r.push(a.part),this.pkg.parts.has(a.part.name)&&(n=Xb(n,a.part));return this.currentPackageMemo={pkg:this.pkg,bodyPart:this.body.part,storyParts:r,result:n},n}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}resolveStory(e){return e.kind==="body"?{ok:true,story:{kind:"body",partName:this.body.part.name},store:this.body}:e.kind==="notesPart"?e.noteKind!=="footnote"&&e.noteKind!=="endnote"?{ok:false,reason:"unknown-scope",detail:String(e.noteKind)}:this.openNotesPartStore(e.noteKind):e.kind!=="headerFooter"||typeof e.rId!="string"||e.rId.length===0?{ok:false,reason:"unknown-scope",detail:String(e.kind)}:this.openHeaderFooterStore(e.rId)}partFor(e){let n=this.resolveStory(e);return n.ok?n.store.part:null}revisionFor(e){let n=this.resolveStory(e);return n.ok?n.store.revision:null}transact(e,n,r={}){return xa$1(this,()=>this.commitStoryTransaction(e,n,r),ya$1)}commitStoryTransaction(e,n,r={}){let a=this.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let{store:i,story:o}=a,s=this.currentPackage(),l=i.historyDepth,d=i.compositionActive,c=i.checkpoint(),u=false,m=new Set,y=false,g=new Set,P=false,f,x=false;i.graftPackage(()=>this.currentPackage());let p=i.transact(S=>{n({...S,applyPackage:R=>S.applyPackage(v=>{let A=R(v);return A!==v&&!x&&(x=Oo(v,A,o.partName)),A}),apply:R=>(R.op==="setListNumbering"&&R.numId!==null&&(P=true),R.op==="setParagraphProperties"&&(f??=R.properties.find(v=>v.localName==="pStyle")?.attributes?.val),u||(R.op==="deleteText"&&Ho(this.pkg,i.part,R,m)||R.op==="deleteBlock"&&Bo(this.pkg,i.part,R,m)||la.has(R.op))&&(u=true),y||(R.op==="deleteText"||R.op==="deleteBlock"?y=Vo(this.pkg,i.part,R,g):(la.has(R.op)||rs.has(R.op))&&(y=true)),S.apply(R)),selectionBefore:R=>S.selectionBefore(R),selectionAfter:R=>S.selectionAfter(R)});},{...r,story:o,...o.kind==="headerFooter"||o.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!p.ok)return {ok:false,reason:p.reason,...p.detail?{detail:p.detail}:{}};this.syncPackageFromStore(i);let h=false;if(p.change&&x&&(this.installPackageSnapshotInternal(i.package),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),h=true),P&&f){let S=bo(this.pkg,f);S&&this.replacePackageShell(S);}let N=false;if(p.change&&u){let S=this.currentPackage(),R=this.cascadeNoteReferences(s,S);if(R===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};R!==S&&(this.installPackageSnapshotInternal(R),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),N=true);}if(p.change&&y){let S=this.currentPackage(),R=Vf(s,S,{storyPartName:o.partName});if(R===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};R!==S&&(this.installPackageSnapshotInternal(R),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),N=true);}if(p.change){this.packageRev+=1;let S=N||h;!d&&r.recordsHistory!==false&&(i.historyDepth>l||S)&&(S?this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage()}):this.pushUndoPointer({kind:"story",partName:o.partName,story:o}));let R=S?this.publishSynthetic(p.change.origin,"global",o,p.change.created):p.change;return S||this.publish(R),{ok:true,change:R}}return {ok:true,change:p.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(e,n=null){let r=this.resolveStory(e);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(e),!r.ok)?false:(this.compositionSession||(this.compositionSession={partName:r.story.partName,beforePackage:this.currentPackage(),storyCheckpoint:r.store.checkpoint(),packageWideEffects:false}),r.store.beginComposition(n),true)}endComposition(){let e=this.compositionSession;if(this.compositionSession=null,!e){this.body.endComposition();return}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return;let r=n.historyDepth;if(n.endComposition(),e.packageWideEffects){n.restoreHistoryStacks(e.storyCheckpoint),this.syncPackageFromStore(n),this.pushUndoPointer({kind:"package",before:e.beforePackage,after:this.currentPackage()});return}if(n.historyDepth>r){let a=e.partName===this.body.part.name?{kind:"body",partName:e.partName}:this.storyRefForPart(e.partName);a&&this.pushUndoPointer({kind:"story",partName:e.partName,story:a});}this.syncPackageFromStore(n);}cancelComposition(){let e=this.compositionSession;if(this.compositionSession=null,!e){this.body.cancelComposition();return}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(e.packageWideEffects){n&&n.restoreCheckpoint(e.storyCheckpoint),this.installPackageSnapshotInternal(e.beforePackage),this.packageRev+=1;let r=e.partName===this.body.part.name?{kind:"body",partName:e.partName}:this.storyRefForPart(e.partName);this.publishSynthetic(b.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(e){return xa$1(this,()=>this.commitLifecycleOp(e),ya$1)}commitLifecycleOp(e){let n=this.currentPackage();if(af(e)){let o=bf(n,e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};if(o.package===n)return {ok:true,change:null};this.installPackageSnapshotInternal(o.package),this.pushUndoPointer({kind:"package",before:n,after:o.package}),this.packageRev+=1;let s={kind:"body",partName:this.body.part.name},l=this.publishSynthetic(b.mutationHuman,o.impact,s,o.createdPartName?[o.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:l}}if(!Hd(e))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let r=Id(n,e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};this.installPackageSnapshotInternal(r.package),this.pushUndoPointer({kind:"package",before:n,after:r.package}),this.packageRev+=1;let a={kind:"body",partName:this.body.part.name},i=this.publishSynthetic(b.mutationHuman,r.impact,a,r.createdPartName?[r.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:i}}undo(){let e=this.undoOrder.pop();if(!e)return null;if(e.kind==="package"){this.installPackageSnapshotInternal(e.before),this.redoOrder.push(e),this.packageRev+=1;let a=this.publishSynthetic(b.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),a}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return null;let r=n.undo();return r?(this.redoOrder.push(e),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let e=this.redoOrder.pop();if(!e)return null;if(e.kind==="package"){this.installPackageSnapshotInternal(e.after),this.undoOrder.push(e),this.packageRev+=1;let a=this.publishSynthetic(b.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),a}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return null;let r=n.redo();return r?(this.undoOrder.push(e),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){let e=this.undoOrder[this.undoOrder.length-1];return !e||e.kind==="package"?null:(e.partName===this.body.part.name?this.body:this.stories.get(e.partName))?.selectionForUndo()??null}selectionForRedo(){let e=this.redoOrder[this.redoOrder.length-1];return !e||e.kind==="package"?null:(e.partName===this.body.part.name?this.body:this.stories.get(e.partName))?.selectionForRedo()??null}openStoryParts(){return ln(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return Po(this.stories,this.pkg)}insertImage(e,n){return Yo(this,e,n)}applyFragmentPaste(e,n){return xo(this,e,n)}replaceImage(e,n,r,a,i,o){return pn(this,e,n,r,a,i,o)}deleteImage(e,n){return Jo(this,e,n)}deleteImageTracked(e,n,r){return qo(this,e,n,r)}embedExternalImage(e,n,r,a,i,o,s){return Qo(this,e,n,r,a,i,o,s)}setDrawingMetadataWithHyperlink(e,n,r,a,i){return Zo(this,e,n,r,a,i)}applyImageProperties(e,n){return ea(this,e,n)}promoteStoryTransactionToPackageUnit(e,n,r,a){this.installPackageSnapshotInternal(n.package),n.historyDepth>a&&n.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:e,after:this.currentPackage()}),this.packageRev+=1;let i=n.part.name===this.body.part.name?{kind:"body",partName:n.part.name}:this.storyRefForPart(n.part.name);return this.publishSynthetic(b.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(e){return e?(this.packageRev+=1,this.publish(e),e):null}adoptPackageUnit(e){let n=this.currentPackage();e!==n&&this.pushUndoPointer({kind:"package",before:e,after:n});}installPackageSnapshot(e){this.installPackageSnapshotInternal(e);}installAuthoritativePackageSnapshot(e){this.installPackageSnapshotInternal(e,false);}publishRemotePackage(e,n){return ra(this,e,n)}replacePackageShell(e){this.shellHyperlinks=Eo(this.shellHyperlinks,this.pkg,e);let n=e;n=Xb(n,this.body.part);for(let r of this.stories.values())e.parts.has(r.part.name)&&(n=Xb(n,r.part));this.pkg=n;}installPackageSnapshotInternal(e,n=true){let r=n?Mo(e,this.pkg,this.shellHyperlinks):e,a=r.parts.get(r.mainDocumentPart);if(!a)return;this.body.replacePart(a);for(let[o,s]of this.stories){let l=r.parts.get(o);l&&s.replacePart(l);}this.rIdToPartName.clear();let i=r.relationships.get(r.mainDocumentPart)??[];for(let o of i){if(o.type!==cn&&o.type!==mn)continue;let s=E(o);s.mode!=="Internal"||!s.target.ok||this.stories.has(s.target.partName)&&r.parts.has(s.target.partName)&&this.rIdToPartName.set(o.id,s.target.partName);}this.pkg=r,this.pkg=Xb(this.pkg,this.body.part);for(let o of this.stories.values())this.pkg.parts.has(o.part.name)&&(this.pkg=Xb(this.pkg,o.part));}openNotesPartStore(e){let n=Pe(this.currentPackage(),e);if(!n)return {ok:false,reason:"missing-part",detail:e};let r=this.stories.get(n.name);if(r)return {ok:true,story:{kind:"notesPart",partName:n.name,noteKind:e},store:r};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let a=Bb(n),i=new $e(a,{historyLimit:this.historyLimit,settingsPart:()=>pe$1(this.pkg)}),o={kind:"notesPart",partName:a.name,noteKind:e};return i.setStoryRef(o),this.stories.set(a.name,i),a!==n&&(this.pkg=Xb(this.pkg,a)),{ok:true,story:o,store:i}}openHeaderFooterStore(e){let n=this.rIdToPartName.get(e);if(n){let l=this.stories.get(n);if(l)return {ok:true,story:{kind:"headerFooter",partName:n,rId:e},store:l}}let r=Wo(this.currentPackage(),e);if(!r.ok)return r;let a=this.stories.get(r.partName);if(a)return this.rIdToPartName.set(e,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:e},store:a};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let i=Bb(r.part),o=new $e(i,{historyLimit:this.historyLimit,settingsPart:()=>pe$1(this.pkg)}),s={kind:"headerFooter",partName:i.name,rId:e};return o.setStoryRef(s),this.stories.set(i.name,o),this.rIdToPartName.set(e,i.name),i!==r.part&&(this.pkg=Xb(this.pkg,i)),{ok:true,story:s,store:o}}storyRefForPart(e){if(e===this.body.part.name)return {kind:"body",partName:e};for(let[r,a]of this.rIdToPartName)if(a===e)return {kind:"headerFooter",partName:e,rId:r};let n=this.currentPackage().parts.get(e);return n?.root.localName==="footnotes"?{kind:"notesPart",partName:e,noteKind:"footnote"}:n?.root.localName==="endnotes"?{kind:"notesPart",partName:e,noteKind:"endnote"}:null}syncPackageFromStore(e){this.pkg=Xb(this.pkg,e.part);}pushUndoPointer(e){this.undoOrder.push(e),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let e=ia(this.pkg,this.stories.keys(),this.undoOrder,this.redoOrder);for(let[a]of [...this.stories])if(!e.has(a)){this.stories.delete(a);for(let[i,o]of [...this.rIdToPartName])o===a&&this.rIdToPartName.delete(i);}let n=sa(e,this.pkg.mainDocumentPart,this.body.part.name,this.undoOrder,this.redoOrder),r=Do(this.pkg,n);r!==this.pkg&&(this.pkg=r),this.shellHyperlinks=Co(this.shellHyperlinks,n,this.pkg.mainDocumentPart);}publish(e){this.lastChange=e;for(let n of this.subscribers)n(e);}publishSynthetic(e,n,r,a){this.commitCounter+=1;let i=this.packageRev-1,o={change:"model-change",fromRevision:i<0?0:i,toRevision:this.packageRev,commitId:`pkg-commit-${this.commitCounter}`,origin:e,dirty:[],created:[...a],deleted:[],splitJoin:[],dependencyKeys:[],impact:n,story:r};return this.publish(o),o}};function as(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function ca(t,e){if(!t){let o=Eb(e);return o?Fb(new Set,o,Cb):"0"}let n=-1,r=new Set,a=o=>{if(o.kind!=="textValue"){if(o.kind==="comment"){let s=as(o,ca$1,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=Cb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of o.children)a(s);}};a(t.root);let i=Eb(e);return i?Fb(r,i,Cb):String(n+1)}var is=256,ss=65535,ma=64;function Et(t,e){return t.length>e}function ua(t){return typeof t!="string"||t.trim().length===0?"invalid-author":Et(t,is)?"resource-limit":O(t)?null:"invalid-author"}function pa(t){return typeof t!="string"||t.length===0?"invalid-text":Et(t,ss)?"resource-limit":O(t)?null:"invalid-text"}function gn(t){if(typeof t!="string")return {ok:false,rejection:"invalid-date"};let e=t.trim();if(Et(e,ma))return {ok:false,rejection:"resource-limit"};if(!O(e))return {ok:false,rejection:"invalid-date"};let n=Be$1(e);return n===null?{ok:false,rejection:"invalid-date"}:Et(n,ma)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function Nc(t){if(t===void 0)return null;let e=gn(t);return e.ok?null:e.rejection}function hn(t){switch(t){case "invalid-author":return "invalid-author";case "invalid-text":return "invalid-text";case "invalid-date":return "invalid-property-value";case "resource-limit":return "resource-limit"}}function fa(t,e){if(t.kind==="textValue")return t;let n=e.get(t.id);if(n!==void 0)return n;let r=false,a=[];for(let i of t.children){let o=fa(i,e);o!==i&&(r=true),a.push(o);}return r?{...t,children:a}:t}function cs(t,e,n){let r=fa(t.root,e);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:t.root.id,nodeId:t.root.id}]};let a=n===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:n,namespaceUri:fa$1}]};return Ha$1(t,t.root.id,a,{deferValidation:true})}function ga(t,e,n){let r=new Map;for(let i of e){if(i.stampParagraph===null)continue;let o=r.get(i.commentsPartName);o||(o=new Map,r.set(i.commentsPartName,o)),o.set(i.stampParagraph.id,{paragraph:i.stampParagraph,paraId:i.paraId});}let a=t;for(let[i,o]of r){let s=a.parts.get(i);if(!s)return null;let l=zb(s.root),d=l??"w14",c=new Map;for(let m of o.values())c.set(m.paragraph.id,n(m.paragraph,m.paraId,d));let u=cs(s,c,l===null?d:null);if(!u.ok)return null;a=Xb(a,u.part);}return a}function ha(t,e,n){let r=t.root.children.map(a=>a.kind==="textValue"?a:e.get(a.id)??a);return Fa$1(t,t.root.id,[...r,...n],{deferValidation:true})}var xa="/word/comments.xml",Pa="/word/commentsExtended.xml",On="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",In="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",ms=[In,"application/vnd.ms-word.commentsExtended+xml"],Oa="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Rn="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",ke="http://schemas.microsoft.com/office/word/2012/wordml";function ot(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function Ve(t,e){return {kind:"genericExtension",namespaceUri:ca$1,localName:t,prefix:"w",value:e}}function ge(t,e,n,r,a,i,o,s=[]){return {id:t,kind:e,namespaceUri:n,localName:a,prefix:r,namespaceBindings:s,attributes:i,children:o}}function Ia(t,e,n,r,a){let i=e===t.mainDocumentPart?[e]:[e,t.mainDocumentPart];for(let o of i)for(let s of Zb(t,o)){if(s.type!==n)continue;let l=w(o,s.rawTarget);if(!l.ok)continue;if(!t.parts.has(l.partName))return l.partName;let d=_b(t,l.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return l.partName}return a}function yn(t,e,n){let r=t.mainDocumentPart;for(let i of Zb(t,r)){if(i.type!==e)continue;let o=w(r,i.rawTarget);if(o.ok&&o.partName===n)return t}let a=cc(t,r);return dc(a,r,e,fg(r,n)).pkg}function bn(t,e){return Ia(t,e,Oa,On,xa)}function Ra(t,e){let n=ff(t,e),r=gf(t,e,n).extended;return r!==null?r:Ia(t,e,Rn,ms,Pa)}function ya(t){let e=new Set;for(let n of t.parts.values())for(let r of yb(n.root))e.add(r);return e}function us(t,e){if(!t)return null;let n=null,r=a=>{if(!(n!==null||a.kind==="textValue")){if(a.kind==="comment"&&ot(a,ca$1,"id")===e){for(let i=a.children.length-1;i>=0;i-=1){let o=a.children[i];if(o.kind!=="paragraph")continue;let s=ot(o,fa$1,"paraId");s!==void 0&&ub(s)&&(n=s.toUpperCase());return}return}for(let i of a.children)r(i);}};return r(t.root),n}function ps(t,e){if(!t)return null;let n=null,r=a=>{if(!(n!==null||a.kind==="textValue")){if(a.kind==="comment"&&ot(a,ca$1,"id")===e){for(let i=a.children.length-1;i>=0;i-=1){let o=a.children[i];if(o.kind==="paragraph"){n=o;return}}return}for(let i of a.children)r(i);}};return r(t.root),n}function ba(t){let e=zb(t.root);if(e!==null)return {part:t,prefix:e};let n={...t.root,namespaceBindings:[...t.root.namespaceBindings,{prefix:"w14",namespaceUri:fa$1}]},r=Ha$1(t,t.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(Ea$1(t.root,n),{part:{...t,root:n},prefix:"w14"})}function va(t,e,n){return ge(t.id,"paragraph",t.namespaceUri,t.prefix??"w",t.localName,[...t.attributes.filter(r=>!(r.namespaceUri===fa$1&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:fa$1,localName:"paraId",prefix:n,value:e}],t.children,t.namespaceBindings)}function fs(t,e,n,r){let a=t.parts.get(e);if(!a)return t;let i=ba(a),o=Ca$1(i.part,n);if(!o||o.kind!=="paragraph")return Xb(t,i.part);let s=Ha$1(i.part,o.id,va(o,r,i.prefix),{deferValidation:true});return Xb(t,s.ok?s.part:i.part)}function gs(t,e,n,r){let a=`${xa}#comment-${t}`,i=n.text!==n.text.trim(),o=ge(`${a}.t`,"text",ca$1,"w","t",i?[{kind:"xmlSpace",namespaceUri:da$1,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${a}.tv`,kind:"textValue",value:n.text}]),s=ge(`${a}.rPr`,"runProperties",ca$1,"w","rPr",[],[ge(`${a}.rStyle`,"generic",ca$1,"w","rStyle",[Ve("val","CommentReference")],[])]),l=ge(`${a}.r`,"run",ca$1,"w","r",[],[s,o]),d=ge(`${a}.pPr`,"paragraphProperties",ca$1,"w","pPr",[],[ge(`${a}.pStyle`,"generic",ca$1,"w","pStyle",[Ve("val","CommentText")],[])]),c=ge(`${a}.p`,"paragraph",ca$1,"w","p",[{kind:"genericExtension",namespaceUri:fa$1,localName:"paraId",prefix:r,value:e}],[d,l]);return ge(a,"comment",ca$1,"w","comment",[Ve("id",t),Ve("author",n.author),...n.initials===void 0?[]:[Ve("initials",n.initials)],...n.date===void 0?[]:[Ve("date",n.date)]],[c])}function kn(t,e){let n=ta$1(e,{name:t,contentType:"application/xml"});return n.ok?n.part.root:null}function Na(t,e){for(let x of [ua(e.author),pa(e.text)])if(x)return {ok:false,reason:hn(x)};let n;if(e.date!==void 0){let x=gn(e.date);if(!x.ok)return {ok:false,reason:hn(x.rejection)};n=x.value;}let r={...e,...n===void 0?{}:{date:n}},a=t.package,i=t.part.name,o=bn(a,i),s=Ra(a,i),l=a.parts.get(o),d=ca(l,r.actorId),c=xb(`${o}#${d}`,ya(a)),u=e.replyToCommentId===void 0?null:us(l,e.replyToCommentId),m=e.replyToCommentId!==void 0&&u===null?ps(l,e.replyToCommentId):null;if(e.replyToCommentId!==void 0&&u===null&&!m)return {ok:false,reason:"unknown-revision"};let y=m?xb(`${o}#parent-${e.replyToCommentId}`,new Set([...ya(a),c])):null,g=u??y,P=e.anchor.endParagraphId??e.anchor.paragraphId,f=t.transact(x=>{x.applyPackage(p=>{let h=p.parts.has(o)?p:(()=>{let N=kn(o,`<w:comments xmlns:w="${ca$1}"/>`);return N?ec(p,o,N,On):null})();return h===null?p:yn(h,Oa,o)}),m&&y&&x.applyPackage(p=>fs(p,o,m.id,y)),x.applyPackage(p=>{let h=p.parts.get(o);if(!h)return p;let N=ba(h),S=Ga$1(N.part,N.part.root.id,N.part.root.children.length,[gs(d,c,r,N.prefix)],{deferValidation:true});return S.ok?Xb(p,S.part):p}),g!==null&&(x.applyPackage(p=>{let h=p.parts.has(s)?p:(()=>{let N=kn(s,`<w15:commentsEx xmlns:w15="${ke}"/>`);return N?ec(p,s,N,In):null})();return h===null?p:yn(h,Rn,s)}),x.applyPackage(p=>{let h=p.parts.get(s);if(!h)return p;let S=[...hs(h).has(g.toUpperCase())?[]:[Pn(`${s}#ex-${g}`,g,void 0,false)],Pn(`${s}#ex-${c}`,c,g,false)],R=Ga$1(h,h.root.id,h.root.children.length,S,{deferValidation:true});return R.ok?Xb(p,R.part):p})),x.applyTo(i,{op:"insertCommentMarker",paragraphId:P,offset:e.anchor.end,commentId:d,marker:"reference"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:P,offset:e.anchor.end,commentId:d,marker:"end"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:e.anchor.paragraphId,offset:e.anchor.start,commentId:d,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return f.ok?{ok:true,commentId:d,change:f.change}:{ok:false,reason:f.reason}}function xn(t){for(let e=t.children.length-1;e>=0;e-=1){let n=t.children[e];if(n.kind==="paragraph")return n}return null}function ka(t){let e=xn(t);if(!e)return null;let n=ot(e,fa$1,"paraId");return n!==void 0&&ub(n)?n.toUpperCase():null}function hs(t){let e=new Map;if(!t)return e;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===ke&&r.localName==="commentEx"){let a=ot(r,ke,"paraId");a!==void 0&&ub(a)&&e.set(a.toUpperCase(),r);}for(let a of r.children)n(a);}};return n(t.root),e}function rt(t,e){return {kind:"genericExtension",namespaceUri:ke,localName:t,prefix:"w15",value:e}}function ys(t,e){return {id:t.id,kind:"generic",namespaceUri:t.namespaceUri,localName:t.localName,...t.prefix===void 0?{}:{prefix:t.prefix},namespaceBindings:t.namespaceBindings,attributes:e,children:t.children}}function ks(t,e,n){let r=[],a=false,i=false;for(let o of t.attributes){if(o.namespaceUri===ke&&o.localName==="done"){a=true,r.push({kind:"genericExtension",namespaceUri:o.namespaceUri,localName:o.localName,...o.prefix===void 0?{}:{prefix:o.prefix},value:n?"1":"0"});continue}o.namespaceUri===ke&&o.localName==="paraIdParent"&&(i=true),r.push(o);}return !i&&e!==void 0&&r.push(rt("paraIdParent",e)),a||r.push(rt("done",n?"1":"0")),ys(t,r)}function Pn(t,e,n,r){return {id:t,kind:"generic",namespaceUri:ke,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[rt("paraId",e),...n===void 0?[]:[rt("paraIdParent",n)],rt("done",r?"1":"0")],children:[]}}function Sa(t,e,n){return xs(t,e,n,ef())}function xs(t,e,n,r){let a=t.package,i=t.part.name;if(ff(a,i)===null)return {ok:false,reason:"unknown-comment"};let s=_if(a,e,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=hf(a,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=l.used,c=new Map,u=[];for(let P of s.ids){let f=s.records.get(P);if(!f)return {ok:false,reason:"unknown-comment"};if(!xn(f.node))return {ok:false,reason:"unknown-comment"};let p=ka(f.node),h=p??xb(`${f.partName}#done-${P}`,d);p===null&&d.add(h),c.set(P,h);}for(let P of s.ids){let f=s.records.get(P),x=xn(f.node),p=c.get(P),h=ka(f.node),N=s.parentCommentIdByChildId.get(P),S=s.parentParaIdByCommentId.get(P)??(N===void 0?void 0:c.get(N)),R=s.commentExByParaId.get(p);u.push({paraId:p,stampParagraph:h===null?x:null,commentsPartName:f.partName,parentParaId:S,existing:R?.node,existingParentParaId:R?.parentParaId,existingDone:R?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(P=>P.existingDone===n))return {ok:true,changed:false,change:null};let m=s.extendedPartName??Pa,y=s.extendedPartName===null,g=t.transact(P=>{P.applyPackage(f=>{let x=ga(f,u,va);if(x===null)return f;let p=x;if(!p.parts.has(m)){let v=kn(m,`<w15:commentsEx xmlns:w15="${ke}"/>`);if(!v)return f;let A=ec(p,m,v,In);p=y?yn(A,Rn,m):A;}let h=p.parts.get(m);if(!h)return f;let N=new Map,S=[];for(let v of u){let A=v.existingParentParaId??v.parentParaId;v.existing?N.set(v.existing.id,ks(v.existing,A,n)):S.push(Pn(`${m}#done-${v.paraId}`,v.paraId,A,n));}let R=ha(h,N,S);return R.ok?Xb(p,R.part):f});});return g.ok?{ok:true,changed:true,change:g.change}:{ok:false,reason:g.reason}}function Xc(t,e){let n=bn(t,e);return t.parts.has(n)&&_b(t,n)===On}function Yc(t,e){return bn(t,e)}function Jc(t,e){return Ra(t,e)}var Ta={kind:"body"};function nm(t,e,n=Ta){let r=n.kind==="body"?null:t.resolveStory(n),a=r?.ok?r.store:t.bodyStore(),i=t.currentPackage(),o=a.checkpoint();return a.graftPackage(()=>t.currentPackage()),xa$1(t,()=>{let s=Na(a,e);return s.ok&&(a.restoreHistoryStacks(o),t.replacePackageShell(a.package),t.adoptPackageUnit(i),t.publishStoryWrite(s.change)),s},s=>ya$1(s))}function rm(t,e,n){let r=t.bodyStore(),a=t.currentPackage(),i=r.checkpoint();return r.graftPackage(()=>t.currentPackage()),xa$1(t,()=>{let o=Sa(r,e,n);return !o.ok||!o.changed||(r.restoreHistoryStacks(i),t.replacePackageShell(r.package),t.adoptPackageUnit(a),t.publishStoryWrite(o.change)),o},o=>o.ok&&o.changed)}function om(t,e,n=Ta,r){if(e.length===0)return false;let a=n.kind==="body"?t.bodyStore().part:t.partFor(n);if(!a)return false;let i={storyPartName:a.name,...r===void 0?{}:{noteId:r}},o=t.bodyStore(),s=t.currentPackage(),l=o.checkpoint();return o.graftPackage(()=>t.currentPackage()),xa$1(t,()=>{let d=false,c=false,u=o.transact(m=>{m.applyPackage(y=>{let g=y;for(let P of e){let f=P.parentCommentId===void 0?Tf(g,P.commentId,i):Uf(g,P.commentId,P.parentCommentId,i);if(f===null)return d=true,y;c||=f!==g,g=f;}return g});});return d||!u.ok||!c?false:(o.restoreHistoryStacks(l),t.installPackageSnapshot(o.package),t.adoptPackageUnit(s),t.publishStoryWrite(u.change),true)},d=>d)}var Ps=256*1024,Os=4096;function Ea(t,e,n){let r=e.payload,a=t.part.name,i=n??a;if(r){if(r.data.length>Ps)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>Os)return {ok:false,reason:"payload-too-large",detail:"label"}}let o=new Set(xf(t.part.root).map(m=>m.node.id)),s=e.replaceControlId===void 0?[]:Ca(t,a,e.replaceControlId),l=null,d,c=t.transact(m=>{if(e.replaceControlId!==void 0){m.apply({op:"removeContentControl",controlId:e.replaceControlId,keepContent:false});for(let P of s)m.applyPackage(f=>ng(f,P.partName,P.nodeId));}let y=e.replaceUntil;if(y!==void 0&&y<=e.offset){l="invalid-range",d="replaceUntil must be past offset";return}if(y!==void 0&&m.apply({op:"deleteText",paragraphId:e.paragraphId,start:e.offset,end:y}),!r){m.apply({op:"insertInlineContentControl",paragraphId:e.paragraphId,offset:e.offset,tag:e.tag,text:e.text,...e.alias===void 0?{}:{alias:e.alias},...e.lock===void 0?{}:{lock:e.lock}});return}let g=null;m.applyPackage(P=>{let f=ig(P,i,r.namespaceUri,r.rootLocalName);if(!f.part)return l="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,P;if(g=sg(f.part,r.rootLocalName,r.nodeId),!g)return l="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,P;let x=mg(f.pkg,f.part.partName,{id:r.nodeId,label:r.label,data:r.data});return lg(x,f.part.partName,r.nodeId)?x:(l="store-not-authored",d="the payload node could not be written into the store",P)}),!(l!==null||!g)&&m.apply({op:"insertInlineContentControl",paragraphId:e.paragraphId,offset:e.offset,tag:e.tag,text:e.text,...e.alias===void 0?{}:{alias:e.alias},...e.lock===void 0?{}:{lock:e.lock},dataBinding:g});});if(l!==null)return {ok:false,reason:l,...d===void 0?{}:{detail:d}};if(!c.ok)return {ok:false,reason:c.reason,...c.detail===void 0?{}:{detail:c.detail}};let u=Is(t,o);return {ok:true,change:c.change,...u===void 0?{}:{nodeId:u}}}function Is(t,e){for(let n of xf(t.part.root))if(!e.has(n.node.id))return n.node.id}function Ca(t,e,n){let r=xf(t.part.root).find(i=>i.node.id===n);if(!r)return [];let a=[];for(let i of gg(t.package,e)){let o=vg(r.node,i.itemId);o!==null&&a.push({partName:i.partName,nodeId:o});}return a}function Ma(t,e){let n=t.part.name,r=Ca(t,n,e),a=t.transact(i=>{i.apply({op:"removeContentControl",controlId:e,keepContent:false});for(let o of r)i.applyPackage(s=>ng(s,o.partName,o.nodeId));});return a.ok?{ok:true,change:a.change}:{ok:false,reason:a.reason,...a.detail===void 0?{}:{detail:a.detail}}}function cm(t,e,n){if(!t.parts.has(e)||n.length===0)return {ok:true,pkg:t,removed:[]};let r=t,a=[];for(let i of n){let o=hg(r,e,i);if(!o)continue;let s=ug(r,o.itemId),l=og(r,o.partName,s);if(l.pkg===r&&kg(r,o.partName).some(d=>!s.has(d.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=l.pkg,a.push(...l.removed);}return {ok:true,pkg:r,removed:a}}var wa=new WeakMap;function Rs(t,e){let n=wa.get(t);n||(n=new Map,wa.set(t,n));let r=n.get(e);if(r)return r;let a=gg(t,e).map(i=>({itemId:i.itemId,nodes:new Map(kg(t,i.partName).map(o=>[o.id,o]))}));return n.set(e,a),a}function mm(t,e,n=e){let r=new Map,a=t.parts.get(e);if(!a)return r;let i=Rs(t,n);if(i.length===0)return r;for(let o of xf(a.root))for(let s of i){let l=vg(o.node,s.itemId);if(l===null)continue;let d=s.nodes.get(l);if(d){r.set(o.node.id,{nodeId:l,label:d.label,data:d.data});break}}return r}function um(t,e,n){let r=new Map,a=hg(t,e,n);if(!a)return r;for(let i of kg(t,a.partName))r.set(i.id,{label:i.label,data:i.data});return r}var Da={kind:"body"};function Aa(t,e,n){let r=e.kind==="body"?null:t.resolveStory(e),a=r?.ok?r.store:t.bodyStore(),i=t.currentPackage(),o=a.checkpoint();return a.graftPackage(()=>t.currentPackage()),xa$1(t,()=>{let s=n(a);return s.ok&&(a.restoreHistoryStacks(o),t.replacePackageShell(a.package),t.adoptPackageUnit(i),t.publishStoryWrite(s.change)),s},s=>ya$1(s))}function hm(t,e,n=Da){return Aa(t,n,r=>Ea(r,e,t.bodyStore().part.name))}function ym(t,e,n=Da){return Aa(t,n,r=>Ma(r,e))}var We="proposed";function bs(t,e){switch(t){case "revisionInsert":case "revisionMoveTo":return e!=="original";case "revisionDelete":case "revisionMoveFrom":return e!=="proposed";default:return false}}var vs=32;function vn(t,e=We){let n=[];return at(t.children,e,0,n),n}function Nn(t,e,n,r,a=We){let i=[];for(let o of vn(t,a)){let s=e.get(o.id);if(!s||s.end<=s.start)continue;let l=Math.max(s.start,n),d=Math.min(s.end,r);l>=d||i.push({run:o,start:l,end:d});}return i}function at(t,e,n,r){if(!(n>=vs)){for(let a of t)if(!(a.kind==="textValue"||a.kind==="paragraphProperties")){if(a.kind==="run"){r.push(a);continue}if(a.kind==="hyperlink"){at(a.children,e,n+1,r);continue}if(ja$1(a.kind)){if(!bs(a.kind,e))continue;at(a.children,e,n+1,r);continue}if(Pc(a)){at(a.children,e,n+1,r);continue}if(xe(a)){let i=ye(a);i&&at(i.children,e,n+1,r);continue}}}}var Ns=new Set(_e),Tn=new Set(Ze);function wm(t){return Tn.has(t)}function Ct(t,e,n){return !t||t.kind==="textValue"?void 0:t.children.find(a=>a.kind===e||a.kind==="generic"&&a.localName===n&&a.namespaceUri===ca$1)}function wn(t,e){if(!t||t.kind==="textValue")return [];let n=[];for(let r of t.children){if(r.kind==="textValue"||!e.has(r.localName))continue;let a=J$1();for(let i of r.attributes)a[i.localName]=i.value;n.push(Object.keys(a).length>0?{localName:r.localName,attributes:a}:{localName:r.localName});}return n}function Em(t,e){let n=Ca$1(t,e);return wn(Ct(n,"paragraphProperties","pPr"),Ns)}function Ss(t,e){let n=Ca$1(t,e),r=Ct(n,"paragraphProperties","pPr");return wn(Ct(r,"runProperties","rPr"),Tn)}function _a(t,e){let n=Array.isArray(e)?e:[e],r=new Set(n.map(i=>i.localName));return [...t.filter(i=>!r.has(i.localName)),...n]}var Ts=new Map([["ascii","asciiTheme"],["hAnsi","hAnsiTheme"],["eastAsia","eastAsiaTheme"],["cs","cstheme"]]);function ws(t,e){let n=t.find(a=>a.localName==="rFonts")?.attributes;if(!n)return e;let r={...n,...e.attributes??{}};for(let a of Object.keys(e.attributes??{})){let i=Ts.get(a);i&&delete r[i];}return {localName:"rFonts",attributes:r}}function En(t){let e=new Map;for(let n of He$1(t)){let r=n.formatRunIds&&n.formatRunIds.length>0?n.formatRunIds:n.runId?[n.runId]:[];for(let a of r){let i=e.get(a);i?(i.start=Math.min(i.start,n.start),i.end=Math.max(i.end,n.end)):e.set(a,{start:n.start,end:n.end});}}return e}function Es(t){let e=new Set;for(let n of He$1(t))if(n.formatRunIds)for(let r of n.formatRunIds)e.add(r);return e}function Sn(t,e){if(e.localName==="rFonts")return ws(t,e);if(e.localName!=="u")return e;let n=t.find(r=>r.localName==="u")?.attributes;return n?{localName:"u",attributes:{...n,...e.attributes??{}}}:e}function Cm(t,e,n){let r=Ss(t,e),a=Array.isArray(n)?n:[n];return _a(r,a.map(i=>Sn(r,i)))}function Cs(t,e){return Array.isArray(e)?e.map(n=>Sn(t,n)):Sn(t,e)}function Mm(t,e,n,r,a,i=We){let o=Ca$1(t,e);if(!o||o.kind!=="paragraph")return [];let s=[],l=Es(o);for(let d of Nn(o,En(o),n,r,i)){let c=wn(Ct(d.run,"runProperties","rPr"),Tn);s.push({start:d.start,end:d.end,properties:_a(c,Cs(c,a)),...l.has(d.run.id)?{targetRunIds:[d.run.id]}:{}});}return s}function Dm(t,e,n,r,a=We){let i=Ca$1(t,e);if(!i||i.kind!=="paragraph"||r<=n)return [];let o=[];for(let s of Nn(i,En(i),n,r,a)){let l=o[o.length-1];l&&s.start<=l.end?l.end=Math.max(l.end,s.end):o.push({start:s.start,end:s.end});}return o}function Am(t,e,n,r,a=We){let i=Ca$1(t,e);if(!i||i.kind!=="paragraph")return [];let o=En(i),s=[];for(let l of vn(i,a)){let d=o.get(l.id);if(!d||d.end<=d.start)continue;(r>n?Math.max(d.start,n)<Math.min(d.end,r):d.start<=n&&n<d.end)&&s.push(l);}return s}function Cn(t){let e=La.get(t.root);if(e)return e;let n=new Map,r=o=>{let s=Ua.get(o);if(s){for(let[d,c]of s)n.set(d,c);return}let l=new Map;Ds(o,l),Ua.set(o,l);for(let[d,c]of l)n.set(d,c);},a=(o,s)=>{if(!(o.kind==="textValue"||s>64)){if(o.kind==="paragraph"){r(o);return}for(let l of o.children)a(l,s+1);}};a(t.root,0);let i=(o,s)=>{if(!(o.kind==="textValue"||s>64)){if(o.kind==="paragraph"){let l=Fa.get(o);if(!l){let d=[];$a(o,0,d),l=d,Fa.set(o,l);}for(let[d,c]of l)n.set(d,c);return}if(o.kind==="tableRow"){let l=Mt.get(o);l||(l=Ha(o),Mt.set(o,l));for(let[d,c]of l)n.set(d,c);}for(let l of o.children)i(l,s+1);}};return i(t.root,0),La.set(t.root,n),n}function $a(t,e,n){if(!(t.kind==="textValue"||e>64)){if(t.kind==="tableRow"){let r=Mt.get(t);r||(r=Ha(t),Mt.set(t,r));for(let a of r)n.push(a);}for(let r of t.children)$a(r,e+1,n);}}function Ha(t){let e=null,n=(o,s)=>{if(!(e||o.kind==="textValue"||s>64)){if(o.kind==="paragraph"){e=o;return}for(let l of o.children)n(l,s+1);}};if(n(t,0),!e)return Ms;let r={paragraphId:e.id,start:0,end:0},a=[],i=(o,s,l)=>{if(o.kind==="textValue"||l>64||o.kind==="paragraph")return;let d=s==="trPr"&&(o.localName==="ins"||o.localName==="del"),c=s==="tcPr"&&(o.localName==="cellIns"||o.localName==="cellDel");(d||c)&&a.push([o.id,r]);for(let u of o.children)i(u,o.localName,l+1);};return i(t,void 0,0),a}var Ms=[],Ua=new WeakMap,La=Mf(8),Mt=new WeakMap,Fa=new WeakMap;function Ds(t,e){let n=Ie(t),r=(o,s,l,d)=>{if(!(o.kind==="textValue"||d>64)){e.set(o.id,{paragraphId:t.id,start:s,end:l});for(let c of o.children)r(c,s,l,d+1);}},a=(o,s)=>{if(o.kind==="textValue"||s>64)return;let l=n.spanOf(o);if(o.kind==="run"){if(!l)return;e.set(o.id,{paragraphId:t.id,start:l.start,end:l.end});for(let d of o.children)d.kind==="runProperties"&&r(d,l.start,l.end,s+1);return}l&&e.set(o.id,{paragraphId:t.id,start:l.start,end:l.end});for(let d of o.children)a(d,s+1);};for(let o of t.children)o.kind!=="paragraphProperties"&&a(o,0);let i=t.children.find(o=>o.kind==="paragraphProperties");i&&r(i,n.length,n.length,0);}function $m(t){return `${t.kind}-${t.id}`}function ja(t){return t.kind==="revision"?t.ranges:t.range?[t.range]:[]}function As(t){return ja(t)[0]??null}function Mn(t,e){let n=As(t);if(!n)return Number.MAX_SAFE_INTEGER;let r=e.get(n.start.paragraphId);return r===void 0?Number.MAX_SAFE_INTEGER:r*1e6+Math.min(n.start.offset,999999)}function _s(t,e){let n=e.get(t.start.paragraphId),r=e.get(t.end.paragraphId);return n===void 0||r===void 0?Number.MAX_SAFE_INTEGER:(r-n)*1e6+(t.end.offset-t.start.offset)}var Us=0,Ls=1,Fs=2;function $s(t,e,n){let r=n.get(e.paragraphId),a=n.get(t.start.paragraphId),i=n.get(t.end.paragraphId);return r===void 0||a===void 0||i===void 0||r<a||r>i||r===a&&e.offset<t.start.offset||r===i&&e.offset>t.end.offset?null:a===i&&t.start.offset===t.end.offset?Us:r===i&&e.offset===t.end.offset?Fs:Ls}function Hs(t,e,n){let r=null;for(let a of ja(t)){let i=$s(a,e,n);if(i===null)continue;let o=_s(a,n);(r===null||i<r.grip||i===r.grip&&o<r.width)&&(r={grip:i,width:o});}return r}var Ba={comment:0,custom:1,revision:2};function Bs(t,e,n){let r=[];for(let a of t){let i=Hs(a,e,n);i!==null&&r.push({item:a,grip:i.grip,width:i.width});}return r.sort((a,i)=>a.grip!==i.grip?a.grip-i.grip:a.width!==i.width?a.width-i.width:a.item.kind!==i.item.kind?Ba[a.item.kind]-Ba[i.item.kind]:a.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-a.item.nesting:0).map(a=>a.item)}function Hm(t,e,n){let a=Bs(t,e,n).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return a?a.kind==="comment"?Va(t,a):a:null}function Bm(t,e){return Va(t,e)}function Va(t,e){let n=new Map,r=new Map;for(let o of t)o.kind==="comment"?n.set(o.id,o):o.kind==="revision"&&r.set(o.id,o);let a=new Set([e.id]),i=e;for(;i.parentId!==void 0;){let o=n.get(i.parentId);if(!o||a.has(o.id))break;a.add(o.id),i=o;}if(i.parentRevisionId!==void 0){let o=r.get(i.parentRevisionId);if(o)return o}return i}var js={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function qm(t){let e=[],n=r=>{if(r.kind==="textValue"){e.push(r.value);return}for(let a of r.children)n(a);};for(let r of t.blocks)n(r);return e.join("")}function Qm(t){if(t.initials&&t.initials.trim().length>0)return t.initials.trim();let e=t.author.trim().split(/\s+/).filter(Boolean);return e.length===0?"?":e.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function Dt(t,e){for(let n of t.attributes)if(n.localName===e&&n.namespaceUri===ca$1)return n.value}function it(t){if(t.kind==="textValue")return t.value;if(t.kind==="tab")return " ";if(t.kind==="hardBreak")return Fc(t);if(Nc$1(t))return "";let e="";for(let n of t.children)e+=it(n);return e}function Dn(t){return `${t.id}\0${t.author}\0${t.date??""}`}var Vs={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo"};function Ws(t){let e=t.root.kind!=="paragraph";if(e){let r=Wa.get(t.root);if(r&&r.name===t.name)return r.items}let n=Ks(t);return e&&Wa.set(t.root,{name:t.name,items:n}),n}var Wa=Mf(8);function Ks(t){let e=yg(t);if(e.length===0)return [];let n=Cn(t),r=new Map;for(let i of e){let o=Dt(i.node,"id");if(o===void 0)continue;let s=Dt(i.node,"author")??"",l=Dt(i.node,"author")===void 0,d=Dt(i.node,"date"),c=d===void 0?{id:o,author:s}:{id:o,author:s,date:d},u=i.propertyChange?"format":i.paragraphMark?"paragraphMark":Vs[i.node.kind]??"structural",m=i.paragraphMark?js[i.node.localName]:void 0,y=n.get(i.node.id),g=y?{partName:t.name,start:{paragraphId:y.paragraphId,offset:y.start},end:{paragraphId:y.paragraphId,offset:y.end}}:null,P=u==="structural"?`structural\0${Dn(c)}`:`${i.node.localName}\0${Dn(c)}`,f=r.get(P);if(f){g&&!f.ranges.some(x=>x.partName===g.partName&&x.start.paragraphId===g.start.paragraphId&&x.start.offset===g.start.offset&&x.end.paragraphId===g.end.paragraphId&&x.end.offset===g.end.offset)&&f.ranges.push(g),u!=="structural"&&f.revisionKind==="structural"&&(f.revisionKind=u),(u==="insert"&&f.revisionKind==="delete"||u==="delete"&&f.revisionKind==="insert"||f.revisionKind==="replace")&&(f.revisionKind="replace"),f.readOnly||=i.refused||l,i.nesting>f.nesting&&(f.nesting=i.nesting),u==="delete"||u==="moveFrom"?f.deletedText+=it(i.node):u!=="format"&&u!=="paragraphMark"&&(f.text+=it(i.node));continue}r.set(P,{address:c,revisionKind:u,...m?{markDirection:m}:{},author:s,...d===void 0?{}:{date:d},text:u==="format"||u==="paragraphMark"||u==="delete"||u==="moveFrom"?"":it(i.node),deletedText:u==="delete"||u==="moveFrom"?it(i.node):"",ranges:g?[g]:[],nesting:i.nesting,readOnly:i.refused||l});}let a=[...r.values()].map(i=>({kind:"revision",id:`${i.revisionKind}-${t.name}\0${Dn(i.address)}`,address:i.address,addresses:[i.address],revisionKind:i.revisionKind,...i.markDirection?{markDirection:i.markDirection}:{},author:i.author,...i.date===void 0?{}:{date:i.date},text:i.revisionKind==="replace"?i.text:i.text||i.deletedText,replacedText:i.revisionKind==="replace"?i.deletedText:"",ranges:i.ranges,nesting:i.nesting,readOnly:i.readOnly,replyIds:[]}));return zs(a,An(t))}function zs(t,e){let n=Gs(t),r=n.filter(l=>(l.revisionKind==="insert"||l.revisionKind==="delete")&&!l.readOnly&&l.ranges.length>0),a=new Set,i=new Map,o=new Map;for(let l of r){if(l.revisionKind!=="insert")continue;let d=l.ranges[0].start,c=`${d.paragraphId}\0${d.offset}`,u=o.get(c);u?u.push(l):o.set(c,[l]);}for(let l of r){if(l.revisionKind!=="delete"||a.has(l.id))continue;let d=l.ranges[l.ranges.length-1].end,c=o.get(`${d.paragraphId}\0${d.offset}`)??[],u=c.length>1?[...c].sort((m,y)=>(m.text.length>0?0:1)-(y.text.length>0?0:1)):c;for(let m of u){if(a.has(m.id)||m.author!==l.author)continue;a.add(l.id),a.add(m.id);let y=Qs(l.ranges[0],m.ranges[0],e)?l:m,g=qs(l.date,m.date);i.set(l.id,{...y,id:`replace-${l.id}-${m.id}`,revisionKind:"replace",...g===void 0?{}:{date:g},addresses:Js([...l.addresses,...m.addresses]),text:m.text,replacedText:l.text,ranges:[...l.ranges,...m.ranges],replacedRangeCount:l.ranges.length,readOnly:l.readOnly||m.readOnly});break}}let s=[];for(let l of n){let d=i.get(l.id);if(d){s.push(d);continue}a.has(l.id)||s.push(l);}return s}function Gs(t){let e=t.filter(l=>(l.revisionKind==="insert"||l.revisionKind==="delete")&&!l.readOnly&&l.ranges.length>0);if(e.length<2)return t;let n=(l,d)=>`${l.revisionKind}\0${l.author}\0${d.paragraphId}\0${d.offset}`,r=new Map,a=new Set;for(let l of e)r.set(n(l,l.ranges[0].start),l),a.add(n(l,l.ranges[l.ranges.length-1].end));let i=new Set,o=new Map;for(let l of e){if(i.has(l.id)||a.has(n(l,l.ranges[0].start)))continue;let d=[l],c=l;for(;;){let u=r.get(n(c,c.ranges[c.ranges.length-1].end));if(!u||u===c||i.has(u.id))break;i.add(u.id),d.push(u),c=u;}d.length>1&&o.set(l.id,Xs(d));}if(o.size===0)return t;let s=[];for(let l of t)i.has(l.id)||s.push(o.get(l.id)??l);return s}function Xs(t){let e=t[0],n=[...e.addresses],r=[...e.ranges],a=e.text,i=e.date;for(let o of t.slice(1)){for(let s of o.addresses)n.some(l=>qa(l,s))||n.push(s);for(let s of o.ranges)r.push(s);a+=o.text,i=Ys(i,o.date);}return {...e,id:t.map(o=>o.id).join("+"),addresses:n,ranges:r,text:a,...i===void 0?{}:{date:i}}}function Ys(t,e){if(t===void 0)return e;if(e===void 0)return t;let n=Date.parse(t),r=Date.parse(e);return Number.isNaN(n)||Number.isNaN(r)?t:r>n?e:t}function Js(t){let e=[];for(let n of t)e.some(r=>qa(r,n))||e.push(n);return e}function qa(t,e){return t.id===e.id&&t.author===e.author&&(t.date??"")===(e.date??"")}function qs(t,e){if(e===void 0)return t;if(t===void 0)return e;let n=Date.parse(t),r=Date.parse(e);return Number.isNaN(n)||Number.isNaN(r)?e:n>r?t:e}function Qs(t,e,n){let r=n.get(t.start.paragraphId)??0,a=n.get(e.start.paragraphId)??0;return r!==a?r<a:t.start.offset<=e.start.offset}function Zs(t,e,n){let r=new Map(e.map(c=>[c.commentId,c])),a=new Map,i=new Map;for(let c of t)c.paraId&&a.set(c.paraId.toUpperCase(),c),i.set(c.id,c);let o=new Map,s=new Map;for(let c of t){let u=r.get(c.id);if(!u||u.orphaned||u.start.paragraphId===u.end.paragraphId&&u.start.offset===u.end.offset)continue;let m=`${u.start.paragraphId}:${u.start.offset}|${u.end.paragraphId}:${u.end.offset}`;o.has(m)?s.set(c.id,o.get(m)):o.set(m,c.id);}let l=new Map;for(let c of t){let u=c.paraId?n.get(c.paraId.toUpperCase()):void 0,m=u?.parentParaId?a.get(u.parentParaId):void 0,y=c.parentCommentId?i.get(c.parentCommentId):void 0,g=u===void 0?s.get(c.id):void 0,P=g?i.get(g):void 0,f=m??y??P;f&&f.id!==c.id&&l.set(c.id,f.id);}for(let c of [...l.keys()]){let u=new Set([c]),m=l.get(c);for(;m!==void 0;){if(u.has(m)){l.delete(c);break}u.add(m),m=l.get(m);}}let d=new Map;for(let[c,u]of l){let m=d.get(u);m?m.push(c):d.set(u,[c]);}return t.map(c=>{let u=r.get(c.id),m=c.paraId?n.get(c.paraId.toUpperCase()):void 0,y=l.get(c.id);return {kind:"comment",id:c.id,comment:c,range:u?{partName:u.partName,start:u.start,end:u.end}:null,resolved:m?.done??false,...y===void 0?{}:{parentId:y},replyIds:d.get(c.id)??[],orphaned:u===void 0||u.orphaned}})}function Zm(t){let e=[t.storyPart],n=new Set([t.storyPart.name]);for(let d of t.furnitureParts??[])n.has(d.name)||(n.add(d.name),e.push(d));let r=t.commentsPart?Pf(t.commentsPart):[],a=t.commentsExtendedPart?Qf(t.commentsExtendedPart):new Map,i=[],o=[],s=e.length===1?An(e[0]):new Map;for(let d of e){for(let m of Ws(d))i.push(m);for(let m of Of(d))o.push(m);if(e.length===1)continue;let c=s,u=c.size;for(let[m,y]of An(d))c.has(m)||c.set(m,u+y);}return el([...i,...Zs(r,o,a)]).sort((d,c)=>Mn(d,s)-Mn(c,s))}function Ka(t){return `${t.partName}\0${t.start.paragraphId}:${t.start.offset}|${t.end.paragraphId}:${t.end.offset}`}function el(t){let e=new Map;for(let o of t)if(o.kind==="revision")for(let s of o.ranges??[]){if(s.start.paragraphId===s.end.paragraphId&&s.start.offset===s.end.offset)continue;let l=Ka(s),d=o.nesting??0,c=e.get(l);(c===void 0||d>c.nesting)&&e.set(l,{id:o.id,nesting:d});}let n=new Map;for(let o of t)o.kind==="comment"&&o.replyIds&&o.replyIds.length>0&&n.set(o.id,o.replyIds);let r=o=>{let s=[],l=new Set([o]),d=[...n.get(o)??[]];for(;d.length>0;){let c=d.shift();l.has(c)||(l.add(c),s.push(c),d.push(...n.get(c)??[]));}return s},a=new Map,i=new Map;for(let o of t){if(o.kind!=="comment"||o.parentId!==void 0||o.orphaned||!o.range)continue;let s=e.get(Ka(o.range))?.id;if(s===void 0)continue;let l=[o.id,...r(o.id)];for(let c of l)i.set(c,s);let d=a.get(s);d?d.push(...l):a.set(s,l);}return t.map(o=>{if(o.kind==="revision"){let s=a.get(o.id)??[];return s.length===0&&(o.replyIds??[]).length===0?o:{...o,replyIds:s}}if(o.kind==="comment"){let s=i.get(o.id);if(s===void 0){if(o.parentRevisionId===void 0)return o;let{parentRevisionId:l,...d}=o;return d}return o.parentRevisionId===s?o:{...o,parentRevisionId:s}}return o})}function An(t){let e=za.get(t.root);if(e)return e;let n=new Map,r=(a,i)=>{if(!(a.kind==="textValue"||i>64)){if(a.kind==="paragraph"){n.has(a.id)||n.set(a.id,n.size);return}if(a.kind==="table"){let o=Ja.get(a);if(!o){let s=[],l=(d,c)=>{if(!(d.kind==="textValue"||c>64)){if(d.kind==="paragraph"){s.push(d.id);return}for(let u of d.children)l(u,c+1);}};for(let d of a.children)l(d,0);o=s,Ja.set(a,o);}for(let s of o)n.has(s)||n.set(s,n.size);return}for(let o of a.children)r(o,i+1);}};return r(t.root,0),za.set(t.root,n),n}var za=Mf(8);function eu(t){let e=Ya.get(t.root);if(e)return e;let n=new Map;for(let r of Qa(t.root,0))n.has(r)||n.set(r,n.size);return Ya.set(t.root,n),n}var Ga=Object.freeze([]),Xa=new WeakMap;function Qa(t,e){if(t.kind==="textValue"||e>64)return Ga;let n=Xa.get(t);if(n&&n.depth===e)return n.ids;let r=null;t.kind==="paragraph"&&(r??=[]).push(t.id);for(let i of t.children){let o=Qa(i,e+1);if(o.length!==0){r??=[];for(let s of o)r.push(s);}}let a=r??Ga;return Xa.set(t,{depth:e,ids:a}),a}var Ya=Mf(8),Ja=new WeakMap;var ru=256,ou=2e3,Za=/[\p{L}\p{N}_]/u;function ei(t){let e=t.toLowerCase();if(e.length===t.length)return e;let n="";for(let r=0;r<t.length;r+=1){let a=t[r],i=a.toLowerCase();n+=i.length===1?i:a;}return n}function tl(t,e,n){let r=e>0?t[e-1]:void 0,a=n<t.length?t[n]:void 0;return !(r!==void 0&&Za.test(r)||a!==void 0&&Za.test(a))}function nl(t){return typeof t=="string"&&t.length>0&&t.length<=256}function au(t,e,n,r={}){let a={matches:[],truncated:false};if(!nl(e)||t.length===0||n<=0)return a;let i=r.matchCase===true,o=r.wholeWord===true,s=i?e:ei(e),l=i?t:ei(t),d=Math.max(0,r.from??0),c=Math.min(t.length,r.to??t.length),u=[],m=l.indexOf(s,d);for(;m>=0;){let y=m+s.length;if(y>c)return {matches:u,truncated:false};if(!o||tl(t,m,y)){if(u.length>=n)return {matches:u,truncated:true};u.push({start:m,length:s.length});}m=l.indexOf(s,y);}return {matches:u,truncated:false}}
|
|
2
|
-
export{Hm as $,hm as A,ym as B,We as C,vn as D,Nn as E,Ns as F,Tn as G,wm as H,Ct as I,wn as J,Em as K,Ss as L,_a as M,ws as N,En as O,Es as P,Sn as Q,Cm as R,Mm as S,Dm as T,Am as U,Cn as V,$m as W,ja as X,As as Y,Mn as Z,Bs as _,ko as a,Bm as aa,vi as b,qm as ba,xo as c,Qm as ca,$e as d,Ws as da,os as e,Zs as ea,da as f,Zm as fa,ua as g,el as ga,pa as h,An as ha,gn as i,eu as ia,Nc as j,ru as ja,ca as k,ou as ka,Na as l,ei as la,Sa as m,tl as ma,Xc as n,nl as na,Yc as o,au as oa,Jc as p,nm as q,rm as r,om as s,Ps as t,Os as u,Ea as v,Ma as w,cm as x,mm as y,um as z};
|
package/dist/chunk-JWZG4QJ5.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkILTZTY3K_cjs=require('./chunk-ILTZTY3K.cjs'),fflate=require('fflate');function J(t){return t.kind!=="textValue"}function F(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===chunkILTZTY3K_cjs.ca}function ne(t,e){for(let n of t)e(n),n.kind!=="textValue"&&ne(n.children,e);}function pe(t){if(t.kind==="textValue")return `T(${t.value})`;if(t.namespaceUri===chunkILTZTY3K_cjs.ca&&t.localName.startsWith("rsid"))return "";let e=t.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===chunkILTZTY3K_cjs.fa&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=t.children.map(pe).join("");return `E(${t.namespaceUri}:${t.localName}[${e}]{${n}})`}function et(t){return `S[${t.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${t.children.map(pe).join("")}`}function It(t){let e=[],n=new Map,r=new Set,a=null;if(t&&J(t.root))for(let i of t.root.children){if(!J(i))continue;if(F(i,"docDefaults")){a=i;continue}if(!F(i,"style"))continue;e.push(i);let o=chunkILTZTY3K_cjs.ze(i,"styleId");o&&n.set(o,i);let s=i.children.find(d=>F(d,"name")),l=s?chunkILTZTY3K_cjs.ze(s,"val"):void 0;l&&r.add(l);}return {part:t,styles:e,docDefaults:a,byId:n,names:r}}function Pt(t,e,n){let r=new Map;if(!t)return r;let a=t.children.find(o=>F(o,e));if(!a||!J(a))return r;let i=a.children.find(o=>F(o,n));if(!i||!J(i))return r;for(let o of i.children)o.kind!=="textValue"&&r.set(o.localName,o);return r}function Zt(t,e,n,r){let a=e;for(let i=0;i<16&&a;i+=1){let o=t.byId.get(a);if(!o)return false;let s=o.children.find(d=>F(d,n));if(s&&J(s)&&s.children.some(d=>d.kind!=="textValue"&&d.localName===r))return true;let l=o.children.find(d=>F(d,"basedOn"));a=l?chunkILTZTY3K_cjs.ze(l,"val"):void 0;}return false}function oi(t,e){for(let n of t.styles){if(chunkILTZTY3K_cjs.ze(n,"type")!==e)continue;let r=chunkILTZTY3K_cjs.ze(n,"default");if(r==="1"||r==="true")return chunkILTZTY3K_cjs.ze(n,"styleId")}}function Ot(t,e){let n=t.children.find(r=>F(r,e));return n&&J(n)?n:null}var ai=new Map(["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"].map((t,e)=>[t,e])),ii=new Map(["rStyle","rFonts","b","bCs","i","iCs","caps","smallCaps","strike","dstrike","outline","shadow","emboss","imprint","noProof","snapToGrid","vanish","webHidden","color","spacing","w","kern","position","sz","szCs","highlight","u","effect","bdr","shd","fitText","vertAlign","rtl","cs","em","lang","eastAsianLayout","specVanish","oMath","rPrChange"].map((t,e)=>[t,e]));function en(t,e,n){let r=Pt(e.docDefaults,"rPrDefault","rPr"),a=Pt(n.docDefaults,"rPrDefault","rPr"),i=Pt(e.docDefaults,"pPrDefault","pPr"),o=Pt(n.docDefaults,"pPrDefault","pPr"),s=(f,x,p)=>{let h=oi(f,"paragraph"),N=h?f.byId.get(h):void 0;if(!N)return h;for(let[S,R]of [["rPr",x],["pPr",p]]){let v=Ot(N,S);if(v)for(let A of v.children)A.kind!=="textValue"&&R.set(A.localName,A);}return h};s(e,r,i),s(n,a,o);let l=new Map;for(let[f,x]of r){let p=a.get(f);(!p||pe(p)!==pe(x))&&l.set(f,x);}let d=new Map;for(let[f,x]of i){if(f==="sectPr")continue;let p=o.get(f);(!p||pe(p)!==pe(x))&&d.set(f,x);}if(l.size===0&&d.size===0)return t;let c=0,u=()=>`fragment#materialized-${c++}`,m=f=>{let x=p=>p.kind==="textValue"?{id:u(),kind:"textValue",value:p.value}:{...p,id:u(),children:p.children.map(x)};return x(f)},y=(f,x,p)=>{if(p.length===0)return f;let h=Ot(f,x);if(h){let S=x==="rPr"?ii:ai,R=[...h.children];for(let A of p){let V=A.kind==="textValue"?Number.MAX_SAFE_INTEGER:S.get(A.localName)??Number.MAX_SAFE_INTEGER,Z=R.length;for(let D=0;D<R.length;D+=1){let B=R[D];if(B.kind==="textValue")continue;let $=S.get(B.localName);if($!==void 0&&$>V){Z=D;break}}R.splice(Z,0,A);}let v={...h,children:R};return {...f,children:f.children.map(A=>A===h?v:A)}}let N={id:u(),kind:x==="rPr"?"runProperties":"paragraphProperties",namespaceUri:chunkILTZTY3K_cjs.ca,localName:x,prefix:"w",namespaceBindings:[],attributes:[],children:p};return {...f,children:[N,...f.children]}},g=f=>{let x=Ot(f,"pPr"),p=x?.children.find(v=>F(v,"pStyle")),h=p?chunkILTZTY3K_cjs.ze(p,"val"):void 0,N=[];for(let[v,A]of d)x?.children.some(Z=>Z.kind!=="textValue"&&Z.localName===v)||h&&Zt(e,h,"pPr",v)||N.push(m(A));let S=v=>{if(v.kind==="textValue")return v;if(v.kind==="run"){let V=Ot(v,"rPr"),Z=V?.children.find($=>F($,"rStyle")),D=Z?chunkILTZTY3K_cjs.ze(Z,"val"):void 0,B=[];for(let[$,G]of l)V?.children.some(M=>M.kind!=="textValue"&&M.localName===$)||D&&Zt(e,D,"rPr",$)||h&&Zt(e,h,"rPr",$)||B.push(m(G));return y(v,"rPr",B)}if(v.kind==="paragraphProperties"||v.kind==="runProperties")return v;let A=v.children.map(S);return A.some((V,Z)=>V!==v.children[Z])?{...v,children:A}:v};return S(y(f,"pPr",N))},P=f=>{if(f.kind==="textValue")return f;if(f.kind==="paragraph")return g(f);let x=f.children.map(P);return x.some((p,h)=>p!==f.children[h])?{...f,children:x}:f};return t.map(P)}function si(t,e){return {...t,children:e}}function li(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===chunkILTZTY3K_cjs.ca}var di=new Set(["commentRangeStart","commentRangeEnd"]),ci=new Set(["altChunk","subDoc"]);function mi(t){return t.kind==="run"&&t.children.some(e=>e.kind==="commentReference")}var ui=new Set(["DDE","DDEAUTO","INCLUDE","INCLUDEPICTURE","INCLUDETEXT","IMPORT","LINK","DATABASE","AUTOTEXT","AUTOTEXTLIST","GOTOBUTTON","MACROBUTTON","PRINT","ADDIN"]);function oo(t){if(t===void 0)return false;let e=t.trim().replace(/^"+/,"").split(/\s+/,1)[0]??"";return ui.has(e.toUpperCase())}function pi(t){if(t.kind!=="run")return null;for(let e of t.children)if(e.kind==="fldChar"){let n=chunkILTZTY3K_cjs.ze(e,"fldCharType");return n==="separate"||n==="end"?n:"begin"}return null}function fi(t){if(t.kind!=="run")return null;let e="",n=false;for(let r of t.children)if(r.kind==="instrText"){n=true;for(let a of r.children)a.kind==="textValue"&&(e+=a.value);}return n?e:null}function gi(t){let e=[],n=new Set,r=i=>{if(i.dangerous){for(let o of i.machinery)n.add(o);for(let o of i.instr)n.add(o);for(let o of i.preResult)n.add(o);}},a=i=>{if(i.kind!=="textValue"){if(i.kind==="run"){let o=pi(i);if(o==="begin"){e.push({dangerous:false,afterSeparate:false,machinery:[i.id],instr:[],preResult:[]});return}let s=e[e.length-1];if(s){if(o==="separate"){s.afterSeparate=true,s.machinery.push(i.id);return}if(o==="end"){s.machinery.push(i.id),e.pop(),r(s);return}let l=fi(i);if(l!==null){s.instr.push(i.id),oo(l)&&(s.dangerous=true);return}s.afterSeparate||s.preResult.push(i.id);return}return}for(let o of i.children)a(o);}};for(let i of t)a(i);for(;e.length>0;){let i=e.pop();i.dangerous=true,r(i);}return n}function hi(t,e){if(t.kind==="textValue")return t;if(t.namespaceUri===chunkILTZTY3K_cjs.ca&&(di.has(t.localName)||t.localName==="sectPr"||ci.has(t.localName))||mi(t)||e.has(t.id))return "drop";if(li(t,"fldSimple")&&oo(chunkILTZTY3K_cjs.ze(t,"instr")))return tn(t.children,e);let n=tn(t.children,e);return n.length===t.children.length&&n.every((r,a)=>r===t.children[a])?t:si(t,n)}function tn(t,e){let n=[];for(let r of t){let a=hi(r,e);a!=="drop"&&(Array.isArray(a)?n.push(...a):n.push(a));}return n}function nn(t){let e=gi(t);return tn(t,e)}var ao="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function q(t,e,n,r){return {...t,attributes:t.attributes.map(a=>a.localName===n&&a.namespaceUri===e?{...a,value:r}:a)}}var yi=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),rn=chunkILTZTY3K_cjs.We,fe=new Map;function Le(t,e){let n=e.styleIds??fe,r=e.numIds??fe,a=e.relIds??fe,i=e.footnoteIds??fe,o=e.endnoteIds??fe,s=e.bookmarkIds??fe,l=e.sdtIds??fe,d=e.revisionIds??fe,c=e.docPrIds??fe,u=(m,y)=>{if(m.kind==="textValue")return m;let g=m;if(m.namespaceUri===chunkILTZTY3K_cjs.ca&&yi.has(m.localName)){let p=chunkILTZTY3K_cjs.ze(m,"val"),h=p!==void 0?n.get(p):void 0;h!==void 0&&(g=q(g,chunkILTZTY3K_cjs.ca,"val",h));}if(F(m,"numId")){let p=chunkILTZTY3K_cjs.ze(m,"val"),h=p!==void 0?r.get(p):void 0;h!==void 0&&(g=q(g,chunkILTZTY3K_cjs.ca,"val",h));}if(m.kind==="noteReference"){let p=m.localName==="footnoteReference"?i:o,h=chunkILTZTY3K_cjs.ze(m,"id"),N=h!==void 0?p.get(h):void 0;N!==void 0&&(g=q(g,chunkILTZTY3K_cjs.ca,"id",N));}if(m.kind==="bookmarkStart"||m.kind==="bookmarkEnd"){let p=chunkILTZTY3K_cjs.ze(m,"id"),h=p!==void 0?s.get(p):void 0;h!==void 0&&(g=q(g,chunkILTZTY3K_cjs.ca,"id",h));}if(F(m,"id")&&y==="sdtPr"){let p=chunkILTZTY3K_cjs.ze(m,"val"),h=p!==void 0?l.get(p):void 0;h!==void 0&&(g=q(g,chunkILTZTY3K_cjs.ca,"val",h));}if(rn(m)){let p=chunkILTZTY3K_cjs.ze(m,"id"),h=p!==void 0?d.get(p):void 0;h!==void 0&&(g=q(g,chunkILTZTY3K_cjs.ca,"id",h));}if(m.kind==="drawingDocPr"){let p=m.attributes.find(N=>N.localName==="id"&&N.namespaceUri==="")?.value,h=p!==void 0?c.get(p):void 0;h!==void 0&&(g=q(g,"","id",h));}for(let p of g.attributes){if(p.namespaceUri!==ao)continue;let h=a.get(p.value);h!==void 0&&h!==p.value&&(g=q(g,ao,p.localName,h));}let P=m.localName,f=g.children.map(p=>u(p,P));return g!==m||f.some((p,h)=>p!==g.children[h])?{...g,children:f}:m};return u(t,"")}function io(t,e,n){let r=t,a=n.get(t)??2;for(;e.has(r);)r=`${t}${a}`,a+=1;return n.set(t,a),r}function so(t,e,n){let r=`${t} (pasted)`,a=n.get(t)??2;for(;e.has(r);)r=`${t} (pasted ${a})`,a+=1;return n.set(t,a),r}var ki=1e5;function lo(t){let e=chunkILTZTY3K_cjs.Eb(),n=xi(t,e),r=Pi(t,e),a=Oi(t,e);return !n||!r||!a?null:{bookmarkIds:n,revisionIds:r,docPrIds:a}}function on(t,e,n,r){if(t)return chunkILTZTY3K_cjs.Gb(e,t,r);let a=n;return ()=>String(a++)}function co(t,e){if(t.add(e),!/^\d{1,10}$/.test(e))return;let n=Number(e);n<=chunkILTZTY3K_cjs.Cb&&t.add(String(n));}function mo(t,e){if(e===void 0)return t;let n=Number(e);return Number.isInteger(n)&&n>t?n:t}function xi(t,e){let n=new Map;if(t.fragmentBookmarkIds.length===0)return n;let r=0,a=new Set;for(let o of [t.ownerPart,...t.notesParts])ne([o.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=chunkILTZTY3K_cjs.ze(s,"id");l!==void 0&&(co(a,l),s.kind==="bookmarkStart"&&(r=mo(r,l)));});let i=on(e,a,r+1,chunkILTZTY3K_cjs.Cb);for(let o of t.fragmentBookmarkIds){if(n.has(o))continue;let s=i();if(s===null)return null;n.set(o,s);}return n}function Pi(t,e){let n=new Map;if(!t.hasRevision)return n;let r=0,a=new Set;for(let s of [t.ownerPart,...t.notesParts]){let l=s===t.ownerPart;ne([s.root],d=>{if(!chunkILTZTY3K_cjs.We(d))return;let c=chunkILTZTY3K_cjs.ze(d,"id");c!==void 0&&co(a,c),l&&(r=mo(r,c));});}let i=on(e,a,r+1,chunkILTZTY3K_cjs.Cb),o=false;return ne(t.travelling,s=>{if(o||!chunkILTZTY3K_cjs.We(s))return;let l=chunkILTZTY3K_cjs.ze(s,"id");if(l===void 0||n.has(l))return;let d=i();d===null?o=true:n.set(l,d);}),o?null:n}function Oi(t,e){let n=new Map;if(!t.hasDocPr)return n;let{used:r}=chunkILTZTY3K_cjs.Ib(t.pkg),a=ki;if(!e){let s=chunkILTZTY3K_cjs.Jb(t.pkg);s.ok&&(a=s.id);}let i=on(e,r,a,chunkILTZTY3K_cjs.Hb),o=false;return ne(t.travelling,s=>{if(o||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(c=>c.localName==="id"&&c.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let d=i();d===null?o=true:n.set(l,d);}),o?null:n}var be="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ii=`${be}/hyperlink`,uo=`${be}/image`,Rt=`${be}/numbering`,an=`${be}/styles`,po="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",fo="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function tt(t,e,n,r){for(let a of chunkILTZTY3K_cjs.Zb(t,e)){if(a.type!==n||a.targetMode==="External")continue;let i=chunkILTZTY3K_cjs.w(a.ownerPart,a.rawTarget);if(i.ok){let o=t.parts.get(i.partName);if(o)return o}}return t.parts.get(r)??null}function sn(t,e){let n=0;return ne([t],r=>{let a=e(r);if(a===void 0)return;let i=Number(a);Number.isInteger(i)&&i>n&&(n=i);}),n}function bt(t,e,n,r){if(n.length===0)return t;let a=chunkILTZTY3K_cjs.Aa(e,"paste"),i=n.map(d=>chunkILTZTY3K_cjs.De(d,a)),o=chunkILTZTY3K_cjs.ch(e,i),s=r??o.root.children.length,l=chunkILTZTY3K_cjs.Ga(o,o.root.id,s,i,{deferValidation:true});return l.ok?chunkILTZTY3K_cjs.Xb(t,l.part):null}function go(t){let e=new Set;return ne(t,n=>{if(n.kind!=="textValue")for(let r of n.attributes)r.namespaceUri===be&&r.value.length>0&&e.add(r.value);}),e}function ho(t,e){if(e.size===0)return [...t];let n=a=>{if(a.kind==="textValue")return a;if(a.kind==="drawing"){let o=false;return ne([a],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===be&&e.has(l.value)&&(o=true);}),o?null:a}if(a.kind==="hyperlink"){let o=a.attributes.find(s=>s.namespaceUri===be)?.value;if(o!==void 0&&e.has(o))return r(a.children)}let i=r(a.children);return i.length===a.children.length&&i.every((o,s)=>o===a.children[s])?a:{...a,children:i}};function r(a){let i=[];for(let o of a){let s=n(o);s!==null&&(Array.isArray(s)?i.push(...s):i.push(s));}return i}return r(t)}var Ri=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),yo={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function bi(t,e){let n=chunkILTZTY3K_cjs.lb(t);return n==="unknown"||(Object.hasOwn(yo,e)?yo[e]:e)!==n||Ri.has(n)&&!chunkILTZTY3K_cjs.Kb(t,n)?null:n}function ko(t,e,n){let r=e.parts.get(e.mainDocumentPart);if(!r)return {ok:false,reason:"no-fragment-document"};if(!t.parts.has(n))return {ok:false,reason:"no-target-part"};let a=r.root.kind==="document"?r.root.children.find(k=>k.kind==="body"):null;if(!a||!J(a))return {ok:false,reason:"no-fragment-document"};let i=nn(a.children.filter(k=>k.kind==="paragraph"||k.kind==="table"||k.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let o=t,s=tt(e,e.mainDocumentPart,Rt,"/word/numbering.xml"),l=new Map,d=[],c=[];if(s&&J(s.root)){let k=new Map,O=[];for(let C of s.root.children)if(J(C))if(F(C,"abstractNum")){let U=chunkILTZTY3K_cjs.ze(C,"abstractNumId");U&&k.set(U,C);}else F(C,"num")&&O.push(C);let I=tt(o,o.mainDocumentPart,Rt,"/word/numbering.xml"),b=new Map,E=new Map;if(I&&J(I.root)){for(let C of I.root.children)if(J(C)&&F(C,"abstractNum")){let U=chunkILTZTY3K_cjs.ze(C,"abstractNumId");U&&E.set(U,C);}for(let C of I.root.children){if(!J(C)||!F(C,"num"))continue;let U=chunkILTZTY3K_cjs.ze(C,"numId");if(!U)continue;let X=C.children.find(H=>F(H,"abstractNumId")),z=X?chunkILTZTY3K_cjs.ze(X,"val"):void 0,re=z?E.get(z):void 0;b.set(`${re?et(re):"none"}::${C.children.filter(H=>F(H,"lvlOverride")).map(pe).join("")}`,U);}}let _=(I?sn(I.root,C=>C.kind!=="textValue"&&F(C,"abstractNum")?chunkILTZTY3K_cjs.ze(C,"abstractNumId"):void 0):0)+1,W=(I?sn(I.root,C=>C.kind!=="textValue"&&F(C,"num")?chunkILTZTY3K_cjs.ze(C,"numId"):void 0):0)+1,le=new Map;for(let C of O){let U=chunkILTZTY3K_cjs.ze(C,"numId");if(!U)continue;let X=C.children.find(he=>F(he,"abstractNumId")),z=X?chunkILTZTY3K_cjs.ze(X,"val"):void 0,re=z?k.get(z):void 0,H=`${re?et(re):"none"}::${C.children.filter(he=>F(he,"lvlOverride")).map(pe).join("")}`,K=b.get(H);if(K!==void 0){l.set(U,K);continue}let ee=z?le.get(z):void 0;ee===void 0&&re&&z&&(ee=String(_++),le.set(z,ee),c.push(q(re,chunkILTZTY3K_cjs.ca,"abstractNumId",ee)));let Se=String(W++);l.set(U,Se);let xe=q(C,chunkILTZTY3K_cjs.ca,"numId",Se);if(ee!==void 0){let he=xe.children.map(Te=>F(Te,"abstractNumId")?q(Te,chunkILTZTY3K_cjs.ca,"val",ee):Te);xe={...xe,children:he};}d.push(xe),b.set(H,Se);}}let u=It(tt(e,e.mainDocumentPart,an,"/word/styles.xml")),m=tt(o,o.mainDocumentPart,an,"/word/styles.xml"),y=It(m),g=new Map,P=[],f=new Set(y.byId.keys()),x=new Set(y.names),p=new Map,h=new Map,N=new Map,S=(k,O)=>{let I=N.get(k);return I===void 0&&(I=et(O),N.set(k,I)),I},R=k=>({...k,attributes:k.attributes.filter(O=>!(O.localName==="default"&&O.namespaceUri===chunkILTZTY3K_cjs.ca))});for(let k of u.styles){let O=chunkILTZTY3K_cjs.ze(k,"styleId");if(!O)continue;let I=y.byId.get(O),b=et(Le(k,{styleIds:g,numIds:l}));if(I&&S(O,I)===b){g.set(O,O);continue}if(!I){g.set(O,O),f.add(O),P.push(R(k));continue}let E=io(`${O}Pasted`,f,p);f.add(E),g.set(O,E),P.push(R(q(k,chunkILTZTY3K_cjs.ca,"styleId",E)));}let v=P.map(k=>{let O=k.children.find(_=>F(_,"name")),I=O?chunkILTZTY3K_cjs.ze(O,"val"):void 0;if(!I||!x.has(I))return I&&x.add(I),k;let b=so(I,x,h);x.add(b);let E=k.children.map(_=>F(_,"name")?q(_,chunkILTZTY3K_cjs.ca,"val",b):_);return {...k,children:E}}),A=null,V=1,Z=()=>{if(A)return A;let k=new Map;for(let[O,I]of o.partBytes){let b=O.startsWith("/")?O:`/${O}`;if(!b.startsWith("/word/media/"))continue;k.set(chunkILTZTY3K_cjs.a(I),b);let E=/\/image(\d+)\./.exec(b);E&&(V=Math.max(V,Number(E[1])+1));}return A=k,k},D=new Map,B=k=>{let O=D.get(k);if(!O){O=new Map;for(let I of chunkILTZTY3K_cjs.Zb(o,k)){if(I.targetMode==="External"||I.type!==uo)continue;let b=chunkILTZTY3K_cjs.w(I.ownerPart,I.rawTarget);b.ok&&O.set(b.partName,I.id);}D.set(k,O);}return O},$=(k,O)=>{let I=k.lastIndexOf("."),b=I===-1?"":k.slice(I+1);return /^[A-Za-z0-9]{1,8}$/.test(b)?b.toLowerCase():O==="image/jpeg"?"jpeg":O==="image/gif"?"gif":"png"},G=(k,O,I)=>{let b=new Map,E=new Set,_=B(O),W=[],le=new Set,C=[],U=[],X=new Map,z=[],re=e.relationships.get(k)??[];for(let H of re){if(!I.has(H.id))continue;if(H.targetMode==="External"){if(H.type===Ii){let we=chunkILTZTY3K_cjs.Ed(o,H.rawTarget,O);we?(o=we.pkg,b.set(H.id,we.relationshipId)):E.add(H.id);}else E.add(H.id);continue}let K=chunkILTZTY3K_cjs.w(H.ownerPart,H.rawTarget);if(!K.ok){E.add(H.id);continue}let ee=e.partBytes.get(K.partName)??e.partBytes.get(K.partName.replace(/^\//,"")),Se=(chunkILTZTY3K_cjs._b(e,K.partName)??"").toLowerCase();if(!ee||!Se.startsWith("image/")){E.add(H.id);continue}let xe=bi(ee,Se);if(xe===null){E.add(H.id);continue}let he=xe,Te=Z(),jn=chunkILTZTY3K_cjs.a(ee),oe=Te.get(jn);if(!oe){let we=$(K.partName,he),ri=ct=>o.partBytes.has(ct)||o.partBytes.has(ct.slice(1))||o.parts.has(ct)||le.has(ct),_t=`/word/media/image${V}.${we}`;for(;ri(_t);)V+=1,_t=`/word/media/image${V}.${we}`;V+=1,oe=_t,W.push({partName:oe,bytes:ee,contentType:he}),le.add(oe),Te.set(jn,oe);}let ni=oe.startsWith("/word/")?oe.slice(6):oe,Vn=_.get(oe);if(Vn!==void 0){b.set(H.id,Vn);continue}let dt=X.get(oe);dt===void 0&&(dt=C.length,X.set(oe,dt),C.push(ni),U.push(oe)),z.push({recordId:H.id,index:dt});}if(W.length>0&&(o=chunkILTZTY3K_cjs.Ob(o,W)),C.length>0){let H=chunkILTZTY3K_cjs.bc(chunkILTZTY3K_cjs.cc(o,O),O,C.map(K=>[uo,K]));if(H.ok){o=H.pkg,H.ids.forEach((K,ee)=>{_.set(U[ee],K);});for(let K of z)b.set(K.recordId,H.ids[K.index]);}else for(let K of z)E.add(K.recordId);}return {relIdMap:b,dropRelIds:E}},ae=G(e.mainDocumentPart,n,go(i));i=ho(i,ae.dropRelIds);let M=new Map,st=new Map,Q=[];for(let k of ["footnote","endnote"]){let O=k==="footnote"?"footnoteReference":"endnoteReference",I=k==="footnote"?M:st,b=new Set;if(ne(i,U=>{if(U.kind!=="textValue"&&U.kind==="noteReference"&&U.localName===O){let X=chunkILTZTY3K_cjs.ze(U,"id");X!==void 0&&b.add(X);}}),b.size===0)continue;let E=chunkILTZTY3K_cjs.Pe(e,k);if(!E||!J(E.root))continue;let _=chunkILTZTY3K_cjs.df(o,k);if(!_.ok||!_.package)return {ok:false,reason:"merge-refused"};o=_.package;let W=chunkILTZTY3K_cjs.Pe(o,k);if(!W)return {ok:false,reason:"merge-refused"};let le=sn(W.root,U=>U.kind!=="textValue"&&U.kind==="note"?chunkILTZTY3K_cjs.ze(U,"id"):void 0)+1,C=[];for(let U of E.root.children){if(!J(U)||U.kind!=="note")continue;let X=chunkILTZTY3K_cjs.ze(U,"id"),z=chunkILTZTY3K_cjs.ze(U,"type");if(z==="separator"||z==="continuationSeparator"||X===void 0||!b.has(X))continue;let re=String(le++);I.set(X,re),C.push(q(U,chunkILTZTY3K_cjs.ca,"id",re));}C.length>0&&Q.push({kind:k,fragmentPartName:E.name,bodies:nn(C)});}let Ne=o.parts.get(n),_n=[...i,...Q.flatMap(k=>k.bodies)],Un=[],At=new Set,Ln=false,Fn=false,Ke=new Map;ne(_n,k=>{if(k.kind!=="textValue"){if(k.kind==="bookmarkStart"||k.kind==="bookmarkEnd"){let O=chunkILTZTY3K_cjs.ze(k,"id");if(O!==void 0&&Un.push(O),k.kind==="bookmarkStart"){let I=chunkILTZTY3K_cjs.ze(k,"name");I&&At.add(I);}return}if(rn(k)){Ln=true;return}if(k.kind==="drawingDocPr"){Fn=true;return}if(k.kind==="contentControlProperties")for(let O of k.children){if(!F(O,"id"))continue;let I=chunkILTZTY3K_cjs.ze(O,"val");if(I!==void 0&&!Ke.has(I)){let b=0,E=`${I}:${Ke.size}`;for(let _=0;_<E.length;_+=1)b=b*31+E.charCodeAt(_)>>>0;Ke.set(I,String(b%2147483647||1));}}}});let lt=lo({pkg:o,ownerPart:Ne,notesParts:Q.map(k=>chunkILTZTY3K_cjs.Pe(o,k.kind)).filter(k=>k!==null),travelling:_n,fragmentBookmarkIds:Un,hasRevision:Ln,hasDocPr:Fn});if(!lt)return {ok:false,reason:"merge-refused"};let $n=lt.bookmarkIds,Hn=lt.revisionIds,Bn=lt.docPrIds;if(At.size>0){let k=new Set;if(ne([Ne.root],O=>{if(O.kind!=="textValue"&&O.kind==="bookmarkStart"){let I=chunkILTZTY3K_cjs.ze(O,"name"),b=chunkILTZTY3K_cjs.ze(O,"id");I&&b!==void 0&&At.has(I)&&k.add(b);}}),k.size>0){let O=b=>{if(b.kind==="textValue")return b;let E=[],_=false;for(let W of b.children){if((W.kind==="bookmarkStart"||W.kind==="bookmarkEnd")&&k.has(chunkILTZTY3K_cjs.ze(W,"id")??"")){_=true;continue}let le=O(W);le!==W&&(_=true),E.push(le);}return _?{...b,children:E}:b},I=O(Ne.root);I!==Ne.root&&(chunkILTZTY3K_cjs.Ea(Ne.root,I),o=chunkILTZTY3K_cjs.Xb(o,{...Ne,root:I}));}}for(let k of Q){let O=chunkILTZTY3K_cjs.Pe(o,k.kind);if(!O)return {ok:false,reason:"merge-refused"};let I=G(k.fragmentPartName,O.name,go(k.bodies)),b=ho(k.bodies,I.dropRelIds);b=[...en(b,u,y)],b=b.map(_=>Le(_,{styleIds:g,numIds:l,relIds:I.relIdMap,footnoteIds:M,endnoteIds:st,bookmarkIds:$n,sdtIds:Ke,revisionIds:Hn,docPrIds:Bn}));let E=bt(o,o.parts.get(O.name),b);if(!E)return {ok:false,reason:"merge-refused"};o=E;}if(v.length>0){let k=v.map(I=>Le(I,{styleIds:g,numIds:l}));if(!m){let I=chunkILTZTY3K_cjs.ta(`<w:styles xmlns:w="${chunkILTZTY3K_cjs.ca}"></w:styles>`,{name:"/word/styles.xml",contentType:fo});if(!I.ok)return {ok:false,reason:"merge-refused"};o=chunkILTZTY3K_cjs.ec(o,"/word/styles.xml",I.part.root,fo);let b=chunkILTZTY3K_cjs.dc(chunkILTZTY3K_cjs.cc(o,o.mainDocumentPart),o.mainDocumentPart,an,"styles.xml");if(!b.ok)return {ok:false,reason:"merge-refused"};o=b.pkg,m=o.parts.get("/word/styles.xml")??null;}if(!m)return {ok:false,reason:"merge-refused"};let O=bt(o,o.parts.get(m.name),k);if(!O)return {ok:false,reason:"merge-refused"};o=O,y=It(o.parts.get(m.name)??null);}if(c.length>0||d.length>0){let k=tt(o,o.mainDocumentPart,Rt,"/word/numbering.xml");if(!k){let _=chunkILTZTY3K_cjs.ta(`<w:numbering xmlns:w="${chunkILTZTY3K_cjs.ca}"></w:numbering>`,{name:"/word/numbering.xml",contentType:po});if(!_.ok)return {ok:false,reason:"merge-refused"};o=chunkILTZTY3K_cjs.ec(o,"/word/numbering.xml",_.part.root,po);let W=chunkILTZTY3K_cjs.dc(chunkILTZTY3K_cjs.cc(o,o.mainDocumentPart),o.mainDocumentPart,Rt,"numbering.xml");if(!W.ok)return {ok:false,reason:"merge-refused"};o=W.pkg,k=o.parts.get("/word/numbering.xml")??null;}if(!k)return {ok:false,reason:"merge-refused"};let O=o.parts.get(k.name),I=O.root.children.findIndex(_=>F(_,"num")),b=c.map(_=>Le(_,{styleIds:g,numIds:l})),E=bt(o,O,b,I===-1?void 0:I);if(!E)return {ok:false,reason:"merge-refused"};if(o=E,E=bt(o,o.parts.get(k.name),d),!E)return {ok:false,reason:"merge-refused"};o=E;}let ti=[...en(i,u,y)].map(k=>Le(k,{styleIds:g,numIds:l,relIds:ae.relIdMap,footnoteIds:M,endnoteIds:st,bookmarkIds:$n,sdtIds:Ke,revisionIds:Hn,docPrIds:Bn}));return {ok:true,pkg:o,blocks:ti}}var vi=16*1024*1024;function Ni(t){let e=t.parts.get(t.mainDocumentPart);if(!e||e.root.kind!=="document")return false;let n=e.root.children.find(i=>i.kind==="body");if(!n||n.kind!=="body"||n.children.length>chunkILTZTY3K_cjs.$g)return false;let r=0,a=(i,o,s)=>{if(o>s||(r+=1,r>chunkILTZTY3K_cjs.bh))return false;if(i.kind==="textValue")return true;for(let l of i.children)if(!a(l,o+1,s))return false;return true};for(let i of n.children)if(!a(i,1,chunkILTZTY3K_cjs.ah))return false;for(let[i,o]of t.parts)if(i!==t.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!a(o.root,1,chunkILTZTY3K_cjs.ah*4))return false;return true}function xo(t,e,n){if(n.fragmentBytes.byteLength>vi)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=chunkILTZTY3K_cjs.Vb(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let a=r.package;if(!Ni(a))return {ok:false,reason:"invalidArgs",detail:"fragment-over-budget"};let i=t.resolveStory(e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let{store:o,story:s}=i;if(o.compositionActive||t.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=t.currentPackage(),d=o.checkpoint(),c=o.historyDepth,u=0,m="";return chunkILTZTY3K_cjs.xa(t,()=>{let y=o.transact(P=>{for(let h of n.priorOps??[])if(!P.apply(h))return;let f=null,x=P.applyPackage(h=>(f=ko(h,a,s.partName),f.ok?f.pkg:h)),p=f;if(!p||!p.ok){m=`fragment-merge:${p?p.reason:"no-merge"}`,P.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}x&&(u=p.blocks.length,P.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:p.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return m.length>0?{ok:false,reason:"invalidArgs",detail:m}:y.ok?y.change?{ok:true,change:t.promoteStoryTransactionToPackageUnit(l,o,d,c),blockCount:u}:{ok:true,change:null,blockCount:u}:{ok:false,reason:y.reason,...y.detail?{detail:y.detail}:{}}},y=>chunkILTZTY3K_cjs.ya(y))}function Si(t){if(!(t===null||t.start!==t.end))return t}var Fe={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function Ti(t){return Object.freeze({parts:new Map([[t.name,t]]),partBytes:new Map,relationships:new Map,externalTargets:[],contentTypes:{defaults:new Map,overrides:new Map([[t.name.toLowerCase(),t.contentType]])},mainDocumentPart:t.name})}var $e=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];subscribers=new Set;historyLimit;settingsPartOverride;storyRef=null;composition=null;constructor(e,n,r={}){let a="root"in e,i=typeof n=="string"?n:void 0,o=typeof n=="object"&&n!==null?n:r;this.current=a?Ti(e):e,this.storyPartName=i??(a?e.name:e.mainDocumentPart),this.historyLimit=o.historyLimit??200,this.settingsPartOverride=o.settingsPart;}setStoryRef(e){this.storyRef=e;}get part(){let e=this.current.parts.get(this.storyPartName);if(!e)throw new Error(`story part missing: ${this.storyPartName}`);return e}get package(){return this.current}get revision(){return this.rev}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get historyDepth(){return this.undoStack.length}get compositionActive(){return this.composition!==null}graftPackage(e){this.current=e(this.current);}replacePart(e){let n=this.current.parts.get(e.name);e!==n&&(this.current=chunkILTZTY3K_cjs.Xb(this.current,e),this.rev+=1);}checkpoint(){return {pkg:this.current,revision:this.rev,undoStack:this.undoStack.slice(),redoStack:this.redoStack.slice(),composition:this.composition?{entry:{...this.composition.entry},committed:this.composition.committed}:null}}restoreCheckpoint(e){this.current=e.pkg,this.rev=e.revision,this.undoStack.length=0,this.undoStack.push(...e.undoStack),this.redoStack.length=0,this.redoStack.push(...e.redoStack),this.composition=e.composition?{entry:{...e.composition.entry},committed:e.composition.committed}:null;}restoreHistoryStacks(e){this.undoStack.length=0,this.undoStack.push(...e.undoStack),this.redoStack.length=0,this.redoStack.push(...e.redoStack);}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}transact(e,n={}){return chunkILTZTY3K_cjs.Db(n.actorId,()=>this.commitTransaction(e,n))}commitTransaction(e,n){let r=n.origin??chunkILTZTY3K_cjs.b.mutationHuman,a=this.current,i=this.rev,o=this.current,s=null,l=0,d=new Set,c=new Set,u=new Set,m=new Set,y=new Set,g=[],P=n.minimumImpact??"text-local",f=null,x=false,p=null,h=null,N=new Map,S=(D,B)=>{let $=chunkILTZTY3K_cjs.xg.get(D.op);if($===void 0)return N.clear(),null;let G=`${B.name}\0${$}`,ae=N.get(G);ae||(ae={id:null},N.set(G,ae));let M=ae;return ()=>M.id??=chunkILTZTY3K_cjs.Ve(B)()},R=(D,B)=>{if(s)return false;let $=o.parts.get(D);if(!$)return s={reason:"unknown-part",detail:D},false;let G=chunkILTZTY3K_cjs.Ag($,this.settingsPartOverride?.()??chunkILTZTY3K_cjs.pe(o),B);if(G)return s={reason:G},false;let ae=S(B,$),M=chunkILTZTY3K_cjs.Zg($,B,{deferValidation:true,...ae?{revisionIds:ae}:{}});if(!M.ok)return s={reason:M.reason,...M.detail?{detail:M.detail}:{}},false;if(o=chunkILTZTY3K_cjs.Xb(o,M.part),M.part===$&&M.effect.dirty.length===0&&M.effect.created.length===0&&M.effect.deleted.length===0&&M.effect.split===void 0&&(M.effect.splits===void 0||M.effect.splits.length===0)&&M.effect.join===void 0&&M.effect.caret===void 0)return true;d.add(D),l+=1;for(let Q of M.effect.dirty)c.add(Q);for(let Q of M.effect.created)u.add(Q);for(let Q of M.effect.deleted)m.add(Q);for(let Q of M.effect.dependencyKeys)y.add(Q);M.effect.split&&g.push({split:M.effect.split});for(let Q of M.effect.splits??[])g.push({split:Q});return M.effect.join&&g.push({join:M.effect.join}),Fe[M.effect.impact]>Fe[P]&&(P=M.effect.impact),M.effect.caret&&(h={paragraphId:M.effect.caret.paragraphId,start:0,end:0}),true};if(e({apply:D=>R(this.storyPartName,D),applyTo:(D,B)=>R(D,B),applyPackage:D=>{if(s)return false;N.clear();let B=D(o);if(B===o)return true;for(let[$,G]of B.parts)o.parts.get($)!==G&&d.add($);return o=B,l+=1,Fe["flow-structural"]>Fe[P]&&(P="flow-structural"),true},selectionBefore:D=>{f=D;},selectionAfter:D=>{x=true,p=D;}}),s){let D=s;return {ok:false,reason:D.reason,...D.detail?{detail:D.detail}:{}}}if(l===0)return {ok:true,change:null};let v=x?p:h,A=x?Si(p):h??void 0;for(let D of d){let B=a.parts.get(D),$=o.parts.get(D);if($===void 0)continue;let G=B?chunkILTZTY3K_cjs.ra(B,$):chunkILTZTY3K_cjs.ra($,$);if(!G.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(G.issues)}}let V=chunkILTZTY3K_cjs.fc(o);return V.ok?((n.recordsHistory??(r!==chunkILTZTY3K_cjs.b.projection&&r!==chunkILTZTY3K_cjs.b.awareness))&&(this.composition?(this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:v}}):(this.pushUndo({pkg:a,revision:i,selectionBefore:f,selectionAfter:v}),this.redoStack.length=0)),this.current=o,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&Fe[n.minimumImpact]>Fe[P]&&(P=n.minimumImpact),{ok:true,change:this.publish(r,i,{dirty:c,created:u,deleted:m,dependencyKeys:y,splitJoin:g,impact:P,caret:A},n.story??this.storyRef??void 0,n.actorId,n.operationId)}):{ok:false,reason:"package-invariant",detail:JSON.stringify(V.issues)}}beginComposition(e=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:e,selectionAfter:null},committed:false});}endComposition(){let e=this.composition;this.composition=null,!(!e||!e.committed)&&(this.pushUndo(e.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}undo(){let e=this.undoStack.pop();if(!e)return null;let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=e.pkg,this.rev+=1,this.publish(chunkILTZTY3K_cjs.b.mutationUndo,n,null,this.storyRef??void 0)}redo(){let e=this.redoStack.pop();if(!e)return null;let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=e.pkg,this.rev+=1,this.publish(chunkILTZTY3K_cjs.b.mutationRedo,n,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}pushUndo(e){this.undoStack.push(e),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(e,n,r,a,i,o){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:e,...i?{actorId:i}:{},...o?{operationId:o}:{},dirty:r?[...r.dirty]:[],created:r?[...r.created]:[],deleted:r?[...r.deleted]:[],splitJoin:r?r.splitJoin:[],dependencyKeys:r?[...r.dependencyKeys]:[],impact:r?r.impact:a?.kind==="headerFooter"?"global":"flow-structural",...r?.caret?{caret:r.caret}:{},...a?{story:a}:{}};for(let l of this.subscribers)l(s);return s}};function ln(t,e){return [...t.values()].map(n=>n.part).filter(n=>e.parts.has(n.name))}function Po(t,e){return ln(t,e).map(n=>n.name).sort().join(",")}function Oo(t,e,n){if(t.relationships!==e.relationships||t.contentTypes!==e.contentTypes||t.partBytes!==e.partBytes||t.externalTargets!==e.externalTargets||t.mainDocumentPart!==e.mainDocumentPart)return true;if(t.parts===e.parts)return false;if(t.parts.size!==e.parts.size)return true;for(let[r,a]of e.parts)if(r!==n&&t.parts.get(r)!==a)return true;return false}var Nt="http://schemas.openxmlformats.org/wordprocessingml/2006/main",wi="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function He(t,e){for(let n of t.children)if(n.kind!=="textValue"&&n.namespaceUri===Nt&&n.localName===e)return n;return null}function vt(t,e){return t.attributes.find(n=>n.namespaceUri===Nt&&n.localName===e)?.value}function Ei(t){let e=vt(t,"val");return e===void 0||e==="1"||e==="true"||e==="on"}function Ro(t,e){return t.kind==="textValue"?Object.freeze({...t,id:e()}):Object.freeze({...t,id:e(),children:t.children.map(n=>Ro(n,e))})}function Ci(t){let e=chunkILTZTY3K_cjs.ta(`<w:styles xmlns:w="${Nt}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:t.name,contentType:wi});if(!e.ok)return null;let n=He(e.part.root,"style"),r=n?He(n,"pPr"):null;return r?Ro(r,chunkILTZTY3K_cjs.Aa(t)):null}var Io=["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"];function Mi(t,e){let n=Io.indexOf(e),r=0;return t.forEach((a,i)=>{if(a.kind==="textValue")return;let o=Io.indexOf(a.localName);o!==-1&&o<=n&&(r=i+1);}),r}function bo(t,e){let n=chunkILTZTY3K_cjs.wd(t);if(!n)return null;let r=null;for(let d of n.root.children)if(d.kind!=="textValue"&&d.namespaceUri===Nt&&d.localName==="style"&&vt(d,"type")==="paragraph"&&vt(d,"styleId")===e){r=d;break}if(!r)return null;let a=He(r,"name");if(a&&vt(a,"val")?.trim().toLowerCase()!=="list paragraph"&&e!=="ListParagraph")return null;let i=Ci(n);if(!i)return null;let o=He(i,"contextualSpacing");if(!o)return null;let s=He(r,"pPr"),l;if(s){let d=He(s,"contextualSpacing");if(d&&Ei(d))return t;l=d?chunkILTZTY3K_cjs.Ha(n,d.id,o):chunkILTZTY3K_cjs.Ga(n,s.id,Mi(s.children,"contextualSpacing"),[o]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));l=chunkILTZTY3K_cjs.Ga(n,r.id,d===-1?r.children.length:d,[i]);}return l.ok?Object.freeze({...t,parts:new Map([...t.parts,[n.name,l.part]])}):null}var To="http://schemas.openxmlformats.org/package/2006/relationships",wo="application/vnd.openxmlformats-package.relationships+xml",_i="http://schemas.openxmlformats.org/package/2006/content-types",vo="/[Content_Types].xml",Be="/word/numbering.xml",No="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",nt="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Ui=`<Override PartName="${Be}" ContentType="${nt}"/>`;function St(t){return `${t.ownerPart}\0${t.id}`}function Eo(t,e,n){let r=new Set(e.externalTargets.filter(s=>s.type===chunkILTZTY3K_cjs.Pa).map(St)),a=n.externalTargets.filter(s=>s.type===chunkILTZTY3K_cjs.Pa&&!r.has(St(s)));if(a.length===0)return t;let i=new Set(t.map(St)),o=a.filter(s=>!i.has(St(s)));return o.length===0?t:Object.freeze([...t,...o])}function Co(t,e,n){let r=t.filter(a=>a.ownerPart===n||e.has(a.ownerPart));return r.length===t.length?t:Object.freeze(r)}function Mo(t,e,n=[]){if(t===e)return t;let r=Li(t,e);return r=Fi(r,e,n),r}function Do(t,e){let n=new Set;for(let a of t.externalTargets)a.type===chunkILTZTY3K_cjs.Pa&&a.ownerPart!==t.mainDocumentPart&&(t.parts.has(a.ownerPart)||e.has(a.ownerPart)||n.add(a.ownerPart));for(let a of t.parts.keys()){let i=ji(a);!i||i===t.mainDocumentPart||t.parts.has(i)||e.has(i)||t.externalTargets.some(o=>o.ownerPart===i)||n.add(i);}if(n.size===0)return t;let r=t;for(let a of n)r=Vi(r,a);return r}function Li(t,e){let n=e.parts.get(Be);if(!n)return t;let r=chunkILTZTY3K_cjs.Xb(t,n),a=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.type===No),i=r.relationships.get(r.mainDocumentPart)??[];if(a&&!i.some(o=>o.type===No)&&!i.some(o=>o.id===a.id)){let o=Hi(r,{...a,ownerPart:r.mainDocumentPart});o&&(r=o);}if(r.contentTypes.overrides.get(chunkILTZTY3K_cjs.u(Be))!==nt){let o=Wi(r);o&&(r=o);}return r}function Fi(t,e,n){let r=n.filter(i=>i.type===chunkILTZTY3K_cjs.Pa);if(r.length===0)return t;let a=t;for(let i of r){let o=$i(t,e,i.ownerPart);if(!o||a.externalTargets.some(d=>d.ownerPart===o&&d.id===i.id)||new Set((a.relationships.get(o)??[]).map(d=>d.id)).has(i.id))continue;let l=Bi(a,{ownerPart:o,id:i.id,type:chunkILTZTY3K_cjs.Pa,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},o);l&&(a=l);}return a}function $i(t,e,n){return n===e.mainDocumentPart?t.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function Hi(t,e){let n=t.mainDocumentPart,r=dn(n),a=t.parts.get(r),i=chunkILTZTY3K_cjs.ta(`<Relationships xmlns="${To}"><Relationship Id="${chunkILTZTY3K_cjs.P(e.id,"relationship id")}" Type="${chunkILTZTY3K_cjs.P(e.type,"relationship type")}" Target="${chunkILTZTY3K_cjs.P(e.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:wo});if(!i.ok)return null;let o=t.relationships.get(n)??[];if(o.some(d=>d.id===e.id))return null;let s={...e,ownerPart:n,order:o.reduce((d,c)=>Math.max(d,c.order),-1)+1},l=new Map([...t.relationships,[n,[...o,s]]]);return a?Ao(t,a,i.part.root.children[0],l):Object.freeze({...t,parts:new Map([...t.parts,[r,i.part]]),relationships:l})}function Bi(t,e,n=t.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let a=dn(r),i=t.parts.get(a),o=chunkILTZTY3K_cjs.ta(`<Relationships xmlns="${To}"><Relationship Id="${chunkILTZTY3K_cjs.P(e.id,"relationship id")}" Type="${chunkILTZTY3K_cjs.Pa}" Target="${chunkILTZTY3K_cjs.P(e.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:a,contentType:wo});if(!o.ok)return null;let s=[...t.externalTargets,e];if(!i)return Object.freeze({...t,parts:new Map([...t.parts,[a,o.part]]),externalTargets:s});let l=Ao(t,i,o.part.root.children[0],t.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Ao(t,e,n,r){if(!n)return null;let a=chunkILTZTY3K_cjs.Aa(e),i=chunkILTZTY3K_cjs.Ga(e,e.root.id,e.root.children.length,[_o(n,a)]);return i.ok?Object.freeze({...t,parts:new Map([...t.parts,[e.name,i.part]]),relationships:r}):null}function _o(t,e){return t.kind==="textValue"?{...t,id:e()}:{...t,id:e(),children:t.children.map(n=>_o(n,e))}}function dn(t){let e=t.lastIndexOf("/");return `${t.slice(0,e)}/_rels/${t.slice(e+1)}.rels`}function ji(t){let e=/^(.*)\/_rels\/([^/]+)\.rels$/.exec(t);if(!e)return null;let n=e[1],r=e[2];return n===""||r===""?null:`${n}/${r}`}function Vi(t,e){let n=dn(e),r=new Map(t.parts);r.delete(n);let a=new Map(t.partBytes);a.delete(n);let i=new Map(t.relationships);i.delete(e);let o=Object.freeze(t.externalTargets.filter(s=>s.ownerPart!==e));return Object.freeze({...t,parts:r,partBytes:a,relationships:i,externalTargets:o})}function Wi(t){let e=t.contentTypes.overrides.get(chunkILTZTY3K_cjs.u(Be));if(e===nt)return t;if(e!==void 0)return null;let n=t.partBytes.get(vo);if(!n)return null;let r=fflate.strFromU8(n),a=So(r);if(!a)return null;let i=r.lastIndexOf(`</${a.rootName}>`);if(i===-1)return null;let o=r.slice(0,i)+Ui+r.slice(i),s=So(o);if(!s||s.rootName!==a.rootName)return null;let l=[...a.children,Uo("Override",{PartName:Be,ContentType:nt})];return s.children.length!==l.length||s.children.some((d,c)=>d!==l[c])?null:Object.freeze({...t,partBytes:new Map([...t.partBytes,[vo,fflate.strToU8(o)]]),contentTypes:Object.freeze({defaults:t.contentTypes.defaults,overrides:new Map([...t.contentTypes.overrides,[chunkILTZTY3K_cjs.u(Be),nt]])})})}function So(t){let e=chunkILTZTY3K_cjs.W(t);if(!e.ok)return null;let n=e.nodes.filter(s=>s.type==="element");if(n.length!==1)return null;let r=n[0],a=r.name.indexOf(":"),i=a===-1?"":r.name.slice(0,a);if(r.name.slice(a+1)!=="Types"||r.attributes[i?`xmlns:${i}`:"xmlns"]!==_i)return null;let o=[];for(let s of r.children)s.type==="element"&&o.push(Uo(s.name,s.attributes));return {rootName:r.name,children:o}}function Uo(t,e){let n=Object.entries(e).map(([r,a])=>`${r}=${a}`).sort();return [t,...n].join("")}var Lo=4e3,Fo=64;function $o(t){return chunkILTZTY3K_cjs.Pe(t,"footnote")!==null||chunkILTZTY3K_cjs.Pe(t,"endnote")!==null}function Ho(t,e,n,r){if(!$o(t))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let a=chunkILTZTY3K_cjs.Ca(e,n.paragraphId);return !a||a.kind!=="paragraph"?true:chunkILTZTY3K_cjs.He(a).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function Bo(t,e,n,r){if(!$o(t))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let a=chunkILTZTY3K_cjs.Ca(e,n.blockId);if(!a||a.kind==="textValue")return true;let i=0,o=(s,l)=>{if(i>=Lo||l>Fo)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return chunkILTZTY3K_cjs.He(s).some(d=>d.node.kind==="noteReference");for(let d of s.children)if(o(d,l+1))return true;return false};return o(a,0)}function jo(t,e,n){if(n.count>=Lo||e>Fo)return true;if(n.count+=1,t.kind==="textValue")return false;if(t.kind==="commentRangeStart"||t.kind==="commentRangeEnd"||t.kind==="commentReference")return true;for(let r of t.children)if(jo(r,e+1,n))return true;return false}function Vo(t,e,n,r){if(!chunkILTZTY3K_cjs.Rf(t))return false;let a=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(a))return true;r.add(a);let i=chunkILTZTY3K_cjs.Ca(e,a);return !i||i.kind==="textValue"?true:jo(i,0,{count:0})}var cn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",mn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function Wo(t,e){let r=(t.relationships.get(t.mainDocumentPart)??[]).find(a=>a.id===e);return r?r.type!==cn&&r.type!==mn?{ok:false,reason:"wrong-relationship-type",detail:r.type}:Ki(t,r):{ok:false,reason:"dangling-relationship",detail:e}}function Ki(t,e){let n=chunkILTZTY3K_cjs.E(e);if(n.mode==="External")return {ok:false,reason:"external-relationship",detail:e.id};if(!n.target.ok)return {ok:false,reason:"bad-relationship-target",detail:n.target.reason};let r=t.parts.get(n.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:n.target.partName};let a=r.root.localName;return a!=="hdr"&&a!=="ftr"?{ok:false,reason:"not-a-story-part",detail:a||r.name}:{ok:true,partName:r.name,part:r}}function ve(t,e){return e.compositionActive||t.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function Ko(t,e){let n=chunkILTZTY3K_cjs.Ca(t,e);return !n||n.kind!=="drawing"?null:n.children.find(a=>a.kind==="inlineDrawing"||a.kind==="anchoredDrawing")??null}function zo(t,e,n){let r=t.parts.get(e);if(!r)return null;let a=chunkILTZTY3K_cjs.Ca(r,n);return !a||a.kind!=="drawing"?null:chunkILTZTY3K_cjs.db(a,{ownerPartName:e,supportedMcRequires:chunkILTZTY3K_cjs._a,limits:chunkILTZTY3K_cjs.Za,resolveRelationship:chunkILTZTY3K_cjs.ab(t,e)})}function Go(t,e,n){let r=chunkILTZTY3K_cjs.F(t.relationships.get(e)??[],e,n);return r.mode==="internal"?r.partName:null}function je(t,e,n,r){let a=t.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let i=ve(t,a.store);if(i)return i;let{store:o,story:s}=a;return chunkILTZTY3K_cjs.xa(t,()=>zi(t,o,s,n,r),l=>chunkILTZTY3K_cjs.ya(l))}function zi(t,e,n,r,a){let i=n.partName,o=t.currentPackage(),s=e.checkpoint(),l=e.historyDepth,d=null,c=false,u=false,m=e.transact(P=>{if(a?.commitGuard?.()===false){u=true;return}if(a?.expectedPackageRevision!==void 0&&t.packageRevision!==a.expectedPackageRevision){c=true;return}let f=r(P,i);if(f===null){P.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}d=f;},{story:n,...a?.actorId?{actorId:a.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(u)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(c)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!m.ok)return {ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}};if(!m.change)return {ok:true,change:null};let y=m.change.created.find(P=>{let f=e.part;return chunkILTZTY3K_cjs.Ca(f,P)?.kind==="drawing"});return y&&(d=y),{ok:true,change:t.promoteStoryTransactionToPackageUnit(o,e,s,l),...d?{drawingNodeId:d}:{}}}function Xo(t,e,n){let r=t.parts.get(e);if(!r)return null;let a=Ko(r,n);return a?chunkILTZTY3K_cjs.Ug(a):null}function un(t,e,n,r){let a=false;return t.applyPackage(i=>{let o=i.parts.get(e);if(!o)return i;let s=chunkILTZTY3K_cjs.Ca(o,n);if(!s||s.kind!=="drawing")return i;let l=Ko(o,n);if(!l)return i;let d=chunkILTZTY3K_cjs.Vg(l,r),c=Gi(s,d),u=chunkILTZTY3K_cjs.Ha(o,s.id,c,{deferValidation:true});return u.ok?(a=true,chunkILTZTY3K_cjs.Xb(i,u.part)):i}),a}function Gi(t,e){return {...t,children:t.children.map(n=>n.id===e.id?e:n)}}async function Yo(t,e,n){let r=chunkILTZTY3K_cjs.Pb(n.widthPoints),a=chunkILTZTY3K_cjs.Pb(n.heightPoints);if(r===null||a===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=t.resolveStory(e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let o=ve(t,i.store);if(o)return o;let s=i.story.partName,l=await chunkILTZTY3K_cjs.Lb(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=l.bytes,c=chunkILTZTY3K_cjs.Nb(t.currentPackage(),s,{bytes:d,mime:n.mime});if(!c.ok)return {ok:false,reason:"invalidArgs",detail:c.reason==="invalid-image"?"invalid-image":c.reason};let u=c.partName,m=je(t,e,(y,g)=>{let P=t.currentPackage(),f=chunkILTZTY3K_cjs.Nb(P,g,{bytes:d,mime:n.mime});if(!f.ok)return null;P=f.pkg,u=f.partName;let x;if(n.hyperlink){let h=chunkILTZTY3K_cjs.Ed(P,n.hyperlink,g);if(!h)return null;P=h.pkg,x=h.relationshipId;}if(!y.applyPackage(()=>P))return null;let p=chunkILTZTY3K_cjs.Qb({docPrId:f.docPrId,relationshipId:f.relationshipId,extentEmu:{cx:r,cy:a},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...x?{hyperlinkRelationshipId:x}:{}});return y.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:p,...n.revision?{revision:n.revision}:{}})?p.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return m.ok?m.change?{...m,mediaPartName:u}:{ok:true,change:null,mediaPartName:u}:m}async function pn(t,e,n,r,a,i,o){let s=t.resolveStory(e);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=ve(t,s.store);if(l)return l;let d=s.story.partName,c=await chunkILTZTY3K_cjs.Lb(i,r,a);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=c.bytes,m=chunkILTZTY3K_cjs.Nb(t.currentPackage(),d,{bytes:u,mime:a});return m.ok?je(t,e,(y,g)=>{let P=t.currentPackage(),f=zo(P,d,n),x=f?.picture?.embeddedRelationshipId??null,p=f?.picture?.linkedRelationshipId??null,h=x??p;if(!h)return null;let N=x!==null?Go(P,d,x):null,S=P,R=chunkILTZTY3K_cjs.Nb(S,g,{bytes:u,mime:a});return !R.ok||(S=R.pkg,!y.applyPackage(()=>S))||!y.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:R.relationshipId})?null:(y.applyPackage(v=>chunkILTZTY3K_cjs.Sb(v,g,N,h)),n)},{expectedPackageRevision:o.expectedPackageRevision,...o.commitGuard?{commitGuard:o.commitGuard}:{},...o.actorId?{actorId:o.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:m.reason==="invalid-image"?"invalid-image":m.reason}}function Jo(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let a=ve(t,r.store);if(a)return a;let i=r.story.partName,o=t.currentPackage(),s=zo(o,i,n);if(!s)return {ok:false,reason:"unknown-drawing"};let l=s.picture?.embeddedRelationshipId??null,d=s.picture?.linkedRelationshipId??null,c=l??d,u=l!==null?Go(o,i,l):null;return je(t,e,(m,y)=>m.apply({op:"deleteDrawing",drawingNodeId:n})?(m.applyPackage(g=>chunkILTZTY3K_cjs.Sb(g,y,u,c)),n):null)}function Xi(t,e){let n=null,r=i=>{let o=false,s=false,l=(d,c)=>{if(o||d.kind==="textValue")return;if(d.id===e){o=true,s=c;return}let u=c||d.kind==="revisionDelete"||d.kind==="revisionMoveFrom";for(let m of d.children)l(m,u);};return l(i,false),s},a=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let o=chunkILTZTY3K_cjs.Ie(i).spanOf(e);if(o!==null&&o.end>o.start){let s=chunkILTZTY3K_cjs.Ca(t,e);if(!s||s.kind!=="drawing"&&!chunkILTZTY3K_cjs.bb(s))return;n={paragraphId:i.id,start:o.start,end:o.end,alreadyDeleted:r(i)};}return}for(let o of i.children)a(o);}};return a(t.root),n}function qo(t,e,n,r){let a=t.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let i=ve(t,a.store);if(i)return i;let o=t.currentPackage().parts.get(a.story.partName);if(!o)return {ok:false,reason:"unknown-drawing"};let s=Xi(o,n);return s?s.alreadyDeleted?{ok:true,change:null}:je(t,e,l=>l.apply({op:"deleteText",paragraphId:s.paragraphId,start:s.start,end:s.end,revision:r})?n:null):{ok:false,reason:"unknown-drawing"}}async function Qo(t,e,n,r,a,i,o,s){let l=await chunkILTZTY3K_cjs.Tb(a,r,i,void 0,o);return l.ok?pn(t,e,n,l.bytes,l.mime,o,{expectedPackageRevision:t.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function Zo(t,e,n,r,a,i){let o=t.resolveStory(e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let s=ve(t,o.store);return s||je(t,e,(l,d)=>{let c=Xo(t.currentPackage(),d,n),u=null;if(i!==null){let y=chunkILTZTY3K_cjs.Ed(t.currentPackage(),i,d);if(!y||!l.applyPackage(()=>y.pkg))return null;u=y.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:a,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!un(l,d,n,u))return null}else if(i===null&&!un(l,d,n,null))return null;let m=false;return l.applyPackage(y=>{let g=chunkILTZTY3K_cjs.Gd(y,d,c);return g===null?(m=true,y):g}),m?null:n})}function ea(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let a=ve(t,r.store);return a||je(t,e,(i,o)=>{let s=Xo(t.currentPackage(),o,n.drawingNodeId),l=null;if(n.hyperlink!==null){let c=chunkILTZTY3K_cjs.Ed(t.currentPackage(),n.hyperlink,o);if(!c||!i.applyPackage(()=>c.pkg))return null;l=c.relationshipId;}for(let c of n.ops)if(!i.apply(c))return null;if(!un(i,o,n.drawingNodeId,n.hyperlink===null?null:l))return null;let d=false;return i.applyPackage(c=>{let u=chunkILTZTY3K_cjs.Gd(c,o,s);return u===null?(d=true,c):u}),d?null:n.drawingNodeId})}function Yi(t,e){if(t===e)return true;if(t.byteLength!==e.byteLength)return false;for(let n=0;n<t.byteLength;n+=1)if(t[n]!==e[n])return false;return true}function ta(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t)if(e.get(n)!==r)return false;return true}function Ji(t,e){return t===e||t.ownerPart===e.ownerPart&&t.id===e.id&&t.type===e.type&&t.rawTarget===e.rawTarget&&t.targetMode===e.targetMode&&t.order===e.order}function qi(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let a=e.get(n);if(!a||a.length!==r.length||a!==r&&r.some((i,o)=>!Ji(i,a[o])))return false}return true}function Qi(t,e){return t===e?true:t.length!==e.length?false:t.every((n,r)=>{let a=e[r];return n===a||n.ownerPart===a.ownerPart&&n.id===a.id&&n.type===a.type&&n.rawTarget===a.rawTarget&&n.sinkSafe===a.sinkSafe})}function Zi(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let a=e.get(n);if(!a||!Yi(r,a))return false}return true}function es(t,e){return t.contentTypes===e.contentTypes||ta(t.contentTypes.defaults,e.contentTypes.defaults)&&ta(t.contentTypes.overrides,e.contentTypes.overrides)}var Tt=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),wt=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function na(t){for(let[e,n]of t)if(!chunkILTZTY3K_cjs.oa(e,n))return wt;return Tt}function ts(t,e){if(t===e)return Tt;if(t.mainDocumentPart!==e.mainDocumentPart||t.parts.size!==e.parts.size||!Zi(t.partBytes,e.partBytes)||!qi(t.relationships,e.relationships)||!Qi(t.externalTargets,e.externalTargets)||!es(t,e))return wt;let n=[];for(let[o,s]of t.parts){let l=e.parts.get(o);if(!l)return wt;s!==l&&n.push([s,l]);}if(n.length===0)return Tt;let[r,a]=n[0];if(n.length>1||r.name!==t.mainDocumentPart)return na(n);let i=chunkILTZTY3K_cjs.pa(a.root,r.root);return i.undecided?na(n):i.equal?Tt:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?wt:{equal:false,dirty:i.paragraphIds,dependencyKeys:[chunkILTZTY3K_cjs.g.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function fn(t){return {ok:false,reason:"package-invariant",detail:t}}function ns(t,e){if(!t.parts.get(t.mainDocumentPart))return fn("no-main-document");for(let[r,a]of t.parts){let i=e?.parts.get(r);if(i===a)continue;let o=i?chunkILTZTY3K_cjs.ra(i,a):chunkILTZTY3K_cjs.qa(a);if(!o.ok)return fn(`invalid-part:${r}:${o.issues[0]?.code??"invalid"}`)}let n=chunkILTZTY3K_cjs.fc(t);return n.ok?null:fn(n.issues[0]?.code??"package-invariant")}function ra(t,e,n){let r=t.currentPackage(),a=ts(e,r);if(a.equal)return {ok:true,change:null};let i=ns(e,r);if(i)return i;let o=t.bodyStore().part.name,s=a.impact!=="global"&&e.mainDocumentPart===o;return chunkILTZTY3K_cjs.xa(t,()=>{let l=t.packageRevision;return t.installAuthoritativePackageSnapshot(e),{ok:true,change:t.publishStoryWrite({change:"model-change",fromRevision:l,toRevision:l+1,commitId:`pkg-remote-${l+1}`,origin:n.origin,...n.actorId?{actorId:n.actorId}:{},...n.operationId?{operationId:n.operationId}:{},dirty:s?a.dirty:[],created:[],deleted:[],splitJoin:[],dependencyKeys:s?a.dependencyKeys:[],impact:s?a.impact:"global",story:{kind:"body",partName:o}})}},()=>false)}function ia(t,e,n,r){let a=[...e],i=new Set;for(let o of a)t.parts.has(o)&&i.add(o);for(let o of n)oa(o,a,i);for(let o of r)oa(o,a,i);return i}function sa(t,e,n,r,a){let i=new Set(t);i.add(e),i.add(n);for(let o of r)aa(o,i);for(let o of a)aa(o,i);return i}function oa(t,e,n){if(t.kind==="story"){n.add(t.partName);return}for(let r of e)(t.before.parts.has(r)||t.after.parts.has(r))&&n.add(r);}function aa(t,e){if(t.kind==="story"){e.add(t.partName);return}for(let n of t.before.parts.keys())e.add(n);for(let n of t.after.parts.keys())e.add(n);}var la=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),rs=new Set(["deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]),os=64,da=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];subscribers=new Set;historyLimit;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;constructor(e,n,r={}){this.pkg=chunkILTZTY3K_cjs.Xb(e,n),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??os,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??chunkILTZTY3K_cjs.cf,this.body=new $e(this.pkg,n.name,{historyLimit:this.historyLimit,settingsPart:()=>chunkILTZTY3K_cjs.pe(this.pkg)}),this.body.setStoryRef({kind:"body",partName:n.name});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let e=this.currentPackageMemo;if(e&&e.pkg===this.pkg&&e.bodyPart===this.body.part){let a=0,i=true;for(let o of this.stories.values()){if(e.storyParts[a]!==o.part){i=false;break}a+=1;}if(i&&a===e.storyParts.length)return e.result}let n=chunkILTZTY3K_cjs.Xb(this.pkg,this.body.part),r=[];for(let a of this.stories.values())r.push(a.part),this.pkg.parts.has(a.part.name)&&(n=chunkILTZTY3K_cjs.Xb(n,a.part));return this.currentPackageMemo={pkg:this.pkg,bodyPart:this.body.part,storyParts:r,result:n},n}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}resolveStory(e){return e.kind==="body"?{ok:true,story:{kind:"body",partName:this.body.part.name},store:this.body}:e.kind==="notesPart"?e.noteKind!=="footnote"&&e.noteKind!=="endnote"?{ok:false,reason:"unknown-scope",detail:String(e.noteKind)}:this.openNotesPartStore(e.noteKind):e.kind!=="headerFooter"||typeof e.rId!="string"||e.rId.length===0?{ok:false,reason:"unknown-scope",detail:String(e.kind)}:this.openHeaderFooterStore(e.rId)}partFor(e){let n=this.resolveStory(e);return n.ok?n.store.part:null}revisionFor(e){let n=this.resolveStory(e);return n.ok?n.store.revision:null}transact(e,n,r={}){return chunkILTZTY3K_cjs.xa(this,()=>this.commitStoryTransaction(e,n,r),chunkILTZTY3K_cjs.ya)}commitStoryTransaction(e,n,r={}){let a=this.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let{store:i,story:o}=a,s=this.currentPackage(),l=i.historyDepth,d=i.compositionActive,c=i.checkpoint(),u=false,m=new Set,y=false,g=new Set,P=false,f,x=false;i.graftPackage(()=>this.currentPackage());let p=i.transact(S=>{n({...S,applyPackage:R=>S.applyPackage(v=>{let A=R(v);return A!==v&&!x&&(x=Oo(v,A,o.partName)),A}),apply:R=>(R.op==="setListNumbering"&&R.numId!==null&&(P=true),R.op==="setParagraphProperties"&&(f??=R.properties.find(v=>v.localName==="pStyle")?.attributes?.val),u||(R.op==="deleteText"&&Ho(this.pkg,i.part,R,m)||R.op==="deleteBlock"&&Bo(this.pkg,i.part,R,m)||la.has(R.op))&&(u=true),y||(R.op==="deleteText"||R.op==="deleteBlock"?y=Vo(this.pkg,i.part,R,g):(la.has(R.op)||rs.has(R.op))&&(y=true)),S.apply(R)),selectionBefore:R=>S.selectionBefore(R),selectionAfter:R=>S.selectionAfter(R)});},{...r,story:o,...o.kind==="headerFooter"||o.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!p.ok)return {ok:false,reason:p.reason,...p.detail?{detail:p.detail}:{}};this.syncPackageFromStore(i);let h=false;if(p.change&&x&&(this.installPackageSnapshotInternal(i.package),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),h=true),P&&f){let S=bo(this.pkg,f);S&&this.replacePackageShell(S);}let N=false;if(p.change&&u){let S=this.currentPackage(),R=this.cascadeNoteReferences(s,S);if(R===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};R!==S&&(this.installPackageSnapshotInternal(R),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),N=true);}if(p.change&&y){let S=this.currentPackage(),R=chunkILTZTY3K_cjs.Vf(s,S,{storyPartName:o.partName});if(R===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};R!==S&&(this.installPackageSnapshotInternal(R),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),N=true);}if(p.change){this.packageRev+=1;let S=N||h;!d&&r.recordsHistory!==false&&(i.historyDepth>l||S)&&(S?this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage()}):this.pushUndoPointer({kind:"story",partName:o.partName,story:o}));let R=S?this.publishSynthetic(p.change.origin,"global",o,p.change.created):p.change;return S||this.publish(R),{ok:true,change:R}}return {ok:true,change:p.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(e,n=null){let r=this.resolveStory(e);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(e),!r.ok)?false:(this.compositionSession||(this.compositionSession={partName:r.story.partName,beforePackage:this.currentPackage(),storyCheckpoint:r.store.checkpoint(),packageWideEffects:false}),r.store.beginComposition(n),true)}endComposition(){let e=this.compositionSession;if(this.compositionSession=null,!e){this.body.endComposition();return}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return;let r=n.historyDepth;if(n.endComposition(),e.packageWideEffects){n.restoreHistoryStacks(e.storyCheckpoint),this.syncPackageFromStore(n),this.pushUndoPointer({kind:"package",before:e.beforePackage,after:this.currentPackage()});return}if(n.historyDepth>r){let a=e.partName===this.body.part.name?{kind:"body",partName:e.partName}:this.storyRefForPart(e.partName);a&&this.pushUndoPointer({kind:"story",partName:e.partName,story:a});}this.syncPackageFromStore(n);}cancelComposition(){let e=this.compositionSession;if(this.compositionSession=null,!e){this.body.cancelComposition();return}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(e.packageWideEffects){n&&n.restoreCheckpoint(e.storyCheckpoint),this.installPackageSnapshotInternal(e.beforePackage),this.packageRev+=1;let r=e.partName===this.body.part.name?{kind:"body",partName:e.partName}:this.storyRefForPart(e.partName);this.publishSynthetic(chunkILTZTY3K_cjs.b.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(e){return chunkILTZTY3K_cjs.xa(this,()=>this.commitLifecycleOp(e),chunkILTZTY3K_cjs.ya)}commitLifecycleOp(e){let n=this.currentPackage();if(chunkILTZTY3K_cjs.af(e)){let o=chunkILTZTY3K_cjs.bf(n,e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};if(o.package===n)return {ok:true,change:null};this.installPackageSnapshotInternal(o.package),this.pushUndoPointer({kind:"package",before:n,after:o.package}),this.packageRev+=1;let s={kind:"body",partName:this.body.part.name},l=this.publishSynthetic(chunkILTZTY3K_cjs.b.mutationHuman,o.impact,s,o.createdPartName?[o.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:l}}if(!chunkILTZTY3K_cjs.Hd(e))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let r=chunkILTZTY3K_cjs.Id(n,e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};this.installPackageSnapshotInternal(r.package),this.pushUndoPointer({kind:"package",before:n,after:r.package}),this.packageRev+=1;let a={kind:"body",partName:this.body.part.name},i=this.publishSynthetic(chunkILTZTY3K_cjs.b.mutationHuman,r.impact,a,r.createdPartName?[r.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:i}}undo(){let e=this.undoOrder.pop();if(!e)return null;if(e.kind==="package"){this.installPackageSnapshotInternal(e.before),this.redoOrder.push(e),this.packageRev+=1;let a=this.publishSynthetic(chunkILTZTY3K_cjs.b.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),a}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return null;let r=n.undo();return r?(this.redoOrder.push(e),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let e=this.redoOrder.pop();if(!e)return null;if(e.kind==="package"){this.installPackageSnapshotInternal(e.after),this.undoOrder.push(e),this.packageRev+=1;let a=this.publishSynthetic(chunkILTZTY3K_cjs.b.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),a}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return null;let r=n.redo();return r?(this.undoOrder.push(e),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){let e=this.undoOrder[this.undoOrder.length-1];return !e||e.kind==="package"?null:(e.partName===this.body.part.name?this.body:this.stories.get(e.partName))?.selectionForUndo()??null}selectionForRedo(){let e=this.redoOrder[this.redoOrder.length-1];return !e||e.kind==="package"?null:(e.partName===this.body.part.name?this.body:this.stories.get(e.partName))?.selectionForRedo()??null}openStoryParts(){return ln(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return Po(this.stories,this.pkg)}insertImage(e,n){return Yo(this,e,n)}applyFragmentPaste(e,n){return xo(this,e,n)}replaceImage(e,n,r,a,i,o){return pn(this,e,n,r,a,i,o)}deleteImage(e,n){return Jo(this,e,n)}deleteImageTracked(e,n,r){return qo(this,e,n,r)}embedExternalImage(e,n,r,a,i,o,s){return Qo(this,e,n,r,a,i,o,s)}setDrawingMetadataWithHyperlink(e,n,r,a,i){return Zo(this,e,n,r,a,i)}applyImageProperties(e,n){return ea(this,e,n)}promoteStoryTransactionToPackageUnit(e,n,r,a){this.installPackageSnapshotInternal(n.package),n.historyDepth>a&&n.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:e,after:this.currentPackage()}),this.packageRev+=1;let i=n.part.name===this.body.part.name?{kind:"body",partName:n.part.name}:this.storyRefForPart(n.part.name);return this.publishSynthetic(chunkILTZTY3K_cjs.b.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(e){return e?(this.packageRev+=1,this.publish(e),e):null}adoptPackageUnit(e){let n=this.currentPackage();e!==n&&this.pushUndoPointer({kind:"package",before:e,after:n});}installPackageSnapshot(e){this.installPackageSnapshotInternal(e);}installAuthoritativePackageSnapshot(e){this.installPackageSnapshotInternal(e,false);}publishRemotePackage(e,n){return ra(this,e,n)}replacePackageShell(e){this.shellHyperlinks=Eo(this.shellHyperlinks,this.pkg,e);let n=e;n=chunkILTZTY3K_cjs.Xb(n,this.body.part);for(let r of this.stories.values())e.parts.has(r.part.name)&&(n=chunkILTZTY3K_cjs.Xb(n,r.part));this.pkg=n;}installPackageSnapshotInternal(e,n=true){let r=n?Mo(e,this.pkg,this.shellHyperlinks):e,a=r.parts.get(r.mainDocumentPart);if(!a)return;this.body.replacePart(a);for(let[o,s]of this.stories){let l=r.parts.get(o);l&&s.replacePart(l);}this.rIdToPartName.clear();let i=r.relationships.get(r.mainDocumentPart)??[];for(let o of i){if(o.type!==cn&&o.type!==mn)continue;let s=chunkILTZTY3K_cjs.E(o);s.mode!=="Internal"||!s.target.ok||this.stories.has(s.target.partName)&&r.parts.has(s.target.partName)&&this.rIdToPartName.set(o.id,s.target.partName);}this.pkg=r,this.pkg=chunkILTZTY3K_cjs.Xb(this.pkg,this.body.part);for(let o of this.stories.values())this.pkg.parts.has(o.part.name)&&(this.pkg=chunkILTZTY3K_cjs.Xb(this.pkg,o.part));}openNotesPartStore(e){let n=chunkILTZTY3K_cjs.Pe(this.currentPackage(),e);if(!n)return {ok:false,reason:"missing-part",detail:e};let r=this.stories.get(n.name);if(r)return {ok:true,story:{kind:"notesPart",partName:n.name,noteKind:e},store:r};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let a=chunkILTZTY3K_cjs.Bb(n),i=new $e(a,{historyLimit:this.historyLimit,settingsPart:()=>chunkILTZTY3K_cjs.pe(this.pkg)}),o={kind:"notesPart",partName:a.name,noteKind:e};return i.setStoryRef(o),this.stories.set(a.name,i),a!==n&&(this.pkg=chunkILTZTY3K_cjs.Xb(this.pkg,a)),{ok:true,story:o,store:i}}openHeaderFooterStore(e){let n=this.rIdToPartName.get(e);if(n){let l=this.stories.get(n);if(l)return {ok:true,story:{kind:"headerFooter",partName:n,rId:e},store:l}}let r=Wo(this.currentPackage(),e);if(!r.ok)return r;let a=this.stories.get(r.partName);if(a)return this.rIdToPartName.set(e,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:e},store:a};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let i=chunkILTZTY3K_cjs.Bb(r.part),o=new $e(i,{historyLimit:this.historyLimit,settingsPart:()=>chunkILTZTY3K_cjs.pe(this.pkg)}),s={kind:"headerFooter",partName:i.name,rId:e};return o.setStoryRef(s),this.stories.set(i.name,o),this.rIdToPartName.set(e,i.name),i!==r.part&&(this.pkg=chunkILTZTY3K_cjs.Xb(this.pkg,i)),{ok:true,story:s,store:o}}storyRefForPart(e){if(e===this.body.part.name)return {kind:"body",partName:e};for(let[r,a]of this.rIdToPartName)if(a===e)return {kind:"headerFooter",partName:e,rId:r};let n=this.currentPackage().parts.get(e);return n?.root.localName==="footnotes"?{kind:"notesPart",partName:e,noteKind:"footnote"}:n?.root.localName==="endnotes"?{kind:"notesPart",partName:e,noteKind:"endnote"}:null}syncPackageFromStore(e){this.pkg=chunkILTZTY3K_cjs.Xb(this.pkg,e.part);}pushUndoPointer(e){this.undoOrder.push(e),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let e=ia(this.pkg,this.stories.keys(),this.undoOrder,this.redoOrder);for(let[a]of [...this.stories])if(!e.has(a)){this.stories.delete(a);for(let[i,o]of [...this.rIdToPartName])o===a&&this.rIdToPartName.delete(i);}let n=sa(e,this.pkg.mainDocumentPart,this.body.part.name,this.undoOrder,this.redoOrder),r=Do(this.pkg,n);r!==this.pkg&&(this.pkg=r),this.shellHyperlinks=Co(this.shellHyperlinks,n,this.pkg.mainDocumentPart);}publish(e){this.lastChange=e;for(let n of this.subscribers)n(e);}publishSynthetic(e,n,r,a){this.commitCounter+=1;let i=this.packageRev-1,o={change:"model-change",fromRevision:i<0?0:i,toRevision:this.packageRev,commitId:`pkg-commit-${this.commitCounter}`,origin:e,dirty:[],created:[...a],deleted:[],splitJoin:[],dependencyKeys:[],impact:n,story:r};return this.publish(o),o}};function as(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function ca(t,e){if(!t){let o=chunkILTZTY3K_cjs.Eb(e);return o?chunkILTZTY3K_cjs.Fb(new Set,o,chunkILTZTY3K_cjs.Cb):"0"}let n=-1,r=new Set,a=o=>{if(o.kind!=="textValue"){if(o.kind==="comment"){let s=as(o,chunkILTZTY3K_cjs.ca,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=chunkILTZTY3K_cjs.Cb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of o.children)a(s);}};a(t.root);let i=chunkILTZTY3K_cjs.Eb(e);return i?chunkILTZTY3K_cjs.Fb(r,i,chunkILTZTY3K_cjs.Cb):String(n+1)}var is=256,ss=65535,ma=64;function Et(t,e){return t.length>e}function ua(t){return typeof t!="string"||t.trim().length===0?"invalid-author":Et(t,is)?"resource-limit":chunkILTZTY3K_cjs.O(t)?null:"invalid-author"}function pa(t){return typeof t!="string"||t.length===0?"invalid-text":Et(t,ss)?"resource-limit":chunkILTZTY3K_cjs.O(t)?null:"invalid-text"}function gn(t){if(typeof t!="string")return {ok:false,rejection:"invalid-date"};let e=t.trim();if(Et(e,ma))return {ok:false,rejection:"resource-limit"};if(!chunkILTZTY3K_cjs.O(e))return {ok:false,rejection:"invalid-date"};let n=chunkILTZTY3K_cjs.Be(e);return n===null?{ok:false,rejection:"invalid-date"}:Et(n,ma)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function Nc(t){if(t===void 0)return null;let e=gn(t);return e.ok?null:e.rejection}function hn(t){switch(t){case "invalid-author":return "invalid-author";case "invalid-text":return "invalid-text";case "invalid-date":return "invalid-property-value";case "resource-limit":return "resource-limit"}}function fa(t,e){if(t.kind==="textValue")return t;let n=e.get(t.id);if(n!==void 0)return n;let r=false,a=[];for(let i of t.children){let o=fa(i,e);o!==i&&(r=true),a.push(o);}return r?{...t,children:a}:t}function cs(t,e,n){let r=fa(t.root,e);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:t.root.id,nodeId:t.root.id}]};let a=n===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:n,namespaceUri:chunkILTZTY3K_cjs.fa}]};return chunkILTZTY3K_cjs.Ha(t,t.root.id,a,{deferValidation:true})}function ga(t,e,n){let r=new Map;for(let i of e){if(i.stampParagraph===null)continue;let o=r.get(i.commentsPartName);o||(o=new Map,r.set(i.commentsPartName,o)),o.set(i.stampParagraph.id,{paragraph:i.stampParagraph,paraId:i.paraId});}let a=t;for(let[i,o]of r){let s=a.parts.get(i);if(!s)return null;let l=chunkILTZTY3K_cjs.zb(s.root),d=l??"w14",c=new Map;for(let m of o.values())c.set(m.paragraph.id,n(m.paragraph,m.paraId,d));let u=cs(s,c,l===null?d:null);if(!u.ok)return null;a=chunkILTZTY3K_cjs.Xb(a,u.part);}return a}function ha(t,e,n){let r=t.root.children.map(a=>a.kind==="textValue"?a:e.get(a.id)??a);return chunkILTZTY3K_cjs.Fa(t,t.root.id,[...r,...n],{deferValidation:true})}var xa="/word/comments.xml",Pa="/word/commentsExtended.xml",On="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",In="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",ms=[In,"application/vnd.ms-word.commentsExtended+xml"],Oa="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Rn="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",ke="http://schemas.microsoft.com/office/word/2012/wordml";function ot(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function Ve(t,e){return {kind:"genericExtension",namespaceUri:chunkILTZTY3K_cjs.ca,localName:t,prefix:"w",value:e}}function ge(t,e,n,r,a,i,o,s=[]){return {id:t,kind:e,namespaceUri:n,localName:a,prefix:r,namespaceBindings:s,attributes:i,children:o}}function Ia(t,e,n,r,a){let i=e===t.mainDocumentPart?[e]:[e,t.mainDocumentPart];for(let o of i)for(let s of chunkILTZTY3K_cjs.Zb(t,o)){if(s.type!==n)continue;let l=chunkILTZTY3K_cjs.w(o,s.rawTarget);if(!l.ok)continue;if(!t.parts.has(l.partName))return l.partName;let d=chunkILTZTY3K_cjs._b(t,l.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return l.partName}return a}function yn(t,e,n){let r=t.mainDocumentPart;for(let i of chunkILTZTY3K_cjs.Zb(t,r)){if(i.type!==e)continue;let o=chunkILTZTY3K_cjs.w(r,i.rawTarget);if(o.ok&&o.partName===n)return t}let a=chunkILTZTY3K_cjs.cc(t,r);return chunkILTZTY3K_cjs.dc(a,r,e,chunkILTZTY3K_cjs.fg(r,n)).pkg}function bn(t,e){return Ia(t,e,Oa,On,xa)}function Ra(t,e){let n=chunkILTZTY3K_cjs.ff(t,e),r=chunkILTZTY3K_cjs.gf(t,e,n).extended;return r!==null?r:Ia(t,e,Rn,ms,Pa)}function ya(t){let e=new Set;for(let n of t.parts.values())for(let r of chunkILTZTY3K_cjs.yb(n.root))e.add(r);return e}function us(t,e){if(!t)return null;let n=null,r=a=>{if(!(n!==null||a.kind==="textValue")){if(a.kind==="comment"&&ot(a,chunkILTZTY3K_cjs.ca,"id")===e){for(let i=a.children.length-1;i>=0;i-=1){let o=a.children[i];if(o.kind!=="paragraph")continue;let s=ot(o,chunkILTZTY3K_cjs.fa,"paraId");s!==void 0&&chunkILTZTY3K_cjs.ub(s)&&(n=s.toUpperCase());return}return}for(let i of a.children)r(i);}};return r(t.root),n}function ps(t,e){if(!t)return null;let n=null,r=a=>{if(!(n!==null||a.kind==="textValue")){if(a.kind==="comment"&&ot(a,chunkILTZTY3K_cjs.ca,"id")===e){for(let i=a.children.length-1;i>=0;i-=1){let o=a.children[i];if(o.kind==="paragraph"){n=o;return}}return}for(let i of a.children)r(i);}};return r(t.root),n}function ba(t){let e=chunkILTZTY3K_cjs.zb(t.root);if(e!==null)return {part:t,prefix:e};let n={...t.root,namespaceBindings:[...t.root.namespaceBindings,{prefix:"w14",namespaceUri:chunkILTZTY3K_cjs.fa}]},r=chunkILTZTY3K_cjs.Ha(t,t.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(chunkILTZTY3K_cjs.Ea(t.root,n),{part:{...t,root:n},prefix:"w14"})}function va(t,e,n){return ge(t.id,"paragraph",t.namespaceUri,t.prefix??"w",t.localName,[...t.attributes.filter(r=>!(r.namespaceUri===chunkILTZTY3K_cjs.fa&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:chunkILTZTY3K_cjs.fa,localName:"paraId",prefix:n,value:e}],t.children,t.namespaceBindings)}function fs(t,e,n,r){let a=t.parts.get(e);if(!a)return t;let i=ba(a),o=chunkILTZTY3K_cjs.Ca(i.part,n);if(!o||o.kind!=="paragraph")return chunkILTZTY3K_cjs.Xb(t,i.part);let s=chunkILTZTY3K_cjs.Ha(i.part,o.id,va(o,r,i.prefix),{deferValidation:true});return chunkILTZTY3K_cjs.Xb(t,s.ok?s.part:i.part)}function gs(t,e,n,r){let a=`${xa}#comment-${t}`,i=n.text!==n.text.trim(),o=ge(`${a}.t`,"text",chunkILTZTY3K_cjs.ca,"w","t",i?[{kind:"xmlSpace",namespaceUri:chunkILTZTY3K_cjs.da,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${a}.tv`,kind:"textValue",value:n.text}]),s=ge(`${a}.rPr`,"runProperties",chunkILTZTY3K_cjs.ca,"w","rPr",[],[ge(`${a}.rStyle`,"generic",chunkILTZTY3K_cjs.ca,"w","rStyle",[Ve("val","CommentReference")],[])]),l=ge(`${a}.r`,"run",chunkILTZTY3K_cjs.ca,"w","r",[],[s,o]),d=ge(`${a}.pPr`,"paragraphProperties",chunkILTZTY3K_cjs.ca,"w","pPr",[],[ge(`${a}.pStyle`,"generic",chunkILTZTY3K_cjs.ca,"w","pStyle",[Ve("val","CommentText")],[])]),c=ge(`${a}.p`,"paragraph",chunkILTZTY3K_cjs.ca,"w","p",[{kind:"genericExtension",namespaceUri:chunkILTZTY3K_cjs.fa,localName:"paraId",prefix:r,value:e}],[d,l]);return ge(a,"comment",chunkILTZTY3K_cjs.ca,"w","comment",[Ve("id",t),Ve("author",n.author),...n.initials===void 0?[]:[Ve("initials",n.initials)],...n.date===void 0?[]:[Ve("date",n.date)]],[c])}function kn(t,e){let n=chunkILTZTY3K_cjs.ta(e,{name:t,contentType:"application/xml"});return n.ok?n.part.root:null}function Na(t,e){for(let x of [ua(e.author),pa(e.text)])if(x)return {ok:false,reason:hn(x)};let n;if(e.date!==void 0){let x=gn(e.date);if(!x.ok)return {ok:false,reason:hn(x.rejection)};n=x.value;}let r={...e,...n===void 0?{}:{date:n}},a=t.package,i=t.part.name,o=bn(a,i),s=Ra(a,i),l=a.parts.get(o),d=ca(l,r.actorId),c=chunkILTZTY3K_cjs.xb(`${o}#${d}`,ya(a)),u=e.replyToCommentId===void 0?null:us(l,e.replyToCommentId),m=e.replyToCommentId!==void 0&&u===null?ps(l,e.replyToCommentId):null;if(e.replyToCommentId!==void 0&&u===null&&!m)return {ok:false,reason:"unknown-revision"};let y=m?chunkILTZTY3K_cjs.xb(`${o}#parent-${e.replyToCommentId}`,new Set([...ya(a),c])):null,g=u??y,P=e.anchor.endParagraphId??e.anchor.paragraphId,f=t.transact(x=>{x.applyPackage(p=>{let h=p.parts.has(o)?p:(()=>{let N=kn(o,`<w:comments xmlns:w="${chunkILTZTY3K_cjs.ca}"/>`);return N?chunkILTZTY3K_cjs.ec(p,o,N,On):null})();return h===null?p:yn(h,Oa,o)}),m&&y&&x.applyPackage(p=>fs(p,o,m.id,y)),x.applyPackage(p=>{let h=p.parts.get(o);if(!h)return p;let N=ba(h),S=chunkILTZTY3K_cjs.Ga(N.part,N.part.root.id,N.part.root.children.length,[gs(d,c,r,N.prefix)],{deferValidation:true});return S.ok?chunkILTZTY3K_cjs.Xb(p,S.part):p}),g!==null&&(x.applyPackage(p=>{let h=p.parts.has(s)?p:(()=>{let N=kn(s,`<w15:commentsEx xmlns:w15="${ke}"/>`);return N?chunkILTZTY3K_cjs.ec(p,s,N,In):null})();return h===null?p:yn(h,Rn,s)}),x.applyPackage(p=>{let h=p.parts.get(s);if(!h)return p;let S=[...hs(h).has(g.toUpperCase())?[]:[Pn(`${s}#ex-${g}`,g,void 0,false)],Pn(`${s}#ex-${c}`,c,g,false)],R=chunkILTZTY3K_cjs.Ga(h,h.root.id,h.root.children.length,S,{deferValidation:true});return R.ok?chunkILTZTY3K_cjs.Xb(p,R.part):p})),x.applyTo(i,{op:"insertCommentMarker",paragraphId:P,offset:e.anchor.end,commentId:d,marker:"reference"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:P,offset:e.anchor.end,commentId:d,marker:"end"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:e.anchor.paragraphId,offset:e.anchor.start,commentId:d,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return f.ok?{ok:true,commentId:d,change:f.change}:{ok:false,reason:f.reason}}function xn(t){for(let e=t.children.length-1;e>=0;e-=1){let n=t.children[e];if(n.kind==="paragraph")return n}return null}function ka(t){let e=xn(t);if(!e)return null;let n=ot(e,chunkILTZTY3K_cjs.fa,"paraId");return n!==void 0&&chunkILTZTY3K_cjs.ub(n)?n.toUpperCase():null}function hs(t){let e=new Map;if(!t)return e;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===ke&&r.localName==="commentEx"){let a=ot(r,ke,"paraId");a!==void 0&&chunkILTZTY3K_cjs.ub(a)&&e.set(a.toUpperCase(),r);}for(let a of r.children)n(a);}};return n(t.root),e}function rt(t,e){return {kind:"genericExtension",namespaceUri:ke,localName:t,prefix:"w15",value:e}}function ys(t,e){return {id:t.id,kind:"generic",namespaceUri:t.namespaceUri,localName:t.localName,...t.prefix===void 0?{}:{prefix:t.prefix},namespaceBindings:t.namespaceBindings,attributes:e,children:t.children}}function ks(t,e,n){let r=[],a=false,i=false;for(let o of t.attributes){if(o.namespaceUri===ke&&o.localName==="done"){a=true,r.push({kind:"genericExtension",namespaceUri:o.namespaceUri,localName:o.localName,...o.prefix===void 0?{}:{prefix:o.prefix},value:n?"1":"0"});continue}o.namespaceUri===ke&&o.localName==="paraIdParent"&&(i=true),r.push(o);}return !i&&e!==void 0&&r.push(rt("paraIdParent",e)),a||r.push(rt("done",n?"1":"0")),ys(t,r)}function Pn(t,e,n,r){return {id:t,kind:"generic",namespaceUri:ke,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[rt("paraId",e),...n===void 0?[]:[rt("paraIdParent",n)],rt("done",r?"1":"0")],children:[]}}function Sa(t,e,n){return xs(t,e,n,chunkILTZTY3K_cjs.ef())}function xs(t,e,n,r){let a=t.package,i=t.part.name;if(chunkILTZTY3K_cjs.ff(a,i)===null)return {ok:false,reason:"unknown-comment"};let s=chunkILTZTY3K_cjs.if(a,e,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=chunkILTZTY3K_cjs.hf(a,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=l.used,c=new Map,u=[];for(let P of s.ids){let f=s.records.get(P);if(!f)return {ok:false,reason:"unknown-comment"};if(!xn(f.node))return {ok:false,reason:"unknown-comment"};let p=ka(f.node),h=p??chunkILTZTY3K_cjs.xb(`${f.partName}#done-${P}`,d);p===null&&d.add(h),c.set(P,h);}for(let P of s.ids){let f=s.records.get(P),x=xn(f.node),p=c.get(P),h=ka(f.node),N=s.parentCommentIdByChildId.get(P),S=s.parentParaIdByCommentId.get(P)??(N===void 0?void 0:c.get(N)),R=s.commentExByParaId.get(p);u.push({paraId:p,stampParagraph:h===null?x:null,commentsPartName:f.partName,parentParaId:S,existing:R?.node,existingParentParaId:R?.parentParaId,existingDone:R?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(P=>P.existingDone===n))return {ok:true,changed:false,change:null};let m=s.extendedPartName??Pa,y=s.extendedPartName===null,g=t.transact(P=>{P.applyPackage(f=>{let x=ga(f,u,va);if(x===null)return f;let p=x;if(!p.parts.has(m)){let v=kn(m,`<w15:commentsEx xmlns:w15="${ke}"/>`);if(!v)return f;let A=chunkILTZTY3K_cjs.ec(p,m,v,In);p=y?yn(A,Rn,m):A;}let h=p.parts.get(m);if(!h)return f;let N=new Map,S=[];for(let v of u){let A=v.existingParentParaId??v.parentParaId;v.existing?N.set(v.existing.id,ks(v.existing,A,n)):S.push(Pn(`${m}#done-${v.paraId}`,v.paraId,A,n));}let R=ha(h,N,S);return R.ok?chunkILTZTY3K_cjs.Xb(p,R.part):f});});return g.ok?{ok:true,changed:true,change:g.change}:{ok:false,reason:g.reason}}function Xc(t,e){let n=bn(t,e);return t.parts.has(n)&&chunkILTZTY3K_cjs._b(t,n)===On}function Yc(t,e){return bn(t,e)}function Jc(t,e){return Ra(t,e)}var Ta={kind:"body"};function nm(t,e,n=Ta){let r=n.kind==="body"?null:t.resolveStory(n),a=r?.ok?r.store:t.bodyStore(),i=t.currentPackage(),o=a.checkpoint();return a.graftPackage(()=>t.currentPackage()),chunkILTZTY3K_cjs.xa(t,()=>{let s=Na(a,e);return s.ok&&(a.restoreHistoryStacks(o),t.replacePackageShell(a.package),t.adoptPackageUnit(i),t.publishStoryWrite(s.change)),s},s=>chunkILTZTY3K_cjs.ya(s))}function rm(t,e,n){let r=t.bodyStore(),a=t.currentPackage(),i=r.checkpoint();return r.graftPackage(()=>t.currentPackage()),chunkILTZTY3K_cjs.xa(t,()=>{let o=Sa(r,e,n);return !o.ok||!o.changed||(r.restoreHistoryStacks(i),t.replacePackageShell(r.package),t.adoptPackageUnit(a),t.publishStoryWrite(o.change)),o},o=>o.ok&&o.changed)}function om(t,e,n=Ta,r){if(e.length===0)return false;let a=n.kind==="body"?t.bodyStore().part:t.partFor(n);if(!a)return false;let i={storyPartName:a.name,...r===void 0?{}:{noteId:r}},o=t.bodyStore(),s=t.currentPackage(),l=o.checkpoint();return o.graftPackage(()=>t.currentPackage()),chunkILTZTY3K_cjs.xa(t,()=>{let d=false,c=false,u=o.transact(m=>{m.applyPackage(y=>{let g=y;for(let P of e){let f=P.parentCommentId===void 0?chunkILTZTY3K_cjs.Tf(g,P.commentId,i):chunkILTZTY3K_cjs.Uf(g,P.commentId,P.parentCommentId,i);if(f===null)return d=true,y;c||=f!==g,g=f;}return g});});return d||!u.ok||!c?false:(o.restoreHistoryStacks(l),t.installPackageSnapshot(o.package),t.adoptPackageUnit(s),t.publishStoryWrite(u.change),true)},d=>d)}var Ps=256*1024,Os=4096;function Ea(t,e,n){let r=e.payload,a=t.part.name,i=n??a;if(r){if(r.data.length>Ps)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>Os)return {ok:false,reason:"payload-too-large",detail:"label"}}let o=new Set(chunkILTZTY3K_cjs.xf(t.part.root).map(m=>m.node.id)),s=e.replaceControlId===void 0?[]:Ca(t,a,e.replaceControlId),l=null,d,c=t.transact(m=>{if(e.replaceControlId!==void 0){m.apply({op:"removeContentControl",controlId:e.replaceControlId,keepContent:false});for(let P of s)m.applyPackage(f=>chunkILTZTY3K_cjs.ng(f,P.partName,P.nodeId));}let y=e.replaceUntil;if(y!==void 0&&y<=e.offset){l="invalid-range",d="replaceUntil must be past offset";return}if(y!==void 0&&m.apply({op:"deleteText",paragraphId:e.paragraphId,start:e.offset,end:y}),!r){m.apply({op:"insertInlineContentControl",paragraphId:e.paragraphId,offset:e.offset,tag:e.tag,text:e.text,...e.alias===void 0?{}:{alias:e.alias},...e.lock===void 0?{}:{lock:e.lock}});return}let g=null;m.applyPackage(P=>{let f=chunkILTZTY3K_cjs.ig(P,i,r.namespaceUri,r.rootLocalName);if(!f.part)return l="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,P;if(g=chunkILTZTY3K_cjs.sg(f.part,r.rootLocalName,r.nodeId),!g)return l="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,P;let x=chunkILTZTY3K_cjs.mg(f.pkg,f.part.partName,{id:r.nodeId,label:r.label,data:r.data});return chunkILTZTY3K_cjs.lg(x,f.part.partName,r.nodeId)?x:(l="store-not-authored",d="the payload node could not be written into the store",P)}),!(l!==null||!g)&&m.apply({op:"insertInlineContentControl",paragraphId:e.paragraphId,offset:e.offset,tag:e.tag,text:e.text,...e.alias===void 0?{}:{alias:e.alias},...e.lock===void 0?{}:{lock:e.lock},dataBinding:g});});if(l!==null)return {ok:false,reason:l,...d===void 0?{}:{detail:d}};if(!c.ok)return {ok:false,reason:c.reason,...c.detail===void 0?{}:{detail:c.detail}};let u=Is(t,o);return {ok:true,change:c.change,...u===void 0?{}:{nodeId:u}}}function Is(t,e){for(let n of chunkILTZTY3K_cjs.xf(t.part.root))if(!e.has(n.node.id))return n.node.id}function Ca(t,e,n){let r=chunkILTZTY3K_cjs.xf(t.part.root).find(i=>i.node.id===n);if(!r)return [];let a=[];for(let i of chunkILTZTY3K_cjs.gg(t.package,e)){let o=chunkILTZTY3K_cjs.vg(r.node,i.itemId);o!==null&&a.push({partName:i.partName,nodeId:o});}return a}function Ma(t,e){let n=t.part.name,r=Ca(t,n,e),a=t.transact(i=>{i.apply({op:"removeContentControl",controlId:e,keepContent:false});for(let o of r)i.applyPackage(s=>chunkILTZTY3K_cjs.ng(s,o.partName,o.nodeId));});return a.ok?{ok:true,change:a.change}:{ok:false,reason:a.reason,...a.detail===void 0?{}:{detail:a.detail}}}function cm(t,e,n){if(!t.parts.has(e)||n.length===0)return {ok:true,pkg:t,removed:[]};let r=t,a=[];for(let i of n){let o=chunkILTZTY3K_cjs.hg(r,e,i);if(!o)continue;let s=chunkILTZTY3K_cjs.ug(r,o.itemId),l=chunkILTZTY3K_cjs.og(r,o.partName,s);if(l.pkg===r&&chunkILTZTY3K_cjs.kg(r,o.partName).some(d=>!s.has(d.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=l.pkg,a.push(...l.removed);}return {ok:true,pkg:r,removed:a}}var wa=new WeakMap;function Rs(t,e){let n=wa.get(t);n||(n=new Map,wa.set(t,n));let r=n.get(e);if(r)return r;let a=chunkILTZTY3K_cjs.gg(t,e).map(i=>({itemId:i.itemId,nodes:new Map(chunkILTZTY3K_cjs.kg(t,i.partName).map(o=>[o.id,o]))}));return n.set(e,a),a}function mm(t,e,n=e){let r=new Map,a=t.parts.get(e);if(!a)return r;let i=Rs(t,n);if(i.length===0)return r;for(let o of chunkILTZTY3K_cjs.xf(a.root))for(let s of i){let l=chunkILTZTY3K_cjs.vg(o.node,s.itemId);if(l===null)continue;let d=s.nodes.get(l);if(d){r.set(o.node.id,{nodeId:l,label:d.label,data:d.data});break}}return r}function um(t,e,n){let r=new Map,a=chunkILTZTY3K_cjs.hg(t,e,n);if(!a)return r;for(let i of chunkILTZTY3K_cjs.kg(t,a.partName))r.set(i.id,{label:i.label,data:i.data});return r}var Da={kind:"body"};function Aa(t,e,n){let r=e.kind==="body"?null:t.resolveStory(e),a=r?.ok?r.store:t.bodyStore(),i=t.currentPackage(),o=a.checkpoint();return a.graftPackage(()=>t.currentPackage()),chunkILTZTY3K_cjs.xa(t,()=>{let s=n(a);return s.ok&&(a.restoreHistoryStacks(o),t.replacePackageShell(a.package),t.adoptPackageUnit(i),t.publishStoryWrite(s.change)),s},s=>chunkILTZTY3K_cjs.ya(s))}function hm(t,e,n=Da){return Aa(t,n,r=>Ea(r,e,t.bodyStore().part.name))}function ym(t,e,n=Da){return Aa(t,n,r=>Ma(r,e))}var We="proposed";function bs(t,e){switch(t){case "revisionInsert":case "revisionMoveTo":return e!=="original";case "revisionDelete":case "revisionMoveFrom":return e!=="proposed";default:return false}}var vs=32;function vn(t,e=We){let n=[];return at(t.children,e,0,n),n}function Nn(t,e,n,r,a=We){let i=[];for(let o of vn(t,a)){let s=e.get(o.id);if(!s||s.end<=s.start)continue;let l=Math.max(s.start,n),d=Math.min(s.end,r);l>=d||i.push({run:o,start:l,end:d});}return i}function at(t,e,n,r){if(!(n>=vs)){for(let a of t)if(!(a.kind==="textValue"||a.kind==="paragraphProperties")){if(a.kind==="run"){r.push(a);continue}if(a.kind==="hyperlink"){at(a.children,e,n+1,r);continue}if(chunkILTZTY3K_cjs.ja(a.kind)){if(!bs(a.kind,e))continue;at(a.children,e,n+1,r);continue}if(chunkILTZTY3K_cjs.Pc(a)){at(a.children,e,n+1,r);continue}if(chunkILTZTY3K_cjs.xe(a)){let i=chunkILTZTY3K_cjs.ye(a);i&&at(i.children,e,n+1,r);continue}}}}var Ns=new Set(chunkILTZTY3K_cjs._e),Tn=new Set(chunkILTZTY3K_cjs.Ze);function wm(t){return Tn.has(t)}function Ct(t,e,n){return !t||t.kind==="textValue"?void 0:t.children.find(a=>a.kind===e||a.kind==="generic"&&a.localName===n&&a.namespaceUri===chunkILTZTY3K_cjs.ca)}function wn(t,e){if(!t||t.kind==="textValue")return [];let n=[];for(let r of t.children){if(r.kind==="textValue"||!e.has(r.localName))continue;let a=chunkILTZTY3K_cjs.J();for(let i of r.attributes)a[i.localName]=i.value;n.push(Object.keys(a).length>0?{localName:r.localName,attributes:a}:{localName:r.localName});}return n}function Em(t,e){let n=chunkILTZTY3K_cjs.Ca(t,e);return wn(Ct(n,"paragraphProperties","pPr"),Ns)}function Ss(t,e){let n=chunkILTZTY3K_cjs.Ca(t,e),r=Ct(n,"paragraphProperties","pPr");return wn(Ct(r,"runProperties","rPr"),Tn)}function _a(t,e){let n=Array.isArray(e)?e:[e],r=new Set(n.map(i=>i.localName));return [...t.filter(i=>!r.has(i.localName)),...n]}var Ts=new Map([["ascii","asciiTheme"],["hAnsi","hAnsiTheme"],["eastAsia","eastAsiaTheme"],["cs","cstheme"]]);function ws(t,e){let n=t.find(a=>a.localName==="rFonts")?.attributes;if(!n)return e;let r={...n,...e.attributes??{}};for(let a of Object.keys(e.attributes??{})){let i=Ts.get(a);i&&delete r[i];}return {localName:"rFonts",attributes:r}}function En(t){let e=new Map;for(let n of chunkILTZTY3K_cjs.He(t)){let r=n.formatRunIds&&n.formatRunIds.length>0?n.formatRunIds:n.runId?[n.runId]:[];for(let a of r){let i=e.get(a);i?(i.start=Math.min(i.start,n.start),i.end=Math.max(i.end,n.end)):e.set(a,{start:n.start,end:n.end});}}return e}function Es(t){let e=new Set;for(let n of chunkILTZTY3K_cjs.He(t))if(n.formatRunIds)for(let r of n.formatRunIds)e.add(r);return e}function Sn(t,e){if(e.localName==="rFonts")return ws(t,e);if(e.localName!=="u")return e;let n=t.find(r=>r.localName==="u")?.attributes;return n?{localName:"u",attributes:{...n,...e.attributes??{}}}:e}function Cm(t,e,n){let r=Ss(t,e),a=Array.isArray(n)?n:[n];return _a(r,a.map(i=>Sn(r,i)))}function Cs(t,e){return Array.isArray(e)?e.map(n=>Sn(t,n)):Sn(t,e)}function Mm(t,e,n,r,a,i=We){let o=chunkILTZTY3K_cjs.Ca(t,e);if(!o||o.kind!=="paragraph")return [];let s=[],l=Es(o);for(let d of Nn(o,En(o),n,r,i)){let c=wn(Ct(d.run,"runProperties","rPr"),Tn);s.push({start:d.start,end:d.end,properties:_a(c,Cs(c,a)),...l.has(d.run.id)?{targetRunIds:[d.run.id]}:{}});}return s}function Dm(t,e,n,r,a=We){let i=chunkILTZTY3K_cjs.Ca(t,e);if(!i||i.kind!=="paragraph"||r<=n)return [];let o=[];for(let s of Nn(i,En(i),n,r,a)){let l=o[o.length-1];l&&s.start<=l.end?l.end=Math.max(l.end,s.end):o.push({start:s.start,end:s.end});}return o}function Am(t,e,n,r,a=We){let i=chunkILTZTY3K_cjs.Ca(t,e);if(!i||i.kind!=="paragraph")return [];let o=En(i),s=[];for(let l of vn(i,a)){let d=o.get(l.id);if(!d||d.end<=d.start)continue;(r>n?Math.max(d.start,n)<Math.min(d.end,r):d.start<=n&&n<d.end)&&s.push(l);}return s}function Cn(t){let e=La.get(t.root);if(e)return e;let n=new Map,r=o=>{let s=Ua.get(o);if(s){for(let[d,c]of s)n.set(d,c);return}let l=new Map;Ds(o,l),Ua.set(o,l);for(let[d,c]of l)n.set(d,c);},a=(o,s)=>{if(!(o.kind==="textValue"||s>64)){if(o.kind==="paragraph"){r(o);return}for(let l of o.children)a(l,s+1);}};a(t.root,0);let i=(o,s)=>{if(!(o.kind==="textValue"||s>64)){if(o.kind==="paragraph"){let l=Fa.get(o);if(!l){let d=[];$a(o,0,d),l=d,Fa.set(o,l);}for(let[d,c]of l)n.set(d,c);return}if(o.kind==="tableRow"){let l=Mt.get(o);l||(l=Ha(o),Mt.set(o,l));for(let[d,c]of l)n.set(d,c);}for(let l of o.children)i(l,s+1);}};return i(t.root,0),La.set(t.root,n),n}function $a(t,e,n){if(!(t.kind==="textValue"||e>64)){if(t.kind==="tableRow"){let r=Mt.get(t);r||(r=Ha(t),Mt.set(t,r));for(let a of r)n.push(a);}for(let r of t.children)$a(r,e+1,n);}}function Ha(t){let e=null,n=(o,s)=>{if(!(e||o.kind==="textValue"||s>64)){if(o.kind==="paragraph"){e=o;return}for(let l of o.children)n(l,s+1);}};if(n(t,0),!e)return Ms;let r={paragraphId:e.id,start:0,end:0},a=[],i=(o,s,l)=>{if(o.kind==="textValue"||l>64||o.kind==="paragraph")return;let d=s==="trPr"&&(o.localName==="ins"||o.localName==="del"),c=s==="tcPr"&&(o.localName==="cellIns"||o.localName==="cellDel");(d||c)&&a.push([o.id,r]);for(let u of o.children)i(u,o.localName,l+1);};return i(t,void 0,0),a}var Ms=[],Ua=new WeakMap,La=chunkILTZTY3K_cjs.Mf(8),Mt=new WeakMap,Fa=new WeakMap;function Ds(t,e){let n=chunkILTZTY3K_cjs.Ie(t),r=(o,s,l,d)=>{if(!(o.kind==="textValue"||d>64)){e.set(o.id,{paragraphId:t.id,start:s,end:l});for(let c of o.children)r(c,s,l,d+1);}},a=(o,s)=>{if(o.kind==="textValue"||s>64)return;let l=n.spanOf(o);if(o.kind==="run"){if(!l)return;e.set(o.id,{paragraphId:t.id,start:l.start,end:l.end});for(let d of o.children)d.kind==="runProperties"&&r(d,l.start,l.end,s+1);return}l&&e.set(o.id,{paragraphId:t.id,start:l.start,end:l.end});for(let d of o.children)a(d,s+1);};for(let o of t.children)o.kind!=="paragraphProperties"&&a(o,0);let i=t.children.find(o=>o.kind==="paragraphProperties");i&&r(i,n.length,n.length,0);}function $m(t){return `${t.kind}-${t.id}`}function ja(t){return t.kind==="revision"?t.ranges:t.range?[t.range]:[]}function As(t){return ja(t)[0]??null}function Mn(t,e){let n=As(t);if(!n)return Number.MAX_SAFE_INTEGER;let r=e.get(n.start.paragraphId);return r===void 0?Number.MAX_SAFE_INTEGER:r*1e6+Math.min(n.start.offset,999999)}function _s(t,e){let n=e.get(t.start.paragraphId),r=e.get(t.end.paragraphId);return n===void 0||r===void 0?Number.MAX_SAFE_INTEGER:(r-n)*1e6+(t.end.offset-t.start.offset)}var Us=0,Ls=1,Fs=2;function $s(t,e,n){let r=n.get(e.paragraphId),a=n.get(t.start.paragraphId),i=n.get(t.end.paragraphId);return r===void 0||a===void 0||i===void 0||r<a||r>i||r===a&&e.offset<t.start.offset||r===i&&e.offset>t.end.offset?null:a===i&&t.start.offset===t.end.offset?Us:r===i&&e.offset===t.end.offset?Fs:Ls}function Hs(t,e,n){let r=null;for(let a of ja(t)){let i=$s(a,e,n);if(i===null)continue;let o=_s(a,n);(r===null||i<r.grip||i===r.grip&&o<r.width)&&(r={grip:i,width:o});}return r}var Ba={comment:0,custom:1,revision:2};function Bs(t,e,n){let r=[];for(let a of t){let i=Hs(a,e,n);i!==null&&r.push({item:a,grip:i.grip,width:i.width});}return r.sort((a,i)=>a.grip!==i.grip?a.grip-i.grip:a.width!==i.width?a.width-i.width:a.item.kind!==i.item.kind?Ba[a.item.kind]-Ba[i.item.kind]:a.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-a.item.nesting:0).map(a=>a.item)}function Hm(t,e,n){let a=Bs(t,e,n).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return a?a.kind==="comment"?Va(t,a):a:null}function Bm(t,e){return Va(t,e)}function Va(t,e){let n=new Map,r=new Map;for(let o of t)o.kind==="comment"?n.set(o.id,o):o.kind==="revision"&&r.set(o.id,o);let a=new Set([e.id]),i=e;for(;i.parentId!==void 0;){let o=n.get(i.parentId);if(!o||a.has(o.id))break;a.add(o.id),i=o;}if(i.parentRevisionId!==void 0){let o=r.get(i.parentRevisionId);if(o)return o}return i}var js={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function qm(t){let e=[],n=r=>{if(r.kind==="textValue"){e.push(r.value);return}for(let a of r.children)n(a);};for(let r of t.blocks)n(r);return e.join("")}function Qm(t){if(t.initials&&t.initials.trim().length>0)return t.initials.trim();let e=t.author.trim().split(/\s+/).filter(Boolean);return e.length===0?"?":e.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function Dt(t,e){for(let n of t.attributes)if(n.localName===e&&n.namespaceUri===chunkILTZTY3K_cjs.ca)return n.value}function it(t){if(t.kind==="textValue")return t.value;if(t.kind==="tab")return " ";if(t.kind==="hardBreak")return chunkILTZTY3K_cjs.Fc(t);if(chunkILTZTY3K_cjs.Nc(t))return "";let e="";for(let n of t.children)e+=it(n);return e}function Dn(t){return `${t.id}\0${t.author}\0${t.date??""}`}var Vs={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo"};function Ws(t){let e=t.root.kind!=="paragraph";if(e){let r=Wa.get(t.root);if(r&&r.name===t.name)return r.items}let n=Ks(t);return e&&Wa.set(t.root,{name:t.name,items:n}),n}var Wa=chunkILTZTY3K_cjs.Mf(8);function Ks(t){let e=chunkILTZTY3K_cjs.yg(t);if(e.length===0)return [];let n=Cn(t),r=new Map;for(let i of e){let o=Dt(i.node,"id");if(o===void 0)continue;let s=Dt(i.node,"author")??"",l=Dt(i.node,"author")===void 0,d=Dt(i.node,"date"),c=d===void 0?{id:o,author:s}:{id:o,author:s,date:d},u=i.propertyChange?"format":i.paragraphMark?"paragraphMark":Vs[i.node.kind]??"structural",m=i.paragraphMark?js[i.node.localName]:void 0,y=n.get(i.node.id),g=y?{partName:t.name,start:{paragraphId:y.paragraphId,offset:y.start},end:{paragraphId:y.paragraphId,offset:y.end}}:null,P=u==="structural"?`structural\0${Dn(c)}`:`${i.node.localName}\0${Dn(c)}`,f=r.get(P);if(f){g&&!f.ranges.some(x=>x.partName===g.partName&&x.start.paragraphId===g.start.paragraphId&&x.start.offset===g.start.offset&&x.end.paragraphId===g.end.paragraphId&&x.end.offset===g.end.offset)&&f.ranges.push(g),u!=="structural"&&f.revisionKind==="structural"&&(f.revisionKind=u),(u==="insert"&&f.revisionKind==="delete"||u==="delete"&&f.revisionKind==="insert"||f.revisionKind==="replace")&&(f.revisionKind="replace"),f.readOnly||=i.refused||l,i.nesting>f.nesting&&(f.nesting=i.nesting),u==="delete"||u==="moveFrom"?f.deletedText+=it(i.node):u!=="format"&&u!=="paragraphMark"&&(f.text+=it(i.node));continue}r.set(P,{address:c,revisionKind:u,...m?{markDirection:m}:{},author:s,...d===void 0?{}:{date:d},text:u==="format"||u==="paragraphMark"||u==="delete"||u==="moveFrom"?"":it(i.node),deletedText:u==="delete"||u==="moveFrom"?it(i.node):"",ranges:g?[g]:[],nesting:i.nesting,readOnly:i.refused||l});}let a=[...r.values()].map(i=>({kind:"revision",id:`${i.revisionKind}-${t.name}\0${Dn(i.address)}`,address:i.address,addresses:[i.address],revisionKind:i.revisionKind,...i.markDirection?{markDirection:i.markDirection}:{},author:i.author,...i.date===void 0?{}:{date:i.date},text:i.revisionKind==="replace"?i.text:i.text||i.deletedText,replacedText:i.revisionKind==="replace"?i.deletedText:"",ranges:i.ranges,nesting:i.nesting,readOnly:i.readOnly,replyIds:[]}));return zs(a,An(t))}function zs(t,e){let n=Gs(t),r=n.filter(l=>(l.revisionKind==="insert"||l.revisionKind==="delete")&&!l.readOnly&&l.ranges.length>0),a=new Set,i=new Map,o=new Map;for(let l of r){if(l.revisionKind!=="insert")continue;let d=l.ranges[0].start,c=`${d.paragraphId}\0${d.offset}`,u=o.get(c);u?u.push(l):o.set(c,[l]);}for(let l of r){if(l.revisionKind!=="delete"||a.has(l.id))continue;let d=l.ranges[l.ranges.length-1].end,c=o.get(`${d.paragraphId}\0${d.offset}`)??[],u=c.length>1?[...c].sort((m,y)=>(m.text.length>0?0:1)-(y.text.length>0?0:1)):c;for(let m of u){if(a.has(m.id)||m.author!==l.author)continue;a.add(l.id),a.add(m.id);let y=Qs(l.ranges[0],m.ranges[0],e)?l:m,g=qs(l.date,m.date);i.set(l.id,{...y,id:`replace-${l.id}-${m.id}`,revisionKind:"replace",...g===void 0?{}:{date:g},addresses:Js([...l.addresses,...m.addresses]),text:m.text,replacedText:l.text,ranges:[...l.ranges,...m.ranges],replacedRangeCount:l.ranges.length,readOnly:l.readOnly||m.readOnly});break}}let s=[];for(let l of n){let d=i.get(l.id);if(d){s.push(d);continue}a.has(l.id)||s.push(l);}return s}function Gs(t){let e=t.filter(l=>(l.revisionKind==="insert"||l.revisionKind==="delete")&&!l.readOnly&&l.ranges.length>0);if(e.length<2)return t;let n=(l,d)=>`${l.revisionKind}\0${l.author}\0${d.paragraphId}\0${d.offset}`,r=new Map,a=new Set;for(let l of e)r.set(n(l,l.ranges[0].start),l),a.add(n(l,l.ranges[l.ranges.length-1].end));let i=new Set,o=new Map;for(let l of e){if(i.has(l.id)||a.has(n(l,l.ranges[0].start)))continue;let d=[l],c=l;for(;;){let u=r.get(n(c,c.ranges[c.ranges.length-1].end));if(!u||u===c||i.has(u.id))break;i.add(u.id),d.push(u),c=u;}d.length>1&&o.set(l.id,Xs(d));}if(o.size===0)return t;let s=[];for(let l of t)i.has(l.id)||s.push(o.get(l.id)??l);return s}function Xs(t){let e=t[0],n=[...e.addresses],r=[...e.ranges],a=e.text,i=e.date;for(let o of t.slice(1)){for(let s of o.addresses)n.some(l=>qa(l,s))||n.push(s);for(let s of o.ranges)r.push(s);a+=o.text,i=Ys(i,o.date);}return {...e,id:t.map(o=>o.id).join("+"),addresses:n,ranges:r,text:a,...i===void 0?{}:{date:i}}}function Ys(t,e){if(t===void 0)return e;if(e===void 0)return t;let n=Date.parse(t),r=Date.parse(e);return Number.isNaN(n)||Number.isNaN(r)?t:r>n?e:t}function Js(t){let e=[];for(let n of t)e.some(r=>qa(r,n))||e.push(n);return e}function qa(t,e){return t.id===e.id&&t.author===e.author&&(t.date??"")===(e.date??"")}function qs(t,e){if(e===void 0)return t;if(t===void 0)return e;let n=Date.parse(t),r=Date.parse(e);return Number.isNaN(n)||Number.isNaN(r)?e:n>r?t:e}function Qs(t,e,n){let r=n.get(t.start.paragraphId)??0,a=n.get(e.start.paragraphId)??0;return r!==a?r<a:t.start.offset<=e.start.offset}function Zs(t,e,n){let r=new Map(e.map(c=>[c.commentId,c])),a=new Map,i=new Map;for(let c of t)c.paraId&&a.set(c.paraId.toUpperCase(),c),i.set(c.id,c);let o=new Map,s=new Map;for(let c of t){let u=r.get(c.id);if(!u||u.orphaned||u.start.paragraphId===u.end.paragraphId&&u.start.offset===u.end.offset)continue;let m=`${u.start.paragraphId}:${u.start.offset}|${u.end.paragraphId}:${u.end.offset}`;o.has(m)?s.set(c.id,o.get(m)):o.set(m,c.id);}let l=new Map;for(let c of t){let u=c.paraId?n.get(c.paraId.toUpperCase()):void 0,m=u?.parentParaId?a.get(u.parentParaId):void 0,y=c.parentCommentId?i.get(c.parentCommentId):void 0,g=u===void 0?s.get(c.id):void 0,P=g?i.get(g):void 0,f=m??y??P;f&&f.id!==c.id&&l.set(c.id,f.id);}for(let c of [...l.keys()]){let u=new Set([c]),m=l.get(c);for(;m!==void 0;){if(u.has(m)){l.delete(c);break}u.add(m),m=l.get(m);}}let d=new Map;for(let[c,u]of l){let m=d.get(u);m?m.push(c):d.set(u,[c]);}return t.map(c=>{let u=r.get(c.id),m=c.paraId?n.get(c.paraId.toUpperCase()):void 0,y=l.get(c.id);return {kind:"comment",id:c.id,comment:c,range:u?{partName:u.partName,start:u.start,end:u.end}:null,resolved:m?.done??false,...y===void 0?{}:{parentId:y},replyIds:d.get(c.id)??[],orphaned:u===void 0||u.orphaned}})}function Zm(t){let e=[t.storyPart],n=new Set([t.storyPart.name]);for(let d of t.furnitureParts??[])n.has(d.name)||(n.add(d.name),e.push(d));let r=t.commentsPart?chunkILTZTY3K_cjs.Pf(t.commentsPart):[],a=t.commentsExtendedPart?chunkILTZTY3K_cjs.Qf(t.commentsExtendedPart):new Map,i=[],o=[],s=e.length===1?An(e[0]):new Map;for(let d of e){for(let m of Ws(d))i.push(m);for(let m of chunkILTZTY3K_cjs.Of(d))o.push(m);if(e.length===1)continue;let c=s,u=c.size;for(let[m,y]of An(d))c.has(m)||c.set(m,u+y);}return el([...i,...Zs(r,o,a)]).sort((d,c)=>Mn(d,s)-Mn(c,s))}function Ka(t){return `${t.partName}\0${t.start.paragraphId}:${t.start.offset}|${t.end.paragraphId}:${t.end.offset}`}function el(t){let e=new Map;for(let o of t)if(o.kind==="revision")for(let s of o.ranges??[]){if(s.start.paragraphId===s.end.paragraphId&&s.start.offset===s.end.offset)continue;let l=Ka(s),d=o.nesting??0,c=e.get(l);(c===void 0||d>c.nesting)&&e.set(l,{id:o.id,nesting:d});}let n=new Map;for(let o of t)o.kind==="comment"&&o.replyIds&&o.replyIds.length>0&&n.set(o.id,o.replyIds);let r=o=>{let s=[],l=new Set([o]),d=[...n.get(o)??[]];for(;d.length>0;){let c=d.shift();l.has(c)||(l.add(c),s.push(c),d.push(...n.get(c)??[]));}return s},a=new Map,i=new Map;for(let o of t){if(o.kind!=="comment"||o.parentId!==void 0||o.orphaned||!o.range)continue;let s=e.get(Ka(o.range))?.id;if(s===void 0)continue;let l=[o.id,...r(o.id)];for(let c of l)i.set(c,s);let d=a.get(s);d?d.push(...l):a.set(s,l);}return t.map(o=>{if(o.kind==="revision"){let s=a.get(o.id)??[];return s.length===0&&(o.replyIds??[]).length===0?o:{...o,replyIds:s}}if(o.kind==="comment"){let s=i.get(o.id);if(s===void 0){if(o.parentRevisionId===void 0)return o;let{parentRevisionId:l,...d}=o;return d}return o.parentRevisionId===s?o:{...o,parentRevisionId:s}}return o})}function An(t){let e=za.get(t.root);if(e)return e;let n=new Map,r=(a,i)=>{if(!(a.kind==="textValue"||i>64)){if(a.kind==="paragraph"){n.has(a.id)||n.set(a.id,n.size);return}if(a.kind==="table"){let o=Ja.get(a);if(!o){let s=[],l=(d,c)=>{if(!(d.kind==="textValue"||c>64)){if(d.kind==="paragraph"){s.push(d.id);return}for(let u of d.children)l(u,c+1);}};for(let d of a.children)l(d,0);o=s,Ja.set(a,o);}for(let s of o)n.has(s)||n.set(s,n.size);return}for(let o of a.children)r(o,i+1);}};return r(t.root,0),za.set(t.root,n),n}var za=chunkILTZTY3K_cjs.Mf(8);function eu(t){let e=Ya.get(t.root);if(e)return e;let n=new Map;for(let r of Qa(t.root,0))n.has(r)||n.set(r,n.size);return Ya.set(t.root,n),n}var Ga=Object.freeze([]),Xa=new WeakMap;function Qa(t,e){if(t.kind==="textValue"||e>64)return Ga;let n=Xa.get(t);if(n&&n.depth===e)return n.ids;let r=null;t.kind==="paragraph"&&(r??=[]).push(t.id);for(let i of t.children){let o=Qa(i,e+1);if(o.length!==0){r??=[];for(let s of o)r.push(s);}}let a=r??Ga;return Xa.set(t,{depth:e,ids:a}),a}var Ya=chunkILTZTY3K_cjs.Mf(8),Ja=new WeakMap;var ru=256,ou=2e3,Za=/[\p{L}\p{N}_]/u;function ei(t){let e=t.toLowerCase();if(e.length===t.length)return e;let n="";for(let r=0;r<t.length;r+=1){let a=t[r],i=a.toLowerCase();n+=i.length===1?i:a;}return n}function tl(t,e,n){let r=e>0?t[e-1]:void 0,a=n<t.length?t[n]:void 0;return !(r!==void 0&&Za.test(r)||a!==void 0&&Za.test(a))}function nl(t){return typeof t=="string"&&t.length>0&&t.length<=256}function au(t,e,n,r={}){let a={matches:[],truncated:false};if(!nl(e)||t.length===0||n<=0)return a;let i=r.matchCase===true,o=r.wholeWord===true,s=i?e:ei(e),l=i?t:ei(t),d=Math.max(0,r.from??0),c=Math.min(t.length,r.to??t.length),u=[],m=l.indexOf(s,d);for(;m>=0;){let y=m+s.length;if(y>c)return {matches:u,truncated:false};if(!o||tl(t,m,y)){if(u.length>=n)return {matches:u,truncated:true};u.push({start:m,length:s.length});}m=l.indexOf(s,y);}return {matches:u,truncated:false}}
|
|
2
|
-
exports.$=Hm;exports.A=hm;exports.B=ym;exports.C=We;exports.D=vn;exports.E=Nn;exports.F=Ns;exports.G=Tn;exports.H=wm;exports.I=Ct;exports.J=wn;exports.K=Em;exports.L=Ss;exports.M=_a;exports.N=ws;exports.O=En;exports.P=Es;exports.Q=Sn;exports.R=Cm;exports.S=Mm;exports.T=Dm;exports.U=Am;exports.V=Cn;exports.W=$m;exports.X=ja;exports.Y=As;exports.Z=Mn;exports._=Bs;exports.a=ko;exports.aa=Bm;exports.b=vi;exports.ba=qm;exports.c=xo;exports.ca=Qm;exports.d=$e;exports.da=Ws;exports.e=os;exports.ea=Zs;exports.f=da;exports.fa=Zm;exports.g=ua;exports.ga=el;exports.h=pa;exports.ha=An;exports.i=gn;exports.ia=eu;exports.j=Nc;exports.ja=ru;exports.k=ca;exports.ka=ou;exports.l=Na;exports.la=ei;exports.m=Sa;exports.ma=tl;exports.n=Xc;exports.na=nl;exports.o=Yc;exports.oa=au;exports.p=Jc;exports.q=nm;exports.r=rm;exports.s=om;exports.t=Ps;exports.u=Os;exports.v=Ea;exports.w=Ma;exports.x=cm;exports.y=mm;exports.z=um;
|