@file-viewer/web 2.0.9 → 2.0.11

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.
@@ -2,4 +2,4 @@
2
2
  * Pure HTML DOCX renderer derived from docx-preview/docxjs.
3
3
  * Released under Apache License 2.0.
4
4
  */
5
- !function(e){function t(t){!e.JSZip&&t&&t.jsZipUrl&&"function"==typeof e.importScripts&&e.importScripts(t.jsZipUrl);var r=e.JSZip;if(!r)throw new Error("JSZip is not available in the DOCX worker. Set workerJsZipUrl or bundle JSZip.");var a={"./comments/comments-extended-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CommentsExtendedPart=void 0;const a=e("../common/part"),n=e("../utils");class s extends a.Part{constructor(e,t){super(e,t),this.comments=[]}parseXml(e){const t=this._package.xmlParser;for(let r of t.elements(e,"commentEx"))this.comments.push({paraId:t.attr(r,"paraId"),paraIdParent:t.attr(r,"paraIdParent"),done:t.boolAttr(r,"done")});this.commentMap=(0,n.keyBy)(this.comments,e=>e.paraId)}}r.CommentsExtendedPart=s},"./comments/comments-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CommentsPart=void 0;const a=e("../common/part"),n=e("../utils");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.comments=this._documentParser.parseComments(e),this.commentMap=(0,n.keyBy)(this.comments,e=>e.id)}}r.CommentsPart=s},"./comments/elements":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WmlCommentRangeEnd=r.WmlCommentRangeStart=r.WmlCommentReference=r.WmlComment=void 0;const a=e("../document/dom");class n extends a.OpenXmlElementBase{constructor(){super(...arguments),this.type=a.DomType.Comment}}r.WmlComment=n;class s extends a.OpenXmlElementBase{constructor(e){super(),this.id=e,this.type=a.DomType.CommentReference}}r.WmlCommentReference=s;class o extends a.OpenXmlElementBase{constructor(e){super(),this.id=e,this.type=a.DomType.CommentRangeStart}}r.WmlCommentRangeStart=o;class i extends a.OpenXmlElementBase{constructor(e){super(),this.id=e,this.type=a.DomType.CommentRangeEnd}}r.WmlCommentRangeEnd=i},"./common/content-types":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseContentTypes=function(e,t){return t.elements(e).map(e=>({extension:t.attr(e,"Extension"),partName:t.attr(e,"PartName"),contentType:t.attr(e,"ContentType")}))}},"./common/open-xml-package":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.OpenXmlPackage=void 0;const n=a(e("jszip")),s=e("../parser/xml-parser"),o=e("../utils"),i=e("./relationship"),l=e("./content-types");class c{constructor(e,t){this._zip=e,this.options=t,this.xmlParser=new s.XmlParser}get(e){const t=function(e){return e.startsWith("/")?e.substr(1):e}(e);return this._zip.files[t]??this._zip.files[t.replace(/\//g,"\\")]}update(e,t){this._zip.file(e,t)}static async load(e,t){const r=await n.default.loadAsync(e);return new c(r,t)}save(e="blob"){return this._zip.generateAsync({type:e})}load(e,t="string"){return this.get(e)?.async(t)??Promise.resolve(null)}async loadRelationships(e=null){let t="_rels/.rels";if(null!=e){const[r,a]=(0,o.splitPath)(e);t=`${r}_rels/${a}.rels`}const r=await this.load(t);return r?(0,i.parseRelationships)(u(this.parseXmlDocument(r)),this.xmlParser):null}async loadContentTypes(){const e=await this.load("[Content_Types].xml");return e?(0,l.parseContentTypes)(u(this.parseXmlDocument(e)),this.xmlParser):[]}parseXmlDocument(e){return(0,s.parseXmlString)(e,this.options.trimXmlDeclaration)}}function u(e){return e.firstElementChild??e.documentElement}r.OpenXmlPackage=c},"./common/part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Part=void 0;const a=e("../parser/xml-parser");r.Part=class{constructor(e,t){this._package=e,this.path=t}async load(){this.rels=await this._package.loadRelationships(this.path);const e=await this._package.load(this.path),t=this._package.parseXmlDocument(e);this._package.options.keepOrigin&&(this._xmlDocument=t),this.parseXml(t.firstElementChild??t.documentElement)}save(){this._package.update(this.path,(0,a.serializeXmlString)(this._xmlDocument))}parseXml(e){}}},"./common/relationship":function(e,t,r){"use strict";var a;Object.defineProperty(r,"__esModule",{value:!0}),r.RelationshipTypes=void 0,r.parseRelationships=function(e,t){return t.elements(e).map(e=>({id:t.attr(e,"Id"),type:t.attr(e,"Type"),target:t.attr(e,"Target"),targetMode:t.attr(e,"TargetMode")}))},function(e){e.OfficeDocument="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",e.FontTable="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",e.Image="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",e.Numbering="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",e.Styles="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",e.StylesWithEffects="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",e.Theme="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",e.Settings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",e.WebSettings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",e.Hyperlink="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",e.Footnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",e.Endnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",e.Footer="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",e.Header="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",e.ExtendedProperties="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",e.CoreProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",e.CustomProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",e.Comments="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",e.CommentsExtended="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",e.AltChunk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk",e.Chart="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",e.ChartUserShapes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes",e.DiagramData="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData",e.DiagramLayout="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout",e.DiagramQuickStyle="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle",e.DiagramColors="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors",e.Ink="http://schemas.microsoft.com/office/2007/relationships/ink",e.ContentPart="http://schemas.openxmlformats.org/officeDocument/2006/relationships/contentPart"}(a||(r.RelationshipTypes=a={}))},"./document/bookmarks":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseBookmarkStart=function(e,t){return{type:a.DomType.BookmarkStart,id:t.attr(e,"id"),name:t.attr(e,"name"),colFirst:t.intAttr(e,"colFirst"),colLast:t.intAttr(e,"colLast")}},r.parseBookmarkEnd=function(e,t){return{type:a.DomType.BookmarkEnd,id:t.attr(e,"id")}};const a=e("./dom")},"./document/border":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseBorder=n,r.parseBorders=function(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"left":r.left=n(a,t);break;case"top":r.top=n(a,t);break;case"right":r.right=n(a,t);break;case"bottom":r.bottom=n(a,t)}return r};const a=e("./common");function n(e,t){return{type:t.attr(e,"val"),color:t.attr(e,"color"),size:t.lengthAttr(e,"sz",a.LengthUsage.Border),offset:t.lengthAttr(e,"space",a.LengthUsage.Point),frame:t.boolAttr(e,"frame"),shadow:t.boolAttr(e,"shadow")}}},"./document/common":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LengthUsage=r.ns=void 0,r.convertLength=function(e,t=r.LengthUsage.Dxa){if(null==e||""===e||/.+(p[xt]|[%])$/i.test(e))return e;var n=parseFloat(e);if(Number.isNaN(n))return null;var s=n*t.mul;return null!=t.min&&null!=t.max&&(s=(0,a.clamp)(s,t.min,t.max)),`${s.toFixed(2)}${t.unit}`},r.convertBoolean=function(e,t=!1){switch(e){case"1":case"on":case"true":return!0;case"0":case"off":case"false":return!1;default:return t}},r.convertPercentage=function(e){return e?parseInt(e)/100:null},r.parseCommonProperty=function(e,t,a){if(e.namespaceURI!=r.ns.wordml)return!1;switch(e.localName){case"color":t.color=a.attr(e,"val");break;case"sz":t.fontSize=a.lengthAttr(e,"val",r.LengthUsage.FontSize);break;case"szCs":t.fontSize??(t.fontSize=a.lengthAttr(e,"val",r.LengthUsage.FontSize));break;default:return!1}return!0};const a=e("../utils");r.ns={wordml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",drawingml:"http://schemas.openxmlformats.org/drawingml/2006/main",picture:"http://schemas.openxmlformats.org/drawingml/2006/picture",wordprocessingCanvas:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",wordprocessingGroup:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wordprocessingShape:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",chart:"http://schemas.openxmlformats.org/drawingml/2006/chart",diagram:"http://schemas.openxmlformats.org/drawingml/2006/diagram",relationship:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",drawing2014:"http://schemas.microsoft.com/office/drawing/2014/main",ink2010:"http://schemas.microsoft.com/office/2010/ink",word2010:"http://schemas.microsoft.com/office/word/2010/wordml",compatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006",math:"http://schemas.openxmlformats.org/officeDocument/2006/math"},r.LengthUsage={Dxa:{mul:.05,unit:"pt"},SignedDxa:{mul:.05,unit:"pt"},Emu:{mul:1/12700,unit:"pt"},FontSize:{mul:.5,unit:"pt"},SignedHalfPoint:{mul:.5,unit:"pt"},Border:{mul:.125,unit:"pt",min:.25,max:12},Point:{mul:1,unit:"pt"},Percent:{mul:.02,unit:"%"},LineHeight:{mul:1/240,unit:""},VmlEmu:{mul:1/12700,unit:""}}},"./document/document-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DocumentPart=void 0;const a=e("../common/part");class n extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.body=this._documentParser.parseDocumentFile(e)}}r.DocumentPart=n},"./document/document":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},"./document/dom":function(e,t,r){"use strict";var a;Object.defineProperty(r,"__esModule",{value:!0}),r.OpenXmlElementBase=r.DomType=void 0,function(e){e.Document="document",e.Paragraph="paragraph",e.Run="run",e.Break="break",e.NoBreakHyphen="noBreakHyphen",e.Table="table",e.Row="row",e.Cell="cell",e.Hyperlink="hyperlink",e.SmartTag="smartTag",e.Drawing="drawing",e.Image="image",e.Text="text",e.Tab="tab",e.PositionalTab="positionalTab",e.SoftHyphen="softHyphen",e.Symbol="symbol",e.BookmarkStart="bookmarkStart",e.BookmarkEnd="bookmarkEnd",e.Footer="footer",e.Header="header",e.FootnoteReference="footnoteReference",e.EndnoteReference="endnoteReference",e.Footnote="footnote",e.Endnote="endnote",e.SimpleField="simpleField",e.ComplexField="complexField",e.Instruction="instruction",e.VmlPicture="vmlPicture",e.MmlMath="mmlMath",e.Shape="shape",e.MmlMathParagraph="mmlMathParagraph",e.MmlFraction="mmlFraction",e.MmlFunction="mmlFunction",e.MmlFunctionName="mmlFunctionName",e.MmlNumerator="mmlNumerator",e.MmlDenominator="mmlDenominator",e.MmlRadical="mmlRadical",e.MmlBase="mmlBase",e.MmlDegree="mmlDegree",e.MmlSuperscript="mmlSuperscript",e.MmlSubscript="mmlSubscript",e.MmlPreSubSuper="mmlPreSubSuper",e.MmlSubArgument="mmlSubArgument",e.MmlSuperArgument="mmlSuperArgument",e.MmlNary="mmlNary",e.MmlDelimiter="mmlDelimiter",e.MmlRun="mmlRun",e.MmlEquationArray="mmlEquationArray",e.MmlLimit="mmlLimit",e.MmlLimitLower="mmlLimitLower",e.MmlLimitUpper="mmlLimitUpper",e.MmlSubSuperscript="mmlSubSuperscript",e.MmlPhantom="mmlPhantom",e.MmlBorderBox="mmlBorderBox",e.MmlAccent="mmlAccent",e.MmlMatrix="mmlMatrix",e.MmlMatrixRow="mmlMatrixRow",e.MmlBox="mmlBox",e.MmlBar="mmlBar",e.MmlGroupChar="mmlGroupChar",e.VmlElement="vmlElement",e.Chart="chart",e.SmartArt="smartArt",e.Ink="ink",e.Ruby="ruby",e.RubyBase="rubyBase",e.RubyText="rubyText",e.Inserted="inserted",e.Deleted="deleted",e.DeletedText="deletedText",e.Comment="comment",e.CommentReference="commentReference",e.CommentRangeStart="commentRangeStart",e.CommentRangeEnd="commentRangeEnd",e.AltChunk="altChunk"}(a||(r.DomType=a={})),r.OpenXmlElementBase=class{constructor(){this.children=[],this.cssStyle={}}}},"./document/fields":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},"./document/line-spacing":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseLineSpacing=function(e,t){return{before:t.lengthAttr(e,"before"),after:t.lengthAttr(e,"after"),line:t.intAttr(e,"line"),lineRule:t.attr(e,"lineRule")}}},"./document/paragraph":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseParagraphProperties=function(e,t){let r={};for(let a of t.elements(e))i(a,r,t);return r},r.parseParagraphProperty=i,r.parseTabs=l,r.parseNumbering=c;const a=e("./common"),n=e("./section"),s=e("./line-spacing"),o=e("./run");function i(e,t,r){if(e.namespaceURI!=a.ns.wordml)return!1;if((0,a.parseCommonProperty)(e,t,r))return!0;switch(e.localName){case"tabs":t.tabs=l(e,r);break;case"sectPr":t.sectionProps=(0,n.parseSectionProperties)(e,r);break;case"numPr":t.numbering=c(e,r);break;case"spacing":return t.lineSpacing=(0,s.parseLineSpacing)(e,r),!1;case"textAlignment":return t.textAlignment=r.attr(e,"val"),!1;case"keepLines":t.keepLines=r.boolAttr(e,"val",!0);break;case"keepNext":t.keepNext=r.boolAttr(e,"val",!0);break;case"pageBreakBefore":t.pageBreakBefore=r.boolAttr(e,"val",!0);break;case"widowControl":t.widowControl=r.boolAttr(e,"val",!0);break;case"outlineLvl":t.outlineLevel=r.intAttr(e,"val");break;case"pStyle":t.styleName=r.attr(e,"val");break;case"rPr":t.runProps=(0,o.parseRunProperties)(e,r);break;default:return!1}return!0}function l(e,t){return t.elements(e,"tab").map(e=>({position:t.lengthAttr(e,"pos"),leader:t.attr(e,"leader"),style:t.attr(e,"val")}))}function c(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"numId":r.id=t.attr(a,"val");break;case"ilvl":r.level=t.intAttr(a,"val")}return r}},"./document/run":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseRunProperties=function(e,t){let r={};for(let a of t.elements(e))n(a,r,t);return r},r.parseRunProperty=n;const a=e("./common");function n(e,t,r){return!!(0,a.parseCommonProperty)(e,t,r)}},"./document/section":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.SectionType=void 0,r.isSectionPageBreak=function(e){return null==e||e===o.NextPage||e===o.EvenPage||e===o.OddPage},r.isSectionColumnBreak=function(e){return e===o.NextColumn},r.parseSectionProperties=function(e,t=n.default){var r={};for(let a of t.elements(e))switch(a.localName){case"pgSz":r.pageSize={width:t.lengthAttr(a,"w"),height:t.lengthAttr(a,"h"),orientation:t.attr(a,"orient")};break;case"type":r.type=t.attr(a,"val");break;case"pgMar":r.pageMargins={left:t.lengthAttr(a,"left"),right:t.lengthAttr(a,"right"),top:t.lengthAttr(a,"top"),bottom:t.lengthAttr(a,"bottom"),header:t.lengthAttr(a,"header"),footer:t.lengthAttr(a,"footer"),gutter:t.lengthAttr(a,"gutter")};break;case"cols":r.columns=i(a,t);break;case"headerReference":(r.headerRefs??(r.headerRefs=[])).push(u(a,t));break;case"footerReference":(r.footerRefs??(r.footerRefs=[])).push(u(a,t));break;case"titlePg":r.titlePage=t.boolAttr(a,"val",!0);break;case"pgBorders":r.pageBorders=(0,s.parseBorders)(a,t);break;case"pgNumType":r.pageNumber=l(a,t);break;case"docGrid":r.docGrid=c(a,t)}return r};const n=a(e("../parser/xml-parser")),s=e("./border");var o;function i(e,t){return{numberOfColumns:t.intAttr(e,"num"),space:t.lengthAttr(e,"space"),separator:t.boolAttr(e,"sep"),equalWidth:t.boolAttr(e,"equalWidth",!0),columns:t.elements(e,"col").map(e=>({width:t.lengthAttr(e,"w"),space:t.lengthAttr(e,"space")}))}}function l(e,t){return{chapSep:t.attr(e,"chapSep"),chapStyle:t.attr(e,"chapStyle"),format:t.attr(e,"fmt"),start:t.intAttr(e,"start")}}function c(e,t){const r=t.intAttr(e,"charSpace",null);return{type:t.attr(e,"type"),linePitch:t.lengthAttr(e,"linePitch"),charSpace:null==r?null:`${(r/4096).toFixed(4)}em`,charSpaceRaw:r}}function u(e,t){return{id:t.attr(e,"id"),type:t.attr(e,"type")}}!function(e){e.Continuous="continuous",e.NextPage="nextPage",e.NextColumn="nextColumn",e.EvenPage="evenPage",e.OddPage="oddPage"}(o||(r.SectionType=o={}))},"./document/style":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},"./document-parser":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.DocumentParser=r.autos=void 0;const n=e("./document/dom"),s=e("./document/paragraph"),o=e("./document/section"),i=a(e("./parser/xml-parser")),l=e("./document/run"),c=e("./document/bookmarks"),u=e("./document/common"),d=e("./vml/vml"),h=e("./comments/elements"),p=e("./utils");r.autos={shd:"inherit",color:"black",borderColor:"black",highlight:"transparent"};const m=[u.ns.wordprocessingShape,u.ns.wordprocessingCanvas,u.ns.wordprocessingGroup,u.ns.drawingml,u.ns.picture],f={oMath:n.DomType.MmlMath,oMathPara:n.DomType.MmlMathParagraph,f:n.DomType.MmlFraction,func:n.DomType.MmlFunction,fName:n.DomType.MmlFunctionName,num:n.DomType.MmlNumerator,den:n.DomType.MmlDenominator,rad:n.DomType.MmlRadical,deg:n.DomType.MmlDegree,e:n.DomType.MmlBase,sSup:n.DomType.MmlSuperscript,sSub:n.DomType.MmlSubscript,sPre:n.DomType.MmlPreSubSuper,sup:n.DomType.MmlSuperArgument,sub:n.DomType.MmlSubArgument,d:n.DomType.MmlDelimiter,nary:n.DomType.MmlNary,eqArr:n.DomType.MmlEquationArray,lim:n.DomType.MmlLimit,limLow:n.DomType.MmlLimitLower,limUpp:n.DomType.MmlLimitUpper,sSubSup:n.DomType.MmlSubSuperscript,phant:n.DomType.MmlPhantom,borderBox:n.DomType.MmlBorderBox,acc:n.DomType.MmlAccent,m:n.DomType.MmlMatrix,mr:n.DomType.MmlMatrixRow,box:n.DomType.MmlBox,bar:n.DomType.MmlBar,groupChr:n.DomType.MmlGroupChar};r.DocumentParser=class{constructor(e){this.options={ignoreWidth:!1,debug:!1,hideWebHiddenContent:!1,...e}}parseNotes(e,t,r){var a=[];for(let n of i.default.elements(e,t)){const e=new r;e.id=i.default.attr(n,"id"),e.noteType=i.default.attr(n,"type"),e.children=this.parseBodyElements(n),a.push(e)}return a}parseComments(e){var t=[];for(let r of i.default.elements(e,"comment")){const e=new h.WmlComment;e.id=i.default.attr(r,"id"),e.author=i.default.attr(r,"author"),e.initials=i.default.attr(r,"initials"),e.date=i.default.attr(r,"date"),e.children=this.parseBodyElements(r),t.push(e)}return t}parseDocumentFile(e){var t=i.default.element(e,"body"),r=i.default.element(e,"background"),a=i.default.element(t,"sectPr");return{type:n.DomType.Document,children:this.parseBodyElements(t),props:a?(0,o.parseSectionProperties)(a,i.default):{},cssStyle:r?this.parseBackground(r):{}}}parseBackground(e){var t={},r=b.colorAttr(e,"color");return r&&(t["background-color"]=r),t}parseBodyElements(e){var t=[];for(const r of i.default.elements(e))switch(r.localName){case"p":t.push(this.parseParagraph(r));break;case"altChunk":t.push(this.parseAltChunk(r));break;case"tbl":t.push(this.parseTable(r));break;case"sdt":t.push(...this.parseSdt(r,e=>this.parseBodyElements(e)))}return t}parseStylesFile(e){var t=[];for(const r of i.default.elements(e))switch(r.localName){case"style":t.push(this.parseStyle(r));break;case"docDefaults":t.push(this.parseDefaultStyles(r))}return t}parseDefaultStyles(e){var t={id:null,name:null,target:null,basedOn:null,styles:[]};for(const n of i.default.elements(e))switch(n.localName){case"rPrDefault":var r=i.default.element(n,"rPr");r&&t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})});break;case"pPrDefault":var a=i.default.element(n,"pPr");a&&t.styles.push({target:"p",values:this.parseDefaultProperties(a,{})})}return t}parseStyle(e){var t={id:i.default.attr(e,"styleId"),isDefault:i.default.boolAttr(e,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(i.default.attr(e,"type")){case"paragraph":t.target="p";break;case"table":t.target="table";break;case"character":t.target="span"}for(const r of i.default.elements(e))switch(r.localName){case"basedOn":t.basedOn=i.default.attr(r,"val");break;case"name":t.name=i.default.attr(r,"val");break;case"link":t.linked=i.default.attr(r,"val");break;case"next":t.next=i.default.attr(r,"val");break;case"aliases":t.aliases=i.default.attr(r,"val").split(",");break;case"pPr":t.styles.push({target:"p",values:this.parseDefaultProperties(r,{})}),t.paragraphProps=(0,s.parseParagraphProperties)(r,i.default);break;case"rPr":t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})}),t.runProps=(0,l.parseRunProperties)(r,i.default);break;case"tblPr":case"tcPr":t.styles.push({target:"td",values:this.parseDefaultProperties(r,{})});break;case"tblStylePr":for(let e of this.parseTableStyle(r))t.styles.push(e);break;case"rsid":case"qFormat":case"hidden":case"semiHidden":case"unhideWhenUsed":case"autoRedefine":case"uiPriority":break;default:this.options.debug&&console.warn(`DOCX: Unknown style element: ${r.localName}`)}return t}parseTableStyle(e){var t=[],r="",a="";switch(i.default.attr(e,"type")){case"firstRow":a=".first-row",r="tr.first-row td";break;case"lastRow":a=".last-row",r="tr.last-row td";break;case"firstCol":a=".first-col",r="td.first-col";break;case"lastCol":a=".last-col",r="td.last-col";break;case"band1Vert":a=":not(.no-vband)",r="td.odd-col";break;case"band2Vert":a=":not(.no-vband)",r="td.even-col";break;case"band1Horz":a=":not(.no-hband)",r="tr.odd-row";break;case"band2Horz":a=":not(.no-hband)",r="tr.even-row";break;default:return[]}for(const n of i.default.elements(e))switch(n.localName){case"pPr":t.push({target:`${r} p`,mod:a,values:this.parseDefaultProperties(n,{})});break;case"rPr":t.push({target:`${r} span`,mod:a,values:this.parseDefaultProperties(n,{})});break;case"tblPr":case"tcPr":t.push({target:r,mod:a,values:this.parseDefaultProperties(n,{})})}return t}parseNumberingFile(e){const t=[],r=[],a={},n=[],s=[];for(const t of i.default.elements(e))switch(t.localName){case"numPicBullet":r.push(this.parseNumberingPicBullet(t));break;case"abstractNum":n.push(t);break;case"num":s.push(t)}for(const e of n)a[i.default.attr(e,"abstractNumId")]=this.parseAbstractNumbering(e,r);for(const e of s){const n=i.default.attr(e,"numId"),s=(a[i.default.elementAttr(e,"abstractNumId","val")]??[]).map(e=>this.cloneNumberingLevel(e,n));for(const t of i.default.elements(e,"lvlOverride")){const e=i.default.intAttr(t,"ilvl"),a=i.default.element(t,"lvl"),o=i.default.element(t,"startOverride");let l=s.find(t=>t.level==e);if(a){l=this.parseNumberingLevel(n,a,r);const t=s.findIndex(t=>t.level==e);t>=0?s[t]=l:s.push(l)}o&&l&&(l.start=i.default.intAttr(o,"val",l.start))}t.push(...s)}return t}cloneNumberingLevel(e,t){return{...e,id:t,pStyle:{...e.pStyle},rStyle:{...e.rStyle},bullet:e.bullet?{...e.bullet}:null}}parseNumberingPicBullet(e){const t=i.default.intAttr(e,"numPicBulletId"),r=i.default.element(e,"pict"),a=r&&i.default.element(r,"shape"),n=a&&i.default.element(a,"imagedata");if(n)return{id:t,src:i.default.attr(n,"id"),style:i.default.attr(a,"style")};const s=i.default.element(e,"drawing"),o=s?this.findDescendant(s,"blip"):null;if(o){const e=s?this.findDescendant(s,"extent"):null,r=[];if(e){const t=i.default.lengthAttr(e,"cx",u.LengthUsage.Emu),a=i.default.lengthAttr(e,"cy",u.LengthUsage.Emu);t&&r.push(`width:${t};`),a&&r.push(`height:${a};`)}return{id:t,src:i.default.attr(o,"embed")??i.default.attr(o,"link"),style:r.join("")||void 0}}return null}parseAbstractNumbering(e,t){var r=[],a=i.default.attr(e,"abstractNumId");for(const n of i.default.elements(e))"lvl"===n.localName&&r.push(this.parseNumberingLevel(a,n,t));return r}parseNumberingLevel(e,t,r){var a={id:e,level:i.default.intAttr(t,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(const e of i.default.elements(t))switch(e.localName){case"start":a.start=i.default.intAttr(e,"val");break;case"pPr":this.parseDefaultProperties(e,a.pStyle);break;case"rPr":this.parseDefaultProperties(e,a.rStyle);break;case"lvlPicBulletId":var n=i.default.intAttr(e,"val");a.bullet=r.find(e=>e?.id==n);break;case"lvlText":a.levelText=i.default.attr(e,"val");break;case"pStyle":a.pStyleName=i.default.attr(e,"val");break;case"numFmt":a.format=i.default.attr(e,"val");break;case"lvlRestart":a.restart=i.default.intAttr(e,"val");break;case"suff":a.suff=i.default.attr(e,"val")}return a}parseSdt(e,t){const r=i.default.element(e,"sdtContent");return r?t(r):[]}parseInserted(e,t){return{type:n.DomType.Inserted,children:t(e)?.children??[]}}parseDeleted(e,t){return{type:n.DomType.Deleted,children:t(e)?.children??[]}}parseAltChunk(e){return{type:n.DomType.AltChunk,children:[],id:i.default.attr(e,"id")}}parseParagraph(e){var t={type:n.DomType.Paragraph,children:[]};for(let r of i.default.elements(e))switch(r.localName){case"pPr":this.parseParagraphProperties(r,t);break;case"r":t.children.push(this.parseRun(r,t));break;case"hyperlink":t.children.push(this.parseHyperlink(r,t));break;case"smartTag":t.children.push(this.parseSmartTag(r,t));break;case"bookmarkStart":t.children.push((0,c.parseBookmarkStart)(r,i.default));break;case"bookmarkEnd":t.children.push((0,c.parseBookmarkEnd)(r,i.default));break;case"commentRangeStart":t.children.push(new h.WmlCommentRangeStart(i.default.attr(r,"id")));break;case"commentRangeEnd":t.children.push(new h.WmlCommentRangeEnd(i.default.attr(r,"id")));break;case"oMath":case"oMathPara":{const e=this.parseMathElement(r);e&&t.children.push(e);break}case"sdt":t.children.push(...this.parseSdt(r,e=>this.parseParagraph(e).children));break;case"ins":t.children.push(this.parseInserted(r,e=>this.parseParagraph(e)));break;case"del":t.children.push(this.parseDeleted(r,e=>this.parseParagraph(e)))}return t}parseParagraphProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{if("rPr"==e.localName){i.default.element(e,"del")&&(t.props={...t.props??{},deletedParagraphMark:!0});const r=t.cssStyle["background-color"];return this.parseDefaultProperties(e,t.cssStyle),null==r?delete t.cssStyle["background-color"]:t.cssStyle["background-color"]=r,(0,s.parseParagraphProperty)(e,t,i.default),!0}if((0,s.parseParagraphProperty)(e,t,i.default))return!0;switch(e.localName){case"pStyle":t.styleName=i.default.attr(e,"val");break;case"cnfStyle":t.className=y.classNameOfCnfStyle(e);break;case"framePr":this.parseFrame(e,t);break;default:return!1}return!0})}parseFrame(e,t){"drop"==i.default.attr(e,"dropCap")&&(t.cssStyle.float="left")}parseHyperlink(e,t){var r={type:n.DomType.Hyperlink,parent:t,children:[]};r.anchor=i.default.attr(e,"anchor"),r.id=i.default.attr(e,"id");for(const t of i.default.elements(e))"r"===t.localName&&r.children.push(this.parseRun(t,r));return r}parseSmartTag(e,t){var r={type:n.DomType.SmartTag,parent:t,children:[]},a=i.default.attr(e,"uri"),s=i.default.attr(e,"element");a&&(r.uri=a),s&&(r.element=s);for(const t of i.default.elements(e))switch(t.localName){case"r":r.children.push(this.parseRun(t,r));break;case"smartTag":r.children.push(this.parseSmartTag(t,r))}return r}parseSimpleField(e,t){const r={type:n.DomType.SimpleField,parent:t,children:[],instruction:i.default.attr(e,"instr"),lock:i.default.boolAttr(e,"lock",!1),dirty:i.default.boolAttr(e,"dirty",!1)};for(const t of i.default.elements(e))switch(t.localName){case"r":r.children.push(this.parseRun(t,r));break;case"hyperlink":r.children.push(this.parseHyperlink(t,r));break;case"smartTag":r.children.push(this.parseSmartTag(t,r));break;case"bookmarkStart":r.children.push((0,c.parseBookmarkStart)(t,i.default));break;case"bookmarkEnd":r.children.push((0,c.parseBookmarkEnd)(t,i.default));break;case"commentRangeStart":r.children.push(new h.WmlCommentRangeStart(i.default.attr(t,"id")));break;case"commentRangeEnd":r.children.push(new h.WmlCommentRangeEnd(i.default.attr(t,"id")));break;case"sdt":r.children.push(...this.parseSdt(t,e=>this.parseParagraph(e).children));break;case"ins":r.children.push(this.parseInserted(t,e=>this.parseParagraph(e)));break;case"del":r.children.push(this.parseDeleted(t,e=>this.parseParagraph(e)))}return r}parseRun(e,t){var r={type:n.DomType.Run,parent:t,children:[]};for(let t of i.default.elements(e))if(t=this.checkAlternateContent(t),t)switch(t.localName){case"t":r.children.push({type:n.DomType.Text,text:t.textContent});break;case"delText":r.children.push({type:n.DomType.DeletedText,text:t.textContent});break;case"commentReference":r.children.push(new h.WmlCommentReference(i.default.attr(t,"id")));break;case"fldSimple":r.children.push(this.parseSimpleField(t,r));break;case"instrText":r.fieldRun=!0,r.children.push({type:n.DomType.Instruction,text:t.textContent});break;case"fldChar":r.fieldRun=!0,r.children.push({type:n.DomType.ComplexField,charType:i.default.attr(t,"fldCharType"),lock:i.default.boolAttr(t,"lock",!1),dirty:i.default.boolAttr(t,"dirty",!1)});break;case"noBreakHyphen":r.children.push({type:n.DomType.NoBreakHyphen});break;case"softHyphen":r.children.push({type:n.DomType.SoftHyphen});break;case"cr":r.children.push({type:n.DomType.Break,break:"line"});break;case"ptab":r.children.push({type:n.DomType.PositionalTab});break;case"br":r.children.push({type:n.DomType.Break,break:i.default.attr(t,"type")||"textWrapping"});break;case"lastRenderedPageBreak":r.children.push({type:n.DomType.Break,break:"lastRenderedPageBreak"});break;case"sym":r.children.push({type:n.DomType.Symbol,font:(0,p.encloseFontFamily)(i.default.attr(t,"font")),char:i.default.hexAttr(t,"char")});break;case"tab":r.children.push({type:n.DomType.Tab});break;case"footnoteReference":r.children.push({type:n.DomType.FootnoteReference,id:i.default.attr(t,"id")});break;case"endnoteReference":r.children.push({type:n.DomType.EndnoteReference,id:i.default.attr(t,"id")});break;case"drawing":let e=this.parseDrawing(t);e&&r.children.push(e);break;case"pict":case"object":r.children.push(this.parseVmlPicture(t));break;case"ruby":r.children.push(this.parseRuby(t));break;case"rPr":this.parseRunProperties(t,r)}return r}parseRuby(e){const t={type:n.DomType.Ruby,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"rubyPr":for(const e of i.default.elements(r))"rubyAlign"===e.localName&&(t.align=i.default.attr(e,"val"));break;case"rt":t.children.push(this.parseRubyContent(r,n.DomType.RubyText));break;case"rubyBase":t.children.push(this.parseRubyContent(r,n.DomType.RubyBase))}return t}parseRubyContent(e,t){const r={type:t,children:[]};for(const a of i.default.elements(e))if("r"==a.localName)r.children.push(this.parseRun(a,r));else if(t==n.DomType.RubyText&&"rPr"==a.localName){const e=i.default.element(a,"hps"),t=e?i.default.intAttr(e,"val",null):null;null!=t&&(r.cssStyle={...r.cssStyle??{},fontSize:t/2+"pt"})}return r}parseMathElement(e){const t=`${e.localName}Pr`,r={type:f[e.localName],children:[]};let a=!1;const s=e=>{if(f[e.localName]){const t=this.parseMathElement(e);t?(t.parent=r,r.children.push(t)):a=!0}else if("r"==e.localName){var o=this.parseRun(e,r);o.type=n.DomType.MmlRun,r.children.push(o)}else if(e.localName==t)r.props=this.parseMathProperies(e);else if("ins"==e.localName)for(const t of i.default.elements(e))s(t);else if("del"==e.localName)if(this.options.renderChanges)for(const t of i.default.elements(e))s(t);else a=!0};for(const t of i.default.elements(e))s(t);return a&&!this.hasVisibleMathContent(r)?null:r}hasVisibleMathContent(e){for(const t of e.children??[]){switch(t.type){case n.DomType.Text:if(t.text?.length)return!0;break;case n.DomType.DeletedText:if(this.options.renderChanges&&t.text?.length)return!0;break;case n.DomType.Symbol:case n.DomType.Tab:case n.DomType.PositionalTab:case n.DomType.NoBreakHyphen:case n.DomType.Break:return!0}if(this.hasVisibleMathContent(t))return!0}return!1}parseMathProperies(e){const t={};for(const r of i.default.elements(e))switch(r.localName){case"chr":t.char=i.default.attr(r,"val");break;case"vertJc":t.verticalJustification=i.default.attr(r,"val");break;case"pos":t.position=i.default.attr(r,"val");break;case"degHide":t.hideDegree=i.default.boolAttr(r,"val");break;case"begChr":t.beginChar=i.default.attr(r,"val");break;case"endChr":t.endChar=i.default.attr(r,"val");break;case"limLoc":t.limitLocation=i.default.attr(r,"val");break;case"grow":t.grow=i.default.boolAttr(r,"val");break;case"sepChr":t.separatorChar=i.default.attr(r,"val")}return t}parseRunProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{switch(e.localName){case"rStyle":t.styleName=i.default.attr(e,"val");break;case"vertAlign":t.verticalAlign=y.valueOfVertAlign(e,!0);break;default:return!1}return!0})}parseVmlPicture(e){const t={type:n.DomType.VmlPicture,children:[]};for(const r of i.default.elements(e)){const e=(0,d.parseVmlElement)(r,this);e&&t.children.push(e)}return t}checkAlternateContent(e){if("AlternateContent"!=e.localName)return e;for(const t of i.default.elements(e).filter(e=>"Choice"==e.localName)){const r=(i.default.attr(t,"Requires")??"").split(/\s+/).filter(Boolean);if(r.length>0&&r.every(t=>m.includes(e.lookupNamespaceURI(t)))){const e=i.default.elements(t)[0];if(e)return e}}const t=i.default.element(e,"Fallback");return t?i.default.elements(t)[0]:null}parseDrawing(e){for(var t of i.default.elements(e))switch(t.localName){case"inline":case"anchor":return this.parseDrawingWrapper(t)}}parseDrawingWrapper(e){var t,r,a,s,o,l,c,d,h,p,m,f={type:n.DomType.Drawing,children:[],cssStyle:{},props:{}},g="anchor"==e.localName;const b=(e,t)=>{t&&(f.cssStyle[e]=y.addSize(f.cssStyle[e],t))};b("margin-left",i.default.lengthAttr(e,"distL",u.LengthUsage.Emu)),b("margin-top",i.default.lengthAttr(e,"distT",u.LengthUsage.Emu)),b("margin-right",i.default.lengthAttr(e,"distR",u.LengthUsage.Emu)),b("margin-bottom",i.default.lengthAttr(e,"distB",u.LengthUsage.Emu));let k=null,x=null,T=null,P=i.default.boolAttr(e,"simplePos",!1),v=i.default.boolAttr(e,"behindDoc",!1),w=i.default.intAttr(e,"relativeHeight",null);null!=w&&(f.cssStyle["z-index"]=`${Math.max(1,Math.round(w/1e3))}`),v&&(f.cssStyle["z-index"]="0");let S={relative:"page",align:"left",offset:"0"},C={relative:"page",align:"top",offset:"0"},E=!1,N=!1,M=!1;for(var A of i.default.elements(e))switch(A.localName){case"simplePos":P&&(S.offset=i.default.lengthAttr(A,"x",u.LengthUsage.Emu),C.offset=i.default.lengthAttr(A,"y",u.LengthUsage.Emu),N=null!=S.offset,M=null!=C.offset);break;case"extent":f.cssStyle.width=i.default.lengthAttr(A,"cx",u.LengthUsage.Emu),f.cssStyle.height=i.default.lengthAttr(A,"cy",u.LengthUsage.Emu);break;case"effectExtent":b("margin-left",i.default.lengthAttr(A,"l",u.LengthUsage.Emu)),b("margin-top",i.default.lengthAttr(A,"t",u.LengthUsage.Emu)),b("margin-right",i.default.lengthAttr(A,"r",u.LengthUsage.Emu)),b("margin-bottom",i.default.lengthAttr(A,"b",u.LengthUsage.Emu));break;case"docPr":f.props.title=i.default.attr(A,"title")??i.default.attr(A,"name"),f.props.alt=i.default.attr(A,"descr")??f.props.title;break;case"positionH":case"positionV":if(!P){let e="positionH"==A.localName,t=e?S:C;var D=i.default.element(A,"align"),L=i.default.element(A,"posOffset");t.relative=i.default.attr(A,"relativeFrom")??t.relative,D&&(t.align=D.textContent,e&&(E=!0)),L&&(t.offset=(0,u.convertLength)(L.textContent,u.LengthUsage.Emu),e?N=null!=t.offset:M=null!=t.offset)}break;case"wrapTopAndBottom":k="wrapTopAndBottom";break;case"wrapNone":k="wrapNone";break;case"wrapSquare":k="wrapSquare",x=i.default.attr(A,"wrapText");break;case"wrapTight":k="wrapTight",x=i.default.attr(A,"wrapText"),T=this.parseWrapPolygon(A);break;case"wrapThrough":k="wrapThrough",x=i.default.attr(A,"wrapText"),T=this.parseWrapPolygon(A);break;case"graphic":var $=this.parseGraphic(A);$&&($.type==n.DomType.Image?((t=$).alt??(t.alt=f.props.alt),(r=$).title??(r.title=f.props.title)):$.type==n.DomType.Shape?((a=$).alt??(a.alt=f.props.alt),(s=$).title??(s.title=f.props.title)):$.type==n.DomType.Chart?((o=$).alt??(o.alt=f.props.alt),(l=$).title??(l.title=f.props.title)):$.type==n.DomType.SmartArt?((c=$).alt??(c.alt=f.props.alt),(d=$).title??(d.title=f.props.title)):$.type==n.DomType.Ink&&((h=$).alt??(h.alt=f.props.alt),(p=$).title??(p.title=f.props.title)),f.children.push($))}f.props.anchorPosition={horizontal:{...S},vertical:{...C},wrapType:k,layoutInCell:i.default.boolAttr(e,"layoutInCell",!0),simplePos:P};const R=()=>{switch(S.align){case"center":f.cssStyle["margin-left"]="auto",f.cssStyle["margin-right"]="auto";break;case"right":f.cssStyle["margin-left"]="auto"}};return"wrapTopAndBottom"==k?(f.cssStyle.display="block",f.cssStyle.clear="both",E?R():N&&S.offset&&(f.cssStyle["margin-inline-start"]=y.addSize(f.cssStyle["margin-inline-start"],S.offset)),M&&C.offset&&(f.cssStyle["margin-top"]=y.addSize(f.cssStyle["margin-top"],C.offset))):"wrapNone"==k?(f.cssStyle.display="block",f.cssStyle.position=g?"absolute":"relative",S.offset&&(f.cssStyle.left=S.offset),C.offset&&(f.cssStyle.top=C.offset)):"wrapSquare"==k||"wrapTight"==k||"wrapThrough"==k?(T&&(f.cssStyle["shape-outside"]=T,(m=f.cssStyle)["clip-path"]??(m["clip-path"]=T)),"left"==x?f.cssStyle.float="right":"right"==x?f.cssStyle.float="left":"left"==S.align||"right"==S.align?f.cssStyle.float=S.align:(f.cssStyle.display="block",R())):!g||"left"!=S.align&&"right"!=S.align?f.cssStyle["vertical-align"]="text-bottom":f.cssStyle.float=S.align,f}parseWrapPolygon(e){const t=i.default.element(e,"wrapPolygon");if(!t)return null;const r=[],a=e=>{const t=i.default.lengthAttr(e,"x",u.LengthUsage.Emu),a=i.default.lengthAttr(e,"y",u.LengthUsage.Emu);t&&a&&r.push(`${t} ${a}`)};for(const e of i.default.elements(t))"start"!=e.localName&&"lineTo"!=e.localName||a(e);return r.length>=3?`polygon(${r.join(", ")})`:null}parseGraphic(e){var t=i.default.element(e,"graphicData");if(!t)return null;for(let e of i.default.elements(t))switch(e.localName){case"pic":return this.parsePicture(e);case"wpc":case"wgp":case"grpSp":return this.parseDrawingContainer(e);case"wsp":case"sp":case"cxnSp":return this.parseWordprocessingShape(e);case"chart":return this.parseChartReference(e);case"relIds":case"diagram":return this.parseSmartArtReference(e);case"contentPart":case"ink":return this.parseInkReference(e)}const r=this.findDescendant(t,"contentPart");return r?this.parseInkReference(r):null}parseDrawingContainer(e){const t={type:n.DomType.Shape,children:[],cssStyle:{display:"inline-block",position:"relative",width:"100%",height:"100%",overflow:"visible","box-sizing":"border-box"},props:{dmlContainer:!0}},r=this.parseDmlGroupTransform(e);for(const a of i.default.elements(e))switch(a.localName){case"wsp":case"sp":case"cxnSp":const e=this.parseDmlPositionedShape(a,r);e&&t.children.push(e);break;case"grpSp":case"wgp":const n=this.parseDrawingContainer(a);n&&t.children.push(n)}return t}parseDmlGroupTransform(e){const t=i.default.element(e,"grpSpPr"),r=t?i.default.element(t,"xfrm"):i.default.element(e,"xfrm"),a=r?i.default.element(r,"off"):null,n=r?i.default.element(r,"ext"):null,s=r?i.default.element(r,"chOff"):null,o=r?i.default.element(r,"chExt"):null,l=n?i.default.floatAttr(n,"cx",null):null,c=n?i.default.floatAttr(n,"cy",null):null,u=o?i.default.floatAttr(o,"cx",null):null,d=o?i.default.floatAttr(o,"cy",null):null;return{offsetX:s?i.default.floatAttr(s,"x",0):0,offsetY:s?i.default.floatAttr(s,"y",0):0,left:a?i.default.floatAttr(a,"x",0):0,top:a?i.default.floatAttr(a,"y",0):0,scaleX:l&&u?l/u:1,scaleY:c&&d?c/d:1}}parseDmlPositionedShape(e,t){const r=i.default.element(e,"spPr");if(!r)return null;const a=this.parseDmlShapeBounds(r,t),s=[];let o=null,l=!1;for(const t of i.default.elements(e))switch(t.localName){case"txbx":case"textBox":l=!0;for(const e of i.default.elements(t,"txbxContent"))s.push(...this.parseBodyElements(e));break;case"bodyPr":o=t}o??(o=i.default.element(e,"bodyPr"));const c={position:"absolute",left:this.pt(a.left),top:this.pt(a.top),width:this.pt(a.width),height:this.pt(a.height),"box-sizing":"border-box",overflow:"hidden"},u=i.default.element(e,"cNvPr"),d=i.default.element(r,"custGeom"),h=i.default.element(r,"prstGeom"),p=this.parseDmlFillStyle(r),m=this.parseDmlLineStyle(i.default.element(r,"ln"));if(d){const e=this.parseDmlCustomGeometry(d);return{type:n.DomType.Shape,children:[],cssStyle:{...c,overflow:"visible"},props:{dmlSvg:!0,viewBox:e?.viewBox??"0 0 1 1",pathD:e?.d??"",fill:p.fill??"none",stroke:m.stroke??"none",strokeWidth:m.strokeWidth??"0",strokeDasharray:m.strokeDasharray},title:u?i.default.attr(u,"title")??i.default.attr(u,"name"):null,alt:u?i.default.attr(u,"descr"):null}}p.backgroundColor&&(c["background-color"]=p.backgroundColor),p.backgroundImage&&(c["background-image"]=p.backgroundImage),m.stroke&&"none"!=m.stroke?c.border=`${m.strokeWidth||"0.75pt"} ${m.borderType||"solid"} ${m.stroke}`:c.border="none";const f=l?this.parseDmlTextBoxProperties(o):null;return{type:n.DomType.Shape,children:s,cssStyle:c,props:{dmlShape:!0,presetGeometry:h?i.default.attr(h,"prst"):null,...f},title:u?i.default.attr(u,"title")??i.default.attr(u,"name"):null,alt:u?i.default.attr(u,"descr"):null}}parseDmlShapeBounds(e,t){const r=i.default.element(e,"xfrm"),a=r?i.default.element(r,"off"):null,n=r?i.default.element(r,"ext"):null,s=t?.scaleX??1,o=t?.scaleY??1,l=t?.offsetX??0,c=t?.offsetY??0,u=t?.left??0,d=t?.top??0,h=a?i.default.floatAttr(a,"x",0):0,p=a?i.default.floatAttr(a,"y",0):0,m=n?i.default.floatAttr(n,"cx",0):0,f=n?i.default.floatAttr(n,"cy",0):0;return{left:this.emuToPt(u+(h-l)*s),top:this.emuToPt(d+(p-c)*o),width:Math.max(0,this.emuToPt(m*s)),height:Math.max(0,this.emuToPt(f*o))}}parseDmlFillStyle(e){if(i.default.element(e,"noFill"))return{fill:"none",backgroundColor:"transparent"};const t=i.default.element(e,"solidFill");if(t){const e=this.parseDmlColor(t)??"transparent";return{fill:e,backgroundColor:e}}const r=i.default.element(e,"pattFill");if(r){const e=this.parseDmlColor(i.default.element(r,"fgClr"))??"currentColor",t=this.parseDmlColor(i.default.element(r,"bgClr"))??"transparent",a=i.default.attr(r,"prst");return{fill:t,backgroundColor:t,backgroundImage:`repeating-linear-gradient(${a&&a.toLowerCase().includes("horz")?"0deg":"90deg"}, ${e} 0, ${e} 0.75pt, ${t} 0.75pt, ${t} 3pt)`}}return{fill:"none",backgroundColor:"transparent"}}parseDmlLineStyle(e){if(!e||i.default.element(e,"noFill"))return{stroke:"none",strokeWidth:"0",borderType:"none"};const t=this.parseDmlColor(i.default.element(e,"solidFill"))??"black",r=i.default.attr(e,"w")?this.pt(this.emuToPt(i.default.floatAttr(e,"w",0))):"0.75pt",a=i.default.elementAttr(e,"prstDash","val");let n=null,s="solid";return a&&"solid"!=a&&(s="dashed",n="dot"==a?"1 2":"4 3"),{stroke:t,strokeWidth:r,borderType:s,strokeDasharray:n}}parseDmlCustomGeometry(e){const t=i.default.element(e,"pathLst"),r=t?i.default.elements(t,"path"):[];let a="",n=1,s=1;for(const e of r){const t=i.default.floatAttr(e,"w",n),r=i.default.floatAttr(e,"h",s);n=Math.max(n,t||1),s=Math.max(s,r||1),a+=this.parseDmlPathData(e,t||1,r||1)}return{d:a.trim(),viewBox:`0 0 ${n} ${s}`}}parseDmlPathData(e,t,r){const a=[],n=e=>{const a=i.default.element(e,"pt");return a?`${this.dmlCoord(i.default.attr(a,"x"),t,r)} ${this.dmlCoord(i.default.attr(a,"y"),t,r)}`:"0 0"};for(const s of i.default.elements(e))switch(s.localName){case"moveTo":a.push(`M ${n(s)}`);break;case"lnTo":a.push(`L ${n(s)}`);break;case"cubicBezTo":const e=i.default.elements(s,"pt").map(e=>`${this.dmlCoord(i.default.attr(e,"x"),t,r)} ${this.dmlCoord(i.default.attr(e,"y"),t,r)}`);3==e.length&&a.push(`C ${e.join(" ")}`);break;case"quadBezTo":const o=i.default.elements(s,"pt").map(e=>`${this.dmlCoord(i.default.attr(e,"x"),t,r)} ${this.dmlCoord(i.default.attr(e,"y"),t,r)}`);2==o.length&&a.push(`Q ${o.join(" ")}`);break;case"close":a.push("Z")}return a.join(" ")+" "}dmlCoord(e,t,r){if("w"==e||"r"==e)return t;if("h"==e||"b"==e)return r;if("l"==e||"t"==e)return 0;const a=parseFloat(e);return Number.isFinite(a)?a:0}dmlVerticalAlign(e){switch(e?i.default.attr(e,"anchor"):null){case"ctr":return"center";case"b":return"flex-end";default:return"flex-start"}}applyDmlTextInsets(e,t){if(!e)return;const r={lIns:"padding-left",tIns:"padding-top",rIns:"padding-right",bIns:"padding-bottom"};for(const[a,n]of Object.entries(r)){const r=i.default.attr(e,a);null!=r&&(t[n]=this.pt(this.emuToPt(parseFloat(r))))}}parseDmlTextBoxProperties(e){const t={};return this.applyDmlTextInsets(e,t),{dmlTextBox:!0,textInsets:t,textVerticalAlign:this.dmlVerticalAlign(e)}}emuToPt(e){return(Number.isFinite(e)?e:0)/12700}pt(e){return Math.round(100*e)/100+"pt"}parseChartReference(e){return{type:n.DomType.Chart,id:i.default.attr(e,"id"),cssStyle:{width:"100%",height:"100%"}}}parseSmartArtReference(e){const t="relIds"==e.localName?e:this.findDescendant(e,"relIds");return{type:n.DomType.SmartArt,dataId:t?i.default.attr(t,"dm"):i.default.attr(e,"dm"),layoutId:t?i.default.attr(t,"lo"):i.default.attr(e,"lo"),styleId:t?i.default.attr(t,"qs"):i.default.attr(e,"qs"),colorId:t?i.default.attr(t,"cs"):i.default.attr(e,"cs"),cssStyle:{width:"100%",height:"100%"}}}parseInkReference(e){return{type:n.DomType.Ink,id:i.default.attr(e,"id"),cssStyle:{width:"100%",height:"100%"}}}parseGraphicPlaceholder(e){return{type:n.DomType.Shape,children:[{type:n.DomType.Text,text:`[${e}]`}],cssStyle:{display:"inline-flex","align-items":"center","justify-content":"center",border:"1px solid #999","background-color":"#f8f8f8",color:"#555","min-width":"2in","min-height":"1in"}}}parseWordprocessingShape(e){const t={type:n.DomType.Shape,children:[],cssStyle:{display:"inline-block",position:"relative","box-sizing":"border-box",overflow:"hidden"}},r=this.findDescendant(e,"cNvPr");let a=null,s=!1;r&&(t.title=i.default.attr(r,"title")??i.default.attr(r,"name"),t.alt=i.default.attr(r,"descr")??t.title);for(const r of i.default.elements(e))switch(r.localName){case"spPr":this.parseDmlShapeProperties(r,t.cssStyle);break;case"txbx":case"textBox":s=!0;for(const e of i.default.elements(r,"txbxContent"))t.children.push(...this.parseBodyElements(e));break;case"bodyPr":a=r}return s&&(t.props={...t.props??{},...this.parseDmlTextBoxProperties(a)}),t}parseDmlShapeProperties(e,t){const r=i.default.element(e,"xfrm");if(r)for(const e of i.default.elements(r))switch(e.localName){case"ext":t.width=i.default.lengthAttr(e,"cx",u.LengthUsage.Emu),t.height=i.default.lengthAttr(e,"cy",u.LengthUsage.Emu);break;case"off":t.left=i.default.lengthAttr(e,"x",u.LengthUsage.Emu),t.top=i.default.lengthAttr(e,"y",u.LengthUsage.Emu)}const a=i.default.element(e,"solidFill"),n=i.default.element(e,"noFill"),s=i.default.element(e,"ln");if(a?t["background-color"]=this.parseDmlColor(a)??t["background-color"]:n&&(t["background-color"]="transparent"),s){const e=this.parseDmlColor(i.default.element(s,"solidFill"))??"black",r=i.default.lengthAttr(s,"w",u.LengthUsage.Emu)??"1px",a=i.default.elementAttr(s,"prstDash","val"),n=a&&"solid"!=a?"dashed":"solid";t.border=`${r} ${n} ${e}`}}parseDmlColor(e){if(!e)return null;const t=i.default.element(e,"srgbClr"),r=i.default.element(e,"schemeClr"),a=i.default.element(e,"prstClr"),n=i.default.element(e,"sysClr");if(t)return this.applyDmlColorTransforms(t,`#${i.default.attr(t,"val")}`);if(r){const e=this.resolveDmlSchemeColor(i.default.attr(r,"val")),t=this.dmlSchemeColorFallback(e);return this.applyDmlColorTransforms(r,`var(--docx-${e}-color${t?`, ${t}`:""})`)}return n?this.applyDmlColorTransforms(n,`#${i.default.attr(n,"lastClr")??i.default.attr(n,"val")}`):a?this.applyDmlColorTransforms(a,i.default.attr(a,"val")):null}resolveDmlSchemeColor(e){switch(e){case"bg1":return"lt1";case"tx1":return"dk1";case"bg2":return"lt2";case"tx2":return"dk2";default:return e}}dmlSchemeColorFallback(e){switch(e){case"dk1":return"#000000";case"lt1":return"#FFFFFF";case"dk2":return"#44546A";case"lt2":return"#E7E6E6";case"accent1":return"#4472C4";case"accent2":return"#ED7D31";case"accent3":return"#A5A5A5";case"accent4":return"#FFC000";case"accent5":return"#5B9BD5";case"accent6":return"#70AD47";case"hlink":return"#0563C1";case"folHlink":return"#954F72";default:return null}}applyDmlColorTransforms(e,t){const r=i.default.elementAttr(e,"lumMod","val"),a=i.default.elementAttr(e,"lumOff","val");if(null!=r){const e=Math.max(0,Math.min(100,parseFloat(r)/1e3));Number.isFinite(e)&&e<100&&(t=`color-mix(in srgb, ${t} ${e}%, black)`)}if(null!=a){const e=Math.max(0,Math.min(100,parseFloat(a)/1e3));Number.isFinite(e)&&e>0&&(t=`color-mix(in srgb, ${t} ${100-e}%, white)`)}return t}findDescendant(e,t){for(const r of i.default.elements(e)){if(r.localName==t)return r;const e=this.findDescendant(r,t);if(e)return e}return null}parsePicture(e){var t={type:n.DomType.Image,src:"",cssStyle:{}},r=i.default.element(e,"blipFill"),a=r?i.default.element(r,"blip"):null,s=r?i.default.element(r,"srcRect"):null;t.src=a?i.default.attr(a,"embed")??i.default.attr(a,"link"):"";const o=this.findDescendant(e,"cNvPr");o&&(t.title=i.default.attr(o,"title")??i.default.attr(o,"name"),t.alt=i.default.attr(o,"descr")??t.title),s&&(t.srcRect=[i.default.intAttr(s,"l",0)/1e5,i.default.intAttr(s,"t",0)/1e5,i.default.intAttr(s,"r",0)/1e5,i.default.intAttr(s,"b",0)/1e5]);var l=i.default.element(e,"spPr"),c=l?i.default.element(l,"xfrm"):null,d=[];if(t.cssStyle.display="block",t.cssStyle.position="relative",t.cssStyle["object-fit"]="contain",c)for(var h of(t.rotation=i.default.intAttr(c,"rot",0)/6e4,i.default.boolAttr(c,"flipH",!1)&&d.push("scaleX(-1)"),i.default.boolAttr(c,"flipV",!1)&&d.push("scaleY(-1)"),i.default.elements(c)))switch(h.localName){case"ext":t.cssStyle.width=i.default.lengthAttr(h,"cx",u.LengthUsage.Emu),t.cssStyle.height=i.default.lengthAttr(h,"cy",u.LengthUsage.Emu);break;case"off":t.cssStyle.left=i.default.lengthAttr(h,"x",u.LengthUsage.Emu),t.cssStyle.top=i.default.lengthAttr(h,"y",u.LengthUsage.Emu)}return d.length>0&&(t.cssStyle.transform=d.join(" ")),t.cssStyle.width||(t.cssStyle.width="100%"),t.cssStyle.height||(t.cssStyle.height="100%"),t}parseTable(e){var t={type:n.DomType.Table,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"tr":t.children.push(this.parseTableRow(r));break;case"tblGrid":t.columns=this.parseTableColumns(r);break;case"tblPr":this.parseTableProperties(r,t)}return t}parseTableColumns(e){var t=[];for(const r of i.default.elements(e))"gridCol"===r.localName&&t.push({width:i.default.lengthAttr(r,"w")});return t}parseTableProperties(e,t){t.cssStyle={},t.cellStyle={};let r=null;switch(this.parseDefaultProperties(e,t.cssStyle,t.cellStyle,e=>{switch(e.localName){case"tblStyle":t.styleName=i.default.attr(e,"val");break;case"tblLook":t.className=y.classNameOftblLook(e);break;case"tblInd":r=this.parseTableIndentation(e);break;case"tblpPr":this.parseTablePosition(e,t);break;case"tblStyleColBandSize":t.colBandSize=i.default.intAttr(e,"val");break;case"tblStyleRowBandSize":t.rowBandSize=i.default.intAttr(e,"val");break;case"hidden":t.cssStyle.display="none";break;default:return!1}return!0}),t.cssStyle["text-align"]){case"center":delete t.cssStyle["text-align"],t.cssStyle["margin-left"]="auto",t.cssStyle["margin-right"]="auto";break;case"right":delete t.cssStyle["text-align"],t.cssStyle["margin-left"]="auto";break;default:delete t.cssStyle["text-align"],r&&(t.cssStyle["margin-inline-start"]=y.addSize(t.cssStyle["margin-inline-start"],r))}}parseTableIndentation(e){const t=i.default.attr(e,"type");return"pct"==t||"auto"==t?null:i.default.lengthAttr(e,"w",u.LengthUsage.SignedDxa)}parseTablePosition(e,t){var r=i.default.lengthAttr(e,"topFromText"),a=i.default.lengthAttr(e,"bottomFromText"),n=i.default.lengthAttr(e,"rightFromText"),s=i.default.lengthAttr(e,"leftFromText");t.cssStyle.float="left",t.cssStyle["margin-bottom"]=y.addSize(t.cssStyle["margin-bottom"],a),t.cssStyle["margin-left"]=y.addSize(t.cssStyle["margin-left"],s),t.cssStyle["margin-right"]=y.addSize(t.cssStyle["margin-right"],n),t.cssStyle["margin-top"]=y.addSize(t.cssStyle["margin-top"],r)}parseTableRow(e){var t={type:n.DomType.Row,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"tc":t.children.push(this.parseTableCell(r));break;case"trPr":case"tblPrEx":this.parseTableRowProperties(r,t)}return t}parseTableRowProperties(e,t){const r={};t.cssStyle=this.parseDefaultProperties(e,r,null,e=>{switch(e.localName){case"cnfStyle":t.className=y.classNameOfCnfStyle(e);break;case"tblHeader":t.isHeader=i.default.boolAttr(e,"val");break;case"gridBefore":t.gridBefore=i.default.intAttr(e,"val");break;case"gridAfter":t.gridAfter=i.default.intAttr(e,"val");break;case"cantSplit":i.default.boolAttr(e,"val",!0)&&(r["break-inside"]="avoid");break;default:return!1}return!0})}parseTableCell(e){var t={type:n.DomType.Cell,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"tbl":t.children.push(this.parseTable(r));break;case"p":t.children.push(this.parseParagraph(r));break;case"tcPr":this.parseTableCellProperties(r,t)}return t}parseTableCellProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,e=>{switch(e.localName){case"gridSpan":t.span=i.default.intAttr(e,"val",null);break;case"vMerge":t.verticalMerge=i.default.attr(e,"val")??"continue";break;case"cnfStyle":t.className=y.classNameOfCnfStyle(e);break;default:return!1}return!0}),this.parseTableCellVerticalText(e,t)}parseTableCellVerticalText(e,t){const r={btLr:{writingMode:"vertical-rl",transform:"rotate(180deg)"},lrTb:{writingMode:"vertical-lr",transform:"none"},tbRl:{writingMode:"vertical-rl",transform:"none"}};for(const a of i.default.elements(e))if("textDirection"===a.localName){const e=r[i.default.attr(a,"val")]||{writingMode:"horizontal-tb"};t.cssStyle["writing-mode"]=e.writingMode,t.cssStyle.transform=e.transform}}parseDefaultProperties(e,t=null,a=null,n=null){t=t||{};for(const s of i.default.elements(e))if(!n?.(s))switch(s.localName){case"jc":t["text-align"]=y.valueOfJc(s);break;case"textAlignment":t["vertical-align"]=y.valueOfTextAlignment(s);break;case"color":t.color=b.colorAttr(s,"val",null,r.autos.color);break;case"sz":t["font-size"]=t["min-height"]=i.default.lengthAttr(s,"val",u.LengthUsage.FontSize);break;case"szCs":t["font-size"]??(t["font-size"]=i.default.lengthAttr(s,"val",u.LengthUsage.FontSize)),t["min-height"]??(t["min-height"]=t["font-size"]);break;case"shd":t["background-color"]=b.colorAttr(s,"fill",null,r.autos.shd);break;case"highlight":t["background-color"]=b.colorAttr(s,"val",null,r.autos.highlight);break;case"vertAlign":t["vertical-align"]=y.valueOfVertAlign(s);break;case"position":t["vertical-align"]=i.default.lengthAttr(s,"val",u.LengthUsage.SignedHalfPoint);break;case"scale":t["font-stretch"]=`${i.default.intAttr(s,"val",100)}%`;break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":t.width=y.valueOfSize(s,"w");break;case"trHeight":this.parseTrHeight(s,t);break;case"strike":t["text-decoration"]=i.default.boolAttr(s,"val",!0)?"line-through":"none";break;case"dstrike":i.default.boolAttr(s,"val",!0)?(t["text-decoration-line"]="line-through",t["text-decoration-style"]="double"):t["text-decoration"]="none";break;case"b":t["font-weight"]=i.default.boolAttr(s,"val",!0)?"bold":"normal";break;case"i":t["font-style"]=i.default.boolAttr(s,"val",!0)?"italic":"normal";break;case"bCs":t["--docx-bidi-font-weight"]=i.default.boolAttr(s,"val",!0)?"bold":"normal","rtl"==t.direction&&(t["font-weight"]=t["--docx-bidi-font-weight"]);break;case"iCs":t["--docx-bidi-font-style"]=i.default.boolAttr(s,"val",!0)?"italic":"normal","rtl"==t.direction&&(t["font-style"]=t["--docx-bidi-font-style"]);break;case"caps":t["text-transform"]=i.default.boolAttr(s,"val",!0)?"uppercase":"none";break;case"smallCaps":t["font-variant"]=i.default.boolAttr(s,"val",!0)?"small-caps":"none";break;case"rtl":i.default.boolAttr(s,"val",!0)&&(t.direction="rtl",t["unicode-bidi"]="embed",t["--docx-bidi-font-weight"]&&(t["font-weight"]=t["--docx-bidi-font-weight"]),t["--docx-bidi-font-style"]&&(t["font-style"]=t["--docx-bidi-font-style"]));break;case"outline":i.default.boolAttr(s,"val",!0)&&(t["-webkit-text-stroke"]="0.5px currentColor");break;case"shadow":i.default.boolAttr(s,"val",!0)&&(t["text-shadow"]="1px 1px 0 currentColor");break;case"emboss":i.default.boolAttr(s,"val",!0)&&(t["text-shadow"]="-1px -1px 0 rgba(255,255,255,.75), 1px 1px 0 rgba(0,0,0,.35)");break;case"imprint":i.default.boolAttr(s,"val",!0)&&(t["text-shadow"]="1px 1px 0 rgba(255,255,255,.75), -1px -1px 0 rgba(0,0,0,.35)");break;case"em":t["text-emphasis-style"]=y.valueOfEmphasisMark(s);break;case"u":this.parseUnderline(s,t);break;case"ind":case"tblInd":this.parseIndentation(s,t);break;case"rFonts":this.parseFont(s,t);break;case"tblBorders":this.parseBorderProperties(s,a||t);break;case"tblCellSpacing":t["border-spacing"]=y.valueOfMargin(s),t["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(s,t);break;case"bdr":t.border=y.valueOfBorder(s);break;case"tcBorders":this.parseBorderProperties(s,t);break;case"vanish":i.default.boolAttr(s,"val",!0)&&(t.display="none");break;case"kern":t["font-kerning"]=i.default.intAttr(s,"val",0)>0?"normal":"none";break;case"noWrap":t["white-space"]=i.default.boolAttr(s,"val",!0)?"nowrap":"normal";break;case"snapToGrid":t["--docx-snap-to-grid"]=i.default.boolAttr(s,"val",!0)?"1":"0";break;case"fitText":this.parseFitText(s,t);break;case"eastAsianLayout":this.parseEastAsianLayout(s,t);break;case"tblCellMar":case"tcMar":this.parseMarginProperties(s,a||t);break;case"tblLayout":t["table-layout"]=y.valueOfTblLayout(s);break;case"vAlign":t["vertical-align"]=y.valueOfTextAlignment(s);break;case"spacing":"pPr"==e.localName?this.parseSpacing(s,t):"rPr"==e.localName&&(t["letter-spacing"]=i.default.lengthAttr(s,"val",u.LengthUsage.SignedDxa));break;case"wordWrap":i.default.boolAttr(s,"val")&&(t["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":t.hyphens=i.default.boolAttr(s,"val",!0)?"none":"auto";break;case"lang":t.$lang=i.default.attr(s,"val");break;case"rtl":case"bidi":i.default.boolAttr(s,"val",!0)&&(t.direction="rtl");break;case"pageBreakBefore":i.default.boolAttr(s,"val",!0)&&(t["break-before"]="page");break;case"keepLines":i.default.boolAttr(s,"val",!0)&&(t["break-inside"]="avoid");break;case"keepNext":i.default.boolAttr(s,"val",!0)&&(t["break-after"]="avoid");break;case"widowControl":i.default.boolAttr(s,"val",!0)&&(t.orphans="2",t.widows="2");break;case"webHidden":this.options.hideWebHiddenContent&&i.default.boolAttr(s,"val",!0)&&(t.display="none");break;case"specVanish":i.default.boolAttr(s,"val",!0)&&(t.display="none");break;case"tabs":case"outlineLvl":case"contextualSpacing":case"tblStyleColBandSize":case"tblStyleRowBandSize":case"suppressLineNumbers":case"noProof":break;default:this.options.debug&&console.warn(`DOCX: Unknown document element: ${e.localName}.${s.localName}`)}return t}parseFitText(e,t){const r=i.default.lengthAttr(e,"val");r&&(t.display="inline-block",t.width=r,t["text-align"]="justify",t["text-align-last"]="justify")}parseEastAsianLayout(e,t){i.default.boolAttr(e,"combine",!1)&&(t["text-combine-upright"]="all"),i.default.boolAttr(e,"vert",!1)&&(t["writing-mode"]="vertical-rl"),i.default.boolAttr(e,"vertCompress",!1)&&(t["font-stretch"]="condensed")}parseUnderline(e,t){var r=i.default.attr(e,"val");if(null!=r){switch(r){case"dash":case"dashDotDotHeavy":case"dashDotHeavy":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dotDotDash":t["text-decoration"]="underline dashed";break;case"dotted":case"dottedHeavy":t["text-decoration"]="underline dotted";break;case"double":t["text-decoration"]="underline double";break;case"single":case"thick":case"words":t["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":t["text-decoration"]="underline wavy";break;case"none":t["text-decoration"]="none"}var a=b.colorAttr(e,"color");a&&(t["text-decoration-color"]=a)}}parseFont(e,t){var r=i.default.attr(e,"ascii"),a=i.default.attr(e,"hAnsi"),n=i.default.attr(e,"eastAsia"),s=i.default.attr(e,"cs"),o=[r,a,y.themeValue(e,"asciiTheme"),y.themeValue(e,"hAnsiTheme"),n,y.themeValue(e,"eastAsiaTheme"),s,y.themeValue(e,"cstheme")??y.themeValue(e,"csTheme")].filter(e=>e).map(e=>(0,p.encloseFontFamily)(e));if(o.length>0){const e=(t["font-family"]??"").split(",").map(e=>e.trim()).filter(e=>e);t["font-family"]=[...new Set([...e,...o])].join(", ")}}parseIndentation(e,t){var r=i.default.lengthAttr(e,"firstLine"),a=i.default.lengthAttr(e,"hanging"),n=i.default.lengthAttr(e,"left"),s=i.default.lengthAttr(e,"start"),o=i.default.lengthAttr(e,"right"),l=i.default.lengthAttr(e,"end");r&&(t["text-indent"]=r,t["--docx-text-indent"]=r),a&&(t["text-indent"]=`-${a}`,t["--docx-text-indent"]=`-${a}`,t["--docx-hanging-indent"]=a),(n||s)&&(t["margin-inline-start"]=n||s,t["--docx-margin-inline-start"]=n||s),(o||l)&&(t["margin-inline-end"]=o||l,t["--docx-margin-inline-end"]=o||l)}parseSpacing(e,t){var r=i.default.lengthAttr(e,"before"),a=i.default.lengthAttr(e,"after"),n=i.default.intAttr(e,"beforeLines",null),s=i.default.intAttr(e,"afterLines",null),o=i.default.boolAttr(e,"beforeAutospacing",!1),l=i.default.boolAttr(e,"afterAutospacing",!1),c=i.default.intAttr(e,"line",null),u=i.default.attr(e,"lineRule");if(o?t["margin-top"]="auto":null!=n?t["margin-top"]=`${(n/100).toFixed(2)}em`:r&&(t["margin-top"]=r),l?t["margin-bottom"]="auto":null!=s?t["margin-bottom"]=`${(s/100).toFixed(2)}em`:a&&(t["margin-bottom"]=a),null!==c)switch(u??"auto"){case"auto":default:t["line-height"]=`${(c/240).toFixed(2)}`;break;case"atLeast":t["line-height"]=`max(1em, ${(c/20).toFixed(2)}pt)`,t["min-height"]=`${(c/20).toFixed(2)}pt`;break;case"exact":case"exactly":t["line-height"]=t["min-height"]=`${(c/20).toFixed(2)}pt`}}parseMarginProperties(e,t){for(const r of i.default.elements(e))switch(r.localName){case"left":case"start":t["padding-left"]=y.valueOfMargin(r);break;case"right":case"end":t["padding-right"]=y.valueOfMargin(r);break;case"top":t["padding-top"]=y.valueOfMargin(r);break;case"bottom":t["padding-bottom"]=y.valueOfMargin(r)}}parseTrHeight(e,t){i.default.attr(e,"hRule"),t.height=i.default.lengthAttr(e,"val")}parseBorderProperties(e,t){for(const r of i.default.elements(e)){const e=y.valueOfBorder(r);switch(r.localName){case"start":case"left":t["border-left"]=e;break;case"end":case"right":t["border-right"]=e;break;case"top":t["border-top"]=e;break;case"bottom":t["border-bottom"]=e;break;case"insideH":t["border-top"]??(t["border-top"]=e),t["border-bottom"]??(t["border-bottom"]=e);break;case"insideV":t["border-left"]??(t["border-left"]=e),t["border-right"]??(t["border-right"]=e)}}}};const g=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"];class b{static colorAttr(e,t,r=null,a="black"){var n=i.default.attr(e,t);if(n)return"auto"==n?a:g.includes(n)?n:`#${n}`;var s=i.default.attr(e,"themeColor");return s?`var(--docx-${s}-color)`:r}}class y{static themeValue(e,t){var r=i.default.attr(e,t);return r?`var(--docx-${r}-font)`:null}static valueOfSize(e,t){var r=u.LengthUsage.Dxa;switch(i.default.attr(e,"type")){case"dxa":break;case"pct":r=u.LengthUsage.Percent;break;case"auto":return"auto"}return i.default.lengthAttr(e,t,r)}static valueOfMargin(e){return i.default.lengthAttr(e,"w")}static valueOfBorder(e){var t=y.parseBorderType(i.default.attr(e,"val"));if("none"==t)return"none";var a=b.colorAttr(e,"color",r.autos.borderColor,r.autos.borderColor);return`${i.default.lengthAttr(e,"sz",u.LengthUsage.Border)??"1pt"} ${t} ${"auto"==a?r.autos.borderColor:a}`}static parseBorderType(e){switch(e){case"single":case"dashDotStroked":case"thick":case"thickThinLargeGap":case"thickThinMediumGap":case"thickThinSmallGap":case"thinThickLargeGap":case"thinThickMediumGap":case"thinThickSmallGap":case"thinThickThinLargeGap":case"thinThickThinMediumGap":case"thinThickThinSmallGap":case"threeDEmboss":case"threeDEngrave":case"wave":return"solid";case"dashed":case"dashSmallGap":return"dashed";case"dotDash":case"dotDotDash":case"dotted":return"dotted";case"double":case"doubleWave":case"triple":return"double";case"inset":return"inset";case"nil":case"none":return"none";case"outset":return"outset"}return"solid"}static valueOfTblLayout(e){return"fixed"==i.default.attr(e,"val")?"fixed":"auto"}static classNameOfCnfStyle(e){const t=i.default.attr(e,"val");return["first-row","last-row","first-col","last-col","odd-col","even-col","odd-row","even-row","ne-cell","nw-cell","se-cell","sw-cell"].filter((e,r)=>"1"==t[r]).join(" ")}static valueOfJc(e){var t=i.default.attr(e,"val");switch(t){case"start":case"left":return"left";case"center":return"center";case"end":case"right":return"right";case"both":return"justify"}return t}static valueOfVertAlign(e,t=!1){var r=i.default.attr(e,"val");switch(r){case"subscript":return"sub";case"superscript":return t?"sup":"super"}return t?null:r}static valueOfEmphasisMark(e){switch(i.default.attr(e,"val")){case"none":return"none";case"comma":return'"﹐"';case"circle":return"circle";default:return"dot"}}static valueOfTextAlignment(e){var t=i.default.attr(e,"val");switch(t){case"auto":case"baseline":return"baseline";case"top":return"top";case"center":return"middle";case"bottom":return"bottom"}return t}static addSize(e,t){return e&&"0.00pt"!=e&&"0px"!=e?t&&"0.00pt"!=t&&"0px"!=t?`calc(${e} + ${t})`:e:t}static classNameOftblLook(e){const t=i.default.hexAttr(e,"val",0);let r="";return(i.default.boolAttr(e,"firstRow")||32&t)&&(r+=" first-row"),(i.default.boolAttr(e,"lastRow")||64&t)&&(r+=" last-row"),(i.default.boolAttr(e,"firstColumn")||128&t)&&(r+=" first-col"),(i.default.boolAttr(e,"lastColumn")||256&t)&&(r+=" last-col"),(i.default.boolAttr(e,"noHBand")||512&t)&&(r+=" no-hband"),(i.default.boolAttr(e,"noVBand")||1024&t)&&(r+=" no-vband"),r.trim()}}},"./document-props/core-props-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CorePropsPart=void 0;const a=e("../common/part"),n=e("./core-props");class s extends a.Part{parseXml(e){this.props=(0,n.parseCoreProps)(e,this._package.xmlParser)}}r.CorePropsPart=s},"./document-props/core-props":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseCoreProps=function(e,t){const r={};for(let a of t.elements(e))switch(a.localName){case"title":r.title=a.textContent;break;case"description":r.description=a.textContent;break;case"subject":r.subject=a.textContent;break;case"creator":r.creator=a.textContent;break;case"keywords":r.keywords=a.textContent;break;case"language":r.language=a.textContent;break;case"lastModifiedBy":r.lastModifiedBy=a.textContent;break;case"revision":a.textContent&&(r.revision=parseInt(a.textContent))}return r}},"./document-props/custom-props-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CustomPropsPart=void 0;const a=e("../common/part"),n=e("./custom-props");class s extends a.Part{parseXml(e){this.props=(0,n.parseCustomProps)(e,this._package.xmlParser)}}r.CustomPropsPart=s},"./document-props/custom-props":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseCustomProps=function(e,t){return t.elements(e,"property").map(e=>{const r=e.firstChild;return{formatId:t.attr(e,"fmtid"),name:t.attr(e,"name"),type:r.nodeName,value:r.textContent}})}},"./document-props/extended-props-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedPropsPart=void 0;const a=e("../common/part"),n=e("./extended-props");class s extends a.Part{parseXml(e){this.props=(0,n.parseExtendedProps)(e,this._package.xmlParser)}}r.ExtendedPropsPart=s},"./document-props/extended-props":function(e,t,r){"use strict";function a(e){if(void 0!==e)return parseInt(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.parseExtendedProps=function(e,t){const r={};for(let n of t.elements(e))switch(n.localName){case"Template":r.template=n.textContent;break;case"Pages":r.pages=a(n.textContent);break;case"Words":r.words=a(n.textContent);break;case"Characters":r.characters=a(n.textContent);break;case"Application":r.application=n.textContent;break;case"Lines":r.lines=a(n.textContent);break;case"Paragraphs":r.paragraphs=a(n.textContent);break;case"Company":r.company=n.textContent;break;case"AppVersion":r.appVersion=n.textContent}return r}},"./docx-preview-worker":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const a=e("./word-document"),n=e("./document-parser"),s=self;function o(e,t,r={}){s.postMessage({id:e,type:t,...r})}s.onmessage=async e=>{const t=e.data;if(!t||"parse"!==t.type)return;const r=t.id;try{const e={...t.options,useWorker:!1,h:void 0,progress:void 0};o(r,"progress",{message:"Loading package relationships"});const s=await a.WordDocument.load(t.data,new n.DocumentParser(e),e);o(r,"progress",{message:"Serializing parsed document model"}),o(r,"parsed",{snapshot:await s.createSnapshot()})}catch(e){o(r,"error",{error:{message:e?.message??`${e}`,stack:e?.stack}})}}},"./docx-preview":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultOptions=void 0,r.parseAsync=l,r.renderDocument=u,r.renderAsync=async function(e,t,a,n){const s={...r.defaultOptions,...n};(0,i.assertViewerLicense)("docx",s.licenseToken);const o=await l(e,s),c=await u(o,s);a??(a=t),a.innerHTML="",t.innerHTML="";let d=0;for(let e of c)("STYLE"===e.nodeName?a:t).appendChild(e),d++,s.renderYieldEveryMs>0&&d%8==0&&await k();g(t,s.className);let h=null;return s.awaitLayout&&(s.progress?.({phase:"layout",message:"Measuring rendered pages"}),h=await m(t,s),g(t,s.className)),s.progress?.({phase:"done",current:h?.pageCount,total:h?.pageCount,message:"DOCX render complete"}),o},r.parseAsyncInWorker=p,r.awaitRenderedLayout=m,r.collectLayoutSnapshot=f,r.syncNumberingMarkerStyles=g,r.yieldToBrowser=k;const a=e("./word-document"),n=e("./document-parser"),s=e("./html-renderer"),o=e("./html"),i=e("./license-gate");function l(e,t){const a={...r.defaultOptions,...t};return(0,i.assertViewerLicense)("docx",a.licenseToken),function(e){return!(!e.useWorker||!e.workerUrl||"undefined"==typeof Worker)}(a)?p(e,a).catch(t=>{if(!a.workerFallback)throw t;a.debug&&console.warn("docx-preview: worker parsing failed; falling back to main thread",t);const r={...a,useWorker:!1};return c(e,r)}):c(e,a)}function c(e,t){return t.progress?.({phase:"parse",message:"Parsing DOCX on main thread"}),a.WordDocument.load(e,new n.DocumentParser(t),t)}async function u(e,t){const a={...r.defaultOptions,...t};(0,i.assertViewerLicense)("docx",a.licenseToken);const n=new s.HtmlRenderer;return await n.render(e,a)}function d(e){const{h:t,progress:r,licenseToken:a,...n}=e;return{...n,useWorker:!1}}r.defaultOptions={ignoreHeight:!1,ignoreWidth:!1,fixedPageHeight:!0,ignoreFonts:!1,breakPages:!0,strictWordCompatibility:!0,paginationTolerance:2,maxDynamicPaginationPasses:1e3,awaitLayout:!0,useWorker:!0,workerUrl:void 0,workerJsZipUrl:void 0,workerFallback:!0,workerTimeout:12e4,renderPageBatchSize:2,renderYieldEveryMs:16,progress:void 0,preserveComplexFieldResults:!0,updatePageReferences:!1,hideWebHiddenContent:!1,debug:!1,experimental:!1,className:"docx",inWrapper:!0,hideWrapperOnPrint:!1,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!1,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1,renderComments:!1,renderAltChunks:!0,h:o.h};let h=0;function p(e,t){const n={...r.defaultOptions,...t};return(0,i.assertViewerLicense)("docx",n.licenseToken),n.workerUrl&&"undefined"!=typeof Worker?(n.progress?.({phase:"worker",message:"Starting DOCX parse worker"}),new Promise((t,r)=>{const s=++h,o=new Worker(n.workerUrl);let i=!1,l=null;const c=()=>{i=!0,l&&clearTimeout(l),o.terminate()};n.workerTimeout>0&&(l=setTimeout(()=>{i||(c(),r(new Error(`docx-preview worker timed out after ${n.workerTimeout}ms`)))},n.workerTimeout)),o.onerror=e=>{i||(c(),r(new Error(e.message||"docx-preview worker error")))},o.onmessage=e=>{const o=e.data??{};if(o.id===s||"ready"===o.type)if("progress"!==o.type){if("parsed"===o.type)return c(),n.progress?.({phase:"worker",message:"Worker parse complete"}),void t(a.WordDocument.fromSnapshot(o.snapshot,n));if("error"===o.type){c();const e=new Error(o.error?.message??"docx-preview worker parse failed");e.stack=o.error?.stack,r(e)}}else n.progress?.({phase:"worker",current:o.current,total:o.total,message:o.message})},o.postMessage({type:"parse",id:s,data:e,options:d(n),jsZipUrl:n.workerJsZipUrl})})):c(e,{...n,useWorker:!1})}async function m(e,t){const a={...r.defaultOptions,...t};await async function(e){const t=Array.from(e.querySelectorAll("img"));await Promise.allSettled(t.map(e=>e.complete?Promise.resolve():new Promise(t=>{e.addEventListener("load",t,{once:!0}),e.addEventListener("error",t,{once:!0})})))}(e),document.fonts?.ready&&await document.fonts.ready;const n=e.querySelector(`.${a.className}-wrapper`);if(a.breakPages&&a.fixedPageHeight&&!a.ignoreHeight&&"true"===n?.dataset.docxPaginating)for(let e=0;e<Math.max(2,Math.min(120,a.maxDynamicPaginationPasses??120))&&(await k(),"true"!==n.dataset.docxPaginated);e++);return await k(),f(e,a)}function f(e,t){const a={...r.defaultOptions,...t},n=Array.from(e.querySelectorAll(`section.${a.className}`)).map((e,t)=>{const r=Array.from(e.querySelectorAll("[data-docx-field-instr]")),n=Array.from(e.querySelectorAll("img")).filter(e=>!e.complete||0===e.naturalWidth).length,s=e.clientHeight>0&&e.scrollHeight>e.clientHeight+(a.paginationTolerance??2);return{index:t+1,section:e.dataset.docxSection??"",pageNumber:parseInt(e.dataset.docxPageNumber??`${t+1}`,10),sectionPageNumber:parseInt(e.dataset.docxSectionPageNumber??"1",10),width:e.clientWidth,height:e.clientHeight,scrollHeight:e.scrollHeight,overflow:s,textLength:e.textContent?.length??0,anchors:Array.from(e.querySelectorAll("[id]")).map(e=>e.id).filter(Boolean),fields:r.map(e=>({instruction:e.dataset.docxFieldInstr??"",value:e.textContent??""})),floats:e.querySelectorAll('[data-docx-float="true"]').length,unresolvedMedia:n}});return{pageCount:n.length,overflowPages:n.filter(e=>e.overflow).map(e=>e.index),unresolvedMedia:n.reduce((e,t)=>e+t.unresolvedMedia,0),pages:n}}function g(e,t="docx"){if(!e||"function"!=typeof getComputedStyle)return;const r=Array.from(e.querySelectorAll("p")),a=`${t}-num-`;for(const e of r){if(!e.className?.includes(a))continue;const t=getComputedStyle(e,"::before");if(!t.content||"none"==t.content||"normal"==t.content)continue;const r=b(e);if(!r||r==e)continue;const n=getComputedStyle(r);y(e,"--docx-marker-font-family",n.fontFamily),y(e,"--docx-marker-font-size",n.fontSize),y(e,"--docx-marker-font-style",n.fontStyle),y(e,"--docx-marker-font-weight",n.fontWeight)}}function b(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;t.nextNode();){const r=t.currentNode;if(!r.nodeValue?.trim())continue;const a=r.parentElement;if(!a||a==e)return e;const n=getComputedStyle(a);if("none"!=n.display&&"hidden"!=n.visibility)return a}return null}function y(e,t,r){r&&e.style.setProperty(t,r)}function k(){return new Promise(e=>{const t=globalThis;"function"==typeof t.requestIdleCallback?t.requestIdleCallback(()=>e(),{timeout:32}):"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>e()):setTimeout(e,0)})}},"./font-table/font-table":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FontTablePart=void 0;const a=e("../common/part"),n=e("./fonts");class s extends a.Part{parseXml(e){this.fonts=(0,n.parseFonts)(e,this._package.xmlParser)}}r.FontTablePart=s},"./font-table/fonts":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseFonts=function(e,t){return t.elements(e).map(e=>n(e,t))},r.parseFont=n,r.parseEmbedFontRef=s;const a={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function n(e,t){let r={name:t.attr(e,"name"),embedFontRefs:[]};for(let a of t.elements(e))switch(a.localName){case"family":r.family=t.attr(a,"val");break;case"altName":r.altName=t.attr(a,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":r.embedFontRefs.push(s(a,t))}return r}function s(e,t){return{id:t.attr(e,"id"),key:t.attr(e,"fontKey"),type:a[e.localName]}}},"./header-footer/elements":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WmlFooter=r.WmlHeader=void 0;const a=e("../document/dom");class n extends a.OpenXmlElementBase{constructor(){super(...arguments),this.type=a.DomType.Header}}r.WmlHeader=n;class s extends a.OpenXmlElementBase{constructor(){super(...arguments),this.type=a.DomType.Footer}}r.WmlFooter=s},"./header-footer/parts":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FooterPart=r.HeaderPart=r.BaseHeaderFooterPart=void 0;const a=e("../common/part"),n=e("./elements");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(e)}}r.BaseHeaderFooterPart=s,r.HeaderPart=class extends s{createRootElement(){return new n.WmlHeader}},r.FooterPart=class extends s{createRootElement(){return new n.WmlFooter}}},"./html-renderer":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.HtmlRenderer=void 0;const a=e("./document/dom"),n=e("./utils"),s=e("./javascript"),o=e("./document/section"),i=e("./html"),l=e("./parser/xml-parser");function c(e){return e>="0"&&e<="9"}function u(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122||t>=913&&t<=1023||t>=119808&&t<=120831}function d(e){return"()+-−=<>≤≥≈≠×÷*/·∙∑Σ∏∫√∞∂∇,.;:[]{}|‖!′″→←↔⇒⇔∈∉⊂⊃⊆⊇∧∨¬".includes(e)}r.HtmlRenderer=class{constructor(){this.className="docx",this.styleMap={},this.currentPart=null,this.currentSectionProps=null,this.currentPageNumber=1,this.currentSectionNumber=1,this.currentSectionPageNumber=1,this.totalPages=1,this.sectionPageCount=1,this.tableVerticalMerges=[],this.currentVerticalMerge=null,this.tableCellPositions=[],this.currentCellPosition=null,this.currentTableRow=null,this.footnoteMap={},this.endnoteMap={},this.currentEndnoteIds=[],this.usedHederFooterParts=[],this.currentTabs=[],this.currentParagraph=null,this.currentParagraphTabIndex=0,this.commentMap={},this.bookmarkTextMap={},this.bookmarkIdToName={},this.tocEntries=[],this.fieldSeqCounters={},this.fieldSetValues={},this.headingIndex=0,this.tasks=[],this.postRenderTasks=[],this.h=i.h}async render(e,t){this.document=e,this.options=t,this.className=t.className,this.rootSelector=t.inWrapper?`.${this.className}-wrapper`:":root",this.h=t.h??i.h,this.styleMap=null,this.tasks=[],this.postRenderTasks=[],this.currentTabs=[],this.fieldSeqCounters={},this.fieldSetValues={},this.headingIndex=0,this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight);const r=[...this.renderDefaultStyle()];e.themePart&&r.push(...this.renderTheme(e.themePart)),null!=e.stylesPart&&(this.styleMap=this.processStyles(e.stylesPart.styles),r.push(...this.renderStyles(e.stylesPart.styles))),e.numberingPart&&(this.prodessNumberings(e.numberingPart.domNumberings),r.push(...await this.renderNumbering(e.numberingPart.domNumberings))),e.footnotesPart&&(this.footnoteMap=(0,n.keyBy)(e.footnotesPart.notes,e=>e.id)),e.endnotesPart&&(this.endnoteMap=(0,n.keyBy)(e.endnotesPart.notes,e=>e.id)),e.settingsPart&&(this.defaultTabSize=e.settingsPart.settings?.defaultTabStop),!t.ignoreFonts&&e.fontTablePart&&r.push(...await this.renderFontTable(e.fontTablePart));var a=await this.renderSections(e.documentPart.body);return this.options.inWrapper?r.push(this.renderWrapper(a)):r.push(...a),this.commentHighlight&&t.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),await Promise.allSettled(this.tasks),this.postRenderTasks.forEach(e=>e()),this.refreshTabStops(),r}renderTheme(e){const t={},r=e.theme?.fontScheme;r&&(r.majorFont&&(t["--docx-majorHAnsi-font"]=r.majorFont.latinTypeface,t["--docx-majorEastAsia-font"]=r.majorFont.eaTypeface??r.majorFont.latinTypeface,t["--docx-majorBidi-font"]=r.majorFont.csTypeface??r.majorFont.latinTypeface,t["--docx-majorCs-font"]=r.majorFont.csTypeface??r.majorFont.latinTypeface),r.minorFont&&(t["--docx-minorHAnsi-font"]=r.minorFont.latinTypeface,t["--docx-minorEastAsia-font"]=r.minorFont.eaTypeface??r.minorFont.latinTypeface,t["--docx-minorBidi-font"]=r.minorFont.csTypeface??r.minorFont.latinTypeface,t["--docx-minorCs-font"]=r.minorFont.csTypeface??r.minorFont.latinTypeface));const a=e.theme?.colorScheme;if(a)for(let[e,r]of Object.entries(a.colors))t[`--docx-${e}-color`]=`#${r}`;const n=this.styleToString(`.${this.className}`,t);return[this.h({tagName:"#comment",children:["docxjs document theme values"]}),this.h({tagName:"style",children:[n]})]}async renderFontTable(e){const t=[];for(let r of e.fonts)for(let e of r.embedFontRefs)try{const a=await this.document.loadFont(e.id,e.key),s={"font-family":(0,n.encloseFontFamily)(r.name),src:`url(${a})`};"bold"!=e.type&&"boldItalic"!=e.type||(s["font-weight"]="bold"),"italic"!=e.type&&"boldItalic"!=e.type||(s["font-style"]="italic"),t.push(this.h({tagName:"#comment",children:[`docxjs ${r.name} font`]})),t.push(this.h({tagName:"style",children:[this.styleToString("@font-face",s)]}))}catch(t){this.options.debug&&console.warn(`Can't load font with id ${e.id} and key ${e.key}`)}return t}processStyleName(e){return e?`${this.className}_${(0,n.escapeClassName)(e)}`:this.className}processStyles(e){const t=(0,n.keyBy)(e.filter(e=>null!=e.id),e=>e.id);for(const a of e.filter(e=>e.basedOn)){var r=t[a.basedOn];if(r){a.paragraphProps=(0,n.mergeDeep)({},r.paragraphProps,a.paragraphProps),a.runProps=(0,n.mergeDeep)({},r.runProps,a.runProps);for(const e of r.styles){const t=a.styles.find(t=>t.target==e.target);t?this.copyStyleProperties(e.values,t.values):a.styles.push({...e,values:{...e.values}})}}else this.options.debug&&console.warn(`Can't find base style ${a.basedOn}`)}for(let t of e)t.cssName=this.processStyleName(t.id);return t}prodessNumberings(e){for(let t of e.filter(e=>e.pStyleName)){const e=this.findStyle(t.pStyleName);e?.paragraphProps?.numbering&&(e.paragraphProps.numbering.level=t.level)}}processElement(e){if(e.children)for(var t of e.children)t.parent=e,t.type==a.DomType.Table?this.processTable(t):this.processElement(t)}processTable(e){const t=e.children??[];let r=e.columns?.length??0;for(const e of t){let t=e.gridBefore??0;for(const r of e.children??[])t+=r.span??1;r=Math.max(r,t+(e.gridAfter??0))}const a=Math.max(e.rowBandSize??1,1),n=Math.max(e.colBandSize??1,1);t.forEach((s,o)=>{0==o&&this.appendClassName(s,"first-row"),o==t.length-1&&this.appendClassName(s,"last-row"),this.appendClassName(s,Math.floor(o/a)%2==0?"odd-row":"even-row");let i=s.gridBefore??0;for(const t of s.children??[]){t.cssStyle=this.copyStyleProperties(e.cellStyle,t.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]);const a=t.span??1,s=i+a-1;0==i&&this.appendClassName(t,"first-col"),r>0&&s>=r-1&&this.appendClassName(t,"last-col"),this.appendClassName(t,Math.floor(i/n)%2==0?"odd-col":"even-col"),this.processElement(t),i+=a}})}collectDocumentMetadata(e){this.bookmarkTextMap={},this.bookmarkIdToName={},this.tocEntries=[];const t={},r=e=>{if(e.type!=a.DomType.Deleted||this.options.renderChanges){switch(e.type){case a.DomType.BookmarkStart:{const r=e;r.id&&r.name&&(this.bookmarkIdToName[r.id]=r.name,t[r.id]=[]);break}case a.DomType.BookmarkEnd:{const r=e,a=this.bookmarkIdToName[r.id];a&&t[r.id]&&(this.bookmarkTextMap[a]=t[r.id].join("").trim(),delete t[r.id]);break}case a.DomType.Text:for(const r of Object.keys(t))t[r].push(e.text??"");break;case a.DomType.DeletedText:if(this.options.renderChanges)for(const r of Object.keys(t))t[r].push(e.text??"")}for(const t of e.children??[])r(t)}};for(const t of e.children??[])r(t);for(const[e,r]of Object.entries(t)){const t=this.bookmarkIdToName[e];t&&(this.bookmarkTextMap[t]=r.join("").trim())}for(const t of e.children??[])this.collectTocEntries(t)}collectTocEntries(e){if(e.type!=a.DomType.Deleted||this.options.renderChanges){if(e.type==a.DomType.Paragraph){const t=e,r=this.findStyle(t.styleName),a=this.extractText(t).trim();let n=t.outlineLevel??r?.paragraphProps?.outlineLevel;if(null==n&&t.styleName){const e=/heading(\d+)|(?:^|[-_ ])h(\d+)$/i.exec(t.styleName);e&&(n=parseInt(e[1]??e[2],10)-1)}if(a&&null!=n&&n>=0&&n<9){const e=this.findFirstBookmark(t),r=e?.name&&!e.name.startsWith("_")?e.name:`${this.className}-heading-${++this.headingIndex}`;t.props={...t.props??{},anchorId:r},this.tocEntries.push({level:n+1,text:a,id:r})}}for(const t of e.children??[])this.collectTocEntries(t)}}findFirstBookmark(e){if(e.type==a.DomType.BookmarkStart)return e;for(const t of e.children??[]){const e=this.findFirstBookmark(t);if(e)return e}return null}extractText(e){switch(e.type){case a.DomType.Text:return e.text??"";case a.DomType.DeletedText:return this.options.renderChanges?e.text??"":"";case a.DomType.Deleted:return this.options.renderChanges?(e.children??[]).map(e=>this.extractText(e)).join(""):"";case a.DomType.Inserted:return(e.children??[]).map(e=>this.extractText(e)).join("");case a.DomType.Tab:case a.DomType.PositionalTab:return"\t";case a.DomType.NoBreakHyphen:return"‑";case a.DomType.SoftHyphen:return"";case a.DomType.Break:return"\n";case a.DomType.Instruction:case a.DomType.ComplexField:return""}return(e.children??[]).map(e=>this.extractText(e)).join("")}appendClassName(e,t){e.className=(0,i.cx)(e.className,t)}copyStyleProperties(e,t,r=null){if(!e)return t;for(var a of(null==t&&(t={}),null==r&&(r=Object.getOwnPropertyNames(e)),r))e.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(t[a]=e[a]);return t}createPageElement(e,t,r){const a={...r};if(t){if(t.pageMargins&&(a.paddingLeft=this.addSize(t.pageMargins.left,t.pageMargins.gutter),a.paddingRight=t.pageMargins.right,a.paddingTop=t.pageMargins.top,a.paddingBottom=t.pageMargins.bottom),t.pageSize){let e=t.pageSize.width,r=t.pageSize.height;if("landscape"==t.pageSize.orientation){const t=this.parseCssLengthValue(e),a=this.parseCssLengthValue(r);null!=t&&null!=a&&t<a&&([e,r]=[r,e])}this.options.ignoreWidth||(a.width=e),this.options.ignoreHeight||(a.minHeight=r,this.options.breakPages&&this.options.fixedPageHeight&&(a.height=r))}t.pageBorders&&(this.applyPageBorder(a,"top",t.pageBorders.top),this.applyPageBorder(a,"right",t.pageBorders.right),this.applyPageBorder(a,"bottom",t.pageBorders.bottom),this.applyPageBorder(a,"left",t.pageBorders.left))}return this.h({tagName:"section",className:e,style:a})}addSize(e,t){return e?t&&"0.00pt"!=t&&"0px"!=t?`calc(${e} + ${t})`:e:t}parseCssLengthValue(e){if(!e)return null;const t=/^(-?\d+(?:\.\d+)?)/.exec(e);return t?parseFloat(t[1]):null}applyPageBorder(e,t,r){if(!r)return;const a=this.borderTypeToCss(r.type);e[`border-${t}`]="none"==a?"none":`${r.size??"1px"} ${a} ${this.borderColor(r.color)}`}borderTypeToCss(e){switch(e){case"nil":case"none":return"none";case"double":case"triple":return"double";case"dashed":case"dashSmallGap":return"dashed";case"dotted":case"dotDash":case"dotDotDash":return"dotted"}return"solid"}borderColor(e){return e&&"auto"!=e?/^[0-9a-f]{6}$/i.test(e)?`#${e}`:e:"black"}createSectionContent(e){const t={},r=e.columns?.numberOfColumns??e.columns?.columns?.length;return e.docGrid&&(e.docGrid.linePitch&&(t["--docx-doc-grid-line-pitch"]=e.docGrid.linePitch),e.docGrid.charSpace&&(t.letterSpacing=e.docGrid.charSpace)),this.document.settingsPart?.settings?.kinsoku&&(t.lineBreak="strict",t.wordBreak="keep-all"),this.document.settingsPart?.settings?.overflowPunctuation&&(t.hangingPunctuation="allow-end"),this.document.settingsPart?.settings?.topLinePunctuation&&(t["text-spacing-trim"]="space-start"),(this.document.settingsPart?.settings?.autoSpaceDE||this.document.settingsPart?.settings?.autoSpaceDN)&&(t["text-autospace"]=[this.document.settingsPart?.settings?.autoSpaceDE?"ideograph-alpha":null,this.document.settingsPart?.settings?.autoSpaceDN?"ideograph-numeric":null].filter(Boolean).join(" ")),e.columns&&r&&(t.columnCount=`${r}`,t.columnGap=e.columns.space,!e.columns.equalWidth&&e.columns.columns?.length>0&&(t.columnWidth=e.columns.columns[0].width,t.columnGap=e.columns.columns[0].space??t.columnGap),e.columns.separator&&(t.columnRule="1px solid black")),this.h({tagName:"article",style:t})}async renderSections(e){const t=[];this.processElement(e),this.collectDocumentMetadata(e);const r=this.splitBySection(e.children,e.props),a=this.groupByPageBreaks(r);let n=null,s=0,o=0;const i=new Map,l=new Map,c=new Map,u=new Map,d=e=>{if(!c.has(e)){const t=++o;c.set(e,`${this.className}-section-${t}`),u.set(e,t)}};for(const e of a){const t=e[0].sectProps;d(t),i.set(t,(i.get(t)??0)+1)}this.totalPages=a.length;for(let r=0,o=a.length;r<o;r++){this.currentFootnoteIds=[];let p=a[r][0].sectProps;d(p);const m=n!=p;s=m&&null!=p?.pageNumber?.start?p.pageNumber.start:s+1,this.currentPageNumber=s,this.currentSectionNumber=u.get(p)??1,this.currentSectionProps=p,this.currentSectionPageNumber=(l.get(p)??0)+1,this.sectionPageCount=i.get(p)??1,l.set(p,this.currentSectionPageNumber);const f=this.createPageElement(this.className,p,e.cssStyle);f.dataset.docxSection=c.get(p),f.dataset.docxSectionNumber=`${this.currentSectionNumber}`,f.dataset.docxSectionPageNumber=`${this.currentSectionPageNumber}`,f.dataset.docxSectionPageCount=`${this.sectionPageCount}`,f.dataset.docxPageNumber=`${s}`,m&&null!=p?.pageNumber?.start&&(f.dataset.docxPageStart=`${p.pageNumber.start}`),this.options.renderHeaders&&this.renderHeaderFooter(p.headerRefs,p,s,m,f);for(const e of a[r]){this.currentSectionProps=e.sectProps;var h=this.createSectionContent(e.sectProps);e.columnBreak&&(h.style.breakBefore="column"),this.renderElements(e.elements,h),f.appendChild(h),p=e.sectProps}if(this.options.renderFootnotes){const e=this.renderNotes(this.currentFootnoteIds,this.footnoteMap,this.document.footnotesPart);e&&f.appendChild(e)}if(this.options.renderEndnotes&&r==o-1){const e=this.renderNotes(this.currentEndnoteIds,this.endnoteMap,this.document.endnotesPart);e&&f.appendChild(e)}this.currentSectionProps=p,this.options.renderFooters&&this.renderHeaderFooter(p.footerRefs,p,s,m,f),t.push(f),await this.yieldDuringRender(r+1,o),n=p}return t}renderHeaderFooter(e,t,r,n,s){if(!e)return;const o=!!this.document.settingsPart?.settings?.evenAndOddHeaders,i=e.find(e=>"default"==e.type);var l=(t.titlePage&&n?e.find(e=>"first"==e.type):null)??(o&&r%2==0?e.find(e=>"even"==e.type):null)??i??e.find(e=>"first"==e.type)??(o?e.find(e=>"even"==e.type):null),c=l&&this.document.findPartByRelId(l.id,this.document.documentPart);if(c){this.currentPart=c,this.usedHederFooterParts.includes(c.path)||(this.processElement(c.rootElement),this.usedHederFooterParts.push(c.path));const[e]=this.renderElements([c.rootElement],s);t?.pageMargins&&(c.rootElement.type===a.DomType.Header?(e.style.marginTop=`calc(${t.pageMargins.header} - ${t.pageMargins.top})`,e.style.minHeight=`calc(${t.pageMargins.top} - ${t.pageMargins.header})`):c.rootElement.type===a.DomType.Footer&&(e.style.marginBottom=`calc(${t.pageMargins.footer} - ${t.pageMargins.bottom})`,e.style.minHeight=`calc(${t.pageMargins.bottom} - ${t.pageMargins.footer})`)),this.currentPart=null}}isPageBreakElement(e){return e.type==a.DomType.Break&&("lastRenderedPageBreak"==e.break?!this.options.ignoreLastRenderedPageBreak:"page"==e.break)}isPageBreakSection(e,t){return!(!e||!t||e.pageSize?.orientation==t.pageSize?.orientation&&e.pageSize?.width==t.pageSize?.width&&e.pageSize?.height==t.pageSize?.height)}splitBySection(e,t){let r={sectProps:null,elements:[],pageBreak:!1,columnBreak:!1},n=[r];const s=(e=!1,t=!1)=>{if(0==r.elements.length&&null==r.sectProps)return r.pageBreak||(r.pageBreak=e),void(r.columnBreak||(r.columnBreak=t));r.pageBreak||(r.pageBreak=e),r.columnBreak||(r.columnBreak=t),r={sectProps:null,elements:[],pageBreak:!1,columnBreak:!1},n.push(r)};for(let t of e){if(t.type!=a.DomType.Paragraph){if(t.type==a.DomType.Table)for(const e of this.splitTableByPageBreaks(t))e.table.children?.length&&r.elements.push(e.table),e.breakAfter&&s(!0);else r.elements.push(t);continue}const e=t,n=this.findStyle(e.styleName),i=e.pageBreakBefore??n?.paragraphProps?.pageBreakBefore;this.options.breakPages&&i&&r.elements.length>0&&s(!0);const l=this.splitParagraphByPageBreaks(e);for(const e of l)r.elements.push(e.paragraph),e.breakAfter&&s(!0);e.sectionProps&&(r.sectProps=e.sectionProps,s((0,o.isSectionPageBreak)(e.sectionProps.type),(0,o.isSectionColumnBreak)(e.sectionProps.type)))}if(n=n.filter(e=>e.elements.length>0),0==n.length)return[{sectProps:t,elements:[],pageBreak:!1,columnBreak:!1}];let i=null;for(let e=n.length-1;e>=0;e--)null==n[e].sectProps?n[e].sectProps=i??t:i=n[e].sectProps;return n}hasPageBreakElement(e){return!!this.isPageBreakElement(e)||(e.children?.some(e=>this.hasPageBreakElement(e))??!1)}splitTableByPageBreaks(e){if(!this.options.breakPages||!e.children?.length)return[{table:e,breakAfter:!1}];if(!e.children.some(e=>this.hasPageBreakElement(e)))return[{table:e,breakAfter:!1}];const t=e.children,r=[];for(const e of t){if(!e.isHeader)break;r.push(e)}const a=[];let n=[];const s=t=>{if(0==n.length&&a.length>0)return;const s=a.length>0;let o=n;s&&r.length>0&&!n.some(e=>e.isHeader)&&(o=[...r,...n]),a.push({table:{...e,children:o},breakAfter:t}),n=[]};for(const e of t)n.push(e),this.hasPageBreakElement(e)&&s(!0);return s(!1),a.length>0?a:[{table:e,breakAfter:!1}]}splitElementByPageBreaks(e){if(this.isPageBreakElement(e))return[{breakAfter:!0}];if(!e.children?.length)return[{element:e}];const t=[];let r={...e,children:[]};const a=()=>{r.children.length>0&&t.push({element:r}),r={...e,children:[]}};for(const n of e.children)for(const e of this.splitElementByPageBreaks(n))e.element&&r.children.push(e.element),e.breakAfter&&(a(),t.push({breakAfter:!0}));return a(),t.length>0?t:[{element:e}]}splitParagraphByPageBreaks(e){if(!this.options.breakPages||!e.children?.length)return[{paragraph:e,breakAfter:!1}];const t=[];let r={...e,children:[]};const a=a=>{(r.children.length>0||0==t.length)&&t.push({paragraph:r,breakAfter:a}),r={...e,sectionProps:null,children:[]}};for(const t of e.children)for(const e of this.splitElementByPageBreaks(t))e.element&&r.children.push(e.element),e.breakAfter&&a(!0);(r.children.length>0||0==t.length)&&t.push({paragraph:r,breakAfter:!1});const n=t[t.length-1]?.paragraph;for(const e of t)e.paragraph!=n&&(e.paragraph.sectionProps=null);return t}styleValuesForTarget(e,t){return e?.styles?.find(e=>e.target==t)?.values}styleValue(e,t,r){return this.styleValuesForTarget(e,t)?.[r]}effectiveParagraphCssValue(e,t,r){return e.cssStyle?.[r]??this.styleValue(t,"p",r)}isInsideTableCell(e){for(let t=e.parent;t;t=t.parent)if(t.type==a.DomType.Cell)return!0;return!1}paragraphUsesDocumentGrid(e,t){const r=this.currentSectionProps?.docGrid?.linePitch;if(!r)return!1;if(this.isInsideTableCell(e)&&!this.document.settingsPart?.settings?.adjustLineHeightInTable)return!1;const a=this.effectiveParagraphCssValue(e,t,"--docx-snap-to-grid");return null==a||!/^(0|false|off)$/i.test(a)}setCssStyle(e,t,r){const a=e.style;"function"==typeof a.setProperty?a.setProperty(t,r):a[t]=r}applyDocumentGridLinePitch(e,t,r){if(!this.paragraphUsesDocumentGrid(e,t))return;if(this.effectiveParagraphCssValue(e,t,"line-height"))return;const a=this.currentSectionProps.docGrid.linePitch,n=this.effectiveParagraphCssValue(e,t,"min-height");if(!n)return void this.setCssStyle(r,"min-height",a);const s=this.parseCssLengthValue(n),o=this.parseCssLengthValue(a);null!=s&&null!=o?s<o&&this.setCssStyle(r,"min-height",a):this.setCssStyle(r,"min-height",`max(${n}, ${a})`)}groupByPageBreaks(e){let t=[],r=null;const a=[t];for(let n of e)r&&(r.pageBreak||this.isPageBreakSection(r.sectProps,n.sectProps))&&(t=[],a.push(t)),t.push(n),r=n;return a.filter(e=>e.length>0)}async yieldDuringRender(e,t){const r=this.options.renderPageBatchSize??0;this.options.progress&&this.options.progress({phase:"render",current:e,total:t,message:`Rendered ${e}/${t} logical pages`}),r>0&&e%r==0&&await this.yieldToBrowser()}async yieldToBrowser(){(this.options.renderYieldEveryMs??0)<=0||await new Promise(e=>{const t=globalThis;"function"==typeof t.requestIdleCallback?t.requestIdleCallback(()=>e(),{timeout:Math.max(1,this.options.renderYieldEveryMs??16)}):"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>e()):setTimeout(e,0)})}renderWrapper(e){return this.h({tagName:"div",className:this.className+"-wrapper",children:e})}scheduleDynamicPagination(e){e.isConnected?(()=>{const t=document.fonts?.ready;(t??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>requestAnimationFrame(()=>this.performDynamicPagination(e)))})})():setTimeout(()=>this.scheduleDynamicPagination(e),0)}async performDynamicPagination(e){if(!e||"true"==e.dataset.docxPaginated||"true"==e.dataset.docxPaginating)return;if(!e.isConnected)return void setTimeout(()=>this.performDynamicPagination(e),0);e.dataset.docxPaginating="true";const t=Array.from(e.querySelectorAll(":scope > section."+this.className)),r=this.options.maxDynamicPaginationPasses??1e3;let a=0;for(let e=0;e<t.length;e++){const n=t[e];let s=n.querySelector(":scope > article");for(e%2==0&&await this.yieldToBrowser();s&&this.isPageOverflowing(n)&&s.children.length>0&&a++<r;){const r=this.createContinuationPage(n),a=r.querySelector(":scope > article");let o=!1,i=0;for(;this.isPageOverflowing(n)&&s.lastElementChild&&i++<500;)if(i%20==0&&await this.yieldToBrowser(),s.children.length>1){let e=this.pickPaginationChunk(s);if(0==e.length)break;if(e.length>=s.children.length){if(this.splitOverflowBlock(s.lastElementChild,n,a)){o=!0;continue}e=[s.lastElementChild]}for(let t=e.length-1;t>=0;t--)a.prepend(e[t]),o=!0}else{if(!this.splitOverflowBlock(s.lastElementChild,n,a))break;o=!0}if(!o||0==a.children.length){r.remove();break}t.splice(e+1,0,r)}}this.cleanupEmptyNumberedParagraphs(e),this.removeEmptyDynamicPages(e),this.updateDynamicFieldPages(e),delete e.dataset.docxPaginating,e.dataset.docxPaginated="true"}pickPaginationChunk(e){const t=Array.from(e.children);if(0==t.length)return[];let r=t.length-1;for(;r>0&&this.isKeepWithNext(t[r-1]);)r--;return t.slice(r)}isKeepWithNext(e){if("true"==e.dataset.docxKeepNext)return!0;const t=getComputedStyle(e);return"avoid"==t.breakAfter||"avoid"==t.pageBreakAfter}isPageOverflowing(e){const t=this.options.paginationTolerance??2,r=e.clientHeight;if(r<=0)return!1;if(e.scrollHeight>r+t)return!0;const a=e.getBoundingClientRect();let n=a.top;for(const t of Array.from(e.children)){const e=t.getBoundingClientRect();if(n=Math.max(n,e.bottom),"article"==t.tagName.toLowerCase())for(const e of Array.from(t.children)){const t=e.getBoundingClientRect();n=Math.max(n,t.bottom)}}return n>a.bottom+t}createContinuationPage(e){const t=e.cloneNode(!0);t.dataset.docxDynamicPage="true",t.removeAttribute("id");for(const e of Array.from(t.querySelectorAll(":scope > article")))e.textContent="";return e.after(t),t}splitOverflowBlock(e,t,r){if(!e||"true"==e.dataset.docxKeepLines)return!1;const a=getComputedStyle(e);if("avoid"==a.breakInside||"avoid"==a.pageBreakInside)return!1;switch(e.tagName.toLowerCase()){case"p":return this.splitParagraphBlock(e,t,r);case"table":return this.splitTableBlock(e,t,r)}return!1}splitParagraphBlock(e,t,r){if(!e.hasChildNodes())return!1;const a=this.cloneBlockShell(e);a.dataset.docxContinued="true",r.prepend(a);let n=!1,s=0;for(;this.isPageOverflowing(t)&&e.hasChildNodes()&&s++<1e3&&this.moveTailInlineNode(e,a,t);)n=!0,this.removeEmptyInlineContainers(e);return n?(e.hasChildNodes()?this.options.strictWordCompatibility&&"true"==e.dataset.docxWidowControl&&this.rebalanceWidowOrphan(e,a,t):e.remove(),!0):(a.remove(),!1)}splitTableBlock(e,t,r){const a=this.tableContentRows(e);if(a.length<=1)return!1;const n=this.cloneBlockShell(e);n.dataset.docxContinued="true";for(const t of Array.from(e.children))"colgroup"==t.tagName?.toLowerCase()&&n.appendChild(t.cloneNode(!0));for(const e of a.filter(e=>"true"==e.dataset.docxRepeatHeader)){const t=e.cloneNode(!0);t.dataset.docxRepeatedHeader="true",n.appendChild(t)}r.prepend(n);let s=!1,o=0;for(;this.isPageOverflowing(t)&&this.tableContentRows(e).length>1&&o++<500;){const t=this.tableContentRows(e).filter(e=>"true"!=e.dataset.docxRepeatedHeader),r=t[t.length-1];if(!r)break;n.insertBefore(r,this.firstMovedTableRow(n)),s=!0}return!!s||(n.remove(),!1)}cloneBlockShell(e){const t=e.cloneNode(!1);return t.removeAttribute("id"),t}tableContentRows(e){return Array.from(e.querySelectorAll(":scope > tr, :scope > tbody > tr"))}firstMovedTableRow(e){return this.tableContentRows(e).find(e=>"true"!=e.dataset.docxRepeatedHeader)??null}moveTailInlineNode(e,t,r){const a=e.lastChild;if(!a)return!1;if(a.nodeType==Node.TEXT_NODE)return this.moveTextTail(a,t,r);if(a instanceof Element&&a.childNodes.length>0&&"br"!=a.tagName?.toLowerCase()){const e=a.cloneNode(!1);e.removeAttribute("id"),t.prepend(e);const n=this.moveTailInlineNode(a,e,r);return a.hasChildNodes()||a.remove(),e.hasChildNodes()||e.remove(),n}return t.prepend(a),!0}moveTextTail(e,t,r){const a=e.data??"";if(!a)return!1;const n=document.createTextNode("");if(t.prepend(n),1==a.length)return n.data=a,e.remove(),!0;let s=1,o=a.length,i=a.length;for(;s<=o;){const t=Math.floor((s+o)/2);e.data=a.substring(0,a.length-t),n.data=a.substring(a.length-t),this.isPageOverflowing(r)?s=t+1:(i=t,o=t-1)}return i=this.adjustSplitToWordBoundary(a,i),e.data=a.substring(0,a.length-i),n.data=a.substring(a.length-i),e.data||e.remove(),!0}adjustSplitToWordBoundary(e,t){if(t<=1||t>=e.length)return t;const r=e.length-t,a=e.lastIndexOf(" ",r);return a>0&&r-a<32?e.length-a-1:t}removeEmptyInlineContainers(e){for(const t of Array.from(e.childNodes))t instanceof HTMLElement&&(this.removeEmptyInlineContainers(t),t.hasChildNodes()||/^(br|img|svg|math)$/i.test(t.tagName)||t.remove())}cleanupEmptyNumberedParagraphs(e){const t=`p[class*="${this.className}-num-"]`;for(const r of Array.from(e.querySelectorAll(t))){if(this.hasVisiblePaginationContent(r))continue;if(!r.id&&!r.querySelector("[id], a[name]"))continue;const t=this.findNextVisiblePaginationBlock(e,r);t&&this.moveAnchorsToBlock(r,t),r.remove()}}removeEmptyDynamicPages(e){const t=Array.from(e.querySelectorAll(`:scope > section.${this.className}[data-docx-dynamic-page="true"]`));for(const e of t){const t=e.querySelector(":scope > article");t&&!Array.from(t.children).some(e=>this.hasVisiblePaginationContent(e))&&e.remove()}}findNextVisiblePaginationBlock(e,t){const r=Array.from(e.querySelectorAll("article p, article table, article figure, article img, article svg, article math"));for(let e=r.indexOf(t)+1;e<r.length;e++){const t=r[e];if(this.hasVisiblePaginationContent(t))return t}return null}hasVisiblePaginationContent(e){return(e.textContent??"").replace(/\s+/g,"").length>0||!!e.querySelector("br,img,svg,math,object,canvas,video,table")}moveAnchorsToBlock(e,t){const r=Array.from(e.querySelectorAll("[id], a[name]"));e.id&&!t.id&&(t.id=e.id);for(let e=r.length-1;e>=0;e--){const a=r[e];a.id&&t.querySelector(`#${CSS.escape(a.id)}`)||t.prepend(a)}}rebalanceWidowOrphan(e,t,r){const a=this.visualLineCount(e),n=this.visualLineCount(t);if(a>=2&&n>=2)return;if(a<2&&e.parentElement&&t.hasChildNodes())return t.prepend(...Array.from(e.childNodes)),void e.remove();let s=0;for(;this.visualLineCount(t)<2&&e.hasChildNodes()&&s++<20&&!this.isPageOverflowing(r)&&this.moveTailInlineNode(e,t,r););}visualLineCount(e){try{const t=document.createRange();t.selectNodeContents(e);const r=Array.from(t.getClientRects());t.detach?.();const a=new Set(r.map(e=>Math.round(e.top)));return Math.max(a.size,1)}catch{return 1}}updateDynamicFieldPages(e){const t=Array.from(e.querySelectorAll(":scope > section."+this.className)),r={},a={},n={},s=[],o=[];let i=0,l="";for(const e of t){const t=e.dataset.docxSection??"";a[t]=(a[t]??0)+1}if(t.forEach((e,t)=>{const c=e.dataset.docxSection??"";if(c!=l){const t=null!=e.dataset.docxPageStart?parseInt(e.dataset.docxPageStart,10):null;i=Number.isFinite(t)?t:i+1,n[c]=1,l=c}else i++,n[c]=(n[c]??0)+1;e.dataset.docxPageNumber=`${i}`,e.dataset.docxSectionPageNumber=`${n[c]}`,e.dataset.docxSectionPageCount=`${a[c]??1}`,s[t]=i,o[t]=n[c];for(const t of Array.from(e.querySelectorAll("[id]")))t.id&&null==r[t.id]&&(r[t.id]=i)}),t.forEach((e,n)=>{const i=e.dataset.docxSection??"";for(const l of Array.from(e.querySelectorAll("[data-docx-field-instr]"))){const c=this.evaluateDynamicField(l.dataset.docxFieldInstr,s[n]??n+1,t.length,r,a[i]??1,o[n]??1,parseInt(e.dataset.docxSectionNumber??"1",10));null!=c&&(l.textContent=c)}}),this.options.updatePageReferences)for(const t of Array.from(e.querySelectorAll("[data-docx-page-ref]"))){const e=t.dataset.docxPageRef;t.textContent=`${r[e]??1}`}}evaluateDynamicField(e,t,r,a,n=r,s=t,o=1){const i=this.tokenizeFieldInstruction((e??"").replace(/\s+/g," ").trim()),l=i[0]?.replace(/^=/,"").toUpperCase();let c=null;switch(l){case"PAGE":c=this.formatFieldNumber(t,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??this.currentSectionProps?.pageNumber?.format));break;case"NUMPAGES":c=this.formatFieldNumber(r,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??this.currentSectionProps?.pageNumber?.format));break;case"SECTIONPAGES":c=this.formatFieldNumber(n,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??this.currentSectionProps?.pageNumber?.format));break;case"SECTION":c=this.formatFieldNumber(o,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??"decimal"));break;case"PAGEREF":{if(!this.options.updatePageReferences)return null;const e=this.firstFieldArgument(i);c=e?`${a[e]??1}`:"";break}}return null==c?null:this.applyFieldFormatting(c,e)}renderDefaultStyle(){var e=this.className,t=`\n.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; }\n.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }`;this.options.hideWrapperOnPrint&&(t=`@media not print { ${t} }`);var r=`${t}\n.${e} { color: black; hyphens: auto; text-underline-position: from-font; font-kerning: normal; font-variant-ligatures: common-ligatures contextual; text-rendering: optimizeLegibility; line-break: auto; }\nsection.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: visible; }\nsection.${e}>article { margin-bottom: auto; z-index: 1; }\nsection.${e}>footer { z-index: 1; }\n.${e} [data-docx-continued="true"] { margin-top: 0 !important; }\n.${e} tr[data-docx-repeat-header="true"], .${e} tr[data-docx-repeated-header="true"] { break-after: avoid; }\n.${e} table { border-collapse: collapse; }\n.${e} table td, .${e} table th { vertical-align: top; overflow-wrap: anywhere; }\n.${e} p { margin: 0pt; min-height: 1em; }\n.${e} span { white-space: pre-wrap; overflow-wrap: break-word; font-feature-settings: "kern" 1; }\n.${e} table span { overflow-wrap: anywhere; }\n.${e} .${e}-float-wrap { shape-margin: 0.15in; }\n.${e} .${e}-field { white-space: pre-wrap; }\n.${e} .${e}-tab-stop { display: inline-block; min-width: 1em; white-space: nowrap; line-height: 1; }\n.${e} .${e}-tab-stop[data-docx-tab-leader="dot"], .${e} .${e}-tab-stop[data-docx-tab-leader="middleDot"] { min-width: 2em; border-bottom: 1px dotted currentColor; height: .85em; transform: translateY(-.18em); }\n.${e} .${e}-tab-stop[data-docx-tab-leader="hyphen"], .${e} .${e}-tab-stop[data-docx-tab-leader="heavy"], .${e} .${e}-tab-stop[data-docx-tab-leader="underscore"] { min-width: 2em; border-bottom: 1px solid currentColor; height: .85em; transform: translateY(-.18em); }\n.${e} .${e}-tab-leader-paragraph > a, .${e} .${e}-tab-leader-paragraph > .${e}-tab-leader-line { display: inline-flex; align-items: baseline; width: calc(100% - var(--docx-text-indent, 0pt)); color: inherit !important; text-decoration: none !important; box-sizing: border-box; max-width: none; }\n.${e} .${e}-tab-leader-paragraph > a, .${e} .${e}-tab-leader-paragraph > a * { color: inherit !important; text-decoration: none !important; }\n.${e} .${e}-toc-paragraph a, .${e} .${e}-toc-paragraph a * { color: inherit !important; text-decoration: none !important; }\n.${e} .${e}-tab-leader-title { flex: 0 1 auto; min-width: 0; }\n.${e} .${e}-tab-leader-page { flex: 0 0 auto; white-space: nowrap; text-align: right; }\n.${e} .${e}-tab-leader-fill, .${e} .${e}-tab-leader-paragraph > a > .${e}-tab-stop[data-docx-tab-leader="dot"], .${e} .${e}-tab-leader-paragraph > a > .${e}-tab-stop[data-docx-tab-leader="middleDot"], .${e} .${e}-tab-leader-paragraph > .${e}-tab-stop[data-docx-tab-leader="dot"], .${e} .${e}-tab-leader-paragraph > .${e}-tab-stop[data-docx-tab-leader="middleDot"] { flex: 1 1 auto; width: auto; margin: 0 .2em; }\n.${e} .${e}-toc { display: table; width: 100%; }\n.${e} .${e}-toc-entry { display: table-row; }\n.${e} .${e}-toc-title, .${e} .${e}-toc-page { display: table-cell; }\n.${e} .${e}-toc-title { border-bottom: 1px dotted currentColor; }\n.${e} .${e}-toc-page { text-align: right; width: 3em; }\n.${e} math { font-family: Cambria Math, STIX Two Math, Latin Modern Math, serif; }\n.${e} ruby { ruby-position: over; }\n.${e} rt { font-size: 0.5em; line-height: 1; }\n.${e} .${e}-chart, .${e} .${e}-smartart, .${e} .${e}-ink { min-width: 2in; min-height: 1in; }\n.${e} a { color: inherit; text-decoration: inherit; }\n.${e} svg { fill: transparent; }\n@media print { .${e}-wrapper { background: transparent; padding: 0; display: block; } section.${e} { margin: 0 auto; box-shadow: none; break-after: page; page-break-after: always; } }\n`;return this.options.renderComments&&(r+=`\n.${e}-comment-ref { cursor: default; }\n.${e}-comment-popover { display: none; z-index: 1000; padding: 0.5rem; background: white; position: absolute; box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.25); width: 30ch; }\n.${e}-comment-ref:hover~.${e}-comment-popover { display: block; }\n.${e}-comment-author,.${e}-comment-date { font-size: 0.875rem; color: #888; }\n`),[this.h({tagName:"#comment",children:["docxjs library predefined styles"]}),this.h({tagName:"style",children:[r]})]}async renderNumbering(e){var t="",r=[];const a=new Map,n=new Map(e.map(e=>[`${e.id}:${e.level}`,this.numFormatToCssValue(e.format)])),s=(e,t)=>{const r=a.get(e)??[];r.push(t),a.set(e,r)};for(var o of e){var i=`p.${this.numberingClass(o.id,o.level)}`,l="none";if(o.bullet){let e=`--${this.className}-${o.bullet.src}`.toLowerCase();t+=this.styleToString(`${i}:before`,{content:"' '",display:"inline-block",background:`var(${e})`},o.bullet.style);try{const r=await this.document.loadNumberingImage(o.bullet.src);t+=`${this.rootSelector} { ${e}: url(${r}) }`}catch(e){this.options.debug&&console.warn(`Can't load numbering image with src ${o.bullet.src}`)}}else if(o.levelText){let e=this.numberingCounter(o.id,o.level);const a=e+" "+(o.start-1),l=this.numberingRestartLevel(o);null!=l&&s(`p.${this.numberingClass(o.id,l)}`,a),r.push(a);const c=this.normalizeNumberingLevelText(o.levelText,o.format,o.rStyle),u=this.numberingMarkerRunStyle(o.rStyle,c.normalized);t+=this.styleToString(`${i}:before`,{content:this.levelTextToContent(c.text,o.suff,o.id,this.numFormatToCssValue(o.format),n),"counter-increment":e,"font-family":"var(--docx-marker-font-family, inherit)","font-size":"var(--docx-marker-font-size, inherit)","font-style":"var(--docx-marker-font-style, inherit)","font-weight":"var(--docx-marker-font-weight, inherit)",...u})}else l=this.numFormatToCssValue(o.format);t+=this.styleToString(i,{display:"list-item","list-style-position":"inside","list-style-type":l,...o.pStyle})}for(const[e,r]of a)t+=this.styleToString(e,{"counter-set":r.join(" ")});return r.length>0&&(t+=this.styleToString(this.rootSelector,{"counter-reset":r.join(" ")})),[this.h({tagName:"#comment",children:["docxjs document numbering styles"]}),this.h({tagName:"style",children:[t]})]}renderStyles(e){var t="";const r=this.styleMap,a=(0,n.keyBy)(e.filter(e=>e.isDefault),e=>e.target);for(const n of e){var s=n.styles;if(n.linked){var o=n.linked&&r[n.linked];o?s=s.concat(o.styles):this.options.debug&&console.warn(`Can't find linked style ${n.linked}`)}for(const e of s){var i=`${n.target??""}.${n.cssName}${e.mod??""}`;n.target!=e.target&&(i+=` ${e.target}`),a[n.target]==n&&(i=`.${this.className} ${n.target}, `+i),t+=this.styleToString(i,e.values)}}return[this.h({tagName:"#comment",children:["docxjs document styles"]}),this.h({tagName:"style",children:[t]})]}renderNotes(e,t,r){var a=e.map(e=>t[e]).filter(e=>e);if(a.length>0){const e=this.currentPart;this.currentPart=r??e;const t=this.renderElements(a);return this.currentPart=e,this.h({tagName:"ol",children:t})}}renderElement(e){switch(e.type){case a.DomType.Paragraph:return this.renderParagraph(e);case a.DomType.BookmarkStart:return this.renderBookmarkStart(e);case a.DomType.BookmarkEnd:return null;case a.DomType.Run:return this.renderRun(e);case a.DomType.Table:return this.renderTable(e);case a.DomType.Row:return this.renderTableRow(e);case a.DomType.Cell:return this.renderTableCell(e);case a.DomType.Hyperlink:return this.renderHyperlink(e);case a.DomType.SmartTag:return this.renderSmartTag(e);case a.DomType.Drawing:return this.renderDrawing(e);case a.DomType.Image:return this.renderImage(e);case a.DomType.Shape:return this.renderShape(e);case a.DomType.Chart:return this.renderChart(e);case a.DomType.SmartArt:return this.renderSmartArt(e);case a.DomType.Ink:return this.renderInk(e);case a.DomType.SimpleField:return this.renderSimpleField(e);case a.DomType.Instruction:case a.DomType.ComplexField:return null;case a.DomType.Text:return this.renderText(e);case a.DomType.DeletedText:return this.renderDeletedText(e);case a.DomType.Tab:return this.renderTab(e);case a.DomType.Symbol:return this.renderSymbol(e);case a.DomType.Break:return this.renderBreak(e);case a.DomType.Footer:return this.renderContainer(e,"footer");case a.DomType.Header:return this.renderContainer(e,"header");case a.DomType.Footnote:case a.DomType.Endnote:return this.renderContainer(e,"li");case a.DomType.FootnoteReference:return this.renderFootnoteReference(e);case a.DomType.EndnoteReference:return this.renderEndnoteReference(e);case a.DomType.NoBreakHyphen:return this.h("‑");case a.DomType.SoftHyphen:return this.h("­");case a.DomType.PositionalTab:return this.renderTab(e);case a.DomType.Ruby:return this.renderRuby(e);case a.DomType.RubyBase:return this.renderContainer(e,"span");case a.DomType.RubyText:return this.toHTML(e,i.ns.html,"rt");case a.DomType.VmlPicture:return this.renderVmlPicture(e);case a.DomType.VmlElement:return this.renderVmlElement(e);case a.DomType.MmlMath:return this.renderContainerNS(e,i.ns.mathML,"math",{xmlns:i.ns.mathML});case a.DomType.MmlMathParagraph:return this.renderMmlMathParagraph(e);case a.DomType.MmlFraction:return this.renderContainerNS(e,i.ns.mathML,"mfrac");case a.DomType.MmlBase:return this.renderContainerNS(e,i.ns.mathML,e.parent?.type==a.DomType.MmlMatrixRow?"mtd":"mrow");case a.DomType.MmlNumerator:case a.DomType.MmlDenominator:case a.DomType.MmlFunction:case a.DomType.MmlLimit:case a.DomType.MmlBox:return this.renderContainerNS(e,i.ns.mathML,"mrow");case a.DomType.MmlGroupChar:return this.renderMmlGroupChar(e);case a.DomType.MmlLimitLower:return this.renderContainerNS(e,i.ns.mathML,"munder");case a.DomType.MmlLimitUpper:return this.renderContainerNS(e,i.ns.mathML,"mover");case a.DomType.MmlSubSuperscript:return this.renderContainerNS(e,i.ns.mathML,"msubsup");case a.DomType.MmlPhantom:return this.renderMmlPhantom(e);case a.DomType.MmlBorderBox:return this.renderContainerNS(e,i.ns.mathML,"menclose");case a.DomType.MmlAccent:return this.renderMmlAccent(e);case a.DomType.MmlMatrix:return this.renderContainerNS(e,i.ns.mathML,"mtable");case a.DomType.MmlMatrixRow:return this.renderContainerNS(e,i.ns.mathML,"mtr");case a.DomType.MmlRadical:return this.renderMmlRadical(e);case a.DomType.MmlSuperscript:return this.renderContainerNS(e,i.ns.mathML,"msup");case a.DomType.MmlSubscript:return this.renderContainerNS(e,i.ns.mathML,"msub");case a.DomType.MmlDegree:case a.DomType.MmlSuperArgument:case a.DomType.MmlSubArgument:return this.renderContainerNS(e,i.ns.mathML,"mrow");case a.DomType.MmlFunctionName:return this.renderContainerNS(e,i.ns.mathML,"mi");case a.DomType.MmlDelimiter:return this.renderMmlDelimiter(e);case a.DomType.MmlRun:return this.renderMmlRun(e);case a.DomType.MmlNary:return this.renderMmlNary(e);case a.DomType.MmlPreSubSuper:return this.renderMmlPreSubSuper(e);case a.DomType.MmlBar:return this.renderMmlBar(e);case a.DomType.MmlEquationArray:return this.renderMllList(e);case a.DomType.Inserted:return this.renderInserted(e);case a.DomType.Deleted:return this.renderDeleted(e);case a.DomType.CommentRangeStart:return this.renderCommentRangeStart(e);case a.DomType.CommentRangeEnd:return this.renderCommentRangeEnd(e);case a.DomType.CommentReference:return this.renderCommentReference(e);case a.DomType.AltChunk:return this.renderAltChunk(e)}return null}renderElements(e,t){if(null==e)return null;const r=[];for(let t=0;t<e.length;t++){const a=this.tryRenderComplexField(e,t);a?(r.push(...(0,n.asArray)(a.node).filter(e=>null!=e)),t=a.nextIndex-1):r.push(...(0,n.asArray)(this.renderElement(e[t])).filter(e=>null!=e))}return t&&r.forEach(e=>t.appendChild((0,n.isString)(e)?document.createTextNode(e):e)),r}tryRenderComplexField(e,t){if(!this.hasFieldChar(e[t],"begin"))return null;let r=0,n=!1,s="";const o=[];for(let i=t;i<e.length;i++){const t=e[i],l=t.type==a.DomType.Run?{...t,fieldRun:!1,children:[]}:null;if(t.type==a.DomType.Run){for(const e of t.children??[]){if(e.type==a.DomType.ComplexField){const t=e;if("begin"==t.charType)r++;else if("separate"==t.charType&&1==r)n=!0;else if("end"==t.charType&&(r--,0==r))return l.children.length>0&&o.push(l),{node:this.renderSimpleField({type:a.DomType.SimpleField,instruction:s,lock:!1,dirty:!1,children:o}),nextIndex:i+1};continue}n||1!=r||e.type!=a.DomType.Instruction?n&&r>0&&l.children.push(e):s+=e.text??""}l.children.length>0&&o.push(l)}else n&&r>0&&o.push(t)}return null}hasFieldChar(e,t){return e.type==a.DomType.Run&&e.children?.some(e=>e.type==a.DomType.ComplexField&&e.charType==t)}renderContainer(e,t){return this.h({tagName:t,children:this.renderElements(e.children)})}renderContainerNS(e,t,r,a){return this.h({ns:t,tagName:r,children:this.renderElements(e.children),...a})}effectiveParagraphTabs(e,t){if(!e?.length)return t;if(!t?.length)return e;const r=[...t];for(const t of e){const e=this.parseCssLengthValue(t.position),a=r.findIndex(t=>this.parseCssLengthValue(t.position)==e);a>=0?r[a]=t:r.push(t)}return r.sort((e,t)=>(this.parseCssLengthValue(e.position)??0)-(this.parseCssLengthValue(t.position)??0))}renderParagraph(e){const t=this.findStyle(e.styleName);e.tabs=this.effectiveParagraphTabs(e.tabs,t?.paragraphProps?.tabs);const r=this.currentParagraph,a=this.currentParagraphTabIndex;this.currentParagraph=e,this.currentParagraphTabIndex=0;const n=this.renderElements(e.children),s=e.props?.deletedParagraphMark&&!this.options.renderChanges;if(s&&!this.hasRenderedContent(n))return this.currentParagraph=r,this.currentParagraphTabIndex=a,null;if(s)return this.currentParagraph=r,this.currentParagraphTabIndex=a,n;var o=this.toHTML(e,i.ns.html,"p",this.wrapTabLeaderChildren(n,!0));this.currentParagraph=r,this.currentParagraphTabIndex=a;const l=e.numbering??t?.paragraphProps?.numbering;l&&o.classList.add(this.numberingClass(l.id,l.level));const c=t?.paragraphProps;(e.pageBreakBefore??c?.pageBreakBefore)&&(o.style.breakBefore="page",o.dataset.docxPageBreakBefore="true"),(e.keepLines??c?.keepLines)&&(o.style.breakInside="avoid",o.dataset.docxKeepLines="true"),(e.keepNext??c?.keepNext)&&(o.style.breakAfter="avoid",o.dataset.docxKeepNext="true"),(e.widowControl??c?.widowControl)&&(o.style.orphans="2",o.style.widows="2",o.dataset.docxWidowControl="true"),this.applyDocumentGridLinePitch(e,t,o);const u=e.tabs?.find(e=>e?.leader&&"none"!=e.leader&&"clear"!=e.style);return u&&(o.classList.add(`${this.className}-tab-leader-paragraph`),o.dataset.docxHasTabLeader="true",o.dataset.docxTabLeader=u.leader,o.dataset.docxTabAlign=u.style),this.isTocParagraphStyle(e.styleName,t)&&(o.classList.add(`${this.className}-toc-paragraph`),o.dataset.docxTocEntry="true"),this.hasParagraphRelativeAnchor(e)&&(o.style.position&&"static"!=o.style.position||(o.style.position="relative"),o.dataset.docxAnchorContext="paragraph"),e.props?.anchorId&&(o.id=e.props.anchorId,o.setAttribute("id",e.props.anchorId)),o}hasParagraphRelativeAnchor(e){for(const t of e.children??[]){if(t.type==a.DomType.Drawing&&"absolute"==t.cssStyle?.position){const e=t.props?.anchorPosition,r=e?.vertical?.relative,a=e?.horizontal?.relative;if("paragraph"==r||"line"==r||"character"==r||"character"==a)return!0}if(this.hasParagraphRelativeAnchor(t))return!0}return!1}renderHyperlink(e){const t=this.renderElements(e.children),r=this.toH(e,i.ns.html,"a",this.wrapTabLeaderChildren(t));if(r.href="",e.id){const t=this.currentPart??this.document.documentPart,a=t?.rels?.find(t=>t.id==e.id&&"External"===t.targetMode);r.href=a?.target??r.href}return!r.href&&e.anchor&&(r.href+=`#${e.anchor}`),this.h(r)}wrapTabLeaderChildren(e,t=!1){if(!e?.length||e.some(e=>this.hasCssClass(e,`${this.className}-tab-leader-title`)))return e;const r=e.findIndex(e=>this.isTabLeaderNode(e));if(r<0)return e;const a=e.slice(0,r),n=e[r],s=e.slice(r+1);this.addCssClass(n,`${this.className}-tab-leader-fill`);const o=[this.h({tagName:"span",className:`${this.className}-tab-leader-title`,children:a}),n,this.h({tagName:"span",className:`${this.className}-tab-leader-page`,children:s})];return t?[this.h({tagName:"span",className:`${this.className}-tab-leader-line`,children:o})]:o}isTabLeaderNode(e){const t=this.nodeDatasetValue(e,"docxTabLeader");return this.hasCssClass(e,this.tabStopClass())&&!!t&&"none"!=t}nodeDatasetValue(e,t){const r=e,a=r?.dataset?.[t];if(null!=a)return String(a);const n="data-"+t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());return"function"==typeof r?.getAttribute?r.getAttribute(n):r?.attributes?.[n]}hasCssClass(e,t){const r=e;return!(!r||!t)&&("function"==typeof r.classList?.contains?r.classList.contains(t):this.nodeClassName(r).split(/\s+/).includes(t))}addCssClass(e,t){const r=e;if(!r||!t||this.hasCssClass(e,t))return;if("function"==typeof r.classList?.add)return void r.classList.add(t);const a=(0,i.cx)(this.nodeClassName(r),t);"function"==typeof r.setAttribute?r.setAttribute("class",a):(r.attributes??(r.attributes={}),r.attributes.class=a)}nodeClassName(e){return"string"==typeof e?.className?e.className:"string"==typeof e?.className?.baseVal?e.className.baseVal:"function"==typeof e?.getAttribute?e.getAttribute("class")??"":e?.attributes?.class??""}renderSmartTag(e){return this.renderContainer(e,"span")}renderCommentRangeStart(e){if(!this.options.renderComments)return null;const t=new Range;this.commentHighlight?.add(t);const r=this.h({tagName:"#comment",children:[`start of comment #${e.id}`]});return this.later(()=>t.setStart(r,0)),this.commentMap[e.id]=t,r}renderCommentRangeEnd(e){if(!this.options.renderComments)return null;const t=this.commentMap[e.id],r=this.h({tagName:"#comment",children:[`end of comment #${e.id}`]});return this.later(()=>t?.setEnd(r,0)),r}renderCommentReference(e){if(!this.options.renderComments)return null;var t=this.document.commentsPart?.commentMap[e.id];if(!t)return null;const r=this.h({tagName:"span",className:`${this.className}-comment-ref`,children:["💬"]}),a=this.h({tagName:"div",className:`${this.className}-comment-popover`,children:[this.h({tagName:"div",className:`${this.className}-comment-author`,children:[t.author]}),this.h({tagName:"div",className:`${this.className}-comment-date`,children:[new Date(t.date).toLocaleString()]}),...this.renderElements(t.children)]});return this.h({tagName:"#fragment",children:[this.h({tagName:"#comment",children:[`comment #${t.id} by ${t.author} on ${t.date}`]}),r,a]})}renderAltChunk(e){if(!this.options.renderAltChunks)return null;var t=this.h({tagName:"iframe",sandbox:"",referrerPolicy:"no-referrer",loading:"lazy"});return this.tasks.push(this.document.loadAltChunk(e.id,this.currentPart).then(e=>{t.srcdoc=e})),t}renderDrawing(e){e.cssStyle?.["shape-outside"]&&(e.className=(0,i.cx)(e.className,`${this.className}-float-wrap`));var t=this.toHTML(e,i.ns.html,"div");return(e.cssStyle?.float||"absolute"==e.cssStyle?.position)&&(t.dataset.docxFloat="true"),t.style.display||(t.style.display="inline-block"),t.style.position||(t.style.position="relative"),t.style.textIndent="0px",t}renderImage(e){let t=this.toHTML(e,i.ns.html,"img",[]),r=e.cssStyle?.transform;if(e.alt&&(t.alt=e.alt),e.title&&(t.title=e.title),e.srcRect&&e.srcRect.some(e=>0!=e)){var[a,n,s,o]=e.srcRect;r=`${r??""} scale(${1/(1-a-s)}, ${1/(1-n-o)})`,t.style.clipPath=`inset(${(100*n).toFixed(2)}% ${(100*s).toFixed(2)}% ${(100*o).toFixed(2)}% ${(100*a).toFixed(2)}%)`,t.style.transformOrigin="top left"}return e.rotation&&(r=`rotate(${e.rotation}deg) ${r??""}`),t.style.transform=r?.trim(),this.document&&e.src&&this.tasks.push(this.document.loadDocumentImage(e.src,this.currentPart).then(e=>{t.src=e,e&&t.setAttribute("src",e)})),t}renderShape(e){if(e.props?.dmlSvg)return this.renderDmlSvgShape(e);const t=e.props?.dmlTextBox?[this.renderDmlTextBox(e)]:null,r=this.toHTML(e,i.ns.html,"div",t);return r.style.display||(r.style.display="inline-block"),e.title&&(r.title=e.title),e.alt&&(r.setAttribute("role","img"),r.setAttribute("aria-label",e.alt)),r}renderDmlTextBox(e){return this.h({tagName:"div",className:`${this.className}-shape-textbox`,style:{"box-sizing":"border-box",display:"flex","flex-direction":"column","justify-content":e.props?.textVerticalAlign??"flex-start","align-items":"stretch",width:"100%",height:"100%",overflow:"hidden",...e.props?.textInsets??{}},children:this.renderElements(e.children)})}renderDmlSvgShape(e){const t=this.createSvgElement("svg",{style:e.cssStyle}),r=e.props??{};t.setAttribute("viewBox",r.viewBox??"0 0 1 1"),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("focusable","false"),e.title&&t.appendChild(this.createSvgElement("title",null,[e.title])),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt));const a=this.createSvgElement("path");return a.setAttribute("d",r.pathD??""),a.setAttribute("fill",r.fill??"none"),a.setAttribute("stroke",r.stroke??"none"),a.setAttribute("stroke-width",r.strokeWidth??"0"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("stroke-linecap","round"),r.strokeDasharray&&a.setAttribute("stroke-dasharray",r.strokeDasharray),t.appendChild(a),t}renderChart(e){const t=this.toHTML(e,i.ns.html,"div",[]);if(t.className=(0,i.cx)(t.className,`${this.className}-chart`),e.title&&(t.title=e.title),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt)),t.appendChild(this.renderGraphicLoading("Chart")),e.id){const r=this.currentPart;this.tasks.push(this.document.loadRelationshipXml(e.id,r).then(e=>{t.textContent="",t.appendChild(e?this.renderChartSvg(e):this.renderGraphicLoading("Chart"))}).catch(()=>{t.textContent="",t.appendChild(this.renderGraphicLoading("Chart"))}))}return t}renderSmartArt(e){const t=this.toHTML(e,i.ns.html,"div",[]);if(t.className=(0,i.cx)(t.className,`${this.className}-smartart`),e.title&&(t.title=e.title),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt)),t.appendChild(this.renderGraphicLoading("SmartArt")),e.dataId){const r=this.currentPart;this.tasks.push(this.document.loadRelationshipXml(e.dataId,r).then(e=>{t.textContent="",t.appendChild(e?this.renderSmartArtSvg(e):this.renderGraphicLoading("SmartArt"))}).catch(()=>{t.textContent="",t.appendChild(this.renderGraphicLoading("SmartArt"))}))}return t}renderInk(e){const t=this.toHTML(e,i.ns.html,"div",[]);if(t.className=(0,i.cx)(t.className,`${this.className}-ink`),e.title&&(t.title=e.title),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt)),t.appendChild(this.renderGraphicLoading("Ink")),e.id){const r=this.currentPart;this.tasks.push(this.document.loadRelationshipText(e.id,r).then(a=>{if(t.textContent="",a?.trim().startsWith("<"))try{return void t.appendChild(this.renderInkSvg((0,l.parseXmlString)(a,!0)))}catch{}return this.document.loadRelationshipBlobUrl(e.id,r).then(r=>{t.textContent="",r?t.appendChild(this.h({tagName:"img",src:r,alt:e.alt??"Ink",style:{width:"100%",height:"100%",objectFit:"contain"}})):t.appendChild(this.renderGraphicLoading("Ink"))})}).catch(()=>{t.textContent="",t.appendChild(this.renderGraphicLoading("Ink"))}))}return t}renderGraphicLoading(e){return this.h({tagName:"span",style:{display:"inline-flex","align-items":"center","justify-content":"center",width:"100%",height:"100%","min-width":"2in","min-height":"1in",border:"1px solid currentColor"},children:[`[${e}]`]})}renderChartSvg(e){const t=e.documentElement,r=this.detectChartType(t),a=this.parseChartSeries(t,r),n=this.createSvgElement("svg",{style:{width:"100%",height:"100%",display:"block"}});n.setAttribute("viewBox","0 0 640 360"),n.setAttribute("preserveAspectRatio","xMidYMid meet");const s=this.extractChartTitle(t);if(s&&n.appendChild(this.svgText(s,320,24,"middle","14px","bold")),0==a.length||a.every(e=>0==e.values.length))return n.appendChild(this.svgText("Chart",320,180,"middle","18px")),n;switch(r){case"pieChart":case"doughnutChart":this.drawPieChart(n,a[0]);break;case"lineChart":case"scatterChart":case"areaChart":this.drawLineChart(n,a,"areaChart"==r);break;default:this.drawBarChart(n,a)}return n}detectChartType(e){return["barChart","bar3DChart","lineChart","pieChart","doughnutChart","areaChart","scatterChart","ofPieChart","radarChart"].find(t=>this.firstByLocal(e,t))??"barChart"}parseChartSeries(e,t){const r=this.firstByLocal(e,t)??e;return this.elementsByLocal(r,"ser").map((e,t)=>{const r=this.firstByLocal(e,"tx"),a=this.firstByLocal(e,"cat")??this.firstByLocal(e,"xVal"),n=this.firstByLocal(e,"val")??this.firstByLocal(e,"yVal"),s=this.chartCacheValues(a),o=this.chartCacheValues(n).map(e=>parseFloat(e)).filter(e=>!Number.isNaN(e));return{name:this.chartText(r)||`Series ${t+1}`,categories:s.length>0?s:o.map((e,t)=>`${t+1}`),values:o}})}chartCacheValues(e){return e?this.elementsByLocal(e,"pt").map(e=>({index:parseInt(e.getAttribute("idx")??"0",10),value:this.firstByLocal(e,"v")?.textContent??""})).sort((e,t)=>e.index-t.index).map(e=>e.value):[]}chartText(e){if(!e)return"";const t=this.chartCacheValues(e);return t.length>0?t.join(" "):this.elementsByLocal(e,"t").map(e=>e.textContent).filter(Boolean).join(" ").trim()}extractChartTitle(e){const t=this.firstByLocal(e,"title");return this.chartText(t)}drawBarChart(e,t){const r=300,a=t[0]?.categories??[],n=Math.max(1,...t.flatMap(e=>e.values)),s=540/Math.max(a.length,1),o=s/Math.max(t.length+1,2);e.appendChild(this.svgLine(60,r,600,r)),e.appendChild(this.svgLine(60,r,60,70)),t.forEach((t,a)=>{t.values.forEach((t,i)=>{const l=Math.max(0,t/n*230),c=this.createSvgElement("rect");c.setAttribute("x",""+(60+i*s+a*o+.2*o)),c.setAttribute("y",""+(r-l)),c.setAttribute("width",""+.8*o),c.setAttribute("height",`${l}`),c.style.fill=this.chartColor(a),e.appendChild(c)})}),a.slice(0,12).forEach((t,r)=>{e.appendChild(this.svgText(t,60+r*s+s/2,318,"middle","10px"))}),t.forEach((t,r)=>this.drawLegend(e,t.name,r,70+130*r,335))}drawLineChart(e,t,r=!1){const a=300,n=Math.max(1,...t.flatMap(e=>e.values)),s=Math.max(...t.map(e=>e.values.length),1),o=540/Math.max(s-1,1);e.appendChild(this.svgLine(60,a,600,a)),e.appendChild(this.svgLine(60,a,60,70)),t.forEach((t,s)=>{const i=t.values.map((e,t)=>[60+t*o,a-e/n*230]),l=this.createSvgElement("path");if(l.setAttribute("d",i.map((e,t)=>`${0==t?"M":"L"}${e[0]},${e[1]}`).join(" ")),l.style.stroke=this.chartColor(s),l.style.strokeWidth="2",l.style.fill="none",e.appendChild(l),r&&i.length>1){const t=this.createSvgElement("path");t.setAttribute("d",`${i.map((e,t)=>`${0==t?"M":"L"}${e[0]},${e[1]}`).join(" ")} L${i[i.length-1][0]},300 L${i[0][0]},300 Z`),t.style.fill=this.chartColor(s),t.style.opacity="0.25",e.appendChild(t)}for(const[t,r]of i){const a=this.createSvgElement("circle");a.setAttribute("cx",`${t}`),a.setAttribute("cy",`${r}`),a.setAttribute("r","3"),a.style.fill=this.chartColor(s),e.appendChild(a)}}),(t[0]?.categories??[]).slice(0,12).forEach((t,r)=>{e.appendChild(this.svgText(t,60+r*o,318,"middle","10px"))}),t.forEach((t,r)=>this.drawLegend(e,t.name,r,70+130*r,335))}drawPieChart(e,t){const r=t.values,a=t.categories,n=r.reduce((e,t)=>e+Math.max(0,t),0)||1;let s=-90;r.forEach((t,r)=>{const o=Math.max(0,t)/n*360,i=this.createSvgElement("path");i.setAttribute("d",this.pieSlicePath(300,180,110,s,s+o)),i.style.fill=this.chartColor(r),e.appendChild(i),this.drawLegend(e,a[r]??`${r+1}`,r,450,90+22*r),s+=o})}pieSlicePath(e,t,r,a,n){const s=this.polar(e,t,r,n),o=this.polar(e,t,r,a),i=n-a<=180?"0":"1";return`M${e},${t} L${s.x},${s.y} A${r},${r} 0 ${i},0 ${o.x},${o.y} Z`}polar(e,t,r,a){const n=(a-90)*Math.PI/180;return{x:e+r*Math.cos(n),y:t+r*Math.sin(n)}}drawLegend(e,t,r,a,n){const s=this.createSvgElement("rect");s.setAttribute("x",`${a}`),s.setAttribute("y",""+(n-10)),s.setAttribute("width","10"),s.setAttribute("height","10"),s.style.fill=this.chartColor(r),e.appendChild(s),e.appendChild(this.svgText(t,a+14,n,"start","10px"))}chartColor(e){return`hsl(${47*e%360}, 65%, 48%)`}renderSmartArtSvg(e){const t=e.documentElement,r=this.elementsByLocal(t,"pt").map(e=>({id:e.getAttribute("modelId"),type:e.getAttribute("type"),text:this.elementsByLocal(e,"t").map(e=>e.textContent).filter(Boolean).join(" ").trim()})).filter(e=>e.id&&e.text&&"doc"!=e.type),a=this.elementsByLocal(t,"cxn").map(e=>({src:e.getAttribute("srcId"),dst:e.getAttribute("destId")})).filter(e=>e.src&&e.dst&&r.some(t=>t.id==e.src)&&r.some(t=>t.id==e.dst)),n=this.createSvgElement("svg",{style:{width:"100%",height:"100%",display:"block"}});if(n.setAttribute("viewBox","0 0 640 360"),n.setAttribute("preserveAspectRatio","xMidYMid meet"),0==r.length)return n.appendChild(this.svgText("SmartArt",320,180,"middle","18px")),n;const s=this.layoutDiagramNodes(r,a),o={},i=Math.min(90,260/Math.max(s.length,1));s.forEach((e,t)=>{const r=55+t*i,a=560/Math.max(e.length,1);e.forEach((e,t)=>{o[e.id]={x:40+a*t+Math.max(0,a-140)/2,y:r}})});for(const e of a){const t=o[e.src],r=o[e.dst];t&&r&&n.appendChild(this.svgLine(t.x+70,t.y+44,r.x+70,r.y))}return r.forEach((e,t)=>{const r=o[e.id];if(!r)return;const a=this.createSvgElement("rect");a.setAttribute("x",`${r.x}`),a.setAttribute("y",`${r.y}`),a.setAttribute("width","140"),a.setAttribute("height","44"),a.setAttribute("rx","8"),a.style.fill=this.chartColor(t),a.style.opacity="0.18",a.style.stroke=this.chartColor(t),n.appendChild(a),n.appendChild(this.svgText(e.text,r.x+70,r.y+27,"middle","11px"))}),n}layoutDiagramNodes(e,t){const r=new Map(e.map(e=>[e.id,0]));t.forEach(e=>r.set(e.dst,(r.get(e.dst)??0)+1));let a=e.filter(e=>0==(r.get(e.id)??0));const n=new Set,s=[];for(0==a.length&&(a=e.slice(0,1));a.length>0;){s.push(a),a.forEach(e=>n.add(e.id));const r=t.filter(e=>a.some(t=>t.id==e.src)).map(e=>e.dst).filter(e=>!n.has(e));a=[...new Set(r)].map(t=>e.find(e=>e.id==t)).filter(Boolean)}const o=e.filter(e=>!n.has(e.id));return o.length>0&&s.push(o),s}renderInkSvg(e){const t=this.createSvgElement("svg",{style:{width:"100%",height:"100%",display:"block"}});t.setAttribute("viewBox","0 0 640 360"),t.setAttribute("preserveAspectRatio","xMidYMid meet");const r=this.elementsByLocal(e.documentElement,"trace").map(e=>this.inkTraceToPoints(e.textContent)),a=this.elementsByLocal(e.documentElement,"path").map(e=>e.getAttribute("d")).filter(Boolean);if(0==r.length&&0==a.length)return t.appendChild(this.svgText("Ink",320,180,"middle","18px")),t;const n=r.flat(),s=Math.min(...n.map(e=>e[0]),0),o=Math.min(...n.map(e=>e[1]),0),i=Math.max(...n.map(e=>e[0]),640),l=Math.max(...n.map(e=>e[1]),360),c=Math.min(600/Math.max(i-s,1),320/Math.max(l-o,1)),u=20-s*c,d=20-o*c;for(const e of r){if(e.length<2)continue;const r=this.createSvgElement("path");r.setAttribute("d",e.map((e,t)=>`${0==t?"M":"L"}${e[0]*c+u},${e[1]*c+d}`).join(" ")),r.style.fill="none",r.style.stroke="currentColor",r.style.strokeWidth="2",r.style.strokeLinecap="round",r.style.strokeLinejoin="round",t.appendChild(r)}for(const e of a){const r=this.createSvgElement("path");r.setAttribute("d",e),r.style.fill="none",r.style.stroke="currentColor",r.style.strokeWidth="2",t.appendChild(r)}return t}inkTraceToPoints(e){const t=(e??"").match(/-?\d+(?:\.\d+)?/g)?.map(Number)??[],r=[];for(let e=0;e+1<t.length;e+=2)r.push([t[e],t[e+1]]);return r}svgLine(e,t,r,a){const n=this.createSvgElement("line");return n.setAttribute("x1",`${e}`),n.setAttribute("y1",`${t}`),n.setAttribute("x2",`${r}`),n.setAttribute("y2",`${a}`),n.style.stroke="currentColor",n.style.strokeWidth="1",n}svgText(e,t,r,a="start",n="12px",s=null){const o=this.createSvgElement("text");return o.setAttribute("x",`${t}`),o.setAttribute("y",`${r}`),o.setAttribute("text-anchor",a),o.style.fill="currentColor",o.style.fontSize=n,s&&(o.style.fontWeight=s),o.appendChild(document.createTextNode(e)),o}elementsByLocal(e,t){const r=e.documentElement??e;return Array.from(r.getElementsByTagName("*")).filter(e=>e.localName==t)}firstByLocal(e,t){return this.elementsByLocal(e,t)[0]??null}renderSimpleField(e){const t=this.evaluateFieldNode(e);return void 0===t?this.renderElements(e.children??[]):null==t?null:(0,n.isString)(t)?this.renderFieldText(t,e.instruction):t}renderFieldText(e,t){const r=this.h({tagName:"span",className:`${this.className}-field`,children:[e]});return t&&(r.dataset.docxFieldInstr=t),r}evaluateFieldNode(e){const t=(e.instruction??"").replace(/\s+/g," ").trim();if(!t)return;if(t.startsWith("=")){const e=this.evaluateFormula(t.substring(1));return null==e?void 0:this.applyFieldFormatting(`${e}`,t)}const r=this.tokenizeFieldInstruction(t),a=r[0]?.replace(/^=/,"").toUpperCase();if(!this.shouldPreserveStoredFieldResult(a,e))switch(a){case"PAGE":return this.applyFieldFormatting(this.formatFieldNumber(this.currentPageNumber,this.currentSectionProps?.pageNumber?.format),t);case"NUMPAGES":return this.applyFieldFormatting(this.formatFieldNumber(this.totalPages,this.currentSectionProps?.pageNumber?.format),t);case"SECTIONPAGES":return this.applyFieldFormatting(this.formatFieldNumber(this.sectionPageCount,this.currentSectionProps?.pageNumber?.format),t);case"SECTION":return this.applyFieldFormatting(this.formatFieldNumber(this.currentSectionNumber,"decimal"),t);case"DATE":case"TIME":case"CREATEDATE":case"SAVEDATE":case"PRINTDATE":return this.applyFieldFormatting(this.evaluateDateField(r,a),t);case"AUTHOR":return this.applyFieldFormatting(this.document.corePropsPart?.props?.creator??"",t);case"TITLE":return this.applyFieldFormatting(this.document.corePropsPart?.props?.title??"",t);case"SUBJECT":return this.applyFieldFormatting(this.document.corePropsPart?.props?.subject??"",t);case"KEYWORDS":return this.applyFieldFormatting(this.document.corePropsPart?.props?.keywords??"",t);case"NUMWORDS":return this.applyFieldFormatting(`${this.document.extendedPropsPart?.props?.words??""}`,t);case"NUMCHARS":return this.applyFieldFormatting(`${this.document.extendedPropsPart?.props?.characters??""}`,t);case"FILENAME":return this.applyFieldFormatting(this.document.documentPart?.path?.split("/").pop()??"",t);case"DOCPROPERTY":return this.applyFieldFormatting(this.evaluateDocPropertyField(r),t);case"DOCVARIABLE":return this.applyFieldFormatting(this.evaluateDocVariableField(r),t);case"MERGEFIELD":return;case"SET":return this.evaluateSetField(r),null;case"QUOTE":return this.applyFieldFormatting(r.slice(1).map(e=>this.resolveFieldValue(e)).join(""),t);case"HYPERLINK":return this.renderHyperlinkField(r,e);case"IF":return this.applyFieldFormatting(this.evaluateIfField(r),t);case"REF":case"STYLEREF":case"NOTEREF":return this.applyFieldFormatting(this.evaluateRefField(r),t);case"PAGEREF":return this.applyFieldFormatting(this.evaluatePageRefField(r),t);case"SEQ":return this.applyFieldFormatting(this.evaluateSeqField(r),t);case"LISTNUM":return this.applyFieldFormatting(this.evaluateListNumField(r),t);case"TC":case"XE":return null;case"TOC":return this.renderTocField(r);case"SYMBOL":return this.evaluateSymbolField(r)}}shouldPreserveStoredFieldResult(e,t){if(!this.options.preserveComplexFieldResults||!t.children?.length)return!1;switch(e){case"PAGE":case"NUMPAGES":case"SECTIONPAGES":case"SECTION":return!1;case"PAGEREF":return!this.options.updatePageReferences;case"TOC":case"REF":case"STYLEREF":case"NOTEREF":case"SEQ":case"LISTNUM":case"IF":case"DOCVARIABLE":case"MERGEFIELD":return!0}return!1}tokenizeFieldInstruction(e){const t=[];let r="",a=null,n=!1;for(const s of e)n?(r+=s,n=!1):"\\"!=s?'"'!=s&&"'"!=s?!/\s/.test(s)||a?r+=s:r&&(t.push(r),r=""):a==s?(a=null,t.push(r),r=""):a?r+=s:(r.trim()&&t.push(r.trim()),r="",a=s):a?n=!0:(r&&(t.push(r),r=""),r="\\");return r&&t.push(r),t}fieldSwitch(e,t){const r=t.toLowerCase(),a=e.findIndex(e=>e.toLowerCase()==r);return a>=0?e[a+1]:null}hasFieldSwitch(e,t){const r=t.toLowerCase();return e.some(e=>e.toLowerCase()==r)}firstFieldArgument(e,t=1){for(let r=t;r<e.length;r++){if(!e[r]?.startsWith("\\"))return e[r];r++}return null}evaluateDateField(e,t){const r=this.fieldSwitch(e,"\\@"),a=new Date;return r?this.formatFieldDate(a,r):"TIME"==t?a.toLocaleTimeString():a.toLocaleDateString()}formatFieldDate(e,t){const r=(e,t=2)=>`${e}`.padStart(t,"0"),a=["January","February","March","April","May","June","July","August","September","October","November","December"],n=a.map(e=>e.substring(0,3)),s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],o=s.map(e=>e.substring(0,3)),i=[[/yyyy/g,`${e.getFullYear()}`],[/yy/g,r(e.getFullYear()%100)],[/MMMM/g,a[e.getMonth()]],[/MMM/g,n[e.getMonth()]],[/MM/g,r(e.getMonth()+1)],[/M/g,`${e.getMonth()+1}`],[/dddd/g,s[e.getDay()]],[/ddd/g,o[e.getDay()]],[/dd/g,r(e.getDate())],[/d/g,`${e.getDate()}`],[/HH/g,r(e.getHours())],[/H/g,`${e.getHours()}`],[/hh/g,r((e.getHours()+11)%12+1)],[/h/g,""+((e.getHours()+11)%12+1)],[/mm/g,r(e.getMinutes())],[/m/g,`${e.getMinutes()}`],[/ss/g,r(e.getSeconds())],[/s/g,`${e.getSeconds()}`],[/AM\/PM/g,e.getHours()<12?"AM":"PM"],[/am\/pm/g,e.getHours()<12?"am":"pm"]];let l=t;for(const[e,t]of i)l=l.replace(e,t);return l}evaluateDocPropertyField(e){const t=this.firstFieldArgument(e)?.toLowerCase();if(!t)return"";const r={...this.document.corePropsPart?.props??{},...this.document.extendedPropsPart?.props??{}};for(const[e,a]of Object.entries(r))if(e.toLowerCase()==t)return null==a?"":`${a}`;return""}evaluateSetField(e){const t=this.firstFieldArgument(e);if(!t)return;const r=e.slice(e.indexOf(t)+1).filter(e=>!e.startsWith("\\")).map(e=>this.resolveFieldValue(e)).join(" ");this.fieldSetValues[t]=r}evaluateDocVariableField(e){const t=this.firstFieldArgument(e);return t?this.fieldSetValues[t]??"":""}renderHyperlinkField(e,t){const r=this.fieldSwitch(e,"\\l"),a=this.firstFieldArgument(e)??"",n=r?`${a}#${r}`:a,s=this.h({tagName:"a",href:n,children:this.renderElements(t.children??[])});return s.textContent||(s.textContent=n||r),s}evaluateIfField(e){const t=["<>",">=","<=","=",">","<"],r=e.findIndex((e,r)=>r>0&&t.includes(e));if(r<0)return"";const a=this.resolveFieldValue(e.slice(1,r).join(" ")),n=e[r],s=this.resolveFieldValue(e[r+1]??""),o=e[r+2]??"",i=e[r+3]??"",l=parseFloat(a),c=parseFloat(s),u=!Number.isNaN(l)&&!Number.isNaN(c),d=u?l:a,h=u?c:s;let p=!1;switch(n){case"=":p=d==h;break;case"<>":p=d!=h;break;case">":p=d>h;break;case"<":p=d<h;break;case">=":p=d>=h;break;case"<=":p=d<=h}return this.resolveFieldValue(p?o:i)}resolveFieldValue(e){const t=(e??"").trim();if(/^[-+]?\d+(?:\.\d+)?$/.test(t))return t;if(this.bookmarkTextMap.hasOwnProperty(t))return this.bookmarkTextMap[t];if(this.fieldSetValues.hasOwnProperty(t))return this.fieldSetValues[t];if(t.startsWith("=")){const e=this.evaluateFormula(t.substring(1));return null==e?"":`${e}`}const r=this.tokenizeFieldInstruction(t)[0]?.toUpperCase();if(["PAGE","NUMPAGES","SECTIONPAGES","SECTION","DATE","TIME","AUTHOR","TITLE","SUBJECT","KEYWORDS","REF","PAGEREF","SEQ","DOCPROPERTY"].includes(r)){const e=this.evaluateFieldNode({type:a.DomType.SimpleField,instruction:t,lock:!1,dirty:!1,children:[]});if((0,n.isString)(e))return e}return t}evaluateRefField(e){const t=this.firstFieldArgument(e);return t?this.bookmarkTextMap[t]??this.fieldSetValues[t]??"":""}evaluatePageRefField(e){const t=this.firstFieldArgument(e);return t?`${null!=this.bookmarkTextMap[t]?Math.max(this.currentPageNumber,1):1}`:""}evaluateSeqField(e){const t=this.firstFieldArgument(e);if(!t)return"";if(this.hasFieldSwitch(e,"\\h"))return"";const r=this.fieldSwitch(e,"\\r"),a=this.hasFieldSwitch(e,"\\c");null!=r?this.fieldSeqCounters[t]=parseInt(r,10)||0:a||(this.fieldSeqCounters[t]=(this.fieldSeqCounters[t]??0)+1);const n=this.fieldSwitch(e,"\\*")??"decimal";return this.formatFieldNumber(this.fieldSeqCounters[t]??0,this.fieldFormatSwitchToNumFormat(n))}evaluateListNumField(e){const t=this.firstFieldArgument(e)??"LISTNUM";this.fieldSeqCounters[t]=(this.fieldSeqCounters[t]??0)+1;const r=this.fieldSwitch(e,"*")??"decimal";return this.formatFieldNumber(this.fieldSeqCounters[t],this.fieldFormatSwitchToNumFormat(r))}renderTocField(e){let t=1,r=9;const a=this.fieldSwitch(e,"\\o");if(a){const e=/(\d+)\s*-\s*(\d+)/.exec(a);e&&(t=parseInt(e[1],10),r=parseInt(e[2],10))}const n=this.tocEntries.filter(e=>e.level>=t&&e.level<=r).map(e=>{const t=this.h({tagName:"span",className:`${this.className}-toc-page`,children:["1"]});return t.dataset.docxPageRef=e.id,this.h({tagName:"div",className:`${this.className}-toc-entry ${this.className}-toc-level-${e.level}`,children:[this.h({tagName:"a",className:`${this.className}-toc-title`,href:`#${e.id}`,children:[e.text]}),t]})});return this.h({tagName:"div",className:`${this.className}-toc`,children:n})}evaluateSymbolField(e){const t=parseInt(e[1],10);return Number.isFinite(t)?String.fromCharCode(t):""}evaluateFormula(e){const t=e.replace(/,/g,"").trim();if(!/^[0-9+\-*/().\s]+$/.test(t))return null;try{const e=Function(`"use strict"; return (${t});`)();return Number.isFinite(e)?e:null}catch{return null}}applyFieldFormatting(e,t){const r=this.tokenizeFieldInstruction(t);let a=e??"";const n=this.fieldSwitch(r,"\\*"),s=n?.toUpperCase(),o=this.fieldSwitch(r,"\\#");if(o){const e=parseFloat(a);Number.isNaN(e)||(a=this.formatNumberPicture(e,o))}switch(s){case"UPPER":a=a.toUpperCase();break;case"LOWER":a=a.toLowerCase();break;case"FIRSTCAP":a=a.substring(0,1).toUpperCase()+a.substring(1).toLowerCase();break;case"CAPS":a=a.replace(/\b\w/g,e=>e.toUpperCase());break;case"ROMAN":{const e=parseInt(a,10);Number.isNaN(e)||(a="roman"==n?this.toRoman(e).toLowerCase():this.toRoman(e).toUpperCase());break}case"ALPHABETIC":{const e=parseInt(a,10);Number.isNaN(e)||(a="alphabetic"==n?this.toLetters(e).toLowerCase():this.toLetters(e).toUpperCase());break}}return a}formatNumberPicture(e,t){const r=t.indexOf("."),a=r>=0?t.length-r-1:0;let n=e.toFixed(a);if(t.includes(",")){const[e,t]=n.split(".");n=e.replace(/\B(?=(\d{3})+(?!\d))/g,",")+(null!=t?`.${t}`:"")}return n}fieldFormatSwitchToNumFormat(e){if("roman"==e)return"lowerRoman";if("alphabetic"==e)return"lowerLetter";switch(e?.toUpperCase()){case"ROMAN":return"upperRoman";case"ALPHABETIC":return"upperLetter";default:return"decimal"}}formatFieldNumber(e,t){switch(t){case"upperRoman":return this.toRoman(e).toUpperCase();case"lowerRoman":return this.toRoman(e).toLowerCase();case"upperLetter":return this.toLetters(e).toUpperCase();case"lowerLetter":return this.toLetters(e).toLowerCase();case"decimalZero":return e<10?`0${e}`:`${e}`;default:return`${e}`}}toRoman(e){const t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let r=Math.max(Math.floor(e),0),a="";for(const[e,n]of t)for(;r>=e;)a+=n,r-=e;return a||`${e}`}toLetters(e){let t=Math.max(Math.floor(e),1),r="";for(;t>0;)t--,r=String.fromCharCode(65+t%26)+r,t=Math.floor(t/26);return r}renderRuby(e){const t=e.children?.find(e=>e.type==a.DomType.RubyBase),r=e.children?.find(e=>e.type==a.DomType.RubyText),s=[...t?this.renderElements(t.children):[],...r?(0,n.asArray)(this.renderElement(r)).filter(e=>null!=e):[]],o=this.h({tagName:"ruby",children:s});return e.align&&(o.style.rubyAlign=e.align),o}hasRenderedContent(e){for(const t of e??[]){if(!t)continue;const e=t,r=e.nodeType,a=String(e.localName??e.tagName??e.nodeName??"").toLowerCase();if(3==r||"#text"==a){if((e.textContent??e.text??e.data??"").length)return!0;continue}if(["br","img","svg","math","table"].includes(a))return!0;if((e.textContent??"").length)return!0;const n=Array.from(e.childNodes??e.children??[]);if(n.length&&this.hasRenderedContent(n))return!0}return!1}renderText(e){return this.h(this.applyCjkLineBreakGuards(e.text))}applyCjkLineBreakGuards(e){if(!e||!this.document.settingsPart?.settings?.kinsoku)return e;const t=this.document.settingsPart.settings.noLineBreaksBefore??"!),.:;?]}¢°·'\"†‡›℃∶、。々〉》」』】〕〗〙〛〜゠ァィゥェォッャュョヮ・ー-?!%,.:;゛゜ヽヾゝゞー",r=this.document.settingsPart.settings.noLineBreaksAfter??"([{$£¥'\"“‘〈《「『【〔〖〘〚";let a="";for(const n of e)t.includes(n)&&(a+="⁠"),a+=n,r.includes(n)&&(a+="⁠");return a}renderDeletedText(e){return this.options.renderChanges?this.renderText(e):null}renderBreak(e){switch(e.break){case"textWrapping":case"line":return this.h({tagName:"br"});case"column":return this.h({tagName:"span",style:{breakAfter:"column"}});case"page":return this.options.breakPages?null:this.h({tagName:"span",style:{breakAfter:"page"}});case"lastRenderedPageBreak":return this.options.breakPages||this.options.ignoreLastRenderedPageBreak?null:this.h({tagName:"span",style:{breakAfter:"page"}})}return null}renderInserted(e){return this.options.renderChanges?this.renderContainer(e,"ins"):this.renderElements(e.children)}renderDeleted(e){return this.options.renderChanges?this.renderContainer(e,"del"):null}renderSymbol(e){return this.h({tagName:"span",children:[String.fromCharCode(e.char)],style:{fontFamily:e.font}})}renderFootnoteReference(e){return this.currentFootnoteIds.push(e.id),this.h({tagName:"sup",children:[`${this.currentFootnoteIds.length}`]})}renderEndnoteReference(e){return this.currentEndnoteIds.push(e.id),this.h({tagName:"sup",children:[`${this.currentEndnoteIds.length}`]})}renderTab(e){const t=this.currentParagraph??function(e,t){for(var r=e.parent;null!=r&&r.type!=t;)r=r.parent;return r}(e,a.DomType.Paragraph),r=t?.tabs??[],n=r.filter(e=>"clear"!=e?.style),s=this.currentParagraphTabIndex++,o=n[Math.min(s,Math.max(n.length-1,0))];var i=this.h({tagName:"span",className:this.tabStopClass(),children:[" "]});return i.dataset.docxTab="true",o&&(i.dataset.docxTabAlign=o.style??"left",i.dataset.docxTabLeader=o.leader??"none",o.position&&(i.dataset.docxTabPos=o.position)),this.options.experimental&&this.currentTabs.push({stops:r,span:i}),i}renderBookmarkStart(e){const t=this.h({tagName:"span"});return e.name&&(t.id=e.name,t.setAttribute("id",e.name)),t}renderRun(e){const t=e.fieldRun?e.children?.filter(e=>e.type!=a.DomType.Instruction&&e.type!=a.DomType.ComplexField):e.children;if(e.fieldRun&&(!t||0==t.length))return null;let r=this.renderElements(t);if(e.verticalAlign&&(r=[this.h({tagName:e.verticalAlign,children:this.renderElements(t)})]),!e.verticalAlign&&1==t?.length&&(t[0].type==a.DomType.Tab||t[0].type==a.DomType.PositionalTab)&&1==r?.length){const t=r[0];return e.cssStyle&&Object.assign(t.style,e.cssStyle),e.className&&t.classList.add(e.className),t}const n=this.toHTML(e,i.ns.html,"span",r);return e.id&&(n.id=e.id),n}renderTable(e){this.tableCellPositions.push(this.currentCellPosition),this.tableVerticalMerges.push(this.currentVerticalMerge),this.currentVerticalMerge={},this.currentCellPosition={col:0,row:0};const t=[];return e.columns&&t.push(this.renderTableColumns(e.columns)),t.push(...this.renderElements(e.children)),this.currentVerticalMerge=this.tableVerticalMerges.pop(),this.currentCellPosition=this.tableCellPositions.pop(),this.toHTML(e,i.ns.html,"table",t)}renderTableColumns(e){const t=e.map(e=>this.h({tagName:"col",style:{width:e.width}}));return this.h({tagName:"colgroup",children:t})}renderTableRow(e){this.currentCellPosition.col=0;const t=[],r=this.currentTableRow;this.currentTableRow=e,e.gridBefore&&t.push(this.renderTableCellPlaceholder(e.gridBefore)),t.push(...this.renderElements(e.children)),e.gridAfter&&t.push(this.renderTableCellPlaceholder(e.gridAfter)),this.currentTableRow=r,this.currentCellPosition.row++;const a=this.toHTML(e,i.ns.html,"tr",t);return e.isHeader&&(a.dataset.docxRepeatHeader="true"),a}renderTableCellPlaceholder(e){return this.h({tagName:"td",colSpan:e,style:{border:"none"}})}renderTableCell(e){const t=this.currentTableRow?.isHeader?"th":"td";let r=this.toHTML(e,i.ns.html,t);const a=this.currentCellPosition.col;return e.verticalMerge?"restart"==e.verticalMerge?(this.currentVerticalMerge[a]=r,r.rowSpan=1):this.currentVerticalMerge[a]&&(this.currentVerticalMerge[a].rowSpan+=1,r.style.display="none"):this.currentVerticalMerge[a]=null,e.span&&(r.colSpan=e.span),this.currentCellPosition.col+=r.colSpan,r}renderVmlPicture(e){return this.renderContainer(e,"div")}renderVmlElement(e){var t=this.h({ns:i.ns.svg,tagName:"svg",style:e.cssStyleText});const r=this.renderVmlChildElement(e);e.imageHref?.id&&this.tasks.push(this.document?.loadDocumentImage(e.imageHref.id,this.currentPart).then(e=>r.setAttribute("href",e))),t.appendChild(r);const a=globalThis.requestAnimationFrame;return("function"==typeof a?a.bind(globalThis):e=>setTimeout(()=>e(Date.now()),0))(()=>{try{const e=t.firstElementChild,r="function"==typeof e?.getBBox?e.getBBox():null;r&&Number.isFinite(r.width)&&Number.isFinite(r.height)&&r.width>0&&r.height>0&&(t.setAttribute("width",`${Math.ceil(r.x+r.width)}`),t.setAttribute("height",`${Math.ceil(r.y+r.height)}`))}catch{}}),t}renderVmlChildElement(e){const t=this.createSvgElement(e.tagName);Object.entries(e.attrs).forEach(([e,r])=>t.setAttribute(e,r));for(let r of e.children)if(r.type==a.DomType.VmlElement)t.appendChild(this.renderVmlChildElement(r));else for(const e of(0,n.asArray)(this.renderElement(r)).filter(e=>null!=e))t.appendChild((0,n.isString)(e)?document.createTextNode(e):e);return t}renderMmlMathParagraph(e){const t=this.renderElements(e.children);for(const e of t)"math"==e?.localName&&e.setAttribute("display","block");return this.h({tagName:"div",className:`${this.className}-math-paragraph`,style:{textAlign:"center"},children:t})}renderMmlPhantom(e){return this.renderContainerNS(e,i.ns.mathML,"mphantom")}renderMmlAccent(e){const t=e.children?.find(e=>e.type==a.DomType.MmlBase),r=this.createMathMLElement("mo",null,[e.props?.char??"^"]),s=t?(0,n.asArray)(this.renderElement(t)).filter(e=>null!=e):[];return this.createMathMLElement("mover",null,[...s,r])}renderMmlRadical(e){const t=e.children.find(e=>e.type==a.DomType.MmlBase);if(e.props?.hideDegree)return this.createMathMLElement("msqrt",null,this.renderElements([t]));const r=e.children.find(e=>e.type==a.DomType.MmlDegree);return this.createMathMLElement("mroot",null,this.renderElements([t,r]))}renderMmlDelimiter(e){const t=[],r=e.props?.beginChar,a=e.props?.endChar;return""!==r&&t.push(this.createMathMLElement("mo",null,[r??"("])),t.push(...this.renderElements(e.children)),""!==a&&t.push(this.createMathMLElement("mo",null,[a??")"])),this.createMathMLElement("mrow",null,t)}renderMmlNary(e){const t=[],r=(0,n.keyBy)(e.children,e=>e.type),s=r[a.DomType.MmlSuperArgument],o=r[a.DomType.MmlSubArgument],i=s?this.createMathMLElement("mrow",null,this.renderElements(s.children)):null,l=o?this.createMathMLElement("mrow",null,this.renderElements(o.children)):null,c=this.createMathMLElement("mo",null,[e.props?.char??"∫"]);return i&&l?t.push(this.createMathMLElement("munderover",null,[c,l,i])):i?t.push(this.createMathMLElement("mover",null,[c,i])):l?t.push(this.createMathMLElement("munder",null,[c,l])):t.push(c),r[a.DomType.MmlBase]&&t.push(...this.renderElements(r[a.DomType.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlPreSubSuper(e){const t=[],r=(0,n.keyBy)(e.children,e=>e.type),s=r[a.DomType.MmlSuperArgument],o=r[a.DomType.MmlSubArgument],i=this.createMathMLElement("mrow",null,s?this.renderElements(s.children):[]),l=this.createMathMLElement("mrow",null,o?this.renderElements(o.children):[]),c=this.createMathMLElement("mrow",null,[]);return t.push(this.createMathMLElement("msubsup",null,[c,l,i])),r[a.DomType.MmlBase]&&t.push(...this.renderElements(r[a.DomType.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlGroupChar(e){const t="bot"===e.props?.verticalJustification?"munder":"mover",r=this.createMathMLElement("mrow",null,this.renderElements(e.children)),a=this.createMathMLElement("mo",null,[e.props?.char??"⏞"]);return this.createMathMLElement(t,null,[r,a])}renderMmlBar(e){const t={};switch(e.props.position){case"top":t.textDecoration="overline";break;case"bottom":t.textDecoration="underline"}return this.renderContainerNS(e,i.ns.mathML,"mrow",{style:t})}renderMmlRun(e){const t=this.extractMathRunText(e);if(null!=t){const r=this.renderMathTextTokens(t,e.cssStyle);return r.length?r:null}return this.renderContainerNS(e,i.ns.mathML,"mrow")}extractMathRunText(e){let t="";for(const r of e.children??[])switch(r.type){case a.DomType.Text:t+=r.text??"";break;case a.DomType.DeletedText:this.options.renderChanges&&(t+=r.text??"");break;case a.DomType.Symbol:t+=String.fromCharCode(r.char);break;case a.DomType.Tab:t+=" ";break;case a.DomType.NoBreakHyphen:t+="‑";break;case a.DomType.SoftHyphen:break;default:return null}return t}renderMathTextTokens(e,t){const r=[];let a=0;for(;a<e.length;){const n=e[a];if(/\s/.test(n)){let t=a+1;for(;t<e.length&&/\s/.test(e[t]);)t++;r.push(this.createMathMLElement("mspace",{width:.25*Math.max(1,t-a)+"em"})),a=t;continue}if(c(n)){let n=a+1;for(;n<e.length&&(c(e[n])||"."==e[n]);)n++;r.push(this.createMathToken("mn",e.substring(a,n),t)),a=n;continue}if(u(n)){let n=a+1;for(;n<e.length&&u(e[n]);)n++;r.push(this.createMathToken("mi",e.substring(a,n),t)),a=n;continue}d(n)?r.push(this.createMathToken("mo",n,t)):r.push(this.createMathToken("mtext",n,t)),a++}return r}createMathToken(e,t,r){return this.createMathMLElement(e,r?{style:r}:null,[t])}renderMllList(e){const t=this.renderElements(e.children).map(e=>this.createMathMLElement("mtr",null,[this.createMathMLElement("mtd",null,[e])]));return this.toHTML(e,i.ns.mathML,"mtable",t)}toH(e,t,r,a=null){const{$lang:n,...s}=e.cssStyle??{};return{ns:t,tagName:r,className:(0,i.cx)(e.className,e.styleName&&this.processStyleName(e.styleName)),lang:n,style:s,children:a??this.renderElements(e.children)}}toHTML(e,t,r,a=null){return this.h(this.toH(e,t,r,a))}findStyle(e){return e&&this.styleMap?.[e]}isTocParagraphStyle(e,t){return[e,t?.id,t?.name,t?.cssName,...t?.aliases??[]].filter(Boolean).map(e=>String(e).replace(/[\s_-]+/g,"").toLowerCase()).some(e=>/^toc[1-9]$/.test(e))}numberingClass(e,t){return`${this.className}-num-${e}-${t}`}tabStopClass(){return`${this.className}-tab-stop`}styleToString(e,t,r=null){let a=`${e} {\r\n`;for(const e in t)e.startsWith("$")||(a+=` ${e}: ${t[e]};\r\n`);return r&&(a+=r),a+"}\r\n"}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}numberingRestartLevel(e){if(e.level<=0)return null;if(null==e.restart)return e.level-1;if(0==e.restart)return null;const t=e.restart-1;return t>=0&&t<e.level?t:null}numberingMarkerRunStyle(e,t){if(!e)return e;const r={...e};return t&&delete r["font-family"],r}normalizeNumberingLevelText(e,t,r){if("bullet"!=t||!e)return{text:e,normalized:!1};const a=(r?.["font-family"]??"").toLowerCase();let n=!1,s=null;if(a.includes("wingdings"))s=this.wingdingsBulletMap();else{if(!a.includes("symbol"))return{text:e,normalized:!1};s=this.symbolBulletMap()}let o="";for(const t of e){const e=s[t.charCodeAt(0)];e?(o+=e,n=!0):o+=t}return{text:o,normalized:n}}symbolBulletMap(){return{183:"•",8226:"•",61623:"•"}}wingdingsBulletMap(){return{61548:"●",61550:"■",61557:"◆",61598:"·",61599:"•",61600:"▪",61601:"○",61604:"◉",61605:"◎",61607:"▪",61608:"◻",61656:"➢",61672:"➔",61690:"▫",61691:"✗",61692:"✓",61693:"☒",61694:"☑"}}levelTextToContent(e,t,r,a,n){const s=[];let o=0;for(const t of e.matchAll(/%\d+/g)){t.index>o&&s.push(`"${this.escapeCssString(e.substring(o,t.index))}"`);let i=parseInt(t[0].substring(1),10)-1;const l=n?.get(`${r}:${i}`)??a??"decimal";s.push(`counter(${this.numberingCounter(r,i)}, ${l})`),o=t.index+t[0].length}const i=e.substring(o);i&&s.push(`"${this.escapeCssString(i)}"`);const l=this.numberingSuffixToCssContent(t);return l&&s.push(l),s.length>0?s.join(" "):'""'}numberingSuffixToCssContent(e){switch(e||"tab"){case"nothing":return"";case"space":return'"\\000020"';default:return'"\\000009"'}}escapeCssString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r?\n/g,"\\A ")}numFormatToCssValue(e){return{none:"none",bullet:"disc",decimal:"decimal",lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero",aiueo:"katakana",aiueoFullWidth:"katakana",chineseCounting:"simp-chinese-informal",chineseCountingThousand:"simp-chinese-informal",chineseLegalSimplified:"simp-chinese-formal",chosung:"hangul-consonant",ideographDigital:"cjk-ideographic",ideographTraditional:"cjk-heavenly-stem",ideographLegalTraditional:"trad-chinese-formal",ideographZodiac:"cjk-earthly-branch",iroha:"katakana-iroha",irohaFullWidth:"katakana-iroha",japaneseCounting:"japanese-informal",japaneseDigitalTenThousand:"cjk-decimal",japaneseLegal:"japanese-formal",thaiNumbers:"thai",koreanCounting:"korean-hangul-formal",koreanDigital:"korean-hangul-formal",koreanDigital2:"korean-hanja-informal",hebrew1:"hebrew",hebrew2:"hebrew",hindiNumbers:"devanagari",ganada:"hangul",taiwaneseCounting:"cjk-ideographic",taiwaneseCountingThousand:"cjk-ideographic",taiwaneseDigital:"cjk-decimal"}[e]??e??"decimal"}refreshTabStops(){this.options.experimental&&setTimeout(()=>{const e=(0,s.computePixelToPoint)();for(let t of this.currentTabs)(0,s.updateTabStop)(t.span,t.stops,this.defaultTabSize,e)},500)}createElementNS(e,t,r,a){return this.h({ns:e,tagName:t,children:a,...r})}createElement(e,t,r){return this.createElementNS(i.ns.html,e,t,r)}createMathMLElement(e,t,r){return this.createElementNS(i.ns.mathML,e,t,r)}createSvgElement(e,t,r){return this.createElementNS(i.ns.svg,e,t,r)}later(e){this.postRenderTasks.push(e)}}},"./html":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ns=void 0,r.h=function e(t){if((0,a.isString)(t))return document.createTextNode(t);if(t instanceof Node)return t;const{ns:r,tagName:n,className:s,style:o,children:i,...l}=t;if("#fragment"===n)return document.createDocumentFragment();if("#comment"===n)return document.createComment(i[0]);const c=r?document.createElementNS(r,n):document.createElement(n);if(s&&c.setAttribute("class",s),o&&((0,a.isString)(o)?c.setAttribute("style",o):Object.assign(c.style,o)),l)for(const[e,t]of Object.entries(l))void 0!==t&&(c[e]=t);return i&&i.forEach(t=>c.appendChild(e(t))),c},r.cx=function(...e){return e.filter(Boolean).join(" ")};const a=e("./utils");var n;!function(e){e.html="http://www.w3.org/1999/xhtml",e.svg="http://www.w3.org/2000/svg",e.mathML="http://www.w3.org/1998/Math/MathML"}(n||(r.ns=n={}))},"./javascript":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.computePixelToPoint=function(e=document.body){const t=document.createElement("div");t.style.width="100pt",e.appendChild(t);const r=100/t.offsetWidth;return e.removeChild(t),r},r.updateTabStop=function(e,t,r,i=.75){const l=e.closest("p");if(!l)return;const c=e.getBoundingClientRect(),u=l.getBoundingClientRect(),d=getComputedStyle(l),h=s(d.marginInlineStart||d.marginLeft),p=s(d.marginInlineEnd||d.marginRight),m=t?.length>0?t.map(e=>({pos:o(e.position),leader:e.leader,style:e.style})).sort((e,t)=>e.pos-t.pos):[a],f=m[m.length-1],g=(u.width+h+p)*i,b=Number.isFinite(o(r))?o(r):36;let y=f.pos+b;if(y<g)for(;y<g&&m.length<n;y+=b)m.push({...a,pos:y});const k=u.left-h,x=(c.left-k)*i,T=m.find(e=>"clear"!=e.style&&e.pos>x);if(null==T)return;let P=1;if("right"==T.style||"center"==T.style){const t=Array.from(l.querySelectorAll(`.${e.className}`)),r=t.indexOf(e)+1,a=document.createRange();a.setStart(e,1),r<t.length?a.setEndBefore(t[r]):a.setEndAfter(l);const n="center"==T.style?.5:1,s=a.getBoundingClientRect(),o=s.left+n*s.width-k;P=T.pos-o*i}else P=T.pos-x;const v=Math.max(Number.isFinite(P)?P:0,0);switch(e.innerHTML="&nbsp;",e.style.display="inline-block",e.style.width=`${v.toFixed(2)}pt`,e.style.minWidth="0pt",e.style.lineHeight="1",e.style.whiteSpace="nowrap",e.style.wordSpacing="normal",e.style.textDecoration="none",e.style.borderBottom="",e.style.height="",e.style.transform="",T.leader){case"dot":case"middleDot":e.style.borderBottom="1px dotted currentColor",e.style.height=".85em",e.style.transform="translateY(-.18em)";break;case"hyphen":case"heavy":case"underscore":e.style.borderBottom="1px solid currentColor",e.style.height=".85em",e.style.transform="translateY(-.18em)"}};const a={pos:0,leader:"none",style:"left"},n=50;function s(e){const t=parseFloat(e);return Number.isFinite(t)?t:0}function o(e){return parseFloat(e)}},"./length":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Length=void 0;const a=e("./utils");class n{constructor(e,t){this.value=e,this.type=t}static parse(e){const t=parseFloat(e),r=/p[tx]$/i.exec(e)?.[0];return new n(t,r)}static from(e){return(0,a.isString)(e)?n.parse(e):e instanceof n?e:null}add(e){if(e.type!==this.type)throw new Error("Can't do math on different types");return new n(this.value+e.value,this.type)}mul(e){return new n(this.value*e,this.type)}valueOf(){return this.value}toString(){return`${this.value.toFixed(2)}${this.type??""}`}}r.Length=n},"./license-gate":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.assertViewerLicense=function(e,t){}},"./metafile/emf-to-svg":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isEmfBinary=o,r.convertEmfToSvgDataUrl=function(e,t){const r=i(e,t);return r?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`:null},r.convertEmfToSvg=i;const a={HEADER:1,POLYBEZIER:2,POLYGON:3,POLYLINE:4,POLYBEZIERTO:5,POLYLINETO:6,POLYPOLYLINE:7,POLYPOLYGON:8,SETWINDOWEXTEX:9,SETWINDOWORGEX:10,SETVIEWPORTEXTEX:11,SETVIEWPORTORGEX:12,EOF:14,SETPIXELV:15,SETMAPMODE:17,SETBKMODE:18,SETPOLYFILLMODE:19,SETTEXTALIGN:22,SETTEXTCOLOR:24,SETBKCOLOR:25,MOVETOEX:27,SCALEVIEWPORTEXTEX:31,SCALEWINDOWEXTEX:32,SAVEDC:33,RESTOREDC:34,SETWORLDTRANSFORM:35,MODIFYWORLDTRANSFORM:36,SELECTOBJECT:37,CREATEPEN:38,CREATEBRUSHINDIRECT:39,DELETEOBJECT:40,ANGLEARC:41,ELLIPSE:42,RECTANGLE:43,ROUNDRECT:44,ARC:45,CHORD:46,PIE:47,LINETO:54,ARCTO:55,POLYDRAW:56,BEGINPATH:59,ENDPATH:60,CLOSEFIGURE:61,FILLPATH:62,STROKEANDFILLPATH:63,STROKEPATH:64,BITBLT:76,STRETCHBLT:77,STRETCHDIBITS:81,EXTCREATEFONTINDIRECTW:82,EXTTEXTOUTA:83,EXTTEXTOUTW:84,POLYBEZIER16:85,POLYGON16:86,POLYLINE16:87,POLYBEZIERTO16:88,POLYLINETO16:89,POLYPOLYLINE16:90,POLYPOLYGON16:91,POLYDRAW16:92,EXTCREATEPEN:95,POLYTEXTOUTA:96,POLYTEXTOUTW:97,SMALLTEXTOUT:108,ALPHABLEND:114,TRANSPARENTBLT:116},n={0:{type:"brush",color:"#ffffff"},1:{type:"brush",color:"#c0c0c0"},2:{type:"brush",color:"#808080"},3:{type:"brush",color:"#404040"},4:{type:"brush",color:"#000000"},5:{type:"brush",color:"none",nullBrush:!0},6:{type:"pen",color:"#ffffff",width:1},7:{type:"pen",color:"#000000",width:1},8:{type:"pen",color:"none",width:0,nullPen:!0},18:{type:"brush",color:"#ffffff"},19:{type:"pen",color:"#000000",width:1}},s={m11:1,m12:0,m21:0,m22:1,dx:0,dy:0};function o(e){if(!e||e.length<48)return!1;const t=h(e);return t.getUint32(0,!0)==a.HEADER&&1179469088==t.getUint32(40,!0)}function i(e,t={}){if(!o(e))return null;const r=h(e),i=r.getUint32(4,!0),g=p(r,8),x=p(r,24),v=r.byteLength>=52?r.getUint32(48,!0):0,A=Math.max(1,g.right-g.left),H=Math.max(1,g.bottom-g.top),j=Math.max(1,x.right-x.left)/100,W=Math.max(1,x.bottom-x.top)/100,V={world:d(s),windowOrg:{x:0,y:0},windowExt:null,viewportOrg:{x:0,y:0},viewportExt:null,pen:{type:"pen",color:"#000000",width:1},brush:{type:"brush",color:"#ffffff",nullBrush:!0},font:null,textColor:"#000000",bkColor:"#ffffff",bkMode:1,polyFillMode:1,textAlign:0,currentPoint:{x:0,y:0}},z=[],J={},Q=[];let ee=Math.max(8,i||108),te=1,re="",ae=!1,ne=0;const se=t.maxRecords??Math.max(1e4,v+100),oe=t.maxShapes??5e4,ie=e=>{!e||ne>=oe||(Q.push(e),ne++)},le=e=>{e&&(re+=(re?" ":"")+e)};for(;ee+8<=r.byteLength&&te++<=se;){const e=r.getUint32(ee,!0),t=r.getUint32(ee+4,!0);if(t<8||ee+t>r.byteLength)break;switch(e){case a.EOF:ee+=t,te=se+1;break;case a.SETWINDOWEXTEX:V.windowExt=f(r,ee+8);break;case a.SETWINDOWORGEX:V.windowOrg=m(r,ee+8);break;case a.SETVIEWPORTEXTEX:V.viewportExt=f(r,ee+8);break;case a.SETVIEWPORTORGEX:V.viewportOrg=m(r,ee+8);break;case a.SCALEWINDOWEXTEX:V.windowExt&&(V.windowExt=T(r,ee,V.windowExt));break;case a.SCALEVIEWPORTEXTEX:V.viewportExt&&(V.viewportExt=T(r,ee,V.viewportExt));break;case a.SETWORLDTRANSFORM:V.world=b(r,ee+8);break;case a.MODIFYWORLDTRANSFORM:{const e=b(r,ee+8),t=r.getUint32(ee+32,!0);1==t?V.world=d(s):2==t?V.world=y(e,V.world):3==t?V.world=y(V.world,e):4==t&&(V.world=e);break}case a.SAVEDC:z.push(l(V));break;case a.RESTOREDC:{const e=r.getInt32(ee+8,!0);if(e<0)for(let t=0;t<Math.min(-e,z.length);t++)Object.assign(V,z.pop());else if(e>0&&e<=z.length){const t=z[e-1];z.length=e-1,Object.assign(V,l(t))}break}case a.SETBKMODE:V.bkMode=r.getUint32(ee+8,!0);break;case a.SETPOLYFILLMODE:V.polyFillMode=r.getUint32(ee+8,!0);break;case a.SETTEXTALIGN:V.textAlign=r.getUint32(ee+8,!0);break;case a.SETTEXTCOLOR:V.textColor=P(r.getUint32(ee+8,!0));break;case a.SETBKCOLOR:V.bkColor=P(r.getUint32(ee+8,!0));break;case a.CREATEPEN:{const e=r.getUint32(ee+8,!0),t=r.getUint32(ee+12,!0),a=Math.abs(r.getInt32(ee+16,!0)),n=P(r.getUint32(ee+24,!0));J[e]={type:"pen",color:n,width:a||1,nullPen:5==(15&t)};break}case a.EXTCREATEPEN:{const e=r.getUint32(ee+8,!0),t=r.getUint32(ee+28,!0),a=Math.abs(r.getInt32(ee+32,!0)),n=r.getUint32(ee+36,!0),s=P(r.getUint32(ee+40,!0));J[e]={type:"pen",color:s,width:a||1,nullPen:5==(15&t)||1==n};break}case a.CREATEBRUSHINDIRECT:{const e=r.getUint32(ee+8,!0),t=r.getUint32(ee+12,!0),a=P(r.getUint32(ee+16,!0));J[e]={type:"brush",color:a,nullBrush:1==t};break}case a.EXTCREATEFONTINDIRECTW:J[r.getUint32(ee+8,!0)]=O(r,ee+12,t-12);break;case a.SELECTOBJECT:{const e=r.getUint32(ee+8,!0),t=2147483648&e?n[2147483647&e]:J[e];"pen"==t?.type?V.pen=c(t):"brush"==t?.type?V.brush=u(t):"font"==t?.type&&(V.font={...t});break}case a.DELETEOBJECT:delete J[r.getUint32(ee+8,!0)];break;case a.BEGINPATH:ae=!0,re="";break;case a.ENDPATH:ae=!1;break;case a.CLOSEFIGURE:le("Z");break;case a.MOVETOEX:{const e=k(V,m(r,ee+8));V.currentPoint=e,ae&&le(`M ${w(e.x)} ${w(e.y)}`);break}case a.LINETO:{const e=k(V,m(r,ee+8));ae?le(`L ${w(e.x)} ${w(e.y)}`):ie(`<path d="M ${w(V.currentPoint.x)} ${w(V.currentPoint.y)} L ${w(e.x)} ${w(e.y)}" ${C(V,!1,!0)}/>`),V.currentPoint=e;break}case a.POLYLINE:case a.POLYGON:M(r,ee,e==a.POLYGON,!1,ae,V,le,ie);break;case a.POLYLINETO:M(r,ee,!1,!0,ae,V,le,ie);break;case a.POLYLINE16:case a.POLYGON16:N(r,ee,e==a.POLYGON16,!1,ae,V,le,ie);break;case a.POLYLINETO16:N(r,ee,!1,!0,ae,V,le,ie);break;case a.POLYBEZIER:D(r,ee,!1,!1,ae,V,le,ie);break;case a.POLYBEZIERTO:D(r,ee,!1,!0,ae,V,le,ie);break;case a.POLYBEZIER16:D(r,ee,!0,!1,ae,V,le,ie);break;case a.POLYBEZIERTO16:D(r,ee,!0,!0,ae,V,le,ie);break;case a.POLYPOLYLINE:case a.POLYPOLYGON:L(r,ee,e==a.POLYPOLYGON,!1,ae,V,le,ie);break;case a.POLYPOLYLINE16:case a.POLYPOLYGON16:L(r,ee,e==a.POLYPOLYGON16,!0,ae,V,le,ie);break;case a.POLYDRAW:$(r,ee,!1,ae,V,le,ie);break;case a.POLYDRAW16:$(r,ee,!0,ae,V,le,ie);break;case a.RECTANGLE:R(r,ee,V,ie,!1);break;case a.ELLIPSE:F(r,ee,V,ie);break;case a.ROUNDRECT:R(r,ee,V,ie,!0);break;case a.ARC:case a.ARCTO:case a.CHORD:case a.PIE:B(r,ee,e,ae,V,le,ie);break;case a.FILLPATH:E(re,V,ie,!0,!1),re="";break;case a.STROKEPATH:E(re,V,ie,!1,!0),re="";break;case a.STROKEANDFILLPATH:E(re,V,ie,!0,!0),re="";break;case a.EXTTEXTOUTA:case a.EXTTEXTOUTW:I(r,ee,t,V,ie,e==a.EXTTEXTOUTW);break;case a.POLYTEXTOUTA:case a.POLYTEXTOUTW:_(r,ee,t,V,ie,e==a.POLYTEXTOUTW);break;case a.SMALLTEXTOUT:U(r,ee,t,V,ie);break;case a.SETPIXELV:X(r,ee,V,ie);break;case a.BITBLT:case a.STRETCHBLT:case a.STRETCHDIBITS:case a.ALPHABLEND:case a.TRANSPARENTBLT:G(r,ee,t,e,V,ie)}ee+=t}if(re&&E(re,V,ie,!0,!0),!Q.length){const t=function(e,t){const r=function(e){const t=function(e){const t=[137,80,78,71,13,10,26,10];for(let r=0;r+t.length+12<=e.length;r++){if(!Y(e,t,r))continue;let a=r+8;for(;a+12<=e.length;){const t=q(e,a),n=String.fromCharCode(e[a+4],e[a+5],e[a+6],e[a+7]);if(a+=12+t,a>e.length)break;if("IEND"==n)return e.subarray(r,a)}}return null}(e);if(t)return`data:image/png;base64,${K(t)}`;const r=function(e){for(let t=0;t+4<e.length;t++)if(255==e[t]&&216==e[t+1]&&255==e[t+2])for(let r=t+4;r+1<e.length;r++)if(255==e[r]&&217==e[r+1])return e.subarray(t,r+2);return null}(e);if(r)return`data:image/jpeg;base64,${K(r)}`;const a=function(e){for(let t=0;t+14<e.length;t++){if(66!=e[t]||77!=e[t+1])continue;const r=Z(e,t+2);if(r>14&&t+r<=e.length)return e.subarray(t,t+r)}return null}(e);return a?`data:image/bmp;base64,${K(a)}`:null}(e);if(!r)return[];const a=Math.max(1,t.right-t.left),n=Math.max(1,t.bottom-t.top);return[`<image x="${w(t.left)}" y="${w(t.top)}" width="${w(a)}" height="${w(n)}" href="${r}" preserveAspectRatio="xMidYMid meet"/>`]}(e,g);t.length&&Q.push(...t)}return Q.length?`<svg xmlns="http://www.w3.org/2000/svg" width="${w(j)}mm" height="${w(W)}mm" viewBox="${w(g.left)} ${w(g.top)} ${w(A)} ${w(H)}" preserveAspectRatio="xMidYMid meet" data-docx-metafile="emf">${Q.join("")}</svg>`:function(e,t,r,a,n){return`<svg xmlns="http://www.w3.org/2000/svg" width="${w(a)}mm" height="${w(n)}mm" viewBox="${w(r.left)} ${w(r.top)} ${w(e)} ${w(t)}" preserveAspectRatio="xMidYMid meet" data-docx-metafile="emf"><rect x="${w(r.left)}" y="${w(r.top)}" width="${w(e)}" height="${w(t)}" fill="none" stroke="#999" stroke-width="1"/><text x="${w(r.left+e/2)}" y="${w(r.top+t/2)}" text-anchor="middle" font-size="12" fill="#666">${S("Unsupported EMF image")}</text></svg>`}(A,H,g,j,W)}function l(e){return{world:d(e.world),windowOrg:{...e.windowOrg},windowExt:e.windowExt?{...e.windowExt}:null,viewportOrg:{...e.viewportOrg},viewportExt:e.viewportExt?{...e.viewportExt}:null,pen:c(e.pen),brush:u(e.brush),font:e.font?{...e.font}:null,textColor:e.textColor,bkColor:e.bkColor,bkMode:e.bkMode,polyFillMode:e.polyFillMode,textAlign:e.textAlign,currentPoint:{...e.currentPoint}}}function c(e){return{...e}}function u(e){return{...e}}function d(e){return{...e}}function h(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function p(e,t){return{left:e.getInt32(t,!0),top:e.getInt32(t+4,!0),right:e.getInt32(t+8,!0),bottom:e.getInt32(t+12,!0)}}function m(e,t){return{x:e.getInt32(t,!0),y:e.getInt32(t+4,!0)}}function f(e,t){return m(e,t)}function g(e,t){return{x:e.getInt16(t,!0),y:e.getInt16(t+2,!0)}}function b(e,t){return{m11:e.getFloat32(t,!0),m12:e.getFloat32(t+4,!0),m21:e.getFloat32(t+8,!0),m22:e.getFloat32(t+12,!0),dx:e.getFloat32(t+16,!0),dy:e.getFloat32(t+20,!0)}}function y(e,t){return{m11:e.m11*t.m11+e.m12*t.m21,m12:e.m11*t.m12+e.m12*t.m22,m21:e.m21*t.m11+e.m22*t.m21,m22:e.m21*t.m12+e.m22*t.m22,dx:e.dx*t.m11+e.dy*t.m21+t.dx,dy:e.dx*t.m12+e.dy*t.m22+t.dy}}function k(e,t){const r=e.world;let a=t.x*r.m11+t.y*r.m21+r.dx,n=t.x*r.m12+t.y*r.m22+r.dy;return e.windowExt&&e.viewportExt&&e.windowExt.x&&e.windowExt.y&&(a=(a-e.windowOrg.x)*e.viewportExt.x/e.windowExt.x+e.viewportOrg.x,n=(n-e.windowOrg.y)*e.viewportExt.y/e.windowExt.y+e.viewportOrg.y),{x:a,y:n}}function x(e){let t=Math.hypot(e.world.m11,e.world.m12),r=Math.hypot(e.world.m21,e.world.m22);e.windowExt&&e.viewportExt&&e.windowExt.x&&e.windowExt.y&&(t*=Math.abs(e.viewportExt.x/e.windowExt.x),r*=Math.abs(e.viewportExt.y/e.windowExt.y));const a=(t+r)/2;return Number.isFinite(a)&&a>0?a:1}function T(e,t,r){const a=e.getInt32(t+8,!0),n=e.getInt32(t+12,!0),s=e.getInt32(t+16,!0),o=e.getInt32(t+20,!0);return{x:n?r.x*a/n:r.x,y:o?r.y*s/o:r.y}}function P(e){const t=e>>8&255,r=e>>16&255;return`#${v(255&e)}${v(t)}${v(r)}`}function v(e){return Math.max(0,Math.min(255,0|e)).toString(16).padStart(2,"0")}function w(e){return Number.isFinite(e)?""+Math.round(1e3*e)/1e3:"0"}function S(e){return`${e??""}`.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function C(e,t,r){const a=[];if(t&&!e.brush.nullBrush?(a.push(`fill="${e.brush.color}"`),a.push(`fill-rule="${2==e.polyFillMode?"nonzero":"evenodd"}"`)):a.push('fill="none"'),r&&!e.pen.nullPen){const t=x(e),r=0==e.pen.width?1:Math.max(.35,e.pen.width*t);a.push(`stroke="${e.pen.color}"`),a.push(`stroke-width="${w(r)}"`),a.push('stroke-linecap="square"'),a.push('stroke-linejoin="miter"')}else a.push('stroke="none"');return a.join(" ")}function E(e,t,r,a,n){e&&r(`<path d="${e}" ${C(t,a,n)}/>`)}function N(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0);if(!l||t+28+4*l>e.byteLength)return;const c=[];for(let r=0;r<l;r++)c.push(k(s,g(e,t+28+4*r)));A(c,r,a,n,s,o,i)}function M(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0);if(!l||t+28+8*l>e.byteLength)return;const c=[];for(let r=0;r<l;r++)c.push(k(s,m(e,t+28+8*r)));A(c,r,a,n,s,o,i)}function A(e,t,r,a,n,s,o){if(!e.length)return;let i=a&&r?"":r?`M ${w(n.currentPoint.x)} ${w(n.currentPoint.y)}`:`M ${w(e[0].x)} ${w(e[0].y)}`;for(let t=r?0:1;t<e.length;t++)i+=` L ${w(e[t].x)} ${w(e[t].y)}`;t&&(i+=" Z"),n.currentPoint=e[e.length-1],a?s(i.trim()):o(`<path d="${i.trim()}" ${C(n,t,!0)}/>`)}function D(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0),c=r?4:8;if(!l||t+28+l*c>e.byteLength)return;const u=[];for(let a=0;a<l;a++){const n=r?g(e,t+28+a*c):m(e,t+28+a*c);u.push(k(s,n))}let d=n&&a?"":a?`M ${w(s.currentPoint.x)} ${w(s.currentPoint.y)}`:`M ${w(u[0].x)} ${w(u[0].y)}`,h=a?s.currentPoint:u[0];for(let e=a?0:1;e+2<u.length;e+=3){const t=u[e],r=u[e+1],a=u[e+2];d+=` C ${w(t.x)} ${w(t.y)} ${w(r.x)} ${w(r.y)} ${w(a.x)} ${w(a.y)}`,h=a}s.currentPoint=h,n?o(d.trim()):i(`<path d="${d.trim()}" ${C(s,!1,!0)}/>`)}function L(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0),c=e.getUint32(t+28,!0),u=t+32,d=u+4*l,h=a?4:8;if(!l||!c||d+c*h>e.byteLength)return;let p=0;for(let t=0;t<l;t++){const l=e.getUint32(u+4*t,!0);if(!l||p+l>c)break;const f=[];for(let t=0;t<l;t++){const r=d+(p+t)*h,n=a?g(e,r):m(e,r);f.push(k(s,n))}A(f,r,!1,n,s,o,i),p+=l}}function $(e,t,r,a,n,s,o){const i=e.getUint32(t+24,!0),l=r?4:8,c=t+28,u=c+i*l;if(!i||u+i>e.byteLength)return;const d=[];for(let t=0;t<i;t++){const a=c+t*l,s=r?g(e,a):m(e,a);d.push(k(n,s))}let h="",p=0;for(;p<i;){const t=e.getUint8(u+p),r=6&t;6==r?(h+=` M ${w(d[p].x)} ${w(d[p].y)}`,n.currentPoint=d[p],p++):2==r?(h+=` L ${w(d[p].x)} ${w(d[p].y)}`,n.currentPoint=d[p],p++):4==r&&p+2<i?(h+=` C ${w(d[p].x)} ${w(d[p].y)} ${w(d[p+1].x)} ${w(d[p+1].y)} ${w(d[p+2].x)} ${w(d[p+2].y)}`,n.currentPoint=d[p+2],p+=3):p++,1&t&&(h+=" Z")}h=h.trim(),h&&(a?s(h):o(`<path d="${h}" ${C(n,!1,!0)}/>`))}function R(e,t,r,a,n){const s=p(e,t+8),o=k(r,{x:s.left,y:s.top}),i=k(r,{x:s.right,y:s.bottom}),l=Math.min(o.x,i.x),c=Math.min(o.y,i.y),u=Math.abs(i.x-o.x),d=Math.abs(i.y-o.y),h=n?` rx="${w(Math.min(u,d)/8)}" ry="${w(Math.min(u,d)/8)}"`:"";a(`<rect x="${w(l)}" y="${w(c)}" width="${w(u)}" height="${w(d)}"${h} ${C(r,!0,!0)}/>`)}function F(e,t,r,a){const n=p(e,t+8),s=k(r,{x:n.left,y:n.top}),o=k(r,{x:n.right,y:n.bottom}),i=(s.x+o.x)/2,l=(s.y+o.y)/2,c=Math.abs(o.x-s.x)/2,u=Math.abs(o.y-s.y)/2;a(`<ellipse cx="${w(i)}" cy="${w(l)}" rx="${w(c)}" ry="${w(u)}" ${C(r,!0,!0)}/>`)}function B(e,t,r,n,s,o,i){const l=p(e,t+8),c=m(e,t+24),u=m(e,t+32),d=(l.left+l.right)/2,h=(l.top+l.bottom)/2,f=Math.abs(l.right-l.left)/2,g=Math.abs(l.bottom-l.top)/2;if(!f||!g)return;const b=Math.atan2(c.y-h,c.x-d);let y=Math.atan2(u.y-h,u.x-d),x=y-b;x<=0&&(x+=2*Math.PI);const T=x>Math.PI?1:0,P=k(s,{x:d+Math.cos(b)*f,y:h+Math.sin(b)*g}),v=k(s,{x:d+Math.cos(y)*f,y:h+Math.sin(y)*g}),S=k(s,{x:d,y:h}),E=k(s,{x:d+f,y:h}),N=k(s,{x:d,y:h+g}),M=Math.max(.01,Math.abs(E.x-S.x)||Math.abs(N.x-S.x)),A=Math.max(.01,Math.abs(N.y-S.y)||Math.abs(E.y-S.y)),D=`A ${w(M)} ${w(A)} 0 ${T} 1 ${w(v.x)} ${w(v.y)}`;let L=`M ${w(P.x)} ${w(P.y)} ${D}`,$=!1;r==a.CHORD?(L+=" Z",$=!0):r==a.PIE&&(L+=` L ${w(S.x)} ${w(S.y)} Z`,$=!0),r==a.ARCTO&&(s.currentPoint=v),n?o(L):i(`<path d="${L}" ${C(s,$,!0)}/>`)}function O(e,t,r){const a=r>=4?e.getInt32(t,!0):12,n=r>=20?e.getInt32(t+16,!0):400,s=r>=21&&0!=e.getUint8(t+20),o=r>=22&&0!=e.getUint8(t+21);let i="";const l=t+28,c=Math.max(0,Math.min(64,r-28));for(let t=0;t+1<c;t+=2){const r=e.getUint16(l+t,!0);if(!r)break;i+=String.fromCharCode(r)}return{type:"font",family:i,size:Math.abs(a)||12,weight:n,italic:s,underline:o}}function I(e,t,r,a,n,s){if(r<76)return;const o=k(a,m(e,t+36)),i=e.getUint32(t+44,!0),l=e.getUint32(t+48,!0);!i||l<=0||l+i*(s?2:1)>r||z(s?H(e,t+l,i):j(new Uint8Array(e.buffer,e.byteOffset+t+l,i)),o,a,n)}function _(e,t,r,a,n,s){if(r<40)return;const o=e.getUint32(t+36,!0);let i=t+40;for(let l=0;l<o&&i+40<=t+r;l++,i+=40){const o=k(a,m(e,i)),l=e.getUint32(i+8,!0),c=e.getUint32(i+12,!0);!l||!c||c+l*(s?2:1)>r||z(s?H(e,t+c,l):j(new Uint8Array(e.buffer,e.byteOffset+t+c,l)),o,a,n)}}function U(e,t,r,a,n){if(r<36)return;const s=k(a,m(e,t+8)),o=e.getUint32(t+16,!0),i=512&e.getUint32(t+20,!0)?40:28;!o||i+o>r||z(j(new Uint8Array(e.buffer,e.byteOffset+t+i,o)),s,a,n)}function H(e,t,r){let a="";for(let n=0;n<r;n++){const r=e.getUint16(t+2*n,!0);r&&(a+=String.fromCharCode(r))}return a}function j(e){if(!e.length)return"";const t=globalThis.TextDecoder;if(t)try{return new t("gb18030").decode(e).replace(/\0+$/g,"")}catch{try{return new t("windows-1252").decode(e).replace(/\0+$/g,"")}catch{}}let r="";for(const t of e)t&&(r+=String.fromCharCode(t));return r}function W(e){const t=6&e.textAlign;return 6==t?'text-anchor="middle"':2==t?'text-anchor="end"':""}function V(e){const t=24&e.textAlign;return 0==t?'dominant-baseline="text-before-edge"':8==t?'dominant-baseline="text-after-edge"':""}function z(e,t,r,a){e&&a(`<text ${function(e,t){const r=e.font,a=Math.max(1,(r?.size??12)*x(e));return[`x="${w(t.x)}"`,`y="${w(t.y)}"`,`fill="${e.textColor}"`,`font-size="${w(a)}"`,r?.family?`font-family="${S(r.family)}"`:"",r?.weight?`font-weight="${r.weight>=600?"bold":"normal"}"`:"",r?.italic?'font-style="italic"':"",r?.underline?'text-decoration="underline"':"",W(e),V(e)].filter(Boolean).join(" ")}(r,t)}>${S(e)}</text>`)}function X(e,t,r,a){if(t+20>e.byteLength)return;const n=k(r,m(e,t+8)),s=P(e.getUint32(t+16,!0));a(`<rect x="${w(n.x)}" y="${w(n.y)}" width="1" height="1" fill="${s}" stroke="none"/>`)}function G(e,t,r,n,s,o){let i=0,l=0,c=0,u=0,d=0,h=0,p=0,m=0;if(n==a.STRETCHDIBITS){if(r<80)return;i=e.getInt32(t+24,!0),l=e.getInt32(t+28,!0),d=e.getUint32(t+48,!0),h=e.getUint32(t+52,!0),p=e.getUint32(t+56,!0),m=e.getUint32(t+60,!0),c=e.getInt32(t+72,!0),u=e.getInt32(t+76,!0)}else{if(r<100)return;i=e.getInt32(t+24,!0),l=e.getInt32(t+28,!0),c=e.getInt32(t+32,!0),u=e.getInt32(t+36,!0),d=e.getUint32(t+84,!0),h=e.getUint32(t+88,!0),p=e.getUint32(t+92,!0),m=e.getUint32(t+96,!0)}if(!d||!h||!p||!m||d+h>r||p+m>r)return;const f=function(e,t,r,a,n,s){const o=t+r,i=t+n;if(a<4||o+a>e.byteLength||i+s>e.byteLength)return null;const l=e.getUint32(o,!0)>=40&&a>=20?e.getUint32(o+16,!0):0,c=new Uint8Array(e.buffer,e.byteOffset+i,s);if(4==l)return`data:image/jpeg;base64,${K(c)}`;if(5==l)return`data:image/png;base64,${K(c)}`;const u=new Uint8Array(a+s);return u.set(new Uint8Array(e.buffer,e.byteOffset+o,a),0),u.set(c,a),function(e,t){if(!e?.length||t<=0||t>e.length)return null;const r=14+e.length,a=14+t,n=new Uint8Array(r);return n[0]=66,n[1]=77,J(n,2,r),J(n,10,a),n.set(e,14),`data:image/bmp;base64,${K(n)}`}(u,a)}(e,t,d,h,p,m);if(!f)return;const g=k(s,{x:i,y:l}),b=k(s,{x:i+c,y:l+u}),y=Math.min(g.x,b.x),x=Math.min(g.y,b.y),T=Math.abs(b.x-g.x),P=Math.abs(b.y-g.y);o(`<image x="${w(y)}" y="${w(x)}" width="${w(T)}" height="${w(P)}" href="${f}" preserveAspectRatio="none"/>`)}function Y(e,t,r){for(let a=0;a<t.length;a++)if(e[r+a]!=t[a])return!1;return!0}function q(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Z(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function J(e,t,r){e[t]=255&r,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255}function K(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));if("function"==typeof btoa)return btoa(t);const r=globalThis.Buffer;return r?r.from(e).toString("base64"):t}},"./notes/elements":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WmlEndnote=r.WmlFootnote=r.WmlBaseNote=void 0;const a=e("../document/dom");class n{}r.WmlBaseNote=n,r.WmlFootnote=class extends n{constructor(){super(...arguments),this.type=a.DomType.Footnote}},r.WmlEndnote=class extends n{constructor(){super(...arguments),this.type=a.DomType.Endnote}}},"./notes/parts":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.EndnotesPart=r.FootnotesPart=r.BaseNotePart=void 0;const a=e("../common/part"),n=e("./elements");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}}r.BaseNotePart=s,r.FootnotesPart=class extends s{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"footnote",n.WmlFootnote)}},r.EndnotesPart=class extends s{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"endnote",n.WmlEndnote)}}},"./numbering/numbering-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.NumberingPart=void 0;const a=e("../common/part"),n=e("./numbering");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){Object.assign(this,(0,n.parseNumberingPart)(e,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(e)}}r.NumberingPart=s},"./numbering/numbering":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseNumberingPart=function(e,t){let r={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let a of t.elements(e))switch(a.localName){case"num":r.numberings.push(s(a,t));break;case"abstractNum":r.abstractNumberings.push(o(a,t));break;case"numPicBullet":r.bulletPictures.push(c(a,t))}return r},r.parseNumbering=s,r.parseAbstractNumbering=o,r.parseNumberingLevel=i,r.parseNumberingLevelOverrride=l,r.parseNumberingBulletPicture=c;const a=e("../document/paragraph"),n=e("../document/run");function s(e,t){let r={id:t.attr(e,"numId"),overrides:[]};for(let a of t.elements(e))switch(a.localName){case"abstractNumId":r.abstractId=t.attr(a,"val");break;case"lvlOverride":r.overrides.push(l(a,t))}return r}function o(e,t){let r={id:t.attr(e,"abstractNumId"),levels:[]};for(let a of t.elements(e))switch(a.localName){case"name":r.name=t.attr(a,"val");break;case"multiLevelType":r.multiLevelType=t.attr(a,"val");break;case"numStyleLink":r.numberingStyleLink=t.attr(a,"val");break;case"styleLink":r.styleLink=t.attr(a,"val");break;case"lvl":r.levels.push(i(a,t))}return r}function i(e,t){let r={level:t.intAttr(e,"ilvl")};for(let s of t.elements(e))switch(s.localName){case"start":r.start=t.attr(s,"val");break;case"lvlRestart":r.restart=t.intAttr(s,"val");break;case"numFmt":r.format=t.attr(s,"val");break;case"lvlText":r.text=t.attr(s,"val");break;case"lvlJc":r.justification=t.attr(s,"val");break;case"lvlPicBulletId":r.bulletPictureId=t.attr(s,"val");break;case"pStyle":r.paragraphStyle=t.attr(s,"val");break;case"pPr":r.paragraphProps=(0,a.parseParagraphProperties)(s,t);break;case"rPr":r.runProps=(0,n.parseRunProperties)(s,t)}return r}function l(e,t){let r={level:t.intAttr(e,"ilvl")};for(let a of t.elements(e))switch(a.localName){case"startOverride":r.start=t.intAttr(a,"val");break;case"lvl":r.numberingLevel=i(a,t)}return r}function c(e,t){var r=t.attr(e,"numPicBulletId"),a=t.element(e,"pict"),n=a&&t.element(a,"shape"),s=n&&t.element(n,"imagedata");if(s)return{id:r,referenceId:t.attr(s,"id"),style:t.attr(n,"style")};var o=t.element(e,"drawing"),i=o&&u(o,"blip",t);return i?{id:r,referenceId:t.attr(i,"embed")??t.attr(i,"link"),style:null}:null}function u(e,t,r){for(const a of r.elements(e)){if(a.localName==t)return a;const e=u(a,t,r);if(e)return e}return null}},"./parser/xml-parser":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.XmlParser=void 0,r.parseXmlString=function(e,t=!1){var r;t&&(e=e.replace(/<[?].*[?]>/,"")),e=65279===(r=e).charCodeAt(0)?r.substring(1):r;const a=(new DOMParser).parseFromString(e,"application/xml"),n=(s=a,s.getElementsByTagName("parsererror")[0]?.textContent);var s;if(n)throw new Error(n);return a},r.serializeXmlString=function(e){return(new XMLSerializer).serializeToString(e)};const a=e("../document/common");class n{elements(e,t=null){const r=[];for(let a=0,n=e.childNodes.length;a<n;a++){let n=e.childNodes.item(a);1!=n.nodeType||null!=t&&n.localName!=t||r.push(n)}return r}element(e,t){for(let r=0,a=e.childNodes.length;r<a;r++){let a=e.childNodes.item(r);if(1==a.nodeType&&a.localName==t)return a}return null}elementAttr(e,t,r){var a=this.element(e,t);return a?this.attr(a,r):void 0}attrs(e){return Array.from(e.attributes)}attr(e,t){for(let r=0,a=e.attributes.length;r<a;r++){let a=e.attributes.item(r);if(a.localName==t)return a.value}return null}intAttr(e,t,r=null){var a=this.attr(e,t);return null!=a&&""!==a?parseInt(a,10):r}hexAttr(e,t,r=null){var a=this.attr(e,t);return null!=a&&""!==a?parseInt(a,16):r}floatAttr(e,t,r=null){var a=this.attr(e,t);return null!=a&&""!==a?parseFloat(a):r}boolAttr(e,t,r=null){return(0,a.convertBoolean)(this.attr(e,t),r)}lengthAttr(e,t,r=a.LengthUsage.Dxa){return(0,a.convertLength)(this.attr(e,t),r)}}r.XmlParser=n;const s=new n;r.default=s},"./settings/settings-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SettingsPart=void 0;const a=e("../common/part"),n=e("./settings");class s extends a.Part{constructor(e,t){super(e,t)}parseXml(e){this.settings=(0,n.parseSettings)(e,this._package.xmlParser)}}r.SettingsPart=s},"./settings/settings":function(e,t,r){"use strict";function a(e,t){var r={defaultNoteIds:[]};for(let a of t.elements(e))switch(a.localName){case"numFmt":r.nummeringFormat=t.attr(a,"val");break;case"footnote":case"endnote":r.defaultNoteIds.push(t.attr(a,"id"))}return r}Object.defineProperty(r,"__esModule",{value:!0}),r.parseSettings=function(e,t){var r={};for(let n of t.elements(e))switch(n.localName){case"defaultTabStop":r.defaultTabStop=t.lengthAttr(n,"val");break;case"footnotePr":r.footnoteProps=a(n,t);break;case"endnotePr":r.endnoteProps=a(n,t);break;case"autoHyphenation":r.autoHyphenation=t.boolAttr(n,"val");break;case"kinsoku":r.kinsoku=t.boolAttr(n,"val",!0);break;case"overflowPunct":r.overflowPunctuation=t.boolAttr(n,"val",!0);break;case"topLinePunct":r.topLinePunctuation=t.boolAttr(n,"val",!0);break;case"autoSpaceDE":r.autoSpaceDE=t.boolAttr(n,"val",!0);break;case"autoSpaceDN":r.autoSpaceDN=t.boolAttr(n,"val",!0);break;case"noLineBreaksAfter":r.noLineBreaksAfter=t.attr(n,"val")||n.textContent||"";break;case"noLineBreaksBefore":r.noLineBreaksBefore=t.attr(n,"val")||n.textContent||"";break;case"evenAndOddHeaders":r.evenAndOddHeaders=t.boolAttr(n,"val",!0);break;case"splitPgBreakAndParaMark":r.splitPageBreakAndParagraphMark=t.boolAttr(n,"val",!0);break;case"compat":for(const e of t.elements(n))"adjustLineHeightInTable"==e.localName&&(r.adjustLineHeightInTable=t.boolAttr(e,"val",!0))}return r},r.parseNoteProperties=a},"./styles/styles-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.StylesPart=void 0;const a=e("../common/part");class n extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.styles=this._documentParser.parseStylesFile(e)}}r.StylesPart=n},"./theme/theme-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ThemePart=void 0;const a=e("../common/part"),n=e("./theme");class s extends a.Part{constructor(e,t){super(e,t)}parseXml(e){this.theme=(0,n.parseTheme)(e,this._package.xmlParser)}}r.ThemePart=s},"./theme/theme":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DmlTheme=void 0,r.parseTheme=function(e,t){var r=new a,o=t.element(e,"themeElements");for(let e of t.elements(o))switch(e.localName){case"clrScheme":r.colorScheme=n(e,t);break;case"fontScheme":r.fontScheme=s(e,t)}return r},r.parseColorScheme=n,r.parseFontScheme=s,r.parseFontInfo=o;class a{}function n(e,t){var r={name:t.attr(e,"name"),colors:{}};for(let s of t.elements(e)){var a=t.element(s,"srgbClr"),n=t.element(s,"sysClr");a?r.colors[s.localName]=t.attr(a,"val"):n&&(r.colors[s.localName]=t.attr(n,"lastClr"))}return r}function s(e,t){var r={name:t.attr(e,"name")};for(let a of t.elements(e))switch(a.localName){case"majorFont":r.majorFont=o(a,t);break;case"minorFont":r.minorFont=o(a,t)}return r}function o(e,t){return{latinTypeface:t.elementAttr(e,"latin","typeface"),eaTypeface:t.elementAttr(e,"ea","typeface"),csTypeface:t.elementAttr(e,"cs","typeface")}}r.DmlTheme=a},"./utils":function(e,t,r){"use strict";function a(e){return e&&"object"==typeof e&&!Array.isArray(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.escapeClassName=function(e){return e?.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()},r.encloseFontFamily=function(e){return/^[^"'].*\s.*[^"']$/.test(e)?`'${e}'`:e},r.splitPath=function(e){let t=e.lastIndexOf("/")+1;return[0==t?"":e.substring(0,t),0==t?e:e.substring(t)]},r.resolvePath=function(e,t){try{const r="http://docx/";return new URL(e,r+t).toString().substring(r.length)}catch{return`${t}${e}`}},r.keyBy=function(e,t){return e.reduce((e,r)=>(e[t(r)]=r,e),{})},r.blobToBase64=function(e){return new Promise((t,r)=>{const a=new FileReader;a.onloadend=()=>t(a.result),a.onerror=()=>r(),a.readAsDataURL(e)})},r.isObject=a,r.isString=function(e){return"string"==typeof e||e instanceof String},r.mergeDeep=function e(t,...r){if(!r.length)return t;const n=r.shift();if(a(t)&&a(n))for(const r in n)if(a(n[r])){e(t[r]??(t[r]={}),n[r])}else t[r]=n[r];return e(t,...r)},r.parseCssRules=function(e){const t={};for(const r of(e??"").split(";")){const e=r.indexOf(":");if(e<=0)continue;const a=r.substring(0,e).trim(),n=r.substring(e+1).trim();a&&(t[a]=n)}return t},r.formatCssRules=function(e){return Object.entries(e??{}).map(([e,t])=>`${e}: ${t}`).join(";")},r.asArray=function(e){return Array.isArray(e)?e:[e]},r.clamp=function(e,t,r){return t>e?t:r<e?r:e}},"./vml/vml":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.VmlElement=void 0,r.parseVmlElement=function e(t,r){var a=new i;switch(t.localName){case"rect":a.tagName="rect",Object.assign(a.attrs,{width:"100%",height:"100%"});break;case"oval":a.tagName="ellipse",Object.assign(a.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":a.tagName="line";break;case"shape":a.tagName="g";break;case"textbox":a.tagName="foreignObject",Object.assign(a.attrs,{width:"100%",height:"100%"});break;default:return null}for(const e of o.default.attrs(t))switch(e.localName){case"style":a.cssStyleText=e.value;break;case"fillcolor":a.attrs.fill=e.value;break;case"strokecolor":a.attrs.stroke=e.value;break;case"strokeweight":a.attrs["stroke-width"]=(0,n.convertLength)(e.value,n.LengthUsage.Point)??e.value;break;case"filled":"f"!=e.value&&"false"!=e.value||(a.attrs.fill="none");break;case"stroked":"f"!=e.value&&"false"!=e.value||(a.attrs.stroke="none");break;case"path":a.tagName="path",a.attrs.d=m(e.value);break;case"from":const[t,r]=p(e.value);Object.assign(a.attrs,{x1:t,y1:r});break;case"to":const[s,o]=p(e.value);Object.assign(a.attrs,{x2:s,y2:o})}for(const n of o.default.elements(t))switch(n.localName){case"stroke":Object.assign(a.attrs,d(n));break;case"fill":Object.assign(a.attrs,h(n));break;case"imagedata":a.tagName="image",Object.assign(a.attrs,l(n)),a.imageHref={id:o.default.attr(n,"id")??o.default.attr(n,"relid")??o.default.attr(n,"pict"),title:o.default.attr(n,"title")};break;case"txbxContent":a.children.push(...r.parseBodyElements(n));break;default:const t=e(n,r);t&&a.children.push(t)}return a};const n=e("../document/common"),s=e("../document/dom"),o=a(e("../parser/xml-parser"));class i extends s.OpenXmlElementBase{constructor(){super(...arguments),this.type=s.DomType.VmlElement,this.attrs={}}}function l(e){const t=c(o.default.attr(e,"cropleft")),r=c(o.default.attr(e,"croptop")),a=c(o.default.attr(e,"cropright")),n=c(o.default.attr(e,"cropbottom")),s=Math.max(1e-4,1-t-a),i=Math.max(1e-4,1-r-n),l={x:u(-t/s),y:u(-r/i),width:u(1/s),height:u(1/i)};return(t||r||a||n)&&(l.preserveAspectRatio="none"),l}function c(e){if(!e)return 0;const t=String(e).trim();if(!t)return 0;let r;return r=/^-?\d+(\.\d+)?f$/i.test(t)?parseFloat(t.slice(0,-1))/65536:t.endsWith("%")?parseFloat(t)/100:parseFloat(t),Number.isFinite(r)?Math.max(0,Math.min(.9999,r)):0}function u(e){return Math.round(1e5*e)/1e3+"%"}function d(e){const t={},r=o.default.attr(e,"color"),a=o.default.attr(e,"weight"),s=o.default.attr(e,"on");return"f"==s||"false"==s?t.stroke="none":r&&(t.stroke=r),t["stroke-width"]=a?(0,n.convertLength)(a,n.LengthUsage.Point)??a:"1px",t}function h(e){const t={},r=o.default.attr(e,"color")??o.default.attr(e,"color2"),a=o.default.attr(e,"on"),n=o.default.attr(e,"opacity");return"f"==a||"false"==a?t.fill="none":r&&(t.fill=r),n&&(t["fill-opacity"]=n.endsWith("%")?""+parseFloat(n)/100:n),t}function p(e){return e.split(",")}function m(e){return e.replace(/([mlxe])|([-\d]+)|([,])/g,e=>/[-\d]/.test(e)?(0,n.convertLength)(e,n.LengthUsage.VmlEmu):/[ml,]/.test(e)?e:"")}r.VmlElement=i},"./word-document":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WordDocument=void 0,r.deobfuscate=w;const a=e("./common/relationship"),n=e("./font-table/font-table"),s=e("./common/open-xml-package"),o=e("./document/document-part"),i=e("./utils"),l=e("./numbering/numbering-part"),c=e("./styles/styles-part"),u=e("./header-footer/parts"),d=e("./document-props/extended-props-part"),h=e("./document-props/core-props-part"),p=e("./theme/theme-part"),m=e("./notes/parts"),f=e("./settings/settings-part"),g=e("./document-props/custom-props-part"),b=e("./comments/comments-part"),y=e("./comments/comments-extended-part"),k=e("./parser/xml-parser"),x=e("./metafile/emf-to-svg"),T=[{type:a.RelationshipTypes.OfficeDocument,target:"word/document.xml"},{type:a.RelationshipTypes.ExtendedProperties,target:"docProps/app.xml"},{type:a.RelationshipTypes.CoreProperties,target:"docProps/core.xml"},{type:a.RelationshipTypes.CustomProperties,target:"docProps/custom.xml"}];class P{constructor(){this.parts=[],this.partsMap={},this.contentTypes=[],this._snapshotAssetDataUrls=null,this._snapshotTextParts=null}static fromSnapshot(e,t){const r=new P;r._options=t,r.rels=e.rels??[],r.contentTypes=e.contentTypes??[],r.parts=[],r.partsMap={},r._snapshotAssetDataUrls=e.assetDataUrls??{},r._snapshotTextParts=e.textParts??{},r._package={load:e=>Promise.resolve(r._snapshotTextParts?.[v(e)]??null),parseXmlDocument:e=>(0,k.parseXmlString)(e,t?.trimXmlDeclaration??!0),get:e=>null!=r._snapshotTextParts?.[v(e)]?{}:null};for(const t of e.parts??[]){const e=r.restoreSnapshotPart(t);e&&(r.parts.push(e),r.partsMap[e.path]=e)}return r}static async load(e,t,r){var a=new P;return a._options=r,a._parser=t,a._package=await s.OpenXmlPackage.load(e,r),a.rels=await a._package.loadRelationships(),a.contentTypes=await a._package.loadContentTypes(),await Promise.all(T.map(e=>{const t=a.rels.find(t=>t.type===e.type)??e;return a.loadRelationshipPart(t.target,t.type)})),a}restoreSnapshotPart(e){const t={path:e.path,rels:e.rels??[]};switch(Object.assign(t,e.data??{}),e.kind){case"document":this.documentPart=t;break;case"fontTable":this.fontTablePart=t;break;case"numbering":this.numberingPart=t;break;case"styles":this.stylesPart=t;break;case"theme":this.themePart=t;break;case"footnotes":this.footnotesPart=t;break;case"endnotes":this.endnotesPart=t;break;case"coreProps":this.corePropsPart=t;break;case"extendedProps":this.extendedPropsPart=t;break;case"settings":this.settingsPart=t;break;case"comments":t.commentMap=(0,i.keyBy)(t.comments??[],e=>e.id),this.commentsPart=t;break;case"commentsExtended":t.commentMap=(0,i.keyBy)(t.comments??[],e=>e.paraId),this.commentsExtendedPart=t}return t}async createSnapshot(){const e={rels:this.rels??[],contentTypes:this.contentTypes??[],parts:this.parts.map(e=>this.snapshotPart(e)).filter(Boolean),assetDataUrls:{},textParts:{}};return await this.preloadSnapshotRelationshipTargets(e),e}snapshotPart(e){const t=e;let r="part",a={};if(e===this.documentPart)r="document",a={body:t.body};else if(e===this.fontTablePart)r="fontTable",a={fonts:t.fonts};else if(e===this.numberingPart)r="numbering",a={numberings:t.numberings,abstractNumberings:t.abstractNumberings,bulletPictures:t.bulletPictures,domNumberings:t.domNumberings};else if(e===this.stylesPart)r="styles",a={styles:t.styles};else if(e===this.themePart)r="theme",a={theme:t.theme};else if(e===this.footnotesPart)r="footnotes",a={notes:t.notes};else if(e===this.endnotesPart)r="endnotes",a={notes:t.notes};else if(e===this.corePropsPart)r="coreProps",a={props:t.props};else if(e===this.extendedPropsPart)r="extendedProps",a={props:t.props};else if(e===this.settingsPart)r="settings",a={settings:t.settings};else if(e===this.commentsPart)r="comments",a={comments:t.comments};else if(e===this.commentsExtendedPart)r="commentsExtended",a={comments:t.comments};else{if(!t.rootElement)return null;r="header"===t.rootElement.type?"header":"footer",a={rootElement:t.rootElement}}return{kind:r,path:e.path,rels:e.rels??[],data:a}}async preloadSnapshotRelationshipTargets(e){const t=new Set,r=e=>{for(const r of e?.rels??[]){if(!r||"External"===r.targetMode)continue;const a=v(this.resolveRelationshipTarget(e,r));a&&!t.has(a)&&t.add(a)}};for(const e of this.parts)r(e);for(const r of t){if(this.partsMap[r])continue;const t=r.toLowerCase(),a=/\.(xml|rels|html?|txt)$/i.test(t);try{if(a){const t=await this._package.load(r,"string");null!=t&&(e.textParts[r]=t)}else{const t=await this.loadPackageAssetDataUrl(r);t&&(e.assetDataUrls[r]=t)}}catch(e){this._options?.debug&&console.warn(`docx-preview: unable to preload relationship target ${r}`,e)}}}blobWithContentType(e,t){if(!e)return null;if(t){const r=this.contentTypes.find(e=>e.partName===t||e.extension&&t.endsWith(`.${e.extension}`));return r?new Blob([e],{type:r.contentType}):e}return e}save(e="blob"){return this._package.save(e)}async loadRelationshipPart(e,t){if(this.partsMap[e])return this.partsMap[e];if(!this._package.get(e))return null;let r=null;switch(t){case a.RelationshipTypes.OfficeDocument:this.documentPart=r=new o.DocumentPart(this._package,e,this._parser);break;case a.RelationshipTypes.FontTable:this.fontTablePart=r=new n.FontTablePart(this._package,e);break;case a.RelationshipTypes.Numbering:this.numberingPart=r=new l.NumberingPart(this._package,e,this._parser);break;case a.RelationshipTypes.Styles:this.stylesPart=r=new c.StylesPart(this._package,e,this._parser);break;case a.RelationshipTypes.Theme:this.themePart=r=new p.ThemePart(this._package,e);break;case a.RelationshipTypes.Footnotes:this.footnotesPart=r=new m.FootnotesPart(this._package,e,this._parser);break;case a.RelationshipTypes.Endnotes:this.endnotesPart=r=new m.EndnotesPart(this._package,e,this._parser);break;case a.RelationshipTypes.Footer:r=new u.FooterPart(this._package,e,this._parser);break;case a.RelationshipTypes.Header:r=new u.HeaderPart(this._package,e,this._parser);break;case a.RelationshipTypes.CoreProperties:this.corePropsPart=r=new h.CorePropsPart(this._package,e);break;case a.RelationshipTypes.ExtendedProperties:this.extendedPropsPart=r=new d.ExtendedPropsPart(this._package,e);break;case a.RelationshipTypes.CustomProperties:r=new g.CustomPropsPart(this._package,e);break;case a.RelationshipTypes.Settings:this.settingsPart=r=new f.SettingsPart(this._package,e);break;case a.RelationshipTypes.Comments:this.commentsPart=r=new b.CommentsPart(this._package,e,this._parser);break;case a.RelationshipTypes.CommentsExtended:this.commentsExtendedPart=r=new y.CommentsExtendedPart(this._package,e)}if(null==r)return Promise.resolve(null);if(this.partsMap[e]=r,this.parts.push(r),await r.load(),r.rels?.length>0){const[e]=(0,i.splitPath)(r.path);await Promise.all(r.rels.filter(e=>"External"!==e.targetMode).map(t=>this.loadRelationshipPart((0,i.resolvePath)(t.target,e),t.type)))}return r}async loadRelationshipXml(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a||"External"===a.targetMode)return null;const n=v(this.resolveRelationshipTarget(r,a)),s=n?this._snapshotTextParts?.[n]??await this._package.load(n,"string"):null;return s?this._package.parseXmlDocument(s):null}async loadRelationshipText(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a||"External"===a.targetMode)return null;const n=v(this.resolveRelationshipTarget(r,a));return n?Promise.resolve(this._snapshotTextParts?.[n]??this._package.load(n,"string")):Promise.resolve(null)}async loadRelationshipBlobUrl(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a)return null;if("External"===a.targetMode)return a.target;const n=v(this.resolveRelationshipTarget(r,a));return n?this.loadPackageAssetUrl(n):null}async loadDocumentImage(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a)return null;if("External"===a.targetMode)return a.target;const n=v(this.resolveRelationshipTarget(r,a));return n?this.loadPackageAssetUrl(n):null}async loadNumberingImage(e){const t=v(this.getPathById(this.numberingPart,e));return t?this.loadPackageAssetUrl(t):null}async loadFont(e,t){const r=v(this.getPathById(this.fontTablePart,e));if(!r)return null;if(this._snapshotAssetDataUrls?.[r])return this._snapshotAssetDataUrls[r];const a=await this._package.load(r,"uint8array");return a?this.blobToURL(new Blob([w(a,t)]),r):a}async loadAltChunk(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a||"External"===a.targetMode)return Promise.resolve(null);const n=v(this.resolveRelationshipTarget(r,a));return n?Promise.resolve(this._snapshotTextParts?.[n]??this._package.load(n,"string")):Promise.resolve(null)}blobToURL(e,t){return e?(e=this.blobWithContentType(e,t),this._options.useBase64URL?(0,i.blobToBase64)(e):URL.createObjectURL(e)):null}async loadPackageAssetUrl(e){const t=v(e);if(!t)return null;if(this._snapshotAssetDataUrls?.[t])return this._snapshotAssetDataUrls[t];if(this.isEmfAsset(t)){const e=await this._package.load(t,"uint8array");if(!e)return null;return this.convertEmfAsset(e,t)||this.blobToURL(new Blob([e],{type:this.contentTypeForPath(t)||"image/x-emf"}),t)}return this.blobToURL(await this._package.load(t,"blob"),t)}async loadPackageAssetDataUrl(e){const t=v(e);if(!t)return null;if(this.isEmfAsset(t)){const e=await this._package.load(t,"uint8array");if(!e)return null;const r=this.convertEmfAsset(e,t);if(r)return r;const a=e?new Blob([e],{type:this.contentTypeForPath(t)||"image/x-emf"}):null;return a?(0,i.blobToBase64)(a):null}const r=await this._package.load(t,"blob"),a=this.blobWithContentType(r,t);return a?(0,i.blobToBase64)(a):null}convertEmfAsset(e,t){if(!e||!(0,x.isEmfBinary)(e))return null;try{return(0,x.convertEmfToSvgDataUrl)(e)}catch(e){return this._options?.debug&&console.warn(`docx-preview: unable to convert EMF asset ${t}`,e),null}}isEmfAsset(e){const t=this.contentTypeForPath(e).toLowerCase();return/\.emf$/i.test(e??"")||"image/x-emf"==t||"image/emf"==t}contentTypeForPath(e){const t=v(e??"").toLowerCase();for(const e of this.contentTypes??[])if(e.partName&&v(e.partName).toLowerCase()==t)return e.contentType??"";const r=/\.([^.\/]+)$/.exec(t),a=r?.[1]??"";if(!a)return"";const n=(this.contentTypes??[]).find(e=>e.extension?.toLowerCase()==a);return n?.contentType??""}findPartByRelId(e,t=null){var r=this.getRelById(t,e);const a=r&&"External"!==r.targetMode?this.resolveRelationshipTarget(t,r):null;return a?this.partsMap[a]:null}getRelById(e,t){return(e?.rels??this.rels??[]).find(e=>e.id==t)}getPathById(e,t){const r=this.getRelById(e,t);return r&&"External"!==r.targetMode?this.resolveRelationshipTarget(e,r):null}resolveRelationshipTarget(e,t){const[r]=e?(0,i.splitPath)(e.path):[""];return v((0,i.resolvePath)(t.target,r))}}function v(e){return e&&e.startsWith("/")?e.substring(1):e}function w(e,t){const r=t.replace(/{|}|-/g,""),a=new Array(16);for(let e=0;e<16;e++)a[16-e-1]=parseInt(r.substring(2*e,2*e+2),16);for(let t=0;t<32;t++)e[t]=e[t]^a[t%16];return e}r.WordDocument=P}},n={};return function e(t,s){var o=function(e,t){if("jszip"===e)return"jszip";if("."===e[0]){var r=function(e){for(var t=e.split("/"),r=[],a=0;a<t.length;a++){var n=t[a];n&&"."!==n&&(".."===n?r.pop():r.push(n))}return"./"+r.join("/")}(t.substring(0,t.lastIndexOf("/")+1)+e);if(a[r])return r;if(a[r+"/index"])return r+"/index"}if(a[e])return e;throw new Error("Cannot resolve module "+e+" from "+t)}(t,s||"./docx-preview-worker");if("jszip"===o)return r;if(n[o])return n[o].exports;var i={exports:{}};return n[o]=i,a[o](function(t){return e(t,o)},i,i.exports),i.exports}("./docx-preview-worker","./docx-preview-worker")}var r=!1;e.onmessage=function(a){var n=a.data||{};if(!r)try{t(n),r=!0,e.onmessage(a)}catch(t){e.postMessage({id:n.id,type:"error",error:{message:t&&t.message?t.message:String(t),stack:t&&t.stack}})}}}(self);
5
+ !function(e){function t(t){!e.JSZip&&t&&t.jsZipUrl&&"function"==typeof e.importScripts&&e.importScripts(t.jsZipUrl);var r=e.JSZip;if(!r)throw new Error("JSZip is not available in the DOCX worker. Set workerJsZipUrl or bundle JSZip.");var a={"./comments/comments-extended-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CommentsExtendedPart=void 0;const a=e("../common/part"),n=e("../utils");class s extends a.Part{constructor(e,t){super(e,t),this.comments=[]}parseXml(e){const t=this._package.xmlParser;for(let r of t.elements(e,"commentEx"))this.comments.push({paraId:t.attr(r,"paraId"),paraIdParent:t.attr(r,"paraIdParent"),done:t.boolAttr(r,"done")});this.commentMap=(0,n.keyBy)(this.comments,e=>e.paraId)}}r.CommentsExtendedPart=s},"./comments/comments-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CommentsPart=void 0;const a=e("../common/part"),n=e("../utils");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.comments=this._documentParser.parseComments(e),this.commentMap=(0,n.keyBy)(this.comments,e=>e.id)}}r.CommentsPart=s},"./comments/elements":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WmlCommentRangeEnd=r.WmlCommentRangeStart=r.WmlCommentReference=r.WmlComment=void 0;const a=e("../document/dom");class n extends a.OpenXmlElementBase{constructor(){super(...arguments),this.type=a.DomType.Comment}}r.WmlComment=n;class s extends a.OpenXmlElementBase{constructor(e){super(),this.id=e,this.type=a.DomType.CommentReference}}r.WmlCommentReference=s;class o extends a.OpenXmlElementBase{constructor(e){super(),this.id=e,this.type=a.DomType.CommentRangeStart}}r.WmlCommentRangeStart=o;class i extends a.OpenXmlElementBase{constructor(e){super(),this.id=e,this.type=a.DomType.CommentRangeEnd}}r.WmlCommentRangeEnd=i},"./common/content-types":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseContentTypes=function(e,t){return t.elements(e).map(e=>({extension:t.attr(e,"Extension"),partName:t.attr(e,"PartName"),contentType:t.attr(e,"ContentType")}))}},"./common/open-xml-package":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.OpenXmlPackage=void 0;const n=a(e("jszip")),s=e("../parser/xml-parser"),o=e("../utils"),i=e("./relationship"),l=e("./content-types");class c{constructor(e,t){this._zip=e,this.options=t,this.xmlParser=new s.XmlParser}get(e){const t=function(e){return e.startsWith("/")?e.substr(1):e}(e);return this._zip.files[t]??this._zip.files[t.replace(/\//g,"\\")]}update(e,t){this._zip.file(e,t)}static async load(e,t){const r=await n.default.loadAsync(e);return new c(r,t)}save(e="blob"){return this._zip.generateAsync({type:e})}load(e,t="string"){return this.get(e)?.async(t)??Promise.resolve(null)}async loadRelationships(e=null){let t="_rels/.rels";if(null!=e){const[r,a]=(0,o.splitPath)(e);t=`${r}_rels/${a}.rels`}const r=await this.load(t);return r?(0,i.parseRelationships)(u(this.parseXmlDocument(r)),this.xmlParser):null}async loadContentTypes(){const e=await this.load("[Content_Types].xml");return e?(0,l.parseContentTypes)(u(this.parseXmlDocument(e)),this.xmlParser):[]}parseXmlDocument(e){return(0,s.parseXmlString)(e,this.options.trimXmlDeclaration)}}function u(e){return e.firstElementChild??e.documentElement}r.OpenXmlPackage=c},"./common/part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Part=void 0;const a=e("../parser/xml-parser");r.Part=class{constructor(e,t){this._package=e,this.path=t}async load(){this.rels=await this._package.loadRelationships(this.path);const e=await this._package.load(this.path),t=this._package.parseXmlDocument(e);this._package.options.keepOrigin&&(this._xmlDocument=t),this.parseXml(t.firstElementChild??t.documentElement)}save(){this._package.update(this.path,(0,a.serializeXmlString)(this._xmlDocument))}parseXml(e){}}},"./common/relationship":function(e,t,r){"use strict";var a;Object.defineProperty(r,"__esModule",{value:!0}),r.RelationshipTypes=void 0,r.parseRelationships=function(e,t){return t.elements(e).map(e=>({id:t.attr(e,"Id"),type:t.attr(e,"Type"),target:t.attr(e,"Target"),targetMode:t.attr(e,"TargetMode")}))},function(e){e.OfficeDocument="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",e.FontTable="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",e.Image="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",e.Numbering="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",e.Styles="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",e.StylesWithEffects="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",e.Theme="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",e.Settings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",e.WebSettings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",e.Hyperlink="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",e.Footnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",e.Endnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",e.Footer="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",e.Header="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",e.ExtendedProperties="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",e.CoreProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",e.CustomProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",e.Comments="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",e.CommentsExtended="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",e.AltChunk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk",e.Chart="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",e.ChartUserShapes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes",e.DiagramData="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData",e.DiagramLayout="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout",e.DiagramQuickStyle="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle",e.DiagramColors="http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors",e.Ink="http://schemas.microsoft.com/office/2007/relationships/ink",e.ContentPart="http://schemas.openxmlformats.org/officeDocument/2006/relationships/contentPart"}(a||(r.RelationshipTypes=a={}))},"./document/bookmarks":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseBookmarkStart=function(e,t){return{type:a.DomType.BookmarkStart,id:t.attr(e,"id"),name:t.attr(e,"name"),colFirst:t.intAttr(e,"colFirst"),colLast:t.intAttr(e,"colLast")}},r.parseBookmarkEnd=function(e,t){return{type:a.DomType.BookmarkEnd,id:t.attr(e,"id")}};const a=e("./dom")},"./document/border":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseBorder=n,r.parseBorders=function(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"left":r.left=n(a,t);break;case"top":r.top=n(a,t);break;case"right":r.right=n(a,t);break;case"bottom":r.bottom=n(a,t)}return r};const a=e("./common");function n(e,t){return{type:t.attr(e,"val"),color:t.attr(e,"color"),size:t.lengthAttr(e,"sz",a.LengthUsage.Border),offset:t.lengthAttr(e,"space",a.LengthUsage.Point),frame:t.boolAttr(e,"frame"),shadow:t.boolAttr(e,"shadow")}}},"./document/common":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LengthUsage=r.ns=void 0,r.convertLength=function(e,t=r.LengthUsage.Dxa){if(null==e||""===e||/.+(p[xt]|[%])$/i.test(e))return e;var n=parseFloat(e);if(Number.isNaN(n))return null;var s=n*t.mul;return null!=t.min&&null!=t.max&&(s=(0,a.clamp)(s,t.min,t.max)),`${s.toFixed(2)}${t.unit}`},r.convertBoolean=function(e,t=!1){switch(e){case"1":case"on":case"true":return!0;case"0":case"off":case"false":return!1;default:return t}},r.convertPercentage=function(e){return e?parseInt(e)/100:null},r.parseCommonProperty=function(e,t,a){if(e.namespaceURI!=r.ns.wordml)return!1;switch(e.localName){case"color":t.color=a.attr(e,"val");break;case"sz":t.fontSize=a.lengthAttr(e,"val",r.LengthUsage.FontSize);break;case"szCs":t.fontSize??(t.fontSize=a.lengthAttr(e,"val",r.LengthUsage.FontSize));break;default:return!1}return!0};const a=e("../utils");r.ns={wordml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",drawingml:"http://schemas.openxmlformats.org/drawingml/2006/main",picture:"http://schemas.openxmlformats.org/drawingml/2006/picture",wordprocessingCanvas:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",wordprocessingGroup:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wordprocessingShape:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",chart:"http://schemas.openxmlformats.org/drawingml/2006/chart",diagram:"http://schemas.openxmlformats.org/drawingml/2006/diagram",relationship:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",drawing2014:"http://schemas.microsoft.com/office/drawing/2014/main",ink2010:"http://schemas.microsoft.com/office/2010/ink",word2010:"http://schemas.microsoft.com/office/word/2010/wordml",compatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006",math:"http://schemas.openxmlformats.org/officeDocument/2006/math"},r.LengthUsage={Dxa:{mul:.05,unit:"pt"},SignedDxa:{mul:.05,unit:"pt"},Emu:{mul:1/12700,unit:"pt"},FontSize:{mul:.5,unit:"pt"},SignedHalfPoint:{mul:.5,unit:"pt"},Border:{mul:.125,unit:"pt",min:.25,max:12},Point:{mul:1,unit:"pt"},Percent:{mul:.02,unit:"%"},LineHeight:{mul:1/240,unit:""},VmlEmu:{mul:1/12700,unit:""}}},"./document/document-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DocumentPart=void 0;const a=e("../common/part");class n extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.body=this._documentParser.parseDocumentFile(e)}}r.DocumentPart=n},"./document/document":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},"./document/dom":function(e,t,r){"use strict";var a;Object.defineProperty(r,"__esModule",{value:!0}),r.OpenXmlElementBase=r.DomType=void 0,function(e){e.Document="document",e.Paragraph="paragraph",e.Run="run",e.Break="break",e.NoBreakHyphen="noBreakHyphen",e.Table="table",e.Row="row",e.Cell="cell",e.Hyperlink="hyperlink",e.SmartTag="smartTag",e.Drawing="drawing",e.Image="image",e.Text="text",e.Tab="tab",e.PositionalTab="positionalTab",e.SoftHyphen="softHyphen",e.Symbol="symbol",e.BookmarkStart="bookmarkStart",e.BookmarkEnd="bookmarkEnd",e.Footer="footer",e.Header="header",e.FootnoteReference="footnoteReference",e.EndnoteReference="endnoteReference",e.Footnote="footnote",e.Endnote="endnote",e.SimpleField="simpleField",e.ComplexField="complexField",e.Instruction="instruction",e.VmlPicture="vmlPicture",e.MmlMath="mmlMath",e.Shape="shape",e.MmlMathParagraph="mmlMathParagraph",e.MmlFraction="mmlFraction",e.MmlFunction="mmlFunction",e.MmlFunctionName="mmlFunctionName",e.MmlNumerator="mmlNumerator",e.MmlDenominator="mmlDenominator",e.MmlRadical="mmlRadical",e.MmlBase="mmlBase",e.MmlDegree="mmlDegree",e.MmlSuperscript="mmlSuperscript",e.MmlSubscript="mmlSubscript",e.MmlPreSubSuper="mmlPreSubSuper",e.MmlSubArgument="mmlSubArgument",e.MmlSuperArgument="mmlSuperArgument",e.MmlNary="mmlNary",e.MmlDelimiter="mmlDelimiter",e.MmlRun="mmlRun",e.MmlEquationArray="mmlEquationArray",e.MmlLimit="mmlLimit",e.MmlLimitLower="mmlLimitLower",e.MmlLimitUpper="mmlLimitUpper",e.MmlSubSuperscript="mmlSubSuperscript",e.MmlPhantom="mmlPhantom",e.MmlBorderBox="mmlBorderBox",e.MmlAccent="mmlAccent",e.MmlMatrix="mmlMatrix",e.MmlMatrixRow="mmlMatrixRow",e.MmlBox="mmlBox",e.MmlBar="mmlBar",e.MmlGroupChar="mmlGroupChar",e.VmlElement="vmlElement",e.Chart="chart",e.SmartArt="smartArt",e.Ink="ink",e.Ruby="ruby",e.RubyBase="rubyBase",e.RubyText="rubyText",e.Inserted="inserted",e.Deleted="deleted",e.DeletedText="deletedText",e.Comment="comment",e.CommentReference="commentReference",e.CommentRangeStart="commentRangeStart",e.CommentRangeEnd="commentRangeEnd",e.AltChunk="altChunk"}(a||(r.DomType=a={})),r.OpenXmlElementBase=class{constructor(){this.children=[],this.cssStyle={}}}},"./document/fields":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},"./document/line-spacing":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseLineSpacing=function(e,t){return{before:t.lengthAttr(e,"before"),after:t.lengthAttr(e,"after"),line:t.intAttr(e,"line"),lineRule:t.attr(e,"lineRule")}}},"./document/paragraph":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseParagraphProperties=function(e,t){let r={};for(let a of t.elements(e))i(a,r,t);return r},r.parseParagraphProperty=i,r.parseTabs=l,r.parseNumbering=c;const a=e("./common"),n=e("./section"),s=e("./line-spacing"),o=e("./run");function i(e,t,r){if(e.namespaceURI!=a.ns.wordml)return!1;if((0,a.parseCommonProperty)(e,t,r))return!0;switch(e.localName){case"tabs":t.tabs=l(e,r);break;case"sectPr":t.sectionProps=(0,n.parseSectionProperties)(e,r);break;case"numPr":t.numbering=c(e,r);break;case"spacing":return t.lineSpacing=(0,s.parseLineSpacing)(e,r),!1;case"textAlignment":return t.textAlignment=r.attr(e,"val"),!1;case"keepLines":t.keepLines=r.boolAttr(e,"val",!0);break;case"keepNext":t.keepNext=r.boolAttr(e,"val",!0);break;case"pageBreakBefore":t.pageBreakBefore=r.boolAttr(e,"val",!0);break;case"widowControl":t.widowControl=r.boolAttr(e,"val",!0);break;case"outlineLvl":t.outlineLevel=r.intAttr(e,"val");break;case"pStyle":t.styleName=r.attr(e,"val");break;case"rPr":t.runProps=(0,o.parseRunProperties)(e,r);break;default:return!1}return!0}function l(e,t){return t.elements(e,"tab").map(e=>({position:t.lengthAttr(e,"pos"),leader:t.attr(e,"leader"),style:t.attr(e,"val")}))}function c(e,t){var r={};for(let a of t.elements(e))switch(a.localName){case"numId":r.id=t.attr(a,"val");break;case"ilvl":r.level=t.intAttr(a,"val")}return r}},"./document/run":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseRunProperties=function(e,t){let r={};for(let a of t.elements(e))n(a,r,t);return r},r.parseRunProperty=n;const a=e("./common");function n(e,t,r){return!!(0,a.parseCommonProperty)(e,t,r)}},"./document/section":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.SectionType=void 0,r.isSectionPageBreak=function(e){return null==e||e===o.NextPage||e===o.EvenPage||e===o.OddPage},r.isSectionColumnBreak=function(e){return e===o.NextColumn},r.parseSectionProperties=function(e,t=n.default){var r={};for(let a of t.elements(e))switch(a.localName){case"pgSz":r.pageSize={width:t.lengthAttr(a,"w"),height:t.lengthAttr(a,"h"),orientation:t.attr(a,"orient")};break;case"type":r.type=t.attr(a,"val");break;case"pgMar":r.pageMargins={left:t.lengthAttr(a,"left"),right:t.lengthAttr(a,"right"),top:t.lengthAttr(a,"top"),bottom:t.lengthAttr(a,"bottom"),header:t.lengthAttr(a,"header"),footer:t.lengthAttr(a,"footer"),gutter:t.lengthAttr(a,"gutter")};break;case"cols":r.columns=i(a,t);break;case"headerReference":(r.headerRefs??(r.headerRefs=[])).push(u(a,t));break;case"footerReference":(r.footerRefs??(r.footerRefs=[])).push(u(a,t));break;case"titlePg":r.titlePage=t.boolAttr(a,"val",!0);break;case"pgBorders":r.pageBorders=(0,s.parseBorders)(a,t);break;case"pgNumType":r.pageNumber=l(a,t);break;case"docGrid":r.docGrid=c(a,t)}return r};const n=a(e("../parser/xml-parser")),s=e("./border");var o;function i(e,t){return{numberOfColumns:t.intAttr(e,"num"),space:t.lengthAttr(e,"space"),separator:t.boolAttr(e,"sep"),equalWidth:t.boolAttr(e,"equalWidth",!0),columns:t.elements(e,"col").map(e=>({width:t.lengthAttr(e,"w"),space:t.lengthAttr(e,"space")}))}}function l(e,t){return{chapSep:t.attr(e,"chapSep"),chapStyle:t.attr(e,"chapStyle"),format:t.attr(e,"fmt"),start:t.intAttr(e,"start")}}function c(e,t){const r=t.intAttr(e,"charSpace",null);return{type:t.attr(e,"type"),linePitch:t.lengthAttr(e,"linePitch"),charSpace:null==r?null:`${(r/4096).toFixed(4)}em`,charSpaceRaw:r}}function u(e,t){return{id:t.attr(e,"id"),type:t.attr(e,"type")}}!function(e){e.Continuous="continuous",e.NextPage="nextPage",e.NextColumn="nextColumn",e.EvenPage="evenPage",e.OddPage="oddPage"}(o||(r.SectionType=o={}))},"./document/style":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},"./document-parser":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.DocumentParser=r.autos=void 0;const n=e("./document/dom"),s=e("./document/paragraph"),o=e("./document/section"),i=a(e("./parser/xml-parser")),l=e("./document/run"),c=e("./document/bookmarks"),u=e("./document/common"),d=e("./vml/vml"),h=e("./comments/elements"),p=e("./utils");r.autos={shd:"inherit",color:"black",borderColor:"black",highlight:"transparent"};const m=[u.ns.wordprocessingShape,u.ns.wordprocessingCanvas,u.ns.wordprocessingGroup,u.ns.drawingml,u.ns.picture],f={oMath:n.DomType.MmlMath,oMathPara:n.DomType.MmlMathParagraph,f:n.DomType.MmlFraction,func:n.DomType.MmlFunction,fName:n.DomType.MmlFunctionName,num:n.DomType.MmlNumerator,den:n.DomType.MmlDenominator,rad:n.DomType.MmlRadical,deg:n.DomType.MmlDegree,e:n.DomType.MmlBase,sSup:n.DomType.MmlSuperscript,sSub:n.DomType.MmlSubscript,sPre:n.DomType.MmlPreSubSuper,sup:n.DomType.MmlSuperArgument,sub:n.DomType.MmlSubArgument,d:n.DomType.MmlDelimiter,nary:n.DomType.MmlNary,eqArr:n.DomType.MmlEquationArray,lim:n.DomType.MmlLimit,limLow:n.DomType.MmlLimitLower,limUpp:n.DomType.MmlLimitUpper,sSubSup:n.DomType.MmlSubSuperscript,phant:n.DomType.MmlPhantom,borderBox:n.DomType.MmlBorderBox,acc:n.DomType.MmlAccent,m:n.DomType.MmlMatrix,mr:n.DomType.MmlMatrixRow,box:n.DomType.MmlBox,bar:n.DomType.MmlBar,groupChr:n.DomType.MmlGroupChar};r.DocumentParser=class{constructor(e){this.options={ignoreWidth:!1,debug:!1,hideWebHiddenContent:!1,...e}}parseNotes(e,t,r){var a=[];for(let n of i.default.elements(e,t)){const e=new r;e.id=i.default.attr(n,"id"),e.noteType=i.default.attr(n,"type"),e.children=this.parseBodyElements(n),a.push(e)}return a}parseComments(e){var t=[];for(let r of i.default.elements(e,"comment")){const e=new h.WmlComment;e.id=i.default.attr(r,"id"),e.author=i.default.attr(r,"author"),e.initials=i.default.attr(r,"initials"),e.date=i.default.attr(r,"date"),e.children=this.parseBodyElements(r),t.push(e)}return t}parseDocumentFile(e){var t=i.default.element(e,"body"),r=i.default.element(e,"background"),a=i.default.element(t,"sectPr");return{type:n.DomType.Document,children:this.parseBodyElements(t),props:a?(0,o.parseSectionProperties)(a,i.default):{},cssStyle:r?this.parseBackground(r):{}}}parseBackground(e){var t={},r=b.colorAttr(e,"color");return r&&(t["background-color"]=r),t}parseBodyElements(e){var t=[];for(const r of i.default.elements(e))switch(r.localName){case"p":t.push(this.parseParagraph(r));break;case"altChunk":t.push(this.parseAltChunk(r));break;case"tbl":t.push(this.parseTable(r));break;case"sdt":t.push(...this.parseSdt(r,e=>this.parseBodyElements(e)))}return t}parseStylesFile(e){var t=[];for(const r of i.default.elements(e))switch(r.localName){case"style":t.push(this.parseStyle(r));break;case"docDefaults":t.push(this.parseDefaultStyles(r))}return t}parseDefaultStyles(e){var t={id:null,name:null,target:null,basedOn:null,styles:[]};for(const n of i.default.elements(e))switch(n.localName){case"rPrDefault":var r=i.default.element(n,"rPr");r&&t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})});break;case"pPrDefault":var a=i.default.element(n,"pPr");a&&t.styles.push({target:"p",values:this.parseDefaultProperties(a,{})})}return t}parseStyle(e){var t={id:i.default.attr(e,"styleId"),isDefault:i.default.boolAttr(e,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(i.default.attr(e,"type")){case"paragraph":t.target="p";break;case"table":t.target="table";break;case"character":t.target="span"}for(const r of i.default.elements(e))switch(r.localName){case"basedOn":t.basedOn=i.default.attr(r,"val");break;case"name":t.name=i.default.attr(r,"val");break;case"link":t.linked=i.default.attr(r,"val");break;case"next":t.next=i.default.attr(r,"val");break;case"aliases":t.aliases=i.default.attr(r,"val").split(",");break;case"pPr":t.styles.push({target:"p",values:this.parseDefaultProperties(r,{})}),t.paragraphProps=(0,s.parseParagraphProperties)(r,i.default);break;case"rPr":t.styles.push({target:"span",values:this.parseDefaultProperties(r,{})}),t.runProps=(0,l.parseRunProperties)(r,i.default);break;case"tblPr":case"tcPr":t.styles.push({target:"td",values:this.parseDefaultProperties(r,{})});break;case"tblStylePr":for(let e of this.parseTableStyle(r))t.styles.push(e);break;case"rsid":case"qFormat":case"hidden":case"semiHidden":case"unhideWhenUsed":case"autoRedefine":case"uiPriority":break;default:this.options.debug&&console.warn(`DOCX: Unknown style element: ${r.localName}`)}return t}parseTableStyle(e){var t=[],r="",a="";switch(i.default.attr(e,"type")){case"firstRow":a=".first-row",r="tr.first-row td";break;case"lastRow":a=".last-row",r="tr.last-row td";break;case"firstCol":a=".first-col",r="td.first-col";break;case"lastCol":a=".last-col",r="td.last-col";break;case"band1Vert":a=":not(.no-vband)",r="td.odd-col";break;case"band2Vert":a=":not(.no-vband)",r="td.even-col";break;case"band1Horz":a=":not(.no-hband)",r="tr.odd-row";break;case"band2Horz":a=":not(.no-hband)",r="tr.even-row";break;default:return[]}for(const n of i.default.elements(e))switch(n.localName){case"pPr":t.push({target:`${r} p`,mod:a,values:this.parseDefaultProperties(n,{})});break;case"rPr":t.push({target:`${r} span`,mod:a,values:this.parseDefaultProperties(n,{})});break;case"tblPr":case"tcPr":t.push({target:r,mod:a,values:this.parseDefaultProperties(n,{})})}return t}parseNumberingFile(e){const t=[],r=[],a={},n=[],s=[];for(const t of i.default.elements(e))switch(t.localName){case"numPicBullet":r.push(this.parseNumberingPicBullet(t));break;case"abstractNum":n.push(t);break;case"num":s.push(t)}for(const e of n)a[i.default.attr(e,"abstractNumId")]=this.parseAbstractNumbering(e,r);for(const e of s){const n=i.default.attr(e,"numId"),s=(a[i.default.elementAttr(e,"abstractNumId","val")]??[]).map(e=>this.cloneNumberingLevel(e,n));for(const t of i.default.elements(e,"lvlOverride")){const e=i.default.intAttr(t,"ilvl"),a=i.default.element(t,"lvl"),o=i.default.element(t,"startOverride");let l=s.find(t=>t.level==e);if(a){l=this.parseNumberingLevel(n,a,r);const t=s.findIndex(t=>t.level==e);t>=0?s[t]=l:s.push(l)}o&&l&&(l.start=i.default.intAttr(o,"val",l.start))}t.push(...s)}return t}cloneNumberingLevel(e,t){return{...e,id:t,pStyle:{...e.pStyle},rStyle:{...e.rStyle},bullet:e.bullet?{...e.bullet}:null}}parseNumberingPicBullet(e){const t=i.default.intAttr(e,"numPicBulletId"),r=i.default.element(e,"pict"),a=r&&i.default.element(r,"shape"),n=a&&i.default.element(a,"imagedata");if(n)return{id:t,src:i.default.attr(n,"id"),style:i.default.attr(a,"style")};const s=i.default.element(e,"drawing"),o=s?this.findDescendant(s,"blip"):null;if(o){const e=s?this.findDescendant(s,"extent"):null,r=[];if(e){const t=i.default.lengthAttr(e,"cx",u.LengthUsage.Emu),a=i.default.lengthAttr(e,"cy",u.LengthUsage.Emu);t&&r.push(`width:${t};`),a&&r.push(`height:${a};`)}return{id:t,src:i.default.attr(o,"embed")??i.default.attr(o,"link"),style:r.join("")||void 0}}return null}parseAbstractNumbering(e,t){var r=[],a=i.default.attr(e,"abstractNumId");for(const n of i.default.elements(e))"lvl"===n.localName&&r.push(this.parseNumberingLevel(a,n,t));return r}parseNumberingLevel(e,t,r){var a={id:e,level:i.default.intAttr(t,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(const e of i.default.elements(t))switch(e.localName){case"start":a.start=i.default.intAttr(e,"val");break;case"pPr":this.parseDefaultProperties(e,a.pStyle);break;case"rPr":this.parseDefaultProperties(e,a.rStyle);break;case"lvlPicBulletId":var n=i.default.intAttr(e,"val");a.bullet=r.find(e=>e?.id==n);break;case"lvlText":a.levelText=i.default.attr(e,"val");break;case"pStyle":a.pStyleName=i.default.attr(e,"val");break;case"numFmt":a.format=i.default.attr(e,"val");break;case"lvlRestart":a.restart=i.default.intAttr(e,"val");break;case"suff":a.suff=i.default.attr(e,"val")}return a}parseSdt(e,t){const r=i.default.element(e,"sdtContent");return r?t(r):[]}parseInserted(e,t){return{type:n.DomType.Inserted,children:t(e)?.children??[]}}parseDeleted(e,t){return{type:n.DomType.Deleted,children:t(e)?.children??[]}}parseAltChunk(e){return{type:n.DomType.AltChunk,children:[],id:i.default.attr(e,"id")}}parseParagraph(e){var t={type:n.DomType.Paragraph,children:[]};for(let r of i.default.elements(e))switch(r.localName){case"pPr":this.parseParagraphProperties(r,t);break;case"r":t.children.push(this.parseRun(r,t));break;case"hyperlink":t.children.push(this.parseHyperlink(r,t));break;case"smartTag":t.children.push(this.parseSmartTag(r,t));break;case"bookmarkStart":t.children.push((0,c.parseBookmarkStart)(r,i.default));break;case"bookmarkEnd":t.children.push((0,c.parseBookmarkEnd)(r,i.default));break;case"commentRangeStart":t.children.push(new h.WmlCommentRangeStart(i.default.attr(r,"id")));break;case"commentRangeEnd":t.children.push(new h.WmlCommentRangeEnd(i.default.attr(r,"id")));break;case"oMath":case"oMathPara":{const e=this.parseMathElement(r);e&&t.children.push(e);break}case"sdt":t.children.push(...this.parseSdt(r,e=>this.parseParagraph(e).children));break;case"ins":t.children.push(this.parseInserted(r,e=>this.parseParagraph(e)));break;case"del":t.children.push(this.parseDeleted(r,e=>this.parseParagraph(e)))}return t}parseParagraphProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{if("rPr"==e.localName){i.default.element(e,"del")&&(t.props={...t.props??{},deletedParagraphMark:!0});const r=t.cssStyle["background-color"];return this.parseDefaultProperties(e,t.cssStyle),null==r?delete t.cssStyle["background-color"]:t.cssStyle["background-color"]=r,(0,s.parseParagraphProperty)(e,t,i.default),!0}if((0,s.parseParagraphProperty)(e,t,i.default))return!0;switch(e.localName){case"pStyle":t.styleName=i.default.attr(e,"val");break;case"cnfStyle":t.className=y.classNameOfCnfStyle(e);break;case"framePr":this.parseFrame(e,t);break;default:return!1}return!0})}parseFrame(e,t){"drop"==i.default.attr(e,"dropCap")&&(t.cssStyle.float="left")}parseHyperlink(e,t){var r={type:n.DomType.Hyperlink,parent:t,children:[]};r.anchor=i.default.attr(e,"anchor"),r.id=i.default.attr(e,"id");for(const t of i.default.elements(e))"r"===t.localName&&r.children.push(this.parseRun(t,r));return r}parseSmartTag(e,t){var r={type:n.DomType.SmartTag,parent:t,children:[]},a=i.default.attr(e,"uri"),s=i.default.attr(e,"element");a&&(r.uri=a),s&&(r.element=s);for(const t of i.default.elements(e))switch(t.localName){case"r":r.children.push(this.parseRun(t,r));break;case"smartTag":r.children.push(this.parseSmartTag(t,r))}return r}parseSimpleField(e,t){const r={type:n.DomType.SimpleField,parent:t,children:[],instruction:i.default.attr(e,"instr"),lock:i.default.boolAttr(e,"lock",!1),dirty:i.default.boolAttr(e,"dirty",!1)};for(const t of i.default.elements(e))switch(t.localName){case"r":r.children.push(this.parseRun(t,r));break;case"hyperlink":r.children.push(this.parseHyperlink(t,r));break;case"smartTag":r.children.push(this.parseSmartTag(t,r));break;case"bookmarkStart":r.children.push((0,c.parseBookmarkStart)(t,i.default));break;case"bookmarkEnd":r.children.push((0,c.parseBookmarkEnd)(t,i.default));break;case"commentRangeStart":r.children.push(new h.WmlCommentRangeStart(i.default.attr(t,"id")));break;case"commentRangeEnd":r.children.push(new h.WmlCommentRangeEnd(i.default.attr(t,"id")));break;case"sdt":r.children.push(...this.parseSdt(t,e=>this.parseParagraph(e).children));break;case"ins":r.children.push(this.parseInserted(t,e=>this.parseParagraph(e)));break;case"del":r.children.push(this.parseDeleted(t,e=>this.parseParagraph(e)))}return r}parseRun(e,t){var r={type:n.DomType.Run,parent:t,children:[]};for(let t of i.default.elements(e))if(t=this.checkAlternateContent(t),t)switch(t.localName){case"t":r.children.push({type:n.DomType.Text,text:t.textContent});break;case"delText":r.children.push({type:n.DomType.DeletedText,text:t.textContent});break;case"commentReference":r.children.push(new h.WmlCommentReference(i.default.attr(t,"id")));break;case"fldSimple":r.children.push(this.parseSimpleField(t,r));break;case"instrText":r.fieldRun=!0,r.children.push({type:n.DomType.Instruction,text:t.textContent});break;case"fldChar":r.fieldRun=!0,r.children.push({type:n.DomType.ComplexField,charType:i.default.attr(t,"fldCharType"),lock:i.default.boolAttr(t,"lock",!1),dirty:i.default.boolAttr(t,"dirty",!1)});break;case"noBreakHyphen":r.children.push({type:n.DomType.NoBreakHyphen});break;case"softHyphen":r.children.push({type:n.DomType.SoftHyphen});break;case"cr":r.children.push({type:n.DomType.Break,break:"line"});break;case"ptab":r.children.push({type:n.DomType.PositionalTab});break;case"br":r.children.push({type:n.DomType.Break,break:i.default.attr(t,"type")||"textWrapping"});break;case"lastRenderedPageBreak":r.children.push({type:n.DomType.Break,break:"lastRenderedPageBreak"});break;case"sym":r.children.push({type:n.DomType.Symbol,font:(0,p.encloseFontFamily)(i.default.attr(t,"font")),char:i.default.hexAttr(t,"char")});break;case"tab":r.children.push({type:n.DomType.Tab});break;case"footnoteReference":r.children.push({type:n.DomType.FootnoteReference,id:i.default.attr(t,"id")});break;case"endnoteReference":r.children.push({type:n.DomType.EndnoteReference,id:i.default.attr(t,"id")});break;case"drawing":let e=this.parseDrawing(t);e&&r.children.push(e);break;case"pict":case"object":r.children.push(this.parseVmlPicture(t));break;case"ruby":r.children.push(this.parseRuby(t));break;case"rPr":this.parseRunProperties(t,r)}return r}parseRuby(e){const t={type:n.DomType.Ruby,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"rubyPr":for(const e of i.default.elements(r))"rubyAlign"===e.localName&&(t.align=i.default.attr(e,"val"));break;case"rt":t.children.push(this.parseRubyContent(r,n.DomType.RubyText));break;case"rubyBase":t.children.push(this.parseRubyContent(r,n.DomType.RubyBase))}return t}parseRubyContent(e,t){const r={type:t,children:[]};for(const a of i.default.elements(e))if("r"==a.localName)r.children.push(this.parseRun(a,r));else if(t==n.DomType.RubyText&&"rPr"==a.localName){const e=i.default.element(a,"hps"),t=e?i.default.intAttr(e,"val",null):null;null!=t&&(r.cssStyle={...r.cssStyle??{},fontSize:t/2+"pt"})}return r}parseMathElement(e){const t=`${e.localName}Pr`,r={type:f[e.localName],children:[]};let a=!1;const s=e=>{if(f[e.localName]){const t=this.parseMathElement(e);t?(t.parent=r,r.children.push(t)):a=!0}else if("r"==e.localName){var o=this.parseRun(e,r);o.type=n.DomType.MmlRun,r.children.push(o)}else if(e.localName==t)r.props=this.parseMathProperies(e);else if("ins"==e.localName)for(const t of i.default.elements(e))s(t);else if("del"==e.localName)if(this.options.renderChanges)for(const t of i.default.elements(e))s(t);else a=!0};for(const t of i.default.elements(e))s(t);return a&&!this.hasVisibleMathContent(r)?null:r}hasVisibleMathContent(e){for(const t of e.children??[]){switch(t.type){case n.DomType.Text:if(t.text?.length)return!0;break;case n.DomType.DeletedText:if(this.options.renderChanges&&t.text?.length)return!0;break;case n.DomType.Symbol:case n.DomType.Tab:case n.DomType.PositionalTab:case n.DomType.NoBreakHyphen:case n.DomType.Break:return!0}if(this.hasVisibleMathContent(t))return!0}return!1}parseMathProperies(e){const t={};for(const r of i.default.elements(e))switch(r.localName){case"chr":t.char=i.default.attr(r,"val");break;case"vertJc":t.verticalJustification=i.default.attr(r,"val");break;case"pos":t.position=i.default.attr(r,"val");break;case"degHide":t.hideDegree=i.default.boolAttr(r,"val");break;case"begChr":t.beginChar=i.default.attr(r,"val");break;case"endChr":t.endChar=i.default.attr(r,"val");break;case"limLoc":t.limitLocation=i.default.attr(r,"val");break;case"grow":t.grow=i.default.boolAttr(r,"val");break;case"sepChr":t.separatorChar=i.default.attr(r,"val")}return t}parseRunProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{switch(e.localName){case"rStyle":t.styleName=i.default.attr(e,"val");break;case"vertAlign":t.verticalAlign=y.valueOfVertAlign(e,!0);break;default:return!1}return!0})}parseVmlPicture(e){const t={type:n.DomType.VmlPicture,children:[]};for(const r of i.default.elements(e)){const e=(0,d.parseVmlElement)(r,this);e&&t.children.push(e)}return t}checkAlternateContent(e){if("AlternateContent"!=e.localName)return e;for(const t of i.default.elements(e).filter(e=>"Choice"==e.localName)){const r=(i.default.attr(t,"Requires")??"").split(/\s+/).filter(Boolean);if(r.length>0&&r.every(t=>m.includes(e.lookupNamespaceURI(t)))){const e=i.default.elements(t)[0];if(e)return e}}const t=i.default.element(e,"Fallback");return t?i.default.elements(t)[0]:null}parseDrawing(e){for(var t of i.default.elements(e))switch(t.localName){case"inline":case"anchor":return this.parseDrawingWrapper(t)}}parseDrawingWrapper(e){var t,r,a,s,o,l,c,d,h,p,m,f={type:n.DomType.Drawing,children:[],cssStyle:{},props:{}},g="anchor"==e.localName;const b=(e,t)=>{t&&(f.cssStyle[e]=y.addSize(f.cssStyle[e],t))};b("margin-left",i.default.lengthAttr(e,"distL",u.LengthUsage.Emu)),b("margin-top",i.default.lengthAttr(e,"distT",u.LengthUsage.Emu)),b("margin-right",i.default.lengthAttr(e,"distR",u.LengthUsage.Emu)),b("margin-bottom",i.default.lengthAttr(e,"distB",u.LengthUsage.Emu));let k=null,x=null,T=null,P=i.default.boolAttr(e,"simplePos",!1),v=i.default.boolAttr(e,"behindDoc",!1),S=i.default.intAttr(e,"relativeHeight",null);null!=S&&(f.cssStyle["z-index"]=`${Math.max(1,Math.round(S/1e3))}`),v&&(f.cssStyle["z-index"]="0");let w={relative:"page",align:"left",offset:"0"},C={relative:"page",align:"top",offset:"0"},E=!1,N=!1,M=!1;for(var A of i.default.elements(e))switch(A.localName){case"simplePos":P&&(w.offset=i.default.lengthAttr(A,"x",u.LengthUsage.Emu),C.offset=i.default.lengthAttr(A,"y",u.LengthUsage.Emu),N=null!=w.offset,M=null!=C.offset);break;case"extent":f.cssStyle.width=i.default.lengthAttr(A,"cx",u.LengthUsage.Emu),f.cssStyle.height=i.default.lengthAttr(A,"cy",u.LengthUsage.Emu);break;case"effectExtent":b("margin-left",i.default.lengthAttr(A,"l",u.LengthUsage.Emu)),b("margin-top",i.default.lengthAttr(A,"t",u.LengthUsage.Emu)),b("margin-right",i.default.lengthAttr(A,"r",u.LengthUsage.Emu)),b("margin-bottom",i.default.lengthAttr(A,"b",u.LengthUsage.Emu));break;case"docPr":f.props.title=i.default.attr(A,"title")??i.default.attr(A,"name"),f.props.alt=i.default.attr(A,"descr")??f.props.title;break;case"positionH":case"positionV":if(!P){let e="positionH"==A.localName,t=e?w:C;var D=i.default.element(A,"align"),L=i.default.element(A,"posOffset");t.relative=i.default.attr(A,"relativeFrom")??t.relative,D&&(t.align=D.textContent,e&&(E=!0)),L&&(t.offset=(0,u.convertLength)(L.textContent,u.LengthUsage.Emu),e?N=null!=t.offset:M=null!=t.offset)}break;case"wrapTopAndBottom":k="wrapTopAndBottom";break;case"wrapNone":k="wrapNone";break;case"wrapSquare":k="wrapSquare",x=i.default.attr(A,"wrapText");break;case"wrapTight":k="wrapTight",x=i.default.attr(A,"wrapText"),T=this.parseWrapPolygon(A);break;case"wrapThrough":k="wrapThrough",x=i.default.attr(A,"wrapText"),T=this.parseWrapPolygon(A);break;case"graphic":var $=this.parseGraphic(A);$&&($.type==n.DomType.Image?((t=$).alt??(t.alt=f.props.alt),(r=$).title??(r.title=f.props.title)):$.type==n.DomType.Shape?((a=$).alt??(a.alt=f.props.alt),(s=$).title??(s.title=f.props.title)):$.type==n.DomType.Chart?((o=$).alt??(o.alt=f.props.alt),(l=$).title??(l.title=f.props.title)):$.type==n.DomType.SmartArt?((c=$).alt??(c.alt=f.props.alt),(d=$).title??(d.title=f.props.title)):$.type==n.DomType.Ink&&((h=$).alt??(h.alt=f.props.alt),(p=$).title??(p.title=f.props.title)),f.children.push($))}f.props.anchorPosition={horizontal:{...w},vertical:{...C},wrapType:k,layoutInCell:i.default.boolAttr(e,"layoutInCell",!0),simplePos:P};const R=()=>{switch(w.align){case"center":f.cssStyle["margin-left"]="auto",f.cssStyle["margin-right"]="auto";break;case"right":f.cssStyle["margin-left"]="auto"}};return"wrapTopAndBottom"==k?(f.cssStyle.display="block",f.cssStyle.clear="both",E?R():N&&w.offset&&(f.cssStyle["margin-inline-start"]=y.addSize(f.cssStyle["margin-inline-start"],w.offset)),M&&C.offset&&(f.cssStyle["margin-top"]=y.addSize(f.cssStyle["margin-top"],C.offset))):"wrapNone"==k?(f.cssStyle.display="block",f.cssStyle.position=g?"absolute":"relative",w.offset&&(f.cssStyle.left=w.offset),C.offset&&(f.cssStyle.top=C.offset)):"wrapSquare"==k||"wrapTight"==k||"wrapThrough"==k?(T&&(f.cssStyle["shape-outside"]=T,(m=f.cssStyle)["clip-path"]??(m["clip-path"]=T)),"left"==x?f.cssStyle.float="right":"right"==x?f.cssStyle.float="left":"left"==w.align||"right"==w.align?f.cssStyle.float=w.align:(f.cssStyle.display="block",R())):!g||"left"!=w.align&&"right"!=w.align?f.cssStyle["vertical-align"]="text-bottom":f.cssStyle.float=w.align,f}parseWrapPolygon(e){const t=i.default.element(e,"wrapPolygon");if(!t)return null;const r=[],a=e=>{const t=i.default.lengthAttr(e,"x",u.LengthUsage.Emu),a=i.default.lengthAttr(e,"y",u.LengthUsage.Emu);t&&a&&r.push(`${t} ${a}`)};for(const e of i.default.elements(t))"start"!=e.localName&&"lineTo"!=e.localName||a(e);return r.length>=3?`polygon(${r.join(", ")})`:null}parseGraphic(e){var t=i.default.element(e,"graphicData");if(!t)return null;for(let e of i.default.elements(t))switch(e.localName){case"pic":return this.parsePicture(e);case"wpc":case"wgp":case"grpSp":return this.parseDrawingContainer(e);case"wsp":case"sp":case"cxnSp":return this.parseWordprocessingShape(e);case"chart":return this.parseChartReference(e);case"relIds":case"diagram":return this.parseSmartArtReference(e);case"contentPart":case"ink":return this.parseInkReference(e)}const r=this.findDescendant(t,"contentPart");return r?this.parseInkReference(r):null}parseDrawingContainer(e){const t={type:n.DomType.Shape,children:[],cssStyle:{display:"inline-block",position:"relative",width:"100%",height:"100%",overflow:"visible","box-sizing":"border-box"},props:{dmlContainer:!0}},r=this.parseDmlGroupTransform(e);for(const a of i.default.elements(e))switch(a.localName){case"wsp":case"sp":case"cxnSp":const e=this.parseDmlPositionedShape(a,r);e&&t.children.push(e);break;case"grpSp":case"wgp":const n=this.parseDrawingContainer(a);n&&t.children.push(n)}return t}parseDmlGroupTransform(e){const t=i.default.element(e,"grpSpPr"),r=t?i.default.element(t,"xfrm"):i.default.element(e,"xfrm"),a=r?i.default.element(r,"off"):null,n=r?i.default.element(r,"ext"):null,s=r?i.default.element(r,"chOff"):null,o=r?i.default.element(r,"chExt"):null,l=n?i.default.floatAttr(n,"cx",null):null,c=n?i.default.floatAttr(n,"cy",null):null,u=o?i.default.floatAttr(o,"cx",null):null,d=o?i.default.floatAttr(o,"cy",null):null;return{offsetX:s?i.default.floatAttr(s,"x",0):0,offsetY:s?i.default.floatAttr(s,"y",0):0,left:a?i.default.floatAttr(a,"x",0):0,top:a?i.default.floatAttr(a,"y",0):0,scaleX:l&&u?l/u:1,scaleY:c&&d?c/d:1}}parseDmlPositionedShape(e,t){const r=i.default.element(e,"spPr");if(!r)return null;const a=this.parseDmlShapeBounds(r,t),s=[];let o=null,l=!1;for(const t of i.default.elements(e))switch(t.localName){case"txbx":case"textBox":l=!0;for(const e of i.default.elements(t,"txbxContent"))s.push(...this.parseBodyElements(e));break;case"bodyPr":o=t}o??(o=i.default.element(e,"bodyPr"));const c={position:"absolute",left:this.pt(a.left),top:this.pt(a.top),width:this.pt(a.width),height:this.pt(a.height),"box-sizing":"border-box",overflow:"hidden"},u=i.default.element(e,"cNvPr"),d=i.default.element(r,"custGeom"),h=i.default.element(r,"prstGeom"),p=this.parseDmlFillStyle(r),m=this.parseDmlLineStyle(i.default.element(r,"ln"));if(d){const e=this.parseDmlCustomGeometry(d);return{type:n.DomType.Shape,children:[],cssStyle:{...c,overflow:"visible"},props:{dmlSvg:!0,viewBox:e?.viewBox??"0 0 1 1",pathD:e?.d??"",fill:p.fill??"none",stroke:m.stroke??"none",strokeWidth:m.strokeWidth??"0",strokeDasharray:m.strokeDasharray},title:u?i.default.attr(u,"title")??i.default.attr(u,"name"):null,alt:u?i.default.attr(u,"descr"):null}}p.backgroundColor&&(c["background-color"]=p.backgroundColor),p.backgroundImage&&(c["background-image"]=p.backgroundImage),m.stroke&&"none"!=m.stroke?c.border=`${m.strokeWidth||"0.75pt"} ${m.borderType||"solid"} ${m.stroke}`:c.border="none";const f=l?this.parseDmlTextBoxProperties(o):null;return{type:n.DomType.Shape,children:s,cssStyle:c,props:{dmlShape:!0,presetGeometry:h?i.default.attr(h,"prst"):null,...f},title:u?i.default.attr(u,"title")??i.default.attr(u,"name"):null,alt:u?i.default.attr(u,"descr"):null}}parseDmlShapeBounds(e,t){const r=i.default.element(e,"xfrm"),a=r?i.default.element(r,"off"):null,n=r?i.default.element(r,"ext"):null,s=t?.scaleX??1,o=t?.scaleY??1,l=t?.offsetX??0,c=t?.offsetY??0,u=t?.left??0,d=t?.top??0,h=a?i.default.floatAttr(a,"x",0):0,p=a?i.default.floatAttr(a,"y",0):0,m=n?i.default.floatAttr(n,"cx",0):0,f=n?i.default.floatAttr(n,"cy",0):0;return{left:this.emuToPt(u+(h-l)*s),top:this.emuToPt(d+(p-c)*o),width:Math.max(0,this.emuToPt(m*s)),height:Math.max(0,this.emuToPt(f*o))}}parseDmlFillStyle(e){if(i.default.element(e,"noFill"))return{fill:"none",backgroundColor:"transparent"};const t=i.default.element(e,"solidFill");if(t){const e=this.parseDmlColor(t)??"transparent";return{fill:e,backgroundColor:e}}const r=i.default.element(e,"pattFill");if(r){const e=this.parseDmlColor(i.default.element(r,"fgClr"))??"currentColor",t=this.parseDmlColor(i.default.element(r,"bgClr"))??"transparent",a=i.default.attr(r,"prst");return{fill:t,backgroundColor:t,backgroundImage:`repeating-linear-gradient(${a&&a.toLowerCase().includes("horz")?"0deg":"90deg"}, ${e} 0, ${e} 0.75pt, ${t} 0.75pt, ${t} 3pt)`}}return{fill:"none",backgroundColor:"transparent"}}parseDmlLineStyle(e){if(!e||i.default.element(e,"noFill"))return{stroke:"none",strokeWidth:"0",borderType:"none"};const t=this.parseDmlColor(i.default.element(e,"solidFill"))??"black",r=i.default.attr(e,"w")?this.pt(this.emuToPt(i.default.floatAttr(e,"w",0))):"0.75pt",a=i.default.elementAttr(e,"prstDash","val");let n=null,s="solid";return a&&"solid"!=a&&(s="dashed",n="dot"==a?"1 2":"4 3"),{stroke:t,strokeWidth:r,borderType:s,strokeDasharray:n}}parseDmlCustomGeometry(e){const t=i.default.element(e,"pathLst"),r=t?i.default.elements(t,"path"):[];let a="",n=1,s=1;for(const e of r){const t=i.default.floatAttr(e,"w",n),r=i.default.floatAttr(e,"h",s);n=Math.max(n,t||1),s=Math.max(s,r||1),a+=this.parseDmlPathData(e,t||1,r||1)}return{d:a.trim(),viewBox:`0 0 ${n} ${s}`}}parseDmlPathData(e,t,r){const a=[],n=e=>{const a=i.default.element(e,"pt");return a?`${this.dmlCoord(i.default.attr(a,"x"),t,r)} ${this.dmlCoord(i.default.attr(a,"y"),t,r)}`:"0 0"};for(const s of i.default.elements(e))switch(s.localName){case"moveTo":a.push(`M ${n(s)}`);break;case"lnTo":a.push(`L ${n(s)}`);break;case"cubicBezTo":const e=i.default.elements(s,"pt").map(e=>`${this.dmlCoord(i.default.attr(e,"x"),t,r)} ${this.dmlCoord(i.default.attr(e,"y"),t,r)}`);3==e.length&&a.push(`C ${e.join(" ")}`);break;case"quadBezTo":const o=i.default.elements(s,"pt").map(e=>`${this.dmlCoord(i.default.attr(e,"x"),t,r)} ${this.dmlCoord(i.default.attr(e,"y"),t,r)}`);2==o.length&&a.push(`Q ${o.join(" ")}`);break;case"close":a.push("Z")}return a.join(" ")+" "}dmlCoord(e,t,r){if("w"==e||"r"==e)return t;if("h"==e||"b"==e)return r;if("l"==e||"t"==e)return 0;const a=parseFloat(e);return Number.isFinite(a)?a:0}dmlVerticalAlign(e){switch(e?i.default.attr(e,"anchor"):null){case"ctr":return"center";case"b":return"flex-end";default:return"flex-start"}}applyDmlTextInsets(e,t){if(!e)return;const r={lIns:"padding-left",tIns:"padding-top",rIns:"padding-right",bIns:"padding-bottom"};for(const[a,n]of Object.entries(r)){const r=i.default.attr(e,a);null!=r&&(t[n]=this.pt(this.emuToPt(parseFloat(r))))}}parseDmlTextBoxProperties(e){const t={};return this.applyDmlTextInsets(e,t),{dmlTextBox:!0,textInsets:t,textVerticalAlign:this.dmlVerticalAlign(e)}}emuToPt(e){return(Number.isFinite(e)?e:0)/12700}pt(e){return Math.round(100*e)/100+"pt"}parseChartReference(e){return{type:n.DomType.Chart,id:i.default.attr(e,"id"),cssStyle:{width:"100%",height:"100%"}}}parseSmartArtReference(e){const t="relIds"==e.localName?e:this.findDescendant(e,"relIds");return{type:n.DomType.SmartArt,dataId:t?i.default.attr(t,"dm"):i.default.attr(e,"dm"),layoutId:t?i.default.attr(t,"lo"):i.default.attr(e,"lo"),styleId:t?i.default.attr(t,"qs"):i.default.attr(e,"qs"),colorId:t?i.default.attr(t,"cs"):i.default.attr(e,"cs"),cssStyle:{width:"100%",height:"100%"}}}parseInkReference(e){return{type:n.DomType.Ink,id:i.default.attr(e,"id"),cssStyle:{width:"100%",height:"100%"}}}parseGraphicPlaceholder(e){return{type:n.DomType.Shape,children:[{type:n.DomType.Text,text:`[${e}]`}],cssStyle:{display:"inline-flex","align-items":"center","justify-content":"center",border:"1px solid #999","background-color":"#f8f8f8",color:"#555","min-width":"2in","min-height":"1in"}}}parseWordprocessingShape(e){const t={type:n.DomType.Shape,children:[],cssStyle:{display:"inline-block",position:"relative","box-sizing":"border-box",overflow:"hidden"}},r=this.findDescendant(e,"cNvPr");let a=null,s=!1;r&&(t.title=i.default.attr(r,"title")??i.default.attr(r,"name"),t.alt=i.default.attr(r,"descr")??t.title);for(const r of i.default.elements(e))switch(r.localName){case"spPr":this.parseDmlShapeProperties(r,t.cssStyle);break;case"txbx":case"textBox":s=!0;for(const e of i.default.elements(r,"txbxContent"))t.children.push(...this.parseBodyElements(e));break;case"bodyPr":a=r}return s&&(t.props={...t.props??{},...this.parseDmlTextBoxProperties(a)}),t}parseDmlShapeProperties(e,t){const r=i.default.element(e,"xfrm");if(r)for(const e of i.default.elements(r))switch(e.localName){case"ext":t.width=i.default.lengthAttr(e,"cx",u.LengthUsage.Emu),t.height=i.default.lengthAttr(e,"cy",u.LengthUsage.Emu);break;case"off":t.left=i.default.lengthAttr(e,"x",u.LengthUsage.Emu),t.top=i.default.lengthAttr(e,"y",u.LengthUsage.Emu)}const a=i.default.element(e,"solidFill"),n=i.default.element(e,"noFill"),s=i.default.element(e,"ln");if(a?t["background-color"]=this.parseDmlColor(a)??t["background-color"]:n&&(t["background-color"]="transparent"),s){const e=this.parseDmlColor(i.default.element(s,"solidFill"))??"black",r=i.default.lengthAttr(s,"w",u.LengthUsage.Emu)??"1px",a=i.default.elementAttr(s,"prstDash","val"),n=a&&"solid"!=a?"dashed":"solid";t.border=`${r} ${n} ${e}`}}parseDmlColor(e){if(!e)return null;const t=i.default.element(e,"srgbClr"),r=i.default.element(e,"schemeClr"),a=i.default.element(e,"prstClr"),n=i.default.element(e,"sysClr");if(t)return this.applyDmlColorTransforms(t,`#${i.default.attr(t,"val")}`);if(r){const e=this.resolveDmlSchemeColor(i.default.attr(r,"val")),t=this.dmlSchemeColorFallback(e);return this.applyDmlColorTransforms(r,`var(--docx-${e}-color${t?`, ${t}`:""})`)}return n?this.applyDmlColorTransforms(n,`#${i.default.attr(n,"lastClr")??i.default.attr(n,"val")}`):a?this.applyDmlColorTransforms(a,i.default.attr(a,"val")):null}resolveDmlSchemeColor(e){switch(e){case"bg1":return"lt1";case"tx1":return"dk1";case"bg2":return"lt2";case"tx2":return"dk2";default:return e}}dmlSchemeColorFallback(e){switch(e){case"dk1":return"#000000";case"lt1":return"#FFFFFF";case"dk2":return"#44546A";case"lt2":return"#E7E6E6";case"accent1":return"#4472C4";case"accent2":return"#ED7D31";case"accent3":return"#A5A5A5";case"accent4":return"#FFC000";case"accent5":return"#5B9BD5";case"accent6":return"#70AD47";case"hlink":return"#0563C1";case"folHlink":return"#954F72";default:return null}}applyDmlColorTransforms(e,t){const r=i.default.elementAttr(e,"lumMod","val"),a=i.default.elementAttr(e,"lumOff","val");if(null!=r){const e=Math.max(0,Math.min(100,parseFloat(r)/1e3));Number.isFinite(e)&&e<100&&(t=`color-mix(in srgb, ${t} ${e}%, black)`)}if(null!=a){const e=Math.max(0,Math.min(100,parseFloat(a)/1e3));Number.isFinite(e)&&e>0&&(t=`color-mix(in srgb, ${t} ${100-e}%, white)`)}return t}findDescendant(e,t){for(const r of i.default.elements(e)){if(r.localName==t)return r;const e=this.findDescendant(r,t);if(e)return e}return null}parsePicture(e){var t={type:n.DomType.Image,src:"",cssStyle:{}},r=i.default.element(e,"blipFill"),a=r?i.default.element(r,"blip"):null,s=r?i.default.element(r,"srcRect"):null;t.src=a?i.default.attr(a,"embed")??i.default.attr(a,"link"):"";const o=this.findDescendant(e,"cNvPr");o&&(t.title=i.default.attr(o,"title")??i.default.attr(o,"name"),t.alt=i.default.attr(o,"descr")??t.title),s&&(t.srcRect=[i.default.intAttr(s,"l",0)/1e5,i.default.intAttr(s,"t",0)/1e5,i.default.intAttr(s,"r",0)/1e5,i.default.intAttr(s,"b",0)/1e5]);var l=i.default.element(e,"spPr"),c=l?i.default.element(l,"xfrm"):null,d=[];if(t.cssStyle.display="block",t.cssStyle.position="relative",t.cssStyle["object-fit"]="contain",c)for(var h of(t.rotation=i.default.intAttr(c,"rot",0)/6e4,i.default.boolAttr(c,"flipH",!1)&&d.push("scaleX(-1)"),i.default.boolAttr(c,"flipV",!1)&&d.push("scaleY(-1)"),i.default.elements(c)))switch(h.localName){case"ext":t.cssStyle.width=i.default.lengthAttr(h,"cx",u.LengthUsage.Emu),t.cssStyle.height=i.default.lengthAttr(h,"cy",u.LengthUsage.Emu);break;case"off":t.cssStyle.left=i.default.lengthAttr(h,"x",u.LengthUsage.Emu),t.cssStyle.top=i.default.lengthAttr(h,"y",u.LengthUsage.Emu)}return d.length>0&&(t.cssStyle.transform=d.join(" ")),t.cssStyle.width||(t.cssStyle.width="100%"),t.cssStyle.height||(t.cssStyle.height="100%"),t}parseTable(e){var t={type:n.DomType.Table,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"tr":t.children.push(this.parseTableRow(r));break;case"tblGrid":t.columns=this.parseTableColumns(r);break;case"tblPr":this.parseTableProperties(r,t)}return t}parseTableColumns(e){var t=[];for(const r of i.default.elements(e))"gridCol"===r.localName&&t.push({width:i.default.lengthAttr(r,"w")});return t}parseTableProperties(e,t){t.cssStyle={},t.cellStyle={};let r=null;switch(this.parseDefaultProperties(e,t.cssStyle,t.cellStyle,e=>{switch(e.localName){case"tblStyle":t.styleName=i.default.attr(e,"val");break;case"tblLook":t.className=y.classNameOftblLook(e);break;case"tblInd":r=this.parseTableIndentation(e);break;case"tblpPr":this.parseTablePosition(e,t);break;case"tblStyleColBandSize":t.colBandSize=i.default.intAttr(e,"val");break;case"tblStyleRowBandSize":t.rowBandSize=i.default.intAttr(e,"val");break;case"hidden":t.cssStyle.display="none";break;default:return!1}return!0}),t.cssStyle["text-align"]){case"center":delete t.cssStyle["text-align"],t.cssStyle["margin-left"]="auto",t.cssStyle["margin-right"]="auto";break;case"right":delete t.cssStyle["text-align"],t.cssStyle["margin-left"]="auto";break;default:delete t.cssStyle["text-align"],r&&(t.cssStyle["margin-inline-start"]=y.addSize(t.cssStyle["margin-inline-start"],r))}}parseTableIndentation(e){const t=i.default.attr(e,"type");return"pct"==t||"auto"==t?null:i.default.lengthAttr(e,"w",u.LengthUsage.SignedDxa)}parseTablePosition(e,t){var r=i.default.lengthAttr(e,"topFromText"),a=i.default.lengthAttr(e,"bottomFromText"),n=i.default.lengthAttr(e,"rightFromText"),s=i.default.lengthAttr(e,"leftFromText");t.cssStyle.float="left",t.cssStyle["margin-bottom"]=y.addSize(t.cssStyle["margin-bottom"],a),t.cssStyle["margin-left"]=y.addSize(t.cssStyle["margin-left"],s),t.cssStyle["margin-right"]=y.addSize(t.cssStyle["margin-right"],n),t.cssStyle["margin-top"]=y.addSize(t.cssStyle["margin-top"],r)}parseTableRow(e){var t={type:n.DomType.Row,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"tc":t.children.push(this.parseTableCell(r));break;case"trPr":case"tblPrEx":this.parseTableRowProperties(r,t)}return t}parseTableRowProperties(e,t){const r={};t.cssStyle=this.parseDefaultProperties(e,r,null,e=>{switch(e.localName){case"cnfStyle":t.className=y.classNameOfCnfStyle(e);break;case"tblHeader":t.isHeader=i.default.boolAttr(e,"val");break;case"gridBefore":t.gridBefore=i.default.intAttr(e,"val");break;case"gridAfter":t.gridAfter=i.default.intAttr(e,"val");break;case"cantSplit":i.default.boolAttr(e,"val",!0)&&(r["break-inside"]="avoid");break;default:return!1}return!0})}parseTableCell(e){var t={type:n.DomType.Cell,children:[]};for(const r of i.default.elements(e))switch(r.localName){case"tbl":t.children.push(this.parseTable(r));break;case"p":t.children.push(this.parseParagraph(r));break;case"tcPr":this.parseTableCellProperties(r,t)}return t}parseTableCellProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,e=>{switch(e.localName){case"gridSpan":t.span=i.default.intAttr(e,"val",null);break;case"vMerge":t.verticalMerge=i.default.attr(e,"val")??"continue";break;case"cnfStyle":t.className=y.classNameOfCnfStyle(e);break;default:return!1}return!0}),this.parseTableCellVerticalText(e,t)}parseTableCellVerticalText(e,t){const r={btLr:{writingMode:"vertical-rl",transform:"rotate(180deg)"},lrTb:{writingMode:"vertical-lr",transform:"none"},tbRl:{writingMode:"vertical-rl",transform:"none"}};for(const a of i.default.elements(e))if("textDirection"===a.localName){const e=r[i.default.attr(a,"val")]||{writingMode:"horizontal-tb"};t.cssStyle["writing-mode"]=e.writingMode,t.cssStyle.transform=e.transform}}parseDefaultProperties(e,t=null,a=null,n=null){t=t||{};for(const s of i.default.elements(e))if(!n?.(s))switch(s.localName){case"jc":t["text-align"]=y.valueOfJc(s);break;case"textAlignment":t["vertical-align"]=y.valueOfTextAlignment(s);break;case"color":t.color=b.colorAttr(s,"val",null,r.autos.color);break;case"sz":t["font-size"]=t["min-height"]=i.default.lengthAttr(s,"val",u.LengthUsage.FontSize);break;case"szCs":t["font-size"]??(t["font-size"]=i.default.lengthAttr(s,"val",u.LengthUsage.FontSize)),t["min-height"]??(t["min-height"]=t["font-size"]);break;case"shd":t["background-color"]=b.colorAttr(s,"fill",null,r.autos.shd);break;case"highlight":t["background-color"]=b.colorAttr(s,"val",null,r.autos.highlight);break;case"vertAlign":t["vertical-align"]=y.valueOfVertAlign(s);break;case"position":t["vertical-align"]=i.default.lengthAttr(s,"val",u.LengthUsage.SignedHalfPoint);break;case"scale":t["font-stretch"]=`${i.default.intAttr(s,"val",100)}%`;break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":t.width=y.valueOfSize(s,"w");break;case"trHeight":this.parseTrHeight(s,t);break;case"strike":t["text-decoration"]=i.default.boolAttr(s,"val",!0)?"line-through":"none";break;case"dstrike":i.default.boolAttr(s,"val",!0)?(t["text-decoration-line"]="line-through",t["text-decoration-style"]="double"):t["text-decoration"]="none";break;case"b":t["font-weight"]=i.default.boolAttr(s,"val",!0)?"bold":"normal";break;case"i":t["font-style"]=i.default.boolAttr(s,"val",!0)?"italic":"normal";break;case"bCs":t["--docx-bidi-font-weight"]=i.default.boolAttr(s,"val",!0)?"bold":"normal","rtl"==t.direction&&(t["font-weight"]=t["--docx-bidi-font-weight"]);break;case"iCs":t["--docx-bidi-font-style"]=i.default.boolAttr(s,"val",!0)?"italic":"normal","rtl"==t.direction&&(t["font-style"]=t["--docx-bidi-font-style"]);break;case"caps":t["text-transform"]=i.default.boolAttr(s,"val",!0)?"uppercase":"none";break;case"smallCaps":t["font-variant"]=i.default.boolAttr(s,"val",!0)?"small-caps":"none";break;case"rtl":i.default.boolAttr(s,"val",!0)&&(t.direction="rtl",t["unicode-bidi"]="embed",t["--docx-bidi-font-weight"]&&(t["font-weight"]=t["--docx-bidi-font-weight"]),t["--docx-bidi-font-style"]&&(t["font-style"]=t["--docx-bidi-font-style"]));break;case"outline":i.default.boolAttr(s,"val",!0)&&(t["-webkit-text-stroke"]="0.5px currentColor");break;case"shadow":i.default.boolAttr(s,"val",!0)&&(t["text-shadow"]="1px 1px 0 currentColor");break;case"emboss":i.default.boolAttr(s,"val",!0)&&(t["text-shadow"]="-1px -1px 0 rgba(255,255,255,.75), 1px 1px 0 rgba(0,0,0,.35)");break;case"imprint":i.default.boolAttr(s,"val",!0)&&(t["text-shadow"]="1px 1px 0 rgba(255,255,255,.75), -1px -1px 0 rgba(0,0,0,.35)");break;case"em":t["text-emphasis-style"]=y.valueOfEmphasisMark(s);break;case"u":this.parseUnderline(s,t);break;case"ind":case"tblInd":this.parseIndentation(s,t);break;case"rFonts":this.parseFont(s,t);break;case"tblBorders":this.parseBorderProperties(s,a||t);break;case"tblCellSpacing":t["border-spacing"]=y.valueOfMargin(s),t["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(s,t);break;case"bdr":t.border=y.valueOfBorder(s);break;case"tcBorders":this.parseBorderProperties(s,t);break;case"vanish":i.default.boolAttr(s,"val",!0)&&(t.display="none");break;case"kern":t["font-kerning"]=i.default.intAttr(s,"val",0)>0?"normal":"none";break;case"noWrap":t["white-space"]=i.default.boolAttr(s,"val",!0)?"nowrap":"normal";break;case"snapToGrid":t["--docx-snap-to-grid"]=i.default.boolAttr(s,"val",!0)?"1":"0";break;case"fitText":this.parseFitText(s,t);break;case"eastAsianLayout":this.parseEastAsianLayout(s,t);break;case"tblCellMar":case"tcMar":this.parseMarginProperties(s,a||t);break;case"tblLayout":t["table-layout"]=y.valueOfTblLayout(s);break;case"vAlign":t["vertical-align"]=y.valueOfTextAlignment(s);break;case"spacing":"pPr"==e.localName?this.parseSpacing(s,t):"rPr"==e.localName&&(t["letter-spacing"]=i.default.lengthAttr(s,"val",u.LengthUsage.SignedDxa));break;case"wordWrap":i.default.boolAttr(s,"val")&&(t["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":t.hyphens=i.default.boolAttr(s,"val",!0)?"none":"auto";break;case"lang":t.$lang=i.default.attr(s,"val");break;case"rtl":case"bidi":i.default.boolAttr(s,"val",!0)&&(t.direction="rtl");break;case"pageBreakBefore":i.default.boolAttr(s,"val",!0)&&(t["break-before"]="page");break;case"keepLines":i.default.boolAttr(s,"val",!0)&&(t["break-inside"]="avoid");break;case"keepNext":i.default.boolAttr(s,"val",!0)&&(t["break-after"]="avoid");break;case"widowControl":i.default.boolAttr(s,"val",!0)&&(t.orphans="2",t.widows="2");break;case"webHidden":this.options.hideWebHiddenContent&&i.default.boolAttr(s,"val",!0)&&(t.display="none");break;case"specVanish":i.default.boolAttr(s,"val",!0)&&(t.display="none");break;case"tabs":case"outlineLvl":case"contextualSpacing":case"tblStyleColBandSize":case"tblStyleRowBandSize":case"suppressLineNumbers":case"noProof":break;default:this.options.debug&&console.warn(`DOCX: Unknown document element: ${e.localName}.${s.localName}`)}return t}parseFitText(e,t){const r=i.default.lengthAttr(e,"val");r&&(t.display="inline-block",t.width=r,t["text-align"]="justify",t["text-align-last"]="justify")}parseEastAsianLayout(e,t){i.default.boolAttr(e,"combine",!1)&&(t["text-combine-upright"]="all"),i.default.boolAttr(e,"vert",!1)&&(t["writing-mode"]="vertical-rl"),i.default.boolAttr(e,"vertCompress",!1)&&(t["font-stretch"]="condensed")}parseUnderline(e,t){var r=i.default.attr(e,"val");if(null!=r){switch(r){case"dash":case"dashDotDotHeavy":case"dashDotHeavy":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dotDotDash":t["text-decoration"]="underline dashed";break;case"dotted":case"dottedHeavy":t["text-decoration"]="underline dotted";break;case"double":t["text-decoration"]="underline double";break;case"single":case"thick":case"words":t["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":t["text-decoration"]="underline wavy";break;case"none":t["text-decoration"]="none"}var a=b.colorAttr(e,"color");a&&(t["text-decoration-color"]=a)}}parseFont(e,t){var r=i.default.attr(e,"ascii"),a=i.default.attr(e,"hAnsi"),n=i.default.attr(e,"eastAsia"),s=i.default.attr(e,"cs"),o=[r,a,y.themeValue(e,"asciiTheme"),y.themeValue(e,"hAnsiTheme"),n,y.themeValue(e,"eastAsiaTheme"),s,y.themeValue(e,"cstheme")??y.themeValue(e,"csTheme")].filter(e=>e).map(e=>(0,p.encloseFontFamily)(e));if(o.length>0){const e=(t["font-family"]??"").split(",").map(e=>e.trim()).filter(e=>e);t["font-family"]=[...new Set([...e,...o])].join(", ")}}parseIndentation(e,t){var r=i.default.lengthAttr(e,"firstLine"),a=i.default.lengthAttr(e,"hanging"),n=i.default.lengthAttr(e,"left"),s=i.default.lengthAttr(e,"start"),o=i.default.lengthAttr(e,"right"),l=i.default.lengthAttr(e,"end");r&&(t["text-indent"]=r,t["--docx-text-indent"]=r),a&&(t["text-indent"]=`-${a}`,t["--docx-text-indent"]=`-${a}`,t["--docx-hanging-indent"]=a),(n||s)&&(t["margin-inline-start"]=n||s,t["--docx-margin-inline-start"]=n||s),(o||l)&&(t["margin-inline-end"]=o||l,t["--docx-margin-inline-end"]=o||l)}parseSpacing(e,t){var r=i.default.lengthAttr(e,"before"),a=i.default.lengthAttr(e,"after"),n=i.default.intAttr(e,"beforeLines",null),s=i.default.intAttr(e,"afterLines",null),o=i.default.boolAttr(e,"beforeAutospacing",!1),l=i.default.boolAttr(e,"afterAutospacing",!1),c=i.default.intAttr(e,"line",null),u=i.default.attr(e,"lineRule");if(o?t["margin-top"]="auto":null!=n?t["margin-top"]=`${(n/100).toFixed(2)}em`:r&&(t["margin-top"]=r),l?t["margin-bottom"]="auto":null!=s?t["margin-bottom"]=`${(s/100).toFixed(2)}em`:a&&(t["margin-bottom"]=a),null!==c)switch(u??"auto"){case"auto":default:t["line-height"]=`${(c/240).toFixed(2)}`;break;case"atLeast":t["line-height"]=`max(1em, ${(c/20).toFixed(2)}pt)`,t["min-height"]=`${(c/20).toFixed(2)}pt`;break;case"exact":case"exactly":t["line-height"]=t["min-height"]=`${(c/20).toFixed(2)}pt`}}parseMarginProperties(e,t){for(const r of i.default.elements(e))switch(r.localName){case"left":case"start":t["padding-left"]=y.valueOfMargin(r);break;case"right":case"end":t["padding-right"]=y.valueOfMargin(r);break;case"top":t["padding-top"]=y.valueOfMargin(r);break;case"bottom":t["padding-bottom"]=y.valueOfMargin(r)}}parseTrHeight(e,t){i.default.attr(e,"hRule"),t.height=i.default.lengthAttr(e,"val")}parseBorderProperties(e,t){for(const r of i.default.elements(e)){const e=y.valueOfBorder(r);switch(r.localName){case"start":case"left":t["border-left"]=e;break;case"end":case"right":t["border-right"]=e;break;case"top":t["border-top"]=e;break;case"bottom":t["border-bottom"]=e;break;case"insideH":t["border-top"]??(t["border-top"]=e),t["border-bottom"]??(t["border-bottom"]=e);break;case"insideV":t["border-left"]??(t["border-left"]=e),t["border-right"]??(t["border-right"]=e)}}}};const g=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"];class b{static colorAttr(e,t,r=null,a="black"){var n=i.default.attr(e,t);if(n)return"auto"==n?a:g.includes(n)?n:`#${n}`;var s=i.default.attr(e,"themeColor");return s?`var(--docx-${s}-color)`:r}}class y{static themeValue(e,t){var r=i.default.attr(e,t);return r?`var(--docx-${r}-font)`:null}static valueOfSize(e,t){var r=u.LengthUsage.Dxa;switch(i.default.attr(e,"type")){case"dxa":break;case"pct":r=u.LengthUsage.Percent;break;case"auto":return"auto"}return i.default.lengthAttr(e,t,r)}static valueOfMargin(e){return i.default.lengthAttr(e,"w")}static valueOfBorder(e){var t=y.parseBorderType(i.default.attr(e,"val"));if("none"==t)return"none";var a=b.colorAttr(e,"color",r.autos.borderColor,r.autos.borderColor);return`${i.default.lengthAttr(e,"sz",u.LengthUsage.Border)??"1pt"} ${t} ${"auto"==a?r.autos.borderColor:a}`}static parseBorderType(e){switch(e){case"single":case"dashDotStroked":case"thick":case"thickThinLargeGap":case"thickThinMediumGap":case"thickThinSmallGap":case"thinThickLargeGap":case"thinThickMediumGap":case"thinThickSmallGap":case"thinThickThinLargeGap":case"thinThickThinMediumGap":case"thinThickThinSmallGap":case"threeDEmboss":case"threeDEngrave":case"wave":return"solid";case"dashed":case"dashSmallGap":return"dashed";case"dotDash":case"dotDotDash":case"dotted":return"dotted";case"double":case"doubleWave":case"triple":return"double";case"inset":return"inset";case"nil":case"none":return"none";case"outset":return"outset"}return"solid"}static valueOfTblLayout(e){return"fixed"==i.default.attr(e,"val")?"fixed":"auto"}static classNameOfCnfStyle(e){const t=i.default.attr(e,"val");return["first-row","last-row","first-col","last-col","odd-col","even-col","odd-row","even-row","ne-cell","nw-cell","se-cell","sw-cell"].filter((e,r)=>"1"==t[r]).join(" ")}static valueOfJc(e){var t=i.default.attr(e,"val");switch(t){case"start":case"left":return"left";case"center":return"center";case"end":case"right":return"right";case"both":return"justify"}return t}static valueOfVertAlign(e,t=!1){var r=i.default.attr(e,"val");switch(r){case"subscript":return"sub";case"superscript":return t?"sup":"super"}return t?null:r}static valueOfEmphasisMark(e){switch(i.default.attr(e,"val")){case"none":return"none";case"comma":return'"﹐"';case"circle":return"circle";default:return"dot"}}static valueOfTextAlignment(e){var t=i.default.attr(e,"val");switch(t){case"auto":case"baseline":return"baseline";case"top":return"top";case"center":return"middle";case"bottom":return"bottom"}return t}static addSize(e,t){return e&&"0.00pt"!=e&&"0px"!=e?t&&"0.00pt"!=t&&"0px"!=t?`calc(${e} + ${t})`:e:t}static classNameOftblLook(e){const t=i.default.hexAttr(e,"val",0);let r="";return(i.default.boolAttr(e,"firstRow")||32&t)&&(r+=" first-row"),(i.default.boolAttr(e,"lastRow")||64&t)&&(r+=" last-row"),(i.default.boolAttr(e,"firstColumn")||128&t)&&(r+=" first-col"),(i.default.boolAttr(e,"lastColumn")||256&t)&&(r+=" last-col"),(i.default.boolAttr(e,"noHBand")||512&t)&&(r+=" no-hband"),(i.default.boolAttr(e,"noVBand")||1024&t)&&(r+=" no-vband"),r.trim()}}},"./document-props/core-props-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CorePropsPart=void 0;const a=e("../common/part"),n=e("./core-props");class s extends a.Part{parseXml(e){this.props=(0,n.parseCoreProps)(e,this._package.xmlParser)}}r.CorePropsPart=s},"./document-props/core-props":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseCoreProps=function(e,t){const r={};for(let a of t.elements(e))switch(a.localName){case"title":r.title=a.textContent;break;case"description":r.description=a.textContent;break;case"subject":r.subject=a.textContent;break;case"creator":r.creator=a.textContent;break;case"keywords":r.keywords=a.textContent;break;case"language":r.language=a.textContent;break;case"lastModifiedBy":r.lastModifiedBy=a.textContent;break;case"revision":a.textContent&&(r.revision=parseInt(a.textContent))}return r}},"./document-props/custom-props-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CustomPropsPart=void 0;const a=e("../common/part"),n=e("./custom-props");class s extends a.Part{parseXml(e){this.props=(0,n.parseCustomProps)(e,this._package.xmlParser)}}r.CustomPropsPart=s},"./document-props/custom-props":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseCustomProps=function(e,t){return t.elements(e,"property").map(e=>{const r=e.firstChild;return{formatId:t.attr(e,"fmtid"),name:t.attr(e,"name"),type:r.nodeName,value:r.textContent}})}},"./document-props/extended-props-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ExtendedPropsPart=void 0;const a=e("../common/part"),n=e("./extended-props");class s extends a.Part{parseXml(e){this.props=(0,n.parseExtendedProps)(e,this._package.xmlParser)}}r.ExtendedPropsPart=s},"./document-props/extended-props":function(e,t,r){"use strict";function a(e){if(void 0!==e)return parseInt(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.parseExtendedProps=function(e,t){const r={};for(let n of t.elements(e))switch(n.localName){case"Template":r.template=n.textContent;break;case"Pages":r.pages=a(n.textContent);break;case"Words":r.words=a(n.textContent);break;case"Characters":r.characters=a(n.textContent);break;case"Application":r.application=n.textContent;break;case"Lines":r.lines=a(n.textContent);break;case"Paragraphs":r.paragraphs=a(n.textContent);break;case"Company":r.company=n.textContent;break;case"AppVersion":r.appVersion=n.textContent}return r}},"./docx-preview-worker":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const a=e("./word-document"),n=e("./document-parser"),s=e("./input-validation"),o=self;function i(e,t,r={}){o.postMessage({id:e,type:t,...r})}o.onmessage=async e=>{const t=e.data;if(!t||"parse"!==t.type)return;const r=t.id;try{const e={...t.options,useWorker:!1,h:void 0,progress:void 0};(0,s.assertNonEmptyDocxInput)(t.data),i(r,"progress",{message:"Loading package relationships"});const o=await a.WordDocument.load(t.data,new n.DocumentParser(e),e);i(r,"progress",{message:"Serializing parsed document model"}),i(r,"parsed",{snapshot:await o.createSnapshot()})}catch(e){i(r,"error",{error:{message:e?.message??`${e}`,stack:e?.stack}})}}},"./docx-preview":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.defaultOptions=void 0,r.parseAsync=c,r.renderDocument=d,r.renderAsync=async function(e,t,a,n){const s={...r.defaultOptions,...n};(0,i.assertViewerLicense)("docx",s.licenseToken);const o=await c(e,s),l=await d(o,s);a??(a=t),a.innerHTML="",t.innerHTML="";let u=0;for(let e of l)("STYLE"===e.nodeName?a:t).appendChild(e),u++,s.renderYieldEveryMs>0&&u%8==0&&await x();b(t,s.className);let h=null;return s.awaitLayout&&(s.progress?.({phase:"layout",message:"Measuring rendered pages"}),h=await f(t,s),b(t,s.className)),s.progress?.({phase:"done",current:h?.pageCount,total:h?.pageCount,message:"DOCX render complete"}),o},r.parseAsyncInWorker=m,r.awaitRenderedLayout=f,r.collectLayoutSnapshot=g,r.syncNumberingMarkerStyles=b,r.yieldToBrowser=x;const a=e("./word-document"),n=e("./document-parser"),s=e("./html-renderer"),o=e("./html"),i=e("./license-gate"),l=e("./input-validation");function c(e,t){const a={...r.defaultOptions,...t};return(0,i.assertViewerLicense)("docx",a.licenseToken),(0,l.assertNonEmptyDocxInput)(e),function(e){return!(!e.useWorker||!e.workerUrl||"undefined"==typeof Worker)}(a)?m(e,a).catch(t=>{if(!a.workerFallback)throw t;a.debug&&console.warn("docx-preview: worker parsing failed; falling back to main thread",t);const r={...a,useWorker:!1};return u(e,r)}):u(e,a)}function u(e,t){return(0,l.assertNonEmptyDocxInput)(e),t.progress?.({phase:"parse",message:"Parsing DOCX on main thread"}),a.WordDocument.load(e,new n.DocumentParser(t),t)}async function d(e,t){const a={...r.defaultOptions,...t};(0,i.assertViewerLicense)("docx",a.licenseToken);const n=new s.HtmlRenderer;return await n.render(e,a)}function h(e){const{h:t,progress:r,licenseToken:a,...n}=e;return{...n,useWorker:!1}}r.defaultOptions={ignoreHeight:!1,ignoreWidth:!1,fixedPageHeight:!0,ignoreFonts:!1,breakPages:!0,strictWordCompatibility:!0,paginationTolerance:2,maxDynamicPaginationPasses:1e3,awaitLayout:!0,useWorker:!0,workerUrl:void 0,workerJsZipUrl:void 0,workerFallback:!0,workerTimeout:12e4,renderPageBatchSize:2,renderYieldEveryMs:16,progress:void 0,preserveComplexFieldResults:!0,updatePageReferences:!1,hideWebHiddenContent:!1,debug:!1,experimental:!1,className:"docx",inWrapper:!0,hideWrapperOnPrint:!1,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!1,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1,renderComments:!1,renderAltChunks:!0,h:o.h};let p=0;function m(e,t){const n={...r.defaultOptions,...t};return(0,i.assertViewerLicense)("docx",n.licenseToken),(0,l.assertNonEmptyDocxInput)(e),n.workerUrl&&"undefined"!=typeof Worker?(n.progress?.({phase:"worker",message:"Starting DOCX parse worker"}),new Promise((t,r)=>{const s=++p,o=new Worker(n.workerUrl);let i=!1,l=null;const c=()=>{i=!0,l&&clearTimeout(l),o.terminate()};n.workerTimeout>0&&(l=setTimeout(()=>{i||(c(),r(new Error(`docx-preview worker timed out after ${n.workerTimeout}ms`)))},n.workerTimeout)),o.onerror=e=>{i||(c(),r(new Error(e.message||"docx-preview worker error")))},o.onmessage=e=>{const o=e.data??{};if(o.id===s||"ready"===o.type)if("progress"!==o.type){if("parsed"===o.type)return c(),n.progress?.({phase:"worker",message:"Worker parse complete"}),void t(a.WordDocument.fromSnapshot(o.snapshot,n));if("error"===o.type){c();const e=new Error(o.error?.message??"docx-preview worker parse failed");e.stack=o.error?.stack,r(e)}}else n.progress?.({phase:"worker",current:o.current,total:o.total,message:o.message})},o.postMessage({type:"parse",id:s,data:e,options:h(n),jsZipUrl:n.workerJsZipUrl})})):u(e,{...n,useWorker:!1})}async function f(e,t){const a={...r.defaultOptions,...t};await async function(e){const t=Array.from(e.querySelectorAll("img"));await Promise.allSettled(t.map(e=>e.complete?Promise.resolve():new Promise(t=>{e.addEventListener("load",t,{once:!0}),e.addEventListener("error",t,{once:!0})})))}(e),document.fonts?.ready&&await document.fonts.ready;const n=e.querySelector(`.${a.className}-wrapper`);if(a.breakPages&&a.fixedPageHeight&&!a.ignoreHeight&&n)for(let e=0;e<Math.max(2,Math.min(120,a.maxDynamicPaginationPasses??120))&&(await x(),"true"!==n.dataset.docxPaginated)&&("true"===n.dataset.docxPaginating||"true"===n.dataset.docxPaginationScheduled);e++);return await x(),g(e,a)}function g(e,t){const a={...r.defaultOptions,...t},n=Array.from(e.querySelectorAll(`section.${a.className}`)).map((e,t)=>{const r=Array.from(e.querySelectorAll("[data-docx-field-instr]")),n=Array.from(e.querySelectorAll("img")).filter(e=>!e.complete||0===e.naturalWidth).length,s=e.clientHeight>0&&e.scrollHeight>e.clientHeight+(a.paginationTolerance??2);return{index:t+1,section:e.dataset.docxSection??"",pageNumber:parseInt(e.dataset.docxPageNumber??`${t+1}`,10),sectionPageNumber:parseInt(e.dataset.docxSectionPageNumber??"1",10),width:e.clientWidth,height:e.clientHeight,scrollHeight:e.scrollHeight,overflow:s,textLength:e.textContent?.length??0,anchors:Array.from(e.querySelectorAll("[id]")).map(e=>e.id).filter(Boolean),fields:r.map(e=>({instruction:e.dataset.docxFieldInstr??"",value:e.textContent??""})),floats:e.querySelectorAll('[data-docx-float="true"]').length,unresolvedMedia:n}});return{pageCount:n.length,overflowPages:n.filter(e=>e.overflow).map(e=>e.index),unresolvedMedia:n.reduce((e,t)=>e+t.unresolvedMedia,0),pages:n}}function b(e,t="docx"){if(!e||"function"!=typeof getComputedStyle)return;const r=Array.from(e.querySelectorAll("p")),a=`${t}-num-`;for(const e of r){if(!e.className?.includes(a))continue;const t=getComputedStyle(e,"::before");if(!t.content||"none"==t.content||"normal"==t.content)continue;const r=y(e);if(!r||r==e)continue;const n=getComputedStyle(r);k(e,"--docx-marker-font-family",n.fontFamily),k(e,"--docx-marker-font-size",n.fontSize),k(e,"--docx-marker-font-style",n.fontStyle),k(e,"--docx-marker-font-weight",n.fontWeight)}}function y(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;t.nextNode();){const r=t.currentNode;if(!r.nodeValue?.trim())continue;const a=r.parentElement;if(!a||a==e)return e;const n=getComputedStyle(a);if("none"!=n.display&&"hidden"!=n.visibility)return a}return null}function k(e,t,r){r&&e.style.setProperty(t,r)}function x(){return new Promise(e=>{const t=globalThis;"function"==typeof t.requestIdleCallback?t.requestIdleCallback(()=>e(),{timeout:32}):"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>e()):setTimeout(e,0)})}},"./font-table/font-table":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FontTablePart=void 0;const a=e("../common/part"),n=e("./fonts");class s extends a.Part{parseXml(e){this.fonts=(0,n.parseFonts)(e,this._package.xmlParser)}}r.FontTablePart=s},"./font-table/fonts":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseFonts=function(e,t){return t.elements(e).map(e=>n(e,t))},r.parseFont=n,r.parseEmbedFontRef=s;const a={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function n(e,t){let r={name:t.attr(e,"name"),embedFontRefs:[]};for(let a of t.elements(e))switch(a.localName){case"family":r.family=t.attr(a,"val");break;case"altName":r.altName=t.attr(a,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":r.embedFontRefs.push(s(a,t))}return r}function s(e,t){return{id:t.attr(e,"id"),key:t.attr(e,"fontKey"),type:a[e.localName]}}},"./header-footer/elements":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WmlFooter=r.WmlHeader=void 0;const a=e("../document/dom");class n extends a.OpenXmlElementBase{constructor(){super(...arguments),this.type=a.DomType.Header}}r.WmlHeader=n;class s extends a.OpenXmlElementBase{constructor(){super(...arguments),this.type=a.DomType.Footer}}r.WmlFooter=s},"./header-footer/parts":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FooterPart=r.HeaderPart=r.BaseHeaderFooterPart=void 0;const a=e("../common/part"),n=e("./elements");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(e)}}r.BaseHeaderFooterPart=s,r.HeaderPart=class extends s{createRootElement(){return new n.WmlHeader}},r.FooterPart=class extends s{createRootElement(){return new n.WmlFooter}}},"./html-renderer":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.HtmlRenderer=void 0;const a=e("./document/dom"),n=e("./utils"),s=e("./javascript"),o=e("./document/section"),i=e("./html"),l=e("./parser/xml-parser");function c(e){return e>="0"&&e<="9"}function u(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122||t>=913&&t<=1023||t>=119808&&t<=120831}function d(e){return"()+-−=<>≤≥≈≠×÷*/·∙∑Σ∏∫√∞∂∇,.;:[]{}|‖!′″→←↔⇒⇔∈∉⊂⊃⊆⊇∧∨¬".includes(e)}r.HtmlRenderer=class{constructor(){this.className="docx",this.styleMap={},this.currentPart=null,this.currentSectionProps=null,this.currentPageNumber=1,this.currentSectionNumber=1,this.currentSectionPageNumber=1,this.totalPages=1,this.sectionPageCount=1,this.tableVerticalMerges=[],this.currentVerticalMerge=null,this.tableCellPositions=[],this.currentCellPosition=null,this.currentTableRow=null,this.footnoteMap={},this.endnoteMap={},this.currentEndnoteIds=[],this.usedHederFooterParts=[],this.currentTabs=[],this.currentParagraph=null,this.currentParagraphTabIndex=0,this.currentParagraphTabCount=0,this.commentMap={},this.bookmarkTextMap={},this.bookmarkIdToName={},this.tocEntries=[],this.fieldSeqCounters={},this.fieldSetValues={},this.headingIndex=0,this.tasks=[],this.postRenderTasks=[],this.h=i.h}async render(e,t){this.document=e,this.options=t,this.className=t.className,this.rootSelector=t.inWrapper?`.${this.className}-wrapper`:":root",this.h=t.h??i.h,this.styleMap=null,this.tasks=[],this.postRenderTasks=[],this.currentTabs=[],this.fieldSeqCounters={},this.fieldSetValues={},this.headingIndex=0,this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight);const r=[...this.renderDefaultStyle()];e.themePart&&r.push(...this.renderTheme(e.themePart)),null!=e.stylesPart&&(this.styleMap=this.processStyles(e.stylesPart.styles),r.push(...this.renderStyles(e.stylesPart.styles))),e.numberingPart&&(this.prodessNumberings(e.numberingPart.domNumberings),r.push(...await this.renderNumbering(e.numberingPart.domNumberings))),e.footnotesPart&&(this.footnoteMap=(0,n.keyBy)(e.footnotesPart.notes,e=>e.id)),e.endnotesPart&&(this.endnoteMap=(0,n.keyBy)(e.endnotesPart.notes,e=>e.id)),e.settingsPart&&(this.defaultTabSize=e.settingsPart.settings?.defaultTabStop),!t.ignoreFonts&&e.fontTablePart&&r.push(...await this.renderFontTable(e.fontTablePart));var a=await this.renderSections(e.documentPart.body);if(this.options.inWrapper){const e=this.renderWrapper(a);r.push(e),this.shouldRunDynamicPagination()&&this.scheduleDynamicPagination(e)}else r.push(...a);return this.commentHighlight&&t.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),await Promise.allSettled(this.tasks),this.postRenderTasks.forEach(e=>e()),this.refreshTabStops(),r}renderTheme(e){const t={},r=e.theme?.fontScheme;r&&(r.majorFont&&(t["--docx-majorHAnsi-font"]=r.majorFont.latinTypeface,t["--docx-majorEastAsia-font"]=r.majorFont.eaTypeface??r.majorFont.latinTypeface,t["--docx-majorBidi-font"]=r.majorFont.csTypeface??r.majorFont.latinTypeface,t["--docx-majorCs-font"]=r.majorFont.csTypeface??r.majorFont.latinTypeface),r.minorFont&&(t["--docx-minorHAnsi-font"]=r.minorFont.latinTypeface,t["--docx-minorEastAsia-font"]=r.minorFont.eaTypeface??r.minorFont.latinTypeface,t["--docx-minorBidi-font"]=r.minorFont.csTypeface??r.minorFont.latinTypeface,t["--docx-minorCs-font"]=r.minorFont.csTypeface??r.minorFont.latinTypeface));const a=e.theme?.colorScheme;if(a)for(let[e,r]of Object.entries(a.colors))t[`--docx-${e}-color`]=`#${r}`;const n=this.styleToString(`.${this.className}`,t);return[this.h({tagName:"#comment",children:["docxjs document theme values"]}),this.h({tagName:"style",children:[n]})]}async renderFontTable(e){const t=[];for(let r of e.fonts)for(let e of r.embedFontRefs)try{const a=await this.document.loadFont(e.id,e.key),s={"font-family":(0,n.encloseFontFamily)(r.name),src:`url(${a})`};"bold"!=e.type&&"boldItalic"!=e.type||(s["font-weight"]="bold"),"italic"!=e.type&&"boldItalic"!=e.type||(s["font-style"]="italic"),t.push(this.h({tagName:"#comment",children:[`docxjs ${r.name} font`]})),t.push(this.h({tagName:"style",children:[this.styleToString("@font-face",s)]}))}catch(t){this.options.debug&&console.warn(`Can't load font with id ${e.id} and key ${e.key}`)}return t}processStyleName(e){return e?`${this.className}_${(0,n.escapeClassName)(e)}`:this.className}processStyles(e){const t=(0,n.keyBy)(e.filter(e=>null!=e.id),e=>e.id);for(const a of e.filter(e=>e.basedOn)){var r=t[a.basedOn];if(r){a.paragraphProps=(0,n.mergeDeep)({},r.paragraphProps,a.paragraphProps),a.runProps=(0,n.mergeDeep)({},r.runProps,a.runProps);for(const e of r.styles){const t=a.styles.find(t=>t.target==e.target);t?this.copyStyleProperties(e.values,t.values):a.styles.push({...e,values:{...e.values}})}}else this.options.debug&&console.warn(`Can't find base style ${a.basedOn}`)}for(let t of e)t.cssName=this.processStyleName(t.id);return t}prodessNumberings(e){for(let t of e.filter(e=>e.pStyleName)){const e=this.findStyle(t.pStyleName);e?.paragraphProps?.numbering&&(e.paragraphProps.numbering.level=t.level)}}processElement(e){if(e.children)for(var t of e.children)t.parent=e,t.type==a.DomType.Table?this.processTable(t):this.processElement(t)}processTable(e){const t=e.children??[];let r=e.columns?.length??0;for(const e of t){let t=e.gridBefore??0;for(const r of e.children??[])t+=r.span??1;r=Math.max(r,t+(e.gridAfter??0))}const a=Math.max(e.rowBandSize??1,1),n=Math.max(e.colBandSize??1,1);t.forEach((s,o)=>{0==o&&this.appendClassName(s,"first-row"),o==t.length-1&&this.appendClassName(s,"last-row"),this.appendClassName(s,Math.floor(o/a)%2==0?"odd-row":"even-row");let i=s.gridBefore??0;for(const t of s.children??[]){t.cssStyle=this.copyStyleProperties(e.cellStyle,t.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]);const a=t.span??1,s=i+a-1;0==i&&this.appendClassName(t,"first-col"),r>0&&s>=r-1&&this.appendClassName(t,"last-col"),this.appendClassName(t,Math.floor(i/n)%2==0?"odd-col":"even-col"),this.processElement(t),i+=a}})}collectDocumentMetadata(e){this.bookmarkTextMap={},this.bookmarkIdToName={},this.tocEntries=[];const t={},r=e=>{if(e.type!=a.DomType.Deleted||this.options.renderChanges){switch(e.type){case a.DomType.BookmarkStart:{const r=e;r.id&&r.name&&(this.bookmarkIdToName[r.id]=r.name,t[r.id]=[]);break}case a.DomType.BookmarkEnd:{const r=e,a=this.bookmarkIdToName[r.id];a&&t[r.id]&&(this.bookmarkTextMap[a]=t[r.id].join("").trim(),delete t[r.id]);break}case a.DomType.Text:for(const r of Object.keys(t))t[r].push(e.text??"");break;case a.DomType.DeletedText:if(this.options.renderChanges)for(const r of Object.keys(t))t[r].push(e.text??"")}for(const t of e.children??[])r(t)}};for(const t of e.children??[])r(t);for(const[e,r]of Object.entries(t)){const t=this.bookmarkIdToName[e];t&&(this.bookmarkTextMap[t]=r.join("").trim())}for(const t of e.children??[])this.collectTocEntries(t)}collectTocEntries(e){if(e.type!=a.DomType.Deleted||this.options.renderChanges){if(e.type==a.DomType.Paragraph){const t=e,r=this.findStyle(t.styleName),a=this.extractText(t).trim();let n=t.outlineLevel??r?.paragraphProps?.outlineLevel;if(null==n&&t.styleName){const e=/heading(\d+)|(?:^|[-_ ])h(\d+)$/i.exec(t.styleName);e&&(n=parseInt(e[1]??e[2],10)-1)}if(a&&null!=n&&n>=0&&n<9){const e=this.findFirstBookmark(t),r=e?.name&&!e.name.startsWith("_")?e.name:`${this.className}-heading-${++this.headingIndex}`;t.props={...t.props??{},anchorId:r},this.tocEntries.push({level:n+1,text:a,id:r})}}for(const t of e.children??[])this.collectTocEntries(t)}}findFirstBookmark(e){if(e.type==a.DomType.BookmarkStart)return e;for(const t of e.children??[]){const e=this.findFirstBookmark(t);if(e)return e}return null}extractText(e){switch(e.type){case a.DomType.Text:return e.text??"";case a.DomType.DeletedText:return this.options.renderChanges?e.text??"":"";case a.DomType.Deleted:return this.options.renderChanges?(e.children??[]).map(e=>this.extractText(e)).join(""):"";case a.DomType.Inserted:return(e.children??[]).map(e=>this.extractText(e)).join("");case a.DomType.Tab:case a.DomType.PositionalTab:return"\t";case a.DomType.NoBreakHyphen:return"‑";case a.DomType.SoftHyphen:return"";case a.DomType.Break:return"\n";case a.DomType.Instruction:case a.DomType.ComplexField:return""}return(e.children??[]).map(e=>this.extractText(e)).join("")}appendClassName(e,t){e.className=(0,i.cx)(e.className,t)}copyStyleProperties(e,t,r=null){if(!e)return t;for(var a of(null==t&&(t={}),null==r&&(r=Object.getOwnPropertyNames(e)),r))e.hasOwnProperty(a)&&!t.hasOwnProperty(a)&&(t[a]=e[a]);return t}createPageElement(e,t,r){const a={...r};let n=null,s=null;if(t){if(t.pageMargins&&(a.paddingLeft=this.addSize(t.pageMargins.left,t.pageMargins.gutter),a.paddingRight=t.pageMargins.right,a.paddingTop=t.pageMargins.top,a.paddingBottom=t.pageMargins.bottom),t.pageSize){let e=t.pageSize.width,r=t.pageSize.height;if("landscape"==t.pageSize.orientation){const t=this.parseCssLengthValue(e),a=this.parseCssLengthValue(r);null!=t&&null!=a&&t<a&&([e,r]=[r,e])}n=e,s=r,this.options.ignoreWidth||(a.width=e),(!this.options.ignoreHeight||!this.options.breakPages)&&(a.minHeight=r,!this.options.ignoreHeight&&this.options.breakPages&&this.options.fixedPageHeight&&(a.height=r))}t.pageBorders&&(this.applyPageBorder(a,"top",t.pageBorders.top),this.applyPageBorder(a,"right",t.pageBorders.right),this.applyPageBorder(a,"bottom",t.pageBorders.bottom),this.applyPageBorder(a,"left",t.pageBorders.left))}const o=this.h({tagName:"section",className:e,style:a});return n&&this.setCssStyle(o,"--docx-page-width",n),s&&this.setCssStyle(o,"--docx-page-height",s),o}addSize(e,t){return e?t&&"0.00pt"!=t&&"0px"!=t?`calc(${e} + ${t})`:e:t}parseCssLengthValue(e){if(!e)return null;const t=/^(-?\d+(?:\.\d+)?)/.exec(e);return t?parseFloat(t[1]):null}applyPageBorder(e,t,r){if(!r)return;const a=this.borderTypeToCss(r.type);e[`border-${t}`]="none"==a?"none":`${r.size??"1px"} ${a} ${this.borderColor(r.color)}`}borderTypeToCss(e){switch(e){case"nil":case"none":return"none";case"double":case"triple":return"double";case"dashed":case"dashSmallGap":return"dashed";case"dotted":case"dotDash":case"dotDotDash":return"dotted"}return"solid"}borderColor(e){return e&&"auto"!=e?/^[0-9a-f]{6}$/i.test(e)?`#${e}`:e:"black"}createSectionContent(e){const t={},r=e.columns?.numberOfColumns??e.columns?.columns?.length;return e.docGrid&&(e.docGrid.linePitch&&(t["--docx-doc-grid-line-pitch"]=e.docGrid.linePitch),e.docGrid.charSpace&&(t.letterSpacing=e.docGrid.charSpace)),this.document.settingsPart?.settings?.kinsoku&&(t.lineBreak="strict",t.wordBreak="keep-all"),this.document.settingsPart?.settings?.overflowPunctuation&&(t.hangingPunctuation="allow-end"),this.document.settingsPart?.settings?.topLinePunctuation&&(t["text-spacing-trim"]="space-start"),(this.document.settingsPart?.settings?.autoSpaceDE||this.document.settingsPart?.settings?.autoSpaceDN)&&(t["text-autospace"]=[this.document.settingsPart?.settings?.autoSpaceDE?"ideograph-alpha":null,this.document.settingsPart?.settings?.autoSpaceDN?"ideograph-numeric":null].filter(Boolean).join(" ")),e.columns&&r&&(t.columnCount=`${r}`,t.columnGap=e.columns.space,!e.columns.equalWidth&&e.columns.columns?.length>0&&(t.columnWidth=e.columns.columns[0].width,t.columnGap=e.columns.columns[0].space??t.columnGap),e.columns.separator&&(t.columnRule="1px solid black")),this.h({tagName:"article",style:t})}async renderSections(e){const t=[];this.processElement(e),this.collectDocumentMetadata(e);const r=this.splitBySection(e.children,e.props),a=this.groupByPageBreaks(r);let n=null,s=0,o=0;const i=new Map,l=new Map,c=new Map,u=new Map,d=e=>{if(!c.has(e)){const t=++o;c.set(e,`${this.className}-section-${t}`),u.set(e,t)}};for(const e of a){const t=e[0].sectProps;d(t),i.set(t,(i.get(t)??0)+1)}this.totalPages=a.length;for(let r=0,o=a.length;r<o;r++){this.currentFootnoteIds=[];let p=a[r][0].sectProps;d(p);const m=n!=p;s=m&&null!=p?.pageNumber?.start?p.pageNumber.start:s+1,this.currentPageNumber=s,this.currentSectionNumber=u.get(p)??1,this.currentSectionProps=p,this.currentSectionPageNumber=(l.get(p)??0)+1,this.sectionPageCount=i.get(p)??1,l.set(p,this.currentSectionPageNumber);const f=this.createPageElement(this.className,p,e.cssStyle);f.dataset.docxSection=c.get(p),f.dataset.docxSectionNumber=`${this.currentSectionNumber}`,f.dataset.docxSectionPageNumber=`${this.currentSectionPageNumber}`,f.dataset.docxSectionPageCount=`${this.sectionPageCount}`,f.dataset.docxPageNumber=`${s}`,m&&null!=p?.pageNumber?.start&&(f.dataset.docxPageStart=`${p.pageNumber.start}`),this.options.renderHeaders&&this.renderHeaderFooter(p.headerRefs,p,s,m,f);for(const e of a[r]){this.currentSectionProps=e.sectProps;var h=this.createSectionContent(e.sectProps);e.columnBreak&&(h.style.breakBefore="column"),this.renderElements(e.elements,h),f.appendChild(h),p=e.sectProps}if(this.options.renderFootnotes){const e=this.renderNotes(this.currentFootnoteIds,this.footnoteMap,this.document.footnotesPart);e&&f.appendChild(e)}if(this.options.renderEndnotes&&r==o-1){const e=this.renderNotes(this.currentEndnoteIds,this.endnoteMap,this.document.endnotesPart);e&&f.appendChild(e)}this.currentSectionProps=p,this.options.renderFooters&&this.renderHeaderFooter(p.footerRefs,p,s,m,f),t.push(f),await this.yieldDuringRender(r+1,o),n=p}return t}renderHeaderFooter(e,t,r,n,s){if(!e)return;const o=!!this.document.settingsPart?.settings?.evenAndOddHeaders,i=e.find(e=>"default"==e.type);var l=(t.titlePage&&n?e.find(e=>"first"==e.type):null)??(o&&r%2==0?e.find(e=>"even"==e.type):null)??i??e.find(e=>"first"==e.type)??(o?e.find(e=>"even"==e.type):null),c=l&&this.document.findPartByRelId(l.id,this.document.documentPart);if(c){this.currentPart=c,this.usedHederFooterParts.includes(c.path)||(this.processElement(c.rootElement),this.usedHederFooterParts.push(c.path));const[e]=this.renderElements([c.rootElement],s);t?.pageMargins&&(c.rootElement.type===a.DomType.Header?(e.style.marginTop=`calc(${t.pageMargins.header} - ${t.pageMargins.top})`,e.style.minHeight=`calc(${t.pageMargins.top} - ${t.pageMargins.header})`):c.rootElement.type===a.DomType.Footer&&(e.style.marginBottom=`calc(${t.pageMargins.footer} - ${t.pageMargins.bottom})`,e.style.minHeight=`calc(${t.pageMargins.bottom} - ${t.pageMargins.footer})`)),this.currentPart=null}}isPageBreakElement(e){return e.type==a.DomType.Break&&("lastRenderedPageBreak"==e.break?!this.options.ignoreLastRenderedPageBreak:"page"==e.break)}isPageBreakSection(e,t){return!(!e||!t||e.pageSize?.orientation==t.pageSize?.orientation&&e.pageSize?.width==t.pageSize?.width&&e.pageSize?.height==t.pageSize?.height)}splitBySection(e,t){let r={sectProps:null,elements:[],pageBreak:!1,columnBreak:!1},n=[r];const s=(e=!1,t=!1)=>{if(0==r.elements.length&&null==r.sectProps)return r.pageBreak||(r.pageBreak=e),void(r.columnBreak||(r.columnBreak=t));r.pageBreak||(r.pageBreak=e),r.columnBreak||(r.columnBreak=t),r={sectProps:null,elements:[],pageBreak:!1,columnBreak:!1},n.push(r)};for(let t of e){if(t.type!=a.DomType.Paragraph){if(t.type==a.DomType.Table)for(const e of this.splitTableByPageBreaks(t))e.table.children?.length&&r.elements.push(e.table),e.breakAfter&&s(!0);else r.elements.push(t);continue}const e=t,n=this.findStyle(e.styleName),i=e.pageBreakBefore??n?.paragraphProps?.pageBreakBefore;this.options.breakPages&&i&&r.elements.length>0&&s(!0);const l=this.splitParagraphByPageBreaks(e);for(const e of l)r.elements.push(e.paragraph),e.breakAfter&&s(!0);e.sectionProps&&(r.sectProps=e.sectionProps,s((0,o.isSectionPageBreak)(e.sectionProps.type),(0,o.isSectionColumnBreak)(e.sectionProps.type)))}if(n=n.filter(e=>e.elements.length>0),0==n.length)return[{sectProps:t,elements:[],pageBreak:!1,columnBreak:!1}];let i=null;for(let e=n.length-1;e>=0;e--)null==n[e].sectProps?n[e].sectProps=i??t:i=n[e].sectProps;return n}hasPageBreakElement(e){return!!this.isPageBreakElement(e)||(e.children?.some(e=>this.hasPageBreakElement(e))??!1)}splitTableByPageBreaks(e){if(!this.options.breakPages||!e.children?.length)return[{table:e,breakAfter:!1}];if(!e.children.some(e=>this.hasPageBreakElement(e)))return[{table:e,breakAfter:!1}];const t=e.children,r=[];for(const e of t){if(!e.isHeader)break;r.push(e)}const a=[];let n=[];const s=t=>{if(0==n.length&&a.length>0)return;const s=a.length>0;let o=n;s&&r.length>0&&!n.some(e=>e.isHeader)&&(o=[...r,...n]),a.push({table:{...e,children:o},breakAfter:t}),n=[]};for(const e of t)n.push(e),this.hasPageBreakElement(e)&&s(!0);return s(!1),a.length>0?a:[{table:e,breakAfter:!1}]}splitElementByPageBreaks(e){if(this.isPageBreakElement(e))return[{breakAfter:!0}];if(!e.children?.length)return[{element:e}];const t=[];let r={...e,children:[]};const a=()=>{r.children.length>0&&t.push({element:r}),r={...e,children:[]}};for(const n of e.children)for(const e of this.splitElementByPageBreaks(n))e.element&&r.children.push(e.element),e.breakAfter&&(a(),t.push({breakAfter:!0}));return a(),t.length>0?t:[{element:e}]}splitParagraphByPageBreaks(e){if(!this.options.breakPages||!e.children?.length)return[{paragraph:e,breakAfter:!1}];const t=[];let r={...e,children:[]};const a=a=>{(r.children.length>0||0==t.length)&&t.push({paragraph:r,breakAfter:a}),r={...e,sectionProps:null,children:[]}};for(const t of e.children)for(const e of this.splitElementByPageBreaks(t))e.element&&r.children.push(e.element),e.breakAfter&&a(!0);(r.children.length>0||0==t.length)&&t.push({paragraph:r,breakAfter:!1});const n=t[t.length-1]?.paragraph;for(const e of t)e.paragraph!=n&&(e.paragraph.sectionProps=null);return t}styleValuesForTarget(e,t){return e?.styles?.find(e=>e.target==t)?.values}styleValue(e,t,r){return this.styleValuesForTarget(e,t)?.[r]}effectiveParagraphCssValue(e,t,r){return e.cssStyle?.[r]??this.styleValue(t,"p",r)}isInsideTableCell(e){for(let t=e.parent;t;t=t.parent)if(t.type==a.DomType.Cell)return!0;return!1}paragraphUsesDocumentGrid(e,t){const r=this.currentSectionProps?.docGrid?.linePitch;if(!r)return!1;if(this.isInsideTableCell(e)&&!this.document.settingsPart?.settings?.adjustLineHeightInTable)return!1;const a=this.effectiveParagraphCssValue(e,t,"--docx-snap-to-grid");return null==a||!/^(0|false|off)$/i.test(a)}setCssStyle(e,t,r){const a=e.style;"function"==typeof a.setProperty?a.setProperty(t,r):a[t]=r}applyDocumentGridLinePitch(e,t,r){if(!this.paragraphUsesDocumentGrid(e,t))return;if(this.effectiveParagraphCssValue(e,t,"line-height"))return;const a=this.currentSectionProps.docGrid.linePitch,n=this.effectiveParagraphCssValue(e,t,"min-height");if(!n)return void this.setCssStyle(r,"min-height",a);const s=this.parseCssLengthValue(n),o=this.parseCssLengthValue(a);null!=s&&null!=o?s<o&&this.setCssStyle(r,"min-height",a):this.setCssStyle(r,"min-height",`max(${n}, ${a})`)}groupByPageBreaks(e){let t=[],r=null;const a=[t];for(let n of e)r&&(r.pageBreak||this.isPageBreakSection(r.sectProps,n.sectProps))&&(t=[],a.push(t)),t.push(n),r=n;return a.filter(e=>e.length>0)}async yieldDuringRender(e,t){const r=this.options.renderPageBatchSize??0;this.options.progress&&this.options.progress({phase:"render",current:e,total:t,message:`Rendered ${e}/${t} logical pages`}),r>0&&e%r==0&&await this.yieldToBrowser()}async yieldToBrowser(){(this.options.renderYieldEveryMs??0)<=0||await new Promise(e=>{const t=globalThis;"function"==typeof t.requestIdleCallback?t.requestIdleCallback(()=>e(),{timeout:Math.max(1,this.options.renderYieldEveryMs??16)}):"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame(()=>e()):setTimeout(e,0)})}renderWrapper(e){return this.h({tagName:"div",className:this.className+"-wrapper",children:e})}shouldRunDynamicPagination(){return!(!this.options.breakPages||!this.options.fixedPageHeight||this.options.ignoreHeight||"undefined"==typeof document||"function"!=typeof requestAnimationFrame)}scheduleDynamicPagination(e){if(!e||"true"==e.dataset.docxPaginated||"true"==e.dataset.docxPaginating||"true"==e.dataset.docxPaginationScheduled)return;e.dataset.docxPaginationScheduled="true";const t=()=>{const t=document.fonts?.ready;(t??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>requestAnimationFrame(()=>this.performDynamicPagination(e)))})},r=()=>{e&&"true"!=e.dataset.docxPaginated&&"true"!=e.dataset.docxPaginating&&(e.isConnected?t():setTimeout(r,0))};r()}async performDynamicPagination(e){if(!e||"true"==e.dataset.docxPaginated||"true"==e.dataset.docxPaginating)return;if(!e.isConnected)return void setTimeout(()=>this.performDynamicPagination(e),0);delete e.dataset.docxPaginationScheduled,e.dataset.docxPaginating="true";const t=Array.from(e.querySelectorAll(":scope > section."+this.className)),r=this.options.maxDynamicPaginationPasses??1e3;let a=0;for(let e=0;e<t.length;e++){const n=t[e];let s=n.querySelector(":scope > article");for(e%2==0&&await this.yieldToBrowser();s&&this.isPageOverflowing(n)&&s.children.length>0&&a++<r;){const r=this.createContinuationPage(n),a=r.querySelector(":scope > article");let o=!1,i=0;for(;this.isPageOverflowing(n)&&s.lastElementChild&&i++<500;)if(i%20==0&&await this.yieldToBrowser(),s.children.length>1){let e=this.pickPaginationChunk(s);if(0==e.length)break;if(e.length>=s.children.length){if(this.splitOverflowBlock(s.lastElementChild,n,a)){o=!0;continue}e=[s.lastElementChild]}for(let t=e.length-1;t>=0;t--)a.prepend(e[t]),o=!0}else{if(!this.splitOverflowBlock(s.lastElementChild,n,a))break;o=!0}if(!o||0==a.children.length){r.remove();break}t.splice(e+1,0,r)}}this.cleanupEmptyNumberedParagraphs(e),this.removeEmptyDynamicPages(e),this.updateDynamicFieldPages(e),delete e.dataset.docxPaginating,e.dataset.docxPaginated="true"}pickPaginationChunk(e){const t=Array.from(e.children);if(0==t.length)return[];let r=t.length-1;for(;r>0&&this.isKeepWithNext(t[r-1]);)r--;return t.slice(r)}isKeepWithNext(e){if("true"==e.dataset.docxKeepNext)return!0;const t=getComputedStyle(e);return"avoid"==t.breakAfter||"avoid"==t.pageBreakAfter}isPageOverflowing(e){const t=this.options.paginationTolerance??2,r=e.clientHeight;if(r<=0)return!1;if(e.scrollHeight>r+t)return!0;const a=e.getBoundingClientRect();let n=a.top;for(const t of Array.from(e.children)){const e=t.getBoundingClientRect();if(n=Math.max(n,e.bottom),"article"==t.tagName.toLowerCase())for(const e of Array.from(t.children)){const t=e.getBoundingClientRect();n=Math.max(n,t.bottom)}}return n>a.bottom+t}createContinuationPage(e){const t=e.cloneNode(!0);t.dataset.docxDynamicPage="true",t.removeAttribute("id");for(const e of Array.from(t.querySelectorAll(":scope > article")))e.textContent="";return e.after(t),t}splitOverflowBlock(e,t,r){if(!e||"true"==e.dataset.docxKeepLines)return!1;const a=getComputedStyle(e);if("avoid"==a.breakInside||"avoid"==a.pageBreakInside)return!1;switch(e.tagName.toLowerCase()){case"p":return this.splitParagraphBlock(e,t,r);case"table":return this.splitTableBlock(e,t,r)}return!1}splitParagraphBlock(e,t,r){if(!e.hasChildNodes())return!1;const a=this.cloneBlockShell(e);a.dataset.docxContinued="true",r.prepend(a);let n=!1,s=0;for(;this.isPageOverflowing(t)&&e.hasChildNodes()&&s++<1e3&&this.moveTailInlineNode(e,a,t);)n=!0,this.removeEmptyInlineContainers(e);return n?(e.hasChildNodes()?this.options.strictWordCompatibility&&"true"==e.dataset.docxWidowControl&&this.rebalanceWidowOrphan(e,a,t):e.remove(),!0):(a.remove(),!1)}splitTableBlock(e,t,r){const a=this.tableContentRows(e);if(a.length<=1)return!1;const n=this.cloneBlockShell(e);n.dataset.docxContinued="true";for(const t of Array.from(e.children))"colgroup"==t.tagName?.toLowerCase()&&n.appendChild(t.cloneNode(!0));for(const e of a.filter(e=>"true"==e.dataset.docxRepeatHeader)){const t=e.cloneNode(!0);t.dataset.docxRepeatedHeader="true",n.appendChild(t)}r.prepend(n);let s=!1,o=0;for(;this.isPageOverflowing(t)&&this.tableContentRows(e).length>1&&o++<500;){const t=this.tableContentRows(e).filter(e=>"true"!=e.dataset.docxRepeatedHeader),r=t[t.length-1];if(!r)break;n.insertBefore(r,this.firstMovedTableRow(n)),s=!0}return!!s||(n.remove(),!1)}cloneBlockShell(e){const t=e.cloneNode(!1);return t.removeAttribute("id"),t}tableContentRows(e){return Array.from(e.querySelectorAll(":scope > tr, :scope > tbody > tr"))}firstMovedTableRow(e){return this.tableContentRows(e).find(e=>"true"!=e.dataset.docxRepeatedHeader)??null}moveTailInlineNode(e,t,r){const a=e.lastChild;if(!a)return!1;if(a.nodeType==Node.TEXT_NODE)return this.moveTextTail(a,t,r);if(a instanceof Element&&a.childNodes.length>0&&"br"!=a.tagName?.toLowerCase()){const e=a.cloneNode(!1);e.removeAttribute("id"),t.prepend(e);const n=this.moveTailInlineNode(a,e,r);return a.hasChildNodes()||a.remove(),e.hasChildNodes()||e.remove(),n}return t.prepend(a),!0}moveTextTail(e,t,r){const a=e.data??"";if(!a)return!1;const n=document.createTextNode("");if(t.prepend(n),1==a.length)return n.data=a,e.remove(),!0;let s=1,o=a.length,i=a.length;for(;s<=o;){const t=Math.floor((s+o)/2);e.data=a.substring(0,a.length-t),n.data=a.substring(a.length-t),this.isPageOverflowing(r)?s=t+1:(i=t,o=t-1)}return i=this.adjustSplitToWordBoundary(a,i),e.data=a.substring(0,a.length-i),n.data=a.substring(a.length-i),e.data||e.remove(),!0}adjustSplitToWordBoundary(e,t){if(t<=1||t>=e.length)return t;const r=e.length-t,a=e.lastIndexOf(" ",r);return a>0&&r-a<32?e.length-a-1:t}removeEmptyInlineContainers(e){for(const t of Array.from(e.childNodes))t instanceof HTMLElement&&(this.removeEmptyInlineContainers(t),t.hasChildNodes()||/^(br|img|svg|math)$/i.test(t.tagName)||t.remove())}cleanupEmptyNumberedParagraphs(e){const t=`p[class*="${this.className}-num-"]`;for(const r of Array.from(e.querySelectorAll(t))){if(this.hasVisiblePaginationContent(r))continue;if(!r.id&&!r.querySelector("[id], a[name]"))continue;const t=this.findNextVisiblePaginationBlock(e,r);t&&this.moveAnchorsToBlock(r,t),r.remove()}}removeEmptyDynamicPages(e){const t=Array.from(e.querySelectorAll(`:scope > section.${this.className}[data-docx-dynamic-page="true"]`));for(const e of t){const t=e.querySelector(":scope > article");t&&!Array.from(t.children).some(e=>this.hasVisiblePaginationContent(e))&&e.remove()}}findNextVisiblePaginationBlock(e,t){const r=Array.from(e.querySelectorAll("article p, article table, article figure, article img, article svg, article math"));for(let e=r.indexOf(t)+1;e<r.length;e++){const t=r[e];if(this.hasVisiblePaginationContent(t))return t}return null}hasVisiblePaginationContent(e){return(e.textContent??"").replace(/\s+/g,"").length>0||!!e.querySelector("br,img,svg,math,object,canvas,video,table")}moveAnchorsToBlock(e,t){const r=Array.from(e.querySelectorAll("[id], a[name]"));e.id&&!t.id&&(t.id=e.id);for(let e=r.length-1;e>=0;e--){const a=r[e];a.id&&t.querySelector(`#${CSS.escape(a.id)}`)||t.prepend(a)}}rebalanceWidowOrphan(e,t,r){const a=this.visualLineCount(e),n=this.visualLineCount(t);if(a>=2&&n>=2)return;if(a<2&&e.parentElement&&t.hasChildNodes())return t.prepend(...Array.from(e.childNodes)),void e.remove();let s=0;for(;this.visualLineCount(t)<2&&e.hasChildNodes()&&s++<20&&!this.isPageOverflowing(r)&&this.moveTailInlineNode(e,t,r););}visualLineCount(e){try{const t=document.createRange();t.selectNodeContents(e);const r=Array.from(t.getClientRects());t.detach?.();const a=new Set(r.map(e=>Math.round(e.top)));return Math.max(a.size,1)}catch{return 1}}updateDynamicFieldPages(e){const t=Array.from(e.querySelectorAll(":scope > section."+this.className)),r={},a={},n={},s=[],o=[];let i=0,l="";for(const e of t){const t=e.dataset.docxSection??"";a[t]=(a[t]??0)+1}if(t.forEach((e,t)=>{const c=e.dataset.docxSection??"";if(c!=l){const t=null!=e.dataset.docxPageStart?parseInt(e.dataset.docxPageStart,10):null;i=Number.isFinite(t)?t:i+1,n[c]=1,l=c}else i++,n[c]=(n[c]??0)+1;e.dataset.docxPageNumber=`${i}`,e.dataset.docxSectionPageNumber=`${n[c]}`,e.dataset.docxSectionPageCount=`${a[c]??1}`,s[t]=i,o[t]=n[c];for(const t of Array.from(e.querySelectorAll("[id]")))t.id&&null==r[t.id]&&(r[t.id]=i)}),t.forEach((e,n)=>{const i=e.dataset.docxSection??"";for(const l of Array.from(e.querySelectorAll("[data-docx-field-instr]"))){const c=this.evaluateDynamicField(l.dataset.docxFieldInstr,s[n]??n+1,t.length,r,a[i]??1,o[n]??1,parseInt(e.dataset.docxSectionNumber??"1",10));null!=c&&(l.textContent=c)}}),this.options.updatePageReferences)for(const t of Array.from(e.querySelectorAll("[data-docx-page-ref]"))){const e=t.dataset.docxPageRef;t.textContent=`${r[e]??1}`}}evaluateDynamicField(e,t,r,a,n=r,s=t,o=1){const i=this.tokenizeFieldInstruction((e??"").replace(/\s+/g," ").trim()),l=i[0]?.replace(/^=/,"").toUpperCase();let c=null;switch(l){case"PAGE":c=this.formatFieldNumber(t,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??this.currentSectionProps?.pageNumber?.format));break;case"NUMPAGES":c=this.formatFieldNumber(r,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??this.currentSectionProps?.pageNumber?.format));break;case"SECTIONPAGES":c=this.formatFieldNumber(n,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??this.currentSectionProps?.pageNumber?.format));break;case"SECTION":c=this.formatFieldNumber(o,this.fieldFormatSwitchToNumFormat(this.fieldSwitch(i,"\\*")??"decimal"));break;case"PAGEREF":{if(!this.options.updatePageReferences)return null;const e=this.firstFieldArgument(i);c=e?`${a[e]??1}`:"";break}}return null==c?null:this.applyFieldFormatting(c,e)}renderDefaultStyle(){var e=this.className,t=`\n.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; }\n.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }`;this.options.hideWrapperOnPrint&&(t=`@media not print { ${t} }`);var r=`${t}\n.${e} { color: black; hyphens: auto; text-underline-position: from-font; font-kerning: normal; font-variant-ligatures: common-ligatures contextual; text-rendering: optimizeLegibility; line-break: auto; }\nsection.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: visible; }\nsection.${e}>article { margin-bottom: auto; z-index: 1; }\nsection.${e}>footer { z-index: 1; }\n.${e} [data-docx-continued="true"] { margin-top: 0 !important; }\n.${e} tr[data-docx-repeat-header="true"], .${e} tr[data-docx-repeated-header="true"] { break-after: avoid; }\n.${e} table { border-collapse: collapse; }\n.${e} table td, .${e} table th { vertical-align: top; overflow-wrap: anywhere; }\n.${e} p { margin: 0pt; min-height: 1em; }\n.${e} span { white-space: pre-wrap; overflow-wrap: break-word; font-feature-settings: "kern" 1; }\n.${e} table span { overflow-wrap: anywhere; }\n.${e} .${e}-float-wrap { shape-margin: 0.15in; }\n.${e} .${e}-field { white-space: pre-wrap; }\n.${e} .${e}-tab-stop { display: inline-block; min-width: 1em; white-space: nowrap; line-height: 1; }\n.${e} .${e}-tab-stop[data-docx-tab-leader="dot"], .${e} .${e}-tab-stop[data-docx-tab-leader="middleDot"] { min-width: 2em; border-bottom: 1px dotted currentColor; height: .85em; transform: translateY(-.18em); }\n.${e} .${e}-tab-stop[data-docx-tab-leader="hyphen"], .${e} .${e}-tab-stop[data-docx-tab-leader="heavy"], .${e} .${e}-tab-stop[data-docx-tab-leader="underscore"] { min-width: 2em; border-bottom: 1px solid currentColor; height: .85em; transform: translateY(-.18em); }\n.${e} .${e}-tab-leader-paragraph > a, .${e} .${e}-tab-leader-paragraph > .${e}-tab-leader-line { display: inline-flex; align-items: baseline; width: calc(100% - var(--docx-text-indent, 0pt)); color: inherit !important; text-decoration: none !important; box-sizing: border-box; max-width: none; }\n.${e} .${e}-tab-leader-paragraph > a, .${e} .${e}-tab-leader-paragraph > a * { color: inherit !important; text-decoration: none !important; }\n.${e} .${e}-toc-paragraph a, .${e} .${e}-toc-paragraph a * { color: inherit !important; text-decoration: none !important; }\n.${e} .${e}-toc-paragraph.${e}-tab-leader-paragraph[class*="${e}-num-"] { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: .35em; align-items: baseline; list-style-position: outside; list-style-type: none; text-indent: 0 !important; }\n.${e} .${e}-toc-paragraph.${e}-tab-leader-paragraph[class*="${e}-num-"]::before { grid-column: 1; grid-row: 1; white-space: pre; margin-inline-end: 0; }\n.${e} .${e}-toc-paragraph.${e}-tab-leader-paragraph[class*="${e}-num-"] > a { grid-column: 2; grid-row: 1; display: inline-flex; flex: 1 1 auto; width: auto; min-width: 0; max-width: 100%; }\n.${e} .${e}-tab-leader-title { flex: 0 1 auto; min-width: 0; }\n.${e} .${e}-tab-leader-page { flex: 0 0 auto; white-space: nowrap; text-align: right; }\n.${e} .${e}-tab-leader-fill, .${e} .${e}-tab-leader-paragraph > a > .${e}-tab-stop[data-docx-tab-leader="dot"], .${e} .${e}-tab-leader-paragraph > a > .${e}-tab-stop[data-docx-tab-leader="middleDot"], .${e} .${e}-tab-leader-paragraph > .${e}-tab-stop[data-docx-tab-leader="dot"], .${e} .${e}-tab-leader-paragraph > .${e}-tab-stop[data-docx-tab-leader="middleDot"] { flex: 1 1 auto; width: auto; margin: 0 .2em; }\n.${e} .${e}-toc { display: table; width: 100%; }\n.${e} .${e}-toc-entry { display: table-row; }\n.${e} .${e}-toc-title, .${e} .${e}-toc-page { display: table-cell; }\n.${e} .${e}-toc-title { border-bottom: 1px dotted currentColor; }\n.${e} .${e}-toc-page { text-align: right; width: 3em; }\n.${e} math { font-family: Cambria Math, STIX Two Math, Latin Modern Math, serif; }\n.${e} ruby { ruby-position: over; }\n.${e} rt { font-size: 0.5em; line-height: 1; }\n.${e} .${e}-chart, .${e} .${e}-smartart, .${e} .${e}-ink { min-width: 2in; min-height: 1in; }\n.${e} a { color: inherit; text-decoration: inherit; }\n.${e} svg { fill: transparent; }\n@media print { .${e}-wrapper { background: transparent; padding: 0; display: block; } section.${e} { margin: 0 auto; box-shadow: none; break-after: page; page-break-after: always; } }\n`;return this.options.renderComments&&(r+=`\n.${e}-comment-ref { cursor: default; }\n.${e}-comment-popover { display: none; z-index: 1000; padding: 0.5rem; background: white; position: absolute; box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.25); width: 30ch; }\n.${e}-comment-ref:hover~.${e}-comment-popover { display: block; }\n.${e}-comment-author,.${e}-comment-date { font-size: 0.875rem; color: #888; }\n`),[this.h({tagName:"#comment",children:["docxjs library predefined styles"]}),this.h({tagName:"style",children:[r]})]}async renderNumbering(e){var t="",r=[];const a=new Map,n=new Map(e.map(e=>[`${e.id}:${e.level}`,this.numFormatToCssValue(e.format)])),s=(e,t)=>{const r=a.get(e)??[];r.push(t),a.set(e,r)};for(var o of e){var i=`p.${this.numberingClass(o.id,o.level)}`,l="none";if(o.bullet){let e=`--${this.className}-${o.bullet.src}`.toLowerCase();t+=this.styleToString(`${i}:before`,{content:"' '",display:"inline-block",background:`var(${e})`},o.bullet.style);try{const r=await this.document.loadNumberingImage(o.bullet.src);t+=`${this.rootSelector} { ${e}: url(${r}) }`}catch(e){this.options.debug&&console.warn(`Can't load numbering image with src ${o.bullet.src}`)}}else if(o.levelText){let e=this.numberingCounter(o.id,o.level);const a=e+" "+(o.start-1),l=this.numberingRestartLevel(o);null!=l&&s(`p.${this.numberingClass(o.id,l)}`,a),r.push(a);const c=this.normalizeNumberingLevelText(o.levelText,o.format,o.rStyle),u=this.numberingMarkerRunStyle(o.rStyle,c.normalized);t+=this.styleToString(`${i}:before`,{content:this.levelTextToContent(c.text,o.suff,o.id,this.numFormatToCssValue(o.format),n),"counter-increment":e,"font-family":"var(--docx-marker-font-family, inherit)","font-size":"var(--docx-marker-font-size, inherit)","font-style":"var(--docx-marker-font-style, inherit)","font-weight":"var(--docx-marker-font-weight, inherit)",...u})}else l=this.numFormatToCssValue(o.format);t+=this.styleToString(i,{display:"list-item","list-style-position":"inside","list-style-type":l,...o.pStyle})}for(const[e,r]of a)t+=this.styleToString(e,{"counter-set":r.join(" ")});return r.length>0&&(t+=this.styleToString(this.rootSelector,{"counter-reset":r.join(" ")})),[this.h({tagName:"#comment",children:["docxjs document numbering styles"]}),this.h({tagName:"style",children:[t]})]}renderStyles(e){var t="";const r=this.styleMap,a=(0,n.keyBy)(e.filter(e=>e.isDefault),e=>e.target);for(const n of e){var s=n.styles;if(n.linked){var o=n.linked&&r[n.linked];o?s=s.concat(o.styles):this.options.debug&&console.warn(`Can't find linked style ${n.linked}`)}for(const e of s){var i=`${n.target??""}.${n.cssName}${e.mod??""}`;n.target!=e.target&&(i+=` ${e.target}`),a[n.target]==n&&(i=`.${this.className} ${n.target}, `+i),t+=this.styleToString(i,e.values)}}return[this.h({tagName:"#comment",children:["docxjs document styles"]}),this.h({tagName:"style",children:[t]})]}renderNotes(e,t,r){var a=e.map(e=>t[e]).filter(e=>e);if(a.length>0){const e=this.currentPart;this.currentPart=r??e;const t=this.renderElements(a);return this.currentPart=e,this.h({tagName:"ol",children:t})}}renderElement(e){switch(e.type){case a.DomType.Paragraph:return this.renderParagraph(e);case a.DomType.BookmarkStart:return this.renderBookmarkStart(e);case a.DomType.BookmarkEnd:return null;case a.DomType.Run:return this.renderRun(e);case a.DomType.Table:return this.renderTable(e);case a.DomType.Row:return this.renderTableRow(e);case a.DomType.Cell:return this.renderTableCell(e);case a.DomType.Hyperlink:return this.renderHyperlink(e);case a.DomType.SmartTag:return this.renderSmartTag(e);case a.DomType.Drawing:return this.renderDrawing(e);case a.DomType.Image:return this.renderImage(e);case a.DomType.Shape:return this.renderShape(e);case a.DomType.Chart:return this.renderChart(e);case a.DomType.SmartArt:return this.renderSmartArt(e);case a.DomType.Ink:return this.renderInk(e);case a.DomType.SimpleField:return this.renderSimpleField(e);case a.DomType.Instruction:case a.DomType.ComplexField:return null;case a.DomType.Text:return this.renderText(e);case a.DomType.DeletedText:return this.renderDeletedText(e);case a.DomType.Tab:return this.renderTab(e);case a.DomType.Symbol:return this.renderSymbol(e);case a.DomType.Break:return this.renderBreak(e);case a.DomType.Footer:return this.renderContainer(e,"footer");case a.DomType.Header:return this.renderContainer(e,"header");case a.DomType.Footnote:case a.DomType.Endnote:return this.renderContainer(e,"li");case a.DomType.FootnoteReference:return this.renderFootnoteReference(e);case a.DomType.EndnoteReference:return this.renderEndnoteReference(e);case a.DomType.NoBreakHyphen:return this.h("‑");case a.DomType.SoftHyphen:return this.h("­");case a.DomType.PositionalTab:return this.renderTab(e);case a.DomType.Ruby:return this.renderRuby(e);case a.DomType.RubyBase:return this.renderContainer(e,"span");case a.DomType.RubyText:return this.toHTML(e,i.ns.html,"rt");case a.DomType.VmlPicture:return this.renderVmlPicture(e);case a.DomType.VmlElement:return this.renderVmlElement(e);case a.DomType.MmlMath:return this.renderContainerNS(e,i.ns.mathML,"math",{xmlns:i.ns.mathML});case a.DomType.MmlMathParagraph:return this.renderMmlMathParagraph(e);case a.DomType.MmlFraction:return this.renderContainerNS(e,i.ns.mathML,"mfrac");case a.DomType.MmlBase:return this.renderContainerNS(e,i.ns.mathML,e.parent?.type==a.DomType.MmlMatrixRow?"mtd":"mrow");case a.DomType.MmlNumerator:case a.DomType.MmlDenominator:case a.DomType.MmlFunction:case a.DomType.MmlLimit:case a.DomType.MmlBox:return this.renderContainerNS(e,i.ns.mathML,"mrow");case a.DomType.MmlGroupChar:return this.renderMmlGroupChar(e);case a.DomType.MmlLimitLower:return this.renderContainerNS(e,i.ns.mathML,"munder");case a.DomType.MmlLimitUpper:return this.renderContainerNS(e,i.ns.mathML,"mover");case a.DomType.MmlSubSuperscript:return this.renderContainerNS(e,i.ns.mathML,"msubsup");case a.DomType.MmlPhantom:return this.renderMmlPhantom(e);case a.DomType.MmlBorderBox:return this.renderContainerNS(e,i.ns.mathML,"menclose");case a.DomType.MmlAccent:return this.renderMmlAccent(e);case a.DomType.MmlMatrix:return this.renderContainerNS(e,i.ns.mathML,"mtable");case a.DomType.MmlMatrixRow:return this.renderContainerNS(e,i.ns.mathML,"mtr");case a.DomType.MmlRadical:return this.renderMmlRadical(e);case a.DomType.MmlSuperscript:return this.renderContainerNS(e,i.ns.mathML,"msup");case a.DomType.MmlSubscript:return this.renderContainerNS(e,i.ns.mathML,"msub");case a.DomType.MmlDegree:case a.DomType.MmlSuperArgument:case a.DomType.MmlSubArgument:return this.renderContainerNS(e,i.ns.mathML,"mrow");case a.DomType.MmlFunctionName:return this.renderContainerNS(e,i.ns.mathML,"mi");case a.DomType.MmlDelimiter:return this.renderMmlDelimiter(e);case a.DomType.MmlRun:return this.renderMmlRun(e);case a.DomType.MmlNary:return this.renderMmlNary(e);case a.DomType.MmlPreSubSuper:return this.renderMmlPreSubSuper(e);case a.DomType.MmlBar:return this.renderMmlBar(e);case a.DomType.MmlEquationArray:return this.renderMllList(e);case a.DomType.Inserted:return this.renderInserted(e);case a.DomType.Deleted:return this.renderDeleted(e);case a.DomType.CommentRangeStart:return this.renderCommentRangeStart(e);case a.DomType.CommentRangeEnd:return this.renderCommentRangeEnd(e);case a.DomType.CommentReference:return this.renderCommentReference(e);case a.DomType.AltChunk:return this.renderAltChunk(e)}return null}renderElements(e,t){if(null==e)return null;const r=[];for(let t=0;t<e.length;t++){const a=this.tryRenderComplexField(e,t);a?(r.push(...(0,n.asArray)(a.node).filter(e=>null!=e)),t=a.nextIndex-1):r.push(...(0,n.asArray)(this.renderElement(e[t])).filter(e=>null!=e))}return t&&r.forEach(e=>t.appendChild((0,n.isString)(e)?document.createTextNode(e):e)),r}tryRenderComplexField(e,t){if(!this.hasFieldChar(e[t],"begin"))return null;let r=0,n=!1,s="";const o=[];for(let i=t;i<e.length;i++){const t=e[i],l=t.type==a.DomType.Run?{...t,fieldRun:!1,children:[]}:null;if(t.type==a.DomType.Run){for(const e of t.children??[]){if(e.type==a.DomType.ComplexField){const t=e;if("begin"==t.charType)r++;else if("separate"==t.charType&&1==r)n=!0;else if("end"==t.charType&&(r--,0==r))return l.children.length>0&&o.push(l),{node:this.renderSimpleField({type:a.DomType.SimpleField,instruction:s,lock:!1,dirty:!1,children:o}),nextIndex:i+1};continue}n||1!=r||e.type!=a.DomType.Instruction?n&&r>0&&l.children.push(e):s+=e.text??""}l.children.length>0&&o.push(l)}else n&&r>0&&o.push(t)}return null}hasFieldChar(e,t){return e.type==a.DomType.Run&&e.children?.some(e=>e.type==a.DomType.ComplexField&&e.charType==t)}renderContainer(e,t){return this.h({tagName:t,children:this.renderElements(e.children)})}renderContainerNS(e,t,r,a){return this.h({ns:t,tagName:r,children:this.renderElements(e.children),...a})}effectiveParagraphTabs(e,t){if(!e?.length)return t;if(!t?.length)return e;const r=[...t];for(const t of e){const e=this.parseCssLengthValue(t.position),a=r.findIndex(t=>this.parseCssLengthValue(t.position)==e);a>=0?r[a]=t:r.push(t)}return r.sort((e,t)=>(this.parseCssLengthValue(e.position)??0)-(this.parseCssLengthValue(t.position)??0))}countParagraphTabs(e){let t=0;const r=e=>{e.type!=a.DomType.Tab&&e.type!=a.DomType.PositionalTab||t++;for(const t of e.children??[])r(t)};return r(e),t}isLeaderTabStop(e){return!!e?.leader&&"none"!=e.leader&&"clear"!=e.style}resolveRenderedTabStop(e,t,r){if(!e?.length)return null;const a=e[Math.min(t,Math.max(e.length-1,0))],n=[...e].reverse().find(e=>this.isLeaderTabStop(e)),s=this.findStyle(this.currentParagraph?.styleName),o=!!n&&!!(this.currentParagraph?.numbering??s?.paragraphProps?.numbering)&&this.isTocParagraphStyle(this.currentParagraph?.styleName,s);return n?r<=1?o?n:a:t>=r-1?n:this.isLeaderTabStop(a)?e.slice(0,Math.min(t+1,e.length)).reverse().find(e=>!this.isLeaderTabStop(e)&&"clear"!=e.style)??e.find(e=>!this.isLeaderTabStop(e)&&"clear"!=e.style)??null:a:a}renderParagraph(e){const t=this.findStyle(e.styleName);e.tabs=this.effectiveParagraphTabs(e.tabs,t?.paragraphProps?.tabs);const r=this.currentParagraph,a=this.currentParagraphTabIndex,n=this.currentParagraphTabCount;this.currentParagraph=e,this.currentParagraphTabIndex=0,this.currentParagraphTabCount=this.countParagraphTabs(e);const s=this.renderElements(e.children),o=e.props?.deletedParagraphMark&&!this.options.renderChanges;if(o&&!this.hasRenderedContent(s))return this.currentParagraph=r,this.currentParagraphTabIndex=a,this.currentParagraphTabCount=n,null;if(o)return this.currentParagraph=r,this.currentParagraphTabIndex=a,this.currentParagraphTabCount=n,s;var l=this.toHTML(e,i.ns.html,"p",this.wrapTabLeaderChildren(s,!0));this.currentParagraph=r,this.currentParagraphTabIndex=a,this.currentParagraphTabCount=n;const c=e.numbering??t?.paragraphProps?.numbering;c&&l.classList.add(this.numberingClass(c.id,c.level));const u=t?.paragraphProps;(e.pageBreakBefore??u?.pageBreakBefore)&&(l.style.breakBefore="page",l.dataset.docxPageBreakBefore="true"),(e.keepLines??u?.keepLines)&&(l.style.breakInside="avoid",l.dataset.docxKeepLines="true"),(e.keepNext??u?.keepNext)&&(l.style.breakAfter="avoid",l.dataset.docxKeepNext="true"),(e.widowControl??u?.widowControl)&&(l.style.orphans="2",l.style.widows="2",l.dataset.docxWidowControl="true"),this.applyDocumentGridLinePitch(e,t,l);const d=e.tabs?.find(e=>this.isLeaderTabStop(e));return d&&(l.classList.add(`${this.className}-tab-leader-paragraph`),l.dataset.docxHasTabLeader="true",l.dataset.docxTabLeader=d.leader,l.dataset.docxTabAlign=d.style),this.isTocParagraphStyle(e.styleName,t)&&(l.classList.add(`${this.className}-toc-paragraph`),l.dataset.docxTocEntry="true"),this.hasParagraphRelativeAnchor(e)&&(l.style.position&&"static"!=l.style.position||(l.style.position="relative"),l.dataset.docxAnchorContext="paragraph"),e.props?.anchorId&&(l.id=e.props.anchorId,l.setAttribute("id",e.props.anchorId)),l}hasParagraphRelativeAnchor(e){for(const t of e.children??[]){if(t.type==a.DomType.Drawing&&"absolute"==t.cssStyle?.position){const e=t.props?.anchorPosition,r=e?.vertical?.relative,a=e?.horizontal?.relative;if("paragraph"==r||"line"==r||"character"==r||"character"==a)return!0}if(this.hasParagraphRelativeAnchor(t))return!0}return!1}renderHyperlink(e){const t=this.renderElements(e.children),r=this.toH(e,i.ns.html,"a",this.wrapTabLeaderChildren(t));if(r.href="",e.id){const t=this.currentPart??this.document.documentPart,a=t?.rels?.find(t=>t.id==e.id&&"External"===t.targetMode);r.href=a?.target??r.href}return!r.href&&e.anchor&&(r.href+=`#${e.anchor}`),this.h(r)}wrapTabLeaderChildren(e,t=!1){if(!e?.length||e.some(e=>this.hasCssClass(e,`${this.className}-tab-leader-title`)))return e;let r=-1;for(let t=e.length-1;t>=0;t--)if(this.isTabLeaderNode(e[t])){r=t;break}if(r<0)return e;const a=e.slice(0,r),n=e[r],s=e.slice(r+1);this.addCssClass(n,`${this.className}-tab-leader-fill`);const o=[this.h({tagName:"span",className:`${this.className}-tab-leader-title`,children:a}),n,this.h({tagName:"span",className:`${this.className}-tab-leader-page`,children:s})];return t?[this.h({tagName:"span",className:`${this.className}-tab-leader-line`,children:o})]:o}isTabLeaderNode(e){const t=this.nodeDatasetValue(e,"docxTabLeader");return this.hasCssClass(e,this.tabStopClass())&&!!t&&"none"!=t}nodeDatasetValue(e,t){const r=e,a=r?.dataset?.[t];if(null!=a)return String(a);const n="data-"+t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());return"function"==typeof r?.getAttribute?r.getAttribute(n):r?.attributes?.[n]}hasCssClass(e,t){const r=e;return!(!r||!t)&&("function"==typeof r.classList?.contains?r.classList.contains(t):this.nodeClassName(r).split(/\s+/).includes(t))}addCssClass(e,t){const r=e;if(!r||!t||this.hasCssClass(e,t))return;if("function"==typeof r.classList?.add)return void r.classList.add(t);const a=(0,i.cx)(this.nodeClassName(r),t);"function"==typeof r.setAttribute?r.setAttribute("class",a):(r.attributes??(r.attributes={}),r.attributes.class=a)}nodeClassName(e){return"string"==typeof e?.className?e.className:"string"==typeof e?.className?.baseVal?e.className.baseVal:"function"==typeof e?.getAttribute?e.getAttribute("class")??"":e?.attributes?.class??""}renderSmartTag(e){return this.renderContainer(e,"span")}renderCommentRangeStart(e){if(!this.options.renderComments)return null;const t=new Range;this.commentHighlight?.add(t);const r=this.h({tagName:"#comment",children:[`start of comment #${e.id}`]});return this.later(()=>t.setStart(r,0)),this.commentMap[e.id]=t,r}renderCommentRangeEnd(e){if(!this.options.renderComments)return null;const t=this.commentMap[e.id],r=this.h({tagName:"#comment",children:[`end of comment #${e.id}`]});return this.later(()=>t?.setEnd(r,0)),r}renderCommentReference(e){if(!this.options.renderComments)return null;var t=this.document.commentsPart?.commentMap[e.id];if(!t)return null;const r=this.h({tagName:"span",className:`${this.className}-comment-ref`,children:["💬"]}),a=this.h({tagName:"div",className:`${this.className}-comment-popover`,children:[this.h({tagName:"div",className:`${this.className}-comment-author`,children:[t.author]}),this.h({tagName:"div",className:`${this.className}-comment-date`,children:[new Date(t.date).toLocaleString()]}),...this.renderElements(t.children)]});return this.h({tagName:"#fragment",children:[this.h({tagName:"#comment",children:[`comment #${t.id} by ${t.author} on ${t.date}`]}),r,a]})}renderAltChunk(e){if(!this.options.renderAltChunks)return null;var t=this.h({tagName:"iframe",sandbox:"",referrerPolicy:"no-referrer",loading:"lazy"});return this.tasks.push(this.document.loadAltChunk(e.id,this.currentPart).then(e=>{t.srcdoc=e})),t}renderDrawing(e){e.cssStyle?.["shape-outside"]&&(e.className=(0,i.cx)(e.className,`${this.className}-float-wrap`));var t=this.toHTML(e,i.ns.html,"div");return(e.cssStyle?.float||"absolute"==e.cssStyle?.position)&&(t.dataset.docxFloat="true"),t.style.display||(t.style.display="inline-block"),t.style.position||(t.style.position="relative"),t.style.textIndent="0px",t}renderImage(e){let t=this.toHTML(e,i.ns.html,"img",[]),r=e.cssStyle?.transform;if(e.alt&&(t.alt=e.alt),e.title&&(t.title=e.title),e.srcRect&&e.srcRect.some(e=>0!=e)){var[a,n,s,o]=e.srcRect;r=`${r??""} scale(${1/(1-a-s)}, ${1/(1-n-o)})`,t.style.clipPath=`inset(${(100*n).toFixed(2)}% ${(100*s).toFixed(2)}% ${(100*o).toFixed(2)}% ${(100*a).toFixed(2)}%)`,t.style.transformOrigin="top left"}return e.rotation&&(r=`rotate(${e.rotation}deg) ${r??""}`),t.style.transform=r?.trim(),this.document&&e.src&&this.tasks.push(this.document.loadDocumentImage(e.src,this.currentPart).then(e=>{t.src=e,e&&t.setAttribute("src",e)})),t}renderShape(e){if(e.props?.dmlSvg)return this.renderDmlSvgShape(e);const t=e.props?.dmlTextBox?[this.renderDmlTextBox(e)]:null,r=this.toHTML(e,i.ns.html,"div",t);return r.style.display||(r.style.display="inline-block"),e.title&&(r.title=e.title),e.alt&&(r.setAttribute("role","img"),r.setAttribute("aria-label",e.alt)),r}renderDmlTextBox(e){return this.h({tagName:"div",className:`${this.className}-shape-textbox`,style:{"box-sizing":"border-box",display:"flex","flex-direction":"column","justify-content":e.props?.textVerticalAlign??"flex-start","align-items":"stretch",width:"100%",height:"100%",overflow:"hidden",...e.props?.textInsets??{}},children:this.renderElements(e.children)})}renderDmlSvgShape(e){const t=this.createSvgElement("svg",{style:e.cssStyle}),r=e.props??{};t.setAttribute("viewBox",r.viewBox??"0 0 1 1"),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("focusable","false"),e.title&&t.appendChild(this.createSvgElement("title",null,[e.title])),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt));const a=this.createSvgElement("path");return a.setAttribute("d",r.pathD??""),a.setAttribute("fill",r.fill??"none"),a.setAttribute("stroke",r.stroke??"none"),a.setAttribute("stroke-width",r.strokeWidth??"0"),a.setAttribute("stroke-linejoin","round"),a.setAttribute("stroke-linecap","round"),r.strokeDasharray&&a.setAttribute("stroke-dasharray",r.strokeDasharray),t.appendChild(a),t}renderChart(e){const t=this.toHTML(e,i.ns.html,"div",[]);if(t.className=(0,i.cx)(t.className,`${this.className}-chart`),e.title&&(t.title=e.title),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt)),t.appendChild(this.renderGraphicLoading("Chart")),e.id){const r=this.currentPart;this.tasks.push(this.document.loadRelationshipXml(e.id,r).then(e=>{t.textContent="",t.appendChild(e?this.renderChartSvg(e):this.renderGraphicLoading("Chart"))}).catch(()=>{t.textContent="",t.appendChild(this.renderGraphicLoading("Chart"))}))}return t}renderSmartArt(e){const t=this.toHTML(e,i.ns.html,"div",[]);if(t.className=(0,i.cx)(t.className,`${this.className}-smartart`),e.title&&(t.title=e.title),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt)),t.appendChild(this.renderGraphicLoading("SmartArt")),e.dataId){const r=this.currentPart;this.tasks.push(this.document.loadRelationshipXml(e.dataId,r).then(e=>{t.textContent="",t.appendChild(e?this.renderSmartArtSvg(e):this.renderGraphicLoading("SmartArt"))}).catch(()=>{t.textContent="",t.appendChild(this.renderGraphicLoading("SmartArt"))}))}return t}renderInk(e){const t=this.toHTML(e,i.ns.html,"div",[]);if(t.className=(0,i.cx)(t.className,`${this.className}-ink`),e.title&&(t.title=e.title),e.alt&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt)),t.appendChild(this.renderGraphicLoading("Ink")),e.id){const r=this.currentPart;this.tasks.push(this.document.loadRelationshipText(e.id,r).then(a=>{if(t.textContent="",a?.trim().startsWith("<"))try{return void t.appendChild(this.renderInkSvg((0,l.parseXmlString)(a,!0)))}catch{}return this.document.loadRelationshipBlobUrl(e.id,r).then(r=>{t.textContent="",r?t.appendChild(this.h({tagName:"img",src:r,alt:e.alt??"Ink",style:{width:"100%",height:"100%",objectFit:"contain"}})):t.appendChild(this.renderGraphicLoading("Ink"))})}).catch(()=>{t.textContent="",t.appendChild(this.renderGraphicLoading("Ink"))}))}return t}renderGraphicLoading(e){return this.h({tagName:"span",style:{display:"inline-flex","align-items":"center","justify-content":"center",width:"100%",height:"100%","min-width":"2in","min-height":"1in",border:"1px solid currentColor"},children:[`[${e}]`]})}renderChartSvg(e){const t=e.documentElement,r=this.detectChartType(t),a=this.parseChartSeries(t,r),n=this.createSvgElement("svg",{style:{width:"100%",height:"100%",display:"block"}});n.setAttribute("viewBox","0 0 640 360"),n.setAttribute("preserveAspectRatio","xMidYMid meet");const s=this.extractChartTitle(t);if(s&&n.appendChild(this.svgText(s,320,24,"middle","14px","bold")),0==a.length||a.every(e=>0==e.values.length))return n.appendChild(this.svgText("Chart",320,180,"middle","18px")),n;switch(r){case"pieChart":case"doughnutChart":this.drawPieChart(n,a[0]);break;case"lineChart":case"scatterChart":case"areaChart":this.drawLineChart(n,a,"areaChart"==r);break;default:this.drawBarChart(n,a)}return n}detectChartType(e){return["barChart","bar3DChart","lineChart","pieChart","doughnutChart","areaChart","scatterChart","ofPieChart","radarChart"].find(t=>this.firstByLocal(e,t))??"barChart"}parseChartSeries(e,t){const r=this.firstByLocal(e,t)??e;return this.elementsByLocal(r,"ser").map((e,t)=>{const r=this.firstByLocal(e,"tx"),a=this.firstByLocal(e,"cat")??this.firstByLocal(e,"xVal"),n=this.firstByLocal(e,"val")??this.firstByLocal(e,"yVal"),s=this.chartCacheValues(a),o=this.chartCacheValues(n).map(e=>parseFloat(e)).filter(e=>!Number.isNaN(e));return{name:this.chartText(r)||`Series ${t+1}`,categories:s.length>0?s:o.map((e,t)=>`${t+1}`),values:o}})}chartCacheValues(e){return e?this.elementsByLocal(e,"pt").map(e=>({index:parseInt(e.getAttribute("idx")??"0",10),value:this.firstByLocal(e,"v")?.textContent??""})).sort((e,t)=>e.index-t.index).map(e=>e.value):[]}chartText(e){if(!e)return"";const t=this.chartCacheValues(e);return t.length>0?t.join(" "):this.elementsByLocal(e,"t").map(e=>e.textContent).filter(Boolean).join(" ").trim()}extractChartTitle(e){const t=this.firstByLocal(e,"title");return this.chartText(t)}drawBarChart(e,t){const r=300,a=t[0]?.categories??[],n=Math.max(1,...t.flatMap(e=>e.values)),s=540/Math.max(a.length,1),o=s/Math.max(t.length+1,2);e.appendChild(this.svgLine(60,r,600,r)),e.appendChild(this.svgLine(60,r,60,70)),t.forEach((t,a)=>{t.values.forEach((t,i)=>{const l=Math.max(0,t/n*230),c=this.createSvgElement("rect");c.setAttribute("x",""+(60+i*s+a*o+.2*o)),c.setAttribute("y",""+(r-l)),c.setAttribute("width",""+.8*o),c.setAttribute("height",`${l}`),c.style.fill=this.chartColor(a),e.appendChild(c)})}),a.slice(0,12).forEach((t,r)=>{e.appendChild(this.svgText(t,60+r*s+s/2,318,"middle","10px"))}),t.forEach((t,r)=>this.drawLegend(e,t.name,r,70+130*r,335))}drawLineChart(e,t,r=!1){const a=300,n=Math.max(1,...t.flatMap(e=>e.values)),s=Math.max(...t.map(e=>e.values.length),1),o=540/Math.max(s-1,1);e.appendChild(this.svgLine(60,a,600,a)),e.appendChild(this.svgLine(60,a,60,70)),t.forEach((t,s)=>{const i=t.values.map((e,t)=>[60+t*o,a-e/n*230]),l=this.createSvgElement("path");if(l.setAttribute("d",i.map((e,t)=>`${0==t?"M":"L"}${e[0]},${e[1]}`).join(" ")),l.style.stroke=this.chartColor(s),l.style.strokeWidth="2",l.style.fill="none",e.appendChild(l),r&&i.length>1){const t=this.createSvgElement("path");t.setAttribute("d",`${i.map((e,t)=>`${0==t?"M":"L"}${e[0]},${e[1]}`).join(" ")} L${i[i.length-1][0]},300 L${i[0][0]},300 Z`),t.style.fill=this.chartColor(s),t.style.opacity="0.25",e.appendChild(t)}for(const[t,r]of i){const a=this.createSvgElement("circle");a.setAttribute("cx",`${t}`),a.setAttribute("cy",`${r}`),a.setAttribute("r","3"),a.style.fill=this.chartColor(s),e.appendChild(a)}}),(t[0]?.categories??[]).slice(0,12).forEach((t,r)=>{e.appendChild(this.svgText(t,60+r*o,318,"middle","10px"))}),t.forEach((t,r)=>this.drawLegend(e,t.name,r,70+130*r,335))}drawPieChart(e,t){const r=t.values,a=t.categories,n=r.reduce((e,t)=>e+Math.max(0,t),0)||1;let s=-90;r.forEach((t,r)=>{const o=Math.max(0,t)/n*360,i=this.createSvgElement("path");i.setAttribute("d",this.pieSlicePath(300,180,110,s,s+o)),i.style.fill=this.chartColor(r),e.appendChild(i),this.drawLegend(e,a[r]??`${r+1}`,r,450,90+22*r),s+=o})}pieSlicePath(e,t,r,a,n){const s=this.polar(e,t,r,n),o=this.polar(e,t,r,a),i=n-a<=180?"0":"1";return`M${e},${t} L${s.x},${s.y} A${r},${r} 0 ${i},0 ${o.x},${o.y} Z`}polar(e,t,r,a){const n=(a-90)*Math.PI/180;return{x:e+r*Math.cos(n),y:t+r*Math.sin(n)}}drawLegend(e,t,r,a,n){const s=this.createSvgElement("rect");s.setAttribute("x",`${a}`),s.setAttribute("y",""+(n-10)),s.setAttribute("width","10"),s.setAttribute("height","10"),s.style.fill=this.chartColor(r),e.appendChild(s),e.appendChild(this.svgText(t,a+14,n,"start","10px"))}chartColor(e){return`hsl(${47*e%360}, 65%, 48%)`}renderSmartArtSvg(e){const t=e.documentElement,r=this.elementsByLocal(t,"pt").map(e=>({id:e.getAttribute("modelId"),type:e.getAttribute("type"),text:this.elementsByLocal(e,"t").map(e=>e.textContent).filter(Boolean).join(" ").trim()})).filter(e=>e.id&&e.text&&"doc"!=e.type),a=this.elementsByLocal(t,"cxn").map(e=>({src:e.getAttribute("srcId"),dst:e.getAttribute("destId")})).filter(e=>e.src&&e.dst&&r.some(t=>t.id==e.src)&&r.some(t=>t.id==e.dst)),n=this.createSvgElement("svg",{style:{width:"100%",height:"100%",display:"block"}});if(n.setAttribute("viewBox","0 0 640 360"),n.setAttribute("preserveAspectRatio","xMidYMid meet"),0==r.length)return n.appendChild(this.svgText("SmartArt",320,180,"middle","18px")),n;const s=this.layoutDiagramNodes(r,a),o={},i=Math.min(90,260/Math.max(s.length,1));s.forEach((e,t)=>{const r=55+t*i,a=560/Math.max(e.length,1);e.forEach((e,t)=>{o[e.id]={x:40+a*t+Math.max(0,a-140)/2,y:r}})});for(const e of a){const t=o[e.src],r=o[e.dst];t&&r&&n.appendChild(this.svgLine(t.x+70,t.y+44,r.x+70,r.y))}return r.forEach((e,t)=>{const r=o[e.id];if(!r)return;const a=this.createSvgElement("rect");a.setAttribute("x",`${r.x}`),a.setAttribute("y",`${r.y}`),a.setAttribute("width","140"),a.setAttribute("height","44"),a.setAttribute("rx","8"),a.style.fill=this.chartColor(t),a.style.opacity="0.18",a.style.stroke=this.chartColor(t),n.appendChild(a),n.appendChild(this.svgText(e.text,r.x+70,r.y+27,"middle","11px"))}),n}layoutDiagramNodes(e,t){const r=new Map(e.map(e=>[e.id,0]));t.forEach(e=>r.set(e.dst,(r.get(e.dst)??0)+1));let a=e.filter(e=>0==(r.get(e.id)??0));const n=new Set,s=[];for(0==a.length&&(a=e.slice(0,1));a.length>0;){s.push(a),a.forEach(e=>n.add(e.id));const r=t.filter(e=>a.some(t=>t.id==e.src)).map(e=>e.dst).filter(e=>!n.has(e));a=[...new Set(r)].map(t=>e.find(e=>e.id==t)).filter(Boolean)}const o=e.filter(e=>!n.has(e.id));return o.length>0&&s.push(o),s}renderInkSvg(e){const t=this.createSvgElement("svg",{style:{width:"100%",height:"100%",display:"block"}});t.setAttribute("viewBox","0 0 640 360"),t.setAttribute("preserveAspectRatio","xMidYMid meet");const r=this.elementsByLocal(e.documentElement,"trace").map(e=>this.inkTraceToPoints(e.textContent)),a=this.elementsByLocal(e.documentElement,"path").map(e=>e.getAttribute("d")).filter(Boolean);if(0==r.length&&0==a.length)return t.appendChild(this.svgText("Ink",320,180,"middle","18px")),t;const n=r.flat(),s=Math.min(...n.map(e=>e[0]),0),o=Math.min(...n.map(e=>e[1]),0),i=Math.max(...n.map(e=>e[0]),640),l=Math.max(...n.map(e=>e[1]),360),c=Math.min(600/Math.max(i-s,1),320/Math.max(l-o,1)),u=20-s*c,d=20-o*c;for(const e of r){if(e.length<2)continue;const r=this.createSvgElement("path");r.setAttribute("d",e.map((e,t)=>`${0==t?"M":"L"}${e[0]*c+u},${e[1]*c+d}`).join(" ")),r.style.fill="none",r.style.stroke="currentColor",r.style.strokeWidth="2",r.style.strokeLinecap="round",r.style.strokeLinejoin="round",t.appendChild(r)}for(const e of a){const r=this.createSvgElement("path");r.setAttribute("d",e),r.style.fill="none",r.style.stroke="currentColor",r.style.strokeWidth="2",t.appendChild(r)}return t}inkTraceToPoints(e){const t=(e??"").match(/-?\d+(?:\.\d+)?/g)?.map(Number)??[],r=[];for(let e=0;e+1<t.length;e+=2)r.push([t[e],t[e+1]]);return r}svgLine(e,t,r,a){const n=this.createSvgElement("line");return n.setAttribute("x1",`${e}`),n.setAttribute("y1",`${t}`),n.setAttribute("x2",`${r}`),n.setAttribute("y2",`${a}`),n.style.stroke="currentColor",n.style.strokeWidth="1",n}svgText(e,t,r,a="start",n="12px",s=null){const o=this.createSvgElement("text");return o.setAttribute("x",`${t}`),o.setAttribute("y",`${r}`),o.setAttribute("text-anchor",a),o.style.fill="currentColor",o.style.fontSize=n,s&&(o.style.fontWeight=s),o.appendChild(document.createTextNode(e)),o}elementsByLocal(e,t){const r=e.documentElement??e;return Array.from(r.getElementsByTagName("*")).filter(e=>e.localName==t)}firstByLocal(e,t){return this.elementsByLocal(e,t)[0]??null}renderSimpleField(e){const t=this.evaluateFieldNode(e);return void 0===t?this.renderElements(e.children??[]):null==t?null:(0,n.isString)(t)?this.renderFieldText(t,e.instruction):t}renderFieldText(e,t){const r=this.h({tagName:"span",className:`${this.className}-field`,children:[e]});return t&&(r.dataset.docxFieldInstr=t),r}evaluateFieldNode(e){const t=(e.instruction??"").replace(/\s+/g," ").trim();if(!t)return;if(t.startsWith("=")){const e=this.evaluateFormula(t.substring(1));return null==e?void 0:this.applyFieldFormatting(`${e}`,t)}const r=this.tokenizeFieldInstruction(t),a=r[0]?.replace(/^=/,"").toUpperCase();if(!this.shouldPreserveStoredFieldResult(a,e))switch(a){case"PAGE":return this.applyFieldFormatting(this.formatFieldNumber(this.currentPageNumber,this.currentSectionProps?.pageNumber?.format),t);case"NUMPAGES":return this.applyFieldFormatting(this.formatFieldNumber(this.totalPages,this.currentSectionProps?.pageNumber?.format),t);case"SECTIONPAGES":return this.applyFieldFormatting(this.formatFieldNumber(this.sectionPageCount,this.currentSectionProps?.pageNumber?.format),t);case"SECTION":return this.applyFieldFormatting(this.formatFieldNumber(this.currentSectionNumber,"decimal"),t);case"DATE":case"TIME":case"CREATEDATE":case"SAVEDATE":case"PRINTDATE":return this.applyFieldFormatting(this.evaluateDateField(r,a),t);case"AUTHOR":return this.applyFieldFormatting(this.document.corePropsPart?.props?.creator??"",t);case"TITLE":return this.applyFieldFormatting(this.document.corePropsPart?.props?.title??"",t);case"SUBJECT":return this.applyFieldFormatting(this.document.corePropsPart?.props?.subject??"",t);case"KEYWORDS":return this.applyFieldFormatting(this.document.corePropsPart?.props?.keywords??"",t);case"NUMWORDS":return this.applyFieldFormatting(`${this.document.extendedPropsPart?.props?.words??""}`,t);case"NUMCHARS":return this.applyFieldFormatting(`${this.document.extendedPropsPart?.props?.characters??""}`,t);case"FILENAME":return this.applyFieldFormatting(this.document.documentPart?.path?.split("/").pop()??"",t);case"DOCPROPERTY":return this.applyFieldFormatting(this.evaluateDocPropertyField(r),t);case"DOCVARIABLE":return this.applyFieldFormatting(this.evaluateDocVariableField(r),t);case"MERGEFIELD":return;case"SET":return this.evaluateSetField(r),null;case"QUOTE":return this.applyFieldFormatting(r.slice(1).map(e=>this.resolveFieldValue(e)).join(""),t);case"HYPERLINK":return this.renderHyperlinkField(r,e);case"IF":return this.applyFieldFormatting(this.evaluateIfField(r),t);case"REF":case"STYLEREF":case"NOTEREF":return this.applyFieldFormatting(this.evaluateRefField(r),t);case"PAGEREF":return this.applyFieldFormatting(this.evaluatePageRefField(r),t);case"SEQ":return this.applyFieldFormatting(this.evaluateSeqField(r),t);case"LISTNUM":return this.applyFieldFormatting(this.evaluateListNumField(r),t);case"TC":case"XE":return null;case"TOC":return this.renderTocField(r);case"SYMBOL":return this.evaluateSymbolField(r)}}shouldPreserveStoredFieldResult(e,t){if(!this.options.preserveComplexFieldResults||!t.children?.length)return!1;switch(e){case"PAGE":case"NUMPAGES":case"SECTIONPAGES":case"SECTION":return!1;case"PAGEREF":return!this.options.updatePageReferences;case"TOC":case"REF":case"STYLEREF":case"NOTEREF":case"SEQ":case"LISTNUM":case"IF":case"DOCVARIABLE":case"MERGEFIELD":return!0}return!1}tokenizeFieldInstruction(e){const t=[];let r="",a=null,n=!1;for(const s of e)n?(r+=s,n=!1):"\\"!=s?'"'!=s&&"'"!=s?!/\s/.test(s)||a?r+=s:r&&(t.push(r),r=""):a==s?(a=null,t.push(r),r=""):a?r+=s:(r.trim()&&t.push(r.trim()),r="",a=s):a?n=!0:(r&&(t.push(r),r=""),r="\\");return r&&t.push(r),t}fieldSwitch(e,t){const r=t.toLowerCase(),a=e.findIndex(e=>e.toLowerCase()==r);return a>=0?e[a+1]:null}hasFieldSwitch(e,t){const r=t.toLowerCase();return e.some(e=>e.toLowerCase()==r)}firstFieldArgument(e,t=1){for(let r=t;r<e.length;r++){if(!e[r]?.startsWith("\\"))return e[r];r++}return null}evaluateDateField(e,t){const r=this.fieldSwitch(e,"\\@"),a=new Date;return r?this.formatFieldDate(a,r):"TIME"==t?a.toLocaleTimeString():a.toLocaleDateString()}formatFieldDate(e,t){const r=(e,t=2)=>`${e}`.padStart(t,"0"),a=["January","February","March","April","May","June","July","August","September","October","November","December"],n=a.map(e=>e.substring(0,3)),s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],o=s.map(e=>e.substring(0,3)),i=[[/yyyy/g,`${e.getFullYear()}`],[/yy/g,r(e.getFullYear()%100)],[/MMMM/g,a[e.getMonth()]],[/MMM/g,n[e.getMonth()]],[/MM/g,r(e.getMonth()+1)],[/M/g,`${e.getMonth()+1}`],[/dddd/g,s[e.getDay()]],[/ddd/g,o[e.getDay()]],[/dd/g,r(e.getDate())],[/d/g,`${e.getDate()}`],[/HH/g,r(e.getHours())],[/H/g,`${e.getHours()}`],[/hh/g,r((e.getHours()+11)%12+1)],[/h/g,""+((e.getHours()+11)%12+1)],[/mm/g,r(e.getMinutes())],[/m/g,`${e.getMinutes()}`],[/ss/g,r(e.getSeconds())],[/s/g,`${e.getSeconds()}`],[/AM\/PM/g,e.getHours()<12?"AM":"PM"],[/am\/pm/g,e.getHours()<12?"am":"pm"]];let l=t;for(const[e,t]of i)l=l.replace(e,t);return l}evaluateDocPropertyField(e){const t=this.firstFieldArgument(e)?.toLowerCase();if(!t)return"";const r={...this.document.corePropsPart?.props??{},...this.document.extendedPropsPart?.props??{}};for(const[e,a]of Object.entries(r))if(e.toLowerCase()==t)return null==a?"":`${a}`;return""}evaluateSetField(e){const t=this.firstFieldArgument(e);if(!t)return;const r=e.slice(e.indexOf(t)+1).filter(e=>!e.startsWith("\\")).map(e=>this.resolveFieldValue(e)).join(" ");this.fieldSetValues[t]=r}evaluateDocVariableField(e){const t=this.firstFieldArgument(e);return t?this.fieldSetValues[t]??"":""}renderHyperlinkField(e,t){const r=this.fieldSwitch(e,"\\l"),a=this.firstFieldArgument(e)??"",n=r?`${a}#${r}`:a,s=this.h({tagName:"a",href:n,children:this.renderElements(t.children??[])});return s.textContent||(s.textContent=n||r),s}evaluateIfField(e){const t=["<>",">=","<=","=",">","<"],r=e.findIndex((e,r)=>r>0&&t.includes(e));if(r<0)return"";const a=this.resolveFieldValue(e.slice(1,r).join(" ")),n=e[r],s=this.resolveFieldValue(e[r+1]??""),o=e[r+2]??"",i=e[r+3]??"",l=parseFloat(a),c=parseFloat(s),u=!Number.isNaN(l)&&!Number.isNaN(c),d=u?l:a,h=u?c:s;let p=!1;switch(n){case"=":p=d==h;break;case"<>":p=d!=h;break;case">":p=d>h;break;case"<":p=d<h;break;case">=":p=d>=h;break;case"<=":p=d<=h}return this.resolveFieldValue(p?o:i)}resolveFieldValue(e){const t=(e??"").trim();if(/^[-+]?\d+(?:\.\d+)?$/.test(t))return t;if(this.bookmarkTextMap.hasOwnProperty(t))return this.bookmarkTextMap[t];if(this.fieldSetValues.hasOwnProperty(t))return this.fieldSetValues[t];if(t.startsWith("=")){const e=this.evaluateFormula(t.substring(1));return null==e?"":`${e}`}const r=this.tokenizeFieldInstruction(t)[0]?.toUpperCase();if(["PAGE","NUMPAGES","SECTIONPAGES","SECTION","DATE","TIME","AUTHOR","TITLE","SUBJECT","KEYWORDS","REF","PAGEREF","SEQ","DOCPROPERTY"].includes(r)){const e=this.evaluateFieldNode({type:a.DomType.SimpleField,instruction:t,lock:!1,dirty:!1,children:[]});if((0,n.isString)(e))return e}return t}evaluateRefField(e){const t=this.firstFieldArgument(e);return t?this.bookmarkTextMap[t]??this.fieldSetValues[t]??"":""}evaluatePageRefField(e){const t=this.firstFieldArgument(e);return t?`${null!=this.bookmarkTextMap[t]?Math.max(this.currentPageNumber,1):1}`:""}evaluateSeqField(e){const t=this.firstFieldArgument(e);if(!t)return"";if(this.hasFieldSwitch(e,"\\h"))return"";const r=this.fieldSwitch(e,"\\r"),a=this.hasFieldSwitch(e,"\\c");null!=r?this.fieldSeqCounters[t]=parseInt(r,10)||0:a||(this.fieldSeqCounters[t]=(this.fieldSeqCounters[t]??0)+1);const n=this.fieldSwitch(e,"\\*")??"decimal";return this.formatFieldNumber(this.fieldSeqCounters[t]??0,this.fieldFormatSwitchToNumFormat(n))}evaluateListNumField(e){const t=this.firstFieldArgument(e)??"LISTNUM";this.fieldSeqCounters[t]=(this.fieldSeqCounters[t]??0)+1;const r=this.fieldSwitch(e,"*")??"decimal";return this.formatFieldNumber(this.fieldSeqCounters[t],this.fieldFormatSwitchToNumFormat(r))}renderTocField(e){let t=1,r=9;const a=this.fieldSwitch(e,"\\o");if(a){const e=/(\d+)\s*-\s*(\d+)/.exec(a);e&&(t=parseInt(e[1],10),r=parseInt(e[2],10))}const n=this.tocEntries.filter(e=>e.level>=t&&e.level<=r).map(e=>{const t=this.h({tagName:"span",className:`${this.className}-toc-page`,children:["1"]});return t.dataset.docxPageRef=e.id,this.h({tagName:"div",className:`${this.className}-toc-entry ${this.className}-toc-level-${e.level}`,children:[this.h({tagName:"a",className:`${this.className}-toc-title`,href:`#${e.id}`,children:[e.text]}),t]})});return this.h({tagName:"div",className:`${this.className}-toc`,children:n})}evaluateSymbolField(e){const t=parseInt(e[1],10);return Number.isFinite(t)?String.fromCharCode(t):""}evaluateFormula(e){const t=e.replace(/,/g,"").trim();if(!/^[0-9+\-*/().\s]+$/.test(t))return null;try{const e=Function(`"use strict"; return (${t});`)();return Number.isFinite(e)?e:null}catch{return null}}applyFieldFormatting(e,t){const r=this.tokenizeFieldInstruction(t);let a=e??"";const n=this.fieldSwitch(r,"\\*"),s=n?.toUpperCase(),o=this.fieldSwitch(r,"\\#");if(o){const e=parseFloat(a);Number.isNaN(e)||(a=this.formatNumberPicture(e,o))}switch(s){case"UPPER":a=a.toUpperCase();break;case"LOWER":a=a.toLowerCase();break;case"FIRSTCAP":a=a.substring(0,1).toUpperCase()+a.substring(1).toLowerCase();break;case"CAPS":a=a.replace(/\b\w/g,e=>e.toUpperCase());break;case"ROMAN":{const e=parseInt(a,10);Number.isNaN(e)||(a="roman"==n?this.toRoman(e).toLowerCase():this.toRoman(e).toUpperCase());break}case"ALPHABETIC":{const e=parseInt(a,10);Number.isNaN(e)||(a="alphabetic"==n?this.toLetters(e).toLowerCase():this.toLetters(e).toUpperCase());break}}return a}formatNumberPicture(e,t){const r=t.indexOf("."),a=r>=0?t.length-r-1:0;let n=e.toFixed(a);if(t.includes(",")){const[e,t]=n.split(".");n=e.replace(/\B(?=(\d{3})+(?!\d))/g,",")+(null!=t?`.${t}`:"")}return n}fieldFormatSwitchToNumFormat(e){if("roman"==e)return"lowerRoman";if("alphabetic"==e)return"lowerLetter";switch(e?.toUpperCase()){case"ROMAN":return"upperRoman";case"ALPHABETIC":return"upperLetter";default:return"decimal"}}formatFieldNumber(e,t){switch(t){case"upperRoman":return this.toRoman(e).toUpperCase();case"lowerRoman":return this.toRoman(e).toLowerCase();case"upperLetter":return this.toLetters(e).toUpperCase();case"lowerLetter":return this.toLetters(e).toLowerCase();case"decimalZero":return e<10?`0${e}`:`${e}`;default:return`${e}`}}toRoman(e){const t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let r=Math.max(Math.floor(e),0),a="";for(const[e,n]of t)for(;r>=e;)a+=n,r-=e;return a||`${e}`}toLetters(e){let t=Math.max(Math.floor(e),1),r="";for(;t>0;)t--,r=String.fromCharCode(65+t%26)+r,t=Math.floor(t/26);return r}renderRuby(e){const t=e.children?.find(e=>e.type==a.DomType.RubyBase),r=e.children?.find(e=>e.type==a.DomType.RubyText),s=[...t?this.renderElements(t.children):[],...r?(0,n.asArray)(this.renderElement(r)).filter(e=>null!=e):[]],o=this.h({tagName:"ruby",children:s});return e.align&&(o.style.rubyAlign=e.align),o}hasRenderedContent(e){for(const t of e??[]){if(!t)continue;const e=t,r=e.nodeType,a=String(e.localName??e.tagName??e.nodeName??"").toLowerCase();if(3==r||"#text"==a){if((e.textContent??e.text??e.data??"").length)return!0;continue}if(["br","img","svg","math","table"].includes(a))return!0;if((e.textContent??"").length)return!0;const n=Array.from(e.childNodes??e.children??[]);if(n.length&&this.hasRenderedContent(n))return!0}return!1}renderText(e){return this.h(this.applyCjkLineBreakGuards(e.text))}applyCjkLineBreakGuards(e){if(!e||!this.document.settingsPart?.settings?.kinsoku)return e;const t=this.document.settingsPart.settings.noLineBreaksBefore??"!),.:;?]}¢°·'\"†‡›℃∶、。々〉》」』】〕〗〙〛〜゠ァィゥェォッャュョヮ・ー-?!%,.:;゛゜ヽヾゝゞー",r=this.document.settingsPart.settings.noLineBreaksAfter??"([{$£¥'\"“‘〈《「『【〔〖〘〚";let a="";for(const n of e)t.includes(n)&&(a+="⁠"),a+=n,r.includes(n)&&(a+="⁠");return a}renderDeletedText(e){return this.options.renderChanges?this.renderText(e):null}renderBreak(e){switch(e.break){case"textWrapping":case"line":return this.h({tagName:"br"});case"column":return this.h({tagName:"span",style:{breakAfter:"column"}});case"page":return this.options.breakPages?null:this.h({tagName:"span",style:{breakAfter:"page"}});case"lastRenderedPageBreak":return this.options.breakPages||this.options.ignoreLastRenderedPageBreak?null:this.h({tagName:"span",style:{breakAfter:"page"}})}return null}renderInserted(e){return this.options.renderChanges?this.renderContainer(e,"ins"):this.renderElements(e.children)}renderDeleted(e){return this.options.renderChanges?this.renderContainer(e,"del"):null}renderSymbol(e){return this.h({tagName:"span",children:[String.fromCharCode(e.char)],style:{fontFamily:e.font}})}renderFootnoteReference(e){return this.currentFootnoteIds.push(e.id),this.h({tagName:"sup",children:[`${this.currentFootnoteIds.length}`]})}renderEndnoteReference(e){return this.currentEndnoteIds.push(e.id),this.h({tagName:"sup",children:[`${this.currentEndnoteIds.length}`]})}renderTab(e){const t=this.currentParagraph??function(e,t){for(var r=e.parent;null!=r&&r.type!=t;)r=r.parent;return r}(e,a.DomType.Paragraph),r=t?.tabs??[],n=r.filter(e=>"clear"!=e?.style),s=this.currentParagraphTabIndex++,o=this.resolveRenderedTabStop(n,s,this.currentParagraphTabCount);var i=this.h({tagName:"span",className:this.tabStopClass(),children:[" "]});return i.dataset.docxTab="true",o&&(i.dataset.docxTabAlign=o.style??"left",i.dataset.docxTabLeader=o.leader??"none",o.position&&(i.dataset.docxTabPos=o.position)),this.options.experimental&&this.currentTabs.push({stops:r,span:i}),i}renderBookmarkStart(e){const t=this.h({tagName:"span"});return e.name&&(t.id=e.name,t.setAttribute("id",e.name)),t}renderRun(e){const t=e.fieldRun?e.children?.filter(e=>e.type!=a.DomType.Instruction&&e.type!=a.DomType.ComplexField):e.children;if(e.fieldRun&&(!t||0==t.length))return null;let r=this.renderElements(t);if(e.verticalAlign&&(r=[this.h({tagName:e.verticalAlign,children:this.renderElements(t)})]),!e.verticalAlign&&1==t?.length&&(t[0].type==a.DomType.Tab||t[0].type==a.DomType.PositionalTab)&&1==r?.length){const t=r[0];return e.cssStyle&&Object.assign(t.style,e.cssStyle),e.className&&t.classList.add(e.className),t}const n=this.toHTML(e,i.ns.html,"span",r);return e.id&&(n.id=e.id),n}renderTable(e){e.columns?.length&&!e.cssStyle?.["table-layout"]&&(e.cssStyle??(e.cssStyle={}),e.cssStyle["table-layout"]="fixed"),this.tableCellPositions.push(this.currentCellPosition),this.tableVerticalMerges.push(this.currentVerticalMerge),this.currentVerticalMerge={},this.currentCellPosition={col:0,row:0};const t=[];return e.columns&&t.push(this.renderTableColumns(e.columns)),t.push(...this.renderElements(e.children)),this.currentVerticalMerge=this.tableVerticalMerges.pop(),this.currentCellPosition=this.tableCellPositions.pop(),this.toHTML(e,i.ns.html,"table",t)}renderTableColumns(e){const t=e.map(e=>this.h({tagName:"col",style:{width:e.width}}));return this.h({tagName:"colgroup",children:t})}renderTableRow(e){this.currentCellPosition.col=0;const t=[],r=this.currentTableRow;this.currentTableRow=e,e.gridBefore&&t.push(this.renderTableCellPlaceholder(e.gridBefore)),t.push(...this.renderElements(e.children)),e.gridAfter&&t.push(this.renderTableCellPlaceholder(e.gridAfter)),this.currentTableRow=r,this.currentCellPosition.row++;const a=this.toHTML(e,i.ns.html,"tr",t);return e.isHeader&&(a.dataset.docxRepeatHeader="true"),a}renderTableCellPlaceholder(e){return this.h({tagName:"td",colSpan:e,style:{border:"none"}})}renderTableCell(e){const t=this.currentTableRow?.isHeader?"th":"td";let r=this.toHTML(e,i.ns.html,t);const a=this.currentCellPosition.col;return e.verticalMerge?"restart"==e.verticalMerge?(this.currentVerticalMerge[a]=r,r.rowSpan=1):this.currentVerticalMerge[a]&&(this.currentVerticalMerge[a].rowSpan+=1,r.style.display="none"):this.currentVerticalMerge[a]=null,e.span&&(r.colSpan=e.span),this.currentCellPosition.col+=r.colSpan,r}renderVmlPicture(e){return this.renderContainer(e,"div")}renderVmlElement(e){var t=this.h({ns:i.ns.svg,tagName:"svg",style:e.cssStyleText});const r=this.renderVmlChildElement(e);e.imageHref?.id&&this.tasks.push(this.document?.loadDocumentImage(e.imageHref.id,this.currentPart).then(e=>r.setAttribute("href",e))),t.appendChild(r);const a=globalThis.requestAnimationFrame;return("function"==typeof a?a.bind(globalThis):e=>setTimeout(()=>e(Date.now()),0))(()=>{try{const e=t.firstElementChild,r="function"==typeof e?.getBBox?e.getBBox():null;r&&Number.isFinite(r.width)&&Number.isFinite(r.height)&&r.width>0&&r.height>0&&(t.setAttribute("width",`${Math.ceil(r.x+r.width)}`),t.setAttribute("height",`${Math.ceil(r.y+r.height)}`))}catch{}}),t}renderVmlChildElement(e){const t=this.createSvgElement(e.tagName);Object.entries(e.attrs).forEach(([e,r])=>t.setAttribute(e,r));for(let r of e.children)if(r.type==a.DomType.VmlElement)t.appendChild(this.renderVmlChildElement(r));else for(const e of(0,n.asArray)(this.renderElement(r)).filter(e=>null!=e))t.appendChild((0,n.isString)(e)?document.createTextNode(e):e);return t}renderMmlMathParagraph(e){const t=this.renderElements(e.children);for(const e of t)"math"==e?.localName&&e.setAttribute("display","block");return this.h({tagName:"div",className:`${this.className}-math-paragraph`,style:{textAlign:"center"},children:t})}renderMmlPhantom(e){return this.renderContainerNS(e,i.ns.mathML,"mphantom")}renderMmlAccent(e){const t=e.children?.find(e=>e.type==a.DomType.MmlBase),r=this.createMathMLElement("mo",null,[e.props?.char??"^"]),s=t?(0,n.asArray)(this.renderElement(t)).filter(e=>null!=e):[];return this.createMathMLElement("mover",null,[...s,r])}renderMmlRadical(e){const t=e.children.find(e=>e.type==a.DomType.MmlBase);if(e.props?.hideDegree)return this.createMathMLElement("msqrt",null,this.renderElements([t]));const r=e.children.find(e=>e.type==a.DomType.MmlDegree);return this.createMathMLElement("mroot",null,this.renderElements([t,r]))}renderMmlDelimiter(e){const t=[],r=e.props?.beginChar,a=e.props?.endChar;return""!==r&&t.push(this.createMathMLElement("mo",null,[r??"("])),t.push(...this.renderElements(e.children)),""!==a&&t.push(this.createMathMLElement("mo",null,[a??")"])),this.createMathMLElement("mrow",null,t)}renderMmlNary(e){const t=[],r=(0,n.keyBy)(e.children,e=>e.type),s=r[a.DomType.MmlSuperArgument],o=r[a.DomType.MmlSubArgument],i=s?this.createMathMLElement("mrow",null,this.renderElements(s.children)):null,l=o?this.createMathMLElement("mrow",null,this.renderElements(o.children)):null,c=this.createMathMLElement("mo",null,[e.props?.char??"∫"]);return i&&l?t.push(this.createMathMLElement("munderover",null,[c,l,i])):i?t.push(this.createMathMLElement("mover",null,[c,i])):l?t.push(this.createMathMLElement("munder",null,[c,l])):t.push(c),r[a.DomType.MmlBase]&&t.push(...this.renderElements(r[a.DomType.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlPreSubSuper(e){const t=[],r=(0,n.keyBy)(e.children,e=>e.type),s=r[a.DomType.MmlSuperArgument],o=r[a.DomType.MmlSubArgument],i=this.createMathMLElement("mrow",null,s?this.renderElements(s.children):[]),l=this.createMathMLElement("mrow",null,o?this.renderElements(o.children):[]),c=this.createMathMLElement("mrow",null,[]);return t.push(this.createMathMLElement("msubsup",null,[c,l,i])),r[a.DomType.MmlBase]&&t.push(...this.renderElements(r[a.DomType.MmlBase].children)),this.createMathMLElement("mrow",null,t)}renderMmlGroupChar(e){const t="bot"===e.props?.verticalJustification?"munder":"mover",r=this.createMathMLElement("mrow",null,this.renderElements(e.children)),a=this.createMathMLElement("mo",null,[e.props?.char??"⏞"]);return this.createMathMLElement(t,null,[r,a])}renderMmlBar(e){const t={};switch(e.props.position){case"top":t.textDecoration="overline";break;case"bottom":t.textDecoration="underline"}return this.renderContainerNS(e,i.ns.mathML,"mrow",{style:t})}renderMmlRun(e){const t=this.extractMathRunText(e);if(null!=t){const r=this.renderMathTextTokens(t,e.cssStyle);return r.length?r:null}return this.renderContainerNS(e,i.ns.mathML,"mrow")}extractMathRunText(e){let t="";for(const r of e.children??[])switch(r.type){case a.DomType.Text:t+=r.text??"";break;case a.DomType.DeletedText:this.options.renderChanges&&(t+=r.text??"");break;case a.DomType.Symbol:t+=String.fromCharCode(r.char);break;case a.DomType.Tab:t+=" ";break;case a.DomType.NoBreakHyphen:t+="‑";break;case a.DomType.SoftHyphen:break;default:return null}return t}renderMathTextTokens(e,t){const r=[];let a=0;for(;a<e.length;){const n=e[a];if(/\s/.test(n)){let t=a+1;for(;t<e.length&&/\s/.test(e[t]);)t++;r.push(this.createMathMLElement("mspace",{width:.25*Math.max(1,t-a)+"em"})),a=t;continue}if(c(n)){let n=a+1;for(;n<e.length&&(c(e[n])||"."==e[n]);)n++;r.push(this.createMathToken("mn",e.substring(a,n),t)),a=n;continue}if(u(n)){let n=a+1;for(;n<e.length&&u(e[n]);)n++;r.push(this.createMathToken("mi",e.substring(a,n),t)),a=n;continue}d(n)?r.push(this.createMathToken("mo",n,t)):r.push(this.createMathToken("mtext",n,t)),a++}return r}createMathToken(e,t,r){return this.createMathMLElement(e,r?{style:r}:null,[t])}renderMllList(e){const t=this.renderElements(e.children).map(e=>this.createMathMLElement("mtr",null,[this.createMathMLElement("mtd",null,[e])]));return this.toHTML(e,i.ns.mathML,"mtable",t)}toH(e,t,r,a=null){const{$lang:n,...s}=e.cssStyle??{};return{ns:t,tagName:r,className:(0,i.cx)(e.className,e.styleName&&this.processStyleName(e.styleName)),lang:n,style:s,children:a??this.renderElements(e.children)}}toHTML(e,t,r,a=null){return this.h(this.toH(e,t,r,a))}findStyle(e){return e&&this.styleMap?.[e]}isTocParagraphStyle(e,t){return[e,t?.id,t?.name,t?.cssName,...t?.aliases??[]].filter(Boolean).map(e=>String(e).replace(/[\s_-]+/g,"").toLowerCase()).some(e=>/^toc[1-9]$/.test(e))}numberingClass(e,t){return`${this.className}-num-${e}-${t}`}tabStopClass(){return`${this.className}-tab-stop`}styleToString(e,t,r=null){let a=`${e} {\r\n`;for(const e in t)e.startsWith("$")||(a+=` ${e}: ${t[e]};\r\n`);return r&&(a+=r),a+"}\r\n"}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}numberingRestartLevel(e){if(e.level<=0)return null;if(null==e.restart)return e.level-1;if(0==e.restart)return null;const t=e.restart-1;return t>=0&&t<e.level?t:null}numberingMarkerRunStyle(e,t){if(!e)return e;const r={...e};return t&&delete r["font-family"],r}normalizeNumberingLevelText(e,t,r){if("bullet"!=t||!e)return{text:e,normalized:!1};const a=(r?.["font-family"]??"").toLowerCase();let n=!1,s=null;if(a.includes("wingdings"))s=this.wingdingsBulletMap();else{if(!a.includes("symbol"))return{text:e,normalized:!1};s=this.symbolBulletMap()}let o="";for(const t of e){const e=s[t.charCodeAt(0)];e?(o+=e,n=!0):o+=t}return{text:o,normalized:n}}symbolBulletMap(){return{183:"•",8226:"•",61623:"•"}}wingdingsBulletMap(){return{61548:"●",61550:"■",61557:"◆",61598:"·",61599:"•",61600:"▪",61601:"○",61604:"◉",61605:"◎",61607:"▪",61608:"◻",61656:"➢",61672:"➔",61690:"▫",61691:"✗",61692:"✓",61693:"☒",61694:"☑"}}levelTextToContent(e,t,r,a,n){const s=[];let o=0;for(const t of e.matchAll(/%\d+/g)){t.index>o&&s.push(`"${this.escapeCssString(e.substring(o,t.index))}"`);let i=parseInt(t[0].substring(1),10)-1;const l=n?.get(`${r}:${i}`)??a??"decimal";s.push(`counter(${this.numberingCounter(r,i)}, ${l})`),o=t.index+t[0].length}const i=e.substring(o);i&&s.push(`"${this.escapeCssString(i)}"`);const l=this.numberingSuffixToCssContent(t);return l&&s.push(l),s.length>0?s.join(" "):'""'}numberingSuffixToCssContent(e){switch(e||"tab"){case"nothing":return"";case"space":return'"\\000020"';default:return'"\\000009"'}}escapeCssString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r?\n/g,"\\A ")}numFormatToCssValue(e){return{none:"none",bullet:"disc",decimal:"decimal",lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero",aiueo:"katakana",aiueoFullWidth:"katakana",chineseCounting:"simp-chinese-informal",chineseCountingThousand:"simp-chinese-informal",chineseLegalSimplified:"simp-chinese-formal",chosung:"hangul-consonant",ideographDigital:"cjk-ideographic",ideographTraditional:"cjk-heavenly-stem",ideographLegalTraditional:"trad-chinese-formal",ideographZodiac:"cjk-earthly-branch",iroha:"katakana-iroha",irohaFullWidth:"katakana-iroha",japaneseCounting:"japanese-informal",japaneseDigitalTenThousand:"cjk-decimal",japaneseLegal:"japanese-formal",thaiNumbers:"thai",koreanCounting:"korean-hangul-formal",koreanDigital:"korean-hangul-formal",koreanDigital2:"korean-hanja-informal",hebrew1:"hebrew",hebrew2:"hebrew",hindiNumbers:"devanagari",ganada:"hangul",taiwaneseCounting:"cjk-ideographic",taiwaneseCountingThousand:"cjk-ideographic",taiwaneseDigital:"cjk-decimal"}[e]??e??"decimal"}refreshTabStops(){this.options.experimental&&setTimeout(()=>{const e=(0,s.computePixelToPoint)();for(let t of this.currentTabs)(0,s.updateTabStop)(t.span,t.stops,this.defaultTabSize,e)},500)}createElementNS(e,t,r,a){return this.h({ns:e,tagName:t,children:a,...r})}createElement(e,t,r){return this.createElementNS(i.ns.html,e,t,r)}createMathMLElement(e,t,r){return this.createElementNS(i.ns.mathML,e,t,r)}createSvgElement(e,t,r){return this.createElementNS(i.ns.svg,e,t,r)}later(e){this.postRenderTasks.push(e)}}},"./html":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ns=void 0,r.h=function e(t){if((0,a.isString)(t))return document.createTextNode(t);if(t instanceof Node)return t;const{ns:r,tagName:n,className:s,style:o,children:i,...l}=t;if("#fragment"===n)return document.createDocumentFragment();if("#comment"===n)return document.createComment(i[0]);const c=r?document.createElementNS(r,n):document.createElement(n);if(s&&c.setAttribute("class",s),o&&((0,a.isString)(o)?c.setAttribute("style",o):Object.assign(c.style,o)),l)for(const[e,t]of Object.entries(l))void 0!==t&&(c[e]=t);return i&&i.forEach(t=>c.appendChild(e(t))),c},r.cx=function(...e){return e.filter(Boolean).join(" ")};const a=e("./utils");var n;!function(e){e.html="http://www.w3.org/1999/xhtml",e.svg="http://www.w3.org/2000/svg",e.mathML="http://www.w3.org/1998/Math/MathML"}(n||(r.ns=n={}))},"./input-validation":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.EMPTY_DOCX_ERROR_MESSAGE=void 0,r.assertNonEmptyDocxInput=function(e){if(0===function(e){if(null==e)return 0;if("undefined"!=typeof Blob&&e instanceof Blob)return e.size;if("undefined"!=typeof ArrayBuffer){if(e instanceof ArrayBuffer)return e.byteLength;if(ArrayBuffer.isView(e))return e.byteLength}return"number"==typeof e.size?e.size:"number"==typeof e.byteLength?e.byteLength:"number"==typeof e.length?e.length:null}(e))throw new Error(r.EMPTY_DOCX_ERROR_MESSAGE)},r.EMPTY_DOCX_ERROR_MESSAGE="文件为空或尚未保存,无法作为 Word 文档打开。请在 WPS/Word 中保存后重新上传。"},"./javascript":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.computePixelToPoint=function(e=document.body){const t=document.createElement("div");t.style.width="100pt",e.appendChild(t);const r=100/t.offsetWidth;return e.removeChild(t),r},r.updateTabStop=function(e,t,r,i=.75){const l=e.closest("p");if(!l)return;const c=e.getBoundingClientRect(),u=l.getBoundingClientRect(),d=getComputedStyle(l),h=s(d.marginInlineStart||d.marginLeft),p=s(d.marginInlineEnd||d.marginRight),m=t?.length>0?t.map(e=>({pos:o(e.position),leader:e.leader,style:e.style})).sort((e,t)=>e.pos-t.pos):[a],f=m[m.length-1],g=(u.width+h+p)*i,b=Number.isFinite(o(r))?o(r):36;let y=f.pos+b;if(y<g)for(;y<g&&m.length<n;y+=b)m.push({...a,pos:y});const k=u.left-h,x=(c.left-k)*i,T=m.find(e=>"clear"!=e.style&&e.pos>x);if(null==T)return;let P=1;if("right"==T.style||"center"==T.style){const t=Array.from(l.querySelectorAll(`.${e.className}`)),r=t.indexOf(e)+1,a=document.createRange();a.setStart(e,1),r<t.length?a.setEndBefore(t[r]):a.setEndAfter(l);const n="center"==T.style?.5:1,s=a.getBoundingClientRect(),o=s.left+n*s.width-k;P=T.pos-o*i}else P=T.pos-x;const v=Math.max(Number.isFinite(P)?P:0,0);switch(e.innerHTML="&nbsp;",e.style.display="inline-block",e.style.width=`${v.toFixed(2)}pt`,e.style.minWidth="0pt",e.style.lineHeight="1",e.style.whiteSpace="nowrap",e.style.wordSpacing="normal",e.style.textDecoration="none",e.style.borderBottom="",e.style.height="",e.style.transform="",T.leader){case"dot":case"middleDot":e.style.borderBottom="1px dotted currentColor",e.style.height=".85em",e.style.transform="translateY(-.18em)";break;case"hyphen":case"heavy":case"underscore":e.style.borderBottom="1px solid currentColor",e.style.height=".85em",e.style.transform="translateY(-.18em)"}};const a={pos:0,leader:"none",style:"left"},n=50;function s(e){const t=parseFloat(e);return Number.isFinite(t)?t:0}function o(e){return parseFloat(e)}},"./length":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Length=void 0;const a=e("./utils");class n{constructor(e,t){this.value=e,this.type=t}static parse(e){const t=parseFloat(e),r=/p[tx]$/i.exec(e)?.[0];return new n(t,r)}static from(e){return(0,a.isString)(e)?n.parse(e):e instanceof n?e:null}add(e){if(e.type!==this.type)throw new Error("Can't do math on different types");return new n(this.value+e.value,this.type)}mul(e){return new n(this.value*e,this.type)}valueOf(){return this.value}toString(){return`${this.value.toFixed(2)}${this.type??""}`}}r.Length=n},"./license-gate":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.assertViewerLicense=function(e,t){}},"./metafile/emf-to-svg":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isEmfBinary=o,r.convertEmfToSvgDataUrl=function(e,t){const r=i(e,t);return r?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`:null},r.convertEmfToSvg=i;const a={HEADER:1,POLYBEZIER:2,POLYGON:3,POLYLINE:4,POLYBEZIERTO:5,POLYLINETO:6,POLYPOLYLINE:7,POLYPOLYGON:8,SETWINDOWEXTEX:9,SETWINDOWORGEX:10,SETVIEWPORTEXTEX:11,SETVIEWPORTORGEX:12,EOF:14,SETPIXELV:15,SETMAPMODE:17,SETBKMODE:18,SETPOLYFILLMODE:19,SETTEXTALIGN:22,SETTEXTCOLOR:24,SETBKCOLOR:25,MOVETOEX:27,SCALEVIEWPORTEXTEX:31,SCALEWINDOWEXTEX:32,SAVEDC:33,RESTOREDC:34,SETWORLDTRANSFORM:35,MODIFYWORLDTRANSFORM:36,SELECTOBJECT:37,CREATEPEN:38,CREATEBRUSHINDIRECT:39,DELETEOBJECT:40,ANGLEARC:41,ELLIPSE:42,RECTANGLE:43,ROUNDRECT:44,ARC:45,CHORD:46,PIE:47,LINETO:54,ARCTO:55,POLYDRAW:56,BEGINPATH:59,ENDPATH:60,CLOSEFIGURE:61,FILLPATH:62,STROKEANDFILLPATH:63,STROKEPATH:64,BITBLT:76,STRETCHBLT:77,STRETCHDIBITS:81,EXTCREATEFONTINDIRECTW:82,EXTTEXTOUTA:83,EXTTEXTOUTW:84,POLYBEZIER16:85,POLYGON16:86,POLYLINE16:87,POLYBEZIERTO16:88,POLYLINETO16:89,POLYPOLYLINE16:90,POLYPOLYGON16:91,POLYDRAW16:92,EXTCREATEPEN:95,POLYTEXTOUTA:96,POLYTEXTOUTW:97,SMALLTEXTOUT:108,ALPHABLEND:114,TRANSPARENTBLT:116},n={0:{type:"brush",color:"#ffffff"},1:{type:"brush",color:"#c0c0c0"},2:{type:"brush",color:"#808080"},3:{type:"brush",color:"#404040"},4:{type:"brush",color:"#000000"},5:{type:"brush",color:"none",nullBrush:!0},6:{type:"pen",color:"#ffffff",width:1},7:{type:"pen",color:"#000000",width:1},8:{type:"pen",color:"none",width:0,nullPen:!0},18:{type:"brush",color:"#ffffff"},19:{type:"pen",color:"#000000",width:1}},s={m11:1,m12:0,m21:0,m22:1,dx:0,dy:0};function o(e){if(!e||e.length<48)return!1;const t=h(e);return t.getUint32(0,!0)==a.HEADER&&1179469088==t.getUint32(40,!0)}function i(e,t={}){if(!o(e))return null;const r=h(e),i=r.getUint32(4,!0),g=p(r,8),x=p(r,24),v=r.byteLength>=52?r.getUint32(48,!0):0,A=Math.max(1,g.right-g.left),H=Math.max(1,g.bottom-g.top),j=Math.max(1,x.right-x.left)/100,W=Math.max(1,x.bottom-x.top)/100,V={world:d(s),windowOrg:{x:0,y:0},windowExt:null,viewportOrg:{x:0,y:0},viewportExt:null,pen:{type:"pen",color:"#000000",width:1},brush:{type:"brush",color:"#ffffff",nullBrush:!0},font:null,textColor:"#000000",bkColor:"#ffffff",bkMode:1,polyFillMode:1,textAlign:0,currentPoint:{x:0,y:0}},z=[],J={},Q=[];let ee=Math.max(8,i||108),te=1,re="",ae=!1,ne=0;const se=t.maxRecords??Math.max(1e4,v+100),oe=t.maxShapes??5e4,ie=e=>{!e||ne>=oe||(Q.push(e),ne++)},le=e=>{e&&(re+=(re?" ":"")+e)};for(;ee+8<=r.byteLength&&te++<=se;){const e=r.getUint32(ee,!0),t=r.getUint32(ee+4,!0);if(t<8||ee+t>r.byteLength)break;switch(e){case a.EOF:ee+=t,te=se+1;break;case a.SETWINDOWEXTEX:V.windowExt=f(r,ee+8);break;case a.SETWINDOWORGEX:V.windowOrg=m(r,ee+8);break;case a.SETVIEWPORTEXTEX:V.viewportExt=f(r,ee+8);break;case a.SETVIEWPORTORGEX:V.viewportOrg=m(r,ee+8);break;case a.SCALEWINDOWEXTEX:V.windowExt&&(V.windowExt=T(r,ee,V.windowExt));break;case a.SCALEVIEWPORTEXTEX:V.viewportExt&&(V.viewportExt=T(r,ee,V.viewportExt));break;case a.SETWORLDTRANSFORM:V.world=b(r,ee+8);break;case a.MODIFYWORLDTRANSFORM:{const e=b(r,ee+8),t=r.getUint32(ee+32,!0);1==t?V.world=d(s):2==t?V.world=y(e,V.world):3==t?V.world=y(V.world,e):4==t&&(V.world=e);break}case a.SAVEDC:z.push(l(V));break;case a.RESTOREDC:{const e=r.getInt32(ee+8,!0);if(e<0)for(let t=0;t<Math.min(-e,z.length);t++)Object.assign(V,z.pop());else if(e>0&&e<=z.length){const t=z[e-1];z.length=e-1,Object.assign(V,l(t))}break}case a.SETBKMODE:V.bkMode=r.getUint32(ee+8,!0);break;case a.SETPOLYFILLMODE:V.polyFillMode=r.getUint32(ee+8,!0);break;case a.SETTEXTALIGN:V.textAlign=r.getUint32(ee+8,!0);break;case a.SETTEXTCOLOR:V.textColor=P(r.getUint32(ee+8,!0));break;case a.SETBKCOLOR:V.bkColor=P(r.getUint32(ee+8,!0));break;case a.CREATEPEN:{const e=r.getUint32(ee+8,!0),t=r.getUint32(ee+12,!0),a=Math.abs(r.getInt32(ee+16,!0)),n=P(r.getUint32(ee+24,!0));J[e]={type:"pen",color:n,width:a||1,nullPen:5==(15&t)};break}case a.EXTCREATEPEN:{const e=r.getUint32(ee+8,!0),t=r.getUint32(ee+28,!0),a=Math.abs(r.getInt32(ee+32,!0)),n=r.getUint32(ee+36,!0),s=P(r.getUint32(ee+40,!0));J[e]={type:"pen",color:s,width:a||1,nullPen:5==(15&t)||1==n};break}case a.CREATEBRUSHINDIRECT:{const e=r.getUint32(ee+8,!0),t=r.getUint32(ee+12,!0),a=P(r.getUint32(ee+16,!0));J[e]={type:"brush",color:a,nullBrush:1==t};break}case a.EXTCREATEFONTINDIRECTW:J[r.getUint32(ee+8,!0)]=O(r,ee+12,t-12);break;case a.SELECTOBJECT:{const e=r.getUint32(ee+8,!0),t=2147483648&e?n[2147483647&e]:J[e];"pen"==t?.type?V.pen=c(t):"brush"==t?.type?V.brush=u(t):"font"==t?.type&&(V.font={...t});break}case a.DELETEOBJECT:delete J[r.getUint32(ee+8,!0)];break;case a.BEGINPATH:ae=!0,re="";break;case a.ENDPATH:ae=!1;break;case a.CLOSEFIGURE:le("Z");break;case a.MOVETOEX:{const e=k(V,m(r,ee+8));V.currentPoint=e,ae&&le(`M ${S(e.x)} ${S(e.y)}`);break}case a.LINETO:{const e=k(V,m(r,ee+8));ae?le(`L ${S(e.x)} ${S(e.y)}`):ie(`<path d="M ${S(V.currentPoint.x)} ${S(V.currentPoint.y)} L ${S(e.x)} ${S(e.y)}" ${C(V,!1,!0)}/>`),V.currentPoint=e;break}case a.POLYLINE:case a.POLYGON:M(r,ee,e==a.POLYGON,!1,ae,V,le,ie);break;case a.POLYLINETO:M(r,ee,!1,!0,ae,V,le,ie);break;case a.POLYLINE16:case a.POLYGON16:N(r,ee,e==a.POLYGON16,!1,ae,V,le,ie);break;case a.POLYLINETO16:N(r,ee,!1,!0,ae,V,le,ie);break;case a.POLYBEZIER:D(r,ee,!1,!1,ae,V,le,ie);break;case a.POLYBEZIERTO:D(r,ee,!1,!0,ae,V,le,ie);break;case a.POLYBEZIER16:D(r,ee,!0,!1,ae,V,le,ie);break;case a.POLYBEZIERTO16:D(r,ee,!0,!0,ae,V,le,ie);break;case a.POLYPOLYLINE:case a.POLYPOLYGON:L(r,ee,e==a.POLYPOLYGON,!1,ae,V,le,ie);break;case a.POLYPOLYLINE16:case a.POLYPOLYGON16:L(r,ee,e==a.POLYPOLYGON16,!0,ae,V,le,ie);break;case a.POLYDRAW:$(r,ee,!1,ae,V,le,ie);break;case a.POLYDRAW16:$(r,ee,!0,ae,V,le,ie);break;case a.RECTANGLE:R(r,ee,V,ie,!1);break;case a.ELLIPSE:F(r,ee,V,ie);break;case a.ROUNDRECT:R(r,ee,V,ie,!0);break;case a.ARC:case a.ARCTO:case a.CHORD:case a.PIE:B(r,ee,e,ae,V,le,ie);break;case a.FILLPATH:E(re,V,ie,!0,!1),re="";break;case a.STROKEPATH:E(re,V,ie,!1,!0),re="";break;case a.STROKEANDFILLPATH:E(re,V,ie,!0,!0),re="";break;case a.EXTTEXTOUTA:case a.EXTTEXTOUTW:I(r,ee,t,V,ie,e==a.EXTTEXTOUTW);break;case a.POLYTEXTOUTA:case a.POLYTEXTOUTW:_(r,ee,t,V,ie,e==a.POLYTEXTOUTW);break;case a.SMALLTEXTOUT:U(r,ee,t,V,ie);break;case a.SETPIXELV:X(r,ee,V,ie);break;case a.BITBLT:case a.STRETCHBLT:case a.STRETCHDIBITS:case a.ALPHABLEND:case a.TRANSPARENTBLT:G(r,ee,t,e,V,ie)}ee+=t}if(re&&E(re,V,ie,!0,!0),!Q.length){const t=function(e,t){const r=function(e){const t=function(e){const t=[137,80,78,71,13,10,26,10];for(let r=0;r+t.length+12<=e.length;r++){if(!Y(e,t,r))continue;let a=r+8;for(;a+12<=e.length;){const t=q(e,a),n=String.fromCharCode(e[a+4],e[a+5],e[a+6],e[a+7]);if(a+=12+t,a>e.length)break;if("IEND"==n)return e.subarray(r,a)}}return null}(e);if(t)return`data:image/png;base64,${K(t)}`;const r=function(e){for(let t=0;t+4<e.length;t++)if(255==e[t]&&216==e[t+1]&&255==e[t+2])for(let r=t+4;r+1<e.length;r++)if(255==e[r]&&217==e[r+1])return e.subarray(t,r+2);return null}(e);if(r)return`data:image/jpeg;base64,${K(r)}`;const a=function(e){for(let t=0;t+14<e.length;t++){if(66!=e[t]||77!=e[t+1])continue;const r=Z(e,t+2);if(r>14&&t+r<=e.length)return e.subarray(t,t+r)}return null}(e);return a?`data:image/bmp;base64,${K(a)}`:null}(e);if(!r)return[];const a=Math.max(1,t.right-t.left),n=Math.max(1,t.bottom-t.top);return[`<image x="${S(t.left)}" y="${S(t.top)}" width="${S(a)}" height="${S(n)}" href="${r}" preserveAspectRatio="xMidYMid meet"/>`]}(e,g);t.length&&Q.push(...t)}return Q.length?`<svg xmlns="http://www.w3.org/2000/svg" width="${S(j)}mm" height="${S(W)}mm" viewBox="${S(g.left)} ${S(g.top)} ${S(A)} ${S(H)}" preserveAspectRatio="xMidYMid meet" data-docx-metafile="emf">${Q.join("")}</svg>`:function(e,t,r,a,n){return`<svg xmlns="http://www.w3.org/2000/svg" width="${S(a)}mm" height="${S(n)}mm" viewBox="${S(r.left)} ${S(r.top)} ${S(e)} ${S(t)}" preserveAspectRatio="xMidYMid meet" data-docx-metafile="emf"><rect x="${S(r.left)}" y="${S(r.top)}" width="${S(e)}" height="${S(t)}" fill="none" stroke="#999" stroke-width="1"/><text x="${S(r.left+e/2)}" y="${S(r.top+t/2)}" text-anchor="middle" font-size="12" fill="#666">${w("Unsupported EMF image")}</text></svg>`}(A,H,g,j,W)}function l(e){return{world:d(e.world),windowOrg:{...e.windowOrg},windowExt:e.windowExt?{...e.windowExt}:null,viewportOrg:{...e.viewportOrg},viewportExt:e.viewportExt?{...e.viewportExt}:null,pen:c(e.pen),brush:u(e.brush),font:e.font?{...e.font}:null,textColor:e.textColor,bkColor:e.bkColor,bkMode:e.bkMode,polyFillMode:e.polyFillMode,textAlign:e.textAlign,currentPoint:{...e.currentPoint}}}function c(e){return{...e}}function u(e){return{...e}}function d(e){return{...e}}function h(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function p(e,t){return{left:e.getInt32(t,!0),top:e.getInt32(t+4,!0),right:e.getInt32(t+8,!0),bottom:e.getInt32(t+12,!0)}}function m(e,t){return{x:e.getInt32(t,!0),y:e.getInt32(t+4,!0)}}function f(e,t){return m(e,t)}function g(e,t){return{x:e.getInt16(t,!0),y:e.getInt16(t+2,!0)}}function b(e,t){return{m11:e.getFloat32(t,!0),m12:e.getFloat32(t+4,!0),m21:e.getFloat32(t+8,!0),m22:e.getFloat32(t+12,!0),dx:e.getFloat32(t+16,!0),dy:e.getFloat32(t+20,!0)}}function y(e,t){return{m11:e.m11*t.m11+e.m12*t.m21,m12:e.m11*t.m12+e.m12*t.m22,m21:e.m21*t.m11+e.m22*t.m21,m22:e.m21*t.m12+e.m22*t.m22,dx:e.dx*t.m11+e.dy*t.m21+t.dx,dy:e.dx*t.m12+e.dy*t.m22+t.dy}}function k(e,t){const r=e.world;let a=t.x*r.m11+t.y*r.m21+r.dx,n=t.x*r.m12+t.y*r.m22+r.dy;return e.windowExt&&e.viewportExt&&e.windowExt.x&&e.windowExt.y&&(a=(a-e.windowOrg.x)*e.viewportExt.x/e.windowExt.x+e.viewportOrg.x,n=(n-e.windowOrg.y)*e.viewportExt.y/e.windowExt.y+e.viewportOrg.y),{x:a,y:n}}function x(e){let t=Math.hypot(e.world.m11,e.world.m12),r=Math.hypot(e.world.m21,e.world.m22);e.windowExt&&e.viewportExt&&e.windowExt.x&&e.windowExt.y&&(t*=Math.abs(e.viewportExt.x/e.windowExt.x),r*=Math.abs(e.viewportExt.y/e.windowExt.y));const a=(t+r)/2;return Number.isFinite(a)&&a>0?a:1}function T(e,t,r){const a=e.getInt32(t+8,!0),n=e.getInt32(t+12,!0),s=e.getInt32(t+16,!0),o=e.getInt32(t+20,!0);return{x:n?r.x*a/n:r.x,y:o?r.y*s/o:r.y}}function P(e){const t=e>>8&255,r=e>>16&255;return`#${v(255&e)}${v(t)}${v(r)}`}function v(e){return Math.max(0,Math.min(255,0|e)).toString(16).padStart(2,"0")}function S(e){return Number.isFinite(e)?""+Math.round(1e3*e)/1e3:"0"}function w(e){return`${e??""}`.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function C(e,t,r){const a=[];if(t&&!e.brush.nullBrush?(a.push(`fill="${e.brush.color}"`),a.push(`fill-rule="${2==e.polyFillMode?"nonzero":"evenodd"}"`)):a.push('fill="none"'),r&&!e.pen.nullPen){const t=x(e),r=0==e.pen.width?1:Math.max(.35,e.pen.width*t);a.push(`stroke="${e.pen.color}"`),a.push(`stroke-width="${S(r)}"`),a.push('stroke-linecap="square"'),a.push('stroke-linejoin="miter"')}else a.push('stroke="none"');return a.join(" ")}function E(e,t,r,a,n){e&&r(`<path d="${e}" ${C(t,a,n)}/>`)}function N(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0);if(!l||t+28+4*l>e.byteLength)return;const c=[];for(let r=0;r<l;r++)c.push(k(s,g(e,t+28+4*r)));A(c,r,a,n,s,o,i)}function M(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0);if(!l||t+28+8*l>e.byteLength)return;const c=[];for(let r=0;r<l;r++)c.push(k(s,m(e,t+28+8*r)));A(c,r,a,n,s,o,i)}function A(e,t,r,a,n,s,o){if(!e.length)return;let i=a&&r?"":r?`M ${S(n.currentPoint.x)} ${S(n.currentPoint.y)}`:`M ${S(e[0].x)} ${S(e[0].y)}`;for(let t=r?0:1;t<e.length;t++)i+=` L ${S(e[t].x)} ${S(e[t].y)}`;t&&(i+=" Z"),n.currentPoint=e[e.length-1],a?s(i.trim()):o(`<path d="${i.trim()}" ${C(n,t,!0)}/>`)}function D(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0),c=r?4:8;if(!l||t+28+l*c>e.byteLength)return;const u=[];for(let a=0;a<l;a++){const n=r?g(e,t+28+a*c):m(e,t+28+a*c);u.push(k(s,n))}let d=n&&a?"":a?`M ${S(s.currentPoint.x)} ${S(s.currentPoint.y)}`:`M ${S(u[0].x)} ${S(u[0].y)}`,h=a?s.currentPoint:u[0];for(let e=a?0:1;e+2<u.length;e+=3){const t=u[e],r=u[e+1],a=u[e+2];d+=` C ${S(t.x)} ${S(t.y)} ${S(r.x)} ${S(r.y)} ${S(a.x)} ${S(a.y)}`,h=a}s.currentPoint=h,n?o(d.trim()):i(`<path d="${d.trim()}" ${C(s,!1,!0)}/>`)}function L(e,t,r,a,n,s,o,i){const l=e.getUint32(t+24,!0),c=e.getUint32(t+28,!0),u=t+32,d=u+4*l,h=a?4:8;if(!l||!c||d+c*h>e.byteLength)return;let p=0;for(let t=0;t<l;t++){const l=e.getUint32(u+4*t,!0);if(!l||p+l>c)break;const f=[];for(let t=0;t<l;t++){const r=d+(p+t)*h,n=a?g(e,r):m(e,r);f.push(k(s,n))}A(f,r,!1,n,s,o,i),p+=l}}function $(e,t,r,a,n,s,o){const i=e.getUint32(t+24,!0),l=r?4:8,c=t+28,u=c+i*l;if(!i||u+i>e.byteLength)return;const d=[];for(let t=0;t<i;t++){const a=c+t*l,s=r?g(e,a):m(e,a);d.push(k(n,s))}let h="",p=0;for(;p<i;){const t=e.getUint8(u+p),r=6&t;6==r?(h+=` M ${S(d[p].x)} ${S(d[p].y)}`,n.currentPoint=d[p],p++):2==r?(h+=` L ${S(d[p].x)} ${S(d[p].y)}`,n.currentPoint=d[p],p++):4==r&&p+2<i?(h+=` C ${S(d[p].x)} ${S(d[p].y)} ${S(d[p+1].x)} ${S(d[p+1].y)} ${S(d[p+2].x)} ${S(d[p+2].y)}`,n.currentPoint=d[p+2],p+=3):p++,1&t&&(h+=" Z")}h=h.trim(),h&&(a?s(h):o(`<path d="${h}" ${C(n,!1,!0)}/>`))}function R(e,t,r,a,n){const s=p(e,t+8),o=k(r,{x:s.left,y:s.top}),i=k(r,{x:s.right,y:s.bottom}),l=Math.min(o.x,i.x),c=Math.min(o.y,i.y),u=Math.abs(i.x-o.x),d=Math.abs(i.y-o.y),h=n?` rx="${S(Math.min(u,d)/8)}" ry="${S(Math.min(u,d)/8)}"`:"";a(`<rect x="${S(l)}" y="${S(c)}" width="${S(u)}" height="${S(d)}"${h} ${C(r,!0,!0)}/>`)}function F(e,t,r,a){const n=p(e,t+8),s=k(r,{x:n.left,y:n.top}),o=k(r,{x:n.right,y:n.bottom}),i=(s.x+o.x)/2,l=(s.y+o.y)/2,c=Math.abs(o.x-s.x)/2,u=Math.abs(o.y-s.y)/2;a(`<ellipse cx="${S(i)}" cy="${S(l)}" rx="${S(c)}" ry="${S(u)}" ${C(r,!0,!0)}/>`)}function B(e,t,r,n,s,o,i){const l=p(e,t+8),c=m(e,t+24),u=m(e,t+32),d=(l.left+l.right)/2,h=(l.top+l.bottom)/2,f=Math.abs(l.right-l.left)/2,g=Math.abs(l.bottom-l.top)/2;if(!f||!g)return;const b=Math.atan2(c.y-h,c.x-d);let y=Math.atan2(u.y-h,u.x-d),x=y-b;x<=0&&(x+=2*Math.PI);const T=x>Math.PI?1:0,P=k(s,{x:d+Math.cos(b)*f,y:h+Math.sin(b)*g}),v=k(s,{x:d+Math.cos(y)*f,y:h+Math.sin(y)*g}),w=k(s,{x:d,y:h}),E=k(s,{x:d+f,y:h}),N=k(s,{x:d,y:h+g}),M=Math.max(.01,Math.abs(E.x-w.x)||Math.abs(N.x-w.x)),A=Math.max(.01,Math.abs(N.y-w.y)||Math.abs(E.y-w.y)),D=`A ${S(M)} ${S(A)} 0 ${T} 1 ${S(v.x)} ${S(v.y)}`;let L=`M ${S(P.x)} ${S(P.y)} ${D}`,$=!1;r==a.CHORD?(L+=" Z",$=!0):r==a.PIE&&(L+=` L ${S(w.x)} ${S(w.y)} Z`,$=!0),r==a.ARCTO&&(s.currentPoint=v),n?o(L):i(`<path d="${L}" ${C(s,$,!0)}/>`)}function O(e,t,r){const a=r>=4?e.getInt32(t,!0):12,n=r>=20?e.getInt32(t+16,!0):400,s=r>=21&&0!=e.getUint8(t+20),o=r>=22&&0!=e.getUint8(t+21);let i="";const l=t+28,c=Math.max(0,Math.min(64,r-28));for(let t=0;t+1<c;t+=2){const r=e.getUint16(l+t,!0);if(!r)break;i+=String.fromCharCode(r)}return{type:"font",family:i,size:Math.abs(a)||12,weight:n,italic:s,underline:o}}function I(e,t,r,a,n,s){if(r<76)return;const o=k(a,m(e,t+36)),i=e.getUint32(t+44,!0),l=e.getUint32(t+48,!0);!i||l<=0||l+i*(s?2:1)>r||z(s?H(e,t+l,i):j(new Uint8Array(e.buffer,e.byteOffset+t+l,i)),o,a,n)}function _(e,t,r,a,n,s){if(r<40)return;const o=e.getUint32(t+36,!0);let i=t+40;for(let l=0;l<o&&i+40<=t+r;l++,i+=40){const o=k(a,m(e,i)),l=e.getUint32(i+8,!0),c=e.getUint32(i+12,!0);!l||!c||c+l*(s?2:1)>r||z(s?H(e,t+c,l):j(new Uint8Array(e.buffer,e.byteOffset+t+c,l)),o,a,n)}}function U(e,t,r,a,n){if(r<36)return;const s=k(a,m(e,t+8)),o=e.getUint32(t+16,!0),i=512&e.getUint32(t+20,!0)?40:28;!o||i+o>r||z(j(new Uint8Array(e.buffer,e.byteOffset+t+i,o)),s,a,n)}function H(e,t,r){let a="";for(let n=0;n<r;n++){const r=e.getUint16(t+2*n,!0);r&&(a+=String.fromCharCode(r))}return a}function j(e){if(!e.length)return"";const t=globalThis.TextDecoder;if(t)try{return new t("gb18030").decode(e).replace(/\0+$/g,"")}catch{try{return new t("windows-1252").decode(e).replace(/\0+$/g,"")}catch{}}let r="";for(const t of e)t&&(r+=String.fromCharCode(t));return r}function W(e){const t=6&e.textAlign;return 6==t?'text-anchor="middle"':2==t?'text-anchor="end"':""}function V(e){const t=24&e.textAlign;return 0==t?'dominant-baseline="text-before-edge"':8==t?'dominant-baseline="text-after-edge"':""}function z(e,t,r,a){e&&a(`<text ${function(e,t){const r=e.font,a=Math.max(1,(r?.size??12)*x(e));return[`x="${S(t.x)}"`,`y="${S(t.y)}"`,`fill="${e.textColor}"`,`font-size="${S(a)}"`,r?.family?`font-family="${w(r.family)}"`:"",r?.weight?`font-weight="${r.weight>=600?"bold":"normal"}"`:"",r?.italic?'font-style="italic"':"",r?.underline?'text-decoration="underline"':"",W(e),V(e)].filter(Boolean).join(" ")}(r,t)}>${w(e)}</text>`)}function X(e,t,r,a){if(t+20>e.byteLength)return;const n=k(r,m(e,t+8)),s=P(e.getUint32(t+16,!0));a(`<rect x="${S(n.x)}" y="${S(n.y)}" width="1" height="1" fill="${s}" stroke="none"/>`)}function G(e,t,r,n,s,o){let i=0,l=0,c=0,u=0,d=0,h=0,p=0,m=0;if(n==a.STRETCHDIBITS){if(r<80)return;i=e.getInt32(t+24,!0),l=e.getInt32(t+28,!0),d=e.getUint32(t+48,!0),h=e.getUint32(t+52,!0),p=e.getUint32(t+56,!0),m=e.getUint32(t+60,!0),c=e.getInt32(t+72,!0),u=e.getInt32(t+76,!0)}else{if(r<100)return;i=e.getInt32(t+24,!0),l=e.getInt32(t+28,!0),c=e.getInt32(t+32,!0),u=e.getInt32(t+36,!0),d=e.getUint32(t+84,!0),h=e.getUint32(t+88,!0),p=e.getUint32(t+92,!0),m=e.getUint32(t+96,!0)}if(!d||!h||!p||!m||d+h>r||p+m>r)return;const f=function(e,t,r,a,n,s){const o=t+r,i=t+n;if(a<4||o+a>e.byteLength||i+s>e.byteLength)return null;const l=e.getUint32(o,!0)>=40&&a>=20?e.getUint32(o+16,!0):0,c=new Uint8Array(e.buffer,e.byteOffset+i,s);if(4==l)return`data:image/jpeg;base64,${K(c)}`;if(5==l)return`data:image/png;base64,${K(c)}`;const u=new Uint8Array(a+s);return u.set(new Uint8Array(e.buffer,e.byteOffset+o,a),0),u.set(c,a),function(e,t){if(!e?.length||t<=0||t>e.length)return null;const r=14+e.length,a=14+t,n=new Uint8Array(r);return n[0]=66,n[1]=77,J(n,2,r),J(n,10,a),n.set(e,14),`data:image/bmp;base64,${K(n)}`}(u,a)}(e,t,d,h,p,m);if(!f)return;const g=k(s,{x:i,y:l}),b=k(s,{x:i+c,y:l+u}),y=Math.min(g.x,b.x),x=Math.min(g.y,b.y),T=Math.abs(b.x-g.x),P=Math.abs(b.y-g.y);o(`<image x="${S(y)}" y="${S(x)}" width="${S(T)}" height="${S(P)}" href="${f}" preserveAspectRatio="none"/>`)}function Y(e,t,r){for(let a=0;a<t.length;a++)if(e[r+a]!=t[a])return!1;return!0}function q(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Z(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function J(e,t,r){e[t]=255&r,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255}function K(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));if("function"==typeof btoa)return btoa(t);const r=globalThis.Buffer;return r?r.from(e).toString("base64"):t}},"./notes/elements":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WmlEndnote=r.WmlFootnote=r.WmlBaseNote=void 0;const a=e("../document/dom");class n{}r.WmlBaseNote=n,r.WmlFootnote=class extends n{constructor(){super(...arguments),this.type=a.DomType.Footnote}},r.WmlEndnote=class extends n{constructor(){super(...arguments),this.type=a.DomType.Endnote}}},"./notes/parts":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.EndnotesPart=r.FootnotesPart=r.BaseNotePart=void 0;const a=e("../common/part"),n=e("./elements");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}}r.BaseNotePart=s,r.FootnotesPart=class extends s{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"footnote",n.WmlFootnote)}},r.EndnotesPart=class extends s{constructor(e,t,r){super(e,t,r)}parseXml(e){this.notes=this._documentParser.parseNotes(e,"endnote",n.WmlEndnote)}}},"./numbering/numbering-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.NumberingPart=void 0;const a=e("../common/part"),n=e("./numbering");class s extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){Object.assign(this,(0,n.parseNumberingPart)(e,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(e)}}r.NumberingPart=s},"./numbering/numbering":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseNumberingPart=function(e,t){let r={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let a of t.elements(e))switch(a.localName){case"num":r.numberings.push(s(a,t));break;case"abstractNum":r.abstractNumberings.push(o(a,t));break;case"numPicBullet":r.bulletPictures.push(c(a,t))}return r},r.parseNumbering=s,r.parseAbstractNumbering=o,r.parseNumberingLevel=i,r.parseNumberingLevelOverrride=l,r.parseNumberingBulletPicture=c;const a=e("../document/paragraph"),n=e("../document/run");function s(e,t){let r={id:t.attr(e,"numId"),overrides:[]};for(let a of t.elements(e))switch(a.localName){case"abstractNumId":r.abstractId=t.attr(a,"val");break;case"lvlOverride":r.overrides.push(l(a,t))}return r}function o(e,t){let r={id:t.attr(e,"abstractNumId"),levels:[]};for(let a of t.elements(e))switch(a.localName){case"name":r.name=t.attr(a,"val");break;case"multiLevelType":r.multiLevelType=t.attr(a,"val");break;case"numStyleLink":r.numberingStyleLink=t.attr(a,"val");break;case"styleLink":r.styleLink=t.attr(a,"val");break;case"lvl":r.levels.push(i(a,t))}return r}function i(e,t){let r={level:t.intAttr(e,"ilvl")};for(let s of t.elements(e))switch(s.localName){case"start":r.start=t.attr(s,"val");break;case"lvlRestart":r.restart=t.intAttr(s,"val");break;case"numFmt":r.format=t.attr(s,"val");break;case"lvlText":r.text=t.attr(s,"val");break;case"lvlJc":r.justification=t.attr(s,"val");break;case"lvlPicBulletId":r.bulletPictureId=t.attr(s,"val");break;case"pStyle":r.paragraphStyle=t.attr(s,"val");break;case"pPr":r.paragraphProps=(0,a.parseParagraphProperties)(s,t);break;case"rPr":r.runProps=(0,n.parseRunProperties)(s,t)}return r}function l(e,t){let r={level:t.intAttr(e,"ilvl")};for(let a of t.elements(e))switch(a.localName){case"startOverride":r.start=t.intAttr(a,"val");break;case"lvl":r.numberingLevel=i(a,t)}return r}function c(e,t){var r=t.attr(e,"numPicBulletId"),a=t.element(e,"pict"),n=a&&t.element(a,"shape"),s=n&&t.element(n,"imagedata");if(s)return{id:r,referenceId:t.attr(s,"id"),style:t.attr(n,"style")};var o=t.element(e,"drawing"),i=o&&u(o,"blip",t);return i?{id:r,referenceId:t.attr(i,"embed")??t.attr(i,"link"),style:null}:null}function u(e,t,r){for(const a of r.elements(e)){if(a.localName==t)return a;const e=u(a,t,r);if(e)return e}return null}},"./parser/xml-parser":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.XmlParser=void 0,r.parseXmlString=function(e,t=!1){var r;t&&(e=e.replace(/<[?].*[?]>/,"")),e=65279===(r=e).charCodeAt(0)?r.substring(1):r;const a=(new DOMParser).parseFromString(e,"application/xml"),n=(s=a,s.getElementsByTagName("parsererror")[0]?.textContent);var s;if(n)throw new Error(n);return a},r.serializeXmlString=function(e){return(new XMLSerializer).serializeToString(e)};const a=e("../document/common");class n{elements(e,t=null){const r=[];for(let a=0,n=e.childNodes.length;a<n;a++){let n=e.childNodes.item(a);1!=n.nodeType||null!=t&&n.localName!=t||r.push(n)}return r}element(e,t){for(let r=0,a=e.childNodes.length;r<a;r++){let a=e.childNodes.item(r);if(1==a.nodeType&&a.localName==t)return a}return null}elementAttr(e,t,r){var a=this.element(e,t);return a?this.attr(a,r):void 0}attrs(e){return Array.from(e.attributes)}attr(e,t){for(let r=0,a=e.attributes.length;r<a;r++){let a=e.attributes.item(r);if(a.localName==t)return a.value}return null}intAttr(e,t,r=null){var a=this.attr(e,t);return null!=a&&""!==a?parseInt(a,10):r}hexAttr(e,t,r=null){var a=this.attr(e,t);return null!=a&&""!==a?parseInt(a,16):r}floatAttr(e,t,r=null){var a=this.attr(e,t);return null!=a&&""!==a?parseFloat(a):r}boolAttr(e,t,r=null){return(0,a.convertBoolean)(this.attr(e,t),r)}lengthAttr(e,t,r=a.LengthUsage.Dxa){return(0,a.convertLength)(this.attr(e,t),r)}}r.XmlParser=n;const s=new n;r.default=s},"./settings/settings-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SettingsPart=void 0;const a=e("../common/part"),n=e("./settings");class s extends a.Part{constructor(e,t){super(e,t)}parseXml(e){this.settings=(0,n.parseSettings)(e,this._package.xmlParser)}}r.SettingsPart=s},"./settings/settings":function(e,t,r){"use strict";function a(e,t){var r={defaultNoteIds:[]};for(let a of t.elements(e))switch(a.localName){case"numFmt":r.nummeringFormat=t.attr(a,"val");break;case"footnote":case"endnote":r.defaultNoteIds.push(t.attr(a,"id"))}return r}Object.defineProperty(r,"__esModule",{value:!0}),r.parseSettings=function(e,t){var r={};for(let n of t.elements(e))switch(n.localName){case"defaultTabStop":r.defaultTabStop=t.lengthAttr(n,"val");break;case"footnotePr":r.footnoteProps=a(n,t);break;case"endnotePr":r.endnoteProps=a(n,t);break;case"autoHyphenation":r.autoHyphenation=t.boolAttr(n,"val");break;case"kinsoku":r.kinsoku=t.boolAttr(n,"val",!0);break;case"overflowPunct":r.overflowPunctuation=t.boolAttr(n,"val",!0);break;case"topLinePunct":r.topLinePunctuation=t.boolAttr(n,"val",!0);break;case"autoSpaceDE":r.autoSpaceDE=t.boolAttr(n,"val",!0);break;case"autoSpaceDN":r.autoSpaceDN=t.boolAttr(n,"val",!0);break;case"noLineBreaksAfter":r.noLineBreaksAfter=t.attr(n,"val")||n.textContent||"";break;case"noLineBreaksBefore":r.noLineBreaksBefore=t.attr(n,"val")||n.textContent||"";break;case"evenAndOddHeaders":r.evenAndOddHeaders=t.boolAttr(n,"val",!0);break;case"splitPgBreakAndParaMark":r.splitPageBreakAndParagraphMark=t.boolAttr(n,"val",!0);break;case"compat":for(const e of t.elements(n))"adjustLineHeightInTable"==e.localName&&(r.adjustLineHeightInTable=t.boolAttr(e,"val",!0))}return r},r.parseNoteProperties=a},"./styles/styles-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.StylesPart=void 0;const a=e("../common/part");class n extends a.Part{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.styles=this._documentParser.parseStylesFile(e)}}r.StylesPart=n},"./theme/theme-part":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ThemePart=void 0;const a=e("../common/part"),n=e("./theme");class s extends a.Part{constructor(e,t){super(e,t)}parseXml(e){this.theme=(0,n.parseTheme)(e,this._package.xmlParser)}}r.ThemePart=s},"./theme/theme":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DmlTheme=void 0,r.parseTheme=function(e,t){var r=new a,o=t.element(e,"themeElements");for(let e of t.elements(o))switch(e.localName){case"clrScheme":r.colorScheme=n(e,t);break;case"fontScheme":r.fontScheme=s(e,t)}return r},r.parseColorScheme=n,r.parseFontScheme=s,r.parseFontInfo=o;class a{}function n(e,t){var r={name:t.attr(e,"name"),colors:{}};for(let s of t.elements(e)){var a=t.element(s,"srgbClr"),n=t.element(s,"sysClr");a?r.colors[s.localName]=t.attr(a,"val"):n&&(r.colors[s.localName]=t.attr(n,"lastClr"))}return r}function s(e,t){var r={name:t.attr(e,"name")};for(let a of t.elements(e))switch(a.localName){case"majorFont":r.majorFont=o(a,t);break;case"minorFont":r.minorFont=o(a,t)}return r}function o(e,t){return{latinTypeface:t.elementAttr(e,"latin","typeface"),eaTypeface:t.elementAttr(e,"ea","typeface"),csTypeface:t.elementAttr(e,"cs","typeface")}}r.DmlTheme=a},"./utils":function(e,t,r){"use strict";function a(e){return e&&"object"==typeof e&&!Array.isArray(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.escapeClassName=function(e){return e?.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()},r.encloseFontFamily=function(e){return/^[^"'].*\s.*[^"']$/.test(e)?`'${e}'`:e},r.splitPath=function(e){let t=e.lastIndexOf("/")+1;return[0==t?"":e.substring(0,t),0==t?e:e.substring(t)]},r.resolvePath=function(e,t){try{const r="http://docx/";return new URL(e,r+t).toString().substring(r.length)}catch{return`${t}${e}`}},r.keyBy=function(e,t){return e.reduce((e,r)=>(e[t(r)]=r,e),{})},r.blobToBase64=function(e){return new Promise((t,r)=>{const a=new FileReader;a.onloadend=()=>t(a.result),a.onerror=()=>r(),a.readAsDataURL(e)})},r.isObject=a,r.isString=function(e){return"string"==typeof e||e instanceof String},r.mergeDeep=function e(t,...r){if(!r.length)return t;const n=r.shift();if(a(t)&&a(n))for(const r in n)if(a(n[r])){e(t[r]??(t[r]={}),n[r])}else t[r]=n[r];return e(t,...r)},r.parseCssRules=function(e){const t={};for(const r of(e??"").split(";")){const e=r.indexOf(":");if(e<=0)continue;const a=r.substring(0,e).trim(),n=r.substring(e+1).trim();a&&(t[a]=n)}return t},r.formatCssRules=function(e){return Object.entries(e??{}).map(([e,t])=>`${e}: ${t}`).join(";")},r.asArray=function(e){return Array.isArray(e)?e:[e]},r.clamp=function(e,t,r){return t>e?t:r<e?r:e}},"./vml/vml":function(e,t,r){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.VmlElement=void 0,r.parseVmlElement=function e(t,r){var a=new i;switch(t.localName){case"rect":a.tagName="rect",Object.assign(a.attrs,{width:"100%",height:"100%"});break;case"oval":a.tagName="ellipse",Object.assign(a.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":a.tagName="line";break;case"shape":a.tagName="g";break;case"textbox":a.tagName="foreignObject",Object.assign(a.attrs,{width:"100%",height:"100%"});break;default:return null}for(const e of o.default.attrs(t))switch(e.localName){case"style":a.cssStyleText=e.value;break;case"fillcolor":a.attrs.fill=e.value;break;case"strokecolor":a.attrs.stroke=e.value;break;case"strokeweight":a.attrs["stroke-width"]=(0,n.convertLength)(e.value,n.LengthUsage.Point)??e.value;break;case"filled":"f"!=e.value&&"false"!=e.value||(a.attrs.fill="none");break;case"stroked":"f"!=e.value&&"false"!=e.value||(a.attrs.stroke="none");break;case"path":a.tagName="path",a.attrs.d=m(e.value);break;case"from":const[t,r]=p(e.value);Object.assign(a.attrs,{x1:t,y1:r});break;case"to":const[s,o]=p(e.value);Object.assign(a.attrs,{x2:s,y2:o})}for(const n of o.default.elements(t))switch(n.localName){case"stroke":Object.assign(a.attrs,d(n));break;case"fill":Object.assign(a.attrs,h(n));break;case"imagedata":a.tagName="image",Object.assign(a.attrs,l(n)),a.imageHref={id:o.default.attr(n,"id")??o.default.attr(n,"relid")??o.default.attr(n,"pict"),title:o.default.attr(n,"title")};break;case"txbxContent":a.children.push(...r.parseBodyElements(n));break;default:const t=e(n,r);t&&a.children.push(t)}return a};const n=e("../document/common"),s=e("../document/dom"),o=a(e("../parser/xml-parser"));class i extends s.OpenXmlElementBase{constructor(){super(...arguments),this.type=s.DomType.VmlElement,this.attrs={}}}function l(e){const t=c(o.default.attr(e,"cropleft")),r=c(o.default.attr(e,"croptop")),a=c(o.default.attr(e,"cropright")),n=c(o.default.attr(e,"cropbottom")),s=Math.max(1e-4,1-t-a),i=Math.max(1e-4,1-r-n),l={x:u(-t/s),y:u(-r/i),width:u(1/s),height:u(1/i)};return(t||r||a||n)&&(l.preserveAspectRatio="none"),l}function c(e){if(!e)return 0;const t=String(e).trim();if(!t)return 0;let r;return r=/^-?\d+(\.\d+)?f$/i.test(t)?parseFloat(t.slice(0,-1))/65536:t.endsWith("%")?parseFloat(t)/100:parseFloat(t),Number.isFinite(r)?Math.max(0,Math.min(.9999,r)):0}function u(e){return Math.round(1e5*e)/1e3+"%"}function d(e){const t={},r=o.default.attr(e,"color"),a=o.default.attr(e,"weight"),s=o.default.attr(e,"on");return"f"==s||"false"==s?t.stroke="none":r&&(t.stroke=r),t["stroke-width"]=a?(0,n.convertLength)(a,n.LengthUsage.Point)??a:"1px",t}function h(e){const t={},r=o.default.attr(e,"color")??o.default.attr(e,"color2"),a=o.default.attr(e,"on"),n=o.default.attr(e,"opacity");return"f"==a||"false"==a?t.fill="none":r&&(t.fill=r),n&&(t["fill-opacity"]=n.endsWith("%")?""+parseFloat(n)/100:n),t}function p(e){return e.split(",")}function m(e){return e.replace(/([mlxe])|([-\d]+)|([,])/g,e=>/[-\d]/.test(e)?(0,n.convertLength)(e,n.LengthUsage.VmlEmu):/[ml,]/.test(e)?e:"")}r.VmlElement=i},"./word-document":function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WordDocument=void 0,r.deobfuscate=S;const a=e("./common/relationship"),n=e("./font-table/font-table"),s=e("./common/open-xml-package"),o=e("./document/document-part"),i=e("./utils"),l=e("./numbering/numbering-part"),c=e("./styles/styles-part"),u=e("./header-footer/parts"),d=e("./document-props/extended-props-part"),h=e("./document-props/core-props-part"),p=e("./theme/theme-part"),m=e("./notes/parts"),f=e("./settings/settings-part"),g=e("./document-props/custom-props-part"),b=e("./comments/comments-part"),y=e("./comments/comments-extended-part"),k=e("./parser/xml-parser"),x=e("./metafile/emf-to-svg"),T=[{type:a.RelationshipTypes.OfficeDocument,target:"word/document.xml"},{type:a.RelationshipTypes.ExtendedProperties,target:"docProps/app.xml"},{type:a.RelationshipTypes.CoreProperties,target:"docProps/core.xml"},{type:a.RelationshipTypes.CustomProperties,target:"docProps/custom.xml"}];class P{constructor(){this.parts=[],this.partsMap={},this.contentTypes=[],this._snapshotAssetDataUrls=null,this._snapshotTextParts=null}static fromSnapshot(e,t){const r=new P;r._options=t,r.rels=e.rels??[],r.contentTypes=e.contentTypes??[],r.parts=[],r.partsMap={},r._snapshotAssetDataUrls=e.assetDataUrls??{},r._snapshotTextParts=e.textParts??{},r._package={load:e=>Promise.resolve(r._snapshotTextParts?.[v(e)]??null),parseXmlDocument:e=>(0,k.parseXmlString)(e,t?.trimXmlDeclaration??!0),get:e=>null!=r._snapshotTextParts?.[v(e)]?{}:null};for(const t of e.parts??[]){const e=r.restoreSnapshotPart(t);e&&(r.parts.push(e),r.partsMap[e.path]=e)}return r}static async load(e,t,r){var a=new P;return a._options=r,a._parser=t,a._package=await s.OpenXmlPackage.load(e,r),a.rels=await a._package.loadRelationships(),a.contentTypes=await a._package.loadContentTypes(),await Promise.all(T.map(e=>{const t=a.rels.find(t=>t.type===e.type)??e;return a.loadRelationshipPart(t.target,t.type)})),a}restoreSnapshotPart(e){const t={path:e.path,rels:e.rels??[]};switch(Object.assign(t,e.data??{}),e.kind){case"document":this.documentPart=t;break;case"fontTable":this.fontTablePart=t;break;case"numbering":this.numberingPart=t;break;case"styles":this.stylesPart=t;break;case"theme":this.themePart=t;break;case"footnotes":this.footnotesPart=t;break;case"endnotes":this.endnotesPart=t;break;case"coreProps":this.corePropsPart=t;break;case"extendedProps":this.extendedPropsPart=t;break;case"settings":this.settingsPart=t;break;case"comments":t.commentMap=(0,i.keyBy)(t.comments??[],e=>e.id),this.commentsPart=t;break;case"commentsExtended":t.commentMap=(0,i.keyBy)(t.comments??[],e=>e.paraId),this.commentsExtendedPart=t}return t}async createSnapshot(){const e={rels:this.rels??[],contentTypes:this.contentTypes??[],parts:this.parts.map(e=>this.snapshotPart(e)).filter(Boolean),assetDataUrls:{},textParts:{}};return await this.preloadSnapshotRelationshipTargets(e),e}snapshotPart(e){const t=e;let r="part",a={};if(e===this.documentPart)r="document",a={body:t.body};else if(e===this.fontTablePart)r="fontTable",a={fonts:t.fonts};else if(e===this.numberingPart)r="numbering",a={numberings:t.numberings,abstractNumberings:t.abstractNumberings,bulletPictures:t.bulletPictures,domNumberings:t.domNumberings};else if(e===this.stylesPart)r="styles",a={styles:t.styles};else if(e===this.themePart)r="theme",a={theme:t.theme};else if(e===this.footnotesPart)r="footnotes",a={notes:t.notes};else if(e===this.endnotesPart)r="endnotes",a={notes:t.notes};else if(e===this.corePropsPart)r="coreProps",a={props:t.props};else if(e===this.extendedPropsPart)r="extendedProps",a={props:t.props};else if(e===this.settingsPart)r="settings",a={settings:t.settings};else if(e===this.commentsPart)r="comments",a={comments:t.comments};else if(e===this.commentsExtendedPart)r="commentsExtended",a={comments:t.comments};else{if(!t.rootElement)return null;r="header"===t.rootElement.type?"header":"footer",a={rootElement:t.rootElement}}return{kind:r,path:e.path,rels:e.rels??[],data:a}}async preloadSnapshotRelationshipTargets(e){const t=new Set,r=e=>{for(const r of e?.rels??[]){if(!r||"External"===r.targetMode)continue;const a=v(this.resolveRelationshipTarget(e,r));a&&!t.has(a)&&t.add(a)}};for(const e of this.parts)r(e);for(const r of t){if(this.partsMap[r])continue;const t=r.toLowerCase(),a=/\.(xml|rels|html?|txt)$/i.test(t);try{if(a){const t=await this._package.load(r,"string");null!=t&&(e.textParts[r]=t)}else{const t=await this.loadPackageAssetDataUrl(r);t&&(e.assetDataUrls[r]=t)}}catch(e){this._options?.debug&&console.warn(`docx-preview: unable to preload relationship target ${r}`,e)}}}blobWithContentType(e,t){if(!e)return null;if(t){const r=this.contentTypes.find(e=>e.partName===t||e.extension&&t.endsWith(`.${e.extension}`));return r?new Blob([e],{type:r.contentType}):e}return e}save(e="blob"){return this._package.save(e)}async loadRelationshipPart(e,t){if(this.partsMap[e])return this.partsMap[e];if(!this._package.get(e))return null;let r=null;switch(t){case a.RelationshipTypes.OfficeDocument:this.documentPart=r=new o.DocumentPart(this._package,e,this._parser);break;case a.RelationshipTypes.FontTable:this.fontTablePart=r=new n.FontTablePart(this._package,e);break;case a.RelationshipTypes.Numbering:this.numberingPart=r=new l.NumberingPart(this._package,e,this._parser);break;case a.RelationshipTypes.Styles:this.stylesPart=r=new c.StylesPart(this._package,e,this._parser);break;case a.RelationshipTypes.Theme:this.themePart=r=new p.ThemePart(this._package,e);break;case a.RelationshipTypes.Footnotes:this.footnotesPart=r=new m.FootnotesPart(this._package,e,this._parser);break;case a.RelationshipTypes.Endnotes:this.endnotesPart=r=new m.EndnotesPart(this._package,e,this._parser);break;case a.RelationshipTypes.Footer:r=new u.FooterPart(this._package,e,this._parser);break;case a.RelationshipTypes.Header:r=new u.HeaderPart(this._package,e,this._parser);break;case a.RelationshipTypes.CoreProperties:this.corePropsPart=r=new h.CorePropsPart(this._package,e);break;case a.RelationshipTypes.ExtendedProperties:this.extendedPropsPart=r=new d.ExtendedPropsPart(this._package,e);break;case a.RelationshipTypes.CustomProperties:r=new g.CustomPropsPart(this._package,e);break;case a.RelationshipTypes.Settings:this.settingsPart=r=new f.SettingsPart(this._package,e);break;case a.RelationshipTypes.Comments:this.commentsPart=r=new b.CommentsPart(this._package,e,this._parser);break;case a.RelationshipTypes.CommentsExtended:this.commentsExtendedPart=r=new y.CommentsExtendedPart(this._package,e)}if(null==r)return Promise.resolve(null);if(this.partsMap[e]=r,this.parts.push(r),await r.load(),r.rels?.length>0){const[e]=(0,i.splitPath)(r.path);await Promise.all(r.rels.filter(e=>"External"!==e.targetMode).map(t=>this.loadRelationshipPart((0,i.resolvePath)(t.target,e),t.type)))}return r}async loadRelationshipXml(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a||"External"===a.targetMode)return null;const n=v(this.resolveRelationshipTarget(r,a)),s=n?this._snapshotTextParts?.[n]??await this._package.load(n,"string"):null;return s?this._package.parseXmlDocument(s):null}async loadRelationshipText(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a||"External"===a.targetMode)return null;const n=v(this.resolveRelationshipTarget(r,a));return n?Promise.resolve(this._snapshotTextParts?.[n]??this._package.load(n,"string")):Promise.resolve(null)}async loadRelationshipBlobUrl(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a)return null;if("External"===a.targetMode)return a.target;const n=v(this.resolveRelationshipTarget(r,a));return n?this.loadPackageAssetUrl(n):null}async loadDocumentImage(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a)return null;if("External"===a.targetMode)return a.target;const n=v(this.resolveRelationshipTarget(r,a));return n?this.loadPackageAssetUrl(n):null}async loadNumberingImage(e){const t=v(this.getPathById(this.numberingPart,e));return t?this.loadPackageAssetUrl(t):null}async loadFont(e,t){const r=v(this.getPathById(this.fontTablePart,e));if(!r)return null;if(this._snapshotAssetDataUrls?.[r])return this._snapshotAssetDataUrls[r];const a=await this._package.load(r,"uint8array");return a?this.blobToURL(new Blob([S(a,t)]),r):a}async loadAltChunk(e,t){const r=t??this.documentPart,a=this.getRelById(r,e);if(!a||"External"===a.targetMode)return Promise.resolve(null);const n=v(this.resolveRelationshipTarget(r,a));return n?Promise.resolve(this._snapshotTextParts?.[n]??this._package.load(n,"string")):Promise.resolve(null)}blobToURL(e,t){return e?(e=this.blobWithContentType(e,t),this._options.useBase64URL?(0,i.blobToBase64)(e):URL.createObjectURL(e)):null}async loadPackageAssetUrl(e){const t=v(e);if(!t)return null;if(this._snapshotAssetDataUrls?.[t])return this._snapshotAssetDataUrls[t];if(this.isEmfAsset(t)){const e=await this._package.load(t,"uint8array");if(!e)return null;return this.convertEmfAsset(e,t)||this.blobToURL(new Blob([e],{type:this.contentTypeForPath(t)||"image/x-emf"}),t)}return this.blobToURL(await this._package.load(t,"blob"),t)}async loadPackageAssetDataUrl(e){const t=v(e);if(!t)return null;if(this.isEmfAsset(t)){const e=await this._package.load(t,"uint8array");if(!e)return null;const r=this.convertEmfAsset(e,t);if(r)return r;const a=e?new Blob([e],{type:this.contentTypeForPath(t)||"image/x-emf"}):null;return a?(0,i.blobToBase64)(a):null}const r=await this._package.load(t,"blob"),a=this.blobWithContentType(r,t);return a?(0,i.blobToBase64)(a):null}convertEmfAsset(e,t){if(!e||!(0,x.isEmfBinary)(e))return null;try{return(0,x.convertEmfToSvgDataUrl)(e)}catch(e){return this._options?.debug&&console.warn(`docx-preview: unable to convert EMF asset ${t}`,e),null}}isEmfAsset(e){const t=this.contentTypeForPath(e).toLowerCase();return/\.emf$/i.test(e??"")||"image/x-emf"==t||"image/emf"==t}contentTypeForPath(e){const t=v(e??"").toLowerCase();for(const e of this.contentTypes??[])if(e.partName&&v(e.partName).toLowerCase()==t)return e.contentType??"";const r=/\.([^.\/]+)$/.exec(t),a=r?.[1]??"";if(!a)return"";const n=(this.contentTypes??[]).find(e=>e.extension?.toLowerCase()==a);return n?.contentType??""}findPartByRelId(e,t=null){var r=this.getRelById(t,e);const a=r&&"External"!==r.targetMode?this.resolveRelationshipTarget(t,r):null;return a?this.partsMap[a]:null}getRelById(e,t){return(e?.rels??this.rels??[]).find(e=>e.id==t)}getPathById(e,t){const r=this.getRelById(e,t);return r&&"External"!==r.targetMode?this.resolveRelationshipTarget(e,r):null}resolveRelationshipTarget(e,t){const[r]=e?(0,i.splitPath)(e.path):[""];return v((0,i.resolvePath)(t.target,r))}}function v(e){return e&&e.startsWith("/")?e.substring(1):e}function S(e,t){const r=t.replace(/{|}|-/g,""),a=new Array(16);for(let e=0;e<16;e++)a[16-e-1]=parseInt(r.substring(2*e,2*e+2),16);for(let t=0;t<32;t++)e[t]=e[t]^a[t%16];return e}r.WordDocument=P}},n={};return function e(t,s){var o=function(e,t){if("jszip"===e)return"jszip";if("."===e[0]){var r=function(e){for(var t=e.split("/"),r=[],a=0;a<t.length;a++){var n=t[a];n&&"."!==n&&(".."===n?r.pop():r.push(n))}return"./"+r.join("/")}(t.substring(0,t.lastIndexOf("/")+1)+e);if(a[r])return r;if(a[r+"/index"])return r+"/index"}if(a[e])return e;throw new Error("Cannot resolve module "+e+" from "+t)}(t,s||"./docx-preview-worker");if("jszip"===o)return r;if(n[o])return n[o].exports;var i={exports:{}};return n[o]=i,a[o](function(t){return e(t,o)},i,i.exports),i.exports}("./docx-preview-worker","./docx-preview-worker")}var r=!1;e.onmessage=function(a){var n=a.data||{};if(!r)try{t(n),r=!0,e.onmessage(a)}catch(t){e.postMessage({id:n.id,type:"error",error:{message:t&&t.message?t.message:String(t),stack:t&&t.stack}})}}}(self);