@betteroffice/docx 0.0.1 → 0.0.3
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 +19 -0
- package/dist/chunk-AEQOEQJ7.mjs +57 -0
- package/dist/chunk-AZ52IWB6.mjs +16 -0
- package/dist/{chunk-SINEY6ZF.mjs → chunk-B4IR6YP4.mjs} +1 -1
- package/dist/chunk-GGEGIQRK.mjs +1 -0
- package/dist/chunk-IFT6DUJX.mjs +1 -0
- package/dist/chunk-J7LNO6SM.mjs +1 -0
- package/dist/{chunk-H3JCIGWK.mjs → chunk-NJHOPXZW.mjs} +1 -1
- package/dist/{chunk-KXNZFTTK.mjs → chunk-WBH3SXI6.mjs} +1 -1
- package/dist/chunk-WON6K4FY.mjs +1 -0
- package/dist/chunk-Y7RUNRU2.mjs +1 -0
- package/dist/collaboration/index.d.mts +65 -0
- package/dist/collaboration/index.mjs +1 -0
- package/dist/{content-sSHuWw49.d.mts → content-MOZ6hKP4.d.mts} +357 -357
- package/dist/core.d.mts +148 -341
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-p-ijSzdh.d.mts → displayListQueries-BJlo7Jkz.d.mts} +24 -6
- package/dist/docx/index.d.mts +40 -520
- package/dist/docx/index.mjs +2 -2
- package/dist/editor/index.d.mts +36 -151
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-Bx6DK6-2.d.mts → fontLoader-aSewHMKF.d.mts} +65 -63
- package/dist/{formatting-DoL7KBSL.d.mts → formatting-D1EPSaJP.d.mts} +1 -1
- package/dist/{rustDisplayList-dqunvwxH.d.mts → frameDelta-D965X8yK.d.mts} +3 -274
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/index-Dx4Z3lkz.d.mts +1010 -0
- package/dist/layout/index.d.mts +19 -240
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +10 -58
- package/dist/layout/pagination/index.mjs +1 -1
- package/dist/layout/render/index.d.mts +11 -11
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +9 -9
- package/dist/plugin-api/index.d.mts +191 -6
- package/dist/plugin-api/resolveItemPositions.d.mts +4 -5
- package/dist/rustDisplayList-BRuZBqdL.d.mts +278 -0
- package/dist/rustMeasureSource-D1KsQvVC.d.mts +106 -0
- package/dist/selectiveSave-CVoajSKE.d.mts +56 -0
- package/dist/styles/index.d.mts +4 -39
- package/dist/styles/index.mjs +1 -1
- package/dist/{styles-VxNcXLdi.d.mts → styles-Dn_o3Vo5.d.mts} +2 -2
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +40 -14
- package/dist/{types-DNrYr6yQ.d.mts → types-BfqUl2h_.d.mts} +3 -71
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +110 -576
- package/dist/utils/index.mjs +1 -84
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/units.d.mts +33 -2
- package/dist/wasm-DO3BUV7C.mjs +1 -0
- package/dist/wasm-NWXX4H5G.mjs +1 -0
- package/dist/wasm-edit.d.mts +14 -5
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +10 -1
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +6 -881
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +16 -139
- package/dist/Subscribable-DOz6Ohoo.d.mts +0 -33
- package/dist/agent/index.d.mts +0 -531
- package/dist/agent/index.mjs +0 -1
- package/dist/chunk-34K66SY4.mjs +0 -1
- package/dist/chunk-4RCISPPE.mjs +0 -1
- package/dist/chunk-52GB3Y42.mjs +0 -1
- package/dist/chunk-6NEKRDXF.mjs +0 -1
- package/dist/chunk-6PW4CWUG.mjs +0 -1
- package/dist/chunk-7DEIW7FL.mjs +0 -1
- package/dist/chunk-7PCO5I2O.mjs +0 -1
- package/dist/chunk-BI3B33LI.mjs +0 -1
- package/dist/chunk-BIQWVK5P.mjs +0 -2
- package/dist/chunk-CIRN3LZA.mjs +0 -1
- package/dist/chunk-DXKG3HQ5.mjs +0 -16
- package/dist/chunk-FPZBTOD6.mjs +0 -1
- package/dist/chunk-FZIA7OFY.mjs +0 -1
- package/dist/chunk-GWKJ2Y4Y.mjs +0 -1
- package/dist/chunk-HJGAQIU7.mjs +0 -2
- package/dist/chunk-I6KKMUUC.mjs +0 -1
- package/dist/chunk-IL5JZJT7.mjs +0 -1
- package/dist/chunk-JY6ILTNS.mjs +0 -1
- package/dist/chunk-KEE52TT5.mjs +0 -1
- package/dist/chunk-KVKLLTDP.mjs +0 -58
- package/dist/chunk-L5ISVQ3W.mjs +0 -1
- package/dist/chunk-LDUWIM7M.mjs +0 -1
- package/dist/chunk-N5Q3YN64.mjs +0 -1
- package/dist/chunk-NEWOMDTX.mjs +0 -1
- package/dist/chunk-O2QSE2I7.mjs +0 -1
- package/dist/chunk-OJOHXQNQ.mjs +0 -1
- package/dist/chunk-OMR3TWCD.mjs +0 -2
- package/dist/chunk-P3KDV4M2.mjs +0 -1
- package/dist/chunk-Q7PO7V73.mjs +0 -1
- package/dist/chunk-QOUFE3VX.mjs +0 -1
- package/dist/chunk-TYHI7RAD.mjs +0 -1
- package/dist/chunk-UIEJWORW.mjs +0 -1
- package/dist/chunk-VAOUFAUH.mjs +0 -1
- package/dist/chunk-VBOTMRXV.mjs +0 -1
- package/dist/chunk-VCER63GQ.mjs +0 -1
- package/dist/chunk-WAUF2UC7.mjs +0 -2
- package/dist/chunk-X4XDO3LZ.mjs +0 -1
- package/dist/chunk-XQBCCJBO.mjs +0 -9
- package/dist/chunk-XWUOLYRQ.mjs +0 -2
- package/dist/chunk-XYH6XWP3.mjs +0 -10
- package/dist/chunk-YBIM6UJV.mjs +0 -8
- package/dist/chunk-YCIH2Q3E.mjs +0 -1
- package/dist/chunk-ZOV5KL7C.mjs +0 -1
- package/dist/colorResolver-n0o7H7ep.d.mts +0 -290
- package/dist/core-plugins.d.mts +0 -37
- package/dist/core-plugins.mjs +0 -1
- package/dist/docx/parser.d.mts +0 -41
- package/dist/docx/parser.mjs +0 -1
- package/dist/docx/rezip.d.mts +0 -148
- package/dist/docx/rezip.mjs +0 -1
- package/dist/docx/serializer/index.d.mts +0 -42
- package/dist/docx/serializer/index.mjs +0 -1
- package/dist/editorTree-DO5PyDK8.d.mts +0 -37
- package/dist/executor-7O2RBJ2B.mjs +0 -1
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +0 -316
- package/dist/headless.d.mts +0 -69
- package/dist/headless.mjs +0 -1
- package/dist/layout/flow/index.d.mts +0 -149
- package/dist/layout/flow/index.mjs +0 -1
- package/dist/layout/measure/index.d.mts +0 -324
- package/dist/layout/measure/index.mjs +0 -1
- package/dist/layout/pagination/types.d.mts +0 -4
- package/dist/layout/pagination/types.mjs +0 -1
- package/dist/managers/AutoSaveManager.d.mts +0 -81
- package/dist/managers/AutoSaveManager.mjs +0 -1
- package/dist/managers/TableSelectionManager.d.mts +0 -74
- package/dist/managers/TableSelectionManager.mjs +0 -1
- package/dist/managers/types.d.mts +0 -113
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +0 -142
- package/dist/mcp.d.mts +0 -162
- package/dist/mcp.mjs +0 -16
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +0 -109
- package/dist/measuredBlock-DZwz8zhD.d.mts +0 -26
- package/dist/plugin-api/types.d.mts +0 -193
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +0 -1
- package/dist/registry-DMM5VTdT.d.mts +0 -165
- package/dist/rustPagination-Bj2hq013.d.mts +0 -106
- package/dist/sectionConfigs-DW3J8q0X.d.mts +0 -55
- package/dist/selectionContext-Buc9BCU1.d.mts +0 -570
- package/dist/selectiveSave-oFBJ1n71.d.mts +0 -16
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +0 -23
- package/dist/settingsParser-CcGvtmCK.d.mts +0 -33
- package/dist/types/agentApi.d.mts +0 -456
- package/dist/types/agentApi.mjs +0 -1
- package/dist/types-dYdjUZMo.d.mts +0 -311
- package/dist/units-O5Y02RKQ.d.mts +0 -34
- package/dist/utils/headingCollector.d.mts +0 -28
- package/dist/utils/headingCollector.mjs +0 -1
- package/dist/utils/highlightColors.d.mts +0 -14
- package/dist/utils/highlightColors.mjs +0 -1
- package/dist/utils/textSelection.d.mts +0 -92
- package/dist/utils/textSelection.mjs +0 -1
- package/dist/variableDetector-Borj29SF.d.mts +0 -115
- package/dist/wasm-FZQ5XB2Y.mjs +0 -1
- package/dist/wasm-SA237OSP.mjs +0 -1
- package/dist/watermarkApi-DCxjutkg.d.mts +0 -38
package/dist/yrs/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b as b$3,c as c$3}from'../chunk-GWKJ2Y4Y.mjs';import {h}from'../chunk-L5ISVQ3W.mjs';import'../chunk-I6KKMUUC.mjs';import'../chunk-ZOV5KL7C.mjs';import {c as c$2,d}from'../chunk-HJGAQIU7.mjs';import {e}from'../chunk-FZIA7OFY.mjs';import {b as b$2}from'../chunk-OBQGPMPQ.mjs';import {L}from'../chunk-YBIM6UJV.mjs';import {c,a}from'../chunk-KXNZFTTK.mjs';import'../chunk-BIQWVK5P.mjs';import {c as c$1,b as b$1}from'../chunk-3UBMCDME.mjs';import {b}from'../chunk-TTRUPDAB.mjs';function In(e,t){let n=0,r=t.map(o=>{let s={paraId:o.paraId,length:Math.max(0,Math.trunc(o.length)),displayStart:n};return n+=s.length+2,s});return {story:e,paragraphs:r}}function Ae(e,t){let n=e.paragraphs.find(r=>r.paraId===t.paraId);return !n||t.story!==e.story?e.paragraphs[0]?.displayStart??0:n.displayStart+1+Math.min(Math.max(0,t.offset),n.length)}function vn(e,t){if(e.paragraphs.length===0)return null;let n=Math.max(0,Math.trunc(t)),r=e.paragraphs[0];for(let o of e.paragraphs){if(o.displayStart>n)break;r=o;}return {story:e.story,paraId:r.paraId,offset:Math.min(Math.max(0,n-(r.displayStart+1)),r.length)}}function An(e,t,n){return Ae(e,t)-Ae(e,n)}var ie=class{constructor(){b(this,"worker");b(this,"pending",new Map);b(this,"nextId",1);b(this,"destroyed",false);b(this,"ready",false);b(this,"revision",0);this.worker=new Worker(new URL("./residentEngineWorker.mjs",import.meta.url),{type:"module",name:"openooxml-resident-engine"}),this.worker.onmessage=t=>{let n=t.data,r=this.pending.get(n.id);r&&(this.pending.delete(n.id),r.timeout&&clearTimeout(r.timeout),n.ok?r.resolve(n):r.reject(ft(n.error,n.residentUnavailable)));},this.worker.onerror=t=>{this.failAll(new Error(`Resident engine worker failed: ${t.message}`)),this.ready=false;},this.worker.onmessageerror=()=>{this.failAll(new Error("Resident engine worker returned an unreadable message")),this.ready=false;};}isReady(){return this.ready}layoutRevision(){return this.revision}async bootstrap(t,n){let r=await this.request({type:"bootstrap",snapshot:t,extras:n,expectedFrameEpoch:0},Fe(t),15e3),o=z(r);return this.ready=true,this.revision=o.layoutRevision,o}async sync(t,n,r){let o=await this.request({type:"sync",snapshot:t,extras:n,expectedFrameEpoch:r},Fe(t)),s=z(o);return this.ready=true,this.revision=s.layoutRevision,s}async buildFrame(t,n){return z(await this.request({type:"buildFrame",extras:t,expectedFrameEpoch:n}))}async applyInput(t,n,r,o=false){if(!this.ready)return {applied:false};try{return {applied:!0,...z(await this.request({type:"applyInput",text:t,selection:n,expectedFrameEpoch:r,profile:o}))}}catch(s){if(s instanceof H)return {applied:false};throw s}}async applyDelete(t,n,r,o=false){if(!this.ready)return {applied:false};try{return {applied:!0,...z(await this.request({type:"applyDelete",direction:t,selection:n,expectedFrameEpoch:r,profile:o}))}}catch(s){if(s instanceof H)return {applied:false};throw s}}invalidate(t,n){if(this.destroyed)return;this.ready=false;let r=t.slice(),s={id:this.nextId++,type:"applyUpdate",update:r,selection:n};this.worker.postMessage(s,[r.buffer]);}async attachCanvases(t,n,r,o){let s=t.map(l=>l.canvas);await this.request({type:"attachCanvases",pages:t,activePageIds:n,devicePixelRatio:r,zoom:o},s);}destroy(){if(this.destroyed)return;this.destroyed=true;let n={id:this.nextId++,type:"destroy"};this.worker.postMessage(n),this.worker.terminate(),this.failAll(new Error("Resident engine worker was destroyed")),this.ready=false;}request(t,n=[],r){if(this.destroyed)return Promise.reject(new Error("Resident engine worker was destroyed"));let o=this.nextId++;return new Promise((s,l)=>{let a=r?setTimeout(()=>{let d=this.pending.get(o);if(!d)return;this.pending.delete(o);let p=new Error(`Resident engine worker did not acknowledge ${t.type} within ${r}ms`);d.reject(p),this.failAll(p),this.ready=false,this.destroyed=true,this.worker.terminate();},r):null;this.pending.set(o,{resolve:s,reject:l,timeout:a}),this.worker.postMessage({...t,id:o},n);})}failAll(t){for(let n of this.pending.values())n.timeout&&clearTimeout(n.timeout),n.reject(t);this.pending.clear();}},H=class extends Error{};function ft(e,t=false){return t?new H(e):new Error(e)}function Fe(e){return [e.state.buffer,...e.fonts.map(t=>t.buffer)]}function z(e){if(!e.frame)throw new Error("Resident engine worker response omitted its FrameDelta");return {frame:new Uint8Array(e.frame),updates:(e.updates??[]).map(t=>new Uint8Array(t)),engineMs:e.engineMs??0,workerTotalMs:e.workerTotalMs??0,engineProfile:e.engineProfile,replayMs:e.replayMs??0,replayedPages:e.replayedPages??0,layoutRevision:e.layoutRevision??0}}function pt(){return typeof Worker<"u"}function le(e){return {sdtType:e.sdtType,id:e.id??null,alias:e.alias??null,tag:e.tag??null,lock:e.lock??null,placeholder:e.placeholder??null,showingPlaceholder:e.showingPlaceholder??false,dateFormat:e.dateFormat??null,listItems:e.listItems?JSON.stringify(e.listItems):null,checked:e.checked??null,dataBinding:e.dataBinding?JSON.stringify(e.dataBinding):null,rawPropertiesXml:e.rawPropertiesXml??null,rawEndPropertiesXml:e.rawEndPropertiesXml??null}}function se(e){let t={sdtType:e.sdtType??"richText"};if(typeof e.id=="number"&&(t.id=e.id),e.alias!=null&&(t.alias=String(e.alias)),e.tag!=null&&(t.tag=String(e.tag)),e.lock!=null&&(t.lock=e.lock),e.placeholder!=null&&(t.placeholder=String(e.placeholder)),e.showingPlaceholder&&(t.showingPlaceholder=true),e.dateFormat!=null&&(t.dateFormat=String(e.dateFormat)),typeof e.listItems=="string"&&e.listItems)try{t.listItems=JSON.parse(e.listItems);}catch{}if(e.checked!=null&&(t.checked=e.checked),typeof e.dataBinding=="string"&&e.dataBinding)try{t.dataBinding=JSON.parse(e.dataBinding);}catch{}return e.rawPropertiesXml!=null&&(t.rawPropertiesXml=String(e.rawPropertiesXml)),e.rawEndPropertiesXml!=null&&(t.rawEndPropertiesXml=String(e.rawEndPropertiesXml)),t}function ae(e,t){let n=e.shapeType||"rect",r=e.geometryPath?.length?e.geometryPath:d(n);if(!r)return null;let o=b$3(b$1(e.size?.width)||100,b$1(e.size?.height)||80,t);return {kind:"shape",id:c$3(),shapeType:n,geometryPath:r,fill:mt(e),stroke:ht(e),transform:yt(e),width:o.width,height:o.height,x:e.offset?b$1(e.offset.x):void 0,y:e.offset?b$1(e.offset.y):void 0,innerText:e.textBody?.content.map(bt),children:(e.children??[]).map(s=>ae(s,t)).filter(s=>s!=null),scene:e.scene,effects:e.effects,textBodyProperties:e.textBodyProperties}}function gt(e){if(e?.kind){if(e.kind==="pattern")return {type:"pattern",color:c$2(e.foregroundColor??e.color),patternPreset:e.patternPreset,foregroundColor:c$2(e.foregroundColor),backgroundColor:c$2(e.backgroundColor)};if(e.kind==="picture"){let t=e.picture?.src;return {type:"picture",color:c$2(e.color),pictureRelId:e.picture?.rId,pictureSrc:t&&(t.startsWith("data:")||t.startsWith("blob:"))?t:void 0,pictureSrcRect:e.srcRect,pictureFillMode:e.fillMode,pictureTile:e.tile,pictureStretchRect:e.stretchRect,pictureOpacity:e.pictureOpacity}}if(e.kind==="theme")return {type:"solid",color:c$2(e.color),themeRefIndex:e.themeRefIndex}}}function mt(e){let t=gt(e.fillPaint);if(t)return t;if(e.fill)return e.fill.type==="none"?{type:"none"}:e.fill.type==="gradient"?{type:"gradient",color:c$2(e.fill.color),gradientType:e.fill.gradient?.type,gradientAngle:e.fill.gradient?.angle,gradientStops:e.fill.gradient?.stops.map(n=>({position:n.position,color:c$2(n.color)??"#000000"}))}:{type:e.fill.type,color:c$2(e.fill.color)}}function ht(e){if(e.outline)return {color:c$2(e.outline.color),width:e.outline.width!=null?b$1(e.outline.width):void 0,dash:e.outline.style}}function yt(e){let t={};return e.transform?.rotation!=null&&(t.rotation=e.transform.rotation),e.transform?.flipH&&(t.flipH=true),e.transform?.flipV&&(t.flipV=true),Object.keys(t).length>0?t:void 0}function bt(e){let t=e.formatting?.alignment,n=t==="both"?"justify":t==="left"||t==="center"||t==="right"?t:void 0;return {kind:"paragraph",id:c$3(),paraId:e.paraId,runs:e.content.flatMap(kt),attrs:n?{alignment:n}:{}}}function kt(e){return e.type==="run"?Ye(e):e.type==="hyperlink"?e.children.flatMap(t=>t.type==="run"?Ye(t):[]):[]}function Ye(e){let t=St(e.formatting),n=[];for(let r of e.content)r.type==="text"&&r.text?n.push({kind:"text",text:r.text,...t}):r.type==="tab"?n.push({kind:"tab",...t}):r.type==="break"&&n.push({kind:"lineBreak"});return n}function St(e){let t={};if(!e)return t;e.bold&&(t.bold=true),e.boldCs!=null&&(t.boldCs=e.boldCs),e.italic&&(t.italic=true),e.italicCs!=null&&(t.italicCs=e.italicCs),e.underline&&(t.underline=true),e.strike&&(t.strike=true);let n=c$2(e.color);n&&(t.color=n),e.fontSize!=null&&(t.fontSize=e.fontSize/2),e.fontSizeCs!=null&&(t.fontSizeCs=e.fontSizeCs/2),e.fontFamily&&(t.fontSlots={...e.fontFamily});let r=e.fontFamily?.ascii??e.fontFamily?.hAnsi??e.fontFamily?.eastAsia??e.fontFamily?.cs;return r&&(t.fontFamily=r),e.cs!=null&&(t.complexScript=e.cs),e.language&&(t.language={...e.language}),t}function N(e){if(Array.isArray(e))return e.map(N);if(e!==null&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[n]=N(r));return t}return e}var Rt={styleId:"pStyle",_sectionProperties:"sectPr"},Tt=new Set(["paraId","textId","renderedPageBreakBefore","numPrFromStyle"]);function Be(e){let t={};for(let[n,r]of Object.entries(e))Tt.has(n)||r===null||r===void 0||(t[Rt[n]??n]=N(r));return t}var xt=new Set(["columnWidths"]);function X(e,t=new Set){let n={};for(let[r,o]of Object.entries(e))t.has(r)||o===null||o===void 0||(n[r]=N(o));return n}function Me(e){return X(e,xt)}function _e(e){let t=e.columnWidths;return Array.isArray(t)?t.map(N):[]}function Ne(e){return X(e)}function Oe(e,t){let n=X(e);return t&&(n.header=true),n}function de(e,t,n,r){return `${e}:t${t}:r${n}c${r}`}function Ee(e,t){return `${e}:sdt${t}`}function Le(e){return X(e)}function G(e){return `hf:${e}`}function De(e){return `fn:${e}`}var Pt=new Set(["bold","italic","superscript","subscript","allCaps","smallCaps","emboss","imprint","textShadow","textOutline","hidden","rtl"]);function j(e){if(e==null)return "null";if(Array.isArray(e))return `[${e.map(j).join(",")}]`;if(typeof e=="object"){let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${j(t[n])}`).join(",")}}`}return JSON.stringify(e)}function wt(e,t){if(!e||!t)return e;let n=t.resolveRunStyle(e.styleId);return n?a(n,e):e}function je(e){if(!e)return [];let t=[],n=(l,a={})=>t.push({name:l,attrs:a});e.bold&&n("bold"),e.italic&&n("italic"),e.underline&&e.underline.style!=="none"&&n("underline",{style:e.underline.style,color:e.underline.color??null}),(e.strike||e.doubleStrike)&&n("strike",{double:e.doubleStrike||false}),e.color&&!e.color.auto&&n("textColor",{rgb:e.color.rgb??null,themeColor:e.color.themeColor??null,themeTint:e.color.themeTint??null,themeShade:e.color.themeShade??null});let r=e.shading?.fill,o=(!e.shading?.pattern||e.shading.pattern==="clear")&&r?.rgb&&!r.auto?h(r.rgb):void 0,s=e.highlight&&e.highlight!=="none"?e.highlight:o;return s&&n("highlight",{color:s}),(e.fontSize!=null||e.fontSizeCs!=null)&&n("fontSize",{size:e.fontSize??null,sizeCs:e.fontSizeCs??null}),e.fontFamily&&n("fontFamily",{ascii:e.fontFamily.ascii??null,hAnsi:e.fontFamily.hAnsi??null,eastAsia:e.fontFamily.eastAsia??null,cs:e.fontFamily.cs??null,asciiTheme:e.fontFamily.asciiTheme??null,hAnsiTheme:e.fontFamily.hAnsiTheme??null,eastAsiaTheme:e.fontFamily.eastAsiaTheme??null,csTheme:e.fontFamily.csTheme??null}),e.vertAlign==="superscript"?n("superscript"):e.vertAlign==="subscript"&&n("subscript"),e.allCaps&&n("allCaps"),e.smallCaps&&n("smallCaps"),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&n("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null}),e.emboss&&n("emboss"),e.imprint&&n("imprint"),e.shadow&&n("textShadow"),e.emphasisMark&&e.emphasisMark!=="none"&&n("emphasisMark",{type:e.emphasisMark}),e.outline&&n("textOutline"),e.hidden&&n("hidden"),e.rtl&&n("rtl"),e.effect&&e.effect!=="none"&&n("textEffect",{effect:e.effect}),e.modernEffects&&n("modernTextEffects",{effects:e.modernEffects}),e.styleId&&n("runStyle",{styleId:e.styleId}),t}function Ue(e){let t={};for(let n of e)n.name==="comment"||n.name==="footnoteRef"||(Pt.has(n.name)?t[n.name]=true:n.name==="highlight"?t.highlight=n.attrs.color:n.name==="insertion"||n.name==="deletion"?t[n.name==="insertion"?"ins":"del"]=N({id:n.attrs.revisionId,author:n.attrs.author,date:n.attrs.date}):t[n.name]=N(n.attrs));return t}function Ct(e){return e.filter(t=>t.name!=="hyperlink"&&t.name!=="comment").map(t=>`${t.name}:${JSON.stringify(t.attrs)}`).sort().join("|")}function It(e,t){return [...e.filter(n=>n.name!==t.name),t]}function $(e,t,n){return {kind:"text",text:e,attrs:Ue(t),pmSize:e.length,...n!==void 0?{commentId:n}:{},marks:[...t]}}function I(e,t,n=[],r,o=1){return {kind:"embed",embedKind:e,payload:t,attrs:Ue(n),pmSize:o,...r!==void 0?{commentId:r}:{},marks:[...n]}}function ze(e,t,n){let r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0;return je(a(a(t,r),e.formatting))}function vt(e){let t=e.size?.width?b$1(e.size.width):void 0,n=e.size?.height?b$1(e.size.height):void 0,r=e.wrap.type,o=e.wrap.wrapText,s=e.position?.horizontal?.alignment,l;r==="inline"||r==="topAndBottom"?l="none":r==="square"||r==="tight"||r==="through"?o==="left"?l="right":o==="right"?l="left":s==="left"||s==="right"?l=s:l="none":l="none";let a=r==="inline"?"inline":r==="topAndBottom"?"block":b$2(r)||l&&l!=="none"?"float":"block",d=[];e.transform?.rotation&&d.push(`rotate(${e.transform.rotation}deg)`),e.transform?.flipH&&d.push("scaleX(-1)"),e.transform?.flipV&&d.push("scaleY(-1)");let p,c,f;if(e.outline?.width){p=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(c=`#${e.outline.color.rgb}`);let g={solid:"solid",dot:"dotted",dash:"dashed",lgDash:"dashed",dashDot:"dashed",lgDashDot:"dashed",lgDashDotDot:"dashed",sysDot:"dotted",sysDash:"dashed",sysDashDot:"dashed",sysDashDotDot:"dashed"};f=e.outline.style&&g[e.outline.style]||"solid";}return N({src:e.src||"",alt:e.alt??null,title:e.title??null,width:t??null,height:n??null,rId:e.rId??null,wrapType:r,displayMode:a,cssFloat:l??null,transform:d.length>0?d.join(" "):null,distTop:e.wrap.distT!=null?b$1(e.wrap.distT):null,distBottom:e.wrap.distB!=null?b$1(e.wrap.distB):null,distLeft:e.wrap.distL!=null?b$1(e.wrap.distL):null,distRight:e.wrap.distR!=null?b$1(e.wrap.distR):null,position:e.position?{horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0}:null,borderWidth:p??null,borderColor:c??null,borderStyle:f??null,wrapText:o??null,hlinkHref:e.hlinkHref??null,cropTop:e.crop?.top??null,cropRight:e.crop?.right??null,cropBottom:e.crop?.bottom??null,cropLeft:e.crop?.left??null,opacity:e.opacity??null,effectExtentTop:e.padding?.top?b$1(e.padding.top):null,effectExtentBottom:e.padding?.bottom?b$1(e.padding.bottom):null,effectExtentLeft:e.padding?.left?b$1(e.padding.left):null,effectExtentRight:e.padding?.right?b$1(e.padding.right):null,layoutInCell:e.layoutInCell??null,allowOverlap:e.allowOverlap??null})}function At(e){let t=e.size?.width?b$1(e.size.width):100,n=e.size?.height?b$1(e.size.height):80,r,o="solid",s,l,a;e.fill&&(o=e.fill.type,r=c$2(e.fill.color),e.fill.type==="gradient"&&e.fill.gradient&&(s=e.fill.gradient.type,l=e.fill.gradient.angle,a=JSON.stringify(e.fill.gradient.stops.map(c=>({position:c.position,color:c$2(c.color)??"#000000"})))));let d=[];e.transform?.rotation&&d.push(`rotate(${e.transform.rotation}deg)`),e.transform?.flipH&&d.push("scaleX(-1)"),e.transform?.flipV&&d.push("scaleY(-1)");let p=e.outline?.width?Math.round(e.outline.width/914400*96*100)/100:1;return N({layoutBlockJson:JSON.stringify(ae(e)),shapeType:e.shapeType||"rect",geometryPath:e.geometryPath??null,shapeId:e.id??null,children:e.children?.length?JSON.stringify(e.children):null,width:t,height:n,fillPaint:e.fillPaint??null,fillColor:r??null,fillType:o,gradientType:s??null,gradientAngle:l??null,gradientStops:a??null,outlineWidth:p,outlineColor:c$2(e.outline?.color)??"#000000",outlineStyle:e.outline?.style||"solid",transform:d.length>0?d.join(" "):null,rotation:e.transform?.rotation??null,flipH:e.transform?.flipH??false,flipV:e.transform?.flipV??false,displayMode:"inline",wrapType:"inline",behindDoc:false,decorative:false,hidden:false})}function Ft(e){return N({chartJson:JSON.stringify(e),chartType:e.chartType??null,title:e.title??null,width:e.size?.width?b$1(e.size.width):320,height:e.size?.height?b$1(e.size.height):220,rId:e.rId??null,path:e.path??null})}function ce(e,t){let n="",r,o=e.type==="simpleField"?e.content:e.fieldResult;for(let a of o)if(a.type==="run"){for(let d of a.content)d.type==="text"&&(n+=d.text);!r&&a.formatting&&(r=a.formatting);}let s=r??(e.type==="complexField"?e.formatting:void 0),l=e.fieldTree?.displayMode??"result";return {payload:{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false,displayMode:l,hasCachedResult:n.length>0,fieldData:JSON.stringify(e),modelKind:"field"},marks:je(a(t,s))}}function fe(e){return {display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""}}function Yt(e){return {name:"hyperlink",attrs:{href:e.href||(e.anchor?`#${e.anchor}`:""),tooltip:e.tooltip??null,rId:e.rId??null}}}function Je(e,t,n,r){let o={name:"footnoteRef",attrs:{id:String(e),noteType:t}},s=[...n,o];return I("noteRef",t==="endnote"?{endnoteRefId:e}:{footnoteRefId:e},s,r,String(e).length)}function He(e,t,n){switch(e.type){case "text":return e.text?[$(e.text,t,n)]:[];case "tab":return [$(" ",t,n)];case "break":return e.breakType===void 0||e.breakType==="textWrapping"?[I("break",{},t,n)]:[];case "softHyphen":return [$("\xAD",t,n)];case "noBreakHyphen":return [$("\u2011",t,n)];case "symbol":{let r=Number.parseInt(e.char,16);if(!Number.isInteger(r)||r<0||r>1114111)return [];let o={name:"fontFamily",attrs:{ascii:e.font||null,hAnsi:e.font||null,eastAsia:e.font||null,cs:e.font||null,asciiTheme:null,hAnsiTheme:null,eastAsiaTheme:null,csTheme:null}};return [$(String.fromCodePoint(r),It(t,o),n)]}case "commentReference":return [I("field",{fieldType:"COMMENT",instruction:"",displayText:"",fieldKind:"simple",fldLock:false,dirty:false,displayMode:"result",hasCachedResult:false,modelKind:"commentReference",...e.id!==void 0?{commentId:e.id}:{}})];case "drawing":return [I("image",vt(e.image))];case "shape":return e.shape.textBody?.content.length?[]:[I("shape",At(e.shape))];case "chart":return [I("chart",Ft(e.chart))];case "footnoteRef":return [Je(e.id,"footnote",t,n)];case "endnoteRef":return [Je(e.id,"endnote",t,n)];default:return []}}function Q(e,t,n,r,o=[]){let s=[...ze(e,t,n),...o];return e.content.flatMap(l=>He(l,s,r))}function pe(e,t,n,r=[]){let o=[],s=Yt(e);for(let l of e.structuredChildren??e.children)if(l.type==="run"){let a=[...ze(l,t,n),...r,s];for(let d of l.content)o.push(...He(d,a));}else if(l.type==="simpleField"||l.type==="complexField"){let a=ce(l,t);o.push(I("field",a.payload,[...a.marks,...r,s]));}else l.type==="mathEquation"&&o.push(I("math",fe(l),[...r,s]));return o}function Bt(e,t,n){return {name:t,attrs:{revisionId:e.id,author:e.author,date:e.date??null,isMovePair:n}}}function Mt(e,t,n,r){let o=e.type==="insertion"||e.type==="moveTo"?"insertion":"deletion",s=Bt(e.info,o,e.type==="moveFrom"||e.type==="moveTo"),l=[];for(let a of e.content)if(a.type==="run")l.push(...Q(a,t,n,r,[s]));else {let d=pe(a,t,n,[s]);for(let p of d)r!==void 0&&(p.commentId=r);l.push(...d);}return l}function $e(e,t,n){let r=[],o=s=>{if(s.kind==="text"){if((s.text===" "?"tab":"text")==="tab"){r.push({kind:"tab",attrs:s.attrs});return}let a=r[r.length-1];a&&"text"in a&&j(a.attrs)===j(s.attrs)?a.text+=s.text:r.push({kind:"text",text:s.text,attrs:s.attrs});return}r.push({kind:s.embedKind,payload:s.payload,attrs:s.attrs});};for(let s of e.content)if(s.type==="run")Q(s,t,n).forEach(o);else if(s.type==="hyperlink")pe(s,t,n).forEach(o);else if(s.type==="simpleField"||s.type==="complexField"){let l=ce(s,t);o(I("field",l.payload,l.marks));}else s.type==="inlineSdt"?o(I("sdt",$e(s,t,n))):s.type==="mathEquation"&&o(I("math",fe(s)));return N({...le(e.properties),propertiesJson:JSON.stringify(e.properties),content:r})}function _t(e,t,n){let r=t?t.resolveParagraphStyle(e.formatting?.styleId).runFormatting:void 0;return a(r,n)}function Nt(e,t,n){let r=Q(e,t,n);if(r.some(a=>a.kind!=="text"&&a.embedKind!=="noteRef"))return null;let o=r.map(a=>Ct(a.marks));if(o.some(a=>a!==o[0]))return null;let s=r.map(a=>{if(a.kind==="text")return a.text;let d=a.payload.footnoteRefId??a.payload.endnoteRefId;return String(d??"")}).join(""),l=o[0];return {text:s,...l!==void 0?{marksKey:l}:{},...e.formatting?{formatting:e.formatting}:{},...e.propertyChanges?{propertyChanges:e.propertyChanges}:{}}}function Ot(e,t,n,r){let o=e.formatting,s=o?.styleId,l={paraId:e.paraId??null,textId:e.textId??null,styleId:s??null,numPr:o?.numPr??null,numPrFromStyle:o?.numPrFromStyle??null,listNumFmt:e.listRendering?.numFmt??null,listIsBullet:e.listRendering?.isBullet??null,listMarker:e.listRendering?.marker??null,listMarkerHidden:e.listRendering?.markerHidden||null,listMarkerFontFamily:e.listRendering?.markerFontFamily||null,listMarkerFontSize:e.listRendering?.markerFontSize||null,listMarkerSuffix:e.listRendering?.markerSuffix||null,listLevelNumFmts:e.listRendering?.levelNumFmts||null,listAbstractNumId:e.listRendering?.abstractNumId??null,listStartOverride:e.listRendering?.startOverride??null,_originalFormatting:o??null};if(t){let c=t.resolveParagraphStyle(s),f=c.paragraphFormatting;l.alignment=o?.alignment??f?.alignment??null,l.spaceBefore=o?.spaceBefore??f?.spaceBefore??null,l.spaceAfter=o?.spaceAfter??f?.spaceAfter??null,l.lineSpacing=o?.lineSpacing??f?.lineSpacing??null,l.lineSpacingRule=o?.lineSpacingRule??f?.lineSpacingRule??null,l.spacingExplicit=o?.spacingExplicit||null,l.indentLeft=o?.indentLeft??f?.indentLeft??null,l.indentRight=o?.indentRight??f?.indentRight??null;let m=o?.numPr?.numId===0&&f?.numPr&&f.numPr.numId!==0?void 0:f;l.indentFirstLine=o?.indentFirstLine??m?.indentFirstLine??null,l.hangingIndent=o?.hangingIndent??m?.hangingIndent??false,l.borders=o?.borders??f?.borders??null,l.shading=o?.shading??f?.shading??null,l.tabs=o?.tabs??f?.tabs??null,l.pageBreakBefore=o?.pageBreakBefore??f?.pageBreakBefore??null,l.keepNext=o?.keepNext??f?.keepNext??null,l.keepLines=o?.keepLines??f?.keepLines??null,l.contextualSpacing=o?.contextualSpacing??f?.contextualSpacing??null,l.outlineLevel=o?.outlineLevel??f?.outlineLevel??null,l.bidi=o?.bidi??f?.bidi??null;let y=t.getDefaultCharacterStyle()?.rPr,k=y?a(c.runFormatting,y):c.runFormatting;l.defaultTextFormatting=a(k,wt(o?.runProperties,t))??null,!o?.numPr&&f?.numPr&&f.numPr.numId!==0&&(l.numPr=f.numPr,l.numPrFromStyle=f.numPr);}else l.alignment=o?.alignment??null,l.spaceBefore=o?.spaceBefore??null,l.spaceAfter=o?.spaceAfter??null,l.lineSpacing=o?.lineSpacing??null,l.lineSpacingRule=o?.lineSpacingRule??null,l.spacingExplicit=o?.spacingExplicit||null,l.indentLeft=o?.indentLeft??null,l.indentRight=o?.indentRight??null,l.indentFirstLine=o?.indentFirstLine??null,l.hangingIndent=o?.hangingIndent??false,l.borders=o?.borders??null,l.shading=o?.shading??null,l.tabs=o?.tabs??null,l.pageBreakBefore=o?.pageBreakBefore??null,l.keepNext=o?.keepNext??null,l.keepLines=o?.keepLines??null,l.outlineLevel=o?.outlineLevel??null,l.bidi=o?.bidi??null,l.defaultTextFormatting=o?.runProperties??null;if(e.sectionProperties){l._sectionProperties=e.sectionProperties;let c=e.sectionProperties.sectionStart;(c==="nextPage"||c==="continuous"||c==="oddPage"||c==="evenPage")&&(l.sectionBreakType=c);}e.renderedPageBreakBefore&&(l.renderedPageBreakBefore=true),Dt(e)&&(l.pageBreakBefore=true),e.pPrIns&&(l.pPrIns={revisionId:e.pPrIns.id,author:e.pPrIns.author,date:e.pPrIns.date??null}),e.pPrDel&&(l.pPrDel={revisionId:e.pPrDel.id,author:e.pPrDel.author,date:e.pPrDel.date??null}),e.propertyChanges?.length&&(l.pPrChange=e.propertyChanges);let a$1=[],d=0,p=0;for(let c of e.content)if(c.type==="bookmarkStart")a$1.push({id:c.id,name:c.name,kind:"start",offset:p,...c.colFirst!==void 0?{colFirst:c.colFirst}:{},...c.colLast!==void 0?{colLast:c.colLast}:{}});else if(c.type==="bookmarkEnd")a$1.push({id:c.id,kind:"end",offset:p});else {let f=Et(c);for(let g=0;g<f;g+=1)p+=n[d]?.pmSize??0,d+=1;}return a$1.length>0&&(l.bookmarks=a$1),r?.length&&(l._originalRunBoundaries=r),l}var Ke=new WeakMap;function Et(e){return Ke.get(e)??0}function Lt(e,t,n){let r=[],o=new Set,s=[],l=_t(e,t,n);for(let d of e.content){let p=r.length,c=o.values().next().value;if(d.type==="commentRangeStart")o.add(d.id);else if(d.type==="commentRangeEnd")o.delete(d.id);else if(d.type==="run"){let f=Nt(d,l,t);f&&s?s.push(f):s=void 0,r.push(...Q(d,l,t,c));}else if(d.type==="hyperlink")s=void 0,r.push(...pe(d,l,t));else if(d.type==="simpleField"||d.type==="complexField"){s=void 0;let f=ce(d,l);r.push(I("field",f.payload,f.marks));}else d.type==="inlineSdt"?(s=void 0,r.push(I("sdt",$e(d,l,t),[],void 0,2))):d.type==="insertion"||d.type==="deletion"||d.type==="moveFrom"||d.type==="moveTo"?(s=void 0,r.push(...Mt(d,l,t,c))):d.type==="mathEquation"?(s=void 0,r.push(I("math",fe(d)))):d.type!=="bookmarkStart"&&d.type!=="bookmarkEnd"&&(s=void 0);Ke.set(d,r.length-p);}let a=Ot(e,t,r,s);return {units:r,ppr:Be(a)}}function K(e,t){for(let n of e.content)n.type==="break"&&n.breakType==="page"?t.push("pageBreak"):(n.type!=="text"||n.text.length>0)&&t.push("visible");}function ge(e,t){for(let n of e)if(n.type==="run")K(n,t);else if(n.type==="hyperlink")for(let r of n.children)r.type==="run"&&K(r,t);else if(n.type==="simpleField")for(let r of n.content)r.type==="run"&&K(r,t);else if(n.type==="complexField")for(let r of [...n.fieldCode,...n.fieldResult])K(r,t);else if(n.type==="inlineSdt")ge(n.content,t);else if(n.type==="insertion"||n.type==="deletion"||n.type==="moveFrom"||n.type==="moveTo")for(let r of n.content)r.type==="run"&&K(r,t);else n.type==="mathEquation"&&t.push("visible");}function Dt(e){let t=[];return ge(e.content,t),t[0]==="pageBreak"}function Jt(e){let t=[];ge(e.content,t);let n=false,r=false;for(let o of t)if(o==="pageBreak"){if(r||n)return true;n=true;}else r=true;return false}function Wt(e){let t=new Map,n=new Map;return e.rows.forEach((r,o)=>{let s=0,l=r.cells.map(d=>{let p=s;return s+=d.formatting?.gridSpan??1,{column:p,vMerge:d.formatting?.vMerge,key:`${o}-${p}`}});if(l.length>0&&l.every(d=>d.vMerge==="continue"&&n.has(d.column))){for(let d of l)n.delete(d.column),t.set(d.key,{rowSpan:1,skip:false});return}for(let d of l)if(d.vMerge==="restart")n.set(d.column,o),t.set(d.key,{rowSpan:1,skip:false});else if(d.vMerge==="continue"){let p=n.get(d.column);if(p===void 0)t.set(d.key,{rowSpan:1,skip:false});else {let c=t.get(`${p}-${d.column}`);c&&(c.rowSpan+=1),t.set(d.key,{rowSpan:1,skip:true});}}else n.delete(d.column),t.set(d.key,{rowSpan:1,skip:false});}),t}function ue(e){return {revisionId:e.id,author:e.author,date:e.date??null}}function jt(e,t,n,r,o,s){let l=t?{top:n?t.top:t.insideH,bottom:r?t.bottom:t.insideH,left:o?t.left:t.insideV,right:s?t.right:t.insideV}:void 0;return l||e?.borders?{...l??{},...e?.borders??{}}:void 0}function We(e$1,t){let n=e$1.formatting,r=e(n?.shading?.fill,t.theme),o=n?.width?.value??t.gridWidth,s=n?.width?.type??(t.gridWidth!==void 0?"pct":null),l={colspan:n?.gridSpan??1,rowspan:t.rowspan,width:o??null,widthType:s,verticalAlign:n?.verticalAlign??null,backgroundColor:r??null,borders:jt(n,t.tableBorders,t.firstRow,t.lastRow,t.firstColumn,t.lastColumn)??null,margins:n?.margins?{top:n.margins.top?.value,bottom:n.margins.bottom?.value,left:n.margins.left?.value??(t.tableBidi?n.margins.end?.value:n.margins.start?.value),right:n.margins.right?.value??(t.tableBidi?n.margins.start?.value:n.margins.end?.value)}:t.defaultMargins??null,textDirection:n?.textDirection??null,noWrap:n?.noWrap??false,_originalFormatting:n??null,_originalResolvedFill:r??null};if(e$1.structuralChange){let a=e$1.structuralChange,d=ue(a.info);a.type==="tableCellInsertion"?l.cellMarker={kind:"ins",info:d}:a.type==="tableCellDeletion"?l.cellMarker={kind:"del",info:d}:a.type==="tableCellMerge"&&(l.cellMarker={kind:"merge",info:d,vMerge:a.vMerge??"cont",...a.vMergeOrig?{vMergeOrig:a.vMergeOrig}:{}});}return e$1.propertyChanges?.length&&(l.tcPrChange=e$1.propertyChanges),{attrs:Oe(l,t.isHeader),content:e$1.content.length>0?e$1.content:[{type:"paragraph",content:[]}]}}function Ut(e,t,n,r,o,s,l){let a={height:e.formatting?.height?.value??null,heightRule:e.formatting?.heightRule??null,isHeader:!!e.formatting?.header,_originalFormatting:e.formatting??null};e.structuralChange&&(e.structuralChange.type==="tableRowInsertion"?a.trIns=ue(e.structuralChange.info):e.structuralChange.type==="tableRowDeletion"&&(a.trDel=ue(e.structuralChange.info))),e.propertyChanges?.length&&(a.trPrChange=e.propertyChanges);let d=t.columnWidths,p=d?.reduce((m,y)=>m+y,0)??0,c=d?.length??Math.max(0,...t.rows.map(m=>m.cells.reduce((y,k)=>y+(k.formatting?.gridSpan??1),0))),f=0,g=[];return e.cells.forEach(m=>{let y=m.formatting?.gridSpan??1,k=f,T=r.get(`${n}-${k}`),b;if(d&&p>0){let v=0;for(let R=0;R<y&&k+R<d.length;R+=1)v+=d[k+R];b=Math.round(v/p*100);}f+=y,!T?.skip&&g.push(We(m,{isHeader:n===0&&!!t.formatting?.look?.firstRow,rowspan:T?.rowSpan??1,gridWidth:b,firstRow:n===0,lastRow:n===t.rows.length-1,firstColumn:k===0,lastColumn:f===c,tableBorders:o,defaultMargins:s,theme:l,tableBidi:!!t.formatting?.bidi}));}),g.length===0&&g.push(We({formatting:c>1?{gridSpan:c}:void 0,content:[{type:"paragraph",content:[]}]},{isHeader:n===0&&!!t.formatting?.look?.firstRow,rowspan:1,gridWidth:p>0?100:void 0,firstRow:n===0,lastRow:n===t.rows.length-1,firstColumn:true,lastColumn:true,tableBorders:o,defaultMargins:s,theme:l,tableBidi:!!t.formatting?.bidi})),{attrs:Ne(a),cells:g}}function zt(e,t,n){let r=t?.getDefaultTableStyle(),o=e.formatting?.styleId,s=o??r?.styleId,l=s?t?.getStyle(s):void 0,a=e.formatting?.borders??l?.tblPr?.borders??r?.tblPr?.borders,d=e.formatting?.cellMargins??l?.tblPr?.cellMargins??r?.tblPr?.cellMargins,p=e.formatting?.bidi?d?.end:d?.start,c=e.formatting?.bidi?d?.start:d?.end,f=d?{top:d.top?.value,bottom:d.bottom?.value,left:d.left?.value??p?.value,right:d.right?.value??c?.value}:void 0,g=[],m=new Set,y=l;for(;y?.basedOn&&g.length<32&&!m.has(y.basedOn);)m.add(y.basedOn),g.unshift(y.basedOn),y=t?.getStyle(y.basedOn);let k={...e.formatting??{},styleCascade:{...o?{selectedStyleId:o}:{},...r?.styleId?{defaultStyleId:r.styleId}:{},...g.length>0?{basedOnStyleIds:g}:{}}},T={styleId:o??null,width:e.formatting?.width?.value??null,widthType:e.formatting?.width?.type??null,justification:e.formatting?.justification??null,columnWidths:e.columnWidths??null,tableLayout:e.formatting?.layout??null,floating:e.formatting?.floating??null,cellMargins:f??null,look:e.formatting?.look??null,bidi:e.formatting?.bidi||null,_originalFormatting:k};e.propertyChanges?.length&&(T.tblPrChange=e.propertyChanges);let b=Wt(e);return {attrs:T,rows:e.rows.map((v,R)=>Ut(v,e,R,b,a,f,n))}}function Ht(e){return Le(le(e))}function $t(e){let t=0;for(let n of e.units){let r=n.kind==="text"?n.text.length:1;if(n.commentId!==void 0&&n.commentId!==0){let o=e.commentCoverage.get(n.commentId),s=o?.[o.length-1];s&&s[1]===t?s[1]=t+r:o?o.push([t,t+r]):e.commentCoverage.set(n.commentId,[[t,t+r]]);}t+=r;}}function W(e,t,n,r){let o={storyId:t,units:[],commentCoverage:new Map};e.plans.push(o);let s=n.length>0?[...n]:[{type:"paragraph",content:[]}],l=0,a=0,d=0,p=null;for(let c of s){if(c.type==="paragraph"){let m=Lt(c,e.styleResolver,r.extraRunFormatting);o.units.push(...m.units),o.units.push(I("pilcrow",{...m.ppr,paraId:c.paraId||`${t}:p${d}`})),d+=1,r.includePageBreaks&&Jt(c)&&o.units.push(I("pageBreak",{})),p="paragraph";continue}if(c.type==="table"){let m=l++,y=zt(c,e.styleResolver,e.theme),k=y.rows.map((T,b)=>({trPr:T.attrs,cells:T.cells.map((v,R)=>({tcPr:v.attrs,story:de(t,m,b,R)}))}));o.units.push(I("table",{tblPr:Me(y.attrs),grid:_e(y.attrs),rows:k})),y.rows.forEach((T,b)=>{T.cells.forEach((v,R)=>{W(e,de(t,m,b,R),v.content,{includePageBreaks:false,appendBodyTail:false,seedComments:false,extraRunFormatting:v.extraRunFormatting});});}),p="table";continue}let f=a++,g=Ee(t,f);o.units.push(I("blockSdt",{...Ht(c.properties),story:g})),W(e,g,c.content,{includePageBreaks:r.includePageBreaks,appendBodyTail:false,seedComments:false}),p="blockSdt";}r.appendBodyTail&&(p==="table"||p==="blockSdt")&&o.units.push(I("pilcrow",{hangingIndent:false,paraId:`${t}:p${d}`})),r.seedComments&&$t(o);}function Kt(e){let t=[{op:"delete",index:0,len:1}],n=0,r="",o={},s=j(o),l=()=>{r&&(t.push({op:"insert",index:n,text:r,attrs:o}),n+=r.length,r="");};for(let a of e)if(a.kind==="text"){let d=j(a.attrs);r&&d!==s&&l(),o=a.attrs,s=d,r+=a.text;}else l(),t.push({op:"insertEmbed",index:n,kind:a.embedKind,payload:a.payload,attrs:a.attrs}),n+=1;return l(),t}function Vt(e,t){e.applyRawOps(t.storyId,Kt(t.units));let n=[];for(let[r,o]of t.commentCoverage)n.push({op:"setComment",id:String(r),ranges:o,author:"",date:"",body:null});n.length>0&&e.applyRawOps(t.storyId,n);}function qt(e,t){let n={styleResolver:t.package.styles?c(t.package.styles):null,theme:t.package.theme??null,plans:[]};W(n,"body",t.package.document.content,{includePageBreaks:true,appendBodyTail:true,seedComments:true});for(let[r,o]of t.package.headers??[])W(n,G(r),o.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let[r,o]of t.package.footers??[])n.plans.some(s=>s.storyId===G(r))||W(n,G(r),o.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let r of t.package.footnotes??[])W(n,De(r.id),r.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let r of n.plans)e.createStory(r.storyId,"","Normal","left");for(let r of n.plans)Vt(e,r);}function Ve(e){return e.numPrFromStyle!=null&&e.numPr!=null&&JSON.stringify(e.numPr)===JSON.stringify(e.numPrFromStyle)}function Ge(e){if(e._originalFormatting){let n=e._originalFormatting,r={...n};return e.alignment!==(n.alignment||void 0)&&(r.alignment=e.alignment||void 0),Ve(e)?(delete r.numPr,delete r.numPrFromStyle):e.numPr!==n.numPr&&JSON.stringify(e.numPr)!==JSON.stringify(n.numPr)&&(r.numPr=e.numPr||void 0,delete r.numPrFromStyle),e.styleId!==(n.styleId||void 0)&&(r.styleId=e.styleId||void 0),e.pageBreakBefore!==(n.pageBreakBefore||void 0)&&(r.pageBreakBefore=e.pageBreakBefore||void 0),e.bidi!==(n.bidi||void 0)&&(r.bidi=e.bidi||void 0),r}if(e.alignment||e.spaceBefore||e.spaceAfter||e.lineSpacing||e.indentLeft||e.indentRight||e.indentFirstLine||e.numPr||e.styleId||e.borders||e.shading||e.tabs||e.outlineLevel!=null||e.contextualSpacing||e.pageBreakBefore||e.bidi)return {alignment:e.alignment||void 0,spaceBefore:e.spaceBefore||void 0,spaceAfter:e.spaceAfter||void 0,lineSpacing:e.lineSpacing||void 0,lineSpacingRule:e.lineSpacingRule||void 0,indentLeft:e.indentLeft||void 0,indentRight:e.indentRight||void 0,indentFirstLine:e.indentFirstLine||void 0,hangingIndent:e.hangingIndent||void 0,numPr:Ve(e)?void 0:e.numPr||void 0,styleId:e.styleId||void 0,borders:e.borders||void 0,shading:e.shading||void 0,tabs:e.tabs||void 0,outlineLevel:e.outlineLevel??void 0,contextualSpacing:e.contextualSpacing||void 0,pageBreakBefore:e.pageBreakBefore||void 0,bidi:e.bidi||void 0}}function Qe(e){if(e._originalFormatting){let n=e._originalFormatting,r={...n};return e.styleId!==(n.styleId||void 0)&&(r.styleId=e.styleId||void 0),e.justification!==(n.justification||void 0)&&(r.justification=e.justification||void 0),e.floating!==(n.floating||void 0)&&(r.floating=e.floating||void 0),e.tableLayout!==(n.layout||void 0)&&(r.layout=e.tableLayout||void 0),e.look!==(n.look||void 0)&&(r.look=e.look||void 0),e.bidi!==(n.bidi||void 0)&&(r.bidi=e.bidi||void 0),(e.width!==n.width?.value||e.widthType!==n.width?.type)&&(r.width=e.width!=null||e.widthType?{value:e.width??0,type:e.widthType||"dxa"}:void 0),e.cellMargins&&(r.cellMargins=qe(e.cellMargins)),r}if(e.styleId||e.width!=null||e.widthType||e.justification||e.tableLayout||e.floating||e.cellMargins||e.look||e.bidi)return {styleId:e.styleId||void 0,width:e.width!=null||e.widthType?{value:e.width??0,type:e.widthType||"dxa"}:void 0,justification:e.justification||void 0,layout:e.tableLayout||void 0,floating:e.floating||void 0,cellMargins:e.cellMargins?qe(e.cellMargins):void 0,look:e.look||void 0,bidi:e.bidi||void 0}}function qe(e){return {top:e.top!=null?{value:e.top,type:"dxa"}:void 0,bottom:e.bottom!=null?{value:e.bottom,type:"dxa"}:void 0,left:e.left!=null?{value:e.left,type:"dxa"}:void 0,right:e.right!=null?{value:e.right,type:"dxa"}:void 0}}function Ze(e){if(e._originalFormatting){let t=e._originalFormatting,n={...t};return e.height!==(t.height?.value||void 0)&&(n.height=e.height?{value:e.height,type:"dxa"}:void 0),e.heightRule!==(t.heightRule||void 0)&&(n.heightRule=e.heightRule||void 0),e.isHeader!==(t.header||void 0)&&(n.header=e.isHeader||void 0),n}if(!(!e.height&&!e.isHeader))return {height:e.height?{value:e.height,type:"dxa"}:void 0,heightRule:e.heightRule||void 0,header:e.isHeader||void 0}}function et(e){if(e._originalFormatting){let n=e._originalFormatting,r={...n};return e.colspan>1&&(r.gridSpan=e.colspan),e.width!=null&&(r.width={value:e.width,type:e.widthType||"dxa"}),e.verticalAlign!==(n.verticalAlign||void 0)&&(r.verticalAlign=e.verticalAlign||void 0),e.backgroundColor?r.shading=e._originalResolvedFill===e.backgroundColor&&n.shading?n.shading:{fill:{rgb:e.backgroundColor}}:n.shading&&(r.shading=void 0),e.borders&&(r.borders=e.borders),e.margins&&(r.margins=Xe(e.margins)),e.textDirection!==(n.textDirection||void 0)&&(r.textDirection=e.textDirection||void 0),r}if(e.colspan>1||e.rowspan>1||e.width!=null||e.verticalAlign||e.backgroundColor||e.borders||e.margins||e.textDirection)return {gridSpan:e.colspan>1?e.colspan:void 0,width:e.width!=null?{value:e.width,type:e.widthType||"dxa"}:void 0,verticalAlign:e.verticalAlign||void 0,textDirection:e.textDirection||void 0,shading:e.backgroundColor?{fill:{rgb:e.backgroundColor}}:void 0,borders:e.borders,margins:e.margins?Xe(e.margins):void 0}}function Xe(e){let t={};return e.top!=null&&(t.top={value:e.top,type:"dxa"}),e.bottom!=null&&(t.bottom={value:e.bottom,type:"dxa"}),e.left!=null&&(t.left={value:e.left,type:"dxa"}),e.right!=null&&(t.right={value:e.right,type:"dxa"}),t}var Xt={paraId:null,textId:null,alignment:null,spaceBefore:null,spaceAfter:null,lineSpacing:null,lineSpacingRule:null,spacingExplicit:null,indentLeft:null,indentRight:null,indentFirstLine:null,hangingIndent:false,numPr:null,numPrFromStyle:null,listNumFmt:null,listIsBullet:null,listMarker:null,listMarkerHidden:null,listMarkerFontFamily:null,listMarkerFontSize:null,listMarkerSuffix:null,listLevelNumFmts:null,listAbstractNumId:null,listStartOverride:null,styleId:null,borders:null,shading:null,tabs:null,pageBreakBefore:null,renderedPageBreakBefore:null,keepNext:null,keepLines:null,contextualSpacing:null,defaultTextFormatting:null,sectionBreakType:null,bidi:null,outlineLevel:null,bookmarks:null,_originalFormatting:null,_originalRunBoundaries:null,_sectionProperties:null,pPrIns:null,pPrDel:null,pPrChange:null},Gt={styleId:null,width:null,widthType:null,justification:null,columnWidths:null,tableLayout:null,floating:null,cellMargins:null,look:null,bidi:null,_originalFormatting:null,tblPrChange:null},Qt={height:null,heightRule:null,isHeader:false,_originalFormatting:null,trIns:null,trDel:null,trPrChange:null},Zt={colspan:1,rowspan:1,colwidth:null,width:null,widthType:null,verticalAlign:null,backgroundColor:null,borders:null,margins:null,textDirection:null,noWrap:false,_originalFormatting:null,_originalResolvedFill:null,cellMarker:null,tcPrChange:null},en=new Set(["bold","italic","superscript","subscript","allCaps","smallCaps","emboss","imprint","textShadow","textOutline","hidden","rtl"]);function w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Y(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function S(e){return typeof e=="string"?e:void 0}function ee(e){if(Array.isArray(e))return e.map(ee);let t=w(e);if(!t)return e;let n={};for(let[r,o]of Object.entries(t))o!=null&&(n[r]=ee(o));return n}function V(e){if(e==null)return "null";if(Array.isArray(e))return `[${e.map(V).join(",")}]`;let t=w(e);return t?`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${V(t[n])}`).join(",")}}`:JSON.stringify(e)}function q(e){let t={...e};return delete t.hyperlink,delete t.ins,delete t.del,t}function ne(e){let t={};e.bold&&(t.bold=true,t.boldCs=true),e.italic&&(t.italic=true,t.italicCs=true);let n=w(e.underline);n&&(t.underline={style:S(n.style)||"single",color:w(n.color)??null});let r=w(e.strike);r&&(r.double?t.doubleStrike=true:t.strike=true);let o=w(e.textColor);o&&(t.color={rgb:S(o.rgb)??null,themeColor:o.themeColor??null,themeTint:S(o.themeTint)??null,themeShade:S(o.themeShade)??null}),typeof e.highlight=="string"&&(t.highlight=e.highlight);let s=w(e.fontSize);if(s){let m=Y(s.size),y=Y(s.sizeCs)??m;m!==void 0&&(t.fontSize=m),y!==void 0&&(t.fontSizeCs=y);}let l=w(e.fontFamily);if(l){let m=S(l.ascii);t.fontFamily={ascii:m??null,hAnsi:S(l.hAnsi)??null,eastAsia:S(l.eastAsia),cs:S(l.cs)||m,asciiTheme:l.asciiTheme??null,hAnsiTheme:S(l.hAnsiTheme),eastAsiaTheme:S(l.eastAsiaTheme),csTheme:S(l.csTheme)};}e.superscript&&(t.vertAlign="superscript"),e.subscript&&(t.vertAlign="subscript"),e.allCaps&&(t.allCaps=true),e.smallCaps&&(t.smallCaps=true);let a=w(e.characterSpacing);if(a){let m=Y(a.spacing),y=Y(a.position),k=Y(a.scale),T=Y(a.kerning);m!==void 0&&(t.spacing=m),y!==void 0&&(t.position=y),k!==void 0&&(t.scale=k),T!==void 0&&(t.kerning=T);}e.emboss&&(t.emboss=true),e.imprint&&(t.imprint=true),e.textShadow&&(t.shadow=true);let d=w(e.emphasisMark);d&&(t.emphasisMark=S(d.type)||"dot"),e.textOutline&&(t.outline=true),e.hidden&&(t.hidden=true),e.rtl&&(t.rtl=true);let p=w(e.textEffect);p&&(t.effect=S(p.effect)||"blinkBackground");let c=w(e.modernTextEffects);c?.effects&&(t.modernEffects=c.effects);let f=w(e.runStyle),g=S(f?.styleId);return g&&(t.styleId=g),t}function ot(e,t){let n=[],r="",o=()=>{r&&(n.push({type:"text",text:r}),r="");},s=t.fontFamily?[t.fontFamily.ascii,t.fontFamily.hAnsi,t.fontFamily.eastAsia,t.fontFamily.cs].filter(a=>!!a):[],l=s.length>0&&s.every(a=>a===s[0])?s[0]:null;for(let a of e){let d=a.codePointAt(0)??0;a==="\xAD"?(o(),n.push({type:"softHyphen"})):a==="\u2011"?(o(),n.push({type:"noBreakHyphen"})):l&&d>=61440&&d<=63743?(o(),n.push({type:"symbol",font:l,char:d.toString(16).toUpperCase().padStart(4,"0")})):r+=a;}return o(),n}function ye(e,t){let n=ne(q(t));return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:ot(e,n)}}function tn(e,t){for(let n of t.content){let r=e.content[e.content.length-1];r?.type==="text"&&n.type==="text"?r.text+=n.text:e.content.push(n);}}function nn(e){let t=0xcbf29ce484222325n;for(let n of new TextEncoder().encode(e))t=(t^BigInt(n))*0x100000001b3n,t&=0xffffffffffffffffn;return Number(t&(1n<<53n)-1n)}function me(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t=Number(e);return Number.isFinite(t)?t:nn(e)}return 0}function U(e,t=false){let n=w(e);if(!n)return null;let r=S(n.author)||"Unknown",o=S(n.date);return {id:me(n.revisionId??n.id),author:r,...o?{date:o}:{}}}function rn(e){let t=w(e.hyperlink);if(!t)return null;let n=S(t.href)||"";return n.startsWith("#")?{type:"hyperlink",anchor:n.slice(1),tooltip:S(t.tooltip)||void 0,children:[]}:{type:"hyperlink",href:n,tooltip:S(t.tooltip)||void 0,rId:S(t.rId)||void 0,children:[]}}function on(e){let t=w(e.hyperlink);return t?S(t.href)||"":null}function it(e,t){let n=S(e.fieldData);if(n&&n.length<=2e6)try{let c=JSON.parse(n),f=c.type==="simpleField"?c.content:c.fieldResult;if((c.type==="simpleField"||c.type==="complexField")&&typeof c.instruction=="string"&&Array.isArray(f)){let g=S(e.displayMode);return c.fieldTree&&g&&(c.fieldTree.displayMode=g),c}}catch{}let r=ne(q(t)),o={type:"run",content:[{type:"text",text:S(e.displayText)||""}],...Object.keys(r).length>0?{formatting:r}:{}},s=S(e.instruction)||"",l=S(e.fieldType)||"UNKNOWN",a=e.fldLock===true||void 0,d=e.dirty===true||void 0,p=S(e.displayMode)||"result";return e.fieldKind==="complex"?{type:"complexField",instruction:s,fieldType:l,fieldCode:[],fieldResult:[o],fldLock:a,dirty:d,fieldTree:{version:1,displayMode:p}}:{type:"simpleField",instruction:s,fieldType:l,content:[o],fldLock:a,dirty:d,fieldTree:{version:1,displayMode:p}}}function lt(e){return {type:"mathEquation",display:S(e.display)||"inline",ommlXml:S(e.ommlXml)||"",plainText:S(e.plainText)||void 0}}function st(e){let t=e,n={type:S(t.wrapType)||"inline"};t.distTop!==void 0&&(n.distT=c$1(Number(t.distTop))),t.distBottom!==void 0&&(n.distB=c$1(Number(t.distBottom))),t.distLeft!==void 0&&(n.distL=c$1(Number(t.distLeft))),t.distRight!==void 0&&(n.distR=c$1(Number(t.distRight))),t.wrapText&&(n.wrapText=t.wrapText);let r={type:"image",rId:S(t.rId)||"",src:S(t.src)||"",alt:S(t.alt)||void 0,title:S(t.title)||void 0,size:{width:c$1(Number(t.width)||0),height:c$1(Number(t.height)||0)},wrap:n};if(t.transform){let l={},a=t.transform.match(/rotate\(([-\d.]+)deg\)/)?.[1];a&&(l.rotation=Number.parseFloat(a)),t.transform.includes("scaleX(-1)")&&(l.flipH=true),t.transform.includes("scaleY(-1)")&&(l.flipV=true),(l.rotation||l.flipH||l.flipV)&&(r.transform=l);}if(t.position?.horizontal&&t.position.vertical&&(r.position={horizontal:{relativeTo:t.position.horizontal.relativeTo||"column",alignment:t.position.horizontal.align,posOffset:t.position.horizontal.posOffset},vertical:{relativeTo:t.position.vertical.relativeTo||"paragraph",alignment:t.position.vertical.align,posOffset:t.position.vertical.posOffset}}),t.borderWidth&&t.borderWidth>0){let l={solid:"solid",dotted:"dot",dashed:"dash",double:"solid",groove:"solid",ridge:"solid",inset:"solid",outset:"solid"};r.outline={width:c$1(t.borderWidth),color:t.borderColor?{rgb:t.borderColor.replace("#","")}:void 0,style:t.borderStyle&&l[t.borderStyle]||"solid"};}t.hlinkHref&&(r.hlinkHref=t.hlinkHref);let o={};t.cropTop!=null&&(o.top=t.cropTop),t.cropRight!=null&&(o.right=t.cropRight),t.cropBottom!=null&&(o.bottom=t.cropBottom),t.cropLeft!=null&&(o.left=t.cropLeft),Object.keys(o).length>0&&(r.crop=o),t.opacity!=null&&t.opacity<1&&(r.opacity=t.opacity),t.layoutInCell!=null&&(r.layoutInCell=t.layoutInCell),t.allowOverlap!=null&&(r.allowOverlap=t.allowOverlap);let s={};return t.effectExtentTop&&(s.top=c$1(t.effectExtentTop)),t.effectExtentBottom&&(s.bottom=c$1(t.effectExtentBottom)),t.effectExtentLeft&&(s.left=c$1(t.effectExtentLeft)),t.effectExtentRight&&(s.right=c$1(t.effectExtentRight)),Object.keys(s).length>0&&(r.padding=s),{type:"run",content:[{type:"drawing",image:r}]}}function at(e){let t={type:"shape",shapeType:S(e.shapeType)||"rect",id:S(e.shapeId)||void 0,size:{width:e.width?c$1(Number(e.width)):0,height:e.height?c$1(Number(e.height)):0}};if(Array.isArray(e.geometryPath)&&e.geometryPath.length>0&&(t.geometryPath=e.geometryPath),e.fillType==="gradient"&&typeof e.gradientStops=="string")try{let r=JSON.parse(e.gradientStops);t.fill={type:"gradient",gradient:{type:S(e.gradientType)||"linear",angle:Y(e.gradientAngle)||void 0,stops:r.map(o=>({position:o.position,color:{rgb:o.color.replace("#","")}}))}};}catch{t.fill={type:"solid",color:{rgb:(S(e.fillColor)||"000000").replace("#","")}};}else typeof e.fillColor=="string"?t.fill={type:S(e.fillType)||"solid",color:{rgb:e.fillColor.replace("#","")}}:e.fillType==="none"&&(t.fill={type:"none"});if(typeof e.outlineWidth=="number"&&e.outlineWidth>0){let r={solid:"solid",dotted:"dot",dashed:"dash"},o=S(e.outlineStyle);t.outline={width:c$1(e.outlineWidth),color:typeof e.outlineColor=="string"?{rgb:e.outlineColor.replace("#","")}:void 0,style:o&&r[o]||"solid"};}let n={};if(typeof e.rotation=="number")n.rotation=e.rotation;else if(typeof e.transform=="string"){let r=e.transform.match(/rotate\(([-\d.]+)deg\)/)?.[1];r&&(n.rotation=Number.parseFloat(r));}return (e.flipH||String(e.transform||"").includes("scaleX(-1)"))&&(n.flipH=true),(e.flipV||String(e.transform||"").includes("scaleY(-1)"))&&(n.flipV=true),(n.rotation||n.flipH||n.flipV)&&(t.transform=n),{type:"run",content:[{type:"shape",shape:t}]}}function ln(e){let t=se(e),n=S(e.propertiesJson);if(n&&n.length<=1e6)try{let l=JSON.parse(n);l&&typeof l=="object"&&typeof l.sdtType=="string"&&(t=l);}catch{}let r=[];for(let l of Array.isArray(e.content)?e.content:[]){let a=w(l),d=S(a?.kind);if(!a||!d)continue;let p=w(a.attrs)??{};if(d==="text"){let c=S(a.text);c!==void 0&&r.push({kind:"text",text:c,attributes:p});continue}r.push({kind:"embed",embedKind:d,payload:w(a.payload)??{},attributes:p});}let o=tt(be(r)),s=dt(e.value);if(s)try{let l=L(t,s);t=l.properties;let a=l.content[0];o=tt(a?.type==="paragraph"?a.content:[]);}catch{}return {type:"inlineSdt",properties:t,content:o}}function tt(e){return e.filter(t=>t.type==="run"||t.type==="hyperlink"||t.type==="simpleField"||t.type==="complexField"||t.type==="inlineSdt"||t.type==="mathEquation")}function dt(e){let t=w(e);return t?.kind==="checkbox"&&typeof t.checked=="boolean"?{kind:"checkbox",checked:t.checked}:t?.kind==="dropdown"&&typeof t.value=="string"?{kind:"dropdown",value:t.value}:t?.kind==="date"&&typeof t.date=="string"?{kind:"date",date:t.date}:null}function ut(e){if(e.modelKind!=="commentReference")return null;let t=Y(e.commentId);return {type:"run",content:[{type:"commentReference",...t!==void 0?{id:t}:{}}]}}function nt(e){if(e.kind==="text")return ye(e.text,e.attributes);switch(e.embedKind){case "break":return {type:"run",content:[{type:"break",breakType:"textWrapping"}]};case "tab":return {type:"run",content:[{type:"tab"}]};case "image":return st(e.payload);case "shape":return at(e.payload);case "field":return ut(e.payload)??it(e.payload,e.attributes);case "math":return lt(e.payload);case "sdt":return ln(e.payload);case "noteRef":{let t=e.payload.footnoteRefId,n=e.payload.endnoteRefId;return {type:"run",content:[t!==void 0?{type:"footnoteRef",id:me(t)}:{type:"endnoteRef",id:me(n)}]}}default:return null}}function sn(e,t){let n;if(e.kind==="embed"&&e.embedKind==="image")n=st(e.payload);else if(e.kind==="embed"&&e.embedKind==="shape")n=at(e.payload);else if(e.kind==="text"){let s=ne(q(e.attributes));n={type:"run",content:[{type:"text",text:e.text}],...Object.keys(s).length>0?{formatting:s}:{}};}else n={type:"run",content:[]};let o=(w(e.attributes.ins)??w(e.attributes.del))?.isMovePair===true;return e.attributes.ins?o?{type:"moveTo",info:t,content:[n]}:{type:"insertion",info:t,content:[n]}:o?{type:"moveFrom",info:t,content:[n]}:{type:"deletion",info:t,content:[n]}}function an(e,t){if(t.kind==="text"){e.children.push(ye(t.text,t.attributes));return}if(t.embedKind==="break")e.children.push({type:"run",content:[{type:"break",breakType:"textWrapping"}]});else if(t.embedKind==="tab")e.children.push({type:"run",content:[{type:"tab"}]});else if(t.embedKind==="field"){let n=ut(t.payload)??it(t.payload,t.attributes);n.type==="run"?e.children.push(n):(e.structuredChildren??(e.structuredChildren=[...e.children])).push(n);}else t.embedKind==="math"&&(e.structuredChildren??(e.structuredChildren=[...e.children])).push(lt(t.payload));}function be(e){let t=[],n=null,r=null,o=null,s=()=>{n&&t.push(n),n=null,r=null;},l=()=>{o&&t.push(o),o=null;};for(let a of e){if(a.kind==="embed"&&a.embedKind==="noteRef"){s(),l();let f=nt(a);f&&t.push(f);continue}let d=U(a.attributes.ins??a.attributes.del);if(d){s(),l(),t.push(sn(a,d));continue}let p=on(a.attributes);if(p!==null){s();let f=o?o.href||(o.anchor?`#${o.anchor}`:""):null;(!o||f!==p)&&(l(),o=rn(a.attributes)),o&&an(o,a);continue}if(l(),a.kind==="text"){let f=V(q(a.attributes)),g=ye(a.text,a.attributes);n&&r===f?tn(n,g):(s(),n=g,r=f);continue}s();let c=nt(a);c&&t.push(c);}return s(),l(),t}function dn(e){if(!e)return {};let t={};for(let n of e.split("|")){let r=n.indexOf(":");if(r<=0)return null;let o=n.slice(0,r),s;try{s=JSON.parse(n.slice(r+1));}catch{return null}o==="comment"||o==="footnoteRef"||(en.has(o)?t[o]=true:o==="highlight"?t.highlight=s.color:o==="insertion"||o==="deletion"?t[o==="insertion"?"ins":"del"]=ee({id:s.revisionId,author:s.author,date:s.date,isMovePair:s.isMovePair}):t[o]=ee(s));}return t}function un(e,t,n){if(!n?.length||!e.every(a=>a.type==="run"&&a.content.every(d=>d.type==="text"))||t.some(a=>a.kind!=="text"||a.attributes.hyperlink)||t.map(a=>a.kind==="text"?a.text:"").join("")!==n.map(a=>a.text).join(""))return e;let o=0,s=0,l=[];for(let a of n){let d=dn(a.marksKey);if(!d)return e;l.push(d);let p=a.text.length;for(;p>0;){let c=t[o];if(!c||V(q(c.attributes))!==V(d))return e;let f=c.text.length-s,g=Math.min(p,f);p-=g,s+=g,s===c.text.length&&(o+=1,s=0);}}return n.map((a,d)=>{let p=a.text.length===0?a.formatting:ne(l[d]),c={type:"run",content:ot(a.text,p??{})};return p&&Object.keys(p).length>0&&(c.formatting=p),a.propertyChanges?.length&&(c.propertyChanges=a.propertyChanges),c})}function Z(e){return e.content.reduce((t,n)=>n.type==="text"||n.type==="instrText"?t+n.text.length:n.type==="symbol"?t+n.char.length:n.type==="tab"||n.type==="softHyphen"||n.type==="noBreakHyphen"?t+1:t,0)}function te(e){switch(e.type){case "run":return Z(e);case "hyperlink":return e.children.reduce((t,n)=>t+(n.type==="run"?Z(n):0),0);case "simpleField":return e.content.reduce((t,n)=>t+te(n),0);case "complexField":return e.fieldResult.reduce((t,n)=>t+Z(n),0);case "inlineSdt":return e.content.reduce((t,n)=>t+te(n),0);case "insertion":case "deletion":case "moveFrom":case "moveTo":return e.content.reduce((t,n)=>t+(n.type==="run"?Z(n):0),0);case "mathEquation":return e.plainText?.length??0;default:return 0}}function cn(e,t){if(!e.content.every(o=>o.type==="text"))return [e,null];let n=e.content.map(o=>o.type==="text"?o.text:"").join(""),r=o=>o?{type:"run",...e.formatting?{formatting:e.formatting}:{},...e.propertyChanges?{propertyChanges:e.propertyChanges}:{},content:[{type:"text",text:o}]}:null;return [r(n.slice(0,t)),r(n.slice(t))]}function rt(e,t,n=r=>r.kind==="start"?{type:"commentRangeStart",id:r.id}:{type:"commentRangeEnd",id:r.id}){if(t.length===0)return e;let r=[...t].sort((d,p)=>d.offset-p.offset||(d.kind===p.kind?d.id-p.id:d.kind==="end"?-1:1)),o=[],s=0,l=0,a=d=>{for(;l<r.length&&r[l].offset===d;){let p=r[l++];o.push(n(p));}};a(0);for(let d of e){let p=te(d),c=r.slice(l).map(f=>f.offset).filter(f=>f>s&&f<s+p);if(d.type==="run"&&d.content.every(f=>f.type==="text")){let f=d,g=0;for(let m of c){if(!f)break;let[y,k]=cn(f,m-s-g);y&&o.push(y),a(m),f=k,g=m-s;}f&&o.push(f);}else o.push(d);s+=p,a(s);}return a(s),o}function fn(e){if(!Array.isArray(e.bookmarks))return [];let t=[];for(let n of e.bookmarks){let r=w(n),o=Y(r?.id);if(!r||o===void 0)continue;let s=Y(r.offset)??0,l={name:S(r.name),colFirst:Y(r.colFirst),colLast:Y(r.colLast)};r.kind==="start"?t.push({id:o,kind:"start",offset:s,...l}):r.kind==="end"?t.push({id:o,kind:"end",offset:s,...l}):(t.push({id:o,kind:"start",offset:0,...l}),t.push({id:o,kind:"end",offset:Number.MAX_SAFE_INTEGER,...l}));}return t}function pn(e){let t={...Xt,...e};return t.styleId=e.pStyle??null,t._sectionProperties=e.sectPr??null,delete t.pStyle,delete t.sectPr,t}function gn(e,t,n,r,o){let s=pn(t),l=be(n);l=un(l,n,Array.isArray(s._originalRunBoundaries)?s._originalRunBoundaries:void 0),l=rt(l,r);let a=fn(t).map(f=>({...f,offset:f.offset===Number.MAX_SAFE_INTEGER?l.reduce((g,m)=>g+te(m),0):f.offset}));a.length>0&&(l=rt(l,a,f=>{let g=f;return g.kind==="start"?{type:"bookmarkStart",id:g.id,name:g.name||"",...g.colFirst!==void 0?{colFirst:g.colFirst}:{},...g.colLast!==void 0?{colLast:g.colLast}:{},position:{offset:g.offset}}:{type:"bookmarkEnd",id:g.id,position:{offset:g.offset}}}));let d={type:"paragraph",paraId:e||void 0,textId:o?.textId,formatting:Ge(s),content:l};o?.renderedPageBreakBefore&&(d.renderedPageBreakBefore=true);let p=U(t.pPrIns,true),c=U(t.pPrDel,true);return p&&(d.pPrIns=p),c&&(d.pPrDel=c),Array.isArray(t.pPrChange)&&t.pPrChange.length>0&&(d.propertyChanges=t.pPrChange),t.sectPr?d.sectionProperties=t.sectPr:t.sectionBreakType&&(d.sectionProperties={sectionStart:t.sectionBreakType}),d}function mn(e){for(let t of e)for(let n of t.cells){let r=n.formatting?.borders;if(!r)continue;let o=r.top||r.left||r.right||r.bottom||r.insideH||r.insideV;return o?{top:r.top??o,bottom:r.bottom??o,left:r.left??o,right:r.right??o,insideH:r.insideH??r.bottom??o,insideV:r.insideV??r.right??o}:void 0}}function hn(e){let t=new Map;e.forEach((r,o)=>{let s=0;for(let l of r.cells){let a=s;if(s+=l.formatting?.gridSpan??1,l.formatting?.vMerge){let d=t.get(a)??[];d.push({rowIndex:o,cell:l}),t.set(a,d);}}});let n=r=>{r.formatting&&(delete r.formatting.vMerge,Object.keys(r.formatting).length===0&&(r.formatting=void 0));};for(let r of t.values()){let o=null,s=0,l=-1,a=()=>{o&&s<2&&n(o),o=null,s=0;};for(let d of r){let p=d.cell.formatting?.vMerge;p==="restart"?(a(),o=d.cell,s=1,l=d.rowIndex):p==="continue"&&(o&&d.rowIndex===l+1?(s+=1,l=d.rowIndex):(a(),n(d.cell)));}a();}}function yn(e,t){let n={...Zt,...t.tcPr??{}},r=t.story&&e.storyIds.has(t.story)?e.storyToBlocks(t.story).filter(l=>l.type==="paragraph"||l.type==="table"):[],o={type:"tableCell",formatting:et(n),content:r},s=n.cellMarker;if(s){let l=U(s.info,true)??{id:0,author:"Unknown"};s.kind==="ins"?o.structuralChange={type:"tableCellInsertion",info:l}:s.kind==="del"?o.structuralChange={type:"tableCellDeletion",info:l}:o.structuralChange={type:"tableCellMerge",info:l,...s.vMerge?{vMerge:s.vMerge}:{},...s.vMergeOrig?{vMergeOrig:s.vMergeOrig}:{}};}return Array.isArray(n.tcPrChange)&&n.tcPrChange.length>0&&(o.propertyChanges=n.tcPrChange),o}function bn(e,t){let n=Array.isArray(t.rows)?t.rows:[],r=[],o=[],s=0;n.forEach((m,y)=>{let k=0;for(let T of Array.isArray(m.cells)?m.cells:[]){for(;r[y]?.[k];)k+=1;let b=T.tcPr??{},v=Y(b.rowspan)||1,R=Y(b.colspan)||1;o.push({row:y,col:k,rowspan:v,colspan:R,cell:yn(e,T)});for(let x=y;x<y+v;x+=1){r[x]??(r[x]=[]);for(let B=k;B<k+R;B+=1)r[x][B]=true;}k+=R,s=Math.max(s,k);}});let l=new Map(o.map(m=>[`${m.row}-${m.col}`,m])),a=new Map;for(let m of o)for(let y=m.row;y<m.row+m.rowspan;y+=1)for(let k=m.col;k<m.col+m.colspan;k+=1)a.set(`${y}-${k}`,m);let d=n.map((m,y)=>{let k=[];for(let x=0;x<s;){let B=l.get(`${y}-${x}`);if(B){let i={...B.cell.formatting??{}};B.colspan>1?i.gridSpan=B.colspan:delete i.gridSpan,B.rowspan>1?i.vMerge="restart":i.vMerge!=="restart"&&i.vMerge!=="continue"&&delete i.vMerge,k.push({...B.cell,formatting:Object.keys(i).length>0?i:void 0}),x+=B.colspan;continue}let O=a.get(`${y}-${x}`);if(!O){x+=1;continue}let J={...O.cell.formatting??{}};O.colspan>1?J.gridSpan=O.colspan:delete J.gridSpan,J.vMerge="continue",k.push({...O.cell,content:[],formatting:J}),x+=O.colspan;}let T={...Qt,...m.trPr??{}},b={type:"tableRow",formatting:Ze(T),cells:k},v=U(T.trIns,true),R=U(T.trDel,true);return v?b.structuralChange={type:"tableRowInsertion",info:v}:R&&(b.structuralChange={type:"tableRowDeletion",info:R}),Array.isArray(T.trPrChange)&&T.trPrChange.length>0&&(b.propertyChanges=T.trPrChange),b});hn(d);let p=Array.isArray(t.grid)?t.grid.filter(m=>typeof m=="number"):[],c={...Gt,...t.tblPr??{},columnWidths:p.length>0?p:void 0},f=Qe(c);if(!f?.borders){let m=mn(d);m&&(f={...f??{},borders:m});}let g={type:"table",columnWidths:c.columnWidths||void 0,formatting:f,rows:d};return Array.isArray(c.tblPrChange)&&c.tblPrChange.length>0&&(g.propertyChanges=c.tblPrChange),g}function kn(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Sn(e){let t=new Map,n=r=>{for(let o of r)if(o.type==="paragraph")o.paraId&&!t.has(o.paraId)&&t.set(o.paraId,o);else if(o.type==="table")for(let s of o.rows)for(let l of s.cells)n(l.content);else n(o.content);};n(e.package.document.content);for(let r of e.package.headers?.values()??[])n(r.content);for(let r of e.package.footers?.values()??[])n(r.content);for(let r of e.package.footnotes??[])n(r.content);for(let r of e.package.endnotes??[])n(r.content);return t}function Rn(e){let t=new Map,n=(r,o)=>{t.set(r,o);let s=0;for(let l of o){if(l.type!=="table")continue;let a=s++;l.rows.forEach((d,p)=>{d.cells.forEach((c,f)=>{n(`${r}:t${a}:r${p}c${f}`,c.content);});});}};n("body",e.package.document.content);for(let[r,o]of e.package.headers??[])n(`hf:${r}`,o.content);for(let[r,o]of e.package.footers??[])n(`hf:${r}`,o.content);for(let r of e.package.footnotes??[])n(`fn:${r.id}`,r.content);return t}function Tn(e,t){let n=new Map;for(let r of t??[]){let o;try{o=e.resolveComment(String(r.id));}catch{continue}let s=new Map;for(let l of o){let a=s.get(l.story)??[];a.push(l),s.set(l.story,a);}for(let[l,a]of s){if(a.length===0)continue;let d=Math.min(...a.map(f=>f.start)),p=Math.max(...a.map(f=>f.end)),c=n.get(l)??[];c.push({id:r.id,start:d,end:p}),n.set(l,c);}}return n}var he=class{constructor(t,n){b(this,"session",t);b(this,"storyIds");b(this,"baseParagraphs");b(this,"baseStories");b(this,"comments");this.storyIds=new Set(t.storyIds()),this.baseParagraphs=Sn(n),this.baseStories=Rn(n),this.comments=Tn(t,n.package.document.comments);}storyToBlocks(t){let n=[],r=this.baseStories.get(t),o=this.session.storySegments(t),s=this.comments.get(t)??[],l=[],a=0,d=0,p=0,c=g=>{let m=[];for(let y of s)y.start>=a&&y.start<=g&&m.push({id:y.id,kind:"start",offset:y.start-a}),y.end>=a&&y.end<=g&&m.push({id:y.id,kind:"end",offset:y.end-a});return m},f=(g,m)=>{let y=0;for(let k=0;k<g.length;k+=1)g[k]===" "&&(k>y&&l.push({kind:"text",text:g.slice(y,k),attributes:m}),l.push({kind:"embed",embedKind:"tab",payload:{},attributes:m}),y=k+1);y<g.length&&l.push({kind:"text",text:g.slice(y),attributes:m});};for(let g of o){if(g.kind==="text"){f(g.text,g.attributes),p+=g.text.length;continue}if(g.kind==="pilcrow"){let m=`${t}:p${d}`,y=g.paraId===m&&!this.baseParagraphs.has(g.paraId)?"":g.paraId;n.push(gn(y,g.properties,l,c(p),this.baseParagraphs.get(g.paraId))),l=[],d+=1,p+=1,a=p;continue}if(g.embedKind==="table")n.push(bn(this,g.payload));else if(g.embedKind==="blockSdt"){let m=S(g.payload.story),y=se(g.payload),k=m&&this.storyIds.has(m)?this.storyToBlocks(m):[],T=dt(g.payload.value);if(T)try{let b=L(y,T);y=b.properties,k=b.content;}catch{}n.push({type:"blockSdt",properties:y,content:k});}else if(g.embedKind==="opaque"){let m=w(g.payload.blob);if(m?.type==="pageBreak")n.push(kn());else {let y=r?.[n.length];m?.type==="blockSdt"&&y?.type==="blockSdt"&&n.push(y);}}else l.push(g);p+=1;}return l.length>0&&n.push({type:"paragraph",content:be(l)}),n}};function xn(e,t,n={}){let r=new he(e,t),o=c=>n.storyIds===void 0||n.storyIds.has(c),s=r.storyIds.has("body")&&o("body")?r.storyToBlocks("body"):t.package.document.content,l=t.package.headers;l&&(n.storyIds===void 0||[...l.keys()].some(c=>o(`hf:${c}`)))&&(l=new Map([...l].map(([c,f])=>{let g=`hf:${c}`;return [c,r.storyIds.has(g)&&o(g)?{...f,content:r.storyToBlocks(g)}:f]})));let a=t.package.footers;a&&(n.storyIds===void 0||[...a.keys()].some(c=>o(`hf:${c}`)))&&(a=new Map([...a].map(([c,f])=>{let g=`hf:${c}`;return [c,r.storyIds.has(g)&&o(g)?{...f,content:r.storyToBlocks(g)}:f]})));let p=n.storyIds===void 0||t.package.footnotes?.some(c=>o(`fn:${c.id}`))?t.package.footnotes?.map(c=>{let f=`fn:${c.id}`;return r.storyIds.has(f)&&o(f)?{...c,content:r.storyToBlocks(f),verbatimXml:void 0}:c}):t.package.footnotes;return {...t,package:{...t.package,document:{...t.package.document,content:s},...l?{headers:l}:{},...a?{footers:a}:{},...p?{footnotes:p}:{}}}}function Te(){return globalThis.__perfTrace}function ke(){return Te()?performance.now():0}function Se(e){return Te()?new TextEncoder().encode(e).byteLength:0}function Re(e,t,n){t!==0&&Te()?.record(e,performance.now()-t,n);}function Pn(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return Math.floor(Math.random()*4294967295)}function ct(e){return JSON.stringify("revisionId"in e?{revisionId:e.revisionId}:{story:e.story,startPara:e.start.paraId,startOffset:e.start.offset,endPara:e.end.paraId,endOffset:e.end.offset})}function wn(e){return JSON.stringify(e.map(t=>({story:t.story,startPara:t.start.paraId,startOffset:t.start.offset,endPara:t.end.paraId,endOffset:t.end.offset})))}function Cn(e,t){let n=new Set,r=false,o=false,s=null,l,a=null,d=new Map,p=new Map,c=[],f=new Map,g=new Map,m=null,y=0,k=false,T=()=>{l=void 0,a=null;},b=i=>(T(),i()),v=i=>i?{anchor:{...i.anchor},head:{...i.head}}:null,R=i=>{s!==i&&(e.track_undo(i),s=i);},x=i=>{let u=`table:${i}`;s!==u&&(e.track_table_undo(i),s=u);},B=i=>{let u=h=>typeof h=="string"&&h===i||typeof h=="number"&&Number.isFinite(h)&&String(h)===i;for(let h of e.story_ids())if(JSON.parse(e.story_segments(h)).some(_=>_.kind==="embed"&&(u(_.payload.embedId)||u(_.payload.id)||u(_.payload.rId))))return h;return null},O=i=>{let u=B(i);u&&R(u);},J=()=>{r||(e.set_update_observer(i=>{for(let u of [...n])u(i);}),r=true);};return {clientId:t,registerFont:i=>{k||(e.clear_measure_fonts(),k=true);let u=e.register_measure_font(i);return c.push(i.slice()),u},clearFonts:()=>{e.clear_measure_fonts(),c.length=0,g.clear(),k=true;},measureParagraphJson:i=>{let u=e.measure_paragraph_json(i);return g.set(i,i),u},layoutDocumentJson:i=>{let u=e.layout_document_json(i);return m=i,y+=1,u},buildDisplayListJson:i=>e.build_display_list_json(i),buildDisplayListFrame:(i,u)=>e.build_display_list_frame(i,u),applyInput:(i,u)=>{let h=l?.head.story??"body";return R(h),b(()=>e.apply_input(i,u))},applyDelete:(i,u)=>{let h=l?.head.story??"body";return R(h),b(()=>e.apply_delete(i,u))},applyInputProfiled:(i,u)=>{let h=l?.head.story??"body";R(h);let P=b(()=>e.apply_input_profiled(i,u)),_=JSON.parse(e.apply_input_profile_json());return {frame:P,profile:_}},applyDeleteProfiled:(i,u)=>{let h=l?.head.story??"body";R(h);let P=b(()=>e.apply_delete_profiled(i,u)),_=JSON.parse(e.apply_input_profile_json());return {frame:P,profile:_}},residentWorkerSnapshot:()=>{if(!m||f.size===0)return null;let i=e.selection();return {clientId:t,state:e.encode_state(),selection:JSON.parse(i),fonts:c.map(u=>u.slice()),renderInputs:[...f].map(([u,h])=>({story:u,env:structuredClone(h)})),measureInputs:[...g.values()],layoutInput:m,layoutRevision:y}},displayHitTestRegionsJson:(i,u,h)=>e.display_hit_test_regions_json(i,u,h),displayRangeRectsJson:(i,u)=>e.display_range_rects_json(i,u),displayRangeRectsRegionJson:(i,u,h,P)=>e.display_range_rects_region_json(i,u,h,P),outlineGlyphJson:(i,u)=>e.outline_glyph_json(i,u),loadState:i=>b(()=>e.load(i)),loadStories:i=>b(()=>JSON.parse(e.load_json(JSON.stringify(i)))),encodeState:()=>e.encode_state(),applyUpdate:i=>b(()=>e.apply_update(i)),applyLocalUpdate:(i,u)=>{R(u),b(()=>e.apply_local_update(i));},onUpdate:i=>(n.add(i),J(),()=>{n.delete(i);}),setSelection:(i,u=i)=>{if(i.story!==u.story)throw new Error("yrs selection must stay inside one story");e.set_selection(i.story,i.paraId,i.offset,u.paraId,u.offset),l={anchor:{...i},head:{...u}};},selection:()=>{if(l!==void 0)return v(l);let i=ke(),u=e.selection();return l=JSON.parse(u),Re("selectionReads",i,{bytes:Se(u),calls:1,detail:"stickySelectionMiss"}),v(l)},setCellSelection:i=>e.set_cell_selection(JSON.stringify(i)),cellSelection:()=>JSON.parse(e.cell_selection()),beginUndoCapture:(i,u=false)=>u?x(i):R(i),markUndoGroup:i=>{let u=e.undo_depth(),h=Math.max(0,u-i);h>1&&d.set(u,h),p.clear();},undo:()=>b(()=>{let i=e.undo_depth(),u=d.get(i)??1,h=false;for(let P=0;P<u;P+=1)h=e.undo()||h;return h&&u>1&&(d.delete(i),p.set(e.redo_depth(),u)),h}),redo:()=>b(()=>{let i=e.redo_depth(),u=p.get(i)??1,h=false;for(let P=0;P<u;P+=1)h=e.redo()||h;return h&&u>1&&(p.delete(i),d.set(e.undo_depth(),u)),h}),canUndo:()=>e.can_undo(),canRedo:()=>e.can_redo(),undoDepth:()=>e.undo_depth(),redoDepth:()=>e.redo_depth(),createStory:(i,u,h="Normal",P="left")=>b(()=>JSON.parse(e.create_story(i,u,h,P))),deleteStory:i=>b(()=>e.delete_story(i)),insertTable:(i,u,h,P)=>(x(i.story),b(()=>JSON.parse(e.insert_table(i.story,i.paraId,i.offset,u,h,P?.name,P?.date)))),insertRow:(i,u,h)=>(x(i.story),b(()=>JSON.parse(e.insert_row(JSON.stringify(i),u==="below",h?.name,h?.date)))),insertColumn:(i,u)=>(x(i.story),b(()=>JSON.parse(e.insert_column(JSON.stringify(i),u==="right")))),deleteRow:(i,u)=>(x(i.anchor.story),b(()=>JSON.parse(e.delete_row(JSON.stringify(i),u?.name,u?.date)))),deleteColumn:i=>(x(i.anchor.story),b(()=>JSON.parse(e.delete_column(JSON.stringify(i))))),deleteTable:i=>(x(i.story),b(()=>JSON.parse(e.delete_table(JSON.stringify(i))))),mergeCells:i=>(x(i.anchor.story),b(()=>JSON.parse(e.merge_cells(JSON.stringify(i))))),splitCell:(i,u,h)=>(x(i.story),b(()=>JSON.parse(e.split_cell(JSON.stringify(i),u,h)))),setCellShading:(i,u)=>(x(i.anchor.story),b(()=>JSON.parse(e.set_cell_shading(JSON.stringify(i),u??void 0)))),setCellTextFormat:(i,u)=>(x(i.anchor.story),b(()=>JSON.parse(e.set_cell_text_format(JSON.stringify(i),JSON.stringify(u))))),setCellBorders:(i,u)=>(x(i.anchor.story),b(()=>JSON.parse(e.set_cell_borders(JSON.stringify(i),JSON.stringify(u))))),setColumnWidth:(i,u)=>(x(i.story),b(()=>JSON.parse(e.set_column_width(JSON.stringify(i),u)))),setTableWidth:(i,u)=>(x(i.story),b(()=>JSON.parse(e.set_table_width(JSON.stringify(i),u)))),insertText:(i,u,h)=>(R(i.story),b(()=>JSON.parse(e.insert_text(i.story,i.paraId,i.offset,u,h?.name,h?.date)))),deleteRange:(i,u)=>(R(i.story),b(()=>JSON.parse(e.delete_range(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,u?.name,u?.date)))),replaceRange:(i,u,h)=>(R(i.story),b(()=>JSON.parse(e.replace_range(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,u,h?.name,h?.date)))),splitParagraph:(i,u)=>(R(i.story),b(()=>JSON.parse(e.split_paragraph(i.story,i.paraId,i.offset,u?.name,u?.date)))),mergeParagraphs:(i,u,h)=>(R(i),b(()=>JSON.parse(e.merge_paragraphs(i,u,h?.name,h?.date)))),toggleMark:(i,u)=>{R(i.story),b(()=>e.toggle_mark(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u)));},formatRange:(i,u)=>{R(i.story),b(()=>e.format_range(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u)));},setHyperlink:(i,u)=>{R(i.story),b(()=>e.set_hyperlink(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u)));},clearFormatting:i=>{R(i.story),b(()=>e.clear_formatting(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset));},applyParagraphStyle:(i,u,h)=>{R(i.story),b(()=>e.apply_paragraph_style(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,u,h?.name,h?.date));},setParagraphAttrs:(i,u,h)=>{R(i.story),b(()=>e.set_paragraph_attrs(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u),h?.name,h?.date));},insertImage:(i,u,h)=>(R(i.story),b(()=>JSON.parse(e.insert_image(i.story,i.paraId,i.offset,JSON.stringify(u),h?.name,h?.date)))),setContentControlValue:(i,u)=>{O(i),b(()=>e.set_content_control_value(i,JSON.stringify(u)));},setContentControlValueAt:(i,u)=>{R(i.story),b(()=>e.set_content_control_value_at(i.story,i.paraId,i.offset,JSON.stringify(u)));},clearContentControlValue:i=>{O(i),b(()=>e.clear_content_control_value(i));},setImageGeometry:(i,u)=>{O(i),b(()=>e.set_image_geometry(i,JSON.stringify(u)));},insertPageBreak:i=>{R(i.story),b(()=>e.insert_page_break(i.story,i.paraId,i.offset));},insertSectionBreak:(i,u)=>{R(i.story),b(()=>e.insert_section_break(i.story,i.paraId,i.offset,u));},insertWatermark:(i,u)=>{R(i.story),b(()=>e.insert_watermark(i.story,i.paraId,i.offset,JSON.stringify(u)));},applyRawOps:(i,u)=>b(()=>e.apply_raw_ops(i,JSON.stringify(u))),setParagraphAttr:(i,u,h)=>b(()=>e.set_paragraph_attr(i,u,JSON.stringify(h??null))),addComment:(i,u,h,P)=>b(()=>JSON.parse(e.add_comment(wn(i),u,h,JSON.stringify(P??null)))),acceptChange:i=>b(()=>JSON.parse(e.accept_change(ct(i)))),rejectChange:i=>b(()=>JSON.parse(e.reject_change(ct(i)))),selectionContext:i=>{let u=JSON.stringify(i);if(a?.key===u)return JSON.parse(a.json);let h=ke(),P=e.selection_context(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset),_=JSON.parse(P);return a={key:u,json:P},Re("selectionContext",h,{bytes:Se(P),calls:1}),_},listRevisions:()=>JSON.parse(e.list_revisions()),resolveComment:i=>JSON.parse(e.resolve_comment(i)),storyIds:()=>e.story_ids(),storyLength:i=>e.story_len(i),storyChecksum:i=>BigInt(e.story_checksum(i)),yrsBlocksForStory:(i,u={})=>{let h=ke(),P=e.yrs_blocks_for_story(i,JSON.stringify(u)),_=JSON.parse(P);return f.set(i,structuredClone(u)),Re("storyBlocks",h,{bytes:Se(P),calls:1,detail:i}),_},paragraphs:i=>JSON.parse(e.paragraphs(i)),paragraphSpans:i=>JSON.parse(e.paragraph_spans(i)),storySegments:i=>JSON.parse(e.story_segments(i)),locateParagraph:(i,u)=>JSON.parse(e.locate_paragraph(i,u)),destroy:()=>{o||(o=true,n.clear(),r&&e.clear_update_observer(),e.free());}}}async function cr(e){let t=e?.clientId??Pn(),n=await import('../wasm-FZQ5XB2Y.mjs');return await n.preloadEditWasm(),Cn(n.createEditSession(t),t)}export{ie as ResidentEngineWorkerClient,pt as canUseResidentEngineWorker,An as compareYrsLocs,In as createYrsInputPositionMap,cr as createYrsSession,vn as displayPositionToYrsLoc,qt as documentToYrs,Ae as yrsLocToDisplayPosition,xn as yrsToDocument};
|
|
1
|
+
export{a as residentCaretDeviceRect,b as residentCaretSnapshotForFrame}from'../chunk-J7LNO6SM.mjs';import {b as b$3}from'../chunk-OBQGPMPQ.mjs';import {c,a}from'../chunk-WBH3SXI6.mjs';import {p,b as b$1}from'../chunk-IFT6DUJX.mjs';import {c as c$1,b as b$2}from'../chunk-3UBMCDME.mjs';import {b}from'../chunk-TTRUPDAB.mjs';function Mn(e,t){let n=0,r=t.map(o=>{let l={paraId:o.paraId,length:Math.max(0,Math.trunc(o.length)),displayStart:n};return n+=l.length+2,l});return {story:e,paragraphs:r}}function Fe(e,t){let n=e.paragraphs.find(r=>r.paraId===t.paraId);return !n||t.story!==e.story?e.paragraphs[0]?.displayStart??0:n.displayStart+1+Math.min(Math.max(0,t.offset),n.length)}function _n(e,t){if(e.paragraphs.length===0)return null;let n=Math.max(0,Math.trunc(t)),r=e.paragraphs[0];for(let o of e.paragraphs){if(o.displayStart>n)break;r=o;}return {story:e.story,paraId:r.paraId,offset:Math.min(Math.max(0,n-(r.displayStart+1)),r.length)}}function Bn(e,t,n){return Fe(e,t)-Fe(e,n)}var ae=class{constructor(){b(this,"worker");b(this,"pending",new Map);b(this,"nextId",1);b(this,"destroyed",false);b(this,"ready",false);b(this,"revision",0);b(this,"remoteVector",null);b(this,"appliedFontsRevision",null);this.worker=new Worker(new URL("./residentEngineWorker.mjs",import.meta.url),{type:"module",name:"openooxml-resident-engine"}),this.worker.onmessage=t=>{let n=t.data;n.ok&&n.stateVector&&(this.remoteVector=new Uint8Array(n.stateVector));let r=this.pending.get(n.id);r&&(this.pending.delete(n.id),r.timeout&&clearTimeout(r.timeout),n.ok?r.resolve(n):r.reject(St(n.error,n.residentUnavailable)));},this.worker.onerror=t=>{this.failAll(new Error(`Resident engine worker failed: ${t.message}`)),this.ready=false;},this.worker.onmessageerror=()=>{this.failAll(new Error("Resident engine worker returned an unreadable message")),this.ready=false;};}isReady(){return this.ready}layoutRevision(){return this.revision}remoteStateVector(){return this.remoteVector}syncedFontsRevision(){return this.appliedFontsRevision}async bootstrap(t,n){let r=t.fontsRevision,o=await this.request({type:"bootstrap",snapshot:t,extras:n,expectedFrameEpoch:0},Ye(t),15e3),l=V(o);return this.recordSync(o,r),this.ready=true,this.revision=l.layoutRevision,l}async sync(t,n,r,o=false){let l=t.fontsRevision,s=await this.request({type:"sync",snapshot:t,extras:n,expectedFrameEpoch:r,paintCaret:o},Ye(t)),a=V(s);return this.recordSync(s,l),this.ready=true,this.revision=a.layoutRevision,a}async buildFrame(t,n,r=false){return V(await this.request({type:"buildFrame",extras:t,expectedFrameEpoch:n,paintCaret:r}))}async applyInput(t,n,r,o=false,l=false){if(!this.ready)return {applied:false};try{return {applied:!0,...V(await this.request({type:"applyInput",text:t,selection:n,expectedFrameEpoch:r,profile:o,paintCaret:l}))}}catch(s){if(s instanceof K)return {applied:false};throw s}}async applyDelete(t,n,r,o=false,l=false){if(!this.ready)return {applied:false};try{return {applied:!0,...V(await this.request({type:"applyDelete",direction:t,selection:n,expectedFrameEpoch:r,profile:o,paintCaret:l}))}}catch(s){if(s instanceof K)return {applied:false};throw s}}eraseCaret(){if(this.destroyed)return;let n={id:this.nextId++,type:"eraseCaret"};this.worker.postMessage(n);}invalidate(t,n){if(this.destroyed)return;this.ready=false;let r=t.slice(),l={id:this.nextId++,type:"applyUpdate",update:r,selection:n};this.worker.postMessage(l,[r.buffer]);}async attachCanvases(t,n,r,o,l){let s=t.map(a=>a.canvas);await this.request({type:"attachCanvases",pages:t,activePageIds:n,devicePixelRatio:r,zoom:o,caretStyle:l},s);}destroy(){if(this.destroyed)return;this.destroyed=true;let n={id:this.nextId++,type:"destroy"};this.worker.postMessage(n),this.worker.terminate(),this.failAll(new Error("Resident engine worker was destroyed")),this.ready=false;}request(t,n=[],r){if(this.destroyed)return Promise.reject(new Error("Resident engine worker was destroyed"));let o=this.nextId++;return new Promise((l,s)=>{let a=r?setTimeout(()=>{let d=this.pending.get(o);if(!d)return;this.pending.delete(o);let f=new Error(`Resident engine worker did not acknowledge ${t.type} within ${r}ms`);d.reject(f),this.failAll(f),this.ready=false,this.destroyed=true,this.worker.terminate();},r):null;this.pending.set(o,{resolve:l,reject:s,timeout:a}),this.worker.postMessage({...t,id:o},n);})}recordSync(t,n){this.appliedFontsRevision=n;}failAll(t){for(let n of this.pending.values())n.timeout&&clearTimeout(n.timeout),n.reject(t);this.pending.clear();}},K=class extends Error{};function St(e,t=false){return t?new K(e):new Error(e)}function Ye(e){return [e.state.buffer,...e.fonts.map(t=>t.buffer)]}function V(e){if(!e.frame)throw new Error("Resident engine worker response omitted its FrameDelta");if(!e.caret)throw new Error("Resident engine worker response omitted its caret snapshot");if(e.selection===void 0)throw new Error("Resident engine worker response omitted its selection");return {frame:new Uint8Array(e.frame),updates:(e.updates??[]).map(t=>new Uint8Array(t)),engineMs:e.engineMs??0,workerTotalMs:e.workerTotalMs??0,engineProfile:e.engineProfile,caret:e.caret,selection:e.selection,caretPainted:e.caretPainted??false,replayMs:e.replayMs??0,replayedPages:e.replayedPages??0,layoutRevision:e.layoutRevision??0}}function Rt(){return typeof Worker<"u"}function de(e){return {sdtType:e.sdtType,id:e.id??null,alias:e.alias??null,tag:e.tag??null,lock:e.lock??null,placeholder:e.placeholder??null,showingPlaceholder:e.showingPlaceholder??false,dateFormat:e.dateFormat??null,listItems:e.listItems?JSON.stringify(e.listItems):null,checked:e.checked??null,dataBinding:e.dataBinding?JSON.stringify(e.dataBinding):null,rawPropertiesXml:e.rawPropertiesXml??null,rawEndPropertiesXml:e.rawEndPropertiesXml??null}}function ue(e){let t={sdtType:e.sdtType??"richText"};if(typeof e.id=="number"&&(t.id=e.id),e.alias!=null&&(t.alias=String(e.alias)),e.tag!=null&&(t.tag=String(e.tag)),e.lock!=null&&(t.lock=e.lock),e.placeholder!=null&&(t.placeholder=String(e.placeholder)),e.showingPlaceholder&&(t.showingPlaceholder=true),e.dateFormat!=null&&(t.dateFormat=String(e.dateFormat)),typeof e.listItems=="string"&&e.listItems)try{t.listItems=JSON.parse(e.listItems);}catch{}if(e.checked!=null&&(t.checked=e.checked),typeof e.dataBinding=="string"&&e.dataBinding)try{t.dataBinding=JSON.parse(e.dataBinding);}catch{}return e.rawPropertiesXml!=null&&(t.rawPropertiesXml=String(e.rawPropertiesXml)),e.rawEndPropertiesXml!=null&&(t.rawEndPropertiesXml=String(e.rawEndPropertiesXml)),t}function E(e){if(Array.isArray(e))return e.map(E);if(e!==null&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[n]=E(r));return t}return e}var Tt={styleId:"pStyle",_sectionProperties:"sectPr"},xt=new Set(["paraId","textId","renderedPageBreakBefore","numPrFromStyle"]);function Me(e){let t={};for(let[n,r]of Object.entries(e))xt.has(n)||r===null||r===void 0||(t[Tt[n]??n]=E(r));return t}var wt=new Set(["columnWidths"]);function Q(e,t=new Set){let n={};for(let[r,o]of Object.entries(e))t.has(r)||o===null||o===void 0||(n[r]=E(o));return n}function _e(e){return Q(e,wt)}function Be(e){let t=e.columnWidths;return Array.isArray(t)?t.map(E):[]}function Ne(e){return Q(e)}function Oe(e,t){let n=Q(e);return t&&(n.header=true),n}function ce(e,t,n,r){return `${e}:t${t}:r${n}c${r}`}function Ee(e,t){return `${e}:sdt${t}`}function Le(e){return Q(e)}function ee(e){return `hf:${e}`}function De(e){return `fn:${e}`}function Je(e){return `en:${e}`}var Pt=new Set(["bold","italic","superscript","subscript","allCaps","smallCaps","emboss","imprint","textShadow","textOutline","hidden","rtl"]);function H(e){if(e==null)return "null";if(Array.isArray(e))return `[${e.map(H).join(",")}]`;if(typeof e=="object"){let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${H(t[n])}`).join(",")}}`}return JSON.stringify(e)}function Ct(e,t){if(!e||!t)return e;let n=t.resolveRunStyle(e.styleId);return n?a(n,e):e}function je(e){if(!e)return [];let t=[],n=(s,a={})=>t.push({name:s,attrs:a});e.bold&&n("bold"),e.italic&&n("italic"),e.underline&&e.underline.style!=="none"&&n("underline",{style:e.underline.style,color:e.underline.color??null}),(e.strike||e.doubleStrike)&&n("strike",{double:e.doubleStrike||false}),e.color&&!e.color.auto&&n("textColor",{rgb:e.color.rgb??null,themeColor:e.color.themeColor??null,themeTint:e.color.themeTint??null,themeShade:e.color.themeShade??null});let r=e.shading?.fill,o=(!e.shading?.pattern||e.shading.pattern==="clear")&&r?.rgb&&!r.auto?p(r.rgb):void 0,l=e.highlight&&e.highlight!=="none"?e.highlight:o;return l&&n("highlight",{color:l}),(e.fontSize!=null||e.fontSizeCs!=null)&&n("fontSize",{size:e.fontSize??null,sizeCs:e.fontSizeCs??null}),e.fontFamily&&n("fontFamily",{ascii:e.fontFamily.ascii??null,hAnsi:e.fontFamily.hAnsi??null,eastAsia:e.fontFamily.eastAsia??null,cs:e.fontFamily.cs??null,asciiTheme:e.fontFamily.asciiTheme??null,hAnsiTheme:e.fontFamily.hAnsiTheme??null,eastAsiaTheme:e.fontFamily.eastAsiaTheme??null,csTheme:e.fontFamily.csTheme??null}),e.vertAlign==="superscript"?n("superscript"):e.vertAlign==="subscript"&&n("subscript"),e.allCaps&&n("allCaps"),e.smallCaps&&n("smallCaps"),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&n("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null}),e.emboss&&n("emboss"),e.imprint&&n("imprint"),e.shadow&&n("textShadow"),e.emphasisMark&&e.emphasisMark!=="none"&&n("emphasisMark",{type:e.emphasisMark}),e.outline&&n("textOutline"),e.hidden&&n("hidden"),e.rtl&&n("rtl"),e.effect&&e.effect!=="none"&&n("textEffect",{effect:e.effect}),e.modernEffects&&n("modernTextEffects",{effects:e.modernEffects}),e.styleId&&n("runStyle",{styleId:e.styleId}),t}function $e(e){let t={};for(let n of e)n.name==="comment"||n.name==="footnoteRef"||(Pt.has(n.name)?t[n.name]=true:n.name==="highlight"?t.highlight=n.attrs.color:n.name==="insertion"||n.name==="deletion"?t[n.name==="insertion"?"ins":"del"]=E({id:n.attrs.revisionId,author:n.attrs.author,date:n.attrs.date}):t[n.name]=E(n.attrs));return t}function It(e){return e.filter(t=>t.name!=="hyperlink"&&t.name!=="comment").map(t=>`${t.name}:${JSON.stringify(t.attrs)}`).sort().join("|")}function vt(e,t){return [...e.filter(n=>n.name!==t.name),t]}function q(e,t,n){return {kind:"text",text:e,attrs:$e(t),pmSize:e.length,...n!==void 0?{commentId:n}:{},marks:[...t]}}function v(e,t,n=[],r,o=1){return {kind:"embed",embedKind:e,payload:t,attrs:$e(n),pmSize:o,...r!==void 0?{commentId:r}:{},marks:[...n]}}function He(e,t,n){let r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0;return je(a(a(t,r),e.formatting))}function At(e){let t=e.size?.width?b$2(e.size.width):void 0,n=e.size?.height?b$2(e.size.height):void 0,r=e.wrap.type,o=e.wrap.wrapText,l=e.position?.horizontal?.alignment,s;r==="inline"||r==="topAndBottom"?s="none":r==="square"||r==="tight"||r==="through"?o==="left"?s="right":o==="right"?s="left":l==="left"||l==="right"?s=l:s="none":s="none";let a=r==="inline"?"inline":r==="topAndBottom"?"block":b$3(r)||s&&s!=="none"?"float":"block",d=[];e.transform?.rotation&&d.push(`rotate(${e.transform.rotation}deg)`),e.transform?.flipH&&d.push("scaleX(-1)"),e.transform?.flipV&&d.push("scaleY(-1)");let f,c,p;if(e.outline?.width){f=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(c=`#${e.outline.color.rgb}`);let g={solid:"solid",dot:"dotted",dash:"dashed",lgDash:"dashed",dashDot:"dashed",lgDashDot:"dashed",lgDashDotDot:"dashed",sysDot:"dotted",sysDash:"dashed",sysDashDot:"dashed",sysDashDotDot:"dashed"};p=e.outline.style&&g[e.outline.style]||"solid";}return E({src:e.src||"",alt:e.alt??null,title:e.title??null,width:t??null,height:n??null,rId:e.rId??null,wrapType:r,displayMode:a,cssFloat:s??null,transform:d.length>0?d.join(" "):null,distTop:e.wrap.distT!=null?b$2(e.wrap.distT):null,distBottom:e.wrap.distB!=null?b$2(e.wrap.distB):null,distLeft:e.wrap.distL!=null?b$2(e.wrap.distL):null,distRight:e.wrap.distR!=null?b$2(e.wrap.distR):null,position:e.position?{horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0}:null,borderWidth:f??null,borderColor:c??null,borderStyle:p??null,wrapText:o??null,hlinkHref:e.hlinkHref??null,cropTop:e.crop?.top??null,cropRight:e.crop?.right??null,cropBottom:e.crop?.bottom??null,cropLeft:e.crop?.left??null,opacity:e.opacity??null,effectExtentTop:e.padding?.top?b$2(e.padding.top):null,effectExtentBottom:e.padding?.bottom?b$2(e.padding.bottom):null,effectExtentLeft:e.padding?.left?b$2(e.padding.left):null,effectExtentRight:e.padding?.right?b$2(e.padding.right):null,layoutInCell:e.layoutInCell??null,allowOverlap:e.allowOverlap??null})}function Ft(e){return {shapeJson:JSON.stringify(e)}}function Yt(e){return E({chartJson:JSON.stringify(e),chartType:e.chartType??null,title:e.title??null,width:e.size?.width?b$2(e.size.width):320,height:e.size?.height?b$2(e.size.height):220,rId:e.rId??null,path:e.path??null})}function fe(e,t){let n="",r,o=e.type==="simpleField"?e.content:e.fieldResult;for(let a of o)if(a.type==="run"){for(let d of a.content)d.type==="text"&&(n+=d.text);!r&&a.formatting&&(r=a.formatting);}let l=r??(e.type==="complexField"?e.formatting:void 0),s=e.fieldTree?.displayMode??"result";return {payload:{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false,displayMode:s,hasCachedResult:n.length>0,fieldData:JSON.stringify(e),modelKind:"field"},marks:je(a(t,l))}}function ge(e){return {display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""}}function Mt(e){return {name:"hyperlink",attrs:{href:e.href||(e.anchor?`#${e.anchor}`:""),tooltip:e.tooltip??null,rId:e.rId??null}}}function Ue(e,t,n,r){let o={name:"footnoteRef",attrs:{id:String(e),noteType:t}},l=[...n,o];return v("noteRef",t==="endnote"?{endnoteRefId:e}:{footnoteRefId:e},l,r,String(e).length)}function ze(e,t,n){switch(e.type){case "text":return e.text?[q(e.text,t,n)]:[];case "tab":return [q(" ",t,n)];case "break":return e.breakType===void 0||e.breakType==="textWrapping"?[v("break",{},t,n)]:[];case "softHyphen":return [q("\xAD",t,n)];case "noBreakHyphen":return [q("\u2011",t,n)];case "symbol":{let r=Number.parseInt(e.char,16);if(!Number.isInteger(r)||r<0||r>1114111)return [];let o={name:"fontFamily",attrs:{ascii:e.font||null,hAnsi:e.font||null,eastAsia:e.font||null,cs:e.font||null,asciiTheme:null,hAnsiTheme:null,eastAsiaTheme:null,csTheme:null}};return [q(String.fromCodePoint(r),vt(t,o),n)]}case "commentReference":return [v("field",{fieldType:"COMMENT",instruction:"",displayText:"",fieldKind:"simple",fldLock:false,dirty:false,displayMode:"result",hasCachedResult:false,modelKind:"commentReference",...e.id!==void 0?{commentId:e.id}:{}})];case "drawing":return [v("image",At(e.image))];case "shape":return [v("shape",Ft(e.shape))];case "chart":return [v("chart",Yt(e.chart))];case "footnoteRef":return [Ue(e.id,"footnote",t,n)];case "endnoteRef":return [Ue(e.id,"endnote",t,n)];default:return []}}function te(e,t,n,r,o=[]){let l=[...He(e,t,n),...o];return e.content.flatMap(s=>ze(s,l,r))}function me(e,t,n,r=[]){let o=[],l=Mt(e);for(let s of e.structuredChildren??e.children)if(s.type==="run"){let a=[...He(s,t,n),...r,l];for(let d of s.content)o.push(...ze(d,a));}else if(s.type==="simpleField"||s.type==="complexField"){let a=fe(s,t);o.push(v("field",a.payload,[...a.marks,...r,l]));}else s.type==="mathEquation"&&o.push(v("math",ge(s),[...r,l]));return o}function _t(e,t,n){return {name:t,attrs:{revisionId:e.id,author:e.author,date:e.date??null,isMovePair:n}}}function Bt(e,t,n,r){let o=e.type==="insertion"||e.type==="moveTo"?"insertion":"deletion",l=_t(e.info,o,e.type==="moveFrom"||e.type==="moveTo"),s=[];for(let a of e.content)if(a.type==="run")s.push(...te(a,t,n,r,[l]));else {let d=me(a,t,n,[l]);for(let f of d)r!==void 0&&(f.commentId=r);s.push(...d);}return s}function Ve(e,t,n){let r=[],o=l=>{if(l.kind==="text"){if((l.text===" "?"tab":"text")==="tab"){r.push({kind:"tab",attrs:l.attrs});return}let a=r[r.length-1];a&&"text"in a&&H(a.attrs)===H(l.attrs)?a.text+=l.text:r.push({kind:"text",text:l.text,attrs:l.attrs});return}r.push({kind:l.embedKind,payload:l.payload,attrs:l.attrs});};for(let l of e.content)if(l.type==="run")te(l,t,n).forEach(o);else if(l.type==="hyperlink")me(l,t,n).forEach(o);else if(l.type==="simpleField"||l.type==="complexField"){let s=fe(l,t);o(v("field",s.payload,s.marks));}else l.type==="inlineSdt"?o(v("sdt",Ve(l,t,n))):l.type==="mathEquation"&&o(v("math",ge(l)));return E({...de(e.properties),propertiesJson:JSON.stringify(e.properties),content:r})}function Nt(e,t,n){let r=t?t.resolveParagraphStyle(e.formatting?.styleId).runFormatting:void 0;return a(r,n)}function Ot(e,t,n){let r=te(e,t,n);if(r.some(a=>a.kind!=="text"&&a.embedKind!=="noteRef"))return null;let o=r.map(a=>It(a.marks));if(o.some(a=>a!==o[0]))return null;let l=r.map(a=>{if(a.kind==="text")return a.text;let d=a.payload.footnoteRefId??a.payload.endnoteRefId;return String(d??"")}).join(""),s=o[0];return {text:l,...s!==void 0?{marksKey:s}:{},...e.formatting?{formatting:e.formatting}:{},...e.propertyChanges?{propertyChanges:e.propertyChanges}:{}}}function Et(e,t,n,r){let o=e.formatting,l=o?.styleId,s={paraId:e.paraId??null,textId:e.textId??null,styleId:l??null,numPr:o?.numPr??null,numPrFromStyle:o?.numPrFromStyle??null,listNumFmt:e.listRendering?.numFmt??null,listIsBullet:e.listRendering?.isBullet??null,listMarker:e.listRendering?.marker??null,listMarkerHidden:e.listRendering?.markerHidden||null,listMarkerFontFamily:e.listRendering?.markerFontFamily||null,listMarkerFontSize:e.listRendering?.markerFontSize||null,listMarkerSuffix:e.listRendering?.markerSuffix||null,listLevelNumFmts:e.listRendering?.levelNumFmts||null,listAbstractNumId:e.listRendering?.abstractNumId??null,listStartOverride:e.listRendering?.startOverride??null,_originalFormatting:o??null};if(t){let c=t.resolveParagraphStyle(l),p=c.paragraphFormatting;s.alignment=o?.alignment??p?.alignment??null,s.spaceBefore=o?.spaceBefore??p?.spaceBefore??null,s.spaceAfter=o?.spaceAfter??p?.spaceAfter??null,s.lineSpacing=o?.lineSpacing??p?.lineSpacing??null,s.lineSpacingRule=o?.lineSpacingRule??p?.lineSpacingRule??null,s.spacingExplicit=o?.spacingExplicit||null,s.indentLeft=o?.indentLeft??p?.indentLeft??null,s.indentRight=o?.indentRight??p?.indentRight??null;let m=o?.numPr?.numId===0&&p?.numPr&&p.numPr.numId!==0?void 0:p;s.indentFirstLine=o?.indentFirstLine??m?.indentFirstLine??null,s.hangingIndent=o?.hangingIndent??m?.hangingIndent??false,s.borders=o?.borders??p?.borders??null,s.shading=o?.shading??p?.shading??null,s.tabs=o?.tabs??p?.tabs??null,s.pageBreakBefore=o?.pageBreakBefore??p?.pageBreakBefore??null,s.keepNext=o?.keepNext??p?.keepNext??null,s.keepLines=o?.keepLines??p?.keepLines??null,s.contextualSpacing=o?.contextualSpacing??p?.contextualSpacing??null,s.outlineLevel=o?.outlineLevel??p?.outlineLevel??null,s.bidi=o?.bidi??p?.bidi??null;let y=t.getDefaultCharacterStyle()?.rPr,k=y?a(c.runFormatting,y):c.runFormatting;s.defaultTextFormatting=a(k,Ct(o?.runProperties,t))??null,!o?.numPr&&p?.numPr&&p.numPr.numId!==0&&(s.numPr=p.numPr,s.numPrFromStyle=p.numPr);}else s.alignment=o?.alignment??null,s.spaceBefore=o?.spaceBefore??null,s.spaceAfter=o?.spaceAfter??null,s.lineSpacing=o?.lineSpacing??null,s.lineSpacingRule=o?.lineSpacingRule??null,s.spacingExplicit=o?.spacingExplicit||null,s.indentLeft=o?.indentLeft??null,s.indentRight=o?.indentRight??null,s.indentFirstLine=o?.indentFirstLine??null,s.hangingIndent=o?.hangingIndent??false,s.borders=o?.borders??null,s.shading=o?.shading??null,s.tabs=o?.tabs??null,s.pageBreakBefore=o?.pageBreakBefore??null,s.keepNext=o?.keepNext??null,s.keepLines=o?.keepLines??null,s.outlineLevel=o?.outlineLevel??null,s.bidi=o?.bidi??null,s.defaultTextFormatting=o?.runProperties??null;if(e.sectionProperties){s._sectionProperties=e.sectionProperties;let c=e.sectionProperties.sectionStart;(c==="nextPage"||c==="continuous"||c==="oddPage"||c==="evenPage")&&(s.sectionBreakType=c);}e.renderedPageBreakBefore&&(s.renderedPageBreakBefore=true),Jt(e)&&(s.pageBreakBefore=true),e.pPrIns&&(s.pPrIns={revisionId:e.pPrIns.id,author:e.pPrIns.author,date:e.pPrIns.date??null}),e.pPrDel&&(s.pPrDel={revisionId:e.pPrDel.id,author:e.pPrDel.author,date:e.pPrDel.date??null}),e.propertyChanges?.length&&(s.pPrChange=e.propertyChanges);let a$1=[],d=0,f=0;for(let c of e.content)if(c.type==="bookmarkStart")a$1.push({id:c.id,name:c.name,kind:"start",offset:f,...c.colFirst!==void 0?{colFirst:c.colFirst}:{},...c.colLast!==void 0?{colLast:c.colLast}:{}});else if(c.type==="bookmarkEnd")a$1.push({id:c.id,kind:"end",offset:f});else {let p=Lt(c);for(let g=0;g<p;g+=1)f+=n[d]?.pmSize??0,d+=1;}return a$1.length>0&&(s.bookmarks=a$1),r?.length&&(s._originalRunBoundaries=r),s}var Ke=new WeakMap;function Lt(e){return Ke.get(e)??0}function Dt(e,t,n){let r=[],o=new Set,l=[],s=Nt(e,t,n);for(let d of e.content){let f=r.length,c=o.values().next().value;if(d.type==="commentRangeStart")o.add(d.id);else if(d.type==="commentRangeEnd")o.delete(d.id);else if(d.type==="run"){let p=Ot(d,s,t);p&&l?l.push(p):l=void 0,r.push(...te(d,s,t,c));}else if(d.type==="hyperlink")l=void 0,r.push(...me(d,s,t));else if(d.type==="simpleField"||d.type==="complexField"){l=void 0;let p=fe(d,s);r.push(v("field",p.payload,p.marks));}else d.type==="inlineSdt"?(l=void 0,r.push(v("sdt",Ve(d,s,t),[],void 0,2))):d.type==="insertion"||d.type==="deletion"||d.type==="moveFrom"||d.type==="moveTo"?(l=void 0,r.push(...Bt(d,s,t,c))):d.type==="mathEquation"?(l=void 0,r.push(v("math",ge(d)))):d.type!=="bookmarkStart"&&d.type!=="bookmarkEnd"&&(l=void 0);Ke.set(d,r.length-f);}let a=Et(e,t,r,l);return {units:r,ppr:Me(a)}}function X(e,t){for(let n of e.content)n.type==="break"&&n.breakType==="page"?t.push("pageBreak"):(n.type!=="text"||n.text.length>0)&&t.push("visible");}function he(e,t){for(let n of e)if(n.type==="run")X(n,t);else if(n.type==="hyperlink")for(let r of n.children)r.type==="run"&&X(r,t);else if(n.type==="simpleField")for(let r of n.content)r.type==="run"&&X(r,t);else if(n.type==="complexField")for(let r of [...n.fieldCode,...n.fieldResult])X(r,t);else if(n.type==="inlineSdt")he(n.content,t);else if(n.type==="insertion"||n.type==="deletion"||n.type==="moveFrom"||n.type==="moveTo")for(let r of n.content)r.type==="run"&&X(r,t);else n.type==="mathEquation"&&t.push("visible");}function Jt(e){let t=[];return he(e.content,t),t[0]==="pageBreak"}function Ut(e){let t=[];he(e.content,t);let n=false,r=false;for(let o of t)if(o==="pageBreak"){if(r||n)return true;n=true;}else r=true;return false}function Wt(e){let t=new Map,n=new Map;return e.rows.forEach((r,o)=>{let l=0,s=r.cells.map(d=>{let f=l;return l+=d.formatting?.gridSpan??1,{column:f,vMerge:d.formatting?.vMerge,key:`${o}-${f}`}});if(s.length>0&&s.every(d=>d.vMerge==="continue"&&n.has(d.column))){for(let d of s)n.delete(d.column),t.set(d.key,{rowSpan:1,skip:false});return}for(let d of s)if(d.vMerge==="restart")n.set(d.column,o),t.set(d.key,{rowSpan:1,skip:false});else if(d.vMerge==="continue"){let f=n.get(d.column);if(f===void 0)t.set(d.key,{rowSpan:1,skip:false});else {let c=t.get(`${f}-${d.column}`);c&&(c.rowSpan+=1),t.set(d.key,{rowSpan:1,skip:true});}}else n.delete(d.column),t.set(d.key,{rowSpan:1,skip:false});}),t}function pe(e){return {revisionId:e.id,author:e.author,date:e.date??null}}function jt(e,t,n,r,o,l){let s=t?{top:n?t.top:t.insideH,bottom:r?t.bottom:t.insideH,left:o?t.left:t.insideV,right:l?t.right:t.insideV}:void 0;return s||e?.borders?{...s??{},...e?.borders??{}}:void 0}function We(e,t){let n=e.formatting,r=b$1(n?.shading?.fill,t.theme),o=n?.width?.value??t.gridWidth,l=n?.width?.type??(t.gridWidth!==void 0?"pct":null),s={colspan:n?.gridSpan??1,rowspan:t.rowspan,width:o??null,widthType:l,verticalAlign:n?.verticalAlign??null,backgroundColor:r??null,borders:jt(n,t.tableBorders,t.firstRow,t.lastRow,t.firstColumn,t.lastColumn)??null,margins:n?.margins?{top:n.margins.top?.value,bottom:n.margins.bottom?.value,left:n.margins.left?.value??(t.tableBidi?n.margins.end?.value:n.margins.start?.value),right:n.margins.right?.value??(t.tableBidi?n.margins.start?.value:n.margins.end?.value)}:t.defaultMargins??null,textDirection:n?.textDirection??null,noWrap:n?.noWrap??false,_originalFormatting:n??null,_originalResolvedFill:r??null};if(e.structuralChange){let a=e.structuralChange,d=pe(a.info);a.type==="tableCellInsertion"?s.cellMarker={kind:"ins",info:d}:a.type==="tableCellDeletion"?s.cellMarker={kind:"del",info:d}:a.type==="tableCellMerge"&&(s.cellMarker={kind:"merge",info:d,vMerge:a.vMerge??"cont",...a.vMergeOrig?{vMergeOrig:a.vMergeOrig}:{}});}return e.propertyChanges?.length&&(s.tcPrChange=e.propertyChanges),{attrs:Oe(s,t.isHeader),content:e.content.length>0?e.content:[{type:"paragraph",content:[]}]}}function $t(e,t,n,r,o,l,s){let a={height:e.formatting?.height?.value??null,heightRule:e.formatting?.heightRule??null,isHeader:!!e.formatting?.header,_originalFormatting:e.formatting??null};e.structuralChange&&(e.structuralChange.type==="tableRowInsertion"?a.trIns=pe(e.structuralChange.info):e.structuralChange.type==="tableRowDeletion"&&(a.trDel=pe(e.structuralChange.info))),e.propertyChanges?.length&&(a.trPrChange=e.propertyChanges);let d=t.columnWidths,f=d?.reduce((m,y)=>m+y,0)??0,c=d?.length??Math.max(0,...t.rows.map(m=>m.cells.reduce((y,k)=>y+(k.formatting?.gridSpan??1),0))),p=0,g=[];return e.cells.forEach(m=>{let y=m.formatting?.gridSpan??1,k=p,R=r.get(`${n}-${k}`),x;if(d&&f>0){let I=0;for(let C=0;C<y&&k+C<d.length;C+=1)I+=d[k+C];x=Math.round(I/f*100);}p+=y,!R?.skip&&g.push(We(m,{isHeader:n===0&&!!t.formatting?.look?.firstRow,rowspan:R?.rowSpan??1,gridWidth:x,firstRow:n===0,lastRow:n===t.rows.length-1,firstColumn:k===0,lastColumn:p===c,tableBorders:o,defaultMargins:l,theme:s,tableBidi:!!t.formatting?.bidi}));}),g.length===0&&g.push(We({formatting:c>1?{gridSpan:c}:void 0,content:[{type:"paragraph",content:[]}]},{isHeader:n===0&&!!t.formatting?.look?.firstRow,rowspan:1,gridWidth:f>0?100:void 0,firstRow:n===0,lastRow:n===t.rows.length-1,firstColumn:true,lastColumn:true,tableBorders:o,defaultMargins:l,theme:s,tableBidi:!!t.formatting?.bidi})),{attrs:Ne(a),cells:g}}function Ht(e,t,n){let r=t?.getDefaultTableStyle(),o=e.formatting?.styleId,l=o??r?.styleId,s=l?t?.getStyle(l):void 0,a=e.formatting?.borders??s?.tblPr?.borders??r?.tblPr?.borders,d=e.formatting?.cellMargins??s?.tblPr?.cellMargins??r?.tblPr?.cellMargins,f=e.formatting?.bidi?d?.end:d?.start,c=e.formatting?.bidi?d?.start:d?.end,p=d?{top:d.top?.value,bottom:d.bottom?.value,left:d.left?.value??f?.value,right:d.right?.value??c?.value}:void 0,g=[],m=new Set,y=s;for(;y?.basedOn&&g.length<32&&!m.has(y.basedOn);)m.add(y.basedOn),g.unshift(y.basedOn),y=t?.getStyle(y.basedOn);let k={...e.formatting??{},styleCascade:{...o?{selectedStyleId:o}:{},...r?.styleId?{defaultStyleId:r.styleId}:{},...g.length>0?{basedOnStyleIds:g}:{}}},R={styleId:o??null,width:e.formatting?.width?.value??null,widthType:e.formatting?.width?.type??null,justification:e.formatting?.justification??null,columnWidths:e.columnWidths??null,tableLayout:e.formatting?.layout??null,floating:e.formatting?.floating??null,cellMargins:p??null,look:e.formatting?.look??null,bidi:e.formatting?.bidi||null,_originalFormatting:k};e.propertyChanges?.length&&(R.tblPrChange=e.propertyChanges);let x=Wt(e);return {attrs:R,rows:e.rows.map((I,C)=>$t(I,e,C,x,a,p,n))}}function zt(e){return Le(de(e))}function Vt(e){let t=0;for(let n of e.units){let r=n.kind==="text"?n.text.length:1;if(n.commentId!==void 0&&n.commentId!==0){let o=e.commentCoverage.get(n.commentId),l=o?.[o.length-1];l&&l[1]===t?l[1]=t+r:o?o.push([t,t+r]):e.commentCoverage.set(n.commentId,[[t,t+r]]);}t+=r;}}function $(e,t,n,r){let o={storyId:t,units:[],commentCoverage:new Map};e.plans.push(o);let l=n.length>0?[...n]:[{type:"paragraph",content:[]}],s=0,a=0,d=0,f=null;for(let c of l){if(c.type==="paragraph"){let m=Dt(c,e.styleResolver,r.extraRunFormatting);o.units.push(...m.units),o.units.push(v("pilcrow",{...m.ppr,paraId:c.paraId||`${t}:p${d}`})),d+=1,r.includePageBreaks&&Ut(c)&&o.units.push(v("pageBreak",{})),f="paragraph";continue}if(c.type==="table"){let m=s++,y=Ht(c,e.styleResolver,e.theme),k=y.rows.map((R,x)=>({trPr:R.attrs,cells:R.cells.map((I,C)=>({tcPr:I.attrs,story:ce(t,m,x,C)}))}));o.units.push(v("table",{tblPr:_e(y.attrs),grid:Be(y.attrs),rows:k})),y.rows.forEach((R,x)=>{R.cells.forEach((I,C)=>{$(e,ce(t,m,x,C),I.content,{includePageBreaks:false,appendBodyTail:false,seedComments:false,extraRunFormatting:I.extraRunFormatting});});}),f="table";continue}let p=a++,g=Ee(t,p);o.units.push(v("blockSdt",{...zt(c.properties),story:g})),$(e,g,c.content,{includePageBreaks:r.includePageBreaks,appendBodyTail:false,seedComments:false}),f="blockSdt";}r.appendBodyTail&&(f==="table"||f==="blockSdt")&&o.units.push(v("pilcrow",{hangingIndent:false,paraId:`${t}:p${d}`})),r.seedComments&&Vt(o);}function Kt(e){let t=[{op:"delete",index:0,len:1}],n=0,r="",o={},l=H(o),s=()=>{r&&(t.push({op:"insert",index:n,text:r,attrs:o}),n+=r.length,r="");};for(let a of e)if(a.kind==="text"){let d=H(a.attrs);r&&d!==l&&s(),o=a.attrs,l=d,r+=a.text;}else s(),t.push({op:"insertEmbed",index:n,kind:a.embedKind,payload:a.payload,attrs:a.attrs}),n+=1;return s(),t}function qt(e,t){e.applyRawOps(t.storyId,Kt(t.units));let n=[];for(let[r,o]of t.commentCoverage)n.push({op:"setComment",id:String(r),ranges:o,author:"",date:"",body:null});n.length>0&&e.applyRawOps(t.storyId,n);}function Xt(e,t){let n={styleResolver:t.package.styles?c(t.package.styles):null,theme:t.package.theme??null,plans:[]};$(n,"body",t.package.document.content,{includePageBreaks:true,appendBodyTail:true,seedComments:true});for(let[r,o]of t.package.headers??[])$(n,ee(r),o.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let[r,o]of t.package.footers??[])n.plans.some(l=>l.storyId===ee(r))||$(n,ee(r),o.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let r of t.package.footnotes??[])$(n,De(r.id),r.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let r of t.package.endnotes??[])$(n,Je(r.id),r.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let r of n.plans)e.createStory(r.storyId,"","Normal","left");for(let r of n.plans)qt(e,r);}var W=class extends Error{constructor(t){super(t),this.name="ContentControlValueError";}};function ne(e,t,n){let r=new RegExp(`<${t}\\b[^>]*>`).exec(e);if(!r)return;let o=new RegExp(`\\b${n}="([^"]*)"`).exec(r[0]);return o?o[1]:void 0}function ye(e,t,n,r){let l=new RegExp(`<${t}\\b[^>]*?(/?)>`).exec(e);if(!l)return e;let s=l[0],a=l[1]==="/",d=s.slice(1,a?-2:-1),c=new RegExp(`\\b${n}="[^"]*"`).test(d)?d.replace(new RegExp(`\\b${n}="[^"]*"`),()=>`${n}="${r}"`):`${d} ${n}="${r}"`;return e.replace(s,()=>`<${c}${a?"/>":">"}`)}function Gt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Zt(e,t){if(!e)return t;let n=parseInt(e,16);return Number.isNaN(n)||n<0||n>1114111||n>=55296&&n<=57343?t:String.fromCodePoint(n)}function Qt(e,t,n){let[r,o,l]=e.slice(0,10).split("-").map(p=>parseInt(p,10));if(!qe(r,o,l))return e;let s=t&&t.trim()?t:"M/d/yyyy",a=p=>String(p).padStart(2,"0"),d=new Date(Date.UTC(r,o-1,l)),f=p=>{try{return new Intl.DateTimeFormat(n||"en",{month:p,timeZone:"UTC"}).format(d)}catch{return new Intl.DateTimeFormat("en",{month:p,timeZone:"UTC"}).format(d)}},c={yyyy:String(r),yy:String(r).slice(-2),MMMM:f("long"),MMM:f("short"),MM:a(o),M:String(o),dd:a(l),d:String(l)};return s.replace(/yyyy|yy|MMMM|MMM|MM|M|dd|d/g,p=>c[p])}function qe(e,t,n){if(!e||!t||!n)return false;let r=new Date(Date.UTC(e,t-1,n));return r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n}function be(e,t){return e?{type:"paragraph",content:[{type:"run",content:[{type:"text",text:e}],...t?{formatting:{fontFamily:{ascii:t,hAnsi:t,eastAsia:t,cs:t}}}:{}}]}:{type:"paragraph",content:[]}}function en(e){return e&&e.replace(/<w:showingPlcHdr\b[^>]*\/>/g,"").replace(/<w:showingPlcHdr\b[^>]*>[\s\S]*?<\/w:showingPlcHdr>/g,"")}function ke(e,t){let n=en(t);return {...e,showingPlaceholder:false,rawPropertiesXml:(n??t)||void 0}}function Se(e,t){let n=e.rawPropertiesXml??"";switch(t.kind){case "dropdown":{if(e.sdtType!=="dropDownList"&&e.sdtType!=="comboBox")throw new W(`Control is '${e.sdtType}', not a dropdown/combo box.`);let r=e.listItems?.find(f=>f.value===t.value||f.displayText===t.value);if(!r&&e.sdtType==="dropDownList")throw new W(`'${t.value}' is not one of the control's list items.`);let o=r?.value??t.value,l=r?.displayText??t.value,s=r?e.listItems?.indexOf(r):void 0,a=e.sdtType==="comboBox"?"w:comboBox":"w:dropDownList",d=ye(n,a,"w:lastValue",Gt(o));return {properties:{...ke(e,d),listLastValue:o,controlState:{...e.controlState,value:l,selectedValue:o,selectedIndex:s,placeholder:false}},content:[be(l)]}}case "checkbox":{if(e.sdtType!=="checkbox")throw new W(`Control is '${e.sdtType}', not a checkbox.`);if(ne(n,"w14:checked","w14:val")==null)throw new W("Checkbox control has no <w14:checked> state to update (not a Word checkbox).");let r=t.checked?"w14:checkedState":"w14:uncheckedState",o=Zt(ne(n,r,"w14:val"),t.checked?"\u2612":"\u2610"),l=ne(n,r,"w14:font"),s=ye(n,"w14:checked","w14:val",t.checked?"1":"0");return {properties:{...ke(e,s),checked:t.checked,controlState:{...e.controlState,checked:t.checked,value:o,placeholder:false}},content:[be(o,l)]}}case "date":{if(e.sdtType!=="date")throw new W(`Control is '${e.sdtType}', not a date control.`);let r=t.date.slice(0,10),[o,l,s]=/^\d{4}-\d{2}-\d{2}$/.test(r)?r.split("-").map(Number):[];if(!qe(o,l,s))throw new W(`Date must be ISO yyyy-mm-dd, got '${t.date}'.`);let a=`${r}T00:00:00`,d=ye(n,"w:date","w:fullDate",a),f=e.dateState?.format??e.dateFormat??ne(n,"w:dateFormat","w:val"),c=e.dateState?.language,p=Qt(r,f,c);return {properties:{...ke(e,d),dateFormat:f,dateState:{...e.dateState,fullDate:a,format:f},controlState:{...e.controlState,value:r,placeholder:false}},content:[be(p)]}}}}function Xe(e){return e.numPrFromStyle!=null&&e.numPr!=null&&JSON.stringify(e.numPr)===JSON.stringify(e.numPrFromStyle)}function Qe(e){if(e._originalFormatting){let n=e._originalFormatting,r={...n};return e.alignment!==(n.alignment||void 0)&&(r.alignment=e.alignment||void 0),Xe(e)?(delete r.numPr,delete r.numPrFromStyle):e.numPr!==n.numPr&&JSON.stringify(e.numPr)!==JSON.stringify(n.numPr)&&(r.numPr=e.numPr||void 0,delete r.numPrFromStyle),e.styleId!==(n.styleId||void 0)&&(r.styleId=e.styleId||void 0),e.pageBreakBefore!==(n.pageBreakBefore||void 0)&&(r.pageBreakBefore=e.pageBreakBefore||void 0),e.bidi!==(n.bidi||void 0)&&(r.bidi=e.bidi||void 0),r}if(e.alignment||e.spaceBefore||e.spaceAfter||e.lineSpacing||e.indentLeft||e.indentRight||e.indentFirstLine||e.numPr||e.styleId||e.borders||e.shading||e.tabs||e.outlineLevel!=null||e.contextualSpacing||e.pageBreakBefore||e.bidi)return {alignment:e.alignment||void 0,spaceBefore:e.spaceBefore||void 0,spaceAfter:e.spaceAfter||void 0,lineSpacing:e.lineSpacing||void 0,lineSpacingRule:e.lineSpacingRule||void 0,indentLeft:e.indentLeft||void 0,indentRight:e.indentRight||void 0,indentFirstLine:e.indentFirstLine||void 0,hangingIndent:e.hangingIndent||void 0,numPr:Xe(e)?void 0:e.numPr||void 0,styleId:e.styleId||void 0,borders:e.borders||void 0,shading:e.shading||void 0,tabs:e.tabs||void 0,outlineLevel:e.outlineLevel??void 0,contextualSpacing:e.contextualSpacing||void 0,pageBreakBefore:e.pageBreakBefore||void 0,bidi:e.bidi||void 0}}function et(e){if(e._originalFormatting){let n=e._originalFormatting,r={...n};return e.styleId!==(n.styleId||void 0)&&(r.styleId=e.styleId||void 0),e.justification!==(n.justification||void 0)&&(r.justification=e.justification||void 0),e.floating!==(n.floating||void 0)&&(r.floating=e.floating||void 0),e.tableLayout!==(n.layout||void 0)&&(r.layout=e.tableLayout||void 0),e.look!==(n.look||void 0)&&(r.look=e.look||void 0),e.bidi!==(n.bidi||void 0)&&(r.bidi=e.bidi||void 0),(e.width!==n.width?.value||e.widthType!==n.width?.type)&&(r.width=e.width!=null||e.widthType?{value:e.width??0,type:e.widthType||"dxa"}:void 0),e.cellMargins&&(r.cellMargins=Ge(e.cellMargins)),r}if(e.styleId||e.width!=null||e.widthType||e.justification||e.tableLayout||e.floating||e.cellMargins||e.look||e.bidi)return {styleId:e.styleId||void 0,width:e.width!=null||e.widthType?{value:e.width??0,type:e.widthType||"dxa"}:void 0,justification:e.justification||void 0,layout:e.tableLayout||void 0,floating:e.floating||void 0,cellMargins:e.cellMargins?Ge(e.cellMargins):void 0,look:e.look||void 0,bidi:e.bidi||void 0}}function Ge(e){return {top:e.top!=null?{value:e.top,type:"dxa"}:void 0,bottom:e.bottom!=null?{value:e.bottom,type:"dxa"}:void 0,left:e.left!=null?{value:e.left,type:"dxa"}:void 0,right:e.right!=null?{value:e.right,type:"dxa"}:void 0}}function tt(e){if(e._originalFormatting){let t=e._originalFormatting,n={...t};return e.height!==(t.height?.value||void 0)&&(n.height=e.height?{value:e.height,type:"dxa"}:void 0),e.heightRule!==(t.heightRule||void 0)&&(n.heightRule=e.heightRule||void 0),e.isHeader!==(t.header||void 0)&&(n.header=e.isHeader||void 0),n}if(!(!e.height&&!e.isHeader))return {height:e.height?{value:e.height,type:"dxa"}:void 0,heightRule:e.heightRule||void 0,header:e.isHeader||void 0}}function nt(e){if(e._originalFormatting){let n=e._originalFormatting,r={...n};return e.colspan>1&&(r.gridSpan=e.colspan),e.width!=null&&(r.width={value:e.width,type:e.widthType||"dxa"}),e.verticalAlign!==(n.verticalAlign||void 0)&&(r.verticalAlign=e.verticalAlign||void 0),e.backgroundColor?r.shading=e._originalResolvedFill===e.backgroundColor&&n.shading?n.shading:{fill:{rgb:e.backgroundColor}}:n.shading&&(r.shading=void 0),e.borders&&(r.borders=e.borders),e.margins&&(r.margins=Ze(e.margins)),e.textDirection!==(n.textDirection||void 0)&&(r.textDirection=e.textDirection||void 0),r}if(e.colspan>1||e.rowspan>1||e.width!=null||e.verticalAlign||e.backgroundColor||e.borders||e.margins||e.textDirection)return {gridSpan:e.colspan>1?e.colspan:void 0,width:e.width!=null?{value:e.width,type:e.widthType||"dxa"}:void 0,verticalAlign:e.verticalAlign||void 0,textDirection:e.textDirection||void 0,shading:e.backgroundColor?{fill:{rgb:e.backgroundColor}}:void 0,borders:e.borders,margins:e.margins?Ze(e.margins):void 0}}function Ze(e){let t={};return e.top!=null&&(t.top={value:e.top,type:"dxa"}),e.bottom!=null&&(t.bottom={value:e.bottom,type:"dxa"}),e.left!=null&&(t.left={value:e.left,type:"dxa"}),e.right!=null&&(t.right={value:e.right,type:"dxa"}),t}var tn={paraId:null,textId:null,alignment:null,spaceBefore:null,spaceAfter:null,lineSpacing:null,lineSpacingRule:null,spacingExplicit:null,indentLeft:null,indentRight:null,indentFirstLine:null,hangingIndent:false,numPr:null,numPrFromStyle:null,listNumFmt:null,listIsBullet:null,listMarker:null,listMarkerHidden:null,listMarkerFontFamily:null,listMarkerFontSize:null,listMarkerSuffix:null,listLevelNumFmts:null,listAbstractNumId:null,listStartOverride:null,styleId:null,borders:null,shading:null,tabs:null,pageBreakBefore:null,renderedPageBreakBefore:null,keepNext:null,keepLines:null,contextualSpacing:null,defaultTextFormatting:null,sectionBreakType:null,bidi:null,outlineLevel:null,bookmarks:null,_originalFormatting:null,_originalRunBoundaries:null,_sectionProperties:null,pPrIns:null,pPrDel:null,pPrChange:null},nn={styleId:null,width:null,widthType:null,justification:null,columnWidths:null,tableLayout:null,floating:null,cellMargins:null,look:null,bidi:null,_originalFormatting:null,tblPrChange:null},rn={height:null,heightRule:null,isHeader:false,_originalFormatting:null,trIns:null,trDel:null,trPrChange:null},on={colspan:1,rowspan:1,colwidth:null,width:null,widthType:null,verticalAlign:null,backgroundColor:null,borders:null,margins:null,textDirection:null,noWrap:false,_originalFormatting:null,_originalResolvedFill:null,cellMarker:null,tcPrChange:null},sn=new Set(["bold","italic","superscript","subscript","allCaps","smallCaps","emboss","imprint","textShadow","textOutline","hidden","rtl"]);function w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function B(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function S(e){return typeof e=="string"?e:void 0}function oe(e){if(Array.isArray(e))return e.map(oe);let t=w(e);if(!t)return e;let n={};for(let[r,o]of Object.entries(t))o!=null&&(n[r]=oe(o));return n}function G(e){if(e==null)return "null";if(Array.isArray(e))return `[${e.map(G).join(",")}]`;let t=w(e);return t?`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${G(t[n])}`).join(",")}}`:JSON.stringify(e)}function Z(e){let t={...e};return delete t.hyperlink,delete t.ins,delete t.del,t}function se(e){let t={};e.bold&&(t.bold=true,t.boldCs=true),e.italic&&(t.italic=true,t.italicCs=true);let n=w(e.underline);n&&(t.underline={style:S(n.style)||"single",color:w(n.color)??null});let r=w(e.strike);r&&(r.double?t.doubleStrike=true:t.strike=true);let o=w(e.textColor);o&&(t.color={rgb:S(o.rgb)??null,themeColor:o.themeColor??null,themeTint:S(o.themeTint)??null,themeShade:S(o.themeShade)??null}),typeof e.highlight=="string"&&(t.highlight=e.highlight);let l=w(e.fontSize);if(l){let m=B(l.size),y=B(l.sizeCs)??m;m!==void 0&&(t.fontSize=m),y!==void 0&&(t.fontSizeCs=y);}let s=w(e.fontFamily);if(s){let m=S(s.ascii);t.fontFamily={ascii:m??null,hAnsi:S(s.hAnsi)??null,eastAsia:S(s.eastAsia),cs:S(s.cs)||m,asciiTheme:s.asciiTheme??null,hAnsiTheme:S(s.hAnsiTheme),eastAsiaTheme:S(s.eastAsiaTheme),csTheme:S(s.csTheme)};}e.superscript&&(t.vertAlign="superscript"),e.subscript&&(t.vertAlign="subscript"),e.allCaps&&(t.allCaps=true),e.smallCaps&&(t.smallCaps=true);let a=w(e.characterSpacing);if(a){let m=B(a.spacing),y=B(a.position),k=B(a.scale),R=B(a.kerning);m!==void 0&&(t.spacing=m),y!==void 0&&(t.position=y),k!==void 0&&(t.scale=k),R!==void 0&&(t.kerning=R);}e.emboss&&(t.emboss=true),e.imprint&&(t.imprint=true),e.textShadow&&(t.shadow=true);let d=w(e.emphasisMark);d&&(t.emphasisMark=S(d.type)||"dot"),e.textOutline&&(t.outline=true),e.hidden&&(t.hidden=true),e.rtl&&(t.rtl=true);let f=w(e.textEffect);f&&(t.effect=S(f.effect)||"blinkBackground");let c=w(e.modernTextEffects);c?.effects&&(t.modernEffects=c.effects);let p=w(e.runStyle),g=S(p?.styleId);return g&&(t.styleId=g),t}function st(e,t){let n=[],r="",o=()=>{r&&(n.push({type:"text",text:r}),r="");},l=t.fontFamily?[t.fontFamily.ascii,t.fontFamily.hAnsi,t.fontFamily.eastAsia,t.fontFamily.cs].filter(a=>!!a):[],s=l.length>0&&l.every(a=>a===l[0])?l[0]:null;for(let a of e){let d=a.codePointAt(0)??0;a==="\xAD"?(o(),n.push({type:"softHyphen"})):a==="\u2011"?(o(),n.push({type:"noBreakHyphen"})):s&&d>=61440&&d<=63743?(o(),n.push({type:"symbol",font:s,char:d.toString(16).toUpperCase().padStart(4,"0")})):r+=a;}return o(),n}function xe(e,t){let n=se(Z(t));return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:st(e,n)}}function ln(e,t){for(let n of t.content){let r=e.content[e.content.length-1];r?.type==="text"&&n.type==="text"?r.text+=n.text:e.content.push(n);}}function an(e){let t=0xcbf29ce484222325n;for(let n of new TextEncoder().encode(e))t=(t^BigInt(n))*0x100000001b3n,t&=0xffffffffffffffffn;return Number(t&(1n<<53n)-1n)}function Re(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t=Number(e);return Number.isFinite(t)?t:an(e)}return 0}function z(e,t=false){let n=w(e);if(!n)return null;let r=S(n.author)||"Unknown",o=S(n.date);return {id:Re(n.revisionId??n.id),author:r,...o?{date:o}:{}}}function dn(e){let t=w(e.hyperlink);if(!t)return null;let n=S(t.href)||"";return n.startsWith("#")?{type:"hyperlink",anchor:n.slice(1),tooltip:S(t.tooltip)||void 0,children:[]}:{type:"hyperlink",href:n,tooltip:S(t.tooltip)||void 0,rId:S(t.rId)||void 0,children:[]}}function un(e){let t=w(e.hyperlink);return t?S(t.href)||"":null}function lt(e,t){let n=S(e.fieldData);if(n&&n.length<=2e6)try{let c=JSON.parse(n),p=c.type==="simpleField"?c.content:c.fieldResult;if((c.type==="simpleField"||c.type==="complexField")&&typeof c.instruction=="string"&&Array.isArray(p)){let g=S(e.displayMode);return c.fieldTree&&g&&(c.fieldTree.displayMode=g),c}}catch{}let r=se(Z(t)),o={type:"run",content:[{type:"text",text:S(e.displayText)||""}],...Object.keys(r).length>0?{formatting:r}:{}},l=S(e.instruction)||"",s=S(e.fieldType)||"UNKNOWN",a=e.fldLock===true||void 0,d=e.dirty===true||void 0,f=S(e.displayMode)||"result";return e.fieldKind==="complex"?{type:"complexField",instruction:l,fieldType:s,fieldCode:[],fieldResult:[o],fldLock:a,dirty:d,fieldTree:{version:1,displayMode:f}}:{type:"simpleField",instruction:l,fieldType:s,content:[o],fldLock:a,dirty:d,fieldTree:{version:1,displayMode:f}}}function at(e){return {type:"mathEquation",display:S(e.display)||"inline",ommlXml:S(e.ommlXml)||"",plainText:S(e.plainText)||void 0}}function dt(e){let t=e,n={type:S(t.wrapType)||"inline"};t.distTop!==void 0&&(n.distT=c$1(Number(t.distTop))),t.distBottom!==void 0&&(n.distB=c$1(Number(t.distBottom))),t.distLeft!==void 0&&(n.distL=c$1(Number(t.distLeft))),t.distRight!==void 0&&(n.distR=c$1(Number(t.distRight))),t.wrapText&&(n.wrapText=t.wrapText);let r={type:"image",rId:S(t.rId)||"",src:S(t.src)||"",alt:S(t.alt)||void 0,title:S(t.title)||void 0,size:{width:c$1(Number(t.width)||0),height:c$1(Number(t.height)||0)},wrap:n};if(t.transform){let s={},a=t.transform.match(/rotate\(([-\d.]+)deg\)/)?.[1];a&&(s.rotation=Number.parseFloat(a)),t.transform.includes("scaleX(-1)")&&(s.flipH=true),t.transform.includes("scaleY(-1)")&&(s.flipV=true),(s.rotation||s.flipH||s.flipV)&&(r.transform=s);}if(t.position?.horizontal&&t.position.vertical&&(r.position={horizontal:{relativeTo:t.position.horizontal.relativeTo||"column",alignment:t.position.horizontal.align,posOffset:t.position.horizontal.posOffset},vertical:{relativeTo:t.position.vertical.relativeTo||"paragraph",alignment:t.position.vertical.align,posOffset:t.position.vertical.posOffset}}),t.borderWidth&&t.borderWidth>0){let s={solid:"solid",dotted:"dot",dashed:"dash",double:"solid",groove:"solid",ridge:"solid",inset:"solid",outset:"solid"};r.outline={width:c$1(t.borderWidth),color:t.borderColor?{rgb:t.borderColor.replace("#","")}:void 0,style:t.borderStyle&&s[t.borderStyle]||"solid"};}t.hlinkHref&&(r.hlinkHref=t.hlinkHref);let o={};t.cropTop!=null&&(o.top=t.cropTop),t.cropRight!=null&&(o.right=t.cropRight),t.cropBottom!=null&&(o.bottom=t.cropBottom),t.cropLeft!=null&&(o.left=t.cropLeft),Object.keys(o).length>0&&(r.crop=o),t.opacity!=null&&t.opacity<1&&(r.opacity=t.opacity),t.layoutInCell!=null&&(r.layoutInCell=t.layoutInCell),t.allowOverlap!=null&&(r.allowOverlap=t.allowOverlap);let l={};return t.effectExtentTop&&(l.top=c$1(t.effectExtentTop)),t.effectExtentBottom&&(l.bottom=c$1(t.effectExtentBottom)),t.effectExtentLeft&&(l.left=c$1(t.effectExtentLeft)),t.effectExtentRight&&(l.right=c$1(t.effectExtentRight)),Object.keys(l).length>0&&(r.padding=l),{type:"run",content:[{type:"drawing",image:r}]}}function ut(e){let t={type:"shape",shapeType:S(e.shapeType)||"rect",id:S(e.shapeId)||void 0,size:{width:e.width?c$1(Number(e.width)):0,height:e.height?c$1(Number(e.height)):0}};if(Array.isArray(e.geometryPath)&&e.geometryPath.length>0&&(t.geometryPath=e.geometryPath),e.fillType==="gradient"&&typeof e.gradientStops=="string")try{let r=JSON.parse(e.gradientStops);t.fill={type:"gradient",gradient:{type:S(e.gradientType)||"linear",angle:B(e.gradientAngle)||void 0,stops:r.map(o=>({position:o.position,color:{rgb:o.color.replace("#","")}}))}};}catch{t.fill={type:"solid",color:{rgb:(S(e.fillColor)||"000000").replace("#","")}};}else typeof e.fillColor=="string"?t.fill={type:S(e.fillType)||"solid",color:{rgb:e.fillColor.replace("#","")}}:e.fillType==="none"&&(t.fill={type:"none"});if(typeof e.outlineWidth=="number"&&e.outlineWidth>0){let r={solid:"solid",dotted:"dot",dashed:"dash"},o=S(e.outlineStyle);t.outline={width:c$1(e.outlineWidth),color:typeof e.outlineColor=="string"?{rgb:e.outlineColor.replace("#","")}:void 0,style:o&&r[o]||"solid"};}let n={};if(typeof e.rotation=="number")n.rotation=e.rotation;else if(typeof e.transform=="string"){let r=e.transform.match(/rotate\(([-\d.]+)deg\)/)?.[1];r&&(n.rotation=Number.parseFloat(r));}return (e.flipH||String(e.transform||"").includes("scaleX(-1)"))&&(n.flipH=true),(e.flipV||String(e.transform||"").includes("scaleY(-1)"))&&(n.flipV=true),(n.rotation||n.flipH||n.flipV)&&(t.transform=n),{type:"run",content:[{type:"shape",shape:t}]}}function cn(e){let t=ue(e),n=S(e.propertiesJson);if(n&&n.length<=1e6)try{let s=JSON.parse(n);s&&typeof s=="object"&&typeof s.sdtType=="string"&&(t=s);}catch{}let r=[];for(let s of Array.isArray(e.content)?e.content:[]){let a=w(s),d=S(a?.kind);if(!a||!d)continue;let f=w(a.attrs)??{};if(d==="text"){let c=S(a.text);c!==void 0&&r.push({kind:"text",text:c,attributes:f});continue}r.push({kind:"embed",embedKind:d,payload:w(a.payload)??{},attributes:f});}let o=rt(we(r)),l=ct(e.value);if(l)try{let s=Se(t,l);t=s.properties;let a=s.content[0];o=rt(a?.type==="paragraph"?a.content:[]);}catch{}return {type:"inlineSdt",properties:t,content:o}}function rt(e){return e.filter(t=>t.type==="run"||t.type==="hyperlink"||t.type==="simpleField"||t.type==="complexField"||t.type==="inlineSdt"||t.type==="mathEquation")}function ct(e){let t=w(e);return t?.kind==="checkbox"&&typeof t.checked=="boolean"?{kind:"checkbox",checked:t.checked}:t?.kind==="dropdown"&&typeof t.value=="string"?{kind:"dropdown",value:t.value}:t?.kind==="date"&&typeof t.date=="string"?{kind:"date",date:t.date}:null}function pt(e){if(e.modelKind!=="commentReference")return null;let t=B(e.commentId);return {type:"run",content:[{type:"commentReference",...t!==void 0?{id:t}:{}}]}}function ot(e){if(e.kind==="text")return xe(e.text,e.attributes);switch(e.embedKind){case "break":return {type:"run",content:[{type:"break",breakType:"textWrapping"}]};case "tab":return {type:"run",content:[{type:"tab"}]};case "image":return dt(e.payload);case "shape":return ut(e.payload);case "field":return pt(e.payload)??lt(e.payload,e.attributes);case "math":return at(e.payload);case "sdt":return cn(e.payload);case "noteRef":{let t=e.payload.footnoteRefId,n=e.payload.endnoteRefId;return {type:"run",content:[t!==void 0?{type:"footnoteRef",id:Re(t)}:{type:"endnoteRef",id:Re(n)}]}}default:return null}}function pn(e,t){let n;if(e.kind==="embed"&&e.embedKind==="image")n=dt(e.payload);else if(e.kind==="embed"&&e.embedKind==="shape")n=ut(e.payload);else if(e.kind==="text"){let l=se(Z(e.attributes));n={type:"run",content:[{type:"text",text:e.text}],...Object.keys(l).length>0?{formatting:l}:{}};}else n={type:"run",content:[]};let o=(w(e.attributes.ins)??w(e.attributes.del))?.isMovePair===true;return e.attributes.ins?o?{type:"moveTo",info:t,content:[n]}:{type:"insertion",info:t,content:[n]}:o?{type:"moveFrom",info:t,content:[n]}:{type:"deletion",info:t,content:[n]}}function fn(e,t){if(t.kind==="text"){e.children.push(xe(t.text,t.attributes));return}if(t.embedKind==="break")e.children.push({type:"run",content:[{type:"break",breakType:"textWrapping"}]});else if(t.embedKind==="tab")e.children.push({type:"run",content:[{type:"tab"}]});else if(t.embedKind==="field"){let n=pt(t.payload)??lt(t.payload,t.attributes);n.type==="run"?e.children.push(n):(e.structuredChildren??(e.structuredChildren=[...e.children])).push(n);}else t.embedKind==="math"&&(e.structuredChildren??(e.structuredChildren=[...e.children])).push(at(t.payload));}function we(e){let t=[],n=null,r=null,o=null,l=()=>{n&&t.push(n),n=null,r=null;},s=()=>{o&&t.push(o),o=null;};for(let a of e){if(a.kind==="embed"&&a.embedKind==="noteRef"){l(),s();let p=ot(a);p&&t.push(p);continue}let d=z(a.attributes.ins??a.attributes.del);if(d){l(),s(),t.push(pn(a,d));continue}let f=un(a.attributes);if(f!==null){l();let p=o?o.href||(o.anchor?`#${o.anchor}`:""):null;(!o||p!==f)&&(s(),o=dn(a.attributes)),o&&fn(o,a);continue}if(s(),a.kind==="text"){let p=G(Z(a.attributes)),g=xe(a.text,a.attributes);n&&r===p?ln(n,g):(l(),n=g,r=p);continue}l();let c=ot(a);c&&t.push(c);}return l(),s(),t}function gn(e){if(!e)return {};let t={};for(let n of e.split("|")){let r=n.indexOf(":");if(r<=0)return null;let o=n.slice(0,r),l;try{l=JSON.parse(n.slice(r+1));}catch{return null}o==="comment"||o==="footnoteRef"||(sn.has(o)?t[o]=true:o==="highlight"?t.highlight=l.color:o==="insertion"||o==="deletion"?t[o==="insertion"?"ins":"del"]=oe({id:l.revisionId,author:l.author,date:l.date,isMovePair:l.isMovePair}):t[o]=oe(l));}return t}function mn(e,t,n){if(!n?.length||!e.every(a=>a.type==="run"&&a.content.every(d=>d.type==="text"))||t.some(a=>a.kind!=="text"||a.attributes.hyperlink)||t.map(a=>a.kind==="text"?a.text:"").join("")!==n.map(a=>a.text).join(""))return e;let o=0,l=0,s=[];for(let a of n){let d=gn(a.marksKey);if(!d)return e;s.push(d);let f=a.text.length;for(;f>0;){let c=t[o];if(!c||G(Z(c.attributes))!==G(d))return e;let p=c.text.length-l,g=Math.min(f,p);f-=g,l+=g,l===c.text.length&&(o+=1,l=0);}}return n.map((a,d)=>{let f=a.text.length===0?a.formatting:se(s[d]),c={type:"run",content:st(a.text,f??{})};return f&&Object.keys(f).length>0&&(c.formatting=f),a.propertyChanges?.length&&(c.propertyChanges=a.propertyChanges),c})}function re(e){return e.content.reduce((t,n)=>n.type==="text"||n.type==="instrText"?t+n.text.length:n.type==="symbol"?t+n.char.length:n.type==="tab"||n.type==="softHyphen"||n.type==="noBreakHyphen"?t+1:t,0)}function ie(e){switch(e.type){case "run":return re(e);case "hyperlink":return e.children.reduce((t,n)=>t+(n.type==="run"?re(n):0),0);case "simpleField":return e.content.reduce((t,n)=>t+ie(n),0);case "complexField":return e.fieldResult.reduce((t,n)=>t+re(n),0);case "inlineSdt":return e.content.reduce((t,n)=>t+ie(n),0);case "insertion":case "deletion":case "moveFrom":case "moveTo":return e.content.reduce((t,n)=>t+(n.type==="run"?re(n):0),0);case "mathEquation":return e.plainText?.length??0;default:return 0}}function hn(e,t){if(!e.content.every(o=>o.type==="text"))return [e,null];let n=e.content.map(o=>o.type==="text"?o.text:"").join(""),r=o=>o?{type:"run",...e.formatting?{formatting:e.formatting}:{},...e.propertyChanges?{propertyChanges:e.propertyChanges}:{},content:[{type:"text",text:o}]}:null;return [r(n.slice(0,t)),r(n.slice(t))]}function it(e,t,n=r=>r.kind==="start"?{type:"commentRangeStart",id:r.id}:{type:"commentRangeEnd",id:r.id}){if(t.length===0)return e;let r=[...t].sort((d,f)=>d.offset-f.offset||(d.kind===f.kind?d.id-f.id:d.kind==="end"?-1:1)),o=[],l=0,s=0,a=d=>{for(;s<r.length&&r[s].offset===d;){let f=r[s++];o.push(n(f));}};a(0);for(let d of e){let f=ie(d),c=r.slice(s).map(p=>p.offset).filter(p=>p>l&&p<l+f);if(d.type==="run"&&d.content.every(p=>p.type==="text")){let p=d,g=0;for(let m of c){if(!p)break;let[y,k]=hn(p,m-l-g);y&&o.push(y),a(m),p=k,g=m-l;}p&&o.push(p);}else o.push(d);l+=f,a(l);}return a(l),o}function yn(e){if(!Array.isArray(e.bookmarks))return [];let t=[];for(let n of e.bookmarks){let r=w(n),o=B(r?.id);if(!r||o===void 0)continue;let l=B(r.offset)??0,s={name:S(r.name),colFirst:B(r.colFirst),colLast:B(r.colLast)};r.kind==="start"?t.push({id:o,kind:"start",offset:l,...s}):r.kind==="end"?t.push({id:o,kind:"end",offset:l,...s}):(t.push({id:o,kind:"start",offset:0,...s}),t.push({id:o,kind:"end",offset:Number.MAX_SAFE_INTEGER,...s}));}return t}function bn(e){let t={...tn,...e};return t.styleId=e.pStyle??null,t._sectionProperties=e.sectPr??null,delete t.pStyle,delete t.sectPr,t}function kn(e,t,n,r,o){let l=bn(t),s=we(n);s=mn(s,n,Array.isArray(l._originalRunBoundaries)?l._originalRunBoundaries:void 0),s=it(s,r);let a=yn(t).map(p=>({...p,offset:p.offset===Number.MAX_SAFE_INTEGER?s.reduce((g,m)=>g+ie(m),0):p.offset}));a.length>0&&(s=it(s,a,p=>{let g=p;return g.kind==="start"?{type:"bookmarkStart",id:g.id,name:g.name||"",...g.colFirst!==void 0?{colFirst:g.colFirst}:{},...g.colLast!==void 0?{colLast:g.colLast}:{},position:{offset:g.offset}}:{type:"bookmarkEnd",id:g.id,position:{offset:g.offset}}}));let d={type:"paragraph",paraId:e||void 0,textId:o?.textId,formatting:Qe(l),content:s};o?.renderedPageBreakBefore&&(d.renderedPageBreakBefore=true);let f=z(t.pPrIns,true),c=z(t.pPrDel,true);return f&&(d.pPrIns=f),c&&(d.pPrDel=c),Array.isArray(t.pPrChange)&&t.pPrChange.length>0&&(d.propertyChanges=t.pPrChange),t.sectPr?d.sectionProperties=t.sectPr:t.sectionBreakType&&(d.sectionProperties={sectionStart:t.sectionBreakType}),d}function Sn(e){for(let t of e)for(let n of t.cells){let r=n.formatting?.borders;if(!r)continue;let o=r.top||r.left||r.right||r.bottom||r.insideH||r.insideV;return o?{top:r.top??o,bottom:r.bottom??o,left:r.left??o,right:r.right??o,insideH:r.insideH??r.bottom??o,insideV:r.insideV??r.right??o}:void 0}}function Rn(e){let t=new Map;e.forEach((r,o)=>{let l=0;for(let s of r.cells){let a=l;if(l+=s.formatting?.gridSpan??1,s.formatting?.vMerge){let d=t.get(a)??[];d.push({rowIndex:o,cell:s}),t.set(a,d);}}});let n=r=>{r.formatting&&(delete r.formatting.vMerge,Object.keys(r.formatting).length===0&&(r.formatting=void 0));};for(let r of t.values()){let o=null,l=0,s=-1,a=()=>{o&&l<2&&n(o),o=null,l=0;};for(let d of r){let f=d.cell.formatting?.vMerge;f==="restart"?(a(),o=d.cell,l=1,s=d.rowIndex):f==="continue"&&(o&&d.rowIndex===s+1?(l+=1,s=d.rowIndex):(a(),n(d.cell)));}a();}}function Tn(e,t){let n={...on,...t.tcPr??{}},r=t.story&&e.storyIds.has(t.story)?e.storyToBlocks(t.story).filter(s=>s.type==="paragraph"||s.type==="table"):[],o={type:"tableCell",formatting:nt(n),content:r},l=n.cellMarker;if(l){let s=z(l.info,true)??{id:0,author:"Unknown"};l.kind==="ins"?o.structuralChange={type:"tableCellInsertion",info:s}:l.kind==="del"?o.structuralChange={type:"tableCellDeletion",info:s}:o.structuralChange={type:"tableCellMerge",info:s,...l.vMerge?{vMerge:l.vMerge}:{},...l.vMergeOrig?{vMergeOrig:l.vMergeOrig}:{}};}return Array.isArray(n.tcPrChange)&&n.tcPrChange.length>0&&(o.propertyChanges=n.tcPrChange),o}function xn(e,t){let n=Array.isArray(t.rows)?t.rows:[],r=[],o=[],l=0;n.forEach((m,y)=>{let k=0;for(let R of Array.isArray(m.cells)?m.cells:[]){for(;r[y]?.[k];)k+=1;let x=R.tcPr??{},I=B(x.rowspan)||1,C=B(x.colspan)||1;o.push({row:y,col:k,rowspan:I,colspan:C,cell:Tn(e,R)});for(let A=y;A<y+I;A+=1){r[A]??(r[A]=[]);for(let F=k;F<k+C;F+=1)r[A][F]=true;}k+=C,l=Math.max(l,k);}});let s=new Map(o.map(m=>[`${m.row}-${m.col}`,m])),a=new Map;for(let m of o)for(let y=m.row;y<m.row+m.rowspan;y+=1)for(let k=m.col;k<m.col+m.colspan;k+=1)a.set(`${y}-${k}`,m);let d=n.map((m,y)=>{let k=[];for(let A=0;A<l;){let F=s.get(`${y}-${A}`);if(F){let b={...F.cell.formatting??{}};F.colspan>1?b.gridSpan=F.colspan:delete b.gridSpan,F.rowspan>1?b.vMerge="restart":b.vMerge!=="restart"&&b.vMerge!=="continue"&&delete b.vMerge,k.push({...F.cell,formatting:Object.keys(b).length>0?b:void 0}),A+=F.colspan;continue}let L=a.get(`${y}-${A}`);if(!L){A+=1;continue}let j={...L.cell.formatting??{}};L.colspan>1?j.gridSpan=L.colspan:delete j.gridSpan,j.vMerge="continue",k.push({...L.cell,content:[],formatting:j}),A+=L.colspan;}let R={...rn,...m.trPr??{}},x={type:"tableRow",formatting:tt(R),cells:k},I=z(R.trIns,true),C=z(R.trDel,true);return I?x.structuralChange={type:"tableRowInsertion",info:I}:C&&(x.structuralChange={type:"tableRowDeletion",info:C}),Array.isArray(R.trPrChange)&&R.trPrChange.length>0&&(x.propertyChanges=R.trPrChange),x});Rn(d);let f=Array.isArray(t.grid)?t.grid.filter(m=>typeof m=="number"):[],c={...nn,...t.tblPr??{},columnWidths:f.length>0?f:void 0},p=et(c);if(!p?.borders){let m=Sn(d);m&&(p={...p??{},borders:m});}let g={type:"table",columnWidths:c.columnWidths||void 0,formatting:p,rows:d};return Array.isArray(c.tblPrChange)&&c.tblPrChange.length>0&&(g.propertyChanges=c.tblPrChange),g}function wn(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Pn(e){let t=new Map,n=r=>{for(let o of r)if(o.type==="paragraph")o.paraId&&!t.has(o.paraId)&&t.set(o.paraId,o);else if(o.type==="table")for(let l of o.rows)for(let s of l.cells)n(s.content);else n(o.content);};n(e.package.document.content);for(let r of e.package.headers?.values()??[])n(r.content);for(let r of e.package.footers?.values()??[])n(r.content);for(let r of e.package.footnotes??[])n(r.content);for(let r of e.package.endnotes??[])n(r.content);return t}function Cn(e){let t=new Map,n=(r,o)=>{t.set(r,o);let l=0;for(let s of o){if(s.type!=="table")continue;let a=l++;s.rows.forEach((d,f)=>{d.cells.forEach((c,p)=>{n(`${r}:t${a}:r${f}c${p}`,c.content);});});}};n("body",e.package.document.content);for(let[r,o]of e.package.headers??[])n(`hf:${r}`,o.content);for(let[r,o]of e.package.footers??[])n(`hf:${r}`,o.content);for(let r of e.package.footnotes??[])n(`fn:${r.id}`,r.content);return t}function In(e,t){let n=new Map;for(let r of t??[]){let o;try{o=e.resolveComment(String(r.id));}catch{continue}let l=new Map;for(let s of o){let a=l.get(s.story)??[];a.push(s),l.set(s.story,a);}for(let[s,a]of l){if(a.length===0)continue;let d=Math.min(...a.map(p=>p.start)),f=Math.max(...a.map(p=>p.end)),c=n.get(s)??[];c.push({id:r.id,start:d,end:f}),n.set(s,c);}}return n}var Te=class{constructor(t,n){b(this,"session",t);b(this,"storyIds");b(this,"baseParagraphs");b(this,"baseStories");b(this,"comments");this.storyIds=new Set(t.storyIds()),this.baseParagraphs=Pn(n),this.baseStories=Cn(n),this.comments=In(t,n.package.document.comments);}storyToBlocks(t){let n=[],r=this.baseStories.get(t),o=this.session.storySegments(t),l=this.comments.get(t)??[],s=[],a=0,d=0,f=0,c=g=>{let m=[];for(let y of l)y.start>=a&&y.start<=g&&m.push({id:y.id,kind:"start",offset:y.start-a}),y.end>=a&&y.end<=g&&m.push({id:y.id,kind:"end",offset:y.end-a});return m},p=(g,m)=>{let y=0;for(let k=0;k<g.length;k+=1)g[k]===" "&&(k>y&&s.push({kind:"text",text:g.slice(y,k),attributes:m}),s.push({kind:"embed",embedKind:"tab",payload:{},attributes:m}),y=k+1);y<g.length&&s.push({kind:"text",text:g.slice(y),attributes:m});};for(let g of o){if(g.kind==="text"){p(g.text,g.attributes),f+=g.text.length;continue}if(g.kind==="pilcrow"){let m=`${t}:p${d}`,y=g.paraId===m&&!this.baseParagraphs.has(g.paraId)?"":g.paraId;n.push(kn(y,g.properties,s,c(f),this.baseParagraphs.get(g.paraId))),s=[],d+=1,f+=1,a=f;continue}if(g.embedKind==="table")n.push(xn(this,g.payload));else if(g.embedKind==="blockSdt"){let m=S(g.payload.story),y=ue(g.payload),k=m&&this.storyIds.has(m)?this.storyToBlocks(m):[],R=ct(g.payload.value);if(R)try{let x=Se(y,R);y=x.properties,k=x.content;}catch{}n.push({type:"blockSdt",properties:y,content:k});}else if(g.embedKind==="opaque"){let m=w(g.payload.blob);if(m?.type==="pageBreak")n.push(wn());else {let y=r?.[n.length];m?.type==="blockSdt"&&y?.type==="blockSdt"&&n.push(y);}}else s.push(g);f+=1;}return s.length>0&&n.push({type:"paragraph",content:we(s)}),n}};function vn(e,t,n={}){let r=new Te(e,t),o=c=>n.storyIds===void 0||n.storyIds.has(c),l=r.storyIds.has("body")&&o("body")?r.storyToBlocks("body"):t.package.document.content,s=t.package.headers;s&&(n.storyIds===void 0||[...s.keys()].some(c=>o(`hf:${c}`)))&&(s=new Map([...s].map(([c,p])=>{let g=`hf:${c}`;return [c,r.storyIds.has(g)&&o(g)?{...p,content:r.storyToBlocks(g)}:p]})));let a=t.package.footers;a&&(n.storyIds===void 0||[...a.keys()].some(c=>o(`hf:${c}`)))&&(a=new Map([...a].map(([c,p])=>{let g=`hf:${c}`;return [c,r.storyIds.has(g)&&o(g)?{...p,content:r.storyToBlocks(g)}:p]})));let f=n.storyIds===void 0||t.package.footnotes?.some(c=>o(`fn:${c.id}`))?t.package.footnotes?.map(c=>{let p=`fn:${c.id}`;return r.storyIds.has(p)&&o(p)?{...c,content:r.storyToBlocks(p),verbatimXml:void 0}:c}):t.package.footnotes;return {...t,package:{...t.package,document:{...t.package.document,content:l},...s?{headers:s}:{},...a?{footers:a}:{},...f?{footnotes:f}:{}}}}function ur(e,t){return !e||!t?e===t:e.anchor.story===t.anchor.story&&e.anchor.paraId===t.anchor.paraId&&e.anchor.offset===t.anchor.offset&&e.head.story===t.head.story&&e.head.paraId===t.head.paraId&&e.head.offset===t.head.offset}function An(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return Math.floor(Math.random()*4294967295)}function ft(e){return JSON.stringify("revisionId"in e?{revisionId:e.revisionId}:{story:e.story,startPara:e.start.paraId,startOffset:e.start.offset,endPara:e.end.paraId,endOffset:e.end.offset})}function Fn(e){return JSON.stringify(e.map(t=>({story:t.story,startPara:t.start.paraId,startOffset:t.start.offset,endPara:t.end.paraId,endOffset:t.end.offset})))}function Yn(e,t){let n=new Map,r=[],o=false,l=false,s=0,a=0,d=false,f=null,c,p=null,g=new Map,m=new Map,y=[],k=new Map,R=new Map,x=null,I=false,C=0,A=0,F=false,L=()=>{c=void 0,p=null;},j=()=>{if(!(l||d||a!==0)){d=true;try{for(;!l&&r.length>0;){let i=r.shift();if(!i)break;for(let[u,h]of [...n]){if(l)return;if(n.get(u)===h)try{h(i.update.slice(),i.origin);}catch{}}}}finally{d=false,l&&(r.length=0);}}},b=i=>{L(),a+=1;try{return i()}finally{a-=1,a===0&&j();}},Pe=i=>i?{anchor:{...i.anchor},head:{...i.head}}:null,P=i=>{f!==i&&(e.track_undo(i),f=i);},_=i=>{let u=`table:${i}`;f!==u&&(e.track_table_undo(i),f=u);},gt=i=>{let u=h=>typeof h=="string"&&h===i||typeof h=="number"&&Number.isFinite(h)&&String(h)===i;for(let h of e.story_ids())if(JSON.parse(e.story_segments(h)).some(O=>O.kind==="embed"&&(u(O.payload.embedId)||u(O.payload.id)||u(O.payload.rId))))return h;return null},le=i=>{let u=gt(i);u&&P(u);},mt=()=>{o||(e.set_update_observer((i,u)=>{u!==0&&u!==1||(r.push({update:i.slice(),origin:u===0?"local":"remote"}),j());}),o=true);},ht=()=>{!o||n.size>0||l||(r.length=0,e.clear_update_observer(),o=false);};return {clientId:t,registerFont:i=>{F||(e.clear_measure_fonts(),F=true);let u=e.register_measure_font(i);return y.push(i.slice()),A+=1,u},clearFonts:()=>{e.clear_measure_fonts(),y.length=0,R.clear(),A+=1,F=true;},measureParagraphJson:i=>{let u=e.measure_paragraph_json(i);return R.set(i,i),u},layoutDocumentJson:i=>{let u=e.layout_document_json(i);return x=i,I=false,C+=1,u},layoutFontRequirementsJson:i=>e.layout_font_requirements_json(i),layoutDocumentWithRegionsJson:i=>{let u=e.layout_document_with_regions_json(i);return x=i,I=true,C+=1,u},buildDisplayListJson:i=>e.build_display_list_json(i),buildDisplayListFrame:(i,u)=>e.build_display_list_frame(i,u),residentCaretSnapshot:()=>JSON.parse(e.resident_caret_snapshot_json()),applyInput:(i,u)=>{let h=c?.head.story??"body";return P(h),b(()=>e.apply_input(i,u))},applyDelete:(i,u)=>{let h=c?.head.story??"body";return P(h),b(()=>e.apply_delete(i,u))},applyInputProfiled:(i,u)=>{let h=c?.head.story??"body";P(h);let T=b(()=>e.apply_input_profiled(i,u)),O=JSON.parse(e.apply_input_profile_json());return {frame:T,profile:O}},applyDeleteProfiled:(i,u)=>{let h=c?.head.story??"body";P(h);let T=b(()=>e.apply_delete_profiled(i,u)),O=JSON.parse(e.apply_input_profile_json());return {frame:T,profile:O}},residentWorkerSnapshot:i=>{if(!x||!I&&k.size===0)return null;let u=e.selection(),h=i?.knownFontsRevision===A,T=null;if(i?.knownStateVector)try{T=e.encode_diff(i.knownStateVector.slice());}catch{T=null;}return {clientId:t,state:T??e.encode_state(),selection:JSON.parse(u),fonts:h?[]:y.map(O=>O.slice()),fontsRevision:A,renderInputs:[...k].map(([O,yt])=>({story:O,env:structuredClone(yt)})),measureInputs:[...R.values()],layoutInput:x,layoutWithRegions:I,layoutRevision:C}},residentWorkerProbe:()=>!x||!I&&k.size===0?null:{layoutRevision:C},displayHitTestRegionsJson:(i,u,h)=>e.display_hit_test_regions_json(i,u,h),displayRangeRectsJson:(i,u)=>e.display_range_rects_json(i,u),displayRangeRectsRegionJson:(i,u,h,T)=>e.display_range_rects_region_json(i,u,h,T),outlineGlyphJson:(i,u)=>e.outline_glyph_json(i,u),loadState:i=>b(()=>e.load(i)),loadStories:i=>b(()=>JSON.parse(e.load_json(JSON.stringify(i)))),encodeState:()=>e.encode_state(),encodeStateVector:()=>e.encode_state_vector(),encodeStateAsUpdate:i=>i===void 0?e.encode_state():e.encode_diff(i.slice()),applyUpdate:i=>b(()=>e.apply_update(i)),applyLocalUpdate:(i,u)=>{P(u),b(()=>e.apply_local_update(i));},onUpdate:i=>{if(l)throw new Error("yrs session is destroyed");if(typeof i!="function")throw new TypeError("update listener must be a function");let u=s++;n.set(u,i),mt();let h=true;return ()=>{h&&(h=false,n.delete(u),ht());}},setSelection:(i,u=i)=>{if(i.story!==u.story)throw new Error("yrs selection must stay inside one story");e.set_selection(i.story,i.paraId,i.offset,u.paraId,u.offset),c={anchor:{...i},head:{...u}};},selection:()=>(c!==void 0||(c=JSON.parse(e.selection())),Pe(c)),setCellSelection:i=>e.set_cell_selection(JSON.stringify(i)),cellSelection:()=>JSON.parse(e.cell_selection()),beginUndoCapture:(i,u=false)=>u?_(i):P(i),markUndoGroup:i=>{let u=e.undo_depth(),h=Math.max(0,u-i);h>1&&g.set(u,h),m.clear();},undo:()=>b(()=>{let i=e.undo_depth(),u=g.get(i)??1,h=!1;for(let T=0;T<u;T+=1)h=e.undo()||h;return h&&u>1&&(g.delete(i),m.set(e.redo_depth(),u)),h}),redo:()=>b(()=>{let i=e.redo_depth(),u=m.get(i)??1,h=!1;for(let T=0;T<u;T+=1)h=e.redo()||h;return h&&u>1&&(m.delete(i),g.set(e.undo_depth(),u)),h}),canUndo:()=>e.can_undo(),canRedo:()=>e.can_redo(),undoDepth:()=>e.undo_depth(),redoDepth:()=>e.redo_depth(),createStory:(i,u,h="Normal",T="left")=>b(()=>JSON.parse(e.create_story(i,u,h,T))),deleteStory:i=>b(()=>e.delete_story(i)),insertTable:(i,u,h,T)=>(_(i.story),b(()=>JSON.parse(e.insert_table(i.story,i.paraId,i.offset,u,h,T?.name,T?.date)))),insertRow:(i,u,h)=>(_(i.story),b(()=>JSON.parse(e.insert_row(JSON.stringify(i),u==="below",h?.name,h?.date)))),insertColumn:(i,u)=>(_(i.story),b(()=>JSON.parse(e.insert_column(JSON.stringify(i),u==="right")))),deleteRow:(i,u)=>(_(i.anchor.story),b(()=>JSON.parse(e.delete_row(JSON.stringify(i),u?.name,u?.date)))),deleteColumn:i=>(_(i.anchor.story),b(()=>JSON.parse(e.delete_column(JSON.stringify(i))))),deleteTable:i=>(_(i.story),b(()=>JSON.parse(e.delete_table(JSON.stringify(i))))),mergeCells:i=>(_(i.anchor.story),b(()=>JSON.parse(e.merge_cells(JSON.stringify(i))))),splitCell:(i,u,h)=>(_(i.story),b(()=>JSON.parse(e.split_cell(JSON.stringify(i),u,h)))),setCellShading:(i,u)=>(_(i.anchor.story),b(()=>JSON.parse(e.set_cell_shading(JSON.stringify(i),u??void 0)))),setCellTextFormat:(i,u)=>(_(i.anchor.story),b(()=>JSON.parse(e.set_cell_text_format(JSON.stringify(i),JSON.stringify(u))))),setCellBorders:(i,u)=>(_(i.anchor.story),b(()=>JSON.parse(e.set_cell_borders(JSON.stringify(i),JSON.stringify(u))))),setColumnWidth:(i,u)=>(_(i.story),b(()=>JSON.parse(e.set_column_width(JSON.stringify(i),u)))),setTableWidth:(i,u)=>(_(i.story),b(()=>JSON.parse(e.set_table_width(JSON.stringify(i),u)))),insertText:(i,u,h)=>(P(i.story),b(()=>JSON.parse(e.insert_text(i.story,i.paraId,i.offset,u,h?.name,h?.date)))),deleteRange:(i,u)=>(P(i.story),b(()=>JSON.parse(e.delete_range(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,u?.name,u?.date)))),replaceRange:(i,u,h)=>(P(i.story),b(()=>JSON.parse(e.replace_range(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,u,h?.name,h?.date)))),splitParagraph:(i,u)=>(P(i.story),b(()=>JSON.parse(e.split_paragraph(i.story,i.paraId,i.offset,u?.name,u?.date)))),mergeParagraphs:(i,u,h)=>(P(i),b(()=>JSON.parse(e.merge_paragraphs(i,u,h?.name,h?.date)))),toggleMark:(i,u)=>{P(i.story),b(()=>e.toggle_mark(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u)));},formatRange:(i,u)=>{P(i.story),b(()=>e.format_range(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u)));},setHyperlink:(i,u)=>{P(i.story),b(()=>e.set_hyperlink(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u)));},clearFormatting:i=>{P(i.story),b(()=>e.clear_formatting(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset));},applyParagraphStyle:(i,u,h)=>{P(i.story),b(()=>e.apply_paragraph_style(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,u,h?.name,h?.date));},setParagraphAttrs:(i,u,h)=>{P(i.story),b(()=>e.set_paragraph_attrs(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset,JSON.stringify(u),h?.name,h?.date));},insertImage:(i,u,h)=>(P(i.story),b(()=>JSON.parse(e.insert_image(i.story,i.paraId,i.offset,JSON.stringify(u),h?.name,h?.date)))),setContentControlValue:(i,u)=>{le(i),b(()=>e.set_content_control_value(i,JSON.stringify(u)));},setContentControlValueAt:(i,u)=>{P(i.story),b(()=>e.set_content_control_value_at(i.story,i.paraId,i.offset,JSON.stringify(u)));},clearContentControlValue:i=>{le(i),b(()=>e.clear_content_control_value(i));},setImageGeometry:(i,u)=>{le(i),b(()=>e.set_image_geometry(i,JSON.stringify(u)));},insertPageBreak:i=>{P(i.story),b(()=>e.insert_page_break(i.story,i.paraId,i.offset));},insertSectionBreak:(i,u)=>{P(i.story),b(()=>e.insert_section_break(i.story,i.paraId,i.offset,u));},insertWatermark:(i,u)=>{P(i.story),b(()=>e.insert_watermark(i.story,i.paraId,i.offset,JSON.stringify(u)));},applyRawOps:(i,u)=>b(()=>e.apply_raw_ops(i,JSON.stringify(u))),setParagraphAttr:(i,u,h)=>b(()=>e.set_paragraph_attr(i,u,JSON.stringify(h??null))),addComment:(i,u,h,T)=>b(()=>JSON.parse(e.add_comment(Fn(i),u,h,JSON.stringify(T??null)))),acceptChange:i=>b(()=>JSON.parse(e.accept_change(ft(i)))),rejectChange:i=>b(()=>JSON.parse(e.reject_change(ft(i)))),selectionContext:i=>{let u=JSON.stringify(i);if(p?.key===u)return JSON.parse(p.json);let h=e.selection_context(i.story,i.start.paraId,i.start.offset,i.end.paraId,i.end.offset),T=JSON.parse(h);return p={key:u,json:h},T},listRevisions:()=>JSON.parse(e.list_revisions()),resolveComment:i=>JSON.parse(e.resolve_comment(i)),storyIds:()=>e.story_ids(),storyLength:i=>e.story_len(i),storyChecksum:i=>BigInt(e.story_checksum(i)),yrsBlocksForStory:(i,u={})=>{let h=e.yrs_blocks_for_story(i,JSON.stringify(u)),T=JSON.parse(h);return k.set(i,structuredClone(u)),T},paragraphs:i=>JSON.parse(e.paragraphs(i)),paragraphSpans:i=>JSON.parse(e.paragraph_spans(i)),storySegments:i=>JSON.parse(e.story_segments(i)),locateParagraph:(i,u)=>JSON.parse(e.locate_paragraph(i,u)),destroy:()=>{l||(l=true,n.clear(),r.length=0,o&&e.clear_update_observer(),e.free());}}}async function cr(e){let t=e?.clientId??An(),n=await import('../wasm-NWXX4H5G.mjs');return await n.preloadEditWasm(),Yn(n.createEditSession(t),t)}export{ae as ResidentEngineWorkerClient,Rt as canUseResidentEngineWorker,Bn as compareYrsLocs,Mn as createYrsInputPositionMap,cr as createYrsSession,_n as displayPositionToYrsLoc,Xt as documentToYrs,ur as sameYrsSelection,Fe as yrsLocToDisplayPosition,vn as yrsToDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import'../chunk-EUUIJVM6.mjs';import {a as a$1,b as b$
|
|
1
|
+
import'../chunk-EUUIJVM6.mjs';import {b as b$1,a as a$1}from'../chunk-J7LNO6SM.mjs';import {a as a$2,b as b$2}from'../chunk-Y7RUNRU2.mjs';import {u as u$1,s,a,g as g$1,j as j$1,i}from'../chunk-GGEGIQRK.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';async function X(){await a$2();let e=b$2(se()),i=new Set,o=false,a=false,s=null,p=null,y=n=>{s!==n&&(e.track_undo(n),s=n);},S=()=>{o||(e.set_update_observer((n,t)=>{if(!(t!==0&&t!==1))for(let c of [...i])c(n,t===0?"local":"remote");}),o=true);};return {registerFont:n=>e.register_measure_font(n),clearFonts:()=>e.clear_measure_fonts(),encodeStateVector:()=>e.encode_state_vector(),measureParagraphJson:n=>e.measure_paragraph_json(n),layoutDocumentJson:n=>e.layout_document_json(n),layoutFontRequirementsJson:n=>e.layout_font_requirements_json(n),layoutDocumentWithRegionsJson:n=>e.layout_document_with_regions_json(n),buildDisplayListFrame:(n,t)=>e.build_display_list_frame(n,t),residentCaretSnapshot:()=>JSON.parse(e.resident_caret_snapshot_json()),selection:()=>JSON.parse(e.selection()),applyInput:(n,t)=>(y(p?.story??"body"),e.apply_input(n,t)),applyDelete:(n,t)=>(y(p?.story??"body"),e.apply_delete(n,t)),applyInputProfiled:(n,t)=>{y(p?.story??"body");let c=e.apply_input_profiled(n,t),l=JSON.parse(e.apply_input_profile_json());return {frame:c,profile:l}},applyDeleteProfiled:(n,t)=>{y(p?.story??"body");let c=e.apply_delete_profiled(n,t),l=JSON.parse(e.apply_input_profile_json());return {frame:c,profile:l}},outlineGlyphJson:(n,t)=>e.outline_glyph_json(n,t),loadState:n=>e.load(n),applyUpdate:n=>e.apply_update(n),onUpdate:n=>(i.add(n),S(),()=>i.delete(n)),setSelection:(n,t=n)=>{if(n.story!==t.story)throw new Error("yrs selection must stay inside one story");e.set_selection(n.story,n.paraId,n.offset,t.paraId,t.offset),p={...t};},yrsBlocksForStory:(n,t={})=>JSON.parse(e.yrs_blocks_for_story(n,JSON.stringify(t))),destroy:()=>{a||(a=true,i.clear(),o&&e.clear_update_observer(),e.free());}}}function se(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return Math.floor(Math.random()*4294967295)}var re=self,r=null,C=null,u=[],M=0,L=-1,q=Promise.resolve(),d=null,D=null,h=new Map,E=new Map,R=new Set,J=1,B=1,x={color:"#000",width:2},P=null,g=null,v=null,O=null,b=new Set;re.onmessage=e=>{q=q.then(()=>le(e.data)).catch(i=>{I({id:e.data.id,ok:false,error:i instanceof Error?i.message:String(i)});});};async function le(e){if(e.type==="destroy"){te();return}if(e.type==="bootstrap"){te(),r=await X(),ee(e.snapshot),ne();let o=performance.now(),a=r.buildDisplayListFrame(e.extras,e.expectedFrameEpoch);await k(e.id,a,performance.now()-o,u,void 0,o);return}if(e.type==="eraseCaret"){P=null,g!==null&&await j(false),I({id:e.id,ok:true});return}if(!r)throw new Error("Resident engine worker is not initialized");if(e.type==="sync"){C?.(),C=null,ee(e.snapshot),ne();let o=performance.now(),a=r.buildDisplayListFrame(e.extras,e.expectedFrameEpoch);await k(e.id,a,performance.now()-o,u,void 0,o,false,e.paintCaret);return}if(e.type==="buildFrame"){u=[];let o=performance.now(),a=r.buildDisplayListFrame(e.extras,e.expectedFrameEpoch);await k(e.id,a,performance.now()-o,u,void 0,o,false,e.paintCaret);return}if(e.type==="applyUpdate"){r.applyUpdate(e.update),e.selection&&r.setSelection(e.selection.anchor,e.selection.head);return}if(e.type==="attachCanvases"){let o=h.size>0&&(J!==e.devicePixelRatio||B!==e.zoom),a=new Set(e.pages.map(s=>s.pageId));for(let s of e.activePageIds)R.has(s)||a.add(s);for(let{pageId:s,canvas:p}of e.pages)h.set(s,p);R=new Set(e.activePageIds),J=e.devicePixelRatio,B=e.zoom,x=e.caretStyle;for(let[s,p]of h)R.has(s)||(p.width=0,p.height=0,E.delete(s),oe(s));await j(o?true:a),I({id:e.id,ok:true});return}r.setSelection(e.selection.anchor,e.selection.head),u=[];let i=performance.now();try{let o=e.type==="applyDelete"?e.profile?r.applyDeleteProfiled(e.direction,e.expectedFrameEpoch):{frame:r.applyDelete(e.direction,e.expectedFrameEpoch),profile:void 0}:e.profile?r.applyInputProfiled(e.text,e.expectedFrameEpoch):{frame:r.applyInput(e.text,e.expectedFrameEpoch),profile:void 0};await k(e.id,o.frame,performance.now()-i,u,o.profile,i,!0,e.paintCaret);}catch(o){let a=o instanceof Error?o.message:String(o);I({id:e.id,ok:false,error:a,residentUnavailable:a.includes("resident input state is not ready")});}finally{u=[];}}function ee(e){if(!r)throw new Error("Resident engine worker is not initialized");if(r.loadState(e.state),e.fontsRevision!==L){r.clearFonts();for(let i of e.fonts)r.registerFont(i);L=e.fontsRevision;}for(let{story:i,env:o}of e.renderInputs)r.yrsBlocksForStory(i,o);for(let i of e.measureInputs)r.measureParagraphJson(i);e.layoutWithRegions?r.layoutDocumentWithRegionsJson(e.layoutInput):r.layoutDocumentJson(e.layoutInput),e.selection&&r.setSelection(e.selection.anchor,e.selection.head),M=e.layoutRevision,u=[];}function ne(){r&&(C=r.onUpdate(e=>u.push(e.slice())));}function te(){C?.(),C=null,r?.destroy(),r=null,u=[],M=0,L=-1,d=null,D=null,h.clear(),E.clear(),R.clear(),P=null,g=null,v=null,O=null,b.clear();}function oe(e){b.delete(e),g===e&&(g=null,v=null);}async function k(e,i,o,a=u,s$1,p=performance.now(),y=false,S=false){d=u$1(d,s(i)),d={...d,pages:d.pages.map(f=>({...f,primitiveIds:f.primitiveIds.slice()}))};let n=r?.residentCaretSnapshot();if(!n||!b$1(n,d))throw new Error("Resident caret snapshot does not match the produced frame");if(y&&!n.caretRect)throw new Error("Resident input frame omitted collapsed caret geometry");let t=r?.selection()??null;P=S?n.caretRect??null:null;let c=new Set(d.pages.map(f=>f.pageId.toString()));for(let f of h.keys())c.has(f)||(h.delete(f),E.delete(f),oe(f));let l=performance.now(),{replayedPages:F,caretPainted:U}=await j(false),Y=performance.now()-l,w=A(i),_=a.map(A),m=r?A(r.encodeStateVector()):void 0;I({id:e,ok:true,frame:w,updates:_,engineMs:o,workerTotalMs:performance.now()-p,engineProfile:s$1,caret:n,selection:t,caretPainted:U,replayMs:Y,replayedPages:F,layoutRevision:M,...m?{stateVector:m}:{}},[w,..._,...m?[m]:[]]);}async function j(e){if(!d||h.size===0)return {replayedPages:0,caretPainted:false};!D&&r&&(D=new a({provider:(t,c)=>r.outlineGlyphJson(t,c)}));let i$1=e===true,o=e instanceof Set?e:null,a$2=P&&R.has(P.pageId)?P:null,s=a$2?a$1(a$2,x,J,B):null,p=a$2&&s?`${a$2.pageId}|${s.x}|${s.y}|${s.width}|${s.height}|${x.color}`:null,y=[];for(let t=0;t<d.pages.length;t+=1){let c=d.pages[t],l=c.pageId.toString();if(!R.has(l))continue;let F=i$1||o?.has(l)===true||d.damagedPageIds.has(c.pageId),U=l===a$2?.pageId&&!(g===l&&v===p),Y=l===g&&l!==a$2?.pageId;if(!F&&!U&&!Y)continue;let w=h.get(l),_=d.displayList.pages[t];if(!w||!_)continue;let m=l,f=E.get(m);f||(f=new OffscreenCanvas(1,1),E.set(m,f));let W=f;if(!F&&b.has(m)){y.push(Promise.resolve({canvas:w,buffer:W,pageId:m}));continue}y.push(g$1(W,_,{glyphCache:D??void 0},J,B).then(()=>({canvas:w,buffer:W,pageId:m})));}let S=await Promise.all(y),n=a$2!==null&&g===a$2.pageId&&v===p;for(let{canvas:t,buffer:c,pageId:l}of S)a$2&&s&&l===a$2.pageId?(O||(O=new OffscreenCanvas(1,1)),j$1(t,c,O,{...s,color:x.color}),b.add(l),g=l,v=p,n=true):(i(t,c),b.delete(l),g===l&&(g=null,v=null));return {replayedPages:S.length,caretPainted:n}}function A(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.slice().buffer}function I(e,i=[]){re.postMessage(e,i);}
|