@eigenpal/docx-js-editor 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClipboardManager-D0D4aUKE.d.ts → ClipboardManager-C0rTRkVQ.d.ts} +29 -1
- package/dist/{ClipboardManager-t936d0KD.d.mts → ClipboardManager-CgpKW2At.d.mts} +29 -1
- package/dist/PageSetupDialog-2SKHDRTF.js +1 -0
- package/dist/PageSetupDialog-SMQJXEBL.mjs +1 -0
- package/dist/{chunk-MRWJ3GNH.js → chunk-3Y6ZBC3P.js} +2 -2
- package/dist/{chunk-YGTSQZRK.mjs → chunk-6CSL7T4S.mjs} +1 -1
- package/dist/chunk-A2DPBJHE.mjs +258 -0
- package/dist/chunk-CQR767EJ.mjs +1 -0
- package/dist/{chunk-IRO7KGGC.js → chunk-DJI7XTMH.js} +2 -2
- package/dist/{chunk-Z35FA4M4.mjs → chunk-FFNGY4AB.mjs} +5 -5
- package/dist/chunk-HIITS47V.js +258 -0
- package/dist/{chunk-VHWEKJ35.js → chunk-N2UPYG75.js} +5 -5
- package/dist/{chunk-VR6PT4IZ.js → chunk-NKJBKWYY.js} +13 -13
- package/dist/{chunk-CQRI4YUS.mjs → chunk-OBTGZZLM.mjs} +13 -13
- package/dist/{chunk-I6LFWQFR.mjs → chunk-TQATISQV.mjs} +1 -1
- package/dist/chunk-ZKKL54FH.js +1 -0
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.mjs +1 -1
- package/dist/core-reexport.d.mts +2 -2
- package/dist/core-reexport.d.ts +2 -2
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.mjs +1 -1
- package/dist/headless-reexport.js +2 -2
- package/dist/headless-reexport.mjs +1 -1
- package/dist/index.d.mts +10 -27
- package/dist/index.d.ts +10 -27
- package/dist/index.js +23 -66
- package/dist/index.mjs +23 -66
- package/dist/mcp-reexport.js +10 -10
- package/dist/mcp-reexport.mjs +8 -8
- package/dist/{react-C-pJU0Y4.d.mts → react-B2h6vE3D.d.mts} +118 -83
- package/dist/{react-By80Gfi-.d.ts → react-CAc4htNH.d.ts} +118 -83
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/selectionRects-D45BP6HQ.js +1 -0
- package/dist/selectionRects-Z72BKRLU.mjs +1 -0
- package/package.json +1 -1
- package/dist/PageSetupDialog-3QCVUNDL.mjs +0 -1
- package/dist/PageSetupDialog-ZZTFPZKJ.js +0 -1
- package/dist/chunk-G72SXG7G.js +0 -258
- package/dist/chunk-MVCTPHRR.mjs +0 -258
- package/dist/chunk-QQ63M65M.js +0 -1
- package/dist/chunk-TDEHAPMZ.mjs +0 -1
- package/dist/selectionRects-6TRAXB7D.js +0 -1
- package/dist/selectionRects-IS7ZAS3A.mjs +0 -1
|
@@ -148,6 +148,34 @@ interface EditorPluginCore<TState = any> {
|
|
|
148
148
|
*/
|
|
149
149
|
styles?: string;
|
|
150
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* A sidebar item anchored to a document position.
|
|
153
|
+
* Framework adapters extend this with rendering capabilities.
|
|
154
|
+
*/
|
|
155
|
+
interface SidebarItem {
|
|
156
|
+
/** Unique ID for this item (used as React key and for overlap resolution). */
|
|
157
|
+
id: string;
|
|
158
|
+
/** ProseMirror document position this item anchors to. */
|
|
159
|
+
anchorPos: number;
|
|
160
|
+
/** Optional key into the anchorPositions Map (e.g. "comment-42", "revision-7"). */
|
|
161
|
+
anchorKey?: string;
|
|
162
|
+
/** Sort priority within items at the same anchor Y. Lower = first. Default: 0. */
|
|
163
|
+
priority?: number;
|
|
164
|
+
/** Temporary items (e.g. "add comment" input) skip entrance animation. */
|
|
165
|
+
isTemporary?: boolean;
|
|
166
|
+
/** Pre-computed Y position (scroll-container coords, pre-zoom). Overrides anchor resolution. */
|
|
167
|
+
fixedY?: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Context provided to plugins when computing sidebar items.
|
|
171
|
+
*/
|
|
172
|
+
interface SidebarItemContext {
|
|
173
|
+
editorView: EditorView | null;
|
|
174
|
+
renderedDomContext: RenderedDomContext | null;
|
|
175
|
+
/** Pre-computed Y positions from layout engine (keys like "comment-{id}"). */
|
|
176
|
+
anchorPositions: Map<string, number>;
|
|
177
|
+
zoom: number;
|
|
178
|
+
}
|
|
151
179
|
|
|
152
180
|
/**
|
|
153
181
|
* Subscribable Base Class
|
|
@@ -433,4 +461,4 @@ declare function getSelectionRuns(): Run[];
|
|
|
433
461
|
declare function createSelectionFromDOM(): ClipboardSelection | null;
|
|
434
462
|
declare const rgbToHex: typeof cssColorToHex;
|
|
435
463
|
|
|
436
|
-
export { AutoSaveManager as A, rgbToHex as B, type CellCoordinates as C, updateTableInDocument as D, type ErrorManagerSnapshot as E, type PluginLifecycleSnapshot as P, type RenderedDomContext as R, Subscribable as S, TABLE_DATA_ATTRIBUTES as T, type PluginLifecycleConfig as a, type AutoSaveManagerOptions as b, type AutoSaveSnapshot as c, type AutoSaveStatus as d, type ClipboardSelection as e, type EditorHandle as f, type EditorPluginCore as g, type ErrorNotification as h, type ErrorSeverity as i, type PanelConfig as j, type PluginPanelProps as k, type PositionCoordinates as l, type SavedDocumentData as m, TableSelectionManager as n, type TableSelectionSnapshot as o, createSelectionFromDOM as p, deleteTableFromDocument as q, extractFormattingFromElement as r, findTableFromClick as s, formatLastSaveTime as t, formatStorageSize as u, getAutoSaveStatusLabel as v, getAutoSaveStorageSize as w, getSelectionRuns as x, getTableFromDocument as y, isAutoSaveSupported as z };
|
|
464
|
+
export { AutoSaveManager as A, rgbToHex as B, type CellCoordinates as C, updateTableInDocument as D, type ErrorManagerSnapshot as E, type SidebarItem as F, type SidebarItemContext as G, type PluginLifecycleSnapshot as P, type RenderedDomContext as R, Subscribable as S, TABLE_DATA_ATTRIBUTES as T, type PluginLifecycleConfig as a, type AutoSaveManagerOptions as b, type AutoSaveSnapshot as c, type AutoSaveStatus as d, type ClipboardSelection as e, type EditorHandle as f, type EditorPluginCore as g, type ErrorNotification as h, type ErrorSeverity as i, type PanelConfig as j, type PluginPanelProps as k, type PositionCoordinates as l, type SavedDocumentData as m, TableSelectionManager as n, type TableSelectionSnapshot as o, createSelectionFromDOM as p, deleteTableFromDocument as q, extractFormattingFromElement as r, findTableFromClick as s, formatLastSaveTime as t, formatStorageSize as u, getAutoSaveStatusLabel as v, getAutoSaveStorageSize as w, getSelectionRuns as x, getTableFromDocument as y, isAutoSaveSupported as z };
|
|
@@ -148,6 +148,34 @@ interface EditorPluginCore<TState = any> {
|
|
|
148
148
|
*/
|
|
149
149
|
styles?: string;
|
|
150
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* A sidebar item anchored to a document position.
|
|
153
|
+
* Framework adapters extend this with rendering capabilities.
|
|
154
|
+
*/
|
|
155
|
+
interface SidebarItem {
|
|
156
|
+
/** Unique ID for this item (used as React key and for overlap resolution). */
|
|
157
|
+
id: string;
|
|
158
|
+
/** ProseMirror document position this item anchors to. */
|
|
159
|
+
anchorPos: number;
|
|
160
|
+
/** Optional key into the anchorPositions Map (e.g. "comment-42", "revision-7"). */
|
|
161
|
+
anchorKey?: string;
|
|
162
|
+
/** Sort priority within items at the same anchor Y. Lower = first. Default: 0. */
|
|
163
|
+
priority?: number;
|
|
164
|
+
/** Temporary items (e.g. "add comment" input) skip entrance animation. */
|
|
165
|
+
isTemporary?: boolean;
|
|
166
|
+
/** Pre-computed Y position (scroll-container coords, pre-zoom). Overrides anchor resolution. */
|
|
167
|
+
fixedY?: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Context provided to plugins when computing sidebar items.
|
|
171
|
+
*/
|
|
172
|
+
interface SidebarItemContext {
|
|
173
|
+
editorView: EditorView | null;
|
|
174
|
+
renderedDomContext: RenderedDomContext | null;
|
|
175
|
+
/** Pre-computed Y positions from layout engine (keys like "comment-{id}"). */
|
|
176
|
+
anchorPositions: Map<string, number>;
|
|
177
|
+
zoom: number;
|
|
178
|
+
}
|
|
151
179
|
|
|
152
180
|
/**
|
|
153
181
|
* Subscribable Base Class
|
|
@@ -433,4 +461,4 @@ declare function getSelectionRuns(): Run[];
|
|
|
433
461
|
declare function createSelectionFromDOM(): ClipboardSelection | null;
|
|
434
462
|
declare const rgbToHex: typeof cssColorToHex;
|
|
435
463
|
|
|
436
|
-
export { AutoSaveManager as A, rgbToHex as B, type CellCoordinates as C, updateTableInDocument as D, type ErrorManagerSnapshot as E, type PluginLifecycleSnapshot as P, type RenderedDomContext as R, Subscribable as S, TABLE_DATA_ATTRIBUTES as T, type PluginLifecycleConfig as a, type AutoSaveManagerOptions as b, type AutoSaveSnapshot as c, type AutoSaveStatus as d, type ClipboardSelection as e, type EditorHandle as f, type EditorPluginCore as g, type ErrorNotification as h, type ErrorSeverity as i, type PanelConfig as j, type PluginPanelProps as k, type PositionCoordinates as l, type SavedDocumentData as m, TableSelectionManager as n, type TableSelectionSnapshot as o, createSelectionFromDOM as p, deleteTableFromDocument as q, extractFormattingFromElement as r, findTableFromClick as s, formatLastSaveTime as t, formatStorageSize as u, getAutoSaveStatusLabel as v, getAutoSaveStorageSize as w, getSelectionRuns as x, getTableFromDocument as y, isAutoSaveSupported as z };
|
|
464
|
+
export { AutoSaveManager as A, rgbToHex as B, type CellCoordinates as C, updateTableInDocument as D, type ErrorManagerSnapshot as E, type SidebarItem as F, type SidebarItemContext as G, type PluginLifecycleSnapshot as P, type RenderedDomContext as R, Subscribable as S, TABLE_DATA_ATTRIBUTES as T, type PluginLifecycleConfig as a, type AutoSaveManagerOptions as b, type AutoSaveSnapshot as c, type AutoSaveStatus as d, type ClipboardSelection as e, type EditorHandle as f, type EditorPluginCore as g, type ErrorNotification as h, type ErrorSeverity as i, type PanelConfig as j, type PluginPanelProps as k, type PositionCoordinates as l, type SavedDocumentData as m, TableSelectionManager as n, type TableSelectionSnapshot as o, createSelectionFromDOM as p, deleteTableFromDocument as q, extractFormattingFromElement as r, findTableFromClick as s, formatLastSaveTime as t, formatStorageSize as u, getAutoSaveStatusLabel as v, getAutoSaveStorageSize as w, getSelectionRuns as x, getTableFromDocument as y, isAutoSaveSupported as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';require('./chunk-SE5EN2QL.js'),require('./chunk-H5NTJZO4.js');var react=require('react'),jsxRuntime=require('react/jsx-runtime');var I=[{label:'Letter (8.5" \xD7 11")',width:12240,height:15840},{label:'A4 (8.27" \xD7 11.69")',width:11906,height:16838},{label:'Legal (8.5" \xD7 14")',width:12240,height:20160},{label:'A3 (11.69" \xD7 16.54")',width:16838,height:23811},{label:'A5 (5.83" \xD7 8.27")',width:8391,height:11906},{label:'B5 (6.93" \xD7 9.84")',width:9979,height:14175},{label:'Executive (7.25" \xD7 10.5")',width:10440,height:15120}];function v(i){return Math.round(i/1440*100)/100}function f(i){return Math.round(i*1440)}function O(i,a){let h=Math.min(i,a),n=Math.max(i,a);return I.findIndex(l=>Math.abs(l.width-h)<20&&Math.abs(l.height-n)<20)}var Z={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},q={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:400,maxWidth:480,width:"100%",margin:20},J={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},Q={padding:"16px 20px",display:"flex",flexDirection:"column",gap:14},A={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},c={display:"flex",alignItems:"center",gap:12},g={width:80,fontSize:13,color:"var(--doc-text-muted)"},b={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13},W={...b},x={fontSize:11,color:"var(--doc-text-muted)",width:16},V={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},H={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"},N=12240,B=15840,s=1440;function $({isOpen:i,onClose:a,onApply:h,currentProps:n}){let[l,y]=react.useState(N),[u,m]=react.useState(B),[p,M]=react.useState("portrait"),[C,R]=react.useState(s),[P,z]=react.useState(s),[w,k]=react.useState(s),[T,D]=react.useState(s);react.useEffect(()=>{if(!i)return;let e=n?.pageWidth||N,r=n?.pageHeight||B,K=n?.orientation||(e>r?"landscape":"portrait");y(e),m(r),M(K),R(n?.marginTop??s),z(n?.marginBottom??s),k(n?.marginLeft??s),D(n?.marginRight??s);},[i,n]);let _=react.useCallback(e=>{if(e<0)return;let r=I[e];p==="landscape"?(y(r.height),m(r.width)):(y(r.width),m(r.height));},[p]),F=react.useCallback(e=>{e!==p&&(M(e),y(u),m(l));},[p,l,u]),E=react.useCallback(()=>{h({pageWidth:l,pageHeight:u,orientation:p,marginTop:C,marginBottom:P,marginLeft:w,marginRight:T}),a();},[l,u,p,C,P,w,T,h,a]),G=react.useCallback(e=>{e.key==="Escape"&&a(),e.key==="Enter"&&E();},[a,E]);if(!i)return null;let L=O(l,u);return jsxRuntime.jsx("div",{style:Z,onClick:a,onKeyDown:G,children:jsxRuntime.jsxs("div",{style:q,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),role:"dialog","aria-label":"Page setup",children:[jsxRuntime.jsx("div",{style:J,children:"Page Setup"}),jsxRuntime.jsxs("div",{style:Q,children:[jsxRuntime.jsx("div",{style:A,children:"Page Size"}),jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("label",{style:g,children:"Size"}),jsxRuntime.jsxs("select",{style:W,value:L,onChange:e=>_(Number(e.target.value)),children:[I.map((e,r)=>jsxRuntime.jsx("option",{value:r,children:e.label},e.label)),L<0&&jsxRuntime.jsx("option",{value:-1,children:"Custom"})]})]}),jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("label",{style:g,children:"Orientation"}),jsxRuntime.jsxs("select",{style:W,value:p,onChange:e=>F(e.target.value),children:[jsxRuntime.jsx("option",{value:"portrait",children:"Portrait"}),jsxRuntime.jsx("option",{value:"landscape",children:"Landscape"})]})]}),jsxRuntime.jsx("div",{style:{...A,marginTop:4},children:"Margins"}),jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("label",{style:g,children:"Top"}),jsxRuntime.jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(C),onChange:e=>R(f(Number(e.target.value)||0))}),jsxRuntime.jsx("span",{style:x,children:"in"})]}),jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("label",{style:g,children:"Bottom"}),jsxRuntime.jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(P),onChange:e=>z(f(Number(e.target.value)||0))}),jsxRuntime.jsx("span",{style:x,children:"in"})]}),jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("label",{style:g,children:"Left"}),jsxRuntime.jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(w),onChange:e=>k(f(Number(e.target.value)||0))}),jsxRuntime.jsx("span",{style:x,children:"in"})]}),jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("label",{style:g,children:"Right"}),jsxRuntime.jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(T),onChange:e=>D(f(Number(e.target.value)||0))}),jsxRuntime.jsx("span",{style:x,children:"in"})]})]}),jsxRuntime.jsxs("div",{style:V,children:[jsxRuntime.jsx("button",{type:"button",style:H,onClick:a,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",style:{...H,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)"},onClick:E,children:"Apply"})]})]})})}exports.PageSetupDialog=$;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-LYBG4YI7.mjs';import'./chunk-TAUMSKRE.mjs';import {useState,useEffect,useCallback}from'react';import {jsx,jsxs}from'react/jsx-runtime';var I=[{label:'Letter (8.5" \xD7 11")',width:12240,height:15840},{label:'A4 (8.27" \xD7 11.69")',width:11906,height:16838},{label:'Legal (8.5" \xD7 14")',width:12240,height:20160},{label:'A3 (11.69" \xD7 16.54")',width:16838,height:23811},{label:'A5 (5.83" \xD7 8.27")',width:8391,height:11906},{label:'B5 (6.93" \xD7 9.84")',width:9979,height:14175},{label:'Executive (7.25" \xD7 10.5")',width:10440,height:15120}];function v(i){return Math.round(i/1440*100)/100}function f(i){return Math.round(i*1440)}function O(i,a){let h=Math.min(i,a),n=Math.max(i,a);return I.findIndex(l=>Math.abs(l.width-h)<20&&Math.abs(l.height-n)<20)}var Z={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},q={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:400,maxWidth:480,width:"100%",margin:20},J={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},Q={padding:"16px 20px",display:"flex",flexDirection:"column",gap:14},A={fontSize:12,fontWeight:600,color:"var(--doc-text-muted)",textTransform:"uppercase",letterSpacing:"0.5px"},c={display:"flex",alignItems:"center",gap:12},g={width:80,fontSize:13,color:"var(--doc-text-muted)"},b={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13},W={...b},x={fontSize:11,color:"var(--doc-text-muted)",width:16},V={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},H={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"},N=12240,B=15840,s=1440;function $({isOpen:i,onClose:a,onApply:h,currentProps:n}){let[l,y]=useState(N),[u,m]=useState(B),[p,M]=useState("portrait"),[C,R]=useState(s),[P,z]=useState(s),[w,k]=useState(s),[T,D]=useState(s);useEffect(()=>{if(!i)return;let e=n?.pageWidth||N,r=n?.pageHeight||B,K=n?.orientation||(e>r?"landscape":"portrait");y(e),m(r),M(K),R(n?.marginTop??s),z(n?.marginBottom??s),k(n?.marginLeft??s),D(n?.marginRight??s);},[i,n]);let _=useCallback(e=>{if(e<0)return;let r=I[e];p==="landscape"?(y(r.height),m(r.width)):(y(r.width),m(r.height));},[p]),F=useCallback(e=>{e!==p&&(M(e),y(u),m(l));},[p,l,u]),E=useCallback(()=>{h({pageWidth:l,pageHeight:u,orientation:p,marginTop:C,marginBottom:P,marginLeft:w,marginRight:T}),a();},[l,u,p,C,P,w,T,h,a]),G=useCallback(e=>{e.key==="Escape"&&a(),e.key==="Enter"&&E();},[a,E]);if(!i)return null;let L=O(l,u);return jsx("div",{style:Z,onClick:a,onKeyDown:G,children:jsxs("div",{style:q,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),role:"dialog","aria-label":"Page setup",children:[jsx("div",{style:J,children:"Page Setup"}),jsxs("div",{style:Q,children:[jsx("div",{style:A,children:"Page Size"}),jsxs("div",{style:c,children:[jsx("label",{style:g,children:"Size"}),jsxs("select",{style:W,value:L,onChange:e=>_(Number(e.target.value)),children:[I.map((e,r)=>jsx("option",{value:r,children:e.label},e.label)),L<0&&jsx("option",{value:-1,children:"Custom"})]})]}),jsxs("div",{style:c,children:[jsx("label",{style:g,children:"Orientation"}),jsxs("select",{style:W,value:p,onChange:e=>F(e.target.value),children:[jsx("option",{value:"portrait",children:"Portrait"}),jsx("option",{value:"landscape",children:"Landscape"})]})]}),jsx("div",{style:{...A,marginTop:4},children:"Margins"}),jsxs("div",{style:c,children:[jsx("label",{style:g,children:"Top"}),jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(C),onChange:e=>R(f(Number(e.target.value)||0))}),jsx("span",{style:x,children:"in"})]}),jsxs("div",{style:c,children:[jsx("label",{style:g,children:"Bottom"}),jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(P),onChange:e=>z(f(Number(e.target.value)||0))}),jsx("span",{style:x,children:"in"})]}),jsxs("div",{style:c,children:[jsx("label",{style:g,children:"Left"}),jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(w),onChange:e=>k(f(Number(e.target.value)||0))}),jsx("span",{style:x,children:"in"})]}),jsxs("div",{style:c,children:[jsx("label",{style:g,children:"Right"}),jsx("input",{type:"number",style:b,min:0,max:10,step:.1,value:v(T),onChange:e=>D(f(Number(e.target.value)||0))}),jsx("span",{style:x,children:"in"})]})]}),jsxs("div",{style:V,children:[jsx("button",{type:"button",style:H,onClick:a,children:"Cancel"}),jsx("button",{type:"button",style:{...H,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)"},onClick:E,children:"Apply"})]})]})})}export{$ as PageSetupDialog};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var chunkVHWEKJ35_js=require('./chunk-VHWEKJ35.js'),chunkIRO7KGGC_js=require('./chunk-IRO7KGGC.js'),chunkAARNCPWR_js=require('./chunk-AARNCPWR.js'),chunkVR6PT4IZ_js=require('./chunk-VR6PT4IZ.js'),chunkH5NTJZO4_js=require('./chunk-H5NTJZO4.js');function G(r,t){let e=et(t),n=new RegExp(`<w:p[\\s][^>]*w14:paraId="${e}"`,"g"),a=[],o;for(;(o=n.exec(r))!==null;)a.push(o.index);if(a.length===0||a.length>1)return null;let s=a[0],i=s,c=0;for(;i<r.length;){let l=r.indexOf("<",i);if(l===-1)break;if(r.startsWith("<w:p",l)){let u=r[l+4];if(u===">"||u===" "||u==="/"){let g=r.indexOf(">",l);if(g===-1)break;if(r[g-1]==="/"){if(c===0)return {start:s,end:g+1};i=g+1;}else c++,i=g+1;}else i=l+1;}else if(r.startsWith("</w:p>",l)){if(c--,c===0)return {start:s,end:l+6};i=l+6;}else i=l+1;}return null}function Q(r,t){let e=G(r,t);return e?r.substring(e.start,e.end):null}function q(r){let t=0,e=/<w:p[\s>]/g,n;for(;(n=e.exec(r))!==null;){let a=n.index,o=r[a+4];(o===">"||o===" ")&&t++;}return t}function X(r){let t=new Map,e=/w14:paraId="([^"]+)"/g,n;for(;(n=e.exec(r))!==null;){let a=n[1];t.set(a,(t.get(a)||0)+1);}return t}function tt(r,t,e){if(e.size===0)return {safe:true};let n=X(r),a=X(t);for(let i of e){let c=n.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-original: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-original: ${i}`}}for(let i of e){let c=a.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-serialized: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-serialized: ${i}`}}let o=q(r),s=q(t);return o!==s?{safe:false,reason:`paragraph-count-mismatch: original=${o}, serialized=${s}`}:{safe:true}}function Z(r,t,e){if(e.size===0)return r;if(!tt(r,t,e).safe)return null;let a=[];for(let s of e){let i=G(r,s);if(!i)return null;let c=Q(t,s);if(!c)return null;a.push({start:i.start,end:i.end,newXml:c});}a.sort((s,i)=>i.start-s.start);let o=r;for(let{start:s,end:i,newXml:c}of a)o=o.substring(0,s)+c+o.substring(i);return o}function et(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function J(r){for(let t of r)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing"&&n.image?.src?.startsWith("data:")&&!n.image?.rId)return true}else if(e.type==="hyperlink"&&e.href&&!e.rId&&!e.anchor)return true}else if(t.type==="table"){for(let e of t.rows)for(let n of e.cells)if(J(n.content))return true}return false}async function Y(r,t,e){let{changedParaIds:n,structuralChange:a,hasUntrackedChanges:o}=e;if(a||o||!t)return null;let s=r.package.document.content;if(J(s))return null;let i=r.package.document.comments,c=i&&i.length>0,l=chunkIRO7KGGC_js.j(r);try{let g=await(await import('./lib-U35UU4OU.js')).default.loadAsync(t),f=new Map;if(n.size>0){let p=g.file("word/document.xml");if(!p)return null;let m=await p.async("text"),b=chunkIRO7KGGC_js.c(r),d=Z(m,b,n);if(!d)return null;f.set("word/document.xml",d);}if(c){f.set("word/comments.xml",chunkIRO7KGGC_js.d(i));let p=g.file("[Content_Types].xml");if(p){let d=await p.async("text");d.includes("/word/comments.xml")||f.set("[Content_Types].xml",d.replace("</Types>",`<Override PartName="/word/comments.xml" ContentType="${chunkIRO7KGGC_js.g}"/></Types>`));}let m="word/_rels/document.xml.rels",b=g.file(m);if(b){let d=await b.async("text");if(!d.includes("comments.xml")){let x=chunkIRO7KGGC_js.e(d);f.set(m,d.replace("</Relationships>",`<Relationship Id="rId${x+1}" Type="${chunkVR6PT4IZ_js.a.comments}" Target="comments.xml"/></Relationships>`));}}}for(let[p,m]of l)f.set(p,m);let y=g.file("docProps/core.xml");if(y){let p=await y.async("text");f.set("docProps/core.xml",chunkIRO7KGGC_js.k(p,{updateModifiedDate:!0}));}return await chunkIRO7KGGC_js.i(g,f)}catch{return null}}function nt(){return [{styleId:"Normal",type:"paragraph",name:"Normal",default:true,qFormat:true,uiPriority:0,rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},{styleId:"Title",type:"paragraph",name:"Title",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:10,rPr:{fontSize:52,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Subtitle",type:"paragraph",name:"Subtitle",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:11,rPr:{fontSize:30,color:{rgb:"666666"},fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Heading1",type:"paragraph",name:"Heading 1",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:40,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:400,spaceAfter:120,lineSpacing:240}},{styleId:"Heading2",type:"paragraph",name:"Heading 2",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:32,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:360,spaceAfter:80,lineSpacing:240}},{styleId:"Heading3",type:"paragraph",name:"Heading 3",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:28,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:320,spaceAfter:80,lineSpacing:240}},{styleId:"Heading4",type:"paragraph",name:"Heading 4",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:24,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:280,spaceAfter:80,lineSpacing:240}}]}function rt(){return {pageWidth:12240,pageHeight:15840,orientation:"portrait",marginTop:1440,marginBottom:1440,marginLeft:1440,marginRight:1440,headerDistance:720,footerDistance:720,gutter:0,columnCount:1,columnSpace:720,equalWidth:true,sectionStart:"nextPage",verticalAlign:"top"}}function at(r={}){let t=rt();r.pageWidth!==void 0&&(t.pageWidth=r.pageWidth),r.pageHeight!==void 0&&(t.pageHeight=r.pageHeight),r.orientation!==void 0&&(t.orientation=r.orientation),r.marginTop!==void 0&&(t.marginTop=r.marginTop),r.marginBottom!==void 0&&(t.marginBottom=r.marginBottom),r.marginLeft!==void 0&&(t.marginLeft=r.marginLeft),r.marginRight!==void 0&&(t.marginRight=r.marginRight);let e={type:"text",text:r.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:r.initialText?[e]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:t},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:nt()}},templateVariables:[],warnings:[]}}function Wt(r,t={}){return at({...t,initialText:r})}var T=class r{constructor(t){chunkH5NTJZO4_js.d(this,"_document");chunkH5NTJZO4_js.d(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await chunkVR6PT4IZ_js.n(t);return new r(e)}static fromDocument(t){return new r(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return chunkVHWEKJ35_js.a(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(s=>s.type==="paragraph"),a=n.map((s,i)=>{let c=this._getParagraphText(s),l=s.formatting?.styleId;return {index:i,preview:c.slice(0,t),style:l,isHeading:l?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(l),isListItem:!!s.listRendering,isEmpty:c.trim().length===0}}),o=(e.sections||[]).map((s,i)=>({index:i,paragraphCount:s.content?.length||0,pageSize:s.properties?.pageWidth&&s.properties?.pageHeight?{width:s.properties.pageWidth,height:s.properties.pageHeight}:void 0,isLandscape:s.properties?.orientation==="landscape",hasHeader:!!s.properties?.headerReferences?.length,hasFooter:!!s.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let a={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(a)}replaceRange(t,e,n={}){let a={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,a={}){let o={type:"insertTable",position:t,rows:e,columns:n,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,n={}){let a={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(a)}insertHyperlink(t,e,n={}){let a={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(a)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n=this._document.originalBuffer;if(!n)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:a}=await import('./processTemplate-5ZST2Q5L.js'),o=a(n,e),s=await chunkVR6PT4IZ_js.n(o),i=new r(s);return i._pendingVariables={},i}async toBuffer(t){if(this._document.originalBuffer){if(t?.selective){let n=await Y(this._document,this._document.originalBuffer,t.selective);if(n)return this._document.originalBuffer=n,n}let e=await chunkIRO7KGGC_js.f(this._document);return this._document.originalBuffer=e,e}return chunkIRO7KGGC_js.l(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){return new r(chunkAARNCPWR_js.b(this._document,t))}_executeCommand(t){let e=new r(chunkAARNCPWR_js.a(this._document,t));return e._pendingVariables={...this._pendingVariables},e}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
|
|
2
|
-
`)}_getParagraphText(t){let e=[];for(let n of t.content)n.type==="run"?e.push(this._getRunText(n)):n.type==="hyperlink"&&e.push(this._getHyperlinkText(n));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(this._getRunText(n));return e.join("")}_getTableText(t){let e=[];for(let n of t.rows)for(let a of n.cells)for(let o of a.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let a=this._getRunText(n);a&&e.push({text:a,formatting:n.formatting});}else if(n.type==="hyperlink"){let a=n.href||"";for(let o of n.children)if(o.type==="run"){let s=this._getRunText(o);s&&e.push({text:s,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:a});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let a of n.content)if(a.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}};async function Gt(r){return T.fromBuffer(r)}function Zt(r){return T.fromDocument(r)}function ot(r,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:n=50}=t,a=r.package.document,o=a.content.filter(m=>m.type==="paragraph"),s=it(o,e,n),i=
|
|
1
|
+
'use strict';var chunkN2UPYG75_js=require('./chunk-N2UPYG75.js'),chunkDJI7XTMH_js=require('./chunk-DJI7XTMH.js'),chunkAARNCPWR_js=require('./chunk-AARNCPWR.js'),chunkNKJBKWYY_js=require('./chunk-NKJBKWYY.js'),chunkH5NTJZO4_js=require('./chunk-H5NTJZO4.js');function G(r,t){let e=et(t),n=new RegExp(`<w:p[\\s][^>]*w14:paraId="${e}"`,"g"),a=[],o;for(;(o=n.exec(r))!==null;)a.push(o.index);if(a.length===0||a.length>1)return null;let s=a[0],i=s,c=0;for(;i<r.length;){let l=r.indexOf("<",i);if(l===-1)break;if(r.startsWith("<w:p",l)){let u=r[l+4];if(u===">"||u===" "||u==="/"){let g=r.indexOf(">",l);if(g===-1)break;if(r[g-1]==="/"){if(c===0)return {start:s,end:g+1};i=g+1;}else c++,i=g+1;}else i=l+1;}else if(r.startsWith("</w:p>",l)){if(c--,c===0)return {start:s,end:l+6};i=l+6;}else i=l+1;}return null}function Q(r,t){let e=G(r,t);return e?r.substring(e.start,e.end):null}function q(r){let t=0,e=/<w:p[\s>]/g,n;for(;(n=e.exec(r))!==null;){let a=n.index,o=r[a+4];(o===">"||o===" ")&&t++;}return t}function X(r){let t=new Map,e=/w14:paraId="([^"]+)"/g,n;for(;(n=e.exec(r))!==null;){let a=n[1];t.set(a,(t.get(a)||0)+1);}return t}function tt(r,t,e){if(e.size===0)return {safe:true};let n=X(r),a=X(t);for(let i of e){let c=n.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-original: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-original: ${i}`}}for(let i of e){let c=a.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-serialized: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-serialized: ${i}`}}let o=q(r),s=q(t);return o!==s?{safe:false,reason:`paragraph-count-mismatch: original=${o}, serialized=${s}`}:{safe:true}}function Z(r,t,e){if(e.size===0)return r;if(!tt(r,t,e).safe)return null;let a=[];for(let s of e){let i=G(r,s);if(!i)return null;let c=Q(t,s);if(!c)return null;a.push({start:i.start,end:i.end,newXml:c});}a.sort((s,i)=>i.start-s.start);let o=r;for(let{start:s,end:i,newXml:c}of a)o=o.substring(0,s)+c+o.substring(i);return o}function et(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function J(r){for(let t of r)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing"&&n.image?.src?.startsWith("data:")&&!n.image?.rId)return true}else if(e.type==="hyperlink"&&e.href&&!e.rId&&!e.anchor)return true}else if(t.type==="table"){for(let e of t.rows)for(let n of e.cells)if(J(n.content))return true}return false}async function Y(r,t,e){let{changedParaIds:n,structuralChange:a,hasUntrackedChanges:o}=e;if(a||o||!t)return null;let s=r.package.document.content;if(J(s))return null;let i=r.package.document.comments,c=i&&i.length>0,l=chunkDJI7XTMH_js.j(r);try{let g=await(await import('./lib-U35UU4OU.js')).default.loadAsync(t),f=new Map;if(n.size>0){let p=g.file("word/document.xml");if(!p)return null;let m=await p.async("text"),b=chunkDJI7XTMH_js.c(r),d=Z(m,b,n);if(!d)return null;f.set("word/document.xml",d);}if(c){f.set("word/comments.xml",chunkDJI7XTMH_js.d(i));let p=g.file("[Content_Types].xml");if(p){let d=await p.async("text");d.includes("/word/comments.xml")||f.set("[Content_Types].xml",d.replace("</Types>",`<Override PartName="/word/comments.xml" ContentType="${chunkDJI7XTMH_js.g}"/></Types>`));}let m="word/_rels/document.xml.rels",b=g.file(m);if(b){let d=await b.async("text");if(!d.includes("comments.xml")){let x=chunkDJI7XTMH_js.e(d);f.set(m,d.replace("</Relationships>",`<Relationship Id="rId${x+1}" Type="${chunkNKJBKWYY_js.a.comments}" Target="comments.xml"/></Relationships>`));}}}for(let[p,m]of l)f.set(p,m);let y=g.file("docProps/core.xml");if(y){let p=await y.async("text");f.set("docProps/core.xml",chunkDJI7XTMH_js.k(p,{updateModifiedDate:!0}));}return await chunkDJI7XTMH_js.i(g,f)}catch{return null}}function nt(){return [{styleId:"Normal",type:"paragraph",name:"Normal",default:true,qFormat:true,uiPriority:0,rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},{styleId:"Title",type:"paragraph",name:"Title",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:10,rPr:{fontSize:52,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Subtitle",type:"paragraph",name:"Subtitle",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:11,rPr:{fontSize:30,color:{rgb:"666666"},fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Heading1",type:"paragraph",name:"Heading 1",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:40,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:400,spaceAfter:120,lineSpacing:240}},{styleId:"Heading2",type:"paragraph",name:"Heading 2",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:32,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:360,spaceAfter:80,lineSpacing:240}},{styleId:"Heading3",type:"paragraph",name:"Heading 3",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:28,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:320,spaceAfter:80,lineSpacing:240}},{styleId:"Heading4",type:"paragraph",name:"Heading 4",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:24,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:280,spaceAfter:80,lineSpacing:240}}]}function rt(){return {pageWidth:12240,pageHeight:15840,orientation:"portrait",marginTop:1440,marginBottom:1440,marginLeft:1440,marginRight:1440,headerDistance:720,footerDistance:720,gutter:0,columnCount:1,columnSpace:720,equalWidth:true,sectionStart:"nextPage",verticalAlign:"top"}}function at(r={}){let t=rt();r.pageWidth!==void 0&&(t.pageWidth=r.pageWidth),r.pageHeight!==void 0&&(t.pageHeight=r.pageHeight),r.orientation!==void 0&&(t.orientation=r.orientation),r.marginTop!==void 0&&(t.marginTop=r.marginTop),r.marginBottom!==void 0&&(t.marginBottom=r.marginBottom),r.marginLeft!==void 0&&(t.marginLeft=r.marginLeft),r.marginRight!==void 0&&(t.marginRight=r.marginRight);let e={type:"text",text:r.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:r.initialText?[e]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:t},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:nt()}},templateVariables:[],warnings:[]}}function Wt(r,t={}){return at({...t,initialText:r})}var T=class r{constructor(t){chunkH5NTJZO4_js.d(this,"_document");chunkH5NTJZO4_js.d(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await chunkNKJBKWYY_js.n(t);return new r(e)}static fromDocument(t){return new r(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return chunkN2UPYG75_js.a(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(s=>s.type==="paragraph"),a=n.map((s,i)=>{let c=this._getParagraphText(s),l=s.formatting?.styleId;return {index:i,preview:c.slice(0,t),style:l,isHeading:l?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(l),isListItem:!!s.listRendering,isEmpty:c.trim().length===0}}),o=(e.sections||[]).map((s,i)=>({index:i,paragraphCount:s.content?.length||0,pageSize:s.properties?.pageWidth&&s.properties?.pageHeight?{width:s.properties.pageWidth,height:s.properties.pageHeight}:void 0,isLandscape:s.properties?.orientation==="landscape",hasHeader:!!s.properties?.headerReferences?.length,hasFooter:!!s.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let a={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(a)}replaceRange(t,e,n={}){let a={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,a={}){let o={type:"insertTable",position:t,rows:e,columns:n,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,n={}){let a={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(a)}insertHyperlink(t,e,n={}){let a={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(a)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n=this._document.originalBuffer;if(!n)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:a}=await import('./processTemplate-5ZST2Q5L.js'),o=a(n,e),s=await chunkNKJBKWYY_js.n(o),i=new r(s);return i._pendingVariables={},i}async toBuffer(t){if(this._document.originalBuffer){if(t?.selective){let n=await Y(this._document,this._document.originalBuffer,t.selective);if(n)return this._document.originalBuffer=n,n}let e=await chunkDJI7XTMH_js.f(this._document);return this._document.originalBuffer=e,e}return chunkDJI7XTMH_js.l(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){return new r(chunkAARNCPWR_js.b(this._document,t))}_executeCommand(t){let e=new r(chunkAARNCPWR_js.a(this._document,t));return e._pendingVariables={...this._pendingVariables},e}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
|
|
2
|
+
`)}_getParagraphText(t){let e=[];for(let n of t.content)n.type==="run"?e.push(this._getRunText(n)):n.type==="hyperlink"&&e.push(this._getHyperlinkText(n));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(this._getRunText(n));return e.join("")}_getTableText(t){let e=[];for(let n of t.rows)for(let a of n.cells)for(let o of a.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let a=this._getRunText(n);a&&e.push({text:a,formatting:n.formatting});}else if(n.type==="hyperlink"){let a=n.href||"";for(let o of n.children)if(o.type==="run"){let s=this._getRunText(o);s&&e.push({text:s,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:a});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let a of n.content)if(a.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}};async function Gt(r){return T.fromBuffer(r)}function Zt(r){return T.fromDocument(r)}function ot(r,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:n=50}=t,a=r.package.document,o=a.content.filter(m=>m.type==="paragraph"),s=it(o,e,n),i=chunkN2UPYG75_js.a(r),c=st(r),l=ct(a),u=lt(a),g=pt(a),f=a.content.some(m=>m.type==="table"),y=ft(a),p=mt(a);return {paragraphCount:o.length,wordCount:u,characterCount:g,variables:i,variableCount:i.length,availableStyles:c,outline:s,sections:l,hasTables:f,hasImages:y,hasHyperlinks:p}}function Qt(r,t,e={}){let{contextChars:n=200,includeSuggestions:a=true}=e,s=r.package.document.content.filter(x=>x.type==="paragraph"),i=s[t.start.paragraphIndex];if(!i)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=h(i),l="";if(t.start.paragraphIndex===t.end.paragraphIndex)l=c.slice(t.start.offset,t.end.offset);else {let x=[];for(let C=t.start.paragraphIndex;C<=t.end.paragraphIndex;C++){let H=s[C];if(!H)continue;let w=h(H);C===t.start.paragraphIndex?x.push(w.slice(t.start.offset)):C===t.end.paragraphIndex?x.push(w.slice(0,t.end.offset)):x.push(w);}l=x.join(`
|
|
3
3
|
`);}let u=yt(s,t.start.paragraphIndex,t.start.offset,n),g=xt(s,t.end.paragraphIndex,t.end.offset,n),f=bt(i,t.start.offset),y=i.formatting||{},p={index:t.start.paragraphIndex,fullText:c,style:i.formatting?.styleId,wordCount:F(c)},m=false,b=Pt(i,t.start.offset),d=a?Ct(l):[];return {selectedText:l,range:t,formatting:f,paragraphFormatting:y,textBefore:u,textAfter:g,paragraph:p,inTable:m,inHyperlink:b,suggestedActions:d}}function K(r){let t=ot(r,{outlineMaxChars:50,maxOutlineParagraphs:10}),e=[`Document with ${t.paragraphCount} paragraphs, ${t.wordCount} words.`];t.hasTables&&e.push("Contains tables."),t.hasImages&&e.push("Contains images."),t.hasHyperlinks&&e.push("Contains hyperlinks."),t.variableCount>0&&e.push(`Has ${t.variableCount} template variables: ${t.variables.join(", ")}`);let n=t.outline.filter(a=>a.isHeading);if(n.length>0){e.push(`
|
|
4
4
|
Headings:`);for(let a of n.slice(0,5)){let o=a.headingLevel||1;e.push(`${" ".repeat(o-1)}- ${a.preview}`);}n.length>5&&e.push(` ... and ${n.length-5} more headings`);}return e.join(" ")}function it(r,t,e){let n=[];for(let a=0;a<Math.min(r.length,e);a++){let o=r[a],s=h(o),i=o.formatting?.styleId;n.push({index:a,preview:s.slice(0,t),style:i,isHeading:dt(i),headingLevel:ht(i),isListItem:!!o.listRendering,isEmpty:s.trim().length===0});}return n}function st(r){let t=r.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}function ct(r){return r.sections?r.sections.map((t,e)=>({index:e,paragraphCount:t.content?.length||0,pageSize:t.properties?.pageWidth&&t.properties?.pageHeight?{width:t.properties.pageWidth,height:t.properties.pageHeight}:void 0,isLandscape:t.properties?.orientation==="landscape",hasHeader:!!t.properties?.headerReferences?.length,hasFooter:!!t.properties?.footerReferences?.length})):[]}function lt(r){let t=0;for(let e of r.content)if(e.type==="paragraph"){let n=h(e);t+=F(n);}else e.type==="table"&&(t+=ut(e));return t}function F(r){return r.split(/\s+/).filter(e=>e.length>0).length}function pt(r){let t=0;for(let e of r.content)if(e.type==="paragraph"){let n=h(e);t+=n.length;}else e.type==="table"&&(t+=gt(e));return t}function ut(r){let t=0;for(let e of r.rows)for(let n of e.cells)for(let a of n.content)if(a.type==="paragraph"){let o=h(a);t+=F(o);}return t}function gt(r){let t=0;for(let e of r.rows)for(let n of e.cells)for(let a of n.content)if(a.type==="paragraph"){let o=h(a);t+=o.length;}return t}function h(r){let t=[];for(let e of r.content)e.type==="run"?t.push(k(e)):e.type==="hyperlink"&&t.push(v(e));return t.join("")}function k(r){return r.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function v(r){let t=[];for(let e of r.children)e.type==="run"&&t.push(k(e));return t.join("")}function ft(r){for(let t of r.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing")return true}}return false}function mt(r){for(let t of r.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function dt(r){return r?r.toLowerCase().includes("heading"):false}function ht(r){if(!r)return;let t=r.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function yt(r,t,e,n){let a=[],o=0,s=r[t];if(s){let l=h(s).slice(0,e);a.unshift(l),o+=l.length;}for(let c=t-1;c>=0&&o<n;c--){let l=r[c];if(!l)continue;let u=h(l);a.unshift(u),o+=u.length;}let i=a.join(`
|
|
5
5
|
`);return i.length>n?"..."+i.slice(-n):i}function xt(r,t,e,n){let a=[],o=0,s=r[t];if(s){let l=h(s).slice(e);a.push(l),o+=l.length;}for(let c=t+1;c<r.length&&o<n;c++){let l=r[c];if(!l)continue;let u=h(l);a.push(u),o+=u.length;}let i=a.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-Z35FA4M4.mjs';import {j,c,d,g,e,k as k$1,i,f,l}from'./chunk-I6LFWQFR.mjs';import {b,a as a$2}from'./chunk-M5F4SK3W.mjs';import {a,n}from'./chunk-CQRI4YUS.mjs';import {d as d$1}from'./chunk-TAUMSKRE.mjs';function G(r,t){let e=et(t),n=new RegExp(`<w:p[\\s][^>]*w14:paraId="${e}"`,"g"),a=[],o;for(;(o=n.exec(r))!==null;)a.push(o.index);if(a.length===0||a.length>1)return null;let s=a[0],i=s,c=0;for(;i<r.length;){let l=r.indexOf("<",i);if(l===-1)break;if(r.startsWith("<w:p",l)){let u=r[l+4];if(u===">"||u===" "||u==="/"){let g=r.indexOf(">",l);if(g===-1)break;if(r[g-1]==="/"){if(c===0)return {start:s,end:g+1};i=g+1;}else c++,i=g+1;}else i=l+1;}else if(r.startsWith("</w:p>",l)){if(c--,c===0)return {start:s,end:l+6};i=l+6;}else i=l+1;}return null}function Q(r,t){let e=G(r,t);return e?r.substring(e.start,e.end):null}function q(r){let t=0,e=/<w:p[\s>]/g,n;for(;(n=e.exec(r))!==null;){let a=n.index,o=r[a+4];(o===">"||o===" ")&&t++;}return t}function X(r){let t=new Map,e=/w14:paraId="([^"]+)"/g,n;for(;(n=e.exec(r))!==null;){let a=n[1];t.set(a,(t.get(a)||0)+1);}return t}function tt(r,t,e){if(e.size===0)return {safe:true};let n=X(r),a=X(t);for(let i of e){let c=n.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-original: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-original: ${i}`}}for(let i of e){let c=a.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-serialized: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-serialized: ${i}`}}let o=q(r),s=q(t);return o!==s?{safe:false,reason:`paragraph-count-mismatch: original=${o}, serialized=${s}`}:{safe:true}}function Z(r,t,e){if(e.size===0)return r;if(!tt(r,t,e).safe)return null;let a=[];for(let s of e){let i=G(r,s);if(!i)return null;let c=Q(t,s);if(!c)return null;a.push({start:i.start,end:i.end,newXml:c});}a.sort((s,i)=>i.start-s.start);let o=r;for(let{start:s,end:i,newXml:c}of a)o=o.substring(0,s)+c+o.substring(i);return o}function et(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function J(r){for(let t of r)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing"&&n.image?.src?.startsWith("data:")&&!n.image?.rId)return true}else if(e.type==="hyperlink"&&e.href&&!e.rId&&!e.anchor)return true}else if(t.type==="table"){for(let e of t.rows)for(let n of e.cells)if(J(n.content))return true}return false}async function Y(r,t,e$1){let{changedParaIds:n,structuralChange:a$1,hasUntrackedChanges:o}=e$1;if(a$1||o||!t)return null;let s=r.package.document.content;if(J(s))return null;let i$1=r.package.document.comments,c$1=i$1&&i$1.length>0,l=j(r);try{let g$1=await(await import('./lib-BCT2DRYI.mjs')).default.loadAsync(t),f=new Map;if(n.size>0){let p=g$1.file("word/document.xml");if(!p)return null;let m=await p.async("text"),b=c(r),d=Z(m,b,n);if(!d)return null;f.set("word/document.xml",d);}if(c$1){f.set("word/comments.xml",d(i$1));let p=g$1.file("[Content_Types].xml");if(p){let d=await p.async("text");d.includes("/word/comments.xml")||f.set("[Content_Types].xml",d.replace("</Types>",`<Override PartName="/word/comments.xml" ContentType="${g}"/></Types>`));}let m="word/_rels/document.xml.rels",b=g$1.file(m);if(b){let d=await b.async("text");if(!d.includes("comments.xml")){let x=e(d);f.set(m,d.replace("</Relationships>",`<Relationship Id="rId${x+1}" Type="${a.comments}" Target="comments.xml"/></Relationships>`));}}}for(let[p,m]of l)f.set(p,m);let y=g$1.file("docProps/core.xml");if(y){let p=await y.async("text");f.set("docProps/core.xml",k$1(p,{updateModifiedDate:!0}));}return await i(g$1,f)}catch{return null}}function nt(){return [{styleId:"Normal",type:"paragraph",name:"Normal",default:true,qFormat:true,uiPriority:0,rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},{styleId:"Title",type:"paragraph",name:"Title",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:10,rPr:{fontSize:52,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Subtitle",type:"paragraph",name:"Subtitle",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:11,rPr:{fontSize:30,color:{rgb:"666666"},fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Heading1",type:"paragraph",name:"Heading 1",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:40,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:400,spaceAfter:120,lineSpacing:240}},{styleId:"Heading2",type:"paragraph",name:"Heading 2",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:32,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:360,spaceAfter:80,lineSpacing:240}},{styleId:"Heading3",type:"paragraph",name:"Heading 3",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:28,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:320,spaceAfter:80,lineSpacing:240}},{styleId:"Heading4",type:"paragraph",name:"Heading 4",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:24,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:280,spaceAfter:80,lineSpacing:240}}]}function rt(){return {pageWidth:12240,pageHeight:15840,orientation:"portrait",marginTop:1440,marginBottom:1440,marginLeft:1440,marginRight:1440,headerDistance:720,footerDistance:720,gutter:0,columnCount:1,columnSpace:720,equalWidth:true,sectionStart:"nextPage",verticalAlign:"top"}}function at(r={}){let t=rt();r.pageWidth!==void 0&&(t.pageWidth=r.pageWidth),r.pageHeight!==void 0&&(t.pageHeight=r.pageHeight),r.orientation!==void 0&&(t.orientation=r.orientation),r.marginTop!==void 0&&(t.marginTop=r.marginTop),r.marginBottom!==void 0&&(t.marginBottom=r.marginBottom),r.marginLeft!==void 0&&(t.marginLeft=r.marginLeft),r.marginRight!==void 0&&(t.marginRight=r.marginRight);let e={type:"text",text:r.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:r.initialText?[e]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:t},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:nt()}},templateVariables:[],warnings:[]}}function Wt(r,t={}){return at({...t,initialText:r})}var T=class r{constructor(t){d$1(this,"_document");d$1(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await n(t);return new r(e)}static fromDocument(t){return new r(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return a$1(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(s=>s.type==="paragraph"),a=n.map((s,i)=>{let c=this._getParagraphText(s),l=s.formatting?.styleId;return {index:i,preview:c.slice(0,t),style:l,isHeading:l?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(l),isListItem:!!s.listRendering,isEmpty:c.trim().length===0}}),o=(e.sections||[]).map((s,i)=>({index:i,paragraphCount:s.content?.length||0,pageSize:s.properties?.pageWidth&&s.properties?.pageHeight?{width:s.properties.pageWidth,height:s.properties.pageHeight}:void 0,isLandscape:s.properties?.orientation==="landscape",hasHeader:!!s.properties?.headerReferences?.length,hasFooter:!!s.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let a={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(a)}replaceRange(t,e,n={}){let a={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,a={}){let o={type:"insertTable",position:t,rows:e,columns:n,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,n={}){let a={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(a)}insertHyperlink(t,e,n={}){let a={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(a)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n$1=this._document.originalBuffer;if(!n$1)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:a}=await import('./processTemplate-LRHXOWMZ.mjs'),o=a(n$1,e),s=await n(o),i=new r(s);return i._pendingVariables={},i}async toBuffer(t){if(this._document.originalBuffer){if(t?.selective){let n=await Y(this._document,this._document.originalBuffer,t.selective);if(n)return this._document.originalBuffer=n,n}let e=await f(this._document);return this._document.originalBuffer=e,e}return l(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){return new r(b(this._document,t))}_executeCommand(t){let e=new r(a$2(this._document,t));return e._pendingVariables={...this._pendingVariables},e}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
|
|
1
|
+
import {a as a$1}from'./chunk-FFNGY4AB.mjs';import {j,c,d,g,e,k as k$1,i,f,l}from'./chunk-TQATISQV.mjs';import {b,a as a$2}from'./chunk-M5F4SK3W.mjs';import {a,n}from'./chunk-OBTGZZLM.mjs';import {d as d$1}from'./chunk-TAUMSKRE.mjs';function G(r,t){let e=et(t),n=new RegExp(`<w:p[\\s][^>]*w14:paraId="${e}"`,"g"),a=[],o;for(;(o=n.exec(r))!==null;)a.push(o.index);if(a.length===0||a.length>1)return null;let s=a[0],i=s,c=0;for(;i<r.length;){let l=r.indexOf("<",i);if(l===-1)break;if(r.startsWith("<w:p",l)){let u=r[l+4];if(u===">"||u===" "||u==="/"){let g=r.indexOf(">",l);if(g===-1)break;if(r[g-1]==="/"){if(c===0)return {start:s,end:g+1};i=g+1;}else c++,i=g+1;}else i=l+1;}else if(r.startsWith("</w:p>",l)){if(c--,c===0)return {start:s,end:l+6};i=l+6;}else i=l+1;}return null}function Q(r,t){let e=G(r,t);return e?r.substring(e.start,e.end):null}function q(r){let t=0,e=/<w:p[\s>]/g,n;for(;(n=e.exec(r))!==null;){let a=n.index,o=r[a+4];(o===">"||o===" ")&&t++;}return t}function X(r){let t=new Map,e=/w14:paraId="([^"]+)"/g,n;for(;(n=e.exec(r))!==null;){let a=n[1];t.set(a,(t.get(a)||0)+1);}return t}function tt(r,t,e){if(e.size===0)return {safe:true};let n=X(r),a=X(t);for(let i of e){let c=n.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-original: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-original: ${i}`}}for(let i of e){let c=a.get(i)||0;if(c===0)return {safe:false,reason:`paraId-not-found-in-serialized: ${i}`};if(c>1)return {safe:false,reason:`duplicate-paraId-in-serialized: ${i}`}}let o=q(r),s=q(t);return o!==s?{safe:false,reason:`paragraph-count-mismatch: original=${o}, serialized=${s}`}:{safe:true}}function Z(r,t,e){if(e.size===0)return r;if(!tt(r,t,e).safe)return null;let a=[];for(let s of e){let i=G(r,s);if(!i)return null;let c=Q(t,s);if(!c)return null;a.push({start:i.start,end:i.end,newXml:c});}a.sort((s,i)=>i.start-s.start);let o=r;for(let{start:s,end:i,newXml:c}of a)o=o.substring(0,s)+c+o.substring(i);return o}function et(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function J(r){for(let t of r)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing"&&n.image?.src?.startsWith("data:")&&!n.image?.rId)return true}else if(e.type==="hyperlink"&&e.href&&!e.rId&&!e.anchor)return true}else if(t.type==="table"){for(let e of t.rows)for(let n of e.cells)if(J(n.content))return true}return false}async function Y(r,t,e$1){let{changedParaIds:n,structuralChange:a$1,hasUntrackedChanges:o}=e$1;if(a$1||o||!t)return null;let s=r.package.document.content;if(J(s))return null;let i$1=r.package.document.comments,c$1=i$1&&i$1.length>0,l=j(r);try{let g$1=await(await import('./lib-BCT2DRYI.mjs')).default.loadAsync(t),f=new Map;if(n.size>0){let p=g$1.file("word/document.xml");if(!p)return null;let m=await p.async("text"),b=c(r),d=Z(m,b,n);if(!d)return null;f.set("word/document.xml",d);}if(c$1){f.set("word/comments.xml",d(i$1));let p=g$1.file("[Content_Types].xml");if(p){let d=await p.async("text");d.includes("/word/comments.xml")||f.set("[Content_Types].xml",d.replace("</Types>",`<Override PartName="/word/comments.xml" ContentType="${g}"/></Types>`));}let m="word/_rels/document.xml.rels",b=g$1.file(m);if(b){let d=await b.async("text");if(!d.includes("comments.xml")){let x=e(d);f.set(m,d.replace("</Relationships>",`<Relationship Id="rId${x+1}" Type="${a.comments}" Target="comments.xml"/></Relationships>`));}}}for(let[p,m]of l)f.set(p,m);let y=g$1.file("docProps/core.xml");if(y){let p=await y.async("text");f.set("docProps/core.xml",k$1(p,{updateModifiedDate:!0}));}return await i(g$1,f)}catch{return null}}function nt(){return [{styleId:"Normal",type:"paragraph",name:"Normal",default:true,qFormat:true,uiPriority:0,rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},{styleId:"Title",type:"paragraph",name:"Title",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:10,rPr:{fontSize:52,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Subtitle",type:"paragraph",name:"Subtitle",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:11,rPr:{fontSize:30,color:{rgb:"666666"},fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Heading1",type:"paragraph",name:"Heading 1",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:40,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:400,spaceAfter:120,lineSpacing:240}},{styleId:"Heading2",type:"paragraph",name:"Heading 2",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:32,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:360,spaceAfter:80,lineSpacing:240}},{styleId:"Heading3",type:"paragraph",name:"Heading 3",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:28,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:320,spaceAfter:80,lineSpacing:240}},{styleId:"Heading4",type:"paragraph",name:"Heading 4",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:24,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:280,spaceAfter:80,lineSpacing:240}}]}function rt(){return {pageWidth:12240,pageHeight:15840,orientation:"portrait",marginTop:1440,marginBottom:1440,marginLeft:1440,marginRight:1440,headerDistance:720,footerDistance:720,gutter:0,columnCount:1,columnSpace:720,equalWidth:true,sectionStart:"nextPage",verticalAlign:"top"}}function at(r={}){let t=rt();r.pageWidth!==void 0&&(t.pageWidth=r.pageWidth),r.pageHeight!==void 0&&(t.pageHeight=r.pageHeight),r.orientation!==void 0&&(t.orientation=r.orientation),r.marginTop!==void 0&&(t.marginTop=r.marginTop),r.marginBottom!==void 0&&(t.marginBottom=r.marginBottom),r.marginLeft!==void 0&&(t.marginLeft=r.marginLeft),r.marginRight!==void 0&&(t.marginRight=r.marginRight);let e={type:"text",text:r.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:r.initialText?[e]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:t},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:nt()}},templateVariables:[],warnings:[]}}function Wt(r,t={}){return at({...t,initialText:r})}var T=class r{constructor(t){d$1(this,"_document");d$1(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await n(t);return new r(e)}static fromDocument(t){return new r(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return a$1(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(s=>s.type==="paragraph"),a=n.map((s,i)=>{let c=this._getParagraphText(s),l=s.formatting?.styleId;return {index:i,preview:c.slice(0,t),style:l,isHeading:l?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(l),isListItem:!!s.listRendering,isEmpty:c.trim().length===0}}),o=(e.sections||[]).map((s,i)=>({index:i,paragraphCount:s.content?.length||0,pageSize:s.properties?.pageWidth&&s.properties?.pageHeight?{width:s.properties.pageWidth,height:s.properties.pageHeight}:void 0,isLandscape:s.properties?.orientation==="landscape",hasHeader:!!s.properties?.headerReferences?.length,hasFooter:!!s.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let a={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(a)}replaceRange(t,e,n={}){let a={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,a={}){let o={type:"insertTable",position:t,rows:e,columns:n,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,n={}){let a={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(a)}insertHyperlink(t,e,n={}){let a={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(a)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n$1=this._document.originalBuffer;if(!n$1)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:a}=await import('./processTemplate-LRHXOWMZ.mjs'),o=a(n$1,e),s=await n(o),i=new r(s);return i._pendingVariables={},i}async toBuffer(t){if(this._document.originalBuffer){if(t?.selective){let n=await Y(this._document,this._document.originalBuffer,t.selective);if(n)return this._document.originalBuffer=n,n}let e=await f(this._document);return this._document.originalBuffer=e,e}return l(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){return new r(b(this._document,t))}_executeCommand(t){let e=new r(a$2(this._document,t));return e._pendingVariables={...this._pendingVariables},e}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
|
|
2
2
|
`)}_getParagraphText(t){let e=[];for(let n of t.content)n.type==="run"?e.push(this._getRunText(n)):n.type==="hyperlink"&&e.push(this._getHyperlinkText(n));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(this._getRunText(n));return e.join("")}_getTableText(t){let e=[];for(let n of t.rows)for(let a of n.cells)for(let o of a.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let a=this._getRunText(n);a&&e.push({text:a,formatting:n.formatting});}else if(n.type==="hyperlink"){let a=n.href||"";for(let o of n.children)if(o.type==="run"){let s=this._getRunText(o);s&&e.push({text:s,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:a});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let a of n.content)if(a.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}};async function Gt(r){return T.fromBuffer(r)}function Zt(r){return T.fromDocument(r)}function ot(r,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:n=50}=t,a=r.package.document,o=a.content.filter(m=>m.type==="paragraph"),s=it(o,e,n),i=a$1(r),c=st(r),l=ct(a),u=lt(a),g=pt(a),f=a.content.some(m=>m.type==="table"),y=ft(a),p=mt(a);return {paragraphCount:o.length,wordCount:u,characterCount:g,variables:i,variableCount:i.length,availableStyles:c,outline:s,sections:l,hasTables:f,hasImages:y,hasHyperlinks:p}}function Qt(r,t,e={}){let{contextChars:n=200,includeSuggestions:a=true}=e,s=r.package.document.content.filter(x=>x.type==="paragraph"),i=s[t.start.paragraphIndex];if(!i)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=h(i),l="";if(t.start.paragraphIndex===t.end.paragraphIndex)l=c.slice(t.start.offset,t.end.offset);else {let x=[];for(let C=t.start.paragraphIndex;C<=t.end.paragraphIndex;C++){let H=s[C];if(!H)continue;let w=h(H);C===t.start.paragraphIndex?x.push(w.slice(t.start.offset)):C===t.end.paragraphIndex?x.push(w.slice(0,t.end.offset)):x.push(w);}l=x.join(`
|
|
3
3
|
`);}let u=yt(s,t.start.paragraphIndex,t.start.offset,n),g=xt(s,t.end.paragraphIndex,t.end.offset,n),f=bt(i,t.start.offset),y=i.formatting||{},p={index:t.start.paragraphIndex,fullText:c,style:i.formatting?.styleId,wordCount:F(c)},m=false,b=Pt(i,t.start.offset),d=a?Ct(l):[];return {selectedText:l,range:t,formatting:f,paragraphFormatting:y,textBefore:u,textAfter:g,paragraph:p,inTable:m,inHyperlink:b,suggestedActions:d}}function K(r){let t=ot(r,{outlineMaxChars:50,maxOutlineParagraphs:10}),e=[`Document with ${t.paragraphCount} paragraphs, ${t.wordCount} words.`];t.hasTables&&e.push("Contains tables."),t.hasImages&&e.push("Contains images."),t.hasHyperlinks&&e.push("Contains hyperlinks."),t.variableCount>0&&e.push(`Has ${t.variableCount} template variables: ${t.variables.join(", ")}`);let n=t.outline.filter(a=>a.isHeading);if(n.length>0){e.push(`
|
|
4
4
|
Headings:`);for(let a of n.slice(0,5)){let o=a.headingLevel||1;e.push(`${" ".repeat(o-1)}- ${a.preview}`);}n.length>5&&e.push(` ... and ${n.length-5} more headings`);}return e.join(" ")}function it(r,t,e){let n=[];for(let a=0;a<Math.min(r.length,e);a++){let o=r[a],s=h(o),i=o.formatting?.styleId;n.push({index:a,preview:s.slice(0,t),style:i,isHeading:dt(i),headingLevel:ht(i),isListItem:!!o.listRendering,isEmpty:s.trim().length===0});}return n}function st(r){let t=r.package.styles;if(!t?.styles)return [];let e=[];for(let[n,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}function ct(r){return r.sections?r.sections.map((t,e)=>({index:e,paragraphCount:t.content?.length||0,pageSize:t.properties?.pageWidth&&t.properties?.pageHeight?{width:t.properties.pageWidth,height:t.properties.pageHeight}:void 0,isLandscape:t.properties?.orientation==="landscape",hasHeader:!!t.properties?.headerReferences?.length,hasFooter:!!t.properties?.footerReferences?.length})):[]}function lt(r){let t=0;for(let e of r.content)if(e.type==="paragraph"){let n=h(e);t+=F(n);}else e.type==="table"&&(t+=ut(e));return t}function F(r){return r.split(/\s+/).filter(e=>e.length>0).length}function pt(r){let t=0;for(let e of r.content)if(e.type==="paragraph"){let n=h(e);t+=n.length;}else e.type==="table"&&(t+=gt(e));return t}function ut(r){let t=0;for(let e of r.rows)for(let n of e.cells)for(let a of n.content)if(a.type==="paragraph"){let o=h(a);t+=F(o);}return t}function gt(r){let t=0;for(let e of r.rows)for(let n of e.cells)for(let a of n.content)if(a.type==="paragraph"){let o=h(a);t+=o.length;}return t}function h(r){let t=[];for(let e of r.content)e.type==="run"?t.push(k(e)):e.type==="hyperlink"&&t.push(v(e));return t.join("")}function k(r){return r.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function v(r){let t=[];for(let e of r.children)e.type==="run"&&t.push(k(e));return t.join("")}function ft(r){for(let t of r.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing")return true}}return false}function mt(r){for(let t of r.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function dt(r){return r?r.toLowerCase().includes("heading"):false}function ht(r){if(!r)return;let t=r.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function yt(r,t,e,n){let a=[],o=0,s=r[t];if(s){let l=h(s).slice(0,e);a.unshift(l),o+=l.length;}for(let c=t-1;c>=0&&o<n;c--){let l=r[c];if(!l)continue;let u=h(l);a.unshift(u),o+=u.length;}let i=a.join(`
|