@docx-editor.dev/core 2.25.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +20 -9
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.js +1 -1
- package/dist/chunk-2BK4G4ZN.js +2 -0
- package/dist/chunk-2SJX44PC.cjs +2 -0
- package/dist/chunk-5BIASAN3.js +1 -0
- package/dist/{chunk-WVJRO4WY.js → chunk-6SEIXJTX.js} +1 -1
- package/dist/chunk-73PG6L2X.js +1 -0
- package/dist/chunk-7RJSH72J.cjs +5 -0
- package/dist/chunk-AGKIHLWQ.cjs +1 -0
- package/dist/chunk-AN6WM4X4.js +2 -0
- package/dist/chunk-ANZ44KQT.cjs +12 -0
- package/dist/chunk-CYT3OQFZ.cjs +1 -0
- package/dist/chunk-DDGGSBAN.js +12 -0
- package/dist/chunk-EEAV3WIN.js +3 -0
- package/dist/{chunk-MEF2AK5L.cjs → chunk-ELQFXMJ5.cjs} +1 -1
- package/dist/chunk-EYK4K2J6.js +1 -0
- package/dist/chunk-JNTETUNZ.cjs +1 -0
- package/dist/chunk-L6V3IJ3S.js +5 -0
- package/dist/chunk-LWCI65EL.js +1 -0
- package/dist/chunk-LZDI4P6I.cjs +1 -0
- package/dist/chunk-NS22DVWT.cjs +2 -0
- package/dist/chunk-QIE3YTU4.cjs +2 -0
- package/dist/chunk-QVBFPAGO.js +5 -0
- package/dist/chunk-RCCOLZEQ.js +2 -0
- package/dist/chunk-SUN62YU6.cjs +5 -0
- package/dist/chunk-TKR2MXX4.cjs +3 -0
- package/dist/chunk-UJL2GDIM.cjs +25 -0
- package/dist/chunk-WQTADNHK.cjs +27 -0
- package/dist/chunk-XSHXBJ2J.js +25 -0
- package/dist/chunk-YXZEBTDF.js +27 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.js +1 -1
- package/dist/contracts/editor.d.ts +3 -3
- package/dist/{editor-DkfCCTxA.d.ts → editor-DYUlyKmb.d.ts} +1 -1
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +14 -2
- package/dist/editor.d.ts +13 -13
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +5 -5
- package/dist/export.js +2 -2
- package/dist/{font-resolver-C295obND.d.ts → font-resolver-u_nE0PI1.d.ts} +5 -3
- package/dist/{index-3KAxeSic.d.ts → index-Docw8Dcb.d.ts} +6 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-C889tgmj.d.ts → layout-shaping-DWitwY73.d.ts} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +89 -23
- package/dist/layout.js +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +3 -3
- package/dist/output.js +1 -1
- package/dist/{protocol-BhmenALD.d.ts → protocol-DniKeDb8.d.ts} +28 -1
- package/dist/{review-paragraph-order-BwhRT264.d.ts → review-paragraph-order-Dc8Q6tfM.d.ts} +5 -1
- package/dist/{semantic-cell-selection-CC3NwCtx.d.ts → semantic-cell-selection-Dy_BmmpL.d.ts} +23 -5
- package/dist/{semantic-interaction-BHlV61hK.d.ts → semantic-interaction-CvFAj0GR.d.ts} +1 -1
- package/dist/{semantic-paint-DfWIWUs6.d.ts → semantic-paint-Bk9wIXdZ.d.ts} +1 -1
- package/dist/{semantic-records-DrExlBy-.d.ts → semantic-records-COqi8pjP.d.ts} +77 -70
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +57 -5
- package/dist/store.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-3RMHRNDA.cjs +0 -1
- package/dist/chunk-42N7OV3G.cjs +0 -1
- package/dist/chunk-47ZJEEBT.js +0 -2
- package/dist/chunk-4B3SXBV6.js +0 -4
- package/dist/chunk-5MWFZ7F4.cjs +0 -11
- package/dist/chunk-AS2OC6J4.cjs +0 -26
- package/dist/chunk-B7SYEMZ7.cjs +0 -1
- package/dist/chunk-BME2KUNL.cjs +0 -1
- package/dist/chunk-CDGVVEUK.js +0 -26
- package/dist/chunk-E4RAPI5J.cjs +0 -2
- package/dist/chunk-FZJTQPH4.js +0 -2
- package/dist/chunk-H7XMRUAO.cjs +0 -5
- package/dist/chunk-ILUE2SI5.js +0 -1
- package/dist/chunk-IZT3C23R.js +0 -1
- package/dist/chunk-KJLPVGSX.cjs +0 -4
- package/dist/chunk-LF5LPZOP.cjs +0 -18
- package/dist/chunk-N5WE5O5Q.js +0 -1
- package/dist/chunk-OVDW4XQD.cjs +0 -2
- package/dist/chunk-SNN53UPD.js +0 -1
- package/dist/chunk-V7LBEUVW.js +0 -5
- package/dist/chunk-VE7YBFQD.js +0 -5
- package/dist/chunk-VOVDX7GW.js +0 -18
- package/dist/chunk-VQ33XGNP.cjs +0 -5
- package/dist/chunk-XUJINXW6.js +0 -1
- package/dist/chunk-Y3TPAITU.cjs +0 -1
- package/dist/chunk-Z65JJLLF.js +0 -11
package/dist/chunk-H7XMRUAO.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
'use strict';var chunk5MWFZ7F4_cjs=require('./chunk-5MWFZ7F4.cjs'),fflate=require('fflate');var Rd=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Pd=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,vd=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Ni(e){return Pd.test(e)||vd.test(e)}function An(e,t){if(!Ni(e))throw new Error(`invalid ${t??"registry"} id ${JSON.stringify(e)}: must be reverse-domain (dev.docx-editor.core.x) or package-owned (@scope/pkg#kind/name)`)}var Id=/^(\d+)\.(\d+)\.(\d+)$/;function it(e){let t=Id.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function Dn(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function _n(e,t){let n=it(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=it(r.slice(1));return Dn(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let i=true;for(let a of o){let s=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!s)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let l=it(a.slice(s.length)),d=Dn(n,l);s===">="?i=i&&d>=0:i=i&&d<0;}return i}return Dn(n,it(r))===0}var pe=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},Fr=(e,t)=>`${e}:${t}`;function Od(e,t={}){let n=new Map;for(let d of e){if(An(d.id,"extension"),Ei(d.version,d.id),n.has(d.id))throw new pe("duplicate-extension",`duplicate extension id ${d.id}`,[d.id]);n.set(d.id,d);for(let c of d.contributions)An(c.id,c.kind),Ei(c.version,`${d.id} \u2192 ${c.id}`),c.replaces&&wd(c.replaces.targetRange,`${d.id} \u2192 replaces ${c.replaces.targetId}`);}for(let d of e){for(let c of d.dependencies??[])if(!n.has(c))throw new pe("missing-dependency",`${d.id} requires missing extension ${c}`,[d.id,c]);for(let c of d.conflicts??[])if(n.has(c)){let m=[d.id,c].sort();throw new pe("conflict",`extensions ${m[0]} and ${m[1]} conflict`,m)}}Sd(n);let r=new Set(t.availablePorts??[]);for(let d of e)for(let c of d.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let d of e)for(let c of d.requiredPorts??[])if(!r.has(c))throw new pe("missing-port",`${d.id} requires unavailable port ${c}`,[d.id,c]);let o=new Map,i=new Map,a=new Map;for(let d of e)for(let c of d.contributions){let m=Fr(c.kind,c.id);if(c.replaces){let p=Fr(c.kind,c.replaces.targetId),k=a.get(p)??[];k.push({ext:d.id,c}),a.set(p,k);continue}if(i.has(m)){let p=[o.get(m),d.id].sort();throw new pe("id-collision",`${c.kind} id ${c.id} registered by both ${p[0]} and ${p[1]}`,p)}i.set(m,c),o.set(m,d.id);}let s=new Map(i);for(let[d,c]of a){let m=i.get(d);if(!m){let u=c[0];throw new pe("replacement-target-missing",`${u.ext} replaces missing target ${u.c.replaces.targetId}`,[u.ext,u.c.replaces.targetId])}let p=m.replaceable??{kind:"none"};for(let{ext:u,c:g}of c){if(!_n(m.version,g.replaces.targetRange))throw new pe("replacement-version-mismatch",`${u} replaces ${g.replaces.targetId}@${m.version} outside range ${g.replaces.targetRange}`,[u,g.replaces.targetId]);if(p.kind==="none")throw new pe("unauthorized-replacement",`${g.replaces.targetId} does not authorize replacement (attempted by ${u})`,[u,g.replaces.targetId])}let k=bd(m,c);s.set(d,k);}return {extensions:n,contributions:s,get:(d,c)=>s.get(Fr(d,c))}}function bd(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((s,l)=>(l.c.replaces.priority??0)-(s.c.replaces.priority??0)),i=o[0].c.replaces.priority??0,a=o.filter(s=>(s.c.replaces.priority??0)===i);if(a.length>1){let s=a.map(l=>l.ext).sort();throw new pe("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${i}: ${s.join(", ")}`,s)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new pe("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function Sd(e){let o=new Map,i=[],a=s=>{o.set(s,1),i.push(s);let l=[...e.get(s)?.dependencies??[]].sort();for(let d of l){let c=o.get(d)??0;if(c===1){let m=i.indexOf(d),p=[...i.slice(m),d];throw new pe("dependency-cycle",`dependency cycle: ${p.join(" -> ")}`,p)}c===0&&a(d);}i.pop(),o.set(s,2);};for(let s of [...e.keys()].sort())(o.get(s)??0)===0&&a(s);}function Ei(e,t){try{it(e);}catch{throw new pe("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function wd(e,t){try{_n("0.0.0",e);}catch{throw new pe("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var st=class extends Error{constructor(t){super(t),this.name="BudgetError";}},Wt=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new chunk5MWFZ7F4_cjs.p(`${t}.budget`,n);}label;capacity;used;children=new Set;activeReservations=0;cleanups=[];disposed=false;carveAmount=0;parent;get inUse(){return this.used.current}get available(){return this.used.remaining}get isDisposed(){return this.disposed}reserve(t){this.assertLive(),this.used.add(t),this.activeReservations+=1;let n=false,r=this;return {amount:t,get released(){return n},release(){n||(n=true,r.used.release(t),r.activeReservations-=1);}}}child(t,n){this.assertLive(),this.used.add(n);let r=new e(t,n);return r.parent=this,r.carveAmount=n,this.children.add(r),r}onRelease(t){this.assertLive(),this.cleanups.push(t);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new st(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new st(`${this.label}: cannot release with ${this.activeReservations} reservation(s) outstanding`);let t=[];for(let n=this.cleanups.length-1;n>=0;n--)try{this.cleanups[n]();}catch(r){t.push(r);}if(this.disposed=true,this.parent&&(this.parent.children.delete(this),this.parent.used.release(this.carveAmount),this.parent=void 0),t.length>0)throw new st(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new st(`${this.label}: budget already released`)}};var Fn=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},zt=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new Fn(t.derivedOnly,t._reason)}}}};var Ln=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},Lr=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new Ln(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(chunk5MWFZ7F4_cjs.f.clock)}identity(){return this.resolve(chunk5MWFZ7F4_cjs.f.identity)}},$r=class{constructor(t=0,n=1){this.step=n;this.t=t;}step;t;now(){let t=this.t;return this.t+=this.step,t}},Ur=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function Nd(e){let t=chunk5MWFZ7F4_cjs.k(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",i={id:o,limits:t,config:n,ports:e.ports,budget:new Wt(`op:${o}`,r),cancellation:new zt};return Object.freeze(i)}function Ed(e){e.budget.dispose();}var jr=Object.freeze({maxRecursionDepth:{unit:"depth",phase:"xml-parse"},maxElementCount:{unit:"count",phase:"xml-parse"},maxPartCount:{unit:"count",phase:"package-read"},maxDecompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressionRatio:{unit:"ratio",phase:"package-read"},maxChunkBytes:{unit:"bytes",phase:"package-read"},maxPaginationPasses:{unit:"passes",phase:"layout"},maxQueueDepth:{unit:"count",phase:"output"}}),Ti=Object.keys(jr);function Td(e,t){return new chunk5MWFZ7F4_cjs.p(`${jr[t].phase}:${t}`,e[t])}var Br=class{counter;current=0;peak=0;constructor(t){this.counter=new chunk5MWFZ7F4_cjs.p("memory",t);}allocate(t){this.counter.add(t),this.current+=t,this.current>this.peak&&(this.peak=this.current);}free(t){this.counter.release(t),this.current=Math.max(0,this.current-t);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function Cd(){for(let e of Ti){let t=chunk5MWFZ7F4_cjs.j[e],n=chunk5MWFZ7F4_cjs.i[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function Kt(e,t=new Set){let n=new WeakSet,r=[],o=i=>{if(i===null)return "null";let a=typeof i;if(a==="boolean")return i?"true":"false";if(a==="number"){let l=i;if(!Number.isFinite(l))throw new Error(`non-finite number is not comparable: ${l}`);return Object.is(l,-0)?"0":String(l)}if(a==="string")return JSON.stringify(i);if(a==="bigint")return `${i.toString()}n`;if(Array.isArray(i))return `[${i.map((l,d)=>{r.push(d);try{return o(l)}finally{r.pop();}}).join(",")}]`;if(a==="object"){let l=i;if(n.has(l))throw new Error("cannot canonicalize a cyclic structure");n.add(l);let c=Object.keys(l).filter(m=>!t.has(m)).sort().map(m=>{r.push(m);try{return `${JSON.stringify(m)}:${o(l[m])}`}finally{r.pop();}}).join(",");return n.delete(l),`{${c}}`}let s=r.length>0?` at ${r.map(String).join(".")}`:"";throw new Error(`unsupported value type in comparator input: ${a}${s}`)};return o(e)}function Hr(e,t){return Md(Kt(e,t))}function Md(e){let t=3421674724,n=2216829733;for(let r=0;r<e.length;r++){n=(n^e.charCodeAt(r))>>>0;let o=n*435,i=Math.floor(o/4294967296);t=Math.imul(t,435)+Math.imul(n,256)+i>>>0,n=o>>>0;}return t.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}var De="dev.docx-editor.core.comparator",Vr={authoredState:{id:`${De}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${De}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${De}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${De}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${De}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${De}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${De}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${De}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${De}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${De}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Wr(e,t,n,r={}){let o=Vr[e];switch(o.mode){case "sync-optimization-only":throw new Error(`${o.id} is not an equivalence basis (${o.note})`);case "tolerance":{if(r.epsilon===void 0)throw new Error(`${o.id} requires an explicit epsilon`);return {equal:Ci(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let i=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=Kt(t,i),s=Kt(n,i);return a===s?{equal:true}:{equal:false,left:a,right:s}}}}function zr(e,t){let n=Vr[e];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let r=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return Hr(t,r)}function Ci(e,t,n){return typeof e=="number"&&typeof t=="number"?Number.isFinite(e)&&Number.isFinite(t)&&Math.abs(e-t)<=n:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,o)=>Ci(r,t[o],n)):false}var Ai=new Set([...chunk5MWFZ7F4_cjs.c,...chunk5MWFZ7F4_cjs.d]),Mi=/^[0-9a-f]{16}$/,Ad=/^[0-9a-f]*$/;function Kr(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,i)=>{let a=`step[${i}]`;Ai.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let s=o.expect;s.outcome==="applied"?(s.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):s.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${s.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=s.committedRevision,s.modelChange&&Dd(s.modelChange,a,n)):(s.committedRevision!==void 0&&n(`${a}: ${s.outcome} step must not commit a revision`),s.authoredStateHash!==void 0&&n(`${a}: ${s.outcome} step must not change authored state`)),s.authoredStateHash!==void 0&&!Mi.test(s.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),s.outputHash!==void 0&&!Mi.test(s.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),Ad.test(o.bytesHex)||n("envelope bytesHex must be hex"),o.bytesHex.length!==o.byteLength*2&&n(`envelope byteLength ${o.byteLength} disagrees with ${o.bytesHex.length/2} decoded bytes`);return {valid:t.length===0,errors:t}}function Dd(e,t,n){Ai.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function _d(e,t){let n=Kr(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,i)=>{let a=`step[${i}]`,s=t.applyStep(o),l=o.expect;if(s.outcome!==l.outcome){r.push(`${a}: outcome ${s.outcome} != expected ${l.outcome}`);return}if(l.outcome==="applied"&&(s.committedRevision!==l.committedRevision&&r.push(`${a}: revision ${s.committedRevision} != expected ${l.committedRevision}`),l.authoredStateHash!==void 0))if(s.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {Wr("authoredState",s.authoredState,s.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=Di(s.authoredState);c!==l.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${l.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function Di(e){return zr("authoredState",e)}function Gt(e){let t=[...e];for(;t.length;){let n=t.pop();if(n.kind!=="textValue"){if(n.namespaceUri===chunk5MWFZ7F4_cjs.fa&&n.localName==="object")return true;for(let r of n.children)t.push(r);}}return false}var lt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Fd="http://schemas.openxmlformats.org/package/2006/relationships",Ld="http://schemas.openxmlformats.org/drawingml/2006/main",Li="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",$i="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",Ui="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Bi="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",ji="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",Gr="application/vnd.openxmlformats-package.relationships+xml",Xr=`${lt}/styles`,Yr=`${lt}/numbering`,Hi=`${lt}/footnotes`,Vi=`${lt}/endnotes`,Wi=`${lt}/officeDocument`,$d=`${lt}/theme`;function Ce(e){return e.kind!=="textValue"}function _i(e,t){return {...e,children:t}}function Xe(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)Xe(n,t);}var Ud=new Set(["pStyle","rStyle","tblStyle"]);function Jr(e,t){for(let n of e)Xe(n,r=>{if(r.kind!=="textValue"&&Ud.has(r.localName)&&r.namespaceUri===chunk5MWFZ7F4_cjs.fa){let o=chunk5MWFZ7F4_cjs.ef(r,"val");o&&t.add(o);}});}function qr(e,t){for(let n of e)Xe(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===chunk5MWFZ7F4_cjs.fa){let o=chunk5MWFZ7F4_cjs.ef(r,"val");o&&t.add(o);}});}function Qr(e){let t=new Set;return Xt(e,t),t}function Xt(e,t){for(let n of e)Xe(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===lt&&o.value.length>0&&t.add(o.value);});}function we(e){return /^\d+$/.test(e)?e.replace(/^0+(?=\d)/,""):e}function Un(e,t){let n={footnote:new Set,endnote:new Set},r=[],o=i=>{for(let a of i)Xe(a,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",d=chunk5MWFZ7F4_cjs.ef(s,"id");if(d===void 0)return;let c=we(d);n[l].has(c)||(n[l].add(c),r.push({kind:l,id:c}));});};for(o(e);r.length>0;){let i=r.pop(),a=t(i.kind,i.id);a!==null&&o([a]);}return n}function Zr(e,t,n){if(e.kind==="textValue")return e;let r=[],o=false;for(let i of e.children){if(i.kind!=="textValue"&&i.namespaceUri===chunk5MWFZ7F4_cjs.fa&&(i.localName==="footnoteReference"||i.localName==="endnoteReference")){let l=i.localName==="footnoteReference"?t:n,d=chunk5MWFZ7F4_cjs.ef(i,"id");if(i.kind!=="noteReference"||d===void 0||!l.has(we(d))){o=true;continue}}let s=Zr(i,t,n);s!==i&&(o=true),r.push(s);}return o?{...e,children:r}:e}function Bd(e,t){for(let n of chunk5MWFZ7F4_cjs.Zd(e,t)){if(n.type!==Xr||n.targetMode==="External")continue;let r=chunk5MWFZ7F4_cjs.w(n.ownerPart,n.rawTarget);if(r.ok)return e.parts.get(r.partName)??null}return e.parts.get("/word/styles.xml")??null}function zi(e,t,n){for(let r of chunk5MWFZ7F4_cjs.Zd(e,t)){if(r.type!==n||r.targetMode==="External")continue;let o=chunk5MWFZ7F4_cjs.w(r.ownerPart,r.rawTarget);if(o.ok)return e.parts.get(o.partName)??null}return null}function Ki(e,t){let n=Bd(e,t),r=new Map,o=[],i=null;if(n&&Ce(n.root))for(let a of n.root.children){if(!Ce(a))continue;if(a.localName==="docDefaults"&&a.namespaceUri===chunk5MWFZ7F4_cjs.fa){i=a;continue}if(a.localName!=="style"||a.namespaceUri!==chunk5MWFZ7F4_cjs.fa)continue;let s=chunk5MWFZ7F4_cjs.ef(a,"styleId");s&&r.set(s,a),(chunk5MWFZ7F4_cjs.ef(a,"default")==="1"||chunk5MWFZ7F4_cjs.ef(a,"default")==="true")&&o.push(a);}return {part:n,byId:r,defaults:o,docDefaults:i}}var jd=new Set(["basedOn","link","next"]);function Gi(e,t){let n=new Set,r=[...t];for(let a of e.defaults){let s=chunk5MWFZ7F4_cjs.ef(a,"styleId");s&&r.push(s);}let o=[];for(;r.length>0;){let a=r.pop();if(n.has(a))continue;n.add(a);let s=e.byId.get(a);if(s){o.push(s);for(let l of s.children)if(Ce(l)&&jd.has(l.localName)&&l.namespaceUri===chunk5MWFZ7F4_cjs.fa){let d=chunk5MWFZ7F4_cjs.ef(l,"val");d&&r.push(d);}}}if(!e.part||!Ce(e.part.root))return o;let i=new Map;return e.part.root.children.forEach((a,s)=>i.set(a,s)),o.sort((a,s)=>(i.get(a)??0)-(i.get(s)??0))}function eo(e,t,n){let r=zi(e,t,Yr)??e.parts.get("/word/numbering.xml")??null;if(!r||!Ce(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],i=new Set;for(let s of r.root.children){if(!Ce(s)||s.localName!=="num"||s.namespaceUri!==chunk5MWFZ7F4_cjs.fa)continue;let l=chunk5MWFZ7F4_cjs.ef(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let d of s.children)if(Ce(d)&&d.localName==="abstractNumId"){let c=chunk5MWFZ7F4_cjs.ef(d,"val");c&&i.add(c);}}}let a=[];for(let s of r.root.children){if(!Ce(s)||s.localName!=="abstractNum"||s.namespaceUri!==chunk5MWFZ7F4_cjs.fa)continue;let l=chunk5MWFZ7F4_cjs.ef(s,"abstractNumId");l&&i.has(l)&&a.push(s);}return {part:r,nums:o,abstracts:a}}var $n={latin:null,eastAsia:null,cs:null};function Xi(e,t){let n=zi(e,t,$d);if(!n)return {major:$n,minor:$n};let r={major:{...$n},minor:{...$n}};return Xe(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==Ld||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let i=o.localName==="majorFont"?r.major:r.minor;for(let a of o.children){if(!Ce(a))continue;let s=chunk5MWFZ7F4_cjs.ef(a,"typeface");s&&(a.localName==="latin"?i.latin=s:a.localName==="ea"?i.eastAsia=s:a.localName==="cs"&&(i.cs=s));}}),{major:r.major,minor:r.minor}}function Hd(e,t){let n=t.startsWith("major")?e.major:e.minor;return t.endsWith("EastAsia")?n.eastAsia??n.latin:t.endsWith("Bidi")?n.cs??n.latin:n.latin}var Vd=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],Fi=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function Ye(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa){let i=[],a=new Map;for(let s of e.attributes){let l=Vd.find(([d])=>d===s.localName);if(l&&s.namespaceUri===chunk5MWFZ7F4_cjs.fa){let d=Hd(t,s.value);d&&a.set(l[1],d);continue}i.push(s);}for(let[s,l]of a)i.some(d=>d.localName===s)||i.push({kind:"genericExtension",namespaceUri:chunk5MWFZ7F4_cjs.fa,localName:s,prefix:"w",value:l});n=i;}else e.attributes.some(i=>Fi.has(i.localName)&&i.namespaceUri===chunk5MWFZ7F4_cjs.fa&&e.attributes.some(a=>a.localName==="val"))&&(n=e.attributes.filter(i=>!(Fi.has(i.localName)&&i.namespaceUri===chunk5MWFZ7F4_cjs.fa)));let r=e.children.map(i=>Ye(i,t)),o=r.some((i,a)=>i!==e.children[a]);return n===e.attributes&&!o?e:{...e,attributes:n,children:r}}function Yi(e,t,n){return {id:e,name:e,contentType:t,root:n}}function Ji(e,t){if(e.root.kind==="document"){let r=e.root.children.find(i=>i.kind==="body"),o=r&&Ce(r)?_i(r,t):{id:"fragment#body",kind:"body",namespaceUri:chunk5MWFZ7F4_cjs.fa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return _i(e.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:chunk5MWFZ7F4_cjs.fa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:chunk5MWFZ7F4_cjs.fa,localName:"document",prefix:"w",namespaceBindings:Ce(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function Yt(e){let t=e.map(n=>{let r=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${chunk5MWFZ7F4_cjs.N(n.id)}" Type="${chunk5MWFZ7F4_cjs.N(n.type)}" Target="${chunk5MWFZ7F4_cjs.N(n.rawTarget)}"${r}/>`}).join("");return `<Relationships xmlns="${Fd}">${t}</Relationships>`}function qi(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function Qi(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Bn(e,t){return {...e,children:t}}function jn(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa}function Jt(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)Jt(n,t);return t}function Zi(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let r=Zi(n,t);if(r)return r}return null}function Wd(e){let t=(n,r)=>{if(n.kind==="textValue")return n;if(r&&jn(n,"vMerge")){if(chunk5MWFZ7F4_cjs.ef(n,"val")==="restart")return n;let i=[...n.attributes.filter(a=>!(a.localName==="val"&&a.namespaceUri===chunk5MWFZ7F4_cjs.fa)),{kind:"wmlVal",namespaceUri:chunk5MWFZ7F4_cjs.fa,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:i}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||jn(n,"tc");return Bn(n,n.children.map(i=>t(i,o)))};return Bn(e,e.children.map(n=>t(n,false)))}function es(e,t){if(!(e.kind==="textValue"||e.kind==="table")){if(jn(e,"tr")){t.push(e);return}for(let n of e.children)es(n,t);}}function ts(e,t,n){if(e.kind==="textValue"||e.kind==="table")return {node:e,hadRows:false,keptRows:false};if(jn(e,"tr")){if(!t.has(e))return {node:null,hadRows:true,keptRows:false};let a=n.value?Wd(e):e;return n.value=false,{node:a,hadRows:true,keptRows:true}}let r=false,o=false,i=[];for(let a of e.children){let s=ts(a,t,n);r||=s.hadRows,o||=s.keptRows,s.node!==null&&i.push(s.node);}return r?{node:o?Bn(e,i):null,hadRows:true,keptRows:o}:{node:e,hadRows:false,keptRows:false}}function ns(e,t,n){let r=[];for(let l of e.children)es(l,r);let o=new Set(Jt(e).filter(l=>t.inRange.has(l)));if(o.size===0)return;let i=r.filter(l=>{let d=Jt(l);return d.length>0&&d.every(c=>t.covered.has(c))}),a=new Set(i.flatMap(l=>Jt(l)));if(i.length>0&&o.size===a.size&&[...o].every(l=>a.has(l))){let l={value:true},d=new Set(i),c=[];for(let m of e.children){let p=ts(m,d,l);p.node!==null&&c.push(p.node);}n.push(Bn(e,c));return}for(let l of Jt(e)){if(!t.inRange.has(l))continue;let d=Zi(e,l);d&&n.push(d);}}var zd="http://schemas.openxmlformats.org/package/2006/content-types",Kd=5e4;function Ve(e){return e.kind!=="textValue"}function rs(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)rs(n,t);return t}function to(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let r=to(n,t);if(r)return r}return null}function He(e,t){return {...e,children:t}}function Gd(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa}function Xd(e){if(e.root.kind==="document"){let t=e.root.children.find(n=>n.kind==="body");return t&&Ve(t)?t:null}return Ve(e.root)?e.root:null}function Yd(e,t){return rs(e).some(n=>t.has(n))}function no(e,t,n){for(let r of e)if(Ve(r)){if(r.kind==="paragraph"){t.inRange.has(r.id)&&n.push(r);continue}if(t.fullBlocks.has(r.id)){n.push(r);continue}if(r.kind==="table"){ns(r,t,n);continue}if(r.kind==="contentControl"){let o=r.children.find(i=>i.kind==="contentControlContent");o&&Ve(o)&&no(o.children,t,n);continue}Yd(r,t.inRange)&&no(r.children,t,n);}}var Jd=new Set(["commentRangeStart","commentRangeEnd"]);function qd(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function ro(e){if(e.kind==="textValue")return e;if(Jd.has(e.localName)&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa||qd(e)||Gd(e,"sectPr"))return null;let t=false,n=[];for(let r of e.children){let o=ro(r);if(o===null){t=true;continue}o!==r&&(t=true),n.push(o);}return t?He(e,n):e}function Qd(e){let t=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){for(let d of l.children)if(d.kind==="fldChar"){let c=chunk5MWFZ7F4_cjs.ef(d,"fldCharType");t.push({nodeId:d.id,type:c==="separate"||c==="end"?c:"begin"});}else d.kind==="instrText"&&t.push({nodeId:d.id,type:"instr"});return}for(let d of l.children)n(d);}};for(let l of e)n(l);if(t.length===0)return e;let r=new Set,o=[],i=null,a=[];for(let l of t){if(l.type==="begin"){o.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let c=o[o.length-1];c?c.separateId=l.nodeId:i=l.nodeId;continue}if(l.type==="instr"){let c=o[o.length-1];c?c.instrIds.push(l.nodeId):i===null&&a.push(l.nodeId);continue}if(!o.pop()){r.add(l.nodeId),i!==null&&r.add(i);for(let c of a)r.add(c);i=null,a=[];}}for(let l of o){r.add(l.beginId),l.separateId!==null&&r.add(l.separateId);for(let d of l.instrIds)r.add(d);}i!==null&&r.add(i);for(let l of a)r.add(l);if(r.size===0)return e;let s=l=>{if(l.kind==="textValue")return l;if(r.has(l.id))return null;let d=[],c=false;for(let m of l.children){let p=s(m);if(p===null){c=true;continue}p!==m&&(c=true),d.push(p);}return c?He(l,d):l};return e.map(l=>s(l)).filter(l=>l!==null)}function oo(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=oo(n);return t}function Zd(e,t){let n=[];for(let r of e.children){if(r.kind!=="contentControl"){n.push(r);continue}let o=t.get(r.id),i=oo(r);if(o===void 0||i>=o){n.push(r);continue}if(i===0)continue;let a=r.children.find(s=>s.kind==="contentControlContent");a&&Ve(a)?n.push(...a.children):n.push(r);}return He(e,n)}function ec(e){let t=new Set,n=new Set,r=a=>{if(a.kind!=="textValue"){if(a.kind==="bookmarkStart"){let s=chunk5MWFZ7F4_cjs.ef(a,"id");s!==void 0&&t.add(s);}if(a.kind==="bookmarkEnd"){let s=chunk5MWFZ7F4_cjs.ef(a,"id");s!==void 0&&n.add(s);}for(let s of a.children)r(s);}};for(let a of e)r(a);let o=new Set([...t].filter(a=>n.has(a)));if(o.size===t.size&&o.size===n.size)return e;let i=a=>{if(a.kind==="textValue")return a;if(a.kind==="bookmarkStart"||a.kind==="bookmarkEnd"){let d=chunk5MWFZ7F4_cjs.ef(a,"id");return d!==void 0&&o.has(d)?a:null}let s=[],l=false;for(let d of a.children){let c=i(d);if(c===null){l=true;continue}c!==d&&(l=true),s.push(c);}return l?He(a,s):a};return e.map(a=>i(a)??a)}function tc(e,t,n){let r=e.parts.get(t.partName);if(!r)return {ok:false,reason:"unknown-part"};if(t.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let o=t.paragraphIds[0],i=t.paragraphIds[t.paragraphIds.length-1],a=new Map;for(let w of [o,i]){let U=to(r.root,w);if(!U)return {ok:false,reason:"empty-range"};for(let H of U.children)H.kind==="contentControl"&&a.set(H.id,oo(H));}let s=r,l=to(s.root,i);if(!l)return {ok:false,reason:"empty-range"};let d=chunk5MWFZ7F4_cjs.tf(l);if(t.endOffset<d){let w=chunk5MWFZ7F4_cjs.Bj(s,{op:"deleteText",paragraphId:i,start:t.endOffset,end:d},{deferValidation:true});if(!w.ok)return {ok:false,reason:"trim-refused"};s=w.part;}if(t.startOffset>0){let w=chunk5MWFZ7F4_cjs.Bj(s,{op:"deleteText",paragraphId:o,start:0,end:t.startOffset},{deferValidation:true});if(!w.ok)return {ok:false,reason:"trim-refused"};s=w.part;}let c=Xd(s);if(!c)return {ok:false,reason:"unknown-part"};let m={inRange:new Set(t.paragraphIds),covered:new Set(t.coveredParagraphIds),fullBlocks:new Set(t.fullyCoveredBlockIds)},p=[];if(no(c.children,m,p),p.length===0)return {ok:false,reason:"empty-range"};if(p.length>Kd)return {ok:false,reason:"resource-limit"};let k=p.map(w=>ro(w)).filter(w=>w!==null).map(w=>w.kind!=="paragraph"||w.id!==o&&w.id!==i?w:Zd(w,a));k=[...Qd(k)],k=[...ec(k)];let u=chunk5MWFZ7F4_cjs.pg(e,"footnote"),g=chunk5MWFZ7F4_cjs.pg(e,"endnote"),h=(w,U)=>Ve(w)&&w.namespaceUri===chunk5MWFZ7F4_cjs.fa&&w.localName===U,x=Un(k,(w,U)=>{let H=w==="footnote"?u:g;if(!H||!Ve(H.root))return null;for(let ee of H.root.children){if(!h(ee,w))continue;let re=chunk5MWFZ7F4_cjs.ef(ee,"id");if(re!==void 0&&we(re)===U)return ee}return null}),f=x.footnote,P=x.endnote;f.size===0&&(u=null),P.size===0&&(g=null);let I=(w,U,H)=>{if(!w||!Ve(w.root))return [];let ee=[];for(let re of w.root.children){if(!h(re,U))continue;let Y=chunk5MWFZ7F4_cjs.ef(re,"id"),Ze=chunk5MWFZ7F4_cjs.ef(re,"type");if(Ze==="separator"||Ze==="continuationSeparator"){ee.push(re);continue}if(Y!==void 0&&H.has(we(Y))){let ht=ro(re);ht&&Ve(ht)&&ee.push(ht);}}return ee},v=I(u,"footnote",f),y=I(g,"endnote",P),T=[...v,...y];if(Gt(k)||Gt(T))return {ok:false,reason:"unsupported-content"};let N=[...k,...T],j=new Set;Jr(N,j);let V=Ki(e,e.mainDocumentPart),Q=new Set;qr(N,Q);let G=[],D=eo(e,e.mainDocumentPart,Q);for(;;){let w=j.size,U=Q.size;G=Gi(V,j),qr(G,Q),D=eo(e,e.mainDocumentPart,Q);let H=[...D.nums,...D.abstracts];Jr(H,j);for(let ee of H)Xe(ee,re=>{if(re.kind!=="textValue"&&(re.localName==="styleLink"||re.localName==="numStyleLink")&&re.namespaceUri===chunk5MWFZ7F4_cjs.fa){let Y=chunk5MWFZ7F4_cjs.ef(re,"val");Y&&j.add(Y);}});if(j.size===w&&Q.size===U)break}let B=Xi(e,e.mainDocumentPart),oe=G.map(w=>Ye(w,B)),ve=V.docDefaults?Ye(V.docDefaults,B):null;k=k.map(w=>Ye(w,B));let L=v.map(w=>Ye(w,B)),$=y.map(w=>Ye(w,B)),X=new Set;Xt(k,X);let S=chunk5MWFZ7F4_cjs.Zd(e,r.name).filter(w=>X.has(w.id)),O=new Map,M=0,W=w=>{let U=new Set;for(let H of w){if(H.targetMode==="External")continue;let ee=chunk5MWFZ7F4_cjs.w(H.ownerPart,H.rawTarget);if(!ee.ok){U.add(H.id);continue}if((chunk5MWFZ7F4_cjs._d(e,ee.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let Y=e.partBytes.get(ee.partName)??e.partBytes.get(ee.partName.replace(/^\//,""));Y?(O.set(ee.partName,Y),M+=Y.byteLength):U.add(H.id);continue}U.add(H.id);}return U},Z=W(S),ie=(w,U)=>{if(w.kind==="textValue")return w;if(w.kind==="drawing"||w.namespaceUri===chunk5MWFZ7F4_cjs.fa&&(w.localName==="pict"||w.localName==="object")){let re=new Set;Xt([w],re);for(let Y of re)if(U.has(Y))return null;return w}let H=[],ee=false;for(let re of w.children){let Y=ie(re,U);if(Y===null){ee=true;continue}Y!==re&&(ee=true),H.push(Y);}return ee?He(w,H):w};Z.size>0&&(k=k.map(w=>ie(w,Z)).filter(w=>w!==null));let z=S.filter(w=>!Z.has(w.id)),_e=(w,U)=>{if(!w)return [];let H=new Set;Xt(U,H);let ee=chunk5MWFZ7F4_cjs.Zd(e,w.name).filter(Y=>H.has(Y.id)),re=W(ee);if(re.size>0)for(let Y=0;Y<U.length;Y+=1){let Ze=ie(U[Y],re);Ze!==null&&(U[Y]=Ze);}return ee.filter(Y=>!re.has(Y.id))},me=_e(u,L),sn=_e(g,$),be=new Map,ft=[],Ft=new Map,gt=(w,U,H)=>{let ee=Yi(w,U,H);be.set(w.slice(1),chunk5MWFZ7F4_cjs.Ua(chunk5MWFZ7F4_cjs.sa(ee))),ft.push([w,U]),Ft.set(w,ee);},Lt=(w,U)=>w.map(H=>{if(H.targetMode==="External")return {...H,ownerPart:U};let ee=chunk5MWFZ7F4_cjs.w(H.ownerPart,H.rawTarget);return {...H,ownerPart:U,rawTarget:ee.ok?ee.partName:H.rawTarget}}),b=Lt(z,"/word/document.xml"),C=Lt(me,"/word/footnotes.xml"),A=Lt(sn,"/word/endnotes.xml"),F=new Set(b.map(w=>w.id)),K=9001,J=(w,U)=>{let H=qi(F,K);K+=1,F.add(H),b.push({ownerPart:"/word/document.xml",id:H,type:w,rawTarget:U,targetMode:"Internal",order:b.length});},se=Ji(s,k);if(gt("/word/document.xml",Li,se),V.part&&(oe.length>0||ve)){let w=He(V.part.root,[...ve?[ve]:[],...oe]);gt("/word/styles.xml",$i,w),J(Xr,"styles.xml");}if(D.part&&(D.nums.length>0||D.abstracts.length>0)){let w=He(D.part.root,[...D.abstracts.map(U=>Ye(U,B)),...D.nums]);gt("/word/numbering.xml",Ui,w),J(Yr,"numbering.xml");}u&&L.length>0&&(gt("/word/footnotes.xml",Bi,He(u.root,L)),J(Hi,"footnotes.xml"),C.length>0&&be.set("word/_rels/footnotes.xml.rels",chunk5MWFZ7F4_cjs.Ua(Yt(C)))),g&&$.length>0&&(gt("/word/endnotes.xml",ji,He(g.root,$)),J(Vi,"endnotes.xml"),A.length>0&&be.set("word/_rels/endnotes.xml.rels",chunk5MWFZ7F4_cjs.Ua(Yt(A))));let ye=new Map;for(let[w,U]of O){be.set(w.slice(1),U);let H=Qi(w);H&&!ye.has(H)&&ye.set(H,chunk5MWFZ7F4_cjs._d(e,w)??"application/octet-stream");}let ge={ownerPart:"/",id:"rId1",type:Wi,rawTarget:"word/document.xml",targetMode:"Internal",order:0};be.set("word/_rels/document.xml.rels",chunk5MWFZ7F4_cjs.Ua(Yt(b))),be.set("_rels/.rels",chunk5MWFZ7F4_cjs.Ua(Yt([ge])));let Fe=[`<Default Extension="rels" ContentType="${Gr}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...ye].map(([w,U])=>`<Default Extension="${chunk5MWFZ7F4_cjs.N(w)}" ContentType="${chunk5MWFZ7F4_cjs.N(U)}"/>`)].join(""),Qe=ft.map(([w,U])=>`<Override PartName="${chunk5MWFZ7F4_cjs.N(w)}" ContentType="${chunk5MWFZ7F4_cjs.N(U)}"/>`).join("");be.set("[Content_Types].xml",chunk5MWFZ7F4_cjs.Ua(`<Types xmlns="${zd}">${Fe}${Qe}</Types>`));let Ie=new Map;Ie.set("/",[ge]),Ie.set("/word/document.xml",b),C.length>0&&Ie.set("/word/footnotes.xml",C),A.length>0&&Ie.set("/word/endnotes.xml",A);let ln=[];for(let w of Ie.values())for(let U of w)U.targetMode==="External"&&ln.push({ownerPart:U.ownerPart,id:U.id,type:U.type,rawTarget:U.rawTarget,sinkSafe:chunk5MWFZ7F4_cjs.x(U.rawTarget).ok});let ae=new Map;ae.set("rels",Gr),ae.set("xml","application/xml");for(let[w,U]of ye)ae.set(w,U);let ue={defaults:ae,overrides:new Map(ft)},Le=new Map;for(let[w,U]of be)Le.set(w.startsWith("/")?w:`/${w}`,U);return {ok:true,bytes:chunk5MWFZ7F4_cjs.Ta(be),package:Object.freeze({parts:Ft,partBytes:Le,relationships:Ie,externalTargets:ln,contentTypes:ue,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:t.lastMarkCovered,blockCount:k.length,mediaBytes:M}}function le(e){return e.kind!=="textValue"}function ne(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa}function Me(e,t){for(let n of e)t(n),n.kind!=="textValue"&&Me(n.children,t);}function Je(e){if(e.kind==="textValue")return `T(${e.value})`;if(e.namespaceUri===chunk5MWFZ7F4_cjs.fa&&e.localName.startsWith("rsid"))return "";let t=e.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===chunk5MWFZ7F4_cjs.ia&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=e.children.map(Je).join("");return `E(${e.namespaceUri}:${e.localName}[${t}]{${n}})`}function qt(e){return `S[${e.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${e.children.map(Je).join("")}`}function Wn(e){let t=[],n=new Map,r=new Set,o=null;if(e&&le(e.root))for(let i of e.root.children){if(!le(i))continue;if(ne(i,"docDefaults")){o=i;continue}if(!ne(i,"style"))continue;t.push(i);let a=chunk5MWFZ7F4_cjs.ef(i,"styleId");a&&n.set(a,i);let s=i.children.find(d=>ne(d,"name")),l=s?chunk5MWFZ7F4_cjs.ef(s,"val"):void 0;l&&r.add(l);}return {part:e,styles:t,docDefaults:o,byId:n,names:r}}function Hn(e,t,n){let r=new Map;if(!e)return r;let o=e.children.find(a=>ne(a,t));if(!o||!le(o))return r;let i=o.children.find(a=>ne(a,n));if(!i||!le(i))return r;for(let a of i.children)a.kind!=="textValue"&&r.set(a.localName,a);return r}function ao(e,t,n,r){let o=t;for(let i=0;i<16&&o;i+=1){let a=e.byId.get(o);if(!a)return false;let s=a.children.find(d=>ne(d,n));if(s&&le(s)&&s.children.some(d=>d.kind!=="textValue"&&d.localName===r))return true;let l=a.children.find(d=>ne(d,"basedOn"));o=l?chunk5MWFZ7F4_cjs.ef(l,"val"):void 0;}return false}function nc(e,t){for(let n of e.styles){if(chunk5MWFZ7F4_cjs.ef(n,"type")!==t)continue;let r=chunk5MWFZ7F4_cjs.ef(n,"default");if(r==="1"||r==="true")return chunk5MWFZ7F4_cjs.ef(n,"styleId")}}function Vn(e,t){let n=e.children.find(r=>ne(r,t));return n&&le(n)?n:null}var rc=new Map(["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"].map((e,t)=>[e,t])),oc=new Map(["rStyle","rFonts","b","bCs","i","iCs","caps","smallCaps","strike","dstrike","outline","shadow","emboss","imprint","noProof","snapToGrid","vanish","webHidden","color","spacing","w","kern","position","sz","szCs","highlight","u","effect","bdr","shd","fitText","vertAlign","rtl","cs","em","lang","eastAsianLayout","specVanish","oMath","rPrChange"].map((e,t)=>[e,t]));function io(e,t,n){let r=Hn(t.docDefaults,"rPrDefault","rPr"),o=Hn(n.docDefaults,"rPrDefault","rPr"),i=Hn(t.docDefaults,"pPrDefault","pPr"),a=Hn(n.docDefaults,"pPrDefault","pPr"),s=(h,R,x)=>{let f=nc(h,"paragraph"),P=f?h.byId.get(f):void 0;if(!P)return f;for(let[I,v]of [["rPr",R],["pPr",x]]){let y=Vn(P,I);if(y)for(let T of y.children)T.kind!=="textValue"&&v.set(T.localName,T);}return f};s(t,r,i),s(n,o,a);let l=new Map;for(let[h,R]of r){let x=o.get(h);(!x||Je(x)!==Je(R))&&l.set(h,R);}let d=new Map;for(let[h,R]of i){if(h==="sectPr")continue;let x=a.get(h);(!x||Je(x)!==Je(R))&&d.set(h,R);}if(l.size===0&&d.size===0)return e;let c=0,m=()=>`fragment#materialized-${c++}`,p=h=>{let R=x=>x.kind==="textValue"?{id:m(),kind:"textValue",value:x.value}:{...x,id:m(),children:x.children.map(R)};return R(h)},k=(h,R,x)=>{if(x.length===0)return h;let f=Vn(h,R);if(f){let I=R==="rPr"?oc:rc,v=[...f.children];for(let T of x){let N=T.kind==="textValue"?Number.MAX_SAFE_INTEGER:I.get(T.localName)??Number.MAX_SAFE_INTEGER,j=v.length;for(let V=0;V<v.length;V+=1){let Q=v[V];if(Q.kind==="textValue")continue;let G=I.get(Q.localName);if(G!==void 0&&G>N){j=V;break}}v.splice(j,0,T);}let y={...f,children:v};return {...h,children:h.children.map(T=>T===f?y:T)}}let P={id:m(),kind:R==="rPr"?"runProperties":"paragraphProperties",namespaceUri:chunk5MWFZ7F4_cjs.fa,localName:R,prefix:"w",namespaceBindings:[],attributes:[],children:x};return {...h,children:[P,...h.children]}},u=h=>{let R=Vn(h,"pPr"),x=R?.children.find(y=>ne(y,"pStyle")),f=x?chunk5MWFZ7F4_cjs.ef(x,"val"):void 0,P=[];for(let[y,T]of d)R?.children.some(j=>j.kind!=="textValue"&&j.localName===y)||f&&ao(t,f,"pPr",y)||P.push(p(T));let I=y=>{if(y.kind==="textValue")return y;if(y.kind==="run"){let N=Vn(y,"rPr"),j=N?.children.find(G=>ne(G,"rStyle")),V=j?chunk5MWFZ7F4_cjs.ef(j,"val"):void 0,Q=[];for(let[G,D]of l)N?.children.some(oe=>oe.kind!=="textValue"&&oe.localName===G)||V&&ao(t,V,"rPr",G)||f&&ao(t,f,"rPr",G)||Q.push(p(D));return k(y,"rPr",Q)}if(y.kind==="paragraphProperties"||y.kind==="runProperties")return y;let T=y.children.map(I);return T.some((N,j)=>N!==y.children[j])?{...y,children:T}:y};return I(k(h,"pPr",P))},g=h=>{if(h.kind==="textValue")return h;if(h.kind==="paragraph")return u(h);let R=h.children.map(g);return R.some((x,f)=>x!==h.children[f])?{...h,children:R}:h};return e.map(g)}var os="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function fe(e,t,n,r){return {...e,attributes:e.attributes.map(o=>o.localName===n&&o.namespaceUri===t?{...o,value:r}:o)}}var ac=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),so=chunk5MWFZ7F4_cjs.yg,We=new Map;function wt(e,t){let n=t.styleIds??We,r=t.numIds??We,o=t.relIds??We,i=t.footnoteIds??We,a=t.endnoteIds??We,s=t.bookmarkIds??We,l=t.sdtIds??We,d=t.revisionIds??We,c=t.docPrIds??We,m=(p,k)=>{if(p.kind==="textValue")return p;let u=p;if(p.namespaceUri===chunk5MWFZ7F4_cjs.fa&&ac.has(p.localName)){let x=chunk5MWFZ7F4_cjs.ef(p,"val"),f=x!==void 0?n.get(x):void 0;f!==void 0&&(u=fe(u,chunk5MWFZ7F4_cjs.fa,"val",f));}if(ne(p,"numId")){let x=chunk5MWFZ7F4_cjs.ef(p,"val"),f=x!==void 0?r.get(x):void 0;f!==void 0&&(u=fe(u,chunk5MWFZ7F4_cjs.fa,"val",f));}if(p.kind==="noteReference"){let x=p.localName==="footnoteReference"?i:a,f=chunk5MWFZ7F4_cjs.ef(p,"id"),P=f!==void 0?x.get(we(f)):void 0;P!==void 0&&(u=fe(u,chunk5MWFZ7F4_cjs.fa,"id",P));}if(p.kind==="bookmarkStart"||p.kind==="bookmarkEnd"){let x=chunk5MWFZ7F4_cjs.ef(p,"id"),f=x!==void 0?s.get(x):void 0;f!==void 0&&(u=fe(u,chunk5MWFZ7F4_cjs.fa,"id",f));}if(ne(p,"id")&&k==="sdtPr"){let x=chunk5MWFZ7F4_cjs.ef(p,"val"),f=x!==void 0?l.get(x):void 0;f!==void 0&&(u=fe(u,chunk5MWFZ7F4_cjs.fa,"val",f));}if(so(p)){let x=chunk5MWFZ7F4_cjs.ef(p,"id"),f=x!==void 0?d.get(x):void 0;f!==void 0&&(u=fe(u,chunk5MWFZ7F4_cjs.fa,"id",f));}if(p.kind==="drawingDocPr"){let x=p.attributes.find(P=>P.localName==="id"&&P.namespaceUri==="")?.value,f=x!==void 0?c.get(x):void 0;f!==void 0&&(u=fe(u,"","id",f));}for(let x of u.attributes){if(x.namespaceUri!==os)continue;let f=o.get(x.value);f!==void 0&&f!==x.value&&(u=fe(u,os,x.localName,f));}let g=p.localName,h=u.children.map(x=>m(x,g));return u!==p||h.some((x,f)=>x!==u.children[f])?{...u,children:h}:p};return m(e,"")}function as(e,t,n){let r=e,o=n.get(e)??2;for(;t.has(r);)r=`${e}${o}`,o+=1;return n.set(e,o),r}function is(e,t,n){let r=`${e} (pasted)`,o=n.get(e)??2;for(;t.has(r);)r=`${e} (pasted ${o})`,o+=1;return n.set(e,o),r}var ic=1e5;function ss(e){let t=chunk5MWFZ7F4_cjs.yb(),n=sc(e,t),r=lc(e,t),o=dc(e,t);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function lo(e,t,n,r){if(e)return chunk5MWFZ7F4_cjs.Bb(t,e,r);let o=n;return ()=>String(o++)}function ls(e,t){if(e.add(t),!/^\d{1,10}$/.test(t))return;let n=Number(t);n<=chunk5MWFZ7F4_cjs.vb&&e.add(String(n));}function ds(e,t){if(t===void 0)return e;let n=Number(t);return Number.isInteger(n)&&n>e?n:e}function sc(e,t){let n=new Map;if(e.fragmentBookmarkIds.length===0)return n;let r=0,o=new Set;for(let a of [e.ownerPart,...e.notesParts])Me([a.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=chunk5MWFZ7F4_cjs.ef(s,"id");l!==void 0&&(ls(o,l),s.kind==="bookmarkStart"&&(r=ds(r,l)));});let i=lo(t,o,r+1,chunk5MWFZ7F4_cjs.vb);for(let a of e.fragmentBookmarkIds){if(n.has(a))continue;let s=i();if(s===null)return null;n.set(a,s);}return n}function lc(e,t){let n=new Map;if(!e.hasRevision)return n;let r=0,o=new Set;for(let s of [e.ownerPart,...e.notesParts]){let l=s===e.ownerPart;Me([s.root],d=>{if(!chunk5MWFZ7F4_cjs.yg(d))return;let c=chunk5MWFZ7F4_cjs.ef(d,"id");c!==void 0&&ls(o,c),l&&(r=ds(r,c));});}let i=lo(t,o,r+1,chunk5MWFZ7F4_cjs.vb),a=false;return Me(e.travelling,s=>{if(a||!chunk5MWFZ7F4_cjs.yg(s))return;let l=chunk5MWFZ7F4_cjs.ef(s,"id");if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}function dc(e,t){let n=new Map;if(!e.hasDocPr)return n;let{used:r}=chunk5MWFZ7F4_cjs.Hd(e.pkg),o=ic;if(!t){let s=chunk5MWFZ7F4_cjs.Id(e.pkg);s.ok&&(o=s.id);}let i=lo(t,r,o,chunk5MWFZ7F4_cjs.Gd),a=false;return Me(e.travelling,s=>{if(a||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(c=>c.localName==="id"&&c.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}function cs(e,t){return `${t?qt(t):"none"}::${e.children.filter(n=>ne(n,"lvlOverride")).map(Je).join("")}`}function ms(e){let t=e.children.find(n=>ne(n,"abstractNumId"));return t?chunk5MWFZ7F4_cjs.ef(t,"val"):void 0}function us(e,t,n){let r=new Set(["0"]),o=0;for(let s of e?.root.children??[]){if(!le(s)||!ne(s,t))continue;let l=chunk5MWFZ7F4_cjs.ef(s,n);if(l===void 0)continue;let d=Number(l);Number.isInteger(d)&&(r.add(String(d)),d>o&&(o=d));}let i=chunk5MWFZ7F4_cjs.yb();if(i)return chunk5MWFZ7F4_cjs.Bb(r,i,chunk5MWFZ7F4_cjs.wb);let a=o+1;return ()=>String(a++)}function ps(e,t){let n={numIdMap:new Map,numsToImport:[],abstractsToImport:[]};if(!e||!le(e.root))return n;let r=new Map,o=[];for(let d of e.root.children)if(le(d))if(ne(d,"abstractNum")){let c=chunk5MWFZ7F4_cjs.ef(d,"abstractNumId");c&&r.set(c,d);}else ne(d,"num")&&o.push(d);let i=new Map;if(t&&le(t.root)){let d=new Map;for(let c of t.root.children){if(!le(c)||!ne(c,"abstractNum"))continue;let m=chunk5MWFZ7F4_cjs.ef(c,"abstractNumId");m&&d.set(m,c);}for(let c of t.root.children){if(!le(c)||!ne(c,"num"))continue;let m=chunk5MWFZ7F4_cjs.ef(c,"numId");if(!m)continue;let p=ms(c),k=p?d.get(p):void 0;i.set(cs(c,k),m);}}let a=us(t,"abstractNum","abstractNumId"),s=us(t,"num","numId"),l=new Map;for(let d of o){let c=chunk5MWFZ7F4_cjs.ef(d,"numId");if(!c)continue;let m=ms(d),p=m?r.get(m):void 0,k=cs(d,p),u=i.get(k);if(u!==void 0){n.numIdMap.set(c,u);continue}let g=m?l.get(m):void 0;if(g===void 0&&p&&m){let x=a();if(x===null)return null;g=x,l.set(m,g),n.abstractsToImport.push(fe(p,chunk5MWFZ7F4_cjs.fa,"abstractNumId",g));}let h=s();if(h===null)return null;n.numIdMap.set(c,h);let R=fe(d,chunk5MWFZ7F4_cjs.fa,"numId",h);if(g!==void 0){let x=R.children.map(f=>ne(f,"abstractNumId")?fe(f,chunk5MWFZ7F4_cjs.fa,"val",g):f);R={...R,children:x};}n.numsToImport.push(R),i.set(k,h);}return n}var Nt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",cc=`${Nt}/hyperlink`,fs=`${Nt}/image`,zn=`${Nt}/numbering`,co=`${Nt}/styles`,gs="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",hs="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Qt(e,t,n,r){for(let o of chunk5MWFZ7F4_cjs.Zd(e,t)){if(o.type!==n||o.targetMode==="External")continue;let i=chunk5MWFZ7F4_cjs.w(o.ownerPart,o.rawTarget);if(i.ok){let a=e.parts.get(i.partName);if(a)return a}}return e.parts.get(r)??null}function mc(e,t){let n=0;return Me([e],r=>{let o=t(r);if(o===void 0)return;let i=Number(o);Number.isInteger(i)&&i>n&&(n=i);}),n}function Kn(e,t,n,r){if(n.length===0)return e;let o=chunk5MWFZ7F4_cjs.Ha(t,"paste"),i=n.map(d=>chunk5MWFZ7F4_cjs.jf(d,o)),a=chunk5MWFZ7F4_cjs.zj(t,i),s=r??a.root.children.length,l=chunk5MWFZ7F4_cjs.Na(a,a.root.id,s,i,{deferValidation:true});return l.ok?chunk5MWFZ7F4_cjs.Xd(e,l.part):null}function ys(e,t){if(t.size===0)return [...e];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"||ne(o,"pict")||ne(o,"object")){let a=false;return Me([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===Nt&&t.has(l.value)&&(a=true);}),a?null:o}if(o.kind==="hyperlink"){let a=o.attributes.find(s=>s.namespaceUri===Nt)?.value;if(a!==void 0&&t.has(a))return r(o.children)}let i=r(o.children);return i.length===o.children.length&&i.every((a,s)=>a===o.children[s])?o:{...o,children:i}};function r(o){let i=[];for(let a of o){let s=n(a);s!==null&&(Array.isArray(s)?i.push(...s):i.push(s));}return i}return r(e)}var uc=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),xs={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function pc(e,t){let n=chunk5MWFZ7F4_cjs.wd(e);return n==="unknown"||(Object.hasOwn(xs,t)?xs[t]:t)!==n||uc.has(n)&&!chunk5MWFZ7F4_cjs.Jd(e,n)?null:n}function mo(e,t,n){for(let b of t.parts.values())if(Gt([b.root]))return {ok:false,reason:"unsupported-content"};let r=t.parts.get(t.mainDocumentPart);if(!r)return {ok:false,reason:"no-fragment-document"};if(!e.parts.has(n))return {ok:false,reason:"no-target-part"};let o=r.root.kind==="document"?r.root.children.find(b=>b.kind==="body"):null;if(!o||!le(o))return {ok:false,reason:"no-fragment-document"};let i=chunk5MWFZ7F4_cjs.Aj(o.children.filter(b=>b.kind==="paragraph"||b.kind==="table"||b.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let a=e,s=ps(Qt(t,t.mainDocumentPart,zn,"/word/numbering.xml"),Qt(a,a.mainDocumentPart,zn,"/word/numbering.xml"));if(!s)return {ok:false,reason:"merge-refused"};let{numIdMap:l,numsToImport:d,abstractsToImport:c}=s,m=Wn(Qt(t,t.mainDocumentPart,co,"/word/styles.xml")),p=Qt(a,a.mainDocumentPart,co,"/word/styles.xml"),k=Wn(p),u=new Map,g=[],h=new Set(k.byId.keys()),R=new Set(k.names),x=new Map,f=new Map,P=new Map,I=(b,C)=>{let A=P.get(b);return A===void 0&&(A=qt(C),P.set(b,A)),A},v=b=>({...b,attributes:b.attributes.filter(C=>!(C.localName==="default"&&C.namespaceUri===chunk5MWFZ7F4_cjs.fa))});for(let b of m.styles){let C=chunk5MWFZ7F4_cjs.ef(b,"styleId");if(!C)continue;let A=k.byId.get(C),F=qt(wt(b,{styleIds:u,numIds:l}));if(A&&I(C,A)===F){u.set(C,C);continue}if(!A){u.set(C,C),h.add(C),g.push(v(b));continue}let K=as(`${C}Pasted`,h,x);h.add(K),u.set(C,K),g.push(v(fe(b,chunk5MWFZ7F4_cjs.fa,"styleId",K)));}let y=g.map(b=>{let C=b.children.find(J=>ne(J,"name")),A=C?chunk5MWFZ7F4_cjs.ef(C,"val"):void 0;if(!A||!R.has(A))return A&&R.add(A),b;let F=is(A,R,f);R.add(F);let K=b.children.map(J=>ne(J,"name")?fe(J,chunk5MWFZ7F4_cjs.fa,"val",F):J);return {...b,children:K}}),T=null,N=1,j=()=>{if(T)return T;let b=new Map;for(let[C,A]of a.partBytes){let F=C.startsWith("/")?C:`/${C}`;if(!F.startsWith("/word/media/"))continue;b.set(chunk5MWFZ7F4_cjs.a(A),F);let K=/\/image(\d+)\./.exec(F);K&&(N=Math.max(N,Number(K[1])+1));}return T=b,b},V=new Map,Q=b=>{let C=V.get(b);if(!C){C=new Map;for(let A of chunk5MWFZ7F4_cjs.Zd(a,b)){if(A.targetMode==="External"||A.type!==fs)continue;let F=chunk5MWFZ7F4_cjs.w(A.ownerPart,A.rawTarget);F.ok&&C.set(F.partName,A.id);}V.set(b,C);}return C},G=(b,C)=>{let A=b.lastIndexOf("."),F=A===-1?"":b.slice(A+1);return /^[A-Za-z0-9]{1,8}$/.test(F)?F.toLowerCase():C==="image/jpeg"?"jpeg":C==="image/gif"?"gif":"png"},D=(b,C,A)=>{let F=new Map,K=new Set,J=Q(C),se=[],ye=new Set,ge=[],Fe=[],Qe=new Map,Ie=[],ln=t.relationships.get(b)??[];for(let ae of ln){if(!A.has(ae.id))continue;if(ae.targetMode==="External"){if(ae.type===cc){let yt=chunk5MWFZ7F4_cjs.Uf(a,ae.rawTarget,C);yt?(a=yt.pkg,F.set(ae.id,yt.relationshipId)):K.add(ae.id);}else K.add(ae.id);continue}let ue=chunk5MWFZ7F4_cjs.w(ae.ownerPart,ae.rawTarget);if(!ue.ok){K.add(ae.id);continue}let Le=t.partBytes.get(ue.partName)??t.partBytes.get(ue.partName.replace(/^\//,"")),w=(chunk5MWFZ7F4_cjs._d(t,ue.partName)??"").toLowerCase();if(!Le||!w.startsWith("image/")){K.add(ae.id);continue}let U=pc(Le,w);if(U===null){K.add(ae.id);continue}let H=U,ee=j(),re=chunk5MWFZ7F4_cjs.a(Le),Y=ee.get(re);if(!Y){let yt=G(ue.partName,H),kd=cn=>a.partBytes.has(cn)||a.partBytes.has(cn.slice(1))||a.parts.has(cn)||ye.has(cn),ar=`/word/media/image${N}.${yt}`;for(;kd(ar);)N+=1,ar=`/word/media/image${N}.${yt}`;N+=1,Y=ar,se.push({partName:Y,bytes:Le,contentType:H}),ye.add(Y),ee.set(re,Y);}let Ze=Y.startsWith("/word/")?Y.slice(6):Y,ht=J.get(Y);if(ht!==void 0){F.set(ae.id,ht);continue}let dn=Qe.get(Y);dn===void 0&&(dn=ge.length,Qe.set(Y,dn),ge.push(Ze),Fe.push(Y)),Ie.push({recordId:ae.id,index:dn});}if(se.length>0&&(a=chunk5MWFZ7F4_cjs.Nd(a,se)),ge.length>0){let ae=chunk5MWFZ7F4_cjs.be(chunk5MWFZ7F4_cjs.de(a,C),C,ge.map(ue=>[fs,ue]));if(ae.ok){a=ae.pkg,ae.ids.forEach((ue,Le)=>{J.set(Fe[Le],ue);});for(let ue of Ie)F.set(ue.recordId,ae.ids[ue.index]);}else for(let ue of Ie)K.add(ue.recordId);}return {relIdMap:F,dropRelIds:K}},B=D(t.mainDocumentPart,n,Qr(i));i=ys(i,B.dropRelIds);let oe=new Map,ve=new Map,L=[],$=(b,C)=>le(b)&&b.namespaceUri===chunk5MWFZ7F4_cjs.fa&&b.localName===C,X={},S=Un(i,(b,C)=>{let A=X[b];if(A===void 0){A=new Map,X[b]=A;let F=chunk5MWFZ7F4_cjs.pg(t,b);if(F&&le(F.root))for(let K of F.root.children){if(!$(K,b))continue;let J=chunk5MWFZ7F4_cjs.ef(K,"id");if(J===void 0)continue;let se=we(J);A.has(se)||A.set(se,K);}}return A.get(C)??null});for(let b of ["footnote","endnote"]){let C=b==="footnote"?oe:ve,A=S[b];if(A.size===0)continue;let F=chunk5MWFZ7F4_cjs.pg(t,b);if(!F||!le(F.root))continue;let K=chunk5MWFZ7F4_cjs.eh(a,b);if(!K.ok||!K.package)return {ok:false,reason:"merge-refused"};a=K.package;let J=chunk5MWFZ7F4_cjs.pg(a,b);if(!J)return {ok:false,reason:"merge-refused"};let se=mc(J.root,ge=>$(ge,b)?chunk5MWFZ7F4_cjs.ef(ge,"id"):void 0)+1,ye=[];for(let ge of F.root.children){if(!$(ge,b))continue;let Fe=chunk5MWFZ7F4_cjs.ef(ge,"id"),Qe=chunk5MWFZ7F4_cjs.ef(ge,"type");if(Qe==="separator"||Qe==="continuationSeparator"||Fe===void 0||!A.has(we(Fe))||C.has(we(Fe)))continue;let Ie=String(se++);C.set(we(Fe),Ie),ye.push(fe(ge,chunk5MWFZ7F4_cjs.fa,"id",Ie));}ye.length>0&&L.push({kind:b,fragmentPartName:F.name,bodies:chunk5MWFZ7F4_cjs.Aj(ye)});}let O=a.parts.get(n),M=[...i,...L.flatMap(b=>b.bodies)],W=[],Z=new Set,ie=false,z=false,_e=new Map;Me(M,b=>{if(b.kind!=="textValue"){if(b.kind==="bookmarkStart"||b.kind==="bookmarkEnd"){let C=chunk5MWFZ7F4_cjs.ef(b,"id");if(C!==void 0&&W.push(C),b.kind==="bookmarkStart"){let A=chunk5MWFZ7F4_cjs.ef(b,"name");A&&Z.add(A);}return}if(so(b)){ie=true;return}if(b.kind==="drawingDocPr"){z=true;return}if(b.kind==="contentControlProperties")for(let C of b.children){if(!ne(C,"id"))continue;let A=chunk5MWFZ7F4_cjs.ef(C,"val");if(A!==void 0&&!_e.has(A)){let F=0,K=`${A}:${_e.size}`;for(let J=0;J<K.length;J+=1)F=F*31+K.charCodeAt(J)>>>0;_e.set(A,String(F%2147483647||1));}}}});let me=ss({pkg:a,ownerPart:O,notesParts:L.map(b=>chunk5MWFZ7F4_cjs.pg(a,b.kind)).filter(b=>b!==null),travelling:M,fragmentBookmarkIds:W,hasRevision:ie,hasDocPr:z});if(!me)return {ok:false,reason:"merge-refused"};let sn=me.bookmarkIds,be=me.revisionIds,ft=me.docPrIds;if(Z.size>0){let b=new Set;if(Me([O.root],C=>{if(C.kind!=="textValue"&&C.kind==="bookmarkStart"){let A=chunk5MWFZ7F4_cjs.ef(C,"name"),F=chunk5MWFZ7F4_cjs.ef(C,"id");A&&F!==void 0&&Z.has(A)&&b.add(F);}}),b.size>0){let C=F=>{if(F.kind==="textValue")return F;let K=[],J=false;for(let se of F.children){if((se.kind==="bookmarkStart"||se.kind==="bookmarkEnd")&&b.has(chunk5MWFZ7F4_cjs.ef(se,"id")??"")){J=true;continue}let ye=C(se);ye!==se&&(J=true),K.push(ye);}return J?{...F,children:K}:F},A=C(O.root);A!==O.root&&(chunk5MWFZ7F4_cjs.La(O.root,A),a=chunk5MWFZ7F4_cjs.Xd(a,{...O,root:A}));}}let Ft=b=>Zr(b,oe,ve);for(let b of L){b.bodies=b.bodies.map(Ft);let C=chunk5MWFZ7F4_cjs.pg(a,b.kind);if(!C)return {ok:false,reason:"merge-refused"};let A=D(b.fragmentPartName,C.name,Qr(b.bodies)),F=ys(b.bodies,A.dropRelIds);F=[...io(F,m,k)],F=F.map(J=>wt(J,{styleIds:u,numIds:l,relIds:A.relIdMap,footnoteIds:oe,endnoteIds:ve,bookmarkIds:sn,sdtIds:_e,revisionIds:be,docPrIds:ft}));let K=Kn(a,a.parts.get(C.name),F);if(!K)return {ok:false,reason:"merge-refused"};a=K;}if(y.length>0){let b=y.map(A=>wt(A,{styleIds:u,numIds:l}));if(!p){let A=chunk5MWFZ7F4_cjs.za(`<w:styles xmlns:w="${chunk5MWFZ7F4_cjs.fa}"></w:styles>`,{name:"/word/styles.xml",contentType:hs});if(!A.ok)return {ok:false,reason:"merge-refused"};a=chunk5MWFZ7F4_cjs.fe(a,"/word/styles.xml",A.part.root,hs);let F=chunk5MWFZ7F4_cjs.ee(chunk5MWFZ7F4_cjs.de(a,a.mainDocumentPart),a.mainDocumentPart,co,"styles.xml");if(!F.ok)return {ok:false,reason:"merge-refused"};a=F.pkg,p=a.parts.get("/word/styles.xml")??null;}if(!p)return {ok:false,reason:"merge-refused"};let C=Kn(a,a.parts.get(p.name),b);if(!C)return {ok:false,reason:"merge-refused"};a=C,k=Wn(a.parts.get(p.name)??null);}if(c.length>0||d.length>0){let b=Qt(a,a.mainDocumentPart,zn,"/word/numbering.xml");if(!b){let J=chunk5MWFZ7F4_cjs.za(`<w:numbering xmlns:w="${chunk5MWFZ7F4_cjs.fa}"></w:numbering>`,{name:"/word/numbering.xml",contentType:gs});if(!J.ok)return {ok:false,reason:"merge-refused"};a=chunk5MWFZ7F4_cjs.fe(a,"/word/numbering.xml",J.part.root,gs);let se=chunk5MWFZ7F4_cjs.ee(chunk5MWFZ7F4_cjs.de(a,a.mainDocumentPart),a.mainDocumentPart,zn,"numbering.xml");if(!se.ok)return {ok:false,reason:"merge-refused"};a=se.pkg,b=a.parts.get("/word/numbering.xml")??null;}if(!b)return {ok:false,reason:"merge-refused"};let C=a.parts.get(b.name),A=C.root.children.findIndex(J=>ne(J,"num")),F=c.map(J=>wt(J,{styleIds:u,numIds:l})),K=Kn(a,C,F,A===-1?void 0:A);if(!K)return {ok:false,reason:"merge-refused"};if(a=K,K=Kn(a,a.parts.get(b.name),d),!K)return {ok:false,reason:"merge-refused"};a=K;}let Lt=[...io(i,m,k)].map(Ft).map(b=>wt(b,{styleIds:u,numIds:l,relIds:B.relIdMap,footnoteIds:oe,endnoteIds:ve,bookmarkIds:sn,sdtIds:_e,revisionIds:be,docPrIds:ft}));return {ok:true,pkg:a,blocks:Lt}}var ks=16*1024*1024;function fc(e){let t=e.parts.get(e.mainDocumentPart);if(!t||t.root.kind!=="document")return false;let n=t.root.children.find(i=>i.kind==="body");if(!n||n.kind!=="body"||n.children.length>chunk5MWFZ7F4_cjs.wj)return false;let r=0,o=(i,a,s)=>{if(a>s||(r+=1,r>chunk5MWFZ7F4_cjs.yj))return false;if(i.kind==="textValue")return true;for(let l of i.children)if(!o(l,a+1,s))return false;return true};for(let i of n.children)if(!o(i,1,chunk5MWFZ7F4_cjs.xj))return false;for(let[i,a]of e.parts)if(i!==e.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!o(a.root,1,chunk5MWFZ7F4_cjs.xj*4))return false;return true}function uo(e,t,n){if(n.fragmentBytes.byteLength>ks)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=chunk5MWFZ7F4_cjs.Vd(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=r.package;if(!fc(o))return {ok:false,reason:"invalidArgs",detail:"fragment-over-budget"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let{store:a,story:s}=i;if(a.compositionActive||e.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=e.currentPackage(),d=a.checkpoint();a.graftPackage(()=>e.currentPackage());let c=0,m="";return chunk5MWFZ7F4_cjs.Ea(e,()=>{let p=a.transact(u=>{for(let x of n.priorOps??[])if(!u.apply(x))return;let g=null,h=u.applyPackage(x=>(g=mo(x,o,s.partName),g.ok?g.pkg:x)),R=g;if(!R||!R.ok){m=`fragment-merge:${R?R.reason:"no-merge"}`,u.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}h&&(c=R.blocks.length,u.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:R.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return m.length>0?{ok:false,reason:"invalidArgs",detail:m}:p.ok?p.change?{ok:true,change:e.promoteStoryTransactionToPackageUnit(l,a,d),blockCount:c}:{ok:true,change:null,blockCount:c}:{ok:false,reason:p.reason,...p.detail?{detail:p.detail}:{}}},p=>chunk5MWFZ7F4_cjs.Fa(p))}function Rs(){let e=null;return (t,n,r)=>{let o=e;if(e=null,!chunk5MWFZ7F4_cjs.Wi(n)||!("paragraphId"in r)||!chunk5MWFZ7F4_cjs.Yi(t,r.paragraphId))return r;if(r.op==="insertText"&&!r.revision&&r.inside===void 0&&o&&o.partName===t.name&&o.paragraphId===r.paragraphId&&o.offset===r.offset)return {...r,inside:o.controlId};if(r.op!=="deleteText"||r.revision||r.start>=r.end)return r;let i=chunk5MWFZ7F4_cjs.Ja(t,r.paragraphId);if(i?.kind!=="paragraph")return r;let a=chunk5MWFZ7F4_cjs.bj(t,chunk5MWFZ7F4_cjs.aj(r));if(a.unprotected.length)return r;let s=chunk5MWFZ7F4_cjs.qf(i);for(let l of a.touches){let d=s.spanOf(l.control);d&&d.start<=r.start&&d.end>=r.end&&(e={partName:t.name,paragraphId:r.paragraphId,offset:r.start,controlId:l.control.id});}return r}}var Ps=new WeakSet;function gc(e){return Ps.add(e),e}function vs(e){return Ps.has(e)}function Zt(e){return {...e,applyPackage:t=>e.applyPackage(gc(t))}}var hc=new Set(["insertText","insertTab","insertHardBreak","insertPageBreak","insertPageField","insertDrawing","deleteText"]),Is=new Set(["insertDrawing"]);function yc(e){if(!(e===null||e.start!==e.end))return e}var Et={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function xc(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 dt=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];subscribers=new Set;historyLimit;settingsPartOverride;storyRef=null;composition=null;constructor(t,n,r={}){let o="root"in t,i=typeof n=="string"?n:void 0,a=typeof n=="object"&&n!==null?n:r;this.current=o?xc(t):t,this.storyPartName=i??(o?t.name:t.mainDocumentPart),this.historyLimit=a.historyLimit??200,this.settingsPartOverride=a.settingsPart;}setStoryRef(t){this.storyRef=t;}get part(){let t=this.current.parts.get(this.storyPartName);if(!t)throw new Error(`story part missing: ${this.storyPartName}`);return t}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(t){this.current=t(this.current);}replacePart(t){let n=this.current.parts.get(t.name);t!==n&&(this.current=chunk5MWFZ7F4_cjs.Xd(this.current,t),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(t){this.current=t.pkg,this.rev=t.revision,this.undoStack.length=0,this.undoStack.push(...t.undoStack),this.redoStack.length=0,this.redoStack.push(...t.redoStack),this.composition=t.composition?{entry:{...t.composition.entry},committed:t.composition.committed}:null;}restoreHistoryStacks(t){this.undoStack.length=0,this.undoStack.push(...t.undoStack),this.redoStack.length=0,this.redoStack.push(...t.redoStack);}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}transact(t,n={}){return chunk5MWFZ7F4_cjs.xb(n.actorId,()=>this.commitTransaction(t,n))}commitTransaction(t,n){let r=n.origin??chunk5MWFZ7F4_cjs.b.mutationHuman,o=n.recordsHistory??(r!==chunk5MWFZ7F4_cjs.b.projection&&r!==chunk5MWFZ7F4_cjs.b.awareness),i=this.undoStack[this.undoStack.length-1];o&&!this.composition&&i?.group!==n.historyGroup&&this.closeHistoryGroup();let a=this.current,s=this.rev,l=this.current,d=null,c=0,m=new Set,p=new Set,k=new Set,u=new Set,g=new Set,h=[],R=n.minimumImpact??"text-local",x=null,f=false,P=null,I=null,v=new Map,y=new Map,T=L=>{let $=y.get(L.name);$||($={mint:null,written:new Set},y.set(L.name,$));let X=$;return {mint:()=>(X.mint??=chunk5MWFZ7F4_cjs.xg(L))(),wrote:S=>{X.written.add(S);},wroteUnder:S=>X.written.has(S)}},N=()=>{for(let L of y.values())L.mint=null;},j=(L,$)=>{let X=chunk5MWFZ7F4_cjs.xi.get(L.op);if(X===void 0)return v.clear(),null;let S=`${$.name}\0${X}`,O=v.get(S);O||(O={id:null},v.set(S,O));let M=O;return ()=>M.id??=T($).mint()},V=(L,$)=>{let X=hc.has(L.op);return !X&&chunk5MWFZ7F4_cjs.xi.get(L.op)!==void 0?null:((!X||Is.has(L.op))&&N(),X?T($):null)},Q=Rs(),G=null,D=(L,$)=>{if(d)return false;let X=l.parts.get(L);if(!X)return d={reason:"unknown-part",detail:L},false;$=Q(X,this.settingsPartOverride?.()??chunk5MWFZ7F4_cjs.eg(l),$);let S=chunk5MWFZ7F4_cjs.Vi(this.settingsPartOverride?.()??chunk5MWFZ7F4_cjs.eg(l),$)??chunk5MWFZ7F4_cjs.cj(X,this.settingsPartOverride?.()??chunk5MWFZ7F4_cjs.eg(l),$,G?.partName===L&&"paragraphId"in $&&G.paragraphId===$.paragraphId?G.fieldNodeId:void 0);if(S)return d={reason:S},false;let O=j($,X),M=V($,X),W=this.settingsPartOverride?.()??chunk5MWFZ7F4_cjs.eg(l),Z=chunk5MWFZ7F4_cjs.Wi(W)&&"paragraphId"in $&&chunk5MWFZ7F4_cjs.Yi(X,$.paragraphId)?chunk5MWFZ7F4_cjs.bi(X,$,G?.partName===L&&G.paragraphId===$.paragraphId?G.fieldNodeId:void 0):null;G=Z&&"paragraphId"in $?{partName:L,paragraphId:$.paragraphId,fieldNodeId:Z.fieldNodeId}:null;let ie={deferValidation:true,...O?{revisionIds:O}:{},...M?{trackedRevisionIds:M}:{}},z=Z?chunk5MWFZ7F4_cjs.hi(X,$,Z,ie):chunk5MWFZ7F4_cjs.Bj(X,$,ie);if(!z.ok)return d={reason:z.reason,...z.detail?{detail:z.detail}:{}},false;if(Is.has($.op)&&N(),l=chunk5MWFZ7F4_cjs.Xd(l,z.part),z.part===X&&z.effect.dirty.length===0&&z.effect.created.length===0&&z.effect.deleted.length===0&&z.effect.split===void 0&&(z.effect.splits===void 0||z.effect.splits.length===0)&&z.effect.join===void 0&&z.effect.caret===void 0)return true;m.add(L),c+=1;for(let me of z.effect.dirty)p.add(me);for(let me of z.effect.created)k.add(me);for(let me of z.effect.deleted)u.add(me);for(let me of z.effect.dependencyKeys)g.add(me);z.effect.split&&h.push({split:z.effect.split});for(let me of z.effect.splits??[])h.push({split:me});return z.effect.join&&h.push({join:z.effect.join}),Et[z.effect.impact]>Et[R]&&(R=z.effect.impact),z.effect.caret&&(I={paragraphId:z.effect.caret.paragraphId,start:0,end:0}),true};if(t({apply:L=>D(this.storyPartName,L),applyTo:(L,$)=>D(L,$),applyPackage:L=>{if(d)return false;let $=this.settingsPartOverride?.()??chunk5MWFZ7F4_cjs.eg(l),X=vs(L)?chunk5MWFZ7F4_cjs.Ui($,{op:"comment"}):chunk5MWFZ7F4_cjs.Vi($);if(X)return d={reason:X},false;v.clear(),N();let S=L(l);if(S===l)return true;for(let[O,M]of S.parts)l.parts.get(O)!==M&&m.add(O);return l=S,c+=1,Et["flow-structural"]>Et[R]&&(R="flow-structural"),true},selectionBefore:L=>{x=L;},selectionAfter:L=>{f=true,P=L;}}),d){let L=d;return {ok:false,reason:L.reason,...L.detail?{detail:L.detail}:{}}}if(c===0)return {ok:true,change:null};let B=f?P:I,oe=f?yc(P):I??void 0;for(let L of m){let $=a.parts.get(L),X=l.parts.get(L);if(X===void 0)continue;let S=$?chunk5MWFZ7F4_cjs.xa($,X):chunk5MWFZ7F4_cjs.xa(X,X);if(!S.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(S.issues)}}let ve=chunk5MWFZ7F4_cjs.ge(l);if(!ve.ok)return {ok:false,reason:"package-invariant",detail:JSON.stringify(ve.issues)};if(o)if(this.composition)chunk5MWFZ7F4_cjs.Lj(n.historyGroup,"split","composition"),this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:B}};else {let L=n.historyGroup,$=this.undoStack[this.undoStack.length-1];L!==void 0&&$!==void 0&&$.group===L?this.undoStack[this.undoStack.length-1]={...$,selectionAfter:B??$.selectionAfter}:this.pushUndo({pkg:a,revision:s,selectionBefore:x,selectionAfter:B,group:L}),chunk5MWFZ7F4_cjs.Lj(L,$?.group===L?"extended":"started"),this.redoStack.length=0;}return this.current=l,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&Et[n.minimumImpact]>Et[R]&&(R=n.minimumImpact),{ok:true,change:this.publish(r,s,{dirty:p,created:k,deleted:u,dependencyKeys:g,splitJoin:h,impact:R,caret:oe},n.story??this.storyRef??void 0,n.actorId,n.operationId)}}beginComposition(t=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:t,selectionAfter:null},committed:false});}endComposition(){let t=this.composition;this.composition=null,!(!t||!t.committed)&&(this.pushUndo(t.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}closeHistoryGroup(){let t=this.undoStack[this.undoStack.length-1];t===void 0||t.group===void 0||(this.undoStack[this.undoStack.length-1]={...t,group:void 0});}undo(){let t=this.undoStack.pop();if(!t)return null;this.closeHistoryGroup();let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(chunk5MWFZ7F4_cjs.b.mutationUndo,n,null,this.storyRef??void 0)}redo(){let t=this.redoStack.pop();if(!t)return null;this.closeHistoryGroup();let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(chunk5MWFZ7F4_cjs.b.mutationRedo,n,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}pushUndo(t){this.undoStack.push(t),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(t,n,r,o,i,a){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:t,...i?{actorId:i}:{},...a?{operationId:a}:{},dirty:r?[...r.dirty]:[],created:r?[...r.created]:[],deleted:r?[...r.deleted]:[],splitJoin:r?r.splitJoin:[],dependencyKeys:r?[...r.dependencyKeys]:[],impact:r?r.impact:o?.kind==="headerFooter"?"global":"flow-structural",...r?.caret?{caret:r.caret}:{},...o?{story:o}:{}};for(let l of this.subscribers)l(s);return s}};function po(e,t,n,r){if(!e)return null;if(e.kind==="package")return (r==="undo"?e.selectionBefore:e.selectionAfter)??null;let o=e.partName===t.part.name?t:n.get(e.partName);return (r==="undo"?o?.selectionForUndo():o?.selectionForRedo())??null}function Os(e){let t=null,n;return {context:{selectionBefore(r){t=r,e.selectionBefore(r);},selectionAfter(r){n=r,e.selectionAfter(r);}},snapshot(r){return {selectionBefore:t,selectionAfter:n===void 0?r??null:n}}}}function fo(e,t){return [...e.values()].map(n=>n.part).filter(n=>t.parts.has(n.name))}function bs(e,t){return fo(e,t).map(n=>n.name).sort().join(",")}function Ss(e,t,n){if(e.relationships!==t.relationships||e.contentTypes!==t.contentTypes||e.partBytes!==t.partBytes||e.externalTargets!==t.externalTargets||e.mainDocumentPart!==t.mainDocumentPart)return true;if(e.parts===t.parts)return false;if(e.parts.size!==t.parts.size)return true;for(let[r,o]of t.parts)if(r!==n&&e.parts.get(r)!==o)return true;return false}var Xn="http://schemas.openxmlformats.org/wordprocessingml/2006/main",kc="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Tt(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===Xn&&n.localName===t)return n;return null}function Gn(e,t){return e.attributes.find(n=>n.namespaceUri===Xn&&n.localName===t)?.value}function Rc(e){let t=Gn(e,"val");return t===void 0||t==="1"||t==="true"||t==="on"}function Ns(e,t){return e.kind==="textValue"?Object.freeze({...e,id:t()}):Object.freeze({...e,id:t(),children:e.children.map(n=>Ns(n,t))})}function Pc(e){let t=chunk5MWFZ7F4_cjs.za(`<w:styles xmlns:w="${Xn}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:e.name,contentType:kc});if(!t.ok)return null;let n=Tt(t.part.root,"style"),r=n?Tt(n,"pPr"):null;return r?Ns(r,chunk5MWFZ7F4_cjs.Ha(e)):null}var ws=["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 vc(e,t){let n=ws.indexOf(t),r=0;return e.forEach((o,i)=>{if(o.kind==="textValue")return;let a=ws.indexOf(o.localName);a!==-1&&a<=n&&(r=i+1);}),r}function Es(e,t){let n=chunk5MWFZ7F4_cjs.Sc(e);if(!n)return null;let r=null;for(let d of n.root.children)if(d.kind!=="textValue"&&d.namespaceUri===Xn&&d.localName==="style"&&Gn(d,"type")==="paragraph"&&Gn(d,"styleId")===t){r=d;break}if(!r)return null;let o=Tt(r,"name");if(o&&Gn(o,"val")?.trim().toLowerCase()!=="list paragraph"&&t!=="ListParagraph")return null;let i=Pc(n);if(!i)return null;let a=Tt(i,"contextualSpacing");if(!a)return null;let s=Tt(r,"pPr"),l;if(s){let d=Tt(s,"contextualSpacing");if(d&&Rc(d))return e;l=d?chunk5MWFZ7F4_cjs.Oa(n,d.id,a):chunk5MWFZ7F4_cjs.Na(n,s.id,vc(s.children,"contextualSpacing"),[a]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));l=chunk5MWFZ7F4_cjs.Na(n,r.id,d===-1?r.children.length:d,[i]);}return l.ok?Object.freeze({...e,parts:new Map([...e.parts,[n.name,l.part]])}):null}var As="http://schemas.openxmlformats.org/package/2006/relationships",Ds="application/vnd.openxmlformats-package.relationships+xml",bc="http://schemas.openxmlformats.org/package/2006/content-types",Ts="/[Content_Types].xml",ct="/word/numbering.xml",Cs="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",en="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Sc=`<Override PartName="${ct}" ContentType="${en}"/>`;function Yn(e){return `${e.ownerPart}\0${e.id}`}function _s(e,t,n){let r=new Set(t.externalTargets.filter(s=>s.type===chunk5MWFZ7F4_cjs._c).map(Yn)),o=n.externalTargets.filter(s=>s.type===chunk5MWFZ7F4_cjs._c&&!r.has(Yn(s)));if(o.length===0)return e;let i=new Set(e.map(Yn)),a=o.filter(s=>!i.has(Yn(s)));return a.length===0?e:Object.freeze([...e,...a])}function Fs(e,t,n){let r=e.filter(o=>o.ownerPart===n||t.has(o.ownerPart));return r.length===e.length?e:Object.freeze(r)}function Ls(e,t,n=[],r=false){if(e===t)return e;let o=wc(e,t,r);return o=Ec(o,t,n),o}function $s(e,t){let n=new Set;for(let o of e.externalTargets)o.type===chunk5MWFZ7F4_cjs._c&&o.ownerPart!==e.mainDocumentPart&&(e.parts.has(o.ownerPart)||t.has(o.ownerPart)||n.add(o.ownerPart));for(let o of e.parts.keys()){let i=Ac(o);!i||i===e.mainDocumentPart||e.parts.has(i)||t.has(i)||e.externalTargets.some(a=>a.ownerPart===i)||n.add(i);}if(n.size===0)return e;let r=e;for(let o of n)r=Dc(r,o);return r}function wc(e,t,n){let r=t.parts.get(ct);if(!r)return e;let o=e.parts.get(ct),i=n&&o?Nc(o,r):r,a=chunk5MWFZ7F4_cjs.Xd(e,i),s=(t.relationships.get(t.mainDocumentPart)??[]).find(d=>d.type===Cs),l=a.relationships.get(a.mainDocumentPart)??[];if(s&&!l.some(d=>d.type===Cs)&&!l.some(d=>d.id===s.id)){let d=Cc(a,{...s,ownerPart:a.mainDocumentPart});d&&(a=d);}if(a.contentTypes.overrides.get(chunk5MWFZ7F4_cjs.u(ct))!==en){let d=_c(a);d&&(a=d);}return a}function Nc(e,t){let n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",r=l=>{if(l.kind==="textValue"||l.namespaceUri!==n)return null;let d=l.localName==="abstractNum"?"abstractNumId":l.localName==="num"?"numId":l.localName==="numPicBullet"?"numPicBulletId":null;if(!d)return null;let c=l.attributes.find(m=>m.namespaceUri===n&&m.localName===d)?.value;return c===void 0?null:`${l.localName}:${c}`},o=new Set(e.root.children.map(r).filter(Boolean)),i=chunk5MWFZ7F4_cjs.Ha(e),a=["numPicBullet","abstractNum","num","numIdMacAtCleanup"],s=e;for(let l of t.root.children){let d=r(l);if(!d||o.has(d)||l.kind==="textValue")continue;let c=a.indexOf(l.localName),m=s.root.children.findIndex(k=>k.kind!=="textValue"&&k.namespaceUri===n&&a.indexOf(k.localName)>c),p=chunk5MWFZ7F4_cjs.Na(s,s.root.id,m<0?s.root.children.length:m,[go(l,i)]);p.ok&&(s=p.part,o.add(d));}return s}function Ec(e,t,n){let r=n.filter(i=>i.type===chunk5MWFZ7F4_cjs._c);if(r.length===0)return e;let o=e;for(let i of r){let a=Tc(e,t,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 l=Mc(o,{ownerPart:a,id:i.id,type:chunk5MWFZ7F4_cjs._c,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);l&&(o=l);}return o}function Tc(e,t,n){return n===t.mainDocumentPart?e.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function Cc(e,t){let n=e.mainDocumentPart,r=ho(n),o=e.parts.get(r),i=chunk5MWFZ7F4_cjs.za(`<Relationships xmlns="${As}"><Relationship Id="${chunk5MWFZ7F4_cjs.P(t.id,"relationship id")}" Type="${chunk5MWFZ7F4_cjs.P(t.type,"relationship type")}" Target="${chunk5MWFZ7F4_cjs.P(t.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:Ds});if(!i.ok)return null;let a=e.relationships.get(n)??[];if(a.some(d=>d.id===t.id))return null;let s={...t,ownerPart:n,order:a.reduce((d,c)=>Math.max(d,c.order),-1)+1},l=new Map([...e.relationships,[n,[...a,s]]]);return o?Us(e,o,i.part.root.children[0],l):Object.freeze({...e,parts:new Map([...e.parts,[r,i.part]]),relationships:l})}function Mc(e,t,n=e.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=ho(r),i=e.parts.get(o),a=chunk5MWFZ7F4_cjs.za(`<Relationships xmlns="${As}"><Relationship Id="${chunk5MWFZ7F4_cjs.P(t.id,"relationship id")}" Type="${chunk5MWFZ7F4_cjs._c}" Target="${chunk5MWFZ7F4_cjs.P(t.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:Ds});if(!a.ok)return null;let s=[...e.externalTargets,t];if(!i)return Object.freeze({...e,parts:new Map([...e.parts,[o,a.part]]),externalTargets:s});let l=Us(e,i,a.part.root.children[0],e.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Us(e,t,n,r){if(!n)return null;let o=chunk5MWFZ7F4_cjs.Ha(t),i=chunk5MWFZ7F4_cjs.Na(t,t.root.id,t.root.children.length,[go(n,o)]);return i.ok?Object.freeze({...e,parts:new Map([...e.parts,[t.name,i.part]]),relationships:r}):null}function go(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>go(n,t))}}function ho(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Ac(e){let t=/^(.*)\/_rels\/([^/]+)\.rels$/.exec(e);if(!t)return null;let n=t[1],r=t[2];return n===""||r===""?null:`${n}/${r}`}function Dc(e,t){let n=ho(t),r=new Map(e.parts);r.delete(n);let o=new Map(e.partBytes);o.delete(n);let i=new Map(e.relationships);i.delete(t);let a=Object.freeze(e.externalTargets.filter(s=>s.ownerPart!==t));return Object.freeze({...e,parts:r,partBytes:o,relationships:i,externalTargets:a})}function _c(e){let t=e.contentTypes.overrides.get(chunk5MWFZ7F4_cjs.u(ct));if(t===en)return e;if(t!==void 0)return null;let n=e.partBytes.get(Ts);if(!n)return null;let r=fflate.strFromU8(n),o=Ms(r);if(!o)return null;let i=r.lastIndexOf(`</${o.rootName}>`);if(i===-1)return null;let a=r.slice(0,i)+Sc+r.slice(i),s=Ms(a);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,Bs("Override",{PartName:ct,ContentType:en})];return s.children.length!==l.length||s.children.some((d,c)=>d!==l[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Ts,fflate.strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[chunk5MWFZ7F4_cjs.u(ct),en]])})})}function Ms(e){let t=chunk5MWFZ7F4_cjs.X(e);if(!t.ok)return null;let n=t.nodes.filter(s=>s.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),i=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[i?`xmlns:${i}`:"xmlns"]!==bc)return null;let a=[];for(let s of r.children)s.type==="element"&&a.push(Bs(s.name,s.attributes));return {rootName:r.name,children:a}}function Bs(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}var js=4e3,Hs=64;function Vs(e){return chunk5MWFZ7F4_cjs.pg(e,"footnote")!==null||chunk5MWFZ7F4_cjs.pg(e,"endnote")!==null}function Ws(e,t,n,r){if(!Vs(e))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let o=chunk5MWFZ7F4_cjs.Ja(t,n.paragraphId);return !o||o.kind!=="paragraph"?true:chunk5MWFZ7F4_cjs.of(o).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function zs(e,t,n,r){if(!Vs(e))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let o=chunk5MWFZ7F4_cjs.Ja(t,n.blockId);if(!o||o.kind==="textValue")return true;let i=0,a=(s,l)=>{if(i>=js||l>Hs)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return chunk5MWFZ7F4_cjs.of(s).some(d=>d.node.kind==="noteReference");for(let d of s.children)if(a(d,l+1))return true;return false};return a(o,0)}function Ks(e,t,n){if(n.count>=js||t>Hs)return true;if(n.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(Ks(r,t+1,n))return true;return false}function Gs(e,t,n,r){if(!chunk5MWFZ7F4_cjs.mh(e))return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let i=chunk5MWFZ7F4_cjs.Ja(t,o);return !i||i.kind==="textValue"?true:Ks(i,0,{count:0})}var yo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",xo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function Xs(e,t){let r=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.id===t);return r?r.type!==yo&&r.type!==xo?{ok:false,reason:"wrong-relationship-type",detail:r.type}:Fc(e,r):{ok:false,reason:"dangling-relationship",detail:t}}function Fc(e,t){let n=chunk5MWFZ7F4_cjs.E(t);if(n.mode==="External")return {ok:false,reason:"external-relationship",detail:t.id};if(!n.target.ok)return {ok:false,reason:"bad-relationship-target",detail:n.target.reason};let r=e.parts.get(n.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:n.target.partName};let o=r.root.localName;return o!=="hdr"&&o!=="ftr"?{ok:false,reason:"not-a-story-part",detail:o||r.name}:{ok:true,partName:r.name,part:r}}function mt(e,t){return t.compositionActive||e.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function Ys(e,t){let n=chunk5MWFZ7F4_cjs.Ja(e,t);return !n||n.kind!=="drawing"?null:n.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function Js(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=chunk5MWFZ7F4_cjs.Ja(r,n);return !o||o.kind!=="drawing"?null:chunk5MWFZ7F4_cjs.od(o,{ownerPartName:t,supportedMcRequires:chunk5MWFZ7F4_cjs.hd,limits:chunk5MWFZ7F4_cjs.gd,resolveRelationship:chunk5MWFZ7F4_cjs.jd(e,t)})}function qs(e,t,n){let r=chunk5MWFZ7F4_cjs.F(e.relationships.get(t)??[],t,n);return r.mode==="internal"?r.partName:null}function Ct(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=mt(e,o.store);if(i)return i;let{store:a,story:s}=o;return chunk5MWFZ7F4_cjs.Ea(e,()=>Lc(e,a,s,n,r),l=>chunk5MWFZ7F4_cjs.Fa(l))}function Lc(e,t,n,r,o){let i=n.partName,a=e.currentPackage(),s=t.checkpoint();t.graftPackage(()=>e.currentPackage());let l=null,d=false,c=false,m=t.transact(u=>{if(o?.commitGuard?.()===false){c=true;return}if(o?.expectedPackageRevision!==void 0&&e.packageRevision!==o.expectedPackageRevision){d=true;return}let g=r(u,i);if(g===null){u.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}l=g;},{story:n,...o?.actorId?{actorId:o.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(c)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(d)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!m.ok)return {ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}};if(!m.change)return {ok:true,change:null};let p=m.change.created.find(u=>{let g=t.part;return chunk5MWFZ7F4_cjs.Ja(g,u)?.kind==="drawing"});return p&&(l=p),{ok:true,change:e.promoteStoryTransactionToPackageUnit(a,t,s),...l?{drawingNodeId:l}:{}}}function Qs(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=Ys(r,n);return o?chunk5MWFZ7F4_cjs.sj(o):null}function ko(e,t,n,r){let o=false;return e.applyPackage(i=>{let a=i.parts.get(t);if(!a)return i;let s=chunk5MWFZ7F4_cjs.Ja(a,n);if(!s||s.kind!=="drawing")return i;let l=Ys(a,n);if(!l)return i;let d=chunk5MWFZ7F4_cjs.tj(l,r),c=$c(s,d),m=chunk5MWFZ7F4_cjs.Oa(a,s.id,c,{deferValidation:true});return m.ok?(o=true,chunk5MWFZ7F4_cjs.Xd(i,m.part)):i}),o}function $c(e,t){return {...e,children:e.children.map(n=>n.id===t.id?t:n)}}async function Zs(e,t,n){let r=chunk5MWFZ7F4_cjs.Pd(n.widthPoints),o=chunk5MWFZ7F4_cjs.Pd(n.heightPoints);if(r===null||o===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let a=mt(e,i.store);if(a)return a;let s=i.story.partName,l=await chunk5MWFZ7F4_cjs.Kd(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=l.bytes,c=chunk5MWFZ7F4_cjs.Md(e.currentPackage(),s,{bytes:d,mime:n.mime});if(!c.ok)return {ok:false,reason:"invalidArgs",detail:c.reason==="invalid-image"?"invalid-image":c.reason};let m=c.partName,p=Ct(e,t,(k,u)=>{let g=e.currentPackage(),h=chunk5MWFZ7F4_cjs.Md(g,u,{bytes:d,mime:n.mime});if(!h.ok)return null;g=h.pkg,m=h.partName;let R;if(n.hyperlink){let f=chunk5MWFZ7F4_cjs.Uf(g,n.hyperlink,u);if(!f)return null;g=f.pkg,R=f.relationshipId;}if(!k.applyPackage(()=>g))return null;let x=chunk5MWFZ7F4_cjs.Qd({docPrId:h.docPrId,relationshipId:h.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...R?{hyperlinkRelationshipId:R}:{}});return k.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:x,...n.revision?{revision:n.revision}:{}})?x.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return p.ok?p.change?{...p,mediaPartName:m}:{ok:true,change:null,mediaPartName:m}:p}async function Ro(e,t,n,r,o,i,a){let s=e.resolveStory(t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=mt(e,s.store);if(l)return l;let d=s.story.partName,c=await chunk5MWFZ7F4_cjs.Kd(i,r,o);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let m=c.bytes,p=chunk5MWFZ7F4_cjs.Md(e.currentPackage(),d,{bytes:m,mime:o});return p.ok?Ct(e,t,(k,u)=>{let g=e.currentPackage(),h=Js(g,d,n),R=h?.picture?.embeddedRelationshipId??null,x=h?.picture?.linkedRelationshipId??null,f=R??x;if(!f)return null;let P=R!==null?qs(g,d,R):null,I=g,v=chunk5MWFZ7F4_cjs.Md(I,u,{bytes:m,mime:o});return !v.ok||(I=v.pkg,!k.applyPackage(()=>I))||!k.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:v.relationshipId})?null:(k.applyPackage(y=>chunk5MWFZ7F4_cjs.Sd(y,u,P,f)),n)},{expectedPackageRevision:a.expectedPackageRevision,...a.commitGuard?{commitGuard:a.commitGuard}:{},...a.actorId?{actorId:a.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:p.reason==="invalid-image"?"invalid-image":p.reason}}function el(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=mt(e,r.store);if(o)return o;let i=r.story.partName,a=e.currentPackage(),s=a.parts.get(i),l=Js(a,i,n)??(s?chunk5MWFZ7F4_cjs.jj(s,n):null);if(!l)return {ok:false,reason:"unknown-drawing"};let d=l.picture?.embeddedRelationshipId??null,c=l.picture?.linkedRelationshipId??null,m=d??c,p=d!==null?qs(a,i,d):null;return Ct(e,t,(k,u)=>k.apply({op:"deleteDrawing",drawingNodeId:n})?(k.applyPackage(g=>chunk5MWFZ7F4_cjs.Sd(g,u,p,m)),n):null)}function Uc(e,t){let n=null,r=i=>{let a=false,s=false,l=(d,c)=>{if(a||d.kind==="textValue")return;if(d.id===t){a=true,s=c;return}let m=c||d.kind==="revisionDelete"||d.kind==="revisionMoveFrom";for(let p of d.children)l(p,m);};return l(i,false),s},o=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let a=chunk5MWFZ7F4_cjs.qf(i).spanOf(t);if(a!==null&&a.end>a.start){let s=chunk5MWFZ7F4_cjs.Ja(e,t);if(!s||s.kind!=="drawing"&&!chunk5MWFZ7F4_cjs.kd(s))return;n={paragraphId:i.id,start:a.start,end:a.end,alreadyDeleted:r(i)};}return}for(let a of i.children)o(a);}};return o(e.root),n}function tl(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=mt(e,o.store);if(i)return i;let a=e.currentPackage().parts.get(o.story.partName);if(!a)return {ok:false,reason:"unknown-drawing"};let s=Uc(a,n);return s?s.alreadyDeleted?{ok:true,change:null}:Ct(e,t,l=>l.apply({op:"deleteText",paragraphId:s.paragraphId,start:s.start,end:s.end,revision:r})?n:null):{ok:false,reason:"unknown-drawing"}}async function nl(e,t,n,r,o,i,a,s){let l=await chunk5MWFZ7F4_cjs.Td(o,r,i,void 0,a);return l.ok?Ro(e,t,n,l.bytes,l.mime,a,{expectedPackageRevision:e.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function rl(e,t,n,r,o,i){let a=e.resolveStory(t);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let s=mt(e,a.store);return s||Ct(e,t,(l,d)=>{let c=Qs(e.currentPackage(),d,n),m=null;if(i!==null){let k=chunk5MWFZ7F4_cjs.Uf(e.currentPackage(),i,d);if(!k||!l.applyPackage(()=>k.pkg))return null;m=k.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&m!==null){if(!ko(l,d,n,m))return null}else if(i===null&&!ko(l,d,n,null))return null;let p=false;return l.applyPackage(k=>{let u=chunk5MWFZ7F4_cjs.Wf(k,d,c);return u===null?(p=true,k):u}),p?null:n})}function ol(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=mt(e,r.store);return o||Ct(e,t,(i,a)=>{let s=Qs(e.currentPackage(),a,n.drawingNodeId),l=null;if(n.hyperlink!==null){let c=chunk5MWFZ7F4_cjs.Uf(e.currentPackage(),n.hyperlink,a);if(!c||!i.applyPackage(()=>c.pkg))return null;l=c.relationshipId;}for(let c of n.ops)if(!i.apply(c))return null;if(!ko(i,a,n.drawingNodeId,n.hyperlink===null?null:l))return null;let d=false;return i.applyPackage(c=>{let m=chunk5MWFZ7F4_cjs.Wf(c,a,s);return m===null?(d=true,c):m}),d?null:n.drawingNodeId})}function Bc(e,t){if(e===t)return true;if(e.byteLength!==t.byteLength)return false;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return false;return true}function al(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e)if(t.get(n)!==r)return false;return true}function jc(e,t){return e===t||e.ownerPart===t.ownerPart&&e.id===t.id&&e.type===t.type&&e.rawTarget===t.rawTarget&&e.targetMode===t.targetMode&&e.order===t.order}function Hc(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e){let o=t.get(n);if(!o||o.length!==r.length||o!==r&&r.some((i,a)=>!jc(i,o[a])))return false}return true}function Vc(e,t){return e===t?true:e.length!==t.length?false:e.every((n,r)=>{let o=t[r];return n===o||n.ownerPart===o.ownerPart&&n.id===o.id&&n.type===o.type&&n.rawTarget===o.rawTarget&&n.sinkSafe===o.sinkSafe})}function Wc(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e){let o=t.get(n);if(!o||!Bc(r,o))return false}return true}function zc(e,t){return e.contentTypes===t.contentTypes||al(e.contentTypes.defaults,t.contentTypes.defaults)&&al(e.contentTypes.overrides,t.contentTypes.overrides)}var Jn=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),qn=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function il(e){for(let[t,n]of e)if(!chunk5MWFZ7F4_cjs.ua(t,n))return qn;return Jn}function Kc(e,t){if(e===t)return Jn;if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||!Wc(e.partBytes,t.partBytes)||!Hc(e.relationships,t.relationships)||!Vc(e.externalTargets,t.externalTargets)||!zc(e,t))return qn;let n=[];for(let[a,s]of e.parts){let l=t.parts.get(a);if(!l)return qn;s!==l&&n.push([s,l]);}if(n.length===0)return Jn;let[r,o]=n[0];if(n.length>1||r.name!==e.mainDocumentPart)return il(n);let i=chunk5MWFZ7F4_cjs.va(o.root,r.root);return i.undecided?il(n):i.equal?Jn:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?qn:{equal:false,dirty:i.paragraphIds,dependencyKeys:[chunk5MWFZ7F4_cjs.g.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function Po(e){return {ok:false,reason:"package-invariant",detail:e}}function Gc(e,t){if(!e.parts.get(e.mainDocumentPart))return Po("no-main-document");for(let[r,o]of e.parts){let i=t?.parts.get(r);if(i===o)continue;let a=i?chunk5MWFZ7F4_cjs.xa(i,o):chunk5MWFZ7F4_cjs.wa(o);if(!a.ok)return Po(`invalid-part:${r}:${a.issues[0]?.code??"invalid"}`)}let n=chunk5MWFZ7F4_cjs.ge(e);return n.ok?null:Po(n.issues[0]?.code??"package-invariant")}function sl(e,t,n){let r=e.currentPackage(),o=Kc(t,r);if(o.equal)return {ok:true,change:null};let i=Gc(t,r);if(i)return i;let a=e.bodyStore().part.name,s=o.impact!=="global"&&t.mainDocumentPart===a;return chunk5MWFZ7F4_cjs.Ea(e,()=>{let l=e.packageRevision;return e.installAuthoritativePackageSnapshot(t),{ok:true,change:e.publishStoryWrite({change:"model-change",fromRevision:l,toRevision:l+1,commitId:`pkg-remote-${l+1}`,origin:n.origin,...n.actorId?{actorId:n.actorId}:{},...n.operationId?{operationId:n.operationId}:{},dirty:s?o.dirty:[],created:[],deleted:[],splitJoin:[],dependencyKeys:s?o.dependencyKeys:[],impact:s?o.impact:"global",story:{kind:"body",partName:a}})}},()=>false)}function cl(e,t,n,r){let o=[...t],i=new Set;for(let a of o)e.parts.has(a)&&i.add(a);for(let a of n)ll(a,o,i);for(let a of r)ll(a,o,i);return i}function ml(e,t,n,r,o){let i=new Set(e);i.add(t),i.add(n);for(let a of r)dl(a,i);for(let a of o)dl(a,i);return i}function ll(e,t,n){if(e.kind==="story"){n.add(e.partName);return}for(let r of t)(e.before.parts.has(r)||e.after.parts.has(r))&&n.add(r);}function dl(e,t){if(e.kind==="story"){t.add(e.partName);return}for(let n of e.before.parts.keys())t.add(n);for(let n of e.after.parts.keys())t.add(n);}var ul=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),pl=new Set(["authorTable","deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]),fl=64,tn=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(t,n,r={}){this.pkg=chunk5MWFZ7F4_cjs.Xd(t,n),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??fl,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??chunk5MWFZ7F4_cjs.dh,this.body=new dt(this.pkg,n.name,{historyLimit:this.historyLimit,settingsPart:()=>chunk5MWFZ7F4_cjs.eg(this.pkg)}),this.body.setStoryRef({kind:"body",partName:n.name});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let t=this.currentPackageMemo;if(t&&t.pkg===this.pkg&&t.bodyPart===this.body.part){let o=0,i=true;for(let a of this.stories.values()){if(t.storyParts[o]!==a.part){i=false;break}o+=1;}if(i&&o===t.storyParts.length)return t.result}let n=chunk5MWFZ7F4_cjs.Xd(this.pkg,this.body.part),r=[];for(let o of this.stories.values())r.push(o.part),this.pkg.parts.has(o.part.name)&&(n=chunk5MWFZ7F4_cjs.Xd(n,o.part));return this.currentPackageMemo={pkg:this.pkg,bodyPart:this.body.part,storyParts:r,result:n},n}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}resolveStory(t){return t.kind==="body"?{ok:true,story:{kind:"body",partName:this.body.part.name},store:this.body}:t.kind==="notesPart"?t.noteKind!=="footnote"&&t.noteKind!=="endnote"?{ok:false,reason:"unknown-scope",detail:String(t.noteKind)}:this.openNotesPartStore(t.noteKind):t.kind!=="headerFooter"||typeof t.rId!="string"||t.rId.length===0?{ok:false,reason:"unknown-scope",detail:String(t.kind)}:this.openHeaderFooterStore(t.rId)}partFor(t){let n=this.resolveStory(t);return n.ok?n.store.part:null}revisionFor(t){let n=this.resolveStory(t);return n.ok?n.store.revision:null}transact(t,n,r={}){return chunk5MWFZ7F4_cjs.Ea(this,()=>this.commitStoryTransaction(t,n,r),chunk5MWFZ7F4_cjs.Fa,r.historyGroup)}commitStoryTransaction(t,n,r={}){let o=this.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let{store:i,story:a}=o,s=this.currentPackage(),l=i.historyDepth,d=i.compositionActive,c=i.checkpoint(),m=false,p=new Set,k=false,u=new Set,g=false,h,R=false,x;i.graftPackage(()=>this.currentPackage());let f=i.transact(v=>{x=Os(v),n({...v,applyTo:(y,T)=>{let N=v.applyTo(y,T);return N&&y!==a.partName&&(R=true),N},applyPackage:y=>v.applyPackage(T=>{let N=y(T);return N!==T&&!R&&(R=Ss(T,N,a.partName)),N}),apply:y=>(y.op==="setListNumbering"&&y.numId!==null&&(g=true),y.op==="setParagraphProperties"&&(h??=y.properties.find(T=>T.localName==="pStyle")?.attributes?.val),m||(y.op==="deleteText"&&Ws(this.pkg,i.part,y,p)||y.op==="deleteBlock"&&zs(this.pkg,i.part,y,p)||ul.has(y.op)||pl.has(y.op))&&(m=true),k||(y.op==="deleteText"||y.op==="deleteBlock"?k=Gs(this.pkg,i.part,y,u):(ul.has(y.op)||pl.has(y.op))&&(k=true)),v.apply(y)),...x.context});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!f.ok)return {ok:false,reason:f.reason,...f.detail?{detail:f.detail}:{}};this.syncPackageFromStore(i);let P=false;if(f.change&&R&&(this.installPackageSnapshotInternal(i.package,false),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),P=true),g&&h){let v=Es(this.pkg,h);v&&this.replacePackageShell(v);}let I=false;if(f.change&&m){let v=this.currentPackage(),y=this.cascadeNoteReferences(s,v);if(y===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};y!==v&&(this.installPackageSnapshotInternal(y),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),I=true);}if(f.change&&k){let v=this.currentPackage(),y=chunk5MWFZ7F4_cjs.qh(s,v,{storyPartName:a.partName});if(y===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};y!==v&&(this.installPackageSnapshotInternal(y),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),I=true);}if(f.change){this.packageRev+=1;let v=I||P;v&&chunk5MWFZ7F4_cjs.Lj(r.historyGroup,"split","package-unit"),!d&&r.recordsHistory!==false&&(i.historyDepth>l||v)&&(v?this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage(),...x?.snapshot(f.change.caret)}):this.pushUndoPointer({kind:"story",partName:a.partName,story:a}));let y=v?this.publishSynthetic(f.change.origin,"global",a,f.change.created):f.change;return v||this.publish(y),{ok:true,change:y}}return {ok:true,change:f.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(t,n=null){let r=this.resolveStory(t);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(t),!r.ok)?false:(this.compositionSession||(this.compositionSession={partName:r.story.partName,beforePackage:this.currentPackage(),storyCheckpoint:r.store.checkpoint(),packageWideEffects:false}),r.store.beginComposition(n),true)}endComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.endComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return;let r=n.historyDepth;if(n.endComposition(),t.packageWideEffects){n.restoreHistoryStacks(t.storyCheckpoint),this.syncPackageFromStore(n),this.pushUndoPointer({kind:"package",before:t.beforePackage,after:this.currentPackage()});return}if(n.historyDepth>r){let o=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);o&&this.pushUndoPointer({kind:"story",partName:t.partName,story:o});}this.syncPackageFromStore(n);}cancelComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.cancelComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(t.packageWideEffects){n&&n.restoreCheckpoint(t.storyCheckpoint),this.installPackageSnapshotInternal(t.beforePackage),this.packageRev+=1;let r=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);this.publishSynthetic(chunk5MWFZ7F4_cjs.b.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(t){return chunk5MWFZ7F4_cjs.Ea(this,()=>this.commitLifecycleOp(t),chunk5MWFZ7F4_cjs.Fa)}commitLifecycleOp(t){let n=this.currentPackage(),r=chunk5MWFZ7F4_cjs.Ui(chunk5MWFZ7F4_cjs.eg(n),t);if(r)return {ok:false,reason:r};if(chunk5MWFZ7F4_cjs.bh(t)){let s=chunk5MWFZ7F4_cjs.ch(n,t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};if(s.package===n)return {ok:true,change:null};this.installPackageSnapshotInternal(s.package),this.pushUndoPointer({kind:"package",before:n,after:s.package}),this.packageRev+=1;let l={kind:"body",partName:this.body.part.name},d=this.publishSynthetic(chunk5MWFZ7F4_cjs.b.mutationHuman,s.impact,l,s.createdPartName?[s.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:d}}if(!chunk5MWFZ7F4_cjs.Zf(t))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let o=chunk5MWFZ7F4_cjs._f(n,t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};this.installPackageSnapshotInternal(o.package),this.pushUndoPointer({kind:"package",before:n,after:o.package}),this.packageRev+=1;let i={kind:"body",partName:this.body.part.name},a=this.publishSynthetic(chunk5MWFZ7F4_cjs.b.mutationHuman,o.impact,i,o.createdPartName?[o.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:a}}undo(){let t=this.undoOrder.pop();if(!t)return null;if(chunk5MWFZ7F4_cjs.Jj(this.body,this.stories,null),t.kind==="package"){this.installPackageSnapshotInternal(t.before,true,t.restoreNumbering),this.redoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(chunk5MWFZ7F4_cjs.b.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.undo();return r?(this.redoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let t=this.redoOrder.pop();if(!t)return null;if(chunk5MWFZ7F4_cjs.Jj(this.body,this.stories,null),t.kind==="package"){this.installPackageSnapshotInternal(t.after,true,t.restoreNumbering),this.undoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(chunk5MWFZ7F4_cjs.b.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.redo();return r?(this.undoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){return po(this.undoOrder.at(-1),this.body,this.stories,"undo")}selectionForRedo(){return po(this.redoOrder.at(-1),this.body,this.stories,"redo")}openStoryParts(){return fo(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return bs(this.stories,this.pkg)}insertImage(t,n){return Zs(this,t,n)}applyFragmentPaste(t,n){return uo(this,t,n)}replaceImage(t,n,r,o,i,a){return Ro(this,t,n,r,o,i,a)}deleteImage(t,n){return el(this,t,n)}deleteImageTracked(t,n,r){return tl(this,t,n,r)}embedExternalImage(t,n,r,o,i,a,s){return nl(this,t,n,r,o,i,a,s)}setDrawingMetadataWithHyperlink(t,n,r,o,i){return rl(this,t,n,r,o,i)}applyImageProperties(t,n){return ol(this,t,n)}promoteStoryTransactionToPackageUnit(t,n,r,o){this.installPackageSnapshotInternal(n.package,false),n.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:t,after:this.currentPackage()}),this.packageRev+=1;let i=n.part.name===this.body.part.name?{kind:"body",partName:n.part.name}:this.storyRefForPart(n.part.name);return this.publishSynthetic(chunk5MWFZ7F4_cjs.b.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(t){return t?(this.packageRev+=1,this.publish(t),t):null}adoptPackageUnit(t){let n=this.currentPackage();t!==n&&this.pushUndoPointer({kind:"package",before:t,after:n});}installPackageSnapshot(t){this.installPackageSnapshotInternal(t);}installAuthoritativePackageSnapshot(t){this.installPackageSnapshotInternal(t,false);}publishRemotePackage(t,n){return sl(this,t,n)}replacePackageShell(t){this.shellHyperlinks=_s(this.shellHyperlinks,this.pkg,t);let n=t;n=chunk5MWFZ7F4_cjs.Xd(n,this.body.part);for(let r of this.stories.values())t.parts.has(r.part.name)&&(n=chunk5MWFZ7F4_cjs.Xd(n,r.part));this.pkg=n;}installPackageSnapshotInternal(t,n=true,r=false){let o=n?Ls(t,this.pkg,this.shellHyperlinks,r):t,i=o.parts.get(o.mainDocumentPart);if(!i)return;this.body.replacePart(i);for(let[s,l]of this.stories){let d=o.parts.get(s);d&&l.replacePart(d);}this.rIdToPartName.clear();let a=o.relationships.get(o.mainDocumentPart)??[];for(let s of a){if(s.type!==yo&&s.type!==xo)continue;let l=chunk5MWFZ7F4_cjs.E(s);l.mode!=="Internal"||!l.target.ok||this.stories.has(l.target.partName)&&o.parts.has(l.target.partName)&&this.rIdToPartName.set(s.id,l.target.partName);}this.pkg=o,this.pkg=chunk5MWFZ7F4_cjs.Xd(this.pkg,this.body.part);for(let s of this.stories.values())this.pkg.parts.has(s.part.name)&&(this.pkg=chunk5MWFZ7F4_cjs.Xd(this.pkg,s.part));}openNotesPartStore(t){let n=chunk5MWFZ7F4_cjs.pg(this.currentPackage(),t);if(!n)return {ok:false,reason:"missing-part",detail:t};let r=this.stories.get(n.name);if(r)return {ok:true,story:{kind:"notesPart",partName:n.name,noteKind:t},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=chunk5MWFZ7F4_cjs.eb(n),i=new dt(o,{historyLimit:this.historyLimit,settingsPart:()=>chunk5MWFZ7F4_cjs.eg(this.pkg)}),a={kind:"notesPart",partName:o.name,noteKind:t};return i.setStoryRef(a),this.stories.set(o.name,i),o!==n&&(this.pkg=chunk5MWFZ7F4_cjs.Xd(this.pkg,o)),{ok:true,story:a,store:i}}openHeaderFooterStore(t){let n=this.rIdToPartName.get(t);if(n){let l=this.stories.get(n);if(l)return {ok:true,story:{kind:"headerFooter",partName:n,rId:t},store:l}}let r=Xs(this.currentPackage(),t);if(!r.ok)return r;let o=this.stories.get(r.partName);if(o)return this.rIdToPartName.set(t,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:t},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=chunk5MWFZ7F4_cjs.eb(r.part),a=new dt(i,{historyLimit:this.historyLimit,settingsPart:()=>chunk5MWFZ7F4_cjs.eg(this.pkg)}),s={kind:"headerFooter",partName:i.name,rId:t};return a.setStoryRef(s),this.stories.set(i.name,a),this.rIdToPartName.set(t,i.name),i!==r.part&&(this.pkg=chunk5MWFZ7F4_cjs.Xd(this.pkg,i)),{ok:true,story:s,store:a}}storyRefForPart(t){if(t===this.body.part.name)return {kind:"body",partName:t};for(let[r,o]of this.rIdToPartName)if(o===t)return {kind:"headerFooter",partName:t,rId:r};let n=this.currentPackage().parts.get(t);return n?.root.localName==="footnotes"?{kind:"notesPart",partName:t,noteKind:"footnote"}:n?.root.localName==="endnotes"?{kind:"notesPart",partName:t,noteKind:"endnote"}:null}syncPackageFromStore(t){this.pkg=chunk5MWFZ7F4_cjs.Xd(this.pkg,t.part);}pushUndoPointer(t){chunk5MWFZ7F4_cjs.Jj(this.body,this.stories,t),t.kind==="package"&&t.before.parts.get("/word/numbering.xml")!==t.after.parts.get("/word/numbering.xml")&&(t={...t,restoreNumbering:true}),this.undoOrder.push(t),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let t=cl(this.pkg,this.stories.keys(),this.undoOrder,this.redoOrder);for(let[o]of [...this.stories])if(!t.has(o)){this.stories.delete(o);for(let[i,a]of [...this.rIdToPartName])a===o&&this.rIdToPartName.delete(i);}let n=ml(t,this.pkg.mainDocumentPart,this.body.part.name,this.undoOrder,this.redoOrder),r=$s(this.pkg,n);r!==this.pkg&&(this.pkg=r),this.shellHyperlinks=Fs(this.shellHyperlinks,n,this.pkg.mainDocumentPart);}publish(t){this.lastChange=t;for(let n of this.subscribers)n(t);}publishSynthetic(t,n,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:t,dirty:[],created:[...o],deleted:[],splitJoin:[],dependencyKeys:[],impact:n,story:r};return this.publish(a),a}};var Xc=256,Yc=65535,gl=64;function Qn(e,t){return e.length>t}function hl(e){return typeof e!="string"||e.trim().length===0?"invalid-author":Qn(e,Xc)?"resource-limit":chunk5MWFZ7F4_cjs.O(e)?null:"invalid-author"}function yl(e){return typeof e!="string"||e.length===0?"invalid-text":Qn(e,Yc)?"resource-limit":chunk5MWFZ7F4_cjs.O(e)?null:"invalid-text"}function vo(e){if(typeof e!="string")return {ok:false,rejection:"invalid-date"};let t=e.trim();if(Qn(t,gl))return {ok:false,rejection:"resource-limit"};if(!chunk5MWFZ7F4_cjs.O(t))return {ok:false,rejection:"invalid-date"};let n=chunk5MWFZ7F4_cjs.hf(t);return n===null?{ok:false,rejection:"invalid-date"}:Qn(n,gl)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function ch(e){if(e===void 0)return null;let t=vo(e);return t.ok?null:t.rejection}function Io(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 Jc(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Oo(e,t){if(!e){let a=chunk5MWFZ7F4_cjs.yb(t);return a?chunk5MWFZ7F4_cjs.Ab(new Set,a,chunk5MWFZ7F4_cjs.vb):"0"}let n=-1,r=new Set,o=a=>{if(a.kind!=="textValue"){if(a.kind==="comment"){let s=Jc(a,chunk5MWFZ7F4_cjs.fa,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=chunk5MWFZ7F4_cjs.vb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of a.children)o(s);}};o(e.root);let i=chunk5MWFZ7F4_cjs.yb(t);return i?chunk5MWFZ7F4_cjs.Ab(r,i,chunk5MWFZ7F4_cjs.vb):String(n+1)}function xl(e,t){if(e.kind==="textValue")return e;let n=t.get(e.id);if(n!==void 0)return n;let r=false,o=[];for(let i of e.children){let a=xl(i,t);a!==i&&(r=true),o.push(a);}return r?{...e,children:o}:e}function Zc(e,t,n){let r=xl(e.root,t);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:e.root.id,nodeId:e.root.id}]};let o=n===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:n,namespaceUri:chunk5MWFZ7F4_cjs.ia}]};return chunk5MWFZ7F4_cjs.Oa(e,e.root.id,o,{deferValidation:true})}function kl(e,t,n){let r=new Map;for(let i of t){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 s=o.parts.get(i);if(!s)return null;let l=chunk5MWFZ7F4_cjs.ab(s.root),d=l??"w14",c=new Map;for(let p of a.values())c.set(p.paragraph.id,n(p.paragraph,p.paraId,d));let m=Zc(s,c,l===null?d:null);if(!m.ok)return null;o=chunk5MWFZ7F4_cjs.Xd(o,m.part);}return o}function Rl(e,t,n){let r=e.root.children.map(o=>o.kind==="textValue"?o:t.get(o.id)??o);return chunk5MWFZ7F4_cjs.Ma(e,e.root.id,[...r,...n],{deferValidation:true})}var Il="/word/comments.xml",Ol="/word/commentsExtended.xml",Eo="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",To="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",em=[To,"application/vnd.ms-word.commentsExtended+xml"],bl="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Co="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",qe="http://schemas.microsoft.com/office/word/2012/wordml";function rn(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Mt(e,t){return {kind:"genericExtension",namespaceUri:chunk5MWFZ7F4_cjs.fa,localName:e,prefix:"w",value:t}}function ze(e,t,n,r,o,i,a,s=[]){return {id:e,kind:t,namespaceUri:n,localName:o,prefix:r,namespaceBindings:s,attributes:i,children:a}}function Sl(e,t,n,r,o){let i=t===e.mainDocumentPart?[t]:[t,e.mainDocumentPart];for(let a of i)for(let s of chunk5MWFZ7F4_cjs.Zd(e,a)){if(s.type!==n)continue;let l=chunk5MWFZ7F4_cjs.w(a,s.rawTarget);if(!l.ok)continue;if(!e.parts.has(l.partName))return l.partName;let d=chunk5MWFZ7F4_cjs._d(e,l.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return l.partName}return o}function bo(e,t,n){let r=e.mainDocumentPart;for(let i of chunk5MWFZ7F4_cjs.Zd(e,r)){if(i.type!==t)continue;let a=chunk5MWFZ7F4_cjs.w(r,i.rawTarget);if(a.ok&&a.partName===n)return e}let o=chunk5MWFZ7F4_cjs.de(e,r);return chunk5MWFZ7F4_cjs.ee(o,r,t,chunk5MWFZ7F4_cjs.Dh(r,n)).pkg}function Mo(e,t){return Sl(e,t,bl,Eo,Il)}function wl(e,t){let n=chunk5MWFZ7F4_cjs.mb(e,t),r=chunk5MWFZ7F4_cjs.nb(e,t,n).extended;return r!==null?r:Sl(e,t,Co,em,Ol)}function Pl(e){let t=new Set;for(let n of e.parts.values())for(let r of chunk5MWFZ7F4_cjs.$a(n.root))t.add(r);return t}function tm(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&rn(o,chunk5MWFZ7F4_cjs.fa,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind!=="paragraph")continue;let s=rn(a,chunk5MWFZ7F4_cjs.ia,"paraId");s!==void 0&&chunk5MWFZ7F4_cjs.Xa(s)&&(n=s.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(e.root),n}function nm(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&rn(o,chunk5MWFZ7F4_cjs.fa,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind==="paragraph"){n=a;return}}return}for(let i of o.children)r(i);}};return r(e.root),n}function Nl(e){let t=chunk5MWFZ7F4_cjs.ab(e.root);if(t!==null)return {part:e,prefix:t};let n={...e.root,namespaceBindings:[...e.root.namespaceBindings,{prefix:"w14",namespaceUri:chunk5MWFZ7F4_cjs.ia}]},r=chunk5MWFZ7F4_cjs.Oa(e,e.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(chunk5MWFZ7F4_cjs.La(e.root,n),{part:{...e,root:n},prefix:"w14"})}function El(e,t,n){return ze(e.id,"paragraph",e.namespaceUri,e.prefix??"w",e.localName,[...e.attributes.filter(r=>!(r.namespaceUri===chunk5MWFZ7F4_cjs.ia&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:chunk5MWFZ7F4_cjs.ia,localName:"paraId",prefix:n,value:t}],e.children,e.namespaceBindings)}function rm(e,t,n,r){let o=e.parts.get(t);if(!o)return e;let i=Nl(o),a=chunk5MWFZ7F4_cjs.Ja(i.part,n);if(!a||a.kind!=="paragraph")return chunk5MWFZ7F4_cjs.Xd(e,i.part);let s=chunk5MWFZ7F4_cjs.Oa(i.part,a.id,El(a,r,i.prefix),{deferValidation:true});return chunk5MWFZ7F4_cjs.Xd(e,s.ok?s.part:i.part)}function om(e,t,n,r){let o=`${Il}#comment-${e}`,i=n.text!==n.text.trim(),a=ze(`${o}.t`,"text",chunk5MWFZ7F4_cjs.fa,"w","t",i?[{kind:"xmlSpace",namespaceUri:chunk5MWFZ7F4_cjs.ga,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=ze(`${o}.rPr`,"runProperties",chunk5MWFZ7F4_cjs.fa,"w","rPr",[],[ze(`${o}.rStyle`,"generic",chunk5MWFZ7F4_cjs.fa,"w","rStyle",[Mt("val","CommentReference")],[])]),l=ze(`${o}.r`,"run",chunk5MWFZ7F4_cjs.fa,"w","r",[],[s,a]),d=ze(`${o}.pPr`,"paragraphProperties",chunk5MWFZ7F4_cjs.fa,"w","pPr",[],[ze(`${o}.pStyle`,"generic",chunk5MWFZ7F4_cjs.fa,"w","pStyle",[Mt("val","CommentText")],[])]),c=ze(`${o}.p`,"paragraph",chunk5MWFZ7F4_cjs.fa,"w","p",[{kind:"genericExtension",namespaceUri:chunk5MWFZ7F4_cjs.ia,localName:"paraId",prefix:r,value:t}],[d,l]);return ze(o,"comment",chunk5MWFZ7F4_cjs.fa,"w","comment",[Mt("id",e),Mt("author",n.author),...n.initials===void 0?[]:[Mt("initials",n.initials)],...n.date===void 0?[]:[Mt("date",n.date)]],[c])}function So(e,t){let n=chunk5MWFZ7F4_cjs.za(t,{name:e,contentType:"application/xml"});return n.ok?n.part.root:null}function Ao(e,t){for(let R of [hl(t.author),yl(t.text)])if(R)return {ok:false,reason:Io(R)};let n;if(t.date!==void 0){let R=vo(t.date);if(!R.ok)return {ok:false,reason:Io(R.rejection)};n=R.value;}let r={...t,...n===void 0?{}:{date:n}},o=e.package,i=e.part.name,a=Mo(o,i),s=wl(o,i),l=o.parts.get(a),d=Oo(l,r.actorId),c=chunk5MWFZ7F4_cjs._a(`${a}#${d}`,Pl(o)),m=t.replyToCommentId===void 0?null:tm(l,t.replyToCommentId),p=t.replyToCommentId!==void 0&&m===null?nm(l,t.replyToCommentId):null;if(t.replyToCommentId!==void 0&&m===null&&!p)return {ok:false,reason:"unknown-revision"};let k=p?chunk5MWFZ7F4_cjs._a(`${a}#parent-${t.replyToCommentId}`,new Set([...Pl(o),c])):null,u=m??k,g=t.anchor.endParagraphId??t.anchor.paragraphId,h=e.transact(R=>{let x=Zt(R);x.applyPackage(f=>{let P=f.parts.has(a)?f:(()=>{let I=So(a,`<w:comments xmlns:w="${chunk5MWFZ7F4_cjs.fa}"/>`);return I?chunk5MWFZ7F4_cjs.fe(f,a,I,Eo):null})();return P===null?f:bo(P,bl,a)}),p&&k&&x.applyPackage(f=>rm(f,a,p.id,k)),x.applyPackage(f=>{let P=f.parts.get(a);if(!P)return f;let I=Nl(P),v=chunk5MWFZ7F4_cjs.Na(I.part,I.part.root.id,I.part.root.children.length,[om(d,c,r,I.prefix)],{deferValidation:true});return v.ok?chunk5MWFZ7F4_cjs.Xd(f,v.part):f}),u!==null&&(x.applyPackage(f=>{let P=f.parts.has(s)?f:(()=>{let I=So(s,`<w15:commentsEx xmlns:w15="${qe}"/>`);return I?chunk5MWFZ7F4_cjs.fe(f,s,I,To):null})();return P===null?f:bo(P,Co,s)}),x.applyPackage(f=>{let P=f.parts.get(s);if(!P)return f;let v=[...am(P).has(u.toUpperCase())?[]:[No(`${s}#ex-${u}`,u,void 0,false)],No(`${s}#ex-${c}`,c,u,false)],y=chunk5MWFZ7F4_cjs.Na(P,P.root.id,P.root.children.length,v,{deferValidation:true});return y.ok?chunk5MWFZ7F4_cjs.Xd(f,y.part):f})),x.applyTo(i,{op:"insertCommentMarker",paragraphId:g,offset:t.anchor.end,commentId:d,marker:"reference"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:g,offset:t.anchor.end,commentId:d,marker:"end"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:t.anchor.paragraphId,offset:t.anchor.start,commentId:d,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return h.ok?{ok:true,commentId:d,change:h.change}:{ok:false,reason:h.reason}}function wo(e){for(let t=e.children.length-1;t>=0;t-=1){let n=e.children[t];if(n.kind==="paragraph")return n}return null}function vl(e){let t=wo(e);if(!t)return null;let n=rn(t,chunk5MWFZ7F4_cjs.ia,"paraId");return n!==void 0&&chunk5MWFZ7F4_cjs.Xa(n)?n.toUpperCase():null}function am(e){let t=new Map;if(!e)return t;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===qe&&r.localName==="commentEx"){let o=rn(r,qe,"paraId");o!==void 0&&chunk5MWFZ7F4_cjs.Xa(o)&&t.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(e.root),t}function nn(e,t){return {kind:"genericExtension",namespaceUri:qe,localName:e,prefix:"w15",value:t}}function im(e,t){return {id:e.id,kind:"generic",namespaceUri:e.namespaceUri,localName:e.localName,...e.prefix===void 0?{}:{prefix:e.prefix},namespaceBindings:e.namespaceBindings,attributes:t,children:e.children}}function sm(e,t,n){let r=[],o=false,i=false;for(let a of e.attributes){if(a.namespaceUri===qe&&a.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:a.namespaceUri,localName:a.localName,...a.prefix===void 0?{}:{prefix:a.prefix},value:n?"1":"0"});continue}a.namespaceUri===qe&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&t!==void 0&&r.push(nn("paraIdParent",t)),o||r.push(nn("done",n?"1":"0")),im(e,r)}function No(e,t,n,r){return {id:e,kind:"generic",namespaceUri:qe,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[nn("paraId",t),...n===void 0?[]:[nn("paraIdParent",n)],nn("done",r?"1":"0")],children:[]}}function Do(e,t,n){return lm(e,t,n,chunk5MWFZ7F4_cjs.lb())}function lm(e,t,n,r){let o=e.package,i=e.part.name;if(chunk5MWFZ7F4_cjs.mb(o,i)===null)return {ok:false,reason:"unknown-comment"};let s=chunk5MWFZ7F4_cjs.fh(o,t,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=chunk5MWFZ7F4_cjs.ob(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=l.used,c=new Map,m=[];for(let g of s.ids){let h=s.records.get(g);if(!h)return {ok:false,reason:"unknown-comment"};if(!wo(h.node))return {ok:false,reason:"unknown-comment"};let x=vl(h.node),f=x??chunk5MWFZ7F4_cjs._a(`${h.partName}#done-${g}`,d);x===null&&d.add(f),c.set(g,f);}for(let g of s.ids){let h=s.records.get(g),R=wo(h.node),x=c.get(g),f=vl(h.node),P=s.parentCommentIdByChildId.get(g),I=s.parentParaIdByCommentId.get(g)??(P===void 0?void 0:c.get(P)),v=s.commentExByParaId.get(x);m.push({paraId:x,stampParagraph:f===null?R:null,commentsPartName:h.partName,parentParaId:I,existing:v?.node,existingParentParaId:v?.parentParaId,existingDone:v?.done??false});}if(m.length===0)return {ok:false,reason:"unknown-comment"};if(m.every(g=>g.existingDone===n))return {ok:true,changed:false,change:null};let p=s.extendedPartName??Ol,k=s.extendedPartName===null,u=e.transact(g=>{Zt(g).applyPackage(R=>{let x=kl(R,m,El);if(x===null)return R;let f=x;if(!f.parts.has(p)){let T=So(p,`<w15:commentsEx xmlns:w15="${qe}"/>`);if(!T)return R;let N=chunk5MWFZ7F4_cjs.fe(f,p,T,To);f=k?bo(N,Co,p):N;}let P=f.parts.get(p);if(!P)return R;let I=new Map,v=[];for(let T of m){let N=T.existingParentParaId??T.parentParaId;T.existing?I.set(T.existing.id,sm(T.existing,N,n)):v.push(No(`${p}#done-${T.paraId}`,T.paraId,N,n));}let y=Rl(P,I,v);return y.ok?chunk5MWFZ7F4_cjs.Xd(f,y.part):R});});return u.ok?{ok:true,changed:true,change:u.change}:{ok:false,reason:u.reason}}function dm(e,t){let n=Mo(e,t);return e.parts.has(n)&&chunk5MWFZ7F4_cjs._d(e,n)===Eo}function cm(e,t){return Mo(e,t)}function mm(e,t){return wl(e,t)}var Tl={kind:"body"};function um(e,t,n=Tl){let r=n.kind==="body"?null:e.resolveStory(n),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),chunk5MWFZ7F4_cjs.Ea(e,()=>{let s=Ao(o,t);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>chunk5MWFZ7F4_cjs.Fa(s))}function pm(e,t,n){let r=e.bodyStore(),o=e.currentPackage(),i=chunk5MWFZ7F4_cjs.Ui(chunk5MWFZ7F4_cjs.eg(o),{op:"setCommentResolved"});if(i)return {ok:false,reason:i};let a=r.checkpoint();return r.graftPackage(()=>e.currentPackage()),chunk5MWFZ7F4_cjs.Ea(e,()=>{let s=Do(r,t,n);return !s.ok||!s.changed||(r.restoreHistoryStacks(a),e.replacePackageShell(r.package),e.adoptPackageUnit(o),e.publishStoryWrite(s.change)),s},s=>s.ok&&s.changed)}function fm(e,t,n=Tl,r){if(t.length===0||chunk5MWFZ7F4_cjs.Ui(chunk5MWFZ7F4_cjs.eg(e.currentPackage()),{op:"deleteComments"}))return false;let o=n.kind==="body"?e.bodyStore().part:e.partFor(n);if(!o)return false;let i={storyPartName:o.name,...r===void 0?{}:{noteId:r}},a=e.bodyStore(),s=e.currentPackage(),l=a.checkpoint();return a.graftPackage(()=>e.currentPackage()),chunk5MWFZ7F4_cjs.Ea(e,()=>{let d=false,c=false,m=a.transact(p=>{Zt(p).applyPackage(u=>{let g=u;for(let h of t){let R=h.parentCommentId===void 0?chunk5MWFZ7F4_cjs.oh(g,h.commentId,i):chunk5MWFZ7F4_cjs.ph(g,h.commentId,h.parentCommentId,i);if(R===null)return d=true,u;c||=R!==g,g=R;}return g});});return d||!m.ok||!c?false:(a.restoreHistoryStacks(l),e.installPackageSnapshot(a.package),e.adoptPackageUnit(s),e.publishStoryWrite(m.change),true)},d=>d)}var Ml=256*1024,Al=4096;function _o(e,t,n){let r=t.payload,o=e.part.name,i=n??o;if(r){if(r.data.length>Ml)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>Al)return {ok:false,reason:"payload-too-large",detail:"label"}}let a=new Set(chunk5MWFZ7F4_cjs.Qb(e.part.root).map(p=>p.node.id)),s=t.replaceControlId===void 0?[]:Dl(e,o,t.replaceControlId),l=null,d,c=e.transact(p=>{if(t.replaceControlId!==void 0){p.apply({op:"removeContentControl",controlId:t.replaceControlId,keepContent:false});for(let g of s)p.applyPackage(h=>chunk5MWFZ7F4_cjs.Lh(h,g.partName,g.nodeId));}let k=t.replaceUntil;if(k!==void 0&&k<=t.offset){l="invalid-range",d="replaceUntil must be past offset";return}if(k!==void 0&&p.apply({op:"deleteText",paragraphId:t.paragraphId,start:t.offset,end:k}),!r){p.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock}});return}let u=null;p.applyPackage(g=>{let h=chunk5MWFZ7F4_cjs.Gh(g,i,r.namespaceUri,r.rootLocalName);if(!h.part)return l="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,g;if(u=chunk5MWFZ7F4_cjs.Qh(h.part,r.rootLocalName,r.nodeId),!u)return l="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,g;let R=chunk5MWFZ7F4_cjs.Kh(h.pkg,h.part.partName,{id:r.nodeId,label:r.label,data:r.data});return chunk5MWFZ7F4_cjs.Jh(R,h.part.partName,r.nodeId)?R:(l="store-not-authored",d="the payload node could not be written into the store",g)}),!(l!==null||!u)&&p.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock},dataBinding:u});});if(l!==null)return {ok:false,reason:l,...d===void 0?{}:{detail:d}};if(!c.ok)return {ok:false,reason:c.reason,...c.detail===void 0?{}:{detail:c.detail}};let m=gm(e,a);return {ok:true,change:c.change,...m===void 0?{}:{nodeId:m}}}function gm(e,t){for(let n of chunk5MWFZ7F4_cjs.Qb(e.part.root))if(!t.has(n.node.id))return n.node.id}function Dl(e,t,n){let r=chunk5MWFZ7F4_cjs.Qb(e.part.root).find(i=>i.node.id===n);if(!r)return [];let o=[];for(let i of chunk5MWFZ7F4_cjs.Eh(e.package,t)){let a=chunk5MWFZ7F4_cjs.Th(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function Fo(e,t){let n=e.part.name,r=Dl(e,n,t),o=e.transact(i=>{i.apply({op:"removeContentControl",controlId:t,keepContent:false});for(let a of r)i.applyPackage(s=>chunk5MWFZ7F4_cjs.Lh(s,a.partName,a.nodeId));});return o.ok?{ok:true,change:o.change}:{ok:false,reason:o.reason,...o.detail===void 0?{}:{detail:o.detail}}}function hm(e,t,n){if(!e.parts.has(t)||n.length===0)return {ok:true,pkg:e,removed:[]};let r=e,o=[];for(let i of n){let a=chunk5MWFZ7F4_cjs.Fh(r,t,i);if(!a)continue;let s=chunk5MWFZ7F4_cjs.Sh(r,a.itemId),l=chunk5MWFZ7F4_cjs.Mh(r,a.partName,s);if(l.pkg===r&&chunk5MWFZ7F4_cjs.Ih(r,a.partName).some(d=>!s.has(d.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=l.pkg,o.push(...l.removed);}return {ok:true,pkg:r,removed:o}}var Cl=new WeakMap;function ym(e,t){let n=Cl.get(e);n||(n=new Map,Cl.set(e,n));let r=n.get(t);if(r)return r;let o=chunk5MWFZ7F4_cjs.Eh(e,t).map(i=>({itemId:i.itemId,nodes:new Map(chunk5MWFZ7F4_cjs.Ih(e,i.partName).map(a=>[a.id,a]))}));return n.set(t,o),o}function xm(e,t,n=t){let r=new Map,o=e.parts.get(t);if(!o)return r;let i=ym(e,n);if(i.length===0)return r;for(let a of chunk5MWFZ7F4_cjs.Qb(o.root))for(let s of i){let l=chunk5MWFZ7F4_cjs.Th(a.node,s.itemId);if(l===null)continue;let d=s.nodes.get(l);if(d){r.set(a.node.id,{nodeId:l,label:d.label,data:d.data});break}}return r}function km(e,t,n){let r=new Map,o=chunk5MWFZ7F4_cjs.Fh(e,t,n);if(!o)return r;for(let i of chunk5MWFZ7F4_cjs.Ih(e,o.partName))r.set(i.id,{label:i.label,data:i.data});return r}var _l={kind:"body"};function Fl(e,t,n){let r=t.kind==="body"?null:e.resolveStory(t),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),chunk5MWFZ7F4_cjs.Ea(e,()=>{let s=n(o);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>chunk5MWFZ7F4_cjs.Fa(s))}function Rm(e,t,n=_l){return Fl(e,n,r=>_o(r,t,e.bodyStore().part.name))}function Pm(e,t,n=_l){return Fl(e,n,r=>Fo(r,t))}var $l=new WeakMap;function Pe(e,t){return $l.set(e,t),e}function q(e){return $l.get(e)??[]}function on(e){return `${e.kind}-${e.id}`}function Lo(e){return e.kind==="revision"?e.ranges:e.range?[e.range]:[]}function Ul(e){return Lo(e)[0]??null}function At(e,t){let n=Ul(e);if(!n)return Number.MAX_SAFE_INTEGER;let r=t.get(n.start.paragraphId);return r===void 0?Number.MAX_SAFE_INTEGER:r*1e6+Math.min(n.start.offset,999999)}function vm(e,t){let n=t.get(e.start.paragraphId),r=t.get(e.end.paragraphId);return n===void 0||r===void 0?Number.MAX_SAFE_INTEGER:(r-n)*1e6+(e.end.offset-e.start.offset)}var Im=0,Om=1,bm=2;function Sm(e,t,n){let r=n.get(t.paragraphId),o=n.get(e.start.paragraphId),i=n.get(e.end.paragraphId);return r===void 0||o===void 0||i===void 0||r<o||r>i||r===o&&t.offset<e.start.offset||r===i&&t.offset>e.end.offset?null:o===i&&e.start.offset===e.end.offset?Im:r===i&&t.offset===e.end.offset?bm:Om}function wm(e,t,n){let r=null;for(let o of Lo(e)){let i=Sm(o,t,n);if(i===null)continue;let a=vm(o,n);(r===null||i<r.grip||i===r.grip&&a<r.width)&&(r={grip:i,width:a});}return r}var Ll={comment:0,custom:1,revision:2};function Nm(e,t,n){let r=[];for(let o of e){let i=wm(o,t,n);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?Ll[o.item.kind]-Ll[i.item.kind]:o.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-o.item.nesting:0).map(o=>o.item)}function Zh(e,t,n){let o=Nm(e,t,n).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return o?o.kind==="comment"?Bl(e,o):o:null}function ey(e,t){return Bl(e,t)}function Bl(e,t){let n=new Map,r=new Map;for(let a of e)a.kind==="comment"?n.set(a.id,a):a.kind==="revision"&&r.set(a.id,a);let o=new Set([t.id]),i=t;for(;i.parentId!==void 0;){let a=n.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}function jl(e){let t=[],n=r=>{if(r.kind==="textValue"){t.push(r.value);return}for(let o of r.children)n(o);};for(let r of e.blocks)n(r);return t.join("")}function Hl(e){if(e.initials&&e.initials.trim().length>0)return e.initials.trim();let t=e.author.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function ut(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return chunk5MWFZ7F4_cjs.tb(e);if(chunk5MWFZ7F4_cjs.Be(e))return "";let t="";for(let n of e.children)t+=ut(n);return t}var Dt=(e,t)=>e.kind!=="textValue"&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa&&e.localName===t;function Vl(e,t,n){let r=new Set(["tcPrChange","trPrChange","tblPrExChange","tblGridChange","tblPrChange"]),o=new Map(n.filter(g=>g.propertyChange&&r.has(g.node.localName)).map(g=>[g.node.id,g]));if(!o.size)return [...t];let i=chunk5MWFZ7F4_cjs.si(e,n).tableHistories,a=[],s=new Map,l=g=>g.node.attributes.find(h=>h.namespaceUri===chunk5MWFZ7F4_cjs.fa&&h.localName==="author")?.value??"",d=(g,h)=>{if(g.kind==="textValue"||Dt(g,"tbl"))return;let R=o.get(g.id);R&&h.push(R);for(let x of g.children)d(x,h);},c=g=>{if(g.kind!=="textValue"){if(Dt(g,"tbl")){let h,R=[],x=[],f=[],P=false;for(let v of g.children){if(Dt(v,"tblGrid")&&d(v,x),Dt(v,"tblPr")&&d(v,f),!Dt(v,"tr"))continue;let y=[];if(d(v,y),P||=y.some(N=>N.refused),!y.length||y.some(N=>N.refused)){h=void 0;continue}let T=l(y[y.length-1]);(!h||h.author!==T)&&(h={ids:new Set,author:T,tableId:g.id},a.push(h),R.push(h));for(let N of y)h.ids.add(N.node.id);}let I=R.at(-1);if(I&&!P&&x.every(v=>!v.refused)){for(let v of x)I.ids.add(v.node.id);if(R.length===1&&x.length>0)for(let v of f){let y=v.node.children.find(T=>Dt(T,"tblPr"));!v.refused&&v.parent?.kind==="tableProperties"&&y&&l(v)===I.author&&(i.has(v.node.id)||chunk5MWFZ7F4_cjs.ua({...v.parent,children:v.parent.children.filter(T=>T.id!==v.node.id)},y))&&I.ids.add(v.node.id);}}}for(let h of g.children)c(h);}};c(e.root);for(let g of a)for(let h of g.ids)s.set(h,g);let m=new Set;for(let g of t){let R=q(g).map(x=>s.get(x));if(R.some(x=>x!==R[0]))for(let x of R)x&&m.add(x.tableId);}for(let g of a)if(m.has(g.tableId))for(let h of g.ids)o.get(h)?.node.localName==="tblGridChange"&&(g.ids.delete(h),s.delete(h));let p=new Map;for(let g of t){let h=q(g),R=h.length?s.get(h[0]):void 0;if(!R||g.readOnly||g.revisionKind!=="format"||!h.every(f=>s.get(f)===R))continue;let x=p.get(R)??[];x.push(g),p.set(R,x);}let k=new Map,u=new Set;for(let g of a){let h=p.get(g)??[],R=h.find(y=>!["tblGridChange","tblPrChange"].includes(y.formattingKind??""))??h[0],x=R?[R,...h.filter(y=>y!==R)]:[],f=x.flatMap(q),P=new Set(f);if(!R||x.length<2||![...g.ids].every(y=>P.has(y)))continue;let I=[...new Map(x.flatMap(y=>y.addresses).map(y=>[JSON.stringify([y.id,y.author,y.date??null]),y])).values()],v=[...new Map(x.filter(y=>!["tblGridChange","tblPrChange"].includes(y.formattingKind??"")).flatMap(y=>y.ranges).map(y=>[JSON.stringify(y),y])).values()];k.set(R,Pe({...R,author:g.author,addresses:I,ranges:v,text:[...new Set(x.map(y=>y.text).filter(Boolean))].join(`
|
|
2
|
-
`)},f));for(let y of x.slice(1))u.add(y);}return t.filter(g=>!u.has(g)).map(g=>k.get(g)??g)}var zl=e=>e.kind==="textValue"?e.value:[e.namespaceUri,e.localName,e.attributes.map(t=>[t.namespaceUri,t.localName,t.value]).sort((t,n)=>JSON.stringify(t).localeCompare(JSON.stringify(n))),e.children.map(zl)],Wl=e=>new Map(e.children.filter(t=>t.kind!=="textValue"&&!(t.namespaceUri===chunk5MWFZ7F4_cjs.fa&&t.localName==="rPrChange")).map(t=>t.kind==="textValue"?["",""]:[JSON.stringify([t.namespaceUri,t.localName]),JSON.stringify(zl(t))]));function Em(e){if(e.node.localName!=="rPrChange"||!e.parent||e.paragraphMark||e.refused)return;let t=e.node.children.find(i=>i.kind!=="textValue"&&i.namespaceUri===chunk5MWFZ7F4_cjs.fa&&i.localName==="rPr");if(!t||t.kind==="textValue")return;let n=Wl(t),r=Wl(e.parent),o=[...new Set([...n.keys(),...r.keys()])].sort().filter(i=>n.get(i)!==r.get(i)).map(i=>[i,r.get(i)??null]);return o.length?JSON.stringify(o):void 0}function Kl(e,t){let n=new Map(t.map(s=>[s.node.id,Em(s)])),r=new Map;for(let s of e){if(s.revisionKind!=="format"||s.formattingKind!=="rPrChange"||s.readOnly||s.ranges.length!==1)continue;let l=s.ranges[0];if(l.start.paragraphId!==l.end.paragraphId||l.start.offset===l.end.offset)continue;let d=q(s),c=d.length?n.get(d[0]):void 0;if(!c||!d.every(k=>n.get(k)===c))continue;let m=JSON.stringify([s.author,l.partName,l.start.paragraphId,c]),p=r.get(m)??[];p.push(s),r.set(m,p);}let o=new Set,i=new Map,a=s=>{if(s.length<2)return;let l=s[0],d=[...new Map(s.flatMap(c=>c.addresses).map(c=>[JSON.stringify([c.id,c.author,c.date??null]),c])).values()];i.set(l,Pe({...l,addresses:d,ranges:s.flatMap(c=>c.ranges),text:s.map(c=>c.text).join("")},s.flatMap(q)));for(let c of s.slice(1))o.add(c);};for(let s of r.values()){s.sort((d,c)=>d.ranges[0].start.offset-c.ranges[0].start.offset);let l=[];for(let d of s)l.length&&l[l.length-1].ranges[0].end.offset!==d.ranges[0].start.offset&&(a(l),l=[]),l.push(d);a(l);}return e.filter(s=>!o.has(s)).map(s=>i.get(s)??s)}var de=(e,t)=>e.kind!=="textValue"&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa&&e.localName===t,an=(e,t)=>e.attributes.find(n=>n.namespaceUri===chunk5MWFZ7F4_cjs.fa&&n.localName===t)?.value;function Tm(e,t,n){let r=e.children.filter(o=>de(o,"tc"));return r.length>0&&r.every(o=>{if(o.kind==="textValue")return false;let i=o.children.filter(a=>a.kind==="paragraph");return i.length>0&&i.every(a=>{if(a.kind==="textValue")return false;let s=a.children.find(m=>de(m,"pPr")),l=s?.kind!=="textValue"?s?.children.find(m=>de(m,"rPr")):void 0,d=l?.kind!=="textValue"?l?.children.filter(m=>de(m,"ins")||de(m,"del")):void 0,c=d?.length===1?d[0]:void 0;return !!c&&c.kind!=="textValue"&&c.localName===t&&an(c,"author")===n})})}function Cm(e,t,n,r){let o=new Map(n.filter(f=>f.parent?.localName==="trPr"&&(f.node.localName==="ins"||f.node.localName==="del")).map(f=>[f.node.id,f]));if(o.size===0)return [...t];let i=new Map(n.map(f=>[f.node.id,f])),a=new Map;for(let f of r.values())a.set(f.paragraphId,Math.max(a.get(f.paragraphId)??0,f.end));let s=[],l=new Map,d=new Set,c=new Map,m=(f,P)=>{if(f.kind==="textValue"||de(f,"tbl"))return;let I=i.get(f.id),v=o.has(f.id);I&&!I.propertyChange&&f.localName===P.direction&&!I.refused&&(v?an(f,"author")===P.author:I.paragraphMark||f.kind==="revisionInsert"||f.kind==="revisionDelete")&&(c.set(f.id,P),v&&P.markerIds.add(f.id));for(let y of f.children)m(y,P);},p=(f,P=0)=>{if(f.kind!=="textValue"){if(de(f,"tr")&&P>1){let I=f.children.find(v=>de(v,"trPr"));if(I&&I.kind!=="textValue")for(let v of I.children)o.has(v.id)&&l.set(v.id,f);}if(de(f,"tbl")){let I;for(let v of f.children){if(v.kind==="textValue"||!de(v,"tr")){I=void 0;continue}let y=v.children.find(Q=>de(Q,"trPr")),T=y?.kind!=="textValue"?y?.children.filter(Q=>o.has(Q.id))??[]:[],N=T.length===1?T[0]:void 0,j=N&&N.kind!=="textValue"?an(N,"author"):void 0;if(!N||N.kind==="textValue"||j===void 0||o.get(N.id)?.refused){I=void 0;continue}let V=N.localName;if(P>0){if(!Tm(v,V,j)){I=void 0;continue}d.add(v.id);}(!I||I.author!==j||I.direction!==V)&&(I={markerIds:new Set,rows:[],author:j,direction:V,followingText:[]},s.push(I)),I.rows.push(v),I.markerIds.add(N.id),m(v,I);}}for(let I of f.children)p(I,P+(de(f,"tbl")?1:0));}};p(e.root);let k,u=new Set(s.flatMap(f=>f.rows.map(P=>P.id))),g=(f,P=0,I=false)=>{if(f.kind==="textValue")return;d.has(f.id)&&(k=void 0);let v=P+(de(f,"tbl")?1:0),y=I||u.has(f.id);if(f.kind==="run"&&!y&&(k=void 0),k&&(f.kind==="revisionInsert"||f.kind==="revisionDelete")){let T=k;k=void 0;let N=i.get(f.id),j=an(T.marker,"author");if(N&&!N.refused&&j!==void 0&&f.localName===T.marker.localName&&an(f,"author")===j&&(c.get(f.id)?.author??j)===j){let V=c.get(f.id);V||(V={markerIds:new Set,rows:[T.row],author:j,direction:T.marker.localName,followingText:[ut(f)],rowEndOnly:true},s.push(V),c.set(f.id,V)),V.markerIds.add(T.marker.id),c.set(T.marker.id,V);}}for(let T of f.children)g(T,v,y);if((de(f,"tc")||f.kind==="paragraph"&&!y)&&(k=void 0),de(f,"tr")&&(k=void 0,v>1&&!d.has(f.id))){let T=f.children.find(V=>de(V,"trPr")),N=T&&T.kind!=="textValue"?T.children.filter(V=>o.has(V.id)):[],j=N.length===1?N[0]:void 0;j&&j.kind!=="textValue"&&!o.get(j.id)?.refused&&(k={marker:j,row:f});}};g(e.root),t=t.map(f=>{let P=q(f);if(f.revisionKind!=="structural"||!P.length||!P.every(v=>l.has(v)))return f;let I=[];for(let v of P){let y,T=N=>{if(!(N.kind==="textValue"||de(N,"tbl")))if(N.kind==="paragraph")y=N;else for(let j of N.children)T(j);};if(T(l.get(v)),y){let N={paragraphId:y.id,offset:a.get(y.id)??0};I.push({partName:e.name,start:N,end:N});}}return I.length?Pe({...f,ranges:I},P):f});let h=new Map;for(let f of t){let P=q(f),I=P.length?c.get(P[0]):void 0;if(!I||f.readOnly||!P.every(y=>c.get(y)===I))continue;let v=h.get(I)??[];v.push(f),h.set(I,v);}let R=new Set,x=new Map;for(let f of s){let P=h.get(f)??[],I=P.find(D=>q(D).some(B=>f.markerIds.has(B))),v=new Set(P.flatMap(q));if(!I||![...f.markerIds].every(D=>v.has(D)))continue;let y=[I,...P.filter(D=>D!==I)],T=y.flatMap(D=>D.addresses),N=[],j=[],V=D=>{if(!(D.kind==="textValue"||de(D,"tbl"))){if(D.kind==="paragraph"){N.push({partName:e.name,start:{paragraphId:D.id,offset:0},end:{paragraphId:D.id,offset:a.get(D.id)??0}}),j.push(ut(D));return}for(let B of D.children)V(B);}};for(let D of f.rows)V(D);if(f.rowEndOnly&&N.length){let D=N[N.length-1];N.splice(0,N.length,{...D,start:D.end});}let Q=new Set(N.map(D=>D.start.paragraphId));for(let D of y)if(!(D.revisionKind==="structural"&&q(D).some(B=>!l.has(B))))for(let B of D.ranges)Q.has(B.start.paragraphId)||N.push(B);j.push(...f.followingText);let G=Pe({...I,addresses:[...new Map(T.map(D=>[JSON.stringify([D.id,D.author,D.date??null]),D])).values()],ranges:N.length?N:y.flatMap(D=>D.ranges),text:j.join(`
|
|
3
|
-
`),nesting:y.reduce((D,B)=>Math.min(D,B.nesting),I.nesting)},y.flatMap(q));x.set(I,G);for(let D of P)D!==I&&R.add(D);}return t.filter(f=>!R.has(f)).map(f=>x.get(f)??f)}function Gl(e,t,n,r,o){let i=Kl(Vl(e,Cm(e,t,n,r),n),n),a=new Set(n.filter(s=>s.node.kind==="moveFromRangeStart"||s.node.kind==="moveToRangeStart").map(s=>s.node.id));return a.size>0||n.some(s=>s.parent?.localName==="trPr"&&["ins","del"].includes(s.node.localName))?i.sort((s,l)=>At(s,o)-At(l,o)||Number(q(l).some(d=>a.has(d)))-Number(q(s).some(d=>a.has(d)))):i}function Xl(e){if(e.parent?.localName==="trPr"){if(e.node.localName==="ins")return "rowInsert";if(e.node.localName==="del")return "rowDelete"}if(e.parent?.localName==="tcPr"){if(e.node.localName==="cellIns")return "cellInsert";if(e.node.localName==="cellDel")return "cellDelete";if(e.node.localName==="cellMerge")return "cellMerge"}if(e.parent?.localName==="numPr"&&e.node.localName==="ins")return "numberingInsert"}function Yl(e,t,n,r){if(!e.some(u=>u.revisionKind==="paragraphMark"))return e;let o=new Map,i=(u,g)=>{if(!(u.kind==="textValue"||g>64))for(let h=0;h<u.children.length;h+=1){let R=u.children[h],x=u.children[h+1];R.kind==="paragraph"&&x?.kind==="paragraph"&&o.set(R.id,x.id),i(R,g+1);}};i(t.root,0);let a=e.map((u,g)=>g),s=u=>{for(;a[u]!==u;)a[u]=a[a[u]],u=a[u];return u},l=new Map,d=new Map,c=(u,g,h)=>JSON.stringify([u.revisionKind==="paragraphMark"?u.markDirection:u.revisionKind,u.author,u.nesting,g,h]),m=(u,g,h)=>{let R=u.get(g);R?R.push(h):u.set(g,[h]);};e.forEach((u,g)=>{if(!(u.readOnly||!["insert","delete","paragraphMark"].includes(u.revisionKind)))for(let h of u.ranges)m(l,c(u,h.start.paragraphId,h.start.offset),g),m(d,c(u,h.end.paragraphId,h.end.offset),g);});let p=(u,g)=>{for(let h of g){let R=e[u].date,x=e[h].date;R!==void 0&&x!==void 0&&!chunk5MWFZ7F4_cjs.Bg(R,x)||(a[s(h)]=s(u));}};e.forEach((u,g)=>{if(!(u.readOnly||u.revisionKind!=="paragraphMark"||!["insert","delete"].includes(u.markDirection??"")))for(let h of u.ranges){p(g,d.get(c(u,h.start.paragraphId,h.start.offset))??[]);let R=o.get(h.end.paragraphId);R&&p(g,l.get(c(u,R,0))??[]);}});let k=new Map;return e.forEach((u,g)=>{let h=s(g),R=k.get(h);R?R.push(u):k.set(h,[u]);}),[...k.values()].map(u=>{if(u.length===1)return u[0];let g=u.flatMap(P=>P.ranges).sort((P,I)=>n.get(P.start.paragraphId)-n.get(I.start.paragraphId)||P.start.offset-I.start.offset),h=u.flatMap(P=>q(P)).flatMap(P=>{let I=r.get(P);return I?[I]:[]}).sort((P,I)=>n.get(P.range.start.paragraphId)-n.get(I.range.start.paragraphId)||P.range.start.offset-I.range.start.offset),R=u[0],x=u.find(P=>P.revisionKind!=="paragraphMark"),f=[...new Map(u.flatMap(P=>P.addresses).map(P=>[JSON.stringify(P),P])).values()];return Pe({...R,id:u.map(P=>P.id).join("+"),revisionKind:x?.revisionKind??"paragraphMark",...x?{markDirection:void 0}:{},addresses:f,ranges:g,text:x?h.map(P=>P.text).join(""):""},u.flatMap(P=>q(P)))})}function $o(e){if(!e.propertyChange||!e.parent)return [];let t=(o,i)=>{let a=o?.children.find(s=>s.kind!=="textValue"&&s.namespaceUri===chunk5MWFZ7F4_cjs.fa&&s.localName==="lang");return a&&a.kind!=="textValue"?a.attributes.find(s=>s.namespaceUri===chunk5MWFZ7F4_cjs.fa&&s.localName===i)?.value:void 0},n=e.node.children.find(o=>o.kind!=="textValue"&&o.localName===e.parent.localName),r=[];for(let o of ["val","eastAsia","bidi"]){let i=t(e.parent,o),a=t(n?.kind!=="textValue"?n:void 0,o);i&&i!==a&&!r.includes(i)&&r.push(i);}return r}var Mm=[{property:"bold",element:"b",attribute:"val",kind:"toggle"},{property:"italic",element:"i",attribute:"val",kind:"toggle"},{property:"underline",element:"u",attribute:"val"},{property:"strike",element:"strike",attribute:"val",kind:"toggle"},{property:"fontFamily",element:"rFonts",attribute:"ascii"},{property:"fontSize",element:"sz",attribute:"val",kind:"halfPoints"},{property:"color",element:"color",attribute:"val"},{property:"alignment",element:"jc",attribute:"val"},{property:"leftIndent",element:"ind",attribute:"left",kind:"twips"},{property:"rightIndent",element:"ind",attribute:"right",kind:"twips"},{property:"firstLineIndent",element:"ind",attribute:"firstLine",kind:"twips"},{property:"hangingIndent",element:"ind",attribute:"hanging",kind:"twips"},{property:"spaceBefore",element:"spacing",attribute:"before",kind:"twips"},{property:"spaceAfter",element:"spacing",attribute:"after",kind:"twips"}];function Uo(e){if(!e.propertyChange||!e.parent)return [];let t=e.node.children.find(r=>r.kind!=="textValue"&&r.namespaceUri===chunk5MWFZ7F4_cjs.fa&&r.localName===e.parent.localName),n=[];for(let r of Mm){let o=a=>{let s=a?.children.find(d=>d.kind!=="textValue"&&d.namespaceUri===chunk5MWFZ7F4_cjs.fa&&d.localName===r.element);if(!s||s.kind==="textValue")return null;let l=s.attributes.find(d=>d.namespaceUri===chunk5MWFZ7F4_cjs.fa&&d.localName===r.attribute)?.value;if(r.kind==="toggle")return l==="0"||l==="false"||l==="off"?"false":"true";if(l===void 0)return null;if(r.kind==="halfPoints"||r.kind==="twips"){let d=Number(l);return Number.isFinite(d)?String(d/(r.kind==="halfPoints"?2:20)):l}return l},i=o(e.parent);i!==o(t?.kind!=="textValue"?t:void 0)&&n.push({property:r.property,value:i});}return n}function er(e){return Zl(e,true)}function wy(e){return Zl(e,false)}function Zl(e,t){let n=t?ql.get(e.root):void 0;if(n)return n;let r=new Map,o=s=>{let l=t?Jl.get(s):void 0;if(l){for(let[c,m]of l)r.set(c,m);return}let d=new Map;Dm(s,d,t),t&&Jl.set(s,d);for(let[c,m]of d)r.set(c,m);},i=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){o(s);return}for(let d of s.children)i(d,l+1);}};i(e.root,0);let a=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){let d=t?Ql.get(s):void 0;if(!d){let c=[];ed(s,0,c,t),d=c,t&&Ql.set(s,d);}for(let[c,m]of d)r.set(c,m);return}if(s.kind==="table"||s.kind==="tableRow"||s.kind==="tableCell"){let d=t?Zn.get(s):void 0;d||(d=td(s),t&&Zn.set(s,d));for(let[c,m]of d)r.set(c,m);}for(let d of s.children)a(d,l+1);}};return a(e.root,0),t&&ql.set(e.root,r),r}function ed(e,t,n,r){if(!(e.kind==="textValue"||t>64)){if(e.kind==="table"||e.kind==="tableRow"||e.kind==="tableCell"){let o=r?Zn.get(e):void 0;o||(o=td(e),r&&Zn.set(e,o));for(let i of o)n.push(i);}for(let o of e.children)ed(o,t+1,n,r);}}function td(e){let t=null,n=(i,a)=>{if(!(t||i.kind==="textValue"||a>64)){if(i.kind==="paragraph"){t=i;return}for(let s of i.children)n(s,a+1);}};if(n(e,0),!t)return Am;let r={paragraphId:t.id,start:0,end:0},o=[];if(e.kind==="textValue")return o;for(let i of e.children)if(!(i.kind==="textValue"||!["tblPr","tblGrid","tblPrEx","trPr","tcPr"].includes(i.localName)))for(let a of i.children){if(a.kind==="textValue")continue;(a.localName===`${i.localName}Change`||i.localName==="trPr"&&["ins","del"].includes(a.localName)||i.localName==="tcPr"&&["cellIns","cellDel","cellMerge"].includes(a.localName))&&o.push([a.id,r]);}return o}var Am=[],Jl=new WeakMap,ql=chunk5MWFZ7F4_cjs.gh(8),Zn=new WeakMap,Ql=new WeakMap;function Dm(e,t,n){let r=n?chunk5MWFZ7F4_cjs.qf(e):chunk5MWFZ7F4_cjs.sf(e),o=(s,l,d,c)=>{if(!(s.kind==="textValue"||c>64)){t.set(s.id,{paragraphId:e.id,start:l,end:d});for(let m of s.children)o(m,l,d,c+1);}},i=(s,l)=>{if(s.kind==="textValue"||l>64)return;let d=r.spanOf(s);if(s.kind==="fldSimple"&&d){o(s,d.start,d.end,l);return}if(s.kind==="run"){if(!d)return;t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)c.kind==="runProperties"&&o(c,d.start,d.end,l+1);return}d&&t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)i(c,l+1);};for(let s of e.children)s.kind!=="paragraphProperties"&&i(s,0);let a=e.children.find(s=>s.kind==="paragraphProperties");a&&o(a,r.length,r.length,0);}var Fm={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function tr(e,t){for(let n of e.attributes)if(n.localName===t&&n.namespaceUri===chunk5MWFZ7F4_cjs.fa)return n.value}function Bo(e){return `${e.id}\0${e.author}\0${e.date??""}`}var Lm={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo",moveFromRangeStart:"moveFrom",moveToRangeStart:"moveTo"},od={retainRevisionItems:true,revisionSites:chunk5MWFZ7F4_cjs.Fi,locations:er,commentAnchors:chunk5MWFZ7F4_cjs.ih,deepOrder:chunk5MWFZ7F4_cjs.Ti};function nr(e){return ad(e,od)}function ad(e,t){let n=e.root.kind!=="paragraph";if(n&&t.retainRevisionItems){let o=nd.get(e.root);if(o&&o.name===e.name)return o.items}let r=$m(e,t);return n&&t.retainRevisionItems&&nd.set(e.root,{name:e.name,items:r}),r}var nd=chunk5MWFZ7F4_cjs.gh(8);function $m(e,t){let n=t.revisionSites(e);if(n.length===0)return [];let r=t.locations(e),o=new Map(chunk5MWFZ7F4_cjs.ti(e.root).map(u=>[u.start.id,u])),i=chunk5MWFZ7F4_cjs.vi(e.root),a=n.some(u=>u.paragraphMark),s=new Map,l=new Map,d=chunk5MWFZ7F4_cjs.ri(e,n);for(let u of n){if(d.has(u.node.id))continue;let g=o.get(u.node.id),h=g?g.content.map(ut).join(""):ut(u.node),R=tr(u.node,"id"),x=R??`missing-${u.node.id}`,f=tr(u.node,"author")??"",P=tr(u.node,"author")===void 0&&u.node.localName!=="tblGridChange",I=tr(u.node,"date"),v=I===void 0?{id:x,author:f}:{id:x,author:f,date:I},y=i.has(u.node.id)?"insert":u.propertyChange?"format":u.paragraphMark?"paragraphMark":Lm[u.node.kind]??"structural",T=u.paragraphMark?Fm[u.node.localName]:void 0,N=y==="structural"?Xl(u):void 0,j=r.get(u.node.id),V=g?.end&&r.get(g.end.id),Q=j&&V&&j.paragraphId===V.paragraphId?{...j,end:V.end}:j,G=Q?{partName:e.name,start:{paragraphId:Q.paragraphId,offset:Q.start},end:{paragraphId:Q.paragraphId,offset:Q.end}}:null;a&&G&&(y==="paragraphMark"||y==="insert"||y==="delete")&&s.set(u.node.id,{range:G,text:y==="paragraphMark"?`
|
|
4
|
-
`:h});let D=y==="structural"?`structural\0${Bo(v)}`:`${y}\0${u.node.localName}\0${Bo(v)}`,B=l.get(D);if(B){B.siteNodeIds.push(u.node.id),N&&!B.structuralChanges?.includes(N)&&(B.structuralChanges??=[]).push(N),u.propertyChange&&(B.formattingLanguages=[...new Set([...B.formattingLanguages??[],...$o(u)])],B.formattingChanges=[...new Map([...B.formattingChanges??[],...Uo(u)].map(oe=>[JSON.stringify(oe),oe])).values()]),G&&!B.ranges.some(oe=>oe.partName===G.partName&&oe.start.paragraphId===G.start.paragraphId&&oe.start.offset===G.start.offset&&oe.end.paragraphId===G.end.paragraphId&&oe.end.offset===G.end.offset)&&B.ranges.push(G),y!=="structural"&&B.revisionKind==="structural"&&(B.revisionKind=y),(y==="insert"&&B.revisionKind==="delete"||y==="delete"&&B.revisionKind==="insert"||B.revisionKind==="replace")&&(B.revisionKind="replace"),B.readOnly||=u.refused||P,u.nesting>B.nesting&&(B.nesting=u.nesting),y==="delete"||y==="moveFrom"?B.deletedText+=h:y!=="format"&&y!=="paragraphMark"&&(B.text+=h);continue}l.set(D,{address:v,localName:u.node.localName,...N?{structuralChanges:[N]}:{},...u.propertyChange?{formattingLanguages:$o(u),formattingChanges:Uo(u)}:{},revisionKind:y,...T?{markDirection:T}:{},author:f,...I===void 0?{}:{date:I},text:y==="format"||y==="paragraphMark"||y==="delete"||y==="moveFrom"?"":h,deletedText:y==="delete"||y==="moveFrom"?h:"",ranges:G?[G]:[],siteNodeIds:[u.node.id],nesting:u.nesting,readOnly:u.refused||P||R===void 0});}let c=[...l.values()].map(u=>Pe({kind:"revision",id:`${u.revisionKind}${u.revisionKind==="format"||u.revisionKind==="paragraphMark"?`-${u.localName}`:""}-${e.name}\0${Bo(u.address)}`,address:u.address,addresses:[u.address],revisionKind:u.revisionKind,...u.revisionKind==="format"?{formattingKind:u.localName}:{},...u.structuralChanges?.length?{structuralChanges:u.structuralChanges}:{},...u.formattingChanges?.length?{formattingChanges:u.formattingChanges}:{},...u.formattingLanguages?.length?{formattingLanguages:u.formattingLanguages}:{},...u.markDirection?{markDirection:u.markDirection}:{},author:u.author,...u.date===void 0?{}:{date:u.date},text:u.revisionKind==="replace"?u.text:u.text||u.deletedText,replacedText:u.revisionKind==="replace"?u.deletedText:"",ranges:u.ranges,nesting:u.nesting,readOnly:u.readOnly,replyIds:[]},u.siteNodeIds)),m=t.deepOrder(e),p=Gl(e,c,n,r,m),k=id(p,m);return Um(Yl(k,e,m,s),m)}function Um(e,t){let n=id(e,t),r=n.filter(l=>(l.revisionKind==="insert"||l.revisionKind==="delete")&&!l.readOnly&&l.ranges.length>0),o=new Set,i=new Map,a=new Map;for(let l of r){if(l.revisionKind!=="insert")continue;let d=l.ranges[0].start,c=`${d.paragraphId}\0${d.offset}`,m=a.get(c);m?m.push(l):a.set(c,[l]);}for(let l of r){if(l.revisionKind!=="delete"||o.has(l.id))continue;let d=l.ranges[l.ranges.length-1].end,c=a.get(`${d.paragraphId}\0${d.offset}`)??[],m=c.length>1?[...c].sort((p,k)=>(p.text.length>0?0:1)-(k.text.length>0?0:1)):c;for(let p of m){if(o.has(p.id)||p.author!==l.author)continue;o.add(l.id),o.add(p.id);let k=zm(l.ranges[0],p.ranges[0],t)?l:p,u=Wm(l.date,p.date);i.set(l.id,Pe({...k,id:`replace-${l.id}-${p.id}`,revisionKind:"replace",...u===void 0?{}:{date:u},addresses:Vm([...l.addresses,...p.addresses]),text:p.text,replacedText:l.text,ranges:[...l.ranges,...p.ranges],replacedRangeCount:l.ranges.length,readOnly:l.readOnly||p.readOnly},[...q(l),...q(p)]));break}}let s=[];for(let l of n){let d=i.get(l.id);if(d){s.push(d);continue}o.has(l.id)||s.push(l);}return s}function id(e,t){let n=e.filter(d=>(d.revisionKind==="insert"||d.revisionKind==="delete")&&!d.readOnly&&d.ranges.length>0);if(n.length<2)return e;let r=d=>`${d.paragraphId}\0${d.offset}`,o=new Map;for(let d of n){let c=`${d.revisionKind}\0${d.author}`,m=o.get(c);m?m.push(d):o.set(c,[d]);}let i=(d,c)=>{let m=d.ranges[0].start,p=c.ranges[0].start,k=(t.get(m.paragraphId)??0)-(t.get(p.paragraphId)??0);return k!==0?k:m.offset-p.offset};for(let d of o.values()){let c=true;for(let m=1;m<d.length&&c;m+=1)c=i(d[m-1],d[m])<=0;c||d.sort(i);}let a=new Set,s=new Map;for(let d of o.values()){let c=[],m="",p=()=>{if(c.length>1){s.set(c[0].id,jm(c));for(let k=1;k<c.length;k+=1)a.add(c[k].id);}c=[];};for(let k of d){let u=r(k.ranges[0].start);c.length>0&&u!==m&&p();let g=c.length===0;c.push(k),(g||Bm(k))&&(m=r(k.ranges[k.ranges.length-1].end));}p();}if(s.size===0)return e;let l=[];for(let d of e)a.has(d.id)||l.push(s.get(d.id)??d);return l}function Bm(e){return e.ranges.some(t=>t.start.paragraphId!==t.end.paragraphId||t.start.offset!==t.end.offset)}function jm(e){let t=e[0],n=[...t.addresses],r=[...t.ranges],o=[...q(t)],i=t.text,a=t.date;for(let s of e.slice(1)){for(let l of s.addresses)n.some(d=>sd(d,l))||n.push(l);for(let l of s.ranges)r.push(l);for(let l of q(s))o.push(l);i+=s.text,a=Hm(a,s.date);}return Pe({...t,id:e.map(s=>s.id).join("+"),addresses:n,ranges:r,text:i,...a===void 0?{}:{date:a}},o)}function Hm(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?e:r>n?t:e}function Vm(e){let t=[];for(let n of e)t.some(r=>sd(r,n))||t.push(n);return t}function sd(e,t){return e.id===t.id&&e.author===t.author&&(e.date??"")===(t.date??"")}function Wm(e,t){if(t===void 0)return e;if(e===void 0)return t;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?t:n>r?e:t}function zm(e,t,n){let r=n.get(e.start.paragraphId)??0,o=n.get(t.start.paragraphId)??0;return r!==o?r<o:e.start.offset<=t.start.offset}function ld(e,t,n){let r=new Map(t.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,s=new Map;for(let c of e){let m=r.get(c.id);if(!m||m.orphaned||m.start.paragraphId===m.end.paragraphId&&m.start.offset===m.end.offset)continue;let p=`${m.start.paragraphId}:${m.start.offset}|${m.end.paragraphId}:${m.end.offset}`;a.has(p)?s.set(c.id,a.get(p)):a.set(p,c.id);}let l=new Map;for(let c of e){let m=c.paraId?n.get(c.paraId.toUpperCase()):void 0,p=m?.parentParaId?o.get(m.parentParaId):void 0,k=c.parentCommentId?i.get(c.parentCommentId):void 0,u=m===void 0?s.get(c.id):void 0,g=u?i.get(u):void 0,h=p??k??g;h&&h.id!==c.id&&l.set(c.id,h.id);}for(let c of [...l.keys()]){let m=new Set([c]),p=l.get(c);for(;p!==void 0;){if(m.has(p)){l.delete(c);break}m.add(p),p=l.get(p);}}let d=new Map;for(let[c,m]of l){let p=d.get(m);p?p.push(c):d.set(m,[c]);}return e.map(c=>{let m=r.get(c.id),p=c.paraId?n.get(c.paraId.toUpperCase()):void 0,k=l.get(c.id);return {kind:"comment",id:c.id,comment:c,range:m?{partName:m.partName,start:m.start,end:m.end}:null,resolved:p?.done??false,...k===void 0?{}:{parentId:k},replyIds:d.get(c.id)??[],orphaned:m===void 0||m.orphaned}})}function Km(e){return Gm(e,od)}function Gm(e,t){let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let c of [...e.furnitureParts??[],...e.stylesPart?[e.stylesPart]:[]])r.has(c.name)||(r.add(c.name),n.push(c));let o=e.commentsPart?chunk5MWFZ7F4_cjs.kh(e.commentsPart):[],i=e.commentsExtendedPart?chunk5MWFZ7F4_cjs.lh(e.commentsExtendedPart):new Map,a=[],s=[],l=n.length===1?t.deepOrder(n[0]):new Map;for(let c of n){for(let k of ad(c,t))a.push(k);for(let k of t.commentAnchors(c))s.push(k);if(n.length===1)continue;let m=l,p=m.size;for(let[k,u]of t.deepOrder(c))m.has(k)||m.set(k,p+u);}return dd([...a,...ld(o,s,i)]).sort((c,m)=>At(c,l)-At(m,l))}function Xm(e,t){if(e.kind!=="comment")return e;let n=e.replyIds??[],r=n.filter(i=>t.has(i)),o=e.parentId!==void 0&&!t.has(e.parentId);if(!o&&r.length===n.length)return e;if(o){let{parentId:i,parentRevisionId:a,...s}=e;return r.length===n.length?s:{...s,replyIds:r}}return {...e,replyIds:r}}function rd(e){return `${e.partName}\0${e.start.paragraphId}:${e.start.offset}|${e.end.paragraphId}:${e.end.offset}`}function dd(e){let t=new Set;for(let l of e)l.kind==="comment"&&t.add(l.id);let n=e.map(l=>Xm(l,t)),r=new Map;for(let l of n)if(l.kind==="revision")for(let d of l.ranges??[]){if(d.start.paragraphId===d.end.paragraphId&&d.start.offset===d.end.offset)continue;let c=rd(d),m=l.nesting??0,p=r.get(c);(p===void 0||m>p.nesting)&&r.set(c,{id:l.id,nesting:m});}let o=new Map;for(let l of n)l.kind==="comment"&&l.replyIds&&l.replyIds.length>0&&o.set(l.id,l.replyIds);let i=l=>{let d=[],c=new Set([l]),m=[...o.get(l)??[]];for(;m.length>0;){let p=m.shift();c.has(p)||(c.add(p),d.push(p),m.push(...o.get(p)??[]));}return d},a=new Map,s=new Map;for(let l of n){if(l.kind!=="comment"||l.parentId!==void 0||l.orphaned||!l.range)continue;let d=r.get(rd(l.range))?.id;if(d===void 0)continue;let c=[l.id,...i(l.id)];for(let p of c)s.set(p,d);let m=a.get(d);m?m.push(...c):a.set(d,c);}return n.map(l=>{if(l.kind==="revision"){let d=a.get(l.id)??[];return d.length===0&&(l.replyIds??[]).length===0?l:Pe({...l,replyIds:d},q(l))}if(l.kind==="comment"){let d=s.get(l.id);if(d===void 0){if(l.parentRevisionId===void 0)return l;let{parentRevisionId:c,...m}=l;return m}return l.parentRevisionId===d?l:{...l,parentRevisionId:d}}return l})}var Ym=256,Jm=2e3,cd=/[\p{L}\p{N}_]/u;function jo(e){let t=e.toLowerCase();if(t.length===e.length)return t;let n="";for(let r=0;r<e.length;r+=1){let o=e[r],i=o.toLowerCase();n+=i.length===1?i:o;}return n}function md(e,t,n){let r=t>0?e[t-1]:void 0,o=n<e.length?e[n]:void 0;return !(r!==void 0&&cd.test(r)||o!==void 0&&cd.test(o))}function ud(e){return typeof e=="string"&&e.length>0&&e.length<=256}function qm(e,t,n,r={}){let o={matches:[],truncated:false};if(!ud(t)||e.length===0||n<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,s=i?t:jo(t),l=i?e:jo(e),d=Math.max(0,r.from??0),c=Math.min(e.length,r.to??e.length),m=[],p=l.indexOf(s,d);for(;p>=0;){let k=p+s.length;if(k>c)return {matches:m,truncated:false};if(!a||md(e,p,k)){if(m.length>=n)return {matches:m,truncated:true};m.push({start:p,length:s.length});}p=l.indexOf(s,k);}return {matches:m,truncated:false}}var Qm=new Set(["plainText","richText","date","dropDownList","comboBox","docPartList"]),Zm=96;function Ho(e,t){return e.kind!=="textValue"&&e.namespaceUri===chunk5MWFZ7F4_cjs.fa&&e.localName===t}function eu(e){return e.kind==="textValue"&&e.value.trim()===""}function tu(e){let t=[],n=(r,o,i)=>{if(r.kind==="textValue"||i>Zm)return;if(chunk5MWFZ7F4_cjs.bf(r)){let s=chunk5MWFZ7F4_cjs.df(r),l=chunk5MWFZ7F4_cjs.Ob(r);if(s&&l&&s.children.every(eu)&&Qm.has(l.type)){t.push({control:r,content:s,kind:l.type,docPart:l.placeholderDocPart,inline:o});return}}let a=o||r.kind==="paragraph"||Ho(r,"p");for(let s of r.children)n(s,a,i+1);};return n(e,false,0),t}function nu(e){return chunk5MWFZ7F4_cjs.dj(e,"rPr",{kind:"runProperties",children:[chunk5MWFZ7F4_cjs.dj(e,"rStyle",{attributes:[["val","PlaceholderText"]]})]})}function ru(e){let t=e.find(r=>r.kind==="paragraph"||Ho(r,"p"));if(!t||t.kind==="textValue")return null;let n=t.children.filter(r=>r.kind!=="paragraphProperties"&&!Ho(r,"pPr"));return n.length>0?n:null}function Vo(e,t){let n=tu(t.root);if(n.length===0)return t;let r=null,o=d=>{if(d!==void 0)return r??=chunk5MWFZ7F4_cjs.Qf(e),r.find(c=>c.name===d)},i=chunk5MWFZ7F4_cjs.Ha(t,"paste"),a=new Set(chunk5MWFZ7F4_cjs.$a(t.root)),s={value:0},l=t;for(let[d,c]of n.entries()){let m=o(c.docPart),p=chunk5MWFZ7F4_cjs.bb(t,c.control),k=null;if(m){let x=m.blocks.map((f,P)=>chunk5MWFZ7F4_cjs.db(chunk5MWFZ7F4_cjs.jf(f,i),a,chunk5MWFZ7F4_cjs.zb(`${c.control.id}:placeholder:${d}:${P}`),s,p));k=c.inline?ru(x):x;}if(!k){let x=chunk5MWFZ7F4_cjs.ej(i,chunk5MWFZ7F4_cjs._i(c.kind),nu(i));k=c.inline?[x]:[chunk5MWFZ7F4_cjs.db(chunk5MWFZ7F4_cjs.dj(i,"p",{kind:"paragraph",children:[x]}),a,chunk5MWFZ7F4_cjs.zb(`${c.control.id}:placeholder:${d}`),s,p)];}let u=chunk5MWFZ7F4_cjs.fj(chunk5MWFZ7F4_cjs.cf(c.control),{showingPlaceholder:true},i),g={...c.content,children:k},h=c.control.children.map(x=>x.id===c.content.id?g:x.kind!=="textValue"&&x.localName==="sdtPr"?u:x),R=chunk5MWFZ7F4_cjs.Ma(l,c.control.id,h);R.ok&&(l=R.part);}return l}function pd(e,t,n){let r=t.filter(a=>a.node.localName==="tblGridChange"&&n.has(a.node.id));if(!r.length)return new Set;let o=new Map;for(let a of t){if(!["trPrChange","tcPrChange","tblPrExChange"].includes(a.node.localName))continue;let s=a.parent;for(;s&&s.kind!=="table";)s=chunk5MWFZ7F4_cjs.Ka(e,s.id);if(!s)continue;let l=o.get(s.id)??[];l.push(a.node.id),o.set(s.id,l);}let i=new Set;for(let a of r){let s=a.parent&&chunk5MWFZ7F4_cjs.Ka(e,a.parent.id),l=s&&o.get(s.id);l?.some(d=>n.has(d))&&l.some(d=>!n.has(d))&&i.add(a.node.id);}return i}function ou(e,t,n,r){let o=r??e.root,i=o.kind==="textValue"?e:{...e,root:o},a=nr(i),s=n===void 0?[...chunk5MWFZ7F4_cjs.ri(i,chunk5MWFZ7F4_cjs.Fi(i))]:[],l=s.length?[{op:"acceptAllRevisions",siteNodeIds:s,...r?{scopeRootId:r.id}:{}}]:[];if(n?.length===0||a.length===0)return {ops:l,result:{resolved:[],skipped:[...new Set(n??[])].map(S=>({key:S,reason:"unknown-revision"})),remaining:a.length}};let d=new Set(n??a.map(on)),c=new Map(a.map(S=>[on(S),S])),m=new Set;for(let S of d){let O=c.get(S);if(O)for(let M of q(O))m.add(M);}let p=chunk5MWFZ7F4_cjs.Fi(i),k=chunk5MWFZ7F4_cjs.ui(o,p,m,t);for(let S of k.selected)m.add(S);for(let S of a){let O=q(S);O.length&&O.every(M=>m.has(M))&&d.add(on(S));}let u=chunk5MWFZ7F4_cjs.Ii(o,p),g=new Map(p.map((S,O)=>[S.node.id,O])),h=p.map((S,O)=>O),R=S=>{for(;h[S]!==S;)h[S]=h[h[S]],S=h[S];return S},x=(S,O)=>{h[R(O)]=R(S);};for(let S of k.dependencies){let O=S.flatMap(M=>g.has(M)?[g.get(M)]:[]);for(let M of O)x(O[0],M);}let f=new Map;for(let S of a){let O=q(S).flatMap(M=>{let W=g.get(M);return W===void 0?[]:[W]});for(let M of O)x(O[0],M);}let P=p.filter(S=>m.has(S.node.id)),I=new Set(chunk5MWFZ7F4_cjs.zi(e,P,t).keys()),v=new Map;for(let[S,O]of p.entries()){if(t==="reject"&&O.propertyChange&&O.parent&&m.has(O.node.id))for(let W of O.parent.children)chunk5MWFZ7F4_cjs.wi(O.node.localName,W)||f.set(W.id,S);let M=t==="accept"?O.node.localName==="del"||O.node.localName==="moveFrom":O.node.localName==="ins"||O.node.localName==="moveTo";if(O.paragraphMark&&O.parent&&M&&!u.has(O.node.id)&&m.has(O.node.id)){let W=chunk5MWFZ7F4_cjs.Ka(e,O.parent.id),Z=W&&chunk5MWFZ7F4_cjs.Ka(e,W.id),ie=Z&&chunk5MWFZ7F4_cjs.Ka(e,Z.id);if(W&&Z&&ie){let z=v.get(ie.id);z||(z=chunk5MWFZ7F4_cjs.Di(ie.children,I),v.set(ie.id,z)),z.has(Z.id)&&f.set(W.id,S);}}if(m.has(O.node.id)&&chunk5MWFZ7F4_cjs.Ai(e,O,t)){let W=chunk5MWFZ7F4_cjs.Ai(e,O,t);W&&!O.refused&&f.set(W.id,S);}}for(let[S,O]of chunk5MWFZ7F4_cjs.Bi(e,P,t)){let M=chunk5MWFZ7F4_cjs.Ja(e,S),W=g.get(O[0]);if(!(M?.kind!=="tableCell"||W===void 0))for(let Z of M.children)Z.localName==="tcPr"&&f.set(Z.id,W);}let y=(S,O)=>{let M=g.get(S.id),W=f.get(S.id);M!==void 0&&W!==void 0&&x(W,M);let Z=M??W;Z!==void 0&&O!==void 0&&x(O,Z);let ie=Z??O;if(S.kind!=="textValue")for(let z of S.children)y(z,ie);};y(o);for(let S of chunk5MWFZ7F4_cjs.Hi(o).values()){let O=S.wrappers.flatMap(M=>{let W=g.get(M.id);return W===void 0?[]:[W]});for(let M of O)x(O[0],M);}for(let S of p.some(O=>O.node.localName==="cellMerge")?chunk5MWFZ7F4_cjs.Ci(i):[]){let O=S.flatMap(M=>{let W=g.get(M);return W===void 0?[]:[W]});for(let M of O)x(O[0],M);}let T=new Map;for(let[S,O]of p.entries()){let M=R(S),W=T.get(M)??[];W.push(O),T.set(M,W);}let N=new Map;for(let[S,O]of T)O.some(M=>M.refused||t==="reject"&&M.propertyChange&&chunk5MWFZ7F4_cjs.yi(M.node)===null)?N.set(S,"unsupported-revision"):O.some(M=>!m.has(M.node.id))&&N.set(S,"incomplete-group");for(let S of a)if(S.readOnly)for(let O of q(S)){let M=g.get(O);M!==void 0&&N.set(R(M),"unsupported-revision");}let j=p.filter((S,O)=>m.has(S.node.id)&&!N.has(R(O))),V=false,Q=chunk5MWFZ7F4_cjs.zi(e,j,t);for(let[S,O]of Q){if(f.has(S))continue;let M=g.get(O[0]);M!==void 0&&(f.set(S,M),V=true);}if(V){y(o);for(let[S,O]of [...N]){let M=R(S);N.get(M)!=="unsupported-revision"&&N.set(M,O);}}let G=[],D=[],B=new Set,oe=new Set(chunk5MWFZ7F4_cjs.qi(e,p,t));for(let S of oe){let O=chunk5MWFZ7F4_cjs.Ka(e,S);for(;O;){if(Q.has(O.id)){oe.delete(S);break}O=chunk5MWFZ7F4_cjs.Ka(e,O.id);}}for(let S of d){let O=c.get(S);if(!O){D.push({key:S,reason:"unknown-revision"});continue}let M={key:S,author:O.author,partName:e.name,revisionKind:O.revisionKind},W=q(O),Z;for(let ie of W){let z=g.get(ie);if(Z=z===void 0?"incomplete-group":N.get(R(z)),Z)break}if(W.length||(Z="unsupported-revision"),Z)D.push({key:S,reason:Z,revision:M});else {W.some(ie=>oe.has(ie))?D.push({key:S,reason:"retained-structure",revision:M}):G.push(M);for(let ie of W)oe.has(ie)||B.add(ie);}}let ve=pd(e,p,B),L=new Set;for(let S of a){let O=q(S);if(S.formattingKind!=="tblGridChange"&&O.length>1)for(let M of O)ve.has(M)&&L.add(M);}let $=[...B].filter(S=>!k.implicit.has(S)&&!L.has(S)),X=a.length-G.length;if(X>0&&$.length){let S={...e,root:{...e.root}},O=chunk5MWFZ7F4_cjs.Ji(S,t,void 0,{siteNodeIds:$,...r?{scopeRootId:r.id}:{}});if(O.ok&&O.part){let M=r?chunk5MWFZ7F4_cjs.Ja(O.part,r.id):O.part.root;X=M&&M.kind!=="textValue"?nr({...O.part,root:M}).length:0;}}return {ops:B.size?[...l,{op:t==="accept"?"acceptAllRevisions":"rejectAllRevisions",siteNodeIds:$,...r?{scopeRootId:r.id}:{}}]:l,result:{resolved:G,skipped:D,remaining:X}}}function Wo(e){return e.kind!=="textValue"}function rr(e,t){for(let n of e.children)if(Wo(n)&&n.localName===t)return n;return null}function au(e,t){let n=[e];for(;n.length>0;){let r=n.pop();if(Wo(r)){if(r.localName===t)return r;for(let o=r.children.length-1;o>=0;o-=1)n.push(r.children[o]);}}return null}var yd=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function _t(e,t,n){let r=rr(e,t),i=(r?rr(r,n):null)?.attributes.find(a=>a.localName==="typeface")?.value;return i!==void 0&&yd.test(i)?i:null}var fd=new WeakMap;function iu(e){let t=e?fd.get(e):void 0;if(t)return t;let n=e?au(e,"fontScheme"):null;if(!n)return xd;let r=Object.freeze({major:_t(n,"majorFont","latin"),minor:_t(n,"minorFont","latin"),majorEastAsia:_t(n,"majorFont","ea"),minorEastAsia:_t(n,"minorFont","ea"),majorBidi:_t(n,"majorFont","cs"),minorBidi:_t(n,"minorFont","cs"),...cu(n)});return e&&fd.set(e,r),r}var gd=new WeakMap,xd=Object.freeze({major:null,minor:null,majorEastAsia:null,minorEastAsia:null});function zo(e,t=null){let n=e?iu(e):xd,r=t?rr(t,"themeFontLang"):null;if(!r||!t)return n;let o=gd.get(t);o||gd.set(t,o=new WeakMap);let i=o.get(n);if(i)return i;let a=k=>r.attributes.find(u=>u.localName===k)?.value,s=hd(a("val")),l=hd(a("bidi")),d=a("eastAsia"),c=or(d),m=(k,u,g)=>u&&(k?n.majorSupplemental:n.minorSupplemental)?.[u]||g||null,p=Object.freeze({major:m(true,s,n.major),minor:m(false,s,n.minor),majorEastAsia:m(true,c,n.majorEastAsia),minorEastAsia:m(false,c,n.minorEastAsia),majorBidi:m(true,l,n.majorBidi),minorBidi:m(false,l,n.minorBidi),...d===void 0?{majorSupplemental:n.majorSupplemental,minorSupplemental:n.minorSupplemental}:{}});return o.set(n,p),p}var su=new Map([["minorAscii",e=>e.minor],["minorHAnsi",e=>e.minor],["majorAscii",e=>e.major],["majorHAnsi",e=>e.major],["minorEastAsia",e=>e.minorEastAsia??null],["majorEastAsia",e=>e.majorEastAsia??null],["minorBidi",e=>e.minorBidi??null],["majorBidi",e=>e.majorBidi??null]]);function Nk(e,t,n){if(e===void 0)return null;let r=su.get(e)?.(t)??null;if(r!==null)return r;let o=or(n);return o?(e==="majorEastAsia"?t.majorSupplemental:e==="minorEastAsia"?t.minorSupplemental:void 0)?.[o]??null:null}function or(e){if(!e||e.length>85)return null;let t=e.toLowerCase().split("-");return t[0]==="ja"?"Jpan":t[0]==="ko"?"Hang":t[0]!=="zh"?null:t.includes("hant")?"Hant":t.includes("hans")?"Hans":t.some(n=>["tw","hk","mo"].includes(n))?"Hant":"Hans"}var lu=new Map([["ar","Arab"],["fa","Arab"],["ur","Arab"],["ps","Arab"],["he","Hebr"],["yi","Hebr"],["dv","Thaa"],["syr","Syrc"]]);function hd(e){if(!e||e.length>85)return null;let t=e.toLowerCase().split("-");return t[1]&&/^[a-z]{4}$/.test(t[1])?t[1][0].toUpperCase()+t[1].slice(1):or(e)??lu.get(t[0])??null}var du=new Map([["Hans","SimSun"],["Hant","PMingLiU"],["Jpan","MS Mincho"],["Hang","Batang"]]);function Ek(e){return du.get(or(e)??"")??null}function cu(e){let t={};for(let[n,r]of [["majorFont","majorSupplemental"],["minorFont","minorSupplemental"]]){let o=Object.create(null);for(let i of rr(e,n)?.children??[]){if(!Wo(i)||i.localName!=="font")continue;let a=i.attributes.find(l=>l.localName==="script")?.value,s=i.attributes.find(l=>l.localName==="typeface")?.value;a&&/^[A-Z][a-z]{3}$/.test(a)&&s&&yd.test(s)&&(o[a]=s);}Object.keys(o).length&&(t[r]=Object.freeze(o));}return t}var pt=Object.freeze({styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"});function Ko(e,t,n,r){let o=(e.relationships.get(t)??[]).find(i=>i.type===n);if(o){let i=chunk5MWFZ7F4_cjs.E(o);if(i.mode==="Internal"&&i.target.ok){let a=e.parts.get(i.target.partName);if(a)return a}}return e.parts.get(r)}function Bk(e){let t=chunk5MWFZ7F4_cjs.Vd(e);if(!t.ok)return {ok:false,reason:t.reason,...t.detail?{detail:t.detail}:{}};let n=t.package.parts.get(t.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-tree",detail:t.package.mainDocumentPart};let r=new tn(t.package,Vo(t.package,chunk5MWFZ7F4_cjs.eb(n)));return {ok:true,view:mu(r)}}function mu(e){let t=()=>e.currentPackage(),n=()=>e.bodyStore().part,r=(d,c)=>Ko(t(),t().mainDocumentPart,d,c)?.root??null,o=Object.freeze(zo(null)),i=null,a=chunk5MWFZ7F4_cjs.vh,s=null;return Object.freeze({part:n,currentPackage:t,packageRevision:()=>e.packageRevision,stylesRoot:()=>r(pt.styles,"/word/styles.xml"),numberingRoot:()=>r(pt.numbering,"/word/numbering.xml"),settingsRoot:()=>r(pt.settings,"/word/settings.xml"),documentThemeFonts(){let d=t();return i!==d&&(o=Object.freeze(zo(r(pt.theme,"/word/theme/theme1.xml"),r(pt.settings,"/word/settings.xml"))),i=d),o},documentProperties(){let d=t();if(s!==d){let c=Ko(d,"/",pt.coreProperties,"/docProps/core.xml"),m=Ko(d,"/",pt.extendedProperties,"/docProps/app.xml");a=chunk5MWFZ7F4_cjs.wh(c?.root??null,m?.root??null),s=d;}return a},headerFooterPartsBySection:()=>chunk5MWFZ7F4_cjs.re(t()),headerFooterResolutionBySection:()=>chunk5MWFZ7F4_cjs.qe(t()),relationshipTarget:d=>chunk5MWFZ7F4_cjs.Vf(t(),n().name,d)})}
|
|
5
|
-
exports.$=um;exports.A=Kt;exports.Aa=Gm;exports.B=Hr;exports.Ba=dd;exports.C=Md;exports.Ca=Ym;exports.D=Vr;exports.Da=Jm;exports.E=Wr;exports.Ea=jo;exports.F=zr;exports.Fa=md;exports.G=Kr;exports.Ga=ud;exports.H=_d;exports.Ha=qm;exports.I=Di;exports.Ia=Vo;exports.J=Gt;exports.Ja=ou;exports.K=tc;exports.Ka=Bk;exports.L=mo;exports.La=mu;exports.M=ks;exports.N=uo;exports.O=dt;exports.P=fl;exports.Q=tn;exports.R=hl;exports.S=yl;exports.T=vo;exports.U=ch;exports.V=Oo;exports.W=Ao;exports.X=Do;exports.Y=dm;exports.Z=cm;exports._=mm;exports.a=zo;exports.aa=pm;exports.b=Nk;exports.ba=fm;exports.c=Ek;exports.ca=Ml;exports.d=Rd;exports.da=Al;exports.e=Ni;exports.ea=_o;exports.f=An;exports.fa=Fo;exports.g=it;exports.ga=hm;exports.h=Dn;exports.ha=xm;exports.i=_n;exports.ia=km;exports.j=pe;exports.ja=Rm;exports.k=Od;exports.ka=Pm;exports.l=st;exports.la=q;exports.m=Wt;exports.ma=on;exports.n=Fn;exports.na=Lo;exports.o=zt;exports.oa=Ul;exports.p=Ln;exports.pa=At;exports.q=Lr;exports.qa=Nm;exports.r=$r;exports.ra=Zh;exports.s=Ur;exports.sa=ey;exports.t=Nd;exports.ta=jl;exports.u=Ed;exports.ua=Hl;exports.v=jr;exports.va=er;exports.w=Ti;exports.wa=wy;exports.x=Td;exports.xa=nr;exports.y=Br;exports.ya=ld;exports.z=Cd;exports.za=Km;
|
package/dist/chunk-ILUE2SI5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {i,b,c,f,d,g,cc,hb,kb,mb,nb,lb,Vc,ib,jb,fd,tc,be,ae,Cd,dc,cd,fc}from'./chunk-VOVDX7GW.js';import {a}from'./chunk-IZT3C23R.js';import {na,fa,oa,Nc,a as a$1}from'./chunk-Z65JJLLF.js';var Te=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function D(e){let n=new Map;for(let t of e)if(Array.isArray(t)){for(let r of t.slice(0,2048)){if(typeof r!="string"||!Te.test(r))continue;let o=r.toLowerCase();if(n.has(o)||n.set(o,r),n.size===2048)break}if(n.size===2048)break}return Object.freeze([...n.values()])}function We(e){let n=e&&"failures"in e?e.failures:void 0;return e==null||(e.sources?.length??0)===0&&(e.substitutions?.length??0)===0&&(n===void 0||Array.isArray(n)&&n.length===0)?void 0:e}var Je=64,Ee=Object.freeze({family:"Calibri",sizeHalfPoints:22});function Oe(e,...n){let t=[e,...n],r=[],o=new Set;for(let a of t)for(let d of a.sources??[]){let c=i(d.request);o.has(c)||(o.add(c),r.push(d));}let s=[],i$1=new Set;for(let a of t)for(let d of a.substitutions??[]){let c=i(d.from);o.has(c)||i$1.has(c)||(i$1.add(c),s.push(d));}let u=D(t.map(a=>a.supportedFamilies));return Object.freeze({...u.length?{supportedFamilies:u}:{},epoch:e.epoch??0,maxFontBytes:e.maxFontBytes??b,sources:Object.freeze(r),...s.length>0?{substitutions:Object.freeze(s)}:{},defaultFont:e.defaultFont??Ee,...e.language!==void 0?{language:e.language}:{}})}var Ne=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function we(e){let n=e?.defaultFont?.family;return n!==void 0&&Ne.test(n)?n:Ee.family}var Ie="docx-editor.dev/font-resolver",Ce=Symbol.for("docx-editor.dev/font-resolver");function on(e){let n={value:true,enumerable:false,configurable:true};try{Object.defineProperty(e,Ce,n),Object.defineProperty(e,Ie,n);}catch(t){throw new TypeError("defineFontResolver cannot mark a frozen or sealed function; mark it before freezing, or wrap it in a fresh function and mark that.",{cause:t})}return e}function rn(e){return typeof e=="function"&&e[Ce]===true}var X=e=>`${e.family.trim().toLowerCase()} ${e.weight} ${e.style}`;function Me(e,n,t){let r=new Map(e.map(o=>[X(o),o]));for(let[o,s]of n)r.set(o,s);for(let o of t)r.has(X(o.to))&&r.set(X(o.from),o.from);return [...r.values()]}async function sn(e,n,t={}){return ve(e,n,t)}async function an(e,n,t={}){return ve(e,n,t)}async function ve(e,n,t){let r=e.map(_e),o,s=[],i$1=[],u=new Map,a=new Set,d=0,c$1=[],f=new Set,m=[],O=n.resolvedFaces??[],w=n.defaultFamily;for(let b$1=0;b$1<e.length;b$1+=1){ke(n.signal);let k=e[b$1],I=Me(O,u,c$1),P;try{let x=r[b$1],S;if(x){let l=await Re(x,n.signal);if(!l.ok)throw l.cause;S=l.value;}else if(typeof k=="function"){let l=await Re(Promise.resolve(k(Le(n,w,I,d))).then(p=>({ok:!0,value:p}),p=>({ok:!1,cause:p})),n.signal);if(!l.ok)throw l.cause;S=l.value;}else S=k;if(S==null)continue;if(typeof S=="function"){Z(t,k,b$1,new TypeError("A font origin answered with a function; pass the resolver itself rather than a function returning one"));continue}let R="failures"in S?S.failures:void 0,M=[];if(Array.isArray(R)){let l=Math.min(R.length,c);for(let p=0;p<l;p++)M.push(R[p]);R.length>l&&M.push(new Error("Additional font-origin failures were omitted"));}else R!==void 0&&M.push(R);let C=Be(S,a,d,f,o?"maxFontBytes"in o&&o.maxFontBytes!==void 0?o.maxFontBytes:b:void 0,t.reserveOwnedBytes,t.instrumentation);P=C;for(let l of new Set([...C.dropped,...M]))Z(t,k,b$1,l);let E=C.fragment;E.supportedFamilies&&s.push(E.supportedFamilies),m.push(...M);let $=(E.sources??[]).map(l=>(i(l.request),[X(l.request),l.request])),y=[...E.substitutions??[]];!o&&"defaultFont"in E&&(w=we(E)),o||(o=E);let g=new Set(C.sourceKeys);if(g.size>0){c$1=c$1.filter(l=>!g.has(i(l.from)));for(let l of g)f.delete(l);}i$1.push(...E.sources??[]);for(let l of C.sourceKeys)a.add(l);d+=C.ownedBytes;for(let[l,p]of $)u.set(l,p);for(let l of y)c$1.push(l),f.add(i(l.from));}catch(x){if(P?.releaseOwnedBytes?.(),n.signal?.aborted)throw n.signal.reason??x;if(x instanceof V)throw x.cause;Z(t,k,b$1,x);continue}}if(!o)return;let{epoch:N,...j}=Oe({...o,supportedFamilies:D(s),sources:i$1,substitutions:c$1});return m.length===0?j:{...j,failures:Object.freeze(m)}}var V=class extends Error{constructor(t){super("Unable to reserve owned font bytes");this.cause=t;this.name="FontOwnershipReservationError";}cause},Y=class extends RangeError{};async function Re(e,n){if(!n)return e;ke(n);let t,r=new Promise((s,i)=>{t=i;}),o=()=>t?.(n.reason);n.addEventListener("abort",o,{once:true});try{return await Promise.race([e,r])}finally{n.removeEventListener("abort",o);}}function _e(e){if(e===null||typeof e!="object")return;let n;try{n=e.then;}catch(t){return Promise.resolve({ok:false,cause:t})}if(typeof n=="function")return Promise.resolve(e).then(t=>({ok:true,value:t}),t=>({ok:false,cause:t}))}function Be(e,n,t,r,o,s,i$1){let u=e.sources??[],a=e.substitutions??[],d$1="maxFontBytes"in e?e.maxFontBytes:void 0,c$1="defaultFont"in e?e.defaultFont:void 0,f$1="epoch"in e?e.epoch:void 0,m="language"in e?e.language:void 0;if(!Array.isArray(u)||!Array.isArray(a))throw new TypeError("Font origin sources and substitutions must be arrays");let O=u.length,w=a.length;if(O>c)throw new RangeError(`Font source count must not exceed ${c}`);if(w>c)throw new RangeError(`Font substitution count must not exceed ${c}`);let N=d$1??b;if(!Number.isSafeInteger(N)||N<=0||N>b)throw new RangeError(`Font byte ceiling must be a positive safe integer no greater than ${b}`);let j=o??N,b$1=0,k=[],I=new Set,P=[],x=[];for(let y=0;y<O;y+=1){let g=u[y];try{let l=Q(g.request),p=g.availability,B=g.faceIndex,h=g.hash,A=g.id,L=i(l);if(p!==void 0&&p!=="available"&&p!=="forbidden")throw new TypeError("Font source availability must be available or forbidden");if(!Number.isSafeInteger(B)||B<0)throw new RangeError("Font face index must be a non-negative safe integer");if(typeof h!="string"||h.length===0)throw new TypeError("Font source hash must be a non-empty string");let K;if(p!=="forbidden"){if(typeof A!="string"||A.length===0)throw new TypeError("Font source id must be a non-empty string");K=g.bytes;let J=f(K);if(J>j)throw new RangeError("Font source exceeds the effective base byte ceiling");if(n.has(L)||I.has(L))continue;if(t+b$1+J>d)throw new RangeError(`Font sources exceed the aggregate byte ceiling of ${d}`);b$1+=J;}else K=new Uint8Array(0);if(n.has(L)||I.has(L))continue;if(n.size+I.size>=c)throw new Y(`Font source count must not exceed ${c}`);I.add(L),k.push(L),P.push(Object.freeze({request:l,id:A,bytes:K,hash:h,faceIndex:B,...p?{availability:p}:{}}));}catch(l){if(l instanceof Y)throw l;x.push(l);}}let S=new Set,R=[];for(let y=0;y<w;y+=1){let g=a[y];try{let l=Q(g.from),p=Q(g.to);i(l),i(p);let B=g.lineMetrics,h=B?Object.freeze({heightEm:B.heightEm,baselineEm:B.baselineEm}):void 0;if(h&&(!Number.isFinite(h.heightEm)||!Number.isFinite(h.baselineEm)||h.heightEm<=0||h.heightEm>4||h.baselineEm<0||h.baselineEm>h.heightEm))throw new RangeError("Font substitution line metrics must fit within a bounded em box");let A=i(l);if(n.has(A)||I.has(A)||r.has(A)||S.has(A))continue;S.add(A),R.push(Object.freeze({from:l,to:p,...h?{lineMetrics:h}:{}}));}catch(l){x.push(l);}}if((O>0||w>0)&&P.length===0&&R.length===0&&x.length>0)throw x[0];let M=r.size;for(let y of I)r.has(y)&&(M-=1);if(M+S.size>c)throw new RangeError(`Font substitution count must not exceed ${c}`);let C;if(c$1!==void 0){let y=c$1.family,g=c$1.sizeHalfPoints;if(i({family:y,weight:400,style:"normal"}),!Number.isSafeInteger(g)||g<=0)throw new RangeError("Default font size must be a positive safe integer in half-points");C=Object.freeze({family:y,sizeHalfPoints:g});}if(f$1!==void 0&&(!Number.isSafeInteger(f$1)||f$1<0))throw new RangeError("Font configuration epoch must be a non-negative safe integer");if(m!==void 0&&typeof m!="string")throw new TypeError("Font shaping language must be a string");let E;if(b$1>0&&s)try{E=s(b$1);}catch(y){throw new V(y)}let $;try{$=P.map(y=>g(y,i$1));}catch(y){throw E?.(),y}return {fragment:Object.freeze({supportedFamilies:D([e.supportedFamilies]),sources:Object.freeze($),substitutions:Object.freeze(R),...f$1!==void 0?{epoch:f$1}:{},...d$1!==void 0?{maxFontBytes:d$1}:{},...C?{defaultFont:C}:{},...m!==void 0?{language:m}:{}}),sourceKeys:Object.freeze(k),ownedBytes:b$1,dropped:Object.freeze(x),releaseOwnedBytes:E}}function Pe(e){return !Number.isSafeInteger(e)||e<=0?0:e>d?d:e}function Le(e,n,t,r){let{committedSourceBytes:o,...s}=e,i=Pe(r);return {...s,defaultFamily:n,...t.length>0?{resolvedFaces:t}:{},...i>0?{committedSourceBytes:i}:{}}}function Q(e){return Object.freeze({family:e.family,weight:e.weight,style:e.style})}function ke(e){if(e?.aborted)throw e.reason??new DOMException("Font resolution was aborted","AbortError")}function Z(e,n,t,r){let o;try{typeof n=="function"&&n.name.length>0&&(o=n.name);}catch{}let s=Object.freeze({originIndex:t,...o!==void 0?{originName:o}:{},cause:r});if(e.onOriginFailure)try{let u=e.onOriginFailure(s);Promise.resolve(u).catch(a=>{console.warn("[fonts] font-origin diagnostic callback failed",a);});return}catch(u){console.warn("[fonts] font-origin diagnostic callback failed",u);}let i="";try{r instanceof Error&&r.message.length>0&&(i=`: ${r.message}`);}catch{}console.warn(`[fonts] a font origin failed and was skipped${i}`,r);}function G(e){let n=new WeakMap;return (t,r)=>{let o=new Set;for(let s of t){let i=[{node:s,context:r,next:0}],u=a=>{i.pop();let d=i.at(-1)?.found??o;for(let c of a)d.add(c);};for(;i.length;){let a=i[i.length-1],d=n.get(a.node);if(d?.key===a.context.key){u(d.families);continue}if(!a.children){let m=e(a.node,a.context);a.children=m.children,a.found=new Set(m.families);}let c=a.children[a.next++];if(c){i.push({...c,next:0});continue}let f=[...a.found];f.length<=256?n.set(a.node,{key:a.context.key,families:f}):n.delete(a.node),u(f);}}return [...o]}}function W(e,n){return e.children.flatMap(t=>t.kind==="textValue"?[]:[{node:t,context:n}])}function qe(e,n){let{styles:t,theme:r,supplementalFamilies:o,depth:s}=n;if(e.kind==="table"){let a=Cd(e,468,s,t),d=[];for(let c of a?.rows??[])for(let f of c.cells){let m={...n,depth:s+1,cellStyle:f.styleFormatting,key:`${n.baseKey}|${s+1}|${JSON.stringify(f.styleFormatting)}`};for(let O of f.blocks)d.push({node:O,context:m});}return {children:d.reverse()}}let i=new Set;if(e.kind==="paragraph"){let a$1=e.children.find(c=>c.kind==="paragraphProperties"),d=dc(t,a$1,n.cellStyle).runProperties;for(let c of cd(e,d,void 0,(f,m)=>fc(f,m,t),void 0,void 0,"all-markup",void 0,void 0,r)){if(!c.text||c.fontSlot!=="eastAsia"&&!o.has(c.style.fontFamily??""))continue;let f=a((c.fontSlot==="eastAsia"?c.style.fontFamilyEastAsia:c.style.fontFamily)??void 0);f&&i.add(f);}}let u=e.localName==="txbxContent"?{...n,cellStyle:void 0,key:`${n.baseKey}|${s}|undefined`}:n;return {families:[...i],children:W(e,u).reverse()}}function ze(){let e=G(qe),n,t;return (r,o,s)=>{if(!n||t!==o||n.theme!==s){let i=cc(o,s);t=o,n={key:`${i.cacheToken}|0|undefined`,baseKey:i.cacheToken,styles:i,theme:s,depth:0,supplementalFamilies:new Set([...Object.values(s.majorSupplemental??{}),...Object.values(s.minorSupplemental??{})])};}return e([...r].reverse(),n)}}function pn(e,n,t){return ze()(e,n,t)}function ee(e,n){return e.attributes.find(t=>t.localName===n)?.value}var De=G((e,n)=>{let t=[];if(e.namespaceUri===fa){if(e.localName==="fldSimple"){let r=Vc(ee(e,"instr")??"")?.font;r&&t.push(r);}if(e.localName==="p")for(let r of je(e))t.push(r);}return {families:t,children:W(e,n)}});function vn(e){let n=new Map;for(let t of De(e,{key:""})){let r=a(t);r!==null&&!n.has(r.toLowerCase())&&n.set(r.toLowerCase(),r);}return [...n.values()]}function je(e){let n=[],t=hb(),r=[];for(let o=e.children.length-1;o>=0;o-=1){let s=e.children[o];s.kind!=="textValue"&&r.push({node:s,containerDepth:0});}for(;r.length>0;){let{node:o,containerDepth:s}=r.pop();if(s>=na||o.namespaceUri===fa&&o.localName==="p")continue;if(o.namespaceUri===fa&&o.localName==="fldChar"){let u=ee(o,"fldCharType");u==="begin"?kb(t):u==="separate"?(t.nesting===1&&Ae(t,n),mb(t)):u==="end"&&(t.nesting===1&&Ae(t,n),nb(t));continue}if(o.namespaceUri===fa&&(o.localName==="instrText"||o.localName==="delInstrText")){lb(t,$e(o),o.localName==="delInstrText");continue}if(o.namespaceUri===fa&&o.localName==="fldSimple"){let u=Vc(ee(o,"instr")??"");u?.font&&n.push(u.font);}let i=oa(o,s);for(let u=o.children.length-1;u>=0;u-=1){let a=o.children[u];a.kind!=="textValue"&&r.push({node:a,containerDepth:i});}}return ib(t),n}function Ae(e,n){let t=jb(e);if(t.overflow)return;let r=Vc(t.instruction);r?.font&&n.push(r.font);}function $e(e){let n="",t=[...e.children].reverse();for(;t.length>0&&n.length<=256;){let r=t.pop();if(r.kind==="textValue")n+=r.value;else for(let o=r.children.length-1;o>=0;o-=1)t.push(r.children[o]);}return n}var Ke=()=>true;function kn(e,n,t,r){if(!n)return [];let o=fd(n),s=cc(t,r),i=new Map;for(let u of e)for(let a$1 of Ue(u)){let d=Nc(a$1.children),c=f=>{if(f)for(let m of f.values())for(let O of [m.markerStyle.fontFamily,m.markerStyle.fontFamilyEastAsia]){let w=a(O??void 0);if(w===null)continue;let N=w.toLowerCase();i.has(N)||i.set(N,w);}};c(tc(d,o,s,Ke));for(let f of d){let m=be(f);for(let O of m.contents)c(ae(O,o,s));}}return [...i.values()].sort((u,a)=>u.localeCompare(a))}function Ue(e){if(e.localName==="document"){for(let n of e.children)if(n.kind!=="textValue"&&n.localName==="body")return [n];return []}if(e.localName==="footnotes"||e.localName==="endnotes"){let n=[];for(let t of e.children)t.kind!=="textValue"&&(t.localName==="footnote"||t.localName==="endnote")&&n.push(t);return n}return [e]}var He={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}};function Nn(e,n){let t=[],r=[],o=0;for(let s of e){let i=s.bytes.byteLength;if(!Number.isSafeInteger(i)||i>n||i>b||i>d-o){r.push(s);continue}o+=i,t.push(s);}return {sources:t,dropped:r}}function In(e,n,t){let r=n.reduce((s,i)=>s+i.bytes.byteLength,0),o=new Set(n.filter(s=>s.request.family.trim().length>0).map(s=>i(s.request)));return Xe(e,{maxFontBytes:t,aggregateBudget:Math.max(0,d-r),shadowedRequests:o})}function Xe(e,n){let t=[],r=[],o=n.aggregateBudget,s=new Set;for(let i$1 of e){let u=He[i$1.style],a=Object.freeze({family:i$1.family,weight:u.weight,style:u.style});if(i$1.family.trim().length===0){r.push({request:a,partName:i$1.partName,reason:"malformed"});continue}let d=i(a);if(!(n.shadowedRequests?.has(d)||s.has(d))){if(s.add(d),i$1.bytes.byteLength>n.maxFontBytes||i$1.bytes.byteLength>o){r.push({request:a,partName:i$1.partName,reason:"overLimit"});continue}o-=i$1.bytes.byteLength,t.push({request:a,id:`embedded:${i$1.partName}#${i$1.style}`,bytes:i$1.bytes,hash:a$1(i$1.bytes),faceIndex:0});}}return {sources:t,dropped:r}}export{D as a,We as b,Je as c,Ee as d,Oe as e,we as f,Ie as g,Ce as h,on as i,rn as j,sn as k,an as l,Nn as m,In as n,Xe as o,G as p,W as q,ze as r,pn as s,vn as t,je as u,kn as v};
|
package/dist/chunk-IZT3C23R.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b}from'./chunk-VE7YBFQD.js';import {fa}from'./chunk-Z65JJLLF.js';var z=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,J=128,Q=/[\u0000-\u001F\u007F-\u009F]/,G=16,nn=2,en=3276;function V(e){return e.kind!=="textValue"}function P(e,n){for(let t of e.children)if(V(t)&&t.localName===n)return t}function O(e,n){return e.attributes.find(t=>t.localName===n)?.value}function D(e){return e===void 0||e.length===0||e.length>J||Q.test(e)?null:e}function v(e,n){let t=b(O(e,"asciiTheme"),n)??b(O(e,"hAnsiTheme"),n);if(t!==null)return t;let l=O(e,"ascii")??O(e,"hAnsi");return l===void 0?null:z.test(l)?l:null}function C(e,n){let t=b(O(e,"eastAsiaTheme"),n);if(t!==null)return t;let l=O(e,"eastAsia");return l===void 0?null:z.test(l)?l:null}function tn(e){return e!==void 0&&z.test(e)?e:null}function On(e){return tn(e)}function ln(e){return e!==void 0&&["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(n=>!!O(e,n))}function Y(e,n){if(!e)return {fontFamily:null,fontSizeHalfPoints:null,hasLatinFontReference:false};let t=P(e,"rFonts"),l=P(e,"sz"),i=l?O(l,"val"):void 0,r=i!==void 0&&/^\d{1,4}$/.test(i)?Number(i):null;return {fontFamily:t?v(t,n):null,hasLatinFontReference:ln(t),fontSizeHalfPoints:r!==null&&r>=nn&&r<=en?r:null}}function Sn(e,n){let t=new Map,l={fontFamily:null,fontSizeHalfPoints:null,hasLatinFontReference:false};if(e){let a=P(e,"docDefaults"),s=a?P(a,"rPrDefault"):void 0;l=Y(s?P(s,"rPr"):void 0,n);for(let u of e.children){if(!V(u)||u.localName!=="style")continue;let o=D(O(u,"styleId"));if(o===null||t.has(o))continue;let f=P(u,"basedOn");t.set(o,{basedOn:D(f?O(f,"val"):void 0),own:Y(P(u,"rPr"),n)});}}let i=new Map,r=a=>{let s=a??"",u=i.get(s);if(u)return u;let o=null,f=null,m=l.hasLatinFontReference,b=new Set,y=a;for(let I=0;y!==null&&I<G&&!b.has(y);I+=1){b.add(y);let E=t.get(y);if(!E)break;o??=E.own.fontFamily,m||=E.own.hasLatinFontReference,f??=E.own.fontSizeHalfPoints,y=E.basedOn;}let g={hasLatinFontReference:m,fontFamily:o??l.fontFamily,fontSizeHalfPoints:f??l.fontSizeHalfPoints};return i.set(s,g),g};return (a,s)=>{let u=r(a),o=s?.find(b=>b.localName==="rFonts"),f=o?b(o.attributes?.asciiTheme,n)??b(o.attributes?.hAnsiTheme,n):null,m=["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(b=>!!o?.attributes?.[b]);return {fontFamily:f??u.fontFamily??(!u.hasLatinFontReference&&!m?n.minor:null),fontSizeHalfPoints:u.fontSizeHalfPoints}}}var an=16,on=16,rn=32,sn=4096;function x(e){return e.kind!=="textValue"}function c(e,n){for(let t of e.children)if(x(t)&&t.localName===n)return t}function M(e,n){return e.attributes.find(t=>t.localName===n)?.value}function un(e){return e==="1"||e==="true"||e==="on"}function H(){return {families:new Map,styleIds:new Set,anyText:false,bareParagraph:false,bareRun:false,bareTable:false}}function _(e,n){for(let[t,l]of n.families)e.families.has(t)||e.families.set(t,l);for(let t of n.styleIds)e.styleIds.add(t);e.anyText||=n.anyText,e.bareParagraph||=n.bareParagraph,e.bareRun||=n.bareRun,e.bareTable||=n.bareTable;}function T(e,n){if(n===null)return;let t=n.toLowerCase();e.has(t)||e.set(t,n);}var fn=new Set(["tab","noBreakHyphen","softHyphen","footnoteRef","endnoteRef","footnoteReference","endnoteReference"]),dn=128;function cn(e){for(let n of e.attributes)if(n.localName==="font"&&!(n.namespaceUri!==fa&&n.namespaceUri!==""))return n.value.length>0&&n.value.length<=dn;return false}function $(e,n){if(n?.has(e.id))return true;for(let t of e.children)if(!(!x(t)||t.namespaceUri!==fa)){if(fn.has(t.localName))return true;if(t.localName==="sym"){if(!cn(t))return true;continue}if(!(t.localName!=="t"&&t.localName!=="delText")){for(let l of t.children)if(!x(l)&&l.value.length>0)return true}}return false}function mn(e){for(let n of e.children)if(!(!x(n)||n.namespaceUri!==fa)&&!(n.localName!=="t"&&n.localName!=="delText")){for(let t of n.children)if(!x(t))for(let l of t.value){let i=l.codePointAt(0);if(i>=4352&&i<=4607||i>=11904&&i<=40959||i>=43360&&i<=43391||i>=44032&&i<=55295||i>=63744&&i<=64255||i>=65072&&i<=65103||i>=65280&&i<=65519||i>=131072&&i<=262143)return true}}return false}function K(e,n){let t=[e];for(;t.length>0;){let l=t.pop();if(x(l)){if(n?.has(l.id))return true;if(l.localName==="r"&&l.namespaceUri===fa){if($(l,n))return true;continue}for(let i of l.children)t.push(i);}}return false}function yn(e,n,t,l){if(!$(e,l))return;n.anyText=true;let i=c(e,"rPr"),r=i?c(i,"rFonts"):void 0;r&&(T(n.families,v(r,t)),mn(e)&&T(n.families,C(r,t)));let a=i?c(i,"rStyle"):void 0,s=D(a?M(a,"val"):void 0);s!==null?n.styleIds.add(s):n.bareRun=true;}function gn(e,n,t){if(!t)return;n.anyText=true;let l=e.localName==="tbl",i=c(e,l?"tblPr":"pPr"),r=i?c(i,l?"tblStyle":"pStyle"):void 0,a=D(r?M(r,"val"):void 0);a!==null?n.styleIds.add(a):l?n.bareTable=true:n.bareParagraph=true;}function X(e){return (e.localName==="p"||e.localName==="tbl")&&e.namespaceUri===fa}function U(e,n,t,l,i){e.namespaceUri===fa&&(i?.has(e.id)&&e.localName==="fldSimple"&&(n.anyText=true,n.bareRun=true),e.localName==="r"?yn(e,n,t,i):X(e)&&gn(e,n,l));}var W=new WeakMap;function q(e,n,t){let l=W.get(e);if(l&&l.major===n.major&&l.minor===n.minor&&l.majorEastAsia===n.majorEastAsia&&l.minorEastAsia===n.minorEastAsia&&l.majorBidi===n.majorBidi&&l.minorBidi===n.minorBidi)return l.summary;let i=H();if(e.children.length>=on&&t<rn){for(let r of e.children)x(r)&&_(i,q(r,n,t+1));U(e,i,n,i.anyText);}else {let r=[e];for(;r.length>0;){let a=r.pop();if(!x(a))continue;let s=X(a)&&K(a);U(a,i,n,s);for(let u=a.children.length-1;u>=0;u-=1)r.push(a.children[u]);}}return W.set(e,{major:n.major,minor:n.minor,majorEastAsia:n.majorEastAsia,minorEastAsia:n.minorEastAsia,majorBidi:n.majorBidi,minorBidi:n.minorBidi,summary:i}),i}var xn={docDefaultFamilies:[],defaultParagraph:null,defaultCharacter:null,defaultTable:null,chainFamilies:()=>[]},Z=new WeakMap;function w(e,n){let t=c(e,"rPr"),l=t?c(t,"rFonts"):void 0;return l?v(l,n):null}function k(e,n){let t=c(e,"rPr"),l=t?c(t,"rFonts"):void 0;return l?C(l,n):null}function hn(e,n){let t=new Map,l=null,i=null,r=null,a=null,s=null,u=c(e,"docDefaults"),o=u?c(u,"rPrDefault"):void 0;o&&(l=w(o,n),i=k(o,n));let f=o?c(o,"rPr"):void 0,m=f?c(f,"rFonts"):void 0;m&&["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(d=>!!M(m,d))||(l??=n.minor);let y=0;for(let d of e.children){if(!x(d)||d.localName!=="style")continue;if(y>=sn)break;y+=1;let h=D(M(d,"styleId"));if(h===null)continue;let S=c(d,"basedOn"),F=[];for(let p of d.children){if(!x(p)||p.localName!=="tblStylePr")continue;let L=w(p,n);L!==null&&F.push(L);let R=k(p,n);R!==null&&F.push(R);}t.set(h,{basedOn:D(S?M(S,"val"):void 0),family:w(d,n),eastAsiaFamily:k(d,n),conditionalFamilies:F});let A=un(M(d,"default")),j=M(d,"type");j==="paragraph"?A?r=h:r===h&&(r=null):j==="character"?A?a=h:a===h&&(a=null):j==="table"&&(A?s=h:s===h&&(s=null));}let g=new Map,I=d=>{if(d===null)return [];let h=g.get(d);if(h)return h;let S=[],F=null,A=null,j=new Set,p=d;for(let L=0;p!==null&&L<an&&!j.has(p);L+=1){j.add(p);let R=t.get(p);if(!R)break;F??=R.family,A??=R.eastAsiaFamily,S.push(...R.conditionalFamilies),p=R.basedOn;}return F!==null&&S.unshift(F),A!==null&&S.unshift(A),g.set(d,S),S};return {docDefaultFamilies:[l,i].filter(d=>d!==null),defaultParagraph:r,defaultCharacter:a,defaultTable:s,chainFamilies:I}}function bn(e,n){if(!e)return {...xn,docDefaultFamilies:n.minor?[n.minor]:[]};let t=Z.get(e);if(t&&t.major===n.major&&t.minor===n.minor&&t.majorEastAsia===n.majorEastAsia&&t.minorEastAsia===n.minorEastAsia&&t.majorBidi===n.majorBidi&&t.minorBidi===n.minorBidi)return t.index;let l=hn(e,n);return Z.set(e,{major:n.major,minor:n.minor,majorEastAsia:n.majorEastAsia,minorEastAsia:n.minorEastAsia,majorBidi:n.majorBidi,minorBidi:n.minorBidi,index:l}),l}function En(e,n,t,l){let i=H(),r=new Map;for(let o of e){let f=H();for(let m of o.children){if(!x(m))continue;if(!l||l.size===0){_(f,q(m,t,0));continue}let b=H(),y=[m];for(;y.length>0;){let g=y.pop();if(!x(g))continue;let I=X(g)&&K(g,l);U(g,b,t,I,l);for(let E=g.children.length-1;E>=0;E-=1)y.push(g.children[E]);}_(f,b);}_(i,f);for(let m of f.families.values())T(r,m);}let a=bn(n,t),s=new Map;for(let o of i.styleIds)for(let f of a.chainFamilies(o))T(s,f);if(i.bareParagraph)for(let o of a.chainFamilies(a.defaultParagraph))T(s,o);if(i.bareRun)for(let o of a.chainFamilies(a.defaultCharacter))T(s,o);if(i.bareTable)for(let o of a.chainFamilies(a.defaultTable))T(s,o);if(i.anyText)for(let o of a.docDefaultFamilies)T(s,o);for(let o of r.keys())s.delete(o);let u=[...s.values()].sort((o,f)=>o<f?-1:o>f?1:0);return Object.freeze({direct:Object.freeze([...r.values()]),inherited:Object.freeze(u)})}function An(e,n,t){let l=En(e,n,t),i=[...l.direct,...l.inherited];return i.sort((r,a)=>r<a?-1:r>a?1:0),i}export{tn as a,On as b,Sn as c,En as d,An as e};
|