efficient-office 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{countWords as e,documentText as t,findInNodes as n,pageBlocks as r,pageDocument as o,pageStarts as a,pageStyles as i,replaceSpots as l,sanitizeHtml as s}from"./chunk-EC6D54MM.js";import{DocumentsConflict as c,useDocumentsHost as d,useDocumentsWords as u}from"./chunk-HNNYUGDU.js";import"./chunk-POH6OTTR.js";import{FileList as m}from"./chunk-PMGQ5GUH.js";import"./chunk-B32ASXHM.js";import{importDocumentFile as f}from"./chunk-O35VT6BD.js";import{fingerprintOf as p,headerKindFor as h,marginTextOfHtml as g,readDocx as w,readParts as b,stampFingerprints as y,tocEntryHtml as v}from"./chunk-YKQ5UKYZ.js";import{BUILTIN_STYLES as x,CHECK_BULLETS as k,HIGHLIGHTS as C,MARGIN_PRESETS as S,PAPER_SIZES as N,REL as $,WEB_FONTS as A,WORD_NS as L,addContentDefault as P,addContentOverride as T,addRel as M,blankDocxParts as R,child as E,escapeXml as z,marginsOf as F,paperOf as O,paraCss as j,parseParaProps as H,parseRunProps as D,parseTabsAttr as I,parseXml as B,partText as U,readRels as W,resolveTarget as q,runCss as K,setPartText as G,tabCss as V,tabsAttr as X,webFontSheetUrl as Q,withMargins as _,withPaper as J,writeZip as Y}from"./chunk-D3JKD7KW.js";import{hasExtension as Z,placeCopy as ee}from"./chunk-XYVQTQ6N.js";import{useEffect as te,useRef as ne,useState as re}from"react";import{WindowTitle as oe,useWindowDirty as ae}from"efficient-shell";import{Button as ie,EmptyState as le,Input as se,LoadingSpinner as ce,confirmDestructive as de,toast as ue}from"efficient-shell/ui";import{useCallback as me,useEffect as fe,useId as pe,useMemo as he,useRef as ge,useState as we}from"react";import{saveIndicator as be,useAutosave as ye}from"efficient-easel/autosave";import{useEaselStrings as ve}from"efficient-easel/strings";import{Icon as xe}from"efficient-shell/icons";import{Button as ke,ColorPickerPanel as Ce,ContextMenu as Se,DropdownMenu as Ne,IconButton as $e,Popover as Ae,PopupMenu as Le,PopupMenuDivider as Pe,PopupMenuItem as Te,PopupMenuLabel as Me,prompt as Re,registerModalEscapeInterceptor as Ee,toast as ze,useShellLocale as Fe}from"efficient-shell/ui";import{SettingsColour as Oe}from"efficient-easel/panel";import{useEaselStrings as je}from"efficient-easel/strings";import{Button as He,Select as De}from"efficient-shell/ui";import{jsx as Ie,jsxs as Be}from"react/jsx-runtime";function Ue({page:e,onPage:t,onMorePageSetup:n,colour:r,onColour:o,outline:a,onHeading:i}){const l=u(),s=je(),c=O(e),d=F(e),m={a4:"A4",a3:"A3",a5:"A5",letter:l.paperLetter,legal:l.paperLegal},f={normal:l.marginsNormal,narrow:l.marginsNarrow,moderate:l.marginsModerate,wide:l.marginsWide},p={value:"custom",label:l.custom};return Be("aside",{className:"docs-panel",children:[Ie("h3",{children:l.documentPanel}),Be("div",{className:"docs-panel-section",children:[Ie("p",{className:"docs-panel-label",children:l.pagePanel}),Ie(De,{"aria-label":l.paperSize,value:c??"custom",onChange:n=>{"custom"!==n&&t(J(e,n))},options:[...c?[]:[p],...Object.keys(N).map(e=>({value:e,label:m[e]}))]}),Ie(De,{"aria-label":l.margins,value:d??"custom",onChange:n=>{"custom"!==n&&t(_(e,n))},options:[...d?[]:[p],...Object.keys(S).map(e=>({value:e,label:f[e]}))]}),Ie(He,{variant:"secondary",block:!0,onClick:n,children:l.morePageSetup})]}),Ie("div",{className:"docs-panel-section",children:Ie(Oe,{label:l.textColor,value:r,onChange:o,words:s.colourRow})}),Be("div",{className:"docs-panel-section",children:[Ie("p",{className:"docs-panel-label",children:l.outline}),0===a.length?Ie("p",{className:"docs-panel-empty",children:l.outlineEmpty}):Ie("ul",{className:"docs-outline",children:a.map((e,t)=>Ie("li",{style:{paddingLeft:10*(e.level-1)+"px"},children:Ie("button",{type:"button",onClick:()=>i(t),children:e.text})},t))})]})]})}import{EaselIconButton as We,EaselTopBar as qe,SaveState as Ke,TopBarCluster as Ge,TopBarDivider as Ve}from"efficient-easel/chrome";import"efficient-easel/shell.css";import"efficient-easel/chrome.css";import"efficient-easel/panel.css";import"efficient-easel/fields.css";import{Icon as Xe}from"efficient-shell/icons";import{DropdownMenu as Qe}from"efficient-shell/ui";import{jsx as _e,jsxs as Je}from"react/jsx-runtime";function Ye({onClose:e,fileMenu:t,name:n,saveState:r,canUndo:o,canRedo:a,onUndo:i,onRedo:l,exportControl:s}){const c=u();return Je(qe,{children:[Je(Ge,{children:[e&&_e(We,{label:c.backToFiles,onClick:e,children:_e(Xe,{name:"chevron-left",size:16})}),t.length>0&&_e(Qe,{trigger:c.menuFile,items:t,align:"start",triggerClassName:"docs-menu-trigger"}),n,_e(Ke,{...r}),_e(Ve,{}),Je("span",{className:"docs-history",onMouseDown:e=>e.preventDefault(),children:[_e(We,{label:c.undo,disabled:!o,onClick:i,children:_e(Xe,{name:"undo",size:16})}),_e(We,{label:c.redo,disabled:!a,onClick:l,children:_e(Xe,{name:"redo",size:16})})]})]}),_e(Ge,{kind:"right",children:s})]})}var Ze=["w:rStyle","w:rFonts","w:b","w:bCs","w:i","w:iCs","w:caps","w:smallCaps","w:strike","w:dstrike","w:outline","w:shadow","w:emboss","w:imprint","w:noProof","w:snapToGrid","w:vanish","w:webHidden","w:color","w:spacing","w:w","w:kern","w:position","w:sz","w:szCs","w:highlight","w:u","w:effect","w:bdr","w:shd","w:fitText","w:vertAlign","w:rtl","w:cs","w:em","w:lang","w:eastAsianLayout","w:specVanish","w:oMath","w:rPrChange"],et=["w:pStyle","w:keepNext","w:keepLines","w:pageBreakBefore","w:framePr","w:widowControl","w:numPr","w:suppressLineNumbers","w:pBdr","w:shd","w:tabs","w:suppressAutoHyphens","w:kinsoku","w:wordWrap","w:overflowPunct","w:topLinePunct","w:autoSpaceDE","w:autoSpaceDN","w:bidi","w:adjustRightInd","w:snapToGrid","w:spacing","w:ind","w:contextualSpacing","w:mirrorIndents","w:suppressOverlap","w:jc","w:textDirection","w:textAlignment","w:textboxTightWrap","w:outlineLvl","w:divId","w:cnfStyle","w:rPr","w:sectPr","w:pPrChange"],tt=["w:cnfStyle","w:tcW","w:gridSpan","w:hMerge","w:vMerge","w:tcBorders","w:shd","w:noWrap","w:tcMar","w:textDirection","w:tcFitText","w:vAlign","w:hideMark","w:headers","w:cellIns","w:cellDel","w:cellMerge","w:tcPrChange"],nt=["w:headerReference","w:footerReference","w:footnotePr","w:endnotePr","w:type","w:pgSz","w:pgMar","w:paperSrc","w:pgBorders","w:lnNumType","w:pgNumType","w:cols","w:formProt","w:vAlign","w:noEndnote","w:titlePg","w:textDirection","w:bidi","w:rtlGutter","w:docGrid","w:printerSettings","w:sectPrChange"];function rt(e){if(!e)return[];return B(e).children.map(t=>({name:t.name,xml:e.slice(t.start,t.end)}))}function ot(e,t){const n=e=>{const n=t.indexOf(e);return n<0?t.length:n};return e.map((e,t)=>({p:e,i:t})).sort((e,t)=>n(e.p.name)-n(t.p.name)||e.i-t.i).map(e=>e.p.xml).join("")}function at(e){const t=new Map;for(const n of(e.getAttribute("style")??"").split(";")){const e=n.indexOf(":");e>0&&t.set(n.slice(0,e).trim().toLowerCase(),n.slice(e+1).trim())}return t}var it={black:"#000000",white:"#ffffff",red:"#ff0000",blue:"#0000ff",green:"#008000",yellow:"#ffff00"};function lt(e){if(!e)return;const t=e.trim().toLowerCase();if("transparent"===t||"inherit"===t||"initial"===t||"auto"===t)return;if(it[t])return it[t];if(/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t))return`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`;const n=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+))?\s*\)$/.exec(t);return!n||void 0!==n[4]&&0===Number(n[4])?void 0:`#${[n[1],n[2],n[3]].map(e=>Math.round(Number(e)).toString(16).padStart(2,"0")).join("")}`}function st(e){if(!e)return;const t=/^(-?[\d.]+)(pt|px|in|cm|mm|em)?$/.exec(e.trim());if(!t)return;const n=Number(t[1]);switch(t[2]){case"pt":return n;case"px":return.75*n;case"in":return 72*n;case"cm":return 72*n/2.54;case"mm":return 72*n/25.4;default:return"0"===t[1]?0:void 0}}var ct=[10,13,16,18,24,32,48].map(e=>.75*e);var dt=(e,t)=>void 0===e||void 0===t?e===t:Math.abs(e-t)<.02,ut=e=>Math.round(20*e);function mt(e,t,n){return ft(n?e.runs.get(n):void 0,t,e)}function ft(e,t,n){const r=e?B(e):void 0,o=D(r,n.theme);let a=rt(e);const i=(e,t)=>{a=a.filter(t=>!e.includes(t.name)),a.push(...t)},l=(e,t)=>void 0===t?[]:[{name:e,xml:t?`<${e}/>`:`<${e} w:val="0"/>`}];if(t.b!==o.b&&i(["w:b","w:bCs"],[...l("w:b",t.b),...l("w:bCs",t.b)]),t.i!==o.i&&i(["w:i","w:iCs"],[...l("w:i",t.i),...l("w:iCs",t.i)]),!!t.u!=!!o.u&&i(["w:u"],t.u?[{name:"w:u",xml:'<w:u w:val="single"/>'}]:o.u?[{name:"w:u",xml:'<w:u w:val="none"/>'}]:[]),t.strike!==o.strike&&!!t.strike!=!!o.strike&&i(["w:strike"],l("w:strike",t.strike)),t.vert!==o.vert&&i(["w:vertAlign"],t.vert?[{name:"w:vertAlign",xml:`<w:vertAlign w:val="${"sub"===t.vert?"subscript":"superscript"}"/>`}]:[]),t.font!==o.font){const e=z(t.font??"");i(["w:rFonts"],t.font?[{name:"w:rFonts",xml:`<w:rFonts w:ascii="${e}" w:hAnsi="${e}" w:eastAsia="${e}" w:cs="${e}"/>`}]:[])}if(t.size!==o.size){const e=t.size?Math.round(2*t.size):0;i(["w:sz","w:szCs"],e?[{name:"w:sz",xml:`<w:sz w:val="${e}"/>`},{name:"w:szCs",xml:`<w:szCs w:val="${e}"/>`}]:[])}if(t.color!==o.color&&i(["w:color"],t.color?[{name:"w:color",xml:`<w:color w:val="${t.color.slice(1).toUpperCase()}"/>`}]:[]),t.hl!==o.hl){const e=t.hl?Object.entries(C).find(([,e])=>e===t.hl)?.[0]:void 0;i(["w:highlight","w:shd"],t.hl?e?[{name:"w:highlight",xml:`<w:highlight w:val="${e}"/>`}]:[{name:"w:shd",xml:`<w:shd w:val="clear" w:color="auto" w:fill="${t.hl.slice(1).toUpperCase()}"/>`}]:[])}const s=ot(a,Ze);return s?`<w:rPr>${s}</w:rPr>`:""}var pt={FootnoteText:'<w:style w:type="paragraph" w:styleId="FootnoteText"><w:name w:val="footnote text"/><w:basedOn w:val="Normal"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style>',FootnoteReference:'<w:style w:type="character" w:styleId="FootnoteReference"><w:name w:val="footnote reference"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:rPr><w:vertAlign w:val="superscript"/></w:rPr></w:style>',TOCHeading:'<w:style w:type="paragraph" w:styleId="TOCHeading"><w:name w:val="TOC Heading"/><w:basedOn w:val="Heading1"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/></w:style>',...Object.fromEntries([1,2,3,4,5,6].map(e=>[`TOC${e}`,`<w:style w:type="paragraph" w:styleId="TOC${e}"><w:name w:val="toc ${e}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="100"/><w:ind w:left="${220*(e-1)}"/></w:pPr></w:style>`]))};function ht(e){const t=W(e.parts,e.doc.docPath).find(e=>e.type===$.styles);return t?q(e.doc.docPath,t.target):void 0}function gt(e,t){const n=ht(e);if(!n)return;const r=U(e.parts,n);if(!r||new RegExp(`w:styleId="${t}"`).test(r))return;const o=x[t]?.xml??pt[t];o&&G(e.parts,n,r.replace("</w:styles>",`${o}</w:styles>`))}var wt=["w:name","w:aliases","w:basedOn","w:next","w:link","w:autoRedefine","w:hidden","w:uiPriority","w:semiHidden","w:unhideWhenUsed","w:qFormat","w:locked","w:personal","w:personalCompose","w:personalReply","w:rsid","w:pPr","w:rPr","w:tblPr","w:trPr","w:tcPr","w:tblStylePr"];function bt(e,t){let n=rt(e);const r=(e,t)=>{n=n.filter(t=>t.name!==e),t&&n.push({name:e,xml:t})};t.align&&r("w:jc",`<w:jc w:val="${"justify"===t.align?"both":t.align}"/>`);const o=[];void 0!==t.indentLeft&&o.push(`w:left="${ut(t.indentLeft)}"`),void 0!==t.indentRight&&o.push(`w:right="${ut(t.indentRight)}"`),void 0!==t.firstLine&&o.push(t.firstLine<0?`w:hanging="${ut(-t.firstLine)}"`:`w:firstLine="${ut(t.firstLine)}"`),o.length&&r("w:ind",`<w:ind ${o.join(" ")}/>`);const a=[];void 0!==t.before&&a.push(`w:before="${ut(t.before)}"`),void 0!==t.after&&a.push(`w:after="${ut(t.after)}"`),void 0!==t.lineMultiple&&a.push(`w:line="${Math.round(240*t.lineMultiple)}" w:lineRule="auto"`),void 0!==t.linePoints&&a.push(`w:line="${ut(t.linePoints)}" w:lineRule="exact"`),a.length&&r("w:spacing",`<w:spacing ${a.join(" ")}/>`);const i=ot(n,et);return i?`<w:pPr>${i}</w:pPr>`:""}function yt(e,t){const n=W(e.parts,e.doc.docPath).find(e=>e.type===$.styles),r=n?U(e.parts,q(e.doc.docPath,n.target)):void 0;if(r)for(const e of B(r).children)if("w:style"===e.name&&E(e,"w:name")?.attrs["w:val"]?.toLowerCase()===t)return e.attrs["w:styleId"];return Object.entries(x).find(([,e])=>e.name===t)?.[0]??null}var vt=["•","o","▪"],xt=["decimal","lowerLetter","lowerRoman"];function kt(e){const t=W(e.parts,e.doc.docPath).find(e=>e.type===$.numbering);if(t){const n=q(e.doc.docPath,t.target);return{path:n,text:U(e.parts,n)??`<w:numbering ${L}></w:numbering>`}}const n="word/numbering.xml";return M(e.parts,e.doc.docPath,$.numbering,"numbering.xml"),T(e.parts,n,"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"),{path:n,text:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<w:numbering ${L}></w:numbering>`}}function Ct(e,t,n){const{path:r,text:o}=kt(e),a=B(o),i=a.children.filter(e=>"w:abstractNum"===e.name).map(e=>Number(e.attrs["w:abstractNumId"])),l=String((i.length?Math.max(...i):-1)+1);let s="";for(let e=0;e<9;e++){s+=`<w:lvl w:ilvl="${e}"><w:start w:val="1"/><w:numFmt w:val="${t?xt[e%3]:"bullet"}"/><w:lvlText w:val="${t?`%${e+1}.`:n??vt[e%3]}"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${720*(e+1)}" w:hanging="360"/></w:pPr></w:lvl>`}const c=`<w:abstractNum w:abstractNumId="${l}"><w:multiLevelType w:val="hybridMultilevel"/>${s}</w:abstractNum>`,d=a.children.find(e=>"w:num"===e.name),u=d?d.start:a.innerEnd>a.innerStart||o.includes("</w:numbering>")?o.lastIndexOf("</w:numbering>"):-1,m=u>=0?o.slice(0,u)+c+o.slice(u):o.replace(/\/>\s*$/,`>${c}</w:numbering>`);return G(e.parts,r,m),l}function St(e,t,n){const{path:r,text:o}=kt(e),a=B(o),i=a.children.filter(e=>"w:num"===e.name).map(e=>Number(e.attrs["w:numId"])),l=String((i.length?Math.max(...i):0)+1),s=`<w:num w:numId="${l}"><w:abstractNumId w:val="${t}"/>${n?'<w:lvlOverride w:ilvl="0"><w:startOverride w:val="1"/></w:lvlOverride>':""}</w:num>`,c=[...a.children].reverse().find(e=>"w:num"===e.name),d=c?c.end:o.lastIndexOf("</w:numbering>");return G(e.parts,r,o.slice(0,d)+s+o.slice(d)),l}var Nt={"image/png":"png","image/jpeg":"jpeg","image/gif":"gif","image/bmp":"bmp","image/webp":"webp","image/svg+xml":"svg"};function $t(e,t){const n=t.getAttribute("data-raw"),r=function(e,t){const n=at(t),r=st(n.get("width")),o=st(n.get("height")),a=t.naturalWidth?.75*t.naturalWidth:0,i=t.naturalHeight?.75*t.naturalHeight:0,l=a&&i?i/a:o&&r?o/r:.75;let s=r??(a||e.contentWidth);return s>2*e.contentWidth&&(s=e.contentWidth),{width:s,height:o??s*l}}(e,t),o=Math.round(12700*r.width),a=Math.round(12700*r.height),i=n?e.doc.raw.get(n):void 0;if(i)return i.replace(/(<wp:extent\b[^>]*?\bcx=")\d+("[^>]*?\bcy=")\d+/,`$1${o}$2${a}`).replace(/(<a:xfrm\b[^>]*>\s*<a:off\b[^>]*\/>\s*<a:ext\b[^>]*?\bcx=")\d+("[^>]*?\bcy=")\d+/,`$1${o}$2${a}`);const l=t.getAttribute("src")??"",s=`${e.part}\n${l}`;let c=e.mediaBySrc.get(s);if(!c){const t=e.images.get(l)??function(e){const t=/^data:([^;,]+);base64,(.*)$/s.exec(e);if(!t)return null;const n=atob(t[2]),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return{bytes:r,mime:t[1]}}(l);if(!t)return"";const n=Nt[t.mime]??"png";P(e.parts,n,t.mime);let r=1;const o=[...e.parts.keys()].find(r=>r.startsWith("word/media/inserted")&&r.endsWith(`.${n}`)&&function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e.parts.get(r),t.bytes));if(o)r=Number(/inserted(\d+)\./.exec(o)[1]);else{for(;e.parts.has(`word/media/inserted${r}.${n}`);)r++;e.parts.set(`word/media/inserted${r}.${n}`,t.bytes)}c=M(e.parts,e.part,$.image,function(e,t){const n=e.split("/").slice(0,-1),r=t.split("/");let o=0;for(;o<n.length&&o<r.length-1&&n[o]===r[o];)o++;return[...n.slice(o).map(()=>".."),...r.slice(o)].join("/")}(e.part,`word/media/inserted${r}.${n}`)),e.mediaBySrc.set(s,c)}const d=++e.drawingId;return`<w:r><w:drawing><wp:inline xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${o}" cy="${a}"/><wp:docPr id="${d}" name="Picture ${d}"/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="${d}" name="Picture ${d}"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${c}"/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${o}" cy="${a}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`}function At(e,t,n,r={}){let o="",a=null;const i=()=>{a?.body&&(o+=`<w:r>${mt(e.doc,a.format,a.runId)}${a.body}</w:r>`),a=null},l=(e,t,n)=>{n&&(a&&a.runId===t&&JSON.stringify(a.format)===JSON.stringify(e)?a.body+=n:(i(),a={format:e,runId:t,body:n}))},s=(t,r,a)=>{if(3===t.nodeType)return void l(r,a,function(e){let t="",n="";const r=()=>{n&&(t+=`<w:t xml:space="preserve">${z(n)}</w:t>`),n=""};for(const o of e)"\t"===o?(r(),t+="<w:tab/>"):"\n"===o?(r(),t+="<w:br/>"):"‑"===o?(r(),t+="<w:noBreakHyphen/>"):"­"===o?(r(),t+="<w:softHyphen/>"):"​"!==o&&"\ufeff"!==o&&(n+=o);return r(),t}(t.nodeValue??""));if(1!==t.nodeType)return;const c=t,d=c.tagName;if("IMG"===d)return i(),void(o+=$t(e,c));const u=c.getAttribute("data-raw");if(u){const t=e.doc.raw.get(u);if(t){i(),o+=t;const n=c.getAttribute("data-note");null!==n&&e.notesUsed.add(n)}return}if(c.hasAttribute("data-page-break"))return void l(r,a,'<w:br w:type="page"/>');const m=c.getAttribute("data-note");if(null!==m)return i(),e.notesUsed.add(m),gt(e,"FootnoteReference"),void(o+=`<w:r><w:rPr><w:rStyle w:val="FootnoteReference"/></w:rPr><w:footnoteReference w:id="${z(m)}"/></w:r>`);const f=c.getAttribute("data-bookmark");if(null!==f){i();const t=++e.bookmarkId;return void(o+=`<w:bookmarkStart w:id="${t}" w:name="${z(f)}"/><w:bookmarkEnd w:id="${t}"/>`)}const p=c.getAttribute("data-field");if("page"===p||"pages"===p)return i(),void(o+=`<w:fldSimple w:instr=" ${"page"===p?"PAGE":"NUMPAGES"} "><w:r>${mt(e.doc,r,a)}<w:t>1</w:t></w:r></w:fldSimple>`);if("BR"===d)return void(function(e,t){let n=e;for(;n!==t;){let e=n.nextSibling;for(;e&&3===e.nodeType&&!e.nodeValue;)e=e.nextSibling;if(e)return!1;if(!n.parentNode)return!0;n=n.parentNode}return!0}(c,n)||l(r,a,"<w:br/>"));if("A"===d)return i(),void(o+=function(e,t,n,r){const o=t.getAttribute("data-anchor"),a=t.getAttribute("href")??"";let i=t.getAttribute("data-rel");const l=W(e.parts,e.part),s=i?l.find(e=>e.id===i):void 0;a&&!a.startsWith("#")&&s?.target!==a&&(i=l.find(e=>e.external&&e.target===a)?.id??M(e.parts,e.part,$.hyperlink,a,!0),t.setAttribute("data-rel",i));const c=t.querySelector("[data-r]")?n:{color:"#0563c1",u:!0,...n},d=At(e,Array.from(t.childNodes),r,c);return`<w:hyperlink${o?` w:anchor="${z(o)}"`:i?` r:id="${z(i)}"`:a.startsWith("#")?` w:anchor="${z(a.slice(1))}"`:""} w:history="1">${d}</w:hyperlink>`}(e,c,r,n));const h=c.getAttribute("data-comment");h&&e.firstComment.get(h)===c&&(i(),o+=`<w:commentRangeStart w:id="${z(h)}"/>`);const g=c.getAttribute("data-r"),w=function(e,t){const n={...t},r=e.tagName;if("B"!==r&&"STRONG"!==r||(n.b=!0),"I"!==r&&"EM"!==r||(n.i=!0),"U"===r&&(n.u=!0),"S"!==r&&"STRIKE"!==r||(n.strike=!0),"SUB"===r&&(n.vert="sub"),"SUP"===r&&(n.vert="super"),"FONT"===r){const t=lt(e.getAttribute("color")??void 0);t&&(n.color=t);const r=e.getAttribute("face");r&&(n.font=r.split(",")[0].replace(/["']/g,"").trim());const o=Number(e.getAttribute("size"));o>=1&&o<=7&&(n.size=ct[o-1])}const o=at(e),a=o.get("font-weight");a&&(n.b="bold"===a||"bolder"===a||Number(a)>=600);const i=o.get("font-style");i&&(n.i="italic"===i||"oblique"===i);const l=o.get("text-decoration-line")??o.get("text-decoration");l&&(/none/.test(l)?(n.u=!1,n.strike=!1):(/underline/.test(l)&&(n.u=!0),/line-through/.test(l)&&(n.strike=!0)));const s=o.get("font-family");s&&(n.font=s.split(",")[0].replace(/["']|&quot;/g,"").trim());const c=st(o.get("font-size"));if(c&&(n.size=Math.round(2*c)/2),o.has("color")){const e=lt(o.get("color"));e?n.color=e:delete n.color}const d=o.get("background-color")??o.get("background");if(void 0!==d){const e=lt(d);e?n.hl=e:delete n.hl}return n}(c,r);for(const e of Array.from(c.childNodes))s(e,w,g??a);h&&e.lastComment.get(h)===c&&(i(),o+=`<w:commentRangeEnd w:id="${z(h)}"/><w:r><w:commentReference w:id="${z(h)}"/></w:r>`)};for(const e of t)s(e,r,null);return i(),o}function Lt(e,t,n,r,o){const a=n?B(n):void 0,i=H(a),l=function(e){const t=at(e),n={},r=t.get("text-align")??e.getAttribute("align")??void 0;"left"===r||"start"===r?n.align="left":"center"!==r&&"right"!==r&&"justify"!==r||(n.align=r);const o=st(t.get("margin-left"));void 0!==o&&(n.indentLeft=o);const a=st(t.get("margin-right"));void 0!==a&&(n.indentRight=a),e.hasAttribute("data-tabs")&&(n.tabs=I(e.getAttribute("data-tabs")));const i=st(t.get("text-indent"));void 0!==i&&(n.firstLine=i);const l=st(t.get("margin-top"));void 0!==l&&(n.before=l);const s=st(t.get("margin-bottom"));void 0!==s&&(n.after=s);const c=t.get("line-height");if(c){const e=st(c);e?n.linePoints=e:Number(c)&&(n.lineMultiple=Number(c))}return n}(t);let s=rt(n);const c=(e,t)=>{s=s.filter(t=>t.name!==e),t&&s.push({name:e,xml:t})};if(c("w:pStyle",r?`<w:pStyle w:val="${z(r)}"/>`:null),c("w:numPr",o?`<w:numPr><w:ilvl w:val="${o.ilvl}"/><w:numId w:val="${z(o.numId)}"/></w:numPr>`:null),l.align!==i.align&&c("w:jc",l.align?`<w:jc w:val="${"justify"===l.align?"both":l.align}"/>`:null),!(o||dt(l.indentLeft,i.indentLeft)&&dt(l.firstLine,i.firstLine)&&dt(l.indentRight,i.indentRight))){const e=[];void 0!==l.indentLeft&&e.push(`w:left="${ut(l.indentLeft)}"`),void 0!==l.indentRight&&e.push(`w:right="${ut(l.indentRight)}"`),void 0!==l.firstLine&&e.push(l.firstLine<0?`w:hanging="${ut(-l.firstLine)}"`:`w:firstLine="${ut(l.firstLine)}"`),c("w:ind",e.length?`<w:ind ${e.join(" ")}/>`:null)}if(!(dt(l.before,i.before)&&dt(l.after,i.after)&&dt(l.lineMultiple,i.lineMultiple)&&dt(l.linePoints,i.linePoints))){const e=[];void 0!==l.before&&e.push(`w:before="${ut(l.before)}"`),void 0!==l.after&&e.push(`w:after="${ut(l.after)}"`),void 0!==l.lineMultiple&&e.push(`w:line="${Math.round(240*l.lineMultiple)}" w:lineRule="auto"`),void 0!==l.linePoints&&e.push(`w:line="${ut(l.linePoints)}" w:lineRule="exact"`),c("w:spacing",e.length?`<w:spacing ${e.join(" ")}/>`:null)}if(t.hasAttribute("data-tabs")&&!Pt(l.tabs??[],i.tabs??[])){const e=(l.tabs??[]).map(e=>`<w:tab w:val="${e.align}" w:pos="${ut(e.pos)}"/>`),t=(i.tabs??[]).filter(e=>!(l.tabs??[]).some(t=>dt(t.pos,e.pos))).map(e=>`<w:tab w:val="clear" w:pos="${ut(e.pos)}"/>`);c("w:tabs",e.length||t.length?`<w:tabs>${[...e,...t].join("")}</w:tabs>`:null)}c("w:sectPr",e.sections.get(t)??null);const d=ot(s,et);return d?`<w:pPr>${d}</w:pPr>`:""}var Pt=(e,t)=>e.length===t.length&&e.every((e,n)=>dt(e.pos,t[n].pos)&&e.align===t[n].align);function Tt(e,t,n,r){const o=t.getAttribute("data-docx"),a=o?e.doc.blocks.get(o):void 0;if(a?.xml&&a.xml.startsWith("<w:p")&&(a.fingerprint===p(t)||t.hasAttribute("data-locked"))&&!e.sections.has(t)&&(t.hasAttribute("data-locked")||(a.numId??null)===(r?.numId??null)&&(a.ilvl??null)===(r?.ilvl??null))){for(const t of a.xml.matchAll(/<w:footnoteReference\b[^>]*w:id="([^"]+)"/g))e.notesUsed.add(t[1]);return a.xml}const i=Lt(e,t,a?.props,function(e,t){let n=t.getAttribute("data-pstyle");if(!n){const r=/^H([1-6])$/.exec(t.tagName);r?n=yt(e,`heading ${r[1]}`)??`Heading${r[1]}`:"BLOCKQUOTE"===t.tagName&&(n=yt(e,"quote"))}return n&&gt(e,n),n}(e,t),r);let l=At(e,n,t);const s=t.getAttribute("data-bm");if(s&&/^[A-Za-z0-9_]+$/.test(s)&&!l.includes(`w:name="${s}"`)){const t=++e.bookmarkId;l=`<w:bookmarkStart w:id="${t}" w:name="${s}"/>${l}<w:bookmarkEnd w:id="${t}"/>`}return`<w:p>${i}${l}</w:p>`}var Mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","TABLE","LI","HR","SECTION","ARTICLE"]);function Rt(e,t,n,r){if(t.hasAttribute("data-checklist")){const n=function(e){if(e.checkNums)return e.checkNums;const{path:t,text:n}=kt(e),r=B(n),o={},a=new Map;for(const e of r.children.filter(e=>"w:abstractNum"===e.name)){const t=e.children.find(e=>"w:lvl"===e.name&&"0"===e.attrs["w:ilvl"]),n=E(t,"w:lvlText")?.attrs["w:val"];n===k.open&&a.set(e.attrs["w:abstractNumId"],"open"),n===k.done&&a.set(e.attrs["w:abstractNumId"],"done")}for(const e of r.children.filter(e=>"w:num"===e.name)){const t=a.get(E(e,"w:abstractNumId")?.attrs["w:val"]??"");t&&!o[t]&&(o[t]=e.attrs["w:numId"])}const i=t=>{const n=Ct(e,!1,t);return St(e,n,!1)};return e.checkNums={open:o.open??i(k.open),done:o.done??i(k.done)},e.checkNums}(e),o=t.getAttribute("data-ilvl"),a=null!==o&&Number(o)>r?Number(o):r+1;let i="";for(const r of Array.from(t.children)){if("UL"===r.tagName||"OL"===r.tagName){i+=Rt(e,r,null,a);continue}if("LI"!==r.tagName)continue;const t=Array.from(r.children).filter(e=>"UL"===e.tagName||"OL"===e.tagName);i+=Tt(e,r,Array.from(r.childNodes).filter(e=>!t.includes(e)),{numId:r.hasAttribute("data-checked")?n.done:n.open,ilvl:a});for(const n of t)i+=Rt(e,n,null,a)}return i}const o=function(e,t,n){const r=t.getAttribute("data-num-id");if(r)return r;if(n)return t.setAttribute("data-num-id",n),n;let o;return"OL"===t.tagName?(e.orderedAbstract??=Ct(e,!0),o=St(e,e.orderedAbstract,!0)):(e.bulletNum??=St(e,Ct(e,!1),!1),o=e.bulletNum),t.setAttribute("data-num-id",o),o}(e,t,n),a=t.getAttribute("data-ilvl"),i=null!==a&&Number(a)>r?Number(a):r+1;let l="";for(const n of Array.from(t.children)){if("UL"===n.tagName||"OL"===n.tagName){l+=Rt(e,n,o,i);continue}if("LI"!==n.tagName)continue;const t=Array.from(n.children).filter(e=>"UL"===e.tagName||"OL"===e.tagName);l+=Tt(e,n,Array.from(n.childNodes).filter(e=>!t.includes(e)),{numId:o,ilvl:i});for(const n of t)l+=Rt(e,n,o,i)}return l}function Et(e){return Array.from(e.children).some(e=>Mt.has(e.tagName))}function zt(e,t){let n="",r=[];const o=()=>{r.some(e=>1===e.nodeType||(e.nodeValue??"").trim())&&(n+=`<w:p>${At(e,r,t)}</w:p>`),r=[]};for(const a of Array.from(t.childNodes)){const t=a;if(1!==a.nodeType||!Mt.has(t.tagName)){r.push(a);continue}o();const i=t.getAttribute("data-docx"),l=i?e.doc.blocks.get(i):void 0;"UL"===t.tagName||"OL"===t.tagName?n+=Rt(e,t,null,-1):"TABLE"===t.tagName?n+=Ft(e,t):t.hasAttribute("data-toc")?n+=jt(e,t,l?.fingerprint===p(t)?l.xml:void 0):t.hasAttribute("data-locked")&&l?.xml?n+=l.xml:"HR"===t.tagName?n+='<w:p><w:pPr><w:pBdr><w:bottom w:val="single" w:sz="6" w:space="1" w:color="auto"/></w:pBdr></w:pPr></w:p>':Et(t)?n+=zt(e,t):n+=Tt(e,t,Array.from(t.childNodes),null)}return o(),n}function Ft(e,t){const n=t.getAttribute("data-docx"),r=n?e.doc.blocks.get(n):void 0;if(r?.xml&&(t.hasAttribute("data-locked")||r.fingerprint===p(t)))return r.xml;const o=Array.from(t.querySelectorAll(":scope > tbody > tr, :scope > tr, :scope > thead > tr, :scope > tfoot > tr")),a=[];let i=0;const l=o.map(t=>{const n=[];let r=0;const o=()=>{for(;a[r]?.left>0;){const e=a[r];e.left--,n.push({continuation:!0,span:e.span,col:r,props:e.props}),r+=e.span}};for(const i of Array.from(t.children).filter(e=>"TD"===e.tagName||"TH"===e.tagName)){o();const t=Math.max(1,Number(i.getAttribute("colspan")??1)),l=Math.max(1,Number(i.getAttribute("rowspan")??1));n.push({cell:i,span:t,col:r}),l>1&&(a[r]={left:l-1,span:t,props:e.doc.blocks.get(i.getAttribute("data-docx")??"")?.props}),r+=t}return o(),i=Math.max(i,r),n}),s=Array.from(t.querySelectorAll(":scope > colgroup > col")),c=[];for(let t=0;t<i;t++){const n=s[t]?st(at(s[t]).get("width")):void 0;c.push(void 0!==n&&s.length===i?ut(n):Math.round(20*e.contentWidth/Math.max(i,1)))}return`<w:tbl>${r?.props??'<w:tblPr><w:tblW w:w="5000" w:type="pct"/><w:tblBorders><w:top w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:bottom w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:insideH w:val="single" w:sz="4" w:space="0" w:color="auto"/><w:insideV w:val="single" w:sz="4" w:space="0" w:color="auto"/></w:tblBorders><w:tblLook w:val="04A0"/></w:tblPr>'}${`<w:tblGrid>${c.map(e=>`<w:gridCol w:w="${e}"/>`).join("")}</w:tblGrid>`}${o.map((t,n)=>`<w:tr>${e.doc.blocks.get(t.getAttribute("data-docx")??"")?.props??""}${l[n].map(t=>{const n=t.span,r=c.slice(t.col,t.col+n).reduce((e,t)=>e+t,0);if("continuation"in t)return`<w:tc><w:tcPr>${Ot(t.props,r,n,"continue",void 0)}</w:tcPr><w:p/></w:tc>`;const o=e.doc.blocks.get(t.cell.getAttribute("data-docx")??""),a=Number(t.cell.getAttribute("rowspan")??1),i=lt(at(t.cell).get("background-color"));let l=zt(e,t.cell);return l.endsWith("</w:p>")||l.endsWith("<w:p/>")||(l+="<w:p/>"),`<w:tc><w:tcPr>${Ot(o?.props,r,n,a>1?"restart":null,i)}</w:tcPr>${l}</w:tc>`}).join("")}</w:tr>`).join("")}</w:tbl>`}function Ot(e,t,n,r,o){const a=e?B(e):void 0;let i=rt(e).filter(e=>!["w:tcW","w:gridSpan","w:vMerge"].includes(e.name));i.push({name:"w:tcW",xml:`<w:tcW w:w="${t}" w:type="dxa"/>`}),n>1&&i.push({name:"w:gridSpan",xml:`<w:gridSpan w:val="${n}"/>`}),r&&i.push({name:"w:vMerge",xml:"restart"===r?'<w:vMerge w:val="restart"/>':"<w:vMerge/>"});const l=E(a,"w:shd")?.attrs["w:fill"]?.toLowerCase();return"continue"!==r&&(o?.slice(1)??void 0)!==(l&&/^[0-9a-f]{6}$/.test(l)?l:void 0)&&(i=i.filter(e=>"w:shd"!==e.name),o&&i.push({name:"w:shd",xml:`<w:shd w:val="clear" w:color="auto" w:fill="${o.slice(1).toUpperCase()}"/>`})),ot(i,tt)}function jt(e,t,n){if(n)return n;const r=Math.round(20*e.contentWidth),o='<w:r><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText xml:space="preserve"> TOC \\o "1-3" \\h \\z \\u </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate"/></w:r>',a=Array.from(t.querySelectorAll("[data-toc-level]")).map((t,n)=>{const a=Math.min(Math.max(Number(t.getAttribute("data-toc-level"))||1,1),6);gt(e,`TOC${a}`);const i=t.querySelector("a"),l=i?.getAttribute("data-anchor")??"",s=t.querySelector("[data-toc-page]")?.textContent??"",c=(i??t).cloneNode(!0);c.querySelectorAll("[data-toc-page]").forEach(e=>e.remove());const d=`<w:r><w:t xml:space="preserve">${z(c.textContent??"")}</w:t></w:r><w:r><w:tab/></w:r><w:r><w:t>${z(s)}</w:t></w:r>`,u=/^[A-Za-z0-9_]+$/.test(l)?`<w:hyperlink w:anchor="${l}" w:history="1">${d}</w:hyperlink>`:d;return`<w:p><w:pPr><w:pStyle w:val="TOC${a}"/><w:tabs><w:tab w:val="right" w:leader="dot" w:pos="${r}"/></w:tabs></w:pPr>${0===n?o:""}${u}</w:p>`});return a.length||a.push(`<w:p>${o}</w:p>`),`<w:sdt><w:sdtPr><w:docPartObj><w:docPartGallery w:val="Table of Contents"/><w:docPartUnique/></w:docPartObj></w:sdtPr><w:sdtContent>${a.join("")}<w:p><w:r><w:fldChar w:fldCharType="end"/></w:r></w:p></w:sdtContent></w:sdt>`}function Ht(e,t){return`<w:footnote w:id="${z(e)}"><w:p><w:pPr><w:pStyle w:val="FootnoteText"/></w:pPr><w:r><w:rPr><w:rStyle w:val="FootnoteReference"/></w:rPr><w:footnoteRef/></w:r><w:r><w:t xml:space="preserve"> ${z(t)}</w:t></w:r></w:p></w:footnote>`}var Dt=["w:writeProtection","w:view","w:zoom","w:removePersonalInformation","w:removeDateAndTime","w:doNotDisplayPageBoundaries","w:displayBackgroundShape","w:printPostScriptOverText","w:printFractionalCharacterWidth","w:printFormsData","w:embedTrueTypeFonts","w:embedSystemFonts","w:saveSubsetFonts","w:saveFormsData","w:mirrorMargins","w:alignBordersAndEdges","w:bordersDoNotSurroundHeader","w:bordersDoNotSurroundFooter","w:gutterAtTop","w:hideSpellingErrors","w:hideGrammaticalErrors","w:activeWritingStyle","w:proofState","w:formsDesign","w:attachedTemplate","w:linkStyles","w:stylePaneFormatFilter","w:stylePaneSortMethod","w:documentType","w:mailMerge","w:revisionView","w:trackRevisions","w:doNotTrackMoves","w:doNotTrackFormatting","w:documentProtection","w:autoFormatOverride","w:styleLockTheme","w:styleLockQFSet","w:defaultTabStop","w:autoHyphenation","w:consecutiveHyphenLimit","w:hyphenationZone","w:doNotHyphenateCaps","w:showEnvelope","w:summaryLength","w:clickAndTypeStyle","w:defaultTableStyle","w:evenAndOddHeaders","w:bookFoldRevPrinting","w:bookFoldPrinting","w:bookFoldPrintingSheets","w:drawingGridHorizontalSpacing","w:drawingGridVerticalSpacing","w:displayHorizontalDrawingGridEvery","w:displayVerticalDrawingGridEvery","w:doNotUseMarginsForDrawingGridOrigin","w:drawingGridHorizontalOrigin","w:drawingGridVerticalOrigin","w:doNotShadeFormData","w:noPunctuationKerning","w:characterSpacingControl","w:printTwoOnOne","w:strictFirstAndLastChars","w:noLineBreaksAfter","w:noLineBreaksBefore","w:savePreviewPicture","w:doNotValidateAgainstSchema","w:saveInvalidXml","w:ignoreMixedContent","w:alwaysShowPlaceholderText","w:doNotDemarcateInvalidXml","w:saveXmlDataOnly","w:useXSLTWhenSaving","w:saveThroughXslt","w:showXMLTags","w:alwaysMergeEmptyNamespace","w:updateFields","w:hdrShapeDefaults","w:footnotePr","w:endnotePr","w:compat","w:docVars","w:rsids","m:mathPr","w:attachedSchema","w:themeFontLang","w:clrSchemeMapping","w:doNotIncludeSubdocsInStats","w:doNotAutoCompressPictures","w:forceUpgrade","w:captions","w:readModeInkLockDown","w:smartTagType","sl:schemaLibrary","w:shapeDefaults","w:doNotEmbedSmartTags","w:decimalSymbol","w:listSeparator"];function It(e,t,n){const{path:r,text:o}=function(e){const t=W(e.parts,e.doc.docPath).find(e=>e.type===$.settings);if(t){const n=q(e.doc.docPath,t.target);return{path:n,text:U(e.parts,n)??`<w:settings ${L}></w:settings>`}}const n="word/settings.xml";return M(e.parts,e.doc.docPath,$.settings,"settings.xml"),T(e.parts,n,"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"),{path:n,text:`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<w:settings ${L}></w:settings>`}}(e),a=B(o),i=a.children.find(e=>e.name===t);let l=o;if(i)l=o.slice(0,i.start)+(n??"")+o.slice(i.end);else if(n){const e=Dt.indexOf(t),r=a.children.find(t=>Dt.indexOf(t.name)>e);l=r?o.slice(0,r.start)+n+o.slice(r.start):/<\/w:settings>\s*$/.test(o)?o.replace(/<\/w:settings>\s*$/,`${n}</w:settings>`):o.replace(/\/>\s*$/,`>${n}</w:settings>`)}l!==o&&G(e.parts,r,l)}function Bt(e,t,n){const r=/^<w:sectPr\b([^>]*?)\/?>/.exec(e)?.[1]??"";let o=rt(`<x>${/^<w:sectPr\b[^>]*\/>$/.test(e)?"":e.replace(/^<w:sectPr\b[^>]*>/,"").replace(/<\/w:sectPr>$/,"")}</x>`).filter(e=>e.name!==t);return n&&(o=[...o,{name:t,xml:n}]),`<w:sectPr${r}>${ot(o,nt)}</w:sectPr>`}var Ut=e=>e>1?`<w:cols w:num="${e}" w:space="720"/>`:null;var Wt=`${L} xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"`;function qt(e,t,n,r){const o=document.createElement("div");o.innerHTML=n;const a=e.part;let i;e.part=r;try{i=zt(e,o)}finally{e.part=a}/<\/w:p>\s*$|<w:p\/>\s*$/.test(i)||(i+="<w:p/>");const l=U(e.parts,r);return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n${(l?new RegExp(`<w:${t}\\b[^>]*>`).exec(l)?.[0]:void 0)??`<w:${t} ${Wt}>`}${i}</w:${t}>`}async function Kt(e,t,n){const r=new Map(e.parts),o=U(r,e.docPath);if(!o)throw new Error("Not a Word document");const a=B(o),i=E(a,"w:body"),l=E(i,"w:sectPr"),s={doc:e,parts:r,images:n.images??new Map,firstComment:new Map,lastComment:new Map,drawingId:9e4,mediaBySrc:e.insertedMedia??=new Map,contentWidth:(n.page.width-n.page.left-n.page.right)/20,bulletNum:null,orderedAbstract:null,part:e.docPath,checkNums:null,bookmarkId:8e4,sections:new Map,notesUsed:new Set};t.querySelectorAll("[data-comment]").forEach(e=>{const t=e.getAttribute("data-comment");s.firstComment.has(t)||s.firstComment.set(t,e),s.lastComment.set(t,e)});const c=l?o.slice(l.start,l.end):void 0,d=function(e,t,n){const r=Array.from(t.children).filter(e=>e.hasAttribute("data-section")),o=(n??"<w:sectPr/>").replace(/<w:(header|footer)Reference\b[^>]*\/>/g,"").replace(/<w:titlePg\b[^>]*\/>/g,"").replace(/<w:type\b[^>]*\/>/g,"");r.forEach((t,n)=>{const a=e.doc.blocks.get(t.getAttribute("data-docx")??""),i=a?.props?/<w:sectPr\b[\s\S]*?(?:<\/w:sectPr>|\/>)/.exec(a.props)?.[0]:void 0;let l=i??o;const s=0===n?null:r[n-1].getAttribute("data-section");l=0===n&&i?l:Bt(l,"w:type",s&&"nextPage"!==s?`<w:type w:val="${z(s)}"/>`:null),l=Bt(l,"w:cols",Ut(Number(t.getAttribute("data-cols")??1))),e.sections.set(t,l)});const a=r[r.length-1]?.getAttribute("data-section");return r.length?a??"nextPage":null}(s,t,c);let u=zt(s,t);/<\/w:p>\s*$|<w:p\/>\s*$/.test(u)||(u+="<w:p/>"),u=function(e){const t=new Set,n=e.replace(/<w:commentRangeStart\b[^>]*w:id="([^"]+)"[^>]*\/>/g,(e,n)=>t.has(n)?"":(t.add(n),e)),r=new Set,o=[],a=n.split(/(<w:commentRangeEnd\b[^>]*\/>|<w:r>(?:<w:rPr>(?:(?!<\/w:rPr>).)*<\/w:rPr>)?<w:commentReference\b[^>]*\/><\/w:r>)/s);for(let e=a.length-1;e>=0;e--){const t=a[e],n=/^<w:commentRangeEnd\b[^>]*w:id="([^"]+)"/.exec(t)??/^<w:r>.*<w:commentReference\b[^>]*w:id="([^"]+)"/s.exec(t);if(n&&e%2==1){const e=`${t.includes("commentRangeEnd")?"e":"r"}${n[1]}`;if(r.has(e))continue;r.add(e)}o.push(t)}return o.reverse().join("")}(u);const m=function(e,t,n,r){let o=t??"<w:sectPr/>";const a=n.page,i=e.doc.page;if(Object.keys(a).some(e=>a[e]!==i[e])||!t){const e=a.width>a.height,n=t?B(t):void 0,r=E(n,"w:pgMar")?.attrs["w:gutter"]??"0";o=Bt(o,"w:pgSz",`<w:pgSz w:w="${a.width}" w:h="${a.height}"${e?' w:orient="landscape"':""}/>`),o=Bt(o,"w:pgMar",`<w:pgMar w:top="${a.top}" w:right="${a.right}" w:bottom="${a.bottom}" w:left="${a.left}" w:header="${a.header}" w:footer="${a.footer}" w:gutter="${r}"/>`)}const l=n.columns??e.doc.columns;l!==e.doc.columns&&(o=Bt(o,"w:cols",Ut(l))),null!==r&&(o=Bt(o,"w:type","nextPage"!==r?`<w:type w:val="${z(r)}"/>`:null));const s=n.titlePage??e.doc.titlePage;s!==e.doc.titlePage&&(o=Bt(o,"w:titlePg",s?"<w:titlePg/>":null));const c=n.evenOdd??e.doc.evenOdd;c!==e.doc.evenOdd&&It(e,"w:evenAndOddHeaders",c?"<w:evenAndOddHeaders/>":null);const d=[],u=(t,n)=>{const r="headers"===t?"header":"footer";for(const o of["default","first","even"]){const a=e.doc[t][o],i=n?.[o];if(void 0===i||!a.editable||i===a.html)continue;if(!a.part&&!i.replace(/<br>|<p>|<\/p>|\s/g,""))continue;let l=a.part;if(!l){let n=1;for(;e.parts.has(`word/${r}${n}.xml`);)n++;l=`word/${r}${n}.xml`,G(e.parts,l,""),T(e.parts,l,`application/vnd.openxmlformats-officedocument.wordprocessingml.${r}+xml`);const i=M(e.parts,e.doc.docPath,"headers"===t?$.header:$.footer,`${r}${n}.xml`);d.push(`<w:${r}Reference w:type="${o}" r:id="${i}"/>`),a.part=l}G(e.parts,l,qt(e,"headers"===t?"hdr":"ftr",i,l))}};if(u("headers",n.headers),u("footers",n.footers),d.length){const e=/^<w:sectPr\b([^>]*?)\/?>/.exec(o)?.[1]??"",t=/^<w:sectPr\b[^>]*\/>$/.test(o)?"":o.replace(/^<w:sectPr\b[^>]*>/,"").replace(/<\/w:sectPr>$/,"");o=`<w:sectPr${e}>${ot([...rt(`<x>${t}</x>`),...d.map(e=>({name:/^<(w:\w+)/.exec(e)[1],xml:e}))],nt)}</w:sectPr>`}return o}(s,c,n,d);!function(e){const t=[...e.notesUsed].filter(t=>{const n=e.doc.footnotes.get(t);return n&&n.editable&&(!n.xml||n.text!==e.doc.footnotesRead?.get(t))});if(!t.length)return;gt(e,"FootnoteText"),gt(e,"FootnoteReference");const n=W(e.parts,e.doc.docPath).find(e=>e.type===$.footnotes);let r,o;n?(r=q(e.doc.docPath,n.target),o=U(e.parts,r)??""):(r="word/footnotes.xml",M(e.parts,e.doc.docPath,$.footnotes,"footnotes.xml"),T(e.parts,r,"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"),o=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<w:footnotes ${L}><w:footnote w:type="separator" w:id="-1"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:continuationSeparator/></w:r></w:p></w:footnote></w:footnotes>`,It(e,"w:footnotePr",'<w:footnotePr><w:footnote w:id="-1"/><w:footnote w:id="0"/></w:footnotePr>'));const a=B(o),i=new Map(a.children.filter(e=>"w:footnote"===e.name).map(e=>[e.attrs["w:id"],e]));let l=o;const s=[],c=[];for(const n of t){const t=Ht(n,e.doc.footnotes.get(n).text),r=i.get(n);r?c.push({start:r.start,end:r.end,xml:t}):s.push(t)}for(const e of c.sort((e,t)=>t.start-e.start))l=l.slice(0,e.start)+e.xml+l.slice(e.end);s.length&&(l=l.replace(/<\/w:footnotes>\s*$/,`${s.join("")}</w:footnotes>`)),G(e.parts,r,l)}(s),n.styleEdits?.size&&function(e,t){for(const n of t.keys())gt(e,n);const n=ht(e),r=n?U(e.parts,n):void 0;if(!n||!r)return;let o=r;const a=B(r).children.filter(e=>"w:style"===e.name&&t.has(e.attrs["w:styleId"])).reverse();for(const n of a){const a=t.get(n.attrs["w:styleId"]),i=r.slice(n.start,n.end),l=B(i),s=E(l,"w:rPr"),c=E(l,"w:pPr"),d=s?i.slice(s.start,s.end):void 0,u=c?i.slice(c.start,c.end):void 0,m=ft(d,{...D(s,e.doc.theme),...a.run},e.doc),f=bt(u,a.para);let p=l.children.filter(e=>"w:rPr"!==e.name&&"w:pPr"!==e.name).map(e=>({name:e.name,xml:i.slice(e.start,e.end)}));f&&p.push({name:"w:pPr",xml:f}),m&&p.push({name:"w:rPr",xml:m}),p=p.filter(Boolean);const h=`${/^<w:style\b[^>]*?(?=\/?>)/.exec(i)[0]}>${ot(p,wt)}</w:style>`;o=o.slice(0,n.start)+h+o.slice(n.end)}G(e.parts,n,o)}(s,n.styleEdits);const f=o.slice(a.start,a.innerStart),p=[!/\bxmlns:r=/.test(f)&&/\br:(id|embed)=/.test(u+m)?' xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"':""].join(""),h=(p?o.slice(0,a.innerStart-1)+p+">":o.slice(0,a.innerStart))+o.slice(a.innerStart,i.innerStart)+u+m+o.slice(i.innerEnd);G(r,e.docPath,h),e.parts=r,e.page={...n.page};for(const t of["headers","footers"]){const r=n[t];for(const n of["default","first","even"]){const o=r?.[n];void 0!==o&&e[t][n].editable&&(e[t][n]={...e[t][n],html:o})}}return e.titlePage=n.titlePage??e.titlePage,e.evenOdd=n.evenOdd??e.evenOdd,e.columns=n.columns??e.columns,e.footnotesRead=new Map([...e.footnotes].map(([e,t])=>[e,t.text])),Y(r)}import{useRef as Gt,useState as Vt}from"react";import{Icon as Xt}from"efficient-shell/icons";import{Button as Qt,Checkbox as _t,Dialog as Jt,IconButton as Yt}from"efficient-shell/ui";import{Fragment as Zt,jsx as en,jsxs as tn}from"react/jsx-runtime";function nn({label:e,html:t,locked:n,scope:r,onRef:o}){const a=u(),i=Gt(null),l=(e,t)=>{document.activeElement!==i.current&&i.current?.focus(),document.execCommand(e,!1,t)},s=e=>{const t=i.current,n=document.getSelection();if(!t||!n)return;if(!n.rangeCount||!t.contains(n.anchorNode)){t.focus();const e=document.createRange();e.selectNodeContents(t.lastElementChild??t),e.collapse(!1),n.removeAllRanges(),n.addRange(e)}const r=n.getRangeAt(0);r.deleteContents();const o=document.createElement("div");o.innerHTML=(e=>`<span data-kind="field" data-field="${e}" contenteditable="false">1</span>`)(e);const a=o.firstChild;r.insertNode(a);const l=a.nextSibling;l&&"BR"===l.nodeName&&!l.nextSibling&&l.remove();const s=document.createTextNode("​");a.after(s),n.collapse(s,1)};return tn("div",{className:"docs-hf-region",children:[tn("div",{className:"docs-hf-tools",onMouseDown:e=>e.preventDefault(),children:[en("span",{className:"docs-hf-label",children:e}),!n&&tn(Zt,{children:[en(Yt,{size:"sm",variant:"ghost","aria-label":a.bold,title:a.bold,onClick:()=>l("bold"),children:en(Xt,{name:"bold",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.italic,title:a.italic,onClick:()=>l("italic"),children:en(Xt,{name:"italic",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.underline,title:a.underline,onClick:()=>l("underline"),children:en(Xt,{name:"underline",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.alignLeft,title:a.alignLeft,onClick:()=>l("justifyLeft"),children:en(Xt,{name:"align-left",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.alignCenter,title:a.alignCenter,onClick:()=>l("justifyCenter"),children:en(Xt,{name:"align-center",size:14})}),en(Yt,{size:"sm",variant:"ghost","aria-label":a.alignRight,title:a.alignRight,onClick:()=>l("justifyRight"),children:en(Xt,{name:"align-right",size:14})}),en(Qt,{size:"sm",variant:"ghost",onClick:()=>s("page"),children:a.pageNumber}),en(Qt,{size:"sm",variant:"ghost",onClick:()=>s("pages"),children:a.pageCount})]})]}),en("div",{ref:e=>{i.current=e,o(e),e&&!e.dataset.ready&&(e.innerHTML=t||"<p><br></p>",e.dataset.ready="1")},className:"docs-page docs-hf-edit","data-doc":r,role:"textbox","aria-label":e,"aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0}),n&&en("p",{className:"docs-hf-note",children:a.headerFooterLocked})]})}function rn({value:e,locked:t,scope:n,onApply:r,onClose:o}){const a=u(),[i,l]=Vt(e.titlePage),[s,c]=Vt(e.evenOdd),d=Gt({}),m=[...i?["first"]:[],"default",...s?["even"]:[]],f={first:a.headerFirst,default:s?a.headerOdd:a.headerDefault,even:a.headerEven};return en(Jt,{open:!0,onClose:o,title:a.headersFooters,size:"lg",footer:tn(Zt,{children:[en(Qt,{variant:"secondary",onClick:o,children:a.cancel}),en(Qt,{variant:"primary",onClick:()=>{const t=(t,n)=>{const r=d.current[`${t}:${n}`];if(!r)return e[t][n];const o=r.innerHTML;return"<p><br></p>"!==o||e[t][n]?o:""},n=e=>({default:t(e,"default"),first:t(e,"first"),even:t(e,"even")});r({headers:n("headers"),footers:n("footers"),titlePage:i,evenOdd:s})},children:a.ok})]}),children:tn("div",{className:"docs-hf",children:[tn("div",{className:"docs-hf-options",children:[en(_t,{checked:i,onChange:l,label:a.differentFirst}),en(_t,{checked:s,onChange:c,label:a.differentOddEven})]}),m.map(r=>tn("section",{className:"docs-hf-kind",children:[en("h4",{children:f[r]}),en(nn,{label:`${a.header} · ${f[r]}`,html:e.headers[r],locked:t.headers[r],scope:n,onRef:e=>{d.current[`headers:${r}`]=e}}),en(nn,{label:`${a.footer} · ${f[r]}`,html:e.footers[r],locked:t.footers[r],scope:n,onRef:e=>{d.current[`footers:${r}`]=e}})]},r))]})})}import{useState as on}from"react";import{Button as an,Dialog as ln,FormField as sn,Input as cn,Select as dn}from"efficient-shell/ui";import{Fragment as un,jsx as mn,jsxs as fn}from"react/jsx-runtime";var pn=e=>{const t=Number(e.replace(",","."));return""!==e.trim()&&Number.isFinite(t)?t:void 0},hn=e=>void 0===e?"":String(Math.round(100*e)/100);function gn({value:e,onApply:t,onClose:n}){const r=u(),[o,a]=on(hn(e.lineMultiple??1.15)),[i,l]=on(hn(e.before??0)),[s,c]=on(hn(e.after??0)),[d,m]=on(hn(e.indentLeft??0)),[f,p]=on(hn(e.indentRight??0)),[h,g]=on(void 0===e.firstLine||0===e.firstLine?"none":e.firstLine>0?"first":"hanging"),[w,b]=on(hn(void 0===e.firstLine?36:Math.abs(e.firstLine)||36)),[y,v]=on(""),x=e=>t=>{e(t.target.value),v("")};return fn(ln,{open:!0,onClose:n,title:r.customSpacing,size:"sm",footer:fn(un,{children:[mn(an,{variant:"secondary",onClick:n,children:r.cancel}),mn(an,{variant:"primary",onClick:()=>{if([o,i,s,d,f,..."none"===h?[]:[w]].some(e=>void 0===pn(e)||pn(e)<0)||pn(o)<=0||pn(o)>10)return void v(r.spacingInvalid);const e=pn(w);t({lineMultiple:pn(o),before:pn(i),after:pn(s),indentLeft:pn(d),indentRight:pn(f),firstLine:"none"===h?0:"first"===h?e:-e})},children:r.ok})]}),children:[fn("div",{className:"docs-para-grid",children:[mn(sn,{label:r.lineSpacingCustom,children:mn(cn,{inputMode:"decimal",value:o,onChange:x(a)})}),mn(sn,{label:r.spacingBefore,children:mn(cn,{inputMode:"decimal",value:i,onChange:x(l)})}),mn(sn,{label:r.spacingAfter,children:mn(cn,{inputMode:"decimal",value:s,onChange:x(c)})}),mn(sn,{label:r.indentLeft,children:mn(cn,{inputMode:"decimal",value:d,onChange:x(m)})}),mn(sn,{label:r.indentRight,children:mn(cn,{inputMode:"decimal",value:f,onChange:x(p)})}),mn(sn,{label:r.indentSpecial,children:mn(dn,{value:h,onChange:e=>{g(String(e)),v("")},options:[{value:"none",label:r.indentNone},{value:"first",label:r.indentFirstLine},{value:"hanging",label:r.indentHanging}]})}),"none"!==h&&mn(sn,{label:r.indentBy,children:mn(cn,{inputMode:"decimal",value:w,onChange:x(b)})})]}),y&&mn("p",{className:"docs-para-error",role:"alert",children:y})]})}import{useRef as wn}from"react";import{Fragment as bn,jsx as yn,jsxs as vn}from"react/jsx-runtime";var xn=4/3,kn={left:"center",center:"right",right:"left"};function Cn({pageWidth:e,marginLeft:t,marginRight:n,zoom:r,value:o,onChange:a}){const i=u(),l=wn(null),s=r/100*xn,c=e-t-n,d=e=>(t+e)*s+"px",m=e=>{const n=l.current.getBoundingClientRect();return r=(e-n.left)/s-t,4.5*Math.round(r/4.5);var r},f=(e,t,n)=>{e.preventDefault(),e.stopPropagation();const r=e.currentTarget;r.setPointerCapture(e.pointerId);const o=l.current.getBoundingClientRect().bottom,i=e=>{const n=t(m(e.clientX),e.clientY>o+12);n&&a(n)},s=e=>{r.removeEventListener("pointermove",i),r.removeEventListener("pointerup",s);const t=n?.(m(e.clientX),e.clientY>o+12);t&&a(t)};r.addEventListener("pointermove",i),r.addEventListener("pointerup",s)},p=(e,t,n)=>Math.min(Math.max(e,t),n),h=o;return vn("div",{className:"docs-ruler",style:{width:e*s+"px"},"aria-label":i.ruler,title:h?i.tabStopHint:void 0,ref:l,onPointerDown:e=>{if(!h||0!==e.button)return;const t=m(e.clientX);t<=0||t>=c||a({...h,tabs:[...h.tabs.filter(e=>Math.abs(e.pos-t)>1),{pos:t,align:"left"}].sort((e,t)=>e.pos-t.pos)})},children:[yn("div",{className:"docs-ruler-margin",style:{left:0,width:d(0)}}),yn("div",{className:"docs-ruler-margin",style:{right:0,width:n*s+"px"}}),Array.from({length:Math.floor(c/36)+1},(e,t)=>yn("span",{className:"docs-ruler-tick",style:{left:d(36*t)},children:t?t/2:""},t)),h&&vn(bn,{children:[yn("button",{type:"button",className:"docs-ruler-first","aria-label":i.indentFirstLine,style:{left:d(h.indentLeft+h.firstLine)},onPointerDown:e=>f(e,e=>({...h,firstLine:p(e,0,c-18)-h.indentLeft}))}),yn("button",{type:"button",className:"docs-ruler-left","aria-label":i.indentLeft,style:{left:d(h.indentLeft)},onPointerDown:e=>f(e,e=>{const t=p(e,0,c-h.indentRight-18);return{...h,indentLeft:t}})}),yn("button",{type:"button",className:"docs-ruler-right","aria-label":i.indentRight,style:{left:d(c-h.indentRight)},onPointerDown:e=>f(e,e=>({...h,indentRight:p(c-e,0,c-h.indentLeft-18)}))}),h.tabs.map((e,t)=>yn("button",{type:"button",className:`docs-ruler-tab docs-ruler-tab-${e.align}`,"aria-label":`${i.tabStop} ${Math.round(e.pos)}pt`,style:{left:d(e.pos)},onDoubleClick:e=>{e.stopPropagation(),a({...h,tabs:h.tabs.map((e,n)=>n===t?{...e,align:kn[e.align]}:e)})},onPointerDown:e=>f(e,e=>({...h,tabs:h.tabs.map((n,r)=>r===t?{...n,pos:p(e,0,c)}:n)}),(e,n)=>({...h,tabs:n?h.tabs.filter((e,n)=>n!==t):h.tabs.map((n,r)=>r===t?{...n,pos:p(e,0,c)}:n).sort((e,t)=>e.pos-t.pos)}))},`${e.pos}-${t}`))]})]})}function Sn(e,t,n){const r=new Blob([e],{type:n}),o=URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(o),1e4)}import{useEffect as Nn,useRef as $n}from"react";import{Icon as An}from"efficient-shell/icons";import{Button as Ln,Checkbox as Pn,IconButton as Tn,Input as Mn}from"efficient-shell/ui";import{jsx as Rn,jsxs as En}from"react/jsx-runtime";function zn({query:e,replacement:t,matchCase:n,current:r,total:o,onQuery:a,onReplacement:i,onMatchCase:l,onStep:s,onReplace:c,onReplaceAll:d,onClose:m}){const f=u(),p=$n(null);return Nn(()=>{p.current?.focus(),p.current?.select()},[]),En("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-line bg-surface-sunken px-2 py-1",children:[Rn("div",{className:"w-40",children:Rn(Mn,{ref:p,size:"sm","aria-label":f.find,placeholder:f.find,value:e,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),s(!e.shiftKey))}})}),Rn("span",{className:"min-w-14 text-xs text-ink-muted","aria-live":"polite",children:e?o?f.matchCount(r+1,o):f.noMatches:""}),Rn(Tn,{size:"sm",variant:"ghost","aria-label":f.previousMatch,title:f.previousMatch,onClick:()=>s(!1),children:Rn(An,{name:"chevron-up",size:16})}),Rn(Tn,{size:"sm",variant:"ghost","aria-label":f.nextMatch,title:f.nextMatch,onClick:()=>s(!0),children:Rn(An,{name:"chevron-down",size:16})}),Rn("div",{className:"ml-1 w-40",children:Rn(Mn,{size:"sm","aria-label":f.replaceWith,placeholder:f.replaceWith,value:t,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),c())}})}),Rn(Ln,{size:"sm",variant:"secondary",onClick:c,children:f.replace}),Rn(Ln,{size:"sm",variant:"secondary",onClick:d,children:f.replaceAll}),En("label",{className:"ml-1 flex items-center gap-1 text-xs text-ink-muted",children:[Rn(Pn,{checked:n,onChange:l,"aria-label":f.matchCase}),f.matchCase]}),Rn(Tn,{className:"ml-auto",size:"sm",variant:"ghost","aria-label":f.closeFind,title:f.closeFind,onClick:m,children:Rn(An,{name:"close",size:16})})]})}var Fn=class{past=[];future=[];get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}record(e){if(this.past[this.past.length-1]?.html===e.html)return;this.past.push(e),this.future=[];let t=this.past.reduce((e,t)=>e+t.html.length,0);for(;this.past.length>1&&(this.past.length>200||t>67108864);)t-=this.past.shift().html.length}undo(e){const t=this.past.pop();return t?(this.future.push(e),t):null}redo(e){const t=this.future.pop();return t?(this.past.push(e),t):null}};function On(e,t,n){const r=[];let o=t;for(;o&&o!==e;){const e=o.parentNode;if(!e)return null;r.unshift(Array.prototype.indexOf.call(e.childNodes,o)),o=e}return o===e?{path:r,offset:n}:null}function jn(e,t){let n=e;for(const e of t.path){const t=n.childNodes[e];if(!t)return null;n=t}const r=3===n.nodeType?(n.nodeValue??"").length:n.childNodes.length;return{node:n,offset:Math.min(t.offset,r)}}function Hn(e){return Array.from(e.querySelectorAll("h1,h2,h3,h4,h5,h6")).filter(e=>!e.closest("[data-hidden]")&&""!==(e.textContent??"").trim())}var Dn=["#000000","#404040","#7f7f7f","#c00000","#ff0000","#ffc000","#00b050","#0070c0","#002060","#7030a0"],In=["#ffff00","#00ff00","#00ffff","#ff00ff","#ff0000","#c0c0c0"],Bn=["#d9e2f3","#e2efd9","#fff2cc","#fbe4d5","#ededed","#bfbfbf"];function Un(e){if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();const t=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(e);return t?`#${[t[1],t[2],t[3]].map(e=>Number(e).toString(16).padStart(2,"0")).join("")}`:""}import{useState as Wn}from"react";import{Button as qn,Dialog as Kn,FormField as Gn,Select as Vn}from"efficient-shell/ui";import{Fragment as Xn,jsx as Qn,jsxs as _n}from"react/jsx-runtime";function Jn({value:e,onApply:t,onClose:n}){const r=u(),[o,a]=Wn(e.page),i=o.width>o.height,l=O(o),s=F(o),c={a4:"A4",a3:"A3",a5:"A5",letter:r.paperLetter,legal:r.paperLegal},d={normal:r.marginsNormal,narrow:r.marginsNarrow,moderate:r.marginsModerate,wide:r.marginsWide},m={value:"custom",label:r.custom};return Qn(Kn,{open:!0,onClose:n,title:r.pageSetup,size:"sm",footer:_n(Xn,{children:[Qn(qn,{variant:"secondary",onClick:n,children:r.cancel}),Qn(qn,{variant:"primary",onClick:()=>t({page:o}),children:r.ok})]}),children:_n("div",{className:"space-y-3",children:[Qn(Gn,{label:r.paperSize,children:Qn(Vn,{value:l??"custom",onChange:e=>{"custom"!==e&&a(t=>J(t,e))},options:[...l?[]:[m],...Object.keys(N).map(e=>({value:e,label:c[e]}))]})}),Qn(Gn,{label:r.orientation,children:Qn(Vn,{value:i?"landscape":"portrait",onChange:e=>{"landscape"===e!==i&&a(e=>({...e,width:e.height,height:e.width}))},options:[{value:"portrait",label:r.portrait},{value:"landscape",label:r.landscape}]})}),Qn(Gn,{label:r.margins,children:Qn(Vn,{value:s??"custom",onChange:e=>{"custom"!==e&&a(t=>_(t,e))},options:[...s?[]:[m],...Object.keys(S).map(e=>({value:e,label:d[e]}))]})})]})})}var Yn=e=>e.querySelectorAll("ul,ol").forEach(e=>e.removeAttribute("data-ilvl"));function Zn(e){const t=e.previousElementSibling,n=e.parentElement;if(!t||"LI"!==t.tagName||!n)return!1;const r=t.lastElementChild;let o;var a;return a=r,"UL"===a?.tagName||"OL"===a?.tagName?o=r:(o=e.ownerDocument.createElement(n.tagName),t.appendChild(o)),o.appendChild(e),Yn(e),!0}function er(e){const t=e.parentElement,n=t?.parentElement;if(!t||"LI"!==n?.tagName)return!1;const r=[];for(let t=e.nextElementSibling;t;t=t.nextElementSibling)r.push(t);if(r.length){const n=e.ownerDocument.createElement(t.tagName),o=t.getAttribute("data-num-id");o&&n.setAttribute("data-num-id",o),r.forEach(e=>n.appendChild(e)),e.appendChild(n)}return n.parentElement.insertBefore(e,n.nextSibling),Yn(e),t.children.length||t.remove(),!0}var tr=e=>Array.from(e.querySelectorAll(":scope > tbody > tr, :scope > tr, :scope > thead > tr, :scope > tfoot > tr")),nr=(e,t)=>Math.max(1,Number(e.getAttribute(t)??1));function rr(e){const t=tr(e),n=t.map(()=>[]);return t.forEach((e,r)=>{let o=0;for(const a of(e=>Array.from(e.children).filter(e=>"TD"===e.tagName||"TH"===e.tagName))(e)){for(;n[r][o];)o++;const e=nr(a,"colspan"),i=nr(a,"rowspan");for(let l=r;l<Math.min(r+i,t.length);l++)for(let t=o;t<o+e;t++)n[l][t]=a;o+=e}}),{table:e,slots:n,cols:Math.max(0,...n.map(e=>e.length))}}function or(e,t){for(let n=0;n<e.slots.length;n++){const r=e.slots[n].indexOf(t);if(r>=0)return{row:n,col:r}}return null}function ar(e){const t=e.createElement("td");return t.innerHTML="<p><br></p>",t}function ir(e,t,n){const r=rr(e),o=or(r,t);if(!o)return;const a=tr(e),i=nr(t,"rowspan"),l=n?o.row+i:o.row,s=e.ownerDocument.createElement("tr"),c=new Set;for(let t=0;t<r.cols;t++){const n=l>0?r.slots[l-1]?.[t]:void 0,o=r.slots[l]?.[t];n&&n===o?c.has(n)||(c.add(n),n.setAttribute("rowspan",String(nr(n,"rowspan")+1))):s.appendChild(ar(e.ownerDocument))}const d=a[l];d?d.parentNode.insertBefore(s,d):a[a.length-1].parentNode.appendChild(s)}function lr(e,t,n){const r=rr(e),o=or(r,t);if(!o)return;const a=n?o.col+nr(t,"colspan"):o.col,i=new Set;r.slots.forEach((t,n)=>{const r=a>0?t[a-1]:void 0,o=t[a];if(r&&r===o)return void(i.has(r)||(i.add(r),r.setAttribute("colspan",String(nr(r,"colspan")+1))));if(o&&o.parentElement!==tr(e)[n])return;const l=tr(e)[n],s=t.slice(a).find(e=>e.parentElement===l);l.insertBefore(ar(e.ownerDocument),s??null)}),sr(e,r.cols+1,a,null)}function sr(e,t,n,r){const o=e.querySelector(":scope > colgroup");if(!o)return;const a=Array.from(o.children);if(null!==r&&a[r]?.remove(),null!==n){const t=e.ownerDocument.createElement("col"),r=a[Math.min(n,a.length-1)];r?.getAttribute("style")&&t.setAttribute("style",r.getAttribute("style")),o.insertBefore(t,a[n]??null)}o.children.length!==t&&o.remove()}import{Fragment as cr,jsx as dr,jsxs as ur}from"react/jsx-runtime";var mr=["Calibri","Arial","Cambria","Courier New","Georgia","Tahoma","Times New Roman","Verdana"],fr=[8,9,10,10.5,11,12,14,16,18,20,22,24,28,32,36,48,72],pr=[1,1.15,1.5,2,2.5,3],hr=/^[A-Za-z][A-Za-z0-9_]{0,39}$/,gr="data-docs-fonts",wr=["default","first","even"];function br(e){const t=[...new Set(e)].filter(e=>A.includes(e));if(!t.length||"undefined"==typeof document)return;const n=document.head.querySelector(`link[${gr}]`),r=n?.getAttribute(gr)?.split("|").filter(Boolean)??[],o=[...new Set([...r,...t])].sort();if(n&&o.length===r.length)return;const a=document.createElement("link");a.rel="stylesheet",a.href=Q(o),a.setAttribute(gr,o.join("|")),document.head.appendChild(a),n?.remove()}function yr(e,t,n){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.querySelectorAll('[data-field="page"]').forEach(e=>{e.textContent=String(t)}),r.querySelectorAll('[data-field="pages"]').forEach(e=>{e.textContent=String(n)}),r.innerHTML}var vr=e=>Math.round(.75*(parseFloat(e)||0)*100)/100,xr=[50,75,90,100,110,125,150,200],kr="p,h1,h2,h3,h4,h5,h6,li,blockquote,pre",Cr=/^(https?:|mailto:|tel:)/i,Sr={bold:!1,italic:!1,underline:!1,strike:!1,sub:!1,sup:!1,ul:!1,ol:!1,align:"left",font:"",size:null,styleId:null,color:""};function Nr({sessionKey:d,doc:m,filename:f,images:p,fileEntries:w,title:b,startsDirty:y,dirty:x,onDirty:k,onOpenFile:C,onNewImageUrl:S,onClose:N,stored:$,onReload:L}){const P=u(),T=Fe(),M=pe().replace(/[^a-zA-Z0-9]/g,""),R=ge(null),E=ge(null),z=ge(null),F=ge(new Fn),H=ge(null),D=ge(null),B=ge(null),U=ge(!!y),W=ge(0),q=ge(()=>{}),G=ge(null),Q=ge(0),_=ge($?.version??""),J=ge(null),[Y,Z]=we({page:m.page}),[ee,te]=we(()=>({headers:{default:m.headers.default.html,first:m.headers.first.html,even:m.headers.even.html},footers:{default:m.footers.default.html,first:m.footers.first.html,even:m.footers.even.html},titlePage:m.titlePage,evenOdd:m.evenOdd})),[ne,re]=we(!1),[oe,ae]=we(m.columns),[ie,le]=we(!1),se=ge(new Map),[ce,de]=we(""),[ue,Oe]=we(null),[je,He]=we(null),De=ge(null),Ie=ge(null),[Be,We]=we(!1),[qe,Ke]=we([]),[,Ge]=we(0),Ve=ge(null),[Xe,Qe]=we(null),[_e,Je]=we(Sr),[Ze,et]=we({undo:!1,redo:!1}),[tt,nt]=we({words:0,pageNow:1}),[rt,ot]=we([0]),[at,it]=we([]),[lt,st]=we(!1),[ct,dt]=we(100),[ut,mt]=we(!1),[ft,pt]=we(!0),[ht,gt]=we(!1),[wt,bt]=we({rows:0,cols:0}),[yt,vt]=we(null),[xt,kt]=we(null),[Ct,St]=we(!1),[Nt,$t]=we(""),[At,Lt]=we(""),[Pt,Tt]=we(!1),[Mt,Rt]=we(0),[Et,zt]=we(0),Ft=ge([]),Ot=(Y.page.width-Y.page.left-Y.page.right)/20,jt=e=>!!e&&!!E.current?.contains(e),Ht=me(()=>{const e=E.current,t=document.getSelection();if(!(e&&t?.anchorNode&&t.focusNode&&jt(t.anchorNode))){const t=H.current;if(!e||!t)return null;const n=On(e,t.startContainer,t.startOffset),r=On(e,t.endContainer,t.endOffset);return n&&r?{anchor:n,focus:r}:null}const n=On(e,t.anchorNode,t.anchorOffset),r=On(e,t.focusNode,t.focusOffset);return n&&r?{anchor:n,focus:r}:null},[]),Dt=me(e=>{const t=E.current,n=document.getSelection();if(!t||!n||!e)return;const r=jn(t,e.anchor),o=jn(t,e.focus);r&&o&&n.setBaseAndExtent(r.node,r.offset,o.node,o.offset)},[]),It=me(e=>{const t=E.current;if(!t)return;const n=document.getSelection(),r=!e&&!!n&&jt(n.anchorNode);if(document.activeElement!==t&&t.focus({preventScroll:!0}),r&&n?.rangeCount)return void(H.current=n.getRangeAt(0).cloneRange());const o=e??H.current;n&&o&&(n.removeAllRanges(),n.addRange(o),H.current=o.cloneRange())},[]),Bt=me(()=>{const e=E.current,t=H.current;if(!e||!t)return[];const n=Array.from(e.querySelectorAll(kr)).filter(e=>!e.closest("[data-locked]"));var r;return(t.collapsed?[(r=t.startContainer,(1===r.nodeType?r:r.parentElement)?.closest(kr))].filter(Boolean):n.filter(e=>t.intersectsNode(e))).filter(e=>jt(e)&&!e.closest("[data-locked]"))},[]),Ut=me(()=>{cancelAnimationFrame(W.current),W.current=requestAnimationFrame(()=>{const n=E.current;if(!n)return;const o=n.getBoundingClientRect().height/(n.offsetHeight||1)||1,i=n.getBoundingClientRect().top+Y.page.top/20*(4/3)*o,l=(Y.page.height-Y.page.top-Y.page.bottom)/20*(4/3),s=a(r(n,i,o),l);ot(e=>e.length===s.length&&e.every((e,t)=>e===s[t])?e:s);const c=document.getSelection();let d=1;if(c?.rangeCount&&jt(c.anchorNode)){const e=c.getRangeAt(0).getClientRects()[0]??c.anchorNode?.getBoundingClientRect?.();if(e){const t=(e.top-i)/o;for(let e=0;e<s.length;e++)s[e]<=t+1&&(d=e+1)}}nt({words:e(t(n)),pageNow:d});const u=[...new Set(Array.from(n.querySelectorAll("[data-note]")).map(e=>e.getAttribute("data-note")))];Ke(e=>e.length===u.length&&e.every((e,t)=>e===u[t])?e:u),le(!!n.querySelector(":scope > [data-section]"));const m=function(e){return Hn(e).map(e=>({level:Number(e.tagName[1]),text:(e.textContent??"").trim().replace(/\s+/g," ")}))}(n);it(e=>{return n=m,(t=e).length===n.length&&t.every((e,t)=>e.level===n[t].level&&e.text===n[t].text)?e:m;var t,n})})},[Y.page]),Wt=me(()=>{const e=document.getSelection();if(!e?.anchorNode||!jt(e.anchorNode))return;const t=1===e.anchorNode.nodeType?e.anchorNode:e.anchorNode.parentElement;if(!t)return;const n=getComputedStyle(t),r=t.closest(kr),o=e=>{try{return document.queryCommandState(e)}catch{return!1}},a=n.textAlign,i=.75*parseFloat(n.fontSize);if(Je({bold:o("bold"),italic:o("italic"),underline:o("underline"),strike:o("strikeThrough"),sub:o("subscript"),sup:o("superscript"),ul:o("insertUnorderedList"),ol:o("insertOrderedList"),align:"center"===a||"right"===a||"justify"===a?a:"left",font:n.fontFamily.split(",")[0].replace(/["']/g,"").trim(),size:i?Math.round(2*i)/2:null,styleId:r?.getAttribute("data-pstyle")??null,color:Un(n.color)}),r&&!r.closest("[data-locked]")){const e=getComputedStyle(r),t="LI"===r.tagName;He({indentLeft:t?0:vr(e.marginLeft),indentRight:vr(e.marginRight),firstLine:t?0:vr(e.textIndent),tabs:I(r.getAttribute("data-tabs"))})}else He(null)},[]),qt=async()=>{const e=G.current;if(!e)throw new Error("No page");if(!U.current&&Y.page===m.page&&m.source)return m.source;const t=Q.current,n=await Kt(m,e,{page:Y.page,headers:ee.headers,footers:ee.footers,titlePage:ee.titlePage,evenOdd:ee.evenOdd,columns:oe,styleEdits:se.current,images:p});return U.current&&Q.current===t&&(m.source=n,U.current=!1,Z(e=>({...e,page:m.page}))),n},Gt=ve(),Vt=ye({debounceMs:1500,maxWaitMs:4e3,save:async()=>{$&&(_.current=await $.store.save($.id,await qt(),_.current))},onFailure:(e,t)=>{e instanceof c?(Vt.stop(),st(!0)):0===t&&ze.error(P.saveFailed)}}),{push:Xt,flush:Qt}=Vt,_t=!!$,Jt=Vt.state.pending;fe(()=>{_t&&k(Jt||lt)},[lt,_t,k,Jt]),fe(()=>()=>{Qt()},[Qt]);const Yt=me(()=>{U.current=!0,Q.current+=1,k(!0),_t&&Xt(Q.current),Ut(),et({undo:F.current.canUndo,redo:F.current.canRedo})},[_t,Ut,k,Xt]),Zt=me(()=>({html:E.current?.innerHTML??"",caret:Ht()}),[Ht]),en=()=>{D.current&&clearTimeout(D.current),D.current=null},tn=me(e=>{e&&E.current&&(E.current.innerHTML=e.html,E.current.focus({preventScroll:!0}),Dt(e.caret),en(),Yt(),Wt())},[Dt,Yt,Wt]),nn=me(()=>tn(F.current.undo(Zt())),[tn,Zt]),on=me(()=>tn(F.current.redo(Zt())),[tn,Zt]),an=me(e=>{It(),en(),F.current.record(Zt()),e(),Yt(),Wt()},[Yt,Wt,It,Zt]),ln=me((e,t)=>an(()=>{document.execCommand(e,!1,t)}),[an]),sn=e=>an(()=>{document.execCommand(e);const t=E.current;if(!t)return;const n=document.getSelection(),r=n?.anchorNode??null,o=n?.anchorOffset??0;let a=!1;t.querySelectorAll("p > ul, p > ol").forEach(e=>{const t=e.parentElement;Array.from(t.childNodes).some(t=>t!==e&&(1===t.nodeType||(t.nodeValue??"").trim()))||(t.replaceWith(e),a=!0)}),a&&r&&n?.collapse(r,o)});fe(()=>{const e=E.current;if(!e)return;G.current=e,e.innerHTML=m.html,br(A.filter(e=>m.html.includes(e)||m.css.includes(e)||m.defaultFont===e));try{document.execCommand("defaultParagraphSeparator",!1,"p"),document.execCommand("styleWithCSS",!1,"true")}catch{}e.focus({preventScroll:!0});const t=e.querySelector(kr);t&&document.getSelection()?.collapse(t,0),Ut();const n=t=>"historyUndo"===t.inputType?(t.preventDefault(),void nn()):"historyRedo"===t.inputType?(t.preventDefault(),void on()):(D.current?clearTimeout(D.current):F.current.record({html:e.innerHTML,caret:Ht()}),void(D.current=setTimeout(()=>{D.current=null},600))),r=()=>{(()=>{const t=B.current;e.querySelectorAll('font[size="7"]').forEach(e=>{const n=document.createElement("span");for(n.setAttribute("style",`font-size:${t??11}pt`);e.firstChild;)n.appendChild(e.firstChild);e.replaceWith(n),3===n.lastChild?.nodeType&&document.getSelection()?.collapse(n.lastChild,(n.lastChild.nodeValue??"").length)})})(),Yt(),Wt()},o=()=>{const e=document.getSelection();e?.rangeCount&&jt(e.anchorNode)&&(H.current=e.getRangeAt(0).cloneRange(),Wt(),Ut())};e.addEventListener("beforeinput",n),e.addEventListener("input",r),document.addEventListener("selectionchange",o);const a=new ResizeObserver(()=>Ut());return a.observe(e),()=>{e.removeEventListener("beforeinput",n),e.removeEventListener("input",r),document.removeEventListener("selectionchange",o),a.disconnect(),cancelAnimationFrame(W.current),en(),J.current&&clearTimeout(J.current)}},[]),fe(()=>{Ut()},[Ut]),fe(()=>{const e=Ve.current;e&&qe.includes(e)&&(Ve.current=null,R.current?.querySelector(`input[data-note-input="${e}"]`)?.focus())},[qe]),fe(()=>{y&&k(!0)},[]);const cn=e=>an(()=>{const t=Ht(),n=e?/^heading ([1-6])$/i.exec(m.styles.find(t=>t.id===e)?.name??"")?.[1]:void 0,r=n?`H${n}`:"P";for(const t of Bt()){if("LI"===t.tagName){e?t.setAttribute("data-pstyle",e):t.removeAttribute("data-pstyle");continue}let n=t;if(t.tagName!==r){n=document.createElement(r);for(const e of Array.from(t.attributes))n.setAttribute(e.name,e.value);for(;t.firstChild;)n.appendChild(t.firstChild);t.replaceWith(n)}e?n.setAttribute("data-pstyle",e):n.removeAttribute("data-pstyle")}Dt(t)}),dn=(e,t)=>an(()=>{for(const n of Bt())n.style["before"===e?"marginTop":"marginBottom"]=t?"10pt":"0pt"}),un=()=>{const e=Bt()[0];if(!e)return{};const t=getComputedStyle(e),n=parseFloat(t.fontSize)||14.67,r=parseFloat(t.lineHeight);return{before:vr(t.marginTop),after:vr(t.marginBottom),lineMultiple:Number.isFinite(r)?Math.round(r/n*100)/100:1.15,indentLeft:"LI"===e.tagName?void 0:vr(t.marginLeft),indentRight:vr(t.marginRight),firstLine:"LI"===e.tagName?void 0:vr(t.textIndent)}},mn=()=>{const e=Ie.current,t=document.getSelection();e&&t&&!t.isCollapsed&&jt(t.anchorNode)&&(Ie.current=null,We(!1),H.current=t.getRangeAt(0).cloneRange(),an(()=>{const t=(e,t)=>{!!t!==(e=>{try{return document.queryCommandState(e)}catch{return!1}})(e)&&document.execCommand(e)};t("bold",e.run.b),t("italic",e.run.i),t("underline",e.run.u),t("strikeThrough",e.run.strike),e.run.font&&document.execCommand("fontName",!1,e.run.font),e.run.color&&document.execCommand("foreColor",!1,e.run.color),document.execCommand("hiliteColor",!1,e.run.hl||"transparent"),e.run.size&&(document.execCommand("styleWithCSS",!1,"false"),document.execCommand("fontSize",!1,"7"),document.execCommand("styleWithCSS",!1,"true"),E.current?.querySelectorAll('font[size="7"]').forEach(t=>{const n=document.createElement("span");for(n.setAttribute("style",`font-size:${e.run.size}pt`);t.firstChild;)n.appendChild(t.firstChild);t.replaceWith(n)}));for(const t of Bt())"LI"!==t.tagName&&(e.styleId?t.setAttribute("data-pstyle",e.styleId):t.removeAttribute("data-pstyle"))}))},fn=e=>{br([e]),ln("fontName",e)},pn=e=>an(()=>{const t=E.current,n=Bt()[0];if(!t||!n)return;const r=Array.from(t.children).find(e=>e.contains(n));if(!r)return;r.setAttribute("data-section",e);const o=document.createElement("p");o.innerHTML="<br>",r.after(o),document.getSelection()?.collapse(o,0)}),hn=e=>{let t=e.getAttribute("data-bm");return t||(t=`_Toc${Math.floor(1e8+899999999*Math.random())}`,e.setAttribute("data-bm",t)),t},wn=()=>{const e=E.current;if(!e)return"";const t=e.getBoundingClientRect().height/(e.offsetHeight||1)||1,n=e.getBoundingClientRect().top+Y.page.top/20*(4/3)*t;return Hn(e).filter(e=>Number(e.tagName[1])<=3&&!e.closest("[data-toc]")).map(e=>{const r=(e.getBoundingClientRect().top-n)/t;let o=1;for(let e=0;e<rt.length;e++)rt[e]<=r+1&&(o=e+1);return v(Number(e.tagName[1]),hn(e),(e.textContent??"").trim(),String(o))}).join("")},bn=()=>{const e=[...m.footnotes.keys(),...qe].map(Number).filter(Number.isFinite),t=String(Math.max(0,...e)+1);m.footnotes.set(t,{text:"",editable:!0}),Ve.current=t,ln("insertHTML",`<span data-kind="note" data-note="${t}" contenteditable="false"></span>`)},yn=()=>Array.from(E.current?.querySelectorAll("[data-bookmark]")??[]).map(e=>e.getAttribute("data-bookmark")),vn=(e,t)=>{It();const n=H.current;if(n&&!n.collapsed)ln("createLink",`#${e}`);else{const n=document.createElement("a");n.href=`#${e}`,n.textContent=t,ln("insertHTML",n.outerHTML)}},xn=e=>{const t=E.current;return t&&/^[A-Za-z0-9_]+$/.test(e)?t.querySelector(`[data-bm="${e}"],[data-bookmark="${e}"],[data-toc-anchor="${e}"]`):null},kn=e=>an(()=>{const t=Bt(),n=t.filter(e=>"LI"===e.tagName);if(n.length){const t=document.getSelection(),r=t?.anchorNode??null,o=t?.anchorOffset??0;for(const t of e?n:[...n].reverse())e?Zn(t):er(t);return void(r&&t?.collapse(r,o))}for(const n of t){const t=parseFloat(n.style.marginLeft)||0,r=Math.max(0,t+(e?36:-36));n.style.marginLeft=r?`${r}pt`:""}}),Nn=e=>ln({left:"justifyLeft",center:"justifyCenter",right:"justifyRight",justify:"justifyFull"}[e]),$n=async e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new Uint8Array(await t.arrayBuffer()),n=URL.createObjectURL(new Blob([e],{type:t.type}));S(n),p.set(n,{bytes:e,mime:t.type});const r=new Image;r.src=n,await r.decode().catch(()=>{});const o=.75*r.naturalWidth,a=Math.min(o||Ot,Ot),i=o?a*(r.naturalHeight/r.naturalWidth):0;ln("insertHTML",`<img src="${n}" alt="" style="width:${Math.round(100*a)/100}pt${i?`;height:${Math.round(100*i)/100}pt`:""}">`)}},An=async()=>{It();const e=H.current?.cloneRange()??null,t=e?.startContainer?1===e.startContainer.nodeType?e.startContainer:e.startContainer.parentElement:null,n=t?.closest("a")??null,r=await Re({title:P.link,message:P.linkPrompt,placeholder:"https://example.com",defaultValue:n?.getAttribute("href")??"",confirmLabel:P.ok,cancelLabel:P.cancel,allowEmpty:!0});if(await new Promise(e=>setTimeout(e,0)),It(e),null===r)return;const o=r.trim();if(!o)return void(n&&ln("unlink"));const a=/^[a-z][a-z0-9+.-]*:/i.test(o)?o:`https://${o}`;if(Cr.test(a))if(n)an(()=>{n.setAttribute("href",a)});else if(e?.collapsed){const e=document.createElement("a");e.href=a,e.textContent=o,ln("insertHTML",e.outerHTML)}else ln("createLink",a);else ze.error(P.linkInvalid)},Ln=()=>ln("insertHTML",'<span data-page-break="" contenteditable="false"></span>​'),Pn=(e,t)=>{gt(!1);const n=function(e,t,n,r){const o=e.createElement("table"),a=e.createElement("colgroup");for(let t=0;t<n;t++){const t=e.createElement("col");t.setAttribute("style",`width:${Math.round(r/n*100)/100}pt`),a.appendChild(t)}o.appendChild(a);const i=e.createElement("tbody");for(let r=0;r<t;r++){const t=e.createElement("tr");for(let r=0;r<n;r++)t.appendChild(ar(e));i.appendChild(t)}return o.appendChild(i),o}(document,e,t,Ot);n.setAttribute("data-new",""),ln("insertHTML",`${n.outerHTML}<p><br></p>`);const r=E.current?.querySelector("table[data-new]");if(r){r.removeAttribute("data-new");const e=r.querySelector("td p");e&&document.getSelection()?.collapse(e,0)}};q.current=e=>{$n(e)};const Tn=e=>{if(!yt)return;const t=yt.el;an(()=>{const n=.75*t.naturalWidth,r=null===e?n:Ot*e,o=t.naturalWidth?t.naturalHeight/t.naturalWidth:.75;t.removeAttribute("width"),t.removeAttribute("height"),t.style.width=Math.round(100*r)/100+"pt",t.style.height=Math.round(r*o*100)/100+"pt"}),vt(null)},Mn=me((e,t)=>{const n=Ft.current,r=e=>{const t=document.createRange();return t.setStart(e[0].node,e[0].start),t.setEnd(e[e.length-1].node,e[e.length-1].end),t},o=globalThis.CSS?.highlights,a=globalThis.Highlight;o&&a&&(o.set("docs-find",new a(...n.map(r))),o.set("docs-find-current",new a(...n[e]?[r(n[e])]:[]))),t&&n[e]&&n[e][0].node.parentElement?.scrollIntoView({block:"center"})},[]),Rn=()=>{const e=globalThis.CSS?.highlights;e?.delete("docs-find"),e?.delete("docs-find-current")},En=me((e,t,r)=>{const o=E.current,a=o?n(o,e,t):[];Ft.current=a,zt(a.length);const i=a.length?Math.min(r,a.length-1):0;Rt(i),Mn(i,!0)},[Mn]),Wn=me(()=>{const e=Ft.current[Mt];St(!1),Rn();const t=E.current;t?.focus({preventScroll:!0}),e&&document.getSelection()?.setBaseAndExtent(e[0].node,e[0].start,e[e.length-1].node,e[e.length-1].end),Ft.current=[]},[Mt]),qn=()=>{const e=document.getSelection(),t=e&&jt(e.anchorNode)?e.toString():"";St(!0);const n=t&&!t.includes("\n")?t:Nt;$t(n),setTimeout(()=>En(n,Pt,0),0)},Kn=ge(Wn);Kn.current=Wn;const Gn=ge(Ct);Gn.current=Ct,fe(()=>Ee(()=>!(!Gn.current||!R.current?.contains(document.activeElement))&&(Kn.current(),!0)),[]),fe(()=>()=>Rn(),[]),fe(()=>{const e=e=>{const{key:t,files:n}=e.detail;t===d&&q.current(n)};return window.addEventListener("docs-insert-images",e),()=>window.removeEventListener("docs-insert-images",e)},[d]);const Vn=$?f:(e=>e.replace(/\.[^.]+$/,"")||e)(f),Xn=`${Vn}.docx`,Qn=async()=>{try{const e=Q.current;Sn(await qt(),Xn,"application/vnd.openxmlformats-officedocument.wordprocessingml.document"),$||Q.current!==e||k(!1)}catch{ze.error(P.saveFailed)}},_n=e=>o({title:Vn,html:e,doc:{css:`${m.css}\n${ce}`},scope:M,page:Y.page,header:g(ee.headers.default),footer:g(ee.footers.default)}),Yn=()=>{const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;width:0;height:0;border:0;left:-10px;top:-10px",document.body.appendChild(e);const t=e.contentWindow;if(!t)return void e.remove();t.document.open(),t.document.write(_n(E.current?.innerHTML??"")),t.document.close();const n=()=>{t.focus(),t.print(),setTimeout(()=>e.remove(),6e4)},r=Array.from(t.document.images).filter(e=>!e.complete);r.length?Promise.all(r.map(e=>e.decode().catch(()=>{}))).then(n):n()},gr=w.length?[...w,{type:"divider",key:"d1"},{key:"save",label:dr($r,{label:P.saveDocx,hint:"⌘S"}),onSelect:()=>{Qn()}}]:[],Nr=[{key:"docx",label:P.saveAsWord,onSelect:()=>{Qn()}},{key:"pdf",label:P.saveAsPdf,onSelect:Yn},{key:"html",label:P.saveAsWeb,onSelect:()=>{(async()=>{const e=document.createElement("div");e.innerHTML=E.current?.innerHTML??"";for(const t of Array.from(e.querySelectorAll("img"))){const e=p.get(t.getAttribute("src")??"");if(!e)continue;let n="";for(let t=0;t<e.bytes.length;t+=32768)n+=String.fromCharCode(...e.bytes.subarray(t,t+32768));t.setAttribute("src",`data:${e.mime};base64,${btoa(n)}`)}e.querySelectorAll("[data-hidden]").forEach(e=>e.remove()),Sn(_n(e.innerHTML),`${Vn}.html`,"text/html")})()}},{key:"txt",label:P.saveAsText,onSelect:()=>{Sn(t(E.current),`${Vn}.txt`,"text/plain")}}],Ar=E.current?yn():[],Lr=[{key:"table",label:P.table,onSelect:()=>gt(!0)},{key:"image",label:P.image,onSelect:()=>z.current?.click()},{key:"link",label:dr($r,{label:P.link,hint:"⌘K"}),onSelect:()=>{An()}},{type:"submenu",key:"linkHeading",label:P.linkToHeading,items:at.length?at.map((e,t)=>({key:`h${t}`,label:dr("span",{style:{paddingLeft:8*(e.level-1)},children:e.text}),onSelect:()=>(e=>{const t=E.current,n=t?Hn(t)[e]:void 0;if(!n)return;It();const r=H.current?.cloneRange()??null;F.current.record(Zt());const o=hn(n);It(r),vn(o,(n.textContent??"").trim())})(t)})):[{type:"label",key:"none",label:P.noHeadings}]},{type:"submenu",key:"linkBookmark",label:P.linkToBookmark,items:Ar.length?Ar.map(e=>({key:e,label:e,onSelect:()=>vn(e,e)})):[{type:"label",key:"none",label:P.noBookmarks}]},{type:"divider",key:"d1"},{key:"toc",label:P.tableOfContents,onSelect:()=>{It();const e=wn();ln("insertHTML",`<div data-toc="" contenteditable="false">${e}</div><p><br></p>`)}},{key:"footnote",label:dr($r,{label:P.footnote,hint:"⌘⌥F"}),onSelect:bn},{key:"bookmark",label:P.bookmark,onSelect:()=>{(async()=>{It();const e=H.current?.cloneRange()??null,t=await Re({title:P.bookmark,message:P.bookmarkPrompt,placeholder:"Clause_4",confirmLabel:P.ok,cancelLabel:P.cancel});if(await new Promise(e=>setTimeout(e,0)),It(e),null===t)return;const n=t.trim();hr.test(n)?yn().includes(n)?ze.error(P.bookmarkTaken):ln("insertHTML",`<span data-kind="mark" data-bookmark="${n}" contenteditable="false"></span>`):ze.error(P.bookmarkInvalid)})()}},{type:"submenu",key:"breaks",label:P.breakMenu,items:[{key:"page",label:dr($r,{label:P.pageBreak,hint:"⌘↵"}),onSelect:Ln},{key:"next",label:P.sectionBreakNext,onSelect:()=>pn("nextPage")},{key:"cont",label:P.sectionBreakContinuous,onSelect:()=>pn("continuous")}]},{key:"number",label:P.pageNumber,onSelect:()=>re(!0)},{key:"line",label:P.horizontalLine,onSelect:()=>ln("insertHorizontalRule")}],Pr=(()=>{const e=E.current,t=H.current?1===H.current.startContainer.nodeType?H.current.startContainer:H.current.startContainer.parentElement:null;return e&&t?Array.from(e.children).find(e=>e.contains(t))??null:null})(),Tr=[{key:"setup",label:P.pageSetup,onSelect:()=>mt(!0)},{key:"hf",label:P.headersFooters,onSelect:()=>re(!0)},{type:"submenu",key:"cols",label:P.columns,items:[1,2,3].map(e=>({key:String(e),label:P.columnsCount(e),onSelect:()=>(e=>{const t=E.current,n=Bt()[0];if(!t)return;let r=n?Array.from(t.children).find(e=>e.contains(n))??null:null;for(;r&&!r.hasAttribute("data-section");)r=r.nextElementSibling;r?an(()=>{e>1?r.setAttribute("data-cols",String(e)):r.removeAttribute("data-cols")}):(ae(e),Yt())})(e)}))},...Pr?.hasAttribute("data-section")?[{key:"unsection",label:P.removeSectionBreak,onSelect:()=>{return e=Pr,an(()=>{e.removeAttribute("data-section"),e.removeAttribute("data-cols")});var e}}]:[]],Mr={Title:P.styleTitle,"heading 1":P.styleHeading1,"heading 2":P.styleHeading2,"heading 3":P.styleHeading3,"heading 4":P.styleHeading4,"heading 5":P.styleHeading5,"heading 6":P.styleHeading6,Quote:P.styleQuote},Rr=[{key:"normal",label:P.styleNormal,onSelect:()=>cn(null)},...m.styles.map(e=>{const t=Mr[e.name]??e.name;return{type:"submenu",key:e.id,label:t,items:[{key:"apply",label:P.applyStyle(t),onSelect:()=>cn(e.id)},{key:"update",label:P.updateStyle(t),onSelect:()=>((e,t)=>an(()=>{const n=Bt()[0];if(!n)return;const r=Array.from(n.querySelectorAll("*")).find(e=>(e.textContent??"").trim()&&!e.querySelector("*"))??n,o=getComputedStyle(r),a=getComputedStyle(n),i=parseFloat(o.fontSize)||14.67,l=parseFloat(a.lineHeight),s={b:Number(o.fontWeight)>=600,i:"italic"===o.fontStyle,u:/underline/.test(o.textDecorationLine),strike:/line-through/.test(o.textDecorationLine),font:o.fontFamily.split(",")[0].replace(/["']/g,"").trim(),size:Math.round(.75*i*2)/2,color:Un(o.color)||void 0},c=a.textAlign,d={align:"center"===c||"right"===c||"justify"===c?c:"left",before:vr(a.marginTop),after:vr(a.marginBottom),...Number.isFinite(l)?{lineMultiple:Math.round(l/(parseFloat(a.fontSize)||i)*100)/100}:{}};se.current.set(e,{run:s,para:d});const u=n.style.tabSize;n.removeAttribute("style"),u&&(n.style.tabSize=u),n.querySelectorAll("[style]").forEach(e=>{for(const t of["font-family","font-size","font-weight","font-style","color","text-decoration","text-decoration-line"])e.style.removeProperty(t)}),de([...se.current].map(([e,t])=>`.docs-page [data-pstyle="${e.replace(/["\\]/g,"")}"]{${[K(t.run),j(t.para)].filter(Boolean).join(";")}}`).join("\n")),br(s.font?[s.font]:[]),ze.success(P.styleUpdated(t))}))(e.id,t)}]}})],Er=he(()=>Array.from(new Set([...m.defaultFont?[m.defaultFont]:[],...mr])),[m.defaultFont]),zr=[{type:"label",key:"word",label:P.wordFonts},...Er.map(e=>({key:e,label:dr("span",{style:{fontFamily:`"${e}"`},children:e}),onSelect:()=>fn(e)})),{type:"label",key:"web",label:P.webFonts},...A.filter(e=>!Er.includes(e)).map(e=>({key:e,label:dr("span",{style:{fontFamily:`"${e}"`},children:e}),onSelect:()=>fn(e)}))],Fr=fr.map(e=>({key:String(e),label:String(e),onSelect:()=>(e=>an(()=>{B.current=e,document.execCommand("styleWithCSS",!1,"false"),document.execCommand("fontSize",!1,"7"),document.execCommand("styleWithCSS",!1,"true");const t=E.current,n=[];if(t.querySelectorAll('font[size="7"]').forEach(t=>{const r=document.createElement("span");for(r.setAttribute("style",`font-size:${e}pt`);t.firstChild;)r.appendChild(t.firstChild);t.replaceWith(r),n.push(r)}),n.length){const e=document.getSelection();e?.setBaseAndExtent(n[0],0,n[n.length-1],n[n.length-1].childNodes.length)}}))(e)})),Or=E.current&&H.current?un():{},jr=[...pr.map(e=>({key:String(e),label:e.toFixed(1.15===e?2:1),onSelect:()=>{return t=e,an(()=>{for(const e of Bt())e.style.lineHeight=String(t)});var t}})),{type:"divider",key:"d1"},(Or.before??0)>0?{key:"before",label:P.removeSpaceBefore,onSelect:()=>dn("before",!1)}:{key:"before",label:P.addSpaceBefore,onSelect:()=>dn("before",!0)},(Or.after??0)>0?{key:"after",label:P.removeSpaceAfter,onSelect:()=>dn("after",!1)}:{key:"after",label:P.addSpaceAfter,onSelect:()=>dn("after",!0)},{type:"divider",key:"d2"},{key:"custom",label:P.customSpacing,onSelect:()=>{It(),Oe(un())}}],Hr=e=>e.preventDefault(),Dr="rounded px-2 py-0.5 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",Ir="inline-flex h-7 items-center gap-1 rounded px-2 text-xs text-ink-muted hover:bg-line-subtle hover:text-ink",Br=dr("div",{className:"mx-1 h-4 w-px bg-line"}),Ur=(e,t,n,r={})=>dr($e,{"aria-label":e,title:e,size:"sm",variant:"ghost",onMouseDown:Hr,onClick:n,disabled:r.disabled,...void 0!==r.pressed?{"aria-pressed":r.pressed}:{},children:t}),Wr=(e,t,n,r="")=>dr(Ne,{"aria-label":e,align:"start",items:n,triggerClassName:Ir,trigger:ur("span",{title:e,className:`flex items-center justify-between gap-1 ${r}`,children:[dr("span",{className:"truncate",children:t}),dr(xe,{name:"chevron-down",size:12})]})}),qr=(e,t,n,r,o)=>dr(Ae,{triggerLabel:e,align:"start",triggerClassName:"inline-flex h-7 w-7 flex-col items-center justify-center rounded text-ink-muted hover:bg-line-subtle hover:text-ink",trigger:ur(cr,{children:[t,dr("span",{className:"h-0.5 w-4 rounded-sm",style:{background:n}})]}),children:({close:t})=>dr(Ce,{label:e,value:"",presets:r,clearable:!0,dragWrites:"end",onChange:e=>{"hiliteColor"===o?ln("hiliteColor",e||"transparent"):ln("foreColor",e||Dn[0]),Gr(t=>({...t,[o]:e||("hiliteColor"===o?"var(--line)":"var(--ink)")})),t()}})}),[Kr,Gr]=we({foreColor:"var(--ink)",hiliteColor:"var(--line)"}),Vr=O(Y.page),Xr=Vr?{a4:"A4",a3:"A3",a5:"A5",letter:P.paperLetter,legal:P.paperLegal}[Vr]:P.custom,Qr=he(()=>{if(!m.lang)return"";try{return new Intl.DisplayNames(T?[T]:void 0,{type:"language"}).of(m.lang)??m.lang}catch{return m.lang}},[m.lang,T]),_r=Y.page.width/20,Jr=Y.page.top/20,Yr=rt.length,Zr=ee.headers[h(1,ee.titlePage,ee.evenOdd)],eo=ee.footers[h(Yr,ee.titlePage,ee.evenOdd)],to=[`.docs-page [data-section="nextPage"]::after{content:${JSON.stringify(P.sectionBreakNext)}}`,`.docs-page [data-section="continuous"]::after{content:${JSON.stringify(P.sectionBreakContinuous)}}`,...[2,3].map(e=>`.docs-page [data-section][data-cols="${e}"]::after{content:${JSON.stringify(`${P.sectionBreakNext} · ${P.columnsCount(e)}`)}}`),`.docs-page [data-section="continuous"][data-cols]::after{content:${JSON.stringify(P.sectionBreakContinuous)}}`,`.docs-page [data-toc]:empty::before{content:${JSON.stringify(P.noHeadings)}}`,ce].join("\n").replaceAll(".docs-page",`.docs-page[data-doc="${M}"]`),no=m.notices,ro=[no.comments&&P.noticeComments(no.comments),no.tracked&&P.noticeTracked(no.tracked),no.objects&&P.noticeObjects(no.objects),no.footnotes&&P.noticeFootnotes(no.footnotes)].filter(Boolean);return ur("div",{ref:R,className:"es-editor docs-frame",onKeyDown:e=>{const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase(),r=jt(e.target),o=()=>{e.preventDefault(),e.stopPropagation()};if(t&&!e.altKey){if("s"===n)return o(),void($?Qt():Qn());if("o"===n)return o(),void C();if("p"===n)return o(),void Yn();if("f"===n)return o(),void qn();if("k"===n)return o(),void An()}if(t&&e.altKey&&("f"===n||"KeyF"===e.code)&&r)return o(),void bn();if(t&&!e.altKey&&r){if("z"===n&&!e.shiftKey)return o(),void nn();if("z"===n&&e.shiftKey||"y"===n)return o(),void on();if("b"===n)return o(),void ln("bold");if("i"===n)return o(),void ln("italic");if("u"===n)return o(),void ln("underline");if("Enter"===e.key)return o(),void Ln()}if(r&&"Tab"===e.key&&!t&&!e.altKey){const t=document.getSelection(),n=t?.anchorNode?1===t.anchorNode.nodeType?t.anchorNode:t.anchorNode.parentElement:null,r=n?.closest("td,th");if(r)return o(),void((e,t)=>{const n=Array.from(e.closest("table").querySelectorAll("td,th")),r=n[n.indexOf(e)+(t?1:-1)];if(r){const e=document.createRange();e.selectNodeContents(r);const t=document.getSelection();t?.removeAllRanges(),t?.addRange(e)}else t&&an(()=>ir(e.closest("table"),e,!0))})(r,!e.shiftKey);if(n?.closest("li"))return o(),void kn(!e.shiftKey);if(!e.shiftKey)return o(),void ln("insertText","\t")}},children:[ur("style",{children:[i(m,M),to]}),dr("input",{ref:z,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&$n(Array.from(e.target.files)),e.target.value=""}}),dr(Ye,{onClose:N,fileMenu:gr,name:b,saveState:$?be(Vt.state,Gt.save):{tone:x?"off-unsaved":"off",label:x?P.noStoreEdited:P.noStoreClean},canUndo:Ze.undo,canRedo:Ze.redo,onUndo:nn,onRedo:on,exportControl:dr(Ne,{"aria-label":P.export,align:"end",items:Nr,triggerClassName:"docs-export-trigger",trigger:ur(cr,{children:[dr(xe,{name:"download",size:16}),P.export]})})}),lt&&ur("div",{className:"docs-conflict",role:"alert",children:[dr("span",{children:P.conflict}),dr(ke,{variant:"secondary",onClick:L,children:P.reload})]}),ur("div",{className:"flex shrink-0 flex-wrap items-center gap-0.5 border-b border-line bg-surface-sunken px-2 py-1",children:[dr(Ne,{trigger:P.menuInsert,items:Lr,align:"start",triggerClassName:Dr}),dr(Ae,{open:ht,onOpenChange:gt,align:"start",triggerLabel:P.table,triggerClassName:"h-5 w-0 overflow-hidden",trigger:dr("span",{}),children:ur("div",{className:"p-1",children:[dr("div",{className:"mb-1 text-xs text-ink-muted",children:wt.rows?P.tableSize(wt.cols,wt.rows):P.table}),dr("div",{className:"grid gap-0.5",style:{gridTemplateColumns:"repeat(8, 1fr)"},onMouseLeave:()=>bt({rows:0,cols:0}),children:Array.from({length:48},(e,t)=>{const n=Math.floor(t/8)+1,r=t%8+1,o=n<=wt.rows&&r<=wt.cols;return dr("button",{type:"button","aria-label":P.tableSize(r,n),onMouseEnter:()=>bt({rows:n,cols:r}),onFocus:()=>bt({rows:n,cols:r}),onClick:()=>Pn(n,r),className:"h-4 w-4 rounded-sm border "+(o?"border-accent-fill bg-accent-tint-strong":"border-line bg-surface")},t)})})]})}),dr(Ne,{trigger:P.menuLayout,items:Tr,align:"start",triggerClassName:Dr}),Br,Ur(P.print,dr(xe,{name:"print",size:16}),Yn),Ur(P.find,dr(xe,{name:"search",size:16}),()=>Ct?Wn():qn(),{pressed:Ct}),Br,Wr(P.paragraphStyle,(e=>{if(!e)return P.styleNormal;const t=m.styles.find(t=>t.id===e);return t?Mr[t.name]??t.name:e})(_e.styleId),Rr,"w-20"),Wr(P.font,_e.font||m.defaultFont||"Calibri",zr,"w-20"),Wr(P.fontSize,_e.size??m.defaultSize??11,Fr),Br,Ur(P.bold,dr(xe,{name:"bold",size:16}),()=>ln("bold"),{pressed:_e.bold}),Ur(P.italic,dr(xe,{name:"italic",size:16}),()=>ln("italic"),{pressed:_e.italic}),Ur(P.underline,dr(xe,{name:"underline",size:16}),()=>ln("underline"),{pressed:_e.underline}),Ur(P.strikethrough,dr(xe,{name:"strike",size:16}),()=>ln("strikeThrough"),{pressed:_e.strike}),Ur(P.superscript,dr(xe,{name:"superscript",size:16}),()=>ln("superscript"),{pressed:_e.sup}),Ur(P.subscript,dr(xe,{name:"subscript",size:16}),()=>ln("subscript"),{pressed:_e.sub}),qr(P.textColor,dr(xe,{name:"text-color",size:14}),Kr.foreColor,Dn,"foreColor"),qr(P.highlight,dr(xe,{name:"palette",size:14}),Kr.hiliteColor,In,"hiliteColor"),Ur(P.paintFormat,dr(xe,{name:"paint-brush",size:16}),()=>{if(Ie.current)return Ie.current=null,void We(!1);It(),Ie.current=(()=>{const e=document.getSelection();if(!e?.anchorNode||!jt(e.anchorNode))return null;const t=1===e.anchorNode.nodeType?e.anchorNode:e.anchorNode.parentElement,n=getComputedStyle(t),r=t.closest(kr),o=e=>{try{return document.queryCommandState(e)}catch{return!1}};return{run:{b:o("bold"),i:o("italic"),u:o("underline"),strike:o("strikeThrough"),font:n.fontFamily.split(",")[0].replace(/["']/g,"").trim(),size:Math.round(.75*parseFloat(n.fontSize)*2)/2,color:Un(n.color),hl:Un(n.backgroundColor)||void 0},styleId:r?.getAttribute("data-pstyle")??null,tag:r?.tagName??"P"}})(),We(!!Ie.current),Ie.current&&ze.info(P.paintFormatHint)},{pressed:Be}),Ur(P.clearFormatting,dr(xe,{name:"clear-marks",size:16}),()=>an(()=>{document.execCommand("removeFormat");for(const e of Bt())e.style.removeProperty("text-align"),e.style.removeProperty("line-height"),e.style.removeProperty("margin-left")})),Br,Ur(P.bulletedList,dr(xe,{name:"list",size:16}),()=>sn("insertUnorderedList"),{pressed:_e.ul}),Ur(P.numberedList,dr(xe,{name:"numbered-list",size:16}),()=>sn("insertOrderedList"),{pressed:_e.ol}),Ur(P.checklist,dr(xe,{name:"checkbox",size:16}),()=>an(()=>{const e=E.current;if(!e)return;const t=Bt(),n=t.length>0&&t.every(e=>e.closest("ul[data-checklist]")),r=document.getSelection(),o=r?.anchorNode??null,a=r?.anchorOffset??0;if(n)document.execCommand("insertUnorderedList");else{const n=new Set(t.map(e=>e.closest("ul,ol")).filter(Boolean));n.size&&![...n].some(e=>"UL"!==e.tagName)||document.execCommand("insertUnorderedList");const r=(document.getSelection()?.anchorNode?.parentElement??o?.parentElement)?.closest("ul");e.querySelectorAll("p > ul").forEach(e=>{const t=e.parentElement;Array.from(t.childNodes).some(t=>t!==e&&(1===t.nodeType||(t.nodeValue??"").trim()))||t.replaceWith(e)});for(const e of[r,...n])e&&"UL"===e.tagName&&(e.setAttribute("data-checklist",""),e.removeAttribute("data-num-id"))}o&&o.isConnected&&r?.collapse(o,Math.min(a,3===o.nodeType?(o.nodeValue??"").length:o.childNodes.length))})),Ur(P.decreaseIndent,dr(xe,{name:"chevron-double-left",size:16}),()=>kn(!1)),Ur(P.increaseIndent,dr(xe,{name:"chevron-double-right",size:16}),()=>kn(!0)),Br,Ur(P.alignLeft,dr(xe,{name:"align-left",size:16}),()=>Nn("left"),{pressed:"left"===_e.align}),Ur(P.alignCenter,dr(xe,{name:"align-center",size:16}),()=>Nn("center"),{pressed:"center"===_e.align}),Ur(P.alignRight,dr(xe,{name:"align-right",size:16}),()=>Nn("right"),{pressed:"right"===_e.align}),Ur(P.justify,dr(xe,{name:"align-justify",size:16}),()=>Nn("justify"),{pressed:"justify"===_e.align}),dr(Ne,{"aria-label":P.paragraphSpacing,align:"start",items:jr,triggerClassName:Ir,trigger:ur("span",{title:P.paragraphSpacing,className:"flex items-center gap-0.5",children:[dr(xe,{name:"line-spacing",size:16}),dr(xe,{name:"chevron-down",size:12})]})})]}),ft&&ro.length>0&&ur("div",{role:"status",className:"flex shrink-0 items-center gap-2 border-b border-status-warning-line bg-status-warning-soft px-3 py-1 text-xs text-status-warning-soft-ink",children:[dr(xe,{name:"info",size:14}),dr("span",{className:"min-w-0 flex-1",children:P.noticeLead(ro)}),dr($e,{size:"sm",variant:"ghost",ink:"inherit","aria-label":P.dismiss,title:P.dismiss,onClick:()=>pt(!1),children:dr(xe,{name:"close",size:14})})]}),Ct&&dr(zn,{query:Nt,replacement:At,matchCase:Pt,current:Mt,total:Et,onQuery:e=>{$t(e),En(e,Pt,0)},onReplacement:Lt,onMatchCase:e=>{Tt(e),En(Nt,e,0)},onStep:e=>{const t=Ft.current.length;if(!t)return;const n=(Mt+(e?1:-1)+t)%t;Rt(n),Mn(n,!0)},onReplace:()=>{const e=Ft.current[Mt];e&&(F.current.record(Zt()),l(e,At),Yt(),En(Nt,Pt,Mt))},onReplaceAll:()=>{const e=Ft.current;if(e.length){F.current.record(Zt());for(let t=e.length-1;t>=0;t--)l(e[t],At);Yt(),ze.success(P.replacedCount(e.length)),En(Nt,Pt,0)}},onClose:Wn}),ur("div",{className:"docs-body",children:[ur("div",{className:"docs-centre",children:[ur("div",{className:"min-h-0 flex-1 overflow-auto bg-surface-sunken px-6 pb-6",children:[dr("div",{className:"docs-ruler-row",children:dr(Cn,{pageWidth:_r,marginLeft:Y.page.left/20,marginRight:Y.page.right/20,zoom:ct,value:je,onChange:e=>{He(e),It(),De.current?clearTimeout(De.current):F.current.record(Zt()),De.current=setTimeout(()=>{De.current=null},500);for(const t of Bt()){"LI"!==t.tagName&&(t.style.marginLeft=e.indentLeft?`${e.indentLeft}pt`:"",t.style.textIndent=e.firstLine?`${e.firstLine}pt`:""),t.style.marginRight=e.indentRight?`${e.indentRight}pt`:"",e.tabs.length?t.setAttribute("data-tabs",X(e.tabs)):t.hasAttribute("data-tabs")&&t.setAttribute("data-tabs","");const n=V({indentLeft:e.indentLeft,tabs:e.tabs});t.style.tabSize=n?n.split(":")[1]:""}Yt()}})}),ur("div",{className:"docs-sheet relative mx-auto shadow",style:{width:`${_r}pt`,zoom:ct/100,minHeight:Y.page.height/20+"pt"},children:[dr("div",{ref:E,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!0,lang:m.lang,role:"textbox","aria-multiline":"true","aria-label":f,"data-doc":M,onPaste:e=>{(async e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e),n=e.clipboardData?.getData("text/html");if(n){e.preventDefault();const t=document.createElement("div");t.innerHTML=s(n);for(const e of Array.from(t.querySelectorAll("img"))){const t=e.getAttribute("src")??"";if(t.startsWith("blob:")&&!p.has(t))try{const e=await(await fetch(t)).blob();p.set(t,{bytes:new Uint8Array(await e.arrayBuffer()),mime:e.type})}catch{e.remove()}}return void ln("insertHTML",t.innerHTML)}t.length&&(e.preventDefault(),$n(t))})(e)},onMouseUp:mn,onKeyUp:e=>{e.shiftKey&&mn()},onClick:e=>{const t=e.target,n=t.closest("[data-toc]");if(n&&jt(n)){const r=t.closest("a"),o=r&&(e.metaKey||e.ctrlKey)?xn(r.getAttribute("data-anchor")??(r.getAttribute("href")??"").slice(1)):null;return o?void o.scrollIntoView({block:"start"}):void Qe({x:e.clientX,y:e.clientY,el:n})}if("LI"===t.tagName&&t.parentElement?.hasAttribute("data-checklist")&&e.nativeEvent.offsetX<0)return void an(()=>{t.toggleAttribute("data-checked")});if("IMG"===t.tagName&&null===t.closest('[contenteditable="false"]')&&!t.getAttribute("contenteditable"))return e.preventDefault(),void vt({x:e.clientX,y:e.clientY,el:t});const r=t.closest("a");if(r&&(e.metaKey||e.ctrlKey)){const e=r.getAttribute("href")??"";e.startsWith("#")?xn(e.slice(1))?.scrollIntoView({block:"start"}):Cr.test(e)&&window.open(e,"_blank","noopener,noreferrer")}},onContextMenu:e=>{const t=e.target.closest?.("td,th");t&&!e.shiftKey&&!t.closest("[data-locked]")&&jt(t)&&(e.preventDefault(),kt({x:e.clientX,y:e.clientY,cell:t}))},className:"docs-page",style:{paddingTop:`${Jr}pt`,paddingRight:Y.page.right/20+"pt",paddingBottom:Y.page.bottom/20+"pt",paddingLeft:Y.page.left/20+"pt",minHeight:Y.page.height/20+"pt",boxSizing:"border-box",...oe>1&&!ie?{columnCount:oe,columnGap:"36pt"}:{},...Be?{cursor:"copy"}:{}}}),dr("button",{type:"button",className:"docs-hf-preview docs-page","data-doc":M,title:P.headersFootersHint,"aria-label":P.headersFooters,onClick:()=>re(!0),"data-hint":P.headersFootersHint,style:{top:Y.page.header/20+"pt",left:Y.page.left/20+"pt",right:Y.page.right/20+"pt",minHeight:Math.max(Y.page.top-Y.page.header-120,240)/20+"pt",maxHeight:Math.max(Y.page.top-Y.page.header,240)/20+"pt"},dangerouslySetInnerHTML:{__html:yr(Zr,1,Yr)}}),qe.length>0&&dr("section",{className:"docs-footnotes","aria-label":P.footnotes,style:{marginLeft:Y.page.left/20+"pt",marginRight:Y.page.right/20+"pt",marginBottom:Y.page.bottom/20+"pt"},children:qe.map((e,t)=>{const n=m.footnotes.get(e);return ur("div",{className:"docs-footnote",children:[dr("sup",{children:t+1}),!1===n?.editable?dr("span",{title:P.footnoteLocked,children:n.text}):dr("input",{"data-note-input":e,value:n?.text??"",placeholder:P.footnotePlaceholder,"aria-label":`${P.footnote} ${t+1}`,onChange:t=>((e,t)=>{const n=m.footnotes.get(e);n?.editable&&(m.footnotes.set(e,{...n,text:t}),Ge(e=>e+1),Yt())})(e,t.target.value)})]},e)})}),rt.slice(1).map((e,t)=>dr("div",{className:"docs-sheet-line pointer-events-none absolute left-0 right-0 border-t border-dashed","aria-hidden":"true",style:{top:`calc(${Jr}pt + ${e}px)`},children:dr("span",{className:"docs-sheet absolute right-1 -top-2 px-1 text-2xs",children:P.pageLabel(t+2)})},e)),dr("button",{type:"button",className:"docs-hf-preview docs-page","data-doc":M,title:P.headersFootersHint,"aria-label":P.headersFooters,onClick:()=>re(!0),"data-hint":P.headersFootersHint,style:{bottom:Y.page.footer/20+"pt",left:Y.page.left/20+"pt",right:Y.page.right/20+"pt",minHeight:Math.max(Y.page.bottom-Y.page.footer-120,240)/20+"pt",maxHeight:Math.max(Y.page.bottom-Y.page.footer,240)/20+"pt"},dangerouslySetInnerHTML:{__html:yr(eo,Yr,Yr)}})]})]}),ur("div",{className:"flex shrink-0 items-center gap-2 border-t border-line bg-surface-sunken px-3 py-1 text-xs text-ink-muted",children:[dr("span",{children:P.pageOf(Math.min(tt.pageNow,rt.length),rt.length)}),dr("span",{children:P.wordCount(tt.words)}),dr("span",{children:Xr}),Qr&&dr("span",{children:Qr}),ur("span",{className:"ml-auto flex items-center gap-1",children:[dr(ke,{size:"sm",variant:"ghost","aria-label":P.zoomOut,onClick:()=>dt(e=>[...xr].reverse().find(t=>t<e)??e),children:"−"}),ur("span",{className:"w-9 text-center tabular-nums",children:[ct,"%"]}),dr(ke,{size:"sm",variant:"ghost","aria-label":P.zoomIn,onClick:()=>dt(e=>xr.find(t=>t>e)??e),children:"+"})]})]})]}),dr(Ue,{page:Y.page,onPage:e=>{Z(t=>({...t,page:e})),Yt()},onMorePageSetup:()=>mt(!0),colour:_e.color,onColour:e=>{Je(t=>({...t,color:e})),Gr(t=>({...t,foreColor:e})),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>{J.current=null,ln("foreColor",e)},150)},outline:at,onHeading:e=>{const t=E.current;t&&Hn(t)[e]?.scrollIntoView({block:"start"})}})]}),ut&&dr(Jn,{value:Y,onClose:()=>mt(!1),onApply:e=>{Z(e),mt(!1),Yt()}}),ne&&dr(rn,{value:ee,scope:M,locked:{headers:Object.fromEntries(wr.map(e=>[e,!m.headers[e].editable])),footers:Object.fromEntries(wr.map(e=>[e,!m.footers[e].editable]))},onClose:()=>re(!1),onApply:e=>{te(e),re(!1),Yt()}}),ue&&dr(gn,{value:ue,onClose:()=>Oe(null),onApply:e=>{var t;Oe(null),t=e,an(()=>{for(const e of Bt())void 0!==t.lineMultiple&&(e.style.lineHeight=String(t.lineMultiple)),void 0!==t.before&&(e.style.marginTop=`${t.before}pt`),void 0!==t.after&&(e.style.marginBottom=`${t.after}pt`),void 0!==t.indentRight&&(e.style.marginRight=t.indentRight?`${t.indentRight}pt`:""),"LI"!==e.tagName&&(void 0!==t.indentLeft&&(e.style.marginLeft=t.indentLeft?`${t.indentLeft}pt`:""),void 0!==t.firstLine&&(e.style.textIndent=t.firstLine?`${t.firstLine}pt`:""))})}}),Xe&&ur(Le,{minWidth:180,portal:!0,style:{position:"fixed",left:Xe.x,top:Xe.y},onClose:()=>Qe(null),children:[dr(Te,{onClick:()=>{var e;e=Xe.el,an(()=>{e.innerHTML=wn()}),Qe(null)},children:P.tocRefresh}),dr(Pe,{}),dr(Te,{danger:!0,onClick:()=>{const e=Xe.el;an(()=>{e.remove()}),Qe(null)},children:P.tocDelete})]}),yt&&ur(Le,{minWidth:150,portal:!0,style:{position:"fixed",left:yt.x,top:yt.y},onClose:()=>vt(null),children:[dr(Me,{children:P.imageWidth}),dr(Te,{onClick:()=>Tn(.25),children:"25%"}),dr(Te,{onClick:()=>Tn(.5),children:"50%"}),dr(Te,{onClick:()=>Tn(.75),children:"75%"}),dr(Te,{onClick:()=>Tn(1),children:"100%"}),dr(Te,{onClick:()=>Tn(null),children:P.imageOriginalSize}),dr(Pe,{}),dr(Te,{danger:!0,onClick:()=>{if(!yt)return;const e=yt.el;an(()=>{e.remove()}),vt(null)},children:P.imageRemove})]}),xt&&dr(Se,{at:{x:xt.x,y:xt.y},owner:xt.cell,onClose:()=>kt(null),items:(e=>{const t=e.closest("table"),n=(e,t,n,r={})=>({key:e,label:t,onSelect:()=>an(n),...r}),r=(e=>{const t=H.current;return t?Array.from(e.querySelectorAll("td,th")).filter(n=>n.closest("table")===e&&t.intersectsNode(n)):[]})(t);return[n("above",P.rowAbove,()=>ir(t,e,!1)),n("below",P.rowBelow,()=>ir(t,e,!0)),n("left",P.columnLeft,()=>lr(t,e,!1)),n("right",P.columnRight,()=>lr(t,e,!0)),{type:"divider",key:"d1"},n("merge",P.mergeCells,()=>{(function(e,t){if(t.length<2)return!1;const n=rr(e);let r=1/0,o=1/0,a=-1,i=-1;for(const e of t){const t=or(n,e);if(!t)return!1;r=Math.min(r,t.row),o=Math.min(o,t.col),a=Math.max(a,t.row+nr(e,"rowspan")-1),i=Math.max(i,t.col+nr(e,"colspan")-1)}const l=new Set;for(let e=r;e<=a;e++)for(let t=o;t<=i;t++){const r=n.slots[e]?.[t];r&&l.add(r)}for(const e of l){const t=or(n,e);if(t.row<r||t.col<o||t.row+nr(e,"rowspan")-1>a||t.col+nr(e,"colspan")-1>i)return!1}const s=n.slots[r][o];for(const e of l)if(e!==s){if((e.textContent??"").trim())for(;e.firstChild;)s.appendChild(e.firstChild);e.remove()}return s.setAttribute("colspan",String(i-o+1)),s.setAttribute("rowspan",String(a-r+1)),i===o&&s.removeAttribute("colspan"),a===r&&s.removeAttribute("rowspan"),!0})(t,r)||ze.error(P.mergeFailed)},{disabled:r.length<2}),{type:"submenu",key:"shade",label:P.cellShading,items:[...Bn.map(t=>({key:t,label:ur("span",{className:"flex items-center gap-2",children:[dr("span",{className:"h-3 w-5 rounded-sm border border-line",style:{background:t}}),t.toUpperCase()]}),onSelect:()=>an(()=>{for(const n of r.length?r:[e])n.style.backgroundColor=t})})),{key:"none",label:P.noColor,onSelect:()=>an(()=>{for(const t of r.length?r:[e])t.style.removeProperty("background-color")})}]},{type:"divider",key:"d2"},n("delRow",P.deleteRow,()=>{!function(e,t){const n=rr(e),r=or(n,t);if(!r)return!1;const o=tr(e);if(1===o.length)return e.remove(),!1;const a=new Set;for(let e=0;e<n.cols;e++){const t=n.slots[r.row][e];if(!t||a.has(t))continue;a.add(t);const i=nr(t,"rowspan");if(1!==i)if(t.parentElement===o[r.row]){const a=o[r.row+1],l=n.slots[r.row+1].slice(e+nr(t,"colspan")).find(e=>e.parentElement===a);t.setAttribute("rowspan",String(i-1)),a.insertBefore(t,l??null)}else t.setAttribute("rowspan",String(i-1))}o[r.row].remove()}(t,e)}),n("delCol",P.deleteColumn,()=>{!function(e,t){const n=rr(e),r=or(n,t);if(!r)return!1;if(1===n.cols)return e.remove(),!1;const o=new Set;for(const e of n.slots){const t=e[r.col];if(!t||o.has(t))continue;o.add(t);const n=nr(t,"colspan");n>1?t.setAttribute("colspan",String(n-1)):t.remove()}sr(e,n.cols-1,null,r.col)}(t,e)}),n("delTable",P.deleteTable,()=>{t.remove()},{danger:!0})]})(xt.cell)})]})}function $r({label:e,hint:t}){return ur("span",{className:"flex w-full items-center justify-between gap-4",children:[dr("span",{children:e}),dr("span",{className:"text-2xs text-ink-faint",children:t})]})}import{useEffect as Ar,useRef as Lr,useState as Pr}from"react";import{Icon as Tr}from"efficient-shell/icons";import{Button as Mr,IconButton as Rr,registerModalEscapeInterceptor as Er,toast as zr}from"efficient-shell/ui";var Fr={LF:"\n",CRLF:"\r\n",CR:"\r"};function Or(e,t){let n=1,r=-1;for(let o=e.indexOf("\n");o>=0&&o<t;o=e.indexOf("\n",o+1))n++,r=o;return{line:n,col:t-r}}function jr(e){let t=1;for(let n=e.indexOf("\n");n>=0;n=e.indexOf("\n",n+1))t++;return t}import{jsx as Hr,jsxs as Dr}from"react/jsx-runtime";function Ir({filename:e,decoded:t,bytes:n,fileEntries:r,title:o,dirty:a,onDirty:i,onOpenFile:l,onClose:s}){const c=u(),d=Lr(null),m=Lr(null),f=Lr(t.text),p=Lr(!1),[h,g]=Pr(!0),[w,b]=Pr(!1),[y,v]=Pr({line:1,col:1,lines:jr(t.text)}),[x,k]=Pr(!1),[C,S]=Pr(""),[N,$]=Pr(""),[A,L]=Pr(!1),[P,T]=Pr(0),[M,R]=Pr([]),E=()=>m.current?.value??"",z=Lr(null),[F,O]=Pr(0),j=()=>{z.current&&m.current&&(z.current.scrollTop=m.current.scrollTop,z.current.scrollLeft=m.current.scrollLeft)};Ar(()=>{const e=z.current?.querySelector("[data-current]"),t=m.current;if(!e||!t)return;const n=e.offsetTop-t.clientHeight/3;(e.offsetTop<t.scrollTop||e.offsetTop>t.scrollTop+t.clientHeight-42)&&(t.scrollTop=Math.max(0,n)),h||(t.scrollLeft=Math.max(0,e.offsetLeft-t.clientWidth/2)),j()},[F,P,M,h]);const H=()=>{const e=m.current;e&&v({...Or(e.value,e.selectionStart),lines:jr(e.value)})},D=(e=C,t=A)=>{const n=function(e,t,n){if(!t)return[];const r=n?e:e.toLowerCase(),o=n?t:t.toLowerCase(),a=r.length===e.length?r:e,i=[];for(let e=a.indexOf(o);e>=0;e=a.indexOf(o,e+Math.max(o.length,1)))i.push(e);return i}(E(),e,t);return R(n),n},I=(e,t,n=C)=>{const r=m.current;if(!r||!e.length)return;const o=(t%e.length+e.length)%e.length;T(o),r.setSelectionRange(e[o],e[o]+n.length),O(e=>e+1)},B=()=>{Sn(p.current?function(e,t,n){const r=e.replace(/\n/g,Fr[n]);if("utf-16le"===t||"utf-16be"===t){const e=new Uint8Array(2+2*r.length),n=new DataView(e.buffer),o="utf-16le"===t;n.setUint16(0,65279,o);for(let e=0;e<r.length;e++)n.setUint16(2+2*e,r.charCodeAt(e),o);return e}const o=(new TextEncoder).encode(r);if("utf-8-bom"!==t)return o;const a=new Uint8Array(o.length+3);return a.set([239,187,191]),a.set(o,3),a}(E(),t.encoding,t.eol):n,e,"text/plain"),p.current&&"windows-1252"===t.encoding&&zr.info(c.savedAsUtf8),f.current=E(),i(!1)},U=()=>{p.current=!0,b(!0),i(E()!==f.current),H(),x&&D()},W=e=>{document.execCommand("insertText",!1,e)||m.current?.setRangeText(e,m.current.selectionStart,m.current.selectionEnd,"end"),U()},q=e=>{m.current?.focus(),document.execCommand(e)},K=()=>{k(!1),m.current?.focus()};Ar(()=>{m.current?.focus(),m.current?.setSelectionRange(0,0)},[]);const G=Lr(x);G.current=x,Ar(()=>Er(()=>!(!G.current||!d.current?.contains(document.activeElement))&&(K(),!0)),[]);const V=[...r,{type:"divider",key:"d1"},{key:"save",label:c.saveKeepType,onSelect:B}],X=a?c.noStoreEdited:c.noStoreClean;return Dr("div",{ref:d,className:"es-editor docs-frame",onKeyDown:e=>{const t=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();if(t&&"s"===n)e.preventDefault(),B();else if(t&&"o"===n)e.preventDefault(),l();else if(t&&"f"===n){e.preventDefault(),k(!0);const t=m.current,n=t?t.value.slice(t.selectionStart,t.selectionEnd):"";n&&!n.includes("\n")&&(S(n),D(n))}else"Tab"!==e.key||t||e.shiftKey||e.target!==m.current||(e.preventDefault(),W("\t"))},children:[Hr(Ye,{onClose:s,fileMenu:V,name:o,saveState:{tone:a?"off-unsaved":"off",label:X},canUndo:w,canRedo:w,onUndo:()=>q("undo"),onRedo:()=>q("redo"),exportControl:Hr(Mr,{variant:"secondary",leftIcon:Hr(Tr,{name:"download",size:16}),onClick:B,children:c.export})}),Dr("div",{className:"flex shrink-0 flex-wrap items-center gap-0.5 border-b border-line bg-surface-sunken px-2 py-1",children:[Hr(Rr,{size:"sm",variant:"ghost","aria-label":c.find,title:c.find,"aria-pressed":x,onClick:()=>k(e=>!e),children:Hr(Tr,{name:"search",size:16})}),Hr(Rr,{size:"sm",variant:"ghost","aria-label":c.wrapLines,title:c.wrapLines,"aria-pressed":h,onClick:()=>g(e=>!e),children:Hr(Tr,{name:"wrap",size:16})})]}),x&&Hr(zn,{query:C,replacement:N,matchCase:A,current:P,total:M.length,onQuery:e=>{S(e);const t=D(e);T(0),I(t,0,e)},onReplacement:$,onMatchCase:e=>{L(e);const t=D(C,e);T(0),I(t,0)},onStep:e=>I(M,P+(e?1:-1)),onReplace:()=>{const e=m.current;if(!e||!M.length)return;e.focus(),e.setSelectionRange(M[P],M[P]+C.length),W(N);const t=D();I(t,P)},onReplaceAll:()=>{const e=m.current;if(!e||!M.length)return;const t=M.length;e.focus();for(let t=M.length-1;t>=0;t--)e.setSelectionRange(M[t],M[t]+C.length),W(N);D(),T(0),zr.success(c.replacedCount(t))},onClose:K}),Dr("div",{className:"relative min-h-0 flex-1 bg-surface",children:[x&&C&&M.length>0&&M.length<=2e3&&Hr("div",{ref:z,"aria-hidden":"true",style:{lineHeight:"21px",scrollbarGutter:"stable"},className:"pointer-events-none absolute inset-0 overflow-hidden p-4 font-mono text-sm text-transparent "+(h?"whitespace-pre-wrap break-words":"whitespace-pre"),children:(()=>{const e=E(),t=[];let n=0;return M.forEach((r,o)=>{t.push(e.slice(n,r)),n=r+C.length,t.push(Hr("mark",{...o===P?{"data-current":""}:{},className:"rounded-sm text-transparent "+(o===P?"bg-status-warning-line":"bg-status-warning-soft"),children:e.slice(r,n)},r))}),t.push(e.slice(n)),t})()}),Hr("textarea",{ref:m,defaultValue:t.text,"aria-label":e,spellCheck:!1,wrap:h?"soft":"off",onInput:U,onSelect:H,onKeyUp:H,onClick:H,onScroll:j,style:{lineHeight:"21px",scrollbarGutter:"stable"},className:"absolute inset-0 h-full w-full resize-none bg-transparent p-4 font-mono text-sm text-ink outline-none "+(h?"whitespace-pre-wrap break-words":"overflow-x-auto whitespace-pre")})]}),Dr("div",{className:"flex shrink-0 items-center gap-2 border-t border-line bg-surface-sunken px-3 py-1 text-xs text-ink-muted",children:[Hr("span",{children:e}),Hr("span",{children:c.lineColumn(y.line,y.col)}),Hr("span",{children:c.lineCount(y.lines)}),Hr("span",{children:t.eol})]})]})}import{jsx as Br,jsxs as Ur}from"react/jsx-runtime";var Wr=new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),qr=["docx"],Kr=`${Array.from(Wr,e=>`.${e}`).join(",")},.docx,text/*`,Gr=/^<!doctype html><meta charset="utf-8"><title>[^<]*<\/title>(?!<body style="font-family:ui-monospace)/,Vr=()=>"undefined"!=typeof navigator&&navigator.language||"en-AU";function Xr({value:e,onRename:t}){const n=u(),[r,o]=re(e);return te(()=>o(e),[e]),Br("div",{className:"docs-title",children:Br(se,{"aria-label":n.documentName,value:r,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},onBlur:()=>{const n=r.trim();o(n||e),n&&n!==e&&t(n)}})})}function Qr({documentId:e,onClose:t}){const n=u(),{store:r,canCreate:o=!0,canDelete:a=!0,chooseFile:i}=d(),[l,s]=re(null),[c,p]=re(null);if(!r||e)return Br(_r,{documentId:e,onClose:t});if(l)return Br(_r,{documentId:l.id,initialFile:l.file,onClose:()=>s(null)},l.key);return Br(m,{words:{windowTitle:n.filesHeading,heading:n.filesHeading,newFile:n.newFile,emptyTitle:n.filesEmptyTitle,emptyBody:n.filesEmptyBody,deleteConfirm:n.deleteConfirm,createFailed:n.createFailed,deleteFailed:n.deleteFailed},files:n.files,list:r.list,create:()=>r.create(n.untitled),rename:r.rename,remove:r.remove,canCreate:o,canDelete:a,accept:Kr,choose:i&&{run:i,request:{title:n.files.choosing(n.fileKind,n.filesHeading),extensions:qr}},onOpen:e=>s({key:Date.now(),id:e}),onOpenFile:(e,t)=>{Z(e.name,qr)?c||(p(n.files.opening(e.name)),f(r,e).then(async r=>{const o=await ee(t,r.id);ue.success(n.files.savedCopy(r.title,e.name,o?t?.location:void 0)),s({key:Date.now(),id:r.id})}).catch(()=>ue.error(n.files.openFailed(e.name))).finally(()=>p(null))):s({key:Date.now(),file:e})},busy:c})}function _r({documentId:e,onClose:t,initialFile:n}){const r=u(),{store:o}=d(),a=o&&e?e:null,i=ne([]),l=ne(0),c=ne(null),m={textBox:r.objectTextBox,chart:r.objectChart,diagram:r.objectDiagram,equation:r.objectEquation,picture:r.objectPicture,object:r.objectOther,contents:r.objectField},f=e=>({labels:m,imageUrl:(t,n)=>{const r=URL.createObjectURL(new Blob([t],{type:n}));return i.current.push(r),e.set(r,{bytes:t,mime:n}),r}}),p=e=>{const t=new Map;return{key:++l.current,kind:"rich",filename:e,images:t,doc:b(R(Vr()),null,f(t))}},[h,g]=re(()=>a?null:p(r.untitled)),[v,x]=re(!1),[k,C]=re(0),[S,N]=re(!1),[$,A]=re(!1),[L,P]=re(!1);ae(L),te(()=>()=>{i.current.forEach(e=>URL.revokeObjectURL(e))},[]),te(()=>{if(!o||!a)return;let e=!0;return x(!1),(async()=>{const t=await o.get(a),n=new Map,r=t.bytes?.length?await w(t.bytes,f(n)):b(R(Vr()),null,f(n));e&&T({key:++l.current,kind:"rich",doc:r,images:n,filename:t.title,stored:{id:t.id,version:t.version}})})().catch(()=>{e&&x(!0)}),()=>{e=!1}},[o,a,k]);const T=e=>{const t=i.current;if(i.current=[],"rich"===e.kind)for(const t of e.images.keys())i.current.push(t);g(e),P(!1),setTimeout(()=>t.filter(e=>!i.current.includes(e)).forEach(e=>URL.revokeObjectURL(e)),0)},M=async()=>!L||de({title:r.discardTitle(h?.filename??""),message:r.discardMessage,confirmLabel:r.discard,cancelLabel:r.keepEditing}),E=async e=>{if(!await M())return;const t=(e.name.split(".").pop()||"").toLowerCase();N(!0);try{if("docx"===t){const t=new Map,n=new Uint8Array(await e.arrayBuffer());try{const r=await w(n,f(t));T({key:++l.current,kind:"rich",doc:r,filename:e.name,images:t})}catch{ue.error(r.cannotRead(e.name))}}else if("doc"===t)ue.error(r.legacyDoc);else if(Wr.has(t)||e.type.startsWith("text/")){const n=new Uint8Array(await e.arrayBuffer()),o=function(e){let t,n="utf-8";if(239===e[0]&&187===e[1]&&191===e[2])n="utf-8-bom",t=new TextDecoder("utf-8").decode(e.subarray(3));else if(255===e[0]&&254===e[1])n="utf-16le",t=new TextDecoder("utf-16le").decode(e.subarray(2));else if(254===e[0]&&255===e[1])n="utf-16be",t=new TextDecoder("utf-16be").decode(e.subarray(2));else try{t=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{n="windows-1252",t=new TextDecoder("windows-1252").decode(e)}const r=t.match(/\r\n/g)?.length??0,o=(t.match(/\n/g)?.length??0)-r,a=(t.match(/\r/g)?.length??0)-r,i=r>o&&r>=a?"CRLF":a>o?"CR":"LF";return{text:t.replace(/\r\n?/g,"\n"),encoding:n,eol:i}}(n);if("html"!==t&&"htm"!==t||!Gr.test(o.text))T({key:++l.current,kind:"text",decoded:o,bytes:n,filename:e.name});else{const t=new Map,n=b(R(Vr()),null,f(t));n.html=s(o.text)||n.html,y(n),T({key:++l.current,kind:"rich",doc:n,images:t,filename:e.name.replace(/\.[^.]+$/,".docx"),imported:!0}),ue.info(r.openedOldSave)}}else ue.error(r.unsupported(t))}finally{N(!1)}};te(()=>{n&&E(n)},[]);const z=async()=>{await M()&&(P(!1),c.current?.click())},F="rich"===h?.kind&&!!h.stored,O=()=>ue.info(r.openFromFiles),j=[{key:"new",label:r.newDocument,onSelect:()=>{(async()=>{await M()&&T(p(r.untitled))})()}},{key:"open",label:Ur("span",{className:"flex w-full items-center justify-between gap-4",children:[Br("span",{children:r.open}),Br("span",{className:"text-2xs text-ink-faint",children:"⌘O"})]}),onSelect:()=>{z()}}],H=h&&Br(Xr,{value:h.filename,onRename:e=>{const t=h?.filename??e;g(t=>t?{...t,filename:e}:t),o&&"rich"===h?.kind&&h.stored&&o.rename(h.stored.id,e).catch(()=>{ue.error(r.renameFailed),g(e=>e?{...e,filename:t}:e)})}});return Ur("div",{className:"relative flex h-full flex-col bg-surface text-ink",onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),$||A(!0))},onDragLeave:e=>{e.currentTarget===e.target&&A(!1)},onDrop:e=>{if(!e.dataTransfer.types.includes("Files"))return;e.preventDefault(),A(!1);const t=Array.from(e.dataTransfer.files??[]);"rich"===h?.kind&&t.length&&t.every(e=>e.type.startsWith("image/"))?window.dispatchEvent(new CustomEvent("docs-insert-images",{detail:{key:h.key,files:t}})):t[0]&&F?O():t[0]&&E(t[0])},children:[h&&Br(oe,{title:`${D=h.filename,D.length>24?`${D.slice(0,23)}…`:D}${L?" •":""} - Documents`}),Br("input",{ref:c,type:"file",accept:Kr,className:"hidden",onChange:e=>{const t=e.target.files?.[0];t&&E(t),e.target.value=""}}),v?Br("div",{className:"docs-open-failed",children:Br(le,{title:r.openFailed,children:t&&Br(ie,{onClick:t,children:r.backToFiles})})}):S||!h?Br(ce,{size:"sm",padding:"",className:"h-full",label:r.loading}):"rich"===h.kind?Br(Nr,{sessionKey:h.key,doc:h.doc,filename:h.filename,images:h.images,fileEntries:F?[]:j,title:H,startsDirty:h.imported,dirty:L,onDirty:P,onOpenFile:()=>{F?O():z()},onNewImageUrl:e=>{i.current.push(e)},onClose:t,stored:o&&h.stored?{store:o,...h.stored}:void 0,onReload:()=>{P(!1),g(null),C(e=>e+1)}},h.key):Br(Ir,{filename:h.filename,decoded:h.decoded,bytes:h.bytes,fileEntries:j,title:H,dirty:L,onDirty:P,onOpenFile:()=>{z()},onClose:t},h.key),$&&Br("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center border-4 border-dashed border-accent-fill bg-accent-tint",children:Br("div",{className:"rounded-md bg-accent-fill px-4 py-2 text-sm font-medium text-on-accent",children:r.dropHint})})]});var D}function Jr({id:e,onClose:t}){return Br(Qr,{documentId:e,onClose:t})}export{Jr as OpenDocument,Qr as default};
@@ -1 +1 @@
1
- import{FileList as e}from"./chunk-PMGQ5GUH.js";import{importDeckFile as t}from"./chunk-6ZFEBY6H.js";import{PptxPasswordError as n,PptxUnreadableError as i}from"./chunk-MDG2ADZ7.js";import{STARTERS as s,starterDeck as l}from"./chunk-Q7NVDOCX.js";import{useSlidesHost as o,useSlidesWords as r}from"./chunk-BGAR3P46.js";import{SlideView as a}from"./chunk-B2X3NIQR.js";import"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{placeCopy as c}from"./chunk-XYVQTQ6N.js";import{lazy as d,Suspense as m,useCallback as p,useEffect as u,useState as h}from"react";import{Button as f,EmptyState as k,IconButton as y,toast as b}from"efficient-shell/ui";import{Icon as N}from"efficient-shell/icons";import{jsx as v,jsxs as C}from"react/jsx-runtime";var w=e=>({title:e.placeholderTitle,subtitle:e.placeholderSubtitle,body:e.placeholderBody,dealerPitch:e.dealerPitch,monthlyReport:e.monthlyReport}),F=d(()=>import("./SlidesEditor-ETCUQVJ7.js")),j=["pptx"];function D({id:e,onClose:t,note:n}){const i=r(),{store:s}=o(),[l,a]=h(null),[c,d]=h(!1),[b,w]=h(n??null),j=p(()=>{s.get(e).then(e=>a(t=>({deck:e,nonce:(t?.nonce??0)+1})),()=>d(!0))},[e,s]);if(u(j,[j]),c)return v("div",{className:"slides-list-empty",children:v(k,{title:i.openFailed,children:v(f,{onClick:t,children:i.backToDecks})})});if(!l)return null;const D=v(m,{fallback:null,children:v(F,{deck:l.deck,onClose:t,onReload:j},l.nonce)});return b?C("div",{className:"slides-with-note",children:[C("div",{className:"slides-import-note",role:"status",children:[v(N,{name:"info",size:16}),v("span",{children:b}),v(y,{"aria-label":i.dismiss,onClick:()=>w(null),children:v(N,{name:"close",size:14})})]}),v("div",{className:"slides-with-note-body",children:D})]}):D}function P(){const d=r(),{store:m,canCreate:u=!0,canDelete:f=!0,chooseFile:k,storeImage:y}=o(),[N,F]=h(null),[P,g]=h(null),x=p(()=>m.list(),[m]);if(N)return v(D,{id:N.id,note:N.note,onClose:()=>F(null)});const B=u&&v("div",{className:"slides-starters","aria-label":d.startFrom,role:"group",children:s.map(e=>{const t="blank"===e?null:l(e,w(d));return C("button",{type:"button",className:"slides-starter",disabled:!!P,onClick:()=>{(async e=>{if(!P)try{const t=await m.create("blank"===e?d.untitledDeck:d.starterName(e));"blank"!==e&&await m.save(t.id,l(e,w(d)),t.version),F({id:t.id})}catch{b.error(d.createFailed)}})(e)},children:[v("span",{className:"slides-starter-thumb",children:t?v(a,{slide:t.slides[0],width:128}):v("span",{className:"slides-starter-blank"})}),v("span",{children:d.starterName(e)})]},e)})});return v(e,{extra:B,words:{windowTitle:d.slidesPanel,heading:d.decks,newFile:d.newDeck,emptyTitle:d.emptyTitle,emptyBody:d.emptyBody,deleteConfirm:d.deleteConfirm,createFailed:d.createFailed,deleteFailed:d.deleteFailed},files:d.files,list:x,create:()=>m.create(d.untitledDeck),rename:m.rename,remove:m.remove,canCreate:u,canDelete:f,accept:".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation",choose:k&&{run:k,request:{title:d.files.choosing(d.fileKind,d.slidesPanel),extensions:j}},onOpen:e=>F({id:e}),onOpenFile:(e,s)=>{if(P)return;const l=d.files.opening(e.name);g(l),t(m,e,{storeImage:y,onProgress:e=>g(`${l} ${Math.round(100*e)}%`)}).then(async t=>{const n=await c(s,t.id);b.success(d.files.savedCopy(t.title,e.name,n?s?.location:void 0)),F({id:t.id,note:d.importNotes({skipped:t.notes.skipped,animations:t.notes.animationsDropped,fonts:t.notes.fontsReplaced})})}).catch(t=>{b.error(t instanceof n?d.pptxPasswordProtected:t instanceof i?t.message:d.files.openFailed(e.name))}).finally(()=>g(null))},busy:P})}export{D as OpenDeck,P as default,w as starterWords};
1
+ import{FileList as e}from"./chunk-PMGQ5GUH.js";import{importDeckFile as t}from"./chunk-ADXHTZ3Q.js";import{PptxPasswordError as n,PptxUnreadableError as i}from"./chunk-MDG2ADZ7.js";import{STARTERS as s,starterDeck as l}from"./chunk-Q7NVDOCX.js";import{useSlidesHost as o,useSlidesWords as r}from"./chunk-BGAR3P46.js";import{SlideView as a}from"./chunk-B2X3NIQR.js";import"./chunk-PXOQN7D6.js";import"./chunk-B32ASXHM.js";import{placeCopy as c}from"./chunk-XYVQTQ6N.js";import{lazy as d,Suspense as m,useCallback as p,useEffect as u,useState as h}from"react";import{Button as f,EmptyState as k,IconButton as y,toast as b}from"efficient-shell/ui";import{Icon as N}from"efficient-shell/icons";import{jsx as v,jsxs as C}from"react/jsx-runtime";var w=e=>({title:e.placeholderTitle,subtitle:e.placeholderSubtitle,body:e.placeholderBody,dealerPitch:e.dealerPitch,monthlyReport:e.monthlyReport}),D=d(()=>import("./SlidesEditor-ETCUQVJ7.js")),j=["pptx"];function F({id:e,onClose:t,note:n}){const i=r(),{store:s}=o(),[l,a]=h(null),[c,d]=h(!1),[b,w]=h(n??null),j=p(()=>{s.get(e).then(e=>a(t=>({deck:e,nonce:(t?.nonce??0)+1})),()=>d(!0))},[e,s]);if(u(j,[j]),c)return v("div",{className:"slides-list-empty",children:v(k,{title:i.openFailed,children:v(f,{onClick:t,children:i.backToDecks})})});if(!l)return null;const F=v(m,{fallback:null,children:v(D,{deck:l.deck,onClose:t,onReload:j},l.nonce)});return b?C("div",{className:"slides-with-note",children:[C("div",{className:"slides-import-note",role:"status",children:[v(N,{name:"info",size:16}),v("span",{children:b}),v(y,{"aria-label":i.dismiss,onClick:()=>w(null),children:v(N,{name:"close",size:14})})]}),v("div",{className:"slides-with-note-body",children:F})]}):F}function P(){const d=r(),{store:m,canCreate:u=!0,canDelete:f=!0,chooseFile:k,storeImage:y}=o(),[N,D]=h(null),[P,g]=h(null),x=p(()=>m.list(),[m]);if(N)return v(F,{id:N.id,note:N.note,onClose:()=>D(null)});const Q=u&&v("div",{className:"slides-starters","aria-label":d.startFrom,role:"group",children:s.map(e=>{const t="blank"===e?null:l(e,w(d));return C("button",{type:"button",className:"slides-starter",disabled:!!P,onClick:()=>{(async e=>{if(!P)try{const t=await m.create("blank"===e?d.untitledDeck:d.starterName(e));"blank"!==e&&await m.save(t.id,l(e,w(d)),t.version),D({id:t.id})}catch{b.error(d.createFailed)}})(e)},children:[v("span",{className:"slides-starter-thumb",children:t?v(a,{slide:t.slides[0],width:128}):v("span",{className:"slides-starter-blank"})}),v("span",{children:d.starterName(e)})]},e)})});return v(e,{extra:Q,words:{windowTitle:d.slidesPanel,heading:d.decks,newFile:d.newDeck,emptyTitle:d.emptyTitle,emptyBody:d.emptyBody,deleteConfirm:d.deleteConfirm,createFailed:d.createFailed,deleteFailed:d.deleteFailed},files:d.files,list:x,create:()=>m.create(d.untitledDeck),rename:m.rename,remove:m.remove,canCreate:u,canDelete:f,accept:".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation",choose:k&&{run:k,request:{title:d.files.choosing(d.fileKind,d.slidesPanel),extensions:j}},onOpen:e=>D({id:e}),onOpenFile:(e,s)=>{if(P)return;const l=d.files.opening(e.name);g(l),t(m,e,{storeImage:y,onProgress:e=>g(`${l} ${Math.round(100*e)}%`)}).then(async t=>{const n=await c(s,t.id);b.success(d.files.savedCopy(t.title,e.name,n?s?.location:void 0)),D({id:t.id,note:d.importNotes({skipped:t.notes.skipped,animations:t.notes.animationsDropped,fonts:t.notes.fontsReplaced})})}).catch(t=>{b.error(t instanceof n?d.pptxPasswordProtected:t instanceof i?t.message:d.files.openFailed(e.name))}).finally(()=>g(null))},busy:P})}export{F as OpenDeck,P as default,w as starterWords};
@@ -1 +1 @@
1
- import{titleOf as r}from"./chunk-XYVQTQ6N.js";var e=r=>new Promise((e,t)=>{const a=new FileReader;a.onload=()=>e(String(a.result)),a.onerror=()=>t(a.error??new Error("Unreadable picture")),a.readAsDataURL(r)});async function t(t,a,o={}){const{importPptx:n}=await(import("./pptxImport-Y7TB6PYP.js")),{document:i,notes:s}=await n(a,{storeImage:o.storeImage??e,onProgress:o.onProgress,signal:o.signal}),c=r(a.name),m=await t.create(c);try{await t.save(m.id,i,m.version)}catch(r){throw await t.remove(m.id).catch(()=>{}),r}return{id:m.id,title:c,notes:s}}export{t as importDeckFile};
1
+ import{titleOf as r}from"./chunk-XYVQTQ6N.js";var e=r=>new Promise((e,t)=>{const a=new FileReader;a.onload=()=>e(String(a.result)),a.onerror=()=>t(a.error??new Error("Unreadable picture")),a.readAsDataURL(r)});async function t(t,a,o={}){const{importPptx:n}=await(import("./pptxImport-OACGHWQ6.js")),{document:i,notes:s}=await n(a,{storeImage:o.storeImage??e,onProgress:o.onProgress,signal:o.signal}),c=r(a.name),m=await t.create(c);try{await t.save(m.id,i,m.version)}catch(r){throw await t.remove(m.id).catch(()=>{}),r}return{id:m.id,title:c,notes:s}}export{t as importDeckFile};
@@ -0,0 +1 @@
1
+ var t=(()=>{const t=new Uint32Array(256);for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)n=1&n?3988292384^n>>>1:n>>>1;t[e]=n>>>0}return t})();function e(e){let n=4294967295;for(let r=0;r<e.length;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0}async function n(t,e){const n=e.writable.getWriter();return n.write(t).then(()=>n.close()).catch(()=>{}),new Uint8Array(await new Response(e.readable).arrayBuffer())}function r(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let n=t.length-22;n>=Math.max(0,t.length-66e3);n--)if(101010256===e.getUint32(n,!0))return{count:e.getUint16(n+10,!0),size:e.getUint32(n+12,!0),offset:e.getUint32(n+16,!0)};throw new Error("Not a zip file")}function a(t,e,n){const r=new DataView(t.buffer,t.byteOffset,t.byteLength),a=new TextDecoder,s=[];let o=e,i=0;for(let e=0;e<n;e++){if(33639248!==r.getUint32(o,!0))throw new Error("Damaged zip file");if(i+=r.getUint32(o+24,!0),i>1073741824)throw new Error("Zip file too large");const e=r.getUint16(o+28,!0),n=a.decode(t.subarray(o+46,o+46+e));n.endsWith("/")||s.push({name:n,method:r.getUint16(o+10,!0),packedSize:r.getUint32(o+20,!0),localAt:r.getUint32(o+42,!0)}),o+=46+e+r.getUint16(o+30,!0)+r.getUint16(o+32,!0)}return s}async function s(t,e){if(0===t.method)return e.slice();if(8===t.method)return n(e,new DecompressionStream("deflate-raw"));throw new Error("Unsupported zip compression")}var o=(t,e)=>{const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.localAt+30+n.getUint16(26,!0)+n.getUint16(28,!0)};async function i(t){const e=r(t),n=new Map;for(const r of a(t,e.offset,e.count)){const e=o(r,t.subarray(r.localAt,r.localAt+30));n.set(r.name,await s(r,t.subarray(e,e+r.packedSize)))}return n}async function l(t){const e=async(e,n)=>new Uint8Array(await t.slice(e,n).arrayBuffer()),n=r(await e(Math.max(0,t.size-66e3),t.size)),i=new Map(a(await e(n.offset,n.offset+n.size),0,n.count).map(t=>[t.name,t]));return{names:[...i.keys()],read:async t=>{const n=i.get(t);if(!n)throw new Error(`No part named ${t}`);const r=o(n,await e(n.localAt,n.localAt+30));return s(n,await e(r,r+n.packedSize))}}}async function w(t){const r=new TextEncoder,a=[],s=[];let o=0;for(const[i,l]of t){const t=r.encode(i),w="undefined"==typeof CompressionStream?null:await n(l,new CompressionStream("deflate-raw")),c=null===w||w.length>=l.length,f=c?l:w,p=e(l),m=new Uint8Array(30+t.length),h=new DataView(m.buffer);h.setUint32(0,67324752,!0),h.setUint16(4,20,!0),h.setUint16(6,2048,!0),h.setUint16(8,c?0:8,!0),h.setUint16(12,33,!0),h.setUint32(14,p,!0),h.setUint32(18,f.length,!0),h.setUint32(22,l.length,!0),h.setUint16(26,t.length,!0),m.set(t,30);const u=new Uint8Array(46+t.length),d=new DataView(u.buffer);d.setUint32(0,33639248,!0),d.setUint16(4,20,!0),d.setUint16(6,20,!0),d.setUint16(8,2048,!0),d.setUint16(10,c?0:8,!0),d.setUint16(14,33,!0),d.setUint32(16,p,!0),d.setUint32(20,f.length,!0),d.setUint32(24,l.length,!0),d.setUint16(28,t.length,!0),d.setUint32(42,o,!0),u.set(t,46),a.push(m,f),s.push(u),o+=m.length+f.length}const i=s.reduce((t,e)=>t+e.length,0),l=new Uint8Array(22),w=new DataView(l.buffer);w.setUint32(0,101010256,!0),w.setUint16(8,t.size,!0),w.setUint16(10,t.size,!0),w.setUint32(12,i,!0),w.setUint32(16,o,!0);const c=new Uint8Array(o+i+22);let f=0;for(const t of[...a,...s,l])c.set(t,f),f+=t.length;return c}var c={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function f(t){return t.includes("&")?t.replace(/&(#x[0-9a-fA-F]+|#\d+|[a-zA-Z]+);/g,(t,e)=>{if("#"!==e[0])return c[e]??t;const n="x"===e[1]?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return n<=1114111?String.fromCodePoint(n):t}):t}function p(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f￾￿]/g,"")}var m=/([^\s=]+)\s*=\s*("([^"]*)"|'([^']*)')/g;function h(t){const e=[];let n=null,r=0;for(;r<t.length;){const a=t.indexOf("<",r);if(a<0)break;if(a>r&&e.length&&(e[e.length-1].text+=f(t.slice(r,a))),t.startsWith("\x3c!--",a)){r=u(t,"--\x3e",a);continue}if(t.startsWith("<?",a)){r=u(t,"?>",a);continue}if(t.startsWith("<![CDATA[",a)){const n=u(t,"]]>",a);e.length&&(e[e.length-1].text+=t.slice(a+9,n-3)),r=n;continue}if(t.startsWith("<!",a)){r=u(t,">",a);continue}const s=d(t,a);if("/"===t[a+1]){const n=e.pop();if(!n||n.name!==t.slice(a+2,s).trim())throw new Error("Malformed XML");n.innerEnd=a,n.end=s+1,r=s+1;continue}const o="/"===t[s-1],i=t.slice(a+1,o?s-1:s),l=i.search(/\s/),w={name:l<0?i:i.slice(0,l),attrs:{},children:[],text:"",start:a,end:s+1,innerStart:s+1,innerEnd:s+1};if(l>=0)for(const t of i.slice(l).matchAll(m))w.attrs[t[1]]=f(t[3]??t[4]??"");e.length?e[e.length-1].children.push(w):n||(n=w),o||e.push(w),r=s+1}if(!n||e.length)throw new Error("Malformed XML");return n}function u(t,e,n){const r=t.indexOf(e,n);if(r<0)throw new Error("Malformed XML");return r+e.length}function d(t,e){let n="";for(let r=e+1;r<t.length;r++){const e=t[r];if(n)e===n&&(n="");else if('"'===e||"'"===e)n=e;else if(">"===e)return r}throw new Error("Malformed XML")}var g=(t,e)=>t?.children.find(t=>t.name===e),y=(t,e)=>t?.children.filter(t=>t.name===e)??[];function v(t,e,n=[]){for(const r of t.children)e.has(r.name)&&n.push(r),v(r,e,n);return n}function b(t){if(!t)return;const e=t.attrs["w:val"];return!("0"===e||"false"===e||"off"===e||"none"===e)}var x='xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"',$="http://schemas.openxmlformats.org/officeDocument/2006/relationships",P={officeDocument:`${$}/officeDocument`,styles:`${$}/styles`,numbering:`${$}/numbering`,theme:`${$}/theme`,comments:`${$}/comments`,footnotes:`${$}/footnotes`,header:`${$}/header`,footer:`${$}/footer`,image:`${$}/image`,hyperlink:`${$}/hyperlink`,settings:`${$}/settings`},U=new TextEncoder,N=new TextDecoder,T=(t,e)=>{const n=t.get(e);return n?N.decode(n):void 0},z=(t,e,n)=>{t.set(e,U.encode(n))},C=t=>{const e=t.lastIndexOf("/");return`${t.slice(0,e+1)}_rels/${t.slice(e+1)}.rels`};function k(t,e){const n=T(t,C(e));return n?h(n).children.filter(t=>"Relationship"===t.name).map(t=>({id:t.attrs.Id,type:t.attrs.Type,target:t.attrs.Target,external:"External"===t.attrs.TargetMode})):[]}function M(t,e){if(e.startsWith("/"))return e.slice(1);const n=t.split("/").slice(0,-1);for(const t of e.split("/"))".."===t?n.pop():"."!==t&&n.push(t);return n.join("/")}function A(t,e,n,r,a=!1){const s=C(e),o=T(t,s),i=new Set(k(t,e).map(t=>t.id));let l=i.size+1;for(;i.has(`rId${l}`);)l++;const w=`rId${l}`,c=`<Relationship Id="${w}" Type="${n}" Target="${p(r)}"${a?' TargetMode="External"':""}/>`;return z(t,s,o?o.replace(/(<\/Relationships>\s*)$/,`${c}$1`).replace(/<Relationships([^>]*)\/>\s*$/,`<Relationships$1>${c}</Relationships>`):`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${c}</Relationships>`),w}function D(t,e,n){const r=T(t,"[Content_Types].xml")??"";r.includes(`PartName="/${e}"`)||z(t,"[Content_Types].xml",r.replace("</Types>",`<Override PartName="/${e}" ContentType="${n}"/></Types>`))}function L(t,e,n){const r=T(t,"[Content_Types].xml")??"";new RegExp(`Extension="${e}"`,"i").test(r)||z(t,"[Content_Types].xml",r.replace(/(<Types[^>]*>)/,`$1<Default Extension="${e}" ContentType="${n}"/>`))}var R={a4:{width:11906,height:16838},letter:{width:12240,height:15840},legal:{width:12240,height:20160},a3:{width:16838,height:23811},a5:{width:8391,height:11906}},I={normal:{top:1440,right:1440,bottom:1440,left:1440},narrow:{top:720,right:720,bottom:720,left:720},moderate:{top:1440,right:1080,bottom:1440,left:1080},wide:{top:1440,right:2880,bottom:1440,left:2880}},F={...R.a4,...I.normal,header:708,footer:708};function E(t,e){const n=R[e];return t.width>t.height?{...t,width:n.height,height:n.width}:{...t,...n}}function O(t,e){return{...t,...I[e]}}function j(t){const e=Math.min(t.width,t.height),n=Math.max(t.width,t.height);for(const[t,r]of Object.entries(R))if(Math.abs(r.width-e)<30&&Math.abs(r.height-n)<30)return t;return null}function H(t){for(const[e,n]of Object.entries(I))if(n.top===t.top&&n.right===t.right&&n.bottom===t.bottom&&n.left===t.left)return e;return null}var S={yellow:"#ffff00",green:"#00ff00",cyan:"#00ffff",magenta:"#ff00ff",blue:"#0000ff",red:"#ff0000",darkBlue:"#000080",darkCyan:"#008080",darkGreen:"#008000",darkMagenta:"#800080",darkRed:"#800000",darkYellow:"#808000",darkGray:"#808080",lightGray:"#c0c0c0",black:"#000000",white:"#ffffff"};function q(t){if(!t)return{};try{const e=h(t),n=g(g(e,"a:themeElements"),"a:fontScheme");return{major:g(g(n,"a:majorFont"),"a:latin")?.attrs.typeface,minor:g(g(n,"a:minorFont"),"a:latin")?.attrs.typeface}}catch{return{}}}var W=t=>t&&/^[0-9a-fA-F]{6}$/.test(t)?`#${t.toLowerCase()}`:void 0;function _(t,e){const n={};if(!t)return n;const r=b(g(t,"w:b"));void 0!==r&&(n.b=r);const a=b(g(t,"w:i"));void 0!==a&&(n.i=a);const s=g(t,"w:u");s&&(n.u="none"!==s.attrs["w:val"]);const o=b(g(t,"w:strike"));void 0!==o&&(n.strike=o);const i=g(t,"w:vertAlign")?.attrs["w:val"];"subscript"===i&&(n.vert="sub"),"superscript"===i&&(n.vert="super");const l=function(t,e){if(!t)return;const n=t.attrs["w:ascii"]??t.attrs["w:hAnsi"];if(n)return n;const r=t.attrs["w:asciiTheme"]??t.attrs["w:hAnsiTheme"];return r?r.startsWith("major")?e.major:e.minor:t.attrs["w:eastAsia"]??t.attrs["w:cs"]}(g(t,"w:rFonts"),e);l&&(n.font=l);const w=Number(g(t,"w:sz")?.attrs["w:val"]);w&&(n.size=w/2);const c=W(g(t,"w:color")?.attrs["w:val"]);c&&(n.color=c);const f=g(t,"w:highlight")?.attrs["w:val"];if(f&&S[f])n.hl=S[f];else{const e=W(g(t,"w:shd")?.attrs["w:fill"]);e&&(n.hl=e)}return n}function V(t){const e={};if(!t)return e;const n=g(t,"w:jc")?.attrs["w:val"];"left"===n||"start"===n?e.align="left":"center"===n?e.align="center":"right"===n||"end"===n?e.align="right":"both"!==n&&"distribute"!==n||(e.align="justify");const r=g(t,"w:ind");if(r){const t=r.attrs["w:left"]??r.attrs["w:start"];void 0!==t&&(e.indentLeft=Number(t)/20);const n=r.attrs["w:right"]??r.attrs["w:end"];void 0!==n&&(e.indentRight=Number(n)/20),void 0!==r.attrs["w:firstLine"]&&(e.firstLine=Number(r.attrs["w:firstLine"])/20),void 0!==r.attrs["w:hanging"]&&(e.firstLine=-Number(r.attrs["w:hanging"])/20)}const a=g(t,"w:spacing");if(a){void 0!==a.attrs["w:before"]&&(e.before=Number(a.attrs["w:before"])/20),void 0!==a.attrs["w:after"]&&(e.after=Number(a.attrs["w:after"])/20);const t=Number(a.attrs["w:line"]);t&&("exact"===a.attrs["w:lineRule"]||"atLeast"===a.attrs["w:lineRule"]?e.linePoints=t/20:e.lineMultiple=t/240)}const s=y(g(t,"w:tabs"),"w:tab").filter(t=>"clear"!==t.attrs["w:val"]&&void 0!==t.attrs["w:pos"]).map(t=>{const e=t.attrs["w:val"];return{pos:Number(t.attrs["w:pos"])/20,align:"center"===e?"center":"right"===e||"end"===e?"right":"left"}}).filter(t=>Number.isFinite(t.pos));return s.length&&(e.tabs=s.sort((t,e)=>t.pos-e.pos)),e}function B(t){if(!t.tabs?.length)return"";const e=t.indentLeft??0,n=t.tabs.find(t=>t.pos>e);return n?`tab-size:${Z(n.pos-e)}pt`:""}var Q=t=>t.map(t=>`${Z(t.pos)}${t.align[0]}`).join(" ");function X(t){return t?t.split(/\s+/).map(t=>{const e=/^(-?[\d.]+)([lcr])$/.exec(t);return e?{pos:Number(e[1]),align:"c"===e[2]?"center":"r"===e[2]?"right":"left"}:null}).filter(t=>!!t&&Number.isFinite(t.pos)).sort((t,e)=>t.pos-e.pos):[]}var Z=t=>Math.round(100*t)/100,G={open:"☐",done:"☑"},J=["Inter","Roboto","Montserrat","Lora","Playfair Display","JetBrains Mono"];function Y(t){return`https://fonts.googleapis.com/css2?${[...t].sort().map(t=>`family=${t.replace(/ /g,"+")}:ital,wght@0,400;0,700;1,400;1,700`).join("&")}&display=swap`}function K(t){const e=[];return t.align&&e.push(`text-align:${t.align}`),void 0!==t.indentLeft&&e.push(`margin-left:${Z(t.indentLeft)}pt`),void 0!==t.indentRight&&e.push(`margin-right:${Z(t.indentRight)}pt`),void 0!==t.firstLine&&e.push(`text-indent:${Z(t.firstLine)}pt`),void 0!==t.before&&e.push(`margin-top:${Z(t.before)}pt`),void 0!==t.after&&e.push(`margin-bottom:${Z(t.after)}pt`),void 0!==t.lineMultiple&&e.push(`line-height:${Z(t.lineMultiple)}`),void 0!==t.linePoints&&e.push(`line-height:${Z(t.linePoints)}pt`),e.join(";")}function tt(t){const e=[];void 0!==t.b&&e.push("font-weight:"+(t.b?700:400)),void 0!==t.i&&e.push("font-style:"+(t.i?"italic":"normal"));const n=[t.u&&"underline",t.strike&&"line-through"].filter(Boolean);return n.length&&e.push(`text-decoration-line:${n.join(" ")}`),t.font&&e.push(`font-family:${function(t){const e=t.replace(/["\\<>;]/g,"");return/mono|courier|consolas|menlo/i.test(e)?`"${e}",monospace`:/times|georgia|cambria|garamond|palatino|serif|song|ming/i.test(e)&&!/sans/i.test(e)?`"${e}",Caladea,serif`:`"${e}",Carlito,Arial,sans-serif`}(t.font)}`),t.size&&e.push(`font-size:${Z(t.size)}pt`),t.color&&e.push(`color:${t.color}`),t.hl&&e.push(`background-color:${t.hl}`),e.join(";")}var et={Title:{name:"Title",xml:'<w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:spacing w:after="80" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="56"/><w:szCs w:val="56"/></w:rPr></w:style>'},Heading1:{name:"heading 1",xml:'<w:style w:type="paragraph" w:styleId="Heading1"><w:name w:val="heading 1"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="360" w:after="80"/><w:outlineLvl w:val="0"/></w:pPr><w:rPr><w:color w:val="0F4761"/><w:sz w:val="40"/><w:szCs w:val="40"/></w:rPr></w:style>'},Heading2:{name:"heading 2",xml:'<w:style w:type="paragraph" w:styleId="Heading2"><w:name w:val="heading 2"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="160" w:after="80"/><w:outlineLvl w:val="1"/></w:pPr><w:rPr><w:color w:val="0F4761"/><w:sz w:val="32"/><w:szCs w:val="32"/></w:rPr></w:style>'},Heading3:{name:"heading 3",xml:'<w:style w:type="paragraph" w:styleId="Heading3"><w:name w:val="heading 3"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="160" w:after="80"/><w:outlineLvl w:val="2"/></w:pPr><w:rPr><w:color w:val="0F4761"/><w:sz w:val="28"/><w:szCs w:val="28"/></w:rPr></w:style>'},Heading4:{name:"heading 4",xml:'<w:style w:type="paragraph" w:styleId="Heading4"><w:name w:val="heading 4"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="80" w:after="40"/><w:outlineLvl w:val="3"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val="0F4761"/><w:sz w:val="24"/><w:szCs w:val="24"/></w:rPr></w:style>'},Heading5:{name:"heading 5",xml:'<w:style w:type="paragraph" w:styleId="Heading5"><w:name w:val="heading 5"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="80" w:after="40"/><w:outlineLvl w:val="4"/></w:pPr><w:rPr><w:color w:val="0F4761"/><w:sz w:val="22"/><w:szCs w:val="22"/></w:rPr></w:style>'},Heading6:{name:"heading 6",xml:'<w:style w:type="paragraph" w:styleId="Heading6"><w:name w:val="heading 6"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="40"/><w:outlineLvl w:val="5"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val="595959"/><w:sz w:val="22"/><w:szCs w:val="22"/></w:rPr></w:style>'},Quote:{name:"Quote",xml:'<w:style w:type="paragraph" w:styleId="Quote"><w:name w:val="Quote"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:spacing w:before="160"/><w:jc w:val="center"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val="404040"/></w:rPr></w:style>'}},nt='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';function rt(t){const e=new Map;z(e,"[Content_Types].xml",`${nt}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/></Types>`),z(e,"_rels/.rels",`${nt}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${P.officeDocument}" Target="word/document.xml"/></Relationships>`);const n=F;z(e,"word/document.xml",`${nt}<w:document ${x}><w:body><w:p/><w:sectPr><w:pgSz w:w="${n.width}" w:h="${n.height}"/><w:pgMar w:top="${n.top}" w:right="${n.right}" w:bottom="${n.bottom}" w:left="${n.left}" w:header="${n.header}" w:footer="${n.footer}" w:gutter="0"/></w:sectPr></w:body></w:document>`),z(e,"word/_rels/document.xml.rels",`${nt}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${P.styles}" Target="styles.xml"/><Relationship Id="rId2" Type="${$}/settings" Target="settings.xml"/></Relationships>`),z(e,"word/settings.xml",`${nt}<w:settings ${x}><w:compat><w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15"/></w:compat></w:settings>`);const r=/^[A-Za-z]{2,3}(-[A-Za-z0-9]+)*$/.test(t)?t:"en-AU";return z(e,"word/styles.xml",`${nt}<w:styles ${x}><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:eastAsia="Calibri" w:cs="Calibri"/><w:sz w:val="22"/><w:szCs w:val="22"/><w:lang w:val="${r}"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="160" w:line="259" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style>${Object.values(et).map(t=>t.xml).join("")}<w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style></w:styles>`),e}export{i as readZip,l as openZip,w as writeZip,p as escapeXml,h as parseXml,g as child,y as childrenOf,v as descendants,x as WORD_NS,P as REL,T as partText,z as setPartText,k as readRels,M as resolveTarget,A as addRel,D as addContentOverride,L as addContentDefault,R as PAPER_SIZES,I as MARGIN_PRESETS,F as DEFAULT_PAGE,E as withPaper,O as withMargins,j as paperOf,H as marginsOf,S as HIGHLIGHTS,q as readThemeFonts,_ as parseRunProps,V as parseParaProps,B as tabCss,Q as tabsAttr,X as parseTabsAttr,G as CHECK_BULLETS,J as WEB_FONTS,Y as webFontSheetUrl,K as paraCss,tt as runCss,et as BUILTIN_STYLES,rt as blankDocxParts};
@@ -0,0 +1 @@
1
+ var e=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI","TR","TABLE","UL","OL","TBODY"]);function t(t){let o="";const a=t=>{for(const n of Array.from(t.childNodes)){if(3===n.nodeType){o+=(n.nodeValue??"").replace(/​/g,"");continue}if(1!==n.nodeType)continue;const t=n;if("BR"===t.tagName){o+="\n";continue}if("DEL"===t.tagName||t.hasAttribute("data-hidden"))continue;if("object"===t.getAttribute("data-kind")||"mark"===t.getAttribute("data-kind"))continue;if("TD"===t.tagName||"TH"===t.tagName){a(t),o=`${o.replace(/\n+$/,"")}\t`;continue}const r=e.has(t.tagName);a(t),r&&!o.endsWith("\n")&&(o+="\n")}};return a(t),o.replace(/\t\n/g,"\n").replace(/\n+$/,"\n")}function o(e){return(e.match(/[぀-ヿ㐀-鿿豈-﫿]/g)?.length??0)+(e.replace(/[぀-ヿ㐀-鿿豈-﫿]/g," ").match(/\S+/g)?.length??0)}function a(t,o,a){if(!o)return[];const n=function(e){const t=[],o=e=>{for(const a of Array.from(e.childNodes))if(3===a.nodeType)t.push(a);else if(1===a.nodeType){const e=a;if("false"===e.getAttribute("contenteditable")||e.hasAttribute("data-raw"))continue;o(e)}};return o(e),t}(t),r=o=>{let a=o.parentNode;for(;a&&a!==t&&!e.has(a.tagName)&&"TD"!==a.tagName;)a=a.parentNode;return a},d=[];let c=0;for(;c<n.length;){const e=r(n[c]);let t=c;const i=[];for(;t<n.length&&r(n[t])===e;)i.push(n[t++]);const s=i.map(e=>e.nodeValue??"").join(""),l=a?s:s.toLowerCase(),p=a?o:o.toLowerCase(),g=l.length===s.length?l:s;for(let e=g.indexOf(p);e>=0;e=g.indexOf(p,e+p.length)){const t=[];let o=0;for(const a of i){const n=(a.nodeValue??"").length,r=Math.max(e,o),d=Math.min(e+p.length,o+n);r<d&&t.push({node:a,start:r-o,end:d-o}),o+=n}d.push(t)}c=t}return d}function n(e,t){e.forEach((e,o)=>{const a=e.node.nodeValue??"";e.node.nodeValue=a.slice(0,e.start)+(0===o?t:"")+a.slice(e.end)})}function r(e,t){const o=[0];if(t<=0)return o;let a=0;for(const n of e)if(n.breakBefore&&n.top>a&&(a=n.top,o.push(a)),!(n.top+n.height-a<=t))if(n.height<=t)n.top>a&&(a=n.top,o.push(a));else for(;n.top+n.height-a>t;)a+=t,o.push(a);return o}function d(e,t,o=1){const a=[],n=e=>{const n=e.getBoundingClientRect();a.push({top:(n.top-t)/o,height:n.height/o,breakBefore:e.hasAttribute("data-break-before")})};for(const r of Array.from(e.children))"TABLE"===r.tagName?r.querySelectorAll("tr").forEach(n):"UL"===r.tagName||"OL"===r.tagName?r.querySelectorAll("li").forEach(n):n(r),r.querySelectorAll("[data-page-break]").forEach(e=>{const n=e.getBoundingClientRect();a.push({top:(n.bottom-t)/o,height:0,breakBefore:!0})});return a}var c=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","UL","OL","LI","TABLE","THEAD","TBODY","TFOOT","TR","TD","TH","COLGROUP","COL","B","STRONG","I","EM","U","S","STRIKE","SUB","SUP","SPAN","FONT","A","BR","IMG","PRE","HR"]),i=new Set(["SCRIPT","STYLE","TITLE","META","LINK","OBJECT","EMBED","IFRAME","NOSCRIPT","TEMPLATE","SVG","MATH","FORM","INPUT","BUTTON","SELECT","TEXTAREA","VIDEO","AUDIO","CANVAS"]),s=new Set(["color","background-color","font-weight","font-style","text-decoration-line","text-decoration","font-family","font-size","text-align","margin-left","line-height","width","height","list-style-type"]),l=/^(https?:|mailto:|tel:|#)/i,p=/^(data:image\/(png|jpe?g|gif|webp|bmp);base64,|blob:)/i;function g(e){const t=document.implementation.createHTMLDocument("");t.body.innerHTML=e;const o=(e,t,a)=>{for(const n of Array.from(e.childNodes)){if(3===n.nodeType){t.appendChild(a.createTextNode(n.nodeValue??""));continue}if(1!==n.nodeType)continue;const e=n,r=e.tagName.toUpperCase();if(i.has(r))continue;if(!c.has(r)){o(e,t,a);continue}if("IMG"===r&&!p.test(e.getAttribute("src")??""))continue;const d=a.createElement(r),g=(e.getAttribute("style")??"").split(";").map(e=>{const t=e.indexOf(":");if(t<0)return"";const o=e.slice(0,t).trim().toLowerCase(),a=e.slice(t+1).trim();return s.has(o)&&!/url\(|expression|mso-/i.test(a)?`${o}:${a}`:""}).filter(Boolean).join(";");g&&d.setAttribute("style",g),"A"===r&&l.test(e.getAttribute("href")??"")&&d.setAttribute("href",e.getAttribute("href")),"IMG"===r&&d.setAttribute("src",e.getAttribute("src"));for(const t of["colspan","rowspan","start","color","face","size"]){const o=e.getAttribute(t);null!==o&&d.setAttribute(t,o)}o(e,d,a),t.appendChild(d)}},a=document.createElement("div");return o(t.body,a,document),a.innerHTML}import{escapeHtml as f}from"efficient-shell/ui";var u='\nhtml,body{margin:0;background:#fff}\n.docs-page [data-comment]{background:none;border:0}\n.docs-page [data-locked]{background:none;box-shadow:none}\n.docs-page [data-page-break]{break-after:page;border:0;margin:0}\n.docs-page [data-section]::after{display:none}\n.docs-page [data-section="nextPage"]{break-after:page}\n.docs-page [data-bookmark]{display:none}\n.docs-page [data-break-before]{break-before:page}\n.docs-page tr,.docs-page img{break-inside:avoid}\n';function h(e,t){return`\n.docs-sheet{background:#fff;color:#777}\n.docs-sheet-line{border-color:#aaa}\n\n${`\n.docs-page{color:#000;background:#fff;white-space:pre-wrap;overflow-wrap:break-word;outline:none;line-height:1.08;tab-size:36pt;font-family:Calibri,Carlito,Arial,sans-serif;font-size:11pt}\n.docs-page p,.docs-page h1,.docs-page h2,.docs-page h3,.docs-page h4,.docs-page h5,.docs-page h6{margin:0;font:inherit;font-weight:400}\n.docs-page ul,.docs-page ol{margin:0;padding-left:24pt}\n.docs-page ul{list-style-type:disc}.docs-page ol{list-style-type:decimal}\n.docs-page ul ul{list-style-type:circle}.docs-page ul ul ul{list-style-type:square}\n.docs-page a{color:#0563c1;text-decoration:underline}\n.docs-page sub,.docs-page sup{font-size:.66em}\n.docs-page img{max-width:100%}\n.docs-page table{border-collapse:collapse;table-layout:fixed;width:100%}\n.docs-page td,.docs-page th{border:.5pt solid #000;padding:0 5.4pt;vertical-align:top}\n.docs-page table[data-no-borders] td,.docs-page table[data-no-borders] th{border:.5pt dotted #bbb}\n.docs-page td p{margin-bottom:0}\n.docs-page blockquote{margin:0 0 8pt 24pt;font-style:italic}\n.docs-page hr{border:0;border-top:.75pt solid #000;margin:6pt 0}\n.docs-page [data-hidden]{display:none}\n.docs-page [data-page-break]{display:block;height:0;border-top:1pt dashed #999;margin:6pt 0;user-select:none}\n.docs-page [data-comment]{background:#fff2cc;border-bottom:1.5pt solid #e0b000}\n.docs-page [data-locked]{background:#f4f4f4;box-shadow:-5pt 0 0 #bbb;cursor:not-allowed}\n.docs-page ins{color:#c00000;text-decoration:underline}\n.docs-page del{color:#c00000;text-decoration:line-through}\n.docs-page [data-kind="object"]{display:inline-block;background:#f4f4f4;border:.75pt dashed #999;color:#555;padding:1pt 5pt;cursor:not-allowed;white-space:normal}\n.docs-page [data-kind="field"]{background:#ededed}\n.docs-page{counter-reset:docs-note}\n.docs-page [data-kind="note"]{vertical-align:super;font-size:.66em}\n.docs-page [data-note]{counter-increment:docs-note;color:#0563c1;padding:0 1pt}\n.docs-page [data-note]::after{content:counter(docs-note)}\n.docs-page [data-kind="endnote"]{vertical-align:super;font-size:.66em}\n.docs-page ul[data-checklist]{list-style:none;padding-left:20pt}\n.docs-page ul[data-checklist]>li{position:relative}\n.docs-page ul[data-checklist]>li::before{content:"\\2610";position:absolute;left:-17pt;width:14pt;text-align:center;cursor:pointer}\n.docs-page ul[data-checklist]>li[data-checked]::before{content:"\\2611"}\n.docs-page ul[data-checklist]>li[data-checked]{text-decoration:line-through;color:#777}\n.docs-page [data-bookmark]{display:inline-block;width:7pt;height:9pt;margin:0 1pt;vertical-align:-1pt;background:#1a73e8;clip-path:polygon(0 0,100% 0,100% 100%,50% 70%,0 100%);cursor:default}\n.docs-page [data-toc]{margin:6pt 0;padding:4pt 0;border-top:.5pt solid #ddd;border-bottom:.5pt solid #ddd;cursor:pointer}\n.docs-page [data-toc] p{display:flex;gap:6pt;margin:0 0 3pt}\n.docs-page [data-toc] p::after{content:"";order:1;flex:1;border-bottom:1pt dotted #999;margin-bottom:3pt}\n.docs-page [data-toc] [data-toc-page]{order:2}\n.docs-page [data-toc] [data-toc-level="2"]{padding-left:11pt}\n.docs-page [data-toc] [data-toc-level="3"]{padding-left:22pt}\n.docs-page [data-toc]:empty::before{color:#777;font-style:italic}\n.docs-page [data-section]::after{display:block;margin:6pt 0;border-top:2pt double #aaa;color:#888;font-size:8pt;text-align:center;line-height:1.6;user-select:none}\n.docs-page ::highlight(docs-find){background:#ffe680}\n.docs-page ::highlight(docs-find-current){background:#ff9f1a}\n\n${e.css}`.replaceAll(".docs-page",`.docs-page[data-doc="${t}"]`)}`}var b=e=>u.replaceAll(".docs-page",`.docs-page[data-doc="${e}"]`);function m(e,t,o){const a=e=>(e??"").replaceAll("{page}",String(t)).replaceAll("{pages}",String(o)),[n,r]=e.split(/\s*\|\s*/);return[a(n),a(r)]}function k(e,t){const[o,a]=function(e){return e.split(/\s*\|\s*/).map(e=>e.split(/(\{page\}|\{pages\})/).map(e=>"{page}"===e?"counter(page)":"{pages}"===e?"counter(pages)":e?`"${e.replace(/["\\\n\r]/g,"")}"`:"").filter(Boolean).join(" "))}(t),n="font:9pt Calibri,Carlito,Arial,sans-serif;color:#555";return`${o?`@${e}-left{content:${o};${n}}`:""}${a?`@${e}-right{content:${a};${n}}`:""}`}function y({title:e,html:t,doc:o,scope:a,page:n,header:r,footer:d}){const c=e=>Math.round(e)/20+"pt",i=`@page{size:${c(n.width)} ${c(n.height)};margin:${c(n.top)} ${c(n.right)} ${c(n.bottom)} ${c(n.left)};${k("top",r)}${k("bottom",d)}}`;return`<!doctype html><html><head><meta charset="utf-8"><meta name="generator" content="efficient-shell Documents"><title>${f(e)}</title><style>${h(o,a)}\n${b(a)}\n${i}</style></head><body><div class="docs-page" data-doc="${a}">${t}</div></body></html>`}export{t as documentText,o as countWords,a as findInNodes,n as replaceSpots,r as pageStarts,d as pageBlocks,g as sanitizeHtml,h as pageStyles,b as printStyles,m as marginText,y as pageDocument};
@@ -1 +1 @@
1
- import{ENGLISH_WORDS as r}from"./chunk-I3AC6PYR.js";import{createContext as e,useContext as o}from"react";import{jsx as t}from"react/jsx-runtime";var n=e(r);function a({words:r,children:e}){return t(n.Provider,{value:r,children:e})}var i=()=>o(n);import{createContext as s,useContext as c}from"react";import{jsx as d}from"react/jsx-runtime";var m=class extends Error{},u=s({});function l({value:r,children:e}){return d(u.Provider,{value:r,children:r.words?d(a,{words:r.words,children:e}):e})}var v=()=>c(u);export{a as DocumentsWordsProvider,i as useDocumentsWords,m as DocumentsConflict,l as DocumentsProvider,v as useDocumentsHost};
1
+ import{ENGLISH_WORDS as r}from"./chunk-POH6OTTR.js";import{createContext as e,useContext as o}from"react";import{jsx as t}from"react/jsx-runtime";var n=e(r);function a({words:r,children:e}){return t(n.Provider,{value:r,children:e})}var i=()=>o(n);import{createContext as s,useContext as c}from"react";import{jsx as d}from"react/jsx-runtime";var m=class extends Error{},u=s({});function l({value:r,children:e}){return d(u.Provider,{value:r,children:r.words?d(a,{words:r.words,children:e}):e})}var v=()=>c(u);export{a as DocumentsWordsProvider,i as useDocumentsWords,m as DocumentsConflict,l as DocumentsProvider,v as useDocumentsHost};
@@ -1 +1 @@
1
- import{readDocx as t}from"./chunk-COXKOQPZ.js";import{titleOf as a}from"./chunk-XYVQTQ6N.js";async function r(r,i){const e=new Uint8Array(await i.arrayBuffer());await t(e);const n=a(i.name),c=await r.create(n);try{await r.save(c.id,e,c.version)}catch(t){throw await r.remove(c.id).catch(()=>{}),t}return{id:c.id,title:n}}export{r as importDocumentFile};
1
+ import{readDocx as t}from"./chunk-YKQ5UKYZ.js";import{titleOf as a}from"./chunk-XYVQTQ6N.js";async function r(r,i){const e=new Uint8Array(await i.arrayBuffer());await t(e);const n=a(i.name),c=await r.create(n);try{await r.save(c.id,e,c.version)}catch(t){throw await r.remove(c.id).catch(()=>{}),t}return{id:c.id,title:n}}export{r as importDocumentFile};
@@ -0,0 +1 @@
1
+ import{ENGLISH_FILE_WORDS as e,ZH_HANS_FILE_WORDS as t}from"./chunk-B32ASXHM.js";var o={styleHeading4:"Heading 4",styleHeading5:"Heading 5",styleHeading6:"Heading 6",applyStyle:e=>`Apply "${e}"`,updateStyle:e=>`Update "${e}" to match`,styleUpdated:e=>`"${e}" now looks like the selected paragraph.`,paintFormat:"Paint format",paintFormatHint:"Select the text to give this formatting.",checklist:"Checklist",paragraphSpacing:"Line and paragraph spacing",addSpaceBefore:"Add space before paragraph",removeSpaceBefore:"Remove space before paragraph",addSpaceAfter:"Add space after paragraph",removeSpaceAfter:"Remove space after paragraph",customSpacing:"Custom spacing and indents",lineSpacingCustom:"Line spacing (lines)",spacingBefore:"Space before (pt)",spacingAfter:"Space after (pt)",indentLeft:"Left indent (pt)",indentRight:"Right indent (pt)",indentSpecial:"Special indent",indentNone:"None",indentFirstLine:"First line",indentHanging:"Hanging",indentBy:"By (pt)",spacingInvalid:"Enter numbers of 0 or more, and a line spacing between 0 and 10.",ruler:"Ruler",tabStop:"Tab stop",tabStopHint:"Click to add a tab stop. Drag one off the ruler to remove it. Double-click one to change its alignment.",columns:"Columns",columnsCount:e=>1===e?"One column":2===e?"Two columns":`${e} columns`,tableOfContents:"Table of contents",tocRefresh:"Refresh table of contents",tocDelete:"Delete table of contents",footnote:"Footnote",footnotes:"Footnotes",footnotePlaceholder:"Footnote text",footnoteLocked:"This footnote holds more than text, so it is kept as it is. Edit it in Word.",bookmark:"Bookmark",bookmarkPrompt:"Name the bookmark. Letters, numbers and underscores, starting with a letter.",bookmarkInvalid:"A bookmark name starts with a letter and has only letters, numbers and underscores.",bookmarkTaken:"There is already a bookmark with that name.",linkToHeading:"Link to a heading",linkToBookmark:"Link to a bookmark",noHeadings:"No headings yet",noBookmarks:"No bookmarks yet",breakMenu:"Break",sectionBreakNext:"Section break (next page)",sectionBreakContinuous:"Section break (continuous)",removeSectionBreak:"Remove section break",headersFooters:"Headers and footers",headersFootersHint:"Click to edit headers and footers",differentFirst:"Different first page",differentOddEven:"Different odd and even pages",headerDefault:"All pages",headerOdd:"Odd pages",headerFirst:"First page",headerEven:"Even pages",pageCount:"Page count",webFonts:"Web fonts",wordFonts:"Word fonts",pdfPageFailed:e=>`Page ${e} couldn't be drawn for the PDF.`,files:e,fileKind:"Word",backToFiles:"Back to files",filesHeading:"Documents",newFile:"New document",openFile:"Open a file",filesEmptyTitle:"Write your first document",filesEmptyBody:"Every change saves by itself.",deleteFile:"Delete",createFailed:"The document could not be made.",deleteFailed:"The document could not be deleted.",deleteConfirm:e=>`Delete "${e}"? Nobody can open it again.`,documentName:"Document name",documentPanel:"Document",pagePanel:"Page",outline:"Outline",outlineEmpty:"Headings in the document show here.",morePageSetup:"More page setup",export:"Export",renameFailed:"The document could not be renamed.",openFailed:"This document could not be opened.",conflict:"Somebody else saved this document, so your latest changes are not saved. Reload to see theirs.",reload:"Reload",noStoreEdited:"Not saved. Export to keep your changes",noStoreClean:"No autosave here. Export to keep a copy",openFromFiles:"Go back to your files to open another document.",untitled:"Untitled",loading:"Loading",newDocument:"New",open:"Open",rename:"Rename",menuFile:"File",menuInsert:"Insert",menuLayout:"Layout",save:"Save",saveDocx:"Save (.docx)",saveKeepType:"Save",saveAs:"Save as",saveAsWord:"Word document (.docx)",saveAsPdf:"PDF (from the print dialog)",saveAsWeb:"Web page (.html)",saveAsText:"Plain text (.txt)",print:"Print",undo:"Undo",redo:"Redo",find:"Find",replaceWith:"Replace with",replace:"Replace",replaceAll:"Replace all",matchCase:"Match case",previousMatch:"Previous match",nextMatch:"Next match",closeFind:"Close find",noMatches:"No matches",paragraphStyle:"Paragraph style",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",superscript:"Superscript",subscript:"Subscript",textColor:"Text color",highlight:"Highlight color",clearFormatting:"Clear formatting",bulletedList:"Bulleted list",numberedList:"Numbered list",decreaseIndent:"Decrease indent",increaseIndent:"Increase indent",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",justify:"Justify",lineSpacing:"Line spacing",styleNormal:"Normal",styleTitle:"Title",styleHeading1:"Heading 1",styleHeading2:"Heading 2",styleHeading3:"Heading 3",styleQuote:"Quote",table:"Table",image:"Image",link:"Link",linkPrompt:"Web address, or leave empty to remove the link.",linkInvalid:"That address can't be used as a link.",pageBreak:"Page break",pageNumber:"Page number",horizontalLine:"Horizontal line",rowAbove:"Insert row above",rowBelow:"Insert row below",columnLeft:"Insert column left",columnRight:"Insert column right",mergeCells:"Merge cells",mergeFailed:"These cells can't be merged: the selection would cut a merged cell.",cellShading:"Cell shading",noColor:"No color",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",imageWidth:"Image width",imageOriginalSize:"Original size",imageRemove:"Remove image",pageSetup:"Page setup",paperSize:"Size",paperLetter:"US Letter",paperLegal:"US Legal",custom:"Custom",orientation:"Orientation",portrait:"Portrait",landscape:"Landscape",margins:"Margins",marginsNormal:"Normal, 2.54 cm",marginsNarrow:"Narrow, 1.27 cm",marginsModerate:"Moderate, 1.91 cm sides",marginsWide:"Wide, 5.08 cm sides",header:"Header",footer:"Footer",headerFooterLocked:"This one holds a picture or a table, so it is kept as it is. Edit it in Word.",ok:"OK",cancel:"Cancel",dismiss:"Dismiss",zoomIn:"Zoom in",zoomOut:"Zoom out",wrapLines:"Wrap lines",objectTextBox:"Text box",objectChart:"Chart from Word. Kept as is.",objectDiagram:"Diagram from Word. Kept as is.",objectEquation:"Equation from Word. Kept as is.",objectPicture:"Picture from Word. Kept as is.",objectOther:"Object from Word. Kept as is.",objectField:"Field",discardMessage:"They haven't been saved.",discard:"Discard",keepEditing:"Keep editing",legacyDoc:".doc is the old Word format. Save it as .docx in Word first.",openedOldSave:"Opened as a document. Save it to get a Word file.",saveFailed:"The document could not be saved.",savedAsUtf8:"Saved as UTF-8: the original encoding can't be written from a browser.",dropHint:"Drop a document to open. Images insert into the page.",matchCount:(e,t)=>`${e} of ${t}`,replacedCount:e=>1===e?"1 replacement":`${e} replacements`,tableSize:(e,t)=>`${e} × ${t}`,pageLabel:e=>`Page ${e}`,pageOf:(e,t)=>`Page ${e} of ${t}`,wordCount:e=>1===e?"1 word":`${e.toLocaleString()} words`,lineColumn:(e,t)=>`Ln ${e}, Col ${t}`,lineCount:e=>1===e?"1 line":`${e.toLocaleString()} lines`,noticeComments:e=>1===e?"1 comment":`${e} comments`,noticeTracked:e=>1===e?"1 tracked change":`${e} tracked changes`,noticeObjects:e=>1===e?"1 object such as a text box":`${e} objects such as text boxes`,noticeFootnotes:e=>1===e?"1 footnote":`${e} footnotes`,noticeLead:e=>`Has ${e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]}. They stay in the file, but need Word to edit.`,discardTitle:e=>`Discard your changes to ${e}?`,cannotRead:e=>`${e} can't be opened. It may be damaged or password protected.`,unsupported:e=>`Unsupported file type: .${e||"unknown"}`},a={styleHeading4:"标题 4",styleHeading5:"标题 5",styleHeading6:"标题 6",applyStyle:e=>`应用“${e}”`,updateStyle:e=>`更新“${e}”以匹配所选内容`,styleUpdated:e=>`“${e}”现在与所选段落一致。`,paintFormat:"格式刷",paintFormatHint:"选择要应用此格式的文字。",checklist:"核对清单",paragraphSpacing:"行距和段落间距",addSpaceBefore:"在段前添加间距",removeSpaceBefore:"删除段前间距",addSpaceAfter:"在段后添加间距",removeSpaceAfter:"删除段后间距",customSpacing:"自定义间距和缩进",lineSpacingCustom:"行距(行)",spacingBefore:"段前(磅)",spacingAfter:"段后(磅)",indentLeft:"左缩进(磅)",indentRight:"右缩进(磅)",indentSpecial:"特殊缩进",indentNone:"无",indentFirstLine:"首行缩进",indentHanging:"悬挂缩进",indentBy:"缩进值(磅)",spacingInvalid:"请输入不小于 0 的数字,行距须在 0 到 10 之间。",ruler:"标尺",tabStop:"制表位",tabStopHint:"单击添加制表位。将制表位拖离标尺即可删除。双击可更改其对齐方式。",columns:"分栏",columnsCount:e=>1===e?"一栏":2===e?"两栏":`${e} 栏`,tableOfContents:"目录",tocRefresh:"更新目录",tocDelete:"删除目录",footnote:"脚注",footnotes:"脚注",footnotePlaceholder:"脚注文字",footnoteLocked:"此脚注包含文字以外的内容,因此保持原样。请在 Word 中编辑。",bookmark:"书签",bookmarkPrompt:"为书签命名。可使用字母、数字和下划线,须以字母开头。",bookmarkInvalid:"书签名称须以字母开头,且只能包含字母、数字和下划线。",bookmarkTaken:"已有同名书签。",linkToHeading:"链接到标题",linkToBookmark:"链接到书签",noHeadings:"尚无标题",noBookmarks:"尚无书签",breakMenu:"分隔符",sectionBreakNext:"分节符(下一页)",sectionBreakContinuous:"分节符(连续)",removeSectionBreak:"删除分节符",headersFooters:"页眉和页脚",headersFootersHint:"单击以编辑页眉和页脚",differentFirst:"首页不同",differentOddEven:"奇偶页不同",headerDefault:"所有页",headerOdd:"奇数页",headerFirst:"首页",headerEven:"偶数页",pageCount:"总页数",webFonts:"网络字体",wordFonts:"Word 字体",pdfPageFailed:e=>`第 ${e} 页无法绘制到 PDF。`,files:t,fileKind:"Word",backToFiles:"返回文件",filesHeading:"文档",newFile:"新建文档",openFile:"打开文件",filesEmptyTitle:"写下您的第一份文档",filesEmptyBody:"每次更改都会自动保存。",deleteFile:"删除",createFailed:"无法创建文档。",deleteFailed:"无法删除文档。",deleteConfirm:e=>`删除“${e}”?之后任何人都无法再打开它。`,documentName:"文档名称",documentPanel:"文档",pagePanel:"页面",outline:"大纲",outlineEmpty:"文档中的标题会显示在这里。",morePageSetup:"更多页面设置",export:"导出",renameFailed:"无法重命名文档。",openFailed:"无法打开此文档。",conflict:"其他人已保存此文档,您最近的更改尚未保存。请重新加载以查看他们的版本。",reload:"重新加载",noStoreEdited:"未保存。请导出以保留更改",noStoreClean:"此处不会自动保存。请导出以保留副本",openFromFiles:"请返回文件列表以打开其他文档。",untitled:"未命名",loading:"正在加载",newDocument:"新建",open:"打开",rename:"重命名",menuFile:"文件",menuInsert:"插入",menuLayout:"布局",save:"保存",saveDocx:"保存 (.docx)",saveKeepType:"保存",saveAs:"另存为",saveAsWord:"Word 文档 (.docx)",saveAsPdf:"PDF(通过打印对话框)",saveAsWeb:"网页 (.html)",saveAsText:"纯文本 (.txt)",print:"打印",undo:"撤销",redo:"重做",find:"查找",replaceWith:"替换为",replace:"替换",replaceAll:"全部替换",matchCase:"区分大小写",previousMatch:"上一个匹配项",nextMatch:"下一个匹配项",closeFind:"关闭查找",noMatches:"无匹配项",paragraphStyle:"段落样式",font:"字体",fontSize:"字号",bold:"加粗",italic:"倾斜",underline:"下划线",strikethrough:"删除线",superscript:"上标",subscript:"下标",textColor:"文字颜色",highlight:"突出显示颜色",clearFormatting:"清除格式",bulletedList:"项目符号列表",numberedList:"编号列表",decreaseIndent:"减少缩进",increaseIndent:"增加缩进",alignLeft:"左对齐",alignCenter:"居中",alignRight:"右对齐",justify:"两端对齐",lineSpacing:"行距",styleNormal:"正文",styleTitle:"标题",styleHeading1:"标题 1",styleHeading2:"标题 2",styleHeading3:"标题 3",styleQuote:"引用",table:"表格",image:"图片",link:"链接",linkPrompt:"输入网址;留空则移除链接。",linkInvalid:"该地址不能用作链接。",pageBreak:"分页符",pageNumber:"页码",horizontalLine:"水平线",rowAbove:"在上方插入行",rowBelow:"在下方插入行",columnLeft:"在左侧插入列",columnRight:"在右侧插入列",mergeCells:"合并单元格",mergeFailed:"无法合并这些单元格:所选范围会切开已合并的单元格。",cellShading:"单元格底纹",noColor:"无颜色",deleteRow:"删除行",deleteColumn:"删除列",deleteTable:"删除表格",imageWidth:"图片宽度",imageOriginalSize:"原始大小",imageRemove:"移除图片",pageSetup:"页面设置",paperSize:"纸张大小",paperLetter:"美国信纸",paperLegal:"美国法律用纸",custom:"自定义",orientation:"方向",portrait:"纵向",landscape:"横向",margins:"页边距",marginsNormal:"常规,2.54 厘米",marginsNarrow:"窄,1.27 厘米",marginsModerate:"中等,左右 1.91 厘米",marginsWide:"宽,左右 5.08 厘米",header:"页眉",footer:"页脚",headerFooterLocked:"此处包含图片或表格,因此保持原样。请在 Word 中编辑。",ok:"确定",cancel:"取消",dismiss:"关闭",zoomIn:"放大",zoomOut:"缩小",wrapLines:"自动换行",objectTextBox:"文本框",objectChart:"来自 Word 的图表,保持原样。",objectDiagram:"来自 Word 的示意图,保持原样。",objectEquation:"来自 Word 的公式,保持原样。",objectPicture:"来自 Word 的图片,保持原样。",objectOther:"来自 Word 的对象,保持原样。",objectField:"域",discardMessage:"这些更改尚未保存。",discard:"放弃",keepEditing:"继续编辑",legacyDoc:".doc 是旧版 Word 格式,请先在 Word 中另存为 .docx。",openedOldSave:"已作为文档打开。保存后即可得到 Word 文件。",saveFailed:"无法保存文档。",savedAsUtf8:"已保存为 UTF-8:浏览器无法写入原始编码。",dropHint:"拖放文档以打开;图片会插入页面。",matchCount:(e,t)=>`第 ${e} 个,共 ${t} 个`,replacedCount:e=>`已替换 ${e} 处`,tableSize:(e,t)=>`${e} × ${t}`,pageLabel:e=>`第 ${e} 页`,pageOf:(e,t)=>`第 ${e} 页,共 ${t} 页`,wordCount:e=>`${e.toLocaleString()} 字`,lineColumn:(e,t)=>`第 ${e} 行,第 ${t} 列`,lineCount:e=>`${e.toLocaleString()} 行`,noticeComments:e=>`${e} 条批注`,noticeTracked:e=>`${e} 处修订`,noticeObjects:e=>`${e} 个文本框等对象`,noticeFootnotes:e=>`${e} 条脚注`,noticeLead:e=>`包含 ${e.join("、")}。它们会保留在文件中,但需要在 Word 中编辑。`,discardTitle:e=>`放弃对 ${e} 的更改?`,cannotRead:e=>`无法打开 ${e}。文件可能已损坏或受密码保护。`,unsupported:e=>`不支持的文件类型:.${e||"未知"}`};export{o as ENGLISH_WORDS,a as ZH_HANS_WORDS};