"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6727],{76727:(t,e,r)=>{let i;r.d(e,{parseDOCX:()=>tx});var n=r(81769);function a(t,e){let r=t.indexOf("\r",e),i=t.indexOf("\n",e);return -1===i?r:-1===r||r+1===i?i:r1?l[t.line-2]:0)+t.column-1;if(e-1&&t<=s.length){let e=0;for(;;){let r=l[e];if(void 0===r){let t=a(s,l[e-1]);r=-1===t?s.length+1:t+1,l[e]=r}if(r>t)return{line:e+1,column:t-(e>0?l[e-1]:0)+1,offset:t};e++}}}});try{i=(0,n.parseXml)(String(t),{includeOffsets:!0,preserveCdata:!0,preserveComments:!0,preserveDocumentType:!0,preserveXmlDeclaration:!0})}catch(e){let t=new u("Could not parse XML with `@rgrove/parse-xml`",{cause:e,place:o.toPoint(e.pos),ruleId:"error",source:"xast-util-from-xml"});throw t.fatal=!0,t.url="https://github.com/syntax-tree/xast-util-from-xml#throws",t}let c={location:o},p=(e=i,r=c,{type:"root",children:function t(e,r){let i=[],n=-1;for(;++nt.includes(e)}let E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function k(t){let e=t.length,r=Array.from({length:4*Math.ceil(e/3)}),i=0;for(let n=0;n>2,u=(3&a)<<4|s>>4,c=(15&s)<<2|l>>6,h=63&l;r[i++]=E[o],r[i++]=E[u],r[i++]=n+1typeof window;async function S(t){let e=await t;return e.default||e}var F=class{#t=!1;constructor({enableHWA:t=!1}={}){this.#t=t}create(t,e){let r=this._createCanvas(t,e);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,r){if(!t)throw Error("Canvas is not specified");t.width=e,t.height=r}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=void 0,t.context=void 0}_createCanvas(t,e){throw Error("Not implemented")}},j=class extends F{_document;constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let r=this._document.createElement("canvas");return r.width=t,r.height=e,r}},D=class extends F{constructor({enableHWA:t=!1}={}){super({enableHWA:t})}_createCanvas(t,e){if(!i)throw Error("@napi-rs/canvas module is not resolved");return i.createCanvas(t,e)}};async function R(t){i??=await S(t())}async function A(t){if(P)return j;if(M){if(!t)throw Error("In Node.js environment, @napi-rs/canvas is required for image cropping. Please provide canvasImport parameter or install it: pnpm add @napi-rs/canvas");return await R(t),D}throw Error("Unsupported environment for canvas operations")}async function _(t,e,r={}){if(!e||!e.left&&!e.top&&!e.right&&!e.bottom||!1===r.enabled)return t;try{let i=await A(r.canvasImport),n=await $(t,i),a=(e.left||0)/1e5*n.width,s=(e.top||0)/1e5*n.height,l=(e.right||0)/1e5*n.width,o=(e.bottom||0)/1e5*n.height,u=Math.round(n.width-a-l),c=Math.round(n.height-s-o),h=n.width-a-l,p=n.height-s-o;if(u<=0||c<=0)return console.warn("Invalid crop dimensions, returning original image"),t;let f=new i().create(u,c);if(!f.context)throw Error("Failed to get 2D context from canvas");f.context.drawImage(n,a,s,h,p,0,0,u,c);let d=r.quality??.92,w="image/jpeg"===r.contentType?"image/jpeg":"image/webp"===r.contentType?"image/webp":"image/png",b="image/png"===w?f.canvas.toDataURL():f.canvas.toDataURL(w,d),g=await (await fetch(b)).arrayBuffer();return new Uint8Array(g)}catch(e){return console.warn("Image cropping failed, returning original image:",e),t}}async function $(t,e){if(P){let e=new Blob([t.buffer]),r=URL.createObjectURL(e);try{let t=new Image;return new Promise((e,i)=>{t.onload=()=>{URL.revokeObjectURL(r),e(t)},t.onerror=()=>{URL.revokeObjectURL(r),i(Error("Failed to load image"))},t.src=r})}catch(t){throw URL.revokeObjectURL(r),t}}if(!i)throw Error("@napi-rs/canvas module is not resolved");return await i.loadImage(w.from(t))}let U={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/bmp":"bmp","image/tiff":"tif","image/x-emf":"emf","image/x-wmf":"wmf","image/x-icon":"ico","image/svg+xml":"svg"},W=N(["left","right","center","inside","outside"]),B=N(["top","bottom","center","inside","outside"]),X=N(["page","character","column","margin","leftMargin","rightMargin","insideMargin","outsideMargin"]),z=N(["page","paragraph","margin","topMargin","bottomMargin","insideMargin","outsideMargin","line"]);function Y(t){let e=t.attributes.l,r=t.attributes.t,i=t.attributes.r,n=t.attributes.b;if(e||r||i||n)return{left:e?parseInt(e,10):void 0,top:r?parseInt(r,10):void 0,right:i?parseInt(i,10):void 0,bottom:n?parseInt(n,10):void 0}}function J(t){return t.match(/^data:([^;]+);/)?.[1]}async function H(t,e,r){if(!(x(t,"pic:spPr")||x(t,"wps:spPr"))||!e.src.startsWith("data:"))return e;let i=I(t,"a:srcRect");if(!i)return e;let n=Y(i);if(!n||!n.left&&!n.top&&!n.right&&!n.bottom)return e;let a={...e,crop:n};if(r.context.image?.crop)try{let[t,i]=e.src.split(",");if(!i)return a;let s=k(await _(C(i),n,{canvasImport:r.context.image?.canvasImport,enabled:!0,contentType:e.contentType||J(e.src)})),l=e.width||0,o=e.height||0,u=(n.left||0)/1e5,c=(n.top||0)/1e5,h=(n.right||0)/1e5,p=(n.bottom||0)/1e5,f=e.contentType||J(e.src);a.src=f?`data:${f};base64,${s}`:`${t},${s}`,a.width=Math.round(l*(1-u-h)),a.height=Math.round(o*(1-c-p)),delete a.crop}catch(t){console.warn("Grouped image cropping failed, using original image:",t)}return a}function q(t){let e=x(t,"w:drawing");if(e)return e;let r=x(t,"mc:AlternateContent"),i=r&&x(r,"mc:Choice");return i?x(i,"w:drawing"):null}async function G(t,e){let r=new Map,i=t["word/_rels/document.xml.rels"];if(!i)return r;let{extToMime:n,extToShort:a}=function(t){let e=new Map,r=new Map,i=t["[Content_Types].xml"];if(!i)return{extToMime:e,extToShort:r};try{let t=x(c(new TextDecoder().decode(i)),"Types");if(!t)return{extToMime:e,extToShort:r};for(let i of T(t,"Default")){let t=i.attributes.Extension,n=i.attributes.ContentType;if(t&&n){e.set(t.toLowerCase(),n);let i=U[n];i&&r.set(t.toLowerCase(),i)}}}catch{}return{extToMime:e,extToShort:r}}(t),s=x(c(new TextDecoder().decode(i)),"Relationships");if(!s)return r;for(let i of T(s,"Relationship"))if("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"===i.attributes.Type&&i.attributes.Id&&i.attributes.Target){let s,l,o,u="word/"+i.attributes.Target,c=t[u];if(!c)continue;let h=function(t,e){let r=t.split(".").pop()?.toLowerCase();return r?e.get(r):void 0}(u,a),p=u.split(".").pop()?.toLowerCase();p&&(s=n.get(p)),!h&&s&&(h=U[s]);try{let t=(0,d.L)(c);l=t.width,o=t.height,!h&&t.type&&(h=t.type)}catch{}h||(h="png");let f=(await (e??L)({id:i.attributes.Id,contentType:s||`image/${h}`,data:c})).src;r.set(i.attributes.Id,{src:f,contentType:s||`image/${h}`,width:l,height:o})}return r}async function K(t,e){let r,i,n,a,s,l,{context:o}=e,u=I(t,"a:blip");if(!u?.attributes["r:embed"])return null;let c=u.attributes["r:embed"],h=o.images.get(c);if(!h)return null;let p=h.src,f=I(t,"a:srcRect");if(f){let t=Y(f);if(t&&(t.left||t.top||t.right||t.bottom)&&(r=t,o.image?.crop&&p.startsWith("data:"))){let[e,i]=p.split(",");if(i){let n=C(i);try{let i=k(await _(n,t,{canvasImport:o.image?.canvasImport,enabled:!0,contentType:h.contentType||J(p)})),a=h.contentType||J(p);p=a?`data:${a};base64,${i}`:`${e},${i}`,r=void 0}catch(t){console.warn("Image cropping failed, using original image:",t)}}}}let d=I(t,"wp:extent");if(d){let t=d.attributes.cx,e=d.attributes.cy;"string"==typeof t&&(i=v(t)),"string"==typeof e&&(n=v(e))}let w=I(t,"a:xfrm");if(w?.attributes.rot){let t=parseInt(w.attributes.rot,10);isNaN(t)||(a=t/6e4)}let b=I(t,"wp:docPr")?.attributes.title,g=I(t,"wp:anchor"),m=g?x(g,"wp:positionH"):void 0,y=g?x(g,"wp:positionV"):void 0;if(g){let t,e=m?function(t){let e,r=x(t,"wp:align"),i=x(t,"wp:posOffset");if(r?.children[0]?.type==="text"){let t=r.children[0].value;W(t)&&(e=t)}let n=i?.children[0]?.type==="text"?parseInt(i.children[0].value,10):void 0;if(e||void 0!==n)return{...e&&{align:e},...void 0!==n&&{offset:n}}}(m):void 0,r=m?.attributes.relativeFrom,i="string"==typeof r&&X(r)?r:"page",n=y?function(t){let e,r=x(t,"wp:align"),i=x(t,"wp:posOffset");if(r?.children[0]?.type==="text"){let t=r.children[0].value;B(t)&&(e=t)}let n=i?.children[0]?.type==="text"?parseInt(i.children[0].value,10):void 0;if(e||void 0!==n)return{...e&&{align:e},...void 0!==n&&{offset:n}}}(y):void 0,a=y?.attributes.relativeFrom,l="string"==typeof a&&z(a)?a:"page",o=g.attributes,u="1"===o.behindDoc,c="1"===o.allowOverlap,h="1"===o.locked,p="0"!==o.layoutInCell,f=o.relativeHeight,d=f?parseInt(f):void 0,w=x(g,"wp:wrapSquare"),b=x(g,"wp:wrapTight"),v=x(g,"wp:wrapTopAndBottom");if(x(g,"wp:wrapNone"),w){let e=w.attributes.wrapText;t={type:1,...e&&{side:e}}}else t=b?{type:2}:v?{type:3}:{type:0};let I=t=>{if(!t)return;let e=parseInt(t,10);if(!isNaN(e)&&0!==e)return e},T=I(o.distT),O=I(o.distB),N=I(o.distL),E=I(o.distR);s={horizontalPosition:{relative:i,...e?.align&&{align:e.align},...e?.offset!==void 0&&{offset:e.offset}},verticalPosition:{relative:l,...n?.align&&{align:n.align},...n?.offset!==void 0&&{offset:n.offset}},...u&&{behindDocument:u},...c&&{allowOverlap:c},...!h&&{lockAnchor:!1},...!p&&{layoutInCell:!1},...void 0!==d&&!isNaN(d)&&{zIndex:d},...t&&{wrap:t},...(T||O||N||E)&&{margins:{...T&&{top:T},...O&&{bottom:O},...N&&{left:N},...E&&{right:E}}}}}let T=I(t,"pic:spPr");if(T){let t=I(T,"a:ln"),e=t&&I(t,"a:solidFill"),r=e&&I(e,"a:srgbClr");r?.attributes.val&&(l={type:"solidFill",color:{value:r.attributes.val}})}return{type:"image",attrs:{src:p,alt:"",...void 0!==i&&{width:i},...void 0!==n&&{height:n},...void 0!==a&&{rotation:a},...b&&{title:b},...s&&{floating:s},...l&&{outline:l},...r&&{crop:r}}}}async function V(t,e){let r,i,n=[],a=x(t,"wp:inline")||x(t,"wp:anchor");if(!a)return n;let s=x(a,"wp:extent");if(s){let t=s.attributes.cx,e=s.attributes.cy;"string"==typeof t&&(r=v(t)),"string"==typeof e&&(i=v(e))}let l=x(a,"a:graphic");if(!l)return n;let o=x(l,"a:graphicData");if(!o)return n;let u=x(o,"wpg:wgp");if(u){let t=x(u,"wpg:grpSp"),a=t?[...T(t,"pic:pic"),...T(t,"pic")]:[...T(u,"pic:pic"),...T(u,"pic")],s=t?T(t,"wps:wsp"):T(u,"wps:wsp"),l=[];for(let t of a){let e=x(t,"a:graphic"),r=null,i=x(t,"pic:spPr");if(i){let t=x(i,"a:xfrm");if(t){let e=x(t,"a:ext");e&&e.attributes.cx&&e.attributes.cy&&(r={cx:parseInt(e.attributes.cx,10),cy:parseInt(e.attributes.cy,10)})}}l.push({pic:t,picGraphic:e,relativeSize:r,isWsp:!1})}for(let t of s){let e=x(t,"a:graphic"),r=null,i=x(t,"wps:spPr");if(i){let t=x(i,"a:xfrm");if(t){let e=x(t,"a:ext");e&&e.attributes.cx&&e.attributes.cy&&(r={cx:parseInt(e.attributes.cx,10),cy:parseInt(e.attributes.cy,10)})}}l.push({pic:t,picGraphic:e,relativeSize:r,isWsp:!0})}let o=0;for(let t of l)t.relativeSize&&(o+=t.relativeSize.cx);let c=o>0&&r?r/o:1;for(let t of l){let{pic:a,picGraphic:s,relativeSize:l,isWsp:u}=t;if(!s){let t=u?x(a,"wps:blipFill")||I(a,"a:blipFill"):x(a,"pic:blipFill")||I(a,"a:blipFill");if(!t)continue;let s=x(t,"a:blip")||I(t,"a:blip");if(!s?.attributes["r:embed"])continue;let h=s.attributes["r:embed"],p=e.context.images.get(h);if(!p)continue;let f=await H(a,p,e),d=f.width,w=f.height;r&&i&&l&&o>0?(d=Math.round(l.cx*c),w=Math.round(l.cy*c)):r&&i&&(d=r,w=i),n.push({type:"image",attrs:{src:f.src,alt:"",width:d,height:w,...f.crop&&{crop:f.crop}}});continue}let h=await K({type:"element",name:"w:drawing",children:[s],attributes:{}},e);h&&(r&&i&&l&&o>0?(h.attrs.width=Math.round(l.cx*c),h.attrs.height=Math.round(l.cy*c)):r&&i&&(h.attrs.width=r,h.attrs.height=i),n.push(h))}}else{let r=await K(t,e);r&&n.push(r)}return n}function Z(t){if(!t)return null;let e=t.attributes["w:val"],r=t.attributes["w:sz"],i=t.attributes["w:color"],n=t.attributes["w:space"],a={single:"single",dashed:"dashed",dotted:"dotted",double:"double",dotDash:"dotDash",dotDotDash:"dotDotDash",none:"none",nil:"none"},s={};return i&&"auto"!==i&&(s.color=`#${i}`),r&&(s.size=parseInt(r)),e&&a[e]&&(s.style=a[e]),n&&(s.space=parseInt(n)),Object.keys(s).length>0?s:null}function Q(t){if(!t)return null;let e=x(t,"w:pBdr");if(!e)return null;let r={},i=Z(x(e,"w:top"));i&&(r.borderTop=i);let n=Z(x(e,"w:bottom"));n&&(r.borderBottom=n);let a=Z(x(e,"w:left"));a&&(r.borderLeft=a);let s=Z(x(e,"w:right"));return s&&(r.borderRight=s),Object.keys(r).length>0?r:null}function tt(t){if(!t)return null;let e=x(t,"w:shd");if(!e)return null;let r={};if(e.attributes["w:fill"]){let t=e.attributes["w:fill"];r.fill=t.startsWith("#")?t:`#${t}`}if(e.attributes["w:color"]&&"auto"!==e.attributes["w:color"]){let t=e.attributes["w:color"];r.color=t.startsWith("#")?t:`#${t}`}return e.attributes["w:val"]&&(r.type=e.attributes["w:val"]),Object.keys(r).length>0?r:null}function te(t){let e={},r=O(t.attributes,"w:left")||O(t.attributes,"w:start");r&&(e.indentLeft=y(parseInt(r,10)));let i=O(t.attributes,"w:right")||O(t.attributes,"w:end");i&&(e.indentRight=y(parseInt(i,10)));let n=t.attributes["w:firstLineChars"];n&&(e.indentFirstLineChars=parseInt(n,10));let a=O(t.attributes,"w:firstLine");if(a&&(e.indentFirstLine=y(parseInt(a,10))),!a&&!n){let i=O(t.attributes,"w:hanging");i&&(e.indentFirstLine=y((r?parseInt(r,10):0)-parseInt(i,10)))}return Object.keys(e).length>0?e:null}function tr(t,e){let r=[],i=e??"",n=new Set;for(;null!=i&&!n.has(i);){n.add(i);let e=t.get(i);if(!e)break;r.push(e),i=e.basedOn}if(0===r.length)return;let a={styleId:e??r[0].styleId};for(let t=r.length-1;t>=0;t--){let e=r[t];void 0===a.name&&(a.name=e.name),void 0===a.outlineLvl&&(a.outlineLvl=e.outlineLvl),void 0===a.basedOn&&(a.basedOn=e.basedOn),e.charFormat&&(a.charFormat=a.charFormat?{...e.charFormat,...a.charFormat}:{...e.charFormat}),e.paragraphFormat&&(a.paragraphFormat=a.paragraphFormat?{...e.paragraphFormat,...a.paragraphFormat}:{...e.paragraphFormat})}return a}function ti(t,e){let r=x(t,"w:pPr"),i={};if(e?.paragraphFormat){let t=e.paragraphFormat;t.indentLeft&&(i.indentLeft=t.indentLeft),t.indentRight&&(i.indentRight=t.indentRight),t.indentFirstLine&&(i.indentFirstLine=t.indentFirstLine),t.indentFirstLineChars&&(i.indentFirstLineChars=t.indentFirstLineChars),t.shading&&(i.shading=t.shading),t.borderTop&&(i.borderTop=t.borderTop),t.borderBottom&&(i.borderBottom=t.borderBottom),t.borderLeft&&(i.borderLeft=t.borderLeft),t.borderRight&&(i.borderRight=t.borderRight)}if(!r)return Object.keys(i).length>0?i:null;let n=x(r,"w:ind");if(n){let t=te(n);t&&Object.assign(i,t)}let a=x(r,"w:spacing");if(a){let t=O(a.attributes,"w:before");t&&(i.spacingBefore=y(parseInt(t,10)));let e=O(a.attributes,"w:after");e&&(i.spacingAfter=y(parseInt(e,10)))}let s=tt(r);s&&(i.shading=s);let l=Q(r);return l&&Object.assign(i,l),Object.keys(i).length>0?i:null}function tn(t,e){let r=x(t,"w:t");if(!r)return null;let i=r.children.find(t=>"text"===t.type);if(!i?.value)return null;let n=ts(t,e);return{type:"text",text:i.value,...n.length&&{marks:n}}}async function ta(t,e){let{context:r,styleInfo:i}=e,n=[];for(let e of t.children)if("element"===e.type){if("w:hyperlink"===e.name){let t=e.attributes["r:id"],a=r.hyperlinks.get(t);if(!a)continue;for(let t of e.children){if("element"!==t.type||"w:r"!==t.name)continue;let e=q(t);if(e){let t=await K(e,{context:r});if(t){n.push(t);continue}let i=await V(e,{context:r});if(i.length){n.push(...i);continue}}let s=tn(t,i);s&&(s.marks=s.marks||[],s.marks.push({type:"link",attrs:{href:a}}),n.push(s))}}else if("w:r"===e.name){let t=q(e);if(t){let e=await V(t,{context:r});if(e.length){n.push(...e);continue}}if(x(e,"w:br")){let t=ts(e,i);n.push({type:"hardBreak",...t.length&&{marks:t}})}let a=tn(e,i);a&&n.push(a)}}return n}function ts(t,e){let r=[],i=x(t,"w:rPr"),n={};if(e?.charFormat&&(n={...e.charFormat}),i){let t=x(i,"w:b");if(t){let e=t.attributes["w:val"];"0"===e||"false"===e?n.bold=!1:n.bold=!0}let e=x(i,"w:i");if(e){let t=e.attributes["w:val"];"0"===t||"false"===t?n.italic=!1:n.italic=!0}let a=x(i,"w:u");if(a){let t=a.attributes["w:val"];"none"!==t&&"false"!==t&&"0"!==t&&(n.underline=!0)}let s=x(i,"w:strike");if(s){let t=s.attributes["w:val"];"0"!==t&&"false"!==t&&(n.strike=!0)}let l=x(i,"w:dstrike");if(l){let t=l.attributes["w:val"];"0"!==t&&"false"!==t&&(n.doubleStrike=!0,n.strike=!1)}let o=x(i,"w:spacing");if(o?.attributes["w:val"]){let t=parseInt(o.attributes["w:val"]);isNaN(t)||(n.characterSpacing=t)}let u=x(i,"w:rtl");if(u){let t=u.attributes["w:val"];"0"!==t&&"false"!==t&&(n.rtl=!0)}let c=x(i,"w:color");if(c?.attributes["w:val"]&&"auto"!==c.attributes["w:val"]){let t=c.attributes["w:val"];n.color=t.startsWith("#")?t:`#${t}`}let h=x(i,"w:sz");if(h?.attributes["w:val"]){let t=parseInt(h.attributes["w:val"],10);isNaN(t)||(n.fontSize=t)}let p=x(i,"w:rFonts");p?.attributes["w:ascii"]&&(n.fontFamily=p.attributes["w:ascii"]);let f=x(i,"w:shd");if(f?.attributes["w:fill"]&&"auto"!==f.attributes["w:fill"]){let t=f.attributes["w:fill"];n.backgroundColor=t.startsWith("#")?t:`#${t}`}let d=x(i,"w:highlight");if(d){let t=d.attributes["w:val"];t&&"none"!==t&&r.push({type:"highlight",attrs:{color:t}})}let w=x(i,"w:vertAlign");if(w){let t=w.attributes["w:val"];"subscript"===t?r.push({type:"subscript"}):"superscript"===t&&r.push({type:"superscript"})}}if(n.bold&&r.push({type:"bold"}),n.italic&&r.push({type:"italic"}),n.underline&&r.push({type:"underline"}),n.strike&&r.push({type:"strike"}),n.doubleStrike&&r.push({type:"strike",attrs:{doubleStrike:!0}}),n.color||n.backgroundColor||n.fontSize||n.fontFamily||n.characterSpacing||n.rtl){let t={color:n.color||"",backgroundColor:n.backgroundColor||"",fontSize:"",fontFamily:"",lineHeight:"",letterSpacing:"",rtl:!1};n.fontSize&&(t.fontSize=`${Math.round(n.fontSize*b*10)/10}px`),n.fontFamily&&(t.fontFamily=n.fontFamily),n.characterSpacing&&(t.letterSpacing=`${n.characterSpacing/15}px`),n.rtl&&(t.rtl=!0),r.push({type:"textStyle",attrs:t})}return r}function tl(t){let e=x(t,"w:pPr");if(!e)return;let r=x(e,"w:jc");if(!r?.attributes["w:val"])return;let i=m[r.attributes["w:val"]];return i?{textAlign:i}:void 0}async function to(t,e){var r;let i,n,{context:a,styleInfo:s}=e,l=x(t,"w:pPr"),o=(l&&x(l,"w:pStyle"))?.attributes["w:val"];if(l){let r=x(l,"w:outlineLvl");if(r?.attributes["w:val"]!==void 0){let i=parseInt(r.attributes["w:val"],10);if(i>=0&&i<=5)return tu(t,e,a.styleMap?tr(a.styleMap,o):void 0,i+1)}}if(o&&a.styleMap){let r=tr(a.styleMap,o);if(r?.outlineLvl!==void 0&&r.outlineLvl>=0&&r.outlineLvl<=5)return tu(t,e,r,r.outlineLvl+1);let i=o.match(/^Heading(\d+)$/);if(i)return tu(t,e,r,parseInt(i[1],10))}let u=a.styleMap?tr(a.styleMap,o):void 0,c=await ta(t,{context:a,styleInfo:s||u}),h={...tl(t),...ti(t,u)};if(1===c.length&&"hardBreak"===c[0].type){let e=x(t,"w:r");if((e&&x(e,"w:br"))?.attributes["w:type"]==="page")return{type:"horizontalRule"}}if(r=t,i=[],(n=t=>{if("w:r"===t.name)i.push(t);else for(let e of t.children)"element"===e.type&&n(e)})(r),i.some(t=>x(t,"w:br")?.attributes["w:type"]==="page")){let t=c.filter(t=>"hardBreak"!==t.type);return[{type:"paragraph",...Object.keys(h).length&&{attrs:h},content:t.length?t:void 0},{type:"horizontalRule"}]}if(1===c.length&&"image"===c[0].type){let t=c[0];return{type:"paragraph",...Object.keys(h).length&&{attrs:h},content:[t]}}return{type:"paragraph",...Object.keys(h).length&&{attrs:h},content:c}}async function tu(t,e,r,i){return{type:"heading",attrs:{level:i,...ti(t,r)},content:await ta(t,{context:e.context,styleInfo:r})}}function tc(t){let e={colspan:1,rowspan:1,colwidth:null},r=x(t,"w:tcPr");if(!r)return e;let i=x(r,"w:gridSpan");i?.attributes["w:val"]&&(e.colspan=parseInt(i.attributes["w:val"]));let n=x(r,"w:vMerge");n&&("restart"===n.attributes["w:val"]?e.rowspan=1:e.rowspan=0);let a=x(r,"w:tcW");if(a?.attributes["w:w"]){let t=parseInt(a.attributes["w:w"]),r=a.attributes["w:type"];"pct"===r?e.colwidth=[Math.round(t/50)]:"auto"===r||"nil"===r||isNaN(t)||(e.colwidth=[Math.round(96*t/1440*10)/10])}let s=x(r,"w:shd");s?.attributes["w:fill"]&&"auto"!==s.attributes["w:fill"]&&(e.backgroundColor=`#${s.attributes["w:fill"]}`);let l=x(r,"w:vAlign");l?.attributes["w:val"]&&(e.verticalAlign=({top:"top",center:"middle",bottom:"bottom",both:"middle"})[l.attributes["w:val"]]);let o=x(r,"w:noWrap");if(o){let t=o.attributes["w:val"];"0"!==t&&"false"!==t&&(e.noWrap=!0)}let u=x(r,"w:textDirection");if(u?.attributes["w:val"]){let t=u.attributes["w:val"];("lrTb"===t||"tbRl"===t||"btLr"===t)&&(e.textDirection=t)}let c=x(r,"w:tcBorders");if(c){let t=Z(x(c,"w:top"));t&&(e.borderTop=t);let r=Z(x(c,"w:bottom"));r&&(e.borderBottom=r);let i=Z(x(c,"w:left")||x(c,"w:start"));i&&(e.borderLeft=i);let n=Z(x(c,"w:right")||x(c,"w:end"));n&&(e.borderRight=n)}return e}async function th(t,e){let r=[];for(let e of t.children)"element"===e.type&&"w:tr"===e.name&&r.push(e);let i=new Map,n=[];for(let t=0;t0){e.activeRowspans.set(i,t-1),i++;continue}let a=tc(n);if(a?.rowspan===1){let t=function(t){let e=1,r=t.colIndex;for(let i=t.rowIndex+1;i=0&&s1&&(a={...a,rowspan:t})}if(a?.rowspan&&a.rowspan>1&&e.activeRowspans.set(i,a.rowspan-1),a?.rowspan===0){i++;continue}let s=await tf(n,e);r.push({type:"tableCell",...a&&{attrs:a},content:s}),i+=a?.colspan||1}return{type:"tableRow",...n&&{attrs:n},content:r}}async function tf(t,e){let r=[];for(let i of t.children)if("element"===i.type&&"w:p"===i.name){let t=await to(i,e);Array.isArray(t)?r.push(...t):r.push(t)}return r.length?r:[{type:"paragraph",content:[]}]}function td(t){let e=x(t,"w:r");if(!e)return null;let r=x(e,"w:t");if(!r)return null;let i=r.children.find(t=>"text"===t.type);return i?.value&&i||null}function tw(t){let e=td(t);if(!e)return!1;let r=e.value;return r.startsWith("☐")||r.startsWith("☑")}async function tb(t,e){return{type:"taskItem",attrs:{checked:td(t)?.value.startsWith("☑")||!1},content:[await tm(t,e)]}}async function tg(t,e){let{siblings:r,index:i,processedIndices:n}=e,a=[],s=i;for(;s0&&"text"===n[0].type){let t=n[0],e=t.text;if(e.startsWith("☐")||e.startsWith("☑")){let r=e.substring(2).trimStart();r?t.text=r:n.shift()}}let a=tl(t);return{type:"paragraph",...a&&{attrs:a},content:n.length?n:void 0}}function ty(t){let e=x(t,"w:pPr");return!!e&&void 0!==x(e,"w:numPr")}function tv(t){let e=x(t,"w:pPr"),r=e&&x(e,"w:numPr");if(!r)return null;let i=x(r,"w:ilvl"),n=x(r,"w:numId");return i&&n?{numId:n.attributes["w:val"],level:parseInt(i.attributes["w:val"]||"0",10)}:null}async function tx(t,e={}){let r=(0,p.AO)(await (0,f.Fo)(t)),i=function(t){let e=new Map,r=t["word/_rels/document.xml.rels"];if(!r)return e;let i=x(c(new TextDecoder().decode(r)),"Relationships");if(!i)return e;for(let t of T(i,"Relationship"))"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"===t.attributes.Type&&t.attributes.Id&&t.attributes.Target&&e.set(t.attributes.Id,t.attributes.Target);return e}(r),n=await G(r,e.image?.handler),a=r["word/document.xml"];if(!a)throw Error("Invalid DOCX file: missing word/document.xml");let s=c(new TextDecoder().decode(a)),l=function(t){let e=new Map,r=new Map,i=t["word/numbering.xml"];if(!i)return e;let n=c(new TextDecoder().decode(i)),a=new Map,s=x(n,"w:numbering");if(!s)return e;for(let t of T(s,"w:abstractNum")){let e=t.attributes["w:abstractNumId"],i=x(t,"w:lvl");if(!i)continue;let n=x(i,"w:numFmt");n?.attributes["w:val"]&&a.set(e,n.attributes["w:val"]);let s=x(i,"w:start");s?.attributes["w:val"]&&r.set(e,parseInt(s.attributes["w:val"],10))}for(let t of T(s,"w:num")){let i=t.attributes["w:numId"],n=x(t,"w:abstractNumId");if(!n?.attributes["w:val"])continue;let s=n.attributes["w:val"],l=a.get(s);if(!l)continue;let o=r.get(s);"bullet"===l?e.set(i,{type:"bullet"}):"none"===l||e.set(i,{type:"ordered",...void 0!==o&&{start:o}})}return e}(r),o=function(t){let e=new Map,r=t["word/styles.xml"];if(!r)return e;let i=x(c(new TextDecoder().decode(r)),"w:styles");if(!i)return e;for(let t of T(i,"w:style").filter(t=>"paragraph"===t.attributes["w:type"])){let r=t.attributes["w:styleId"];if(!r)continue;let i={styleId:r},n=x(t,"w:name");n?.attributes["w:val"]&&(i.name=n.attributes["w:val"]);let a=x(t,"w:pPr");if(a){let t=x(a,"w:outlineLvl");t?.attributes["w:val"]!==void 0&&(i.outlineLvl=parseInt(t.attributes["w:val"],10));let e=x(a,"w:basedOn");e?.attributes["w:val"]&&(i.basedOn=e.attributes["w:val"]);let r=Q(a),n=tt(a),s=x(a,"w:ind"),l=s?te(s):null;if(r||n||l){let t={};l&&Object.assign(t,l),r&&Object.assign(t,r),n&&(t.shading=n),Object.keys(t).length>0&&(i.paragraphFormat=t)}}let s=x(t,"w:rPr");if(s){let t={},e=x(s,"w:color");if(e?.attributes["w:val"]&&"auto"!==e.attributes["w:val"]){let r=e.attributes["w:val"];t.color=r.startsWith("#")?r:`#${r}`}let r=x(s,"w:b");if(r){let e=r.attributes["w:val"];"0"!==e&&"false"!==e&&(t.bold=!0)}let n=x(s,"w:i");if(n){let e=n.attributes["w:val"];"0"!==e&&"false"!==e&&(t.italic=!0)}let a=x(s,"w:u");if(a){let e=a.attributes["w:val"];"none"!==e&&"false"!==e&&"0"!==e&&(t.underline=!0)}let l=x(s,"w:strike");if(l){let e=l.attributes["w:val"];"0"!==e&&"false"!==e&&(t.strike=!0)}let o=x(s,"w:sz");if(o?.attributes["w:val"]){let e=parseInt(o.attributes["w:val"],10);isNaN(e)||(t.fontSize=e)}let u=x(s,"w:rFonts");u?.attributes["w:ascii"]&&(t.fontFamily=u.attributes["w:ascii"]);let c=x(s,"w:dstrike");if(c){let e=c.attributes["w:val"];"0"!==e&&"false"!==e&&(t.doubleStrike=!0)}let h=x(s,"w:spacing");if(h?.attributes["w:val"]){let e=parseInt(h.attributes["w:val"]);isNaN(e)||(t.characterSpacing=e)}let p=x(s,"w:rtl");if(p){let e=p.attributes["w:val"];"0"!==e&&"false"!==e&&(t.rtl=!0)}Object.keys(t).length>0&&(i.charFormat=t)}e.set(r,i),"1"===t.attributes["w:default"]&&e.set("",i)}return e}(r);return await tI(s,{context:{...e,hyperlinks:i,images:n,listTypeMap:l,styleMap:o}})}async function tI(t,e){if("root"!==t.type)return{type:"doc",content:[]};let r=x(t,"w:document");if(!r)return{type:"doc",content:[]};let i=x(r,"w:body");return i?{type:"doc",content:await tT(i.children.filter(t=>"element"===t.type),e)}:{type:"doc",content:[]}}async function tT(t,e){let r=[],i=new Set;for(let n=0;n"text"===t.type);if(e&&"value"in e&&e.value&&e.value.trim().length>0)return!1}if(x(e,"w:drawing")||x(e,"mc:AlternateContent")||x(e,"w:pict"))return!1;let r=x(e,"w:br");if(r&&"page"===r.attributes["w:type"])return!1}return!0}(a))continue;let s=await tO(a,t,n,e,i);Array.isArray(s)?r.push(...s):s&&r.push(s)}return r}async function tO(t,e,r,i,n){switch(t.name){case"w:tbl":return await th(t,i);case"w:p":let a,s;if(a=x(t,"w:pPr"),(s=(a&&x(a,"w:pStyle"))?.attributes["w:val"])===g||s?.startsWith("Code")||0)return await tN(t);if(tw(t))return await tg(t,{...i,siblings:e,index:r,processedIndices:n});if(ty(t))return await tE(t,e,r,i,n);if(function(t){let e=x(t,"w:r");if(!e)return!1;let r=!1,i=!1;for(let t of e.children)"element"===t.type&&("w:br"===t.name&&"page"===t.attributes["w:type"]?r=!0:"w:t"===t.name?t.children.find(t=>"text"===t.type)?.value?.trim().length&&(i=!0):"w:rPr"!==t.name&&(i=!0));return r&&!i}(t))return{type:"horizontalRule"};return await to(t,i);default:return null}}async function tN(t){let e=function(t){let e=x(t,"w:pPr"),r=(e&&x(e,"w:pStyle"))?.attributes["w:val"];if(r?.startsWith(g))return r.replace(g,"").toLowerCase()||void 0}(t),r=function(t){let e=[];for(let r of T(t,"w:r")){let t=x(r,"w:t");if(!t)continue;let i=t.children.find(t=>"text"===t.type);i&&"value"in i&&i.value&&e.push({type:"text",text:i.value})}return e}(t);return{type:"codeBlock",...e&&{attrs:{language:e}},content:r}}async function tE(t,e,r,i,n){let a=tv(t);if(!a)return await to(t,i);let s=i.context.listTypeMap.get(a.numId);if(!s)return await to(t,i);let l=s.type,o=[],u=r;for(;u{var e=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a={},s={XmlCdata:()=>T,XmlComment:()=>O,XmlDeclaration:()=>N,XmlDocument:()=>k,XmlDocumentType:()=>C,XmlElement:()=>E,XmlError:()=>L,XmlNode:()=>x,XmlProcessingInstruction:()=>M,XmlText:()=>I,parseXml:()=>F};for(var l in s)e(a,l,{get:s[l],enumerable:!0});t.exports=((t,a,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let l of i(a))n.call(t,l)||void 0===l||e(t,l,{get:()=>a[l],enumerable:!(s=r(a,l))||s.enumerable});return t})(e({},"__esModule",{value:!0}),a);var o=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,u=class{constructor(t){if(this.k=this.u(t,!0),this.d=0,this.length=t.length,this.l=this.k!==this.length,this.h=t,this.l){let e=[];for(let r=0,i=0;i65535?2:1;this.A=e}}get B(){return this.d>=this.k}u(t,e=this.l){return e?t.replace(o,"_").length:t.length}p(t=1){this.d=Math.min(this.k,this.d+t)}f(t=this.d){var e;return this.l?null!=(e=this.A[t])?e:1/0:t}G(t=1){let e=this.m(t);return this.p(t),e}v(t){let e=this.f(),r=this.h.slice(e,e+t);return this.p(this.u(r)),r}w(t){let{length:e,l:r,h:i}=this,n=this.f(),a=n;if(r)for(;a="\uD800"&&e<="\uDBFF";if(r&&(e+=i[a+1]),!t(e))break;a+=r?2:1}else for(;a0?this.v(e):""}s(t){let e=this.f(),r=this.h.indexOf(t,e);return r>0?this.v(r-e):""}m(t=1){let{d:e,h:r}=this;return this.l?r.slice(this.f(e),this.f(e+t)):r.slice(e,e+t)}n(t=0){this.d=t>=0?Math.min(this.k,t):Math.max(0,this.d+t)}},c=/["&<]/,h=/['&<]/,p=/\r\n|[\n\r\t]/g,f=/<|&|]]>/,d=Object.freeze(Object.assign(Object.create(null),{amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}));function w(t){let e=t.codePointAt(0);return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||45===e||46===e||183===e||e>=768&&e<=879||8255===e||8256===e||b(t,e)}function b(t,e=t.codePointAt(0)){return e>=97&&e<=122||e>=65&&e<=90||58===e||95===e||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||8204===e||8205===e||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function g(t){return"#"===t||w(t)}function m(t){let e=t.codePointAt(0);return 32===e||9===e||10===e||13===e}function y(t){return t>=32&&t<=55295||10===t||9===t||13===t||t>=57344&&t<=65533||t>=65536&&t<=1114111}var v=class t{constructor(){this.parent=null,this.start=-1,this.end=-1}get document(){var t,e;return null!=(e=null==(t=this.parent)?void 0:t.document)?e:null}get isRootNode(){return null!==this.parent&&this.parent===this.document&&this.type===t.TYPE_ELEMENT}get preserveWhitespace(){var t;return!!(null==(t=this.parent)?void 0:t.preserveWhitespace)}get type(){return""}toJSON(){let t={type:this.type};return this.isRootNode&&(t.isRootNode=!0),this.preserveWhitespace&&(t.preserveWhitespace=!0),-1!==this.start&&(t.start=this.start,t.end=this.end),t}};v.TYPE_CDATA="cdata",v.TYPE_COMMENT="comment",v.TYPE_DOCUMENT="document",v.TYPE_DOCUMENT_TYPE="doctype",v.TYPE_ELEMENT="element",v.TYPE_PROCESSING_INSTRUCTION="pi",v.TYPE_TEXT="text",v.TYPE_XML_DECLARATION="xmldecl";var x=v,I=class extends x{constructor(t=""){super(),this.text=t}get type(){return x.TYPE_TEXT}toJSON(){return Object.assign(x.prototype.toJSON.call(this),{text:this.text})}},T=class extends I{get type(){return x.TYPE_CDATA}},O=class extends x{constructor(t=""){super(),this.content=t}get type(){return x.TYPE_COMMENT}toJSON(){return Object.assign(x.prototype.toJSON.call(this),{content:this.content})}},N=class extends x{constructor(t,e,r){super(),this.version=t,this.encoding=null!=e?e:null,this.standalone=null!=r?r:null}get type(){return x.TYPE_XML_DECLARATION}toJSON(){let t=x.prototype.toJSON.call(this);for(let e of(t.version=this.version,["encoding","standalone"]))null!==this[e]&&(t[e]=this[e]);return t}},E=class t extends x{constructor(t,e=Object.create(null),r=[]){super(),this.name=t,this.attributes=e,this.children=r}get isEmpty(){return 0===this.children.length}get preserveWhitespace(){let e=this;for(;e instanceof t;){if("xml:space"in e.attributes)return"preserve"===e.attributes["xml:space"];e=e.parent}return!1}get text(){return this.children.map(t=>"text"in t?t.text:"").join("")}get type(){return x.TYPE_ELEMENT}toJSON(){return Object.assign(x.prototype.toJSON.call(this),{name:this.name,attributes:this.attributes,children:this.children.map(t=>t.toJSON())})}},k=class extends x{constructor(t=[]){super(),this.children=t}get document(){return this}get root(){for(let t of this.children)if(t instanceof E)return t;return null}get text(){return this.children.map(t=>"text"in t?t.text:"").join("")}get type(){return x.TYPE_DOCUMENT}toJSON(){return Object.assign(x.prototype.toJSON.call(this),{children:this.children.map(t=>t.toJSON())})}},C=class extends x{constructor(t,e,r,i){super(),this.name=t,this.publicId=null!=e?e:null,this.systemId=null!=r?r:null,this.internalSubset=null!=i?i:null}get type(){return x.TYPE_DOCUMENT_TYPE}toJSON(){let t=x.prototype.toJSON.call(this);for(let e of(t.name=this.name,["publicId","systemId","internalSubset"]))null!==this[e]&&(t[e]=this[e]);return t}},L=class extends Error{constructor(t,e,r){let i=1,n="",a=1;for(let t=0;t50&&(i<40?n=n.slice(0,50):(l=i-20,n=n.slice(l,i+30))),super(`${t} (line ${a}, column ${i}) ${n} `+" ".repeat(i-l+1)+"^\n"),this.column=i,this.excerpt=n,this.line=a,this.name="XmlError",this.pos=e}},M=class extends x{constructor(t,e=""){super(),this.name=t,this.content=e}get type(){return x.TYPE_PROCESSING_INSTRUCTION}toJSON(){return Object.assign(x.prototype.toJSON.call(this),{name:this.name,content:this.content})}},P=class{constructor(t,e={}){let r=this.document=new k;this.j=r,this.g=e,this.c=new u(t),this.g.includeOffsets&&(r.start=0,r.end=t.length),this.parse()}i(t,e){return t.parent=this.j,this.g.includeOffsets&&(t.start=this.c.f(e),t.end=this.c.f()),this.j.children.push(t),!0}y(t,e){let{children:r}=this.j,{length:i}=r;if(t=S(t),i>0){let e=r[i-1];if((null==e?void 0:e.type)===x.TYPE_TEXT)return e.text+=t,this.g.includeOffsets&&(e.end=this.c.f()),!0}return this.i(new I(t),e)}H(){let t=Object.create(null);for(;this.e();){let e=this.q();if(!e)break;let r=this.t()&&this.I();if(!1===r)throw this.a("Attribute value expected");if(e in t)throw this.a(`Duplicate attribute: ${e}`);if("xml:space"===e&&"default"!==r&&"preserve"!==r)throw this.a('Value of the `xml:space` attribute must be "default" or "preserve"');t[e]=r}if(this.g.sortAttributes){let e=Object.keys(t).sort(),r=Object.create(null);for(let i=0;i");if(this.o(r),!t.b("]]>"))throw this.a("Unclosed CDATA section");return this.g.preserveCdata?this.i(new T(S(r)),e):this.y(r,e)}K(){let{c:t}=this,e=t.d,r=t.x(f);if(!r)return!1;if(this.o(r),"]]>"===t.m(3))throw this.a("Element content may not contain the CDATA section close delimiter `]]>`");return this.y(r,e)}D(){let{c:t}=this,e=t.d;if(!t.b("\x3c!--"))return!1;let r=t.s("--");if(this.o(r),!t.b("--\x3e")){if("--"===t.m(2))throw this.a("The string `--` isn't allowed inside a comment");throw this.a("Unclosed comment")}return!this.g.preserveComments||this.i(new O(S(r)),e)}L(){let t=this.c.d,e=this.C();return!!e&&this.y(e,t)}M(){let t,e,r,{c:i}=this,n=i.d;if(!i.b("/),!i.b("]"))throw this.a("Unclosed internal subset");this.e()}if(!i.b(">"))throw this.a("Unclosed doctype declaration");return!this.g.preserveDocumentType||this.i(new C(a,t,e,r),n)}E(){let{c:t}=this,e=t.d;if(!t.b("<"))return!1;let r=this.q();if(!r)return t.n(e),!1;let i=this.H(),n=!!t.b("/>"),a=new E(r,i);if(a.parent=this.j,!n){let e;if(!t.b(">"))throw this.a(`Unclosed start tag for element \`${r}\``);this.j=a;do this.K();while(this.E()||this.L()||this.J()||this.F()||this.D());let i=t.d;if(!t.b(""))throw this.a(`Unclosed end tag for element ${r}`);this.j=a.parent}return this.i(a,e)}t(){return this.e(),!!this.c.b("=")&&(this.e(),!0)}z(){return this.D()||this.F()||this.e()}q(){return b(this.c.m())?this.c.w(w):""}F(){let{c:t}=this,e=t.d;if(!t.b(""))return this.i(new M(r),e);throw this.a("Whitespace is required after a processing instruction name")}let i=t.s("?>");if(this.o(i),!t.b("?>"))throw this.a("Unterminated processing instruction");return this.i(new M(r,S(i)),e)}O(){let{c:t}=this,e=t.d;for(this.P();this.z(););if(this.M())for(;this.z(););return e"))throw this.a("Invalid or unclosed XML declaration");return!this.g.preserveXmlDeclaration||this.i(new N(n,t||void 0,e||void 0),i)}a(t){let{c:e}=this;return new L(t,e.d,e.h)}parse(){if(this.c.b("\uFEFF"),this.O(),!this.E())throw this.a("Root element is missing or invalid");for(;this.z(););if(!this.c.B)throw this.a("Extra content at the end of the document")}o(t){let{length:e}=t;for(let r=0;r65535&&(r+=1)}}};function S(t){let e=0;for(;-1!==(e=t.indexOf("\r",e));)t="\n"===t[e+1]?t.slice(0,e)+t.slice(e+1):t.slice(0,e)+"\n"+t.slice(e+1);return t}function F(t,e){return new P(t,e).document}}}]);