@zphhhhh/docx-preview 0.4.20

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.
@@ -0,0 +1,2 @@
1
+ import e from"jszip";import*as t from"lodash-es";import r from"konva";function n(e,t,r,n){return new(r||(r=Promise))(function(a,s){function i(e){try{o(n.next(e))}catch(e){s(e)}}function l(e){try{o(n.throw(e))}catch(e){s(e)}}function o(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,l)}o((n=n.apply(e,t||[])).next())})}function a(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;const s={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4","mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["*mp4","mp4v","*mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};var i,l,o;Object.freeze(s);i=new WeakMap,l=new WeakMap,o=new WeakMap;var c,d=new class{constructor(...e){i.set(this,new Map),l.set(this,new Map),o.set(this,new Map);for(const t of e)this.define(t)}define(e,t=!1){for(let[r,n]of Object.entries(e)){r=r.toLowerCase(),n=n.map(e=>e.toLowerCase()),a(this,o,"f").has(r)||a(this,o,"f").set(r,new Set);const e=a(this,o,"f").get(r);let s=!0;for(let o of n){const n=o.startsWith("*");if(o=n?o.slice(1):o,null==e||e.add(o),s&&a(this,l,"f").set(r,o),s=!1,n)continue;const c=a(this,i,"f").get(o);if(c&&c!=r&&!t)throw new Error(`"${r} -> ${o}" conflicts with "${c} -> ${o}". Pass \`force=true\` to override this definition.`);a(this,i,"f").set(o,r)}}return this}getType(e){var t;if("string"!=typeof e)return null;const r=e.replace(/^.*[/\\]/,"").toLowerCase(),n=r.replace(/^.*\./,"").toLowerCase(),s=r.length<e.length;return!(n.length<r.length-1)&&s?null:null!==(t=a(this,i,"f").get(n))&&void 0!==t?t:null}getExtension(e){var t,r;return"string"!=typeof e?null:null!==(r=(e=null===(t=null==e?void 0:e.split)||void 0===t?void 0:t.call(e,";")[0])&&a(this,l,"f").get(e.trim().toLowerCase()))&&void 0!==r?r:null}getAllExtensions(e){var t;return"string"!=typeof e?null:null!==(t=a(this,o,"f").get(e.toLowerCase()))&&void 0!==t?t:null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const e of a(this,o,"f").values())Object.freeze(e);return this}_getTestState(){return{types:a(this,i,"f"),extensions:a(this,l,"f")}}}(s)._freeze();!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"}(c||(c={}));const p="http://schemas.openxmlformats.org/wordprocessingml/2006/main",h={mul:1/9525,unit:"px"},u={mul:.05,unit:"pt"},m={mul:1/12700,unit:"pt"},f={mul:.5,unit:"pt"},g={mul:.125,unit:"pt"},b={mul:1,unit:"pt"},y={mul:1e-5,unit:""},v={mul:.02,unit:"%"},k={mul:1e-5,unit:""},x={mul:1/6e4,unit:"deg"};function w(e,t=u,r=!0){if(!e)return null;if("number"==typeof e){let n=e*t.mul;return r?`${n.toFixed(2)}${t.unit}`:n}if(/.+(p[xt]|%)$/.test(e))return e;let n=parseFloat(e)*t.mul;return r?`${n.toFixed(2)}${t.unit}`:n}function S(e,t,r){if(e.namespaceURI!=p)return!1;switch(e.localName){case"color":t.color=r.attr(e,"val");break;case"sz":t.fontSize=r.lengthAttr(e,"val",f);break;default:return!1}return!0}class C{elements(e,t=null){const r=[];for(let n=0,a=e.childNodes.length;n<a;n++){let a=e.childNodes.item(n);1!=a.nodeType||null!=t&&a.localName!=t||r.push(a)}return r}element(e,t){for(let r=0,n=e.childNodes.length;r<n;r++){let n=e.childNodes.item(r);if(1==n.nodeType&&n.localName==t)return n}return null}elementAttr(e,t,r){let n=this.element(e,t);return n?this.attr(n,r):void 0}attrs(e){return Array.from(e.attributes)}attr(e,t,r=null){let n=this.attrs(e).find(e=>e.localName==t);return n?n.value:r}intAttr(e,t,r=null){let n=this.attr(e,t);return n?parseInt(n):r}hexAttr(e,t,r=null){let n=this.attr(e,t);return n?parseInt(n,16):r}floatAttr(e,t,r=null){let n=this.attr(e,t);return n?parseFloat(n):r}boolAttr(e,t,r=null){return 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}}(this.attr(e,t),r)}lengthAttr(e,t,r=u,n){var a;return null!==(a=w(this.attr(e,t),r))&&void 0!==a?a:n}numberAttr(e,t,r=u,n=0){var a;return null!==(a=w(this.attr(e,t),r,!1))&&void 0!==a?a:n}}const P=new C;class N{constructor(e,t){this._package=e,this.path=t}load(){return n(this,void 0,void 0,function*(){this.rels=yield this._package.loadRelationships(this.path);const e=yield this._package.load(this.path),t=this._package.parseXmlDocument(e);this._package.options.keepOrigin&&(this._xmlDocument=t),this.parseXml(t.firstElementChild)})}save(){var e;this._package.update(this.path,(e=this._xmlDocument,(new XMLSerializer).serializeToString(e)))}parseXml(e){}}const T={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function M(e,t){return t.elements(e).map(e=>function(e,t){let r={name:t.attr(e,"name"),embedFontRefs:[]};for(let n of t.elements(e))switch(n.localName){case"family":r.family=t.attr(n,"val");break;case"altName":r.altName=t.attr(n,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":r.embedFontRefs.push(A(n,t))}return r}(e,t))}function A(e,t){return{id:t.attr(e,"id"),key:t.attr(e,"fontKey"),type:T[e.localName]}}class E extends N{parseXml(e){this.fonts=M(e,this._package.xmlParser)}}function R(e){if(void 0===e)throw new Error("className cannot be undefined. Please provide a valid string.");const t=[{pattern:/[ .]+/g,replacement:"-"},{pattern:/[&]+/g,replacement:"and"},{pattern:/[#@]+/g,replacement:""}];let r=e;for(const e of t)r=r.replace(e.pattern,e.replacement);return r.toLowerCase()}function $(e){let t=e.lastIndexOf("/")+1;return[0==t?"":e.substring(0,t),0==t?e:e.substring(t)]}function D(e,t){try{const r="http://docx/";return new URL(e,r+t).toString().substring(r.length)}catch(r){return`${t}${e}`}}function F(e){return Array.isArray(e)?e:[e]}function B(){if("object"==typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues&&"function"==typeof Uint8Array){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>{const t=Number(e);return(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)})}}let e=(new Date).getTime(),t="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:3&n|8).toString(16)})}class L{constructor(e,t){this._zip=e,this.options=t,this.xmlParser=new C}get(e){var t;const r=function(e){return e.startsWith("/")?e.substr(1):e}(e);return null!==(t=this._zip.files[r])&&void 0!==t?t:this._zip.files[r.replace(/\//g,"\\")]}update(e,t){this._zip.file(e,t)}static load(t,r){return n(this,void 0,void 0,function*(){const n=yield e.loadAsync(t);return new L(n,r)})}save(e="blob"){return this._zip.generateAsync({type:e})}load(e,t="string"){var r,n;return null!==(n=null===(r=this.get(e))||void 0===r?void 0:r.async(t))&&void 0!==n?n:Promise.resolve(null)}loadRelationships(){return n(this,arguments,void 0,function*(e=null){let t="_rels/.rels";if(null!=e){const[r,n]=$(e);t=`${r}_rels/${n}.rels`}const r=yield this.load(t);return r?(n=this.parseXmlDocument(r).firstElementChild,(a=this.xmlParser).elements(n).map(e=>({id:a.attr(e,"Id"),type:a.attr(e,"Type"),target:a.attr(e,"Target"),targetMode:a.attr(e,"TargetMode")}))):null;var n,a})}parseXmlDocument(e){return function(e,t=!1){var r;t&&(e=e.replace(/<[?].*[?]>/,"")),e=65279===(r=e).charCodeAt(0)?r.substring(1):r;const n=(new DOMParser).parseFromString(e,"application/xml"),a=null===(s=n.getElementsByTagName("parsererror")[0])||void 0===s?void 0:s.textContent;var s;if(a)throw new Error(a);return n}(e,this.options.trimXmlDeclaration)}}class j extends N{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.body=this._documentParser.parseDocumentFile(e)}}function O(e,t){return{type:t.attr(e,"val"),color:t.attr(e,"color"),size:t.lengthAttr(e,"sz",g),offset:t.lengthAttr(e,"space",b),frame:t.boolAttr(e,"frame"),shadow:t.boolAttr(e,"shadow")}}function I(e,t){var r={};for(let n of t.elements(e))switch(n.localName){case"left":r.left=O(n,t);break;case"top":r.top=O(n,t);break;case"right":r.right=O(n,t);break;case"bottom":r.bottom=O(n,t)}return r}var H,_,z,U,V,W,X;function G(e,t=P){var r,n;let a={contentSize:{}},s={};for(let i of t.elements(e))switch(i.localName){case"bidi":case"endnotePr":case"footnotePr":case"formProt":case"lnNumType":case"noEndnote":case"paperSrc":case"printerSettings":case"rtlGutter":case"sectPrChange":case"textDirection":case"vAlign":break;case"cols":a.columns=q(i,t);break;case"docGrid":a.docGrid=J(i,t);break;case"footerReference":(null!==(r=a.footerRefs)&&void 0!==r?r:a.footerRefs=[]).push(K(i,t));break;case"headerReference":(null!==(n=a.headerRefs)&&void 0!==n?n:a.headerRefs=[]).push(K(i,t));break;case"pgBorders":a.pageBorders=I(i,t);break;case"pgMar":a.pageMargins={left:t.lengthAttr(i,"left"),right:t.lengthAttr(i,"right"),top:t.lengthAttr(i,"top"),bottom:t.lengthAttr(i,"bottom"),header:t.lengthAttr(i,"header"),footer:t.lengthAttr(i,"footer"),gutter:t.lengthAttr(i,"gutter")},s.pageMargins={left:t.intAttr(i,"left"),right:t.intAttr(i,"right"),top:t.intAttr(i,"top"),bottom:t.intAttr(i,"bottom"),header:t.intAttr(i,"header"),footer:t.intAttr(i,"footer"),gutter:t.intAttr(i,"gutter")};break;case"pgNumType":a.pageNumber=Y(i,t);break;case"pgSz":a.pageSize={width:t.lengthAttr(i,"w"),height:t.lengthAttr(i,"h"),orientation:t.attr(i,"orient")},s.pageSize={width:t.intAttr(i,"w"),height:t.intAttr(i,"h")};break;case"titlePg":a.titlePage=t.boolAttr(i,"val",!0);break;case"type":a.type=t.attr(i,"val");break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Section Property:${e.localName}`,"color:#f75607")}let{width:i,height:l}=s.pageSize,{left:o,right:c,top:d,bottom:p}=s.pageMargins;return a.contentSize.width=w(i-o-c),a}function q(e,t){return{count: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 K(e,t){return{id:t.attr(e,"id"),type:t.attr(e,"type")}}function J(e,t){let r={type:_.Default};for(let n of t.attrs(e))switch(n.localName){case"charSpace":r.characterSpace=t.intAttr(e,"charSpace");break;case"linePitch":r.linePitch=t.intAttr(e,"linePitch");break;case"type":r.type=t.attr(e,"type",_.Default);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Grid Property:${e.localName}`,"color:#f75607")}return r}function Y(e,t){return{chapSep:t.attr(e,"chapSep"),chapStyle:t.attr(e,"chapStyle"),format:t.attr(e,"fmt"),start:t.intAttr(e,"start")}}function Z(e,t){let{snapToGrid:r,spacing:n}=e,a={};if(n){let e;for(const t in n)switch(t){case"line":e=null==n?void 0:n.line;break;case"after":a["margin-bottom"]=n[t];break;case"before":a["margin-top"]=n[t]}switch(null==n?void 0:n.lineRule){case"auto":default:a["line-height"]=e/240;break;case"atLeast":a["line-height"]=`calc(100% + ${e/20}pt)`;break;case"exact":a["line-height"]=e/20+"pt"}}if(!1===r)return a;if(null==t?void 0:t.docGrid){let{docGrid:e}=t;switch(e.type){case _.Lines:case _.LinesAndChars:case _.SnapToChars:"number"==typeof a["line-height"]&&(a["line-height"]=a["line-height"]*e.linePitch/20+"pt");break;case _.Default:return a;default:console.warn(`DOCX:%c Unknown DocGrid Type:${e.type}`,"color:#f75607")}}return a}function Q(e,t){let r={};for(let n of t.elements(e))ee(n,r,t);return r}function ee(e,t,r){return S(e,t,r)}function te(e,t){let r={};for(let n of t.elements(e))re(n,r,t);return r}function re(e,t,r){if(e.namespaceURI!=p)return!1;if(S(e,t,r))return!0;switch(e.localName){case"adjustRightInd":case"autoSpaceDE":case"autoSpaceDN":case"contextualSpacing":case"divId":break;case"keepLines":t.keepLines=r.boolAttr(e,"val",!0);break;case"keepNext":t.keepNext=r.boolAttr(e,"val",!0);break;case"numPr":t.numbering=function(e,t){let r={};for(let n of t.elements(e))switch(n.localName){case"numId":r.id=t.attr(n,"val");break;case"ilvl":r.level=t.intAttr(n,"val")}return r}(e,r);break;case"outlineLvl":t.outlineLevel=r.intAttr(e,"val");break;case"pageBreakBefore":t.pageBreakBefore=r.boolAttr(e,"val",!0);break;case"rPr":t.runProperties=Q(e,r);break;case"sectPr":t.sectionProperties=G(e,r);break;case"snapToGrid":t.snapToGrid=r.boolAttr(e,"val",!0);break;case"spacing":return t.spacing=function(e,t){let r={lineRule:z.Auto};for(const n of t.attrs(e))switch(n.localName){case"after":r.after=t.lengthAttr(e,"after",void 0,"0pt");break;case"afterAutospacing":case"afterLines":case"beforeAutospacing":case"beforeLines":break;case"before":r.before=t.lengthAttr(e,"before",void 0,"0pt");break;case"line":r.line=t.intAttr(e,"line",0);break;case"lineRule":r.lineRule=t.attr(e,"lineRule",z.Auto);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Spacing Property:${n.localName}`,"color:#f75607")}return r}(e,r),!1;case"tabs":t.tabs=function(e,t){return t.elements(e,"tab").map(e=>({position:t.numberAttr(e,"pos"),leader:t.attr(e,"leader"),style:t.attr(e,"val")}))}(e,r);break;case"textAlignment":return t.textAlignment=r.attr(e,"val"),!1;default:return!1}return!0}function ne(e,t){let r={id:t.attr(e,"numId"),overrides:[]};for(let n of t.elements(e))switch(n.localName){case"abstractNumId":r.abstractId=t.attr(n,"val");break;case"lvlOverride":r.overrides.push(ie(n,t))}return r}function ae(e,t){let r={id:t.attr(e,"abstractNumId"),levels:[]};for(let n of t.elements(e))switch(n.localName){case"name":r.name=t.attr(n,"val");break;case"multiLevelType":r.multiLevelType=t.attr(n,"val");break;case"numStyleLink":r.numberingStyleLink=t.attr(n,"val");break;case"styleLink":r.styleLink=t.attr(n,"val");break;case"lvl":r.levels.push(se(n,t))}return r}function se(e,t){let r={level:t.intAttr(e,"ilvl")};for(let n of t.elements(e))switch(n.localName){case"start":r.start=t.attr(n,"val");break;case"lvlRestart":r.restart=t.intAttr(n,"val");break;case"numFmt":r.format=t.attr(n,"val");break;case"lvlText":r.text=t.attr(n,"val");break;case"lvlJc":r.justification=t.attr(n,"val");break;case"lvlPicBulletId":r.bulletPictureId=t.attr(n,"val");break;case"pStyle":r.paragraphStyle=t.attr(n,"val");break;case"pPr":r.paragraphProps=te(n,t);break;case"rPr":r.runProps=Q(n,t)}return r}function ie(e,t){let r={level:t.intAttr(e,"ilvl")};for(let n of t.elements(e))switch(n.localName){case"startOverride":r.start=t.intAttr(n,"val");break;case"lvl":r.numberingLevel=se(n,t)}return r}function le(e,t){var r=t.element(e,"pict"),n=r&&t.element(r,"shape"),a=n&&t.element(n,"imagedata");return a?{id:t.attr(e,"numPicBulletId"),referenceId:t.attr(a,"id"),style:t.attr(n,"style")}:null}!function(e){e.Continuous="continuous",e.NextPage="nextPage",e.NextColumn="nextColumn",e.EvenPage="evenPage",e.OddPage="oddPage"}(H||(H={})),function(e){e.Default="default",e.Lines="lines",e.LinesAndChars="linesAndChars",e.SnapToChars="snapToChars"}(_||(_={})),function(e){e.AtLeast="atLeast",e.Auto="auto",e.Exact="exact"}(z||(z={}));class oe extends N{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){Object.assign(this,function(e,t){let r={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let n of t.elements(e))switch(n.localName){case"num":r.numberings.push(ne(n,t));break;case"abstractNum":r.abstractNumberings.push(ae(n,t));break;case"numPicBullet":r.bulletPictures.push(le(n,t))}return r}(e,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(e)}}class ce extends N{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.styles=this._documentParser.parseStylesFile(e)}}!function(e){e.Document="document",e.Page="page",e.Paragraph="paragraph",e.Run="run",e.Break="break",e.LastRenderedPageBreak="lastRenderedPageBreak",e.SectionBreak="sectionBreak",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.Character="character",e.Tab="tab",e.Symbol="symbol",e.BookmarkStart="bookmarkStart",e.BookmarkEnd="bookmarkEnd",e.Footer="footer",e.Header="header",e.FootnoteReference="footnoteReference",e.EndnoteReference="endnoteReference",e.Footnotes="footnotes",e.Footnote="footnote",e.Endnotes="endnotes",e.Endnote="endnote",e.SimpleField="simpleField",e.ComplexField="complexField",e.Instruction="instruction",e.VmlPicture="vmlPicture",e.Shape="shape",e.MmlMath="mmlMath",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.MmlMatrix="mmlMatrix",e.MmlMatrixRow="mmlMatrixRow",e.MmlBox="mmlBox",e.MmlBar="mmlBar",e.MmlGroupChar="mmlGroupChar",e.VmlElement="vmlElement",e.Inserted="inserted",e.Deleted="deleted",e.DeletedText="deletedText",e.Comment="comment",e.CommentReference="commentReference",e.CommentRangeStart="commentRangeStart",e.CommentRangeEnd="commentRangeEnd",e.AltChunk="altChunk"}(U||(U={})),function(e){e.Base="mmlBase",e.Bar="mmlBar",e.Box="mmlBox",e.Delimiter="mmlDelimiter",e.Degree="mmlDegree",e.Denominator="mmlDenominator",e.Function="mmlFunction",e.FunctionName="mmlFunctionName",e.Fraction="mmlFraction",e.GroupChar="mmlGroupChar",e.Limit="mmlLimit",e.LimitLower="mmlLimitLower",e.Matrix="mmlMatrix",e.MatrixRow="mmlMatrixRow",e.Math="mmlMath",e.MathParagraph="mmlMathParagraph",e.Nary="mmlNary",e.Numerator="mmlNumerator",e.PreSubSuper="mmlPreSubSuper",e.Radical="mmlRadical",e.SubArgument="mmlSubArgument",e.Subscript="mmlSubscript",e.Superscript="mmlSuperscript"}(V||(V={}));class de{constructor(){this.children=[],this.cssStyle={}}}!function(e){e.Column="column",e.Page="page",e.TextWrapping="textWrapping"}(W||(W={})),function(e){e.Inline="Inline",e.None="None",e.TopAndBottom="TopAndBottom",e.Tight="Tight",e.Through="Through",e.Square="Square",e.Polygon="Polygon"}(X||(X={}));class pe extends de{constructor(){super(...arguments),this.type=U.Header}}class he extends de{constructor(){super(...arguments),this.type=U.Footer}}class ue extends N{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.rootElement=this.createRootElement(),this.rootElement.level=1,this.rootElement.children=this._documentParser.parseBodyElements(e)}}class me extends ue{createRootElement(){return new pe}}class fe extends ue{createRootElement(){return new he}}function ge(e){if(void 0!==e)return parseInt(e)}class be extends N{parseXml(e){this.props=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=ge(n.textContent);break;case"Words":r.words=ge(n.textContent);break;case"Characters":r.characters=ge(n.textContent);break;case"Application":r.application=n.textContent;break;case"Lines":r.lines=ge(n.textContent);break;case"Paragraphs":r.paragraphs=ge(n.textContent);break;case"Company":r.company=n.textContent;break;case"AppVersion":r.appVersion=n.textContent}return r}(e,this._package.xmlParser)}}class ye extends N{parseXml(e){this.props=function(e,t){const r={};for(let n of t.elements(e))switch(n.localName){case"title":r.title=n.textContent;break;case"description":r.description=n.textContent;break;case"subject":r.subject=n.textContent;break;case"creator":r.creator=n.textContent;break;case"keywords":r.keywords=n.textContent;break;case"language":r.language=n.textContent;break;case"lastModifiedBy":r.lastModifiedBy=n.textContent;break;case"revision":n.textContent&&(r.revision=parseInt(n.textContent))}return r}(e,this._package.xmlParser)}}class ve{}function ke(e,t){var r={name:t.attr(e,"name"),colors:{}};for(let s of t.elements(e)){var n=t.element(s,"srgbClr"),a=t.element(s,"sysClr");n?r.colors[s.localName]=t.attr(n,"val"):a&&(r.colors[s.localName]=t.attr(a,"lastClr"))}return r}function xe(e,t){var r={name:t.attr(e,"name")};for(let n of t.elements(e))switch(n.localName){case"majorFont":r.majorFont=we(n,t);break;case"minorFont":r.minorFont=we(n,t)}return r}function we(e,t){return{latinTypeface:t.elementAttr(e,"latin","typeface"),eaTypeface:t.elementAttr(e,"ea","typeface"),csTypeface:t.elementAttr(e,"cs","typeface")}}class Se extends N{constructor(e,t){super(e,t)}parseXml(e){this.theme=function(e,t){var r=new ve,n=t.element(e,"themeElements");for(let e of t.elements(n))switch(e.localName){case"clrScheme":r.colorScheme=ke(e,t);break;case"fontScheme":r.fontScheme=xe(e,t)}return r}(e,this._package.xmlParser)}}class Ce extends de{constructor(){super(...arguments),this.children=[]}}class Pe{}class Ne extends Ce{constructor(){super(...arguments),this.type=U.Footnotes}}class Te extends Pe{constructor(){super(...arguments),this.type=U.Footnote}}class Me extends Ce{constructor(){super(...arguments),this.type=U.Endnotes}}class Ae extends Pe{constructor(){super(...arguments),this.type=U.Endnote}}class Ee extends N{constructor(e,t,r){super(e,t),this._documentParser=r}}class Re extends Ee{constructor(e,t,r){super(e,t,r)}parseXml(e){this.rootElement=new Ne,this.rootElement.level=1,this.rootElement.children=this._documentParser.parseNotes(e,"footnote",Te)}}class $e extends Ee{constructor(e,t,r){super(e,t,r)}parseXml(e){this.rootElement=new Me,this.rootElement.level=1,this.rootElement.children=this._documentParser.parseNotes(e,"endnote",Ae)}}function De(e,t){var r={defaultNoteIds:[]};for(let n of t.elements(e))switch(n.localName){case"numFmt":r.nummeringFormat=t.attr(n,"val");break;case"footnote":case"endnote":r.defaultNoteIds.push(t.attr(n,"id"))}return r}class Fe extends N{constructor(e,t){super(e,t)}parseXml(e){this.settings=function(e,t){var r={};for(let n of t.elements(e))switch(n.localName){case"autoHyphenation":r.autoHyphenation=t.boolAttr(n,"val");break;case"defaultTabStop":r.defaultTabStop=t.lengthAttr(n,"val");break;case"endnotePr":r.endnoteProps=De(n,t);break;case"evenAndOddHeaders":r.evenAndOddHeaders=t.boolAttr(n,"val",!0);break;case"footnotePr":r.footnoteProps=De(n,t)}return r}(e,this._package.xmlParser)}}class Be extends N{parseXml(e){this.props=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}})}(e,this._package.xmlParser)}}class Le extends N{constructor(e,t,r){super(e,t),this._documentParser=r}parseXml(e){this.comments=this._documentParser.parseComments(e),this.commentMap=t.keyBy(this.comments,"id")}}const je=[{type:c.OfficeDocument,target:"word/document.xml"},{type:c.ExtendedProperties,target:"docProps/app.xml"},{type:c.CoreProperties,target:"docProps/core.xml"},{type:c.CustomProperties,target:"docProps/custom.xml"}];class Oe{constructor(){this.parts=[],this.partsMap={}}static load(e,t,r){return n(this,void 0,void 0,function*(){var n=new Oe;return n._options=r,n._parser=t,n._package=yield L.load(e,r),n.rels=yield n._package.loadRelationships(),yield Promise.all(je.map(e=>{var t;const r=null!==(t=n.rels.find(t=>t.type===e.type))&&void 0!==t?t:e;return n.loadRelationshipPart(r.target,r.type)})),n})}save(e="blob"){return this._package.save(e)}loadRelationshipPart(e,t){return n(this,void 0,void 0,function*(){var r;if(this.partsMap[e])return this.partsMap[e];if(!this._package.get(e))return null;let n=null;switch(t){case c.OfficeDocument:this.documentPart=n=new j(this._package,e,this._parser);break;case c.FontTable:this.fontTablePart=n=new E(this._package,e);break;case c.Numbering:this.numberingPart=n=new oe(this._package,e,this._parser);break;case c.Styles:this.stylesPart=n=new ce(this._package,e,this._parser);break;case c.Theme:this.themePart=n=new Se(this._package,e);break;case c.Footnotes:this.footnotesPart=n=new Re(this._package,e,this._parser);break;case c.Endnotes:this.endnotesPart=n=new $e(this._package,e,this._parser);break;case c.Footer:n=new fe(this._package,e,this._parser);break;case c.Header:n=new me(this._package,e,this._parser);break;case c.CoreProperties:this.corePropsPart=n=new ye(this._package,e);break;case c.ExtendedProperties:this.extendedPropsPart=n=new be(this._package,e);break;case c.CustomProperties:n=new Be(this._package,e);break;case c.Settings:this.settingsPart=n=new Fe(this._package,e);break;case c.Comments:this.commentsPart=n=new Le(this._package,e,this._parser)}if(null==n)return Promise.resolve(null);if(this.partsMap[e]=n,this.parts.push(n),yield n.load(),(null===(r=n.rels)||void 0===r?void 0:r.length)>0){const[e]=$(n.path);yield Promise.all(n.rels.map(t=>this.loadRelationshipPart(D(t.target,e),t.type)))}return n})}loadDocumentImage(e,t){return n(this,void 0,void 0,function*(){const r=yield this.loadResource(null!=t?t:this.documentPart,e,"blob");return this.blobToURL(r)})}loadNumberingImage(e){return n(this,void 0,void 0,function*(){const t=yield this.loadResource(this.numberingPart,e,"blob");return this.blobToURL(t)})}loadFont(e,t){return n(this,void 0,void 0,function*(){const r=yield this.loadResource(this.fontTablePart,e,"uint8array");return r?this.blobToURL(new Blob([Ie(r,t)])):r})}loadAltChunk(e,t){return n(this,void 0,void 0,function*(){return yield this.loadResource(null!=t?t:this.documentPart,e,"string")})}blobToURL(e){return e?this._options.useBase64URL?function(e){return new Promise((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=()=>r(),n.readAsDataURL(e)})}(e):URL.createObjectURL(e):null}findPartByRelId(e,t=null){var r,n=(null!==(r=t.rels)&&void 0!==r?r:this.rels).find(t=>t.id==e);const a=t?$(t.path)[0]:"";return n?this.partsMap[D(n.target,a)]:null}getPathById(e,t){const r=e.rels.find(e=>e.id==t),[n]=$(e.path);return r?D(r.target,n):null}loadResource(e,t,r){return n(this,void 0,void 0,function*(){const n=this.getPathById(e,t);let a=d.getType(n);if(n){let e=yield this._package.load(n,r);return new Blob([e],{type:a})}return Promise.resolve(null)})}}function Ie(e,t){const r=t.replace(/{|}|-/g,""),n=new Array(16);for(let e=0;e<16;e++)n[16-e-1]=parseInt(r.substring(2*e,2*e+2),16);for(let t=0;t<32;t++)e[t]=e[t]^n[t%16];return e}class He extends de{constructor(){super(...arguments),this.type=U.VmlElement,this.attrs={}}}function _e(e,t){var r=new He;switch(e.localName){case"rect":r.tagName="rect",Object.assign(r.attrs,{width:"100%",height:"100%"});break;case"oval":r.tagName="ellipse",Object.assign(r.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":r.tagName="line";break;case"shape":r.tagName="g";break;case"textbox":r.tagName="foreignObject",Object.assign(r.attrs,{width:"100%",height:"100%"});break;default:return null}for(const t of P.attrs(e))switch(t.localName){case"style":r.cssStyleText=t.value;break;case"fillcolor":r.attrs.fill=t.value;break;case"from":const[e,n]=Ve(t.value);Object.assign(r.attrs,{x1:e,y1:n});break;case"to":const[a,s]=Ve(t.value);Object.assign(r.attrs,{x2:a,y2:s})}for(const n of P.elements(e))switch(n.localName){case"stroke":Object.assign(r.attrs,ze(n));break;case"fill":Object.assign(r.attrs,Ue());break;case"imagedata":r.tagName="image",Object.assign(r.attrs,{width:"100%",height:"100%"}),r.imageHref={id:P.attr(n,"id"),title:P.attr(n,"title")};break;case"txbxContent":r.children.push(...t.parseBodyElements(n));break;default:const e=_e(n,t);e&&r.children.push(e)}return r}function ze(e){var t;return{stroke:P.attr(e,"color"),"stroke-width":null!==(t=P.lengthAttr(e,"weight",m))&&void 0!==t?t:"1px"}}function Ue(e){return{}}function Ve(e){return e.split(",")}class We extends de{constructor(){super(...arguments),this.type=U.Comment}}class Xe extends de{constructor(e){super(),this.id=e,this.type=U.CommentReference}}class Ge extends de{constructor(e){super(),this.id=e,this.type=U.CommentRangeStart}}class qe extends de{constructor(e){super(),this.id=e,this.type=U.CommentRangeEnd}}var Ke="inherit",Je="black",Ye="black",Ze="transparent";const Qe=[],et={oMath:U.MmlMath,oMathPara:U.MmlMathParagraph,f:U.MmlFraction,func:U.MmlFunction,fName:U.MmlFunctionName,num:U.MmlNumerator,den:U.MmlDenominator,rad:U.MmlRadical,deg:U.MmlDegree,e:U.MmlBase,sSup:U.MmlSuperscript,sSub:U.MmlSubscript,sPre:U.MmlPreSubSuper,sup:U.MmlSuperArgument,sub:U.MmlSubArgument,d:U.MmlDelimiter,nary:U.MmlNary,eqArr:U.MmlEquationArray,lim:U.MmlLimit,limLow:U.MmlLimitLower,m:U.MmlMatrix,mr:U.MmlMatrixRow,box:U.MmlBox,bar:U.MmlBar,groupChr:U.MmlGroupChar},tt={ignoreWidth:!1,debug:!1,ignoreTableWrap:!0,ignoreImageWrap:!0};class rt{constructor(e){this.options=Object.assign(Object.assign({},tt),e)}parseDocumentFile(e){let t={uuid:"root",pages:[],sectProps:{},type:U.Document},r=P.element(e,"background");t.cssStyle=r?this.parseBackground(r):{};let n=P.element(e,"body");t.children=this.parseBodyElements(n);let a=P.element(n,"sectPr");return a&&(t.sectProps=G(a,P)),t.sectProps.sectionId=B(),t}parseBackground(e){let t={},r=at.colorAttr(e,"color");return r&&(t["background-color"]=r),t}parseBodyElements(e){let t=[];return at.foreach(e,e=>{switch(e.localName){case"p":t.push(this.parseParagraph(e));break;case"altChunk":t.push(this.parseAltChunk(e));break;case"tbl":t.push(this.parseTable(e));break;case"sdt":t.push(...this.parseSdt(e));break;case"sectPr":break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Body Element:${e.localName}`,"color:red")}}),t}parseAltChunk(e){return{type:U.AltChunk,children:[],id:P.attr(e,"id")}}parseStylesFile(e){let t=[];for(const r of P.elements(e))switch(r.localName){case"style":t.push(this.parseStyle(r));break;case"docDefaults":t.push(this.parseDefaultStyles(r));break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Style File:${r.localName}`,"color:#f75607")}return t}parseDefaultStyles(e){let t={basedOn:null,id:null,name:null,rulesets:[],type:null};for(const r of P.elements(e))switch(r.localName){case"rPrDefault":let e=P.element(r,"rPr");e&&t.rulesets.push({target:"span",declarations:this.parseDefaultProperties(e,{})});break;case"pPrDefault":let n=P.element(r,"pPr");if(n){let e=te(n,P),r={target:"p",declarations:this.parseDefaultProperties(n,{})};Object.assign(r.declarations,Z(e)),t.rulesets.push(r)}break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Default Style:${r.localName}`,"color:#f75607")}return t}parseStyle(e){let t={basedOn:null,id:null,name:null,rulesets:[],type:null};for(const r of P.attrs(e))switch(r.localName){case"customStyle":t.customStyle=P.boolAttr(e,"customStyle",!1);break;case"default":t.isDefault=P.boolAttr(e,"default",!1);break;case"styleId":t.id=P.attr(e,"styleId");break;case"type":t.type=P.attr(e,"type");const n={paragraph:"p",table:"table",character:"span",numbering:"p"};n.hasOwnProperty(t.type)?t.label=n[t.type]:this.options&&this.options.debug&&console.warn(`DOCX:%c Unknown Style Type:${t.type}`,"color:#f75607");break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Style Property:${r.localName}`,"color:#f75607")}for(const r of P.elements(e))switch(r.localName){case"aliases":t.aliases=P.attr(r,"val").split(",");break;case"autoRedefine":t.autoRedefine=!0;break;case"basedOn":t.basedOn=P.attr(r,"val");break;case"hidden":t.hidden=!0;break;case"link":t.linked=P.attr(r,"val");break;case"locked":t.locked=!0;break;case"name":t.name=P.attr(r,"val");break;case"next":t.next=P.attr(r,"val");break;case"personal":t.personal=P.boolAttr(r,"val");break;case"personalCompose":t.personalCompose=P.boolAttr(r,"val");break;case"personalReply":t.personalReply=P.boolAttr(r,"val");break;case"pPr":t.paragraphProps=te(r,P);let e={target:"p",declarations:this.parseDefaultProperties(r,{})};Object.assign(e.declarations,Z(t.paragraphProps)),t.rulesets.push(e);break;case"qFormat":t.primaryStyle=!0;break;case"rPr":t.rulesets.push({target:"span",declarations:this.parseDefaultProperties(r,{})}),t.runProps=Q(r,P);break;case"rsid":t.rsid=P.hexAttr(r,"val");break;case"semiHidden":t.semiHidden=!0;break;case"tblPr":case"tcPr":t.rulesets.push({target:"td",declarations:this.parseDefaultProperties(r,{})});break;case"trPr":t.rulesets.push({target:"tr",declarations:this.parseDefaultProperties(r,{})});break;case"tblStylePr":for(let e of this.parseTableStyle(r))t.rulesets.push(e);break;case"uiPriority":t.uiPriority=P.intAttr(r,"val",1/0);break;case"unhideWhenUsed":t.unhideWhenUsed=!0;break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Style element:${r.localName}`,"color:blue")}return t}parseTableStyle(e){let t=[],r="",n="";switch(P.attr(e,"type")){case"firstRow":n=".first-row",r="tr.first-row td";break;case"lastRow":n=".last-row",r="tr.last-row td";break;case"firstCol":n=".first-col",r="td.first-col";break;case"lastCol":n=".last-col",r="td.last-col";break;case"band1Vert":n=":not(.no-vband)",r="td.odd-col";break;case"band2Vert":n=":not(.no-vband)",r="td.even-col";break;case"band1Horz":n=":not(.no-hband)",r="tr.odd-row";break;case"band2Horz":n=":not(.no-hband)",r="tr.even-row";break;default:return[]}for(const a of P.elements(e))switch(a.localName){case"pPr":let e=te(a,P),s={target:`${r} p`,modifier:n,declarations:this.parseDefaultProperties(a,{})};Object.assign(s.declarations,Z(e)),t.push(s);break;case"rPr":t.push({target:`${r} span`,modifier:n,declarations:this.parseDefaultProperties(a,{})});break;case"tblPr":case"tcPr":t.push({target:r,modifier:n,declarations:this.parseDefaultProperties(a,{})});break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Table Style:${a.localName}`,"color:#f75607")}return t}parseNumberingFile(e){let t=[];const r={};let n=[];for(const a of P.elements(e))switch(a.localName){case"abstractNum":this.parseAbstractNumbering(a,n).forEach(e=>t.push(e));break;case"numPicBullet":n.push(this.parseNumberingPicBullet(a));break;case"num":let e=P.attr(a,"numId"),s=P.elementAttr(a,"abstractNumId","val");r[s]=e;break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Numbering File:${a.localName}`,"color:#f75607")}return t.forEach(e=>e.id=r[e.id]),t}parseNumberingPicBullet(e){let t=P.element(e,"pict"),r=t&&P.element(t,"shape"),n=r&&P.element(r,"imagedata");return n?{id:P.intAttr(e,"numPicBulletId"),src:P.attr(n,"id"),style:P.attr(r,"style")}:null}parseAbstractNumbering(e,t){let r=[],n=P.attr(e,"abstractNumId");for(const a of P.elements(e))if("lvl"===a.localName)r.push(this.parseNumberingLevel(n,a,t));else this.options.debug&&console.warn(`DOCX:%c Unknown Abstract Numbering:${a.localName}`,"color:#f75607");return r}parseNumberingLevel(e,t,r){let n={id:e,level:P.intAttr(t,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(const e of P.elements(t))switch(e.localName){case"start":n.start=P.intAttr(e,"val");break;case"pPr":this.parseDefaultProperties(e,n.pStyle);break;case"rPr":this.parseDefaultProperties(e,n.rStyle);break;case"lvlPicBulletId":let t=P.intAttr(e,"val");n.bullet=r.find(e=>(null==e?void 0:e.id)==t);break;case"lvlText":n.levelText=P.attr(e,"val");break;case"pStyle":n.pStyleName=P.attr(e,"val");break;case"numFmt":n.format=P.attr(e,"val");break;case"suff":n.suff=P.attr(e,"val");break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Numbering Level:${e.localName}`,"color:#f75607")}return n}parseSdt(e){let t=[];const r=P.element(e,"sdtContent");return r&&(t=this.parseBodyElements(r)),t}parseNotes(e,t,r){let n=[];for(let a of P.elements(e,t)){const e=new r;e.id=P.attr(a,"id"),e.noteType=P.attr(a,"type"),e.children=this.parseBodyElements(a),n.push(e)}return n}parseComments(e){let t=[];for(let r of P.elements(e,"comment")){const e=new We;e.id=P.attr(r,"id"),e.author=P.attr(r,"author"),e.initials=P.attr(r,"initials"),e.date=P.attr(r,"date"),e.children=this.parseBodyElements(r),t.push(e)}return t}parseInserted(e){let t={type:U.Inserted,children:[]};return at.foreach(e,e=>{if("r"===e.localName)t.children.push(this.parseRun(e));else this.options.debug&&console.warn(`DOCX:%c Unknown Inserted:${e.localName}`,"color:#f75607")}),t}parseDeleted(e){let t={type:U.Deleted,children:[]};return at.foreach(e,e=>{if("r"===e.localName)t.children.push(this.parseRun(e));else this.options.debug&&console.warn(`DOCX:%c Unknown Inserted:${e.localName}`,"color:#f75607")}),t}parseParagraph(e){let t={type:U.Paragraph,children:[],props:{},cssStyle:{}};if(at.foreach(e,e=>{switch(e.localName){case"pPr":this.parseParagraphProperties(e,t);break;case"r":t.children.push(this.parseRun(e));break;case"hyperlink":t.children.push(this.parseHyperlink(e));break;case"bookmarkStart":t.children.push((r=e,n=P,{type:U.BookmarkStart,id:n.attr(r,"id"),name:n.attr(r,"name"),colFirst:n.intAttr(r,"colFirst"),colLast:n.intAttr(r,"colLast")}));break;case"bookmarkEnd":t.children.push(function(e,t){return{type:U.BookmarkEnd,id:t.attr(e,"id")}}(e,P));break;case"commentRangeStart":t.children.push(new Ge(P.attr(e,"id")));break;case"commentRangeEnd":t.children.push(new qe(P.attr(e,"id")));break;case"oMath":case"oMathPara":t.children.push(this.parseMathElement(e));break;case"sdt":t.children.push(...this.parseSdt(e));break;case"ins":t.children.push(this.parseInserted(e));break;case"del":t.children.push(this.parseDeleted(e));break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Paragraph Element:${e.localName}`,"color:#f75607")}var r,n}),0===t.children.length){let e={type:U.Break,break:W.TextWrapping},r={type:U.Run,children:[e]};t.children=[r]}return t}parseParagraphProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{if(re(e,t.props,P))return!0;switch(e.localName){case"cnfStyle":t.className=st.classNameOfCnfStyle(e);break;case"framePr":this.parseFrame(e,t);break;case"pStyle":t.styleName=P.attr(e,"val");break;default:return!1}return!0})}parseFrame(e,t){"drop"==P.attr(e,"dropCap")&&(t.cssStyle.float="left")}parseHyperlink(e){let t={type:U.Hyperlink,children:[]},r=P.attr(e,"anchor"),n=P.attr(e,"id");return r&&(t.href="#"+r),n&&(t.id=n),at.foreach(e,e=>{if("r"===e.localName)t.children.push(this.parseRun(e));else this.options.debug&&console.warn(`DOCX:%c Unknown Hyperlink Element:${e.localName}`,"color:#f75607")}),t}parseSmartTag(e,t){var r={type:U.SmartTag,parent:t,children:[]},n=P.attr(e,"uri"),a=P.attr(e,"element");n&&(r.uri=n),a&&(r.element=a);for(const t of P.elements(e))if("r"===t.localName)r.children.push(this.parseRun(t));return r}parseRun(e){let t={type:U.Run,children:[]};return at.foreach(e,e=>{switch((e=this.checkAlternateContent(e)).localName){case"rPr":this.parseRunProperties(e,t);break;case"t":t.children.push(this.parseText(e,U.Text));break;case"delText":t.children.push(this.parseText(e,U.DeletedText));break;case"commentReference":t.children.push(new Xe(P.attr(e,"id")));break;case"fldSimple":t.children.push({type:U.SimpleField,instruction:P.attr(e,"instr"),lock:P.boolAttr(e,"lock",!1),dirty:P.boolAttr(e,"dirty",!1)});break;case"instrText":t.fieldRun=!0,t.children.push(this.parseText(e,U.Instruction));break;case"fldChar":t.fieldRun=!0,t.children.push({type:U.ComplexField,charType:P.attr(e,"fldCharType"),lock:P.boolAttr(e,"lock",!1),dirty:P.boolAttr(e,"dirty",!1)});break;case"noBreakHyphen":t.children.push({type:U.NoBreakHyphen});break;case"br":t.children.push({type:U.Break,break:P.attr(e,"type")||"textWrapping",props:{clear:P.attr(e,"clear")}});break;case"lastRenderedPageBreak":t.children.push({type:U.LastRenderedPageBreak});break;case"sym":t.children.push({type:U.Symbol,font:P.attr(e,"font"),char:P.attr(e,"char")});break;case"ptab":break;case"tab":t.children.push({type:U.Tab});break;case"footnoteReference":t.children.push({type:U.FootnoteReference,id:P.attr(e,"id")});break;case"endnoteReference":t.children.push({type:U.EndnoteReference,id:P.attr(e,"id")});break;case"drawing":t.children.push(this.parseDrawing(e));break;case"pict":t.children.push(this.parseVmlPicture(e));break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Run Element:${e.localName}`,"color:#f75607")}}),t}parseText(e,t){let r={type:t,text:""},n=e.textContent;return"preserve"===P.attr(e,"xml:space")&&(n=n.split(/\s/).join(" ")),r.text=n,n.length>0&&(r.children=this.parseCharacter(n)),r}parseCharacter(e){let t=[];return t=e.match(/[\u4e00-\u9fa5]+/g)?e.split(""):e.match(/\S+|\s+/g),t.map(e=>({type:U.Character,char:e}))}parseRunProperties(e,t){this.parseDefaultProperties(e,t.cssStyle={},null,e=>{switch(e.localName){case"rStyle":t.styleName=P.attr(e,"val");break;case"vertAlign":t.verticalAlign=st.valueOfVertAlign(e,!0);break;case"spacing":this.parseSpacing(e,t);break;default:return!1}return!0})}parseMathElement(e){const t=`${e.localName}Pr`,r={type:et[e.localName],children:[]};return at.foreach(e,e=>{if(et[e.localName])r.children.push(this.parseMathElement(e));else if("r"==e.localName){let t=this.parseRun(e);t.type=U.MmlRun,r.children.push(t)}else e.localName==t&&(r.props=this.parseMathProperties(e))}),r}parseMathProperties(e){const t={};for(const r of P.elements(e))switch(r.localName){case"chr":t.char=P.attr(r,"val");break;case"vertJc":t.verticalJustification=P.attr(r,"val");break;case"pos":t.position=P.attr(r,"val");break;case"degHide":t.hideDegree=P.boolAttr(r,"val");break;case"begChr":t.beginChar=P.attr(r,"val");break;case"endChr":t.endChar=P.attr(r,"val");break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Math Property:${r.localName}`,"color:#f75607")}return t}parseVmlPicture(e){const t={type:U.VmlPicture,children:[]};for(const r of P.elements(e)){const e=_e(r,this);e&&t.children.push(e)}return t}checkAlternateContent(e){var t;if("AlternateContent"!=e.localName)return e;let r=P.element(e,"Choice");if(r){let t=P.attr(r,"Requires"),n=e.lookupNamespaceURI(t);if(Qe.includes(n))return r.firstElementChild}return null===(t=P.element(e,"Fallback"))||void 0===t?void 0:t.firstElementChild}parseDrawing(e){for(let t of P.elements(e))switch(t.localName){case"inline":case"anchor":return this.parseDrawingWrapper(t);default:this.options.debug&&console.warn(`DOCX:%c Unknown Drawing Element:${t.localName}`,"color:#f75607")}}parseDrawingWrapper(e){var t,r;let n=P.boolAttr(e,"layoutInCell"),a=P.boolAttr(e,"locked"),s=P.boolAttr(e,"behindDoc"),i=P.boolAttr(e,"allowOverlap"),l=P.boolAttr(e,"simplePos"),o=P.intAttr(e,"relativeHeight",1),c={left:P.lengthAttr(e,"distL",m),right:P.lengthAttr(e,"distR",m),top:P.lengthAttr(e,"distT",m),bottom:P.lengthAttr(e,"distB",m),distL:P.intAttr(e,"distL",0),distR:P.intAttr(e,"distR",0),distT:P.intAttr(e,"distT",0),distB:P.intAttr(e,"distB",0)},d={type:U.Drawing,children:[],cssStyle:{},props:{localName:e.localName,wrapType:null,layoutInCell:n,locked:a,behindDoc:s,allowOverlap:i,simplePos:l,relativeHeight:o,distance:c,extent:{}}},p={relative:"page",align:"left",offset:"0pt",origin:0},h={relative:"page",align:"top",offset:"0pt",origin:0};for(let n of P.elements(e))switch(n.localName){case"simplePos":l&&(p.offset=P.lengthAttr(n,"x",m),h.offset=P.lengthAttr(n,"y",m),p.origin=P.intAttr(n,"x",0),h.origin=P.intAttr(n,"y",0));break;case"positionH":if(!l){let e=P.element(n,"align"),r=P.element(n,"posOffset");p.relative=null!==(t=P.attr(n,"relativeFrom"))&&void 0!==t?t:p.relative,e&&(p.align=e.textContent),r&&(p.offset=at.sizeValue(r,m),p.origin=at.parseTextContent(r)),d.props.posX=p}break;case"positionV":if(!l){let e=P.element(n,"align"),t=P.element(n,"posOffset");h.relative=null!==(r=P.attr(n,"relativeFrom"))&&void 0!==r?r:h.relative,e&&(h.align=e.textContent),t&&(h.offset=at.sizeValue(t,m),h.origin=at.parseTextContent(t)),d.props.posY=h}break;case"extent":d.props.extent={width:P.lengthAttr(n,"cx",m),height:P.lengthAttr(n,"cy",m),origin_width:P.intAttr(n,"cx",0),origin_height:P.intAttr(n,"cy",0)};break;case"effectExtent":d.props.effectExtent={top:P.lengthAttr(n,"t",m),bottom:P.lengthAttr(n,"b",m),left:P.lengthAttr(n,"l",m),right:P.lengthAttr(n,"r",m),origin_top:P.intAttr(n,"t",0),origin_bottom:P.intAttr(n,"b",0),origin_left:P.intAttr(n,"l",0),origin_right:P.intAttr(n,"r",0)};break;case"graphic":let e=this.parseGraphic(n);e&&d.children.push(e);break;case"wrapTopAndBottom":d.props.wrapType=X.TopAndBottom;break;case"wrapNone":d.props.wrapType=X.None;break;case"wrapSquare":d.props.wrapType=X.Square,d.props.wrapText=P.attr(n,"wrapText");break;case"wrapThrough":case"wrapTight":d.props.wrapType=X.Tight,d.props.wrapText=P.attr(n,"wrapText");let a=P.element(n,"wrapPolygon");this.parsePolygon(a,d);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Drawing Property:${n.localName}`,"color:#f75607")}let{extent:u,effectExtent:f}=d.props,g=u.origin_width+f.origin_left+f.origin_right,b=u.origin_height+f.origin_top+f.origin_bottom;if(d.cssStyle.width=w(g,m),d.cssStyle.height=w(b,m),"inline"===e.localName&&(d.props.wrapType=X.Inline),"anchor"===e.localName){d.cssStyle.position="relative",d.cssStyle["z-index"]=s?-1:o,this.options.ignoreImageWrap&&(d.props.wrapType=X.Inline);let{wrapText:e,wrapType:t}=d.props;switch(t){case X.TopAndBottom:d.cssStyle.float="left",d.cssStyle.width="100%",d.cssStyle["text-align"]=p.align,d.cssStyle.transform=`translate(${p.offset},0)`,d.cssStyle["margin-top"]=`calc(${h.offset} - ${c.top})`,d.cssStyle["shape-outside"]=`inset(calc(${h.offset} - ${c.top}) 0 0 0)`,d.cssStyle["box-sizing"]="content-box",d.cssStyle["padding-top"]=c.top,d.cssStyle["padding-bottom"]=c.bottom;break;case X.None:switch(d.cssStyle.position="absolute",p.align){case"left":case"right":d.cssStyle[p.align]=p.offset;break;case"center":d.cssStyle.left="50%",d.cssStyle.transform="translateX(-50%)"}d.cssStyle.top=h.offset;break;case X.Square:switch(d.cssStyle.float="left"===e?"right":"left",d.cssStyle["margin-top"]=`calc(${h.offset} - ${c.top})`,d.cssStyle["shape-outside"]=`inset(calc(${h.offset} - ${c.top}) 0 0 0)`,e){case"left":switch(p.align){case"left":d.cssStyle["margin-right"]=`calc(100% - ${u.width} - ${p.offset} - ${c.right})`;break;case"right":d.cssStyle["margin-right"]=`calc(${p.offset} - ${c.right})`;break;case"center":d.cssStyle["margin-right"]=`calc( 50% - (${u.width} - ${p.offset}) / 2 - ${c.right} )`}break;case"right":switch(p.align){case"left":d.cssStyle["margin-left"]=`calc(${p.offset} - ${c.left})`;break;case"right":d.cssStyle["margin-left"]=`calc(100% - ${u.width} - ${p.offset} - ${c.left})`,d.cssStyle["margin-right"]=`calc(${p.offset} - ${c.right})`;break;case"center":d.cssStyle["margin-left"]=`calc( 50% - (${u.width} - ${p.offset} ) / 2 - ${c.left} )`}break;default:console.error(`text wrap picture on ${e} is not supported!`)}d.cssStyle["box-sizing"]="content-box",d.cssStyle["padding-top"]=c.top,d.cssStyle["padding-bottom"]=c.bottom,d.cssStyle["padding-left"]=c.left,d.cssStyle["padding-right"]=c.right;break;case X.Through:case X.Tight:d.cssStyle.float="left"===e?"right":"left";let{polygonData:t}=d.props;switch(d.cssStyle["shape-outside"]=`polygon(${t})`,d.cssStyle["margin-top"]=h.offset,e){case"left":switch(p.align){case"left":d.cssStyle["margin-right"]=`calc(100% - ${u.width} - ${p.offset})`;break;case"right":d.cssStyle["margin-right"]=p.offset;break;case"center":d.cssStyle["margin-right"]=`calc( 50% - (${u.width} - ${p.offset}) / 2 )`}break;case"right":switch(p.align){case"left":d.cssStyle["margin-left"]=p.offset;break;case"right":d.cssStyle["margin-left"]=`calc(100% - ${u.width} - ${p.offset})`;break;case"center":d.cssStyle["margin-left"]=`calc( 50% - (${u.width} - ${p.offset} ) / 2 )`}break;default:console.error(`text wrap picture on ${e} is not supported!`)}}}return d}parsePolygon(e,t){let r=[],{wrapText:n,distance:a,extent:s,posX:i,posY:l}=t.props;at.foreach(e,e=>{var t,o,c,d,p,h,u,f,g,b,y,v;let k,x,S,C,N,T,M=P.intAttr(e,"x",0),A=P.intAttr(e,"y",0);switch(n){case"left":switch(i.align){case"left":k=M*s.origin_width/21600-a.distL,x=A*s.origin_height/21600+l.origin,N=null!==(t=w(k,m))&&void 0!==t?t:"0pt",T=null!==(o=w(x,m))&&void 0!==o?o:"0pt";break;case"right":k=M*s.origin_width/21600+i.origin-a.distL,x=A*s.origin_height/21600+l.origin,N=null!==(c=w(k,m))&&void 0!==c?c:"0pt",T=null!==(d=w(x,m))&&void 0!==d?d:"0pt";break;case"center":k=M*s.origin_width/21600+i.origin-a.distL,x=A*s.origin_height/21600+l.origin,N=null!==(p=w(k,m))&&void 0!==p?p:"0pt",T=null!==(h=w(x,m))&&void 0!==h?h:"0pt"}break;case"right":switch(i.align){case"left":k=M*s.origin_width/21600+i.origin+a.distR,x=A*s.origin_height/21600+l.origin,N=null!==(u=w(k,m))&&void 0!==u?u:"0pt",T=null!==(f=w(x,m))&&void 0!==f?f:"0pt";break;case"right":k=M*s.origin_width/21600+i.origin+a.distR,x=A*s.origin_height/21600+l.origin,S=null!==(g=w(k,m))&&void 0!==g?g:"0pt",C=null!==(b=w(x,m))&&void 0!==b?b:"0pt",N=`calc(100% + ${S} - ${s.width})`,T=C;break;case"center":k=M*s.origin_width/21600+i.origin+a.distR,x=A*s.origin_height/21600+l.origin,S=null!==(y=w(k,m))&&void 0!==y?y:"0pt",C=null!==(v=w(x,m))&&void 0!==v?v:"0pt",N=`calc(50% + ${S})`,T=C}break;default:console.error(`text wrap picture on ${n} is not supported!`)}let E=`${N} ${T}`;r.push(E)}),t.props.polygonData=r.join(",")}parseGraphic(e){let t=P.element(e,"graphicData");for(let e of P.elements(t))switch(e.localName){case"wsp":return this.parseShape(e);case"pic":return this.parsePicture(e);default:this.options.debug&&console.warn(`DOCX:%c Unknown Graphic Element:${e.localName}`,"color:#f75607")}return null}parseShape(e){let t={type:U.Shape,cssStyle:{}};for(let r of P.elements(e))switch(r.localName){case"cNvPr":case"cNvSpPr":case"cNvCnPr":case"spPr":return this.parseShapeProperties(r,t);default:this.options.debug&&console.warn(`DOCX:%c Unknown Shape Element:${r.localName}`,"color:#f75607")}return null}parseShapeProperties(e,t){for(let r of P.elements(e))if("xfrm"===r.localName){P.boolAttr(r,"flipH")&&(t.props.is_transform=!0,t.props.transform.scaleX=-1),P.boolAttr(r,"flipV")&&(t.props.is_transform=!0,t.props.transform.scaleY=-1);let e=P.numberAttr(r,"rot",x,0);e&&(t.props.is_transform=!0,t.props.transform.rotate=e),this.parseTransform2D(r,t)}else this.options.debug&&console.warn(`DOCX:%c Unknown Shape Property:${r.localName}`,"color:#f75607");return null}parsePicture(e){let t={type:U.Image,src:"",cssStyle:{},props:{is_clip:!1,clip:{},is_transform:!1,transform:{}}};for(let r of P.elements(e))switch(r.localName){case"nvPicPr":break;case"blipFill":this.parseBlipFill(r,t);break;case"spPr":this.parseShapeProperties(r,t);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Picture Element:${r.localName}`,"color:#f75607")}return t}parseTransform2D(e,t){for(let r of P.elements(e))switch(r.localName){case"ext":let e,n,{transform:a}=t.props,s=P.intAttr(r,"cx",0),i=P.intAttr(r,"cy",0);if(null==a?void 0:a.rotate){let t=Math.PI*a.rotate/180;e=Math.abs(s*Math.cos(t)+i*Math.sin(t)),n=Math.abs(s*Math.sin(t)+i*Math.cos(t))}else e=s,n=i;t.props.width=w(e,h,!1),t.props.height=w(n,h,!1),t.cssStyle.width=w(e,m,!0),t.cssStyle.height=w(n,m,!0);break;case"off":t.cssStyle.left=P.lengthAttr(r,"x",m),t.cssStyle.top=P.lengthAttr(r,"y",m);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Transform2D Element:${r.localName}`,"color:#f75607")}}parseBlipFill(e,t){for(let r of P.elements(e))switch(r.localName){case"blip":t.src=P.attr(r,"embed"),this.parseBlip(r,t);break;case"srcRect":let e=P.numberAttr(r,"l",y,0),n=P.numberAttr(r,"r",y,0),a=P.numberAttr(r,"t",y,0),s=P.numberAttr(r,"b",y,0);t.props.is_clip=[e,n,a,s].some(e=>0!==e),t.props.clip.type="inset",t.props.clip.path={top:a,right:n,bottom:s,left:e};break;case"stretch":case"tile":break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Blip Fill Element:${r.localName}`,"color:#f75607")}}parseBlip(e,t){for(let r of P.elements(e))switch(r.localName){case"alphaBiLevel":case"alphaCeiling":case"alphaFloor":case"alphaInv":case"alphaMod":break;case"alphaModFix":let e=P.lengthAttr(r,"amt",k);t.cssStyle.opacity=e;break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Blip Element:${r.localName}`,"color:#f75607")}}parseTable(e){let t={type:U.Table,children:[]};for(const r of P.elements(e))switch(r.localName){case"tblPr":this.parseTableProperties(r,t);break;case"tblGrid":t.columns=this.parseTableColumns(r);break;case"tr":t.children.push(this.parseTableRow(r));break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Table Element:${r.localName}`,"color:#f75607")}return t}parseTableColumns(e){let t=[];for(const r of P.elements(e))switch(r.localName){case"gridCol":t.push({width:P.lengthAttr(r,"w")});break;case"tblGridChange":break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Table Columns Element:${r.localName}`,"color:#f75607")}return t}parseTableProperties(e,t){switch(t.cssStyle={},t.cellStyle={},this.parseDefaultProperties(e,t.cssStyle,t.cellStyle,e=>{switch(e.localName){case"tblStyle":t.styleName=P.attr(e,"val");break;case"tblLook":t.className=st.classNameOftblLook(e);break;case"tblpPr":this.parseTablePosition(e,t);break;case"tblStyleColBandSize":t.colBandSize=P.intAttr(e,"val");break;case"tblStyleRowBandSize":t.rowBandSize=P.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:this.options.debug&&console.warn(`DOCX:%c Unknown Table Align:${t.cssStyle["text-align"]}`,"color:#f75607")}}parseTablePosition(e,t){if(this.options.ignoreTableWrap)return!1;let r=P.lengthAttr(e,"topFromText"),n=P.lengthAttr(e,"bottomFromText"),a=P.lengthAttr(e,"rightFromText"),s=P.lengthAttr(e,"leftFromText");t.cssStyle.float="left",t.cssStyle["margin-bottom"]=st.addSize(t.cssStyle["margin-bottom"],n),t.cssStyle["margin-left"]=st.addSize(t.cssStyle["margin-left"],s),t.cssStyle["margin-right"]=st.addSize(t.cssStyle["margin-right"],a),t.cssStyle["margin-top"]=st.addSize(t.cssStyle["margin-top"],r)}parseTableRow(e){let t={type:U.Row,children:[]};for(const r of P.elements(e))switch(r.localName){case"tc":t.children.push(this.parseTableCell(r));break;case"trPr":case"tblPrEx":this.parseTableRowProperties(r,t);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Table Row Element:${r.localName}`,"color:#f75607")}return t}parseTableRowProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,e=>{switch(e.localName){case"cnfStyle":t.className=st.classNameOfCnfStyle(e);break;case"tblHeader":t.isHeader=P.boolAttr(e,"val",!0);break;case"gridBefore":t.gridBefore=P.intAttr(e,"val");break;case"gridAfter":t.gridAfter=P.intAttr(e,"val");break;default:return!1}return!0})}parseTableCell(e){let t={type:U.Cell,children:[]};for(const r of P.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);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Table Cell Element:${r.localName}`,"color:#f75607")}return t}parseTableCellProperties(e,t){t.cssStyle=this.parseDefaultProperties(e,{},null,e=>{var r;switch(e.localName){case"gridSpan":t.span=P.intAttr(e,"val",null);break;case"vMerge":t.verticalMerge=null!==(r=P.attr(e,"val"))&&void 0!==r?r:"continue";break;case"cnfStyle":t.className=st.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 n of P.elements(e))if("textDirection"===n.localName){const e=r[P.attr(n,"val")]||{writingMode:"horizontal-tb"};t.cssStyle["writing-mode"]=e.writingMode,t.cssStyle.transform=e.transform}}parseDefaultProperties(e,t=null,r=null,n=null){return t=t||{},at.foreach(e,a=>{if(!(null==n?void 0:n(a)))switch(a.localName){case"b":t["font-weight"]=P.boolAttr(a,"val",!0)?"bold":"normal";break;case"bidi":case"bCs":case"cs":case"dstrike":case"eastAsianLayout":case"effect":case"em":case"emboss":case"fitText":case"iCs":case"imprint":case"kern":case"noProof":case"outline":case"rPrChange":case"rtl":case"shadow":case"specVanish":case"szCs":case"vertAlign":case"w":case"webHidden":case"noWrap":break;case"bdr":t.border=st.valueOfBorder(a);break;case"caps":t["text-transform"]=P.boolAttr(a,"val",!0)?"uppercase":"none";break;case"color":t.color=at.colorAttr(a,"val",null,Je);break;case"highlight":t["background-color"]=at.colorAttr(a,"val",null,Ze);break;case"i":t["font-style"]=P.boolAttr(a,"val",!0)?"italic":"normal";break;case"lang":t.$lang=P.attr(a,"val");break;case"position":t.verticalAlign=P.lengthAttr(a,"val",f);break;case"rFonts":this.parseFont(a,t);break;case"shd":t["background-color"]=at.colorAttr(a,"fill",null,Ke);break;case"smallCaps":t["font-variant"]=P.boolAttr(a,"val",!0)?"small-caps":"none";break;case"strike":t["text-decoration"]=P.boolAttr(a,"val",!0)?"line-through":"none";break;case"sz":t["font-size"]=t["min-height"]=P.lengthAttr(a,"val",f);break;case"u":this.parseUnderline(a,t);break;case"vanish":P.boolAttr(a,"val",!0)&&(t.display="none");break;case"jc":t["text-align"]=st.valueOfJc(a);break;case"textAlignment":case"vAlign":t["vertical-align"]=st.valueOfTextAlignment(a);break;case"tcW":this.options.ignoreWidth;break;case"tblW":t.width=st.valueOfSize(a,"w");break;case"trHeight":this.parseTrHeight(a,t);break;case"ind":case"tblInd":this.parseIndentation(a,t);break;case"tblBorders":this.parseBorderProperties(a,r||t);break;case"tblCellSpacing":t["border-spacing"]=st.valueOfMargin(a),t["border-collapse"]="separate";break;case"pBdr":case"tcBorders":this.parseBorderProperties(a,t);break;case"tblCellMar":case"tcMar":this.parseMarginProperties(a,r||t);break;case"tblLayout":t["table-layout"]=st.valueOfTblLayout(a);break;case"wordWrap":P.boolAttr(a,"val")&&(t["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":t.hyphens=P.boolAttr(a,"val",!0)?"none":"auto";break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Property Element:${e.localName}.${a.localName}`,"color:green")}}),t}parseUnderline(e,t){let r=P.attr(e,"val");if(null==r)return;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";break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Underline Property:${r}`,"color:#f75607")}let n=at.colorAttr(e,"color");n&&(t["text-decoration-color"]=n)}parseFont(e,t){let r=new Set,n=P.attr(e,"ascii"),a=st.themeValue(e,"asciiTheme");r.add(n).add(a);let s=P.attr(e,"eastAsia"),i=st.themeValue(e,"eastAsiaTheme");r.add(s).add(i);let l=P.attr(e,"cs"),o=st.themeValue(e,"cstheme");r.add(l).add(o);let c=P.attr(e,"hAnsi"),d=st.themeValue(e,"hAnsiTheme");r.add(c).add(d);let p=[...r].filter(e=>e);p.length>0&&(t["font-family"]=p.join(", ")),t._hint=P.attr(e,"hint")}parseIndentation(e,t){let r={};for(const t of P.attrs(e))switch(t.localName){case"end":r.end=P.lengthAttr(e,"end");break;case"endChars":r.endCharacters=P.lengthAttr(e,"endChars");break;case"firstLine":r.firstLine=P.lengthAttr(e,"firstLine");break;case"firstLineChars":r.firstLineChars=P.lengthAttr(e,"firstLineChars");break;case"hanging":r.hanging=P.lengthAttr(e,"hanging");break;case"hangingChars":r.hangingChars=P.lengthAttr(e,"hangingChars");break;case"left":r.left=P.lengthAttr(e,"left");break;case"leftChars":r.leftChars=P.lengthAttr(e,"leftChars");break;case"right":r.right=P.lengthAttr(e,"right");break;case"rightChars":r.rightChars=P.lengthAttr(e,"rightChars");break;case"start":r.start=P.lengthAttr(e,"start");break;case"startChars":r.startChars=P.lengthAttr(e,"startChars");break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Indentation Property:${t.localName}`,"color:#f75607")}r.firstLine&&(t["text-indent"]=r.firstLine),r.hanging&&(t["text-indent"]=`-${r.hanging}`),(r.left||r.start)&&(t["padding-left"]=r.left||r.start),(r.right||r.end)&&(t["padding-right"]=r.right||r.end)}parseSpacing(e,t){for(const r of P.attrs(e))if("val"===r.localName)t.cssStyle["margin-bottom"]=P.lengthAttr(e,"val");else this.options.debug&&console.warn(`DOCX:%c Unknown Spacing Property:${r.localName}`,"color:#f75607")}parseMarginProperties(e,t){for(const r of P.elements(e))switch(r.localName){case"left":t["padding-left"]=st.valueOfMargin(r);break;case"right":t["padding-right"]=st.valueOfMargin(r);break;case"top":t["padding-top"]=st.valueOfMargin(r);break;case"bottom":t["padding-bottom"]=st.valueOfMargin(r);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Margin Property:${r.localName}`,"color:#f75607")}}parseTrHeight(e,t){P.attr(e,"hRule"),t.height=P.lengthAttr(e,"val")}parseBorderProperties(e,t){for(const r of P.elements(e))switch(r.localName){case"start":case"left":t["border-left"]=st.valueOfBorder(r);break;case"end":case"right":t["border-right"]=st.valueOfBorder(r);break;case"top":t["border-top"]=st.valueOfBorder(r);break;case"bottom":t["border-bottom"]=st.valueOfBorder(r);break;default:this.options.debug&&console.warn(`DOCX:%c Unknown Border Property:${r.localName}`,"color:#f75607")}}}const nt=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"];class at{static foreach(e,t){for(let r=0;r<e.children.length;r++){let n=e.children[r];n.nodeType==Node.ELEMENT_NODE&&t(n,r)}}static colorAttr(e,t,r=null,n="black"){let a=P.attr(e,t);if(a)return"auto"==a?n:nt.includes(a)?a:`#${a}`;let s=P.attr(e,"themeColor");return s?`var(--docx-${s}-color)`:r}static sizeValue(e,t=u){return w(e.textContent,t)}static parseTextContent(e,t=0){let r=e.textContent;return r?parseInt(r):t}}class st{static themeValue(e,t){let r=P.attr(e,t);return r?`var(--docx-${r}-font)`:null}static valueOfSize(e,t){let r=u;switch(P.attr(e,"type")){case"dxa":break;case"pct":r=v;break;case"auto":return"auto"}return P.lengthAttr(e,t,r)}static valueOfMargin(e){return P.lengthAttr(e,"w")}static valueOfBorder(e){let t=P.attr(e,"val");if("nil"==t)return"none";let r=at.colorAttr(e,"color");return`${P.lengthAttr(e,"sz",g)} ${t} ${"auto"==r?Ye:r}`}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"==P.attr(e,"type")?"fixed":"auto"}static classNameOfCnfStyle(e){const t=P.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){let t=P.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){let r=P.attr(e,"val");switch(r){case"subscript":return"sub";case"superscript":return t?"sup":"super"}return t?null:r}static valueOfTextAlignment(e){let t=P.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 null==e?t:null==t?e:`calc(${e} + ${t})`}static classNameOftblLook(e){const t=P.hexAttr(e,"val",0);let r="";return(P.boolAttr(e,"firstRow")||32&t)&&(r+=" first-row"),(P.boolAttr(e,"lastRow")||64&t)&&(r+=" last-row"),(P.boolAttr(e,"firstColumn")||128&t)&&(r+=" first-col"),(P.boolAttr(e,"lastColumn")||256&t)&&(r+=" last-col"),(P.boolAttr(e,"noHBand")||512&t)&&(r+=" no-hband"),(P.boolAttr(e,"noVBand")||1024&t)&&(r+=" no-vband"),r.trim()}}const it={position:0,leader:"none",style:"left"};function lt(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}function ot(e,t,r,n=.75){const a=e.closest("p"),s=e.getBoundingClientRect(),i=a.getBoundingClientRect(),l=getComputedStyle(a),o=(null==t?void 0:t.length)>0?t.sort((e,t)=>e.position-t.position):[it],c=o[o.length-1],d=i.width*n,p=parseFloat(r);let h=c.position+p;if(h<d)for(;h<d&&o.length<50;h+=p)o.push(Object.assign(Object.assign({},it),{position:h}));const u=parseFloat(l.marginLeft),m=i.left+u,f=(s.left-m)*n,g=o.find(e=>"clear"!=e.style&&e.position>f);if(null==g)return;let b=1;if("right"==g.style||"center"==g.style){const t=Array.from(a.querySelectorAll(`.${e.className}`)),r=t.indexOf(e)+1,s=document.createRange();s.setStartBefore(e),r<t.length?s.setEndBefore(t[r]):s.setEndAfter(a);const l="center"===g.style?.5:1,o=s.getBoundingClientRect(),c=o.left+l*o.width-(i.left-u);b=g.position-c*n}else b=g.position-f;switch(e.innerHTML="&nbsp;",e.style.textDecoration="inherit",e.style.wordSpacing=`${b.toFixed(0)}pt`,g.leader){case"dot":case"middleDot":e.style.textDecorationLine="underline",e.style.textDecorationStyle="dotted";break;case"hyphen":e.style.textDecorationLine="underline",e.style.textDecorationStyle="dashed";break;case"heavy":case"underscore":e.style.textDecorationLine="underline",e.style.textDecorationStyle="solid";break;default:e.style.textDecorationLine="none"}}class ct{constructor({sectProps:e,children:t=[],stack:r=[],isSplit:n=!1,isFirstPage:a=!1,isLastPage:s=!1,breakIndex:i=new Set,contentElement:l,checkingOverflow:o=!1}){this.type=U.Page,this.level=1,this.pageId=B(),this.sectProps=e,this.children=t,this.stack=r,this.isSplit=n,this.isFirstPage=a,this.isLastPage=s,this.breakIndex=i,this.contentElement=l,this.checkingOverflow=o}}const dt="http://www.w3.org/2000/svg",pt="http://www.w3.org/1998/Math/MathML";var ht;!function(e){e.TRUE="true",e.FALSE="false",e.UNKNOWN="undetected"}(ht||(ht={}));class ut{constructor(){this.className="docx",this.styleMap={},this.currentPart=null,this.tableVerticalMerges=[],this.currentVerticalMerge=null,this.tableCellPositions=[],this.currentCellPosition=null,this.footnoteMap={},this.endnoteMap={},this.currentEndnoteIds=[],this.usedHederFooterParts=[],this.currentTabs=[],this.tabsTimeout=0,this.commentMap={},this.tasks=[],this.postRenderTasks=[]}later(e){this.postRenderTasks.push(e)}render(e,r){return n(this,arguments,void 0,function*(e,r,n=null,a){var s;this.document=e,this.options=a,this.className=a.className,this.rootSelector=a.inWrapper?`.${this.className}-wrapper`:":root",this.styleMap=null,this.wrapper=r,n=n||r,this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight),bt(n),bt(r),kt(n,"docxjs library predefined styles"),n.appendChild(this.renderDefaultStyle()),e.themePart&&(kt(n,"docxjs document theme values"),this.renderTheme(e.themePart,n)),null!=e.stylesPart&&(this.styleMap=this.processStyles(e.stylesPart.styles),kt(n,"docxjs document styles"),n.appendChild(this.renderStyles(e.stylesPart.styles))),e.numberingPart&&(this.processNumberings(e.numberingPart.domNumberings),kt(n,"docxjs document numbering styles"),n.appendChild(this.renderNumbering(e.numberingPart.domNumberings,n))),!a.ignoreFonts&&e.fontTablePart&&this.renderFontTable(e.fontTablePart,n),e.footnotesPart&&(this.footnoteMap=t.keyBy(e.footnotesPart.rootElement.children,"id")),e.endnotesPart&&(this.endnoteMap=t.keyBy(e.endnotesPart.rootElement.children,"id")),e.settingsPart&&(this.defaultTabSize=null===(s=e.settingsPart.settings)||void 0===s?void 0:s.defaultTabStop);let i=this.renderPages(e.documentPart.body);this.options.inWrapper?r.appendChild(this.renderWrapper(i)):yt(r,i),this.commentHighlight&&a.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),this.postRenderTasks.forEach(e=>e()),this.refreshTabStops()})}renderDefaultStyle(){let e=this.className,t=`\n\t\t\t.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; } \n\t\t\t.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }\n\t\t\t.${e} { color: black; hyphens: auto; text-underline-position: from-font; }\n\t\t\tsection.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }\n section.${e}>header { position: absolute; top: 0; z-index: 1; display: flex; align-items: flex-end; }\n\t\t\tsection.${e}>article { z-index: 1; }\n\t\t\tsection.${e}>footer { position: absolute; bottom: 0; z-index: 1; }\n\t\t\t.${e} table { border-collapse: collapse; }\n\t\t\t.${e} table td, .${e} table th { vertical-align: top; }\n\t\t\t.${e} p { margin: 0pt; min-height: 1em; }\n\t\t\t.${e} span { white-space: pre-wrap; overflow-wrap: break-word; }\n\t\t\t.${e} a { color: inherit; text-decoration: inherit; }\n\t\t\t.${e} img, ${e} svg { vertical-align: baseline; }\n\t\t\t.${e} .clearfix::after { content: ""; display: block; line-height: 0; clear: both; }\n\t\t`;return this.options.renderComments&&(t+=`\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`),vt(t)}renderTheme(e,t){var r,n;const a={},s=null===(r=e.theme)||void 0===r?void 0:r.fontScheme;s&&(s.majorFont&&(a["--docx-majorHAnsi-font"]=s.majorFont.latinTypeface),s.minorFont&&(a["--docx-minorHAnsi-font"]=s.minorFont.latinTypeface));const i=null===(n=e.theme)||void 0===n?void 0:n.colorScheme;if(i)for(let[e,t]of Object.entries(i.colors))a[`--docx-${e}-color`]=`#${t}`;const l=this.styleToString(`.${this.className}`,a);t.appendChild(vt(l))}processStyleName(e){return e?`${this.className}_${R(e)}`:this.className}processStyles(e){const r=t.keyBy(e.filter(e=>null!=e.id),"id");for(const n of e.filter(e=>e.basedOn)){let e=r[n.basedOn];if(e){n.paragraphProps=t.merge(n.paragraphProps,e.paragraphProps),n.runProps=t.merge(n.runProps,e.runProps);for(const t of e.rulesets){const e=n.rulesets.find(e=>e.target==t.target);e?this.copyStyleProperties(t.declarations,e.declarations):n.rulesets.push(Object.assign(Object.assign({},t),{declarations:Object.assign({},t.declarations)}))}}else this.options.debug&&console.warn(`Can't find base style ${n.basedOn}`)}for(let t of e)t.cssName=this.processStyleName(t.id);return r}renderStyles(e){var r;let n="";const a=this.styleMap,s=t.keyBy(e.filter(e=>e.isDefault),"target");for(const t of e){let e=t.rulesets;if(t.linked){let r=t.linked&&a[t.linked];r?e=e.concat(r.rulesets):this.options.debug&&console.warn(`Can't find linked style ${t.linked}`)}for(const a of e){let e=`${null!==(r=t.type)&&void 0!==r?r:""}.${t.cssName}`;t.type!=a.target&&(e+=` ${a.target}`),s[t.type]==t&&(e=`.${this.className} ${t.type}, `+e),n+=this.styleToString(e,a.declarations)}}return vt(n)}processNumberings(e){var t;for(let r of e.filter(e=>e.pStyleName)){const e=this.findStyle(r.pStyleName);(null===(t=null==e?void 0:e.paragraphProps)||void 0===t?void 0:t.numbering)&&(e.paragraphProps.numbering.level=r.level)}}renderNumbering(e,t){let r="",n=[];for(let a of e){let e=`p.${this.numberingClass(a.id,a.level)}`,s="none";if(a.bullet){let n=`--${this.className}-${a.bullet.src}`.toLowerCase();r+=this.styleToString(`${e}:before`,{content:"' '",display:"inline-block",background:`var(${n})`},a.bullet.style),this.document.loadNumberingImage(a.bullet.src).then(e=>{let r=`${this.rootSelector} { ${n}: url(${e}) }`;t.appendChild(vt(r))})}else if(a.levelText){let t=this.numberingCounter(a.id,a.level);const s=t+" "+(a.start-1);a.level>0&&(r+=this.styleToString(`p.${this.numberingClass(a.id,a.level-1)}`,{"counter-set":s})),n.push(s),r+=this.styleToString(`${e}:before`,Object.assign({content:this.levelTextToContent(a.levelText,a.suff,a.id,this.numFormatToCssValue(a.format)),"counter-increment":t},a.rStyle))}else s=this.numFormatToCssValue(a.format);r+=this.styleToString(e,Object.assign({display:"list-item","list-style-position":"inside","list-style-type":s},a.pStyle))}return n.length>0&&(r+=this.styleToString(this.rootSelector,{"counter-reset":n.join(" ")})),vt(r)}numberingClass(e,t){return`${this.className}-num-${e}-${t}`}styleToString(e,t,r=null){let n=`${e} {\r\n`;for(const e in t)e.startsWith("$")||(n+=` ${e}: ${t[e]};\r\n`);return r&&(n+=r),n+"}\r\n"}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}levelTextToContent(e,t,r,n){var a;return`"${e.replace(/%\d*/g,e=>{let t=parseInt(e.substring(1),10)-1;return`"counter(${this.numberingCounter(r,t)}, ${n})"`})}${null!==(a={tab:"\\9",space:"\\a0"}[t])&&void 0!==a?a:""}"`}numFormatToCssValue(e){var t;return null!==(t={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])&&void 0!==t?t:e}renderFontTable(e,t){for(let r of e.fonts)for(let e of r.embedFontRefs)this.document.loadFont(e.id,e.key).then(n=>{const a={"font-family":r.name,src:`url(${n})`};"bold"!=e.type&&"boldItalic"!=e.type||(a["font-weight"]="bold"),"italic"!=e.type&&"boldItalic"!=e.type||(a["font-style"]="italic"),kt(t,`docxjs ${r.name} font`);const s=this.styleToString("@font-face",a);t.appendChild(vt(s)),this.refreshTabStops()})}renderWrapper(e){return mt("div",{className:`${this.className}-wrapper`},e)}copyStyleProperties(e,t,r=null){if(!e)return t;null==t&&(t={}),null==r&&(r=Object.getOwnPropertyNames(e));for(let n of r)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(t[n]=e[n]);return t}processElement(e){if(e.children)for(let t of e.children)t.parent=e,t.type==U.Table?this.processTable(t):this.processElement(t)}processTable(e){for(let t of e.children)for(let r of t.children)r.cssStyle=this.copyStyleProperties(e.cellStyle,r.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]),this.processElement(r)}splitPage(e){var t;let r=new ct({});const n=[r];for(const a of e){if(a.level=1,r.children.push(a),a.type==U.Paragraph){const e=a,s=e.props.sectionProperties;s&&(s.sectionId=B());const i=this.findStyle(e.styleName);(null===(t=null==i?void 0:i.paragraphProps)||void 0===t?void 0:t.pageBreakBefore)&&(r.isSplit=!0,r.sectProps=s,r=new ct({}),n.push(r));let l=-1,o=-1;if(e.children&&(l=e.children.findIndex(e=>{var t;return o=null===(t=e.children)||void 0===t?void 0:t.findIndex(e=>(e.type===U.Break||e.type===U.LastRenderedPageBreak)&&(e.type===U.LastRenderedPageBreak?r.children.length>2||!this.options.ignoreLastRenderedPageBreak:"page"===e.break||void 0)),o=null!=o?o:-1,-1!=o})),-1!=l){r.isSplit=!0;const e=r.children.some(e=>e.type===U.Table);e&&(r.isSplit=!1);let t=r.children.some(e=>e.children.some(e=>{var t;return e.type===U.Hyperlink&&(null===(t=null==e?void 0:e.href)||void 0===t?void 0:t.includes("Toc"))}));t&&(r.isSplit=!1)}if((-1!=l||s&&s.type!=H.Continuous&&s.type!=H.NextColumn)&&(r.sectProps=s,r=new ct({}),n.push(r)),-1!=l){let t=e.children[l],n=o<t.children.length-1;if(l<e.children.length-1||n){let a=e.children;const s=Object.assign(Object.assign({},e),{children:a.slice(l)});if(e.children=a.slice(0,l),r.children.push(s),n){const r=t.children,n=Object.assign(Object.assign({},t),{children:r.slice(0,o)});e.children.push(n),t.children=r.slice(o)}}}}a.type===U.Table&&(r.isSplit=!1)}let a=null;for(let e=n.length-1;e>=0;e--)null==n[e].sectProps?n[e].sectProps=a:a=n[e].sectProps;return n}renderPages(e){const t=[];let r;this.processElement(e),r=this.options.breakPages?this.splitPage(e.children):[new ct({sectProps:e.sectProps,children:e.children})],e.pages=r;let n=null;for(let a=0,s=r.length;a<s;a++){this.currentFootnoteIds=[];const i=r[a],{sectProps:l}=i;let o=null!=l?l:e.sectProps,c=t.length,d=n!=o,p=a===s-1,h=this.renderPage(i,o,e.cssStyle,c,d,p);t.push(...h),n=l}return t}renderPage(e,t,r,n,a,s){const i=this.createPage(this.className,t);this.renderStyleValues(r,i),this.options.renderHeaders&&this.renderHeaderFooterRef(t.headerRefs,t,n,a,i);let l=mt("article");return this.options.breakPages&&(l.style.minHeight=t.contentSize.height),this.renderElements(e.children,l),i.appendChild(l),this.options.renderFootnotes&&this.renderNotes(this.currentFootnoteIds,this.footnoteMap,i),this.options.renderEndnotes&&s&&this.renderNotes(this.currentEndnoteIds,this.endnoteMap,i),this.options.renderFooters&&this.renderHeaderFooterRef(t.footerRefs,t,n,a,i),[i]}createPage(e,t){let r=mt("section",{className:e});return t&&(t.pageMargins&&(r.style.paddingLeft=t.pageMargins.left,r.style.paddingRight=t.pageMargins.right,r.style.paddingTop=t.pageMargins.top,r.style.paddingBottom=t.pageMargins.bottom),t.pageSize&&(this.options.ignoreWidth||(r.style.width=t.pageSize.width),this.options.ignoreHeight||(r.style.minHeight=t.pageSize.height)),t.columns&&t.columns.count&&(r.style.columnCount=`${t.columns.count}`,r.style.columnGap=t.columns.space,t.columns.separator&&(r.style.columnRule="1px solid black"))),r}renderHeaderFooterRef(e,t,r,n,a){var s,i,l,o,c,d,p,h;if(!e)return;let u=null!==(i=null!==(s=t.titlePage&&n?e.find(e=>"first"==e.type):null)&&void 0!==s?s:r%2==1?e.find(e=>"even"==e.type):null)&&void 0!==i?i:e.find(e=>"default"==e.type),m=u&&this.document.findPartByRelId(u.id,this.document.documentPart);if(m){switch(this.currentPart=m,this.usedHederFooterParts.includes(m.path)||(this.processElement(m.rootElement),this.usedHederFooterParts.push(m.path)),m.rootElement.type){case U.Header:m.rootElement.cssStyle={left:null===(l=t.pageMargins)||void 0===l?void 0:l.left,width:null===(o=t.contentSize)||void 0===o?void 0:o.width,height:null===(c=t.pageMargins)||void 0===c?void 0:c.top};break;case U.Footer:m.rootElement.cssStyle={left:null===(d=t.pageMargins)||void 0===d?void 0:d.left,width:null===(p=t.contentSize)||void 0===p?void 0:p.width,height:null===(h=t.pageMargins)||void 0===h?void 0:h.bottom};break;default:console.warn("set header/footer style error",m.rootElement.type)}this.renderElements([m.rootElement],a),this.currentPart=null}}renderNotes(e,t,r){let n=e.map(e=>t[e]).filter(e=>e);if(n.length>0){let e=mt("ol",null,this.renderElements(n));r.appendChild(e)}}renderElements(e,t){if(null==e)return null;let r=[];for(let t=0;t<e.length;t++){let n=this.renderElement(e[t]);Array.isArray(n)?r.push(...n):n&&r.push(n)}return t&&yt(t,r),r}renderElement(e){switch(e.type){case U.Paragraph:return this.renderParagraph(e);case U.BookmarkStart:return this.renderBookmarkStart(e);case U.BookmarkEnd:return null;case U.Run:return this.renderRun(e);case U.Table:return this.renderTable(e);case U.Row:return this.renderTableRow(e);case U.Cell:return this.renderTableCell(e);case U.Hyperlink:return this.renderHyperlink(e);case U.Drawing:return this.renderDrawing(e);case U.Image:return this.renderImage(e);case U.Text:return this.renderText(e);case U.DeletedText:return this.renderDeletedText(e);case U.Tab:return this.renderTab(e);case U.Symbol:return this.renderSymbol(e);case U.Break:return this.renderBreak(e);case U.Footer:return this.renderHeaderFooter(e,"footer");case U.Header:return this.renderHeaderFooter(e,"header");case U.Footnote:case U.Endnote:return this.renderContainer(e,"li");case U.FootnoteReference:return this.renderFootnoteReference(e);case U.EndnoteReference:return this.renderEndnoteReference(e);case U.NoBreakHyphen:return mt("wbr");case U.VmlPicture:return this.renderVmlPicture(e);case U.VmlElement:return this.renderVmlElement(e);case U.MmlMath:return this.renderContainerNS(e,pt,"math",{xmlns:pt});case U.MmlMathParagraph:return this.renderContainer(e,"span");case U.MmlFraction:return this.renderContainerNS(e,pt,"mfrac");case U.MmlBase:return this.renderContainerNS(e,pt,e.parent.type==U.MmlMatrixRow?"mtd":"mrow");case U.MmlNumerator:case U.MmlDenominator:case U.MmlFunction:case U.MmlLimit:case U.MmlBox:return this.renderContainerNS(e,pt,"mrow");case U.MmlGroupChar:return this.renderMmlGroupChar(e);case U.MmlLimitLower:return this.renderContainerNS(e,pt,"munder");case U.MmlMatrix:return this.renderContainerNS(e,pt,"mtable");case U.MmlMatrixRow:return this.renderContainerNS(e,pt,"mtr");case U.MmlRadical:return this.renderMmlRadical(e);case U.MmlSuperscript:return this.renderContainerNS(e,pt,"msup");case U.MmlSubscript:return this.renderContainerNS(e,pt,"msub");case U.MmlDegree:case U.MmlSuperArgument:case U.MmlSubArgument:return this.renderContainerNS(e,pt,"mn");case U.MmlFunctionName:return this.renderContainerNS(e,pt,"ms");case U.MmlDelimiter:return this.renderMmlDelimiter(e);case U.MmlRun:return this.renderMmlRun(e);case U.MmlNary:return this.renderMmlNary(e);case U.MmlPreSubSuper:return this.renderMmlPreSubSuper(e);case U.MmlBar:return this.renderMmlBar(e);case U.MmlEquationArray:return this.renderMllList(e);case U.Inserted:return this.renderInserted(e);case U.Deleted:return this.renderDeleted(e);case U.CommentRangeStart:return this.renderCommentRangeStart(e);case U.CommentRangeEnd:return this.renderCommentRangeEnd(e);case U.CommentReference:return this.renderCommentReference(e)}return null}isPageBreakElement(e){return(e.type===U.Break||e.type===U.LastRenderedPageBreak)&&(e.type===U.LastRenderedPageBreak?!this.options.ignoreLastRenderedPageBreak:"page"===e.break||void 0)}renderChildren(e,t){return this.renderElements(e.children,t)}renderContainer(e,t,r){return mt(t,r,this.renderChildren(e))}renderContainerNS(e,t,r,n){return gt(t,r,n,this.renderChildren(e))}renderParagraph(e){var t,r,n,a,s;let i=mt("p");const l=this.findStyle(e.styleName);null!==(t=(s=e.props).tabs)&&void 0!==t||(s.tabs=null===(r=null==l?void 0:l.paragraphProps)||void 0===r?void 0:r.tabs),this.renderClass(e,i),this.renderChildren(e,i),this.renderStyleValues(e.cssStyle,i),this.renderCommonProperties(i.style,e.props);const o=null!==(n=e.props.numbering)&&void 0!==n?n:null===(a=null==l?void 0:l.paragraphProps)||void 0===a?void 0:a.numbering;return o&&i.classList.add(this.numberingClass(o.id,o.level)),i}renderRun(e){if(e.fieldRun)return null;const t=mt("span");if(this.renderClass(e,t),this.renderStyleValues(e.cssStyle,t),e.verticalAlign){const r=mt(e.verticalAlign);this.renderChildren(e,r),t.appendChild(r)}else this.renderChildren(e,t);return t}renderText(e){return document.createTextNode(e.text)}renderHyperlink(e){let t=mt("a");if(this.renderChildren(e,t),this.renderStyleValues(e.cssStyle,t),e.href)t.href=e.href;else if(e.id){const r=this.document.documentPart.rels.find(t=>t.id==e.id&&"External"===t.targetMode);t.href=null==r?void 0:r.target}return t}renderDrawing(e){let t=mt("div");return t.style.display="inline-block",t.style.position="relative",t.style.textIndent="0px",this.renderChildren(e,t),this.renderStyleValues(e.cssStyle,t),t}renderImage(e){let t=mt("img");return this.renderStyleValues(e.cssStyle,t),this.document&&this.document.loadDocumentImage(e.src,this.currentPart).then(e=>{t.src=e}),t}renderDeletedText(e){return this.options.renderEndnotes?document.createTextNode(e.text):null}renderBreak(e){return"textWrapping"==e.break?mt("br"):null}renderInserted(e){return this.options.renderChanges?this.renderContainer(e,"ins"):this.renderChildren(e)}renderDeleted(e){return this.options.renderChanges?this.renderContainer(e,"del"):null}renderCommentRangeStart(e){var t;if(!this.options.renderComments)return null;const r=new Range;null===(t=this.commentHighlight)||void 0===t||t.add(r);const n=document.createComment(`start of comment #${e.id}`);return this.later(()=>r.setStart(n,0)),this.commentMap[e.id]=r,n}renderCommentRangeEnd(e){if(!this.options.renderComments)return null;const t=this.commentMap[e.id],r=document.createComment(`end of comment #${e.id}`);return this.later(()=>null==t?void 0:t.setEnd(r,0)),r}renderCommentReference(e){var t;if(!this.options.renderComments)return null;var r=null===(t=this.document.commentsPart)||void 0===t?void 0:t.commentMap[e.id];if(!r)return null;const n=new DocumentFragment,a=mt("span",{className:`${this.className}-comment-ref`});a.textContent="💬";const s=mt("div",{className:`${this.className}-comment-popover`});return this.renderCommentContent(r,s),n.appendChild(document.createComment(`comment #${r.id} by ${r.author} on ${r.date}`)),n.appendChild(a),n.appendChild(s),n}renderCommentContent(e,t){t.appendChild(mt("div",{className:`${this.className}-comment-author`},[e.author])),t.appendChild(mt("div",{className:`${this.className}-comment-date`},[new Date(e.date).toLocaleString()])),this.renderElements(e.children,t)}renderSymbol(e){let t=mt("span");return t.style.fontFamily=e.font,t.innerHTML=`&#x${e.char};`,t}renderHeaderFooter(e,t){let r=mt(t);return this.renderChildren(e,r),this.renderStyleValues(e.cssStyle,r),r}renderFootnoteReference(e){let t=mt("sup");return this.currentFootnoteIds.push(e.id),t.textContent=`${this.currentFootnoteIds.length}`,t}renderEndnoteReference(e){let t=mt("sup");return this.currentEndnoteIds.push(e.id),t.textContent=`${this.currentEndnoteIds.length}`,t}renderTab(e){var t;let r=mt("span");if(r.innerHTML="&emsp;",this.options.experimental){r.className=this.tabStopClass();let n=null===(t=function(e,t){let r=e.parent;for(;null!=r&&r.type!=t;)r=r.parent;return r}(e,U.Paragraph).props)||void 0===t?void 0:t.tabs;this.currentTabs.push({stops:n,span:r})}return r}renderBookmarkStart(e){let t=mt("span");return t.id=e.name,t}renderTable(e){let t=mt("table");return this.tableCellPositions.push(this.currentCellPosition),this.tableVerticalMerges.push(this.currentVerticalMerge),this.currentVerticalMerge={},this.currentCellPosition={col:0,row:0},e.columns&&t.appendChild(this.renderTableColumns(e.columns)),this.renderClass(e,t),this.renderChildren(e,t),this.renderStyleValues(e.cssStyle,t),this.currentVerticalMerge=this.tableVerticalMerges.pop(),this.currentCellPosition=this.tableCellPositions.pop(),t}renderTableColumns(e){let t=mt("colgroup");for(let r of e){let e=mt("col");r.width&&(e.style.width=r.width),t.appendChild(e)}return t}renderTableRow(e){let t=mt("tr");return this.currentCellPosition.col=0,this.renderClass(e,t),this.renderChildren(e,t),this.renderStyleValues(e.cssStyle,t),this.currentCellPosition.row++,t}renderTableCell(e){let t=mt("td");const r=this.currentCellPosition.col;return e.verticalMerge?"restart"==e.verticalMerge?(this.currentVerticalMerge[r]=t,t.rowSpan=1):this.currentVerticalMerge[r]&&(this.currentVerticalMerge[r].rowSpan+=1,t.style.display="none"):this.currentVerticalMerge[r]=null,this.renderClass(e,t),this.renderChildren(e,t),this.renderStyleValues(e.cssStyle,t),e.span&&(t.colSpan=e.span),this.currentCellPosition.col+=t.colSpan,t}renderVmlPicture(e){let t=mt("div");return this.renderChildren(e,t),t}renderVmlElement(e){var t,r;let n=ft("svg");n.setAttribute("style",e.cssStyleText);const a=this.renderVmlChildElement(e);return(null===(t=e.imageHref)||void 0===t?void 0:t.id)&&(null===(r=this.document)||void 0===r||r.loadDocumentImage(e.imageHref.id,this.currentPart).then(e=>a.setAttribute("href",e))),n.appendChild(a),requestAnimationFrame(()=>{const e=n.firstElementChild.getBBox();n.setAttribute("width",`${Math.ceil(e.x+e.width)}`),n.setAttribute("height",`${Math.ceil(e.y+e.height)}`)}),n}renderVmlChildElement(e){const t=ft(e.tagName);Object.entries(e.attrs).forEach(([e,r])=>t.setAttribute(e,r));for(let r of e.children)r.type==U.VmlElement?t.appendChild(this.renderVmlChildElement(r)):t.append(...F(this.renderElement(r)));return t}renderMmlRadical(e){var t;const r=e.children.find(e=>e.type==U.MmlBase);if(null===(t=e.props)||void 0===t?void 0:t.hideDegree)return gt(pt,"msqrt",null,this.renderElements([r]));const n=e.children.find(e=>e.type==U.MmlDegree);return gt(pt,"mroot",null,this.renderElements([r,n]))}renderMmlDelimiter(e){var t,r;const n=[];return n.push(gt(pt,"mo",null,[null!==(t=e.props.beginChar)&&void 0!==t?t:"("])),n.push(...this.renderElements(e.children)),n.push(gt(pt,"mo",null,[null!==(r=e.props.endChar)&&void 0!==r?r:")"])),gt(pt,"mrow",null,n)}renderMmlNary(e){var r,n;const a=[],s=t.keyBy(e.children,"type"),i=s[U.MmlSuperArgument],l=s[U.MmlSubArgument],o=i?gt(pt,"mo",null,F(this.renderElement(i))):null,c=l?gt(pt,"mo",null,F(this.renderElement(l))):null,d=gt(pt,"mo",null,[null!==(n=null===(r=e.props)||void 0===r?void 0:r.char)&&void 0!==n?n:"∫"]);return o||c?a.push(gt(pt,"munderover",null,[d,c,o])):o?a.push(gt(pt,"mover",null,[d,o])):c?a.push(gt(pt,"munder",null,[d,c])):a.push(d),a.push(...this.renderElements(s[U.MmlBase].children)),gt(pt,"mrow",null,a)}renderMmlPreSubSuper(e){const r=[],n=t.keyBy(e.children,"type"),a=n[U.MmlSuperArgument],s=n[U.MmlSubArgument],i=a?gt(pt,"mo",null,F(this.renderElement(a))):null,l=s?gt(pt,"mo",null,F(this.renderElement(s))):null,o=gt(pt,"mo",null);return r.push(gt(pt,"msubsup",null,[o,l,i])),r.push(...this.renderElements(n[U.MmlBase].children)),gt(pt,"mrow",null,r)}renderMmlGroupChar(e){const t="bot"===e.props.verticalJustification?"mover":"munder",r=this.renderContainerNS(e,pt,t);return e.props.char&&r.appendChild(gt(pt,"mo",null,[e.props.char])),r}renderMmlBar(e){const t=this.renderContainerNS(e,pt,"mrow");switch(e.props.position){case"top":t.style.textDecoration="overline";break;case"bottom":t.style.textDecoration="underline"}return t}renderMmlRun(e){const t=gt(pt,"ms");return this.renderClass(e,t),this.renderStyleValues(e.cssStyle,t),this.renderChildren(e,t),t}renderMllList(e){const t=gt(pt,"mtable");this.renderClass(e,t),this.renderStyleValues(e.cssStyle,t);const r=this.renderChildren(e);for(let e of r)t.appendChild(gt(pt,"mtr",null,[gt(pt,"mtd",null,[e])]));return t}renderStyleValues(e,t){for(let r in e)r.startsWith("$")?t.setAttribute(r.slice(1),e[r]):t.style[r]=e[r]}renderRunProperties(e,t){this.renderCommonProperties(e,t)}renderCommonProperties(e,t){null!=t&&(t.color&&(e.color=t.color),t.fontSize&&(e["font-size"]=t.fontSize))}renderClass(e,t){e.className&&(t.className=e.className),e.styleName&&t.classList.add(this.processStyleName(e.styleName))}findStyle(e){var t;return e&&(null===(t=this.styleMap)||void 0===t?void 0:t[e])}tabStopClass(){return`${this.className}-tab-stop`}refreshTabStops(){this.options.experimental&&(clearTimeout(this.tabsTimeout),this.tabsTimeout=setTimeout(()=>{const e=lt();for(let t of this.currentTabs)ot(t.span,t.stops,this.defaultTabSize,e)},500))}}function mt(e,t,r){return gt(void 0,e,t,r)}function ft(e,t,r){return gt(dt,e,t,r)}function gt(e,t,r,n){let a=e?document.createElementNS(e,t):document.createElement(t);return Object.assign(a,r),n&&yt(a,n),a}function bt(e){e.innerHTML=""}function yt(e,r){r.forEach(r=>{e.appendChild(t.isString(r)?document.createTextNode(r):r)})}function vt(e){return mt("style",{innerHTML:e})}function kt(e,t){e.appendChild(document.createComment(t))}const xt="http://www.w3.org/2000/svg",wt="http://www.w3.org/1998/Math/MathML";var St;!function(e){e.TRUE="true",e.FALSE="false",e.SELF="self",e.FULL="full",e.PART="part",e.UNKNOWN="undetected",e.IGNORE="ignore"}(St||(St={}));class Ct{constructor(){this.className="docx",this.styleMap={},this.currentPart=null,this.tableVerticalMerges=[],this.currentVerticalMerge=null,this.tableCellPositions=[],this.currentCellPosition=null,this.footnoteMap={},this.endnoteMap={},this.currentEndnoteIds=[],this.usedHeaderFooterParts=[],this.currentTabs=[],this.commentMap={},this.postRenderTasks=[]}later(e){this.postRenderTasks.push(e)}render(e,r){return n(this,arguments,void 0,function*(e,r,n=null,a){var s;this.document=e,this.options=a,this.className=a.className,this.rootSelector=a.inWrapper?`.${this.className}-wrapper`:":root",this.styleMap=null,this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight),this.bodyContainer=r,n=n||r,this.pointToPixelRatio=lt(),Mt(n),Mt(r),$t(n,"docxjs library predefined styles"),n.appendChild(this.renderDefaultStyle()),e.themePart&&($t(n,"docxjs document theme values"),this.renderTheme(e.themePart,n)),null!=e.stylesPart&&(this.styleMap=this.processStyles(e.stylesPart.styles),$t(n,"docxjs document styles"),n.appendChild(this.renderStyles(e.stylesPart.styles))),e.numberingPart&&(this.processNumberings(e.numberingPart.domNumberings),$t(n,"docxjs document numbering styles"),n.appendChild(this.renderNumbering(e.numberingPart.domNumberings,n))),!a.ignoreFonts&&e.fontTablePart&&this.renderFontTable(e.fontTablePart,n),e.footnotesPart&&(this.footnoteMap=t.keyBy(e.footnotesPart.rootElement.children,"id")),e.endnotesPart&&(this.endnoteMap=t.keyBy(e.endnotesPart.rootElement.children,"id")),e.settingsPart&&(this.defaultTabSize=null===(s=e.settingsPart.settings)||void 0===s?void 0:s.defaultTabStop),this.options.inWrapper?(this.wrapper=this.renderWrapper(),r.appendChild(this.wrapper)):this.wrapper=r,this.renderKonva(),yield this.renderPages(e.documentPart.body),this.konva_stage.visible(!1),this.refreshTabStops(),this.commentHighlight&&a.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),this.postRenderTasks.forEach(e=>e())})}renderDefaultStyle(){const e=this.className;let t=`\n\t\t\t.${e} { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif }\n\t\t\t.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; line-height:normal; font-weight:normal; } \n\t\t\t.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }\n\t\t\t.${e} { color: black; hyphens: auto; text-underline-position: from-font; }\n\t\t\tsection.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }\n section.${e}>header { position: absolute; top: 0; z-index: 1; display: flex; flex-direction: column; justify-content: flex-end; }\n\t\t\tsection.${e}>article { z-index: 1; }\n\t\t\tsection.${e}>footer { position: absolute; bottom: 0; z-index: 1; }\n\t\t\t.${e} table { border-collapse: collapse; }\n\t\t\t.${e} table td, .${e} table th { vertical-align: top; }\n\t\t\t.${e} p { margin: 0pt; min-height: 1em; }\n\t\t\t.${e} span { white-space: pre-wrap; overflow-wrap: break-word; }\n\t\t\t.${e} a { color: inherit; text-decoration: inherit; }\n\t\t\t.${e} img, ${e} svg { vertical-align: baseline; }\n\t\t\t.${e} svg { fill: transparent; }\n\t\t\t.${e} .clearfix::after { content: ""; display: block; line-height: 0; clear: both; }\n\t\t`;return this.options.renderComments&&(t+=`\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`),Rt(t)}renderTheme(e,t){var r,n;const a={},s=null===(r=e.theme)||void 0===r?void 0:r.fontScheme;s&&(s.majorFont&&(a["--docx-majorHAnsi-font"]=s.majorFont.latinTypeface),s.minorFont&&(a["--docx-minorHAnsi-font"]=s.minorFont.latinTypeface));const i=null===(n=e.theme)||void 0===n?void 0:n.colorScheme;if(i)for(const[e,t]of Object.entries(i.colors))a[`--docx-${e}-color`]=`#${t}`;const l=this.styleToString(`.${this.className}`,a);t.appendChild(Rt(l))}processStyleName(e){return e?`${this.className}_${R(e)}`:this.className}processStyles(e){let r=t.keyBy(e,"id");for(const n of e){if(n.cssName=this.processStyleName(n.id),null===n.basedOn)continue;const e=r[n.basedOn];if(e){(null==e?void 0:e.paragraphProps)&&(n.paragraphProps=t.merge({},null==e?void 0:e.paragraphProps,n.paragraphProps)),(null==e?void 0:e.runProps)&&(n.runProps=t.merge({},null==e?void 0:e.runProps,n.runProps));for(let r of e.rulesets){let e=n.rulesets.find(e=>e.target==r.target);e?e.declarations=t.merge({},r.declarations,e.declarations):n.rulesets.push(Object.assign({},r))}}else this.options.debug&&console.warn(`Can't find base style ${n.basedOn}`)}return r}renderStyles(e){var t;let r="";for(const n of e)for(const e of n.rulesets){let a=`${null!==(t=n.label)&&void 0!==t?t:""}.${n.cssName}`;n.label!==e.target&&(a+=` ${e.target}`),n.isDefault&&(a=`.${this.className} ${n.label}, `+a),r+=this.styleToString(a,e.declarations)}return Rt(r)}processNumberings(e){var t;for(const r of e.filter(e=>e.pStyleName)){const e=this.findStyle(r.pStyleName);(null===(t=null==e?void 0:e.paragraphProps)||void 0===t?void 0:t.numbering)&&(e.paragraphProps.numbering.level=r.level)}}renderNumbering(e,t){let r="";const n=[];for(const a of e){const e=`p.${this.numberingClass(a.id,a.level)}`;let s="none";if(a.bullet){const n=`--${this.className}-${a.bullet.src}`.toLowerCase();r+=this.styleToString(`${e}:before`,{content:"' '",display:"inline-block",background:`var(${n})`},a.bullet.style),this.document.loadNumberingImage(a.bullet.src).then(e=>{const r=`${this.rootSelector} { ${n}: url(${e}) }`;t.appendChild(Rt(r))})}else if(a.levelText){const t=this.numberingCounter(a.id,a.level),s=t+" "+(a.start-1);a.level>0&&(r+=this.styleToString(`p.${this.numberingClass(a.id,a.level-1)}`,{"counter-reset":s})),n.push(s),r+=this.styleToString(`${e}:before`,Object.assign({content:this.levelTextToContent(a.levelText,a.suff,a.id,this.numFormatToCssValue(a.format)),"counter-increment":t},a.rStyle))}else s=this.numFormatToCssValue(a.format);r+=this.styleToString(e,Object.assign({display:"list-item","list-style-position":"inside","list-style-type":s},a.pStyle))}return n.length>0&&(r+=this.styleToString(this.rootSelector,{"counter-reset":n.join(" ")})),Rt(r)}numberingClass(e,t){return`${this.className}-num-${e}-${t}`}styleToString(e,t,r=null){let n=`${e} {\r\n`;for(const e in t)e.startsWith("$")||(n+=` ${e}: ${t[e]};\r\n`);return r&&(n+=r),n+"}\r\n"}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}levelTextToContent(e,t,r,n){var a;return`"${e.replace(/%\d*/g,e=>{const t=parseInt(e.substring(1),10)-1;return`"counter(${this.numberingCounter(r,t)}, ${n})"`})}${null!==(a={tab:"\\9",space:"\\a0"}[t])&&void 0!==a?a:""}"`}numFormatToCssValue(e){var t;return null!==(t={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])&&void 0!==t?t:e}renderFontTable(e,t){for(const r of e.fonts)for(const e of r.embedFontRefs)this.document.loadFont(e.id,e.key).then(n=>{const a={"font-family":r.name,src:`url(${n})`};"bold"!=e.type&&"boldItalic"!=e.type||(a["font-weight"]="bold"),"italic"!=e.type&&"boldItalic"!=e.type||(a["font-style"]="italic"),$t(t,`docxjs ${r.name} font`);const s=this.styleToString("@font-face",a);t.appendChild(Rt(s)),this.refreshTabStops()})}renderWrapper(){return Pt("div",{className:`${this.className}-wrapper`})}copyStyleProperties(e,t,r=null){if(!e)return t;null==t&&(t={}),null==r&&(r=Object.getOwnPropertyNames(e));for(const n of r)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(t[n]=e[n]);return t}processElement(e){if(e.children)for(const t of e.children)t.parent=e,t.level=(null==e?void 0:e.level)+1,t.type==U.Table?(this.processTable(t),this.processElement(t)):this.processElement(t)}processTable(e){for(const t of e.children)for(const r of t.children)r.cssStyle=this.copyStyleProperties(e.cellStyle,r.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"])}splitPageBySymbol(e){var r,n,a;let s=t.cloneDeep(e),i=new ct({isSplit:!0}),l=[];function o(){i.children.length>0&&(l.push(i),i=new ct({isSplit:!0}))}const c=(e,r)=>{var n,a,l;let c=new Set([U.BookmarkStart]);if(e.type===U.Paragraph){const d=this.findStyle(null==e?void 0:e.styleName);if(null===(n=null==d?void 0:d.paragraphProps)||void 0===n?void 0:n.pageBreakBefore){let h=i.stack.pop();return i.children=m(i.stack),o(),h.prev=null,void(i.stack=[h])}const p=null===(a=e.props)||void 0===a?void 0:a.sectionProperties;if(!1===i.isSplit&&void 0===p)return;i.sectProps=p}if(e.type===U.Table&&i.isSplit&&(i.isSplit=!1),e.type===U.Hyperlink){const u=null===(l=null==e?void 0:e.href)||void 0===l?void 0:l.includes("Toc");i.isSplit&&u&&(i.isSplit=!1)}if(e.type===U.LastRenderedPageBreak){if(!1===i.isSplit)return;let{left:f,removedElementIds:g,ignoredElementIds:b}=k(e),y=r.find(e=>e.type===U.Paragraph),v=i.stack.some(e=>{if(e.parent.uuid===(null==y?void 0:y.uuid)){let t=!1;if(e.prev){!1===c.has(e.prev.type)&&(t=!0)}return t}return!1});if(f>0){g.push(e.uuid);let x=i.stack.filter(e=>b.includes(e.uuid));i.stack=i.stack.filter(e=>!g.includes(e.uuid)),i.children=m(i.stack),o(),i.stack.push(...x),i.stack.push(e);let w=r.map(e=>{let r=t.cloneDeep(e);return r.prev=null,r.type===U.Paragraph&&v&&(r.cssStyle["text-indent"]="0"),r});i.stack.push(...w)}function k(e){let t=[],n=[],a=0,i=[e,...r],l={ignoredType:null,uuid:null};for(let e of i){if(l.ignoredType){let r=e.children.findIndex(e=>e.uuid===l.uuid),s=e.children.slice(0,r);s.reverse();for(let e of s){if(e.type!==l.ignoredType){a+=1;break}t.push(e.uuid),n.push(e.uuid)}}if(l.uuid=e.uuid,e.prev){if(!c.has(e.prev.type)){a+=1;break}l.ignoredType=e.prev.type}else l.ignoredType=null,e.parent.uuid!==s.uuid&&n.push(e.parent.uuid)}return{left:a,removedElementIds:n,ignoredElementIds:t}}}if(e.break==W.Page&&(i.children=m(i.stack),o()),e.type===U.SectionBreak){switch(e.break){case H.Continuous:case H.NextColumn:break;case H.EvenPage:case H.OddPage:case H.NextPage:default:i.children=m(i.stack),o()}}};let d=[];u(s,[]);let p=[];for(;d.length>0;){let[e,t]=d.pop();if(e.type===U.Paragraph){const t=null===(r=e.props)||void 0===r?void 0:r.sectionProperties;if(t){t.sectionId=B();let r={type:U.SectionBreak,break:null!==(n=t.type)&&void 0!==n?n:H.NextPage},a={type:U.Run,children:[r]};e.children.push(a)}}p.push([e,t]),u(e,t)}let h=null!==(a=s.sectProps.type)&&void 0!==a?a:H.NextPage;for(let e=p.length-1;e>=0;e--){let[t]=p[e];if(t.type===U.SectionBreak){let{break:e}=t;t.break=h,h=e}}for(let e=0;e<p.length;e++){let[t,r]=p[e];0===i.stack.length&&(t.prev=null),i.stack.push(t),c(t,r)}function u(e,t){var r,n;const a=null!==(n=null===(r=null==e?void 0:e.children)||void 0===r?void 0:r.length)&&void 0!==n?n:0;if(0===a)return;if(e.type===U.Text)return;let s=null;for(let r=a-1;r>=0;r--){const n=e.children[r];n.uuid=B(),n.parent={uuid:e.uuid,type:e.type},s&&(s.prev={uuid:n.uuid,type:n.type}),0===r&&(n.prev=null),s=n;let a=e.type===U.Document?[]:[e,...t];d.push([n,a])}}function m(e){let t=e.filter(e=>e.parent.uuid===s.uuid);const r=function(e,t){return t.map(t=>{let n=e.filter(e=>e.parent.uuid===t.uuid);return n.length?Object.assign(Object.assign({},t),{children:r(e,n)}):Object.assign({},t)})};return r(e,t)}i.stack.length>0&&(i.isSplit=!1,i.children=m([...i.stack]),i.sectProps=s.sectProps,l.push(i));let f=null;for(let e of l)e.sectProps&&((null==f?void 0:f.headerRefs)&&(e.sectProps.headerRefs=t.unionBy(e.sectProps.headerRefs,f.headerRefs,"type")),(null==f?void 0:f.footerRefs)&&(e.sectProps.footerRefs=t.unionBy(e.sectProps.footerRefs,f.footerRefs,"type")),f=e.sectProps);let g=null;for(let e=l.length-1;e>=0;e--)null==l[e].sectProps?l[e].sectProps=g:g=l[e].sectProps;return l}renderPages(e){return n(this,void 0,void 0,function*(){let t;t=this.options.breakPages?this.splitPageBySymbol(e):[new ct({isSplit:!0,sectProps:e.sectProps,children:e.children})],e.pages=t;let r=null,n=[...t];for(let t=0;t<n.length;t++){this.currentFootnoteIds=[];const a=n[t],{sectProps:s}=a;a.sectProps=null!=s?s:e.sectProps,a.isFirstPage=r!=a.sectProps,a.isLastPage=t===n.length-1,a.checkingOverflow=!1,this.currentPage=a,r=a.sectProps,yield this.renderPage()}})}renderPage(){return n(this,void 0,void 0,function*(){const{pageId:e,sectProps:r,children:n,isFirstPage:a,isLastPage:s}=this.currentPage;this.processElement(this.currentPage);const i=this.createPage(this.className,r);this.renderStyleValues(this.document.documentPart.body.cssStyle,i);let l=this.document.documentPart.body.pages,o=l.findIndex(t=>t.pageId===e),c=null,d=null;this.options.renderHeaders&&(c=yield this.renderHeaderFooterRef(r.headerRefs,r,o,a,i)),this.options.renderFooters&&(d=yield this.renderHeaderFooterRef(r.footerRefs,r,o,a,i));const p=this.createPageContent(r);let h=e=>{var t;return(null!==(t=null==e?void 0:e.offsetHeight)&&void 0!==t?t:0)*this.pointToPixelRatio},{pageSize:u,pageMargins:m}=r,f=h(c),g=h(d),b=t.max([parseFloat(m.top),f]),y=t.max([parseFloat(m.bottom),g]);i.style.paddingTop=`${b}pt`,i.style.paddingBottom=`${y}pt`,this.options.breakPages?p.style.height=parseFloat(u.height)-b-y+"pt":p.style.minHeight=parseFloat(u.height)-b-y+"pt",this.currentPage.contentElement=p,i.appendChild(p),this.currentPage.checkingOverflow=!0,(yield this.renderElements(n,p))===St.FALSE&&(this.currentPage.isSplit=!0,l[o]=this.currentPage),this.currentPage.checkingOverflow=!1,this.options.renderFootnotes&&(yield this.renderNotes(U.Footnotes,this.currentFootnoteIds,this.footnoteMap,i)),this.options.renderEndnotes&&s&&(yield this.renderNotes(U.Endnotes,this.currentEndnoteIds,this.endnoteMap,i))})}createPage(e,t){const r=Pt("section",{className:e});return t&&(r.dataset.sectionId=t.sectionId,t.pageMargins&&(r.style.paddingLeft=t.pageMargins.left,r.style.paddingRight=t.pageMargins.right,r.style.paddingTop=t.pageMargins.top,r.style.paddingBottom=t.pageMargins.bottom),t.pageSize&&(this.options.ignoreWidth||(r.style.width=t.pageSize.width),this.options.ignoreHeight||(r.style.minHeight=t.pageSize.height))),this.wrapper.appendChild(r),r}createPageContent(e){const t=Pt("article");if(e.columns){const{count:r,space:n,separator:a}=e.columns;r>1&&(t.style.columnCount=`${r}`,t.style.columnGap=n),a&&(t.style.columnRule="1px solid black")}return t}renderHeaderFooterRef(e,t,r,a,s){return n(this,void 0,void 0,function*(){var n,i,l,o;if(!e)return null;let c;if(c=t.titlePage&&a?e.find(e=>"first"==e.type):this.document.settingsPart.settings.evenAndOddHeaders?(r+=1)%2==0?e.find(e=>"even"===e.type):e.find(e=>"default"===e.type||"odd"===e.type):e.find(e=>"default"===e.type),!c)return console.error("Header/Footer reference is not found"),null;let d=this.document.findPartByRelId(null==c?void 0:c.id,this.document.documentPart);if(!d)return console.error(`Part corresponding to the reference with id:${null==c?void 0:c.id} is not found`),null;this.currentPart=d,!1===this.usedHeaderFooterParts.includes(d.path)&&(this.processElement(d.rootElement),this.usedHeaderFooterParts.push(d.path));let p=null;switch(d.rootElement.type){case U.Header:d.rootElement.cssStyle={left:null===(n=t.pageMargins)||void 0===n?void 0:n.left,"padding-top":t.pageMargins.header,width:null===(i=t.contentSize)||void 0===i?void 0:i.width},p=yield this.renderHeaderFooter(d.rootElement,"header",s);break;case U.Footer:d.rootElement.cssStyle={left:null===(l=t.pageMargins)||void 0===l?void 0:l.left,"padding-bottom":t.pageMargins.footer,width:null===(o=t.contentSize)||void 0===o?void 0:o.width},p=yield this.renderHeaderFooter(d.rootElement,"footer",s);break;default:console.warn("set header/footer style error",d.rootElement.type)}return this.currentPart=null,p})}renderNotes(){return n(this,arguments,void 0,function*(e=U.Footnotes,t,r,n){const a=t.map(e=>r[e]).filter(e=>e);if(a.length>0){const t=Pt("ol",null);let r=e===U.Footnotes?new Ne:new Me;r.children=a,this.processElement(r),yield this.renderChildren(r,t),n.appendChild(t)}})}renderElements(e,t){return n(this,void 0,void 0,function*(){var r,n;let a=[],s=this.document.documentPart.body.pages,{pageId:i,sectProps:l,children:o}=this.currentPage,c=s.findIndex(e=>e.pageId===i);for(let i=0;i<e.length;i++){const d=e[i];d.index=i,d.breakIndex||(d.breakIndex=new Set);const p=yield this.renderElement(d,t);let h,u=null!==(n=null===(r=null==p?void 0:p.dataset)||void 0===r?void 0:r.overflow)&&void 0!==n?n:St.UNKNOWN;switch(u){case St.SELF:d.breakIndex.add(0),d.parent.breakIndex.add(i),Et(p,t),h="break";break;case St.TRUE:case St.FULL:d.parent.breakIndex.add(i),d.type!==U.Cell&&Et(p,t),h="break";break;case St.PART:d.parent.breakIndex.add(i),h="break";break;case St.FALSE:case St.UNKNOWN:case St.IGNORE:h="continue";break;default:h="continue",this.options.debug&&console.error("unhandled overflow",u,d)}if(d.type===U.Cell&&(h="continue"),a.push(u),"continue"!==h){if(2===d.level){let e=o.splice(i);const t=new ct({sectProps:l,children:e});this.splitElementsByBreakIndex(this.currentPage,t),this.currentPage.isSplit=!0,this.currentPage.checkingOverflow=!1,this.processElement(this.currentPage),s[c]=this.currentPage,s.splice(c+1,0,t),this.currentPage=t,yield this.renderPage()}break}}if(0===a.length)return St.FALSE;let d=[St.FULL,St.SELF,St.TRUE,St.PART];return a.every(e=>e===St.PART)?St.PART:a.every(e=>d.includes(e))?St.FULL:a.every(e=>e===St.UNKNOWN)?St.UNKNOWN:a.every(e=>[St.FALSE,St.UNKNOWN,St.IGNORE].includes(e))?St.FALSE:a.some(e=>d.includes(e))?St.PART:St.UNKNOWN})}splitElementsByBreakIndex(e,r){for(let a=0;a<(null==r?void 0:r.children.length);a++){let s=r.children[a],{type:i,breakIndex:l,children:o}=s;if(!l)continue;if(!o||0===(null==o?void 0:o.length))continue;let c=t.cloneDeepWith(s,(e,t)=>{if("parent"===t)return null}),d=l.size>0?[...l][0]:o.length;switch(i){case U.Table:let t=[];t=o.filter(e=>e.isHeader);const r=o.splice(0,d);o[0].children.forEach(e=>{"continue"===e.verticalMerge&&(e.verticalMerge="restart")}),t.length>0&&t.length<o.length&&o.unshift(...t),c.children=r,e.children.push(c);break;case U.Row:if(null==s?void 0:s.isHeader)continue;e.children.push(c);break;case U.Cell:c.children=o.splice(0,d),e.children[a]=c;break;case U.Paragraph:let i=n(s);c.children=o.splice(0,d),e.children.push(c),i&&(s.cssStyle["text-indent"]="0");break;default:c.children=o.splice(0,d),e.children.push(c)}i!==U.Row&&l.size>0&&(s.breakIndex=void 0),o.length>0&&this.splitElementsByBreakIndex(c,s)}function n(e){let{breakIndex:t,children:r,type:a}=e;if(!t)return!1;if(!r||0===(null==r?void 0:r.length))return!1;let s=[...t][0];return 0===s?n(r[s]):s<r.length||void 0}}renderElement(e,t){return n(this,void 0,void 0,function*(){let r;switch(e.type){case U.Paragraph:r=yield this.renderParagraph(e,t);break;case U.Run:r=yield this.renderRun(e,t);break;case U.Text:r=yield this.renderText(e,t);break;case U.Character:r=yield this.renderCharacter(e,t);break;case U.Table:r=yield this.renderTable(e,t);break;case U.Row:r=yield this.renderTableRow(e,t);break;case U.Cell:r=yield this.renderTableCell(e,t);break;case U.Hyperlink:r=yield this.renderHyperlink(e,t);break;case U.Drawing:r=yield this.renderDrawing(e,t);break;case U.Image:r=yield this.renderImage(e,t);break;case U.BookmarkStart:r=this.renderBookmarkStart(e,t);break;case U.BookmarkEnd:r=null;break;case U.Tab:r=yield this.renderTab(e,t);break;case U.Symbol:r=yield this.renderSymbol(e,t);break;case U.Break:r=yield this.renderBreak(e,t);break;case U.LastRenderedPageBreak:r=yield this.renderLastRenderedPageBreak(e,t);break;case U.SectionBreak:r=yield this.renderSectionBreak(e,t);break;case U.Inserted:r=yield this.renderInserted(e,t);break;case U.Deleted:r=yield this.renderDeleted(e,t);break;case U.DeletedText:r=yield this.renderDeletedText(e,t);break;case U.NoBreakHyphen:r=Pt("wbr"),t&&(yield this.appendChildren(t,r));break;case U.CommentRangeStart:r=this.renderCommentRangeStart(e),t&&r&&t.appendChild(r);break;case U.CommentRangeEnd:r=this.renderCommentRangeEnd(e),t&&r&&t.appendChild(r);break;case U.CommentReference:r=yield this.renderCommentReference(e),t&&r&&t.appendChild(r);break;case U.Footer:r=yield this.renderHeaderFooter(e,"footer",t);break;case U.Header:r=yield this.renderHeaderFooter(e,"header",t);break;case U.Footnote:case U.Endnote:r=yield this.renderContainer(e,"li"),t&&At(t,r);break;case U.FootnoteReference:r=this.renderFootnoteReference(e),t&&At(t,r);break;case U.EndnoteReference:r=this.renderEndnoteReference(e),t&&At(t,r);break;case U.VmlElement:r=yield this.renderVmlElement(e,t);break;case U.VmlPicture:r=yield this.renderVmlPicture(e),t&&At(t,r);break;case U.MmlMath:r=yield this.renderContainerNS(e,wt,"math",{xmlns:wt}),t&&(r.dataset.overflow=yield this.appendChildren(t,r));break;case U.MmlMathParagraph:r=yield this.renderContainer(e,"span"),t&&At(t,r);break;case U.MmlFraction:r=yield this.renderContainerNS(e,wt,"mfrac"),t&&At(t,r);break;case U.MmlBase:r=yield this.renderContainerNS(e,wt,e.parent.type==U.MmlMatrixRow?"mtd":"mrow"),t&&At(t,r);break;case U.MmlNumerator:case U.MmlDenominator:case U.MmlFunction:case U.MmlLimit:case U.MmlBox:r=yield this.renderContainerNS(e,wt,"mrow"),t&&At(t,r);break;case U.MmlGroupChar:r=yield this.renderMmlGroupChar(e),t&&At(t,r);break;case U.MmlLimitLower:r=yield this.renderContainerNS(e,wt,"munder"),t&&At(t,r);break;case U.MmlMatrix:r=yield this.renderContainerNS(e,wt,"mtable"),t&&At(t,r);break;case U.MmlMatrixRow:r=yield this.renderContainerNS(e,wt,"mtr"),t&&At(t,r);break;case U.MmlRadical:r=yield this.renderMmlRadical(e),t&&At(t,r);break;case U.MmlSuperscript:r=yield this.renderContainerNS(e,wt,"msup"),t&&At(t,r);break;case U.MmlSubscript:r=yield this.renderContainerNS(e,wt,"msub"),t&&At(t,r);break;case U.MmlDegree:case U.MmlSuperArgument:case U.MmlSubArgument:r=yield this.renderContainerNS(e,wt,"mn"),t&&At(t,r);break;case U.MmlFunctionName:r=yield this.renderContainerNS(e,wt,"ms"),t&&At(t,r);break;case U.MmlDelimiter:r=yield this.renderMmlDelimiter(e),t&&At(t,r);break;case U.MmlRun:r=yield this.renderMmlRun(e),t&&At(t,r);break;case U.MmlNary:r=yield this.renderMmlNary(e),t&&At(t,r);break;case U.MmlPreSubSuper:r=yield this.renderMmlPreSubSuper(e),t&&At(t,r);break;case U.MmlBar:r=yield this.renderMmlBar(e),t&&At(t,r);break;case U.MmlEquationArray:r=yield this.renderMllList(e),t&&At(t,r)}return r&&1===(null==r?void 0:r.nodeType)&&(r.dataset.tag=e.type),r})}renderChildren(e,t){return n(this,void 0,void 0,function*(){return yield this.renderElements(e.children,t)})}appendChildren(e,t){return n(this,void 0,void 0,function*(){At(e,t);let{isSplit:r,contentElement:n,checkingOverflow:a}=this.currentPage;if(r)return St.UNKNOWN;if(a){return function(e){const t=getComputedStyle(e).overflow;t&&"visible"!==t||(e.style.overflow="hidden");const r=e.clientHeight<e.scrollHeight;return e.style.overflow=t,r}(n)?St.TRUE:St.FALSE}return St.UNKNOWN})}renderContainer(e,t,r){return n(this,void 0,void 0,function*(){const n=Pt(t,r);return n.dataset.overflow=yield this.renderChildren(e,n),n})}renderContainerNS(e,t,r,a){return n(this,void 0,void 0,function*(){const n=Tt(t,r,a);return yield this.renderChildren(e,n),n})}renderParagraph(e,r){return n(this,void 0,void 0,function*(){var n,a,s;const i=Pt("p");i.dataset.uuid=e.uuid,this.renderClass(e,i),Object.assign(e.cssStyle,Z(e.props,this.currentPage.sectProps)),this.renderStyleValues(e.cssStyle,i),this.renderCommonProperties(i.style,e.props);const l=this.findStyle(e.styleName);e.props.tabs=t.unionBy(e.props.tabs,null===(n=null==l?void 0:l.paragraphProps)||void 0===n?void 0:n.tabs,"position");const o=null!==(a=e.props.numbering)&&void 0!==a?a:null===(s=null==l?void 0:l.paragraphProps)||void 0===s?void 0:s.numbering;o&&i.classList.add(this.numberingClass(o.id,o.level));const c=e.children.some(e=>{var t,r;const n=null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.some(e=>e.type===U.Drawing&&e.props.wrapType===X.TopAndBottom),a=null===(r=null==e?void 0:e.children)||void 0===r?void 0:r.some(e=>{var t;return e.type===U.Break&&(null===(t=null==e?void 0:e.props)||void 0===t?void 0:t.clear)});return n||a});let d;return c&&i.classList.add("clearfix"),i.style.position="relative",d=yield this.appendChildren(r,i),d===St.TRUE?(i.dataset.overflow=St.SELF,i):(i.dataset.overflow=yield this.renderChildren(e,i),i)})}renderRun(e,t){return n(this,void 0,void 0,function*(){if(e.fieldRun)return null;const r=Pt("span");let n;if(this.renderClass(e,r),this.renderStyleValues(e.cssStyle,r),n=yield this.appendChildren(t,r),n===St.TRUE)return r.dataset.overflow=St.SELF,r;if(e.verticalAlign){const t=Pt(e.verticalAlign);return At(r,t),r.dataset.overflow=yield this.renderChildren(e,t),r}return r.dataset.overflow=yield this.renderChildren(e,r),r})}renderText(e,t){return n(this,void 0,void 0,function*(){let r=document.createTextNode("");r.dataset={overflow:St.UNKNOWN},At(t,r);let{isSplit:n}=this.currentPage;return n?(r.appendData(e.text),r):(r.dataset.overflow=yield this.renderChildren(e,r),r)})}renderCharacter(e,t){return n(this,void 0,void 0,function*(){let r=document.createTextNode(e.char);return r.dataset={overflow:St.UNKNOWN},r.dataset.overflow=yield this.appendChildren(t,r),r})}renderTable(e,t){return n(this,void 0,void 0,function*(){const r=Pt("table");let n;return r.dataset.uuid=B(),this.tableCellPositions.push(this.currentCellPosition),this.tableVerticalMerges.push(this.currentVerticalMerge),this.currentVerticalMerge={},this.currentCellPosition={col:0,row:0},this.renderClass(e,r),this.renderStyleValues(e.cssStyle,r),n=yield this.appendChildren(t,r),n===St.TRUE?(r.dataset.overflow=St.SELF,r):(e.columns&&this.renderTableColumns(e.columns,r),r.dataset.overflow=yield this.renderChildren(e,r),this.currentVerticalMerge=this.tableVerticalMerges.pop(),this.currentCellPosition=this.tableCellPositions.pop(),r)})}renderTableColumns(e,t){const r=Pt("colgroup");At(t,r);for(const t of e){const e=Pt("col");t.width&&(e.style.width=t.width),At(r,e)}return r}renderTableRow(e,t){return n(this,void 0,void 0,function*(){const r=Pt("tr");let n;return this.currentCellPosition.col=0,this.renderClass(e,r),this.renderStyleValues(e.cssStyle,r),n=yield this.appendChildren(t,r),n===St.TRUE?(r.dataset.overflow=St.SELF,r):(r.dataset.overflow=yield this.renderChildren(e,r),this.currentCellPosition.row++,r)})}renderTableCell(e,t){return n(this,void 0,void 0,function*(){const r=Pt("td"),n=this.currentCellPosition.col;let a;return e.verticalMerge?"restart"==e.verticalMerge?(this.currentVerticalMerge[n]=r,r.rowSpan=1):this.currentVerticalMerge[n]&&(this.currentVerticalMerge[n].rowSpan+=1,r.style.display="none"):this.currentVerticalMerge[n]=null,this.renderClass(e,r),this.renderStyleValues(e.cssStyle,r),e.span&&(r.colSpan=e.span),this.currentCellPosition.col+=r.colSpan,a=yield this.appendChildren(t,r),a===St.TRUE?(r.dataset.overflow=St.SELF,r):(r.dataset.overflow=yield this.renderChildren(e,r),r)})}renderHyperlink(e,t){return n(this,void 0,void 0,function*(){const r=Pt("a");let n;if(this.renderStyleValues(e.cssStyle,r),n=yield this.appendChildren(t,r),n===St.TRUE)return r.dataset.overflow=St.SELF,r;if(e.href)r.href=e.href;else if(e.id){const t=this.document.documentPart.rels.find(t=>t.id==e.id&&"External"===t.targetMode);r.href=null==t?void 0:t.target}return r.dataset.overflow=yield this.renderChildren(e,r),r})}renderDrawing(e,t){return n(this,void 0,void 0,function*(){const r=Pt("span");let n;return r.style.textIndent="0px",r.dataset.wrap=null==e?void 0:e.props.wrapType,this.renderStyleValues(e.cssStyle,r),n=yield this.appendChildren(t,r),n===St.TRUE?(r.dataset.overflow=St.SELF,r):(r.dataset.overflow=yield this.renderChildren(e,r),r)})}renderImage(e,t){return n(this,void 0,void 0,function*(){const{is_clip:r,is_transform:n}=e.props,a=new Image;this.renderStyleValues(e.cssStyle,a);const s=yield this.document.loadDocumentImage(e.src,this.currentPart);if(r||n)try{a.src=yield this.transformImage(e,s)}catch(t){console.error(`transform ${e.src} image error:`,t)}else a.src=s;return a.dataset.overflow=yield this.appendChildren(t,a),a})}renderKonva(){const e=Pt("div");e.id="konva-container",At(this.bodyContainer,e),this.konva_stage=new r.Stage({container:"konva-container"}),this.konva_layer=new r.Layer({listening:!1}),this.konva_stage.add(this.konva_layer),this.konva_stage.visible(!0)}transformImage(e,t){return n(this,void 0,void 0,function*(){const{is_clip:n,clip:a,is_transform:s,transform:i}=e.props,l=new Image;l.src=t,yield l.decode();const{naturalWidth:o,naturalHeight:c}=l;this.konva_stage.width(o),this.konva_stage.height(c),this.konva_layer.removeChildren();const d=new r.Group,p=new r.Image({image:l,x:o/2,y:c/2,width:o,height:c,offset:{x:o/2,y:c/2}});if(n){const{left:e,right:t,top:r,bottom:n}=a.path,s=o*e,i=c*r,l=o*(1-e-t),d=c*(1-r-n);p.crop({x:s,y:i,width:l,height:d}),p.size({width:l,height:d})}if(s)for(const e in i)switch(e){case"scaleX":p.scaleX(i[e]);break;case"scaleY":p.scaleY(i[e]);break;case"rotate":p.rotation(i[e])}let h;if(d.add(p),this.konva_layer.add(d),this.options.useBase64URL)h=d.toDataURL();else{const e=yield d.toBlob();h=URL.createObjectURL(e)}return h})}renderBookmarkStart(e,t){const r=Pt("span");return r.id=e.name,At(t,r),r.dataset.overflow=St.IGNORE,r}renderTab(e,t){return n(this,void 0,void 0,function*(){var r;const n=Pt("span");if(n.innerHTML="&nbsp;",this.options.experimental){n.className=this.tabStopClass();const t=null===(r=function(e,t){let r=e.parent;for(;null!=r&&r.type!=t;)r=r.parent;return r}(e,U.Paragraph).props)||void 0===r?void 0:r.tabs;this.currentTabs.push({stops:t,span:n})}return t&&(yield this.appendChildren(t,n)),n})}renderSymbol(e,t){return n(this,void 0,void 0,function*(){const r=Pt("span");let n;return r.style.fontFamily=e.font,r.innerHTML=`&#x${e.char};`,n=yield this.appendChildren(t,r),n===St.TRUE&&(r.dataset.overflow=St.SELF),r.dataset.overflow=n,r})}renderBreak(e,t){return n(this,void 0,void 0,function*(){let r;switch(e.break){case W.Page:r=Pt("br"),r.classList.add("break","page");break;case W.Column:r=Pt("br"),r.classList.add("break","column");break;case W.TextWrapping:default:r=Pt("br"),r.classList.add("break","textWrap")}let n=yield this.appendChildren(t,r);return n===St.TRUE&&(n=St.SELF),r.dataset.overflow=n,r})}renderLastRenderedPageBreak(e,t){return n(this,void 0,void 0,function*(){const e=Pt("wbr");e.classList.add("lastRenderedPageBreak");let r=yield this.appendChildren(t,e);return r===St.TRUE&&(r=St.SELF),e.dataset.overflow=r,e})}renderSectionBreak(e,t){return n(this,void 0,void 0,function*(){const r=Pt("s");r.classList.add("break","section");let n=yield this.appendChildren(t,r);return n===St.TRUE&&(n=St.SELF),r.dataset.overflow=n,r.dataset.type=e.break,r})}renderInserted(e,t){return n(this,void 0,void 0,function*(){const r=Pt(this.options.renderChanges?"ins":"span");let n;return n=yield this.appendChildren(t,r),n===St.TRUE?(r.dataset.overflow=St.SELF,r):(r.dataset.overflow=yield this.renderChildren(e,r),r)})}renderDeleted(e,t){return n(this,void 0,void 0,function*(){let r,n=Pt("del");return!1===this.options.renderChanges&&(n.style.display="none"),r=yield this.appendChildren(t,n),r===St.TRUE?(n.dataset.overflow=St.SELF,n):(n.dataset.overflow=yield this.renderChildren(e,n),n)})}renderDeletedText(e,t){return n(this,void 0,void 0,function*(){return this.options.renderChanges,this.renderText(e,t)})}renderCommentRangeStart(e){var t;if(!this.options.renderComments)return null;const r=new Range;null===(t=this.commentHighlight)||void 0===t||t.add(r);const n=document.createComment(`start of comment #${e.id}`);return this.later(()=>r.setStart(n,0)),this.commentMap[e.id]=r,n}renderCommentRangeEnd(e){if(!this.options.renderComments)return null;const t=this.commentMap[e.id],r=document.createComment(`end of comment #${e.id}`);return this.later(()=>null==t?void 0:t.setEnd(r,0)),r}renderCommentReference(e){return n(this,void 0,void 0,function*(){var t;if(!this.options.renderComments)return null;var r=null===(t=this.document.commentsPart)||void 0===t?void 0:t.commentMap[e.id];if(!r)return null;const n=new DocumentFragment,a=Pt("span",{className:`${this.className}-comment-ref`});a.textContent="💬";const s=Pt("div",{className:`${this.className}-comment-popover`});return yield this.renderCommentContent(r,s),n.appendChild(document.createComment(`comment #${r.id} by ${r.author} on ${r.date}`)),n.appendChild(a),n.appendChild(s),n})}renderCommentContent(e,t){return n(this,void 0,void 0,function*(){const r=Pt("div",{className:`${this.className}-comment-author`});r.textContent=e.author,t.appendChild(r);const n=Pt("div",{className:`${this.className}-comment-date`});n.textContent=new Date(e.date).toLocaleString(),t.appendChild(n),yield this.renderElements(e.children,t)})}renderHeaderFooter(e,t,r){return n(this,void 0,void 0,function*(){const n=Pt(t);return At(r,n),this.renderStyleValues(e.cssStyle,n),yield this.renderChildren(e,n),n})}renderFootnoteReference(e){const t=Pt("sup");return this.currentFootnoteIds.push(e.id),t.textContent=`${this.currentFootnoteIds.length}`,t}renderEndnoteReference(e){const t=Pt("sup");return this.currentEndnoteIds.push(e.id),t.textContent=`${this.currentEndnoteIds.length}`,t}renderVmlElement(e,t){return n(this,void 0,void 0,function*(){var r,n;const a=Nt("svg");a.setAttribute("style",e.cssStyleText);const s=yield this.renderVmlChildElement(e);if(null===(r=e.imageHref)||void 0===r?void 0:r.id){const t=yield null===(n=this.document)||void 0===n?void 0:n.loadDocumentImage(e.imageHref.id,this.currentPart);s.setAttribute("href",t)}return At(a,s),requestAnimationFrame(()=>{const e=a.firstElementChild.getBBox();a.setAttribute("width",`${Math.ceil(e.x+e.width)}`),a.setAttribute("height",`${Math.ceil(e.y+e.height)}`)}),t&&(a.dataset.overflow=yield this.appendChildren(t,a)),a})}renderVmlPicture(e){return n(this,void 0,void 0,function*(){const t=Pt("span");return yield this.renderChildren(e,t),t})}renderVmlChildElement(e){return n(this,void 0,void 0,function*(){const t=Nt(e.tagName);Object.entries(e.attrs).forEach(([e,r])=>t.setAttribute(e,r));for(const r of e.children)if(r.type==U.VmlElement){const e=yield this.renderVmlChildElement(r);At(t,e)}else yield this.renderElement(r,t);return t})}renderMmlRadical(e){return n(this,void 0,void 0,function*(){var t;const r=e.children.find(e=>e.type==U.MmlBase);let n;if(null===(t=e.props)||void 0===t?void 0:t.hideDegree)return n=Tt(wt,"msqrt",null),yield this.renderElements([r],n),n;const a=e.children.find(e=>e.type==U.MmlDegree);return n=Tt(wt,"mroot",null),yield this.renderElements([r,a],n),n})}renderMmlDelimiter(e){return n(this,void 0,void 0,function*(){var t,r;const n=Tt(wt,"mrow",null);return At(n,Tt(wt,"mo",null,[null!==(t=e.props.beginChar)&&void 0!==t?t:"("])),yield this.renderElements(e.children,n),At(n,Tt(wt,"mo",null,[null!==(r=e.props.endChar)&&void 0!==r?r:")"])),n})}renderMmlNary(e){return n(this,void 0,void 0,function*(){var r,n;const a=[],s=t.keyBy(e.children,"type"),i=s[U.MmlSuperArgument],l=s[U.MmlSubArgument];let o=i?Tt(wt,"mo",null,F(yield this.renderElement(i))):null,c=l?Tt(wt,"mo",null,F(yield this.renderElement(l))):null,d=Tt(wt,"mo",null,[null!==(n=null===(r=e.props)||void 0===r?void 0:r.char)&&void 0!==n?n:"∫"]);o||c?a.push(Tt(wt,"munderover",null,[d,c,o])):o?a.push(Tt(wt,"mover",null,[d,o])):c?a.push(Tt(wt,"munder",null,[d,c])):a.push(d);const p=Tt(wt,"mrow",null);return At(p,a),yield this.renderElements(s[U.MmlBase].children,p),p})}renderMmlPreSubSuper(e){return n(this,void 0,void 0,function*(){const r=[],n=t.keyBy(e.children,"type"),a=n[U.MmlSuperArgument],s=n[U.MmlSubArgument];let i=a?Tt(wt,"mo",null,F(yield this.renderElement(a))):null,l=s?Tt(wt,"mo",null,F(yield this.renderElement(s))):null,o=Tt(wt,"mo",null);r.push(Tt(wt,"msubsup",null,[o,l,i]));const c=Tt(wt,"mrow",null);return At(c,r),yield this.renderElements(n[U.MmlBase].children,c),c})}renderMmlGroupChar(e){return n(this,void 0,void 0,function*(){let t="bot"===e.props.verticalJustification?"mover":"munder",r=yield this.renderContainerNS(e,wt,t);if(e.props.char){At(r,Tt(wt,"mo",null,[e.props.char]))}return r})}renderMmlBar(e){return n(this,void 0,void 0,function*(){let t=yield this.renderContainerNS(e,wt,"mrow");switch(e.props.position){case"top":t.style.textDecoration="overline";break;case"bottom":t.style.textDecoration="underline"}return t})}renderMmlRun(e){return n(this,void 0,void 0,function*(){const t=Tt(wt,"ms");return this.renderClass(e,t),this.renderStyleValues(e.cssStyle,t),yield this.renderChildren(e,t),t})}renderMllList(e){return n(this,void 0,void 0,function*(){const t=Tt(wt,"mtable");this.renderClass(e,t),this.renderStyleValues(e.cssStyle,t);for(const r of e.children){const e=yield this.renderElement(r),n=Tt(wt,"mtd",null,[e]);At(t,Tt(wt,"mtr",null,[n]))}return t})}renderStyleValues(e,t){for(const r in e)r.startsWith("$")?t.setAttribute(r.slice(1),e[r]):t.style[r]=e[r]}renderRunProperties(e,t){this.renderCommonProperties(e,t)}renderCommonProperties(e,t){null!=t&&(t.color&&(e.color=t.color),t.fontSize&&(e["font-size"]=t.fontSize))}renderClass(e,t){e.className&&(t.className=e.className),e.styleName&&t.classList.add(this.processStyleName(e.styleName))}findStyle(e){var t;return e&&(null===(t=this.styleMap)||void 0===t?void 0:t[e])}tabStopClass(){return`${this.className}-tab-stop`}refreshTabStops(){if(this.options.experimental)for(const e of this.currentTabs)ot(e.span,e.stops,this.defaultTabSize,this.pointToPixelRatio)}}function Pt(e,t){return Tt(null,e,t)}function Nt(e,t){return Tt(xt,e,t)}function Tt(e,t,r,n){let a;switch(e){case"http://www.w3.org/1998/Math/MathML":case"http://www.w3.org/2000/svg":a=document.createElementNS(e,t);break;default:a=document.createElement(t)}return r&&Object.assign(a,r),n&&At(a,n),a}function Mt(e){e.innerHTML=""}function At(e,r){if(e instanceof Element&&(Array.isArray(r)?e.append(...r):t.isString(r)?e.append(r):e.appendChild(r)),e instanceof Text){if(Array.isArray(r))throw new Error("Text append children: children must be text node");r instanceof Text&&e.appendData(r.wholeText)}}function Et(e,t){if(void 0!==t){if(t instanceof Text){if(Array.isArray(e))throw new Error("Text remove target: target must be text node!");e instanceof Text&&t.deleteData(t.length-e.length,e.length)}t instanceof Element&&(Array.isArray(e)?e.forEach(e=>{e instanceof Element?e.remove():t.removeChild(e)}):e instanceof Element?e.remove():t.removeChild(e))}else if(Array.isArray(e))e.forEach(e=>{if(!(e instanceof Element))throw new Error("removeElements: target must be Element!");e.remove()});else{if(!(e instanceof Element))throw new Error("removeElements: target must be Element!");e.remove()}}function Rt(e){return Pt("style",{innerHTML:e})}function $t(e,t){e.appendChild(document.createComment(t))}const Dt={breakPages:!0,className:"docx",ignoreFonts:!1,ignoreHeight:!1,ignoreImageWrap:!1,ignoreLastRenderedPageBreak:!0,ignoreTableWrap:!0,ignoreWidth:!1,inWrapper:!0,hideWrapperOnPrint:!1,renderAltChunks:!0,renderChanges:!1,renderComments:!1,renderEndnotes:!0,renderFooters:!0,renderFootnotes:!0,renderHeaders:!0,trimXmlDeclaration:!0,useBase64URL:!1,debug:!1,experimental:!1};function Ft(e,t=null){const r=Object.assign(Object.assign({},Dt),t);return Oe.load(e,new rt(r),r)}function Bt(e,t,r){return n(this,arguments,void 0,function*(e,t,r,n=!0,a){const s=Object.assign(Object.assign({},Dt),a),i=n?new Ct:new ut;yield i.render(e,t,r,s)})}function Lt(e,t){return n(this,arguments,void 0,function*(e,t,r=null,n=null){const a=yield Ft(e,n);return yield Bt(a,t,r,!0,n),a})}function jt(e,t,r,a){return n(this,void 0,void 0,function*(){const n=yield Ft(e,a);return yield Bt(n,t,r,!1,a),n})}export{Dt as defaultOptions,Ft as parseAsync,jt as renderAsync,Bt as renderDocument,Lt as renderSync};
2
+ //# sourceMappingURL=docx-preview.esm.min.js.map