@docx-editor.dev/core 2.29.0 → 2.31.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.
Files changed (107) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.d.ts +22 -26
  3. package/dist/automation.js +1 -1
  4. package/dist/binding.cjs +1 -1
  5. package/dist/binding.d.ts +47 -40
  6. package/dist/binding.js +1 -1
  7. package/dist/bookmark-names-DDuAra_V.d.ts +37 -0
  8. package/dist/{chrome-print-CAs51cpq.d.ts → chrome-print-BWvaVEhD.d.ts} +577 -243
  9. package/dist/chunk-243W4WW2.cjs +2 -0
  10. package/dist/{chunk-G4HOFIKJ.js → chunk-2E2RPEKX.js} +1 -1
  11. package/dist/chunk-4S24UOPG.js +30 -0
  12. package/dist/chunk-5JPIEN54.cjs +3 -0
  13. package/dist/{chunk-7WQ7AAHW.cjs → chunk-5SO5QDMV.cjs} +1 -1
  14. package/dist/{chunk-UHHYFIDT.cjs → chunk-6IDOVU6L.cjs} +1 -1
  15. package/dist/chunk-DBOOTED4.cjs +30 -0
  16. package/dist/chunk-EOTAXOJY.cjs +5 -0
  17. package/dist/chunk-FDAKJ2SJ.cjs +30 -0
  18. package/dist/chunk-FNNOJNGY.js +3 -0
  19. package/dist/chunk-FT33HRZP.js +5 -0
  20. package/dist/{chunk-W35WTWAO.cjs → chunk-HC6YNKUI.cjs} +1 -1
  21. package/dist/chunk-HZ66UCIS.js +2 -0
  22. package/dist/{chunk-MM5QBMTE.cjs → chunk-IBRBNT37.cjs} +1 -1
  23. package/dist/chunk-IVIN7X43.js +30 -0
  24. package/dist/chunk-LZY6B6IV.js +4 -0
  25. package/dist/chunk-MOYYRVFV.cjs +2 -0
  26. package/dist/{chunk-OMCG63ZF.js → chunk-N6B3BXCL.js} +1 -1
  27. package/dist/chunk-Q5K2GGNG.js +2 -0
  28. package/dist/chunk-R2XINWVE.js +7 -0
  29. package/dist/chunk-SUEXVBPR.js +1 -0
  30. package/dist/chunk-T2QQHG5C.js +18 -0
  31. package/dist/{chunk-LSZ6KPKK.js → chunk-VWIJKH4A.js} +1 -1
  32. package/dist/chunk-WO4V6PNS.cjs +18 -0
  33. package/dist/chunk-XMJKFURD.cjs +4 -0
  34. package/dist/{chunk-BY2ACZZ6.cjs → chunk-XSTGE3NI.cjs} +1 -1
  35. package/dist/chunk-YQWMI6J5.cjs +7 -0
  36. package/dist/{chunk-RCLZXP3B.js → chunk-ZCJS7D7S.js} +1 -1
  37. package/dist/collaboration/replication.cjs +1 -1
  38. package/dist/collaboration/replication.d.ts +4 -5
  39. package/dist/collaboration/replication.js +1 -1
  40. package/dist/collaboration.d.ts +3 -4
  41. package/dist/contracts/document.d.ts +3 -3
  42. package/dist/contracts/editor.d.ts +8 -9
  43. package/dist/contracts/interaction.d.ts +2 -2
  44. package/dist/contracts/modules.d.ts +12 -13
  45. package/dist/contracts/types.d.ts +2 -2
  46. package/dist/{custom-node-writes-Bn6uciLb.d.ts → custom-node-writes-TeUvMP13.d.ts} +2 -2
  47. package/dist/{diagnostic-context-B8M79cfK.d.ts → diagnostic-context-DJ0P1uZE.d.ts} +3 -2
  48. package/dist/{diagnostic-hints-BeVjfNOv.d.ts → diagnostic-hints-C9JlLz1L.d.ts} +12 -5
  49. package/dist/{document-protection-CUb55pl_.d.ts → document-protection-C8x3P2J6.d.ts} +1 -1
  50. package/dist/{editor-CZQZmTIU.d.ts → editor-B2ShlO23.d.ts} +368 -52
  51. package/dist/{editor-scope-7o9xweiJ.d.ts → editor-scope-C7ke1KJG.d.ts} +57 -4
  52. package/dist/editor.cjs +1 -1
  53. package/dist/editor.css +5 -3
  54. package/dist/editor.d.ts +606 -34
  55. package/dist/editor.js +1 -1
  56. package/dist/export.cjs +2 -2
  57. package/dist/export.d.ts +17 -15
  58. package/dist/export.js +2 -2
  59. package/dist/{font-resolver-lSBLirLR.d.ts → font-resolver-CWh40DYp.d.ts} +1 -1
  60. package/dist/font-shaping-policy-BvpkrfxM.d.ts +7 -0
  61. package/dist/{headless-document-view-pp3q7wIh.d.ts → headless-document-view-qOpaCF82.d.ts} +2 -2
  62. package/dist/index.cjs +1 -1
  63. package/dist/index.d.ts +24 -24
  64. package/dist/index.js +1 -1
  65. package/dist/{layout-shaping-BD-dF_rn.d.ts → layout-shaping-CWS3j0Xr.d.ts} +3 -2
  66. package/dist/layout.cjs +1 -1
  67. package/dist/layout.d.ts +112 -44
  68. package/dist/layout.js +1 -1
  69. package/dist/{note-properties-qQUjO1GQ.d.ts → note-properties-QsKh24sM.d.ts} +1 -1
  70. package/dist/{omml-equation-BUbU0utM.d.ts → omml-equation-BsLAa2lX.d.ts} +38 -8
  71. package/dist/output.cjs +1 -1
  72. package/dist/output.d.ts +20 -10
  73. package/dist/output.js +1 -1
  74. package/dist/{protocol-DYzzz2ej.d.ts → protocol-COZJUKUY.d.ts} +94 -2
  75. package/dist/{review-paragraph-order-CN_0l2Cb.d.ts → review-paragraph-order-C_QbCKcH.d.ts} +1 -1
  76. package/dist/{semantic-cell-selection-eYag3P47.d.ts → semantic-cell-selection-Cub9FDa8.d.ts} +2 -2
  77. package/dist/{semantic-interaction-kR_QB845.d.ts → semantic-interaction-dApRIYpt.d.ts} +1 -1
  78. package/dist/{semantic-paint-ZayFF3tD.d.ts → semantic-paint-DLzA8sjP.d.ts} +3 -3
  79. package/dist/{semantic-record-queries-Bsgth6lv.d.ts → semantic-record-queries-3yp9o11g.d.ts} +1 -1
  80. package/dist/{semantic-records-DQmumPgL.d.ts → semantic-records-B-akgRch.d.ts} +207 -139
  81. package/dist/store.cjs +1 -1
  82. package/dist/store.d.ts +49 -136
  83. package/dist/store.js +1 -1
  84. package/dist/{tree-package-store-CovjNARF.d.ts → tree-package-store-B8l8DX3Z.d.ts} +612 -428
  85. package/dist/{tree-session-contract-CZVAGl51.d.ts → tree-session-contract-DeLRqohz.d.ts} +28 -13
  86. package/dist/{types-barrel-DuC5QBNC.d.ts → types-barrel-CkF2JbU4.d.ts} +1146 -745
  87. package/package.json +2 -2
  88. package/dist/chunk-236O4YQW.js +0 -2
  89. package/dist/chunk-6JPL6ZAS.cjs +0 -5
  90. package/dist/chunk-6ZQP4HQ7.js +0 -3
  91. package/dist/chunk-BCXH4BXB.js +0 -5
  92. package/dist/chunk-CAJEXXVG.cjs +0 -4
  93. package/dist/chunk-CPWLFPWC.js +0 -30
  94. package/dist/chunk-D7ZMDMPX.cjs +0 -3
  95. package/dist/chunk-DOHF6FA7.cjs +0 -30
  96. package/dist/chunk-DVX32P2P.js +0 -27
  97. package/dist/chunk-E4LOMDNL.js +0 -1
  98. package/dist/chunk-EKLM7NWB.cjs +0 -7
  99. package/dist/chunk-G3K63G7P.cjs +0 -27
  100. package/dist/chunk-JLVBDYVQ.cjs +0 -2
  101. package/dist/chunk-LQX36Z5P.js +0 -7
  102. package/dist/chunk-OSFOJTHU.cjs +0 -18
  103. package/dist/chunk-T6K2QYNZ.cjs +0 -2
  104. package/dist/chunk-TRGAVV2Y.js +0 -4
  105. package/dist/chunk-U4JZVSOE.js +0 -2
  106. package/dist/chunk-YQ5G6LC7.js +0 -18
  107. package/dist/image-resources-tXLQShoC.d.ts +0 -211
