@docx-editor.dev/core 2.9.1 → 2.9.2

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 (87) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.js +1 -1
  3. package/dist/binding.cjs +1 -1
  4. package/dist/binding.d.cts +7 -7
  5. package/dist/binding.d.ts +7 -7
  6. package/dist/binding.js +1 -1
  7. package/dist/chunk-6JWP2H7K.js +2 -0
  8. package/dist/chunk-6KNLLEUW.cjs +18 -0
  9. package/dist/chunk-7ADTI533.cjs +10 -0
  10. package/dist/chunk-7ETDCPF6.cjs +2 -0
  11. package/dist/chunk-7I3BSGGS.js +1 -0
  12. package/dist/{chunk-XMHWBL3K.cjs → chunk-7UU5YFCD.cjs} +1 -1
  13. package/dist/chunk-CKDAK3MV.js +10 -0
  14. package/dist/chunk-DIMEYVNS.js +2 -0
  15. package/dist/{chunk-IEXDXWTA.cjs → chunk-H2656QDI.cjs} +1 -1
  16. package/dist/chunk-KQGENNL5.cjs +15 -0
  17. package/dist/chunk-LIXPSV4T.js +18 -0
  18. package/dist/{chunk-DKMKH77K.cjs → chunk-O4UULRAQ.cjs} +5 -5
  19. package/dist/chunk-SIIFNE6U.js +15 -0
  20. package/dist/chunk-VXYECPKA.js +5 -0
  21. package/dist/contracts/editor.d.cts +6 -6
  22. package/dist/contracts/editor.d.ts +6 -6
  23. package/dist/contracts/interaction.d.cts +6 -6
  24. package/dist/contracts/interaction.d.ts +6 -6
  25. package/dist/contracts/modules.d.cts +3 -3
  26. package/dist/contracts/modules.d.ts +3 -3
  27. package/dist/{custom-node-writes-QyVZdTUA.d.ts → custom-node-writes-D6SGwebL.d.ts} +20 -4
  28. package/dist/{custom-node-writes-7ERv0f_X.d.cts → custom-node-writes-Dy3b20PS.d.cts} +20 -4
  29. package/dist/{editor-PUlv5Pp7.d.ts → editor-Cvd7Geoc.d.ts} +4 -4
  30. package/dist/{editor-CojjwMmF.d.cts → editor-cAEf1uXW.d.cts} +4 -4
  31. package/dist/editor.cjs +1 -1
  32. package/dist/editor.css +9 -5
  33. package/dist/editor.d.cts +18 -18
  34. package/dist/editor.d.ts +18 -18
  35. package/dist/editor.js +1 -1
  36. package/dist/{image-resources-eZqD_-vC.d.ts → image-resources-BgA9EQxY.d.ts} +1 -1
  37. package/dist/{image-resources-DQOiwOuE.d.cts → image-resources-BiA-IXgo.d.cts} +1 -1
  38. package/dist/{index-oN-v8DQ5.d.ts → index-DRqY5JVF.d.ts} +58 -12
  39. package/dist/{index-DGPSeLI0.d.cts → index-wb-iOxfh.d.cts} +58 -12
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +12 -12
  42. package/dist/index.d.ts +12 -12
  43. package/dist/index.js +1 -1
  44. package/dist/layout.cjs +1 -1
  45. package/dist/layout.d.cts +334 -306
  46. package/dist/layout.d.ts +334 -306
  47. package/dist/layout.js +1 -1
  48. package/dist/output.cjs +1 -1
  49. package/dist/output.d.cts +5 -5
  50. package/dist/output.d.ts +5 -5
  51. package/dist/output.js +1 -1
  52. package/dist/{review-items-DpsqTHio.d.cts → review-items-B8tffIXj.d.cts} +1 -1
  53. package/dist/{review-items-D5SPFtsO.d.ts → review-items-bdGxFWNA.d.ts} +1 -1
  54. package/dist/{review-reads-CP106AHp.d.cts → review-reads-Bxz03tHG.d.cts} +1 -1
  55. package/dist/{review-reads-B2Ji3fVU.d.ts → review-reads-CHODU0LI.d.ts} +1 -1
  56. package/dist/{semantic-cell-selection-DJPjBWzf.d.cts → semantic-cell-selection-BPzx6DdT.d.cts} +2 -2
  57. package/dist/{semantic-cell-selection-BWhVAk5B.d.ts → semantic-cell-selection-CsHcr-yk.d.ts} +2 -2
  58. package/dist/{semantic-interaction-BjOcDB06.d.cts → semantic-interaction-BfWDD_0V.d.cts} +1 -1
  59. package/dist/{semantic-interaction-Cca1-X_a.d.ts → semantic-interaction-D-RZ9Ust.d.ts} +1 -1
  60. package/dist/{semantic-paint-Ur7pAINj.d.cts → semantic-paint-Bd7EqzXV.d.cts} +2 -2
  61. package/dist/{semantic-paint-CufpIQFw.d.ts → semantic-paint-WhVtSDJK.d.ts} +2 -2
  62. package/dist/{semantic-records-Cc1MJrhM.d.ts → semantic-records-DCt-ZwKU.d.ts} +22 -4
  63. package/dist/{semantic-records-C3Z76KeN.d.cts → semantic-records-DadVT_E1.d.cts} +22 -4
  64. package/dist/{shaped-measurer-CwlTPDJO.d.ts → shaped-measurer-B9f4A7QA.d.ts} +1 -1
  65. package/dist/{shaped-measurer-CYSK20E2.d.cts → shaped-measurer-CninrHr_.d.cts} +1 -1
  66. package/dist/store.cjs +1 -1
  67. package/dist/store.d.cts +131 -131
  68. package/dist/store.d.ts +131 -131
  69. package/dist/store.js +1 -1
  70. package/dist/{tree-op-types-XMVsJSpe.d.ts → tree-op-types-CnRb7AYo.d.ts} +22 -1
  71. package/dist/{tree-op-types-B0-sCtw-.d.cts → tree-op-types-D1vNJ7XC.d.cts} +22 -1
  72. package/dist/{tree-session-D945D43B.d.cts → tree-session-Df02ajqc.d.cts} +5 -5
  73. package/dist/{tree-session-DBJgmdmc.d.ts → tree-session-ZuBFOhIh.d.ts} +5 -5
  74. package/dist/{tree-store-C6vc8E_2.d.cts → tree-store-B_sJBMIS.d.cts} +1 -1
  75. package/dist/{tree-store-ClA-qng4.d.ts → tree-store-DgETo6Mf.d.ts} +1 -1
  76. package/package.json +2 -2
  77. package/dist/chunk-5VC5HGJA.js +0 -2
  78. package/dist/chunk-A2JIBG75.js +0 -1
  79. package/dist/chunk-FWUI7EXG.cjs +0 -15
  80. package/dist/chunk-GZWMLQJO.js +0 -18
  81. package/dist/chunk-IMMAG4QP.cjs +0 -10
  82. package/dist/chunk-JTSNJQFO.js +0 -15
  83. package/dist/chunk-KBCC66CI.js +0 -5
  84. package/dist/chunk-LJ6BY6IU.cjs +0 -18
  85. package/dist/chunk-QDBAXFIK.js +0 -2
  86. package/dist/chunk-RD266XSK.cjs +0 -2
  87. package/dist/chunk-VUJGPCPU.js +0 -10
@@ -1,10 +0,0 @@
1
- import {XMLParser,XMLValidator}from'fast-xml-parser';import {unzipSync,zipSync,strToU8,strFromU8}from'fflate';var Xk=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qk=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),nt=(e,n)=>e>>>n|e<<32-n,zu=e=>{let n=Math.ceil((e.byteLength+9)/64)*64,t=new Uint8Array(n);t.set(e),t[e.byteLength]=128;let r=BigInt(e.byteLength)*8n;for(let a=0;a<8;a+=1)t[n-1-a]=Number(r>>BigInt(a*8)&0xffn);let o=Xk.slice(),i=new Uint32Array(64);for(let a=0;a<t.length;a+=64){for(let p=0;p<16;p+=1){let x=a+p*4;i[p]=(t[x]<<24|t[x+1]<<16|t[x+2]<<8|t[x+3])>>>0;}for(let p=16;p<64;p+=1){let x=i[p-15],y=i[p-2],N=nt(x,7)^nt(x,18)^x>>>3,b=nt(y,17)^nt(y,19)^y>>>10;i[p]=i[p-16]+N+i[p-7]+b>>>0;}let l=o[0],s=o[1],d=o[2],c=o[3],u=o[4],f=o[5],m=o[6],g=o[7];for(let p=0;p<64;p+=1){let x=nt(u,6)^nt(u,11)^nt(u,25),y=u&f^~u&m,N=g+x+y+qk[p]+i[p]>>>0,b=nt(l,2)^nt(l,13)^nt(l,22),h=l&s^l&d^s&d,P=b+h>>>0;g=m,m=f,f=u,u=c+N>>>0,c=d,d=s,s=l,l=N+P>>>0;}o[0]=o[0]+l>>>0,o[1]=o[1]+s>>>0,o[2]=o[2]+d>>>0,o[3]=o[3]+c>>>0,o[4]=o[4]+u>>>0,o[5]=o[5]+f>>>0,o[6]=o[6]+m>>>0,o[7]=o[7]+g>>>0;}return `sha256:${Array.from(o,a=>a.toString(16).padStart(8,"0")).join("")}`};var z="dev.docx-editor.core",ge={mutationHuman:`${z}.origin.mutation.human`,mutationAgent:`${z}.origin.mutation.agent`,mutationRemote:`${z}.origin.mutation.remote`,mutationUndo:`${z}.origin.mutation.undo`,mutationRedo:`${z}.origin.mutation.redo`,mutationMigration:`${z}.origin.mutation.migration`,mutationRepair:`${z}.origin.mutation.repair`,mutationServer:`${z}.origin.mutation.server`,projection:`${z}.origin.projection`,awareness:`${z}.origin.awareness`},$_=[ge.mutationHuman,ge.mutationAgent,ge.mutationRemote,ge.mutationUndo,ge.mutationRedo,ge.mutationMigration,ge.mutationRepair,ge.mutationServer],z_=[ge.projection,ge.awareness],Yk={applied:`${z}.result.applied`,validation:`${z}.result.validation`,conflict:`${z}.result.conflict`,resource:`${z}.result.resource`,authorization:`${z}.result.authorization`,aborted:`${z}.result.aborted`},Zk={fonts:`${z}.port.fonts`,shaping:`${z}.port.shaping`,images:`${z}.port.images`,clock:`${z}.port.clock`,identity:`${z}.port.identity`,persistence:`${z}.port.persistence`,transport:`${z}.port.transport`,scheduling:`${z}.port.scheduling`,audit:`${z}.port.audit`,authorization:`${z}.port.authorization`,resourceAccounting:`${z}.port.resource-accounting`,cancellation:`${z}.port.cancellation`,externalResourceConsent:`${z}.port.external-resource-consent`},sr={style:`${z}.dep.style`,numbering:`${z}.dep.numbering`,section:`${z}.dep.section`,story:`${z}.dep.story`,font:`${z}.dep.font`,image:`${z}.dep.image`,table:`${z}.dep.table`,field:`${z}.dep.field`,note:`${z}.dep.note`,headerFooter:`${z}.dep.header-footer`,annotation:`${z}.dep.annotation`},X_=[...Object.values(ge),...Object.values(Yk),...Object.values(Zk),...Object.values(sr)];var Xu=Object.freeze({maxRecursionDepth:256,maxElementCount:5e7,maxPartCount:1e5,maxDecompressedBytes:2147483648,maxCompressedBytes:536870912,maxCompressionRatio:200,maxChunkBytes:67108864,maxPaginationPasses:100,maxQueueDepth:1e6}),Qk=Object.freeze({maxRecursionDepth:128,maxElementCount:1e7,maxPartCount:1e4,maxDecompressedBytes:512*1024*1024,maxCompressedBytes:128*1024*1024,maxCompressionRatio:100,maxChunkBytes:16*1024*1024,maxPaginationPasses:32,maxQueueDepth:1e5}),Jk=Object.keys(Xu);function Y_(e){let n={};for(let t of Jk){let r=Xu[t],o=e?.[t],i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:Qk[t];n[t]=Math.min(Math.floor(i),r);}return Object.freeze(n)}var oa=Object.freeze({maxEncodedBytes:64*1024*1024,maxDecodedBytes:512*1024*1024,maxPixels:25e7,maxDimension:65536,maxPolygonPoints:16384,maxExternalRedirects:32}),eb=Object.freeze({maxEncodedBytes:32*1024*1024,maxDecodedBytes:400*1024*1024,maxPixels:1e8,maxDimension:32768,maxPolygonPoints:4096,maxExternalRedirects:8}),nb=Object.keys(oa);function Ar(e){let n={};for(let t of nb){let r=oa[t],o=e?.[t],i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:eb[t];n[t]=Math.min(Math.floor(i),r);}return Object.freeze(n)}var is=class extends Error{constructor(t,r,o){super(`${t}: attempted ${o} exceeds limit ${r}`);this.label=t;this.limit=r;this.attempted=o;this.name="LimitExceededError";}label;limit;attempted},ia=class{constructor(n,t){this.label=n;this.limit=t;if(!Number.isFinite(t)||t<0)throw new Error(`BoundedCounter limit must be a finite non-negative number, got ${t}`)}label;limit;value=0;get current(){return this.value}get remaining(){return this.limit-this.value}add(n=1){if(!Number.isFinite(n)||n<0)throw new Error(`${this.label}: increment must be a finite non-negative number, got ${n}`);if(n>Number.MAX_SAFE_INTEGER-this.value||this.value+n>this.limit)throw new is(this.label,this.limit,this.value+n);return this.value+=n,this.value}canAdd(n=1){return Number.isFinite(n)&&n>=0&&n<=Number.MAX_SAFE_INTEGER-this.value&&this.value+n<=this.limit}release(n){if(!Number.isFinite(n)||n<0)throw new Error(`${this.label}: release must be finite >= 0`);this.value=Math.max(0,this.value-n);}};var aa=/[\x00-\x1f\x7f]/,tb=new RegExp(aa.source,"g");function J_(e){return e.replace(tb,"")}var rb=/%(2f|5c)/i,ob=/%2e/i,ib=/^[a-zA-Z]:/;function Yu(e){return e.length===0?"empty":aa.test(e)?"control-char":e.includes("\\")?"backslash":ib.test(e)||e.startsWith("//")?"drive-or-unc":rb.test(e)?"encoded-separator":ob.test(e)?"encoded-dot":null}function Zu(e){let n;try{n=decodeURIComponent(e);}catch{return {ok:false,reason:"bad-encoding"}}return aa.test(n)?{ok:false,reason:"control-char"}:n.includes("\\")?{ok:false,reason:"backslash"}:{ok:true,value:n}}function ab(e){return e.length===0?"empty-segment":e==="."||e===".."?"dot-segment":e.endsWith(".")?"segment-trailing-dot":e==="__proto__"||e==="constructor"||e==="prototype"?"unsafe-key":null}function xe(e){let n=Yu(e);if(n)return {ok:false,reason:n};let t=Zu(e);if(!t.ok)return t;let o=(t.value.startsWith("/")?t.value.slice(1):t.value).split("/");for(let i of o){let a=ab(i);if(a)return {ok:false,reason:a}}return {ok:true,partName:"/"+o.join("/")}}var qu=xe("word/document.xml"),eD=qu.ok?qu.partName:"/word/document.xml";function as(e){let n="";for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);n+=r>=65&&r<=90?String.fromCharCode(r+32):e[t];}return n}function G(e){return as(e)}function nD(e){let n=new Map,t=[];for(let o of e){let i=xe(o);if(!i.ok){t.push({raw:o,reason:i.reason});continue}let a=G(i.partName);n.set(a,(n.get(a)??0)+1);}return {duplicates:[...n.entries()].filter(([,o])=>o>1).map(([o])=>o),rejected:t}}function We(e,n){let t=Yu(n);if(t)return {ok:false,reason:t};let r=Zu(n);if(!r.ok)return r;let o=r.value,i=e.replace(/^\//,"").split("/");i.pop();let a=o.startsWith("/")?[]:[...i];for(let l of (o.startsWith("/")?o.slice(1):o).split("/"))if(!(l===""||l===".")){if(l===".."){if(a.length===0)return {ok:false,reason:"traversal-escape"};a.pop();continue}if(l.endsWith("."))return {ok:false,reason:"segment-trailing-dot"};a.push(l);}return a.length===0?{ok:false,reason:"empty-segment"}:{ok:true,partName:"/"+a.join("/")}}var lb=/^(javascript|vbscript|data|file):/i,sb=/^[a-zA-Z][a-zA-Z0-9+.-]*:/;function Mr(e){return e.length===0?{ok:false,reason:"empty"}:aa.test(e)?{ok:false,reason:"control-char"}:sb.test(e)?lb.test(e)?{ok:false,reason:"unsafe-scheme"}:{ok:true,partName:e}:{ok:false,reason:"not-absolute-uri"}}var db=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*$/,cb=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\s*$/;function Qu(e){let n=e.indexOf(";");return n===-1?db.test(e):cb.test(e.slice(0,n))?e.slice(n+1).split(";").every(t=>t.length>0):false}function Ju(e){return as(e.replace(/^\./,""))}function ls(e,n=1e5){let t=new ia("content-type-records",n),r=new Map,o=new Map;for(let i of e.defaults){try{t.add(1);}catch{return {ok:false,error:{code:"too-many-records",limit:n}}}if(!Qu(i.contentType))return {ok:false,error:{code:"invalid-mime",value:i.contentType}};let a=Ju(i.extension),l=r.get(a);if(l!==void 0&&l!==i.contentType)return {ok:false,error:{code:"conflicting-default",extension:a}};r.set(a,i.contentType);}for(let i of e.overrides){try{t.add(1);}catch{return {ok:false,error:{code:"too-many-records",limit:n}}}if(!Qu(i.contentType))return {ok:false,error:{code:"invalid-mime",value:i.contentType}};let a=xe(i.partName);if(!a.ok)return {ok:false,error:{code:"invalid-override-name",partName:i.partName}};let l=G(a.partName),s=o.get(l);if(s!==void 0&&s!==i.contentType)return {ok:false,error:{code:"duplicate-override",partName:l}};o.set(l,i.contentType);}return {ok:true,index:{defaults:r,overrides:o}}}function Bt(e,n){let t=e.overrides.get(G(n));if(t!==void 0)return {ok:true,contentType:t,source:"override"};let r=n.lastIndexOf(".");if(r>=0){let o=Ju(n.slice(r+1)),i=e.defaults.get(o);if(i!==void 0)return {ok:true,contentType:i,source:"default"}}return {ok:false,reason:"unknown"}}var la="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";function ef(e){let n=new Map,t=new Map;for(let r of [...e].sort((o,i)=>o.order-i.order)){let o=t.get(r.ownerPart)??new Set;if(o.has(r.id))return {ok:false,error:{code:"duplicate-id",ownerPart:r.ownerPart,id:r.id}};o.add(r.id),t.set(r.ownerPart,o);let i=n.get(r.ownerPart)??[];i.push(r),n.set(r.ownerPart,i);}return {ok:true,byOwner:n}}function Me(e){return e.targetMode==="External"?{mode:"External",sinkSafe:Mr(e.rawTarget),raw:e.rawTarget}:{mode:"Internal",target:We(e.ownerPart,e.rawTarget),raw:e.rawTarget}}function _r(e,n,t){if(!e)return {mode:"missing"};for(let r of e){if(r.ownerPart!==n||r.id!==t)continue;if(r.type!==la)return {mode:"missing"};let o=Me(r);return o.mode==="External"?{mode:"external",sinkSafe:o.sinkSafe.ok,raw:o.raw}:o.target.ok?{mode:"internal",partName:o.target.partName,raw:o.raw}:{mode:"missing"}}return {mode:"missing"}}var ub=["__proto__","prototype","constructor"],fb=new Set(ub),ss=class extends Error{constructor(t,r){super(`dangerous key ${JSON.stringify(t)} at ${r||"<root>"}`);this.key=t;this.path=r;this.name="DangerousKeyError";}key;path};function mb(e){return fb.has(e)}function cs(){return Object.create(null)}function sD(e,n=""){return ds(e,n,new WeakSet)}function ds(e,n,t){if(e===null||typeof e!="object")return e;if(t.has(e))throw new Error(`cyclic structure at ${n||"<root>"}`);if(t.add(e),Array.isArray(e)){let o=e.map((i,a)=>ds(i,`${n}[${a}]`,t));return t.delete(e),o}let r=cs();for(let o of Object.keys(e)){if(mb(o))throw new ss(o,n);r[o]=ds(e[o],n?`${n}.${o}`:o,t);}return t.delete(e),r}var pb=new Set(["http","https","mailto","tel","ftp"]),gb=/^([a-zA-Z][a-zA-Z0-9+.-]*):/;function yt(e){let n=e.replace(/[\t\n\r]/g,"").trim(),t=gb.exec(n);return t&&!pb.has(t[1].toLowerCase())?{ok:false,inert:true}:{ok:true,href:n}}var nf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;","\r":"&#xD;"};function xb(e){return e.replace(/[&<>"'\r]/g,n=>nf[n])}var hb={...nf,"\n":"&#xA;"," ":"&#x9;"};function yb(e){return e.replace(/[&<>"'\r\n\t]/g,n=>hb[n])}function Ob(e){return e===9||e===10||e===13?false:e<32?true:e===65534||e===65535}function $(e){if(typeof e!="string")return false;for(let n=0;n<e.length;n++){let t=e.charCodeAt(n);if(Ob(t))return false;if(t>=55296&&t<=56319){let r=e.charCodeAt(n+1);if(!(r>=56320&&r<=57343))return false;n++;}else if(t>=56320&&t<=57343)return false}return true}function on(e,n){if(typeof e!="string")throw new Error(`${n} must be a string scalar (got ${typeof e})`);if(!$(e))throw new Error(`${n} contains a character not valid in XML 1.0`);return xb(e)}function tf(e,n){if(typeof e!="string")throw new Error(`${n} must be a string scalar (got ${typeof e})`);if(!$(e))throw new Error(`${n} contains a character not valid in XML 1.0`);return yb(e)}function cD(e){return e.replace(/[\x00-\x1f\x7f"'\\]/g,n=>`\\${n.charCodeAt(0).toString(16)} `)}function uD(e){return /url\s*\(|@import/i.test(e)}var Nb=["field-dde","field-include","macro","activex","ole","embedded-object","executable-relationship"],kb=new Set(Nb);function bb(e){return kb.has(e)}var Pb=new Set(["PAGE","NUMPAGES","PAGEREF","REF","SEQ","TOC","DATE","TIME","STYLEREF"]);function fD(e){let n=e.trim().split(/\s+/)[0]?.toUpperCase()??"";return Pb.has(n)}function mD(e){let n=[],t=[];for(let r of e)(bb(r.kind)?t:n).push(r);return {kept:n,removed:t,nonLossless:t.length>0}}var Dr=256,sf=Dr,Fo=64*1024*1024,rf=1e6;function of(e){let n=e.indexOf("&")<0?e:e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g,(t,r)=>{switch(r){case "amp":return "&";case "lt":return "<";case "gt":return ">";case "quot":return '"';case "apos":return "'";default:{let o=r[1]==="x"?parseInt(r.slice(2),16):parseInt(r.slice(1),10);if(!Number.isSafeInteger(o)||!(o===9||o===10||o===13||o>=32&&o<=55295||o>=57344&&o<=65533||o>=65536&&o<=1114111))throw new Error("numeric reference is not a valid XML 1.0 scalar");return String.fromCodePoint(o)}}});return df(n)}function df(e){if(!$(e))throw new Error("value is not valid XML 1.0 text");return e}var sa=class extends Error{},da=class extends Error{},af=/&(?!(amp|lt|gt|quot|apos);)[A-Za-z_][\w.-]*;/y;function lf(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=0}function Rb(e){for(let n=0;n<e.length;n+=1){let t=e.charCodeAt(n);if(!(t!==60&&t!==38)){if(t===38){if(af.lastIndex=n,af.test(e))return "entity-forbidden";continue}if(e.startsWith("<![CDATA[",n)){let r=e.indexOf("]]>",n+9);if(r<0)return "parse-error";n=r+2;continue}if(e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r<0)return "parse-error";n=r+2;continue}if(e.startsWith("<?",n)){let r=e.indexOf("?>",n+2);if(r<0)return "parse-error";n=r+1;continue}if(e.startsWith("<!",n)){let r=e.slice(n,n+10).toUpperCase();if(r.startsWith("<!DOCTYPE"))return "dtd-forbidden";if(r.startsWith("<!ENTITY"))return "entity-forbidden"}}}}function Ib(e,n){let t=0;for(let r=0;r<e.length;r+=1){let o=e.charCodeAt(r);if(o<=127)t+=1;else if(o<=2047)t+=2;else if(o>=55296&&o<=56319){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(t+=4,r+=1):t+=3;}else t+=3;if(t>n)return true}return false}function Tb(e,n){let t=0;for(let r=0;r<e.length;r+=1){if(e[r]!=="<")continue;if(e.startsWith("<!--",r)){let l=e.indexOf("-->",r+4);if(l<0)return "parse-error";r=l+2;continue}if(e.startsWith("<![CDATA[",r)){let l=e.indexOf("]]>",r+9);if(l<0)return "parse-error";r=l+2;continue}if(e.startsWith("<?",r)){let l=e.indexOf("?>",r+2);if(l<0)return "parse-error";r=l+1;continue}let o=e[r+1];if(o==="/"||o==="!")continue;if(t+=1,t>n)return "too-many-elements";let i,a=false;for(r+=1;r<e.length;r+=1){let l=e[r];if(i)l===i&&(i=void 0);else if(l==='"'||l==="'")i=l;else if(l===">"){a=true;break}}if(!a)return "parse-error"}}function Cb(e){let n=0;for(let t=0;t<e.length;t+=1){if(e[t]!=="<")continue;if(e.startsWith("<!--",t)){let a=e.indexOf("-->",t+4);if(a<0)return "parse-error";t=a+2;continue}if(e.startsWith("<![CDATA[",t)){let a=e.indexOf("]]>",t+9);if(a<0)return "parse-error";t=a+2;continue}if(e.startsWith("<?",t)){let a=e.indexOf("?>",t+2);if(a<0)return "parse-error";t=a+1;continue}if(e.startsWith("</",t)){n=Math.max(0,n-1);let a=e.indexOf(">",t+2);if(a<0)return "parse-error";t=a;continue}if(e.startsWith("<!",t))continue;let r,o=-1;for(let a=t+1;a<e.length;a+=1){let l=e[a];if(r)l===r&&(r=void 0);else if(l==='"'||l==="'")r=l;else if(l===">"){o=a;break}}if(o<0)return "parse-error";if(!e.slice(t+1,o).trimEnd().endsWith("/")&&(n+=1,n>sf+1))return "too-deep";t=o;}}var vb=new XMLParser({preserveOrder:true,ignoreAttributes:false,attributeNamePrefix:"@_",trimValues:false,parseTagValue:false,parseAttributeValue:false,processEntities:false,htmlEntities:false,cdataPropName:"#cdata",ignoreDeclaration:true,ignorePiTags:true});function tt(e,n={maxBytes:Fo}){if(!lf(n.maxBytes)||n.maxElements!==void 0&&!lf(n.maxElements))return {ok:false,reason:"invalid-limits"};let t=Math.min(n.maxBytes,Fo),r=Math.min(n.maxElements??rf,rf);if(Ib(e,t))return {ok:false,reason:"too-large"};let o=Rb(e);if(o)return {ok:false,reason:o};let i=Tb(e,r);if(i)return {ok:false,reason:i};let a=Cb(e);if(a)return {ok:false,reason:a};if(XMLValidator.validate(e)!==true)return {ok:false,reason:"parse-error"};let l;try{l=vb.parse(e);}catch{return {ok:false,reason:"parse-error"}}try{return {ok:!0,nodes:cf(l,0,{count:0,maxElements:r})}}catch(s){return {ok:false,reason:s instanceof sa?"too-deep":s instanceof da?"too-many-elements":"parse-error"}}}function us(e,n){if(typeof e!="string")throw new Error(`non-scalar ${n}`);return e}function Sb(e){if(typeof e=="string")return e;if(!Array.isArray(e))throw new Error("non-scalar cdata");return e.map(n=>{if(n!==null&&typeof n=="object"&&"#text"in n)return us(n["#text"],"cdata");throw new Error("non-scalar cdata")}).join("")}function cf(e,n,t){if(n>sf)throw new sa;let r=[];for(let o of e){if("#text"in o){r.push({type:"text",value:of(us(o["#text"],"text"))});continue}if("#cdata"in o){r.push({type:"text",value:df(Sb(o["#cdata"]))});continue}let i=o[":@"]??{},a=Object.keys(o).find(s=>s!==":@");if(!a)continue;if(t.count+=1,t.count>t.maxElements)throw new da;let l=Object.create(null);for(let[s,d]of Object.entries(i))l[s.replace(/^@_/,"")]=of(us(d,"attribute"));r.push({type:"element",name:a,attributes:l,children:cf(o[a]??[],n+1,t)});}return r}function Ab(e,n){for(let t of e){if(t.type!=="element")continue;if(t.name===n)return t;let r=Ab(t.children,n);if(r)return r}}function hD(e,n){return e.children.filter(t=>t.type==="element"&&t.name===n)}function Mb(e){let n="";for(let t of e.children)t.type==="text"?n+=t.value:n+=Mb(t);return n}var _b=/^[A-Za-z_][A-Za-z0-9._-]*$/;function be(e){return _b.test(e)}function Db(e){let n=e.split(":");return n.length===1?be(n[0]):n.length===2?be(n[0])&&be(n[1]):false}function OD(e){if(!Db(e))throw new Error(`invalid QName for serialization: ${JSON.stringify(e)}`)}var uf=class{byUri=new Map;usedPrefixes=new Set;counter=0;constructor(n={}){for(let[t,r]of Object.entries(n))this.byUri.set(t,r),this.usedPrefixes.add(r);}prefixFor(n){let t=this.byUri.get(n);if(t)return t;let r;do this.counter+=1,r=`ns${this.counter}`;while(this.usedPrefixes.has(r));return this.byUri.set(n,r),this.usedPrefixes.add(r),r}bindings(){return [...this.byUri.entries()].map(([n,t])=>({prefix:t,uri:n}))}};var mf="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Ub="http://schemas.microsoft.com/office/word/2010/wordml",Lb=["rPr","alias","tag","id","lock","placeholder","temporary","showingPlcHdr","dataBinding","label","tabIndex"],ff=new Map(Lb.map((e,n)=>[e,n])),Bb=new Set(["equation","comboBox","date","docPartObj","docPartList","dropDownList","picture","richText","text","citation","group","bibliography"]),Fb=new Set(["contentControlDateFormat","contentControlLid","contentControlStoreMappedDataAs","contentControlCalendar"]),Vb=new Set(["contentControlDateFormat","contentControlLid","contentControlStoreMappedDataAs","contentControlCalendar","generic"]),Wb=new Set(["contentControlChecked","contentControlCheckedState","contentControlUncheckedState","generic"]),Hb={dateFormat:"contentControlDateFormat",lid:"contentControlLid",storeMappedDataAs:"contentControlStoreMappedDataAs",calendar:"contentControlCalendar"},jb={checked:"contentControlChecked",checkedState:"contentControlCheckedState",uncheckedState:"contentControlUncheckedState"},Kb={sdt:"contentControl",sdtPr:"contentControlProperties",sdtEndPr:"contentControlEndProperties",sdtContent:"contentControlContent",dropDownList:"contentControlDropDownList",comboBox:"contentControlComboBox",listItem:"contentControlListItem",date:"contentControlDate",text:"contentControlText",dataBinding:"contentControlDataBinding"},Gb={checkbox:"contentControlCheckbox"};function Vo(e){return Fb.has(e)}function pf(e,n,t){if(e===Ub){if(t==="contentControlCheckbox"){let r=jb[n];if(r!==void 0)return r}return Gb[n]}if(e===mf&&!(n==="sdt"&&t==="run")){if(t==="contentControlDate"){let r=Hb[n];if(r!==void 0)return r}return Kb[n]}}function Ft(e,n){return e.filter(n).length<=1}function gf(e){let n=0,t=false,r=false,o=false;for(let i of e){if(i.kind==="contentControlProperties"){if(n>0||t)return false;t=true,n=1;continue}if(i.kind==="contentControlEndProperties"){if(n>1||r)return false;r=true,n=2;continue}if(i.kind==="contentControlContent"){if(n>2||o)return false;o=true,n=3;continue}if(i.kind==="textValue"||i.kind!=="generic"&&i.kind!=="bookmarkStart"&&i.kind!=="bookmarkEnd")return false}return true}function xf(e){let n=-1,t=false,r=new Set;for(let o of e){if(o.kind==="textValue")return false;if(o.kind==="runProperties"){if(r.has(0)||t||0<n)return false;r.add(0),n=0;continue}if(o.kind==="contentControlDropDownList"||o.kind==="contentControlComboBox"||o.kind==="contentControlDate"||o.kind==="contentControlText"){if(t)return false;t=true;continue}if(o.kind==="contentControlDataBinding"){let a=ff.get("dataBinding");if(r.has(a)||t||a<n)return false;r.add(a),n=a;continue}if(o.kind==="contentControlCheckbox")continue;if(o.kind!=="generic")return false;if(o.namespaceUri!==mf)continue;let i=ff.get(o.localName);if(i!==void 0){if(r.has(i)||t||i<n)return false;r.add(i),n=i;continue}if(Bb.has(o.localName)){if(t)return false;t=true;continue}}return true}function hf(e){return e.every(n=>n.kind==="runProperties"||n.kind==="generic")&&Ft(e,n=>n.kind==="runProperties")}function yf(e){return e.every(n=>n.kind==="paragraph"||n.kind==="table"||n.kind==="run"||n.kind==="tableRow"||n.kind==="tableCell"||n.kind==="contentControl"||n.kind==="hyperlink"||n.kind==="bookmarkStart"||n.kind==="bookmarkEnd"||n.kind==="commentRangeStart"||n.kind==="commentRangeEnd"||n.kind==="generic")}function Of(e){return e.every(n=>n.kind==="contentControlListItem"||n.kind==="generic")}function Nf(e){return e.every(n=>Vb.has(n.kind))?Ft(e,n=>n.kind==="contentControlDateFormat")&&Ft(e,n=>n.kind==="contentControlLid")&&Ft(e,n=>n.kind==="contentControlStoreMappedDataAs")&&Ft(e,n=>n.kind==="contentControlCalendar"):false}function kf(e){return e.every(n=>Wb.has(n.kind))?Ft(e,n=>n.kind==="contentControlChecked")&&Ft(e,n=>n.kind==="contentControlCheckedState")&&Ft(e,n=>n.kind==="contentControlUncheckedState"):false}function bf(e){return e.length===0}var Sf="http://schemas.openxmlformats.org/wordprocessingml/2006/main",$b="http://schemas.microsoft.com/office/word/2010/wordprocessingShape",fa="http://schemas.openxmlformats.org/drawingml/2006/main",ma="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",ps="http://schemas.openxmlformats.org/drawingml/2006/picture",zb="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Xb="http://schemas.openxmlformats.org/drawingml/2006/picture",Wo=-2147483648,Ho=2147483647,Ur=-27273042329600,Lr=27273042316900,jo=27273042316900,qb=new Set(["drawing","inlineDrawing","anchoredDrawing","drawingExtent","drawingEffectExtent","drawingDocPr","drawingGraphicFramePr","drawingGraphic","drawingGraphicData","drawingSimplePos","drawingPositionH","drawingPositionV","drawingPositionAlign","drawingPositionOffset","drawingWrapNone","drawingWrapSquare","drawingWrapTight","drawingWrapThrough","drawingWrapTopBottom","drawingWrapPolygon","drawingWrapPolygonStart","drawingWrapPolygonLineTo","picture","pictureNvPicPr","pictureBlipFill","pictureBlip","pictureSrcRect","pictureStretch","pictureTile","pictureShapeProperties","pictureTransform","pictureTransformOffset","pictureTransformExtent","picturePresetGeometry"]),Ko=new Set(["character","column","insideMargin","leftMargin","margin","outsideMargin","page","rightMargin"]),Go=new Set(["bottomMargin","insideMargin","line","margin","outsideMargin","page","paragraph","topMargin"]),Yb=new Set(["bothSides","left","right","largest"]),Zb=new Set(["center","inside","left","outside","right"]),Qb=new Set(["bottom","center","inside","outside","top"]),gs=512;function An(e){return qb.has(e)}function Jb(e,n){if(!An(e))return true;if(n===void 0)return false;let t=n.kind;if(t==="generic")return false;switch(e){case "drawing":return n.wmlLocalName==="r";case "inlineDrawing":case "anchoredDrawing":return t==="drawing";case "drawingExtent":case "drawingDocPr":case "drawingGraphicFramePr":case "drawingGraphic":return t==="inlineDrawing"||t==="anchoredDrawing";case "drawingEffectExtent":return t==="inlineDrawing"||t==="anchoredDrawing"||t==="drawingWrapSquare"||t==="drawingWrapTopBottom";case "drawingSimplePos":case "drawingPositionH":case "drawingPositionV":case "drawingWrapNone":case "drawingWrapSquare":case "drawingWrapTight":case "drawingWrapThrough":case "drawingWrapTopBottom":return t==="anchoredDrawing";case "drawingPositionAlign":case "drawingPositionOffset":return t==="drawingPositionH"||t==="drawingPositionV";case "drawingWrapPolygon":return t==="drawingWrapTight"||t==="drawingWrapThrough";case "drawingWrapPolygonStart":case "drawingWrapPolygonLineTo":return t==="drawingWrapPolygon";case "drawingGraphicData":return t==="drawingGraphic";case "picture":return t==="drawingGraphicData"&&n.attributes!==void 0&&xs(n.attributes);case "pictureNvPicPr":case "pictureBlipFill":case "pictureShapeProperties":return t==="picture";case "pictureBlip":case "pictureSrcRect":case "pictureStretch":case "pictureTile":return t==="pictureBlipFill";case "pictureTransform":case "picturePresetGeometry":return t==="pictureShapeProperties";case "pictureTransformOffset":case "pictureTransformExtent":return t==="pictureTransform";default:return false}}function v(e,n){for(let t of e)if(t.localName===n&&t.namespaceUri==="")return t.value}function Pf(e,n){for(let t of e)if(t.localName===n&&t.namespaceUri===zb)return t.value}function Af(e){if(e===void 0||!/^-?\d+$/.test(e))return null;let n=Number(e);return Number.isInteger(n)?n:null}function fs(e,n){let t=v(e,n),r=Af(t);if(r!==null&&!(r<Ur||r>Lr))return t}function Vt(e,n){return fs(e,n)}function ms(e,n){let t=v(e,n);if(t===void 0||!/^\d+$/.test(t))return;let r=Number(t);if(!(!Number.isFinite(r)||r<0||r>4294967295))return t}function eP(e){for(let r of ["distT","distB","distL","distR"])if(v(e,r)!==void 0&&ms(e,r)===void 0)return false;let n=v(e,"simplePos");if(n!==void 0&&n!=="0"&&n!=="1"&&n!=="true"&&n!=="false"||ms(e,"relativeHeight")===void 0)return false;for(let r of ["behindDoc","locked","layoutInCell","allowOverlap"]){let o=v(e,r);if(o===void 0||!["0","1","true","false"].includes(o))return false}let t=v(e,"hidden");return !(t!==void 0&&!["0","1","true","false"].includes(t))}function Wt(e,n){let t=v(e,n);if(t===void 0||!/^\d+$/.test(t))return;let r=Number(t);if(!(!Number.isInteger(r)||r<0||r>jo))return t}function wf(e){let n=e.find(r=>r.kind==="textValue");if(n===void 0||n.kind!=="textValue")return false;let t=Af(n.value);return t===null?false:t>=Wo&&t<=Ho}function Ef(e,n){let t=n.find(o=>o.kind==="textValue");return t===void 0||t.kind!=="textValue"?false:(e==="drawingPositionH"?Zb:Qb).has(t.value.trim())}function xs(e){return v(e,"uri")===Xb}function ee(e,n){let t=0;for(let r of e)r.kind===n&&(t+=1);return t}function nP(e){let n=0;for(let t of e)t.kind==="drawingGraphicData"&&(n+=1),t.kind==="generic"&&t.namespaceUri===fa&&t.localName==="graphicData"&&(n+=1);return n}function tP(e){let n=0;for(let t of e)(t.kind==="inlineDrawing"||t.kind==="anchoredDrawing")&&(n+=1),t.kind==="generic"&&t.namespaceUri===ma&&(t.localName==="inline"||t.localName==="anchor")&&(n+=1);return n}var Mf=new Set(["drawingExtent","drawingEffectExtent","drawingDocPr","drawingGraphicFramePr","drawingGraphic","drawingSimplePos","drawingPositionH","drawingPositionV","drawingWrapNone","drawingWrapSquare","drawingWrapTight","drawingWrapThrough","drawingWrapTopBottom","generic"]),rP=new Set(["drawingSimplePos","drawingPositionH","drawingPositionV","drawingWrapNone","drawingWrapSquare","drawingWrapTight","drawingWrapThrough","drawingWrapTopBottom"]),hs=new Set(["drawingWrapNone","drawingWrapSquare","drawingWrapTight","drawingWrapThrough","drawingWrapTopBottom"]),oP=new Set(["drawingPositionAlign","drawingPositionOffset","generic","textValue"]),iP=new Set(["drawingWrapPolygonStart","drawingWrapPolygonLineTo","generic"]),aP=new Set(["drawingEffectExtent","generic"]),lP=new Set(["drawingEffectExtent","generic"]),sP=new Set(["drawingWrapPolygon","generic"]);function _f(e){return e.kind==="drawingEffectExtent"||e.kind==="generic"&&e.namespaceUri===ma&&e.localName==="effectExtent"}function Df(e){return Vt(e,"l")!==void 0&&Vt(e,"t")!==void 0&&Vt(e,"r")!==void 0&&Vt(e,"b")!==void 0}function ca(e){let n=e.filter(_f);if(n.length>1)return false;for(let t of n)if(t.kind==="textValue"||!Df(t.attributes))return false;return true}function Rf(e){return !e.some(_f)}var dP=new Set(["pictureNvPicPr","pictureBlipFill","pictureShapeProperties","generic"]),cP=new Set(["pictureBlip","pictureSrcRect","pictureStretch","pictureTile","generic"]),uP=new Set(["pictureTransform","picturePresetGeometry","generic"]),fP=new Set(["pictureTransformOffset","pictureTransformExtent","generic"]);function If(e){if(ee(e,"drawingWrapPolygonStart")!==1)return false;let n=0,t=false;for(let o of e)if(o.kind!=="generic"){if(!iP.has(o.kind))return false;if(o.kind==="drawingWrapPolygonStart"){if(t||n>0)return false;n+=1;continue}if(o.kind==="drawingWrapPolygonLineTo"){if(n===0)return false;t=true,n+=1;}}return n<3||n>gs?false:e.find(o=>o.kind==="drawingWrapPolygonStart"||o.kind==="drawingWrapPolygonLineTo")?.kind==="drawingWrapPolygonStart"}function Tf(e){let n=v(e,"wrapText");return n!==void 0&&Yb.has(n)}var mP=["drawingSimplePos","drawingPositionH","drawingPositionV","drawingExtent"],pP="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing";function Cf(e){return e.kind!=="generic"||e.namespaceUri!==pP?null:e.localName==="sizeRelH"?"drawingSizeRelH":e.localName==="sizeRelV"?"drawingSizeRelV":null}function gP(e){if(e.kind==="drawingSimplePos")return "drawingSimplePos";if(e.kind==="drawingPositionH")return "drawingPositionH";if(e.kind==="drawingPositionV")return "drawingPositionV";if(e.kind==="drawingExtent")return "drawingExtent";if(e.kind==="drawingEffectExtent")return "drawingEffectExtent";if(hs.has(e.kind))return "drawingWrap";if(e.kind==="drawingDocPr")return "drawingDocPr";if(e.kind==="drawingGraphicFramePr")return "drawingGraphicFramePr";if(e.kind==="drawingGraphic")return "drawingGraphic";if(e.kind!=="generic"||e.namespaceUri!==ma)return null;switch(e.localName){case "simplePos":return "drawingSimplePos";case "positionH":return "drawingPositionH";case "positionV":return "drawingPositionV";case "extent":return "drawingExtent";case "effectExtent":return "drawingEffectExtent";case "wrapNone":case "wrapSquare":case "wrapTight":case "wrapThrough":case "wrapTopAndBottom":return "drawingWrap";case "docPr":return "drawingDocPr";case "cNvGraphicFramePr":return "drawingGraphicFramePr";case "graphic":return "drawingGraphic";default:return null}}function xP(e){if(ee(e,"drawingExtent")!==1||ee(e,"drawingGraphic")!==1||!ca(e)||ee(e,"drawingDocPr")!==1||ee(e,"drawingGraphicFramePr")>1||ee(e,"drawingSimplePos")!==1||ee(e,"drawingPositionH")!==1||ee(e,"drawingPositionV")!==1)return false;let n=0;for(let i of e){if(!Mf.has(i.kind)&&Cf(i)===null)return false;hs.has(i.kind)&&(n+=1);}if(n!==1)return false;let t=e.find(i=>i.kind==="drawingExtent");if(t===void 0||t.kind!=="drawingExtent"||Wt(t.attributes,"cx")===void 0||Wt(t.attributes,"cy")===void 0)return false;let r=[];for(let i of e){let a=Cf(i)??gP(i);if(a===null)return false;r.push(a==="drawingWrapSquare"||a==="drawingWrapNone"||a==="drawingWrapTight"||a==="drawingWrapThrough"||a==="drawingWrapTopBottom"?"drawingWrap":a);}let o=0;for(let i of mP){if(r[o]!==i)return false;o+=1;}return r[o]==="drawingEffectExtent"&&(o+=1),r[o]!=="drawingWrap"||(o+=1,r[o]!=="drawingDocPr")||(o+=1,r[o]==="drawingGraphicFramePr"&&(o+=1),r[o]!=="drawingGraphic")?false:(o+=1,r[o]==="drawingSizeRelH"&&(o+=1),r[o]==="drawingSizeRelV"&&(o+=1),o===r.length)}function ua(e,n){if(e==="anchoredDrawing")return xP(n);if(ee(n,"drawingExtent")!==1||ee(n,"drawingGraphic")!==1||!ca(n)||ee(n,"drawingDocPr")>1||ee(n,"drawingGraphicFramePr")>1)return false;let t=0;for(let o of n){if(!Mf.has(o.kind)||rP.has(o.kind))return false;hs.has(o.kind)&&(t+=1);}let r=n.find(o=>o.kind==="drawingExtent");return !(r===void 0||r.kind!=="drawingExtent"||Wt(r.attributes,"cx")===void 0||Wt(r.attributes,"cy")===void 0)}function vf(e){let n=ee(e,"drawingPositionAlign"),t=ee(e,"drawingPositionOffset");return n+t!==1?false:e.every(r=>oP.has(r.kind))}function hP(e){return e.kind!=="generic"||e.namespaceUri!==fa?false:e.localName==="hlinkClick"||e.localName==="hlinkHover"||e.localName==="extLst"}function yP(e){return e.kind!=="generic"||e.namespaceUri!==ps||e.localName!=="cNvPr"||ms(e.attributes,"id")===void 0?false:v(e.attributes,"name")!==void 0}function OP(e){if(e.length!==2)return false;let[n,t]=e;return yP(n)?t.kind==="generic"&&t.namespaceUri===ps&&t.localName==="cNvPicPr":false}function NP(e){let n=e.filter(t=>t.kind!=="generic");return n.length!==3?false:n[0].kind==="pictureNvPicPr"&&n[1].kind==="pictureBlipFill"&&n[2].kind==="pictureShapeProperties"}function Uf(e,n){switch(e){case "drawing":return ee(n,"inlineDrawing")+ee(n,"anchoredDrawing")===1&&n.every(t=>t.kind==="inlineDrawing"||t.kind==="anchoredDrawing"||t.kind==="generic");case "inlineDrawing":return ua("inlineDrawing",n);case "anchoredDrawing":return ua("anchoredDrawing",n);case "drawingGraphic":return nP(n)===1;case "pictureBlipFill":return ee(n,"pictureBlip")===1;default:return true}}function Lf(e,n){return An(e)?Uf(e,n):false}function pa(e,n,t,r,o){if(!An(e))return true;if(!Jb(e,o)||!Uf(e,r))return false;if(e==="drawing")return n!=="drawing"?false:ee(r,"inlineDrawing")+ee(r,"anchoredDrawing")===1&&tP(r)===1;if(e==="inlineDrawing")return n==="inline"&&ua("inlineDrawing",r);if(e==="anchoredDrawing")return n==="anchor"&&eP(t)&&ua("anchoredDrawing",r);if(e==="drawingExtent")return n==="extent"&&Wt(t,"cx")!==void 0&&Wt(t,"cy")!==void 0&&r.length===0;if(e==="drawingEffectExtent")return n==="effectExtent"&&Df(t)&&r.length===0;if(e==="drawingGraphicFramePr"){if(n!=="cNvGraphicFramePr")return false;let i=0;for(let a of r){if(a.kind!=="generic"||a.namespaceUri!==fa)return false;if(a.localName==="graphicFrameLocks"){i+=1;continue}if(a.localName!=="extLst")return false}return i<=1}if(e==="drawingDocPr")return r.every(i=>hP(i));if(e==="drawingGraphic")return n==="graphic"&&ee(r,"drawingGraphicData")<=1&&r.every(i=>i.kind==="drawingGraphicData"||i.kind==="generic");if(e==="drawingGraphicData")return n==="graphicData"&&xs(t)&&ee(r,"picture")<=1&&r.every(i=>i.kind==="picture"||i.kind==="generic");if(e==="drawingSimplePos")return n==="simplePos"&&fs(t,"x")!==void 0&&fs(t,"y")!==void 0&&r.length===0;if(e==="drawingPositionH"){let i=v(t,"relativeFrom");if(n!=="positionH"||i===void 0||!Ko.has(i)||!vf(r))return false;let a=r.find(s=>s.kind==="drawingPositionAlign"),l=r.find(s=>s.kind==="drawingPositionOffset");return !(a!==void 0&&!Ef("drawingPositionH",a.children)||l!==void 0&&!wf(l.children))}if(e==="drawingPositionV"){let i=v(t,"relativeFrom");if(n!=="positionV"||i===void 0||!Go.has(i)||!vf(r))return false;let a=r.find(s=>s.kind==="drawingPositionAlign"),l=r.find(s=>s.kind==="drawingPositionOffset");return !(a!==void 0&&!Ef("drawingPositionV",a.children)||l!==void 0&&!wf(l.children))}if(e==="drawingWrapNone")return n==="wrapNone"&&ee(r,"drawingWrapPolygon")===0&&Rf(r);if(e==="drawingWrapSquare")return n==="wrapSquare"&&ee(r,"drawingWrapPolygon")===0&&ca(r)&&r.every(i=>aP.has(i.kind))&&Tf(t);if(e==="drawingWrapTopBottom")return n==="wrapTopAndBottom"&&ee(r,"drawingWrapPolygon")===0&&ca(r)&&r.every(i=>lP.has(i.kind));if(e==="drawingWrapTight"||e==="drawingWrapThrough"){let i=e==="drawingWrapTight"?"wrapTight":"wrapThrough";if(ee(r,"drawingWrapPolygon")!==1||n!==i||!Tf(t)||!Rf(r)||!r.every(s=>sP.has(s.kind)))return false;let l=r.find(s=>s.kind==="drawingWrapPolygon");return l!==void 0&&If(l.children)}if(e==="drawingPositionAlign"||e==="drawingPositionOffset")return n!==(e==="drawingPositionAlign"?"align":"posOffset")?false:r.every(i=>i.kind==="textValue"||i.kind==="generic");if(e==="drawingWrapPolygon")return n==="wrapPolygon"&&If(r);if(e==="drawingWrapPolygonStart"||e==="drawingWrapPolygonLineTo")return n===(e==="drawingWrapPolygonStart"?"start":"lineTo")&&Vt(t,"x")!==void 0&&Vt(t,"y")!==void 0&&r.length===0;if(e==="picture")return n==="pic"&&r.every(i=>dP.has(i.kind))&&ee(r,"pictureNvPicPr")===1&&ee(r,"pictureBlipFill")===1&&ee(r,"pictureShapeProperties")===1&&NP(r);if(e==="pictureNvPicPr")return n==="nvPicPr"&&OP(r);if(e==="pictureBlipFill"){let i=ee(r,"pictureStretch"),a=ee(r,"pictureTile");return n==="blipFill"&&r.every(l=>cP.has(l.kind))&&ee(r,"pictureBlip")===1&&ee(r,"pictureSrcRect")<=1&&i+a<=1}if(e==="pictureBlip"){let i=Pf(t,"embed"),a=Pf(t,"link");return i===void 0&&a===void 0||i!==void 0&&a!==void 0?false:n==="blip"&&r.every(l=>l.kind==="generic")}return e==="pictureSrcRect"?n==="srcRect"&&r.length===0:e==="pictureStretch"||e==="pictureTile"?n===(e==="pictureStretch"?"stretch":"tile")&&r.every(a=>a.kind==="generic"):e==="pictureShapeProperties"?n==="spPr"&&r.every(i=>uP.has(i.kind))&&ee(r,"pictureTransform")<=1&&ee(r,"picturePresetGeometry")<=1:e==="pictureTransform"?n==="xfrm"&&r.every(i=>fP.has(i.kind))&&ee(r,"pictureTransformOffset")<=1&&ee(r,"pictureTransformExtent")<=1:e==="pictureTransformOffset"?n==="off"&&Vt(t,"x")!==void 0&&Vt(t,"y")!==void 0&&r.length===0:e==="pictureTransformExtent"?n==="ext"&&Wt(t,"cx")!==void 0&&Wt(t,"cy")!==void 0&&r.length===0:e==="picturePresetGeometry"?n==="prstGeom"&&r.every(i=>i.kind==="generic"):false}function Bf(e,n,t){if(e===Sf&&n==="drawing")return t?.wmlLocalName==="r"?"drawing":"generic";if(e===ma){if(t?.kind==="drawing"){if(n==="inline")return "inlineDrawing";if(n==="anchor")return "anchoredDrawing"}if(t?.kind==="inlineDrawing"||t?.kind==="anchoredDrawing"){if(n==="extent")return "drawingExtent";if(n==="effectExtent")return "drawingEffectExtent";if(n==="docPr")return "drawingDocPr";if(n==="cNvGraphicFramePr")return "drawingGraphicFramePr";if(n==="simplePos"&&t.kind==="anchoredDrawing")return "drawingSimplePos";if(n==="positionH"&&t.kind==="anchoredDrawing")return "drawingPositionH";if(n==="positionV"&&t.kind==="anchoredDrawing")return "drawingPositionV";if(n==="wrapNone"&&t.kind==="anchoredDrawing")return "drawingWrapNone";if(n==="wrapSquare"&&t.kind==="anchoredDrawing")return "drawingWrapSquare";if(n==="wrapTight"&&t.kind==="anchoredDrawing")return "drawingWrapTight";if(n==="wrapThrough"&&t.kind==="anchoredDrawing")return "drawingWrapThrough";if(n==="wrapTopAndBottom"&&t.kind==="anchoredDrawing")return "drawingWrapTopBottom"}if(t?.kind==="drawingPositionH"||t?.kind==="drawingPositionV"){if(n==="align")return "drawingPositionAlign";if(n==="posOffset")return "drawingPositionOffset"}if((t?.kind==="drawingWrapTight"||t?.kind==="drawingWrapThrough")&&n==="wrapPolygon")return "drawingWrapPolygon";if((t?.kind==="drawingWrapSquare"||t?.kind==="drawingWrapTopBottom")&&n==="effectExtent")return "drawingEffectExtent";if(t?.kind==="drawingWrapPolygon"){if(n==="start")return "drawingWrapPolygonStart";if(n==="lineTo")return "drawingWrapPolygonLineTo"}return null}if(e===fa){if((t?.kind==="inlineDrawing"||t?.kind==="anchoredDrawing")&&n==="graphic")return "drawingGraphic";if(t?.kind==="drawingGraphic"&&n==="graphicData")return "drawingGraphicData";if(t?.kind==="pictureBlipFill"){if(n==="blip")return "pictureBlip";if(n==="srcRect")return "pictureSrcRect";if(n==="stretch")return "pictureStretch";if(n==="tile")return "pictureTile"}if(t?.kind==="pictureTransform"){if(n==="off")return "pictureTransformOffset";if(n==="ext")return "pictureTransformExtent"}if(t?.kind==="pictureShapeProperties"){if(n==="xfrm")return "pictureTransform";if(n==="prstGeom")return "picturePresetGeometry"}return null}if(e===ps){if(t?.kind==="drawingGraphicData"&&n==="pic")return t.attributes!==void 0&&xs(t.attributes)?"picture":"generic";if(t?.kind==="picture"){if(n==="nvPicPr")return "pictureNvPicPr";if(n==="blipFill")return "pictureBlipFill";if(n==="spPr")return "pictureShapeProperties"}return null}return null}function kP(e,n){return e.namespaceUri===Sf&&e.localName==="txbxContent"&&n?.namespaceUri===$b&&n.localName==="txbx"}function ys(e,n){return e.map(t=>{if(t.kind==="textValue"||kP(t,n))return t;let r=An(t.kind)?"generic":t.kind;return {...t,kind:r,children:ys(t.children,t)}})}var O="http://schemas.openxmlformats.org/wordprocessingml/2006/main",X="http://www.w3.org/XML/1998/namespace",He="http://www.w3.org/2000/xmlns/",_e="http://schemas.openxmlformats.org/markup-compatibility/2006",zo="http://www.w3.org/2001/XMLSchema-instance",j="http://schemas.microsoft.com/office/word/2010/wordml",F="http://schemas.openxmlformats.org/drawingml/2006/main",_="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",Ze="http://schemas.openxmlformats.org/drawingml/2006/picture",$n="http://schemas.openxmlformats.org/officeDocument/2006/relationships";var Os=new Set(["ProcessContent","PreserveElements","PreserveAttributes"]),Ye=class extends Error{constructor(t){super(t);this.reason=t;}reason};function ga(e){let n=e.indexOf(":");if(n<0){if(!be(e))throw new Ye("invalid-name");return {localName:e}}if(e.indexOf(":",n+1)>=0)throw new Ye("invalid-name");let t=e.slice(0,n),r=e.slice(n+1);if(!be(t)||!be(r))throw new Ye("invalid-name");return {prefix:t,localName:r}}function Ht(e,n){return `${e}\0${n}`}function $o(e,n){let t=ga(e),r=t.prefix===void 0?n.get("")??"":n.get(t.prefix);if(r===void 0)throw new Ye("undeclared-prefix");return [r,t.localName]}function xa(e,n){let t=e.trim().split(/\s+/).filter(Boolean).map(r=>{if(!be(r))throw new Ye("invalid-name");let o=n.get(r);if(o===void 0)throw new Ye("undeclared-prefix");return o});return [...new Set(t)].sort()}function Ns(e,n,t,r){return e.namespaceUri===_e&&(e.localName==="Ignorable"||e.localName==="MustUnderstand")||t===_e&&r==="Choice"&&e.namespaceUri===""&&e.localName==="Requires"?xa(e.value,n).join(" "):e.namespaceUri===_e&&Os.has(e.localName)?e.value.trim().split(/\s+/).filter(Boolean).map(o=>JSON.stringify($o(o,n))).sort().join(" "):e.namespaceUri===zo&&e.localName==="type"?JSON.stringify($o(e.value.trim(),n)):e.value}function Br(e,n,t,r){for(let o of e)Ns(o,n,t,r);}var bP=new Set(["sectPr","pPrChange"]);function he(e){return e==="revisionInsert"||e==="revisionDelete"||e==="revisionMoveFrom"||e==="revisionMoveTo"}function PP(e){return e==="moveFromRangeStart"||e==="moveFromRangeEnd"||e==="moveToRangeStart"||e==="moveToRangeEnd"||e==="commentRangeStart"||e==="commentRangeEnd"}function Mn(e){return e.kind==="generic"||e.kind==="bookmarkStart"||e.kind==="bookmarkEnd"||e.kind==="hyperlink"||PP(e.kind)||e.kind==="contentControl"}function ha(e,n){if(An(e))return Lf(e,n);switch(e){case "document":return n.every(t=>t.kind==="body"||Mn(t))&&n.filter(t=>t.kind==="body").length===1;case "body":return n.every(t=>t.kind==="paragraph"||t.kind==="table"||Mn(t));case "paragraph":{let t=n.findIndex(r=>r.kind==="paragraphProperties");return n.every(r=>r.kind==="paragraphProperties"||r.kind==="run"||he(r.kind)||r.kind==="fldSimple"||Mn(r))&&(t<0||t===0)&&n.filter(r=>r.kind==="paragraphProperties").length<=1}case "hyperlink":return n.every(t=>t.kind==="run"||t.kind==="drawing"||t.kind==="fldSimple"||he(t.kind)||Mn(t));case "bookmarkStart":case "bookmarkEnd":return n.length===0;case "run":{let t=n.findIndex(r=>r.kind==="runProperties");return n.every(r=>r.kind==="runProperties"||r.kind==="text"||r.kind==="deletedText"||r.kind==="tab"||r.kind==="hardBreak"||r.kind==="bookmarkStart"||r.kind==="bookmarkEnd"||r.kind==="commentReference"||r.kind==="fldChar"||r.kind==="instrText"||r.kind==="noteReference"||r.kind==="noteRef"||r.kind==="separator"||r.kind==="continuationSeparator"||r.kind==="drawing"||r.kind==="generic")&&(t<0||t===0)&&n.filter(r=>r.kind==="runProperties").length<=1}case "revisionInsert":case "revisionDelete":case "revisionMoveFrom":case "revisionMoveTo":return n.every(t=>t.kind==="run"||t.kind==="drawing"||t.kind==="fldSimple"||he(t.kind)||Mn(t));case "moveFromRangeStart":case "moveFromRangeEnd":case "moveToRangeStart":case "moveToRangeEnd":case "commentRangeStart":case "commentRangeEnd":case "commentReference":return n.length===0;case "comments":return n.every(t=>t.kind==="comment"||Mn(t));case "comment":return n.every(t=>t.kind==="paragraph"||t.kind==="table"||Mn(t));case "runProperties":return n.every(t=>t.kind==="generic");case "paragraphProperties":{let t=n.findIndex(r=>r.kind==="runProperties");return n.every(r=>r.kind==="runProperties"||r.kind==="generic")&&n.filter(r=>r.kind==="runProperties").length<=1&&(t<0||n.slice(t+1).every(r=>r.kind==="generic"&&r.namespaceUri===O&&bP.has(r.localName)))}case "text":case "deletedText":return n.every(t=>t.kind==="textValue");case "tab":case "hardBreak":return n.length===0;case "fldChar":return n.every(t=>t.kind==="generic");case "instrText":return n.every(t=>t.kind==="textValue");case "fldSimple":return n.every(t=>t.kind==="run"||he(t.kind)||Mn(t));case "footnotes":case "endnotes":return n.every(t=>t.kind==="note"||t.kind==="generic");case "note":return n.every(t=>t.kind==="paragraph"||t.kind==="table"||Mn(t));case "noteReference":case "noteRef":case "separator":case "continuationSeparator":return n.length===0;case "table":return n.every(t=>t.kind==="tableRow"||t.kind==="tableProperties"||t.kind==="tableGrid"||Mn(t))&&n.filter(t=>t.kind==="tableProperties").length<=1&&n.filter(t=>t.kind==="tableGrid").length<=1;case "tableRow":return n.every(t=>t.kind==="tableCell"||Mn(t));case "tableCell":return n.every(t=>t.kind==="paragraph"||t.kind==="table"||Mn(t));case "tableGrid":case "tableProperties":return n.every(t=>t.kind==="generic");case "contentControl":return gf(n);case "contentControlProperties":return xf(n);case "contentControlEndProperties":return hf(n);case "contentControlContent":return yf(n);case "contentControlDropDownList":case "contentControlComboBox":return Of(n);case "contentControlDate":return Nf(n);case "contentControlCheckbox":return kf(n);case "contentControlListItem":case "contentControlDateFormat":case "contentControlLid":case "contentControlStoreMappedDataAs":case "contentControlCalendar":case "contentControlText":case "contentControlDataBinding":case "contentControlChecked":case "contentControlCheckedState":case "contentControlUncheckedState":return bf(n);default:return false}}function Ff(e){return e===" "||e===" "||e==="\r"||e===`
2
- `}function wP(e){return e.length>0&&(Ff(e[0])||Ff(e[e.length-1]))}function ks(e){let n=e.children.find(t=>t.kind==="textValue");return n?.kind==="textValue"?n.value:""}function bs(e,n){let t=e.filter(r=>!(r.namespaceUri===X&&r.localName==="space"));return wP(n)?[...t,{kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:"preserve"}]:t}function EP(e,n,t=O){if(e.kind!=="textValue"){for(let r of e.children)if(r.kind!=="textValue"&&r.localName===n&&r.namespaceUri===t)return r}}function RP(e,n,t=O){return e.attributes.find(r=>r.localName===n&&r.namespaceUri===t)?.value}function Xo(e,n,t=O){let r=EP(e,n,t);if(!r)return false;let o=RP(r,"val",t);return o===void 0||!(o==="0"||o==="false"||o==="off")}function Es(e){if(!be(e))throw new Error(`invalid local name for OOXML serialization: ${JSON.stringify(e)}`)}function ya(e){if(e===He)throw new Error("the XMLNS namespace cannot name an OOXML element or authored attribute");on(e,"namespace URI");}function Hf(e,n,t){if(e.kind!=="textValue"){e.namespaceUri!==""&&n.add(e.namespaceUri);for(let r of e.attributes)r.namespaceUri!==""&&n.add(r.namespaceUri);for(let r of e.namespaceBindings){r.namespaceUri!==""&&n.add(r.namespaceUri);let o=t.get(r.prefix)??new Set;o.add(r.namespaceUri),t.set(r.prefix,o);}for(let r of e.children)Hf(r,n,t);}}function jf(e,n){return e.namespaceUri===_e&&(e.localName==="Ignorable"||e.localName==="MustUnderstand")||n.namespaceUri===_e&&n.localName==="Choice"&&e.namespaceUri===""&&e.localName==="Requires"}function Kf(e){return e.namespaceUri===_e&&Os.has(e.localName)||e.namespaceUri===zo&&e.localName==="type"}function Gf(e,n,t){if(e.kind==="textValue")return;let r=n;if(e.namespaceBindings.length>0){let o=new Map(n);for(let i of e.namespaceBindings)o.set(i.prefix,i.namespaceUri);r=o;}for(let o of e.attributes)if(o.namespaceUri!==""&&t.add(o.namespaceUri),typeof o.value=="string")try{if(jf(o,e))for(let i of xa(o.value,r))t.add(i);else if(Kf(o))for(let i of o.value.trim().split(/\s+/).filter(Boolean)){let[a]=$o(i,r);a!==""&&t.add(a);}}catch{}for(let o of e.children)Gf(o,r,t);}function Vf(e,n,t){let r=[];for(let[o,i]of n)o!==""&&be(o)&&!t.has(o)&&i.size===1&&i.has(e)&&r.push(o);return r.sort(),r[0]}function IP(e){let n=new Set,t=new Map;Hf(e,n,t),n.delete(""),n.delete(X),n.delete(He);let r=new Map([[X,"xml"]]),o=new Set(["xml","xmlns"]),i=(c,u)=>{let f=u,m=0;for(;o.has(f)||[...t.get(f)??[]].some(g=>g!==c);)m+=1,f=u===""?`ns${m}`:`${u}${m}`;r.set(c,f),o.add(f),n.delete(c);};e.namespaceUri!==""&&e.namespaceBindings.some(c=>c.prefix===""&&c.namespaceUri===e.namespaceUri)&&(r.set(e.namespaceUri,""),o.add(""),n.delete(e.namespaceUri)),n.has(O)&&i(O,"w"),n.has(_e)&&i(_e,"mc"),n.has(zo)&&i(zo,"xsi");let l=0;for(let c of [...n].sort()){let f=Vf(c,t,o);if(f===void 0)do l+=1,f=`ns${l}`;while(o.has(f));i(c,f);}let s=new Set;Gf(e,new Map([["xml",X],["xmlns",He]]),s);let d=new Map;for(let c of [...s].sort()){if(r.get(c)!=="")continue;let u=Vf(c,t,o);if(u===void 0)do l+=1,u=`ns${l}`;while(o.has(u));d.set(c,u),o.add(u);}return {byUri:r,attributeAliases:d}}function Ps(e,n){let t=n.attributeAliases.get(e);if(t!==void 0)return t;let r=n.byUri.get(e);if(r===void 0)throw new Error(`no controlled prefix for namespace ${JSON.stringify(e)}`);if(r==="")throw new Error(`namespace ${JSON.stringify(e)} requires a non-empty controlled prefix`);return r}function Wf(e,n,t,r){if(Es(n),ya(e),e==="")return n;if(r)return `${Ps(e,t)}:${n}`;let o=t.byUri.get(e);if(o===void 0)throw new Error(`no controlled prefix for namespace ${JSON.stringify(e)}`);return o===""?n:`${o}:${n}`}function $f(e){if(e.length===0)return e;let n=e.length>1?new Set:null;for(let t of e){if(Es(t.localName),ya(t.namespaceUri),!n)continue;let r=Ht(t.namespaceUri,t.localName);if(n.has(r))throw new Error(`duplicate expanded attribute {${t.namespaceUri}}${t.localName}`);n.add(r);}return e.length===1?e:[...e].sort((t,r)=>{let o=Ht(t.namespaceUri,t.localName),i=Ht(r.namespaceUri,r.localName);return o<i?-1:o>i?1:0})}function TP(e,n,t,r){let o=e.value;if(typeof o!="string")throw new Error(`attribute {${e.namespaceUri}}${e.localName} value must be a string scalar`);return jf(e,n)?xa(o,t).map(i=>Ps(i,r)).sort().join(" "):Kf(e)?o.trim().split(/\s+/).filter(Boolean).map(i=>{let[a,l]=$o(i,t);return Es(l),ya(a),a===""?l:`${Ps(a,r)}:${l}`}).sort().join(" "):o}function CP(e,n,t){return !!(n.get(e.prefix)===e.namespaceUri||t.byUri.has(e.namespaceUri)||t.attributeAliases.has(e.namespaceUri))}function zf(e,n,t,r,o,i){if(e.kind==="textValue"){i.push(on(e.value,"OOXML text"));return}let a=t,l="";if(e.namespaceBindings.length>0){let m=new Map(t),g=new Set;l=[...e.namespaceBindings].sort((p,x)=>{let y=p.prefix.localeCompare(x.prefix);return y!==0?y:p.namespaceUri.localeCompare(x.namespaceUri)}).map(p=>{if(p.prefix!==""&&!be(p.prefix)||p.prefix==="xmlns"||g.has(p.prefix))throw new Error(`invalid or duplicate namespace prefix ${JSON.stringify(p.prefix)}`);ya(p.namespaceUri),g.add(p.prefix);let x=o!==""&&CP(p,m,n);if(m.set(p.prefix,p.namespaceUri),x)return "";let y=p.prefix===""?"xmlns":`xmlns:${p.prefix}`;return ` ${y}="${on(p.namespaceUri,y)}"`}).join(""),a=m;}let s=e.kind==="text"||e.kind==="deletedText"||e.kind==="instrText"?bs(e.attributes,ks(e)):e.attributes;Br(s,a,e.namespaceUri,e.localName);let d=Xf(s),c=d==="preserve"?true:d==="default"?false:r,u=Wf(e.namespaceUri,e.localName,n,false);i.push(`<${u}${o}${l}`);for(let m of $f(s)){let g=Wf(m.namespaceUri,m.localName,n,true),p=TP(m,e,a,n);i.push(` ${g}="${tf(p,`attribute ${g}`)}"`);}let f=qf(e,c);if(f.length===0){i.push("/>");return}i.push(">");for(let m of f)zf(m,n,a,c,"",i);i.push(`</${u}>`);}function vP(e,n){return n===""?` xmlns="${on(e,"xmlns")}"`:` xmlns:${n}="${on(e,`namespace ${n}`)}"`}function Fr(e){let n=IP(e.root),t=new Map([["xml",X],["xmlns",He]]),r=[];for(let[a,l]of n.byUri)a!==X&&r.push({namespaceUri:a,prefix:l});for(let[a,l]of n.attributeAliases)r.push({namespaceUri:a,prefix:l});let o=r.sort((a,l)=>a.prefix.localeCompare(l.prefix)).map(({namespaceUri:a,prefix:l})=>(t.set(l,a),vP(a,l))).join(""),i=[];return zf(e.root,n,t,false,o,i),i.join("")}function Xf(e){return e.find(n=>n.namespaceUri===X&&n.localName==="space")?.value}function qf(e,n){if(!e.children.some(o=>o.kind==="textValue"))return e.children;let t=e.children.some(o=>o.kind!=="textValue"),r=e.children.some(o=>o.kind==="textValue"&&!/^\s*$/.test(o.value));return e.children.filter(o=>o.kind!=="textValue"||n||e.kind==="text"||e.kind==="instrText"||!t||r||!/^\s*$/.test(o.value))}function Yf(e,n,t){if(e.kind==="textValue")return ["text",e.value];let r=new Map(t);for(let d of e.namespaceBindings)r.set(d.prefix,d.namespaceUri);let o=e.kind==="text"||e.kind==="deletedText"||e.kind==="instrText"?bs(e.attributes,ks(e)):e.attributes,i=Xf(o),a=i==="preserve"?true:i==="default"?false:n,l=$f(o).map(d=>[d.namespaceUri,d.localName,Ns(d,r,e.namespaceUri,e.localName)]),s=qf(e,a).map(d=>Yf(d,a,r));return ["element",e.namespaceUri,e.localName,l,s]}var Zf=new Map([["xml",X],["xmlns",He]]);function Qf(e,n=Zf){return JSON.stringify(Yf("root"in e?e.root:e,false,n))}function ws(e){return Qf(e)}function SP(e,n){return ws(e)===ws(n)}var AP={document:[O,"document"],body:[O,"body"],paragraph:[O,"p"],run:[O,"r"],runProperties:[O,"rPr"],text:[O,"t"],paragraphProperties:[O,"pPr"],tab:[O,"tab"],hardBreak:[O,"br"],fldChar:[O,"fldChar"],instrText:[O,"instrText"],fldSimple:[O,"fldSimple"],footnotes:[O,"footnotes"],endnotes:[O,"endnotes"],note:[O,"footnote"],noteReference:[O,"footnoteReference"],noteRef:[O,"footnoteRef"],separator:[O,"separator"],continuationSeparator:[O,"continuationSeparator"],table:[O,"tbl"],tableRow:[O,"tr"],tableCell:[O,"tc"],tableGrid:[O,"tblGrid"],tableProperties:[O,"tblPr"],hyperlink:[O,"hyperlink"],bookmarkStart:[O,"bookmarkStart"],bookmarkEnd:[O,"bookmarkEnd"],deletedText:[O,"delText"],revisionInsert:[O,"ins"],revisionDelete:[O,"del"],revisionMoveFrom:[O,"moveFrom"],revisionMoveTo:[O,"moveTo"],moveFromRangeStart:[O,"moveFromRangeStart"],moveFromRangeEnd:[O,"moveFromRangeEnd"],moveToRangeStart:[O,"moveToRangeStart"],moveToRangeEnd:[O,"moveToRangeEnd"],commentRangeStart:[O,"commentRangeStart"],commentRangeEnd:[O,"commentRangeEnd"],commentReference:[O,"commentReference"],comments:[O,"comments"],comment:[O,"comment"],contentControl:[O,"sdt"],contentControlProperties:[O,"sdtPr"],contentControlEndProperties:[O,"sdtEndPr"],contentControlContent:[O,"sdtContent"],contentControlDropDownList:[O,"dropDownList"],contentControlComboBox:[O,"comboBox"],contentControlListItem:[O,"listItem"],contentControlDate:[O,"date"],contentControlDateFormat:[O,"dateFormat"],contentControlLid:[O,"lid"],contentControlStoreMappedDataAs:[O,"storeMappedDataAs"],contentControlCalendar:[O,"calendar"],contentControlText:[O,"text"],contentControlDataBinding:[O,"dataBinding"],contentControlCheckbox:[j,"checkbox"],contentControlChecked:[j,"checked"],contentControlCheckedState:[j,"checkedState"],contentControlUncheckedState:[j,"uncheckedState"],drawing:[O,"drawing"],inlineDrawing:[_,"inline"],anchoredDrawing:[_,"anchor"],drawingExtent:[_,"extent"],drawingEffectExtent:[_,"effectExtent"],drawingDocPr:[_,"docPr"],drawingGraphicFramePr:[_,"cNvGraphicFramePr"],drawingGraphic:[F,"graphic"],drawingGraphicData:[F,"graphicData"],drawingSimplePos:[_,"simplePos"],drawingPositionH:[_,"positionH"],drawingPositionV:[_,"positionV"],drawingPositionAlign:[_,"align"],drawingPositionOffset:[_,"posOffset"],drawingWrapNone:[_,"wrapNone"],drawingWrapSquare:[_,"wrapSquare"],drawingWrapTight:[_,"wrapTight"],drawingWrapThrough:[_,"wrapThrough"],drawingWrapTopBottom:[_,"wrapTopAndBottom"],drawingWrapPolygon:[_,"wrapPolygon"],drawingWrapPolygonStart:[_,"start"],drawingWrapPolygonLineTo:[_,"lineTo"],picture:[Ze,"pic"],pictureNvPicPr:[Ze,"nvPicPr"],pictureBlipFill:[Ze,"blipFill"],pictureBlip:[F,"blip"],pictureSrcRect:[F,"srcRect"],pictureStretch:[F,"stretch"],pictureTile:[F,"tile"],pictureShapeProperties:[Ze,"spPr"],pictureTransform:[F,"xfrm"],pictureTransformOffset:[F,"off"],pictureTransformExtent:[F,"ext"],picturePresetGeometry:[F,"prstGeom"]};function MP(e,n){return n.every(t=>t.kind==="wmlVal"?Vo(e):t.kind==="xmlSpace"?t.namespaceUri===X&&t.localName==="space"&&t.prefix==="xml"&&(t.value==="default"||t.value==="preserve"):!(t.namespaceUri===X&&t.localName==="space"||t.namespaceUri===O&&t.localName==="val"))}function qo(e){return Jf(e,null)}function Oa(e,n){return Jf(n,e)}function Jf(e,n){let t=[],r=new Set,o=[],i=()=>{let s="root";for(let d of o)s+=`.children[${d}]`;return s},a=(s,d)=>{t.push({code:s,path:i(),...d===void 0?{}:{nodeId:d}});},l=(s,d,c,u,f)=>{if(u&&c===s)return;if(typeof s.id!="string"||s.id.length===0?a("invalid-id",s.id):r.has(s.id)?a("duplicate-id",s.id):r.add(s.id),s.kind==="textValue"){$(s.value)||a("invalid-xml-value",s.id);return}let m=d;if(s.namespaceBindings.length>0){let h=new Map(d),P=new Set;for(let k of s.namespaceBindings)!P.has(k.prefix)&&(k.prefix===""||be(k.prefix))&&k.prefix!=="xmlns"&&$(k.namespaceUri)&&k.namespaceUri!==He&&!(k.prefix==="xml"&&k.namespaceUri!==X)&&!(k.prefix!=="xml"&&k.namespaceUri===X)&&!(k.prefix!==""&&k.namespaceUri==="")||a("invalid-namespace",s.id),P.add(k.prefix),h.set(k.prefix,k.namespaceUri);m=h;}be(s.localName)||a("invalid-name",s.id),(!$(s.namespaceUri)||s.namespaceUri===He)&&a("invalid-namespace",s.id),(s.prefix===void 0?(m.get("")??"")===s.namespaceUri:be(s.prefix)&&m.get(s.prefix)===s.namespaceUri)||a("invalid-qname",s.id);let p=s.attributes.length>1?new Set:null;for(let h of s.attributes)if(be(h.localName)||a("invalid-name",s.id),(!$(h.namespaceUri)||h.namespaceUri===He)&&a("invalid-namespace",s.id),$(h.value)||a("invalid-xml-value",s.id),(h.prefix===void 0?h.namespaceUri==="":be(h.prefix)&&m.get(h.prefix)===h.namespaceUri)||a("invalid-qname",s.id),p){let k=Ht(h.namespaceUri,h.localName);p.has(k)&&a("duplicate-expanded-attribute",s.id),p.add(k);}try{Br(s.attributes,m,s.namespaceUri,s.localName);}catch{a("invalid-qname",s.id);}if(s.kind!=="generic"){let[h,P]=AP[s.kind],k=s.kind==="note"?s.localName==="footnote"||s.localName==="endnote":s.kind==="noteReference"?s.localName==="footnoteReference"||s.localName==="endnoteReference":s.kind==="noteRef"?s.localName==="footnoteRef"||s.localName==="endnoteRef":s.localName===P;(s.namespaceUri!==h||!k||(An(s.kind)?!pa(s.kind,s.localName,s.attributes,s.children,f):!MP(s.kind,s.attributes)||!ha(s.kind,s.children)))&&a("known-node-invariant",s.id);}let x=u&&c!==void 0&&c.kind!=="textValue"&&c.namespaceBindings===s.namespaceBindings,y=null;if(x){let h=new Map;for(let P of c.children)h.has(P.id)||h.set(P.id,P);y=h;}let b={wmlLocalName:s.namespaceUri===O?s.localName:void 0,kind:s.kind,namespaceUri:s.namespaceUri,localName:s.localName,attributes:s.attributes};for(let h=0;h<s.children.length;h+=1){let P=s.children[h];o.push(h),l(P,m,y?.get(P.id),x,b),o.pop();}};return l(e.root,new Map([["xml",X],["xmlns",He]]),n?.root,n!==null,void 0),t.length===0?{ok:true}:{ok:false,issues:Object.freeze(t)}}var XD=Object.freeze({initial:"deterministic-structural-path-after-normalized-parse",unchanged:"retain-id-through-structural-sharing",replacement:"explicitly-retain-or-allocate",uniqueness:"unique-within-part"}),_P={document:"document",body:"body",p:"paragraph",r:"run",rPr:"runProperties",t:"text",delText:"deletedText",pPr:"paragraphProperties",tab:"tab",br:"hardBreak",fldChar:"fldChar",instrText:"instrText",fldSimple:"fldSimple",footnotes:"footnotes",endnotes:"endnotes",footnote:"note",endnote:"note",footnoteReference:"noteReference",endnoteReference:"noteReference",footnoteRef:"noteRef",endnoteRef:"noteRef",separator:"separator",continuationSeparator:"continuationSeparator",tbl:"table",tr:"tableRow",tc:"tableCell",tblGrid:"tableGrid",tblPr:"tableProperties",hyperlink:"hyperlink",bookmarkStart:"bookmarkStart",bookmarkEnd:"bookmarkEnd",moveFromRangeStart:"moveFromRangeStart",moveFromRangeEnd:"moveFromRangeEnd",moveToRangeStart:"moveToRangeStart",moveToRangeEnd:"moveToRangeEnd",commentRangeStart:"commentRangeStart",commentRangeEnd:"commentRangeEnd",commentReference:"commentReference",comments:"comments",comment:"comment",sdt:"contentControl"},DP=new Set(["r","rPr","pPr","trPr","tcPr","tblPr","tblPrEx","numPr","sectPr","sdtPr","sdtEndPr"]),UP={sdtPr:"contentControlProperties",sdtEndPr:"contentControlEndProperties",sdtContent:"contentControlContent"};function LP(e,n,t){let r=Bf(e,n,t);return r!==null?r:e===O?em(n,t?.wmlLocalName):"generic"}var BP={ins:"revisionInsert",del:"revisionDelete",moveFrom:"revisionMoveFrom",moveTo:"revisionMoveTo"},FP=new Set(["rPr","pPr","trPr","tcPr","tblPr","tblPrEx","numPr","sectPr","rPrChange","pPrChange","trPrChange","tcPrChange","tblPrChange","tblPrExChange","sectPrChange"]);function em(e,n){let t=BP[e];if(t!==void 0)return n!==void 0&&FP.has(n)?"generic":t;let r=UP[e];return r!==void 0?n==="sdt"?r:"generic":e==="sdt"?n!==void 0&&DP.has(n)?"generic":"contentControl":_P[e]??"generic"}function nm(e){if(e.kind==="textValue")return Object.freeze(e);for(let n of e.attributes)Object.freeze(n);for(let n of e.namespaceBindings)Object.freeze(n);for(let n of e.children)nm(n);return Object.freeze(e.attributes),Object.freeze(e.namespaceBindings),Object.freeze(e.children),Object.freeze(e)}function VP(e,n){let t=null,r=[];for(let[o,i]of Object.entries(e.attributes)){if(o!=="xmlns"&&!o.startsWith("xmlns:"))continue;t??=new Map(n);let a=o==="xmlns"?"":o.slice(6);if(a!==""&&!be(a)||a==="xmlns"||a==="xml"&&i!==X||a!=="xml"&&i===X||i===He||a!==""&&i==="")throw new Ye("invalid-namespace");t.set(a,i),r.push({prefix:a,namespaceUri:i});}return {bindings:t??n,authored:r}}function WP(e,n){let t=ga(e);if(t.prefix==="xmlns")throw new Ye("invalid-namespace");if(t.prefix!==void 0){let r=n.get(t.prefix);if(r===void 0)throw new Ye("undeclared-prefix");return {...t,namespaceUri:r}}return {...t,namespaceUri:n.get("")??""}}function HP(e,n){let t=[],r=new Set,o=true,i=false;for(let[a,l]of Object.entries(e.attributes)){if(a==="xmlns"||a.startsWith("xmlns:"))continue;let s=ga(a),d="";if(s.prefix!==void 0){if(d=n.get(s.prefix)??"",!n.has(s.prefix))throw new Ye("undeclared-prefix");if(s.prefix==="xmlns")throw new Ye("invalid-namespace")}let c=Ht(d,s.localName);if(r.has(c))throw new Ye("duplicate-expanded-attribute");r.add(c),d===X&&s.localName==="space"?s.prefix==="xml"&&(l==="default"||l==="preserve")?t.push({kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:l}):(o=false,t.push({kind:"genericExtension",namespaceUri:d,localName:s.localName,...s.prefix===void 0?{}:{prefix:s.prefix},value:l})):d===O&&s.localName==="val"?(i=true,t.push({kind:"wmlVal",namespaceUri:O,localName:"val",...s.prefix===void 0?{}:{prefix:s.prefix},value:l})):t.push({kind:"genericExtension",namespaceUri:d,localName:s.localName,...s.prefix===void 0?{}:{prefix:s.prefix},value:l});}return {attributes:t,compatibleWithKnownNode:o,hasWmlVal:i}}function jP(e,n){let t=e.find(r=>r.namespaceUri===X&&r.localName==="space")?.value;return t==="preserve"?true:t==="default"?false:n}function KP(e,n,t){if(!e.some(l=>l.type==="text"))return e;let r=e.some(l=>l.type==="element"),o=e.some(l=>l.type==="text"&&!/^\s*$/.test(l.value)),i=e.filter(l=>l.type==="element"||n||t||!r||o||!/^\s*$/.test(l.value)),a=[];for(let l of i){let s=a[a.length-1];l.type==="text"&&s?.type==="text"?a[a.length-1]={type:"text",value:s.value+l.value}:a.push(l);}return a}function tm(e,n,t,r,o,i,a=void 0,l){let s=VP(e,n),d=WP(e.name,s.bindings),c=HP(e,s.bindings),u=c.attributes;Br(u,s.bindings,d.namespaceUri,d.localName);let f=jP(u,o),m=d.namespaceUri===O,p=d.namespaceUri===O&&(d.localName==="sdtPr"||d.localName==="sdtEndPr"||d.localName==="sdtContent")&&a!=="contentControl"?void 0:pf(d.namespaceUri,d.localName,a),x=p!==void 0?p:m?em(d.localName,i):"generic",y=LP(d.namespaceUri,d.localName,l),N=y!=="generic"&&An(y)?y:x,b=KP(e.children,f,N==="text"||N==="deletedText"||N==="instrText"),h={wmlLocalName:m?d.localName:void 0,kind:N,namespaceUri:d.namespaceUri,localName:d.localName,attributes:u},P=b.map((A,U)=>{let B=`${r}.${U}`;return A.type==="text"?{id:`${t}#${B}`,kind:"textValue",value:A.value}:tm(A,s.bindings,t,B,f,h.wmlLocalName,h.kind==="generic"?void 0:h.kind,h)}),k=c.compatibleWithKnownNode&&(!c.hasWmlVal||N!=="generic"&&Vo(N)),E=N!=="generic"&&An(N)?pa(N,d.localName,u,P,l):N!=="generic"&&ha(N,P)&&GP(N,d.localName,u)&&(N!=="fldChar"||u.some(A=>A.localName!=="fldCharType"||A.namespaceUri!==O&&A.namespaceUri!==""?false:A.value==="begin"||A.value==="separate"||A.value==="end")),w=N!=="generic"&&k&&E?N:"generic",I=w==="generic"&&An(N)?ys(P,d):P;return {id:`${t}#${r}`,kind:w,namespaceUri:d.namespaceUri,localName:d.localName,...d.prefix===void 0?{}:{prefix:d.prefix},namespaceBindings:s.authored,attributes:u,children:I}}function GP(e,n,t){if(e!=="note"&&e!=="noteReference"&&e!=="noteRef"&&e!=="separator"&&e!=="continuationSeparator"&&e!=="footnotes"&&e!=="endnotes")return true;let r=o=>{for(let i of t)if(i.localName===o&&(i.namespaceUri===O||i.namespaceUri===""))return i.value};if(e==="note"){if(n!=="footnote"&&n!=="endnote")return false;let o=r("id");if(o===void 0||!/^-?\d{1,10}$/.test(o))return false;let i=Number(o);if(!Number.isInteger(i)||i<-2147483648||i>2147483647)return false;let a=r("type");return !(a!==void 0&&a!=="normal"&&a!=="separator"&&a!=="continuationSeparator"&&a!=="continuationNotice")}if(e==="noteReference"){if(n!=="footnoteReference"&&n!=="endnoteReference")return false;let o=r("id");if(o===void 0||!/^-?\d{1,10}$/.test(o))return false;let i=Number(o);return Number.isInteger(i)&&i>=-2147483648&&i<=2147483647}return e==="noteRef"?n==="footnoteRef"||n==="endnoteRef":e==="separator"?n==="separator":e==="continuationSeparator"?n==="continuationSeparator":e==="footnotes"?n==="footnotes":e==="endnotes"?n==="endnotes":true}function ne(e,n,t){let r=tt(e,t);if(!r.ok)return r;let o=r.nodes.filter(i=>i.type==="element");if(o.length===0)return {ok:false,reason:"missing-root"};if(o.length!==1)return {ok:false,reason:"multiple-roots"};try{let i=nm(tm(o[0],new Map([["xml",X],["xmlns",He]]),n.name,"0",!1));return {ok:!0,part:Object.freeze({id:`part:${n.name}`,name:n.name,contentType:n.contentType,root:i})}}catch(i){return {ok:false,reason:i instanceof Ye?i.reason:"parse-error"}}}var Yo=new WeakMap;function Vr(e){let n=Yo.get(e);if(n)return n;let t=new Map,r=new Map,o=(a,l)=>{if(t.has(a.id)||(t.set(a.id,a),l!==null&&r.set(a.id,l)),a.kind!=="textValue")for(let s of a.children)o(s,a.id);};o(e,null);let i={nodes:t,parents:r,mintFrontier:0};return Yo.set(e,i),i}function eU(e){return new Set(Vr(e.root).nodes.keys())}function S(e){let n=Vr(e.root),t=new Set,r=n.mintFrontier;return ()=>{let o=`${e.name}#new:${r}`;for(;n.nodes.has(o)||t.has(o);)r+=1,o=`${e.name}#new:${r}`;return t.add(o),r+=1,n.mintFrontier=r,o}}function XP(e,n){let t=Vr(e),r=t.nodes.get(n);if(!r)return null;let o=[r],i=r;for(;i&&i!==e;){let a=t.parents.get(i.id);i=a===void 0?void 0:t.nodes.get(a),i&&o.push(i);}return i!==e?null:(o.reverse(),o)}function om(e,n){return Vr(e.root).nodes.has(n)}function R(e,n){return Vr(e.root).nodes.get(n)??null}function Ce(e,n){let t=Vr(e.root);if(!t.nodes.has(n))return null;let r=t.parents.get(n),o=r===void 0?void 0:t.nodes.get(r);return o&&o.kind!=="textValue"?o:null}function Ts(e,n){return Object.freeze({...e,children:n})}function rm(e,n){let t=Yo.get(e);t&&(Yo.delete(e),im(t,e,n,null),Yo.set(n,t));}function Rs(e,n){if(e.nodes.get(n.id)===n&&(e.nodes.delete(n.id),e.parents.delete(n.id)),n.kind!=="textValue")for(let t of n.children)Rs(e,t);}function Is(e,n,t){if(e.nodes.set(n.id,n),e.parents.set(n.id,t),n.kind!=="textValue")for(let r of n.children)Is(e,r,n.id);}function im(e,n,t,r){if(n===t){r!==null&&e.parents.get(t.id)!==r&&e.parents.set(t.id,r);return}if(n.id!==t.id){Rs(e,n),r!==null&&Is(e,t,r);return}e.nodes.set(t.id,t),r!==null&&e.parents.get(t.id)!==r&&e.parents.set(t.id,r);let o=n.kind==="textValue"?[]:n.children,i=t.kind==="textValue"?[]:t.children,a=Math.min(o.length,i.length),l=0;for(;l<a&&o[l]===i[l];)l+=1;let s=o.length,d=i.length;for(;s>l&&d>l&&o[s-1]===i[d-1];)s-=1,d-=1;let c=new Map;for(let f=l;f<s;f+=1){let m=o[f];c.has(m.id)||c.set(m.id,m);}let u=new Set;for(let f=l;f<d;f+=1)u.add(i[f].id);for(let[f,m]of c)u.has(f)||Rs(e,m);for(let f=l;f<d;f+=1){let m=i[f],g=c.get(m.id);g?im(e,g,m,t.id):Is(e,m,t.id);}}function Na(e,n,t){let r=XP(e.root,n);if(!r)return null;if(r.length===1)return !t||t.kind==="textValue"?null:(rm(e.root,t),Object.freeze({...e,root:t}));let o=t;for(let i=r.length-2;i>=0;i-=1){let a=r[i],l=r[i+1].id,s=[];for(let d of a.children){if(d.id!==l){s.push(d);continue}o&&s.push(o);}o=Ts(a,s);}return rm(e.root,o),Object.freeze({...e,root:o})}function Zo(e,n){if(!e)return {ok:false,issues:[{code:"known-node-invariant",path:"(edit target)"}]};if(n?.deferValidation)return {ok:true,part:e};let t=qo(e);return t.ok?{ok:true,part:e}:{ok:false,issues:t.issues}}function L(e,n,t,r){let o=R(e,n);return !o||o.kind==="textValue"?{ok:false,issues:[{code:"known-node-invariant",path:n,nodeId:n}]}:Zo(Na(e,n,Ts(o,t)),r)}function M(e,n,t,r,o){let i=R(e,n);if(!i||i.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:n,nodeId:n}]};let a=Math.max(0,Math.min(t,i.children.length)),l=[...i.children.slice(0,a),...r,...i.children.slice(a)];return Zo(Na(e,n,Ts(i,l)),o)}function V(e,n,t,r){return om(e,n)?Zo(Na(e,n,t),r):{ok:false,issues:[{code:"known-node-invariant",path:n,nodeId:n}]}}function oe(e,n,t){return om(e,n)?Zo(Na(e,n,null),t):{ok:false,issues:[{code:"known-node-invariant",path:n,nodeId:n}]}}function Ot(e,n,t){let r=e;for(let o of n){let i=o(r);if(!i.ok)return i;r=i.part;}return Zo(r,t)}var Cs={maxEntries:1e4,maxTotalBytes:512*1024*1024,maxRatio:200},jt=class extends Error{constructor(t){super(t);this.reason=t;}reason};function sm(e,n=Cs){let t=n.maxRatio??200,r=0,o=0,i,a=new Set,l;try{l=unzipSync(e,{filter:d=>{if(d.name.endsWith("/"))return !1;if(r+=1,r>n.maxEntries)throw new jt("too-many-entries");let c=xe(d.name);if(!c.ok)throw i=`${d.name}: ${c.reason}`,new jt("bad-name");let u=G(c.partName);if(a.has(u))throw i=`${d.name}: OPC-equivalent duplicate of ${c.partName}`,new jt("bad-name");if(a.add(u),d.originalSize/Math.max(1,d.size)>t)throw new jt("too-large");if(o+=d.originalSize,o>n.maxTotalBytes)throw new jt("too-large");return !0}});}catch(d){return d instanceof jt?{ok:false,reason:d.reason,detail:i}:{ok:false,reason:"inflate-error"}}let s=new Map;for(let[d,c]of Object.entries(l)){let u=xe(d);u.ok&&s.set(u.partName,c);}return {ok:true,entries:s}}var ZP=new Date(Date.UTC(1980,0,2,12));function dm(e){let n=Object.create(null),t=new Set;for(let[r,o]of e){let i=xe(r);if(!i.ok)throw new Error(`unsafe part name on write: ${r} (${i.reason})`);let a=G(i.partName);if(t.has(a))throw new Error(`OPC-equivalent duplicate part name on write: ${i.partName}`);t.add(a),n[i.partName.replace(/^\//,"")]=o;}return zipSync(n,{mtime:ZP})}var QP="http://schemas.openxmlformats.org/officeDocument/2006/relationships",an="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";function vs(e,n,t){if(e.kind!=="textValue"){for(let r of e.attributes)if(r.namespaceUri===n&&r.localName===t)return r.value}}function cm(e){return e.kind==="hyperlink"}function JP(e){return vs(e,O,"anchor")}function Ss(e){return vs(e,QP,"id")}function lU(e,n){let t=vs(e,O,"tooltip"),r=Ss(e),o=JP(e);if(r!==void 0&&r!==""){let i=n(r);if(i&&i.external){let a=yt(i.target),l=a.ok&&i.sinkSafe===true;return {kind:"external",authored:i.target,href:l?a.href:null,...o!==void 0?{anchor:o}:{},...t!==void 0?{tooltip:t}:{},relationshipId:r}}return {kind:"unresolved",authored:i?.target??"",href:null,...o!==void 0?{anchor:o}:{},...t!==void 0?{tooltip:t}:{},relationshipId:r}}return o!==void 0&&o!==""?{kind:"internal",authored:o,href:ew(o),anchor:o,...t!==void 0?{tooltip:t}:{}}:{kind:"unresolved",authored:"",href:null,...t!==void 0?{tooltip:t}:{}}}function ew(e){let n=yt(e);return !n.ok||n.href.length===0?null:`#${n.href}`}function As(){return {compatibilityBranches:0,visited:0,depth:0,refused:false,compatibilityBranchNodeId:null,diagnostics:[]}}function ie(e){return e.kind!=="textValue"}function Qo(e){return e.kind==="generic"&&e.namespaceUri===_e&&e.localName==="AlternateContent"}function um(e){return e.kind==="generic"&&e.namespaceUri===_e&&e.localName==="Choice"}function fm(e){return e.kind==="generic"&&e.namespaceUri===_e&&e.localName==="Fallback"}function _n(e,n){if(n.namespaceBindings.length===0)return e;let t=new Map(e);for(let r of n.namespaceBindings)t.set(r.prefix,r.namespaceUri);return t}var nw=new Map;function Wr(){return nw}function ae(e,n){for(let t of e)if(ie(t)&&t.kind===n)return t;return null}var Hr="http://schemas.microsoft.com/office/word/2010/wordprocessingShape",tw="http://schemas.microsoft.com/office/word/2010/wordprocessingShape",rw=/^[0-9A-Fa-f]{6}$/,ow=64,iw=1024,mm=2**31-1;function de(e,n=true){if(e===void 0||!/^-?\d{1,15}$/.test(e))return null;let t=Number(e);return Number.isFinite(t)?n?t<0?0:t>mm?mm:t:t:null}function re(e,n){for(let t of e)if(ie(t)&&(n.typedKind!==void 0&&t.kind===n.typedKind||n.namespaceUri!==void 0&&n.localName!==void 0&&t.kind==="generic"&&t.namespaceUri===n.namespaceUri&&t.localName===n.localName))return t;return null}function ka(e){let n=re(e.children,{namespaceUri:F,localName:"solidFill"});if(!n)return null;let t=re(n.children,{namespaceUri:F,localName:"srgbClr"});if(!t)return null;let r=v(t.attributes,"val");return r!==void 0&&rw.test(r)?r:null}function aw(e,n,t,r,o){let i=null;for(let a of e.children){if(!ie(a))continue;if(a.namespaceUri!==F)return false;if(a.localName==="close"){i=null;continue}if(a.localName!=="moveTo"&&a.localName!=="lnTo")return false;let l=re(a.children,{namespaceUri:F,localName:"pt"});if(!l)return false;let s=de(v(l.attributes,"x"),false),d=de(v(l.attributes,"y"),false);if(s===null||d===null)return false;let c={x:s*n,y:d*t};if(!Number.isFinite(c.x)||!Number.isFinite(c.y)||o.remaining<=0)return false;if(o.remaining-=1,a.localName==="moveTo"||i===null){if(r.length>=ow)return false;i=[c],r.push(i);}else i.push(c);}return true}function xm(e){let n=ae(e.children,"drawingGraphic")??re(e.children,{namespaceUri:F,localName:"graphic"});if(!n)return null;let t=ae(n.children,"drawingGraphicData")??re(n.children,{namespaceUri:F,localName:"graphicData"});return !t||v(t.attributes,"uri")!==tw?null:re(t.children,{namespaceUri:Hr,localName:"wsp"})??null}function hm(e,n,t){if(n.cx<=0||n.cy<=0)return null;let r=xm(e);if(!r||re(r.children,{namespaceUri:Hr,localName:"txbx"}))return null;let o=re(r.children,{namespaceUri:Hr,localName:"spPr"});if(!o)return null;let i=re(o.children,{namespaceUri:F,localName:"xfrm"});if(i){let m=v(i.attributes,"rot");if(m!==void 0&&m!=="0"||v(i.attributes,"flipH")==="1"||v(i.attributes,"flipV")==="1")return null}let a=ka(o),l=re(o.children,{namespaceUri:F,localName:"ln"}),s=l?ka(l):null,d=s!==null?de(v(l.attributes,"w"))??12700:0;if(a===null&&s===null)return null;let c=[],u=re(o.children,{namespaceUri:F,localName:"custGeom"});if(u){let m=re(u.children,{namespaceUri:F,localName:"pathLst"});if(!m)return null;let g={remaining:iw};for(let p of m.children){if(!ie(p))continue;if(p.namespaceUri!==F||p.localName!=="path")return null;let x=de(v(p.attributes,"w"))??n.cx,y=de(v(p.attributes,"h"))??n.cy;if(x<=0||y<=0||!aw(p,n.cx/x,n.cy/y,c,g))return null}}else {let m=re(o.children,{namespaceUri:F,localName:"prstGeom"});if(!m||v(m.attributes,"prst")!=="rect")return null;c.push([{x:0,y:0},{x:n.cx,y:0},{x:n.cx,y:n.cy},{x:0,y:n.cy}]);}let f=c.filter(m=>m.length>=3);return f.length===0?null:{extentEmu:{cx:n.cx,cy:n.cy},subpathsEmu:f,fillHex:a,strokeHex:s,strokeWidthEmu:d}}var pm=91440,gm=45720;function ym(e,n){if(n.cx<=0||n.cy<=0)return null;let t=xm(e);if(!t)return null;let r=re(t.children,{namespaceUri:Hr,localName:"txbx"});if(!r)return null;let o=re(r.children,{namespaceUri:O,localName:"txbxContent"});if(!o)return null;let i=re(t.children,{namespaceUri:Hr,localName:"bodyPr"}),a=(p,x)=>{let y=i?v(i.attributes,p):void 0;if(y===void 0)return x;let N=de(y,false);return N===null||N<0?x:N},l=i?v(i.attributes,"anchor"):void 0,s=l==="ctr"?"center":l==="b"?"bottom":"top",d="none";i&&(re(i.children,{namespaceUri:F,localName:"spAutoFit"})?d="shape":re(i.children,{namespaceUri:F,localName:"normAutofit"})&&(d="normal"));let c=re(t.children,{namespaceUri:Hr,localName:"spPr"}),u=c?ka(c):null,f=c?re(c.children,{namespaceUri:F,localName:"ln"}):null,m=f?ka(f):null,g=m!==null?de(v(f.attributes,"w"))??12700:0;return {contentNodeId:o.id,content:o,insetsEmu:{top:a("tIns",gm),right:a("rIns",pm),bottom:a("bIns",gm),left:a("lIns",pm)},verticalAnchor:s,autofit:d,fillHex:u,strokeHex:m,strokeWidthEmu:g}}var Cm=["inline","square","squareLeft","squareRight","tight","through","topAndBottom","behind","inFront"],Kt=Object.freeze({maxCompatibilityBranches:64,maxVisitedElements:4096,maxDrawingDepth:64}),rt=new Set([j,"http://schemas.microsoft.com/office/word/2012/wordml","http://schemas.microsoft.com/office/word/2015/wordml","http://schemas.microsoft.com/office/word/2016/wordml",_,F,Ze,$n,O,_e,"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"]),lw="http://schemas.openxmlformats.org/drawingml/2006/picture",sw=1e6,Pa=Object.freeze({top:0,right:0,bottom:0,left:0}),dw=Object.freeze({left:0,top:0,right:0,bottom:0}),cw=Object.freeze({select:false,move:false,resize:false,changeAspect:false}),jr=Object.freeze({grayscale:false,brightness:0,contrast:0});function Ds(e,n){return t=>{for(let r of e.externalTargets)if(!(r.ownerPart!==n||r.id!==t))return r.type!==an?null:{target:r.rawTarget,external:true,sinkSafe:r.sinkSafe};for(let r of e.relationships.get(n)??[]){if(r.id!==t)continue;let o=Me(r);return o.mode==="External"?r.type!==an?null:{target:r.rawTarget,external:true,sinkSafe:o.sinkSafe.ok}:{target:r.rawTarget,external:false}}return null}}function uw(e,n){if(n===void 0)return null;let t=n(e);if(t===null||!t.external)return null;let r=yt(t.target);return !r.ok||t.sinkSafe!==true?null:r.href}function fw(e){for(let n of e.children)if(ie(n)&&n.kind==="generic"&&n.namespaceUri===F&&n.localName==="hlinkClick")return n;return null}function _s(e,n){for(let t of e)if(t.localName===n&&t.namespaceUri===$n)return t.value}function mw(e,n){for(let t of e)if(t.localName===n&&t.namespaceUri===_e)return t.value}function pw(e){if(e===void 0||!/^-?\d+$/.test(e))return null;let n=Number(e);return !Number.isInteger(n)||n<Wo||n>Ho?null:n}function Om(e){if(e===void 0||!/^-?\d+$/.test(e))return null;let n=Number(e);return !Number.isInteger(n)||n<Ur||n>Lr?null:n}function ba(e){let n=de(e,false);return n===null||n<=0?0:Math.min(n/1e5,1)}function gw(e){if(e===void 0||!/^\d{1,10}$/.test(e))return null;let n=Number(e);return Number.isFinite(n)?n:null}function Nm(e){for(let n of e.children)if(n.kind==="textValue")return n.value;return null}function xw(e,n,t){let r=mw(e.attributes,"Requires")??v(e.attributes,"Requires");if(r===void 0||r.trim().length===0)return false;let o=r.trim().split(/\s+/).filter(i=>i.length>0);return o.length===0?false:o.every(i=>{let a=n.get(i);return a===void 0||a.length===0?false:t.has(a)})}function km(e){for(let n of e.children)if(ie(n))return n;return null}function hw(e){return e===null||!ie(e)?null:e.kind==="drawing"||e.kind==="generic"&&e.namespaceUri===O&&e.localName==="drawing"?e:"non-picture"}function yw(e){return e.kind==="generic"&&e.namespaceUri===O&&e.localName==="drawing"}function bm(e){return e.kind==="inlineDrawing"||e.kind==="anchoredDrawing"||e.kind==="generic"&&e.namespaceUri===_&&(e.localName==="inline"||e.localName==="anchor")}function Us(e,n,t,r,o){let i=_n(r,e);if(n.compatibilityBranches+=1,n.compatibilityBranches>t.maxCompatibilityBranches)return n.refused=true,{branch:null,branchNodeId:null};let a=null,l=null;for(let s of e.children)if(ie(s)){if(um(s)){if(n.compatibilityBranches+=1,n.compatibilityBranches>t.maxCompatibilityBranches)return n.refused=true,{branch:null,branchNodeId:null};let d=s,c=_n(i,d);if(xw(d,c,o)){let u=km(d);return n.compatibilityBranchNodeId=d.id,{branch:u,branchNodeId:d.id}}continue}if(fm(s)){let d=s;a=km(d),l=d.id;}}return a!==null&&(n.compatibilityBranchNodeId=l),{branch:a,branchNodeId:l}}function Ow(e,n,t,r,o){for(let i of e.children){if(!Ls(n,t))return {anchor:null};if(bm(i))return {anchor:i};if(Qo(i)){let a=_n(r,i),l=Us(i,n,t,a,o);if(l.branch===null||!ie(l.branch))continue;if(bm(l.branch))return {anchor:l.branch}}}return {anchor:null}}function Ls(e,n){return e.visited+=1,e.visited>n.maxVisitedElements?(e.refused=true,false):true}function Pm(e){return e.kind==="picture"||e.kind==="generic"&&e.namespaceUri===Ze&&e.localName==="pic"}function Nw(e,n,t,r,o,i){for(let a of e.children){if(!Ls(n,t))return null;if(Qo(a)){let l=_n(r,a),s=Us(a,n,t,l,o);if(s.branch&&ie(s.branch)&&Pm(s.branch))return s.branch;continue}if(ie(a)&&(a.kind==="picture"||i&&Pm(a)))return a}return null}function kw(e){let n=ae(e.children,"pictureBlipFill");if(n){let t=ae(n.children,"pictureBlip");if(t)return t}for(let t of e.children)if(ie(t)&&t.kind==="generic"&&t.namespaceUri===Ze&&t.localName==="blipFill"){for(let r of t.children)if(ie(r)&&(r.kind==="pictureBlip"||r.kind==="generic"&&r.namespaceUri===F&&r.localName==="blip"))return r}return null}function bw(e){let n=ae(e.children,"pictureBlipFill");if(n){let t=ae(n.children,"pictureSrcRect");if(t)return t;for(let r of n.children)if(ie(r)&&r.kind==="generic"&&r.namespaceUri===F&&r.localName==="srcRect")return r}for(let t of e.children)if(ie(t)&&t.kind==="generic"&&t.namespaceUri===Ze&&t.localName==="blipFill"){for(let r of t.children)if(ie(r)&&r.kind==="generic"&&r.namespaceUri===F&&r.localName==="srcRect")return r}return null}function Pw(e){let n=ae(e.children,"pictureBlipFill");if(n&&ae(n.children,"pictureTile")!==null)return true;for(let t of e.children)if(ie(t)&&t.kind==="generic"&&t.namespaceUri===Ze&&t.localName==="blipFill"){for(let r of t.children)if(ie(r)&&(r.kind==="pictureTile"||r.kind==="generic"&&r.namespaceUri===F&&r.localName==="tile"))return true}return false}function ww(e,n){for(let t of e.children)if(ie(t)){if(t.kind==="drawingWrapNone"||t.kind==="drawingWrapSquare"||t.kind==="drawingWrapTight"||t.kind==="drawingWrapThrough"||t.kind==="drawingWrapTopBottom")return t;if(n&&t.kind==="generic"&&t.namespaceUri===_&&(t.localName==="wrapNone"||t.localName==="wrapSquare"||t.localName==="wrapTight"||t.localName==="wrapThrough"||t.localName==="wrapTopAndBottom"))return t}return null}function vm(e){return Object.freeze({top:de(v(e.attributes,"distT"))??0,right:de(v(e.attributes,"distR"))??0,bottom:de(v(e.attributes,"distB"))??0,left:de(v(e.attributes,"distL"))??0})}function wm(e,n){if(!e)return null;let t=ae(e.children,"drawingEffectExtent")??(n?re(e.children,{namespaceUri:_,localName:"effectExtent"}):null);return t?Object.freeze({left:de(v(t.attributes,"l"),false)??0,top:de(v(t.attributes,"t"),false)??0,right:de(v(t.attributes,"r"),false)??0,bottom:de(v(t.attributes,"b"),false)??0}):null}function Ew(e,n,t){let r=Bs(n);if(r==="square"||r==="topAndBottom"){let i=wm(n,t);if(i)return i}let o=wm(e,t);return o||Pa}function Em(e,n){let t=ae(e.children,"drawingExtent")??(n?re(e.children,{namespaceUri:_,localName:"extent"}):null);if(!t)return null;let r=de(v(t.attributes,"cx")),o=de(v(t.attributes,"cy"));return r===null||o===null?null:Object.freeze({cx:r,cy:o})}function Rm(e,n){if(!e)return Object.freeze({relativeFrom:n,align:null,offsetEmu:null});let r=v(e.attributes,"relativeFrom")??n,o=ae(e.children,"drawingPositionAlign")??re(e.children,{namespaceUri:_,localName:"align"});if(o){let a=Nm(o)?.trim()??null;return Object.freeze({relativeFrom:r,align:a,offsetEmu:null})}let i=ae(e.children,"drawingPositionOffset")??re(e.children,{namespaceUri:_,localName:"posOffset"});if(i){let a=Nm(i),l=a!==null?pw(a):null;return Object.freeze({relativeFrom:r,align:null,offsetEmu:l})}return Object.freeze({relativeFrom:r,align:null,offsetEmu:null})}function Rw(e,n){let t=ae(e.children,"drawingSimplePos")??re(e.children,{namespaceUri:_,localName:"simplePos"}),r=Object.freeze({xEmu:t?Om(v(t.attributes,"x"))??0:0,yEmu:t?Om(v(t.attributes,"y"))??0:0}),o=ae(e.children,"drawingPositionH")??re(e.children,{namespaceUri:_,localName:"positionH"}),i=ae(e.children,"drawingPositionV")??re(e.children,{namespaceUri:_,localName:"positionV"}),a=Rm(o,"column"),l=Rm(i,"paragraph");return !n&&!o&&!i&&!t?null:Object.freeze({simplePosition:r,horizontal:a,vertical:l})}function Im(e){if(e===void 0||!/^-?\d+$/.test(e))return null;let n=Number(e);return !Number.isInteger(n)||n<Ur||n>Lr?null:n}function Iw(e,n,t){let r=ae(e.children,"drawingWrapPolygon");if(!r)return Object.freeze([]);let o=0;for(let l of r.children)ie(l)&&(l.kind!=="drawingWrapPolygonStart"&&l.kind!=="drawingWrapPolygonLineTo"||(o+=1));if(o>gs)return n.diagnostics.push({code:"wrap-polygon-over-limit",nodeId:t,detail:String(o)}),Object.freeze([]);let i=[],a=false;for(let l of r.children){if(!ie(l)||l.kind!=="drawingWrapPolygonStart"&&l.kind!=="drawingWrapPolygonLineTo")continue;let s=Im(v(l.attributes,"x")),d=Im(v(l.attributes,"y"));if(s===null||d===null){a=true;continue}i.push(Object.freeze({x:s,y:d}));}return a||i.length<3?(n.diagnostics.push({code:"wrap-polygon-malformed",nodeId:t,detail:a?"invalid-coordinate":"insufficient-points"}),Object.freeze([])):Object.freeze(i)}function Bs(e){switch(e?.kind){case "drawingWrapSquare":return "square";case "drawingWrapTight":return "tight";case "drawingWrapThrough":return "through";case "drawingWrapTopBottom":return "topAndBottom";}if(e&&e.kind==="generic"&&e.namespaceUri===_)switch(e.localName){case "wrapSquare":return "square";case "wrapTight":return "tight";case "wrapThrough":return "through";case "wrapTopAndBottom":return "topAndBottom";}return "none"}function Tw(e,n,t){if(e==="inline")return "inline";let r=Bs(n);if(r==="none")return t?"behind":"inFront";if(r==="square"){let o=v(n.attributes,"wrapText")??"bothSides";return o==="left"?"squareLeft":o==="right"?"squareRight":"square"}return r==="tight"?"tight":r==="through"?"through":"topAndBottom"}function Cw(e,n,t){if(!e)return null;let r=Bs(e),o=v(e.attributes,"wrapText")??"bothSides";return Object.freeze({element:r,textSide:o==="left"||o==="right"||o==="largest"?o:"bothSides",distancesEmu:vm(e),polygon:r==="tight"||r==="through"?Iw(e,n,t):Object.freeze([])})}function vw(e){if(!e)return {};let n=e.children.find(o=>ie(o)&&o.kind==="generic"&&o.namespaceUri===F&&o.localName==="graphicFrameLocks");if(!n||!ie(n))return {};let t=n.attributes,r=o=>{let i=v(t,o);if(i!==void 0)return i==="1"||i==="true"};return {select:r("noSelect"),move:r("noMove"),resize:r("noResize"),changeAspect:r("noChangeAspect")}}function Sw(e,n){return Object.freeze(e?{select:true,move:true,resize:true,changeAspect:true}:{select:n.select??false,move:n.move??false,resize:n.resize??false,changeAspect:n.changeAspect??false})}function Aw(e,n,t){let r=ae(e.children,"drawingDocPr")??(n?re(e.children,{namespaceUri:_,localName:"docPr"}):null);if(!r)return Object.freeze({docPrId:null,name:"",title:"",description:"",hidden:v(e.attributes,"hidden")==="1",hyperlinkHref:null});let o=null,i=fw(r);if(i!==null){let a=_s(i.attributes,"id");a&&(o=uw(a,t));}return Object.freeze({docPrId:gw(v(r.attributes,"id")),name:v(r.attributes,"name")??"",title:v(r.attributes,"title")??"",description:v(r.attributes,"descr")??"",hidden:v(r.attributes,"hidden")==="1"||v(e.attributes,"hidden")==="1",hyperlinkHref:o})}function Tm(e){if(e===void 0||!/^-?\d+$/.test(e))return null;let n=Number(e);return Number.isInteger(n)?n/1e3:null}function Mw(e){let n=false,t=0,r=0;for(let o of e.children)if(!(!ie(o)||o.kind!=="generic")&&o.namespaceUri===F){if(o.localName==="grayscl"){n=true;continue}if(o.localName==="lum"){let i=Tm(v(o.attributes,"bright")),a=Tm(v(o.attributes,"contrast"));i!==null&&(t=i),a!==null&&(r=a);}}return Object.freeze({grayscale:n,brightness:t,contrast:r})}function _w(e,n,t,r,o){if(!Ls(n,t.limits))return {picture:null,relationshipId:null,effects:jr,diagnostic:null};let i=ae(e.children,"drawingGraphic")??(o?re(e.children,{namespaceUri:F,localName:"graphic"}):null);if(!i)return {picture:null,relationshipId:null,effects:jr,diagnostic:{code:"unsupported-graphic",nodeId:e.id,detail:"missing-graphic"}};let a=ae(i.children,"drawingGraphicData")??(o?re(i.children,{namespaceUri:F,localName:"graphicData"}):null);if(!a)return {picture:null,relationshipId:null,effects:jr,diagnostic:{code:"unsupported-graphic",nodeId:i.id,detail:"missing-graphic-data"}};let l=v(a.attributes,"uri"),s=_n(r,e),d=_n(s,i),c=_n(d,a),u=Nw(a,n,t.limits,c,t.supportedMcRequires,o);if(l!==lw||!u)return {picture:null,relationshipId:null,effects:jr,diagnostic:{code:"unsupported-graphic",nodeId:a.id,detail:l??"non-picture"}};let f=kw(u),m=f?_s(f.attributes,"embed")??null:null,g=f?_s(f.attributes,"link")??null:null,p=m??g,x=bw(u),y=x?Object.freeze({left:ba(v(x.attributes,"l")),top:ba(v(x.attributes,"t")),right:ba(v(x.attributes,"r")),bottom:ba(v(x.attributes,"b"))}):dw,N=Pw(u)?"tile":"stretch",b=ae(u.children,"pictureShapeProperties"),h=b?ae(b.children,"pictureTransform"):null,P=h?ae(h.children,"pictureTransformOffset"):null,k=h?ae(h.children,"pictureTransformExtent"):null,E=h?v(h.attributes,"rot"):void 0,w=E!==void 0?de(E,false):null,I=Object.freeze({rotationDegrees:w===null?0:w/6e4,flipHorizontal:h?v(h.attributes,"flipH")==="1":false,flipVertical:h?v(h.attributes,"flipV")==="1":false,offsetEmu:Object.freeze({x:P?de(v(P.attributes,"x"),false)??0:0,y:P?de(v(P.attributes,"y"),false)??0:0}),extentEmu:Object.freeze({cx:k?de(v(k.attributes,"cx"))??0:0,cy:k?de(v(k.attributes,"cy"))??0:0})}),A=b?ae(b.children,"picturePresetGeometry"):null,U=A?v(A.attributes,"prst")??null:null,B=f?Mw(f):jr;return {picture:Object.freeze({embeddedRelationshipId:m,linkedRelationshipId:g,crop:y,fillMode:N,transform:I,presetGeometry:U}),relationshipId:p,effects:B,diagnostic:null}}function wa(e){return Object.freeze({...e,extentEmu:Object.freeze({...e.extentEmu}),effectExtentEmu:Object.freeze({...e.effectExtentEmu}),inlineDistancesEmu:Object.freeze({...e.inlineDistancesEmu}),wrapGeometry:e.wrapGeometry?Object.freeze({...e.wrapGeometry,distancesEmu:Object.freeze({...e.wrapGeometry.distancesEmu}),polygon:Object.freeze(e.wrapGeometry.polygon.map(n=>Object.freeze({...n})))}):null,position:e.position?Object.freeze({...e.position,simplePosition:Object.freeze({...e.position.simplePosition}),horizontal:Object.freeze({...e.position.horizontal}),vertical:Object.freeze({...e.position.vertical})}):null,anchor:e.anchor?Object.freeze({...e.anchor}):null,picture:e.picture?Object.freeze({...e.picture,crop:Object.freeze({...e.picture.crop}),transform:Object.freeze({...e.picture.transform})}):null,vectorShape:e.vectorShape?Object.freeze({...e.vectorShape,extentEmu:Object.freeze({...e.vectorShape.extentEmu}),subpathsEmu:Object.freeze(e.vectorShape.subpathsEmu.map(n=>Object.freeze(n.map(t=>Object.freeze({...t})))))}):null,textboxStory:e.textboxStory?Object.freeze({...e.textboxStory,insetsEmu:Object.freeze({...e.textboxStory.insetsEmu})}):null,locks:Object.freeze({...e.locks}),effects:Object.freeze({...e.effects}),diagnostics:Object.freeze(e.diagnostics.map(n=>Object.freeze({...n})))})}function Ms(e,n,t,r,o){return t.diagnostics.some(i=>i.code==="resource-refused")||t.diagnostics.push({code:"resource-refused",nodeId:e.id,detail:"projection-limit"}),wa(Object.freeze({drawingNodeId:e.id,ownerPartName:n.ownerPartName,kind:r,relationshipId:null,docPrId:null,name:"",title:"",description:"",hyperlinkHref:null,hidden:false,extentEmu:o,effectExtentEmu:Pa,inlineDistancesEmu:Pa,wrap:r==="inline"?"inline":"inFront",wrapGeometry:null,position:null,anchor:null,picture:null,vectorShape:null,textboxStory:null,locks:cw,effects:jr,compatibilityBranchNodeId:t.compatibilityBranchNodeId,diagnostics:t.diagnostics}))}function Sm(e){return Qo(e)}function Ea(e,n,t=rt,r=Kt){let o=As(),i=Us(e,o,r,n,t),a=hw(i.branch);return Object.freeze(a===null||a==="non-picture"?{segmentNode:e,drawing:null,removeNodeIds:Object.freeze([e.id])}:{segmentNode:e,drawing:a,removeNodeIds:Object.freeze([e.id])})}function Dw(e){let n=e.description.length>0?e.description:e.title.length>0?e.title:null;return Object.freeze({hidden:e.hidden,decorative:n===null,label:n})}function dr(e,n){let t={ownerPartName:n.ownerPartName,supportedMcRequires:n.supportedMcRequires,limits:n.limits,resolveRelationship:n.resolveRelationship},r=n.namespaceScope??Wr(),o=yw(e),i=As();i.depth>=t.limits.maxDrawingDepth&&(i.refused=true),i.depth+=1;let{anchor:a}=Ow(e,i,t.limits,r,t.supportedMcRequires);i.depth-=1;let l=a?Em(a,o):null;if(i.refused&&l){let h=a.kind==="anchoredDrawing"||a.kind==="generic"&&a.localName==="anchor"?"anchored":"inline";return Ms(e,t,i,h,l)}if(!a)return i.diagnostics.push({code:"malformed-drawing",nodeId:e.id,detail:"missing-anchor"}),null;let s=a.kind==="anchoredDrawing"||a.kind==="generic"&&a.localName==="anchor"?"anchored":"inline",d=Em(a,o);if(!d)return i.refused||i.diagnostics.push({code:"invalid-geometry",nodeId:a.id,detail:"extent"}),null;if(i.refused)return Ms(e,t,i,s,d);let c=Aw(a,o,t.resolveRelationship),u=s==="anchored"?ww(a,o):null,f=v(a.attributes,"behindDoc")==="1",m=v(a.attributes,"simplePos")==="1",g=ae(a.children,"drawingGraphicFramePr")??(o?re(a.children,{namespaceUri:_,localName:"cNvGraphicFramePr"}):null),p=Sw(v(a.attributes,"locked")==="1",vw(g)),x=_w(a,i,t,r,o);if(x.diagnostic&&i.diagnostics.push(x.diagnostic),i.refused)return Ms(e,t,i,s,d);let y=s==="anchored"?Cw(u,i,e.id):null,N=s==="anchored"?Rw(a,m):null,b=s==="anchored"?Object.freeze({simplePos:m,relativeHeight:de(v(a.attributes,"relativeHeight"))??0,behindDocument:f,layoutInCell:v(a.attributes,"layoutInCell")!=="0",allowOverlap:v(a.attributes,"allowOverlap")!=="0"}):null;return wa(Object.freeze({drawingNodeId:e.id,ownerPartName:t.ownerPartName,kind:s,relationshipId:x.relationshipId,docPrId:c.docPrId,name:c.name,title:c.title,description:c.description,hyperlinkHref:c.hyperlinkHref,hidden:c.hidden,extentEmu:d,effectExtentEmu:Ew(a,u,o),inlineDistancesEmu:s==="inline"?vm(a):Pa,wrap:Tw(s,u,f),wrapGeometry:y,position:N,anchor:b,picture:x.picture,vectorShape:x.picture?null:hm(a,d),textboxStory:x.picture?null:ym(a,d),locks:p,effects:x.effects,compatibilityBranchNodeId:i.compatibilityBranchNodeId,diagnostics:i.diagnostics}))}function Uw(e,n){let t=Ea(e,n.namespaceScope,n.supportedMcRequires,n.limits);if(t.drawing===null)return null;let r=dr(t.drawing,{...n,namespaceScope:n.namespaceScope});return !r||r.picture===null&&r.vectorShape===null&&r.textboxStory===null?null:r}var Lw=4;function Am(e,n,t,r,o){let i=[{node:e,namespaceScope:Wr(),depth:0,storyDepth:0}],a=0,l=(s,d,c)=>{if(!(d.storyDepth>=Lw)&&!(d.depth>=Dr)&&ie(s))for(let u=s.children.length-1;u>=0;u-=1){let f=s.children[u];ie(f)&&i.push({node:f,namespaceScope:c,depth:d.depth+1,storyDepth:d.storyDepth+1});}};for(;i.length>0;){let s=i.pop();if(!ie(s.node))continue;if(a+=1,a>sw)break;if(s.depth>Dr)continue;let d=_n(s.namespaceScope,s.node);if(s.node.kind==="drawing"){let c=dr(s.node,{...t,namespaceScope:d});c&&(r.push(c),o?.set(s.node.id,c)),c?.textboxStory&&l(s.node,s,d);continue}if(Qo(s.node)){let c=Uw(s.node,{ownerPartName:n,supportedMcRequires:t.supportedMcRequires,limits:t.limits,namespaceScope:d,resolveRelationship:t.resolveRelationship});if(c&&(r.push(c),o?.set(s.node.id,c)),c?.textboxStory){let u=Ea(s.node,d,t.supportedMcRequires,t.limits).drawing;u&&l(u,s,d);}continue}if(!(s.depth>=Dr))for(let c=s.node.children.length-1;c>=0;c-=1){let u=s.node.children[c];ie(u)&&i.push({node:u,namespaceScope:d,depth:s.depth+1,storyDepth:s.storyDepth});}}}function Mm(e,n){let t={ownerPartName:e.name,supportedMcRequires:n?.supportedMcRequires??rt,limits:n?.limits??Kt,resolveRelationship:n?.resolveRelationship},r=[];return Am(e.root,e.name,t,r),Object.freeze(r.map(wa))}function wU(e,n){let t={ownerPartName:e.name,supportedMcRequires:n?.supportedMcRequires??rt,limits:n?.limits??Kt,resolveRelationship:n?.resolveRelationship},r=[],o=new Map;return Am(e.root,e.name,t,r,o),Object.freeze(o)}var Bw=/^\/word\/(document|footnotes|endnotes)\.xml$|^\/word\/(header|footer)[^/]+\.xml$/;function Kr(e,n){let t=[];for(let[r,o]of e.parts){if(!Bw.test(r))continue;let i=Mm(o,{...n,resolveRelationship:Ds(e,r)});for(let a of i)t.push(a);}return Object.freeze(t.map(wa))}function _m(e,n,t){for(let r of e){if(!r.removeNodeIds||r.removeNodeIds.length===0||!(n<r.end&&t>r.start))continue;if(!(n<=r.start&&t>=r.end))return true}return false}var Dm=1,Jo=new Map;function Ra(e,n){return `${e}\0${n}`}function Fw(e){let n=e.split("\0");return n.length>=2?`${n[0]}\0${n[1]}`:e}function Um(e,n,t){if(e.disposed||n.contentId!==t||n.generation!==e.generation)return null;let r=e.slots.get(Ra(n.resourceKey,t));return !r||r.contentId!==t||r.generation!==n.generation||r.refCount<=0?null:r.bytes}function Fs(e,n){return Object.freeze({acquire:(i,a,l)=>{if(n.disposed)throw new Error("ValidatedImageBytesRegistry disposed");let s=Fw(i);for(let[f,m]of [...n.slots.entries()])f.startsWith(`${s}\0`)&&m.contentId!==a&&(n.slots.delete(f),n.generation+=1);let d=Ra(i,a),c=n.slots.get(d);c?c.bytes=new Uint8Array(l):n.slots.set(d,{contentId:a,bytes:new Uint8Array(l),generation:n.generation,refCount:0});let u=n.slots.get(d);return Object.freeze({registryId:e,resourceKey:i,contentId:a,generation:u.generation})},retain:i=>{if(i.registryId!==e||n.disposed)throw new Error("ValidatedImageBytesRegistry stale handle");let a=Ra(i.resourceKey,i.contentId),l=n.slots.get(a);if(!l||l.generation!==i.generation)throw new Error("ValidatedImageBytesRegistry stale handle");l.refCount+=1;let s=n.nextRetainId;return n.nextRetainId+=1,n.retainIds.add(s),Object.freeze({registryId:e,resourceKey:i.resourceKey,contentId:i.contentId,generation:i.generation,retainId:s})},release:i=>{if(i.registryId!==e||!n.retainIds.has(i.retainId))return;n.retainIds.delete(i.retainId);let a=Ra(i.resourceKey,i.contentId),l=n.slots.get(a);!l||l.generation!==i.generation||(l.refCount-=1,l.refCount<=0&&n.slots.delete(a));},mint:(i,a)=>Um(n,i,a),dispose:()=>{n.disposed||(n.disposed=true,n.generation+=1,n.slots.clear(),n.retainIds.clear(),Jo.delete(e));}})}function Vs(){let e=Dm;Dm+=1;let n={generation:0,slots:new Map,retainIds:new Set,nextRetainId:1,disposed:false};return Jo.set(e,n),Fs(e,n)}function RU(e,n){let t=Jo.get(e.registryId);return t?Um(t,e,n):null}function IU(e){let n=Jo.get(e.registryId);if(!n)return null;try{return Fs(e.registryId,n).retain(e)}catch{return null}}function TU(e){let n=Jo.get(e.registryId);n&&Fs(e.registryId,n).release(e);}Vs();var jm=Object.freeze([137,80,78,71,13,10,26,10]),Gr=96,Vw=65536,Ww=512,Hw=8192,jw=300,Kw=150,Gw=Object.freeze({"image/png":"image/png","image/jpeg":"image/jpeg","image/jpg":"image/jpeg","image/gif":"image/gif","image/bmp":"image/bmp","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp","image/webp":"image/webp","image/svg+xml":"image/svg+xml","image/tiff":"image/tiff","image/x-emf":"image/x-emf","image/x-wmf":"image/x-wmf"});function Km(e,n){if(e.length<n.length)return false;for(let t=0;t<n.length;t+=1)if(e[t]!==n[t])return false;return true}function Lm(e){return e===32||e===9||e===10||e===13}function $w(e){let n=e.subarray(0,Math.min(e.length,Ww)),t=0;for(;t<n.length&&Lm(n[t]);)t+=1;if(t+5<n.length&&n[t]===60&&n[t+1]===63){let r=-1;for(let o=t+2;o+1<n.length;o+=1)if(n[o]===63&&n[o+1]===62){r=o;break}if(r===-1)return false;for(t=r+2;t<n.length&&Lm(n[t]);)t+=1;}return t+4<=n.length&&n[t]===60&&n[t+1]===115&&n[t+2]===118&&n[t+3]===103&&(t+4===n.length||n[t+4]===32||n[t+4]===9||n[t+4]===10||n[t+4]===13||n[t+4]===62)}function Gm(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"||e==="image/bmp"||e==="image/webp"}function $m(e){return e==="image/tiff"||e==="image/x-emf"||e==="image/x-wmf"}function zr(e){return Km(e,jm)?"image/png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.length>=2&&e[0]===66&&e[1]===77?"image/bmp":e.length>=12&&e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56&&(e[4]===55||e[4]===57)&&e[5]===97?"image/gif":$w(e)?"image/svg+xml":e.length>=4&&(e[0]===73&&e[1]===73&&e[2]===42&&e[3]===0||e[0]===77&&e[1]===77&&e[2]===0&&e[3]===42)?"image/tiff":e.length>=44&&e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0?"image/x-emf":e.length>=4&&e[0]===215&&e[1]===205&&e[2]===198&&e[3]===154||e.length>=4&&e[0]===1&&e[1]===0&&e[2]===9&&e[3]===0?"image/x-wmf":"unknown"}function zw(e,n){switch(e){case 0:return n===1||n===2||n===4||n===8||n===16;case 2:return n===8||n===16;case 3:return n===1||n===2||n===4||n===8;case 4:return n===8||n===16;case 6:return n===8||n===16;default:return false}}function Xw(e){if(!Km(e,jm)||e.length<33||(e[8]<<24>>>0|e[9]<<16|e[10]<<8|e[11])!==13||e[12]!==73||e[13]!==72||e[14]!==68||e[15]!==82)return null;let t=e[16]<<24>>>0|e[17]<<16|e[18]<<8|e[19],r=e[20]<<24>>>0|e[21]<<16|e[22]<<8|e[23];if(t===0||r===0)return null;let o=e[24],i=e[25],a=e[26],l=e[27],s=e[28];return !zw(i,o)||a!==0||l!==0||s!==0&&s!==1?null:{pixelWidth:t,pixelHeight:r}}function qw(e){if(e.length<10||e[0]!==71||e[1]!==73||e[2]!==70||e[3]!==56||e[4]!==55&&e[4]!==57||e[5]!==97)return null;let n=e[6]|e[7]<<8,t=e[8]|e[9]<<8;return n===0||t===0?null:{pixelWidth:n,pixelHeight:t}}function Yw(e){return e>=192&&e<=195||e>=197&&e<=199||e>=201&&e<=203||e>=205&&e<=207}function Zw(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let n=2,t=Math.min(e.length,Vw);for(;n+1<t;){if(e[n]!==255)return null;let r=e[n+1];for(n+=2;r===255&&n<t;)r=e[n],n+=1;if(r===216)continue;if(r===217)return null;if(r===1||r>=208&&r<=215)continue;if(n+1>=t)return null;let o=e[n]<<8|e[n+1];if(o<2)return null;let i=n+o;if(i>t)return null;if(Yw(r)){if(o<7||n+6>=t)return null;let a=e[n+3]<<8|e[n+4],l=e[n+5]<<8|e[n+6];return l===0||a===0?null:{pixelWidth:l,pixelHeight:a}}n=i;}return null}var Qw=12,Bm=40,Jw=new Set([0,1,4,8,16,24,32]);function eE(e){if(e.length<26||e[0]!==66||e[1]!==77)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=n.getUint32(14,true);if(t===Qw){let a=n.getUint16(18,true),l=n.getUint16(20,true);return a===0||l===0?null:{pixelWidth:a,pixelHeight:l}}if(t<Bm||t>1024||e.length<14+Bm)return null;let r=n.getInt32(18,true),o=n.getInt32(22,true),i=Math.abs(o);return r<=0||i===0||n.getUint16(26,true)!==1||!Jw.has(n.getUint16(28,true))?null:{pixelWidth:r,pixelHeight:i}}function nE(e){if(e.length<30)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=String.fromCharCode(e[12],e[13],e[14],e[15]);if(t==="VP8 "){if(e[23]!==157||e[24]!==1||e[25]!==42)return null;let r=n.getUint16(26,true)&16383,o=n.getUint16(28,true)&16383;return r===0||o===0?null:{pixelWidth:r,pixelHeight:o}}if(t==="VP8L"){if(e[20]!==47)return null;let r=n.getUint32(21,true),o=(r&16383)+1,i=(r>>>14&16383)+1;return {pixelWidth:o,pixelHeight:i}}if(t==="VP8X"){let r=(e[24]|e[25]<<8|e[26]<<16)+1,o=(e[27]|e[28]<<8|e[29]<<16)+1;return {pixelWidth:r,pixelHeight:o}}return null}var tE=4096,Fm=256,rE=257,oE=3,iE=4;function aE(e){if(e.length<8)return null;let n;if(e[0]===73&&e[1]===73)n=true;else if(e[0]===77&&e[1]===77)n=false;else return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint16(2,n)!==42)return null;let r=t.getUint32(4,n);if(r<8||r+2>e.length)return null;let o=t.getUint16(r,n);if(o===0||o>tE||r+2+o*12>e.length)return null;let i=0,a=0;for(let l=0;l<o;l+=1){let s=r+2+l*12,d=t.getUint16(s,n);if(d!==Fm&&d!==rE)continue;if(t.getUint32(s+4,n)!==1)return null;let c=t.getUint16(s+2,n),u;if(c===oE)u=t.getUint16(s+8,n);else if(c===iE)u=t.getUint32(s+8,n);else return null;d===Fm?i=u:a=u;}return i<=0||a<=0?null:{pixelWidth:i,pixelHeight:a}}var lE=Object.freeze({"":1,px:1,pt:96/72,pc:16,in:96,cm:96/2.54,mm:96/25.4,q:96/101.6});function Vm(e){let n=e.trim();if(n==="")return null;let t=Number.parseFloat(n);if(!Number.isFinite(t)||t<=0)return null;let r=0;for((n[r]==="+"||n[r]==="-")&&(r+=1);r<n.length&&n[r]>="0"&&n[r]<="9";)r+=1;if(n[r]===".")for(r+=1;r<n.length&&n[r]>="0"&&n[r]<="9";)r+=1;if(n[r]==="e"||n[r]==="E"){let a=r+1;(n[a]==="+"||n[a]==="-")&&(a+=1);let l=0;for(;a<n.length&&n[a]>="0"&&n[a]<="9";)a+=1,l+=1;l>0&&(r=a);}let o=lE[n.slice(r).trim().toLowerCase()];if(o===void 0)return null;let i=t*o;return Number.isFinite(i)&&i>0?i:null}function sE(e){let n=[],t="";for(let i of `${e} `){if(i===" "||i===","||i===" "||i===`
3
- `||i==="\r"){if(t!==""&&(n.push(Number.parseFloat(t)),t="",n.length>4))return null;continue}if(t+=i,t.length>64)return null}if(n.length!==4||!n.every(i=>Number.isFinite(i)))return null;let[,,r,o]=n;return r>0&&o>0?Object.freeze({width:r,height:o}):null}function dE(e){let n=e.subarray(0,Math.min(e.length,Hw)),t=new TextDecoder("utf-8",{fatal:false}).decode(n),r=t.indexOf("<svg");if(r===-1)return null;let o=r+4,i={width:"",height:"",viewBox:""};for(;o<t.length;){let a=t[o];if(a===">"||a==="/")break;if(a===" "||a===" "||a===`
4
- `||a==="\r"){o+=1;continue}let l="";for(;o<t.length&&!`
5
- \r=>/`.includes(t[o]);)l+=t[o],o+=1;for(;o<t.length&&`
6
- \r`.includes(t[o]);)o+=1;if(t[o]!=="=")continue;for(o+=1;o<t.length&&`
7
- \r`.includes(t[o]);)o+=1;let s=t[o],d="";if(s==='"'||s==="'"){for(o+=1;o<t.length&&t[o]!==s;)d+=t[o],o+=1;if(o>=t.length)return null;o+=1;}else for(;o<t.length&&!`
8
- \r>/`.includes(t[o]);)d+=t[o],o+=1;l in i&&(i[l]=d);}return o>=t.length?null:Object.freeze(i)}function cE(e,n){let t=dE(e);if(t===null)return null;let r=Vm(t.width),o=Vm(t.height),i=sE(t.viewBox),a,l;if(r!==null&&o!==null)a=r,l=o;else if(i!==null){let d=i.width/i.height;r!==null?(a=r,l=r/d):o!==null?(a=o*d,l=o):(a=i.width,l=i.height);}else a=r??jw,l=o??Kw;let s=d=>Math.min(Math.max(Math.round(d),1),n.maxDimension);return {pixelWidth:s(a),pixelHeight:s(l)}}function ni(e,n){switch(n){case "image/png":return Xw(e);case "image/gif":return qw(e);case "image/jpeg":return Zw(e);case "image/bmp":return eE(e);case "image/webp":return nE(e);default:return null}}function Ws(e,n){let t=Bt(e.contentTypes,n);return t.ok?Gw[t.contentType.toLowerCase()]??"unknown":"unknown"}function $r(e){return new Uint8Array(e)}function ei(e){return zu(e)}function Hs(e,n,t){return `${e}\0${n}\0${t}`}function Nt(e){return Object.freeze(e)}function ue(e,n,t){return Nt({kind:"unrenderable",partName:e,mime:n,reason:t})}function Ia(e,n,t){if(!Number.isFinite(e)||!Number.isFinite(n)||e<=0||n<=0||e>t.maxDimension||n>t.maxDimension||e>Number.MAX_SAFE_INTEGER/n)return null;let r=e*n;return r>t.maxPixels?null:r}function Ta(e,n){return e>Number.MAX_SAFE_INTEGER/4?false:e*4<=n.maxDecodedBytes}function Wm(e){return Gm(e)?"raster":$m(e)?"preserved":"vector"}function uE(e,n){return e==="unknown"||n==="unknown"?false:Wm(e)!==Wm(n)?true:e!==n}function Hm(e,n,t){return t.mode==="internal"?`${e}\0${n}\0internal\0${t.partName}\0${t.raw}`:t.mode==="external"?`${e}\0${n}\0external\0${t.raw}\0${t.sinkSafe?"1":"0"}`:`${e}\0${n}\0missing`}function fE(e,n){return e.relationships.get(n)??[]}function Ca(e,n,t){return _r(fE(e,n),n,t)}function zm(e,n){let t=0;for(let r of Kr(e)){let o=r.picture?.embeddedRelationshipId;if(!o)continue;let i=Ca(e,r.ownerPartName,o);i.mode==="internal"&&i.partName===n&&(t+=1);}return t}var mE=Object.keys(oa);function Xm(e){return mE.map(n=>`${n}=${e[n]}`).join("\0")}var js=new WeakMap;function pE(e,n,t){let r=js.get(e);r||(r=new WeakMap,js.set(e,r));let o=r.get(n);o||(o=new Map,r.set(n,o));let i=Xm(t),a=o.get(i);if(a)return a;let s={lookup:hE(e,n,t)};return o.set(i,s),s}function gE(e,n,t,r){let o=js.get(e);if(!o)return;let i=o.get(n);if(!i)return;let a=Xm(t),l=i.get(a);!l||l.lookup!==r||(i.delete(a),i.size===0&&o.delete(n));}function qm(e,n){let t=Ar(n.limits);return pE(e,n.decodePort,t).lookup}function xE(e,n){return qm(e,n)}function hE(e,n,t){let r=e,o=0,i=false,a=Vs(),l=new Map,s=new Map,d=()=>{if(i)throw new Error("ImageResourceLookup disposed")},c=(h,P)=>`${h}\0${P}`,u=(h,P,k)=>`${h}\0${P}\0${k}`,f=()=>{o+=1,l.clear(),s.clear();},m=(h,P)=>{let k=Ca(r,h,P),E=Hm(h,P,k),w=l.get(c(h,P));if(!w||w.relationshipFingerprint!==E)return null;if(k.mode==="internal"){let I=r.partBytes.get(k.partName);if(!I||ei(I)!==w.contentId)return null}return w},g=async(h,P,k,E)=>{if(E!==o||i)throw new Error("ImageResourceLookup stale");if(k.length>t.maxEncodedBytes)return ue(P,Ws(r,P),"resource-limit");let w=zr(k),I=Ws(r,P);if(I!=="unknown"&&w!=="unknown"&&uE(I,w))return ue(P,w,"signature-mismatch");if(I!=="unknown"&&w==="unknown")return ue(P,I,"signature-mismatch");if(w==="unknown")return ue(P,"unknown","unsupported-format");if($m(w)){let ke=w,xt=n.convertPreserved?.bind(n);if(!xt)return ue(P,ke,"unsupported-format");if(ke==="image/tiff"){let qe=aE(k);if(qe===null)return ue(P,ke,"unsupported-format");let Sr=Ia(qe.pixelWidth,qe.pixelHeight,t);if(Sr===null||!Ta(Sr,t))return ue(P,ke,"resource-limit")}let pe=ei(k),ht=u(h,P,pe),ra=s.get(ht);if(ra)return ra;let rs=$r(k),Lo=new Promise((qe,Sr)=>{(async()=>{try{let et;try{et=await xt(rs,ke,t);}catch{qe(ue(P,ke,"decode-failed"));return}if(E!==o||i){Sr(new Error("ImageResourceLookup stale"));return}if(et===null){qe(ue(P,ke,"unsupported-format"));return}if(et.bytes.length>t.maxEncodedBytes){qe(ue(P,ke,"resource-limit"));return}let Bo=zr(et.bytes);if(Bo!==et.mime||!Gm(Bo)){qe(ue(P,ke,"decode-failed"));return}let lr=ni(et.bytes,Bo);if(lr===null){qe(ue(P,ke,"decode-failed"));return}let Ku=Ia(lr.pixelWidth,lr.pixelHeight,t);if(Ku===null||!Ta(Ku,t)){qe(ue(P,ke,"resource-limit"));return}let os;try{os=await n.decode($r(et.bytes),Bo,t);}catch{qe(ue(P,ke,"decode-failed"));return}if(E!==o||i){Sr(new Error("ImageResourceLookup stale"));return}if(os.pixelWidth!==lr.pixelWidth||os.pixelHeight!==lr.pixelHeight){qe(ue(P,ke,"decode-failed"));return}let Gu=Hs(h,P,pe),$u=a.acquire(Gu,pe,$r(et.bytes));a.retain($u),qe(Nt({kind:"ready",partName:P,contentId:pe,resourceKey:Gu,validatedHandle:$u,mime:Bo,pixelWidth:lr.pixelWidth,pixelHeight:lr.pixelHeight,dpiX:Gr,dpiY:Gr}));}catch(et){Sr(et);}finally{E===o&&s.delete(ht);}})();});return s.set(ht,Lo),Lo}if(w==="image/svg+xml"){let ke=cE(k,t);if(ke===null)return ue(P,w,"decode-failed");let xt=ei(k),pe=Hs(h,P,xt),ht=a.acquire(pe,xt,$r(k));return a.retain(ht),Nt({kind:"ready",partName:P,contentId:xt,resourceKey:pe,validatedHandle:ht,mime:w,pixelWidth:ke.pixelWidth,pixelHeight:ke.pixelHeight,dpiX:Gr,dpiY:Gr})}let A=ni(k,w);if(A===null)return ue(P,w,"unsupported-format");let U=Ia(A.pixelWidth,A.pixelHeight,t);if(U===null||!Ta(U,t))return ue(P,w,"resource-limit");let B=ei(k),C=u(h,P,B),rn=s.get(C);if(rn)return rn;let fn=$r(k),ju=new Promise((ke,xt)=>{(async()=>{try{let pe;try{pe=await n.decode(fn,w,t);}catch{ke(ue(P,w,"decode-failed"));return}if(E!==o||i){xt(new Error("ImageResourceLookup stale"));return}if(pe.pixelWidth!==A.pixelWidth||pe.pixelHeight!==A.pixelHeight){ke(ue(P,w,"decode-failed"));return}let ht=Ia(pe.pixelWidth,pe.pixelHeight,t);if(ht===null||!Ta(ht,t)){ke(ue(P,w,"resource-limit"));return}let ra=Number.isFinite(pe.dpiX)&&pe.dpiX>0?pe.dpiX:Gr,rs=Number.isFinite(pe.dpiY)&&pe.dpiY>0?pe.dpiY:Gr,Lo=Hs(h,P,B),qe=a.acquire(Lo,B,fn);a.retain(qe),ke(Nt({kind:"ready",partName:P,contentId:B,resourceKey:Lo,validatedHandle:qe,mime:w,pixelWidth:pe.pixelWidth,pixelHeight:pe.pixelHeight,dpiX:ra,dpiY:rs}));}catch(pe){xt(pe);}finally{E===o&&s.delete(C);}})();});return s.set(C,ju),ju},p=(h,P,k,E,w="")=>(l.set(c(h,P),{relationshipFingerprint:Hm(h,P,k),contentId:w,state:E}),E),x=async(h,P)=>{d();let k=Ca(r,h,P),E=m(h,P);if(E)return E.state;if(k.mode==="external")return p(h,P,k,Nt({kind:"external",relationshipId:P,sinkSafe:k.sinkSafe}));if(k.mode==="missing")return p(h,P,k,Nt({kind:"missing",relationshipId:P}));let w=r.partBytes.get(k.partName);if(!w)return p(h,P,k,Nt({kind:"missing",relationshipId:P}));let I=$r(w),A=o,U=await g(h,k.partName,I,A);if(A!==o||i)throw new Error("ImageResourceLookup stale");let B=U.kind==="ready"||U.kind==="unrenderable"&&U.partName?ei(I):"";return p(h,P,k,U,B)},y=(h,P)=>{d();let k=Ca(r,h,P),E=m(h,P);return E?E.state:k.mode==="external"?p(h,P,k,Nt({kind:"external",relationshipId:P,sinkSafe:k.sinkSafe})):k.mode==="internal"?p(h,P,k,ue(k.partName,Ws(r,k.partName),"unsupported-format")):p(h,P,k,Nt({kind:"missing",relationshipId:P}))},b=Object.freeze({resolveEmbedded:x,resolveLinked:y,resolveForProjection:async h=>{if(d(),!h.picture)return ue(null,"unknown","non-picture-graphic");let P=h.picture.linkedRelationshipId;if(P)return y(h.ownerPartName,P);let k=h.picture.embeddedRelationshipId;return k?x(h.ownerPartName,k):ue(null,"unknown","unsupported-format")},liveReferenceCount:h=>zm(r,h),dispose:()=>{i=true,f(),a.dispose(),gE(r,n,t,b);}});return b}var Ym="/[Content_Types].xml",yE="http://schemas.openxmlformats.org/package/2006/content-types",OE="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",NE=/(?:\/xml|\+xml)$/i;function va(e){return new TextDecoder(e,{fatal:true})}function Ks(e,n){let t=n?.maxBytes??Fo;if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)return {ok:false,reason:"invalid-limits"};if(e.byteLength>Math.min(t,Fo))return {ok:false,reason:"too-large"};try{if(e[0]===255&&e[1]===254)return {ok:!0,xml:va("utf-16le").decode(e.subarray(2))};if(e[0]===254&&e[1]===255)return {ok:!0,xml:va("utf-16be").decode(e.subarray(2))};if(e[0]===60&&e[1]===0&&e[2]===63&&e[3]===0)return {ok:!0,xml:va("utf-16le").decode(e)};if(e[0]===0&&e[1]===60&&e[2]===0&&e[3]===63)return {ok:!0,xml:va("utf-16be").decode(e)};let r=e[0]===239&&e[1]===187&&e[2]===191?3:0;return {ok:!0,xml:strFromU8(e.subarray(r))}}catch{return {ok:false,reason:"parse-error"}}}var Zm=Object.freeze({maxXmlParts:512,maxRelationships:1e4});function np(e){return e.type==="element"}function tp(e,n,t=[]){for(let r of e){if(!np(r))continue;let o=r.name.indexOf(":");(o===-1?r.name:r.name.slice(o+1))===n&&t.push(r),tp(r.children,n,t);}return t}function Sa(e,n){for(let[t,r]of Object.entries(e.attributes)){let o=t.indexOf(":");if((o===-1?t:t.slice(o+1))===n)return r}}function rp(e){let n=e.indexOf(":");return n===-1?{prefix:"",localName:e}:{prefix:e.slice(0,n),localName:e.slice(n+1)}}function kE(e){let n=new Map;for(let[t,r]of Object.entries(e))t==="xmlns"?n.set("",r):t.startsWith("xmlns:")&&n.set(t.slice(6),r);return n}function bE(e,n){let t=kE(n.attributes);return t.size===0?e:new Map([...e,...t])}function PE(e,n){return n.get(rp(e.name).prefix)}function Aa(e,n){for(let[t,r]of Object.entries(e.attributes))if(t.indexOf(":")===-1&&t===n)return r}function Gs(e,n,t,r=[]){for(let o of e){if(!np(o))continue;let i=bE(t,o);rp(o.name).localName===n&&PE(o,i)===yE&&r.push(o),Gs(o.children,n,i,r);}return r}function wE(e){let n=/^(.*)\/_rels\/([^/]*)\.rels$/.exec(e);if(!n)return null;let[,t,r]=n;return r===""?"/":`${t}/${r}`}function EE(e,n){let t=tt(e,n);if(!t.ok)return null;let r=[],o=[],i=0,a=new Map;for(let s of Gs(t.nodes,"Default",a)){let d=Aa(s,"Extension"),c=Aa(s,"ContentType");d===void 0||c===void 0||r.push({extension:d,contentType:c,order:i++});}for(let s of Gs(t.nodes,"Override",a)){let d=Aa(s,"PartName"),c=Aa(s,"ContentType");d===void 0||c===void 0||o.push({partName:d,contentType:c,order:i++});}let l=ls({defaults:r,overrides:o});return l.ok?l.index:null}function RE(e,n){let t=Bt(n,e);return t.ok?t.contentType:""}function KU(e,n={}){let t=sm(e,n.zip??Cs);if(!t.ok)return {ok:false,reason:t.reason,detail:t.detail};let r=t.entries.get(Ym);if(!r)return {ok:false,reason:"no-content-types"};let o=Ks(r,n.xml);if(!o.ok)return {ok:false,reason:o.reason};let i=EE(o.xml,n.xml);if(!i)return {ok:false,reason:"bad-content-types"};let a=n.maxRelationships??Zm.maxRelationships,l=[],s=[],d=0;for(let[y,N]of t.entries){let b=wE(y);if(b===null)continue;let h=Ks(N,n.xml);if(!h.ok)return {ok:false,reason:h.reason,detail:y};let P=tt(h.xml,n.xml);if(!P.ok)return {ok:false,reason:P.reason,detail:y};for(let k of tp(P.nodes,"Relationship")){if(l.length>=a)return {ok:false,reason:"too-many-relationships"};let E=Sa(k,"Id"),w=Sa(k,"Type"),I=Sa(k,"Target");if(E===void 0||w===void 0||I===void 0)return {ok:false,reason:"bad-relationship-target",detail:`${y}: missing attribute`};l.push({ownerPart:b,id:E,type:w,rawTarget:I,targetMode:Sa(k,"TargetMode")==="External"?"External":"Internal",order:d++});}}let c=ef(l);if(!c.ok)return {ok:false,reason:"duplicate-relationship-id",detail:`${c.error.ownerPart}: ${c.error.id}`};for(let y of l){let N=Me(y);if(N.mode==="External"){s.push({ownerPart:y.ownerPart,id:y.id,type:y.type,rawTarget:y.rawTarget,sinkSafe:N.sinkSafe.ok});continue}if(!N.target.ok)return {ok:false,reason:"bad-relationship-target",detail:`${y.ownerPart}/${y.id} -> ${y.rawTarget}: ${N.target.reason}`}}let f=(c.byOwner.get("/")??[]).find(y=>y.type===OE);if(!f)return {ok:false,reason:"no-main-document"};let m=Me(f);if(m.mode!=="Internal"||!m.target.ok)return {ok:false,reason:"no-main-document",detail:f.rawTarget};let g=m.target.partName;if(!t.entries.has(g))return {ok:false,reason:"no-main-document",detail:g};let p=n.maxXmlParts??Zm.maxXmlParts,x=new Map;for(let[y,N]of t.entries){if(y===Ym)continue;let b=RE(y,i);if(b.toLowerCase()==="image/svg+xml"||!NE.test(b))continue;if(x.size>=p)return {ok:false,reason:"too-many-xml-parts"};let h=xe(y);if(!h.ok)return {ok:false,reason:"bad-relationship-target",detail:`${y}: ${h.reason}`};let P=Ks(N,n.xml);if(!P.ok)return {ok:false,reason:P.reason,detail:y};let k=ne(P.xml,{name:h.partName,contentType:b},n.xml);if(!k.ok)return {ok:false,reason:k.reason,detail:y};x.set(h.partName,k.part);}return {ok:true,package:Object.freeze({parts:x,partBytes:t.entries,relationships:c.byOwner,externalTargets:Object.freeze(s),contentTypes:i,mainDocumentPart:g})}}function GU(e){let n=new Map(e.partBytes);for(let[t,r]of e.parts)n.set(t,strToU8(Fr(r)));return dm(n)}function D(e,n){let t=new Map(e.parts);return t.set(n.name,n),Object.freeze({...e,parts:t})}var qr="/[Content_Types].xml",ip="http://schemas.openxmlformats.org/package/2006/content-types",$s="http://schemas.openxmlformats.org/package/2006/relationships",IE="application/vnd.openxmlformats-package.relationships+xml";function Ma(e){for(let[n,t]of e){let r=xe(n);if(r.ok&&G(r.partName)===G(qr))return {storageKey:n,bytes:t}}return null}function Xs(e){return Ma(e.partBytes)}function it(e,n){return e.relationships.get(n)??[]}function at(e,n){let t=Bt(e.contentTypes,n);return t.ok?t.contentType:null}function ot(e){let n=e.lastIndexOf("/"),t=e.slice(0,n),r=e.slice(n+1);return `${t}/_rels/${r}.rels`}function qs(e,n,t,r,o=[]){return {id:e,kind:"generic",namespaceUri:n,localName:t,namespaceBindings:o,attributes:Object.entries(r).map(([i,a])=>({kind:"genericExtension",namespaceUri:"",localName:i,value:a})),children:[]}}function TE(e){let n=G(e);return n===G(qr)||/\/_rels\/[^/]*\.rels$/.test(n)}function CE(e){return G(e)===G(qr)}function vE(e,n){let t=G(n);for(let r of e.parts.keys())if(G(r)===t)return true;for(let r of e.partBytes.keys())if(G(r)===t)return true;return false}function ap(e){let n=xe(e);return !n.ok||TE(n.partName)?null:n.partName}function lp(e,n){return `${e.name}#minted-${n}`}function zs(e,n){if(e.kind!=="textValue")return e.attributes.find(t=>t.localName===n&&t.namespaceUri==="")?.value}function SE(e,n){if(e.kind!=="generic"||e.namespaceUri!==ip||e.localName!=="Override")return false;let t=zs(e,"PartName"),r=zs(e,"ContentType");return t!==void 0&&r!==void 0&&G(t)===G(n)}function AE(e,n,t){return {...e,attributes:e.attributes.map(r=>r.localName===n&&r.namespaceUri===""?{...r,value:t}:r)}}function op(e,n,t){let r=e.root;if(r.kind!=="generic")return {part:e,changed:false};let o=false,i=false,a=[];for(let s of r.children){if(!SE(s,n)){a.push(s);continue}if(o){i=true;continue}if(o=true,s.kind!=="generic")continue;if(zs(s,"ContentType")===t){a.push(s);continue}i=true,a.push(AE(s,"ContentType",t));}if(o||(i=true,a.push(qs(lp(e,`override-${n}`),ip,"Override",{PartName:n,ContentType:t}))),!i)return {part:e,changed:false};let l=L(e,r.id,a,{deferValidation:true});return l.ok?{part:l.part,changed:true}:{part:e,changed:false}}function Yr(e,n,t,r){let o=ap(n);if(o===null)return e;let i=G(o);if(r?.forceOverride){if(e.contentTypes.overrides.get(i)===t){let u=Ma(e.partBytes);if(u!==null){let f=ne(new TextDecoder().decode(u.bytes),{name:qr,contentType:"application/xml"});if(f.ok&&!op(f.part,o,t).changed)return e}}}else if(at(e,o)===t)return e;let a=Ma(e.partBytes);if(a===null)return e;let l=ne(new TextDecoder().decode(a.bytes),{name:qr,contentType:"application/xml"});if(!l.ok)return e;let s=op(l.part,o,t);if(!s.changed)return e;let d=new Map(e.contentTypes.overrides);d.set(i,t);let c=new Map(e.partBytes);return c.set(a.storageKey,new TextEncoder().encode(Fr(s.part))),Object.freeze({...e,partBytes:c,contentTypes:{defaults:e.contentTypes.defaults,overrides:d}})}function Ys(e,n){let t=xe(n);if(!t.ok)return {pkg:e,ok:false};let r=G(t.partName),o=G(ot(t.partName)),i=new Map;for(let[u,f]of e.relationships){let m=f.filter(g=>{if(g.targetMode==="External")return false;let p=We(u,g.rawTarget);return p.ok&&G(p.partName)===r});m.length>0&&i.set(u,new Set(m.map(g=>g.id)));}for(let u of i.keys())if(!e.parts.has(ot(u)))return {pkg:e,ok:false};let a=new Map(e.parts),l=new Map(e.partBytes);for(let u of [a,l])for(let f of [...u.keys()]){let m=G(f);(m===r||m===o)&&u.delete(f);}let s=new Map(e.relationships);s.delete(t.partName);for(let[u,f]of i){let m=s.get(u)??[];s.set(u,m.filter(y=>!f.has(y.id)));let g=a.get(ot(u));if(!g)continue;let p=g.root.children.filter(y=>{let N=sp(y);return N===void 0||!f.has(N)}),x=L(g,g.root.id,p);if(!x.ok)return {pkg:e,ok:false};a.set(x.part.name,x.part);}let d=e.externalTargets.filter(u=>G(u.ownerPart)!==r),c=Object.freeze({...e,parts:a,partBytes:l,relationships:s,externalTargets:d});return {pkg:ME(c,t.partName),ok:true}}function ME(e,n){let t=G(n);if(!e.contentTypes.overrides.has(t))return e;let r=Ma(e.partBytes);if(r===null)return e;let o=ne(new TextDecoder().decode(r.bytes),{name:qr,contentType:"application/xml"});if(!o.ok)return e;let i=o.part.root.children.filter(d=>{if(d.kind==="textValue"||d.localName!=="Override")return true;let c=d.attributes.find(u=>u.localName==="PartName");return c===void 0||G(c.value)!==t});if(i.length===o.part.root.children.length)return e;let a=L(o.part,o.part.root.id,i);if(!a.ok)return e;let l=new Map(e.contentTypes.overrides);l.delete(t);let s=new Map(e.partBytes);return s.set(r.storageKey,new TextEncoder().encode(Fr(a.part))),Object.freeze({...e,partBytes:s,contentTypes:{defaults:e.contentTypes.defaults,overrides:l}})}function sp(e){if(!(e.kind==="textValue"||!("attributes"in e)))return e.attributes.find(n=>n.localName==="Id"&&n.namespaceUri==="")?.value}function _E(e,n){let t=new Set(it(e,n).map(o=>o.id)),r=e.parts.get(ot(n));if(r){let o=i=>{if(i.kind!=="textValue"&&i.localName==="Relationship"){let a=sp(i);a!==void 0&&a.length>0&&t.add(a);}if(i.kind!=="textValue")for(let a of i.children)o(a);};o(r.root);}return t}function DE(e,n){let t=_E(e,n),r=0;for(let i of t){let a=/^rId(\d+)$/.exec(i);a&&(r=Math.max(r,Number(a[1])));}let o=r+1;for(;t.has(`rId${o}`);)o+=1;return `rId${o}`}function ti(e,n){let t=xe(n);if(!t.ok)return e;let r=ot(t.partName);if(e.parts.has(r))return e;for(let a of e.partBytes.keys())if(G(a)===G(r))return e;let o=qs(`${r}#root`,$s,"Relationships",{},[{prefix:"",namespaceUri:$s}]);return D(e,{id:r,name:r,contentType:IE,root:o})}function Gt(e,n,t,r){let o=it(e,n),i=DE(e,n),a=ot(n),l=e.parts.get(a);if(!l)return {pkg:e,relationshipId:i,ok:false};let s=qs(lp(l,i),$s,"Relationship",{Id:i,Type:t,Target:r}),d=M(l,l.root.id,l.root.children.length,[s],{deferValidation:true});if(!d.ok)return {pkg:e,relationshipId:i,ok:false};let c=new Map(e.relationships);return c.set(n,[...o,{ownerPart:n,id:i,type:t,rawTarget:r,targetMode:"Internal",order:o.length}]),{pkg:Object.freeze({...D(e,d.part),relationships:c}),relationshipId:i,ok:true}}function cr(e,n,t,r){let o=ap(n);return o===null||vE(e,o)?e:Yr(D(e,{id:o,name:o,contentType:r,root:t}),o,r)}function UE(e){if(e.targetMode==="External")return null;let n=We(e.ownerPart,e.rawTarget);return n.ok?n.partName:null}function dp(e){let n=[];for(let[r,o]of e.relationships)for(let i of o){let a=UE(i);a!==null&&(e.parts.has(a)||e.partBytes.has(a)||n.push({code:"dangling-relationship",partName:a,ownerPart:r}));}let t=new Map;for(let r of e.parts.keys()){at(e,r)===null&&n.push({code:"missing-content-type",partName:r}),CE(r)&&n.push({code:"reserved-part-name",partName:r}),xe(r).ok||n.push({code:"unsafe-part-name",partName:r});let o=G(r),i=t.get(o);i!==void 0?n.push({code:"duplicate-part-name",partName:r,ownerPart:i}):t.set(o,r);}return n.length===0?{ok:true}:{ok:false,issues:n}}var mp="http://schemas.openxmlformats.org/package/2006/relationships",Zs="application/vnd.openxmlformats-package.relationships+xml",LE="http://schemas.openxmlformats.org/package/2006/content-types",cp=4096;function kt(e){let n=0;for(let t of e.relationships.values())for(let r of t){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(n=Math.max(n,Number(o[1])));}for(let t of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(t.id);r&&(n=Math.max(n,Number(r[1])));}return `rId${n+1}`}function oi(e){let n=e.lastIndexOf("/");return `${e.slice(0,n)}/_rels/${e.slice(n+1)}.rels`}function ur(e,n,t,r){if(!/^(header|footer|settings)\d*\.xml$/.test(r)&&r!=="settings.xml")return null;let o=e.mainDocumentPart,i=oi(o),a=e.parts.get(i),l=ne(`<Relationships xmlns="${mp}"><Relationship Id="${n}" Type="${t}" Target="${r}"/></Relationships>`,{name:i,contentType:Zs});if(!l.ok)return null;let s=e.relationships.get(o)??[];if(s.some(g=>g.id===n))return null;let d={ownerPart:o,id:n,type:t,rawTarget:r,targetMode:"Internal",order:s.reduce((g,p)=>Math.max(g,p.order),-1)+1},c=new Map([...e.relationships,[o,[...s,d]]]);if(!a)return Object.freeze({...e,parts:new Map([...e.parts,[i,l.part]]),relationships:c});let u=S(a),f=l.part.root.children[0];if(!f)return null;let m=M(a,a.root.id,a.root.children.length,[Dn(f,u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[i,m.part]]),relationships:c}):null}function Dn(e,n){return e.kind==="textValue"?{...e,id:n()}:{...e,id:n(),children:e.children.map(t=>Dn(t,n))}}function BE(e,n){if(!(e.kind==="textValue"||!("attributes"in e)))return e.attributes.find(t=>t.localName===n)?.value}function Qs(e,n){let t=e.mainDocumentPart,r=e.relationships.get(t)??[];if(!r.find(u=>u.id===n))return e;let i=r.filter(u=>u.id!==n),a=new Map([...e.relationships,[t,i]]),l=oi(t),s=e.parts.get(l);if(!s)return Object.freeze({...e,relationships:a});let d=s.root.children.find(u=>u.kind!=="textValue"&&u.localName==="Relationship"&&BE(u,"Id")===n);if(!d)return Object.freeze({...e,relationships:a});let c=oe(s,d.id);return c.ok?Object.freeze({...e,parts:new Map([...e.parts,[l,c.part]]),relationships:a}):null}function pp(e,n,t){if(n===t)return e;let r=e.relationships.get(n)??[],o=e.externalTargets.filter(p=>p.ownerPart===n),i=oi(n),a=oi(t),l=e.parts.get(i),s=e.partBytes.get(i);if(r.length===0&&o.length===0&&!l&&!s)return e;if(r.length>cp)return null;let d=[];for(let p of r){if(p.targetMode==="Internal"&&!We(t,p.rawTarget).ok)return null;d.push(Object.freeze({ownerPart:t,id:p.id,type:p.type,rawTarget:p.rawTarget,targetMode:p.targetMode,order:p.order}));}let c=new Set(d.map(p=>p.id)),u=[];for(let p of o){let x=Mr(p.rawTarget).ok;if(u.push(Object.freeze({ownerPart:t,id:p.id,type:p.type,rawTarget:p.rawTarget,sinkSafe:x})),!c.has(p.id)){if(d.length>=cp)return null;d.push(Object.freeze({ownerPart:t,id:p.id,type:p.type,rawTarget:p.rawTarget,targetMode:"External",order:d.length===0?0:d[d.length-1].order+1}));}}let f=e;if(l){let p=FE(l,a);if(!p)return null;f=Object.freeze({...f,parts:new Map([...f.parts,[a,p]])});}else if(d.length>0){let p=VE(a,d);if(!p)return null;f=Object.freeze({...f,parts:new Map([...f.parts,[a,p]])});}else s&&(f=Object.freeze({...f,partBytes:new Map([...f.partBytes,[a,s]])}));let m=new Map(f.relationships);d.length>0?m.set(t,Object.freeze(d)):m.delete(t);let g=u.length>0?Object.freeze([...f.externalTargets,...u]):f.externalTargets;return Object.freeze({...f,relationships:m,externalTargets:g})}function gp(e,n){let t=oi(n),r=new Map(e.parts);r.delete(t);let o=new Map(e.partBytes);o.delete(t);let i=new Map(e.relationships);i.delete(n);let a=Object.freeze(e.externalTargets.filter(l=>l.ownerPart!==n));return Object.freeze({...e,parts:r,partBytes:o,relationships:i,externalTargets:a})}function FE(e,n){let t=0,r=()=>(t+=1,`${n}#clone:${t}`),o=Dn(e.root,r);return o.kind==="textValue"?null:Object.freeze({id:`part:${n}`,name:n,contentType:Zs,root:o})}function VE(e,n){let t=n.map(o=>{let i=o.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${ri(o.id)}" Type="${ri(o.type)}" Target="${ri(o.rawTarget)}"${i}/>`}).join(""),r=ne(`<Relationships xmlns="${mp}">${t}</Relationships>`,{name:e,contentType:Zs});return r.ok?r.part:null}function bt(e,n,t){let r=G(n),o=e.contentTypes.overrides.get(r);if(o===t)return e;if(o!==void 0)return null;let i=Xs(e);if(i===null)return null;let a=strFromU8(i.bytes),l=_a(a);if(!l)return null;let s=`<Override PartName="${n}" ContentType="${t}"/>`,d=a.lastIndexOf(`</${l.rootName}>`);if(d===-1)return null;let c=a.slice(0,d)+s+a.slice(d),u=_a(c);if(!u||u.rootName!==l.rootName)return null;let f=[...l.children,hp("Override",{PartName:n,ContentType:t})];return u.children.length!==f.length||u.children.some((m,g)=>m!==f[g])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[i.storageKey,strToU8(c)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[r,t]])})})}function ii(e,n){let t=G(n);if(!e.contentTypes.overrides.has(t))return e;let r=Xs(e);if(r===null)return null;let o=strFromU8(r.bytes),i=_a(o);if(!i)return null;let a=tt(o);if(!a.ok)return null;let l=a.nodes.filter(p=>p.type==="element");if(l.length!==1)return null;let s=l[0],d=[],c=false;for(let p of s.children){if(p.type!=="element"){d.push(p);continue}if((p.name.includes(":")?p.name.slice(p.name.indexOf(":")+1):p.name)==="Override"&&(p.attributes.PartName===n||p.attributes.PartName?.toLowerCase()===t)){c=true;continue}d.push(p);}if(!c)return e;let u={...s,children:d},f=WE({...a,nodes:[u]},i.rootName);if(!f)return null;let m=_a(f);if(!m||m.rootName!==i.rootName||m.children.length!==i.children.length-1)return null;let g=new Map(e.contentTypes.overrides);return g.delete(t),Object.freeze({...e,partBytes:new Map([...e.partBytes,[r.storageKey,strToU8(f)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:g})})}function WE(e,n){let t=e.nodes.find(r=>r.type==="element"&&r.name===n);return t?'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+xp(t):null}function xp(e){let n=Object.entries(e.attributes).map(([r,o])=>` ${r}="${ri(o)}"`).join("");if(e.children.length===0)return `<${e.name}${n}/>`;let t=e.children.map(r=>r.type==="element"?xp(r):r.type==="text"?ri(r.value):"").join("");return `<${e.name}${n}>${t}</${e.name}>`}function ri(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function _a(e){let n=tt(e);if(!n.ok)return null;let t=n.nodes.filter(l=>l.type==="element");if(t.length!==1)return null;let r=t[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"]!==LE)return null;let a=[];for(let l of r.children)l.type==="element"&&a.push(hp(l.name,l.attributes));return {rootName:r.name,children:a}}function hp(e,n){let t=Object.entries(n).map(([r,o])=>`${r}=${o}`).sort();return [e,...t].join("")}var yp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",Op=4294967295,HE=Object.freeze({"image/png":"image/png","image/jpeg":"image/jpeg","image/gif":"image/gif","image/bmp":"image/bmp","image/webp":"image/webp"}),jE=Object.freeze({"image/png":"png","image/jpeg":"jpeg","image/gif":"gif","image/bmp":"bmp","image/webp":"webp"}),KE=new Set(["image/png","image/jpeg","image/jpg","image/gif","image/bmp","image/x-ms-bmp","image/x-bmp","image/webp","image/svg+xml","image/tiff","image/x-emf","image/x-wmf"]);function GE(e){return e.kind==="textValue"?false:e.kind==="drawingDocPr"?true:e.localName==="docPr"&&e.namespaceUri===yp}function $E(e){return e.localName==="id"&&e.namespaceUri===""}function zE(e){if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes)if($E(n))return n.value}}function XE(e){if(e===void 0)return null;let n=e.trim();if(n.length===0||(n.startsWith("+")&&(n=n.slice(1)),n.length===0))return null;for(let o=0;o<n.length;o+=1){let i=n.charCodeAt(o);if(i<48||i>57)return null}let t=n;for(;t.length>1&&t.startsWith("0");)t=t.slice(1);if(t.length>10)return null;let r=Number(t);return !Number.isInteger(r)||r<=0||r>Op?null:r}function Np(e,n){if(n(e),e.kind!=="textValue")for(let t of e.children)Np(t,n);}function qE(e){let n=0;for(let t of e.parts.values())Np(t.root,r=>{if(!GE(r))return;let o=XE(zE(r));o!==null&&(n=Math.max(n,o));});return n}function Qm(e){let n=qE(e)+1;return n<=0||n>Op?{ok:false,reason:"invalidArgs"}:{ok:true,id:n}}function mn(e){let n=xe(e);return n.ok?G(n.partName):null}function kp(e,n){let t=mn(n);if(t===null)return false;for(let r of e.parts.keys())if(mn(r)===t)return true;for(let r of e.partBytes.keys())if(mn(r)===t)return true;return false}function ed(e,n){for(let t of [...n.partBytes.keys(),...n.parts.keys()])if(t.startsWith("/"))return e;return e.startsWith("/")?e.slice(1):e}function Ua(e){return new Uint8Array(e)}function YE(e,n){if(e.length!==n.length)return false;for(let t=0;t<e.length;t+=1)if(e[t]!==n[t])return false;return true}function ZE(e,n){let t=mn(n);if(t===null)return null;for(let[r,o]of e.partBytes)if(mn(r)===t)return o;return null}function nd(e,n){let t=Ar();if(e.length===0||e.length>t.maxEncodedBytes||zr(e)!==n)return false;let r=ni(e,n);return !(!r||r.pixelWidth>t.maxDimension||r.pixelHeight>t.maxDimension||r.pixelWidth>Number.MAX_SAFE_INTEGER/r.pixelHeight||r.pixelWidth*r.pixelHeight>t.maxPixels)}async function La(e,n,t,r=Ar()){let o=Ua(n);if(!nd(o,t))return {ok:false,reason:"invalid-image"};let i=ni(o,t);if(!i)return {ok:false,reason:"invalid-image"};let a=Ua(o);try{let l=await e.decode(a,t,r);if(l.pixelWidth!==i.pixelWidth||l.pixelHeight!==i.pixelHeight||l.pixelWidth<=0||l.pixelHeight<=0||l.pixelWidth>r.maxDimension||l.pixelHeight>r.maxDimension||l.pixelWidth*l.pixelHeight>r.maxPixels)return {ok:!1,reason:"invalid-image"}}catch{return {ok:false,reason:"invalid-image"}}return {ok:true,bytes:o}}function QE(e,n){for(let t=1;t<=Number.MAX_SAFE_INTEGER;t+=1){let r=`/word/media/image${t}.${n}`;if(!kp(e,r))return ed(r,e)}return null}function JE(e){let n=xe(e);if(!n.ok)return null;let t=n.partName;return t.startsWith("/word/media/")?t.slice(6):null}function bp(e,n,t){return Kr(e).some(r=>{if(r.ownerPartName!==n)return false;let o=r.picture?.embeddedRelationshipId,i=r.picture?.linkedRelationshipId;return o===t||i===t})}function eR(e,n,t){let r=e.relationships.get(n)??[],o=_r(r,n,t);return o.mode==="internal"?o.partName:null}function nR(e,n){let t=mn(n);if(t===null)return false;for(let r of e.relationships.values())for(let o of r){if(o.targetMode==="External")continue;let i=We(o.ownerPart,o.rawTarget);if(i.ok&&mn(i.partName)===t)return true}return false}function Pp(e,n){let t=mn(n);if(t===null)return 0;let r=0;for(let o of Kr(e)){let i=o.picture?.embeddedRelationshipId;if(!i)continue;let a=eR(e,o.ownerPartName,i);a!==null&&mn(a)===t&&(r+=1);}return r}function tR(e,n){let t=xe(n);if(!t.ok||!t.partName.startsWith("/word/media/"))return false;let r=Bt(e.contentTypes,t.partName);return r.ok?KE.has(r.contentType.toLowerCase()):false}function Jm(e,n,t,r){let o=xe(n);if(!o.ok)return e;let i=ed(o.partName,e),a=Ua(t),l=ZE(e,o.partName);if(l!==null&&YE(l,a))return Yr(e,o.partName,r,{forceOverride:true});let s=new Map(e.partBytes);s.set(i,a);let d=new Map(e.parts),c=mn(i);for(let u of [...d.keys()])c!==null&&mn(u)===c&&d.delete(u);return Yr(Object.freeze({...e,partBytes:s,parts:d}),o.partName,r,{forceOverride:true})}function Xr(e,n,t){let r=xe(n);if(!r.ok)return {ok:false,reason:"invalidArgs"};let o=r.partName;if(!e.parts.has(o))return {ok:false,reason:"invalidArgs"};if(!nd(t.bytes,t.mime))return {ok:false,reason:"invalid-image"};let i=Qm(e);if(!i.ok)return {ok:false,reason:"invalidArgs"};let a=jE[t.mime],l=QE(e,a);if(l===null)return {ok:false,reason:"invalidArgs"};let s=HE[t.mime],d=Jm(e,l,t.bytes,s),c=JE(l);if(c===null)return {ok:false,reason:"invalidArgs"};let u=Gt(ti(d,o),o,la,c);return u.ok?(d=u.pkg,Object.freeze({ok:true,pkg:d,partName:l,relationshipId:u.relationshipId,docPrId:i.id})):{ok:false,reason:"invalidArgs"}}var rR=12700;function td(e){if(!Number.isFinite(e)||e<=0)return null;let n=Math.round(e*rR);return n<=0||n>jo?null:n}var oR="http://schemas.openxmlformats.org/wordprocessingml/2006/main",iR="http://schemas.openxmlformats.org/drawingml/2006/main",aR="http://schemas.openxmlformats.org/drawingml/2006/picture",lR="http://schemas.openxmlformats.org/officeDocument/2006/relationships",sR="http://schemas.openxmlformats.org/drawingml/2006/picture";function wp(e,n){if(n(e),e.kind!=="textValue")for(let t of e.children)wp(t,n);}function dR(e){let n=null;return wp(e.root,t=>{n===null&&t.kind==="drawing"&&(n=t);}),n}function Ep(e){let n=Math.round(e.extentEmu.cx),t=Math.round(e.extentEmu.cy),r=[`id="${e.docPrId}"`,'name=""'];e.title&&e.title.length>0&&r.push(`title="${Da(e.title)}"`),e.description&&e.description.length>0&&r.push(`descr="${Da(e.description)}"`);let o=e.hyperlinkRelationshipId?`<a:hlinkClick r:id="${Da(e.hyperlinkRelationshipId)}"/>`:"",i=`<w:document xmlns:w="${oR}" xmlns:wp="${yp}" xmlns:a="${iR}" xmlns:pic="${aR}" xmlns:r="${lR}"><w:body><w:p><w:r><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${n}" cy="${t}"/><wp:docPr ${r.join(" ")}>${o}</wp:docPr><wp:cNvGraphicFramePr/><a:graphic><a:graphicData uri="${sR}"><pic:pic><pic:nvPicPr><pic:cNvPr id="0" name="" descr=""/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${Da(e.relationshipId)}"/><a:srcRect/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${n}" cy="${t}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic></wp:inline></w:drawing></w:r></w:p></w:body></w:document>`,a=ne(i,{name:"/word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"});if(!a.ok)throw new Error(`buildInlinePictureDrawing: ${a.reason}`);let l=dR(a.part);if(!l||l.kind!=="drawing")throw new Error("buildInlinePictureDrawing: missing drawing");return l}function Da(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function ep(e,n){let t=xe(n);if(!t.ok||!tR(e,t.partName)||Pp(e,t.partName)>0||nR(e,t.partName))return e;let r=ed(t.partName,e),o=new Map(e.partBytes),i=mn(r),a=false;if(i!==null)for(let d of [...o.keys()])mn(d)===i&&(o.delete(d),a=true);if(!a&&!kp(e,t.partName))return e;let l=new Map(e.parts);if(i!==null)for(let d of [...l.keys()])mn(d)===i&&l.delete(d);let s=Object.freeze({...e,partBytes:o,parts:l});return ii(s,t.partName)??s}function cR(e,n){if(!(e.kind==="textValue"||!("attributes"in e)))return e.attributes.find(t=>t.localName===n&&t.namespaceUri==="")?.value}function uR(e,n,t){let r=e.relationships.get(n)??[];if(!r.find(u=>u.id===t))return e;let i=r.filter(u=>u.id!==t),a=new Map([...e.relationships,[n,i]]),l=ot(n),s=e.parts.get(l);if(!s)return Object.freeze({...e,relationships:a});let d=s.root.children.find(u=>u.kind!=="textValue"&&u.localName==="Relationship"&&cR(u,"Id")===t);if(!d)return Object.freeze({...e,relationships:a});let c=oe(s,d.id);return c.ok?Object.freeze({...e,parts:new Map([...e.parts,[l,c.part]]),relationships:a}):null}function fR(e,n,t){if(bp(e,n,t))return e;let r=e.externalTargets.filter(o=>!(o.ownerPart===n&&o.id===t));return r.length===e.externalTargets.length?e:Object.freeze({...e,externalTargets:Object.freeze(r)})}function rd(e,n,t,r){let o=e;if(r!==null&&!bp(o,n,r)){let i=uR(o,n,r);i!==null&&(o=i);}return t!==null&&Pp(o,t)===0&&(o=ep(o,t)),r!==null&&(o=fR(o,n,r)),o}function mR(e){let n=e.toLowerCase().replace(/^\[/,"").replace(/\]$/,"");if(n==="localhost"||n.endsWith(".localhost")||n.endsWith(".local")||n==="::1"||n==="0:0:0:0:0:0:0:1"||n.startsWith("fe80:")||n.startsWith("fc")||n.startsWith("fd")||n.startsWith("ff"))return true;let t=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(n);if(t){let r=Number(t[1]),o=Number(t[2]);if(r===10||r===127||r===0||r===169&&o===254||r===172&&o>=16&&o<=31||r===192&&o===168||r>=224)return true}return false}function Js(e){let n;try{n=new URL(e);}catch{return {ok:false,detail:"relative-url"}}return n.protocol!=="https:"?{ok:false,detail:"https-only"}:n.username.length>0||n.password.length>0?{ok:false,detail:"embedded-credentials"}:mR(n.hostname)?{ok:false,detail:"private-network"}:{ok:true,href:n.href}}function pR(e,n){try{return new URL(n,e).href}catch{return null}}function gR(e){let n=0;for(let o of e)n+=o.length;let t=new Uint8Array(n),r=0;for(let o of e)t.set(o,r),r+=o.length;return t}function xR(e){if(!e)return "unknown";let n=e.split(";")[0]?.trim().toLowerCase()??"";return n==="image/png"?"image/png":n==="image/jpeg"||n==="image/jpg"?"image/jpeg":n==="image/gif"?"image/gif":"unknown"}async function Rp(e,n,t,r=Ar(),o){if(typeof e.requestPublicHttps!="function")return {ok:false,reason:"fetch-refused",detail:"atomic-fetch-port-required"};let i=Js(n);if(!i.ok)return {ok:false,reason:"fetch-refused",detail:i.detail};let a=i.href,l=0;for(;;){if(t.aborted)return {ok:false,reason:"fetch-refused",detail:"aborted"};let s=Js(a);if(!s.ok)return {ok:false,reason:"fetch-refused",detail:s.detail};a=s.href;let d;try{d=await e.requestPublicHttps(a,{redirect:"manual",signal:t});}catch{return {ok:false,reason:"fetch-refused",detail:"network-error"}}if(d.connectedUrl!==a)return {ok:false,reason:"fetch-refused",detail:"connected-url-mismatch"};if(d.status>=300&&d.status<400&&d.location){if(l>=r.maxExternalRedirects)return {ok:false,reason:"fetch-refused",detail:"redirect-limit"};let p=pR(a,d.location);if(p===null)return {ok:false,reason:"fetch-refused",detail:"bad-redirect"};let x=Js(p);if(!x.ok)return {ok:false,reason:"fetch-refused",detail:x.detail};a=x.href,l+=1;continue}if(d.status!==200)return {ok:false,reason:"fetch-refused",detail:`status-${d.status}`};let c=[],u=0;try{for await(let p of d.body){if(t.aborted)return {ok:!1,reason:"fetch-refused",detail:"aborted"};if(u+=p.length,u>r.maxEncodedBytes)return {ok:!1,reason:"invalid-image",detail:"byte-limit"};c.push(p);}}catch{return {ok:false,reason:"fetch-refused",detail:"network-error"}}let f=gR(c),m=zr(f);if(m!=="image/png"&&m!=="image/jpeg"&&m!=="image/gif")return {ok:false,reason:"invalid-image",detail:"unsupported-format"};let g=xR(d.contentType);if(g!=="unknown"&&g!==m)return {ok:false,reason:"invalid-image",detail:"content-type-spoof"};if(!nd(f,m))return {ok:false,reason:"invalid-image",detail:"invalid-bytes"};if(o){let p=await La(o,f,m,r);return p.ok?{ok:true,bytes:p.bytes,mime:m}:{ok:false,reason:"invalid-image",detail:"invalid-bytes"}}return {ok:true,bytes:Ua(f),mime:m}}}function Un(e){switch(e.kind){case "fallback":return false;case "text":return !/[{}[\]^_√∑]/u.test(e.value);case "row":return e.items.every(Un);case "fraction":return Un(e.numerator)&&Un(e.denominator);case "radical":return Un(e.radicand)&&(!e.degree||Un(e.degree));case "script":return Un(e.base)&&(!e.subscript||Un(e.subscript))&&(!e.superscript||Un(e.superscript));case "nary":return e.operator==="\u2211"&&Un(e.body)&&(!e.lowerLimit||Un(e.lowerLimit))&&(!e.upperLimit||Un(e.upperLimit))}}function bn(e){switch(e.kind){case "row":return e.items.map(bn).join("");case "text":return e.value;case "fallback":return e.text;case "fraction":return `{${bn(e.numerator)}}/{${bn(e.denominator)}}`;case "radical":return `\u221A${e.degree?`[${bn(e.degree)}]`:""}{${bn(e.radicand)}}`;case "script":return bn(e.base)+(e.subscript?`_{${bn(e.subscript)}}`:"")+(e.superscript?`^{${bn(e.superscript)}}`:"");case "nary":return e.operator+(e.lowerLimit?`[${bn(e.lowerLimit)}]`:"")+(e.upperLimit?`^[${bn(e.upperLimit)}]`:"")+`{${bn(e.body)}}`}}function Ip(e,n){if(!Un(e))return "";let t=bn(e),r=n(t);return r.ok&&bn(r.expression)===t?t:""}var $t="http://schemas.openxmlformats.org/officeDocument/2006/math",Fa=Object.freeze({maxDepth:24,maxNodes:256,maxTextLength:512}),Tp=new WeakMap,hR=64,ai=new Map,Cp=new WeakMap;function Mp(e){let n=(t,r)=>Number.isSafeInteger(t)&&t>0?t:r;return {maxDepth:n(e?.maxDepth,Fa.maxDepth),maxNodes:n(e?.maxNodes,Fa.maxNodes),maxTextLength:n(e?.maxTextLength,Fa.maxTextLength)}}function fr(e,n){return e.kind==="generic"&&e.namespaceUri===$t&&(n===void 0||e.localName===n)}function yR(e){return e.length===1?e[0]:Object.freeze({kind:"row",items:Object.freeze([...e])})}function Re(e){return e.children}function ad(e,n){let t=e.limits.maxTextLength-e.text.length;if(t<=0)return n.length>0&&(e.truncated=true),"";let r=n.slice(0,t);return e.text+=r,r.length!==n.length&&(e.truncated=true),r}function _p(e,n){return n>e.limits.maxDepth||e.visitedNodes>=e.limits.maxNodes?(e.truncated=true,false):(e.visitedNodes+=1,true)}function Ba(e,n,t){let r=n.text.length;ld(e,n,t);let o=n.text.slice(r);return Object.freeze({kind:"fallback",text:o||(n.truncated?"\u2026":"")})}function ld(e,n,t){if(_p(n,t)){if(e.kind==="textValue"){ad(n,e.value);return}for(let r of Re(e))if(ld(r,n,t+1),n.truncated&&n.text.length>=n.limits.maxTextLength)return}}function De(e,n){for(let t of Re(e))if(fr(t,n))return t;return null}function Pt(e,n){return Re(e).filter(t=>fr(t,n))}function Zr(e,n){if(e.attributes.length>0)return false;let t=new Map;for(let r of Re(e)){if(!fr(r)||n[r.localName]===void 0)return false;t.set(r.localName,(t.get(r.localName)??0)+1);}return Object.entries(n).every(([r,o])=>{let i=t.get(r)??0;return i>=o.min&&i<=o.max})}function Va(e){return e.attributes.length===0&&Re(e).length===0}function OR(e){return e.attributes.find(n=>n.namespaceUri===$t&&n.localName==="val")?.value}function od(e,n){if(Re(e).length>0||e.attributes.length!==1)return false;let t=OR(e);return t!==void 0&&(n===void 0||n.has(t))}function NR(e){if(e.attributes.length>0)return false;let n=Pt(e,"rPr"),t=Pt(e,"t");return n.length>1||t.length===0||n[0]&&!Va(n[0])||n.length+t.length!==Re(e).length?false:t.every(r=>r.attributes.every(o=>o.namespaceUri===X&&o.localName==="space"&&(o.value==="preserve"||o.value==="default"))&&Re(r).every(o=>o.kind==="textValue"))}function wt(e){if(e.kind==="textValue")return true;if(!fr(e))return false;if(e.localName==="r")return NR(e);if(e.localName==="t")return e.attributes.every(n=>n.namespaceUri===X&&n.localName==="space"&&(n.value==="preserve"||n.value==="default"))&&Re(e).every(n=>n.kind==="textValue");if(e.localName==="f"){if(!Zr(e,{fPr:{min:0,max:1},num:{min:1,max:1},den:{min:1,max:1}}))return false;let n=De(e,"fPr");return (!n||Va(n))&&Re(Pt(e,"num")[0]).every(wt)&&Re(Pt(e,"den")[0]).every(wt)}if(e.localName==="rad"){if(!Zr(e,{radPr:{min:0,max:1},deg:{min:1,max:1},e:{min:1,max:1}}))return false;let n=Pt(e,"deg")[0],t=De(e,"radPr");return (!t||Va(t)||Re(n).length===0&&Zr(t,{degHide:{min:1,max:1}})&&od(Pt(t,"degHide")[0],new Set(["1","true","on"])))&&Re(n).every(wt)&&Re(Pt(e,"e")[0]).every(wt)}if(e.localName==="sSup"||e.localName==="sSub"||e.localName==="sSubSup"){let n=`${e.localName}Pr`,t={[n]:{min:0,max:1},e:{min:1,max:1},sub:{min:e.localName==="sSup"?0:1,max:e.localName==="sSup"?0:1},sup:{min:e.localName==="sSub"?0:1,max:e.localName==="sSub"?0:1}};if(!Zr(e,t))return false;let r=De(e,n);return (!r||Va(r))&&["e","sub","sup"].every(o=>Pt(e,o).every(i=>Re(i).every(wt)))}if(e.localName==="nary"){if(!Zr(e,{naryPr:{min:0,max:1},sub:{min:0,max:1},sup:{min:0,max:1},e:{min:1,max:1}}))return false;let n=De(e,"naryPr");if(n){if(!Zr(n,{chr:{min:0,max:1},limLoc:{min:0,max:1}}))return false;let t=De(n,"chr"),r=De(n,"limLoc");if(t&&!od(t)||r&&!od(r,new Set(["undOvr"])))return false}return ["e","sub","sup"].every(t=>Pt(e,t).every(r=>Re(r).every(wt)))}return false}function Pn(e,n,t,r){let o=[];for(let i of Re(e))r&&fr(i,r)||o.push(Dp(i,n,t+1));return yR(o)}function kR(e,n,t){if(!wt(e))return null;if(e.localName==="f"){let r=De(e,"num"),o=De(e,"den");return !r||!o?null:Object.freeze({kind:"fraction",numerator:Pn(r,n,t+1),denominator:Pn(o,n,t+1)})}if(e.localName==="rad"){let r=De(e,"e");if(!r)return null;let o=De(e,"deg"),i=o&&Re(o).length>0?Pn(o,n,t+1):void 0;return Object.freeze({kind:"radical",radicand:Pn(r,n,t+1),...i===void 0?{}:{degree:i}})}if(e.localName==="sSup"||e.localName==="sSub"||e.localName==="sSubSup"){let r=De(e,"e"),o=e.localName==="sSup"?null:De(e,"sub"),i=e.localName==="sSub"?null:De(e,"sup");return !r||e.localName!=="sSup"&&!o||e.localName!=="sSub"&&!i?null:Object.freeze({kind:"script",base:Pn(r,n,t+1),...o?{subscript:Pn(o,n,t+1)}:{},...i?{superscript:Pn(i,n,t+1)}:{}})}if(e.localName==="nary"){let r=De(e,"e");if(!r)return null;let o=De(e,"sub"),i=De(e,"sup"),a=De(e,"naryPr"),s=(a?De(a,"chr"):null)?.attributes.find(d=>d.namespaceUri===$t&&d.localName==="val")?.value??"\u2211";return Object.freeze({kind:"nary",operator:ad(n,s),body:Pn(r,n,t+1),...o&&Re(o).length>0?{lowerLimit:Pn(o,n,t+1)}:{},...i&&Re(i).length>0?{upperLimit:Pn(i,n,t+1)}:{}})}return null}function Dp(e,n,t){return _p(n,t)?e.kind==="textValue"?Object.freeze({kind:"text",value:ad(n,e.value)}):fr(e)?e.localName==="oMath"?Pn(e,n,t):e.localName==="r"?wt(e)?Pn(e,n,t,"rPr"):Ba(e,n,t+1):e.localName==="t"?wt(e)?Pn(e,n,t):Ba(e,n,t+1):kR(e,n,t)??Ba(e,n,t+1):Ba(e,n,t+1):Object.freeze({kind:"fallback",text:"\u2026"})}function E1(e,n){if(!fr(e,"oMath"))return null;let t=n===void 0?Tp.get(e):void 0;if(t)return t;let r=d=>(n===void 0&&Tp.set(e,d),d),o=Mp(n),i={limits:o,visitedNodes:0,text:"",truncated:false};ld(e,i,1);let a=i.text+(i.truncated?"\u2026":"");if(i.truncated)return r(Object.freeze({sourceNodeId:e.id,expression:Object.freeze({kind:"fallback",text:a||"\u2026"}),fallbackText:a,truncated:true,visitedNodes:i.visitedNodes}));let l={limits:{...o,maxNodes:Number.MAX_SAFE_INTEGER},visitedNodes:0,text:"",truncated:false},s=Dp(e,l,1);if(l.truncated){let d=l.text+"\u2026";return r(Object.freeze({sourceNodeId:e.id,expression:Object.freeze({kind:"fallback",text:d}),fallbackText:d,truncated:true,visitedNodes:i.visitedNodes}))}return r(Object.freeze({sourceNodeId:e.id,expression:s,fallbackText:a,truncated:false,visitedNodes:i.visitedNodes}))}var fe=class extends Error{constructor(t){super(t);this.reason=t;}reason},id=class{constructor(n,t){this.input=n;this.limits=t;}input;limits;index=0;nodes=0;parse(){if(this.input.length===0)throw new fe("empty");if(this.input.length>this.limits.maxTextLength)throw new fe("text-limit");if(!$(this.input))throw new fe("invalid-xml-text");let n=this.sequence(void 0,1);if(this.index!==this.input.length)throw new fe("invalid-syntax");return n}make(n,t){if(t>this.limits.maxDepth)throw new fe("depth-limit");if(this.nodes+=1,this.nodes>this.limits.maxNodes)throw new fe("node-limit");return Object.freeze(n)}sequence(n,t){if(t>this.limits.maxDepth)throw new fe("depth-limit");let r=[];for(;this.index<this.input.length&&this.input[this.index]!==n;){if(this.input[this.index]==="}"||this.input[this.index]==="]")throw new fe("invalid-syntax");r.push(this.scripted(t+1));}if(n!==void 0){if(this.input[this.index]!==n)throw new fe("invalid-syntax");this.index+=1;}return r.length===0?this.make({kind:"row",items:Object.freeze([])},t):r.length===1?r[0]:this.make({kind:"row",items:Object.freeze(r)},t)}scripted(n){let t=this.input[this.index]==="{",r=this.primary(n+1),o,i,a;for(;this.input[this.index]==="^"||this.input[this.index]==="_";){let l=this.input[this.index++],s=this.scriptOperand(n+1);if(l==="^"){if(a)throw new fe("invalid-syntax");a=s;}else {if(i)throw new fe("invalid-syntax");i=s;}}if(i||a){if(!t&&r.kind==="text"){let l=Array.from(r.value);l.length>1&&(o=this.make({kind:"text",value:l.slice(0,-1).join("")},n+1),r=this.make({kind:"text",value:l.at(-1)},n+1));}r=this.make({kind:"script",base:r,...i===void 0?{}:{subscript:i},...a===void 0?{}:{superscript:a}},n);}return o?this.make({kind:"row",items:[o,r]},n):r}scriptOperand(n){if(this.input[this.index]==="{")return this.braced(n+1);let t=this.codePoint();if(t===null||"^_{}[]".includes(t))throw new fe("invalid-syntax");return this.make({kind:"text",value:t},n)}braced(n){if(this.input[this.index]!=="{")throw new fe("invalid-syntax");this.index+=1;let t=this.sequence("}",n+1);if(t.kind==="row"&&t.items.length===0)throw new fe("invalid-syntax");return t}primary(n){if(this.input[this.index]==="{"){let r=this.braced(n+1);if(this.input[this.index]==="/"&&this.input[this.index+1]==="{"){this.index+=1;let o=this.braced(n+1);return this.make({kind:"fraction",numerator:r,denominator:o},n)}return r}if(this.input[this.index]==="\u221A"){this.index+=1;let r;if(this.input[this.index]==="["&&(this.index+=1,r=this.sequence("]",n+1),r.kind==="row"&&r.items.length===0))throw new fe("invalid-syntax");if(this.input[this.index]!=="{")throw new fe("invalid-syntax");return this.make({kind:"radical",radicand:this.braced(n+1),...r===void 0?{}:{degree:r}},n)}if(this.input[this.index]==="\u2211"){this.index+=1;let r,o;if(this.input[this.index]==="["&&(this.index+=1,r=this.sequence("]",n+1),r.kind==="row"&&r.items.length===0))throw new fe("invalid-syntax");if(this.input[this.index]==="^"){if(this.index+=1,this.input[this.index]!=="[")throw new fe("invalid-syntax");if(this.index+=1,o=this.sequence("]",n+1),o.kind==="row"&&o.items.length===0)throw new fe("invalid-syntax")}if(this.input[this.index]!=="{")throw new fe("invalid-syntax");return this.make({kind:"nary",operator:"\u2211",body:this.braced(n+1),...r===void 0?{}:{lowerLimit:r},...o===void 0?{}:{upperLimit:o}},n)}let t=this.index;for(;this.index<this.input.length;){let r=this.input[this.index];if("{}[]^_\u221A\u2211".includes(r))break;this.index+=1;}if(this.index===t)throw new fe("invalid-syntax");return this.make({kind:"text",value:this.input.slice(t,this.index)},n)}codePoint(){if(this.index>=this.input.length)return null;let n=this.input.codePointAt(this.index);if(n===void 0)return null;let t=String.fromCodePoint(n);return this.index+=t.length,t}};function Wa(e,n){let t=n===void 0&&e.length<=Fa.maxTextLength,r=t?ai.get(e):void 0;if(r)return r;let o;try{o=Object.freeze({ok:!0,expression:new id(e,Mp(n)).parse()});}catch(i){o=Object.freeze({ok:false,reason:i instanceof fe?i.reason:"invalid-syntax"});}if(t){if(ai.size>=hR){let i=ai.keys().next().value;i!==void 0&&ai.delete(i);}ai.set(e,o);}return o}function R1(e){let n=Cp.get(e);if(n!==void 0)return n;let t=Ip(e,Wa);return Cp.set(e,t),t}function vp(e,n){return Object.freeze({kind:"genericExtension",namespaceUri:$t,localName:e,prefix:"m",value:n})}function Sp(e,n){return Object.freeze({id:n(),kind:"textValue",value:e})}function Ap(e){return /^\s|\s$/.test(e)?[Object.freeze({kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:"preserve"})]:[]}function ce(e,n,t,r=[]){return Object.freeze({id:t(),kind:"generic",namespaceUri:$t,localName:e,prefix:"m",namespaceBindings:Object.freeze([]),attributes:Object.freeze([...r]),children:Object.freeze([...n])})}function pn(e,n){switch(e.kind){case "row":return e.items.flatMap(t=>pn(t,n));case "text":return [ce("r",[ce("t",[Sp(e.value,n)],n,Ap(e.value))],n)];case "fallback":return [ce("r",[ce("t",[Sp(e.text,n)],n,Ap(e.text))],n)];case "fraction":return [ce("f",[ce("num",pn(e.numerator,n),n),ce("den",pn(e.denominator,n),n)],n)];case "radical":return [ce("rad",[ce("deg",e.degree?pn(e.degree,n):[],n),ce("e",pn(e.radicand,n),n)],n)];case "script":{if(e.subscript&&e.superscript)return [ce("sSubSup",[ce("e",pn(e.base,n),n),ce("sub",pn(e.subscript,n),n),ce("sup",pn(e.superscript,n),n)],n)];let t=e.superscript!==void 0,r=t?e.superscript:e.subscript;return [ce(t?"sSup":"sSub",[ce("e",pn(e.base,n),n),ce(t?"sup":"sub",pn(r,n),n)],n)]}case "nary":return [ce("nary",[ce("naryPr",[ce("chr",[],n,[vp("val",e.operator)]),ce("limLoc",[],n,[vp("val","undOvr")])],n),ce("sub",e.lowerLimit?pn(e.lowerLimit,n):[],n),ce("sup",e.upperLimit?pn(e.upperLimit,n):[],n),ce("e",pn(e.body,n),n)],n)]}}function bR(e,n){let t=ce("oMath",pn(e,n),n);return Object.freeze({...t,namespaceBindings:Object.freeze([Object.freeze({prefix:"m",namespaceUri:$t})])})}function Up(e,n,t){let r=Wa(e,t);return r.ok?Object.freeze({ok:true,expression:r.expression,equation:bR(r.expression,n)}):r}var mr=32;function Lp(e){return e.kind}function Qe(e){return e.kind==="textValue"?false:Lp(e)==="contentControl"?true:e.kind==="generic"&&e.localName==="sdt"&&e.namespaceUri===O}function ja(e){return e.kind==="textValue"?false:Lp(e)==="contentControlContent"?true:e.kind==="generic"&&e.localName==="sdtContent"&&e.namespaceUri===O}function li(e){if(e.kind==="textValue"||!Qe(e))return null;for(let n of e.children)if(n.kind!=="textValue"&&ja(n))return n.children;return null}function sd(e){if(e.kind==="textValue"||!Qe(e))return [];let n=[];for(let t of e.children)if(t.kind!=="textValue"&&ja(t))for(let r of t.children)n.push(r);return n}function C1(e,n=0,t=()=>true){let r=[],o=(i,a)=>{for(let l of i)if(l.kind!=="textValue"){if(l.kind==="paragraph"||l.kind==="table"){t(l)&&r.push(l);continue}Qe(l)&&a<mr&&o(sd(l),a+1);}};return o(e,n),r}function dd(e,n,t){for(let r of e)if(r.kind!=="textValue"){if(r.kind==="paragraph"||r.kind==="table"){t(r);continue}if(Qe(r)&&n<mr){let o=li(r);o&&dd(o,n+1,t);}}}function Ha(e,n,t){for(let r of e)if(r.kind!=="textValue"){if(r.kind==="paragraph")t(r);else if(r.kind==="table"){for(let o of r.children)if(o.kind==="tableRow")for(let i of o.children)i.kind==="tableCell"&&Ha(i.children,n,t);}else if(Qe(r)&&n<mr){let o=li(r);o&&Ha(o,n+1,t);}}}function zt(e,n,t){for(let r of e)if(!(r.kind==="textValue"||r.kind==="paragraphProperties")){if(r.kind==="run"){t(r);continue}if(r.kind==="hyperlink"){n<mr&&zt(r.children,n+1,t);continue}if(Qe(r)){if(n<mr){let o=li(r);o&&zt(o,n+1,t);}continue}t(r);}}var PR="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",wR="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",ER="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",Bp=Object.freeze([]),cd=4096,RR=Object.freeze({headers:new Map,footers:new Map,evenAndOddHeaders:false,titlePage:false});function fd(e){return e.kind==="textValue"?[]:e.children}function ud(e,n){return e.attributes.find(t=>t.localName===n)?.value}function IR(e){return e==="default"||e==="first"||e==="even"?e:null}function Ka(e,n){for(let t of fd(e))if(t.kind!=="textValue"&&t.localName===n)return t}function jp(e){if(e.kind!=="textValue"){if(e.kind==="body"||e.localName==="body")return e;for(let n of e.children){let t=jp(n);if(t)return t}}}function TR(e){let n=e.children.find(t=>t.kind==="paragraphProperties")??Ka(e,"pPr");if(!(!n||n.kind==="textValue"))return Ka(n,"sectPr")}var Fp=new WeakMap;function CR(e){let n=Fp.get(e);if(n)return n;let t=0,r=false,o=[];dd([e],0,a=>{t+=1;let l=a.kind==="paragraph"?TR(a):void 0;r=l!==void 0,l&&o.length<cd&&o.push(l);});let i=Object.freeze({blockCount:t,sectionProperties:Object.freeze(o),lastBlockEndsSection:r});return Fp.set(e,i),i}function Et(e){let n=jp(e);if(!n)return [];let t=[],r=0,o=false;for(let i of n.children){let a=CR(i);if(a.blockCount!==0){r+=a.blockCount;for(let l of a.sectionProperties){if(t.length>=cd)return t;t.push(l);}o=a.lastBlockEndsSection;}}if(t.length>=cd)return t;if(r===0||!o)t.push(Ka(n,"sectPr")??null);else {let i=Ka(n,"sectPr");i&&t.push(i);}return t}function vR(e,n){let t=new Map,r=new Map;for(let o of fd(e)){if(o.kind==="textValue")continue;let i=o.localName==="headerReference",a=o.localName==="footerReference";if(!i&&!a)continue;let l=IR(ud(o,"type"));if(!l)continue;let s=n(ud(o,"id"),i?PR:wR);if(!s)continue;let d=i?t:r;d.has(l)||d.set(l,s);}return {headers:t,footers:r,titlePage:Xo(e,"titlePg")}}function Vp(e,n){let t=new Map;if(e)for(let[r,o]of e)t.set(r,{...o,inherited:true});for(let[r,o]of n)t.set(r,{part:o.part,partName:o.part.name,rId:o.rId,inherited:false});return t}function Wp(e){let n=new Map;for(let[t,r]of e)n.set(t,r.part);return n}function SR(e){return e.map(n=>({headers:Wp(n.headers),footers:Wp(n.footers),evenAndOddHeaders:n.evenAndOddHeaders,titlePage:n.titlePage}))}var Hp=new WeakMap;function AR(e,n){return e.length===n.length&&e.every((t,r)=>t===n[r])}function MR(e){let n=new Set;for(let t of e)for(let r of [t.headers,t.footers])for(let o of r.values())n.add(o.part);return [...n]}function Kp(e){let n=e.parts.get(e.mainDocumentPart);if(!n)return null;let t=e.relationships.get(e.mainDocumentPart),r=t??Bp,o=DR(e,r),i=Et(n.root),a=t??i.find(g=>g!==null)??Bp,l=Hp.get(a);if(l&&l.evenAndOddHeaders===o&&AR(l.sectionProperties,i)&&l.slotParts.every(g=>e.parts.get(g.name)===g))return l;let s=(g,p)=>{if(!g)return;let x=r.find(b=>b.id===g&&b.type===p);if(!x)return;let y=Me(x);if(y.mode!=="Internal"||!y.target.ok)return;let N=e.parts.get(y.target.partName);return N?{part:N,rId:g}:void 0},d=[],c,u=i.length>0?i:[null];for(let g of u){let p=g?vR(g,s):{headers:new Map,footers:new Map,titlePage:false},x={headers:Vp(c?.headers,p.headers),footers:Vp(c?.footers,p.footers),evenAndOddHeaders:o,titlePage:p.titlePage};d.push(x),c=x;}let f=Object.freeze(d),m=Object.freeze({sectionProperties:i,evenAndOddHeaders:o,slotParts:Object.freeze(MR(f)),resolution:f,parts:Object.freeze(SR(f))});return Hp.set(a,m),m}function si(e){return Kp(e)?.resolution??[]}function _R(e){return Kp(e)?.parts??[]}function _1(e){let n=_R(e);return n[n.length-1]??RR}function DR(e,n){let t=n.find(i=>i.type===ER);if(!t)return false;let r=Me(t);if(r.mode!=="Internal"||!r.target.ok)return false;let o=e.parts.get(r.target.partName);if(!o)return false;for(let i of fd(o.root)){if(i.kind==="textValue"||i.localName!=="evenAndOddHeaders")continue;let a=ud(i,"val");return a!=="0"&&a!=="false"}return false}var UR="\f";function Gp(e){for(let n of e.attributes)if(!(n.namespaceUri!==O||n.localName!=="type"))switch(n.value){case "page":return "page";case "column":return "column";case "textWrapping":return "line";default:return "other"}return "line"}function L1(e){return e.kind==="hardBreak"&&Gp(e)==="page"}function Ga(e){return Gp(e)==="page"?UR:`
9
- `}function $p(e){return e==="line"?[]:[{kind:"genericExtension",namespaceUri:O,localName:"type",prefix:"w",value:"page"}]}var LR="\uFFFC",BR=new Set(["begin","separate","end"]);function pr(e,n){if(!(e.kind==="textValue"||!("attributes"in e))){for(let t of e.attributes)if(t.namespaceUri===O&&t.localName===n||t.namespaceUri===""&&t.localName===n)return t.value}}function Je(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function gr(e){if(!Je(e,"fldChar"))return null;let n=pr(e,"fldCharType");return n==="begin"||n==="separate"||n==="end"?n:null}function W1(e){return e.kind==="fldChar"}function md(e){return e.kind==="instrText"}function H1(e){return e.kind==="fldSimple"}function Xt(e,n){return gr(e)===n}function di(e){return e.kind==="instrText"||e.kind==="generic"&&(Je(e,"instrText")||Je(e,"delInstrText"))}function FR(e){return e.kind==="generic"&&Je(e,"delInstrText")}function Qr(e){return e.kind==="fldSimple"||e.kind==="generic"&&Je(e,"fldSimple")}function pd(e){if(!di(e)||e.kind==="textValue")return "";let n="",t=[...e.children??[]];for(;t.length>0;){let r=t.pop();if(r.kind==="textValue"){n=r.value+n;continue}for(let o of r.children??[])t.push(o);}return n}function j1(e){if(Qr(e))return pr(e,"instr")}function K1(e,n){if(e.kind==="textValue"||!("attributes"in e))return;let t=pr(e,n);return t===void 0?e.attributes.some(o=>o.localName===n&&(o.namespaceUri===O||o.namespaceUri===""))?true:void 0:!(t==="0"||t==="false"||t==="off")}function gd(){return LR}function qp(e){return gr(e)!==null?true:di(e)}function G1(e){if(e.kind==="textValue"||gr(e)===null)return false;for(let n of e.children)if(n.kind!=="textValue"&&n.localName==="ffData"&&Je(n,"ffData"))return true;return false}var VR=256,Yp=64,WR=256,HR=2,jR=288,KR=Yp-1;function zp(e){let n=pr(e,"val");return n===void 0?true:!(n==="0"||n==="false"||n==="off")}function GR(e){let n=pr(e,"val");if(n===void 0||!/^\d{1,7}$/.test(n))return null;let t=Number.parseInt(n,10);return Math.min(jR,Math.max(HR,t))}function Xp(e){let n=pr(e,"val");if(n===void 0||!/^-?\d{1,7}$/.test(n))return null;let t=Number.parseInt(n,10);return t>=0&&t<=KR?t:null}function $R(e,n){let t,r,o=null,i=false,a=false;if(e.kind!=="textValue")for(let l of e.children){if(n.left--<=0)break;l.kind!=="textValue"&&(Je(l,"checked")?t??=zp(l):Je(l,"default")?r??=zp(l):Je(l,"size")?i||(i=true,o=GR(l)):Je(l,"sizeAuto")&&(a=true));}return {kind:"checkbox",checked:t??r??false,sizeHalfPoints:a?null:o}}function zR(e,n){let t=null,r=null,o=false,i=false,a=[];if(e.kind!=="textValue")for(let s of e.children){if(n.left--<=0)break;if(s.kind!=="textValue"){if(Je(s,"result"))o||(o=true,t=Xp(s));else if(Je(s,"default"))i||(i=true,r=Xp(s));else if(Je(s,"listEntry")){if(a.length>=Yp)continue;let d=pr(s,"val");d!==void 0&&a.push(d.slice(0,WR));}}}let l=s=>s!==null&&s>=0&&s<a.length;return {kind:"dropdown",entries:a,selectedIndex:l(t)?t:l(r)?r:0}}function $1(e){if(e.kind==="textValue"||gr(e)===null)return null;let n={left:VR};for(let t of e.children){if(n.left--<=0)return null;if(!(t.kind==="textValue"||!Je(t,"ffData"))){for(let r of t.children){if(n.left--<=0)return null;if(r.kind!=="textValue"){if(Je(r,"checkBox"))return $R(r,n);if(Je(r,"ddList"))return zR(r,n)}}return null}}return null}var XR=/\s*\\\*\s*MERGEFORMAT\s*$/i,Zp=4096;function qR(e,n=Zp){if(e.length>n)return false;let t=e.replace(/\s+/g," ").trim().toUpperCase();return t.length>n?false:t.replace(XR,"").trim()==="FORMTEXT"}function YR(e,n){let t=n?.maxNesting??4,r=n?.maxInstructionChars??Zp,o=[],i=[],a=d=>{if(d.kind==="textValue")return [];let c=[],u=f=>{if(f.kind==="run"){c.push(f.id);return}if(f.kind!=="textValue")for(let m of f.children??[])u(m);};for(let f of d.children??[])u(f);return c},l=(d,c=0)=>{if(d.kind==="fldSimple"||d.kind==="generic"&&Qr(d)){o.push({kind:"simple",node:d,runId:"",removeNodeIds:[d.id],formatRunIds:a(d),addressing:"atomic"});return}if(d.kind==="run"){for(let u of d.children)u.kind!=="runProperties"&&i.push({runId:d.id,node:u});return}if(Qe(d)){if(c<mr)for(let u of sd(d))l(u,c+1);return}if(d.kind!=="textValue"&&(d.kind==="hyperlink"||he(d.kind)))for(let u of d.children)l(u,c);};for(let d of e.children)l(d);let s=0;for(;s<i.length;){let d=i[s];if(!Xt(d.node,"begin")){s+=1;continue}let c=0,u=false,f=0,m="",g=false,p=0,x="",y=false,N=false,b="instruction",h=[],P=[],k=new Set,E,w=-1;for(let U=s;U<i.length;U+=1){let B=i[U],C=B.node;if(Xt(C,"begin")){c+=1,c>t&&(u=true),h.push(C.id);continue}if(di(C)){if(c===1&&b==="instruction"){let rn=pd(C);FR(C)?(p+=rn.length,p>r?(y=true,x=""):y||(x+=rn)):(N=true,f+=rn.length,f>r?(g=true,m=""):g||(m+=rn));}c>=1&&h.push(C.id);continue}if(Xt(C,"separate")){c===1&&b==="instruction"&&(b="result",E=B.runId),c>=1&&h.push(C.id);continue}if(Xt(C,"end")){if(c>=1&&h.push(C.id),c-=1,c===0){b="done",w=U;break}continue}c>=1&&(b==="result"&&c===1?C.kind==="text"||C.kind==="deletedText"||C.kind==="tab"||C.kind==="hardBreak"||C.kind==="textValue"?(h.push(C.id),B.runId&&!k.has(B.runId)&&(k.add(B.runId),P.push(B.runId))):C.kind==="generic"&&h.push(C.id):b==="instruction"&&h.push(C.id));}if(w<0||u)break;let I=N?m:x,A=P.length>0?P:E?[E]:d.runId?[d.runId]:[];o.push({kind:"complex",node:d.node,runId:d.runId,removeNodeIds:[...new Set(h)],formatRunIds:A,addressing:qR(I,r)?"editable-result":"atomic"}),s=w+1;}return o}function $a(e,n){return YR(e,n).filter(t=>t.addressing==="atomic")}function z1(e){return BR.has(e)}var Qp=256,Jr=512,Jp=512,xd=4,q1=3;function ci(e){if(e.length>256)return null;let n=e.trim();if(n.length===0||(n.split(/\s+/)[0]??"").toUpperCase()!=="TOC")return null;let r=/\\h\b/i.test(n),o=/\\n\b/i.test(n),i=1,a=9,l=/\\o\s*(?:"(\d{1,2})\s*-\s*(\d{1,2})"|(\d{1,2})\s*-\s*(\d{1,2}))/i.exec(n);if(l){let s=Number(l[1]??l[3]),d=Number(l[2]??l[4]);if(!Number.isInteger(s)||!Number.isInteger(d)||s<1||d>9||s>d)return null;i=s,a=d;}return !r&&/\\o\b/i.test(n)&&(r=true),{keyword:"TOC",hyperlink:r,omitPageNumbers:o,outlineStart:i,outlineEnd:a,raw:n}}function ZR(e){if(e.root.kind==="body")return e.root;for(let n of e.root.children)if(n.kind==="body")return n;return null}var eg=new WeakMap;function QR(e){let n=eg.get(e);if(n)return n;let t=[],r=o=>{if(o.kind!=="textValue"){if(gr(o)!==null||md(o)){t.push(o);return}for(let i of o.children)r(i);}};for(let o of e.children)r(o);return eg.set(e,t),t}var rg=Object.freeze([]),ng=new WeakMap;function og(e,n,t){let r=ng.get(e);if(r)return r;let o=[],i=[],a=c=>{for(let u of QR(c)){let f=gr(u);if(f==="begin"){o.length>=4?o.push(null):o.push({beginNodeId:u.id,beginParagraphId:c.id,containerId:e.id,contentControlId:n,instructionChunks:[],resultParagraphIds:[],instructionLength:0,separated:false,invalid:false});continue}let m=o[o.length-1];if(md(u)){if(m&&!m.separated){let p=pd(u);m.instructionLength+=p.length,m.instructionLength>256?m.invalid=true:m.instructionChunks.push(p);}continue}if(f==="separate"){m&&(m.separated=true);continue}if(f!=="end"||o.length===0)continue;let g=o.pop();if(g&&g.separated&&!g.invalid&&g.containerId===e.id&&g.beginParagraphId!==c.id){let p=ci(g.instructionChunks.join(""));p&&i.push({beginNodeId:g.beginNodeId,beginParagraphId:g.beginParagraphId,endParagraphId:c.id,resultParagraphIds:g.resultParagraphIds,containerId:g.containerId,...g.contentControlId?{contentControlId:g.contentControlId}:{},instruction:p});}}for(let u of o)u&&u.separated&&u.beginParagraphId!==c.id&&u.containerId===e.id&&u.resultParagraphIds.push(c.id);};for(let c of e.children){if(c.kind==="paragraph"){a(c);continue}if(!(!Qe(c)||t>=4))for(let u of c.children)ja(u)&&i.push(...og(u,c.id,t+1));}let l=new Map;for(let c of i)!("id"in c)&&c.contentControlId&&l.set(c.contentControlId,(l.get(c.contentControlId)??0)+1);let s=i.map(c=>"id"in c?c:{...c,id:c.contentControlId&&l.get(c.contentControlId)===1?c.contentControlId:c.beginNodeId}),d=s.length>0?Object.freeze(s):rg;return ng.set(e,d),d}var tg=new WeakMap;function eo(e){let n=tg.get(e);if(n)return n;let t=ZR(e),r=t?og(t,void 0,0):rg;return tg.set(e,r),r}function no(e,n){return e.find(t=>t.id===n)??null}var JR=256,ig=1e4,eI="_GoBack";function nI(e,n){if(e.kind!=="textValue"){for(let t of e.attributes)if(t.namespaceUri===O&&t.localName===n)return t.value}}function ag(e){let n=new Map,t=i=>{if(i.kind==="textValue")return i.value.length;if(i.kind==="tab"||i.kind==="hardBreak")return 1;if(i.kind==="runProperties"||i.kind==="generic")return 0;let a=0;for(let l of i.children)a+=t(l);return a},r=i=>{if(i.kind==="textValue")return;let a=0,l=s=>{if(s.kind==="bookmarkStart"){let d=nI(s,"name");d!==void 0&&d.length>0&&d.length<=JR&&d!==eI&&!n.has(d)&&n.size<ig&&n.set(d,{name:d,paragraphId:i.id,offset:a});return}if(s.kind==="run"){a+=t(s);return}if(s.kind==="hyperlink")for(let d of s.children)l(d);};for(let s of i.children)l(s);},o=i=>{if(!(i.kind==="textValue"||n.size>=ig)){if(i.kind==="paragraph"){r(i);return}for(let a of i.children)o(a);}};return o(e.root),n}var rL=20,za=e=>e,oL=e=>e,iL=e=>e/20,aL=e=>Math.round(e*20);var tI=za(240);function cg(e){if(!Number.isFinite(e))return za(0);let n=Math.max(0,Math.min(8,Math.trunc(e)));return za(n*tI)}function Ln(e,n){return {kind:"genericExtension",namespaceUri:O,localName:e,prefix:"w",value:n}}function rI(e,n){return {id:e(),kind:"text",namespaceUri:O,localName:"t",prefix:"w",namespaceBindings:[],attributes:/^\s|\s$/.test(n)?[{kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:"preserve"}]:[],children:[{id:e(),kind:"textValue",value:n}]}}function lg(e,n){return {id:e(),kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:[rI(e,n)]}}function oI(e){return {id:e(),kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"generic",namespaceUri:O,localName:"ptab",prefix:"w",namespaceBindings:[],attributes:[Ln("alignment","right"),Ln("relativeTo","margin"),Ln("leader","dot")],children:[]}]}}function hd(e,n){return {id:e(),kind:"fldChar",namespaceUri:O,localName:"fldChar",prefix:"w",namespaceBindings:[],attributes:[Ln("fldCharType",n)],children:[]}}function iI(e,n){return {id:e(),kind:"instrText",namespaceUri:O,localName:"instrText",prefix:"w",namespaceBindings:[],attributes:[{kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:"preserve"}],children:[{id:e(),kind:"textValue",value:` ${n} `}]}}function sg(e,n){return {id:e(),kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:[...n]}}function dg(e,n){return {id:e(),kind:"paragraph",namespaceUri:O,localName:"p",prefix:"w",namespaceBindings:[],attributes:[],children:[...n]}}function ug(e,n){return {id:e(),kind:"generic",namespaceUri:O,localName:"ind",prefix:"w",namespaceBindings:[],attributes:[Ln("left",String(n))],children:[]}}function aI(e){return e.kind==="textValue"?false:e.children.some(n=>n.kind!=="textValue"&&n.localName==="ind")}function lI(e,n){if(e.kind==="textValue")return e;let t=[...e.children],r=t.findIndex(o=>o.kind!=="textValue"&&o.localName==="pStyle");return r>=0?t.splice(r+1,0,n):t.push(n),{...e,children:t}}function sI(e,n,t){if(aI(e))return e;let r=cg(t);return r===0?e:lI(e,ug(n,r))}function dI(e,n,t){let r=[{id:e(),kind:"generic",namespaceUri:O,localName:"pStyle",prefix:"w",namespaceBindings:[],attributes:[Ln("val",n)],children:[]}],o=cg(t);return o>0&&r.push(ug(e,o)),{id:e(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:r}}function fg(e,n){return e.kind==="textValue"?{...e,id:n()}:{...e,id:n(),children:e.children.map(t=>fg(t,n))}}function yd(e,n,t,r){let o=`TOC${Math.min(n.level+1,9)}`,i=[lg(e,n.text)];t.omitPageNumbers||(i.push(oI(e)),i.push(lg(e,n.pageNumberText)));let a=t.hyperlink?[{id:e(),kind:"hyperlink",namespaceUri:O,localName:"hyperlink",prefix:"w",namespaceBindings:[],attributes:[Ln("anchor",n.bookmarkName)],children:i}]:i,l=r?sI(fg(r,e),e,n.level):dI(e,o,n.level);return {id:e(),kind:"paragraph",namespaceUri:O,localName:"p",prefix:"w",namespaceBindings:[],attributes:[],children:[l,...a]}}function mg(e,n,t,r){let o=dg(e,[sg(e,[hd(e,"begin"),iI(e,t.raw),hd(e,"separate")])]),i=dg(e,[sg(e,[hd(e,"end")])]),a={id:e(),kind:"contentControlProperties",namespaceUri:O,localName:"sdtPr",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"generic",namespaceUri:O,localName:"alias",prefix:"w",namespaceBindings:[],attributes:[Ln("val",r)],children:[]},{id:e(),kind:"generic",namespaceUri:O,localName:"docPartObj",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"generic",namespaceUri:O,localName:"docPartGallery",prefix:"w",namespaceBindings:[],attributes:[Ln("val","Table of Contents")],children:[]},{id:e(),kind:"generic",namespaceUri:O,localName:"docPartUnique",prefix:"w",namespaceBindings:[],attributes:[],children:[]}]}]},l={id:e(),kind:"contentControlContent",namespaceUri:O,localName:"sdtContent",prefix:"w",namespaceBindings:[],attributes:[],children:[o,...n.map(s=>yd(e,s,t)),i]};return {id:e(),kind:"contentControl",namespaceUri:O,localName:"sdt",prefix:"w",namespaceBindings:[],attributes:[],children:[a,l]}}function cI(e){return e.length>0&&e.length<=40&&!/[\u0000-\u001F\u007F-\u009F]/.test(e)}function uI(e){return e.replace(/[\t\n\r]+/g," ").replace(/ {2,}/g," ").trim()}function fL(e,n,t,r,o){let i=ag(e),a=new Map;for(let[u,f]of i)u.startsWith("_Toc")&&!a.has(f.paragraphId)&&a.set(f.paragraphId,u);let l=[],s=[],d=0,c=16e8+i.size%1e4;for(let u of n){if(l.length>=512)break;if(o.has(u.blockId))continue;let f=u.level+1;if(f<t.outlineStart||f>t.outlineEnd)continue;let m=a.get(u.blockId);if(!m&&t.hyperlink){if(d>=512||(m=`_Toc${c}`,c+=1,!cI(m)))continue;s.push({paragraphId:u.blockId,name:m}),d+=1,a.set(u.blockId,m);}m||(m=`_Toc${u.blockId.replace(/[^A-Za-z0-9]/g,"").slice(-12)||"0"}`),l.push({level:u.level,text:uI(u.text),headingParagraphId:u.blockId,bookmarkName:m,pageNumberText:r.get(u.blockId)??"1"});}return {entries:l,bookmarksToCreate:s}}function pg(e,n,t){return {start:{id:e(),kind:"bookmarkStart",namespaceUri:O,localName:"bookmarkStart",prefix:"w",namespaceBindings:[],attributes:[Ln("id",t),Ln("name",n)],children:[]},end:{id:e(),kind:"bookmarkEnd",namespaceUri:O,localName:"bookmarkEnd",prefix:"w",namespaceBindings:[],attributes:[Ln("id",t)],children:[]}}}function Od(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function ui(e,n){for(let t of e.attributes)if(t.namespaceUri===O&&t.localName===n)return t.value;return null}function Nd(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return Ga(e);if(e.kind==="generic"||e.kind==="runProperties"||e.kind==="paragraphProperties")return "";if(e.kind==="hyperlink"||Qe(e)){let t="",r=e.kind==="hyperlink"?e.children:li(e)??[];for(let o of r)t+=Nd(o);return t}let n="";for(let t of e.children)n+=Nd(t);return n}function fI(e,n){let t=[],r="",o=i=>{i.kind==="run"&&(t.push(i.id),r+=Nd(i));};return zt(e.children,0,o),{nodeId:e.id,ordinal:n,text:r,runIds:t}}function gg(e){if(e.kind==="body")return e;for(let n of e.children){if(n.kind==="textValue")continue;let t=gg(n);if(t)return t}return null}function mI(e){let n=gg(e.root);if(!n)return null;let t=[];return Ha(n.children,0,r=>{t.push(fI(r,t.length));}),{partName:e.name,rootId:n.id,paragraphs:t}}function pI(e){let n=new Map;if(!e)return n;let t=r=>{if(r.kind!=="textValue"){if(Od(r,"style")){let o=ui(r,"styleId");if(o!==null){let i=null,a=null;for(let l of r.children)Od(l,"name")&&(i=ui(l,"val")),Od(l,"basedOn")&&(a=ui(l,"val"));n.has(o)||n.set(o,{styleId:o,type:ui(r,"type")??"",nodeId:r.id,name:i,basedOn:a,isDefault:["1","true","on"].includes(ui(r,"default")??"")});}}for(let o of r.children)t(o);}};return t(e.root),n}var gI=/\/styles\.xml$/i;function kd(e){return [...e.parts.values()].find(n=>gI.test(n.name))}function hL(e,n){let t=new Map,r=new Map,o=e.parts.get(e.mainDocumentPart),i=[...o?[o]:[],...[...e.parts.values()].filter(l=>l.name!==e.mainDocumentPart)];for(let l of i){let s=mI(l);if(s){t.set(l.name,s);for(let d of s.paragraphs)r.set(d.nodeId,d);}}let a=kd(e);return Object.freeze({revision:n,stories:t,paragraphs:r,relationships:e.relationships,styles:pI(a)})}var xI=/^[0-9A-Fa-f]{8}$/;function lt(e){if(!xI.test(e))return false;let n=Number.parseInt(e,16);return n!==0&&n<2147483648}function Xa(e){if(e.kind==="textValue")return null;for(let n of e.attributes)if(n.namespaceUri===j&&n.localName==="paraId")return n.value;return null}function fi(e){let n=2166136261;for(let t=0;t<e.length;t+=1)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function xg(e){return e.toString(16).toUpperCase().padStart(8,"0")}function wn(e,n){let t=0;for(let r=0;r<64;r+=1){t=fi(r===0?e:`${e} ${r}`)&2147483647;let o=xg(t);if(t!==0&&!n.has(o))return o}for(;;){t=t%2147483647+1;let r=xg(t);if(!n.has(r))return r}}var hg=new WeakMap;function zn(e){let n=hg.get(e);if(n)return n;let t=new Set,r=o=>{if(o.kind==="textValue")return;let i=Xa(o);i!==null&&lt(i)&&t.add(i.toUpperCase());for(let a of o.children)r(a);};return r(e),hg.set(e,t),t}function mi(e){for(let n of e.namespaceBindings)if(n.namespaceUri===j&&n.prefix!=="")return n.prefix;return null}function xr(e,n){let t=e.root.namespaceBindings.filter(i=>i.namespaceUri===j&&i.prefix!=="");if(t.length===0)return null;let r=[],o=n;for(;o&&o.id!==e.root.id;)r.push(o),o=Ce(e,o.id);for(let i of t)if(!r.some(l=>l.namespaceBindings.some(s=>s.prefix===i.prefix&&s.namespaceUri!==j)))return i.prefix;return null}function Rt(e,n){return Object.freeze([Object.freeze({kind:"genericExtension",namespaceUri:j,localName:"paraId",prefix:e,value:n}),Object.freeze({kind:"genericExtension",namespaceUri:j,localName:"textId",prefix:e,value:n})])}function hI(e){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName==="p"}function yI(e){let n=[],t=r=>{if(r.kind!=="textValue"){hI(r)&&n.push(r);for(let o of r.children)t(o);}};return t(e),n}function OI(e){return e.namespaceUri===j&&(e.localName==="paraId"||e.localName==="textId")}function NI(e){let n=new Set,t=r=>{if(r.kind!=="textValue"){for(let o of r.namespaceBindings)o.namespaceUri!==j&&n.add(o.prefix);for(let o of r.children)t(o);}};return t(e),n}function kI(e){if(!e.has("w14"))return "w14";for(let n=97;n<=122;n+=1){let t=`w14${String.fromCharCode(n)}`;if(!e.has(t))return t}for(let n=2;;n+=1){let t=`w14x${n}`;if(!e.has(t))return t}}function yg(e){return Object.freeze(e.attributes),Object.freeze(e.namespaceBindings),Object.freeze(e.children),Object.freeze(e)}function pi(e){let n=yI(e.root),t=new Set,r=[],o=false;for(let m of n){let g=Xa(m),p=g!==null&&lt(g)?g.toUpperCase():null;p!==null&&!t.has(p)?(t.add(p),o=true):r.push(m);}let i=mi(e.root);if(r.length===0&&!(o&&i===null))return e;let a=NI(e.root),l=i!==null&&!a.has(i)?i:kI(a),s=!e.root.namespaceBindings.some(m=>m.prefix===l&&m.namespaceUri===j),d=new Map;for(let m of r){let g=wn(m.id,t);t.add(g),d.set(m.id,[...Rt(l,g),...m.attributes.filter(p=>!OI(p))]);}let c=m=>{if(m.kind==="textValue")return m;let g=null;m.children.forEach((x,y)=>{let N=c(x);N!==x&&(g??=[...m.children],g[y]=N);});let p=d.get(m.id);return !p&&!g?m:yg({...m,...g?{children:g}:{},...p?{attributes:p}:{}})},u=c(e.root);if(s){let m=[...u.namespaceBindings,Object.freeze({prefix:l,namespaceUri:j})],g=u.attributes.find(x=>x.namespaceUri===_e&&x.localName==="Ignorable"),p=u.attributes;g&&!g.value.trim().split(/\s+/).includes(l)&&(p=u.attributes.map(x=>x===g?Object.freeze({...x,value:[g.value.trim(),l].filter(Boolean).join(" ")}):x)),u=yg({...u,namespaceBindings:m,attributes:p});}let f=Object.freeze({...e,root:u});return qo(f).ok?f:e}var bI="http://schemas.openxmlformats.org/package/2006/relationships",PI="application/vnd.openxmlformats-package.relationships+xml",wI=2048;function EI(e){if(typeof e!="string"||e.length===0||e.length>wI||!$(e))return null;let n=yt(e);return !n.ok||n.href.length===0?null:Mr(n.href).ok?n.href:null}function Og(e){let n=e.lastIndexOf("/");return `${e.slice(0,n)}/_rels/${e.slice(n+1)}.rels`}function RI(e){let n=0;for(let t of e.relationships.values())for(let r of t){let o=/^rId(\d{1,9})$/.exec(r.id);o&&(n=Math.max(n,Number(o[1])));}for(let t of e.externalTargets){let r=/^rId(\d{1,9})$/.exec(t.id);r&&(n=Math.max(n,Number(r[1])));}return `rId${n+1}`}function Ng(e,n){return e.kind==="textValue"?{...e,id:n()}:{...e,id:n(),children:e.children.map(t=>Ng(t,n))}}function qa(e,n,t=e.mainDocumentPart){let r=EI(n);if(r===null)return null;let o=t;if(typeof o!="string"||o.length===0||o!==e.mainDocumentPart&&!e.parts.has(o))return null;let i=e.externalTargets.find(g=>g.ownerPart===o&&g.type===an&&g.rawTarget===r);if(i)return {pkg:e,relationshipId:i.id};let a=Og(o),l=e.parts.get(a),s=RI(e),d=ne(`<Relationships xmlns="${bI}"><Relationship Id="${on(s,"relationship id")}" Type="${an}" Target="${on(r,"relationship target")}" TargetMode="External"/></Relationships>`,{name:a,contentType:PI});if(!d.ok)return null;let c=[...e.externalTargets,{ownerPart:o,id:s,type:an,rawTarget:r,sinkSafe:true}];if(!l)return {pkg:Object.freeze({...e,parts:new Map([...e.parts,[a,d.part]]),externalTargets:c}),relationshipId:s};let u=S(l),f=d.part.root.children[0];if(!f)return null;let m=M(l,l.root.id,l.root.children.length,[Ng(f,u)]);return m.ok?{pkg:Object.freeze({...e,parts:new Map([...e.parts,[a,m.part]]),externalTargets:c}),relationshipId:s}:null}function CL(e,n,t){for(let o of e.externalTargets)if(o.ownerPart===n&&o.id===t)return {target:o.rawTarget,external:true,sinkSafe:o.sinkSafe};let r=(e.relationships.get(n)??[]).find(o=>o.id===t);return r?{target:r.rawTarget,external:false}:null}function II(e){if(!(e.kind==="textValue"||!("attributes"in e)))return e.attributes.find(n=>n.localName==="Id"&&n.namespaceUri==="")?.value}function TI(e){if(!(e.kind==="textValue"||!("attributes"in e))&&e.kind==="generic"&&!(e.namespaceUri!==F||e.localName!=="hlinkClick")){for(let n of e.attributes)if(n.localName==="id"&&n.namespaceUri===$n)return n.value}}function kg(e,n){if(n(e),e.kind!=="textValue")for(let t of e.children)kg(t,n);}function CI(e,n,t){let r=e.parts.get(n);if(!r)return false;let o=false;return kg(r.root,i=>{if(!o){if(cm(i)){Ss(i)===t&&(o=true);return}TI(i)===t&&(o=true);}}),o}function vI(e,n,t){if(!e.externalTargets.find(s=>s.ownerPart===n&&s.id===t&&s.type===an))return e;let o=Og(n),i=e.parts.get(o),a=e.parts;if(i){let s=i.root.children.find(d=>d.kind!=="textValue"&&d.localName==="Relationship"&&II(d)===t);if(s){let d=oe(i,s.id);if(!d.ok)return null;a=new Map([...e.parts,[o,d.part]]);}}let l=Object.freeze(e.externalTargets.filter(s=>!(s.ownerPart===n&&s.id===t)));return Object.freeze({...e,parts:a,externalTargets:l})}function bd(e,n,t){return t===null||CI(e,n,t)?e:vI(e,n,t)}var wd=O,Ya="http://schemas.openxmlformats.org/officeDocument/2006/relationships",SI="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",AI="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",Za="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",MI="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",_I="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",bg="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",Pd="/word/settings.xml",Pg=1e4,DI=31680,Rg=4096,UI=new Set(["createHeaderFooter","deleteHeaderFooter","linkToPrevious","unlinkFromPrevious","setSectionFurnitureOptions"]);function Ed(e){return UI.has(e.op)}function Y(e,n){return n?{ok:false,reason:e,detail:n}:{ok:false,reason:e}}function LI(e){return e==="default"||e==="first"||e==="even"}function BI(e){return e==="header"||e==="footer"}function Ig(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function Ja(e){return !Ig(e.sectionIndex)||e.sectionIndex>=Rg?Y("invalidArgs","sectionIndex"):BI(e.kind)?LI(e.variant)?null:Y("invalidArgs","variant"):Y("invalidArgs","kind")}function Tg(e,n){if(!Ed(n))return Y("invalidArgs","unknown-op");switch(n.op){case "createHeaderFooter":return FI(e,n);case "deleteHeaderFooter":return VI(e,n);case "linkToPrevious":return WI(e,n);case "unlinkFromPrevious":return HI(e,n);case "setSectionFurnitureOptions":return jI(e,n)}}function FI(e,n){let t=Ja(n);if(t)return t;let r=si(e);if(n.sectionIndex>=r.length)return Y("invalidArgs","sectionIndex");let o=r[n.sectionIndex];if((n.kind==="header"?o.headers:o.footers).has(n.variant))return Y("invalidArgs","slot-occupied");let a=Cg(e,n.kind);if(!a)return Y("tree-invariant","part-allocation");let l=KI(a.partName,a.contentType,n.kind);if(!l)return Y("tree-invariant","empty-part");let s=D(e,l),d=ur(s,a.rId,a.relType,a.target);if(!d)return Y("tree-invariant","relationship");s=d;let c=bt(s,a.partName,a.contentType);if(!c)return Y("tree-invariant","content-type");s=c;let u=Sg(s,n.sectionIndex,n.kind,n.variant,a.rId);if(!u)return Y("tree-invariant","sectPr-reference");if(s=u,n.titlePage===true){let f=_g(s,n.sectionIndex,{titlePage:true});if(!f)return Y("tree-invariant","sectPr-options");s=f;}if(n.evenAndOddHeaders===true){let f=Dg(s,true);if(!f)return Y("tree-invariant","settings");s=f;}return {ok:true,package:s,impact:"global",createdRId:a.rId,createdPartName:a.partName}}function VI(e,n){let t=Ja(n);if(t)return t;let r=si(e);if(n.sectionIndex>=r.length)return Y("invalidArgs","sectionIndex");let o=r[n.sectionIndex],a=(n.kind==="header"?o.headers:o.footers).get(n.variant);if(!a||a.inherited)return Y("invalidArgs","not-declared");let l=Ag(e,n.sectionIndex,n.kind,n.variant);if(!l)return Y("tree-invariant","sectPr-reference");if(Ug(l,a.rId)>0)return {ok:true,package:l,impact:"global"};let d=Lg(l,a.rId,a.partName);return d?{ok:true,package:d,impact:"global"}:Y("tree-invariant","gc")}function WI(e,n){let t=Ja(n);if(t)return t;if(n.sectionIndex===0)return Y("invalidArgs","first-section");let r=si(e);if(n.sectionIndex>=r.length)return Y("invalidArgs","sectionIndex");let o=r[n.sectionIndex],a=(n.kind==="header"?o.headers:o.footers).get(n.variant);if(!a||a.inherited)return Y("invalidArgs","not-declared");let l=Ag(e,n.sectionIndex,n.kind,n.variant);if(!l)return Y("tree-invariant","sectPr-reference");if(Ug(l,a.rId)>0)return {ok:true,package:l,impact:"global"};let d=Lg(l,a.rId,a.partName);return d?{ok:true,package:d,impact:"global"}:Y("tree-invariant","gc")}function HI(e,n){let t=Ja(n);if(t)return t;let r=si(e);if(n.sectionIndex>=r.length)return Y("invalidArgs","sectionIndex");let o=r[n.sectionIndex],a=(n.kind==="header"?o.headers:o.footers).get(n.variant);if(!a)return Y("invalidArgs","nothing-to-unlink");if(!a.inherited)return Y("invalidArgs","already-declared");let l=e.parts.get(a.partName);if(!l)return Y("tree-invariant","missing-source");let s=Cg(e,n.kind);if(!s)return Y("tree-invariant","part-allocation");let d=GI(l,s.partName,s.contentType);if(!d)return Y("tree-invariant","clone");let c=D(e,d),u=pp(c,a.partName,s.partName);if(!u)return Y("tree-invariant","owned-relationships");c=u;let f=ur(c,s.rId,s.relType,s.target);if(!f)return Y("tree-invariant","relationship");c=f;let m=bt(c,s.partName,s.contentType);if(!m)return Y("tree-invariant","content-type");c=m;let g=Sg(c,n.sectionIndex,n.kind,n.variant,s.rId);return g?{ok:true,package:g,impact:"global",createdRId:s.rId,createdPartName:s.partName}:Y("tree-invariant","sectPr-reference")}function jI(e,n){let t=n.titlePage!==void 0,r=n.evenAndOddHeaders!==void 0,o=n.headerDistanceTwips!==void 0,i=n.footerDistanceTwips!==void 0;if(!t&&!r&&!o&&!i)return Y("invalidArgs","empty-options");for(let s of [n.headerDistanceTwips,n.footerDistanceTwips])if(s!==void 0&&(!Number.isInteger(s)||s<0||s>DI))return Y("invalidArgs","distance");let a=t||o||i;if(a&&(n.sectionIndex===void 0||!Ig(n.sectionIndex)||n.sectionIndex>=Rg))return Y("invalidArgs","sectionIndex");let l=e;if(a){let s=_g(l,n.sectionIndex,{titlePage:n.titlePage,headerDistanceTwips:n.headerDistanceTwips,footerDistanceTwips:n.footerDistanceTwips});if(!s)return Y("tree-invariant","sectPr-options");l=s;}if(r){let s=Dg(l,n.evenAndOddHeaders);if(!s)return Y("tree-invariant","settings");l=s;}return {ok:true,package:l,impact:"global"}}function Cg(e,n){let t=n==="header"?"header":"footer",r=n==="header"?MI:_I,o=n==="header"?SI:AI,i=1;for(;i<=Pg;i+=1){let l=`/word/${t}${i}.xml`;if(!e.parts.has(l)&&!e.partBytes.has(l))break}if(i>Pg)return null;let a=`${t}${i}.xml`;return /^(header|footer)\d{1,5}\.xml$/.test(a)?{partName:`/word/${t}${i}.xml`,target:a,rId:kt(e),relType:o,contentType:r}:null}function KI(e,n,t){let r=t==="header"?"hdr":"ftr",o=`<w:${r} xmlns:w="${wd}" xmlns:r="${Ya}"><w:p><w:r><w:t></w:t></w:r></w:p></w:${r}>`,i=ne(o,{name:e,contentType:n});return i.ok?i.part:null}function GI(e,n,t){let r=0,o=()=>(r+=1,`${n}#clone:${r}`),i=vg(e.root,o);if(i.kind==="textValue")return null;let a=i;return Object.freeze({id:`part:${n}`,name:n,contentType:t,root:a})}function vg(e,n){return e.kind==="textValue"?{...e,id:n()}:{...e,id:n(),children:e.children.map(t=>vg(t,n))}}function $I(e){let n=e.root.namespaceBindings.find(r=>r.prefix==="r");if(n)return n.namespaceUri===Ya?e:null;let t={...e.root,namespaceBindings:Object.freeze([...e.root.namespaceBindings,Object.freeze({prefix:"r",namespaceUri:Ya})])};return {...e,root:t}}function Sg(e,n,t,r,o){if(!/^rId\d{1,9}$/.test(o))return null;let i=e.parts.get(e.mainDocumentPart);if(!i)return null;let a=$I(i);if(!a)return null;let l=Et(a.root);if(n>=l.length)return null;let s=t==="header"?"headerReference":"footerReference",d=S(a),c=XI(s,r,o,d);if(!c)return null;let u=l[n],f;if(u){let m=Mg(u,s,r),g=[c,...m.children],p=L(a,u.id,g);if(!p.ok)return null;f=p.part;}else {let m=Rd(a.root);if(!m)return null;let g=gi(d(),"sectPr",[],[c]),p=M(a,m.id,m.children.length,[g]);if(!p.ok)return null;f=p.part;}return D(e,f)}function Ag(e,n,t,r){let o=e.parts.get(e.mainDocumentPart);if(!o)return null;let i=Et(o.root);if(n>=i.length)return null;let a=i[n];if(!a)return zI();let s=Mg(a,t==="header"?"headerReference":"footerReference",r);if(s.children.length===a.children.length)return null;let d=L(o,a.id,s.children);return d.ok?D(e,d.part):null}function zI(){return null}function Mg(e,n,t){let r=e.children.filter(o=>o.kind==="textValue"||o.localName!==n?true:Qa(o,"type")!==t);return {...e,children:r}}function XI(e,n,t,r){let o=`<w:sectPr xmlns:w="${wd}" xmlns:r="${Ya}"><w:${e} w:type="${n}" r:id="${t}"/></w:sectPr>`,i=ne(o,{name:"/word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"});if(!i.ok)return null;let a=i.part.root.children[0];return !a||a.kind==="textValue"||a.localName!==e||Qa(a,"type")!==n||Qa(a,"id")!==t?null:Dn(a,r)}function _g(e,n,t){let r=e.parts.get(e.mainDocumentPart);if(!r)return null;let o=Et(r.root);if(n>=o.length)return null;let i=S(r),a=o[n],l=r;if(!a){let c=Rd(r.root);if(!c)return null;let u=gi(i(),"sectPr",[],[]),f=M(r,c.id,c.children.length,[u]);if(!f.ok||(l=f.part,a=Et(l.root)[n]??null,!a))return null}let s=[...a.children];if(t.titlePage!==void 0&&(s=s.filter(c=>c.kind==="textValue"||c.localName!=="titlePg"),t.titlePage)){let c=gi(i(),"titlePg",[],[]);s.splice(Eg(s,"titlePg"),0,c);}if(t.headerDistanceTwips!==void 0||t.footerDistanceTwips!==void 0){let c=s.find(m=>m.kind!=="textValue"&&m.localName==="pgMar"),u=new Map;if(c)for(let m of c.attributes)u.set(m.localName,m.value);t.headerDistanceTwips!==void 0&&u.set("header",String(t.headerDistanceTwips)),t.footerDistanceTwips!==void 0&&u.set("footer",String(t.footerDistanceTwips));for(let m of ["top","right","bottom","left"])u.has(m)||u.set(m,"1440");let f=gi(c?.id??i(),"pgMar",[...u.entries()].map(([m,g])=>YI(m,g)),[]);c?s=s.map(m=>m.id===c.id?f:m):s.splice(Eg(s,"pgMar"),0,f);}let d=L(l,a.id,s);return d.ok?D(e,d.part):null}function Dg(e,n){let t=e,o=(t.relationships.get(t.mainDocumentPart)??[]).find(u=>u.type===Za);if(!o){let u=qI(t);if(!u||(t=u,o=(t.relationships.get(t.mainDocumentPart)??[]).find(f=>f.type===Za),!o))return null}let i=Me(o);if(i.mode!=="Internal"||!i.target.ok)return null;let a=i.target.partName,l=t.parts.get(a);if(!l)return null;let s=S(l),d=l.root.children.filter(u=>u.kind==="textValue"||u.localName!=="evenAndOddHeaders");if(n){let u=gi(s(),"evenAndOddHeaders",[],[]);d=[...d,u];}let c=L(l,l.root.id,d);return c.ok?D(t,c.part):null}function qI(e){if(e.parts.has(Pd))return ur(e,kt(e),Za,"settings.xml");let n=`<w:settings xmlns:w="${wd}"></w:settings>`,t=ne(n,{name:Pd,contentType:bg});if(!t.ok)return null;let r=D(e,t.part),o=ur(r,kt(r),Za,"settings.xml");return o?(r=o,bt(r,Pd,bg)):null}function Ug(e,n){let t=e.parts.get(e.mainDocumentPart);if(!t)return 0;let r=0;for(let o of Et(t.root))if(o)for(let i of o.children)i.kind!=="textValue"&&(i.localName!=="headerReference"&&i.localName!=="footerReference"||Qa(i,"id")===n&&(r+=1));return r}function Lg(e,n,t){let r=Qs(e,n);if(!r)return null;let o=new Map(r.parts);o.delete(t);let i=new Map(r.partBytes);return i.delete(t),r=Object.freeze({...r,parts:o,partBytes:i}),r=gp(r,t),ii(r,t)}function Qa(e,n){if(!(e.kind==="textValue"||!("attributes"in e)))return e.attributes.find(t=>t.localName===n)?.value}function Rd(e){if(e.kind!=="textValue"){if(e.kind==="body"||e.localName==="body")return e;for(let n of e.children){let t=Rd(n);if(t)return t}}}function YI(e,n){return {kind:"genericExtension",namespaceUri:O,localName:e,prefix:"w",value:n}}function gi(e,n,t,r){return {id:e,kind:"generic",namespaceUri:O,localName:n,prefix:"w",namespaceBindings:[],attributes:t,children:r}}var wg=["pgSz","pgMar","paperSrc","pgBorders","lnNumType","pgNumType","cols","formProt","vAlign","noEndnote","titlePg","textDirection","bidi","rtlGutter","docGrid","printerSettings","sectPrChange"];function Eg(e,n){let t=wg.indexOf(n);if(t===-1)return e.length;let r=new Set(wg.slice(t+1)),o=e.findIndex(i=>i.kind!=="textValue"&&"localName"in i&&r.has(i.localName));return o===-1?e.length:o}var ZI="\uFFFC",Id=1,xi=2147483647,WL=-1,HL=0,QI=new Set(["normal","separator","continuationSeparator","continuationNotice"]),JI=/^(footnote|endnote):(-?\d{1,10})$/;function Td(e,n){if(!(e.kind==="textValue"||!("attributes"in e))){for(let t of e.attributes)if(t.namespaceUri===O&&t.localName===n||t.namespaceUri===""&&t.localName===n)return t.value}}function to(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function Bg(e){if(e===void 0||e===""||!/^-?\d{1,10}$/.test(e))return null;let n=Number(e);return !Number.isInteger(n)||n<-2147483648||n>2147483647?null:n}function jL(e,n){return `${e}:${n}`}function KL(e){let n=JI.exec(e);if(!n)return null;let t=Bg(n[2]);return t===null?null:{noteKind:n[1],noteId:t}}function GL(e){return e.kind==="footnotes"}function $L(e){return e.kind==="endnotes"}function zL(e){return e.kind==="note"}function XL(e){return e.kind==="noteReference"}function qL(e){return e.kind==="noteRef"}function YL(e){return e.kind==="separator"}function ZL(e){return e.kind==="continuationSeparator"}function hr(e){if(e.kind==="note")return e.localName==="footnote"?"footnote":e.localName==="endnote"?"endnote":null;if(e.kind==="generic"){if(to(e,"footnote"))return "footnote";if(to(e,"endnote"))return "endnote"}return null}function gn(e){return Bg(Td(e,"id"))}function Cd(e){let n=Td(e,"type");if(n!==void 0)return QI.has(n)?n:void 0}function hi(e){let n=Cd(e);return n===void 0||n==="normal"}function el(e){if(e.kind==="noteReference")return e.localName==="footnoteReference"?"footnote":e.localName==="endnoteReference"?"endnote":null;if(e.kind==="generic"){if(to(e,"footnoteReference"))return "footnote";if(to(e,"endnoteReference"))return "endnote"}return null}function Fg(e){if(e.kind==="noteRef")return e.localName==="footnoteRef"?"footnote":e.localName==="endnoteRef"?"endnote":null;if(e.kind==="generic"){if(to(e,"footnoteRef"))return "footnote";if(to(e,"endnoteRef"))return "endnote"}return null}function QL(e){if(e.kind==="textValue"||!("attributes"in e))return;let n=Td(e,"customMarkFollows");return n===void 0?e.attributes.some(r=>r.localName==="customMarkFollows"&&(r.namespaceUri===O||r.namespaceUri===""))?true:void 0:!(n==="0"||n==="false"||n==="off")}function JL(){return ZI}function yi(e){return e.kind==="noteReference"||e.kind==="noteRef"||e.kind==="separator"||e.kind==="continuationSeparator"}function nl(e){let n=[];return zt(e.children,0,t=>{if(t.kind==="run")for(let r of t.children)yi(r)&&n.push({kind:r.kind,node:r,runId:t.id,removeNodeIds:[r.id]});}),n}var Oi=1e4;function vd(e){if(e.kind==="textValue")return null;let n=0,t=0;for(let o of e.children){if(t>=Oi)break;if(t+=1,hr(o)===null)continue;let i=gn(o);i!==null&&i>n&&(n=i);}if(n>=xi)return null;let r=Math.max(n+1,Id);return r>xi?null:r}function yr(e){if(e.kind!=="footnotes"&&e.kind!=="endnotes")return [];let n=[];for(let t of e.children){if(n.length>=Oi)break;t.kind==="note"&&n.push(t);}return n}function It(e,n){for(let t of yr(e))if(gn(t)===n)return t}var ro=Object.freeze({pos:"pageBottom",numFmt:"decimal",numStart:1,numRestart:"continuous"}),oo=Object.freeze({pos:"docEnd",numFmt:"lowerRoman",numStart:1,numRestart:"continuous"}),Vg=new Set(["pageBottom","beneathText","sectEnd","docEnd"]),Wg=new Set(["sectEnd","docEnd"]),Hg=new Set(["continuous","eachSect","eachPage"]),eT="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings";function nT(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function Ni(e,n){if(e.kind!=="textValue"){for(let t of e.children)if(nT(t,n))return t}}function tl(e,n){for(let t of e.attributes)if(t.localName===n&&(t.namespaceUri===O||t.namespaceUri===""))return t.value}function tT(e){if(e===void 0||!/^\d{1,10}$/.test(e))return;let n=Number(e);if(!(!Number.isInteger(n)||n<0||n>2147483647))return n}function rT(e){if(!e||e.kind==="textValue")return;let n={},t=false,r=Ni(e,"pos");if(r){let l=tl(r,"val");l!==void 0&&(n.pos=l,t=true);}let o=Ni(e,"numFmt");if(o){let l=tl(o,"val");l!==void 0&&(n.numFmt=l,t=true);}let i=Ni(e,"numStart");if(i){let l=tT(tl(i,"val"));l!==void 0&&(n.numStart=l,t=true);}let a=Ni(e,"numRestart");if(a){let l=tl(a,"val");l!==void 0&&(n.numRestart=l,t=true);}return !t&&e.children.length===0?{}:t||e.children.length>0?n:void 0}function rl(e,n){if(!e)return;let t=Ni(e,n);return rT(t)}function rB(e){return rl(e,"footnotePr")}function oB(e){return rl(e,"endnotePr")}function Tt(e){let n=e.relationships.get(e.mainDocumentPart)??[];for(let t of n){if(t.type!==eT)continue;let r=Me(t);if(!(r.mode!=="Internal"||!r.target.ok))return e.parts.get(r.target.partName)??null}return e.parts.get("/word/settings.xml")??null}function iB(e){if(e)return rl(e.root,"footnotePr")}function aB(e){if(e)return rl(e.root,"endnotePr")}function qt(e,n,t){return e!==void 0?e:n!==void 0?n:t}function jg(e,n){return e!==void 0&&Hg.has(e)?e:n}function lB(e,n){let t=qt(e?.pos,n?.pos,ro.pos);return {pos:Vg.has(t)?t:ro.pos,numFmt:qt(e?.numFmt,n?.numFmt,ro.numFmt),numStart:qt(e?.numStart,n?.numStart,ro.numStart),numRestart:jg(qt(e?.numRestart,n?.numRestart,ro.numRestart),ro.numRestart)}}function sB(e,n){let t=qt(e?.pos,n?.pos,oo.pos);return {pos:Wg.has(t)?t:oo.pos,numFmt:qt(e?.numFmt,n?.numFmt,oo.numFmt),numStart:qt(e?.numStart,n?.numStart,oo.numStart),numRestart:jg(qt(e?.numRestart,n?.numRestart,oo.numRestart),oo.numRestart)}}function Kg(e){return Wg.has(e)}function Gg(e){return Vg.has(e)}function $g(e){return Hg.has(e)}var W=[sr.story],oT="http://schemas.microsoft.com/office/word/2012/wordml",iT={checkbox:j,repeatingSection:oT},ol=32;function il(e){return e.kind}function we(e){if(e.kind==="textValue")return false;let n=il(e);return n==="contentControl"?true:n==="generic"&&e.localName==="sdt"&&e.namespaceUri===O}function zg(e){if(e.kind==="textValue")return false;let n=il(e);return n==="contentControlContent"?true:n==="generic"&&e.localName==="sdtContent"&&e.namespaceUri===O}function Xg(e){if(e.kind==="textValue")return false;let n=il(e);return n==="contentControlProperties"?true:n==="generic"&&e.localName==="sdtPr"&&e.namespaceUri===O}function aT(e){if(e.kind==="textValue")return false;let n=il(e);return n==="contentControlEndProperties"?true:n==="generic"&&e.localName==="sdtEndPr"&&e.namespaceUri===O}function Xn(e){return e.kind==="textValue"||!we(e)?void 0:e.children.find(t=>t.kind!=="textValue"&&Xg(t))}function Bn(e){return e.kind==="textValue"||!we(e)?void 0:e.children.find(t=>t.kind!=="textValue"&&zg(t))}function al(e){if(e.kind==="textValue"||!we(e))return null;let n=[],t=0;for(let r of e.children)if(r.kind!=="textValue"&&!(Xg(r)||aT(r))){if(zg(r)){if(t+=1,t>1)return null;n.push(...r.children);continue}n.push(r);}return n}function Ie(e,n,t=iT[n]??O){return !e||e.kind==="textValue"?void 0:e.children.find(o=>o.kind!=="textValue"&&o.localName===n&&o.namespaceUri===t)}function Ue(e,n,t){if(!e||e.kind==="textValue")return;let r=e.namespaceUri;return e.attributes.find(o=>o.localName===n&&o.namespaceUri===r)?.value}function lT(e){switch(e){case "sdtLocked":return {wrapper:true,content:false};case "contentLocked":return {wrapper:false,content:true};case "sdtContentLocked":return {wrapper:true,content:true};default:return {wrapper:false,content:false}}}function Sd(e,n){return {wrapper:e.wrapper||n.wrapper,content:e.content||n.content}}function io(e){let n=Ie(Xn(e),"lock");return lT(Ue(n,"val"))}function st(e){return Ie(Xn(e),"dataBinding")!==void 0}function qg(e){return Ie(Xn(e),"repeatingSection")!==void 0}function ki(e){let n=Xn(e);return n?Xo(n,"showingPlcHdr"):false}function ln(e){let n=Xn(e);return n?Xo(n,"temporary"):false}function ao(e,n){let t=null,r=(o,i)=>{if(o.kind==="textValue"||t)return;if(o.id===n){t=i;return}let a=o.kind==="hyperlink"||o.kind==="fldSimple"||o.kind==="contentControl"||o.kind==="generic"&&o.localName==="fldSimple"?o:i;for(let l of o.children)r(l,a);};for(let o of e.children)r(o,null);return t}function Ad(e,n,t){let r=ao(e,n.runId);return r===null?false:t===void 0||ao(e,t.runId)!==r}function je(e,n){let t=qn(e,n);if(t)return t;let r=Ct(e,n);return r[r.length-1]??null}function lo(e){let n=Xn(e);return n?Ie(n,"repeatingSection")?"repeatingSection":Ie(n,"checkbox")?"checkbox":Ie(n,"dropDownList")?"dropdown":Ie(n,"comboBox")?"combo":Ie(n,"date")?"date":Ie(n,"picture")?"picture":Ie(n,"text")?"text":"richText":"richText"}function Ct(e,n){let t=[],r=Z(e,n);for(;r;)we(r)&&t.push(r),r=Z(e,r.id);return t.reverse()}function Fn(e,n){let t=io(n);for(let r of Ct(e,n.id))t=Sd(t,io(r));return t}function ve(e,n){let t={wrapper:false,content:false},r=qn(e,n);r&&(t=Sd(t,io(r)));for(let o of Ct(e,n))t=Sd(t,io(o));return t}function qn(e,n){let t=R(e,n);return !t||t.kind==="textValue"||!we(t)?null:t}function bi(e){let n=Xn(e),t=Ie(n,"dropDownList")??Ie(n,"comboBox");if(!t)return [];let r=[];for(let o of t.children){if(o.kind==="textValue"||o.localName!=="listItem"||o.namespaceUri!==O)continue;let i=Ue(o,"value")??"",a=Ue(o,"displayText")??i;r.push({displayText:a,value:i});}return r}function Yg(e){let n=Ie(Xn(e),"checkbox");if(!n)return null;let t=n.children.find(l=>l.kind!=="textValue"&&l.localName==="checked"&&l.namespaceUri===j),r=Ue(t,"val"),o=r===void 0||!(r==="0"||r==="false"||r==="off"),i=n.children.find(l=>l.kind!=="textValue"&&l.localName==="checkedState"&&l.namespaceUri===j),a=n.children.find(l=>l.kind!=="textValue"&&l.localName==="uncheckedState"&&l.namespaceUri===j);return {checkbox:n,checked:o,checkedGlyph:Ue(i,"val")??"2612",uncheckedGlyph:Ue(a,"val")??"2610",checkedFont:Ue(i,"font"),uncheckedFont:Ue(a,"font")}}function sT(e,n){return n<1||n>12?0:n===2?e%4===0&&e%100!==0||e%400===0?29:28:n===4||n===6||n===9||n===11?30:31}function Pi(e){let n=e.trim(),t=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})?)?$/.exec(n);if(!t)return null;let r=Number(t[1]),o=Number(t[2]),i=Number(t[3]),a=sT(r,o);if(a===0||i<1||i>a)return null;let l=`${t[1]}-${t[2]}-${t[3]}`;if(t[4]===void 0)return `${l}T00:00:00Z`;let s=Number(t[4]),d=Number(t[5]),c=Number(t[6]);if(s>23||d>59||c>59)return null;let u=t[7]!==void 0?`.${t[7]}`:"",f=t[8]??"Z";return dT(f)?`${l}T${t[4]}:${t[5]}:${t[6]}${u}${f}`:null}function dT(e){if(e==="Z")return true;if(e.length!==6||e[0]!=="+"&&e[0]!=="-")return false;let n=e[0]==="+"?1:-1,t=Number(e.slice(1,3)),r=Number(e.slice(4,6));if(!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<0||r>59)return false;let o=n*(t*60+r);return !(o>840||o<-840||Math.abs(o)===840&&r!==0)}function ll(e,n){let t=Pi(e);if(!t)return null;let r=/^(\d{4})-(\d{2})-(\d{2})/.exec(t);if(!r)return null;let o=Number(r[1]),i=Number(r[2]),a=Number(r[3]),l=n&&n.length>0?n:"M/d/yyyy",s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d=["January","February","March","April","May","June","July","August","September","October","November","December"];return l.replace(/yyyy|yy|MMMM|MMM|MM|M|dd|d/g,c=>{switch(c){case "yyyy":return String(o);case "yy":return String(o).slice(-2);case "MMMM":return d[i-1];case "MMM":return s[i-1];case "MM":return String(i).padStart(2,"0");case "M":return String(i);case "dd":return String(a).padStart(2,"0");case "d":return String(a);default:return c}})}function so(e){let n=e.trim().toLowerCase();return n==="true"||n==="1"||n==="checked"||n==="on"?true:n==="false"||n==="0"||n==="unchecked"||n==="off"?false:null}function Te(e,n){let t=qn(e,n);return t&&st(t)?true:Ct(e,n).some(st)}function Le(e,n){return {ok:true,part:e,effect:n}}function T(e,n){return e.ok?Le(e.part,n):{ok:false,reason:"tree-invariant",detail:JSON.stringify(e.issues)}}function Ke(e,n){return e.kind==="textValue"?{id:n(),kind:"textValue",value:e.value}:{...e,id:n(),children:e.children.map(t=>Ke(t,n))}}function ye(e){return e.kind==="textValue"?void 0:e.children.find(t=>t.kind!=="textValue"&&dt(t))}function dt(e){return e.kind==="paragraphProperties"?true:e.kind==="generic"&&e.localName==="pPr"&&e.namespaceUri===O}function Yn(e){return e.kind==="textValue"?void 0:e.children.find(t=>t.kind!=="textValue"&&Yt(t))}function Yt(e){return e.kind==="runProperties"?true:e.kind==="generic"&&e.localName==="rPr"&&e.namespaceUri===O}function Vn(e,n){return !e||e.kind==="textValue"?void 0:e.children.find(r=>r.kind!=="textValue"&&r.localName===n&&r.namespaceUri===O)}function Z(e,n){return Ce(e,n)}var cT="http://schemas.openxmlformats.org/officeDocument/2006/math";function uT(e){return e.kind!=="textValue"&&e.namespaceUri===cT&&e.localName==="oMath"}function En(e){return e!==null&&e.kind==="paragraph"}function Q(e){return Qg(e,null)}var Zg=new WeakMap;function Pe(e){let n=Zg.get(e);if(n)return n;let t=fT(e);return Zg.set(e,t),t}function fT(e){let n=new Map,t=Qg(e,n),r=t.length===0?0:t[t.length-1].end,o=i=>n.get(typeof i=="string"?i:i.id)??null;return {length:r,segments:t,spanOf:o,lengthOf:i=>{let a=o(i);return a===null?0:a.end-a.start}}}function Qg(e,n){let t=[],r=0,o=(m,g)=>{n!==null&&n.set(m.id,{start:g,end:r});},i=$a(e),a=nl(e),l=new Map(i.map(m=>[m.node.id,m])),s=new Map(a.map(m=>[m.node.id,m])),d=new Set;for(let m of i)for(let g of m.removeNodeIds)d.add(g);let c=m=>{t.push({runId:m.runId,node:m.node,start:r,end:r+1,removeNodeIds:m.removeNodeIds,...m.formatRunIds&&m.formatRunIds.length>0?{formatRunIds:m.formatRunIds}:{}}),r+=1;},u=(m,g,p=Wr())=>{let x=r,y=m.kind!=="textValue"&&"localName"in m?_n(p,m):p,N=l.get(m.id);if(N&&N.kind==="complex"){c(N),o(m,x);return}if(d.has(m.id)){o(m,x);return}let b=s.get(m.id);if(b){c(b),o(m,x);return}if(yi(m)){c({runId:g,node:m,removeNodeIds:[m.id]}),o(m,x);return}if(qp(m)||Xt(m,"begin")||Xt(m,"separate")||Xt(m,"end")||di(m)){o(m,x);return}if(m.kind==="textValue"){t.push({runId:g,node:m,start:r,end:r+m.value.length}),r+=m.value.length,o(m,x);return}if(m.kind==="tab"||m.kind==="hardBreak"){t.push({runId:g,node:m,start:r,end:r+1}),r+=1,o(m,x);return}if(m.kind==="drawing"){c({runId:g,node:m,removeNodeIds:[m.id]}),o(m,x);return}if(m.kind==="runProperties"){o(m,x);return}if(m.kind==="generic"){if(Sm(m)){let h=Ea(m,y,rt);c({runId:g,node:h.segmentNode,removeNodeIds:h.removeNodeIds});}o(m,x);return}if(we(m)){o(m,x);return}if(m.kind==="text"||m.kind==="deletedText"){for(let h of m.children)u(h,g,y);o(m,x);return}for(let h of m.children)u(h,g,y);o(m,x);},f=(m,g)=>{let p=r;if(m.kind==="textValue"||g>=Jg){o(m,p);return}if(uT(m)){c({runId:m.id,node:m,removeNodeIds:[m.id]}),o(m,p);return}if(Qr(m)){let x=l.get(m.id);x&&c(x),o(m,p);return}if(m.kind==="run"){let x=_n(Wr(),m);for(let y of m.children)u(y,m.id,x);o(m,p);return}if(m.kind==="hyperlink"||he(m.kind)){for(let x of m.children)f(x,g+1);o(m,p);return}if(we(m)&&g<ol){let x=Bn(m);if(x){let y=r;for(let N of x.children)f(N,g+1);n?.set(x.id,{start:y,end:r});}}o(m,p);};for(let m of e.children)f(m,0);return t}var Jg=32;function Zt(e,n=0){if(e.kind==="run")return [e];if(e.kind==="textValue"||n>=Jg)return [];if(e.kind==="hyperlink"||he(e.kind))return e.children.flatMap(t=>Zt(t,n+1));if(we(e)&&n<ol){let t=Bn(e);return t?t.children.flatMap(r=>Zt(r,n+1)):[]}return []}function Md(e,n,t){let r=Q(e),o=t===null?r:r.filter(d=>sl(t,d.node.id));for(let d of o)if(d.node.kind==="textValue"&&!(n<=d.start||n>=d.end))return {kind:"withinValue",segment:d};let i=o.find(d=>d.start===n);if(i)return {kind:"atBoundary",segment:i};let a=t===null?e.children.filter(d=>d.kind==="run"):e.children.flatMap(d=>Zt(d)).filter(d=>sl(t,d.id)),l=a[a.length-1];return l&&l.kind!=="textValue"?{kind:"appendToRun",run:l}:{kind:"newRun",holder:t===null||t.kind==="textValue"||sl(t,e.id)?e:mT(t)}}function mT(e){for(let n of e.children)if(n.kind!=="textValue"&&(n.kind==="contentControlContent"||n.kind==="generic"&&n.localName==="sdtContent"))return n;return e}function ex(e,n,t){let r=Md(e,n,t);return r.kind==="withinValue"||r.kind==="atBoundary"?r.segment.runId:r.kind==="appendToRun"?r.run.id:r.holder.id}function sl(e,n){return e.id===n?true:e.kind==="textValue"?false:e.children.some(t=>sl(t,n))}function Zn(e){let n=Q(e);return n.length===0?0:n[n.length-1].end}function nx(e,n){if(n.add(e.id),e.kind!=="textValue")for(let t of e.children)nx(t,n);}function tx(e,n,t){let r=ao(e,t);if(!r||r.kind!=="contentControl")return null;let o=new Set;nx(r,o);let i=Number.MAX_SAFE_INTEGER,a=-1;for(let l of n)o.has(l.runId)&&(l.start<i&&(i=l.start),l.end>a&&(a=l.end));return a<0?null:{controlId:r.id,start:i,end:a}}function rx(e,n){let t=Q(e),r=[...t].reverse().find(i=>i.end===n&&i.end>i.start);if(!r)return null;let o=tx(e,t,r.runId);return o&&o.end===n?o:null}function ox(e,n){let t=Q(e),r=t.find(i=>i.start===n&&i.end>i.start);if(!r)return null;let o=tx(e,t,r.runId);return o&&o.start===n?o:null}function co(e,n){let t=Pe(e);for(let r of t.segments)if(r.removeNodeIds&&r.start<n&&n<r.end)return true;for(let r of e.children){if(r.kind==="run")continue;let o=t.spanOf(r);if(o&&o.start<n&&n<o.end)return true}return false}function Be(e,n){for(let t of Q(e)){if(t.node.kind!=="textValue"||n<=t.start||n>=t.end)continue;let r=n-t.start,o=t.node.value.charCodeAt(r-1),i=t.node.value.charCodeAt(r);if(o>=55296&&o<=56319&&i>=56320&&i<=57343)return true}return false}var pT="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",gT="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",Or=2e4,sx=1e6,xT=256;function wi(e=Or,n=xT){return {visited:0,maxVisited:e,parts:0,maxParts:n,truncated:false}}function ix(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function hT(e,n){if(!(e.kind==="textValue"||!("attributes"in e))){for(let t of e.attributes)if(t.localName===n&&(t.namespaceUri===O||t.namespaceUri===""))return t.value}}function yT(e){let n=hT(e,"customMarkFollows");return n===void 0?e.kind==="textValue"||!("attributes"in e)?false:e.attributes.some(t=>t.localName==="customMarkFollows"&&(t.namespaceUri===O||t.namespaceUri==="")):!(n==="0"||n==="false"||n==="off")}function dx(e){return e?e.visited>=e.maxVisited?(e.truncated=true,false):(e.visited+=1,true):true}function OT(e){return e.parts>=e.maxParts?(e.truncated=true,false):(e.parts+=1,true)}function Ge(e,n){let t=n==="footnote"?pT:gT,r=n==="footnote"?"footnotes":"endnotes",o=e.relationships.get(e.mainDocumentPart)??[];for(let i of o){if(i.type!==t)continue;let a=Me(i);if(a.mode!=="Internal"||!a.target.ok)continue;let l=e.parts.get(a.target.partName);if(l&&l.root.localName===r)return l}return null}function NT(e,n,t,r,o,i){let a=el(n);if(!a)return;let l=gn(n);l===null||e.length>=i||e.push({noteKind:a,noteId:l,nodeId:n.id,paragraphId:t,atomOffset:r,customMarkFollows:yT(n),partName:o});}function cx(e,n,t,r,o){if(!(n.length>=r||t&&t.truncated))for(let i of Q(e)){if(n.length>=r||t&&t.truncated||!dx(t))return;i.node.kind==="noteReference"&&NT(n,i.node,e.id,i.start,o,r);}}var ax=new WeakMap;function ux(e,n){let t=ax.get(e);if(t)return t;let r=[];return cx(e,r,void 0,Or,n),ax.set(e,r),r}var _d=Object.freeze([]),lx=new WeakMap;function fx(e,n,t){if(e.kind==="textValue"||t>64)return _d;if(e.kind==="paragraph")return ux(e,n);let r=lx.get(e);if(r)return r;let o=null;for(let a of e.children){let l=fx(a,n,t+1);if(l.length===0)continue;o??=[];let s=Or-o.length;if(s<=0)break;o.push(...l.slice(0,s));}let i=o?Object.freeze(o):_d;return lx.set(e,i),i}function kT(e,n){let t=n?.maxHits??Or,r=n?.budget;if(t<=0)return _d;if(r===void 0&&t<=Or){let l=fx(e.root,e.name,0);return l.length>t?l.slice(0,t):l}let o=r===void 0,i=[],a=(l,s)=>{if(!(i.length>=t||r&&r.truncated)){if(s>64){r&&(r.truncated=true);return}if(dx(r)&&l.kind!=="textValue"){if(l.kind==="paragraph"){if(o){for(let d of ux(l,e.name)){if(i.length>=t)return;i.push(d);}return}cx(l,i,r,t,e.name);return}for(let d of l.children)a(d,s+1);}}};return a(e.root,0),i}function Nr(e,n){let t=n?.budget??wi(),r=n?.maxHits??Or,o=[];for(let i of e.parts.values()){if(t.truncated)break;if(!i.name.endsWith(".xml"))continue;if(!OT(t))break;let a=kT(i,{maxHits:Number.isFinite(r)?Math.max(0,r-o.length):r,budget:t});o.push(...a);}return o}function EB(e){let n=Ge(e,"footnote"),t=Ge(e,"endnote"),r=[],o=wi(),i=Or,a=Nr(e,{budget:o,maxHits:i}),l=(s,d)=>{let c=s==="footnote"?n:t;if(!c)return false;let u=It(c.root,d);return u!==void 0&&(hi(u)||hr(u)!==null)};for(let s of a)if(!l(s.noteKind,s.noteId)&&(r.push({code:"dangling-note-reference",noteKind:s.noteKind,noteId:s.noteId,sourceNodeId:s.nodeId}),r.length>=Oi))break;return (o.truncated||a.length>=i)&&r.push({code:"note-reference-scan-truncated"}),r}function RB(e,n){return It(e.root,n)!==void 0}function mx(e){let n=[];if(e.root.kind!=="footnotes"&&e.root.kind!=="endnotes")return n;for(let t of e.root.children){if(n.length>=Oi)break;if(!ix(t,"footnote")&&!ix(t,"endnote")&&t.kind!=="note"||!hi(t))continue;let r=gn(t);r!==null&&r>0&&n.push(r);}return n}var bT="http://schemas.openxmlformats.org/package/2006/relationships",PT="application/vnd.openxmlformats-package.relationships+xml";function wT(e){let n=e.lastIndexOf("/");return `${e.slice(0,n)}/_rels/${e.slice(n+1)}.rels`}function px(e,n,t,r){if(!/^(footnotes|endnotes)\.xml$/.test(r))return null;let o=e.mainDocumentPart,i=wT(o),a=e.parts.get(i),l=ne(`<Relationships xmlns="${bT}"><Relationship Id="${n}" Type="${t}" Target="${r}"/></Relationships>`,{name:i,contentType:PT});if(!l.ok)return null;let s=e.relationships.get(o)??[];if(s.some(g=>g.id===n))return null;let d={ownerPart:o,id:n,type:t,rawTarget:r,targetMode:"Internal",order:s.reduce((g,p)=>Math.max(g,p.order),-1)+1},c=new Map([...e.relationships,[o,[...s,d]]]);if(!a)return Object.freeze({...e,parts:new Map([...e.parts,[i,l.part]]),relationships:c});let u=S(a),f=l.part.root.children[0];if(!f)return null;let m=M(a,a.root.id,a.root.children.length,[Dn(f,u)]);return m.ok?Object.freeze({...e,parts:new Map([...e.parts,[i,m.part]]),relationships:c}):null}var cl=O,ET="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",gx="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",Dd="/word/settings.xml";function xx(e,n){let t=e,r=Tt(t);if(!r){let i=RT(t);if(!i)return null;t=i,r=Tt(t);}if(!r)return null;let o=IT(r,n);return o?D(t,o):null}function RT(e){if(e.parts.has(Dd))return e;let n=`<w:settings xmlns:w="${cl}"></w:settings>`,t=ne(n,{name:Dd,contentType:gx});if(!t.ok)return null;let r=D(e,t.part),o=kt(r),i=ur(r,o,ET,"settings.xml");return i?(r=i,bt(r,Dd,gx)):null}function IT(e,n){let t=S(e),r=e.root.children.filter(a=>a.kind==="textValue"||a.localName!=="footnotePr"&&a.localName!=="endnotePr"),o=[];if(n.footnote)o.push(ul(t,"footnotePr",n.footnote));else {let a=e.root.children.find(l=>l.kind!=="textValue"&&l.localName==="footnotePr");a&&o.push(a);}if(n.endnote)o.push(ul(t,"endnotePr",n.endnote));else {let a=e.root.children.find(l=>l.kind!=="textValue"&&l.localName==="endnotePr");a&&o.push(a);}let i=L(e,e.root.id,[...r,...o]);return i.ok?i.part:null}function hx(e,n,t){let r=e.parts.get(e.mainDocumentPart);if(!r)return null;let o=Et(r.root);if(n>=o.length)return null;let i=o[n];if(!i)return null;let a=S(r),l=i.children.filter(c=>c.kind==="textValue"||c.localName!=="footnotePr"&&c.localName!=="endnotePr"),s=[];if(t.footnote)s.push(ul(a,"footnotePr",t.footnote));else {let c=i.children.find(u=>u.kind!=="textValue"&&u.localName==="footnotePr");c&&s.push(c);}if(t.endnote)s.push(ul(a,"endnotePr",t.endnote));else {let c=i.children.find(u=>u.kind!=="textValue"&&u.localName==="endnotePr");c&&s.push(c);}let d=L(r,i.id,[...s,...l]);return d.ok?D(e,d.part):null}function ul(e,n,t){let r=[];return t.position!==void 0&&r.push(dl(e,"pos",t.position)),t.numFmt!==void 0&&r.push(dl(e,"numFmt",t.numFmt)),t.numStart!==void 0&&r.push(dl(e,"numStart",String(t.numStart))),t.numRestart!==void 0&&r.push(dl(e,"numRestart",t.numRestart)),{id:e(),kind:"generic",namespaceUri:cl,localName:n,prefix:"w",namespaceBindings:[],attributes:[],children:r}}function dl(e,n,t){return {id:e(),kind:"generic",namespaceUri:cl,localName:n,prefix:"w",namespaceBindings:[],attributes:[{kind:"wmlVal",namespaceUri:cl,localName:"val",prefix:"w",value:t}],children:[]}}var ct=O,TT="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",CT="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",vT="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",ST="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",AT=4096,yx={footnote:"FootnoteReference",endnote:"EndnoteReference"};function Ox(e){return e.localName==="val"&&(e.namespaceUri===O||e.namespaceUri==="")}function kx(e,n,t){if(e.kind!=="run"||n===t||!e.children.some(l=>MT(l)))return e;let r=yx[n],o=yx[t],i=false,a=e.children.map(l=>{if(l.kind!=="runProperties")return l;let s=false,d=l.children.map(c=>c.kind!=="generic"||c.namespaceUri!==O||c.localName!=="rStyle"||!c.attributes.some(f=>Ox(f)&&f.value===r)?c:(s=true,i=true,{...c,attributes:c.attributes.map(f=>Ox(f)&&f.value===r?{...f,value:o}:f)}));return s?{...l,children:d}:l});return i?{...e,children:a}:e}function MT(e){return el(e)!==null||Fg(e)!==null}var _T=new Set(["insertNote","deleteNote","convertNote","convertAllNotes","setNoteProperties"]);function Ud(e){return _T.has(e.op)}function H(e,n){return n?{ok:false,reason:e,detail:n}:{ok:false,reason:e}}function fl(e){return e==="footnote"||e==="endnote"}function bx(e){return typeof e=="number"&&Number.isInteger(e)&&e>=Id&&e<=xi}function Ei(){return wi(sx)}function Px(e,n,t){if(!Ud(n))return H("invalidArgs","unknown-op");switch(n.op){case "insertNote":return DT(e,n);case "deleteNote":return wx(e,n,t);case "convertNote":return Rx(e,n,t);case "convertAllNotes":return BT(e,n,t);case "setNoteProperties":return FT(e,n)}}function DT(e,n){if(!fl(n.noteKind))return H("invalidArgs","noteKind");if(typeof n.paragraphId!="string"||n.paragraphId.length===0)return H("invalidArgs","paragraphId");if(!Number.isInteger(n.offset)||n.offset<0)return H("invalidArgs","offset");let t=HT(e,n.paragraphId);if(!t.ok)return H("invalidArgs",t.detail);let r=t.paragraph,o=GT(r);if(n.offset>o)return H("invalidArgs","offset-out-of-range");let i=e,a=Ix(i,n.noteKind);if(!a.ok)return a;i=a.package;let l=a.createdPartName,s=Ge(i,n.noteKind);if(!s)return H("tree-invariant","missing-notes-part");let d=vd(s.root);if(d===null)return H("invalidArgs","note-id-exhausted");let c=WT(n.noteKind,d),u=ne(c,{name:s.name,contentType:s.contentType});if(!u.ok)return H("tree-invariant","note-body-parse");let f=u.part.root.children.find(E=>E.kind==="note");if(!f)return H("tree-invariant","note-body-missing");let m=S(s),g=Dn(f,m),p=M(s,s.root.id,s.root.children.length,[g]);if(!p.ok)return H("tree-invariant","note-body-insert");i=D(i,p.part);let x=i.parts.get(t.partName);if(!x)return H("tree-invariant","story-missing");let y=R(x,n.paragraphId);if(!y||y.kind!=="paragraph")return H("tree-invariant","paragraph-missing");if(!KT(x,n.paragraphId))return H("tree-invariant","paragraph-not-in-body");let N=n.noteKind==="footnote"?"footnoteReference":"endnoteReference",b=n.noteKind==="footnote"?"FootnoteReference":"EndnoteReference",h=S(x),P=$T(h,N,d,b),k=zT(x,y,n.offset,[P]);return k?(i=D(i,k),{ok:true,package:i,impact:"global",noteId:d,noteKind:n.noteKind,...l?{createdPartName:l}:{}}):H("tree-invariant","reference-insert")}function wx(e,n,t){if(!fl(n.noteKind))return H("invalidArgs","noteKind");if(!bx(n.noteId))return H("invalidArgs","noteId");let r=Ge(e,n.noteKind);if(!r)return H("invalidArgs","missing-notes-part");if(!It(r.root,n.noteId))return H("invalidArgs","note-not-found");let i=qT(e,n.noteKind,n.noteId,t?.scanBudget);if(!i)return H("tree-invariant","reference-scan-truncated");let a=i,l=Ge(a,n.noteKind);if(!l)return H("tree-invariant","notes-part-lost");let s=It(l.root,n.noteId);if(!s)return {ok:true,package:a,impact:"global",noteId:n.noteId,noteKind:n.noteKind};let d=oe(l,s.id);return d.ok?(a=D(a,d.part),{ok:true,package:a,impact:"global",noteId:n.noteId,noteKind:n.noteKind}):H("tree-invariant","note-body-remove")}function Ex(e,n,t){let r=t?.beforeBudget??Ei(),o=t?.afterBudget??Ei(),i=Nr(e,{budget:r,maxHits:Number.POSITIVE_INFINITY}),a=Nr(n,{budget:o,maxHits:Number.POSITIVE_INFINITY});if(r.truncated||o.truncated)return null;let l=new Set(a.map(c=>`${c.noteKind}:${c.noteId}`)),s=n,d=new Set;for(let c of i){let u=`${c.noteKind}:${c.noteId}`;if(l.has(u)||d.has(u)||(d.add(u),c.noteId<=0))continue;let f=Ge(s,c.noteKind);if(!f||!It(f.root,c.noteId))continue;let m=wx(s,{noteKind:c.noteKind,noteId:c.noteId});if(!m.ok)return null;s=m.package;}return s}function Rx(e,n,t,r){if(!fl(n.fromKind))return H("invalidArgs","fromKind");if(!bx(n.noteId))return H("invalidArgs","noteId");let o=n.fromKind==="footnote"?"endnote":"footnote",i=Ge(e,n.fromKind);if(!i)return H("invalidArgs","missing-source-part");let a=It(i.root,n.noteId);if(!a)return H("invalidArgs","note-not-found");let l=Cd(a);if(l==="separator"||l==="continuationSeparator"||l==="continuationNotice")return H("invalidArgs","separator-not-convertible");let s=UT(e,n.fromKind,n.noteId,t,r);if(!s)return H("tree-invariant","reference-scan-truncated");let d=e,c=Ix(d,o);if(!c.ok)return c;d=c.package;let u=c.createdPartName,f=Ge(d,o);if(!f)return H("tree-invariant","missing-target-part");let m=vd(f.root);if(m===null)return H("invalidArgs","note-id-exhausted");let g=S(f),p=QT(a,n.fromKind,o,m,g),x=M(f,f.root.id,f.root.children.length,[p]);if(!x.ok)return H("tree-invariant","target-insert");d=D(d,x.part);let y=Ge(d,n.fromKind);if(!y)return H("tree-invariant","source-lost");let N=It(y.root,n.noteId);if(N){let h=oe(y,N.id);if(!h.ok)return H("tree-invariant","source-remove");d=D(d,h.part);}let b=ZT(d,n.fromKind,o,m,s);return b?(d=b,{ok:true,package:d,impact:"global",noteId:m,noteKind:o,...u?{createdPartName:u}:{}}):H("tree-invariant","reference-rewrite")}function UT(e,n,t,r,o){let i=s=>s.noteKind===n&&s.noteId===t;if(o){let s=o.filter(i);if(s.every(d=>LT(e,d)))return s}let a=r?.scanBudget??Ei(),l=Nr(e,{budget:a,maxHits:Number.POSITIVE_INFINITY}).filter(i);return a.truncated?null:l}function LT(e,n){let t=e.parts.get(n.partName);return t!==void 0&&R(t,n.nodeId)!==null}function BT(e,n,t){if(!fl(n.fromKind))return H("invalidArgs","fromKind");let r=Ge(e,n.fromKind);if(!r)return {ok:true,package:e,impact:"global"};let o=mx(r);if(o.length===0)return {ok:true,package:e,impact:"global"};let i=t?.scanBudget??Ei(),a=Nr(e,{budget:i,maxHits:Number.POSITIVE_INFINITY});if(i.truncated)return H("tree-invariant","reference-scan-truncated");let l=e,s,d,c=n.fromKind==="footnote"?"endnote":"footnote";for(let u of o){let f=Rx(l,{fromKind:n.fromKind,noteId:u},void 0,a);if(!f.ok)return f;l=f.package,f.createdPartName&&(s=f.createdPartName),d=f.noteId;}return {ok:true,package:l,impact:"global",...d!==void 0?{noteId:d,noteKind:c}:{},...s?{createdPartName:s}:{}}}function FT(e,n){if(n.scope!=="document"&&n.scope!=="section")return H("invalidArgs","scope");if(!n.footnote&&!n.endnote)return H("invalidArgs","empty");if(n.footnote?.position!==void 0&&!Gg(n.footnote.position))return H("invalidArgs","footnote-position");if(n.endnote?.position!==void 0&&(n.endnote.position==="pageBottom"||!Kg(n.endnote.position)))return H("invalidArgs","endnote-pageBottom");for(let r of [n.footnote,n.endnote])if(r){if(r.numRestart!==void 0&&!$g(r.numRestart))return H("invalidArgs","numRestart");if(r.numFmt!==void 0&&(typeof r.numFmt!="string"||!$(r.numFmt)))return H("invalidArgs","numFmt");if(r.numStart!==void 0&&(!Number.isInteger(r.numStart)||r.numStart<0||r.numStart>xi))return H("invalidArgs","numStart")}if(n.scope==="document"){let r=xx(e,n);return r?{ok:true,package:r,impact:"global"}:H("tree-invariant","settings-write")}if(n.sectionIndex===void 0||!Number.isInteger(n.sectionIndex)||n.sectionIndex<0||n.sectionIndex>=AT)return H("invalidArgs","sectionIndex");let t=hx(e,n.sectionIndex,n);return t?{ok:true,package:t,impact:"global"}:H("invalidArgs","section-write")}function Ix(e,n){if(Ge(e,n))return {ok:true,package:e,impact:"global"};let r=n==="footnote"?"/word/footnotes.xml":"/word/endnotes.xml",o=n==="footnote"?"footnotes.xml":"endnotes.xml",i=n==="footnote"?TT:CT,a=n==="footnote"?vT:ST;if(e.parts.has(r)||e.partBytes.has(r))return H("tree-invariant","part-name-collision");let l=VT(r,a,n);if(!l)return H("tree-invariant","empty-notes-part");let s=D(e,l),d=kt(s),c=px(s,d,i,o);if(!c)return H("tree-invariant","relationship");s=c;let u=bt(s,r,a);return u?(s=u,{ok:true,package:s,impact:"global",createdPartName:r}):H("tree-invariant","content-type")}function VT(e,n,t){let r=t==="footnote"?"footnotes":"endnotes",o=t==="footnote"?"footnote":"endnote",i=`<w:${r} xmlns:w="${ct}"><w:${o} w:type="separator" w:id="-1"><w:p><w:r><w:separator/></w:r></w:p></w:${o}><w:${o} w:type="continuationSeparator" w:id="0"><w:p><w:r><w:continuationSeparator/></w:r></w:p></w:${o}></w:${r}>`,a=ne(i,{name:e,contentType:n});return a.ok?a.part:null}function WT(e,n){let t=e==="footnote"?"footnotes":"endnotes",r=e==="footnote"?"footnote":"endnote";return `<w:${t} xmlns:w="${ct}"><w:${r} w:id="${n}"><w:p><w:r><w:rPr><w:rStyle w:val="${e==="footnote"?"FootnoteReference":"EndnoteReference"}"/></w:rPr><w:${e==="footnote"?"footnoteRef":"endnoteRef"}/></w:r><w:r><w:t xml:space="preserve"></w:t></w:r></w:p></w:${r}></w:${t}>`}function HT(e,n){let t=e.parts.get(e.mainDocumentPart);if(t){let o=Tx(t,n);if(o)return {ok:true,partName:t.name,paragraph:o}}let r=wi();for(let o of e.parts.values()){if(!o.name.endsWith(".xml"))continue;if(r.parts>=r.maxParts)break;r.parts+=1;let i=R(o,n);if(i&&i.kind==="paragraph")return o.name===e.mainDocumentPart?{ok:false,detail:"paragraph-not-in-body"}:{ok:false,detail:"story-not-body"}}return {ok:false,detail:"paragraph-not-found"}}function jT(e){for(let n of e.root.children)if(n.kind==="body"||n.kind!=="textValue"&&n.namespaceUri===O&&n.localName==="body")return n;return null}function Tx(e,n){let t=jT(e);return t?Cx(t,n,0):null}function KT(e,n){return Tx(e,n)!==null}function Cx(e,n,t){if(t>64)return null;if(e.kind==="paragraph"&&e.id===n)return e;if(e.kind==="textValue")return null;for(let r of e.children){let o=Cx(r,n,t+1);if(o)return o}return null}function GT(e){return vx(e).reduce((n,t)=>Math.max(n,t.end),0)}function vx(e){let n=[],t=0,r=$a(e),o=nl(e),i=new Map(r.map(c=>[c.node.id,c])),a=new Map(o.map(c=>[c.node.id,c])),l=new Set;for(let c of r)for(let u of c.removeNodeIds)l.add(u);let s=(c,u)=>{n.push({runId:c,node:u,start:t,end:t+1}),t+=1;},d=(c,u)=>{let f=i.get(c.id);if(f&&f.kind==="complex"){s(u,c);return}if(!l.has(c.id)){if(a.has(c.id)||yi(c)){s(u,c);return}if(c.kind==="textValue"){n.push({runId:u,node:c,start:t,end:t+c.value.length}),t+=c.value.length;return}if(c.kind==="tab"||c.kind==="hardBreak"){s(u,c);return}if(!(c.kind==="runProperties"||c.kind==="generic"||Qe(c))){if(c.kind==="text"){for(let m of c.children)d(m,u);return}for(let m of c.children)d(m,u);}}};return zt(e.children,0,c=>{if(Qr(c)){i.get(c.id)&&s("",c);return}if(c.kind==="run")for(let u of c.children)d(u,c.id);}),n}function $T(e,n,t,r){return {id:e(),kind:"run",namespaceUri:ct,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"runProperties",namespaceUri:ct,localName:"rPr",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"generic",namespaceUri:ct,localName:"rStyle",prefix:"w",namespaceBindings:[],attributes:[{kind:"wmlVal",namespaceUri:ct,localName:"val",prefix:"w",value:r}],children:[]}]},{id:e(),kind:"noteReference",namespaceUri:ct,localName:n,prefix:"w",namespaceBindings:[],attributes:[{kind:"genericExtension",namespaceUri:ct,localName:"id",prefix:"w",value:String(t)}],children:[]}]}}function zT(e,n,t,r){let o=vx(n),i=S(e),a=o.reduce((d,c)=>Math.max(d,c.end),0);for(let d of o){if(d.node.kind!=="textValue"||t<=d.start||t>=d.end)continue;let c=t-d.start,u=d.node.value,f=XT(n,d.node.id);if(!f)return null;let m=R(e,d.runId);if(!m||m.kind!=="run"||n.children.findIndex(P=>P.id===m.id)<0)return null;let p={...m,id:i(),children:m.children.flatMap(P=>P.id===f.id?[Nx(i,u.slice(0,c))]:[P])},x={...m,id:i(),children:m.children.flatMap(P=>P.id===f.id?[Nx(i,u.slice(c))]:[Sx(P,i)])},y=Dn(p,i),N=Dn(x,i),b=n.children.flatMap(P=>P.id===m.id?[y,...r,N]:[P]),h=L(e,n.id,b);return h.ok?h.part:null}if(t===0){let d=n.children[0]?.kind==="paragraphProperties"?1:0,c=M(e,n.id,d,r);return c.ok?c.part:null}if(t>=a){let d=M(e,n.id,n.children.length,r);return d.ok?d.part:null}let l=o.find(d=>d.start===t);if(l?.runId){let d=n.children.findIndex(c=>c.id===l.runId);if(d>=0){let c=M(e,n.id,d,r);return c.ok?c.part:null}}if(l&&!l.runId){let d=n.children.findIndex(u=>u.id===l.node.id),c=M(e,n.id,Math.max(0,d),r);return c.ok?c.part:null}let s=M(e,n.id,n.children.length,r);return s.ok?s.part:null}function Sx(e,n){return e.kind==="textValue"?{...e,id:n()}:{...e,id:n(),children:e.children.map(t=>Sx(t,n))}}function Nx(e,n){return {id:e(),kind:"text",namespaceUri:ct,localName:"t",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"textValue",value:n}]}}function XT(e,n){let t=r=>{if(r.kind==="textValue")return null;if(r.kind==="text"&&r.children.some(o=>o.id===n))return r;for(let o of r.children){let i=t(o);if(i)return i}return null};return t(e)}function qT(e,n,t,r){let o=r??Ei(),i=Nr(e,{budget:o,maxHits:Number.POSITIVE_INFINITY}).filter(s=>s.noteKind===n&&s.noteId===t);if(o.truncated)return null;let a=e,l=new Map;for(let s of i){let d=l.get(s.partName)??[];d.push(s.nodeId),l.set(s.partName,d);}for(let[s,d]of l){let c=a.parts.get(s);if(!c)return null;let u=c;for(let f of d){if(!R(u,f))continue;let m=Ax(u,f),g=m&&YT(m,f)?m.id:f,p=oe(u,g);if(!p.ok)return null;u=p.part;}a=D(a,u);}return a}function Ax(e,n){let t=[e.root];for(;t.length>0;){let r=t.pop();if(r.kind!=="textValue"){if(r.kind==="run"&&r.children.some(o=>o.id===n))return r;for(let o of r.children)t.push(o);}}return null}function YT(e,n){for(let t of e.children)if(t.kind!=="runProperties"&&t.id!==n)return false;return true}function ZT(e,n,t,r,o){let i=e,a=t==="footnote"?"footnoteReference":"endnoteReference",l=new Map;for(let s of o){let d=l.get(s.partName)??[];d.push(s.nodeId),l.set(s.partName,d);}for(let[s,d]of l){let c=i.parts.get(s);if(!c)return null;let u=c;for(let f of d){let m=R(u,f);if(!m||m.kind==="textValue")return null;let g={...m,kind:"noteReference",localName:a,attributes:m.attributes.map(y=>y.localName==="id"&&(y.namespaceUri===O||y.namespaceUri==="")?{...y,value:String(r)}:y)},p=V(u,f,g);if(!p.ok)return null;u=p.part;let x=Ax(u,f);if(x){let y=kx(x,n,t);if(y!==x){let N=V(u,x.id,y);if(!N.ok)return null;u=N.part;}}}i=D(i,u);}return i}function QT(e,n,t,r,o){let i=t==="footnote"?"footnote":"endnote",a=t==="footnote"?"footnoteRef":"endnoteRef",l=s=>{if(s.kind==="textValue")return {...s,id:o()};let d=s.kind,c=s.localName,u=s.attributes;s.id===e.id||s.kind==="note"&&gn(s)===gn(e)?(d="note",c=i,u=s.attributes.map(g=>g.localName==="id"?{...g,value:String(r)}:g),u.some(g=>g.localName==="id")||(u=[...u,{kind:"genericExtension",namespaceUri:ct,localName:"id",prefix:"w",value:String(r)}])):(s.kind==="noteRef"||hr(s)===null&&(s.localName==="footnoteRef"||s.localName==="endnoteRef"))&&(d="noteRef",c=a);let f=s.children.map(l),m={...s,id:o(),kind:d,localName:c,attributes:u,children:f};return s.kind==="run"&&(m=kx(m,n,t)),m};return l(e)}var ml=32,Mx=1e4,Bx=2147483647,JT=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),Fx={richText:"richText",text:"plainText",dropDownList:"dropDownList",comboBox:"comboBox",date:"date",picture:"picture",docPartObj:"docPartObj",docPartList:"docPartList",group:"group",citation:"citation",bibliography:"bibliography",equation:"equation"};function tF(e){return e.kind==="contentControl"}function rF(e){return e.kind==="contentControlContent"}function pl(e){return e.kind==="contentControl"?true:e.kind==="generic"&&e.namespaceUri===O&&e.localName==="sdt"}function Bd(e){if(e.kind==="textValue")return [];let n=[];for(let t of e.children)t.kind!=="textValue"&&(t.kind==="contentControlContent"||t.localName==="sdtContent")&&n.push(...t.children);return n}function Ii(e,n=ml){let t=false;for(let i of e)if(pl(i)){t=true;break}if(!t)return e;let r=[],o=(i,a)=>{for(let l of i){if(!pl(l)){r.push(l);continue}if(a>=n){r.push(l);continue}o(Bd(l),a+1);}};return o(e,0),r}function gl(e){if(e.kind==="contentControl")return e.children.find(n=>n.kind==="contentControlProperties")}function eC(e){return e.kind!=="contentControl"?void 0:e.children.find(t=>t.kind==="contentControlProperties"||t.kind==="generic"&&t.localName==="sdtPr"&&t.namespaceUri===O)}function oF(e){if(e.kind==="contentControl")return e.children.find(n=>n.kind==="contentControlEndProperties")}function uo(e){if(e.kind==="contentControl")return e.children.find(n=>n.kind==="contentControlContent")}function Vx(e,n,t){if(e.kind!=="textValue"){for(let r of e.attributes)if(r.localName===n&&(r.namespaceUri===t||r.namespaceUri===""))return r.value}}function $e(e,n){return Vx(e,n,O)}function Ld(e,n){return Vx(e,n,j)}function Wx(e,n,t){if(!e||e.kind==="textValue")return [];let r=[];for(let o of e.children)o.kind!=="textValue"&&o.namespaceUri===n&&o.localName===t&&r.push(o);return r}function sn(e,n,t){return Wx(e,n,t)[0]}function _x(e){if(!e)return false;let n=$e(e,"val");return n===void 0||!(n==="0"||n==="false"||n==="off")}function nC(e){if(!e)return false;let n=Ld(e,"val");return n===void 0||!(n==="0"||n==="false"||n==="off")}function tC(e){if(e===void 0||!/^-?\d{1,10}$/.test(e))return;let n=Number(e);if(!(!Number.isInteger(n)||n<-2147483648||n>Bx))return n}function Dx(e,n){let t=sn(e,j,n);if(!t)return;let r=Ld(t,"val");if(r===void 0)return;let o=Ld(t,"font");return o===void 0?{value:r}:{value:r,font:o}}function rC(e){let n=[];for(let t of Wx(e,O,"listItem")){let r=$e(t,"value")??"",o=$e(t,"displayText")??r;n.push({displayText:o,value:r});}return n}function oC(e){let n=l=>{let s=sn(e,O,l);return s?$e(s,"val"):void 0},t=$e(e,"fullDate"),r=n("dateFormat"),o=n("lid"),i=n("storeMappedDataAs"),a=n("calendar");return {...t===void 0?{}:{fullDate:t},...r===void 0?{}:{dateFormat:r},...o===void 0?{}:{lid:o},...i===void 0?{}:{storeMappedDataAs:i},...a===void 0?{}:{calendar:a}}}function Wn(e){let n=eC(e),t=$e(sn(n,O,"alias")??kr,"val"),r=$e(sn(n,O,"tag")??kr,"val"),o=tC($e(sn(n,O,"id")??kr,"val")),i=$e(sn(n,O,"lock")??kr,"val"),a=i!==void 0&&JT.has(i)?i:"unlocked",l=sn(n,O,"placeholder"),s=l?$e(sn(l,O,"docPart")??kr,"val"):void 0,d=sn(n,O,"dataBinding"),c=d?$e(d,"xpath"):void 0,u=d?$e(d,"storeItemID"):void 0,f=d?$e(d,"prefixMappings"):void 0,m=$e(sn(n,O,"label")??kr,"val"),g=$e(sn(n,O,"tabIndex")??kr,"val"),p=g!==void 0&&/^\d{1,10}$/.test(g)?Number(g):void 0,x="untyped",y;if(n)for(let w of n.children){if(w.kind==="textValue"||w.namespaceUri!==O)continue;let I=Fx[w.localName];if(I!==void 0){x=I,y=w;break}}let N=sn(n,j,"checkbox"),b;if(N){let w=Dx(N,"checkedState"),I=Dx(N,"uncheckedState");b={checked:nC(sn(N,j,"checked")),...w===void 0?{}:{checkedState:w},...I===void 0?{}:{uncheckedState:I}},x==="untyped"&&(x="checkbox");}let h=y&&(x==="dropDownList"||x==="comboBox")?rC(y):[],P=y&&(x==="dropDownList"||x==="comboBox")?$e(y,"lastValue"):void 0,k=y&&x==="date"?oC(y):void 0,E=y&&x==="plainText"?iC(y,"multiLine"):void 0;return {type:x,...t===void 0?{}:{alias:t},...r===void 0?{}:{tag:r},...o===void 0?{}:{id:o},lock:a,...s===void 0?{}:{placeholderDocPart:s},temporary:_x(sn(n,O,"temporary")),showingPlaceholder:_x(sn(n,O,"showingPlcHdr")),...d===void 0?{}:{dataBinding:{...c===void 0?{}:{xpath:c},...u===void 0?{}:{storeItemID:u},...f===void 0?{}:{prefixMappings:f}}},...m===void 0?{}:{label:m},...p===void 0?{}:{tabIndex:p},listItems:h,...P===void 0?{}:{lastValue:P},...k===void 0?{}:{date:k},...E===void 0?{}:{multiLine:E},...b===void 0?{}:{checkbox:b}}}var kr=Object.freeze({id:"",kind:"generic",namespaceUri:"",localName:"",namespaceBindings:Object.freeze([]),attributes:Object.freeze([]),children:Object.freeze([])});function iC(e,n){let t=$e(e,n);if(t!==void 0)return !(t==="0"||t==="false"||t==="off")}function aC(e){let n=uo(e);if(!n)return "empty";let t=false;for(let r of n.children)if(r.kind!=="textValue"){if(r.kind==="tableRow")return "row";if(r.kind==="tableCell")return "cell";if(r.kind==="paragraph"||r.kind==="table")return "block";if(r.kind==="contentControl"){let o=aC(r);if(o!=="empty")return o;continue}if(r.kind==="run"||r.kind==="hyperlink"||r.kind==="fldSimple"||r.kind==="revisionInsert"||r.kind==="revisionDelete"||r.kind==="revisionMoveFrom"||r.kind==="revisionMoveTo"){t=true;continue}}return t?"inline":n.children.length===0?"empty":"block"}var Ux=new WeakMap;function Lx(e,n,t,r=false){let o=[],i=(a,l,s)=>{if(!(a.kind==="textValue"||o.length>=t))for(let d of a.children){if(o.length>=t)return;if(d.kind==="contentControl"){if(l>=n)continue;o.push({node:d,depth:l,ancestors:[...s]}),i(d,l+1,[...s,d]);continue}if(r&&l===0&&(d.kind==="paragraph"||d.kind==="table")){for(let c of Se(d)){if(o.length>=t)return;o.push(c);}continue}i(d,l,s);}};return i(e,0,[]),o}function lC(e){for(let n of e)Object.freeze(n.ancestors),Object.freeze(n);return Object.freeze(e)}function Se(e,n){if(n===void 0){let t=Ux.get(e);if(t!==void 0)return t;let r=lC(Lx(e,ml,Mx,true));return Ux.set(e,r),r}return Lx(e,n.maxDepth??ml,n.limit??Mx)}function iF(e,n){for(let t of Se(e))if(t.node.id===n)return t;return null}function aF(e){let n=uo(e);if(!n)return "";let t="",r=0,o=(i,a)=>{if(!(r>sC||a>ml*4)){if(r+=1,i.kind==="textValue"){t+=i.value;return}if(!(i.kind==="deletedText"||i.kind==="instrText")){if(i.kind==="tab"){t+=" ";return}for(let l of i.children)o(l,a+1);}}};for(let i of n.children)o(i,0);return t}var sC=1e5;function Fd(e){let n=false,t=false;for(let r of e)(r==="sdtLocked"||r==="sdtContentLocked")&&(n=true),(r==="contentLocked"||r==="sdtContentLocked")&&(t=true);return n&&t?"sdtContentLocked":n?"sdtLocked":t?"contentLocked":"unlocked"}function fo(e){return e==="contentLocked"||e==="sdtContentLocked"}function xl(e){return e==="sdtLocked"||e==="sdtContentLocked"}var Ri=["rPr","alias","tag","id","lock","placeholder","temporary","showingPlcHdr","dataBinding","label","tabIndex"],dC=new Set(Object.keys(Fx));function hl(e){let n=t=>{if(t.kind==="textValue"||t.namespaceUri!==O)return Ri.length+2;let r=Ri.indexOf(t.localName);return r>=0?r:dC.has(t.localName)?Ri.length:Ri.length+2};return [...e].map((t,r)=>({node:t,index:r,rank:n(t)})).sort((t,r)=>t.rank!==r.rank?t.rank-r.rank:t.index-r.index).map(t=>t.node)}function lF(e){let n=0;for(let t of Se(e)){let r=Wn(t.node).id;r!==void 0&&r>n&&(n=r);}return n>=Bx?null:n+1}var cC=32;function uC(e){return e.kind==="textValue"?null:e.kind==="body"?"body":e.kind==="note"?hi(e)?"note":null:e.localName==="hdr"?"header":e.localName==="ftr"?"footer":null}function Ci(e){let n=[],t=r=>{if(r.kind==="textValue")return;let o=uC(r);if(o){n.push({kind:o,root:r});return}for(let i of r.children)t(i);};return t(e.root),n}function Hx(e){let n=t=>{if(t.kind==="textValue")return false;if(t.kind==="body"||t.kind==="note"||t.localName==="hdr"||t.localName==="ftr")return true;for(let r of t.children)if(n(r))return true;return false};return n(e.root)}function uF(e){for(let n of Ci(e))if(n.kind==="body")return n.root;return null}function fF(e){if(e.kind==="textValue")return [];let n=[];return Ti(e.children,n,0),n}function Ti(e,n,t){for(let r of e){if(r.kind==="paragraph"){n.push(r);continue}if(r.kind==="table"){for(let o of Ii(r.children))if(o.kind==="tableRow")for(let i of Ii(o.children))i.kind==="tableCell"&&Ti(i.children,n,t);continue}pl(r)&&t<cC&&Ti(Bd(r),n,t+1);}}var Rn="http://schemas.microsoft.com/office/word/2012/wordml",In="http://schemas.microsoft.com/office/word/2016/wordml/cid",Vd="/word/comments.xml",Wd="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",jx="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",fC="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",mC="application/vnd.ms-word.commentsExtended+xml",pC=[fC,mC],gC="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",xC="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml",hC="application/vnd.ms-word.commentsIds+xml",yC=[xC,hC],OC="http://schemas.microsoft.com/office/2016/relationships/commentsIds",NC=512,kC=5e4,yl=64;function vt(e=kC,n=NC){return {visited:0,maxVisited:e,parts:0,maxParts:n,truncated:false}}function Ol(e){return e.visited>=e.maxVisited?(e.truncated=true,false):(e.visited+=1,true)}function xn(e){return e.parts>=e.maxParts?(e.truncated=true,false):(e.parts+=1,true)}function ut(e,n,t,r=0,o){if(!Ol(n))return false;if(e.kind==="textValue")return o?.(e.value),true;if(r>yl)return n.truncated=true,false;if(t(e))return true;for(let i of e.children)if(!ut(i,n,t,r+1,o))return false;return true}function se(e,n,t){for(let r of e.attributes)if(r.localName===t&&r.namespaceUri===n)return r.value}function bC(e,n){return n===null?false:typeof e=="string"?n===e:e.includes(n)}function vi(e,n,t,r){for(let o of it(e,n)){if(o.type!==t)continue;let i=We(n,o.rawTarget);if(i.ok&&e.parts.has(i.partName)&&bC(r,at(e,i.partName)))return i.partName}return null}function Tn(e,n){let t=vi(e,n,jx,Wd);if(t!==null)return t;let r=vi(e,e.mainDocumentPart,jx,Wd);return r!==null?r:e.parts.has(Vd)&&at(e,Vd)===Wd?Vd:null}function Nl(e,n,t){let r=(o,i)=>{let a=vi(e,n,o,i);if(a!==null)return a;if(t!==null&&t!==n){let l=vi(e,t,o,i);if(l!==null)return l}return n===e.mainDocumentPart?null:vi(e,e.mainDocumentPart,o,i)};return {extended:r(gC,pC),ids:r(OC,yC)}}function Hd(e,n,t){let r=new Map,o=new Set,i=e.parts.get(n);return !i||!xn(t)?{byId:r,duplicateIds:o}:(ut(i.root,t,a=>{if(a.kind!=="comment")return false;let l=se(a,O,"id");return l!==void 0&&(r.has(l)?o.add(l):r.set(l,{partName:i.name,node:a})),true}),{byId:r,duplicateIds:o})}function Kx(e,n,t){return Hd(e,n,t).byId}function PC(e){return e.namespaceUri===Rn&&e.localName==="commentEx"||e.namespaceUri===In&&e.localName==="commentId"}function wC(e,n){return n.namespaceUri===Rn&&n.localName==="commentEx"?e.namespaceUri===Rn&&e.localName==="commentsEx":n.namespaceUri===In&&n.localName==="commentId"?e.namespaceUri===In&&e.localName==="commentsIds":false}function mo(e,n,t){let r=[],o=new Set;for(let i of n){if(i===null||o.has(i))continue;o.add(i);let a=e.parts.get(i);if(!a||!xn(t)||!ut(a.root,t,s=>(PC(s)&&r.push({partName:a.name,node:s}),false)))break}return r}function Gx(e,n){let t=new Map;for(let r of n){let o=t.get(r.partName);if(!o){let a=e.parts.get(r.partName);if(!a)return true;o=new Set;for(let l of a.root.children)l.kind!=="textValue"&&o.add(l.id);t.set(r.partName,o);}let i=e.parts.get(r.partName);if(i===void 0||!o.has(r.node.id)||!wC(i.root,r.node))return true}return false}function kl(e,n,t,r,o){let i=new Set;if(n.size===0)return {marked:i,truncated:r.truncated};for(let a of e.parts.values()){if(!a.name.endsWith(".xml"))continue;if(!xn(r))return {marked:n,truncated:true};if(o!=null&&o===a.root)continue;if(!ut(a.root,r,s=>{if(o!=null&&s===o)return true;if(s.kind!=="commentRangeStart"&&s.kind!=="commentRangeEnd"&&s.kind!=="commentReference")return false;let d=se(s,O,"id");return d===void 0||!n.has(d)||Tn(e,a.name)===t&&i.add(d),true}))return {marked:n,truncated:true};if(i.size===n.size)return {marked:i,truncated:false}}return {marked:i,truncated:r.truncated}}function jd(e,n,t){let r=[],o=[],i=ut(e,t,a=>{if(a.kind==="commentRangeStart"||a.kind==="commentRangeEnd"||a.kind==="commentReference"){let l=se(a,O,"id");return l!==void 0&&n.has(l)&&r.push(a.id),true}return a.kind==="run"&&a.children.filter(s=>!(s.kind==="commentReference"&&n.has(se(s,O,"id")??""))&&s.kind!=="runProperties").length===0&&a.children.some(s=>s.kind==="commentReference")?(o.push(a.id),true):false});return {doomed:r,emptiedRuns:o,truncated:!i||t.truncated}}function $x(e,n){let t=new Map,r=new Map,o=0,i=(l,s,d)=>{let c=t.get(l);t.set(l,{covering:s||(c?.covering??false),paired:d||(c?.paired??false),anyMarker:true});},a=ut(e,n,l=>{if(l.kind==="commentRangeStart"){let s=se(l,O,"id");return s!==void 0&&(r.set(s,o),i(s,false,false)),true}if(l.kind==="commentRangeEnd"){let s=se(l,O,"id");if(s!==void 0){let d=r.get(s);r.delete(s),i(s,d!==void 0&&o>d,d!==void 0);}return true}if(l.kind==="commentReference"){let s=se(l,O,"id");return s!==void 0&&i(s,false,false),true}return l.kind==="tab"||l.kind==="hardBreak"||l.kind==="noteReference"||l.kind==="drawing"?(o+=1,true):false},0,l=>{o+=l.length;});return {states:t,truncated:!a||n.truncated}}function zx(e,n){let t=new Map,r=new Map,o=null,i=0,a=ut(e,n,l=>{if(l.kind==="paragraph")return o=l.id,i=0,false;if(l.kind==="commentRangeStart"){let s=se(l,O,"id");return s!==void 0&&o!==null&&r.set(s,{paragraphId:o,offset:i}),true}if(l.kind==="commentRangeEnd"){let s=se(l,O,"id");if(s!==void 0&&o!==null){let d=r.get(s);r.delete(s),d!==void 0&&t.set(s,{startParagraphId:d.paragraphId,startOffset:d.offset,endParagraphId:o,endOffset:i});}return true}return l.kind==="commentReference"?true:l.kind==="tab"||l.kind==="hardBreak"||l.kind==="noteReference"||l.kind==="drawing"?(i+=1,true):false},0,l=>{i+=l.length;});return {spans:t,truncated:!a||n.truncated}}function Xx(e,n){let t=new Set;for(let r of e.parts.values()){if(!r.name.endsWith(".xml"))continue;if(!xn(n))return {used:t,truncated:true};if(!ut(r.root,n,i=>{let a=se(i,j,"paraId");return a!==void 0&&lt(a)&&t.add(a.toUpperCase()),false}))return {used:t,truncated:true}}return {used:t,truncated:n.truncated}}function Qt(e){let n=new WeakMap,t=[],r=o=>{for(let i=t.length-1;i>=0;i-=1){if(t[i].deref()!==o)continue;let[a]=t.splice(i,1);t.push(a);return}};return {get(o){let i=n.get(o);return i!==void 0&&r(o),i},set(o,i){if(n.has(o))r(o);else for(t.push(new WeakRef(o));t.length>e;){let a=t.shift().deref();a&&!t.some(l=>l.deref()===a)&&n.delete(a);}n.set(o,i);}}}var bl="http://schemas.microsoft.com/office/word/2012/wordml",EC="http://schemas.microsoft.com/office/word/2010/wordml",RC="http://schemas.microsoft.com/office/word/2016/wordml/cid";function po(e,n,t){for(let r of e.attributes)if(r.localName===t&&r.namespaceUri===n)return r.value}function Si(e,n){return po(e,O,n)}function IC(e){let n=qx.get(e);if(n)return n;let t=TC(e);return qx.set(e,t),t}var qx=new WeakMap;function TC(e){let n=Pe(e),t=[],r=(o,i)=>{for(let a of o)if(a.kind!=="textValue"){if(a.kind==="commentRangeStart"||a.kind==="commentRangeEnd"){let l=Si(a,"id"),s=n.spanOf(a);l!==void 0&&s&&t.push({commentId:l,kind:a.kind==="commentRangeStart"?"start":"end",offset:s.start});continue}(a.kind==="hyperlink"||he(a.kind))&&i<32&&r(a.children,i+1);}};return r(e.children,0),t}function Zx(e){let n=new Map,t=[],r=null;for(let o of CC(e))for(let i of IC(o)){let a={paragraphId:o.id,offset:i.offset};if(r=a,i.kind==="start"){n.set(i.commentId,a);continue}let l=n.get(i.commentId);if(l===void 0){t.push({commentId:i.commentId,partName:e.name,start:a,end:a,orphaned:true});continue}n.delete(i.commentId),t.push({commentId:i.commentId,partName:e.name,start:l,end:a,orphaned:false});}for(let[o,i]of n)t.push({commentId:o,partName:e.name,start:i,end:r??i,orphaned:true});return t}function CC(e){let n=Yx.get(e.root);if(n)return n;let t=[];for(let o of Ci(e))o.root.kind!=="textValue"&&Ti(o.root.children,t,0);let r=t.filter(o=>o.kind==="paragraph");return Yx.set(e.root,r),r}var Yx=Qt(8);function Qx(e){let n=[],t=r=>{if(r.kind!=="textValue"){if(r.kind==="comment"){let o=Si(r,"id");if(o!==void 0){let i=[];for(let f of r.children)(f.kind==="paragraph"||f.kind==="table")&&i.push(f);let a=Si(r,"initials"),l=Si(r,"date"),s;for(let f=i.length-1;f>=0;f-=1)if(i[f]?.kind==="paragraph"){s=i[f];break}let d=s?po(s,EC,"paraId"):void 0,c=po(r,RC,"parentId"),u=c===o?void 0:c;n.push({id:o,author:Si(r,"author")??"",...a===void 0?{}:{initials:a},...l===void 0?{}:{date:l},blocks:i,...d===void 0?{}:{paraId:d},...u===void 0?{}:{parentCommentId:u}});}return}for(let o of r.children)t(o);}};return t(e.root),n}function Jx(e){let n=new Map,t=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===bl&&r.localName==="commentEx"){let o=po(r,bl,"paraId");if(o!==void 0){let i=po(r,bl,"paraIdParent"),a=po(r,bl,"done");n.set(o.toUpperCase(),{...i===void 0?{}:{parentParaId:i.toUpperCase()},done:a==="1"||a==="true"||a==="on"});}return}for(let o of r.children)t(o);}};return t(e.root),n}function Kd(e){let n=vt();for(let t of e.parts.values()){if(!t.name.endsWith(".xml"))continue;if(!xn(n))return true;let r=false,o=ut(t.root,n,i=>i.kind!=="comment"?false:(r=true,true));if(r||!o)return true}return false}function vC(e){return e==="1"||e==="true"||e==="on"}function SC(e,n){let t=e.parts.get(n.storyPartName);if(!t)return null;if(n.noteId===void 0)return t.root;for(let r of yr(t.root))if(gn(r)===n.noteId)return r;return null}function Gd(e){for(let n=e.children.length-1;n>=0;n-=1){let t=e.children[n];if(t.kind!=="paragraph")continue;let r=se(t,j,"paraId");return r===void 0?null:r.toUpperCase()}return null}function AC(e){return `${e.startParagraphId}:${e.startOffset}|${e.endParagraphId}:${e.endOffset}`}function MC(e){return e.startParagraphId===e.endParagraphId&&e.startOffset===e.endOffset}function Ai(e,n){let t=Tn(e,n.storyPartName);return Nl(e,n.storyPartName,t)}function $d(e,n,t,r){let o=Tn(e,n.storyPartName),i=o===null?{byId:new Map,duplicateIds:new Set}:Hd(e,o,t),a=i.byId,l=new Map,s=new Map,d=new Map,c=new Map,u=new Map,f=Ai(e,n),m={childrenOf:l,records:a,duplicateIds:i.duplicateIds,parentParaIdByCommentId:d,parentCommentIdByChildId:c,commentExByParaId:u,extendedPartName:f.extended,malformed:false};if(t.truncated)return m;let g=new Map;for(let[k,E]of a){let w=Gd(E.node);if(w===null)continue;let I=g.get(w);if(I!==void 0&&I!==k)return {...m,malformed:true};g.set(w,k);}let p=false,x=(k,E)=>{if(k===E){p=true;return}let w=c.get(E);if(w!==void 0&&w!==k){p=true;return}c.set(E,k);let I=a.get(k)?.node,A=I===void 0?null:Gd(I);A!==null&&!d.has(E)&&d.set(E,A);let U=l.get(k),B=s.get(k);(!U||!B)&&(U=[],B=new Set,l.set(k,U),s.set(k,B)),!B.has(E)&&(B.add(E),U.push(E));};for(let[k,E]of a){let w=se(E.node,In,"parentId");if(w!==void 0){if(w===k){p=true;continue}a.has(w)&&x(w,k);}}let y=new Set,N=new Set,b=new Set,h=new Set,P=mo(e,[f.extended,f.ids],t);if(t.truncated)return {...m,malformed:false};if(Gx(e,P))return {...m,malformed:true};for(let k of P){if(k.node.namespaceUri===Rn&&k.node.localName==="commentEx"){let I=se(k.node,Rn,"paraId");if(I===void 0)continue;let A=I.toUpperCase();if(N.has(A))return {...m,malformed:true};N.add(A);let U=se(k.node,Rn,"paraIdParent"),B=U===void 0?void 0:U.toUpperCase();if(y.add(A),u.set(A,{partName:k.partName,node:k.node,paraId:A,...B===void 0?{}:{parentParaId:B},done:vC(se(k.node,Rn,"done"))}),B===void 0)continue;let C=g.get(A),rn=g.get(B);C!==void 0&&rn!==void 0&&(d.set(C,B),x(rn,C));continue}if(k.node.namespaceUri!==In||k.node.localName!=="commentId")continue;let E=se(k.node,In,"paraId"),w=se(k.node,In,"durableId");if(E!==void 0){let I=E.toUpperCase();if(b.has(I))return {...m,malformed:true};b.add(I);}if(w!==void 0){let I=w.toUpperCase();if(h.has(I))return {...m,malformed:true};h.add(I);}}if(t.truncated)return {...m,malformed:false};if(p)return {...m,malformed:true};if(r){let k=SC(e,n);if(k){if(!xn(t))return {...m,malformed:false};let{spans:E,truncated:w}=zx(k,t);if(w)return {...m,malformed:false};let I=new Map;for(let A of a.keys()){let U=E.get(A);if(U===void 0||MC(U))continue;let B=AC(U);if(!I.has(B)){I.set(B,A);continue}let C=Gd(a.get(A).node);C!==null&&y.has(C)||x(I.get(B),A);}}}return p?{...m,malformed:true}:_C(c,t)?{...m,malformed:true}:t.truncated?{...m,malformed:false}:{childrenOf:l,records:a,duplicateIds:i.duplicateIds,parentParaIdByCommentId:d,parentCommentIdByChildId:c,commentExByParaId:u,extendedPartName:f.extended,malformed:false}}function _C(e,n){let t=new Set;for(let r of e.keys()){if(t.has(r))continue;let o=new Set,i=r,a=0;for(;i!==void 0;){if(a>yl)return n.truncated=true,false;if(o.has(i))return true;if(t.has(i))break;o.add(i),t.add(i),i=e.get(i),a+=1;}}return false}function zd(e,n,t){let r=new Set([e]),o=[e],i=0,a=0,l=1;for(;i<o.length;){if(a>yl)return t.truncated=true,r;let s=o[i];i+=1;for(let d of n.get(s)??[])r.has(d)||(r.add(d),o.push(d));i===l&&(a+=1,l=o.length);}return r}function Xd(e,n,t,r){let o=$d(e,t,r,true);if(r.truncated)return {ok:false,reason:"scan-truncated"};if(o.malformed)return {ok:false,reason:"malformed-metadata"};if(!o.records.has(n))return {ok:false,reason:"unknown-comment"};let i=zd(n,o.childrenOf,r);if(r.truncated)return {ok:false,reason:"scan-truncated"};for(let a of i)if(o.duplicateIds.has(a))return {ok:false,reason:"duplicate-comment"};return {ok:true,ids:i,records:o.records,parentParaIdByCommentId:o.parentParaIdByCommentId,parentCommentIdByChildId:o.parentCommentIdByChildId,commentExByParaId:o.commentExByParaId,extendedPartName:o.extendedPartName}}var DC="http://schemas.microsoft.com/office/word/2010/wordml";function rh(e){return {storyPartName:e.mainDocumentPart}}var eh=new WeakMap;function oh(e){let n=eh.get(e);if(n)return n;let t=new Map;for(let r of yr(e)){let o=gn(r);o!==null&&t.set(o,r);}return eh.set(e,t),t}function qd(e,n){let t=e.parts.get(n.storyPartName);return t?n.noteId===void 0?t.root:oh(t.root).get(n.noteId)??null:null}function UC(e,n,t){if(n.noteId!==void 0)return [n];let r=e.parts.get(n.storyPartName);if(!r||r.root.kind!=="footnotes"&&r.root.kind!=="endnotes")return [n];if(!xn(t))return [];let o=[];for(let i of yr(r.root)){if(!Ol(t))return o;let a=gn(i);a===null||a<=0||o.push({storyPartName:n.storyPartName,noteId:a});}return o.length>0?o:[n]}function LC(e,n,t){let r=[];for(let o of e.parts.values()){if(o.root.kind!=="footnotes"&&o.root.kind!=="endnotes")continue;if(!xn(t))return r;let i=n.parts.get(o.name),a=i===void 0?new Set:oh(i.root);for(let l of yr(o.root)){if(!Ol(t))return r;let s=gn(l);s===null||s<=0||a.has(s)||r.push({storyPartName:o.name,noteId:s});}}return r}function nh(e,n,t){let r=qd(e,n);if(!r)return new Map;if(!xn(t))return null;let{states:o,truncated:i}=$x(r,t);return i?null:o}function Pl(e){for(let n=e.children.length-1;n>=0;n-=1){let t=e.children[n];if(t.kind!=="paragraph")continue;let r=se(t,DC,"paraId");return r===void 0?null:r.toUpperCase()}return null}function Yd(e,n,t){let r=Tn(e,n.storyPartName);return r===null?new Map:Kx(e,r,t)}function ih(e,n,t,r){let o=$d(e,t,r,false);return zd(n,o.childrenOf,r)}function Jt(e,n,t){let r=e.parts.get(n);if(!r)return e;let o=r;for(let i of t){if(!R(o,i))continue;let a=oe(o,i,{deferValidation:true});if(!a.ok)return null;o=a.part;}return o===r?e:D(e,o)}function th(e,n,t,r,o){let i=e.parts.get(n);if(!i||t.size===0)return e;let a=i;for(let[l,s]of t){let d=R(a,l);if(!d||d.kind==="textValue")continue;let c=false,u=d.attributes.map(g=>g.kind!=="genericExtension"||g.namespaceUri!==r||g.localName!==o?g:(c=g.value!==s,c?{...g,value:s}:g));if(!c)continue;let f={...d,attributes:u},m=V(a,l,f,{deferValidation:true});if(!m.ok)return null;a=m.part;}return a===i?e:D(e,a)}function ah(e,n,t,r){let o=e.parts.get(t.storyPartName),i=qd(e,t);if(!o||!i)return {pkg:e,truncated:false};if(!xn(r))return {pkg:e,truncated:true};let a=jd(i,n,r);if(a.truncated)return {pkg:e,truncated:true};if(a.doomed.length===0&&a.emptiedRuns.length===0)return {pkg:e,truncated:false};let l=Jt(e,o.name,[...a.emptiedRuns,...a.doomed]);return l===null?null:{pkg:l,truncated:false}}function lh(e,n,t,r){if(n.size===0)return e;let o=Ai(e,t),i=new Map;for(let l of mo(e,[o.extended,o.ids],r)){let s=se(l.node,Rn,"paraId")??se(l.node,In,"paraId");if(s===void 0||!n.has(s.toUpperCase()))continue;let d=i.get(l.partName);d?d.push(l.node.id):i.set(l.partName,[l.node.id]);}if(r.truncated)return e;let a=e;for(let[l,s]of i){let d=Jt(a,l,s);if(d===null)return null;a=d;}return a}function sh(e,n,t,r){let o=Yd(e,t,r);if(!o.has(n))return e;let i=ih(e,n,t,r);if(r.truncated)return e;let a=ah(e,i,t,r);if(a===null)return null;if(a.truncated)return e;let l=a.pkg,s=kl(l,i,Tn(e,t.storyPartName),r);if(s.truncated)return l;let d=new Set([...i].filter(f=>!s.marked.has(f))),c=new Set,u=new Map;for(let f of d){let m=o.get(f);if(!m)continue;let g=Pl(m.node);g!==null&&c.add(g);let p=u.get(m.partName);p?p.push(m.node.id):u.set(m.partName,[m.node.id]);}for(let[f,m]of u){let g=Jt(l,f,m);if(g===null)return null;l=g;}return lh(l,c,t,r)}function LF(e,n,t){return sh(e,n,t??rh(e),vt())}function BF(e,n,t){return sh(e,n,t,vt())}function FF(e,n,t,r){return BC(e,n,t,r,vt())}function BC(e,n,t,r,o){let i=Yd(e,r,o);if(o.truncated)return e;let a=i.get(n),l=i.get(t);if(!a||!l||n===t)return e;let s=e.parts.get(r.storyPartName),d=qd(e,r),c={doomed:[],emptiedRuns:[],truncated:false};if(s&&d&&(!xn(o)||(c=jd(d,new Set([n]),o),c.truncated)))return e;let u=kl(e,new Set([n]),Tn(e,r.storyPartName),o,d);if(u.truncated)return e;if(u.marked.has(n))return !s||c.doomed.length===0&&c.emptiedRuns.length===0?e:Jt(e,s.name,[...c.emptiedRuns,...c.doomed]);let m=Pl(a.node),g=Pl(l.node),p=new Map;for(let h of i.values()){if(se(h.node,In,"parentId")!==n)continue;let P=p.get(h.partName);P||(P=new Map,p.set(h.partName,P)),P.set(h.node.id,t);}let x=new Map;if(m!==null&&g!==null){let h=Ai(e,r);for(let P of mo(e,[h.extended],o)){if(se(P.node,Rn,"paraIdParent")?.toUpperCase()!==m)continue;let E=x.get(P.partName);E||(E=new Map,x.set(P.partName,E)),E.set(P.node.id,g);}if(o.truncated)return e}let y=new Map;if(m!==null){let h=Ai(e,r);for(let P of mo(e,[h.extended,h.ids],o)){let k=se(P.node,Rn,"paraId")??se(P.node,In,"paraId");if(k===void 0||k.toUpperCase()!==m)continue;let E=y.get(P.partName);E?E.push(P.node.id):y.set(P.partName,[P.node.id]);}if(o.truncated)return e}let N=e;for(let[h,P]of p){let k=th(N,h,P,In,"parentId");if(k===null)return null;N=k;}for(let[h,P]of x){let k=th(N,h,P,Rn,"paraIdParent");if(k===null)return null;N=k;}if(s&&(c.doomed.length>0||c.emptiedRuns.length>0)){let h=Jt(N,s.name,[...c.emptiedRuns,...c.doomed]);if(h===null)return null;N=h;}let b=Jt(N,a.partName,[a.node.id]);if(b===null)return null;N=b;for(let[h,P]of y){let k=Jt(N,h,P);if(k===null)return null;N=k;}return N}function dh(e,n,t){return FC(e,n,t,vt())}function FC(e,n,t,r){let o=r,i=t??rh(e),a=[...UC(e,i,o)];if(o.truncated)return n;for(let f of LC(e,n,o)){if(o.truncated)return n;a.some(m=>m.storyPartName===f.storyPartName&&m.noteId===f.noteId)||a.push(f);}let l=n,s=[];for(let f of a){if(o.truncated)return n;let m=nh(e,f,o),g=nh(l,f,o);if(m===null||g===null)return n;for(let[p,x]of m){if(!x.covering)continue;let y=g.get(p);!(y===void 0||!y.anyMarker)&&!(y.paired&&!y.covering)||s.push({owner:f,commentId:p});}}let d=[];for(let f of s){if(o.truncated)return n;let m=ih(l,f.commentId,f.owner,o);if(o.truncated)return n;let g=ah(l,m,f.owner,o);if(g===null)return null;if(g.truncated)return n;l=g.pkg,d.push({owner:f.owner,ids:m});}let c=new Map;for(let f of d){let m=Tn(l,f.owner.storyPartName),g=c.get(m);g||(g=new Set,c.set(m,g));for(let p of f.ids)g.add(p);}let u=new Map;for(let[f,m]of c){let g=kl(l,m,f,o);u.set(f,g.truncated?m:g.marked);}for(let f of d){let m=Tn(l,f.owner.storyPartName),g=u.get(m)??f.ids,p=new Set([...f.ids].filter(h=>!g.has(h)));if(p.size===0)continue;let x=Yd(l,f.owner,o),y=new Set,N=new Map;for(let h of p){let P=x.get(h);if(!P)continue;let k=Pl(P.node);k!==null&&y.add(k);let E=N.get(P.partName);E?E.push(P.node.id):N.set(P.partName,[P.node.id]);}for(let[h,P]of N){let k=Jt(l,h,P);if(k===null)return null;l=k;}let b=lh(l,y,f.owner,o);if(b===null)return null;l=b;}return l}var ph="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",gh="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps",Zd="application/vnd.openxmlformats-officedocument.customXmlProperties+xml",wl="http://schemas.openxmlformats.org/officeDocument/2006/customXml";function ch(e){let n=a=>fi(`${a} ${e}`).toString(16).padStart(8,"0").toUpperCase(),t=n("a"),r=n("b"),o=n("c"),i=n("d");return `{${t}-${r.slice(0,4)}-${r.slice(4)}-${o.slice(0,4)}-${o.slice(4)}${i}}`}var VC=["/docProps/core.xml","/word/settings.xml"];function WC(e){let n=2166136261,t=0;for(let r of [e.mainDocumentPart,...VC]){let o=e.partBytes.get(r);if(o){t+=o.length;for(let i of o)n^=i,n=Math.imul(n,16777619)>>>0;}}return `${e.mainDocumentPart}#${String(t)}#${n.toString(16)}`}var HC=/\/_rels\/[^/]*\.rels$/i;function Qd(e,n){let t=e.split("/").slice(1,-1),r=n.split("/").slice(1),o=0;for(;o<t.length&&o<r.length-1&&t[o]===r[o];)o+=1;return `${"../".repeat(t.length-o)}${r.slice(o).join("/")}`}function uh(e){return {item:`/customXml/item${String(e)}.xml`,props:`/customXml/itemProps${String(e)}.xml`}}function fh(e,n){let t=ne(n,{name:e,contentType:"application/xml"});return t.ok?t.part.root:null}function jC(e,n){let t=e.parts.get(n);if(!t)return null;let r=t.root.attributes.find(o=>o.localName==="itemID"&&o.namespaceUri===wl);return r&&r.value.length>0?r.value:null}function _i(e,n){let t=[];for(let r of it(e,n)){if(r.type!==ph||r.targetMode==="External")continue;let o=We(n,r.rawTarget);if(!o.ok)continue;let i=e.parts.get(o.partName);if(!i||HC.test(o.partName))continue;let a=it(e,o.partName).find(d=>d.type===gh&&d.targetMode!=="External");if(!a)continue;let l=We(o.partName,a.rawTarget);if(!l.ok||at(e,l.partName)!==Zd)continue;let s=jC(e,l.partName);s!==null&&t.push({partName:o.partName,propsPartName:l.partName,itemId:s,namespaceUri:i.root.namespaceUri});}return t}function Mi(e,n,t){return _i(e,n).find(r=>r.namespaceUri===t)??null}function xh(e,n,t,r){let o=Mi(e,n,t);if(o){let h=e.parts.get(o.partName)?.root;return h&&h.localName!==r?{pkg:e,part:null}:{pkg:e,part:o}}if(!be(r))return {pkg:e,part:null};let i=new Set;for(let h of e.parts.keys())i.add(G(h));for(let h of e.partBytes.keys())i.add(G(h));let a=h=>{let{item:P,props:k}=uh(h);return !i.has(G(P))&&!i.has(G(k))&&!i.has(G(ot(P)))},l=1;for(;!a(l);)l+=1;let s=uh(l),d=KC(e),c=`${WC(e)} ${n} ${t} ${s.item}`,u=ch(c);for(let h=1;d.has(u.toUpperCase())&&h<64;h+=1)u=ch(`${c} ${String(h)}`);if(d.has(u.toUpperCase()))return {pkg:e,part:null};let f=mh(t),m=mh(u);if(f===null||m===null)return {pkg:e,part:null};let g=fh(s.item,`<${r} xmlns="${f}"/>`),p=fh(s.props,`<ds:datastoreItem ds:itemID="${m}" xmlns:ds="${wl}"><ds:schemaRefs><ds:schemaRef ds:uri="${f}"/></ds:schemaRefs></ds:datastoreItem>`);if(!g||!p)return {pkg:e,part:null};let x=cr(e,s.item,g,"application/xml");if(x=cr(x,s.props,p,Zd),!x.parts.has(s.item)||!x.parts.has(s.props))return {pkg:e,part:null};x=Yr(x,s.props,Zd);let y=Gt(ti(x,n),n,ph,Qd(n,s.item));if(!y.ok)return {pkg:e,part:null};let N=Gt(ti(y.pkg,s.item),s.item,gh,`itemProps${String(l)}.xml`);if(!N.ok)return {pkg:e,part:null};let b=Mi(N.pkg,n,t);return !b||b.partName!==s.item?{pkg:e,part:null}:{pkg:N.pkg,part:{partName:s.item,propsPartName:s.props,itemId:u,namespaceUri:t}}}function mh(e){return /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/.test(e)?null:e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function KC(e){let n=new Set;for(let t of e.parts.values()){if(t.root.localName!=="datastoreItem"||t.root.namespaceUri!==wl)continue;let r=t.root.attributes.find(o=>o.localName==="itemID"&&o.namespaceUri===wl);r&&n.add(r.value.toUpperCase());}return n}function XF(e,n,t){let r=e;for(let o of _i(e,n)){if(o.namespaceUri!==t)continue;let i=Ys(r,o.partName);if(!i.ok)return {pkg:e,ok:false};let a=Ys(i.pkg,o.propsPartName);if(!a.ok)return {pkg:e,ok:false};r=a.pkg;}return {pkg:r,ok:true}}var Di=/^[A-Za-z_][\w.-]{0,127}$/,ec="label",Oh="data",nc="node";function Jd(e){if(e.kind==="textValue")return e.value;let n="";for(let t of e.children)n+=Jd(t);return n}function hh(e,n){return e.children.find(t=>t.kind!=="textValue"&&t.localName===n)??null}function Ui(e){let n=e.attributes.find(t=>t.localName==="id"&&t.namespaceUri==="");return n&&n.value.length>0?n.value:null}function El(e){let n=[];for(let t of e.root.children)t.kind!=="textValue"&&t.localName===nc&&t.namespaceUri===e.root.namespaceUri&&n.push(t);return n}function Nh(e,n,t,r,o){return {id:e,kind:"generic",namespaceUri:n,localName:t,namespaceBindings:[],attributes:Object.entries(r).map(([i,a])=>({kind:"genericExtension",namespaceUri:"",localName:i,value:a})),children:o}}function yh(e,n,t,r){let o=Nh(e,n,t,{},[{id:`${e}#text`,kind:"textValue",value:r}]);return r===r.trim()?o:{...o,attributes:[...o.attributes,{kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:"preserve"}]}}function Li(e,n){let t=e.parts.get(n);if(!t)return [];let r=[];for(let o of El(t)){let i=Ui(o);if(i===null)continue;let a=hh(o,ec),l=hh(o,Oh);r.push({id:i,label:a?Jd(a):"",data:l?Jd(l):""});}return r}function kh(e,n,t){return Li(e,n).find(r=>r.id===t)??null}function bh(e,n,t){if(!Di.test(t.id))return e;let r=e.parts.get(n);if(!r)return e;let o=r.root.namespaceUri,i=`${n}#node-${t.id}`,a=Nh(i,o,nc,{id:t.id},[yh(`${i}-label`,o,ec,t.label),yh(`${i}-data`,o,Oh,t.data)]),l=El(r).find(d=>Ui(d)===t.id);if(l){let d=L(r,r.root.id,[...r.root.children.map(c=>c.id===l.id?a:c)]);return d.ok?D(e,d.part):e}let s=M(r,r.root.id,r.root.children.length,[a],{deferValidation:true});return s.ok?D(e,s.part):e}function tc(e,n,t){let r=e.parts.get(n);if(!r)return e;let o=El(r).find(a=>Ui(a)===t);if(!o)return e;let i=oe(r,o.id);return i.ok?D(e,i.part):e}function Ph(e,n,t){let r=e.parts.get(n);if(!r)return {pkg:e,removed:[]};let o=El(r).filter(s=>{let d=Ui(s);return d!==null&&!t.has(d)});if(o.length===0)return {pkg:e,removed:[]};let i=new Set(o.map(s=>s.id)),a=r.root.children.filter(s=>!i.has(s.id)),l=L(r,r.root.id,a);return l.ok?{pkg:D(e,l.part),removed:o.map(s=>Ui(s)??"").filter(s=>s.length>0)}:{pkg:e,removed:[]}}function wh(e,n,t){return !Di.test(e)||!Di.test(n)||!Di.test(t)?null:`/${e}:${n}/${e}:${nc}[@id='${t}']/${e}:${ec}`}function Eh(e,n){return !Di.test(e)||/['"<>&]/.test(n)||/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/.test(n)?null:`xmlns:${e}='${n}'`}var Rh="ns0",GC=/^\/([A-Za-z_][\w.-]*):([A-Za-z_][\w.-]*)\/\1:node\[@id='([A-Za-z_][\w.-]{0,127})'\]\/\1:label$/;function Ih(e,n,t){let r=wh(Rh,n,t),o=Eh(Rh,e.namespaceUri);return r===null||o===null?null:{prefixMappings:o,xpath:r,storeItemId:e.itemId}}var $C=2048;function Th(e){if(typeof e!="object"||e===null)return false;let n=e;for(let t of [n.prefixMappings,n.xpath,n.storeItemId])if(typeof t!="string"||t.length===0||t.length>$C||!$(t))return false;return true}function zC(e,n){let t=r=>r.replace(/^\{|\}$/g,"").toUpperCase();return t(e)===t(n)}function XC(e,n){let t=new Set;for(let r of Se(e.root)){let o=Rl(r.node,n);o!==null&&t.add(o);}return t}function Ch(e,n){let t=new Set;for(let r of e.parts.values())if(Hx(r))for(let o of XC(r,n))t.add(o);return t}function Rl(e,n){let t=Wn(e).dataBinding;return !t?.xpath||!t.storeItemID||!zC(t.storeItemID,n)?null:GC.exec(t.xpath)?.[3]??null}function br(e,n){let t=R(e,n);if(t===null)return null;let r=hr(t);if(r===null)return null;let o=r==="footnote"?"footnotes":"endnotes";return e.root.kind!==o?null:Ce(e,t.id)?.id===e.root.id?t:null}var vh=new Set(["cellIns","cellDel","cellMerge","trPrChange","tcPrChange","tblPrChange","tblPrExChange","tblGridChange","sectPrChange"]),Sh=new Set(["rPrChange","pPrChange"]),qC=new Set(["moveFrom","moveTo"]),YC=new Set(["trPr","tcPr","tblPr","tblPrEx","numPr","sectPr"]);function ZC(e,n,t){return (e.localName==="ins"||e.localName==="del")&&n==="trPr"&&t==="tr"?true:(e.localName==="cellIns"||e.localName==="cellDel")&&n==="tcPr"&&t==="tc"}function go(e,n){for(let t of e.attributes)if(t.localName===n&&t.namespaceUri===O)return t.value}function Mh(e){let n=go(e,"id"),t=go(e,"author");if(n===void 0||t===void 0)return null;let r=go(e,"date");return r===void 0?{id:n,author:t}:{id:n,author:t,date:r}}function QC(e,n){return e.id===n.id&&e.author===n.author&&(e.date??null)===(n.date??null)}var Ah=new WeakMap;function rc(e,n){let t=[],r=(i,a,l,s)=>{if(i.kind==="textValue")return;if(i.kind==="paragraph"||i.kind==="table"){let f=Ah.get(i);if(f){for(let p of f)t.push(p);return}let m=t.length;for(let p of i.children)r(p,i,a,0);let g=t.slice(m);Ah.set(i,g);return}let d=a?.namespaceUri===O?a.localName:void 0,c=l?.namespaceUri===O?l.localName:void 0;if(i.namespaceUri===O){let f=he(i.kind),m=d==="rPr"&&c==="pPr"&&qC.has(i.localName);if((f||m||vh.has(i.localName)||Sh.has(i.localName)||i.localName==="ins"||i.localName==="del")&&Mh(i)!==null){let p=d==="rPr"&&c!=="pPr"&&(i.localName==="ins"||i.localName==="del"),x=ZC(i,d,c),y=p||vh.has(i.localName)||d!==void 0&&YC.has(d),N=(!f||m)&&d==="rPr"&&c==="pPr"&&!y;t.push({node:i,parent:a,refused:y&&!x,paragraphMark:N,propertyChange:Sh.has(i.localName),nesting:s});}}let u=he(i.kind)?s+1:s;for(let f of i.children)r(f,i,a,u);},o=n===void 0?e.root:R(e,n);return o!==null&&r(o,null,null,0),t}function _h(e){return rc(e)}function JC(e){let n=new Map,t=i=>{let a=n.get(i);if(a)return a;let l={wrappers:[],markers:[]};return n.set(i,l),l},r=[],o=i=>{if(i.kind!=="textValue"){for(let a of i.children)if(a.kind!=="textValue"){if(a.kind==="moveFromRangeStart"||a.kind==="moveToRangeStart"){let l=go(a,"name");l!==void 0&&(r.push({name:l,id:go(a,"id")}),t(l).markers.push(a));continue}if(a.kind==="moveFromRangeEnd"||a.kind==="moveToRangeEnd"){let l=go(a,"id"),s=-1;for(let c=r.length-1;c>=0;c-=1)if(r[c].id===l){s=c;break}let d=s>=0?r.splice(s,1)[0]:r.pop();d&&t(d.name).markers.push(a);continue}if(a.kind==="revisionMoveFrom"||a.kind==="revisionMoveTo"){let l=r[r.length-1];l!==void 0&&t(l.name).wrappers.push(a);}o(a);}}};return o(e),n}function ev(e,n){let t=R(e,n);for(;t!==null;){if(t.kind==="paragraph")return t.id;t=Ce(e,t.id);}return null}function nv(e,n){let t=R(e,n);for(;t!==null;){if(t.kind==="tableRow")return t.id;t=Ce(e,t.id);}return null}function Dh(e,n){let t=R(e,n);return t===null||t.kind==="textValue"?null:t}function Uh(e,n,t){return n===void 0?[...e]:e.filter(r=>{let o=Mh(r.node);return o===null||!QC(o,n)?false:t===void 0||r.node.localName===t})}function Lh(e,n){let t=new Map;for(let r of n){let o=r.node.localName==="ins"||r.node.localName==="cellIns"?"ins":r.node.localName==="del"||r.node.localName==="cellDel"?"del":null;if(!(o!==null&&(r.parent?.localName==="trPr"&&(r.node.localName==="ins"||r.node.localName==="del")||r.parent?.localName==="tcPr"&&(r.node.localName==="cellIns"||r.node.localName==="cellDel")))||o===null)continue;let a=nv(e,r.node.id);if(a===null)return "unsupported-revision";let l=t.get(a);if(l&&l.kind!==o)return "unsupported-revision";let s=l??{kind:o,rowMarkerCount:0,cellMarkerCount:0,markerIds:[]};s.markerIds.push(r.node.id),r.parent?.localName==="trPr"?s.rowMarkerCount+=1:s.cellMarkerCount+=1,t.set(a,s);}for(let[r,o]of t){let a=Dh(e,r)?.children.filter(l=>l.kind==="tableCell").length??0;if(o.rowMarkerCount!==1||a===0||o.cellMarkerCount!==a)return "unsupported-revision"}return t}function Bh(e,n,t,r){if(r?.scopeRootId!==void 0&&br(e,r.scopeRootId)===null)return [];let o=Uh(rc(e,r?.scopeRootId),t,r?.localName),i=Lh(e,o);if(typeof i=="string")return [];let a=[];for(let[l,s]of i){if(!(s.kind==="ins"&&n==="reject"||s.kind==="del"&&n==="accept"))continue;let c=Dh(e,l);c&&a.push(c);}return a}function tv(e,n){switch(e.kind){case "revisionInsert":case "revisionMoveTo":return n==="accept"?"unwrap":"remove";case "revisionDelete":case "revisionMoveFrom":return n==="accept"?"remove":"restore";default:return "remove"}}function rv(e){return {...e,kind:"text",localName:"t"}}function Fh(e){if(e.kind==="textValue")return e;let n=e.children.map(Fh),t=n.some((r,o)=>r!==e.children[o])?{...e,children:n}:e;return t.kind==="deletedText"?rv(t):t.kind==="generic"&&t.namespaceUri===O&&t.localName==="delInstrText"?{...t,localName:"instrText"}:t}function ov(e){let n=e.localName==="rPrChange"?"rPr":"pPr";for(let t of e.children)if(t.kind!=="textValue"&&t.namespaceUri===O&&t.localName===n)return t.children;return null}function Il(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function iv(e){return e.kind==="paragraph"||e.kind==="table"?true:e.kind!=="textValue"&&Qe(e)}function Vh(e,n){let t=[],r=[];for(let[o,i]of e.entries()){if(i.kind!=="textValue"&&n.removeRows.has(i.id)||i.kind==="table"&&i.children.every(s=>s.kind!=="tableRow"||n.removeRows.has(s.id))&&i.children.some(s=>s.kind==="tableRow")||i.kind!=="textValue"&&n.dropMarks.has(i.id)||i.kind!=="textValue"&&n.restoreProperties.has(i.id))continue;let a=i.kind==="textValue"?void 0:n.actions.get(i.id);if(a==="remove")continue;if(i.kind!=="textValue"&&(a==="unwrap"||a==="restore")){for(let s of Vh(i.children,n))t.push(a==="restore"?Fh(s):s);continue}let l=Wh(i,n);if(i.kind==="fldSimple"||i.kind==="hyperlink"){let s=l[0];if(l.length===1&&s!==void 0&&s.kind!=="textValue"&&s.children.length===0)continue}if(i.kind==="paragraph"){let s=l[0];if(s!==void 0&&s.kind!=="textValue"){let d=s.children.filter(m=>Il(m,"pPr")),c=[...r,...s.children.filter(m=>!Il(m,"pPr"))];r=[];let f=e.slice(o+1).find(m=>iv(m))?.kind==="paragraph";if(n.mergeForward.has(i.id)&&f){r=c;continue}if(c.length>s.children.length-d.length){t.push({...s,children:[...d,...c]});continue}}}t.push(...l);}return r.length>0&&t.push(...r),t}function Wh(e,n){if(e.kind==="textValue")return [e];let t=e.children.find(r=>r.kind!=="textValue"&&n.restoreProperties.has(r.id));if(t!==void 0&&t.kind!=="textValue"){let r=ov(t);if(r!==null){let o=t.localName==="pPrChange"?e.children.filter(i=>Il(i,"rPr")||Il(i,"sectPr")):[];return [{...e,children:[...r,...o]}]}}return [{...e,children:Vh(e.children,n)}]}function Hh(e,n,t,r){let o=r?.scopeRootId===void 0?e.root:br(e,r.scopeRootId);if(o===null)return {ok:false,reason:"invalid-property-value"};let i=rc(e,r?.scopeRootId),a=Uh(i,t,r?.localName);if(a.length===0)return {ok:false,reason:"unknown-revision"};if(a.some(b=>b.refused))return {ok:false,reason:"unsupported-revision"};let l=new Map,s=new Set,d=new Set,c=new Set,u=new Set,f=Lh(e,a);if(typeof f=="string")return {ok:false,reason:f};for(let[b,h]of f)if(h.kind==="ins"&&n==="reject"||h.kind==="del"&&n==="accept")u.add(b);else for(let k of h.markerIds)s.add(k);let m=b=>{l.set(b.id,tv(b,n));};for(let b of a)if(!(b.node.localName==="cellIns"||b.node.localName==="cellDel"||(b.node.localName==="ins"||b.node.localName==="del")&&b.parent?.localName==="trPr")){if(b.propertyChange){n==="accept"?s.add(b.node.id):d.add(b.node.id);continue}if(b.paragraphMark){let h=n==="accept"&&(b.node.localName==="del"||b.node.localName==="moveFrom")||n==="reject"&&(b.node.localName==="ins"||b.node.localName==="moveTo");if(s.add(b.node.id),h){let P=ev(e,b.node.id);if(P===null)return {ok:false,reason:"unsupported-revision"};c.add(P);}continue}m(b.node);}if(a.filter(b=>b.node.kind==="revisionMoveFrom"||b.node.kind==="revisionMoveTo").length>0){for(let[,b]of JC(o))if(b.wrappers.some(h=>l.has(h.id))){for(let h of b.wrappers)m(h);for(let h of b.markers)s.add(h.id);}}let p={actions:l,dropMarks:s,restoreProperties:d,mergeForward:c,removeRows:u},x=Wh(e.root,p),y=x[0];if(x.length!==1||y===void 0||y.kind==="textValue")return {ok:false,reason:"tree-invariant"};let N=L(e,e.root.id,y.children,r);return N.ok?{ok:true,part:N.part,effect:{dirty:[],created:[],deleted:[],dependencyKeys:[sr.story],impact:"flow-structural"}}:{ok:false,reason:"tree-invariant"}}var Hn=1024;var ze=Object.freeze({maxRows:1e4,maxColumns:1024,maxTraversalNodes:1e6});function oc(e,n,t){if(typeof e!="number"||!Number.isFinite(e)||e<1)return n;let r=Math.floor(e);return r<1?n:Math.min(r,t)}function Xe(e){return Object.freeze({maxRows:oc(e?.maxRows,1e4,1e4),maxColumns:oc(e?.maxColumns,1024,1024),maxTraversalNodes:oc(e?.maxTraversalNodes,1e6,1e6)})}var jh=["single","dashed","dotted","double","triple","thick"];function ic(e){return e===void 0?true:!Number.isFinite(e)||!Number.isInteger(e)?false:e>=Wo&&e<=Ho}function ac(e){return e===void 0?true:!Number.isFinite(e)||!Number.isInteger(e)?false:e>=Ur&&e<=Lr}function Kh(e){return (e.mode??"frame")==="simple"?ac(e.horizontalEmu)&&ac(e.verticalEmu):e.relativeToH!==void 0&&!Ko.has(e.relativeToH)||e.relativeToV!==void 0&&!Go.has(e.relativeToV)?false:ic(e.horizontalEmu)&&ic(e.verticalEmu)}var yV=Object.freeze([...Ko]),OV=Object.freeze([...Go]);function NV(e){return e.horizontalEmu!==void 0||e.verticalEmu!==void 0||e.relativeToH!==void 0||e.relativeToV!==void 0}function kV(e,n){return n?.position?.mode==="simple"?Object.freeze({mode:"simple",...e.horizontalEmu!==void 0?{horizontalEmu:e.horizontalEmu}:{},...e.verticalEmu!==void 0?{verticalEmu:e.verticalEmu}:{}}):Object.freeze({mode:"frame",...e.horizontalEmu!==void 0?{horizontalEmu:e.horizontalEmu}:{},...e.verticalEmu!==void 0?{verticalEmu:e.verticalEmu}:{},...e.relativeToH!==void 0?{relativeToH:e.relativeToH}:{},...e.relativeToV!==void 0?{relativeToV:e.relativeToV}:{}})}function bV(e,n){if(e.relativeToH!==void 0&&!Ko.has(e.relativeToH)||e.relativeToV!==void 0&&!Go.has(e.relativeToV))return false;let t=n==="simple"?ac:ic;return t(e.horizontalEmu)&&t(e.verticalEmu)}function $h(e,n){return e.id===n?true:e.kind==="textValue"?false:e.children.some(t=>$h(t,n))}function av(e,n){let t=r=>{if(r.kind==="textValue")return null;if((r.kind==="text"||r.kind==="deletedText")&&r.children.some(o=>o.id===n))return r;for(let o of r.children){let i=t(o);if(i)return i}return null};return t(e)}function Gh(e,n,t="text"){let r=e();return {id:e(),kind:t,namespaceUri:O,localName:t==="deletedText"?"delText":"t",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:r,kind:"textValue",value:n}]}}function lv(e,n){return {id:e(),kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:n}}function zh(e,n,t,r,o){let i=S(e),a=Q(n);for(let c of a){if(c.node.kind!=="textValue"||t<=c.start||t>=c.end)continue;let u=t-c.start,f=c.node.value,m=av(n,c.node.id);if(!m)return {ok:false,issues:[{code:"known-node-invariant",path:"orphan-text-value",nodeId:c.node.id}]};let g=R(e,c.runId);if(!g||g.kind!=="run")return {ok:false,issues:[{code:"known-node-invariant",path:"missing-run",nodeId:c.runId}]};let p=m.kind==="deletedText"?"deletedText":"text",x=Gh(i,f.slice(0,u),p),y=Gh(i,f.slice(u),p),N=g.children.flatMap(b=>b.id===m.id?[x,...r,y]:[b]);return L(e,g.id,N,o)}let l=a.find(c=>c.start===t);if(l){let c=R(e,l.runId);if(!c||c.kind!=="run")return {ok:false,issues:[{code:"known-node-invariant",path:"missing-run",nodeId:l.runId}]};let u=c.children.findIndex(f=>$h(f,l.node.id));return M(e,c.id,Math.max(0,u),r,o)}let s=n.children.flatMap(c=>c.kind==="run"?[c]:c.kind==="hyperlink"||he(c.kind)?c.children.filter(u=>u.kind==="run"):[]),d=s[s.length-1];return d&&d.kind==="run"?M(e,d.id,d.children.length,r,o):M(e,n.id,n.children.length,[lv(i,r)],o)}function Xh(e,n){for(let t of Q(e))if(!(!t.removeNodeIds||t.removeNodeIds.length===0)&&n>t.start&&n<t.end)return true;return false}function xo(e){let n=t=>{if(t.kind==="textValue")return null;if(t.kind==="body")return t;for(let r of t.children??[]){let o=n(r);if(o)return o}return null};return n(e.root)}function lc(e){let n=xo(e);if(!n)return null;for(let t of n.children)if(t.kind!=="textValue"&&"localName"in t&&t.localName==="sectPr")return t;return null}function Yh(e){let n=[],t=r=>{if(r.kind!=="textValue"&&r.kind!=="table"){if("localName"in r&&r.localName==="sectPr"){n.push(r);return}for(let o of r.children??[])t(o);}};return t(e.root),n}function Bi(e,n){let t=false,r=false,o=(i,a)=>{if(r||i.kind==="textValue")return;if(i.id===n){t=a,r=true;return}let l=a||i.kind==="table";for(let s of i.children??[])o(s,l);};return o(e.root,false),t}function jn(e,n){if(!(!e||e.kind==="textValue"||!("attributes"in e))){for(let t of e.attributes??[])if(t.localName===n)return t.value}}function St(e,n){if(!e||e.kind==="textValue")return null;for(let t of e.children??[])if(t.kind!=="textValue"&&"localName"in t&&t.localName===n)return t;return null}var qh=(e,n,t)=>{if(e===void 0||!/^-?\d{1,7}$/.test(e))return n;let r=Number(e);return !Number.isFinite(r)||r<=0||r>t?n:r},Pr=(e,n)=>{if(e===void 0||!/^-?\d{1,7}$/.test(e))return n;let t=Number(e);return !Number.isFinite(t)||Math.abs(t)>31680?n:t};function Fi(e,n){let t=n.pageWidthTwips??e.widthTwips,r=n.pageHeightTwips??e.heightTwips;if(n.orientation!==void 0&&n.pageWidthTwips===void 0&&n.pageHeightTwips===void 0){let o=Math.max(e.widthTwips,e.heightTwips),i=Math.min(e.widthTwips,e.heightTwips);t=n.orientation==="landscape"?o:i,r=n.orientation==="landscape"?i:o;}return {widthTwips:t,heightTwips:r}}function ho(e,n){if(n===void 0){let i=Yh(e);return lc(e)?i:[...i,null]}let t=false,r,o=(i,a)=>{if(r!==void 0||i.kind==="textValue")return;if(i.kind==="paragraph"){if(i.id===n&&(t=true),t&&!a){let s=ye(i),d=s?St(s,"sectPr"):null;d&&(r=d);}return}let l=a||i.kind==="table";for(let s of i.children??[])o(s,l);};return o(e.root,false),[r??lc(e)]}function yo(e){let n=St(e,"pgSz"),t=St(e,"pgMar");return {widthTwips:qh(jn(n,"w"),12240,63360),heightTwips:qh(jn(n,"h"),15840,63360),topTwips:Pr(jn(t,"top"),1440),rightTwips:Pr(jn(t,"right"),1440),bottomTwips:Pr(jn(t,"bottom"),1440),leftTwips:Pr(jn(t,"left"),1440),headerTwips:Pr(jn(t,"header"),720),footerTwips:Pr(jn(t,"footer"),720),gutterTwips:Pr(jn(t,"gutter"),0)}}var sc=1e5;function Vi(e){if(e!==void 0){if(e==="1"||e==="true")return true;if(e==="0"||e==="false")return false}}function sv(e){return e?"1":"0"}function ny(e,n){let t=R(e,n);for(;t;){if(t.kind==="paragraph")return t;t=Z(e,t.id);}return null}function dv(e){return e.kind==="drawingSimplePos"||e.kind==="drawingPositionH"||e.kind==="drawingPositionV"||e.kind==="drawingWrapNone"||e.kind==="drawingWrapSquare"||e.kind==="drawingWrapTight"||e.kind==="drawingWrapThrough"||e.kind==="drawingWrapTopBottom"?true:e.namespaceUri!==_?false:e.localName==="simplePos"||e.localName==="positionH"||e.localName==="positionV"||e.localName.startsWith("wrap")}function cv(e){let n=q(e.children,{kind:"drawingExtent"})??q(e.children,{namespaceUri:_,localName:"extent"}),t=Number(Ae(n?.attributes??[],"cx")??"914400"),r=Number(Ae(n?.attributes??[],"cy")??"914400");return {cx:t,cy:r}}function uv(e,n,t){let r=(o,i,a,l)=>({id:t(),kind:o,namespaceUri:_,localName:i,prefix:"wp",namespaceBindings:[],attributes:[te("x",String(Math.round(a))),te("y",String(Math.round(l)))],children:[]});return {id:t(),kind:"drawingWrapPolygon",namespaceUri:_,localName:"wrapPolygon",prefix:"wp",namespaceBindings:[],attributes:[te("edited","0")],children:[r("drawingWrapPolygonStart","start",0,0),r("drawingWrapPolygonLineTo","lineTo",e,0),r("drawingWrapPolygonLineTo","lineTo",e,n),r("drawingWrapPolygonLineTo","lineTo",0,n),r("drawingWrapPolygonLineTo","lineTo",0,0)]}}function dc(e,n,t){return J(e,{children:e.children.map(r=>r.id===n?t:r)})}function Oe(e){return e.kind!=="textValue"}function Ae(e,n){for(let t of e)if(t.localName===n&&t.namespaceUri==="")return t.value}function te(e,n){return {kind:"genericExtension",namespaceUri:"",localName:e,value:n}}function en(e,n,t){let r=e.filter(o=>!(o.localName===n&&o.namespaceUri===""));return t!==void 0&&r.push(te(n,t)),r}function J(e,n){return {...e,...n}}function q(e,n){for(let t of e)if(Oe(t)&&!(n.kind!==void 0&&t.kind!==n.kind)&&!(n.localName!==void 0&&t.localName!==n.localName)&&!(n.namespaceUri!==void 0&&t.namespaceUri!==n.namespaceUri))return t;return null}function ty(e){return q(e.children,{kind:"inlineDrawing"})??q(e.children,{kind:"anchoredDrawing"})??q(e.children,{namespaceUri:_,localName:"inline"})??q(e.children,{namespaceUri:_,localName:"anchor"})}function fv(e,n){let t=R(e,n);return t!==null&&t.kind==="drawing"}function ry(e,n){return dr(n,{ownerPartName:e.name,supportedMcRequires:rt,limits:Kt})}function oy(e){return e!==null&&e.picture!==null}function Zh(e){return Number.isFinite(e)&&e>0&&e<=jo}function mv(e){return [e.left,e.top,e.right,e.bottom].some(t=>!Number.isFinite(t)||t<0||t>sc)?false:e.left+e.right<sc&&e.top+e.bottom<sc}function Tl(e){return String(Math.round(e))}function pv(e){let n=q(e.children,{kind:"drawingGraphicFramePr"})??q(e.children,{namespaceUri:_,localName:"cNvGraphicFramePr"});if(!n)return {};let t=n.children.find(o=>Oe(o)&&o.namespaceUri===F&&o.localName==="graphicFrameLocks");if(!t||!Oe(t))return {};let r=o=>{let i=Ae(t.attributes,o);return Vi(i)};return {select:r("noSelect"),move:r("noMove"),resize:r("noResize"),changeAspect:r("noChangeAspect")}}function iy(e){if(Vi(Ae(e.attributes,"locked"))===true)return Object.freeze({select:true,move:true,resize:true,changeAspect:true});let t=pv(e);return Object.freeze({select:t.select??false,move:t.move??false,resize:t.resize??false,changeAspect:t.changeAspect??false})}function wr(e,n){let t=iy(e);return n==="deleteDrawing"&&t.select||n==="resizeDrawing"&&t.resize||n==="cropDrawing"&&(t.resize||t.changeAspect)||n==="positionDrawing"&&t.move||n==="setDrawingWrap"&&t.move||n==="transformDrawing"&&(t.resize||t.changeAspect)?"drawing-locked":n==="setDrawingLocks"||n==="setDrawingMetadata"?null:n==="replaceDrawingResource"&&t.resize?"drawing-locked":null}function Fe(e,n){if(!fv(e,n))return R(e,n)?"not-a-drawing":"unknown-drawing";let t=R(e,n),r=ty(t);if(!r)return "not-a-drawing";let o=ry(e,t);return !o||!oy(o)?"not-a-picture-drawing":{drawing:t,anchor:r,projection:o}}function gv(e){return e.length>0&&e.length<=512&&/^[A-Za-z0-9._-]+$/.test(e)}function cc(e){switch(e.op){case "setDrawingMetadata":case "setDrawingLocks":case "replaceDrawingResource":return "text-local";case "insertDrawing":case "deleteDrawing":case "resizeDrawing":case "cropDrawing":case "positionDrawing":case "setDrawingWrap":case "transformDrawing":return "flow-structural";default:{return "flow-structural"}}}function mc(e,n){switch(n.op){case "insertDrawing":{let t=R(e,n.paragraphId);if(!t)return "unknown-paragraph";if(!En(t))return "not-a-paragraph";let r=Zn(t);if(!Number.isInteger(n.offset)||n.offset<0||n.offset>r)return "offset-out-of-range";if(Be(t,n.offset))return "splits-surrogate-pair";if(Xh(t,n.offset))return "invalid-range";let o=Q(t).find(l=>l.start===n.offset);if(o?.removeNodeIds&&o.removeNodeIds.length>0&&o.node.kind!=="textValue"&&o.node.kind!=="tab"&&o.node.kind!=="hardBreak")return "invalid-range";if(n.drawing.kind!=="drawing"||!ty(n.drawing))return "not-a-drawing";let a=ry(e,n.drawing);return oy(a)?Bi(e,n.paragraphId)&&n.offset!==r&&n.offset!==0&&!Q(t).find(s=>s.start===n.offset)?"cross-cell-drawing":null:"not-a-picture-drawing"}case "deleteDrawing":{if(n.revision)return "trackedDrawingDeletionUnsupported";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:wr(t.anchor,n.op)}case "replaceDrawingResource":{if(!gv(n.relationshipId))return "invalid-drawing-value";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:wr(t.anchor,n.op)}case "resizeDrawing":{if(!Zh(n.extentEmu.cx)||!Zh(n.extentEmu.cy))return "invalid-drawing-value";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:wr(t.anchor,n.op)}case "cropDrawing":{if(!mv(n.crop))return "invalid-drawing-value";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:wr(t.anchor,n.op)}case "positionDrawing":{if(!Kh(n.position))return "invalid-drawing-value";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:t.projection.kind!=="anchored"?"invalid-drawing-value":wr(t.anchor,n.op)}case "setDrawingWrap":{if(!Cm.includes(n.wrap))return "invalid-drawing-value";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:wr(t.anchor,n.op)}case "setDrawingMetadata":{if(!Qh(n.title)||!Qh(n.description)||n.hyperlink!==void 0&&n.hyperlink!==null&&!yt(n.hyperlink).ok)return "invalid-drawing-value";if(n.hyperlink!==void 0&&n.hyperlink!==null)return "packageTransactionRequired";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:null}case "setDrawingLocks":{for(let r of [n.locks.select,n.locks.move,n.locks.resize,n.locks.changeAspect])if(r!==void 0&&typeof r!="boolean")return "invalid-drawing-value";let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:null}case "transformDrawing":{let t=Fe(e,n.drawingNodeId);return typeof t=="string"?t:t.projection.picture?wr(t.anchor,n.op):"not-a-drawing"}default:{return "unknown-op"}}}function Qh(e){if(typeof e!="string"||e.length>2048)return false;for(let n=0;n<e.length;n+=1){let t=e.charCodeAt(n);if(t===0||t>=1&&t<=8||t===11||t===12||t>=14&&t<=31)return false}return true}function ay(e,n,t){let r=ny(e,n);return {dirty:r?[r.id,n]:[n],created:[],deleted:[],dependencyKeys:W,impact:cc(t)}}function xv(e,n,t){let r=q(e.children,{kind:"drawingExtent"})??q(e.children,{namespaceUri:_,localName:"extent"});if(!r)return e;let o=J(r,{attributes:en(en(r.attributes,"cx",String(Math.round(n))),"cy",String(Math.round(t)))});return J(e,{children:e.children.map(i=>i.id===r.id?o:i)})}function pc(e){let n=q(e.children,{kind:"drawingGraphic"});if(!n)return null;let t=q(n.children,{kind:"drawingGraphicData"});return t?q(t.children,{kind:"picture"}):null}function hv(e){let n=q(e.children,{kind:"pictureBlipFill"})??q(e.children,{namespaceUri:Ze,localName:"blipFill"});return n?q(n.children,{kind:"pictureBlip"})??q(n.children,{namespaceUri:F,localName:"blip"}):null}function ly(e,n){return {kind:"genericExtension",namespaceUri:$n,localName:e,prefix:"r",value:n}}function uc(e,n,t){let r=e.filter(o=>!(o.localName===n&&o.namespaceUri===$n));return t!==void 0&&r.push(ly(n,t)),r}function yv(e,n){let t=pc(e);if(!t)return e;let r=t.children.find(f=>Oe(f)&&(f.kind==="pictureBlipFill"||f.localName==="blipFill"));if(!r)return e;let o=hv(t);if(!o)return e;let i=J(o,{attributes:uc(uc(o.attributes,"link",void 0),"embed",n)}),a=J(r,{children:r.children.map(f=>f.id===o.id?i:f)}),l=J(t,{children:t.children.map(f=>f.id===r.id?a:f)}),s=q(e.children,{kind:"drawingGraphic"}),d=q(s.children,{kind:"drawingGraphicData"}),c=J(d,{children:d.children.map(f=>f.id===t.id?l:f)}),u=J(s,{children:s.children.map(f=>f.id===d.id?c:f)});return J(e,{children:e.children.map(f=>f.id===s.id?u:f)})}function Ov(e,n,t){let r=pc(e);if(!r)return e;let o=r.children.find(c=>Oe(c)&&(c.kind==="pictureBlipFill"||c.localName==="blipFill"));if(!o)return e;let i=q(o.children,{kind:"pictureSrcRect"})??q(o.children,{namespaceUri:F,localName:"srcRect"}),a=en(en(en(en(i?.attributes??[],"l",Tl(n.left)),"t",Tl(n.top)),"r",Tl(n.right)),"b",Tl(n.bottom));if(!i){i={id:t(),kind:"pictureSrcRect",namespaceUri:F,localName:"srcRect",prefix:"a",namespaceBindings:[],attributes:a,children:[]};let c=o.children.findIndex(p=>Oe(p)&&(p.kind==="pictureBlip"||p.localName==="blip")),u=c>=0?c+1:0,f=[...o.children];f.splice(u,0,i);let m=J(o,{children:f}),g=J(r,{children:r.children.map(p=>p.id===o.id?m:p)});return fc(e,g)}let l=J(i,{attributes:a}),s=J(o,{children:o.children.map(c=>c.id===i.id?l:c)}),d=J(r,{children:r.children.map(c=>c.id===o.id?s:c)});return fc(e,d)}function fc(e,n){let t=q(e.children,{kind:"drawingGraphic"}),r=q(t.children,{kind:"drawingGraphicData"}),o=J(r,{children:r.children.map(a=>a.id===n.id?n:a)}),i=J(t,{children:t.children.map(a=>a.id===r.id?o:a)});return J(e,{children:e.children.map(a=>a.id===t.id?i:a)})}function Nv(e){return q(e.children,{kind:"pictureShapeProperties"})??q(e.children,{namespaceUri:Ze,localName:"spPr"})}function kv(e,n,t){let r=pc(e);if(!r||!n.picture)return e;let o=Nv(r);if(!o)return e;let i=q(o.children,{kind:"drawingTransform"})??q(o.children,{namespaceUri:F,localName:"xfrm"}),a=n.picture.transform.rotationDegrees,l=n.picture.transform.flipHorizontal,s=n.picture.transform.flipVertical;switch(t){case "rotateCW":a=(a+90)%360;break;case "rotateCCW":a=(a+270)%360;break;case "flipH":l=!l;break;case "flipV":s=!s;break}let d=[...i?.attributes??[]],c=Math.round(a*6e4),u=en(en(en(d,"rot",c===0?void 0:String(c)),"flipH",l?"1":void 0),"flipV",s?"1":void 0);if(!i)return e;let f=J(i,{attributes:u}),m=J(o,{children:o.children.map(p=>p.id===i.id?f:p)}),g=J(r,{children:r.children.map(p=>p.id===o.id?m:p)});return fc(e,g)}function bv(e,n,t,r){let o=q(e.children,{kind:"drawingDocPr"})??q(e.children,{namespaceUri:_,localName:"docPr"});if(!o)return e;let i=en(en(o.attributes,"title",n.length>0?n:void 0),"descr",t.length>0?t:void 0),a=[...o.children];r===null&&(a=a.filter(s=>!(Oe(s)&&s.namespaceUri===F&&s.localName==="hlinkClick")));let l=J(o,{attributes:i,children:a});return J(e,{children:e.children.map(s=>s.id===o.id?l:s)})}function sy(e){let n=q(e.children,{kind:"drawingDocPr"})??q(e.children,{namespaceUri:_,localName:"docPr"});if(!n)return null;let t=n.children.find(r=>Oe(r)&&r.namespaceUri===F&&r.localName==="hlinkClick");if(!t||!Oe(t))return null;for(let r of t.attributes)if(r.localName==="id"&&r.namespaceUri===$n)return r.value;return null}function dy(e,n){let t=q(e.children,{kind:"drawingDocPr"})??q(e.children,{namespaceUri:_,localName:"docPr"});if(!t)return e;let r=[...t.children];if(n===null)r=r.filter(i=>!(Oe(i)&&i.namespaceUri===F&&i.localName==="hlinkClick"));else {let i=r.find(a=>Oe(a)&&a.namespaceUri===F&&a.localName==="hlinkClick");if(i){let a=J(i,{attributes:uc(i.attributes,"id",n)});r=r.map(l=>l.id===i.id?a:l);}else r.push({id:`${t.id}#hlink`,kind:"generic",namespaceUri:F,localName:"hlinkClick",prefix:"a",namespaceBindings:[],attributes:[ly("id",n)],children:[]});}let o=J(t,{children:r});return J(e,{children:e.children.map(i=>i.id===t.id?o:i)})}function Pv(e,n){return Object.freeze({select:n.select??e.select,move:n.move??e.move,resize:n.resize??e.resize,changeAspect:n.changeAspect??e.changeAspect})}var wv=new Set(["noSelect","noMove","noResize","noChangeAspect"]),Ev=[["select","noSelect"],["move","noMove"],["resize","noResize"],["changeAspect","noChangeAspect"]];function Rv(e){return e.select!==void 0||e.move!==void 0||e.resize!==void 0||e.changeAspect!==void 0}function Iv(e){return Vi(Ae(e.attributes,"locked"))===true}function Tv(e){return e.namespaceUri===""?e.localName:`${e.namespaceUri}:${e.localName}`}function Cv(e){return q(e.children,{kind:"drawingGraphicFramePr"})??q(e.children,{namespaceUri:_,localName:"cNvGraphicFramePr"})}function vv(e){return e.children.find(n=>Oe(n)&&n.namespaceUri===F&&n.localName==="graphicFrameLocks")}function Sv(e,n){let t=[...e.children],r=t.findIndex(o=>Oe(o)&&(o.kind==="drawingGraphic"||o.localName==="graphic"));return t.splice(r>=0?r:t.length,0,n),J(e,{children:t})}function Av(e,n,t){return J(e,{children:e.children.map(r=>r.id===n?t:r)})}function Mv(e,n,t,r){let o=iy(e),i=Pv(o,t),a=Iv(e)&&Rv(t),l=i.select&&i.move&&i.resize&&i.changeAspect,s=J(e,{attributes:en(e.attributes,"locked",l?"1":"0")}),d=Cv(s);d||(d={id:r(),kind:"drawingGraphicFramePr",namespaceUri:_,localName:"cNvGraphicFramePr",prefix:"wp",namespaceBindings:[],attributes:[],children:[]},s=Sv(s,d));let c=vv(d),u=new Map;for(let y of c?.attributes??[])u.set(Tv(y),y);let f=(y,N)=>{if(N===void 0)return;let b=y;if(N){let h=u.get(b);h&&Vi(h.value)===true?u.set(b,h):u.set(b,te(y,sv(true)));}else u.delete(b);};for(let[y,N]of Ev)a?f(N,i[y]):t[y]!==void 0&&f(N,t[y]);let m=["noSelect","noMove","noResize","noChangeAspect"].some(y=>{let N=u.get(y)?.value;return Vi(N)===true}),g=[...u.values()].some(y=>y.namespaceUri!==""||!wv.has(y.localName)),p=d.children.filter(y=>!(Oe(y)&&y.localName==="graphicFrameLocks"));if(m||g){let y=c?J(c,{attributes:[...u.values()]}):{id:r(),kind:"generic",namespaceUri:F,localName:"graphicFrameLocks",prefix:"a",namespaceBindings:[],attributes:[...u.values()],children:[]};p=[...p,y];}let x={...d,kind:"drawingGraphicFramePr",children:p};return Av(s,d.id,x)}function Jh(e){switch(e){case "inline":return {behindDocument:false,wrapLocalName:"wrapNone"};case "behind":return {behindDocument:true,wrapLocalName:"wrapNone"};case "inFront":return {behindDocument:false,wrapLocalName:"wrapNone"};case "square":return {behindDocument:false,wrapLocalName:"wrapSquare",wrapText:"bothSides"};case "squareLeft":return {behindDocument:false,wrapLocalName:"wrapSquare",wrapText:"left"};case "squareRight":return {behindDocument:false,wrapLocalName:"wrapSquare",wrapText:"right"};case "tight":return {behindDocument:false,wrapLocalName:"wrapTight",wrapText:"bothSides"};case "through":return {behindDocument:false,wrapLocalName:"wrapThrough",wrapText:"bothSides"};case "topAndBottom":return {behindDocument:false,wrapLocalName:"wrapTopAndBottom"};default:{return {behindDocument:false,wrapLocalName:"wrapSquare",wrapText:"bothSides"}}}}function cy(e){return e.children.filter(n=>Oe(n)&&!dv(n))}function _v(e){return e?e.children.filter(n=>Oe(n)&&n.kind==="generic"&&n.localName!=="wrapPolygon"&&n.localName!=="effectExtent"):[]}function Dv(e,n,t){let r=t?Uv(t):{top:0,right:0,bottom:0,left:0},o=(t?.attributes??[]).filter(i=>i.namespaceUri!=="");switch(e){case "wrapNone":break;case "wrapSquare":o.push(te("distT",String(r.top)),te("distB",String(r.bottom)),te("distL",String(r.left)),te("distR",String(r.right))),n.wrapText&&o.push(te("wrapText",n.wrapText));break;case "wrapTight":case "wrapThrough":o.push(te("distL",String(r.left)),te("distR",String(r.right))),n.wrapText&&o.push(te("wrapText",n.wrapText));break;case "wrapTopAndBottom":o.push(te("distT",String(r.top)),te("distB",String(r.bottom)));break}return o}function uy(e,n,t,r){let o=Dv(e.wrapLocalName,e,t),i={wrapNone:"drawingWrapNone",wrapSquare:"drawingWrapSquare",wrapTight:"drawingWrapTight",wrapThrough:"drawingWrapThrough",wrapTopAndBottom:"drawingWrapTopBottom"},a=[..._v(t)];if(e.wrapLocalName==="wrapSquare"||e.wrapLocalName==="wrapTopAndBottom"){let l=t?.children.find(s=>Oe(s)&&(s.kind==="drawingEffectExtent"||s.namespaceUri===_&&s.localName==="effectExtent"))??null;l&&a.unshift(l);}if(e.wrapLocalName==="wrapTight"||e.wrapLocalName==="wrapThrough"){let{cx:l,cy:s}=cv(r);a.unshift(uv(l,s,n));}return {id:n(),kind:i[e.wrapLocalName],namespaceUri:_,localName:e.wrapLocalName,prefix:"wp",namespaceBindings:[],attributes:o,children:a}}function Uv(e){let n=t=>Number(Ae(e.attributes,t)??"0");return {top:n("distT"),right:n("distR"),bottom:n("distB"),left:n("distL")}}function Lv(e,n){let t=n.position,r=t?.horizontal.relativeFrom??"column",o=t?.vertical.relativeFrom??"paragraph";return [{id:e(),kind:"drawingSimplePos",namespaceUri:_,localName:"simplePos",prefix:"wp",namespaceBindings:[],attributes:[te("x","0"),te("y","0")],children:[]},{id:e(),kind:"drawingPositionH",namespaceUri:_,localName:"positionH",prefix:"wp",namespaceBindings:[],attributes:[te("relativeFrom",r)],children:[{id:e(),kind:"drawingPositionOffset",namespaceUri:_,localName:"posOffset",prefix:"wp",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"textValue",value:String(t?.horizontal.offsetEmu??0)}]}]},{id:e(),kind:"drawingPositionV",namespaceUri:_,localName:"positionV",prefix:"wp",namespaceBindings:[],attributes:[te("relativeFrom",o)],children:[{id:e(),kind:"drawingPositionOffset",namespaceUri:_,localName:"posOffset",prefix:"wp",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"textValue",value:String(t?.vertical.offsetEmu??0)}]}]}]}function Bv(e,n,t){let r=(...c)=>n.find(u=>Oe(u)&&c.includes(u.kind))??n.find(u=>Oe(u)&&c.includes(u.localName)),o=r("drawingExtent","extent"),i=r("drawingEffectExtent","effectExtent"),a=r("drawingDocPr","docPr"),l=r("drawingGraphicFramePr","cNvGraphicFramePr"),s=r("drawingGraphic","graphic"),d=[...e];o&&d.push(o),i&&d.push(i),d.push(t),a&&d.push(a),l&&d.push(l),s&&d.push(s);for(let c of n)d.includes(c)||d.push(c);return d}function Fv(e,n,t,r){let o=fy(e),i=uy(n,r,o,e),a=cy(e),l=Lv(r,t),s=e.kind==="inlineDrawing"||e.localName==="inline"?{top:Number(Ae(e.attributes,"distT")??"0"),right:Number(Ae(e.attributes,"distR")??"0"),bottom:Number(Ae(e.attributes,"distB")??"0"),left:Number(Ae(e.attributes,"distL")??"0")}:{top:0,right:0,bottom:0,left:0},d=e.attributes.filter(c=>c.namespaceUri!=="");return {id:r(),kind:"anchoredDrawing",namespaceUri:_,localName:"anchor",prefix:"wp",namespaceBindings:[],attributes:[te("distT",String(s.top)),te("distB",String(s.bottom)),te("distL",String(s.left)),te("distR",String(s.right)),te("simplePos",Ae(e.attributes,"simplePos")??"0"),te("relativeHeight",String(t.anchor?.relativeHeight??251658240)),te("behindDoc",n.behindDocument?"1":"0"),te("locked",Ae(e.attributes,"locked")??"0"),te("layoutInCell",Ae(e.attributes,"layoutInCell")??"1"),te("allowOverlap",Ae(e.attributes,"allowOverlap")??"1"),...d],children:Bv(l,a,i)}}function Vv(e,n){let t=cy(e),r={top:Number(Ae(e.attributes,"distT")??"0"),right:Number(Ae(e.attributes,"distR")??"0"),bottom:Number(Ae(e.attributes,"distB")??"0"),left:Number(Ae(e.attributes,"distL")??"0")};return {id:n(),kind:"inlineDrawing",namespaceUri:_,localName:"inline",prefix:"wp",namespaceBindings:[],attributes:[te("distT",String(r.top)),te("distR",String(r.right)),te("distB",String(r.bottom)),te("distL",String(r.left))],children:t}}function Wv(e,n,t,r,o){if(r==="inline"){if(t.kind==="inline")return e;let f=Vv(n,o);return dc(e,n.id,f)}if(t.kind==="inline"){let f=Jh(r),m=Fv(n,f,t,o);return dc(e,n.id,m)}let i=Jh(r),a=fy(n),l=uy(i,o,a,n),s=J(n,{attributes:en(n.attributes,"behindDoc",i.behindDocument?"1":"0")}),d=s.children.filter(f=>Oe(f)?f.id===a?.id?false:!(f.kind==="drawingWrapNone"||f.kind==="drawingWrapSquare"||f.kind==="drawingWrapTight"||f.kind==="drawingWrapThrough"||f.kind==="drawingWrapTopBottom"||f.namespaceUri===_&&f.localName.startsWith("wrap")):true),c=d.findIndex(f=>Oe(f)&&(f.kind==="drawingDocPr"||f.localName==="docPr")),u=[...d];return u.splice(c>=0?c:u.length,0,l),s=J(s,{children:u}),dc(e,n.id,s)}function fy(e){for(let n of e.children)if(Oe(n)&&(n.kind==="drawingWrapNone"||n.kind==="drawingWrapSquare"||n.kind==="drawingWrapTight"||n.kind==="drawingWrapThrough"||n.kind==="drawingWrapTopBottom"||n.namespaceUri===_&&n.localName.startsWith("wrap")))return n;return null}function ey(e,n,t,r,o,i){let a=q(e.children,{kind:n})??q(e.children,{namespaceUri:_,localName:t});if(!a)return e;let l=a.attributes;r&&(l=en(l,"relativeFrom",r));let s=[...a.children];o!==void 0&&(s=s.filter(c=>!(Oe(c)&&(c.localName==="posOffset"||c.localName==="align"||c.kind==="drawingPositionOffset"||c.kind==="drawingPositionAlign"))),s.push({id:i(),kind:"drawingPositionOffset",namespaceUri:_,localName:"posOffset",prefix:"wp",namespaceBindings:[],attributes:[],children:[{id:i(),kind:"textValue",value:String(Math.round(o))}]}));let d=J(a,{attributes:l,children:s});return J(e,{children:e.children.map(c=>c.id===a.id?d:c)})}function Hv(e,n,t){if(Ae(e.attributes,"simplePos")==="1"){let i=q(e.children,{kind:"drawingSimplePos"});if(!i)return e;let a=i.attributes;n.horizontalEmu!==void 0&&(a=en(a,"x",String(Math.round(n.horizontalEmu)))),n.verticalEmu!==void 0&&(a=en(a,"y",String(Math.round(n.verticalEmu))));let l=J(i,{attributes:a});return J(e,{children:e.children.map(s=>s.id===i.id?l:s)})}let o=e;return (n.horizontalEmu!==void 0||n.relativeToH)&&(o=ey(o,"drawingPositionH","positionH",n.relativeToH,n.horizontalEmu,t)),(n.verticalEmu!==void 0||n.relativeToV)&&(o=ey(o,"drawingPositionV","positionV",n.relativeToV,n.verticalEmu,t)),o}function jv(e){let n=[{prefix:"wp",namespaceUri:_},{prefix:"a",namespaceUri:F},{prefix:"pic",namespaceUri:Ze},{prefix:"r",namespaceUri:$n}],t=[...e.namespaceBindings];for(let r of n)t.some(o=>o.prefix===r.prefix)||t.push(r);return J(e,{namespaceBindings:t})}function Er(e,n,t,r,o){let i=J(n,{children:n.children.map(l=>l.id===t.id?t:l)}),a=V(e,n.id,i,o);return T(a,ay(e,n.id,r))}function my(e,n,t){let r=mc(e,n);if(r)return {ok:false,reason:r};let o=S(e);switch(n.op){case "insertDrawing":{let i=R(e,n.paragraphId),a=jv(Ke(n.drawing,o)),l=zh(e,i,n.offset,[a],t),s={dirty:[i.id,a.id],created:[a.id],deleted:[],dependencyKeys:W,impact:cc(n)};return T(l,s)}case "deleteDrawing":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=ny(e,i.drawing.id),l={dirty:a?[a.id,i.drawing.id]:[i.drawing.id],created:[],deleted:[i.drawing.id],dependencyKeys:W,impact:cc(n)};return T(oe(e,i.drawing.id,t),l)}case "replaceDrawingResource":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=yv(i.anchor,n.relationshipId);return Er(e,i.drawing,a,n,t)}case "resizeDrawing":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=xv(i.anchor,n.extentEmu.cx,n.extentEmu.cy);return Er(e,i.drawing,a,n,t)}case "cropDrawing":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=Ov(i.anchor,n.crop,o);return Er(e,i.drawing,a,n,t)}case "positionDrawing":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=Hv(i.anchor,n.position,o);return Er(e,i.drawing,a,n,t)}case "setDrawingWrap":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=Wv(i.drawing,i.anchor,i.projection,n.wrap,o),l=V(e,i.drawing.id,a,t);return T(l,ay(e,i.drawing.id,n))}case "setDrawingMetadata":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=bv(i.anchor,n.title,n.description,n.hyperlink);return Er(e,i.drawing,a,n,t)}case "setDrawingLocks":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=Mv(i.anchor,i.projection,n.locks,o);return Er(e,i.drawing,a,n,t)}case "transformDrawing":{let i=Fe(e,n.drawingNodeId);if(typeof i=="string")return {ok:false,reason:i};let a=kv(i.anchor,i.projection,n.action);return Er(e,i.drawing,a,n,t)}default:{return {ok:false,reason:"unknown-op"}}}}function Cl(e){return e.op==="insertDrawing"||e.op==="replaceDrawingResource"||e.op==="deleteDrawing"||e.op==="resizeDrawing"||e.op==="cropDrawing"||e.op==="positionDrawing"||e.op==="setDrawingWrap"||e.op==="setDrawingMetadata"||e.op==="setDrawingLocks"||e.op==="transformDrawing"}var er=["rFonts","sz","szCs","color","b","bCs","i","iCs","u","strike","dstrike","highlight","vertAlign","position","caps","smallCaps","spacing","w","kern"],nr=["pStyle","jc","spacing","ind","tabs","numPr","keepNext","keepLines","widowControl","pageBreakBefore","contextualSpacing","shd"],vl=["replaceStoryBlocks","insertText","deleteText","setParagraphMarkRevision","proposeParagraphMerge","insertCommentMarker","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","insertTab","insertHardBreak","insertPageBreak","insertPageField","setListLevel","setListNumbering","setParagraphTabStops","setParagraphMarkProperties","splitParagraph","splitParagraphMany","joinParagraphs","setRunProperties","setParagraphProperties","setSectionProperties","setSectionMark","insertHyperlink","setHyperlinkTarget","removeHyperlink","setMathEquation","removeMathEquation","setContentControlValue","removeContentControl","insertInlineContentControl","addRepeatingSectionItem","removeRepeatingSectionItem","deleteBlock","insertTable","insertTableRow","deleteTableRow","insertTableColumn","deleteTableColumn","setTableColumnWidths","setTableRightEdgeWidth","setTableRowHeight","setTableCellBorders","setTableCellFill","setTableCellVerticalAlignment","createHeaderFooter","deleteHeaderFooter","linkToPrevious","unlinkFromPrevious","setSectionFurnitureOptions","insertNote","deleteNote","convertNote","convertAllNotes","setNoteProperties","setContentControlProperties","insertContentControl","insertDrawing","replaceDrawingResource","deleteDrawing","resizeDrawing","cropDrawing","positionDrawing","setDrawingWrap","setDrawingMetadata","setDrawingLocks","transformDrawing","insertToc","replaceTocResult","rewriteTocPageNumbers"];var Kv=new Set(["paragraph","table","tableRow"]);function Rr(e){let n=[],t=r=>{if(r.kind!=="textValue"){r.kind==="paragraph"&&n.push(r.id);for(let o of r.children)t(o);}};return t(e),n}function Gv(e){let n=[],t=o=>{for(let i of Ii(o))if(i.kind==="paragraph")n.push(i.id);else if(i.kind==="table"){for(let a of i.children)if(a.kind==="tableRow")for(let l of a.children)l.kind==="tableCell"&&t(l.children);}},r=e.root.kind==="body"?e.root:e.root.children.find(o=>o.kind==="body")??e.root;return r.kind==="textValue"||t(r.children),n}function gy(e,n){let t=R(e,n);if(!t)return null;let r=new Set(Rr(t)),o=Gv(e),i=o.findIndex(a=>r.has(a));if(i===-1)return o.find(a=>!r.has(a))??null;for(let a=i-1;a>=0;a-=1){let l=o[a];if(!r.has(l))return l}for(let a=i;a<o.length;a+=1){let l=o[a];if(!r.has(l))return l}return null}function py(e,n){let t=false,r=o=>{if(!(t||o.kind==="textValue"||o.id===n)){if(o.kind==="paragraph"){t=true;return}for(let i of o.children)r(i);}};return r(e.root),t}function gc(e,n,t){return e.kind==="textValue"?0:e.children.filter(r=>r.kind===n&&r.id!==t).length}function xy(e,n){if(typeof n!="string"||n.length===0)return "unknown-block";let t=R(e,n);if(!t)return "unknown-block";if(t.kind==="textValue"||!Kv.has(t.kind))return "not-a-block";let r=Ce(e,n);if(!r)return "not-a-block";if(t.kind==="paragraph"){if(Vn(ye(t),"sectPr"))return "carries-section-mark";if(r.kind==="tableCell"&&gc(r,"paragraph",n)===0)return "block-required"}return t.kind==="tableRow"&&gc(r,"tableRow",n)===0?"block-required":(t.kind==="table"&&r.kind==="tableCell"&&gc(r,"paragraph",n)===0,py(e,n)?null:"block-required")}function Wi(e,n,t,r,o){let i=Q(n),a=i.filter(u=>u.start<r&&u.end>t);if(a.length>0)return je(e,a[0].runId);if(t!==r)return je(e,n.id);let l=i.find(u=>u.start===t),s=[...i].reverse().find(u=>u.end===t),d=l?je(e,l.runId):null,c=s?je(e,s.runId):null;if(d&&ki(d))return d;if(c&&ki(c))return c;if(d&&ln(d))return d;if(c&&ln(c))return c;if(o!=="right"&&s&&s.removeNodeIds===void 0&&c?.id===d?.id&&!Ad(n,s,l))return c??je(e,n.id);if(l)return d??je(e,n.id);if(c){let u=Ct(e,c.id);return u[u.length-1]??null}return je(e,n.id)}function $v(e,n,t,r,o){let i=Q(n),a=new Set(i.filter(s=>s.start<r&&s.end>t).map(s=>s.runId));if(a.size===0&&t===r){let s=i.find(f=>f.start===t),d=[...i].reverse().find(f=>f.end===t),u=o!=="right"&&d!==void 0&&d.removeNodeIds===void 0&&je(e,d.runId)?.id===(s?je(e,s.runId)?.id:void 0)&&!Ad(n,d,s)?d:s;u&&a.add(u.runId);}for(let s of a){if(Te(e,s))return "bound";if(ve(e,s).content)return "locked"}let l=Wi(e,n,t,r,o);if(l){if(st(l)||Ct(e,l.id).some(st))return "bound";if(Fn(e,l).content||ln(l)&&Fn(e,l).wrapper)return "locked"}return null}function Sl(e,n){return e.id===n?true:e.kind==="textValue"?false:e.children.some(t=>Sl(t,n))}function At(e,n,t,r,o){return $v(e,n,t,r,o)}function xc(e,n){if(Te(e,n))return "bound";if(ve(e,n).content)return "locked";let t=je(e,n);if(t){if(st(t)||Ct(e,t.id).some(st))return "bound";if(ln(t)&&Fn(e,t).wrapper)return "locked"}return null}function hy(e,n){if(n.kind==="textValue")return null;if(Te(e,n.id))return "bound";if(ve(e,n.id).content)return "locked";let t=r=>{if(r.kind==="textValue")return null;if(we(r)){if(st(r))return "bound";let o=io(r);if(o.content||o.wrapper)return "locked"}for(let o of r.children){let i=t(o);if(i)return i}return null};return t(n)}function yy(e,n,t){if(typeof n!="string"||n.length===0)return "unknown-control";let r=qn(e,n);if(!r)return "unknown-control";if(qg(r)||lo(r)==="repeatingSection")return "unsupported";if(st(r)||Ct(e,r.id).some(st))return "bound";if(Fn(e,r).content||ln(r)&&Fn(e,r).wrapper)return "locked";if(typeof t!="string"||!$(t))return "invalidArgs";switch(lo(r)){case "dropdown":return bi(r).some(a=>a.value===t)?null:"invalidArgs";case "combo":return null;case "checkbox":return so(t)===null?"typeMismatch":null;case "date":return ll(t,void 0)===null?"invalidArgs":null;case "picture":return "typeMismatch";case "text":case "richText":case "other":return null;default:return "unsupported"}}function Oy(e,n){if(typeof n!="string"||n.length===0)return "unknown-control";let t=qn(e,n);return t?Fn(e,t).wrapper?"locked":null:"unknown-control"}var wy=["richText","plainText","dropDownList","comboBox","date"],zv=4096,Xv={date:"Click here to enter a date.",dropDownList:"Choose an item.",comboBox:"Choose an item."},qv="Click here to enter text.";function Oc(e){return Xv[e]??qv}function Hi(e,n){let t=R(e,n);if(!t||t.kind==="textValue")return [];let r=[],o=Ce(e,n);for(;o;)o.kind==="contentControl"&&r.push(o),o=Ce(e,o.id);return r.reverse(),t.kind==="contentControl"&&r.push(t),r}function Nc(e,n){return Fd(Hi(e,n).map(t=>Wn(t).lock))}var tr=(e,n)=>({kind:"nodes",targets:[{nodeId:e,range:{start:n,end:n},writes:true}]}),Ny=(e,n)=>({kind:"nodes",targets:[{nodeId:e,range:{start:n,end:n}}]}),Al=(e,n,t)=>({kind:"nodes",targets:[{nodeId:e,range:{start:n,end:t}}]}),Ee=e=>({kind:"nodes",targets:[{nodeId:e}]}),ky=e=>({kind:"nodes",targets:[{nodeId:e,structural:true}]}),hc=e=>({kind:"nodes",targets:Ey(e).map(n=>({nodeId:n}))});function Ey(e){return Array.isArray(e)?e:[]}var yc=e=>Ey(e).map(n=>({nodeId:n.paragraphId,structural:true})),Ry={insertText:e=>e.inside===void 0?tr(e.paragraphId,e.offset):{kind:"control",controlId:e.inside,intent:"value",at:{paragraphId:e.paragraphId,offset:e.offset}},deleteText:e=>Al(e.paragraphId,e.start,e.end),insertTab:e=>tr(e.paragraphId,e.offset),insertHardBreak:e=>tr(e.paragraphId,e.offset),insertPageBreak:e=>tr(e.paragraphId,e.offset),insertPageField:e=>tr(e.paragraphId,e.offset),insertCommentMarker:e=>Ny(e.paragraphId,e.offset),insertNote:e=>tr(e.paragraphId,e.offset),setRunProperties:e=>Al(e.paragraphId,e.start,e.end),insertHyperlink:e=>Al(e.paragraphId,e.start,e.end),insertContentControl:e=>Al(e.paragraphId,e.start,e.end),insertInlineContentControl:e=>tr(e.paragraphId,e.offset),splitParagraph:e=>Ny(e.paragraphId,e.offset),splitParagraphMany:e=>({kind:"nodes",targets:e.offsets.map(n=>({nodeId:e.paragraphId,range:{start:n,end:n}}))}),joinParagraphs:e=>({kind:"nodes",targets:[{nodeId:e.firstId,structural:true},{nodeId:e.secondId,structural:true}]}),setParagraphProperties:e=>Ee(e.paragraphId),setParagraphMarkProperties:e=>Ee(e.paragraphId),setParagraphMarkRevision:e=>Ee(e.paragraphId),proposeParagraphMerge:e=>Ee(e.paragraphId),setListLevel:e=>Ee(e.paragraphId),setListNumbering:e=>Ee(e.paragraphId),setParagraphTabStops:e=>Ee(e.paragraphId),setSectionMark:e=>Ee(e.paragraphId),deleteBlock:e=>({kind:"nodes",targets:[{nodeId:e.blockId,removes:true}]}),setHyperlinkTarget:e=>Ee(e.linkId),removeHyperlink:e=>({kind:"nodes",targets:[{nodeId:e.linkId,structural:true}]}),setMathEquation:e=>Ee(e.equationId),removeMathEquation:e=>({kind:"nodes",targets:[{nodeId:e.equationId,structural:true}]}),acceptRevision:e=>({kind:"revisions",action:"accept",revision:e.revision,...e.localName===void 0?{}:{localName:e.localName}}),rejectRevision:e=>({kind:"revisions",action:"reject",revision:e.revision,...e.localName===void 0?{}:{localName:e.localName}}),acceptAllRevisions:e=>({kind:"revisions",action:"accept",...e.scopeRootId===void 0?{}:{scopeRootId:e.scopeRootId}}),rejectAllRevisions:e=>({kind:"revisions",action:"reject",...e.scopeRootId===void 0?{}:{scopeRootId:e.scopeRootId}}),setContentControlValue:e=>({kind:"control",controlId:e.controlId,intent:"value",replacesContent:true}),setContentControlProperties:e=>({kind:"control",controlId:e.controlId,intent:"metadata"}),removeContentControl:e=>({kind:"control",controlId:e.controlId,intent:"removal",replacesContent:e.keepContent!==true}),addRepeatingSectionItem:e=>({kind:"control",controlId:e.controlId,intent:"value"}),removeRepeatingSectionItem:e=>({kind:"control",controlId:e.controlId,intent:"value",replacesContent:true}),insertTable:e=>({kind:"nodes",targets:[{nodeId:e.beforeParagraphId}]}),insertTableRow:e=>ky(e.tableId),deleteTableRow:e=>({kind:"nodes",targets:[{nodeId:e.tableId,structural:true},{nodeId:e.rowId,removes:true}]}),insertTableColumn:e=>ky(e.tableId),deleteTableColumn:e=>({kind:"nodes",targets:[{nodeId:e.tableId,structural:true},{nodeId:e.tableId,removes:true}]}),setTableColumnWidths:e=>Ee(e.tableId),setTableRightEdgeWidth:e=>Ee(e.tableId),setTableRowHeight:e=>Ee(e.rowId),setTableCellBorders:e=>hc(e.cellIds),setTableCellFill:e=>hc(e.cellIds),setTableCellVerticalAlignment:e=>hc(e.cellIds),insertDrawing:e=>tr(e.paragraphId,e.offset),replaceDrawingResource:e=>Ee(e.drawingNodeId),deleteDrawing:e=>({kind:"nodes",targets:[{nodeId:e.drawingNodeId,removes:true}]}),resizeDrawing:e=>Ee(e.drawingNodeId),cropDrawing:e=>Ee(e.drawingNodeId),positionDrawing:e=>Ee(e.drawingNodeId),setDrawingWrap:e=>Ee(e.drawingNodeId),setDrawingMetadata:e=>Ee(e.drawingNodeId),setDrawingLocks:e=>Ee(e.drawingNodeId),transformDrawing:e=>Ee(e.drawingNodeId),insertToc:e=>({kind:"nodes",targets:[{nodeId:e.beforeParagraphId},...yc(e.bookmarksToCreate)]}),replaceTocResult:e=>({kind:"nodes",targets:[{nodeId:e.tocId,structural:true},...yc(e.bookmarksToCreate)]}),rewriteTocPageNumbers:e=>({kind:"nodes",targets:yc(e.updates)}),replaceStoryBlocks:e=>({kind:"nodes",targets:[{nodeId:e.storyRootId,structural:true}]}),setSectionProperties:()=>({kind:"documentProperties"}),setSectionFurnitureOptions:()=>({kind:"documentProperties"}),setNoteProperties:()=>({kind:"documentProperties"}),deleteNote:()=>({kind:"part"}),convertNote:()=>({kind:"part"}),convertAllNotes:()=>({kind:"part"}),createHeaderFooter:()=>({kind:"none"}),deleteHeaderFooter:()=>({kind:"none"}),linkToPrevious:()=>({kind:"none"}),unlinkFromPrevious:()=>({kind:"none"})};new Set(Object.keys(Ry));function kc(e){let n=Ry[e.op];return n?n(e):{kind:"part"}}var Yv={touches:[],unprotected:[]};function Qn(e){return e.map(n=>Wn(n).lock)}function bc(e,n){if(n.kind==="none")return Yv;if(n.kind==="documentProperties")return {touches:[],unprotected:[e.root.id]};if(n.kind==="part")return {touches:Se(e.root).map(i=>({control:i.node,locks:Qn([...i.ancestors,i.node]),removed:false,discarded:false})),unprotected:[e.root.id]};if(n.kind==="control"){let o=Hi(e,n.controlId),i=o[o.length-1];if(!i||i.id!==n.controlId||i.kind!=="contentControl")return {touches:[],unprotected:[e.root.id]};let a=n.intent==="value"&&n.at!==void 0?Jv(o,Qv(e,n.at,i)):o;return {touches:[...a.map((l,s)=>({control:l,locks:Qn(a.slice(0,s+1)),removed:n.intent==="removal"&&l.id===i.id,discarded:false})),...Zv(i,n.replacesContent===true)],unprotected:n.intent==="value"||o.length>1?[]:[n.controlId]}}if(n.kind==="revisions")return nS(e,n.action,n.revision,n.localName,n.scopeRootId);let t=[],r=[];for(let o of n.targets){let a=Hi(e,o.nodeId).filter(m=>m.id!==o.nodeId);for(let m=0;m<a.length;m+=1)t.push({control:a[m],locks:Qn(a.slice(0,m+1)),removed:false,discarded:false});let l=R(e,o.nodeId);if(!l||l.kind==="textValue"){a.length===0&&r.push(o.nodeId);continue}let s=Qn(a),d=Se(l),c=null,u=m=>l.kind!=="paragraph"?null:(c??=Pe(l),c.spanOf(m)),f=false;for(let m of d){let g=u(m.node);o.range!==void 0&&eS(g,o.range,o.writes===true)&&(f=true),(o.removes===true||o.structural===true||o.range!==void 0&&Iy(g,o.range,o.writes===true))&&t.push({control:m.node,locks:[...s,...Qn([...m.ancestors,m.node])],removed:o.removes===true,discarded:false});}a.length===0&&!f&&r.push(o.nodeId);}return {touches:t,unprotected:r}}function Zv(e,n){return n?Se(e).map(t=>({control:t.node,locks:Qn([...t.ancestors,t.node]),removed:false,discarded:true})):[]}function Qv(e,n,t){let r=R(e,n.paragraphId);return !r||r.kind!=="paragraph"?[]:Hi(e,ex(r,n.offset,t))}function Jv(e,n){if(n.length===0)return e;let t=[...n],r=new Set(n.map(o=>o.id));for(let o of e)r.has(o.id)||(r.add(o.id),t.push(o));return t}function Iy(e,n,t){return e===null?false:n.end<=n.start?t?n.start>=e.start&&n.start<e.end:n.start>e.start&&n.start<e.end:n.start<e.end&&n.end>e.start}function eS(e,n,t){return e===null?false:n.end<=n.start?Iy(e,n,t):n.start>=e.start&&n.end<=e.end}function nS(e,n,t,r,o){let i=[],a=[],l=o===void 0?e.root:br(e,o);if(l===null)return {touches:i,unprotected:[e.root.id]};let s=0,d=(f,m)=>{if(!(f.kind==="textValue"||s>tS)){if(oS(f,t,r)){s+=1,m.length===0&&a.push(f.id);for(let g=0;g<m.length;g+=1)i.push({control:m[g],locks:Qn(m.slice(0,g+1)),removed:false,discarded:false});if(iS(f,n)){for(let g of Se(f))i.push({control:g.node,locks:[...Qn(m),...Qn([...g.ancestors,g.node])],removed:true,discarded:false});return}}for(let g of f.children)d(g,g.kind==="contentControl"?[...m,g]:m);}};d(l,[]);let c=new Set(Bh(e,n,t,{...r===void 0?{}:{localName:r},...o===void 0?{}:{scopeRootId:o}}).map(f=>f.id)),u=(f,m)=>{if(!(f.kind==="textValue"||c.size===0)){if(c.delete(f.id)){for(let g of Se(f))i.push({control:g.node,locks:[...Qn(m),...Qn([...g.ancestors,g.node])],removed:true,discarded:false});return}for(let g of f.children)u(g,g.kind==="contentControl"?[...m,g]:m);}};return u(l,[]),{touches:i,unprotected:a}}var tS=5e4,rS=new Set(["ins","del","moveFrom","moveTo","rPrChange","pPrChange","tblPrChange","trPrChange","tcPrChange","sectPrChange","tblGridChange","cellIns","cellDel","cellMerge"]);function oS(e,n,t){if(e.kind==="textValue"||e.namespaceUri!==O||!rS.has(e.localName)||t!==void 0&&e.localName!==t)return false;if(!n)return true;let r=o=>e.attributes.find(i=>i.localName===o&&i.namespaceUri===O)?.value;return !(r("id")!==n.id||r("author")!==n.author||n.date!==void 0&&r("date")!==n.date)}function iS(e,n){return e.kind==="textValue"?false:e.localName==="ins"||e.localName==="moveTo"?n==="reject":e.localName==="del"||e.localName==="moveFrom"?n==="accept":false}function Ty(e,n){let t=kc(n),r=t.kind==="control"&&t.intent!=="value";for(let o of bc(e,t).touches){if(r&&!o.discarded)continue;let i=Fd(o.locks);if(fo(i)||(o.removed||o.discarded)&&xl(i))return "locked"}return null}function Cy(e,n){let t=kc(n),r=t.kind==="control"&&t.intent!=="value";if(t.kind==="part"||t.kind==="documentProperties")return null;for(let o of bc(e,t).touches)if(!(r&&!o.discarded)&&!o.removed&&Wn(o.control).dataBinding)return "bound";return null}function aS(e){if(!e)return false;for(let n of e.root.children){if(n.kind==="textValue"||n.namespaceUri!==O||n.localName!=="documentProtection")continue;let t=r=>n.attributes.find(o=>o.localName===r&&o.namespaceUri===O)?.value;return t("edit")!=="forms"?false:vy(t("enforcement"))}return false}function vy(e){return e===void 0?true:e!=="0"&&e!=="false"&&e!=="off"}function Sy(e,n,t){if(!aS(n))return null;let r=kc(t);if(r.kind==="none")return null;for(let o of bc(e,r).unprotected)if(!(o!==e.root.id&&!lS(e,o)))return "locked";return null}function lS(e,n){let t=false,r=true,o=i=>{if(i.kind==="textValue")return false;if(i.id===n&&(t=true),t&&i.namespaceUri===O&&i.localName==="sectPr"&&i.id!==n){let a=i.children.find(l=>l.kind!=="textValue"&&l.namespaceUri===O&&l.localName==="formProt");return a&&a.kind!=="textValue"&&(r=vy(a.attributes.find(l=>l.localName==="val"&&l.namespaceUri===O)?.value)),true}for(let a of i.children)if(o(a))return true;return false};return o(e.root),r}function Mt(e,n,t={}){return {id:e(),kind:t.kind??"generic",namespaceUri:O,localName:n,prefix:"w",namespaceBindings:[],attributes:(t.attributes??[]).map(([r,o])=>({kind:"generic",namespaceUri:O,localName:r,prefix:"w",value:o})),children:t.children??[]}}function Pc(e,n,t){let r={id:e(),kind:"textValue",value:n},o={id:e(),kind:"text",namespaceUri:O,localName:"t",prefix:"w",namespaceBindings:[],attributes:[],children:[r]};return {id:e(),kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:t?[t,o]:[o]}}function sS(e,n){if(!e||e.kind==="textValue")return;let t=(r,o)=>{if(!(r.kind==="textValue"||o>8)){if(r.kind==="run"){let i=Yn(r);return i?Ml(i,n):void 0}for(let i of r.children){let a=t(i,o+1);if(a)return a}}};return t(e,0)}function Ml(e,n){return e.kind==="textValue"?{id:n(),kind:"textValue",value:e.value}:{...e,id:n(),children:e.children.map(t=>Ml(t,n))}}function by(e,n,t){let r=e.attributes.findIndex(a=>a.localName===n&&a.namespaceUri!==""),o={...r>=0?e.attributes[r]:{kind:"generic",namespaceUri:e.namespaceUri,localName:n,prefix:e.prefix},value:t},i=r>=0?e.attributes.map((a,l)=>l===r?o:a):[...e.attributes,o];return {...e,attributes:i}}var dS=/^(\d{4})-(\d{2})-(\d{2})(?:T[\d:.]{1,15}Z?)?$/;function cS(e){let n=dS.exec(e);if(!n)return null;let t=Number(n[1]),r=Number(n[2]),o=Number(n[3]);if(r<1||r>12||o<1||o>31)return null;let i=new Date(Date.UTC(t,r-1,o));return i.getUTCFullYear()!==t||i.getUTCMonth()!==r-1||i.getUTCDate()!==o?null:{year:t,month:r,day:o}}var Py=["January","February","March","April","May","June","July","August","September","October","November","December"];function uS(e,n){let t=`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}`;if(!n||n.length===0||n.length>64)return t;let r="",o=0;for(;o<n.length;){let i=n[o];if(i!=="y"&&i!=="M"&&i!=="d"){r+=i,o+=1;continue}let a=0;for(;o+a<n.length&&n[o+a]===i;)a+=1;i==="y"?r+=a<=2?String(e.year%100).padStart(2,"0"):String(e.year):i==="M"?r+=a>=4?Py[e.month-1]:a===3?Py[e.month-1].slice(0,3):String(e.month).padStart(Math.min(a,2),"0"):r+=String(e.day).padStart(Math.min(a,2),"0"),o+=a;}return r}function fS(e,n){if(typeof n!="string")return n;switch(e.type){case "dropDownList":return {kind:"listItem",value:n};case "checkbox":{let t=so(n);return t===null?"typeMismatch":{kind:"checkbox",checked:t}}case "date":return {kind:"date",iso:n};default:return {kind:"text",text:n}}}function mS(e,n){switch(n.kind){case "text":return e.type!=="richText"&&e.type!=="plainText"&&e.type!=="comboBox"&&e.type!=="untyped"?"typeMismatch":typeof n.text!="string"||!$(n.text)?"invalidArgs":n.text.length===0?{text:Oc(e.type),showingPlaceholder:true}:{text:n.text,showingPlaceholder:false,...e.type==="comboBox"?{lastValue:n.text}:{}};case "listItem":{if(e.type!=="dropDownList"&&e.type!=="comboBox")return "typeMismatch";let t=e.listItems.find(r=>r.value===n.value);return t?{text:t.displayText,showingPlaceholder:false,lastValue:t.value}:"invalidArgs"}case "checkbox":{if(e.type!=="checkbox"||!e.checkbox)return "typeMismatch";if(typeof n.checked!="boolean")return "invalidArgs";let t=n.checked?e.checkbox.checkedState:e.checkbox.uncheckedState,r=pS(t?.value,n.checked);return r===null?"invalidArgs":{text:r,showingPlaceholder:false,checked:n.checked}}case "date":{if(e.type!=="date")return "typeMismatch";let t=typeof n.iso=="string"?cS(n.iso):null;if(!t)return "invalidArgs";let r=`${String(t.year).padStart(4,"0")}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`;return {text:uS(t,e.date?.dateFormat),showingPlaceholder:false,fullDate:`${r}T00:00:00Z`}}default:return "invalidArgs"}}function pS(e,n){let t=e??(n?"2612":"2610");if(!/^[0-9A-Fa-f]{1,6}$/.test(t))return null;let r=Number.parseInt(t,16);return !Number.isInteger(r)||r<0||r>1114111||r>=55296&&r<=57343?null:String.fromCodePoint(r)}function ji(e,n,t){let r=e??Mt(t,"sdtPr",{kind:"contentControlProperties"}),o=[...r.children],i=(l,s)=>{let d=o.findIndex(u=>u.kind!=="textValue"&&u.namespaceUri===O&&u.localName===l);if(s===null){d>=0&&o.splice(d,1);return}let c=Mt(t,l,{attributes:[["val",s]]});d>=0?o[d]=c:o.push(c);},a=(l,s)=>{let d=o.findIndex(c=>c.kind!=="textValue"&&c.namespaceUri===O&&c.localName===l);if(!s){d>=0&&o.splice(d,1);return}d<0&&o.push(Mt(t,l));};return n.tag!==void 0&&i("tag",n.tag),n.alias!==void 0&&i("alias",n.alias),n.lock!==void 0&&i("lock",n.lock==="unlocked"?null:n.lock),n.id!==void 0&&i("id",String(n.id)),n.showingPlaceholder!==void 0&&a("showingPlcHdr",n.showingPlaceholder),n.temporary===false&&a("temporary",false),n.lastValue!==void 0&&(o=o.map(l=>l.kind==="textValue"||l.namespaceUri!==O||l.localName!=="dropDownList"&&l.localName!=="comboBox"?l:by(l,"lastValue",n.lastValue))),n.fullDate!==void 0&&(o=o.map(l=>l.kind!=="textValue"&&l.namespaceUri===O&&l.localName==="date"?by(l,"fullDate",n.fullDate):l)),n.checked!==void 0&&(o=o.map(l=>{if(l.kind==="textValue"||l.namespaceUri!==j||l.localName!=="checkbox")return l;let s=l.children.map(d=>d.kind==="textValue"||d.namespaceUri!==j||d.localName!=="checked"?d:{...d,attributes:d.attributes.map(c=>c.localName==="val"&&c.namespaceUri===j?{...c,value:n.checked?"1":"0"}:c)});return {...l,children:s}})),{...r,children:hl(o)}}function Ay(e,n,t){let r=sS(e,t),o=Pc(t,n,r),i=e?.children.find(s=>s.kind==="paragraph");if(!i||i.kind==="textValue")return [o];let a=i.children.find(s=>s.kind!=="textValue"&&s.localName==="pPr");return [{...i,children:a?[a,o]:[o]}]}function Oo(e,n){return {dirty:[e],created:[],deleted:[],dependencyKeys:W,impact:n}}function wc(e,n){let t=R(e,n);return t?t.kind!=="contentControl"?"not-a-content-control":{control:t,lock:Nc(e,n)}:"unknown-content-control"}function My(e,n,t){let r=wc(e,n.controlId);if(typeof r=="string")return {ok:false,reason:r};let{control:o,lock:i}=r,a=Wn(o);if(a.dataBinding)return {ok:false,reason:"bound"};if(fo(i))return {ok:false,reason:"locked"};let l=fS(a,n.value);if(typeof l=="string")return {ok:false,reason:l};let s=mS(a,l);if(typeof s=="string")return {ok:false,reason:s};let d=S(e),c=gl(o),u=uo(o),f=ji(c,{showingPlaceholder:s.showingPlaceholder,...s.lastValue===void 0?{}:{lastValue:s.lastValue},...s.fullDate===void 0?{}:{fullDate:s.fullDate},...s.checked===void 0?{}:{checked:s.checked}},d),m={...u??Mt(d,"sdtContent",{kind:"contentControlContent"}),children:Ay(u,s.text,d)},g={...o,children:[f,...o.children.filter(x=>x.kind!=="contentControlProperties"&&x.kind!=="contentControlContent"),m]},p=V(e,o.id,g,t);return p.ok?a.temporary?Ec(p.part,{controlId:o.id,keepContent:true},t):{ok:true,part:p.part,effect:Oo(o.id,"flow-structural")}:{ok:false,reason:"tree-invariant",detail:JSON.stringify(p.issues)}}function _y(e,n,t){let r=wc(e,n.controlId);if(typeof r=="string")return {ok:false,reason:r};let{control:o,lock:i}=r;if(fo(i)||xl(i))return {ok:false,reason:"locked"};let a=S(e),s=[ji(gl(o),{...n.tag===void 0?{}:{tag:n.tag},...n.alias===void 0?{}:{alias:n.alias},...n.lock===void 0?{}:{lock:n.lock}},a),...o.children.filter(d=>d.kind!=="contentControlProperties")];return T(V(e,o.id,{...o,children:s},t),Oo(o.id,"paragraph-local"))}function Ec(e,n,t){let r=wc(e,n.controlId);if(typeof r=="string")return {ok:false,reason:r};let{control:o,lock:i}=r;if(xl(i))return {ok:false,reason:"locked"};let a=Z(e,o.id);if(!a)return {ok:false,reason:"tree-invariant"};let l=uo(o),s=n.keepContent&&l?[...l.children]:[],d=a.children.flatMap(c=>c.id===o.id?s:[c]);return T(L(e,a.id,d,t),Oo(a.id,"flow-structural"))}function Dy(e,n,t){let r=Hi(e,n);for(let a=r.length-1;a>=0;a-=1){let l=r[a];if(Wn(l).showingPlaceholder)return {control:l,offset:0}}let o=R(e,n);if(!o||o.kind!=="paragraph")return null;let i=Pe(o);for(let a of Se(o)){if(!Wn(a.node).showingPlaceholder)continue;let l=i.spanOf(a.node);if(l&&t>=l.start&&t<=l.end)return {control:a.node,offset:l.start}}return null}function Uy(e,n,t){let r=R(e,n);if(!r||r.kind!=="contentControl")return null;let o=S(e),i=uo(r),a=ji(gl(r),{showingPlaceholder:false},o),l={...i??Mt(o,"sdtContent",{kind:"contentControlContent"}),children:Ay(i,"",o)},s={...r,children:[a,...r.children.filter(c=>c.kind!=="contentControlProperties"&&c.kind!=="contentControlContent"),l]},d=V(e,r.id,s,t);return d.ok?d.part:null}function Rc(e){return e==null?true:typeof e!="string"||e.length>zv?false:$(e)}function gS(e,n){let t=[],r=n;for(;r&&(t.push(r),r.id!==e.root.id);)r=Ce(e,r.id);return t.reverse()}function Ki(e,n){let t=new Map([["xml",X],["xmlns",He]]);for(let r of gS(e,n))for(let o of r.namespaceBindings)t.set(o.prefix,o.namespaceUri);return t}function xS(e){if(!e.has("w"))return "w";for(let n=97;n<=122;n+=1){let t=`w${String.fromCharCode(n)}`;if(!e.has(t))return t}for(let n=2;;n+=1){let t=`wx${n}`;if(!e.has(t))return t}}function Ve(e,n){let t=Ki(e,n),r=t.get("")===O,o=[];for(let[s,d]of t)s!==""&&d===O&&o.push(s);let i,a=null;return o.length>0?i=o.includes("w")?"w":o[0]:(i=xS(new Set(t.keys())),a=Object.freeze({prefix:i,namespaceUri:O})),Object.freeze({elementPrefix:r?void 0:i,attributePrefix:i,rowBinding:a})}function dn(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function rr(e){return dn(e,"gridCol")}function K(e,n){for(let t of e.children)if(dn(t,n))return t}function cn(e,n){for(let t of e.attributes)if(t.namespaceUri===O&&t.localName===n)return t.value}function Ly(e,n,t=O){return e.localName===n&&e.namespaceUri===t}var hS=["tblStyle","tblpPr","tblOverlap","bidiVisual","tblStyleRowBandSize","tblStyleColBandSize","tblW","jc","tblCellSpacing","tblInd","tblBorders","shd","tblLayout","tblCellMar","tblLook","tblCaption","tblDescription","tblPrChange"],Ic=["cnfStyle","divId","gridBefore","gridAfter","wBefore","wAfter","cantSplit","trHeight","tblHeader","tblCellSpacing","jc","hidden","ins","del","trPrChange"],_l=["cnfStyle","tcW","gridSpan","hMerge","vMerge","tcBorders","shd","noWrap","tcMar","textDirection","tcFitText","vAlign","hideMark","headers","cellIns","cellDel","cellMerge","tcPrChange"];function Gi(e,n){if(n.kind==="textValue"||n.namespaceUri!==O)return e.length;let t=e.indexOf(n.localName);return t===-1?e.length:t}function yS(e,n){return Gi(e,n)!==e.length}function OS(e,n){let t=[],r=[];e.forEach((a,l)=>{yS(n,a)&&(t.push(l),r.push(a));});let o=[...e];if(r.length<2)return o;let i=[...r].sort((a,l)=>Gi(n,a)-Gi(n,l));return t.forEach((a,l)=>{o[a]=i[l];}),o}function NS(e,n){if(e.length!==n.length)return false;for(let t=0;t<e.length;t+=1)if(e[t]!==n[t])return false;return true}function kS(e){return {ok:false,reason:e}}function No(e){return {ok:false,reason:e}}function Tc(e,n,t,r,o=O){if(n!==null&&!Ly(n,r,o))return kS("wrong-expanded-name");let i=false,a=[];for(let s of e.children){if(dn(s,r)&&s.namespaceUri===o){if(n===null)continue;i?a.push(s):(a.push(n),i=true);continue}a.push(s);}if(n!==null&&!i){let s=Gi(t,n),d=a.length;for(let c=0;c<a.length;c+=1){let u=Gi(t,a[c]);if(u!==t.length&&u>s){d=c;break}}a.splice(d,0,n);}let l=OS(a,t);return NS(e.children,l)?{ok:true,container:e}:{ok:true,container:Object.freeze({...e,children:l})}}function Cc(e,n){return Tc(e,n,hS,n.localName)}function vc(e,n){return Tc(e,n,Ic,n.localName)}function Ir(e,n){return Tc(e,n,_l,n.localName)}function bS(e,n){let t=[];for(let r of e.children)r.kind!=="textValue"&&r.id===n&&rr(r)&&t.push(r);return t}function $i(e,n,t){if(t!==null&&!rr(t))return No("wrong-expanded-name");let r=bS(e,n);if(e.children.some(s=>s.kind!=="textValue"&&s.id===n&&!rr(s)))return No("extension-collision");if(r.length>1)return No("duplicate-grid-column");if(r.length===0)return No("unknown-grid-column");let i=r[0];if(t===null){let s=e.children.filter(d=>d!==i);return s.length===e.children.length?{ok:true,grid:e}:{ok:true,grid:Object.freeze({...e,children:s})}}if(t===i)return e.children.some(d=>d!==i&&d.id===t.id)?No("duplicate-grid-column"):{ok:true,grid:e};if(e.children.some(s=>s!==i&&s.id===t.id))return No("duplicate-grid-column");let l=e.children.map(s=>s===i?t:s);return {ok:true,grid:Object.freeze({...e,children:l})}}function Dl(e,n){let t=false;for(let r of e.children)if(dn(r,n)){if(t)return true;t=true;}return false}function PS(e){let n=e&&K(e,"gridSpan"),t=n&&cn(n,"val");if(!t||!/^\d{1,7}$/.test(t))return 1;let r=Number(t);return Number.isInteger(r)&&r>1?Math.min(r,1024):1}function wS(e){return e!==void 0&&K(e,"vMerge")!==void 0}function ES(e){return e!==void 0&&K(e,"hMerge")!==void 0}function RS(e){let n=K(e,"tcPr");return PS(n)>1||wS(n)||ES(n)}function IS(e){let n=0;for(let t of e.children)rr(t)&&(n+=1);return n}function TS(e,n){let t=[];for(let r of e.children)if(rr(r)&&(t.push(r),t.length>=n))break;return t}function CS(e){let n=new Set;for(let t of e.children)if(rr(t)){if(n.has(t.id))return true;n.add(t.id);}return false}function vS(e){let n=0;for(let t of e.children)t.kind==="tableRow"&&(n+=1);return n}function SS(e){let n=0;for(let t of e.children)t.kind==="tableCell"&&(n+=1);return n}function ft(e,n){return n===void 0?{ok:false,reason:e}:{ok:false,reason:e,detail:n}}function AS(e,n,t){let r=[e],o=0,i;for(;r.length>0;){if(o>=t)return {ok:false,reason:"resource-limit",detail:"traversal"};let a=r.pop();if(o+=1,a.id===n){if(i!==void 0)return {ok:false,reason:"duplicate-node-id",detail:n};i=a;}if(a.kind==="textValue")continue;let l=a.children.length,s=t-o-r.length;if(l>s)return {ok:false,reason:"resource-limit",detail:"traversal"};for(let d=l-1;d>=0;d-=1)r.push(a.children[d]);}return i===void 0?{ok:false,reason:"unknown-table",detail:n}:{ok:true,node:i}}function nn(e,n,t=ze){let r=Xe(t),o=AS(e,n,r.maxTraversalNodes);if(!o.ok)return ft(o.reason,o.detail);let i=o.node;if(i.kind!=="table")return ft("unknown-table",n);let a=i;if(Dl(a,"tblPr"))return ft("duplicate-property-container","tblPr");if(Dl(a,"tblGrid"))return ft("duplicate-property-container","tblGrid");let l=K(a,"tblGrid"),s=l?.kind==="tableGrid"?l:void 0;if(l!==void 0&&s===void 0)return ft("duplicate-property-container","tblGrid");if(s&&CS(s))return ft("duplicate-node-id","gridCol");if(vS(a)>r.maxRows)return ft("resource-limit","maxRows");let c=0;for(let p of a.children){if(p.kind!=="tableRow")continue;if(Dl(p,"trPr"))return ft("duplicate-property-container","trPr");let x=SS(p);x>c&&(c=x);for(let y of p.children)if(y.kind==="tableCell"&&Dl(y,"tcPr"))return ft("duplicate-property-container","tcPr")}let u=s?IS(s):0;if(u>r.maxColumns||c>r.maxColumns)return ft("resource-limit","maxColumns");let f=s?TS(s,u):[],m=[],g=false;for(let p of a.children){if(p.kind!=="tableRow")continue;let x=[];for(let y of p.children)y.kind==="tableCell"&&(RS(y)&&(g=true),x.push(y));m.push({row:p,cells:x});}return {ok:true,topology:{table:a,grid:s,gridColumns:f,rows:m,hasMerge:g}}}function Sc(e,n){return e.length!==n.length?false:e.every((t,r)=>MS(t,n[r]))}function MS(e,n){if(e.kind!==n.kind)return false;if(e.kind==="textValue"||n.kind==="textValue")return e.kind==="textValue"&&n.kind==="textValue"&&e.value===n.value;if(e.namespaceUri!==n.namespaceUri||e.localName!==n.localName||e.attributes.length!==n.attributes.length)return false;for(let t=0;t<e.attributes.length;t+=1){let r=e.attributes[t],o=n.attributes[t];if(r.namespaceUri!==o.namespaceUri||r.localName!==o.localName||r.prefix!==o.prefix||r.value!==o.value)return false}return Sc(e.children,n.children)}function zi(e){for(let n=e.length-1;n>=0;n-=1){let t=e[n];if(t.kind==="textValue"||t.kind!=="revisionInsert")continue;return t.attributes.find(o=>o.namespaceUri===O&&o.localName==="author")?.value??""}return null}function Ul(e){return e.some(n=>n.kind!=="textValue"&&n.kind==="revisionDelete")}function NW(e,n,t,r){if(t<=n)return 0;let o=Pe(e),i=0,a=(l,s)=>{for(let d of l){if(d.kind==="textValue")continue;let c=o.spanOf(d);if(!(!c||c.end<=n||c.start>=t)){if(d.kind==="run"){if(Ul(s)||zi(s)!==r)continue;i+=Math.min(t,c.end)-Math.max(n,c.start);continue}a(d.children,[...s,d]);}}};return a(e.children,[]),i}function Ac(e,n){return {kind:"genericExtension",namespaceUri:O,localName:e,prefix:"w",value:n}}function Kn(e,n,t,r,o){return {id:e,kind:n,namespaceUri:O,localName:t,prefix:"w",namespaceBindings:[],attributes:r,children:o}}function bo(e){let n=-1,t=o=>{if(o.kind!=="textValue"){if(Wy.has(o.localName)&&o.namespaceUri===O)for(let i of o.attributes){if(i.namespaceUri!==O||i.localName!=="id"||!/^\d{1,10}$/.test(i.value))continue;let a=Number(i.value);a<=Mc&&a>n&&(n=a);}for(let i of o.children)t(i);}};t(e.root);let r=n+1;return ()=>{if(r>Mc){let o=_S(e);for(let i=0;i<=Mc;i+=1)if(!o.has(String(i)))return String(i);throw new TypeError("no free revision id")}return String(r++)}}function _S(e){let n=new Set,t=r=>{if(r.kind!=="textValue"){if(Wy.has(r.localName)&&r.namespaceUri===O)for(let o of r.attributes)o.namespaceUri===O&&o.localName==="id"&&n.add(o.value);for(let o of r.children)t(o);}};return t(e.root),n}var Wy=new Set(["ins","del","moveFrom","moveTo","cellIns","cellDel","cellMerge","rPrChange","pPrChange","tblPrChange","tblPrExChange","tcPrChange","trPrChange","sectPrChange","tblGridChange","numberingChange"]),Mc=2147483647;function Uc(e,n){return [Ac("id",e),Ac("author",n.author),...n.date===void 0?[]:[Ac("date",n.date)]]}function _t(e,n,t){let r=e();return Kn(e(),t?"deletedText":"text",t?"delText":"t",[],[{id:r,kind:"textValue",value:n}])}function DS(e,n,t,r){return Kn(e(),"run","r",[],[...n,_t(e,t,r)])}function hn(e){return e.kind!=="textValue"&&e.kind==="runProperties"}function ko(e,n){return n.kind==="textValue"?{id:e(),kind:"textValue",value:n.value}:{...n,id:e(),children:n.children.map(t=>ko(e,t))}}function Lc(e,n){if(e===void 0||n===void 0)return e===n;let t=Date.parse(e),r=Date.parse(n);return Number.isNaN(t)||Number.isNaN(r)?e===n:Math.abs(r-t)<=US}var US=6e4;function LS(e){if(e.kind!=="textValue")return e.attributes.find(n=>n.namespaceUri===O&&n.localName==="date")?.value}function BS(e){return e.kind!=="revisionDelete"?null:e.attributes.find(n=>n.namespaceUri===O&&n.localName==="id")?.value??null}function FS(e){let n=new Set,t=new Set;for(let r of e.segments)if(!(!r.removeNodeIds||r.removeNodeIds.length===0)){n.add(r.node.id);for(let o of r.removeNodeIds)o!==r.node.id&&t.add(o);}return {begin:n,tail:t}}function Bc(e){return le(e).filter(n=>!hn(n))}function VS(e,n){if(e.kind!=="run")return false;let t=Bc(e);return t.length>0&&t.every(r=>n.tail.has(r.id))}function WS(e,n){return e.kind!=="run"?false:Bc(e).some(t=>n.begin.has(t.id))}function Hy(e,n,t,r,o,i){let a=S(e),l=bo(e),s=Pe(n),d={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"text-local"},c={offset:0},u=FS(s),f=false,m=$y(n,s,t,t,o.author,o.date),g=m?{author:o.author,...m.date===void 0?{}:{date:m.date}}:o,p=m?.id??l(),x=b=>Kn(a(),"revisionInsert","ins",Uc(p,g),[DS(a,b,r,false)]),y=(b,h)=>{let P=[];for(let k of b){if(f){P.push(k);continue}if(k.kind!=="textValue"&&k.kind==="paragraphProperties"){P.push(k);continue}let E=s.lengthOf(k),w=c.offset,I=w+E;if(VS(k,u)){P.push(k);continue}let A=k.kind!=="textValue"&&(k.kind==="hyperlink"||k.kind==="revisionInsert"||k.kind==="revisionMoveTo"),U=A&&zi([k])===o.author&&Lc(LS(k),o.date);if(A&&(t>w&&t<I||U&&t>=w&&t<=I)){P.push({...k,children:y(k.children,[...h,k])});continue}if(!f&&t>w&&t<I&&k.kind!=="textValue"&&(k.kind==="revisionDelete"||k.kind==="revisionMoveFrom")){c.offset=I,P.push(k,x([])),f=true;continue}if(!f&&t===w&&k.kind!=="run"){if(m!==null&&k.kind==="revisionDelete"&&BS(k)===m.id){c.offset=I,P.push(k,x([])),f=true;continue}P.push(x([])),f=true,c.offset=I,P.push(k);continue}if(WS(k,u)&&t===I&&t!==w){c.offset=I,P.push(k);continue}if(k.kind==="run"&&t>=w&&t<=I){if(zi([...h,k])===o.author){P.push(HS(a,s,k,t-w,r,false)),f=true,c.offset=I+r.length;continue}let C=le(k).filter(hn).map(rn=>ko(a,rn));if(t===w)P.push(x(C),k);else if(t===I)P.push(k,x(C));else {let[rn,fn]=jy(a,s,k,t-w);P.push(rn,x(C),fn);}f=true,c.offset=I;continue}c.offset=I,P.push(k);}return P},N=_c(a,y(n.children,[]));if(!f){if(t!==c.offset)return {ok:false,reason:"offset-out-of-range",detail:"offset past the paragraph"};N=[...N,x([])];}return T(L(e,n.id,N,i),d)}function jy(e,n,t,r){let o=le(t).filter(hn),i=[],a=[],l=0;for(let s of le(t)){if(hn(s))continue;let d=n.lengthOf(s);if(l+d<=r)i.push(s);else if(l>=r)a.push(s);else if(s.kind==="text"||s.kind==="deletedText"){let c=le(s).find(m=>m.kind==="textValue"),u=c&&c.kind==="textValue"?c.value:"",f=r-l;i.push(_t(e,u.slice(0,f),s.kind==="deletedText")),a.push(_t(e,u.slice(f),s.kind==="deletedText"));}else a.push(s);l+=d;}return [Kn(e(),"run","r",[],[...o.map(s=>ko(e,s)),...i]),Kn(e(),"run","r",[],[...o.map(s=>ko(e,s)),...a])]}function HS(e,n,t,r,o,i){let[a,l]=jy(e,n,t,r),s=[...le(a).filter(c=>!hn(c)),_t(e,o,i),...le(l).filter(c=>!hn(c))],d=le(t).filter(hn).map(c=>ko(e,c));return Kn(e(),"run","r",[],[...d,...Ky(e,s)])}function Ky(e,n){let t=[];for(let r of n){let o=t[t.length-1];if(!(o!==void 0&&o.kind===r.kind&&(r.kind==="text"||r.kind==="deletedText"))){t.push(r);continue}let a=le(o).find(d=>d.kind==="textValue"),l=le(r).find(d=>d.kind==="textValue"),s=(a&&a.kind==="textValue"?a.value:"")+(l&&l.kind==="textValue"?l.value:"");t[t.length-1]=_t(e,s,r.kind==="deletedText");}return t}function le(e){return e.kind==="textValue"?[]:e.children}function Gy(e,n,t,r,o,i){let a=S(e),l=bo(e),s=Pe(n),d=$y(n,s,t,r,o.author,o.date),c=d?.id??l(),u=d?{author:o.author,...d.date===void 0?{}:{date:d.date}}:o,f={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"text-local"},m={offset:0},g=new Set;for(let b of s.segments)if(!(!b.removeNodeIds||b.removeNodeIds.length===0)&&!(b.start<t||b.end>r))for(let h of b.removeNodeIds)g.add(h);let p=b=>b.kind!=="textValue"&&Bc(b).some(h=>g.has(h.id)),x=b=>Kn(a(),"revisionDelete","del",Uc(c,u),b),y=(b,h)=>{let P=[];for(let k of b){let E=s.lengthOf(k),w=m.offset,I=w+E;if(g.has(k.id)&&k.kind!=="textValue"&&Dt(k,"fldSimple")){m.offset=I,P.push({...k,children:_c(a,k.children.map(C=>C.kind==="run"&&!Ul(h)?x([Fy(a,C)]):C))});continue}if((I<=t||w>=r||E===0)&&!p(k)){m.offset=I,P.push(k);continue}if(k.kind!=="textValue"&&(k.kind==="hyperlink"||k.kind==="revisionInsert"||k.kind==="revisionDelete"||k.kind==="revisionMoveFrom"||k.kind==="revisionMoveTo")){let C=y(k.children,[...h,k]);C.length>0&&P.push({...k,children:C});continue}if(k.kind!=="run"){m.offset=I,P.push(k);continue}if(m.offset=I,Ul(h)){P.push(k);continue}let A=zi(h)===o.author,U={from:Math.max(t,w)-w,to:Math.min(r,I)-w},B=GS(a,s,k,U.from,U.to,g);B.before&&P.push(B.before),B.covered&&(A||P.push(x([Fy(a,B.covered)]))),B.after&&P.push(B.after);}return P},N=_c(a,y(n.children,[]));return T(L(e,n.id,N,i),f)}function _c(e,n){let t=[];for(let r of n){let o=t[t.length-1];if(o!==void 0&&o.kind!=="textValue"&&r.kind!=="textValue"&&o.kind===r.kind&&(r.kind==="revisionInsert"||r.kind==="revisionDelete")&&KS(o,r)){t[t.length-1]={...o,children:jS(e,o.children,r.children)};continue}t.push(r);}return t}function jS(e,n,t){let r=n[n.length-1],o=t[0];if(r?.kind!=="run"||o?.kind!=="run"||!By(r)||!By(o))return [...n,...t];let i=r.children.filter(hn),a=o.children.filter(hn);if(!Sc(i,a))return [...n,...t];let l=Ky(e,[...r.children.filter(d=>!hn(d)),...o.children.filter(d=>!hn(d))]),s={...r,children:[...i,...l]};return [...n.slice(0,-1),s,...t.slice(1)]}function By(e){let n=e.children.filter(t=>!hn(t));return n.length>0&&n.every(t=>t.kind==="text"||t.kind==="deletedText")}function KS(e,n){let t=(r,o)=>r.attributes.find(i=>i.namespaceUri===O&&i.localName===o)?.value;return t(e,"id")!==void 0&&t(e,"id")===t(n,"id")&&t(e,"author")===t(n,"author")&&t(e,"date")===t(n,"date")}function $y(e,n,t,r,o,i){let a=null,l=s=>{if(!(a!==null||s.kind==="textValue")){if(s.kind==="revisionDelete"){let d=s.attributes,c=d.find(m=>m.namespaceUri===O&&m.localName==="author"),u=d.find(m=>m.namespaceUri===O&&m.localName==="id"),f=n.spanOf(s);if(c?.value===o&&u&&f&&(f.end===t||f.start===r)){let m=d.find(g=>g.namespaceUri===O&&g.localName==="date");if(!Lc(m?.value,i))return;a={id:u.value,date:m?.value};return}}for(let d of s.children)l(d);}};for(let s of e.children)l(s);return a}function GS(e,n,t,r,o,i=new Set){let a=le(t).filter(hn),l=f=>f.length===0?null:Kn(e(),"run","r",[],[...a.map(m=>ko(e,m)),...f]),s=[],d=[],c=[],u=0;for(let f of le(t)){if(hn(f))continue;let m=n.lengthOf(f),g=u,p=u+m;if(u=p,i.has(f.id)){d.push(f);continue}if(p<=r){s.push(f);continue}if(g>=o){c.push(f);continue}if(f.kind!=="text"&&f.kind!=="deletedText"){d.push(f);continue}let x=le(f).find(k=>k.kind==="textValue"),y=x&&x.kind==="textValue"?x.value:"",N=f.kind==="deletedText",b=y.slice(0,Math.max(0,r-g)),h=y.slice(Math.max(0,r-g),Math.min(y.length,o-g)),P=y.slice(Math.min(y.length,o-g));b&&s.push(_t(e,b,N)),h&&d.push(_t(e,h,N)),P&&c.push(_t(e,P,N));}return {before:l(s),covered:l(d),after:l(c)}}function Fy(e,n){let t=le(n).map(r=>{if(r.kind!=="textValue"&&Dt(r,"instrText")){let a=le(r).find(d=>d.kind==="textValue"),l=a&&a.kind==="textValue"?a.value:"",s=e();return Kn(e(),"generic","delInstrText",r.attributes,[{id:s,kind:"textValue",value:l}])}if(r.kind!=="text")return r;let o=le(r).find(a=>a.kind==="textValue"),i=o&&o.kind==="textValue"?o.value:"";return _t(e,i,true)});return {...n,id:e(),children:t}}function Ll(e,n,t,r,o){let i=S(e),a={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"},l=Xy(n,t);if(l&&l.author===r.author)return T({ok:true,part:e},a);let s=$S(e,n,t,r)??bo(e)(),d=Kn(i(),"generic",t,Uc(s,r),[]),c=le(n).find(k=>k.kind==="paragraphProperties"),u=le(n).filter(k=>k.kind!=="paragraphProperties"),f=c?le(c).find(k=>Dt(k,"rPr")):void 0,m=f?le(f).filter(k=>!qy(k,t)):[],g=m.filter(Dc),p=m.filter(k=>!Dc(k)),x=t==="ins"?[d,...g]:[...g,d],y=Kn(i(),"runProperties","rPr",[],[...x,...p]),N=c?le(c).filter(k=>!Dt(k,"rPr")):[],b=N.filter(Vy),h=N.filter(k=>!Vy(k)),P=Kn(i(),"paragraphProperties","pPr",c?c.attributes:[],[...h,y,...b]);return T(L(e,n.id,[P,...u],o),a)}function zy(e,n,t,r){let o=Ce(e,n.id);if(!o)return {ok:false,reason:"tree-invariant"};let i=o.children,a=i.findIndex(s=>s.id===n.id),l=a>0?i[a-1]:void 0;return !l||l.kind!=="paragraph"?{ok:false,reason:"not-adjacent-siblings"}:Ll(e,l,"del",t,r)}function Fc(e,n){let t=Xy(e,"ins");return t!==void 0&&t.author===n}function Xy(e,n){let t=le(e).find(a=>a.kind==="paragraphProperties"),r=t?le(t).find(a=>Dt(a,"rPr")):void 0,o=r?le(r).find(a=>qy(a,n)):void 0;if(!o||o.kind==="textValue")return;let i=o.attributes.find(a=>a.namespaceUri===O&&a.localName==="author");return {localName:o.localName,author:i?.value??""}}function Vy(e){return Dt(e,"sectPr")||Dt(e,"pPrChange")}function qy(e,n){return e.kind!=="textValue"&&Dt(e,n)}function Dc(e){return e.kind!=="textValue"&&e.namespaceUri===O&&(e.localName==="ins"||e.localName==="del")}function Dt(e,n){return e.kind!=="textValue"&&e.namespaceUri===O&&e.localName===n}function $S(e,n,t,r){let o=Ce(e,n.id);if(!o)return null;let i=o.children,a=i.findIndex(l=>l.id===n.id);for(let l of [i[a-1],i[a+1]]){if(!l||l.kind!=="paragraph")continue;let s=le(l).find(m=>m.kind==="paragraphProperties"),d=s?le(s).find(m=>Dt(m,"rPr")):void 0,c=d?le(d).find(Dc):void 0;if(!c||c.kind==="textValue"||c.localName!==t)continue;let u=m=>c.attributes.find(g=>g.namespaceUri===O&&g.localName===m)?.value;if(u("author")!==r.author||!Lc(u("date"),r.date))continue;let f=u("id");if(f!==void 0)return f}return null}var Vc=/^[0-9A-Fa-f]{6}$/,jc=["top","left","bottom","right","insideH","insideV"],Yy=new Set(["val","sz","color","themeColor","themeTint","themeShade"]),Zy=new Set(["fill","themeFill","themeFillTint","themeFillShade"]),YS=["all","outside","inside","top","bottom","left","right"],ZS=new Set(["dark1","light1","dark2","light2","accent1","accent2","accent3","accent4","accent5","accent6","hyperlink","followedHyperlink","none","background1","text1","background2","text2"]),QS={lt1:"light1",dk1:"dark1",lt2:"light2",dk2:"dark2",bg1:"background1",tx1:"text1",bg2:"background2",tx2:"text2",hlink:"hyperlink",folhlink:"followedHyperlink"},JS={dirty:[],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"},oO={dirty:[],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"};function Vl(e){return e==="duplicate-node-id"?"unknown-table":e}function Gc(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function $c(e,n){if(!Gc(e,n))return null;let t=e[n];return typeof t!="string"||t.length===0?null:t}function or(e,n){if(Object.keys(e).length!==n.length)return false;for(let r of n)if(!Gc(e,r))return false;return true}function Wc(e,n){let t=0;for(let r of e.children)dn(r,n)&&(t+=1);return t}function eA(e){let n=e&&K(e,"gridSpan"),t=n&&cn(n,"val");if(!t||!/^\d{1,7}$/.test(t))return 1;let r=Number(t);return Number.isInteger(r)&&r>1?Math.min(r,1024):1}function nA(e,n){let t=e&&K(e,n),r=t&&cn(t,"val");if(!r||!/^\d{1,7}$/.test(r))return 0;let o=Number(r);return Number.isInteger(o)&&o>0?Math.min(o,1024):0}function tA(e){let n=e&&K(e,"vMerge");return n?cn(n,"val")==="restart"?"restart":"continue":"none"}function rA(e){let n=K(e,"trPr"),r=nA(n,"gridBefore"),o=[];for(let i of e.children){if(i.kind!=="tableCell")continue;let a=K(i,"tcPr"),l=Math.min(r,1024),s=Math.min(eA(a),Math.max(0,1024-l));o.push({startCol:l,span:s,vMergeKind:tA(a)}),r=l+s;}return o}function lO(e,n){return `${e}\0${n}`}function Hc(e,n){if(n)return {...e,visualOwner:n};let t={...e,visualOwner:void 0};return t.visualOwner=t,t}function aA(e,n){let t=[],r=new Map,o=new Map,i=new Map,a=new Map,l=new Map;for(let d=0;d<e.rows.length;d+=1){if(d>=n.maxRows)return {ok:false,reason:"resource-limit"};let c=e.rows[d],u=rA(c.row),f=o.get(d);f||(f=[],o.set(d,f));let m=i.get(d);m||(m=new Map,i.set(d,m));for(let g=0;g<c.cells.length;g+=1){let p=c.cells[g],x=u[g],y=lO(x.startCol,x.span);if(x.vMergeKind==="restart"){a.set(y,p.id),l.set(p.id,[p.id]);let N=Hc({rowIndex:d,startCol:x.startCol,span:x.span,endCol:x.startCol+x.span-1,cell:p,vMergeKind:x.vMergeKind});t.push(N),r.set(p.id,N),f.push(N),m.set(y,N);}else if(x.vMergeKind==="continue"){let N=a.get(y);if(!N)return {ok:false,reason:"tree-invariant"};let b=r.get(N);l.get(N).push(p.id),a.set(y,N);let h=Hc({rowIndex:d,startCol:x.startCol,span:x.span,endCol:x.startCol+x.span-1,cell:p,vMergeKind:x.vMergeKind},b);t.push(h),r.set(p.id,h),f.push(h),m.set(y,h);}else {a.delete(y);let N=Hc({rowIndex:d,startCol:x.startCol,span:x.span,endCol:x.startCol+x.span-1,cell:p,vMergeKind:x.vMergeKind});t.push(N),r.set(p.id,N),f.push(N),m.set(y,N);}if(t.length>n.maxTraversalNodes)return {ok:false,reason:"resource-limit"}}}let s=new Map;for(let[d,c]of l)s.set(d,Object.freeze([...c]));return {ok:true,index:{placed:t,byId:r,byRow:o,intervalAtRow:i,visualMembersByOwnerId:s}}}function lA(e){let n=new Map;for(let t of e.placed){let r=lO(t.startCol,t.span);if(t.vMergeKind==="restart"){n.set(r,t.rowIndex);continue}if(t.vMergeKind==="continue"){let o=n.get(r);if(o===void 0||t.rowIndex!==o+1)return false;n.set(r,t.rowIndex);continue}n.delete(r);}return true}function sA(e,n,t,r,o,i,a){let l=r-t+1,s=i-o+1;if(l<=0||s<=0)return "invalidArgs";let d=l*s;if(d>a.maxTraversalNodes)return "resource-limit";let c=0;for(let p=t;p<=r;p+=1)c+=e.byRow.get(p)?.length??0;let u=new Set,f=0;for(let p of n){let y=e.byId.get(p).visualOwner.cell.id;if(u.has(y))continue;u.add(y);let N=e.visualMembersByOwnerId.get(y);f+=N?N.length:1;}let m=e.placed.length;return m+d+c+l+m+f+u.size+d>a.maxTraversalNodes?"resource-limit":null}function dA(e,n,t){let r=[];if(e.forEach((d,c)=>{if(d.span<=0)return;let u=d.startCol,f=d.endCol+1;u>=f||f<=n||u>t||(r.push({x:u,kind:1,entry:d,cellIndex:c}),r.push({x:f,kind:0,entry:d,cellIndex:c}));}),r.length===0)return [];r.sort((d,c)=>d.x!==c.x?d.x-c.x:d.kind!==c.kind?d.kind-c.kind:d.cellIndex-c.cellIndex);let o=new Map,i,a=r[0].x,l=[],s=()=>{i=void 0;let d=Number.POSITIVE_INFINITY;for(let[c,u]of o)c<d&&(d=c,i=u);};for(let d of r){if(d.x>a&&i){let c=l[l.length-1];c&&c.end===a&&c.entry.cell.id===i.cell.id?l[l.length-1]={start:c.start,end:d.x,entry:i}:l.push({start:a,end:d.x,entry:i});}d.kind===1?o.set(d.cellIndex,d.entry):o.delete(d.cellIndex),s(),a=d.x;}return l}function zc(e,n){for(let t of e)if(n>=t.start&&n<t.end)return t.entry}function cA(e,n,t,r,o){let i=[];for(let a=n;a<=t;a+=1){let l=e.byRow.get(a)??[];for(let d of l)if(d.span<=0)return {ok:false};let s=dA(l,r,o);if(s===null)return {ok:false};for(let d=r;d<=o;d+=1)if(!zc(s,d))return {ok:false};i.push(s);}return {ok:true,grid:{rowFrom:n,rowTo:t,colFrom:r,colTo:o,rows:i}}}function Cn(e,n,t){let r=e.rows[n-e.rowFrom];return zc(r,t).visualOwner}function uA(e){let n=K(e,"tcPr");if(!n)return null;if(Wc(n,"tcBorders")>1||Wc(n,"shd")>1)return "duplicate-property-container";let t=K(n,"tcBorders");if(t){for(let r of jc)if(Wc(t,r)>1)return "duplicate-property-container"}return null}function Wl(e,n,t){if(!Array.isArray(n)||n.length===0)return {ok:false,reason:"invalidArgs"};if(n.length>65536||n.length>t.maxRows*t.maxColumns)return {ok:false,reason:"resource-limit"};let r=new Set;for(let g of n){if(typeof g!="string"||g.length===0)return {ok:false,reason:"invalidArgs"};if(r.has(g))return {ok:false,reason:"invalidArgs"};r.add(g);}let o=aA(e,t);if(!o.ok)return {ok:false,reason:o.reason};let{index:i}=o,{byId:a}=i;for(let g of n){if(!a.has(g))return {ok:false,reason:"invalidArgs"};let p=uA(a.get(g).cell);if(p)return {ok:false,reason:p}}let l=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,d=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(let g of n){let p=a.get(g);l=Math.min(l,p.rowIndex),s=Math.max(s,p.rowIndex),d=Math.min(d,p.startCol),c=Math.max(c,p.endCol);}let u=sA(i,n,l,s,d,c,t);if(u)return {ok:false,reason:u};if(!lA(i))return {ok:false,reason:"tree-invariant"};let f=cA(i,l,s,d,c);if(!f.ok)return {ok:false,reason:"invalidArgs"};for(let g=l;g<=s;g+=1)for(let p=d;p<=c;p+=1){let x=f.grid.rows[g-l],y=zc(x,p);if(!y||!r.has(y.cell.id))return {ok:false,reason:"invalidArgs"}}let m=new Set;for(let g of n){let x=a.get(g).visualOwner.cell.id;if(m.has(x))continue;m.add(x);let y=i.visualMembersByOwnerId.get(x);if(y){for(let N of y)if(!r.has(N))return {ok:false,reason:"invalidArgs"};continue}if(!r.has(x))return {ok:false,reason:"invalidArgs"}}return {ok:true,selection:{index:i,selectedIds:r,grid:f.grid}}}function sO(e){let n=e.toLowerCase();return ZS.has(n)?n:QS[n]??null}function Qy(e){return typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=1}function Xc(e){if(!e||typeof e!="object")return false;let n=e.kind;if(n==="hex"){if(!or(e,["kind","value"]))return false;let t=e.value;return typeof t=="string"&&Vc.test(t)}if(n==="auto"){if(!or(e,["kind","resolvedHex"]))return false;let t=e.resolvedHex;return typeof t=="string"&&Vc.test(t)}if(n==="theme"){let t=e,r=["kind","slot","resolvedHex"];return t.tint!==void 0&&r.push("tint"),t.shade!==void 0&&r.push("shade"),!(!or(e,r)||typeof t.slot!="string"||sO(t.slot)===null||typeof t.resolvedHex!="string"||!Vc.test(t.resolvedHex)||t.tint!==void 0&&!Qy(t.tint)||t.shade!==void 0&&!Qy(t.shade))}return false}function fA(e){if(!e||typeof e!="object"||!or(e,["style","size","color"]))return false;let n=e.style;if(typeof n!="string"||!jh.includes(n))return false;let t=e.size;return typeof t!="number"||!Number.isInteger(t)||t<1||t>96?false:Xc(e.color)}function Jy(e){return Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")}function mA(e,n){return e.kind==="hex"?e.value.toUpperCase():e.kind==="auto"&&n==="themeColor"?"auto":e.resolvedHex.toUpperCase()}function qc(e,n,t){let r=[{kind:"genericExtension",namespaceUri:O,localName:t==="themeFill"?"fill":"color",prefix:n.attributePrefix,value:mA(e,t)}];if(e.kind==="theme"){let o=sO(e.slot);r.push({kind:"genericExtension",namespaceUri:O,localName:t,prefix:n.attributePrefix,value:o});let i=t==="themeFill"?"themeFillTint":"themeTint",a=t==="themeFill"?"themeFillShade":"themeShade";e.tint!==void 0&&r.push({kind:"genericExtension",namespaceUri:O,localName:i,prefix:n.attributePrefix,value:Jy(e.tint)}),e.shade!==void 0&&r.push({kind:"genericExtension",namespaceUri:O,localName:a,prefix:n.attributePrefix,value:Jy(e.shade)});}return r}function ir(e,n,t,r,o=[]){return {id:n(),kind:"generic",namespaceUri:O,localName:e,...t.elementPrefix===void 0?{}:{prefix:t.elementPrefix},namespaceBindings:[],attributes:r,children:o}}function pA(e,n,t,r){if(r.kind==="clear")return ir(e,n,t,[{kind:"wmlVal",namespaceUri:O,localName:"val",prefix:t.attributePrefix,value:"none"}]);let o=r.spec;return ir(e,n,t,[{kind:"wmlVal",namespaceUri:O,localName:"val",prefix:t.attributePrefix,value:o.style},{kind:"genericExtension",namespaceUri:O,localName:"sz",prefix:t.attributePrefix,value:String(o.size)},...qc(o.color,t,"themeColor")])}function Bl(e,n){if(e.length!==n.length)return false;for(let t=0;t<e.length;t+=1){let r=e[t],o=n[t];if(r.namespaceUri!==o.namespaceUri||r.localName!==o.localName||r.value!==o.value)return false}return true}function Po(e,n,t,r,o=false){let i=[],a=false;for(let l of e){if(l.namespaceUri===O&&l.localName===n){a||(i.push(o?{kind:"wmlVal",namespaceUri:O,localName:"val",prefix:r.attributePrefix,value:t}:{kind:"genericExtension",namespaceUri:O,localName:n,prefix:r.attributePrefix,value:t}),a=true);continue}i.push(l);}return a||i.push(o?{kind:"wmlVal",namespaceUri:O,localName:"val",prefix:r.attributePrefix,value:t}:{kind:"genericExtension",namespaceUri:O,localName:n,prefix:r.attributePrefix,value:t}),i}function Fl(e,n){return e.filter(t=>t.namespaceUri!==O||!n.has(t.localName))}function gA(e,n,t){if(n.kind==="clear"){let i=Fl(e.attributes,Yy);return i=Po(i,"val","none",t,true),Bl(e.attributes,i)?null:Object.freeze({...e,attributes:i})}let r=n.spec,o=Fl(e.attributes,Yy);o=Po(o,"val",r.style,t,true),o=Po(o,"sz",String(r.size),t);for(let i of qc(r.color,t,"themeColor"))o=Po(o,i.localName,i.value,t);return Bl(e.attributes,o)?null:Object.freeze({...e,attributes:o})}function eO(e){let n=jc.indexOf(e);return n===-1?jc.length:n}function xA(e,n){let t=eO(n.localName),r=e.length;for(let i=0;i<e.length;i+=1){let a=e[i];if(a.kind!=="textValue"&&a.namespaceUri===O&&eO(a.localName)>t){r=i;break}}let o=[...e];return o.splice(r,0,n),o}function hA(e,n,t,r){if(n.size===0)return {container:e??null,changed:false};let o=false,i=e?[...e.children]:[];for(let a of ["top","left","bottom","right"]){let l=n.get(a);if(!l)continue;let s=i.findIndex(d=>dn(d,a));if(s>=0){let d=gA(i[s],l,r);d&&(i[s]=d,o=true);continue}i=xA(i,pA(a,t,r,l)),o=true;}return o?e?{container:Object.freeze({...e,children:i}),changed:true}:{container:ir("tcBorders",t,r,[],i),changed:true}:{container:e??null,changed:false}}function yA(e,n,t,r){if(n===null){if(!e)return {container:null,changed:false};let l=Fl(e.attributes,Zy);return Bl(e.attributes,l)?{container:e,changed:false}:{container:Object.freeze({...e,attributes:l}),changed:true}}let o=qc(n,r,"themeFill");if(!e){let l=[{kind:"wmlVal",namespaceUri:O,localName:"val",prefix:r.attributePrefix,value:"clear"},...o];return {container:ir("shd",t,r,l),changed:true}}let i=Fl(e.attributes,Zy);e.attributes.find(l=>l.namespaceUri===O&&l.localName==="val")?.value==="nil"&&(i=Po(i,"val","clear",r,true));for(let l of o)i=Po(i,l.localName,l.value,r,l.localName==="val");return Bl(e.attributes,i)?{container:e,changed:false}:{container:Object.freeze({...e,attributes:i}),changed:true}}function OA(e,n,t,r){let o=e.get(n);o||(o=new Map,e.set(n,o)),o.set(t,r);}function nO(e,n,t,r,o){let{grid:i}=e,a=(g,p)=>{OA(o,g,p,t==="clear"?{kind:"clear"}:{kind:"set",spec:r});},{rowFrom:l,rowTo:s,colFrom:d,colTo:c}=i,u=n,f=(g,p)=>{a(g,"bottom"),a(p,"top");},m=(g,p)=>{a(g,"right"),a(p,"left");};if(u==="all"){let g=new Set;for(let p=l;p<=s;p+=1)for(let x=d;x<=c;x+=1)g.add(Cn(i,p,x).cell.id);for(let p of g)for(let x of ["top","left","bottom","right"])a(p,x);return}if(u==="outside"){for(let g=d;g<=c;g+=1)a(Cn(i,l,g).cell.id,"top"),a(Cn(i,s,g).cell.id,"bottom");for(let g=l;g<=s;g+=1)a(Cn(i,g,d).cell.id,"left"),a(Cn(i,g,c).cell.id,"right");return}if(u==="inside"){for(let g=l;g<s;g+=1)for(let p=d;p<=c;p+=1){let x=Cn(i,g,p),y=Cn(i,g+1,p);x.cell.id!==y.cell.id&&f(x.cell.id,y.cell.id);}for(let g=d;g<c;g+=1)for(let p=l;p<=s;p+=1){let x=Cn(i,p,g),y=Cn(i,p,g+1);x.cell.id!==y.cell.id&&m(x.cell.id,y.cell.id);}return}if(u==="top"){for(let g=d;g<=c;g+=1)a(Cn(i,l,g).cell.id,"top");return}if(u==="bottom"){for(let g=d;g<=c;g+=1)a(Cn(i,s,g).cell.id,"bottom");return}if(u==="left"){for(let g=l;g<=s;g+=1)a(Cn(i,g,d).cell.id,"left");return}for(let g=l;g<=s;g+=1)a(Cn(i,g,c).cell.id,"right");}function tO(e,n,t){let r=new Map;return n==="none"?(nO(e,t,"clear",void 0,r),r):(nO(e,n,"set",t,r),r)}function NA(e,n,t,r){let o=K(e,"tcPr"),i=o&&K(o,"tcBorders"),a=hA(i,n,t,r);if(!a.changed)return null;let l=o;if(a.container===null)return null;if(l){let c=Ir(l,a.container);if(!c.ok)return null;l=c.container;}else l=ir("tcPr",t,r,[],[a.container]);if(l===o)return null;if(o){let c=e.children.map(u=>u===o?l:u);return Object.freeze({...e,children:c})}let s=0;for(let c=0;c<e.children.length;c+=1){let u=e.children[c];if(u.kind==="paragraph"||u.kind==="table")break;s=c+1;}let d=[...e.children];return d.splice(s,0,l),Object.freeze({...e,children:d})}function kA(e,n,t,r){let o=K(e,"tcPr"),i=o&&K(o,"shd"),a=yA(i,n,t,r);if(!a.changed||a.container===null&&!i)return null;let l=o;if(a.container===null)return null;if(l){let c=Ir(l,a.container);if(!c.ok)return null;l=c.container;}else l=ir("tcPr",t,r,[],[a.container]);if(l===o)return null;if(o){let c=e.children.map(u=>u===o?l:u);return Object.freeze({...e,children:c})}let s=0;for(let c=0;c<e.children.length;c+=1){let u=e.children[c];if(u.kind==="paragraph"||u.kind==="table")break;s=c+1;}let d=[...e.children];return d.splice(s,0,l),Object.freeze({...e,children:d})}function bA(e,n,t,r){let o=K(e,"tcPr"),i=o&&K(o,"vAlign");if(i&&cn(i,"val")===n)return null;let a=ir("vAlign",t,r,[{kind:"genericExtension",namespaceUri:O,localName:"val",prefix:r.attributePrefix,value:n}]),l=o??ir("tcPr",t,r,[]),s=Ir(l,a);if(!s.ok)return null;if(o){let c=e.children.map(u=>u===o?s.container:u);return Object.freeze({...e,children:c})}let d=[s.container,...e.children];return Object.freeze({...e,children:d})}function rO(e){return typeof e=="string"&&YS.includes(e)}function PA(e){return !$c(e,"tableId")||!Array.isArray(e.cellIds)||!Gc(e,"scope")?"invalidArgs":e.scope==="none"?!or(e,["op","tableId","cellIds","scope","target"])||!rO(e.target)?"invalidArgs":null:!or(e,["op","tableId","cellIds","scope","spec"])||!rO(e.scope)?"invalidArgs":null}function wA(e){return !$c(e,"tableId")||!Array.isArray(e.cellIds)||!or(e,["op","tableId","cellIds","color"])?"invalidArgs":e.color!==null&&!Xc(e.color)?"invalid-property-value":null}function EA(e){return !$c(e,"tableId")||!Array.isArray(e.cellIds)||!or(e,["op","tableId","cellIds","alignment"])?"invalidArgs":["top","center","bottom"].includes(e.alignment)?null:"invalid-property-value"}function wo(e,n,t=ze){let r=n.op==="setTableCellBorders"?PA(n):n.op==="setTableCellFill"?wA(n):EA(n);if(r)return r;let o=Xe(t),i=nn(e.root,n.tableId,o);if(!i.ok)return Vl(i.reason);let a=Wl(i.topology,n.cellIds,o);return a.ok?n.op==="setTableCellFill"&&n.color!==null&&!Xc(n.color)||n.op==="setTableCellBorders"&&n.scope!=="none"&&!fA(n.spec)?"invalid-property-value":null:a.reason}function Yc(e,n,t){return !t.rowBinding||Ki(n,e).has(t.rowBinding.prefix)?e:Object.freeze({...e,namespaceBindings:[...e.namespaceBindings,t.rowBinding]})}function RA(e,n,t,r=ze){let o=wo(e,n,r);if(o)return {ok:false,reason:o};let i=Xe(r),a=nn(e.root,n.tableId,i);if(!a.ok)return {ok:false,reason:Vl(a.reason)};let l=Wl(a.topology,n.cellIds,i);if(!l.ok)return {ok:false,reason:l.reason};let s=n.scope==="none"?tO(l.selection,"none",n.target):tO(l.selection,n.scope,n.spec),d=Ve(e,a.topology.table),c=S(e),u=[],f=new Set,m=false;for(let[x,y]of s){let N=l.selection.index.byId.get(x);if(!N)continue;let b=NA(N.cell,y,c,d);b&&(m=true,f.add(x),u.push(h=>V(h,x,b,t)));}if(!m)return Le(e,JS);let g=Yc(a.topology.table,e,d);g!==a.topology.table&&(f.add(a.topology.table.id),u.unshift(x=>V(x,a.topology.table.id,g,t)));let p={dirty:[...f],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"};return T(Ot(e,u,t),p)}function IA(e,n,t,r=ze){let o=wo(e,n,r);if(o)return {ok:false,reason:o};let i=Xe(r),a=nn(e.root,n.tableId,i);if(!a.ok)return {ok:false,reason:Vl(a.reason)};let l=Wl(a.topology,n.cellIds,i);if(!l.ok)return {ok:false,reason:l.reason};let s=Ve(e,a.topology.table),d=S(e),c=[],u=new Set,f=false;for(let p of l.selection.selectedIds){let x=l.selection.index.byId.get(p);if(!x)continue;let y=kA(x.cell,n.color,d,s);y&&(f=true,u.add(p),c.push(N=>V(N,p,y,t)));}if(!f)return Le(e,oO);let m=Yc(a.topology.table,e,s);m!==a.topology.table&&(u.add(a.topology.table.id),c.unshift(p=>V(p,a.topology.table.id,m,t)));let g={dirty:[...u],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"};return T(Ot(e,c,t),g)}function TA(e,n,t,r=ze){let o=wo(e,n,r);if(o)return {ok:false,reason:o};let i=Xe(r),a=nn(e.root,n.tableId,i);if(!a.ok)return {ok:false,reason:Vl(a.reason)};let l=Wl(a.topology,n.cellIds,i);if(!l.ok)return {ok:false,reason:l.reason};let s=Ve(e,a.topology.table),d=S(e),c=[],u=new Set;for(let g of l.selection.selectedIds){let p=l.selection.index.byId.get(g);if(!p)continue;let x=bA(p.cell,n.alignment,d,s);x&&(u.add(g),c.push(y=>V(y,g,x,t)));}if(c.length===0)return Le(e,oO);let f=Yc(a.topology.table,e,s);f!==a.topology.table&&(u.add(a.topology.table.id),c.unshift(g=>V(g,a.topology.table.id,f,t)));let m={dirty:[...u],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"};return T(Ot(e,c,t),m)}function Zc(e,n,t){return n.op==="setTableCellBorders"?RA(e,n,t):n.op==="setTableCellFill"?IA(e,n,t):TA(e,n,t)}var CA=new Set(["ins","del","trPrChange"]),uO=new Set(["vMerge","hMerge","cellIns","cellDel","cellMerge","tcPrChange"]),vA=new Set([...uO,"gridSpan"]),fO=Ic.filter(e=>!CA.has(e)),mO=_l.filter(e=>!uO.has(e)),pO=_l.filter(e=>!vA.has(e)),Hl={tcBorders:["top","left","bottom","right","insideH","insideV"],tcMar:["top","left","bottom","right"]};function mt(e){return e==="duplicate-node-id"?"unknown-table":e}function SA(e){let n=e&&K(e,"gridSpan"),t=n&&cn(n,"val");if(!t||!/^\d{1,7}$/.test(t))return 1;let r=Number(t);return Number.isInteger(r)&&r>1?Math.min(r,1024):1}function AA(e,n){let t=e&&K(e,n),r=t&&cn(t,"val");if(!r||!/^\d{1,7}$/.test(r))return 0;let o=Number(r);return Number.isInteger(o)&&o>0?Math.min(o,1024):0}function MA(e){let n=e&&K(e,"vMerge");return n?cn(n,"val")==="restart"?"restart":"continue":"none"}function dO(e){let n=K(e,"trPr"),r=AA(n,"gridBefore"),o=[];for(let i of e.children){if(i.kind!=="tableCell")continue;let a=K(i,"tcPr"),l=Math.min(r,1024),s=Math.min(SA(a),1024-l);o.push({startCol:l,span:s,vMergeKind:MA(a)}),r=l+s;}return o}function _A(e,n,t,r){return e===t&&n===r}var yn=["val"],Ro=["w","type"],DA=["val","fill","color","themeFill","themeFillTint","themeFillShade","themeColor","themeTint","themeShade"],gO=["val","sz","color","space","shadow","frame","themeColor","themeTint","themeShade"],UA=["val","hRule"],xO={cnfStyle:yn,divId:yn,gridBefore:yn,gridAfter:yn,gridSpan:yn,wBefore:Ro,wAfter:Ro,tcW:Ro,cantSplit:yn,trHeight:UA,tblHeader:yn,tblCellSpacing:Ro,jc:yn,hidden:yn,shd:DA,noWrap:yn,textDirection:yn,tcFitText:yn,vAlign:yn,hideMark:yn},LA=new Set(["cantSplit","tblHeader","noWrap","tcFitText","hideMark"]);function BA(e,n){if(n<=0||n>=e.rows.length)return false;let t=dO(e.rows[n-1].row),r=dO(e.rows[n].row);for(let o of t)if(o.vMergeKind!=="none"){for(let i of r)if(i.vMergeKind==="continue"&&_A(o.startCol,o.span,i.startCol,i.span))return true}return false}function Kl(e,n,t){let r=new Set(n),o=[];for(let i of e.attributes)i.namespaceUri===O&&r.has(i.localName)&&o.push(i.localName==="val"?{kind:"wmlVal",namespaceUri:O,localName:"val",prefix:t.attributePrefix,value:i.value}:{kind:"genericExtension",namespaceUri:O,localName:i.localName,prefix:t.attributePrefix,value:i.value});return o}function un(e,n,t,r,o=[]){return {id:n(),kind:"generic",namespaceUri:O,localName:e,...t.elementPrefix===void 0?{}:{prefix:t.elementPrefix},namespaceBindings:[],attributes:r,children:o}}function cO(e,n,t){let r=(o,i)=>({kind:"genericExtension",namespaceUri:O,localName:o,prefix:t.attributePrefix,value:i});return [r("id",e),r("author",n.author),...n.date===void 0?[]:[r("date",n.date)]]}function hO(e,n,t,r,o,i){let a=un(n,o,i,cO(t,r,i)),l=K(e,"trPr"),s=l??un("trPr",o,i,[]),d=vc(s,a);if(!d.ok)return e;let c=n==="ins"?"cellIns":"cellDel",u=e.children.map(f=>{if(f.kind!=="tableCell")return f===l?d.container:f;let m=un(c,o,i,cO(t,r,i)),g=K(f,"tcPr"),p=g??un("tcPr",o,i,[]),x=Ir(p,m);if(!x.ok)return f;let y=g?f.children.map(N=>N===g?x.container:N):[x.container,...f.children];return Object.freeze({...f,children:y})});return l||u.unshift(d.container),Object.freeze({...e,children:u})}function FA(e,n,t){return {id:e(),kind:"tableRow",namespaceUri:O,localName:"tr",...t.elementPrefix===void 0?{}:{prefix:t.elementPrefix},namespaceBindings:t.rowBinding?[t.rowBinding]:[],attributes:[],children:n}}function yO(e,n,t){return {id:e(),kind:"tableCell",namespaceUri:O,localName:"tc",...t.elementPrefix===void 0?{}:{prefix:t.elementPrefix},namespaceBindings:[],attributes:[],children:n}}function OO(e){return e.children.some(n=>n.kind!=="textValue"&&n.namespaceUri===O)}function NO(e,n,t){return e.children.some(r=>r.kind==="textValue")||OO(e)?false:Kl(e,n,t).length>0}function VA(e,n,t,r){return NO(e,t,r)?un(e.localName,n,r,Kl(e,t,r)):null}function kO(e,n){if(e.children.some(o=>o.kind==="textValue")||OO(e))return false;let t=xO[e.localName];return t?Kl(e,t,n).length>0?true:LA.has(e.localName):false}function WA(e,n,t){if(!kO(e,t))return null;let r=xO[e.localName];return un(e.localName,n,t,Kl(e,r,t))}function HA(e,n,t){let r=Hl[e.localName];if(!r)return null;let o=e.localName==="tcMar"?Ro:gO,i=[];for(let a of r){let l=e.children.find(d=>dn(d,a));if(!l||l.kind==="textValue")continue;let s=VA(l,n,o,t);s&&i.push(s);}return i.length===0?null:un(e.localName,n,t,[],i)}function jA(e,n,t){return Hl[e.localName]?HA(e,n,t):WA(e,n,t)}function iu(e,n,t,r){let o=[];for(let i of n){let a=e.children.find(s=>dn(s,i));if(!a||a.kind==="textValue")continue;let l=jA(a,t,r);l&&o.push(l);}return o.length===0?null:un(e.localName,t,r,[],o)}function KA(e,n){if(Hl[e.localName]){let t=Hl[e.localName],r=e.localName==="tcMar"?Ro:gO,o=1;for(let i of t){let a=e.children.find(l=>dn(l,i));!a||a.kind==="textValue"||!NO(a,r,n)||(o+=1);}return o>1?o:0}return kO(e,n)?1:0}var GA=Object.freeze({elementPrefix:"w",attributePrefix:"w",rowBinding:null});function Qc(e,n){let t=1;for(let r of n){let o=e.children.find(a=>dn(a,r));if(!o||o.kind==="textValue")continue;let i=KA(o,GA);i>0&&(t+=i);}return t}function bO(e){let n=e.children.filter(o=>o.kind==="tableCell");if(n.length===0)return null;let t=1;for(let o of n){t+=2;let i=K(o,"tcPr");i&&(t+=Qc(i,mO));}let r=K(e,"trPr");return r&&(t+=Qc(r,fO)),{sourceRow:e,cellCount:n.length,structureBudget:t}}function PO(e,n,t,r,o,i){let a=xr(e,n),l=[];if(a!==null){let s=wn(r,o);o.add(s),l.push(...Rt(a,s));}return {id:t(),kind:"paragraph",namespaceUri:O,localName:"p",...i.elementPrefix===void 0?{}:{prefix:i.elementPrefix},namespaceBindings:[],attributes:l,children:[]}}function $A(e,n,t,r,o,i,a){let l=K(e,"tcPr"),s=l?iu(l,mO,r,a):void 0,d=[];return s&&d.push(s),d.push(PO(n,t,r,`${o}:p`,i,a)),yO(r,d,a)}function zA(e,n,t,r){let o=Ve(n,t),i=e.sourceRow,a=K(i,"trPr"),l=a?iu(a,fO,r,o):void 0,s=new Set(zn(n.root)),d=[],c=[];l&&d.push(l);let u=0;for(let m of i.children){if(m.kind!=="tableCell")continue;let g=$A(m,n,t,r,`${i.id}:c${u}`,s,o);u+=1,c.push(g.children.find(p=>p.kind==="paragraph").id),d.push(g);}return {row:FA(r,d,o),paragraphIds:c}}function XA(e,n){return e.children.findIndex(t=>t.id===n)}function qA(e,n,t,r,o){if(n.rows.length>=o.maxRows)return "resource-limit";let i=bO(n.rows[t].row);if(i===null)return "tree-invariant";if(i.structureBudget>o.maxTraversalNodes)return "resource-limit";let a=r==="above"?t:t+1;return BA(n,a)?"vertical-merge-crossing":null}function Gl(e,n,t=ze){if(n.revision!==void 0&&(typeof n.revision.author!="string"||n.revision.author.trim().length===0||n.revision.date!==void 0&&typeof n.revision.date!="string"))return "invalid-property-value";let r=Xe(t),o=nn(e.root,n.tableId,r);if(!o.ok)return mt(o.reason);let{topology:i}=o,a=i.rows.findIndex(l=>l.row.id===n.rowId);return a===-1?"unknown-row":n.op==="deleteTableRow"?i.rows.length===1?"block-required":null:qA(e,i,a,n.where,r)}function YA(e,n,t,r=ze){let o=Gl(e,n,r);if(o)return {ok:false,reason:o};let i=Xe(r),a=nn(e.root,n.tableId,i);if(!a.ok)return {ok:false,reason:mt(a.reason)};let{topology:l}=a,s=l.rows.findIndex(y=>y.row.id===n.rowId);if(s===-1)return {ok:false,reason:"unknown-row"};let d=bO(l.rows[s].row);if(d===null)return {ok:false,reason:"tree-invariant"};let c=S(e),u=zA(d,e,l.table,c),f=n.revision?hO(u.row,"ins",bo(e)(),n.revision,c,Ve(e,l.table)):u.row,m=u.paragraphIds,g=XA(l.table,n.rowId);if(g===-1)return {ok:false,reason:"unknown-row"};let p=n.where==="above"?g:g+1,x={dirty:[l.table.id,f.id],created:[f.id,...f.children.filter(y=>y.kind==="tableCell").map(y=>y.id),...m],deleted:[],dependencyKeys:W,impact:"flow-structural",caret:{paragraphId:m[0]}};return T(M(e,l.table.id,p,[f],t),x)}function ZA(e,n,t,r=ze){let o=Gl(e,n,r);if(o)return {ok:false,reason:o};let i=nn(e.root,n.tableId,Xe(r));if(!i.ok)return {ok:false,reason:mt(i.reason)};let a=i.topology.rows.find(p=>p.row.id===n.rowId)?.row;if(!a)return {ok:false,reason:"unknown-row"};let l=i.topology.rows.findIndex(p=>p.row.id===n.rowId),s=i.topology.rows[l],d=l>0?l-1:l+1,c=i.topology.rows[d],u=c?.cells[0];if(n.referenceCellId&&c){let p=s.cells.findIndex(x=>x.id===n.referenceCellId);p>=0&&c.cells[p]&&(u=c.cells[p]);}let f=u?TO(u):null;if(!f)return {ok:false,reason:"tree-invariant"};let m=Rr(a);if(n.revision){let p=S(e),x=hO(a,"del",bo(e)(),n.revision,p,Ve(e,i.topology.table)),y={dirty:[n.tableId,n.rowId],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural",caret:{paragraphId:f}};return T(V(e,n.rowId,x,t),y)}let g={dirty:[n.tableId],created:[],deleted:[n.rowId,...m],dependencyKeys:W,impact:"flow-structural",caret:{paragraphId:f}};return T(oe(e,n.rowId,t),g)}function wO(e,n,t){return n.op==="insertTableRow"?YA(e,n,t):ZA(e,n,t)}function QA(e){let n=K(e,"tcPr"),t=n&&K(n,"tcW");if(!t)return;let r=cn(t,"type");if(r!==void 0&&r!=="dxa")return;let o=cn(t,"w");if(!(!o||!/^\d{1,9}$/.test(o)))return o}function Tr(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function Ut(e,n){if(!Tr(e,n))return null;let t=e[n];return typeof t!="string"||t.length===0?null:t}function au(e){let n=Tr(e,"gridColumnId"),t=Tr(e,"referenceCellId");if(n===t)return null;if(n){let o=Ut(e,"gridColumnId");return o?{kind:"gridColumn",id:o}:null}let r=Ut(e,"referenceCellId");return r?{kind:"referenceCell",id:r}:null}function Jn(e,n){let t=e.gridColumns.findIndex(r=>r.id===n);return t===-1?null:t}function lu(e,n){let t=e.rows[0];if(!t)return null;let r=t.cells.findIndex(o=>o.id===n);return r===-1?null:r}function JA(e){for(let{cells:n}of e.rows)for(let t of n){let r=K(t,"tcPr");if(r&&(K(r,"gridSpan")||K(r,"hMerge")||K(r,"vMerge")))return true}return false}function EO(e){if(JA(e))return "table-has-merge";if(e.rows.length===0)return "tree-invariant";let n=e.rows[0].cells.length;if(n===0)return "tree-invariant";for(let{row:t,cells:r}of e.rows){if(r.length!==n)return "tree-invariant";let o=K(t,"trPr");if(o&&(K(o,"gridBefore")||K(o,"gridAfter")))return "tree-invariant"}return e.grid&&e.gridColumns.length!==n?"tree-invariant":null}function RO(e,n){let t=e.gridColumns[n];if(t){let r=cn(t,"w");return r&&/^\d{1,9}$/.test(r)?r:void 0}return QA(e.rows[0].cells[n])}function Jc(e,n,t){let r=[];return t&&r.push({kind:"genericExtension",namespaceUri:O,localName:"w",prefix:n.attributePrefix,value:t}),un("gridCol",e,n,r)}function IO(e){let n=0;for(let t of e.children)if(t.kind!=="textValue"){if(dn(t,"tblPr")){n+=1;continue}break}return n}function e0(e,n,t,r){if(e.children.some(l=>l.id===r.id))return null;let o=e.children.findIndex(l=>l.id===n);if(o===-1)return null;let i=t==="left"?o:o+1,a=[...e.children];return a.splice(i,0,r),Object.freeze({...e,children:a})}function n0(e,n,t,r,o){let i=e.rows[0].cells.length+1,a=[];for(let l=0;l<i;l+=1){if(l===r){a.push(Jc(n,t,o));continue}let s=l>r?l-1:l;a.push(Jc(n,t,RO(e,s)));}return {id:n(),kind:"tableGrid",namespaceUri:O,localName:"tblGrid",...t.elementPrefix===void 0?{}:{prefix:t.elementPrefix},namespaceBindings:[],attributes:[],children:a}}function t0(e,n){let t=0;for(let r=0;r<e.children.length;r+=1)if(e.children[r].kind==="tableCell"){if(t===n)return r;t+=1;}return e.children.length}function TO(e){return e.children.find(t=>t.kind==="paragraph")?.id??null}function su(e,n,t){return !t.rowBinding||Ki(n,e).has(t.rowBinding.prefix)?e:Object.freeze({...e,namespaceBindings:[...e.namespaceBindings,t.rowBinding]})}function CO(e,n,t,r){let o=t==="left"?n:n+1,i=e.rows.map(l=>l.cells[n]),a=e.grid?2:e.rows[0].cells.length+3;for(let l of i){a+=2;let s=K(l,"tcPr");s&&(a+=Qc(s,pO));}return {referenceIndex:n,insertIndex:o,referenceWidth:RO(e,n),structureBudget:a,referenceCells:i,synthesizeGrid:!e.grid||e.gridColumns.length===0,targetGridColumnId:e.gridColumns[n]?.id??null}}function r0(e,n,t,r,o,i,a){let l=K(e,"tcPr"),s=l?iu(l,pO,r,a):void 0,d=[];return s&&d.push(s),d.push(PO(n,t,r,`${o}:p`,i,a)),yO(r,d,a)}function o0(e,n){if(!Tr(e,"where")||e.where!=="left"&&e.where!=="right")return "invalidArgs";let t=au(e);if(!t)return "invalidArgs";let r=n.grid!==void 0&&n.gridColumns.length>0;return t.kind==="gridColumn"?r?Jn(n,t.id)===null?"unknown-grid-column":null:"invalidArgs":r?"invalidArgs":lu(n,t.id)===null?"unknown-grid-column":null}function $l(e,n,t=ze){if(!Ut(n,"tableId"))return "invalidArgs";let r=Xe(t),o=nn(e.root,n.tableId,r);if(!o.ok)return mt(o.reason);let{topology:i}=o,a=EO(i);if(a)return a;if(n.op==="deleteTableColumn")return Ut(n,"gridColumnId")?!i.grid||i.gridColumns.length===0||Jn(i,n.gridColumnId)===null?"unknown-grid-column":i.gridColumns.length===1?"block-required":null:"invalidArgs";let l=o0(n,i);if(l)return l;let s=au(n),d=s.kind==="gridColumn"?Jn(i,s.id):lu(i,s.id);if((i.gridColumns.length>0?i.gridColumns.length+1:i.rows[0].cells.length+1)>r.maxColumns)return "resource-limit";Ve(e,i.table);return CO(i,d,n.where).structureBudget>r.maxTraversalNodes?"resource-limit":null}function i0(e,n,t,r=ze){let o=$l(e,n,r);if(o)return {ok:false,reason:o};let i=Xe(r),a=nn(e.root,n.tableId,i);if(!a.ok)return {ok:false,reason:mt(a.reason)};let{topology:l}=a,s=au(n);if(!s)return {ok:false,reason:"invalidArgs"};let d=s.kind==="gridColumn"?Jn(l,s.id):lu(l,s.id);if(d===null)return {ok:false,reason:"unknown-grid-column"};let c=CO(l,d,n.where,Ve(e,l.table)),u=Ve(e,l.table),f=S(e),m=new Set(zn(e.root)),g=su(l.table,e,u),p=[],x=[];for(let w=0;w<l.rows.length;w+=1){let I=c.referenceCells[w],A=r0(I,e,g,f,`${l.table.id}:col:${d}:r${w}`,m,u);p.push(A),x.push(A.children.find(U=>U.kind==="paragraph").id);}let y,N;if(c.synthesizeGrid)y=n0(l,f,u,c.insertIndex,c.referenceWidth),N=y.children.filter(w=>w.kind!=="textValue"&&w.localName==="gridCol").map(w=>w.id);else {let w=Jc(f,u,c.referenceWidth),I=e0(l.grid,c.targetGridColumnId,n.where,w);if(!I)return {ok:false,reason:"tree-invariant"};y=I,N=[w.id];}let b=[];g!==l.table&&b.push(w=>V(w,l.table.id,g,t));for(let w=0;w<l.rows.length;w+=1){let I=l.rows[w].row,A=t0(I,c.insertIndex),U=p[w];b.push(B=>M(B,I.id,A,[U],t));}c.synthesizeGrid?b.push(w=>M(w,l.table.id,IO(l.table),[y],t)):b.push(w=>V(w,l.grid.id,y,t));let h=[l.table.id,...l.rows.map(w=>w.row.id)];c.synthesizeGrid||h.push(l.grid.id);let P=c.synthesizeGrid?[y.id,...N,...p.map(w=>w.id),...x]:[...N,...p.map(w=>w.id),...x],k=x[0],E={dirty:h,created:P,deleted:[],dependencyKeys:W,impact:"flow-structural",caret:{paragraphId:k}};return T(Ot(e,b,t),E)}function a0(e,n,t,r=ze){let o=$l(e,n,r);if(o)return {ok:false,reason:o};let i=nn(e.root,n.tableId,Xe(r));if(!i.ok)return {ok:false,reason:mt(i.reason)};let{topology:a}=i,l=Jn(a,n.gridColumnId);if(l===null||!a.grid)return {ok:false,reason:"unknown-grid-column"};let s=a.rows.map(p=>p.cells[l]),d=s.flatMap(p=>Rr(p)),c=l<a.gridColumns.length-1?l+1:l-1,u=TO(a.rows[0].cells[c]);if(!u)return {ok:false,reason:"tree-invariant"};let f=$i(a.grid,n.gridColumnId,null);if(!f.ok)return {ok:false,reason:f.reason==="unknown-grid-column"?"unknown-grid-column":"tree-invariant"};let m=[];for(let p of s)m.push(x=>oe(x,p.id,t));m.push(p=>V(p,a.grid.id,f.grid,t));let g={dirty:[a.table.id,a.grid.id,...a.rows.map(p=>p.row.id)],created:[],deleted:[n.gridColumnId,...s.map(p=>p.id),...d],dependencyKeys:W,impact:"flow-structural",caret:{paragraphId:u}};return T(Ot(e,m,t),g)}function vO(e,n,t){return n.op==="insertTableColumn"?i0(e,n,t):a0(e,n,t)}function eu(e,n){if(!Tr(e,n))return null;let t=e[n];return typeof t!="number"||!Number.isFinite(t)||!Number.isInteger(t)||t<300||t>31680?null:t}function l0(e,n){if(!Tr(e,n))return null;let t=e[n];return typeof t!="number"||!Number.isFinite(t)||!Number.isInteger(t)||t<300||t>31680?null:t}function Eo(e){let n=cn(e,"w");if(!n||!/^\d{1,9}$/.test(n))return null;let t=Number(n);return !Number.isInteger(t)||t<0?null:t}function nu(e,n,t){let r=String(n),o=e.attributes.filter(i=>!(i.namespaceUri===O&&i.localName==="w"));return o.push({kind:"genericExtension",namespaceUri:O,localName:"w",prefix:t.attributePrefix,value:r}),Object.freeze({...e,attributes:o})}function SO(e,n,t,r){return un(e,n,t,[{kind:"genericExtension",namespaceUri:O,localName:"w",prefix:t.attributePrefix,value:String(r)},{kind:"genericExtension",namespaceUri:O,localName:"type",prefix:t.attributePrefix,value:"dxa"}])}function s0(e,n){return un("tblLayout",e,n,[{kind:"genericExtension",namespaceUri:O,localName:"type",prefix:n.attributePrefix,value:"fixed"}])}function d0(e,n,t,r){let o=K(e,"tblPr"),i=o??un("tblPr",n,t,[],[]),a=Cc(i,s0(n,t));if(!a.ok)return {ok:false};if(i=a.container,r!==void 0){let l=Cc(i,SO("tblW",n,t,r));if(!l.ok)return {ok:false};i=l.container;}return {ok:true,tblPr:i,insert:o===void 0}}function AO(e,n,t,r,o,i){let a=K(n,"tblPr"),l=d0(n,t,r,i);return l.ok?l.insert?(e.push(s=>M(s,n.id,IO(n),[l.tblPr],o)),null):(l.tblPr!==a&&e.push(s=>V(s,a.id,l.tblPr,o)),null):"tree-invariant"}function tu(e,n,t,r){let o=SO("tcW",t,r,n),i=K(e,"tcPr");if(i){let d=Ir(i,o);if(!d.ok||d.container===i)return e;let c=e.children.map(u=>u===i?d.container:u);return Object.freeze({...e,children:c})}let a=un("tcPr",t,r,[],[o]),l=0;for(let d=0;d<e.children.length;d+=1){let c=e.children[d];if(c.kind==="paragraph"||c.kind==="table")break;l=d+1;}let s=[...e.children];return s.splice(l,0,a),Object.freeze({...e,children:s})}function c0(e){if(!e.grid||e.gridColumns.length===0)return "unknown-grid-column";for(let n of e.gridColumns)if(Eo(n)===null)return "tree-invariant";return null}function u0(e){return !Ut(e,"leftGridColumnId")||!Ut(e,"rightGridColumnId")||eu(e,"leftWidthTwips")===null||eu(e,"rightWidthTwips")===null||e.leftGridColumnId===e.rightGridColumnId?"invalidArgs":null}function f0(e){return !Ut(e,"gridColumnId")||eu(e,"columnWidthTwips")===null||l0(e,"tableWidthTwips")===null?"invalidArgs":null}function m0(e){return !Ut(e,"rowId")||!Tr(e,"heightTwips")||typeof e.heightTwips!="number"||!Number.isInteger(e.heightTwips)||e.heightTwips<20||e.heightTwips>31680?"invalidArgs":null}function Xi(e,n,t=ze){if(!Ut(n,"tableId"))return "invalidArgs";let r=n.op==="setTableColumnWidths"?u0(n):n.op==="setTableRightEdgeWidth"?f0(n):m0(n);if(r)return r;let o=Xe(t),i=nn(e.root,n.tableId,o);if(!i.ok)return mt(i.reason);let{topology:a}=i;if(n.op==="setTableRowHeight")return a.rows.some(g=>g.row.id===n.rowId)?null:"unknown-row";let l=EO(a);if(l)return l;let s=c0(a);if(s)return s;if(n.op==="setTableColumnWidths"){let g=Jn(a,n.leftGridColumnId),p=Jn(a,n.rightGridColumnId);if(g===null||p===null)return "unknown-grid-column";if(p!==g+1)return "invalidArgs";let x=Eo(a.gridColumns[g]),y=Eo(a.gridColumns[p]),N=n.leftWidthTwips,b=n.rightWidthTwips;return N+b!==x+y||N===x&&b===y?"invalidArgs":null}let d=a.gridColumns.length-1,c=Jn(a,n.gridColumnId);if(c===null)return "unknown-grid-column";if(c!==d)return "invalidArgs";let u=Eo(a.gridColumns[d]),f=0;for(let g of a.gridColumns)f+=Eo(g);if(n.columnWidthTwips===u&&n.tableWidthTwips===f)return "invalidArgs";let m=0;for(let g=0;g<a.gridColumns.length;g+=1){let p=g===d?n.columnWidthTwips:Eo(a.gridColumns[g]);m+=p;}return n.tableWidthTwips!==m?"invalidArgs":null}function p0(e,n,t,r=ze){let o=Xi(e,n,r);if(o)return {ok:false,reason:o};let i=nn(e.root,n.tableId,Xe(r));if(!i.ok)return {ok:false,reason:mt(i.reason)};let{topology:a}=i,l=Jn(a,n.leftGridColumnId),s=Jn(a,n.rightGridColumnId);if(l===null||s===null||!a.grid)return {ok:false,reason:"unknown-grid-column"};let d=Ve(e,a.table),c=su(a.table,e,d),u=S(e),f=nu(a.gridColumns[l],n.leftWidthTwips,d),m=nu(a.gridColumns[s],n.rightWidthTwips,d),g=a.grid,p=$i(g,n.leftGridColumnId,f);if(!p.ok)return {ok:false,reason:p.reason==="unknown-grid-column"?"unknown-grid-column":"tree-invariant"};if(g=p.grid,p=$i(g,n.rightGridColumnId,m),!p.ok)return {ok:false,reason:p.reason==="unknown-grid-column"?"unknown-grid-column":"tree-invariant"};g=p.grid;let x=[];c!==a.table&&x.push(h=>V(h,a.table.id,c,t)),g!==a.grid&&x.push(h=>V(h,a.grid.id,g,t));let y=AO(x,c,u,d,t);if(y)return {ok:false,reason:y};for(let{cells:h}of a.rows){let P=tu(h[l],n.leftWidthTwips,u,d),k=tu(h[s],n.rightWidthTwips,u,d);P!==h[l]&&x.push(E=>V(E,P.id,P,t)),k!==h[s]&&x.push(E=>V(E,k.id,k,t));}let b={dirty:[a.table.id,a.grid.id,...a.rows.map(h=>h.row.id)],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"};return T(Ot(e,x,t),b)}function g0(e,n,t,r=ze){let o=Xi(e,n,r);if(o)return {ok:false,reason:o};let i=nn(e.root,n.tableId,Xe(r));if(!i.ok)return {ok:false,reason:mt(i.reason)};let{topology:a}=i,l=a.gridColumns.length-1;if(!a.grid||Jn(a,n.gridColumnId)!==l)return {ok:false,reason:"invalidArgs"};let s=Ve(e,a.table),d=su(a.table,e,s),c=S(e),u=nu(a.gridColumns[l],n.columnWidthTwips,s),f=$i(a.grid,n.gridColumnId,u);if(!f.ok)return {ok:false,reason:f.reason==="unknown-grid-column"?"unknown-grid-column":"tree-invariant"};let m=f.grid,g=[];d!==a.table&&g.push(N=>V(N,a.table.id,d,t)),g.push(N=>V(N,a.grid.id,m,t));let p=AO(g,d,c,s,t,n.tableWidthTwips);if(p)return {ok:false,reason:p};for(let{cells:N}of a.rows){let b=tu(N[l],n.columnWidthTwips,c,s);b!==N[l]&&g.push(h=>V(h,b.id,b,t));}let y={dirty:[a.table.id,a.grid.id,...a.rows.map(N=>N.row.id)],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"};return T(Ot(e,g,t),y)}function x0(e,n,t){let r=Xi(e,n);if(r)return {ok:false,reason:r};let o=nn(e.root,n.tableId);if(!o.ok)return {ok:false,reason:mt(o.reason)};let i=o.topology.rows.find(x=>x.row.id===n.rowId)?.row;if(!i)return {ok:false,reason:"unknown-row"};let a=S(e),l=Ve(e,i),s=(x,y)=>({kind:"genericExtension",namespaceUri:O,localName:x,prefix:l.attributePrefix,value:y}),d=un("trHeight",a,l,[s("val",String(n.heightTwips)),s("hRule","exact")]),c=K(i,"trPr"),u=c??un("trPr",a,l,[]),f=vc(u,d);if(!f.ok)return {ok:false,reason:"tree-invariant"};let m=c?i.children.map(x=>x===c?f.container:x):[f.container,...i.children],g=Object.freeze({...i,children:m}),p={dirty:[i.id,...Rr(i)],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"};return T(V(e,i.id,g,t),p)}function MO(e,n,t){return n.op==="setTableColumnWidths"?p0(e,n,t):n.op==="setTableRightEdgeWidth"?g0(e,n,t):x0(e,n,t)}function _O(e,n){if(!Array.isArray(n.entries)||n.entries.length>512||!Array.isArray(n.bookmarksToCreate)||n.bookmarksToCreate.length>512)return "invalidArgs";for(let t of n.entries)if(!Number.isInteger(t.level)||t.level<0||t.level>8||typeof t.text!="string"||t.text.length>200||!$(t.text)||typeof t.headingParagraphId!="string"||t.headingParagraphId.length===0||typeof t.bookmarkName!="string"||t.bookmarkName.length===0||t.bookmarkName.length>40||!$(t.bookmarkName)||typeof t.pageNumberText!="string"||t.pageNumberText.length>32||!$(t.pageNumberText))return "invalidArgs";for(let t of n.bookmarksToCreate){if(typeof t.paragraphId!="string"||t.paragraphId.length===0||typeof t.name!="string"||t.name.length===0||t.name.length>40||!$(t.name))return "invalidArgs";let r=R(e,t.paragraphId);if(!r||r.kind!=="paragraph")return "unknown-paragraph";if(Te(e,t.paragraphId))return "bound";if(ve(e,t.paragraphId).content)return "locked"}return null}function DO(e,n){if(typeof n.beforeParagraphId!="string"||n.beforeParagraphId.length===0||typeof n.alias!="string"||n.alias.length===0||n.alias.length>128||!$(n.alias)||!ci(n.instruction))return "invalidArgs";let t=R(e,n.beforeParagraphId);if(!t||t.kind!=="paragraph")return "unknown-paragraph";let r=Z(e,t.id);return !r||r.localName!=="body"?"not-a-block":Te(e,t.id)?"bound":ve(e,t.id).content?"locked":_O(e,n)}function UO(e,n){for(let t of [n.beginParagraphId,...n.resultParagraphIds,n.endParagraphId]){if(Te(e,t))return "bound";if(ve(e,t).content)return "locked"}if(n.contentControlId){let t=R(e,n.contentControlId);if(t&&we(t)){if(Fn(e,t).content)return "locked";if(Te(e,n.contentControlId))return "bound"}}return null}function LO(e,n){if(typeof n.tocId!="string"||n.tocId.length===0)return "invalidArgs";let t=_O(e,n);if(t)return t;let r=no(eo(e),n.tocId);return r?UO(e,r):"unknown-block"}function BO(e,n){if(typeof n.tocId!="string"||n.tocId.length===0||!Array.isArray(n.updates)||n.updates.length>512)return "invalidArgs";for(let r of n.updates)if(typeof r.paragraphId!="string"||r.paragraphId.length===0||typeof r.pageNumberText!="string"||r.pageNumberText.length>32||!$(r.pageNumberText))return "invalidArgs";let t=no(eo(e),n.tocId);return t?n.updates.some(r=>!t.resultParagraphIds.includes(r.paragraphId))?"invalidArgs":UO(e,t):"unknown-block"}function FO(e,n,t){let r=e,o=S(r),i=[],a=new Set,l=d=>{if(d.kind!=="textValue"){if(d.localName==="bookmarkStart"||d.localName==="bookmarkEnd"){let c=d.attributes.find(u=>u.localName==="id")?.value;c&&a.add(c);}for(let c of d.children)l(c);}};l(r.root);let s=1;for(let d of n){let c=R(r,d.paragraphId);if(!c||c.kind==="textValue")return {ok:false,reason:"unknown-paragraph"};for(;a.has(String(s));)s+=1;let u=String(s++);a.add(u);let f=pg(o,d.name,u),m=[...c.children],g=0;m[0]&&m[0].kind!=="textValue"&&m[0].localName==="pPr"&&(g=1),m.splice(g,0,f.start),m.push(f.end);let p=L(r,c.id,m,t);if(!p.ok)return {ok:false,reason:"tree-invariant",detail:"bookmark-insert"};r=p.part,i.push(c.id);}return Le(r,{dirty:i,created:[],deleted:[],dependencyKeys:i,impact:"flow-structural"})}function h0(e,n,t,r){let o=R(e,n.containerId);if(!o||o.kind==="textValue")return {ok:false,reason:"unknown-block"};let i=o.children.findIndex(p=>p.id===n.beginParagraphId),a=o.children.findIndex(p=>p.id===n.endParagraphId);if(i<0||a<0||a<=i)return {ok:false,reason:"invalidArgs"};let l=new Map;for(let p of n.resultParagraphIds){let x=R(e,p);if(!x||x.kind==="textValue")continue;let y=x.children.find(h=>h.kind!=="textValue"&&h.localName==="pPr");if(!y||y.kind==="textValue")continue;let N=y.children.find(h=>h.kind!=="textValue"&&h.localName==="pStyle");if(N?.kind==="textValue")continue;let b=N?.attributes.find(h=>h.localName==="val")?.value;b?.startsWith("TOC")&&!l.has(b)&&l.set(b,y);}let s=S(e),d=t.map(p=>{let x=`TOC${Math.min(p.level+1,9)}`;return yd(s,p,n.instruction,l.get(x))}),c=[...o.children.slice(0,i+1),...d,...o.children.slice(a)],u=n.resultParagraphIds,f=d.map(p=>p.id),m=L(e,o.id,c,r);if(!m.ok)return {ok:false,reason:"tree-invariant"};let g={dirty:[n.beginParagraphId,n.endParagraphId,...f],created:f,deleted:u,dependencyKeys:[n.containerId],impact:"flow-structural"};return T(m,g)}function VO(e,n,t){let r=e;if(n.bookmarksToCreate.length>0){let u=FO(r,n.bookmarksToCreate,t);if(!u.ok||!u.part)return u;r=u.part;}let o=ci(n.instruction),i=R(r,n.beforeParagraphId);if(!o||!i||i.kind!=="paragraph")return {ok:false,reason:"invalidArgs"};let a=Z(r,i.id);if(!a||a.localName!=="body")return {ok:false,reason:"not-a-block"};let l=a.children.findIndex(u=>u.id===i.id);if(l<0)return {ok:false,reason:"tree-invariant"};let s=S(r),d=mg(s,n.entries,o,n.alias),c=M(r,a.id,l,[d],t);return T(c,{dirty:[a.id,...n.entries.map(u=>u.headingParagraphId)],created:[d.id],deleted:[],dependencyKeys:[a.id],impact:"flow-structural"})}function WO(e,n,t){if(!no(eo(e),n.tocId))return {ok:false,reason:"unknown-block"};let o=e;if(n.bookmarksToCreate.length>0){let l=FO(o,n.bookmarksToCreate,t);if(!l.ok||!l.part)return l;o=l.part;}let i=no(eo(o),n.tocId);if(!i)return {ok:false,reason:"unknown-block"};let a=n.entries.map(l=>({level:l.level,text:l.text,headingParagraphId:l.headingParagraphId,bookmarkName:l.bookmarkName,pageNumberText:l.pageNumberText}));return h0(o,i,a,t)}function y0(e,n,t){let r=[],o=false,i=c=>{if((c.kind==="tab"||c.kind!=="textValue"&&c.localName==="ptab")&&(o=true),c.kind==="text"||c.kind!=="textValue"&&c.localName==="t"){r.push(c);return}c.kind!=="textValue"&&c.children.forEach(i);};if(i(e),!o||r.length<2)return null;let a=r[r.length-1];if(a.kind==="textValue")return null;let l=a.id,s="";for(let c of a.children)c.kind==="textValue"&&(s+=c.value);if(s===n)return null;let d=c=>{if(c.kind==="textValue")return c;if(c.id===l)return {...c,children:[{id:t(),kind:"textValue",value:n}]};let u=c.children.map(d);return u.some((f,m)=>f!==c.children[m])?{...c,children:u}:c};return d(e)}function HO(e,n,t){let r=no(eo(e),n.tocId);if(!r)return {ok:false,reason:"unknown-block"};let o=e,i=S(o),a=[];for(let l of n.updates){if(!r.resultParagraphIds.includes(l.paragraphId))continue;let s=R(o,l.paragraphId);if(!s||s.kind==="textValue")continue;let d=y0(s,l.pageNumberText,i);if(!d)continue;let c=Z(o,s.id);if(!c)return {ok:false,reason:"unknown-block"};let u=c.children.map(m=>m.id===s.id?d:m),f=L(o,c.id,u,t);if(!f.ok)return {ok:false,reason:"tree-invariant"};o=f.part,a.push(l.paragraphId);}return a.length===0?Le(o,{dirty:[],created:[],deleted:[],dependencyKeys:[],impact:"text-local"}):Le(o,{dirty:a,created:[],deleted:[],dependencyKeys:a,impact:"text-local"})}var b0=new Set(["body","hdr","ftr","tc","sdtContent","footnote","endnote"]);function Cr(e,n,t,r=[],o=[]){return {id:n(),kind:"generic",namespaceUri:O,localName:e,...t.elementPrefix===void 0?{}:{prefix:t.elementPrefix},namespaceBindings:[],attributes:r,children:o}}function tn(e,n,t){return {kind:"genericExtension",namespaceUri:O,localName:e,prefix:t.attributePrefix,value:n}}function P0(e,n,t){return Cr(e,n,t,[tn("val","single",t),tn("sz","4",t),tn("space","0",t),tn("color","auto",t)])}function w0(e,n){let t=Cr("tblBorders",e,n,[],["top","left","bottom","right","insideH","insideV"].map(i=>P0(i,e,n))),r=Cr("tblW",e,n,[tn("w","0",n),tn("type","auto",n)]),o=Cr("tblLook",e,n,[tn("val","04A0",n),tn("firstRow","1",n),tn("lastRow","0",n),tn("firstColumn","1",n),tn("lastColumn","0",n),tn("noHBand","0",n),tn("noVBand","1",n)]);return {id:e(),kind:"tableProperties",namespaceUri:O,localName:"tblPr",...n.elementPrefix===void 0?{}:{prefix:n.elementPrefix},namespaceBindings:[],attributes:[],children:[r,t,o]}}function E0(e,n,t,r){let o=[];for(let i=0;i<e;i+=1)o.push(Cr("gridCol",t,r,[tn("w",String(n),r)]));return {id:t(),kind:"tableGrid",namespaceUri:O,localName:"tblGrid",...r.elementPrefix===void 0?{}:{prefix:r.elementPrefix},namespaceBindings:[],attributes:[],children:o}}function jO(e,n,t,r,o){let i=[];if(e!==null){let a=wn(n,t);t.add(a),i.push(...Rt(e,a));}return {id:r(),kind:"paragraph",namespaceUri:O,localName:"p",...o.elementPrefix===void 0?{}:{prefix:o.elementPrefix},namespaceBindings:[],attributes:i,children:[]}}function R0(e,n,t,r,o){let i=[],a=[],l=[];for(let d=0;d<e.rows;d+=1){let c=[];for(let u=0;u<e.cols;u+=1){let f=Cr("tcW",r,o,[tn("w",String(e.columnWidthTwips),o),tn("type","dxa",o)]),m=Cr("tcPr",r,o,[],[f]),g=jO(n,`${e.beforeParagraphId}:r${d}c${u}`,t,r,o);a.push(g.id);let p={id:r(),kind:"tableCell",namespaceUri:O,localName:"tc",...o.elementPrefix===void 0?{}:{prefix:o.elementPrefix},namespaceBindings:[],attributes:[],children:[m,g]};i.push(p.id),c.push(p);}l.push({id:r(),kind:"tableRow",namespaceUri:O,localName:"tr",...o.elementPrefix===void 0?{}:{prefix:o.elementPrefix},namespaceBindings:[],attributes:[],children:c});}return {table:{id:r(),kind:"table",namespaceUri:O,localName:"tbl",...o.elementPrefix===void 0?{}:{prefix:o.elementPrefix},namespaceBindings:o.rowBinding?[o.rowBinding]:[],attributes:[],children:[w0(r,o),E0(e.cols,e.columnWidthTwips,r,o),...l]},cellIds:i,paragraphIds:a}}function du(e,n,t){return typeof e=="number"&&Number.isInteger(e)&&e>=n&&e<=t}function cu(e,n){if(typeof n.beforeParagraphId!="string"||n.beforeParagraphId.length===0||!du(n.rows,1,32767)||!du(n.cols,1,63))return "invalidArgs";if(n.rows*n.cols>2e4)return "resource-limit";if(!du(n.columnWidthTwips,300,31680)||n.columnWidthTwips*n.cols>31680)return "invalid-property-value";let t=R(e,n.beforeParagraphId);if(!t)return "unknown-paragraph";if(t.kind!=="paragraph")return "not-a-paragraph";let r=Z(e,t.id);return !r||!b0.has(r.localName)?"not-a-block":Te(e,t.id)?"bound":ve(e,t.id).content?"locked":null}function KO(e,n,t){let r=cu(e,n);if(r)return {ok:false,reason:r};let o=R(e,n.beforeParagraphId),i=o?Z(e,o.id):null;if(!o||!i)return {ok:false,reason:"unknown-paragraph"};let a=i.children.findIndex(x=>x.id===o.id);if(a<0)return {ok:false,reason:"tree-invariant"};let l=S(e),s=Ve(e,i),d=xr(e,i),c=new Set(zn(e.root)),u=R0(n,d,c,l,s),f=a>0?i.children[a-1]:void 0,m=f&&f.kind!=="textValue"&&f.localName==="tbl"?jO(d,`${n.beforeParagraphId}:sep`,c,l,s):null,g=m?[m,u.table]:[u.table],p={dirty:[i.id,u.table.id],created:[...m?[m.id]:[],u.table.id,...u.cellIds,...u.paragraphIds],deleted:[],dependencyKeys:W,impact:"flow-structural",caret:{paragraphId:u.paragraphIds[0]}};return T(M(e,i.id,a,g,t),p)}var I0=1e4;function uu(e,n,t){let r=R(e,n);return !r||r.kind==="textValue"?"unknown-block":Ci(e).some(o=>o.root.id===n)?!Array.isArray(t)||t.length<1||t.length>I0?"invalidArgs":t.every(o=>typeof o=="string"&&$(o))?null:"invalid-text":"not-a-block"}function GO(e,n){if(n.push(e.id),e.kind!=="textValue")for(let t of e.children)GO(t,n);}function T0(e,n){let t=[];if(n.length>0){let r={id:e(),kind:"textValue",value:n},o={id:e(),kind:"text",namespaceUri:O,localName:"t",prefix:"w",namespaceBindings:[],attributes:[],children:[r]};t.push({id:e(),kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:[o]});}return {id:e(),kind:"paragraph",namespaceUri:O,localName:"p",prefix:"w",namespaceBindings:[],attributes:[],children:t}}function $O(e,n,t,r){let o=uu(e,n,t);if(o)return {ok:false,reason:o};let i=R(e,n),a=i.children,l=i.kind==="body"?a.find(g=>g.kind!=="textValue"&&g.namespaceUri===i.namespaceUri&&g.localName==="sectPr"):void 0,s=S(e),d=t.map(g=>T0(s,g)),c=[];for(let g of a)g!==l&&GO(g,c);let u=L(e,i.id,[...d,...l?[l]:[]],r);if(!u.ok)return {ok:false,reason:"tree-invariant"};let f=pi(u.part),m={dirty:[i.id],created:d.map(g=>g.id),deleted:c,dependencyKeys:["story-blocks","paragraph-text","sections","review"],impact:"global"};return {ok:true,part:f,effect:m}}var zO=new Set(er),XO=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),C0=new Set(nr);function fu(e,n){for(let t of e){if(!n.has(t.localName))return "unsupported-property";for(let[r,o]of Object.entries(t.attributes??{}))if(!/^[A-Za-z_][\w.-]*$/.test(r)||typeof o!="string"||!$(o))return "invalid-property-value"}return null}var ZO=512;function mu(e,n,t){return _m(Q(e),n,t)}function qO(e,n,t){let r=Q(e),o=new Set,i=(a,l)=>{if(a.kind==="textValue")return;let s=l||a.kind==="hyperlink";s&&a.kind==="run"&&o.add(a.id);for(let d of a.children)i(d,s);};for(let a of e.children)i(a,false);return o.size===0?false:r.some(a=>o.has(a.runId)&&a.start<t&&a.end>n)}function YO(e){let n=e.relationshipId!==void 0,t=e.anchor!==void 0;if(n===t)return "invalid-property-value";for(let r of [e.relationshipId,e.anchor,e.tooltip])if(r!==void 0&&(typeof r!="string"||r.length===0||r.length>ZO||!$(r)))return "invalid-property-value";return null}function v0(e,n,t,r){if(typeof r!="string"||r.length===0)return "invalidArgs";let o=R(e,r);if(!o)return "unknown-content-control";if(o.kind!=="contentControl")return "not-a-content-control";let i=R(e,n);if(!i||!En(i))return null;let a=Sl(o,n)?{start:0,end:Zn(i)}:Sl(i,r)?Pe(i).spanOf(o):null;return a?!Number.isInteger(t)||t<a.start||t>a.end?"offset-out-of-range":null:"unknown-content-control"}function pu(e,n){if(!vl.includes(n.op))return "unknown-op";if(Cl(n))return mc(e,n);if(n.op==="replaceStoryBlocks")return uu(e,n.storyRootId,n.paragraphs);if(n.op==="insertText"&&n.inside!==void 0){let i=v0(e,n.paragraphId,n.offset,n.inside);if(i)return i}if(n.op!=="deleteBlock"){let i=Ty(e,n);if(i)return i}let t=Cy(e,n);if(t)return t;if(n.op==="setContentControlProperties"||n.op==="setContentControlValue"&&typeof n.value!="string"||n.op==="removeContentControl"&&n.keepContent!==void 0){let i=R(e,n.controlId);if(!i)return "unknown-content-control";if(i.kind!=="contentControl")return "not-a-content-control";if(n.op==="setContentControlProperties"){if(n.tag===void 0&&n.alias===void 0&&n.lock===void 0)return "invalidArgs";for(let a of [n.tag,n.alias])if(!Rc(a))return "invalid-property-value";if(n.lock!==void 0&&!XO.has(n.lock))return "invalidArgs"}return null}if(n.op==="insertContentControl"){if(!wy.includes(n.type))return "invalidArgs";for(let a of [n.tag,n.alias])if(!Rc(a))return "invalid-property-value";if(n.lock!==void 0&&!XO.has(n.lock))return "invalidArgs";if(!Number.isInteger(n.start)||!Number.isInteger(n.end))return "invalid-range";let i=R(e,n.paragraphId);return i?En(i)?n.start<0||n.end>Zn(i)||n.start>n.end?"invalid-range":Be(i,n.start)||Be(i,n.end)?"splits-surrogate-pair":co(i,n.start)||co(i,n.end)?"indivisible-content":At(e,i,n.start,n.end):"not-a-paragraph":"unknown-paragraph"}if(n.op==="createHeaderFooter"||n.op==="deleteHeaderFooter"||n.op==="linkToPrevious"||n.op==="unlinkFromPrevious")return !Number.isInteger(n.sectionIndex)||n.sectionIndex<0||n.kind!=="header"&&n.kind!=="footer"||n.variant!=="default"&&n.variant!=="first"&&n.variant!=="even","invalidArgs";if(n.op==="setSectionFurnitureOptions"){if(n.titlePage===void 0&&n.evenAndOddHeaders===void 0&&n.headerDistanceTwips===void 0&&n.footerDistanceTwips===void 0)return "invalidArgs";for(let a of [n.headerDistanceTwips,n.footerDistanceTwips])if(a!==void 0&&(!Number.isInteger(a)||a<0||a>31680))return "invalidArgs";return n.sectionIndex!==void 0&&(!Number.isInteger(n.sectionIndex)||n.sectionIndex<0),"invalidArgs"}if(n.op==="insertNote"||n.op==="deleteNote"||n.op==="convertNote"||n.op==="convertAllNotes"||n.op==="setNoteProperties")return "invalidArgs";if(n.op==="addRepeatingSectionItem"||n.op==="removeRepeatingSectionItem")return "unsupported";if(n.op==="setContentControlValue")return typeof n.value!="string"?"typeMismatch":yy(e,n.controlId,n.value);if(n.op==="removeContentControl")return Oy(e,n.controlId);if(n.op==="insertTable")return cu(e,n);if(n.op==="insertToc")return DO(e,n);if(n.op==="replaceTocResult")return LO(e,n);if(n.op==="rewriteTocPageNumbers")return BO(e,n);if(n.op==="setSectionProperties"){let i=[n.pageWidthTwips,n.pageHeightTwips],a=[n.marginTopTwips,n.marginRightTwips,n.marginBottomTwips,n.marginLeftTwips];if(i.every(l=>l===void 0)&&a.every(l=>l===void 0)&&n.orientation===void 0)return "invalid-property-value";for(let l of i)if(l!==void 0&&(!Number.isInteger(l)||l<1||l>63360))return "invalid-property-value";for(let l of a)if(l!==void 0&&(!Number.isInteger(l)||l<0||l>31680))return "invalid-property-value";if(n.orientation!==void 0&&n.orientation!=="portrait"&&n.orientation!=="landscape")return "invalid-property-value";if(n.anchorParagraphId!==void 0){let l=R(e,n.anchorParagraphId);if(!l)return "unknown-paragraph";if(!En(l))return "not-a-paragraph"}if(!xo(e))return "tree-invariant";for(let l of ho(e,n.anchorParagraphId)){let s=yo(l),{widthTwips:d,heightTwips:c}=Fi(s,n),u=n.marginTopTwips??s.topTwips,f=n.marginRightTwips??s.rightTwips,m=n.marginBottomTwips??s.bottomTwips,g=n.marginLeftTwips??s.leftTwips;if(d-g-s.gutterTwips-f<=0||c-u-m<=0)return "invalid-property-value"}return null}if(n.op==="deleteBlock"){let i=R(e,n.blockId);if(i&&i.kind!=="textValue"){let a=hy(e,i);if(a)return a}return xy(e,n.blockId)}if(n.op==="insertTableRow"||n.op==="deleteTableRow")return Gl(e,n);if(n.op==="insertTableColumn"||n.op==="deleteTableColumn")return $l(e,n);if(n.op==="setTableColumnWidths"||n.op==="setTableRightEdgeWidth"||n.op==="setTableRowHeight")return Xi(e,n);if(n.op==="setTableCellBorders"||n.op==="setTableCellFill"||n.op==="setTableCellVerticalAlignment")return wo(e,n);if(n.op==="joinParagraphs"){let i=R(e,n.firstId),a=R(e,n.secondId);if(!i||!a)return "unknown-paragraph";if(!En(i)||!En(a))return "not-a-paragraph";if(Te(e,n.firstId)||Te(e,n.secondId))return "bound";if(ve(e,n.firstId).content||ve(e,n.secondId).content)return "locked";for(let l of [n.firstId,n.secondId]){let s=je(e,l);if(s&&ln(s)&&Fn(e,s).wrapper)return "locked"}return null}if(n.op==="setHyperlinkTarget"||n.op==="removeHyperlink"){let i=R(e,n.linkId);if(!i)return "unknown-paragraph";if(i.kind!=="hyperlink")return "not-a-paragraph";{let a=xc(e,n.linkId);if(a)return a}return n.op==="setHyperlinkTarget"?YO(n):null}if(n.op==="setMathEquation"||n.op==="removeMathEquation"){let i=R(e,n.equationId);if(!i)return "unknown-paragraph";if(i.kind==="textValue"||i.kind!=="generic"||i.namespaceUri!==$t||i.localName!=="oMath")return "not-a-paragraph";let a=xc(e,n.equationId);return a||(n.op==="setMathEquation"&&!Wa(n.linear).ok?"invalid-property-value":null)}if(n.op==="insertCommentMarker"){let i=R(e,n.paragraphId);return i?En(i)?!Number.isInteger(n.offset)||n.offset<0||n.offset>Zn(i)?"offset-out-of-range":typeof n.commentId!="string"||!/^\d+$/.test(n.commentId)?"invalid-property-value":null:"not-a-paragraph":"unknown-paragraph"}if(n.op==="acceptRevision"||n.op==="rejectRevision"||n.op==="acceptAllRevisions"||n.op==="rejectAllRevisions"){if(n.op==="acceptRevision"||n.op==="rejectRevision"){let i=n.revision;if(typeof i?.id!="string"||i.id.length===0||typeof i.author!="string"||i.date!==void 0&&typeof i.date!="string")return "invalid-property-value"}else if(n.scopeRootId!==void 0&&(typeof n.scopeRootId!="string"||n.scopeRootId.length===0||br(e,n.scopeRootId)===null))return "invalid-property-value";return null}let r=R(e,n.paragraphId);if(!r)return "unknown-paragraph";if(!En(r))return "not-a-paragraph";let o=Zn(r);switch(n.op){case "insertText":return !Number.isInteger(n.offset)||n.offset<0||n.offset>o?"offset-out-of-range":typeof n.text!="string"||!$(n.text)?"invalid-text":Be(r,n.offset)?"splits-surrogate-pair":n.bias!==void 0&&n.bias!=="left"&&n.bias!=="right"?"invalidArgs":n.inside!==void 0?null:At(e,r,n.offset,n.offset,n.bias);case "setListLevel":return !Number.isInteger(n.level)||n.level<0||n.level>8?"invalid-range":Te(e,n.paragraphId)?"bound":ve(e,n.paragraphId).content?"locked":null;case "proposeParagraphMerge":return typeof n.revision?.author!="string"||n.revision.author.length===0?"invalid-property-value":null;case "setParagraphMarkRevision":return n.kind!=="ins"&&n.kind!=="del"?"invalid-range":typeof n.revision?.author!="string"||n.revision.author.length===0?"invalid-property-value":null;case "setParagraphMarkProperties":if(!Array.isArray(n.properties))return "invalid-range";{let i=fu(n.properties,zO);if(i)return i}return Te(e,n.paragraphId)?"bound":ve(e,n.paragraphId).content?"locked":null;case "setParagraphTabStops":{if(!Array.isArray(n.stops)||n.stops.length>64)return "invalid-range";for(let i of n.stops)if(typeof i!="object"||i===null||!Number.isInteger(i.positionTwips)||i.positionTwips<0||i.positionTwips>31680||!["left","center","right","decimal","bar"].includes(i.alignment)||i.leader!==void 0&&!["none","dot","hyphen","underscore","heavy","middleDot"].includes(i.leader))return "invalid-range";if(new Set(n.stops.map(i=>Math.round(i.positionTwips))).size!==n.stops.length)return "invalid-range";if(n.inForcePositionsTwips!==void 0){if(!Array.isArray(n.inForcePositionsTwips)||n.inForcePositionsTwips.length>64)return "invalid-range";for(let i of n.inForcePositionsTwips)if(!Number.isInteger(i)||Math.abs(i)>31680)return "invalid-range"}return Te(e,n.paragraphId)?"bound":ve(e,n.paragraphId).content?"locked":null}case "setListNumbering":{let i=n.level??0;return !Number.isInteger(i)||i<0||i>8||n.numId!==null&&!/^\d{1,9}$/.test(n.numId)?"invalid-range":Te(e,n.paragraphId)?"bound":ve(e,n.paragraphId).content?"locked":null}case "insertTab":case "insertHardBreak":case "insertPageBreak":return !Number.isInteger(n.offset)||n.offset<0||n.offset>o?"offset-out-of-range":Be(r,n.offset)?"splits-surrogate-pair":At(e,r,n.offset,n.offset);case "insertPageField":return !Number.isInteger(n.offset)||n.offset<0||n.offset>o?"offset-out-of-range":Be(r,n.offset)?"splits-surrogate-pair":n.field!=="PAGE"&&n.field!=="NUMPAGES"&&n.field!=="SECTIONPAGES"&&n.field!=="PAGE_X_OF_Y"?"invalidArgs":At(e,r,n.offset,n.offset);case "splitParagraph":return !Number.isInteger(n.offset)||n.offset<0||n.offset>o?"offset-out-of-range":Be(r,n.offset)?"splits-surrogate-pair":mu(r,n.offset,n.offset+1)?"invalid-range":null;case "splitParagraphMany":{if(!Array.isArray(n.offsets)||n.offsets.length===0)return "invalid-range";let i=-1;for(let a of n.offsets){if(!Number.isInteger(a)||a<0||a>o)return "offset-out-of-range";if(a<i)return "invalid-range";if(i=a,Be(r,a))return "splits-surrogate-pair";let l=At(e,r,a,a);if(l)return l;if(mu(r,a,a+1))return "invalid-range"}return null}case "deleteText":return !Number.isInteger(n.start)||!Number.isInteger(n.end)?"invalid-range":n.start<0||n.end>o?"offset-out-of-range":n.start>=n.end?"invalid-range":Be(r,n.start)||Be(r,n.end)?"splits-surrogate-pair":mu(r,n.start,n.end)?"invalid-range":At(e,r,n.start,n.end);case "setRunProperties":{if(!Number.isInteger(n.start)||!Number.isInteger(n.end))return "invalid-range";if(n.start<0||n.end>o)return "offset-out-of-range";if(n.start>=n.end)return "invalid-range";{let i=fu(n.properties,zO);if(i)return i}return At(e,r,n.start,n.end)}case "setParagraphProperties":{let i=fu(n.properties,C0);return i||(Te(e,n.paragraphId)?"bound":ve(e,n.paragraphId).content?"locked":null)}case "insertInlineContentControl":return Number.isInteger(n.offset)?n.offset<0||n.offset>o?"offset-out-of-range":Be(r,n.offset)?"splits-surrogate-pair":typeof n.tag!="string"||n.tag.length===0||n.tag.length>64||typeof n.text!="string"||n.text.length===0||qO(r,n.offset,n.offset)||n.dataBinding!==void 0&&!Th(n.dataBinding)?"invalid-property-value":null:"invalid-range";case "insertHyperlink":{if(!Number.isInteger(n.start)||!Number.isInteger(n.end))return "invalid-range";if(n.start<0||n.end>o)return "offset-out-of-range";if(n.start>=n.end)return "invalid-range";if(Be(r,n.start)||Be(r,n.end))return "splits-surrogate-pair";if(qO(r,n.start,n.end)||n.styleId!==void 0&&(typeof n.styleId!="string"||n.styleId.length===0||n.styleId.length>ZO||!$(n.styleId)))return "invalid-property-value";{let i=At(e,r,n.start,n.end);if(i)return i}return YO(n)}case "setSectionMark":{let i=ye(r);return i&&St(i,"sectPr")||Bi(e,n.paragraphId)?"invalid-property-value":Te(e,n.paragraphId)?"bound":ve(e,n.paragraphId).content?"locked":null}default:return "unknown-op"}}function QO(e,n,t,r){let o=Pe(e),i=n.id===e.id?{start:0,end:o.length}:o.spanOf(n);if(!i)return null;let a=new Set,l=new Set;for(let d of o.segments)if(!((d.removeNodeIds?.length??0)<2))for(let c of d.removeNodeIds??[])l.add(c);if(l.size>0){let d=(u,f)=>l.has(u.id)?true:u.kind==="textValue"||f>8?false:u.children.some(m=>d(m,f+1)),c=false;for(let u of n.children){if(u.kind==="textValue"||!d(u,0)){c=false;continue}c&&a.add(u.id),c=true;}}let s=i.start;for(let d=0;d<n.children.length;d+=1){let c=n.children[d],u=c.kind==="paragraphProperties"||c.kind==="runProperties";if(s===t&&!u&&!a.has(c.id))return {containerId:n.id,index:d};if(c.kind==="textValue")continue;let f=o.lengthOf(c);if(t>s&&t<s+f&&r<S0){let m=A0(c);if(m){let g=QO(e,m,t,r+1);if(g)return g}}s+=f;}return s===t?{containerId:n.id,index:n.children.length}:null}var S0=32;function A0(e){return e.kind==="textValue"?null:he(e.kind)||e.kind==="hyperlink"?e:we(e)?Bn(e)??null:null}function JO(e,n,t,r){return {id:e,kind:n,namespaceUri:O,localName:t,prefix:"w",namespaceBindings:[],attributes:[{kind:"genericExtension",namespaceUri:O,localName:"id",prefix:"w",value:r}],children:[]}}function M0(e,n){return {id:e,kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:[JO(`${e}.0`,"commentReference","commentReference",n)]}}function _0(e){if(e.kind!=="run")return false;let n=false;for(let t of e.children){if(t.kind==="commentReference"){n=true;continue}if(t.kind!=="runProperties")return false}return n}function D0(e){return e.kind==="commentRangeStart"||e.kind==="commentRangeEnd"||_0(e)}function U0(e,n,t){let r=n;if(t==="start"||t==="end"){for(;r<e.children.length&&e.children[r].kind==="commentRangeStart";)r+=1;return r}for(;r<e.children.length&&D0(e.children[r]);)r+=1;return r}function eN(e,n,t,r){let o=Io(e,n,t.offset,r);if(!o.ok)return {ok:false,reason:o.reason};let i=R(o.part,n.id);if(!i||i.kind!=="paragraph")return {ok:false,reason:"tree-invariant"};let a=QO(i,i,t.offset,0);if(!a)return {ok:false,reason:"offset-out-of-range"};let l=a.index,s=R(o.part,a.containerId);s&&s.kind!=="textValue"&&(l=U0(s,a.index,t.marker));let d=`${e.name}#comment-${t.marker}-${t.commentId}-${t.offset}`,c=t.marker==="reference"?M0(d,t.commentId):JO(d,t.marker==="start"?"commentRangeStart":"commentRangeEnd",t.marker==="start"?"commentRangeStart":"commentRangeEnd",t.commentId),u=M(o.part,a.containerId,l,[c],r);return u.ok?{ok:true,part:u.part,effect:{dirty:[n.id],created:[],deleted:[],dependencyKeys:[sr.story],impact:"text-local"}}:{ok:false,reason:"tree-invariant",detail:JSON.stringify(u.issues)}}var gu=["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"],L0=["ins","del","moveFrom","moveTo","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"],tN={authorable:new Set(nr),sequence:gu},zl={authorable:new Set(er),sequence:L0};function nN(e,n,t){let r=Object.entries(e.attributes??{}).map(([i,a])=>({kind:"genericExtension",namespaceUri:O,localName:i,prefix:"w",value:a})),o=t&&t.kind!=="textValue"?t:void 0;return o&&B0(o,r)?t:{id:n,kind:"generic",namespaceUri:O,localName:e.localName,prefix:"w",namespaceBindings:[],attributes:r,children:o?.children??[]}}function B0(e,n){let t=e.attributes??[];if(t.length!==n.length)return false;for(let r of n){let o=t.find(i=>i.localName===r.localName);if(!o||o.value!==r.value)return false}return true}function qi(e,n){if(n.kind==="textValue")return e.length;let t=e.indexOf(n.localName);return t===-1?e.length:t}function Yi(e,n,t,r){let o=new Map;for(let l of n){let s=o.get(l.localName);s?s.push(l):o.set(l.localName,[l]);}let i=new Map,a=[];for(let l of e){if(l.kind==="textValue"||!t.authorable.has(l.localName)){a.push(l);continue}let s=i.get(l.localName)??0;i.set(l.localName,s+1);let d=o.get(l.localName)?.[s];d&&a.push(nN(d,r(),l));}for(let[l,s]of o)if(t.authorable.has(l))for(let d=i.get(l)??0;d<s.length;d+=1){let c=nN(s[d],r()),u=qi(t.sequence,c),f=a.findIndex(m=>qi(t.sequence,m)>u);f===-1?a.push(c):a.splice(f,0,c);}return F0(a,t.sequence)}function rN(e,n,t){let r=n.indexOf(t);if(r<0)return e.length;for(let o=0;o<e.length;o+=1){let i=e[o];if(!i||i.kind==="textValue")continue;let a=n.indexOf(i.localName);if(a>=0&&a>r)return o}return e.length}function F0(e,n){let t=[],r=[];e.forEach((a,l)=>{qi(n,a)!==n.length&&(t.push(l),r.push(a));});let o=[...e];if(r.length<2)return o;let i=[...r].sort((a,l)=>qi(n,a)-qi(n,l));return t.forEach((a,l)=>{o[a]=i[l];}),o}function hu(e){if(e.kind==="textValue")return;let n=e.children.filter(t=>!("localName"in t)||t.localName!=="sectPr");if(n.length===e.children.length)return e;if(n.length!==0)return {...e,children:n}}function me(e,n){return {kind:"genericExtension",namespaceUri:O,localName:e,prefix:"w",value:n}}function On(e,n,t,r){return {id:e,kind:"generic",namespaceUri:O,localName:n,prefix:"w",namespaceBindings:[],attributes:t,children:r}}var oN=e=>e&&e.kind!=="textValue"&&"attributes"in e?e.attributes:[],xu=e=>e&&e.kind!=="textValue"?e.children??[]:[];function lN(e,n,t){if(!xo(e))return {ok:false,reason:"tree-invariant",detail:"part has no body"};let o=n.pageWidthTwips!==void 0||n.pageHeightTwips!==void 0||n.orientation!==void 0,i=n.marginTopTwips!==void 0||n.marginRightTwips!==void 0||n.marginBottomTwips!==void 0||n.marginLeftTwips!==void 0,a={dirty:[],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"},l=S(e),s=ho(e,n.anchorParagraphId),d=new Map,c=null;for(let m of s){let g=H0(m,n,o,i,l);m?d.set(m.id,g):c=On(l(),"sectPr",[],g);}let u=m=>{if(m.kind==="textValue")return m;let g=d.get(m.id);if(g)return {...m,children:g};let p=false,x=m.children.map(y=>{let N=u(y);return N!==y&&(p=true),N});return m.kind==="body"&&c?{...m,children:[...x,c]}:p?{...m,children:x}:m},f=e.root.children.map(u);return T(L(e,e.root.id,f,t),a)}function sN(e,n,t,r,o){let i=ye(n),a=Vn(i,"numPr");if(!a)return {ok:false,reason:"not-a-list-paragraph"};let l={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"},s=a.children.find(c=>c.kind!=="textValue"&&c.localName==="ilvl"),d=On(o(),"ilvl",[me("val",String(t))],[]);return s?T(V(e,s.id,d,r),l):T(M(e,a.id,0,[d],r),l)}function dN(e,n,t,r,o,i){let a={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"},l=ye(n),s=Vn(l,"numPr");if(t===null)return s?T(oe(e,s.id,o),a):Le(e,a);let d=On(i(),"numPr",[],[On(i(),"ilvl",[me("val",String(r))],[]),On(i(),"numId",[me("val",t)],[])]);if(s)return T(V(e,s.id,d,o),a);if(l){let u=l.children.findIndex(f=>f.kind!=="textValue"&&f.localName==="pStyle")+1;return T(M(e,l.id,u,[d],o),a)}let c={id:i(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:[d]};return T(M(e,n.id,0,[c],o),a)}var V0=new Set(["bar","num"]),W0=64;function cN(e,n,t,r,o,i){let a={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"},l=ye(n),s=Vn(l,"tabs"),d=new Set(t.map(k=>Math.round(k.positionTwips))),c=(s?.children??[]).filter(k=>k.kind!=="textValue"&&k.localName==="tab"),u=k=>Math.round(Number(Ue(k,"pos"))),f=k=>Ue(k,"val")!=="clear"&&(V0.has(Ue(k,"val")??"")||!Number.isInteger(Number(Ue(k,"pos")))),m=c.filter(k=>f(k)&&!d.has(u(k))),g=c.filter(k=>Ue(k,"val")==="clear").map(u).filter(k=>Number.isFinite(k)&&!d.has(k)),p=[...new Set([...g,...(r??[]).map(k=>Math.round(k)).filter(k=>!d.has(k))])].sort((k,E)=>k-E),x=Math.max(0,W0-t.length),y=p.slice(0,x),N=m.slice(0,Math.max(0,x-y.length));if(t.length===0&&y.length===0&&N.length===0)return s?T(oe(e,s.id,o),a):Le(e,a);let b=[...t.map(k=>({...k,positionTwips:Math.round(k.positionTwips)})),...y.map(k=>({positionTwips:k,alignment:"clear"}))].sort((k,E)=>k.positionTwips-E.positionTwips).map(k=>On(i(),"tab",[me("val",k.alignment),me("pos",String(k.positionTwips)),..."leader"in k&&k.leader&&k.leader!=="none"?[me("leader",k.leader)]:[]],[])),h=On(i(),"tabs",[],[...b,...N.map(k=>Ke(k,i))].sort((k,E)=>Number(Ue(k,"pos")??0)-Number(Ue(E,"pos")??0)));if(s)return T(V(e,s.id,h,o),a);if(l){let k=rN(l.children,gu,"tabs");return T(M(e,l.id,k,[h],o),a)}let P={id:i(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:[h]};return T(M(e,n.id,0,[P],o),a)}function uN(e,n,t){let r=R(e,n),o=S(e),i=ho(e,n)[0]??null,a=yo(i),l={dirty:[n],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"},s=i?Ke(i,o):On(o(),"sectPr",[],[On(o(),"pgSz",[me("w",String(a.widthTwips)),me("h",String(a.heightTwips)),...a.widthTwips>a.heightTwips?[me("orient","landscape")]:[]],[]),On(o(),"pgMar",[me("top",String(a.topTwips)),me("right",String(a.rightTwips)),me("bottom",String(a.bottomTwips)),me("left",String(a.leftTwips)),me("header",String(a.headerTwips)),me("footer",String(a.footerTwips)),me("gutter",String(a.gutterTwips))],[])]),d=ye(r);if(!d){let u={id:o(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:[s]};return T(M(e,r.id,0,[u],t),l)}let c=d.children.findIndex(u=>"localName"in u&&u.localName==="pPrChange");return T(M(e,d.id,c===-1?d.children.length:c,[s],t),l)}function H0(e,n,t,r,o){let i=yo(e),a=St(e,"pgSz"),l=null;if(t){let{widthTwips:u,heightTwips:f}=Fi(i,n),m=u!==i.widthTwips||f!==i.heightTwips,g=n.orientation!==void 0?n.orientation==="landscape"?"landscape":void 0:jn(a,"orient"),p=new Set(["w","h","orient",...m?["code"]:[]]),x=oN(a).filter(y=>!p.has(y.localName));l=On(a?.id??o(),"pgSz",[me("w",String(u)),me("h",String(f)),...g?[me("orient",g)]:[],...x],xu(a));}let s=St(e,"pgMar"),d=null;if(r){let u=[["top",n.marginTopTwips,i.topTwips],["right",n.marginRightTwips,i.rightTwips],["bottom",n.marginBottomTwips,i.bottomTwips],["left",n.marginLeftTwips,i.leftTwips]];if(s){let f=new Set(u.filter(([,g])=>g!==void 0).map(([g])=>g)),m=oN(s).filter(g=>!f.has(g.localName));d=On(s.id,"pgMar",[...u.filter(([,g])=>g!==void 0).map(([g,p])=>me(g,String(p))),...m],xu(s));}else d=On(o(),"pgMar",[...u.map(([f,m,g])=>me(f,String(m??g))),me("header",String(i.headerTwips)),me("footer",String(i.footerTwips)),me("gutter",String(i.gutterTwips))],[]);}let c=[...xu(e)];return l&&(a?c=c.map(u=>u.id===a.id?l:u):c.splice(aN(c,"pgSz"),0,l)),d&&(s?c=c.map(u=>u.id===s.id?d:u):c.splice(aN(c,"pgMar"),0,d)),c}var iN=["pgSz","pgMar","paperSrc","pgBorders","lnNumType","pgNumType","cols","formProt","vAlign","noEndnote","titlePg","textDirection","bidi","rtlGutter","docGrid","printerSettings","sectPrChange"];function aN(e,n){let t=new Set(iN.slice(iN.indexOf(n)+1)),r=e.findIndex(o=>o.kind!=="textValue"&&"localName"in o&&t.has(o.localName));return r===-1?e.length:r}var j0=new Set(["sectPr","pPrChange"]);function fN(e,n,t,r,o){let i={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"},a=ye(n),l=Vn(a,"rPr"),s=Yi(l?.children??[],t,zl,o);if(s.length===0)return l?T(oe(e,l.id,r),i):Le(e,i);let d=On(l?.id??o(),"rPr",[],s);if(l)return T(V(e,l.id,d,r),i);if(a){let u=a.children.findIndex(m=>m.kind!=="textValue"&&j0.has(m.localName)),f=u===-1?a.children.length:u;return T(M(e,a.id,f,[d],r),i)}let c={id:o(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:[d]};return T(M(e,n.id,0,[c],r),i)}function yu(e,n){return {id:e(),kind:"fldChar",namespaceUri:O,localName:"fldChar",prefix:"w",namespaceBindings:[],attributes:[{kind:"genericExtension",namespaceUri:O,localName:"fldCharType",prefix:"w",value:n}],children:[]}}function K0(e,n){let t=e();return {id:e(),kind:"instrText",namespaceUri:O,localName:"instrText",prefix:"w",namespaceBindings:[],attributes:[{kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:"preserve"}],children:[{id:t,kind:"textValue",value:` ${n} `}]}}function G0(e,n){let t=e();return {id:e(),kind:"text",namespaceUri:O,localName:"t",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:t,kind:"textValue",value:n}]}}function mN(e){let n=t=>[r=>yu(r,"begin"),r=>K0(r,t),r=>yu(r,"separate"),r=>yu(r,"end")];return e==="PAGE_X_OF_Y"?[...n("PAGE"),t=>G0(t," of "),...n("NUMPAGES")]:[...n(e)]}var $0={richText:"richText",plainText:"text",dropDownList:"dropDownList",comboBox:"comboBox",date:"date"};function z0(e){let n=0;for(let t of Se(e.root)){let r=Wn(t.node).id;r!==void 0&&r>n&&(n=r);}return n>=2147483647?null:n+1}function pN(e,n,t){let r=z0(e),o=ji(void 0,{...n.tag===void 0?{}:{tag:n.tag},...n.alias===void 0?{}:{alias:n.alias},...r===null?{}:{id:r},...n.lock===void 0?{}:{lock:n.lock},...n.start===n.end?{showingPlaceholder:true}:{}},t),i=Mt(t,$0[n.type]);return {...o,children:hl([...o.children,i])}}function gN(e,n,t){let r=Mt(t,"sdtContent",{kind:"contentControlContent",children:n});return Mt(t,"sdt",{kind:"contentControl",children:[e,r]})}function xN(e,n,t){let r=R(e,n.paragraphId);return r?r.kind!=="paragraph"?{ok:false,reason:"not-a-paragraph"}:fo(Nc(e,n.paragraphId))?{ok:false,reason:"locked"}:n.start<0||n.end>Zn(r)||n.start>n.end?{ok:false,reason:"invalid-range"}:Be(r,n.start)||Be(r,n.end)?{ok:false,reason:"splits-surrogate-pair"}:co(r,n.start)||co(r,n.end)?{ok:false,reason:"indivisible-content"}:n.start===n.end?Z0(e,r,n,t):X0(e,n,t):{ok:false,reason:"unknown-paragraph"}}function X0(e,n,t){let r=e;for(let m of [n.end,n.start]){let g=R(r,n.paragraphId);if(!g||g.kind!=="paragraph")return {ok:false,reason:"tree-invariant"};let p=Io(r,g,m,t);if(!p.ok)return {ok:false,reason:p.reason};r=p.part;}let o=R(r,n.paragraphId);if(!o||o.kind!=="paragraph")return {ok:false,reason:"tree-invariant"};let i=Pe(o),a=[],l=false;for(let m of o.children){let g=i.spanOf(m);if(!(!g||g.start===g.end)){if(g.start>=n.start&&g.end<=n.end){a.push(m),l=true;continue}if(g.start<n.end&&g.end>n.start)return {ok:false,reason:"invalid-range"}}}if(!l)return {ok:false,reason:"invalid-range"};let s=S(r),d=gN(pN(r,n,s),a,s),c=new Set(a.map(m=>m.id)),u=false,f=[];for(let m of o.children){if(!c.has(m.id)){f.push(m);continue}u||(f.push(d),u=true);}return T(L(r,o.id,f,t),Oo(o.id,"flow-structural"))}function q0(e,n,t,r){let o=n.segments,i=null;for(let s of o)s.end<=t&&s.end>0&&(i=s);i??=o.find(s=>s.start>=t)??null;let a=i?R(e,i.runId):null,l=a&&a.kind==="run"?Yn(a):null;return l?Ml(l,r):void 0}function Y0(e){let n=new Map;for(let t of e.segments){if(!t.removeNodeIds)continue;let r={start:t.start,end:t.end};for(let o of t.removeNodeIds)n.set(o,r);}return n.size===0?()=>null:t=>{let r=n.get(t.id);if(r)return r;if(t.kind==="textValue")return null;for(let o of t.children){let i=n.get(o.id);if(i)return i}return null}}function Z0(e,n,t,r){let o=t.start,i=Io(e,n,o,r);if(!i.ok)return {ok:false,reason:i.reason};let a=i.part,l=R(a,t.paragraphId);if(!l||l.kind!=="paragraph")return {ok:false,reason:"tree-invariant"};let s=Pe(l),d=S(a),c=Pc(d,Oc(t.type),q0(a,s,o,d)),u=gN(pN(a,t,d),[c],d),f=Y0(s),m=[],g=[],p=0;for(let x of l.children){if(dt(x)){m.push(x);continue}let y=s.spanOf(x),N=y&&y.start!==y.end?y:f(x)??y;if(!N||N.start===N.end){(p<o?m:g).push(x);continue}p=N.end,(N.end<=o?m:g).push(x);}return T(L(a,l.id,[...m,u,...g],r),Oo(l.id,"flow-structural"))}function Gn(e,n,t="text"){let r=e();return {id:e(),kind:t,namespaceUri:O,localName:t==="deletedText"?"delText":"t",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:r,kind:"textValue",value:n}]}}function Ou(e,n,t="line"){return {id:e(),kind:n==="tab"?"tab":"hardBreak",namespaceUri:O,localName:n,prefix:"w",namespaceBindings:[],attributes:n==="br"?[...$p(t)]:[],children:[]}}function Q0(e,n,t){let r=R(e,n);return !r||r.kind!=="paragraph"?t:Math.min(t,Zn(r))}function kn(e,n){return {id:e(),kind:"run",namespaceUri:O,localName:"r",prefix:"w",namespaceBindings:[],attributes:[],children:n}}function ql(e,n,t){let r=pu(e,n);if(r)return {ok:false,reason:r};if(n.op==="replaceStoryBlocks")return $O(e,n.storyRootId,n.paragraphs,t);if(n.op==="setContentControlValue"&&typeof n.value!="string")return My(e,n,t);if(n.op==="setContentControlProperties")return _y(e,n,t);if(n.op==="removeContentControl"&&n.keepContent!==void 0)return Ec(e,n,t);if(n.op==="insertContentControl")return xN(e,n,t);if(n.op==="insertText"&&!n.revision){let a=Dy(e,n.paragraphId,n.offset);if(a){let l=Uy(e,a.control.id,t);if(l)return ql(l,{...n,offset:Q0(l,n.paragraphId,a.offset)},t)}}if(n.op==="insertTableRow"||n.op==="deleteTableRow")return wO(e,n,t);if(n.op==="insertTableColumn"||n.op==="deleteTableColumn")return vO(e,n,t);if(n.op==="setTableColumnWidths"||n.op==="setTableRightEdgeWidth"||n.op==="setTableRowHeight")return MO(e,n,t);if(n.op==="setTableCellBorders"||n.op==="setTableCellFill"||n.op==="setTableCellVerticalAlignment")return Zc(e,n,t);if(Cl(n))return my(e,n,t);if(n.op==="insertTable")return KO(e,n,t);if(n.op==="deleteBlock")return NM(e,n.blockId,t);if(n.op==="insertToc")return VO(e,n,t);if(n.op==="replaceTocResult")return WO(e,n,t);if(n.op==="rewriteTocPageNumbers")return HO(e,n,t);if(n.op==="joinParagraphs")return ku(e,n.firstId,n.secondId,t);if(n.op==="setHyperlinkTarget")return sM(e,n,t);if(n.op==="removeHyperlink")return dM(e,n.linkId,t);if(n.op==="setMathEquation"||n.op==="removeMathEquation"){let a=R(e,n.equationId);if(!a||a.kind==="textValue")return {ok:false,reason:"tree-invariant"};let l=a,s=null;for(;l;){if(l.kind==="paragraph"){s=l;break}l=Z(e,l.id);}if(!s)return {ok:false,reason:"tree-invariant"};let d={dirty:[s.id],created:[],deleted:[],dependencyKeys:W,impact:"text-local"};if(n.op==="removeMathEquation")return T(oe(e,a.id,t),d);let c=Up(n.linear,S(e));if(!c.ok)return {ok:false,reason:"invalid-property-value"};let u={...c.equation,id:a.id};return T(V(e,a.id,u,t),d)}if(n.op==="insertCommentMarker"){let a=R(e,n.paragraphId);return !a||a.kind!=="paragraph"?{ok:false,reason:"not-a-paragraph"}:eN(e,a,n,t)}if(n.op==="acceptRevision"||n.op==="rejectRevision"||n.op==="acceptAllRevisions"||n.op==="rejectAllRevisions"){let a=n.op==="acceptRevision"||n.op==="acceptAllRevisions",l=n.op==="acceptRevision"||n.op==="rejectRevision"?n.revision:void 0,s=n.op==="acceptRevision"||n.op==="rejectRevision"?n.localName:void 0,d=n.op==="acceptAllRevisions"||n.op==="rejectAllRevisions"?n.scopeRootId:void 0,c=Hh(e,a?"accept":"reject",l,{...t,...s===void 0?{}:{localName:s},...d===void 0?{}:{scopeRootId:d}});return !c.ok||!c.part||!c.effect?{ok:false,reason:c.reason??"tree-invariant"}:{ok:true,part:c.part,effect:c.effect}}if(n.op==="removeContentControl")return bN(e,n.controlId,t);if(n.op==="setContentControlValue")return typeof n.value!="string"?{ok:false,reason:"typeMismatch"}:uM(e,n.controlId,n.value,t);if(n.op==="setSectionProperties")return lN(e,n,t);if(n.op==="setSectionMark")return uN(e,n.paragraphId,t);if(n.op==="createHeaderFooter"||n.op==="deleteHeaderFooter"||n.op==="linkToPrevious"||n.op==="unlinkFromPrevious"||n.op==="setSectionFurnitureOptions"||n.op==="insertNote"||n.op==="deleteNote"||n.op==="convertNote"||n.op==="convertAllNotes"||n.op==="setNoteProperties")return {ok:false,reason:"invalidArgs",detail:"package-lifecycle-op"};if(n.op==="addRepeatingSectionItem"||n.op==="removeRepeatingSectionItem")return {ok:false,reason:"unsupported"};let o=R(e,n.paragraphId),i=S(e);switch(n.op){case "insertText":return n.revision?Hy(e,o,n.offset,n.text,n.revision,t):Zi(e,o,n.offset,[a=>Gn(a,n.text)],t,n.inside,n.bias);case "insertTab":return Zi(e,o,n.offset,[a=>Ou(a,"tab")],t);case "insertHardBreak":return Zi(e,o,n.offset,[a=>Ou(a,"br","line")],t);case "setListLevel":return sN(e,o,n.level,t,i);case "setParagraphMarkProperties":return fN(e,o,n.properties,t,i);case "setListNumbering":return dN(e,o,n.numId,n.level??0,t,i);case "setParagraphTabStops":return cN(e,o,n.stops,n.inForcePositionsTwips,t,i);case "insertPageBreak":return Zi(e,o,n.offset,[a=>Ou(a,"br","page")],t);case "insertPageField":return Zi(e,o,n.offset,mN(n.field),t);case "deleteText":return n.revision?Gy(e,o,n.start,n.end,n.revision,t):rM(e,o,n.start,n.end,t);case "insertHyperlink":return iM(e,o,n,t);case "insertInlineContentControl":return aM(e,o,n,t);case "setParagraphMarkRevision":{if(n.kind==="del"&&Fc(o,n.revision.author)){let a=Z(e,o.id),l=a?.children.findIndex(d=>d.id===o.id)??-1,s=l>=0?a?.children[l+1]:void 0;if(s&&s.kind==="paragraph")return ku(e,o.id,s.id,t)}return Ll(e,o,n.kind,n.revision,t)}case "proposeParagraphMerge":{let a=Z(e,o.id),l=a?.children.findIndex(d=>d.id===o.id)??-1,s=l>0?a?.children[l-1]:void 0;return s&&s.kind==="paragraph"&&Fc(s,n.revision.author)?ku(e,s.id,o.id,t):zy(e,o,n.revision,t)}case "splitParagraph":return xM(e,o,n.offset,t);case "splitParagraphMany":{let a=hM(e,o,n.offsets,t);if(!n.revision||!a.ok)return a;let l=[o.id,...a.effect.created.slice(0,-1)],s=a;for(let d of l){let c=R(s.part,d);if(!c||c.kind!=="paragraph")continue;let u=Ll(s.part,c,"ins",n.revision,t);if(!u.ok)return u;s={...u,effect:{...a.effect}};}return s}case "setRunProperties":return wM(e,o,n.start,n.end,n.properties,t,n.targetRunIds);case "setParagraphProperties":{let a=ye(o),l=Yi(a?.children??[],n.properties,tN,i),s={dirty:[o.id],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"};if(l.length===0)return a?T(oe(e,a.id,t),s):Le(e,s);if(a)return T(L(e,a.id,l,t),s);let d={id:i(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:l};return T(M(e,o.id,0,[d],t),s)}default:return {ok:false,reason:"unknown-op"}}}function Zi(e,n,t,r,o,i,a="left"){let l=Wi(e,n,t,t,a);if(l&&ki(l))return J0(e,l,r,o);let s=S(e),d=r.map(h=>h(s)),c=Q(n),u={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"text-local"},f=i===void 0?null:R(e,i);if(i!==void 0&&(f===null||f.kind==="textValue"))return {ok:false,reason:"unknown-content-control"};let m=f?.kind==="textValue"?null:f,g=Md(n,t,m),p;if(g.kind==="withinValue"){let h=g.segment;if(h.node.kind!=="textValue")return {ok:false,reason:"tree-invariant"};let P=t-h.start,k=h.node.value,E=ON(n,h.node.id);if(!E)return {ok:false,reason:"tree-invariant",detail:"orphan text value"};let w=R(e,h.runId);if(!w||w.kind!=="run")return {ok:false,reason:"tree-invariant"};if(E.kind==="deletedText"){let C=Nu(e,n,w,d,"after",{nextId:s,effect:u,control:l,options:o});if(C)return C}let I=E.kind==="deletedText"?"deletedText":"text",A=Gn(s,k.slice(0,P),I),U=Gn(s,k.slice(P),I),B=w.children.flatMap(C=>C.id===E.id?[A,...d,U]:[C]);return p=T(L(e,w.id,B,vn(o,l)),u),Nn(p,l,o)}if(i!==void 0){if(g.kind==="atBoundary"){let h=R(e,g.segment.runId);if(!h||h.kind!=="run")return {ok:false,reason:"tree-invariant"};let P=h.children.findIndex(k=>vr(k,g.segment.node.id));return p=T(M(e,h.id,Math.max(0,P),d,vn(o,l)),u),Nn(p,l,o)}return g.kind==="appendToRun"?(p=T(M(e,g.run.id,g.run.children.length,d,vn(o,l)),u),Nn(p,l,o)):(p=T(M(e,g.holder.id,g.holder.children.length,[kn(s,d)],vn(o,l)),u),Nn(p,l,o))}let x=yN(c,h=>h.end===t),y=c.find(h=>h.start===t);if(a==="left"&&x&&x.removeNodeIds===void 0&&!nM(e,x,y)&&!tM(n,x,y)){let h=R(e,x.runId);if(!h||h.kind!=="run")return {ok:false,reason:"tree-invariant"};let P=Nu(e,n,h,d,"after",{nextId:s,effect:u,control:l,options:o});if(P)return P;let k=h.children.findIndex(E=>vr(E,x.node.id));return p=T(M(e,h.id,k<0?h.children.length:k+1,d,vn(o,l)),u),Nn(p,l,o)}if(y){let h=R(e,y.runId);if(!h||h.kind!=="run"){let E=Z(e,y.node.id);if(y.removeNodeIds!==void 0&&E?.kind==="paragraph"&&E.id===n.id){let w=E.children.findIndex(I=>I.id===y.node.id);return w<0?{ok:false,reason:"tree-invariant"}:(p=T(M(e,E.id,w,[kn(s,d)],vn(o,l)),u),Nn(p,l,o))}return {ok:false,reason:"tree-invariant"}}let P=Nu(e,n,h,d,"before",{nextId:s,effect:u,control:l,options:o});if(P)return P;let k=h.children.findIndex(E=>vr(E,y.node.id));return p=T(M(e,h.id,Math.max(0,k),d,vn(o,l)),u),Nn(p,l,o)}if(x){let h=ao(n,x.runId);if(h){let P=Z(e,h.id);if(P){let k=P.children.findIndex(E=>E.id===h.id);if(k>=0)return p=T(M(e,P.id,k+1,[kn(s,d)],vn(o,l)),u),Nn(p,l,o)}}}if(x?.removeNodeIds&&x.removeNodeIds.length===1){let h=R(e,x.removeNodeIds[0]),P=h?Z(e,h.id):null;if(h&&P?.kind==="paragraph"&&P.id===n.id){let k=P.children.findIndex(E=>E.id===h.id);return k<0?{ok:false,reason:"tree-invariant"}:(p=T(M(e,P.id,k+1,[kn(s,d)],vn(o,l)),u),Nn(p,l,o))}}let N=n.children.filter(h=>h.kind==="run"),b=N[N.length-1];return b?(p=T(M(e,b.id,b.children.length,d,vn(o,l)),u),Nn(p,l,o)):(p=T(M(e,n.id,n.children.length,[kn(s,d)],vn(o,l)),u),Nn(p,l,o))}function Nu(e,n,t,r,o,i){let a=null,l=false;for(let f=Z(e,t.id);f&&f.id!==n.id;f=Z(e,f.id))he(f.kind)&&(a=f,(f.kind==="revisionDelete"||f.kind==="revisionMoveFrom")&&(l=true));if(!l||!a)return null;let s=Z(e,a.id);if(!s)return {ok:false,reason:"tree-invariant"};let d=s.children.findIndex(f=>f.id===a.id);if(d<0)return {ok:false,reason:"tree-invariant"};let c=(t.kind==="textValue"?[]:t.children).filter(f=>Yt(f)).map(f=>Ke(f,i.nextId)),u=T(M(e,s.id,o==="after"?d+1:d,[kn(i.nextId,[...c,...r])],vn(i.options,i.control)),i.effect);return Nn(u,i.control,i.options)}function vn(e,n){return n&&ln(n)?{...e,deferValidation:true}:e}function Nn(e,n,t){if(!e.ok||!n||!ln(n)||!qn(e.part,n.id))return e;let o=bN(e.part,n.id,t);return o.ok?Le(o.part,{dirty:[...new Set([...e.effect.dirty,...o.effect.dirty])],created:e.effect.created,deleted:e.effect.deleted,dependencyKeys:W,impact:"flow-structural"}):o}function J0(e,n,t,r){let o=S(e),i=t.map(f=>f(o)),a=Z(e,n.id),l=a?.kind==="paragraph",s=kn(o,i),d=l?[s]:[{id:o(),kind:"paragraph",namespaceUri:O,localName:"p",prefix:"w",namespaceBindings:[],attributes:[],children:[s]}],c=PN(n,d,o);c=To(c,pt);let u={dirty:a?[a.id]:[n.id],created:l?[]:d.map(f=>f.id),deleted:l?[]:eM(n),dependencyKeys:W,impact:!l||ln(n)?"flow-structural":"text-local"};if(ln(n)){if(!a)return {ok:false,reason:"tree-invariant"};let f=al(c);if(!f)return {ok:false,reason:"tree-invariant"};let m=a.children.flatMap(g=>g.id===n.id?f:[g]);return T(L(e,a.id,m,r),{...u,impact:"flow-structural"})}return T(V(e,n.id,c,r),u)}function eM(e){if(e.kind==="textValue")return [];let n=Bn(e);if(!n)return [];let t=[],r=(o,i)=>{if(!(o.kind==="textValue"||i>32)){if(o.kind==="paragraph"){t.push(o.id);return}for(let a of o.children)r(a,i+1);}};for(let o of n.children)r(o,0);return t}function yN(e,n){for(let t=e.length-1;t>=0;t-=1){let r=e[t];if(n(r))return r}}function nM(e,n,t){let r=je(e,n.runId)?.id,o=t?je(e,t.runId)?.id:void 0;return r!==o}function tM(e,n,t){let r=i=>{let a=null,l=(s,d)=>{if(s.kind==="textValue"||a)return;if(s.id===i){a=d;return}let c=s.kind==="hyperlink"||s.kind==="fldSimple"||s.kind==="contentControl"||s.kind==="generic"&&s.localName==="fldSimple"?s:d;for(let u of s.children)l(u,c);};for(let s of e.children)l(s,null);return a},o=r(n.runId);return o===null?false:t===void 0||r(t.runId)!==o}function vr(e,n){return e.id===n?true:e.kind==="textValue"?false:e.children.some(t=>vr(t,n))}function Xl(e,n){let t=r=>{if(r.kind==="textValue")return null;if((r.kind==="text"||r.kind==="deletedText")&&r.children.some(o=>o.id===n))return r.kind;for(let o of r.children){let i=t(o);if(i)return i}return null};return t(e)??"text"}function ON(e,n){let t=r=>{if(r.kind==="textValue")return null;if((r.kind==="text"||r.kind==="deletedText")&&r.children.some(o=>o.id===n))return r;for(let o of r.children){let i=t(o);if(i)return i}return null};return t(e)}function rM(e,n,t,r,o){let i=Wi(e,n,t,r),a=vn(o,i),l=Q(n),s={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"text-local"},d=e,c=S(e);for(let f of [...l].reverse()){if(f.end<=t||f.start>=r)continue;if(f.removeNodeIds&&f.removeNodeIds.length>0){for(let N of f.removeNodeIds){if(!R(d,N))continue;let b=oe(d,N,o);if(!b.ok)return T(b,s);d=b.part;}continue}if(f.node.kind!=="textValue"){let N=oe(d,f.node.id,a);if(!N.ok)return T(N,s);d=N.part;continue}let m=Math.max(0,t-f.start),g=Math.min(f.node.value.length,r-f.start),p=f.node.value.slice(0,m)+f.node.value.slice(g),x=ON(n,f.node.id);if(!x)return {ok:false,reason:"tree-invariant",detail:"orphan text value"};let y=p.length===0?oe(d,x.id,a):V(d,x.id,Gn(c,p,x.kind==="deletedText"?"deletedText":"text"),a);if(!y.ok)return T(y,s);d=y.part;}let u=R(d,n.id);if(u&&u.kind==="paragraph"){let f=g=>{for(let p of g){if(p.kind==="hyperlink"){let N=f(p.children);if(N)return N;let b=R(d,p.id);if(b&&b.kind!=="textValue"&&Zt(b).length===0){let h=Z(d,p.id);if(!h)return {ok:false,reason:"tree-invariant"};let P=L(d,h.id,h.children.flatMap(k=>k.id===p.id?[...b.children]:[k]),a);if(!P.ok)return T(P,s);d=P.part;}continue}if(p.kind!=="textValue"&&he(p.kind)){let N=f(p.children);if(N)return N;let b=R(d,p.id);if(b&&b.kind!=="textValue"&&Zt(b).length===0){let h=Z(d,p.id);if(!h)return {ok:false,reason:"tree-invariant"};let P=L(d,h.id,h.children.flatMap(k=>k.id===p.id?[...b.children]:[k]),a);if(!P.ok)return T(P,s);d=P.part;}continue}if(we(p)){let N=Bn(p);if(N){let b=f(N.children);if(b)return b}continue}if(p.kind!=="run"||p.children.some(N=>!Yt(N)))continue;let y=oe(d,p.id,a);if(!y.ok)return T(y,s);d=y.part;}return null},m=f(u.children);if(m)return m}return Nn(Le(d,s),i,o)}var Co="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function oM(e,n,t){let r=[{kind:"genericExtension",namespaceUri:O,localName:"history",prefix:"w",value:"1"}];n.relationshipId!==void 0&&r.push({kind:"genericExtension",namespaceUri:Co,localName:"id",prefix:"r",value:n.relationshipId}),n.anchor!==void 0&&r.push({kind:"genericExtension",namespaceUri:O,localName:"anchor",prefix:"w",value:n.anchor}),n.tooltip!==void 0&&r.push({kind:"genericExtension",namespaceUri:O,localName:"tooltip",prefix:"w",value:n.tooltip});let o=n.relationshipId!==void 0?[{prefix:"r",namespaceUri:Co}]:[];return {id:e(),kind:"hyperlink",namespaceUri:O,localName:"hyperlink",prefix:"w",namespaceBindings:o,attributes:r,children:t}}function NN(e,n,t){if(e.kind==="hyperlink")return Ne(e,e.children.map(l=>NN(l,n,t)),null);if(e.kind!=="run")return e;let r={id:t(),kind:"generic",namespaceUri:O,localName:"rStyle",prefix:"w",namespaceBindings:[],attributes:[{kind:"genericExtension",namespaceUri:O,localName:"val",prefix:"w",value:n}],children:[]},o=Yn(e);if(!o){let l={id:t(),kind:"runProperties",namespaceUri:O,localName:"rPr",prefix:"w",namespaceBindings:[],attributes:[],children:[r]};return Ne(e,[l,...e.children],null)}let i=o.children.filter(l=>l.kind==="textValue"||l.localName!=="rStyle"||l.namespaceUri!==O),a=Ne(o,[r,...i],null);return Ne(e,e.children.map(l=>l.id===o.id?a:l),null)}function iM(e,n,t,r){let o=S(e),i=Q(n),a=[],l=[],s=[],d={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"},c=0;for(let p of n.children){if(dt(p))continue;let x=gt(p,i);if(x.length===0){(c<t.start?a:c<t.end?l:s).push(p);continue}let y=x[0].start,N=x[x.length-1].end;if(c=N,N<=t.start){a.push(p);continue}if(y>=t.end){s.push(p);continue}if(y>=t.start&&N<=t.end){l.push(p);continue}let[b,h,P]=Qi(p,[t.start,t.end],3,i,o);a.push(...b),l.push(...h),s.push(...P);}if(l.length===0)return {ok:false,reason:"invalid-range"};let u=t.styleId===void 0?l:l.map(p=>NN(p,t.styleId,o)),f=oM(o,t,u),m=ye(n),g=[...m?[m]:[],...a,f,...s];return T(L(e,n.id,g,r),d)}function aM(e,n,t,r){let o=S(e),i=Q(n),a=[],l=[],s={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"},d=0;for(let x of n.children){if(dt(x))continue;let y=gt(x,i);if(y.length===0){(d<t.offset?a:l).push(x);continue}let N=y[0].start,b=y[y.length-1].end;if(d=b,b<=t.offset){a.push(x);continue}if(N>=t.offset){l.push(x);continue}let[h,P]=Qi(x,[t.offset],2,i,o);a.push(...h),l.push(...P);}let c=yN(i,x=>x.end<=t.offset&&x.end>0)??i.find(x=>x.start>=t.offset),u=c?R(e,c.runId):null,f=u&&u.kind==="run"?Yn(u):null,m=lM(o,t,f?kN(f,o):null),g=ye(n),p=[...g?[g]:[],...a,m,...l];return T(L(e,n.id,p,r),s)}function kN(e,n){return e.kind==="textValue"?{id:n(),kind:"textValue",value:e.value}:{...e,id:n(),children:e.children.map(t=>kN(t,n))}}function lM(e,n,t=null){let r=(u,f)=>({kind:"genericExtension",namespaceUri:O,localName:u,prefix:"w",value:f}),o=(u,f)=>({id:e(),kind:"generic",namespaceUri:O,localName:u,prefix:"w",namespaceBindings:[],attributes:[{kind:"genericExtension",namespaceUri:O,localName:"val",prefix:"w",value:f}],children:[]}),i=e(),a=String(fi(`${i} ${n.tag}`)&2147483647||1),l=n.dataBinding,s=()=>({id:e(),kind:"contentControlDataBinding",namespaceUri:O,localName:"dataBinding",prefix:"w",namespaceBindings:[],attributes:[r("prefixMappings",l.prefixMappings),r("xpath",l.xpath),r("storeItemID",l.storeItemId)],children:[]}),d={id:i,kind:"contentControlProperties",namespaceUri:O,localName:"sdtPr",prefix:"w",namespaceBindings:[],attributes:[],children:[...n.alias===void 0?[]:[o("alias",n.alias)],o("tag",n.tag),o("id",a),...n.lock===void 0?[]:[o("lock",n.lock)],...l?[s()]:[]]},c={id:e(),kind:"contentControlContent",namespaceUri:O,localName:"sdtContent",prefix:"w",namespaceBindings:[],attributes:[],children:[kn(e,[...t?[t]:[],Gn(e,n.text)])]};return {id:e(),kind:"contentControl",namespaceUri:O,localName:"sdt",prefix:"w",namespaceBindings:[],attributes:[],children:[d,c]}}function sM(e,n,t){let r=R(e,n.linkId);if(!r||r.kind!=="hyperlink")return {ok:false,reason:"tree-invariant"};let o=Z(e,r.id);if(!o)return {ok:false,reason:"tree-invariant"};let i=r.attributes.filter(c=>c.namespaceUri===Co&&c.localName==="id"?false:c.namespaceUri!==O?true:c.localName==="anchor"?false:c.localName==="tooltip"?n.tooltip===void 0:true),a=[];n.relationshipId!==void 0&&a.push({kind:"genericExtension",namespaceUri:Co,localName:"id",prefix:"r",value:n.relationshipId}),n.anchor!==void 0&&a.push({kind:"genericExtension",namespaceUri:O,localName:"anchor",prefix:"w",value:n.anchor}),n.tooltip!==void 0&&a.push({kind:"genericExtension",namespaceUri:O,localName:"tooltip",prefix:"w",value:n.tooltip});let l=r.namespaceBindings;n.relationshipId!==void 0&&!l.some(c=>c.prefix==="r"&&c.namespaceUri===Co)&&(l=[...l,{prefix:"r",namespaceUri:Co}]);let s={...r,namespaceBindings:l,attributes:[...i,...a]},d={dirty:[o.id],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"};return T(V(e,r.id,s,t),d)}function dM(e,n,t){let r=R(e,n);if(!r||r.kind!=="hyperlink")return {ok:false,reason:"tree-invariant"};let o=Z(e,r.id);if(!o)return {ok:false,reason:"tree-invariant"};let i=o.children.flatMap(l=>l.id===r.id?[...r.children]:[l]),a={dirty:[o.id],created:[],deleted:[],dependencyKeys:W,impact:"paragraph-local"};return T(L(e,o.id,i,t),a)}function bN(e,n,t){let r=qn(e,n);if(!r)return {ok:false,reason:"tree-invariant"};let o=Z(e,r.id);if(!o)return {ok:false,reason:"tree-invariant"};let i=al(r);if(!i)return {ok:false,reason:"tree-invariant"};let a=o.children.flatMap(s=>s.id===r.id?i:[s]),l={dirty:[o.id],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"};return T(L(e,o.id,a,t),l)}function cM(e,n,t){let r=[];return t&&r.push({id:e(),kind:"runProperties",namespaceUri:O,localName:"rPr",prefix:"w",namespaceBindings:[],attributes:[],children:[{id:e(),kind:"generic",namespaceUri:O,localName:"rFonts",prefix:"w",namespaceBindings:[],attributes:[{namespaceUri:O,prefix:"w",localName:"ascii",value:t},{namespaceUri:O,prefix:"w",localName:"hAnsi",value:t},{namespaceUri:O,prefix:"w",localName:"eastAsia",value:t}],children:[]}]}),/^[0-9A-Fa-f]{4}$/.test(n)&&t?r.push({id:e(),kind:"generic",namespaceUri:O,localName:"sym",prefix:"w",namespaceBindings:[],attributes:[{namespaceUri:O,prefix:"w",localName:"font",value:t},{namespaceUri:O,prefix:"w",localName:"char",value:n}],children:[]}):r.push(Gn(e,n)),kn(e,r)}function PN(e,n,t){if(e.kind==="textValue")return e;let r=Bn(e),o=r?Ne(r,n,null):{id:t(),kind:"generic",namespaceUri:O,localName:"sdtContent",prefix:"w",namespaceBindings:[],attributes:[],children:n},i=[],a=false;for(let l of e.children){if(l.kind!=="textValue"&&l.localName==="sdtContent"){i.push(o),a=true;continue}i.push(l);}return a||i.push(o),Ne(e,i,null)}function pt(e){let n=e.children;return Ne(e,n.filter(t=>t.kind==="textValue"||t.localName!=="showingPlcHdr"),null)}function To(e,n){if(e.kind==="textValue")return e;let t=Xn(e);if(!t)return e;let r=n(t);return Ne(e,e.children.map(o=>o.id===t.id?r:o),null)}function hN(e,n){let t=e.attributes.filter(r=>r.localName!=="lastValue");return {...e,attributes:[...t,{namespaceUri:O,prefix:"w",localName:"lastValue",value:n}]}}function uM(e,n,t,r){let o=qn(e,n);if(!o)return {ok:false,reason:"tree-invariant"};let i=S(e),a=Z(e,o.id),l=a?.kind==="paragraph",s=lo(o),d=o,c=(f,m)=>{let g=cM(i,f,m),p=Bn(d),x=!l&&p?.children.length===1?p.children[0]:void 0,y=x?.kind==="paragraph"?{...x,children:[...x.children.filter(dt),g]}:void 0,N=l?[g]:[y??{id:i(),kind:"paragraph",namespaceUri:O,localName:"p",prefix:"w",namespaceBindings:[],attributes:[],children:[g]}];d=PN(d,N,i),d=To(d,pt);};switch(s){case "dropdown":{let m=bi(o).find(g=>g.value===t);if(!m)return {ok:false,reason:"invalidArgs"};d=To(d,g=>{let p=Ie(g,"dropDownList");if(!p)return pt(g);let x=g.children;return Ne(pt(g),x.map(y=>y.id===p.id?hN(p,t):y),null)}),c(m.displayText);break}case "combo":{let g=bi(o).find(p=>p.value===t)?.displayText??t;d=To(d,p=>{let x=Ie(p,"comboBox");if(!x)return pt(p);let y=p.children;return Ne(pt(p),y.map(N=>N.id===x.id?hN(x,t):N),null)}),c(g);break}case "checkbox":{let f=so(t);if(f===null)return {ok:false,reason:"typeMismatch"};let m=Yg(o);if(!m)return {ok:false,reason:"typeMismatch"};d=To(d,x=>{let y=Ie(x,"checkbox");if(!y)return pt(x);let N=y.children,b=Ne(y,N.map(w=>{if(w.kind==="textValue"||w.localName!=="checked")return w;let I=w.attributes.filter(A=>A.localName!=="val");return {...w,attributes:[...I,{namespaceUri:w.attributes[0]?.namespaceUri??j,prefix:w.attributes[0]?.prefix??"w14",localName:"val",value:f?"1":"0"}]}}),null),P=(b.kind==="textValue"?[]:b.children).some(w=>w.kind!=="textValue"&&w.localName==="checked"),k=P?b:Ne(y,[{id:i(),kind:"generic",namespaceUri:j,localName:"checked",prefix:"w14",namespaceBindings:[],attributes:[{namespaceUri:j,prefix:"w14",localName:"val",value:f?"1":"0"}],children:[]},...N],null),E=x.children;return Ne(pt(x),E.map(w=>w.id===y.id?P?b:k:w),null)});let g=f?m.checkedGlyph:m.uncheckedGlyph,p=f?m.checkedFont:m.uncheckedFont;c(g,p);break}case "date":{let f=Xn(o),m=Ie(f,"date"),g=Ue(Ie(m,"dateFormat"),"val"),p=Pi(t),x=p?ll(p,g):null;if(p===null||x===null)return {ok:false,reason:"invalidArgs"};d=To(d,y=>{let N=Ie(y,"date");if(!N)return pt(y);let b=N.attributes.filter(k=>k.localName!=="fullDate"),h={...N,attributes:[...b,{namespaceUri:O,prefix:"w",localName:"fullDate",value:p}]},P=y.children;return Ne(pt(y),P.map(k=>k.id===N.id?h:k),null)}),c(x);break}case "text":case "richText":case "other":c(t);break;default:return {ok:false,reason:"unsupported"}}let u={dirty:a?[a.id]:[o.id],created:[],deleted:[],dependencyKeys:W,impact:"flow-structural"};if(ln(o)){if(!a)return {ok:false,reason:"tree-invariant"};let f=al(d);if(!f)return {ok:false,reason:"tree-invariant"};let m=a.children.flatMap(g=>g.id===o.id?f:[g]);return T(L(e,a.id,m,r),u)}return T(V(e,o.id,d,r),u)}var fM=new Set(["bookmarkEnd","commentRangeEnd","moveFromRangeEnd","moveToRangeEnd","permEnd","customXmlInsRangeEnd","customXmlDelRangeEnd","customXmlMoveFromRangeEnd","customXmlMoveToRangeEnd"]),wN=new Map([["bookmarkEnd","bookmarkStart"],["commentRangeEnd","commentRangeStart"],["moveFromRangeEnd","moveFromRangeStart"],["moveToRangeEnd","moveToRangeStart"],["permEnd","permStart"],["customXmlInsRangeEnd","customXmlInsRangeStart"],["customXmlDelRangeEnd","customXmlDelRangeStart"],["customXmlMoveFromRangeEnd","customXmlMoveFromRangeStart"],["customXmlMoveToRangeEnd","customXmlMoveToRangeStart"]]),mM=new Set(wN.values());function pM(e){return e.kind!=="textValue"&&fM.has(e.localName)}function EN(e,n){if(n.kind==="textValue")return null;let t=n.attributes.find(r=>r.localName==="id");return t?`${e}\0${t.value}`:null}function RN(e){return e.kind==="textValue"||!mM.has(e.localName)?null:EN(e.localName,e)}function IN(e,n){if(!pM(e)||e.kind==="textValue")return false;let t=wN.get(e.localName),r=t?EN(t,e):null;return r===null||!n.has(r)}function gM(e,n,t,r){return n!==t?n<t:IN(e,r)}function TN(e,n){let t=Xa(n);if(t===null||!lt(t))return null;let r=xr(e,n);return r===null?null:{headId:t.toUpperCase(),prefix:r}}function gt(e,n){let t=new Set(Zt(e).map(r=>r.id));return t.size===0?[]:n.filter(r=>t.has(r.runId))}function CN(e,n,t,r){if(e.kind==="hyperlink"||we(e)||e.kind!=="textValue"&&he(e.kind)){if(e.kind==="textValue")return {head:e,tail:null};let d=we(e)?Bn(e):e;if(!d)return {head:e,tail:null};let c=[],u=[],f=gt(e,t)[0]?.start??0,m=d.children;for(let x of m){let y=gt(x,t);if(y.length===0){(f<n?c:u).push(x);continue}let N=y[0].start,b=y[y.length-1].end;if(f=b,b<=n)c.push(x);else if(N>=n)u.push(x);else {let h=CN(x,n,t,r);h.head&&c.push(h.head),h.tail&&u.push(h.tail);}}if(e.kind==="hyperlink"||he(e.kind))return {head:c.length>0?Ne(e,c,null):null,tail:u.length>0?Ne(e,u,r):null};let g=e.children,p=(x,y)=>{let N=Ne(d,x,y?r:null);return y?Ne(e,g.map(b=>b.id===d.id?N:Ke(b,r)),r):Ne(e,g.map(b=>b.id===d.id?N:b),null)};return {head:c.length>0?p(c,false):null,tail:u.length>0?p(u,true):null}}if(e.kind!=="run")return {head:e,tail:null};let o=t.filter(d=>d.runId===e.id),i=Yn(e),a=[],l=[];for(let d of e.children){if(Yt(d))continue;let c=o.find(u=>vr(d,u.node.id));if(!c){a.push(d);continue}if(c.end<=n)a.push(d);else if(c.start>=n)l.push(d);else if(c.node.kind==="textValue"){let u=n-c.start,f=Xl(e,c.node.id);a.push(Gn(r,c.node.value.slice(0,u),f)),l.push(Gn(r,c.node.value.slice(u),f));}else a.push(d);}let s=i?Ke(i,r):null;return {head:a.length>0?kn(r,i?[i,...a]:a):null,tail:l.length>0?kn(r,s?[s,...l]:l):null}}function Ne(e,n,t){return {...e,...t?{id:t()}:{},children:n}}function xM(e,n,t,r){let o=S(e),i=Q(n),a=[],l=[],s=ye(n),d=0,c=new Set;for(let N of n.children){if(dt(N))continue;let b=gt(N,i);if(b.length===0){(gM(N,d,t,c)?a:l).push(N);let E=RN(N);E&&c.add(E);continue}let h=b[0].start,P=b[b.length-1].end;if(P>d&&c.clear(),d=P,P<=t){a.push(N);continue}if(h>=t){l.push(N);continue}let k=CN(N,t,i,o);k.head&&a.push(k.head),k.tail&&l.push(k.tail);}let u=s?hu(s):void 0,f=TN(e,n),m={id:o(),kind:"paragraph",namespaceUri:O,localName:"p",prefix:"w",namespaceBindings:[],attributes:f?Rt(f.prefix,wn(`${f.headId}:${t}`,zn(e.root))):[],children:s?[Ke(s,o),...l]:l},g={dirty:[n.id],created:[m.id],deleted:[],split:{from:n.id,tail:m.id},dependencyKeys:W,impact:"flow-structural"},p=Z(e,n.id);if(!p)return {ok:false,reason:"tree-invariant",detail:"paragraph has no parent"};let x=Object.freeze({...n,children:u?[u,...a]:a}),y=p.children.flatMap(N=>N.id===n.id?[x,m]:[N]);return T(L(e,p.id,y,r),g)}function Sn(e,n,t="tail"){let r=0,o=e.length;for(;r<o;){let i=r+o>>1;(t==="tail"?e[i]<=n:e[i]<n)?r=i+1:o=i;}return r}function Qi(e,n,t,r,o){let i=Array.from({length:t},()=>[]);if(e.kind==="hyperlink"){let u=Array.from({length:t},()=>[]),f=gt(e,r)[0]?.start??0;for(let g of e.children){let p=gt(g,r);if(p.length===0){u[Sn(n,f)].push(g);continue}let x=p[0].start,y=p[p.length-1].end;f=y;let N=Sn(n,x),b=y>x?Sn(n,y-1):N;if(N===b){u[N].push(g);continue}let h=Qi(g,n,t,r,o);for(let P=0;P<t;P+=1)for(let k of h[P])u[P].push(k);}let m=false;for(let g=0;g<t;g+=1){let p=u[g];p.length!==0&&(i[g].push(Ne(e,p,m?o:null)),m=true);}return i}if(we(e)){if(e.kind==="textValue")return i[0].push(e),i;let u=Bn(e);if(!u)return i[0].push(e),i;let f=e.children,m=u.children,g=Array.from({length:t},()=>[]),p=gt(e,r)[0]?.start??0;for(let y of m){let N=gt(y,r);if(N.length===0){g[Sn(n,p)].push(y);continue}let b=N[0].start,h=N[N.length-1].end;p=h;let P=Sn(n,b),k=h>b?Sn(n,h-1):P;if(P===k){g[P].push(y);continue}let E=Qi(y,n,t,r,o);for(let w=0;w<t;w+=1)for(let I of E[w])g[w].push(I);}let x=false;for(let y=0;y<t;y+=1){let N=g[y];if(N.length===0)continue;let b=Ne(u,N,x?o:null);x?i[y].push(Ne(e,f.map(h=>h.id===u.id?b:Ke(h,o)),o)):i[y].push(Ne(e,f.map(h=>h.id===u.id?b:h),null)),x=true;}return i}if(e.kind!=="run")return i[Sn(n,0)].push(e),i;let a=r.filter(u=>u.runId===e.id),l=Sn(n,a[0]?.start??0),s=Yn(e),d=Array.from({length:t},()=>[]);for(let u of e.children){if(Yt(u))continue;let f=a.find(h=>vr(u,h.node.id));if(!f){d[l].push(u);continue}if(f.node.kind!=="textValue"){d[Sn(n,f.start)].push(u);continue}let m=f.start,g=f.end,p=m,x=Sn(n,m),y=false,N=u;for(let h of n){if(h<=m)continue;if(h>=g)break;let P=f.node.value.slice(p-m,h-m);P.length>0&&d[x].push(Gn(o,P,Xl(N,f.node.id))),p=h,x+=1,y=true;}if(!y){d[x].push(u);continue}let b=f.node.value.slice(p-m);b.length>0&&d[x].push(Gn(o,b,Xl(N,f.node.id)));}let c=false;for(let u=0;u<t;u+=1){let f=d[u];if(f.length===0)continue;let m=s?c?Ke(s,o):s:null;c=true,i[u].push(kn(o,m?[m,...f]:f));}return i}function hM(e,n,t,r){let o=S(e),i=Q(n),a=ye(n),l=t.length+1,s=Array.from({length:l},()=>[]),d=0,c=new Set;for(let b of n.children){if(dt(b))continue;let h=gt(b,i);if(h.length===0){let A=Sn(t,d,IN(b,c)?"head":"tail");s[A].push(b);let U=RN(b);U&&c.add(U);continue}let P=h[0].start,k=h[h.length-1].end;k>d&&c.clear(),d=k;let E=Sn(t,P),w=k>P?Sn(t,k-1):E;if(E===w){s[E].push(b);continue}let I=Qi(b,t,l,i,o);for(let A=0;A<l;A+=1)for(let U of I[A])s[A].push(U);}let u=a?hu(a):void 0,f=TN(e,n),m=Array.from({length:l},()=>null);if(f){let b=new Set(zn(e.root));for(let h=l-1;h>=1;h-=1){let P=wn(`${f.headId}:${t[h-1]}`,b);b.add(P),m[h]=Rt(f.prefix,P);}}let g=[];for(let b=1;b<l;b+=1){let P=b===l-1?a:u;g.push({id:o(),kind:"paragraph",namespaceUri:O,localName:"p",prefix:"w",namespaceBindings:[],attributes:m[b]??[],children:P?[Ke(P,o),...s[b]]:s[b]});}let p={dirty:[n.id],created:g.map(b=>b.id),deleted:[],splits:g.map(b=>({from:n.id,tail:b.id})),dependencyKeys:W,impact:"flow-structural"},x=Z(e,n.id);if(!x)return {ok:false,reason:"tree-invariant",detail:"paragraph has no parent"};let y=Object.freeze({...n,children:u?[u,...s[0]]:s[0]}),N=x.children.flatMap(b=>b.id===n.id?[y,...g]:[b]);return T(L(e,x.id,N,r),p)}function yM(e,n){let t=n;for(;t;){let r=R(e,t);if(!r||r.kind==="textValue")return null;if(r.kind==="table")return r;t=Z(e,t)?.id??null;}return null}function OM(e,n,t,r){let o=Ve(e,n),i=zn(e.root),a=[],l=xr(e,n);if(l!==null){let s=wn(r,i);a.push(...Rt(l,s));}return {id:t(),kind:"paragraph",namespaceUri:O,localName:"p",...o.elementPrefix===void 0?{}:{prefix:o.elementPrefix},namespaceBindings:[],attributes:a,children:[]}}function NM(e,n,t){let r=R(e,n);if(!r)return {ok:false,reason:"unknown-block"};let o=gy(e,n);if(!o)return {ok:false,reason:"block-required"};let i=Z(e,n),a=r.kind==="table"&&i?.kind==="tableCell"&&i.children.every(x=>x.kind!=="paragraph"),l=Rr(r),s=[],d={dirty:[],created:s,deleted:[n,...l.filter(x=>x!==n)],dependencyKeys:W,impact:"flow-structural",caret:{paragraphId:o}},c=oe(e,n,t);if(!c.ok)return {ok:false,reason:"unknown-block"};if(!a||!i)return T(c,d);let u=yM(c.part,i.id);if(!u)return T(c,d);let f=S(c.part),m=OM(c.part,u,f,`${n}:cell-p`),g=R(c.part,i.id);if(!g||g.kind==="textValue")return T(c,d);let p=M(c.part,i.id,g.children.length,[m],t);return p.ok?T(p,{...d,created:[...s,m.id]}):{ok:false,reason:"tree-invariant"}}function ku(e,n,t,r){let o=R(e,t),i=Z(e,n),a=Z(e,t);if(!i||!a||i.id!==a.id)return {ok:false,reason:"not-adjacent-siblings"};let l=i.children.findIndex(h=>h.id===n);if(i.children.findIndex(h=>h.id===t)!==l+1)return {ok:false,reason:"not-adjacent-siblings"};let d=[],c=new Set;for(let h of [n,t]){let P=je(e,h);P&&ln(P)&&!c.has(P.id)&&(c.add(P.id),d.push(P));}let u={dirty:[n],created:[],deleted:[t],join:{kept:n,removed:t},dependencyKeys:W,impact:"flow-structural"},f=o.children.filter(h=>!dt(h)),m=i.children.find(h=>h.id===n);if(!m||m.kind!=="paragraph")return {ok:false,reason:"tree-invariant",detail:"survivor missing"};let g=S(e),p=bM(m,o,g),x=Object.freeze({...p,children:[...p.children,...f]}),y=i.children.flatMap(h=>h.id===n?[x]:h.id===t?[]:[h]),N=d.length>0?{...r,deferValidation:true}:r,b=T(L(e,i.id,y,N),u);for(let h of d)b=Nn(b,h,r);return b}var kM=new Set(["ins","del","moveFrom","moveTo"]),bu=e=>e.kind!=="textValue"&&e.namespaceUri===O&&kM.has(e.localName);function bM(e,n,t){let r=(Vn(ye(n),"rPr")?.children??[]).filter(bu),o=(Vn(ye(e),"rPr")?.children??[]).some(bu),i=r.length>0||o?PM(e,r,t):e,a=Vn(ye(n),"sectPr");if(!a)return i;let l=Ke(a,t),s=ye(i);if(!s){let m={id:t(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:[l]};return {...i,children:[m,...i.children]}}let d=s.children.filter(m=>m.kind==="textValue"||m.localName!=="sectPr"),c=d.findIndex(m=>m.kind!=="textValue"&&m.localName==="pPrChange"),u=c===-1?d.length:c,f={...s,children:[...d.slice(0,u),l,...d.slice(u)]};return {...i,children:i.children.map(m=>m.id===s.id?f:m)}}function PM(e,n,t){let r=n.map(c=>Ke(c,t)),o=ye(e);if(!o){if(r.length===0)return e;let c={id:t(),kind:"runProperties",namespaceUri:O,localName:"rPr",prefix:"w",namespaceBindings:[],attributes:[],children:r},u={id:t(),kind:"paragraphProperties",namespaceUri:O,localName:"pPr",prefix:"w",namespaceBindings:[],attributes:[],children:[c]};return {...e,children:[u,...e.children]}}let i=Vn(o,"rPr"),a=(i?.children??[]).filter(c=>!bu(c)),l=i===void 0?r.length>0?{id:t(),kind:"runProperties",namespaceUri:O,localName:"rPr",prefix:"w",namespaceBindings:[],attributes:[],children:r}:void 0:{...i,children:[...r,...a]};if(!l)return e;let s=i===void 0?(()=>{let c=o.children.findIndex(f=>f.kind!=="textValue"&&(f.localName==="sectPr"||f.localName==="pPrChange")),u=c===-1?o.children.length:c;return [...o.children.slice(0,u),l,...o.children.slice(u)]})():o.children.map(c=>c.id===i.id?l:c),d={...o,children:s};return {...e,children:e.children.map(c=>c.id===o.id?d:c)}}function wM(e,n,t,r,o,i,a){let l={dirty:[n.id],created:[],deleted:[],dependencyKeys:W,impact:"text-local"},s=e;for(let m of [r,t]){let g=R(s,n.id),p=Io(s,g,m,i);if(!p.ok)return p;s=p.part;}let d=R(s,n.id),c=Q(d),u=new Set;if(a&&a.length>0)for(let m of a)u.add(m);else for(let m of c)if(!(m.start<t||m.end>r))if(m.formatRunIds&&m.formatRunIds.length>0)for(let g of m.formatRunIds)u.add(g);else m.runId&&u.add(m.runId);let f=S(s);for(let m of u){let g=R(s,m);if(!g||g.kind!=="run")continue;let p=Yn(g),x=g.children.filter(h=>!Yt(h)),y=Yi(p?.children??[],o,zl,f);if(y.length===0){if(!p)continue;let h=L(s,g.id,x,i);if(!h.ok)return T(h,l);s=h.part;continue}let N=p?{...p,children:y}:{id:f(),kind:"runProperties",namespaceUri:O,localName:"rPr",prefix:"w",namespaceBindings:[],attributes:[],children:y},b=L(s,g.id,[N,...x],i);if(!b.ok)return T(b,l);s=b.part;}return Le(s,l)}function Io(e,n,t,r){let o=Q(n),i=[];for(let y of o)i[i.length-1]!==y.runId&&i.push(y.runId);let a=i.find(y=>{let N=o.filter(b=>b.runId===y);return N[0].start<t&&N[N.length-1].end>t});if(a===void 0)return {ok:true,part:e};let l=R(e,a);if(!l||l.kind!=="run")return {ok:false,reason:"tree-invariant"};let s=S(e),d=Yn(l),c=[],u=[];for(let y of l.children){if(Yt(y))continue;let N=o.find(b=>b.runId===l.id&&vr(y,b.node.id));if(!N){c.push(y);continue}if(N.end<=t)c.push(y);else if(N.start>=t)u.push(y);else if(N.node.kind==="textValue"){let b=t-N.start,h=Xl(y,N.node.id);c.push(Gn(s,N.node.value.slice(0,b),h)),u.push(Gn(s,N.node.value.slice(b),h));}else c.push(y);}let f=kn(s,d?[d,...c]:c),m=kn(s,d?[Ke(d,s),...u]:u),g=Z(e,l.id);if(!g)return {ok:false,reason:"tree-invariant"};let p=g.children.flatMap(y=>y.id===l.id?[f,m]:[y]),x=L(e,g.id,p,r);return x.ok?{ok:true,part:x.part}:{ok:false,reason:"tree-invariant",detail:JSON.stringify(x.issues)}}function EM(e,n){let t=R(e,n);if(!En(t))return null;let r="";for(let o of Q(t)){if(o.removeNodeIds&&o.removeNodeIds.length>0){r+=gd();continue}o.node.kind==="textValue"?r+=o.node.value:o.node.kind==="tab"?r+=" ":o.node.kind==="hardBreak"?r+=Ga(o.node):(o.node.kind==="fldChar"||o.node.kind==="fldSimple"||o.node.kind==="generic"&&(o.node.localName==="fldChar"||o.node.localName==="fldSimple"))&&(r+=gd());}return r}function RM(e){if(!(e===null||e.start!==e.end))return e}var vo={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function IM(e){return Object.freeze({parts:new Map([[e.name,e]]),partBytes:new Map,relationships:new Map,externalTargets:[],contentTypes:{defaults:new Map,overrides:new Map([[e.name.toLowerCase(),e.contentType]])},mainDocumentPart:e.name})}var So=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];subscribers=new Set;historyLimit;settingsPartOverride;storyRef=null;composition=null;constructor(n,t,r={}){let o="root"in n,i=typeof t=="string"?t:void 0,a=typeof t=="object"&&t!==null?t:r;this.current=o?IM(n):n,this.storyPartName=i??(o?n.name:n.mainDocumentPart),this.historyLimit=a.historyLimit??200,this.settingsPartOverride=a.settingsPart;}setStoryRef(n){this.storyRef=n;}get part(){let n=this.current.parts.get(this.storyPartName);if(!n)throw new Error(`story part missing: ${this.storyPartName}`);return n}get package(){return this.current}get revision(){return this.rev}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get historyDepth(){return this.undoStack.length}get compositionActive(){return this.composition!==null}graftPackage(n){this.current=n(this.current);}replacePart(n){let t=this.current.parts.get(n.name);n!==t&&(this.current=D(this.current,n),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(n){this.current=n.pkg,this.rev=n.revision,this.undoStack.length=0,this.undoStack.push(...n.undoStack),this.redoStack.length=0,this.redoStack.push(...n.redoStack),this.composition=n.composition?{entry:{...n.composition.entry},committed:n.composition.committed}:null;}restoreHistoryStacks(n){this.undoStack.length=0,this.undoStack.push(...n.undoStack),this.redoStack.length=0,this.redoStack.push(...n.redoStack);}subscribe(n){return this.subscribers.add(n),()=>this.subscribers.delete(n)}transact(n,t={}){let r=t.origin??ge.mutationHuman,o=this.current,i=this.rev,a=this.current,l=null,s=0,d=new Set,c=new Set,u=new Set,f=new Set,m=new Set,g=[],p=t.minimumImpact??"text-local",x=null,y=false,N=null,b=null,h=(I,A)=>{if(l)return false;let U=a.parts.get(I);if(!U)return l={reason:"unknown-part",detail:I},false;let B=Sy(U,this.settingsPartOverride?.()??Tt(a),A);if(B)return l={reason:B},false;let C=ql(U,A,{deferValidation:true});if(!C.ok)return l={reason:C.reason,...C.detail?{detail:C.detail}:{}},false;if(a=D(a,C.part),C.part===U&&C.effect.dirty.length===0&&C.effect.created.length===0&&C.effect.deleted.length===0&&C.effect.split===void 0&&(C.effect.splits===void 0||C.effect.splits.length===0)&&C.effect.join===void 0&&C.effect.caret===void 0)return true;d.add(I),s+=1;for(let fn of C.effect.dirty)c.add(fn);for(let fn of C.effect.created)u.add(fn);for(let fn of C.effect.deleted)f.add(fn);for(let fn of C.effect.dependencyKeys)m.add(fn);C.effect.split&&g.push({split:C.effect.split});for(let fn of C.effect.splits??[])g.push({split:fn});return C.effect.join&&g.push({join:C.effect.join}),vo[C.effect.impact]>vo[p]&&(p=C.effect.impact),C.effect.caret&&(b={paragraphId:C.effect.caret.paragraphId,start:0,end:0}),true};if(n({apply:I=>h(this.storyPartName,I),applyTo:(I,A)=>h(I,A),applyPackage:I=>{if(l)return false;let A=I(a);if(A===a)return true;for(let[U,B]of A.parts)a.parts.get(U)!==B&&d.add(U);return a=A,s+=1,vo["flow-structural"]>vo[p]&&(p="flow-structural"),true},selectionBefore:I=>{x=I;},selectionAfter:I=>{y=true,N=I;}}),l){let I=l;return {ok:false,reason:I.reason,...I.detail?{detail:I.detail}:{}}}if(s===0)return {ok:true,change:null};let P=y?N:b,k=y?RM(N):b??void 0;for(let I of d){let A=o.parts.get(I),U=a.parts.get(I);if(U===void 0)continue;let B=A?Oa(A,U):Oa(U,U);if(!B.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(B.issues)}}let E=dp(a);return E.ok?(r!==ge.projection&&(this.composition?(this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:P}}):(this.pushUndo({pkg:o,revision:i,selectionBefore:x,selectionAfter:P}),this.redoStack.length=0)),this.current=a,this.rev+=1,t.story&&(this.storyRef=t.story),t.minimumImpact&&vo[t.minimumImpact]>vo[p]&&(p=t.minimumImpact),{ok:true,change:this.publish(r,i,{dirty:c,created:u,deleted:f,dependencyKeys:m,splitJoin:g,impact:p,caret:k},t.story??this.storyRef??void 0)}):{ok:false,reason:"package-invariant",detail:JSON.stringify(E.issues)}}beginComposition(n=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:n,selectionAfter:null},committed:false});}endComposition(){let n=this.composition;this.composition=null,!(!n||!n.committed)&&(this.pushUndo(n.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}undo(){let n=this.undoStack.pop();if(!n)return null;let t=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:n.selectionBefore,selectionAfter:n.selectionAfter}),this.current=n.pkg,this.rev+=1,this.publish(ge.mutationUndo,t,null,this.storyRef??void 0)}redo(){let n=this.redoStack.pop();if(!n)return null;let t=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:n.selectionBefore,selectionAfter:n.selectionAfter}),this.current=n.pkg,this.rev+=1,this.publish(ge.mutationRedo,t,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}pushUndo(n){this.undoStack.push(n),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(n,t,r,o){this.commitCounter+=1;let i={change:"model-change",fromRevision:t,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:n,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}:{}};for(let a of this.subscribers)a(i);return i}};function Pu(e,n){return [...e.values()].map(t=>t.part).filter(t=>n.parts.has(t.name))}function vN(e,n){return Pu(e,n).map(t=>t.name).sort().join(",")}var Zl="http://schemas.openxmlformats.org/wordprocessingml/2006/main",TM="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Ao(e,n){for(let t of e.children)if(t.kind!=="textValue"&&t.namespaceUri===Zl&&t.localName===n)return t;return null}function Yl(e,n){return e.attributes.find(t=>t.namespaceUri===Zl&&t.localName===n)?.value}function CM(e){let n=Yl(e,"val");return n===void 0||n==="1"||n==="true"||n==="on"}function AN(e,n){return e.kind==="textValue"?Object.freeze({...e,id:n()}):Object.freeze({...e,id:n(),children:e.children.map(t=>AN(t,n))})}function vM(e){let n=ne(`<w:styles xmlns:w="${Zl}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:e.name,contentType:TM});if(!n.ok)return null;let t=Ao(n.part.root,"style"),r=t?Ao(t,"pPr"):null;return r?AN(r,S(e)):null}var SN=["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 SM(e,n){let t=SN.indexOf(n),r=0;return e.forEach((o,i)=>{if(o.kind==="textValue")return;let a=SN.indexOf(o.localName);a!==-1&&a<=t&&(r=i+1);}),r}function MN(e,n){let t=kd(e);if(!t)return null;let r=null;for(let d of t.root.children)if(d.kind!=="textValue"&&d.namespaceUri===Zl&&d.localName==="style"&&Yl(d,"type")==="paragraph"&&Yl(d,"styleId")===n){r=d;break}if(!r)return null;let o=Ao(r,"name");if(o&&Yl(o,"val")?.trim().toLowerCase()!=="list paragraph"&&n!=="ListParagraph")return null;let i=vM(t);if(!i)return null;let a=Ao(i,"contextualSpacing");if(!a)return null;let l=Ao(r,"pPr"),s;if(l){let d=Ao(l,"contextualSpacing");if(d&&CM(d))return e;s=d?V(t,d.id,a):M(t,l.id,SM(l.children,"contextualSpacing"),[a]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));s=M(t,r.id,d===-1?r.children.length:d,[i]);}return s.ok?Object.freeze({...e,parts:new Map([...e.parts,[t.name,s.part]])}):null}var LN="http://schemas.openxmlformats.org/package/2006/relationships",BN="application/vnd.openxmlformats-package.relationships+xml",_M="http://schemas.openxmlformats.org/package/2006/content-types",_N="/[Content_Types].xml",Mo="/word/numbering.xml",DN="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",Ji="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",DM=`<Override PartName="${Mo}" ContentType="${Ji}"/>`;function Ql(e){return `${e.ownerPart}\0${e.id}`}function FN(e,n,t){let r=new Set(n.externalTargets.filter(l=>l.type===an).map(Ql)),o=t.externalTargets.filter(l=>l.type===an&&!r.has(Ql(l)));if(o.length===0)return e;let i=new Set(e.map(Ql)),a=o.filter(l=>!i.has(Ql(l)));return a.length===0?e:Object.freeze([...e,...a])}function VN(e,n,t){let r=e.filter(o=>o.ownerPart===t||n.has(o.ownerPart));return r.length===e.length?e:Object.freeze(r)}function WN(e,n,t=[]){if(e===n)return e;let r=UM(e,n);return r=LM(r,n,t),r}function HN(e,n){let t=new Set;for(let o of e.externalTargets)o.type===an&&o.ownerPart!==e.mainDocumentPart&&(e.parts.has(o.ownerPart)||n.has(o.ownerPart)||t.add(o.ownerPart));for(let o of e.parts.keys()){let i=WM(o);!i||i===e.mainDocumentPart||e.parts.has(i)||n.has(i)||e.externalTargets.some(a=>a.ownerPart===i)||t.add(i);}if(t.size===0)return e;let r=e;for(let o of t)r=HM(r,o);return r}function UM(e,n){let t=n.parts.get(Mo);if(!t)return e;let r=D(e,t),o=(n.relationships.get(n.mainDocumentPart)??[]).find(a=>a.type===DN),i=r.relationships.get(r.mainDocumentPart)??[];if(o&&!i.some(a=>a.type===DN)&&!i.some(a=>a.id===o.id)){let a=FM(r,{...o,ownerPart:r.mainDocumentPart});a&&(r=a);}if(r.contentTypes.overrides.get(G(Mo))!==Ji){let a=jM(r);a&&(r=a);}return r}function LM(e,n,t){let r=t.filter(i=>i.type===an);if(r.length===0)return e;let o=e;for(let i of r){let a=BM(e,n,i.ownerPart);if(!a||o.externalTargets.some(d=>d.ownerPart===a&&d.id===i.id)||new Set((o.relationships.get(a)??[]).map(d=>d.id)).has(i.id))continue;let s=VM(o,{ownerPart:a,id:i.id,type:an,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);s&&(o=s);}return o}function BM(e,n,t){return t===n.mainDocumentPart?e.mainDocumentPart:typeof t!="string"||t.length===0?null:t}function FM(e,n){let t=e.mainDocumentPart,r=wu(t),o=e.parts.get(r),i=ne(`<Relationships xmlns="${LN}"><Relationship Id="${on(n.id,"relationship id")}" Type="${on(n.type,"relationship type")}" Target="${on(n.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:BN});if(!i.ok)return null;let a=e.relationships.get(t)??[];if(a.some(d=>d.id===n.id))return null;let l={...n,ownerPart:t,order:a.reduce((d,c)=>Math.max(d,c.order),-1)+1},s=new Map([...e.relationships,[t,[...a,l]]]);return o?jN(e,o,i.part.root.children[0],s):Object.freeze({...e,parts:new Map([...e.parts,[r,i.part]]),relationships:s})}function VM(e,n,t=e.mainDocumentPart){let r=t;if(typeof r!="string"||r.length===0)return null;let o=wu(r),i=e.parts.get(o),a=ne(`<Relationships xmlns="${LN}"><Relationship Id="${on(n.id,"relationship id")}" Type="${an}" Target="${on(n.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:BN});if(!a.ok)return null;let l=[...e.externalTargets,n];if(!i)return Object.freeze({...e,parts:new Map([...e.parts,[o,a.part]]),externalTargets:l});let s=jN(e,i,a.part.root.children[0],e.relationships);return s?Object.freeze({...s,externalTargets:l}):null}function jN(e,n,t,r){if(!t)return null;let o=S(n),i=M(n,n.root.id,n.root.children.length,[KN(t,o)]);return i.ok?Object.freeze({...e,parts:new Map([...e.parts,[n.name,i.part]]),relationships:r}):null}function KN(e,n){return e.kind==="textValue"?{...e,id:n()}:{...e,id:n(),children:e.children.map(t=>KN(t,n))}}function wu(e){let n=e.lastIndexOf("/");return `${e.slice(0,n)}/_rels/${e.slice(n+1)}.rels`}function WM(e){let n=/^(.*)\/_rels\/([^/]+)\.rels$/.exec(e);if(!n)return null;let t=n[1],r=n[2];return t===""||r===""?null:`${t}/${r}`}function HM(e,n){let t=wu(n),r=new Map(e.parts);r.delete(t);let o=new Map(e.partBytes);o.delete(t);let i=new Map(e.relationships);i.delete(n);let a=Object.freeze(e.externalTargets.filter(l=>l.ownerPart!==n));return Object.freeze({...e,parts:r,partBytes:o,relationships:i,externalTargets:a})}function jM(e){let n=e.contentTypes.overrides.get(G(Mo));if(n===Ji)return e;if(n!==void 0)return null;let t=e.partBytes.get(_N);if(!t)return null;let r=strFromU8(t),o=UN(r);if(!o)return null;let i=r.lastIndexOf(`</${o.rootName}>`);if(i===-1)return null;let a=r.slice(0,i)+DM+r.slice(i),l=UN(a);if(!l||l.rootName!==o.rootName)return null;let s=[...o.children,GN("Override",{PartName:Mo,ContentType:Ji})];return l.children.length!==s.length||l.children.some((d,c)=>d!==s[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[_N,strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[G(Mo),Ji]])})})}function UN(e){let n=tt(e);if(!n.ok)return null;let t=n.nodes.filter(l=>l.type==="element");if(t.length!==1)return null;let r=t[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"]!==_M)return null;let a=[];for(let l of r.children)l.type==="element"&&a.push(GN(l.name,l.attributes));return {rootName:r.name,children:a}}function GN(e,n){let t=Object.entries(n).map(([r,o])=>`${r}=${o}`).sort();return [e,...t].join("")}var $N=4e3,zN=64;function XN(e){return Ge(e,"footnote")!==null||Ge(e,"endnote")!==null}function qN(e,n,t,r){if(!XN(e))return false;if(r.has(t.paragraphId))return true;r.add(t.paragraphId);let o=R(n,t.paragraphId);return !o||o.kind!=="paragraph"?true:Q(o).some(i=>i.node.kind==="noteReference"&&i.start<t.end&&i.end>t.start)}function YN(e,n,t,r){if(!XN(e))return false;if(r.has(t.blockId))return true;r.add(t.blockId);let o=R(n,t.blockId);if(!o||o.kind==="textValue")return true;let i=0,a=(l,s)=>{if(i>=$N||s>zN)return true;if(i+=1,l.kind==="textValue")return false;if(l.kind==="paragraph")return Q(l).some(d=>d.node.kind==="noteReference");for(let d of l.children)if(a(d,s+1))return true;return false};return a(o,0)}function ZN(e,n,t){if(t.count>=$N||n>zN)return true;if(t.count+=1,e.kind==="textValue")return false;if(e.kind==="commentRangeStart"||e.kind==="commentRangeEnd"||e.kind==="commentReference")return true;for(let r of e.children)if(ZN(r,n+1,t))return true;return false}function QN(e,n,t,r){if(!Kd(e))return false;let o=t.op==="deleteText"?t.paragraphId:t.blockId;if(r.has(o))return true;r.add(o);let i=R(n,o);return !i||i.kind==="textValue"?true:ZN(i,0,{count:0})}function _o(e,n){return n.compositionActive||e.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function JN(e,n){let t=R(e,n);return !t||t.kind!=="drawing"?null:t.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function ek(e,n,t){let r=e.parts.get(n);if(!r)return null;let o=R(r,t);return !o||o.kind!=="drawing"?null:dr(o,{ownerPartName:n,supportedMcRequires:rt,limits:Kt,resolveRelationship:Ds(e,n)})}function nk(e,n,t){let r=_r(e.relationships.get(n)??[],n,t);return r.mode==="internal"?r.partName:null}function ea(e,n,t,r){let o=e.resolveStory(n);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=_o(e,o.store);if(i)return i;let{store:a,story:l}=o,s=l.partName,d=e.currentPackage(),c=a.checkpoint(),u=a.historyDepth,f=null,m=false,g=false,p=a.transact(N=>{if(r?.commitGuard?.()===false){g=true;return}if(r?.expectedPackageRevision!==void 0&&e.packageRevision!==r.expectedPackageRevision){m=true;return}let b=t(N,s);if(b===null){N.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}f=b;},{story:l,...l.kind==="headerFooter"||l.kind==="notesPart"?{minimumImpact:"global"}:{}});if(g)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(m)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!p.ok)return {ok:false,reason:p.reason,...p.detail?{detail:p.detail}:{}};if(!p.change)return {ok:true,change:null};let x=p.change.created.find(N=>{let b=a.part;return R(b,N)?.kind==="drawing"});return x&&(f=x),{ok:true,change:e.promoteStoryTransactionToPackageUnit(d,a,c,u),...f?{drawingNodeId:f}:{}}}function tk(e,n,t){let r=e.parts.get(n);if(!r)return null;let o=JN(r,t);return o?sy(o):null}function Eu(e,n,t,r){let o=false;return e.applyPackage(i=>{let a=i.parts.get(n);if(!a)return i;let l=R(a,t);if(!l||l.kind!=="drawing")return i;let s=JN(a,t);if(!s)return i;let d=dy(s,r),c=KM(l,d),u=V(a,l.id,c,{deferValidation:true});return u.ok?(o=true,D(i,u.part)):i}),o}function KM(e,n){return {...e,children:e.children.map(t=>t.id===n.id?n:t)}}async function rk(e,n,t){let r=td(t.widthPoints),o=td(t.heightPoints);if(r===null||o===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=e.resolveStory(n);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let a=_o(e,i.store);if(a)return a;let l=i.story.partName,s=await La(t.decodePort,t.bytes,t.mime);if(!s.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=s.bytes,c=Xr(e.currentPackage(),l,{bytes:d,mime:t.mime});if(!c.ok)return {ok:false,reason:"invalidArgs",detail:c.reason==="invalid-image"?"invalid-image":c.reason};let u=c.partName,f=ea(e,n,(m,g)=>{let p=e.currentPackage(),x=Xr(p,g,{bytes:d,mime:t.mime});if(!x.ok)return null;p=x.pkg,u=x.partName;let y;if(t.hyperlink){let b=qa(p,t.hyperlink,g);if(!b)return null;p=b.pkg,y=b.relationshipId;}if(!m.applyPackage(()=>p))return null;let N=Ep({docPrId:x.docPrId,relationshipId:x.relationshipId,extentEmu:{cx:r,cy:o},...t.title!==void 0?{title:t.title}:{},...t.description!==void 0?{description:t.description}:{},...y?{hyperlinkRelationshipId:y}:{}});return m.apply({op:"insertDrawing",paragraphId:t.paragraphId,offset:t.offset,drawing:N})?N.id:null},{expectedPackageRevision:t.expectedPackageRevision,...t.commitGuard?{commitGuard:t.commitGuard}:{}});return f.ok?f.change?{...f,mediaPartName:u}:{ok:true,change:null,mediaPartName:u}:f}async function Ru(e,n,t,r,o,i,a){let l=e.resolveStory(n);if(!l.ok)return {ok:false,reason:l.reason,...l.detail?{detail:l.detail}:{}};let s=_o(e,l.store);if(s)return s;let d=l.story.partName,c=await La(i,r,o);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=c.bytes,f=Xr(e.currentPackage(),d,{bytes:u,mime:o});return f.ok?ea(e,n,(m,g)=>{let p=e.currentPackage(),x=ek(p,d,t),y=x?.picture?.embeddedRelationshipId??null,N=x?.picture?.linkedRelationshipId??null,b=y??N;if(!b)return null;let h=y!==null?nk(p,d,y):null,P=p,k=Xr(P,g,{bytes:u,mime:o});return !k.ok||(P=k.pkg,!m.applyPackage(()=>P))||!m.apply({op:"replaceDrawingResource",drawingNodeId:t,relationshipId:k.relationshipId})?null:(m.applyPackage(E=>rd(E,g,h,b)),t)},{expectedPackageRevision:a.expectedPackageRevision,...a.commitGuard?{commitGuard:a.commitGuard}:{}}):{ok:false,reason:"invalidArgs",detail:f.reason==="invalid-image"?"invalid-image":f.reason}}function ok(e,n,t){let r=e.resolveStory(n);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=_o(e,r.store);if(o)return o;let i=r.story.partName,a=e.currentPackage(),l=ek(a,i,t);if(!l)return {ok:false,reason:"unknown-drawing"};let s=l.picture?.embeddedRelationshipId??null,d=l.picture?.linkedRelationshipId??null,c=s??d,u=s!==null?nk(a,i,s):null;return ea(e,n,(f,m)=>f.apply({op:"deleteDrawing",drawingNodeId:t})?(f.applyPackage(g=>rd(g,m,u,c)),t):null)}async function ik(e,n,t,r,o,i,a){let l=await Rp(o,r,i,void 0,a);return l.ok?Ru(e,n,t,l.bytes,l.mime,a,{expectedPackageRevision:e.packageRevision}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function ak(e,n,t,r,o,i){let a=e.resolveStory(n);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let l=_o(e,a.store);return l||ea(e,n,(s,d)=>{let c=tk(e.currentPackage(),d,t),u=null;if(i!==null){let m=qa(e.currentPackage(),i,d);if(!m||!s.applyPackage(()=>m.pkg))return null;u=m.relationshipId;}if(!s.apply({op:"setDrawingMetadata",drawingNodeId:t,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!Eu(s,d,t,u))return null}else if(i===null&&!Eu(s,d,t,null))return null;let f=false;return s.applyPackage(m=>{let g=bd(m,d,c);return g===null?(f=true,m):g}),f?null:t})}function lk(e,n,t){let r=e.resolveStory(n);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=_o(e,r.store);return o||ea(e,n,(i,a)=>{let l=tk(e.currentPackage(),a,t.drawingNodeId),s=null;if(t.hyperlink!==null){let c=qa(e.currentPackage(),t.hyperlink,a);if(!c||!i.applyPackage(()=>c.pkg))return null;s=c.relationshipId;}for(let c of t.ops)if(!i.apply(c))return null;if(!Eu(i,a,t.drawingNodeId,t.hyperlink===null?null:s))return null;let d=false;return i.applyPackage(c=>{let u=bd(c,a,l);return u===null?(d=true,c):u}),d?null:t.drawingNodeId})}var sk=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),GM=new Set(["deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]),ck="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",uk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",$M=64,dk=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];subscribers=new Set;historyLimit;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;constructor(n,t,r={}){this.pkg=D(n,t),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??$M,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??Ex,this.body=new So(this.pkg,t.name,{historyLimit:this.historyLimit,settingsPart:()=>Tt(this.pkg)}),this.body.setStoryRef({kind:"body",partName:t.name});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let n=this.currentPackageMemo;if(n&&n.pkg===this.pkg&&n.bodyPart===this.body.part){let o=0,i=true;for(let a of this.stories.values()){if(n.storyParts[o]!==a.part){i=false;break}o+=1;}if(i&&o===n.storyParts.length)return n.result}let t=D(this.pkg,this.body.part),r=[];for(let o of this.stories.values())r.push(o.part),this.pkg.parts.has(o.part.name)&&(t=D(t,o.part));return this.currentPackageMemo={pkg:this.pkg,bodyPart:this.body.part,storyParts:r,result:t},t}subscribe(n){return this.subscribers.add(n),()=>this.subscribers.delete(n)}resolveStory(n){return n.kind==="body"?{ok:true,story:{kind:"body",partName:this.body.part.name},store:this.body}:n.kind==="notesPart"?n.noteKind!=="footnote"&&n.noteKind!=="endnote"?{ok:false,reason:"unknown-scope",detail:String(n.noteKind)}:this.openNotesPartStore(n.noteKind):n.kind!=="headerFooter"||typeof n.rId!="string"||n.rId.length===0?{ok:false,reason:"unknown-scope",detail:String(n.kind)}:this.openHeaderFooterStore(n.rId)}partFor(n){let t=this.resolveStory(n);return t.ok?t.store.part:null}revisionFor(n){let t=this.resolveStory(n);return t.ok?t.store.revision:null}transact(n,t,r={}){let o=this.resolveStory(n);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let{store:i,story:a}=o,l=this.currentPackage(),s=i.historyDepth,d=i.compositionActive,c=i.checkpoint(),u=false,f=new Set,m=false,g=new Set,p=false,x,y=i.transact(b=>{t({...b,apply:h=>(h.op==="setListNumbering"&&h.numId!==null&&(p=true),h.op==="setParagraphProperties"&&(x??=h.properties.find(P=>P.localName==="pStyle")?.attributes?.val),u||(h.op==="deleteText"&&qN(this.pkg,i.part,h,f)||h.op==="deleteBlock"&&YN(this.pkg,i.part,h,f)||sk.has(h.op))&&(u=true),m||(h.op==="deleteText"||h.op==="deleteBlock"?m=QN(this.pkg,i.part,h,g):(sk.has(h.op)||GM.has(h.op))&&(m=true)),b.apply(h)),selectionBefore:h=>b.selectionBefore(h),selectionAfter:h=>b.selectionAfter(h)});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!y.ok)return {ok:false,reason:y.reason,...y.detail?{detail:y.detail}:{}};if(this.syncPackageFromStore(i),p&&x){let b=MN(this.pkg,x);b&&this.replacePackageShell(b);}let N=false;if(y.change&&u){let b=this.currentPackage(),h=this.cascadeNoteReferences(l,b);if(h===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(l),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};h!==b&&(this.installPackageSnapshotInternal(h),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),N=true);}if(y.change&&m){let b=this.currentPackage(),h=dh(l,b,{storyPartName:a.partName});if(h===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(l),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};h!==b&&(this.installPackageSnapshotInternal(h),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),N=true);}if(y.change){this.packageRev+=1,!d&&(i.historyDepth>s||N)&&(N?this.pushUndoPointer({kind:"package",before:l,after:this.currentPackage()}):this.pushUndoPointer({kind:"story",partName:a.partName,story:a}));let b=N?this.publishSynthetic(y.change.origin,"global",a,y.change.created):y.change;return N||this.publish(b),{ok:true,change:b}}return {ok:true,change:y.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(n,t=null){let r=this.resolveStory(n);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(n),!r.ok)?false:(this.compositionSession||(this.compositionSession={partName:r.story.partName,beforePackage:this.currentPackage(),storyCheckpoint:r.store.checkpoint(),packageWideEffects:false}),r.store.beginComposition(t),true)}endComposition(){let n=this.compositionSession;if(this.compositionSession=null,!n){this.body.endComposition();return}let t=n.partName===this.body.part.name?this.body:this.stories.get(n.partName);if(!t)return;let r=t.historyDepth;if(t.endComposition(),n.packageWideEffects){t.restoreHistoryStacks(n.storyCheckpoint),this.syncPackageFromStore(t),this.pushUndoPointer({kind:"package",before:n.beforePackage,after:this.currentPackage()});return}if(t.historyDepth>r){let o=n.partName===this.body.part.name?{kind:"body",partName:n.partName}:this.storyRefForPart(n.partName);o&&this.pushUndoPointer({kind:"story",partName:n.partName,story:o});}this.syncPackageFromStore(t);}cancelComposition(){let n=this.compositionSession;if(this.compositionSession=null,!n){this.body.cancelComposition();return}let t=n.partName===this.body.part.name?this.body:this.stories.get(n.partName);if(n.packageWideEffects){t&&t.restoreCheckpoint(n.storyCheckpoint),this.installPackageSnapshotInternal(n.beforePackage),this.packageRev+=1;let r=n.partName===this.body.part.name?{kind:"body",partName:n.partName}:this.storyRefForPart(n.partName);this.publishSynthetic(ge.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}t?.cancelComposition();}applyLifecycleOp(n){let t=this.currentPackage();if(Ud(n)){let a=Px(t,n);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};if(a.package===t)return {ok:true,change:null};this.installPackageSnapshotInternal(a.package),this.pushUndoPointer({kind:"package",before:t,after:a.package}),this.packageRev+=1;let l={kind:"body",partName:this.body.part.name},s=this.publishSynthetic(ge.mutationHuman,a.impact,l,a.createdPartName?[a.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:s}}if(!Ed(n))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let r=Tg(t,n);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};this.installPackageSnapshotInternal(r.package),this.pushUndoPointer({kind:"package",before:t,after:r.package}),this.packageRev+=1;let o={kind:"body",partName:this.body.part.name},i=this.publishSynthetic(ge.mutationHuman,r.impact,o,r.createdPartName?[r.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:i}}undo(){let n=this.undoOrder.pop();if(!n)return null;if(n.kind==="package"){this.installPackageSnapshotInternal(n.before),this.redoOrder.push(n),this.packageRev+=1;let o=this.publishSynthetic(ge.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let t=n.partName===this.body.part.name?this.body:this.stories.get(n.partName);if(!t)return null;let r=t.undo();return r?(this.redoOrder.push(n),this.syncPackageFromStore(t),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let n=this.redoOrder.pop();if(!n)return null;if(n.kind==="package"){this.installPackageSnapshotInternal(n.after),this.undoOrder.push(n),this.packageRev+=1;let o=this.publishSynthetic(ge.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let t=n.partName===this.body.part.name?this.body:this.stories.get(n.partName);if(!t)return null;let r=t.redo();return r?(this.undoOrder.push(n),this.syncPackageFromStore(t),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){let n=this.undoOrder[this.undoOrder.length-1];return !n||n.kind==="package"?null:(n.partName===this.body.part.name?this.body:this.stories.get(n.partName))?.selectionForUndo()??null}selectionForRedo(){let n=this.redoOrder[this.redoOrder.length-1];return !n||n.kind==="package"?null:(n.partName===this.body.part.name?this.body:this.stories.get(n.partName))?.selectionForRedo()??null}openStoryParts(){return Pu(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return vN(this.stories,this.pkg)}insertImage(n,t){return rk(this,n,t)}replaceImage(n,t,r,o,i,a){return Ru(this,n,t,r,o,i,a)}deleteImage(n,t){return ok(this,n,t)}embedExternalImage(n,t,r,o,i,a){return ik(this,n,t,r,o,i,a)}setDrawingMetadataWithHyperlink(n,t,r,o,i){return ak(this,n,t,r,o,i)}applyImageProperties(n,t){return lk(this,n,t)}promoteStoryTransactionToPackageUnit(n,t,r,o){this.installPackageSnapshotInternal(t.package),t.historyDepth>o&&t.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:n,after:this.currentPackage()}),this.packageRev+=1;let i=t.part.name===this.body.part.name?{kind:"body",partName:t.part.name}:this.storyRefForPart(t.part.name);return this.publishSynthetic(ge.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(n){return n?(this.packageRev+=1,this.publish(n),n):null}adoptPackageUnit(n){let t=this.currentPackage();n!==t&&this.pushUndoPointer({kind:"package",before:n,after:t});}installPackageSnapshot(n){this.installPackageSnapshotInternal(n);}replacePackageShell(n){this.shellHyperlinks=FN(this.shellHyperlinks,this.pkg,n);let t=n;t=D(t,this.body.part);for(let r of this.stories.values())n.parts.has(r.part.name)&&(t=D(t,r.part));this.pkg=t;}installPackageSnapshotInternal(n){let t=WN(n,this.pkg,this.shellHyperlinks),r=t.parts.get(t.mainDocumentPart);if(!r)return;this.body.replacePart(r);for(let[i,a]of this.stories){let l=t.parts.get(i);l&&a.replacePart(l);}this.rIdToPartName.clear();let o=t.relationships.get(t.mainDocumentPart)??[];for(let i of o){if(i.type!==ck&&i.type!==uk)continue;let a=Me(i);a.mode!=="Internal"||!a.target.ok||this.stories.has(a.target.partName)&&t.parts.has(a.target.partName)&&this.rIdToPartName.set(i.id,a.target.partName);}this.pkg=t,this.pkg=D(this.pkg,this.body.part);for(let i of this.stories.values())this.pkg.parts.has(i.part.name)&&(this.pkg=D(this.pkg,i.part));}openNotesPartStore(n){let t=Ge(this.currentPackage(),n);if(!t)return {ok:false,reason:"missing-part",detail:n};let r=this.stories.get(t.name);if(r)return {ok:true,story:{kind:"notesPart",partName:t.name,noteKind:n},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=pi(t),i=new So(o,{historyLimit:this.historyLimit,settingsPart:()=>Tt(this.pkg)}),a={kind:"notesPart",partName:o.name,noteKind:n};return i.setStoryRef(a),this.stories.set(o.name,i),o!==t&&(this.pkg=D(this.pkg,o)),{ok:true,story:a,store:i}}openHeaderFooterStore(n){let t=this.rIdToPartName.get(n);if(t){let s=this.stories.get(t);if(s)return {ok:true,story:{kind:"headerFooter",partName:t,rId:n},store:s}}let r=zM(this.currentPackage(),n);if(!r.ok)return r;let o=this.stories.get(r.partName);if(o)return this.rIdToPartName.set(n,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:n},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=pi(r.part),a=new So(i,{historyLimit:this.historyLimit,settingsPart:()=>Tt(this.pkg)}),l={kind:"headerFooter",partName:i.name,rId:n};return a.setStoryRef(l),this.stories.set(i.name,a),this.rIdToPartName.set(n,i.name),i!==r.part&&(this.pkg=D(this.pkg,i)),{ok:true,story:l,store:a}}storyRefForPart(n){if(n===this.body.part.name)return {kind:"body",partName:n};for(let[r,o]of this.rIdToPartName)if(o===n)return {kind:"headerFooter",partName:n,rId:r};let t=this.currentPackage().parts.get(n);return t?.root.localName==="footnotes"?{kind:"notesPart",partName:n,noteKind:"footnote"}:t?.root.localName==="endnotes"?{kind:"notesPart",partName:n,noteKind:"endnote"}:null}syncPackageFromStore(n){this.pkg=D(this.pkg,n.part);}pushUndoPointer(n){this.undoOrder.push(n),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let n=this.retainedStoryPartNames();for(let[o]of [...this.stories])if(!n.has(o)){this.stories.delete(o);for(let[i,a]of [...this.rIdToPartName])a===o&&this.rIdToPartName.delete(i);}let t=this.retainedHyperlinkOwnerParts(n),r=HN(this.pkg,t);r!==this.pkg&&(this.pkg=r),this.shellHyperlinks=VN(this.shellHyperlinks,t,this.pkg.mainDocumentPart);}retainedStoryPartNames(){let n=new Set,t=this.pkg;for(let r of this.stories.keys())t.parts.has(r)&&n.add(r);for(let r of this.undoOrder)this.retainPointerStoryParts(r,n);for(let r of this.redoOrder)this.retainPointerStoryParts(r,n);return n}retainedHyperlinkOwnerParts(n){let t=new Set(n);t.add(this.pkg.mainDocumentPart),t.add(this.body.part.name);for(let r of this.undoOrder)this.retainPointerHyperlinkOwners(r,t);for(let r of this.redoOrder)this.retainPointerHyperlinkOwners(r,t);return t}retainPointerStoryParts(n,t){if(n.kind==="story"){t.add(n.partName);return}for(let r of this.stories.keys())(n.before.parts.has(r)||n.after.parts.has(r))&&t.add(r);}retainPointerHyperlinkOwners(n,t){if(n.kind==="story"){t.add(n.partName);return}for(let r of n.before.parts.keys())t.add(r);for(let r of n.after.parts.keys())t.add(r);}publish(n){this.lastChange=n;for(let t of this.subscribers)t(n);}publishSynthetic(n,t,r,o){this.commitCounter+=1;let i=this.packageRev-1,a={change:"model-change",fromRevision:i<0?0:i,toRevision:this.packageRev,commitId:`pkg-commit-${this.commitCounter}`,origin:n,dirty:[],created:[...o],deleted:[],splitJoin:[],dependencyKeys:[],impact:t,story:r};return this.publish(a),a}};function zM(e,n){let r=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.id===n);return r?r.type!==ck&&r.type!==uk?{ok:false,reason:"wrong-relationship-type",detail:r.type}:XM(e,r):{ok:false,reason:"dangling-relationship",detail:n}}function XM(e,n){let t=Me(n);if(t.mode==="External")return {ok:false,reason:"external-relationship",detail:n.id};if(!t.target.ok)return {ok:false,reason:"bad-relationship-target",detail:t.target.reason};let r=e.parts.get(t.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:t.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 qM=256,YM=65535,fk=64;function Jl(e,n){return e.length>n}function mk(e){return typeof e!="string"||e.trim().length===0?"invalid-author":Jl(e,qM)?"resource-limit":$(e)?null:"invalid-author"}function pk(e){return typeof e!="string"||e.length===0?"invalid-text":Jl(e,YM)?"resource-limit":$(e)?null:"invalid-text"}function Iu(e){if(typeof e!="string")return {ok:false,rejection:"invalid-date"};let n=e.trim();if(Jl(n,fk))return {ok:false,rejection:"resource-limit"};if(!$(n))return {ok:false,rejection:"invalid-date"};let t=Pi(n);return t===null?{ok:false,rejection:"invalid-date"}:Jl(t,fk)?{ok:false,rejection:"resource-limit"}:{ok:true,value:t}}function KK(e){if(e===void 0)return null;let n=Iu(e);return n.ok?null:n.rejection}function Tu(e){switch(e){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 gk(e,n){if(e.kind==="textValue")return e;let t=n.get(e.id);if(t!==void 0)return t;let r=false,o=[];for(let i of e.children){let a=gk(i,n);a!==i&&(r=true),o.push(a);}return r?{...e,children:o}:e}function JM(e,n,t){let r=gk(e.root,n);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:e.root.id,nodeId:e.root.id}]};let o=t===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:t,namespaceUri:j}]};return V(e,e.root.id,o,{deferValidation:true})}function xk(e,n,t){let r=new Map;for(let i of n){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=e;for(let[i,a]of r){let l=o.parts.get(i);if(!l)return null;let s=mi(l.root),d=s??"w14",c=new Map;for(let f of a.values())c.set(f.paragraph.id,t(f.paragraph,f.paraId,d));let u=JM(l,c,s===null?d:null);if(!u.ok)return null;o=D(o,u.part);}return o}function hk(e,n,t){let r=e.root.children.map(o=>o.kind==="textValue"?o:n.get(o.id)??o);return L(e,e.root.id,[...r,...t],{deferValidation:true})}var kk="/word/comments.xml",bk="/word/commentsExtended.xml",Au="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",Mu="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",e_=[Mu,"application/vnd.ms-word.commentsExtended+xml"],Pk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",_u="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",ar="http://schemas.microsoft.com/office/word/2012/wordml";function Uo(e,n,t){for(let r of e.attributes)if(r.localName===t&&r.namespaceUri===n)return r.value}function Do(e,n){return {kind:"genericExtension",namespaceUri:O,localName:e,prefix:"w",value:n}}function Lt(e,n,t,r,o,i,a,l=[]){return {id:e,kind:n,namespaceUri:t,localName:o,prefix:r,namespaceBindings:l,attributes:i,children:a}}function wk(e,n,t,r,o){let i=n===e.mainDocumentPart?[n]:[n,e.mainDocumentPart];for(let a of i)for(let l of it(e,a)){if(l.type!==t)continue;let s=We(a,l.rawTarget);if(!s.ok)continue;if(!e.parts.has(s.partName))return s.partName;let d=at(e,s.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return s.partName}return o}function yk(e,n,t){let r=e.mainDocumentPart;for(let o of it(e,r)){if(o.type!==n)continue;let i=We(r,o.rawTarget);if(i.ok&&i.partName===t)return e}return Gt(e,r,n,Qd(r,t)).pkg}function Du(e,n){return wk(e,n,Pk,Au,kk)}function Ek(e,n){let t=Tn(e,n),r=Nl(e,n,t).extended;return r!==null?r:wk(e,n,_u,e_,bk)}function n_(e){if(!e)return "0";let n=-1,t=r=>{if(r.kind!=="textValue"){if(r.kind==="comment"){let o=Uo(r,O,"id");if(o!==void 0&&/^\d{1,10}$/.test(o)){let i=Number(o);Number.isSafeInteger(i)&&i<=2147483647&&i>n&&(n=i);}}for(let o of r.children)t(o);}};return t(e.root),String(n+1)}function Ok(e){let n=new Set;for(let t of e.parts.values())for(let r of zn(t.root))n.add(r);return n}function t_(e,n){if(!e)return null;let t=null,r=o=>{if(!(t!==null||o.kind==="textValue")){if(o.kind==="comment"&&Uo(o,O,"id")===n){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind!=="paragraph")continue;let l=Uo(a,j,"paraId");l!==void 0&&lt(l)&&(t=l.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(e.root),t}function r_(e,n){if(!e)return null;let t=null,r=o=>{if(!(t!==null||o.kind==="textValue")){if(o.kind==="comment"&&Uo(o,O,"id")===n){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind==="paragraph"){t=a;return}}return}for(let i of o.children)r(i);}};return r(e.root),t}function Rk(e){let n=mi(e.root);if(n!==null)return {part:e,prefix:n};let t={...e.root,namespaceBindings:[...e.root.namespaceBindings,{prefix:"w14",namespaceUri:j}]};return {part:{...e,root:t},prefix:"w14"}}function Ik(e,n,t){return Lt(e.id,"paragraph",e.namespaceUri,e.prefix??"w",e.localName,[...e.attributes.filter(r=>!(r.namespaceUri===j&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:j,localName:"paraId",prefix:t,value:n}],e.children,e.namespaceBindings)}function o_(e,n,t,r){let o=e.parts.get(n);if(!o)return e;let i=Rk(o),a=R(i.part,t);if(!a||a.kind!=="paragraph")return D(e,i.part);let l=V(i.part,a.id,Ik(a,r,i.prefix),{deferValidation:true});return D(e,l.ok?l.part:i.part)}function i_(e,n,t,r){let o=`${kk}#comment-${e}`,i=t.text!==t.text.trim(),a=Lt(`${o}.t`,"text",O,"w","t",i?[{kind:"xmlSpace",namespaceUri:X,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:t.text}]),l=Lt(`${o}.rPr`,"runProperties",O,"w","rPr",[],[Lt(`${o}.rStyle`,"generic",O,"w","rStyle",[Do("val","CommentReference")],[])]),s=Lt(`${o}.r`,"run",O,"w","r",[],[l,a]),d=Lt(`${o}.pPr`,"paragraphProperties",O,"w","pPr",[],[Lt(`${o}.pStyle`,"generic",O,"w","pStyle",[Do("val","CommentText")],[])]),c=Lt(`${o}.p`,"paragraph",O,"w","p",[{kind:"genericExtension",namespaceUri:j,localName:"paraId",prefix:r,value:n}],[d,s]);return Lt(o,"comment",O,"w","comment",[Do("id",e),Do("author",t.author),...t.initials===void 0?[]:[Do("initials",t.initials)],...t.date===void 0?[]:[Do("date",t.date)]],[c])}function Cu(e,n){let t=ne(n,{name:e,contentType:"application/xml"});return t.ok?t.part.root:null}function uG(e,n){for(let y of [mk(n.author),pk(n.text)])if(y)return {ok:false,reason:Tu(y)};let t;if(n.date!==void 0){let y=Iu(n.date);if(!y.ok)return {ok:false,reason:Tu(y.rejection)};t=y.value;}let r={...n,...t===void 0?{}:{date:t}},o=e.package,i=e.part.name,a=Du(o,i),l=Ek(o,i),s=o.parts.get(a),d=n_(s),c=wn(`${a}#${d}`,Ok(o)),u=n.replyToCommentId===void 0?null:t_(s,n.replyToCommentId),f=n.replyToCommentId!==void 0&&u===null?r_(s,n.replyToCommentId):null;if(n.replyToCommentId!==void 0&&u===null&&!f)return {ok:false,reason:"unknown-revision"};let m=f?wn(`${a}#parent-${n.replyToCommentId}`,new Set([...Ok(o),c])):null,g=u??m,p=n.anchor.endParagraphId??n.anchor.paragraphId,x=e.transact(y=>{y.applyPackage(N=>{let b=N.parts.has(a)?N:(()=>{let h=Cu(a,`<w:comments xmlns:w="${O}"/>`);return h?cr(N,a,h,Au):null})();return b===null?N:yk(b,Pk,a)}),f&&m&&y.applyPackage(N=>o_(N,a,f.id,m)),y.applyPackage(N=>{let b=N.parts.get(a);if(!b)return N;let h=Rk(b),P=M(h.part,h.part.root.id,h.part.root.children.length,[i_(d,c,r,h.prefix)],{deferValidation:true});return P.ok?D(N,P.part):N}),g!==null&&(y.applyPackage(N=>{let b=N.parts.has(l)?N:(()=>{let h=Cu(l,`<w15:commentsEx xmlns:w15="${ar}"/>`);return h?cr(N,l,h,Mu):null})();return b===null?N:yk(b,_u,l)}),y.applyPackage(N=>{let b=N.parts.get(l);if(!b)return N;let P=[...a_(b).has(g.toUpperCase())?[]:[Su(`${l}#ex-${g}`,g,void 0,false)],Su(`${l}#ex-${c}`,c,g,false)],k=M(b,b.root.id,b.root.children.length,P,{deferValidation:true});return k.ok?D(N,k.part):N})),y.applyTo(i,{op:"insertCommentMarker",paragraphId:p,offset:n.anchor.end,commentId:d,marker:"reference"}),y.applyTo(i,{op:"insertCommentMarker",paragraphId:p,offset:n.anchor.end,commentId:d,marker:"end"}),y.applyTo(i,{op:"insertCommentMarker",paragraphId:n.anchor.paragraphId,offset:n.anchor.start,commentId:d,marker:"start"});});return x.ok?{ok:true,commentId:d,change:x.change}:{ok:false,reason:x.reason}}function vu(e){for(let n=e.children.length-1;n>=0;n-=1){let t=e.children[n];if(t.kind==="paragraph")return t}return null}function Nk(e){let n=vu(e);if(!n)return null;let t=Uo(n,j,"paraId");return t!==void 0&&lt(t)?t.toUpperCase():null}function a_(e){let n=new Map;if(!e)return n;let t=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===ar&&r.localName==="commentEx"){let o=Uo(r,ar,"paraId");o!==void 0&&lt(o)&&n.set(o.toUpperCase(),r);}for(let o of r.children)t(o);}};return t(e.root),n}function na(e,n){return {kind:"genericExtension",namespaceUri:ar,localName:e,prefix:"w15",value:n}}function l_(e,n){return {id:e.id,kind:"generic",namespaceUri:e.namespaceUri,localName:e.localName,...e.prefix===void 0?{}:{prefix:e.prefix},namespaceBindings:e.namespaceBindings,attributes:n,children:e.children}}function s_(e,n,t){let r=[],o=false,i=false;for(let a of e.attributes){if(a.namespaceUri===ar&&a.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:a.namespaceUri,localName:a.localName,...a.prefix===void 0?{}:{prefix:a.prefix},value:t?"1":"0"});continue}a.namespaceUri===ar&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&n!==void 0&&r.push(na("paraIdParent",n)),o||r.push(na("done",t?"1":"0")),l_(e,r)}function Su(e,n,t,r){return {id:e,kind:"generic",namespaceUri:ar,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[na("paraId",n),...t===void 0?[]:[na("paraIdParent",t)],na("done",r?"1":"0")],children:[]}}function fG(e,n,t){return d_(e,n,t,vt())}function d_(e,n,t,r){let o=e.package,i=e.part.name;if(Tn(o,i)===null)return {ok:false,reason:"unknown-comment"};let l=Xd(o,n,{storyPartName:i},r);if(!l.ok)return {ok:false,reason:"unknown-comment"};let s=Xx(o,r);if(s.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=s.used,c=new Map,u=[];for(let p of l.ids){let x=l.records.get(p);if(!x)return {ok:false,reason:"unknown-comment"};if(!vu(x.node))return {ok:false,reason:"unknown-comment"};let N=Nk(x.node),b=N??wn(`${x.partName}#done-${p}`,d);N===null&&d.add(b),c.set(p,b);}for(let p of l.ids){let x=l.records.get(p),y=vu(x.node),N=c.get(p),b=Nk(x.node),h=l.parentCommentIdByChildId.get(p),P=l.parentParaIdByCommentId.get(p)??(h===void 0?void 0:c.get(h)),k=l.commentExByParaId.get(N);u.push({paraId:N,stampParagraph:b===null?y:null,commentsPartName:x.partName,parentParaId:P,existing:k?.node,existingParentParaId:k?.parentParaId,existingDone:k?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(p=>p.existingDone===t))return {ok:true,changed:false,change:null};let f=l.extendedPartName??bk,m=l.extendedPartName===null,g=e.transact(p=>{p.applyPackage(x=>{let y=xk(x,u,Ik);if(y===null)return x;let N=y;if(!N.parts.has(f)){let E=Cu(f,`<w15:commentsEx xmlns:w15="${ar}"/>`);if(!E)return x;let w=cr(N,f,E,Mu);N=m?Gt(w,i,_u,"commentsExtended.xml").pkg:w;}let b=N.parts.get(f);if(!b)return x;let h=new Map,P=[];for(let E of u){let w=E.existingParentParaId??E.parentParaId;E.existing?h.set(E.existing.id,s_(E.existing,w,t)):P.push(Su(`${f}#done-${E.paraId}`,E.paraId,w,t));}let k=hk(b,h,P);return k.ok?D(N,k.part):x});});return g.ok?{ok:true,changed:true,change:g.change}:{ok:false,reason:g.reason}}function mG(e,n){let t=Du(e,n);return e.parts.has(t)&&at(e,t)===Au}function pG(e,n){return Du(e,n)}function gG(e,n){return Ek(e,n)}var c_=256*1024,u_=4096;function bG(e,n,t){let r=n.payload,o=e.part.name,i=t??o;if(r){if(r.data.length>c_)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>u_)return {ok:false,reason:"payload-too-large",detail:"label"}}let a=new Set(Se(e.part.root).map(f=>f.node.id)),l=n.replaceControlId===void 0?[]:Ck(e,o,n.replaceControlId),s=null,d,c=e.transact(f=>{if(n.replaceControlId!==void 0){f.apply({op:"removeContentControl",controlId:n.replaceControlId,keepContent:false});for(let p of l)f.applyPackage(x=>tc(x,p.partName,p.nodeId));}let m=n.replaceUntil;if(m!==void 0&&m<=n.offset){s="invalid-range",d="replaceUntil must be past offset";return}if(m!==void 0&&f.apply({op:"deleteText",paragraphId:n.paragraphId,start:n.offset,end:m}),!r){f.apply({op:"insertInlineContentControl",paragraphId:n.paragraphId,offset:n.offset,tag:n.tag,text:n.text,...n.alias===void 0?{}:{alias:n.alias},...n.lock===void 0?{}:{lock:n.lock}});return}let g=null;f.applyPackage(p=>{let x=xh(p,i,r.namespaceUri,r.rootLocalName);if(!x.part)return s="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,p;if(g=Ih(x.part,r.rootLocalName,r.nodeId),!g)return s="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,p;let y=bh(x.pkg,x.part.partName,{id:r.nodeId,label:r.label,data:r.data});return kh(y,x.part.partName,r.nodeId)?y:(s="store-not-authored",d="the payload node could not be written into the store",p)}),!(s!==null||!g)&&f.apply({op:"insertInlineContentControl",paragraphId:n.paragraphId,offset:n.offset,tag:n.tag,text:n.text,...n.alias===void 0?{}:{alias:n.alias},...n.lock===void 0?{}:{lock:n.lock},dataBinding:g});});if(s!==null)return {ok:false,reason:s,...d===void 0?{}:{detail:d}};if(!c.ok)return {ok:false,reason:c.reason,...c.detail===void 0?{}:{detail:c.detail}};let u=f_(e,a);return {ok:true,change:c.change,...u===void 0?{}:{nodeId:u}}}function f_(e,n){for(let t of Se(e.part.root))if(!n.has(t.node.id))return t.node.id}function Ck(e,n,t){let r=Se(e.part.root).find(i=>i.node.id===t);if(!r)return [];let o=[];for(let i of _i(e.package,n)){let a=Rl(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function PG(e,n){let t=e.part.name,r=Ck(e,t,n),o=e.transact(i=>{i.apply({op:"removeContentControl",controlId:n,keepContent:false});for(let a of r)i.applyPackage(l=>tc(l,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 wG(e,n,t){if(!e.parts.has(n)||t.length===0)return {ok:true,pkg:e,removed:[]};let r=e,o=[];for(let i of t){let a=Mi(r,n,i);if(!a)continue;let l=Ch(r,a.itemId),s=Ph(r,a.partName,l);if(s.pkg===r&&Li(r,a.partName).some(d=>!l.has(d.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=s.pkg,o.push(...s.removed);}return {ok:true,pkg:r,removed:o}}var Tk=new WeakMap;function m_(e,n){let t=Tk.get(e);t||(t=new Map,Tk.set(e,t));let r=t.get(n);if(r)return r;let o=_i(e,n).map(i=>({itemId:i.itemId,nodes:new Map(Li(e,i.partName).map(a=>[a.id,a]))}));return t.set(n,o),o}function EG(e,n,t=n){let r=new Map,o=e.parts.get(n);if(!o)return r;let i=m_(e,t);if(i.length===0)return r;for(let a of Se(o.root))for(let l of i){let s=Rl(a.node,l.itemId);if(s===null)continue;let d=l.nodes.get(s);if(d){r.set(a.node.id,{nodeId:s,label:d.label,data:d.data});break}}return r}function RG(e,n,t){let r=new Map,o=Mi(e,n,t);if(!o)return r;for(let i of Li(e,o.partName))r.set(i.id,{label:i.label,data:i.data});return r}var p_=new Set(nr),Lu=new Set(er);function MG(e){return Lu.has(e)}function es(e,n,t){return !e||e.kind==="textValue"?void 0:e.children.find(o=>o.kind===n||o.kind==="generic"&&o.localName===t&&o.namespaceUri===O)}function Bu(e,n){if(!e||e.kind==="textValue")return [];let t=[];for(let r of e.children){if(r.kind==="textValue"||!n.has(r.localName))continue;let o=cs();for(let i of r.attributes)o[i.localName]=i.value;t.push(Object.keys(o).length>0?{localName:r.localName,attributes:o}:{localName:r.localName});}return t}function _G(e,n){let t=R(e,n);return Bu(es(t,"paragraphProperties","pPr"),p_)}function g_(e,n){let t=R(e,n),r=es(t,"paragraphProperties","pPr");return Bu(es(r,"runProperties","rPr"),Lu)}function vk(e,n){let t=Array.isArray(n)?n:[n],r=new Set(t.map(i=>i.localName));return [...e.filter(i=>!r.has(i.localName)),...t]}var x_=new Map([["ascii","asciiTheme"],["hAnsi","hAnsiTheme"],["eastAsia","eastAsiaTheme"],["cs","cstheme"]]);function h_(e,n){let t=e.find(o=>o.localName==="rFonts")?.attributes;if(!t)return n;let r={...t,...n.attributes??{}};for(let o of Object.keys(n.attributes??{})){let i=x_.get(o);i&&delete r[i];}return {localName:"rFonts",attributes:r}}function Sk(e){let n=new Map;for(let t of Q(e)){let r=t.formatRunIds&&t.formatRunIds.length>0?t.formatRunIds:t.runId?[t.runId]:[];for(let o of r){let i=n.get(o);i?(i.start=Math.min(i.start,t.start),i.end=Math.max(i.end,t.end)):n.set(o,{start:t.start,end:t.end});}}return n}function y_(e){let n=new Set;for(let t of Q(e))if(t.formatRunIds)for(let r of t.formatRunIds)n.add(r);return n}function Uu(e,n){if(n.localName==="rFonts")return h_(e,n);if(n.localName!=="u")return n;let t=e.find(r=>r.localName==="u")?.attributes;return t?{localName:"u",attributes:{...t,...n.attributes??{}}}:n}function DG(e,n,t){let r=g_(e,n),o=Array.isArray(t)?t:[t];return vk(r,o.map(i=>Uu(r,i)))}function O_(e,n){return Array.isArray(n)?n.map(t=>Uu(e,t)):Uu(e,n)}function UG(e,n,t,r,o){let i=R(e,n);if(!i||i.kind!=="paragraph")return [];let a=[],l=Sk(i),s=y_(i),d=c=>{if(c.kind==="hyperlink"){for(let p of c.children)d(p);return}if(c.kind==="fldSimple"||c.kind==="generic"&&c.localName==="fldSimple"){for(let p of c.children)d(p);return}if(c.kind!=="run")return;let u=l.get(c.id);if(!u||u.end<=u.start)return;let f=Math.max(u.start,t),m=Math.min(u.end,r);if(f>=m)return;let g=Bu(es(c,"runProperties","rPr"),Lu);a.push({start:f,end:m,properties:vk(g,O_(g,o)),...s.has(c.id)?{targetRunIds:[c.id]}:{}});};for(let c of i.children)d(c);return a}function LG(e,n,t,r){let o=R(e,n);if(!o||o.kind!=="paragraph")return [];let i=Sk(o),a=[],l=s=>{if(s.kind==="hyperlink"){for(let u of s.children)l(u);return}if(s.kind==="fldSimple"||s.kind==="generic"&&s.localName==="fldSimple"){for(let u of s.children)l(u);return}if(s.kind!=="run")return;let d=i.get(s.id);if(!d||d.end<=d.start)return;(r>t?Math.max(d.start,t)<Math.min(d.end,r):d.start<=t&&t<d.end)&&a.push(s);};for(let s of o.children)l(s);return a}function Fu(e){let n=Mk.get(e.root);if(n)return n;let t=new Map,r=a=>{let l=Ak.get(a);if(l){for(let[d,c]of l)t.set(d,c);return}let s=new Map;k_(a,s),Ak.set(a,s);for(let[d,c]of s)t.set(d,c);},o=(a,l)=>{if(!(a.kind==="textValue"||l>64)){if(a.kind==="paragraph"){r(a);return}for(let s of a.children)o(s,l+1);}};o(e.root,0);let i=(a,l)=>{if(!(a.kind==="textValue"||l>64)){if(a.kind==="paragraph"){let s=_k.get(a);if(!s){let d=[];Dk(a,0,d),s=d,_k.set(a,s);}for(let[d,c]of s)t.set(d,c);return}if(a.kind==="tableRow"){let s=ns.get(a);s||(s=Uk(a),ns.set(a,s));for(let[d,c]of s)t.set(d,c);}for(let s of a.children)i(s,l+1);}};return i(e.root,0),Mk.set(e.root,t),t}function Dk(e,n,t){if(!(e.kind==="textValue"||n>64)){if(e.kind==="tableRow"){let r=ns.get(e);r||(r=Uk(e),ns.set(e,r));for(let o of r)t.push(o);}for(let r of e.children)Dk(r,n+1,t);}}function Uk(e){let n=null,t=(a,l)=>{if(!(n||a.kind==="textValue"||l>64)){if(a.kind==="paragraph"){n=a;return}for(let s of a.children)t(s,l+1);}};if(t(e,0),!n)return N_;let r={paragraphId:n.id,start:0,end:0},o=[],i=(a,l,s)=>{if(a.kind==="textValue"||s>64||a.kind==="paragraph")return;let d=l==="trPr"&&(a.localName==="ins"||a.localName==="del"),c=l==="tcPr"&&(a.localName==="cellIns"||a.localName==="cellDel");(d||c)&&o.push([a.id,r]);for(let u of a.children)i(u,a.localName,s+1);};return i(e,void 0,0),o}var N_=[],Ak=new WeakMap,Mk=Qt(8),ns=new WeakMap,_k=new WeakMap;function k_(e,n){let t=Pe(e),r=(a,l,s,d)=>{if(!(a.kind==="textValue"||d>64)){n.set(a.id,{paragraphId:e.id,start:l,end:s});for(let c of a.children)r(c,l,s,d+1);}},o=(a,l)=>{if(a.kind==="textValue"||l>64)return;let s=t.spanOf(a);if(a.kind==="run"){if(!s)return;n.set(a.id,{paragraphId:e.id,start:s.start,end:s.end});for(let d of a.children)d.kind==="runProperties"&&r(d,s.start,s.end,l+1);return}s&&n.set(a.id,{paragraphId:e.id,start:s.start,end:s.end});for(let d of a.children)o(d,l+1);};for(let a of e.children)a.kind!=="paragraphProperties"&&o(a,0);let i=e.children.find(a=>a.kind==="paragraphProperties");i&&r(i,t.length,t.length,0);}function HG(e){return `${e.kind}-${e.id}`}function Bk(e){return e.kind==="revision"?e.ranges:e.range?[e.range]:[]}function b_(e){return Bk(e)[0]??null}function Vu(e,n){let t=b_(e);if(!t)return Number.MAX_SAFE_INTEGER;let r=n.get(t.start.paragraphId);return r===void 0?Number.MAX_SAFE_INTEGER:r*1e6+Math.min(t.start.offset,999999)}function P_(e,n){let t=n.get(e.start.paragraphId),r=n.get(e.end.paragraphId);return t===void 0||r===void 0?Number.MAX_SAFE_INTEGER:(r-t)*1e6+(e.end.offset-e.start.offset)}var w_=0,E_=1,R_=2;function I_(e,n,t){let r=t.get(n.paragraphId),o=t.get(e.start.paragraphId),i=t.get(e.end.paragraphId);return r===void 0||o===void 0||i===void 0||r<o||r>i||r===o&&n.offset<e.start.offset||r===i&&n.offset>e.end.offset?null:o===i&&e.start.offset===e.end.offset?w_:r===i&&n.offset===e.end.offset?R_:E_}function T_(e,n,t){let r=null;for(let o of Bk(e)){let i=I_(o,n,t);if(i===null)continue;let a=P_(o,t);(r===null||i<r.grip||i===r.grip&&a<r.width)&&(r={grip:i,width:a});}return r}var Lk={comment:0,custom:1,revision:2};function C_(e,n,t){let r=[];for(let o of e){let i=T_(o,n,t);i!==null&&r.push({item:o,grip:i.grip,width:i.width});}return r.sort((o,i)=>o.grip!==i.grip?o.grip-i.grip:o.width!==i.width?o.width-i.width:o.item.kind!==i.item.kind?Lk[o.item.kind]-Lk[i.item.kind]:o.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-o.item.nesting:0).map(o=>o.item)}function jG(e,n,t){let o=C_(e,n,t).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return o?o.kind==="comment"?Fk(e,o):o:null}function KG(e,n){return Fk(e,n)}function Fk(e,n){let t=new Map,r=new Map;for(let a of e)a.kind==="comment"?t.set(a.id,a):a.kind==="revision"&&r.set(a.id,a);let o=new Set([n.id]),i=n;for(;i.parentId!==void 0;){let a=t.get(i.parentId);if(!a||o.has(a.id))break;o.add(a.id),i=a;}if(i.parentRevisionId!==void 0){let a=r.get(i.parentRevisionId);if(a)return a}return i}var v_={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function QG(e){let n=[],t=r=>{if(r.kind==="textValue"){n.push(r.value);return}for(let o of r.children)t(o);};for(let r of e.blocks)t(r);return n.join("")}function JG(e){if(e.initials&&e.initials.trim().length>0)return e.initials.trim();let n=e.author.trim().split(/\s+/).filter(Boolean);return n.length===0?"?":n.slice(0,2).map(t=>t[0].toUpperCase()).join("")}function ts(e,n){for(let t of e.attributes)if(t.localName===n&&t.namespaceUri===O)return t.value}function ta(e){if(e.kind==="textValue")return e.value;let n="";for(let t of e.children)n+=ta(t);return n}function Wu(e){return `${e.id}\0${e.author}\0${e.date??""}`}var S_={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo"};function A_(e){let n=e.root.kind!=="paragraph";if(n){let r=Vk.get(e.root);if(r&&r.name===e.name)return r.items}let t=M_(e);return n&&Vk.set(e.root,{name:e.name,items:t}),t}var Vk=Qt(8);function M_(e){let n=Fu(e),t=new Map;for(let o of _h(e)){let i=ts(o.node,"id");if(i===void 0)continue;let a=ts(o.node,"author")??"",l=ts(o.node,"author")===void 0,s=ts(o.node,"date"),d=s===void 0?{id:i,author:a}:{id:i,author:a,date:s},c=o.propertyChange?"format":o.paragraphMark?"paragraphMark":S_[o.node.kind]??"structural",u=o.paragraphMark?v_[o.node.localName]:void 0,f=n.get(o.node.id),m=f?{partName:e.name,start:{paragraphId:f.paragraphId,offset:f.start},end:{paragraphId:f.paragraphId,offset:f.end}}:null,g=c==="structural"?`structural\0${Wu(d)}`:`${o.node.localName}\0${Wu(d)}`,p=t.get(g);if(p){m&&!p.ranges.some(x=>x.partName===m.partName&&x.start.paragraphId===m.start.paragraphId&&x.start.offset===m.start.offset&&x.end.paragraphId===m.end.paragraphId&&x.end.offset===m.end.offset)&&p.ranges.push(m),c!=="structural"&&p.revisionKind==="structural"&&(p.revisionKind=c),(c==="insert"&&p.revisionKind==="delete"||c==="delete"&&p.revisionKind==="insert"||p.revisionKind==="replace")&&(p.revisionKind="replace"),p.readOnly||=o.refused||l,o.nesting>p.nesting&&(p.nesting=o.nesting),c==="delete"||c==="moveFrom"?p.deletedText+=ta(o.node):c!=="format"&&c!=="paragraphMark"&&(p.text+=ta(o.node));continue}t.set(g,{address:d,revisionKind:c,...u?{markDirection:u}:{},author:a,...s===void 0?{}:{date:s},text:c==="format"||c==="paragraphMark"||c==="delete"||c==="moveFrom"?"":ta(o.node),deletedText:c==="delete"||c==="moveFrom"?ta(o.node):"",ranges:m?[m]:[],nesting:o.nesting,readOnly:o.refused||l});}let r=[...t.values()].map(o=>({kind:"revision",id:`${o.revisionKind}-${e.name}\0${Wu(o.address)}`,address:o.address,addresses:[o.address],revisionKind:o.revisionKind,...o.markDirection?{markDirection:o.markDirection}:{},author:o.author,...o.date===void 0?{}:{date:o.date},text:o.revisionKind==="replace"?o.text:o.text||o.deletedText,replacedText:o.revisionKind==="replace"?o.deletedText:"",ranges:o.ranges,nesting:o.nesting,readOnly:o.readOnly,replyIds:[]}));return __(r,Hu(e))}function __(e,n){let t=D_(e),r=t.filter(s=>(s.revisionKind==="insert"||s.revisionKind==="delete")&&!s.readOnly&&s.ranges.length>0),o=new Set,i=new Map,a=new Map;for(let s of r){if(s.revisionKind!=="insert")continue;let d=s.ranges[0].start,c=`${d.paragraphId}\0${d.offset}`,u=a.get(c);u?u.push(s):a.set(c,[s]);}for(let s of r){if(s.revisionKind!=="delete"||o.has(s.id))continue;let d=s.ranges[s.ranges.length-1].end,c=a.get(`${d.paragraphId}\0${d.offset}`)??[],u=c.length>1?[...c].sort((f,m)=>(f.text.length>0?0:1)-(m.text.length>0?0:1)):c;for(let f of u){if(o.has(f.id)||f.author!==s.author)continue;o.add(s.id),o.add(f.id);let m=V_(s.ranges[0],f.ranges[0],n)?s:f,g=F_(s.date,f.date);i.set(s.id,{...m,id:`replace-${s.id}-${f.id}`,revisionKind:"replace",...g===void 0?{}:{date:g},addresses:B_([...s.addresses,...f.addresses]),text:f.text,replacedText:s.text,ranges:[...s.ranges,...f.ranges],replacedRangeCount:s.ranges.length,readOnly:s.readOnly||f.readOnly});break}}let l=[];for(let s of t){let d=i.get(s.id);if(d){l.push(d);continue}o.has(s.id)||l.push(s);}return l}function D_(e){let n=e.filter(s=>(s.revisionKind==="insert"||s.revisionKind==="delete")&&!s.readOnly&&s.ranges.length>0);if(n.length<2)return e;let t=(s,d)=>`${s.revisionKind}\0${s.author}\0${d.paragraphId}\0${d.offset}`,r=new Map,o=new Set;for(let s of n)r.set(t(s,s.ranges[0].start),s),o.add(t(s,s.ranges[s.ranges.length-1].end));let i=new Set,a=new Map;for(let s of n){if(i.has(s.id)||o.has(t(s,s.ranges[0].start)))continue;let d=[s],c=s;for(;;){let u=r.get(t(c,c.ranges[c.ranges.length-1].end));if(!u||u===c||i.has(u.id))break;i.add(u.id),d.push(u),c=u;}d.length>1&&a.set(s.id,U_(d));}if(a.size===0)return e;let l=[];for(let s of e)i.has(s.id)||l.push(a.get(s.id)??s);return l}function U_(e){let n=e[0],t=[...n.addresses],r=[...n.ranges],o=n.text,i=n.date;for(let a of e.slice(1)){for(let l of a.addresses)t.some(s=>Gk(s,l))||t.push(l);for(let l of a.ranges)r.push(l);o+=a.text,i=L_(i,a.date);}return {...n,id:e.map(a=>a.id).join("+"),addresses:t,ranges:r,text:o,...i===void 0?{}:{date:i}}}function L_(e,n){if(e===void 0)return n;if(n===void 0)return e;let t=Date.parse(e),r=Date.parse(n);return Number.isNaN(t)||Number.isNaN(r)?e:r>t?n:e}function B_(e){let n=[];for(let t of e)n.some(r=>Gk(r,t))||n.push(t);return n}function Gk(e,n){return e.id===n.id&&e.author===n.author&&(e.date??"")===(n.date??"")}function F_(e,n){if(n===void 0)return e;if(e===void 0)return n;let t=Date.parse(e),r=Date.parse(n);return Number.isNaN(t)||Number.isNaN(r)?n:t>r?e:n}function V_(e,n,t){let r=t.get(e.start.paragraphId)??0,o=t.get(n.start.paragraphId)??0;return r!==o?r<o:e.start.offset<=n.start.offset}function W_(e,n,t){let r=new Map(n.map(c=>[c.commentId,c])),o=new Map,i=new Map;for(let c of e)c.paraId&&o.set(c.paraId.toUpperCase(),c),i.set(c.id,c);let a=new Map,l=new Map;for(let c of e){let u=r.get(c.id);if(!u||u.orphaned||u.start.paragraphId===u.end.paragraphId&&u.start.offset===u.end.offset)continue;let f=`${u.start.paragraphId}:${u.start.offset}|${u.end.paragraphId}:${u.end.offset}`;a.has(f)?l.set(c.id,a.get(f)):a.set(f,c.id);}let s=new Map;for(let c of e){let u=c.paraId?t.get(c.paraId.toUpperCase()):void 0,f=u?.parentParaId?o.get(u.parentParaId):void 0,m=c.parentCommentId?i.get(c.parentCommentId):void 0,g=u===void 0?l.get(c.id):void 0,p=g?i.get(g):void 0,x=f??m??p;x&&x.id!==c.id&&s.set(c.id,x.id);}for(let c of [...s.keys()]){let u=new Set([c]),f=s.get(c);for(;f!==void 0;){if(u.has(f)){s.delete(c);break}u.add(f),f=s.get(f);}}let d=new Map;for(let[c,u]of s){let f=d.get(u);f?f.push(c):d.set(u,[c]);}return e.map(c=>{let u=r.get(c.id),f=c.paraId?t.get(c.paraId.toUpperCase()):void 0,m=s.get(c.id);return {kind:"comment",id:c.id,comment:c,range:u?{partName:u.partName,start:u.start,end:u.end}:null,resolved:f?.done??false,...m===void 0?{}:{parentId:m},replyIds:d.get(c.id)??[],orphaned:u===void 0||u.orphaned}})}function e$(e){let n=[e.storyPart],t=new Set([e.storyPart.name]);for(let d of e.furnitureParts??[])t.has(d.name)||(t.add(d.name),n.push(d));let r=e.commentsPart?Qx(e.commentsPart):[],o=e.commentsExtendedPart?Jx(e.commentsExtendedPart):new Map,i=[],a=[],l=n.length===1?Hu(n[0]):new Map;for(let d of n){for(let f of A_(d))i.push(f);for(let f of Zx(d))a.push(f);if(n.length===1)continue;let c=l,u=c.size;for(let[f,m]of Hu(d))c.has(f)||c.set(f,u+m);}return H_([...i,...W_(r,a,o)]).sort((d,c)=>Vu(d,l)-Vu(c,l))}function Wk(e){return `${e.partName}\0${e.start.paragraphId}:${e.start.offset}|${e.end.paragraphId}:${e.end.offset}`}function H_(e){let n=new Map;for(let a of e)if(a.kind==="revision")for(let l of a.ranges??[]){if(l.start.paragraphId===l.end.paragraphId&&l.start.offset===l.end.offset)continue;let s=Wk(l),d=a.nesting??0,c=n.get(s);(c===void 0||d>c.nesting)&&n.set(s,{id:a.id,nesting:d});}let t=new Map;for(let a of e)a.kind==="comment"&&a.replyIds&&a.replyIds.length>0&&t.set(a.id,a.replyIds);let r=a=>{let l=[],s=new Set([a]),d=[...t.get(a)??[]];for(;d.length>0;){let c=d.shift();s.has(c)||(s.add(c),l.push(c),d.push(...t.get(c)??[]));}return l},o=new Map,i=new Map;for(let a of e){if(a.kind!=="comment"||a.parentId!==void 0||a.orphaned||!a.range)continue;let l=n.get(Wk(a.range))?.id;if(l===void 0)continue;let s=[a.id,...r(a.id)];for(let c of s)i.set(c,l);let d=o.get(l);d?d.push(...s):o.set(l,s);}return e.map(a=>{if(a.kind==="revision"){let l=o.get(a.id)??[];return l.length===0&&(a.replyIds??[]).length===0?a:{...a,replyIds:l}}if(a.kind==="comment"){let l=i.get(a.id);if(l===void 0){if(a.parentRevisionId===void 0)return a;let{parentRevisionId:s,...d}=a;return d}return a.parentRevisionId===l?a:{...a,parentRevisionId:l}}return a})}function Hu(e){let n=Hk.get(e.root);if(n)return n;let t=new Map,r=(o,i)=>{if(!(o.kind==="textValue"||i>64)){if(o.kind==="paragraph"){t.has(o.id)||t.set(o.id,t.size);return}if(o.kind==="table"){let a=Kk.get(o);if(!a){let l=[],s=(d,c)=>{if(!(d.kind==="textValue"||c>64)){if(d.kind==="paragraph"){l.push(d.id);return}for(let u of d.children)s(u,c+1);}};for(let d of o.children)s(d,0);a=l,Kk.set(o,a);}for(let l of a)t.has(l)||t.set(l,t.size);return}for(let a of o.children)r(a,i+1);}};return r(e.root,0),Hk.set(e.root,t),t}var Hk=Qt(8);function n$(e){let n=jk.get(e.root);if(n)return n;let t=new Map,r=(o,i)=>{if(!(o.kind==="textValue"||i>64)){o.kind==="paragraph"&&!t.has(o.id)&&t.set(o.id,t.size);for(let a of o.children)r(a,i+1);}};return r(e.root,0),jk.set(e.root,t),t}var jk=Qt(8),Kk=new WeakMap;var o$=256,i$=2e3,$k=/[\p{L}\p{N}_]/u;function zk(e){let n=e.toLowerCase();if(n.length===e.length)return n;let t="";for(let r=0;r<e.length;r+=1){let o=e[r],i=o.toLowerCase();t+=i.length===1?i:o;}return t}function j_(e,n,t){let r=n>0?e[n-1]:void 0,o=t<e.length?e[t]:void 0;return !(r!==void 0&&$k.test(r)||o!==void 0&&$k.test(o))}function K_(e){return typeof e=="string"&&e.length>0&&e.length<=256}function a$(e,n,t,r={}){let o={matches:[],truncated:false};if(!K_(n)||e.length===0||t<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,l=i?n:zk(n),s=i?e:zk(e),d=Math.max(0,r.from??0),c=Math.min(e.length,r.to??e.length),u=[],f=s.indexOf(l,d);for(;f>=0;){let m=f+l.length;if(m>c)return {matches:u,truncated:false};if(!a||j_(e,f,m)){if(u.length>=t)return {matches:u,truncated:true};u.push({start:f,length:l.length});}f=s.indexOf(l,m);}return {matches:u,truncated:false}}
10
- export{OD as $,$w as $a,W1 as $b,Tg as $c,kT as $d,xh as $e,PG as $f,ls as A,oe as Aa,$t as Ab,rL as Ac,vd as Ad,xl as Ae,kV as Af,QG as Ag,Bt as B,Ot as Ba,Fa as Bb,za as Bc,yr as Bd,Ri as Be,bV as Bf,JG as Bg,la as C,Cs as Ca,E1 as Cb,oL as Cc,It as Cd,hl as Ce,cc as Cf,A_ as Cg,ef as D,sm as Da,Wa as Db,iL as Dc,ro as Dd,lF as De,mc as Df,W_ as Dg,Me as E,dm as Ea,R1 as Eb,aL as Ec,oo as Ed,cC as Ee,Jh as Ef,e$ as Eg,_r as F,QP as Fa,Up as Fb,tI as Fc,rT as Fd,Ci as Fe,Cl as Ff,H_ as Fg,ub as G,an as Ga,mr as Gb,cg as Gc,rB as Gd,Hx as Ge,er as Gf,Hu as Gg,ss as H,cm as Ha,Qe as Hb,yd as Hc,oB as Hd,uF as He,nr as Hf,n$ as Hg,mb as I,JP as Ia,ja as Ib,mg as Ic,Tt as Id,fF as Ie,vl as If,o$ as Ig,cs as J,Ss as Ja,li as Jb,uI as Jc,iB as Jd,Ti as Je,pu as Jf,i$ as Jg,sD as K,lU as Ka,sd as Kb,fL as Kc,aB as Kd,Qt as Ke,ql as Kf,zk as Kg,yt as L,_n as La,C1 as Lb,pg as Lc,lB as Ld,bl as Le,EM as Lf,j_ as Lg,xb as M,Wr as Ma,dd as Mb,pI as Mc,sB as Md,Zx as Me,So as Mf,K_ as Mg,$ as N,Cm as Na,Ha as Nb,kd as Nc,Kg as Nd,Qx as Ne,$M as Nf,a$ as Ng,cD as O,Kt as Oa,zt as Ob,hL as Oc,Gg as Od,Jx as Oe,dk as Of,uD as P,rt as Pa,Et as Pb,lt as Pc,$g as Pd,Kd as Pe,mk as Pf,Nb as Q,sw as Qa,SR as Qb,Xa as Qc,ye as Qd,LF as Qe,pk as Qf,bb as R,Ds as Ra,si as Rb,fi as Rc,Yn as Rd,BF as Re,Iu as Rf,fD as S,Sm as Sa,_R as Sb,wn as Sc,Vn as Sd,FF as Se,KK as Sf,mD as T,Dw as Ta,_1 as Tb,zn as Tc,Q as Td,dh as Te,uG as Tf,Dr as U,dr as Ua,UR as Ub,mi as Uc,Pe as Ud,ph as Ue,fG as Uf,tt as V,Mm as Va,Gp as Vb,Rt as Vc,rx as Vd,gh as Ve,mG as Vf,Ab as W,wU as Wa,L1 as Wb,pi as Wc,ox as Wd,Zd as We,pG as Wf,hD as X,RU as Xa,Ga as Xb,EI as Xc,Or as Xd,wl as Xe,gG as Xf,Mb as Y,IU as Ya,$p as Yb,qa as Yc,xT as Yd,ch as Ye,c_ as Yf,be as Z,TU as Za,LR as Zb,CL as Zc,wi as Zd,_i as Ze,u_ as Zf,Db as _,Ww as _a,gr as _b,Ed as _c,Ge as _d,Mi as _e,bG as _f,zu as a,uf as aa,zr as ab,md as ac,ZI as ad,Nr as ae,XF as af,wG as ag,ge as b,An as ba,Xw as bb,H1 as bc,Id as bd,EB as be,Li as bf,EG as bg,$_ as c,O as ca,qw as cb,Xt as cc,xi as cd,RB as ce,kh as cf,RG as cg,z_ as d,X as da,Zw as db,di as dc,WL as dd,mx as de,bh as df,p_ as dg,Yk as e,He as ea,cE as eb,FR as ec,HL as ed,Ud as ee,tc as ef,Lu as eg,Zk as f,$n as fa,ni as fb,Qr as fc,Bg as fd,Px as fe,Ph as ff,MG as fg,sr as g,Ye as ga,zm as gb,pd as gc,jL as gd,Ex as ge,wh as gf,es as gg,X_ as h,he as ha,qm as hb,j1 as hc,KL as hd,ml as he,Eh as hf,Bu as hg,Xu as i,PP as ia,xE as ib,K1 as ic,GL as id,Mx as ie,Rh as if,_G as ig,Qk as j,Xo as ja,Qm as jb,gd as jc,$L as jd,Bx as je,Ih as jf,g_ as jg,Y_ as k,Fr as ka,Jm as kb,qp as kc,zL as kd,tF as ke,XC as kf,vk as kg,oa as l,Zf as la,Xr as lb,G1 as lc,XL as ld,rF as le,Ch as lf,h_ as lg,eb as m,Qf as ma,ep as mb,$1 as mc,qL as md,pl as me,Rl as mf,Sk as mg,Ar as n,ws as na,Zm as nb,Zp as nc,YL as nd,Bd as ne,_h as nf,y_ as ng,is as o,SP as oa,KU as ob,YR as oc,ZL as od,Ii as oe,Nc as of,Uu as og,ia as p,qo as pa,GU as pb,$a as pc,hr as pd,gl as pe,Hn as pf,DG as pg,J_ as q,XD as qa,D as qb,z1 as qc,gn as qd,oF as qe,K as qf,UG as qg,xe as r,ne as ra,Xs as rb,Qp as rc,Cd as rd,uo as re,cn as rf,LG as rg,eD as s,eU as sa,it as sb,Jr as sc,hi as sd,tC as se,nn as sf,Fu as sg,as as t,S as ta,at as tb,Jp as tc,el as td,Wn as te,NW as tf,HG as tg,G as u,om as ua,ot as ub,xd as uc,Fg as ud,aC as ue,jh as uf,Bk as ug,nD as v,R as va,Yr as vb,q1 as vc,QL as vd,Se as ve,yo as vf,b_ as vg,We as w,Ce as wa,Ys as wb,ci as wc,JL as wd,iF as we,Kh as wf,Vu as wg,Mr as x,L as xa,Gt as xb,eo as xc,yi as xd,aF as xe,yV as xf,C_ as xg,Qu as y,M as ya,cr as yb,no as yc,nl as yd,Fd as ye,OV as yf,jG as yg,Ju as z,V as za,dp as zb,ag as zc,Oi as zd,fo as ze,NV as zf,KG as zg};