@@ -0,0 +1,2 @@
1
+ import {h,i,u,k,p,o,n,la,Vi as Vi$1,og,xl as xl$1,lh,Ke,Vd as Vd$1,Le,S,C,Ud as Ud$1,Uk,$f,Ib,Mb,ei,Va,Ie,Ia,Se as Se$1,Re,Qe as Qe$1,Ee as Ee$1,Na,Oa,yj,Hb,nf,g,ah,Bj,Cj,dj,Ga,Te as Te$1,Bl as Bl$1,di,Cl as Cl$1,li,pi,bi,ci,Vg,Wg,J,Eb,zl as zl$1,T,cg,Kb,Fb,yb,Ya,Yd as Yd$1,Zd as Zd$1,fi,$d as $d$1,ni,oi,$b,Ki as Ki$1,Fi as Fi$1,Pi,Ji as Ji$1,Ii,Di as Di$1,Si,Ei as Ei$1,Ri,Li as Li$1,Hi as Hi$1,Ra,zb,Bb,Db,eg,Jb,Lk,Fk,Kk,Mk,Zf,Xa,yk,Hj,rk,Mj,Lj,Jj,uk,lk,ik,Ua,pk,mk,nk,Ta,tk,ok,kk,hk,vk,Qg,hf,if as _if,vi as vi$1,ui,B,Ba,Pg,f,we,Oe,Jk,Dj,Fj,wj,tl as tl$1,yl as yl$1,Lg,Tk,Qk,Wa,kg,bd as bd$1,Za,ye,te,ve,ze,Be as Be$1,bl as bl$1,Ce,zd,_d as _d$1,Ci as Ci$1,Ab,qa,vb,fe as fe$1,se,jk,Lb,Gb,Sk,Pd as Pd$1,Hd as Hd$1,Id as Id$1,Kd as Kd$1,K,Ea,l,Fa,z,Yf,_f,Zb,Ik,Hk,mg,xh,yh,Ld as Ld$1,Da,U,aa,Rk,Rg,kl as kl$1,ll as ll$1,ma,qe as qe$1,re,pe}from'./chunk-T2QQHG5C.js';import {strFromU8,strToU8}from'fflate';var ic=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],sc=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,lc=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Ni(t){return sc.test(t)||lc.test(t)}function wn(t,e){if(!Ni(t))throw new Error(`invalid ${e??"registry"} id ${JSON.stringify(t)}: must be reverse-domain (dev.docx-editor.core.x) or package-owned (@scope/pkg#kind/name)`)}var cc=/^(\d+)\.(\d+)\.(\d+)$/;function dt(t){let e=cc.exec(t);if(!e)throw new Error(`invalid semantic version: ${JSON.stringify(t)}`);return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3])}}function Cn(t,e){return t.major!==e.major?t.major<e.major?-1:1:t.minor!==e.minor?t.minor<e.minor?-1:1:t.patch!==e.patch?t.patch<e.patch?-1:1:0}function Mn(t,e){let n=dt(t),r=e.trim();if(r==="*")return true;if(r.startsWith("^")){let o=dt(r.slice(1));return Cn(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(e)}`);let i=true;for(let a of o){let s=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!s)throw new Error(`unsupported version range: ${JSON.stringify(e)}`);let l=dt(a.slice(s.length)),c=Cn(n,l);s===">="?i=i&&c>=0:i=i&&c<0;}return i}return Cn(n,dt(r))===0}var fe=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},Mr=(t,e)=>`${t}:${e}`;function dc(t,e={}){let n=new Map;for(let c of t){if(wn(c.id,"extension"),vi(c.version,c.id),n.has(c.id))throw new fe("duplicate-extension",`duplicate extension id ${c.id}`,[c.id]);n.set(c.id,c);for(let d of c.contributions)wn(d.id,d.kind),vi(d.version,`${c.id} \u2192 ${d.id}`),d.replaces&&pc(d.replaces.targetRange,`${c.id} \u2192 replaces ${d.replaces.targetId}`);}for(let c of t){for(let d of c.dependencies??[])if(!n.has(d))throw new fe("missing-dependency",`${c.id} requires missing extension ${d}`,[c.id,d]);for(let d of c.conflicts??[])if(n.has(d)){let u=[c.id,d].sort();throw new fe("conflict",`extensions ${u[0]} and ${u[1]} conflict`,u)}}uc(n);let r=new Set(e.availablePorts??[]);for(let c of t)for(let d of c.contributions)d.kind==="runtimePort"&&r.add(d.id);for(let c of t)for(let d of c.requiredPorts??[])if(!r.has(d))throw new fe("missing-port",`${c.id} requires unavailable port ${d}`,[c.id,d]);let o=new Map,i=new Map,a=new Map;for(let c of t)for(let d of c.contributions){let u=Mr(d.kind,d.id);if(d.replaces){let m=Mr(d.kind,d.replaces.targetId),O=a.get(m)??[];O.push({ext:c.id,c:d}),a.set(m,O);continue}if(i.has(u)){let m=[o.get(u),c.id].sort();throw new fe("id-collision",`${d.kind} id ${d.id} registered by both ${m[0]} and ${m[1]}`,m)}i.set(u,d),o.set(u,c.id);}let s=new Map(i);for(let[c,d]of a){let u=i.get(c);if(!u){let f=d[0];throw new fe("replacement-target-missing",`${f.ext} replaces missing target ${f.c.replaces.targetId}`,[f.ext,f.c.replaces.targetId])}let m=u.replaceable??{kind:"none"};for(let{ext:f,c:y}of d){if(!Mn(u.version,y.replaces.targetRange))throw new fe("replacement-version-mismatch",`${f} replaces ${y.replaces.targetId}@${u.version} outside range ${y.replaces.targetRange}`,[f,y.replaces.targetId]);if(m.kind==="none")throw new fe("unauthorized-replacement",`${y.replaces.targetId} does not authorize replacement (attempted by ${f})`,[f,y.replaces.targetId])}let O=mc(u,d);s.set(c,O);}return {extensions:n,contributions:s,get:(c,d)=>s.get(Mr(c,d))}}function mc(t,e){let n=t.replaceable??{kind:"none"};if(e.length===1)return e[0].c;if(n.kind==="priority"){let o=[...e].sort((s,l)=>(l.c.replaces.priority??0)-(s.c.replaces.priority??0)),i=o[0].c.replaces.priority??0,a=o.filter(s=>(s.c.replaces.priority??0)===i);if(a.length>1){let s=a.map(l=>l.ext).sort();throw new fe("ambiguous-replacement",`multiple replacers of ${t.id} share top priority ${i}: ${s.join(", ")}`,s)}return o[0].c}let r=e.map(o=>o.ext).sort();throw new fe("ambiguous-replacement",`multiple replacers of ${t.id}: ${r.join(", ")}`,r)}function uc(t){let o=new Map,i=[],a=s=>{o.set(s,1),i.push(s);let l=[...t.get(s)?.dependencies??[]].sort();for(let c of l){let d=o.get(c)??0;if(d===1){let u=i.indexOf(c),m=[...i.slice(u),c];throw new fe("dependency-cycle",`dependency cycle: ${m.join(" -> ")}`,m)}d===0&&a(c);}i.pop(),o.set(s,2);};for(let s of [...t.keys()].sort())(o.get(s)??0)===0&&a(s);}function vi(t,e){try{dt(t);}catch{throw new fe("invalid-version",`invalid version ${JSON.stringify(t)} in ${e}`,[e])}}function pc(t,e){try{Mn("0.0.0",t);}catch{throw new fe("invalid-version",`invalid version range ${JSON.stringify(t)} in ${e}`,[e])}}var mt=class extends Error{constructor(e){super(e),this.name="BudgetError";}},jt=class t{constructor(e,n){this.label=e;this.capacity=n;this.used=new u(`${e}.budget`,n);}label;capacity;used;children=new Set;activeReservations=0;cleanups=[];disposed=false;carveAmount=0;parent;get inUse(){return this.used.current}get available(){return this.used.remaining}get isDisposed(){return this.disposed}reserve(e){this.assertLive(),this.used.add(e),this.activeReservations+=1;let n=false,r=this;return {amount:e,get released(){return n},release(){n||(n=true,r.used.release(e),r.activeReservations-=1);}}}child(e,n){this.assertLive(),this.used.add(n);let r=new t(e,n);return r.parent=this,r.carveAmount=n,this.children.add(r),r}onRelease(e){this.assertLive(),this.cleanups.push(e);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new mt(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new mt(`${this.label}: cannot release with ${this.activeReservations} reservation(s) outstanding`);let e=[];for(let n=this.cleanups.length-1;n>=0;n--)try{this.cleanups[n]();}catch(r){e.push(r);}if(this.disposed=true,this.parent&&(this.parent.children.delete(this),this.parent.used.release(this.carveAmount),this.parent=void 0),e.length>0)throw new mt(`${this.label}: ${e.length} cleanup error(s); first: ${String(e[0])}`)}assertLive(){if(this.disposed)throw new mt(`${this.label}: budget already released`)}};var An=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},Vt=class{_cancelled=false;_phase="pre-publication";_reason;cancel(e){this._cancelled=true,e!==void 0&&(this._reason=e);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let e=this;return {get isCancelled(){return e._cancelled},get phase(){return e._phase},get derivedOnly(){return e.derivedOnly},checkpoint(){if(e._cancelled)throw new An(e.derivedOnly,e._reason)}}}};var Dn=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},Ar=class{ports=new Map;provide(e,n){return this.ports.set(e,n),this}has(e){return this.ports.has(e)}resolve(e){if(!this.ports.has(e))throw new Dn(e);return this.ports.get(e)}missing(e){return e.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(k.clock)}identity(){return this.resolve(k.identity)}},Dr=class{constructor(e=0,n=1){this.step=n;this.t=e;}step;t;now(){let e=this.t;return this.t+=this.step,e}},_r=class{constructor(e="id"){this.prefix=e;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function fc(t){let e=p(t.limits),n=Object.freeze({...t.config??{}}),r=t.capacity??e.maxDecompressedBytes,o=t.id??"op",i={id:o,limits:e,config:n,ports:t.ports,budget:new jt(`op:${o}`,r),cancellation:new Vt};return Object.freeze(i)}function gc(t){t.budget.dispose();}var Lr=Object.freeze({maxRecursionDepth:{unit:"depth",phase:"xml-parse"},maxElementCount:{unit:"count",phase:"xml-parse"},maxPartCount:{unit:"count",phase:"package-read"},maxDecompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressionRatio:{unit:"ratio",phase:"package-read"},maxChunkBytes:{unit:"bytes",phase:"package-read"},maxPaginationPasses:{unit:"passes",phase:"layout"},maxQueueDepth:{unit:"count",phase:"output"}}),Ei=Object.keys(Lr);function hc(t,e){return new u(`${Lr[e].phase}:${e}`,t[e])}var Fr=class{counter;current=0;peak=0;constructor(e){this.counter=new u("memory",e);}allocate(e){this.counter.add(e),this.current+=e,this.current>this.peak&&(this.peak=this.current);}free(e){this.counter.release(e),this.current=Math.max(0,this.current-e);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function yc(){for(let t of Ei){let e=o[t],n$1=n[t];if(!Number.isFinite(e)||e<=0)throw new Error(`default ${t} must be finite > 0`);if(!Number.isFinite(n$1)||n$1<=0)throw new Error(`ceiling ${t} must be finite > 0`);if(e>n$1)throw new Error(`default ${t} exceeds ceiling`)}}function zt(t,e=new Set){let n=new WeakSet,r=[],o=i=>{if(i===null)return "null";let a=typeof i;if(a==="boolean")return i?"true":"false";if(a==="number"){let l=i;if(!Number.isFinite(l))throw new Error(`non-finite number is not comparable: ${l}`);return Object.is(l,-0)?"0":String(l)}if(a==="string")return JSON.stringify(i);if(a==="bigint")return `${i.toString()}n`;if(Array.isArray(i))return `[${i.map((l,c)=>{r.push(c);try{return o(l)}finally{r.pop();}}).join(",")}]`;if(a==="object"){let l=i;if(n.has(l))throw new Error("cannot canonicalize a cyclic structure");n.add(l);let d=Object.keys(l).filter(u=>!e.has(u)).sort().map(u=>{r.push(u);try{return `${JSON.stringify(u)}:${o(l[u])}`}finally{r.pop();}}).join(",");return n.delete(l),`{${d}}`}let s=r.length>0?` at ${r.map(String).join(".")}`:"";throw new Error(`unsupported value type in comparator input: ${a}${s}`)};return o(t)}function Hr(t,e){return xc(zt(t,e))}function xc(t){let e=3421674724,n=2216829733;for(let r=0;r<t.length;r++){n=(n^t.charCodeAt(r))>>>0;let o=n*435,i=Math.floor(o/4294967296);e=Math.imul(e,435)+Math.imul(n,256)+i>>>0,n=o>>>0;}return e.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}var Me="dev.docx-editor.core.comparator",$r={authoredState:{id:`${Me}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${Me}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${Me}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${Me}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${Me}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${Me}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${Me}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${Me}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${Me}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${Me}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Ur(t,e,n,r={}){let o=$r[t];switch(o.mode){case "sync-optimization-only":throw new Error(`${o.id} is not an equivalence basis (${o.note})`);case "tolerance":{if(r.epsilon===void 0)throw new Error(`${o.id} requires an explicit epsilon`);return {equal:Ti(e,n,r.epsilon)}}case "exact":case "canonical-exact":{let i=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=zt(e,i),s=zt(n,i);return a===s?{equal:true}:{equal:false,left:a,right:s}}}}function Br(t,e){let n=$r[t];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let r=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return Hr(e,r)}function Ti(t,e,n){return typeof t=="number"&&typeof e=="number"?Number.isFinite(t)&&Number.isFinite(e)&&Math.abs(t-e)<=n:Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((r,o)=>Ti(r,e[o],n)):false}var Ci=new Set([...h,...i]),wi=/^[0-9a-f]{16}$/,kc=/^[0-9a-f]*$/;function jr(t){let e=[],n=o=>e.push(o);t.formatVersion!==1&&n(`unsupported formatVersion ${t.formatVersion}`),t.documentId||n("documentId is required"),t.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(t.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;t.steps.forEach((o,i)=>{let a=`step[${i}]`;Ci.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let s=o.expect;s.outcome==="applied"?(s.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):s.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${s.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=s.committedRevision,s.modelChange&&Pc(s.modelChange,a,n)):(s.committedRevision!==void 0&&n(`${a}: ${s.outcome} step must not commit a revision`),s.authoredStateHash!==void 0&&n(`${a}: ${s.outcome} step must not change authored state`)),s.authoredStateHash!==void 0&&!wi.test(s.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),s.outputHash!==void 0&&!wi.test(s.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...t.snapshots??[],...t.updates??[]])o.documentId!==t.documentId&&n(`envelope documentId ${o.documentId} != ${t.documentId}`),kc.test(o.bytesHex)||n("envelope bytesHex must be hex"),o.bytesHex.length!==o.byteLength*2&&n(`envelope byteLength ${o.byteLength} disagrees with ${o.bytesHex.length/2} decoded bytes`);return {valid:e.length===0,errors:e}}function Pc(t,e,n){Ci.has(t.origin)||n(`${e}: modelChange origin ${t.origin} unknown`),t.toRevision<=t.fromRevision&&n(`${e}: modelChange revision must advance`);}function Oc(t,e){let n=jr(t);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return e.init(t),t.steps.forEach((o,i)=>{let a=`step[${i}]`,s=e.applyStep(o),l=o.expect;if(s.outcome!==l.outcome){r.push(`${a}: outcome ${s.outcome} != expected ${l.outcome}`);return}if(l.outcome==="applied"&&(s.committedRevision!==l.committedRevision&&r.push(`${a}: revision ${s.committedRevision} != expected ${l.committedRevision}`),l.authoredStateHash!==void 0))if(s.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {Ur("authoredState",s.authoredState,s.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let d=Mi(s.authoredState);d!==l.authoredStateHash&&r.push(`${a}: authoredStateHash ${d} != expected ${l.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function Mi(t){return Br("authoredState",t)}var bc="urn:schemas-microsoft-com:office:office";function Sc(t){return t.kind==="textValue"||t.namespaceUri!==la?false:t.localName==="object"?true:t.localName==="pict"&&t.children.some(e=>e.kind!=="textValue"&&e.namespaceUri===bc&&e.localName==="OLEObject")}function Gt(t){let e=[...t];for(;e.length;){let n=e.pop();if(n.kind!=="textValue"){if(Sc(n))return true;for(let r of n.children)e.push(r);}}return false}var Ai=24,Fn=Object.freeze([Object.freeze({localName:"kern",attributes:Object.freeze({val:"2"})}),Object.freeze({localName:"sz",attributes:Object.freeze({val:String(Ai)})}),Object.freeze({localName:"szCs",attributes:Object.freeze({val:String(Ai)})})]),Ln=Object.freeze([Object.freeze({localName:"spacing",attributes:Object.freeze({after:"160",line:"278",lineRule:"auto"})})]),_i=Object.freeze({run:true,paragraph:true}),Fi=Object.freeze({run:false,paragraph:false});function Li(t){if(!t)return _i;let e=n=>t.children.some(r=>r.kind!=="textValue"&&r.namespaceUri===la&&r.localName===n);return {run:!e("rPrDefault"),paragraph:!e("pPrDefault")}}function Vr(t,e){return t&&t.namespaceUri!==la?Fi:Li(e)}function Fu(t){return t?t.namespaceUri!==la?Fi:Li(Rc(t)):_i}function _n(t,e,n,r){return {id:n,kind:t,namespaceUri:la,localName:e,prefix:"w",namespaceBindings:[],attributes:[],children:r}}function Di(t,e){let n=t==="rPr"?Fn:Ln;return _n(t==="rPr"?"runProperties":"paragraphProperties",t,`${e}-${t}`,n.map(r=>Vi$1(r,`${e}-${t}-${r.localName}`)))}function Rc(t){let e=t.children.find(n=>n.kind!=="textValue"&&n.namespaceUri===la&&n.localName==="docDefaults");return e&&e.kind!=="textValue"?e:void 0}function Hi(t,e,n){let r=Vr(t,e);if(!r.run&&!r.paragraph)return e;let o=[];r.run&&o.push(_n("generic","rPrDefault",`${n}-rPrDefault`,[Di("rPr",n)])),r.paragraph&&o.push(_n("generic","pPrDefault",`${n}-pPrDefault`,[Di("pPr",n)]));let i=r.run?[...o,...e?.children??[]]:[...e?.children??[],...o];return e?{...e,children:i}:_n("generic","docDefaults",`${n}-docDefaults`,i)}var ut="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ic="http://schemas.openxmlformats.org/package/2006/relationships",Nc="http://schemas.openxmlformats.org/drawingml/2006/main",Bi="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",ji="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",Vi="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",zi="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",Gi="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",zr="application/vnd.openxmlformats-package.relationships+xml",Gr=`${ut}/styles`,Wr=`${ut}/numbering`,Wi=`${ut}/footnotes`,Ki=`${ut}/endnotes`,Xi=`${ut}/officeDocument`,vc=`${ut}/theme`;function Ee(t){return t.kind!=="textValue"}function $i(t,e){return {...t,children:e}}function Ye(t,e){if(e(t),t.kind!=="textValue")for(let n of t.children)Ye(n,e);}var Ec=new Set(["pStyle","rStyle","tblStyle"]);function Kr(t,e){for(let n of t)Ye(n,r=>{if(r.kind!=="textValue"&&Ec.has(r.localName)&&r.namespaceUri===la){let o=$f(r,"val");o&&e.add(o);}});}function Xr(t,e){for(let n of t)Ye(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===la){let o=$f(r,"val");o&&e.add(o);}});}function Yr(t){let e=new Set;return Wt(t,e),e}function Wt(t,e){for(let n of t)Ye(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===ut&&o.value.length>0&&e.add(o.value);});}function Se(t){return /^\d+$/.test(t)?t.replace(/^0+(?=\d)/,""):t}function $n(t,e){let n={footnote:new Set,endnote:new Set},r=[],o=i=>{for(let a of i)Ye(a,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",c=$f(s,"id");if(c===void 0)return;let d=Se(c);n[l].has(d)||(n[l].add(d),r.push({kind:l,id:d}));});};for(o(t);r.length>0;){let i=r.pop(),a=e(i.kind,i.id);a!==null&&o([a]);}return n}function qr(t,e,n){if(t.kind==="textValue")return t;let r=[],o=false;for(let i of t.children){if(i.kind!=="textValue"&&i.namespaceUri===la&&(i.localName==="footnoteReference"||i.localName==="endnoteReference")){let l=i.localName==="footnoteReference"?e:n,c=$f(i,"id");if(i.kind!=="noteReference"||c===void 0||!l.has(Se(c))){o=true;continue}}let s=qr(i,e,n);s!==i&&(o=true),r.push(s);}return o?{...t,children:r}:t}function Tc(t,e){for(let n of Ke(t,e)){if(n.type!==Gr||n.targetMode==="External")continue;let r=B(n.ownerPart,n.rawTarget);if(r.ok)return t.parts.get(r.partName)??null}return t.parts.get("/word/styles.xml")??null}function Yi(t,e,n){for(let r of Ke(t,e)){if(r.type!==n||r.targetMode==="External")continue;let o=B(r.ownerPart,r.rawTarget);if(o.ok)return t.parts.get(o.partName)??null}return null}function qi(t,e){let n=Tc(t,e),r=new Map,o=[],i=null;if(n&&Ee(n.root))for(let a of n.root.children){if(!Ee(a))continue;if(a.localName==="docDefaults"&&a.namespaceUri===la){i=a;continue}if(a.localName!=="style"||a.namespaceUri!==la)continue;let s=$f(a,"styleId");s&&r.set(s,a),($f(a,"default")==="1"||$f(a,"default")==="true")&&o.push(a);}return {part:n,byId:r,defaults:o,docDefaults:i}}var wc=new Set(["basedOn","link","next"]);function Ji(t,e){let n=new Set,r=[...e];for(let a of t.defaults){let s=$f(a,"styleId");s&&r.push(s);}let o=[];for(;r.length>0;){let a=r.pop();if(n.has(a))continue;n.add(a);let s=t.byId.get(a);if(s){o.push(s);for(let l of s.children)if(Ee(l)&&wc.has(l.localName)&&l.namespaceUri===la){let c=$f(l,"val");c&&r.push(c);}}}if(!t.part||!Ee(t.part.root))return o;let i=new Map;return t.part.root.children.forEach((a,s)=>i.set(a,s)),o.sort((a,s)=>(i.get(a)??0)-(i.get(s)??0))}function Jr(t,e,n){let r=Yi(t,e,Wr)??t.parts.get("/word/numbering.xml")??null;if(!r||!Ee(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],i=new Set;for(let s of r.root.children){if(!Ee(s)||s.localName!=="num"||s.namespaceUri!==la)continue;let l=$f(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let c of s.children)if(Ee(c)&&c.localName==="abstractNumId"){let d=$f(c,"val");d&&i.add(d);}}}let a=[];for(let s of r.root.children){if(!Ee(s)||s.localName!=="abstractNum"||s.namespaceUri!==la)continue;let l=$f(s,"abstractNumId");l&&i.has(l)&&a.push(s);}return {part:r,nums:o,abstracts:a}}var Hn={latin:null,eastAsia:null,cs:null};function Qi(t,e){let n=Yi(t,e,vc);if(!n)return {major:Hn,minor:Hn};let r={major:{...Hn},minor:{...Hn}};return Ye(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==Nc||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let i=o.localName==="majorFont"?r.major:r.minor;for(let a of o.children){if(!Ee(a))continue;let s=$f(a,"typeface");s&&(a.localName==="latin"?i.latin=s:a.localName==="ea"?i.eastAsia=s:a.localName==="cs"&&(i.cs=s));}}),{major:r.major,minor:r.minor}}function Cc(t,e){let n=e.startsWith("major")?t.major:t.minor;return e.endsWith("EastAsia")?n.eastAsia??n.latin:e.endsWith("Bidi")?n.cs??n.latin:n.latin}var Mc=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],Ui=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function qe(t,e){if(t.kind==="textValue")return t;let n=t.attributes;if(t.localName==="rFonts"&&t.namespaceUri===la){let i=[],a=new Map;for(let s of t.attributes){let l=Mc.find(([c])=>c===s.localName);if(l&&s.namespaceUri===la){let c=Cc(e,s.value);c&&a.set(l[1],c);continue}i.push(s);}for(let[s,l]of a)i.some(c=>c.localName===s)||i.push({kind:"genericExtension",namespaceUri:la,localName:s,prefix:"w",value:l});n=i;}else t.attributes.some(i=>Ui.has(i.localName)&&i.namespaceUri===la&&t.attributes.some(a=>a.localName==="val"))&&(n=t.attributes.filter(i=>!(Ui.has(i.localName)&&i.namespaceUri===la)));let r=t.children.map(i=>qe(i,e)),o=r.some((i,a)=>i!==t.children[a]);return n===t.attributes&&!o?t:{...t,attributes:n,children:r}}function Zi(t,e,n){return {id:t,name:t,contentType:e,root:n}}function es(t,e){if(t.root.kind==="document"){let r=t.root.children.find(i=>i.kind==="body"),o=r&&Ee(r)?$i(r,e):{id:"fragment#body",kind:"body",namespaceUri:la,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:e};return $i(t.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:la,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:e};return {id:"fragment#document",kind:"document",namespaceUri:la,localName:"document",prefix:"w",namespaceBindings:Ee(t.root)?t.root.namespaceBindings:[],attributes:[],children:[n]}}function Kt(t){let e=t.map(n=>{let r=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${S(n.id)}" Type="${S(n.type)}" Target="${S(n.rawTarget)}"${r}/>`}).join("");return `<Relationships xmlns="${Ic}">${e}</Relationships>`}function ts(t,e){let n=e;for(;t.has(`rId${n}`);)n+=1;return `rId${n}`}function ns(t){let e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1).toLowerCase()}function Un(t,e){return {...t,children:e}}function Bn(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===la}function Xt(t,e=[]){if(t.kind==="textValue")return e;t.kind==="paragraph"&&e.push(t.id);for(let n of t.children)Xt(n,e);return e}function rs(t,e){if(t.kind==="textValue")return null;if(t.kind==="paragraph"&&t.id===e)return t;for(let n of t.children){let r=rs(n,e);if(r)return r}return null}function Ac(t){let e=(n,r)=>{if(n.kind==="textValue")return n;if(r&&Bn(n,"vMerge")){if($f(n,"val")==="restart")return n;let i=[...n.attributes.filter(a=>!(a.localName==="val"&&a.namespaceUri===la)),{kind:"wmlVal",namespaceUri:la,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:i}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||Bn(n,"tc");return Un(n,n.children.map(i=>e(i,o)))};return Un(t,t.children.map(n=>e(n,false)))}function os(t,e){if(!(t.kind==="textValue"||t.kind==="table")){if(Bn(t,"tr")){e.push(t);return}for(let n of t.children)os(n,e);}}function as(t,e,n){if(t.kind==="textValue"||t.kind==="table")return {node:t,hadRows:false,keptRows:false};if(Bn(t,"tr")){if(!e.has(t))return {node:null,hadRows:true,keptRows:false};let a=n.value?Ac(t):t;return n.value=false,{node:a,hadRows:true,keptRows:true}}let r=false,o=false,i=[];for(let a of t.children){let s=as(a,e,n);r||=s.hadRows,o||=s.keptRows,s.node!==null&&i.push(s.node);}return r?{node:o?Un(t,i):null,hadRows:true,keptRows:o}:{node:t,hadRows:false,keptRows:false}}function is(t,e,n){let r=[];for(let l of t.children)os(l,r);let o=new Set(Xt(t).filter(l=>e.inRange.has(l)));if(o.size===0)return;let i=r.filter(l=>{let c=Xt(l);return c.length>0&&c.every(d=>e.covered.has(d))}),a=new Set(i.flatMap(l=>Xt(l)));if(i.length>0&&o.size===a.size&&[...o].every(l=>a.has(l))){let l={value:true},c=new Set(i),d=[];for(let u of t.children){let m=as(u,c,l);m.node!==null&&d.push(m.node);}n.push(Un(t,d));return}for(let l of Xt(t)){if(!e.inRange.has(l))continue;let c=rs(t,l);c&&n.push(c);}}var Dc="http://schemas.openxmlformats.org/package/2006/content-types",_c=5e4;function Ae(t){return t.kind!=="textValue"}function ss(t,e=[]){if(t.kind==="textValue")return e;t.kind==="paragraph"&&e.push(t.id);for(let n of t.children)ss(n,e);return e}function Qr(t,e){if(t.kind==="textValue")return null;if(t.kind==="paragraph"&&t.id===e)return t;for(let n of t.children){let r=Qr(n,e);if(r)return r}return null}function Fc(){return {id:"fragment#styles",kind:"generic",namespaceUri:la,localName:"styles",prefix:"w",namespaceBindings:[{prefix:"w",namespaceUri:la}],attributes:[],children:[]}}function $e(t,e){return {...t,children:e}}function Lc(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===la}function Hc(t){if(t.root.kind==="document"){let e=t.root.children.find(n=>n.kind==="body");return e&&Ae(e)?e:null}return Ae(t.root)?t.root:null}function $c(t,e){return ss(t).some(n=>e.has(n))}function Zr(t,e,n){for(let r of t)if(Ae(r)){if(r.kind==="paragraph"){e.inRange.has(r.id)&&n.push(r);continue}if(e.fullBlocks.has(r.id)){n.push(r);continue}if(r.kind==="table"){is(r,e,n);continue}if(r.kind==="contentControl"){let o=r.children.find(i=>i.kind==="contentControlContent");o&&Ae(o)&&Zr(o.children,e,n);continue}$c(r,e.inRange)&&Zr(r.children,e,n);}}var Uc=new Set(["commentRangeStart","commentRangeEnd"]);function Bc(t){return t.kind==="run"&&t.children.some(e=>e.kind==="commentReference")}function eo(t){if(t.kind==="textValue")return t;if(Uc.has(t.localName)&&t.namespaceUri===la||Bc(t)||Lc(t,"sectPr"))return null;let e=false,n=[];for(let r of t.children){let o=eo(r);if(o===null){e=true;continue}o!==r&&(e=true),n.push(o);}return e?$e(t,n):t}function jc(t){let e=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){for(let c of l.children)if(c.kind==="fldChar"){let d=$f(c,"fldCharType");e.push({nodeId:c.id,type:d==="separate"||d==="end"?d:"begin"});}else c.kind==="instrText"&&e.push({nodeId:c.id,type:"instr"});return}for(let c of l.children)n(c);}};for(let l of t)n(l);if(e.length===0)return t;let r=new Set,o=[],i=null,a=[];for(let l of e){if(l.type==="begin"){o.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let d=o[o.length-1];d?d.separateId=l.nodeId:i=l.nodeId;continue}if(l.type==="instr"){let d=o[o.length-1];d?d.instrIds.push(l.nodeId):i===null&&a.push(l.nodeId);continue}if(!o.pop()){r.add(l.nodeId),i!==null&&r.add(i);for(let d of a)r.add(d);i=null,a=[];}}for(let l of o){r.add(l.beginId),l.separateId!==null&&r.add(l.separateId);for(let c of l.instrIds)r.add(c);}i!==null&&r.add(i);for(let l of a)r.add(l);if(r.size===0)return t;let s=l=>{if(l.kind==="textValue")return l;if(r.has(l.id))return null;let c=[],d=false;for(let u of l.children){let m=s(u);if(m===null){d=true;continue}m!==u&&(d=true),c.push(m);}return d?$e(l,c):l};return t.map(l=>s(l)).filter(l=>l!==null)}function to(t){if(t.kind==="textValue")return t.value.length;let e=0;for(let n of t.children)e+=to(n);return e}function Vc(t,e){let n=[];for(let r of t.children){if(r.kind!=="contentControl"){n.push(r);continue}let o=e.get(r.id),i=to(r);if(o===void 0||i>=o){n.push(r);continue}if(i===0)continue;let a=r.children.find(s=>s.kind==="contentControlContent");a&&Ae(a)?n.push(...a.children):n.push(r);}return $e(t,n)}function zc(t){let e=new Set,n=new Set,r=a=>{if(a.kind!=="textValue"){if(a.kind==="bookmarkStart"){let s=$f(a,"id");s!==void 0&&e.add(s);}if(a.kind==="bookmarkEnd"){let s=$f(a,"id");s!==void 0&&n.add(s);}for(let s of a.children)r(s);}};for(let a of t)r(a);let o=new Set([...e].filter(a=>n.has(a)));if(o.size===e.size&&o.size===n.size)return t;let i=a=>{if(a.kind==="textValue")return a;if(a.kind==="bookmarkStart"||a.kind==="bookmarkEnd"){let c=$f(a,"id");return c!==void 0&&o.has(c)?a:null}let s=[],l=false;for(let c of a.children){let d=i(c);if(d===null){l=true;continue}d!==c&&(l=true),s.push(d);}return l?$e(a,s):a};return t.map(a=>i(a)??a)}function Gc(t,e,n){let r=t.parts.get(e.partName);if(!r)return {ok:false,reason:"unknown-part"};if(e.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let o=e.paragraphIds[0],i=e.paragraphIds[e.paragraphIds.length-1],a=new Map;for(let P of [o,i]){let L=Qr(r.root,P);if(!L)return {ok:false,reason:"empty-range"};for(let z of L.children)z.kind==="contentControl"&&a.set(z.id,to(z));}let s=r,l=Qr(s.root,i);if(!l)return {ok:false,reason:"empty-range"};let c=og(l);if(e.endOffset<c){let P=xl$1(s,{op:"deleteText",paragraphId:i,start:e.endOffset,end:c},{deferValidation:true});if(!P.ok)return {ok:false,reason:"trim-refused"};s=P.part;}if(e.startOffset>0){let P=xl$1(s,{op:"deleteText",paragraphId:o,start:0,end:e.startOffset},{deferValidation:true});if(!P.ok)return {ok:false,reason:"trim-refused"};s=P.part;}let d=Hc(s);if(!d)return {ok:false,reason:"unknown-part"};let u={inRange:new Set(e.paragraphIds),covered:new Set(e.coveredParagraphIds),fullBlocks:new Set(e.fullyCoveredBlockIds)},m=[];if(Zr(d.children,u,m),m.length===0)return {ok:false,reason:"empty-range"};if(m.length>_c)return {ok:false,reason:"resource-limit"};let O=m.map(P=>eo(P)).filter(P=>P!==null).map(P=>P.kind!=="paragraph"||P.id!==o&&P.id!==i?P:Vc(P,a));O=[...jc(O)],O=[...zc(O)];let f=lh(t,"footnote"),y=lh(t,"endnote"),R=(P,L)=>Ae(P)&&P.namespaceUri===la&&P.localName===L,h=$n(O,(P,L)=>{let z=P==="footnote"?f:y;if(!z||!Ae(z.root))return null;for(let J of z.root.children){if(!R(J,P))continue;let W=$f(J,"id");if(W!==void 0&&Se(W)===L)return J}return null}),p=h.footnote,S$1=h.endnote;p.size===0&&(f=null),S$1.size===0&&(y=null);let C$1=(P,L,z)=>{if(!P||!Ae(P.root))return [];let J=[];for(let W of P.root.children){if(!R(W,L))continue;let re=$f(W,"id"),Ge=$f(W,"type");if(Ge==="separator"||Ge==="continuationSeparator"){J.push(W);continue}if(re!==void 0&&z.has(Se(re))){let We=eo(W);We&&Ae(We)&&J.push(We);}}return J},D=C$1(f,"footnote",p),H=C$1(y,"endnote",S$1),v=[...D,...H];if(Gt(O)||Gt(v))return {ok:false,reason:"unsupported-content"};let M=[...O,...v],Y=new Set;Kr(M,Y);let j=qi(t,t.mainDocumentPart),ne=new Set;Xr(M,ne);let Q=[],$=Jr(t,t.mainDocumentPart,ne);for(;;){let P=Y.size,L=ne.size;Q=Ji(j,Y),Xr(Q,ne),$=Jr(t,t.mainDocumentPart,ne);let z=[...$.nums,...$.abstracts];Kr(z,Y);for(let J of z)Ye(J,W=>{if(W.kind!=="textValue"&&(W.localName==="styleLink"||W.localName==="numStyleLink")&&W.namespaceUri===la){let re=$f(W,"val");re&&Y.add(re);}});if(Y.size===P&&ne.size===L)break}let te=Qi(t,t.mainDocumentPart),me=Q.map(P=>qe(P,te)),le=j.part&&Ae(j.part.root)?j.part.root:null,_=Hi(le,j.docDefaults,"fragment#doc-defaults"),F=_?qe(_,te):null;O=O.map(P=>qe(P,te));let V=D.map(P=>qe(P,te)),ee=H.map(P=>qe(P,te)),x=new Set;Wt(O,x);let g=Ke(t,r.name).filter(P=>x.has(P.id)),T=new Map,U=0,K=P=>{let L=new Set;for(let z of P){if(z.targetMode==="External")continue;let J=B(z.ownerPart,z.rawTarget);if(!J.ok){L.add(z.id);continue}if((Le(t,J.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let re=t.partBytes.get(J.partName)??t.partBytes.get(J.partName.replace(/^\//,""));re?(T.set(J.partName,re),U+=re.byteLength):L.add(z.id);continue}L.add(z.id);}return L},B$1=K(g),ce=(P,L)=>{if(P.kind==="textValue")return P;if(P.kind==="drawing"||P.namespaceUri===la&&(P.localName==="pict"||P.localName==="object")){let W=new Set;Wt([P],W);for(let re of W)if(L.has(re))return null;return P}let z=[],J=false;for(let W of P.children){let re=ce(W,L);if(re===null){J=true;continue}re!==W&&(J=true),z.push(re);}return J?$e(P,z):P};B$1.size>0&&(O=O.map(P=>ce(P,B$1)).filter(P=>P!==null));let ae=g.filter(P=>!B$1.has(P.id)),et=(P,L)=>{if(!P)return [];let z=new Set;Wt(L,z);let J=Ke(t,P.name).filter(re=>z.has(re.id)),W=K(J);if(W.size>0)for(let re=0;re<L.length;re+=1){let Ge=ce(L[re],W);Ge!==null&&(L[re]=Ge);}return J.filter(re=>!W.has(re.id))},rn=et(f,V),on=et(y,ee),Pe=new Map,ht=[],er=new Map,tt=(P,L,z)=>{let J=Zi(P,L,z);Pe.set(P.slice(1),Vd$1(Ba(J))),ht.push([P,L]),er.set(P,J);},k=(P,L)=>P.map(z=>{if(z.targetMode==="External")return {...z,ownerPart:L};let J=B(z.ownerPart,z.rawTarget);return {...z,ownerPart:L,rawTarget:J.ok?J.partName:z.rawTarget}}),N=k(ae,"/word/document.xml"),E=k(rn,"/word/footnotes.xml"),A=k(on,"/word/endnotes.xml"),G=new Set(N.map(P=>P.id)),X=9001,ie=(P,L)=>{let z=ts(G,X);X+=1,G.add(z),N.push({ownerPart:"/word/document.xml",id:z,type:P,rawTarget:L,targetMode:"Internal",order:N.length});},Re=es(s,O);if(tt("/word/document.xml",Bi,Re),me.length>0||F){let P=$e(le??Fc(),[...F?[F]:[],...me]);tt("/word/styles.xml",ji,P),ie(Gr,"styles.xml");}if($.part&&($.nums.length>0||$.abstracts.length>0)){let P=$e($.part.root,[...$.abstracts.map(L=>qe(L,te)),...$.nums]);tt("/word/numbering.xml",Vi,P),ie(Wr,"numbering.xml");}f&&V.length>0&&(tt("/word/footnotes.xml",zi,$e(f.root,V)),ie(Wi,"footnotes.xml"),E.length>0&&Pe.set("word/_rels/footnotes.xml.rels",Vd$1(Kt(E)))),y&&ee.length>0&&(tt("/word/endnotes.xml",Gi,$e(y.root,ee)),ie(Ki,"endnotes.xml"),A.length>0&&Pe.set("word/_rels/endnotes.xml.rels",Vd$1(Kt(A))));let ue=new Map;for(let[P,L]of T){Pe.set(P.slice(1),L);let z=ns(P);z&&!ue.has(z)&&ue.set(z,Le(t,P)??"application/octet-stream");}let we={ownerPart:"/",id:"rId1",type:Xi,rawTarget:"word/document.xml",targetMode:"Internal",order:0};Pe.set("word/_rels/document.xml.rels",Vd$1(Kt(N))),Pe.set("_rels/.rels",Vd$1(Kt([we])));let nt=[`<Default Extension="rels" ContentType="${zr}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...ue].map(([P,L])=>`<Default Extension="${S(P)}" ContentType="${S(L)}"/>`)].join(""),je=ht.map(([P,L])=>`<Override PartName="${S(P)}" ContentType="${S(L)}"/>`).join("");Pe.set("[Content_Types].xml",Vd$1(`<Types xmlns="${Dc}">${nt}${je}</Types>`));let Ve=new Map;Ve.set("/",[we]),Ve.set("/word/document.xml",N),E.length>0&&Ve.set("/word/footnotes.xml",E),A.length>0&&Ve.set("/word/endnotes.xml",A);let se=[];for(let P of Ve.values())for(let L of P)L.targetMode==="External"&&se.push({ownerPart:L.ownerPart,id:L.id,type:L.type,rawTarget:L.rawTarget,sinkSafe:C(L.rawTarget).ok});let de=new Map;de.set("rels",zr),de.set("xml","application/xml");for(let[P,L]of ue)de.set(P,L);let ze={defaults:de,overrides:new Map(ht)},At=new Map;for(let[P,L]of Pe)At.set(P.startsWith("/")?P:`/${P}`,L);return {ok:true,bytes:Ud$1(Pe),package:Object.freeze({parts:er,partBytes:At,relationships:Ve,externalTargets:se,contentTypes:ze,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:e.lastMarkCovered,blockCount:O.length,mediaBytes:U}}function oe(t){return t.kind!=="textValue"}function q(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===la}function Te(t,e){for(let n of t)e(n),n.kind!=="textValue"&&Te(n.children,e);}function Je(t){if(t.kind==="textValue")return `T(${t.value})`;if(t.namespaceUri===la&&t.localName.startsWith("rsid"))return "";let e=t.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===qa&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=t.children.map(Je).join("");return `E(${t.namespaceUri}:${t.localName}[${e}]{${n}})`}function qt(t){return `S[${t.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${t.children.map(Je).join("")}`}function zn(t){let e=[],n=new Map,r=new Set,o=null;if(t&&oe(t.root))for(let i of t.root.children){if(!oe(i))continue;if(q(i,"docDefaults")){o=i;continue}if(!q(i,"style"))continue;e.push(i);let a=$f(i,"styleId");a&&n.set(a,i);let s=i.children.find(c=>q(c,"name")),l=s?$f(s,"val"):void 0;l&&r.add(l);}return {part:t,styles:e,docDefaults:o,byId:n,names:r}}function jn(t,e,n){let r=new Map;if(!t)return r;let o=t.children.find(a=>q(a,e));if(!o||!oe(o))return r;let i=o.children.find(a=>q(a,n));if(!i||!oe(i))return r;for(let a of i.children)a.kind!=="textValue"&&r.set(a.localName,a);return r}function cs(t){let e=t.part?.root;return e&&oe(e)?e:null}function ls(t){return Vr(cs(t),t.docDefaults)}function Vn(t){return new Map(t.map(e=>[e.localName,Vi$1(e,`fragment#application-${e.localName}`)]))}function Wc(t,e){let n=new Set,r=e;for(let o=0;o<16&&r;o+=1){let i=t.byId.get(r);if(!i)break;let s=Yt(i,"pPr")?.children.find(c=>q(c,"spacing"));if(s&&oe(s))for(let c of s.attributes)n.add(c.localName);let l=i.children.find(c=>q(c,"basedOn"));r=l?$f(l,"val"):void 0;}return n}function no(t,e,n,r){let o=e;for(let i=0;i<16&&o;i+=1){let a=t.byId.get(o);if(!a)return false;let s=a.children.find(c=>q(c,n));if(s&&oe(s)&&s.children.some(c=>c.kind!=="textValue"&&c.localName===r))return true;let l=a.children.find(c=>q(c,"basedOn"));o=l?$f(l,"val"):void 0;}return false}function Kc(t,e){for(let n of t.styles){if($f(n,"type")!==e)continue;let r=$f(n,"default");if(r==="1"||r==="true")return $f(n,"styleId")}}function Yt(t,e){let n=t.children.find(r=>q(r,e));return n&&oe(n)?n:null}var Xc=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])),Yc=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 ro(t,e,n){let r=cs(e)?ls(e):null,o=ls(n),i=r?.run?Vn(Fn):jn(e.docDefaults,"rPrDefault","rPr"),a=o.run?Vn(Fn):jn(n.docDefaults,"rPrDefault","rPr"),s=r?.paragraph?Vn(Ln):jn(e.docDefaults,"pPrDefault","pPr"),l=o.paragraph?Vn(Ln):jn(n.docDefaults,"pPrDefault","pPr"),c=(p,S,C)=>{let D=Kc(p,"paragraph"),H=D?p.byId.get(D):void 0;if(!H)return D;for(let[v,M]of [["rPr",S],["pPr",C]]){let Y=Yt(H,v);if(Y)for(let j of Y.children)j.kind!=="textValue"&&M.set(j.localName,j);}return D};c(e,i,s),c(n,a,l);let d=new Map;for(let[p,S]of i){let C=a.get(p);(!C||Je(C)!==Je(S))&&d.set(p,S);}let u=new Map;for(let[p,S]of s){if(p==="sectPr")continue;let C=l.get(p);(!C||Je(C)!==Je(S))&&u.set(p,S);}if(d.size===0&&u.size===0)return t;let m=0,O=()=>`fragment#materialized-${m++}`,f=p=>{let S=C=>C.kind==="textValue"?{id:O(),kind:"textValue",value:C.value}:{...C,id:O(),children:C.children.map(S)};return S(p)},y=(p,S,C)=>{if(C.length===0)return p;let D=Yt(p,S);if(D){let v=S==="rPr"?Yc:Xc,M=[...D.children];for(let j of C){let ne=j.kind==="textValue"?Number.MAX_SAFE_INTEGER:v.get(j.localName)??Number.MAX_SAFE_INTEGER,Q=M.length;for(let $=0;$<M.length;$+=1){let te=M[$];if(te.kind==="textValue")continue;let me=v.get(te.localName);if(me!==void 0&&me>ne){Q=$;break}}M.splice(Q,0,j);}let Y={...D,children:M};return {...p,children:p.children.map(j=>j===D?Y:j)}}let H={id:O(),kind:S==="rPr"?"runProperties":"paragraphProperties",namespaceUri:la,localName:S,prefix:"w",namespaceBindings:[],attributes:[],children:C};return {...p,children:[H,...p.children]}},R=(p,S,C,D,H)=>{let v=Wc(e,H),M=S.children.find($=>q($,"spacing"));if(M&&oe(M))for(let $ of M.attributes)v.add($.localName);let Y=new Map(D&&oe(D)?D.attributes.map($=>[$.localName,$.value]):[]),j=C.attributes.filter($=>!v.has($.localName)&&Y.get($.localName)!==$.value);if(j.length===0)return p;let ne=M&&oe(M)?{...M,attributes:[...M.attributes,...j]}:{...C,id:O(),attributes:j,children:[]},Q=M?{...S,children:S.children.map($=>$===M?ne:$)}:y(p,"pPr",[ne]).children.find($=>q($,"pPr"));return {...p,children:p.children.map($=>$===S?Q:$)}},b=p=>{let S=Yt(p,"pPr"),C=S?.children.find(j=>q(j,"pStyle")),D=C?$f(C,"val"):void 0,H=[],v=p;for(let[j,ne]of u){let Q=S?.children.some(te=>te.kind!=="textValue"&&te.localName===j),$=!!D&&no(e,D,"pPr",j);j==="spacing"&&(Q||$)&&S!==null&&oe(ne)&&(v=R(v,S,ne,l.get("spacing"),D)),!(Q||$)&&H.push(f(ne));}let M=j=>{if(j.kind==="textValue")return j;if(j.kind==="run"){let Q=Yt(j,"rPr"),$=Q?.children.find(le=>q(le,"rStyle")),te=$?$f($,"val"):void 0,me=[];for(let[le,_]of d)Q?.children.some(V=>V.kind!=="textValue"&&V.localName===le)||te&&no(e,te,"rPr",le)||D&&no(e,D,"rPr",le)||me.push(f(_));return y(j,"rPr",me)}if(j.kind==="paragraphProperties"||j.kind==="runProperties")return j;let ne=j.children.map(M);return ne.some((Q,$)=>Q!==j.children[$])?{...j,children:ne}:j};return M(y(v,"pPr",H))},h=p=>{if(p.kind==="textValue")return p;if(p.kind==="paragraph")return b(p);let S=p.children.map(h);return S.some((C,D)=>C!==p.children[D])?{...p,children:S}:p};return t.map(h)}var ds="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function ge(t,e,n,r){return {...t,attributes:t.attributes.map(o=>o.localName===n&&o.namespaceUri===e?{...o,value:r}:o)}}var qc=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),oo=yh,Ue=new Map;function Rt(t,e){let n=e.styleIds??Ue,r=e.numIds??Ue,o=e.relIds??Ue,i=e.footnoteIds??Ue,a=e.endnoteIds??Ue,s=e.bookmarkIds??Ue,l=e.sdtIds??Ue,c=e.revisionIds??Ue,d=e.docPrIds??Ue,u=(m,O)=>{if(m.kind==="textValue")return m;let f=m;if(m.namespaceUri===la&&qc.has(m.localName)){let h=$f(m,"val"),p=h!==void 0?n.get(h):void 0;p!==void 0&&(f=ge(f,la,"val",p));}if(q(m,"numId")){let h=$f(m,"val"),p=h!==void 0?r.get(h):void 0;p!==void 0&&(f=ge(f,la,"val",p));}if(m.kind==="noteReference"){let h=m.localName==="footnoteReference"?i:a,p=$f(m,"id"),S=p!==void 0?h.get(Se(p)):void 0;S!==void 0&&(f=ge(f,la,"id",S));}if(m.kind==="bookmarkStart"||m.kind==="bookmarkEnd"){let h=$f(m,"id"),p=h!==void 0?s.get(h):void 0;p!==void 0&&(f=ge(f,la,"id",p));}if(q(m,"id")&&O==="sdtPr"){let h=$f(m,"val"),p=h!==void 0?l.get(h):void 0;p!==void 0&&(f=ge(f,la,"val",p));}if(oo(m)){let h=$f(m,"id"),p=h!==void 0?c.get(h):void 0;p!==void 0&&(f=ge(f,la,"id",p));}if(m.kind==="drawingDocPr"){let h=m.attributes.find(S=>S.localName==="id"&&S.namespaceUri==="")?.value,p=h!==void 0?d.get(h):void 0;p!==void 0&&(f=ge(f,"","id",p));}for(let h of f.attributes){if(h.namespaceUri!==ds)continue;let p=o.get(h.value);p!==void 0&&p!==h.value&&(f=ge(f,ds,h.localName,p));}let y=m.localName,R=f.children.map(h=>u(h,y));return f!==m||R.some((h,p)=>h!==f.children[p])?{...f,children:R}:m};return u(t,"")}function ms(t,e,n){let r=t,o=n.get(t)??2;for(;e.has(r);)r=`${t}${o}`,o+=1;return n.set(t,o),r}function us(t,e,n){let r=`${t} (pasted)`,o=n.get(t)??2;for(;e.has(r);)r=`${t} (pasted ${o})`,o+=1;return n.set(t,o),r}var Jc=1e5;function ps(t){let e=Ib(),n=Qc(t,e),r=Zc(t,e),o=ed(t,e);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function ao(t,e,n,r){if(t)return Lb(e,t,r);let o=n;return ()=>String(o++)}function fs(t,e){if(t.add(e),!/^\d{1,10}$/.test(e))return;let n=Number(e);n<=Fb&&t.add(String(n));}function gs(t,e){if(e===void 0)return t;let n=Number(e);return Number.isInteger(n)&&n>t?n:t}function Qc(t,e){let n=new Map;if(t.fragmentBookmarkIds.length===0)return n;let r=0,o=new Set;for(let a of [t.ownerPart,...t.notesParts])Te([a.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=$f(s,"id");l!==void 0&&(fs(o,l),s.kind==="bookmarkStart"&&(r=gs(r,l)));});let i=ao(e,o,r+1,Fb);for(let a of t.fragmentBookmarkIds){if(n.has(a))continue;let s=i();if(s===null)return null;n.set(a,s);}return n}function Zc(t,e){let n=new Map;if(!t.hasRevision)return n;let r=0,o=new Set;for(let s of [t.ownerPart,...t.notesParts]){let l=s===t.ownerPart;Te([s.root],c=>{if(!yh(c))return;let d=$f(c,"id");d!==void 0&&fs(o,d),l&&(r=gs(r,d));});}let i=ao(e,o,r+1,Fb),a=false;return Te(t.travelling,s=>{if(a||!yh(s))return;let l=$f(s,"id");if(l===void 0||n.has(l))return;let c=i();c===null?a=true:n.set(l,c);}),a?null:n}function ed(t,e){let n=new Map;if(!t.hasDocPr)return n;let{used:r}=qe$1(t.pkg),o=Jc;if(!e){let s=re(t.pkg);s.ok&&(o=s.id);}let i=ao(e,r,o,pe),a=false;return Te(t.travelling,s=>{if(a||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(d=>d.localName==="id"&&d.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let c=i();c===null?a=true:n.set(l,c);}),a?null:n}function hs(t,e){return `${e?qt(e):"none"}::${t.children.filter(n=>q(n,"lvlOverride")).map(Je).join("")}`}function ys(t){let e=t.children.find(n=>q(n,"abstractNumId"));return e?$f(e,"val"):void 0}function xs(t,e,n){let r=new Set(["0"]),o=0;for(let s of t?.root.children??[]){if(!oe(s)||!q(s,e))continue;let l=$f(s,n);if(l===void 0)continue;let c=Number(l);Number.isInteger(c)&&(r.add(String(c)),c>o&&(o=c));}let i=Ib();if(i)return Lb(r,i,Gb);let a=o+1;return ()=>String(a++)}function ks(t,e){let n={numIdMap:new Map,numsToImport:[],abstractsToImport:[]};if(!t||!oe(t.root))return n;let r=new Map,o=[];for(let c of t.root.children)if(oe(c))if(q(c,"abstractNum")){let d=$f(c,"abstractNumId");d&&r.set(d,c);}else q(c,"num")&&o.push(c);let i=new Map;if(e&&oe(e.root)){let c=new Map;for(let d of e.root.children){if(!oe(d)||!q(d,"abstractNum"))continue;let u=$f(d,"abstractNumId");u&&c.set(u,d);}for(let d of e.root.children){if(!oe(d)||!q(d,"num"))continue;let u=$f(d,"numId");if(!u)continue;let m=ys(d),O=m?c.get(m):void 0;i.set(hs(d,O),u);}}let a=xs(e,"abstractNum","abstractNumId"),s=xs(e,"num","numId"),l=new Map;for(let c of o){let d=$f(c,"numId");if(!d)continue;let u=ys(c),m=u?r.get(u):void 0,O=hs(c,m),f=i.get(O);if(f!==void 0){n.numIdMap.set(d,f);continue}let y=u?l.get(u):void 0;if(y===void 0&&m&&u){let h=a();if(h===null)return null;y=h,l.set(u,y),n.abstractsToImport.push(ge(m,la,"abstractNumId",y));}let R=s();if(R===null)return null;n.numIdMap.set(d,R);let b=ge(c,la,"numId",R);if(y!==void 0){let h=b.children.map(p=>q(p,"abstractNumId")?ge(p,la,"val",y):p);b={...b,children:h};}n.numsToImport.push(b),i.set(O,R);}return n}var It="http://schemas.openxmlformats.org/officeDocument/2006/relationships",td=`${It}/hyperlink`,Ps=`${It}/image`,Gn=`${It}/numbering`,io=`${It}/styles`,Os="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",bs="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Jt(t,e,n,r){for(let o of Ke(t,e)){if(o.type!==n||o.targetMode==="External")continue;let i=B(o.ownerPart,o.rawTarget);if(i.ok){let a=t.parts.get(i.partName);if(a)return a}}return t.parts.get(r)??null}function nd(t,e){let n=0;return Te([t],r=>{let o=e(r);if(o===void 0)return;let i=Number(o);Number.isInteger(i)&&i>n&&(n=i);}),n}function Wn(t,e,n,r){if(n.length===0)return t;let o=Ra(e,"paste"),i=n.map(c=>eg(c,o)),a=Tk(e,i),s=r??a.root.children.length,l=Ya(a,a.root.id,s,i,{deferValidation:true});return l.ok?Ie(t,l.part):null}function Ss(t,e){if(e.size===0)return [...t];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"||q(o,"pict")||q(o,"object")){let a=false;return Te([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===It&&e.has(l.value)&&(a=true);}),a?null:o}if(o.kind==="hyperlink"){let a=o.attributes.find(s=>s.namespaceUri===It)?.value;if(a!==void 0&&e.has(a))return r(o.children)}let i=r(o.children);return i.length===o.children.length&&i.every((a,s)=>a===o.children[s])?o:{...o,children:i}};function r(o){let i=[];for(let a of o){let s=n(a);s!==null&&(Array.isArray(s)?i.push(...s):i.push(s));}return i}return r(t)}var rd=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),Rs={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function od(t,e){let n=fe$1(t);return n==="unknown"||(Object.hasOwn(Rs,e)?Rs[e]:e)!==n||rd.has(n)&&!se(t,n)?null:n}function so(t,e,n){for(let k of e.parts.values())if(Gt([k.root]))return {ok:false,reason:"unsupported-content"};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 o=r.root.kind==="document"?r.root.children.find(k=>k.kind==="body"):null;if(!o||!oe(o))return {ok:false,reason:"no-fragment-document"};let i=Uk(o.children.filter(k=>k.kind==="paragraph"||k.kind==="table"||k.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let a=t,s=ks(Jt(e,e.mainDocumentPart,Gn,"/word/numbering.xml"),Jt(a,a.mainDocumentPart,Gn,"/word/numbering.xml"));if(!s)return {ok:false,reason:"merge-refused"};let{numIdMap:l,numsToImport:c,abstractsToImport:d}=s,u=zn(Jt(e,e.mainDocumentPart,io,"/word/styles.xml")),m=Jt(a,a.mainDocumentPart,io,"/word/styles.xml"),O=zn(m),f$1=new Map,y=[],R=new Set(O.byId.keys()),b=new Set(O.names),h=new Map,p=new Map,S=new Map,C=(k,N)=>{let E=S.get(k);return E===void 0&&(E=qt(N),S.set(k,E)),E},D=k=>({...k,attributes:k.attributes.filter(N=>!(N.localName==="default"&&N.namespaceUri===la))});for(let k of u.styles){let N=$f(k,"styleId");if(!N)continue;let E=O.byId.get(N),A=qt(Rt(k,{styleIds:f$1,numIds:l}));if(E&&C(N,E)===A){f$1.set(N,N);continue}if(!E){f$1.set(N,N),R.add(N),y.push(D(k));continue}let G=ms(`${N}Pasted`,R,h);R.add(G),f$1.set(N,G),y.push(D(ge(k,la,"styleId",G)));}let H=y.map(k=>{let N=k.children.find(X=>q(X,"name")),E=N?$f(N,"val"):void 0;if(!E||!b.has(E))return E&&b.add(E),k;let A=us(E,b,p);b.add(A);let G=k.children.map(X=>q(X,"name")?ge(X,la,"val",A):X);return {...k,children:G}}),v=null,M=1,Y=Ib()===void 0?null:Mb(Number.MAX_SAFE_INTEGER),j=()=>{if(v)return v;let k=new Map;for(let[N,E]of a.partBytes){let A=N.startsWith("/")?N:`/${N}`;if(!A.startsWith("/word/media/"))continue;k.set(f(E),A);let G=/\/image(\d+)\./.exec(A);G&&(M=Math.max(M,Number(G[1])+1));}return v=k,k},ne=new Map,Q=k=>{let N=ne.get(k);if(!N){N=new Map;for(let E of Ke(a,k)){if(E.targetMode==="External"||E.type!==Ps)continue;let A=B(E.ownerPart,E.rawTarget);A.ok&&N.set(A.partName,E.id);}ne.set(k,N);}return N},$=(k,N)=>{let E=k.lastIndexOf("."),A=E===-1?"":k.slice(E+1);return /^[A-Za-z0-9]{1,8}$/.test(A)?A.toLowerCase():N==="image/jpeg"?"jpeg":N==="image/gif"?"gif":"png"},te=(k,N,E)=>{let A=new Map,G=new Set,X=Q(N),ie=[],Re=new Set,ue=[],we$1=[],nt=new Map,je=[],Ve=e.relationships.get(k)??[];for(let se of Ve){if(!E.has(se.id))continue;if(se.targetMode==="External"){if(se.type===td){let rt=Pg(a,se.rawTarget,N);rt?(a=rt.pkg,A.set(se.id,rt.relationshipId)):G.add(se.id);}else G.add(se.id);continue}let de=B(se.ownerPart,se.rawTarget);if(!de.ok){G.add(se.id);continue}let ze=e.partBytes.get(de.partName)??e.partBytes.get(de.partName.replace(/^\//,"")),At=(Le(e,de.partName)??"").toLowerCase();if(!ze||!At.startsWith("image/")){G.add(se.id);continue}let P=od(ze,At);if(P===null){G.add(se.id);continue}let L=P,z=j(),J=f(ze),W=z.get(J);if(!W){let rt=$(de.partName,L),Ko=an=>a.partBytes.has(an)||a.partBytes.has(an.slice(1))||a.parts.has(an)||Re.has(an),yt;if(Y)do yt=`/word/media/image${Y.next().value}.${rt}`;while(Ko(yt));else {for(yt=`/word/media/image${M}.${rt}`;Ko(yt);)M+=1,yt=`/word/media/image${M}.${rt}`;M+=1;}W=yt,ie.push({partName:W,bytes:ze,contentType:L}),Re.add(W),z.set(J,W);}let re=W.startsWith("/word/")?W.slice(6):W,Ge=X.get(W);if(Ge!==void 0){A.set(se.id,Ge);continue}let We=nt.get(W);We===void 0&&(We=ue.length,nt.set(W,We),ue.push(re),we$1.push(W)),je.push({recordId:se.id,index:We});}if(ie.length>0&&(a=we(a,ie)),ue.length>0){let se=Oe(Qe$1(a,N),N,ue.map(de=>[Ps,de]));if(se.ok){a=se.pkg,se.ids.forEach((de,ze)=>{X.set(we$1[ze],de);});for(let de of je)A.set(de.recordId,se.ids[de.index]);}else for(let de of je)G.add(de.recordId);}return {relIdMap:A,dropRelIds:G}},me=te(e.mainDocumentPart,n,Yr(i));i=Ss(i,me.dropRelIds);let le=new Map,_=new Map,F=[],V=(k,N)=>oe(k)&&k.namespaceUri===la&&k.localName===N,ee={},x=$n(i,(k,N)=>{let E=ee[k];if(E===void 0){E=new Map,ee[k]=E;let A=lh(e,k);if(A&&oe(A.root))for(let G of A.root.children){if(!V(G,k))continue;let X=$f(G,"id");if(X===void 0)continue;let ie=Se(X);E.has(ie)||E.set(ie,G);}}return E.get(N)??null});for(let k of ["footnote","endnote"]){let N=k==="footnote"?le:_,E=x[k];if(E.size===0)continue;let A=lh(e,k);if(!A||!oe(A.root))continue;let G=ei(a,k);if(!G.ok||!G.package)return {ok:false,reason:"merge-refused"};a=G.package;let X=lh(a,k);if(!X)return {ok:false,reason:"merge-refused"};let ie=nd(X.root,ue=>V(ue,k)?$f(ue,"id"):void 0)+1,Re=[];for(let ue of A.root.children){if(!V(ue,k))continue;let we=$f(ue,"id"),nt=$f(ue,"type");if(nt==="separator"||nt==="continuationSeparator"||we===void 0||!E.has(Se(we))||N.has(Se(we)))continue;let je=String(ie++);N.set(Se(we),je),Re.push(ge(ue,la,"id",je));}Re.length>0&&F.push({kind:k,fragmentPartName:A.name,bodies:Uk(Re)});}let g=a.parts.get(n),T=[...i,...F.flatMap(k=>k.bodies)],U=[],K=new Set,B$1=false,ce=false,ae=new Map;Te(T,k=>{if(k.kind!=="textValue"){if(k.kind==="bookmarkStart"||k.kind==="bookmarkEnd"){let N=$f(k,"id");if(N!==void 0&&U.push(N),k.kind==="bookmarkStart"){let E=$f(k,"name");E&&K.add(E);}return}if(oo(k)){B$1=true;return}if(k.kind==="drawingDocPr"){ce=true;return}if(k.kind==="contentControlProperties")for(let N of k.children){if(!q(N,"id"))continue;let E=$f(N,"val");if(E!==void 0&&!ae.has(E)){let A=0,G=`${E}:${ae.size}`;for(let X=0;X<G.length;X+=1)A=A*31+G.charCodeAt(X)>>>0;ae.set(E,String(A%2147483647||1));}}}});let et=ps({pkg:a,ownerPart:g,notesParts:F.map(k=>lh(a,k.kind)).filter(k=>k!==null),travelling:T,fragmentBookmarkIds:U,hasRevision:B$1,hasDocPr:ce});if(!et)return {ok:false,reason:"merge-refused"};let rn=et.bookmarkIds,on=et.revisionIds,Pe=et.docPrIds;if(K.size>0){let k=new Set;if(Te([g.root],N=>{if(N.kind!=="textValue"&&N.kind==="bookmarkStart"){let E=$f(N,"name"),A=$f(N,"id");E&&A!==void 0&&K.has(E)&&k.add(A);}}),k.size>0){let N=A=>{if(A.kind==="textValue")return A;let G=[],X=false;for(let ie of A.children){if((ie.kind==="bookmarkStart"||ie.kind==="bookmarkEnd")&&k.has($f(ie,"id")??"")){X=true;continue}let Re=N(ie);Re!==ie&&(X=true),G.push(Re);}return X?{...A,children:G}:A},E=N(g.root);E!==g.root&&(Va(g.root,E),a=Ie(a,{...g,root:E}));}}let ht=k=>qr(k,le,_);for(let k of F){k.bodies=k.bodies.map(ht);let N=lh(a,k.kind);if(!N)return {ok:false,reason:"merge-refused"};let E=te(k.fragmentPartName,N.name,Yr(k.bodies)),A=Ss(k.bodies,E.dropRelIds);A=[...ro(A,u,O)],A=A.map(X=>Rt(X,{styleIds:f$1,numIds:l,relIds:E.relIdMap,footnoteIds:le,endnoteIds:_,bookmarkIds:rn,sdtIds:ae,revisionIds:on,docPrIds:Pe}));let G=Wn(a,a.parts.get(N.name),A);if(!G)return {ok:false,reason:"merge-refused"};a=G;}if(H.length>0){let k=H.map(E=>Rt(E,{styleIds:f$1,numIds:l}));if(!m){let E=Ia(`<w:styles xmlns:w="${la}"></w:styles>`,{name:"/word/styles.xml",contentType:bs});if(!E.ok)return {ok:false,reason:"merge-refused"};a=Se$1(a,"/word/styles.xml",E.part.root,bs);let A=Re(Qe$1(a,a.mainDocumentPart),a.mainDocumentPart,io,"styles.xml");if(!A.ok)return {ok:false,reason:"merge-refused"};a=A.pkg,m=a.parts.get("/word/styles.xml")??null;}if(!m)return {ok:false,reason:"merge-refused"};let N=Wn(a,a.parts.get(m.name),k);if(!N)return {ok:false,reason:"merge-refused"};a=N,O=zn(a.parts.get(m.name)??null);}if(d.length>0||c.length>0){let k=Jt(a,a.mainDocumentPart,Gn,"/word/numbering.xml");if(!k){let X=Ia(`<w:numbering xmlns:w="${la}"></w:numbering>`,{name:"/word/numbering.xml",contentType:Os});if(!X.ok)return {ok:false,reason:"merge-refused"};a=Se$1(a,"/word/numbering.xml",X.part.root,Os);let ie=Re(Qe$1(a,a.mainDocumentPart),a.mainDocumentPart,Gn,"numbering.xml");if(!ie.ok)return {ok:false,reason:"merge-refused"};a=ie.pkg,k=a.parts.get("/word/numbering.xml")??null;}if(!k)return {ok:false,reason:"merge-refused"};let N=a.parts.get(k.name),E=N.root.children.findIndex(X=>q(X,"num")),A=d.map(X=>Rt(X,{styleIds:f$1,numIds:l})),G=Wn(a,N,A,E===-1?void 0:E);if(!G)return {ok:false,reason:"merge-refused"};if(a=G,G=Wn(a,a.parts.get(k.name),c),!G)return {ok:false,reason:"merge-refused"};a=G;}let tt=[...ro(i,u,O)].map(ht).map(k=>Rt(k,{styleIds:f$1,numIds:l,relIds:me.relIdMap,footnoteIds:le,endnoteIds:_,bookmarkIds:rn,sdtIds:ae,revisionIds:on,docPrIds:Pe}));return {ok:true,pkg:a,blocks:tt}}var Is=16*1024*1024;function ad(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>Qk)return false;let r=0,o=(i,a,s)=>{if(a>s||(r+=1,r>Sk))return false;if(i.kind==="textValue")return true;for(let l of i.children)if(!o(l,a+1,s))return false;return true};for(let i of n.children)if(!o(i,1,Rk))return false;for(let[i,a]of t.parts)if(i!==t.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!o(a.root,1,Rk*4))return false;return true}function lo(t,e,n){if(n.fragmentBytes.byteLength>Is)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=Ee$1(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=r.package;if(!ad(o))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:a,story:s}=i;if(a.compositionActive||t.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=t.currentPackage(),c=a.checkpoint();a.graftPackage(()=>t.currentPackage());let d=0,u="";return Na(t,()=>{let m=a.transact(f=>{for(let h of n.priorOps??[])if(!f.apply(h))return;let y=null,R=f.applyPackage(h=>(y=so(h,o,s.partName),y.ok?y.pkg:h)),b=y;if(!b||!b.ok){u=`fragment-merge:${b?b.reason:"no-merge"}`,f.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}R&&(d=b.blocks.length,f.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:b.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return u.length>0?{ok:false,reason:"invalidArgs",detail:u}:m.ok?m.change?{ok:true,change:t.promoteStoryTransactionToPackageUnit(l,a,c),blockCount:d}:{ok:true,change:null,blockCount:d}:{ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}}},m=>Oa(m))}function Ns(){let t=null;return (e,n,r)=>{let o=t;if(t=null,!Dj(n)||!("paragraphId"in r)||!Fj(e,r.paragraphId))return r;if(r.op==="insertText"&&!r.revision&&r.inside===void 0&&o&&o.partName===e.name&&o.paragraphId===r.paragraphId&&o.offset===r.offset)return {...r,inside:o.controlId};if(r.op!=="deleteText"||r.revision||r.start>=r.end)return r;let i=Ta(e,r.paragraphId);if(i?.kind!=="paragraph")return r;let a=Ik(e,Hk(r));if(a.unprotected.length)return r;let s=mg(i);for(let l of a.touches){let c=s.spanOf(l.control);c&&c.start<=r.start&&c.end>=r.end&&(t={partName:e.name,paragraphId:r.paragraphId,offset:r.start,controlId:l.control.id});}return r}}function co(t,e){for(let[n,r]of e.parts){let o=t.parts.get(n);!o||o.root===r.root||o.root.id!==r.root.id||Wa(o.root,r.root);}return e}var vs=new WeakSet;function id(t){return vs.add(t),t}function Es(t){return vs.has(t)}function Qt(t){return {...t,applyPackage:e=>t.applyPackage(id(e))}}var sd=new Set(["insertText","insertTab","insertHardBreak","insertPageBreak","insertPageField","insertDrawing","deleteText","setParagraphMarkRevision"]),Ts=new Set(["insertDrawing"]);function ld(t){if(!(t===null||t.start!==t.end))return t}var Nt={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function cd(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 pt=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];pushCount=0;subscribers=new Set;historyLimit;settingsPartOverride;contentLockPolicy;storyRef=null;composition=null;constructor(e,n,r={}){let o="root"in e,i=typeof n=="string"?n:void 0,a=typeof n=="object"&&n!==null?n:r;this.current=o?cd(e):e,this.storyPartName=i??(o?e.name:e.mainDocumentPart),this.historyLimit=a.historyLimit??200,this.settingsPartOverride=a.settingsPart,this.contentLockPolicy=yj(a.contentLockPolicy);}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 historyPushCount(){return this.pushCount}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=Ie(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 Hb(n.actorId,()=>nf(n.fieldResults,()=>this.commitTransaction(e,n)))}commitTransaction(e,n){let r=n.origin??g.mutationHuman,o=n.recordsHistory??(r!==g.projection&&r!==g.awareness),i=this.undoStack[this.undoStack.length-1];o&&!this.composition&&i?.group!==n.historyGroup&&this.closeHistoryGroup();let a=this.current,s=this.rev,l=this.current,c=null,d=0,u=new Set,m=new Set,O=new Set,f=new Set,y=new Set,R=[],b=n.minimumImpact??"text-local",h=null,p=false,S=null,C=null,D=new Map,H=new Map,v=_=>{let F=H.get(_.name);F||(F={mint:null,written:new Set},H.set(_.name,F));let V=F;return {mint:()=>(V.mint??=xh(_))(),wrote:ee=>{V.written.add(ee);},wroteUnder:ee=>V.written.has(ee)}},M=()=>{for(let _ of H.values())_.mint=null;},Y=(_,F)=>{let V=jk.get(_.op);if(V===void 0)return D.clear(),null;let ee=`${F.name}\0${V}`,x=D.get(ee);x||(x={id:null},D.set(ee,x));let g=x;return ()=>g.id??=v(F).mint()},j=(_,F)=>{let V=sd.has(_.op);return !V&&jk.get(_.op)!==void 0?null:((!V||Ts.has(_.op))&&M(),V?v(F):null)},ne=Ns(),Q=null,$=(_,F)=>{if(c)return false;let V=l.parts.get(_);if(!V)return c={reason:"unknown-part",detail:_},false;F=ne(V,this.settingsPartOverride?.()??ah(l),F);let ee=Cj(this.settingsPartOverride?.()??ah(l),F)??Jk(V,this.settingsPartOverride?.()??ah(l),F,Q?.partName===_&&"paragraphId"in F&&Q.paragraphId===F.paragraphId?Q.fieldNodeId:void 0);if(ee)return c={reason:ee},false;let x=Y(F,V),g=j(F,V),T=this.settingsPartOverride?.()??ah(l),U=Dj(T)&&"paragraphId"in F&&Fj(V,F.paragraphId)?wj(V,F,Q?.partName===_&&Q.paragraphId===F.paragraphId?Q.fieldNodeId:void 0):null;Q=U&&"paragraphId"in F?{partName:_,paragraphId:F.paragraphId,fieldNodeId:U.fieldNodeId}:null;let K={deferValidation:true,...this.contentLockPolicy?{contentLockPolicy:this.contentLockPolicy}:{},...x?{revisionIds:x}:{},...g?{trackedRevisionIds:g}:{}},B=U?tl$1(V,F,U,K):yl$1(V,F,K);if(!B.ok)return c={reason:B.reason,...B.detail?{detail:B.detail}:{}},false;if(Ts.has(F.op)&&M(),l=Ie(l,B.part),B.part===V&&B.effect.dirty.length===0&&B.effect.created.length===0&&B.effect.deleted.length===0&&B.effect.split===void 0&&(B.effect.splits===void 0||B.effect.splits.length===0)&&B.effect.join===void 0&&B.effect.caret===void 0)return true;u.add(_),d+=1;for(let ae of B.effect.dirty)m.add(ae);for(let ae of B.effect.created)O.add(ae);for(let ae of B.effect.deleted)f.add(ae);for(let ae of B.effect.dependencyKeys)y.add(ae);B.effect.split&&R.push({split:B.effect.split});for(let ae of B.effect.splits??[])R.push({split:ae});return B.effect.join&&R.push({join:B.effect.join}),Nt[B.effect.impact]>Nt[b]&&(b=B.effect.impact),B.effect.caret&&(C={paragraphId:B.effect.caret.paragraphId,start:0,end:0}),true};if(e({apply:_=>$(this.storyPartName,_),applyTo:(_,F)=>$(_,F),applyPackage:_=>{if(c)return false;let F=this.settingsPartOverride?.()??ah(l),V=Es(_)?Bj(F,{op:"comment"}):Cj(F);if(V)return c={reason:V},false;D.clear(),M();let ee;try{ee=_(l);}catch(x){if(!dj(x))throw x;return c={reason:x.reason,detail:x.message},false}if(ee===l)return true;for(let[x,g]of ee.parts)l.parts.get(x)!==g&&u.add(x);return l=ee,d+=1,Nt["flow-structural"]>Nt[b]&&(b="flow-structural"),true},selectionBefore:_=>{h=_;},selectionAfter:_=>{p=true,S=_;}}),c){let _=c;return {ok:false,reason:_.reason,..._.detail?{detail:_.detail}:{}}}if(d===0)return {ok:true,change:null};let te=p?S:C,me=p?ld(S):C??void 0;for(let _ of u){let F=a.parts.get(_),V=l.parts.get(_);if(V===void 0)continue;let ee=F?Ga(F,V):Ga(V,V);if(!ee.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(ee.issues)}}let le=Te$1(l);if(!le.ok)return {ok:false,reason:"package-invariant",detail:JSON.stringify(le.issues)};if(o)if(this.composition)Bl$1(n.historyGroup,"split","composition"),this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:te}};else {let _=n.historyGroup,F=this.undoStack[this.undoStack.length-1];_!==void 0&&F!==void 0&&F.group===_?this.undoStack[this.undoStack.length-1]={...F,selectionAfter:te??F.selectionAfter}:this.pushUndo({pkg:a,revision:s,selectionBefore:h,selectionAfter:te,group:_}),Bl$1(_,F?.group===_?"extended":"started"),this.redoStack.length=0;}return this.current=l,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&Nt[n.minimumImpact]>Nt[b]&&(b=n.minimumImpact),{ok:true,change:this.publish(r,s,{dirty:m,created:O,deleted:f,dependencyKeys:y,splitJoin:R,impact:b,caret:me},n.story??this.storyRef??void 0,n.actorId,n.operationId)}}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;}closeHistoryGroup(){let e=this.undoStack[this.undoStack.length-1];e===void 0||e.group===void 0||(this.undoStack[this.undoStack.length-1]={...e,group:void 0});}undo(){let e=this.undoStack.pop();if(!e)return null;this.closeHistoryGroup();let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=co(this.current,e.pkg),this.rev+=1,this.publish(g.mutationUndo,n,null,this.storyRef??void 0)}redo(){let e=this.redoStack.pop();if(!e)return null;this.closeHistoryGroup();let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=co(this.current,e.pkg),this.rev+=1,this.publish(g.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}discardNewestUndoEntry(){let e=this.undoStack.pop();return e?{selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}:null}pushUndo(e){this.pushCount+=1,this.undoStack.push(e),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(e,n,r,o,i,a){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:e,...i?{actorId:i}:{},...a?{operationId:a}:{},dirty:r?[...r.dirty]:[],created:r?[...r.created]:[],deleted:r?[...r.deleted]:[],splitJoin:r?r.splitJoin:[],dependencyKeys:r?[...r.dependencyKeys]:[],impact:r?r.impact:o?.kind==="headerFooter"?"global":"flow-structural",...r?.caret?{caret:r.caret}:{},...o?{story:o}:{}};return nf("atomic",()=>{for(let l of this.subscribers)l(s);}),s}};function mo(t,e,n,r){if(!t)return null;if(t.kind==="package")return (r==="undo"?t.selectionBefore:t.selectionAfter)??null;let o=t.partName===e.part.name?e:n.get(t.partName);return (r==="undo"?o?.selectionForUndo():o?.selectionForRedo())??null}function ws(t){let e=null,n;return {context:{selectionBefore(r){e=r,t.selectionBefore(r);},selectionAfter(r){n=r,t.selectionAfter(r);}},snapshot(r){return {selectionBefore:e,selectionAfter:n===void 0?r??null:n}}}}function uo(t,e){return [...t.values()].map(n=>n.part).filter(n=>e.parts.has(n.name))}function Cs(t,e){return uo(t,e).map(n=>n.name).sort().join(",")}function Ms(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,o]of e.parts)if(r!==n&&t.parts.get(r)!==o)return true;return false}var As="/word/numbering.xml";function vt(t,e){return t===void 0?void 0:{group:t,before:e}}function po(t){return t.kind==="package"&&t.before.parts.get(As)!==t.after.parts.get(As)?{...t,restoreNumbering:true}:t}var Kn=class{open=null;close(){this.open=null;}admit(e,n,r,o,i){let a=this.open;if(n===void 0)return this.open=null,po(e);if(a===null||a.group!==n.group||r.at(-1)!==a.pointer){let m=po(e);return this.open={group:n.group,before:n.before,pointer:m},Bl$1(n.group,"started"),m}r.pop();let s=e.kind==="story"?o(e.partName):null,l=a.pointer.kind==="story"?o(a.pointer.partName):null,c=a.pointer.kind==="package"?a.pointer.selectionAfter??null:null,d={kind:"package",before:a.before,after:i(),selectionBefore:a.pointer.kind==="package"?a.pointer.selectionBefore??null:l?.selectionBefore??null,selectionAfter:(e.kind==="package"?e.selectionAfter:s?.selectionAfter)??c},u=po(d);return this.open={...a,pointer:u},Bl$1(n.group,"extended"),u}};var Yn="http://schemas.openxmlformats.org/wordprocessingml/2006/main",dd="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Et(t,e){for(let n of t.children)if(n.kind!=="textValue"&&n.namespaceUri===Yn&&n.localName===e)return n;return null}function Xn(t,e){return t.attributes.find(n=>n.namespaceUri===Yn&&n.localName===e)?.value}function md(t){let e=Xn(t,"val");return e===void 0||e==="1"||e==="true"||e==="on"}function _s(t,e){return t.kind==="textValue"?Object.freeze({...t,id:e()}):Object.freeze({...t,id:e(),children:t.children.map(n=>_s(n,e))})}function ud(t){let e=Ia(`<w:styles xmlns:w="${Yn}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:t.name,contentType:dd});if(!e.ok)return null;let n=Et(e.part.root,"style"),r=n?Et(n,"pPr"):null;return r?_s(r,Ra(t)):null}var Ds=["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 pd(t,e){let n=Ds.indexOf(e),r=0;return t.forEach((o,i)=>{if(o.kind==="textValue")return;let a=Ds.indexOf(o.localName);a!==-1&&a<=n&&(r=i+1);}),r}function Fs(t,e){let n=bd$1(t);if(!n)return null;let r=null;for(let c of n.root.children)if(c.kind!=="textValue"&&c.namespaceUri===Yn&&c.localName==="style"&&Xn(c,"type")==="paragraph"&&Xn(c,"styleId")===e){r=c;break}if(!r)return null;let o=Et(r,"name");if(o&&Xn(o,"val")?.trim().toLowerCase()!=="list paragraph"&&e!=="ListParagraph")return null;let i=ud(n);if(!i)return null;let a=Et(i,"contextualSpacing");if(!a)return null;let s=Et(r,"pPr"),l;if(s){let c=Et(s,"contextualSpacing");if(c&&md(c))return t;l=c?Za(n,c.id,a):Ya(n,s.id,pd(s.children,"contextualSpacing"),[a]);}else {let c=r.children.findIndex(d=>d.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(d.localName));l=Ya(n,r.id,c===-1?r.children.length:c,[i]);}return l.ok?Object.freeze({...t,parts:new Map([...t.parts,[n.name,l.part]])}):null}var Us="http://schemas.openxmlformats.org/package/2006/relationships",Bs="application/vnd.openxmlformats-package.relationships+xml",hd="http://schemas.openxmlformats.org/package/2006/content-types",Ls="/[Content_Types].xml",ft="/word/numbering.xml",Hs="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",Zt="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",yd=`<Override PartName="${ft}" ContentType="${Zt}"/>`;function qn(t){return `${t.ownerPart}\0${t.id}`}function js(t,e,n){let r=new Set(e.externalTargets.filter(s=>s.type===zd).map(qn)),o=n.externalTargets.filter(s=>s.type===zd&&!r.has(qn(s)));if(o.length===0)return t;let i=new Set(t.map(qn)),a=o.filter(s=>!i.has(qn(s)));return a.length===0?t:Object.freeze([...t,...a])}function Vs(t,e,n){let r=t.filter(o=>o.ownerPart===n||e.has(o.ownerPart));return r.length===t.length?t:Object.freeze(r)}function zs(t,e,n=[],r=false){if(t===e)return t;let o=xd(t,e,r);return o=Pd(o,e,n),o}function Gs(t,e){let n=new Set;for(let o of t.externalTargets)o.type===zd&&o.ownerPart!==t.mainDocumentPart&&(t.parts.has(o.ownerPart)||e.has(o.ownerPart)||n.add(o.ownerPart));for(let o of t.parts.keys()){let i=Rd(o);!i||i===t.mainDocumentPart||t.parts.has(i)||e.has(i)||t.externalTargets.some(a=>a.ownerPart===i)||n.add(i);}if(n.size===0)return t;let r=t;for(let o of n)r=Id(r,o);return r}function xd(t,e,n){let r=e.parts.get(ft);if(!r)return t;let o=t.parts.get(ft),i=n&&o?kd(o,r):r,a=Ie(t,i),s=(e.relationships.get(e.mainDocumentPart)??[]).find(c=>c.type===Hs),l=a.relationships.get(a.mainDocumentPart)??[];if(s&&!l.some(c=>c.type===Hs)&&!l.some(c=>c.id===s.id)){let c=bd(a,{...s,ownerPart:a.mainDocumentPart});c&&(a=c);}if(a.contentTypes.overrides.get(z(ft))!==Zt){let c=Nd(a);c&&(a=c);}return a}function kd(t,e){let n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",r=l=>{if(l.kind==="textValue"||l.namespaceUri!==n)return null;let c=l.localName==="abstractNum"?"abstractNumId":l.localName==="num"?"numId":l.localName==="numPicBullet"?"numPicBulletId":null;if(!c)return null;let d=l.attributes.find(u=>u.namespaceUri===n&&u.localName===c)?.value;return d===void 0?null:`${l.localName}:${d}`},o=new Set(t.root.children.map(r).filter(Boolean)),i=Ra(t),a=["numPicBullet","abstractNum","num","numIdMacAtCleanup"],s=t;for(let l of e.root.children){let c=r(l);if(!c||o.has(c)||l.kind==="textValue")continue;let d=a.indexOf(l.localName),u=s.root.children.findIndex(O=>O.kind!=="textValue"&&O.namespaceUri===n&&a.indexOf(O.localName)>d),m=Ya(s,s.root.id,u<0?s.root.children.length:u,[fo(l,i)]);m.ok&&(s=m.part,o.add(c));}return s}function Pd(t,e,n){let r=n.filter(i=>i.type===zd);if(r.length===0)return t;let o=t;for(let i of r){let a=Od(t,e,i.ownerPart);if(!a||o.externalTargets.some(c=>c.ownerPart===a&&c.id===i.id)||new Set((o.relationships.get(a)??[]).map(c=>c.id)).has(i.id))continue;let l=Sd(o,{ownerPart:a,id:i.id,type:zd,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);l&&(o=l);}return o}function Od(t,e,n){return n===e.mainDocumentPart?t.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function bd(t,e){let n=t.mainDocumentPart,r=go(n),o=t.parts.get(r),i=Ia(`<Relationships xmlns="${Us}"><Relationship Id="${U(e.id,"relationship id")}" Type="${U(e.type,"relationship type")}" Target="${U(e.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:Bs});if(!i.ok)return null;let a=t.relationships.get(n)??[];if(a.some(c=>c.id===e.id))return null;let s={...e,ownerPart:n,order:a.reduce((c,d)=>Math.max(c,d.order),-1)+1},l=new Map([...t.relationships,[n,[...a,s]]]);return o?Ws(t,o,i.part.root.children[0],l):Object.freeze({...t,parts:new Map([...t.parts,[r,i.part]]),relationships:l})}function Sd(t,e,n=t.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=go(r),i=t.parts.get(o),a=Ia(`<Relationships xmlns="${Us}"><Relationship Id="${U(e.id,"relationship id")}" Type="${zd}" Target="${U(e.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:Bs});if(!a.ok)return null;let s=[...t.externalTargets,e];if(!i)return Object.freeze({...t,parts:new Map([...t.parts,[o,a.part]]),externalTargets:s});let l=Ws(t,i,a.part.root.children[0],t.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Ws(t,e,n,r){if(!n)return null;let o=Ra(e),i=Ya(e,e.root.id,e.root.children.length,[fo(n,o)]);return i.ok?Object.freeze({...t,parts:new Map([...t.parts,[e.name,i.part]]),relationships:r}):null}function fo(t,e){return t.kind==="textValue"?{...t,id:e()}:{...t,id:e(),children:t.children.map(n=>fo(n,e))}}function go(t){let e=t.lastIndexOf("/");return `${t.slice(0,e)}/_rels/${t.slice(e+1)}.rels`}function Rd(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 Id(t,e){let n=go(e),r=new Map(t.parts);r.delete(n);let o=new Map(t.partBytes);o.delete(n);let i=new Map(t.relationships);i.delete(e);let a=Object.freeze(t.externalTargets.filter(s=>s.ownerPart!==e));return Object.freeze({...t,parts:r,partBytes:o,relationships:i,externalTargets:a})}function Nd(t){let e=t.contentTypes.overrides.get(z(ft));if(e===Zt)return t;if(e!==void 0)return null;let n=t.partBytes.get(Ls);if(!n)return null;let r=strFromU8(n),o=$s(r);if(!o)return null;let i=r.lastIndexOf(`</${o.rootName}>`);if(i===-1)return null;let a=r.slice(0,i)+yd+r.slice(i),s=$s(a);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,Ks("Override",{PartName:ft,ContentType:Zt})];return s.children.length!==l.length||s.children.some((c,d)=>c!==l[d])?null:Object.freeze({...t,partBytes:new Map([...t.partBytes,[Ls,strToU8(a)]]),contentTypes:Object.freeze({defaults:t.contentTypes.defaults,overrides:new Map([...t.contentTypes.overrides,[z(ft),Zt]])})})}function $s(t){let e=aa(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],o=r.name.indexOf(":"),i=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[i?`xmlns:${i}`:"xmlns"]!==hd)return null;let a=[];for(let s of r.children)s.type==="element"&&a.push(Ks(s.name,s.attributes));return {rootName:r.name,children:a}}function Ks(t,e){let n=Object.entries(e).map(([r,o])=>`${r}=${o}`).sort();return [t,...n].join("")}var Xs=4e3,Ys=64;function qs(t){return lh(t,"footnote")!==null||lh(t,"endnote")!==null}function Js(t,e,n,r){if(!qs(t))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let o=Ta(e,n.paragraphId);return !o||o.kind!=="paragraph"?true:kg(o).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function Qs(t,e,n,r){if(!qs(t))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let o=Ta(e,n.blockId);if(!o||o.kind==="textValue")return true;let i=0,a=(s,l)=>{if(i>=Xs||l>Ys)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return kg(s).some(c=>c.node.kind==="noteReference");for(let c of s.children)if(a(c,l+1))return true;return false};return a(o,0)}function Zs(t,e,n){if(n.count>=Xs||e>Ys)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(Zs(r,e+1,n))return true;return false}function el(t,e,n,r){if(!t())return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let i=Ta(e,o);return !i||i.kind==="textValue"?true:Zs(i,0,{count:0})}var ho="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",yo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function tl(t,e){let r=(t.relationships.get(t.mainDocumentPart)??[]).find(o=>o.id===e);return r?r.type!==ho&&r.type!==yo?{ok:false,reason:"wrong-relationship-type",detail:r.type}:vd(t,r):{ok:false,reason:"dangling-relationship",detail:e}}function vd(t,e){let n=J(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 o=r.root.localName;return o!=="hdr"&&o!=="ftr"?{ok:false,reason:"not-a-story-part",detail:o||r.name}:{ok:true,partName:r.name,part:r}}var xo=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),ko=new Set(["authorTable","deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]);function gt(t,e){return e.compositionActive||t.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function nl(t,e){let n=Ta(t,e);return !n||n.kind!=="drawing"?null:n.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function rl(t,e,n){let r=t.parts.get(e);if(!r)return null;let o=Ta(r,n);return !o||o.kind!=="drawing"?null:Pd$1(o,{ownerPartName:e,supportedMcRequires:Id$1,limits:Hd$1,resolveRelationship:Kd$1(t,e)})}function ol(t,e,n){let r=K(t.relationships.get(e)??[],e,n);return r.mode==="internal"?r.partName:null}function Tt(t,e,n,r){let o=t.resolveStory(e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=gt(t,o.store);if(i)return i;let{store:a,story:s}=o;return Na(t,()=>Ed(t,a,s,n,r),l=>Oa(l))}function Ed(t,e,n,r,o){let i=n.partName,a=t.currentPackage(),s=e.checkpoint();e.graftPackage(()=>t.currentPackage());let l=null,c=false,d=false,u=e.transact(f=>{if(o?.commitGuard?.()===false){d=true;return}if(o?.expectedPackageRevision!==void 0&&t.packageRevision!==o.expectedPackageRevision){c=true;return}let y=r(f,i);if(y===null){f.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}l=y;},{story:n,...o?.actorId?{actorId:o.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(d)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(c)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!u.ok)return {ok:false,reason:u.reason,...u.detail?{detail:u.detail}:{}};if(!u.change)return {ok:true,change:null};let m=u.change.created.find(f=>{let y=e.part;return Ta(y,f)?.kind==="drawing"});return m&&(l=m),{ok:true,change:t.promoteStoryTransactionToPackageUnit(a,e,s),...l?{drawingNodeId:l}:{}}}function al(t,e,n){let r=t.parts.get(e);if(!r)return null;let o=nl(r,n);return o?kl$1(o):null}function Po(t,e,n,r){let o=false;return t.applyPackage(i=>{let a=i.parts.get(e);if(!a)return i;let s=Ta(a,n);if(!s||s.kind!=="drawing")return i;let l=nl(a,n);if(!l)return i;let c=ll$1(l,r),d=Td(s,c),u=Za(a,s.id,d,{deferValidation:true});return u.ok?(o=true,Ie(i,u.part)):i}),o}function Td(t,e){return {...t,children:t.children.map(n=>n.id===e.id?e:n)}}async function il(t,e,n){let r=ye(n.widthPoints),o=ye(n.heightPoints);if(r===null||o===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 a=gt(t,i.store);if(a)return a;let s=i.story.partName,l=await te(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let c=l.bytes,d=ve(t.currentPackage(),s,{bytes:c,mime:n.mime});if(!d.ok)return {ok:false,reason:"invalidArgs",detail:d.reason==="invalid-image"?"invalid-image":d.reason};let u=d.partName,m=Tt(t,e,(O,f)=>{let y=t.currentPackage(),R=ve(y,f,{bytes:c,mime:n.mime});if(!R.ok)return null;y=R.pkg,u=R.partName;let b;if(n.hyperlink){let p=Pg(y,n.hyperlink,f);if(!p)return null;y=p.pkg,b=p.relationshipId;}if(!O.applyPackage(()=>y))return null;let h=ze({docPrId:R.docPrId,relationshipId:R.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...b?{hyperlinkRelationshipId:b}:{}});return O.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:h,...n.revision?{revision:n.revision}:{}})?h.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 Oo(t,e,n,r,o,i,a){let s=t.resolveStory(e);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=gt(t,s.store);if(l)return l;let c=s.story.partName,d=await te(i,r,o);if(!d.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=d.bytes,m=ve(t.currentPackage(),c,{bytes:u,mime:o});return m.ok?Tt(t,e,(O,f)=>{let y=t.currentPackage(),R=rl(y,c,n),b=R?.picture?.embeddedRelationshipId??null,h=R?.picture?.linkedRelationshipId??null,p=b??h;if(!p)return null;let S=b!==null?ol(y,c,b):null,C=y,D=ve(C,f,{bytes:u,mime:o});return !D.ok||(C=D.pkg,!O.applyPackage(()=>C))||!O.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:D.relationshipId})?null:(O.applyPackage(H=>Be$1(H,f,S,p)),n)},{expectedPackageRevision:a.expectedPackageRevision,...a.commitGuard?{commitGuard:a.commitGuard}:{},...a.actorId?{actorId:a.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:m.reason==="invalid-image"?"invalid-image":m.reason}}function sl(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=gt(t,r.store);if(o)return o;let i=r.story.partName,a=t.currentPackage(),s=a.parts.get(i),l=rl(a,i,n)??(s?bl$1(s,n):null);if(!l)return {ok:false,reason:"unknown-drawing"};let c=l.picture?.embeddedRelationshipId??null,d=l.picture?.linkedRelationshipId??null,u=c??d,m=c!==null?ol(a,i,c):null;return Tt(t,e,(O,f)=>O.apply({op:"deleteDrawing",drawingNodeId:n})?(O.applyPackage(y=>Be$1(y,f,m,u)),n):null)}function wd(t,e){let n=null,r=i=>{let a=false,s=false,l=(c,d)=>{if(a||c.kind==="textValue")return;if(c.id===e){a=true,s=d;return}let u=d||c.kind==="revisionDelete"||c.kind==="revisionMoveFrom";for(let m of c.children)l(m,u);};return l(i,false),s},o=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let a=mg(i).spanOf(e);if(a!==null&&a.end>a.start){let s=Ta(t,e);if(!s||s.kind!=="drawing"&&!Ld$1(s))return;n={paragraphId:i.id,start:a.start,end:a.end,alreadyDeleted:r(i)};}return}for(let a of i.children)o(a);}};return o(t.root),n}function ll(t,e,n,r){let o=t.resolveStory(e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=gt(t,o.store);if(i)return i;let a=t.currentPackage().parts.get(o.story.partName);if(!a)return {ok:false,reason:"unknown-drawing"};let s=wd(a,n);return s?s.alreadyDeleted?{ok:true,change:null}:Tt(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 cl(t,e,n,r,o,i,a,s){let l=await Ce(o,r,i,void 0,a);return l.ok?Oo(t,e,n,l.bytes,l.mime,a,{expectedPackageRevision:t.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function dl(t,e,n,r,o,i){let a=t.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let s=gt(t,a.store);return s||Tt(t,e,(l,c)=>{let d=al(t.currentPackage(),c,n),u=null;if(i!==null){let O=Pg(t.currentPackage(),i,c);if(!O||!l.applyPackage(()=>O.pkg))return null;u=O.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!Po(l,c,n,u))return null}else if(i===null&&!Po(l,c,n,null))return null;let m=false;return l.applyPackage(O=>{let f=Rg(O,c,d);return f===null?(m=true,O):f}),m?null:n})}function ml(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=gt(t,r.store);return o||Tt(t,e,(i,a)=>{let s=al(t.currentPackage(),a,n.drawingNodeId),l=null;if(n.hyperlink!==null){let d=Pg(t.currentPackage(),n.hyperlink,a);if(!d||!i.applyPackage(()=>d.pkg))return null;l=d.relationshipId;}for(let d of n.ops)if(!i.apply(d))return null;if(!Po(i,a,n.drawingNodeId,n.hyperlink===null?null:l))return null;let c=false;return i.applyPackage(d=>{let u=Rg(d,a,s);return u===null?(c=true,d):u}),c?null:n.drawingNodeId})}function Cd(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 ul(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 Md(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 Ad(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let o=e.get(n);if(!o||o.length!==r.length||o!==r&&r.some((i,a)=>!Md(i,o[a])))return false}return true}function Dd(t,e){return t===e?true:t.length!==e.length?false:t.every((n,r)=>{let o=e[r];return n===o||n.ownerPart===o.ownerPart&&n.id===o.id&&n.type===o.type&&n.rawTarget===o.rawTarget&&n.sinkSafe===o.sinkSafe})}function _d(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let o=e.get(n);if(!o||!Cd(r,o))return false}return true}function Fd(t,e){return t.contentTypes===e.contentTypes||ul(t.contentTypes.defaults,e.contentTypes.defaults)&&ul(t.contentTypes.overrides,e.contentTypes.overrides)}var Jn=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 pl(t){for(let[e,n]of t)if(!Da(e,n)||!Ea(n.root,e.root).idsPreserved)return wt;return Jn}function Ld(t,e){if(t===e)return Jn;if(t.mainDocumentPart!==e.mainDocumentPart||t.parts.size!==e.parts.size||!_d(t.partBytes,e.partBytes)||!Ad(t.relationships,e.relationships)||!Dd(t.externalTargets,e.externalTargets)||!Fd(t,e))return wt;let n=[];for(let[a,s]of t.parts){let l=e.parts.get(a);if(!l)return wt;s!==l&&n.push([s,l]);}if(n.length===0)return Jn;let[r,o]=n[0];if(n.length>1||r.name!==t.mainDocumentPart)return pl(n);let i=Ea(o.root,r.root);return i.undecided?pl(n):i.equal&&i.idsPreserved?Jn:i.equal?i.renamedOutsideParagraphs||i.renamedParagraphIds.length===0?wt:{equal:false,dirty:i.renamedParagraphIds,dependencyKeys:[l.story],impact:"text-local"}:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?wt:{equal:false,dirty:i.paragraphIds,dependencyKeys:[l.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function bo(t){return {ok:false,reason:"package-invariant",detail:t}}function Hd(t,e){if(!t.parts.get(t.mainDocumentPart))return bo("no-main-document");for(let[r,o]of t.parts){let i=e?.parts.get(r);if(i===o)continue;let a=i?Ga(i,o):Fa(o);if(!a.ok)return bo(`invalid-part:${r}:${a.issues[0]?.code??"invalid"}`)}let n=Te$1(t);return n.ok?null:bo(n.issues[0]?.code??"package-invariant")}function fl(t,e,n){let r=t.currentPackage(),o=Ld(e,r);if(o.equal)return {ok:true,change:null};let i=Hd(e,r);if(i)return i;let a=t.bodyStore().part.name,s=o.impact!=="global"&&e.mainDocumentPart===a;return Na(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?o.dirty:[],created:[],deleted:[],splitJoin:[],dependencyKeys:s?o.dependencyKeys:[],impact:s?o.impact:"global",story:{kind:"body",partName:a}})}},()=>false)}function $d(t,e,n,r){let o=[...e],i=new Set;for(let a of o)t.parts.has(a)&&i.add(a);for(let a of n)gl(a,o,i);for(let a of r)gl(a,o,i);return i}function Ud(t,e,n,r,o){let i=new Set(t);i.add(e),i.add(n);for(let a of r)hl(a,i);for(let a of o)hl(a,i);return i}function gl(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 hl(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);}function yl(t){let{stories:e,rIdToPartName:n,undoOrder:r,redoOrder:o}=t,i=$d(t.pkg,e.keys(),r,o);for(let[l]of [...e])if(!i.has(l)){e.delete(l);for(let[c,d]of [...n])d===l&&n.delete(c);}let a=Ud(i,t.pkg.mainDocumentPart,t.bodyPartName,r,o),s=Gs(t.pkg,a);return {pkg:s,shellHyperlinks:Vs(t.shellHyperlinks,a,s.mainDocumentPart)}}function xl(t,e,n,r,o,i){return {change:"model-change",fromRevision:Math.max(0,e-1),toRevision:e,commitId:`pkg-commit-${t}`,origin:n,dirty:[],created:[...i],deleted:[],splitJoin:[],dependencyKeys:[],impact:r,story:o}}var kl=64,en=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];historyGroups=new Kn;subscribers=new Set;historyLimit;contentLockPolicy;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;storyStoreOptions(){return {historyLimit:this.historyLimit,settingsPart:()=>ah(this.pkg),...this.contentLockPolicy?{contentLockPolicy:this.contentLockPolicy}:{}}}constructor(e,n,r={}){this.pkg=Ie(e,n),this.historyLimit=r.historyLimit??200,this.contentLockPolicy=yj(r.contentLockPolicy),this.maxEditableStoryParts=r.maxEditableStoryParts??kl,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??di,this.body=new pt(this.pkg,n.name,this.storyStoreOptions()),this.body.setStoryRef({kind:"body",partName:n.name}),Cl$1(this,{current:()=>this.undoOrder.at(-1)??null,split:()=>{this.closeHistoryGroups(),this.redoOrder.length=0;}});}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 o=0,i=true;for(let a of this.stories.values()){if(e.storyParts[o]!==a.part){i=false;break}o+=1;}if(i&&o===e.storyParts.length)return e.result}let n=Ie(this.pkg,this.body.part),r=[];for(let o of this.stories.values())r.push(o.part),this.pkg.parts.has(o.part.name)&&(n=Ie(n,o.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 Na(this,()=>this.commitStoryTransaction(e,n,r),Oa,r.historyGroup)}commitStoryTransaction(e,n,r={}){let o=this.resolveStory(e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let{store:i,story:a}=o,s=this.currentPackage(),l=i.historyPushCount,c=i.compositionActive,d=i.checkpoint(),u=false,m=new Set,O=false,f,y=new Set,R=false,b,h=false,p;i.graftPackage(()=>this.currentPackage());let S=i.transact(H=>{p=ws(H),n({...H,applyTo:(v,M)=>{let Y=H.applyTo(v,M);return Y&&v!==a.partName&&(h=true),Y},applyPackage:v=>H.applyPackage(M=>{let Y=v(M);return Y!==M&&!h&&(h=Ms(M,Y,a.partName)),Y}),apply:v=>(v.op==="setListNumbering"&&v.numId!==null&&(R=true),v.op==="setParagraphProperties"&&(b??=v.properties.find(M=>M.localName==="pStyle")?.attributes?.val),u||(v.op==="deleteText"&&Js(this.pkg,i.part,v,m)||v.op==="deleteBlock"&&Qs(this.pkg,i.part,v,m)||xo.has(v.op)||ko.has(v.op))&&(u=true),O||(v.op==="deleteText"||v.op==="deleteBlock"?O=el(()=>f??=li(this.pkg),i.part,v,y):(xo.has(v.op)||ko.has(v.op))&&(O=true)),H.apply(v)),...p.context});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!S.ok)return {ok:false,reason:S.reason,...S.detail?{detail:S.detail}:{}};this.syncPackageFromStore(i);let C=false;if(S.change&&h&&(this.installPackageSnapshotInternal(i.package,false),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(d),C=true),R&&b){let H=Fs(this.pkg,b);H&&this.replacePackageShell(H);}let D=false;if(S.change&&u){let H=this.currentPackage(),v=this.cascadeNoteReferences(s,H);if(v===null)return i.restoreCheckpoint(d),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};v!==H&&(this.installPackageSnapshotInternal(v),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(d),D=true);}if(S.change&&O){let H=this.currentPackage(),v=pi(s,H,{storyPartName:a.partName});if(v===null)return i.restoreCheckpoint(d),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};v!==H&&(this.installPackageSnapshotInternal(v),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(d),D=true);}if(S.change){this.packageRev+=1;let H=D||C;if(!c&&r.recordsHistory!==false&&(i.historyPushCount>l||H))if(H)this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage(),...p?.snapshot(S.change.caret)},vt(r.historyGroup,s));else {let M=vt(r.historyGroup,s);this.pushUndoPointer({kind:"story",partName:a.partName,story:a},M);}let v=H?this.publishSynthetic(S.change.origin,"global",a,S.change.created):S.change;return H||this.publish(v),{ok:true,change:v}}return {ok:true,change:S.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.historyPushCount;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.historyPushCount>r){let o=e.partName===this.body.part.name?{kind:"body",partName:e.partName}:this.storyRefForPart(e.partName);o&&this.pushUndoPointer({kind:"story",partName:e.partName,story:o});}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(g.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(e,n={}){let r=()=>this.commitLifecycleOp(e,n.historyGroup);return Hb(n.actorId,()=>Na(this,r,Oa,n.historyGroup))}commitLifecycleOp(e,n){let r=this.currentPackage(),o=Bj(ah(r),e);if(o)return {ok:false,reason:o};if(bi(e)){let c=ci(r,e);if(!c.ok)return {ok:false,reason:c.reason,...c.detail?{detail:c.detail}:{}};if(c.package===r)return {ok:true,change:null};this.installPackageSnapshotInternal(c.package);let d=vt(n,r);this.pushUndoPointer({kind:"package",before:r,after:c.package},d),this.packageRev+=1;let u={kind:"body",partName:this.body.part.name},m=this.publishSynthetic(g.mutationHuman,c.impact,u,c.createdPartName?[c.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:m}}if(!Vg(e))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let i=Wg(r,e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};this.installPackageSnapshotInternal(i.package);let a=vt(n,r);this.pushUndoPointer({kind:"package",before:r,after:i.package},a),this.packageRev+=1;let s={kind:"body",partName:this.body.part.name},l=this.publishSynthetic(g.mutationHuman,i.impact,s,i.createdPartName?[i.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:l}}undo(){let e=this.undoOrder.pop();if(!e)return null;if(this.closeHistoryGroups(),e.kind==="package"){this.installPackageSnapshotInternal(e.before,true,e.restoreNumbering),this.redoOrder.push(e),this.packageRev+=1;let o=this.publishSynthetic(g.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}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(this.closeHistoryGroups(),e.kind==="package"){this.installPackageSnapshotInternal(e.after,true,e.restoreNumbering),this.undoOrder.push(e),this.packageRev+=1;let o=this.publishSynthetic(g.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}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(){return mo(this.undoOrder.at(-1),this.body,this.stories,"undo")}selectionForRedo(){return mo(this.redoOrder.at(-1),this.body,this.stories,"redo")}openStoryParts(){return uo(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return Cs(this.stories,this.pkg)}insertImage(e,n){return il(this,e,n)}applyFragmentPaste(e,n){return lo(this,e,n)}replaceImage(e,n,r,o,i,a){return Oo(this,e,n,r,o,i,a)}deleteImage(e,n){return sl(this,e,n)}deleteImageTracked(e,n,r){return ll(this,e,n,r)}embedExternalImage(e,n,r,o,i,a,s){return cl(this,e,n,r,o,i,a,s)}setDrawingMetadataWithHyperlink(e,n,r,o,i){return dl(this,e,n,r,o,i)}applyImageProperties(e,n){return ml(this,e,n)}promoteStoryTransactionToPackageUnit(e,n,r,o){this.installPackageSnapshotInternal(n.package,false),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(g.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){this.adoptGroupedPackageUnit(e,void 0);}adoptGroupedPackageUnit(e,n){let r=this.currentPackage();e!==r&&this.pushUndoPointer({kind:"package",before:e,after:r},vt(n,e));}installPackageSnapshot(e){this.installPackageSnapshotInternal(e);}installAuthoritativePackageSnapshot(e){this.installPackageSnapshotInternal(e,false);}publishRemotePackage(e,n){return fl(this,e,n)}replacePackageShell(e){this.shellHyperlinks=js(this.shellHyperlinks,this.pkg,e);let n=e;n=Ie(n,this.body.part);for(let r of this.stories.values())e.parts.has(r.part.name)&&(n=Ie(n,r.part));this.pkg=n;}installPackageSnapshotInternal(e,n=true,r=false){let o=n?zs(e,this.pkg,this.shellHyperlinks,r):e,i=o.parts.get(o.mainDocumentPart);if(!i)return;this.body.replacePart(i);for(let[s,l]of this.stories){let c=o.parts.get(s);c&&l.replacePart(c);}this.rIdToPartName.clear();let a=o.relationships.get(o.mainDocumentPart)??[];for(let s of a){if(s.type!==ho&&s.type!==yo)continue;let l=J(s);l.mode!=="Internal"||!l.target.ok||this.stories.has(l.target.partName)&&o.parts.has(l.target.partName)&&this.rIdToPartName.set(s.id,l.target.partName);}this.pkg=o,this.pkg=Ie(this.pkg,this.body.part);for(let s of this.stories.values())this.pkg.parts.has(s.part.name)&&(this.pkg=Ie(this.pkg,s.part));}openNotesPartStore(e){let n=lh(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 o=Eb(n),i=new pt(o,this.storyStoreOptions()),a={kind:"notesPart",partName:o.name,noteKind:e};return i.setStoryRef(a),this.stories.set(o.name,i),o!==n&&(this.pkg=Ie(this.pkg,o)),{ok:true,story:a,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=tl(this.currentPackage(),e);if(!r.ok)return r;let o=this.stories.get(r.partName);if(o)return this.rIdToPartName.set(e,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:e},store:o};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=Eb(r.part),a=new pt(i,this.storyStoreOptions()),s={kind:"headerFooter",partName:i.name,rId:e};return a.setStoryRef(s),this.stories.set(i.name,a),this.rIdToPartName.set(e,i.name),i!==r.part&&(this.pkg=Ie(this.pkg,i)),{ok:true,story:s,store:a}}storyRefForPart(e){if(e===this.body.part.name)return {kind:"body",partName:e};for(let[r,o]of this.rIdToPartName)if(o===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=Ie(this.pkg,e.part);}closeHistoryGroups(){zl$1(this.body,this.stories,null),this.historyGroups.close();}pushUndoPointer(e,n){e=this.historyGroups.admit(e,n,this.undoOrder,r=>(r===this.body.part.name?this.body:this.stories.get(r))?.discardNewestUndoEntry()??null,()=>this.currentPackage()),zl$1(this.body,this.stories,e),this.undoOrder.push(e),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let e=yl({pkg:this.pkg,stories:this.stories,rIdToPartName:this.rIdToPartName,bodyPartName:this.body.part.name,shellHyperlinks:this.shellHyperlinks,undoOrder:this.undoOrder,redoOrder:this.redoOrder});this.pkg=e.pkg,this.shellHyperlinks=e.shellHyperlinks;}publish(e){this.lastChange=e;for(let n of this.subscribers)n(e);}publishSynthetic(e,n,r,o){this.commitCounter+=1;let i=xl(this.commitCounter,this.packageRev,e,n,r,o);return this.publish(i),i}};var Bd=256,jd=65535,Pl=64;function Qn(t,e){return t.length>e}function Ol(t){return typeof t!="string"||t.trim().length===0?"invalid-author":Qn(t,Bd)?"resource-limit":T(t)?null:"invalid-author"}function bl(t){return typeof t!="string"||t.length===0?"invalid-text":Qn(t,jd)?"resource-limit":T(t)?null:"invalid-text"}function So(t){if(typeof t!="string")return {ok:false,rejection:"invalid-date"};let e=t.trim();if(Qn(e,Pl))return {ok:false,rejection:"resource-limit"};if(!T(e))return {ok:false,rejection:"invalid-date"};let n=cg(e);return n===null?{ok:false,rejection:"invalid-date"}:Qn(n,Pl)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function eh(t){if(t===void 0)return null;let e=So(t);return e.ok?null:e.rejection}function Ro(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 Vd(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function Io(t,e){if(!t){let a=Ib(e);return a?Kb(new Set,a,Fb):"0"}let n=-1,r=new Set,o=a=>{if(a.kind!=="textValue"){if(a.kind==="comment"){let s=Vd(a,la,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=Fb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of a.children)o(s);}};o(t.root);let i=Ib(e);return i?Kb(r,i,Fb):String(n+1)}function Sl(t,e){if(t.kind==="textValue")return t;let n=e.get(t.id);if(n!==void 0)return n;let r=false,o=[];for(let i of t.children){let a=Sl(i,e);a!==i&&(r=true),o.push(a);}return r?{...t,children:o}:t}function Wd(t,e,n){let r=Sl(t.root,e);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:t.root.id,nodeId:t.root.id}]};let o=n===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:n,namespaceUri:qa}]};return Za(t,t.root.id,o,{deferValidation:true})}function Rl(t,e,n){let r=new Map;for(let i of e){if(i.stampParagraph===null)continue;let a=r.get(i.commentsPartName);a||(a=new Map,r.set(i.commentsPartName,a)),a.set(i.stampParagraph.id,{paragraph:i.stampParagraph,paraId:i.paraId});}let o=t;for(let[i,a]of r){let s=o.parts.get(i);if(!s)return null;let l=Ab(s.root),c=l??"w14",d=new Map;for(let m of a.values())d.set(m.paragraph.id,n(m.paragraph,m.paraId,c));let u=Wd(s,d,l===null?c:null);if(!u.ok)return null;o=Ie(o,u.part);}return o}function Il(t,e,n){let r=t.root.children.map(o=>o.kind==="textValue"?o:e.get(o.id)??o);return Xa(t,t.root.id,[...r,...n],{deferValidation:true})}var El="/word/comments.xml",Tl="/word/commentsExtended.xml",wo="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",Co="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Kd=[Co,"application/vnd.ms-word.commentsExtended+xml"],wl="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Mo="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",Qe="http://schemas.microsoft.com/office/word/2012/wordml";function nn(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function Ct(t,e){return {kind:"genericExtension",namespaceUri:la,localName:t,prefix:"w",value:e}}function Be(t,e,n,r,o,i,a,s=[]){return {id:t,kind:e,namespaceUri:n,localName:o,prefix:r,namespaceBindings:s,attributes:i,children:a}}function Cl(t,e,n,r,o){let i=e===t.mainDocumentPart?[e]:[e,t.mainDocumentPart];for(let a of i)for(let s of Ke(t,a)){if(s.type!==n)continue;let l=B(a,s.rawTarget);if(!l.ok)continue;if(!t.parts.has(l.partName))return l.partName;let c=Le(t,l.partName);if(c!==null&&(typeof r=="string"?c===r:r.includes(c)))return l.partName}return o}function No(t,e,n){let r=t.mainDocumentPart;for(let i of Ke(t,r)){if(i.type!==e)continue;let a=B(r,i.rawTarget);if(a.ok&&a.partName===n)return t}let o=Qe$1(t,r);return Re(o,r,e,Ci$1(r,n)).pkg}function Ao(t,e){return Cl(t,e,wl,wo,El)}function Ml(t,e){let n=Zd$1(t,e),r=_d$1(t,e,n).extended;return r!==null?r:Cl(t,e,Mo,Kd,Tl)}function Nl(t){let e=new Set;for(let n of t.parts.values())for(let r of zb(n.root))e.add(r);return e}function Xd(t,e){if(!t)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&nn(o,la,"id")===e){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind!=="paragraph")continue;let s=nn(a,qa,"paraId");s!==void 0&&vb(s)&&(n=s.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(t.root),n}function Yd(t,e){if(!t)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&nn(o,la,"id")===e){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind==="paragraph"){n=a;return}}return}for(let i of o.children)r(i);}};return r(t.root),n}function Al(t){let e=Ab(t.root);if(e!==null)return {part:t,prefix:e};let n={...t.root,namespaceBindings:[...t.root.namespaceBindings,{prefix:"w14",namespaceUri:qa}]},r=Za(t,t.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(Va(t.root,n),{part:{...t,root:n},prefix:"w14"})}function Dl(t,e,n){return Be(t.id,"paragraph",t.namespaceUri,t.prefix??"w",t.localName,[...t.attributes.filter(r=>!(r.namespaceUri===qa&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:qa,localName:"paraId",prefix:n,value:e}],t.children,t.namespaceBindings)}function qd(t,e,n,r){let o=t.parts.get(e);if(!o)return t;let i=Al(o),a=Ta(i.part,n);if(!a||a.kind!=="paragraph")return Ie(t,i.part);let s=Za(i.part,a.id,Dl(a,r,i.prefix),{deferValidation:true});return Ie(t,s.ok?s.part:i.part)}function Jd(t,e,n,r){let o=`${El}#comment-${t}`,i=n.text!==n.text.trim(),a=Be(`${o}.t`,"text",la,"w","t",i?[{kind:"xmlSpace",namespaceUri:ma,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=Be(`${o}.rPr`,"runProperties",la,"w","rPr",[],[Be(`${o}.rStyle`,"generic",la,"w","rStyle",[Ct("val","CommentReference")],[])]),l=Be(`${o}.r`,"run",la,"w","r",[],[s,a]),c=Be(`${o}.pPr`,"paragraphProperties",la,"w","pPr",[],[Be(`${o}.pStyle`,"generic",la,"w","pStyle",[Ct("val","CommentText")],[])]),d=Be(`${o}.p`,"paragraph",la,"w","p",[{kind:"genericExtension",namespaceUri:qa,localName:"paraId",prefix:r,value:e}],[c,l]);return Be(o,"comment",la,"w","comment",[Ct("id",t),Ct("author",n.author),...n.initials===void 0?[]:[Ct("initials",n.initials)],...n.date===void 0?[]:[Ct("date",n.date)]],[d])}function vo(t,e){let n=Ia(e,{name:t,contentType:"application/xml"});return n.ok?n.part.root:null}function Do(t,e){for(let b of [Ol(e.author),bl(e.text)])if(b)return {ok:false,reason:Ro(b)};let n;if(e.date!==void 0){let b=So(e.date);if(!b.ok)return {ok:false,reason:Ro(b.rejection)};n=b.value;}let r={...e,...n===void 0?{}:{date:n}},o=t.package,i=t.part.name,a=Ao(o,i),s=Ml(o,i),l=o.parts.get(a),c=Io(l,r.actorId),d=yb(`${a}#${c}`,Nl(o)),u=e.replyToCommentId===void 0?null:Xd(l,e.replyToCommentId),m=e.replyToCommentId!==void 0&&u===null?Yd(l,e.replyToCommentId):null;if(e.replyToCommentId!==void 0&&u===null&&!m)return {ok:false,reason:"unknown-revision"};let O=m?yb(`${a}#parent-${e.replyToCommentId}`,new Set([...Nl(o),d])):null,f=u??O,y=e.anchor.endParagraphId??e.anchor.paragraphId,R=t.transact(b=>{let h=Qt(b);h.applyPackage(p=>{let S=p.parts.has(a)?p:(()=>{let C=vo(a,`<w:comments xmlns:w="${la}"/>`);return C?Se$1(p,a,C,wo):null})();return S===null?p:No(S,wl,a)}),m&&O&&h.applyPackage(p=>qd(p,a,m.id,O)),h.applyPackage(p=>{let S=p.parts.get(a);if(!S)return p;let C=Al(S),D=Ya(C.part,C.part.root.id,C.part.root.children.length,[Jd(c,d,r,C.prefix)],{deferValidation:true});return D.ok?Ie(p,D.part):p}),f!==null&&(h.applyPackage(p=>{let S=p.parts.has(s)?p:(()=>{let C=vo(s,`<w15:commentsEx xmlns:w15="${Qe}"/>`);return C?Se$1(p,s,C,Co):null})();return S===null?p:No(S,Mo,s)}),h.applyPackage(p=>{let S=p.parts.get(s);if(!S)return p;let D=[...Qd(S).has(f.toUpperCase())?[]:[To(`${s}#ex-${f}`,f,void 0,false)],To(`${s}#ex-${d}`,d,f,false)],H=Ya(S,S.root.id,S.root.children.length,D,{deferValidation:true});return H.ok?Ie(p,H.part):p})),h.applyTo(i,{op:"insertCommentMarker",paragraphId:y,offset:e.anchor.end,commentId:c,marker:"reference"}),h.applyTo(i,{op:"insertCommentMarker",paragraphId:y,offset:e.anchor.end,commentId:c,marker:"end"}),h.applyTo(i,{op:"insertCommentMarker",paragraphId:e.anchor.paragraphId,offset:e.anchor.start,commentId:c,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return R.ok?{ok:true,commentId:c,change:R.change}:{ok:false,reason:R.reason}}function Eo(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 vl(t){let e=Eo(t);if(!e)return null;let n=nn(e,qa,"paraId");return n!==void 0&&vb(n)?n.toUpperCase():null}function Qd(t){let e=new Map;if(!t)return e;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===Qe&&r.localName==="commentEx"){let o=nn(r,Qe,"paraId");o!==void 0&&vb(o)&&e.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(t.root),e}function tn(t,e){return {kind:"genericExtension",namespaceUri:Qe,localName:t,prefix:"w15",value:e}}function Zd(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 em(t,e,n){let r=[],o=false,i=false;for(let a of t.attributes){if(a.namespaceUri===Qe&&a.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:a.namespaceUri,localName:a.localName,...a.prefix===void 0?{}:{prefix:a.prefix},value:n?"1":"0"});continue}a.namespaceUri===Qe&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&e!==void 0&&r.push(tn("paraIdParent",e)),o||r.push(tn("done",n?"1":"0")),Zd(t,r)}function To(t,e,n,r){return {id:t,kind:"generic",namespaceUri:Qe,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[tn("paraId",e),...n===void 0?[]:[tn("paraIdParent",n)],tn("done",r?"1":"0")],children:[]}}function _o(t,e,n){return tm(t,e,n,Yd$1())}function tm(t,e,n,r){let o=t.package,i=t.part.name;if(Zd$1(o,i)===null)return {ok:false,reason:"unknown-comment"};let s=fi(o,e,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=$d$1(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let c=l.used,d=new Map,u=[];for(let y of s.ids){let R=s.records.get(y);if(!R)return {ok:false,reason:"unknown-comment"};if(!Eo(R.node))return {ok:false,reason:"unknown-comment"};let h=vl(R.node),p=h??yb(`${R.partName}#done-${y}`,c);h===null&&c.add(p),d.set(y,p);}for(let y of s.ids){let R=s.records.get(y),b=Eo(R.node),h=d.get(y),p=vl(R.node),S=s.parentCommentIdByChildId.get(y),C=s.parentParaIdByCommentId.get(y)??(S===void 0?void 0:d.get(S)),D=s.commentExByParaId.get(h);u.push({paraId:h,stampParagraph:p===null?b:null,commentsPartName:R.partName,parentParaId:C,existing:D?.node,existingParentParaId:D?.parentParaId,existingDone:D?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(y=>y.existingDone===n))return {ok:true,changed:false,change:null};let m=s.extendedPartName??Tl,O=s.extendedPartName===null,f=t.transact(y=>{Qt(y).applyPackage(b=>{let h=Rl(b,u,Dl);if(h===null)return b;let p=h;if(!p.parts.has(m)){let v=vo(m,`<w15:commentsEx xmlns:w15="${Qe}"/>`);if(!v)return b;let M=Se$1(p,m,v,Co);p=O?No(M,Mo,m):M;}let S=p.parts.get(m);if(!S)return b;let C=new Map,D=[];for(let v of u){let M=v.existingParentParaId??v.parentParaId;v.existing?C.set(v.existing.id,em(v.existing,M,n)):D.push(To(`${m}#done-${v.paraId}`,v.paraId,M,n));}let H=Il(S,C,D);return H.ok?Ie(p,H.part):b});});return f.ok?{ok:true,changed:true,change:f.change}:{ok:false,reason:f.reason}}function nm(t,e){let n=Ao(t,e);return t.parts.has(n)&&Le(t,n)===wo}function rm(t,e){return Ao(t,e)}function om(t,e){return Ml(t,e)}var _l={kind:"body"};function am(t,e,n=_l,r){let o=n.kind==="body"?null:t.resolveStory(n),i=o?.ok?o.store:t.bodyStore(),a=t.currentPackage(),s=i.checkpoint();return i.graftPackage(()=>t.currentPackage()),Na(t,()=>{let l=Do(i,e);return l.ok&&(i.restoreHistoryStacks(s),t.replacePackageShell(i.package),t.adoptGroupedPackageUnit(a,r),t.publishStoryWrite(l.change)),l},l=>Oa(l),r)}function im(t,e,n,r){let o=t.bodyStore(),i=t.currentPackage(),a=Bj(ah(i),{op:"setCommentResolved"});if(a)return {ok:false,reason:a};let s=o.checkpoint();return o.graftPackage(()=>t.currentPackage()),Na(t,()=>{let l=_o(o,e,n);return !l.ok||!l.changed||(o.restoreHistoryStacks(s),t.replacePackageShell(o.package),t.adoptGroupedPackageUnit(i,r),t.publishStoryWrite(l.change)),l},l=>l.ok&&l.changed,r)}function sm(t,e,n=_l,r,o){if(e.length===0||Bj(ah(t.currentPackage()),{op:"deleteComments"}))return false;let i=n.kind==="body"?t.bodyStore().part:t.partFor(n);if(!i)return false;let a={storyPartName:i.name,...r===void 0?{}:{noteId:r}},s=t.bodyStore(),l=t.currentPackage(),c=s.checkpoint();return s.graftPackage(()=>t.currentPackage()),Na(t,()=>{let d=false,u=false,m=s.transact(O=>{Qt(O).applyPackage(y=>{let R=y;for(let b of e){let h=b.parentCommentId===void 0?ni(R,b.commentId,a):oi(R,b.commentId,b.parentCommentId,a);if(h===null)return d=true,y;u||=h!==R,R=h;}return R});});return d||!m.ok||!u?false:(s.restoreHistoryStacks(c),t.installPackageSnapshot(s.package),t.adoptGroupedPackageUnit(l,o),t.publishStoryWrite(m.change),true)},d=>d,o)}var Ll=256*1024,Hl=4096;function Fo(t,e,n){let r=e.payload,o=t.part.name,i=n??o;if(r){if(r.data.length>Ll)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>Hl)return {ok:false,reason:"payload-too-large",detail:"label"}}let a=new Set($b(t.part.root).map(m=>m.node.id)),s=e.replaceControlId===void 0?[]:$l(t,o,e.replaceControlId),l=null,c,d=t.transact(m=>{if(e.replaceControlId!==void 0){m.apply({op:"removeContentControl",controlId:e.replaceControlId,keepContent:false});for(let y of s)m.applyPackage(R=>Ki$1(R,y.partName,y.nodeId));}let O=e.replaceUntil;if(O!==void 0&&O<=e.offset){l="invalid-range",c="replaceUntil must be past offset";return}if(O!==void 0&&m.apply({op:"deleteText",paragraphId:e.paragraphId,start:e.offset,end:O}),!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 f=null;m.applyPackage(y=>{let R=Fi$1(y,i,r.namespaceUri,r.rootLocalName);if(!R.part)return l="store-not-authored",c=`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})`,y;if(f=Pi(R.part,r.rootLocalName,r.nodeId),!f)return l="unaddressable-payload",c=`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`,y;let b=Ji$1(R.pkg,R.part.partName,{id:r.nodeId,label:r.label,data:r.data});return Ii(b,R.part.partName,r.nodeId)?b:(l="store-not-authored",c="the payload node could not be written into the store",y)}),!(l!==null||!f)&&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:f});});if(l!==null)return {ok:false,reason:l,...c===void 0?{}:{detail:c}};if(!d.ok)return {ok:false,reason:d.reason,...d.detail===void 0?{}:{detail:d.detail}};let u=lm(t,a);return {ok:true,change:d.change,...u===void 0?{}:{nodeId:u}}}function lm(t,e){for(let n of $b(t.part.root))if(!e.has(n.node.id))return n.node.id}function $l(t,e,n){let r=$b(t.part.root).find(i=>i.node.id===n);if(!r)return [];let o=[];for(let i of Di$1(t.package,e)){let a=Si(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function Lo(t,e){let n=t.part.name,r=$l(t,n,e),o=t.transact(i=>{i.apply({op:"removeContentControl",controlId:e,keepContent:false});for(let a of r)i.applyPackage(s=>Ki$1(s,a.partName,a.nodeId));});return o.ok?{ok:true,change:o.change}:{ok:false,reason:o.reason,...o.detail===void 0?{}:{detail:o.detail}}}function cm(t,e,n){if(!t.parts.has(e)||n.length===0)return {ok:true,pkg:t,removed:[]};let r=t,o=[];for(let i of n){let a=Ei$1(r,e,i);if(!a)continue;let s=Ri(r,a.itemId),l=Li$1(r,a.partName,s);if(l.pkg===r&&Hi$1(r,a.partName).some(c=>!s.has(c.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=l.pkg,o.push(...l.removed);}return {ok:true,pkg:r,removed:o}}var Fl=new WeakMap;function dm(t,e){let n=Fl.get(t);n||(n=new Map,Fl.set(t,n));let r=n.get(e);if(r)return r;let o=Di$1(t,e).map(i=>({itemId:i.itemId,nodes:new Map(Hi$1(t,i.partName).map(a=>[a.id,a]))}));return n.set(e,o),o}function mm(t,e,n=e){let r=new Map,o=t.parts.get(e);if(!o)return r;let i=dm(t,n);if(i.length===0)return r;for(let a of $b(o.root))for(let s of i){let l=Si(a.node,s.itemId);if(l===null)continue;let c=s.nodes.get(l);if(c){r.set(a.node.id,{nodeId:l,label:c.label,data:c.data});break}}return r}function um(t,e,n){let r=new Map,o=Ei$1(t,e,n);if(!o)return r;for(let i of Hi$1(t,o.partName))r.set(i.id,{label:i.label,data:i.data});return r}var Ul={kind:"body"};function Bl(t,e,n,r){let o=e.kind==="body"?null:t.resolveStory(e),i=o?.ok?o.store:t.bodyStore(),a=t.currentPackage(),s=i.checkpoint();return i.graftPackage(()=>t.currentPackage()),Na(t,()=>{let l=n(i);return l.ok&&(i.restoreHistoryStacks(s),t.replacePackageShell(i.package),t.adoptGroupedPackageUnit(a,r),t.publishStoryWrite(l.change)),l},l=>Oa(l),r)}function pm(t,e,n=Ul,r){return Bl(t,n,o=>Fo(o,e,t.bodyStore().part.name),r)}function fm(t,e,n=Ul){return Bl(t,n,r=>Lo(r,e))}var gm=256,hm=2e3,jl=/[\p{L}\p{N}_]/u;function Ho(t){let e=t.toLowerCase();if(e.length===t.length)return e;let n="";for(let r=0;r<t.length;r+=1){let o=t[r],i=o.toLowerCase();n+=i.length===1?i:o;}return n}function Vl(t,e,n){let r=e>0?t[e-1]:void 0,o=n<t.length?t[n]:void 0;return !(r!==void 0&&jl.test(r)||o!==void 0&&jl.test(o))}function zl(t){return typeof t=="string"&&t.length>0&&t.length<=256}function ym(t,e,n,r={}){let o={matches:[],truncated:false};if(!zl(e)||t.length===0||n<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,s=i?e:Ho(e),l=i?t:Ho(t),c=Math.max(0,r.from??0),d=Math.min(t.length,r.to??t.length),u=[],m=l.indexOf(s,c);for(;m>=0;){let O=m+s.length;if(O>d)return {matches:u,truncated:false};if(!a||Vl(t,m,O)){if(u.length>=n)return {matches:u,truncated:true};u.push({start:m,length:s.length});}m=l.indexOf(s,O);}return {matches:u,truncated:false}}var xm=new Set(["plainText","richText","date","dropDownList","comboBox","docPartList"]),km=96;function $o(t,e){return t.kind!=="textValue"&&t.namespaceUri===la&&t.localName===e}function Pm(t){return t.kind==="textValue"&&t.value.trim()===""}function Om(t){let e=[],n=(r,o,i)=>{if(r.kind==="textValue"||i>km)return;if(Yf(r)){let s=_f(r),l=Zb(r);if(s&&l&&s.children.every(Pm)&&xm.has(l.type)){e.push({control:r,content:s,kind:l.type,docPart:l.placeholderDocPart,inline:o});return}}let a=o||r.kind==="paragraph"||$o(r,"p");for(let s of r.children)n(s,a,i+1);};return n(t,false,0),e}function bm(t){return Kk(t,"rPr",{kind:"runProperties",children:[Kk(t,"rStyle",{attributes:[["val","PlaceholderText"]]})]})}function Sm(t){let e=t.find(r=>r.kind==="paragraph"||$o(r,"p"));if(!e||e.kind==="textValue")return null;let n=e.children.filter(r=>r.kind!=="paragraphProperties"&&!$o(r,"pPr"));return n.length>0?n:null}function Uo(t,e){let n=Om(e.root);if(n.length===0)return e;let r=null,o=c=>{if(c!==void 0)return r??=Lg(t),r.find(d=>d.name===c)},i=Ra(e,"paste"),a=new Set(zb(e.root)),s={value:0},l=e;for(let[c,d]of n.entries()){let u=o(d.docPart),m=Bb(e,d.control),O=null;if(u){let h=u.blocks.map((p,S)=>Db(eg(p,i),a,Jb(`${d.control.id}:placeholder:${c}:${S}`),s,m));O=d.inline?Sm(h):h;}if(!O){let h=Lk(i,Fk(d.kind),bm(i));O=d.inline?[h]:[Db(Kk(i,"p",{kind:"paragraph",children:[h]}),a,Jb(`${d.control.id}:placeholder:${c}`),s,m)];}let f=Mk(Zf(d.control),{showingPlaceholder:true},i),y={...d.content,children:O},R=d.control.children.map(h=>h.id===d.content.id?y:h.kind!=="textValue"&&h.localName==="sdtPr"?f:h),b=Xa(l,d.control.id,R);b.ok&&(l=b.part);}return l}function Gl(t,e,n){let r=e.filter(a=>a.node.localName==="tblGridChange"&&n.has(a.node.id));if(!r.length)return new Set;let o=new Map;for(let a of e){if(!["trPrChange","tcPrChange","tblPrExChange"].includes(a.node.localName))continue;let s=a.parent;for(;s&&s.kind!=="table";)s=Ua(t,s.id);if(!s)continue;let l=o.get(s.id)??[];l.push(a.node.id),o.set(s.id,l);}let i=new Set;for(let a of r){let s=a.parent&&Ua(t,a.parent.id),l=s&&o.get(s.id);l?.some(c=>n.has(c))&&l.some(c=>!n.has(c))&&i.add(a.node.id);}return i}function Rm(t,e,n,r){let o=r??t.root,i=o.kind==="textValue"?t:{...t,root:o},a=yk(i),s=n===void 0?[...Hj(i,rk(i))]:[],l=s.length?[{op:"acceptAllRevisions",siteNodeIds:s,...r?{scopeRootId:r.id}:{}}]:[];if(n?.length===0||a.length===0)return {ops:l,result:{resolved:[],skipped:[...new Set(n??[])].map(x=>({key:x,reason:"unknown-revision"})),remaining:a.length}};let c=new Set(n??a.map(Mj)),d=new Map(a.map(x=>[Mj(x),x])),u=new Set;for(let x of c){let g=d.get(x);if(g)for(let T of Lj(g))u.add(T);}let m=rk(i),O=Jj(o,m,u,e);for(let x of O.selected)u.add(x);for(let x of a){let g=Lj(x);g.length&&g.every(T=>u.has(T))&&c.add(Mj(x));}let f=uk(o,m),y=new Map(m.map((x,g)=>[x.node.id,g])),R=m.map((x,g)=>g),b=x=>{for(;R[x]!==x;)R[x]=R[R[x]],x=R[x];return x},h=(x,g)=>{R[b(g)]=b(x);};for(let x of O.dependencies){let g=x.flatMap(T=>y.has(T)?[y.get(T)]:[]);for(let T of g)h(g[0],T);}let p=new Map;for(let x of a){let g=Lj(x).flatMap(T=>{let U=y.get(T);return U===void 0?[]:[U]});for(let T of g)h(g[0],T);}let S=m.filter(x=>u.has(x.node.id)),C=new Set(lk(t,S,e).keys()),D=new Map;for(let[x,g]of m.entries()){if(e==="reject"&&g.propertyChange&&g.parent&&u.has(g.node.id))for(let U of g.parent.children)ik(g.node.localName,U)||p.set(U.id,x);let T=e==="accept"?g.node.localName==="del"||g.node.localName==="moveFrom":g.node.localName==="ins"||g.node.localName==="moveTo";if(g.paragraphMark&&g.parent&&T&&!f.has(g.node.id)&&u.has(g.node.id)){let U=Ua(t,g.parent.id),K=U&&Ua(t,U.id),B=K&&Ua(t,K.id);if(U&&K&&B){let ce=D.get(B.id);ce||(ce=pk(B.children,C),D.set(B.id,ce)),ce.has(K.id)&&p.set(U.id,x);}}if(u.has(g.node.id)&&mk(t,g,e)){let U=mk(t,g,e);U&&!g.refused&&p.set(U.id,x);}}for(let[x,g]of nk(t,S,e)){let T=Ta(t,x),U=y.get(g[0]);if(!(T?.kind!=="tableCell"||U===void 0))for(let K of T.children)K.localName==="tcPr"&&p.set(K.id,U);}let H=(x,g)=>{let T=y.get(x.id),U=p.get(x.id);T!==void 0&&U!==void 0&&h(U,T);let K=T??U;K!==void 0&&g!==void 0&&h(g,K);let B=K??g;if(x.kind!=="textValue")for(let ce of x.children)H(ce,B);};H(o);for(let x of tk(o).values()){let g=x.wrappers.flatMap(T=>{let U=y.get(T.id);return U===void 0?[]:[U]});for(let T of g)h(g[0],T);}for(let x of m.some(g=>g.node.localName==="cellMerge")?ok(i):[]){let g=x.flatMap(T=>{let U=y.get(T);return U===void 0?[]:[U]});for(let T of g)h(g[0],T);}let v=new Map;for(let[x,g]of m.entries()){let T=b(x),U=v.get(T)??[];U.push(g),v.set(T,U);}let M=new Map,Y=new Map;for(let[x,g]of v){let T=g.find(K=>K.refused),U=e==="reject"&&g.some(K=>K.propertyChange&&kk(K.node)===null);T||U?(M.set(x,"unsupported-revision"),Y.set(x,T?.refusal??"unrecorded-properties")):g.some(K=>!u.has(K.node.id))&&M.set(x,"incomplete-group");}for(let x of a)if(x.readOnly)for(let g of Lj(x)){let T=y.get(g);T!==void 0&&(M.set(b(T),"unsupported-revision"),Y.has(b(T))||Y.set(b(T),"read-only"));}let j=m.filter((x,g)=>u.has(x.node.id)&&!M.has(b(g))),ne=false,Q=lk(t,j,e);for(let[x,g]of Q){if(p.has(x))continue;let T=y.get(g[0]);T!==void 0&&(p.set(x,T),ne=true);}if(ne){H(o);for(let[x,g]of [...M]){let T=b(x);if(M.get(T)!=="unsupported-revision"){M.set(T,g);let U=Y.get(x);U&&Y.set(T,U);}}}let $=[],te=[],me=new Set,le=new Set(hk(t,m,e));for(let x of le){let g=Ua(t,x);for(;g;){if(Q.has(g.id)){le.delete(x);break}g=Ua(t,g.id);}}for(let x of c){let g=d.get(x);if(!g){te.push({key:x,reason:"unknown-revision"});continue}let T={key:x,author:g.author,partName:t.name,revisionKind:g.revisionKind,...g.formattingKind?{formattingKind:g.formattingKind}:{}},U=Lj(g),K,B;for(let ce of U){let ae=y.get(ce);if(K=ae===void 0?"incomplete-group":M.get(b(ae)),B=ae===void 0?void 0:Y.get(b(ae)),K)break}if(U.length||(K="unsupported-revision",B="no-sites"),K)te.push({key:x,reason:K,revision:T,...K==="unsupported-revision"&&B?{detail:B}:{}});else {U.some(ce=>le.has(ce))?te.push({key:x,reason:"retained-structure",revision:T}):$.push(T);for(let ce of U)le.has(ce)||me.add(ce);}}let _=Gl(t,m,me),F=new Set;for(let x of a){let g=Lj(x);if(x.formattingKind!=="tblGridChange"&&g.length>1)for(let T of g)_.has(T)&&F.add(T);}let V=[...me].filter(x=>!O.implicit.has(x)&&!F.has(x)),ee=a.length-$.length;if(ee>0&&V.length){let x={...t,root:{...t.root}},g=vk(x,e,void 0,{siteNodeIds:V,...r?{scopeRootId:r.id}:{}});if(g.ok&&g.part){let T=r?Ta(g.part,r.id):g.part.root;ee=T&&T.kind!=="textValue"?yk({...g.part,root:T}).length:0;}}return {ops:me.size?[...l,{op:e==="accept"?"acceptAllRevisions":"rejectAllRevisions",siteNodeIds:V,...r?{scopeRootId:r.id}:{}}]:l,result:{resolved:$,skipped:te,remaining:ee}}}var jx="Times New Roman",Vx="SimSun",Bo="Hans",Kl=Object.freeze({minor:new Map([["Hans","SimSun"],["Hant","PMingLiU"],["Jpan","MS Mincho"],["Hang","Batang"]]),major:new Map([["Hans","SimHei"],["Hant","MingLiU"],["Jpan","MS Gothic"],["Hang","Dotum"]])}),Xl=Object.freeze({minor:new Map([["Hans","DengXian"],["Hant","PMingLiU"],["Jpan","Yu Mincho"],["Hang","Malgun Gothic"]]),major:new Map([["Hans","DengXian Light"],["Hant","PMingLiU"],["Jpan","Yu Gothic Light"],["Hang","Malgun Gothic"]])}),Yl=new Set(["simsun","nsimsun","simsun-extb","simhei","kaiti","kaiti_gb2312","fangsong","fangsong_gb2312","microsoft yahei","microsoft yahei ui","microsoft yahei light","microsoft jhenghei","microsoft jhenghei ui","microsoft jhenghei light","mingliu","pmingliu","mingliu_hkscs","mingliu-extb","pmingliu-extb","dfkai-sb","dengxian","dengxian light","lisu","youyuan","stsong","stzhongsong","stfangsong","stkaiti","stheiti","stxihei","stxingkai","stliti","sthupo","stxinwei","pingfang sc","pingfang tc","pingfang hk","songti sc","songti tc","heiti sc","heiti tc","kaiti sc","kaiti tc","\u5B8B\u4F53","\u65B0\u5B8B\u4F53","\u9ED1\u4F53","\u6977\u4F53","\u4EFF\u5B8B","\u5FAE\u8F6F\u96C5\u9ED1","\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","\u7B49\u7EBF","\u7D30\u660E\u9AD4","\u65B0\u7D30\u660E\u9AD4","\u6A19\u6977\u9AD4","\u534E\u6587\u6977\u4F53","\u534E\u6587\u5B8B\u4F53","\u534E\u6587\u9ED1\u4F53","\u534E\u6587\u4EFF\u5B8B","\u534E\u6587\u4E2D\u5B8B","\u534E\u6587\u7EC6\u9ED1"]),ql=new Set(["arial","arial black","arial narrow","aptos","aptos display","book antiqua","calibri","calibri light","cambria","candara","century gothic","consolas","constantia","corbel","courier new","garamond","georgia","helvetica","helvetica neue","palatino linotype","segoe ui","tahoma","times new roman","trebuchet ms","verdana"]),Jl=new Set(["ms mincho","ms gothic","ms pmincho","ms pgothic","ms ui gothic","meiryo","meiryo ui","yu mincho","yu gothic","yu gothic ui","yu gothic light","yu gothic medium","hiragino mincho pron","hiragino kaku gothic pron","hiragino sans","\uFF4D\uFF53 \u660E\u671D","\uFF4D\uFF53 \u30B4\u30B7\u30C3\u30AF","\u30E1\u30A4\u30EA\u30AA","\u6E38\u660E\u671D","\u6E38\u30B4\u30B7\u30C3\u30AF","malgun gothic","batang","batangche","gulim","gulimche","dotum","dotumche","gungsuh","gungsuhche","apple sd gothic neo","\uB9D1\uC740 \uACE0\uB515","\uBC14\uD0D5","\uAD74\uB9BC","\uB3CB\uC6C0","\uAD81\uC11C"]),Im=new Set(["86","88"]),Nm=new Set(["80","81","86","88"]);function zx(t,e){let n=t?.trim().toLowerCase();return !n||n.startsWith("@")?false:Yl.has(n)?true:ql.has(n)||Jl.has(n)?false:e?.includes(n)??false}function Gx(t,e){let n=t?.trim().toLowerCase();return !n||n.startsWith("@")?false:Yl.has(n)||Jl.has(n)?true:ql.has(n)?false:e?.includes(n)??false}function Wl(t){return t.kind!=="textValue"}function Ql(t){return ec(t,Im)}function Zl(t){return ec(t,Nm)}function ec(t,e){if(!t)return [];let n=[];for(let r of t.children){if(!Wl(r)||r.localName!=="font")continue;let o=r.attributes.find(i=>i.localName==="name")?.value;if(!(!o||o.length>128)){for(let i of r.children){if(!Wl(i)||i.localName!=="charset")continue;let a=i.attributes.find(s=>s.localName==="val")?.value;a&&e.has(a.toLowerCase())&&n.push(o.trim().toLowerCase());}if(n.length>=256)break}}return Object.freeze(n)}function Vo(t){return t.kind!=="textValue"}function Zn(t,e){for(let n of t.children)if(Vo(n)&&n.localName===e)return n;return null}function vm(t,e){let n=[t];for(;n.length>0;){let r=n.pop();if(Vo(r)){if(r.localName===e)return r;for(let o=r.children.length-1;o>=0;o-=1)n.push(r.children[o]);}}return null}var ac=/^[\p{L}\p{N}\p{M} \-.+_,;]{1,64}$/u;function Mt(t,e,n){let r=Zn(t,e),i=(r?Zn(r,n):null)?.attributes.find(a=>a.localName==="typeface")?.value;return i!==void 0&&ac.test(i)?i:null}var tc=new WeakMap;function Em(t){let e=t?tc.get(t):void 0;if(e)return e;let n=t?vm(t,"fontScheme"):null;if(!n)return jo;let r=Object.freeze({major:Mt(n,"majorFont","latin"),minor:Mt(n,"minorFont","latin"),majorEastAsia:Mt(n,"majorFont","ea"),minorEastAsia:Mt(n,"minorFont","ea"),majorBidi:Mt(n,"majorFont","cs"),minorBidi:Mt(n,"minorFont","cs"),...Am(n)});return t&&tc.set(t,r),r}var nc=new WeakMap,jo=Object.freeze({major:null,minor:null,majorEastAsia:null,minorEastAsia:null}),Tm=new WeakMap,rc=new WeakMap;function zo(t,e=null,n=null){let r=wm(t,e);if(!n)return r;let o=Ql(n),i=Zl(n);if(i.length===0)return r;let a=rc.get(n);a||rc.set(n,a=new WeakMap);let s=a.get(r);if(s)return s;let l=Object.freeze({...r,...o.length>0?{chineseFontTableFaces:o}:{},eastAsianFontTableFaces:i});return a.set(r,l),l}function wm(t,e){let n=t?Em(t):jo,r=e?Zn(e,"themeFontLang"):null,o=Tm;r&&e&&(o=nc.get(e)??new WeakMap,nc.set(e,o));let i=o.get(n);if(i)return i;let a=R=>r?.attributes.find(b=>b.localName===R)?.value,s=oc(a("val")),l=oc(a("bidi")),c=a("eastAsia"),d=Go(c),u=(R,b,h)=>b&&(R?n.majorSupplemental:n.minorSupplemental)?.[b]||h||null,m=n===jo?Xl:Kl,O=d??Bo,f=(R,b)=>(d?u(R,d,b):b||u(R,Bo,null))||(R?m.major:m.minor).get(O)||null,y=Object.freeze({major:u(true,s,n.major),minor:u(false,s,n.minor),majorEastAsia:f(true,n.majorEastAsia),minorEastAsia:f(false,n.minorEastAsia),majorBidi:u(true,l,n.majorBidi),minorBidi:u(false,l,n.minorBidi),...c===void 0?{majorSupplemental:n.majorSupplemental,minorSupplemental:n.minorSupplemental}:{}});return o.set(n,y),y}var Cm=new Map([["minorAscii",t=>t.minor],["minorHAnsi",t=>t.minor],["majorAscii",t=>t.major],["majorHAnsi",t=>t.major],["minorEastAsia",t=>t.minorEastAsia??null],["majorEastAsia",t=>t.majorEastAsia??null],["minorBidi",t=>t.minorBidi??null],["majorBidi",t=>t.majorBidi??null]]);function Xx(t,e,n){if(t===void 0)return null;let r=Cm.get(t)?.(e)??null;if(r!==null)return r;let o=Go(n);return o?(t==="majorEastAsia"?e.majorSupplemental:t==="minorEastAsia"?e.minorSupplemental:void 0)?.[o]??null:null}function Go(t){if(!t||t.length>85)return null;let e=t.toLowerCase().split("-");return e[0]==="ja"?"Jpan":e[0]==="ko"?"Hang":e[0]!=="zh"?null:e.includes("hant")?"Hant":e.includes("hans")?"Hans":e.some(n=>["tw","hk","mo"].includes(n))?"Hant":"Hans"}var Mm=new Map([["ar","Arab"],["fa","Arab"],["ur","Arab"],["ps","Arab"],["he","Hebr"],["yi","Hebr"],["dv","Thaa"],["syr","Syrc"]]);function oc(t){if(!t||t.length>85)return null;let e=t.toLowerCase().split("-");return e[1]&&/^[a-z]{4}$/.test(e[1])?e[1][0].toUpperCase()+e[1].slice(1):Go(t)??Mm.get(e[0])??null}function Am(t){let e={};for(let[n,r]of [["majorFont","majorSupplemental"],["minorFont","minorSupplemental"]]){let o=Object.create(null);for(let i of Zn(t,n)?.children??[]){if(!Vo(i)||i.localName!=="font")continue;let a=i.attributes.find(l=>l.localName==="script")?.value,s=i.attributes.find(l=>l.localName==="typeface")?.value;a&&/^[A-Z][a-z]{3}$/.test(a)&&s&&ac.test(s)&&(o[a]=s);}Object.keys(o).length&&(e[r]=Object.freeze(o));}return e}var Ze=Object.freeze({styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",fontTable:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"});function Wo(t,e,n,r){let o=(t.relationships.get(e)??[]).find(i=>i.type===n);if(o){let i=J(o);if(i.mode==="Internal"&&i.target.ok){let a=t.parts.get(i.target.partName);if(a)return a}}return t.parts.get(r)}function ak(t){let e=Ee$1(t);if(!e.ok)return {ok:false,reason:e.reason,...e.detail?{detail:e.detail}:{}};let n=e.package.parts.get(e.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-tree",detail:e.package.mainDocumentPart};let r=new en(e.package,Uo(e.package,Eb(n)));return {ok:true,view:Dm(r)}}function Dm(t){let e=()=>t.currentPackage(),n=()=>t.bodyStore().part,r=(c,d)=>Wo(e(),e().mainDocumentPart,c,d)?.root??null,o=Object.freeze(zo(null)),i=null,a=ui,s=null;return Object.freeze({part:n,currentPackage:e,packageRevision:()=>t.packageRevision,stylesRoot:()=>r(Ze.styles,"/word/styles.xml"),numberingRoot:()=>r(Ze.numbering,"/word/numbering.xml"),settingsRoot:()=>r(Ze.settings,"/word/settings.xml"),documentThemeFonts(){let c=e();return i!==c&&(o=Object.freeze(zo(r(Ze.theme,"/word/theme/theme1.xml"),r(Ze.settings,"/word/settings.xml"),r(Ze.fontTable,"/word/fontTable.xml"))),i=c),o},documentProperties(){let c=e();if(s!==c){let d=Wo(c,"/",Ze.coreProperties,"/docProps/core.xml"),u=Wo(c,"/",Ze.extendedProperties,"/docProps/app.xml");a=vi$1(d?.root??null,u?.root??null),s=c;}return a},headerFooterPartsBySection:()=>_if(e()),headerFooterResolutionBySection:()=>hf(e()),relationshipTarget:c=>Qg(e(),n().name,c)})}
2
+ export{nm as $,$r as A,zo as Aa,Ur as B,Xx as Ba,Br as C,ak as Ca,jr as D,Dm as Da,Oc as E,Mi as F,Sc as G,Gt as H,Fn as I,Ln as J,Li as K,Fu as L,Di as M,Gc as N,so as O,Is as P,lo as Q,pt as R,kl as S,en as T,Ol as U,bl as V,So as W,eh as X,Io as Y,Do as Z,_o as _,ic as a,rm as aa,Ni as b,om as ba,wn as c,am as ca,dt as d,im as da,Cn as e,sm as ea,Mn as f,Ll as fa,fe as g,Hl as ga,dc as h,Fo as ha,mt as i,Lo as ia,jt as j,cm as ja,An as k,mm as ka,Vt as l,um as la,Dn as m,pm as ma,Ar as n,fm as na,Dr as o,gm as oa,_r as p,hm as pa,fc as q,Ho as qa,gc as r,Vl as ra,Lr as s,zl as sa,Ei as t,ym as ta,hc as u,Uo as ua,Fr as v,Rm as va,yc as w,jx as wa,zt as x,Vx as xa,Hr as y,zx as ya,xc as z,Gx as za};